Bug 459938 - Fix yuv2rgb in liboggplay to display correct colours - rs=roc

This commit is contained in:
Chris Double 2008-10-29 07:58:22 +13:00
Родитель ea3a3562ec
Коммит eb27d2880d
4 изменённых файлов: 118 добавлений и 28 удалений

Просмотреть файл

@ -6,3 +6,6 @@ the Mozilla build system.
http://svn.annodex.net/liboggplay/trunk/
The svn revision number used was r3729.
The patch from Annodex trac ticket 421 is applied to fix bug 459938:
http://trac.annodex.net/ticket/421

Просмотреть файл

@ -357,29 +357,27 @@ void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
ptro2 = ptro;
for (j = 0; j < yuv->y_width; j += 2) {
short pr, pg, pb;
short pr, pg, pb, y;
short r, g, b;
//pr = ((128 + (ptrv[j/2] - 128) * 292) >> 8) - 16; /* 1.14 * 256 */
pr = (-41344 + ptrv[j/2] * 292) >> 8;
//pg = ((128 - (ptru[j/2] - 128) * 101 - (ptrv[j/2] - 128) * 149) >> 8)-16;
// /* 0.395 & 0.581 */
pg = (28032 - ptru[j/2] * 101 - ptrv[j/2] * 149) >> 8;
//pb = ((128 + (ptru[j/2] - 128) * 520) >> 8) - 16; /* 2.032 */
pb = (-70528 + ptru[j/2] * 520) >> 8;
pr = (-56992 + ptrv[j/2] * 409) >> 8;
pg = (34784 - ptru[j/2] * 100 - ptrv[j/2] * 208) >> 8;
pb = (-70688 + ptru[j/2] * 516) >> 8;
r = ptry[j] + pr;
g = ptry[j] + pg;
b = ptry[j] + pb;
y = 298*ptry[j] >> 8;
r = y + pr;
g = y + pg;
b = y + pb;
*ptro2++ = CLAMP(r);
*ptro2++ = CLAMP(g);
*ptro2++ = CLAMP(b);
*ptro2++ = 255;
r = ptry[j + 1] + pr;
g = ptry[j + 1] + pg;
b = ptry[j + 1] + pb;
y = 298*ptry[j + 1] >> 8;
r = y + pr;
g = y + pg;
b = y + pb;
*ptro2++ = CLAMP(r);
*ptro2++ = CLAMP(g);
@ -409,29 +407,27 @@ void oggplay_yuv2bgr(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
ptro2 = ptro;
for (j = 0; j < yuv->y_width; j += 2) {
short pr, pg, pb;
short pr, pg, pb, y;
short r, g, b;
//pr = ((128 + (ptrv[j/2] - 128) * 292) >> 8) - 16; /* 1.14 * 256 */
pr = (-41344 + ptrv[j/2] * 292) >> 8;
//pg = ((128 - (ptru[j/2] - 128) * 101 - (ptrv[j/2] - 128) * 149) >> 8)-16;
// /* 0.395 & 0.581 */
pg = (28032 - ptru[j/2] * 101 - ptrv[j/2] * 149) >> 8;
//pb = ((128 + (ptru[j/2] - 128) * 520) >> 8) - 16; /* 2.032 */
pb = (-70528 + ptru[j/2] * 520) >> 8;
pr = (-56992 + ptrv[j/2] * 409) >> 8;
pg = (34784 - ptru[j/2] * 100 - ptrv[j/2] * 208) >> 8;
pb = (-70688 + ptru[j/2] * 516) >> 8;
r = ptry[j] + pr;
g = ptry[j] + pg;
b = ptry[j] + pb;
y = 298*ptry[j] >> 8;
r = y + pr;
g = y + pg;
b = y + pb;
*ptro2++ = CLAMP(b);
*ptro2++ = CLAMP(g);
*ptro2++ = CLAMP(r);
*ptro2++ = 255;
r = ptry[j + 1] + pr;
g = ptry[j + 1] + pg;
b = ptry[j + 1] + pb;
y = 298*ptry[j + 1] >> 8;
r = y + pr;
g = y + pg;
b = y + pb;
*ptro2++ = CLAMP(b);
*ptro2++ = CLAMP(g);

Просмотреть файл

@ -34,3 +34,6 @@ sed s/\#include\ \"config_win32.h\"//g $1/src/liboggplay/oggplay_private.h >./sr
sed s/\#include\ \<config.h\>/\#ifdef\ WIN32\\n\#include\ \"config_win32.h\"\\n\#else\\n\#include\ \<config.h\>\\n\#endif/g ./src/liboggplay/oggplay_private.h1 >./src/liboggplay/oggplay_private.h
rm ./src/liboggplay/oggplay_private.h1
sed s/\#ifdef\ HAVE_INTTYPES_H/\#if\ HAVE_INTTYPES_H/g $1/src/liboggplay/oggplay_data.c >./src/liboggplay/oggplay_data.c
cd ./src/liboggplay
patch <../../yuv2rgb-vanilla-fix.patch
cd ../..

Просмотреть файл

@ -0,0 +1,88 @@
Index: oggplay_yuv2rgb.c
===================================================================
--- oggplay_yuv2rgb.c (revision 3733)
+++ oggplay_yuv2rgb.c (working copy)
@@ -357,29 +357,27 @@
ptro2 = ptro;
for (j = 0; j < yuv->y_width; j += 2) {
- short pr, pg, pb;
+ short pr, pg, pb, y;
short r, g, b;
- //pr = ((128 + (ptrv[j/2] - 128) * 292) >> 8) - 16; /* 1.14 * 256 */
- pr = (-41344 + ptrv[j/2] * 292) >> 8;
- //pg = ((128 - (ptru[j/2] - 128) * 101 - (ptrv[j/2] - 128) * 149) >> 8)-16;
- // /* 0.395 & 0.581 */
- pg = (28032 - ptru[j/2] * 101 - ptrv[j/2] * 149) >> 8;
- //pb = ((128 + (ptru[j/2] - 128) * 520) >> 8) - 16; /* 2.032 */
- pb = (-70528 + ptru[j/2] * 520) >> 8;
+ pr = (-56992 + ptrv[j/2] * 409) >> 8;
+ pg = (34784 - ptru[j/2] * 100 - ptrv[j/2] * 208) >> 8;
+ pb = (-70688 + ptru[j/2] * 516) >> 8;
- r = ptry[j] + pr;
- g = ptry[j] + pg;
- b = ptry[j] + pb;
+ y = 298*ptry[j] >> 8;
+ r = y + pr;
+ g = y + pg;
+ b = y + pb;
*ptro2++ = CLAMP(r);
*ptro2++ = CLAMP(g);
*ptro2++ = CLAMP(b);
*ptro2++ = 255;
- r = ptry[j + 1] + pr;
- g = ptry[j + 1] + pg;
- b = ptry[j + 1] + pb;
+ y = 298*ptry[j + 1] >> 8;
+ r = y + pr;
+ g = y + pg;
+ b = y + pb;
*ptro2++ = CLAMP(r);
*ptro2++ = CLAMP(g);
@@ -409,29 +407,27 @@
ptro2 = ptro;
for (j = 0; j < yuv->y_width; j += 2) {
- short pr, pg, pb;
+ short pr, pg, pb, y;
short r, g, b;
- //pr = ((128 + (ptrv[j/2] - 128) * 292) >> 8) - 16; /* 1.14 * 256 */
- pr = (-41344 + ptrv[j/2] * 292) >> 8;
- //pg = ((128 - (ptru[j/2] - 128) * 101 - (ptrv[j/2] - 128) * 149) >> 8)-16;
- // /* 0.395 & 0.581 */
- pg = (28032 - ptru[j/2] * 101 - ptrv[j/2] * 149) >> 8;
- //pb = ((128 + (ptru[j/2] - 128) * 520) >> 8) - 16; /* 2.032 */
- pb = (-70528 + ptru[j/2] * 520) >> 8;
+ pr = (-56992 + ptrv[j/2] * 409) >> 8;
+ pg = (34784 - ptru[j/2] * 100 - ptrv[j/2] * 208) >> 8;
+ pb = (-70688 + ptru[j/2] * 516) >> 8;
- r = ptry[j] + pr;
- g = ptry[j] + pg;
- b = ptry[j] + pb;
+ y = 298*ptry[j] >> 8;
+ r = y + pr;
+ g = y + pg;
+ b = y + pb;
*ptro2++ = CLAMP(b);
*ptro2++ = CLAMP(g);
*ptro2++ = CLAMP(r);
*ptro2++ = 255;
- r = ptry[j + 1] + pr;
- g = ptry[j + 1] + pg;
- b = ptry[j + 1] + pb;
+ y = 298*ptry[j + 1] >> 8;
+ r = y + pr;
+ g = y + pg;
+ b = y + pb;
*ptro2++ = CLAMP(b);
*ptro2++ = CLAMP(g);