# HG changeset patch # User reimar # Date 1270400190 0 # Node ID a5c6b37b3af6eba12710f1ed33bdb9a9097f210f # Parent e9eedc6fa642f9d7ca91ebab90dabe51087f2303 Factor out the YUV->RGB conversion auto-selection and also enable auto-selection of ATI fragment shaders since they should do accurate conversions now. diff -r e9eedc6fa642 -r a5c6b37b3af6 libvo/gl_common.c --- a/libvo/gl_common.c Sun Apr 04 16:48:46 2010 +0000 +++ b/libvo/gl_common.c Sun Apr 04 16:56:30 2010 +0000 @@ -1380,6 +1380,20 @@ } /** + * \brief detect the best YUV->RGB conversion method available + */ +int glAutodetectYUVConversion(void) { + const char *extensions = mpglGetString(GL_EXTENSIONS); + if (strstr(extensions, "GL_ARB_fragment_program")) + return YUV_CONVERSION_FRAGMENT; + if (strstr(extensions, "GL_ATI_text_fragment_shader")) + return YUV_CONVERSION_TEXT_FRAGMENT; + if (strstr(extensions, "GL_ATI_fragment_shader")) + return YUV_CONVERSION_COMBINERS_ATI; + return YUV_CONVERSION_NONE; +} + +/** * \brief setup YUV->RGB conversion * \param parms struct containing parameters like conversion and scaler type, * brightness, ... diff -r e9eedc6fa642 -r a5c6b37b3af6 libvo/gl_common.h --- a/libvo/gl_common.h Sun Apr 04 16:48:46 2010 +0000 +++ b/libvo/gl_common.h Sun Apr 04 16:56:30 2010 +0000 @@ -345,6 +345,7 @@ float filter_strength; } gl_conversion_params_t; +int glAutodetectYUVConversion(void); void glSetupYUVConversion(gl_conversion_params_t *params); void glEnableYUVConversion(GLenum target, int type); void glDisableYUVConversion(GLenum target, int type); diff -r e9eedc6fa642 -r a5c6b37b3af6 libvo/vo_gl.c --- a/libvo/vo_gl.c Sun Apr 04 16:48:46 2010 +0000 +++ b/libvo/vo_gl.c Sun Apr 04 16:56:30 2010 +0000 @@ -480,7 +480,8 @@ if (ati_hack == -1) ati_hack = ati_broken_pbo; if (force_pbo == -1) force_pbo = strstr(extensions, "_pixel_buffer_object") ? is_ati : 0; if (use_rectangle == -1) use_rectangle = strstr(extensions, "_texture_non_power_of_two") ? 0 : 0; - if (use_yuv == -1) use_yuv = strstr(extensions, "GL_ARB_fragment_program") ? 2 : 0; + if (use_yuv == -1) + use_yuv = glAutodetectYUVConversion(); if (is_ati && (lscale == 1 || lscale == 2 || cscale == 1 || cscale == 2)) mp_msg(MSGT_VO, MSGL_WARN, "[gl] Selected scaling mode may be broken on ATI cards.\n" "Tell _them_ to fix GL_REPEAT if you have issues.\n"); diff -r e9eedc6fa642 -r a5c6b37b3af6 libvo/vo_gl2.c --- a/libvo/vo_gl2.c Sun Apr 04 16:48:46 2010 +0000 +++ b/libvo/vo_gl2.c Sun Apr 04 16:56:30 2010 +0000 @@ -886,7 +886,6 @@ } if(!init_mpglcontext(&glctx, gltype)) goto err_out; if (use_yuv == -1) { - const char *extensions; #ifdef CONFIG_GL_WIN32 if (config_w32(320, 200, 320, 200, VOFLAG_HIDDEN, "", 0) == -1) #else @@ -895,8 +894,7 @@ goto err_out; if (glctx.setGlWindow(&glctx) == SET_WINDOW_FAILED) goto err_out; - extensions = mpglGetString(GL_EXTENSIONS); - use_yuv = strstr(extensions, "GL_ARB_fragment_program") ? 2 : 0; + use_yuv = glAutodetectYUVConversion(); } return 0;