[FFmpeg-devel] [PATCH 202/281] dpcm: convert to new channel layout API
James Almer
jamrial at gmail.com
Thu Jan 13 04:02:35 EET 2022
From: Vittorio Giovara <vittorio.giovara at gmail.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
Signed-off-by: Anton Khirnov <anton at khirnov.net>
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavcodec/dpcm.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c
index d9ea23adb3..95052282ae 100644
--- a/libavcodec/dpcm.c
+++ b/libavcodec/dpcm.c
@@ -132,7 +132,7 @@ static av_cold int dpcm_decode_init(AVCodecContext *avctx)
DPCMContext *s = avctx->priv_data;
int i;
- if (avctx->channels < 1 || avctx->channels > 2) {
+ if (avctx->ch_layout.nb_channels < 1 || avctx->ch_layout.nb_channels > 2) {
av_log(avctx, AV_LOG_ERROR, "invalid number of channels\n");
return AVERROR(EINVAL);
}
@@ -215,7 +215,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
int out = 0, ret;
int predictor[2];
int ch = 0;
- int stereo = avctx->channels - 1;
+ int stereo = avctx->ch_layout.nb_channels - 1;
int16_t *output_samples, *samples_end;
GetByteContext gb;
@@ -229,10 +229,10 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
out = buf_size - 8;
break;
case AV_CODEC_ID_INTERPLAY_DPCM:
- out = buf_size - 6 - avctx->channels;
+ out = buf_size - 6 - avctx->ch_layout.nb_channels;
break;
case AV_CODEC_ID_XAN_DPCM:
- out = buf_size - 2 * avctx->channels;
+ out = buf_size - 2 * avctx->ch_layout.nb_channels;
break;
case AV_CODEC_ID_SOL_DPCM:
if (avctx->codec_tag != 3)
@@ -250,12 +250,12 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
return AVERROR(EINVAL);
}
- if (out % avctx->channels) {
+ if (out % avctx->ch_layout.nb_channels) {
av_log(avctx, AV_LOG_WARNING, "channels have differing number of samples\n");
}
/* get output buffer */
- frame->nb_samples = (out + avctx->channels - 1) / avctx->channels;
+ frame->nb_samples = (out + avctx->ch_layout.nb_channels - 1) / avctx->ch_layout.nb_channels;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
output_samples = (int16_t *)frame->data[0];
@@ -287,7 +287,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
case AV_CODEC_ID_INTERPLAY_DPCM:
bytestream2_skipu(&gb, 6); /* skip over the stream mask and stream length */
- for (ch = 0; ch < avctx->channels; ch++) {
+ for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
predictor[ch] = sign_extend(bytestream2_get_le16u(&gb), 16);
*output_samples++ = predictor[ch];
}
@@ -307,7 +307,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
{
int shift[2] = { 4, 4 };
- for (ch = 0; ch < avctx->channels; ch++)
+ for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++)
predictor[ch] = sign_extend(bytestream2_get_le16u(&gb), 16);
ch = 0;
--
2.34.1
More information about the ffmpeg-devel
mailing list