mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-28 23:13:18 +08:00
vo_opengl: fix the fix for fixing odd video sizes
Commit acb40644 fixed video with unaligned luma/chroma sizes. It
attempted to disable the fix for videos where it effectively does
nothing (just some minor performance paranoia), but this check was
broken - fix it by not duplicating the logic for this.
This commit is contained in:
+15
-16
@@ -172,6 +172,7 @@ struct gl_video {
|
||||
bool is_yuv, is_rgb, is_packed_yuv;
|
||||
bool has_alpha;
|
||||
char color_swizzle[5];
|
||||
float chroma_fix[2];
|
||||
|
||||
float input_gamma, conv_gamma;
|
||||
|
||||
@@ -793,20 +794,8 @@ static void update_uniforms(struct gl_video *p, GLuint program)
|
||||
gl->Uniform2f(loc, 1.0 / (1 << xs), 1.0 / (1 << ys));
|
||||
}
|
||||
|
||||
loc = gl->GetUniformLocation(program, "chroma_fix");
|
||||
if (loc >= 0) {
|
||||
// If the dimensions of the Y plane are not aligned on the luma.
|
||||
// Assume 4:2:0 with size (3,3). The last luma pixel is (2,2).
|
||||
// The last chroma pixel is (1,1), not (0,0). So for luma, the
|
||||
// coordinate range is [0,3), for chroma it is [0,2). This means the
|
||||
// texture coordinates for chroma are stretched by adding 1 luma pixel
|
||||
// to the range. Undo this.
|
||||
double fx = p->image.planes[0].tex_w / (double)p->image.planes[1].tex_w
|
||||
/ (1 << p->image_desc.chroma_xs);
|
||||
double fy = p->image.planes[0].tex_h / (double)p->image.planes[1].tex_h
|
||||
/ (1 << p->image_desc.chroma_ys);
|
||||
gl->Uniform2f(loc, fx, fy);
|
||||
}
|
||||
gl->Uniform2f(gl->GetUniformLocation(program, "chroma_fix"),
|
||||
p->chroma_fix[0], p->chroma_fix[1]);
|
||||
|
||||
loc = gl->GetUniformLocation(program, "chroma_center_offset");
|
||||
if (loc >= 0) {
|
||||
@@ -1244,8 +1233,7 @@ static void compile_shaders(struct gl_video *p)
|
||||
if (p->opts.alpha_mode == 2 && p->has_alpha)
|
||||
shader_def(&header_conv, "USE_ALPHA_BLEND", "1");
|
||||
shader_def_opt(&header_conv, "USE_CHROMA_FIX",
|
||||
(p->image.planes[0].tex_w & ~(1u << p->image_desc.chroma_xs) ||
|
||||
p->image.planes[0].tex_h & ~(1u << p->image_desc.chroma_ys)));
|
||||
p->chroma_fix[0] != 1.0f || p->chroma_fix[1] != 1.0f);
|
||||
|
||||
shader_def_opt(&header_final, "USE_SIGMOID_INV", use_sigmoid);
|
||||
shader_def_opt(&header_final, "USE_GAMMA_POW", p->opts.gamma > 0);
|
||||
@@ -1761,6 +1749,17 @@ static void init_video(struct gl_video *p, const struct mp_image_params *params)
|
||||
p->texture_w = p->image.planes[0].tex_w;
|
||||
p->texture_h = p->image.planes[0].tex_h;
|
||||
|
||||
// If the dimensions of the Y plane are not aligned on the luma.
|
||||
// Assume 4:2:0 with size (3,3). The last luma pixel is (2,2).
|
||||
// The last chroma pixel is (1,1), not (0,0). So for luma, the
|
||||
// coordinate range is [0,3), for chroma it is [0,2). This means the
|
||||
// texture coordinates for chroma are stretched by adding 1 luma pixel
|
||||
// to the range. Undo this.
|
||||
p->chroma_fix[0] = p->texture_w / (double)p->image.planes[1].tex_w
|
||||
/ (1 << p->image_desc.chroma_xs);
|
||||
p->chroma_fix[1] = p->texture_h / (double)p->image.planes[1].tex_h
|
||||
/ (1 << p->image_desc.chroma_ys);
|
||||
|
||||
debug_check_gl(p, "after video texture creation");
|
||||
|
||||
if (p->hwdec_active) {
|
||||
|
||||
Reference in New Issue
Block a user