[Ffmpeg-devel] [PATCH] lowres chroma bug

Oleg Metelitsa oleg
Fri Feb 9 08:42:52 CET 2007


Hello,

> 3)  We can add two extra pixels to image in lowres=2 mode:
> image_stride =  image_width  +  2
> chroma_stride = image_width/2 + 2
> Then  the garbage will be written to those extra (dummy) pixels rather
> than to the beginning of the next row.

Please,  find  the  patch  3)  attached.  It  may be not so interested
comparing  to  the  patches  proposed earlier. But the advantage is it
does not change non lowres H.264 operation.

Index: libavcodec/utils.c
===================================================================
--- /libavcodec/utils.c (revision 7890)
+++ /libavcodec/utils.c (working copy)
@@ -279,7 +279,9 @@
         if(!(s->flags&CODEC_FLAG_EMU_EDGE)){
             w+= EDGE_WIDTH*2;
             h+= EDGE_WIDTH*2;
-        }
+        } else if(s->lowres==2)
+            w+= 4;
+
         avpicture_fill(&picture, NULL, s->pix_fmt, w, h);
         pixel_size= picture.linesize[0]*8 / w;

The  idea  is  to  add 4 pixels before calling avpicture_fill() inside
avcodec_default_get_buffer  function.  As  a  result  4 pixels will be
added to linesize[0] and 2 pixels to linesize[1] and linesize[2].

All  sizes will be aligned inside avpicture_fill(). For example, if we
have  coded_width=640  and  width=160 after applying lowres=2 mode, we
will  have linesize[1]=176 and linesize[1]=88 as a result of alignment
operation.

Regards,

Oleg Metelitsa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avcodec_default_get_buffer.diff
Type: application/octet-stream
Size: 562 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070209/9e245609/attachment.obj>



More information about the ffmpeg-devel mailing list