From 1e57ebd2d6214aeaf0af9788eaac07db76b1a68a Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 28 Nov 2023 18:57:21 +0530 Subject: [PATCH] BASOP update in ivas_init_dec.c [x] Datatype and BASOP updates in ivas_init_dec.c. [x] Floating code output is bit exact with base version IVAS code. [x] Float buffer mallocs to be converted. --- lib_dec/ivas_init_dec.c | 976 ++++++++++++++++++++-------------------- 1 file changed, 488 insertions(+), 488 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 86643b646..31748cdec 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -47,7 +47,7 @@ * Local function prototypes *-------------------------------------------------------------------*/ -static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_read ); +static ivas_error ivas_read_format( Decoder_Struct *st_ivas, Word16 *num_bits_read ); static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); @@ -61,14 +61,14 @@ static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); ivas_error ivas_dec_setup( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : output synthesis signal */ + UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ + Word16 *data /* o : output synthesis signal */ ) { - int16_t k, idx, num_bits_read; - int16_t nchan_ism, element_mode_flag; + Word16 k, idx, num_bits_read; + Word16 nchan_ism, element_mode_flag; Decoder_State *st; - int32_t ivas_total_brate; + Word32 ivas_total_brate; ivas_error error; error = IVAS_ERR_OK; @@ -88,7 +88,7 @@ ivas_error ivas_dec_setup( * Read other signling (ISM/MC mode, number of channels, etc.) *-------------------------------------------------------------------*/ - if ( is_DTXrate( ivas_total_brate ) == 0 ) + IF ( EQ_16(is_DTXrate( ivas_total_brate ), 0 )) { /*-------------------------------------------------------------------* * Read IVAS format related signaling: @@ -98,17 +98,17 @@ ivas_error ivas_dec_setup( * - in MC : read LS setup *-------------------------------------------------------------------*/ - if ( st_ivas->ivas_format == STEREO_FORMAT ) + IF ( st_ivas->ivas_format == STEREO_FORMAT ) { element_mode_flag = 1; } - else if ( st_ivas->ivas_format == ISM_FORMAT ) + ELSE IF ( st_ivas->ivas_format == ISM_FORMAT ) { /* read the number of objects */ st_ivas->nchan_transport = 1; nchan_ism = 1; - k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ); - while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS ) + k = (Word16) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ); + WHILE ( st_ivas->bit_stream[k] && LT_16(nchan_ism , MAX_NUM_OBJECTS )) { nchan_ism++; k--; @@ -116,16 +116,16 @@ ivas_error ivas_dec_setup( st_ivas->nchan_ism = nchan_ism; - if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->ivas_format == SBA_FORMAT ) + ELSE IF ( st_ivas->ivas_format == SBA_FORMAT ) { /* read Ambisonic (SBA) planar flag */ st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; - num_bits_read += SBA_PLANAR_BITS; + num_bits_read = add(num_bits_read, SBA_PLANAR_BITS); /* read Ambisonic (SBA) order */ st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; @@ -134,55 +134,55 @@ ivas_error ivas_dec_setup( /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); - num_bits_read += SBA_ORDER_BITS; - if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) + num_bits_read = add(num_bits_read, SBA_ORDER_BITS); + IF ( GT_16(st_ivas->ini_frame , 0) && NE_32(ivas_total_brate, st_ivas->last_active_ivas_total_brate) && GT_32(ivas_total_brate, IVAS_SID_5k2 )) { - if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } } - else + ELSE { ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); } } - else if ( st_ivas->ivas_format == MASA_FORMAT ) + ELSE IF ( st_ivas->ivas_format == MASA_FORMAT ) { /* read number of MASA transport channels */ - if ( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 1] ) + IF ( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 1] ) { st_ivas->nchan_transport = 2; element_mode_flag = 1; } - else + ELSE { st_ivas->nchan_transport = 1; } - if ( st_ivas->ini_frame > 0 ) + IF ( GT_16(st_ivas->ini_frame, 0 )) { /* reconfigure in case a change of operation mode is detected */ - if ( ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) || ( st_ivas->ini_active_frame == 0 ) ) + IF ( ( GT_32(ivas_total_brate, IVAS_SID_5k2) && NE_32(ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate )) || EQ_16( st_ivas->ini_active_frame, 0 ) ) { - if ( st_ivas->last_ivas_format == MASA_FORMAT ) + IF ( st_ivas->last_ivas_format == MASA_FORMAT ) { - if ( st_ivas->ini_active_frame == 0 && ivas_total_brate != FRAME_NO_DATA && ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->nCPE == 1 ) + IF ( EQ_16(st_ivas->ini_active_frame, 0) && NE_32(ivas_total_brate, FRAME_NO_DATA) && LT_32(ivas_total_brate, MASA_STEREO_MIN_BITRATE) && EQ_16(st_ivas->nCPE, 1 )) { st_ivas->hCPE[0]->nchan_out = 1; } - else + ELSE { - if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } } } - else + ELSE { - if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; @@ -191,7 +191,7 @@ ivas_error ivas_dec_setup( } } } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + ELSE IF ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { st_ivas->nchan_transport = 2; /* always 2 MASA transport channels */ @@ -199,48 +199,48 @@ ivas_error ivas_dec_setup( st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ); - if ( st_ivas->ini_frame > 0 ) + IF ( GT_16(st_ivas->ini_frame, 0 )) { /* reconfigure in case a change of operation mode is detected */ - if ( ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) || ( st_ivas->ini_active_frame == 0 ) ) + IF ( ( GT_32(ivas_total_brate, IVAS_SID_5k2) && NE_32(ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate )) || EQ_16( st_ivas->ini_active_frame, 0 ) ) { - if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } } } } - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + ELSE IF ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { /* the number of objects is written at the end of the bitstream, in the SBA metadata */ st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; - if ( ivas_total_brate < IVAS_24k4 || ivas_total_brate >= IVAS_256k ) + IF ( LT_32(ivas_total_brate, IVAS_24k4) || GE_32(ivas_total_brate, IVAS_256k )) { /* read Ambisonic (SBA) planar flag */ st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; - num_bits_read += SBA_PLANAR_BITS; + num_bits_read = add(num_bits_read, SBA_PLANAR_BITS); } st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; - num_bits_read += SBA_ORDER_BITS; + num_bits_read = add(num_bits_read, SBA_ORDER_BITS); /* read Ambisonic (SBA) order */ - if ( ivas_total_brate < IVAS_256k ) + IF ( LT_32(ivas_total_brate, IVAS_256k )) { st_ivas->sba_order = 3; } - if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate ) + IF ( GT_16(st_ivas->ini_frame, 0) && NE_32(ivas_total_brate, st_ivas->last_active_ivas_total_brate )) { - if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } } - else + ELSE { /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); @@ -248,36 +248,36 @@ ivas_error ivas_dec_setup( ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); /*correct number of CPEs for discrete ISM coding*/ - if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF ( GT_16(st_ivas->ini_frame, 0) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; + st_ivas->nCPE += add( st_ivas->nchan_ism, 1 ) >> 1; } } - if ( ivas_total_brate >= IVAS_256k ) + IF ( GE_32(ivas_total_brate, IVAS_256k )) { st_ivas->ism_mode = ISM_SBA_MODE_DISC; } - else + ELSE { st_ivas->ism_mode = ISM_MODE_NONE; } } - else if ( st_ivas->ivas_format == MC_FORMAT ) + ELSE IF ( st_ivas->ivas_format == MC_FORMAT ) { /* read MC configuration */ idx = 0; - for ( k = 0; k < MC_LS_SETUP_BITS; k++ ) + FOR ( k = 0; k < MC_LS_SETUP_BITS; k++ ) { - if ( st_ivas->bit_stream[num_bits_read + k] ) + IF ( st_ivas->bit_stream[num_bits_read + k] ) { idx += 1 << ( MC_LS_SETUP_BITS - 1 - k ); } } - num_bits_read += MC_LS_SETUP_BITS; + num_bits_read = add(num_bits_read, MC_LS_SETUP_BITS); /* select MC format mode; reconfigure the MC format decoder */ - if ( ( error = ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } @@ -287,82 +287,82 @@ ivas_error ivas_dec_setup( * Read element mode *-------------------------------------------------------------------*/ - if ( st_ivas->ini_frame == 0 && element_mode_flag ) + IF ( EQ_16(st_ivas->ini_frame, 0) && element_mode_flag ) { /* read stereo technology info */ - if ( ivas_total_brate < MIN_BRATE_MDCT_STEREO ) + IF ( LT_32(ivas_total_brate, MIN_BRATE_MDCT_STEREO )) { /* 1 bit */ - if ( st_ivas->bit_stream[num_bits_read] ) + IF ( st_ivas->bit_stream[num_bits_read] ) { - st_ivas->element_mode_init = 1 + IVAS_CPE_DFT; + st_ivas->element_mode_init = add(1, IVAS_CPE_DFT); } - else + ELSE { - st_ivas->element_mode_init = 0 + IVAS_CPE_DFT; + st_ivas->element_mode_init = add(0, IVAS_CPE_DFT); } } - else + ELSE { st_ivas->element_mode_init = IVAS_CPE_MDCT; } } } - else if ( ivas_total_brate == IVAS_SID_5k2 ) + ELSE IF ( EQ_32(ivas_total_brate, IVAS_SID_5k2 )) { - switch ( st_ivas->sid_format ) + SWITCH ( st_ivas->sid_format ) { case SID_DFT_STEREO: st_ivas->element_mode_init = IVAS_CPE_DFT; - break; + BREAK; case SID_MDCT_STEREO: st_ivas->element_mode_init = IVAS_CPE_MDCT; - break; + BREAK; case SID_ISM: st_ivas->element_mode_init = IVAS_SCE; - break; + BREAK; case SID_MASA_1TC: st_ivas->element_mode_init = IVAS_SCE; st_ivas->nchan_transport = 1; - break; + BREAK; case SID_MASA_2TC: - if ( st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1 - SID_FORMAT_NBITS] == 1 ) + IF ( st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1 - SID_FORMAT_NBITS] == 1 ) { st_ivas->element_mode_init = IVAS_CPE_MDCT; } - else + ELSE { st_ivas->element_mode_init = IVAS_CPE_DFT; } st_ivas->nchan_transport = 2; - break; + BREAK; case SID_SBA_1TC: st_ivas->element_mode_init = IVAS_SCE; - break; + BREAK; case SID_SBA_2TC: st_ivas->element_mode_init = IVAS_CPE_MDCT; - break; + BREAK; } - if ( st_ivas->ini_frame > 0 && st_ivas->ivas_format == SBA_FORMAT ) + IF ( GT_16(st_ivas->ini_frame, 0) && st_ivas->ivas_format == SBA_FORMAT ) { - int16_t nchan_transport_old, nchan_transport; + Word16 nchan_transport_old, nchan_transport; nchan_transport_old = st_ivas->nchan_transport; - nchan_transport = ( st_ivas->sid_format == SID_SBA_2TC ) ? 2 : 1; + nchan_transport = ( EQ_16(st_ivas->sid_format, SID_SBA_2TC )) ? 2 : 1; - if ( ( nchan_transport_old != nchan_transport ) ) + IF ( ( nchan_transport_old != nchan_transport ) ) { /*Setting the default bitrate for the reconfig function*/ - if ( st_ivas->sid_format == SID_SBA_2TC ) + IF ( EQ_16(st_ivas->sid_format, SID_SBA_2TC )) { st_ivas->hDecoderConfig->ivas_total_brate = IVAS_48k; } - else + ELSE { st_ivas->hDecoderConfig->ivas_total_brate = IVAS_24k4; } - if ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_sba_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } @@ -372,13 +372,13 @@ ivas_error ivas_dec_setup( } } - if ( st_ivas->ini_frame == 0 && st_ivas->ivas_format == ISM_FORMAT ) + IF ( EQ_16(st_ivas->ini_frame, 0) && st_ivas->ivas_format == ISM_FORMAT ) { /* read the number of objects */ st_ivas->nchan_transport = 1; nchan_ism = 1; - k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS; - while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS ) + k = (Word16) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS; + WHILE ( st_ivas->bit_stream[k] && LT_16(nchan_ism, MAX_NUM_OBJECTS )) { nchan_ism++; k--; @@ -389,14 +389,14 @@ ivas_error ivas_dec_setup( /* read ism_mode */ st_ivas->ism_mode = ISM_MODE_DISC; - if ( nchan_ism > 2 ) + IF ( GT_16(nchan_ism, 2 )) { k -= nchan_ism; /* SID metadata flags */ idx = st_ivas->bit_stream[k]; - st_ivas->ism_mode = (ISM_MODE) ( idx + 1 ); + st_ivas->ism_mode = (ISM_MODE) add( idx , 1 ); } - if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } @@ -408,14 +408,14 @@ ivas_error ivas_dec_setup( * and number of transport channels *-------------------------------------------------------------------*/ - if ( st_ivas->ini_frame == 0 && st_ivas->ivas_format != UNDEFINED_FORMAT ) + IF ( EQ_16(st_ivas->ini_frame, 0) && st_ivas->ivas_format != UNDEFINED_FORMAT ) { - if ( ( error = doSanityChecks_IVAS( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = doSanityChecks_IVAS( st_ivas ) ) != IVAS_ERR_OK ) { return IVAS_ERROR( error, "Sanity checks failed" ); } - if ( ( error = ivas_init_decoder( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_init_decoder( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -431,9 +431,9 @@ ivas_error ivas_dec_setup( reset_elements( st_ivas ); /* update bitstream buffer pointer -> take into account already read bits */ - if ( ( st_ivas->nSCE > 0 ) || ( st_ivas->nCPE > 0 ) ) + IF ( ( GT_16(st_ivas->nSCE, 0 )) || ( GT_16(st_ivas->nCPE, 0 )) ) { - st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; + st = GT_16( st_ivas->nSCE, 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; st->next_bit_pos = num_bits_read; st->total_brate = ACELP_8k00; /* only temporary initialization - this is needed for get_next_indice() in the frame following NO_DATA frame */ } @@ -450,11 +450,11 @@ ivas_error ivas_dec_setup( static ivas_error ivas_read_format( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t *num_bits_read /* o : number of IVAS signaling bits read from the bitstream */ + Word16 *num_bits_read /* o : number of IVAS signaling bits read from the bitstream */ ) { - int16_t k, idx; - int32_t ivas_total_brate; + Word16 k, idx; + Word32 ivas_total_brate; ivas_error error; error = IVAS_ERR_OK; @@ -463,44 +463,44 @@ static ivas_error ivas_read_format( *num_bits_read = 0; - if ( !st_ivas->bfi && is_DTXrate( ivas_total_brate ) == 0 ) + IF ( !st_ivas->bfi && is_DTXrate( ivas_total_brate ) == 0 ) { /* read IVAS format */ k = 0; - if ( st_ivas->bit_stream[*num_bits_read] ) + IF ( st_ivas->bit_stream[*num_bits_read] ) { k = 1; } k <<= 1; ( *num_bits_read )++; - if ( st_ivas->bit_stream[*num_bits_read] ) + IF ( st_ivas->bit_stream[*num_bits_read] ) { k += 1; } ( *num_bits_read )++; - switch ( k ) + SWITCH ( k ) { case 0: st_ivas->ivas_format = STEREO_FORMAT; - break; + BREAK; case 1: st_ivas->ivas_format = MC_FORMAT; - break; + BREAK; case 2: st_ivas->ivas_format = ISM_FORMAT; - if ( ivas_total_brate >= IVAS_24k4 ) + IF ( ivas_total_brate >= IVAS_24k4 ) { - if ( st_ivas->bit_stream[*num_bits_read] ) + IF ( st_ivas->bit_stream[*num_bits_read] ) { ( *num_bits_read )++; - if ( st_ivas->bit_stream[*num_bits_read] ) + IF ( st_ivas->bit_stream[*num_bits_read] ) { st_ivas->ivas_format = SBA_ISM_FORMAT; } - else + ELSE { st_ivas->ivas_format = MASA_ISM_FORMAT; } @@ -508,13 +508,13 @@ static ivas_error ivas_read_format( ( *num_bits_read )++; } - break; + BREAK; case 3: - if ( st_ivas->bit_stream[*num_bits_read] ) + IF ( st_ivas->bit_stream[*num_bits_read] ) { st_ivas->ivas_format = MASA_FORMAT; } - else + ELSE { st_ivas->ivas_format = SBA_FORMAT; /* read Ambisonic (SBA) planar flag */ @@ -523,72 +523,72 @@ static ivas_error ivas_read_format( /* read Ambisonic (SBA) order */ st_ivas->sba_order = st_ivas->bit_stream[( *num_bits_read ) + 2 + SBA_PLANAR_BITS]; st_ivas->sba_order += 2 * st_ivas->bit_stream[( *num_bits_read ) + 1 + SBA_PLANAR_BITS]; - if ( st_ivas->sba_order == 0 ) + IF ( st_ivas->sba_order == 0 ) { st_ivas->ivas_format = SBA_ISM_FORMAT; } } ( *num_bits_read )++; - break; + BREAK; } } - else if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 ) + ELSE IF ( EQ_16(st_ivas->bfi, 0) && ivas_total_brate == IVAS_SID_5k2 ) { /* read IVAS format in SID frame */ idx = 0; - for ( k = 0; k < SID_FORMAT_NBITS; k++ ) + FOR ( k = 0; k < SID_FORMAT_NBITS; k++ ) { idx += st_ivas->bit_stream[k] << ( SID_FORMAT_NBITS - 1 - k ); } - ( *num_bits_read ) += SID_FORMAT_NBITS; + ( *num_bits_read ) = add(*num_bits_read, SID_FORMAT_NBITS); st_ivas->sid_format = idx; - switch ( idx ) + SWITCH ( idx ) { case SID_DFT_STEREO: case SID_MDCT_STEREO: st_ivas->ivas_format = STEREO_FORMAT; - break; + BREAK; case SID_ISM: st_ivas->ivas_format = ISM_FORMAT; - break; + BREAK; case SID_MULTICHANNEL: st_ivas->ivas_format = MC_FORMAT; - break; + BREAK; case SID_SBA_1TC: st_ivas->ivas_format = SBA_FORMAT; st_ivas->element_mode_init = IVAS_SCE; - break; + BREAK; case SID_SBA_2TC: st_ivas->ivas_format = SBA_FORMAT; st_ivas->element_mode_init = IVAS_CPE_MDCT; - break; + BREAK; case SID_MASA_1TC: st_ivas->ivas_format = MASA_FORMAT; st_ivas->element_mode_init = IVAS_SCE; - break; + BREAK; case SID_MASA_2TC: st_ivas->ivas_format = MASA_FORMAT; - if ( st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] == 1 ) + IF ( st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] == 1 ) { st_ivas->element_mode_init = IVAS_CPE_MDCT; } - else + ELSE { st_ivas->element_mode_init = IVAS_CPE_DFT; } - break; + BREAK; default: /* This should actually be impossible, since only 3 bits are read, so if this happens something is broken */ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Invalid value %c found in SID format field.", st_ivas->sid_format ); } - if ( st_ivas->ivas_format == SBA_FORMAT ) + IF ( st_ivas->ivas_format == SBA_FORMAT ) { - if ( st_ivas->sba_analysis_order == 0 ) + IF ( st_ivas->sba_analysis_order == 0 ) { st_ivas->sba_analysis_order = SBA_FOA_ORDER; } @@ -598,7 +598,7 @@ static ivas_error ivas_read_format( st_ivas->bit_stream += ( *num_bits_read ); ( *num_bits_read ) = 0; } - else + ELSE { /* In SID/NO_DATA frames, use the previous frame IVAS format */ } @@ -615,36 +615,36 @@ static ivas_error ivas_read_format( *-------------------------------------------------------------------*/ /*! r: number of channels to be synthesised */ -int16_t getNumChanSynthesis( +Word16 getNumChanSynthesis( Decoder_Struct *st_ivas /* i : IVAS decoder structure */ ) { - int16_t n; + Word16 n; n = st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE; - if ( st_ivas->sba_dirac_stereo_flag ) + IF ( st_ivas->sba_dirac_stereo_flag ) { n = CPE_CHANNELS; #if 0 /* TODO wkr: this is actually a correct bugfix for OSBA, it is disabled for now to pass the pipelines in the OSBA JBM branch */ - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { n += st_ivas->nchan_ism; } #endif } - else if ( ( st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT ) && st_ivas->ivas_format != SBA_ISM_FORMAT ) + ELSE IF ( ( st_ivas->hMCT != NULL || st_ivas->ivas_format == SBA_FORMAT ) && st_ivas->ivas_format != SBA_ISM_FORMAT ) { n = st_ivas->nchan_transport; } - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + ELSE IF ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { n = st_ivas->nchan_transport + st_ivas->nchan_ism; } - else + ELSE { n = st_ivas->nchan_transport; } @@ -714,9 +714,9 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Custom loudspeaker layout handle *--------------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->Opt_LsCustom ) + IF ( st_ivas->hDecoderConfig->Opt_LsCustom ) { - if ( ( error = ivas_ls_custom_open( &( st_ivas->hLsSetupCustom ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_ls_custom_open( &( st_ivas->hLsSetupCustom ) ) ) != IVAS_ERR_OK ) { return error; } @@ -726,13 +726,13 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Head-Tracking handle *--------------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) + IF ( st_ivas->hDecoderConfig->Opt_Headrotation ) { - if ( ( error = ivas_headTrack_open( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_headTrack_open( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking ) ) != IVAS_ERR_OK ) { return error; } @@ -742,9 +742,9 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize external orientation handle *--------------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) + IF ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - if ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) { return error; } @@ -754,9 +754,9 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize combined orientation handle *--------------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) + IF ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - if ( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) { return error; } @@ -766,23 +766,23 @@ ivas_error ivas_init_decoder_front( * Allocate HRTF binary handle *--------------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) + IF ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) { - if ( ( error = ivas_HRTF_binary_open( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_HRTF_binary_open( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_HRTF_CRend_binary_open( &( st_ivas->hSetOfHRTF ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_HRTF_CRend_binary_open( &( st_ivas->hSetOfHRTF ) ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_HRTF_fastconv_binary_open( &st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_HRTF_fastconv_binary_open( &st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_HRTF_parambin_binary_open( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_HRTF_parambin_binary_open( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } @@ -792,15 +792,15 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Binaural Renderer configuration handle *--------------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB + IF ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_render_config_init_from_rom( &st_ivas->hRenderConfig ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_render_config_init_from_rom( &st_ivas->hRenderConfig ) ) != IVAS_ERR_OK ) { return error; } @@ -820,16 +820,16 @@ ivas_error ivas_init_decoder( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - int16_t i, n, k; - int16_t sce_id, cpe_id; - int16_t numCldfbAnalyses, numCldfbSyntheses; - int16_t granularity, n_channels_transport_jbm; - int32_t output_Fs, ivas_total_brate; - int32_t binauralization_delay_ns; + Word16 i, n, k; + Word16 sce_id, cpe_id; + Word16 numCldfbAnalyses, numCldfbSyntheses; + Word16 granularity, n_channels_transport_jbm; + Word32 output_Fs, ivas_total_brate; + Word32 binauralization_delay_ns; AUDIO_CONFIG output_config; DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; - int32_t ism_total_brate; + Word32 ism_total_brate; error = IVAS_ERR_OK; @@ -845,18 +845,18 @@ ivas_error ivas_init_decoder( * Set number of output channels for EXTERNAL output config. *-----------------------------------------------------------------*/ - if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + IF ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { - if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + IF ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); hDecoderConfig->nchan_out += st_ivas->nchan_ism; } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + ELSE IF ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { hDecoderConfig->nchan_out = st_ivas->nchan_transport + st_ivas->nchan_ism; } - else if ( !( st_ivas->ism_mode == ISM_MODE_PARAM ) ) + ELSE IF ( !( st_ivas->ism_mode == ISM_MODE_PARAM ) ) { hDecoderConfig->nchan_out = st_ivas->nchan_transport; } @@ -872,7 +872,7 @@ ivas_error ivas_init_decoder( ivas_output_init( &( st_ivas->hOutSetup ), output_config ); - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + IF ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; st_ivas->intern_config = IVAS_AUDIO_CONFIG_7_1_4; @@ -880,7 +880,7 @@ ivas_error ivas_init_decoder( st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config ); } - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + IF ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3; @@ -889,12 +889,12 @@ ivas_error ivas_init_decoder( } /* Only initialize transport setup if it is used */ - if ( st_ivas->transport_config != IVAS_AUDIO_CONFIG_INVALID ) + IF ( st_ivas->transport_config != IVAS_AUDIO_CONFIG_INVALID ) { ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config ); } - if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) + IF ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) { ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); @@ -903,9 +903,9 @@ ivas_error ivas_init_decoder( ivas_renderer_select( st_ivas ); - if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - if ( ( error = ivas_ls_custom_output_init( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_ls_custom_output_init( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -913,23 +913,23 @@ ivas_error ivas_init_decoder( ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); - if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) + IF ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) { ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); - if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled ) + IF ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled ) { st_ivas->hLsSetupCustom->separate_ch_found = 0; - if ( st_ivas->hOutSetup.nchan_out_woLFE >= MCMASA_MIN_SPEAKERS_SEPARATE_CENTER ) + IF ( st_ivas->hOutSetup.nchan_out_woLFE >= MCMASA_MIN_SPEAKERS_SEPARATE_CENTER ) { /* check for a speaker at (0, 0) if minimum speaker count is available */ - for ( i = 0; i < st_ivas->hOutSetup.nchan_out_woLFE; i++ ) + FOR ( i = 0; i < st_ivas->hOutSetup.nchan_out_woLFE; i++ ) { - if ( st_ivas->hOutSetup.ls_azimuth[i] == 0.0f && st_ivas->hOutSetup.ls_elevation[i] == 0.0f ) + IF ( st_ivas->hOutSetup.ls_azimuth[i] == 0.0f && st_ivas->hOutSetup.ls_elevation[i] == 0.0f ) { st_ivas->hIntSetup.separateChannelIndex = i; st_ivas->hLsSetupCustom->separate_ch_found = 1; - break; + BREAK; } } } @@ -941,21 +941,21 @@ ivas_error ivas_init_decoder( * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ - if ( st_ivas->ivas_format == MONO_FORMAT ) + IF ( st_ivas->ivas_format == MONO_FORMAT ) { st_ivas->nSCE = 1; /* in mono, there is always only one SCE */ st_ivas->nCPE = 0; st_ivas->nchan_transport = 1; sce_id = 0; - if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK ) + IF ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK ) { return error; } reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } - else if ( st_ivas->ivas_format == STEREO_FORMAT ) + ELSE IF ( st_ivas->ivas_format == STEREO_FORMAT ) { st_ivas->nchan_transport = CPE_CHANNELS; st_ivas->intern_config = IVAS_AUDIO_CONFIG_STEREO; @@ -964,7 +964,7 @@ ivas_error ivas_init_decoder( st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */ cpe_id = 0; - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK ) + IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK ) { return error; } @@ -975,9 +975,9 @@ ivas_error ivas_init_decoder( } /* init EFAP for custom LS output and set hTransSetup */ - if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hOutSetup.ls_azimuth, st_ivas->hOutSetup.ls_elevation, st_ivas->hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) + IF ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hOutSetup.ls_azimuth, st_ivas->hOutSetup.ls_elevation, st_ivas->hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; } @@ -985,34 +985,34 @@ ivas_error ivas_init_decoder( ivas_output_init( &( st_ivas->hTransSetup ), IVAS_AUDIO_CONFIG_STEREO ); } } - else if ( st_ivas->ivas_format == ISM_FORMAT ) + ELSE IF ( st_ivas->ivas_format == ISM_FORMAT ) { - int32_t element_brate_tmp[MAX_NUM_OBJECTS]; + Word32 element_brate_tmp[MAX_NUM_OBJECTS]; st_ivas->nSCE = st_ivas->nchan_transport; /* "st_ivas->nchan_transport" is known from ivas_dec_setup */ st_ivas->nCPE = 0; st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + IF ( st_ivas->ism_mode == ISM_MODE_PARAM ) { st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; st_ivas->nSCE = MAX_PARAM_ISM_WAVE; - if ( ( error = ivas_param_ism_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_param_ism_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nSCE, element_brate_tmp ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nSCE, element_brate_tmp ) ) != IVAS_ERR_OK ) { return error; } - for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { - if ( ( error = create_sce_dec( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK ) + IF ( ( error = create_sce_dec( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK ) { return error; } @@ -1024,66 +1024,66 @@ ivas_error ivas_init_decoder( st_ivas->hISMDTX.sce_id_dtx = 0; - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + IF ( st_ivas->ism_mode == ISM_MODE_PARAM ) { st_ivas->hSCE[1]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed3 = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->seed2; } } - else if ( st_ivas->ivas_format == SBA_FORMAT ) + ELSE IF ( st_ivas->ivas_format == SBA_FORMAT ) { - if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) { return error; } - if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup ) + IF ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup ) { - if ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) { return error; } } - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) { return error; } - if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) + IF ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) { - if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; } - else + ELSE { - int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; + Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1]; st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); - if ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) + IF ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) { st_ivas->hSpar->enc_param_start_band = 0; - set_c( (int8_t *) st_ivas->hQMetaData->twoDirBands, (int8_t) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); - st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; + set_c( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); + st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); - for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { - if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) + IF ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) { return error; } @@ -1091,23 +1091,23 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } - for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) + IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) { return error; } - for ( n = 0; n < CPE_CHANNELS; n++ ) + FOR ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } } /* create CPE element for DFT Stereo like upmix */ - if ( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 ) + IF ( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 ) { - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) + IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) { return error; } @@ -1116,9 +1116,9 @@ ivas_error ivas_init_decoder( st_ivas->hCPE[0]->hCoreCoder[1] = NULL; } - if ( st_ivas->nCPE > 1 ) + IF ( st_ivas->nCPE > 1 ) { - if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -1127,32 +1127,32 @@ ivas_error ivas_init_decoder( /* set CNA/CNG flags */ ivas_sba_set_cna_cng_flag( st_ivas ); } - else if ( st_ivas->ivas_format == MASA_FORMAT ) + ELSE IF ( st_ivas->ivas_format == MASA_FORMAT ) { /* if we start in ISM_MODE_NONE in MASA_ISM, that appears as normal MASA, but we may change to a mode with ISMs */ st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; - if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } - if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + IF ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { - if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } } - for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { - if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) + IF ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) { return error; } @@ -1160,14 +1160,14 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } - for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) + IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) { return error; } - for ( n = 0; n < CPE_CHANNELS; n++ ) + FOR ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } @@ -1176,66 +1176,66 @@ ivas_error ivas_init_decoder( /* set CNA/CNG flags */ ivas_sba_set_cna_cng_flag( st_ivas ); } - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + ELSE IF ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - int32_t temp_brate[MAX_SCE]; + Word32 temp_brate[MAX_SCE]; st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); - if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK ) { return error; } - if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup ) + IF ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->hOutSetup.is_loudspeaker_setup ) { - if ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_sba_get_hoa_dec_matrix( st_ivas->hOutSetup, &st_ivas->hoa_dec_mtx, st_ivas->hIntSetup.ambisonics_order ) ) != IVAS_ERR_OK ) { return error; } } - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) { return error; } - if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) + IF ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) { - if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; } - else + ELSE { - int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; + Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1]; st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); - if ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) + IF ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) { st_ivas->hSpar->enc_param_start_band = 0; - set_c( (int8_t *) st_ivas->hQMetaData->twoDirBands, (int8_t) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); - st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; + set_c( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); + st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } - for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { - if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) + IF ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) { return error; } @@ -1243,29 +1243,29 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; st_ivas->element_mode_init = IVAS_CPE_MDCT; } - for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) + IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) { return error; } - for ( n = 0; n < CPE_CHANNELS; n++ ) + FOR ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } } /* create CPE element for DFT Stereo like upmix */ - if ( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 ) + IF ( st_ivas->sba_dirac_stereo_flag && st_ivas->nCPE == 0 ) { - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) + IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) { return error; } @@ -1274,22 +1274,22 @@ ivas_error ivas_init_decoder( st_ivas->hCPE[0]->hCoreCoder[1] = NULL; } - if ( st_ivas->nCPE > 1 ) + IF ( st_ivas->nCPE > 1 ) { - if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_osba_data_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_osba_data_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -1298,52 +1298,52 @@ ivas_error ivas_init_decoder( /* set CNA/CNG flags */ ivas_sba_set_cna_cng_flag( st_ivas ); } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + ELSE IF ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; - if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; } k = 0; ism_total_brate = 0; - while ( k < SIZE_IVAS_BRATE_TBL && ivas_total_brate != ivas_brate_tbl[k] ) + WHILE ( LT_16(k, SIZE_IVAS_BRATE_TBL) && NE_32(ivas_total_brate, ivas_brate_tbl[k] )) { k++; } - if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + IF ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { /* one separated object */ st_ivas->nSCE = 1; ism_total_brate = sep_object_brate[k - 2][0]; - if ( ( error = create_sce_dec( st_ivas, 0, ism_total_brate ) ) != IVAS_ERR_OK ) + IF ( ( error = create_sce_dec( st_ivas, 0, ism_total_brate ) ) != IVAS_ERR_OK ) { return error; } reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] ); - if ( ( error = ivas_ism_metadata_dec_create( st_ivas, 1, NULL ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_ism_metadata_dec_create( st_ivas, 1, NULL ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + ELSE IF ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - int32_t temp_brate[MAX_SCE]; + Word32 temp_brate[MAX_SCE]; st_ivas->nSCE = st_ivas->nchan_ism; /* number of objects */ - for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { temp_brate[sce_id] = sep_object_brate[k - 2][st_ivas->nSCE - 1]; ism_total_brate += temp_brate[sce_id]; - if ( ( error = create_sce_dec( st_ivas, sce_id, temp_brate[sce_id] ) ) != IVAS_ERR_OK ) + IF ( ( error = create_sce_dec( st_ivas, sce_id, temp_brate[sce_id] ) ) != IVAS_ERR_OK ) { return error; } @@ -1351,48 +1351,48 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } - if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) { return error; } } - if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_omasa_data_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } - if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + IF ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { - if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } } - if ( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate - ism_total_brate ) ) != IVAS_ERR_OK ) + IF ( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate - ism_total_brate ) ) != IVAS_ERR_OK ) { return error; } - for ( n = 0; n < CPE_CHANNELS; n++ ) + FOR ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[0]->hCoreCoder[n] ); } } - else if ( st_ivas->ivas_format == MC_FORMAT ) + ELSE IF ( st_ivas->ivas_format == MC_FORMAT ) { - if ( st_ivas->mc_mode == MC_MODE_MCT ) + IF ( st_ivas->mc_mode == MC_MODE_MCT ) { /* init EFAP for custom LS setup */ - if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) + IF ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; } @@ -1404,30 +1404,30 @@ ivas_error ivas_init_decoder( st_ivas->element_mode_init = IVAS_CPE_MDCT; - for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) + IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) { return error; } - for ( n = 0; n < CPE_CHANNELS; n++ ) + FOR ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } } - if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + ELSE IF ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { /* init EFAP for custom LS setup */ - if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) + IF ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; } @@ -1437,103 +1437,103 @@ ivas_error ivas_init_decoder( st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / CPE_CHANNELS; st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; - if ( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } st_ivas->element_mode_init = IVAS_CPE_MDCT; - for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) + IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) * CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) { return error; } - for ( n = 0; n < CPE_CHANNELS; n++ ) + FOR ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } } - if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + ELSE IF ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { /* init EFAP for custom LS setup */ - if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { - if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) + IF ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; } } - if ( ( error = ivas_param_mc_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_param_mc_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } - for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) + IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) { return error; } - for ( n = 0; n < CPE_CHANNELS; n++ ) + FOR ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } } - if ( st_ivas->nCPE > 1 ) + IF ( GT_16(st_ivas->nCPE, 1 )) { - if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } } - else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + ELSE IF ( st_ivas->mc_mode == MC_MODE_MCMASA ) { - int32_t brate_sce, brate_cpe; + Word32 brate_sce, brate_cpe; ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); - if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); - if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_MCMASA_MONO_STEREO ) + IF ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_MCMASA_MONO_STEREO ) { - if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } } - if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled && !st_ivas->hLsSetupCustom->separate_ch_found ) + IF ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled && !st_ivas->hLsSetupCustom->separate_ch_found ) { /* If no speaker matching the separated channel, compute panning gains for the separated channel. */ - if ( st_ivas->hVBAPdata == NULL ) + IF ( st_ivas->hVBAPdata == NULL ) { /* Distribute signal to all channels if VBAP is not properly initialized. */ set_f( st_ivas->hLsSetupCustom->separate_ch_gains, inv_sqrt( st_ivas->hLsSetupCustom->num_spk ), st_ivas->hLsSetupCustom->num_spk ); } - else + ELSE { vbap_determine_gains( st_ivas->hVBAPdata, st_ivas->hLsSetupCustom->separate_ch_gains, 0, 0, 0 ); } @@ -1541,9 +1541,9 @@ ivas_error ivas_init_decoder( ivas_mcmasa_split_brate( st_ivas->hOutSetup.separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); - for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) + FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { - if ( ( error = create_sce_dec( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK ) + IF ( ( error = create_sce_dec( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK ) { return error; } @@ -1551,25 +1551,25 @@ ivas_error ivas_init_decoder( reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] ); } - for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) + FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { st_ivas->element_mode_init = IVAS_CPE_MDCT; /* element_mode_init was IVAS_SCE for SCE initialization */ - if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK ) + IF ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK ) { return error; } - for ( n = 0; n < CPE_CHANNELS; n++ ) + FOR ( n = 0; n < CPE_CHANNELS; n++ ) { reset_indices_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n] ); } } /* create CPE element for DFT Stereo like upmix */ - if ( st_ivas->sba_dirac_stereo_flag ) + IF ( st_ivas->sba_dirac_stereo_flag ) { - if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) + IF ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK ) { return error; } @@ -1579,7 +1579,7 @@ ivas_error ivas_init_decoder( } /* set CNA/CNG flags */ - if ( st_ivas->nchan_transport == 1 && ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) + IF ( EQ_16(st_ivas->nchan_transport, 1) && ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 1; st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 1; @@ -1595,21 +1595,21 @@ ivas_error ivas_init_decoder( /* set number of output channels used for synthesis/decoding */ n = getNumChanSynthesis( st_ivas ); - if ( n > 0 ) + IF ( GT_16(n, 0 )) { - if ( ( st_ivas->mem_hp20_out = (float **) malloc( n * sizeof( float * ) ) ) == NULL ) + IF ( ( st_ivas->mem_hp20_out = (float **) malloc( n * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } } - else + ELSE { st_ivas->mem_hp20_out = NULL; } - for ( i = 0; i < n; i++ ) + FOR ( i = 0; i < n; i++ ) { - if ( ( st_ivas->mem_hp20_out[i] = (float *) malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL ) + IF ( ( st_ivas->mem_hp20_out[i] = (float *) malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } @@ -1621,82 +1621,82 @@ ivas_error ivas_init_decoder( * Allocate and initialize rendering handles *--------------------------------------------------------------------*/ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + IF ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { - if ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } /* ParamISM is handled separately from other common config */ - else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) + ELSE IF ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) { - if ( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) + IF ( st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { - if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } } - if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) + ELSE IF ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } - if ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + IF ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } } - if ( st_ivas->hDecoderConfig->Opt_5ms ) + IF ( NE_16(st_ivas->hDecoderConfig->Opt_5ms, 0) ) { granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; } } } - else if ( st_ivas->renderer_type == RENDERER_MC ) + ELSE IF ( st_ivas->renderer_type == RENDERER_MC ) { - if ( ( error = ivas_ls_setup_conversion_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_ls_setup_conversion_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + ELSE IF ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { - if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + ELSE IF ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + IF ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->ivas_format == MC_FORMAT && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) { - if ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth, st_ivas->hIntSetup.ls_elevation, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) + IF ( ( error = efap_init_data( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth, st_ivas->hIntSetup.ls_elevation, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ) != IVAS_ERR_OK ) { return error; } } - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + IF ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; @@ -1704,26 +1704,26 @@ ivas_error ivas_init_decoder( st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; - if ( st_ivas->hDecoderConfig->Opt_5ms ) + IF ( NE_16(st_ivas->hDecoderConfig->Opt_5ms, 0) ) { - if ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) + IF ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) { granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, MC_PARAMUPMIX_MAX_INPUT_CHANS, MC_PARAMUPMIX_MAX_INPUT_CHANS, granularity ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, MC_PARAMUPMIX_MAX_INPUT_CHANS, MC_PARAMUPMIX_MAX_INPUT_CHANS, granularity ) ) != IVAS_ERR_OK ) { return error; } } - else + ELSE { granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; } @@ -1731,34 +1731,34 @@ ivas_error ivas_init_decoder( } } - if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + IF ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + IF ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { /* Allocate TD renderer for the objects in DISC mode */ - if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ - if ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - if ( st_ivas->renderer_type == RENDERER_DIRAC && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + IF ( st_ivas->renderer_type == RENDERER_DIRAC && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ - if ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } } - if ( ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && + IF ( ( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->ism_mode == ISM_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) && ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || @@ -1770,18 +1770,18 @@ ivas_error ivas_init_decoder( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { - if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } - if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + IF ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF ( ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { /* Allocate TD renderer for the objects in DISC mode */ - if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -1792,25 +1792,25 @@ ivas_error ivas_init_decoder( * LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay *-----------------------------------------------------------------*/ - if ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + IF ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { binauralization_delay_ns = st_ivas->binaural_latency_ns; - if ( st_ivas->hBinRenderer != NULL ) + IF ( st_ivas->hBinRenderer != NULL ) { - if ( st_ivas->hBinRenderer->render_lfe ) + IF ( st_ivas->hBinRenderer->render_lfe ) { { /* Account for filterbank delay */ binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS; } } - else + ELSE { binauralization_delay_ns = 0; } } - if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK ) { return error; } @@ -1825,32 +1825,32 @@ ivas_error ivas_init_decoder( ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses ); - for ( i = 0; i < numCldfbAnalyses; i++ ) + FOR ( i = 0; i < numCldfbAnalyses; i++ ) { - if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + IF ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } } - for ( ; i < MAX_INTERN_CHANNELS; i++ ) + FOR ( ; i < MAX_INTERN_CHANNELS; i++ ) { st_ivas->cldfbAnaDec[i] = NULL; } - for ( i = 0; i < numCldfbSyntheses; i++ ) + FOR ( i = 0; i < numCldfbSyntheses; i++ ) { - if ( ( error = openCldfb( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + IF ( ( error = openCldfb( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } } - for ( ; i < MAX_OUTPUT_CHANNELS; i++ ) + FOR ( ; i < MAX_OUTPUT_CHANNELS; i++ ) { st_ivas->cldfbSynDec[i] = NULL; } /* CLDFB Interpolation weights */ - if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 ) + IF ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !st_ivas->sba_dirac_stereo_flag && st_ivas->hDecoderConfig->nchan_out != 1 ) { ivas_spar_get_cldfb_gains( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig ); } @@ -1859,7 +1859,7 @@ ivas_error ivas_init_decoder( * Allocate and initialize limiter struct *-----------------------------------------------------------------*/ - if ( ( error = ivas_limiter_open( &st_ivas->hLimiter, hDecoderConfig->nchan_out, output_Fs ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_limiter_open( &st_ivas->hLimiter, hDecoderConfig->nchan_out, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -1868,31 +1868,31 @@ ivas_error ivas_init_decoder( * Allocate and initialize JBM struct + buffer *-----------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL ) + IF ( NE_16(st_ivas->hDecoderConfig->Opt_5ms, 0) && st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } } - if ( st_ivas->hTcBuffer == NULL ) + IF ( st_ivas->hTcBuffer == NULL ) { /* we need the handle anyway, but without the buffer*/ - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ) != IVAS_ERR_OK ) { return error; } } - if ( st_ivas->hJbmMetadata == NULL ) + IF ( st_ivas->hJbmMetadata == NULL ) { - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + IF ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { - if ( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } @@ -1903,23 +1903,23 @@ ivas_error ivas_init_decoder( * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ - if ( !st_ivas->hDecoderConfig->Opt_5ms ) + IF ( EQ_16(st_ivas->hDecoderConfig->Opt_5ms, 0) ) { - for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) + FOR ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) { /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) + IF ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } } } - else + ELSE { n = 0; } - for ( ; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) + FOR ( ; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { st_ivas->p_output_f[n] = NULL; } @@ -1940,127 +1940,127 @@ void destroy_core_dec( { destroy_cldfb_decoder( hCoreCoder ); - if ( hCoreCoder->hGSCDec != NULL ) + IF ( hCoreCoder->hGSCDec != NULL ) { free( hCoreCoder->hGSCDec ); hCoreCoder->hGSCDec = NULL; } - if ( hCoreCoder->hPFstat != NULL ) + IF ( hCoreCoder->hPFstat != NULL ) { free( hCoreCoder->hPFstat ); hCoreCoder->hPFstat = NULL; } - if ( hCoreCoder->hMusicPF != NULL ) + IF ( hCoreCoder->hMusicPF != NULL ) { free( hCoreCoder->hMusicPF ); hCoreCoder->hMusicPF = NULL; } - if ( hCoreCoder->hBPF != NULL ) + IF ( hCoreCoder->hBPF != NULL ) { free( hCoreCoder->hBPF ); hCoreCoder->hBPF = NULL; } - if ( hCoreCoder->hBWE_zero != NULL ) + IF ( hCoreCoder->hBWE_zero != NULL ) { free( hCoreCoder->hBWE_zero ); hCoreCoder->hBWE_zero = NULL; } - if ( hCoreCoder->hTdCngDec != NULL ) + IF ( hCoreCoder->hTdCngDec != NULL ) { free( hCoreCoder->hTdCngDec ); hCoreCoder->hTdCngDec = NULL; } - if ( hCoreCoder->hSC_VBR != NULL ) + IF ( hCoreCoder->hSC_VBR != NULL ) { free( hCoreCoder->hSC_VBR ); hCoreCoder->hSC_VBR = NULL; } - if ( hCoreCoder->hAmrwb_IO != NULL ) + IF ( hCoreCoder->hAmrwb_IO != NULL ) { free( hCoreCoder->hAmrwb_IO ); hCoreCoder->hAmrwb_IO = NULL; } - if ( hCoreCoder->hBWE_TD != NULL ) + IF ( hCoreCoder->hBWE_TD != NULL ) { free( hCoreCoder->hBWE_TD ); hCoreCoder->hBWE_TD = NULL; } - if ( hCoreCoder->hBWE_FD != NULL ) + IF ( hCoreCoder->hBWE_FD != NULL ) { free( hCoreCoder->hBWE_FD ); hCoreCoder->hBWE_FD = NULL; } - if ( hCoreCoder->hBWE_FD_HR != NULL ) + IF ( hCoreCoder->hBWE_FD_HR != NULL ) { free( hCoreCoder->hBWE_FD_HR ); hCoreCoder->hBWE_FD_HR = NULL; } - if ( hCoreCoder->hWIDec != NULL ) + IF ( hCoreCoder->hWIDec != NULL ) { free( hCoreCoder->hWIDec ); hCoreCoder->hWIDec = NULL; } - if ( hCoreCoder->hTECDec != NULL ) + IF ( hCoreCoder->hTECDec != NULL ) { free( hCoreCoder->hTECDec ); hCoreCoder->hTECDec = NULL; } - if ( hCoreCoder->hTcxLtpDec != NULL ) + IF ( hCoreCoder->hTcxLtpDec != NULL ) { free( hCoreCoder->hTcxLtpDec ); hCoreCoder->hTcxLtpDec = NULL; } - if ( hCoreCoder->hTcxDec != NULL ) + IF ( hCoreCoder->hTcxDec != NULL ) { free( hCoreCoder->hTcxDec ); hCoreCoder->hTcxDec = NULL; } - if ( hCoreCoder->hTcxCfg != NULL ) + IF ( hCoreCoder->hTcxCfg != NULL ) { free( hCoreCoder->hTcxCfg ); hCoreCoder->hTcxCfg = NULL; } - if ( hCoreCoder->hTonalMDCTConc != NULL ) + IF ( hCoreCoder->hTonalMDCTConc != NULL ) { free( hCoreCoder->hTonalMDCTConc ); hCoreCoder->hTonalMDCTConc = NULL; } - if ( hCoreCoder->hIGFDec != NULL ) + IF ( hCoreCoder->hIGFDec != NULL ) { free( hCoreCoder->hIGFDec ); hCoreCoder->hIGFDec = NULL; } - if ( hCoreCoder->hPlcInfo != NULL ) + IF ( hCoreCoder->hPlcInfo != NULL ) { free( hCoreCoder->hPlcInfo ); hCoreCoder->hPlcInfo = NULL; } - if ( hCoreCoder->hHQ_core != NULL ) + IF ( hCoreCoder->hHQ_core != NULL ) { free( hCoreCoder->hHQ_core ); hCoreCoder->hHQ_core = NULL; } - if ( hCoreCoder->hHQ_nbfec != NULL ) + IF ( hCoreCoder->hHQ_nbfec != NULL ) { free( hCoreCoder->hHQ_nbfec ); hCoreCoder->hHQ_nbfec = NULL; @@ -2080,26 +2080,26 @@ void ivas_initialize_handles_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - int16_t i; + Word16 i; - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) + FOR ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) { st_ivas->cldfbAnaDec[i] = NULL; } - for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { st_ivas->cldfbSynDec[i] = NULL; } /* SCE handles */ - for ( i = 0; i < MAX_SCE; i++ ) + FOR ( i = 0; i < MAX_SCE; i++ ) { st_ivas->hSCE[i] = NULL; } /* CPE handles */ - for ( i = 0; i < MAX_CPE; i++ ) + FOR ( i = 0; i < MAX_CPE; i++ ) { st_ivas->hCPE[i] = NULL; } @@ -2109,7 +2109,7 @@ void ivas_initialize_handles_dec( st_ivas->hLimiter = NULL; /* ISM metadata handles */ - for ( i = 0; i < MAX_NUM_OBJECTS; i++ ) + FOR ( i = 0; i < MAX_NUM_OBJECTS; i++ ) { st_ivas->hIsmMetaData[i] = NULL; } @@ -2158,7 +2158,7 @@ void ivas_initialize_handles_dec( st_ivas->hJbmMetadata = NULL; /* floating-point output audio buffers */ - for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) + FOR ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { st_ivas->p_output_f[i] = NULL; } @@ -2177,29 +2177,29 @@ void ivas_destroy_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) { - int16_t i; + Word16 i; /* CLDFB handles */ - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) + FOR ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) { - if ( st_ivas->cldfbAnaDec[i] != NULL ) + IF ( st_ivas->cldfbAnaDec[i] != NULL ) { deleteCldfb( &( st_ivas->cldfbAnaDec[i] ) ); } } - for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { - if ( st_ivas->cldfbSynDec[i] != NULL ) + IF ( st_ivas->cldfbSynDec[i] != NULL ) { deleteCldfb( &( st_ivas->cldfbSynDec[i] ) ); } } /* SCE handles */ - for ( i = 0; i < MAX_SCE; i++ ) + FOR ( i = 0; i < MAX_SCE; i++ ) { - if ( st_ivas->hSCE[i] != NULL ) + IF ( st_ivas->hSCE[i] != NULL ) { destroy_sce_dec( st_ivas->hSCE[i] ); st_ivas->hSCE[i] = NULL; @@ -2207,12 +2207,12 @@ void ivas_destroy_dec( } /* CPE handles */ - for ( i = 0; i < MAX_CPE; i++ ) + FOR ( i = 0; i < MAX_CPE; i++ ) { - if ( st_ivas->hCPE[i] != NULL ) + IF ( st_ivas->hCPE[i] != NULL ) { /* set pointer to NULL as core coder already deallocated in destroy_sce_dec() */ - if ( st_ivas->sba_dirac_stereo_flag && st_ivas->nchan_transport == 1 ) + IF ( st_ivas->sba_dirac_stereo_flag && st_ivas->nchan_transport == 1 ) { st_ivas->hCPE[i]->hCoreCoder[0] = NULL; st_ivas->hCPE[i]->hCoreCoder[1] = NULL; @@ -2223,9 +2223,9 @@ void ivas_destroy_dec( } /* HP20 filter handles */ - if ( st_ivas->mem_hp20_out != NULL ) + IF ( st_ivas->mem_hp20_out != NULL ) { - for ( i = 0; i < getNumChanSynthesis( st_ivas ); i++ ) + FOR ( i = 0; i < getNumChanSynthesis( st_ivas ); i++ ) { free( st_ivas->mem_hp20_out[i] ); st_ivas->mem_hp20_out[i] = NULL; @@ -2241,11 +2241,11 @@ void ivas_destroy_dec( ivas_ism_renderer_close( &( st_ivas->hIsmRendererData ) ); /* DirAC handle */ - if ( st_ivas->ivas_format == ISM_FORMAT ) + IF ( st_ivas->ivas_format == ISM_FORMAT ) { ivas_param_ism_dec_close( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); } - else + ELSE { ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); @@ -2256,7 +2256,7 @@ void ivas_destroy_dec( ivas_spar_dec_close( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 ); /* HOA decoder matrix */ - if ( st_ivas->hoa_dec_mtx != NULL ) + IF ( st_ivas->hoa_dec_mtx != NULL ) { free( st_ivas->hoa_dec_mtx ); st_ivas->hoa_dec_mtx = NULL; @@ -2304,7 +2304,7 @@ void ivas_destroy_dec( ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); /* Custom LS configuration handle */ - if ( st_ivas->hLsSetupCustom != NULL ) + IF ( st_ivas->hLsSetupCustom != NULL ) { free( st_ivas->hLsSetupCustom ); st_ivas->hLsSetupCustom = NULL; @@ -2329,11 +2329,11 @@ void ivas_destroy_dec( ivas_combined_orientation_close( &st_ivas->hCombinedOrientationData ); /* Time Domain binaural renderer handle */ - if ( st_ivas->hBinRendererTd != NULL ) + IF ( st_ivas->hBinRendererTd != NULL ) { ivas_td_binaural_close( &st_ivas->hBinRendererTd ); } - else if ( st_ivas->hHrtfTD != NULL ) + ELSE IF ( st_ivas->hHrtfTD != NULL ) { BSplineModelEvalDealloc( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); @@ -2358,7 +2358,7 @@ void ivas_destroy_dec( /* Limiter struct */ ivas_limiter_close( &( st_ivas->hLimiter ) ); - if ( st_ivas->hDecoderConfig != NULL ) + IF ( st_ivas->hDecoderConfig != NULL ) { free( st_ivas->hDecoderConfig ); st_ivas->hDecoderConfig = NULL; @@ -2366,16 +2366,16 @@ void ivas_destroy_dec( ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer ); - if ( st_ivas->hJbmMetadata != NULL ) + IF ( st_ivas->hJbmMetadata != NULL ) { free( st_ivas->hJbmMetadata ); st_ivas->hJbmMetadata = NULL; } /* floating-point output audio buffers */ - for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) + FOR ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { - if ( st_ivas->p_output_f[i] != NULL ) + IF ( st_ivas->p_output_f[i] != NULL ) { free( st_ivas->p_output_f[i] ); st_ivas->p_output_f[i] = NULL; @@ -2398,8 +2398,8 @@ void ivas_destroy_dec( /*! r: number of cldfb instances */ void ivas_init_dec_get_num_cldfb_instances( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ - int16_t *numCldfbAnalyses, /* o : number of needed CLDFB analysis instances */ - int16_t *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */ + Word16 *numCldfbAnalyses, /* o : number of needed CLDFB analysis instances */ + Word16 *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */ ) { IVAS_FORMAT ivas_format; @@ -2408,104 +2408,104 @@ void ivas_init_dec_get_num_cldfb_instances( ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ - switch ( st_ivas->renderer_type ) + SWITCH ( st_ivas->renderer_type ) { case RENDERER_BINAURAL_PARAMETRIC: case RENDERER_BINAURAL_PARAMETRIC_ROOM: case RENDERER_STEREO_PARAMETRIC: - if ( st_ivas->nchan_transport == 1 ) + IF ( st_ivas->nchan_transport == 1 ) { *numCldfbAnalyses = st_ivas->nchan_transport + 1; } - if ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hOutSetup.separateChannelEnabled ) + IF ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hOutSetup.separateChannelEnabled ) { *numCldfbAnalyses = st_ivas->nchan_transport + 1; } - if ( ivas_format == SBA_ISM_FORMAT ) + IF ( ivas_format == SBA_ISM_FORMAT ) { - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { *numCldfbAnalyses += st_ivas->nchan_ism; } } - if ( ivas_format == MASA_ISM_FORMAT ) + IF ( ivas_format == MASA_ISM_FORMAT ) { - if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + IF ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { *numCldfbAnalyses += st_ivas->nchan_ism; } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + ELSE IF ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { *numCldfbAnalyses = st_ivas->nchan_transport + 1; } } - if ( st_ivas->hDiracDecBin->useTdDecorr ) + IF ( st_ivas->hDiracDecBin->useTdDecorr ) { *numCldfbAnalyses += 2; } - break; + BREAK; case RENDERER_NON_DIEGETIC_DOWNMIX: case RENDERER_MONO_DOWNMIX: - if ( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT || ivas_format == SBA_ISM_FORMAT ) + IF ( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT || ivas_format == SBA_ISM_FORMAT ) { /* CLDFB not used in rendering */ *numCldfbAnalyses = 0; *numCldfbSyntheses = 0; } - break; + BREAK; case RENDERER_DIRAC: - if ( ivas_format == SBA_FORMAT ) + IF ( ivas_format == SBA_FORMAT ) { *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; - if ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) + IF ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) { *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE; } - else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA ) + ELSE IF ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA ) { *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans; } - else + ELSE { *numCldfbSyntheses = MAX_OUTPUT_CHANNELS; } } - if ( ivas_format != SBA_FORMAT ) + IF ( ivas_format != SBA_FORMAT ) { - if ( st_ivas->nchan_transport > 2 && st_ivas->sba_planar ) + IF ( GT_16(st_ivas->nchan_transport, 2) && NE_16(st_ivas->sba_planar, 0) ) { - *numCldfbAnalyses = st_ivas->nchan_transport + 1; + *numCldfbAnalyses = add(st_ivas->nchan_transport, 1); } - else if ( st_ivas->nchan_transport == 1 && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + ELSE IF ( EQ_16(st_ivas->nchan_transport, 1) && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - *numCldfbAnalyses = st_ivas->nchan_transport + 1; + *numCldfbAnalyses = add(st_ivas->nchan_transport, 1); } } - break; + BREAK; case RENDERER_MC_PARAMMC: - if ( st_ivas->hDecoderConfig->nchan_out <= 2 ) + IF ( LE_16(st_ivas->hDecoderConfig->nchan_out, 2 )) { /* CLDFB not used in rendering */ *numCldfbAnalyses = 0; *numCldfbSyntheses = 0; } - else + ELSE { *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses( st_ivas ); } - break; + BREAK; case RENDERER_PARAM_ISM: /* Already correct with no exception */ - break; + BREAK; case RENDERER_DISABLE: /* CLDFB not used */ *numCldfbAnalyses = 0; *numCldfbSyntheses = 0; - break; + BREAK; case RENDERER_MC: case RENDERER_SBA_LINEAR_DEC: case RENDERER_TD_PANNING: @@ -2518,79 +2518,79 @@ void ivas_init_dec_get_num_cldfb_instances( case RENDERER_OSBA_STEREO: case RENDERER_OSBA_AMBI: case RENDERER_OSBA_LS: - if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) + IF ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) { - if ( st_ivas->sba_dirac_stereo_flag ) + IF ( NE_16(st_ivas->sba_dirac_stereo_flag, 0) ) { *numCldfbAnalyses = 0; *numCldfbSyntheses = 0; } - else + ELSE { *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; - if ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) + IF ( st_ivas->hOutSetup.is_loudspeaker_setup && st_ivas->renderer_type == RENDERER_DIRAC ) { *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE; } - else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA ) + ELSE IF ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA ) { *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans; } - else + ELSE { *numCldfbSyntheses = MAX_OUTPUT_CHANNELS; } - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + IF ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { *numCldfbAnalyses = st_ivas->nchan_ism + st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; } } } - else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + ELSE IF ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { /* do nothing for ParamMC */ } - else + ELSE { /* CLDFB not used in rendering */ *numCldfbAnalyses = 0; *numCldfbSyntheses = 0; } - break; + BREAK; case RENDERER_SBA_LINEAR_ENC: - if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + IF ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses( st_ivas ); } - else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + ELSE IF ( st_ivas->ism_mode == ISM_MODE_PARAM ) { *numCldfbSyntheses = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; } - else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + ELSE IF ( st_ivas->mc_mode == MC_MODE_MCMASA ) { *numCldfbAnalyses = st_ivas->nchan_transport; *numCldfbSyntheses = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; } - else + ELSE { /* CLDFB not used in rendering */ *numCldfbAnalyses = 0; *numCldfbSyntheses = 0; } - break; + BREAK; default: assert( 0 && "Renderer not handled for CLDFB reservation." ); } - if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) + IF ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) { - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + IF ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { *numCldfbAnalyses = max( MC_PARAMUPMIX_MAX_INPUT_CHANS, *numCldfbAnalyses ); } - else + ELSE { *numCldfbAnalyses = max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbAnalyses ); } @@ -2612,7 +2612,7 @@ static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - int32_t output_Fs; + Word32 output_Fs; AUDIO_CONFIG output_config; output_Fs = st_ivas->hDecoderConfig->output_Fs; @@ -2622,7 +2622,7 @@ static ivas_error doSanityChecks_IVAS( * Sanity checks *-----------------------------------------------------------------*/ - if ( output_Fs == 8000 ) + IF ( output_Fs == 8000 ) { return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "8kHz output sampling rate is not supported in IVAS." ); } @@ -2631,88 +2631,88 @@ static ivas_error doSanityChecks_IVAS( assert( st_ivas->ivas_format != MONO_FORMAT && "\n Wrong IVAS format: MONO" ); /* Verify output configuration compatible with non-diegetic panning */ - if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan && ( st_ivas->ivas_format != MONO_FORMAT ) && ( st_ivas->transport_config != IVAS_AUDIO_CONFIG_ISM1 ) ) + IF ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan && ( st_ivas->ivas_format != MONO_FORMAT ) && ( st_ivas->transport_config != IVAS_AUDIO_CONFIG_ISM1 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Non-diegetic panning not supported in this IVAS format" ); } /* Verify stereo output configuration */ - if ( st_ivas->ivas_format == STEREO_FORMAT ) + IF ( st_ivas->ivas_format == STEREO_FORMAT ) { - if ( output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO && output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF ( output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO && output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM ) { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Wrong output configuration specified for Stereo!" ); } } - else if ( st_ivas->ivas_format == ISM_FORMAT ) + ELSE IF ( st_ivas->ivas_format == ISM_FORMAT ) { /* Verify ISM output configuration */ - if ( output_config == IVAS_AUDIO_CONFIG_INVALID ) + IF ( output_config == IVAS_AUDIO_CONFIG_INVALID ) { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for ISM" ); } } - else if ( st_ivas->ivas_format == SBA_FORMAT ) + ELSE IF ( st_ivas->ivas_format == SBA_FORMAT ) { /* Verify SBA output coniguration */ - if ( output_config == IVAS_AUDIO_CONFIG_INVALID ) + IF ( output_config == IVAS_AUDIO_CONFIG_INVALID ) { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for SBA" ); } } - else if ( st_ivas->ivas_format == MASA_FORMAT ) + ELSE IF ( st_ivas->ivas_format == MASA_FORMAT ) { - if ( output_config == IVAS_AUDIO_CONFIG_INVALID ) + IF ( output_config == IVAS_AUDIO_CONFIG_INVALID ) { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for MASA!" ); } } - else if ( st_ivas->ivas_format == MC_FORMAT ) + ELSE IF ( st_ivas->ivas_format == MC_FORMAT ) { /* Verify MC output configuration */ - if ( output_config == IVAS_AUDIO_CONFIG_INVALID || output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + IF ( output_config == IVAS_AUDIO_CONFIG_INVALID || output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for Multi-channel" ); } } - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) + IF ( st_ivas->hDecoderConfig->Opt_Headrotation ) { - if ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB + IF ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { return IVAS_ERROR( IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED, "Wrong set-up: Head-rotation not supported in this configuration" ); } } - if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) + IF ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - if ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { return IVAS_ERROR( IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED, "Wrong set-up: External orientation not supported in this configuration" ); } } - if ( st_ivas->hDecoderConfig->Opt_dpid_on ) + IF ( st_ivas->hDecoderConfig->Opt_dpid_on ) { - if ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF ( !( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { return IVAS_ERROR( IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED, "Wrong set-up: Directivity is not supported in this output configuration." ); } } - if ( st_ivas->hDecoderConfig->Opt_aeid_on ) + IF ( st_ivas->hDecoderConfig->Opt_aeid_on ) { - if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + IF ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { return IVAS_ERROR( IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, "Wrong set-up: Acoustic environment is not supported in this output configuration." ); } } - if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) + IF ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { - if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + IF ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" ); } -- GitLab