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-dvd.c | |
parent | d2a360c139f857892433660a4ecf509502d6fa43 (diff) | |
download | ffmpeg-ac0d207a1a7644bb15cf4a3598455b1bea4ad921.tar.gz |
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-dvd.c')
-rw-r--r-- | libavcodec/pcm-dvd.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c index 775d342eaa..7f991bba65 100644 --- a/libavcodec/pcm-dvd.c +++ b/libavcodec/pcm-dvd.c @@ -55,6 +55,7 @@ static int pcm_dvd_parse_header(AVCodecContext *avctx, const uint8_t *header) static const uint32_t frequencies[4] = { 48000, 96000, 44100, 32000 }; PCMDVDContext *s = avctx->priv_data; int header_int = (header[0] & 0xe0) | (header[1] << 8) | (header[2] << 16); + int channels; /* early exit if the header didn't change apart from the frame number */ if (s->last_header == header_int) @@ -89,9 +90,12 @@ static int pcm_dvd_parse_header(AVCodecContext *avctx, const uint8_t *header) avctx->sample_rate = frequencies[header[1] >> 4 & 3]; /* get the number of channels */ - avctx->channels = 1 + (header[1] & 7); + channels = 1 + (header[1] & 7); + + av_channel_layout_uninit(&avctx->ch_layout); + av_channel_layout_default(&avctx->ch_layout, channels); /* calculate the bitrate */ - avctx->bit_rate = avctx->channels * + avctx->bit_rate = channels * avctx->sample_rate * avctx->bits_per_coded_sample; @@ -100,15 +104,15 @@ static int pcm_dvd_parse_header(AVCodecContext *avctx, const uint8_t *header) * needed to complete a set of samples for each channel. */ if (avctx->bits_per_coded_sample == 16) { s->samples_per_block = 1; - s->block_size = avctx->channels * 2; + s->block_size = channels * 2; } else { - switch (avctx->channels) { + switch (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 / channels; s->groups_per_block = 1; break; case 8: @@ -118,11 +122,11 @@ static int pcm_dvd_parse_header(AVCodecContext *avctx, const uint8_t *header) s->groups_per_block = 2; break; default: - /* need avctx->channels groups */ - s->block_size = 4 * avctx->channels * + /* need channels groups */ + s->block_size = 4 * channels * avctx->bits_per_coded_sample / 8; s->samples_per_block = 4; - s->groups_per_block = avctx->channels; + s->groups_per_block = channels; break; } } @@ -130,7 +134,7 @@ static int pcm_dvd_parse_header(AVCodecContext *avctx, const uint8_t *header) if (avctx->debug & FF_DEBUG_PICT_INFO) ff_dlog(avctx, "pcm_dvd_parse_header: %d channels, %d bits per sample, %d Hz, %"PRId64" bit/s\n", - avctx->channels, avctx->bits_per_coded_sample, + avctx->ch_layout.nb_channels, avctx->bits_per_coded_sample, avctx->sample_rate, avctx->bit_rate); s->last_header = header_int; @@ -155,7 +159,7 @@ static void *pcm_dvd_decode_samples(AVCodecContext *avctx, const uint8_t *src, bytestream2_get_buffer(&gb, dst16, blocks * s->block_size); dst16 += blocks * s->block_size / 2; #else - int samples = blocks * avctx->channels; + int samples = blocks * avctx->ch_layout.nb_channels; do { *dst16++ = bytestream2_get_be16u(&gb); } while (--samples); @@ -163,7 +167,7 @@ static void *pcm_dvd_decode_samples(AVCodecContext *avctx, const uint8_t *src, return dst16; } case 20: - if (avctx->channels == 1) { + if (avctx->ch_layout.nb_channels == 1) { do { for (i = 2; i; i--) { dst32[0] = bytestream2_get_be16u(&gb) << 16; @@ -191,7 +195,7 @@ static void *pcm_dvd_decode_samples(AVCodecContext *avctx, const uint8_t *src, } return dst32; case 24: - if (avctx->channels == 1) { + if (avctx->ch_layout.nb_channels == 1) { do { for (i = 2; i; i--) { dst32[0] = bytestream2_get_be16u(&gb) << 16; |