diff options
author | Damiano Galassi <[email protected]> | 2017-08-07 08:25:28 +0200 |
---|---|---|
committer | John Stebbins <[email protected]> | 2017-11-09 09:04:15 -0800 |
commit | 9d67804d059c9d0946ba73bba229c69a78ea7439 (patch) | |
tree | 5374a1e371698fd22a70b65a2f1071065131d27c /libhb | |
parent | 8f7da9e73c6fcd98b4d3d1b3fb55d56af555ce05 (diff) |
libhb: read video rotation from libav.
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.h | 1 | ||||
-rw-r--r-- | libhb/hbffmpeg.h | 1 | ||||
-rw-r--r-- | libhb/stream.c | 31 |
3 files changed, 33 insertions, 0 deletions
diff --git a/libhb/common.h b/libhb/common.h index e39c3a778..2b8467d82 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -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) diff --git a/libhb/hbffmpeg.h b/libhb/hbffmpeg.h index e15f91650..82930ad96 100644 --- a/libhb/hbffmpeg.h +++ b/libhb/hbffmpeg.h @@ -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" diff --git a/libhb/stream.c b/libhb/stream.c index a2d50447e..ba1d41761 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -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) |