-
Notifications
You must be signed in to change notification settings - Fork 349
RFC: Add final support for compress audio #3959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8c74976
5d82014
14ad9c2
f1edc11
a3245fb
7f21aa8
ac6c89b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -245,7 +245,7 @@ static int codec_adapter_prepare(struct comp_dev *dev) | |
| } | ||
|
|
||
| /* Allocate local buffer */ | ||
| buff_size = MAX(cd->period_bytes, codec->cpd.in_buff_size) * buff_periods; | ||
| buff_size = MAX(cd->period_bytes, codec->cpd.out_buff_size) * buff_periods; | ||
| if (cd->local_buff) { | ||
| ret = buffer_set_size(cd->local_buff, buff_size); | ||
| if (ret < 0) { | ||
|
|
@@ -392,6 +392,7 @@ static int codec_adapter_copy(struct comp_dev *dev) | |
| return ret; | ||
|
|
||
| bytes_to_process -= codec->cpd.consumed; | ||
| processed += codec->cpd.consumed; | ||
| comp_update_buffer_consume(source, codec->cpd.consumed); | ||
| } | ||
|
|
||
|
|
@@ -405,6 +406,13 @@ static int codec_adapter_copy(struct comp_dev *dev) | |
| break; | ||
| } | ||
|
|
||
| /* TODO: remove magic number and use possible maximum output per | ||
| * decoding algorithm type | ||
| * 9216 is maximum frame length bytes for mp3 at 192Khz, 24bits, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that makes no sense. mp3 never supported 192kHz and perceptual coders don't care about bit depth. I don't recall what the max value was but this was something at 320 kbits/s
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @plbossart It is clear that I still need to read upon mp3 stuff and all. I'm still confused about all the version / etc. I started with a sample mp3 file: From the internet I have this: If my understanding is correct MP3 is MPEG-1 Audio Layer III or MPEG-2 Audio Layer III. So, based on the table above mp3 should also support 192kHZ. But I admit my comment there is just bad! I will remove it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you may be confusing kbs and kHz :-) the rates are https://en.wikipedia.org/wiki/MP3 has most of the needed information.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you are right the comment should be read 192kbps. |
||
| */ | ||
| if (local_buff->stream.free < 9217) | ||
|
||
| goto db_verify; | ||
|
|
||
| buffer_invalidate(source, codec_buff_size); | ||
| codec_adapter_copy_from_source_to_lib(&source->stream, &codec->cpd, | ||
| codec_buff_size); | ||
|
|
@@ -426,18 +434,22 @@ static int codec_adapter_copy(struct comp_dev *dev) | |
| bytes_to_process -= codec->cpd.consumed; | ||
| processed += codec->cpd.consumed; | ||
| produced += codec->cpd.produced; | ||
|
|
||
| audio_stream_produce(&local_buff->stream, codec->cpd.produced); | ||
| comp_update_buffer_consume(source, codec->cpd.consumed); | ||
| } | ||
|
|
||
| if (!produced && !cd->deep_buff_bytes) { | ||
| comp_dbg(dev, "codec_adapter_copy(): nothing processed in this call"); | ||
| goto end; | ||
| } else if (!produced && cd->deep_buff_bytes) { | ||
| goto db_verify; | ||
| /* we haven't produced anything in this period but we | ||
| * still have data in the local buffer to copy to sink | ||
| */ | ||
| if (audio_stream_get_avail_bytes(&local_buff->stream) >= cd->period_bytes) | ||
| goto copy_period; | ||
| else | ||
| goto end; | ||
| } | ||
|
|
||
| audio_stream_produce(&local_buff->stream, produced); | ||
| comp_update_buffer_consume(source, processed); | ||
|
|
||
| db_verify: | ||
| if (cd->deep_buff_bytes) { | ||
| if (cd->deep_buff_bytes >= audio_stream_get_avail_bytes(&local_buff->stream)) { | ||
|
|
@@ -450,6 +462,7 @@ static int codec_adapter_copy(struct comp_dev *dev) | |
| } | ||
| } | ||
|
|
||
| copy_period: | ||
| comp_get_copy_limits_with_lock(local_buff, sink, &cl); | ||
| copy_bytes = cl.frames * cl.source_frame_bytes; | ||
| audio_stream_copy(&local_buff->stream, 0, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # | ||
| # Topology with codec_adapter processing component for i.MX8QM/i.MX8QXP | ||
| # | ||
|
|
||
| # Include topology builder | ||
| include(`utils.m4') | ||
| include(`dai.m4') | ||
| include(`pipeline.m4') | ||
| include(`sai.m4') | ||
| include(`pcm.m4') | ||
| include(`buffer.m4') | ||
|
|
||
| # Include TLV library | ||
| include(`common/tlv.m4') | ||
|
|
||
| # Include Token library | ||
| include(`sof/tokens.m4') | ||
|
|
||
| # Include DSP configuration | ||
| include(`platform/imx/imx8qxp.m4') | ||
|
|
||
|
|
||
| # Post process setup config | ||
|
|
||
| #codec Post Process setup config | ||
| # | ||
| # Define the pipelines | ||
| # | ||
| # PCM0 <----> volume <-----> SAI3 (wm8960) | ||
| # | ||
|
|
||
|
|
||
| +# Post process setup config | ||
| define(`CA_SETUP_CONTROLBYTES', | ||
| `` bytes "0x53,0x4f,0x46,0x00,0x00,0x00,0x00,0x00,' | ||
| ` 0x20,0x00,0x00,0x00,0x00,0x10,0x00,0x03,' | ||
| ` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' | ||
| ` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' | ||
| ` 0x06,0x01,0xDE,0xCA,0x00,0x00,0x00,0x00,' | ||
| ` 0x80,0xBB,0x00,0x00,0x20,0x00,0x00,0x00,' | ||
| ` 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' | ||
| ` 0x0C,0x00,0x00,0x00,0x20,0x00,0x00,0x00"'' | ||
| ) | ||
|
|
||
| define(`CA_SETUP_CONTROLBYTES_MAX', 300) | ||
|
|
||
| undefine(`DAI_PERIODS') | ||
| define(`DAI_PERIODS', 16) | ||
|
|
||
| dnl PIPELINE_PCM_ADD(pipeline, | ||
| dnl pipe id, pcm, max channels, format, | ||
| dnl period, priority, core, | ||
| dnl pcm_min_rate, pcm_max_rate, pipeline_rate, | ||
| dnl time_domain, sched_comp) | ||
|
|
||
| # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. | ||
| # Set 1000us deadline on core 0 with priority 0 | ||
| PIPELINE_PCM_ADD(sof/pipe-codec-adapter-playback.m4, | ||
| 1, 0, 2, s32le, | ||
| 1000, 0, 0, | ||
| 48000, 48000, 48000) | ||
|
|
||
| # | ||
| # DAIs configuration | ||
| # | ||
|
|
||
| dnl DAI_ADD(pipeline, | ||
| dnl pipe id, dai type, dai_index, dai_be, | ||
| dnl buffer, periods, format, | ||
| dnl period, priority, core, time_domain) | ||
|
|
||
| # playback DAI is SAI3 using 2 periods | ||
| # Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 | ||
| DAI_ADD(sof/pipe-dai-playback.m4, | ||
| 1, SAI, 1, sai1-wm8960-hifi, | ||
| PIPELINE_SOURCE_1, 2, s32le, | ||
| 1000, 0, 0, SCHEDULE_TIME_DOMAIN_DMA) | ||
|
|
||
|
|
||
| # PCM Low Latency, id 0 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PCM?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @plbossart copy paste of course. |
||
|
|
||
| dnl PCM_DUPLEX_ADD(name, pcm_id, playback, capture) | ||
| COMPR_PLAYBACK_ADD(Port0, 0, PIPELINE_PCM_1) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CompressedPort0?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. |
||
|
|
||
| dnl DAI_CONFIG(type, idx, link_id, name, sai_config) | ||
| DAI_CONFIG(SAI, 1, 0, sai1-wm8960-hifi, | ||
| SAI_CONFIG(I2S, SAI_CLOCK(mclk, 12288000, codec_mclk_in), | ||
| SAI_CLOCK(bclk, 3072000, codec_master), | ||
| SAI_CLOCK(fsync, 48000, codec_master), | ||
| SAI_TDM(2, 32, 3, 3), | ||
| SAI_CONFIG_DATA(SAI, 1, 0))) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,10 +115,10 @@ W_CODEC_ADAPTER(0, PIPELINE_FORMAT, DAI_PERIODS, DAI_PERIODS, CA_SCHEDULE_CORE, | |
| LIST(` ', "CA_SETUP_CONTROLBYTES_NAME_PIPE", "CA_RUNTIME_CONTROLBYTES_NAME_PIPE")) | ||
|
|
||
| # Playback Buffers | ||
| W_BUFFER(0, COMP_BUFFER_SIZE(DAI_PERIODS, | ||
| W_BUFFER(0, COMP_BUFFER_SIZE(8, | ||
|
||
| COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, COMP_PERIOD_FRAMES(PCM_MAX_RATE, SCHEDULE_PERIOD)), | ||
| PLATFORM_HOST_MEM_CAP, SCHEDULE_CORE) | ||
| W_BUFFER(1, COMP_BUFFER_SIZE(DAI_PERIODS, | ||
| W_BUFFER(1, COMP_BUFFER_SIZE(2, | ||
| COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, COMP_PERIOD_FRAMES(PCM_MAX_RATE, SCHEDULE_PERIOD)), | ||
| PLATFORM_DAI_MEM_CAP, SCHEDULE_CORE) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.