diff options
author | Anton Khirnov <anton@khirnov.net> | 2019-06-04 12:35:16 +0200 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-03-15 09:42:45 -0300 |
commit | 73cb6c87acd270551253db1871b245ffe3420d5b (patch) | |
tree | 908b4853a60a8fdd598cf6220d05f5cf9c8cdf5b /libavcodec/sonic.c | |
parent | a9dfca7c59094808cd88b26d31f10b868edef475 (diff) | |
download | ffmpeg-73cb6c87acd270551253db1871b245ffe3420d5b.tar.gz |
sonic: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/sonic.c')
-rw-r--r-- | libavcodec/sonic.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index cf1cfb1460..34f1605b29 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -598,13 +598,13 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx) s->version = 2; - if (avctx->channels > MAX_CHANNELS) + if (avctx->ch_layout.nb_channels > MAX_CHANNELS) { av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n"); return AVERROR(EINVAL); /* only stereo or mono for now */ } - if (avctx->channels == 2) + if (avctx->ch_layout.nb_channels == 2) s->decorrelation = MID_SIDE; else s->decorrelation = 3; @@ -637,7 +637,7 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx) for (i = 0; i < s->num_taps; i++) s->tap_quant[i] = ff_sqrt(i+1); - s->channels = avctx->channels; + s->channels = avctx->ch_layout.nb_channels; s->samplerate = avctx->sample_rate; s->block_align = 2048LL*s->samplerate/(44100*s->downsampling); @@ -853,7 +853,7 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx) int i; int ret; - s->channels = avctx->channels; + s->channels = avctx->ch_layout.nb_channels; s->samplerate = avctx->sample_rate; if (!avctx->extradata) @@ -896,7 +896,9 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "Only mono and stereo streams are supported by now\n"); return AVERROR_INVALIDDATA; } - avctx->channels = s->channels; + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + avctx->ch_layout.nb_channels = s->channels; s->lossless = get_bits1(&gb); if (!s->lossless) @@ -989,7 +991,7 @@ static int sonic_decode_frame(AVCodecContext *avctx, if (buf_size == 0) return 0; - frame->nb_samples = s->frame_size / avctx->channels; + frame->nb_samples = s->frame_size / avctx->ch_layout.nb_channels; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; samples = (int16_t *)frame->data[0]; |