diff options
author | wm4 <wm4@nowhere> | 2012-12-24 01:10:57 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-01-13 20:04:11 +0100 |
commit | 5830d639b8d58b0911510db1ccb5de296adfcb4b (patch) | |
tree | 750496d0c09dc293a2ba7a8589a7679535edfc35 /video/out/vo_opengl.c | |
parent | 3791c226b7f3bebbb63a96b61db67b9dc97ff9b8 (diff) | |
download | mpv-5830d639b8d58b0911510db1ccb5de296adfcb4b.tar.bz2 mpv-5830d639b8d58b0911510db1ccb5de296adfcb4b.tar.xz |
video: remove img_format compat hacks
Remove the strange things the old mp_image_setfmt() code did to the
image format parameters. This includes setting chroma shift to 31 for
gray (Y8) formats and more.
Y8 + vo_opengl_old didn't actually work for unknown reasons (regression
in this branch). Fix this. The difference is that Y8 is now interpreted
as gray RGB (LUMINANCE texture) instead of involving YUV (and levels)
conversion.
Get rid of distinguishing RGB and BGR. There wasn't really any good
reason for this.
Remove mp_get_chroma_shift() and IMGFMT_IS_YUVP16*(). mp_imgfmt_desc
gives the same information and more.
Diffstat (limited to 'video/out/vo_opengl.c')
-rw-r--r-- | video/out/vo_opengl.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c index d0c435c59a..4cb9fb76e1 100644 --- a/video/out/vo_opengl.c +++ b/video/out/vo_opengl.c @@ -1558,17 +1558,19 @@ static bool init_format(int fmt, struct gl_priv *init) if (!init) init = &dummy; - mp_image_t dummy_img = {0}; - mp_image_setfmt(&dummy_img, fmt); + struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(fmt); + if (!desc.id) + return false; init->image_format = fmt; init->component_bits = -1; + init->plane_bits = desc.plane_bits; // RGB/packed formats for (const struct fmt_entry *e = mp_to_gl_formats; e->mp_format; e++) { if (e->mp_format == fmt) { supported = true; - init->plane_bits = dummy_img.bpp; + init->plane_bits = desc.bpp[0]; init->gl_format = e->format; init->gl_internal_format = e->internal_format; init->component_bits = e->component_bits; @@ -1578,14 +1580,14 @@ static bool init_format(int fmt, struct gl_priv *init) } // YUV/planar formats - if (!supported && mp_get_chroma_shift(fmt, NULL, NULL, &init->plane_bits)) { + 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; init->gl_type = GL_UNSIGNED_BYTE; - } else if (IMGFMT_IS_YUVP16_NE(fmt)) { + } else if (init->plane_bits <= 16 && (desc.flags & MP_IMGFLAG_NE)) { supported = true; init->gl_internal_format = GL_R16; init->gl_type = GL_UNSIGNED_SHORT; @@ -1605,19 +1607,19 @@ static bool init_format(int fmt, struct gl_priv *init) return false; init->plane_bytes = (init->plane_bits + 7) / 8; - init->is_yuv = dummy_img.flags & MP_IMGFLAG_YUV; + init->is_yuv = desc.flags & MP_IMGFLAG_YUV; init->is_linear_rgb = false; // NOTE: we throw away the additional alpha plane, if one exists. - init->plane_count = dummy_img.num_planes > 2 ? 3 : 1; - assert(dummy_img.num_planes >= init->plane_count); - assert(dummy_img.num_planes <= init->plane_count + 1); + init->plane_count = desc.num_planes > 2 ? 3 : 1; + assert(desc.num_planes >= init->plane_count); + assert(desc.num_planes <= init->plane_count + 1); for (int n = 0; n < init->plane_count; n++) { struct texplane *plane = &init->planes[n]; - plane->shift_x = n > 0 ? dummy_img.chroma_x_shift : 0; - plane->shift_y = n > 0 ? dummy_img.chroma_y_shift : 0; + plane->shift_x = desc.xs[n]; + plane->shift_y = desc.ys[n]; } return true; |