[vlc-devel] [PATCH 1/3] demux: Prioritize side data rotation rather than metadata one

Vittorio Giovara vittorio.giovara at gmail.com
Wed Feb 27 00:40:51 CET 2019


The side data API will offer a more accurate representation of the
rendering operations in the next commit.
---
 modules/demux/avformat/demux.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index ba91e8deb9..b57438afea 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -116,34 +116,33 @@ static void get_rotation(es_format_t *fmt, AVStream *s)
     AVDictionaryEntry *rotation = av_dict_get(s->metadata, kRotateKey, NULL, 0);
     long angle = 0;
 
-    if( rotation )
-    {
-        angle = strtol(rotation->value, NULL, 10);
+    int32_t *matrix = (int32_t *)av_stream_get_side_data(s, AV_PKT_DATA_DISPLAYMATRIX, NULL);
+    if( matrix ) {
+        angle = lround(av_display_rotation_get(matrix));
 
         if (angle > 45 && angle < 135)
-            fmt->video.orientation = ORIENT_ROTATED_90;
+            fmt->video.orientation = ORIENT_ROTATED_270;
 
-        else if (angle > 135 && angle < 225)
+        else if (angle > 135 || angle < -135)
             fmt->video.orientation = ORIENT_ROTATED_180;
 
-        else if (angle > 225 && angle < 315)
-            fmt->video.orientation = ORIENT_ROTATED_270;
+        else if (angle < -45 && angle > -135)
+            fmt->video.orientation = ORIENT_ROTATED_90;
 
         else
             fmt->video.orientation = ORIENT_NORMAL;
-    }
-    int32_t *matrix = (int32_t *)av_stream_get_side_data(s, AV_PKT_DATA_DISPLAYMATRIX, NULL);
-    if( matrix ) {
-        angle = lround(av_display_rotation_get(matrix));
+
+    } else if( rotation ) {
+        angle = strtol(rotation->value, NULL, 10);
 
         if (angle > 45 && angle < 135)
-            fmt->video.orientation = ORIENT_ROTATED_270;
+            fmt->video.orientation = ORIENT_ROTATED_90;
 
-        else if (angle > 135 || angle < -135)
+        else if (angle > 135 && angle < 225)
             fmt->video.orientation = ORIENT_ROTATED_180;
 
-        else if (angle < -45 && angle > -135)
-            fmt->video.orientation = ORIENT_ROTATED_90;
+        else if (angle > 225 && angle < 315)
+            fmt->video.orientation = ORIENT_ROTATED_270;
 
         else
             fmt->video.orientation = ORIENT_NORMAL;
-- 
2.20.1



More information about the vlc-devel mailing list