Skip to content

Commit 6b7cdf0

Browse files
committed
Audio: Cadence: Add a PCM (WAV) decoder
This patch adds a PCM decoder that is compatible with Cadence codec API. It allows to test tinycompress cplay playback with wav format files. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent accf902 commit 6b7cdf0

12 files changed

Lines changed: 390 additions & 2 deletions

File tree

app/compr/README.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ cadence.conf - Base Cadence codec module only (no individual codecs)
1616
mp3.conf - MP3 decoder and encoder
1717
aac.conf - AAC decoder
1818
vorbis.conf - Vorbis decoder
19-
all_codecs.conf - All supported codecs (MP3, AAC, Vorbis)
19+
pcm.conf - PCM (wav) decoder
20+
all_codecs.conf - All supported codecs (MP3, AAC, Vorbis, pcm)
2021

2122
Usage Examples
2223
--------------

app/compr/all_codecs.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ CONFIG_CADENCE_CODEC_AAC_DEC=y
88
CONFIG_CADENCE_CODEC_AAC_DEC_LIB="../cadence_libs/xa_aac_dec.a"
99
CONFIG_CADENCE_CODEC_VORBIS_DEC=y
1010
CONFIG_CADENCE_CODEC_VORBIS_DEC_LIB="../cadence_libs/xa_vorbis_dec.a"
11-
11+
CONFIG_SOF_COMPRESS_CODEC_PCM_DEC=y

app/compr/pcm.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# PCM (wav) decoder
2+
CONFIG_CADENCE_CODEC=y
3+
CONFIG_SOF_COMPRESS_CODEC_PCM_DEC=y

src/audio/base_fw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ static void get_codec_info(struct sof_tlv **tuple)
100100
codec_info.items[codec_info.count++] =
101101
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_VORBIS, SOF_IPC_STREAM_PLAYBACK);
102102
#endif
103+
#ifdef CONFIG_SOF_COMPRESS_CODEC_PCM_DEC
104+
codec_info.items[codec_info.count++] =
105+
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_PCM, SOF_IPC_STREAM_PLAYBACK);
106+
#endif
103107

104108
if (!codec_info.count)
105109
return;

src/audio/module_adapter/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ endif()
3333
zephyr_library_import(xa_mp3_enc ${CONFIG_CADENCE_CODEC_MP3_ENC_LIB})
3434
endif()
3535

36+
zephyr_library_sources_ifdef(CONFIG_SOF_COMPRESS_CODEC_PCM_DEC
37+
module/compress_other/xa_pcm_dec.c)
38+
3639
if (CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING)
3740
if(CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING STREQUAL "m" AND DEFINED CONFIG_LLEXT)
3841
add_subdirectory(module/dolby/llext
@@ -148,6 +151,10 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD)
148151

149152
endif()
150153

154+
if(CONFIG_SOF_COMPRESS_CODEC_PCM_DEC)
155+
add_subdirectory(module/compress_other)
156+
endif()
157+
151158
if(CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING)
152159
target_include_directories(sof PRIVATE ${PROJECT_SOURCE_DIR}/third_party/include)
153160
add_local_sources(sof module/dolby/dax.c)

src/audio/module_adapter/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ if CADENCE_CODEC
173173
This option is a string and takes the full name of the SRC library binary.
174174
endif
175175

176+
config SOF_COMPRESS_CODEC_PCM_DEC
177+
bool "SOF PCM (WAV) decoder"
178+
help
179+
Select to enable PCM (WAV) decoder.
180+
This provides PCM/WAV file decoding support through a simple
181+
implementation that handles the PCM data. Note that this is not
182+
a Cadence codec module but an open-source addition to support the
183+
PCM data format. In addition need to build the cplay from
184+
tinycompress with option --enable-pcm to use this.
185+
176186
endif # Cadence
177187

178188
config COMP_DOLBY_DAX_AUDIO_PROCESSING

src/audio/module_adapter/module/cadence.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ struct cadence_api cadence_api_table[] = {
7474
.api = xa_src_pp,
7575
},
7676
#endif
77+
#ifdef CONFIG_SOF_COMPRESS_CODEC_PCM_DEC
78+
{
79+
.id = SOF_COMPRESS_CODEC_PCM_DEC_ID,
80+
.api = xa_pcm_dec,
81+
},
82+
#endif
7783
};
7884

7985
static int cadence_codec_get_api_id(uint32_t compress_id, uint32_t direction)
@@ -89,6 +95,8 @@ static int cadence_codec_get_api_id(uint32_t compress_id, uint32_t direction)
8995
return CADENCE_CODEC_AAC_DEC_ID;
9096
case SND_AUDIOCODEC_VORBIS:
9197
return CADENCE_CODEC_VORBIS_DEC_ID;
98+
case SND_AUDIOCODEC_PCM:
99+
return SOF_COMPRESS_CODEC_PCM_DEC_ID;
92100
default:
93101
return -EINVAL;
94102
}
@@ -236,6 +244,8 @@ int cadence_codec_get_samples(struct processing_module *mod)
236244
return 1152;
237245
case CADENCE_CODEC_AAC_DEC_ID:
238246
return 1024;
247+
case SOF_COMPRESS_CODEC_PCM_DEC_ID:
248+
return 1024;
239249
default:
240250
break;
241251
}

src/audio/module_adapter/module/cadence_ipc4.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ static int cadence_configure_codec_params(struct processing_module *mod)
209209
case CADENCE_CODEC_VORBIS_DEC_ID:
210210
/* No configuration needed for Vorbis */
211211
return 0;
212+
case SOF_COMPRESS_CODEC_PCM_DEC_ID:
213+
/* No configuration needed for PCM decoder */
214+
return 0;
212215
default:
213216
break;
214217
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
3+
if(CONFIG_SOF_COMPRESS_CODEC_PCM_DEC)
4+
add_local_sources(sof xa_pcm_dec.c)
5+
endif()

0 commit comments

Comments
 (0)