diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 0d33219dd9..23a89386b7 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -36,6 +36,9 @@ #if HAVE_AVCODEC_REPLAYGAIN_SIDE_DATA # include #endif +#if HAVE_AV_DISPLAYMATRIX +# include +#endif #include #include "compat/libav.h" @@ -482,13 +485,20 @@ static void handle_stream(demuxer_t *demuxer, int i) if (sh_video->bitrate == 0) sh_video->bitrate = avfc->bit_rate; +#if HAVE_AV_DISPLAYMATRIX + uint8_t *sd = av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, NULL); + if (sd) + sh_video->rotate = av_display_rotation_get((uint32_t *)sd); +#else AVDictionaryEntry *rot = av_dict_get(st->metadata, "rotate", NULL, 0); if (rot && rot->value) { char *end = NULL; long int r = strtol(rot->value, &end, 10); if (end && !end[0]) - sh_video->rotate = ((r % 360) + 360) % 360; + sh_video->rotate = r; } +#endif + sh_video->rotate = ((sh_video->rotate % 360) + 360) % 360; // This also applies to vfw-muxed mkv, but we can't detect these easily. sh_video->avi_dts = matches_avinputformat_name(priv, "avi"); diff --git a/old-configure b/old-configure index 21db04c224..3bf27780f1 100755 --- a/old-configure +++ b/old-configure @@ -808,6 +808,12 @@ api_statement_check \ libavcodec/avcodec.h \ 'enum AVPacketSideDataType type = AV_PKT_DATA_REPLAYGAIN' +api_statement_check \ + "libavutil/libavcodec display matrix side data" \ + HAVE_AV_DISPLAYMATRIX \ + libavutil/frame.h \ + 'enum AVFrameSideDataType type = AV_FRAME_DATA_DISPLAYMATRIX' + api_statement_check \ "libavutil AVFrame metadata" \ HAVE_AVFRAME_METADATA \ diff --git a/wscript b/wscript index aca7fbd88d..8780cb220e 100644 --- a/wscript +++ b/wscript @@ -383,6 +383,12 @@ Libav libraries ({0}). Aborting.".format(" ".join(libav_pkg_config_checks)) 'func': check_statement('libavcodec/avcodec.h', 'enum AVPacketSideDataType type = AV_PKT_DATA_REPLAYGAIN', use='libav') + }, { + 'name': 'av-displaymatrix', + 'desc': 'libavutil/libavcodec display matrix side data', + 'func': check_statement('libavutil/frame.h', + 'enum AVFrameSideDataType type = AV_FRAME_DATA_DISPLAYMATRIX', + use='libav') },{ 'name': 'avframe-metadata', 'desc': 'libavutil AVFrame metadata',