demux_lavf: support new rotation metadata API

This commit is contained in:
wm4 2014-06-01 17:56:10 +02:00
parent b5e40e15a3
commit 556bb1cf13
3 changed files with 23 additions and 1 deletions

View File

@ -36,6 +36,9 @@
#if HAVE_AVCODEC_REPLAYGAIN_SIDE_DATA
# include <libavutil/replaygain.h>
#endif
#if HAVE_AV_DISPLAYMATRIX
# include <libavutil/display.h>
#endif
#include <libavutil/opt.h>
#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");

View File

@ -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 \

View File

@ -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',