[MPlayer-cvslog] r33502 - in trunk/libvo: csputils.c csputils.h gl_common.h vo_gl.c vo_gl2.c

reimar subversion at mplayerhq.hu
Tue May 24 22:52:28 CEST 2011


Author: reimar
Date: Tue May 24 22:52:27 2011
New Revision: 33502

Log:
Support 9- and 10-bit YUV input for OpenGL vos.

Modified:
   trunk/libvo/csputils.c
   trunk/libvo/csputils.h
   trunk/libvo/gl_common.h
   trunk/libvo/vo_gl.c
   trunk/libvo/vo_gl2.c

Modified: trunk/libvo/csputils.c
==============================================================================
--- trunk/libvo/csputils.c	Tue May 24 21:53:20 2011	(r33501)
+++ trunk/libvo/csputils.c	Tue May 24 22:52:27 2011	(r33502)
@@ -62,6 +62,9 @@ void mp_gen_gamma_map(uint8_t *map, int 
  * not with e.g. MP_CSP_XYZ
  */
 void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, float yuv2rgb[3][4]) {
+  float depth_multiplier = params->input_shift >= 0 ?
+                           (1 << params->input_shift) :
+                           (1.0 / (1 << -params->input_shift));
   float uvcos = params->saturation * cos(params->hue);
   float uvsin = params->saturation * sin(params->hue);
   int format = params->format;
@@ -128,6 +131,9 @@ void mp_get_yuv2rgb_coeffs(struct mp_csp
     // this "centers" contrast control so that e.g. a contrast of 0
     // leads to a grey image, not a black one
     yuv2rgb[i][COL_C] += 0.5 - params->contrast / 2.0;
+    yuv2rgb[i][COL_Y] *= depth_multiplier;
+    yuv2rgb[i][COL_U] *= depth_multiplier;
+    yuv2rgb[i][COL_V] *= depth_multiplier;
   }
 }
 

Modified: trunk/libvo/csputils.h
==============================================================================
--- trunk/libvo/csputils.h	Tue May 24 21:53:20 2011	(r33501)
+++ trunk/libvo/csputils.h	Tue May 24 22:52:27 2011	(r33502)
@@ -53,6 +53,7 @@ struct mp_csp_params {
   float rgamma;
   float ggamma;
   float bgamma;
+  int input_shift;
 };
 
 void mp_gen_gamma_map(unsigned char *map, int size, float gamma);

