Repository navigation
Conversation
ursus161
marked this pull request as draft
December 1, 2026 13:50
ursus161
marked this pull request as ready for review
December 1, 2026 13:51
Collaborator
|
Can one of the admins verify this patch?
|
float_to_s32() rescales the float sample to the 32-bit range and then casts it to int16_t before storing it as int32_t. Every value outside the int16_t range is out of range for the cast, which is undefined behavior; on a host build with gcc it yields 0 for every sample, so an S32 sink receives silence instead of the processed audio. Store the rescaled value through sat_int32() instead. The saturation is needed as well: in float, 1.0f - 1.0f / 2^31 rounds to 1.0f, so a full-scale sample rescales to 2^31, which does not fit in int32_t. The upstream topologies feed the component 16-bit audio, so they do not hit this path, but the component accepts S32 sources and sinks. Fixes: 28a5265 ("google_aec: Rework prepare/process() to support dynamic formats") Signed-off-by: Ștefan Ghețu <stefan.ghetu@nxp.com>
ursus161
force-pushed
the
google-rtc-fix-float-to-s32
branch
from
December 1, 2026 14:03
e89033b to
b16c5ab
Compare
singalsu
approved these changes
Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
float_to_s32()rescales the float sample to the 32-bit range and then casts it toint16_tbefore storing it asint32_t. Every value outside theint16_trange is out of range for the cast (undefined behavior), so an S32 sink does not get the processed audio.The fix stores the value through
sat_int32(). The saturation is needed as well: in float,1.0f - 1.0f / 2^31rounds to1.0f, so a full-scale sample rescales to2^31, which does not fit inint32_t.Found while looking at the Google RTC AEC component as a stand-in AEC for i.MX8MP (IPC3). The upstream topologies feed the component 16-bit audio, so they do not hit this path today.
Checked on the host with the two conversion functions copied out of the file (gcc, x86):
Not tested on hardware: no in-tree topology uses S32 with this component.