[FFmpeg-devel] [PATCH] yuv-> rgb C unscaled conversion broken for resolutions not multiple of 8

Reimar Döffinger Reimar.Doeffinger
Wed May 30 17:05:12 CEST 2007


Hello,
unscaled yuv->rgb pure C conversion does miss some rightmost pixels if
the width is not divisible by 8, as exhibited in
http://movies.apple.com/trailers/images/hd_btn2_480p.mov by doing
mplayer hd_btn2_480p.mov -vf format=rgb24,scale -loop 0
Attached patch at least fixes some of the conversions for the case where
width is divisible by 4.
Comments?

Greetings from LinuxTag bug fixing association,
Reimar D?ffinger
-------------- next part --------------
Index: libswscale/yuv2rgb.c
===================================================================
--- libswscale/yuv2rgb.c	(revision 23416)
+++ libswscale/yuv2rgb.c	(working copy)
@@ -276,7 +276,7 @@
             int attribute_unused U, V;\
             int Y;\
 
-#define EPILOG(dst_delta)\
+#define EPILOG1(dst_delta)\
             pu += 4;\
             pv += 4;\
             py_1 += 8;\
@@ -284,10 +284,20 @@
             dst_1 += dst_delta;\
             dst_2 += dst_delta;\
         }\
+        if (c->dstW & 4) {
+            int attribute_unused U, V;\
+            int Y;\
+
+#define EPILOG2()\
+        }\
     }\
     return srcSliceH;\
 }
 
+#define EPILOG(dst_delta)\
+    EPILOG1(dst_delta)\
+    EPILOG2()
+
 PROLOG(yuv2rgb_c_32, uint32_t)
     RGB(0);
     DST1(0);
@@ -304,8 +314,16 @@
     RGB(3);
     DST2(3);
     DST1(3);
-EPILOG(8)
+EPILOG1(8)
+    RGB(0);
+    DST1(0);
+    DST2(0);
 
+    RGB(1);
+    DST2(1);
+    DST1(1);
+EPILOG2()
+
 PROLOG(yuv2rgb_c_24_rgb, uint8_t)
     RGB(0);
     DST1RGB(0);
@@ -322,8 +340,16 @@
     RGB(3);
     DST2RGB(3);
     DST1RGB(3);
-EPILOG(24)
+EPILOG1(24)
+    RGB(0);
+    DST1RGB(0);
+    DST2RGB(0);
 
+    RGB(1);
+    DST2RGB(1);
+    DST1RGB(1);
+EPILOG2()
+
 // only trivial mods from yuv2rgb_c_24_rgb
 PROLOG(yuv2rgb_c_24_bgr, uint8_t)
     RGB(0);
@@ -341,8 +367,16 @@
     RGB(3);
     DST2BGR(3);
     DST1BGR(3);
-EPILOG(24)
+EPILOG1(24)
+    RGB(0);
+    DST1BGR(0);
+    DST2BGR(0);
 
+    RGB(1);
+    DST2BGR(1);
+    DST1BGR(1);
+EPILOG2()
+
 // This is exactly the same code as yuv2rgb_c_32 except for the types of
 // r, g, b, dst_1, dst_2
 PROLOG(yuv2rgb_c_16, uint16_t)



More information about the ffmpeg-devel mailing list