Commit 52a29768 authored by Jonas Svedberg's avatar Jonas Svedberg
Browse files

FIX_976_USAN_PVQ_DEC_OMASA , corrected premature cast

parent 6a18db23
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -163,6 +163,10 @@
#define FIX_956_DECODER_COMMAND_LINE_FIX                /* VA: Output correct error message when the decoder command-line has too many mandatory arguments. */
#define FIX_955_FASTCONV_REND_IN_ISM                    /* VA: put FastConv rendering call under DEBUGGING */


#define FIX_976_USAN_PVQ_DEC_OMASA                      /* Ericsson:  premature cast to unsigned detected by USAN corrected  */


/* #################### End BE switches ################################## */

/* #################### Start NON-BE switches ############################ */
+14 −4
Original line number Diff line number Diff line
@@ -415,11 +415,16 @@ static void densitySymbolIndexDecode(
#undef WMC_TOOL_SKIP

    res_c = res - c;

    if ( c == 0 )
    {
        tot = res * ( res + 1 ) + 1;
        dec_freq = rc_decode( &st->BER_detect, hPVQ, tot );
#ifdef FIX_976_USAN_PVQ_DEC_OMASA  
        alpha = (int16_t) floor_sqrt_exact( ( uint32_t )(( res + 1 ) * ( res + 1 ) - dec_freq )) + res + 1;
#else
        alpha = (int16_t) floor_sqrt_exact( ( uint32_t )( res + 1 ) * ( res + 1 ) - dec_freq ) + res + 1;
#endif
        sym_freq = 2 * ( res - alpha ) + 1;
        cum_freq = alpha * ( 2 * ( res + 1 ) - alpha );
    }
@@ -437,7 +442,12 @@ static void densitySymbolIndexDecode(
        dec_freq = rc_decode( &st->BER_detect, hPVQ, tot );
        if ( dec_freq < tot - ( res + 1 ) - ( res - ( c + 1 ) ) * ( res - c ) * c + c + 1 )
        {
#ifdef FIX_976_USAN_PVQ_DEC_OMASA  
           alpha = ( res_c - 1 + (int16_t) floor_sqrt_exact( (uint32_t) ( res_c * ( res_c + 4 * dec_freq - 2 ) + 1 ) ) ) / ( 2 * res_c );
#else
           alpha = ( res_c - 1 + (int16_t) floor_sqrt_exact( (uint32_t) res_c * ( res_c + 4 * dec_freq - 2 ) + 1 ) ) / ( 2 * res_c );
#endif 

            sym_freq = 2 * alpha * res_c + 1;
            cum_freq = alpha * ( ( alpha - 1 ) * res_c + 1 );
        }