summaryrefslogtreecommitdiffstats
path: root/video/filter/vf_rotate.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-27 18:13:14 +0200
committerwm4 <wm4@nowhere>2014-09-27 18:31:59 +0200
commitcdb25d5a21e2502fef51c2ae7ae387bf990ab73d (patch)
tree612e501e4e087a22722592d921c6966af6b16e33 /video/filter/vf_rotate.c
parent0ec6df2ddfc6eb22de3c4f98c78d291997a5e93d (diff)
downloadmpv-cdb25d5a21e2502fef51c2ae7ae387bf990ab73d.tar.bz2
mpv-cdb25d5a21e2502fef51c2ae7ae387bf990ab73d.tar.xz
video: change automatic rotation and 3D filter insertion
We inserted these filters with fixed parameters, which was ok. But this also didn't change image parameters for the filters down the filter chain and the VO. For example, if rotation by 90° was requested by the file, we would insert a filter and rotate the video, but the VO would still receive image parameters that direct rotation by 90°. This wasn't a problem, but it could become one. Fix this by letting the filters automatically pick up the image params. The image params are reset on application. (We could probably also always try to apply and reset image params in a filter, instead of having special "auto" parameters. This would probably work, and video.c would insert a "rotate=0" filter. But I'm afraid this would be confusing and the current solution is cosmetically slightly nicer.) Unfortunately, the vf_stereo3d.c change turned out a big mess, but once the "internal" filter is fully replaced with libavfilter, most of this can be radically simplified.
Diffstat (limited to 'video/filter/vf_rotate.c')
-rw-r--r--video/filter/vf_rotate.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/video/filter/vf_rotate.c b/video/filter/vf_rotate.c
index 6328e75722..579c3ea24a 100644
--- a/video/filter/vf_rotate.c
+++ b/video/filter/vf_rotate.c
@@ -32,19 +32,39 @@ struct vf_priv_s {
struct vf_lw_opts *lw_opts;
};
+static const char *const rot[] = {
+ "null",
+ "transpose=clock",
+ "vflip,hflip",
+ "transpose=cclock",
+ "null", // actually set in lavfi_recreate()
+};
+
+static int lavfi_reconfig(struct vf_instance *vf,
+ struct mp_image_params *in,
+ struct mp_image_params *out)
+{
+ struct vf_priv_s *p = vf_lw_old_priv(vf);
+ if (p->angle == 4) { // "auto"
+ int r = in->rotate;
+ if (r < 0 || (r % 90) != 0) {
+ MP_ERR(vf, "Can't apply rotation of %d degrees.\n", r);
+ return -1;
+ }
+ vf_lw_update_graph(vf, NULL, "%s", rot[(r / 90) % 360]);
+ out->rotate = 0;
+ }
+ return 0;
+}
+
static int vf_open(vf_instance_t *vf)
{
struct vf_priv_s *p = vf->priv;
- static const char *const rot[] = {
- "null",
- "transpose=clock",
- "vflip,hflip",
- "transpose=cclock",
- };
-
- if (vf_lw_set_graph(vf, p->lw_opts, NULL, "%s", rot[p->angle]) >= 0)
+ if (vf_lw_set_graph(vf, p->lw_opts, NULL, "%s", rot[p->angle]) >= 0) {
+ vf_lw_set_reconfig_cb(vf, lavfi_reconfig);
return 1;
+ }
MP_FATAL(vf, "Requires libavfilter.\n");
return 1;
@@ -61,7 +81,8 @@ const vf_info_t vf_info_rotate = {
({"0", 0},
{"90", 1},
{"180", 2},
- {"270", 3})),
+ {"270", 3},
+ {"auto", 4})),
OPT_SUBSTRUCT("", lw_opts, vf_lw_conf, 0),
{0}
},