From 6dcca2b980aee5f8b4b167db357b6dc57e3707e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Thu, 14 Mar 2019 16:20:42 -0400 Subject: [PATCH] rotation: fix build with ffmpeg < 4.0 Change-Id: I975fb3844b135c7eb15357558e52f9bbfee13237 --- src/media/libav_deps.h | 5 +++++ src/media/libav_utils.cpp | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/media/libav_deps.h b/src/media/libav_deps.h index 0e5eb3253c..0f16c78887 100644 --- a/src/media/libav_deps.h +++ b/src/media/libav_deps.h @@ -39,6 +39,11 @@ extern "C" { #include <libavutil/intreadwrite.h> #include <libavutil/log.h> #include <libavutil/samplefmt.h> + +#if LIBAVUTIL_VERSION_MAJOR < 56 +AVFrameSideData* +av_frame_new_side_data_from_buf(AVFrame* frame, enum AVFrameSideDataType type, AVBufferRef* buf); +#endif } #include "libav_utils.h" diff --git a/src/media/libav_utils.cpp b/src/media/libav_utils.cpp index 50f6fbea76..aade971200 100644 --- a/src/media/libav_utils.cpp +++ b/src/media/libav_utils.cpp @@ -23,7 +23,9 @@ #include "libav_deps.h" // MUST BE INCLUDED FIRST +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "video/video_base.h" #include "logger.h" @@ -36,6 +38,20 @@ #include <exception> #include <ciso646> // fix windows compiler bug +extern "C" { +#if LIBAVUTIL_VERSION_MAJOR < 56 +AVFrameSideData* +av_frame_new_side_data_from_buf(AVFrame* frame, enum AVFrameSideDataType type, AVBufferRef* buf) +{ + auto side_data = av_frame_new_side_data(frame, type, 0); + av_buffer_unref(&side_data->buf); + side_data->buf = buf; + side_data->data = side_data->buf->data; + side_data->size = side_data->buf->size; +} +#endif +} + namespace ring { namespace libav_utils { #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100) -- GitLab