From e6720ddea4249e095b554e0a28d7aa6a714ff6ac Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 14 May 2021 15:00:34 +0200 Subject: [PATCH] FFmpeg: compilation fix The compat FF_API_PLUS1_MINUS1 macro (babdb792) was incorrectly used - if it were defined, the new depth field is already present. On contrary, if not, depth_minus1 needed to be used. Rather do not depend on it, anyway and use libavutil version. --- src/audio/codec/libavcodec.cpp | 4 ++-- src/video_compress/libavcodec.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/audio/codec/libavcodec.cpp b/src/audio/codec/libavcodec.cpp index fc7a792b6..02fc06e96 100644 --- a/src/audio/codec/libavcodec.cpp +++ b/src/audio/codec/libavcodec.cpp @@ -114,7 +114,7 @@ struct libavcodec_codec_state { uint32_t magic; pthread_mutex_t *libav_global_lock; AVCodecContext *codec_ctx; - AVCodec *codec; + const AVCodec *codec; AVFrame *av_frame; @@ -224,7 +224,7 @@ static void *libavcodec_init(audio_codec_t audio_codec, audio_codec_direction_t } /* check that a given sample format is supported by the encoder */ -static int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt) +static int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat sample_fmt) { const enum AVSampleFormat *p = codec->sample_fmts; diff --git a/src/video_compress/libavcodec.cpp b/src/video_compress/libavcodec.cpp index 7f02ce058..9d7134ffc 100644 --- a/src/video_compress/libavcodec.cpp +++ b/src/video_compress/libavcodec.cpp @@ -779,7 +779,7 @@ static int get_subsampling(enum AVPixelFormat fmt) { * The list is ordered according to input description and requested subsampling. */ static list get_available_pix_fmts(struct video_desc in_desc, - AVCodec *codec, int requested_subsampling, codec_t force_conv_to) + const AVCodec *codec, int requested_subsampling, codec_t force_conv_to) { list fmts; @@ -835,12 +835,12 @@ static list get_available_pix_fmts(struct video_desc in_desc sort(available_formats.begin(), available_formats.end(), [bits_per_comp, is_rgb, preferred_subsampling](enum AVPixelFormat a, enum AVPixelFormat b) { const struct AVPixFmtDescriptor *pda = av_pix_fmt_desc_get(a); const struct AVPixFmtDescriptor *pdb = av_pix_fmt_desc_get(b); -#if defined(FF_API_PLUS1_MINUS1) +#if LIBAVUTIL_VERSION_MAJOR >= 56 int deptha = pda->comp[0].depth; int depthb = pdb->comp[0].depth; #else - int deptha = pda->comp[0].depth_minus1; - int depthb = pdb->comp[0].depth_minus1; + int deptha = pda->comp[0].depth_minus1 + 1; + int depthb = pdb->comp[0].depth_minus1 + 1; #endif #if defined(AV_PIX_FMT_FLAG_RGB) bool rgba = pda->flags & AV_PIX_FMT_FLAG_RGB; @@ -903,7 +903,7 @@ ADD_TO_PARAM("lavc-use-codec", * requested_subsampling. */ list get_requested_pix_fmts(struct video_desc in_desc, - AVCodec *codec, int requested_subsampling) { + const AVCodec *codec, int requested_subsampling) { codec_t force_conv_to = VIDEO_CODEC_NONE; // if non-zero, use only this codec as a target // of UG conversions (before FFMPEG conversion) // or (likely) no conversion at all @@ -1013,7 +1013,7 @@ static bool configure_with(struct state_video_compress_libav *s, struct video_de int ret; codec_t ug_codec = VIDEO_CODEC_NONE; AVPixelFormat pix_fmt; - AVCodec *codec = nullptr; + const AVCodec *codec = nullptr; #ifdef HAVE_SWSCALE sws_freeContext(s->sws_ctx); s->sws_ctx = nullptr;