Skip to content

Commit c70c0ce

Browse files
lrgirdwoclaude
andcommitted
audio: ffmpeg_dec: add MP3 decoder
Add CONFIG_FFMPEG_DEC_MP3: enables the libavcodec mp3 decoder and mpegaudio parser in the cross-build, the FFMPEG_DEC_CODEC_MP3 codec id mapping, and the float math layer (the mp3 decoder uses it). Verified building for ace30 (ptl) with decoders [flac,mp3]. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7e6618b commit c70c0ce

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/audio/ffmpeg_dec/Kconfig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ config FFMPEG_DEC_OPUS
4545
Opus (SILK+CELT) decoder. Pulls in the single-precision float math
4646
layer. Enables --enable-decoder=opus in the libavcodec build.
4747

48+
config FFMPEG_DEC_MP3
49+
bool "MP3 decoder"
50+
help
51+
MPEG-1/2 Layer III decoder. Enables --enable-decoder=mp3 and the
52+
mpegaudio parser in the libavcodec build. Uses the float math layer.
53+
4854
comment "FFmpeg audio filters (libavfilter; need the avfilter-graph backend to run)"
4955

5056
config FFMPEG_FILTER_AFFTDN
@@ -75,7 +81,7 @@ config FFMPEG_BUILD_AVFILTER
7581
# built. Gates compilation of the fast single-precision libm (fastmathf.c).
7682
config FFMPEG_DEC_FLOAT_MATH
7783
bool
78-
default y if FFMPEG_DEC_AAC || FFMPEG_DEC_OPUS || FFMPEG_FILTER_AFFTDN
84+
default y if FFMPEG_DEC_AAC || FFMPEG_DEC_OPUS || FFMPEG_DEC_MP3 || FFMPEG_FILTER_AFFTDN
7985

8086
config FFMPEG_DEC_COLD_SPLIT
8187
bool "Place cold FFmpeg code (av_cold init/setup) in DRAM [EXPERIMENTAL]"

src/audio/ffmpeg_dec/ffmpeg.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ if(CONFIG_FFMPEG_DEC_OPUS)
3838
list(APPEND _ff_decoders opus)
3939
list(APPEND _ff_parsers opus)
4040
endif()
41+
if(CONFIG_FFMPEG_DEC_MP3)
42+
list(APPEND _ff_decoders mp3)
43+
list(APPEND _ff_parsers mpegaudio)
44+
endif()
4145
if(NOT _ff_decoders)
4246
message(FATAL_ERROR "ffmpeg_dec: no decoder selected (Kconfig FFMPEG_DEC_*)")
4347
endif()

src/audio/ffmpeg_dec/ffmpeg_dec-ffmpeg.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ static enum AVCodecID ffmpeg_dec_av_codec_id(enum ffmpeg_dec_codec codec)
100100
#if defined(CONFIG_FFMPEG_DEC_OPUS)
101101
case FFMPEG_DEC_CODEC_OPUS:
102102
return AV_CODEC_ID_OPUS;
103+
#endif
104+
#if defined(CONFIG_FFMPEG_DEC_MP3)
105+
case FFMPEG_DEC_CODEC_MP3:
106+
return AV_CODEC_ID_MP3;
103107
#endif
104108
default:
105109
return AV_CODEC_ID_NONE;

src/audio/ffmpeg_dec/ffmpeg_dec.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ enum ffmpeg_dec_codec {
3232
FFMPEG_DEC_CODEC_FLAC,
3333
FFMPEG_DEC_CODEC_AAC,
3434
FFMPEG_DEC_CODEC_OPUS,
35+
FFMPEG_DEC_CODEC_MP3,
3536
};
3637

3738
/* Default codec for a new instance, picked from the Kconfig selection until the
@@ -43,6 +44,8 @@ enum ffmpeg_dec_codec {
4344
#define FFMPEG_DEC_DEFAULT_CODEC FFMPEG_DEC_CODEC_AAC
4445
#elif defined(CONFIG_FFMPEG_DEC_OPUS)
4546
#define FFMPEG_DEC_DEFAULT_CODEC FFMPEG_DEC_CODEC_OPUS
47+
#elif defined(CONFIG_FFMPEG_DEC_MP3)
48+
#define FFMPEG_DEC_DEFAULT_CODEC FFMPEG_DEC_CODEC_MP3
4649
#else
4750
#define FFMPEG_DEC_DEFAULT_CODEC FFMPEG_DEC_CODEC_NONE
4851
#endif

0 commit comments

Comments
 (0)