[FFmpeg-devel] [PATCH 1/2] ffplay: unify displaymatrix based rotation code

Michael Niedermayer michaelni at gmx.at
Sun May 3 22:40:33 CEST 2015


On Sun, May 03, 2015 at 09:16:55PM +0200, Marton Balint wrote:
> 
> On Sun, 3 May 2015, Michael Niedermayer wrote:
> 
> >Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> >---
> >ffplay.c |   45 +++++++++++++++++++++++----------------------
> >1 file changed, 23 insertions(+), 22 deletions(-)
> >
> >diff --git a/ffplay.c b/ffplay.c
> >index 826a473..eea00e6 100644
> >--- a/ffplay.c
> >+++ b/ffplay.c
> >@@ -33,6 +33,7 @@
> >#include "libavutil/avstring.h"
> >#include "libavutil/colorspace.h"
> >#include "libavutil/display.h"
> >+#include "libavutil/eval.h"
> >#include "libavutil/mathematics.h"
> >#include "libavutil/pixdesc.h"
> >#include "libavutil/imgutils.h"
> >@@ -2020,30 +2021,30 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
> >        AVDictionaryEntry *rotate_tag = av_dict_get(is->video_st->metadata, "rotate", NULL, 0);
> >        uint8_t* displaymatrix = av_stream_get_side_data(is->video_st,
> >                                                         AV_PKT_DATA_DISPLAYMATRIX, NULL);
> >+        double theta = 0;
> >
> >        if (rotate_tag && *rotate_tag->value && strcmp(rotate_tag->value, "0")) {
> >-            if (!strcmp(rotate_tag->value, "90")) {
> >-                INSERT_FILT("transpose", "clock");
> >-            } else if (!strcmp(rotate_tag->value, "180")) {
> >-                INSERT_FILT("hflip", NULL);
> >-                INSERT_FILT("vflip", NULL);
> >-            } else if (!strcmp(rotate_tag->value, "270")) {
> >-                INSERT_FILT("transpose", "cclock");
> >-            } else {
> >-                char rotate_buf[64];
> >-                snprintf(rotate_buf, sizeof(rotate_buf), "%s*PI/180", rotate_tag->value);
> >-                INSERT_FILT("rotate", rotate_buf);
> >-            }
> >-        } else if (displaymatrix) {
> >-            double rot = av_display_rotation_get((int32_t*) displaymatrix);
> >-            if (rot < -135 || rot > 135) {
> >-                INSERT_FILT("vflip", NULL);
> >-                INSERT_FILT("hflip", NULL);
> >-            } else if (rot < -45) {
> >-                INSERT_FILT("transpose", "dir=clock");
> >-            } else if (rot > 45) {
> >-                INSERT_FILT("transpose", "dir=cclock");
> >-            }
> >+            char *tail;
> >+            theta = av_strtod(rotate_tag->value, &tail);
> >+            if (*tail)
> >+                theta = 0;
> >+        }
> >+        if (displaymatrix && !theta)
> >+            theta = av_display_rotation_get((int32_t*) displaymatrix);
> >+
> >+        theta -= 360*floor(theta/360 + 0.9/360);
> >+
> >+        if (fabs(theta - 90) < 1.0) {
> >+            INSERT_FILT("transpose", "clock");
> >+        } else if (fabs(theta - 180) < 1.0) {
> >+            INSERT_FILT("hflip", NULL);
> >+            INSERT_FILT("vflip", NULL);
> >+        } else if (fabs(theta - 270) < 1.0) {
> >+            INSERT_FILT("transpose", "cclock");
> >+        } else if (fabs(theta) > 1.0) {
> >+            char rotate_buf[64];
> >+            snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta);
> >+            INSERT_FILT("rotate", rotate_buf);
> >        }
> >    }
> 
> LGTM, thanks.

applied

thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150503/d4d45a6d/attachment.asc>


More information about the ffmpeg-devel mailing list