summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWessel Dankers <wsl@fruit.je>2013-01-12 15:50:58 +0100
committerwm4 <wm4@nowhere>2013-01-27 13:27:32 +0100
commitd84b572b8cc07484a8c3e92a6a536b80930fad5b (patch)
tree744eae3dd1f1bd53d14f4fe69faa3f97878d7c01
parent8a7b8c3dd6ddb58adb221cfd194c57457a40839c (diff)
downloadmpv-d84b572b8cc07484a8c3e92a6a536b80930fad5b.tar.bz2
mpv-d84b572b8cc07484a8c3e92a6a536b80930fad5b.tar.xz
vo_opengl: always dither
Dithering was disabled if the input bit depth was not larger than the output bit depth of the screen framebuffer. But since scaling, RGB conversion, and other filters change the number of significant bits anyway, dithering could still benefit image quality even in these cases. Always do dithering, unless dithering is completely disabled. The original intention of this mechanism was not to change the image needlessly when playing video that matches the native bit depth of the screen.
-rw-r--r--DOCS/man/en/vo.rst5
-rw-r--r--video/out/vo_opengl.c37
2 files changed, 12 insertions, 30 deletions
diff --git a/DOCS/man/en/vo.rst b/DOCS/man/en/vo.rst
index 824342b279..b87f982632 100644
--- a/DOCS/man/en/vo.rst
+++ b/DOCS/man/en/vo.rst
@@ -337,11 +337,6 @@ opengl
8
Dither to 8 bit output.
- Note that dithering will always be disabled if the bit depth
- of the video is lower or equal to the detected dither-depth.
- If color management is enabled, input depth is assumed to be
- 16 bits, because the 3D LUT output is 16 bit wide.
-
Note that the depth of the connected video display device can not be
detected. Often, LCD panels will do dithering on their own, which
conflicts with vo_opengl's dithering, and leads to ugly output.
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index a44c467b64..cc67187a0f 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -194,7 +194,6 @@ struct gl_priv {
// per pixel (full pixel when packed, each component when planar)
int plane_bytes;
int plane_bits;
- int component_bits;
GLint gl_internal_format;
GLenum gl_format;
@@ -231,20 +230,19 @@ struct fmt_entry {
int mp_format;
GLint internal_format;
GLenum format;
- int component_bits;
GLenum type;
};
static const struct fmt_entry mp_to_gl_formats[] = {
- {IMGFMT_RGB48, GL_RGB16, GL_RGB, 16, GL_UNSIGNED_SHORT},
- {IMGFMT_RGB24, GL_RGB, GL_RGB, 8, GL_UNSIGNED_BYTE},
- {IMGFMT_RGBA, GL_RGBA, GL_RGBA, 8, GL_UNSIGNED_BYTE},
- {IMGFMT_RGB15, GL_RGBA, GL_RGBA, 5, GL_UNSIGNED_SHORT_1_5_5_5_REV},
- {IMGFMT_RGB16, GL_RGB, GL_RGB, 6, GL_UNSIGNED_SHORT_5_6_5_REV},
- {IMGFMT_BGR15, GL_RGBA, GL_BGRA, 5, GL_UNSIGNED_SHORT_1_5_5_5_REV},
- {IMGFMT_BGR16, GL_RGB, GL_RGB, 6, GL_UNSIGNED_SHORT_5_6_5},
- {IMGFMT_BGR24, GL_RGB, GL_BGR, 8, GL_UNSIGNED_BYTE},
- {IMGFMT_BGRA, GL_RGBA, GL_BGRA, 8, GL_UNSIGNED_BYTE},
+ {IMGFMT_RGB48, GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT},
+ {IMGFMT_RGB24, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE},
+ {IMGFMT_RGBA, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE},
+ {IMGFMT_RGB15, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV},
+ {IMGFMT_RGB16, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV},
+ {IMGFMT_BGR15, GL_RGBA, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV},
+ {IMGFMT_BGR16, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5},
+ {IMGFMT_BGR24, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE},
+ {IMGFMT_BGRA, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
{0},
};
@@ -885,14 +883,10 @@ static void init_dither(struct gl_priv *p)
if (p->dither_depth > 0)
dst_depth = p->dither_depth;
- int src_depth = p->component_bits;
- if (p->use_lut_3d)
- src_depth = 16;
-
- if (dst_depth >= src_depth || p->dither_depth < 0 || src_depth < 0)
+ if (p->dither_depth < 0)
return;
- mp_msg(MSGT_VO, MSGL_V, "[gl] Dither %d->%d.\n", src_depth, dst_depth);
+ mp_msg(MSGT_VO, MSGL_V, "[gl] Dither to %d.\n", dst_depth);
// This defines how many bits are considered significant for output on
// screen. The superfluous bits will be used for rounded according to the
@@ -1562,7 +1556,6 @@ static bool init_format(int fmt, struct gl_priv *init)
return false;
init->image_format = fmt;
- init->component_bits = -1;
init->plane_bits = desc.plane_bits;
// RGB/packed formats
@@ -1572,7 +1565,6 @@ static bool init_format(int fmt, struct gl_priv *init)
init->plane_bits = desc.bpp[0];
init->gl_format = e->format;
init->gl_internal_format = e->internal_format;
- init->component_bits = e->component_bits;
init->gl_type = e->type;
break;
}
@@ -1581,7 +1573,6 @@ static bool init_format(int fmt, struct gl_priv *init)
// YUV/planar formats
if (!supported && (desc.flags & MP_IMGFLAG_YUV_P)) {
init->gl_format = GL_RED;
- init->component_bits = init->plane_bits;
if (init->plane_bits == 8) {
supported = true;
init->gl_internal_format = GL_RED;
@@ -1596,7 +1587,7 @@ static bool init_format(int fmt, struct gl_priv *init)
// RGB/planar
if (!supported && fmt == IMGFMT_GBRP) {
supported = true;
- init->plane_bits = init->component_bits = 8;
+ init->plane_bits = 8;
init->gl_format = GL_RED;
init->gl_internal_format = GL_RED;
init->gl_type = GL_UNSIGNED_BYTE;
@@ -2290,10 +2281,6 @@ static const char help_text[] =
" 8 bits per component are assumed.\n"
" 8: Dither to 8 bit output.\n"
" Default: -1.\n"
-" Note that dithering will always be disabled if the bit depth\n"
-" of the video is lower or qual to the detected dither-depth.\n"
-" If color management is enabled, input depth is assumed to be\n"
-" 16 bits, because the 3D LUT output is 16 bit wide.\n"
" debug\n"
" Check for OpenGL errors, i.e. call glGetError(). Also request a\n"
" debug OpenGL context.\n"