lavc audio chann removed: compat

This commit is contained in:
Martin Pulec
2024-12-02 09:56:00 +01:00
parent 38234ecc52
commit 70a04d71b8
2 changed files with 14 additions and 6 deletions

View File

@@ -296,10 +296,7 @@ static bool reinitialize_coder(struct libavcodec_codec_state *s, struct audio_de
return false;
}
s->codec_ctx->channels = 1;
#if LIBAVCODEC_VERSION_MAJOR >= 54
s->codec_ctx->channel_layout = AV_CH_LAYOUT_MONO;
#endif
AVCODECCTX_CHANNELS(s->codec_ctx) = 1;
pthread_mutex_lock(s->libav_global_lock);
/* open it */
@@ -316,8 +313,12 @@ static bool reinitialize_coder(struct libavcodec_codec_state *s, struct audio_de
s->av_frame->nb_samples = s->codec_ctx->frame_size;
s->av_frame->format = s->codec_ctx->sample_fmt;
#if LIBAVCODEC_VERSION_MAJOR >= 54
#if FF_API_NEW_CHANNEL_LAYOUT
s->av_frame->ch_layout = (struct AVChannelLayout) AV_CHANNEL_LAYOUT_MONO;
#else
s->av_frame->channel_layout = AV_CH_LAYOUT_MONO;
#endif
#if LIBAVCODEC_VERSION_MAJOR >= 54
s->av_frame->sample_rate = s->codec_ctx->sample_rate;
#endif
@@ -347,7 +348,7 @@ static bool reinitialize_decoder(struct libavcodec_codec_state *s, struct audio_
avcodec_close(s->codec_ctx);
pthread_mutex_unlock(s->libav_global_lock);
s->codec_ctx->channels = 1;
AVCODECCTX_CHANNELS(s->codec_ctx) = 1;
s->codec_ctx->bits_per_coded_sample = 4; // ADPCM
s->codec_ctx->sample_rate = desc.sample_rate;

View File

@@ -120,6 +120,13 @@ extern "C" {
#define AV_CODEC_ID_AV1 AV_CODEC_ID_NONE
#endif
#if defined FF_API_OLD_CHANNEL_LAYOUT || (LIBAVUTIL_VERSION_MAJOR >= 58)
#define AVCODECCTX_CHANNELS(context) (context)->ch_layout.nb_channels
#define FF_API_NEW_CHANNEL_LAYOUT 1
#else
#define AVCODECCTX_CHANNELS(context) (context)->channels
#endif
// avutil
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51, 42, 0) // FFMPEG commit 78071a1420b
#define AV_PIX_FMT_NONE PIX_FMT_NONE