diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-05-07 07:20:32 +0200 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-03-15 09:42:44 -0300 |
commit | 3caf14e0a4f6d79a79ad7644d0fa456616d3d40d (patch) | |
tree | e4669711954906f3dcca5403de266c1cd664faff /libavcodec/s302menc.c | |
parent | 1d4e6ce31c817e45f00dec44e4071216504d694f (diff) | |
download | ffmpeg-3caf14e0a4f6d79a79ad7644d0fa456616d3d40d.tar.gz |
s302m: convert to new channel layout API
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>
Diffstat (limited to 'libavcodec/s302menc.c')
-rw-r--r-- | libavcodec/s302menc.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libavcodec/s302menc.c b/libavcodec/s302menc.c index 528d712e79..56db25c76b 100644 --- a/libavcodec/s302menc.c +++ b/libavcodec/s302menc.c @@ -37,10 +37,10 @@ static av_cold int s302m_encode_init(AVCodecContext *avctx) { S302MEncContext *s = avctx->priv_data; - if (avctx->channels & 1 || avctx->channels > 8) { + if (avctx->ch_layout.nb_channels & 1 || avctx->ch_layout.nb_channels > 8) { av_log(avctx, AV_LOG_ERROR, "Encoding %d channel(s) is not allowed. Only 2, 4, 6 and 8 channels are supported.\n", - avctx->channels); + avctx->ch_layout.nb_channels); return AVERROR(EINVAL); } @@ -61,7 +61,7 @@ static av_cold int s302m_encode_init(AVCodecContext *avctx) } avctx->frame_size = 0; - avctx->bit_rate = 48000 * avctx->channels * + avctx->bit_rate = 48000 * avctx->ch_layout.nb_channels * (avctx->bits_per_raw_sample + 4); s->framing_index = 0; @@ -72,9 +72,9 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { S302MEncContext *s = avctx->priv_data; + const int nb_channels = avctx->ch_layout.nb_channels; const int buf_size = AES3_HEADER_LEN + - (frame->nb_samples * - avctx->channels * + (frame->nb_samples * nb_channels * (avctx->bits_per_raw_sample + 4)) / 8; int ret, c, channels; uint8_t *o; @@ -91,7 +91,7 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt, o = avpkt->data; init_put_bits(&pb, o, buf_size); put_bits(&pb, 16, buf_size - AES3_HEADER_LEN); - put_bits(&pb, 2, (avctx->channels - 2) >> 1); // number of channels + put_bits(&pb, 2, (nb_channels - 2) >> 1); // number of channels put_bits(&pb, 8, 0); // channel ID put_bits(&pb, 2, (avctx->bits_per_raw_sample - 16) / 4); // bits per samples (0 = 16bit, 1 = 20bit, 2 = 24bit) put_bits(&pb, 4, 0); // alignments @@ -104,7 +104,7 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt, for (c = 0; c < frame->nb_samples; c++) { uint8_t vucf = s->framing_index == 0 ? 0x10: 0; - for (channels = 0; channels < avctx->channels; channels += 2) { + for (channels = 0; channels < nb_channels; channels += 2) { o[0] = ff_reverse[(samples[0] & 0x0000FF00) >> 8]; o[1] = ff_reverse[(samples[0] & 0x00FF0000) >> 16]; o[2] = ff_reverse[(samples[0] & 0xFF000000) >> 24]; @@ -126,7 +126,7 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt, for (c = 0; c < frame->nb_samples; c++) { uint8_t vucf = s->framing_index == 0 ? 0x80: 0; - for (channels = 0; channels < avctx->channels; channels += 2) { + for (channels = 0; channels < nb_channels; channels += 2) { o[0] = ff_reverse[ (samples[0] & 0x000FF000) >> 12]; o[1] = ff_reverse[ (samples[0] & 0x0FF00000) >> 20]; o[2] = ff_reverse[((samples[0] & 0xF0000000) >> 28) | vucf]; @@ -147,7 +147,7 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt, for (c = 0; c < frame->nb_samples; c++) { uint8_t vucf = s->framing_index == 0 ? 0x10 : 0; - for (channels = 0; channels < avctx->channels; channels += 2) { + for (channels = 0; channels < nb_channels; channels += 2) { o[0] = ff_reverse[ samples[0] & 0xFF]; o[1] = ff_reverse[(samples[0] & 0xFF00) >> 8]; o[2] = ff_reverse[(samples[1] & 0x0F) << 4] | vucf; |