From 10d9acda3f2f80f89d90fda378a5e427209760fb Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 25 Apr 2018 09:17:09 -0400 Subject: [PATCH] ffmpeg: handle some API changes for release/4.0 master closes #534 Change-Id: I02ca8e2e3cbe6193705b34f6f2df09205b283022 --- lib/codeclib.c | 2 ++ lib/fix_frame_channel_layout-01.h | 11 ++++++++++- lib/fix_frame_channel_layout-02.h | 5 ++++- lib/fix_frame_channel_layout-03.h | 9 +++++++++ lib/fix_frame_channel_layout-04.h | 9 +++++++++ 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 lib/fix_frame_channel_layout-03.h create mode 100644 lib/fix_frame_channel_layout-04.h diff --git a/lib/codeclib.c b/lib/codeclib.c index c8b594c80..c0a6f6c79 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -695,8 +695,10 @@ static void avc_def_init(codec_def_t *def) { } void codeclib_init(int print) { +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100) av_register_all(); avcodec_register_all(); +#endif avfilter_register_all(); avformat_network_init(); av_log_set_callback(avlog_ilog); diff --git a/lib/fix_frame_channel_layout-01.h b/lib/fix_frame_channel_layout-01.h index 5e24334f8..b0f10769b 100644 --- a/lib/fix_frame_channel_layout-01.h +++ b/lib/fix_frame_channel_layout-01.h @@ -3,7 +3,16 @@ #include "compat.h" INLINE void fix_frame_channel_layout(AVFrame *frame) { - if (frame->channel_layout) + if (frame->channel_layout) { +#if LIBAVUTIL_VERSION_MAJOR < 56 + if (!frame->channels) + frame->channels = av_frame_get_channels(frame); +#endif return; + } +#if LIBAVUTIL_VERSION_MAJOR < 56 frame->channel_layout = av_get_default_channel_layout(av_frame_get_channels(frame)); +#else + frame->channel_layout = av_get_default_channel_layout(frame->channels); +#endif } diff --git a/lib/fix_frame_channel_layout-02.h b/lib/fix_frame_channel_layout-02.h index fac1b29cb..eb597e086 100644 --- a/lib/fix_frame_channel_layout-02.h +++ b/lib/fix_frame_channel_layout-02.h @@ -3,7 +3,10 @@ #include "compat.h" INLINE void fix_frame_channel_layout(AVFrame *frame) { - if (frame->channel_layout) + if (frame->channel_layout) { + if (!frame->channels) + frame->channels = av_frame_get_channels(frame); return; + } frame->channel_layout = av_get_default_channel_layout(frame->channels); } diff --git a/lib/fix_frame_channel_layout-03.h b/lib/fix_frame_channel_layout-03.h new file mode 100644 index 000000000..5e24334f8 --- /dev/null +++ b/lib/fix_frame_channel_layout-03.h @@ -0,0 +1,9 @@ +#include +#include +#include "compat.h" + +INLINE void fix_frame_channel_layout(AVFrame *frame) { + if (frame->channel_layout) + return; + frame->channel_layout = av_get_default_channel_layout(av_frame_get_channels(frame)); +} diff --git a/lib/fix_frame_channel_layout-04.h b/lib/fix_frame_channel_layout-04.h new file mode 100644 index 000000000..fac1b29cb --- /dev/null +++ b/lib/fix_frame_channel_layout-04.h @@ -0,0 +1,9 @@ +#include +#include +#include "compat.h" + +INLINE void fix_frame_channel_layout(AVFrame *frame) { + if (frame->channel_layout) + return; + frame->channel_layout = av_get_default_channel_layout(frame->channels); +}