CRAS: mix: preserve signedness for S24_LE when scaling
Imaging a S24_LE data: 0xb1b2b3. It stores as an int32_t as following:
MSB LSB
xx b1 b2 b3
The first byte is "don't care" byte. But when scaling the value,
the first byte indicates the sign of the value.
For example, 0x00f54a00 represents a negative 24-bit audio sample but a
positive 32-bit integer. After divided by 2, it becomes 0x007aa500.
Signedness of 24-bit audio sample changed.
This fix shifts left 8 bits, calculates as a signed integer, and shifts
right 8 bits back to preserve the correct signedness.
BUG=b:110795132
TEST=play youtube and no distorted noise
Change-Id: I2ca5b9f6c058bbb20a80f0f2d6ba00cade1fe1b9
Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1356686
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2 files changed