summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-01-18 18:34:10 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-01-18 18:34:10 +0000
commit09e3d23298940a75c39d6423659fac2d0100b1ba (patch)
tree8e9143ead53e8410744a6a9dcf34b2bb77873f8c /libvo
parentab2518c5fead7c573813bbdac1b56c65fc221816 (diff)
downloadmpv-09e3d23298940a75c39d6423659fac2d0100b1ba.tar.bz2
mpv-09e3d23298940a75c39d6423659fac2d0100b1ba.tar.xz
Use the same unsharp filter template for 2D and RECT textures
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25783 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/gl_common.c53
1 files changed, 21 insertions, 32 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index fd963409b8..356eddfccb 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -756,26 +756,19 @@ 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";" \
+static const char *unsharp_filt_template =
+ "PARAM dcoord = {%f, %f, %f, %f};"
+ "ADD coord, fragment.texcoord[%c].xyxy, dcoord;"
+ "SUB coord2, fragment.texcoord[%c].xyxy, dcoord;"
+ "TEX a.r, fragment.texcoord[%c], texture[%c], %s;"
+ "TEX b.r, coord.xyxy, texture[%c], %s;"
+ "TEX b.g, coord.zwzw, texture[%c], %s;"
"ADD b.r, b.r, b.g;" \
- "TEX b.b, coord2.xyxy, texture[%c], "textype";" \
- "TEX b.g, coord2.zwzw, texture[%c], "textype";" \
- "DP3 b, b, {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");
+ "TEX b.b, coord2.xyxy, texture[%c], %s;"
+ "TEX b.g, coord2.zwzw, texture[%c], %s;"
+ "DP3 b, b, {0.25, 0.25, 0.25};"
+ "SUB b.r, a.r, b.r;"
+ "MAD yuv.%c, b.r, %s, a.r;";
static const char *yuv_prog_template =
"PARAM ycoef = {%.4f, %.4f, %.4f};"
@@ -1015,10 +1008,13 @@ static void create_conv_textures(int conv, int *texu, char *texs,
*/
static void add_scaler(int scaler, char **prog_pos, int *remain, char *texs,
char in_tex, char out_comp, int rect, int texw, int texh) {
+ const char *ttype = rect ? "RECT" : "2D";
+ const float ptw = rect ? 1.0 : 1.0 / texw;
+ const float pth = rect ? 1.0 : 1.0 / texh;
switch (scaler) {
case YUV_SCALER_BILIN:
snprintf(*prog_pos, *remain, bilin_filt_template, out_comp, in_tex,
- in_tex, rect ? "RECT" : "2D");
+ in_tex, ttype);
break;
case YUV_SCALER_BICUB:
if (rect)
@@ -1056,18 +1052,11 @@ static void add_scaler(int scaler, char **prog_pos, int *remain, char *texs,
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}");
+ snprintf(*prog_pos, *remain, unsharp_filt_template,
+ 0.5 * ptw, 0.5 * pth, 0.5 * ptw, -0.5 * pth,
+ in_tex, in_tex, in_tex,
+ in_tex, ttype, in_tex, ttype, in_tex, ttype, in_tex, ttype,
+ in_tex, ttype, out_comp, "{0.5}");
break;
}
*remain -= strlen(*prog_pos);