Skip to content

Commit 505ec0c

Browse files
committed
ffmpeg_dec: add aptX HD, G.726/G.726LE, and G.711 A-law/mu-law codecs
Extend ffmpeg_dec and ffmpeg_enc with three pure-integer audio codecs: - Bluetooth aptX HD (24-bit S32P, 6-byte block-aligned decode and encode) - ITU-T G.726 ADPCM (big-endian profile=0 and little-endian profile=1, 2/3/4/5 bits/sample at 8/16/48 kHz with FF_COMPLIANCE_UNOFFICIAL) - ITU-T G.711 A-law and mu-law companded PCM (mono/stereo at 8/16/48 kHz) Also extract decim_3to1_step(), add an anti-aliased 6:1 (48->8 kHz) mono decimator in ffmpeg_dec-convert.c, and replace hardcoded G.722/SBC rate and channel conversion checks in ffmpeg-encode.c with per-codec supports_mono_downmix, supports_decim_3to1, and supports_decim_6to1 flags. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 7d500e6 commit 505ec0c

18 files changed

Lines changed: 1089 additions & 65 deletions

‎src/audio/ffmpeg_dec/CMakeLists.txt‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@ else()
2727
if(CONFIG_FFMPEG_DEC_G722 OR CONFIG_COMP_FFMPEG_DEC_STUB)
2828
add_local_sources(sof ffmpeg_dec-g722.c)
2929
endif()
30-
if(CONFIG_FFMPEG_DEC_APTX OR CONFIG_COMP_FFMPEG_DEC_STUB)
30+
if(CONFIG_FFMPEG_DEC_APTX OR CONFIG_FFMPEG_DEC_APTX_HD OR CONFIG_COMP_FFMPEG_DEC_STUB)
3131
add_local_sources(sof ffmpeg_dec-aptx.c)
3232
endif()
33+
if(CONFIG_FFMPEG_DEC_G726 OR CONFIG_COMP_FFMPEG_DEC_STUB)
34+
add_local_sources(sof ffmpeg_dec-g726.c)
35+
endif()
36+
if(CONFIG_FFMPEG_DEC_ALAW OR CONFIG_FFMPEG_DEC_MULAW OR CONFIG_COMP_FFMPEG_DEC_STUB)
37+
add_local_sources(sof ffmpeg_dec-g711.c)
38+
endif()
3339

3440
if(CONFIG_COMP_FFMPEG_DEC_STUB)
3541
add_local_sources(sof ffmpeg_dec-stub.c)
@@ -58,9 +64,15 @@ else()
5864
if(CONFIG_FFMPEG_ENC_G722)
5965
add_local_sources(sof ffmpeg-enc-g722.c)
6066
endif()
61-
if(CONFIG_FFMPEG_ENC_APTX)
67+
if(CONFIG_FFMPEG_ENC_APTX OR CONFIG_FFMPEG_ENC_APTX_HD)
6268
add_local_sources(sof ffmpeg-enc-aptx.c)
6369
endif()
70+
if(CONFIG_FFMPEG_ENC_G726)
71+
add_local_sources(sof ffmpeg-enc-g726.c)
72+
endif()
73+
if(CONFIG_FFMPEG_ENC_ALAW OR CONFIG_FFMPEG_ENC_MULAW)
74+
add_local_sources(sof ffmpeg-enc-g711.c)
75+
endif()
6476
if(CONFIG_FFMPEG_FILTER)
6577
add_local_sources(sof ffmpeg-filter.c)
6678
endif()
@@ -102,9 +114,15 @@ else()
102114
if(CONFIG_FFMPEG_ENC_G722)
103115
list(APPEND _ffmpeg_dec_sources ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg-enc-g722.c)
104116
endif()
105-
if(CONFIG_FFMPEG_ENC_APTX)
117+
if(CONFIG_FFMPEG_ENC_APTX OR CONFIG_FFMPEG_ENC_APTX_HD)
106118
list(APPEND _ffmpeg_dec_sources ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg-enc-aptx.c)
107119
endif()
120+
if(CONFIG_FFMPEG_ENC_G726)
121+
list(APPEND _ffmpeg_dec_sources ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg-enc-g726.c)
122+
endif()
123+
if(CONFIG_FFMPEG_ENC_ALAW OR CONFIG_FFMPEG_ENC_MULAW)
124+
list(APPEND _ffmpeg_dec_sources ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg-enc-g711.c)
125+
endif()
108126
if(CONFIG_FFMPEG_FILTER)
109127
list(APPEND _ffmpeg_dec_sources ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg-filter.c)
110128
endif()

