diff mbox series

[FFmpeg-devel,202/281] dpcm: convert to new channel layout API

Message ID 20220113020242.661-23-jamrial@gmail.com
State New
Headers show
Series New channel layout API
Related show

Commit Message

James Almer Jan. 13, 2022, 2:02 a.m. UTC
From: Vittorio Giovara <vittorio.giovara@gmail.com>

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>
---
 libavcodec/dpcm.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff mbox series

Patch

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;