From: Steve Lhomme Date: Wed, 19 Jun 2024 11:59:15 +0000 (+0200) Subject: avcommon: use a specific macro to check the FFmpeg libavcodec version X-Git-Tag: archive/raspbian/3.0.21-7+rpi1^2~39 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4969d59c1b6e0f074afe2094b77925d9de574f90;p=vlc.git avcommon: use a specific macro to check the FFmpeg libavcodec version This macro doesn't check for libav which is assumed to not have to relevant code. This is the same macro name used in VLC 4.0. Gbp-Pq: Name 0087-avcommon-use-a-specific-macro-to-check-the-FFmpeg-li.patch --- diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c index 7a979e96..a3f67f7b 100644 --- a/modules/codec/avcodec/audio.c +++ b/modules/codec/avcodec/audio.c @@ -142,7 +142,7 @@ static int OpenAudioCodec( decoder_t *p_dec ) } ctx->sample_rate = p_dec->fmt_in.audio.i_rate; -#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100) +#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) av_channel_layout_default( &ctx->ch_layout, p_dec->fmt_in.audio.i_channels ); #else ctx->channels = p_dec->fmt_in.audio.i_channels; @@ -402,7 +402,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ret = avcodec_receive_frame( ctx, frame ); if( ret == 0 ) { -#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100) +#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) int channels = frame->ch_layout.nb_channels; #else int channels = ctx->channels; @@ -592,7 +592,7 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust ) p_dec->fmt_out.audio.i_rate = p_sys->p_context->sample_rate; /* */ -#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100) +#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) if( p_sys->i_previous_channels == p_sys->p_context->ch_layout.nb_channels && p_sys->i_previous_layout == p_sys->p_context->ch_layout.u.mask ) return; @@ -617,7 +617,7 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust ) int i_channels_src = 0, channel_count; uint64_t channel_layout_mask; -#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100) +#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) channel_layout_mask = p_sys->p_context->ch_layout.u.mask; channel_count = p_sys->p_context->ch_layout.nb_channels; #elif API_CHANNEL_LAYOUT diff --git a/modules/codec/avcodec/avcommon.h b/modules/codec/avcodec/avcommon.h index aa0c0b88..10ad13dc 100644 --- a/modules/codec/avcodec/avcommon.h +++ b/modules/codec/avcodec/avcommon.h @@ -123,7 +123,7 @@ static inline void vlc_init_avcodec(vlc_object_t *obj) vlc_init_avutil(obj); -#if (LIBAVFORMAT_VERSION_MICRO < 100) || (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 10, 100)) +#if (LIBAVFORMAT_VERSION_MICRO < 100) || !(LIBAVCODEC_VERSION_CHECK(58, 10, 100)) avcodec_register_all(); #endif diff --git a/modules/codec/avcodec/avcommon_compat.h b/modules/codec/avcodec/avcommon_compat.h index b504fcd8..ac02c06d 100644 --- a/modules/codec/avcodec/avcommon_compat.h +++ b/modules/codec/avcodec/avcommon_compat.h @@ -30,6 +30,10 @@ #ifdef HAVE_LIBAVCODEC_AVCODEC_H #include +/* check the FFmpeg libavutil version */ +#define LIBAVCODEC_VERSION_CHECK( a, d, e ) \ + (LIBAVCODEC_VERSION_MICRO >= 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( a, d, e ) ) + /* LIBAV_CODEC_VERSION_CHECK checks for the right version of libav and FFmpeg * a is the major version * b and c the minor and micro versions of libav diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c index 607a1bcb..890473e9 100644 --- a/modules/codec/avcodec/directx_va.c +++ b/modules/codec/avcodec/directx_va.c @@ -274,7 +274,7 @@ static const directx_va_mode_t DXVA_MODES[] = { /* VPx */ { "VP8", &DXVA_ModeVP8_VLD, 8, 0, NULL }, -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 57, 17, 100 ) && LIBAVCODEC_VERSION_MICRO >= 100 +#if LIBAVCODEC_VERSION_CHECK( 57, 17, 100 ) { "VP9 profile 0", &DXVA_ModeVP9_VLD_Profile0, 8, AV_CODEC_ID_VP9, PROF_VP9_MAIN }, { "VP9 profile 2", &DXVA_ModeVP9_VLD_10bit_Profile2, 10, AV_CODEC_ID_VP9, PROF_VP9_10 }, #else @@ -284,7 +284,7 @@ static const directx_va_mode_t DXVA_MODES[] = { { "VP9 profile Intel", &DXVA_ModeVP9_VLD_Intel, 8, 0, NULL }, /* AV1 */ -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 58, 112, 103 ) && LIBAVCODEC_VERSION_MICRO >= 100 +#if LIBAVCODEC_VERSION_CHECK( 58, 112, 103 ) { "AV1 Main profile 8", &DXVA_ModeAV1_VLD_Profile0, 8, AV_CODEC_ID_AV1, PROF_AV1_MAIN }, { "AV1 Main profile 10", &DXVA_ModeAV1_VLD_Profile0, 10, AV_CODEC_ID_AV1, PROF_AV1_MAIN }, { "AV1 High profile 8", &DXVA_ModeAV1_VLD_Profile1, 8, AV_CODEC_ID_AV1, PROF_AV1_HIGH }, diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c index 9cf9a7d0..2014b8af 100644 --- a/modules/codec/avcodec/encoder.c +++ b/modules/codec/avcodec/encoder.c @@ -61,8 +61,7 @@ #define RAW_AUDIO_FRAME_SIZE (2048) -#if LIBAVCODEC_VERSION_MICRO >= 100 && \ - LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 0, 100) +#if LIBAVCODEC_VERSION_CHECK(59, 0, 100) # define AVC_MAYBE_CONST const #else # define AVC_MAYBE_CONST @@ -183,7 +182,7 @@ static const uint64_t pi_channels_map[][2] = { AV_CH_STEREO_RIGHT, 0 }, }; -# if !LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100) +# if !LIBAVCODEC_VERSION_CHECK(59, 24, 100) static const uint32_t channel_mask[][2] = { {0,0}, {AOUT_CHAN_CENTER, AV_CH_LAYOUT_MONO}, @@ -765,7 +764,7 @@ int InitVideoEnc( vlc_object_t *p_this ) uint32_t order_mask = 0; int i_channels_src = 0; msg_Dbg( p_enc, "Creating channel order for reordering"); -# if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100) +# if LIBAVCODEC_VERSION_CHECK(59, 24, 100) av_channel_layout_default( &p_context->ch_layout, p_enc->fmt_out.audio.i_channels ); uint64_t channel_mask = p_context->ch_layout.u.mask; # else @@ -918,7 +917,7 @@ errmsg: if( p_enc->fmt_out.audio.i_channels > 2 ) { -#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100) +#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) av_channel_layout_default( &p_context->ch_layout, 2 ); #else p_context->channels = 2; @@ -1282,7 +1281,7 @@ static block_t *handle_delay_buffer( encoder_t *p_enc, encoder_sys_t *p_sys, uns av_frame_unref( p_sys->frame ); p_sys->frame->format = p_sys->p_context->sample_fmt; p_sys->frame->nb_samples = leftover_samples + p_sys->i_samples_delay; -#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100) +#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) av_channel_layout_copy(&p_sys->frame->ch_layout, &p_sys->p_context->ch_layout); #else p_sys->frame->channel_layout = p_sys->p_context->channel_layout; @@ -1417,7 +1416,7 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf ) p_sys->frame->pts = date_Get( &p_sys->buffer_date ) * p_sys->p_context->time_base.den / CLOCK_FREQ / p_sys->p_context->time_base.num; -#if LIBAV_CODEC_VERSION_CHECK(59, 999, 999, 24, 100) +#if LIBAVCODEC_VERSION_CHECK(59, 24, 100) av_channel_layout_copy(&p_sys->frame->ch_layout, &p_sys->p_context->ch_layout); #else p_sys->frame->channel_layout = p_sys->p_context->channel_layout; diff --git a/modules/codec/avcodec/fourcc.c b/modules/codec/avcodec/fourcc.c index 3aea6b58..d75c21ff 100644 --- a/modules/codec/avcodec/fourcc.c +++ b/modules/codec/avcodec/fourcc.c @@ -182,12 +182,10 @@ static const struct vlc_avcodec_fourcc video_codecs[] = /* AV_CODEC_ID_V210X */ { VLC_CODEC_TMV, AV_CODEC_ID_TMV }, { VLC_CODEC_V210, AV_CODEC_ID_V210 }, -#if LIBAVCODEC_VERSION_MICRO >= 100 -# if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 59, 42, 102 ) +#if LIBAVCODEC_VERSION_CHECK( 59, 42, 102 ) { VLC_CODEC_VUYA, AV_CODEC_ID_RAWVIDEO }, -# elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 50, 100 ) +#elif LIBAVCODEC_VERSION_CHECK( 54, 50, 100 ) { VLC_CODEC_VUYA, AV_CODEC_ID_AYUV }, -# endif #endif /* AV_CODEC_ID_DPX */ { VLC_CODEC_MAD, AV_CODEC_ID_MAD }, @@ -285,19 +283,19 @@ static const struct vlc_avcodec_fourcc video_codecs[] = /* ffmpeg only: AV_CODEC_ID_SNOW */ /* ffmpeg only: AV_CODEC_ID_SMVJPEG */ -#if LIBAV_CODEC_VERSION_CHECK( 57, 999, 999, 24, 102 ) +#if LIBAVCODEC_VERSION_CHECK( 57, 24, 102 ) { VLC_CODEC_CINEFORM, AV_CODEC_ID_CFHD }, #endif -#if LIBAV_CODEC_VERSION_CHECK( 57, 999, 999, 70, 100 ) +#if LIBAVCODEC_VERSION_CHECK( 57, 70, 100 ) { VLC_CODEC_PIXLET, AV_CODEC_ID_PIXLET }, #endif -#if LIBAV_CODEC_VERSION_CHECK( 57, 999, 999, 71, 101 ) +#if LIBAVCODEC_VERSION_CHECK( 57, 71, 101 ) { VLC_CODEC_SPEEDHQ, AV_CODEC_ID_SPEEDHQ }, #endif -#if LIBAV_CODEC_VERSION_CHECK( 57, 999, 999, 79, 100 ) +#if LIBAVCODEC_VERSION_CHECK( 57, 79, 100 ) { VLC_CODEC_FMVC, AV_CODEC_ID_FMVC }, #endif }; @@ -414,7 +412,7 @@ static const struct vlc_avcodec_fourcc audio_codecs[] = /* AV_CODEC_ID_WESTWOOD_SND1 */ { VLC_CODEC_GSM, AV_CODEC_ID_GSM }, { VLC_CODEC_QDM2, AV_CODEC_ID_QDM2 }, -#if LIBAV_CODEC_VERSION_CHECK( 57, 999, 999, 71, 100 ) +#if LIBAVCODEC_VERSION_CHECK( 57, 71, 100 ) { VLC_CODEC_QDMC, AV_CODEC_ID_QDMC }, #endif { VLC_CODEC_COOK, AV_CODEC_ID_COOK }, @@ -482,7 +480,7 @@ static const struct vlc_avcodec_fourcc spu_codecs[] = { VLC_CODEC_SSA, AV_CODEC_ID_SSA }, /* AV_CODEC_ID_MOV_TEXT */ { VLC_CODEC_BD_PG, AV_CODEC_ID_HDMV_PGS_SUBTITLE }, -#if LIBAV_CODEC_VERSION_CHECK( 57, 999, 999, 71, 100 ) +#if LIBAVCODEC_VERSION_CHECK( 57, 71, 100 ) { VLC_CODEC_BD_TEXT, AV_CODEC_ID_HDMV_TEXT_SUBTITLE }, #endif { VLC_CODEC_TELETEXT, AV_CODEC_ID_DVB_TELETEXT }, diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c index 552c602e..c306e916 100644 --- a/modules/codec/avcodec/video.c +++ b/modules/codec/avcodec/video.c @@ -1824,8 +1824,7 @@ no_reuse: if (!can_hwaccel) return swfmt; -#if (LIBAVCODEC_VERSION_MICRO >= 100) \ - && (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 83, 101)) +#if (LIBAVCODEC_VERSION_MICRO >= 100) && !(LIBAVCODEC_VERSION_CHECK(57, 83, 101)) if (p_context->active_thread_type) { msg_Warn(p_dec, "thread type %d: disabling hardware acceleration", diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c index 39d2366c..9975b0f4 100644 --- a/modules/demux/avformat/demux.c +++ b/modules/demux/avformat/demux.c @@ -400,7 +400,7 @@ int avformat_OpenDemux( vlc_object_t *p_this ) es_format_Init( &es_fmt, AUDIO_ES, fcc ); es_fmt.i_original_fourcc = CodecTagToFourcc( cp->codec_tag ); es_fmt.i_bitrate = cp->bit_rate; -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 59, 24, 100 ) && LIBAVCODEC_VERSION_MICRO >= 100 +#if LIBAVCODEC_VERSION_CHECK( 59, 24, 100 ) es_fmt.audio.i_channels = cp->ch_layout.nb_channels; #else es_fmt.audio.i_channels = cp->channels; diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c index 664a6467..a48190c9 100644 --- a/modules/demux/avformat/mux.c +++ b/modules/demux/avformat/mux.c @@ -273,7 +273,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) { case AUDIO_ES: codecpar->codec_type = AVMEDIA_TYPE_AUDIO; -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 59, 24, 100 ) && LIBAVCODEC_VERSION_MICRO >= 100 +#if LIBAVCODEC_VERSION_CHECK( 59, 24, 100 ) av_channel_layout_default( &codecpar->ch_layout, fmt->audio.i_channels ); #else codecpar->channels = fmt->audio.i_channels;