]> git.sesse.net Git - vlc/commitdiff
Avformat: Support rotation information
authorMatthias Keiser <matthias@tristan-inc.com>
Mon, 17 Feb 2014 00:32:20 +0000 (01:32 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 18 Feb 2014 10:26:49 +0000 (11:26 +0100)
Notably for mp4

Ref #2882

modules/demux/avformat/demux.c

index b550ca9c8fe3cb6b04933177c564ab7f28b2e48a..92fcbc04a675fed54e2315a5d497136377ad032e 100644 (file)
@@ -335,6 +335,28 @@ int OpenDemux( vlc_object_t *p_this )
 
             fmt.video.i_width = cc->width;
             fmt.video.i_height = cc->height;
+
+            char const *kRotateKey = "rotate";
+            AVDictionaryEntry *rotation = av_dict_get(s->metadata, kRotateKey, NULL, 0);
+
+            if( rotation )
+            {
+
+                long angle = strtol(rotation->value, NULL, 10);
+
+                if (angle > 45 && angle < 135)
+                    fmt.video.orientation = ORIENT_ROTATED_270;
+
+                else if (angle > 135 && angle < 225)
+                    fmt.video.orientation = ORIENT_ROTATED_180;
+
+                else if (angle > 225 && angle < 315)
+                    fmt.video.orientation = ORIENT_ROTATED_90;
+
+                else
+                    fmt.video.orientation = ORIENT_NORMAL;
+            }
+
 #if LIBAVCODEC_VERSION_MAJOR < 54
             if( cc->palctrl )
             {