LCOV - code coverage report
Current view: top level - lib_rend - ivas_td_decorr.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 120 129 93.0 %
Date: 2025-05-23 08:37:30 Functions: 8 8 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : #include <stdint.h>
      34             : #include "options.h"
      35             : #include "prot.h"
      36             : #include "ivas_prot.h"
      37             : #include "ivas_prot_rend.h"
      38             : #ifdef DEBUGGING
      39             : #include "debug.h"
      40             : #endif
      41             : #include "math.h"
      42             : #include <assert.h>
      43             : #include "wmc_auto.h"
      44             : 
      45             : 
      46             : /*------------------------------------------------------------------------------------------*
      47             :  * Local constants
      48             :  *------------------------------------------------------------------------------------------*/
      49             : 
      50             : static const float ivas_hadamard_decorr_APD_coeff[IVAS_APD_16_SECT][IVAS_APD_16_SECT] = {
      51             :     { 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f },
      52             :     { 0.4f, -0.4f, 0.4f, -0.4f, 0.4f, -0.4f, 0.4f, -0.4f, 0.4f, -0.4f, 0.4f, -0.4f, 0.4f, -0.4f, 0.4f, -0.4f },
      53             :     { 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f },
      54             :     { 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, 0.4f },
      55             :     { 0.4f, 0.4f, 0.4f, 0.4f, -0.4f, -0.4f, -0.4f, -0.4f, 0.4f, 0.4f, 0.4f, 0.4f, -0.4f, -0.4f, -0.4f, -0.4f },
      56             :     { 0.4f, -0.4f, 0.4f, -0.4f, -0.4f, 0.4f, -0.4f, 0.4f, 0.4f, -0.4f, 0.4f, -0.4f, -0.4f, 0.4f, -0.4f, 0.4f },
      57             :     { 0.4f, 0.4f, -0.4f, -0.4f, -0.4f, -0.4f, 0.4f, 0.4f, 0.4f, 0.4f, -0.4f, -0.4f, -0.4f, -0.4f, 0.4f, 0.4f },
      58             :     { 0.4f, -0.4f, -0.4f, 0.4f, -0.4f, 0.4f, 0.4f, -0.4f, 0.4f, -0.4f, -0.4f, 0.4f, -0.4f, 0.4f, 0.4f, -0.4f },
      59             :     { 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, -0.4f, -0.4f, -0.4f, -0.4f, -0.4f, -0.4f, -0.4f, -0.4f },
      60             :     { 0.4f, -0.4f, 0.4f, -0.4f, 0.4f, -0.4f, 0.4f, -0.4f, -0.4f, 0.4f, -0.4f, 0.4f, -0.4f, 0.4f, -0.4f, 0.4f },
      61             :     { 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.4f },
      62             :     { 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f },
      63             :     { 0.4f, 0.4f, 0.4f, 0.4f, -0.4f, -0.4f, -0.4f, -0.4f, -0.4f, -0.4f, -0.4f, -0.4f, 0.4f, 0.4f, 0.4f, 0.4f },
      64             :     { 0.4f, -0.4f, 0.4f, -0.4f, -0.4f, 0.4f, -0.4f, 0.4f, -0.4f, 0.4f, -0.4f, 0.4f, 0.4f, -0.4f, 0.4f, -0.4f },
      65             :     { 0.4f, 0.4f, -0.4f, -0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, 0.4f, 0.4f, -0.4f, -0.4f },
      66             :     { 0.4f, -0.4f, -0.4f, 0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, 0.4f, -0.4f, -0.4f, 0.4f }
      67             : };
      68             : 
      69             : /* For R = 3.^([0:obj.parm_APD_nSections-1]/4); */
      70             : static const float ivas_three_pow_frac[IVAS_MAX_DECORR_APD_SECTIONS] = {
      71             :     1.000000000000000f,
      72             :     1.316074013710022f,
      73             :     1.732050776481628f,
      74             :     2.279507160186768f,
      75             :     3.000000000000000f,
      76             :     3.948222038857480f,
      77             :     5.196152422706630f,
      78             :     6.838521170864330f,
      79             :     9.000000000000000f,
      80             :     11.84466611657240f,
      81             :     15.58845726811990f,
      82             :     20.51556351259300f,
      83             :     27.00000000000000f,
      84             :     35.53399834971730f,
      85             :     46.76537180435970f,
      86             :     61.54669053777900f,
      87             : };
      88             : 
      89             : #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN        ( 2.0f )
      90             : #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR ( 3.0f )
      91             : 
      92             : /*------------------------------------------------------------------------------------------*
      93             :  * Local functions declaration
      94             :  *------------------------------------------------------------------------------------------*/
      95             : 
      96             : static int16_t ivas_get_APD_filt_orders( const int16_t num_out_chans, const int32_t output_Fs, int16_t *APD_filt_orders );
      97             : 
      98             : static void ivas_td_decorr_init( ivas_td_decorr_state_t *hTdDecorr, const int16_t num_out_chans, const int16_t ducking_flag );
      99             : 
     100             : 
     101             : /*-------------------------------------------------------------------------
     102             :  * ivas_td_decorr_reconfig_dec()
     103             :  *
     104             :  * Allocate and initialize time domain decorrelator handle
     105             :  *------------------------------------------------------------------------*/
     106             : 
     107       12771 : ivas_error ivas_td_decorr_reconfig_dec(
     108             :     const IVAS_FORMAT ivas_format,      /* i  : IVAS format                     */
     109             :     const int32_t ivas_total_brate,     /* i  : total IVAS bitrate              */
     110             :     const int16_t nchan_transport,      /* i  : number of transport channels    */
     111             :     const int32_t output_Fs,            /* i  : output sampling rate            */
     112             :     ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle          */
     113             :     uint16_t *useTdDecorr               /* i/o: TD decorrelator flag            */
     114             : )
     115             : {
     116             :     uint16_t useTdDecorr_new;
     117             :     ivas_error error;
     118             : 
     119       12771 :     useTdDecorr_new = 0;
     120       12771 :     if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT )
     121             :     {
     122        2079 :         if ( nchan_transport == 1 )
     123             :         {
     124        1347 :             useTdDecorr_new = 1;
     125             :         }
     126             :     }
     127       10692 :     else if ( ivas_format == MASA_FORMAT )
     128             :     {
     129        5364 :         if ( ( ivas_total_brate < IVAS_48k && nchan_transport == 1 ) || ivas_total_brate < MASA_STEREO_MIN_BITRATE )
     130             :         {
     131        2964 :             useTdDecorr_new = 1;
     132             :         }
     133             :     }
     134        5328 :     else if ( ivas_format == MC_FORMAT )
     135             :     {
     136         849 :         if ( ivas_total_brate < IVAS_48k && nchan_transport == 1 )
     137             :         {
     138         756 :             useTdDecorr_new = 1;
     139             :         }
     140             :     }
     141             : 
     142       12771 :     if ( *useTdDecorr != useTdDecorr_new )
     143             :     {
     144        2787 :         *useTdDecorr = useTdDecorr_new;
     145             : 
     146        2787 :         if ( *useTdDecorr )
     147             :         {
     148        1803 :             if ( ivas_total_brate >= IVAS_13k2 && ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) )
     149             :             {
     150         561 :                 if ( *hTdDecorr == NULL )
     151             :                 {
     152         561 :                     if ( ( error = ivas_td_decorr_dec_open( hTdDecorr, output_Fs, 3, 1 ) ) != IVAS_ERR_OK )
     153             :                     {
     154           0 :                         return error;
     155             :                     }
     156             :                 }
     157             : 
     158         561 :                 if ( ivas_total_brate < IVAS_24k4 )
     159             :                 {
     160         330 :                     ( *hTdDecorr )->pTrans_det->duck_mult_fac = IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR;
     161             :                 }
     162             :                 else
     163             :                 {
     164         231 :                     ( *hTdDecorr )->pTrans_det->duck_mult_fac = IVAS_TDET_DUCK_MULT_FAC_PARA_BIN;
     165             :                 }
     166             :             }
     167             :             else
     168             :             {
     169        1242 :                 if ( *hTdDecorr == NULL )
     170             :                 {
     171        1242 :                     if ( ( error = ivas_td_decorr_dec_open( hTdDecorr, output_Fs, 3, 0 ) ) != IVAS_ERR_OK )
     172             :                     {
     173           0 :                         return error;
     174             :                     }
     175             :                 }
     176             :                 else
     177             :                 {
     178           0 :                     ivas_td_decorr_init( *hTdDecorr, 3, 0 );
     179             :                 }
     180             :             }
     181             :         }
     182             :         else
     183             :         {
     184         984 :             ivas_td_decorr_dec_close( hTdDecorr );
     185             :         }
     186             :     }
     187             : 
     188       12771 :     return IVAS_ERR_OK;
     189             : }
     190             : 
     191             : 
     192             : /*-------------------------------------------------------------------------
     193             :  * ivas_td_decorr_dec_open()
     194             :  *
     195             :  * Allocate and initialize time domain decorrelator handle
     196             :  *------------------------------------------------------------------------*/
     197             : 
     198        6162 : ivas_error ivas_td_decorr_dec_open(
     199             :     ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle          */
     200             :     const int32_t output_Fs,            /* i  : output sampling rate            */
     201             :     const int16_t nchan_internal,       /* i  : number of internal channels     */
     202             :     const int16_t ducking_flag          /* i  : ducking flag                    */
     203             : )
     204             : {
     205             :     int16_t i, j, len;
     206             :     int16_t num_out_chans;
     207             :     ivas_td_decorr_state_t *hTdDecorr_loc;
     208             :     ivas_error error;
     209             : 
     210        6162 :     num_out_chans = nchan_internal - 1;
     211             : 
     212        6162 :     error = IVAS_ERR_OK;
     213             : 
     214        6162 :     if ( ( hTdDecorr_loc = (ivas_td_decorr_state_t *) malloc( sizeof( ivas_td_decorr_state_t ) ) ) == NULL )
     215             :     {
     216           0 :         return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" );
     217             :     }
     218             : 
     219        6162 :     if ( ( hTdDecorr_loc->look_ahead_buf = (float *) malloc( sizeof( float ) * (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) ) ) == NULL )
     220             :     {
     221           0 :         return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" );
     222             :     }
     223        6162 :     set_f( hTdDecorr_loc->look_ahead_buf, 0, (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU ) );
     224        6162 :     hTdDecorr_loc->offset = (int16_t) ( output_Fs * IVAS_DECORR_PARM_LOOKAHEAD_TAU );
     225        6162 :     hTdDecorr_loc->num_apd_sections = ivas_get_APD_filt_orders( num_out_chans, output_Fs, hTdDecorr_loc->APD_filt_state[0].order );
     226             : 
     227       24012 :     for ( j = 0; j < num_out_chans; j++ )
     228             :     {
     229       93006 :         for ( i = 0; i < hTdDecorr_loc->num_apd_sections; i++ )
     230             :         {
     231       75156 :             len = hTdDecorr_loc->APD_filt_state[0].order[i];
     232             : 
     233       75156 :             if ( ( hTdDecorr_loc->APD_filt_state[j].state[i] = (float *) malloc( sizeof( float ) * len ) ) == NULL )
     234             :             {
     235           0 :                 return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR COV decoder" );
     236             :             }
     237             : 
     238       75156 :             set_f( hTdDecorr_loc->APD_filt_state[j].state[i], 0, len );
     239             :         }
     240             :     }
     241             : 
     242        6162 :     ivas_td_decorr_init( hTdDecorr_loc, num_out_chans, ducking_flag );
     243             : 
     244        6162 :     if ( ducking_flag )
     245             :     {
     246        4920 :         if ( ( error = ivas_transient_det_open( &hTdDecorr_loc->pTrans_det, output_Fs ) ) != IVAS_ERR_OK )
     247             :         {
     248           0 :             return error;
     249             :         }
     250             :     }
     251             :     else
     252             :     {
     253        1242 :         hTdDecorr_loc->pTrans_det = NULL;
     254             :     }
     255             : 
     256        6162 :     *hTdDecorr = hTdDecorr_loc;
     257             : 
     258        6162 :     return error;
     259             : }
     260             : 
     261             : 
     262             : /*-------------------------------------------------------------------------
     263             :  * ivas_td_decorr_dec_close()
     264             :  *
     265             :  * Deallocate time domain decorrelator handle
     266             :  *------------------------------------------------------------------------*/
     267             : 
     268        8001 : void ivas_td_decorr_dec_close(
     269             :     ivas_td_decorr_state_t **hTdDecorr /* i/o: TD decorrelator handle   */
     270             : )
     271             : {
     272             :     int16_t i, j;
     273             : 
     274        8001 :     if ( hTdDecorr == NULL || *hTdDecorr == NULL )
     275             :     {
     276        1839 :         return;
     277             :     }
     278             : 
     279        6162 :     free( ( *hTdDecorr )->look_ahead_buf );
     280        6162 :     ( *hTdDecorr )->look_ahead_buf = NULL;
     281             : 
     282       24012 :     for ( j = 0; j < ( *hTdDecorr )->num_apd_outputs; j++ )
     283             :     {
     284       93006 :         for ( i = 0; i < ( *hTdDecorr )->num_apd_sections; i++ )
     285             :         {
     286       75156 :             free( ( *hTdDecorr )->APD_filt_state[j].state[i] );
     287       75156 :             ( *hTdDecorr )->APD_filt_state[j].state[i] = NULL;
     288             :         }
     289             :     }
     290             : 
     291        6162 :     if ( ( *hTdDecorr )->pTrans_det != NULL )
     292             :     {
     293        4920 :         ivas_transient_det_close( &( *hTdDecorr )->pTrans_det );
     294             :     }
     295             : 
     296        6162 :     free( ( *hTdDecorr ) );
     297        6162 :     ( *hTdDecorr ) = NULL;
     298             : 
     299        6162 :     return;
     300             : }
     301             : 
     302             : 
     303             : /*-----------------------------------------------------------------------------------------*
     304             :  * Function ivas_get_APD_filt_orders()
     305             :  *
     306             :  * Calculate the orders of the APD IIR filters and return num APD sections
     307             :  *-----------------------------------------------------------------------------------------*/
     308             : 
     309        6162 : static int16_t ivas_get_APD_filt_orders(
     310             :     const int16_t num_out_chans,
     311             :     const int32_t output_Fs,
     312             :     int16_t *APD_filt_orders )
     313             : {
     314             :     int16_t i;
     315        6162 :     int16_t num_apd_sections = 0;
     316             :     float sum_R, R[IVAS_MAX_DECORR_APD_SECTIONS];
     317             : 
     318        6162 :     switch ( num_out_chans )
     319             :     {
     320        2097 :         case IVAS_TD_DECORR_OUT_1CH:
     321             :         case IVAS_TD_DECORR_OUT_2CH:
     322        2097 :             num_apd_sections = IVAS_APD_2_SECT;
     323        2097 :             break;
     324        3612 :         case IVAS_TD_DECORR_OUT_3CH:
     325             :         case IVAS_TD_DECORR_OUT_4CH:
     326        3612 :             num_apd_sections = IVAS_APD_4_SECT;
     327        3612 :             break;
     328         453 :         case IVAS_TD_DECORR_OUT_5CH:
     329             :         case IVAS_TD_DECORR_OUT_6CH:
     330             :         case IVAS_TD_DECORR_OUT_7CH:
     331             :         case IVAS_TD_DECORR_OUT_8CH:
     332         453 :             num_apd_sections = IVAS_APD_8_SECT;
     333         453 :             break;
     334           0 :         default:
     335           0 :             assert( !"Invalid num out chans" );
     336             :             break;
     337             :     }
     338             : 
     339        6162 :     sum_R = 0.0f;
     340       28428 :     for ( i = 0; i < num_apd_sections; i++ )
     341             :     {
     342       22266 :         R[i] = ivas_three_pow_frac[i];
     343       22266 :         sum_R += R[i];
     344             :     }
     345             : 
     346       28428 :     for ( i = 0; i < num_apd_sections; i++ )
     347             :     {
     348       22266 :         APD_filt_orders[i] = (int16_t) ceil( output_Fs * IVAS_DECORR_PARM_APD_TAU * R[i] / sum_R );
     349             :     }
     350             : 
     351        6162 :     return num_apd_sections;
     352             : }
     353             : 
     354             : 
     355             : /*-----------------------------------------------------------------------------------------*
     356             :  * Function ivas_td_decorr_init()
     357             :  *
     358             :  * TD decorr Initialisation function
     359             :  *-----------------------------------------------------------------------------------------*/
     360             : 
     361        6162 : static void ivas_td_decorr_init(
     362             :     ivas_td_decorr_state_t *hTdDecorr, /* i/o: TD decorrelator handle   */
     363             :     const int16_t num_out_chans,       /* i  : number of channels       */
     364             :     const int16_t ducking_flag         /* i  : TD ducking flag          */
     365             : )
     366             : {
     367             :     int16_t i, j;
     368             : 
     369        6162 :     hTdDecorr->ducking_flag = ducking_flag;
     370        6162 :     hTdDecorr->num_apd_outputs = num_out_chans;
     371             : 
     372       24012 :     for ( i = 0; i < hTdDecorr->num_apd_outputs; i++ )
     373             :     {
     374       93006 :         for ( j = 0; j < hTdDecorr->num_apd_sections; j++ )
     375             :         {
     376       75156 :             hTdDecorr->APD_filt_state[i].order[j] = hTdDecorr->APD_filt_state[0].order[j];
     377       75156 :             hTdDecorr->APD_filt_state[i].coeffs[j] = ivas_hadamard_decorr_APD_coeff[i][j];
     378       75156 :             hTdDecorr->APD_filt_state[i].idx[j] = 0;
     379             :         }
     380             :     }
     381             : 
     382        6162 :     return;
     383             : }
     384             : 
     385             : 
     386             : /*-----------------------------------------------------------------------------------------*
     387             :  * Function ivas_td_decorr_APD_iir_filter()
     388             :  *
     389             :  * APD IIR filter
     390             :  *-----------------------------------------------------------------------------------------*/
     391             : 
     392     1147119 : void ivas_td_decorr_APD_iir_filter(
     393             :     ivas_td_decorr_APD_filt_state_t *filter_state, /* i/o: TD decorrelator filter handle    */
     394             :     float *pIn_out,                                /* i/o: audio channels                   */
     395             :     const int16_t num_APD_sections,                /* i  : numbef of APD sections           */
     396             :     const int16_t length                           /* i  : output frame length              */
     397             : )
     398             : {
     399             :     int16_t i, k;
     400             :     int16_t idx;
     401     1147119 :     float *pIn = pIn_out;
     402     1147119 :     float *pOut = pIn_out;
     403             :     float tmp_pIn_buf_i;
     404             : 
     405     6212691 :     for ( k = 0; k < num_APD_sections; k++ )
     406             :     {
     407     5065572 :         float *pFilt_state = filter_state->state[k];
     408     5065572 :         float filt_coeff = filter_state->coeffs[k];
     409     5065572 :         int16_t order = filter_state->order[k];
     410             : 
     411     5065572 :         idx = filter_state->idx[k];
     412             : 
     413  4217037732 :         for ( i = 0; i < length; i++ )
     414             :         {
     415  4211972160 :             tmp_pIn_buf_i = pIn[i];
     416             : 
     417  4211972160 :             pOut[i] = pFilt_state[idx] + pIn[i] * filt_coeff;
     418             : 
     419  4211972160 :             pFilt_state[idx++] = tmp_pIn_buf_i - filt_coeff * pOut[i];
     420             : 
     421  4211972160 :             if ( order == idx )
     422             :             {
     423    34468965 :                 idx = 0;
     424             :             }
     425             :         }
     426     5065572 :         filter_state->idx[k] = idx;
     427             :     }
     428             : 
     429     1147119 :     return;
     430             : }
     431             : 
     432             : 
     433             : /*-----------------------------------------------------------------------------------------*
     434             :  * Function ivas_td_decorr_APD_sections()
     435             :  *
     436             :  * TD decorr all pass delay sections
     437             :  *-----------------------------------------------------------------------------------------*/
     438             : 
     439      372675 : static void ivas_td_decorr_APD_sections(
     440             :     ivas_td_decorr_state_t *hTdDecorr, /* i/o: TD decorrelator handle   */
     441             :     float **ppOut_pcm,                 /* i/o: audio channels           */
     442             :     const int16_t output_frame         /* i  : output frame length      */
     443             : )
     444             : {
     445             :     int16_t i;
     446             : 
     447     1510434 :     for ( i = 0; i < hTdDecorr->num_apd_outputs; i++ )
     448             :     {
     449     1137759 :         ivas_td_decorr_APD_iir_filter( &hTdDecorr->APD_filt_state[i], ppOut_pcm[i], hTdDecorr->num_apd_sections, output_frame );
     450             :     }
     451             : 
     452      372675 :     return;
     453             : }
     454             : 
     455             : 
     456             : /*-----------------------------------------------------------------------------------------*
     457             :  * Function ivas_td_decorr_process()
     458             :  *
     459             :  * TD decorr process call
     460             :  *-----------------------------------------------------------------------------------------*/
     461             : 
     462      372675 : void ivas_td_decorr_process(
     463             :     ivas_td_decorr_state_t *hTdDecorr, /* i/o: TD decorrelator handle       */
     464             :     float *pcm_in[],                   /* i  : input audio channels         */
     465             :     float **ppOut_pcm,                 /* o  : output audio channels        */
     466             :     const int16_t output_frame         /* i  : output frame length          */
     467             : )
     468             : {
     469             :     int16_t i, j;
     470             :     float in_duck_gain[L_FRAME48k], out_duck_gain[L_FRAME48k];
     471             : 
     472             :     /* Look-ahead delay */
     473      372675 :     mvr2r( pcm_in[0], ppOut_pcm[0], output_frame );
     474      372675 :     delay_signal( ppOut_pcm[0], output_frame, hTdDecorr->look_ahead_buf, hTdDecorr->offset );
     475             : 
     476             :     /* In ducking gains */
     477      372675 :     if ( hTdDecorr->ducking_flag )
     478             :     {
     479      272088 :         ivas_td_decorr_get_ducking_gains( hTdDecorr->pTrans_det, pcm_in[0], in_duck_gain, out_duck_gain, output_frame, 0 );
     480             : 
     481   219897108 :         for ( j = 0; j < output_frame; j++ )
     482             :         {
     483   219625020 :             ppOut_pcm[0][j] = ppOut_pcm[0][j] * in_duck_gain[j];
     484             :         }
     485             :     }
     486             : 
     487     1137759 :     for ( i = 1; i < hTdDecorr->num_apd_outputs; i++ )
     488             :     {
     489      765084 :         mvr2r( ppOut_pcm[0], ppOut_pcm[i], output_frame );
     490             :     }
     491             : 
     492             :     /* All pass delay section */
     493      372675 :     ivas_td_decorr_APD_sections( hTdDecorr, ppOut_pcm, output_frame );
     494             : 
     495             :     /* Out ducking gains */
     496      372675 :     if ( hTdDecorr->ducking_flag )
     497             :     {
     498     1141422 :         for ( i = 0; i < hTdDecorr->num_apd_outputs; i++ )
     499             :         {
     500   718577634 :             for ( j = 0; j < output_frame; j++ )
     501             :             {
     502   717708300 :                 ppOut_pcm[i][j] = ppOut_pcm[i][j] * out_duck_gain[j];
     503             :             }
     504             :         }
     505             :     }
     506             : 
     507      372675 :     return;
     508             : }

Generated by: LCOV version 1.14