From 74a05a7f53878c70d10326d60d75e39fd93d944c Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Wed, 19 Mar 2014 06:54:04 +0100
Subject: [PATCH] pcm/Neon: explicit rounding

Convert to 31 bit first, then right-shift with rounding to 16 bit.
---
 src/pcm/Neon.hxx | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/pcm/Neon.hxx b/src/pcm/Neon.hxx
index ba31e55b8..7109778ab 100644
--- a/src/pcm/Neon.hxx
+++ b/src/pcm/Neon.hxx
@@ -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);