mirror of
https://github.com/mpv-player/mpv
synced 2024-10-02 16:25:33 +02:00
Add a new GPU-based scaling method to vo gl
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22507 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
c60af33716
commit
c9c2f7332e
@ -708,6 +708,26 @@ static const char *bicub_filt_template_RECT =
|
|||||||
"MUL cdelta.yw, parmy.rrgg, {0, -1, 0, 1};"
|
"MUL cdelta.yw, parmy.rrgg, {0, -1, 0, 1};"
|
||||||
BICUB_FILT_MAIN("RECT");
|
BICUB_FILT_MAIN("RECT");
|
||||||
|
|
||||||
|
#define BICUB_X_FILT_MAIN(textype) \
|
||||||
|
"ADD coord, fragment.texcoord[%c].xyxy, cdelta.xyxw;" \
|
||||||
|
"ADD coord2, fragment.texcoord[%c].xyxy, cdelta.zyzw;" \
|
||||||
|
"TEX a.r, coord, texture[%c], "textype";" \
|
||||||
|
"TEX b.r, coord2, texture[%c], "textype";" \
|
||||||
|
/* x-interpolation */ \
|
||||||
|
"LRP yuv.%c, parmx.b, a.rrrr, b.rrrr;"
|
||||||
|
|
||||||
|
static const char *bicub_x_filt_template_2D =
|
||||||
|
"MAD coord.x, fragment.texcoord[%c], {%f, %f}, {0.5, 0.5};"
|
||||||
|
"TEX parmx, coord, texture[%c], 1D;"
|
||||||
|
"MUL cdelta.xz, parmx.rrgg, {-%f, 0, %f, 0};"
|
||||||
|
BICUB_X_FILT_MAIN("2D");
|
||||||
|
|
||||||
|
static const char *bicub_x_filt_template_RECT =
|
||||||
|
"ADD coord.x, fragment.texcoord[%c], {0.5, 0.5};"
|
||||||
|
"TEX parmx, coord, texture[%c], 1D;"
|
||||||
|
"MUL cdelta.xz, parmx.rrgg, {-1, 0, 1, 0};"
|
||||||
|
BICUB_X_FILT_MAIN("RECT");
|
||||||
|
|
||||||
static const char *yuv_prog_template =
|
static const char *yuv_prog_template =
|
||||||
"PARAM ycoef = {%.4f, %.4f, %.4f};"
|
"PARAM ycoef = {%.4f, %.4f, %.4f};"
|
||||||
"PARAM ucoef = {%.4f, %.4f, %.4f};"
|
"PARAM ucoef = {%.4f, %.4f, %.4f};"
|
||||||
@ -765,6 +785,7 @@ static void create_scaler_textures(int scaler, int *texu, char *texs) {
|
|||||||
case YUV_SCALER_BILIN:
|
case YUV_SCALER_BILIN:
|
||||||
break;
|
break;
|
||||||
case YUV_SCALER_BICUB:
|
case YUV_SCALER_BICUB:
|
||||||
|
case YUV_SCALER_BICUB_X:
|
||||||
texs[0] = (*texu)++;
|
texs[0] = (*texu)++;
|
||||||
gen_spline_lookup_tex(GL_TEXTURE0 + texs[0]);
|
gen_spline_lookup_tex(GL_TEXTURE0 + texs[0]);
|
||||||
texs[0] += '0';
|
texs[0] += '0';
|
||||||
@ -960,6 +981,17 @@ static void add_scaler(int scaler, char **prog_pos, int *remain, char *texs,
|
|||||||
texs[0], (float)1.0 / texh, (float)1.0 / texh,
|
texs[0], (float)1.0 / texh, (float)1.0 / texh,
|
||||||
in_tex, in_tex, in_tex, in_tex, in_tex, in_tex, out_comp);
|
in_tex, in_tex, in_tex, in_tex, in_tex, in_tex, out_comp);
|
||||||
break;
|
break;
|
||||||
|
case YUV_SCALER_BICUB_X:
|
||||||
|
if (rect)
|
||||||
|
snprintf(*prog_pos, *remain, bicub_x_filt_template_RECT,
|
||||||
|
in_tex, texs[0],
|
||||||
|
in_tex, in_tex, in_tex, in_tex, out_comp);
|
||||||
|
else
|
||||||
|
snprintf(*prog_pos, *remain, bicub_x_filt_template_2D,
|
||||||
|
in_tex, (float)texw, (float)texh,
|
||||||
|
texs[0], (float)1.0 / texw, (float)1.0 / texw,
|
||||||
|
in_tex, in_tex, in_tex, in_tex, out_comp);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
*remain -= strlen(*prog_pos);
|
*remain -= strlen(*prog_pos);
|
||||||
*prog_pos += strlen(*prog_pos);
|
*prog_pos += strlen(*prog_pos);
|
||||||
|
@ -894,6 +894,7 @@ static int preinit(const char *arg)
|
|||||||
" lscale=<n>\n"
|
" lscale=<n>\n"
|
||||||
" 0: use standard bilinear scaling for luma.\n"
|
" 0: use standard bilinear scaling for luma.\n"
|
||||||
" 1: use improved bicubic scaling for luma.\n"
|
" 1: use improved bicubic scaling for luma.\n"
|
||||||
|
" 2: use cubic in X, linear in Y direction scaling for luma.\n"
|
||||||
" cscale=<n>\n"
|
" cscale=<n>\n"
|
||||||
" as lscale but for chroma (2x slower with little visible effect).\n"
|
" as lscale but for chroma (2x slower with little visible effect).\n"
|
||||||
" customprog=<filename>\n"
|
" customprog=<filename>\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user