gecko-dev/media/liboggplay/bug488951_yuv_fix.patch
Matthew Gregan bd64741ff1 bug 488951. Fix YUV conversion to deal with odd-size video frames. rs=roc
--HG--
extra : rebase_source : fdeb49a21a33103fe1591a3399b44cf4107c90d4
2009-05-20 14:46:58 +12:00

44 lines
1.7 KiB
Diff

diff --git a/media/liboggplay/src/liboggplay/oggplay_yuv2rgb_template.h b/media/liboggplay/src/liboggplay/oggplay_yuv2rgb_template.h
--- a/media/liboggplay/src/liboggplay/oggplay_yuv2rgb_template.h
+++ b/media/liboggplay/src/liboggplay/oggplay_yuv2rgb_template.h
@@ -55,28 +55,38 @@ static void
CONVERT \
} \
/* \
* the video frame is not the multiple of NUM_PIXELS, \
* thus we have to deal with remaning pixels using \
* vanilla implementation. \
*/ \
if (r) { \
+ /* if there's only 1 remaining pixel to process \
+ and the luma width is odd, the for loop above \
+ has already advanced pu and pv too far. */ \
+ if (r==1 && yuv->y_width&1) { \
+ pu -= 1; pv -= 1; \
+ } \
for \
( \
j=(yuv->y_width-r); j < yuv->y_width; \
++j, \
dst += 4, \
py += 1 \
) \
{ \
LOOKUP_COEFFS \
VANILLA_YUV2RGB_PIXEL(py[0], ruv, guv, buv) \
VANILLA_OUT(dst, r, g, b) \
- if (!(j%2)) { \
+ /* advance chroma ptrs every second sample, except \
+ when the luma width is odd, in which case the \
+ chroma samples are truncated and we must reuse \
+ the previous chroma sample */ \
+ if (j%2 && !(j+1==yuv->y_width-1 && yuv->y_width&1)) { \
pu += 1; pv += 1; \
} \
} \
} \
\
ptro += rgb->rgb_width * 4; \
ptry += yuv->y_width; \
\