diff --git a/lib_dec/jbm_jb4_circularbuffer.c b/lib_dec/jbm_jb4_circularbuffer.c index bf3cbb71b874a08ef19593f914e9d1cfaa6b3dd7..6bff530beb3ec96f86dc914d734aaa4cfc3fcccc 100644 --- a/lib_dec/jbm_jb4_circularbuffer.c +++ b/lib_dec/jbm_jb4_circularbuffer.c @@ -207,7 +207,7 @@ JB4_CIRCULARBUFFER_ELEMENT JB4_CIRCULARBUFFER_Back( { JB4_CIRCULARBUFFER_ELEMENT ret; - IF( NE_32( h->writePos, 0U ) ) + IF( h->writePos != 0U ) { ret = h->data[h->writePos - 1]; move32(); @@ -408,7 +408,7 @@ void JB4_CIRCULARBUFFER_MinAndPercentile( /* init output variables */ minEle = h->data[h->readPos]; - + move32(); /* To calculate the percentile, a number of elements with the highest values are collected in maxElements in * ascending sorted order. This array has a size of nElementsToIgnore plus one. This additional element is the * lowest of all maxElements, and is called the percentile of all elements. */ diff --git a/lib_dec/jbm_jb4_inputbuffer.c b/lib_dec/jbm_jb4_inputbuffer.c index 25d02da35cfddd5f227cac744253a7ff1d05ad10..f876c11c0e56efcdc5fa46077664178ac704b9aa 100644 --- a/lib_dec/jbm_jb4_inputbuffer.c +++ b/lib_dec/jbm_jb4_inputbuffer.c @@ -139,7 +139,6 @@ ivas_error JB4_INPUTBUFFER_Init( h->readPos = 0; move16(); h->compareFunction = compareFunction; - move16(); return IVAS_ERR_OK; } @@ -213,8 +212,8 @@ Word16 JB4_INPUTBUFFER_Enque( { IF( replace != 0 ) { - *replacedElement = h->data[L_add( h->readPos, middle ) % h->capacity]; - h->data[L_add( h->readPos, middle ) % h->capacity] = element; + *replacedElement = h->data[( h->readPos + middle ) % h->capacity]; + h->data[( h->readPos + middle ) % h->capacity] = element; return 0; } return 1; @@ -235,7 +234,7 @@ Word16 JB4_INPUTBUFFER_Enque( canMoveRight = (UWord16) LT_32( insertPos, h->writePos ); canMoveLeft = (UWord16) GT_32( insertPos, h->writePos ); } - + test(); assert( canMoveRight != 0 || canMoveLeft != 0 ); IF( canMoveRight ) @@ -260,7 +259,7 @@ Word16 JB4_INPUTBUFFER_Enque( /* move lower elements to the left and insert before insertPos */ FOR( j = 0; j < low; j++ ) { - h->data[L_add( L_sub( h->readPos, 1 ), j )] = h->data[L_add( h->readPos, j )]; + h->data[( h->readPos - 1 ) + j] = h->data[h->readPos + j]; } h->data[insertPos - 1] = element; @@ -337,12 +336,12 @@ JB4_INPUTBUFFER_ELEMENT JB4_INPUTBUFFER_Element( /* return h->data[(h->readPos + index) % h->capacity] without error handling */ IF( LT_32( L_add( h->readPos, index ), h->capacity ) ) { - ret = h->data[L_add( h->readPos, index )]; + ret = h->data[( h->readPos + index )]; } ELSE { /* wrap around */ - ret = h->data[L_sub( L_add( h->readPos, index ), h->capacity )]; + ret = h->data[( ( h->readPos + index ) - h->capacity )]; } return ret; diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index 44d6abe4ba1c9eea19e2651b904d9769824e6924..36fef8f0053fb562781c0d20802e664dd287975f 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -183,7 +183,7 @@ struct JB4 UWord32 FecOffWin[10]; UWord32 optimum_offset; - Word32 netLossRate_fx; + Word32 netLossRate_fx; // Q15 Word32 nPartialCopiesUsed; Word32 last_nLost; Word32 last_ntot; @@ -479,22 +479,22 @@ Word16 JB4_PushDataUnit( { IF( dataUnit->partialCopyOffset == 0 ) { - if ( h->rfOffset2Active > 0 ) + IF( h->rfOffset2Active > 0 ) { h->rfOffset2Active = sub( h->rfOffset2Active, 1 ); move16(); } - if ( h->rfOffset3Active > 0 ) + IF( h->rfOffset3Active > 0 ) { h->rfOffset3Active = sub( h->rfOffset3Active, 1 ); move16(); } - if ( h->rfOffset5Active > 0 ) + IF( h->rfOffset5Active > 0 ) { h->rfOffset5Active = sub( h->rfOffset5Active, 1 ); move16(); } - if ( h->rfOffset7Active > 0 ) + IF( h->rfOffset7Active > 0 ) { h->rfOffset7Active = sub( h->rfOffset7Active, 1 ); move16(); @@ -641,13 +641,13 @@ Word16 JB4_getFECoffset( Word16 JB4_FECoffset( JB4_HANDLE h ) { - IF( LT_32( h->netLossRate_fx, 1634 ) ) + IF( LT_32( h->netLossRate_fx, 1634 /*.05f in Q15*/ ) ) { - return (Word16) 0; + return 0; } ELSE { - return (Word16) 1; + return 1; } } @@ -663,7 +663,7 @@ Word16 JB4_PopDataUnit( Word16 ret; assert( sysTime >= h->prevPopSysTime ); - if ( GT_64( sysTime, W_add( h->prevPopSysTime, 20 ) ) ) + IF( GT_64( sysTime, W_add( h->prevPopSysTime, 20 ) ) ) { h->lastPlayoutOffset = L_add( h->lastPlayoutOffset, 20 ); move32(); @@ -780,6 +780,7 @@ static Word16 JB4_adaptPlayout( bool stretchTime; /* reset scale */ + test(); IF( scale == NULL || maxScaling == NULL ) { return -1; @@ -901,13 +902,9 @@ static void JB4_adaptActivePlayout( { IF( convertToLateLoss ) { -#ifndef IVAS_FLOAT_FIXED - JB4_dropFromBuffer( h ); -#else JB4_dropFromBuffer( h ); h->nLostOrStretched = L_add( h->nLostOrStretched, 1 ); move32(); -#endif } ELSE IF( dropEarly ) { @@ -924,8 +921,8 @@ static void JB4_adaptActivePlayout( Word32 temp = BASOP_Util_Divide3232_Scale_cadence( W_extract_l( W_sub( dropRateMax, dropRateMin ) ), W_extract_l( dropGapMax ), &exp ); /* limit gap to [gapMin,gapMax] and calculate current drop rate from gap */ Word64 temp2 = W_mult0_32_32( W_extract_l( JB4_MIN( gap, dropGapMax ) ), temp ); - Word64 temp3 = W_shr( temp2, 31 - exp ); - Word64 diff = W_sub( W_shl( temp3 + 1, 31 - exp ), temp2 ); + Word64 temp3 = W_shr( temp2, sub( 31, exp ) ); + Word64 diff = W_sub( W_shl( W_add( temp3, 1 ), sub( 31, exp ) ), temp2 ); if ( LE_64( diff, 21 ) ) { temp3 = W_add( temp3, 1 ); @@ -1124,7 +1121,7 @@ static Word16 JB4_inspectBufferForDropping( { Word16 temp, exp; temp = BASOP_Util_Divide3232_Scale( JB4_rtpTimeStampDiff( h->nextExpectedTs, firstTs ), (Word32) ( h->frameDuration ), &exp ); - seqNrDiff = L_shl( temp, sub( exp, 15 ) ); + seqNrDiff = L_shl( temp, sub( exp, 15 ) ); // Q0 } ELSE { @@ -1219,7 +1216,7 @@ static Word16 JB4_checkDtxDropping( Word16 temp, exp; temp = BASOP_Util_Divide3232_Scale( JB4_rtpTimeStampDiff( h->nextExpectedTs, firstDu->timeStamp ), (Word32) ( h->frameDuration ), &exp ); - seqNrDiff = L_shl( temp, exp - 15 ); + seqNrDiff = L_shl( temp, sub( exp, 15 ) ); // Q0 if ( seqNrDiff <= 0 ) { /* no not drop first active frame */ @@ -1270,7 +1267,7 @@ static void JB4_estimateShortTermJitter( { duration = (UWord32) W_sub( maxTime, minTime ); maxDuration = (UWord32) W_shl( h->timeScale, 2 ); - WHILE( GT_64( duration, maxDuration ) ) + WHILE( duration > maxDuration ) { JB4_CIRCULARBUFFER_Deque( h->stJitterFifo, &dequedElement ); JB4_CIRCULARBUFFER_Deque( h->stTimeStampFifo, &dequedElement ); @@ -1294,13 +1291,13 @@ static void JB4_estimateShortTermJitter( temp = BASOP_Util_Divide3232_Scale( maxElement, (Word32) h->frameDuration, &exp ); IF( exp < 0 ) { - temp = L_shl( temp, exp ); + temp = L_shl( temp, exp ); // Q31 exp = 0; move16(); } IF( temp != 0 ) { - temp = L_shr( ceil_fixed( temp, 15 - exp ), 15 - exp ); + temp = L_shr( ceil_fixed( temp, sub( 15, exp ) ), sub( 15, exp ) ); // Q31 } h->stJitter = (UWord32) W_mult0_32_32( temp, h->frameDuration ); move32(); @@ -1383,7 +1380,7 @@ static void JB4_popFromBuffer( maxval = h->FecOffWin[i]; move16(); h->optimum_offset = i; - move16(); + move32(); } h->FecOffWin[i] = 0; move32(); @@ -1404,7 +1401,7 @@ static void JB4_popFromBuffer( test(); IF( lost != 0 && total_rec != 0 ) { - h->netLossRate_fx = divide3232( lost, total_rec ); + h->netLossRate_fx = divide3232( lost, total_rec ); // Q15 } ELSE { @@ -1430,7 +1427,7 @@ static void JB4_popFromBuffer( test(); IF( frameoffset > 0 && LT_16( frameoffset, MAXOFFSET ) ) { - h->FecOffWin[frameoffset] = W_extract_l( W_add( h->FecOffWin[frameoffset], 1 ) ); + h->FecOffWin[frameoffset] = (UWord32) ( W_add( h->FecOffWin[frameoffset], 1 ) ); move32(); } } @@ -1503,7 +1500,7 @@ static void JB4_popFromBuffer( test(); IF( !tempDataUnit->partial_frame && !h->lastPoppedWasSilence ) { - frameoffset = extract_l( Mult_32_32( JB4_rtpTimeStampDiff( h->nextExpectedTs, tempDataUnit->timeStamp ), INV_20_Q31 ) ); + frameoffset = extract_l( Mult_32_32( JB4_rtpTimeStampDiff( h->nextExpectedTs, tempDataUnit->timeStamp ), INV_20_Q31 ) ); // Q0 test(); IF( ( frameoffset > 0 ) && LT_16( frameoffset, MAXOFFSET ) ) { @@ -1523,7 +1520,7 @@ static void JB4_popFromBuffer( /* separate concealments since last available pop in lost and stretched */ Word16 exp; nStretched = BASOP_Util_Divide3232_Scale( tsDiff, h->frameDuration, &exp ); - nStretched = (UWord32) W_shr( nStretched, sub( 15, exp ) ); + nStretched = (UWord32) W_shr( nStretched, sub( 15, exp ) ); // Q0 assert( h->nLostOrStretched >= nStretched ); h->nLost = (UWord32) W_add( h->nLost, W_sub( h->nLostOrStretched, nStretched ) ); /* jitter-induced insertion (e.g. buffer underflow) */ @@ -1622,7 +1619,7 @@ static void JB4_dropFromBuffer( /* separate concealments since last available pop in lost and stretched */ Word16 exp; nStretched = BASOP_Util_Divide3232_Scale( tsDiff, (Word32) h->frameDuration, &exp ); - nStretched = (UWord32) W_shr( nStretched, sub( 15, exp ) ); + nStretched = (UWord32) W_shr( nStretched, sub( 15, exp ) ); // Q0 assert( h->nLostOrStretched >= nStretched ); /* convert stretching followed by shrinking to late-loss */ @@ -1636,8 +1633,7 @@ static void JB4_dropFromBuffer( move32(); move32(); move32(); - move32(); - if ( !dataUnit->silenceIndicator ) + IF( !dataUnit->silenceIndicator ) { /* JBM induced removal of a speech frame (intentional frame dropping) */ h->jitterInducedConcealments = (UWord32) W_add( h->jitterInducedConcealments, 1 ); @@ -1752,6 +1748,7 @@ static Word16 JB4_inputBufferCompareFunction( Word16 result; *replaceWithNewElementIfEqual = 0; + move16(); newDataUnit = (JB4_DATAUNIT_HANDLE) newElement; arrayDataUnit = (JB4_DATAUNIT_HANDLE) arrayElement; diff = JB4_rtpTimeStampDiff( arrayDataUnit->timeStamp, newDataUnit->timeStamp ); diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index e5fc42d8dc9e0c3168b0c39fc398496856e7ef7d..1ddb7fee675273bf1600e72a5e5f46828a289263 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -218,7 +218,7 @@ void apa_reset( ps->nFramesSinceSetScale = 0; move32(); ps->scale = 100; - move32(); + move16(); ps->p_min = 0; move16(); ps->l_search = 0; @@ -261,7 +261,7 @@ UWord8 apa_reconfigure( move16(); free( ps->buf_out_fx ); - ps->buf_out_fx = (Word16 *) malloc( sizeof( float ) * ps->buf_out_capacity ); + ps->buf_out_fx = (Word16 *) malloc( sizeof( Word16 ) * ps->buf_out_capacity ); IF( !ps->buf_out_fx ) { return 2; @@ -279,24 +279,24 @@ UWord8 apa_reconfigure( /* in the order of a pitch, set to 160 samples at 16 kHz */ /* used for windowing and as the correlation length, i.e., */ /* the size of the template segment. */ - ps->l_seg = (UWord16) imult3216( Mult_32_16( ps->rate, INV_100_Q15 ), (Word16) ps->num_channels ); + ps->l_seg = (UWord16) imult3216( Mult_32_16( ps->rate, INV_100_Q15 ), (Word16) ps->num_channels ); // Q0 move16(); /* set frame size */ /* set to 320 samples at 16 kHz */ - ps->l_frm = (UWord16) imult3216( Mult_32_16( ps->rate, INV_FRAME_PER_SEC_Q15 ), (Word16) ps->num_channels ); + ps->l_frm = (UWord16) imult3216( Mult_32_16( ps->rate, INV_FRAME_PER_SEC_Q15 ), (Word16) ps->num_channels ); // Q0 move16(); /* set minimum pitch */ /* set to 40 samples at 16 kHz */ /* (defines min change in number of samples, i.e., abs(l_in-l_out) >= p_min) */ - ps->p_min = (UWord16) imult3216( Mult_32_16( ps->rate, INV_400_Q15 ), (Word16) ps->num_channels ); + ps->p_min = (UWord16) imult3216( Mult_32_16( ps->rate, INV_400_Q15 ), (Word16) ps->num_channels ); // Q0 move16(); /* set search length */ /* must cover one pitch, set to 200 samples at 16 kHz */ /* (the resulting maximum pitch is then p_min+l_search = 240 samples at 16 kHz) */ - ps->l_search = (UWord16) imult3216( Mult_32_16( ps->rate, INV_80_Q15 ), (Word16) ps->num_channels ); + ps->l_search = (UWord16) imult3216( Mult_32_16( ps->rate, INV_80_Q15 ), (Word16) ps->num_channels ); // Q0 move16(); return 0; @@ -345,36 +345,34 @@ bool apa_set_rate( /* in the order of a pitch, set to 160 samples at 16 kHz */ /* used for windowing and as the correlation length, i.e., */ /* the size of the template segment. */ - ps->l_seg = (UWord16) imult3216( Mult_32_16( ps->rate, INV_100_Q15 ), ps->num_channels ); + ps->l_seg = (UWord16) imult3216( Mult_32_16( ps->rate, INV_100_Q15 ), ps->num_channels ); // Q0 move16(); /* init Hann window */ /* Note: l_win < APA_BUF_PER_CHANNEL is required */ /* Length of Hann window should be independent of * number of channels - same window applied to all channels */ - ps->l_halfwin = (UWord16) Mult_32_16( ps->rate, INV_100_Q15 ); - move16(); + ps->l_halfwin = (UWord16) Mult_32_16( ps->rate, INV_100_Q15 ); // Q0 move16(); /* set frame size */ /* set to 320 samples at 16 kHz */ - ps->l_frm = (UWord16) imult3216( ( Mult_32_16( ps->rate, INV_FRAME_PER_SEC_Q15 ) ), ps->num_channels ); + ps->l_frm = (UWord16) imult3216( ( Mult_32_16( ps->rate, INV_FRAME_PER_SEC_Q15 ) ), ps->num_channels ); // Q0 move16(); /* set minimum pitch */ /* set to 40 samples at 16 kHz */ /* (defines min change in number of samples, i.e., abs(l_in-l_out) >= p_min) */ - ps->p_min = (UWord16) imult3216( ( Mult_32_16( ps->rate, INV_400_Q15 ) ), ps->num_channels ); + ps->p_min = (UWord16) imult3216( ( Mult_32_16( ps->rate, INV_400_Q15 ) ), ps->num_channels ); // Q0 move16(); /* set search length */ /* must cover one pitch, set to 200 samples at 16 kHz */ /* (the resulting maximum pitch is then p_min+l_search = 240 samples at 16 kHz) */ - ps->l_search = (UWord16) imult3216( Mult_32_16( ps->rate, INV_80_Q15 ), ps->num_channels ); + ps->l_search = (UWord16) imult3216( Mult_32_16( ps->rate, INV_80_Q15 ), ps->num_channels ); // Q0 move16(); ps->win_fx = pcmdsp_window_hann_640; - move16(); ps->l_halfwin = 320; move16(); ps->win_incrementor = 1; @@ -382,14 +380,12 @@ bool apa_set_rate( IF( EQ_32( ps->rate, 48000 ) ) { ps->win_fx = pcmdsp_window_hann_960; - move16(); ps->l_halfwin = 480; move16(); } IF( EQ_32( ps->rate, 24000 ) ) { ps->win_fx = pcmdsp_window_hann_960; - move16(); ps->l_halfwin = 480; move16(); ps->win_incrementor = 2; @@ -533,12 +529,12 @@ bool apa_set_evs_compat_mode( */ bool apa_set_quality( apa_state_t *ps, - Word32 quality, + Word32 quality, // Q16 UWord16 qualityred, UWord16 qualityrise ) { assert( ps != NULL ); - assert( -131072 <= quality && quality <= 203161 ); + assert( -131072 /*-2.0f in Q16*/ <= quality && quality <= 203161 /*3.1f in Q16*/ ); assert( qualityred > 0 && qualityred <= 20 ); assert( qualityrise > 0 && qualityrise <= 20 ); @@ -670,10 +666,10 @@ bool apa_exit( */ UWord8 apa_exec_fx( apa_state_t *ps, /* i/o: state struct */ - const Word16 a_in[], /* i : input samples */ + const Word16 a_in[], /* i : input samples Q0 */ UWord16 l_in, /* i : number of input samples */ UWord16 maxScaling, /* i : allowed number of inserted/removed samples */ - Word16 a_out[], /* o : output samples */ + Word16 a_out[], /* o : output samples Q0*/ UWord16 *l_out /* o : number of output samples */ ) { @@ -789,7 +785,7 @@ UWord8 apa_exec_fx( IF( NE_32( l_frm_out, ps->l_frm ) ) { test(); - IF( NE_32( maxScaling, 0 ) && + IF( maxScaling != 0 && GT_32( abs_s( extract_l( L_sub( ps->l_frm, l_frm_out ) ) ), maxScaling ) ) { /* maxScaling exceeded -> discard scaled frame */ @@ -875,10 +871,10 @@ UWord8 apa_exec_fx( UWord8 apa_exec_ivas_fx( apa_state_t *ps, /* i/o: state struct */ - const Word16 a_in[], /* i : input samples */ + const Word16 a_in[], /* i : input samples Q(-1) */ UWord16 l_in, /* i : number of input samples */ UWord16 maxScaling, /* i : allowed number of inserted/removed samples */ - Word16 a_out[], /* o : output samples */ + Word16 a_out[], /* o : output samples Q(-1) */ UWord16 *l_out /* o : number of output samples */ ) { @@ -921,8 +917,6 @@ UWord8 apa_exec_ivas_fx( } /* get target length */ - test(); - test(); IF( GT_32( ps->scale, 100 ) ) { // expScaling = (int32_t) ( ( ps->l_frm * ( ps->scale - 100.0f ) / 100.0f ) * ( ps->nFramesSinceSetScale + 1 ) + 0.5f ); @@ -990,7 +984,7 @@ UWord8 apa_exec_ivas_fx( IF( NE_32( l_frm_out, ps->l_frm ) ) { test(); - IF( NE_32( maxScaling, 0 ) && + IF( ( maxScaling != 0 ) && GT_32( abs_s( extract_l( L_sub( ps->l_frm, l_frm_out ) ) ), maxScaling ) ) { /* maxScaling exceeded -> discard scaled frame */ @@ -1109,8 +1103,9 @@ static void get_scaling_quality_fx( const apa_state_t *ps, Word16 offset, Word16 corr_len, Word16 pitch, - Word16 *energydBQ8, - Word32 *qualityQ16 ) + Word16 *energydBQ8, // Q8 + Word32 *qualityQ16 // Q16 +) { Word32 energy, maxEnergy; Word32 qualityOfMaxEnergy; /* we measure the quality for all channels and select the one with highest energy */ @@ -1125,8 +1120,10 @@ static void get_scaling_quality_fx( const apa_state_t *ps, Word16 i; - maxEnergy = L_deposit_l( 0 ); - qualityOfMaxEnergy = L_deposit_l( 0 ); + maxEnergy = 0; + qualityOfMaxEnergy = 0; + move32(); + move32(); FOR( i = 0; i < ps->num_channels; i++ ) { @@ -1177,6 +1174,7 @@ static void get_scaling_quality_fx( const apa_state_t *ps, *qualityQ16 = L_shr( L_mac0( L_mult0( half_pitch_cn, three_halves_pitch_cn ), pitch_cn, double_pitch_cn ), 14 ); + move32(); BASOP_SATURATE_WARNING_OFF_EVS energy = L_add( L_add( L_add( pitch_energy, half_pitch_energy ), three_halves_pitch_energy ), double_pitch_energy ); BASOP_SATURATE_WARNING_ON_EVS @@ -1184,6 +1182,7 @@ static void get_scaling_quality_fx( const apa_state_t *ps, ELSE { *qualityQ16 = L_shl( L_deposit_l( pitch_cn ), 1 ); /* value is negative, thus pass it */ + move32(); energy = L_add( pitch_energy, 0 ); } @@ -1231,9 +1230,9 @@ Word16 apa_getQualityIncreaseForLowEnergy_fx( Word16 energydBQ8 ) { Word16 qualIncreaseMinEnergy, qualIncreaseMaxEnergy, qualIncForLowEnergy; /* Q8 */ - qualIncreaseMinEnergy = -65 * ( 1 << 8 ); + qualIncreaseMinEnergy = -65 * ( 1 << 8 ); // Q8 move16(); - qualIncreaseMaxEnergy = -40 * ( 1 << 8 ); + qualIncreaseMaxEnergy = -40 * ( 1 << 8 ); // Q8 move16(); qualIncForLowEnergy = 0; move16(); @@ -1370,7 +1369,7 @@ static Word8 logarithmic_search_fx( const apa_state_t *ps, inlen = add( sub( s_start_old, s_start ), s_len_old ); } } - WHILE( GT_16( css, 2 ) ); + WHILE( ( css > 2 ) ); return 0; } @@ -1422,8 +1421,8 @@ static Word16 find_synch_fx( apa_state_t *ps, Word16 fixed_pos, Word16 corr_len, Word16 offset, - Word16 *energydBQ8, - Word32 *qualityQ16, + Word16 *energydBQ8, // Q8 + Word32 *qualityQ16, // Q16 Word16 *synch_pos ) { assert( ( corr_len - 1 + s_start + s_len - 1 + offset ) < l_in ); @@ -1446,7 +1445,7 @@ static Word16 find_synch_fx( apa_state_t *ps, /* assert synch_pos is cleanly divisible by number of channels */ assert( *synch_pos % ps->num_channels == 0 ); - *qualityQ16 = L_deposit_l( 0 ); + *qualityQ16 = 0; move32(); get_scaling_quality_fx( ps, in, l_in, offset, corr_len, abs_s( sub( *synch_pos, fixed_pos ) ), energydBQ8, qualityQ16 ); @@ -1480,8 +1479,8 @@ static Word16 find_synch_fx( apa_state_t *ps, */ static bool copy_frm_fx( apa_state_t *ps, - const Word16 frm_in_fx[], - Word16 frm_out_fx[], + const Word16 frm_in_fx[], // Qx + Word16 frm_out_fx[], // Qx UWord16 *l_frm_out ) { UWord16 i; @@ -1530,9 +1529,9 @@ static bool copy_frm_fx( */ static bool shrink_frm_fx( apa_state_t *ps, - const Word16 frm_in_fx[], + const Word16 frm_in_fx[], // Qx UWord16 maxScaling, - Word16 frm_out_fx[], + Word16 frm_out_fx[], // Qx UWord16 *l_frm_out ) { bool findSynchResult = 0; @@ -1555,7 +1554,11 @@ static bool shrink_frm_fx( frm_in_fx += l_frm; /* set search range */ - s_start = ( ps->p_min / ps->num_channels ) * ps->num_channels; + // s_start = ( ps->p_min / ps->num_channels ) * ps->num_channels; + Word16 tmp, tmp_e; + tmp = BASOP_Util_Divide3232_Scale( ps->p_min, ps->num_channels, &tmp_e ); + tmp = shr( tmp, sub( 15, tmp_e ) ); + s_start = i_mult( tmp, extract_l( ps->num_channels ) ); s_end = add( s_start, extract_l( ps->l_search ) ); IF( GE_32( L_add( s_end, l_seg ), l_frm ) ) { @@ -1566,9 +1569,9 @@ static bool shrink_frm_fx( IF( isSilence_fx( frm_in_fx, l_seg, 10 ) ) { /* maximum scaling */ - energy_fx = -65 * ( 1 << 8 ); + energy_fx = -65 * ( 1 << 8 ); // Q8 move16(); - quality_fx = 5 << Q16; + quality_fx = 5 << Q16; // Q16 move32(); IF( ps->evs_compat_mode == false ) { @@ -1604,7 +1607,7 @@ static bool shrink_frm_fx( { /* find synch */ scaleSignal16( frm_in_fx, ps->frmInScaled, l_frm, ps->signalScaleForCorrelation ); - findSynchResult = find_synch_fx( ps, ps->frmInScaled, l_frm, s_start, (UWord16) ( s_end - s_start ), 0, l_seg, 0, &energy_fx, &quality_fx, &xtract ); + findSynchResult = find_synch_fx( ps, ps->frmInScaled, l_frm, s_start, (UWord16) ( sub( s_end, s_start ) ), 0, l_seg, 0, &energy_fx, &quality_fx, &xtract ); } /* assert synch_pos is cleanly divisible by number of channels */ @@ -1714,8 +1717,8 @@ static bool shrink_frm_fx( */ static bool extend_frm_fx( apa_state_t *ps, - const Word16 frm_in_fx[], - Word16 frm_out_fx[], + const Word16 frm_in_fx[], // Qx + Word16 frm_out_fx[], // Qx UWord16 *l_frm_out ) { bool findSynchResult = 0; @@ -1727,18 +1730,25 @@ static bool extend_frm_fx( UWord16 over[MAXN + 2]; Word16 l_rem; Word16 s_start = 0; + move16(); Word16 energy_fx; Word32 quality_fx = 0; + move32(); UWord16 l_frm, l_seg; const Word16 *fadeOut_fx, *fadeIn_fx; Word16 *out_fx; l_frm = ps->l_frm; l_seg = ps->l_seg; - + move16(); + move16(); /* number of segments/iterations */ l_frm_out_target = (UWord16) ( L_add( l_frm, L_shr( l_frm, 1 ) ) ); - N = ( l_frm_out_target / l_seg ) - 1; + //(l_frm_out_target/l_seg -1 ) + Word16 tmp, tmp_e; + tmp = BASOP_Util_Divide3232_Scale( l_frm_out_target, l_seg, &tmp_e ); + tmp = shr( tmp, sub( 15, tmp_e ) ); + N = sub( ( tmp ), 1 ); if ( LT_16( N, 1 ) ) { N = 1; @@ -1752,21 +1762,23 @@ static bool extend_frm_fx( /* s[n] are given relative to 2nd frame and point to the start of */ /* the search region. The first segment (n=1) will not be moved. */ /* Hence, the iterations will start with n=2. */ - s_min = -( ps->l_search ) - ( ps->p_min ); + s_min = extract_l( L_negate( L_add( ps->l_search, ps->p_min ) ) ); /* (make sure not to exceed array dimension) */ - if ( l_frm + s_min < 0 ) + IF( L_add( l_frm, s_min ) < 0 ) { - s_min = -( l_frm ); + s_min = extract_l( L_negate( l_frm ) ); } - s_max = l_frm - 2 * l_seg - ps->l_search; + s_max = extract_l( L_sub( L_sub( l_frm, L_shl( l_seg, 1 ) ), ps->l_search ) ); if ( s_max < s_min ) { N = 1; + move16(); } /* for just one segment start at s_min */ if ( N == 1 ) { s[2] = s_min; + move16(); } /* else, spread linear in between s_min and s_max */ /* (including s_min and s_max) */ @@ -1774,7 +1786,14 @@ static bool extend_frm_fx( { FOR( n = 2; n <= ( N + 1 ); n++ ) { - s[n] = s_min + ( ( s_max - s_min ) * ( n - 2 ) ) / ( N - 1 ); + // s[n] = s_min + ( ( s_max - s_min ) * ( n - 2 ) ) / ( N - 1 ); + Word16 tmp2, tmp2_e; + tmp2 = sub( s_max, s_min ); + tmp2 = i_mult( tmp2, extract_l( L_sub( n, 2 ) ) ); + tmp2 = BASOP_Util_Divide1616_Scale( tmp2, sub( N, 1 ), &tmp2_e ); + tmp2 = shr( tmp2, sub( 15, tmp2_e ) ); + s[n] = add( s_min, tmp2 ); + move16(); } } @@ -1782,34 +1801,39 @@ static bool extend_frm_fx( * Planning Phase */ - xtract[1] = -( l_seg ); /* make sync_start=0 in 1st iteration */ + xtract[1] = extract_l( L_negate( l_seg ) ); /* make sync_start=0 in 1st iteration */ + move16(); n = 2; - + move16(); /* define synch segment (to be correlated with search region) */ - sync_start = xtract[n - 1] + l_seg; + sync_start = extract_l( L_add( xtract[n - 1], l_seg ) ); over[n] = 1; /* will be reset if overlap is not required */ + move16(); /* check end of search region: should be at least p_min */ /* samples on the left of synch_start */ - IF( ( s[n] + ps->l_search ) < ( sync_start - ( ps->p_min ) ) ) + IF( LT_32( L_add( s[n], ps->l_search ), L_sub( sync_start, ( ps->p_min ) ) ) ) { s_start = s[n]; - s_end = s_start + ps->l_search; + move16(); + s_end = extract_l( L_add( s_start, ps->l_search ) ); } ELSE { /* shrink search region to enforce minimum shift */ - s_end = sync_start - ( ps->p_min ); - IF( s[n] + ps->l_search < sync_start ) + s_end = extract_l( L_sub( sync_start, ( ps->p_min ) ) ); + IF( LT_16( extract_l( L_add( s[n], ps->l_search ) ), sync_start ) ) { s_start = s[n]; /* just do it with normal start position */ + move16(); } - ELSE IF( n == ( N + 1 ) ) /* move search region left for last segment */ + ELSE IF( EQ_32( n, L_add( N, 1 ) ) ) /* move search region left for last segment */ { - s_start = s_end - ( ps->l_search - ps->p_min ); + s_start = extract_l( L_sub( s_end, L_sub( ps->l_search, ps->p_min ) ) ); } ELSE { over[n] = 0; /* don't search/overlap (just copy down) */ + move16(); } } @@ -1819,17 +1843,23 @@ static bool extend_frm_fx( IF( isSilence_fx( frm_in_fx, l_seg, 10 ) ) { /* maximum scaling */ - energy_fx = -65 * ( 1 << 8 ); + energy_fx = -65 * ( 1 << 8 ); // Q8 move16(); - quality_fx = 5 << 16; + quality_fx = 5 << 16; // Q16 move32(); - xtract[n] = s_start + ps->num_channels; + xtract[n] = extract_l( L_add( s_start, ps->num_channels ) ); + move16(); IF( ps->evs_compat_mode == false ) { /* take renderer buffer samples into accout */ - xtract[n] += ps->l_r_buf; + xtract[n] = extract_l( L_add( xtract[n], ps->l_r_buf ) ); /* snap to next renderer time slot border to resynchronize */ - xtract[n] -= ( ( N - 1 ) * l_seg - xtract[n] + ps->l_r_buf ) % ps->l_ts; + // xtract[n] -= ( ( N - 1 ) * l_seg - xtract[n] + ps->l_r_buf ) % ps->l_ts; + Word16 tmp3; + tmp3 = extract_l( L_add( L_sub( W_extract_l( W_mult0_32_32( L_sub( N, 1 ), l_seg ) ), xtract[n] ), ps->l_r_buf ) ); + xtract[n] = sub( xtract[n], tmp3 % ps->l_ts ); + move16(); + move16(); } } ELSE @@ -1838,15 +1868,15 @@ static bool extend_frm_fx( frmInScaled = ps->frmInScaled; assert( sizeof( ps->frmInScaled ) / sizeof( ps->frmInScaled[0] ) >= 2 * (size_t) l_frm ); scaleSignal16( frm_in_fx, frmInScaled, shl( l_frm, 1 ), ps->signalScaleForCorrelation ); - findSynchResult = find_synch_fx( ps, frmInScaled, 2 * l_frm, s_start, s_end - s_start, sync_start, l_seg, l_frm, &energy_fx, &quality_fx, &xtract[n] ); + findSynchResult = find_synch_fx( ps, frmInScaled, extract_l( L_shl( l_frm, 1 ) ), s_start, sub( s_end, s_start ), sync_start, l_seg, l_frm, &energy_fx, &quality_fx, &xtract[n] ); } /* assert synch_pos is cleanly divisible by number of channels */ assert( xtract[n] % ps->num_channels == 0 ); /* test for sufficient quality */ IF( LT_32( quality_fx, L_add( L_sub( ps->targetQuality_fx, - L_mult0( ps->bad_frame_count, 6554 ) ), - L_mult0( ps->good_frame_count, 13107 ) ) ) ) + L_mult0( ps->bad_frame_count, 6554 /*.1f in Q16*/ ) ), + L_mult0( ps->good_frame_count, 13107 /*.1f in Q16*/ ) ) ) ) { /* not sufficient */ over[n] = 0; @@ -1893,7 +1923,8 @@ static bool extend_frm_fx( /* Calculate output data */ FOR( n = 2; n <= N; n++ ) { - IF( over[n] && xtract[n - 1] + l_seg != xtract[n] ) + test(); + IF( over[n] && NE_16( extract_l( L_add( xtract[n - 1], l_seg ) ), xtract[n] ) ) { /* mix 2nd half of previous segment with 1st half of current segment */ fadeOut_fx = frm_in_fx + l_frm + xtract[n - 1] + l_seg; @@ -1933,7 +1964,7 @@ static bool extend_frm_fx( } /* set output length */ - *l_frm_out = ( N - 1 ) * l_seg + l_rem; - + *l_frm_out = (UWord16) ( W_mult0_32_32( L_sub( N, 1 ), L_add( l_seg, l_rem ) ) ); + move16(); return 0; } diff --git a/lib_dec/jbm_pcmdsp_apa.h b/lib_dec/jbm_pcmdsp_apa.h index c1654407c588155f87b4b1c02700eb1f95bf187c..42215ba16d6be96dd94d61c16a77ad4bb238045e 100644 --- a/lib_dec/jbm_pcmdsp_apa.h +++ b/lib_dec/jbm_pcmdsp_apa.h @@ -144,8 +144,10 @@ bool apa_set_quality( apa_state_t *s, Word32 quality, UWord16 qualityred, UWord1 bool apa_exit( apa_state_t **s ); +#ifndef IVAS_FLOAT_FIXED uint8_t apa_exec( apa_state_t *s, const float a_in[], uint16_t l_in, uint16_t maxScaling, float a_out[], uint16_t *l_out ); -uint8_t apa_exec_ivas_fx( apa_state_t *s, const Word16 a_in[], uint16_t l_in, uint16_t maxScaling, Word16 a_out[], uint16_t *l_out ); -uint8_t apa_exec_fx( apa_state_t *s, const Word16 a_in[], uint16_t l_in, uint16_t maxScaling, Word16 a_out[], uint16_t *l_out ); - +#else +uint8_t apa_exec_ivas_fx( apa_state_t *s, const Word16 a_in[], UWord16 l_in, UWord16 maxScaling, Word16 a_out[], UWord16 *l_out ); +uint8_t apa_exec_fx( apa_state_t *s, const Word16 a_in[], UWord16 l_in, UWord16 maxScaling, Word16 a_out[], UWord16 *l_out ); +#endif #endif /* JBM_PCMDSP_APA_H */ diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.c b/lib_dec/jbm_pcmdsp_similarityestimation.c index 435a5bb4b64a0e476d1af06cceba278a027a6917..6bf8c5c90495d008bf32907f740fae5955df1661 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation.c @@ -90,10 +90,11 @@ Word32 cross_correlation_subsampled_self_fx( const Word16 *signal, Word32 sum; Word16 i; - sum = L_deposit_l( 0 ); + sum = 0; + move32(); FOR( i = 0; i < corr_len; i += subsampling ) { - sum = L_mac0( sum, signal[add( x, i )], signal[add( y, i )] ); + sum = L_mac0( sum, signal[x + i], signal[y + i] ); } return sum; @@ -203,10 +204,12 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, signalX = &signal[x]; signalY = &signal[y]; - sumXY = L_deposit_l( 0 ); - sumXX = L_deposit_l( 0 ); - sumYY = L_deposit_l( 0 ); - + sumXY = 0; + sumXX = 0; + sumYY = 0; + move32(); + move32(); + move32(); FOR( i = 0; i < corr_len; i += subsampling ) { sumXY = L_mac0( sumXY, signalX[i], signalY[i] ); @@ -235,7 +238,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, { #ifdef FX_834_OVFL_JBM_CROSSCORR Flag Overflow = 0; - move16(); + move32(); #endif normCC = 0; move16(); @@ -293,10 +296,11 @@ Word32 cross_correlation_self_fx( const Word16 *signal, Word32 sum; Word16 i; - sum = L_deposit_l( 0 ); + sum = 0; + move32(); FOR( i = 0; i < corr_len; i++ ) { - sum = L_mac0( sum, signal[add( x, i )], signal[add( y, i )] ); + sum = L_mac0( sum, signal[x + i], signal[y + i] ); } return sum; @@ -320,7 +324,8 @@ Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ) ret = 1; move16(); - energy = L_deposit_l( 0 ); + energy = 0; + move32(); samplesPerSegment = idiv1616U( len, segments ); /* calculate maxEnergy with factor 2 to reduce rounding error */ maxEnergy = L_mult0( samplesPerSegment, 37 ); /* 37 = 2 * exp10(-65.0 / 20) * 32768 */ @@ -337,13 +342,14 @@ Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ) /* check energy of current segment */ /* 20 * log10(energy / 32768 / samplesPerSegment) > -65 * => energy > samplesPerSegment * 10 ^ (-65 / 20) * 32768 */ - if ( GT_32( energy, maxEnergy ) ) + IF( GT_32( energy, maxEnergy ) ) { ret = 0; move16(); BREAK; } - energy = L_deposit_l( 0 ); + energy = 0; + move32(); j = add( j, samplesPerSegment ); } } diff --git a/lib_dec/jbm_pcmdsp_similarityestimation.h b/lib_dec/jbm_pcmdsp_similarityestimation.h index 349189119dda6aec9f7fabe5cf3f70fe01b52788..9a76a63f848aa66e5556d4bbb9f024c9296daf2a 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation.h +++ b/lib_dec/jbm_pcmdsp_similarityestimation.h @@ -41,7 +41,7 @@ #include "options.h" #include "typedef.h" - +#ifndef IVAS_FLOAT_FIXED /* ******************************************************************************** * @@ -67,13 +67,11 @@ * ******************************************************************************** */ -#ifndef IVAS_FLOAT_FIXED float cross_correlation_self( const float *signal, uint16_t x, uint16_t y, uint16_t corr_len ); -#endif // !IVAS_FLOAT_FIXED /* ******************************************************************************** @@ -100,14 +98,12 @@ float cross_correlation_self( * ******************************************************************************** */ -#ifndef IVAS_FLOAT_FIXED float cross_correlation_subsampled_self( const float *signal, uint16_t x, uint16_t y, uint16_t corr_len, uint16_t subsampling ); -#endif /* ******************************************************************************** * @@ -144,7 +140,6 @@ float cross_correlation_subsampled_self( * ******************************************************************************** */ -#ifndef IVAS_FLOAT_FIXED float normalized_cross_correlation_self( const float *signal, uint16_t x, @@ -152,13 +147,13 @@ float normalized_cross_correlation_self( uint16_t corr_len, uint16_t subsampling, float *energy ); -#endif + /* Splits the signal into segments and checks if all of them have very low energy. */ bool isSilence( const float *signal, uint32_t len, uint32_t segments ); - +#else Word32 cross_correlation_subsampled_self_fx( const Word16 *signal, Word16 x, Word16 y, @@ -166,10 +161,9 @@ Word32 cross_correlation_subsampled_self_fx( const Word16 *signal, Word16 subsampling ); Word16 getSignalScaleForCorrelation( Word32 sampleRate ); -#ifdef IVAS_FLOAT_FIXED + void scaleSignal16( const Word16 *src, Word16 *dst, Word16 n, Word16 rightShift ); -#endif /* IVAS_FLOAT_FIXED */ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, Word16 x, @@ -186,4 +180,5 @@ Word32 cross_correlation_self_fx( const Word16 *signal, Word8 isSilence_fx( const Word16 *signal, Word16 len, Word16 segments ); -#endif /* JBM_PCMDSP_SIMILARITYESTIMATION_H */ +#endif /* IVAS_FLOAT_FIXED */ +#endif /* JBM_PCMDSP_SIMILARITYESTIMATION_H */ \ No newline at end of file diff --git a/lib_dec/jbm_pcmdsp_window.c b/lib_dec/jbm_pcmdsp_window.c index a9ed3f82c79ee0970520b75273714cd5cd9dc7e4..8df52a83e39f3de50160325cadf12a0eb9af0c43 100644 --- a/lib_dec/jbm_pcmdsp_window.c +++ b/lib_dec/jbm_pcmdsp_window.c @@ -41,7 +41,7 @@ #include "jbm_pcmdsp_window.h" #include "cnst.h" #include "wmc_auto.h" - +#ifndef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------------* * hannWindow() * @@ -68,7 +68,7 @@ void hannWindow( return; } - +#endif /*-----------------------------------------------------------------------* * overlapAdd() diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 82a77f60294300701605a70f1bb039e14b6f23c2..2b7f40ce769b5bf8e76167e079179b58799305f1 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -492,12 +492,14 @@ void ivas_analy_sp_fx( Scale_sig( fft_temp, L_FRAME_12k8, Scale_fac[i_subfr] ); r_fft_fx_lc( FFT_W128, SIZE_256, SIZE2_256, NUM_STAGE_256, fft_temp, pt_fft, 1 ); + Scale_sig( pt_fft, L_FFT, -1 ); // Q(-1) /*e_min_scaled = Q_new + QSCALE + 2*/ find_enr( pt_fft, pt_bands, lf_E + i_subfr * VOIC_BINS, &LEtot, min_band, max_band, add( Q_new, Scale_fac2 ), e_min_scaled, &Bin_E[i_subfr * L_FFT / 2], BIN, band_energies + i_subfr * NB_BANDS ); pt_bands += NB_BANDS; pt_fft += L_FFT; } + LEtot = L_shl_sat( LEtot, 2 ); // Q_new + Q_SCALE - 2 } ELSE { diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 7f79fdbc2d4bac902fde2ed5b451152933cf4ace..89ae5910138af0301ec79d7d7ee3ec81ae8453a0 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -296,8 +296,8 @@ ivas_error ivas_cpe_enc( fixedToFloat_arr( hCPE->hFrontVad[n]->mem_decim_fx, hCPE->hFrontVad[n]->mem_decim, Q_inp, 90 ); hCPE->hFrontVad[n]->mem_preemph = fixedToFloat( hCPE->hFrontVad[n]->mem_preemph_fx, Q_inp + Qband ); fixedToFloat_arr( hCPE->hFrontVad[n]->buffer_12k8_fx, hCPE->hFrontVad[n]->buffer_12k8, Q_buffer[n], 384 ); - fixedToFloat_arrL( fr_bands_fx[n], fr_bands[n], Q_buffer[n] + QSCALE + 2, 40 ); - fixedToFloat_arrL( lf_E_fx[n], lf_E[n], Q_buffer[n] + QSCALE, 148 ); + fixedToFloat_arrL( fr_bands_fx[n], fr_bands[n], Q_buffer[n] + QSCALE, 40 ); + fixedToFloat_arrL( lf_E_fx[n], lf_E[n], Q_buffer[n] + QSCALE - 2, 148 ); Etot_LR[n] = fixedToFloat( Etot_LR_fx[n], Q8 ); fixedToFloat_arrL( hCPE->hFrontVad[n]->hNoiseEst->bckr_fx, hCPE->hFrontVad[n]->hNoiseEst->bckr, Q_new_old + QSCALE, 20 ); @@ -317,7 +317,7 @@ ivas_error ivas_cpe_enc( } } // fixedToFloat_arrL( band_energies_fx, band_energies, Q_new + QSCALE + 2, 40 ); - fixedToFloat_arrL( &band_energies_LR_fx[0], &band_energies_LR[0], Q_buffer[1] + QSCALE + 2 - band_ener_guardbits, 40 ); + fixedToFloat_arrL( &band_energies_LR_fx[0], &band_energies_LR[0], Q_buffer[1] + QSCALE - band_ener_guardbits, 40 ); } #endif #else diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 61e8f6e62c1288611e6622d63a47d230ee3903b8..64296eb11d774e0320ea6f0d520cb0b805784167 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -420,8 +420,8 @@ ivas_error front_vad_fx( noise_est_pre_32fx( Etot_fx, hFrontVads[0]->ini_frame, hFrontVad->hNoiseEst, 0, 0, 0 ); /* wb_vad */ - Scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, Q_new + QSCALE - ( Q_new_old + QSCALE ), 20 ); - Scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, Q_new + QSCALE - ( Q_new_old + QSCALE ), 20 ); + Scale_sig32( hFrontVads[n]->hNoiseEst->bckr_fx, NB_BANDS, Q_new + QSCALE - ( Q_new_old + QSCALE )); + Scale_sig32( hFrontVads[n]->hNoiseEst->enrO_fx, NB_BANDS, Q_new + QSCALE - ( Q_new_old + QSCALE )); hFrontVad->hNoiseEst->sign_dyn_lp_fx = extract_h( hFrontVad->hNoiseEst->sign_dyn_lp_32fx ); hFrontVad->hNoiseEst->Etot_v_h2_fx = extract_h( hFrontVad->hNoiseEst->Etot_v_h2_32fx ); hFrontVad->hVAD->vad_flag = wb_vad_ivas_fx( sts[n], fr_bands_fx[n], &dummy, &dummy, &dummy, &snr_sum_he_fx, &localVAD_HE_SAD[n], &dummy_short, Q_new, hFrontVad->hVAD, hFrontVad->hNoiseEst, hFrontVad->lp_speech_fx, hFrontVad->lp_noise_fx ); diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index c3af6c90467ce04790c938151de2acc60a678894..1bfc4a4bf83a68767169b4c2bc1c490430fc0a75 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -2785,7 +2785,8 @@ void noise_est_ivas_fx( { /* st->harm_cor_cnt = max(1, (short) round_f( (float) st->harm_cor_cnt / 4.0f )) ; */ - *st_harm_cor_cnt = s_max( 1, shr( add( *st_harm_cor_cnt, 2 ), 1 ) ); + *st_harm_cor_cnt = s_max( 1, shr( add( *st_harm_cor_cnt, 2 ), 2 ) ); + move16(); } diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 6723304c71f5fdebe1f216aa28f029cdb4965445..18a71e2942870b6b33a0faffd5a4422a74dc63af 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -2676,8 +2676,8 @@ Word16 wb_vad_ivas_fx( /*snr_sum_ol = 10.0f * (float)log10( hVAD->L_snr_sum_vad_fx );*/ snr_sum_ol = vad_snr_log_fx( hVAD->L_snr_sum_vad_fx, LG10 ); /* snr in Q8 */ } - ELSE IF( ( ( LE_16( st_fx->last_coder_type, UNVOICED ) ) && ( LT_32( L_snr_outlier, MAX_SNR_OUTLIER_2_FX ) ) && ( st_fx->Opt_SC_VBR != 0 ) ) || - ( ( LE_16( last_7k2_coder_type, UNVOICED ) ) && ( LT_32( L_snr_outlier, MAX_SNR_OUTLIER_2_FX ) ) && ( st_fx->Opt_SC_VBR == 0 ) ) ) + ELSE IF( ( ( LE_16( st_fx->last_coder_type, UNVOICED ) ) && ( LT_32( L_snr_outlier, MAX_SNR_OUTLIER_2_FX ) ) && ( st_fx->Opt_SC_VBR == 0 ) ) || + ( ( LE_16( last_7k2_coder_type, UNVOICED ) ) && ( LT_32( L_snr_outlier, MAX_SNR_OUTLIER_2_FX ) ) && ( st_fx->Opt_SC_VBR != 0 ) ) ) { /* thr1_ol = thr1 + (float)(1.0f - 0.04f * snr_outlier); */ diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 9e8733d3fcbc44a0909fc0ded2bbae938770682b..af3d9000c0a7294f28d75a12b44302a0787de678 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -241,7 +241,7 @@ ivas_error ivas_dirac_allocate_parameters_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } - set32_fx( hSpatParamRendCom->diffuseness_vector_fx[i], ONE_IN_Q30, hSpatParamRendCom->num_freq_bands ); + set32_fx( hSpatParamRendCom->diffuseness_vector_fx[i], ONE_IN_Q30, hSpatParamRendCom->num_freq_bands ); // q30 IF( ( hSpatParamRendCom->energy_ratio1_fx[i] = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) { @@ -339,7 +339,10 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( DIRAC_CONFIG_FLAG flag_config; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - flag_config = EQ_32( flag_config_inp, DIRAC_RECONFIGURE_MODE ) ? DIRAC_RECONFIGURE : flag_config_inp; + IF( EQ_32( flag_config_inp, DIRAC_RECONFIGURE_MODE ) ) + flag_config = DIRAC_RECONFIGURE; + ELSE + flag_config = flag_config_inp; move32(); error = IVAS_ERR_OK; move32(); @@ -367,7 +370,7 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( IF( EQ_32( flag_config, DIRAC_OPEN ) ) { /* hSpatParamRendCom->slot_size = (int16_t) ( ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX ); */ - hSpatParamRendCom->slot_size = extract_l( Mpy_32_32( output_Fs, 2684355 /* 1 / ( FRAMES_PER_SEC * CLDFB_NO_COL_MAX) in Q31 */ ) ); + hSpatParamRendCom->slot_size = extract_l( Mpy_32_32( output_Fs, 2684355 /* 1 / ( FRAMES_PER_SEC * CLDFB_NO_COL_MAX) in Q31 */ ) ); // Q0+Q31-Q31=>Q0 move16(); set16_fx( hSpatParamRendCom->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set16_fx( hSpatParamRendCom->subframe_nbslots, JBM_CLDFB_SLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS ); @@ -380,7 +383,7 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( hSpatParamRendCom->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; move16(); /* hSpatParamRendCom->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); */ - hSpatParamRendCom->num_freq_bands = extract_l( Mpy_32_32( output_Fs, 2684355 /* INV_CLDFB_BANDWIDTH in Q31 */ ) ); + hSpatParamRendCom->num_freq_bands = extract_l( Mpy_32_32( output_Fs, 2684355 /* INV_CLDFB_BANDWIDTH in Q31 */ ) ); // 0+31-31=>0 move16(); hSpatParamRendCom->numSimultaneousDirections = 0; move16(); @@ -454,7 +457,10 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( Word16 num_slots_in_subfr, tmp; tmp = 1; move16(); - num_slots_in_subfr = dec_param_estim_flag ? CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES : 1; + IF( dec_param_estim_flag ) + num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; + ELSE + num_slots_in_subfr = 1; move16(); hSpatParamRendCom->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_DIRAC_PARAM_DEC_SFR; move16(); @@ -1890,9 +1896,9 @@ void ivas_dirac_free_mem( #ifdef IVAS_FLOAT_FIXED void compute_hoa_encoder_mtx_fx( - const Word32 *azimuth, - const Word32 *elevation, - Word32 *response_fx, + const Word32 *azimuth, /*q22*/ + const Word32 *elevation, /*q22*/ + Word32 *response_fx, /*q31*/ const Word16 num_responses, const Word16 ambisonics_order ) { @@ -1901,7 +1907,7 @@ void compute_hoa_encoder_mtx_fx( num_sh = ivas_sba_get_nchan_fx( ambisonics_order, 0 ); FOR( k = 0; k < num_responses; k++ ) { - ivas_dirac_dec_get_response_fx( shr( extract_h( azimuth[k] ), Q22 - Q16 ), shr( extract_h( elevation[k] ), Q22 - Q16 ), &response_fx[imult1616( k, num_sh )], ambisonics_order, Q31 ); /* Q31 */ + ivas_dirac_dec_get_response_fx( shr( extract_h( azimuth[k] ), Q22 - Q16 ), shr( extract_h( elevation[k] ), Q22 - Q16 ), &response_fx[k * num_sh], ambisonics_order, Q31 ); /* Q31 */ } return; @@ -1961,12 +1967,12 @@ void ivas_dirac_dec_get_frequency_axis_fx( Word16 k, const_part, scale; /* calc cldfb frequency axis */ - const_part = BASOP_Util_Divide3216_Scale( output_Fs, shl( num_freq_bands, 1 ), &scale ); - const_part = shr( const_part, sub( -1, scale ) ); + const_part = BASOP_Util_Divide3216_Scale( output_Fs, shl( num_freq_bands, 1 ), &scale ); // 15-(scale+31-15)=>-1-scale + const_part = shr( const_part, sub( -1, scale ) ); // q(-1-scale)->q0 FOR( k = 0; k < num_freq_bands; k++ ) { /* frequency_axis[k] = ((float)k + 0.5f) * const_part; */ - frequency_axis[k] = add( i_mult( k, const_part ), shr( const_part, 1 ) ); + frequency_axis[k] = add( i_mult( k, const_part ), shr( const_part, 1 ) ); /*q0*/ move16(); } @@ -2089,7 +2095,7 @@ void initDiffuseResponses( } #else void initDiffuseResponses_fx( - Word16 *diffuse_response_function_fx, + Word16 *diffuse_response_function_fx, /*q15*/ const Word16 num_channels, const AUDIO_CONFIG output_config, const IVAS_OUTPUT_SETUP hOutSetup, @@ -2107,7 +2113,7 @@ void initDiffuseResponses_fx( test(); IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) ) { - diffuse_response_function_fx[0] = MAX16B; + diffuse_response_function_fx[0] = MAX16B; /*1 q15*/ move16(); diffuse_response_function_fx[1] = 18918 /*inv_sqrt(3.0f) oin Q15*/; move16(); @@ -2139,7 +2145,7 @@ void initDiffuseResponses_fx( IF( EQ_32( ivas_format, MC_FORMAT ) && ( EQ_32( transport_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( transport_config, IVAS_AUDIO_CONFIG_7_1 ) ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) { num_horizontal_speakers = sub( num_channels, NUM_ELEVATED_SPEAKERS ); - Copy( diffuse_response_CICP6_fx, diffuse_response_function_fx, num_horizontal_speakers ); + Copy( diffuse_response_CICP6_fx, diffuse_response_function_fx, num_horizontal_speakers ); // q15 set16_fx( &diffuse_response_function_fx[num_horizontal_speakers], 0, NUM_ELEVATED_SPEAKERS ); *num_ele_spk_no_diffuse_rendering = NUM_ELEVATED_SPEAKERS; move16(); @@ -2149,24 +2155,24 @@ void initDiffuseResponses_fx( num_horizontal_speakers = sub( num_channels, NUM_ELEVATED_SPEAKERS ); exp_var1 = 15; move16(); - var1 = ISqrt16( num_horizontal_speakers, &exp_var1 ); - var1 = shr( var1, negate( exp_var1 ) ); // Q15 - set16_fx( diffuse_response_function_fx, var1, num_horizontal_speakers ); + var1 = ISqrt16( num_horizontal_speakers, &exp_var1 ); // q=15-exp_var1 + var1 = shr( var1, negate( exp_var1 ) ); // Q15 + set16_fx( diffuse_response_function_fx, var1, num_horizontal_speakers ); // q15 set16_fx( &diffuse_response_function_fx[num_horizontal_speakers], 0, NUM_ELEVATED_SPEAKERS ); *num_ele_spk_no_diffuse_rendering = NUM_ELEVATED_SPEAKERS; move16(); } ELSE IF( ( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) || EQ_32( ivas_format, MC_FORMAT ) ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) && EQ_16( num_channels, 5 ) ) { - Copy( diffuse_response_CICP6_fx, diffuse_response_function_fx, num_channels ); + Copy( diffuse_response_CICP6_fx, diffuse_response_function_fx, num_channels ); // q15 } ELSE IF( ( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) || EQ_32( ivas_format, MC_FORMAT ) ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) && EQ_16( num_channels, 7 ) ) { - Copy( diffuse_response_CICP14_fx, diffuse_response_function_fx, num_channels ); + Copy( diffuse_response_CICP14_fx, diffuse_response_function_fx, num_channels ); // q15 } ELSE IF( ( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) || EQ_32( ivas_format, MC_FORMAT ) ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) && EQ_16( num_channels, 9 ) ) { - Copy( diffuse_response_CICP16_fx, diffuse_response_function_fx, num_channels ); + Copy( diffuse_response_CICP16_fx, diffuse_response_function_fx, num_channels ); // q15 } ELSE IF( ( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) || EQ_32( ivas_format, MC_FORMAT ) ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { @@ -2177,10 +2183,10 @@ void initDiffuseResponses_fx( move16(); FOR( i = 0; i < num_channels; i++ ) { - IF( LE_32( abs( hOutSetup.ls_elevation_fx[i] ), 20971520 ) /*5 in Q22*/ ) + IF( LE_32( L_abs( hOutSetup.ls_elevation_fx[i] /*q22*/ ), 20971520 /*5 in Q22*/ ) ) { num_horizontal_speakers = add( num_horizontal_speakers, 1 ); - diffuse_response_function_fx[i] = MAX16B; + diffuse_response_function_fx[i] = MAX16B; // q15 move16(); } ELSE @@ -2196,13 +2202,13 @@ void initDiffuseResponses_fx( { exp_var1 = 15; move16(); - Word16 num_horizontal_speakers_isq = ISqrt16( num_horizontal_speakers, &exp_var1 ); - num_horizontal_speakers_isq = shr( num_horizontal_speakers_isq, negate( exp_var1 ) ); + Word16 num_horizontal_speakers_isq = ISqrt16( num_horizontal_speakers, &exp_var1 ); // q15-exp_var1 + num_horizontal_speakers_isq = shr( num_horizontal_speakers_isq, negate( exp_var1 ) ); // q15 assert( 0 ); /*No stream hitting*/ FOR( i = 0; i < num_channels; i++ ) { - diffuse_response_function_fx[i] = shr( mult( diffuse_response_function_fx[i], num_horizontal_speakers_isq ), Q15 ); + diffuse_response_function_fx[i] = mult( diffuse_response_function_fx[i], num_horizontal_speakers_isq ); // q15 move16(); } } @@ -2211,9 +2217,9 @@ void initDiffuseResponses_fx( var1 = num_channels, exp_var1 = 15; move16(); move16(); - res = ISqrt16( var1, &exp_var1 ); - res = shr( res, negate( exp_var1 ) ); - set16_fx( diffuse_response_function_fx, res, num_channels ); + res = ISqrt16( var1, &exp_var1 ); // q=15-exp_var1 + res = shr( res, negate( exp_var1 ) ); // q=15 + set16_fx( diffuse_response_function_fx, res, num_channels ); // q15 *num_ele_spk_no_diffuse_rendering = 0; move16(); } @@ -2223,9 +2229,9 @@ void initDiffuseResponses_fx( var1 = num_channels, exp_var1 = 15; move16(); move16(); - res = ISqrt16( var1, &exp_var1 ); - res = shr( res, negate( exp_var1 ) ); - set16_fx( diffuse_response_function_fx, res, num_channels ); + res = ISqrt16( var1, &exp_var1 ); // q=15-exp_var1 + res = shr( res, negate( exp_var1 ) ); // q15 + set16_fx( diffuse_response_function_fx, res, num_channels ); // q15 } } ELSE @@ -2233,9 +2239,9 @@ void initDiffuseResponses_fx( var1 = num_channels, exp_var1 = 15; move16(); move16(); - res = ISqrt16( var1, &exp_var1 ); - res = shr( res, negate( exp_var1 ) ); - set16_fx( diffuse_response_function_fx, res, num_channels ); + res = ISqrt16( var1, &exp_var1 ); // q(15-exp_var1) + res = shr( res, negate( exp_var1 ) ); // q15 + set16_fx( diffuse_response_function_fx, res, num_channels ); // q15 } } ELSE @@ -2251,9 +2257,9 @@ void initDiffuseResponses_fx( var1 = j, exp_var1 = 15; move16(); move16(); - res = ISqrt16( var1, &exp_var1 ); - diffuse_response_function_fx[idx] = shr( res, negate( exp_var1 ) ); - idx = add( idx, 1 ); + res = ISqrt16( var1, &exp_var1 ); // q(15-exp_var1) + diffuse_response_function_fx[idx] = shr( res, negate( exp_var1 ) ); // q15 + idx = idx + 1; } } } @@ -2271,13 +2277,13 @@ void initDiffuseResponses_fx( #ifdef IVAS_FLOAT_FIXED void protoSignalComputation_shd_fx( - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 *proto_direct_buffer_f_fx, + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*Q(q_cldfb)*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*Q(q_cldfb)*/ + Word32 *proto_direct_buffer_f_fx, /*Q(proto_direct_buffer_f_q)*/ Word16 *proto_direct_buffer_f_q, - Word32 *proto_diffuse_buffer_f_fx, + Word32 *proto_diffuse_buffer_f_fx, /*Q(proto_diffuse_buffer_f_q)*/ Word16 *proto_diffuse_buffer_f_q, - Word32 *reference_power_fx, + Word32 *reference_power_fx, /*Q(reference_power_q)*/ Word16 *reference_power_q, const Word16 slot_index, const Word16 num_inputs, @@ -2305,16 +2311,16 @@ void protoSignalComputation_shd_fx( q_shift = Q31; move16(); - p_proto_direct_buffer_fx = proto_direct_buffer_f_fx + i_mult( i_mult( slot_index, 2 ), i_mult( num_freq_bands, num_inputs ) ); - p_proto_diffuse_buffer_fx = proto_diffuse_buffer_f_fx + i_mult( i_mult( slot_index, 2 ), i_mult( num_freq_bands, num_outputs_diff ) ); + p_proto_direct_buffer_fx = proto_direct_buffer_f_fx + i_mult( i_mult( slot_index, 2 ), i_mult( num_freq_bands, num_inputs ) ); /*proto_direct_buffer_f_q*/ + p_proto_diffuse_buffer_fx = proto_diffuse_buffer_f_fx + i_mult( i_mult( slot_index, 2 ), i_mult( num_freq_bands, num_outputs_diff ) ); /*proto_diffuse_buffer_f_q*/ IF( EQ_16( num_inputs, 1 ) ) { FOR( l = 0; l < num_freq_bands; l++ ) { - p_proto_direct_buffer_fx[2 * l] = RealBuffer_fx[0][0][l]; + p_proto_direct_buffer_fx[2 * l] = RealBuffer_fx[0][0][l]; /*Q(q_cldfb)*/ move32(); - p_proto_direct_buffer_fx[add( 2 * l, 1 )] = ImagBuffer_fx[0][0][l]; + p_proto_direct_buffer_fx[2 * l + 1] = ImagBuffer_fx[0][0][l]; /*Q(q_cldfb)*/ move32(); } *proto_direct_buffer_f_q = q_cldfb; @@ -2328,19 +2334,19 @@ void protoSignalComputation_shd_fx( FOR( l = 0; l < num_freq_bands; l++ ) { - re1 = L_add( RealBuffer_fx[0][0][l], RealBuffer_fx[1][0][l] ); - im1 = L_add( ImagBuffer_fx[0][0][l], ImagBuffer_fx[1][0][l] ); + re1 = L_add( RealBuffer_fx[0][0][l], RealBuffer_fx[1][0][l] ); /*Q(q_cldfb)*/ + im1 = L_add( ImagBuffer_fx[0][0][l], ImagBuffer_fx[1][0][l] ); /*Q(q_cldfb)*/ - re2 = L_sub( RealBuffer_fx[0][0][l], RealBuffer_fx[1][0][l] ); - im2 = L_sub( ImagBuffer_fx[0][0][l], ImagBuffer_fx[1][0][l] ); + re2 = L_sub( RealBuffer_fx[0][0][l], RealBuffer_fx[1][0][l] ); /*Q(q_cldfb)*/ + im2 = L_sub( ImagBuffer_fx[0][0][l], ImagBuffer_fx[1][0][l] ); /*Q(q_cldfb)*/ - p_proto_direct_buffer_fx[2 * l] = re1; + p_proto_direct_buffer_fx[2 * l] = re1; /*Q(q_cldfb)*/ move32(); - p_proto_direct_buffer_fx[add( 2 * l, 1 )] = im1; + p_proto_direct_buffer_fx[2 * l + 1] = im1; /*Q(q_cldfb)*/ move32(); - p_proto_direct_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = L_shl( Mpy_32_32( p_Rmat_fx[0], re2 ), Q1 ); // left shift is done to maintain constant Q factor for p_proto_direct_buffer_fx + p_proto_direct_buffer_fx[2 * ( num_freq_bands + l )] = L_shl( Mpy_32_32( p_Rmat_fx[0], re2 ), Q1 ); // left shift is done to maintain constant Q factor for p_proto_direct_buffer_fx =>Q(q_cldfb) move32(); - p_proto_direct_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = L_shl( Mpy_32_32( p_Rmat_fx[0], im2 ), Q1 ); // left shift is done to maintain constant Q factor for p_proto_direct_buffer_fx + p_proto_direct_buffer_fx[2 * ( num_freq_bands + l ) + 1] = L_shl( Mpy_32_32( p_Rmat_fx[0], im2 ), Q1 ); // left shift is done to maintain constant Q factor for p_proto_direct_buffer_fx => Q(q_cldfb) move32(); } *proto_direct_buffer_f_q = q_cldfb; @@ -2350,16 +2356,16 @@ void protoSignalComputation_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - re1 = L_add( RealBuffer_fx[0][0][l], RealBuffer_fx[1][0][l] ); - im1 = L_add( ImagBuffer_fx[0][0][l], ImagBuffer_fx[1][0][l] ); + re1 = L_add( RealBuffer_fx[0][0][l], RealBuffer_fx[1][0][l] ); /*Q(q_cldfb)*/ + im1 = L_add( ImagBuffer_fx[0][0][l], ImagBuffer_fx[1][0][l] ); /*Q(q_cldfb)*/ - p_proto_direct_buffer_fx[2 * l] = re1; + p_proto_direct_buffer_fx[2 * l] = re1; /*Q(q_cldfb)*/ move32(); - p_proto_direct_buffer_fx[add( 2 * l, 1 )] = im1; + p_proto_direct_buffer_fx[2 * l + 1] = im1; /*Q(q_cldfb)*/ move32(); - p_proto_direct_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = L_sub( RealBuffer_fx[0][0][l], RealBuffer_fx[1][0][l] ); + p_proto_direct_buffer_fx[2 * num_freq_bands + 2 * l] = L_sub( RealBuffer_fx[0][0][l], RealBuffer_fx[1][0][l] ); /*Q(q_cldfb)*/ move32(); - p_proto_direct_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = L_sub( ImagBuffer_fx[0][0][l], ImagBuffer_fx[1][0][l] ); + p_proto_direct_buffer_fx[2 * num_freq_bands + 2 * l + 1] = L_sub( ImagBuffer_fx[0][0][l], ImagBuffer_fx[1][0][l] ); /*Q(q_cldfb)*/ move32(); } } @@ -2368,10 +2374,10 @@ void protoSignalComputation_shd_fx( } ELSE IF( GE_16( num_inputs, 4 ) ) { - p_k_fx[0] = p_proto_direct_buffer_fx; - p_k_fx[1] = p_proto_direct_buffer_fx + i_mult( 2, num_freq_bands ); - p_k_fx[2] = p_proto_direct_buffer_fx + i_mult( 4, num_freq_bands ); - p_k_fx[3] = p_proto_direct_buffer_fx + i_mult( 6, num_freq_bands ); + p_k_fx[0] = p_proto_direct_buffer_fx; /*Q(proto_direct_buffer_f_q)*/ + p_k_fx[1] = p_proto_direct_buffer_fx + i_mult( 2, num_freq_bands ); /*Q(proto_direct_buffer_f_q)*/ + p_k_fx[2] = p_proto_direct_buffer_fx + i_mult( 4, num_freq_bands ); /*Q(proto_direct_buffer_f_q)*/ + p_k_fx[3] = p_proto_direct_buffer_fx + i_mult( 6, num_freq_bands ); /*Q(proto_direct_buffer_f_q)*/ Rmat_k[0] = 0; move16(); @@ -2399,50 +2405,50 @@ void protoSignalComputation_shd_fx( FOR( l = 0; l < num_freq_bands; l++ ) { - *p_k_fx[0] = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); + *p_k_fx[0] = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ move32(); - reference_power_fx[add( l, num_freq_bands )] = Mpy_32_32( *p_k_fx[0], *p_k_fx[0] ); + reference_power_fx[l + num_freq_bands] = Mpy_32_32( *p_k_fx[0], *p_k_fx[0] ); /*2*Q(q_cldfb+min_q_shift)-31*/ move32(); p_k_fx[0]++; - *p_k_fx[0] = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); + *p_k_fx[0] = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ move32(); - reference_power_fx[add( l, num_freq_bands )] = Madd_32_32( reference_power_fx[add( l, num_freq_bands )], *p_k_fx[0], *p_k_fx[0] ); + reference_power_fx[l + num_freq_bands] = Madd_32_32( reference_power_fx[l + num_freq_bands], *p_k_fx[0], *p_k_fx[0] ); /*2*Q(q_cldfb+min_q_shift)-31*/ move32(); p_k_fx[0]++; - reference_power_fx[l] = L_shr( reference_power_fx[add( l, num_freq_bands )], 1 ); + reference_power_fx[l] = L_shr( reference_power_fx[l + num_freq_bands], 1 ); /*2*Q(q_cldfb+min_q_shift)-31-1*/ move32(); FOR( k = 1; k < 4; k++ ) { - re1 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); - re2 = L_shl( RealBuffer_fx[2][0][l], min_q_shift ); - re3 = L_shl( RealBuffer_fx[3][0][l], min_q_shift ); - im1 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); - im2 = L_shl( ImagBuffer_fx[2][0][l], min_q_shift ); - im3 = L_shl( ImagBuffer_fx[3][0][l], min_q_shift ); + re1 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ + re2 = L_shl( RealBuffer_fx[2][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ + re3 = L_shl( RealBuffer_fx[3][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ + im1 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ + im2 = L_shl( ImagBuffer_fx[2][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ + im3 = L_shl( ImagBuffer_fx[3][0][l], min_q_shift ); /*Q(q_cldfb+min_q_shift)*/ idx = i_mult( 3, Rmat_k[k] ); idx1 = add( l, i_mult( add( k, 1 ), num_freq_bands ) ); - *p_k_fx[k] = Madd_32_32( Madd_32_32( Mpy_32_32( p_Rmat_fx[add( idx, 1 )], re1 ), p_Rmat_fx[add( idx, 2 )], re2 ), p_Rmat_fx[idx], re3 ); + *p_k_fx[k] = Madd_32_32( Madd_32_32( Mpy_32_32( p_Rmat_fx[idx + 1], re1 ), p_Rmat_fx[idx + 2], re2 ), p_Rmat_fx[idx], re3 ); /*Q(30 + q_cldfb+min_q_shift-31)=>Q(q_cldfb+min_q_shift-1)*/ move32(); - *p_k_fx[k] = L_shl( *p_k_fx[k], Q1 ); // left shift is done to maintain constant Q factor for p_k_fx + *p_k_fx[k] = L_shl( *p_k_fx[k], Q1 ); // left shift is done to maintain constant Q factor for p_k_fx Q(q_cldfb+min_q_shift) move32(); - reference_power_fx[idx1] = Mpy_32_32( *p_k_fx[k], *p_k_fx[k] ); + reference_power_fx[idx1] = Mpy_32_32( *p_k_fx[k], *p_k_fx[k] ); // Q(2*(q_cldfb + min_q_shift)-31) move32(); p_k_fx[k]++; - *p_k_fx[k] = Madd_32_32( Madd_32_32( Mpy_32_32( p_Rmat_fx[add( idx, 1 )], im1 ), p_Rmat_fx[add( idx, 2 )], im2 ), p_Rmat_fx[idx], im3 ); + *p_k_fx[k] = Madd_32_32( Madd_32_32( Mpy_32_32( p_Rmat_fx[idx + 1], im1 ), p_Rmat_fx[idx + 2], im2 ), p_Rmat_fx[idx], im3 ); /*Q(q_cldfb+min_q_shift-1)*/ move32(); - *p_k_fx[k] = L_shl( *p_k_fx[k], Q1 ); // left shift is done to maintain constant Q factor + *p_k_fx[k] = L_shl( *p_k_fx[k], Q1 ); // left shift is done to maintain constant Q factor Q(q_cldfb+min_q_shift) move32(); - reference_power_fx[idx1] = Mpy_32_32( *p_k_fx[k], *p_k_fx[k] ); + reference_power_fx[idx1] = Mpy_32_32( *p_k_fx[k], *p_k_fx[k] ); // Q(2*(q_cldfb + min_q_shift)-31) move32(); p_k_fx[k]++; - reference_power_fx[l] = L_add( reference_power_fx[l], L_shr( reference_power_fx[idx1], 1 ) ); + reference_power_fx[l] = L_add( reference_power_fx[l], L_shr( reference_power_fx[idx1], 1 ) ); /*2*Q(q_cldfb+min_q_shift)-31-1*/ move32(); } @@ -2451,9 +2457,9 @@ void protoSignalComputation_shd_fx( FOR( k = 1; k < 4; k++ ) { - RealBuffer_fx[k][0][l] = L_shr( p_proto_direct_buffer_fx[i_mult( 2, add( i_mult( k, num_freq_bands ), l ) )], sub( *proto_direct_buffer_f_q, q_cldfb ) ); + RealBuffer_fx[k][0][l] = L_shr( p_proto_direct_buffer_fx[2 * ( k * num_freq_bands + l )], sub( *proto_direct_buffer_f_q, q_cldfb ) ); // proto_direct_buffer_f_q -> q_cldfb move32(); - ImagBuffer_fx[k][0][l] = L_shr( p_proto_direct_buffer_fx[add( i_mult( 2, add( i_mult( k, num_freq_bands ), l ) ), 1 )], sub( *proto_direct_buffer_f_q, q_cldfb ) ); + ImagBuffer_fx[k][0][l] = L_shr( p_proto_direct_buffer_fx[2 * ( k * num_freq_bands + l ) + 1], sub( *proto_direct_buffer_f_q, q_cldfb ) ); // proto_direct_buffer_f_q -> q_cldfb move32(); } } @@ -2465,17 +2471,17 @@ void protoSignalComputation_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - p_proto_direct_buffer_fx[i_mult( 2, add( i_mult( k, num_freq_bands ), l ) )] = RealBuffer_fx[k][0][l]; + p_proto_direct_buffer_fx[2 * ( k * num_freq_bands + l )] = RealBuffer_fx[k][0][l]; // q_cldfb move32(); - p_proto_direct_buffer_fx[add( i_mult( 2, add( i_mult( k, num_freq_bands ), l ) ), 1 )] = ImagBuffer_fx[k][0][l]; + p_proto_direct_buffer_fx[2 * ( k * num_freq_bands + l ) + 1] = ImagBuffer_fx[k][0][l]; // q_cldfb move32(); - re1 = L_shl( RealBuffer_fx[k][0][l], min_q_shift ); - im1 = L_shl( ImagBuffer_fx[k][0][l], min_q_shift ); + re1 = L_shl( RealBuffer_fx[k][0][l], min_q_shift ); // q_cldfb+min_q_shift + im1 = L_shl( ImagBuffer_fx[k][0][l], min_q_shift ); // q_cldfb+min_q_shift - reference_power_fx[add( l, i_mult( add( k, 1 ), num_freq_bands ) )] = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); + reference_power_fx[l + ( k + 1 ) * num_freq_bands] = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); // 2*(q_cldfb+min_q_shift)-31 move32(); - reference_power_fx[l] = L_add( reference_power_fx[l], L_shr( reference_power_fx[add( l, i_mult( add( k, 1 ), num_freq_bands ) )], 1 ) ); + reference_power_fx[l] = L_add( reference_power_fx[l], L_shr( reference_power_fx[l + ( k + 1 ) * num_freq_bands], 1 ) ); // 2*(q_cldfb+min_q_shift)-31-1 move32(); } } @@ -2490,9 +2496,9 @@ void protoSignalComputation_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - p_proto_direct_buffer_fx[i_mult( 2, add( i_mult( k, num_freq_bands ), l ) )] = RealBuffer_fx[k][0][l]; + p_proto_direct_buffer_fx[2 * ( k * num_freq_bands + l )] = RealBuffer_fx[k][0][l]; // q_cldfb move32(); - p_proto_direct_buffer_fx[add( i_mult( 2, add( i_mult( k, num_freq_bands ), l ) ), 1 )] = ImagBuffer_fx[k][0][l]; + p_proto_direct_buffer_fx[2 * ( k * num_freq_bands + l ) + 1] = ImagBuffer_fx[k][0][l]; // q_cldfb move32(); } } @@ -2500,7 +2506,7 @@ void protoSignalComputation_shd_fx( /*Copy direct to diffuse proto*/ - Copy32( p_proto_direct_buffer_fx, p_proto_diffuse_buffer_fx, i_mult( i_mult( 2, num_freq_bands ), s_min( num_outputs_diff, num_inputs ) ) ); + Copy32( p_proto_direct_buffer_fx, p_proto_diffuse_buffer_fx, i_mult( i_mult( 2, num_freq_bands ), s_min( num_outputs_diff, num_inputs ) ) ); /*proto_diffuse_buffer_f_q -> proto_direct_buffer_f_q*/ *proto_diffuse_buffer_f_q = *proto_direct_buffer_f_q; move16(); @@ -2509,9 +2515,9 @@ void protoSignalComputation_shd_fx( /* Add comfort noise addition (CNA) to diffuse proto only*/ FOR( l = 0; l < num_freq_bands; l++ ) { - p_proto_diffuse_buffer_fx[i_mult( 2, l )] = L_add( p_proto_diffuse_buffer_fx[i_mult( 2, l )], RealBuffer_fx[1][0][l] ); + p_proto_diffuse_buffer_fx[2 * l] = L_add( p_proto_diffuse_buffer_fx[2 * l], RealBuffer_fx[1][0][l] ); // q_cldfb move32(); - p_proto_diffuse_buffer_fx[add( i_mult( 2, l ), 1 )] = L_add( p_proto_diffuse_buffer_fx[add( i_mult( 2, l ), 1 )], ImagBuffer_fx[1][0][l] ); + p_proto_diffuse_buffer_fx[2 * l + 1] = L_add( p_proto_diffuse_buffer_fx[2 * l + 1], ImagBuffer_fx[1][0][l] ); // q_cldfb move32(); } } @@ -2684,15 +2690,15 @@ void protoSignalComputation_shd( #ifdef IVAS_FLOAT_FIXED void protoSignalComputation1_fx( - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 *proto_frame_f_fx, + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 *proto_frame_f_fx, /*proto_frame_f_q*/ Word16 *proto_frame_f_q, - Word32 *proto_direct_buffer_f_fx, + Word32 *proto_direct_buffer_f_fx, /*proto_direct_buffer_f_q*/ Word16 *proto_direct_buffer_f_q, - Word32 *reference_power_fx, + Word32 *reference_power_fx, /*reference_power_q*/ Word16 *reference_power_q, - Word32 *proto_power_smooth_fx, + Word32 *proto_power_smooth_fx, /*proto_power_smooth_q*/ Word16 *proto_power_smooth_q, const Word16 slot_index, const Word16 num_outputs_diff, @@ -2709,7 +2715,7 @@ void protoSignalComputation1_fx( q_shift = Q31; move16(); - p_proto_buffer_fx = proto_direct_buffer_f_fx + i_mult( slot_index, i_mult( 2, num_freq_bands ) ); + p_proto_buffer_fx = proto_direct_buffer_f_fx + ( slot_index * ( 2 * num_freq_bands ) ); /*proto_direct_buffer_f_q*/ /* calculate the maximum shift possible for the bufferS RealBuffer_fx and ImagBuffer_fx*/ q_shift = L_norm_arr( RealBuffer_fx[0][0], num_freq_bands ); @@ -2723,48 +2729,48 @@ void protoSignalComputation1_fx( q_shift = getScaleFactor32( proto_power_smooth_fx, num_freq_bands ); q_shift = sub( q_shift, find_guarded_bits_fx( 2 ) ); - Scale_sig32( proto_power_smooth_fx, num_freq_bands, q_shift ); + Scale_sig32( proto_power_smooth_fx, num_freq_bands, q_shift ); /*proto_power_smooth_q+q_shift*/ *proto_power_smooth_q = add( *proto_power_smooth_q, q_shift ); proto_power_smooth_fx_q = *proto_power_smooth_q; move16(); FOR( l = 0; l < num_freq_bands; l++ ) { - re = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); - im = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); + re = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift + im = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift - reference_power_fx[l] = Madd_32_32( Mpy_32_32( re, re ), im, im ); + reference_power_fx[l] = Madd_32_32( Mpy_32_32( re, re ), im, im ); // 2*(q_cldfb+min_q_shift)-31 move32(); *reference_power_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); move16(); IF( LT_16( *reference_power_q, *proto_power_smooth_q ) ) { - proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *proto_power_smooth_q, *reference_power_q ) ), reference_power_fx[l] ); + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *proto_power_smooth_q, *reference_power_q ) ), reference_power_fx[l] ); // reference_power_q move32(); proto_power_smooth_fx_q = *reference_power_q; move16(); } ELSE { - proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( reference_power_fx[l], sub( *reference_power_q, *proto_power_smooth_q ) ) ); + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( reference_power_fx[l], sub( *reference_power_q, *proto_power_smooth_q ) ) ); // proto_power_smooth_q move32(); proto_power_smooth_fx_q = *proto_power_smooth_q; move16(); } - idx = i_mult( 2, l ); - p_proto_buffer_fx[idx] = RealBuffer_fx[0][0][l]; + idx = 2 * l; + p_proto_buffer_fx[idx] = RealBuffer_fx[0][0][l]; // q_cldfb move32(); - p_proto_buffer_fx[add( idx, 1 )] = ImagBuffer_fx[0][0][l]; + p_proto_buffer_fx[idx + 1] = ImagBuffer_fx[0][0][l]; // q_cldfb move32(); FOR( k = 0; k < num_outputs_diff; k++ ) { idx = add( i_mult( i_mult( 2, k ), num_freq_bands ), i_mult( 2, l ) ); - proto_frame_f_fx[idx] = RealBuffer_fx[0][0][l]; + proto_frame_f_fx[idx] = RealBuffer_fx[0][0][l]; // q_cldfb move32(); - proto_frame_f_fx[add( idx, 1 )] = ImagBuffer_fx[0][0][l]; + proto_frame_f_fx[idx + 1] = ImagBuffer_fx[0][0][l]; // q_cldfb move32(); } } @@ -2822,15 +2828,15 @@ void protoSignalComputation1( #ifdef IVAS_FLOAT_FIXED void protoSignalComputation2_fx( - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 *proto_frame_f_fx, + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 *proto_frame_f_fx, /*q_proto_frame_f*/ Word16 *q_proto_frame_f, - Word32 *proto_direct_buffer_f_fx, + Word32 *proto_direct_buffer_f_fx, /*q_proto_direct_buffer_f*/ Word16 *q_proto_direct_buffer_f, - Word32 *reference_power_fx, + Word32 *reference_power_fx, /*q_reference_power*/ Word16 *q_reference_power, - Word32 *proto_power_smooth_fx, + Word32 *proto_power_smooth_fx, /*q_proto_power_smooth*/ Word16 *q_proto_power_smooth, const Word16 isloudspeaker, const Word16 slot_index, @@ -2895,32 +2901,32 @@ void protoSignalComputation2_fx( IF( isloudspeaker ) { q_shift = getScaleFactor32( proto_power_smooth_fx, i_mult( 3, num_freq_bands ) ); - scale_sig32( proto_power_smooth_fx, i_mult( 3, num_freq_bands ), sub( q_shift, 1 ) ); + scale_sig32( proto_power_smooth_fx, i_mult( 3, num_freq_bands ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1 } ELSE { q_shift = getScaleFactor32( proto_power_smooth_fx, i_mult( 2, num_freq_bands ) ); - scale_sig32( proto_power_smooth_fx, i_mult( 2, num_freq_bands ), sub( q_shift, 1 ) ); + scale_sig32( proto_power_smooth_fx, i_mult( 2, num_freq_bands ), sub( q_shift, 1 ) ); // q_proto_power_smooth+q_shift-1 } *q_proto_power_smooth = add( *q_proto_power_smooth, sub( q_shift, 1 ) ); move16(); IF( isloudspeaker ) { - p_proto_buffer_fx = proto_direct_buffer_f_fx + i_mult( i_mult( i_mult( slot_index, 2 ), num_freq_bands ), 3 ); + p_proto_buffer_fx = proto_direct_buffer_f_fx + i_mult( i_mult( i_mult( slot_index, 2 ), num_freq_bands ), 3 ); // q_proto_direct_buffer_f q_temp = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); move16(); FOR( l = 0; l < num_freq_bands; l++ ) { - re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); - im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); - re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); - im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift - Real_aux_fx = L_add( re1, re2 ); - Imag_aux_fx = L_add( im1, im2 ); + Real_aux_fx = L_add( re1, re2 ); // q_cldfb+min_q_shift + Imag_aux_fx = L_add( im1, im2 ); // q_cldfb+min_q_shift // Left_power_fx = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); W_tmp1 = W_add( W_mult0_32_32( re1, re1 ), W_mult0_32_32( im1, im1 ) ); // 2*(q_cldfb+min_q_shift) @@ -2932,77 +2938,77 @@ void protoSignalComputation2_fx( reference_power_64fx[l] = W_add( W_tmp1, W_tmp2 ); // 2*(q_cldfb+min_q_shift) move64(); - temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); + temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift)-31 IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } - p_proto_buffer_fx[i_mult( 2, l )] = Real_aux_fx; + p_proto_buffer_fx[2 * l] = Real_aux_fx; // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( i_mult( 2, l ), 1 )] = Imag_aux_fx; + p_proto_buffer_fx[2 * l + 1] = Imag_aux_fx; // q_cldfb+min_q_shift move32(); - temp = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); + temp = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); // 2*(q_cldfb+min_q_shift)-31 IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[add( l, num_freq_bands )], sub( *q_proto_power_smooth, q_temp ) ), temp ); + proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( proto_power_smooth_fx[add( l, num_freq_bands )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } - p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = re1; + p_proto_buffer_fx[2 * ( num_freq_bands + l )] = re1; // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = im1; + p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] = im1; // q_cldfb+min_q_shift move32(); - temp = Madd_32_32( Mpy_32_32( re2, re2 ), im2, im2 ); + temp = Madd_32_32( Mpy_32_32( re2, re2 ), im2, im2 ); // 2*(q_cldfb+min_q_shift)-31 IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[add( l, i_mult( 2, num_freq_bands ) )] = L_add( L_shr( proto_power_smooth_fx[add( l, i_mult( 2, num_freq_bands ) )], sub( *q_proto_power_smooth, q_temp ) ), temp ); + proto_power_smooth_fx[l + ( 2 * num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[l + ( 2 * num_freq_bands )], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[add( l, i_mult( 2, num_freq_bands ) )] = L_add( proto_power_smooth_fx[add( l, i_mult( 2, num_freq_bands ) )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l + ( 2 * num_freq_bands )] = L_add( proto_power_smooth_fx[l + ( 2 * num_freq_bands )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } - p_proto_buffer_fx[add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) )] = re2; + p_proto_buffer_fx[4 * num_freq_bands + 2 * l] = re2; // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im2; + p_proto_buffer_fx[4 * num_freq_bands + 2 * l + 1] = im2; // q_cldfb+min_q_shift move32(); - proto_frame_f_fx[i_mult( 2, l )] = Real_aux_fx; + proto_frame_f_fx[2 * l] = Real_aux_fx; // q_cldfb+min_q_shift move32(); - proto_frame_f_fx[add( i_mult( 2, l ), 1 )] = Imag_aux_fx; + proto_frame_f_fx[2 * l + 1] = Imag_aux_fx; // q_cldfb+min_q_shift move32(); - proto_frame_f_fx[add( i_mult( 2, num_freq_bands ), i_mult( 2, l ) )] = re1; + proto_frame_f_fx[2 * num_freq_bands + 2 * l] = re1; // q_cldfb+min_q_shift move32(); - proto_frame_f_fx[add( add( i_mult( 2, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im1; + proto_frame_f_fx[2 * num_freq_bands + 2 * l + 1] = im1; // q_cldfb+min_q_shift move32(); - proto_frame_f_fx[add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) )] = re2; + proto_frame_f_fx[4 * num_freq_bands + 2 * l] = re2; // q_cldfb+min_q_shift move32(); - proto_frame_f_fx[add( add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im2; + proto_frame_f_fx[4 * num_freq_bands + 2 * l + 1] = im2; // q_cldfb+min_q_shift move32(); } } ELSE IF( stereo_type_detect != NULL ) { - p_proto_buffer_fx = proto_direct_buffer_f_fx + i_mult( i_mult( i_mult( slot_index, 2 ), num_freq_bands ), 2 ); + p_proto_buffer_fx = proto_direct_buffer_f_fx + ( slot_index * 4 * num_freq_bands ); // q_proto_direct_buffer_f left_bb_power_fx = 0; move32(); @@ -3025,7 +3031,7 @@ void protoSignalComputation2_fx( a_fx = 21474836; /*0.01 in Q31*/ /* Temporal smoothing coefficient */ move32(); - b_fx = L_sub( ONE_IN_Q31, a_fx ); /* Temporal smoothing coefficient */ + b_fx = L_sub( ONE_IN_Q31, a_fx ); /* Temporal smoothing coefficient q31*/ // a2_fx = 214748365; /*0.1 in Q31*/ /* Temporal smoothing coefficient */ // b2_fx = L_sub( ONE_IN_Q31, a2_fx ); /* Temporal smoothing coefficient */ @@ -3052,14 +3058,14 @@ void protoSignalComputation2_fx( FOR( l = 0; l < num_freq_bands; l++ ) { - re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); - im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); - re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); - im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+min_q_shift + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+min_q_shift /* Compute sum signal */ - Real_aux_fx = L_add( re1, re2 ); - Imag_aux_fx = L_add( im1, im2 ); + Real_aux_fx = L_add( re1, re2 ); // q_cldfb+min_q_shift + Imag_aux_fx = L_add( im1, im2 ); // q_cldfb+min_q_shift /* Compute reference power */ // Left_power_fx = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); @@ -3073,82 +3079,82 @@ void protoSignalComputation2_fx( reference_power_64fx[l] = W_add( W_tmp1, W_tmp2 ); // 2*(q_cldfb+min_q_shift) move64(); - left_bb_power_fx = L_add( left_bb_power_fx, Left_power_fx ); - right_bb_power_fx = L_add( right_bb_power_fx, Right_power_fx ); + left_bb_power_fx = L_add( left_bb_power_fx, Left_power_fx ); // 2*(q_cldfb+min_q_shift) -31 + right_bb_power_fx = L_add( right_bb_power_fx, Right_power_fx ); // 2*(q_cldfb+min_q_shift) -31 // total_bb_power_fx = L_add( total_bb_power_fx, reference_power_fx[l] ); - total_bb_power_fx = L_add( total_bb_power_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); + total_bb_power_fx = L_add( total_bb_power_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // 2*(q_cldfb+min_q_shift) -31 IF( GT_16( l, MASA_HI_FREQ_START_BIN ) ) { - left_hi_power_fx = L_add( left_hi_power_fx, Left_power_fx ); - right_hi_power_fx = L_add( right_hi_power_fx, Right_power_fx ); + left_hi_power_fx = L_add( left_hi_power_fx, Left_power_fx ); // 2*(q_cldfb+min_q_shift) -31 + right_hi_power_fx = L_add( right_hi_power_fx, Right_power_fx ); // 2*(q_cldfb+min_q_shift) -31 // total_hi_power_fx = L_add( total_hi_power_fx, reference_power_fx[l] ); - total_hi_power_fx = L_add( total_hi_power_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); + total_hi_power_fx = L_add( total_hi_power_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // 2*(q_cldfb+min_q_shift) -31 } IF( LT_16( l, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ) ) { - re_aux = L_shl( Real_aux_fx, sub( temp_q_shift, min_q_shift ) ); - im_aux = L_shl( Imag_aux_fx, sub( temp_q_shift, min_q_shift ) ); + re_aux = L_shl( Real_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift + im_aux = L_shl( Imag_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift - sum_power_fx = Madd_32_32( Mpy_32_32( re_aux, re_aux ), im_aux, im_aux ); - temp = Mpy_32_32( a_fx, sum_power_fx ); + sum_power_fx = Madd_32_32( Mpy_32_32( re_aux, re_aux ), im_aux, im_aux ); // 2*(q_cldfb+temp_q_shift)-31 + temp = Mpy_32_32( a_fx, sum_power_fx ); // 2*(q_cldfb+temp_q_shift)-31 IF( LT_16( q_temp2, stereo_type_detect->q_sum_power ) ) { - stereo_type_detect->sum_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->sum_power_fx[l] ), sub( stereo_type_detect->q_sum_power, q_temp2 ) ) ); + stereo_type_detect->sum_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->sum_power_fx[l] ), sub( stereo_type_detect->q_sum_power, q_temp2 ) ) ); // q_temp2 move32(); } ELSE { - stereo_type_detect->sum_power_fx[l] = L_add( L_shr( temp, sub( q_temp2, stereo_type_detect->q_sum_power ) ), Mpy_32_32( b_fx, stereo_type_detect->sum_power_fx[l] ) ); + stereo_type_detect->sum_power_fx[l] = L_add( L_shr( temp, sub( q_temp2, stereo_type_detect->q_sum_power ) ), Mpy_32_32( b_fx, stereo_type_detect->sum_power_fx[l] ) ); // stereo_type_detect->q_sum_power move32(); } - temp = Mpy_32_32( a_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); + temp = Mpy_32_32( a_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // 2*(q_cldfb+min_q_shift) -31 IF( LT_16( q_temp, stereo_type_detect->q_total_power ) ) { - stereo_type_detect->total_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ), sub( stereo_type_detect->q_total_power, q_temp ) ) ); + stereo_type_detect->total_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ), sub( stereo_type_detect->q_total_power, q_temp ) ) ); // q_temp move32(); } ELSE { - stereo_type_detect->total_power_fx[l] = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ) ); + stereo_type_detect->total_power_fx[l] = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ) ); // stereo_type_detect->q_total_power move32(); } test(); IF( ( stereo_type_detect->sum_power_fx[l] == 0 ) && ( stereo_type_detect->total_power_fx[l] == 0 ) ) { - sum_total_ratio_fx[l] = MAX_16; + sum_total_ratio_fx[l] = MAX_16; // q15 move32(); } ELSE { - sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale( stereo_type_detect->sum_power_fx[l], L_add( stereo_type_detect->total_power_fx[l], EPSILON_FX ), &exp ); + sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale( stereo_type_detect->sum_power_fx[l], L_add( stereo_type_detect->total_power_fx[l], EPSILON_FX ), &exp ); // 15-(exp+s_min( stereo_type_detect->q_total_power, q_temp )-s_min( stereo_type_detect->q_sum_power, q_temp2 )) move32(); q_sum_total_ratio = add( sub( 15, exp ), sub( s_min( stereo_type_detect->q_sum_power, q_temp2 ), s_min( stereo_type_detect->q_total_power, q_temp ) ) ); - sum_total_ratio_fx[l] = L_shl( sum_total_ratio_fx[l], sub( Q15, q_sum_total_ratio ) ); + sum_total_ratio_fx[l] = L_shl( sum_total_ratio_fx[l], sub( Q15, q_sum_total_ratio ) ); // q15 move32(); } } IF( l == 0 ) { - RealSubtract_fx = L_sub( re1, re2 ); - ImagSubtract_fx = L_sub( im1, im2 ); + RealSubtract_fx = L_sub( re1, re2 ); // q_cldfb+min_q_shift + ImagSubtract_fx = L_sub( im1, im2 ); // q_cldfb+min_q_shift - temp = Madd_32_32( Mpy_32_32( RealSubtract_fx, RealSubtract_fx ), ImagSubtract_fx, ImagSubtract_fx ); + temp = Madd_32_32( Mpy_32_32( RealSubtract_fx, RealSubtract_fx ), ImagSubtract_fx, ImagSubtract_fx ); // 2*(q_cldfb+min_q_shift)-31 IF( LT_16( q_temp, stereo_type_detect->q_subtract_power_y ) ) { - stereo_type_detect->subtract_power_y_fx = L_add( L_shr( stereo_type_detect->subtract_power_y_fx, sub( stereo_type_detect->q_subtract_power_y, q_temp ) ), temp ); + stereo_type_detect->subtract_power_y_fx = L_add( L_shr( stereo_type_detect->subtract_power_y_fx, sub( stereo_type_detect->q_subtract_power_y, q_temp ) ), temp ); // q_temp move32(); stereo_type_detect->q_subtract_power_y = q_temp; move16(); } ELSE { - stereo_type_detect->subtract_power_y_fx = L_add( stereo_type_detect->subtract_power_y_fx, L_shr( temp, sub( q_temp, stereo_type_detect->q_subtract_power_y ) ) ); + stereo_type_detect->subtract_power_y_fx = L_add( stereo_type_detect->subtract_power_y_fx, L_shr( temp, sub( q_temp, stereo_type_detect->q_subtract_power_y ) ) ); // stereo_type_detect->q_subtract_power_y move32(); } } @@ -3160,46 +3166,46 @@ void protoSignalComputation2_fx( { IF( L_or( LT_16( l, sub( dipole_freq_range[1], 1 ) ), GE_16( l, MASA_SUM_PROTO_START_BIN ) ) ) { - Real_aux_fx = Madd_32_16( Mpy_32_16_1( Real_aux_fx, shr( interpolatorSpaced_fx, 1 ) ), Real_aux_fx, interpolatorDmx_fx ); - Imag_aux_fx = Madd_32_16( Mpy_32_16_1( Imag_aux_fx, shr( interpolatorSpaced_fx, 1 ) ), Imag_aux_fx, interpolatorDmx_fx ); + Real_aux_fx = Madd_32_16( Mpy_32_16_1( Real_aux_fx, shr( interpolatorSpaced_fx, 1 ) ), Real_aux_fx, interpolatorDmx_fx ); // q_cldfb+min_q_shift + Imag_aux_fx = Madd_32_16( Mpy_32_16_1( Imag_aux_fx, shr( interpolatorSpaced_fx, 1 ) ), Imag_aux_fx, interpolatorDmx_fx ); // q_cldfb+min_q_shift - temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); + temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift) -31 IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } - p_proto_buffer_fx[2 * l] = Real_aux_fx; + p_proto_buffer_fx[2 * l] = Real_aux_fx; // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( 2 * l, 1 )] = Imag_aux_fx; + p_proto_buffer_fx[2 * l + 1] = Imag_aux_fx; // q_cldfb+min_q_shift move32(); } ELSE { - tempSpaced_fx = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); - tempDmx_fx = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); + tempSpaced_fx = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); // 2*(q_cldfb+min_q_shift)-31 + tempDmx_fx = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift)-31 - temp = Madd_32_16( Mpy_32_16_1( tempSpaced_fx, interpolatorSpaced_fx ), tempDmx_fx, interpolatorDmx_fx ); + temp = Madd_32_16( Mpy_32_16_1( tempSpaced_fx, interpolatorSpaced_fx ), tempDmx_fx, interpolatorDmx_fx ); // 2*(q_cldfb+min_q_shift)-31 IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } - p_proto_buffer_fx[2 * l] = Madd_32_16( Mpy_32_16_1( re1, interpolatorSpaced_fx ), Real_aux_fx, interpolatorDmx_fx ); + p_proto_buffer_fx[2 * l] = Madd_32_16( Mpy_32_16_1( re1, interpolatorSpaced_fx ), Real_aux_fx, interpolatorDmx_fx ); // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( 2 * l, 1 )] = Madd_32_16( Mpy_32_16_1( im1, interpolatorSpaced_fx ), Imag_aux_fx, interpolatorDmx_fx ); + p_proto_buffer_fx[2 * l + 1] = Madd_32_16( Mpy_32_16_1( im1, interpolatorSpaced_fx ), Imag_aux_fx, interpolatorDmx_fx ); // q_cldfb+min_q_shift move32(); } } @@ -3207,62 +3213,62 @@ void protoSignalComputation2_fx( { IF( L_or( LT_16( l, sub( dipole_freq_range[1], 1 ) ), GE_16( l, MASA_SUM_PROTO_START_BIN ) ) ) { - Real_aux_fx = L_shr( Real_aux_fx, 1 ); - Imag_aux_fx = L_shr( Imag_aux_fx, 1 ); - temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); + Real_aux_fx = L_shr( Real_aux_fx, 1 ); // q_cldfb+min_q_shift + Imag_aux_fx = L_shr( Imag_aux_fx, 1 ); // q_cldfb+min_q_shift + temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift)-31 IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } - p_proto_buffer_fx[2 * l] = Real_aux_fx; + p_proto_buffer_fx[2 * l] = Real_aux_fx; // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( 2 * l, 1 )] = Imag_aux_fx; + p_proto_buffer_fx[2 * l + 1] = Imag_aux_fx; // q_cldfb+min_q_shift move32(); } ELSE { - temp = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); + temp = Madd_32_32( Mpy_32_32( re1, re1 ), im1, im1 ); // 2*(q_cldfb+min_q_shift)-31 IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } - p_proto_buffer_fx[2 * l] = re1; + p_proto_buffer_fx[2 * l] = re1; // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( 2 * l, 1 )] = im1; + p_proto_buffer_fx[2 * l + 1] = im1; // q_cldfb+min_q_shift move32(); } } ELSE { - temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); + temp = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); // 2*(q_cldfb+min_q_shift)-31 IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } - p_proto_buffer_fx[2 * l] = Real_aux_fx; + p_proto_buffer_fx[2 * l] = Real_aux_fx; // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( 2 * l, 1 )] = Imag_aux_fx; + p_proto_buffer_fx[2 * l + 1] = Imag_aux_fx; // q_cldfb+min_q_shift move32(); } @@ -3271,35 +3277,35 @@ void protoSignalComputation2_fx( { IF( LT_16( l, dipole_freq_range[0] ) ) { - p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[2 * l], interpolatorSpaced_fx ), L_sub( re1, re2 ), interpolatorDmx_fx ); + p_proto_buffer_fx[2 * ( num_freq_bands + l )] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[2 * l], interpolatorSpaced_fx ), L_sub( re1, re2 ), interpolatorDmx_fx ); // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[add( 2 * l, 1 )], interpolatorSpaced_fx ), L_sub( im1, im2 ), interpolatorDmx_fx ); + p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[2 * l + 1], interpolatorSpaced_fx ), L_sub( im1, im2 ), interpolatorDmx_fx ); // q_cldfb+min_q_shift move32(); } ELSE IF( LT_16( l, dipole_freq_range[1] ) ) { - p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = Madd_32_16( Mpy_32_16_1( L_sub( im1, im2 ), interpolatorSpaced_fx ), L_sub( re1, re2 ), interpolatorDmx_fx ); + p_proto_buffer_fx[2 * ( num_freq_bands + l )] = Madd_32_16( Mpy_32_16_1( L_sub( im1, im2 ), interpolatorSpaced_fx ), L_sub( re1, re2 ), interpolatorDmx_fx ); // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = Madd_32_16( Mpy_32_16_1( -L_sub( re1, re2 ), interpolatorSpaced_fx ), L_sub( im1, im2 ), interpolatorDmx_fx ); + p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] = Madd_32_16( Mpy_32_16_1( -L_sub( re1, re2 ), interpolatorSpaced_fx ), L_sub( im1, im2 ), interpolatorDmx_fx ); // q_cldfb+min_q_shift move32(); } ELSE { - p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[2 * l], interpolatorSpaced_fx ), L_sub( re1, re2 ), interpolatorDmx_fx ); + p_proto_buffer_fx[2 * ( num_freq_bands + l )] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[2 * l], interpolatorSpaced_fx ), L_sub( re1, re2 ), interpolatorDmx_fx ); // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[add( 2 * l, 1 )], interpolatorSpaced_fx ), L_sub( im1, im2 ), interpolatorDmx_fx ); + p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] = Madd_32_16( Mpy_32_16_1( p_proto_buffer_fx[2 * l + 1], interpolatorSpaced_fx ), L_sub( im1, im2 ), interpolatorDmx_fx ); // q_cldfb+min_q_shift move32(); } - temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )], p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] ), p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )], p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] ); + temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[2 * ( num_freq_bands + l )], p_proto_buffer_fx[2 * ( num_freq_bands + l )] ), p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1], p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] ); // 2*(q_cldfb+min_q_shift)-31 IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[add( l, num_freq_bands )], sub( *q_proto_power_smooth, q_temp ) ), temp ); + proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( proto_power_smooth_fx[add( l, num_freq_bands )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } } @@ -3307,74 +3313,74 @@ void protoSignalComputation2_fx( { IF( LT_16( l, dipole_freq_range[0] ) ) /* proto = W */ { - p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = p_proto_buffer_fx[2 * l]; + p_proto_buffer_fx[2 * ( num_freq_bands + l )] = p_proto_buffer_fx[2 * l]; // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = p_proto_buffer_fx[add( 2 * l, 1 )]; + p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] = p_proto_buffer_fx[2 * l + 1]; // q_cldfb+min_q_shift move32(); - proto_power_smooth_fx[add( l, num_freq_bands )] = proto_power_smooth_fx[l]; + proto_power_smooth_fx[l + num_freq_bands] = proto_power_smooth_fx[l]; move32(); } ELSE IF( LT_16( l, dipole_freq_range[1] ) ) /* proto = -i * (x1-x2) * eq */ { - p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = L_sub( im1, im2 ); + p_proto_buffer_fx[2 * ( num_freq_bands + l )] = L_sub( im1, im2 ); // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = -L_sub( re1, re2 ); + p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] = -L_sub( re1, re2 ); // q_cldfb+min_q_shift move32(); - temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )], p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] ), p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )], p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] ); + temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[2 * ( num_freq_bands + l )], p_proto_buffer_fx[2 * ( num_freq_bands + l )] ), p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1], p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] ); // 2*(q_cldfb+min_q_shift)-31 IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[add( l, num_freq_bands )], sub( *q_proto_power_smooth, q_temp ) ), temp ); + proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( proto_power_smooth_fx[add( l, num_freq_bands )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } } ELSE /* proto = W */ { - p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = p_proto_buffer_fx[2 * l]; + p_proto_buffer_fx[2 * ( num_freq_bands + l )] = p_proto_buffer_fx[2 * l]; // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = p_proto_buffer_fx[add( 2 * l, 1 )]; + p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] = p_proto_buffer_fx[2 * l + 1]; // q_cldfb+min_q_shift move32(); - proto_power_smooth_fx[add( l, num_freq_bands )] = proto_power_smooth_fx[l]; + proto_power_smooth_fx[l + num_freq_bands] = proto_power_smooth_fx[l]; // min( q_temp, *q_proto_power_smooth ) move32(); } } ELSE { - p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = L_sub( re1, re2 ); + p_proto_buffer_fx[2 * ( num_freq_bands + l )] = L_sub( re1, re2 ); // q_cldfb+min_q_shift move32(); - p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = L_sub( im1, im2 ); + p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] = L_sub( im1, im2 ); // q_cldfb+min_q_shift move32(); - temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )], p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] ), p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )], p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] ); + temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[2 * ( num_freq_bands + l )], p_proto_buffer_fx[2 * ( num_freq_bands + l )] ), p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1], p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] ); // 2*(q_cldfb+min_q_shift)-31 IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[add( l, num_freq_bands )], sub( *q_proto_power_smooth, q_temp ) ), temp ); + proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( proto_power_smooth_fx[add( l, num_freq_bands )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } } /* Compute protos for decorrelation */ - proto_frame_f_fx[2 * l] = Real_aux_fx; + proto_frame_f_fx[2 * l] = Real_aux_fx; // q_cldfb+min_q_shift move32(); - proto_frame_f_fx[add( 2 * l, 1 )] = Imag_aux_fx; + proto_frame_f_fx[2 * l + 1] = Imag_aux_fx; // q_cldfb+min_q_shift move32(); - proto_frame_f_fx[add( i_mult( 2, num_freq_bands ), i_mult( 2, l ) )] = re1; + proto_frame_f_fx[2 * num_freq_bands + 2 * l] = re1; // q_cldfb+min_q_shift move32(); - proto_frame_f_fx[add( add( i_mult( 2, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im1; + proto_frame_f_fx[2 * num_freq_bands + 2 * l + 1] = im1; // q_cldfb+min_q_shift move32(); - proto_frame_f_fx[add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) )] = re2; + proto_frame_f_fx[4 * num_freq_bands + 2 * l] = re2; // q_cldfb+min_q_shift move32(); - proto_frame_f_fx[add( add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im2; + proto_frame_f_fx[4 * num_freq_bands + 2 * l + 1] = im2; // q_cldfb+min_q_shift move32(); } @@ -3397,67 +3403,67 @@ void protoSignalComputation2_fx( } } - temp = Mpy_32_32( a_fx, left_bb_power_fx ); + temp = Mpy_32_32( a_fx, left_bb_power_fx ); // 2*(q_cldfb+min_q_shift) -31 IF( LT_16( q_temp, stereo_type_detect->q_left_bb_power ) ) { - stereo_type_detect->left_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->left_bb_power_fx ), sub( stereo_type_detect->q_left_bb_power, q_temp ) ) ); + stereo_type_detect->left_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->left_bb_power_fx ), sub( stereo_type_detect->q_left_bb_power, q_temp ) ) ); // q_temp move32(); stereo_type_detect->q_left_bb_power = q_temp; move16(); } ELSE { - stereo_type_detect->left_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_left_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->left_bb_power_fx ) ); + stereo_type_detect->left_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_left_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->left_bb_power_fx ) ); // stereo_type_detect->q_left_bb_power move32(); } - temp = Mpy_32_32( a_fx, right_bb_power_fx ); + temp = Mpy_32_32( a_fx, right_bb_power_fx ); // 2*(q_cldfb+min_q_shift) -31 IF( LT_16( q_temp, stereo_type_detect->q_right_bb_power ) ) { - stereo_type_detect->right_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->right_bb_power_fx ), sub( stereo_type_detect->q_right_bb_power, q_temp ) ) ); + stereo_type_detect->right_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->right_bb_power_fx ), sub( stereo_type_detect->q_right_bb_power, q_temp ) ) ); // q_temp move32(); stereo_type_detect->q_right_bb_power = q_temp; move16(); } ELSE { - stereo_type_detect->right_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_right_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->right_bb_power_fx ) ); + stereo_type_detect->right_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_right_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->right_bb_power_fx ) ); // stereo_type_detect->q_right_bb_power move32(); } - temp = Mpy_32_32( a_fx, total_bb_power_fx ); + temp = Mpy_32_32( a_fx, total_bb_power_fx ); // 2*(q_cldfb+min_q_shift) -31 IF( LT_16( q_temp, stereo_type_detect->q_total_bb_power ) ) { - stereo_type_detect->total_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_bb_power_fx ), sub( stereo_type_detect->q_total_bb_power, q_temp ) ) ); + stereo_type_detect->total_bb_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_bb_power_fx ), sub( stereo_type_detect->q_total_bb_power, q_temp ) ) ); // q_temp move32(); stereo_type_detect->q_total_bb_power = q_temp; move16(); } ELSE { - stereo_type_detect->total_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_bb_power_fx ) ); + stereo_type_detect->total_bb_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_bb_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_bb_power_fx ) ); // stereo_type_detect->q_total_bb_power move32(); } IF( LT_16( stereo_type_detect->q_left_bb_power, stereo_type_detect->q_right_bb_power ) ) { - lr_bb_power_fx = L_min( stereo_type_detect->left_bb_power_fx, L_shr( stereo_type_detect->right_bb_power_fx, sub( stereo_type_detect->q_right_bb_power, stereo_type_detect->q_left_bb_power ) ) ); + lr_bb_power_fx = L_min( stereo_type_detect->left_bb_power_fx, L_shr( stereo_type_detect->right_bb_power_fx, sub( stereo_type_detect->q_right_bb_power, stereo_type_detect->q_left_bb_power ) ) ); // stereo_type_detect->q_left_bb_power move32(); q_lr_bb_power = stereo_type_detect->q_left_bb_power; move16(); } ELSE { - lr_bb_power_fx = L_min( L_shr( stereo_type_detect->left_bb_power_fx, sub( stereo_type_detect->q_left_bb_power, stereo_type_detect->q_right_bb_power ) ), stereo_type_detect->right_bb_power_fx ); + lr_bb_power_fx = L_min( L_shr( stereo_type_detect->left_bb_power_fx, sub( stereo_type_detect->q_left_bb_power, stereo_type_detect->q_right_bb_power ) ), stereo_type_detect->right_bb_power_fx ); // stereo_type_detect->q_right_bb_power move32(); q_lr_bb_power = stereo_type_detect->q_right_bb_power; move16(); } q_lr_bb_power = sub( q_lr_bb_power, 1 ); /* = (lr_bb_power_fx * 2) */ - temp = BASOP_Util_Divide3232_Scale_cadence( lr_bb_power_fx, L_add( stereo_type_detect->total_bb_power_fx, EPSILON_FX ), &exp ); + temp = BASOP_Util_Divide3232_Scale_cadence( lr_bb_power_fx, L_add( stereo_type_detect->total_bb_power_fx, EPSILON_FX ), &exp ); // Q(31-(exp+stereo_type_detect->q_total_bb_power-q_lr_bb_power)) exp = sub( 31, add( sub( 31, exp ), sub( q_lr_bb_power, stereo_type_detect->q_total_bb_power ) ) ); - temp = BASOP_Util_Log2( temp ); + temp = BASOP_Util_Log2( temp ); // q25 IF( NE_32( temp, MIN_32 ) ) { temp = Mpy_32_32( L_add( L_shl( exp, Q25 ), temp ), LOG10_2_Q31 ); // Q25 @@ -3465,65 +3471,65 @@ void protoSignalComputation2_fx( // 20480 = 10 in Q11 lr_total_bb_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21 - temp = Mpy_32_32( a_fx, left_hi_power_fx ); + temp = Mpy_32_32( a_fx, left_hi_power_fx ); // 2*(q_cldfb+min_q_shift) -31 IF( LT_16( q_temp, stereo_type_detect->q_left_hi_power ) ) { - stereo_type_detect->left_hi_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->left_hi_power_fx ), sub( stereo_type_detect->q_left_hi_power, q_temp ) ) ); + stereo_type_detect->left_hi_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->left_hi_power_fx ), sub( stereo_type_detect->q_left_hi_power, q_temp ) ) ); // q_temp move32(); stereo_type_detect->q_left_hi_power = q_temp; move16(); } ELSE { - stereo_type_detect->left_hi_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_left_hi_power ) ), Mpy_32_32( b_fx, stereo_type_detect->left_hi_power_fx ) ); + stereo_type_detect->left_hi_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_left_hi_power ) ), Mpy_32_32( b_fx, stereo_type_detect->left_hi_power_fx ) ); // stereo_type_detect->q_left_hi_power move32(); } - temp = Mpy_32_32( a_fx, right_hi_power_fx ); + temp = Mpy_32_32( a_fx, right_hi_power_fx ); // 2*(q_cldfb+min_q_shift) -31 IF( LT_16( q_temp, stereo_type_detect->q_right_hi_power ) ) { - stereo_type_detect->right_hi_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->right_hi_power_fx ), sub( stereo_type_detect->q_right_hi_power, q_temp ) ) ); + stereo_type_detect->right_hi_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->right_hi_power_fx ), sub( stereo_type_detect->q_right_hi_power, q_temp ) ) ); // q_temp move32(); stereo_type_detect->q_right_hi_power = q_temp; move16(); } ELSE { - stereo_type_detect->right_hi_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_right_hi_power ) ), Mpy_32_32( b_fx, stereo_type_detect->right_hi_power_fx ) ); + stereo_type_detect->right_hi_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_right_hi_power ) ), Mpy_32_32( b_fx, stereo_type_detect->right_hi_power_fx ) ); // stereo_type_detect->q_right_hi_power move32(); } - temp = Mpy_32_32( a_fx, total_hi_power_fx ); + temp = Mpy_32_32( a_fx, total_hi_power_fx ); // 2*(q_cldfb+min_q_shift) -31 IF( LT_16( q_temp, stereo_type_detect->q_total_hi_power ) ) { - stereo_type_detect->total_hi_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_hi_power_fx ), sub( stereo_type_detect->q_total_hi_power, q_temp ) ) ); + stereo_type_detect->total_hi_power_fx = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_hi_power_fx ), sub( stereo_type_detect->q_total_hi_power, q_temp ) ) ); // q_temp move32(); stereo_type_detect->q_total_hi_power = q_temp; move16(); } ELSE { - stereo_type_detect->total_hi_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_hi_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_hi_power_fx ) ); + stereo_type_detect->total_hi_power_fx = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_hi_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_hi_power_fx ) ); // stereo_type_detect->q_total_hi_power move32(); } IF( LT_16( stereo_type_detect->q_left_hi_power, stereo_type_detect->q_right_hi_power ) ) { - lr_hi_power_fx = L_min( stereo_type_detect->left_hi_power_fx, L_shr( stereo_type_detect->right_hi_power_fx, sub( stereo_type_detect->q_right_hi_power, stereo_type_detect->q_left_hi_power ) ) ); + lr_hi_power_fx = L_min( stereo_type_detect->left_hi_power_fx, L_shr( stereo_type_detect->right_hi_power_fx, sub( stereo_type_detect->q_right_hi_power, stereo_type_detect->q_left_hi_power ) ) ); // stereo_type_detect->q_left_hi_power move32(); q_lr_hi_power = stereo_type_detect->q_left_hi_power; } ELSE { - lr_hi_power_fx = L_min( L_shr( stereo_type_detect->left_hi_power_fx, sub( stereo_type_detect->q_left_hi_power, stereo_type_detect->q_right_hi_power ) ), stereo_type_detect->right_hi_power_fx ); + lr_hi_power_fx = L_min( L_shr( stereo_type_detect->left_hi_power_fx, sub( stereo_type_detect->q_left_hi_power, stereo_type_detect->q_right_hi_power ) ), stereo_type_detect->right_hi_power_fx ); // stereo_type_detect->q_right_hi_power move32(); q_lr_hi_power = stereo_type_detect->q_right_hi_power; } q_lr_hi_power = sub( q_lr_hi_power, 1 ); /* = (q_lr_hi_power * 2) */ - temp = BASOP_Util_Divide3232_Scale_cadence( lr_hi_power_fx, L_add( stereo_type_detect->total_hi_power_fx, EPSILON_FX ), &exp ); + temp = BASOP_Util_Divide3232_Scale_cadence( lr_hi_power_fx, L_add( stereo_type_detect->total_hi_power_fx, EPSILON_FX ), &exp ); // Q=31-(exp+ stereo_type_detect->q_total_hi_power-q_lr_hi_power) exp = sub( 31, add( sub( 31, exp ), sub( q_lr_hi_power, stereo_type_detect->q_total_hi_power ) ) ); - temp = BASOP_Util_Log2( temp ); + temp = BASOP_Util_Log2( temp ); // q25 IF( NE_32( temp, MIN_32 ) ) { temp = Mpy_32_32( L_add( L_shl( exp, Q25 ), temp ), LOG10_2_Q31 ); // Q25 @@ -3531,9 +3537,9 @@ void protoSignalComputation2_fx( // 20480 = 10 in Q11 lr_total_hi_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21 - minimum_l( sum_total_ratio_fx, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ), &min_sum_total_ratio_fx ); + minimum_l( sum_total_ratio_fx, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ), &min_sum_total_ratio_fx ); // q_sum_total_ratio exp = sub( 31, q_sum_total_ratio ); - temp = BASOP_Util_Log2( min_sum_total_ratio_fx ); + temp = BASOP_Util_Log2( min_sum_total_ratio_fx ); // q25 IF( NE_32( temp, MIN_32 ) ) { temp = Mpy_32_32( L_add( L_shl( exp, Q25 ), temp ), LOG10_2_Q31 ); // Q25 @@ -3552,69 +3558,69 @@ void protoSignalComputation2_fx( } ELSE { - p_proto_buffer_fx = proto_direct_buffer_f_fx + i_mult( i_mult( i_mult( slot_index, 2 ), num_freq_bands ), 2 ); + p_proto_buffer_fx = proto_direct_buffer_f_fx + ( slot_index * num_freq_bands * 4 ); // q_proto_direct_buffer_f q_temp = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); FOR( l = 0; l < num_freq_bands; l++ ) { - re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); - re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); - im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); - im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); + re1 = L_shl( RealBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+ min_q_shift + re2 = L_shl( RealBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+ min_q_shift + im1 = L_shl( ImagBuffer_fx[0][0][l], min_q_shift ); // q_cldfb+ min_q_shift + im2 = L_shl( ImagBuffer_fx[1][0][l], min_q_shift ); // q_cldfb+ min_q_shift - Real_aux_fx = L_add( re1, re2 ); - Imag_aux_fx = L_add( im1, im2 ); + Real_aux_fx = L_add( re1, re2 ); // q_cldfb+ min_q_shift + Imag_aux_fx = L_add( im1, im2 ); // q_cldfb+ min_q_shift // reference_power_fx[l] = Madd_32_32( Mpy_32_32( Real_aux_fx, Real_aux_fx ), Imag_aux_fx, Imag_aux_fx ); - reference_power_64fx[l] = W_add( W_mult0_32_32( Real_aux_fx, Real_aux_fx ), W_mult0_32_32( Imag_aux_fx, Imag_aux_fx ) ); // 2*(q_cldfb+min_q_shift) + reference_power_64fx[l] = W_add( W_mult0_32_32( Real_aux_fx, Real_aux_fx ), W_mult0_32_32( Imag_aux_fx, Imag_aux_fx ) ); // q_temp move64(); IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); + proto_power_smooth_fx[l] = L_add( L_shr( proto_power_smooth_fx[l], sub( *q_proto_power_smooth, q_temp ) ), W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( W_extract_l( W_shr( reference_power_64fx[l], 31 ) ), sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l] = L_add( proto_power_smooth_fx[l], L_shr( W_extract_l( W_shr( reference_power_64fx[l], 31 ) ), sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } - p_proto_buffer_fx[2 * l] = Real_aux_fx; + p_proto_buffer_fx[2 * l] = Real_aux_fx; // q_cldfb+ min_q_shift move32(); - p_proto_buffer_fx[add( 2 * l, 1 )] = Imag_aux_fx; + p_proto_buffer_fx[2 * l + 1] = Imag_aux_fx; // q_cldfb+ min_q_shift move32(); - p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] = L_sub( re1, re2 ); + p_proto_buffer_fx[2 * ( num_freq_bands + l )] = L_sub( re1, re2 ); // q_cldfb+ min_q_shift move32(); - p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] = L_sub( im1, im2 ); + p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] = L_sub( im1, im2 ); // q_cldfb+ min_q_shift move32(); - temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )], p_proto_buffer_fx[i_mult( 2, add( num_freq_bands, l ) )] ), p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )], p_proto_buffer_fx[add( i_mult( 2, add( num_freq_bands, l ) ), 1 )] ); + temp = Madd_32_32( Mpy_32_32( p_proto_buffer_fx[2 * ( num_freq_bands + l )], p_proto_buffer_fx[2 * ( num_freq_bands + l )] ), p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1], p_proto_buffer_fx[2 * ( num_freq_bands + l ) + 1] ); // q_temp IF( LT_16( q_temp, *q_proto_power_smooth ) ) { - proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[add( l, num_freq_bands )], sub( *q_proto_power_smooth, q_temp ) ), temp ); + proto_power_smooth_fx[l + num_freq_bands] = L_add( L_shr( proto_power_smooth_fx[l + num_freq_bands], sub( *q_proto_power_smooth, q_temp ) ), temp ); // q_temp move32(); } ELSE { - proto_power_smooth_fx[add( l, num_freq_bands )] = L_add( proto_power_smooth_fx[add( l, num_freq_bands )], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); + proto_power_smooth_fx[l + num_freq_bands] = L_add( proto_power_smooth_fx[l + num_freq_bands], L_shr( temp, sub( q_temp, *q_proto_power_smooth ) ) ); // q_proto_power_smooth move32(); } - proto_frame_f_fx[2 * l] = Real_aux_fx; + proto_frame_f_fx[2 * l] = Real_aux_fx; // q_cldfb+ min_q_shift move32(); - proto_frame_f_fx[add( 2 * l, 1 )] = Imag_aux_fx; + proto_frame_f_fx[2 * l + 1] = Imag_aux_fx; // q_cldfb+ min_q_shift move32(); - proto_frame_f_fx[add( i_mult( 2, num_freq_bands ), i_mult( 2, l ) )] = re1; + proto_frame_f_fx[2 * num_freq_bands + 2 * l] = re1; // q_cldfb+ min_q_shift move32(); - proto_frame_f_fx[add( add( i_mult( 2, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im1; + proto_frame_f_fx[2 * num_freq_bands + 2 * l + 1] = im1; // q_cldfb+ min_q_shift move32(); - proto_frame_f_fx[add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) )] = re2; + proto_frame_f_fx[4 * num_freq_bands + 2 * l] = re2; // q_cldfb+ min_q_shift move32(); - proto_frame_f_fx[add( add( i_mult( 4, num_freq_bands ), i_mult( 2, l ) ), 1 )] = im2; + proto_frame_f_fx[4 * num_freq_bands + 2 * l + 1] = im2; // q_cldfb+ min_q_shift move32(); } } @@ -3630,7 +3636,7 @@ void protoSignalComputation2_fx( } FOR( l = 0; l < num_freq_bands; l++ ) { - reference_power_fx[l] = W_extract_h( W_shl( reference_power_64fx[l], norm_shift ) ); + reference_power_fx[l] = W_extract_h( W_shl( reference_power_64fx[l], norm_shift ) ); // q_reference_power_64fx+norm_shift-32 move32(); } *q_reference_power = sub( add( q_reference_power_64fx, norm_shift ), 32 ); @@ -3976,20 +3982,20 @@ void protoSignalComputation2( #ifdef IVAS_FLOAT_FIXED void protoSignalComputation4_fx( - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 *proto_frame_f_fx, + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 *proto_frame_f_fx, /*proto_frame_f_q*/ Word16 *proto_frame_f_q, - Word32 *proto_direct_buffer_f_fx, + Word32 *proto_direct_buffer_f_fx, /*proto_direct_buffer_f_q*/ Word16 *proto_direct_buffer_f_q, - Word32 *reference_power_fx, + Word32 *reference_power_fx, /*reference_power_q*/ Word16 *reference_power_q, - Word32 *proto_power_smooth_fx, + Word32 *proto_power_smooth_fx, /*proto_power_smooth_q*/ Word16 *proto_power_smooth_q, const Word16 slot_index, const Word16 num_outputs_diff, const Word16 num_freq_bands, - const Word32 *mtx_hoa_decoder, + const Word32 *mtx_hoa_decoder, /*q29*/ const Word16 nchan_transport, const Word16 *sba_map_tc_ind, Word16 q_cldfb ) @@ -4026,12 +4032,12 @@ void protoSignalComputation4_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - re = L_shl( RealBuffer_fx[k][0][l], min_q_shift ); - im = L_shl( ImagBuffer_fx[k][0][l], min_q_shift ); + re = L_shl( RealBuffer_fx[k][0][l], min_q_shift ); // q_cldfb+min_q_shift + im = L_shl( ImagBuffer_fx[k][0][l], min_q_shift ); // q_cldfb+min_q_shift - sq_tmp_fx = Madd_32_32( Mpy_32_32( re, re ), im, im ); + sq_tmp_fx = Madd_32_32( Mpy_32_32( re, re ), im, im ); // 2*(q_cldfb+min_q_shift)-31 - reference_power_fx[l] = Madd_32_16( reference_power_fx[l], sq_tmp_fx, 16384 ); // 16384 = 0.5 in Q15 + reference_power_fx[l] = Madd_32_16( reference_power_fx[l], sq_tmp_fx, 16384 /*0.5 in Q15*/ ); // 2*(q_cldfb+min_q_shift)-31 move32(); } } @@ -4049,18 +4055,18 @@ void protoSignalComputation4_fx( idx = add( i_mult( i_mult( 2, l ), num_freq_bands ), i_mult( 2, k ) ); proto_frame_f_fx[idx] = 0; move32(); - proto_frame_f_fx[add( idx, 1 )] = 0; + proto_frame_f_fx[idx + 1] = 0; move32(); FOR( n = 0; n < nchan_transport; n++ ) { idx2 = add( i_mult( l, 16 ), sba_map_tc_ind[n] ); - re = L_shl( RealBuffer_fx[n][0][k], min_q_shift ); - im = L_shl( ImagBuffer_fx[n][0][k], min_q_shift ); + re = L_shl( RealBuffer_fx[n][0][k], min_q_shift ); // q_cldfb+min_q_shift + im = L_shl( ImagBuffer_fx[n][0][k], min_q_shift ); // q_cldfb+min_q_shift - proto_frame_f_fx[idx] = Madd_32_32( proto_frame_f_fx[idx], re, mtx_hoa_decoder[idx2] ); + proto_frame_f_fx[idx] = Madd_32_32( proto_frame_f_fx[idx], re, mtx_hoa_decoder[idx2] ); // q_cldfb+min_q_shift+29-31 => q_cldfb+min_q_shift-2 move32(); - proto_frame_f_fx[add( idx, 1 )] = Madd_32_32( proto_frame_f_fx[add( idx, 1 )], im, mtx_hoa_decoder[idx2] ); + proto_frame_f_fx[idx + 1] = Madd_32_32( proto_frame_f_fx[idx + 1], im, mtx_hoa_decoder[idx2] ); // q_cldfb+min_q_shift-2 move32(); } } @@ -4072,7 +4078,7 @@ void protoSignalComputation4_fx( min_q_shift = getScaleFactor32( proto_power_smooth_fx, i_mult( num_outputs_diff, num_freq_bands ) ); min_q_shift = sub( min_q_shift, find_guarded_bits_fx( 2 ) ); - Scale_sig32( proto_power_smooth_fx, i_mult( num_outputs_diff, num_freq_bands ), min_q_shift ); + Scale_sig32( proto_power_smooth_fx, i_mult( num_outputs_diff, num_freq_bands ), min_q_shift ); // proto_power_smooth_q+min_q_shift *proto_power_smooth_q = add( *proto_power_smooth_q, min_q_shift ); move16(); proto_power_smooth_fx_q = *proto_power_smooth_q; @@ -4082,40 +4088,40 @@ void protoSignalComputation4_fx( min_q_shift = getScaleFactor32( proto_frame_f_fx, i_mult( 2, i_mult( num_outputs_diff, num_freq_bands ) ) ); min_q_shift = sub( min_q_shift, find_guarded_bits_fx( 2 ) ); - Scale_sig32( proto_frame_f_fx, i_mult( 2, i_mult( num_outputs_diff, num_freq_bands ) ), min_q_shift ); + Scale_sig32( proto_frame_f_fx, i_mult( 2, i_mult( num_outputs_diff, num_freq_bands ) ), min_q_shift ); // proto_frame_f_q+min_q_shift *proto_frame_f_q = add( *proto_frame_f_q, min_q_shift ); move16(); offset = i_mult( i_mult( slot_index, 2 ), i_mult( num_freq_bands, num_outputs_diff ) ); - p_proto_buffer_fx = proto_direct_buffer_f_fx + offset; + p_proto_buffer_fx = proto_direct_buffer_f_fx + offset; // proto_direct_buffer_f_q FOR( k = 0; k < num_outputs_diff; k++ ) { FOR( l = 0; l < num_freq_bands; l++ ) { - idx = i_mult( 2, add( i_mult( k, num_freq_bands ), l ) ); + idx = 2 * ( k * num_freq_bands + l ); - sq_tmp_fx = Madd_32_32( Mpy_32_32( proto_frame_f_fx[idx], proto_frame_f_fx[idx] ), proto_frame_f_fx[add( idx, 1 )], proto_frame_f_fx[add( idx, 1 )] ); + sq_tmp_fx = Madd_32_32( Mpy_32_32( proto_frame_f_fx[idx], proto_frame_f_fx[idx] ), proto_frame_f_fx[idx + 1], proto_frame_f_fx[idx + 1] ); // 2*(proto_frame_f_q)-31 sq_tmp_q = sub( add( *proto_frame_f_q, *proto_frame_f_q ), 31 ); IF( LT_16( *proto_power_smooth_q, sq_tmp_q ) ) { - proto_power_smooth_fx[add( l, i_mult( k, num_freq_bands ) )] = L_add( proto_power_smooth_fx[add( l, i_mult( k, num_freq_bands ) )], L_shr( sq_tmp_fx, sub( sq_tmp_q, *proto_power_smooth_q ) ) ); + proto_power_smooth_fx[l + ( k * num_freq_bands )] = L_add( proto_power_smooth_fx[l + ( k * num_freq_bands )], L_shr( sq_tmp_fx, sub( sq_tmp_q, *proto_power_smooth_q ) ) ); // proto_power_smooth_q move32(); proto_power_smooth_fx_q = *proto_power_smooth_q; move16(); } ELSE { - proto_power_smooth_fx[add( l, i_mult( k, num_freq_bands ) )] = L_add( L_shr( proto_power_smooth_fx[add( l, i_mult( k, num_freq_bands ) )], sub( *proto_power_smooth_q, sq_tmp_q ) ), sq_tmp_fx ); + proto_power_smooth_fx[l + ( k * num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[l + ( k * num_freq_bands )], sub( *proto_power_smooth_q, sq_tmp_q ) ), sq_tmp_fx ); // sq_tmp_q move32(); proto_power_smooth_fx_q = sq_tmp_q; move16(); } - p_proto_buffer_fx[idx] = proto_frame_f_fx[idx]; + p_proto_buffer_fx[idx] = proto_frame_f_fx[idx]; // proto_frame_f_q move32(); - p_proto_buffer_fx[add( idx, 1 )] = proto_frame_f_fx[add( idx, 1 )]; + p_proto_buffer_fx[idx + 1] = proto_frame_f_fx[idx + 1]; // proto_frame_f_q move32(); } } @@ -4213,7 +4219,7 @@ void ivas_dirac_dec_compute_diffuse_proto_fx( Word32 *p_proto_diff_fx, *p_power_smooth_fx; Word32 *p_hoa_enc_fx; - proto_frame_dec_f_fx = hDirACRend->proto_frame_dec_f_fx; + proto_frame_dec_f_fx = hDirACRend->proto_frame_dec_f_fx; // hDirACRend->proto_frame_dec_f_q h_dirac_output_synthesis_params = &( hDirACRend->h_output_synthesis_psd_params ); h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state ); @@ -4225,17 +4231,18 @@ void ivas_dirac_dec_compute_diffuse_proto_fx( return; } - p_diff_buffer_fx = h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx + imult1616( shl( imult1616( slot_idx, num_freq_bands_diff ), 1 ), hDirACRend->hOutSetup.nchan_out_woLFE ); + p_diff_buffer_fx = h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx + ( ( ( slot_idx * num_freq_bands_diff ) << 1 ) * hDirACRend->hOutSetup.nchan_out_woLFE ); // proto_diffuse_buffer_f_q p_diff_buffer_1_fx = p_diff_buffer_fx + 1; - p_power_smooth_fx = h_dirac_output_synthesis_state->proto_power_diff_smooth_fx; + p_power_smooth_fx = h_dirac_output_synthesis_state->proto_power_diff_smooth_fx; // h_dirac_output_synthesis_state->proto_power_diff_smooth_q - Word16 diffuse_start = slot_idx * 2 * num_freq_bands_diff * hDirACRend->hOutSetup.nchan_out_woLFE; + Word16 diffuse_start = imult1616( slot_idx, shl( imult1616( num_freq_bands_diff, hDirACRend->hOutSetup.nchan_out_woLFE ), 1 ) ); Word16 diff_e, smooth_e, proto_e, max_e; Word32 diff_square, diff_square_1, diff_square_sum; Word16 diff_square_e; Word16 old_diff_e; diff_e = sub( 31, h_dirac_output_synthesis_state->proto_diffuse_buffer_f_q ); old_diff_e = diff_e; + move16(); smooth_e = sub( 31, h_dirac_output_synthesis_state->proto_power_diff_smooth_q ); proto_e = sub( 31, hDirACRend->proto_frame_dec_f_q ); @@ -4243,22 +4250,22 @@ void ivas_dirac_dec_compute_diffuse_proto_fx( { diff_square_e = add( shl( proto_e, 1 ), 1 ); max_e = add( s_max( diff_square_e, smooth_e ), 1 ); - Scale_sig32( p_power_smooth_fx, h_dirac_output_synthesis_state->proto_power_diff_smooth_len, sub( smooth_e, max_e ) ); + Scale_sig32( p_power_smooth_fx, h_dirac_output_synthesis_state->proto_power_diff_smooth_len, sub( smooth_e, max_e ) ); // 31-max_e FOR( k = 0; k < hDirACRend->hOutSetup.nchan_out_woLFE; k++ ) { - p_proto_diff_fx = proto_frame_dec_f_fx + shl( imult1616( k, num_freq_bands ), 1 ); + p_proto_diff_fx = proto_frame_dec_f_fx + shl( imult1616( k, num_freq_bands ), 1 ); // hDirACRend->proto_frame_dec_f_q FOR( l = 0; l < num_freq_bands_diff; l++ ) { - *p_diff_buffer_fx = *( p_proto_diff_fx++ ); + *p_diff_buffer_fx = *( p_proto_diff_fx++ ); // hDirACRend->proto_frame_dec_f_q move32(); - *p_diff_buffer_1_fx = *( p_proto_diff_fx++ ); + *p_diff_buffer_1_fx = *( p_proto_diff_fx++ ); // hDirACRend->proto_frame_dec_f_q move32(); diff_square = L_shr( Mpy_32_32( *p_diff_buffer_fx, *p_diff_buffer_fx ), 1 ); // 2 * proto_e + 1 diff_square_1 = L_shr( Mpy_32_32( *p_diff_buffer_1_fx, *p_diff_buffer_1_fx ), 1 ); // 2 * proto_e + 1 - diff_square_sum = L_add( diff_square, diff_square_1 ); - diff_square_sum = L_shr( diff_square_sum, sub( max_e, diff_square_e ) ); - *p_power_smooth_fx = L_add( *p_power_smooth_fx, diff_square_sum ); + diff_square_sum = L_add( diff_square, diff_square_1 ); // Q(31- diff_square_e) + diff_square_sum = L_shr( diff_square_sum, sub( max_e, diff_square_e ) ); // Q(31-max_e) + *p_power_smooth_fx = L_add( *p_power_smooth_fx, diff_square_sum ); // Q(31-max_e) move32(); p_power_smooth_fx++; @@ -4275,13 +4282,13 @@ void ivas_dirac_dec_compute_diffuse_proto_fx( Word16 gb = find_guarded_bits_fx( hDirACRend->num_outputs_diff ); diff_square_e = add( shl( add( proto_e, gb ), 1 ), 1 ); max_e = add( s_max( diff_square_e, smooth_e ), 1 ); - Scale_sig32( p_power_smooth_fx, h_dirac_output_synthesis_state->proto_power_diff_smooth_len, sub( smooth_e, max_e ) ); + Scale_sig32( p_power_smooth_fx, h_dirac_output_synthesis_state->proto_power_diff_smooth_len, sub( smooth_e, max_e ) ); // 31-max_e FOR( k = 0; k < hDirACRend->hOutSetup.nchan_out_woLFE; k++ ) { FOR( l = 0; l < num_freq_bands_diff; l++ ) { - p_hoa_enc_fx = hDirACRend->hoa_encoder_fx + k; - p_proto_diff_fx = proto_frame_dec_f_fx + shl( l, 1 ); + p_hoa_enc_fx = hDirACRend->hoa_encoder_fx + k; // q31 + p_proto_diff_fx = proto_frame_dec_f_fx + shl( l, 1 ); // hDirACRend->proto_frame_dec_f_q *p_diff_buffer_fx = 0; move32(); @@ -4291,19 +4298,19 @@ void ivas_dirac_dec_compute_diffuse_proto_fx( /*LS to HOA*/ FOR( m = 0; m < hDirACRend->num_outputs_diff; m++ ) { - *p_diff_buffer_fx = L_add( *p_diff_buffer_fx, L_shr( Mpy_32_32( *p_hoa_enc_fx, *p_proto_diff_fx ), gb ) ); + *p_diff_buffer_fx = L_add( *p_diff_buffer_fx, L_shr( Mpy_32_32( *p_hoa_enc_fx, *p_proto_diff_fx ), gb ) ); // hDirACRend->proto_frame_dec_f_q-gb move32(); - *p_diff_buffer_1_fx = L_add( *p_diff_buffer_1_fx, L_shr( Mpy_32_32( *p_hoa_enc_fx, *( p_proto_diff_fx + 1 ) ), gb ) ); + *p_diff_buffer_1_fx = L_add( *p_diff_buffer_1_fx, L_shr( Mpy_32_32( *p_hoa_enc_fx, *( p_proto_diff_fx + 1 ) ), gb ) ); // hDirACRend->proto_frame_dec_f_q-gb move32(); p_hoa_enc_fx += hDirACRend->hOutSetup.nchan_out_woLFE; p_proto_diff_fx += shl( num_freq_bands, 1 ); } - diff_square = L_shr( Mpy_32_32( *p_diff_buffer_fx, *p_diff_buffer_fx ), 1 ); // 2*(2 + proto_e + gb) + 1 - diff_square_1 = L_shr( Mpy_32_32( *p_diff_buffer_1_fx, *p_diff_buffer_1_fx ), 1 ); // 2*(2 + proto_e + gb) + 1 - diff_square_sum = L_add( diff_square, diff_square_1 ); - diff_square_sum = L_shr( diff_square_sum, sub( max_e, diff_square_e ) ); - *p_power_smooth_fx = L_add( *p_power_smooth_fx, diff_square_sum ); + diff_square = L_shr( Mpy_32_32( *p_diff_buffer_fx, *p_diff_buffer_fx ), 1 ); // 2*( proto_e + gb) + 1 + diff_square_1 = L_shr( Mpy_32_32( *p_diff_buffer_1_fx, *p_diff_buffer_1_fx ), 1 ); // 2*( proto_e + gb) + 1 + diff_square_sum = L_add( diff_square, diff_square_1 ); // 2*( proto_e + gb) + 1 + diff_square_sum = L_shr( diff_square_sum, sub( max_e, diff_square_e ) ); // 31-max_e + *p_power_smooth_fx = L_add( *p_power_smooth_fx, diff_square_sum ); // 31-max_e move32(); p_power_smooth_fx++; @@ -4318,10 +4325,10 @@ void ivas_dirac_dec_compute_diffuse_proto_fx( move16(); Word16 new_diff_e = s_max( diff_e, old_diff_e ); - Scale_sig32( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx, diffuse_start, sub( old_diff_e, new_diff_e ) ); + Scale_sig32( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx, diffuse_start, sub( old_diff_e, new_diff_e ) ); // 31-new_diff_e #ifdef MSAN_FIX Scale_sig32( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx + diffuse_start, - i_mult( shl( num_freq_bands_diff, 1 ), hDirACRend->hOutSetup.nchan_out_woLFE ), sub( diff_e, new_diff_e ) ); + i_mult( shl( num_freq_bands_diff, 1 ), hDirACRend->hOutSetup.nchan_out_woLFE ), sub( diff_e, new_diff_e ) ); // 31-new_diff_e #else Scale_sig32( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx + diffuse_start, sub( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_len, diffuse_start ), sub( diff_e, new_diff_e ) ); @@ -4417,9 +4424,9 @@ void ivas_dirac_dec_compute_diffuse_proto( #ifdef IVAS_FLOAT_FIXED void computeDirectionAngles_fx( - Word32 *intensity_real_x_fx, - Word32 *intensity_real_y_fx, - Word32 *intensity_real_z_fx, + Word32 *intensity_real_x_fx, /*q_intensity_real*/ + Word32 *intensity_real_y_fx, /*q_intensity_real*/ + Word32 *intensity_real_z_fx, /*q_intensity_real*/ Word16 q_intensity_real, const Word16 num_frequency_bands, Word16 *azimuth, @@ -4441,28 +4448,28 @@ void computeDirectionAngles_fx( exp1 = norm_l( intensity_real_x_fx[k] ); exp2 = norm_l( intensity_real_y_fx[k] ); exp3 = norm_l( intensity_real_z_fx[k] ); - x_re = L_shl( intensity_real_x_fx[k], exp1 ); - y_re = L_shl( intensity_real_y_fx[k], exp2 ); - z_re = L_shl( intensity_real_z_fx[k], exp3 ); + x_re = L_shl( intensity_real_x_fx[k], exp1 ); /*q_intensity_real+exp1*/ + y_re = L_shl( intensity_real_y_fx[k], exp2 ); /*q_intensity_real+exp2*/ + z_re = L_shl( intensity_real_z_fx[k], exp3 ); /*q_intensity_real+exp3*/ - tmp1 = Mpy_32_32( x_re, x_re ); + tmp1 = Mpy_32_32( x_re, x_re ); /*2*(q_intensity_real+exp1)-31*/ q_tmp1 = sub( add( add( q_intensity_real, exp1 ), add( q_intensity_real, exp1 ) ), 31 ); - tmp2 = Mpy_32_32( y_re, y_re ); + tmp2 = Mpy_32_32( y_re, y_re ); /*2*(q_intensity_real+exp2)-31*/ q_tmp2 = sub( add( add( q_intensity_real, exp2 ), add( q_intensity_real, exp2 ) ), 31 ); - temp = BASOP_Util_Add_Mant32Exp( tmp1, sub( 31, q_tmp1 ), tmp2, sub( 31, q_tmp2 ), &exp ); + temp = BASOP_Util_Add_Mant32Exp( tmp1, sub( 31, q_tmp1 ), tmp2, sub( 31, q_tmp2 ), &exp ); // 31-exp - tmp2 = Mpy_32_32( z_re, z_re ); + tmp2 = Mpy_32_32( z_re, z_re ); /*2*(q_intensity_real+exp3)-31*/ q_tmp2 = sub( add( add( q_intensity_real, exp3 ), add( q_intensity_real, exp3 ) ), 31 ); - intensityNorm = BASOP_Util_Add_Mant32Exp( temp, exp, tmp2, sub( 31, q_tmp2 ), &exp ); + intensityNorm = BASOP_Util_Add_Mant32Exp( temp, exp, tmp2, sub( 31, q_tmp2 ), &exp ); // 31-exp q_intensityNorm = sub( 31, exp ); IF( LE_32( intensityNorm, EPSILON_FX ) ) { - intensityNorm = ONE_IN_Q30; + intensityNorm = ONE_IN_Q30; // q30 move32(); - x = ONE_IN_Q30; + x = ONE_IN_Q30; // q30 move32(); q_x = Q30; move16(); @@ -4477,31 +4484,31 @@ void computeDirectionAngles_fx( } ELSE { - temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, intensityNorm, &exp ); + temp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, intensityNorm, &exp ); // Q=31-(exp-(30-q_intensityNorm)) exp = sub( exp, sub( Q30, q_intensityNorm ) ); - temp = Sqrt32( temp, &exp ); + temp = Sqrt32( temp, &exp ); // Q=31-exp q_temp = sub( 31, exp ); - x = Mpy_32_32( x_re, temp ); + x = Mpy_32_32( x_re, temp ); /*Q=q_intensity_real+exp1+q_temp-31*/ q_x = sub( add( add( q_intensity_real, exp1 ), q_temp ), 31 ); - y = Mpy_32_32( y_re, temp ); + y = Mpy_32_32( y_re, temp ); /*Q=q_intensity_real+exp2+q_temp-31*/ q_y = sub( add( add( q_intensity_real, exp2 ), q_temp ), 31 ); - z = Mpy_32_32( z_re, temp ); + z = Mpy_32_32( z_re, temp ); /*Q=q_intensity_real+exp3+q_temp-31*/ q_z = sub( add( add( q_intensity_real, exp3 ), q_temp ), 31 ); } - tmp1 = Mpy_32_32( x, x ); + tmp1 = Mpy_32_32( x, x ); /*Q=2*q_x-31*/ q_tmp1 = sub( add( q_x, q_x ), 31 ); - tmp2 = Mpy_32_32( y, y ); + tmp2 = Mpy_32_32( y, y ); /*Q=2*q_y-31*/ q_tmp2 = sub( add( q_y, q_y ), 31 ); - temp = BASOP_Util_Add_Mant32Exp( tmp1, sub( 31, q_tmp1 ), tmp2, sub( 31, q_tmp2 ), &exp ); - radius = Sqrt32( temp, &exp ); + temp = BASOP_Util_Add_Mant32Exp( tmp1, sub( 31, q_tmp1 ), tmp2, sub( 31, q_tmp2 ), &exp ); // Q=31-exp + radius = Sqrt32( temp, &exp ); // Q=31-exp - res = BASOP_util_atan2( y, x, sub( sub( 31, q_y ), sub( 31, q_x ) ) ); /* Q13 */ - res = add( s_max( -23040, s_min( 23040, mult( res, _180_OVER_PI_Q9 ) ) ), 64 ); /* Q7 */ - azimuth[k] = shr( abs_s( res ), Q7 ); /* Q0 */ + res = BASOP_util_atan2( y, x, sub( sub( 31, q_y ), sub( 31, q_x ) ) ); /* Q13 */ + res = add( s_max( -23040 /*-180 q7*/, s_min( 23040 /*180 q7*/, mult( res, _180_OVER_PI_Q9 /*180/pi q9*/ ) ) ), 64 /*0.5 q7*/ ); /* Q7 */ + azimuth[k] = shr( abs_s( res ), Q7 ); /* Q0 */ move16(); IF( res < 0 ) { @@ -4509,9 +4516,9 @@ void computeDirectionAngles_fx( move16(); } - res = BASOP_util_atan2( z, radius, sub( sub( 31, q_z ), exp ) ); /* Q13 */ - res = add( s_max( -11520, s_min( 23040, mult( res, _180_OVER_PI_Q9 ) ) ), 64 ); /* Q7 */ - elevation[k] = shr( abs_s( res ), Q7 ); /* Q0 */ + res = BASOP_util_atan2( z, radius, sub( sub( 31, q_z ), exp ) ); /* Q13 */ + res = add( s_max( -11520 /*-90 q7*/, s_min( 23040 /*180 q7*/, mult( res, _180_OVER_PI_Q9 /*180/pi q9*/ ) ) ), 64 /*0.5 q7*/ ); /* Q7 */ + elevation[k] = shr( abs_s( res ), Q7 ); /* Q0 */ move16(); IF( res < 0 ) { @@ -4719,28 +4726,28 @@ void ivas_masa_stereotype_detection_fx( Word32 lr_total_hi_temp_fx; Word32 temp; - lr_total_bb_ratio_db_fx = stereo_type_detect->lr_total_bb_ratio_db_fx; + lr_total_bb_ratio_db_fx = stereo_type_detect->lr_total_bb_ratio_db_fx; // q21 move32(); - lr_total_hi_ratio_db_fx = stereo_type_detect->lr_total_hi_ratio_db_fx; + lr_total_hi_ratio_db_fx = stereo_type_detect->lr_total_hi_ratio_db_fx; // q21 move32(); - min_sum_total_ratio_db_fx = stereo_type_detect->min_sum_total_ratio_db_fx; + min_sum_total_ratio_db_fx = stereo_type_detect->min_sum_total_ratio_db_fx; // q21 move32(); - subtract_target_ratio_db_fx = stereo_type_detect->subtract_target_ratio_db_fx; + subtract_target_ratio_db_fx = stereo_type_detect->subtract_target_ratio_db_fx; // q21 move32(); /* Determine if the determined features match the spaced mic type */ change_to_spaced_selection = 0; move16(); - IF( LT_32( subtract_target_ratio_db_fx, -THREE_Q21 ) ) + IF( LT_32( subtract_target_ratio_db_fx, -THREE_Q21 /*-3 q21*/ ) ) { /* subtract_temp = ( -subtract_target_ratio_db - 3.0f ) / 3.0f; */ - temp = L_sub( L_shr( -subtract_target_ratio_db_fx, 1 ), L_shr( THREE_Q21, 1 ) ); - subtract_temp_fx = Mpy_32_32( temp, 715827883 /* 1 / 3.0f in Q31 */ ); - subtract_temp_fx = L_shl( subtract_temp_fx, 1 ); /* Q21 */ + temp = L_sub( L_shr( -subtract_target_ratio_db_fx, 1 ), L_shr( THREE_Q21, 1 ) ); // q20 + subtract_temp_fx = Mpy_32_32( temp, 715827883 /* 1 / 3.0f in Q31 */ ); // q20 + subtract_temp_fx = L_shl( subtract_temp_fx, 1 ); /* Q21 */ /* min_sum_temp = max( -min_sum_total_ratio_db / 6.0f, 0.0f ); */ min_sum_temp_fx = Mpy_32_32_r( -min_sum_total_ratio_db_fx, 357913941 /* 1 / 6.0f in Q31 */ ); /* Q21 */ - min_sum_temp_fx = L_max( min_sum_temp_fx, 0 ); + min_sum_temp_fx = L_max( min_sum_temp_fx, 0 ); /*q21*/ /* lr_total_bb_temp = lr_total_bb_ratio_db / 6.0f; */ lr_total_bb_temp_fx = Mpy_32_32_r( lr_total_bb_ratio_db_fx, 357913941 /* 1 / 6.0f in Q31 */ ); /* Q21 */ @@ -4770,7 +4777,7 @@ void ivas_masa_stereotype_detection_fx( change_to_downmix_fx = L_add( L_add( subtract_temp_fx, min_sum_temp_fx ), lr_total_bb_temp_fx ); /* Q21 */ - IF( GE_32( change_to_downmix_fx, ONE_IN_Q21 ) ) + IF( GE_32( change_to_downmix_fx, ONE_IN_Q21 /*1 q21*/ ) ) { change_to_downmix_selection = 1; move16(); @@ -4791,7 +4798,7 @@ void ivas_masa_stereotype_detection_fx( change_to_downmix2_fx = L_add( L_add( subtract_temp_fx, min_sum_temp_fx ), lr_total_hi_temp_fx ); // Q21 - IF( GE_32( change_to_downmix2_fx, ONE_IN_Q21 ) ) + IF( GE_32( change_to_downmix2_fx, ONE_IN_Q21 /*1 q21*/ ) ) { change_to_downmix_selection = 1; move16(); @@ -4932,13 +4939,13 @@ void ivas_masa_stereotype_detection( #ifdef IVAS_FLOAT_FIXED void computeIntensityVector_dec_fx( - Word32 Cldfb_RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 Cldfb_ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ Word16 q_cldfb, const Word16 num_frequency_bands, - Word32 *intensity_real_x_fx, - Word32 *intensity_real_y_fx, - Word32 *intensity_real_z_fx, + Word32 *intensity_real_x_fx, /*q_intensity_real*/ + Word32 *intensity_real_y_fx, /*q_intensity_real*/ + Word32 *intensity_real_z_fx, /*q_intensity_real*/ Word16 *q_intensity_real ) { /* @@ -4961,24 +4968,24 @@ void computeIntensityVector_dec_fx( FOR( i = 0; i < num_frequency_bands; ++i ) { - re1 = L_shl( Cldfb_RealBuffer_fx[0][0][i], min_q_shift ); - im1 = L_shl( Cldfb_ImagBuffer_fx[0][0][i], min_q_shift ); - re2 = L_shl( Cldfb_RealBuffer_fx[3][0][i], min_q_shift ); - im2 = L_shl( Cldfb_ImagBuffer_fx[3][0][i], min_q_shift ); + re1 = L_shl( Cldfb_RealBuffer_fx[0][0][i], min_q_shift ); /*q_cldfb+min_q_shift*/ + im1 = L_shl( Cldfb_ImagBuffer_fx[0][0][i], min_q_shift ); /*q_cldfb+min_q_shift*/ + re2 = L_shl( Cldfb_RealBuffer_fx[3][0][i], min_q_shift ); /*q_cldfb+min_q_shift*/ + im2 = L_shl( Cldfb_ImagBuffer_fx[3][0][i], min_q_shift ); /*q_cldfb+min_q_shift*/ - intensity_real_x_fx[i] = Madd_32_32( Mpy_32_32( re2, re1 ), im2, im1 ); + intensity_real_x_fx[i] = Madd_32_32( Mpy_32_32( re2, re1 ), im2, im1 ); /*2*(q_cldfb+min_q_shift)-31*/ move32(); - re2 = L_shl( Cldfb_RealBuffer_fx[1][0][i], min_q_shift ); - im2 = L_shl( Cldfb_ImagBuffer_fx[1][0][i], min_q_shift ); + re2 = L_shl( Cldfb_RealBuffer_fx[1][0][i], min_q_shift ); /*q_cldfb+min_q_shift*/ + im2 = L_shl( Cldfb_ImagBuffer_fx[1][0][i], min_q_shift ); /*q_cldfb+min_q_shift*/ - intensity_real_y_fx[i] = Madd_32_32( Mpy_32_32( re2, re1 ), im2, im1 ); + intensity_real_y_fx[i] = Madd_32_32( Mpy_32_32( re2, re1 ), im2, im1 ); /*2*(q_cldfb+min_q_shift)-31*/ move32(); - re2 = L_shl( Cldfb_RealBuffer_fx[2][0][i], min_q_shift ); - im2 = L_shl( Cldfb_ImagBuffer_fx[2][0][i], min_q_shift ); + re2 = L_shl( Cldfb_RealBuffer_fx[2][0][i], min_q_shift ); /*q_cldfb+min_q_shift*/ + im2 = L_shl( Cldfb_ImagBuffer_fx[2][0][i], min_q_shift ); /*q_cldfb+min_q_shift*/ - intensity_real_z_fx[i] = Madd_32_32( Mpy_32_32( re2, re1 ), im2, im1 ); + intensity_real_z_fx[i] = Madd_32_32( Mpy_32_32( re2, re1 ), im2, im1 ); /*2*(q_cldfb+min_q_shift)-31*/ move32(); } @@ -5026,10 +5033,10 @@ void computeIntensityVector_dec( #ifdef IVAS_FLOAT_FIXED void ivas_lfe_synth_with_cldfb_fx( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 RealBufferLfe_fx[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 ImagBufferLfe_fx[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 RealBufferLfe_fx[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 ImagBufferLfe_fx[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ const Word16 slot_index, const Word16 subframe_index, const Word16 nchan_transport, @@ -5045,6 +5052,7 @@ void ivas_lfe_synth_with_cldfb_fx( Word16 transportGain_q_fx, lfeGain_q_fx; Word16 exp, min_q_shift; Word32 re, im; + move16(); // temp_q exp = Q31; move16(); @@ -5069,89 +5077,89 @@ void ivas_lfe_synth_with_cldfb_fx( } min_q_shift = sub( sub( min_q_shift, find_guarded_bits_fx( nchan_transport ) ), 1 ); - re = L_shl( RealBuffer_fx[0][0][0], min_q_shift ); - im = L_shl( ImagBuffer_fx[0][0][0], min_q_shift ); + re = L_shl( RealBuffer_fx[0][0][0], min_q_shift ); // q_cldfb+min_q_shift + im = L_shl( ImagBuffer_fx[0][0][0], min_q_shift ); // q_cldfb+min_q_shift - protoLfeReal_fx = re; + protoLfeReal_fx = re; // q_cldfb+min_q_shift move32(); - protoLfeImag_fx = im; + protoLfeImag_fx = im; // q_cldfb+min_q_shift move32(); - transportEne_fx = Madd_32_32( Mpy_32_32( re, re ), im, im ); + transportEne_fx = Madd_32_32( Mpy_32_32( re, re ), im, im ); // 2*(q_cldfb+min_q_shift)-31 FOR( i = 1; i < nchan_transport; i++ ) { - re = L_shl( RealBuffer_fx[i][0][0], min_q_shift ); - im = L_shl( ImagBuffer_fx[i][0][0], min_q_shift ); + re = L_shl( RealBuffer_fx[i][0][0], min_q_shift ); // q_cldfb+min_q_shift + im = L_shl( ImagBuffer_fx[i][0][0], min_q_shift ); // q_cldfb+min_q_shift - protoLfeReal_fx = L_add( protoLfeReal_fx, re ); - protoLfeImag_fx = L_add( protoLfeImag_fx, im ); - transportEne_fx = L_add( transportEne_fx, Madd_32_32( Mpy_32_32( re, re ), im, im ) ); + protoLfeReal_fx = L_add( protoLfeReal_fx, re ); // q_cldfb+min_q_shift + protoLfeImag_fx = L_add( protoLfeImag_fx, im ); // q_cldfb+min_q_shift + transportEne_fx = L_add( transportEne_fx, Madd_32_32( Mpy_32_32( re, re ), im, im ) ); // 2*(q_cldfb+min_q_shift)-31 } transportEne_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); - protoLfeEne_fx = Madd_32_32( Mpy_32_32( protoLfeReal_fx, protoLfeReal_fx ), protoLfeImag_fx, protoLfeImag_fx ); + protoLfeEne_fx = Madd_32_32( Mpy_32_32( protoLfeReal_fx, protoLfeReal_fx ), protoLfeImag_fx, protoLfeImag_fx ); // 2*(q_cldfb+min_q_shift)-31 protoLfeEne_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); - targetEneLfe_fx = Mpy_32_16_1( transportEne_fx, hMasaLfeSynth->lfeToTotalEnergyRatio_fx[subframe_index] ); + targetEneLfe_fx = Mpy_32_16_1( transportEne_fx, hMasaLfeSynth->lfeToTotalEnergyRatio_fx[subframe_index] ); // targetEneLfe_q+14-15 targetEneLfe_q = sub( add( transportEne_q, Q14 ), 15 ); - temp = s_max( sub( ONE_IN_Q14, hMasaLfeSynth->lfeToTotalEnergyRatio_fx[subframe_index] ), 164 ); // 164 = 0.01 in Q14 - targetEneTrans_fx = Mpy_32_16_1( transportEne_fx, temp ); + temp = s_max( sub( ONE_IN_Q14 /*1 q14*/, hMasaLfeSynth->lfeToTotalEnergyRatio_fx[subframe_index] ), 164 /*0.01 in Q14*/ ); // q14 + targetEneTrans_fx = Mpy_32_16_1( transportEne_fx, temp ); /*transportEne_q+Q14 -15*/ targetEneTrans_q = sub( add( transportEne_q, Q14 ), 15 ); - hMasaLfeSynth->transportEneSmooth_fx = Mpy_32_16_1( hMasaLfeSynth->transportEneSmooth_fx, MCMASA_LFE_SYNTH_ALPHA_Q15 ); + hMasaLfeSynth->transportEneSmooth_fx = Mpy_32_16_1( hMasaLfeSynth->transportEneSmooth_fx, MCMASA_LFE_SYNTH_ALPHA_Q15 ); // hMasaLfeSynth->transportEneSmooth_q+15-15 move32(); - hMasaLfeSynth->protoLfeEneSmooth_fx = Mpy_32_16_1( hMasaLfeSynth->protoLfeEneSmooth_fx, MCMASA_LFE_SYNTH_ALPHA_Q15 ); + hMasaLfeSynth->protoLfeEneSmooth_fx = Mpy_32_16_1( hMasaLfeSynth->protoLfeEneSmooth_fx, MCMASA_LFE_SYNTH_ALPHA_Q15 ); // hMasaLfeSynth->protoLfeEneSmooth_q+15-15 move32(); - hMasaLfeSynth->targetEneLfeSmooth_fx = Mpy_32_16_1( hMasaLfeSynth->targetEneLfeSmooth_fx, MCMASA_LFE_SYNTH_ALPHA_Q15 ); + hMasaLfeSynth->targetEneLfeSmooth_fx = Mpy_32_16_1( hMasaLfeSynth->targetEneLfeSmooth_fx, MCMASA_LFE_SYNTH_ALPHA_Q15 ); // hMasaLfeSynth->targetEneLfeSmooth_q+15-15 move32(); - hMasaLfeSynth->targetEneTransSmooth_fx = Mpy_32_16_1( hMasaLfeSynth->targetEneTransSmooth_fx, MCMASA_LFE_SYNTH_ALPHA_Q15 ); + hMasaLfeSynth->targetEneTransSmooth_fx = Mpy_32_16_1( hMasaLfeSynth->targetEneTransSmooth_fx, MCMASA_LFE_SYNTH_ALPHA_Q15 ); // hMasaLfeSynth->targetEneTransSmooth_q+15-15 move32(); - hMasaLfeSynth->transportEneSmooth_fx = BASOP_Util_Add_Mant32Exp( hMasaLfeSynth->transportEneSmooth_fx, sub( 31, hMasaLfeSynth->transportEneSmooth_q ), transportEne_fx, sub( 31, transportEne_q ), &temp_q ); + hMasaLfeSynth->transportEneSmooth_fx = BASOP_Util_Add_Mant32Exp( hMasaLfeSynth->transportEneSmooth_fx, sub( 31, hMasaLfeSynth->transportEneSmooth_q ), transportEne_fx, sub( 31, transportEne_q ), &temp_q ); // 31-temp_q move32(); hMasaLfeSynth->transportEneSmooth_q = sub( 31, temp_q ); move16(); - hMasaLfeSynth->protoLfeEneSmooth_fx = BASOP_Util_Add_Mant32Exp( hMasaLfeSynth->protoLfeEneSmooth_fx, sub( 31, hMasaLfeSynth->protoLfeEneSmooth_q ), protoLfeEne_fx, sub( 31, protoLfeEne_q ), &temp_q ); + hMasaLfeSynth->protoLfeEneSmooth_fx = BASOP_Util_Add_Mant32Exp( hMasaLfeSynth->protoLfeEneSmooth_fx, sub( 31, hMasaLfeSynth->protoLfeEneSmooth_q ), protoLfeEne_fx, sub( 31, protoLfeEne_q ), &temp_q ); // 31-temp_q move32(); hMasaLfeSynth->protoLfeEneSmooth_q = sub( 31, temp_q ); move16(); - hMasaLfeSynth->targetEneLfeSmooth_fx = BASOP_Util_Add_Mant32Exp( hMasaLfeSynth->targetEneLfeSmooth_fx, sub( 31, hMasaLfeSynth->targetEneLfeSmooth_q ), targetEneLfe_fx, sub( 31, targetEneLfe_q ), &temp_q ); + hMasaLfeSynth->targetEneLfeSmooth_fx = BASOP_Util_Add_Mant32Exp( hMasaLfeSynth->targetEneLfeSmooth_fx, sub( 31, hMasaLfeSynth->targetEneLfeSmooth_q ), targetEneLfe_fx, sub( 31, targetEneLfe_q ), &temp_q ); // 31-temp_q move32(); hMasaLfeSynth->targetEneLfeSmooth_q = sub( 31, temp_q ); move16(); - hMasaLfeSynth->targetEneTransSmooth_fx = BASOP_Util_Add_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( 31, hMasaLfeSynth->targetEneTransSmooth_q ), targetEneTrans_fx, sub( 31, targetEneTrans_q ), &temp_q ); + hMasaLfeSynth->targetEneTransSmooth_fx = BASOP_Util_Add_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( 31, hMasaLfeSynth->targetEneTransSmooth_q ), targetEneTrans_fx, sub( 31, targetEneTrans_q ), &temp_q ); // 31-temp_q move32(); hMasaLfeSynth->targetEneTransSmooth_q = sub( 31, temp_q ); move16(); - temp = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->protoLfeEneSmooth_fx ), &temp_q ); + temp = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->protoLfeEneSmooth_fx ), &temp_q ); // 15-(temp_q-(hMasaLfeSynth->targetEneLfeSmooth_q-hMasaLfeSynth->protoLfeEneSmooth_q)) temp_q = add( sub( hMasaLfeSynth->targetEneLfeSmooth_q, hMasaLfeSynth->protoLfeEneSmooth_q ), sub( Q15, temp_q ) ); exp = sub( Q15, temp_q ); - lfeGain_fx = Sqrt16( temp, &exp ); + lfeGain_fx = Sqrt16( temp, &exp ); // 15-exp lfeGain_q_fx = sub( Q15, exp ); - IF( GT_32( L_shr( lfeGain_fx, sub( lfeGain_q_fx, Q14 ) ), ONE_IN_Q14 ) ) + IF( GT_32( L_shr( lfeGain_fx, sub( lfeGain_q_fx, Q14 ) ), ONE_IN_Q14 /*1 q14*/ ) ) { - lfeGain_fx = ONE_IN_Q14; + lfeGain_fx = ONE_IN_Q14; /*1 q14*/ move16(); lfeGain_q_fx = Q14; move16(); } - temp = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &temp_q ); + temp = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &temp_q ); // Q=15-(temp_q-(hMasaLfeSynth->targetEneTransSmooth_q-hMasaLfeSynth->transportEneSmooth_q)) temp_q = add( sub( hMasaLfeSynth->targetEneTransSmooth_q, hMasaLfeSynth->transportEneSmooth_q ), sub( Q15, temp_q ) ); exp = sub( Q15, temp_q ); - transportGain_fx = Sqrt16( temp, &exp ); + transportGain_fx = Sqrt16( temp, &exp ); // q=15-exp transportGain_q_fx = sub( Q15, exp ); - IF( GT_32( L_shr( transportGain_fx, sub( transportGain_q_fx, Q14 ) ), ONE_IN_Q14 ) ) + IF( GT_32( L_shr( transportGain_fx, sub( transportGain_q_fx, Q14 ) ), ONE_IN_Q14 /*1 q14*/ ) ) { - transportGain_fx = ONE_IN_Q14; + transportGain_fx = ONE_IN_Q14; /*1 q14*/ move16(); transportGain_q_fx = Q14; move16(); @@ -5251,7 +5259,7 @@ void rotateAziEle_DirAC_fx( Word16 *ele, /* i/o: array of elevation values */ const Word16 band1, /* i : bands to work on (lower limit) */ const Word16 band2, /* i : bands to work on (upper bound) */ - const Word32 *p_Rmat_fx /* i : pointer to real-space rotation matrix */ + const Word32 *p_Rmat_fx /* i : pointer to real-space rotation matrix q30*/ ) { Word16 b; @@ -5260,8 +5268,8 @@ void rotateAziEle_DirAC_fx( Word16 exp, temp; Word32 *ptr_sin, *ptr_cos; - ptr_sin = &sine_table_Q31[180]; // sin[x] = sine_table_Q31[180 + x] - ptr_cos = cosine_table_Q31; + ptr_sin = &sine_table_Q31[180]; // sin[x] = sine_table_Q31[180 + x] q31 + ptr_cos = cosine_table_Q31; // q31 push_wmops( "rotateAziEle_DirAC" ); @@ -5271,7 +5279,7 @@ void rotateAziEle_DirAC_fx( IF( GT_16( abs_s( ele[b] ), 180 ) ) { // cos(180 + x) = -cos(x) - w_fx = L_negate( ptr_cos[sub( abs_s( ele[b] ), 180 )] ); // Q31 + w_fx = L_negate( ptr_cos[abs( ele[b] ) - 180] ); // Q31 } ELSE { @@ -5282,11 +5290,11 @@ void rotateAziEle_DirAC_fx( IF( GT_16( abs_s( azi[b] ), 180 ) ) { // cos(180 + x) = -cos(x) - tmp = L_negate( ptr_cos[sub( abs_s( azi[b] ), 180 )] ); // Q31 + tmp = L_negate( ptr_cos[abs( azi[b] ) - 180] ); // Q31 } ELSE { - tmp = ptr_cos[abs_s( azi[b] )]; // Q31 + tmp = ptr_cos[abs( azi[b] )]; // Q31 move32(); } @@ -5296,13 +5304,13 @@ void rotateAziEle_DirAC_fx( IF( GT_16( azi[b], 180 ) ) { // sin(180 + x) = -sin(x) - tmp = L_negate( ptr_sin[sub( azi[b], 180 )] ); // Q31 + tmp = L_negate( ptr_sin[azi[b] - 180] ); // Q31 move32(); } ELSE IF( LT_16( azi[b], -180 ) ) { // sin(-(180 + x)) = sin(180 + x) = sinx - tmp = ptr_sin[sub( abs_s( azi[b] ), 180 )]; // Q31 + tmp = ptr_sin[abs( azi[b] ) - 180]; // Q31 move32(); } ELSE @@ -5315,13 +5323,13 @@ void rotateAziEle_DirAC_fx( IF( GT_16( ele[b], 180 ) ) { // sin(180 + x) = -sin(x) - dv_2_fx = L_negate( ptr_sin[sub( ele[b], 180 )] ); // Q31 + dv_2_fx = L_negate( ptr_sin[ele[b] - 180] ); // Q31 move32(); } ELSE IF( LT_16( ele[b], -180 ) ) { // sin(-(180 + x)) = -sin(180 + x) = sinx - dv_2_fx = ptr_sin[sub( abs_s( ele[b] ), 180 )]; // Q31 + dv_2_fx = ptr_sin[abs( ele[b] ) - 180]; // Q31 move32(); } ELSE @@ -5341,7 +5349,7 @@ void rotateAziEle_DirAC_fx( tmp = L_add( Mpy_32_32( dv_r_0_fx, dv_r_0_fx ), Mpy_32_32( dv_r_1_fx, dv_r_1_fx ) ); // Q27 exp = sub( 31, Q27 ); - tmp = Sqrt32( tmp, &exp ); + tmp = Sqrt32( tmp, &exp ); // q=31-exp temp = BASOP_util_atan2( dv_r_2_fx, tmp, sub( sub( 31, 29 ), exp ) ); // Q13 ele[b] = shr( mult( temp, _180_OVER_PI_Q9 ), 7 ); // Q0 move16(); @@ -5775,7 +5783,7 @@ static void ivas_masa_ext_dirac_render_sf( #else static void ivas_masa_ext_dirac_render_sf_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: IVAS decoder structure */ - Word32 *output_f_fx[] /* i/o: synthesized core-coder transport channels/DirAC output */ + Word32 *output_f_fx[] /* i/o: synthesized core-coder transport channels/DirAC output q11*/ ) { Word16 i, ch, idx_in, idx_lfe; @@ -5826,10 +5834,24 @@ static void ivas_masa_ext_dirac_render_sf_fx( DirAC_mem = hDirACRend->stack_mem; - onset_filter_fx = DirAC_mem.onset_filter_fx; - reference_power_fix = DirAC_mem.reference_power_fx; - reference_power_smooth_fx = ( DirAC_mem.reference_power_fx == NULL ) ? NULL : DirAC_mem.reference_power_fx + hSpatParamRendCom->num_freq_bands; - onset_filter_subframe_fx = ( DirAC_mem.onset_filter_fx == NULL ) ? NULL : DirAC_mem.onset_filter_fx + hSpatParamRendCom->num_freq_bands; + onset_filter_fx = DirAC_mem.onset_filter_fx; // q31 + reference_power_fix = DirAC_mem.reference_power_fx; // DirAC_mem.reference_power_q + IF( ( DirAC_mem.reference_power_fx == NULL ) ) + { + reference_power_smooth_fx = NULL; + } + ELSE + { + reference_power_smooth_fx = DirAC_mem.reference_power_fx + hSpatParamRendCom->num_freq_bands; // DirAC_mem.reference_power_q + } + IF( ( DirAC_mem.onset_filter_fx == NULL ) ) + { + onset_filter_subframe_fx = NULL; + } + ELSE + { + onset_filter_subframe_fx = DirAC_mem.onset_filter_fx + hSpatParamRendCom->num_freq_bands; // q31 + } coherence_flag = 1; /* There is always coherence assumed for ext rend of MASA */ move16(); /* Construct default MASA band mapping */ @@ -5857,7 +5879,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( Copy( hSpatParamRendCom->azimuth[hSpatParamRendCom->render_to_md_map[subframe_idx]], azimuth, hSpatParamRendCom->num_freq_bands ); Copy( hSpatParamRendCom->elevation[hSpatParamRendCom->render_to_md_map[subframe_idx]], elevation, hSpatParamRendCom->num_freq_bands ); - Copy32( hSpatParamRendCom->diffuseness_vector_fx[hSpatParamRendCom->render_to_md_map[subframe_idx]], diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands ); + Copy32( hSpatParamRendCom->diffuseness_vector_fx[hSpatParamRendCom->render_to_md_map[subframe_idx]], diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands ); // q30 IF( NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { @@ -5889,22 +5911,22 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) { - dirEne_fx = hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i]; + dirEne_fx = hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i]; // 29 move32(); - surCohEner_fx = Mpy_32_16_1( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], hSpatParamRendCom->surroundingCoherence_fx[md_idx][i] ); // Q.29 - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i] = L_sub( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], surCohEner_fx ); + surCohEner_fx = Mpy_32_16_1( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], hSpatParamRendCom->surroundingCoherence_fx[md_idx][i] ); // Q.29 + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i] = L_sub( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], surCohEner_fx ); // q29 move32(); - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i] = L_add( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], surCohEner_fx ); + hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i] = L_add( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], surCohEner_fx ); // q29 move32(); - surCohRatio_fx[i] = L_deposit_h( BASOP_Util_Divide3232_Scale( surCohEner_fx, L_add( L_add( 1, dirEne_fx ), surCohEner_fx ), &surCohRatio_exp[i] ) ); + surCohRatio_fx[i] = L_deposit_h( BASOP_Util_Divide3232_Scale( surCohEner_fx, L_add( L_add( 1, dirEne_fx ), surCohEner_fx ), &surCohRatio_exp[i] ) ); // 31-surCohRatio_exp move32(); temp_exp = s_max( temp_exp, surCohRatio_exp[i] ); } FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) { - surCohRatio_fx[i] = L_shr( surCohRatio_fx[i], sub( temp_exp, surCohRatio_exp[i] ) ); + surCohRatio_fx[i] = L_shr( surCohRatio_fx[i], sub( temp_exp, surCohRatio_exp[i] ) ); // 31-temp_exp move32(); } Q_surCohRatio = sub( 31, temp_exp ); @@ -5932,7 +5954,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) { - surCohRatio_fx[i] = L_deposit_h( hSpatParamRendCom->surroundingCoherence_fx[md_idx][i] ); + surCohRatio_fx[i] = L_deposit_h( hSpatParamRendCom->surroundingCoherence_fx[md_idx][i] ); // q31 move32(); } } @@ -6022,18 +6044,18 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); IF( LT_16( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ) { - Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); + Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); // DirAC_mem.reference_power_q DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q; move16(); } ELSE { - Scale_sig32( reference_power_fix, hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_smooth_q, DirAC_mem.reference_power_q ) ); + Scale_sig32( reference_power_fix, hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_smooth_q, DirAC_mem.reference_power_q ) ); // DirAC_mem.reference_power_smooth_q DirAC_mem.reference_power_q = DirAC_mem.reference_power_smooth_q; move16(); } temp_proto_frame_q = sub( getScaleFactor32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len ), 2 ); - Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); + Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); // hDirACRend->proto_frame_f_q+temp_proto_frame_q hDirACRend->proto_frame_f_q = add( hDirACRend->proto_frame_f_q, temp_proto_frame_q ); move16(); } @@ -6059,18 +6081,18 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); IF( LT_16( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ) { - Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); + Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); // DirAC_mem.reference_power_q DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q; move16(); } ELSE { - Scale_sig32( reference_power_fix, hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_smooth_q, DirAC_mem.reference_power_q ) ); + Scale_sig32( reference_power_fix, hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_smooth_q, DirAC_mem.reference_power_q ) ); // DirAC_mem.reference_power_smooth_q DirAC_mem.reference_power_q = DirAC_mem.reference_power_smooth_q; move16(); } temp_proto_frame_q = sub( getScaleFactor32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len ), 2 ); - Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); + Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); // hDirACRend->proto_frame_f_q+temp_proto_frame_q hDirACRend->proto_frame_f_q = add( hDirACRend->proto_frame_f_q, temp_proto_frame_q ); move16(); @@ -6093,19 +6115,19 @@ static void ivas_masa_ext_dirac_render_sf_fx( IF( LT_16( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ) { - Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); + Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); // DirAC_mem.reference_power_q DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q; move16(); } ELSE { - Scale_sig32( reference_power_fix, hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_smooth_q, DirAC_mem.reference_power_q ) ); + Scale_sig32( reference_power_fix, hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_smooth_q, DirAC_mem.reference_power_q ) ); // DirAC_mem.reference_power_smooth_q DirAC_mem.reference_power_q = DirAC_mem.reference_power_smooth_q; move16(); } temp_proto_frame_q = sub( getScaleFactor32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len ), 2 ); - Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); + Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); // hDirACRend->proto_frame_f_q+temp_proto_frame_q hDirACRend->proto_frame_f_q = add( hDirACRend->proto_frame_f_q, temp_proto_frame_q ); move16(); @@ -6140,7 +6162,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 0 ); /* Q31 */ - p_onset_filter_fx = onset_filter_subframe_fx; + p_onset_filter_fx = onset_filter_subframe_fx; /*q31*/ } ELSE { @@ -6161,23 +6183,23 @@ static void ivas_masa_ext_dirac_render_sf_fx( hDirACRend->h_freq_domain_decorr_ap_params, hDirACRend->h_freq_domain_decorr_ap_state ); - hDirACRend->proto_frame_dec_f_fx = DirAC_mem.frame_dec_f_fx; + hDirACRend->proto_frame_dec_f_fx = DirAC_mem.frame_dec_f_fx; // DirAC_mem.frame_dec_f_q hDirACRend->proto_frame_dec_f_q = DirAC_mem.frame_dec_f_q; move16(); - p_onset_filter_fx = onset_filter_fx; + p_onset_filter_fx = onset_filter_fx; // q31 } } ELSE { IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - set32_fx( onset_filter_subframe_fx, ONE_IN_Q31, hSpatParamRendCom->num_freq_bands ); - p_onset_filter_fx = onset_filter_subframe_fx; + set32_fx( onset_filter_subframe_fx, ONE_IN_Q31, hSpatParamRendCom->num_freq_bands ); // q31 + p_onset_filter_fx = onset_filter_subframe_fx; // q31 } ELSE { /* no frequency domain decorrelation: use prototype frame */ - hDirACRend->proto_frame_dec_f_fx = hDirACRend->proto_frame_f_fx; + hDirACRend->proto_frame_dec_f_fx = hDirACRend->proto_frame_f_fx; // q31 hDirACRend->proto_frame_dec_f_q = hDirACRend->proto_frame_f_q; p_onset_filter_fx = NULL; } @@ -6193,11 +6215,11 @@ static void ivas_masa_ext_dirac_render_sf_fx( /* Compute diffuse prototypes */ ivas_dirac_dec_compute_diffuse_proto_fx( hDirACRend, hSpatParamRendCom->num_freq_bands, slot_idx ); } - Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( 31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); + Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( 31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); // q31 h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; move16(); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( 31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( 31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); // q31 hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q = Q31; move16(); @@ -6221,12 +6243,12 @@ static void ivas_masa_ext_dirac_render_sf_fx( IF( NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - Scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, -1 ); + Scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, -1 ); // DirAC_mem.reference_power_q-1 DirAC_mem.reference_power_q = sub( DirAC_mem.reference_power_q, 1 ); move16(); DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q; move16(); - v_add_fixed( reference_power_fix, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 0 ); + v_add_fixed( reference_power_fix, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 0 ); // DirAC_mem.reference_power_smooth_q } } /*Rescaling proto_direct_buffer_f*/ @@ -6242,14 +6264,14 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - Scale_sig32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( slot_idx, idiv1616( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len, hSpatParamRendCom->subframe_nbslots[subframe_idx] ) )], idiv1616( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), sub( temp, proto_direct_buffer_f_temp_q[slot_idx] ) ); + Scale_sig32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[( slot_idx * ( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len / hSpatParamRendCom->subframe_nbslots[subframe_idx] ) )], idiv1616( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), sub( temp, proto_direct_buffer_f_temp_q[slot_idx] ) ); // temp } } ELSE { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - Scale_sig32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( slot_idx, idiv1616( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len, hSpatParamRendCom->subframe_nbslots[subframe_idx] ) )], idiv1616( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), sub( temp, proto_direct_buffer_f_temp_q[slot_idx] ) ); + Scale_sig32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[( slot_idx * ( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len / hSpatParamRendCom->subframe_nbslots[subframe_idx] ) )], idiv1616( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), sub( temp, proto_direct_buffer_f_temp_q[slot_idx] ) ); // temp } } hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q = temp; @@ -6259,13 +6281,13 @@ static void ivas_masa_ext_dirac_render_sf_fx( ivas_dirac_dec_output_synthesis_get_interpolator_fx( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); /*Memories Scaling*/ - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( 31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( 31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); // q31 hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q = Q31; move16(); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( 31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( 31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); // q31 hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q = Q31; move16(); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands, sub( 31, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands, sub( 31, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); // q31 hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q31; move16(); @@ -6276,27 +6298,27 @@ static void ivas_masa_ext_dirac_render_sf_fx( FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { Scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, sub( 6, q_cldfb ) ); + hSpatParamRendCom->num_freq_bands, sub( 6, q_cldfb ) ); // q6 Scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, sub( 6, q_cldfb ) ); + hSpatParamRendCom->num_freq_bands, sub( 6, q_cldfb ) ); // q6 } } q_cldfb = 6; move16(); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len, sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len, sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth ) ); // q26 hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth = Q26; move16(); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len, sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len, sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth ) ); // q26 hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = Q26; move16(); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len, sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len, sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ) ); // q26 hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = Q26; move16(); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len, sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len, sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev ) ); // q26 hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = Q26; move16(); @@ -6326,8 +6348,8 @@ static void ivas_masa_ext_dirac_render_sf_fx( Word16 new_proto_diffuse_buffer_f_q = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len ); Word16 new_proto_direct_buffer_f_q = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, new_proto_diffuse_buffer_f_q ); - scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len, new_proto_direct_buffer_f_q ); + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, new_proto_diffuse_buffer_f_q ); // hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q + new_proto_diffuse_buffer_f_q + scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_len, new_proto_direct_buffer_f_q ); // hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q + new_proto_direct_buffer_f_q hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q = add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, new_proto_direct_buffer_f_q ); move16(); hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = add( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, new_proto_diffuse_buffer_f_q ); @@ -6340,42 +6362,42 @@ static void ivas_masa_ext_dirac_render_sf_fx( FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, sub( 11, q_cldfb ) ); + hSpatParamRendCom->num_freq_bands, sub( 11, q_cldfb ) ); // q11 scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, sub( 11, q_cldfb ) ); + hSpatParamRendCom->num_freq_bands, sub( 11, q_cldfb ) ); // q11 } } q_cldfb = 11; move16(); Word16 reference_power_temp_q = getScaleFactor32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len ); - scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, reference_power_temp_q ); + scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, reference_power_temp_q ); /*DirAC_mem.reference_power_q + reference_power_temp_q*/ DirAC_mem.reference_power_q = add( DirAC_mem.reference_power_q, reference_power_temp_q ); move16(); DirAC_mem.reference_power_smooth_q = add( DirAC_mem.reference_power_q, reference_power_temp_q ); move16(); Word16 q_cy_auto_diff_smooth = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_len ); - Scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_len, q_cy_auto_diff_smooth ); + Scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_len, q_cy_auto_diff_smooth ); // h_dirac_output_synthesis_state->q_cy_auto_diff_smooth+ q_cy_auto_diff_smooth h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, q_cy_auto_diff_smooth ); move16(); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands, sub( 31, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands, sub( 31, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q ) ); // q31 hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q = Q31; move16(); - Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( 31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); + Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( 31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); // q31 h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; move16(); - Scale_sig32( h_dirac_output_synthesis_state->direct_responses_fx, hSpatParamRendCom->num_freq_bands, sub( 31, h_dirac_output_synthesis_state->direct_responses_q ) ); + Scale_sig32( h_dirac_output_synthesis_state->direct_responses_fx, hSpatParamRendCom->num_freq_bands, sub( 31, h_dirac_output_synthesis_state->direct_responses_q ) ); // q31 h_dirac_output_synthesis_state->direct_responses_q = Q31; move16(); /*Q-adjustment*/ IF( hDirACRend->masa_stereo_type_detect ) { - hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx = L_shl( hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx, sub( s_min( hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ), hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth ) ); + hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx = L_shl( hDirACRend->masa_stereo_type_detect->subtract_power_y_smooth_fx, sub( s_min( hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ), hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth ) ); // s_min( hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ) move32(); - hDirACRend->masa_stereo_type_detect->subtract_power_y_fx = L_shl( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, sub( s_min( hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ), hDirACRend->masa_stereo_type_detect->q_subtract_power_y ) ); + hDirACRend->masa_stereo_type_detect->subtract_power_y_fx = L_shl( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, sub( s_min( hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ), hDirACRend->masa_stereo_type_detect->q_subtract_power_y ) ); // s_min( hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ) move32(); hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth = s_min( hDirACRend->masa_stereo_type_detect->q_subtract_power_y_smooth, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); @@ -6384,25 +6406,25 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); } - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ); move16(); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ); move16(); Word16 proto_power_diff_smooth_prev_temp_q = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len ); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len, proto_power_diff_smooth_prev_temp_q ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len, proto_power_diff_smooth_prev_temp_q ); // hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q + proto_power_diff_smooth_prev_temp_q hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q, proto_power_diff_smooth_prev_temp_q ); move16(); Word16 proto_power_diff_smooth_temp_q = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len ); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len, proto_power_diff_smooth_temp_q ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len, proto_power_diff_smooth_temp_q ); // hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q + proto_power_diff_smooth_temp_q hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, proto_power_diff_smooth_temp_q ); move16(); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ), hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ) ); - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ), hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ), hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ) + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ), hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q ) hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q ); move16(); hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q ); @@ -6412,8 +6434,8 @@ static void ivas_masa_ext_dirac_render_sf_fx( /*Buffer rescaling*/ - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, hSpatParamRendCom->num_freq_bands, sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q ) ); - Scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ), DirAC_mem.reference_power_q ) ); + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, hSpatParamRendCom->num_freq_bands, sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + Scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ), DirAC_mem.reference_power_q ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ); move16(); @@ -6439,13 +6461,13 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); IF( LT_16( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ) { - Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); + Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); // DirAC_mem.reference_power_q DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q; move16(); } ELSE { - Scale_sig32( reference_power_fix, hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_smooth_q, DirAC_mem.reference_power_q ) ); + Scale_sig32( reference_power_fix, hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_smooth_q, DirAC_mem.reference_power_q ) ); // DirAC_mem.reference_power_smooth_q DirAC_mem.reference_power_q = DirAC_mem.reference_power_smooth_q; move16(); } @@ -6482,9 +6504,9 @@ static void ivas_masa_ext_dirac_render_sf_fx( FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, scale_factor ); + hSpatParamRendCom->num_freq_bands, scale_factor ); // q_cldfb+scale_factor scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, scale_factor ); + hSpatParamRendCom->num_freq_bands, scale_factor ); // q_cldfb+scale_factor } } q_cldfb = add( q_cldfb, scale_factor ); @@ -6503,7 +6525,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( IF( hDirACRend->hOutSetup.num_lfe > 0 && ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) { /* No LFE for MASA rendering */ - set32_fx( &( output_f_fx[ch][imult1616( index_slot, hSpatParamRendCom->num_freq_bands )] ), 0, hSpatParamRendCom->subframe_nbslots[subframe_idx] * hSpatParamRendCom->num_freq_bands ); + set32_fx( &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), 0, imult1616( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->num_freq_bands ) ); IF( LT_16( idx_lfe, sub( hDirACRend->hOutSetup.num_lfe, 1 ) ) ) { @@ -6514,17 +6536,17 @@ static void ivas_masa_ext_dirac_render_sf_fx( { /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ Word16 q_out = sub( q_cldfb, 1 ); - scale_sig32( hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_length, sub( q_out, hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state ) ); + scale_sig32( hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_length, sub( q_out, hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state ) ); // q_out hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state = q_out; move16(); FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { - RealBuffer_fx[i] = Cldfb_RealBuffer_fx[idx_in][i]; - ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; + RealBuffer_fx[i] = Cldfb_RealBuffer_fx[idx_in][i]; // q_cldfb + ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; // q_cldfb } Word16 out_size = imult1616( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, hMasaExtRend->cldfbSynRend[idx_in] ); - scale_sig32( &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, sub( 11, q_out ) ); + scale_sig32( &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, sub( 11, q_out ) ); // q11 idx_in++; } } @@ -6580,7 +6602,7 @@ void ivas_masa_ext_dirac_render( #else void ivas_masa_ext_dirac_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ - Word32 *output_f[], /* i/o: input/output signals in time domain */ + Word32 *output_f[], /* i/o: input/output signals in time domain q11*/ const Word16 num_subframes /* i : number of subframes to render */ ) { @@ -6595,7 +6617,7 @@ void ivas_masa_ext_dirac_render_fx( FOR( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { - output_f_local[n] = output_f[n]; + output_f_local[n] = output_f[n]; // q11 } hSpatParamRendCom->subframes_rendered = hSpatParamRendCom->dirac_read_idx; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 8a9e8185d112cb9a33fb9c20ddb2089a36c397a1..8752094cee7a1ae0e409d54cba7b63c02832bf11 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -442,26 +442,26 @@ void ivas_dirac_free_mem_fx( ); void initDiffuseResponses_fx( - Word16 *diffuse_response_function_fx, - const int16_t num_channels, + Word16 *diffuse_response_function_fx, /*q15*/ + const Word16 num_channels, const AUDIO_CONFIG output_config, const IVAS_OUTPUT_SETUP hOutSetup, - const int16_t ambisonics_order, + const Word16 ambisonics_order, const IVAS_FORMAT ivas_format, - int16_t *num_ele_spk_no_diffuse_rendering, + Word16 *num_ele_spk_no_diffuse_rendering, const AUDIO_CONFIG transport_config ); #endif #ifdef IVAS_FLOAT_FIXED void computeIntensityVector_dec_fx( - Word32 Cldfb_RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + Word32 Cldfb_RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 Cldfb_ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ Word16 q_cldfb, const Word16 num_frequency_bands, - Word32 *intensity_real_x_fx, - Word32 *intensity_real_y_fx, - Word32 *intensity_real_z_fx, + Word32 *intensity_real_x_fx, /*q_intensity_real*/ + Word32 *intensity_real_y_fx, /*q_intensity_real*/ + Word32 *intensity_real_z_fx, /*q_intensity_real*/ Word16 *q_intensity_real ); #else @@ -476,19 +476,19 @@ void computeIntensityVector_dec( #endif #ifdef IVAS_FLOAT_FIXED void protoSignalComputation_shd_fx( - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 *proto_direct_buffer_f_fx, + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*Q(q_cldfb)*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*Q(q_cldfb)*/ + Word32 *proto_direct_buffer_f_fx, /*Q(proto_direct_buffer_f_q)*/ Word16 *proto_direct_buffer_f_q, - Word32 *proto_diffuse_buffer_f_fx, + Word32 *proto_diffuse_buffer_f_fx, /*Q(proto_diffuse_buffer_f_q)*/ Word16 *proto_diffuse_buffer_f_q, - Word32 *reference_power_fx, + Word32 *reference_power_fx, /*Q(reference_power_q)*/ Word16 *reference_power_q, const Word16 slot_index, const Word16 num_inputs, const Word16 num_outputs_diff, const Word16 num_freq_bands, - Word32 *p_Rmat_fx, + Word32 *p_Rmat_fx, /* Q30 */ Word16 q_cldfb ); #endif @@ -507,15 +507,15 @@ void protoSignalComputation_shd( #ifdef IVAS_FLOAT_FIXED void protoSignalComputation1_fx( - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 *proto_frame_f_fx, + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 *proto_frame_f_fx, /*proto_frame_f_q*/ Word16 *proto_frame_f_q, - Word32 *proto_direct_buffer_f_fx, + Word32 *proto_direct_buffer_f_fx, /*proto_direct_buffer_f_q*/ Word16 *proto_direct_buffer_f_q, - Word32 *reference_power_fx, + Word32 *reference_power_fx, /*reference_power_q*/ Word16 *reference_power_q, - Word32 *proto_power_smooth_fx, + Word32 *proto_power_smooth_fx, /*proto_power_smooth_q*/ Word16 *proto_power_smooth_q, const Word16 slot_index, const Word16 num_outputs_diff, @@ -537,15 +537,15 @@ void protoSignalComputation1( #ifdef IVAS_FLOAT_FIXED void protoSignalComputation2_fx( - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 *proto_frame_f_fx, + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 *proto_frame_f_fx, /*q_proto_frame_f*/ Word16 *q_proto_frame_f, - Word32 *proto_direct_buffer_f_fx, + Word32 *proto_direct_buffer_f_fx, /*q_proto_direct_buffer_f*/ Word16 *q_proto_direct_buffer_f, - Word32 *reference_power_fx, + Word32 *reference_power_fx, /*q_reference_power*/ Word16 *q_reference_power, - Word32 *proto_power_smooth_fx, + Word32 *proto_power_smooth_fx, /*q_proto_power_smooth*/ Word16 *q_proto_power_smooth, const Word16 isloudspeaker, const Word16 slot_index, @@ -569,20 +569,20 @@ void protoSignalComputation2( #ifdef IVAS_FLOAT_FIXED void protoSignalComputation4_fx( - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 *proto_frame_f_fx, + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 *proto_frame_f_fx, /*proto_frame_f_q*/ Word16 *proto_frame_f_q, - Word32 *proto_direct_buffer_f_fx, + Word32 *proto_direct_buffer_f_fx, /*proto_direct_buffer_f_q*/ Word16 *proto_direct_buffer_f_q, - Word32 *reference_power_fx, + Word32 *reference_power_fx, /*reference_power_q*/ Word16 *reference_power_q, - Word32 *proto_power_smooth_fx, + Word32 *proto_power_smooth_fx, /*proto_power_smooth_q*/ Word16 *proto_power_smooth_q, const Word16 slot_index, const Word16 num_outputs_diff, const Word16 num_freq_bands, - const Word32 *mtx_hoa_decoder, + const Word32 *mtx_hoa_decoder, /*q29*/ const Word16 nchan_transport, const Word16 *sba_map_tc_ind, Word16 q_cldfb @@ -623,9 +623,9 @@ void ivas_dirac_dec_compute_diffuse_proto_fx( #ifdef IVAS_FLOAT_FIXED void computeDirectionAngles_fx( - Word32 *intensity_real_x_fx, - Word32 *intensity_real_y_fx, - Word32 *intensity_real_z_fx, + Word32 *intensity_real_x_fx, /*q_intensity_real*/ + Word32 *intensity_real_y_fx, /*q_intensity_real*/ + Word32 *intensity_real_z_fx, /*q_intensity_real*/ Word16 q_intensity_real, const Word16 num_frequency_bands, Word16 *azimuth, @@ -664,10 +664,10 @@ void ivas_masa_stereotype_detection( #ifdef IVAS_FLOAT_FIXED void ivas_lfe_synth_with_cldfb_fx( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 RealBufferLfe_fx[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], - Word32 ImagBufferLfe_fx[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 RealBufferLfe_fx[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ + Word32 ImagBufferLfe_fx[MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /*q_cldfb*/ const Word16 slot_index, const Word16 subframe_index, const Word16 nchan_transport, @@ -688,11 +688,11 @@ void ivas_lfe_synth_with_cldfb( #ifdef IVAS_FLOAT_FIXED void rotateAziEle_DirAC_fx( - Word16 *azi, - Word16 *ele, - const Word16 band1, - const Word16 band2, - const Word32 *p_Rmat_fx + Word16 *azi, /* i/o: array of azimuth values */ + Word16 *ele, /* i/o: array of elevation values */ + const Word16 band1, /* i : bands to work on (lower limit) */ + const Word16 band2, /* i : bands to work on (upper bound) */ + const Word32 *p_Rmat_fx /* i : pointer to real-space rotation matrix q30*/ ); #endif void rotateAziEle_DirAC( @@ -953,11 +953,11 @@ void compute_hoa_encoder_mtx( #ifdef IVAS_FLOAT_FIXED void compute_hoa_encoder_mtx_fx( - const Word32 *azimuth, - const Word32 *elevation, - Word32 *response_fx, + const Word32 *azimuth, /*q22*/ + const Word32 *elevation, /*q22*/ + Word32 *response_fx, /*q31*/ const Word16 num_responses, - const Word16 ambisonics_order); + const Word16 ambisonics_order ); #endif #ifndef IVAS_FLOAT_FIXED @@ -1103,9 +1103,9 @@ void ivas_masa_ext_dirac_render( ); #else void ivas_masa_ext_dirac_render_fx( - MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ - Word32 *output_f[], /* i/o: input/output signals in time domain */ - const Word16 num_subframes /* i : number of subframes to render */ + MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ + Word32 *output_f[], /* i/o: input/output signals in time domain q11*/ + const Word16 num_subframes /* i : number of subframes to render */ ); #endif /*----------------------------------------------------------------------------------*