[vlc-commits] demux/avformat: Prioritize side data rotation rather than metadata one

Vittorio Giovara git at videolan.org
Fri Mar 1 23:46:45 CET 2019


vlc | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Tue Feb 26 17:00:32 2019 -0500| [1997cec8abd801bbf4ebcae72db28ab8277f221c] | committer: Vittorio Giovara

demux/avformat: Prioritize side data rotation rather than metadata one

The side data API will offer a more accurate representation of the
rendering operations in the next commit.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1997cec8abd801bbf4ebcae72db28ab8277f221c
---

 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;



More information about the vlc-commits mailing list