[FFmpeg-devel] [PATCH 2/2] ffplay: support snap to 90degree autorotation

Michael Niedermayer michaelni at gmx.at
Sun May 3 03:10:05 CEST 2015


do people prefer this to be enabled or disabled by default ?

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 ffplay.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ffplay.c b/ffplay.c
index eea00e6..48b09ee 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -343,6 +343,7 @@ static int nb_vfilters = 0;
 static char *afilters = NULL;
 #endif
 static int autorotate = 1;
+static int snapto90 = 0;
 
 /* current context */
 static int is_full_screen;
@@ -2032,6 +2033,9 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
         if (displaymatrix && !theta)
             theta = av_display_rotation_get((int32_t*) displaymatrix);
 
+        if (snapto90)
+            theta = 90 * round(theta/90);
+
         theta -= 360*floor(theta/360 + 0.9/360);
 
         if (fabs(theta - 90) < 1.0) {
@@ -3742,6 +3746,7 @@ static const OptionDef options[] = {
     { "scodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &subtitle_codec_name }, "force subtitle decoder", "decoder_name" },
     { "vcodec", HAS_ARG | OPT_STRING | OPT_EXPERT, {    &video_codec_name }, "force video decoder",    "decoder_name" },
     { "autorotate", OPT_BOOL, { &autorotate }, "automatically rotate video", "" },
+    { "snapto90", OPT_BOOL, { &snapto90 }, "automatically rotate to any angle or multiplies of 90°", "" },
     { NULL, },
 };
 
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list