Repository navigation
audio: ffmpeg_dec: add libavfilter graph support (afftdn, alimiter) - #11423
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Critical defects remain in end-of-stream draining, 24-bit PCM scaling, configuration synchronization, and IPC3 filter dispatch, causing lost audio, incorrect output, race conditions, or initialization failure.
6 open issues
Synchronize configuration updates with filter graph opening · New Use valid PCM formats for filter conversions · New Drain final partial input and filter output before signaling EOS · New Dispatch IPC3 filter instances to the default filter · New Saturate float-to-int32 conversion at the positive limit · New Preserve exponent scale and handle overflow and subnormals · New
What changed in this PR
Adds on-DSP libavfilter processing to ffmpeg_dec, extending its decoder and encoder support with PCM noise reduction and peak limiting.
Changes:
- Adds
afftdnandalimitergraphs with deferred initialization, PCM conversion, and runtime filter selection. - Integrates filters into Kconfig, built-in and LLEXT builds, module lifecycle dispatch, and PCM capability reporting.
- Implements LLEXT floating-point string parsing and updates built-in parsing helpers.
| File | Description |
|---|---|
src/kernel/audio/base_fw.c |
Advertises PCM playback when filters are enabled. |
src/audio/ffmpeg_dec/llext/CMakeLists.txt |
Includes filter code and adjusts library link order. |
src/audio/ffmpeg_dec/Kconfig |
Adds filter selection and default-filter options. |
src/audio/ffmpeg_dec/ffmpeg.cmake |
Enables selected libavfilter components in the cross-build. |
src/audio/ffmpeg_dec/ffmpeg-filter.c |
Implements filter graphs, PCM conversion, buffering, and lifecycle handling. |
src/audio/ffmpeg_dec/ffmpeg_dec.h |
Declares filter entry points and instance state. |
src/audio/ffmpeg_dec/ffmpeg_dec.c |
Routes initialization, processing, and configuration to filter mode. |
src/audio/ffmpeg_dec/ffmpeg_dec-shims.c |
Implements LLEXT strtod() and strtof(). |
src/audio/ffmpeg_dec/ffmpeg_dec-builtin-libc.c |
Updates special-value handling and bounds exponent parsing. |
src/audio/ffmpeg_dec/CMakeLists.txt |
Adds filter sources and libavfilter linkage for built-in builds. |
Review effort: Balanced
PR 11423: test resultsRun date: 2026-11-09 10:20 UTC Tested commit: 7319a8f2ea59989acd831e5bed250c4c62d0aa03 |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical defects can discard final audio, mis-scale IPC4 24-bit samples, and cause runtime faults in LLEXT builds with the FPU disabled.
9 open issues
Apply the soft-float override to LLEXT filter glue · New Dispatch IPC3 filter instances to the default filter Drain final partial input and filter output before signaling EOS Use valid PCM formats for filter conversions Synchronize configuration updates with filter graph opening Avoid EOS-only wakeups when output cannot drain · New Preserve requested exponents when handling range limits · New Preserve exponent scale and handle overflow and subnormals Saturate float-to-int32 conversion at the positive limit
Review effort: Balanced
0d731df to
7319a8f
Compare
|
All 18 review comments have been addressed and pushed in commit Review Comment Fixes
|
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved defects can break Clang LLEXT compilation, block the low-latency pipeline, cause alignment faults, prevent limiter initialization, and silently drop audio tails.
5 open issues
Fall back to scalar stores for misaligned VFPU destinations · New Reject low-latency instances during filter initialization · New Preserve paired -Xclang flags in the LLEXT build · New Use a boolean value accepted by the LLEXT option parser · New Limit pulled frames to FIFO capacity to avoid dropping the tail · New
9 resolved since last review
Apply the soft-float override to LLEXT filter glue Dispatch IPC3 filter instances to the default filter Drain final partial input and filter output before signaling EOS Use valid PCM formats for filter conversions Synchronize configuration updates with filter graph opening Preserve requested exponents when handling range limits Avoid EOS-only wakeups when output cannot drain Preserve exponent scale and handle overflow and subnormals Saturate float-to-int32 conversion at the positive limit
Review effort: Balanced
Add on-DSP libavfilter audio filter graph support (ffmpeg-filter.c) to the ffmpeg_dec module: - Build an abuffer(src) -> <filter> -> abuffersink(sink) graph with deferred DP-thread initialization so heavy filter setup (such as afftdn FFT table generation) runs off the IPC/IDC worker stack. - Support FFT-based noise reduction (CONFIG_FFMPEG_FILTER_AFFTDN, afftdn) and lookahead brickwall peak limiting (CONFIG_FFMPEG_FILTER_ALIMITER, alimiter), selectable via Kconfig default, IPC4 snd_codec profile, or runtime module configuration. - Extend ffmpeg_dec-convert.c with shared PCM-to-AVFrame and AVFrame-to-PCM conversions using <sof/audio/format.h> Q-format macros, and split HiFi3/HiFi4 VFPU SIMD conversion intrinsics into ffmpeg-convert-hifi.c. - Provide C90 strtod/strtof in the libc shims so libavfilter option parsing works in both built-in (=y) and LLEXT (=m) builds. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
7319a8f to
0869229
Compare
|
CI failures unrelated to PR. |


Add on-DSP
libavfilteraudio filter graph support (src/audio/ffmpeg_dec/ffmpeg-filter.c) to theffmpeg_decmodule:abuffer(src) -> <filter> -> abuffersink(sink)graph with deferred DP-thread initialization so heavy filter setup (such asafftdnFFT table generation) runs on the module's deep DP stack rather than the IPC/IDC worker stack.CONFIG_FFMPEG_FILTER_AFFTDN(afftdn): FFT-based audio noise reduction (AV_SAMPLE_FMT_FLTP).CONFIG_FFMPEG_FILTER_ALIMITER(alimiter): Lookahead brickwall peak limiter (AV_SAMPLE_FMT_DBL).CONFIG_FFMPEG_FILTER_DEFAULT_AFFTDN/CONFIG_FFMPEG_FILTER_DEFAULT_ALIMITER), IPC4snd_codec.profile, or runtime module configuration (<filter_name>[:<filter_args>]).S16_LE,S24_4LE, andS32_LEinput/output PCM formats, using packed HiFi4/HiFi5 VFPUint32 <-> floatconversion intrinsics (float.sx2/trunc.sx2) on VFPU-capable Xtensa cores.strtod/strtof: Provides C90strtod()andstrtof()inffmpeg_dec-shims.c(matchingffmpeg_dec-builtin-libc.c) solibavfilteroption parsing works in both built-in (=y) and LLEXT (=m) builds.