Repository navigation
Conversation
Define SND_AUDIOCODEC_APTX_HD (0x15), SND_AUDIOCODEC_G726 (0x16), SND_AUDIOCODEC_ALAW (0x17), and SND_AUDIOCODEC_MULAW (0x18) in compress_params.h and advance SND_AUDIOCODEC_MAX. Advertise playback/capture support for the new codecs in base_fw.c get_codec_info() with bounds-checked helper add_codec_info_item(), and extend the BESPOKE capability guards to cover them. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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>
505ec0c to
a710769
Compare
There was a problem hiding this comment.
🟡 Changes recommended
G.726 encoding and decoding accept unsupported multichannel requests as mono, while the 16→8 kHz decimation filter provides insufficient stopband rejection and introduces audible-band aliasing.
3 open issues
What changed in this PR
Extends SOF’s FFmpeg-based compressed playback and capture with aptX HD, G.726/G.726LE, and G.711, building on the lossless codec support in #11427.
Changes:
- Adds codec implementations, format selection, and packet framing.
- Adds 48→8 kHz mono decimation and encoder conversion capability flags.
- Integrates the codecs into configuration, builds, and IPC capability reporting.
| File | Description |
|---|---|
src/kernel/audio/base_fw.c |
Advertises new codec capabilities using bounded insertion. |
src/include/ipc/compress_params.h |
Defines new compressed-audio codec IDs. |
src/audio/ffmpeg_dec/llext/CMakeLists.txt |
Includes new codecs in loadable-module builds. |
src/audio/ffmpeg_dec/Kconfig |
Adds decoder and encoder selection options. |
src/audio/ffmpeg_dec/ffmpeg.cmake |
Enables selected codecs in libavcodec. |
src/audio/ffmpeg_dec/ffmpeg-encode.c |
Registers encoders and uses conversion capability flags. |
src/audio/ffmpeg_dec/ffmpeg-enc-sbc.c |
Declares SBC conversion capabilities. |
src/audio/ffmpeg_dec/ffmpeg-enc-g726.c |
Implements G.726/G.726LE encoding. |
src/audio/ffmpeg_dec/ffmpeg-enc-g722.c |
Declares G.722 conversion capabilities. |
src/audio/ffmpeg_dec/ffmpeg-enc-g711.c |
Implements shared A-law and mu-law encoding. |
src/audio/ffmpeg_dec/ffmpeg-enc-aptx.c |
Shares encoder logic with aptX HD. |
src/audio/ffmpeg_dec/ffmpeg_dec.h |
Adds codec definitions, request fields, and conversion state. |
src/audio/ffmpeg_dec/ffmpeg_dec.c |
Registers decoders and stores IPC stream parameters. |
src/audio/ffmpeg_dec/ffmpeg_dec-g726.c |
Configures G.726 decoding and aligned packet limits. |
src/audio/ffmpeg_dec/ffmpeg_dec-g711.c |
Configures G.711 decoding and channel-aligned packets. |
src/audio/ffmpeg_dec/ffmpeg_dec-ffmpeg.c |
Maps new codecs and G.726 profiles to libavcodec. |
src/audio/ffmpeg_dec/ffmpeg_dec-convert.h |
Declares the 6:1 mono decimator. |
src/audio/ffmpeg_dec/ffmpeg_dec-convert.c |
Extracts the 3:1 filter step and adds 6:1 decimation. |
src/audio/ffmpeg_dec/ffmpeg_dec-aptx.c |
Adds aptX HD selection and six-byte block alignment. |
src/audio/ffmpeg_dec/CMakeLists.txt |
Includes new codecs in built-in builds. |
Review effort: Balanced
| g726->enc_rate = enc_rate; | ||
| g726->avctx->strict_std_compliance = FF_COMPLIANCE_UNOFFICIAL; | ||
| g726->avctx->sample_rate = enc_rate; | ||
| av_channel_layout_default(&g726->avctx->ch_layout, 1); |
There was a problem hiding this comment.
Fixed in commit 63115a5: explicit non-mono G.726 capture requests (req_ch > 1 in ffmpeg_enc_g726_validate_params() and e->req_channels > 1 in ffmpeg_enc_g726_configure()) are now rejected with -EINVAL, while req_channels <= 1 continues to downmix stereo sources to mono. Verified on Spider hardware (hw:0,51 -C g726 -n 2 fails immediately with EINVAL; -n 1 succeeds).
| int32_t acc = (int32_t)hist[12] + 2 * (int32_t)y0 + (int32_t)y1 + 2; | ||
|
|
||
| dst[i] = sat_int16(acc >> 2); |
There was a problem hiding this comment.
Fixed in commit 63115a5: replaced the 3-tap 16->8 kHz stage in ffmpeg_dec_pcm_decimate_6to1_s16_mono() with a 29-tap symmetric Kaiser-windowed linear-phase low-pass FIR (fc = 0.225 * 16 kHz = 3.6 kHz, beta = 5.2, unity Q15 gain 32768) and a persistent 27-sample delay line (FFMPEG_DECIM_6TO1_HIST_LEN = 39 in e->decim_hist), giving -22.9 dB at the 4 kHz Nyquist frequency, -72.6 dB at 5 kHz, and >63 dB stopband rejection above 4.5 kHz. Verified 8 kHz G.726 and G.711 A-law/mu-law capture and playback on Spider.
| } | ||
|
|
||
| avctx->sample_rate = rate; | ||
| av_channel_layout_default(&avctx->ch_layout, 1); |
There was a problem hiding this comment.
Fixed in commit 63115a5: added a validate_params hook to ffmpeg_dec_codec_ops and rejected explicit multichannel G.726 decode requests (req_ch > 1 in ffmpeg_dec_g726_validate_params() and cd->req_channels > 1 in ffmpeg_dec_g726_configure_avctx()) with -EINVAL, while preserving mono-to-stereo sink upmixing. Also fixed unframed compress EOS draining for G.711/G.726/aptX by clearing min_available on compressed decode sources in ffmpeg_dec_prepare() so comp_check_eos() does not inject 0x00 silence blocks after host EOS. Verified on Spider (hw:0,50 -C g726 -n 2 rejects immediately with EINVAL, and -n 1 G.726/A-law/mu-law/aptX HD playback drains cleanly).
Address PR thesofproject#11462 review feedback and unframed compress EOS drain issues: - Reject explicit non-mono G.726 capture requests (req_ch > 1) with -EINVAL in both validate_params and configure while preserving stereo-to-mono downmix when mono or default channels are requested. - Add validate_params hook to ffmpeg_dec_codec_ops and reject explicit multichannel G.726 playback requests (req_channels > 1) with -EINVAL at both IPC init and configure_avctx time while still allowing mono streams to upmix to stereo PCM sinks. - Upgrade the 16->8 kHz stage of ffmpeg_dec_pcm_decimate_6to1_s16_mono() from a 3-tap [1, 2, 1]/4 filter to a 29-tap Kaiser-windowed linear-phase low-pass FIR (fc = 0.225 * 16 kHz = 3.6 kHz, beta = 5.2, unity Q15) with a persistent 27-sample delay line (FFMPEG_DECIM_6TO1_HIST_LEN = 39), achieving -22.9 dB at 4 kHz Nyquist, -72.6 dB at 5 kHz, and >63 dB stopband attenuation above 4.5 kHz. - Clear min_available on compressed decode sources in ffmpeg_dec_prepare() (with EXPORT_SYMBOL(source_set_min_available)) and gate ffmpeg_dec_is_ready_to_process() on eos_sent / final host_eos flush so comp_check_eos() does not inject trailing 0x00 silence blocks into unframed G.711/G.726/aptX bitstreams at compress drain. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

