Mercurial > mplayer.hg
changeset 16586:26b156d7a68d
Support rectangular texture in fragment programs
author | reimar |
---|---|
date | Sun, 25 Sep 2005 16:07:54 +0000 |
parents | af59e082803a |
children | 3b108342a983 |
files | libvo/gl_common.c libvo/gl_common.h libvo/vo_gl.c libvo/vo_gl2.c |
diffstat | 4 files changed, 27 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/gl_common.c Sun Sep 25 15:42:18 2005 +0000 +++ b/libvo/gl_common.c Sun Sep 25 16:07:54 2005 +0000 @@ -468,23 +468,25 @@ static const char *yuv_prog_template = "!!ARBfp1.0\n" + "OPTION ARB_precision_hint_fastest;" "TEMP res, y, u, v;" - "TEX y, fragment.texcoord[0], texture[0], 2D;" + "TEX y, fragment.texcoord[0], texture[0], %s;" "MAD res, y, {%.4f, %.4f, %.4f}, {%.4f, %.4f, %.4f};" - "TEX u, fragment.texcoord[1], texture[1], 2D;" + "TEX u, fragment.texcoord[1], texture[1], %s;" "MAD res, u, {%.4f, %.4f, %.4f}, res;" - "TEX v, fragment.texcoord[2], texture[2], 2D;" + "TEX v, fragment.texcoord[2], texture[2], %s;" "MAD result.color, v, {%.4f, %.4f, %.4f}, res;" "END"; static const char *yuv_pow_prog_template = "!!ARBfp1.0\n" + "OPTION ARB_precision_hint_fastest;" "TEMP res, y, u, v;" - "TEX y, fragment.texcoord[0], texture[0], 2D;" + "TEX y, fragment.texcoord[0], texture[0], %s;" "MAD res, y, {%.4f, %.4f, %.4f}, {%.4f, %.4f, %.4f};" - "TEX u, fragment.texcoord[1], texture[1], 2D;" + "TEX u, fragment.texcoord[1], texture[1], %s;" "MAD res, u, {%.4f, %.4f, %.4f}, res;" - "TEX v, fragment.texcoord[2], texture[2], 2D;" + "TEX v, fragment.texcoord[2], texture[2], %s;" "MAD_SAT res, v, {%.4f, %.4f, %.4f}, res;" "POW result.color.r, res.r, %.4f.r;" "POW result.color.g, res.g, %.4f.g;" @@ -493,14 +495,14 @@ static const char *yuv_lookup_prog_template = "!!ARBfp1.0\n" + "OPTION ARB_precision_hint_fastest;" "TEMP res, y, u, v;" - "TEX y, fragment.texcoord[0], texture[0], 2D;" - "MAD res, y, {%.4f, %.4f, %.4f, 0}, {%.4f, %.4f, %.4f, 0};" - "TEX u, fragment.texcoord[1], texture[1], 2D;" + "TEX y, fragment.texcoord[0], texture[0], %s;" + "MAD res, y, {%.4f, %.4f, %.4f, 0}, {%.4f, %.4f, %.4f, 0.125};" + "TEX u, fragment.texcoord[1], texture[1], %s;" "MAD res, u, {%.4f, %.4f, %.4f, 0}, res;" - "TEX v, fragment.texcoord[2], texture[2], 2D;" + "TEX v, fragment.texcoord[2], texture[2], %s;" "MAD res, v, {%.4f, %.4f, %.4f, 0}, res;" - "ADD res.a, res.a, 0.125;" "TEX result.color.r, res.raaa, texture[3], 2D;" "ADD res.a, res.a, 0.25;" "TEX result.color.g, res.gaaa, texture[3], 2D;" @@ -519,9 +521,10 @@ */ static void glSetupYUVFragprog(float brightness, float contrast, float uvcos, float uvsin, float rgamma, - float ggamma, float bgamma, int type) { + float ggamma, float bgamma, int type, int rect) { char yuv_prog[1000]; const char *prog_template = yuv_prog_template; + char *tex_type = rect ? "RECT" : "2D"; int lookup = 0; GLint i; // this is the conversion matrix, with y, u, v factors @@ -564,8 +567,8 @@ rgamma = 1.0 / rgamma; ggamma = 1.0 / ggamma; bgamma = 1.0 / bgamma; - snprintf(yuv_prog, 1000, prog_template, ry, gy, by, rc, gc, bc, ru, gu, bu, - rv, gv, bv, rgamma, bgamma, bgamma); + snprintf(yuv_prog, 1000, prog_template, tex_type, ry, gy, by, rc, gc, bc, + tex_type, ru, gu, bu, tex_type, rv, gv, bv, rgamma, bgamma, bgamma); ProgramString(GL_FRAGMENT_PROGRAM, GL_PROGRAM_FORMAT_ASCII, strlen(yuv_prog), yuv_prog); glGetIntegerv(GL_PROGRAM_ERROR_POSITION, &i); @@ -598,6 +601,7 @@ /** * \brief setup YUV->RGB conversion + * \param target texture target for Y, U and V textures (e.g. GL_TEXTURE_2D) * \param brightness brightness adjustment offset * \param contrast contrast adjustment factor * \param hue hue adjustment angle @@ -607,7 +611,8 @@ * \param bgamma gamma value for blue channel * \param type YUV conversion type */ -void glSetupYUVConversion(int type, float brightness, float contrast, +void glSetupYUVConversion(GLenum target, int type, + float brightness, float contrast, float hue, float saturation, float rgamma, float ggamma, float bgamma) { float uvcos = saturation * cos(hue); @@ -632,7 +637,8 @@ case YUV_CONVERSION_FRAGMENT: case YUV_CONVERSION_FRAGMENT_POW: glSetupYUVFragprog(brightness, contrast, uvcos, uvsin, - rgamma, ggamma, bgamma, type); + rgamma, ggamma, bgamma, type, + target == GL_TEXTURE_RECTANGLE); break; } }
--- a/libvo/gl_common.h Sun Sep 25 15:42:18 2005 +0000 +++ b/libvo/gl_common.h Sun Sep 25 16:07:54 2005 +0000 @@ -158,7 +158,8 @@ #define YUV_CONVERSION_FRAGMENT_POW 3 //! use a fragment program with additional table lookup for YUV conversion #define YUV_CONVERSION_FRAGMENT_LOOKUP 4 -void glSetupYUVConversion(int type, float brightness, float contrast, +void glSetupYUVConversion(GLenum target, int type, + float brightness, float contrast, float hue, float saturation, float rgamma, float ggamma, float bgamma); void inline glEnableYUVConversion(GLenum target, int type);
--- a/libvo/vo_gl.c Sun Sep 25 15:42:18 2005 +0000 +++ b/libvo/vo_gl.c Sun Sep 25 16:07:54 2005 +0000 @@ -151,7 +151,8 @@ float rgamma = exp(log(8.0) * eq_rgamma / 100.0); float ggamma = exp(log(8.0) * eq_ggamma / 100.0); float bgamma = exp(log(8.0) * eq_bgamma / 100.0); - glSetupYUVConversion(use_yuv, bri, cont, hue, sat, rgamma, ggamma, bgamma); + glSetupYUVConversion(gl_target, use_yuv, bri, cont, hue, sat, + rgamma, ggamma, bgamma); if (custom_prog) { FILE *f = fopen(custom_prog, "r"); if (!f)
--- a/libvo/vo_gl2.c Sun Sep 25 15:42:18 2005 +0000 +++ b/libvo/vo_gl2.c Sun Sep 25 16:07:54 2005 +0000 @@ -763,7 +763,7 @@ BindProgram(GL_FRAGMENT_PROGRAM, fragprog); break; } - glSetupYUVConversion(use_yuv, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0); + glSetupYUVConversion(GL_TEXTURE_2D, use_yuv, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0); } gl_set_antialias(0);