diff --git a/include/ffmscompat.h b/include/ffmscompat.h index ca13bc59c3..0f6a1e219b 100644 --- a/include/ffmscompat.h +++ b/include/ffmscompat.h @@ -72,7 +72,7 @@ # undef CodecID # endif # if VERSION_CHECK(LIBAVCODEC_VERSION_INT, <, 54, 28, 0, 54, 59, 100) -# define avcodec_free_frame av_free +static void avcodec_free_frame(AVFrame **frame) { av_freep(frame); } # endif #endif diff --git a/src/core/audiosource.h b/src/core/audiosource.h index 23a6a46fb2..49b97562bf 100644 --- a/src/core/audiosource.h +++ b/src/core/audiosource.h @@ -29,6 +29,9 @@ extern "C" { #include #include #include + +#include "ffmscompat.h" + #include "indexing.h" #include "utils.h" #include "ffms.h" diff --git a/src/core/utils.cpp b/src/core/utils.cpp index 9878889e89..703cc23537 100644 --- a/src/core/utils.cpp +++ b/src/core/utils.cpp @@ -22,6 +22,11 @@ #include #include +// avcodec.h includes audioconvert.h, but we need to include audioconvert.h +// ourselves later +#define FF_API_OLD_AUDIOCONVERT 0 +#define AVUTIL_AUDIOCONVERT_H + #include "utils.h" #include "codectype.h" @@ -217,9 +222,18 @@ void InitNullPacket(AVPacket &pkt) { extern "C" { #if VERSION_CHECK(LIBAVUTIL_VERSION_INT, >=, 52, 2, 0, 52, 6, 100) #include -#elif VERSION_CHECK(LIBAVUTIL_VERSION_INT, >=, 51, 26, 0, 51, 45, 100) -#include #else +#undef AVUTIL_AUDIOCONVERT_H + +// Whether or not av_get_default_channel_layout exists in a given version +// depends on which branch that version is from, since FFmpeg doesn't +// understand the concept of version numbers. Work around this by always using +// our copy, since that's less effort than detecting whether or not it's +// available. +#define av_get_default_channel_layout av_get_default_channel_layout_hurr +#include "libavutil/audioconvert.h" +#undef av_get_default_channel_layout + static int64_t av_get_default_channel_layout(int nb_channels) { switch(nb_channels) { case 1: return AV_CH_LAYOUT_MONO;