Loading lib_com/options.h +3 −1 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ #define FIX_BASOP_2513_EXTRA_RETURN_REND_OPEN /* Nokia: BASOP issue 2513: Removes extra return block */ #define FIX_BASOP_2514_EFAP_PORTING_ERROR /* Nokia: BASOP issue 2514: Fix wrongly ported line */ #define FIX_BASOP_2516_REND_CUSTOM_LAYOUT_PORT_BUG /* Nokia: BASOP issue 2516: Fix porting bug in setting planar state for custom layout in renderer */ #define USE_RTPDUMP /* FhG: RTPDUMP format (rtptools standard) instead of custom format */ #define FIX_FLOAT_1569_REND_RENDER_CONFIG_CHECKS /* Nokia: float issue 1569: fix render config checks in renderer */ #define FIX_BASOP_2526_SPAR_MASA_PARAM_MAP_Q_BUG /* Nokia: BASOP issue 2526: Fix wrong Q variable in SPAR to MASA param mapping */ #define FIX_BASOP_2524_MASA_REDUCE_META_BUG /* Nokia: BASOP issue 2524: Fix wrong reset of W_tmp in reduce_metadata_further_fx */ Loading @@ -121,7 +122,8 @@ #define FIX_BASOP_2522_MAP_PARAMS_DIRAC_STEREO /* FhG: BASOP issue 2522: Fix copy and paste error for side_gain calculation in map_params_dirac_to_stereo() */ #define FIX_2505_IVAS_DEC_SEGFAULT /* FhG: BASOP #2505: Add headroom to input of ivas_rend_crendProcessSubframe_fx() for ivas_mdft_fx() calculation */ #define HARMONIZE_DoRTFTn /* VA: harmonize functions DoRTFTn_fx() and DoRTFTn_fx_ivas() */ #define FIX_1574_EFAP_CODE_LINT /* FhG: float issue 1574: Code quality fixes in ivas_efap.c */ #define FIX_BASOP_2529_MASA_RATIO_SCALINGS /* Nokia: BASOP issue 2529: Fix MASA ratio scalings and verifications */ /* ##################### End NON-BE switches ########################### */ Loading lib_enc/ivas_masa_enc_fx.c +24 −0 Original line number Diff line number Diff line Loading @@ -2303,9 +2303,17 @@ static void compensate_energy_ratios_fx( move32(); FOR( dir = 0; dir < numDirs; dir++ ) { #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS ratioSum = L_add( ratioSum, L_shr( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], 1 ) ); // accumulate in Q29 #else ratioSum = L_add( ratioSum, hMeta->directional_meta[dir].energy_ratio_fx[sf][band] ); // Q30 #endif } #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS ratioSum = L_add( ratioSum, L_shr( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], 1 ) ); // accumulate in Q29 #else ratioSum = L_add( ratioSum, hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] ); // Q30 #endif IF( ratioSum == 0 ) { Loading @@ -2317,8 +2325,12 @@ static void compensate_energy_ratios_fx( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = ONE_IN_Q30; // Q30 move32(); } #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS ELSE IF( GT_32( L_abs( L_sub( ratioSum, ONE_IN_Q29 ) ), 1 ) ) // else if ( ratioSum != 1.0f ) from float with minor rounding tolerance #else // ELSE IF( NE_32( ratioSum, ONE_IN_Q30 ) ) ELSE /* Removing the check against 1 works well!!! */ #endif { Word16 exp_diff; FOR( dir = 0; dir < numDirs; dir++ ) Loading @@ -2326,13 +2338,21 @@ static void compensate_energy_ratios_fx( hMeta->directional_meta[dir].energy_ratio_fx[sf][band] = BASOP_Util_Divide3232_Scale_newton( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], ratioSum, &exp_diff ); move32(); #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS hMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], sub( exp_diff, Q2 ) ); // back to Q30 #else hMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], sub( exp_diff, Q1 ) ); // Q30 #endif move32(); } hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = BASOP_Util_Divide3232_Scale_newton( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], ratioSum, &exp_diff ); move32(); #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], sub( exp_diff, Q2 ) ); // back to Q30 #else hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], sub( exp_diff, Q1 ) ); // Q30 #endif move32(); } } Loading Loading @@ -3990,7 +4010,11 @@ void ivas_merge_masa_metadata_fx( direct_scaler_e = 0; move16(); hMeta->directional_meta[0].energy_ratio_fx[sf][band] = Mpy_32_32( direct_scaler_fx, hMeta->directional_meta[0].energy_ratio_fx[sf][band] ); /*q30*/ #ifdef FIX_BASOP_2525_MASA_MERGE_WRONG_ASSIGN hMeta->directional_meta[1].energy_ratio_fx[sf][band] = Mpy_32_32( direct_scaler_fx, hMeta->directional_meta[1].energy_ratio_fx[sf][band] ); /*q30*/ #else hMeta->directional_meta[1].energy_ratio_fx[sf][band] = Mpy_32_32( direct_scaler_fx, hMeta->directional_meta[0].energy_ratio_fx[sf][band] ); /*q30*/ #endif move32(); move32(); } Loading lib_rend/ivas_allrad_dec_fx.c +6 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,12 @@ ivas_error ivas_sba_get_hoa_dec_matrix_fx( ELSE IF( hOutSetup.is_loudspeaker_setup ) { /* init EFIP */ #ifdef FIX_1574_EFAP_CODE_LINT /* ensure the handle is NULL before passing, otherwise efap_init_data will think this is allocated memory and return an error */ hEFAP = NULL; #endif IF( NE_16( ( error = efap_init_data_fx( &( hEFAP ), hOutSetup.ls_azimuth_fx, hOutSetup.ls_elevation_fx, num_spk, EFAP_MODE_EFIP ) ), IVAS_ERR_OK ) ) { return error; Loading lib_rend/ivas_efap_fx.c +86 −4 Original line number Diff line number Diff line Loading @@ -37,7 +37,9 @@ #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #ifndef FIX_1574_EFAP_CODE_LINT #include "ivas_stat_dec.h" #endif #include "wmc_auto.h" #include "ivas_prot_fx.h" Loading @@ -60,6 +62,9 @@ #define Q22_180_DEG 754974720 #define Q22_360_DEG 1509949440 #define Q22_120_DEG 503316480 #ifdef FIX_1574_EFAP_CODE_LINT #define MAX_AZI_GAP 13421773 /* (1.f / 160.0f) in Q31 */ #endif #define Q22_240_DEG 1006632960 /*-----------------------------------------------------------------------* Loading @@ -86,7 +91,11 @@ static Word32 get_tri_gain_fx( const Word32 A[2] /*q22*/, const Word32 B[2] /*q2 * EFAP Utils *-----------------------------------------------------------------------*/ #ifdef FIX_1574_EFAP_CODE_LINT static void add_vertex_fx( EFAP_VERTEX *vtxArray, const Word32 azi /*q22*/, const Word32 ele /*q22*/, const Word16 pos, const EFAP_VTX_DMX_TYPE dmxType ); #else static void add_vertex_fx( EFAP_VERTEX *vtxArray, const Word32 azi /*q22*/, const Word32 ele /*q22*/, const Word16 pos, const EFAP_VTX_DMX_TYPE ); #endif static void efap_sort_s_fx( Word16 *x, Word16 *idx, const Word16 len ); static Word32 vertex_distance_fx( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGLE tri, const Word16 vtxIdx ); Loading @@ -99,7 +108,11 @@ static Word16 get_neighbours_fx( const EFAP_LS_TRIANGLE *triArray, const Word16 static void matrix_times_row_fx( Word32 mat[EFAP_MAX_SIZE_TMP_BUFF][EFAP_MAX_SIZE_TMP_BUFF] /*q31*/, const Word32 *vec /*q31*/, const Word16 L, Word32 *out /*q31*/ ); static void tri_to_poly_fx( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGLE *triArray, const Word16 numVtx, const Word16 numTri, Word16 sortedChan[EFAP_MAX_POLY_SET][EFAP_MAX_CHAN_NUM], Word16 *outLengthPS, Word16 outLengthSorted[EFAP_MAX_POLY_SET] ); #ifdef FIX_1574_EFAP_CODE_LINT static Word16 compare_poly_fx( Word16 *old_poly, Word16 lenOld, Word16 *new_poly, Word16 lenNew ); #else static Word16 compare_poly_fx( Word16 *old, Word16 lenOld, Word16 *new, Word16 lenNew ); #endif static void sort_channels_vertex_fx( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGLE *triArray, Word16 channels[EFAP_MAX_CHAN_NUM], const Word16 lengthChannels, Word16 idxTri ); static Word32 efap_32mod32( const Word32 x /*q22*/, const Word32 y /*q22*/ ); Loading Loading @@ -136,10 +149,22 @@ ivas_error efap_init_data_fx( move32(); /* Basic init checks */ #ifdef FIX_1574_EFAP_CODE_LINT IF( hEFAPdata == NULL ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "pointer to EFAP handle is NULL" ); } IF( *hEFAPdata != NULL ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "EFAP handle must be NULL before initialization" ); } #endif test(); IF( !speaker_node_azi_deg || !speaker_node_ele_deg ) { #ifndef FIX_1574_EFAP_CODE_LINT hEFAPdata = NULL; #endif return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "EFAP requires arrays of speaker azimuths and elevations" ); } Loading Loading @@ -181,13 +206,21 @@ ivas_error efap_init_data_fx( /* Memory allocation for the polyset array */ IF( ( efap->polyData.polysetArray = (EFAP_POLYSET *) malloc( polyset_size * sizeof( EFAP_POLYSET ) ) ) == NULL ) { #ifdef FIX_1574_EFAP_CODE_LINT return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP polygon array\n" ) ); #else return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP bufferS\n" ) ); #endif } /* Memory allocation for the triangle array */ IF( ( efap->polyData.triArray = (EFAP_LS_TRIANGLE *) malloc( polyset_size * sizeof( EFAP_LS_TRIANGLE ) ) ) == NULL ) { #ifdef FIX_1574_EFAP_CODE_LINT return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP triangle array\n" ) ); #else return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP bufferS\n" ) ); #endif } /*-----------------------------------------------------------------* Loading Loading @@ -354,10 +387,18 @@ void efap_free_data_fx( ( *hEFAPdata )->vtxData.vtxOrder = NULL; free( ( *hEFAPdata )->polyData.polysetArray ); #ifdef FIX_1574_EFAP_CODE_LINT ( *hEFAPdata )->polyData.polysetArray = NULL; #else ( *hEFAPdata )->vtxData.vtxOrder = NULL; #endif free( ( *hEFAPdata )->polyData.triArray ); #ifdef FIX_1574_EFAP_CODE_LINT ( *hEFAPdata )->polyData.triArray = NULL; #else ( *hEFAPdata )->vtxData.vtxOrder = NULL; #endif free( ( *hEFAPdata )->bufferLong_fx ); ( *hEFAPdata )->bufferLong_fx = NULL; Loading Loading @@ -634,11 +675,17 @@ static void initial_polyeder_fx( } /* 2. attempt to create a triangle with nonzero area */ #ifndef FIX_1574_EFAP_CODE_LINT tmp = 0; move32(); #endif v_sub_fx( vtxData->vertexArray[tetrahedron[1]].pos, vtxData->vertexArray[tetrahedron[0]].pos, tmp1, 3, 1 ); // tmp1 Q(31-1) WHILE( LT_16( tetrahedron[2], numVtx ) ) { #ifdef FIX_1574_EFAP_CODE_LINT tmp = 0; move32(); #endif v_sub_fx( vtxData->vertexArray[tetrahedron[2]].pos, vtxData->vertexArray[tetrahedron[0]].pos, tmp2, 3, 1 ); // tmp2 Q(31-1) efap_crossp_fx( tmp1, tmp2, tmpCross ); // tmpCross Q29 FOR( i = 0; i < 3; i++ ) Loading Loading @@ -750,7 +797,9 @@ static void add_ghost_speakers_fx( Word16 lengthHorGhst; /* Nb of Horizontal Ghost */ Word16 i, j, k, a; /* Integer for loops */ Word16 num_new; /* Number of new vertices to add */ #ifndef FIX_1574_EFAP_CODE_LINT Word32 maxAngle; /* Max azimuth tolerance for extend the LS setup horizontaly */ #endif Word32 newDiff; /* Angle differences that will help us set the extended LS setup */ Word32 newAzi; /* New azimuth for the new horizontal LS */ Word32 ele[EFAP_MAX_SIZE_TMP_BUFF]; Loading @@ -765,8 +814,10 @@ static void add_ghost_speakers_fx( move32(); numVertex = *numVtx; move16(); #ifndef FIX_1574_EFAP_CODE_LINT maxAngle = 13421773; //(1.f / 160.0f) in Q31 move32(); #endif /* Extracting Azi and Ele for computation purposes */ FOR( i = 0; i < numVertex; ++i ) Loading Loading @@ -857,7 +908,11 @@ static void add_ghost_speakers_fx( a = add( a, 2 ); lengthHorGhst = add( lengthHorGhst, 2 ); } #ifdef FIX_1574_EFAP_CODE_LINT ELSE /* fill gaps greater than MAX_AZI_GAP */ #else ELSE /* fill gaps greater than maxAngle */ #endif { /* Here, k correspond to the number of LS whose ele is < 45 deg, should be = numVertex */ sort_l( tmpAzi, k ); // tmpAzi q22 Loading @@ -867,7 +922,11 @@ static void add_ghost_speakers_fx( { tmpAngleDiff[i] = L_sub( tmpAzi[i + 1], tmpAzi[i] ); // q22 move32(); #ifdef FIX_1574_EFAP_CODE_LINT sectors[i] = ceil_fx( Mpy_32_32( tmpAngleDiff[i], MAX_AZI_GAP ), Q22 ); // q22 #else sectors[i] = ceil_fx( Mpy_32_32( tmpAngleDiff[i], maxAngle ), Q22 ); // q22 #endif move32(); if ( GT_32( sectors[i], Q22_1 /*1 q22*/ ) ) Loading @@ -877,7 +936,11 @@ static void add_ghost_speakers_fx( } tmpAngleDiff[k - 1] = L_sub( L_add( tmpAzi[0], Q22_360_DEG /*360 q22*/ ), tmpAzi[k - 1] ); // q22 #ifdef FIX_1574_EFAP_CODE_LINT sectors[k - 1] = ceil_fx( Mpy_32_32( tmpAngleDiff[k - 1], MAX_AZI_GAP ), Q22 ); // q22 #else sectors[k - 1] = ceil_fx( Mpy_32_32( tmpAngleDiff[k - 1], maxAngle ), Q22 ); // q22 #endif if ( GT_32( sectors[k - 1], Q22_1 /*1 q22*/ ) ) { Loading Loading @@ -1257,7 +1320,11 @@ static void remap_ghosts_fx( { IF( GT_16( triArray[i].LS[j], g ) ) { #ifdef FIX_1574_EFAP_CODE_LINT triArray[i].LS[j] = sub( triArray[i].LS[j], 1 ); #else triArray[i].LS[j] = sub( g, 1 ); #endif move16(); } } Loading Loading @@ -2159,7 +2226,11 @@ static void tri_to_poly_fx( /* Output */ *outLengthPS = lenPolySet; move16(); #ifdef FIX_1574_EFAP_CODE_LINT Copy( sortedLengths, outLengthSorted, lenPolySet ); #else Copy( sortedLengths, outLengthSorted, EFAP_MAX_POLY_SET ); #endif return; } Loading @@ -2171,10 +2242,17 @@ static void tri_to_poly_fx( *-------------------------------------------------------------------------*/ static Word16 compare_poly_fx( #ifdef FIX_1574_EFAP_CODE_LINT Word16 *old_poly, /* i : Existing polygon */ Word16 lenOld, /* i : Length of existing polygon */ Word16 *new_poly, /* i : New polygon */ Word16 lenNew /* i : Length of new polygon */ #else Word16 *old, /* i : Existing polygon */ Word16 lenOld, /* i : Length of existing polygon */ Word16 *new, /* i : New polygon */ Word16 lenNew /* i : Length of new polygon */ #endif ) { Word16 i, j; Loading @@ -2187,7 +2265,11 @@ static Word16 compare_poly_fx( { FOR( j = count; j < lenNew; ++j ) { #ifdef FIX_1574_EFAP_CODE_LINT IF( EQ_16( old_poly[i], new_poly[j] ) ) #else IF( EQ_16( old[i], new[j] ) ) #endif { count = add( count, 1 ); BREAK; Loading lib_rend/lib_rend_fx.c +37 −0 Original line number Diff line number Diff line Loading @@ -9017,7 +9017,11 @@ static void renderMasaToMasa( IVAS_REND_AudioBuffer outAudio ) { Word16 sf, band, dir, numDirs; #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS Word32 ratioSum_fx; /* Q29 for accumulation */ #else Word32 ratioSum_fx; /* Q30 */ #endif MASA_DECODER_EXT_OUT_META_HANDLE outMeta; MASA_METADATA_FRAME *inMeta; Word32 tmpBuffer_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; Loading Loading @@ -9145,9 +9149,17 @@ static void renderMasaToMasa( move32(); FOR( dir = 0; dir < numDirs; dir++ ) { #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS ratioSum_fx = L_add( ratioSum_fx, L_shr( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], 1 ) ); // accumulate in Q29 #else ratioSum_fx = L_add( ratioSum_fx, inMeta->directional_meta[dir].energy_ratio_fx[sf][band] ); #endif } #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS ratioSum_fx = L_add( ratioSum_fx, L_shr( inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], 1 ) ); // accumulate in Q29 #else ratioSum_fx = L_add( ratioSum_fx, inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] ); #endif IF( ratioSum_fx == 0 ) { Loading @@ -9159,7 +9171,11 @@ static void renderMasaToMasa( inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = ONE_IN_Q30; move32(); } #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS ELSE IF( GT_32( L_abs( L_sub( ratioSum_fx, ONE_IN_Q29 ) ), 1 ) ) // else if ( ratioSum != 1.0f ) from float with minor rounding tolerance #else ELSE IF( NE_32( ratioSum_fx, ONE_IN_Q30 ) ) #endif { Word16 tmp_e = 0; move16(); Loading @@ -9168,7 +9184,11 @@ static void renderMasaToMasa( FOR( dir = 0; dir < numDirs; dir++ ) { tmp = BASOP_Util_Divide3232_Scale_newton( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], ratioSum_fx, &tmp_e ); #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS inMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 2 ) ); /* Back to Q30 */ #else inMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 1 ) ); /* Q30 */ #endif move32(); } tmp_e = 0; Loading @@ -9176,7 +9196,11 @@ static void renderMasaToMasa( tmp = 0; move32(); tmp = BASOP_Util_Divide3232_Scale_newton( inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], ratioSum_fx, &tmp_e ); #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 2 ) ); /* Back to Q30 */ #else inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 1 ) ); /* Q30 */ #endif move32(); } } Loading @@ -9191,16 +9215,29 @@ static void renderMasaToMasa( FOR( dir = 0; dir < numDirs; dir++ ) { outMeta->directionIndex[dir][sf][band] = index_theta_phi_16_fx( &inMeta->directional_meta[dir].elevation_fx[sf][band], &inMeta->directional_meta[dir].azimuth_fx[sf][band], masaInput->hMasaPrerend->sph_grid16 ); #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS outMeta->directToTotalRatio[dir][sf][band] = (UWord8) W_extract_h( W_mult_32_16( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], UINT8_MAX << 1 ) ); #else outMeta->directToTotalRatio[dir][sf][band] = (UWord8) L_shr( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], Q22 ); #endif outMeta->diffuseToTotalRatio[sf][band] = (UWord8) sub( outMeta->diffuseToTotalRatio[sf][band], outMeta->directToTotalRatio[dir][sf][band] ); #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS outMeta->spreadCoherence[dir][sf][band] = (UWord8) W_extract_h( W_mult_32_16( L_deposit_h( inMeta->directional_meta[dir].spread_coherence_fx[sf][band] ), UINT8_MAX << 1 ) ); #else outMeta->spreadCoherence[dir][sf][band] = (UWord8) shr( inMeta->directional_meta[dir].spread_coherence_fx[sf][band], Q7 ); #endif move16(); move16(); move16(); move16(); } #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS outMeta->surroundCoherence[sf][band] = (UWord8) W_extract_h( W_mult_32_16( L_deposit_h( inMeta->common_meta.surround_coherence_fx[sf][band] ), UINT8_MAX << 1 ) ); #else outMeta->surroundCoherence[sf][band] = (UWord8) shr( inMeta->common_meta.surround_coherence_fx[sf][band], Q7 ); #endif move16(); } } Loading Loading
lib_com/options.h +3 −1 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ #define FIX_BASOP_2513_EXTRA_RETURN_REND_OPEN /* Nokia: BASOP issue 2513: Removes extra return block */ #define FIX_BASOP_2514_EFAP_PORTING_ERROR /* Nokia: BASOP issue 2514: Fix wrongly ported line */ #define FIX_BASOP_2516_REND_CUSTOM_LAYOUT_PORT_BUG /* Nokia: BASOP issue 2516: Fix porting bug in setting planar state for custom layout in renderer */ #define USE_RTPDUMP /* FhG: RTPDUMP format (rtptools standard) instead of custom format */ #define FIX_FLOAT_1569_REND_RENDER_CONFIG_CHECKS /* Nokia: float issue 1569: fix render config checks in renderer */ #define FIX_BASOP_2526_SPAR_MASA_PARAM_MAP_Q_BUG /* Nokia: BASOP issue 2526: Fix wrong Q variable in SPAR to MASA param mapping */ #define FIX_BASOP_2524_MASA_REDUCE_META_BUG /* Nokia: BASOP issue 2524: Fix wrong reset of W_tmp in reduce_metadata_further_fx */ Loading @@ -121,7 +122,8 @@ #define FIX_BASOP_2522_MAP_PARAMS_DIRAC_STEREO /* FhG: BASOP issue 2522: Fix copy and paste error for side_gain calculation in map_params_dirac_to_stereo() */ #define FIX_2505_IVAS_DEC_SEGFAULT /* FhG: BASOP #2505: Add headroom to input of ivas_rend_crendProcessSubframe_fx() for ivas_mdft_fx() calculation */ #define HARMONIZE_DoRTFTn /* VA: harmonize functions DoRTFTn_fx() and DoRTFTn_fx_ivas() */ #define FIX_1574_EFAP_CODE_LINT /* FhG: float issue 1574: Code quality fixes in ivas_efap.c */ #define FIX_BASOP_2529_MASA_RATIO_SCALINGS /* Nokia: BASOP issue 2529: Fix MASA ratio scalings and verifications */ /* ##################### End NON-BE switches ########################### */ Loading
lib_enc/ivas_masa_enc_fx.c +24 −0 Original line number Diff line number Diff line Loading @@ -2303,9 +2303,17 @@ static void compensate_energy_ratios_fx( move32(); FOR( dir = 0; dir < numDirs; dir++ ) { #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS ratioSum = L_add( ratioSum, L_shr( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], 1 ) ); // accumulate in Q29 #else ratioSum = L_add( ratioSum, hMeta->directional_meta[dir].energy_ratio_fx[sf][band] ); // Q30 #endif } #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS ratioSum = L_add( ratioSum, L_shr( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], 1 ) ); // accumulate in Q29 #else ratioSum = L_add( ratioSum, hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] ); // Q30 #endif IF( ratioSum == 0 ) { Loading @@ -2317,8 +2325,12 @@ static void compensate_energy_ratios_fx( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = ONE_IN_Q30; // Q30 move32(); } #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS ELSE IF( GT_32( L_abs( L_sub( ratioSum, ONE_IN_Q29 ) ), 1 ) ) // else if ( ratioSum != 1.0f ) from float with minor rounding tolerance #else // ELSE IF( NE_32( ratioSum, ONE_IN_Q30 ) ) ELSE /* Removing the check against 1 works well!!! */ #endif { Word16 exp_diff; FOR( dir = 0; dir < numDirs; dir++ ) Loading @@ -2326,13 +2338,21 @@ static void compensate_energy_ratios_fx( hMeta->directional_meta[dir].energy_ratio_fx[sf][band] = BASOP_Util_Divide3232_Scale_newton( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], ratioSum, &exp_diff ); move32(); #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS hMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], sub( exp_diff, Q2 ) ); // back to Q30 #else hMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], sub( exp_diff, Q1 ) ); // Q30 #endif move32(); } hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = BASOP_Util_Divide3232_Scale_newton( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], ratioSum, &exp_diff ); move32(); #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], sub( exp_diff, Q2 ) ); // back to Q30 #else hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], sub( exp_diff, Q1 ) ); // Q30 #endif move32(); } } Loading Loading @@ -3990,7 +4010,11 @@ void ivas_merge_masa_metadata_fx( direct_scaler_e = 0; move16(); hMeta->directional_meta[0].energy_ratio_fx[sf][band] = Mpy_32_32( direct_scaler_fx, hMeta->directional_meta[0].energy_ratio_fx[sf][band] ); /*q30*/ #ifdef FIX_BASOP_2525_MASA_MERGE_WRONG_ASSIGN hMeta->directional_meta[1].energy_ratio_fx[sf][band] = Mpy_32_32( direct_scaler_fx, hMeta->directional_meta[1].energy_ratio_fx[sf][band] ); /*q30*/ #else hMeta->directional_meta[1].energy_ratio_fx[sf][band] = Mpy_32_32( direct_scaler_fx, hMeta->directional_meta[0].energy_ratio_fx[sf][band] ); /*q30*/ #endif move32(); move32(); } Loading
lib_rend/ivas_allrad_dec_fx.c +6 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,12 @@ ivas_error ivas_sba_get_hoa_dec_matrix_fx( ELSE IF( hOutSetup.is_loudspeaker_setup ) { /* init EFIP */ #ifdef FIX_1574_EFAP_CODE_LINT /* ensure the handle is NULL before passing, otherwise efap_init_data will think this is allocated memory and return an error */ hEFAP = NULL; #endif IF( NE_16( ( error = efap_init_data_fx( &( hEFAP ), hOutSetup.ls_azimuth_fx, hOutSetup.ls_elevation_fx, num_spk, EFAP_MODE_EFIP ) ), IVAS_ERR_OK ) ) { return error; Loading
lib_rend/ivas_efap_fx.c +86 −4 Original line number Diff line number Diff line Loading @@ -37,7 +37,9 @@ #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #ifndef FIX_1574_EFAP_CODE_LINT #include "ivas_stat_dec.h" #endif #include "wmc_auto.h" #include "ivas_prot_fx.h" Loading @@ -60,6 +62,9 @@ #define Q22_180_DEG 754974720 #define Q22_360_DEG 1509949440 #define Q22_120_DEG 503316480 #ifdef FIX_1574_EFAP_CODE_LINT #define MAX_AZI_GAP 13421773 /* (1.f / 160.0f) in Q31 */ #endif #define Q22_240_DEG 1006632960 /*-----------------------------------------------------------------------* Loading @@ -86,7 +91,11 @@ static Word32 get_tri_gain_fx( const Word32 A[2] /*q22*/, const Word32 B[2] /*q2 * EFAP Utils *-----------------------------------------------------------------------*/ #ifdef FIX_1574_EFAP_CODE_LINT static void add_vertex_fx( EFAP_VERTEX *vtxArray, const Word32 azi /*q22*/, const Word32 ele /*q22*/, const Word16 pos, const EFAP_VTX_DMX_TYPE dmxType ); #else static void add_vertex_fx( EFAP_VERTEX *vtxArray, const Word32 azi /*q22*/, const Word32 ele /*q22*/, const Word16 pos, const EFAP_VTX_DMX_TYPE ); #endif static void efap_sort_s_fx( Word16 *x, Word16 *idx, const Word16 len ); static Word32 vertex_distance_fx( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGLE tri, const Word16 vtxIdx ); Loading @@ -99,7 +108,11 @@ static Word16 get_neighbours_fx( const EFAP_LS_TRIANGLE *triArray, const Word16 static void matrix_times_row_fx( Word32 mat[EFAP_MAX_SIZE_TMP_BUFF][EFAP_MAX_SIZE_TMP_BUFF] /*q31*/, const Word32 *vec /*q31*/, const Word16 L, Word32 *out /*q31*/ ); static void tri_to_poly_fx( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGLE *triArray, const Word16 numVtx, const Word16 numTri, Word16 sortedChan[EFAP_MAX_POLY_SET][EFAP_MAX_CHAN_NUM], Word16 *outLengthPS, Word16 outLengthSorted[EFAP_MAX_POLY_SET] ); #ifdef FIX_1574_EFAP_CODE_LINT static Word16 compare_poly_fx( Word16 *old_poly, Word16 lenOld, Word16 *new_poly, Word16 lenNew ); #else static Word16 compare_poly_fx( Word16 *old, Word16 lenOld, Word16 *new, Word16 lenNew ); #endif static void sort_channels_vertex_fx( const EFAP_VERTEX *vtxArray, const EFAP_LS_TRIANGLE *triArray, Word16 channels[EFAP_MAX_CHAN_NUM], const Word16 lengthChannels, Word16 idxTri ); static Word32 efap_32mod32( const Word32 x /*q22*/, const Word32 y /*q22*/ ); Loading Loading @@ -136,10 +149,22 @@ ivas_error efap_init_data_fx( move32(); /* Basic init checks */ #ifdef FIX_1574_EFAP_CODE_LINT IF( hEFAPdata == NULL ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "pointer to EFAP handle is NULL" ); } IF( *hEFAPdata != NULL ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "EFAP handle must be NULL before initialization" ); } #endif test(); IF( !speaker_node_azi_deg || !speaker_node_ele_deg ) { #ifndef FIX_1574_EFAP_CODE_LINT hEFAPdata = NULL; #endif return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "EFAP requires arrays of speaker azimuths and elevations" ); } Loading Loading @@ -181,13 +206,21 @@ ivas_error efap_init_data_fx( /* Memory allocation for the polyset array */ IF( ( efap->polyData.polysetArray = (EFAP_POLYSET *) malloc( polyset_size * sizeof( EFAP_POLYSET ) ) ) == NULL ) { #ifdef FIX_1574_EFAP_CODE_LINT return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP polygon array\n" ) ); #else return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP bufferS\n" ) ); #endif } /* Memory allocation for the triangle array */ IF( ( efap->polyData.triArray = (EFAP_LS_TRIANGLE *) malloc( polyset_size * sizeof( EFAP_LS_TRIANGLE ) ) ) == NULL ) { #ifdef FIX_1574_EFAP_CODE_LINT return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP triangle array\n" ) ); #else return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP bufferS\n" ) ); #endif } /*-----------------------------------------------------------------* Loading Loading @@ -354,10 +387,18 @@ void efap_free_data_fx( ( *hEFAPdata )->vtxData.vtxOrder = NULL; free( ( *hEFAPdata )->polyData.polysetArray ); #ifdef FIX_1574_EFAP_CODE_LINT ( *hEFAPdata )->polyData.polysetArray = NULL; #else ( *hEFAPdata )->vtxData.vtxOrder = NULL; #endif free( ( *hEFAPdata )->polyData.triArray ); #ifdef FIX_1574_EFAP_CODE_LINT ( *hEFAPdata )->polyData.triArray = NULL; #else ( *hEFAPdata )->vtxData.vtxOrder = NULL; #endif free( ( *hEFAPdata )->bufferLong_fx ); ( *hEFAPdata )->bufferLong_fx = NULL; Loading Loading @@ -634,11 +675,17 @@ static void initial_polyeder_fx( } /* 2. attempt to create a triangle with nonzero area */ #ifndef FIX_1574_EFAP_CODE_LINT tmp = 0; move32(); #endif v_sub_fx( vtxData->vertexArray[tetrahedron[1]].pos, vtxData->vertexArray[tetrahedron[0]].pos, tmp1, 3, 1 ); // tmp1 Q(31-1) WHILE( LT_16( tetrahedron[2], numVtx ) ) { #ifdef FIX_1574_EFAP_CODE_LINT tmp = 0; move32(); #endif v_sub_fx( vtxData->vertexArray[tetrahedron[2]].pos, vtxData->vertexArray[tetrahedron[0]].pos, tmp2, 3, 1 ); // tmp2 Q(31-1) efap_crossp_fx( tmp1, tmp2, tmpCross ); // tmpCross Q29 FOR( i = 0; i < 3; i++ ) Loading Loading @@ -750,7 +797,9 @@ static void add_ghost_speakers_fx( Word16 lengthHorGhst; /* Nb of Horizontal Ghost */ Word16 i, j, k, a; /* Integer for loops */ Word16 num_new; /* Number of new vertices to add */ #ifndef FIX_1574_EFAP_CODE_LINT Word32 maxAngle; /* Max azimuth tolerance for extend the LS setup horizontaly */ #endif Word32 newDiff; /* Angle differences that will help us set the extended LS setup */ Word32 newAzi; /* New azimuth for the new horizontal LS */ Word32 ele[EFAP_MAX_SIZE_TMP_BUFF]; Loading @@ -765,8 +814,10 @@ static void add_ghost_speakers_fx( move32(); numVertex = *numVtx; move16(); #ifndef FIX_1574_EFAP_CODE_LINT maxAngle = 13421773; //(1.f / 160.0f) in Q31 move32(); #endif /* Extracting Azi and Ele for computation purposes */ FOR( i = 0; i < numVertex; ++i ) Loading Loading @@ -857,7 +908,11 @@ static void add_ghost_speakers_fx( a = add( a, 2 ); lengthHorGhst = add( lengthHorGhst, 2 ); } #ifdef FIX_1574_EFAP_CODE_LINT ELSE /* fill gaps greater than MAX_AZI_GAP */ #else ELSE /* fill gaps greater than maxAngle */ #endif { /* Here, k correspond to the number of LS whose ele is < 45 deg, should be = numVertex */ sort_l( tmpAzi, k ); // tmpAzi q22 Loading @@ -867,7 +922,11 @@ static void add_ghost_speakers_fx( { tmpAngleDiff[i] = L_sub( tmpAzi[i + 1], tmpAzi[i] ); // q22 move32(); #ifdef FIX_1574_EFAP_CODE_LINT sectors[i] = ceil_fx( Mpy_32_32( tmpAngleDiff[i], MAX_AZI_GAP ), Q22 ); // q22 #else sectors[i] = ceil_fx( Mpy_32_32( tmpAngleDiff[i], maxAngle ), Q22 ); // q22 #endif move32(); if ( GT_32( sectors[i], Q22_1 /*1 q22*/ ) ) Loading @@ -877,7 +936,11 @@ static void add_ghost_speakers_fx( } tmpAngleDiff[k - 1] = L_sub( L_add( tmpAzi[0], Q22_360_DEG /*360 q22*/ ), tmpAzi[k - 1] ); // q22 #ifdef FIX_1574_EFAP_CODE_LINT sectors[k - 1] = ceil_fx( Mpy_32_32( tmpAngleDiff[k - 1], MAX_AZI_GAP ), Q22 ); // q22 #else sectors[k - 1] = ceil_fx( Mpy_32_32( tmpAngleDiff[k - 1], maxAngle ), Q22 ); // q22 #endif if ( GT_32( sectors[k - 1], Q22_1 /*1 q22*/ ) ) { Loading Loading @@ -1257,7 +1320,11 @@ static void remap_ghosts_fx( { IF( GT_16( triArray[i].LS[j], g ) ) { #ifdef FIX_1574_EFAP_CODE_LINT triArray[i].LS[j] = sub( triArray[i].LS[j], 1 ); #else triArray[i].LS[j] = sub( g, 1 ); #endif move16(); } } Loading Loading @@ -2159,7 +2226,11 @@ static void tri_to_poly_fx( /* Output */ *outLengthPS = lenPolySet; move16(); #ifdef FIX_1574_EFAP_CODE_LINT Copy( sortedLengths, outLengthSorted, lenPolySet ); #else Copy( sortedLengths, outLengthSorted, EFAP_MAX_POLY_SET ); #endif return; } Loading @@ -2171,10 +2242,17 @@ static void tri_to_poly_fx( *-------------------------------------------------------------------------*/ static Word16 compare_poly_fx( #ifdef FIX_1574_EFAP_CODE_LINT Word16 *old_poly, /* i : Existing polygon */ Word16 lenOld, /* i : Length of existing polygon */ Word16 *new_poly, /* i : New polygon */ Word16 lenNew /* i : Length of new polygon */ #else Word16 *old, /* i : Existing polygon */ Word16 lenOld, /* i : Length of existing polygon */ Word16 *new, /* i : New polygon */ Word16 lenNew /* i : Length of new polygon */ #endif ) { Word16 i, j; Loading @@ -2187,7 +2265,11 @@ static Word16 compare_poly_fx( { FOR( j = count; j < lenNew; ++j ) { #ifdef FIX_1574_EFAP_CODE_LINT IF( EQ_16( old_poly[i], new_poly[j] ) ) #else IF( EQ_16( old[i], new[j] ) ) #endif { count = add( count, 1 ); BREAK; Loading
lib_rend/lib_rend_fx.c +37 −0 Original line number Diff line number Diff line Loading @@ -9017,7 +9017,11 @@ static void renderMasaToMasa( IVAS_REND_AudioBuffer outAudio ) { Word16 sf, band, dir, numDirs; #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS Word32 ratioSum_fx; /* Q29 for accumulation */ #else Word32 ratioSum_fx; /* Q30 */ #endif MASA_DECODER_EXT_OUT_META_HANDLE outMeta; MASA_METADATA_FRAME *inMeta; Word32 tmpBuffer_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; Loading Loading @@ -9145,9 +9149,17 @@ static void renderMasaToMasa( move32(); FOR( dir = 0; dir < numDirs; dir++ ) { #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS ratioSum_fx = L_add( ratioSum_fx, L_shr( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], 1 ) ); // accumulate in Q29 #else ratioSum_fx = L_add( ratioSum_fx, inMeta->directional_meta[dir].energy_ratio_fx[sf][band] ); #endif } #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS ratioSum_fx = L_add( ratioSum_fx, L_shr( inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], 1 ) ); // accumulate in Q29 #else ratioSum_fx = L_add( ratioSum_fx, inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] ); #endif IF( ratioSum_fx == 0 ) { Loading @@ -9159,7 +9171,11 @@ static void renderMasaToMasa( inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = ONE_IN_Q30; move32(); } #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS ELSE IF( GT_32( L_abs( L_sub( ratioSum_fx, ONE_IN_Q29 ) ), 1 ) ) // else if ( ratioSum != 1.0f ) from float with minor rounding tolerance #else ELSE IF( NE_32( ratioSum_fx, ONE_IN_Q30 ) ) #endif { Word16 tmp_e = 0; move16(); Loading @@ -9168,7 +9184,11 @@ static void renderMasaToMasa( FOR( dir = 0; dir < numDirs; dir++ ) { tmp = BASOP_Util_Divide3232_Scale_newton( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], ratioSum_fx, &tmp_e ); #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS inMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 2 ) ); /* Back to Q30 */ #else inMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 1 ) ); /* Q30 */ #endif move32(); } tmp_e = 0; Loading @@ -9176,7 +9196,11 @@ static void renderMasaToMasa( tmp = 0; move32(); tmp = BASOP_Util_Divide3232_Scale_newton( inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], ratioSum_fx, &tmp_e ); #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 2 ) ); /* Back to Q30 */ #else inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 1 ) ); /* Q30 */ #endif move32(); } } Loading @@ -9191,16 +9215,29 @@ static void renderMasaToMasa( FOR( dir = 0; dir < numDirs; dir++ ) { outMeta->directionIndex[dir][sf][band] = index_theta_phi_16_fx( &inMeta->directional_meta[dir].elevation_fx[sf][band], &inMeta->directional_meta[dir].azimuth_fx[sf][band], masaInput->hMasaPrerend->sph_grid16 ); #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS outMeta->directToTotalRatio[dir][sf][band] = (UWord8) W_extract_h( W_mult_32_16( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], UINT8_MAX << 1 ) ); #else outMeta->directToTotalRatio[dir][sf][band] = (UWord8) L_shr( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], Q22 ); #endif outMeta->diffuseToTotalRatio[sf][band] = (UWord8) sub( outMeta->diffuseToTotalRatio[sf][band], outMeta->directToTotalRatio[dir][sf][band] ); #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS outMeta->spreadCoherence[dir][sf][band] = (UWord8) W_extract_h( W_mult_32_16( L_deposit_h( inMeta->directional_meta[dir].spread_coherence_fx[sf][band] ), UINT8_MAX << 1 ) ); #else outMeta->spreadCoherence[dir][sf][band] = (UWord8) shr( inMeta->directional_meta[dir].spread_coherence_fx[sf][band], Q7 ); #endif move16(); move16(); move16(); move16(); } #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS outMeta->surroundCoherence[sf][band] = (UWord8) W_extract_h( W_mult_32_16( L_deposit_h( inMeta->common_meta.surround_coherence_fx[sf][band] ), UINT8_MAX << 1 ) ); #else outMeta->surroundCoherence[sf][band] = (UWord8) shr( inMeta->common_meta.surround_coherence_fx[sf][band], Q7 ); #endif move16(); } } Loading