[vlc-commits] adpcm: fix undefined signed shift

Rémi Denis-Courmont git at videolan.org
Mon Jun 9 19:06:25 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jun  9 19:35:26 2014 +0300| [2d5099799c99aad850c461a71438b015bafdd4cb] | committer: Rémi Denis-Courmont

adpcm: fix undefined signed shift

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2d5099799c99aad850c461a71438b015bafdd4cb
---

 modules/codec/adpcm.c |   28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/modules/codec/adpcm.c b/modules/codec/adpcm.c
index b62c016..b052965 100644
--- a/modules/codec/adpcm.c
+++ b/modules/codec/adpcm.c
@@ -755,30 +755,30 @@ static void DecodeAdpcmEA( decoder_t *p_dec, int16_t *p_sample,
 
     for (p_buffer += chans; p_buffer < p_end; p_buffer += chans)
     {
+        union { uint32_t u; int32_t i; } spl;
+
         for (unsigned c = 0; c < chans; c++)
         {
-            int32_t spl;
-
-            spl = ((p_buffer[c] & 0xf0) << 0x18u) >> d[c];
-            spl = (spl + cur[c] * c1[c] + prev[c] * c2[c] + 0x80) >> 8;
-            CLAMP( spl, -32768, 32767 );
+            spl.u = (p_buffer[c] & 0xf0u) << 24u;
+            spl.i >>= d[c];
+            spl.i = (spl.i + cur[c] * c1[c] + prev[c] * c2[c] + 0x80) >> 8;
+            CLAMP(spl.i, -32768, 32767);
             prev[c] = cur[c];
-            cur[c] = spl;
+            cur[c] = spl.i;
 
-            *(p_sample++) = spl;
+            *(p_sample++) = spl.i;
         }
 
         for (unsigned c = 0; c < chans; c++)
         {
-            int32_t spl;
-
-            spl = ((p_buffer[c] & 0x0f) << 0x1cu) >> d[c];
-            spl = (spl + cur[c] * c1[c] + prev[c] * c2[c] + 0x80) >> 8;
-            CLAMP( spl, -32768, 32767 );
+            spl.u = (p_buffer[c] & 0x0fu) << 28u;
+            spl.i >>= d[c];
+            spl.i = (spl.i + cur[c] * c1[c] + prev[c] * c2[c] + 0x80) >> 8;
+            CLAMP(spl.i, -32768, 32767);
             prev[c] = cur[c];
-            cur[c] = spl;
+            cur[c] = spl.i;
 
-            *(p_sample++) = spl;
+            *(p_sample++) = spl.i;
         }
     }
 }



More information about the vlc-commits mailing list