summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-30 22:14:47 +0200
committerwm4 <wm4@nowhere>2016-09-30 22:19:01 +0200
commit52fea2f909ec7fd5c99819d1d283a6ac6bd0c937 (patch)
tree6860137b2b147c1e0c49c0ddac8babfd550a521a
parent026cccaddfd5048f6b64bc20bd75f79a65b03aa9 (diff)
downloadmpv-52fea2f909ec7fd5c99819d1d283a6ac6bd0c937.tar.bz2
mpv-52fea2f909ec7fd5c99819d1d283a6ac6bd0c937.tar.xz
vo_opengl: partially fix dumb-mode cropping with rotation
Combining rotation and cropping didn't work. It was just completely broken. I'm still not sure if this is correct. Chroma positioning seems to be broken on rotation. There might also be a problem with non-mod-2 frame sizes. Still, strictly an improvement for both rotated and non-rotated rendering modes. Also, this could probably be written in a more elegant way.
-rw-r--r--video/out/opengl/video.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 99b0d8273c..93930a5a21 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -2338,6 +2338,11 @@ static void pass_draw_osd(struct gl_video *p, int draw_flags, double pts,
gl_sc_set_vao(p->sc, &p->vao);
}
+static float chroma_realign(int size, int shift)
+{
+ return size / (float)(mp_chroma_div_up(size, shift) << shift);
+}
+
// Minimal rendering code path, for GLES or OpenGL 2.1 without proper FBOs.
static void pass_render_frame_dumb(struct gl_video *p, int fbo)
{
@@ -2352,11 +2357,24 @@ static void pass_render_frame_dumb(struct gl_video *p, int fbo)
int index = 0;
for (int i = 0; i < p->plane_count; i++) {
- struct gl_transform trel = {{{(float)p->texture_w / tex[i].w, 0.0},
- {0.0, (float)p->texture_h / tex[i].h}}};
- gl_transform_trans(trel, &tex[i].transform);
- gl_transform_trans(transform, &tex[i].transform);
- gl_transform_trans(off[i], &tex[i].transform);
+ int xs = p->image_desc.xs[i];
+ int ys = p->image_desc.ys[i];
+ if (p->image_params.rotate % 180 == 90)
+ MPSWAP(int, xs, ys);
+
+ struct gl_transform t = transform;
+ t.m[0][0] *= chroma_realign(p->texture_w, xs);
+ t.m[1][1] *= chroma_realign(p->texture_h, ys);
+
+ t.t[0] /= 1 << xs;
+ t.t[1] /= 1 << ys;
+
+ t.t[0] += off[i].t[0];
+ t.t[1] += off[i].t[1];
+
+ gl_transform_trans(tex[i].transform, &t);
+ tex[i].transform = t;
+
copy_img_tex(p, &index, tex[i]);
}