‎src/audio/ffmpeg_dec/Kconfig‎

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,36 @@ config FFMPEG_DEC_APTX
8383
--enable-decoder=aptx in the libavcodec build for compress playback
8484
streams requesting SND_AUDIOCODEC_APTX.
8585

86+
config FFMPEG_DEC_APTX_HD
87+
bool "Bluetooth aptX HD decoder"
88+
help
89+
Bluetooth aptX HD 24-bit audio decoder. Pure integer 4-band QMF +
90+
ADPCM decoder with no floating-point math dependency. Enables
91+
--enable-decoder=aptx_hd in the libavcodec build for compress
92+
playback streams requesting SND_AUDIOCODEC_APTX_HD.
93+
94+
config FFMPEG_DEC_G726
95+
bool "ITU-T G.726 ADPCM decoder"
96+
help
97+
ITU-T G.726 ADPCM decoder (16/24/32/40 kbps, big- and little-endian
98+
packing via profile=1). Pure integer ADPCM decoder with no
99+
floating-point math dependency. Enables
100+
--enable-decoder=adpcm_g726,adpcm_g726le in the libavcodec build.
101+
102+
config FFMPEG_DEC_ALAW
103+
bool "ITU-T G.711 A-law decoder"
104+
help
105+
ITU-T G.711 A-law companded PCM decoder. Pure integer table lookup
106+
with no floating-point math dependency. Enables
107+
--enable-decoder=pcm_alaw in the libavcodec build.
108+
109+
config FFMPEG_DEC_MULAW
110+
bool "ITU-T G.711 mu-law decoder"
111+
help
112+
ITU-T G.711 mu-law companded PCM decoder. Pure integer table lookup
113+
with no floating-point math dependency. Enables
114+
--enable-decoder=pcm_mulaw in the libavcodec build.
115+
86116
comment "FFmpeg encoders to build (footprint scales with selection)"
87117

88118
config FFMPEG_ENC_MP3
@@ -144,11 +174,41 @@ config FFMPEG_ENC_APTX
144174
dependency. Selected at runtime for compress capture streams
145175
requesting SND_AUDIOCODEC_APTX.
146176

177+
config FFMPEG_ENC_APTX_HD
178+
bool "Bluetooth aptX HD encoder (native libavcodec)"
179+
help
180+
Bluetooth aptX HD 24-bit audio encoder via native libavcodec aptx_hd
181+
encoder. Pure integer 4-band QMF + ADPCM encoder with no
182+
floating-point math dependency. Selected at runtime for compress
183+
capture streams requesting SND_AUDIOCODEC_APTX_HD.
184+
185+
config FFMPEG_ENC_G726
186+
bool "ITU-T G.726 ADPCM encoder (native libavcodec)"
187+
help
188+
ITU-T G.726 ADPCM encoder (16/24/32/40 kbps, big- and little-endian
189+
packing via profile=1) via native libavcodec adpcm_g726 /
190+
adpcm_g726le encoders. Pure integer ADPCM with no floating-point math
191+
dependency.
192+
193+
config FFMPEG_ENC_ALAW
194+
bool "ITU-T G.711 A-law encoder (native libavcodec)"
195+
help
196+
ITU-T G.711 A-law companded PCM encoder via native libavcodec
197+
pcm_alaw encoder. Pure integer lookup with no floating-point math
198+
dependency.
199+
200+
config FFMPEG_ENC_MULAW
201+
bool "ITU-T G.711 mu-law encoder (native libavcodec)"
202+
help
203+
ITU-T G.711 mu-law companded PCM encoder via native libavcodec
204+
pcm_mulaw encoder. Pure integer lookup with no floating-point math
205+
dependency.
206+
147207
# Selected automatically when any encoder is enabled. Gates compilation of the
148208
# runtime encode path (ffmpeg-encode.c).
149209
config FFMPEG_ENC
150210
bool
151-
default y if FFMPEG_ENC_MP3 || FFMPEG_ENC_AAC || FFMPEG_ENC_FLAC || FFMPEG_ENC_ALAC || FFMPEG_ENC_SBC || FFMPEG_ENC_G722 || FFMPEG_ENC_APTX
211+
default y if FFMPEG_ENC_MP3 || FFMPEG_ENC_AAC || FFMPEG_ENC_FLAC || FFMPEG_ENC_ALAC || FFMPEG_ENC_SBC || FFMPEG_ENC_G722 || FFMPEG_ENC_APTX || FFMPEG_ENC_APTX_HD || FFMPEG_ENC_G726 || FFMPEG_ENC_ALAW || FFMPEG_ENC_MULAW
152212

