diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2008-01-15 17:59:20 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2008-01-15 17:59:20 +0000 |
commit | 1fbd767ef649f643b42749af3000b1276b9b00eb (patch) | |
tree | 5bef70ecff668c41850e93abf2677e9617f311dd /libvo/gl_common.c | |
parent | 6fed08aee33418948dcb5c3c4cdfae1ddf13df11 (diff) | |
download | mpv-1fbd767ef649f643b42749af3000b1276b9b00eb.tar.bz2 mpv-1fbd767ef649f643b42749af3000b1276b9b00eb.tar.xz |
Add experimental unsharp-mask OpenGL scaler. Certainly not yet perfect.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25757 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/gl_common.c')
-rw-r--r-- | libvo/gl_common.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c index 7afb1a9c34..4117d6de9f 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -756,6 +756,26 @@ static const char *bicub_x_filt_template_RECT = "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 @@ static void create_scaler_textures(int scaler, int *texu, char *texs) { 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 @@ static void add_scaler(int scaler, char **prog_pos, int *remain, char *texs, (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); |