vf_rotate: allow arbitrary rotation

vf_rotate selects the correct filter for 90° rotation, but it can be
extended to use lavfi's vf_rotate as fallback.

See #3434.
This commit is contained in:
wm4 2016-08-19 09:37:52 +02:00
parent e6952c7053
commit 4e3663a2da
2 changed files with 11 additions and 4 deletions

View File

@ -217,8 +217,8 @@ static void filter_reconfig(struct MPContext *mpctx, struct vo_chain *vo_c)
if (mpctx->opts->deinterlace >= 0)
video_vf_vo_control(vo_c, VFCTRL_SET_DEINTERLACE, &(int){0});
if (params.rotate && (params.rotate % 90 == 0)) {
if (!(vo_c->vo->driver->caps & VO_CAP_ROTATE90)) {
if (params.rotate) {
if (!(vo_c->vo->driver->caps & VO_CAP_ROTATE90) || params.rotate % 90) {
// Try to insert a rotation filter.
char *args[] = {"angle", "auto", NULL};
if (try_filter(vo_c, "rotate", "autorotate", args) < 0)

View File

@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <inttypes.h>
#include "common/msg.h"
@ -46,11 +47,17 @@ static int lavfi_reconfig(struct vf_instance *vf,
struct vf_priv_s *p = vf_lw_old_priv(vf);
if (p->angle == 4) { // "auto"
int r = in->rotate;
if (r < 0 || r >= 360 || (r % 90) != 0) {
if (r < 0 || r >= 360) {
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]);
if (r % 90) {
double a = r / 180.0 * M_PI;
vf_lw_update_graph(vf, NULL, "rotate=%f:ow=rotw(%f):oh=roth(%f)",
a, a, a);
} else {
vf_lw_update_graph(vf, NULL, "%s", rot[(r / 90) % 360]);
}
out->rotate = 0;
}
return 0;