Quoting James Almer (2022-01-13 03:05:05) > From: Anton Khirnov <anton@khirnov.net> > > Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> > Signed-off-by: Anton Khirnov <anton@khirnov.net> > Signed-off-by: James Almer <jamrial@gmail.com> > --- > libavcodec/libgsmdec.c | 4 ++-- > libavcodec/libgsmenc.c | 4 ++-- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/libgsmdec.c b/libavcodec/libgsmdec.c > index ae4a952d99..aa028bc262 100644 > --- a/libavcodec/libgsmdec.c > +++ b/libavcodec/libgsmdec.c > @@ -48,8 +48,8 @@ typedef struct LibGSMDecodeContext { > static av_cold int libgsm_decode_init(AVCodecContext *avctx) { > LibGSMDecodeContext *s = avctx->priv_data; > > - avctx->channels = 1; > - avctx->channel_layout = AV_CH_LAYOUT_MONO; > + av_channel_layout_uninit(&avctx->ch_layout); > + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; > if (!avctx->sample_rate) > avctx->sample_rate = 8000; > avctx->sample_fmt = AV_SAMPLE_FMT_S16; > diff --git a/libavcodec/libgsmenc.c b/libavcodec/libgsmenc.c > index a2f6c1c62e..f73f254d50 100644 > --- a/libavcodec/libgsmenc.c > +++ b/libavcodec/libgsmenc.c > @@ -49,9 +49,9 @@ static av_cold int libgsm_encode_close(AVCodecContext *avctx) { > } > > static av_cold int libgsm_encode_init(AVCodecContext *avctx) { > - if (avctx->channels > 1) { > + if (avctx->ch_layout.nb_channels > 1) { > av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n", > - avctx->channels); > + avctx->ch_layout.nb_channels); > return -1; This could be dropped completely, since the codec sets ch_layouts.
diff --git a/libavcodec/libgsmdec.c b/libavcodec/libgsmdec.c index ae4a952d99..aa028bc262 100644 --- a/libavcodec/libgsmdec.c +++ b/libavcodec/libgsmdec.c @@ -48,8 +48,8 @@ typedef struct LibGSMDecodeContext { static av_cold int libgsm_decode_init(AVCodecContext *avctx) { LibGSMDecodeContext *s = avctx->priv_data; - avctx->channels = 1; - avctx->channel_layout = AV_CH_LAYOUT_MONO; + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; if (!avctx->sample_rate) avctx->sample_rate = 8000; avctx->sample_fmt = AV_SAMPLE_FMT_S16; diff --git a/libavcodec/libgsmenc.c b/libavcodec/libgsmenc.c index a2f6c1c62e..f73f254d50 100644 --- a/libavcodec/libgsmenc.c +++ b/libavcodec/libgsmenc.c @@ -49,9 +49,9 @@ static av_cold int libgsm_encode_close(AVCodecContext *avctx) { } static av_cold int libgsm_encode_init(AVCodecContext *avctx) { - if (avctx->channels > 1) { + if (avctx->ch_layout.nb_channels > 1) { av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n", - avctx->channels); + avctx->ch_layout.nb_channels); return -1; }