[vlc-commits] a52: avoid overflow conversion to signed integer

Rémi Denis-Courmont git at videolan.org
Tue Jun 10 21:46:26 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jun 10 22:45:28 2014 +0300| [4a440e8cd38918d915fa0f724ce279c7c128e7ad] | committer: Rémi Denis-Courmont

a52: avoid overflow conversion to signed integer

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

 modules/audio_filter/converter/a52tofloat32.c |   22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/modules/audio_filter/converter/a52tofloat32.c b/modules/audio_filter/converter/a52tofloat32.c
index 0a892ce..d2016bf 100644
--- a/modules/audio_filter/converter/a52tofloat32.c
+++ b/modules/audio_filter/converter/a52tofloat32.c
@@ -236,7 +236,10 @@ static void Interleave( sample_t *restrict p_out, const sample_t *restrict p_in,
         for( unsigned i = 0; i < 256; i++ )
         {
 #ifdef LIBA52_FIXED
-            p_out[i * i_nb_channels + pi_chan_table[j]] = ((uint32_t)p_in[j * 256 + i]) << 4;
+            union { uint32_t u; int32_t i; } spl;
+
+            spl.u = ((uint32_t)p_in[j * 256 + i]) << 4;
+            p_out[i * i_nb_channels + pi_chan_table[j]] = spl.i;
 #else
             p_out[i * i_nb_channels + pi_chan_table[j]] = p_in[j * 256 + i];
 #endif
@@ -252,12 +255,17 @@ static void Duplicate( sample_t *restrict p_out, const sample_t *restrict p_in )
     for( unsigned i = 256; i--; )
     {
 #ifdef LIBA52_FIXED
-        sample_t s = ((uint32_t)*(p_in++)) << 4;
+        union { uint32_t u; int32_t i; } spl;
+
+        spl.u = ((uint32_t)*(p_in++)) << 4;
+        *p_out++ = spl.i;
+        *p_out++ = spl.i;
 #else
         sample_t s = *(p_in++);
-#endif
+
         *p_out++ = s;
         *p_out++ = s;
+#endif
     }
 }
 
@@ -272,8 +280,12 @@ static void Exchange( sample_t *restrict p_out, const sample_t *restrict p_in )
     for( unsigned i = 0; i < 256; i++ )
     {
 #ifdef LIBA52_FIXED
-        *p_out++ = ((uint32_t)*p_first++) << 4;
-        *p_out++ = ((uint32_t)*p_second++) << 4;
+        uint32_t spl[2];
+
+        spl[0] = ((uint32_t)*p_first++) << 4;
+        spl[1] = ((uint32_t)*p_second++) << 4;
+        memcpy( p_out, spl, sizeof(spl) );
+        p_out += 2;
 #else
         *p_out++ = *p_first++;
         *p_out++ = *p_second++;



More information about the vlc-commits mailing list