[xiph-commits] r16890 - trunk/theora/examples

gmaxwell at svn.xiph.org gmaxwell at svn.xiph.org
Wed Feb 10 22:41:20 PST 2010


Author: gmaxwell
Date: 2010-02-10 22:41:20 -0800 (Wed, 10 Feb 2010)
New Revision: 16890

Modified:
   trunk/theora/examples/player_example.c
Log:
player_example.c: Switch to the same careful conversion code as is used by the telemetry

Modified: trunk/theora/examples/player_example.c
===================================================================
--- trunk/theora/examples/player_example.c	2010-02-10 16:48:00 UTC (rev 16889)
+++ trunk/theora/examples/player_example.c	2010-02-11 06:41:20 UTC (rev 16890)
@@ -111,25 +111,8 @@
 SDL_Rect rect;
 unsigned char *RGBbuffer;
 
-static int lu_Y[256];
-static int lu_R[256];
-static int lu_GU[256];
-static int lu_GV[256];
-static int lu_B[256];
 #define OC_CLAMP255(_x)     ((unsigned char)((((_x)<0)-1)&((_x)|-((_x)>255))))
 
-static void init_yuv2rgb() {
-  int i;
-  for(i=0;i<256;i++)
-  {
-    lu_Y[i]  =  2441889*(i- 16) + 1048576;
-    lu_R[i]  =  3347111*(i-128);
-    lu_GV[i] = -1704917*(i-128);
-    lu_GU[i] =  -821585*(i-128);
-    lu_B[i]  =  4230442*(i-128);
-  }
-}
-
 /* single frame video buffering */
 int          videobuf_ready=0;
 ogg_int64_t  videobuf_granulepos=-1;
@@ -350,7 +333,6 @@
   else if (px_fmt==TH_PF_444) {
     RGBbuffer = calloc(sizeof(char),w*h*4);
     fprintf(stderr,"warning: SDL does not support YUV 4:4:4, using slow software conversion.\n");
-    init_yuv2rgb();
   } else
     yuv_overlay = SDL_CreateYUVOverlay(w, h,
                                      SDL_YV12_OVERLAY,
@@ -415,13 +397,13 @@
       unsigned char *out = RGBbuffer+(screen->w*i*4);
       for (j=0;j<screen->w;j++) {
         int r, g, b;
-        int y = lu_Y[in_y[j]];
-        b=(y + lu_B[in_u[j]])>>21;
-        out[j*4]     = OC_CLAMP255(b);
-        g=(y + lu_GV[in_v[j]] + lu_GU[in_u[j]])>>21;
-        out[j*4+1]   = OC_CLAMP255(g);
-        r=(y + lu_R[in_v[j]])>>21;
-        out[j*4+2]   = OC_CLAMP255(r);
+        r=(1904000*in_y[j]+2609823*in_v[j]-363703744)/1635200;
+        g=(3827562*in_y[j]-1287801*in_u[j]
+         -2672387*in_v[j]+447306710)/3287200;
+        b=(952000*in_y[j]+1649289*in_u[j]-225932192)/817600;
+        out[4*j+0]=OC_CLAMP255(b);
+        out[4*j+1]=OC_CLAMP255(g);
+        out[4*j+2]=OC_CLAMP255(r);
       }  
       output=SDL_CreateRGBSurfaceFrom(RGBbuffer,screen->w,screen->h,32,4*screen->w,0,0,0,0);
       SDL_BlitSurface(output,NULL,screen,NULL);



More information about the commits mailing list