diff --git a/apps/decoder.c b/apps/decoder.c index b914b3ae4cd5aed93ce50f62fb7f27f5558a0f81..5c785db397e2dcfbc5b8e5454f1dd61006ec4104 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2221,23 +2221,23 @@ static ivas_error decodeG192( } #ifdef FIX_CREND_SIMPLIFY_CODE - /* Load HRTF binary file data */ - if ( arg.hrtfReaderEnabled ) + /* Read main parameters from the bitstream to set-up the decoder */ + hHrtfBinary->binaural_renderer_old = hHrtfBinary->binaural_renderer; + hHrtfBinary->binaural_renderer_sec_old = hHrtfBinary->binaural_renderer_sec; + if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtfBinary->binaural_renderer, &hHrtfBinary->binaural_renderer_sec, &hHrtfBinary->hrtf_set_audio_cfg ) ) != IVAS_ERR_OK ) { - /* Read main parameters from the bitstream to set-up the decoder */ - hHrtfBinary->binaural_renderer_old = hHrtfBinary->binaural_renderer; - hHrtfBinary->binaural_renderer_sec_old = hHrtfBinary->binaural_renderer_sec; - if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtfBinary->binaural_renderer, &hHrtfBinary->binaural_renderer_sec, &hHrtfBinary->hrtf_set_audio_cfg ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; + } - /* Placeholder for memory reallocation */ - /* ... */ + /* Placeholder for memory reallocation */ + /* ... */ + /* Load HRTF binary file data */ + if ( arg.hrtfReaderEnabled ) + { if ( ( error = load_hrtf_from_file( hHrtfBinary, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nIVAS_DEC_LoadHrtfFromFile failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "\nload_hrtf_from_file failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } } @@ -2691,6 +2691,7 @@ static ivas_error decodeVoIP( int16_t nOutSamples = 0; #ifdef FIX_CREND_SIMPLIFY_CODE bool bitstreamReadDone = false; + uint16_t nSamplesRendered; #endif vec_pos_update = 0; @@ -2809,6 +2810,9 @@ static ivas_error decodeVoIP( while ( 1 ) { +#ifdef FIX_CREND_SIMPLIFY_CODE + nSamplesRendered = 0; +#endif /* reference vector */ if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 ) @@ -2972,11 +2976,15 @@ static ivas_error decodeVoIP( /* decode and get samples */ +#ifdef FIX_HRTF_LOAD + while ( nSamplesRendered < nOutSamples ) + { +#endif #ifdef SUPPORT_JBM_TRACEFILE #ifdef FIX_CREND_SIMPLIFY_CODE - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered ) ) != IVAS_ERR_OK ) #else - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) #endif #else #ifdef FIX_CREND_SIMPLIFY_CODE @@ -2985,16 +2993,13 @@ static ivas_error decodeVoIP( if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) #endif #endif - { - fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } + { + fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } #ifdef FIX_CREND_SIMPLIFY_CODE - if ( bitstreamReadDone == true ) - { - /* Load HRTF binary file data */ - if ( arg.hrtfReaderEnabled ) + if ( bitstreamReadDone == true ) { /* Read main parameters from the bitstream to set-up the decoder */ hHrtf->binaural_renderer_old = hHrtf->binaural_renderer; @@ -3007,12 +3012,18 @@ static ivas_error decodeVoIP( /* Placeholder for memory reallocation */ /* ... */ - if ( ( error = load_hrtf_from_file( hHrtf, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK ) + /* Load HRTF binary file data */ + if ( arg.hrtfReaderEnabled ) { - fprintf( stderr, "\nIVAS_DEC_LoadHrtfFromFile failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; + if ( ( error = load_hrtf_from_file( hHrtf, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nload_hrtf_from_file failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } } } +#endif +#ifdef FIX_HRTF_LOAD } #endif @@ -3299,6 +3310,7 @@ cleanup: return error; } + #ifdef FIX_CREND_SIMPLIFY_CODE /*---------------------------------------------------------------------* * load_hrtf_from_file() diff --git a/apps/renderer.c b/apps/renderer.c index c84cbac9e867c9e8a5878d7c7ceee5a65f9c31c5..97de605325dc1303f6f91c20f88a41cfa005e184 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -693,7 +693,11 @@ static int16_t get_cldfb_in_flag( int16_t cldfb_in_flag; cldfb_in_flag = 0; +#ifdef FIX_HRTF_LOAD + if ( renderConfig->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV ) +#else if ( renderConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) +#endif { #ifdef DEBUGGING cldfb_in_flag = 1; diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 09923953685b329703526a25bb35e1e1f04156b3..cdbae021b4a9cd335840162e95e17cd8b79bd125 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -274,6 +274,7 @@ typedef enum } ISAR_SPLIT_REND_CODEC; +#ifndef FIX_HRTF_LOAD typedef enum { ISAR_SPLIT_REND_RENDERER_SELECTION_CREND, @@ -283,7 +284,7 @@ typedef enum ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT, } ISAR_SPLIT_REND_RENDERER_SELECTION; - +#endif typedef struct _ISAR_SPLIT_REND_BITS_DATA { uint8_t *bits_buf; @@ -314,7 +315,11 @@ typedef struct _ISAR_SPLIT_REND_CONFIG int16_t codec_frame_size_ms; /* Codec frame size in milliseconds, only relevant with LC3plus */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode; ISAR_SPLIT_REND_CODEC codec; +#ifdef FIX_HRTF_LOAD + IVAS_BIN_RENDERER_TYPE rendererSelection; +#else ISAR_SPLIT_REND_RENDERER_SELECTION rendererSelection; +#endif int16_t lc3plus_highres; } ISAR_SPLIT_REND_CONFIG_DATA, *ISAR_SPLIT_REND_CONFIG_HANDLE; diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index ccfc4fe0d9156a2eba92fbcbc0c0ebfd0708e62d..87dce6d2f05a9675d62eed07a97f6c9376205b2a 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -114,9 +114,12 @@ void ivas_masa_prerender_fx( ); ivas_error ivas_masa_dec_reconfigure_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef FIX_HRTF_LOAD + , UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ Word16 *data /* o : output synthesis signal */ +#endif ); void reconstruct_ism_ratios_fx( @@ -192,10 +195,15 @@ ivas_error ivas_omasa_ism_metadata_dec_fx( ivas_error ivas_omasa_dec_config_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_HRTF_LOAD + Word16 *num_src, + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS] +#else UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ Word16 *num_src, Word16 SrcInd[MAX_NUM_TDREND_CHANNELS], Word16 *data /* o : output synthesis signal */ +#endif ); void ivas_omasa_modify_masa_energy_ratios_fx( @@ -2363,9 +2371,12 @@ void ivas_destroy_dec_fx( ivas_error ivas_ism_dec_config_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ + const ISM_MODE last_ism_mode /* i/o: last ISM mode */ +#ifndef FIX_HRTF_LOAD + , UWord16 *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ Word16 *data /* o : output synthesis signal */ +#endif ); ivas_error ivas_ism_metadata_dec_create_fx( @@ -2379,9 +2390,12 @@ void ivas_ism_reset_metadata_handle_dec_fx( ); ivas_error ivas_sba_dec_reconfigure_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef FIX_HRTF_LOAD + , UWord16 *nSamplesFlushed, /* o : number of samples flushed */ Word16 *data /* o : output synthesis signal */ +#endif ); ivas_error ivas_spar_md_dec_matrix_open_fx( @@ -2389,6 +2403,7 @@ ivas_error ivas_spar_md_dec_matrix_open_fx( const Word16 num_channels, /* i : number of internal channels */ const Word16 num_md_sub_frames /* i : number of MD subframes */ ); + void ivas_spar_md_dec_matrix_close_fx( ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ const Word16 num_channels /* i : number of internal channels */ @@ -2416,9 +2431,12 @@ void ivas_omasa_data_close_fx( ivas_error ivas_mc_dec_config_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 idx, /* i : LS config. index */ + const Word16 idx /* i : LS config. index */ +#ifndef FIX_HRTF_LOAD + , UWord16 *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ Word16 *data /* o : output synthesis signal */ +#endif ); void ivas_lfe_window_init_fx( @@ -4034,9 +4052,12 @@ ivas_error ivas_dec_get_format_fx( ); ivas_error ivas_dec_setup( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef FIX_HRTF_LOAD + , UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ Word16 *data /* o : output synthesis signal */ +#endif ); ivas_error create_mct_dec_fx( @@ -4271,9 +4292,12 @@ ivas_error ivas_ism_metadata_enc_fx( ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ + const ISM_MODE last_ism_mode /* i/o: last ISM mode */ +#ifndef FIX_HRTF_LOAD + , UWord16 *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ Word16 *data /* o : output synthesis signal */ +#endif ); ivas_error ivas_param_ism_dec_open_fx( diff --git a/lib_com/options.h b/lib_com/options.h index e83a0613e8d34dfaff541c367ed84fe090f836b3..345223a0aa41911c3751b9805f40319023f89811 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,6 +124,8 @@ #define USE_REVERB_16BIT_ROM /* if desactivated old rom hrtf tables is used */ #define USE_TDREND_16BIT_ROM /* if desactivated old rom hrtf tables is used. when active some tests case with 4 ISM fail due to owerflow in round_fixed function */ #define USE_FASTCONV_PARAMBIN_16BIT_ROM /* if desactivated old rom hrtf tables is used */ +#define FIX_HRTF_LOAD /* VA: issue 1187: fix memory issue when HRTFs are loaded from a binary file */ +#define FIX_HRTF_LOAD_KEEP_BE // VA: temp. hack to keep BE when FIX_HRTF_LOAD is activated - the code will be removed once HRTF updates are stable #endif #define NONBE_1377_REND_DIRATT_CONF /* Eri: Issue 1377: Error in directivity attenuation configuration for both IVAS_dec and IVAS_rend */ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index b8588a04643f3ac707d216210daa7f66adebe1af..4691523c696152cfea01148d5112bbca46d4be35 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -843,10 +843,11 @@ ivas_error ivas_allocate_binaural_hrtf_fx( } /*-------------------------------------------------------------------------* - * ivas_binaural_HRTF_open() + * ivas_binaural_hrtf_open() * * *-------------------------------------------------------------------------*/ + static ivas_error ivas_binaural_hrtf_open_fx( HRTFS_FASTCONV_HANDLE *hHrtfFastConv, /* i : fastconv HRTF handle */ const AUDIO_CONFIG input_config, /* i : output configuration */ @@ -1157,15 +1158,18 @@ static ivas_error ivas_binaural_hrtf_open_fx( #endif *hHrtfFastConv = HrtfFastConv; - } - return IVAS_ERR_OK; + return IVAS_ERR_OK; + } } + + /*-------------------------------------------------------------------------* - * ivas_binaural_obtain_DMX_fx() + * ivas_binaural_obtain_DMX() * * *-------------------------------------------------------------------------*/ + static void ivas_binaural_obtain_DMX_fx( const Word16 numTimeSlots, BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ @@ -1484,8 +1488,10 @@ ivas_error ivas_binRenderer_open_fx( /* Define of head rotation has to be done in binRendeder in CLDFB*/ hBinRenderer->rotInCldfb = 0; move16(); + test(); - if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + test(); + IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { hBinRenderer->rotInCldfb = 1; move16(); @@ -1552,6 +1558,7 @@ ivas_error ivas_binRenderer_open_fx( return IVAS_ERROR( IVAS_ERR_INTERNAL, "HRTF binary file present but not used in FastConv renderer" ); } #endif + /* Load HRTF tables */ IF( NE_32( ( error = ivas_binaural_hrtf_open_fx( &st_ivas->hHrtfFastConv, st_ivas->hIntSetup.output_config, st_ivas->renderer_type ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 580ba9d06c516a4f4de78b688e1e6ab412e1ca2b..bb53a60b99ecfc51e835dcb505b8cae0728a38d5 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -252,7 +252,7 @@ ivas_error ivas_dec_get_format_fx( /* this should be non-zero if original input format was MASA_ISM_FORMAT */ st_ivas->ism_mode = ISM_MODE_NONE; move16(); - nchan_ism = st_ivas->bit_stream[k - 3] + shl( st_ivas->bit_stream[k - 2], 1 ); + nchan_ism = add( st_ivas->bit_stream[k - 3], shl( st_ivas->bit_stream[k - 2], 1 ) ); IF( nchan_ism > 0 ) { @@ -266,11 +266,19 @@ ivas_error ivas_dec_get_format_fx( */ nchan_ism = sub( 5, nchan_ism ); test(); +#ifdef FIX_HRTF_LOAD + IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( nchan_ism, 2 ) ) + { + nchan_ism = 1; + move16(); + } +#else IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( st_ivas->nchan_ism, 2 ) ) { st_ivas->nchan_ism = 1; move16(); } +#endif /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ st_ivas->nchan_transport = 2; @@ -336,7 +344,11 @@ ivas_error ivas_dec_get_format_fx( /* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ sba_order = st_ivas->bit_stream[num_bits_read + 1]; move16(); +#ifdef FIX_HRTF_LOAD + sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); +#else sba_order = shl( st_ivas->bit_stream[num_bits_read], 1 ); +#endif num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); /* read the real Ambisonic order when the above bits are used to signal OSBA format */ @@ -344,7 +356,11 @@ ivas_error ivas_dec_get_format_fx( { sba_order = st_ivas->bit_stream[num_bits_read + 1]; move16(); +#ifdef FIX_HRTF_LOAD + sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); +#else sba_order = shl( st_ivas->bit_stream[num_bits_read], 1 ); +#endif num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); } @@ -524,9 +540,12 @@ ivas_error ivas_dec_get_format_fx( *-------------------------------------------------------------------*/ ivas_error ivas_dec_setup( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef FIX_HRTF_LOAD + , UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ Word16 *data /* o : output synthesis signal */ +#endif ) { Word16 k, idx, num_bits_read; @@ -595,7 +614,11 @@ ivas_error ivas_dec_setup( st_ivas->nchan_ism = nchan_ism; move16(); +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = ivas_ism_dec_config_fx( st_ivas, st_ivas->ism_mode ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_ism_dec_config_fx( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -618,7 +641,11 @@ ivas_error ivas_dec_setup( test(); IF( 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 ) ) { +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -695,7 +722,11 @@ ivas_error ivas_dec_setup( } ELSE { +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = ivas_masa_dec_reconfigure_fx( st_ivas ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -703,7 +734,11 @@ ivas_error ivas_dec_setup( } ELSE { +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = ivas_omasa_dec_config_fx( st_ivas, &num_src, SrcInd ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -729,7 +764,11 @@ ivas_error ivas_dec_setup( test(); IF( ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) || ( st_ivas->ini_active_frame == 0 ) ) { +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = ivas_omasa_dec_config_fx( st_ivas, &num_src, SrcInd ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -768,7 +807,11 @@ ivas_error ivas_dec_setup( test(); IF( st_ivas->ini_frame > 0 && NE_32( ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ) { +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -818,7 +861,11 @@ ivas_error ivas_dec_setup( num_bits_read = add( num_bits_read, MC_LS_SETUP_BITS ); /* select MC format mode; reconfigure the MC format decoder */ +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = ivas_mc_dec_config_fx( st_ivas, idx ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_mc_dec_config_fx( st_ivas, idx, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -929,7 +976,11 @@ ivas_error ivas_dec_setup( move16(); } +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_sba_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -988,7 +1039,11 @@ ivas_error ivas_dec_setup( move32(); } +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = ivas_ism_dec_config_fx( st_ivas, last_ism_mode ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_ism_dec_config_fx( st_ivas, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -1146,12 +1201,13 @@ static ivas_error ivas_read_format( { st_ivas->ivas_format = SBA_ISM_FORMAT; move32(); + #ifdef FIX_CREND_SIMPLIFY_CODE /* read the real Ambisonic order when the above bits are used to signal OSBA format */ IF( LE_32( ivas_total_brate, IVAS_24k4 ) ) { - st_ivas->sba_order = st_ivas->bit_stream[*num_bits_read + 2 + SBA_PLANAR_BITS + SBA_ORDER_BITS]; - st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[*num_bits_read + 1 + SBA_PLANAR_BITS + SBA_ORDER_BITS], 1 ) ); + st_ivas->sba_order = st_ivas->bit_stream[add( *num_bits_read, 2 + SBA_PLANAR_BITS + SBA_ORDER_BITS )]; + st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[add( *num_bits_read, 1 + SBA_PLANAR_BITS + SBA_ORDER_BITS )], 1 ) ); } #endif } @@ -1435,10 +1491,11 @@ ivas_error ivas_init_decoder_front( } } +#ifndef FIX_CREND_SIMPLIFY_CODE /*-------------------------------------------------------------------* * Allocate HRTF binary handle *--------------------------------------------------------------------*/ -#ifndef FIX_CREND_SIMPLIFY_CODE + IF( st_ivas->hDecoderConfig->Opt_HRTF_binary ) { IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ), IVAS_ERR_OK ) ) diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 08d2c340167fcdfcbb69a82d0b05c8cf8f12c558..ab404b2a9b730b3d496df7bba9fb849754774408 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -48,9 +48,12 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 nchan_transport_old, /* i : last number of transport channels */ - const ISM_MODE last_ism_mode, /* i : last ISM mode */ - UWord16 *nSamplesRendered, /* o : number of samples rendered */ - Word16 *data /* o : output synthesis signal Q0*/ + const ISM_MODE last_ism_mode /* i : last ISM mode */ +#ifndef FIX_HRTF_LOAD + , + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + Word16 *data /* o : output synthesis signal Q0*/ +#endif ) { ivas_error error; @@ -62,12 +65,16 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( Word16 tc_nchan_allocate_new; Word16 tc_granularity_new; Word16 nchan_out_buff, nchan_out_buff_old; +#ifndef FIX_HRTF_LOAD AUDIO_CONFIG intern_config_old; IVAS_OUTPUT_SETUP hIntSetupOld; RENDERER_TYPE renderer_type_old; +#endif +#ifndef FIX_HRTF_LOAD error = IVAS_ERR_OK; move32(); +#endif nCPE_old = st_ivas->nCPE; move16(); nSCE_old = st_ivas->nSCE; @@ -109,11 +116,14 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( /*-----------------------------------------------------------------* * HP20 memories *-----------------------------------------------------------------*/ + IF( NE_32( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_transport_old ) ), IVAS_ERR_OK ) ) { return error; } + +#ifndef FIX_HRTF_LOAD /* save old IntSetup, might be needed for JBM flushing...*/ intern_config_old = st_ivas->intern_config; move32(); @@ -123,7 +133,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( move16(); renderer_type_old = st_ivas->renderer_type; move32(); - +#endif /*-----------------------------------------------------------------* * Initialize the needed renderer struct and destroy the unnecessary renderer struct *-----------------------------------------------------------------*/ @@ -161,15 +171,18 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( render what still fits in the new granularity */ tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); - IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) - { - IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) - { + IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ){ +#ifdef FIX_HRTF_LOAD + /* flush already done in IVAS_DEC_ReadFormat() */ +#else + IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) ){ return error; - } + } +#endif } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ - ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + ELSE + IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) { @@ -238,7 +251,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( #ifdef FIX_CREND_SIMPLIFY_CODE IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hHrtfCrend, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, 0, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) #else - IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) #endif st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; @@ -301,7 +314,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( #ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); #else - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); #endif } } @@ -382,9 +395,14 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } } - return error; +#ifdef FIX_HRTF_LOAD + return IVAS_ERR_OK; +#else +return error; +#endif } + /*------------------------------------------------------------------------- * ivas_ism_dec_config() * @@ -393,18 +411,23 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( *-------------------------------------------------------------------------*/ ivas_error ivas_ism_dec_config_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ - UWord16 *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ - Word16 *data /* o : output synthesis signal Q0*/ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const ISM_MODE last_ism_mode /* i/o: last ISM mode */ +#ifndef FIX_HRTF_LOAD + , + UWord16 *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ + Word16 *data /* o : output synthesis signal Q0*/ +#endif ) { Word32 ivas_total_brate; ivas_error error; Word16 nchan_transport_old; +#ifndef FIX_HRTF_LOAD error = IVAS_ERR_OK; move32(); +#endif ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); /* Assumes that num of input objects are constant */ @@ -443,9 +466,14 @@ ivas_error ivas_ism_dec_config_fx( { /* ISM bit-rate switching */ test(); - IF( ( NE_16( st_ivas->ism_mode, last_ism_mode ) ) || ( NE_32( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) ) + IF( ( NE_16( st_ivas->ism_mode, last_ism_mode ) ) || ( NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) ) { +#ifdef FIX_HRTF_LOAD + IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode ) ), IVAS_ERR_OK ) ) + +#else IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -470,7 +498,11 @@ ivas_error ivas_ism_dec_config_fx( /* ISM mode switching */ IF( NE_32( st_ivas->ism_mode, last_ism_mode ) ) { +#ifdef FIX_HRTF_LOAD + IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode ) ), IVAS_ERR_OK ) ) +#else IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -500,5 +532,10 @@ ivas_error ivas_ism_dec_config_fx( move32(); BREAK; } + +#ifdef FIX_HRTF_LOAD + return IVAS_ERR_OK; +#else return error; +#endif } diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 5980879b428ec862cace22b463a8c546ac5db7e5..e3964ae25ca6ce76b8d8a5870e2f1a8bd7dca7a9 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -188,9 +188,9 @@ ivas_error ivas_masa_decode_fx( { /* re-read the number of objects, needed in case of bad frame */ #ifdef FIX_CREND_SIMPLIFY_CODE - ch = sub( 5, add( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 3], shl( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 2], 1 ) ) ); + ch = sub( 5, add( st_ivas->bit_stream[sub( bits_per_frame, 3 )], shl( st_ivas->bit_stream[sub( bits_per_frame, 2 )], 1 ) ) ); - IF( EQ_16( ch, 5 ) ) + if ( EQ_16( ch, 5 ) ) { ch = 0; move16(); @@ -1677,16 +1677,13 @@ static Word16 decode_lfe_to_total_energy_ratio_fx( * Reconfigure IVAS MASA decoder *-------------------------------------------------------------------*/ -/*-------------------------------------------------------------------* - * ivas_masa_dec_reconfigure_fx() - * - * Reconfigure IVAS MASA decoder - *-------------------------------------------------------------------*/ - ivas_error ivas_masa_dec_reconfigure_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef FIX_HRTF_LOAD + , UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ Word16 *data /* o : output synthesis signal */ +#endif ) { Word16 n, tmp, num_bits; @@ -1699,9 +1696,10 @@ ivas_error ivas_masa_dec_reconfigure_fx( Word32 ism_total_brate; Word16 pos_idx; +#ifndef FIX_HRTF_LOAD error = IVAS_ERR_OK; move16(); - +#endif ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; @@ -1741,7 +1739,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] == NULL ) ) { /* init a new DirAC dec */ - if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } @@ -1793,7 +1791,6 @@ ivas_error ivas_masa_dec_reconfigure_fx( FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { - // st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport; st_ivas->hSCE[sce_id]->element_brate = L_deposit_h( BASOP_Util_Divide3216_Scale( ivas_total_brate, st_ivas->nchan_transport, &tmp_e ) ); st_ivas->hSCE[sce_id]->element_brate = L_shr( st_ivas->hSCE[sce_id]->element_brate, sub( 15, tmp_e ) ); // Q0 @@ -1810,16 +1807,23 @@ ivas_error ivas_masa_dec_reconfigure_fx( tmp = extract_l( Mpy_32_32( st_ivas->hSCE[sce_id]->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); num_bits = add( num_bits, tmp ); - test(); - test(); - test(); - IF( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] != NULL ) +#ifdef FIX_HRTF_LOAD_KEEP_BE + if ( ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ) >= st_ivas->hTcBuffer->n_samples_granularity ) { - if ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) +#endif + test(); + test(); + test(); + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] != NULL ) { - return error; + IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) + { + return error; + } } +#ifdef FIX_HRTF_LOAD_KEEP_BE } +#endif } FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) @@ -1879,7 +1883,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] != NULL ) ) { - if ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) { return error; } @@ -1897,7 +1901,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] != NULL ) ) { - if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { return error; } @@ -1921,6 +1925,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ + IF( st_ivas->hDiracDecBin[0] != NULL ) { IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ), IVAS_ERR_OK ) ) @@ -1932,6 +1937,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( /*-----------------------------------------------------------------* * CLDFB instances *-----------------------------------------------------------------*/ + IF( st_ivas->hSpar ) { Word16 Q_tmp = getScaleFactor16( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 16 ); @@ -1939,7 +1945,8 @@ ivas_error ivas_masa_dec_reconfigure_fx( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_tmp; move16(); } - if ( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, st_ivas->nchan_transport, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) ) + + IF( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, st_ivas->nchan_transport, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) ) { return error; } @@ -2017,7 +2024,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ IF( GT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) { - if ( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -2027,10 +2034,14 @@ ivas_error ivas_masa_dec_reconfigure_fx( { IF( LT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) { +#ifdef FIX_HRTF_LOAD + /* flush already done in IVAS_DEC_ReadFormat() */ +#else if ( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) { return error; } +#endif } } } @@ -2077,7 +2088,11 @@ ivas_error ivas_masa_dec_reconfigure_fx( } } +#ifdef FIX_HRTF_LOAD + return IVAS_ERR_OK; +#else return error; +#endif } diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index d66a373e82bac230839c9ca0b61e71eb750c0e0c..1a745c4a24bcdfa15ce19d4f5e5d8dafe0f04a63 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -48,7 +48,11 @@ * Local function prototypes *-----------------------------------------------------------------------*/ +#ifdef FIX_HRTF_LOAD +static ivas_error ivas_mc_dec_reconfig_fx( Decoder_Struct *st_ivas ); +#else static ivas_error ivas_mc_dec_reconfig_fx( Decoder_Struct *st_ivas, UWord16 *nSamplesRendered, Word16 *data ); +#endif /*--------------------------------------------------------------------------* @@ -816,10 +820,13 @@ void ivas_mct_dec_close( /*! r : MC format mode */ ivas_error ivas_mc_dec_config_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 idx, /* i : LS config. index */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word16 idx /* i : LS config. index */ +#ifndef FIX_HRTF_LOAD + , UWord16 *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ Word16 *data /* o : output synthesis signal */ +#endif ) { AUDIO_CONFIG signaled_config; @@ -859,10 +866,16 @@ ivas_error ivas_mc_dec_config_fx( move16(); } } + +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = ivas_mc_dec_reconfig_fx( st_ivas ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_mc_dec_reconfig_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } + IF( st_ivas->hRenderConfig ) { FOR( Word16 i = 0; i < 4; i++ ) @@ -889,9 +902,12 @@ ivas_error ivas_mc_dec_config_fx( *-------------------------------------------------------------------------*/ static ivas_error ivas_mc_dec_reconfig_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef FIX_HRTF_LOAD + , UWord16 *nSamplesRendered, /* o : number of samples flushed from the last frame (JBM) */ Word16 *data /* o : output synthesis signal */ +#endif ) { Word16 nchan_transport_old, nSCE_old, nCPE_old, sba_dirac_stereo_flag_old, nchan_hp20_old; @@ -905,12 +921,17 @@ static ivas_error ivas_mc_dec_reconfig_fx( Word16 tc_nchan_tc_new; Word16 tc_nchan_allocate_new; Word16 tc_granularity_new; +#ifndef FIX_HRTF_LOAD AUDIO_CONFIG intern_config_old; IVAS_OUTPUT_SETUP hIntSetupOld; +#endif Word16 nchan_out_buff_old, nchan_out_buff; + +#ifndef FIX_HRTF_LOAD error = IVAS_ERR_OK; move32(); +#endif ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); nchan_transport_old = st_ivas->nchan_transport; @@ -949,13 +970,14 @@ static ivas_error ivas_mc_dec_reconfig_fx( st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); move16(); +#ifndef FIX_HRTF_LOAD /* save old IntSetup, might be needed for JBM flushing...*/ intern_config_old = st_ivas->intern_config; move32(); hIntSetupOld = st_ivas->hIntSetup; tc_granularity_new = 1; move16(); - +#endif /* renderer might have changed, reselect */ renderer_type_old = st_ivas->renderer_type; move32(); @@ -999,15 +1021,18 @@ static ivas_error ivas_mc_dec_reconfig_fx( render what still fits in the new granularity */ tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); move16(); - IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) - { - IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) - { + IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ){ +#ifdef FIX_HRTF_LOAD + /* flush already done in IVAS_DEC_ReadFormat() */ +#else + IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ), IVAS_ERR_OK ) ){ return error; - } +} +#endif } /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ - ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) + ELSE + IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) { @@ -1370,7 +1395,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( #ifdef NONBE_FIX_1220_OMASA_JBM_EXT_USAN ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) ) #else - ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) && st_ivas->hDirAC != NULL ) + ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) && st_ivas->hDirAC != NULL ) #endif { ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) ); @@ -1421,7 +1446,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( #ifdef FIX_CREND_SIMPLIFY_CODE ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); #else - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); #endif } @@ -1490,7 +1515,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( #ifdef FIX_CREND_SIMPLIFY_CODE IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hHrtfCrend, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, 0, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) #else - 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->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) + 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->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) #endif { return error; @@ -1671,5 +1696,10 @@ static ivas_error ivas_mc_dec_reconfig_fx( { return error; } - return error; + +#ifdef FIX_HRTF_LOAD + return IVAS_ERR_OK; +#else +return error; +#endif } diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 914dde94e33c16435d54b1810e5ac9e7068c0568..5e898d236581592d3e4595f9b3e25dec01e9c4d8 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -62,6 +62,15 @@ ivas_error ivas_td_binaural_open_fx( move16(); } +#ifdef FIX_HRTF_LOAD + if ( st_ivas->hHrtfTD == NULL && st_ivas->hDecoderConfig->Opt_HRTF_binary && + ( st_ivas->ivas_format != SBA_ISM_FORMAT ) // ToDo: temporary hack to avoid ASAN errors -> see issue #1202 + ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL, "HRTF binary file present but not used in TD renderer" ); + } + +#endif return ivas_td_binaural_open_unwrap_fx( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, *num_src, st_ivas->ivas_format, st_ivas->transport_config, st_ivas->hRenderConfig->directivity_fx, st_ivas->hRenderConfig->distAtt_fx, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns, SrcInd ); } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 439958731f2b132b4abf437f1618a24e6258372b..7278b9968fa35439ad267c76af69b8f34beef655 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -467,11 +467,16 @@ void ivas_omasa_data_close_fx( *--------------------------------------------------------------------------*/ ivas_error ivas_omasa_dec_config_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef FIX_HRTF_LOAD + Word16 *num_src, + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS] +#else UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ Word16 *num_src, Word16 SrcInd[MAX_NUM_TDREND_CHANNELS], Word16 *data /* o : output synthesis signal Qx*/ +#endif ) { Word16 k, sce_id, nSCE_old, nchan_hp20_old, numCldfbAnalyses_old, numCldfbSyntheses_old, n_MD; @@ -535,7 +540,11 @@ ivas_error ivas_omasa_dec_config_fx( } ELSE { +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = ivas_masa_dec_reconfigure_fx( st_ivas ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index c5df63529a3e351386b9154f60a7e24d2f597059..6a77c5c0ec6068c60b854d6489f8d0117521e487 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -107,9 +107,12 @@ void ivas_sba_set_cna_cng_flag( *-------------------------------------------------------------------*/ ivas_error ivas_sba_dec_reconfigure_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef FIX_HRTF_LOAD + , UWord16 *nSamplesFlushed, /* o : number of samples flushed Q0*/ Word16 *data /* o : output synthesis signal Q0*/ +#endif ) { Word16 nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; @@ -176,8 +179,10 @@ ivas_error ivas_sba_dec_reconfigure_fx( st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order ); +#ifndef FIX_HRTF_LOAD *nSamplesFlushed = 0; move16(); +#endif granularity_new = st_ivas->hTcBuffer->n_samples_granularity; /*Q0*/ move16(); @@ -236,6 +241,9 @@ ivas_error ivas_sba_dec_reconfigure_fx( /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ IF( LT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { +#ifdef FIX_HRTF_LOAD + /* flush already done in IVAS_DEC_ReadFormat() */ +#else /* write back info for correct rendering of the flushable samples */ st_ivas->sba_analysis_order = sba_analysis_order_old_flush; /*Q0*/ move16(); @@ -252,6 +260,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( move16(); st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; /*Q0*/ move32(); +#endif } ELSE IF( GT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { @@ -621,6 +630,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( /*-----------------------------------------------------------------* * HP20 memories *-----------------------------------------------------------------*/ + IF( NE_32( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ), IVAS_ERR_OK ) ) { return error; @@ -641,6 +651,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( /*-----------------------------------------------------------------* * CLDFB instances *-----------------------------------------------------------------*/ + IF( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) ) { return error; @@ -763,10 +774,20 @@ ivas_error ivas_sba_dec_reconfigure_fx( return error; } +#ifdef FIX_HRTF_LOAD + return IVAS_ERR_OK; +#else return error; +#endif } +/*-------------------------------------------------------------------* + * ivas_sba_dec_digest_tc() + * + * + *-------------------------------------------------------------------*/ + void ivas_sba_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const Word16 nCldfbSlots, /* i : number of CLDFB slots Q0*/ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index d0e887114ff5bbd162fc6e6d55913714bf6cc4a1..0dc09e13539f246cd62041f5dc2b9dea8871b822 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -273,14 +273,14 @@ ivas_error IVAS_DEC_VoIP_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ Word16 *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels Q0 */ - const UWord32 systemTimestamp_ms /* i : current system timestamp */ + const UWord32 systemTimestamp_ms, /* i : current system timestamp */ #ifdef SUPPORT_JBM_TRACEFILE - , JbmTraceFileWriterFn jbmWriterFn, - void* jbmWriter + JbmTraceFileWriterFn jbmWriterFn, + void* jbmWriter, #endif #ifdef FIX_CREND_SIMPLIFY_CODE -, - bool *bitstreamReadDone /* o : flag indicating that bitstream was read */ + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ + UWord16 *nSamplesRendered /* o : number of samples rendered */ #endif ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index a6e5a559516ee88b02b5cbca1d3f545cb2084cb2..d1c857d2e78a9ca1a12536e1959f072a5e10e25a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -96,6 +96,12 @@ struct IVAS_DEC Word16 sdp_hf_only; /* RTP payload format parameter: only Header-Full format without zero padding for size collision avoidance */ Word16 prev_ft_speech; /* RXDTX handler: previous frametype flag for G.192 format AMRWB SID_FIRST detection */ Word16 CNG; /* RXDTX handler: CNG=1, nonCNG=0 */ + +#ifdef FIX_HRTF_LOAD + UWord16 nSamplesFlushed; + Word16 flushbuffer[20 * 960 / 4]; // temp. hack + bool hasBeenPreparedRendering; +#endif }; /*---------------------------------------------------------------------* @@ -110,7 +116,11 @@ static ivas_error evs_dec_main_fx( Decoder_Struct *st_ivas, const Word16 nOutSam static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_format, Word16 *bitstream_format_internal, Word16 *sdp_hf_only, const bool is_voip_enabled ); static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const UWord16 nTransportChannels, const UWord16 l_ts ); +#ifdef FIX_HRTF_LOAD +static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, UWord16 *nTcBufferGranularity, UWord8 *nTransportChannels ); +#else static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, UWord16 *nTcBufferGranularity, UWord8 *nTransportChannels, UWord8 *nOutChannels, UWord16 *nSamplesRendered, Word16 *data ); +#endif static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, Word32 *pcmBuf_fx, Word16 *nOutSamples ); static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const Word16 nSamplesForRendering, Word16 *nSamplesResidual, Word32 *pcmBuf ); static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const UWord16 nSamplesForRendering, UWord16 *nSamplesRendered, UWord16 *nSamplesAvailableNext, Word16 *pcmBuf ); @@ -184,6 +194,10 @@ ivas_error IVAS_DEC_Open( move16(); move16(); move16(); +#ifdef FIX_HRTF_LOAD + hIvasDec->nSamplesFlushed = 0; + hIvasDec->hasBeenPreparedRendering = false; +#endif hIvasDec->mode = mode; move16(); @@ -1158,10 +1172,14 @@ ivas_error IVAS_DEC_GetSamples( /* check if we need to run the setup function */ test(); IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ){ - /* setup */ - - IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ){ - return error; + /* setup */ +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels ) ), IVAS_ERR_OK ) ) +#else + IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) +#endif + { + return error; } } { @@ -1558,30 +1576,40 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ UWord16 *nTcBufferGranularity, /* o : granularity of the TC Buffer */ - UWord8 *nTransportChannels, /* o : number of decoded transport PCM channels */ - UWord8 *nOutChannels, /* o : number of decoded out channels (PCM or CLDFB) */ - UWord16 *nSamplesRendered, /* o : number of samples flushed from the last frame */ - Word16 *data /* o : output synthesis signal Q0 */ + UWord8 *nTransportChannels /* o : number of decoded transport PCM channels */ +#ifndef FIX_HRTF_LOAD + , + UWord8 *nOutChannels, /* o : number of decoded out channels (PCM or CLDFB) */ + UWord16 *nSamplesRendered, /* o : number of samples flushed from the last frame */ + Word16 *data /* o : output synthesis signal Q0 */ +#endif ) { ivas_error error; +#ifndef FIX_HRTF_LOAD *nSamplesRendered = 0; move16(); - +#endif IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) { IF( EQ_16( (Word16) hIvasDec->st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { *nTransportChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; +#ifndef FIX_HRTF_LOAD *nOutChannels = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; +#endif } ELSE { *nTransportChannels = 1; +#ifndef FIX_HRTF_LOAD *nOutChannels = 1; +#endif } +#ifndef FIX_HRTF_LOAD move16(); +#endif move16(); } ELSE @@ -1641,7 +1669,11 @@ static ivas_error IVAS_DEC_Setup( } } +#ifdef FIX_HRTF_LOAD + IF( NE_32( ( error = ivas_dec_setup( st_ivas ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -1717,8 +1749,10 @@ static ivas_error IVAS_DEC_Setup( *nTransportChannels = (UWord8) st_ivas->hTcBuffer->nchan_transport_jbm; *nTcBufferGranularity = (UWord16) st_ivas->hTcBuffer->n_samples_granularity; +#ifndef FIX_HRTF_LOAD *nOutChannels = (UWord8) st_ivas->hDecoderConfig->nchan_out; move16(); +#endif move16(); move16(); @@ -1938,8 +1972,33 @@ static ivas_error IVAS_DEC_GetRenderedSamples( st_ivas = hIvasDec->st_ivas; +#ifdef FIX_HRTF_LOAD + // temp code to make HRTF changes working in the old API structure + UWord16 nSamplesRendered_loop = 0; + Word16 nOutChannels = st_ivas->hDecoderConfig->nchan_out; + move16(); + hIvasDec->hasBeenFedFrame = false; + + /* check for possible flushed samples from a rate switch */ + IF( hIvasDec->nSamplesFlushed > 0 ) + { + /* note: offset (rendered samples) is always 0 */ + Copy( hIvasDec->flushbuffer, pcmBuf, hIvasDec->nSamplesFlushed * nOutChannels ); + + *nSamplesRendered = hIvasDec->nSamplesFlushed; + hIvasDec->nSamplesFlushed = 0; + move16(); + move16(); + } + + /* run the main IVAS decoding routine */ + error = ivas_jbm_dec_render_fx( st_ivas, nSamplesForRendering - *nSamplesRendered, &nSamplesRendered_loop, nSamplesAvailableNext, pcmBuf + ( *nSamplesRendered * nOutChannels ) ); + + *nSamplesRendered = add( *nSamplesRendered, nSamplesRendered_loop ); +#else /* run the main IVAS decoding routine */ error = ivas_jbm_dec_render_fx( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcmBuf ); +#endif return error; } @@ -2701,6 +2760,7 @@ ivas_error IVAS_DEC_GetHrtfStatisticsHandle( return IVAS_ERR_OK; } + #ifdef FIX_CREND_SIMPLIFY_CODE /*---------------------------------------------------------------------* * IVAS_DEC_HRTF_binary_open( ) @@ -2729,7 +2789,7 @@ ivas_error IVAS_DEC_HRTF_binary_open( /* TD binaural renderer */ test(); test(); - IF( ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && st_ivas->hHrtfTD == NULL ) + IF( ( EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_TDREND ) || EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) && st_ivas->hHrtfTD == NULL ) { IF( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) { @@ -2740,7 +2800,7 @@ ivas_error IVAS_DEC_HRTF_binary_open( /* Crend binaural renderer */ test(); test(); - IF( ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && st_ivas->hHrtfCrend == NULL ) + IF( ( EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_CREND ) || EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) && st_ivas->hHrtfCrend == NULL ) { IF( ( error = ivas_HRTF_CRend_binary_open_fx( &( st_ivas->hHrtfCrend ) ) ) != IVAS_ERR_OK ) { @@ -2751,7 +2811,7 @@ ivas_error IVAS_DEC_HRTF_binary_open( /* FastConv binaural renderer */ test(); test(); - IF( ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && st_ivas->hHrtfFastConv == NULL ) + IF( ( EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_FASTCONV ) || EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) && st_ivas->hHrtfFastConv == NULL ) { IF( ( error = ivas_HRTF_fastconv_binary_open_fx( &st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) { @@ -2762,7 +2822,7 @@ ivas_error IVAS_DEC_HRTF_binary_open( /* Parametric binaural renderer */ test(); test(); - IF( ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_PARAMBIN || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && st_ivas->hHrtfParambin == NULL ) + IF( ( EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_PARAMBIN ) || EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) && st_ivas->hHrtfParambin == NULL ) { IF( ( error = ivas_HRTF_parambin_binary_open_fx( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { @@ -2773,7 +2833,7 @@ ivas_error IVAS_DEC_HRTF_binary_open( test(); test(); test(); - IF( st_ivas->hHrtfStatistics == NULL && ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + IF( st_ivas->hHrtfStatistics == NULL && ( EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_FASTCONV ) || EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_CREND ) ) && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { IF( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ) != IVAS_ERR_OK ) { @@ -2785,6 +2845,7 @@ ivas_error IVAS_DEC_HRTF_binary_open( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_HRTF_binary_close( ) * @@ -2845,6 +2906,7 @@ ivas_error IVAS_DEC_HRTF_binary_close( } #endif + /*---------------------------------------------------------------------* * copyRendererConfigStruct( ) * @@ -3602,6 +3664,57 @@ ivas_error IVAS_DEC_ReadFormat( } } } + +#ifdef FIX_HRTF_LOAD + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( NE_32( renderer_type_old, st_ivas->renderer_type ) && NE_32( renderer_type_old, RENDERER_DISABLE ) ) || + ( st_ivas->ini_active_frame > 0 && ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) + { + /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv + render what still fits in the new granularity */ + Word16 tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + + // st_ivas->nchan_transport = nchan_transport_old; // ToDo: temporarily deactivated to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1200 + + if ( st_ivas->ivas_format == MASA_FORMAT ) + { + st_ivas->nchan_ism = 0; // ToDo: temporary hack to keep FIX_HRTF_LOAD bit-exact but this is likely a bug in the main -> see issue #1199 + } + + IF( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) + { +#ifdef FIX_HRTF_LOAD_KEEP_BE + if ( ivas_format_old == MASA_ISM_FORMAT && ism_mode_old == ISM_MASA_MODE_DISC ) + { + if ( st_ivas->hDiracDecBin[0] != NULL ) + { + IF( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) && st_ivas->hDiracDecBin[0] != NULL ) + { + if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#endif + IF( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &st_ivas->hIntSetup, mc_mode_old, ism_mode_old, &hIvasDec->nSamplesFlushed, hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#endif } st_ivas->ism_mode = ism_mode_old; @@ -3619,6 +3732,8 @@ ivas_error IVAS_DEC_ReadFormat( return IVAS_ERR_OK; } #endif + + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_GetSamples( ) * @@ -3626,18 +3741,17 @@ ivas_error IVAS_DEC_ReadFormat( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_VoIP_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - Word16 *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels Q0 */ - const UWord32 systemTimestamp_ms /* i : current system timestamp */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + UWord16 nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + Word16 *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels Q0 */ + const UWord32 systemTimestamp_ms, /* i : current system timestamp */ #ifdef SUPPORT_JBM_TRACEFILE - , JbmTraceFileWriterFn jbmWriterFn, - void *jbmWriter + void *jbmWriter, #endif #ifdef FIX_CREND_SIMPLIFY_CODE - , - bool *bitstreamReadDone /* o : flag indicating that bitstream was read */ + bool *bitstreamReadDone, /* o : that bitstream was read */ + UWord16 *nSamplesRendered /* o : number of samples rendered */ #endif ) { @@ -3649,7 +3763,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( UWord16 extBufferedSamples; Word16 result; ivas_error error; +#ifndef FIX_CREND_SIMPLIFY_CODE Word16 nSamplesRendered; +#endif UWord8 nOutChannels; test(); @@ -3663,7 +3779,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hDecoderConfig = st_ivas->hDecoderConfig; hVoIP = hIvasDec->hVoIP; nOutChannels = (UWord8) st_ivas->hDecoderConfig->nchan_out; +#ifndef FIX_CREND_SIMPLIFY_CODE nSamplesRendered = 0; +#endif move16(); move16(); move16(); @@ -3673,8 +3791,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return IVAS_ERR_WRONG_PARAMS; } - /* make sure that the FIFO after decoder/scaler contains at least one sound card frame (i.e. 20ms) */ +/* make sure that the FIFO after decoder/scaler contains at least one sound card frame (i.e. 20ms) */ +#ifdef FIX_CREND_SIMPLIFY_CODE + WHILE( LT_16( *nSamplesRendered, nSamplesPerChannel ) ) +#else WHILE( LT_16( nSamplesRendered, nSamplesPerChannel ) ) +#endif { IF( hIvasDec->nSamplesAvailableNext == 0 ) { @@ -3759,6 +3881,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { return error; } + #ifdef FIX_CREND_SIMPLIFY_CODE *bitstreamReadDone = true; #endif @@ -3802,6 +3925,15 @@ ivas_error IVAS_DEC_VoIP_GetSamples( JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); } +#ifdef FIX_HRTF_LOAD + test(); + IF( hIvasDec->hasBeenFedFirstGoodFrame && *bitstreamReadDone == true ) + { + /* new bitstream was feeded, return for reconfiguration */ + return IVAS_ERR_OK; + } + +#endif IF( !hIvasDec->hasBeenFedFirstGoodFrame ) { hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; @@ -3817,8 +3949,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* codec mode to use not known yet - simply output silence */ /* directly set output zero */ Word16 nSamplesToZero = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); +#ifdef FIX_CREND_SIMPLIFY_CODE + set16_fx( pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), 0, imult1616( nSamplesToZero, nOutChannels ) ); + *nSamplesRendered = add( *nSamplesRendered, nSamplesToZero ); +#else set16_fx( pcmBuf + imult1616( nSamplesRendered, nOutChannels ), 0, imult1616( nSamplesToZero, nOutChannels ) ); nSamplesRendered = add( nSamplesRendered, nSamplesToZero ); +#endif hIvasDec->nSamplesRendered = add( hIvasDec->nSamplesRendered, nSamplesToZero ); hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero ); move16(); @@ -3829,15 +3966,30 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { Word16 nSamplesToRender, nSamplesRendered_loop; bool tmp; +#ifdef FIX_CREND_SIMPLIFY_CODE + nSamplesToRender = sub( nSamplesPerChannel, *nSamplesRendered ); +#else nSamplesToRender = sub( nSamplesPerChannel, nSamplesRendered ); +#endif /* render IVAS frames directly to the output buffer */ +#ifdef FIX_CREND_SIMPLIFY_CODE + IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( *nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) +#endif { return error; } +#ifdef FIX_HRTF_LOAD + *bitstreamReadDone = false; // temp hack until JBM API is reworked +#endif +#ifdef FIX_CREND_SIMPLIFY_CODE + *nSamplesRendered = add( *nSamplesRendered, nSamplesRendered_loop ); +#else nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); +#endif update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); } } @@ -3895,6 +4047,9 @@ ivas_error IVAS_DEC_Flush( ivas_error error; UWord16 nSamplesToRender; UWord16 nSamplesFlushedLocal; +#ifdef FIX_HRTF_LOAD + nSamplesFlushedLocal = 0; // temp. hack +#endif test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index d610a4a083f2e05d5d2b2d8f109e9fdf8012484c..d957215d7d776432df253d0b0e9d0a7b1ba37902 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1118,7 +1118,11 @@ ivas_error ISAR_POST_REND_InitConfig( hIvasRend->splitRenderConfig.isar_frame_size_ms = 0; /* 0 means "use default for selected codec" */ hIvasRend->splitRenderConfig.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; hIvasRend->splitRenderConfig.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; +#ifdef FIX_HRTF_LOAD + hIvasRend->splitRenderConfig.rendererSelection = IVAS_BIN_RENDERER_TYPE_DEFAULT; +#else hIvasRend->splitRenderConfig.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT; +#endif } return IVAS_ERR_OK; diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 565bfd380d2d54674b0b85a516bb65559a5704dd..60849b7ba774e03d0169dd975c5b859fc714281c 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -2226,6 +2226,7 @@ void ivas_rend_closeCldfbRend( * * Convolver block *-----------------------------------------------------------------------------------------*/ + #ifdef FIX_CREND_SIMPLIFY_CODE static ivas_error ivas_rend_crendConvolver( const CREND_WRAPPER *pCrend, diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index afcaa5ae1b516198287605b30df96f464868fc6e..66cc455eb9d6fbd2b7684346be40916c8a7aaf20 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -456,12 +456,15 @@ void ivas_dirac_dec_close_binaural_data( return; } + + /*------------------------------------------------------------------------- * ivas_dirac_dec_binaural_copy_hrtfs() * * Temporary function for copying HRTF data from rom tables if no binary * file was given. *------------------------------------------------------------------------*/ + ivas_error ivas_dirac_dec_binaural_copy_hrtfs_fx( HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ ) @@ -511,17 +514,18 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs_fx( Copy32( parametricEarlyPartEneCorrection_fx, hrtfParambin->parametricEarlyPartEneCorrection_fx, CLDFB_NO_CHANNELS_MAX ); /*Q28*/ #endif *hHrtfParambin = hrtfParambin; - } - return IVAS_ERR_OK; + return IVAS_ERR_OK; + } } /*------------------------------------------------------------------------- - * void ivas_dirac_dec_binaural_render_fx() + * void ivas_dirac_dec_binaural_render() * * *------------------------------------------------------------------------*/ + void ivas_dirac_dec_binaural_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ @@ -4867,7 +4871,7 @@ static void getDirectPartGains_fx( Word16 aziRadMapped, A, A2, A3; const Word16 LsAngleRad = 17157; // Q15 move16(); - Word32 *ptr_sin, *ptr_cos; + const Word32 *ptr_sin, *ptr_cos; Word32 sin_val, cos_val; Word16 e_mappedX; diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 8cfb7d18eb30b5a4d5d4bf7e65fd6ddf3608ac86..83615cfb77fe3968a8bada855aa31b04d86f8d4d 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -3542,7 +3542,7 @@ void rotateAziEle_DirAC_fx( Word32 dv_0_fx, dv_1_fx, dv_2_fx; Word32 dv_r_0_fx, dv_r_1_fx, dv_r_2_fx, tmp, w_fx; Word16 exp, temp; - Word32 *ptr_sin, *ptr_cos; + const Word32 *ptr_sin, *ptr_cos; ptr_sin = &sine_table_Q31[180]; // sin[x] = sine_table_Q31[180 + x] q31 ptr_cos = cosine_table_Q31; // q31 diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 89b11b66dd660ef8faca839b2a4356c25275d45d..712213775cf94767cb01967d8d08595c1f93c99c 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -109,28 +109,7 @@ ivas_error ivas_HRTF_CRend_binary_open_fx( /*-----------------------------------------------------------------------* - * ivas_HRTF_CRend_binary_open_buffers_uint16() - * - * Allocate buffer with dynamic length for HRTF binary Crend handle - *-----------------------------------------------------------------------*/ - -ivas_error ivas_HRTF_CRend_binary_open_buffers_uint16( - UWord16 **buffer, /* o : buffer to allocate */ - const UWord32 mem_size /* i : size of buffer */ -) -{ - *buffer = (UWord16 *) malloc( mem_size ); - - if ( *buffer == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); - } - - return IVAS_ERR_OK; -} - -/*-----------------------------------------------------------------------* - * ivas_HRTF_CRend_binary_open_buffers_uint16() + * ivas_HRTF_CRend_binary_open_buffers_int16() * * Allocate buffer with dynamic length for HRTF binary Crend handle *-----------------------------------------------------------------------*/ @@ -150,49 +129,6 @@ ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( return IVAS_ERR_OK; } - -/*-----------------------------------------------------------------------* - * ivas_HRTF_CRend_binary_open_buffers_float() - * - * Allocate buffer with dynamic length for HRTF binary Crend handle - *-----------------------------------------------------------------------*/ - -ivas_error ivas_HRTF_CRend_binary_open_buffers_float( - float **buffer, /* o : buffer to allocate */ - const UWord32 mem_size /* i : size of buffer */ -) -{ - *buffer = (float *) malloc( mem_size ); - - IF( *buffer == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); - } - - return IVAS_ERR_OK; -} - -/*-----------------------------------------------------------------------* - * ivas_HRTF_CRend_binary_open_buffers_int32() - * - * Allocate buffer with dynamic length for HRTF binary Crend handle - *-----------------------------------------------------------------------*/ - -ivas_error ivas_HRTF_CRend_binary_open_buffers_int32( - Word32 **buffer, /* o : buffer to allocate */ - const UWord32 mem_size /* i : size of buffer */ -) -{ - *buffer = (Word32 *) malloc( mem_size ); - - IF( *buffer == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); - } - - return IVAS_ERR_OK; -} - #else /*-----------------------------------------------------------------------* * ivas_HRTF_CRend_binary_open() @@ -300,6 +236,7 @@ void ivas_HRTF_CRend_binary_close_fx( } #endif + /*-----------------------------------------------------------------------* * ivas_HRTF_fastconv_binary_open() * @@ -314,7 +251,9 @@ ivas_error ivas_HRTF_fastconv_binary_open_fx( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FASTCONV HRTF tables!" ); } + ivas_init_binaural_hrtf_fx( *hHrtfFastConv ); + return IVAS_ERR_OK; } @@ -462,17 +401,17 @@ ivas_error ivas_HRTF_statistics_init( { case 48000: HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - if ( HrtfStatistics->average_energy_l_dyn == NULL ) + IF( HrtfStatistics->average_energy_l_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - if ( HrtfStatistics->average_energy_r_dyn == NULL ) + IF( HrtfStatistics->average_energy_r_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - if ( HrtfStatistics->inter_aural_coherence_dyn == NULL ) + IF( HrtfStatistics->inter_aural_coherence_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } @@ -491,17 +430,17 @@ ivas_error ivas_HRTF_statistics_init( break; case 32000: HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - if ( HrtfStatistics->average_energy_l_dyn == NULL ) + IF( HrtfStatistics->average_energy_l_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - if ( HrtfStatistics->average_energy_r_dyn == NULL ) + IF( HrtfStatistics->average_energy_r_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); - if ( HrtfStatistics->inter_aural_coherence_dyn == NULL ) + IF( HrtfStatistics->inter_aural_coherence_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } @@ -552,6 +491,5 @@ ivas_error ivas_HRTF_statistics_init( *hHrtfStatistics = HrtfStatistics; - return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 4c30f23de7ce0945b0495b097f19db6900798f63..5b18e8a43642e1e7e0e906996b628ff85ed06ee7 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -853,8 +853,6 @@ ivas_error TDREND_SRC_Alloc( ivas_error error; TDREND_SRC_t *Src_p; - error = IVAS_ERR_OK; - move32(); *Src_pp = NULL; /* Allocate the TDREND_SRC_t variable */ @@ -877,7 +875,7 @@ ivas_error TDREND_SRC_Alloc( *Src_pp = Src_p; - return error; + return IVAS_ERR_OK; } /*-------------------------------------------------------------------* diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 87b927ab74137f5303f81306a5559b48401eb185..b5a0a8d6e206ce31e661aed90ac8b4dfae77f1af 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -617,23 +617,8 @@ ivas_error ivas_HRTF_CRend_binary_open_fx( HRTFS_CREND_DATA **hHrtfCrend /* i/o: Crend HRTF handle */ ); -ivas_error ivas_HRTF_CRend_binary_open_buffers_uint16( - uint16_t **buffer, /* o : buffer to allocate */ - const uint32_t mem_size /* i : size of buffer */ -); - -ivas_error ivas_HRTF_CRend_binary_open_buffers_float( - float **buffer, /* o : buffer to allocate */ - const uint32_t mem_size /* i : size of buffer */ -); - ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( - int16_t **buffer, /* o : buffer to allocate */ - const uint32_t mem_size /* i : size of buffer */ -); - -ivas_error ivas_HRTF_CRend_binary_open_buffers_int32( - int32_t **buffer, /* o : buffer to allocate */ + int16_t **buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ ); @@ -645,7 +630,6 @@ ivas_error ivas_HRTF_statistics_init( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ const int32_t sampleRate /* i : Sample rate */ ); - #else ivas_error ivas_HRTF_CRend_binary_open_fx( diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index 98e5a0b3324fc63091defb5efac165317dfd66b2..ca2d7ef9fb21dbf4a87d635699f2492f6a22b37b 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -156,7 +156,11 @@ ivas_error ivas_render_config_init_from_rom_fx( move32(); ( *hRenderConfig )->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; move32(); +#ifdef FIX_HRTF_LOAD + ( *hRenderConfig )->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_DEFAULT; +#else ( *hRenderConfig )->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT; +#endif move32(); ( *hRenderConfig )->split_rend_config.lc3plus_highres = 0; move16(); diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index f794e0327a5832efe85619047ce7d808d8d7f49f..bfb82b4619bb350f76168de80910a69f9aad8f7c 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -59,37 +59,40 @@ extern const Word16 hrtfShCoeffs_factorQ_fx; extern const Word16 parametricReverberationTimes_factorQ_fx; extern const Word16 parametricReverberationEneCorrections_factorQ_fx; extern const Word16 parametricEarlyPartEneCorrection_factorQ_fx; -extern Word16 leftHRIRReal_HOA3_fx[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ -extern Word16 leftHRIRImag_HOA3_fx[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ -extern Word16 rightHRIRReal_HOA3_fx[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ -extern Word16 rightHRIRImag_HOA3_fx[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ -extern Word16 leftHRIRReal_HOA2_fx[BINAURAL_CONVBANDS][HOA2_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ -extern Word16 leftHRIRImag_HOA2_fx[BINAURAL_CONVBANDS][HOA2_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ -extern Word16 rightHRIRReal_HOA2_fx[BINAURAL_CONVBANDS][HOA2_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ -extern Word16 rightHRIRImag_HOA2_fx[BINAURAL_CONVBANDS][HOA2_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ -extern Word16 leftHRIRReal_FOA_fx[BINAURAL_CONVBANDS][FOA_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ -extern Word16 leftHRIRImag_FOA_fx[BINAURAL_CONVBANDS][FOA_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ -extern Word16 rightHRIRReal_FOA_fx[BINAURAL_CONVBANDS][FOA_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ -extern Word16 rightHRIRImag_FOA_fx[BINAURAL_CONVBANDS][FOA_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ -extern Word16 leftHRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]; /* Q29 */ -extern Word16 leftHRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]; /* Q29 */ -extern Word16 rightHRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]; /* Q29 */ -extern Word16 rightHRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]; /* Q29 */ -extern Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ -extern Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ +extern const Word16 leftHRIRReal_HOA3_fx[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ +extern const Word16 leftHRIRImag_HOA3_fx[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ +extern const Word16 rightHRIRReal_HOA3_fx[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ +extern const Word16 rightHRIRImag_HOA3_fx[BINAURAL_CONVBANDS][HOA3_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ +extern const Word16 leftHRIRReal_HOA2_fx[BINAURAL_CONVBANDS][HOA2_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ +extern const Word16 leftHRIRImag_HOA2_fx[BINAURAL_CONVBANDS][HOA2_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ +extern const Word16 rightHRIRReal_HOA2_fx[BINAURAL_CONVBANDS][HOA2_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ +extern const Word16 rightHRIRImag_HOA2_fx[BINAURAL_CONVBANDS][HOA2_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ +extern const Word16 leftHRIRReal_FOA_fx[BINAURAL_CONVBANDS][FOA_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ +extern const Word16 leftHRIRImag_FOA_fx[BINAURAL_CONVBANDS][FOA_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ +extern const Word16 rightHRIRReal_FOA_fx[BINAURAL_CONVBANDS][FOA_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ +extern const Word16 rightHRIRImag_FOA_fx[BINAURAL_CONVBANDS][FOA_CHANNELS][BINAURAL_NTAPS_SBA]; /* Q29 */ +extern const Word16 leftHRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]; /* Q29 */ +extern const Word16 leftHRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]; /* Q29 */ +extern const Word16 rightHRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]; /* Q29 */ +extern const Word16 rightHRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS]; /* Q29 */ +extern const Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ +extern const Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ + +extern const Word32 FASTCONV_HOA3_latency_s_fx; +extern const Word32 FASTCONV_HOA2_latency_s_fx; +extern const Word32 FASTCONV_FOA_latency_s_fx; -extern Word32 FASTCONV_HOA3_latency_s_fx; -extern Word32 FASTCONV_HOA2_latency_s_fx; -extern Word32 FASTCONV_FOA_latency_s_fx; /* Binaural rendering data set based on HRIRs */ extern const Word32 FASTCONV_HRIR_latency_s_fx; + /* Binaural rendering data set based on BRIRs */ extern const Word32 FASTCONV_BRIR_latency_s_fx; extern const Word16 FASTCONV_factor_Q_BRIR_latency_s_fx; -extern Word16 leftBRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; /* Q29 */ -extern Word16 leftBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; /* Q29 */ -extern Word16 rightBRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; /* Q29 */ -extern Word16 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; /* Q29 */ +extern const Word16 leftBRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; /* Q29 */ +extern const Word16 leftBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; /* Q29 */ +extern const Word16 rightBRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; /* Q29 */ +extern const Word16 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; /* Q29 */ + /* Reverberation parameters based on BRIRs for fastconv */ extern Word16 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ extern Word16 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ diff --git a/lib_rend/ivas_rom_binauralRenderer_fx.c b/lib_rend/ivas_rom_binauralRenderer_fx.c index 568b25ae25e145aeda5c29c89000f39103c5589f..630740efbc73d290ecd1071305b78da4c2acac81 100644 --- a/lib_rend/ivas_rom_binauralRenderer_fx.c +++ b/lib_rend/ivas_rom_binauralRenderer_fx.c @@ -43,14 +43,14 @@ /*------------------------------------------------------------------------- * Binaural rendering related ROM tables *------------------------------------------------------------------------*/ - +#ifdef DEBUGGING /* Binaural rendering data set based on HRIRs */ /* Tables generated by the script at "scripts/binauralRenderer_interface/run_generate_IVAS_tables.m */ /* Can be replaced by your own generated HRIR tables */ /* * Generated with Matlab version 9.3.0.713579 (R2017b) by MUXE6256 */ - +#endif #ifdef USE_FASTCONV_PARAMBIN_16BIT_ROM diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index 660b03fa17b4ecad52160ffdcf9dbd109024da51..e9a3a20cec977b679fc4a9815b6bf9a5b4466d3a 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -47,8 +47,8 @@ #include "ivas_cnst.h" -extern Word32 sine_table_Q31 [361]; -extern Word32 cosine_table_Q31 [181]; +extern const Word32 sine_table_Q31 [361]; +extern const Word32 cosine_table_Q31 [181]; #ifdef FIX_CREND_SIMPLIFY_CODE @@ -70,8 +70,8 @@ extern const Word16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[B extern const Word16 CRendBin_Combined_HRIR_coeff_Q_48kHz_fx; extern const Word16 CRendBin_Combined_HRIR_coeff_re_48kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][240]; extern const Word16 CRendBin_Combined_HRIR_coeff_im_48kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][240]; -extern Word16 *CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; -extern Word16 *CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ @@ -86,8 +86,8 @@ extern const Word16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[B extern const Word16 CRendBin_Combined_HRIR_coeff_Q_32kHz_fx; extern const Word16 CRendBin_Combined_HRIR_coeff_re_32kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][160]; extern const Word16 CRendBin_Combined_HRIR_coeff_im_32kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][160]; -extern Word16 *CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; -extern Word16 *CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 16000 */ @@ -102,8 +102,8 @@ extern const Word16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[B extern const Word16 CRendBin_Combined_HRIR_coeff_Q_16kHz_fx; extern const Word16 CRendBin_Combined_HRIR_coeff_re_16kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][80]; extern const Word16 CRendBin_Combined_HRIR_coeff_im_16kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][80]; -extern Word16 *CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; -extern Word16 *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]; @@ -125,8 +125,8 @@ extern const Word16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAUR extern const Word16 CRendBin_FOA_HRIR_coeff_Q_48kHz_fx; extern const Word16 CRendBin_FOA_HRIR_coeff_re_48kHz_fx[FOA_CHANNELS][BINAURAL_CHANNELS][240]; extern const Word16 CRendBin_FOA_HRIR_coeff_im_48kHz_fx[FOA_CHANNELS][BINAURAL_CHANNELS][240]; -extern Word16 *CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; -extern Word16 *CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ @@ -157,8 +157,8 @@ extern const Word16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAUR extern const Word16 CRendBin_FOA_HRIR_coeff_Q_16kHz_fx; extern const Word16 CRendBin_FOA_HRIR_coeff_re_16kHz_fx[FOA_CHANNELS][BINAURAL_CHANNELS][80]; extern const Word16 CRendBin_FOA_HRIR_coeff_im_16kHz_fx[FOA_CHANNELS][BINAURAL_CHANNELS][80]; -extern Word16 *CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; -extern Word16 *CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]; @@ -180,8 +180,8 @@ extern const Word16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAU extern const Word16 CRendBin_HOA2_HRIR_coeff_Q_48kHz_fx; extern const Word16 CRendBin_HOA2_HRIR_coeff_re_48kHz_fx[HOA2_CHANNELS][BINAURAL_CHANNELS][240]; extern const Word16 CRendBin_HOA2_HRIR_coeff_im_48kHz_fx[HOA2_CHANNELS][BINAURAL_CHANNELS][240]; -extern Word16 *CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; -extern Word16 *CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ @@ -212,8 +212,8 @@ extern const Word16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAU extern const Word16 CRendBin_HOA2_HRIR_coeff_Q_16kHz_fx; extern const Word16 CRendBin_HOA2_HRIR_coeff_re_16kHz_fx[HOA2_CHANNELS][BINAURAL_CHANNELS][80]; extern const Word16 CRendBin_HOA2_HRIR_coeff_im_16kHz_fx[HOA2_CHANNELS][BINAURAL_CHANNELS][80]; -extern Word16 *CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; -extern Word16 *CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]; @@ -235,8 +235,8 @@ extern const Word16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAU extern const Word16 CRendBin_HOA3_HRIR_coeff_Q_48kHz_fx; extern const Word16 CRendBin_HOA3_HRIR_coeff_re_48kHz_fx[HOA3_CHANNELS][BINAURAL_CHANNELS][240]; extern const Word16 CRendBin_HOA3_HRIR_coeff_im_48kHz_fx[HOA3_CHANNELS][BINAURAL_CHANNELS][240]; -extern Word16 *CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; -extern Word16 *CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ @@ -251,8 +251,8 @@ extern const Word16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAU extern const Word16 CRendBin_HOA3_HRIR_coeff_Q_32kHz_fx; extern const Word16 CRendBin_HOA3_HRIR_coeff_re_32kHz_fx[HOA3_CHANNELS][BINAURAL_CHANNELS][160]; extern const Word16 CRendBin_HOA3_HRIR_coeff_im_32kHz_fx[HOA3_CHANNELS][BINAURAL_CHANNELS][160]; -extern Word16 *CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; -extern Word16 *CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; +extern const Word16 *CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; /* Sample Rate = 16000 */ @@ -290,8 +290,8 @@ extern const Word16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BI extern const Word16 CRendBin_Combined_BRIR_coeff_Q_48kHz_fx; extern const Word16 CRendBin_Combined_BRIR_coeff_re_48kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2955]; extern const Word16 CRendBin_Combined_BRIR_coeff_im_48kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2955]; -extern Word16 CRendBin_Combined_BRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS][2885]; -extern Word16 CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS][2885]; +extern const Word16 CRendBin_Combined_BRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS][2885]; +extern const Word16 CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS][2885]; /* Sample Rate = 32000 */ @@ -306,8 +306,8 @@ extern const Word16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BI extern const Word16 CRendBin_Combined_BRIR_coeff_Q_32kHz_fx; extern const Word16 CRendBin_Combined_BRIR_coeff_re_32kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2818]; extern const Word16 CRendBin_Combined_BRIR_coeff_im_32kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2818]; -extern Word16 CRendBin_Combined_BRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS][2868]; -extern Word16 CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS][2868]; +extern const Word16 CRendBin_Combined_BRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS][2868]; +extern const Word16 CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS][2868]; /* Sample Rate = 16000 */ @@ -322,8 +322,8 @@ extern const Word16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BI extern const Word16 CRendBin_Combined_BRIR_coeff_Q_16kHz_fx; extern const Word16 CRendBin_Combined_BRIR_coeff_re_16kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1799]; extern const Word16 CRendBin_Combined_BRIR_coeff_im_16kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1799]; -extern Word16 CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS][2474]; -extern Word16 CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS][2474]; +extern const Word16 CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS][2474]; +extern const Word16 CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS][2474]; #ifdef USE_REVERB_16BIT_ROM /********************** default HRIR reverb rom tables **********************/ diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c index 1849f19e2cb282b0ca46b021e3a764fcb9120c1f..108e347693418c68740f14e3d9e9a11165bdef4f 100644 --- a/lib_rend/ivas_rom_binaural_crend_head_fx.c +++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c @@ -67489,7 +67489,7 @@ const float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = #endif -Word32 sine_table_Q31 [361] = { +const Word32 sine_table_Q31 [361] = { 187, -37478868, -74946000, -112390808, -149800880, -187165824, -224473232, -261712288, -298872128, -335940416, -372906880, -409759232, -446486784, -483078848, -519523232, -555809856, -591926720, -627863744, -663609024, -699152192, -734482816, @@ -67529,7 +67529,8 @@ Word32 sine_table_Q31 [361] = { 335940416, 298872128, 261712288, 224473232, 187165824, 149800880, 112390808, 74946000, 37478868, -187, }; -Word32 cosine_table_Q31 [181] = { + +const Word32 cosine_table_Q31[181] = { 2147483647, 2147156608, 2146175488, 2144540544, 2142252544, 2139311872, 2135719552, 2131476608, 2126584448, 2121044608, 2114858496, 2108028288, 2100556032, 2092443776, 2083694208, 2074309888, 2064293760, 2053648896, 2042378368, 2030485632, 2017974528, diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index b3b0e55b196fd35d1420404edb8cf7131b54dadd..e761a8f15c50acc3ea2cc5847a479dbe47c792b5 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1343,6 +1343,7 @@ typedef struct /*------------------------------------------------------------------------------------------* * Crend structures *------------------------------------------------------------------------------------------*/ + #ifdef FIX_CREND_SIMPLIFY_CODE typedef struct ivas_hrtf_crend_structure #else diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 0d234814c8a306fe1b853635dd83af0a22445a67..68ad09d679f0f4aa7f67cd57fb965c27858df7fe 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -3092,11 +3092,14 @@ static ivas_error updateSbaPanGains( case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: { +#ifdef FIX_HRTF_LOAD + IF( EQ_32( hRendCfg->split_rend_config.rendererSelection, IVAS_BIN_RENDERER_TYPE_FASTCONV ) ) +#else IF( EQ_32( hRendCfg->split_rend_config.rendererSelection, ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) ) - +#endif { assert( inConfig == IVAS_AUDIO_CONFIG_HOA3 && ( *rendCtx.pOutSampleRate == 48000 ) && "split binaural fast conv mode is currently supported with HOA3 input and 48k sampling rate only" ); - if ( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -3104,7 +3107,7 @@ static ivas_error updateSbaPanGains( else { assert( ( *rendCtx.pOutSampleRate == 48000 ) && "split binaural crend mode is currently supported with 48k sampling rate only" ); - if ( ( error = ivas_rend_openMultiBinCrend( &inputSba->crendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_rend_openMultiBinCrend( &inputSba->crendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -3116,9 +3119,13 @@ static ivas_error updateSbaPanGains( case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: #endif { +#ifdef FIX_HRTF_LOAD + IF( EQ_32( hRendCfg->split_rend_config.rendererSelection, IVAS_BIN_RENDERER_TYPE_FASTCONV ) ) +#else if ( hRendCfg->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) +#endif { - if ( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -4030,7 +4037,11 @@ static Word16 getCldfbRendFlag( isCldfbRend = 0; move16(); } +#ifdef FIX_HRTF_LOAD + ELSE IF( GT_16( numMasaInputs, 0 ) || ( GT_16( numSbaInputs, 0 ) && EQ_32( hIvasRend->hRendererConfig->split_rend_config.rendererSelection, IVAS_BIN_RENDERER_TYPE_FASTCONV ) ) ) +#else ELSE IF( GT_16( numMasaInputs, 0 ) || ( GT_16( numSbaInputs, 0 ) && EQ_32( hIvasRend->hRendererConfig->split_rend_config.rendererSelection, ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) ) ) +#endif { isCldfbRend = 1; move16(); @@ -4622,7 +4633,6 @@ ivas_error IVAS_REND_GetDelay_fx( { latency_ns = 0; } - move32(); latency_ns = L_max( latency_ns, hIvasRend->inputsMc[i].tdRendWrapper.binaural_latency_ns ); @@ -4637,7 +4647,11 @@ ivas_error IVAS_REND_GetDelay_fx( test(); IF( hIvasRend->splitRendWrapper != NULL && hIvasRend->splitRendWrapper->hBinHrSplitPreRend != NULL ) { +#ifdef FIX_HRTF_LOAD + IF( EQ_32( hIvasRend->hRendererConfig->split_rend_config.rendererSelection, IVAS_BIN_RENDERER_TYPE_FASTCONV ) ) +#else IF( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) +#endif { latency_ns = hIvasRend->inputsSba[i].cldfbRendWrapper.binaural_latency_ns; move32(); @@ -7791,17 +7805,21 @@ static ivas_error renderSbaToSplitBinaural( push_wmops( "renderSbaToSplitBinaural" ); +#ifdef FIX_HRTF_LOAD + IF( EQ_32( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection, IVAS_BIN_RENDERER_TYPE_FASTCONV ) ) +#else IF( EQ_32( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection, ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) ) +#endif { - if ( ( error = renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, low_res_pre_rend_rot, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ), *outAudio.pq_fact ) ) != IVAS_ERR_OK ) + IF( ( error = renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, low_res_pre_rend_rot, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ), *outAudio.pq_fact ) ) != IVAS_ERR_OK ) { return error; } accumulateCLDFBArrayToBuffer_fx( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } - else + ELSE { IF( ( error = renderSbaToMultiBinaural( sbaInput, outConfig, tmpCrendBuffer, outAudio.pq_fact ) ) != IVAS_ERR_OK ) { @@ -7838,7 +7856,11 @@ static ivas_error renderSbaToBinaural( push_wmops( "renderSbaToBinaural" ); +#ifdef FIX_HRTF_LOAD + IF( EQ_32( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection, IVAS_BIN_RENDERER_TYPE_FASTCONV ) ) +#else IF( EQ_32( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection, ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) ) +#endif { Word32 Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c new file mode 100644 index 0000000000000000000000000000000000000000..0bf2bf226236edeb1681ccb64d67490e58cc3df0 --- /dev/null +++ b/lib_util/ambi_convert.c @@ -0,0 +1,504 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include +#include "wmc_auto.h" +#include "ambi_convert.h" + +#define ONE_1_Q29 536870912l /* 1.0f */ +#define ONE_OVER_2_Q29 268435456l /* 1.0f/2.0f */ + +#define SQRT_2_Q29 759250112l /* sqrtf(2.0f) */ +#define SQRT_3_Q29 929887680l /* sqrtf(3.0f) */ +#define SQRT_5_Q29 1200479872l /* sqrtf(5.0f) */ +#define SQRT_7_Q29 1420426880l /* sqrtf(7.0f) */ + +#define INV_SQRT_2_Q29 379625024l /* 1.0f/sqrtf(2.0f) */ +#define INV_SQRT_3_Q29 309962528l /* 1.0f/sqrtf(3.0f) */ +#define INV_SQRT_5_Q29 240095920l /* 1.0f/sqrtf(5.0f) */ +#define INV_SQRT_7_Q29 202918096l /* 1.0f/sqrtf(7.0f) */ + +#define TWO_OVER_SQRT_3_Q29 619925120l /* 2.0f/sqrtf(3.0f) */ +#define THREE_OVER_SQRT_5_Q29 720287936l /* 3.0f/sqrtf(5.0f) */ +#define SQRT_8_OVER_5_Q29 679093952l /* sqrtf(8.0f/5.0f) */ +#define SQRT_45_OVER_32_Q29 636650560l /* sqrtf(45.0f/32.0f) */ + +#define INV_TWO_OVER_SQRT_3_Q29 464943840l /* 1.0f/TWO_OVER_SQRT_3_Q29 */ +#define INV_THREE_OVER_SQRT_5_Q29 400159968l /* 1.0f/THREE_OVER_SQRT_5_Q29 */ +#define INV_SQRT_8_OVER_5_Q29 424433728l /* 1.0f/INV_SQRT_8_OVER_5_Q29 */ +#define INV_SQRT_45_OVER_32_Q29 452729280l /* 1.0f/SQRT_45_OVER_32_Q29 */ + + +/* -------------------------------- + normalization conversion tables + -------------------------------- */ + +static const Word32 SN3D_N3D[AMBI_MAX_CHANNELS] = { ONE_1_Q29, + SQRT_3_Q29, SQRT_3_Q29, SQRT_3_Q29, + SQRT_5_Q29, SQRT_5_Q29, SQRT_5_Q29, SQRT_5_Q29, SQRT_5_Q29, + SQRT_7_Q29, SQRT_7_Q29, SQRT_7_Q29, SQRT_7_Q29, SQRT_7_Q29, SQRT_7_Q29, SQRT_7_Q29 }; + +static const Word32 N3D_SN3D[AMBI_MAX_CHANNELS] = { ONE_1_Q29, + INV_SQRT_3_Q29, INV_SQRT_3_Q29, INV_SQRT_3_Q29, + INV_SQRT_5_Q29, INV_SQRT_5_Q29, INV_SQRT_5_Q29, INV_SQRT_5_Q29, INV_SQRT_5_Q29, + INV_SQRT_7_Q29, INV_SQRT_7_Q29, INV_SQRT_7_Q29, INV_SQRT_7_Q29, INV_SQRT_7_Q29, INV_SQRT_7_Q29, INV_SQRT_7_Q29 }; + + +static const Word32 SN3D_MAXN[AMBI_MAX_CHANNELS] = { ONE_1_Q29, + ONE_1_Q29, ONE_1_Q29, ONE_1_Q29, + TWO_OVER_SQRT_3_Q29, TWO_OVER_SQRT_3_Q29, ONE_1_Q29, TWO_OVER_SQRT_3_Q29, TWO_OVER_SQRT_3_Q29, + SQRT_8_OVER_5_Q29, THREE_OVER_SQRT_5_Q29, SQRT_45_OVER_32_Q29, ONE_1_Q29, SQRT_45_OVER_32_Q29, THREE_OVER_SQRT_5_Q29, SQRT_8_OVER_5_Q29 }; + +static const Word32 MAXN_SN3D[AMBI_MAX_CHANNELS] = { ONE_1_Q29, + ONE_1_Q29, ONE_1_Q29, ONE_1_Q29, + INV_TWO_OVER_SQRT_3_Q29, INV_TWO_OVER_SQRT_3_Q29, ONE_1_Q29, INV_TWO_OVER_SQRT_3_Q29, INV_TWO_OVER_SQRT_3_Q29, + INV_SQRT_8_OVER_5_Q29, INV_THREE_OVER_SQRT_5_Q29, INV_SQRT_45_OVER_32_Q29, ONE_1_Q29, INV_SQRT_45_OVER_32_Q29, INV_THREE_OVER_SQRT_5_Q29, INV_SQRT_8_OVER_5_Q29 }; + +static const Word32 SN3D_FM[AMBI_MAX_CHANNELS] = { INV_SQRT_2_Q29, + ONE_1_Q29, ONE_1_Q29, ONE_1_Q29, + TWO_OVER_SQRT_3_Q29, TWO_OVER_SQRT_3_Q29, ONE_1_Q29, TWO_OVER_SQRT_3_Q29, TWO_OVER_SQRT_3_Q29, + SQRT_8_OVER_5_Q29, THREE_OVER_SQRT_5_Q29, SQRT_45_OVER_32_Q29, ONE_1_Q29, SQRT_45_OVER_32_Q29, THREE_OVER_SQRT_5_Q29, SQRT_8_OVER_5_Q29 }; + +static const Word32 FM_SN3D[AMBI_MAX_CHANNELS] = { SQRT_2_Q29, + ONE_1_Q29, ONE_1_Q29, ONE_1_Q29, + INV_TWO_OVER_SQRT_3_Q29, INV_TWO_OVER_SQRT_3_Q29, ONE_1_Q29, INV_TWO_OVER_SQRT_3_Q29, INV_TWO_OVER_SQRT_3_Q29, + INV_SQRT_8_OVER_5_Q29, INV_THREE_OVER_SQRT_5_Q29, INV_SQRT_45_OVER_32_Q29, ONE_1_Q29, INV_SQRT_45_OVER_32_Q29, INV_THREE_OVER_SQRT_5_Q29, INV_SQRT_8_OVER_5_Q29 }; + +/* ---------------------------- + channel re-ordering tables + ---------------------------- */ + +static const int16_t REORDER_FM_ACN[AMBI_MAX_CHANNELS] = { 0, + 2, 3, 1, + 8, 6, 4, 5, 7, + 15, 13, 11, 9, 10, 12, 14 }; + +static const int16_t REORDER_SID_ACN[AMBI_MAX_CHANNELS] = { 0, + 2, 3, 1, + 5, 7, 8, 6, 4, + 10, 12, 14, 15, 13, 11, 9 }; + +static const int16_t REORDER_ACN_FM[AMBI_MAX_CHANNELS] = { 0, + 3, 1, 2, + 6, 7, 5, 8, 4, + 12, 13, 11, 14, 10, 15, 9 }; + +static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0, + 3, 1, 2, + 8, 4, 7, 5, 6, + 15, 9, 14, 10, 13, 11, 12 }; + +/* ---------------------------------- + API functions for the conversion + ---------------------------------- */ + +/*-------------------------------------------------------------------------* +* convert_ambi_format() +* +* Convert signal between ACN-SN3D and other common ambisonics conventions +--------------------------------------------------------------------------*/ + +AMBI_CONVERT_ERROR convert_ambi_format( + Word16 *in[], /* i: input ambisonics channels, Q0 */ + Word16 *out[], /* o: output ambisonics channels, Q0 */ + int16_t order, /* i: ambisonics order */ + AMBI_FMT in_format, /* i: input ambisonics format */ + AMBI_FMT out_format /* i: output ambisonics format */ +) +{ + + Word16 tmp[AMBI_MAX_CHANNELS * L_FRAME48k]; + Word16 *p_tmp[AMBI_MAX_CHANNELS]; + AMBI_CONVERT_ERROR err = AMBI_CONVERT_OK; + + AMBI_CHANNEL_ORDER ch_ord_in = AMBI_CHANNEL_ORDER_ACN; + AMBI_CHANNEL_ORDER ch_ord_out = AMBI_CHANNEL_ORDER_ACN; + + AMBI_CHANNEL_NORM ch_norm_in = AMBI_NORM_SN3D; + AMBI_CHANNEL_NORM ch_norm_out = AMBI_NORM_SN3D; + + Word16 i, j; + + assert( order <= 3 ); + + if ( in_format != AMBI_FMT_ACN_SN3D && out_format != AMBI_FMT_ACN_SN3D ) + { + assert( 0 && "Conversion only supported to and from ACN-SN3D" ); + } + i = 0; + move16(); + FOR( j = 0; j < AMBI_MAX_CHANNELS; j++ ) + { + p_tmp[j] = &tmp[i]; + move32(); + i = add( i, L_FRAME48k ); + } + + SWITCH( in_format ) + { + case AMBI_FMT_ACN_SN3D: + ch_ord_in = AMBI_CHANNEL_ORDER_ACN; + ch_norm_in = AMBI_NORM_SN3D; + move16(); + move16(); + break; + case AMBI_FMT_ACN_N3D: + ch_ord_in = AMBI_CHANNEL_ORDER_ACN; + ch_norm_in = AMBI_NORM_N3D; + move16(); + move16(); + break; + case AMBI_FMT_FM_MAXN: + ch_ord_in = AMBI_CHANNEL_ORDER_FM; + ch_norm_in = AMBI_NORM_MAXN; + move16(); + move16(); + break; + case AMBI_FMT_FM_FM: + ch_ord_in = AMBI_CHANNEL_ORDER_FM; + ch_norm_in = AMBI_NORM_FM; + move16(); + move16(); + break; + case AMBI_FMT_SID_SN3D: + ch_ord_in = AMBI_CHANNEL_ORDER_SID; + ch_norm_in = AMBI_NORM_SN3D; + move16(); + move16(); + break; + case AMBI_FMT_SID_N3D: + ch_ord_in = AMBI_CHANNEL_ORDER_SID; + ch_norm_in = AMBI_NORM_N3D; + move16(); + move16(); + break; + default: + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; + } + + SWITCH( out_format ) + { + case AMBI_FMT_ACN_SN3D: + ch_ord_out = AMBI_CHANNEL_ORDER_ACN; + ch_norm_out = AMBI_NORM_SN3D; + move16(); + move16(); + break; + case AMBI_FMT_ACN_N3D: + ch_ord_out = AMBI_CHANNEL_ORDER_ACN; + ch_norm_out = AMBI_NORM_N3D; + move16(); + move16(); + break; + case AMBI_FMT_FM_MAXN: + ch_ord_out = AMBI_CHANNEL_ORDER_FM; + ch_norm_out = AMBI_NORM_MAXN; + move16(); + move16(); + break; + case AMBI_FMT_FM_FM: + ch_ord_out = AMBI_CHANNEL_ORDER_FM; + ch_norm_out = AMBI_NORM_FM; + move16(); + move16(); + break; + case AMBI_FMT_SID_SN3D: + ch_ord_out = AMBI_CHANNEL_ORDER_SID; + ch_norm_out = AMBI_NORM_SN3D; + move16(); + move16(); + break; + case AMBI_FMT_SID_N3D: + ch_ord_out = AMBI_CHANNEL_ORDER_SID; + ch_norm_out = AMBI_NORM_N3D; + move16(); + move16(); + break; + default: + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; + } + + IF( in_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) + { + IF( ch_ord_in != ch_ord_out ) + { + IF( ( err = renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } + IF( ( err = reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } + } + ELSE + { + IF( ( err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } + } + } + ELSE IF( in_format == AMBI_FMT_ACN_SN3D && ch_ord_in != ch_ord_out ) + { + IF( ( err = reorder_channels( in, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } + } + ELSE IF( out_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) + { + IF( ch_ord_in != ch_ord_out ) + { + IF( ( err = reorder_channels( in, p_tmp, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } + IF( ( err = renormalize_channels( p_tmp, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } + } + ELSE + { + IF( ( err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } + } + } + ELSE IF( out_format == AMBI_FMT_ACN_SN3D && ch_ord_in != ch_ord_out ) + { + IF( ( err = reorder_channels( in, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } + } + ELSE IF( out_format == AMBI_FMT_ACN_SN3D && in_format == AMBI_FMT_ACN_SN3D ) + { + int16_t i_chan = 0; + int16_t n_chan = i_mult2( add( order, 1 ), add( order, 1 ) ); + + FOR( i_chan = 0; i_chan < n_chan; i_chan++ ) + { + int16_t i = 0; + move16(); + FOR( i = 0; i < L_FRAME48k; i++ ) + { + out[i_chan][i] = in[i_chan][i]; + move16(); + } + } + } + ELSE + { + assert( 0 && "This should never happen!" ); + } + + return AMBI_CONVERT_OK; +} + +/*-------------------------------------------------------------------------* +* renormalize_channels() +* +* Rescale audio channels according to the selected ambisonics convention +--------------------------------------------------------------------------*/ + +AMBI_CONVERT_ERROR renormalize_channels( + Word16 *in[], /* i: input ambisonics channels, Q0 */ + Word16 *out[], /* o: output ambisonics channels, Q0 */ + int16_t order, /* i: ambisonics order */ + AMBI_CHANNEL_NORM in_format, /* i: input ambisonics format */ + AMBI_CHANNEL_NORM out_format /* i: output ambisonics format */ +) +{ + int16_t n_chan = i_mult2( add( order, 1 ), add( order, 1 ) ); + int16_t i_chan, i; + const Word32 *conversion_table = 0; + Word32 minval = 0; + Word32 maxval = 0; + move32(); + move32(); + move32(); + + + /* conversion factors are applied on the channels assuming that they are still/already in ACN order */ + IF( in_format == AMBI_NORM_SN3D ) + { + IF( out_format == AMBI_NORM_N3D ) + { + conversion_table = SN3D_N3D; + move32(); + } + ELSE IF( out_format == AMBI_NORM_MAXN ) + { + conversion_table = SN3D_MAXN; + move32(); + } + ELSE IF( out_format == AMBI_NORM_FM ) + { + conversion_table = SN3D_FM; + move32(); + } + ELSE + { + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; + } + } + ELSE IF( out_format == AMBI_NORM_SN3D ) + { + IF( in_format == AMBI_NORM_N3D ) + { + conversion_table = N3D_SN3D; + move32(); + } + ELSE IF( in_format == AMBI_NORM_MAXN ) + { + conversion_table = MAXN_SN3D; + move32(); + } + ELSE IF( in_format == AMBI_NORM_FM ) + { + conversion_table = FM_SN3D; + move32(); + } + ELSE + { + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; + } + } + ELSE + { + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; + } + + + FOR( i_chan = 0; i_chan < n_chan; i_chan++ ) + { + Word32 conversion_factor = conversion_table[i_chan]; + Word32 outval; + move32(); + FOR( i = 0; i < L_FRAME48k; i++ ) + { + Word64 tmp; + tmp = W_mult0_32_32( (Word32) in[i_chan][i], conversion_factor ); + /* tmp = W_add( tmp, ONE_OVER_2_Q29); */ /* rounding up */ + outval = W_extract_l( W_shr( tmp, Q29 ) ); + minval = L_min( minval, outval ); + maxval = L_min( maxval, outval ); + out[i_chan][i] = extract_l( outval ); + } + } + IF( ( minval < MIN16B ) || ( maxval > MAX16B ) ) + { + return AMBI_CONVERT_CLIPPING_DETECTED; + } + return AMBI_CONVERT_OK; +} + +/*-------------------------------------------------------------------------* +* reorder_channels() +* +* Reorder channels according to the selected ambisonics convention +--------------------------------------------------------------------------*/ + +AMBI_CONVERT_ERROR reorder_channels( + Word16 *in[], /* i: input ambisonics channels, Q0 */ + Word16 *out[], /* o: output ambisonics channels, Q0 */ + int16_t order, /* i: ambisonics order */ + AMBI_CHANNEL_ORDER in_format, /* i: input ambisonics format */ + AMBI_CHANNEL_ORDER out_format /* i: output ambisonics format */ +) +{ + int16_t n_chan = i_mult2( add( order, 1 ), add( order, 1 ) ); + int16_t i_chan, i; + Word16 tmp[AMBI_MAX_CHANNELS]; + const int16_t *idx_table = 0; + + IF( in_format == AMBI_CHANNEL_ORDER_ACN ) + { + IF( out_format == AMBI_CHANNEL_ORDER_FM ) + { + idx_table = REORDER_ACN_FM; + move16(); + } + ELSE IF( out_format == AMBI_CHANNEL_ORDER_SID ) + { + idx_table = REORDER_ACN_SID; + move16(); + } + ELSE + { + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; + } + } + ELSE IF( out_format == AMBI_CHANNEL_ORDER_ACN ) + { + IF( in_format == AMBI_CHANNEL_ORDER_FM ) + { + idx_table = REORDER_FM_ACN; + move16(); + } + ELSE IF( in_format == AMBI_CHANNEL_ORDER_SID ) + { + idx_table = REORDER_SID_ACN; + move16(); + } + ELSE + { + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; + } + } + ELSE + { + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; + } + + FOR( i = 0; i < L_FRAME48k; i++ ) + { + FOR( i_chan = 0; i_chan < n_chan; i_chan++ ) + { + int16_t idx = idx_table[i_chan]; + move16(); + tmp[i_chan] = in[idx][i]; + move16(); + } + FOR( i_chan = 0; i_chan < n_chan; i_chan++ ) + { + out[i_chan][i] = tmp[i_chan]; + move16(); + } + } + + return AMBI_CONVERT_OK; +} diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h new file mode 100644 index 0000000000000000000000000000000000000000..207bd276f1c98f1552f49e3d0560023765ec5686 --- /dev/null +++ b/lib_util/ambi_convert.h @@ -0,0 +1,103 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#ifndef AMBI_CONVERT_H +#define AMBI_CONVERT_H + +#include +#include "options.h" +#include "prot_fx.h" +#include "ivas_cnst.h" +#include +#include "wmc_auto.h" +#include "ivas_prot_fx.h" + + +#define L_FRAME48k 960 +#define AMBI_MAX_CHANNELS 16 + +typedef enum +{ + AMBI_FMT_ACN_SN3D = 0, + AMBI_FMT_ACN_N3D, + AMBI_FMT_FM_MAXN, + AMBI_FMT_FM_FM, + AMBI_FMT_SID_SN3D, + AMBI_FMT_SID_N3D +} AMBI_FMT; + +typedef enum +{ + AMBI_NORM_SN3D = 0, + AMBI_NORM_N3D, + AMBI_NORM_MAXN, + AMBI_NORM_FM +} AMBI_CHANNEL_NORM; + +typedef enum +{ + AMBI_CHANNEL_ORDER_ACN = 0, + AMBI_CHANNEL_ORDER_FM, + AMBI_CHANNEL_ORDER_SID +} AMBI_CHANNEL_ORDER; + +typedef enum +{ + AMBI_CONVERT_OK = 0, + AMBI_CONVERT_UNSUPPORTED_CONVERSION, + AMBI_CONVERT_CLIPPING_DETECTED +} AMBI_CONVERT_ERROR; + +AMBI_CONVERT_ERROR convert_ambi_format( + Word16 *in[], /* i: input ambisonics channels, Q0 */ + Word16 *out[], /* o: output ambisonics channels, Q0 */ + int16_t order, /* i: ambisonics order */ + AMBI_FMT in_format, /* i: input ambisonics format */ + AMBI_FMT out_format /* i: output ambisonics format */ +); + +AMBI_CONVERT_ERROR renormalize_channels( + Word16 *in[], /* i: input ambisonics channels, Q0 */ + Word16 *out[], /* o: output ambisonics channels, Q0 */ + int16_t order, /* i: ambisonics order */ + AMBI_CHANNEL_NORM in_format, /* i: input ambisonics format */ + AMBI_CHANNEL_NORM out_format /* i: output ambisonics format */ +); + +AMBI_CONVERT_ERROR reorder_channels( + Word16 *in[], /* i: input ambisonics channels, Q0 */ + Word16 *out[], /* o: output ambisonics channels, Q0 */ + int16_t order, /* i: ambisonics order */ + AMBI_CHANNEL_ORDER in_format, /* i: input ambisonics format */ + AMBI_CHANNEL_ORDER out_format /* i: output ambisonics format */ +); +#endif diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index db73488bdc9179ccc5d75244f4ee7d90f2f44c2b..43273f78b60538bc22180653592ef18888377095 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -250,14 +250,16 @@ static ivas_error read_hrtf_binary_header( ivas_hrtfs_header_t *hrtf_header, FILE *f_hrtf ) { + #ifdef FIX_CREND_SIMPLIFY_CODE if ( hrtf_header == NULL || f_hrtf == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } #endif + /* HRTF Header */ - /* Renderer type (4 bytes) : See "HRTF_READER_RENDERER_TYPE" */ + /* Renderer type (4 bytes) : See "HRTF_READER_RENDERER_TYPE" */ /* Input configuration (4 bytes) : See "BINAURAL_INPUT_AUDIO_CONFIG" */ /* Sampling Frequency (4 bytes) */ /* Raw data size (4 bytes) */ @@ -270,6 +272,7 @@ static ivas_error read_hrtf_binary_header( return IVAS_ERR_END_OF_FILE; } + #ifdef FIX_CREND_SIMPLIFY_CODE /*-------------------------------------------------------------------* * audio_cfg_2_binaural_cfg() @@ -1082,11 +1085,11 @@ static ivas_error load_reverb_from_binary( #ifndef FIX_CREND_SIMPLIFY_CODE float f_tmp_lr_energy_and_iac_dyn[LR_IAC_LENGTH_NR_FC]; #endif - #ifdef FIX_CREND_SIMPLIFY_CODE int16_t ind; Word16 factorQ; Word16 tmp16; + if ( hHrtfStatistics == NULL || f_hrtf == NULL ) #else if ( hHrtfStatistics == NULL ) @@ -1612,6 +1615,7 @@ void destroy_td_hrtf( return; } + #ifdef FIX_CREND_SIMPLIFY_CODE /*---------------------------------------------------------------------* * create_Crend_HRTF_from_rawdata() @@ -2840,7 +2844,6 @@ ivas_error load_fastconv_HRTF_from_binary( ivas_hrtfs_file_header_t hrtfs_file_header; int16_t hrtf_id; int16_t asFastconv = 0; - #ifdef FIX_CREND_SIMPLIFY_CODE bool load = false; BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg; @@ -2884,6 +2887,7 @@ ivas_error load_fastconv_HRTF_from_binary( free( hrtf_data ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "HRTF binary file not compliant (number of HRTF)" ); } + #ifdef FIX_CREND_SIMPLIFY_CODE if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && /* HRIRs */ ( OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL || OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) || @@ -3041,6 +3045,7 @@ ivas_error load_parambin_HRTF_from_binary( ivas_hrtfs_file_header_t hrtfs_file_header; int16_t hrtf_id; int16_t asParam = 0; + #ifdef FIX_CREND_SIMPLIFY_CODE if ( hrtfReader == NULL || hrtfReader->file == NULL ) { @@ -3081,7 +3086,6 @@ ivas_error load_parambin_HRTF_from_binary( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "HRTF binary file not compliant (number of HRTF)" ); } - #ifdef FIX_CREND_SIMPLIFY_CODE if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_PARAMETRIC ) /* Parametric binauralizer data is represented as single entity */ #else @@ -3094,6 +3098,7 @@ ivas_error load_parambin_HRTF_from_binary( return IVAS_ERR_INVALID_HRTF_SAMPLING_RATE; } #endif + if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) { free( hrtf_data ); @@ -3104,6 +3109,7 @@ ivas_error load_parambin_HRTF_from_binary( if ( ( create_parambin_HRTF_from_rawdata( &hHrtfParamBin, hrtf_data ) ) != IVAS_ERR_OK ) { free( hrtf_data ); + #ifdef FIX_CREND_SIMPLIFY_CODE return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create ParamBin HRTF from binary file" ); #else @@ -3128,6 +3134,7 @@ ivas_error load_parambin_HRTF_from_binary( } } + #ifdef FIX_CREND_SIMPLIFY_CODE /*---------------------------------------------------------------------* * load_Crend_HRTF_from_binary() @@ -3235,6 +3242,7 @@ ivas_error load_Crend_HRTF_from_binary( } free( hrtf_data ); + return IVAS_ERR_OK; } #else @@ -3344,6 +3352,8 @@ ivas_error create_SetOfHRTF_from_binary( return IVAS_ERR_OK; } #endif + + /*---------------------------------------------------------------------* * destroy_crend_hrtf() * @@ -3363,7 +3373,6 @@ static void destroy_HRTF( uint16_t i, j; test(); - test(); #ifdef FIX_CREND_SIMPLIFY_CODE if ( *hHrtfCrend != NULL && hHrtfCrend != NULL ) { @@ -3473,6 +3482,7 @@ void destroy_SetOfHRTF( } #endif + /*---------------------------------------------------------------------* * destroy_hrtf_statistics() * @@ -3498,6 +3508,7 @@ void destroy_hrtf_statistics( free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); } } + ivas_HRTF_statistics_close( hHrtfStatistics ); #ifdef FIX_CREND_SIMPLIFY_CODE diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 1d5f111ac6144e021506690a5a894eecb645c142..6d4b61caec73ef384997ef36c02727c4b09a4cdf 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2540,19 +2540,35 @@ ivas_error RenderConfigReader_read( { if ( strcmp( pValue, "CREND" ) == 0 ) { +#ifdef FIX_HRTF_LOAD + hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_CREND; +#else hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_CREND; +#endif } else if ( strcmp( pValue, "FASTCONV" ) == 0 ) { +#ifdef FIX_HRTF_LOAD + hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_FASTCONV; +#else hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV; +#endif } else if ( strcmp( pValue, "PARAMBIN" ) == 0 ) { +#ifdef FIX_HRTF_LOAD + hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_PARAMBIN; +#else hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_PARAMBIN; +#endif } else if ( strcmp( pValue, "TDREND" ) == 0 ) { +#ifdef FIX_HRTF_LOAD + hRenderConfig->split_rend_config.rendererSelection = IVAS_BIN_RENDERER_TYPE_TDREND; +#else hRenderConfig->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_TDREND; +#endif } else {