pcm/Neon: explicit rounding

Convert to 31 bit first, then right-shift with rounding to 16 bit.
This commit is contained in:
Max Kellermann 2014-03-19 06:54:04 +01:00
parent a68acf5c66
commit 74a05a7f53
1 changed files with 5 additions and 3 deletions

View File

@ -76,11 +76,13 @@ struct NeonFloatTo16 {
/* convert to 32 bit integer */
int32x4x4_t ivalue;
neon_x4_b(vcvtq_n_s32_f32, ivalue, value,
DstTraits::BITS - 1);
30);
/* convert to 16 bit integer with saturation */
/* convert to 16 bit integer with saturation
and rounding */
int16x4x4_t nvalue;
neon_x4_u(vqmovn_s32, nvalue, ivalue);
neon_x4_b(vqrshrn_n_s32, nvalue, ivalue,
30 - DstTraits::BITS + 1);
/* store result */
vst4_s16(dst, nvalue);