[FFmpeg-cvslog] r20552 - trunk/libavcodec/mjpegdec.c

Michael Niedermayer michaelni
Fri Nov 20 14:21:53 CET 2009


On Thu, Nov 19, 2009 at 03:10:23PM +0100, Reimar D?ffinger wrote:
> On Thu, Nov 19, 2009 at 12:49:03PM +0100, reimar wrote:
> > Author: reimar
> > Date: Thu Nov 19 12:49:03 2009
> > New Revision: 20552
> > 
> > Log:
> > Disable image flipping during JPEG decoding if CODEC_FLAG_EMU_EDGE is set
> > instead of either aborting on the assert or crashing due to writing beyond
> > the array due to insufficient padding.
> > 
> > Modified:
> >    trunk/libavcodec/mjpegdec.c
> > 
> > Modified: trunk/libavcodec/mjpegdec.c
> > ==============================================================================
> > --- trunk/libavcodec/mjpegdec.c	Thu Nov 19 01:05:30 2009	(r20551)
> > +++ trunk/libavcodec/mjpegdec.c	Thu Nov 19 12:49:03 2009	(r20552)
> > @@ -770,6 +770,10 @@ static int mjpeg_decode_scan(MJpegDecode
> >      uint8_t* data[MAX_COMPONENTS];
> >      int linesize[MAX_COMPONENTS];
> >  
> > +    if(s->flipped && s->avctx->flags & CODEC_FLAG_EMU_EDGE) {
> > +        av_log(s->avctx, AV_LOG_ERROR, "Can not flip image with CODEC_FLAG_EMU_EDGE set!\n");
> > +        s->flipped = 0;
> > +    }
> >      for(i=0; i < nb_components; i++) {
> >          int c = s->comp_index[i];
> >          data[c] = s->picture.data[c];
> > @@ -777,7 +781,6 @@ static int mjpeg_decode_scan(MJpegDecode
> >          s->coefs_finished[c] |= 1;
> >          if(s->flipped) {
> >              //picture should be flipped upside-down for this codec
> > -            assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE));
> >              data[c] += (linesize[c] * (s->v_scount[i] * (8 * s->mb_height -((s->height/s->v_max)&7)) - 1 ));
> 
> I just realize that this is more strict than necessary, it is only an
> issue when the height does not match the block size, so the following one should
> be ok, what do you think?
> There is the additional issue that the check for flipped is not correct,
> since only videos encoded with the Intel MJPEG VFW encoder are flipped,
> wereas JPEGs generated by some cameras also use the Intel library, just
> not the VFW codec and aren't flipped, sample here:
> http://johannes.eventify.de/kiste-temp/Sample_slomo_kiste.avi
> (hard see, but it plays flipped because s->flipped is incorrectly 1).
> 
> Index: libavcodec/mjpegdec.c
> ===================================================================
> --- libavcodec/mjpegdec.c       (revision 20552)
> +++ libavcodec/mjpegdec.c       (working copy)
> @@ -770,7 +770,7 @@
>      uint8_t* data[MAX_COMPONENTS];
>      int linesize[MAX_COMPONENTS];
>  
> -    if(s->flipped && s->avctx->flags & CODEC_FLAG_EMU_EDGE) {
> +    if(s->flipped && (s->avctx->flags & CODEC_FLAG_EMU_EDGE) && ((s->height/s->v_max)&7)) {

I dont think this is correct
The test should be s->height % (s->v_max*8)

besides this the fliped code also looks suspect

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/attachments/20091120/b59eb7ce/attachment.pgp>



More information about the ffmpeg-cvslog mailing list