gecko/media/liboggplay/yuv2argb.patch

90 lines
2.6 KiB
Diff
Raw Normal View History

diff --git a/media/liboggplay/include/oggplay/oggplay_tools.h b/media/liboggplay/include/oggplay/oggplay_tools.h
index 30531a4..19fe709 100644
--- a/media/liboggplay/include/oggplay/oggplay_tools.h
+++ b/media/liboggplay/include/oggplay/oggplay_tools.h
@@ -75,6 +75,9 @@ void
oggplay_yuv2rgb(OggPlayYUVChannels* yuv, OggPlayRGBChannels * rgb);
void
+oggplay_yuv2argb(OggPlayYUVChannels* yuv, OggPlayRGBChannels * rgb);
+
+void
oggplay_yuv2bgr(OggPlayYUVChannels* yuv, OggPlayRGBChannels * rgb);
ogg_int64_t
diff --git a/media/liboggplay/src/liboggplay/config.h b/media/liboggplay/src/liboggplay/config.h
index e1754e4..46faa8a 100644
--- a/media/liboggplay/src/liboggplay/config.h
+++ b/media/liboggplay/src/liboggplay/config.h
@@ -86,3 +86,8 @@
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
#undef HAVE_GLUT
+
+#include "prcpucfg.h"
+#ifdef IS_BIG_ENDIAN
+#define WORDS_BIGENDIAN
+#endif
diff --git a/media/liboggplay/src/liboggplay/oggplay_yuv2rgb.c b/media/liboggplay/src/liboggplay/oggplay_yuv2rgb.c
index 0e2cef0..e070dc7 100644
--- a/media/liboggplay/src/liboggplay/oggplay_yuv2rgb.c
+++ b/media/liboggplay/src/liboggplay/oggplay_yuv2rgb.c
@@ -396,6 +396,57 @@ void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
}
}
+/* Vanilla implementation if YUV->ARGB conversion */
+void oggplay_yuv2argb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
+
+ unsigned char * ptry = yuv->ptry;
+ unsigned char * ptru = yuv->ptru;
+ unsigned char * ptrv = yuv->ptrv;
+ unsigned char * ptro = rgb->ptro;
+ unsigned char * ptro2;
+ int i, j;
+
+ for (i = 0; i < yuv->y_height; i++) {
+ ptro2 = ptro;
+ for (j = 0; j < yuv->y_width; j += 2) {
+
+ short pr, pg, pb, y;
+ short r, g, b;
+
+ 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;
+
+ y = 298*ptry[j] >> 8;
+ r = y + pr;
+ g = y + pg;
+ b = y + pb;
+
+ *ptro2++ = 255;
+ *ptro2++ = CLAMP(r);
+ *ptro2++ = CLAMP(g);
+ *ptro2++ = CLAMP(b);
+
+ y = 298*ptry[j + 1] >> 8;
+ r = y + pr;
+ g = y + pg;
+ b = y + pb;
+
+ *ptro2++ = 255;
+ *ptro2++ = CLAMP(r);
+ *ptro2++ = CLAMP(g);
+ *ptro2++ = CLAMP(b);
+ }
+ ptry += yuv->y_width;
+ if (i & 1) {
+ ptru += yuv->uv_width;
+ ptrv += yuv->uv_width;
+ }
+ ptro += rgb->rgb_width * 4;
+ }
+}
+
+
/* Vanilla implementation of YUV->BGR conversion*/
void oggplay_yuv2bgr(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {