]> granicus.if.org Git - handbrake/commitdiff
libhb: read video rotation from libav.
authorDamiano Galassi <damiog@gmail.com>
Mon, 7 Aug 2017 06:25:28 +0000 (08:25 +0200)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Thu, 9 Nov 2017 17:04:15 +0000 (09:04 -0800)
libhb/common.h
libhb/hbffmpeg.h
libhb/stream.c

index e39c3a7783e201ad44a4fda4135fffab606e163f..2b8467d82d9cde96a0268d7d24930a0ee855244b 100644 (file)
@@ -1015,6 +1015,7 @@ struct hb_title_s
 
     int           preview_count;
     int           has_resolution_change;
+    enum { HB_ROTATION_0, HB_ROTATION_90, HB_ROTATION_180, HB_ROTATION_270 } rotation;
     hb_geometry_t geometry;
     hb_rational_t dar;             // aspect ratio for the title's video
     hb_rational_t container_dar;   // aspect ratio from container (0 if none)
index e15f91650d7a05f554265dab493709e8dd110b00..82930ad961061c3143b5eb53fe340d0ad65e3d7c 100644 (file)
@@ -15,6 +15,7 @@
 #include "libavutil/opt.h"
 #include "libavutil/avutil.h"
 #include "libavutil/downmix_info.h"
+#include "libavutil/display.h"
 #include "libswscale/swscale.h"
 #include "libavresample/avresample.h"
 #include "common.h"
index a2d50447ec426d670cef26fe7d4ff60e6e759b75..ba1d41761746590f6a4e443ddef0dbf6806ad8ae 100644 (file)
@@ -5543,6 +5543,37 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title )
                 title->geometry.par.den = ic->streams[i]->sample_aspect_ratio.den;
             }
 
+            int j;
+            for (j = 0; j < ic->streams[i]->nb_side_data; j++)
+            {
+                AVPacketSideData sd = ic->streams[i]->side_data[j];
+                switch (sd.type)
+                {
+                    case AV_PKT_DATA_DISPLAYMATRIX:
+                    {
+                        int rotation = av_display_rotation_get((int32_t *)sd.data);
+                        switch (rotation) {
+                            case 90:
+                                title->rotation = HB_ROTATION_90;
+                                break;
+                            case 180:
+                            case -180:
+                                title->rotation = HB_ROTATION_180;
+                                break;
+                            case -90:
+                            case 270:
+                                title->rotation = HB_ROTATION_270;
+                                break;
+                            default:
+                                break;
+                        }
+                        break;
+                    }
+                    default:
+                        break;
+                }
+            }
+
             title->video_codec = WORK_DECAVCODECV;
             title->video_codec_param = codecpar->codec_id;
             if (ic->iformat->raw_codec_id != AV_CODEC_ID_NONE)