diff --git a/apps/decoder.c b/apps/decoder.c index 959d7f5094b82908eba65956b6b5ec49603e6a82..d75b058b0c34fa2af14afd23648b4100d8159bfb 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -128,16 +128,16 @@ typedef struct #endif IVAS_DEC_COMPLEXITY_LEVEL complexityLevel; bool tsmEnabled; +#ifndef NONBE_UNIFIED_DECODING_PATHS bool enable5ms; +#else + IVAS_RENDER_FRAMESIZE renderFramesize; +#endif #ifdef DEBUGGING IVAS_DEC_FORCED_REND_MODE forcedRendMode; #ifdef DEBUG_FOA_AGC FILE *agcBitstream; /* temporary */ #endif -#ifdef DEBUG_JBM_CMD_OPTION - bool noBadFrameDelay; - uint16_t frontendFetchSizeMs; -#endif #ifdef VARIABLE_SPEED_DECODING bool tsmScaleFileEnabled; char *tsmScaleFileName; @@ -162,7 +162,14 @@ static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotF #else static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); #endif -static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); +static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, +#ifdef NONBE_UNIFIED_DECODING_PATHS + RotFileReader *headRotReader, + RotFileReader *externalOrientationFileReader, + RotFileReader *refRotReader, + Vector3PairFileReader *referenceVectorReader, +#endif + IVAS_DEC_HANDLE hIvasDec ); #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 ); @@ -429,8 +436,16 @@ int main( * Configure the decoder *------------------------------------------------------------------------------------------*/ - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.enable5ms, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, - arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, arg.Opt_dpid_on, arg.acousticEnvironmentId, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, +#ifndef NONBE_UNIFIED_DECODING_PATHS + arg.enable5ms, +#else + arg.renderFramesize, +#endif + arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, + arg.Opt_dpid_on, + arg.acousticEnvironmentId, + arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -443,11 +458,25 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + IVAS_RENDER_FRAMESIZE asked_frame_size = arg.renderFramesize; +#endif if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = IVAS_DEC_GetRenderFramesize( hIvasDec, &arg.renderFramesize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + if ( arg.renderFramesize != asked_frame_size ) + { + fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for split rendering!\n" ); + } +#endif arg.enableHeadRotation = true; } @@ -602,22 +631,39 @@ int main( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( arg.enable5ms && - ( renderConfig.split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - renderConfig.split_rend_config.dof == 0 ) ) + if ( +#ifdef NONBE_UNIFIED_DECODING_PATHS + arg.renderFramesize == IVAS_RENDER_FRAMESIZE_5MS && +#else + arg.enable5ms && +#endif + ( renderConfig.split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + renderConfig.split_rend_config.dof == 0 ) ) { - /*TODO : needs to be refined as this wont work with LCLD codec*/ +/*TODO : needs to be refined as this wont work with LCLD codec*/ +#ifdef NONBE_UNIFIED_DECODING_PATHS + arg.renderFramesize = IVAS_RENDER_FRAMESIZE_5MS; +#else arg.enable5ms = true; +#endif } else { - arg.enable5ms = false; +#ifdef NONBE_UNIFIED_DECODING_PATHS + arg.renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; +#else + arg.enable5ms = true; +#endif } - +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = IVAS_DEC_SetRenderFramesize( hIvasDec, arg.renderFramesize ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Set5msFlag( hIvasDec, arg.enable5ms ) ) != IVAS_ERR_OK ) +#endif { return error; } + #endif if ( RenderConfigReader_read( renderConfigReader, arg.renderConfigFilename, &renderConfig ) != IVAS_ERR_OK ) @@ -758,7 +804,11 @@ int main( if ( arg.voipMode ) { - error = decodeVoIP( arg, hBsReader, hIvasDec ); + error = decodeVoIP( arg, hBsReader, +#ifdef NONBE_UNIFIED_DECODING_PATHS + headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, +#endif + hIvasDec ); } else { @@ -1012,19 +1062,17 @@ static bool parseCmdlIVAS_dec( arg->Opt_non_diegetic_pan = 0; arg->non_diegetic_pan_gain = 0.f; arg->tsmEnabled = false; +#ifndef NONBE_UNIFIED_DECODING_PATHS arg->enable5ms = false; +#else + arg->renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; +#endif #ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING arg->tsmScale = 100; arg->tsmScaleFileEnabled = false; arg->tsmScaleFileName = NULL; #endif -#ifdef DEBUG_JBM_CMD_OPTION - arg->frontendFetchSizeMs = JBM_FRONTEND_FETCH_FRAMESIZE_MS; -#endif -#ifdef DEBUG_JBM_CMD_OPTION - arg->noBadFrameDelay = false; -#endif #endif arg->acousticEnvironmentId = 65535; for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) @@ -1156,13 +1204,6 @@ static bool parseCmdlIVAS_dec( } #endif /* #ifdef DEBUG_MODE_INFO_TWEAK */ #endif /* #ifdef DEBUG_MODE_INFO */ -#ifdef DEBUG_JBM_CMD_OPTION - else if ( strcmp( argv_to_upper, "-VOIP_NO_BAD_FRAME" ) == 0 ) - { - arg->noBadFrameDelay = true; - i++; - } -#endif #ifdef VARIABLE_SPEED_DECODING else if ( strcmp( argv_to_upper, "-VS" ) == 0 ) { @@ -1196,26 +1237,6 @@ static bool parseCmdlIVAS_dec( } } #endif -#ifdef DEBUG_JBM_CMD_OPTION - else if ( strcmp( argv_to_upper, "-VOIP_FRAMESIZE" ) == 0 ) - { - i++; - int32_t tmp; - if ( i < argc - 3 ) - { - if ( !is_digits_only( argv[i] ) ) - { - return false; - } - - if ( sscanf( argv[i], "%d", &tmp ) > 0 ) - { - i++; - } - arg->frontendFetchSizeMs = (uint16_t) tmp; - } - } -#endif #endif /* #ifdef DEBUGGING */ else if ( strcmp( argv_to_upper, "-MIME" ) == 0 ) @@ -1238,11 +1259,47 @@ static bool parseCmdlIVAS_dec( arg->headrotTrajFileName = argv[i]; i++; } +#ifndef NONBE_UNIFIED_DECODING_PATHS else if ( strcmp( argv_to_upper, "-FR5" ) == 0 ) { arg->enable5ms = true; i++; } +#else + else if ( strcmp( argv_to_upper, "-FR" ) == 0 ) + { + int32_t tmp; + i++; + if ( i < argc - 3 ) + { + if ( !is_digits_only( argv[i] ) ) + { + return false; + } + + if ( sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + switch ( (int16_t) tmp ) + { + case 5: + arg->renderFramesize = IVAS_RENDER_FRAMESIZE_5MS; + break; + case 10: + arg->renderFramesize = IVAS_RENDER_FRAMESIZE_10MS; + break; + case 20: + arg->renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; + break; + default: + fprintf( stderr, "Error: Invalid render frame size %d \n\n", tmp ); + usage_dec(); + return false; + } + } + } +#endif else if ( strcmp( argv_to_upper, "-OTR" ) == 0 ) { @@ -1549,10 +1606,12 @@ static bool parseCmdlIVAS_dec( return false; } +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( ( !arg->enableHeadRotation ) && ( !arg->enableExternalOrientation ) && ( !arg->tsmEnabled ) ) { arg->enable5ms = false; } +#endif return true; } @@ -1591,9 +1650,6 @@ static void usage_dec( void ) fprintf( stdout, "-VOIP : VoIP mode: RTP in G192\n" ); fprintf( stdout, "-VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump\n" ); fprintf( stdout, "-VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump\n" ); -#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" ); @@ -1605,11 +1661,12 @@ static void usage_dec( void ) 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 DEBUG_JBM_CMD_OPTION - fprintf( stdout, "-VOIP_framesize : VoIP mode: acoustic frontend fetch frame size (must be multiples of 5!)\n" ); -#endif #endif +#ifndef NONBE_UNIFIED_DECODING_PATHS fprintf( stdout, "-fr5 : option to perform rendering + head-tracking with 5ms frame size\n" ); +#else + fprintf( stdout, "-fr L : render frame size in ms L=(5,10,20), default is 20)\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" ); fprintf( stdout, " written into a .txt file. Each line contains the FER indicator \n" ); @@ -1690,8 +1747,12 @@ static ivas_error initOnFirstGoodFrame( const DecArguments arg, /* i : */ const int16_t numInitialBadFrames, /* i : */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_UNIFIED_DECODING_PATHS + int16_t *numOutSamples, /* i/o: */ +#else uint16_t *numOutSamples, /* i/o: */ - int16_t *vec_pos_len, /* i/o: */ +#endif + int16_t *vec_pos_len, /* i/o: */ #else const uint16_t numOutSamples, /* i : */ #endif @@ -1933,13 +1994,27 @@ static ivas_error initOnFirstGoodFrame( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( *splitRendWriter != NULL ) { +#ifndef NONBE_UNIFIED_DECODING_PATHS int16_t enable5ms; +#endif if ( numOutSamples == NULL || vec_pos_len == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* real setting of the 5ms mode for split rendering is only known after the decoded first good frame, reset the variables needed in the main decoding loop accordingly here*/ + if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, numOutSamples ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, vec_pos_len ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } +#else if ( ( error = IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ) ) != IVAS_ERR_OK ) { return error; @@ -1956,6 +2031,7 @@ static ivas_error initOnFirstGoodFrame( *numOutSamples = (int16_t) ( arg.output_Fs / 1000 * DEFAULT_FETCH_FRAMESIZE_MS ); *vec_pos_len = 1; } +#endif } #endif @@ -1997,7 +2073,7 @@ static ivas_error decodeG192( int16_t nOutChannels = 0; int16_t delayNumSamples = -1; int16_t delayNumSamples_orig[3]; -#ifdef SPLIT_REND_WITH_HEAD_ROT +#if defined( SPLIT_REND_WITH_HEAD_ROT ) && !defined( NONBE_UNIFIED_DECODING_PATHS ) uint16_t nOutSamples = 0; #else int16_t nOutSamples = 0; @@ -2077,6 +2153,18 @@ static ivas_error decodeG192( nSamplesAvailableNext = 0; vec_pos_update = 0; +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nOutSamples ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, &vec_pos_len ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } +#else if ( arg.enableHeadRotation && arg.enable5ms ) { nOutSamples = (int16_t) ( arg.output_Fs / 1000 * HEADROTATION_FETCH_FRAMESIZE_MS ); @@ -2087,7 +2175,7 @@ static ivas_error decodeG192( nOutSamples = (int16_t) ( arg.output_Fs / 1000 * DEFAULT_FETCH_FRAMESIZE_MS ); vec_pos_len = 1; } - +#endif /*------------------------------------------------------------------------------------------* * Loop for every packet (frame) of bitstream data * - Read the bitstream packet @@ -2132,7 +2220,7 @@ static ivas_error decodeG192( goto cleanup; } } - +#ifndef NONBE_UNIFIED_DECODING_PATHS int16_t enable5ms, num_subframes; if ( ( error = IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ) ) != IVAS_ERR_OK ) { @@ -2140,7 +2228,14 @@ static ivas_error decodeG192( } arg.enable5ms = enable5ms; num_subframes = ( arg.enable5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; - +#else + int16_t num_subframes; + if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" ); + goto cleanup; + } +#endif /* Head-tracking input simulation */ /* Head-tracking input simulation */ if ( arg.enableHeadRotation ) @@ -2795,6 +2890,12 @@ static ivas_error writeJbmTraceFileFrameWrapper( const void *data, void *writer static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, +#ifdef NONBE_UNIFIED_DECODING_PATHS + RotFileReader *headRotReader, + RotFileReader *externalOrientationFileReader, + RotFileReader *refRotReader, + Vector3PairFileReader *referenceVectorReader, +#endif IVAS_DEC_HANDLE hIvasDec ) { bool decodingFailed = true; /* Assume failure until cleanup is reached without errors */ @@ -2837,6 +2938,30 @@ static ivas_error decodeVoIP( IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN; IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; +#ifdef NONBE_UNIFIED_DECODING_PATHS + IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; + int16_t vec_pos_update, vec_pos_len; + int16_t nOutSamples = 0; +#endif + +#ifdef NONBE_UNIFIED_DECODING_PATHS + vec_pos_update = 0; + if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } + if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nOutSamples ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, &vec_pos_len ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError getting render frame size in samples\n" ); + return error; + } +#endif for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { @@ -2935,23 +3060,140 @@ static ivas_error decodeVoIP( * Main receiving/decoding loop *------------------------------------------------------------------------------------------*/ -#ifdef DEBUG_JBM_CMD_OPTION - systemTimeInc_ms = arg.frontendFetchSizeMs; -#endif - while ( 1 ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifndef NONBE_UNIFIED_DECODING_PATHS +#if defined( SPLIT_REND_WITH_HEAD_ROT ) uint16_t nOutSamples = 0; #else int16_t nOutSamples = 0; #endif -#ifdef DEBUG_JBM_CMD_OPTION - nOutSamples = (int16_t) ( arg.output_Fs / 1000 * arg.frontendFetchSizeMs ); -#else nOutSamples = (int16_t) ( arg.output_Fs / 1000 * JBM_FRONTEND_FETCH_FRAMESIZE_MS ); #endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* reference vector */ + if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 ) + { + IVAS_VECTOR3 listenerPosition, referencePosition; + if ( ( error = Vector3PairFileReader_read( referenceVectorReader, &listenerPosition, &referencePosition ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading listener and reference positions from %s\n", IVAS_DEC_GetErrorMessage( error ), Vector3PairFileReader_getFilePath( referenceVectorReader ) ); + goto cleanup; + } + + if ( ( error = IVAS_DEC_FeedRefVectorData( hIvasDec, listenerPosition, referencePosition ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedRefVectorData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + + /* Reference rotation */ + if ( arg.enableReferenceRotation && vec_pos_update == 0 ) + { + IVAS_QUATERNION quaternion; + if ( ( error = HeadRotationFileReading( refRotReader, &quaternion, NULL ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading reference rotation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( refRotReader ) ); + goto cleanup; + } + + if ( ( error = IVAS_DEC_FeedRefRotData( hIvasDec, quaternion ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedRefRotData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + int16_t num_subframes; + if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" ); + goto cleanup; + } + + /* Head-tracking input simulation */ + /* Head-tracking input simulation */ + if ( arg.enableHeadRotation ) + { + IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( headRotReader == NULL ) + { + for ( i = 0; i < num_subframes; i++ ) + { + Quaternions[i].w = -3.0f; + Quaternions[i].x = 0.0f; + Quaternions[i].y = 0.0f; + Quaternions[i].z = 0.0f; + Pos[i].x = 0.0f; + Pos[i].y = 0.0f; + Pos[i].z = 0.0f; + } + } + else + { +#endif + for ( i = 0; i < num_subframes; i++ ) + { + if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), + RotationFileReader_getFilePath( headRotReader ) ); + goto cleanup; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif + + for ( i = 0; i < num_subframes; i++ ) + { + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + DEFAULT_AXIS +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + } + + if ( arg.enableExternalOrientation ) + { + IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + int8_t enableHeadRotation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + int8_t enableExternalOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + int16_t numFramesToTargetOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; + + for ( i = 0; i < num_subframes; i++ ) + { + + if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternions[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError %s while reading external orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), + RotationFileReader_getFilePath( externalOrientationFileReader ) ); + goto cleanup; + } + } + for ( i = 0; i < num_subframes; i++ ) + { + if ( ( error = IVAS_DEC_FeedExternalOrientationData( hIvasDec, Quaternions[i], enableHeadRotation[i], enableExternalOrientation[i], enableRotationInterpolation[i], numFramesToTargetOrientation[i], i ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedExternalOrientationData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + } + +#endif + + /* read all packets with a receive time smaller than the system time */ while ( nextPacketRcvTime_ms <= systemTime_ms ) { @@ -3005,7 +3247,6 @@ static ivas_error decodeVoIP( /* decode and get samples */ #ifdef SPLIT_REND_WITH_HEAD_ROT - #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) #else @@ -3066,11 +3307,7 @@ static ivas_error decodeVoIP( goto cleanup; } } -#ifdef DEBUG_JBM_CMD_OPTION - else if ( arg.noBadFrameDelay == false ) -#else else -#endif { ++numInitialBadFrames; } @@ -3144,7 +3381,9 @@ static ivas_error decodeVoIP( { fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame ); } - +#ifdef NONBE_UNIFIED_DECODING_PATHS + vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; +#endif frame++; systemTime_ms += systemTimeInc_ms; diff --git a/apps/renderer.c b/apps/renderer.c index 9f0c242529853a40a8ca95a894deacb8c75c8fdd..94e6aee0fa68067b8a8a00877acd828299fdb6fa 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -187,7 +187,11 @@ typedef struct bool lfeCustomRoutingEnabled; char inLfePanningMatrixFile[RENDERER_MAX_CLI_ARG_LENGTH]; float syncMdDelay; +#ifdef NONBE_UNIFIED_DECODING_PATHS + IVAS_RENDER_FRAMESIZE render_framesize; +#else bool framing_5ms; +#endif uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS]; uint16_t acousticEnvironmentId; } CmdlnArgs; @@ -219,6 +223,9 @@ typedef enum #endif CmdLnOptionId_referenceVectorFile, CmdLnOptionId_exteriorOrientationFile, +#ifdef NONBE_UNIFIED_DECODING_PATHS + CmdLnOptionId_framing, +#endif CmdLnOptionId_framing5ms, CmdLnOptionId_syncMdDelay, CmdLnOptionId_directivityPatternId, @@ -368,6 +375,14 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "exof", .description = "External orientation trajectory file for simulation of external orientations", }, +#ifdef NONBE_UNIFIED_DECODING_PATHS + { + .id = CmdLnOptionId_framing, + .match = "framing", + .matchShort = "fr", + .description = "Set Render audio framing.", + }, +#endif { .id = CmdLnOptionId_framing5ms, .match = "framing_5ms", @@ -999,9 +1014,17 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); +#else const int16_t frameSize_smpls = (int16_t) ( ( args.framing_5ms ? 5 : 20 ) * args.sampleRate / 1000 ); +#endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, ( args.framing_5ms ) ? 1 : 4 ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1496,7 +1519,11 @@ int main( { int16_t num_in_channels; num_in_channels = inBuffer.config.numChannels; +#ifdef NONBE_UNIFIED_DECODING_PATHS + const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_framesize ) == 0; +#else const bool isCurrentFrameMultipleOf20ms = !args.framing_5ms || frame % 4 == 0; +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT numSamplesRead = 0; @@ -1548,7 +1575,11 @@ int main( #endif int16_t num_subframes, sf_idx; +#ifdef NONBE_UNIFIED_DECODING_PATHS + num_subframes = (int16_t) args.render_framesize; +#else num_subframes = ( args.framing_5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; +#endif if ( isCurrentFrameMultipleOf20ms ) { @@ -2336,6 +2367,37 @@ static bool parseDiegeticPan( return true; } + +#ifdef NONBE_UNIFIED_DECODING_PATHS +static bool parseRenderFramesize( char *value, + IVAS_RENDER_FRAMESIZE *render_framesize ) +{ + int32_t tmp; + + *render_framesize = IVAS_RENDER_FRAMESIZE_UNKNOWN; + if ( !is_digits_only( value ) ) + { + return false; + } + tmp = (int32_t) strtol( value, NULL, 0 ); + switch ( (int16_t) tmp ) + { + case 5: + *render_framesize = IVAS_RENDER_FRAMESIZE_5MS; + break; + case 10: + *render_framesize = IVAS_RENDER_FRAMESIZE_10MS; + break; + case 20: + *render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + break; + default: + return false; + } + return true; +} +#endif + static bool parseOrientationTracking( char *value, int8_t *orientation_tracking ) @@ -2633,7 +2695,11 @@ static CmdlnArgs defaultArgs( args.lfeCustomRoutingEnabled = false; clearString( args.inLfePanningMatrixFile ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS; +#else args.framing_5ms = false; +#endif args.syncMdDelay = 0; for ( int32_t i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) @@ -2795,9 +2861,24 @@ static void parseOption( exit( -1 ); } break; +#ifdef NONBE_UNIFIED_DECODING_PATHS + case CmdLnOptionId_framing: + assert( numOptionValues == 1 ); + if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) ) + { + fprintf( stderr, "Unknown or invalid option for LFE position: %s\n", optionValues[0] ); + exit( -1 ); + } + + break; +#endif case CmdLnOptionId_framing5ms: assert( numOptionValues == 0 ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + args->render_framesize = IVAS_RENDER_FRAMESIZE_5MS; +#else args->framing_5ms = true; +#endif fprintf( stderr, "Warning: this is a placeholder for 5ms framing.\n" ); break; case CmdLnOptionId_directivityPatternId: diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index c841cc02c0d9c8d8ecd2e82eabde769d85544cf4..d587ee7f63c80251810ba4d569d7d52c915e5119 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -150,6 +150,16 @@ typedef enum } IVAS_HEAD_ORIENT_TRK_T; +#ifdef NONBE_UNIFIED_DECODING_PATHS +typedef enum +{ + IVAS_RENDER_FRAMESIZE_UNKNOWN = 0, + IVAS_RENDER_FRAMESIZE_5MS = 1, + IVAS_RENDER_FRAMESIZE_10MS = 2, + IVAS_RENDER_FRAMESIZE_20MS = 4 +} IVAS_RENDER_FRAMESIZE; +#endif + typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE; typedef struct ivas_masa_decoder_ext_out_meta_struct *IVAS_MASA_DECODER_EXT_OUT_META_HANDLE; diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 113676751d5fa532665578e6e58afb89a6910748..dc956fcc7c6a9f13d38a630398a9184307b3be39 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -190,6 +190,11 @@ typedef enum TC_BUFFER_MODE_BUFFER } TC_BUFFER_MODE; +#ifdef UNIFY_CHANNEL_MEM_HEAP +#define TC_BUFFER_NUM_FULL_CHAN_UNKNOWN -1 +#define TC_BUFFER_NUM_FULL_CHAN_DONT_COUNT 0 +#endif + /*----------------------------------------------------------------------------------* * IVAS Bitrates *----------------------------------------------------------------------------------*/ @@ -1213,7 +1218,9 @@ enum #define MASA_STEREO_MIN_BITRATE IVAS_24k4 #define MAXIMUM_OMASA_FREQ_BANDS 8 /* Corresponds to maximum number of coding bands at 32 kbps */ #define OMASA_STEREO_SW_CNT_MAX 100 - +#ifdef UNIFY_CHANNEL_MEM_HEAP +#define OMASA_TDREND_MATCHING_GAIN 0.7943f +#endif #define MASA_BIT_REDUCT_PARAM 10 #define MASA_MAXIMUM_TWO_DIR_BANDS 24 #define NBITS_HR_COH 4 diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 66350fb694ce824290f7dce3d26619c9a20b5646..e6e98c6205849387c23ba01d0c49021b0aa71636 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -854,6 +854,12 @@ void ivas_jbm_dec_get_md_map( int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + , + int16_t *nchan_transport_jbm, /* o : number of TSM channels */ + int16_t *nchan_transport_internal, /* o : number of internal channels (i.e. plus e.g. addtl. decorr */ + int16_t *nchan_transport_full /* o : number of channels to allocate fully */ +#endif ); void ivas_jbm_dec_copy_tc_no_tsm( @@ -876,10 +882,14 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( - const RENDERER_TYPE rendererType, /* i : renderer type */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int32_t output_Fs /* i : sampling rate */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + Decoder_Struct *st_ivas /* i : main decoder structure */ +#else + const RENDERER_TYPE rendererType, /* i : renderer type */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const MC_MODE mc_mode, /* i : MC mode */ + const int32_t output_Fs /* i : sampling rate */ +#endif ); ivas_error ivas_jbm_dec_tc_buffer_open( @@ -892,12 +902,15 @@ ivas_error ivas_jbm_dec_tc_buffer_open( ); 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 */ +#ifndef UNIFY_CHANNEL_MEM_HEAP + , + 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 */ +#endif ); void ivas_jbm_dec_tc_buffer_close( @@ -3682,6 +3695,9 @@ 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 */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, +#endif const int16_t cna_flag /* i : CNA flag for LB and HB */ ); @@ -5254,13 +5270,15 @@ void ivas_binRenderer( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - HEAD_TRACK_DATA_HANDLE hPostRendHeadTrackData, #endif COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ +#ifndef NONBE_UNIFIED_DECODING_PATHS int16_t subframe_idx, /* i : subframe index */ +#endif const int16_t numTimeSlots, /* i : number of time slots to process */ +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HEAD_TRACK_DATA_HANDLE hPostRendHeadTrackData, +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT float Cldfb_RealBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ float Cldfb_ImagBuffer_Binaural[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ @@ -5922,11 +5940,14 @@ void ivas_omasa_separate_object_render( ); void ivas_omasa_separate_object_render_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesRendered, /* i : number of samples rendered */ - float *output_f[], /* o : rendered time signal */ - const int16_t subframes_rendered, /* i : number of subframes rendered */ - const int16_t slots_rendered /* i : number of CLDFB slots rendered */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesRendered, /* i : number of samples rendered */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + float *input_f[], /* i : discrete objects transport time signal */ +#endif + float *output_f[], /* o : rendered time signal */ + const int16_t subframes_rendered, /* i : number of subframes rendered */ + const int16_t slots_rendered /* i : number of CLDFB slots rendered */ ); void ivas_omasa_encode_masa_to_total( diff --git a/lib_com/options.h b/lib_com/options.h index 9348bf96aa50ce1ab1f6849493c456476d5d5bc3..02b3de6c194fbe6a812f2caae4adffd26c81b293 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,7 +148,7 @@ /* only BE switches wrt selection floating point code */ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ -/*#define SPLIT_REND_WITH_HEAD_ROT*/ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ +/*#define SPLIT_REND_WITH_HEAD_ROT */ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ @@ -165,6 +165,10 @@ #define NONBE_FIX_819_DOUBLE_PREC_COMB_FORMATS /* VA: issue 820: Double precision arithmetic in combined formats */ #define NONBE_FIX_849_OMASA_BFI_CRASH /* VA: issue 849: fix OMASA 2TC and FEC crashes */ +#define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ +#ifdef NONBE_UNIFIED_DECODING_PATHS +/*#define UNIFY_CHANNEL_MEM_HEAP*/ +#endif /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 5e36f024f8507f402390b9863c88408ffbc90bb3..95bb1a9fdcdb0437a92f21e84c4be6f67a43c30e 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1804,7 +1804,10 @@ 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 */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i : common spatial parameter rendering handle */ +#endif + const int16_t cna_flag /* i : CNA flag for LB and HB */ ) { int16_t i; @@ -1940,6 +1943,31 @@ void generate_masking_noise_lb_dirac( n_samples_start += hFdCngCom->frameSize; } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* move to the real subframe start to avoid overwriting the LB signal */ + { + int16_t slot_size_lb, slot_size_fb, move_size; + int16_t n_samples_out_start_fb; + int16_t n_samples_out_start_lb; + slot_size_lb = hFdCngCom->frameSize / DEFAULT_JBM_CLDFB_TIMESLOTS; + slot_size_fb = hSpatParamRendCom->slot_size; + /* move from last to first subframe */ + n_samples_out_start_lb = ( hSpatParamRendCom->num_slots - hSpatParamRendCom->subframe_nbslots[hSpatParamRendCom->nb_subframes - 1] ) * slot_size_lb; + n_samples_out_start_fb = ( hSpatParamRendCom->num_slots - hSpatParamRendCom->subframe_nbslots[hSpatParamRendCom->nb_subframes - 1] ) * slot_size_fb; + + for ( i = hSpatParamRendCom->nb_subframes - 1; i > 0; i-- ) + { + move_size = hSpatParamRendCom->subframe_nbslots[i] * slot_size_lb; + mvr2r( &tdBuffer[n_samples_out_start_lb], &tdBuffer[n_samples_out_start_fb], move_size ); + n_samples_out_start_lb -= hSpatParamRendCom->subframe_nbslots[i] * slot_size_lb; + n_samples_out_start_fb -= hSpatParamRendCom->subframe_nbslots[i] * slot_size_fb; + } +#ifdef DEBUGGING + assert( n_samples_out_start_fb == 0 ); + assert( n_samples_out_start_lb == 0 ); +#endif + } +#endif pop_wmops(); diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index e31abae1d8d1fdc8bdb2db943acfec5f4597c0e8..ab7313e96cf291d6b0fa4e87525333037017d21e 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1646,15 +1646,21 @@ void ivas_binaural_cldfb( } /* Implement binaural rendering */ + ivas_binRenderer( + st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, JBM_CLDFB_SLOTS_IN_SUBFRAME, NULL, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); -#else - ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, JBM_CLDFB_SLOTS_IN_SUBFRAME, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #endif -#else - ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, JBM_CLDFB_SLOTS_IN_SUBFRAME, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + st_ivas->hCombinedOrientationData, +#ifndef NONBE_UNIFIED_DECODING_PATHS + subframeIdx, +#endif + JBM_CLDFB_SLOTS_IN_SUBFRAME, +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + NULL, #endif + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, + Cldfb_RealBuffer, Cldfb_ImagBuffer ); #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) @@ -1695,7 +1701,10 @@ void ivas_binaural_cldfb( } } #endif - +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES ); +#endif /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -1819,12 +1828,23 @@ void ivas_binaural_cldfb_sf( } /* Implement binaural rendering */ + ivas_binRenderer( + st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); -#else - ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #endif - + st_ivas->hCombinedOrientationData, +#ifndef NONBE_UNIFIED_DECODING_PATHS + subframeIdx, +#endif + st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + NULL, +#endif + Cldfb_RealBuffer_Binaural, + Cldfb_ImagBuffer_Binaural, + Cldfb_RealBuffer, + Cldfb_ImagBuffer ); #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { @@ -1842,7 +1862,10 @@ void ivas_binaural_cldfb_sf( } } #endif - +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ); +#endif /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -1885,8 +1908,10 @@ void ivas_binRenderer( const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, #endif COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - int16_t subframe_idx, /* i : subframe index */ - const int16_t numTimeSlots, /* i : number of time slots to render */ +#ifndef NONBE_UNIFIED_DECODING_PATHS + int16_t subframe_idx, /* i : subframe index */ +#endif + const int16_t numTimeSlots, /* i : number of time slots to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG HEAD_TRACK_DATA_HANDLE hPostRendHeadTrackData, #endif @@ -1937,24 +1962,49 @@ void ivas_binRenderer( #endif /* Head rotation in HOA3 or CICPx */ - if ( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && hBinRenderer->rotInCldfb ) + if ( hCombinedOrientationData != NULL && +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] +#else + hCombinedOrientationData->enableCombinedOrientation[subframe_idx] +#endif + + && hBinRenderer->rotInCldfb ) { if ( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) { /* Rotation in SHD (HOA3) */ if ( hCombinedOrientationData->shd_rot_max_order == -1 ) { - rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, hCombinedOrientationData->Rmat[subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); + rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], +#else + hCombinedOrientationData->Rmat[subframe_idx], +#endif + hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); } else if ( hCombinedOrientationData->shd_rot_max_order > 0 ) { - rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, hCombinedOrientationData->Rmat[subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); + rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], +#else + hCombinedOrientationData->Rmat[subframe_idx], +#endif + hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); } } else { /* Rotation in SD (CICPx) */ - rotateFrame_sd_cldfb( hCombinedOrientationData->Rmat[subframe_idx], RealBuffer, ImagBuffer, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); + rotateFrame_sd_cldfb( +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], +#else + hCombinedOrientationData->Rmat[subframe_idx], +#endif + RealBuffer, ImagBuffer, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); } } @@ -2147,11 +2197,18 @@ void ivas_rend_CldfbMultiBinRendProcess( #endif #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, &head_track_post, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); +#else ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, sf_idx, MAX_PARAM_SPATIAL_SUBFRAMES, &head_track_post, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); +#endif +#else +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); #else ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, sf_idx, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); #endif - +#endif for ( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) { for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index a329fc7b7d84b6b8c52269ec39a6e6bf4b52d996..03a8533f15879417d367a0ecdccb562c4419dc34 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -97,11 +97,14 @@ ivas_error ivas_dec( * Combine orientations *----------------------------------------------------------------*/ +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( ( error = combine_external_and_head_orientations_dec( st_ivas->hHeadTrackData, st_ivas->hExtOrientationData, st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) { return error; } - +#else + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------* * Binaural split rendering setup @@ -1054,7 +1057,6 @@ ivas_error ivas_dec( } } - /*----------------------------------------------------------------* * Write IVAS output channels * - compensation for saturation @@ -1130,6 +1132,11 @@ ivas_error ivas_dec( st_ivas->last_ivas_format = st_ivas->ivas_format; +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update global combined orientation start index */ + ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, output_frame ); +#endif + /* in case first frame(s) was/were lost, deallocate output buffers */ if ( st_ivas->bfi && st_ivas->ini_frame == 0 ) { diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 6a4bc7fe9eead601ab6f027cd700bfd4adfb73e8..d747c993a30bf694247dd1cc93db86b6400e7ff2 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -948,11 +948,14 @@ ivas_error ivas_dirac_dec_config( } } +#if 0 /* Allocate transport channel buffers for SBA format when in JBM */ if ( dec_config_flag == DIRAC_OPEN ) { if ( +#ifndef NONBE_UNIFIED_DECODING_PATHS st_ivas->hDecoderConfig->Opt_5ms && +#endif st_ivas->hTcBuffer == NULL ) { if ( st_ivas->ivas_format == SBA_FORMAT ) @@ -978,7 +981,7 @@ ivas_error ivas_dirac_dec_config( } } } - +#endif return error; } @@ -1618,7 +1621,11 @@ void ivas_dirac_dec( { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; st_ivas->hTcBuffer->tc[nchan_transport] = &cng_td_buffer[0]; +#ifdef UNIFY_CHANNEL_MEM_HEAP + generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], DEFAULT_JBM_CLDFB_TIMESLOTS, st_ivas->hSpatParamRendCom, st->cna_dirac_flag && st->flag_cna ); +#else generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], DEFAULT_JBM_CLDFB_TIMESLOTS, st->cna_dirac_flag && st->flag_cna ); +#endif } ivas_dirac_dec_set_md_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); @@ -1630,6 +1637,9 @@ void ivas_dirac_dec( { output_f_local[n] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); +#endif } if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -1710,6 +1720,10 @@ void ivas_dirac_dec_render( { output_f_local[ch] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); +#endif } if ( hSpatParamRendCom->slots_rendered == hSpatParamRendCom->num_slots ) @@ -1857,9 +1871,19 @@ void ivas_dirac_dec_render_sf( set_zero( onset_filter_subframe, hSpatParamRendCom->num_freq_bands ); } - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] ) + if ( st_ivas->hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] +#endif + ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + p_Rmat = &st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx][0][0]; +#else p_Rmat = &st_ivas->hCombinedOrientationData->Rmat[subframe_idx][0][0]; +#endif if ( st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; @@ -1923,7 +1947,13 @@ void ivas_dirac_dec_render_sf( } } - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 1 ) + if ( st_ivas->hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] +#endif + && st_ivas->hCombinedOrientationData->shd_rot_max_order == 1 ) { ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, hDirACRend, @@ -2025,10 +2055,18 @@ void ivas_dirac_dec_render_sf( generate_masking_noise_dirac( st->hFdCngDec->hFdCngCom, st_ivas->cldfbAnaDec[1], +#ifdef UNIFY_CHANNEL_MEM_HEAP + &st_ivas->hTcBuffer->tc[1][slot_idx_start * hSpatParamRendCom->num_freq_bands], +#else st_ivas->hTcBuffer->tc[1], +#endif Cldfb_RealBuffer[1][0], Cldfb_ImagBuffer[1][0], +#ifndef UNIFY_CHANNEL_MEM_HEAP index_slot, +#else + slot_idx, +#endif st->cna_dirac_flag && st->flag_cna, ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && st->cng_type == FD_CNG && st->cng_sba_flag ); } @@ -2050,7 +2088,13 @@ void ivas_dirac_dec_render_sf( if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) + if ( st_ivas->hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] +#endif + && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) { protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, @@ -2282,7 +2326,13 @@ void ivas_dirac_dec_render_sf( } /*Compute PSDs*/ - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) + if ( st_ivas->hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] +#endif + && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) { ivas_dirac_dec_output_synthesis_process_slot( reference_power, p_onset_filter, @@ -2479,12 +2529,20 @@ void ivas_dirac_dec_render_sf( #endif /* Perform binaural rendering */ + ivas_binRenderer( st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframe_idx, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); -#else - ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframe_idx, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #endif + st_ivas->hCombinedOrientationData, +#ifndef NONBE_UNIFIED_DECODING_PATHS + subframe_idx, +#endif + hSpatParamRendCom->subframe_nbslots[subframe_idx], +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + NULL, +#endif + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 5d9a8369d32f19a9e175d817a2ed9b13cc96ba6c..ca1bb493cbc46bdb6bef6ff6cebec0cf5a65ee65 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -259,8 +259,11 @@ static ivas_error ivas_dec_init_split_rend( } #endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ); +#else error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->Opt_5ms ); - +#endif return error; } #endif @@ -353,8 +356,10 @@ ivas_error ivas_dec_setup( st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; +#ifndef NONBE_UNIFIED_DECODING_PATHS /* set Ambisonic (SBA) order used for analysis and coding */ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); +#endif num_bits_read += SBA_ORDER_BITS; if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) @@ -370,6 +375,10 @@ ivas_error ivas_dec_setup( } else { +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* set Ambisonic (SBA) order used for analysis and coding */ + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); +#endif ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); } } @@ -1019,7 +1028,13 @@ ivas_error ivas_init_decoder_front( if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - if ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hDecoderConfig->render_framesize +#else + ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -1031,7 +1046,16 @@ ivas_error ivas_init_decoder_front( if ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - if ( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hDecoderConfig->output_Fs, +#endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hDecoderConfig->render_framesize +#else + ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -1101,7 +1125,9 @@ ivas_error ivas_init_decoder( int16_t i, n, k; int16_t sce_id, cpe_id; int16_t numCldfbAnalyses, numCldfbSyntheses; +#ifndef UNIFY_CHANNEL_MEM_HEAP int16_t granularity, n_channels_transport_jbm; +#endif int32_t output_Fs, ivas_total_brate; int32_t binauralization_delay_ns; AUDIO_CONFIG output_config; @@ -1962,7 +1988,10 @@ ivas_error ivas_init_decoder( } } +#ifndef UNIFY_CHANNEL_MEM_HEAP +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { 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 ); @@ -1972,6 +2001,7 @@ ivas_error ivas_init_decoder( return error; } } +#endif } else if ( st_ivas->renderer_type == RENDERER_MC ) { @@ -2010,7 +2040,10 @@ ivas_error ivas_init_decoder( st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; +#ifndef UNIFY_CHANNEL_MEM_HEAP +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { if ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) { @@ -2035,6 +2068,7 @@ ivas_error ivas_init_decoder( } } } +#endif } if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) @@ -2173,11 +2207,15 @@ ivas_error ivas_init_decoder( return error; } +#ifndef UNIFY_CHANNEL_MEM_HEAP /*-----------------------------------------------------------------* * Allocate and initialize JBM struct + buffer *-----------------------------------------------------------------*/ - - if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL ) + if ( +#ifndef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hDecoderConfig->Opt_5ms && +#endif + st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); @@ -2196,6 +2234,7 @@ ivas_error ivas_init_decoder( return error; } } +#endif if ( st_ivas->hJbmMetadata == NULL ) { @@ -2211,10 +2250,15 @@ ivas_error ivas_init_decoder( /*-----------------------------------------------------------------* * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ - +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_5ms ) +#endif { +#ifdef UNIFY_CHANNEL_MEM_HEAP + for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_UNKNOWN ); n++ ) +#else for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) +#endif { /* note: these are intra-frame heap memories */ if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) @@ -2223,16 +2267,35 @@ ivas_error ivas_init_decoder( } } } +#ifndef NONBE_UNIFIED_DECODING_PATHS else { n = 0; } +#endif for ( ; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { st_ivas->p_output_f[n] = NULL; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + { + int16_t nchan_transport_jbm; + int16_t nchan_transport_internal; + int16_t nchan_transport_full; + int16_t renderer_granularity; + TC_BUFFER_MODE tc_buffer_mode; + ivas_jbm_dec_get_num_tc_channels( st_ivas, &nchan_transport_jbm, &nchan_transport_internal, &nchan_transport_full ); + tc_buffer_mode = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + renderer_granularity = ivas_jbm_dec_get_render_granularity( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, tc_buffer_mode, nchan_transport_jbm, nchan_transport_internal, nchan_transport_full, renderer_granularity ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + return error; } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index f778e7f23f41779f99ef74d5d9d0de22687e763f..cd481ac88229a319a8688ade0ece483cab8fc2f0 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -63,9 +63,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( int32_t element_brate_tmp[MAX_NUM_OBJECTS]; int16_t nSCE_old, nCPE_old; int16_t numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode; +#ifndef UNIFY_CHANNEL_MEM_HEAP TC_BUFFER_MODE tc_buffer_mode_new; int16_t tc_nchan_tc_new; int16_t tc_nchan_allocate_new; +#endif int16_t tc_granularity_new; #ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC int16_t nchan_out_buff, nchan_out_buff_old; @@ -86,10 +88,19 @@ static ivas_error ivas_ism_bitrate_switching_dec( ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); st_ivas->ism_mode = ism_mode; #ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC - nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1, st_ivas->hTcBuffer->nchan_buffer_full ); +#else + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); +#endif +#else +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hTcBuffer->nchan_buffer_full ); #else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); #endif +#endif + if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) { @@ -136,7 +147,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->hDecoderConfig->output_config ); } +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { /* transfer subframe info from DirAC or ParamMC to central tc buffer */ if ( last_ism_mode == ISM_MODE_PARAM && st_ivas->hSpatParamRendCom != NULL && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE ) ) @@ -150,7 +163,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* 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 */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas ); +#else tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { @@ -330,17 +347,28 @@ static ivas_error ivas_ism_bitrate_switching_dec( * floating-point output audio buffers *-----------------------------------------------------------------*/ +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_5ms ) +#endif { #ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1, TC_BUFFER_NUM_FULL_CHAN_UNKNOWN ); +#else nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); +#endif if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) { return error; } +#else +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_UNKNOWN ); #else nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif + if ( nchan_out_buff > nchan_out_buff_old ) { @@ -367,9 +395,16 @@ static ivas_error ivas_ism_bitrate_switching_dec( /*-----------------------------------------------------------------* * JBM TC buffers *-----------------------------------------------------------------*/ - +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#else int16_t tc_nchan_full_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; @@ -399,6 +434,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } } +#endif /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hSpatParamRendCom != NULL ) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index fda2762c2b0ecfb3ca7e34c2a2fcc19e36d91997..30cc7f9c5ace65f6f292d7b39a0315f4ec11f66b 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -590,12 +590,16 @@ ivas_error ivas_param_ism_dec_open( st_ivas->hParamIsmDec = hParamIsmDec; st_ivas->hSpatParamRendCom = hSpatParamRendCom; + +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE ) { int16_t nchan_transport = st_ivas->nchan_transport; int16_t nchan_full = 0; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { nchan_full = nchan_transport; @@ -649,12 +653,13 @@ ivas_error ivas_param_ism_dec_open( } } } +#ifndef NONBE_UNIFIED_DECODING_PATHS else { hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc = NULL; hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc = NULL; } - +#endif pop_wmops(); return error; } @@ -1204,8 +1209,11 @@ void ivas_param_ism_dec_digest_tc( } } } - - if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) + if ( st_ivas->hDecoderConfig->Opt_tsm +#ifndef NONBE_UNIFIED_DECODING_PATHS + || !st_ivas->hDecoderConfig->Opt_5ms +#endif + ) { /*TODO : FhG to check*/ ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, fade_len, transport_channels_f ); @@ -1216,7 +1224,11 @@ void ivas_param_ism_dec_digest_tc( /* CLDFB Analysis */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) + if ( st_ivas->hDecoderConfig->Opt_tsm +#ifndef NONBE_UNIFIED_DECODING_PATHS + || !st_ivas->hDecoderConfig->Opt_5ms +#endif + ) { float RealBuffer[CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 268b90f963d18efd5ed3a1ca845b5160d4d18ab6..2e025b1fcb50c26b51f39eddf0991bb713d47d9e 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -258,6 +258,10 @@ void ivas_ism_render_sf( int16_t tc_offset; int16_t interp_offset; float gain, prev_gain; +#ifdef UNIFY_CHANNEL_MEM_HEAP + float input_f[MAX_NUM_OBJECTS][L_FRAME48k]; + int16_t nchan_ism; +#endif num_objects = st_ivas->nchan_transport; if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -270,12 +274,26 @@ void ivas_ism_render_sf( tc_offset = st_ivas->hTcBuffer->n_samples_rendered; interp_offset = st_ivas->hTcBuffer->n_samples_rendered; +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_ism = st_ivas->nchan_ism; + for ( i = 0; i < nchan_ism; i++ ) + { + mvr2r( &st_ivas->hTcBuffer->tc[i][tc_offset], input_f[i], n_samples_to_render ); + } +#endif + for ( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { set_f( output_f[i], 0.0f, n_samples_to_render ); } - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) + if ( st_ivas->hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] +#endif + ) { ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); interp_offset = 0; @@ -284,7 +302,13 @@ void ivas_ism_render_sf( for ( i = 0; i < num_objects; i++ ) { /* Combined rotation: rotate the object positions depending the head and external orientations */ - if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + if ( st_ivas->hCombinedOrientationData != NULL && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 +#endif + ) { rotateAziEle( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[0], st_ivas->hIntSetup.is_planar_setup ); if ( st_ivas->hEFAPdata != NULL ) @@ -306,7 +330,11 @@ void ivas_ism_render_sf( if ( fabsf( gain ) > 0.0f || fabsf( prev_gain ) > 0.0f ) { g1 = &st_ivas->hIsmRendererData->interpolator[interp_offset]; +#ifdef UNIFY_CHANNEL_MEM_HEAP + tc = input_f[i]; +#else tc = &st_ivas->hTcBuffer->tc[i][tc_offset]; +#endif for ( k = 0; k < n_samples_to_render; k++ ) { g2 = 1.0f - *g1; @@ -315,12 +343,22 @@ void ivas_ism_render_sf( } /* update here only in case of head rotation */ - if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 ) + if ( st_ivas->hCombinedOrientationData != NULL && +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 +#else + st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] == 1 +#endif + ) { st_ivas->hIsmRendererData->prev_gains[i][j] = gain; } } } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_to_render ); +#endif return; } @@ -592,8 +630,11 @@ void ivas_omasa_separate_object_render( *-------------------------------------------------------------------------*/ void ivas_omasa_separate_object_render_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesRendered, /* i : number of samples rendered */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesRendered, /* i : number of samples rendered */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + float *input_f[], /* i : discrete object transport time signal */ +#endif float *output_f[], /* o : rendered time signal */ const int16_t subframes_rendered, /* i : number of subframes rendered */ const int16_t slots_rendered /* i : number of CLDFB slots rendered */ @@ -612,7 +653,9 @@ void ivas_omasa_separate_object_render_jbm( int16_t azimuth, elevation; int16_t num_objects; uint8_t single_separated; +#ifndef UNIFY_CHANNEL_MEM_HEAP float *input_f[MAX_TRANSPORT_CHANNELS]; +#endif float *output_f_local[MAX_OUTPUT_CHANNELS]; int16_t offsetSamples; int16_t n_samples_sf, md_idx; @@ -643,12 +686,12 @@ void ivas_omasa_separate_object_render_jbm( { output_f_local[j] = output_f[j]; } - +#ifndef UNIFY_CHANNEL_MEM_HEAP for ( obj = 0; obj < num_objects; obj++ ) { input_f[obj] = &st_ivas->hTcBuffer->tc[obj + 2][offsetSamples]; } - +#endif slots_to_render = nSamplesRendered / hSpatParamRendCom->slot_size; first_sf = subframes_rendered; last_sf = first_sf; @@ -661,6 +704,7 @@ void ivas_omasa_separate_object_render_jbm( for ( obj = 0; obj < num_objects; obj++ ) { +#ifndef UNIFY_CHANNEL_MEM_HEAP /* Delay the signal to match CLDFB delay. Delay the whole buffer with the first rendering call of the stretched buffer. */ if ( slots_rendered == 0 ) { @@ -669,7 +713,7 @@ void ivas_omasa_separate_object_render_jbm( tcBufferSize = hSpatParamRendCom->num_slots * hSpatParamRendCom->slot_size; delay_signal( input_f[obj], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer[obj], st_ivas->hMasaIsmData->delayBuffer_size ); } - +#endif offsetSamples = 0; for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index eccf5169c1992c83d4ef92f9580856622adcabbf..fdba671b78f3a2b66663275468080498fac3748f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -71,9 +71,11 @@ ivas_error ivas_jbm_dec_tc( ) { int16_t n, output_frame, nchan_out; - Decoder_State *st; /* used for bitstream handling */ - float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ + Decoder_State *st; /* used for bitstream handling */ + float *p_output[MAX_TRANSPORT_CHANNELS]; /* 'float' buffer for output synthesis */ +#ifndef UNIFY_CHANNEL_MEM_HEAP float output_f[MAX_TRANSPORT_CHANNELS][L_FRAME48k]; /* TODO: can be allocated dynamically using st_ivas->p_output_f */ +#endif int16_t nchan_remapped; int16_t nb_bits_metadata[MAX_SCE + 1]; int32_t output_Fs, ivas_total_brate; @@ -97,7 +99,11 @@ ivas_error ivas_jbm_dec_tc( for ( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + p_output[n] = st_ivas->p_output_f[n]; +#else p_output[n] = output_f[n]; +#endif } /*----------------------------------------------------------------* @@ -704,8 +710,11 @@ ivas_error ivas_jbm_dec_tc( /*----------------------------------------------------------------* * Write IVAS transport channels *----------------------------------------------------------------*/ - - if ( st_ivas->hDecoderConfig->Opt_tsm == 1 || !st_ivas->hDecoderConfig->Opt_5ms ) + if ( st_ivas->hDecoderConfig->Opt_tsm == 1 +#ifndef NONBE_UNIFIED_DECODING_PATHS + || !st_ivas->hDecoderConfig->Opt_5ms +#endif + ) { ivas_syn_output_f( p_output, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data ); } @@ -773,8 +782,11 @@ void ivas_jbm_dec_feed_tc_to_renderer( { p_data_f[n] = &data_f[n][0]; } - - if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) + if ( st_ivas->hDecoderConfig->Opt_tsm +#ifndef NONBE_UNIFIED_DECODING_PATHS + || !st_ivas->hDecoderConfig->Opt_5ms +#endif + ) { ivas_jbm_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data, p_data_f ); } @@ -830,11 +842,20 @@ void ivas_jbm_dec_feed_tc_to_renderer( ivas_ism_dec_digest_tc( st_ivas ); /* delay the objects here for all renderers where it is needed */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + if ( +#ifdef SPLIT_REND_WITH_HEAD_ROT + ( +#endif + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL +#ifdef SPLIT_REND_WITH_HEAD_ROT + ) && + ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + ) { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { @@ -870,6 +891,32 @@ void ivas_jbm_dec_feed_tc_to_renderer( { ivas_ism_dec_digest_tc( st_ivas ); } +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* delay discrete objects */ + if ( ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) || + ( st_ivas->renderer_type == RENDERER_DIRAC ) ) + { + int16_t num_objects, obj; + + + if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + num_objects = 1; + } + else + { + num_objects = st_ivas->nchan_ism; + } + for ( obj = 0; obj < num_objects; obj++ ) + { + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) + { + v_multc( st_ivas->hTcBuffer->tc[obj + 2], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[obj + 2], st_ivas->hTcBuffer->n_samples_available ); + } + delay_signal( st_ivas->hTcBuffer->tc[obj + 2], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[obj], st_ivas->hMasaIsmData->delayBuffer_size ); + } + } +#endif } else if ( st_ivas->ivas_format == MC_FORMAT ) { @@ -917,7 +964,9 @@ ivas_error ivas_jbm_dec_render( { int16_t n, nchan_out; int16_t nchan_transport; +#ifndef UNIFY_CHANNEL_MEM_HEAP float output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; /* 'float' buffer for output synthesis */ +#endif int16_t nchan_remapped; int32_t output_Fs; AUDIO_CONFIG output_config; @@ -926,6 +975,12 @@ ivas_error ivas_jbm_dec_render( float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; float *p_tc[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; +#ifdef UNIFY_CHANNEL_MEM_HEAP + int16_t output_offset; +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t nchan_out_syn_output; +#endif push_wmops( "ivas_dec_render" ); /*----------------------------------------------------------------* @@ -939,16 +994,35 @@ ivas_error ivas_jbm_dec_render( output_config = st_ivas->hDecoderConfig->output_config; nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; - for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* make sure we do not overwrite anything if we are w/o TSM and rendering in less than 20ms chunks*/ + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + output_offset = 0; + } + else { - p_output[n] = &output[n][0]; + output_offset = st_ivas->hTcBuffer->n_samples_rendered; } +#endif + + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) + for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) + { +#ifdef UNIFY_CHANNEL_MEM_HEAP + + p_output[n] = st_ivas->p_output_f[n] + output_offset; +#else + p_output[n] = &output[n][0]; +#endif + } for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) { p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered]; } +#ifndef NONBE_UNIFIED_DECODING_PATHS /*----------------------------------------------------------------* * Combine orientations *----------------------------------------------------------------*/ @@ -957,6 +1031,14 @@ ivas_error ivas_jbm_dec_render( { return error; } +#else + if ( st_ivas->hCombinedOrientationData != NULL ) + { + /* take the discard samples into account here to make sure head rotation stays on the correct 5ms grid */ + st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start -= st_ivas->hTcBuffer->n_samples_discard; + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); + } +#endif /*----------------------------------------------------------------* * Rendering @@ -1027,14 +1109,35 @@ ivas_error ivas_jbm_dec_render( /* Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, 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, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + 0 +#endif +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -1125,15 +1228,30 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_OSBA_STEREO ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + float output_stereo[CPE_CHANNELS][L_FRAME48k]; + float *p_output_stereo[CPE_CHANNELS]; + for ( n = 0; n < CPE_CHANNELS; n++ ) + { + p_output_stereo[n] = output_stereo[n]; + } +#endif *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); /* render objects */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + ivas_ism_render_sf( st_ivas, p_output_stereo, *nSamplesRendered ); +#else ivas_ism_render_sf( st_ivas, p_output, *nSamplesRendered ); - +#endif /* add already rendererd SBA part */ for ( n = 0; n < nchan_out; n++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + v_add( p_output_stereo[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); +#else v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); +#endif } } else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) @@ -1145,17 +1263,26 @@ ivas_error ivas_jbm_dec_render( { p_output_ism[n] = &output_ism[n][0]; } +#ifdef UNIFY_CHANNEL_MEM_HEAP +#ifdef OSBA_ROOM_IR + if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) +#endif + { + ivas_ism_render_sf( st_ivas, p_output_ism, *nSamplesRendered ); + } +#endif if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) { return error; } +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) { ivas_ism_render_sf( st_ivas, p_output_ism, *nSamplesRendered ); } - +#endif for ( n = 0; n < nchan_out; n++ ) { if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) @@ -1203,11 +1330,19 @@ ivas_error ivas_jbm_dec_render( #endif for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + mvr2r( p_output[n], p_output[n + st_ivas->nchan_ism], *nSamplesRendered ); +#else mvr2r( output[n], output[n + st_ivas->nchan_ism], *nSamplesRendered ); +#endif } for ( n = 0; n < st_ivas->nchan_ism; n++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + set_zero( p_output[n], *nSamplesRendered ); +#else set_zero( output[n], *nSamplesRendered ); +#endif } } } @@ -1230,13 +1365,35 @@ 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->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; + if ( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } } + else + { +#endif + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + 0 +#endif +#endif + ) ) != IVAS_ERR_OK ) + { + return error; + } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } else if ( st_ivas->renderer_type == RENDERER_MC ) { @@ -1249,18 +1406,33 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { ivas_mc_paramupmix_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_tc, p_output ); + if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) { ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, *nSamplesRendered, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); @@ -1287,12 +1459,26 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - if ( ( ivas_td_binaural_renderer( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - return error; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } } + else + { +#endif + if ( ( error = ivas_td_binaural_renderer( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif } } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) @@ -1315,9 +1501,17 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { /* we still need to copy the separate channel if available */ - if ( st_ivas->hOutSetup.separateChannelEnabled ) + if ( st_ivas->hOutSetup.separateChannelEnabled +#ifdef UNIFY_CHANNEL_MEM_HEAP + && st_ivas->hDecoderConfig->Opt_tsm /* w/o TSM they are already in the correct buffers */ +#endif + ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); } @@ -1325,25 +1519,42 @@ ivas_error ivas_jbm_dec_render( { for ( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; n++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + set_zero( p_output[n], *nSamplesRendered ); +#else set_zero( output[n], *nSamplesRendered ); +#endif } } } /* copy discrete C and TD LFE from internal TC to output */ - if ( st_ivas->hOutSetup.separateChannelEnabled ) + if ( st_ivas->hOutSetup.separateChannelEnabled +#ifdef UNIFY_CHANNEL_MEM_HEAP + && st_ivas->hDecoderConfig->Opt_tsm /* w/o TSM they are already in the correct buffers */ +#endif + ) { if ( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || output_config == IVAS_AUDIO_CONFIG_5_1_2 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL] + offset, p_output[LFE_CHANNEL], *nSamplesRendered ); + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL] + offset, output[LFE_CHANNEL], *nSamplesRendered ); mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } else if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } } } @@ -1358,6 +1569,11 @@ ivas_error ivas_jbm_dec_render( st_ivas->hTcBuffer->n_samples_available -= *nSamplesRendered; st_ivas->hTcBuffer->n_samples_rendered += *nSamplesRendered; +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update global combined orientation start index */ + ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); +#endif + if ( st_ivas->hTcBuffer->n_samples_discard > 0 ) { for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) @@ -1369,6 +1585,15 @@ ivas_error ivas_jbm_dec_render( } #ifdef SPLIT_REND_WITH_HEAD_ROT + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses; + } + else + { + nchan_out_syn_output = nchan_out; + } + if ( st_ivas->hDecoderConfig->Opt_Limiter ) #endif { @@ -1389,7 +1614,7 @@ ivas_error ivas_jbm_dec_render( st_ivas->noClipping += #endif #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_syn_output( p_output, *nSamplesRendered, nchan_out, (int16_t *) data ); + ivas_syn_output( p_output, *nSamplesRendered, nchan_out_syn_output, (int16_t *) data ); #else ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); #endif @@ -1397,7 +1622,7 @@ ivas_error ivas_jbm_dec_render( #ifdef SPLIT_REND_WITH_HEAD_ROT break; case PCM_FLOAT32: - ivas_syn_output_f( p_output, *nSamplesRendered, nchan_out, (float *) data ); + ivas_syn_output_f( p_output, *nSamplesRendered, nchan_out_syn_output, (float *) data ); break; default: error = IVAS_ERR_UNKNOWN; @@ -1454,6 +1679,10 @@ ivas_error ivas_jbm_dec_flush_renderer( n_samples_still_available -= n_samples_to_render; assert( n_samples_still_available < tc_granularity_new ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); +#endif + if ( n_slots_still_available ) { int16_t ch_idx; @@ -1507,7 +1736,14 @@ ivas_error ivas_jbm_dec_flush_renderer( ivas_ism_render_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ); if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, 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 ) + NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + 0 +#endif +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -1527,7 +1763,14 @@ 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->hCombinedOrientationData, - hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + 0 +#endif +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -1629,6 +1872,11 @@ ivas_error ivas_jbm_dec_flush_renderer( #endif } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update global combined orientation start index */ + ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); +#endif + *nSamplesRendered = n_samples_to_render; /* Only write out the valid data*/ @@ -1911,12 +2159,19 @@ void ivas_jbm_dec_get_md_map_even_spacing( int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + , + int16_t *nchan_transport_jbm, /* o : number of TSM channels */ + int16_t *nchan_transport_internal, /* o : number of internal channels (i.e. plus e.g. addtl. decorr */ + int16_t *nchan_transport_full /* o : number of channels to allocate fully */ +#endif ) { int16_t num_tc; int32_t ivas_total_brate; AUDIO_CONFIG output_config; + if ( st_ivas->renderer_type == RENDERER_DISABLE ) { num_tc = st_ivas->hDecoderConfig->nchan_out; @@ -1925,6 +2180,10 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc = st_ivas->nchan_transport; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -1937,7 +2196,32 @@ int16_t ivas_jbm_dec_get_num_tc_channels( if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { num_tc = 1; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif + } +#ifdef UNIFY_CHANNEL_MEM_HEAP + else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + if ( st_ivas->renderer_type == RENDERER_DISABLE ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + *nchan_transport_full = num_tc; + *nchan_transport_internal = num_tc; + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + else + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = 0; + } } +#endif } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { @@ -1962,6 +2246,50 @@ int16_t ivas_jbm_dec_get_num_tc_channels( num_tc++; } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + if ( st_ivas->ivas_format == SBA_FORMAT ) + { + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS; + *nchan_transport_full = *nchan_transport_internal; + } + else + { + int16_t sba_order_internal, num_channels_internal; + sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); + num_channels_internal = ivas_sba_get_nchan_metadata( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate ); + *nchan_transport_internal = num_channels_internal; + *nchan_transport_full = num_channels_internal; + } + } + else if ( st_ivas->ivas_format == MASA_FORMAT && ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) ) + { + *nchan_transport_internal += 1; + *nchan_transport_full += 1; + } + else + { + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS; + *nchan_transport_full = *nchan_transport_internal; + } + else + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + } +#endif } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { @@ -1975,7 +2303,35 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc += st_ivas->nchan_ism; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + + if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + { + num_tc = 1; + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS + 2; + *nchan_transport_full = *nchan_transport_internal; + } + else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + *nchan_transport_internal += 1; + *nchan_transport_full += 1; + } +#endif + } +#ifdef UNIFY_CHANNEL_MEM_HEAP + else + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; } +#endif } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -1991,16 +2347,58 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc += st_ivas->nchan_ism; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_full = num_tc; + *nchan_transport_internal = num_tc; + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + { + if ( ( st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism; + *nchan_transport_full = num_tc; + *nchan_transport_internal = num_tc; + } + else + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + *nchan_transport_full = num_tc; + *nchan_transport_internal = num_tc; + } + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS; + *nchan_transport_full = *nchan_transport_internal; + } + else + { + *nchan_transport_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + *nchan_transport_internal += st_ivas->nchan_ism; + *nchan_transport_full = *nchan_transport_internal; + } + } +#endif } else if ( st_ivas->ivas_format == MC_FORMAT ) { if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) { num_tc = 1; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif } else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) { num_tc = 2; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif } else if ( st_ivas->mc_mode == MC_MODE_MCT ) { @@ -2020,6 +2418,10 @@ int16_t ivas_jbm_dec_get_num_tc_channels( else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { num_tc = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = MC_PARAMUPMIX_MAX_INPUT_CHANS; + *nchan_transport_full = MC_PARAMUPMIX_MAX_INPUT_CHANS; +#endif } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { @@ -2034,13 +2436,41 @@ int16_t ivas_jbm_dec_get_num_tc_channels( /* LFE is synthesized in TD with the TCs*/ num_tc++; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + { + num_tc = st_ivas->hDecoderConfig->nchan_out; + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + { + *nchan_transport_internal = 2 * BINAURAL_CHANNELS; + *nchan_transport_full = *nchan_transport_internal; + } +#endif + } +#ifdef UNIFY_CHANNEL_MEM_HEAP + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + *nchan_transport_internal = num_tc; + *nchan_transport_full = 0; } +#endif } else if ( st_ivas->ivas_format == MONO_FORMAT && st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX ) { num_tc = MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_internal = num_tc; + *nchan_transport_full = num_tc; +#endif } - +#ifdef UNIFY_CHANNEL_MEM_HEAP + *nchan_transport_jbm = num_tc; +#endif return num_tc; } @@ -2112,14 +2542,36 @@ static void ivas_jbm_dec_copy_tc( /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( +#ifdef UNIFY_CHANNEL_MEM_HEAP + Decoder_Struct *st_ivas /* i : main decoder structure */ +#else const RENDERER_TYPE rendererType, /* i : renderer type */ const IVAS_FORMAT ivas_format, /* i : ivas format */ const MC_MODE mc_mode, /* i : MC mode */ const int32_t output_Fs /* i : sampling rate */ +#endif ) { int16_t render_granularity; +#ifdef UNIFY_CHANNEL_MEM_HEAP + render_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + { + if ( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) ) + { + render_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + } + else + { + render_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + } + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + render_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ + } +#else if ( rendererType == RENDERER_BINAURAL_OBJECTS_TD || rendererType == RENDERER_BINAURAL_MIXER_CONV || rendererType == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { if ( ( ivas_format == MC_FORMAT ) && ( mc_mode == MC_MODE_PARAMUPMIX ) ) @@ -2135,6 +2587,7 @@ int16_t ivas_jbm_dec_get_render_granularity( { render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); } +#endif return render_granularity; } @@ -2189,6 +2642,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->num_slots = nMaxSlotsPerSubframe * MAX_PARAM_SPATIAL_SUBFRAMES; set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + hTcBuffer->tc_buffer = NULL; +#endif if ( hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_NONE ) { @@ -2199,20 +2655,38 @@ ivas_error ivas_jbm_dec_tc_buffer_open( hTcBuffer->tc[ch_idx] = NULL; } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + else if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + /* we can directly use the already allocated in/out buffers */ + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = st_ivas->p_output_f[ch_idx]; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } + } +#endif else { int16_t n_samp_full, n_samp_residual; int32_t offset; +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->hDecoderConfig->Opt_tsm ) { +#endif n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); n_samp_residual = hTcBuffer->n_samples_granularity - 1; +#ifndef UNIFY_CHANNEL_MEM_HEAP } else { n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); n_samp_residual = 0; } +#endif nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; @@ -2265,20 +2739,36 @@ ivas_error ivas_jbm_dec_tc_buffer_open( *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef UNIFY_CHANNEL_MEM_HEAP + , 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 */ +#endif ) { int16_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; int16_t ch_idx; DECODER_TC_BUFFER_HANDLE hTcBuffer; +#ifdef UNIFY_CHANNEL_MEM_HEAP + int16_t nchan_transport_jbm; + int16_t nchan_transport_internal; + int16_t nchan_full; + int16_t n_samples_granularity; + TC_BUFFER_MODE tc_buffer_mode; +#endif hTcBuffer = st_ivas->hTcBuffer; +#ifdef UNIFY_CHANNEL_MEM_HEAP + ivas_jbm_dec_get_num_tc_channels( st_ivas, &nchan_transport_jbm, &nchan_transport_internal, &nchan_full ); + tc_buffer_mode = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + n_samples_granularity = ivas_jbm_dec_get_render_granularity( st_ivas ); +#endif + /* if granularity changes, adapt subframe_nb_slots */ if ( n_samples_granularity != hTcBuffer->n_samples_granularity ) { @@ -2312,58 +2802,105 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( } } - hTcBuffer->tc_buffer_mode = tc_buffer_mode; - hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; - hTcBuffer->nchan_transport_internal = nchan_transport_internal; - 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 ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( nchan_transport_jbm != hTcBuffer->nchan_transport_jbm || nchan_transport_internal != hTcBuffer->nchan_transport_internal || nchan_full != hTcBuffer->nchan_buffer_full || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode || n_samples_granularity != st_ivas->hTcBuffer->n_samples_granularity ) + { #endif + hTcBuffer->tc_buffer_mode = tc_buffer_mode; + hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; + hTcBuffer->nchan_transport_internal = nchan_transport_internal; + hTcBuffer->nchan_buffer_full = nchan_full; + nchan_residual = nchan_transport_internal - nchan_full; + hTcBuffer->n_samples_granularity = n_samples_granularity; - /* realloc buffers */ - if ( hTcBuffer->tc_buffer ) - { - free( hTcBuffer->tc_buffer ); - } - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); - n_samp_residual = hTcBuffer->n_samples_granularity - 1; - } - else - { - n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); - n_samp_residual = 0; - } - nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; - nsamp_to_allocate += nchan_residual * n_samp_residual; +#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 +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + /* we can directly use the already allocated in/out buffers */ + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = st_ivas->p_output_f[ch_idx]; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } + } - 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 ); + else + { +#endif + /* realloc buffers */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( hTcBuffer->tc_buffer != NULL ) + { +#endif + free( hTcBuffer->tc_buffer ); + hTcBuffer->tc_buffer = NULL; +#ifdef NONBE_UNIFIED_DECODING_PATHS + } +#endif +#ifndef UNIFY_CHANNEL_MEM_HEAP + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { +#endif + n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); + n_samp_residual = hTcBuffer->n_samples_granularity - 1; +#ifndef UNIFY_CHANNEL_MEM_HEAP + } + else + { + n_samp_full = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + n_samp_residual = 0; + } +#endif + nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; + nsamp_to_allocate += nchan_residual * n_samp_residual; - offset = 0; - for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_full; - } - for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_residual; - } +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( nsamp_to_allocate == 0 ) + { + hTcBuffer->tc_buffer = NULL; + for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } + } + else + { +#endif + 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 ); - for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = NULL; + offset = 0; + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_full; + } + for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_residual; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } +#ifdef NONBE_UNIFIED_DECODING_PATHS + } +#endif +#ifdef UNIFY_CHANNEL_MEM_HEAP + } } - +#endif return IVAS_ERR_OK; } @@ -2505,8 +3042,21 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( { /* all renderers where we are done after TC decoding (might include DMX to mono/stereo */ case RENDERER_DISABLE: +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMUPMIX && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) ) + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + } + else + { + buffer_mode = TC_BUFFER_MODE_BUFFER; + } + break; +#endif case RENDERER_MCMASA_MONO_STEREO: +#ifndef UNIFY_CHANNEL_MEM_HEAP case RENDERER_OSBA_STEREO: +#endif case RENDERER_MONO_DOWNMIX: buffer_mode = TC_BUFFER_MODE_BUFFER; break; @@ -2546,11 +3096,21 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( } break; case RENDERER_MC: +#ifdef UNIFY_CHANNEL_MEM_HEAP + { + int16_t num_tc, tmp1, tmp2; + ivas_jbm_dec_get_num_tc_channels( st_ivas, &num_tc, &tmp1, &tmp2 ); + if ( num_tc != st_ivas->hDecoderConfig->nchan_out ) +#else if ( ivas_jbm_dec_get_num_tc_channels( st_ivas ) != st_ivas->hDecoderConfig->nchan_out ) +#endif { buffer_mode = TC_BUFFER_MODE_RENDERER; } - break; +#ifdef UNIFY_CHANNEL_MEM_HEAP + } +#endif + break; case RENDERER_SBA_LINEAR_ENC: if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT && ( st_ivas->renderer_type == RENDERER_MC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) && ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ) ) { @@ -2571,6 +3131,18 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( buffer_mode = TC_BUFFER_MODE_RENDERER; } break; +#ifdef UNIFY_CHANNEL_MEM_HEAP + case RENDERER_OSBA_STEREO: + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + buffer_mode = TC_BUFFER_MODE_RENDERER; + } + else + { + buffer_mode = TC_BUFFER_MODE_BUFFER; + } + break; +#endif #ifdef DEBUGGING default: assert( 0 ); @@ -2603,12 +3175,14 @@ void ivas_jbm_dec_copy_tc_no_tsm( hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; n_ch_full_copy = min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); n_ch_cldfb = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; + /* copy full tcs*/ for ( ch_idx = 0; ch_idx < n_ch_full_copy; ch_idx++ ) { +#ifndef UNIFY_CHANNEL_MEM_HEAP mvr2r( tc[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], hTcBuffer->n_samples_buffered ); +#endif } - /* CLDFB ana for ParamMC/ParamISM */ if ( n_ch_cldfb > 0 ) { diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 5c5411a41f97710315f348d6ccdfcea898f073b6..56af0502f0fca93bbb646372b3f43f23c8a80a0c 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -621,8 +621,13 @@ ivas_error ivas_masa_dec_open( st_ivas->hMasa = hMasa; +#ifndef UNIFY_CHANNEL_MEM_HEAP /* allocate transport channels*/ - if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) + if ( +#ifndef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hDecoderConfig->Opt_5ms && +#endif + st_ivas->hTcBuffer == NULL && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC ) { int16_t nchan_to_allocate, nchan_transport; TC_BUFFER_MODE buffer_mode; @@ -656,6 +661,7 @@ ivas_error ivas_masa_dec_open( return error; } } +#endif return error; } @@ -1258,7 +1264,9 @@ ivas_error ivas_masa_dec_reconfigure( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) +#endif { if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) { @@ -1450,20 +1458,29 @@ ivas_error ivas_masa_dec_reconfigure( st_ivas->ism_mode = ISM_MODE_NONE; } +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) +#endif { +#ifndef UNIFY_CHANNEL_MEM_HEAP int16_t tc_nchan_to_allocate; int16_t tc_nchan_transport; TC_BUFFER_MODE buffer_mode_new; +#endif int16_t n_samples_granularity; +#ifdef UNIFY_CHANNEL_MEM_HEAP + n_samples_granularity = ivas_jbm_dec_get_render_granularity( st_ivas ); +#else n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); 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; +#endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS + 2; @@ -1472,11 +1489,12 @@ ivas_error ivas_masa_dec_reconfigure( { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } - +#endif if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { +#ifndef UNIFY_CHANNEL_MEM_HEAP n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ - +#endif if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) @@ -1500,12 +1518,24 @@ ivas_error ivas_masa_dec_reconfigure( } } } +#ifndef UNIFY_CHANNEL_MEM_HEAP else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) { /* addtl channel for CNG */ tc_nchan_to_allocate++; } +#endif + + +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( st_ivas->ivas_format != MASA_ISM_FORMAT ) + { + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#else 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, n_samples_granularity ) ) != IVAS_ERR_OK ) @@ -1513,14 +1543,19 @@ ivas_error ivas_masa_dec_reconfigure( return error; } } +#endif - if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) - { - mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); - st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) + { + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + } +#ifdef UNIFY_CHANNEL_MEM_HEAP } +#endif +#ifndef UNIFY_CHANNEL_MEM_HEAP if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size; @@ -1530,6 +1565,7 @@ ivas_error ivas_masa_dec_reconfigure( st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier; } } +#endif } return error; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index cfc070a02ff21f949900e5c710f39856e24cda31..443363934a9af02d39407889af6562f61fc81f33 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -439,7 +439,11 @@ ivas_error ivas_param_mc_dec_open( ivas_param_mc_dec_init( hParamMC, nchan_transport, nchan_out_cov ); - if ( st_ivas->hDecoderConfig->Opt_5ms && hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) + if ( +#ifndef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hDecoderConfig->Opt_5ms && +#endif + hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) { int16_t n_cldfb_slots; @@ -460,6 +464,7 @@ ivas_error ivas_param_mc_dec_open( } set_zero( hParamMC->Cldfb_ImagBuffer_tc, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); +#ifndef UNIFY_CHANNEL_MEM_HEAP 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 ) @@ -467,6 +472,7 @@ ivas_error ivas_param_mc_dec_open( return error; } } +#endif } else { @@ -1434,7 +1440,11 @@ void ivas_param_mc_dec_digest_tc( /* slot loop for gathering the input data */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { - if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) + if ( st_ivas->hDecoderConfig->Opt_tsm +#ifndef NONBE_UNIFIED_DECODING_PATHS + || !st_ivas->hDecoderConfig->Opt_5ms +#endif + ) { float RealBuffer[CLDFB_NO_CHANNELS_MAX]; float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; @@ -1745,23 +1755,19 @@ void ivas_param_mc_dec_render( } #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, NULL, st_ivas->hCombinedOrientationData, subframe_idx, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); - -#else - ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframe_idx, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); - -#endif - -#else ivas_binRenderer( st_ivas->hBinRenderer, +#ifdef SPLIT_REND_WITH_HEAD_ROT + &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, #endif - st_ivas->hCombinedOrientationData, subframe_idx, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #endif - + st_ivas->hCombinedOrientationData, +#ifndef NONBE_UNIFIED_DECODING_PATHS + subframe_idx, +#endif + hParamMC->subframe_nbslots[subframe_idx], + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { @@ -1778,6 +1784,10 @@ void ivas_param_mc_dec_render( } } } +#endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); #endif } else if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index f3640d5a6990017a9b77c15d23fecc3874a5b563..84ca0dd9cb0fb67d821e96f430185e1b9e1a5b84 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -351,20 +351,21 @@ void ivas_mc_paramupmix_dec( #endif /* Implement binaural rendering */ + ivas_binRenderer( st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, /* TODO (5ms) : tmu2Dlb please verify */ JBM_CLDFB_SLOTS_IN_SUBFRAME, NULL, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); -#else - ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, /* TODO (5ms) : tmu2Dlb please verify */ JBM_CLDFB_SLOTS_IN_SUBFRAME, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); + &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #endif -#else - ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, /* TODO (5ms) : tmu2Dlb please verify */ JBM_CLDFB_SLOTS_IN_SUBFRAME, + st_ivas->hCombinedOrientationData, +#ifndef NONBE_UNIFIED_DECODING_PATHS + subframeIdx, /* TODO (5ms) : tmu2Dlb please verify */ +#endif + JBM_CLDFB_SLOTS_IN_SUBFRAME, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, #endif - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); -#endif - + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, + Cldfb_RealBuffer_subfr, + Cldfb_ImagBuffer_subfr ); #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { @@ -383,7 +384,10 @@ void ivas_mc_paramupmix_dec( } } #endif - +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, maxBand * MAX_PARAM_SPATIAL_SUBFRAMES ); +#endif /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -444,9 +448,17 @@ void ivas_mc_paramupmix_dec( } #ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC +#ifdef UNIFY_CHANNEL_MEM_HEAP + for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers_dec( st_ivas, -1, -1, TC_BUFFER_NUM_FULL_CHAN_DONT_COUNT ); ch++ ) +#else for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); ch++ ) +#endif +#else +#ifdef UNIFY_CHANNEL_MEM_HEAP + for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_DONT_COUNT ); ch++ ) #else for ( ch = first_empty_channel; ch < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); ch++ ) +#endif #endif { set_f( output_f[ch], 0.0f, output_frame ); @@ -566,6 +578,10 @@ void ivas_mc_paramupmix_dec_render( { output_f_local[ch] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); +#endif } for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) @@ -662,7 +678,9 @@ ivas_error ivas_mc_paramupmix_dec_open( hMCParamUpmix->free_param_interpolator = 0; hMCParamUpmix->param_interpolator = NULL; +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) +#endif { if ( ( hMCParamUpmix->param_interpolator = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * sizeof( float ) ) ) == NULL ) { @@ -673,7 +691,13 @@ ivas_error ivas_mc_paramupmix_dec_open( ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator ); } - if ( st_ivas->hDecoderConfig->Opt_5ms == 1 && st_ivas->hTcBuffer == NULL ) + +#ifndef UNIFY_CHANNEL_MEM_HEAP + if ( +#ifndef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hDecoderConfig->Opt_5ms == 1 && +#endif + st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; int16_t nchan_tc; @@ -699,7 +723,7 @@ ivas_error ivas_mc_paramupmix_dec_open( return error; } } - +#endif st_ivas->hMCParamUpmix = hMCParamUpmix; return error; @@ -1141,12 +1165,18 @@ static void ivas_mc_paramupmix_dec_sf( #endif /* Implement binaural rendering */ + ivas_binRenderer( st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_binRenderer( st_ivas->hBinRenderer, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); -#else - ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); + &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #endif - + st_ivas->hCombinedOrientationData, +#ifndef NONBE_UNIFIED_DECODING_PATHS + subframeIdx, +#endif + st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, + Cldfb_RealBuffer_subfr, + Cldfb_ImagBuffer_subfr ); #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 51b8fde619bc586840d71c9b108308f3116f7bbc..8430ff1f7326880e92b00cbba35d63f1a4565f46 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -725,9 +725,11 @@ static ivas_error ivas_mc_dec_reconfig( Decoder_State *st; ivas_error error; MC_MODE mc_mode, last_mc_mode; +#ifndef UNIFY_CHANNEL_MEM_HEAP TC_BUFFER_MODE tc_buffer_mode_new; int16_t tc_nchan_tc_new; int16_t tc_nchan_allocate_new; +#endif int16_t tc_granularity_new; AUDIO_CONFIG intern_config_old; IVAS_OUTPUT_SETUP hIntSetupOld; @@ -776,7 +778,9 @@ static ivas_error ivas_mc_dec_reconfig( /* side effect of the renderer selection can be a changed internal config */ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { /* transfer subframe info from DirAC or ParamMC to central tc buffer */ if ( last_mc_mode == MC_MODE_PARAMMC ) @@ -798,7 +802,11 @@ static ivas_error ivas_mc_dec_reconfig( /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas ); +#else tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); +#endif if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1323,9 +1331,16 @@ static ivas_error ivas_mc_dec_reconfig( /*-----------------------------------------------------------------* * JBM TC buffers *-----------------------------------------------------------------*/ - +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) +#endif { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#else int16_t tc_nchan_full_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; @@ -1368,7 +1383,7 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } - +#endif /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hSpatParamRendCom != NULL ) { @@ -1388,15 +1403,20 @@ static ivas_error ivas_mc_dec_reconfig( } } -#ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC + /*-----------------------------------------------------------------* * floating-point output audio buffers *-----------------------------------------------------------------*/ - +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_5ms ) +#endif { #ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1, TC_BUFFER_NUM_FULL_CHAN_UNKNOWN ); +#else nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); +#endif if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) { @@ -1404,7 +1424,11 @@ static ivas_error ivas_mc_dec_reconfig( } #else int16_t nchan_out_buff, ch; +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_UNKNOWN ); +#else nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif if ( nchan_out_buff > nchan_out_buf_old ) { @@ -1427,7 +1451,6 @@ static ivas_error ivas_mc_dec_reconfig( } #endif } -#endif return error; } diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 11e71c925c6fed7f9f39f1555381275b4b973586..7b03284e88baca92dfca21af1e0244ba18debb96 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -99,10 +99,15 @@ ivas_error ivas_td_binaural_renderer( } return ivas_td_binaural_renderer_unwrap( st_ivas->hReverb, st_ivas->transport_config, st_ivas->hBinRendererTd, nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hCombinedOrientationData, +#else ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation : NULL, ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL, - ism_md_subframe_update, output, output_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); +#endif + ism_md_subframe_update, output, output_frame, + MAX_PARAM_SPATIAL_SUBFRAMES ); } @@ -221,9 +226,16 @@ ivas_error ivas_td_binaural_renderer_sf( /* Update the listener's location/orientation */ if ( ( error = TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, +#ifdef NONBE_UNIFIED_DECODING_PATHS + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] : 0, + ( st_ivas->hCombinedOrientationData != NULL ) ? &st_ivas->hCombinedOrientationData->Quaternions[st_ivas->hCombinedOrientationData->subframe_idx] : NULL, + ( st_ivas->hCombinedOrientationData != NULL ) ? &st_ivas->hCombinedOrientationData->listenerPos[st_ivas->hCombinedOrientationData->subframe_idx] : NULL +#else ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] : 0, ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->Quaternions : NULL, - ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL ) ) != IVAS_ERR_OK ) + ( st_ivas->hCombinedOrientationData != NULL ) ? st_ivas->hCombinedOrientationData->listenerPos : NULL +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -261,9 +273,139 @@ ivas_error ivas_td_binaural_renderer_sf( { output_f_local[ch] += output_frame; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, output_frame ); +#endif } st_ivas->hTcBuffer->subframes_rendered = last_sf; return IVAS_ERR_OK; } + +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * ivas_td_binaural_renderer_sf_splitBinaural() + * + * Render to multiple binaural pairs based on relative head positions for split rendering. + *---------------------------------------------------------------------*/ + +ivas_error ivas_td_binaural_renderer_sf_splitBinaural( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + int16_t nSamplesRendered /* i : number of samples to render */ +) +{ + int16_t i; + int16_t pos_idx; + IVAS_QUATERNION originalHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; + BINAURAL_TD_OBJECT_RENDERER_HANDLE origTdRendHandle; + ivas_error error; + int16_t original_subframes_rendered; + int16_t original_slots_rendered; + float *p_bin_output[BINAURAL_CHANNELS]; + + push_wmops( "ivas_td_binaural_renderer_sf_splitBinaural" ); + + pMultiBinPoseData = &st_ivas->hSplitBinRend.splitrend.multiBinPoseData; + + /* If not yet allocated, open additional instances of TD renderer */ + for ( i = 0; i < pMultiBinPoseData->num_poses - 1; ++i ) + { + if ( st_ivas->hSplitBinRend.splitrend.hTdRendHandles[i] != NULL ) + { + continue; + } + + if ( ( error = ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, + st_ivas->hDecoderConfig->output_Fs, + st_ivas->nchan_transport, + st_ivas->ivas_format, + st_ivas->transport_config, + st_ivas->hRenderConfig->directivity, + st_ivas->hTransSetup, + &st_ivas->hSplitBinRend.splitrend.hTdRendHandles[i], + &st_ivas->binaural_latency_ns ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* Save current head positions */ + for ( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + originalHeadRot[i] = st_ivas->hCombinedOrientationData->Quaternions[i]; + } + + original_subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + original_slots_rendered = st_ivas->hTcBuffer->slots_rendered; + origTdRendHandle = st_ivas->hBinRendererTd; + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; pos_idx++ ) + { + /* Update head positions */ + if ( pos_idx != 0 ) + { + for ( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + if ( originalHeadRot[i].w == -3.0f ) + { + st_ivas->hCombinedOrientationData->Quaternions[i].w = -3.0f; + st_ivas->hCombinedOrientationData->Quaternions[i].x = originalHeadRot[i].x + pMultiBinPoseData->relative_head_poses[pos_idx][0]; + st_ivas->hCombinedOrientationData->Quaternions[i].y = originalHeadRot[i].y + pMultiBinPoseData->relative_head_poses[pos_idx][1]; + st_ivas->hCombinedOrientationData->Quaternions[i].z = originalHeadRot[i].z + pMultiBinPoseData->relative_head_poses[pos_idx][2]; + } + else + { + st_ivas->hCombinedOrientationData->Quaternions[i].w = -3.0f; + + Quat2EulerDegree( originalHeadRot[i], /* TODO tmu : fix bug with ordering*/ + &st_ivas->hCombinedOrientationData->Quaternions[i].z, + &st_ivas->hCombinedOrientationData->Quaternions[i].y, + &st_ivas->hCombinedOrientationData->Quaternions[i].x ); + + st_ivas->hCombinedOrientationData->Quaternions[i].x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + st_ivas->hCombinedOrientationData->Quaternions[i].y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + st_ivas->hCombinedOrientationData->Quaternions[i].z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + } + } + } + + /* set output channels */ + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + p_bin_output[i] = output[pos_idx * BINAURAL_CHANNELS + i]; + } + st_ivas->hTcBuffer->subframes_rendered = original_subframes_rendered; + st_ivas->hTcBuffer->slots_rendered = original_slots_rendered; + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); + + /* Render */ + if ( pos_idx != 0 ) + { + st_ivas->hBinRendererTd = st_ivas->hSplitBinRend.splitrend.hTdRendHandles[pos_idx - 1]; + } + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_bin_output, nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + + /* Restore original head rotation */ + for ( i = 0; i < st_ivas->hCombinedOrientationData->num_subframes; ++i ) + { + st_ivas->hCombinedOrientationData->Quaternions[i] = originalHeadRot[i]; + } + /* restore original td renderer handle */ + st_ivas->hBinRendererTd = origTdRendHandle; + + pop_wmops(); + + return IVAS_ERR_OK; +} +#endif +#endif diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 81b8789335bf51f1dedb086cc942f29b85c4a507..6a67557e0bd727cb5327ff783e328ff047dcf57d 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -47,8 +47,9 @@ * Local constants *------------------------------------------------------------------------*/ +#ifndef UNIFY_CHANNEL_MEM_HEAP #define OMASA_TDREND_MATCHING_GAIN 0.7943f - +#endif /*-------------------------------------------------------------------* * ivas_omasa_data_open() @@ -182,8 +183,12 @@ ivas_error ivas_omasa_dec_config( ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); #ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); +#else +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hTcBuffer->nchan_buffer_full ); #else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif #endif st_ivas->ivas_format = ivas_format_orig; @@ -404,18 +409,27 @@ ivas_error ivas_omasa_dec_config( /*-----------------------------------------------------------------* * floating-point output audio buffers *-----------------------------------------------------------------*/ - +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_5ms ) +#endif { + #ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1, TC_BUFFER_NUM_FULL_CHAN_UNKNOWN ); +#else nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); - +#endif if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) { return error; } +#else +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_UNKNOWN ); #else nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif if ( nchan_out_buff > nchan_out_buff_old ) { @@ -440,6 +454,31 @@ ivas_error ivas_omasa_dec_config( } } +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) + { + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + } + + + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size; + int16_t n; + for ( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ ) + { + st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier; + } + } +#endif + return IVAS_ERR_OK; } @@ -661,13 +700,43 @@ void ivas_omasa_dirac_rend_jbm( { int16_t subframes_rendered; int16_t slots_rendered; +#ifdef UNIFY_CHANNEL_MEM_HEAP + float discrete_objects_f[MAX_NUM_OBJECTS][L_FRAME48k]; + float *p_discrete_objects_f[MAX_NUM_OBJECTS]; + int16_t num_objects, offsetSamples, obj, slots_to_render; + + if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + num_objects = 1; + } + else + { + num_objects = st_ivas->nchan_ism; + } +#endif subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; +#ifdef UNIFY_CHANNEL_MEM_HEAP + offsetSamples = slots_rendered * st_ivas->hSpatParamRendCom->slot_size; + slots_to_render = min( st_ivas->hSpatParamRendCom->num_slots - st_ivas->hSpatParamRendCom->slots_rendered, nSamplesAsked / st_ivas->hSpatParamRendCom->slot_size ); + *nSamplesRendered = slots_to_render * st_ivas->hSpatParamRendCom->slot_size; + + for ( obj = 0; obj < num_objects; obj++ ) + { + p_discrete_objects_f[obj] = discrete_objects_f[obj]; + mvr2r( &st_ivas->hTcBuffer->tc[obj + 2][offsetSamples], p_discrete_objects_f[obj], *nSamplesRendered ); + } +#endif + ivas_dirac_dec_render( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_f ); +#ifdef UNIFY_CHANNEL_MEM_HEAP + ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, p_discrete_objects_f, output_f, subframes_rendered, slots_rendered ); +#else ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, output_f, subframes_rendered, slots_rendered ); +#endif return; } @@ -709,6 +778,9 @@ ivas_error ivas_omasa_dirac_td_binaural( ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); +#endif if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK ) { return error; @@ -739,17 +811,30 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( ) { int16_t n; +#ifdef UNIFY_CHANNEL_MEM_HEAP + float data_separated_objects[MAX_NUM_OBJECTS][2 * L_FRAME48k]; +#else float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; +#endif +#ifndef UNIFY_CHANNEL_MEM_HEAP float gain = OMASA_TDREND_MATCHING_GAIN; +#endif ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; +#ifndef UNIFY_CHANNEL_MEM_HEAP float *tc_local[MAX_TRANSPORT_CHANNELS]; +#endif +#ifdef UNIFY_CHANNEL_MEM_HEAP + float *p_save_tc[MAX_NUM_OBJECTS]; + int16_t offsetSamples, slots_to_render; +#endif for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { p_sepobj[n] = &data_separated_objects[n][0]; } +#ifndef UNIFY_CHANNEL_MEM_HEAP /* Delay the object signals to match the CLDFB delay. Delay the whole buffer with the first rendering call of the stretched buffer. */ if ( st_ivas->hSpatParamRendCom->slots_rendered == 0 ) { @@ -764,14 +849,41 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( delay_signal( tc_local[n], tcBufferSize, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } } +#else + /* save objects */ + offsetSamples = st_ivas->hSpatParamRendCom->slots_rendered * st_ivas->hSpatParamRendCom->slot_size; + slots_to_render = min( st_ivas->hSpatParamRendCom->num_slots - st_ivas->hSpatParamRendCom->slots_rendered, nSamplesAsked / st_ivas->hSpatParamRendCom->slot_size ); + *nSamplesRendered = slots_to_render * st_ivas->hSpatParamRendCom->slot_size; + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + mvr2r( &st_ivas->hTcBuffer->tc[2 + n][offsetSamples], &data_separated_objects[n][offsetSamples], *nSamplesRendered ); + } +#endif ivas_dirac_dec_binaural_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, nchan_transport, output_f ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); +#endif +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* temporary set the object tc pointers to the locally saved ones */ + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + p_save_tc[n] = st_ivas->hTcBuffer->tc[2 + n]; + st_ivas->hTcBuffer->tc[2 + n] = p_sepobj[n]; + } +#endif if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } - +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* bend saved tc pointers back */ + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + st_ivas->hTcBuffer->tc[2 + n] = p_save_tc[n]; + } +#endif for ( n = 0; n < BINAURAL_CHANNELS; n++ ) { v_add( output_f[n], p_sepobj[n], output_f[n], *nSamplesRendered ); diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 9b23a45f7528da18f4a8a0d64936a0d9e9533705..67252de96af13861d6e2e5e074295a89191580aa 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -134,26 +134,105 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( { int16_t n; ivas_error error; +#ifdef UNIFY_CHANNEL_MEM_HEAP + float data_separated_objects[MAX_NUM_OBJECTS][2 * L_FRAME48k]; + float *p_save_tc[MAX_NUM_OBJECTS]; + int16_t offsetSamples, slots_to_render; + float *p_sepobj[MAX_NUM_OBJECTS]; + + for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) + { + p_sepobj[n] = &data_separated_objects[n][0]; + } + /* save objects */ + offsetSamples = st_ivas->hSpatParamRendCom->slots_rendered * st_ivas->hSpatParamRendCom->slot_size; + slots_to_render = min( st_ivas->hSpatParamRendCom->num_slots - st_ivas->hSpatParamRendCom->slots_rendered, nSamplesAsked / st_ivas->hSpatParamRendCom->slot_size ); + *nSamplesRendered = slots_to_render * st_ivas->hSpatParamRendCom->slot_size; + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + mvr2r( &st_ivas->hTcBuffer->tc[n][offsetSamples], &data_separated_objects[n][offsetSamples], *nSamplesRendered ); + } +#endif if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, &output_f[2] ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* temporary set the object tc pointers to the locally saved ones */ + for ( n = 0; n < st_ivas->nchan_ism; n++ ) { - return error; + p_save_tc[n] = st_ivas->hTcBuffer->tc[n]; + st_ivas->hTcBuffer->tc[n] = p_sepobj[n]; } +#endif - for ( n = 0; n < BINAURAL_CHANNELS; n++ ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - int16_t i; - for ( i = 0; i < nSamplesAsked; i++ ) + int16_t slot_idx, num_cldfb_bands, b, nchan_transport_orig; + int16_t cldfb_slots, slot_idx_start; + float Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[CLDFB_NO_CHANNELS_MAX]; + + num_cldfb_bands = st_ivas->hSplitBinRend.splitrend.hCldfbHandles->cldfbAna[0]->no_channels; + nchan_transport_orig = st_ivas->nchan_transport; + st_ivas->nchan_transport = st_ivas->nchan_ism; + slot_idx_start = st_ivas->hTcBuffer->n_samples_rendered / num_cldfb_bands; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) { - output_f[n][i] = 0.5f * output_f[2 + n][i] + 0.5f * output_f[n][i]; + return error; + } + st_ivas->nchan_transport = nchan_transport_orig; + cldfb_slots = *nSamplesRendered / num_cldfb_bands; + + for ( n = 0; n < st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++n ) + { + for ( slot_idx = 0; slot_idx < cldfb_slots; slot_idx++ ) + { + cldfbAnalysis_ts( &( output_f[n][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer, Cldfb_ImagBuffer, num_cldfb_bands, st_ivas->hSplitBinRend.splitrend.hCldfbHandles->cldfbAna[n] ); + + for ( b = 0; b < num_cldfb_bands; b++ ) + { + st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx][b] = + ( 0.5f * st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_RealBuffer_Binaural[n][slot_idx_start + slot_idx][b] ) + + ( 0.5f * Cldfb_RealBuffer[b] ); + + st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx][b] = + ( 0.5f * st_ivas->hSplitBinRend.hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural[n][slot_idx_start + slot_idx][b] ) + + ( 0.5f * Cldfb_ImagBuffer[b] ); + } + } } } + else + { +#endif + + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + for ( n = 0; n < BINAURAL_CHANNELS; n++ ) + { + int16_t i; + for ( i = 0; i < nSamplesAsked; i++ ) + { + output_f[n][i] = 0.5f * output_f[2 + n][i] + 0.5f * output_f[n][i]; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + } +#endif +#ifdef UNIFY_CHANNEL_MEM_HEAP + /* bend saved tc pointers back */ + for ( n = 0; n < st_ivas->nchan_ism; n++ ) + { + st_ivas->hTcBuffer->tc[2 + n] = p_save_tc[n]; + } +#endif return IVAS_ERR_OK; } @@ -232,7 +311,11 @@ ivas_error ivas_osba_dirac_td_binaural( num_cldfb_bands = st_ivas->hSplitBinRend.splitrend.hCldfbHandles->cldfbAna[0]->no_channels; nchan_transport_orig = st_ivas->nchan_transport; st_ivas->nchan_transport = st_ivas->nchan_ism; +#ifdef NONBE_UNIFIED_DECODING_PATHS + +#else ObjRenderIvasFrame_splitBinaural( st_ivas, output, output_frame ); +#endif st_ivas->nchan_transport = nchan_transport_orig; for ( n = 0; n < st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++n ) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 203bf0ff48fac4a7f451e9e13f7f9eb2a3f15c0e..93f9ae088d0a77511898cb405c49268b03470ff9 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -123,7 +123,9 @@ ivas_error ivas_sba_dec_reconfigure( #else int16_t ch, nchan_out_buff, nchan_out_buff_old; #endif +#ifndef NONBE_UNIFIED_DECODING_PATHS int16_t sba_analysis_order_old; +#endif int16_t sba_analysis_order_old_flush; DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; @@ -135,14 +137,27 @@ ivas_error ivas_sba_dec_reconfigure( ivas_total_brate = hDecoderConfig->ivas_total_brate; last_ivas_total_brate = st_ivas->last_active_ivas_total_brate; sba_analysis_order_old_flush = st_ivas->sba_analysis_order; +#ifndef NONBE_UNIFIED_DECODING_PATHS sba_analysis_order_old = ivas_sba_get_analysis_order( last_ivas_total_brate, st_ivas->sba_order ); - +#endif /*-----------------------------------------------------------------* * Set SBA high-level parameters * Save old SBA high-level parameters *-----------------------------------------------------------------*/ - +#ifdef UNIFY_CHANNEL_MEM_HEAP +#ifdef NONBE_UNIFIED_DECODING_PATHS + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old_flush, last_ivas_total_brate, st_ivas->hTcBuffer->nchan_buffer_full ); +#else + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate, st_ivas->hTcBuffer->nchan_buffer_full ); +#endif +#else +#ifdef NONBE_UNIFIED_DECODING_PATHS + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old_flush, last_ivas_total_brate ); +#else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, sba_analysis_order_old, last_ivas_total_brate ); +#endif +#endif + ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); @@ -581,11 +596,14 @@ ivas_error ivas_sba_dec_reconfigure( return error; } +#ifndef UNIFY_CHANNEL_MEM_HEAP /*-----------------------------------------------------------------* * JBM TC buffers *-----------------------------------------------------------------*/ +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#endif { int16_t tc_nchan_to_allocate; int16_t tc_nchan_tc; @@ -637,6 +655,7 @@ ivas_error ivas_sba_dec_reconfigure( } } } +#endif /* resync SPAR and DirAC JBM info from TC Buffer */ if ( st_ivas->hSpatParamRendCom != NULL ) @@ -666,10 +685,15 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * floating-point output audio buffers *-----------------------------------------------------------------*/ - +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_5ms ) +#endif { +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_UNKNOWN ); +#else nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); +#endif #ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) @@ -699,7 +723,14 @@ ivas_error ivas_sba_dec_reconfigure( #endif } - return IVAS_ERR_OK; +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + + return error; } @@ -784,7 +815,11 @@ void ivas_sba_dec_digest_tc( ( ( st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) && ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; +#ifdef UNIFY_CHANNEL_MEM_HEAP + generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st_ivas->hSpatParamRendCom, st->cna_dirac_flag && st->flag_cna ); +#else generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna ); +#endif } return; @@ -852,6 +887,10 @@ ivas_error ivas_sba_dec_render( { output_f_local[ch] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); +#endif } if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 8ed7de61f4a66e5136bb86169fe46b2e2f44c4e6..f3b23a2dcc8d4294e1f3958d4074f2bed88a6587 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -422,9 +422,21 @@ void ivas_ism2sba_sf( int16_t i, j, k; float g1, *g2, *tc, *out, gain, prev_gain; int16_t sba_num_chans; +#ifdef UNIFY_CHANNEL_MEM_HEAP + float input_f[MAX_NUM_OBJECTS][L_FRAME48k]; +#endif assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" ); + +#ifdef UNIFY_CHANNEL_MEM_HEAP + for ( i = 0; i < num_objects; i++ ) + { + mvr2r( &buffer_in[i][offset], input_f[i], n_samples_to_render ); + } +#endif + + /* Init*/ sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); for ( j = 0; j < sba_num_chans; j++ ) @@ -437,7 +449,11 @@ void ivas_ism2sba_sf( for ( j = 0; j < sba_num_chans; j++ ) { g2 = hIsmRendererData->interpolator + offset; +#ifdef UNIFY_CHANNEL_MEM_HEAP + tc = input_f[i] + offset; +#else tc = buffer_in[i] + offset; +#endif out = buffer_out[j]; gain = hIsmRendererData->gains[i][j]; prev_gain = hIsmRendererData->prev_gains[i][j]; @@ -488,7 +504,11 @@ ivas_error ivas_sba_upmixer_renderer( sba_ch_idx = st_ivas->nchan_ism; } +#ifdef UNIFY_CHANNEL_MEM_HEAP + for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, TC_BUFFER_NUM_FULL_CHAN_DONT_COUNT ) - sba_ch_idx; ch++ ) +#else for ( ch = 0; ch < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) - sba_ch_idx; ch++ ) +#endif { output_f[ch] = output[ch]; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 9c6b45a2ed7b61416919417a8a0de814e371126c..bf83e0cd248b695b02eb8e0aabcc1880da5e61e7 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -75,6 +75,7 @@ ivas_error ivas_spar_dec_open( int16_t num_decor_chs, map_idx; error = IVAS_ERR_OK; + sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); num_channels_internal = ivas_sba_get_nchan_metadata( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate ); @@ -210,8 +211,17 @@ ivas_error ivas_spar_dec_open( hSpar->render_to_md_map[map_idx] = map_idx; } +#ifndef UNIFY_CHANNEL_MEM_HEAP /* allocate transport channels*/ - if ( ( st_ivas->hDecoderConfig->Opt_5ms || st_ivas->ivas_format == SBA_ISM_FORMAT ) && st_ivas->hTcBuffer == NULL ) + if ( +#ifndef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hDecoderConfig->Opt_5ms && +#endif + st_ivas->hTcBuffer == NULL +#ifndef NONBE_UNIFIED_DECODING_PATHS + || st_ivas->ivas_format == SBA_ISM_FORMAT +#endif + ) { int16_t nchan_to_allocate; int16_t nchan_tc; @@ -254,18 +264,20 @@ ivas_error ivas_spar_dec_open( granularity = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); } +#ifndef NONBE_UNIFIED_DECODING_PATHS /* make sure we have a TC buffer with the correct granularity for rate switching in OSBA */ if ( !st_ivas->hDecoderConfig->Opt_5ms ) { nchan_tc = 0; nchan_to_allocate = 0; } - +#endif if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ) != IVAS_ERR_OK ) { return error; } } +#endif st_ivas->hSpar = hSpar; @@ -1454,6 +1466,9 @@ void ivas_spar_dec_upmixer( { output_f_local[n] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); +#endif } for ( n = 0; n < nchan_internal_total; n++ ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 1a428a0590f5e8055f2d69e1df343cb386535130..4b0135f3af307817481301dacff5b0e734fcc234 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1014,7 +1014,11 @@ typedef struct decoder_config_structure #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t Opt_Limiter; #endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + IVAS_RENDER_FRAMESIZE render_framesize; +#else int16_t Opt_5ms; +#endif int16_t Opt_delay_comp; /* flag indicating delay compensation active */ } DECODER_CONFIG, *DECODER_CONFIG_HANDLE; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index bedf202625ea1a11986d4fe4e126a777740c5bb7..85b129106c44934e8c12019fb244fe708c86b0b7 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -82,6 +82,9 @@ struct IVAS_DEC PCMDSP_APA_HANDLE hTimeScaler; bool needNewFrame; bool hasBeenFedFrame; +#ifdef NONBE_UNIFIED_DECODING_PATHS + bool updateOrientation; +#endif uint16_t nSamplesAvailableNext; int16_t nSamplesRendered; int16_t nTransportChannelsOld; @@ -123,6 +126,9 @@ static PCM_RESOLUTION pcm_type_API_to_internal( const IVAS_DEC_PCM_TYPE pcmType static void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int32_t offset ); static ivas_error set_pcm_buffer_to_zero( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int16_t nZeroSamples ); #endif +#ifdef NONBE_UNIFIED_DECODING_PATHS +static int16_t get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); +#endif /*---------------------------------------------------------------------* @@ -167,6 +173,9 @@ ivas_error IVAS_DEC_Open( hIvasDec->hasBeenFedFirstGoodFrame = false; hIvasDec->hasDecodedFirstGoodFrame = false; hIvasDec->isInitialized = false; +#ifdef NONBE_UNIFIED_DECODING_PATHS + hIvasDec->updateOrientation = false; +#endif hIvasDec->mode = mode; @@ -264,7 +273,9 @@ static void init_decoder_config( #ifdef SPLIT_REND_WITH_HEAD_ROT hDecoderConfig->Opt_Limiter = 1; #endif +#ifndef NONBE_UNIFIED_DECODING_PATHS hDecoderConfig->Opt_5ms = 0; +#endif hDecoderConfig->Opt_delay_comp = 0; hDecoderConfig->Opt_ExternalOrientation = 0; hDecoderConfig->Opt_dpid_on = 0; @@ -359,16 +370,20 @@ static IVAS_DEC_BS_FORMAT mapIvasFormat( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_Configure( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const uint32_t sampleRate, /* i : output sampling frequency */ - const AUDIO_CONFIG outputConfig, /* i : output configuration */ - const int16_t tsmEnabled, /* i : enable TSM */ - const int16_t enable5ms, /* i : enable 5ms rendering path */ - const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ - const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ - const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ - const int16_t enableExternalOrientation, /* i : enable external orientations */ - const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const uint32_t sampleRate, /* i : output sampling frequency */ + const AUDIO_CONFIG outputConfig, /* i : output configuration */ + const int16_t tsmEnabled, /* i : enable time scale modification */ +#ifndef NONBE_UNIFIED_DECODING_PATHS + const int16_t enable5ms, /* i : enable 5ms rendering path */ +#else + const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ +#endif + const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ + const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ + const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ + const int16_t enableExternalOrientation, /* i : enable external orientations */ + const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */ const int16_t renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ const int16_t Opt_non_diegetic_pan, /* i : diegetic or not */ const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ @@ -422,7 +437,9 @@ ivas_error IVAS_DEC_Configure( } hDecoderConfig->Opt_tsm = tsmEnabled; +#ifndef NONBE_UNIFIED_DECODING_PATHS hDecoderConfig->Opt_5ms = enable5ms; +#endif hDecoderConfig->Opt_LsCustom = customLsOutputEnabled; hDecoderConfig->Opt_Headrotation = enableHeadRotation; hDecoderConfig->orientation_tracking = orientation_tracking; @@ -434,6 +451,13 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->Opt_ExternalOrientation = enableExternalOrientation; hDecoderConfig->Opt_dpid_on = Opt_dpid_on; hDecoderConfig->Opt_aeid_on = acousticEnvironmentId != 65535 ? TRUE : FALSE; +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( renderFramesize == IVAS_RENDER_FRAMESIZE_UNKNOWN ) + { + return IVAS_ERR_WRONG_PARAMS; + } + hDecoderConfig->render_framesize = renderFramesize; +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) @@ -488,7 +512,11 @@ ivas_error IVAS_DEC_EnableSplitRendering( hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; hDecoderConfig->Opt_Headrotation = 1; +#ifndef NONBE_UNIFIED_DECODING_PATHS hDecoderConfig->Opt_5ms = false; +#else + hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; +#endif hDecoderConfig->Opt_Limiter = 0; @@ -496,6 +524,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( } #endif +#ifndef NONBE_UNIFIED_DECODING_PATHS /*---------------------------------------------------------------------* * IVAS_DEC_Set5msFlag( ) * @@ -538,6 +567,144 @@ ivas_error IVAS_DEC_Get5msFlag( return IVAS_ERR_OK; } +#else +/*---------------------------------------------------------------------* + * get_render_framesize_ms( ) + * + * Get the 5ms flag + *---------------------------------------------------------------------*/ + +int16_t get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ) +{ + return (int16_t) ( render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_SetRenderFramesize( ) + * + * Get the 5ms flag + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_SetRenderFramesize( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_FRAMESIZE render_framesize /* i : render framesize */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hDecoderConfig == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + hIvasDec->st_ivas->hDecoderConfig->render_framesize = render_framesize; + + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetGetRenderFramesize( ) + * + * Get the 5ms flag + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetRenderFramesize( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_framesize == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *render_framesize = hIvasDec->st_ivas->hDecoderConfig->render_framesize; + + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetGetRenderFramesizeSamples( ) + * + * Get render framesize in samples + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetRenderFramesizeSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *render_framesize /* o : render framesize in samples */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_framesize == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *render_framesize = (int16_t) ( hIvasDec->st_ivas->hDecoderConfig->output_Fs * hIvasDec->st_ivas->hDecoderConfig->render_framesize / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ); + + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetGetRenderFramesizeMs( ) + * + * Get render framesize in milliseconds + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetRenderFramesizeMs( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint32_t *render_framesize /* o : render framesize in samples */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || render_framesize == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *render_framesize = get_render_frame_size_ms( hIvasDec->st_ivas->hDecoderConfig->render_framesize ); + + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetGetReferencesUpdateFrequency( ) + * + * Get update frequency of the reference vector/orientation + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetReferencesUpdateFrequency( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *update_frequency /* o : update frequency */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || update_frequency == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *update_frequency = (int16_t) ( IVAS_MAX_PARAM_SPATIAL_SUBFRAMES / hIvasDec->st_ivas->hDecoderConfig->render_framesize ); + + return IVAS_ERR_OK; +} + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetGetNumOrientationSubframes( ) + * + * Get the number of subframes for head/ecernal orientation per render frame + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetNumOrientationSubframes( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *num_subframes /* o : render framesize */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || num_subframes == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + *num_subframes = (int16_t) hIvasDec->st_ivas->hDecoderConfig->render_framesize; + + return IVAS_ERR_OK; +} +#endif /*---------------------------------------------------------------------* @@ -569,8 +736,9 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->Opt_VOIP = 1; hDecoderConfig->Opt_tsm = 1; +#ifndef NONBE_UNIFIED_DECODING_PATHS hDecoderConfig->Opt_5ms = 1; - +#endif if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) { hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config ); @@ -719,6 +887,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( * Main function to decode to PCM data *---------------------------------------------------------------------*/ +#ifndef NONBE_UNIFIED_DECODING_PATHS static ivas_error _GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -779,7 +948,7 @@ static ivas_error _GetSamples( return IVAS_ERR_OK; } - +#endif ivas_error IVAS_DEC_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ @@ -810,6 +979,32 @@ ivas_error IVAS_DEC_GetSamples( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( hIvasDec->updateOrientation ) + { + /*----------------------------------------------------------------* + * Combine orientations + *----------------------------------------------------------------*/ + + if ( ( error = combine_external_and_head_orientations_dec( hIvasDec->st_ivas->hHeadTrackData, hIvasDec->st_ivas->hExtOrientationData, hIvasDec->st_ivas->hCombinedOrientationData ) ) != IVAS_ERR_OK ) + { + return error; + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*----------------------------------------------------------------* + * Binaural split rendering setup + *----------------------------------------------------------------*/ + + if ( hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + ivas_set_split_rend_ht_setup( &hIvasDec->st_ivas->hSplitBinRend, hIvasDec->st_ivas->hCombinedOrientationData ); + } +#endif + + hIvasDec->updateOrientation = false; + } +#endif + if ( !hIvasDec->hasBeenFedFrame && hIvasDec->nSamplesAvailableNext == 0 ) { /* no frame was fed, do nothing but ask for a frame */ @@ -833,8 +1028,6 @@ ivas_error IVAS_DEC_GetSamples( *needNewFrame = true; } } - - /* only for 1st step 5ms API, split rendering still needs to go through the old decoding function */ else { /* check if we need to run the setup function */ @@ -855,7 +1048,7 @@ ivas_error IVAS_DEC_GetSamples( /* :TODO: change nSamplesAsked also if we are in 5ms 0dof split rendering... */ #endif } - +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !hIvasDec->st_ivas->hDecoderConfig->Opt_5ms ) { #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -877,6 +1070,7 @@ ivas_error IVAS_DEC_GetSamples( *needNewFrame = true; } else +#endif { /* check if we need to run the setup function, tc decoding and feeding the renderer */ if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) @@ -1016,9 +1210,15 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; - if ( st_ivas->hDecoderConfig->Opt_5ms && hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && - ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || - hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + if ( +#ifdef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS && +#else + st_ivas->hDecoderConfig->Opt_5ms && +#endif + hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && + ( hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + hIvasDec->st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { numSamplesPerChannelToSplitEncode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); numSamplesPerChannelCacheSize = numSamplesPerChannelToDecode - numSamplesPerChannelToSplitEncode; @@ -1117,7 +1317,11 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ if ( pcm_out_flag ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ) +#else if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { #ifndef DISABLE_LIMITER ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToSplitEncode, st_ivas->BER_detect ); @@ -1647,7 +1851,9 @@ ivas_error IVAS_DEC_FeedHeadTrackData( #ifdef SPLIT_REND_WITH_HEAD_ROT hHeadTrackData->sr_pose_pred_axis = rot_axis; #endif - +#ifdef NONBE_UNIFIED_DECODING_PATHS + hIvasDec->updateOrientation = true; +#endif return IVAS_ERR_OK; } @@ -1677,6 +1883,10 @@ ivas_error IVAS_DEC_FeedRefRotData( pOtr->refRot.z = rotation.z; pOtr->refRot.y = rotation.y; +#ifdef NONBE_UNIFIED_DECODING_PATHS + hIvasDec->updateOrientation = true; +#endif + return IVAS_ERR_OK; } @@ -1704,6 +1914,10 @@ ivas_error IVAS_DEC_FeedRefVectorData( pOtr = hIvasDec->st_ivas->hHeadTrackData->OrientationTracker; +#ifdef NONBE_UNIFIED_DECODING_PATHS + hIvasDec->updateOrientation = true; +#endif + return ivas_orient_trk_SetReferenceVector( pOtr, listenerPos, refPos ); } @@ -1746,6 +1960,10 @@ ivas_error IVAS_DEC_FeedExternalOrientationData( hExternalOrientationData->enableRotationInterpolation[subframe_idx] = enableRotationInterpolation; hExternalOrientationData->numFramesToTargetOrientation[subframe_idx] = numFramesToTargetOrientation; +#ifdef NONBE_UNIFIED_DECODING_PATHS + hIvasDec->updateOrientation = true; +#endif + return IVAS_ERR_OK; } @@ -1957,7 +2175,6 @@ ivas_error IVAS_DEC_GetRenderConfig( const IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render configuration handle */ ) { - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL || hRCout == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -2905,7 +3122,9 @@ static ivas_error printConfigInfo_dec( get_channel_config( st_ivas->hDecoderConfig->output_config, &config_str[0] ); fprintf( stdout, "Output configuration: %s\n", config_str ); - +#ifdef NONBE_UNIFIED_DECODING_PATHS + fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); +#endif if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) { fprintf( stdout, "HRIR/BRIR file: ON\n" ); @@ -2971,7 +3190,7 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "TSM mode: ON\n" ); } - +#ifndef NONBE_UNIFIED_DECODING_PATHS /*-----------------------------------------------------------------* * Print 5ms API mode info *-----------------------------------------------------------------*/ @@ -2980,7 +3199,7 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "API 5ms mode: ON\n" ); } - +#endif return IVAS_ERR_OK; } @@ -3084,7 +3303,9 @@ static ivas_error evs_dec_main( int16_t *pcmBuf ) { DEC_CORE_HANDLE *hCoreCoder; +#ifndef UNIFY_CHANNEL_MEM_HEAP float output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN][L_FRAME48k]; +#endif float mixer_left, mixer_rigth; float *p_output[MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN]; int16_t ch; @@ -3097,7 +3318,11 @@ static ivas_error evs_dec_main( for ( ch = 0; ch < MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN; ch++ ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + p_output[ch] = st_ivas->p_output_f[ch]; +#else p_output[ch] = output[ch]; +#endif } /* run the main EVS decoding routine */ @@ -3105,14 +3330,22 @@ static ivas_error evs_dec_main( { if ( hCoreCoder[0]->Opt_AMR_WB ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = amr_wb_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0] ) ) != IVAS_ERR_OK ) +#else if ( ( error = amr_wb_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0] ) ) != IVAS_ERR_OK ) +#endif { return error; } } else { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -3122,21 +3355,33 @@ static ivas_error evs_dec_main( { if ( hCoreCoder[0]->bfi == 0 ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0], FRAMEMODE_NORMAL ) ) != IVAS_ERR_OK ) +#endif { return error; } } else if ( hCoreCoder[0]->bfi == 2 ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_FUTURE ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0], FRAMEMODE_FUTURE ) ) != IVAS_ERR_OK ) +#endif { return error; } } else { +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], p_output[0], FRAMEMODE_MISSING ) ) != IVAS_ERR_OK ) +#else if ( ( error = evs_dec( hCoreCoder[0], st_ivas->mem_hp20_out[0], output[0], FRAMEMODE_MISSING ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -3149,11 +3394,22 @@ static ivas_error evs_dec_main( { mixer_left = ( st_ivas->hDecoderConfig->non_diegetic_pan_gain + 1.f ) * 0.5f; mixer_rigth = 1.f - mixer_left; +#ifdef UNIFY_CHANNEL_MEM_HEAP + v_multc( p_output[0], mixer_rigth, p_output[1], nOutSamples ); + v_multc( p_output[0], mixer_left, p_output[0], nOutSamples ); +#else v_multc( output[0], mixer_rigth, output[1], nOutSamples ); v_multc( output[0], mixer_left, output[0], nOutSamples ); +#endif } - if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hDecoderConfig->Opt_5ms ) + + if ( !st_ivas->hDecoderConfig->Opt_tsm +#ifndef NONBE_UNIFIED_DECODING_PATHS + && st_ivas->hDecoderConfig->Opt_5ms +#endif + + ) { ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 7b798dea6e547f8019a17bcd4671fbe654e8f8b9..11aa3917efe1e50cea3c454da6e284e6d39bc97d 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -125,7 +125,11 @@ ivas_error IVAS_DEC_Configure( const uint32_t sampleRate, /* i : output sampling frequency */ const IVAS_AUDIO_CONFIG outputConfig, /* i : audio configuration */ const int16_t tsmEnabled, /* i : enable TSM */ - const int16_t enable5ms, /* i : enable 5ms rendering path */ +#ifndef NONBE_UNIFIED_DECODING_PATHS + const int16_t enable5ms, /* i : enable 5ms rendering path */ +#else + const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ +#endif const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ @@ -307,6 +311,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( ); #endif +#ifndef NONBE_UNIFIED_DECODING_PATHS ivas_error IVAS_DEC_Set5msFlag( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t enable5ms /* i : 5ms flag */ @@ -316,6 +321,37 @@ ivas_error IVAS_DEC_Get5msFlag( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ int16_t *enable5ms /* o : 5ms flag */ ); +#else +ivas_error IVAS_DEC_SetRenderFramesize( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_FRAMESIZE render_framesize /* i : render framesize */ +); + +ivas_error IVAS_DEC_GetRenderFramesize( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */ +); + +ivas_error IVAS_DEC_GetRenderFramesizeSamples( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *render_framesize /* o : render framesize in samples */ +); + +ivas_error IVAS_DEC_GetReferencesUpdateFrequency( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *update_frequency /* o : update frequency */ +); + +ivas_error IVAS_DEC_GetNumOrientationSubframes( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *num_subframes /* o : render framesize */ +); + +ivas_error IVAS_DEC_GetRenderFramesizeMs( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint32_t *render_framesize /* o : render framesize in samples */ +); +#endif #ifdef DEBUGGING bool IVAS_DEC_GetBerDetectFlag( diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 0563921c6bcc20526ddedf8dbbc39424f800e9a4..cab412c1c31b62285484c7f23362cc47bc45f7a2 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1861,6 +1861,10 @@ ivas_error ivas_rend_crendProcess( return error; } } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( hCombinedOrientationData, subframe_len ); +#endif } else { @@ -1898,6 +1902,12 @@ ivas_error ivas_rend_crendProcessSubframe( 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 */ +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + const int16_t pos_idx +#endif +#endif ) { int16_t subframe_idx, subframe_len; @@ -1911,7 +1921,11 @@ ivas_error ivas_rend_crendProcessSubframe( CREND_HANDLE hCrend; #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCrend = pCrend->hCrend[pos_idx]; +#else hCrend = pCrend->hCrend[0]; +#endif #else hCrend = pCrend->hCrend; #endif @@ -1997,7 +2011,11 @@ ivas_error ivas_rend_crendProcessSubframe( if ( ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0, pos_idx ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0, 0 ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0 ) ) != IVAS_ERR_OK ) @@ -2009,7 +2027,11 @@ ivas_error ivas_rend_crendProcessSubframe( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( pCrend->hCrend[0]->hReverb != NULL ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = ivas_reverb_process( pCrend->hCrend[pos_idx]->hReverb, inConfig, 1, tc_local, p_pcm_tmp, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_process( pCrend->hCrend[0]->hReverb, inConfig, 1, tc_local, p_pcm_tmp, 0 ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2038,6 +2060,10 @@ ivas_error ivas_rend_crendProcessSubframe( { return IVAS_ERR_INVALID_INPUT_FORMAT; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( hCombinedOrientationData, subframe_len ); +#endif } /* move to output */ @@ -2194,3 +2220,180 @@ ivas_error ivas_rend_crendProcessSplitBin( return IVAS_ERR_OK; } #endif + +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*-----------------------------------------------------------------------------------------* + * Function ivas_rend_crend_ProcessSubframesSplitBin() + * + * Process call for IVAS Crend renderer + *-----------------------------------------------------------------------------------------*/ + +ivas_error ivas_rend_crendProcessSubframesSplitBin( + 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 MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + 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 i, j; + int16_t sf; + int16_t pos_idx; + ivas_error error; + float gain_lfe; + float tmpLfeBuffer[L_FRAME48k]; + float *p_bin_output[BINAURAL_CHANNELS]; + int16_t original_subframes_rendered, original_slots_rendered; + float tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + float *p_tmpInputBuffer[MAX_OUTPUT_CHANNELS]; + float tmpSplitBinBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + + COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; + COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; + + /* save current head positions */ + pCombinedOrientationDataLocal = hCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + original_subframes_rendered = hTcBuffer->subframes_rendered; + original_slots_rendered = hTcBuffer->slots_rendered; + + /* copy input */ + for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) + { + mvr2r( input_f[i], tmpInputBuffer[i], n_samples_to_render ); + } + + for ( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) + { + p_tmpInputBuffer[i] = tmpInputBuffer[i]; + } + + /* save current head positions */ + pCombinedOrientationDataLocal = hCombinedOrientationData; + combinedOrientationDataLocal = *pCombinedOrientationDataLocal; + if ( pMultiBinPoseData->poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) + { + for ( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf ) + { + combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0]; + for ( i = 0; i < 3; i++ ) + { + for ( j = 0; j < 3; j++ ) + { + combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j]; + } + } + } + } + + /* copy LFE to tmpLfeBuffer and apply gain only once */ + if ( hIntSetup->num_lfe > 0 && hIntSetup->index_lfe[0] != -1 ) + { + mvr2r( output[hIntSetup->index_lfe[0]], tmpLfeBuffer, n_samples_to_render ); + gain_lfe = ( ( pCrend != NULL ) && ( pCrend->hHrtfCrend != NULL ) ) ? pCrend->hHrtfCrend->gain_lfe : GAIN_LFE; + v_multc( tmpLfeBuffer, gain_lfe, tmpLfeBuffer, n_samples_to_render ); + } + else + { + set_zero( tmpLfeBuffer, n_samples_to_render ); + } + + for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; ++pos_idx ) + { + /* Update head positions */ + + IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; + for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i]; + Quaternions_abs.w = -3.0f; + Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ + + Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; + Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; + Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; + combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; + QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] ); + } + + + pCombinedOrientationDataLocal = &combinedOrientationDataLocal; + /* set output channels */ + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + p_bin_output[i] = output[pos_idx * BINAURAL_CHANNELS + i]; + } + hTcBuffer->subframes_rendered = original_subframes_rendered; + hTcBuffer->slots_rendered = original_slots_rendered; + ivas_combined_orientation_set_to_start_index( pCombinedOrientationDataLocal ); + + for ( i = 0; i < 3; i++ ) + { + mvr2r( hCombinedOrientationData->Rmat_prev[pos_idx][i], pCombinedOrientationDataLocal->Rmat_prev[0][i], 3 ); + } + if ( ( error = ivas_rend_crendProcessSubframe( pCrend, + inConfig, + outConfig, + hDecoderConfig, + pCombinedOrientationDataLocal, + hIntSetup, + hEFAPdata, + hTcBuffer, + p_tmpInputBuffer, + p_tmpInputBuffer, + n_samples_to_render, + output_Fs, + pos_idx ) ) != IVAS_ERR_OK ) + { + return error; + } + + for ( i = 0; i < 3; i++ ) + { + mvr2r( pCombinedOrientationDataLocal->Rmat_prev[0][i], hCombinedOrientationData->Rmat_prev[pos_idx][i], 3 ); + } + + for ( i = 0; i < BINAURAL_CHANNELS; ++i ) + { + /* accumulate LFE to output */ + v_add( tmpInputBuffer[i], tmpLfeBuffer, tmpInputBuffer[i], n_samples_to_render ); + + /* move to split bin output buffer */ + mvr2r( tmpInputBuffer[i], tmpSplitBinBuffer[pos_idx * BINAURAL_CHANNELS + i], n_samples_to_render ); + } + + /* overwrite rendered channels with input again for next iteration */ + for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) + { + mvr2r( input_f[i], tmpInputBuffer[i], n_samples_to_render ); + } + + /* restore original headrotation data */ + for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) + { + combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i]; + } + } + + /* copy split binaural rendered signals to final output */ + for ( i = 0; i < BINAURAL_CHANNELS * pMultiBinPoseData->num_poses; ++i ) + { + mvr2r( tmpSplitBinBuffer[i], output[i], n_samples_to_render ); + } + + /* update main combined orientation access index */ + ivas_combined_orientation_update_index( hCombinedOrientationData, n_samples_to_render ); + + return IVAS_ERR_OK; +} +#endif +#endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 55299076d521f6683ab5edc849237d9c5b8285c2..0bbb6249672b1e0b253a092776b0c710e8a86d0e 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -306,8 +306,13 @@ ivas_error ivas_dirac_dec_init_binaural_data( st_ivas->hDiracDecBin = hDiracDecBin; #endif +#ifndef UNIFY_CHANNEL_MEM_HEAP /* allocate transport channels*/ - if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL ) + if ( +#ifndef NONBE_UNIFIED_DECODING_PATHS + st_ivas->hDecoderConfig->Opt_5ms && +#endif + st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; int16_t n_samples_granularity; @@ -329,7 +334,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } - +#endif return IVAS_ERR_OK; } @@ -496,6 +501,10 @@ void ivas_dirac_dec_binaural_render( { output_f_local[ch] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); +#endif } if ( hSpatParamRendCom->slots_rendered == hSpatParamRendCom->num_slots ) @@ -619,7 +628,11 @@ void ivas_dirac_dec_binaural( { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; st_ivas->hTcBuffer->tc[nchan_transport] = &cng_td_buffer[0]; +#ifdef UNIFY_CHANNEL_MEM_HEAP + generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[nchan_transport], DEFAULT_JBM_CLDFB_TIMESLOTS, st_ivas->hSpatParamRendCom, st->cna_dirac_flag && st->flag_cna ); +#else generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[nchan_transport], DEFAULT_JBM_CLDFB_TIMESLOTS, st->cna_dirac_flag && st->flag_cna ); +#endif } for ( subframe = 0; subframe < num_subframes; subframe++ ) @@ -632,6 +645,9 @@ void ivas_dirac_dec_binaural( { p_output[ch] += n_samples_sf; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_combined_orientation_update_index( hCombinedOrientationData, n_samples_sf ); +#endif hSpatParamRendCom->dirac_read_idx = ( hSpatParamRendCom->dirac_read_idx + 1 ) % hSpatParamRendCom->dirac_md_buffer_length; } @@ -761,9 +777,17 @@ static void ivas_dirac_dec_binaural_internal( generate_masking_noise_dirac( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom, st_ivas->cldfbAnaDec[1], +#ifdef UNIFY_CHANNEL_MEM_HEAP + &st_ivas->hTcBuffer->tc[nchan_transport][offsetSamples], +#else st_ivas->hTcBuffer->tc[nchan_transport], +#endif Cldfb_RealBuffer_in[2][slot], Cldfb_ImagBuffer_in[2][slot], +#ifdef UNIFY_CHANNEL_MEM_HEAP + slot, +#else slotInFrame, +#endif st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->hSCE[0]->hCoreCoder[0]->flag_cna, ( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ); @@ -771,7 +795,11 @@ static void ivas_dirac_dec_binaural_internal( st_ivas->cldfbAnaDec[1], /*nothing will be analyzed, just get cnst*/ NULL, Cldfb_RealBuffer_in[1][slot], Cldfb_ImagBuffer_in[1][slot], +#ifdef UNIFY_CHANNEL_MEM_HEAP + slot, +#else slotInFrame, +#endif st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->hSCE[0]->hCoreCoder[0]->flag_cna, ( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ); @@ -847,7 +875,11 @@ static void ivas_dirac_dec_binaural_internal( { for ( j = 0; j < 3; j++ ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + Rmat[i][j] = hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i][j]; +#else Rmat[i][j] = hCombinedOrientationData->Rmat[subframe][i][j]; +#endif } } @@ -865,7 +897,13 @@ static void ivas_dirac_dec_binaural_internal( #ifndef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, st_ivas->hMasaIsmData ); + hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, +#else + hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, +#endif + st_ivas->hMasaIsmData ); #endif if ( config_data.ivas_format == ISM_FORMAT ) @@ -901,7 +939,12 @@ static void ivas_dirac_dec_binaural_internal( } ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, + hCombinedOrientationData && +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, +#else + hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, +#endif nchanSeparateChannels, st_ivas->hMasaIsmData ); #ifdef SPLIT_REND_WITH_HEAD_ROT diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 314f30af10af7132c07caa4952e0f15b86bb386b..44a04816eec415e6881faf27629332693e9c07f6 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -287,13 +287,17 @@ ivas_error ivas_td_binaural_renderer_unwrap( const int16_t lfe_idx, /* i : LFE channel index */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ ISM_METADATA_HANDLE *hIsmMetaData, /* i : ISM metadata handle */ - const int16_t *enableCombinedOrientation, /* i : Combined orientation flag */ - const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ - const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ - const int16_t ism_md_subframe_update, /* i : Number of subframes to delay ism metadata to sync with audio */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame, /* i : output frame length */ - const int16_t num_subframes /* i : number of subframes to render */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientaton data handle */ +#else + const int16_t *enableCombinedOrientation, /* i : Combined orientation flag */ + const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ + const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ +#endif + const int16_t ism_md_subframe_update, /* i : Number of subframes to delay ism metadata to sync with audio */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t output_frame, /* i : output frame length */ + const int16_t num_subframes /* i : number of subframes to render */ ) { int16_t subframe_length; @@ -303,6 +307,23 @@ ivas_error ivas_td_binaural_renderer_unwrap( int16_t c_indx, nS; float *p_reverb_signal[BINAURAL_CHANNELS]; int16_t ch; +#ifdef NONBE_UNIFIED_DECODING_PATHS + int16_t *enableCombinedOrientation; /* i : Combined orientation flag */ + IVAS_QUATERNION *Quaternions; /* i : Head tracking data per subframe */ + IVAS_VECTOR3 *Pos; /* i : Listener position data per subframe */ +#endif + +#ifdef NONBE_UNIFIED_DECODING_PATHS + enableCombinedOrientation = NULL; + Quaternions = NULL; + Pos = NULL; + if ( hCombinedOrientationData != NULL ) + { + enableCombinedOrientation = hCombinedOrientationData->enableCombinedOrientation; + Quaternions = hCombinedOrientationData->Quaternions; + Pos = hCombinedOrientationData->listenerPos; + } +#endif for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -334,7 +355,13 @@ ivas_error ivas_td_binaural_renderer_unwrap( } /* Update the listener's location/orientation */ - if ( ( error = TDREND_Update_listener_orientation( hBinRendererTd, ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[subframe_idx] : NULL ) ) != IVAS_ERR_OK ) + if ( ( error = TDREND_Update_listener_orientation( hBinRendererTd, +#ifdef NONBE_UNIFIED_DECODING_PATHS + ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[hCombinedOrientationData->subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[hCombinedOrientationData->subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[hCombinedOrientationData->subframe_idx] : NULL +#else + ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[subframe_idx] : NULL +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -363,6 +390,11 @@ ivas_error ivas_td_binaural_renderer_unwrap( c_indx++; } } + +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ + ivas_combined_orientation_update_index( hCombinedOrientationData, subframe_length ); +#endif } if ( hReverb != NULL ) @@ -737,9 +769,13 @@ ivas_error ivas_td_binaural_renderer_ext( } if ( ( error = ivas_td_binaural_renderer_unwrap( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, +#ifdef NONBE_UNIFIED_DECODING_PATHS + *hCombinedOrientationData, +#else ( hCombinedOrientationData != NULL ) ? ( *hCombinedOrientationData )->enableCombinedOrientation : NULL, ( hCombinedOrientationData != NULL ) ? ( *hCombinedOrientationData )->Quaternions : NULL, ( hCombinedOrientationData != NULL ) ? ( *hCombinedOrientationData )->listenerPos : NULL, +#endif ism_md_subframe_update_ext, p_output, output_frame, (int16_t) ( ( output_frame * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) / output_Fs ) ) ) != IVAS_ERR_OK ) { diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index aec94224609b632a158a79184e32667a83770cbf..87cf6e006aba7dc65e1389277bf91f10f22a1d63 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -267,6 +267,10 @@ int16_t ivas_get_nchan_buffers_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t sba_analysis_order, /* i : SBA order evaluated in SBA decoder */ const int32_t ivas_total_brate /* i : total IVAS bitrate */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + , + const int16_t tc_buffer_nchan_full /* i : number of full tc channels needed */ +#endif ) { int16_t nchan_out_buff; @@ -278,7 +282,11 @@ int16_t ivas_get_nchan_buffers_dec( if ( st_ivas->ivas_format == MONO_FORMAT ) { +#ifdef UNIFY_CHANNEL_MEM_HEAP + nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; +#else nchan_out_buff = 0; +#endif } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { @@ -405,6 +413,22 @@ int16_t ivas_get_nchan_buffers_dec( } #endif +#ifdef UNIFY_CHANNEL_MEM_HEAP + if ( !st_ivas->hDecoderConfig->Opt_tsm ) + { + if ( tc_buffer_nchan_full >= 0 ) + { + nchan_out_buff = max( nchan_out_buff, tc_buffer_nchan_full ); + } + else + { + int16_t nchan_buf_full, tmp1, tmp2; + ivas_jbm_dec_get_num_tc_channels( st_ivas, &tmp1, &tmp2, &nchan_buf_full ); + nchan_out_buff = max( nchan_out_buff, nchan_buf_full ); + } + } +#endif + return nchan_out_buff; } diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index a8b9c029b086f0dd20bb6b908c0f94122d548e0a..10688753ed65a2d7776191307a73d782615c48eb 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -75,9 +75,12 @@ int16_t ivas_get_nchan_buffers_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t sba_analysis_order, /* i : SBA order evaluated in SBA decoder */ const int32_t ivas_total_brate /* i : total IVAS bitrate */ +#ifdef UNIFY_CHANNEL_MEM_HEAP + , + const int16_t tc_buffer_nchan_full /* i : number of full tc channels needed */ +#endif ); - /*----------------------------------------------------------------------------------* * Limiter prototypes *----------------------------------------------------------------------------------*/ @@ -556,9 +559,13 @@ ivas_error ivas_td_binaural_renderer_unwrap( const int16_t lfe_idx, /* i : LFE channel index */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ ISM_METADATA_HANDLE *hIsmMetaData, /* i : ISM metadata handle */ - const int16_t *enableCombinedOrientation, /* i : Combined orientation flag */ - const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ - const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientaton data handle */ +#else + const int16_t *enableCombinedOrientation, /* i : Combined orientation flag */ + const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ + const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ +#endif const int16_t ism_md_subframe_update, float *output[], /* i/o: SCE channels / Binaural synthesis */ const int16_t output_frame, /* i : output frame length */ @@ -878,6 +885,12 @@ ivas_error ivas_rend_crendProcessSubframe( 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 */ +#ifdef NONBE_UNIFIED_DECODING_PATHS +#ifdef SPLIT_REND_WITH_HEAD_ROT + , + const int16_t pos_idx +#endif +#endif ); @@ -1241,6 +1254,22 @@ void rotateFrame_sd( const int16_t subframe_idx /* i : subframe index */ ); +#ifdef NONBE_UNIFIED_DECODING_PATHS +void ivas_combined_orientation_update_index( + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ + const int16_t samples_rendered /* i : samples rendered since the last call */ +); + +void ivas_combined_orientation_update_start_index( + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ + const int16_t samples_rendered /* i : samples rendered since the last call */ +); + +void ivas_combined_orientation_set_to_start_index( + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ +); +#endif + void rotateFrame_shd_cldfb( float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */ float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ @@ -1271,7 +1300,10 @@ void ivas_external_orientation_close( ivas_error ivas_combined_orientation_open( COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* o : combined orientation handle */ - const int16_t num_subframes /* i : number of subframes */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + const int32_t fs, +#endif + const int16_t num_subframes ); void ivas_combined_orientation_close( @@ -1719,6 +1751,30 @@ ivas_error ObjRenderIvasFrame_splitBinaural( const int16_t output_frame /* i : output frame length */ ); +#ifdef NONBE_UNIFIED_DECODING_PATHS +ivas_error ivas_td_binaural_renderer_sf_splitBinaural( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + int16_t nSamplesRendered /* i : number of samples to render */ +); + +ivas_error ivas_rend_crendProcessSubframesSplitBin( + 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 MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + 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 + ivas_error ivas_rend_crendProcessSplitBin( const CREND_WRAPPER *pCrend, const AUDIO_CONFIG inConfig, diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index b6420deed1f928a94ba2d62a7064a9b9e1b054fc..daa0be2b0b9f28d949ae0a2fa0e25754d7b34e2d 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -394,7 +394,11 @@ void rotateFrame_shd( SHrotmatgen( SHrotmat_prev, hCombinedOrientationData->Rmat_prev, shd_rot_max_order ); #endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + SHrotmatgen( SHrotmat, hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], shd_rot_max_order ); +#else SHrotmatgen( SHrotmat, hCombinedOrientationData->Rmat[subframe_idx], shd_rot_max_order ); +#endif for ( i = 0; i < subframe_len; i++ ) { @@ -448,7 +452,11 @@ void rotateFrame_shd( for ( i = 0; i < 3; i++ ) { mvr2r( +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], +#else hCombinedOrientationData->Rmat[subframe_idx][i], +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT hCombinedOrientationData->Rmat_prev[0][i], #else @@ -544,7 +552,13 @@ void rotateFrame_sd( } /* gains for current subframe rotation */ - rotateAziEle( hTransSetup.ls_azimuth[ch_in_woLFE], hTransSetup.ls_elevation[ch_in_woLFE], &azimuth, &elevation, hCombinedOrientationData->Rmat[subframe_idx], hTransSetup.is_planar_setup ); + rotateAziEle( hTransSetup.ls_azimuth[ch_in_woLFE], hTransSetup.ls_elevation[ch_in_woLFE], &azimuth, &elevation, +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], +#else + hCombinedOrientationData->Rmat[subframe_idx], +#endif + hTransSetup.is_planar_setup ); if ( hEFAPdata != NULL && ( hTransSetup.ls_azimuth[ch_in_woLFE] != azimuth || hTransSetup.ls_elevation[ch_in_woLFE] != elevation ) ) { efap_determine_gains( hEFAPdata, tmp_gains, azimuth, elevation, EFAP_MODE_EFAP ); @@ -582,7 +596,11 @@ void rotateFrame_sd( for ( i = 0; i < 3; i++ ) { mvr2r( +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], +#else hCombinedOrientationData->Rmat[subframe_idx][i], +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT hCombinedOrientationData->Rmat_prev[0][i], #else @@ -871,8 +889,10 @@ void ivas_external_orientation_close( ivas_error ivas_combined_orientation_open( COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* o : combined orientation handle */ - const int16_t num_subframes /* i : number of subframes */ -) +#ifdef NONBE_UNIFIED_DECODING_PATHS + const int32_t fs, +#endif + const int16_t num_subframes ) { int16_t i; int16_t j; @@ -935,6 +955,9 @@ ivas_error ivas_combined_orientation_open( } } ( *hCombinedOrientationData )->sr_pose_pred_axis = DEFAULT_AXIS; +#ifdef NONBE_UNIFIED_DECODING_PATHS + ( *hCombinedOrientationData )->sr_low_res_flag = 0; +#endif #else for ( j = 0; j < 3; j++ ) { @@ -956,6 +979,12 @@ ivas_error ivas_combined_orientation_open( ( *hCombinedOrientationData )->isExtOrientationFrozen = 0; ( *hCombinedOrientationData )->isHeadRotationFrozen = 0; +#ifdef NONBE_UNIFIED_DECODING_PATHS + ( *hCombinedOrientationData )->subframe_idx = 0; + ( *hCombinedOrientationData )->subframe_size = (int16_t) ( fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); + ( *hCombinedOrientationData )->cur_subframe_samples_rendered = 0; +#endif + return IVAS_ERR_OK; } @@ -1327,6 +1356,12 @@ ivas_error combine_external_and_head_orientations( #ifdef SPLIT_REND_WITH_HEAD_ROT hCombinedOrientationData->sr_pose_pred_axis = sr_pose_pred_axis; #endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + hCombinedOrientationData->subframe_idx = 0; + hCombinedOrientationData->cur_subframe_samples_rendered = 0; + hCombinedOrientationData->subframe_idx_start = 0; + hCombinedOrientationData->cur_subframe_samples_rendered_start = 0; +#endif return IVAS_ERR_OK; } @@ -1679,3 +1714,91 @@ void SHrotmatgen( return; } + +#ifdef NONBE_UNIFIED_DECODING_PATHS +/*------------------------------------------------------------------------- + * ivas_combined_orientation_update_index() + * + * update read index based on the number of rendered samples + *------------------------------------------------------------------------*/ + +void ivas_combined_orientation_update_index( + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ + const int16_t samples_rendered /* i : samples rendered since the last call */ +) +{ + if ( hCombinedOrientationData != NULL ) + { + if ( hCombinedOrientationData->num_subframes == 1 +#ifdef SPLIT_REND_WITH_HEAD_ROT + || hCombinedOrientationData->sr_low_res_flag +#endif + ) + { + /* only one orientation available anyway or split rendering with low resolution*/ + hCombinedOrientationData->subframe_idx = 0; + } + else + { + hCombinedOrientationData->cur_subframe_samples_rendered += samples_rendered; + hCombinedOrientationData->subframe_idx += hCombinedOrientationData->cur_subframe_samples_rendered / hCombinedOrientationData->subframe_size; + hCombinedOrientationData->cur_subframe_samples_rendered = hCombinedOrientationData->cur_subframe_samples_rendered % hCombinedOrientationData->subframe_size; + hCombinedOrientationData->subframe_idx = min( hCombinedOrientationData->subframe_idx, hCombinedOrientationData->num_subframes - 1 ); + } + } + return; +} + + +/*------------------------------------------------------------------------- + * ivas_combined_orientation_update_index() + * + * update read index based on the number of rendered samples + *------------------------------------------------------------------------*/ + +void ivas_combined_orientation_set_to_start_index( + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ +) +{ + if ( hCombinedOrientationData != NULL ) + { + hCombinedOrientationData->subframe_idx = hCombinedOrientationData->subframe_idx_start; + hCombinedOrientationData->cur_subframe_samples_rendered = hCombinedOrientationData->cur_subframe_samples_rendered_start; + } + return; +} + +/*------------------------------------------------------------------------- + * ivas_combined_orientation_update_start_index() + * + * update read index based on the number of rendered samples + *------------------------------------------------------------------------*/ + +void ivas_combined_orientation_update_start_index( + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ + const int16_t samples_rendered /* i : samples rendered since the last call */ +) +{ + if ( hCombinedOrientationData != NULL ) + { + if ( hCombinedOrientationData->num_subframes == 1 +#ifdef SPLIT_REND_WITH_HEAD_ROT + || hCombinedOrientationData->sr_low_res_flag +#endif + ) + { + /* only one orientation available anyway or split rendering with low resolution*/ + hCombinedOrientationData->subframe_idx = 0; + } + else + { + hCombinedOrientationData->cur_subframe_samples_rendered_start += samples_rendered; + hCombinedOrientationData->subframe_idx_start += hCombinedOrientationData->cur_subframe_samples_rendered / hCombinedOrientationData->subframe_size; + hCombinedOrientationData->cur_subframe_samples_rendered_start = hCombinedOrientationData->cur_subframe_samples_rendered % hCombinedOrientationData->subframe_size; + hCombinedOrientationData->subframe_idx_start = min( hCombinedOrientationData->subframe_idx, hCombinedOrientationData->num_subframes - 1 ); + } + } + return; +} + +#endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index ae8a382f3e389fb96860d673d7dfab61a72ffe60..79a7951e531438793d133f52fa5bf0ac692a14fc 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -701,13 +701,22 @@ typedef struct ivas_combined_orientation_struct IVAS_VECTOR3 listenerPos[MAX_PARAM_SPATIAL_SUBFRAMES]; #ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; +#ifdef NONBE_UNIFIED_DECODING_PATHS + int16_t sr_low_res_flag; +#endif #endif IVAS_QUATERNION Quaternion_frozen_ext; IVAS_QUATERNION Quaternion_frozen_head; int8_t isExtOrientationFrozen; int8_t isHeadRotationFrozen; int16_t num_subframes; - +#ifdef NONBE_UNIFIED_DECODING_PATHS + int16_t subframe_idx; + int16_t subframe_size; + int16_t cur_subframe_samples_rendered; + int16_t subframe_idx_start; + int16_t cur_subframe_samples_rendered_start; +#endif } COMBINED_ORIENTATION_DATA, *COMBINED_ORIENTATION_HANDLE; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index f319e46bbd32c69a829df3f7e3fe83b8b84e1adb..566b2e52d1ab7019f5b9dea4745b1a5c16d25d91 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3207,7 +3207,9 @@ static DecoderDummy *initDecoderDummy( decDummy->hDecoderConfig->nchan_out = numOutChannels; decDummy->hDecoderConfig->Opt_Headrotation = 0; decDummy->hDecoderConfig->Opt_tsm = 0; +#ifndef NONBE_UNIFIED_DECODING_PATHS decDummy->hDecoderConfig->Opt_5ms = 0; +#endif decDummy->hBinRenderer = NULL; #ifdef SPLIT_REND_WITH_HEAD_ROT decDummy->hSplitBinRend.hSplitRendBits = NULL; @@ -3285,7 +3287,11 @@ static DecoderDummy *initDecoderDummy( } /* Combined orientations */ - if ( ( error = ivas_combined_orientation_open( &( decDummy->hCombinedOrientationData ), num_subframes ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_combined_orientation_open( &( decDummy->hCombinedOrientationData ), +#ifdef NONBE_UNIFIED_DECODING_PATHS + sampleRate, +#endif + num_subframes ) ) != IVAS_ERR_OK ) { assert( error == IVAS_ERR_OK ); } @@ -3637,7 +3643,11 @@ ivas_error IVAS_REND_Open( } /* Initilize combined orientation data */ - if ( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), num_subframes ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), +#ifdef NONBE_UNIFIED_DECODING_PATHS + outputSampleRate, +#endif + num_subframes ) ) != IVAS_ERR_OK ) { return error; } @@ -6370,6 +6380,11 @@ static ivas_error renderInputIsm( /* Apply input gain to new audio */ v_multc( inAudio.data, ismInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* set combined orientation subframe info to start info */ + ivas_combined_orientation_set_to_start_index( *ismInput->base.ctx.pCombinedOrientationData ); +#endif + switch ( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: @@ -7096,6 +7111,11 @@ static ivas_error renderInputMc( /* Apply input gain to new audio */ v_multc( inAudio.data, mcInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* set combined orientation subframe info to start info */ + ivas_combined_orientation_set_to_start_index( *( mcInput->base.ctx.pCombinedOrientationData ) ); +#endif + switch ( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: @@ -7948,6 +7968,12 @@ static ivas_error renderInputSba( /* Apply input gain to new audio */ v_multc( inAudio.data, sbaInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* set combined orientation subframe info to start info */ + ivas_combined_orientation_set_to_start_index( *( sbaInput->base.ctx.pCombinedOrientationData ) ); +#endif + + switch ( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: @@ -8355,6 +8381,11 @@ static ivas_error renderInputMasa( /* Apply input gain to new audio */ v_multc( inAudio.data, masaInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* set combined orientation subframe info to start info */ + ivas_combined_orientation_set_to_start_index( *( masaInput->base.ctx.pCombinedOrientationData ) ); +#endif + switch ( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: @@ -8826,6 +8857,11 @@ static ivas_error getSamplesInternal( } #endif +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* update global cominbed orientation start index */ + ivas_combined_orientation_update_start_index( hIvasRend->hCombinedOrientationData, outAudio.config.numSamplesPerChannel ); +#endif + return IVAS_ERR_OK; }