Skip to content

Commit

Permalink
Audio Format: Add vec_sat_int8x2 function
Browse files Browse the repository at this point in the history
- Added to pack two 32-bit integers in an 8x2 vector.

Signed-off-by: Shriram Shastry <malladi.sastry@intel.com>
  • Loading branch information
ShriramShastry committed Aug 4, 2024
1 parent edbe706 commit 5e6e50c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/include/sof/audio/format_hifi3.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,23 @@ static inline int8_t sat_int8(int32_t x)
return (int8_t)AE_MOVAD32_L(a_i);
}

/**
* @brief Saturate and round two 32-bit integers to 8-bit packed into an 8x2 vector.
*
* @param x 32-bit integer.
* @param y 32-bit integer.
* @return Packed 8-bit saturated integers.
*
* This function takes two 32-bit integers, packs them into a 32x2 vector,
* and performs 8-bit saturation on each element, returning the result in an 8x2 vector.
*/
static inline ae_int32x2 vec_sat_int8x2(int32_t x, int32_t y)
{
/* Move two 32-bit values to ae_f32x2 type */
ae_f32x2 d0 = AE_MOVDA32X2(x, y);

/* Shift left by 24 bits and then right by 24 bits to sign-extend and saturate */
return AE_F32X2_SRAI(AE_F32X2_SLAIS(d0, 24), 24);
}

#endif /* __SOF_AUDIO_FORMAT_HIFI3_H__ */

0 comments on commit 5e6e50c

Please sign in to comment.