Summary
Extends
ffmpeg_decandffmpeg_encwith three pure-integer, streaming audio codecs alongside IPC capability advertisement and a 6:1 mono decimator:CONFIG_FFMPEG_DEC_APTX_HD,CONFIG_FFMPEG_ENC_APTX_HD,SND_AUDIOCODEC_APTX_HD = 0x15):ffmpeg_dec-aptx.candffmpeg-enc-aptx.cto share core logic between aptX and aptX HD (AV_SAMPLE_FMT_S32Pstereo, 6-byte block alignment clamped at1020bytes per unparsed packet).CONFIG_FFMPEG_DEC_G726,CONFIG_FFMPEG_ENC_G726,SND_AUDIOCODEC_G726 = 0x16):profile=0,adpcm_g726) and little-endian (profile=1,adpcm_g726le), 2/3/4/5 bits per sample (default4), byte/block-aligned unparsed framing (1/3/5bytes),FF_COMPLIANCE_UNOFFICIALfor 8/16/48 kHz streams, and160-sample encode framing.CONFIG_FFMPEG_DEC_ALAW/MULAW,CONFIG_FFMPEG_ENC_ALAW/MULAW,SND_AUDIOCODEC_ALAW = 0x17,SND_AUDIOCODEC_MULAW = 0x18):ffmpeg_dec-g711.candffmpeg-enc-g711.ccovering mono and stereo streams at 8/16/48 kHz.decim_3to1_step()and addedffmpeg_dec_pcm_decimate_6to1_s16_mono()(48 kHz -> 8 kHz) inffmpeg_dec-convert.c.ffmpeg-encode.cwithsupports_mono_downmix,supports_decim_3to1, andsupports_decim_6to1onstruct ffmpeg_enc_codec_ops.Commits
9b1a1f67aipc: compress: add aptX HD, ITU-T G.726, and ITU-T G.711 codec IDsa710769cdffmpeg_dec: add aptX HD, G.726/G.726LE, and G.711 A-law/mu-law codecsTesting
zephyr/scripts/checkpatch.pl --no-tree -g origin/main..HEAD --ignore C99_COMMENTS(with Zephyr.checkpatch.conf) — 0 errors, 0 warnings for both9b1a1f67a510anda710769cd2c9.intel_adsp/ace30/ptl,CONFIG_COMP_FFMPEG_DEC_STUB=y): passed.intel_adsp/cavs25) and PTL (intel_adsp/ace30/ptl) with all Tier 1 codecs enabled +west sign: passed.FAIL=0across 5 capture + playback pairs):aptx_hd_48k_2c(id=21, 48000 Hz 2 ch): capture decoded withffmpeg/ffprobe(pcm_s16le,48000,2) and playback verified.g726_8k_32k(id=22, 8000 Hz 1 chprof=0) andg726le_8k_24k(id=22, 8000 Hz 1 chprof=1): capture decoded (pcm_s16le,8000,1) and playback verified.alaw_8k_1c(id=23, 8000 Hz 1 ch) andmulaw_8k_1c(id=24, 8000 Hz 1 ch): capture decoded (pcm_s16le,8000,1) and playback verified.505ec0c1e, identical codec code): 13 capture + playback configurations (FAIL=0), additionally covering G.726 at 16/40 kbps (8k),64k(16k, 3:1 decimator), and192k(48k), plus A-law/mu-law at16kmono and48kstereo.