[FFmpeg-devel] [PATCH 189/281] aptx: convert to new channel layout API

James Almer jamrial at gmail.com
Thu Jan 13 04:02:22 EET 2022


From: Anton Khirnov <anton at khirnov.net>

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/aptx.c    | 2 +-
 libavcodec/aptxdec.c | 8 +++++++-
 libavcodec/aptxenc.c | 6 ++++++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aptx.c b/libavcodec/aptx.c
index 3aeee1907c..d8e0c207cf 100644
--- a/libavcodec/aptx.c
+++ b/libavcodec/aptx.c
@@ -509,7 +509,7 @@ av_cold int ff_aptx_init(AVCodecContext *avctx)
     AptXContext *s = avctx->priv_data;
     int chan, subband;
 
-    if (avctx->channels != 2)
+    if (avctx->ch_layout.nb_channels != 2)
         return AVERROR_INVALIDDATA;
 
     s->hd = avctx->codec->id == AV_CODEC_ID_APTX_HD;
diff --git a/libavcodec/aptxdec.c b/libavcodec/aptxdec.c
index bdcc076c41..1d862e8e6b 100644
--- a/libavcodec/aptxdec.c
+++ b/libavcodec/aptxdec.c
@@ -146,7 +146,7 @@ static int aptx_decode_frame(AVCodecContext *avctx, void *data,
     }
 
     /* get output buffer */
-    frame->channels = NB_CHANNELS;
+    frame->ch_layout.nb_channels = NB_CHANNELS;
     frame->format = AV_SAMPLE_FMT_S32P;
     frame->nb_samples = 4 * avpkt->size / s->block_size;
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
@@ -181,7 +181,10 @@ const AVCodec ff_aptx_decoder = {
     .decode                = aptx_decode_frame,
     .capabilities          = AV_CODEC_CAP_DR1,
     .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE,
+#if FF_API_OLD_CHANNEL_LAYOUT
     .channel_layouts       = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, 0},
+#endif
+    .ch_layouts            = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_STEREO, { 0 } },
     .sample_fmts           = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P,
                                                              AV_SAMPLE_FMT_NONE },
 };
@@ -198,7 +201,10 @@ const AVCodec ff_aptx_hd_decoder = {
     .decode                = aptx_decode_frame,
     .capabilities          = AV_CODEC_CAP_DR1,
     .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE,
+#if FF_API_OLD_CHANNEL_LAYOUT
     .channel_layouts       = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, 0},
+#endif
+    .ch_layouts            = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_STEREO, { 0 } },
     .sample_fmts           = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P,
                                                              AV_SAMPLE_FMT_NONE },
 };
diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c
index 5ea6053c26..1230ee306d 100644
--- a/libavcodec/aptxenc.c
+++ b/libavcodec/aptxenc.c
@@ -253,7 +253,10 @@ const AVCodec ff_aptx_encoder = {
     .encode2               = aptx_encode_frame,
     .close                 = aptx_close,
     .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE,
+#if FF_API_OLD_CHANNEL_LAYOUT
     .channel_layouts       = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, 0},
+#endif
+    .ch_layouts            = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_STEREO, { 0 } },
     .sample_fmts           = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P,
                                                              AV_SAMPLE_FMT_NONE },
     .supported_samplerates = (const int[]) {8000, 16000, 24000, 32000, 44100, 48000, 0},
@@ -272,7 +275,10 @@ const AVCodec ff_aptx_hd_encoder = {
     .encode2               = aptx_encode_frame,
     .close                 = aptx_close,
     .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE,
+#if FF_API_OLD_CHANNEL_LAYOUT
     .channel_layouts       = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, 0},
+#endif
+    .ch_layouts            = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_STEREO, { 0 } },
     .sample_fmts           = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P,
                                                              AV_SAMPLE_FMT_NONE },
     .supported_samplerates = (const int[]) {8000, 16000, 24000, 32000, 44100, 48000, 0},
-- 
2.34.1



More information about the ffmpeg-devel mailing list