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 | ac0d207a1a7644bb15cf4a3598455b1bea4ad921 (patch) | |
tree | 68ae4902980d8bc16304d00bb74e2272e5516955 /libavcodec/pcm-dvdenc.c | |
parent | d2a360c139f857892433660a4ecf509502d6fa43 (diff) |
pcm: 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/pcm-dvdenc.c')
-rw-r--r-- | libavcodec/pcm-dvdenc.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/libavcodec/pcm-dvdenc.c b/libavcodec/pcm-dvdenc.c index c9afac69d2..e16c2a5fe4 100644 --- a/libavcodec/pcm-dvdenc.c +++ b/libavcodec/pcm-dvdenc.c @@ -60,7 +60,7 @@ static av_cold int pcm_dvd_encode_init(AVCodecContext *avctx) } avctx->bits_per_coded_sample = 16 + quant * 4; - avctx->block_align = avctx->channels * avctx->bits_per_coded_sample / 8; + avctx->block_align = avctx->ch_layout.nb_channels * avctx->bits_per_coded_sample / 8; avctx->bit_rate = avctx->block_align * 8LL * avctx->sample_rate; if (avctx->bit_rate > 9800000) { av_log(avctx, AV_LOG_ERROR, "Too big bitrate: reduce sample rate, bitdepth or channels.\n"); @@ -69,16 +69,16 @@ static av_cold int pcm_dvd_encode_init(AVCodecContext *avctx) if (avctx->sample_fmt == AV_SAMPLE_FMT_S16) { s->samples_per_block = 1; - s->block_size = avctx->channels * 2; + s->block_size = avctx->ch_layout.nb_channels * 2; frame_size = 2008 / s->block_size; } else { - switch (avctx->channels) { + switch (avctx->ch_layout.nb_channels) { case 1: case 2: case 4: /* one group has all the samples needed */ s->block_size = 4 * avctx->bits_per_coded_sample / 8; - s->samples_per_block = 4 / avctx->channels; + s->samples_per_block = 4 / avctx->ch_layout.nb_channels; s->groups_per_block = 1; break; case 8: @@ -88,11 +88,11 @@ static av_cold int pcm_dvd_encode_init(AVCodecContext *avctx) s->groups_per_block = 2; break; default: - /* need avctx->channels groups */ - s->block_size = 4 * avctx->channels * + /* need avctx->ch_layout.nb_channels groups */ + s->block_size = 4 * avctx->ch_layout.nb_channels * avctx->bits_per_coded_sample / 8; s->samples_per_block = 4; - s->groups_per_block = avctx->channels; + s->groups_per_block = avctx->ch_layout.nb_channels; break; } @@ -100,7 +100,7 @@ static av_cold int pcm_dvd_encode_init(AVCodecContext *avctx) } s->header[0] = 0x0c; - s->header[1] = (quant << 6) | (freq << 4) | (avctx->channels - 1); + s->header[1] = (quant << 6) | (freq << 4) | (avctx->ch_layout.nb_channels - 1); s->header[2] = 0x80; if (!avctx->frame_size) @@ -113,7 +113,7 @@ static int pcm_dvd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { PCMDVDContext *s = avctx->priv_data; - int samples = frame->nb_samples * avctx->channels; + int samples = frame->nb_samples * avctx->ch_layout.nb_channels; int64_t pkt_size = (frame->nb_samples / s->samples_per_block) * s->block_size + 3; int blocks = (pkt_size - 3) / s->block_size; const int16_t *src16; @@ -138,7 +138,7 @@ static int pcm_dvd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } while (--samples); break; case AV_SAMPLE_FMT_S32: - if (avctx->channels == 1) { + if (avctx->ch_layout.nb_channels == 1) { do { for (int i = 2; i; i--) { bytestream2_put_be16(&pb, src32[0] >> 16); @@ -181,11 +181,18 @@ const AVCodec ff_pcm_dvd_encoder = { .init = pcm_dvd_encode_init, .encode2 = pcm_dvd_encode_frame, .supported_samplerates = (const int[]) { 48000, 96000, 0}, +#if FF_API_OLD_CHANNEL_LAYOUT .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT1, AV_CH_LAYOUT_7POINT1, 0 }, +#endif + .ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, + AV_CHANNEL_LAYOUT_STEREO, + AV_CHANNEL_LAYOUT_5POINT1, + AV_CHANNEL_LAYOUT_7POINT1, + { 0 } }, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE }, |