[FFmpeg-devel] [PATCH] Video decoder and demuxer for AMV files

Aurelien Jacobs aurel
Tue Sep 25 21:02:47 CEST 2007


Vladimir Voroshilov wrote:

> 2007/9/24, Vladimir Voroshilov <voroshil at gmail.com>:
> > 2007/9/24, Aurelien Jacobs <aurel at gnuage.org>:
> > > On Mon, 24 Sep 2007 20:14:36 +0700
> > > "Vladimir Voroshilov" <voroshil at gmail.com> wrote:
> > >
> > > > Hi, All.
> > > >
> > > > amv_codec_ffmpeg.patch: Decoder for modified MJPEG, used it AMV files.
> > > >
> 
> [...]
> 
> > Thank you for review.
> > Fixed version attached.
> >
> 
> I forget to say that resulting image is flipped upside-down.
> Please anybody help me with fixing this.

Short answer: negative stride

Longer answer: Look at this code from mjpeg_decode_scan():
   ptr = s->picture.data[c] +
            (((s->linesize[c] * (v * mb_y + y) * 8) +
            (h * mb_x + x) * 8) >> s->avctx->lowres);

To flip the image upside-down, s->picture.data[c] need to be
replaced by a pointer to (s->picture.data[c] + size of the image
buffer - size of one line), and s->linesize[c] must be negative.

That's the basic principle. You will probably need to do other
small related changes. And ensure that the code still behave
the same way as it does now for other mjpeg codecs.

Aurel




More information about the ffmpeg-devel mailing list