[vlc-devel] [PATCH 4/7] Support for rotated MP4 Movies (bug #2882)

Matthias Keiser matthias at tristan-inc.com
Mon Feb 17 01:32:20 CET 2014


---
 modules/demux/avformat/demux.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index b550ca9..be596b3 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -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 )
             {
-- 
1.8.3.4 (Apple Git-47)





More information about the vlc-devel mailing list