Commit 4a440e8c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

a52: avoid overflow conversion to signed integer

parent 9acdb09e
......@@ -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++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment