Skip to content
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

Google aec sink src dp #8722

Merged
merged 3 commits into from
Feb 8, 2024
Merged

Conversation

marcinszkudlinski
Copy link
Contributor

@marcinszkudlinski marcinszkudlinski commented Jan 10, 2024

this is a replacement of #8469
all review changes from it have been included

This PR modifies google AEC shimm to use sink/src interface and to be run as DP module in 10ms period

This is upstream of AEC changes from 007 branch and:

please ignore checkpatch warnings in google_rtc_audio_processing_ll.c, this file is - and should stay - 1:1 copy of legacy google_rtc_audio_processing.c.

@marcinszkudlinski marcinszkudlinski force-pushed the aec-on-main branch 3 times, most recently from 422946e to 878a4da Compare January 10, 2024 12:03
@marcinszkudlinski marcinszkudlinski marked this pull request as ready for review January 10, 2024 12:03
@@ -13,7 +13,7 @@ if((NOT CONFIG_LIBRARY) OR CONFIG_LIBRARY_STATIC)
if(CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING)
target_include_directories(sof PRIVATE ${CMAKE_SOURCE_DIR}/third_party/include)
add_local_sources(sof
google_rtc_audio_processing.c
google_rtc_audio_processing_ll.c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking aloud as this was done for other modules with IPC3/4 split, is there any common code where we can have a google_rtc_audio_processing_common.c ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there's really very little divergence needed. In the, heh, "other" patch, IPC3/4 deltas are limited to:

  • The set_config() method is handled differently for IPC4, and in a way that seems a little like needless boilerplate (this has never worked in main, so it's not clear to me why the changes happened). I haven't touched this yet but absolutely will clean it up.

  • A single workaround line remains to set the reference stream format (topology isn't getting to the pipeline correctly).

  • The single line "is this the reference or capture buffer?" predicate works differently (IPC3 checks pipeline IDs, IPC4 looks at the pin index instead, really those too are equivalent and I don't know why they diverged).

app/boards/intel_adsp_ace15_mtpm.conf Outdated Show resolved Hide resolved
Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objection in principle to merging this first, as long as there's a sincere commitment from Intel to consume and validate the other version too. If the only reason for merging this is to cut another "stable drop" branch that is cut off from SOF main, that seems like a bad trade. We need to agree on a single implementation and that takes work from both sides.

As far as code: it would be cleaner to avoid all the code motion (i.e. leave it all in one file, avoid the IPC3 removals), which really isn't needed to support the unified AEC and will only confuse the git history. (Edit: but that's not a -1, it's no harder to squash a big change than a small one, the only impact is to the pour soul trying to figure out what happened from the commit log)

@@ -53,9 +53,7 @@ DECLARE_TR_CTX(google_rtc_audio_processing_tr, SOF_UUID(google_rtc_audio_process
LOG_LEVEL_INFO);

struct google_rtc_audio_processing_comp_data {
#if CONFIG_IPC_MAJOR_4
Copy link
Contributor

@andyross andyross Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this "remove IPC3 support" patch, or just squash it? IPC3 support is going to be added right back in as soon as this merges, so it seems a little silly to go through the motions of turning it off.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we split this file into google_rtc_audio_processing_ipc3.c and google_rtc_audio_processing_ipc4.c like smart_amp ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, I did not touch goole RTC part for ipc3/ipc4 split, because last quarter, a lot of patches are changing this module, if you need me to do this, we can do it later, this module indeed need a separation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do the ipc3/ipc4 split later as we have now so many PR in flight touching this code.

@@ -13,7 +13,7 @@ if((NOT CONFIG_LIBRARY) OR CONFIG_LIBRARY_STATIC)
if(CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING)
target_include_directories(sof PRIVATE ${CMAKE_SOURCE_DIR}/third_party/include)
add_local_sources(sof
google_rtc_audio_processing.c
google_rtc_audio_processing_ll.c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there's really very little divergence needed. In the, heh, "other" patch, IPC3/4 deltas are limited to:

  • The set_config() method is handled differently for IPC4, and in a way that seems a little like needless boilerplate (this has never worked in main, so it's not clear to me why the changes happened). I haven't touched this yet but absolutely will clean it up.

  • A single workaround line remains to set the reference stream format (topology isn't getting to the pipeline correctly).

  • The single line "is this the reference or capture buffer?" predicate works differently (IPC3 checks pipeline IDs, IPC4 looks at the pin index instead, really those too are equivalent and I don't know why they diverged).

Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the only reason for merging this is to cut another "stable drop" branch that is cut off from SOF main, that seems like a bad trade. We need to agree on a single implementation and that takes work from both sides.

And... it turns out from sideband communication that this is exactly what is happening.
I think this has to be a -1 from me. I've been following the rules in #8571, addressing review comments, splitting out changes, chasing down workarounds and external/framework issues instead of just working around them inline. It's neither fair nor good engineering practice for Intel to ram this through just to be able to cut a release without having to work with me.

Can you guys please actually try the code in #8571 first before merging this without review? It works as-is, though I need to push up a respin without the separately-submitted changes. I'll get this out this afternoon. If it doesn't work, then report problems and let's work together on fixing them.

@@ -53,9 +53,7 @@ DECLARE_TR_CTX(google_rtc_audio_processing_tr, SOF_UUID(google_rtc_audio_process
LOG_LEVEL_INFO);

struct google_rtc_audio_processing_comp_data {
#if CONFIG_IPC_MAJOR_4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we split this file into google_rtc_audio_processing_ipc3.c and google_rtc_audio_processing_ipc4.c like smart_amp ?

src = audio_stream_wrap(mic_stream, src);
dst = audio_stream_wrap(out_stream, dst);
#if CONFIG_COMP_GOOGLE_RTC_USE_32_BIT_FLOAT_API
GoogleRtcAudioProcessingAnalyzeRender_float32(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use different proc function for different format and select proc function based on module config
.e.g.

const struct drc_proc_fnmap drc_proc_fnmap[] = {
/* { SOURCE_FORMAT , PROCESSING FUNCTION } */
#if CONFIG_FORMAT_S16LE
	{ SOF_IPC_FRAME_S16_LE, drc_s16_default },
#endif /* CONFIG_FORMAT_S16LE */

#if CONFIG_FORMAT_S24LE
	{ SOF_IPC_FRAME_S24_4LE, drc_s24_default },
#endif /* CONFIG_FORMAT_S24LE */

#if CONFIG_FORMAT_S32LE
	{ SOF_IPC_FRAME_S32_LE, drc_s32_default },
#endif /* CONFIG_FORMAT_S32LE */
};

Copy link
Contributor Author

@marcinszkudlinski marcinszkudlinski Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a separate option - just use google's API 16 or 32. It is independent of out CONFIG_FORMAT_xxxx flags.
In fact, AEC 16 and 32 bit API differ a bit more than just number of bits - they also accept diffrent set of parameters:

int GoogleRtcAudioProcessingAnalyzeRender_float32(
    GoogleRtcAudioProcessingState *const state, const float *const *src);
int GoogleRtcAudioProcessingAnalyzeRender_int16(
    GoogleRtcAudioProcessingState *const state, const int16_t *const src);

const float *const *src vs const float *const src - a pointer to a table of pointers to channels or just a pointer to first channel

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, this is basically the architecture in #8571 (though it's selected with a branch and isn't table driven), there are a bunch of function pointers for doing the optimized sink/source de/interleave+convert+copy for each format variant, without any cut/paste of algorithm code. See https://github.com/andyross/sof/blob/mt8195-aec/src/audio/google/google_rtc_audio_processing.c#L112

@marcinszkudlinski
Copy link
Contributor Author

why _LL ?

because IPC4 != DP_scheduling

this PR does:

  • LL version for IPC3 and IPC4
  • DP version (IPC4 only - no choice here)

@mwasko
Copy link
Contributor

mwasko commented Jan 11, 2024

No objection in principle to merging this first, as long as there's a sincere commitment from Intel to consume and validate the other version too.

@andyross the purpose of this change is to enable AEC module with DP Scheduler using IPC4. Since Intel has already transition to IPC4 then we have no plan to enable and validate this feature with IPC3. However, there are no objections to follow up with IPC3 support as a next step, but the validation and enabling will have to be done on your end.

As far as code: it would be cleaner to avoid all the code motion (i.e. leave it all in one file, avoid the IPC3 removals), which really isn't needed to support the unified AEC and will only confuse the git history. (Edit: but that's not a -1, it's no harder to squash a big change than a small one, the only impact is to the pour soul trying to figure out what happened from the commit log)

I talked with @marcinszkudlinski and "Remove IPC3 support" is unfortunate naming and should be squashed, because the intention here is not to remove any IPC3 functionality, but rather limit the new feature to IPC4 (at least in this PR).

@andyross
Copy link
Contributor

Since Intel has already transition to IPC4 then we have no plan to enable and validate this feature with IPC3

This isn't an Intel project and SOF isn't an Intel deliverable though. I understand you don't want to support IPC3 anymore (I don't either, FWIW), but we still have devices shipping with it and they need to run with current code still. Which is why #8571 exists: it has all the features this PR does, plus IPC3 support, plus dynamic stream format handling, it's smaller, faster, and it does it all in a single source file without having to copy and paste all the future changes between this and a "legacy" version. If there are features you want to see there, just add review comments and let's work together on fixing them.

I absolutely understand there are business worries about what software which entity is willing to support. And that may have to be dealt with out of band. I'll remove the -1 here since it's not really code-related and replace it with a proper review trying to point out the collisions and how it compares with the competing PR.

@andyross andyross self-requested a review January 11, 2024 15:16
@andyross
Copy link
Contributor

Can we split this file into google_rtc_audio_processing_ipc3.c and google_rtc_audio_processing_ipc4.c like smart_amp ?

To repeat, there's really just not that much divergence. The only major code block that changes is that the control handling has a rather different API in IPC4 (this was pre-existing, and absolutely can be cleaned up a ton). Beyond that, there's some sink/source validation code that obviously doesn't apply to IPC3 and a 1-line workaround for the broken reference channel count (which is a protocol bug really, will submit a proposed fix once we get things merged).

Basically see here and scan for the use of IPC_MAJOR: https://github.com/andyross/sof/blob/mt8195-aec/src/audio/google/google_rtc_audio_processing.c

@marcinszkudlinski
Copy link
Contributor Author

...so here's a merge IPC3+IPC4
IPC4 works with DP scheduling only

@mwasko
Copy link
Contributor

mwasko commented Jan 12, 2024

This isn't an Intel project and SOF isn't an Intel deliverable though. I understand you don't want to support IPC3 anymore (I don't either, FWIW), but we still have devices shipping with it and they need to run with current code still.

@andyross you are completely right and because of that you cannot expect Intel to enable and validate all possible configurations that are supported in SOF. This change introduce DP scheduling support for IPC4 because this is the configuration we can validate and guarantee the quality of it.

@andyross
Copy link
Contributor

you cannot expect Intel to enable and validate all possible configurations that are supported in SOF.

Of course not. I just want you to review and approve a PR. If it doesn't work on your supported platform, provide comments and test results or whatever and we'll work together to fix it. I'll handle the other stuff.

@marcinszkudlinski
Copy link
Contributor Author

marcinszkudlinski commented Jan 24, 2024

@andyross @lkoenig @marc-hb all requests addressed, pls proceed

@mwasko
Copy link
Contributor

mwasko commented Jan 29, 2024

@lkoenig, @andyross your change requests has been addressed, please update your review so we can move forward with this PR.

@lkoenig
Copy link
Contributor

lkoenig commented Jan 29, 2024

Sorry I was on vacation. Will have a look tomorrow.

@lkoenig
Copy link
Contributor

lkoenig commented Feb 2, 2024

I think we are getting there. Any update ?

@lkoenig lkoenig closed this Feb 2, 2024
@lkoenig lkoenig reopened this Feb 2, 2024
@lkoenig
Copy link
Contributor

lkoenig commented Feb 2, 2024

Sorry I clicked the wrong button.

This commit changes AEC to use sink/src interface
and makes it to be a DP module

it also enables optional usage of 32bit AEC API

Signed-off-by: Marcin Szkudlinski <[email protected]>
@marcinszkudlinski
Copy link
Contributor Author

I was on medical leave, please proceed

@marcinszkudlinski
Copy link
Contributor Author

@andyross ?

Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, thought I was already +1. Fine with me, though not looking forward to having to piecewise-rework the other PR.

@lgirdwood
Copy link
Member

Sorry, thought I was already +1. Fine with me, though not looking forward to having to piecewise-rework the other PR.

Thanks @andyross - we can plan this better next time, a lot of moving parts this time which increased effort/complexity.

@lgirdwood
Copy link
Member

SOFCI TEST

@lgirdwood
Copy link
Member

Re run the CI build check. CI went down on Monday so manually restart.

@lgirdwood lgirdwood dismissed andyross’s stale review February 8, 2024 11:47

Andy has replied that his comments are now addressed and gives a +1 now..

@lgirdwood lgirdwood merged commit 8e34109 into thesofproject:main Feb 8, 2024
36 of 44 checks passed
@marcinszkudlinski marcinszkudlinski deleted the aec-on-main branch February 8, 2024 11:50
@@ -92,3 +92,6 @@ CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_MIN=y
CONFIG_PROBE=y
CONFIG_PROBE_DMA_MAX=2
CONFIG_LOG_TIMESTAMP_64BIT=y

CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING=y
CONFIG_COMP_STUBS=y
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

From src/audio/Kconfig
"CONFIG_STUBS: This should only be used in testing environments like fuzzers or CI."

Good example of #9386

cc: @cujomalainey

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#9410 results and discussion seem to show a test seems to depend on this!

marc-hb added a commit to marc-hb/sof that referenced this pull request Aug 24, 2024
CONFIG_COMP_STUBS=y was enabled in thesofproject#8722 / commit 8e34109 ("AEC:
Enable Google AEC with Mock compliation").

CONFIG_COMP_STUBS indirectly enables
CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MOCK which was the desired
effect. However it also automatically and silently "mocks" all other 3rd
party modules which is not desirable. So, replace it with the more
focused `CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MOCK`. `src/audio/Kconfig`
says "CONFIG_STUBS: This should only be used in testing environments
like fuzzers or CI."

It's not clear why official sof-bin releases should include
`google_rtc_audio_processing_mock.c` but that's another topic for
another day.

build-mtl/zephyr.strip is identical before versus after this commit.

Signed-off-by: Marc Herbert <[email protected]>
marc-hb added a commit to marc-hb/sof that referenced this pull request Sep 3, 2024
CONFIG_COMP_STUBS=y was enabled in thesofproject#8722 / commit 8e34109 ("AEC:
Enable Google AEC with Mock compliation").

CONFIG_COMP_STUBS indirectly enables
CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MOCK which was the desired
effect. However it also automatically and silently "mocks" all other 3rd
party modules which is not desirable. So, replace it with the more
focused `CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MOCK`. `src/audio/Kconfig`
says "CONFIG_STUBS: This should only be used in testing environments
like fuzzers or CI."

Official sof-bin releases include `google_rtc_audio_processing_mock.c`
because the CI that uses it can't use extra CONFIGS. That's another
topic for another day, see thesofproject#9410.

build-mtl/zephyr.strip is identical before versus after this commit.

Signed-off-by: Marc Herbert <[email protected]>
cujomalainey pushed a commit that referenced this pull request Sep 4, 2024
CONFIG_COMP_STUBS=y was enabled in #8722 / commit 8e34109 ("AEC:
Enable Google AEC with Mock compliation").

CONFIG_COMP_STUBS indirectly enables
CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MOCK which was the desired
effect. However it also automatically and silently "mocks" all other 3rd
party modules which is not desirable. So, replace it with the more
focused `CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MOCK`. `src/audio/Kconfig`
says "CONFIG_STUBS: This should only be used in testing environments
like fuzzers or CI."

Official sof-bin releases include `google_rtc_audio_processing_mock.c`
because the CI that uses it can't use extra CONFIGS. That's another
topic for another day, see #9410.

build-mtl/zephyr.strip is identical before versus after this commit.

Signed-off-by: Marc Herbert <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.