summaryrefslogtreecommitdiff
path: root/libavcodec/sbcenc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2019-06-04 12:31:31 +0200
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:44 -0300
commitb7483d02c246b1f5155eb156c98785830560a7b4 (patch)
treed047cf3dcc086a63c2e7187ba289e29ae8ac3b7b /libavcodec/sbcenc.c
parent3caf14e0a4f6d79a79ad7644d0fa456616d3d40d (diff)
downloadffmpeg-b7483d02c246b1f5155eb156c98785830560a7b4.tar.gz
sbc: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/sbcenc.c')
-rw-r--r--libavcodec/sbcenc.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libavcodec/sbcenc.c b/libavcodec/sbcenc.c
index 45156277b7..cff93e8917 100644
--- a/libavcodec/sbcenc.c
+++ b/libavcodec/sbcenc.c
@@ -202,7 +202,7 @@ static int sbc_encode_init(AVCodecContext *avctx)
sbc->msbc = 1;
if (sbc->msbc) {
- if (avctx->channels != 1) {
+ if (avctx->ch_layout.nb_channels != 1) {
av_log(avctx, AV_LOG_ERROR, "mSBC require mono channel.\n");
return AVERROR(EINVAL);
}
@@ -227,7 +227,7 @@ static int sbc_encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- if (avctx->channels == 1) {
+ if (avctx->ch_layout.nb_channels == 1) {
frame->mode = SBC_MODE_MONO;
if (sbc->max_delay <= 3000 || avctx->bit_rate > 270000)
frame->subbands = 4;
@@ -251,7 +251,7 @@ static int sbc_encode_init(AVCodecContext *avctx)
d = frame->blocks * ((frame->mode == SBC_MODE_DUAL_CHANNEL) + 1);
frame->bitpool = (((avctx->bit_rate * frame->subbands * frame->blocks) / avctx->sample_rate)
- - 4 * frame->subbands * avctx->channels
+ - 4 * frame->subbands * avctx->ch_layout.nb_channels
- (frame->mode == SBC_MODE_JOINT_STEREO)*frame->subbands - 32 + d/2) / d;
if (avctx->global_quality > 0)
frame->bitpool = avctx->global_quality / FF_QP2LAMBDA;
@@ -263,8 +263,8 @@ static int sbc_encode_init(AVCodecContext *avctx)
if (avctx->sample_rate == avctx->codec->supported_samplerates[i])
frame->frequency = i;
- frame->channels = avctx->channels;
- frame->codesize = frame->subbands * frame->blocks * avctx->channels * 2;
+ frame->channels = avctx->ch_layout.nb_channels;
+ frame->codesize = frame->subbands * frame->blocks * avctx->ch_layout.nb_channels * 2;
frame->crc_ctx = av_crc_get_table(AV_CRC_8_EBU);
memset(&sbc->dsp.X, 0, sizeof(sbc->dsp.X));
@@ -353,8 +353,13 @@ const AVCodec ff_sbc_encoder = {
.init = sbc_encode_init,
.encode2 = sbc_encode_frame,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
+#if FF_API_OLD_CHANNEL_LAYOUT
.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO,
AV_CH_LAYOUT_STEREO, 0},
+#endif
+ .ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO,
+ AV_CHANNEL_LAYOUT_STEREO,
+ { 0 } },
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE },
.supported_samplerates = (const int[]) { 16000, 32000, 44100, 48000, 0 },