Mercurial > mplayer.hg
changeset 25729:9a96fd14d1c5
Add experimental unsharp-mask OpenGL scaler. Certainly not yet perfect.
author | reimar |
---|---|
date | Tue, 15 Jan 2008 17:59:20 +0000 |
parents | df6e9b54ecaa |
children | 2428200918a0 |
files | DOCS/man/en/mplayer.1 libvo/gl_common.c libvo/gl_common.h libvo/vo_gl.c |
diffstat | 4 files changed, 39 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1 Tue Jan 15 17:54:48 2008 +0000 +++ b/DOCS/man/en/mplayer.1 Tue Jan 15 17:59:20 2008 +0000 @@ -3654,6 +3654,8 @@ Works on a few more cards than method 1. .br 3: Same as 1 but does not use a lookup texture. Might be faster on some cards. +.br +4: Use unsharp masking with 3x3 support and a strength of 0.5. Experimental. .RE .IPs cscale=<n> Select the scaling function to use for chrominance scaling.
--- a/libvo/gl_common.c Tue Jan 15 17:54:48 2008 +0000 +++ b/libvo/gl_common.c Tue Jan 15 17:59:20 2008 +0000 @@ -756,6 +756,26 @@ "MUL cdelta.xz, parmx.rrgg, {-1, 0, 1, 0};" BICUB_X_FILT_MAIN("RECT"); +#define UNSHARP_FILT_MAIN(textype) \ + "TEX a.r, fragment.texcoord[%c], texture[%c], "textype";" \ + "TEX b.r, coord.xyxy, texture[%c], "textype";" \ + "TEX b.g, coord.zwzw, texture[%c], "textype";" \ + "TEX b.b, coord2.xyxy, texture[%c], "textype";" \ + "TEX b.a, coord2.zwzw, texture[%c], "textype";" \ + "DP4 b, b, {0.25, 0.25, 0.25, 0.25};" \ + "SUB b.r, a.r, b.r;" \ + "MAD yuv.%c, b.r, %s, a.r;" + +static const char *unsharp_filt_template_2D = + "ADD coord, fragment.texcoord[%c].xyxy, {%f, %f, -%f, -%f};" + "ADD coord2, fragment.texcoord[%c].xyxy, {%f, -%f, -%f, %f};" + UNSHARP_FILT_MAIN("2D"); + +static const char *unsharp_filt_template_RECT = + "ADD coord, fragment.texcoord[%c].xyxy, {0.5, 0.5, -0.5, -0.5};" + "ADD coord2, fragment.texcoord[%c].xyxy, {0.5, -0.5, -0.5, 0.5};" + UNSHARP_FILT_MAIN("RECT"); + static const char *yuv_prog_template = "PARAM ycoef = {%.4f, %.4f, %.4f};" "PARAM ucoef = {%.4f, %.4f, %.4f};" @@ -812,6 +832,7 @@ switch (scaler) { case YUV_SCALER_BILIN: case YUV_SCALER_BICUB_NOTEX: + case YUV_SCALER_UNSHARP: break; case YUV_SCALER_BICUB: case YUV_SCALER_BICUB_X: @@ -1033,6 +1054,20 @@ (float)1.0 / texh, (float)1.0 / texh, in_tex, in_tex, in_tex, in_tex, in_tex, in_tex, out_comp); break; + case YUV_SCALER_UNSHARP: + if (rect) + snprintf(*prog_pos, *remain, unsharp_filt_template_RECT, + in_tex, + in_tex, + in_tex, in_tex, in_tex, in_tex, in_tex, in_tex, out_comp, + "{0.5}"); + else + snprintf(*prog_pos, *remain, unsharp_filt_template_2D, + in_tex, (float)0.5 / texw, (float)0.5 / texh, (float)0.5 / texw, (float)0.5 / texh, + in_tex, (float)0.5 / texw, (float)0.5 / texh, (float)0.5 / texw, (float)0.5 / texh, + in_tex, in_tex, in_tex, in_tex, in_tex, in_tex, out_comp, + "{0.5}"); + break; } *remain -= strlen(*prog_pos); *prog_pos += strlen(*prog_pos);
--- a/libvo/gl_common.h Tue Jan 15 17:54:48 2008 +0000 +++ b/libvo/gl_common.h Tue Jan 15 17:59:20 2008 +0000 @@ -243,6 +243,7 @@ #define YUV_SCALER_BICUB_X 2 //! use cubic scaling without additional lookup texture #define YUV_SCALER_BICUB_NOTEX 3 +#define YUV_SCALER_UNSHARP 4 //! mask for conversion type #define YUV_CONVERSION_MASK 0xF //! mask for scaler type
--- a/libvo/vo_gl.c Tue Jan 15 17:54:48 2008 +0000 +++ b/libvo/vo_gl.c Tue Jan 15 17:59:20 2008 +0000 @@ -856,6 +856,7 @@ " 1: use improved bicubic scaling for luma.\n" " 2: use cubic in X, linear in Y direction scaling for luma.\n" " 3: as 1 but without using a lookup texture.\n" + " 4: experimental unsharp masking.\n" " cscale=<n>\n" " as lscale but for chroma (2x slower with little visible effect).\n" " customprog=<filename>\n"