Modified: trunk/libvo/gl_common.h
==============================================================================
--- trunk/libvo/gl_common.h	Tue May 24 21:53:20 2011	(r33501)
+++ trunk/libvo/gl_common.h	Tue May 24 22:52:27 2011	(r33502)
@@ -351,6 +351,20 @@ int loadGPUProgram(GLenum target, char *
 #define SET_YUV_CONVERSION(c)   ((c) & YUV_CONVERSION_MASK)
 #define SET_YUV_LUM_SCALER(s)   (((s) & YUV_SCALER_MASK) << YUV_LUM_SCALER_SHIFT)
 #define SET_YUV_CHROM_SCALER(s) (((s) & YUV_SCALER_MASK) << YUV_CHROM_SCALER_SHIFT)
+//! returns whether the yuv conversion supports large brightness range etc.
+static inline int glYUVLargeRange(int conv)
+{
+  switch (conv)
+  {
+  case YUV_CONVERSION_NONE:
+  case YUV_CONVERSION_COMBINERS:
+  case YUV_CONVERSION_COMBINERS_ATI:
+  case YUV_CONVERSION_FRAGMENT_LOOKUP3D:
+  case YUV_CONVERSION_TEXT_FRAGMENT:
+    return 0;
+  }
+  return 1;
+}
 /** \} */
 
 typedef struct {

Modified: trunk/libvo/vo_gl.c
==============================================================================
--- trunk/libvo/vo_gl.c	Tue May 24 21:53:20 2011	(r33501)
+++ trunk/libvo/vo_gl.c	Tue May 24 22:52:27 2011	(r33502)
@@ -230,7 +230,7 @@ static void texSize(int w, int h, int *t
 //! maximum size of custom fragment program
 #define MAX_CUSTOM_PROG_SIZE (1024 * 1024)
 static void update_yuvconv(void) {
-  int xs, ys;
+  int xs, ys, depth;
   float bri = eq_bri / 100.0;
   float cont = (eq_cont + 100) / 100.0;
   float hue = eq_hue / 100.0 * 3.1415927;
@@ -239,11 +239,12 @@ static void update_yuvconv(void) {
   float ggamma = exp(log(8.0) * eq_ggamma / 100.0);
   float bgamma = exp(log(8.0) * eq_bgamma / 100.0);
   gl_conversion_params_t params = {gl_target, yuvconvtype,
-      {colorspace, levelconv, bri, cont, hue, sat, rgamma, ggamma, bgamma},
+      {colorspace, levelconv, bri, cont, hue, sat, rgamma, ggamma, bgamma, 0},
       texture_width, texture_height, 0, 0, filter_strength};
-  mp_get_chroma_shift(image_format, &xs, &ys, NULL);
+  mp_get_chroma_shift(image_format, &xs, &ys, &depth);
   params.chrom_texw = params.texw >> xs;
   params.chrom_texh = params.texh >> ys;
+  params.csp_params.input_shift = -depth & 7;
   glSetupYUVConversion(&params);
   if (custom_prog) {
     FILE *f = fopen(custom_prog, "rb");
@@ -1081,7 +1082,7 @@ query_format(uint32_t format)
     if (format == IMGFMT_RGB24 || format == IMGFMT_RGBA)
         return caps;
     if (use_yuv && mp_get_chroma_shift(format, NULL, NULL, &depth) &&
-        (depth == 8 || depth == 16) &&
+        (depth == 8 || depth == 16 || glYUVLargeRange(use_yuv)) &&
         (IMGFMT_IS_YUVP16_NE(format) || !IMGFMT_IS_YUVP16(format)))
         return caps;
     // HACK, otherwise we get only b&w with some filters (e.g. -vf eq)

Modified: trunk/libvo/vo_gl2.c
==============================================================================
--- trunk/libvo/vo_gl2.c	Tue May 24 21:53:20 2011	(r33501)
+++ trunk/libvo/vo_gl2.c	Tue May 24 22:52:27 2011	(r33502)
@@ -560,7 +560,7 @@ static int initGl(uint32_t d_width, uint
   glDisable(GL_CULL_FACE);
   glEnable (GL_TEXTURE_2D);
   if (is_yuv) {
-    int xs, ys;
+    int xs, ys, depth;
     gl_conversion_params_t params = {GL_TEXTURE_2D, use_yuv,
           {-1, -1, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0},
           texture_width, texture_height, 0, 0, 0};
@@ -581,9 +581,10 @@ static int initGl(uint32_t d_width, uint
         mpglBindProgram(GL_FRAGMENT_PROGRAM, fragprog);
         break;
     }
-    mp_get_chroma_shift(image_format, &xs, &ys, NULL);
+    mp_get_chroma_shift(image_format, &xs, &ys, &depth);
     params.chrom_texw = params.texw >> xs;
     params.chrom_texh = params.texh >> ys;
+    params.csp_params.input_shift = -depth & 7;
     glSetupYUVConversion(&params);
   }
 
@@ -807,7 +808,7 @@ query_format(uint32_t format)
 {
   int depth;
   if (use_yuv && mp_get_chroma_shift(format, NULL, NULL, &depth) &&
-      (depth == 8 || depth == 16) &&
+      (depth == 8 || depth == 16 || glYUVLargeRange(use_yuv)) &&
       (IMGFMT_IS_YUVP16_NE(format) || !IMGFMT_IS_YUVP16(format)))
     return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD |
            VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE;


More information about the MPlayer-cvslog mailing list