all repos — mgba @ 0ac6f0862c61b1d49a1cfb97c8189dc763085b2e

mGBA Game Boy Advance Emulator

FFmpeg: Use max of libav and FFmpeg version numbers
Jeffrey Pfau jeffrey@endrift.com
Sat, 17 Sep 2016 01:23:27 -0700
commit

0ac6f0862c61b1d49a1cfb97c8189dc763085b2e

parent

16ff5802b6fed375b86d3261fe6dd1913c9008a0

2 files changed, 20 insertions(+), 3 deletions(-)

jump to
M src/feature/ffmpeg/ffmpeg-encoder.csrc/feature/ffmpeg/ffmpeg-encoder.c

@@ -214,8 +214,13 @@ encoder->context->oformat = oformat;

#endif if (acodec) { +#ifdef FFMPEG_USE_CODECPAR encoder->audioStream = avformat_new_stream(encoder->context, NULL); encoder->audio = avcodec_alloc_context3(acodec); +#else + encoder->audioStream = avformat_new_stream(encoder->context, acodec); + encoder->audio = encoder->audioStream->codec; +#endif encoder->audio->bit_rate = encoder->audioBitrate; encoder->audio->channels = 2; encoder->audio->channel_layout = AV_CH_LAYOUT_STEREO;

@@ -266,13 +271,18 @@ #else

encoder->absf = av_bitstream_filter_init("aac_adtstoasc"); #endif } -#ifdef FFMPEG_USE_NEW_BSF +#ifdef FFMPEG_USE_CODECPAR avcodec_parameters_from_context(encoder->audioStream->codecpar, encoder->audio); #endif } +#ifdef FFMPEG_USE_CODECPAR encoder->videoStream = avformat_new_stream(encoder->context, NULL); encoder->video = avcodec_alloc_context3(vcodec); +#else + encoder->videoStream = avformat_new_stream(encoder->context, vcodec); + encoder->video = encoder->videoStream->codec; +#endif encoder->video->bit_rate = encoder->videoBitrate; encoder->video->width = encoder->width; encoder->video->height = encoder->height;

@@ -306,7 +316,7 @@ encoder->videoFrame->height = encoder->video->height;

encoder->videoFrame->pts = 0; _ffmpegSetVideoDimensions(&encoder->d, encoder->iwidth, encoder->iheight); av_image_alloc(encoder->videoFrame->data, encoder->videoFrame->linesize, encoder->video->width, encoder->video->height, encoder->video->pix_fmt, 32); -#ifdef FFMPEG_USE_NEW_BSF +#ifdef FFMPEG_USE_CODECPAR avcodec_parameters_from_context(encoder->videoStream->codecpar, encoder->video); #endif
M src/feature/ffmpeg/ffmpeg-encoder.hsrc/feature/ffmpeg/ffmpeg-encoder.h

@@ -11,12 +11,19 @@

#include <libavformat/avformat.h> #include <libavcodec/version.h> +// Version 57.16 in FFmpeg #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 100) #define FFMPEG_USE_PACKETS #endif -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 15, 0) +// Version 57.15 in libav +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 35, 0) #define FFMPEG_USE_NEW_BSF +#endif + +// Version 57.14 in libav +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 0) +#define FFMPEG_USE_CODECPAR #endif #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 8, 0)