diff options
Diffstat (limited to 'video/filter/vf_rotate.c')
-rw-r--r-- | video/filter/vf_rotate.c | 39 |
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} }, |