summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-09-07 21:02:49 +0200
committerwm4 <wm4@nowhere>2015-09-07 21:18:30 +0200
commit8a9c9e0ede8a39fd7d9bbef5cc5d6b2e166b7366 (patch)
tree94b2240f69d091ea3cb950f70338489a2a105f65 /video
parentcd32179627f979337ca4b55f20abfb14c3db370e (diff)
downloadmpv-8a9c9e0ede8a39fd7d9bbef5cc5d6b2e166b7366.tar.bz2
mpv-8a9c9e0ede8a39fd7d9bbef5cc5d6b2e166b7366.tar.xz
vo_opengl: move video source rectangle computation to a function
Needed for the following commit.
Diffstat (limited to 'video')
-rw-r--r--video/out/gl_video.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index bd97b34c7c..1586e80f0c 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -1629,6 +1629,32 @@ static void pass_delinearize(struct gl_video *p, enum mp_csp_trc trc)
}
}
+// Compute the cropped and rotated transformation of the video source rectangle.
+// vp_w and vp_h are set to the _destination_ video size.
+static void compute_src_transform(struct gl_video *p, struct gl_transform *tr,
+ int *vp_w, int *vp_h)
+{
+ float sx = (p->src_rect.x1 - p->src_rect.x0) / (float)p->image_w,
+ sy = (p->src_rect.y1 - p->src_rect.y0) / (float)p->image_h,
+ ox = p->src_rect.x0,
+ oy = p->src_rect.y0;
+ struct gl_transform transform = {{{sx,0.0}, {0.0,sy}}, {ox,oy}};
+
+ int xc = 0, yc = 1;
+ *vp_w = p->dst_rect.x1 - p->dst_rect.x0,
+ *vp_h = p->dst_rect.y1 - p->dst_rect.y0;
+
+ if ((p->image_params.rotate % 180) == 90) {
+ MPSWAP(float, transform.m[0][xc], transform.m[0][yc]);
+ MPSWAP(float, transform.m[1][xc], transform.m[1][yc]);
+ MPSWAP(float, transform.t[0], transform.t[1]);
+ MPSWAP(int, xc, yc);
+ MPSWAP(int, *vp_w, *vp_h);
+ }
+
+ *tr = transform;
+}
+
// Takes care of the main scaling and pre/post-conversions
static void pass_scale_main(struct gl_video *p)
{
@@ -1675,24 +1701,9 @@ static void pass_scale_main(struct gl_video *p)
sig_center, sig_scale, sig_offset, sig_slope);
}
- // Compute the cropped and rotated transformation
- float sx = (p->src_rect.x1 - p->src_rect.x0) / (float)p->image_w,
- sy = (p->src_rect.y1 - p->src_rect.y0) / (float)p->image_h,
- ox = p->src_rect.x0,
- oy = p->src_rect.y0;
- struct gl_transform transform = {{{sx,0.0}, {0.0,sy}}, {ox,oy}};
-
- int xc = 0, yc = 1,
- vp_w = p->dst_rect.x1 - p->dst_rect.x0,
- vp_h = p->dst_rect.y1 - p->dst_rect.y0;
-
- if ((p->image_params.rotate % 180) == 90) {
- MPSWAP(float, transform.m[0][xc], transform.m[0][yc]);
- MPSWAP(float, transform.m[1][xc], transform.m[1][yc]);
- MPSWAP(float, transform.t[0], transform.t[1]);
- MPSWAP(int, xc, yc);
- MPSWAP(int, vp_w, vp_h);
- }
+ struct gl_transform transform;
+ int vp_w, vp_h;
+ compute_src_transform(p, &transform, &vp_w, &vp_h);
GLSLF("// main scaling\n");
finish_pass_fbo(p, &p->indirect_fbo, p->image_w, p->image_h, 0, 0);