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

Audio Math: Improve audio format saturation functions. #9344

Merged
16 changes: 15 additions & 1 deletion src/include/sof/audio/format_hifi3.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,23 @@ static inline ae_int32x2 vec_sat_int32x2(int64_t x, int64_t y)
/* Round and saturate both 64-bit values to 32-bit and pack them */
return (ae_int32x2)AE_ROUND32X2F64SSYM(d0, d1);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit about commit text, the new version isn't more accurate, it's mote efficient.

/**
* @brief Saturate and round a 32-bit integer to 24-bit.
*
* @param x 32-bit integer.
* @return 24-bit saturated integer.
*
* This function takes a 32-bit integer and saturates it to a 24-bit integer
* using saturating arithmetic instructions.
*/
static inline int32_t sat_int24(int32_t x)
{
return AE_SRAI32(AE_SLAI32S(x, 8), 8);
/* Move 32-bit value to ae_f32x2 type */
ae_f32x2 d0 = AE_MOVDA32(x);

/* Saturate to 24-bit */
return (ae_int32)AE_SAT24S(d0);
singalsu marked this conversation as resolved.
Show resolved Hide resolved
}

static inline int16_t sat_int16(int32_t x)
Expand Down