mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-29 07:06:59 +08:00
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
This commit is contained in:
@@ -3654,6 +3654,8 @@ Older cards will not be able to handle this for chroma at least in fullscreen mo
|
||||
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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -243,6 +243,7 @@ int loadGPUProgram(GLenum target, char *prog);
|
||||
#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
|
||||
|
||||
@@ -856,6 +856,7 @@ static int preinit(const char *arg)
|
||||
" 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"
|
||||
|
||||
Reference in New Issue
Block a user