diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index bfe36b1f4812b8e44a7cb32fca8793c1b443c962..23aa2ae3f0b6722871f7f9d2c37b27e41f46862f 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -78,7 +78,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index 9b7b5806615c336f40e3f5850ded7b2c2d4103ec..3b648fae048920ae06aa709785d4b49d2e58d710 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -73,7 +73,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) false diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 760621d7a40ce2113110aed02262c1d0f8f40ff9..80910aa5e713bfca913d57aa453a16cac1744f1d 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;..\lib_rend;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index d9f8e974f0a9fbb885386ff137db1a0b8ef49c0c..3378ac10f0ccb8b95616f87f6d225f38af30bb3d 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 4bd0ca9a93af1b4580271f339f0670bdc1a26bac..865652649a8a320ff0769bd83170528445da8ab3 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/apps/decoder.c b/apps/decoder.c index 0b83b180db809fbcb1e2b67aefae7976e64c69a7..7ceda8f6f3a244bd35a21bc039bc2f81563a79ba 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -84,7 +84,6 @@ static #endif #ifdef JBM_TSM_ON_TCS #define JBM_FRONTEND_FETCH_FRAMESIZE_MS 20 -#define FRAME_SIZE_NS 20000000L #endif typedef struct @@ -128,8 +127,6 @@ typedef struct #ifdef DEBUG_FOA_AGC FILE *agcBitstream; /* temporary */ #endif - -#endif #ifdef DEBUG_JBM_CMD_OPTION bool noBadFrameDelay; #endif @@ -144,6 +141,7 @@ typedef struct uint16_t frontendFetchSizeMs; #endif #endif +#endif } DecArguments; @@ -156,10 +154,10 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, HeadRotFileReader *headRotReader, HeadRotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); +#ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING static ivas_error decodeVariableSpeed( DecArguments arg, BS_READER_HANDLE hBsReader, HeadRotFileReader *headRotReader, HeadRotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); #endif -#ifdef DEBUGGING static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); static int16_t app_own_random( int16_t *seed ); static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar ); @@ -407,6 +405,33 @@ int main( goto cleanup; } +#ifdef JBM_TSM_ON_TCS + /*------------------------------------------------------------------------------------------* + * Configure VoIP mode + *------------------------------------------------------------------------------------------*/ + + if ( arg.voipMode ) + { + if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, IVAS_DEC_VOIP_MODE_VOIP, 100, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nCould not enable VOIP: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } +#ifdef VARIABLE_SPEED_DECODING +#ifdef DEBUGGING + else if ( arg.variableSpeedMode ) + { + if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, IVAS_DEC_VOIP_MODE_VARIABLE_SPEED, arg.tsmScale, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nCould not enable Variable Play Speed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } +#endif +#endif +#endif + #ifdef DEBUGGING /*-----------------------------------------------------------------* * Preview bitstream and print config information @@ -437,6 +462,22 @@ int main( BS_Reader_Rewind( hBsReader ); IVAS_DEC_PrintConfigWithBitstream( hIvasDec, arg.quietModeEnabled, bit_stream, num_bits ); + +#ifdef VARIABLE_SPEED_DECODING +#ifdef DEBUGGING + if ( arg.variableSpeedMode ) + { + if ( arg.tsmScaleFileEnabled ) + { + fprintf( stdout, "Variable speed file: %s\n", arg.tsmScaleFileName ); + } + else + { + fprintf( stdout, "Variable speed factor: %i\n", arg.tsmScale ); + } + } +#endif +#endif } /*------------------------------------------------------------------------------------------* @@ -617,32 +658,26 @@ int main( if ( arg.voipMode ) { -#ifdef JBM_TSM_ON_TCS - if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, IVAS_DEC_VOIP_MODE_VOIP, 100, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) -#else +#ifndef JBM_TSM_ON_TCS #ifdef VARIABLE_SPEED_DECODING if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, IVAS_DEC_VOIP_MODE_VOIP, 100, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) -#endif #endif { fprintf( stderr, "\nCould not enable VOIP: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - +#endif error = decodeVoIP( arg, hBsReader, hIvasDec ); } #ifdef VARIABLE_SPEED_DECODING +#ifdef DEBUGGING else if ( arg.variableSpeedMode ) { - if ( ( error = IVAS_DEC_EnableVoIP( hIvasDec, IVAS_DEC_VOIP_MODE_VARIABLE_SPEED, arg.tsmScale, 60, arg.inputFormat ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nCould not enable Variable Play Speed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } error = decodeVariableSpeed( arg, hBsReader, headRotReader, refRotReader, referenceVectorReader, hIvasDec ); } +#endif #endif else { @@ -878,8 +913,10 @@ static bool parseCmdlIVAS_dec( arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192; arg->Opt_non_diegetic_pan = 0; arg->non_diegetic_pan_gain = 0.f; + +#ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING - arg->variableSpeedMode = 0; + arg->variableSpeedMode = false; arg->tsmScale = 100; arg->tsmScaleFileEnabled = false; arg->tsmScaleFileName = NULL; @@ -891,6 +928,7 @@ static bool parseCmdlIVAS_dec( #endif #ifdef DEBUG_JBM_CMD_OPTION arg->noBadFrameDelay = false; +#endif #endif /*-----------------------------------------------------------------* @@ -1017,7 +1055,6 @@ static bool parseCmdlIVAS_dec( } #endif /* #ifdef DEBUG_MODE_INFO_TWEAK */ #endif /* #ifdef DEBUG_MODE_INFO */ -#endif /* #ifdef DEBUGGING */ #ifdef DEBUG_JBM_CMD_OPTION else if ( strcmp( argv_to_upper, "-VOIP_NO_BAD_FRAME" ) == 0 ) { @@ -1026,11 +1063,10 @@ static bool parseCmdlIVAS_dec( } #endif #ifdef VARIABLE_SPEED_DECODING - else if ( strcmp( argv_to_upper, "-VS" ) == 0 ) { i++; - int tmp = 100; + int32_t tmp = 100; arg->variableSpeedMode = true; if ( i < argc - 3 ) { @@ -1040,7 +1076,6 @@ static bool parseCmdlIVAS_dec( arg->tsmScaleFileName = argv[i]; i++; } - else { if ( ( sscanf( argv[i], "%d", &tmp ) > 0 ) ) @@ -1049,6 +1084,13 @@ static bool parseCmdlIVAS_dec( } } arg->tsmScale = (uint16_t) tmp; + + if ( arg->tsmScale < 50 || arg->tsmScale > 150 ) + { + fprintf( stderr, "Error: Scaling factor value must be 50 <= fac <= 150!\n\n" ); + usage_dec(); + return false; + } } } #endif @@ -1057,7 +1099,7 @@ static bool parseCmdlIVAS_dec( else if ( strcmp( argv_to_upper, "-VOIP_FRAMESIZE" ) == 0 ) { i++; - int tmp; + int32_t tmp; if ( i < argc - 3 ) { if ( !is_digits_only( argv[i] ) ) @@ -1074,6 +1116,7 @@ static bool parseCmdlIVAS_dec( } #endif #endif +#endif /* #ifdef DEBUGGING */ else if ( strcmp( argv_to_upper, "-MIME" ) == 0 ) { @@ -1350,20 +1393,22 @@ static void usage_dec( void ) #ifdef DEBUG_JBM_CMD_OPTION fprintf( stdout, "-VOIP_no_bad_frame : VoIP mode: do not put out bad frames in the beginning as silence \n" ); #endif + fprintf( stdout, " The decoder may read rtpdump files containing TS26.445 Annex A.2.2\n" ); + fprintf( stdout, " EVS RTP Payload Format. The SDP parameter hf_only is required.\n" ); + fprintf( stdout, " Reading RFC4867 AMR/AMR-WB RTP payload format is not supported.\n" ); +#ifdef SUPPORT_JBM_TRACEFILE + fprintf( stdout, "-Tracefile TF : VoIP mode: Generate trace file named TF\n" ); +#endif +#ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING - fprintf( stdout, "-VS fac : Varaible Speed mode: change speed of playout fac as integer in percent. fac<100 faster, fac>100 slower\n" ); + fprintf( stdout, "-VS fac : Variable Speed mode: change speed of playout fac as integer in percent.\n" ); + fprintf( stdout, " 50 <= fac <= 150; fac<100 faster, fac>100 slower\n" ); #endif #ifdef JBM_TSM_ON_TCS #ifdef DEBUG_JBM_CMD_OPTION fprintf( stdout, "-VOIP_framesize : VoIP mode: acoustic frontend fetch frame size (must be multiples of 5!)\n" ); #endif - #endif - fprintf( stdout, " The decoder may read rtpdump files containing TS26.445 Annex A.2.2\n" ); - fprintf( stdout, " EVS RTP Payload Format. The SDP parameter hf_only is required.\n" ); - fprintf( stdout, " Reading RFC4867 AMR/AMR-WB RTP payload format is not supported.\n" ); -#ifdef SUPPORT_JBM_TRACEFILE - fprintf( stdout, "-Tracefile TF : VoIP mode: Generate trace file named TF\n" ); #endif fprintf( stdout, "-fec_cfg_file : Optimal channel aware configuration computed by the JBM \n" ); fprintf( stdout, " as described in Section 6.3.1 of TS26.448. The output is \n" ); @@ -2263,8 +2308,7 @@ static ivas_error decodeVoIP( /* decode and get samples */ - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, - pcmBuf, systemTime_ms + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms #if defined( JBM_TSM_ON_TCS ) || defined( VARIABLE_SPEED_DECODING ) , &nSamplesAvailableNext @@ -2477,6 +2521,7 @@ cleanup: } +#ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING /*---------------------------------------------------------------------* * decodeVariableSpeed() @@ -2557,6 +2602,7 @@ static ivas_error decodeVariableSpeed( #endif nSamplesAvailableNext = 0; nOutSamples = (int16_t) ( arg.output_Fs / 1000 * VARIABLE_SPEED_FETCH_FRAMESIZE_MS ); + /*------------------------------------------------------------------------------------------* * Loop for every packet (frame) of bitstream data * - Read the bitstream packet @@ -2584,6 +2630,7 @@ static ivas_error decodeVariableSpeed( goto cleanup; } } + /* Reference rotation */ if ( arg.enableReferenceRotation ) { @@ -2600,6 +2647,7 @@ static ivas_error decodeVariableSpeed( goto cleanup; } } + /* Head-tracking input simulation */ if ( arg.enableHeadRotation ) { @@ -2624,21 +2672,19 @@ static ivas_error decodeVariableSpeed( /* decode and get samples */ do { - error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, - pcmBuf, 0, - &nSamplesAvailableNext + error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, 0, &nSamplesAvailableNext #ifdef SUPPORT_JBM_TRACEFILE , - writeJbmTraceFileFrameWrapper, - jbmTraceWriter + writeJbmTraceFileFrameWrapper, jbmTraceWriter #endif ); - if ( error != IVAS_ERR_OK && error != IVAS_ERR_VS_FRAME_NEEDED ) + if ( error != IVAS_ERR_OK && error != IVAS_ERR_VS_FRAME_NEEDED ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } + if ( error == IVAS_ERR_VS_FRAME_NEEDED ) { if ( arg.tsmScaleFileEnabled ) @@ -2729,7 +2775,6 @@ static ivas_error decodeVariableSpeed( } } - /* Write current frame */ if ( decodedGoodFrame ) { @@ -2816,6 +2861,7 @@ static ivas_error decodeVariableSpeed( /*------------------------------------------------------------------------------------------* * Flush what is still left in the VoIP Buffers.... *------------------------------------------------------------------------------------------*/ + while ( nSamplesAvailableNext > 0 ) { int16_t nSamplesFlushed; @@ -2876,25 +2922,19 @@ static ivas_error decodeVariableSpeed( } /* decode and get samples */ - if ( ( error = IVAS_DEC_VoIP_Flush( hIvasDec, nOutSamples, - pcmBuf, - &nSamplesAvailableNext, - &nSamplesFlushed ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesAvailableNext, &nSamplesFlushed ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - /* Write current frame */ - if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, nSamplesFlushed * nOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); goto cleanup; } - /* Write ISm metadata to external file(s) */ if ( decodedGoodFrame && arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) { @@ -2952,6 +2992,7 @@ static ivas_error decodeVariableSpeed( #endif } } + /*------------------------------------------------------------------------------------------* * Printouts after decoding has finished *------------------------------------------------------------------------------------------*/ @@ -3015,10 +3056,9 @@ cleanup: return error; } - #endif -#ifdef DEBUGGING + /*---------------------------------------------------------------------* * parseForcedRendModeDec() * diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index 99ae9894f44a26c5b29d70b3cb5e8bc4497f39ce..f0408ea3ddca06d1eac0552ecba721c7e60d6b42 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -940,6 +940,7 @@ void SynthesisSTFT( return; } + #ifdef JBM_TSM_ON_TCS /*------------------------------------------------------------------- * SynthesisSTFT_dirac() @@ -966,7 +967,6 @@ void SynthesisSTFT_dirac( mvr2r( olapBuffer + hFdCngCom->frameSize, olapBuffer, hFdCngCom->frameSize ); set_f( olapBuffer + hFdCngCom->frameSize, 0.0f, hFdCngCom->frameSize ); /*olapBuffer, fftBuffer, olapWin*/ - for ( i = hFdCngCom->frameSize / 4; i < 3 * hFdCngCom->frameSize / 4; i++ ) { olapBuffer[i] += fftBuffer[i] * olapWin[i - hFdCngCom->frameSize / 4]; @@ -1009,6 +1009,7 @@ void SynthesisSTFT_dirac( } #endif + /*------------------------------------------------------------------- * mhvals() * diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 28aa855801093db1178328eb33cf3477820ed65b..f6298fe9ea1ec9f6b8c3c15c0650f516168e0ab8 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -214,6 +214,7 @@ typedef enum #define MAX_JBM_L_FRAME_NS 40000000L #define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH #define MAX_CLDFB_DIGEST_CHANNELS 4 + typedef enum { TC_BUFFER_MODE_NONE = 0, diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index b50d8a679cb93ce29dcde823480af5f199d72c1d..e1ba2c291250522c8cef15aebdca4201dc3dbf7a 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -85,14 +85,14 @@ typedef enum IVAS_ERR_ISM_INVALID_METADATA_VALUE, IVAS_ERR_INVALID_MASA_FORMAT_METADATA_FILE, IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, -#ifdef VARIABLE_SPEED_DECODING - IVAS_ERR_VS_FRAME_NEEDED, -#endif #ifdef DEBUGGING IVAS_ERR_INVALID_FORCE_MODE, #ifdef DEBUG_AGC_ENCODER_CMD_OPTION IVAS_ERR_INVALID_AGC, #endif +#ifdef VARIABLE_SPEED_DECODING + IVAS_ERR_VS_FRAME_NEEDED, +#endif #endif /*----------------------------------------* diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 650473d85221fc723834ea642781869912856ea8..556daf327b9a1f9680cad2775e1cc263cf1eafff 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -256,9 +256,9 @@ ivas_error ivas_compute_core_buffers( /*! r: number of clipped samples */ uint32_t ivas_syn_output( #ifdef JBM_TSM_ON_TCS - float *synth[], /* i/o: float synthesis signal */ + float *synth[], /* i/o: float synthesis signal */ #else - float synth[][L_FRAME48k], /* i/o: float synthesis signal */ + float synth[][L_FRAME48k], /* i/o: float synthesis signal */ #endif const int16_t output_frame, /* i : output frame length (one channel) */ const int16_t n_channels, /* i : number of output channels */ @@ -267,11 +267,11 @@ uint32_t ivas_syn_output( #ifdef JBM_TSM_ON_TCS void ivas_syn_output_f( - float *synth[], /* i/o: float synthesis signal */ - const int16_t output_frame, /* i : output frame length (one channel) */ - const int16_t n_channels, /* i : number of output channels */ - float *synth_out /* o : integer 16 bits synthesis signal */ - ); + float *synth[], /* i/o: float synthesis signal */ + const int16_t output_frame, /* i : output frame length (one channel) */ + const int16_t n_channels, /* i : number of output channels */ + float *synth_out /* o : integer 16 bits synthesis signal */ +); #endif void ivas_initialize_handles_enc( @@ -318,10 +318,10 @@ ivas_error ivas_dec( ivas_error ivas_dec_setup( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ - #ifdef JBM_TSM_ON_TCS +#ifdef JBM_TSM_ON_TCS , - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : flushed PCM samples */ + uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ + int16_t *data /* o : flushed PCM samples */ #endif ); @@ -765,105 +765,111 @@ void dtx_read_padding_bits( const int16_t num_bits ); + #ifdef JBM_TSM_ON_TCS /*----------------------------------------------------------------------------------* * JBM prototypes *----------------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *data /* o : output synthesis signals */ ); ivas_error ivas_jbm_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of samples wanted */ - uint16_t *nSamplesRendered, /* o : number of samples rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ - int16_t *data /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesAsked, /* i : number of samples wanted */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ + int16_t *data /* o : output synthesis signal */ ); ivas_error ivas_jbm_dec_flush_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t tc_granularity_new, /* i : new renderer granularity */ - const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ - const AUDIO_CONFIG intern_config_old, /* i : old internal config */ - const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ - const MC_MODE mc_mode_old, /* i : old MC mode */ - const ISM_MODE ism_mode_old, /* i : old ISM mode */ - uint16_t *nSamplesRendered, /* o : number of samples flushed */ - int16_t *data /* o : rendered samples */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t tc_granularity_new, /* i : new renderer granularity */ + const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ + const AUDIO_CONFIG intern_config_old, /* i : old internal config */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ + const MC_MODE mc_mode_old, /* i : old MC mode */ + const ISM_MODE ism_mode_old, /* i : old ISM mode */ + uint16_t *nSamplesRendered, /* o : number of samples flushed */ + int16_t *data /* o : rendered samples */ ); ivas_error ivas_jbm_dec_feed_tc_to_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i: : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o: : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i/o: transport channels/output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ + float *data /* i/o: transport channels/output synthesis signal */ ); ivas_error ivas_jbm_dec_set_discard_samples( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ + Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ); void ivas_jbm_dec_get_adapted_linear_interpolator( - const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ - const int16_t interp_length, /* i : length of the interpolator to be created */ - float *interpolator /* o : the interpolator */ + const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ + const int16_t interp_length, /* i : length of the interpolator to be created */ + float *interpolator /* o : the interpolator */ ); void ivas_jbm_dec_get_adapted_subframes( - const int16_t nCldfbTs, /* i : number of time slots in the current frame */ - int16_t *subframe_nbslots, /* i/o: subframe grid */ - int16_t *nb_subframes /* i/o: number of subframes in the frame */ + const int16_t nCldfbTs, /* i : number of time slots in the current frame */ + int16_t *subframe_nbslots, /* i/o: subframe grid */ + int16_t *nb_subframes /* i/o: number of subframes in the frame */ ); void ivas_jbm_dec_get_md_map( - const int16_t default_len, /* i : default frame length in metadata slots */ - const int16_t len, /* i : length of the modfied frames in metadata slots */ - const int16_t subframe_len, /* i : default length of a subframe */ - const int16_t offset, /* i : current read offset into the md buffer */ - const int16_t buf_len, /* i : length of the metadata buffer */ - int16_t *map /* o : metadata index map */ + const int16_t default_len, /* i : default frame length in metadata slots */ + const int16_t len, /* i : length of the modfied frames in metadata slots */ + const int16_t subframe_len, /* i : default length of a subframe */ + const int16_t offset, /* i : current read offset into the md buffer */ + const int16_t buf_len, /* i : length of the metadata buffer */ + int16_t *map /* o : metadata index map */ ); -int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas ); /* i : IVAS decoder handle */ +int16_t ivas_jbm_dec_get_num_tc_channels( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +); TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( - Decoder_Struct *st_ivas /* i : IVAS decoder handle */ + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); -int16_t ivas_jbm_dec_get_render_granularity( /* o : render granularity */ - const RENDERER_TYPE rendererType, /* i : renderer type */ - const int32_t output_Fs /* i : sampling rate */ +/*! r: render granularity */ +int16_t ivas_jbm_dec_get_render_granularity( + const RENDERER_TYPE rendererType, /* i : renderer type */ + const int32_t output_Fs /* i : sampling rate */ ); ivas_error ivas_jbm_dec_tc_buffer_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ - const int16_t nchan_transport_jbm, /* i : number of real transport channels */ - const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : nubmer of channels to fully store */ - const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ + const int16_t nchan_transport_jbm, /* i : number of real transport channels */ + const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ + const int16_t nchan_full, /* i : number of channels to fully store */ + const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ); ivas_error ivas_jbm_dec_tc_buffer_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ - const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ - const int16_t nchan_full, /* i : new number of channels to fully store */ - const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ + const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ + const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ + const int16_t nchan_full, /* i : new number of channels to fully store */ + const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ ); void ivas_jbm_dec_tc_buffer_close( - DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ + DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ); + void ivas_jbm_dec_td_renderers_adapt_subframes( - Decoder_Struct *st_ivas + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif + /*----------------------------------------------------------------------------------* * ISM prototypes *----------------------------------------------------------------------------------*/ @@ -1018,8 +1024,8 @@ ivas_error ivas_ism_dec_config( const ISM_MODE last_ism_mode /* i/o: last ISM mode */ #ifdef JBM_TSM_ON_TCS , - uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change */ - int16_t *data /* o : flushed PCM samples */ + uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change*/ + int16_t *data /* o : flushed PCM samples */ #endif ); @@ -1039,21 +1045,21 @@ void ivas_param_ism_dec( #ifdef JBM_TSM_ON_TCS void ivas_ism_dec_digest_tc( - Decoder_Struct *st_ivas + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); void ivas_param_ism_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); void ivas_param_ism_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ); #endif @@ -3421,12 +3427,12 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_TSM_ON_TCS ivas_error ivas_sba_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering, /* i : number of samples provided */ - float *data[] /* i : transport channel samples */ - ); + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nCldfbSlots, /* i : number of CLDFB slots */ + const int16_t nSamplesForRendering, /* i : number of samples provided */ + float *data[] /* i : transport channel samples */ +); #endif void ivas_init_dec_get_num_cldfb_instances( @@ -3645,31 +3651,32 @@ void ivas_dirac_dec_read_BS( #ifdef JBM_TSM_ON_TCS void generate_masking_noise_lb_dirac( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ - const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ - const int16_t cna_flag /* i : CNA flag for LB and HB */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ + const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ + const int16_t cna_flag /* i : CNA flag for LB and HB */ ); void ivas_dirac_dec_set_md_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs ); + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +); void ivas_dirac_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport /* i : number of transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t nchan_transport /* i : number of transport channels */ ); #endif #ifdef JBM_TSM_ON_TCS void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ); #endif @@ -3680,9 +3687,9 @@ void ivas_dirac_dec_render_sf( #endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ #else - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ + float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ #endif const int16_t nchan_transport, /* i : number of transport channels */ float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], @@ -3832,7 +3839,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( DIRAC_DEC_HANDLE hDirAC, /* i/o: DirAC handle */ const int16_t nchan_transport, /* i : number of transport channels */ #ifdef JBM_TSM_ON_TCS - const int16_t nbslots, /* i : number of slots to process */ + const int16_t nbslots, /* i : number of slots to process */ #endif const float *onset_filter , @@ -3843,12 +3850,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( ); void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ - DIRAC_DEC_HANDLE hDirAC, /* i/o: DirAC handle */ + float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ + float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ + DIRAC_DEC_HANDLE hDirAC, /* i/o: DirAC handle */ #ifdef JBM_TSM_ON_TCS - const int16_t nbslots, /* i : number of slots to process */ - const int16_t diff_md_idx, /* i : md slot idx of diffuseness to use */ + const int16_t nbslots, /* i : number of slots to process */ + const int16_t diff_md_idx, /* i : md slot idx of diffuseness to use */ #endif float *reference_power_smooth, float qualityBasedSmFactor @@ -3910,35 +3917,35 @@ void calculate_hodirac_sector_parameters( #endif float RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],/* i : signal vector (L+1)^2 x N_bins, real part */ float ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],/* i : signal vector, imaginary part */ - const float beta, /* i : forgetting factor for average filtering */ - const int16_t *band_grouping, /* i : indices of band groups */ - const int16_t N_bands, /* i : number of bands (groups) */ - const int16_t enc_param_start_band, /* i : first band to process */ - float *azi, /* o : array of sector azimuth angles, flat */ - float *ele, /* o : array of sector elevation angles, flat */ - float *diff, /* o : array of sector diffuseness values, flat */ - float *ene /* o : array of sector energy values, flat */ + const float beta, /* i : forgetting factor for average filtering */ + const int16_t *band_grouping, /* i : indices of band groups */ + const int16_t N_bands, /* i : number of bands (groups) */ + const int16_t enc_param_start_band, /* i : first band to process */ + float *azi, /* o : array of sector azimuth angles, flat */ + float *ele, /* o : array of sector elevation angles, flat */ + float *diff, /* o : array of sector diffuseness values, flat */ + float *ene /* o : array of sector energy values, flat */ ); void ivas_mc_paramupmix_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ - float data_f[][L_FRAME48k], /* i/o: input: CICP6, CICP12, CICP14, CICP16 or CICP19 MC data */ - const int16_t input_frame /* i : input frame length */ + Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ + BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ + float data_f[][L_FRAME48k], /* i/o: input: CICP6, CICP12, CICP14, CICP16 or CICP19 MC data */ + const int16_t input_frame /* i : input frame length */ ); ivas_error ivas_mc_paramupmix_enc_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); void ivas_mc_paramupmix_enc_close( - MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ + MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ const int32_t sampling_rate ); void ivas_mc_paramupmix_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ ); int16_t ivas_mc_paramupmix_getNumTransportChannels( @@ -3946,19 +3953,19 @@ int16_t ivas_mc_paramupmix_getNumTransportChannels( ); ivas_error ivas_mc_paramupmix_dec_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); void ivas_mc_paramupmix_dec_close( - MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */ + MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */ ); void ivas_mc_paramupmix_dec_read_BS( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - Decoder_State *st, /* i/o: decoder state structure */ - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */ - int16_t *nb_bits /* o : number of bits written */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + Decoder_State *st, /* i/o: decoder state structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */ + int16_t *nb_bits /* o : number of bits written */ ); void ivas_param_mc_metadata_open( @@ -4030,17 +4037,17 @@ void ivas_param_mc_dec_read_BS( #ifdef JBM_TSM_ON_TCS void ivas_param_mc_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); void ivas_param_mc_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ); #endif @@ -4049,7 +4056,7 @@ void ivas_param_mc_dec( #ifdef JBM_TSM_ON_TCS float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ #else - float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ + float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ #endif ); @@ -4183,8 +4190,9 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( #ifdef JBM_TSM_ON_TCS void ivas_dirac_dec_output_synthesis_get_interpolator( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ - const uint16_t interp_length ); + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ + const uint16_t interp_length /* i : interpolator length */ +); #endif void ivas_dirac_dec_output_synthesis_cov_init( @@ -4202,8 +4210,8 @@ void ivas_dirac_dec_output_synthesis_cov_close( void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( #ifdef JBM_TSM_ON_TCS - float *RealBuffer, /* i : input channel filter bank samples (real part) */ - float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ + float *RealBuffer, /* i : input channel filter bank samples (real part) */ + float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ #else float RealBuffer[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS][CLDFB_NO_CHANNELS_MAX], /* i : input channel filter bank samples (real part) */ float ImagBuffer[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS][CLDFB_NO_CHANNELS_MAX], /* i : input channel filter bank samples (imaginary part */ @@ -4214,14 +4222,14 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( const int16_t nchan_in /* i : number of input channels */ #ifndef JBM_TSM_ON_TCS , - const int16_t idx_slot /* i : index of the slot to be added to the input covariance */ + const int16_t idx_slot /* i : index of the slot to be added to the input covariance */ #endif ); void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( #ifdef JBM_TSM_ON_TCS - float *Cldfb_RealBuffer_in, /* i : input channel filter bank samples (real part) */ - float *Cldfb_ImagBuffer_in, /* i : input channel filter bank samples (imaginary part) */ + float *Cldfb_RealBuffer_in, /* i : input channel filter bank samples (real part) */ + float *Cldfb_ImagBuffer_in, /* i : input channel filter bank samples (imaginary part) */ #else float Cldfb_RealBuffer_in[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_NSLOTS][CLDFB_NO_CHANNELS_MAX], /* i : CLDFB samples of the transport channels (real part) */ float Cldfb_ImagBuffer_in[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_NSLOTS][CLDFB_NO_CHANNELS_MAX], /* i : CLDFB samples of the transport channels (imaginary part) */ @@ -4229,17 +4237,17 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (real part) */ float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (imaginary part) */ #ifdef JBM_TSM_ON_TCS - float *mixing_matrix[], /* i : parameter band wise mixing matrices (direct part) */ - float *mixing_matrix_res[], /* i : parameter band wise mixing matrices (residual part) */ + float *mixing_matrix[], /* i : parameter band wise mixing matrices (direct part) */ + float *mixing_matrix_res[], /* i : parameter band wise mixing matrices (residual part) */ #else float mixing_matrix[PARAM_MC_MAX_PARAMETER_BANDS][MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : parameter band wise mixing matrices (direct part) */ float mixing_matrix_res[PARAM_MC_MAX_PARAMETER_BANDS_RES][MAX_CICP_CHANNELS * MAX_CICP_CHANNELS], /* i : parameter band wise mixing matrices (residual part) */ #endif - const uint16_t slot_idx_sfr, /* i : time slot index for the current slot within the current subframe */ - const uint16_t slot_idx_tot, /* i : time slot index for the current slot within the frame */ - const int16_t nX, /* i : number of input channels */ - const int16_t nY, /* i : number of output channels */ - PARAM_MC_DEC_HANDLE hParamMC /* i : handle to the Parametric MC decoder state */ + const uint16_t slot_idx_sfr, /* i : time slot index for the current slot within the current subframe */ + const uint16_t slot_idx_tot, /* i : time slot index for the current slot within the frame */ + const int16_t nX, /* i : number of input channels */ + const int16_t nY, /* i : number of output channels */ + PARAM_MC_DEC_HANDLE hParamMC /* i : handle to the Parametric MC decoder state */ ); int16_t computeMixingMatricesISM( @@ -4324,7 +4332,7 @@ void ivas_sba_upmixer_renderer( ivas_error ivas_sba_linear_renderer( #ifdef JBM_TSM_ON_TCS - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ #else float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ #endif @@ -4343,14 +4351,6 @@ void ivas_sba_mix_matrix_determiner( const int16_t output_frame /* i : output frame length */ ); -#ifdef JBM_TSM_ON_TCS -void ivas_sba_prototype_renderer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - float inIm[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* i : Input audio in CLDFB domain, imag */ -); -#endif - /* AGC */ /*! r: AGC enable flag */ int16_t ivas_agc_enc_get_flag( @@ -4447,7 +4447,7 @@ int16_t ivas_get_sba_num_TCs( void ivas_spar_set_bitrate_config( ivas_spar_md_com_cfg *pSpar_md_cfg, /* i/o: SPAR MD config. handle */ const int16_t table_idx, /* i : config. table index */ - const int16_t num_bands /* i : number of bands */ + const int16_t num_bands /* i : number of bands */ #ifdef ARITH_HUFF_CODER_CHANGES , const int16_t dirac2spar_md_flag, @@ -4516,46 +4516,46 @@ int16_t ivas_is_res_channel( #ifdef JBM_TSM_ON_TCS void ivas_spar_dec_agc_pca( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float output[][L_FRAME48k], /* i/o: input/output audio channels */ - const int16_t output_frame /* i : output frame length */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float output[][L_FRAME48k], /* i/o: input/output audio channels */ + const int16_t output_frame /* i : output frame length */ ); void ivas_spar_dec_set_render_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ ); void ivas_spar_dec_set_render_params( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */ ); void ivas_spar_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nCldfbSlots, /* i : number of CLDFB slots */ + const int16_t nSamplesForRendering /* i : number of samples provided */ ); ivas_error ivas_sba_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nCldfbSlots, /* i : number of CLDFB slots */ + const int16_t nSamplesForRendering /* i : number of samples provided */ ); void ivas_sba_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ); void ivas_spar_dec_upmixer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* o : output audio channels */ - const int16_t nchan_internal /* i : number of internal channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float *output[], /* o : output audio channels */ + const int16_t nchan_internal /* i : number of internal channels */ ); #endif @@ -4651,7 +4651,7 @@ void ivas_get_spar_md_from_dirac( ); int16_t ivas_get_spar_dec_md_num_subframes( - const int16_t sba_order, /* i : Ambisonic (SBA) order */ + const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int32_t ivas_total_brate ); ivas_error ivas_spar_md_dec_open( @@ -5170,7 +5170,7 @@ void masa_sample_rate_band_correction( #else const int32_t sampling_rate, /* i : sampling rate */ #endif - MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ + MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ ); void invdct4_transform( @@ -5227,9 +5227,10 @@ void ivas_binaural_cldfb( #ifdef JBM_TSM_ON_TCS void ivas_binaural_cldfb_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t n_samples_to_render, - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + ); #endif @@ -5250,8 +5251,8 @@ void ivas_binaural_add_LFE( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ int16_t output_frame, /* i : length of input frame */ #ifdef JBM_TSM_ON_TCS - float *input_f[], /* i : transport channels */ - float *output_f[] /* o : synthesized core-coder transport channels/DirAC output */ + float *input_f[], /* i : transport channels */ + float *output_f[] /* o : synthesized core-coder transport channels/DirAC output */ #else float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ #endif @@ -5269,7 +5270,7 @@ ivas_error ivas_ism_renderer_open( void ivas_ism_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output_f[], /* i/o: core-coder transport channels/object output */ + float *output_f[], /* i/o: core-coder transport channels/object output */ #else float output_f[][L_FRAME48k], /* i/o: core-coder transport channels/object output */ #endif @@ -5278,9 +5279,9 @@ void ivas_ism_render( #ifdef JBM_TSM_ON_TCS void ivas_ism_render_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: core-coder transport channels/object output */ - const int16_t n_samples_to_render /* i : output frame length per channel */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output_f[], /* i/o: core-coder transport channels/object output */ + const int16_t n_samples_to_render /* i : output frame length per channel */ ); #endif @@ -5294,10 +5295,10 @@ void ivas_ism_get_stereo_gains( void ivas_mc2sba( IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ #ifdef JBM_TSM_ON_TCS - float *in_buffer_td[], /* i : MC signals (on input) and the HOA3 (on output) */ - float *buffer_td[], /* o : MC signals (on input) and the HOA3 (on output) */ + float *in_buffer_td[], /* i : MC signals (on input) and the HOA3 (on output) */ + float *buffer_td[], /* o : MC signals (on input) and the HOA3 (on output) */ #else - float buffer_td[][L_FRAME48k], /* i/o: MC signals (on input) and the HOA3 (on output) */ + float buffer_td[][L_FRAME48k], /* i/o: MC signals (on input) and the HOA3 (on output) */ #endif const int16_t output_frame, /* i : output frame length per channel */ const int16_t sba_order, /* i : SBA order */ @@ -5306,9 +5307,9 @@ void ivas_mc2sba( void ivas_ism2sba( #ifdef JBM_TSM_ON_TCS - float *buffer_td[], /* i/o: TD signal buffers */ + float *buffer_td[], /* i/o: TD signal buffers */ #else - float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */ + float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */ #endif ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ const ISM_METADATA_HANDLE hIsmMetaData[], /* i : object metadata */ @@ -5319,15 +5320,17 @@ void ivas_ism2sba( #ifdef JBM_TSM_ON_TCS void ivas_ism2sba_sf( - float *buffer_in[], /* i : TC buffer */ - float *buffer_out[], /* o : TD signal buffers */ - ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ - const int16_t num_objects, /* i : number of objects */ - const int16_t n_samples_to_render, /* i : output frame length per channel */ - const int16_t offset, /* i : offset for the interpolatr */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ + float *buffer_in[], /* i : TC buffer */ + float *buffer_out[], /* o : TD signal buffers */ + ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ + const int16_t num_objects, /* i : number of objects */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int16_t offset, /* i : offset for the interpolatr */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ ); #endif + + /*----------------------------------------------------------------------------------* * Amplitude Panning VBAP prototypes *----------------------------------------------------------------------------------*/ @@ -5381,10 +5384,10 @@ void ivas_ls_setup_conversion( const int16_t input_chans, /* i : number of input channels to the renderer */ const int16_t output_frame, /* i : frame length */ #ifdef JBM_TSM_ON_TCS - float *input[], /* i : LS input/output synthesis signal */ - float *output[] /* i/o: LS input/output synthesis signal */ + float *input[], /* i : LS input/output synthesis signal */ + float *output[] /* i/o: LS input/output synthesis signal */ #else - float output[][L_FRAME48k] /* i/o: LS input/output synthesis signal */ + float output[][L_FRAME48k] /* i/o: LS input/output synthesis signal */ #endif ); @@ -5399,9 +5402,9 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( ); void ivas_lssetupconversion_process_param_mc( - Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ + Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ #ifdef JBM_TSM_ON_TCS - int16_t num_timeslots, /* i : number of time slots to process */ + const int16_t num_timeslots, /* i : number of time slots to process */ #endif float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ @@ -5632,18 +5635,18 @@ ivas_error ivas_td_binaural_open( ivas_error ivas_td_binaural_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: SCE channels / Binaural synthesis */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ #else - float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ + float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ #endif const int16_t output_frame /* i : output frame length */ ); #ifdef JBM_TSM_ON_TCS -void ObjRenderIVASSubframe( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame /* i : output frame length */ +ivas_error ivas_td_binaural_renderer_sf( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ); #endif diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 9285e23a227a86f3e3b649f263901a8cfe3378f4..f2dd0871dc1ea18a9cbc3dbad1a8c494f5605820 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -472,7 +472,7 @@ static void ivas_td_decorr_APD_sections( void ivas_td_decorr_process( ivas_td_decorr_state_t *hTdDecorr, /* i/o: SPAR Covar. decoder handle */ #ifdef JBM_TSM_ON_TCS - float *pcm_in[], + float *pcm_in[], /* i : input audio channels */ #else float pcm_in[][L_FRAME48k], /* i : input audio channels */ #endif diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index ce4abafeb5d8cda10fa6ff720e89e7a1322c2e32..cf59a751a6a50efc3fc01c31753b515e8a44c59f 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -163,6 +163,7 @@ uint32_t ivas_syn_output( return noClipping; } + #ifdef JBM_TSM_ON_TCS /*-------------------------------------------------------------------* * ivas_syn_output_f() @@ -197,6 +198,7 @@ void ivas_syn_output_f( } #endif + /*-------------------------------------------------------------------* * mvr2r_inc() * diff --git a/lib_com/options.h b/lib_com/options.h index 2d1ac97a23bbdb6887f9dea91bf18b498b67a589..991224f6eb632faf71d7427f7fd48a1a903d4762 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -189,8 +189,8 @@ #define FIX_463_TD_RENDERER_DIRECTIVITY_RESET /* Eri: Remove unintentional reset of directivity pattern */ #define FIX_642 /* FhG: Fix for issue 642, buggy DoA-array access in DirAC head rotation*/ #define FIX_443_FD_CNG_INIT /* FhG: correct bitrate value for FD-CNG init */ -#define VARIABLE_SPEED_DECODING /* FhG: variable speed decoding employing the JBM functioniality */ -#define JBM_TSM_ON_TCS /* FhG: run the TSM part of JBM on the TCs instead of the final output pcm waveforms */ +#define VARIABLE_SPEED_DECODING /* FhG: Contribution 37: variable speed decoding employing the JBM functioniality */ +#define JBM_TSM_ON_TCS /* FhG: Contribution 37: run the TSM part of JBM on the TCs instead of the final output pcm waveforms */ #define FIX_DTX_428 /* FhG: fix for issue 428, crash with DTX and bitrate switching */ #define FIX_STEREO_474 /* FhG fix for issue 574, crash with SBA to stereo output at 512 kbps */ #define FIX_MDCT_ST_PLC_FADEOUT_DELAY diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 23fd63059c6057f72ac4fb2b9c73110f3cd7091e..db8b6a659f45ea35805d908d8b962cd3195f737d 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1793,6 +1793,7 @@ void generate_stereo_masking_noise( return; } + #ifdef JBM_TSM_ON_TCS /*------------------------------------------------------------------- * generate_masking_noise_hf_cldfb() @@ -1824,7 +1825,6 @@ void generate_masking_noise_lb_dirac( n_samples_out = hFdCngCom->frameSize / DEFAULT_JBM_CLDFB_TIMESLOTS * nCldfbTs; n_samples_start = 0; - /*LB CLDFB - CNA from STFT*/ #ifdef DEBUG_MODE_DIRAC { @@ -1946,7 +1946,6 @@ void generate_masking_noise_lb_dirac( return; } - #endif diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 45288514ddb87fb7d92c90538bc0c65d3c8a821e..240205706faeda8bf15f4572ee9da594e0c5324d 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1081,17 +1081,19 @@ void ivas_binaural_cldfb( return; } + + #ifdef JBM_TSM_ON_TCS /*-------------------------------------------------------------------------* - * ivas_binaural_cldfb() + * ivas_binaural_cldfb_sf() * * Perform CLDFB analysis, fastconv binaural rendering and CLDFB synthesis *-------------------------------------------------------------------------*/ void ivas_binaural_cldfb_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t n_samples_to_render, - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ ) { float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; @@ -1105,6 +1107,7 @@ void ivas_binaural_cldfb_sf( /* Implement a 5 msec loops */ maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); slot_size = st_ivas->hTcBuffer->nb_subframes; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_to_render / slot_size ); first_sf = st_ivas->hTcBuffer->subframes_rendered; @@ -1112,6 +1115,7 @@ void ivas_binaural_cldfb_sf( slot_index_start = st_ivas->hTcBuffer->slots_rendered; slot_index_start_cldfb = 0; st_ivas->hTcBuffer->slots_rendered += slots_to_render; + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; @@ -1153,6 +1157,7 @@ void ivas_binaural_cldfb_sf( #else ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hHeadTrackData, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #endif + /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -1170,7 +1175,9 @@ void ivas_binaural_cldfb_sf( slot_index_start += st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_index_start_cldfb += st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; } + st_ivas->hTcBuffer->subframes_rendered = last_sf; + return; } #endif diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index e0e6a28725bfe326089cee562935aac2896210c3..5d2b1218d1059ff0c7b85825084515c132e4c89f 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -280,13 +280,7 @@ ivas_error ivas_dec( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, - AUDIO_CONFIG_7_1_4, - AUDIO_CONFIG_BINAURAL_ROOM, - NULL, - NULL, - NULL, - NULL, + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, NULL, NULL, NULL, NULL, #ifdef JBM_TSM_ON_TCS p_output, #else @@ -541,13 +535,8 @@ ivas_error ivas_dec( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, - st_ivas->intern_config, - st_ivas->hOutSetup.output_config, - st_ivas->hDecoderConfig, - st_ivas->hHeadTrackData, - &st_ivas->hIntSetup, - st_ivas->hEFAPdata, + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, + st_ivas->hHeadTrackData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, #ifdef JBM_TSM_ON_TCS p_output, #else @@ -587,6 +576,7 @@ ivas_error ivas_dec( { return error; } + ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); #else if ( ( ivas_td_binaural_renderer( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) @@ -641,6 +631,7 @@ ivas_error ivas_dec( { return error; } + #ifdef JBM_TSM_ON_TCS ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); #else @@ -684,6 +675,7 @@ ivas_error ivas_dec( { return error; } + #ifdef JBM_TSM_ON_TCS ivas_binaural_add_LFE( st_ivas, output_frame, p_output, p_output ); #else @@ -849,6 +841,7 @@ ivas_error ivas_dec( * - compensation for saturation * - float to integer conversion *----------------------------------------------------------------*/ + #ifdef JBM_TSM_ON_TCS ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, output_frame, st_ivas->BER_detect ); @@ -864,6 +857,7 @@ ivas_error ivas_dec( #endif ivas_syn_output( output, output_frame, nchan_out, data ); #endif + /*----------------------------------------------------------------* * Common updates *----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 025a876d05f14b7f388d0e4a2bb42aa79e8971ad..646f6b18090cbaa8255cafebff787418a1b34a49 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -269,6 +269,9 @@ ivas_error ivas_dirac_dec_config( ivas_error error; int16_t nchan_transport_orig; int16_t hodirac_flag; +#ifdef JBM_TSM_ON_TCS + int16_t map_idx; +#endif DIRAC_CONFIG_FLAG flag_config; flag_config = ( flag_config_inp == DIRAC_RECONFIGURE_MODE ) ? DIRAC_RECONFIGURE : flag_config_inp; @@ -1010,29 +1013,26 @@ ivas_error ivas_dirac_dec_config( if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { hDirAC->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES; + #ifdef JBM_TSM_ON_TCS + set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); + for ( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS; map_idx++ ) { - int16_t map_idx; - set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - for ( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS; map_idx++ ) - { - hDirAC->render_to_md_map[map_idx] = map_idx; - } + hDirAC->render_to_md_map[map_idx] = map_idx; } + #endif } else if ( st_ivas->ivas_format == MASA_FORMAT ) { hDirAC->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; hDirAC->dirac_bs_md_write_idx = DELAY_MASA_PARAM_DEC_SFR; + #ifdef JBM_TSM_ON_TCS + set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); + for ( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS; map_idx++ ) { - int16_t map_idx; - set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - for ( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS; map_idx++ ) - { - hDirAC->render_to_md_map[map_idx] = map_idx; - } + hDirAC->render_to_md_map[map_idx] = map_idx; } #endif } @@ -1058,13 +1058,11 @@ ivas_error ivas_dirac_dec_config( hDirAC->dirac_estimator_idx = 0; } #ifdef JBM_TSM_ON_TCS + + set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); + for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) { - int16_t map_idx; - set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) - { - hDirAC->render_to_md_map[map_idx] = hDirAC->dirac_read_idx + map_idx * num_slots_in_subfr / JBM_CLDFB_SLOTS_IN_SUBFRAME; - } + hDirAC->render_to_md_map[map_idx] = hDirAC->dirac_read_idx + map_idx * num_slots_in_subfr / JBM_CLDFB_SLOTS_IN_SUBFRAME; } #endif } @@ -1116,6 +1114,7 @@ ivas_error ivas_dirac_dec_config( } } } + #ifdef JBM_TSM_ON_TCS /* allocate transport channels*/ if ( flag_config == DIRAC_OPEN ) @@ -1142,7 +1141,6 @@ ivas_error ivas_dirac_dec_config( } } } - #endif /* JBM_TMS_ON_TCS*/ return error; @@ -2057,6 +2055,7 @@ void ivas_qmetadata_to_dirac( band_end = band_grouping[band + 1]; #ifdef JBM_TSM_ON_TCS tmp_write_idx_param_band = hDirAC->dirac_bs_md_write_idx; + for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) #else for ( block = 0; block < hDirAC->nb_subframes; block++ ) @@ -2073,6 +2072,7 @@ void ivas_qmetadata_to_dirac( #endif hDirAC->spreadCoherence[block][b] = 0.0f; hDirAC->surroundingCoherence[block][b] = 0.0f; + #ifdef JBM_TSM_ON_TCS if ( hDirAC->hConfig->dec_param_estim == FALSE ) { @@ -2254,6 +2254,7 @@ void ivas_qmetadata_to_dirac( for ( b = band_grouping[band]; b < hDirAC->num_freq_bands; b++ ) { tmp_write_idx_band = hDirAC->dirac_bs_md_write_idx; + #ifdef JBM_TSM_ON_TCS for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) #else @@ -2318,9 +2319,11 @@ void ivas_qmetadata_to_dirac( * * Set metadata index mapping for DirAC *------------------------------------------------------------------------*/ + void ivas_dirac_dec_set_md_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs ) + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +) { int16_t num_slots_in_subfr; DIRAC_DEC_HANDLE hDirAC; @@ -2362,6 +2365,7 @@ void ivas_dirac_dec_set_md_map( { float tmp; int16_t sf_idx, slot_idx, slot_idx_abs; + slot_idx_abs = 0; for ( sf_idx = 0; sf_idx < hDirAC->nb_subframes; sf_idx++ ) { @@ -2373,17 +2377,20 @@ void ivas_dirac_dec_set_md_map( } hDirAC->render_to_md_map[sf_idx] = ( (int16_t) roundf( tmp / (float) hDirAC->subframe_nbslots[sf_idx] ) + hDirAC->dirac_read_idx ) % hDirAC->dirac_md_buffer_length; } + set_s( &hDirAC->render_to_md_map[hDirAC->nb_subframes], 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME - hDirAC->nb_subframes ); } return; } + /*------------------------------------------------------------------------- * ivas_dirac_dec() * * DirAC decoding process *------------------------------------------------------------------------*/ + void ivas_dirac_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ @@ -2402,17 +2409,21 @@ void ivas_dirac_dec( { output_f_local[n] = &output_f[n][0]; } + for ( n = 0; n < nchan_transport; n++ ) { st_ivas->hTcBuffer->tc[n] = output_f[n]; } + if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->sba_mode != SBA_MODE_SPAR ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; st_ivas->hTcBuffer->tc[nchan_transport] = &cng_td_buffer[0]; generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], DEFAULT_JBM_CLDFB_TIMESLOTS, st->cna_dirac_flag && st->flag_cna ); } + ivas_dirac_dec_set_md_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); + for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { ivas_dirac_dec_render_sf( st_ivas, output_f_local, nchan_transport, NULL, NULL ); @@ -2421,6 +2432,7 @@ void ivas_dirac_dec( output_f_local[n] += n_samples_sf; } } + if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) { st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_CLDFB_TIMESLOTS ) % st_ivas->hDirAC->dirac_md_buffer_length; @@ -2441,13 +2453,20 @@ void ivas_dirac_dec( return; } + +/*------------------------------------------------------------------------- + * ivas_dirac_dec_render() + * + * DirAC decoding renderer process + *------------------------------------------------------------------------*/ + void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -2466,16 +2485,19 @@ void ivas_dirac_dec_render( output_f_local[ch] = output_f[ch]; } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hDirAC->num_slots - hDirAC->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hDirAC->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hDirAC->subframe_nbslots[last_sf]; last_sf++; } + #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif @@ -2499,16 +2521,20 @@ void ivas_dirac_dec_render( st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } } + *nSamplesAvailable = ( hDirAC->num_slots - hDirAC->slots_rendered ) * slot_size; + return; } #endif + /*------------------------------------------------------------------------- * ivas_dirac_dec() * * DirAC decoding process *------------------------------------------------------------------------*/ + #ifndef JBM_TSM_ON_TCS void ivas_dirac_dec( #else @@ -2717,6 +2743,7 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->hHeadTrackData->shd_rot_max_order == 0 ) { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; + #ifdef JBM_TSM_ON_TCS for ( slot_idx = 0; slot_idx < hDirAC->subframe_nbslots[subframe_idx]; slot_idx++ ) #else @@ -2745,7 +2772,6 @@ void ivas_dirac_dec_render_sf( if ( hDirAC->hConfig->dec_param_estim == FALSE ) { - /* compute response */ if ( hDirAC->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { @@ -2809,7 +2835,6 @@ void ivas_dirac_dec_render_sf( } } - if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData->shd_rot_max_order == 1 ) { ivas_dirac_dec_compute_directional_responses( hDirAC, @@ -2842,7 +2867,6 @@ void ivas_dirac_dec_render_sf( } } - #ifdef JBM_TSM_ON_TCS for ( slot_idx = 0; slot_idx < hDirAC->subframe_nbslots[subframe_idx]; slot_idx++ ) #else @@ -3249,6 +3273,7 @@ void ivas_dirac_dec_render_sf( } #endif } + #ifndef JBM_TSM_ON_TCS if ( hDirAC->hConfig->dec_param_estim == 0 ) { @@ -3320,8 +3345,9 @@ void ivas_dirac_dec_render_sf( qualityBasedSmFactor = st_ivas->hMasa->data.dir_decode_quality; qualityBasedSmFactor *= qualityBasedSmFactor; } + #ifdef JBM_TSM_ON_TCS - /* Workaround for BE (should be gone when #393 is adressed) */ + /* ToDo: Workaround for BE (should be gone when #393 is adressed) */ if ( hDirAC->hConfig->dec_param_estim == 1 ) { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 892cfe4acbd1120a7f3d2f4b90eae08a2fa2ad76..ffe6fea38249029d090ac8ee38e6171705641479 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -104,8 +104,12 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( set_zero( h_dirac_output_synthesis_state->cx_old[idx], nchan_in * nchan_in ); set_zero( h_dirac_output_synthesis_state->cy_old[idx], nchan_out * nchan_out ); set_zero( h_dirac_output_synthesis_state->mixing_matrix_old[idx], nchan_out * nchan_in ); + #ifdef JBM_TSM_ON_TCS - h_dirac_output_synthesis_state->mixing_matrix[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ); + if ( ( h_dirac_output_synthesis_state->mixing_matrix[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n" ) ); + } set_zero( h_dirac_output_synthesis_state->mixing_matrix[idx], nchan_out * nchan_in ); #endif } @@ -118,6 +122,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( h_dirac_output_synthesis_state->mixing_matrix[idx] = NULL; #endif } + for ( idx = 0; idx < num_param_bands_residual; idx++ ) { if ( ( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ) ) == NULL ) @@ -125,8 +130,12 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); } set_zero( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx], nchan_out * nchan_out ); + #ifdef JBM_TSM_ON_TCS - h_dirac_output_synthesis_state->mixing_matrix_res[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ); + if ( ( h_dirac_output_synthesis_state->mixing_matrix_res[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n" ) ); + } set_zero( h_dirac_output_synthesis_state->mixing_matrix_res[idx], nchan_out * nchan_out ); #endif } @@ -158,16 +167,18 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS /*-------------------------------------------------------------------* - * ivas_dirac_dec_output_synthesis_cov_open() + * ivas_dirac_dec_output_synthesis_get_interpolator() + * * - * Sets up the state and parameters for the Covariance Synthesis *-------------------------------------------------------------------*/ void ivas_dirac_dec_output_synthesis_get_interpolator( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ - const uint16_t interp_length ) + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ + const uint16_t interp_length /* i : interpolator length */ +) { int16_t idx; @@ -285,6 +296,7 @@ void ivas_dirac_dec_output_synthesis_cov_close( free( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] ); h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] = NULL; } + #ifdef JBM_TSM_ON_TCS if ( h_dirac_output_synthesis_state->mixing_matrix[idx] != NULL ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 98ddbe5ec8e1b18ef076c4a66ff63e48a3c7579c..ddb6496fce7930e0dcd97fbcb297e0471643b5a1 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -676,6 +676,9 @@ ivas_error ivas_init_decoder( int16_t i, k, n; int16_t sce_id, cpe_id; int16_t numCldfbAnalyses, numCldfbSyntheses; +#ifdef JBM_TSM_ON_TCS + int16_t granularity, n_channels_transport_jbm; +#endif int32_t output_Fs, ivas_total_brate; int32_t binauralization_delay_ns; AUDIO_CONFIG output_config; @@ -1326,13 +1329,13 @@ ivas_error ivas_init_decoder( return error; } } + #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active ) { - int16_t granularity; - int16_t n_channels_transport_jbm; granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; @@ -1371,13 +1374,13 @@ ivas_error ivas_init_decoder( } st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; + #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active ) { - int16_t granularity; - int16_t n_channels_transport_jbm; granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; @@ -1404,6 +1407,7 @@ ivas_error ivas_init_decoder( /*-----------------------------------------------------------------* * LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay *-----------------------------------------------------------------*/ + if ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { binauralization_delay_ns = st_ivas->binaural_latency_ns; @@ -1475,15 +1479,21 @@ ivas_error ivas_init_decoder( } #ifdef JBM_TSM_ON_TCS + /*-----------------------------------------------------------------* + * Allocate and initialize JBM struct + buffer + *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active && st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ - int16_t n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } } + if ( st_ivas->hTcBuffer == NULL ) { /* we need the handle anyway, but without the buffer*/ @@ -1497,9 +1507,6 @@ ivas_error ivas_init_decoder( return error; } -#ifdef JBM_TSM_ON_TCS - -#endif /*------------------------------------------------------------------------- * destroy_core_dec() diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 34645b07df8fd4fe711edcfc7c073f0dc5675597..fe98ca0dcb4fff6317395dc2ffc9701fd98d4b5a 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -54,8 +54,8 @@ static ivas_error ivas_ism_bitrate_switching( const ISM_MODE last_ism_mode /* i : last ISM mode */ #ifdef JBM_TSM_ON_TCS , - uint16_t *nSamplesRendered, - int16_t *data + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + int16_t *data /* o : rendered samples */ #endif ) { @@ -63,7 +63,6 @@ static ivas_error ivas_ism_bitrate_switching( int32_t element_brate_tmp[MAX_NUM_OBJECTS]; int16_t nSCE_old, nCPE_old; int16_t numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode; - #ifdef JBM_TSM_ON_TCS TC_BUFFER_MODE tc_buffer_mode_new; int16_t tc_nchan_tc_new; @@ -142,9 +141,11 @@ static ivas_error ivas_ism_bitrate_switching( st_ivas->hTcBuffer->slots_rendered = st_ivas->hDirAC->slots_rendered; mvs2s( st_ivas->hDirAC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } + /* 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 */ tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->hDecoderConfig->output_Fs ); + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) @@ -330,6 +331,7 @@ static ivas_error ivas_ism_bitrate_switching( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active == 1 ) { int16_t tc_nchan_full_new; @@ -340,15 +342,18 @@ static ivas_error ivas_ism_bitrate_switching( tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; tc_nchan_full_new = tc_nchan_allocate_new; } + if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { tc_nchan_full_new = 0; } + /* reconfigure buffer */ if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new ) @@ -358,6 +363,7 @@ static ivas_error ivas_ism_bitrate_switching( return error; } } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hDirAC != NULL ) { @@ -365,6 +371,7 @@ static ivas_error ivas_ism_bitrate_switching( st_ivas->hDirAC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; st_ivas->hDirAC->num_slots = st_ivas->hTcBuffer->num_slots; st_ivas->hDirAC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hDirAC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } } diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 7c22ff2e9e16aa871944278f3d3eba7dba5df3d6..6dd301f1610afa04f7ba1efd6afbe3fbdb088243 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -95,6 +95,7 @@ ivas_error ivas_ism_dtx_dec( ism_mode_bstr = (ISM_MODE) ( idx + 1 ); st_ivas->ism_mode = ism_mode_bstr; } + #ifdef JBM_TSM_ON_TCS if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, NULL, NULL ) ) != IVAS_ERR_OK ) #else diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 5236de4109e9a7344cbb722341c74d50b4e183da..da4ce9210742163bccc1535f4177c8721d981fd4 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -157,6 +157,7 @@ static void ivas_ism_get_proto_matrix( return; } + #ifdef JBM_TSM_ON_TCS static void ivas_param_ism_collect_slot( DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ @@ -185,9 +186,11 @@ static void ivas_param_ism_collect_slot( ref_power[bin_idx] += tmp; } } + return; } + static void ivas_param_ism_compute_mixing_matrix( const int16_t nchan_ism, /* i : number of ISM channels */ DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ @@ -404,6 +407,7 @@ static void ivas_param_ism_compute_mixing_matrix( } #endif + #ifdef JBM_TSM_ON_TCS static void ivas_param_ism_render_slot( DIRAC_DEC_HANDLE hDirAC, @@ -442,6 +446,7 @@ static void ivas_param_ism_render_slot( } #endif + static void ivas_param_ism_rendering( DIRAC_DEC_HANDLE hDirAC, float Cldfb_RealBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], @@ -703,6 +708,7 @@ ivas_error ivas_param_ism_dec_open( st_ivas->hISMDTX.dtx_flag = 0; st_ivas->hDirAC = hDirAC; + #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active ) { @@ -718,9 +724,16 @@ ivas_error ivas_param_ism_dec_open( } else { - hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ); + if ( ( hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) ); + } set_zero( hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc, MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands ); - hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ); + + if ( ( hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) ); + } set_zero( hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc, MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands ); } if ( st_ivas->hTcBuffer == NULL ) @@ -1054,6 +1067,7 @@ void ivas_param_ism_dec( RealBuffer[i] = Cldfb_RealBuffer[idx_in][i]; ImagBuffer[i] = Cldfb_ImagBuffer[idx_in][i]; } + #ifdef JBM_TSM_ON_TCS cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][slot_idx_start * hDirAC->num_freq_bands] ), hDirAC->num_freq_bands * hDirAC->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); @@ -1092,21 +1106,29 @@ void ivas_param_ism_dec( } #ifdef JBM_TSM_ON_TCS + +/*-------------------------------------------------------------------------* + * ivas_ism_dec_digest_tc() + * + * + *-------------------------------------------------------------------------*/ + void ivas_ism_dec_digest_tc( - Decoder_Struct *st_ivas ) + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - if ( - st_ivas->renderer_type == RENDERER_TD_PANNING || - st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) ) + if ( st_ivas->renderer_type == RENDERER_TD_PANNING || + st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) ) { int16_t i, num_objects; int16_t azimuth, elevation; + /* we have a full frame interpolator, adapt it */ /* for BE testing */ if ( ( st_ivas->hDecoderConfig->output_Fs / (int32_t) FRAMES_PER_SECOND ) == st_ivas->hTcBuffer->n_samples_available ) @@ -1139,6 +1161,7 @@ void ivas_ism_dec_digest_tc( for ( i = 0; i < num_objects; i++ ) { mvr2r( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->prev_gains[i], MAX_OUTPUT_CHANNELS ); + if ( st_ivas->intern_config == AUDIO_CONFIG_STEREO ) { ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, @@ -1151,15 +1174,15 @@ void ivas_ism_dec_digest_tc( // TODO tmu review when #215 is resolved azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->azimuth + 0.5f ); elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->elevation + 0.5f ); + if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && st_ivas->hHeadTrackData == NULL ) { - - if ( st_ivas->hIntSetup.is_planar_setup ) { /* If no elevation support in output format, then rendering should be done with zero elevation */ elevation = 0; } + if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); @@ -1173,13 +1196,21 @@ void ivas_ism_dec_digest_tc( } } } + return; } + +/*-------------------------------------------------------------------------* + * ivas_param_ism_dec_digest_tc() + * + * + *-------------------------------------------------------------------------*/ + void ivas_param_ism_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ) { int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; @@ -1189,7 +1220,6 @@ void ivas_param_ism_dec_digest_tc( float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; /* Direct Response/EFAP Gains */ float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; - DIRAC_DEC_HANDLE hDirAC; /* Initialization */ @@ -1308,21 +1338,27 @@ void ivas_param_ism_dec_digest_tc( /* Compute mixing matrix */ ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hDirAC, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hDirAC->hParamIsmRendering->mixing_matrix_lin ); - pop_wmops(); return; } -static void ivas_ism_param_dec_render_sf( Decoder_Struct *st_ivas, - IVAS_OUTPUT_SETUP hSetup, - const int16_t nchan_transport, - const int16_t nchan_out, - const int16_t nchan_out_woLFE, - float *output_f[] /* o : rendered time signal */ + +/*-------------------------------------------------------------------------* + * ivas_ism_param_dec_render_sf() + * + * + *-------------------------------------------------------------------------*/ + +static void ivas_ism_param_dec_render_sf( + Decoder_Struct *st_ivas, + IVAS_OUTPUT_SETUP hSetup, + const int16_t nchan_transport, + const int16_t nchan_out, + const int16_t nchan_out_woLFE, + float *output_f[] /* o : rendered time signal */ ) { - int16_t ch, slot_idx, i, index_slot; /* CLDFB Output Buffers */ float Cldfb_RealBuffer[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; @@ -1360,7 +1396,6 @@ static void ivas_ism_param_dec_render_sf( Decoder_Struct *st_ivas, Cldfb_ImagBuffer_in[ch] = &hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc[index_slot * hDirAC->num_freq_bands * nchan_transport + ch * hDirAC->num_freq_bands]; } - /* Compute bandwise rendering to target LS using covariance rendering */ ivas_param_ism_render_slot( hDirAC, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirAC->hParamIsmRendering->mixing_matrix_lin, index_slot, slot_idx, @@ -1397,16 +1432,26 @@ static void ivas_ism_param_dec_render_sf( Decoder_Struct *st_ivas, idx_in++; } } + hDirAC->slots_rendered += hDirAC->subframe_nbslots[subframe_idx]; hDirAC->subframes_rendered++; + + return; } + +/*-------------------------------------------------------------------------* + * ivas_param_ism_dec_render() + * + * + *-------------------------------------------------------------------------*/ + void ivas_param_ism_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t ch, slots_to_render, first_sf, last_sf, subframe_idx; @@ -1434,11 +1479,13 @@ void ivas_param_ism_dec_render( nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hDirAC->num_slots - hDirAC->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hDirAC->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hDirAC->subframe_nbslots[last_sf]; @@ -1447,10 +1494,12 @@ void ivas_param_ism_dec_render( #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif + for ( ch = 0; ch < nchan_out; ch++ ) { output_f_local[ch] = &output_f[ch][0]; } + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { ivas_ism_param_dec_render_sf( st_ivas, hSetup, nchan_transport, nchan_out, nchan_out_woLFE, output_f_local ); @@ -1460,6 +1509,7 @@ void ivas_param_ism_dec_render( output_f_local[ch] += n_samples_sf; } } + if ( hDirAC->slots_rendered == hDirAC->num_slots ) { /* copy the memories */ @@ -1481,10 +1531,11 @@ void ivas_param_ism_dec_render( st_ivas->hIsmMetaData[ch]->elevation = st_ivas->hDirAC->elevation_values[ch]; } } + *nSamplesAvailable = ( hDirAC->num_slots - hDirAC->slots_rendered ) * slot_size; + return; } - #endif @@ -1533,6 +1584,7 @@ void ivas_param_ism_params_to_masa_param_mapping( hDirAC->numSimultaneousDirections = 1; azimuth[0] = (int16_t) roundf( hDirAC->azimuth_values[0] ); elevation[0] = (int16_t) roundf( hDirAC->elevation_values[0] ); + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) @@ -1576,6 +1628,7 @@ void ivas_param_ism_params_to_masa_param_mapping( } } } + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) @@ -1592,6 +1645,7 @@ void ivas_param_ism_params_to_masa_param_mapping( hDirAC->numSimultaneousDirections = 1; azimuth[0] = (int16_t) roundf( hDirAC->azimuth_values[0] ); elevation[0] = (int16_t) roundf( hDirAC->elevation_values[0] ); + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 785b86834ba6d86f71ffe348f18815a5898378a8..031c6cf18f93607afcf974e3d342c4f9e155fa2e 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -109,6 +109,7 @@ ivas_error ivas_ism_renderer_open( st_ivas->hIsmRendererData->interpolator[i] = (float) i / ( (float) interpolator_length - 1 ); } #endif + return error; } @@ -229,6 +230,12 @@ void ivas_ism_render( } #ifdef JBM_TSM_ON_TCS +/*-------------------------------------------------------------------------* + * ivas_ism_render_sf() + * + * Object rendering process + *-------------------------------------------------------------------------*/ + void ivas_ism_render_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: core-coder transport channels/object output */ @@ -259,6 +266,7 @@ void ivas_ism_render_sf( { /* Calculate rotation matrix from the quaternion */ QuatToRotMat( st_ivas->hHeadTrackData->Quaternions[st_ivas->hHeadTrackData->num_quaternions++], Rmat ); + ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); @@ -267,7 +275,6 @@ void ivas_ism_render_sf( for ( i = 0; i < num_objects; i++ ) { - /* Head rotation: rotate the object positions depending the head's orientation */ #ifdef FIX_473_JITTER_NONDIEGETIC_PANNING if ( st_ivas->hHeadTrackData != NULL && st_ivas->hHeadTrackData->num_quaternions >= 0 && !st_ivas->hIsmMetaData[i]->non_diegetic_flag ) @@ -302,6 +309,7 @@ void ivas_ism_render_sf( output_f[j2][k] += ( *( g1++ ) * gain + g2 * prev_gain ) * *( tc++ ); } } + /* update here only in case of head rotation */ if ( st_ivas->hHeadTrackData != NULL && st_ivas->hHeadTrackData->num_quaternions >= 0 ) { @@ -309,6 +317,7 @@ void ivas_ism_render_sf( } } } + return; } #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d3279030d29da811c91a15be7c1cca47a1e90eec..0e112a84df666e6f2364bb1005070854542c8e74 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -51,18 +51,21 @@ /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ + static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *data, float *tc_digest_f[] ); + static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc() * - * Principal IVAS decoder routine, decoding of metadata and transport channels + * Principal IVAS JBM decoder routine, decoding of metadata and transport channels *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : transport channel signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *data /* o : transport channel signals */ ) { int16_t n, output_frame, nchan_out; @@ -130,6 +133,7 @@ ivas_error ivas_jbm_dec_tc( { hp20( output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } + if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hDecoderConfig->nchan_out == 1 ) { ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, output_frame, p_output, p_output ); @@ -147,7 +151,6 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - // VE: call ivas_ism_metadata_dec() with 'st_ivas' - TBD if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt ) ) != IVAS_ERR_OK ) { return error; @@ -506,17 +509,18 @@ ivas_error ivas_jbm_dec_tc( return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_feed_tc_to_renderer() * - * Feed decoded transport channels and metadata to the IVAS renderer routine + * Feed decoded transport channels and metadata to the IVAS JBM renderer routine *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_feed_tc_to_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i: : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o: : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i : transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ + float *data /* i : transport channels */ ) { @@ -594,8 +598,9 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( /*--------------------------------------------------------------------------* * ivas_dec_render() * - * Principal IVAS rendering routine + * Principal IVAS JBM rendering routine *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesAsked, /* i : number of samples wanted */ @@ -604,7 +609,6 @@ ivas_error ivas_jbm_dec_render( int16_t *data /* o : output synthesis signal */ ) { - int16_t n, nchan_out; int16_t nchan_transport; float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ /* IVAS_fmToDo: buffer can be allocated dynamically based on the actual number of output channels */ @@ -632,6 +636,7 @@ ivas_error ivas_jbm_dec_render( nchan_transport = st_ivas->hTcBuffer->nchan_transport_jbm; output_config = st_ivas->hDecoderConfig->output_config; nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { p_output[n] = &output[n][0]; @@ -696,6 +701,7 @@ ivas_error ivas_jbm_dec_render( else /* ISM_MODE_DISC */ { *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + /* Loudspeaker or Ambisonics rendering */ if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { @@ -720,25 +726,19 @@ ivas_error ivas_jbm_dec_render( /* Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, *nSamplesRendered ); + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - AUDIO_CONFIG_7_1_4, - AUDIO_CONFIG_BINAURAL_ROOM, - st_ivas->hDecoderConfig, - NULL, - NULL, - NULL, - st_ivas->hTcBuffer, - p_output, - p_output, - *nSamplesRendered, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, st_ivas->hDecoderConfig, NULL, NULL, + NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); } #ifdef DEBUGGING @@ -752,6 +752,7 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { nchan_remapped = nchan_transport; + /* Loudspeakers, Ambisonics or Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { @@ -766,7 +767,11 @@ ivas_error ivas_jbm_dec_render( { mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); } - ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); + + if ( ( error = ivas_sba_linear_renderer( p_output, *nSamplesRendered, nchan_remapped, output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( st_ivas->renderer_type == RENDERER_DIRAC ) { @@ -791,21 +796,12 @@ ivas_error ivas_jbm_dec_render( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - st_ivas->intern_config, - st_ivas->hOutSetup.output_config, - st_ivas->hDecoderConfig, - st_ivas->hHeadTrackData, - &st_ivas->hIntSetup, - st_ivas->hEFAPdata, - st_ivas->hTcBuffer, - p_tc, - p_output, - *nSamplesRendered, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hHeadTrackData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc, p_output ); } else if ( st_ivas->renderer_type == RENDERER_MC ) @@ -819,7 +815,11 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, *nSamplesRendered ); + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc, p_output ); } } @@ -829,8 +829,6 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { - - /* Rendering */ int16_t offset = st_ivas->hDirAC->slots_rendered * st_ivas->hDirAC->slot_size; nchan_remapped = st_ivas->nchan_transport; @@ -842,7 +840,6 @@ ivas_error ivas_jbm_dec_render( { ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); - if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { /* we still need to copy the separate channel if available */ @@ -850,6 +847,7 @@ ivas_error ivas_jbm_dec_render( { mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); } + ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); } else if ( st_ivas->intern_config == AUDIO_CONFIG_5_1 && ( output_config == AUDIO_CONFIG_5_1_2 || output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1 ) ) @@ -860,6 +858,7 @@ ivas_error ivas_jbm_dec_render( } } } + /* copy discrete C and TD LFE from internal TC to output */ if ( st_ivas->hOutSetup.separateChannelEnabled ) { @@ -884,8 +883,10 @@ ivas_error ivas_jbm_dec_render( * - compensation for saturation * - float to integer conversion *----------------------------------------------------------------*/ + st_ivas->hTcBuffer->n_samples_available -= *nSamplesRendered; st_ivas->hTcBuffer->n_samples_rendered += *nSamplesRendered; + if ( st_ivas->hTcBuffer->n_samples_discard > 0 ) { for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) @@ -915,6 +916,7 @@ ivas_error ivas_jbm_dec_render( * * Flush samples if renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_flush_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t tc_granularity_new, /* i : new renderer granularity */ @@ -939,6 +941,7 @@ ivas_error ivas_jbm_dec_flush_renderer( *nSamplesRendered = 0; hTcBuffer = st_ivas->hTcBuffer; + /* get number of possible slots in new granularity */ n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered; n_slots_still_available = n_samples_still_available / tc_granularity_new; @@ -946,9 +949,11 @@ ivas_error ivas_jbm_dec_flush_renderer( n_samples_to_render = *nSamplesRendered; n_samples_still_available -= n_samples_to_render; assert( n_samples_still_available < tc_granularity_new ); + if ( n_slots_still_available ) { - int ch_idx; + int16_t ch_idx; + /* render what is still there with zero padding */ for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { @@ -957,6 +962,7 @@ ivas_error ivas_jbm_dec_flush_renderer( set_zero( hTcBuffer->tc[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); mvr2r( hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_rendered + n_samples_to_render, hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_granularity, n_samples_still_available ); } + /* simple change of the slot info */ hTcBuffer->num_slots = 1; hTcBuffer->nb_subframes = 1; @@ -980,28 +986,24 @@ ivas_error ivas_jbm_dec_flush_renderer( /* Binaural rendering */ if ( renderer_type_old == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ); + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ set_f( st_ivas->hIsmRendererData->interpolator, 1.0f, hTcBuffer->n_samples_granularity ); + ivas_ism_render_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ); - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - AUDIO_CONFIG_7_1_4, - AUDIO_CONFIG_BINAURAL_ROOM, - st_ivas->hDecoderConfig, - NULL, - NULL, - NULL, - st_ivas->hTcBuffer, - p_output, - p_output, - hTcBuffer->n_samples_granularity, - st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, st_ivas->hDecoderConfig, NULL, NULL, + NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, p_output, p_output ); } } @@ -1016,26 +1018,22 @@ ivas_error ivas_jbm_dec_flush_renderer( { if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV || renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - intern_config_old, - st_ivas->hOutSetup.output_config, - st_ivas->hDecoderConfig, - st_ivas->hHeadTrackData, - hIntSetupOld, - st_ivas->hEFAPdata, - st_ivas->hTcBuffer, - hTcBuffer->tc, - p_output, - hTcBuffer->n_samples_granularity, - st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hHeadTrackData, hIntSetupOld, + st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ); + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + { + return error; + } + + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); } } @@ -1062,11 +1060,13 @@ ivas_error ivas_jbm_dec_flush_renderer( return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_set_discard_samples() * * Set number of samples to discard in the first subframe if the renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_set_discard_samples( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ) @@ -1085,9 +1085,11 @@ ivas_error ivas_jbm_dec_set_discard_samples( /* set last subframes number to max to ensure correct continuation */ st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe; } + return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_linear_interpolator() * @@ -1114,6 +1116,7 @@ void ivas_jbm_dec_get_adapted_linear_interpolator( { interpolator[idx] = max( 0.0f, interpolator[idx + 1] - dec ); } + if ( interpolator[idx + 1] > 0.0f ) { dec = interpolator[idx + 1] / ( jbm_segment_len + 1 ); @@ -1126,13 +1129,17 @@ void ivas_jbm_dec_get_adapted_linear_interpolator( { set_f( interpolator, 0.0f, idx + 1 ); } + + return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_subframes() * * Get an interpolator that is adapted to time scale modified IVAS frame *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_get_adapted_subframes( const int16_t nCldfbTs, /* i : number of time slots in the current frame */ int16_t *subframe_nbslots, /* i/o: subframe grid */ @@ -1141,6 +1148,7 @@ void ivas_jbm_dec_get_adapted_subframes( { uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; uint16_t nCldfbSlotsLocal = nCldfbTs; + /* get last subframe size from previous frame, determine how many slots have to be processed in the first subframe (i.e. potential leftover of a 5ms subframe) */ nSlotsInFirstSubframe = ( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - subframe_nbslots[*nb_subframes - 1] ); @@ -1150,26 +1158,33 @@ void ivas_jbm_dec_get_adapted_subframes( *nb_subframes = 1; nCldfbSlotsLocal -= nSlotsInFirstSubframe; } + *nb_subframes += (int16_t) ceilf( (float) nCldfbSlotsLocal / (float) PARAM_MC_MAX_NSLOTS_IN_SUBFRAME ); nSlotsInLastSubframe = nCldfbSlotsLocal % PARAM_MC_MAX_NSLOTS_IN_SUBFRAME; + set_s( subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, *nb_subframes ); + if ( nSlotsInFirstSubframe > 0 ) { subframe_nbslots[0] = nSlotsInFirstSubframe; } + if ( nSlotsInLastSubframe > 0 ) { subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe; } + return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_linear_interpolator() * * Get an meta data map adapted to a time scale modified IVAS frame *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_get_md_map( const int16_t default_len, /* i : default frame length in metadata slots */ const int16_t len, /* i : length of the modfied frames in metadata slots */ @@ -1181,19 +1196,19 @@ void ivas_jbm_dec_get_md_map( { int16_t jbm_segment_len, map_idx, src_idx, src_idx_map; float dec, src_idx_f; + #ifdef DEBUGGING assert( default_len % 2 == 0 ); #endif - jbm_segment_len = ( default_len >> 1 ); dec = 1.0f / default_len; - for ( map_idx = len - 1, src_idx = default_len - 1; map_idx >= jbm_segment_len; map_idx--, src_idx-- ) { src_idx_map = max( 0, src_idx / subframe_len ); map[map_idx] = ( offset + src_idx_map ) % buf_len; } + /* changed part (first segment), interpolate index to parameters (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ if ( src_idx >= 0 ) @@ -1211,14 +1226,20 @@ void ivas_jbm_dec_get_md_map( { set_s( map, offset, map_idx + 1 ); } + + return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_num_tc_channels() * * Get the number of transport channels provided by the JBM transport channel decode function *--------------------------------------------------------------------------*/ -int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas ) /* i : IVAS decoder handle */ + +int16_t ivas_jbm_dec_get_num_tc_channels( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +) { int16_t num_tc; int32_t ivas_total_brate; @@ -1314,18 +1335,20 @@ int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas ) /* i : IVAS return num_tc; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_copy_tc() * * Copy interleaved transport chnannels to the correct buffers, update the TC * buffer handle *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_copy_tc( + +static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of samples to digest */ int16_t *nSamplesResidual, /* o : number of samples that will be left for the next frame */ float *data, /* i : (interleaved) transport channel samples */ - float *tc_digest_f[] /* o : samples that will be directly digestest (eg. by CLDFB) */ + float *tc_digest_f[] /* o : samples that will be directly digested (e.g. by CLDFB) */ ) { int16_t ch; @@ -1334,7 +1357,6 @@ void ivas_jbm_dec_copy_tc( int16_t n_ch_full_copy; int16_t n_ch_res_copy; - hTcBuffer = st_ivas->hTcBuffer; n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered; hTcBuffer->n_samples_buffered = n_samples_still_available + nSamplesForRendering + hTcBuffer->n_samples_discard; @@ -1352,6 +1374,7 @@ void ivas_jbm_dec_copy_tc( hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_jbm + ch]; } } + if ( n_ch_res_copy > 0 ) { for ( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) @@ -1364,13 +1387,24 @@ void ivas_jbm_dec_copy_tc( mvr2r( tc_digest_f[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc[ch], *nSamplesResidual ); } } + hTcBuffer->n_samples_rendered = 0; + return; } -int16_t ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, - const int32_t output_Fs ) +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_get_render_granularity() + * + * + *--------------------------------------------------------------------------*/ + +/*! r: render granularity */ +int16_t ivas_jbm_dec_get_render_granularity( + const RENDERER_TYPE rendererType, /* i : renderer type */ + const int32_t output_Fs /* i : sampling rate */ +) { int16_t render_granularity; @@ -1386,17 +1420,19 @@ int16_t ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, return render_granularity; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_open() * - * open and initialize the transport channel buffer + * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc_buffer_open( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ const int16_t nchan_transport_jbm, /* i : number of real transport channels */ const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : nubmer of channels to fully store */ + const int16_t nchan_full, /* i : number of channels to fully store */ const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ) { @@ -1415,8 +1451,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open( if ( ( hTcBuffer = (DECODER_TC_BUFFER_HANDLE) malloc( sizeof( DECODER_TC_BUFFER ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } + hTcBuffer->tc_buffer_mode = tc_buffer_mode; hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; hTcBuffer->nchan_transport_internal = nchan_transport_internal; @@ -1450,10 +1487,16 @@ ivas_error ivas_jbm_dec_tc_buffer_open( int16_t n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); int16_t n_samp_residual = hTcBuffer->n_samples_granularity - 1; int32_t offset; + nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; - hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ); + + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { @@ -1472,14 +1515,17 @@ ivas_error ivas_jbm_dec_tc_buffer_open( } st_ivas->hTcBuffer = hTcBuffer; + return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_reconfigure() * - * open and initialize the transport channel buffer + * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc_buffer_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ @@ -1537,8 +1583,10 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer->nchan_buffer_full = nchan_full; nchan_residual = nchan_transport_internal - nchan_full; hTcBuffer->n_samples_granularity = n_samples_granularity; +#ifdef DEBUGGING /* what is remaining from last frames needs always be smaller than n_samples_granularity */ assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity ); +#endif /* realloc buffers */ free( hTcBuffer->tc_buffer ); @@ -1546,8 +1594,13 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( n_samp_residual = hTcBuffer->n_samples_granularity - 1; nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; - hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ); + + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { @@ -1567,7 +1620,14 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( return error; } -void ivas_jbm_dec_tc_buffer_playout( + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_tc_buffer_playout() + * + * + *--------------------------------------------------------------------------*/ + +static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, @@ -1577,25 +1637,37 @@ void ivas_jbm_dec_tc_buffer_playout( int16_t ch_idx, slot_size, slots_to_render, first_sf, last_sf; slot_size = st_ivas->hTcBuffer->n_samples_granularity; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, nSamplesAsked / slot_size ); st_ivas->hTcBuffer->slots_rendered += slots_to_render; *nSamplesRendered = (uint16_t) slots_to_render * slot_size; first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; last_sf++; } + for ( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) { mvr2r( st_ivas->hTcBuffer->tc[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered, output[ch_idx], *nSamplesRendered ); } st_ivas->hTcBuffer->subframes_rendered = last_sf; + + return; } + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_tc_buffer_close() + * + * Close JBM transport channel buffer + *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_tc_buffer_close( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) @@ -1617,20 +1689,31 @@ void ivas_jbm_dec_tc_buffer_close( free( *phTcBuffer ); *phTcBuffer = NULL; } + return; } + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_td_renderers_adapt_subframes() + * + * Close JBM transport channel buffer + *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_td_renderers_adapt_subframes( - Decoder_Struct *st_ivas ) + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) { int16_t nMaxSlotsPerSubframe, nSlotsAvailable; uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; + nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; st_ivas->hTcBuffer->num_slots = nSlotsAvailable; st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; nSlotsInFirstSubframe = nMaxSlotsPerSubframe - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; st_ivas->hTcBuffer->nb_subframes = 0; + if ( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->nb_subframes = 1; @@ -1640,24 +1723,37 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe; set_s( st_ivas->hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( st_ivas->hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, st_ivas->hTcBuffer->nb_subframes ); + if ( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe; } + if ( nSlotsInLastSubframe > 0 ) { st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe; } + st_ivas->hTcBuffer->slots_rendered = 0; st_ivas->hTcBuffer->subframes_rendered = 0; + + return; } -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( Decoder_Struct *st_ivas ) + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_get_tc_buffer_mode() + * + * + *--------------------------------------------------------------------------*/ + +TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) { TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_BUFFER; - /*:TODO: wrap this maybe nicer without directly accessing the st_ivas struct...*/ switch ( st_ivas->renderer_type ) { /* all renderers where we are done after TC decoding (might include DMX to mono/stereo */ @@ -1724,7 +1820,6 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( Decoder_Struct *st_ivas ) #endif } - return buffer_mode; } #endif diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 7445bfb4894103069b518c76da51d939b6088b54..401e041894797ab2e2d572ba76e0d8c6b44932e7 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -413,11 +413,13 @@ ivas_error ivas_masa_dec_open( { int16_t nchan_to_allocate; TC_BUFFER_MODE buffer_mode; + buffer_mode = TC_BUFFER_MODE_RENDERER; if ( st_ivas->mc_mode == MC_MODE_MCMASA && ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) { buffer_mode = TC_BUFFER_MODE_BUFFER; } + nchan_to_allocate = ivas_jbm_dec_get_num_tc_channels( st_ivas ); if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { @@ -1299,11 +1301,13 @@ ivas_error ivas_masa_dec_reconfigure( buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + tc_nchan_to_allocate = tc_nchan_transport; if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } + if ( tc_nchan_transport != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || buffer_mode_new != st_ivas->hTcBuffer->tc_buffer_mode ) { if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) @@ -1313,6 +1317,7 @@ ivas_error ivas_masa_dec_reconfigure( } } #endif + return error; } @@ -1349,7 +1354,6 @@ void ivas_spar_param_to_masa_param_mapping( float slot_fac; #endif - /* Set values */ hDirAC = st_ivas->hDirAC; hDirAC->numSimultaneousDirections = 1; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index c6e0776660877f0faf0577fb3e5583cf268e5d48..4be35d188e885187d17629cb048449ebce5a3a64 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -481,10 +481,18 @@ ivas_error ivas_param_mc_dec_open( #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active && hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) { - hParamMC->Cldfb_RealBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ); + if ( ( hParamMC->Cldfb_RealBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); + } set_zero( hParamMC->Cldfb_RealBuffer_tc, MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hParamMC->num_freq_bands ); - hParamMC->Cldfb_ImagBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ); + + if ( ( hParamMC->Cldfb_ImagBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); + } set_zero( hParamMC->Cldfb_ImagBuffer_tc, MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hParamMC->num_freq_bands ); + if ( st_ivas->hTcBuffer == NULL ) { if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) @@ -498,6 +506,7 @@ ivas_error ivas_param_mc_dec_open( hParamMC->Cldfb_RealBuffer_tc = NULL; hParamMC->Cldfb_ImagBuffer_tc = NULL; } + hParamMC->subframes_rendered = 0; hParamMC->slots_rendered = 0; #endif @@ -652,7 +661,6 @@ ivas_error ivas_param_mc_dec_reconfig( hParamMC->slot_size = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX; hParamMC->subframe_nbslots = CLDFB_NO_COL_MAX / PARAM_MC_NSUBFRAMES_DEC; #endif - hParamMC->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); hParamMC->max_band_energy_compensation = hParamMC->num_freq_bands; @@ -1406,7 +1414,14 @@ void ivas_param_mc_dec_read_BS( return; } + #ifdef JBM_TSM_ON_TCS +/*------------------------------------------------------------------------- + * ivas_param_mc_dec_digest_tc() + * + * + *------------------------------------------------------------------------*/ + void ivas_param_mc_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ @@ -1550,6 +1565,7 @@ void ivas_param_mc_dec_digest_tc( return; } + /*------------------------------------------------------------------------- * ivas_param_mc_dec() * @@ -1831,11 +1847,13 @@ void ivas_param_mc_dec_render( } #endif + /*------------------------------------------------------------------------- * ivas_param_mc_dec() * * Parametric MC decoding process *------------------------------------------------------------------------*/ + #ifdef JBM_TSM_ON_TCS void ivas_param_mc_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 6eada0e18b3912579410cf73cf7600bc67c8bf07..46c4343800b8474a557627ae809ed95d5562798b 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -911,7 +911,6 @@ static ivas_error ivas_mc_dec_reconfig( } #endif - if ( last_mc_mode == MC_MODE_MCT ) { if ( st_ivas->hMCT != NULL && st_ivas->nchan_transport <= CPE_CHANNELS ) @@ -1295,6 +1294,7 @@ static ivas_error ivas_mc_dec_reconfig( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active == 1 ) { int16_t tc_nchan_full_new; @@ -1314,6 +1314,7 @@ static ivas_error ivas_mc_dec_reconfig( { tc_nchan_full_new = 0; } + /* reconfigure buffer */ if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new || @@ -1324,6 +1325,7 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hDirAC != NULL ) { @@ -1343,5 +1345,6 @@ static ivas_error ivas_mc_dec_reconfig( } } #endif + return error; } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 1849ce6bdf2477cc1436d15bc99a67a4d435fe46..ba14104ed95239e1cf2b831c48be80c715f70b88 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -102,18 +102,20 @@ ivas_error ivas_td_binaural_renderer( #endif } + #ifdef JBM_TSM_ON_TCS /*---------------------------------------------------------------------* - * ObjRenderIVASFrame() + * ivas_td_binaural_renderer_sf() * * Receives the current frames for the object streams, updates metadata * and renders the current frame. *---------------------------------------------------------------------*/ -void ObjRenderIVASSubframe( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t n_samples_asked ) +ivas_error ivas_td_binaural_renderer_sf( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ +) { int16_t first_sf, last_sf, subframe_idx; float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -121,6 +123,8 @@ void ObjRenderIVASSubframe( float *output_f_local[BINAURAL_CHANNELS]; float *tc_local[MAX_TRANSPORT_CHANNELS]; int16_t ch, slot_size, slots_to_render, output_frame; + ivas_error error; + #ifdef FIX_356_ISM_METADATA_SYNC int16_t ism_md_subframe_update_jbm; int16_t c_indx, nS; @@ -140,20 +144,25 @@ void ObjRenderIVASSubframe( { p_reverb_signal[ch] = reverb_signal[ch]; } + for ( ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++ ) { tc_local[ch] = st_ivas->hTcBuffer->tc[ch] + st_ivas->hTcBuffer->n_samples_rendered; } + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { output_f_local[ch] = output[ch]; } + slot_size = st_ivas->hTcBuffer->n_samples_granularity; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_asked / slot_size ); + slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_granularity / slot_size ); first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; st_ivas->hTcBuffer->slots_rendered += slots_to_render; + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; @@ -186,22 +195,28 @@ void ObjRenderIVASSubframe( #endif /* Update the listener's location/orientation */ - TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, - st_ivas->hDecoderConfig->Opt_Headrotation, + TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? &st_ivas->hHeadTrackData->Quaternions[0] : NULL, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos : NULL ); if ( ( st_ivas->hRenderConfig != NULL ) && ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) ) { - ivas_reverb_process( st_ivas->hReverb, st_ivas->transport_config, 0, tc_local, p_reverb_signal, 0 ); + if ( ( error = ivas_reverb_process( st_ivas->hReverb, st_ivas->transport_config, 0, tc_local, p_reverb_signal, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } } /* Render subframe */ #ifdef FIX_356_ISM_METADATA_SYNC - TDREND_GetMix( st_ivas->hBinRendererTd, output_f_local, output_frame, 0, ism_md_subframe_update_jbm != subframe_idx ); + if ( ( error = TDREND_GetMix( st_ivas->hBinRendererTd, output_f_local, output_frame, 0, ism_md_subframe_update_jbm ) ) != IVAS_ERR_OK ) #else - TDREND_GetMix( st_ivas->hBinRendererTd, output_f_local, output_frame, 0 ); + if ( ( error = TDREND_GetMix( st_ivas->hBinRendererTd, output_f_local, output_frame, 0 ) ) != IVAS_ERR_OK ) #endif + { + return error; + } + if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ { if ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) @@ -211,16 +226,20 @@ void ObjRenderIVASSubframe( v_add( reverb_signal[1], output_f_local[1], output_f_local[1], output_frame ); } } + for ( ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++ ) { tc_local[ch] += output_frame; } + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { output_f_local[ch] += output_frame; } } + st_ivas->hTcBuffer->subframes_rendered = last_sf; - return; + + return IVAS_ERR_OK; } #endif diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 131f07090cd0386c986910002fa8b1d51dbe8800..7d14ee5041ad42eb604bd594911bfa2232b7ef0a 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -1145,7 +1145,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( void ivas_lssetupconversion_process_param_mc( Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ #ifdef JBM_TSM_ON_TCS - int16_t num_timeslots, + const int16_t num_timeslots, #endif float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c old mode 100644 new mode 100755 index ac8bb23541e85f11e8a6d506396d3f512ab4ef98..9918a80b8291e964bfa7809b095dd02558b3e332 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -125,6 +125,7 @@ ivas_error ivas_sba_dec_reconfigure( * Set SBA high-level parameters * Save old SBA high-level parameters *-----------------------------------------------------------------*/ + ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); nSCE_old = st_ivas->nSCE; @@ -133,6 +134,7 @@ ivas_error ivas_sba_dec_reconfigure( sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); + #ifdef JBM_TSM_ON_TCS /* save old */ if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) @@ -193,6 +195,7 @@ ivas_error ivas_sba_dec_reconfigure( hSpar = st_ivas->hSpar; st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); + #ifdef JBM_TSM_ON_TCS /* synchronize subframe info */ st_ivas->hSpar->num_slots = st_ivas->hTcBuffer->num_slots; @@ -201,6 +204,7 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); #endif + if ( st_ivas->nchan_transport == 1 ) { st_ivas->element_mode_init = IVAS_SCE; @@ -279,6 +283,7 @@ ivas_error ivas_sba_dec_reconfigure( { return error; } + #ifdef JBM_TSM_ON_TCS /* synchronize subframe info */ st_ivas->hDirAC->num_slots = st_ivas->hTcBuffer->num_slots; @@ -359,8 +364,9 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_TSM_ON_TCS /*-----------------------------------------------------------------* - * TC buffer + * JBM TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active == 1 ) { int16_t tc_nchan_to_allocate; @@ -402,10 +408,17 @@ ivas_error ivas_sba_dec_reconfigure( } } #endif + return error; } #ifdef JBM_TSM_ON_TCS +/*-------------------------------------------------------------------* + * ivas_sba_dec_digest_tc() + * + * + *-------------------------------------------------------------------*/ + ivas_error ivas_sba_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nCldfbSlots, /* i : number of CLDFB slots */ @@ -423,22 +436,27 @@ ivas_error ivas_sba_dec_digest_tc( { ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots ); } + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { ivas_spar_dec_digest_tc( st_ivas, st_ivas->nchan_transport, nCldfbSlots, nSamplesForRendering ); } + if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { int16_t nSamplesLeftForTD, default_frame; float *decorr_signal[BINAURAL_CHANNELS]; float *p_tc[2 * BINAURAL_CHANNELS]; + default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; + for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { decorr_signal[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx + BINAURAL_CHANNELS]; p_tc[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx]; } + while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); @@ -451,21 +469,30 @@ ivas_error ivas_sba_dec_digest_tc( nSamplesLeftForTD -= nSamplesToDecorr; } } + /* if we have a late CNG generation, do it here */ if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->sba_mode != SBA_MODE_SPAR ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna ); } + return error; } + +/*-------------------------------------------------------------------* + * ivas_sba_dec_render() + * + * + *-------------------------------------------------------------------*/ + void ivas_sba_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -477,7 +504,9 @@ void ivas_sba_dec_render( hSpar = st_ivas->hSpar; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + #ifdef DEBUGGING assert( hSpar ); #endif @@ -485,12 +514,15 @@ void ivas_sba_dec_render( { output_f_local[ch] = output_f[ch]; } + slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hSpar->num_slots - hSpar->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hSpar->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hSpar->subframe_nbslots[last_sf]; @@ -499,9 +531,11 @@ void ivas_sba_dec_render( #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { int16_t n_samples_sf = slot_size * hSpar->subframe_nbslots[subframe_idx]; + ivas_spar_dec_upmixer_sf( st_ivas, output_f_local, nchan_internal ); for ( ch = 0; ch < nchan_out; ch++ ) { @@ -513,6 +547,7 @@ void ivas_sba_dec_render( { ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); } + if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -524,6 +559,7 @@ void ivas_sba_dec_render( st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } } + *nSamplesAvailable = ( hSpar->num_slots - hSpar->slots_rendered ) * slot_size; return; diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 71a5718436251a496db1f5644969f05c6c1a7c6c..ed2915aacc677a3eea86d474bdc5c3a5f31ec0f9 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -92,6 +92,7 @@ void ivas_sba2mc_cldfb( g = hoa_dec_mtx[SBA_NHARM_HOA3 * n + m]; p_realOut = realOut[n]; p_imagOut = imagOut[n]; + #ifdef JBM_TSM_ON_TCS for ( iBlock = 0; iBlock < nb_timeslots; iBlock++ ) #else @@ -115,6 +116,7 @@ void ivas_sba2mc_cldfb( { p_realOut = realOut[n]; p_imagOut = imagOut[n]; + #ifdef JBM_TSM_ON_TCS for ( iBlock = 0; iBlock < nb_timeslots; iBlock++ ) #else @@ -429,7 +431,6 @@ void ivas_sba_upmixer_renderer( const int16_t output_frame /* i : output frame length */ ) { - int16_t nchan_internal; #ifndef JBM_TSM_ON_TCS int16_t i; @@ -462,10 +463,12 @@ void ivas_sba_upmixer_renderer( #ifdef JBM_TSM_ON_TCS float *output_f[MAX_OUTPUT_CHANNELS]; int16_t ch; + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { output_f[ch] = output[ch]; } + ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); #else ivas_sba_linear_renderer( output, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c old mode 100644 new mode 100755 index 0c1948a56cda70b7043e12ba6e72f8f1297f3afc..7609099b5f5862091f692fbf2a214087afe6c74a --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -193,6 +193,7 @@ ivas_error ivas_spar_dec_open( hSpar->subframes_rendered = 0; hSpar->slots_rendered = 0; hSpar->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; + /* init render timeslot mapping */ { int16_t map_idx; @@ -202,6 +203,7 @@ ivas_error ivas_spar_dec_open( hSpar->render_to_md_map[map_idx] = map_idx; } } + /* allocate transport channels*/ if ( st_ivas->hDecoderConfig->voip_active == 1 && st_ivas->hTcBuffer == NULL ) { @@ -1055,14 +1057,20 @@ static void ivas_spar_calc_smooth_facs( return; } + #ifdef JBM_TSM_ON_TCS +/*-------------------------------------------------------------------* + * ivas_spar_dec_agc_pca() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_agc_pca( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float output[][L_FRAME48k], /* i/o: input/output audio channels */ const int16_t output_frame /* i : output frame length */ ) { - int16_t nchan_transport; int16_t num_in_ingest; DECODER_CONFIG_HANDLE hDecoderConfig; @@ -1096,6 +1104,7 @@ void ivas_spar_dec_agc_pca( { num_in_ingest = nchan_transport; } + /*---------------------------------------------------------------------* * AGC *---------------------------------------------------------------------*/ @@ -1115,12 +1124,21 @@ void ivas_spar_dec_agc_pca( #endif } pop_wmops(); + return; } + +/*-------------------------------------------------------------------* + * ivas_spar_dec_set_render_map() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_set_render_map( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs ) + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +) { SPAR_DEC_HANDLE hSpar; @@ -1139,6 +1157,8 @@ void ivas_spar_dec_set_render_map( return; } + + /*-------------------------------------------------------------------* * ivas_spar_dec_upmixer() * @@ -1155,9 +1175,11 @@ void ivas_spar_dec_set_render_params( int16_t num_bands_out; hSpar = st_ivas->hSpar; + /*---------------------------------------------------------------------* * Gen umx mat *---------------------------------------------------------------------*/ + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi, @@ -1168,6 +1190,13 @@ void ivas_spar_dec_set_render_params( return; } + +/*-------------------------------------------------------------------* + * ivas_spar_dec_digest_tc() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nchan_transport, /* i : number of transport channels */ @@ -1185,11 +1214,13 @@ void ivas_spar_dec_digest_tc( float *p_tc[MAX_SPAR_INTERNAL_CHANNELS]; int16_t nchan_internal, ch; int16_t nSamplesLeftForTD, default_frame; + /* TD decorrelator */ default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + for ( ch = 0; ch < nchan_internal; ch++ ) { pPcm_tmp[ch] = Pcm_tmp[ch]; @@ -1199,6 +1230,7 @@ void ivas_spar_dec_digest_tc( while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); + ivas_td_decorr_process( hSpar->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr ); if ( hSpar->hTdDecorr->num_apd_outputs >= ( nchan_internal - nchan_transport ) ) { @@ -1222,16 +1254,23 @@ void ivas_spar_dec_digest_tc( { p_tc[ch] += nSamplesToDecorr; } + nSamplesLeftForTD -= nSamplesToDecorr; } } ivas_spar_dec_set_render_params( st_ivas, nCldfbSlots ); - return; } + +/*-------------------------------------------------------------------* + * ivas_spar_dec_upmixer() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_upmixer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float output[][L_FRAME48k], /* i/o: input/output audio channels */ @@ -1251,10 +1290,12 @@ void ivas_spar_dec_upmixer( nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n_samples_sf = JBM_CLDFB_SLOTS_IN_SUBFRAME * NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { output_f_local[n] = &output[n][0]; } + for ( n = 0; n < nchan_internal; n++ ) { st_ivas->hTcBuffer->tc[n] = output[n]; @@ -1263,10 +1304,12 @@ void ivas_spar_dec_upmixer( /*---------------------------------------------------------------------* * TD decorrelation *---------------------------------------------------------------------*/ + for ( i = 0; i < nchan_internal; i++ ) { pPcm_tmp[i] = Pcm_tmp[i]; } + if ( hSpar->hMdDec->td_decorr_flag ) { ivas_td_decorr_process( hSpar->hTdDecorr, st_ivas->hTcBuffer->tc, pPcm_tmp, output_frame ); @@ -1290,7 +1333,6 @@ void ivas_spar_dec_upmixer( } } - ivas_spar_dec_set_render_params( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); if ( st_ivas->hDirAC != 0 ) @@ -1306,10 +1348,12 @@ void ivas_spar_dec_upmixer( output_f_local[n] += n_samples_sf; } } + for ( n = 0; n < nchan_internal; n++ ) { st_ivas->hTcBuffer->tc[n] = NULL; } + if ( st_ivas->hDirAC != 0 ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -1321,6 +1365,7 @@ void ivas_spar_dec_upmixer( st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } } + return; } #endif @@ -1332,6 +1377,7 @@ void ivas_spar_dec_upmixer( * * IVAS SPAR upmixer *-------------------------------------------------------------------*/ + void ivas_spar_dec_upmixer_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *output[], /* o : output audio channels */ @@ -1683,6 +1729,7 @@ void ivas_spar_dec_upmixer( cldfb_in_ts_im[out_ch][ts][cldfb_band] = out_im[out_ch]; } } + #ifdef JBM_TSM_ON_TCS if ( ( ( slot_idx_start + ts + 1 ) == hSpar->num_slots ) || ( ( md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME ) != ( hSpar->render_to_md_map[ts + slot_idx_start + 1] / JBM_CLDFB_SLOTS_IN_SUBFRAME ) ) ) { @@ -1833,10 +1880,12 @@ void ivas_spar_dec_upmixer( #ifndef JBM_TSM_ON_TCS } #endif + #ifdef JBM_TSM_ON_TCS hSpar->slots_rendered += hSpar->subframe_nbslots[hSpar->subframes_rendered]; hSpar->subframes_rendered++; #endif + pop_wmops(); return; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index e3b97e632d771f81654c10a8aea4cd2264f05636..834ce32ab5221525f1719942de5fd3f90e432c39 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -440,6 +440,7 @@ typedef struct param_ism_rendering float *Cldfb_RealBuffer_tc; float *Cldfb_ImagBuffer_tc; #endif + } PARAM_ISM_RENDERING_DATA, *PARAM_ISM_RENDERING_HANDLE; @@ -1250,8 +1251,11 @@ typedef struct decoder_tc_buffer_structure int16_t slots_rendered; int16_t num_slots; int16_t n_samples_discard; /* number of samples to discard from the beginning of the output */ + } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; #endif + + /*----------------------------------------------------------------------------------* * * Main IVAS decoder structure @@ -1339,6 +1343,11 @@ typedef struct Decoder_Struct RENDER_CONFIG_DATA *hRenderConfig; /* Renderer config pointer */ int32_t binaural_latency_ns; /* Binauralization latency in ns */ +#ifdef JBM_TSM_ON_TCS + /* JBM module */ + DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM structure */ +#endif + #ifdef DEBUGGING int32_t noClipping; /* number of clipped samples */ #endif @@ -1346,10 +1355,6 @@ typedef struct Decoder_Struct int16_t ism_extmeta_active; /* Extended metadata active in decoder */ int16_t ism_extmeta_cnt; /* Change frame counter for extended metadata */ - -#ifdef JBM_TSM_ON_TCS - DECODER_TC_BUFFER_HANDLE hTcBuffer; -#endif } Decoder_Struct; /* clang-format on */ diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index c224b4cfbf011792e21bb1e621f096553d11dbbb..9742a01183753e39f0de9897f9821ad58ad7bbb4 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -412,7 +412,9 @@ bool apa_set_renderer_residual_samples( return 0; } -bool apa_set_evs_compat_mode( apa_state_t *ps, bool mode ) +bool apa_set_evs_compat_mode( + apa_state_t *ps, + bool mode ) { /* make sure pointer is valid */ if ( ps == NULL ) diff --git a/lib_dec/jbm_pcmdsp_fifo.c b/lib_dec/jbm_pcmdsp_fifo.c index fd0df04ca8efac158aade1d4d66085cd601da55c..108b069402b473d58ae07320601c881e52cad8c4 100644 --- a/lib_dec/jbm_pcmdsp_fifo.c +++ b/lib_dec/jbm_pcmdsp_fifo.c @@ -176,6 +176,7 @@ int16_t pcmdsp_fifo_write( } #ifdef JBM_TSM_ON_TCS +#ifdef DEBUGGING /* Writes the given audio data to the FIFO. */ int16_t pcmdsp_fifo_write_zero( PCMDSP_FIFO_HANDLE h, @@ -217,6 +218,7 @@ int16_t pcmdsp_fifo_write_zero( return 0; } #endif +#endif /* Reads the given number of audio samples from the FIFO. */ int16_t pcmdsp_fifo_read( diff --git a/lib_dec/jbm_pcmdsp_fifo.h b/lib_dec/jbm_pcmdsp_fifo.h index e6c64dc9e8e7b5cbeaa1c51f3f1ecda1cdc1f434..d16bd2b8d25439384c73cebf450fabc16c247f53 100644 --- a/lib_dec/jbm_pcmdsp_fifo.h +++ b/lib_dec/jbm_pcmdsp_fifo.h @@ -73,9 +73,12 @@ void pcmdsp_fifo_destroy( PCMDSP_FIFO_HANDLE *ph ); ivas_error pcmdsp_fifo_init( PCMDSP_FIFO_HANDLE h, uint16_t nSamplesPerChannel, uint16_t nChannels, uint16_t nBytesPerSample ); int16_t pcmdsp_fifo_write( PCMDSP_FIFO_HANDLE h, const uint8_t *samples, uint16_t nSamplesPerChannel ); + #ifdef JBM_TSM_ON_TCS +#ifdef DEBUGGING int16_t pcmdsp_fifo_write_zero( PCMDSP_FIFO_HANDLE h, uint16_t nSamplesPerChannel ); #endif +#endif int16_t pcmdsp_fifo_read( PCMDSP_FIFO_HANDLE h, uint16_t nSamplesPerChannel, uint8_t *samples ); diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 6e26744341e6bce7869ae2dc8a97d838465cabc0..20429118336c7ce4b4251990527e34ddd837fe24 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -63,7 +63,7 @@ struct IVAS_DEC_VOIP JB4_DATAUNIT_HANDLE hCurrentDataUnit; /* Points to the currently processed data unit */ uint16_t *bs_conversion_buf; /* Buffer for bitstream conversion from packed to serial */ #ifdef VARIABLE_SPEED_DECODING - uint8_t mode; + IVAS_DEC_VOIP_MODE voipMode; uint16_t speedFac; bool needNewFrame; #endif @@ -128,6 +128,7 @@ static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferG static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, int16_t *nOutSamples ); static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *pcmBuf ); static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, int16_t *pcmBuf ); +static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, int16_t *nSamplesBuffered ); #endif /*---------------------------------------------------------------------* @@ -538,8 +539,8 @@ ivas_error IVAS_DEC_Configure( ivas_error IVAS_DEC_EnableVoIP( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef VARIABLE_SPEED_DECODING - const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or varable speed */ - const uint16_t speedFac, /* i : speed factor for varable speed */ + const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or variable speed */ + const uint16_t speedFac, /* i : speed factor for variable speed */ #endif const int16_t jbmSafetyMargin, /* i : allowed delay reserve for JBM, in milliseconds */ const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ @@ -560,11 +561,9 @@ ivas_error IVAS_DEC_EnableVoIP( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; hIvasDec->Opt_VOIP = 1; - #ifdef JBM_TSM_ON_TCS hDecoderConfig->voip_active = 1; #endif @@ -585,7 +584,6 @@ ivas_error IVAS_DEC_EnableVoIP( #endif #endif - #ifndef JBM_TSM_ON_TCS assert( hDecoderConfig->nchan_out > 0 && "EXT output not yet supported in VoIP mode" ); #endif @@ -603,7 +601,7 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->lastDecodedWasActive = 0; hIvasDec->hVoIP->hCurrentDataUnit = NULL; #ifdef VARIABLE_SPEED_DECODING - hIvasDec->hVoIP->mode = voipMode; + hIvasDec->hVoIP->voipMode = voipMode; hIvasDec->hVoIP->speedFac = speedFac; hIvasDec->hVoIP->needNewFrame = false; #endif @@ -615,6 +613,7 @@ ivas_error IVAS_DEC_EnableVoIP( #else hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs * hDecoderConfig->nchan_out / FRAMES_PER_SEC ); #endif + #ifdef JBM_TSM_ON_TCS /* postpone init of the buffers until we know the real number of TCs*/ hIvasDec->hVoIP->apaExecBuffer = NULL; @@ -641,7 +640,7 @@ ivas_error IVAS_DEC_EnableVoIP( /* initialize JBM */ #ifdef VARIABLE_SPEED_DECODING hIvasDec->hVoIP->hJBM = NULL; - if ( hIvasDec->hVoIP->mode == IVAS_DEC_VOIP_MODE_VOIP ) + if ( hIvasDec->hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VOIP ) { #endif if ( ( error = JB4_Create( &hIvasDec->hVoIP->hJBM ) != IVAS_ERR_OK ) != IVAS_ERR_OK ) @@ -683,13 +682,10 @@ ivas_error IVAS_DEC_EnableVoIP( #endif #ifdef JBM_TSM_ON_TCS - - /* postpone init of time scaler until we know the real number of TCs */ + /* postpone init of time scaler and output FIFO until we know the real number of TCs */ hIvasDec->hVoIP->hTimeScaler = NULL; - /* create output pcm fifo*/ - /* :TODO: also provide CLDFB output FIFO if things work out */ #ifdef VARIABLE_SPEED_DECODING - if ( hIvasDec->hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) + if ( hIvasDec->hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) { hIvasDec->hVoIP->needNewFrame = true; } @@ -813,7 +809,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( } #ifdef VARIABLE_SPEED_DECODING - if ( hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) + if ( hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) { hIvasDec->hVoIP->needNewFrame = false; } @@ -924,6 +920,7 @@ static ivas_error IVAS_DEC_Setup( Decoder_Struct *st_ivas; st_ivas = hIvasDec->st_ivas; + /*----------------------------------------------------------------* * IVAS decoder setup * - read IVAS format signaling @@ -948,6 +945,7 @@ static ivas_error IVAS_DEC_Setup( return error; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetTcSamples( ) * @@ -1068,6 +1066,25 @@ ivas_error IVAS_DEC_GetRenderedSamples( } + return error; +} + +ivas_error IVAS_DEC_GetBufferedNumberOfSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o : IVAS decoder handle */ + int16_t *nSamplesBuffered /* o : number of samples still buffered */ +) +{ + ivas_error error; + error = IVAS_ERR_OK; + + *nSamplesBuffered = 0; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *nSamplesBuffered = hIvasDec->st_ivas->hTcBuffer->n_samples_buffered - hIvasDec->st_ivas->hTcBuffer->n_samples_rendered; + return error; } #endif @@ -1797,6 +1814,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( } #ifdef VARIABLE_SPEED_DECODING +#ifdef DEBUGGING /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_SetScale( ) * @@ -1817,6 +1835,7 @@ ivas_error IVAS_DEC_VoIP_SetScale( return error; } #endif +#endif /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_GetSamples( ) @@ -1877,7 +1896,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( maxScaling = hVoIP->speedFac; #endif - /* TODO(mcjbm): ringbuffer capacity should be configurable by user */ #ifdef JBM_TSM_ON_TCS if ( ( hVoIP->hFifoOut != NULL && nSamplesPerChannel > hVoIP->hFifoOut->capacity ) || nSamplesPerChannel == 0 ) #else @@ -1894,14 +1912,17 @@ ivas_error IVAS_DEC_VoIP_GetSamples( while ( pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoAfterTimeScaler ) < nSamplesPerChannel ) #endif { +#ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING - if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->needNewFrame ) + if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->needNewFrame ) { /* we need another bs frame fed into the decoder...*/ *sampleAvailableNext = 0; return IVAS_ERR_VS_FRAME_NEEDED; } #endif +#endif + #ifdef JBM_TSM_ON_TCS if ( hVoIP->nSamplesAvailableNext == 0 ) { @@ -1912,7 +1933,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } else { - extBufferedSamples = nSamplesRendered; /* TODO: JBM use renderer residual samples here */ + int16_t nSamplesBuffered; + nSamplesBuffered = 0; + if ( hIvasDec->hasBeenFedFirstGoodFrame ) + { + IVAS_DEC_GetBufferedNumberOfSamples( hIvasDec, &nSamplesBuffered ); + } + extBufferedSamples = nSamplesRendered + nSamplesBuffered; } #else extBufferedSamples = pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoAfterTimeScaler ); @@ -1920,8 +1947,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( extBufferedTime_ms = extBufferedSamples * 1000 / hDecoderConfig->output_Fs; dataUnit = NULL; + #ifdef VARIABLE_SPEED_DECODING - if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VOIP ) + if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VOIP ) { #endif /* pop one access unit from the jitter buffer */ @@ -1932,7 +1960,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } #ifdef VARIABLE_SPEED_DECODING } - else if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) + else if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) { scale = hVoIP->speedFac; maxScaling = hVoIP->speedFac; @@ -1960,7 +1988,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } #ifdef VARIABLE_SPEED_DECODING - if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VOIP ) + if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VOIP ) { #endif /* copy bitstream into decoder state */ @@ -1979,6 +2007,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef VARIABLE_SPEED_DECODING } #endif + /* decode */ if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { @@ -1987,11 +2016,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( nSamplesTcsScaled = hVoIP->nSamplesFrame; if ( hVoIP->hFifoOut != NULL ) { +#ifdef DEBUGGING /* feed zeros to FIFO */ if ( pcmdsp_fifo_write_zero( hVoIP->hFifoOut, nSamplesTcsScaled ) != 0 ) { return IVAS_ERR_UNKNOWN; } +#endif } else { @@ -2009,6 +2040,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef JBM_TSM_ON_TCS uint16_t l_ts = 1; uint16_t nSamplesRendered_loop; + /* setup ivas decoder and get the number of TCs */ /* might render some remaining samples from the previous frame too if the renderer granularity changed */ if ( hVoIP->hFifoOut ) @@ -2030,11 +2062,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return error; } } + nSamplesRendered += nSamplesRendered_loop; if ( nTransportChannels != hVoIP->nTransportChannelsOld ) { IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ); } + /* decode TCs only */ if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hVoIP->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { @@ -2050,7 +2084,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } #ifdef VARIABLE_SPEED_DECODING - if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VOIP ) + if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VOIP ) { #endif if ( dataUnit ) @@ -2073,6 +2107,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hVoIP->lastDecodedWasActive = 1; } #endif + /* limit scale to range supported by time scaler */ if ( scale < APA_MIN_SCALE ) { @@ -2128,10 +2163,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { /* render IVAS frames */ int16_t nResidualSamples; + if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hVoIP->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; } + /* feed residual samples to TSM for the next call */ if ( apa_set_renderer_residual_samples( hVoIP->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) { @@ -2169,6 +2206,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #endif #ifdef JBM_TSM_ON_TCS } + if ( hIvasDec->hasBeenFedFirstGoodFrame && hVoIP->rendererType != JBM_RENDERER_NONE ) { uint16_t nSamplesRendered_loop; @@ -2176,12 +2214,15 @@ ivas_error IVAS_DEC_VoIP_GetSamples( if ( hVoIP->hFifoOut ) { int16_t rendererPcmBuf[( MAX_OUTPUT_CHANNELS * L_FRAME_MAX * APA_MAX_SCALE ) / 100]; + nSamplesToRender = nSamplesPerChannel - pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoOut ); + /* render IVAS frames */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hVoIP->nSamplesAvailableNext, rendererPcmBuf ) ) != IVAS_ERR_OK ) { return error; } + if ( pcmdsp_fifo_write( hVoIP->hFifoOut, (uint8_t *) rendererPcmBuf, nSamplesRendered_loop ) != 0 ) { return IVAS_ERR_UNKNOWN; @@ -2190,15 +2231,18 @@ ivas_error IVAS_DEC_VoIP_GetSamples( else { nSamplesToRender = nSamplesPerChannel - nSamplesRendered; + /* render IVAS frames directly to the output buffer */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hVoIP->nSamplesAvailableNext, pcmBuf + nSamplesRendered * nOutChannels ) ) != IVAS_ERR_OK ) { return error; } } + nSamplesRendered += nSamplesRendered_loop; + #ifdef VARIABLE_SPEED_DECODING - if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext == 0 ) + if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext == 0 ) { hVoIP->needNewFrame = true; } @@ -2211,12 +2255,14 @@ ivas_error IVAS_DEC_VoIP_GetSamples( else { hVoIP->nSamplesAvailableNext = max( 0, pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoOut ) - nSamplesPerChannel ); + #ifdef VARIABLE_SPEED_DECODING - if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext < nSamplesPerChannel ) + if ( hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext < nSamplesPerChannel ) { hVoIP->needNewFrame = true; } #endif + hVoIP->nSamplesAvailableNext = 0; } #endif @@ -2265,11 +2311,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #if defined( VARIABLE_SPEED_DECODING ) || defined( JBM_TSM_ON_TCS ) ivas_error IVAS_DEC_VoIP_Flush( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ int16_t *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 */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ - int16_t *nSamplesFlushed /* o : number of samples flushed */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ + int16_t *nSamplesFlushed /* o : number of samples flushed */ ) { ivas_error error; @@ -2279,6 +2325,7 @@ ivas_error IVAS_DEC_VoIP_Flush( uint16_t nSamplesToRender; uint16_t nSamplesFlushedLocal; #endif + error = IVAS_ERR_OK; hVoIP = hIvasDec->hVoIP; @@ -2287,6 +2334,7 @@ ivas_error IVAS_DEC_VoIP_Flush( #else *nSamplesFlushed = min( nSamplesPerChannel, pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoAfterTimeScaler ) ); #endif + #ifdef JBM_TSM_ON_TCS if ( hVoIP->rendererType == JBM_RENDERER_NONE ) { @@ -2310,25 +2358,28 @@ ivas_error IVAS_DEC_VoIP_Flush( } else { - nSamplesToRender = (uint16_t) *nSamplesFlushed; /* render IVAS frames */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hVoIP->nSamplesAvailableNext, rendererPcmBuf ) ) != IVAS_ERR_OK ) { return error; } + if ( pcmdsp_fifo_write( hVoIP->hFifoOut, (uint8_t *) rendererPcmBuf, nSamplesFlushedLocal ) != 0 ) { return IVAS_ERR_UNKNOWN; } + if ( pcmdsp_fifo_read( hVoIP->hFifoOut, nSamplesFlushedLocal, (uint8_t *) pcmBuf ) != 0 ) { return IVAS_ERR_UNKNOWN; } + *nSamplesAvailableNext = hVoIP->nSamplesAvailableNext; *nSamplesFlushed = (int16_t) nSamplesFlushedLocal; } #endif + return error; } #endif @@ -2344,7 +2395,7 @@ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ #ifdef JBM_TSM_ON_TCS , - int16_t nSamplesAsked + const int16_t nSamplesAsked #endif ) { @@ -2398,6 +2449,7 @@ static void IVAS_DEC_Close_VoIP( #else pcmdsp_fifo_destroy( &hVoIP->hFifoAfterTimeScaler ); #endif + if ( hVoIP->apaExecBuffer != NULL ) { free( hVoIP->apaExecBuffer ); @@ -2624,7 +2676,7 @@ static ivas_error printConfigInfo_dec( } /*-----------------------------------------------------------------* - * Print number of output configuration + * Print output configuration *-----------------------------------------------------------------*/ if ( st_ivas->ivas_format == MONO_FORMAT ) @@ -2743,6 +2795,17 @@ static ivas_error printConfigInfo_dec( } } +#ifdef JBM_TSM_ON_TCS + /*-----------------------------------------------------------------* + * Print VoIP mode info + *-----------------------------------------------------------------*/ + + if ( st_ivas->hDecoderConfig->voip_active ) + { + fprintf( stdout, "VoIP mode: ON\n" ); + } +#endif + return IVAS_ERR_OK; } @@ -2932,7 +2995,6 @@ static ivas_error evs_dec_main( int16_t pcm_buf_local[L_FRAME48k]; #endif - /* convert 'float' output data to 'short' */ #ifdef DEBUGGING st_ivas->noClipping += @@ -2954,6 +3016,7 @@ static ivas_error evs_dec_main( #ifdef JBM_TSM_ON_TCS } #endif + return error; } @@ -3145,14 +3208,30 @@ static ivas_error input_format_API_to_internal( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS -static int16_t IVAS_DEC_VoIP_GetRenderGranularity( Decoder_Struct *st_ivas ) +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_GetRenderGranularity() + * + * + *---------------------------------------------------------------------*/ + +static int16_t IVAS_DEC_VoIP_GetRenderGranularity( + Decoder_Struct *st_ivas ) { return st_ivas->hTcBuffer->n_samples_granularity; } -static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( IVAS_DEC_HANDLE hIvasDec ) + +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_GetRendererConfig() + * + * + *---------------------------------------------------------------------*/ + +static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( + IVAS_DEC_HANDLE hIvasDec ) { JBM_RENDERER_TYPE rendererType; rendererType = JBM_RENDERER_NONE; @@ -3169,13 +3248,22 @@ static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( IVAS_DEC_HANDLE hIvasD return rendererType; } -ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ) + +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_reconfigure() + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_VoIP_reconfigure( + IVAS_DEC_HANDLE hIvasDec, + const uint16_t nTransportChannels, + const uint16_t l_ts ) { IVAS_DEC_VOIP *hVoIP; ivas_error error; - hVoIP = hIvasDec->hVoIP; if ( hIvasDec->hVoIP->hTimeScaler == NULL ) @@ -3186,10 +3274,11 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n DECODER_CONFIG_HANDLE hDecoderConfig; #ifdef VARIABLE_SPEED_DECODING - startQuality = hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ? -2.0f : 1.0f; + startQuality = hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ? -2.0f : 1.0f; #else startQuality = 1.0f; #endif + /* get current renderer type*/ hVoIP->rendererType = IVAS_DEC_VoIP_GetRendererConfig( hIvasDec ); hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; @@ -3217,12 +3306,13 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n { return IVAS_ERR_INIT_ERROR; } - hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ); - set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); - if ( hIvasDec->hVoIP->apaExecBuffer == NULL ) + + if ( ( hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } + set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); + if ( apa_init( &hIvasDec->hVoIP->hTimeScaler, nTransportChannels ) != IVAS_ERR_OK || apa_set_rate( hIvasDec->hVoIP->hTimeScaler, hDecoderConfig->output_Fs ) != 0 || @@ -3232,6 +3322,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n { return IVAS_ERR_INIT_ERROR; } + if ( hVoIP->hFifoOut == NULL && hVoIP->rendererType == JBM_RENDERER_NONE ) { /* we still need the FIFO out buffer */ @@ -3242,7 +3333,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n } } #ifdef VARIABLE_SPEED_DECODING - else if ( hIvasDec->hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) + else if ( hIvasDec->hVoIP->voipMode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED ) { if ( pcmdsp_fifo_create( &hIvasDec->hVoIP->hFifoOut ) != 0 || pcmdsp_fifo_init( hIvasDec->hVoIP->hFifoOut, (uint16_t) ( hDecoderConfig->output_Fs * 4 / FRAMES_PER_SEC ) /* 4 frames */, hDecoderConfig->nchan_out, sizeof( int16_t ) ) != 0 ) @@ -3251,6 +3342,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n } } #endif + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { if ( apa_set_evs_compat_mode( hIvasDec->hVoIP->hTimeScaler, true ) != 0 ) @@ -3268,12 +3360,11 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n /* realloc apa_exe_buffer */ free( hIvasDec->hVoIP->apaExecBuffer ); - hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ); - set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); - if ( hIvasDec->hVoIP->apaExecBuffer == NULL ) + if ( ( hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } + set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); } hIvasDec->hVoIP->nTransportChannelsOld = (uint8_t) nTransportChannels; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index d8418916e2210cedebf872262bf2f21803144eae..0539d75188f6e5478e51dac2e26d177369ee6f3a 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -227,12 +227,14 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( ); #ifdef VARIABLE_SPEED_DECODING +#ifdef DEBUGGING /*! r: error code */ ivas_error IVAS_DEC_VoIP_SetScale( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t scale /* i : TSM scale to set */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t scale /* i : TSM scale to set */ ); #endif +#endif /*! r: error code */ ivas_error IVAS_DEC_VoIP_GetSamples( @@ -242,7 +244,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( const uint32_t systemTimestamp_ms /* i : current system timestamp */ #if defined( JBM_TSM_ON_TCS ) || defined(VARIABLE_SPEED_DECODING ) , - uint16_t *sampleAvailableNext /* o : samples available for the next call */ + uint16_t *sampleAvailableNext /* o : samples available for the next call */ #endif #ifdef SUPPORT_JBM_TRACEFILE , JbmTraceFileWriterFn jbmWriterFn, @@ -252,11 +254,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #if defined( JBM_TSM_ON_TCS ) || defined(VARIABLE_SPEED_DECODING ) ivas_error IVAS_DEC_VoIP_Flush( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - int16_t *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 */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ - int16_t *nSamplesFlushed /* o : number of samples flushed */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + int16_t *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 */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ + int16_t *nSamplesFlushed /* o : number of samples flushed */ ); #endif @@ -266,8 +268,8 @@ ivas_error IVAS_DEC_VoIP_Flush( ivas_error IVAS_DEC_EnableVoIP( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef VARIABLE_SPEED_DECODING - const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or varable speed */ - const uint16_t speedFac, /* i : speed factor for varable speed */ + const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or variable speed */ + const uint16_t speedFac, /* i : speed factor for variable speed */ #endif const int16_t jbmSafetyMargin, /* i : allowed delay reserve for JBM, in milliseconds */ const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ @@ -386,7 +388,7 @@ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ #ifdef JBM_TSM_ON_TCS , - int16_t nSamplesAsked + const int16_t nSamplesAsked #endif ); diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 12efe39c5b7d5800f4f859fd3fcd272d52996123..76af4a17c8755e4a6bdccfbe435c0524e304fa4a 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1507,12 +1507,14 @@ ivas_error ivas_rend_crendProcess( output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; + #ifdef JBM_TSM_ON_TCS for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { p_pcm_tmp[i] = pcm_tmp[i]; } #endif + for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { if ( hDecoderConfig && hDecoderConfig->Opt_Headrotation && hHeadTrackData && hHeadTrackData->num_quaternions >= 0 ) @@ -1574,20 +1576,28 @@ ivas_error ivas_rend_crendProcess( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS +/*-----------------------------------------------------------------------------------------* + * Function ivas_rend_crendProcessSubframe() + * + * + *-----------------------------------------------------------------------------------------*/ + ivas_error ivas_rend_crendProcessSubframe( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - DECODER_TC_BUFFER_HANDLE hTcBuffer, - float *input_f[], - float *output[], /* i/o: input/output audio channels */ - const int16_t n_samples_to_render, - const int32_t output_Fs ) + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : Head tracking data structure */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + float *input_f[], /* i : transport channels */ + float *output[], /* i/o: input/output audio channels */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int32_t output_Fs /* i : output sampling rate */ +) { int16_t subframe_idx, subframe_len; int16_t nchan_out, nchan_in, ch, first_sf, last_sf, slot_size, slots_to_render; @@ -1607,10 +1617,12 @@ ivas_error ivas_rend_crendProcessSubframe( in_config = getIvasAudioConfigFromRendAudioConfig( inRendConfig ); inConfigType = getAudioConfigType( inRendConfig ); + if ( ( error = getAudioConfigNumChannels( outRendConfig, &nchan_out ) ) != IVAS_ERR_OK ) { return error; } + if ( ( error = getAudioConfigNumChannels( inRendConfig, &nchan_in ) ) != IVAS_ERR_OK ) { return error; @@ -1620,17 +1632,20 @@ ivas_error ivas_rend_crendProcessSubframe( { tc_local[ch] = input_f[ch]; } + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { p_pcm_tmp[ch] = pcm_tmp[ch]; } slot_size = hTcBuffer->n_samples_granularity; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hTcBuffer->num_slots - hTcBuffer->slots_rendered, n_samples_to_render / slot_size ); first_sf = hTcBuffer->subframes_rendered; last_sf = first_sf; hTcBuffer->slots_rendered += slots_to_render; + while ( slots_to_render > 0 ) { slots_to_render -= hTcBuffer->subframe_nbslots[last_sf]; @@ -1640,9 +1655,9 @@ ivas_error ivas_rend_crendProcessSubframe( for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { subframe_len = hTcBuffer->subframe_nbslots[subframe_idx] * hTcBuffer->n_samples_granularity; + if ( hDecoderConfig && hDecoderConfig->Opt_Headrotation && hHeadTrackData && hHeadTrackData->num_quaternions >= 0 ) { - /* Rotation in SHD for: MC with elevation (5_1_2 / 5_1_4 / 7_1_4) -> BINAURAL SBA SPAR -> BINAURAL or BINAURAL_ROOM @@ -1693,7 +1708,6 @@ ivas_error ivas_rend_crendProcessSubframe( mvr2r( pcm_tmp[ch], output[ch], n_samples_to_render ); } - hTcBuffer->subframes_rendered = last_sf; pop_wmops(); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index f19e0dbf1a4657f63f4961b27c21c6a6d10dbc47..525935ffbf13fa8036829a62506c58f960bbd608 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -93,7 +93,6 @@ static void adaptTransportSignalsHeadtracked( HEAD_TRACK_DATA_HANDLE hHeadTrackD static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( HEAD_TRACK_DATA_HANDLE hHeadTrackData, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nBins, float Rmat[3][3] ); #endif - static void formulate2x2MixingMatrix( float Ein1, float Ein2, float CinRe, float CinIm, float Eout1, float Eout2, float CoutRe, float CoutIm, float Q[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Mre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Mim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], const float regularizationFactor ); static void hrtfShGetHrtf( const int16_t bin, const int16_t aziDeg, const int16_t eleDeg, float *lRealp, float *lImagp, float *rRealp, float *rImagp ); @@ -105,8 +104,6 @@ static void matrixMul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Ai static void matrixTransp2Mul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] ); -#ifdef JBM_TSM_ON_TCS -#endif /*------------------------------------------------------------------------- * ivas_dirac_dec_init_binaural_data() * @@ -249,8 +246,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } - -#endif /* JBM_TMS_ON_TCS*/ +#endif return IVAS_ERR_OK; } @@ -330,14 +326,21 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS +/*------------------------------------------------------------------------- + * void ivas_dirac_dec_binaural_render() + * + * + *------------------------------------------------------------------------*/ + void ivas_dirac_dec_binaural_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - const int16_t nchan_transport, - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -356,16 +359,19 @@ void ivas_dirac_dec_binaural_render( output_f_local[ch] = output_f[ch]; } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hDirAC->num_slots - hDirAC->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hDirAC->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hDirAC->subframe_nbslots[last_sf]; last_sf++; } + #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif @@ -378,16 +384,19 @@ void ivas_dirac_dec_binaural_render( output_f_local[ch] += n_samples_sf; } } + if ( hDirAC->slots_rendered == hDirAC->num_slots ) { st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } + *nSamplesAvailable = ( hDirAC->num_slots - hDirAC->slots_rendered ) * slot_size; return; } #endif + /*------------------------------------------------------------------------- * ivas_dirac_dec_binaural() * @@ -428,7 +437,6 @@ void ivas_dirac_dec_binaural( { ivas_spar_dec_set_render_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); } - #endif if ( st_ivas->hDiracDecBin->useTdDecorr ) @@ -447,14 +455,15 @@ void ivas_dirac_dec_binaural( #endif } output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + #ifdef JBM_TSM_ON_TCS - { - ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); - } + ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); + #else ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, output_f, decorr_signal, output_frame ); #endif } + #ifdef JBM_TSM_ON_TCS if ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) { @@ -468,7 +477,9 @@ void ivas_dirac_dec_binaural( { #ifdef JBM_TSM_ON_TCS int16_t n_samples_sf = slot_size * st_ivas->hDirAC->subframe_nbslots[subframe]; + ivas_dirac_dec_binaural_internal( st_ivas, p_output, nchan_transport, subframe ); + for ( ch = 0; ch < 2 * BINAURAL_CHANNELS; ch++ ) { p_output[ch] += n_samples_sf; @@ -478,12 +489,14 @@ void ivas_dirac_dec_binaural( ivas_dirac_dec_binaural_internal( st_ivas, output_f, nchan_transport, subframe ); #endif } + #ifdef JBM_TSM_ON_TCS for ( ch = 0; ch < 2 * BINAURAL_CHANNELS; ch++ ) { st_ivas->hTcBuffer->tc[ch] = NULL; } #endif + return; } @@ -491,8 +504,7 @@ void ivas_dirac_dec_binaural( /*------------------------------------------------------------------------- * Local functions *------------------------------------------------------------------------*/ -#ifdef JBM_TSM_ON_TCS -#endif + static void ivas_dirac_dec_binaural_internal( Decoder_Struct *st_ivas, @@ -1355,8 +1367,6 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices( return; } -#ifdef JBM_TSM_ON_TCS -#endif static void ivas_dirac_dec_binaural_process_output( Decoder_Struct *st_ivas, @@ -1492,8 +1502,6 @@ static void ivas_dirac_dec_binaural_process_output( return; } -#ifdef JBM_TSM_ON_TCS -#endif static void adaptTransportSignalsHeadtracked( HEAD_TRACK_DATA_HANDLE hHeadTrackData, diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index b6427949a0acce5a3f017352d36f3a875263df05..2f5b406c66cedfe26113c93f8d5214f1c45cbe53 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -344,7 +344,6 @@ ivas_error ivas_td_binaural_renderer_unwrap( } } - if ( hReverb != NULL && hReverb->pConfig.roomAcoustics.late_reverb_on ) { /* add reverb to rendered signals */ @@ -490,7 +489,7 @@ void TDREND_Update_object_positions( #ifndef FIX_356_ISM_METADATA_SYNC , #ifdef JBM_TSM_ON_TCS - float *output[] + float *output[] /* i/o: SCE/MC channels */ #else float output[][L_FRAME48k] /* i/o: SCE/MC channels */ #endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index de652e6f984a32beba9a91d5836e7dfe92d3cfb0..d87324cca3232dec15235d8dab6610671468952c 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -161,12 +161,12 @@ void ivas_dirac_dec_binaural( #ifdef JBM_TSM_ON_TCS void ivas_dirac_dec_binaural_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - const int16_t nchan_transport, - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ); #endif @@ -240,7 +240,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( const int16_t ism_md_subframe_update, #endif #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: SCE channels / Binaural synthesis */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ #else float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ #endif @@ -527,7 +527,8 @@ void ivas_rend_closeCrend( CREND_WRAPPER_HANDLE *pCrend ); ivas_error ivas_rend_initCrendWrapper( - CREND_WRAPPER_HANDLE *pCrend ); + CREND_WRAPPER_HANDLE *pCrend +); ivas_error ivas_rend_crendProcess( const CREND_WRAPPER *pCrend, @@ -538,7 +539,7 @@ ivas_error ivas_rend_crendProcess( IVAS_OUTPUT_SETUP_HANDLE hIntSetup, EFAP_HANDLE hEFAPdata, #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: input/output audio channels */ + float *output[], /* i/o: input/output audio channels */ #else float output[][L_FRAME48k], /* i/o: input/output audio channels */ #endif @@ -547,18 +548,19 @@ ivas_error ivas_rend_crendProcess( #ifdef JBM_TSM_ON_TCS ivas_error ivas_rend_crendProcessSubframe( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - DECODER_TC_BUFFER_HANDLE hTcBuffer, - float *input_f[], - float *output[], /* i/o: input/output audio channels */ - const int16_t n_samples_to_render, - const int32_t output_Fs ); + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : Head tracking data structure */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + float *input_f[], /* i : transport channels */ + float *output[], /* i/o: input/output audio channels */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int32_t output_Fs /* i : output sampling rate */ +); #endif @@ -631,8 +633,8 @@ ivas_error ivas_reverb_process( const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const int16_t mix_signals, /* i : add reverb to output signal */ #ifdef JBM_TSM_ON_TCS - float *pcm_in[], /* i : the PCM audio to apply reverb on */ - float *pcm_out[], /* o : the PCM audio with reverb applied */ + float *pcm_in[], /* i : the PCM audio to apply reverb on */ + float *pcm_out[], /* o : the PCM audio with reverb applied */ #else float pcm_in[][L_FRAME48k], /* i : the PCM audio to apply reverb on */ float pcm_out[][L_FRAME48k], /* o : the PCM audio with reverb applied */ @@ -872,7 +874,7 @@ void rotateFrame_shd( void rotateFrame_sd( HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: unrotated SD signal buffer in TD */ + float *output[], /* i/o: unrotated SD signal buffer in TD */ #else float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */ #endif @@ -888,7 +890,7 @@ void rotateFrame_shd_cldfb( float Rmat[3][3], /* i : real-space rotation matrix */ const int16_t nInChannels, /* i : number of channels */ #ifdef JBM_TSM_ON_TCS - const int16_t numTimeSlots, /* i : number of time slots to process */ + const int16_t numTimeSlots, /* i : number of time slots to process */ #endif const int16_t shd_rot_max_order /* i : split-order rotation method */ ); diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 6809cdee2bcf9869dbe8918d5bb820746c242f29..79ef75e4708d8f98c845e55b9afc33f9376da4aa 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -500,7 +500,7 @@ void rotateFrame_shd_cldfb( float Rmat[3][3], /* i : real-space rotation matrix */ const int16_t nInChannels, /* i : number of channels */ #ifdef JBM_TSM_ON_TCS - const int16_t numTimeSlots, + const int16_t numTimeSlots, /* i : number of time slots to process */ #endif const int16_t shd_rot_max_order /* i : split-order rotation method */ ) diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index eeeb505dea009192cd800ae5acbc8ceb3026e320..059cd847e1a44782cf226dafafa90a65043666ca 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -50,158 +50,6 @@ * Render prototype audio signals using SBA mixing matrices *-------------------------------------------------------------------*/ -#ifdef JBM_TSM_ON_TCS -void ivas_sba_prototype_renderer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - float inIm[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* i : Input audio in CLDFB domain, imag */ -) -{ - float mixer_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; - SPAR_DEC_HANDLE hSpar; - DECODER_CONFIG_HANDLE hDecoderConfig; - int16_t num_spar_bands, spar_band; - int16_t b, ts; - int16_t num_cldfb_bands, numch_in, numch_out; - int16_t cldfb_band; - int16_t out_ch, in_ch; - int16_t firstInCh, inChEnd, firstOutCh, outChEnd; - int16_t slot_idx_start; - - push_wmops( "ivas_sba_prototype_renderer" ); - - hSpar = st_ivas->hSpar; - hDecoderConfig = st_ivas->hDecoderConfig; - num_spar_bands = hSpar->hFbMixer->pFb->filterbank_num_bands; - - num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands; - numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; - numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; - - if ( st_ivas->nchan_transport == 1 ) - { - firstInCh = 0; - inChEnd = 1; - firstOutCh = 0; - outChEnd = 1; - } - else /* 2 TC */ - { - firstInCh = 0; - inChEnd = 2; - firstOutCh = 1; - outChEnd = 2; - } - slot_idx_start = hSpar->slots_rendered; - /* Apply mixing matrix */ - for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) - { - int16_t md_idx = hSpar->render_to_md_map[ts + slot_idx_start]; - /* determine SPAR parameters for this time slot */ - ivas_spar_get_parameters( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat ); - - for ( cldfb_band = 0; cldfb_band < num_cldfb_bands; cldfb_band++ ) - { - float out_re[IVAS_SPAR_MAX_CH]; - float out_im[IVAS_SPAR_MAX_CH]; - float cldfb_par; - ivas_fb_bin_to_band_data_t *bin2band = &hSpar->hFbMixer->pFb->fb_bin_to_band; - - for ( out_ch = firstOutCh; out_ch < outChEnd; out_ch++ ) - { - out_re[out_ch] = 0.0f; - out_im[out_ch] = 0.0f; - - for ( in_ch = firstInCh; in_ch < inChEnd; in_ch++ ) - { - if ( cldfb_band < CLDFB_PAR_WEIGHT_START_BAND ) /* tuning parameter, depends on how much SPAR Filters overlap for the CLDFB bands */ - { - spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band]; - cldfb_par = mixer_mat[out_ch][in_ch][spar_band]; - } - else - { - cldfb_par = 0.0f; - for ( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ ) - { - /* accumulate contributions from all SPAR bands */ - cldfb_par += mixer_mat[out_ch][in_ch][spar_band] * bin2band->pp_cldfb_weights_per_spar_band[cldfb_band][spar_band]; - } - } - - out_re[out_ch] += inRe[in_ch][ts][cldfb_band] * cldfb_par; - out_im[out_ch] += inIm[in_ch][ts][cldfb_band] * cldfb_par; - } - } - - /*update CLDFB data with the parameter-modified data*/ - for ( out_ch = firstOutCh; out_ch < outChEnd; out_ch++ ) - { - inRe[out_ch][ts][cldfb_band] = out_re[out_ch]; - inIm[out_ch][ts][cldfb_band] = out_im[out_ch]; - } - } - - /* Update mixing matrices */ - if ( ( ( slot_idx_start + ts + 1 ) == hSpar->num_slots ) || ( ( md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME ) != ( hSpar->render_to_md_map[ts + slot_idx_start + 1] / JBM_CLDFB_SLOTS_IN_SUBFRAME ) ) ) - { - /* we have crossed an unadapted parameter sf border, update previous mixing matrices */ - int16_t md_sf = md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME; - hSpar->i_subframe++; - hSpar->i_subframe = min( hSpar->i_subframe, MAX_PARAM_SPATIAL_SUBFRAMES ); - mvr2r( hSpar->hMdDec->mixer_mat_prev[1][0][0], hSpar->hMdDec->mixer_mat_prev[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - mvr2r( hSpar->hMdDec->mixer_mat_prev[2][0][0], hSpar->hMdDec->mixer_mat_prev[1][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - mvr2r( hSpar->hMdDec->mixer_mat_prev[3][0][0], hSpar->hMdDec->mixer_mat_prev[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - mvr2r( hSpar->hMdDec->mixer_mat_prev[4][0][0], hSpar->hMdDec->mixer_mat_prev[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - - for ( out_ch = 0; out_ch < numch_out; out_ch++ ) - { - for ( in_ch = 0; in_ch < numch_in; in_ch++ ) - { - for ( b = 0; b < num_spar_bands; b++ ) - { - hSpar->hMdDec->mixer_mat_prev[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat[out_ch][in_ch][b + md_sf * IVAS_MAX_NUM_BANDS]; - } - } - } - } - } - - /* Create prototypes */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) - { - for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) - { - if ( st_ivas->nchan_transport == 1 ) /* Dual mono */ - { - mvr2r( inRe[0][ts], inRe[1][ts], CLDFB_NO_CHANNELS_MAX ); - mvr2r( inIm[0][ts], inIm[1][ts], CLDFB_NO_CHANNELS_MAX ); - } - else if ( st_ivas->nchan_transport == 2 ) /* Opposing cardioids */ - { - float temp_signal[CLDFB_NO_CHANNELS_MAX]; - - v_add( inRe[0][ts], inRe[1][ts], temp_signal, CLDFB_NO_CHANNELS_MAX ); - v_sub( inRe[0][ts], inRe[1][ts], inRe[1][ts], CLDFB_NO_CHANNELS_MAX ); - mvr2r( temp_signal, inRe[0][ts], CLDFB_NO_CHANNELS_MAX ); - v_multc( inRe[0][ts], 0.5f, inRe[0][ts], CLDFB_NO_CHANNELS_MAX ); - v_multc( inRe[1][ts], 0.5f, inRe[1][ts], CLDFB_NO_CHANNELS_MAX ); - - v_add( inIm[0][ts], inIm[1][ts], temp_signal, CLDFB_NO_CHANNELS_MAX ); - v_sub( inIm[0][ts], inIm[1][ts], inIm[1][ts], CLDFB_NO_CHANNELS_MAX ); - mvr2r( temp_signal, inIm[0][ts], CLDFB_NO_CHANNELS_MAX ); - v_multc( inIm[0][ts], 0.5f, inIm[0][ts], CLDFB_NO_CHANNELS_MAX ); - v_multc( inIm[1][ts], 0.5f, inIm[1][ts], CLDFB_NO_CHANNELS_MAX ); - } - } - } - - pop_wmops(); - - return; -} -#endif - void ivas_sba_prototype_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ @@ -306,6 +154,7 @@ void ivas_sba_prototype_renderer( inIm[out_ch][ts][cldfb_band] = out_im[out_ch]; } } + #ifdef JBM_TSM_ON_TCS /* Update mixing matrices */ if ( ( ( slot_idx_start + ts + 1 ) == hSpar->num_slots ) || ( ( md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME ) != ( hSpar->render_to_md_map[ts + slot_idx_start + 1] / JBM_CLDFB_SLOTS_IN_SUBFRAME ) ) ) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index edb495e2e5cb6b4afe0f17a39681ad4770df0e0b..6a1de3b0e2024ca4fd83efd4615974e91e0c635f 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4423,6 +4423,7 @@ static ivas_error renderIsmToBinauralRoom( const IVAS_REND_HeadRotData *headRotData; #ifdef JBM_TSM_ON_TCS float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; @@ -4801,10 +4802,10 @@ static ivas_error renderMcToBinaural( IVAS_REND_AudioConfig inConfig; ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; - #ifdef JBM_TSM_ON_TCS float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; int16_t i; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; @@ -4885,10 +4886,10 @@ static ivas_error renderMcToBinauralRoom( IVAS_REND_AudioConfig inConfig; ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; - #ifdef JBM_TSM_ON_TCS float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; int16_t i; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; @@ -4972,7 +4973,6 @@ static ivas_error renderMcCustomLsToBinauralRoom( IVAS_REND_AudioBuffer tmpRotBuffer; IVAS_REND_AudioBuffer tmpMcBuffer; IVAS_REND_AudioBuffer *tmpBufPtr; - #ifdef JBM_TSM_ON_TCS float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; #endif @@ -5228,10 +5228,8 @@ static ivas_error renderSbaToBinaural( IVAS_REND_AudioBuffer outAudio ) { float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; - #ifdef JBM_TSM_ON_TCS float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; int16_t i; @@ -5300,7 +5298,6 @@ static ivas_error renderSbaToBinauralRoom( IVAS_REND_AudioBuffer tmpRotBuffer; IVAS_REND_AudioBuffer tmpMcBuffer; IVAS_REND_AudioBuffer *tmpBufPtr; - #ifdef JBM_TSM_ON_TCS float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; #endif