153213
comment "FFmpeg audio filters to build (libavfilter)"
154214
depends on IPC_MAJOR_4

‎src/audio/ffmpeg_dec/ffmpeg-enc-aptx.c‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// Copyright(c) 2026 Intel Corporation.
44
//
5-
// Bluetooth aptX per-codec encoder implementation for ffmpeg_dec.
5+
/* Bluetooth aptX / aptX HD per-codec encoder implementation for ffmpeg_dec. */
66

77
#include <sof/audio/module_adapter/module/generic.h>
88
#include <ipc/compress_params.h>
@@ -46,14 +46,17 @@ static int ffmpeg_enc_aptx_init(struct processing_module *mod, struct ffmpeg_enc
4646
{
4747
struct comp_dev *dev = mod->dev;
4848
struct ffmpeg_enc_aptx_data *aptx;
49+
enum AVCodecID codec_id;
4950

5051
aptx = mod_zalloc(mod, sizeof(*aptx));
5152
if (!aptx)
5253
return -ENOMEM;
5354

54-
aptx->codec = avcodec_find_encoder(AV_CODEC_ID_APTX);
55+
codec_id = (e->codec_ops->id == FFMPEG_DEC_CODEC_APTX_HD) ?
56+
AV_CODEC_ID_APTX_HD : AV_CODEC_ID_APTX;
57+
aptx->codec = avcodec_find_encoder(codec_id);
5558
if (!aptx->codec) {
56-
comp_err(dev, "libavcodec aptX encoder not found");
59+
comp_err(dev, "libavcodec %s encoder not found", e->codec_ops->name);
5760
mod_free(mod, aptx);
5861
return -ENODEV;
5962
}
@@ -188,6 +191,7 @@ static void ffmpeg_enc_aptx_free(struct processing_module *mod, struct ffmpeg_en
188191
e->codec_priv = NULL;
189192
}
190193

194+
#if defined(CONFIG_FFMPEG_ENC_APTX)
191195
const struct ffmpeg_enc_codec_ops ffmpeg_enc_aptx_ops = {
192196
.id = FFMPEG_DEC_CODEC_APTX,
193197
.snd_codec_id = SND_AUDIOCODEC_APTX,
@@ -199,3 +203,18 @@ const struct ffmpeg_enc_codec_ops ffmpeg_enc_aptx_ops = {
199203
.reset = ffmpeg_enc_aptx_reset,
200204
.free = ffmpeg_enc_aptx_free,
201205
};
206+
#endif
207+
208+
#if defined(CONFIG_FFMPEG_ENC_APTX_HD)
209+
const struct ffmpeg_enc_codec_ops ffmpeg_enc_aptx_hd_ops = {
210+
.id = FFMPEG_DEC_CODEC_APTX_HD,
211+
.snd_codec_id = SND_AUDIOCODEC_APTX_HD,
212+
.name = "aptx_hd",
213+
.validate_params = ffmpeg_enc_aptx_validate_params,
214+
.init = ffmpeg_enc_aptx_init,
215+
.configure = ffmpeg_enc_aptx_configure,
216+
.encode_frame = ffmpeg_enc_aptx_encode_frame,
217+
.reset = ffmpeg_enc_aptx_reset,
218+
.free = ffmpeg_enc_aptx_free,
219+
};
220+
#endif

0 commit comments

Comments
 (0)