changeset 1052:f529b09e64b7 libavcodec

Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images when this conversion was used. I suspect that the same bug may be lurking in other conversions. [The assumption was that the linesize was equal to the width for both the source and destination images. This turns out not to be true in some cases.]
author philipjsg
date Sat, 08 Feb 2003 15:34:25 +0000
parents e5a9dbf597d4
children f07fd48c23d4
files imgconvert.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/imgconvert.c	Sat Feb 08 12:00:57 2003 +0000
+++ b/imgconvert.c	Sat Feb 08 15:34:25 2003 +0000
@@ -574,8 +574,8 @@
     cb = dst->data[1];                                                  \
     cr = dst->data[2];                                                  \
                                                                         \
-    wrap = width;                                                       \
-    wrap3 = width * BPP;                                                \
+    wrap = dst->linesize[0];                                            \
+    wrap3 = src->linesize[0];                                           \
     p = src->data[0];                                                   \
     for(y=0;y<height;y+=2) {                                            \
         for(x=0;x<width;x+=2) {                                         \
@@ -620,8 +620,10 @@
             p += -wrap3 + 2 * BPP;                                      \
             lum += -wrap + 2;                                           \
         }                                                               \
-        p += wrap3;                                                     \
-        lum += wrap;                                                    \
+        p += wrap3 + (wrap3 - width * BPP);                             \
+        lum += wrap + (wrap - width);                                   \
+        cb += dst->linesize[1] - width / 2;                             \
+        cr += dst->linesize[2] - width / 2;                             \
     }                                                                   \
 }                                                                       \
                                                                         \