summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-12-30 00:14:20 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-12-30 00:14:20 +0200
commitdc7f1830224e1953fb07ffcc045735b2b15af310 (patch)
tree3028341d6fd07c19b8b7c78fdfd7c411cbdce573 /libvo
parent0f81e5f9732d143ab47c9b03dfd528f3a0af4aea (diff)
parenta0601ed2566d132fec57dcf163372f9f341f3c13 (diff)
downloadmpv-dc7f1830224e1953fb07ffcc045735b2b15af310.tar.bz2
mpv-dc7f1830224e1953fb07ffcc045735b2b15af310.tar.xz
Merge svn changes up to r30104
Ignore the broken correct-pts change in r30100.
Diffstat (limited to 'libvo')
-rw-r--r--libvo/gl_common.c60
-rw-r--r--libvo/gl_common.h3
-rw-r--r--libvo/vo_gl.c54
3 files changed, 66 insertions, 51 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index f9b8359906..527c891327 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -834,11 +834,11 @@ static const char *bilin_filt_template =
"LRP yuv.%c, parmx.b, a.bbbb, a.aaaa;"
static const char *bicub_filt_template_2D =
- "MAD coord.xy, fragment.texcoord[%c], {%f, %f}, {0.5, 0.5};"
+ "MAD coord.xy, fragment.texcoord[%c], {%e, %e}, {0.5, 0.5};"
"TEX parmx, coord.x, texture[%c], 1D;"
- "MUL cdelta.xz, parmx.rrgg, {-%f, 0, %f, 0};"
+ "MUL cdelta.xz, parmx.rrgg, {-%e, 0, %e, 0};"
"TEX parmy, coord.y, texture[%c], 1D;"
- "MUL cdelta.yw, parmy.rrgg, {0, -%f, 0, %f};"
+ "MUL cdelta.yw, parmy.rrgg, {0, -%e, 0, %e};"
BICUB_FILT_MAIN("2D");
static const char *bicub_filt_template_RECT =
@@ -860,12 +860,12 @@ static const char *bicub_filt_template_RECT =
"SUB "t".y, "t".yyyy, "s";"
static const char *bicub_notex_filt_template_2D =
- "MAD coord.xy, fragment.texcoord[%c], {%f, %f}, {0.5, 0.5};"
+ "MAD coord.xy, fragment.texcoord[%c], {%e, %e}, {0.5, 0.5};"
"FRC coord.xy, coord.xyxy;"
CALCWEIGHTS("parmx", "coord.xxxx")
- "MUL cdelta.xz, parmx.rrgg, {-%f, 0, %f, 0};"
+ "MUL cdelta.xz, parmx.rrgg, {-%e, 0, %e, 0};"
CALCWEIGHTS("parmy", "coord.yyyy")
- "MUL cdelta.yw, parmy.rrgg, {0, -%f, 0, %f};"
+ "MUL cdelta.yw, parmy.rrgg, {0, -%e, 0, %e};"
BICUB_FILT_MAIN("2D");
static const char *bicub_notex_filt_template_RECT =
@@ -886,9 +886,9 @@ static const char *bicub_notex_filt_template_RECT =
"LRP yuv.%c, parmx.b, a.rrrr, b.rrrr;"
static const char *bicub_x_filt_template_2D =
- "MAD coord.x, fragment.texcoord[%c], {%f}, {0.5};"
+ "MAD coord.x, fragment.texcoord[%c], {%e}, {0.5};"
"TEX parmx, coord, texture[%c], 1D;"
- "MUL cdelta.xyz, parmx.rrgg, {-%f, 0, %f};"
+ "MUL cdelta.xyz, parmx.rrgg, {-%e, 0, %e};"
BICUB_X_FILT_MAIN("2D");
static const char *bicub_x_filt_template_RECT =
@@ -898,7 +898,7 @@ static const char *bicub_x_filt_template_RECT =
BICUB_X_FILT_MAIN("RECT");
static const char *unsharp_filt_template =
- "PARAM dcoord%c = {%f, %f, %f, %f};"
+ "PARAM dcoord%c = {%e, %e, %e, %e};"
"ADD coord, fragment.texcoord[%c].xyxy, dcoord%c;"
"SUB coord2, fragment.texcoord[%c].xyxy, dcoord%c;"
"TEX a.r, fragment.texcoord[%c], texture[%c], %s;"
@@ -909,11 +909,11 @@ static const char *unsharp_filt_template =
"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, {%f}, a.r;";
+ "MAD yuv.%c, b.r, {%e}, a.r;";
static const char *unsharp_filt_template2 =
- "PARAM dcoord%c = {%f, %f, %f, %f};"
- "PARAM dcoord2%c = {%f, 0, 0, %f};"
+ "PARAM dcoord%c = {%e, %e, %e, %e};"
+ "PARAM dcoord2%c = {%e, 0, 0, %e};"
"ADD coord, fragment.texcoord[%c].xyxy, dcoord%c;"
"SUB coord2, fragment.texcoord[%c].xyxy, dcoord%c;"
"TEX a.r, fragment.texcoord[%c], texture[%c], %s;"
@@ -933,13 +933,13 @@ static const char *unsharp_filt_template2 =
"TEX b.g, coord2.zwzw, texture[%c], %s;"
"DP4 b.r, b, {-0.1171875, -0.1171875, -0.1171875, -0.09765625};"
"MAD b.r, a.r, {0.859375}, b.r;"
- "MAD yuv.%c, b.r, {%f}, a.r;";
+ "MAD yuv.%c, b.r, {%e}, a.r;";
static const char *yuv_prog_template =
- "PARAM ycoef = {%.4f, %.4f, %.4f};"
- "PARAM ucoef = {%.4f, %.4f, %.4f};"
- "PARAM vcoef = {%.4f, %.4f, %.4f};"
- "PARAM offsets = {%.4f, %.4f, %.4f};"
+ "PARAM ycoef = {%e, %e, %e};"
+ "PARAM ucoef = {%e, %e, %e};"
+ "PARAM vcoef = {%e, %e, %e};"
+ "PARAM offsets = {%e, %e, %e};"
"TEMP res;"
"MAD res.rgb, yuv.rrrr, ycoef, offsets;"
"MAD res.rgb, yuv.gggg, ucoef, res;"
@@ -947,11 +947,11 @@ static const char *yuv_prog_template =
"END";
static const char *yuv_pow_prog_template =
- "PARAM ycoef = {%.4f, %.4f, %.4f};"
- "PARAM ucoef = {%.4f, %.4f, %.4f};"
- "PARAM vcoef = {%.4f, %.4f, %.4f};"
- "PARAM offsets = {%.4f, %.4f, %.4f};"
- "PARAM gamma = {%.4f, %.4f, %.4f};"
+ "PARAM ycoef = {%e, %e, %e};"
+ "PARAM ucoef = {%e, %e, %e};"
+ "PARAM vcoef = {%e, %e, %e};"
+ "PARAM offsets = {%e, %e, %e};"
+ "PARAM gamma = {%e, %e, %e};"
"TEMP res;"
"MAD res.rgb, yuv.rrrr, ycoef, offsets;"
"MAD res.rgb, yuv.gggg, ucoef, res;"
@@ -962,10 +962,10 @@ static const char *yuv_pow_prog_template =
"END";
static const char *yuv_lookup_prog_template =
- "PARAM ycoef = {%.4f, %.4f, %.4f, 0};"
- "PARAM ucoef = {%.4f, %.4f, %.4f, 0};"
- "PARAM vcoef = {%.4f, %.4f, %.4f, 0};"
- "PARAM offsets = {%.4f, %.4f, %.4f, 0.125};"
+ "PARAM ycoef = {%e, %e, %e, 0};"
+ "PARAM ucoef = {%e, %e, %e, 0};"
+ "PARAM vcoef = {%e, %e, %e, 0};"
+ "PARAM offsets = {%e, %e, %e, 0.125};"
"TEMP res;"
"MAD res, yuv.rrrr, ycoef, offsets;"
"MAD res.rgb, yuv.gggg, ucoef, res;"
@@ -1093,7 +1093,7 @@ static void create_conv_textures(gl_conversion_params_t *params, int *texu, char
switch (conv) {
case YUV_CONVERSION_FRAGMENT:
case YUV_CONVERSION_FRAGMENT_POW:
- break;
+ break;
case YUV_CONVERSION_FRAGMENT_LOOKUP:
texs[0] = (*texu)++;
ActiveTexture(GL_TEXTURE0 + texs[0]);
@@ -1409,6 +1409,8 @@ void glSetupYUVConversion(gl_conversion_params_t *params) {
case YUV_CONVERSION_FRAGMENT_POW:
glSetupYUVFragprog(params);
break;
+ case YUV_CONVERSION_NONE:
+ break;
default:
mp_msg(MSGT_VO, MSGL_ERR, "[gl] unknown conversion type %i\n", YUV_CONVERSION(params->type));
}
@@ -1421,7 +1423,6 @@ void glSetupYUVConversion(gl_conversion_params_t *params) {
* \ingroup glconversion
*/
void glEnableYUVConversion(GLenum target, int type) {
- if (type <= 0) return;
switch (YUV_CONVERSION(type)) {
case YUV_CONVERSION_COMBINERS:
ActiveTexture(GL_TEXTURE1);
@@ -1443,6 +1444,7 @@ void glEnableYUVConversion(GLenum target, int type) {
case YUV_CONVERSION_FRAGMENT_LOOKUP:
case YUV_CONVERSION_FRAGMENT_POW:
case YUV_CONVERSION_FRAGMENT:
+ case YUV_CONVERSION_NONE:
Enable(GL_FRAGMENT_PROGRAM);
break;
}
@@ -1455,7 +1457,6 @@ void glEnableYUVConversion(GLenum target, int type) {
* \ingroup glconversion
*/
void glDisableYUVConversion(GLenum target, int type) {
- if (type <= 0) return;
switch (YUV_CONVERSION(type)) {
case YUV_CONVERSION_COMBINERS:
ActiveTexture(GL_TEXTURE1);
@@ -1477,6 +1478,7 @@ void glDisableYUVConversion(GLenum target, int type) {
case YUV_CONVERSION_FRAGMENT_LOOKUP:
case YUV_CONVERSION_FRAGMENT_POW:
case YUV_CONVERSION_FRAGMENT:
+ case YUV_CONVERSION_NONE:
Disable(GL_FRAGMENT_PROGRAM);
break;
}
diff --git a/libvo/gl_common.h b/libvo/gl_common.h
index 654f13caf9..e556718ec0 100644
--- a/libvo/gl_common.h
+++ b/libvo/gl_common.h
@@ -69,6 +69,9 @@
#ifndef GL_CLAMP_TO_EDGE
#define GL_CLAMP_TO_EDGE 0x812F
#endif
+#ifndef GL_GENERATE_MIPMAP
+#define GL_GENERATE_MIPMAP 0x8191
+#endif
#ifndef GL_REGISTER_COMBINERS_NV
#define GL_REGISTER_COMBINERS_NV 0x8522
#endif
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index fab076355f..ad23b7963a 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -86,6 +86,9 @@ static int osd_color;
static int use_aspect;
static int use_ycbcr;
+#define MASK_ALL_YUV (~(1 << YUV_CONVERSION_NONE))
+#define MASK_NOT_COMBINERS (~((1 << YUV_CONVERSION_NONE) | (1 << YUV_CONVERSION_COMBINERS) | (1 << YUV_CONVERSION_COMBINERS_ATI)))
+#define MASK_GAMMA_SUPPORT (MASK_NOT_COMBINERS & ~(1 << YUV_CONVERSION_FRAGMENT))
static int use_yuv;
static int lscale;
static int cscale;
@@ -120,6 +123,7 @@ static char *custom_prog;
static char *custom_tex;
static int custom_tlin;
static int custom_trect;
+static int mipmap_gen;
static int int_pause;
static int eq_bri = 0;
@@ -458,6 +462,7 @@ static void autodetectGlExtensions(void) {
* set global gl-related variables to their default values
*/
static int initGl(uint32_t d_width, uint32_t d_height) {
+ int scale_type = mipmap_gen ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR;
autodetectGlExtensions();
texSize(image_width, image_height, &texture_width, &texture_height);
@@ -483,29 +488,34 @@ static int initGl(uint32_t d_width, uint32_t d_height) {
BindTexture(GL_TEXTURE_3D, default_texs[i + 14]);
}
ActiveTexture(GL_TEXTURE1);
- glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, GL_LINEAR,
+ glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, scale_type,
texture_width / 2, texture_height / 2, 128);
+ if (mipmap_gen)
+ TexParameteri(gl_target, GL_GENERATE_MIPMAP, GL_TRUE);
ActiveTexture(GL_TEXTURE2);
- glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, GL_LINEAR,
+ glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, scale_type,
texture_width / 2, texture_height / 2, 128);
- switch (use_yuv) {
- case YUV_CONVERSION_FRAGMENT_LOOKUP:
- case YUV_CONVERSION_FRAGMENT_POW:
- case YUV_CONVERSION_FRAGMENT:
- if (!GenPrograms || !BindProgram) {
- mp_msg(MSGT_VO, MSGL_ERR, "[gl] fragment program functions missing!\n");
- break;
- }
+ if (mipmap_gen)
+ TexParameteri(gl_target, GL_GENERATE_MIPMAP, GL_TRUE);
+ ActiveTexture(GL_TEXTURE0);
+ BindTexture(gl_target, 0);
+ }
+ if (image_format == IMGFMT_YV12 || custom_prog)
+ {
+ if ((MASK_NOT_COMBINERS & (1 << use_yuv)) || custom_prog) {
+ if (!GenPrograms || !BindProgram) {
+ mp_msg(MSGT_VO, MSGL_ERR, "[gl] fragment program functions missing!\n");
+ } else {
GenPrograms(1, &fragprog);
BindProgram(GL_FRAGMENT_PROGRAM, fragprog);
- break;
+ }
}
- ActiveTexture(GL_TEXTURE0);
- BindTexture(gl_target, 0);
update_yuvconv();
}
- glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, GL_LINEAR,
+ glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, scale_type,
texture_width, texture_height, 0);
+ if (mipmap_gen)
+ TexParameteri(gl_target, GL_GENERATE_MIPMAP, GL_TRUE);
resize(d_width, d_height);
@@ -658,14 +668,14 @@ static void do_render(void) {
// BindTexture(GL_TEXTURE_2D, texture_id);
Color3f(1,1,1);
- if (image_format == IMGFMT_YV12)
+ if (image_format == IMGFMT_YV12 || custom_prog)
glEnableYUVConversion(gl_target, yuvconvtype);
glDrawTex(0, 0, image_width, image_height,
0, 0, image_width, image_height,
texture_width, texture_height,
use_rectangle == 1, image_format == IMGFMT_YV12,
mpi_flipped ^ vo_flipped);
- if (image_format == IMGFMT_YV12)
+ if (image_format == IMGFMT_YV12 || custom_prog)
glDisableYUVConversion(gl_target, yuvconvtype);
}
@@ -982,6 +992,7 @@ static const opt_t subopts[] = {
{"customtex", OPT_ARG_MSTRZ,&custom_tex, NULL},
{"customtlin", OPT_ARG_BOOL, &custom_tlin, NULL},
{"customtrect", OPT_ARG_BOOL, &custom_trect, NULL},
+ {"mipmapgen", OPT_ARG_BOOL, &mipmap_gen, NULL},
{"osdcolor", OPT_ARG_INT, &osd_color, NULL},
{NULL}
};
@@ -1013,6 +1024,7 @@ static int preinit(const char *arg)
custom_tex = NULL;
custom_tlin = 1;
custom_trect = 0;
+ mipmap_gen = 0;
osd_color = 0xffffff;
if (subopt_parse(arg, subopts) != 0) {
mp_msg(MSGT_VO, MSGL_FATAL,
@@ -1043,6 +1055,8 @@ static int preinit(const char *arg)
" Interval in displayed frames between to buffer swaps.\n"
" 1 is equivalent to enable VSYNC, 0 to disable VSYNC.\n"
" Requires GLX_SGI_swap_control support to work.\n"
+ " ycbcr\n"
+ " also try to use the GL_MESA_ycbcr_texture extension\n"
" yuv=<n>\n"
" 0: use software YUV to RGB conversion.\n"
" 1: use register combiners (nVidia only, for older cards).\n"
@@ -1070,10 +1084,10 @@ static int preinit(const char *arg)
" use GL_NEAREST scaling for customtex texture\n"
" customtrect\n"
" use texture_rectangle for customtex texture\n"
+ " mipmapgen\n"
+ " generate mipmaps for the video image (use with TXB in customprog)\n"
" osdcolor=<0xAARRGGBB>\n"
" use the given color for the OSD\n"
- " ycbcr\n"
- " also try to use the GL_MESA_ycbcr_texture extension\n"
"\n" );
return -1;
}
@@ -1092,10 +1106,6 @@ static int preinit(const char *arg)
return 0;
}
-#define MASK_ALL_YUV (~(1 << YUV_CONVERSION_NONE))
-#define MASK_NOT_COMBINERS (~((1 << YUV_CONVERSION_NONE) | (1 << YUV_CONVERSION_COMBINERS) | (1 << YUV_CONVERSION_COMBINERS_ATI)))
-#define MASK_GAMMA_SUPPORT (MASK_NOT_COMBINERS & ~(1 << YUV_CONVERSION_FRAGMENT))
-
static const struct {
const char *name;
int *value;