diff --git a/apps/decoder.c b/apps/decoder.c index 959d7f5094b82908eba65956b6b5ec49603e6a82..9b5619ceacba661f4e0663c2380c127782665ae4 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,12 @@ 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 +#ifndef NONBE_UNIFIED_DECODING_PATHS static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); +#else +static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); +#endif + #ifdef DEBUGGING static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); static int16_t app_own_random( int16_t *seed ); @@ -197,6 +202,9 @@ int main( Vector3PairFileReader *referenceVectorReader = NULL; RenderConfigReader *renderConfigReader = NULL; int16_t *pcmBuf = NULL; +#ifdef NONBE_UNIFIED_DECODING_PATHS + IVAS_RENDER_FRAMESIZE asked_frame_size; +#endif #ifdef DEBUGGING int32_t noClipping; int32_t cnt_frames_limited; @@ -429,13 +437,32 @@ 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 ) +#ifndef NONBE_UNIFIED_DECODING_PATHS + 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 ) +#else + asked_frame_size = arg.renderFramesize; + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, 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 ) +#endif + + { + 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 decoding to EXT!\n" ); + } +#endif + /*------------------------------------------------------------------------------------------* * Configure Split rendering *------------------------------------------------------------------------------------------*/ @@ -443,12 +470,28 @@ 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 + 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; } #endif @@ -602,22 +645,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 ) ) +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( arg.renderFramesize == IVAS_RENDER_FRAMESIZE_5MS && ( renderConfig.split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + renderConfig.split_rend_config.dof == 0 ) ) +#else + if ( arg.enable5ms && ( renderConfig.split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE || + renderConfig.split_rend_config.dof == 0 ) ) +#endif { - /*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 +818,11 @@ int main( if ( arg.voipMode ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec ); +#else error = decodeVoIP( arg, hBsReader, hIvasDec ); +#endif } else { @@ -1012,19 +1076,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 +1218,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 +1251,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 +1273,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,11 +1620,13 @@ 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 +1664,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 +1675,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 +1761,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 +2008,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 +2045,7 @@ static ivas_error initOnFirstGoodFrame( *numOutSamples = (int16_t) ( arg.output_Fs / 1000 * DEFAULT_FETCH_FRAMESIZE_MS ); *vec_pos_len = 1; } +#endif } #endif @@ -1997,7 +2087,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 +2167,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,6 +2189,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 @@ -2133,6 +2236,7 @@ static ivas_error decodeG192( } } +#ifndef NONBE_UNIFIED_DECODING_PATHS int16_t enable5ms, num_subframes; if ( ( error = IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ) ) != IVAS_ERR_OK ) { @@ -2140,7 +2244,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 +2906,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 +2954,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 +3076,138 @@ 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 +3261,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 +3321,7 @@ static ivas_error decodeVoIP( goto cleanup; } } -#ifdef DEBUG_JBM_CMD_OPTION - else if ( arg.noBadFrameDelay == false ) -#else else -#endif { ++numInitialBadFrames; } @@ -3144,7 +3395,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..7d890c648e34659c0da5ef7536c50f3aed041c6d 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,39 @@ 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 +2697,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 +2863,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..1ccb94000c0162c2345037fa2c53218ae90d130d 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -150,6 +150,17 @@ 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..04850edf4e7c77ef92e1dbdac0e2ea618c5dce47 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -190,6 +190,7 @@ typedef enum TC_BUFFER_MODE_BUFFER } TC_BUFFER_MODE; + /*----------------------------------------------------------------------------------* * IVAS Bitrates *----------------------------------------------------------------------------------*/ @@ -1213,7 +1214,6 @@ 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 - #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 ec085c65848cbe42a10b74a20eda2bed6e495981..c07df11308e97bd13b2ce49a7744f77cb8dcbfa1 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -902,10 +902,10 @@ 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 */ + 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 */ ); ivas_error ivas_jbm_dec_tc_buffer_open( @@ -5280,13 +5280,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 */ diff --git a/lib_com/options.h b/lib_com/options.h index 48d4845cc382022420a8cdeacaac4661718928dd..88a8a0757279c9f3c7bae35ac566c5961e8ca6b2 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 */ #define FIX_817_DOUBLE_PREC_REND_MD /* Eri: Issue 817: Avoid double precision in renderer metadata module */ @@ -173,6 +173,7 @@ #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 */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index efb4ee9e3f01fb2b2c8d8f2c2968a9706317187d..bd13d245a42c90c093075772e9fed1fa9266024b 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1650,15 +1650,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 ) @@ -1700,6 +1706,11 @@ 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++ ) { @@ -1823,11 +1834,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 ) @@ -1847,6 +1870,11 @@ 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++ ) { @@ -1889,8 +1917,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 @@ -1941,24 +1971,40 @@ void ivas_binRenderer( #endif /* Head rotation in HOA3 or CICPx */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] && hBinRenderer->rotInCldfb ) +#else if ( hCombinedOrientationData != NULL && hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && hBinRenderer->rotInCldfb ) +#endif { if ( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) { /* Rotation in SHD (HOA3) */ if ( hCombinedOrientationData->shd_rot_max_order == -1 ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); +#else rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, hCombinedOrientationData->Rmat[subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); +#endif } else if ( hCombinedOrientationData->shd_rot_max_order > 0 ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); +#else rotateFrame_shd_cldfb( RealBuffer, ImagBuffer, hCombinedOrientationData->Rmat[subframe_idx], hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, hCombinedOrientationData->shd_rot_max_order ); +#endif } } else { /* Rotation in SD (CICPx) */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + rotateFrame_sd_cldfb( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], RealBuffer, ImagBuffer, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); +#else rotateFrame_sd_cldfb( hCombinedOrientationData->Rmat[subframe_idx], RealBuffer, ImagBuffer, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); +#endif } } @@ -2151,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..bef9fa9b8d1e6c9cab28094495c99689638599e3 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -94,13 +94,17 @@ ivas_error ivas_dec( } /*----------------------------------------------------------------* - * Combine orientations + * Update combined orientation access index *----------------------------------------------------------------*/ +#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 /*----------------------------------------------------------------* @@ -111,8 +115,8 @@ ivas_error ivas_dec( { ivas_set_split_rend_ht_setup( &st_ivas->hSplitBinRend, st_ivas->hCombinedOrientationData ); } -#endif +#endif /*----------------------------------------------------------------* * Decoding + Rendering *----------------------------------------------------------------*/ @@ -1054,7 +1058,6 @@ ivas_error ivas_dec( } } - /*----------------------------------------------------------------* * Write IVAS output channels * - compensation for saturation @@ -1130,6 +1133,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..ebdee8beaeed441ed726d830894ce1f980fa6f3e 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -948,12 +948,15 @@ ivas_error ivas_dirac_dec_config( } } +#ifndef NONBE_UNIFIED_DECODING_PATHS /* Allocate transport channel buffers for SBA format when in JBM */ if ( dec_config_flag == DIRAC_OPEN ) { - if ( - st_ivas->hDecoderConfig->Opt_5ms && - st_ivas->hTcBuffer == NULL ) +#ifndef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL ) +#else + if ( st_ivas->hTcBuffer == NULL ) +#endif { if ( st_ivas->ivas_format == SBA_FORMAT ) { @@ -978,6 +981,7 @@ ivas_error ivas_dirac_dec_config( } } } +#endif return error; } @@ -1630,6 +1634,11 @@ void ivas_dirac_dec( { output_f_local[n] += 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->hDirAC->hConfig->dec_param_estim == 1 ) @@ -1710,6 +1719,11 @@ 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,17 @@ void ivas_dirac_dec_render_sf( set_zero( onset_filter_subframe, hSpatParamRendCom->num_freq_bands ); } +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] ) +#else if ( st_ivas->hCombinedOrientationData && 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 +1945,11 @@ void ivas_dirac_dec_render_sf( } } +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 1 ) +#else if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 1 ) +#endif { ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, hDirACRend, @@ -2050,7 +2076,11 @@ void ivas_dirac_dec_render_sf( if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) +#else if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) +#endif { protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, @@ -2282,7 +2312,11 @@ void ivas_dirac_dec_render_sf( } /*Compute PSDs*/ +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) +#else if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) +#endif { ivas_dirac_dec_output_synthesis_process_slot( reference_power, p_onset_filter, @@ -2479,12 +2513,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..7ed132c87b2ec8745260b72e9e9b46280b4bd219 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -259,7 +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; } @@ -353,9 +357,11 @@ 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 +376,11 @@ 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 +1030,11 @@ ivas_error ivas_init_decoder_front( if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1031,7 +1046,11 @@ ivas_error ivas_init_decoder_front( if ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_framesize ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1962,8 +1981,10 @@ ivas_error ivas_init_decoder( } } +#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 ); @@ -1971,7 +1992,9 @@ ivas_error ivas_init_decoder( { return error; } +#ifndef NONBE_UNIFIED_DECODING_PATHS } +#endif } else if ( st_ivas->renderer_type == RENDERER_MC ) { @@ -2010,8 +2033,10 @@ ivas_error ivas_init_decoder( st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; +#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 ) ) { granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); @@ -2034,7 +2059,9 @@ ivas_error ivas_init_decoder( return error; } } +#ifndef NONBE_UNIFIED_DECODING_PATHS } +#endif } if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) @@ -2177,7 +2204,12 @@ ivas_error ivas_init_decoder( * Allocate and initialize JBM struct + buffer *-----------------------------------------------------------------*/ +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL ) +#else + if ( st_ivas->hTcBuffer == NULL ) +#endif + { /* 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 ); @@ -2212,8 +2244,10 @@ ivas_error ivas_init_decoder( * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_5ms ) { +#endif for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) { /* note: these are intra-frame heap memories */ @@ -2222,17 +2256,20 @@ ivas_error ivas_init_decoder( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } } +#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; } + return error; } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index f778e7f23f41779f99ef74d5d9d0de22687e763f..99a02aaabe401f705a19fed06641ea4e4dd668d3 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -91,6 +91,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); #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 ) { return error; @@ -136,7 +137,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 ) ) @@ -330,7 +333,9 @@ 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 nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); @@ -342,6 +347,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( #else nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + if ( nchan_out_buff > nchan_out_buff_old ) { for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) @@ -367,8 +373,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( /*-----------------------------------------------------------------* * JBM TC buffers *-----------------------------------------------------------------*/ - +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms ) +#endif { int16_t tc_nchan_full_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index fda2762c2b0ecfb3ca7e34c2a2fcc19e36d91997..d355798f6da6d20ea4ef2a775091899a55bf2b4f 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; @@ -648,12 +652,14 @@ 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; @@ -1205,7 +1211,11 @@ void ivas_param_ism_dec_digest_tc( } } +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) +#else + if ( st_ivas->hDecoderConfig->Opt_tsm ) +#endif { /*TODO : FhG to check*/ ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, fade_len, transport_channels_f ); @@ -1216,7 +1226,11 @@ void ivas_param_ism_dec_digest_tc( /* CLDFB Analysis */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) +#else + if ( st_ivas->hDecoderConfig->Opt_tsm ) +#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..bb57f4c479b4fd0d682d34b27d0a2e8273cbc7ff 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -270,12 +270,17 @@ void ivas_ism_render_sf( tc_offset = st_ivas->hTcBuffer->n_samples_rendered; interp_offset = st_ivas->hTcBuffer->n_samples_rendered; + for ( i = 0; i < nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { set_f( output_f[i], 0.0f, n_samples_to_render ); } +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 ) +#else if ( st_ivas->hCombinedOrientationData && 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,9 +289,14 @@ void ivas_ism_render_sf( for ( i = 0; i < num_objects; i++ ) { /* Combined rotation: rotate the object positions depending the head and external orientations */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 ) +#else if ( st_ivas->hCombinedOrientationData != NULL && 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 ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); @@ -315,13 +325,22 @@ void ivas_ism_render_sf( } /* update here only in case of head rotation */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hCombinedOrientationData != NULL && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] == 1 ) +#else if ( st_ivas->hCombinedOrientationData != NULL && 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; } @@ -643,12 +662,10 @@ void ivas_omasa_separate_object_render_jbm( { output_f_local[j] = output_f[j]; } - for ( obj = 0; obj < num_objects; obj++ ) { input_f[obj] = &st_ivas->hTcBuffer->tc[obj + 2][offsetSamples]; } - slots_to_render = nSamplesRendered / hSpatParamRendCom->slot_size; first_sf = subframes_rendered; last_sf = first_sf; @@ -669,7 +686,6 @@ 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 ); } - 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..3e91dce0444914a0246ea4d3973b53cd38dfceea 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -705,7 +705,11 @@ ivas_error ivas_jbm_dec_tc( * Write IVAS transport channels *----------------------------------------------------------------*/ +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_tsm == 1 || !st_ivas->hDecoderConfig->Opt_5ms ) +#else + if ( st_ivas->hDecoderConfig->Opt_tsm == 1 ) +#endif { ivas_syn_output_f( p_output, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data ); } @@ -774,7 +778,12 @@ void ivas_jbm_dec_feed_tc_to_renderer( p_data_f[n] = &data_f[n][0]; } + +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) +#else + if ( st_ivas->hDecoderConfig->Opt_tsm ) +#endif { ivas_jbm_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data, p_data_f ); } @@ -830,11 +839,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++ ) { @@ -926,6 +944,9 @@ 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 SPLIT_REND_WITH_HEAD_ROT + int16_t nchan_out_syn_output; +#endif push_wmops( "ivas_dec_render" ); /*----------------------------------------------------------------* @@ -939,6 +960,7 @@ 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++ ) { p_output[n] = &output[n][0]; @@ -949,6 +971,7 @@ ivas_error ivas_jbm_dec_render( p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered]; } +#ifndef NONBE_UNIFIED_DECODING_PATHS /*----------------------------------------------------------------* * Combine orientations *----------------------------------------------------------------*/ @@ -957,6 +980,19 @@ ivas_error ivas_jbm_dec_render( { return error; } +#else + /*----------------------------------------------------------------* + * Update combined orientation access index + *----------------------------------------------------------------*/ + + 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 +1063,33 @@ 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 ( defined NONBE_UNIFIED_DECODING_PATHS && defined SPLIT_REND_WITH_HEAD_ROT ) + 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, 0 ) ) != IVAS_ERR_OK ) +#else 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 ) +#endif { return error; } @@ -1155,7 +1210,6 @@ ivas_error ivas_jbm_dec_render( { ivas_ism_render_sf( st_ivas, p_output_ism, *nSamplesRendered ); } - for ( n = 0; n < nchan_out; n++ ) { if ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) @@ -1230,13 +1284,36 @@ 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 ( defined NONBE_UNIFIED_DECODING_PATHS && defined SPLIT_REND_WITH_HEAD_ROT ) + 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, 0 ) ) != IVAS_ERR_OK ) +#else + 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 ) + +#endif - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); + { + return error; + } + + 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 +1326,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 +1379,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 ) @@ -1358,6 +1464,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 +1480,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 +1509,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 +1517,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 +1574,11 @@ 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 + /* update combined orientation access index */ + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); +#endif + if ( n_slots_still_available ) { int16_t ch_idx; @@ -1506,8 +1631,13 @@ 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 ) +#if ( defined NONBE_UNIFIED_DECODING_PATHS && defined SPLIT_REND_WITH_HEAD_ROT ) + 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, 0 ) ) != IVAS_ERR_OK ) +#else + 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 ) +#endif { return error; } @@ -1526,8 +1656,13 @@ ivas_error ivas_jbm_dec_flush_renderer( { if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV || renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { +#if ( defined NONBE_UNIFIED_DECODING_PATHS && defined SPLIT_REND_WITH_HEAD_ROT ) + 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, 0 ) ) != IVAS_ERR_OK ) +#else 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 ) +#endif { return error; } @@ -1629,6 +1764,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*/ @@ -1917,6 +2057,7 @@ int16_t ivas_jbm_dec_get_num_tc_channels( int32_t ivas_total_brate; AUDIO_CONFIG output_config; + if ( st_ivas->renderer_type == RENDERER_DISABLE ) { num_tc = st_ivas->hDecoderConfig->nchan_out; @@ -2279,6 +2420,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer = st_ivas->hTcBuffer; + /* if granularity changes, adapt subframe_nb_slots */ if ( n_samples_granularity != hTcBuffer->n_samples_granularity ) { @@ -2318,16 +2460,22 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer->nchan_buffer_full = nchan_full; nchan_residual = nchan_transport_internal - nchan_full; hTcBuffer->n_samples_granularity = n_samples_granularity; + #ifdef DEBUGGING /* what is remaining from last frames needs always be smaller than n_samples_granularity */ assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity ); #endif - /* realloc buffers */ - if ( hTcBuffer->tc_buffer ) +#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 + 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 ); @@ -2341,28 +2489,42 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; - if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( nsamp_to_allocate == 0 ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); - } - set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); - - offset = 0; - for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_full; + hTcBuffer->tc_buffer = NULL; + for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } } - for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + else { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_residual; - } +#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 return IVAS_ERR_OK; } @@ -2603,12 +2765,12 @@ 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++ ) { mvr2r( tc[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], hTcBuffer->n_samples_buffered ); } - /* 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..a160275ea96358f2132e79d2f868d75799107005 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -622,7 +622,11 @@ ivas_error ivas_masa_dec_open( st_ivas->hMasa = hMasa; /* allocate transport channels*/ +#ifndef NONBE_UNIFIED_DECODING_PATHS 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 ) +#else + if ( 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 ) +#endif { int16_t nchan_to_allocate, nchan_transport; TC_BUFFER_MODE buffer_mode; @@ -1258,15 +1262,19 @@ 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 ) { mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; } +#ifndef NONBE_UNIFIED_DECODING_PATHS } +#endif ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); @@ -1450,7 +1458,9 @@ 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 { int16_t tc_nchan_to_allocate; int16_t tc_nchan_transport; @@ -1472,11 +1482,9 @@ ivas_error ivas_masa_dec_reconfigure( { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } - if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ - if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) @@ -1506,6 +1514,7 @@ ivas_error ivas_masa_dec_reconfigure( tc_nchan_to_allocate++; } + 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 ) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index cfc070a02ff21f949900e5c710f39856e24cda31..d6e7ade6fabbac6acb7687fc5ef115a2ad85cfe1 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 ); +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms && hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) +#else + if ( hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) +#endif { int16_t n_cldfb_slots; @@ -970,6 +974,60 @@ ivas_error ivas_param_mc_dec_reconfig( set_zero( hParamMC->proto_frame_f, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands ); } + +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( nchan_transport_old != nchan_transport ) + { + if ( hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) + { + int16_t n_cldfb_slots; + + + if ( hParamMC->Cldfb_RealBuffer_tc != NULL ) + { + free( hParamMC->Cldfb_RealBuffer_tc ); + hParamMC->Cldfb_RealBuffer_tc = NULL; + } + + if ( hParamMC->Cldfb_RealBuffer_tc != NULL ) + { + free( hParamMC->Cldfb_RealBuffer_tc ); + hParamMC->Cldfb_RealBuffer_tc = NULL; + } + + n_cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; + if ( st_ivas->hDecoderConfig->Opt_tsm ) + { + n_cldfb_slots = MAX_JBM_CLDFB_TIMESLOTS; + } + if ( ( hParamMC->Cldfb_RealBuffer_tc = (float *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); + } + set_zero( hParamMC->Cldfb_RealBuffer_tc, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); + + if ( ( hParamMC->Cldfb_ImagBuffer_tc = (float *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); + } + set_zero( hParamMC->Cldfb_ImagBuffer_tc, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); + } + else + { + if ( hParamMC->Cldfb_RealBuffer_tc != NULL ) + { + free( hParamMC->Cldfb_RealBuffer_tc ); + hParamMC->Cldfb_RealBuffer_tc = NULL; + } + + if ( hParamMC->Cldfb_RealBuffer_tc != NULL ) + { + free( hParamMC->Cldfb_RealBuffer_tc ); + hParamMC->Cldfb_RealBuffer_tc = NULL; + } + } + } +#endif return error; } @@ -1434,7 +1492,11 @@ void ivas_param_mc_dec_digest_tc( /* slot loop for gathering the input data */ for ( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) +#else + if ( st_ivas->hDecoderConfig->Opt_tsm ) +#endif { float RealBuffer[CLDFB_NO_CHANNELS_MAX]; float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; @@ -1745,22 +1807,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 ) @@ -1779,6 +1838,11 @@ 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..2582b5a8085153987aa561ff5ceda65efaf2481f 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -351,19 +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, +#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 ) @@ -384,6 +386,11 @@ 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++ ) { @@ -566,6 +573,11 @@ 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,8 +674,10 @@ 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 ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) ); @@ -671,9 +685,15 @@ ivas_error ivas_mc_paramupmix_dec_open( hMCParamUpmix->free_param_interpolator = 1; ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator ); +#ifndef NONBE_UNIFIED_DECODING_PATHS } +#endif +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 && st_ivas->hTcBuffer == NULL ) +#else + if ( st_ivas->hTcBuffer == NULL ) +#endif { int16_t nchan_to_allocate; int16_t nchan_tc; @@ -699,7 +719,6 @@ ivas_error ivas_mc_paramupmix_dec_open( return error; } } - st_ivas->hMCParamUpmix = hMCParamUpmix; return error; @@ -1141,11 +1160,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..df488824b30b71946f43a54ecb330365e9e1ae26 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -776,8 +776,11 @@ 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 ) { @@ -804,7 +807,7 @@ static ivas_error ivas_mc_dec_reconfig( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif { return error; @@ -818,7 +821,9 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } +#ifndef NONBE_UNIFIED_DECODING_PATHS } +#endif if ( st_ivas->mc_mode == MC_MODE_MCT ) { @@ -1324,7 +1329,9 @@ static ivas_error ivas_mc_dec_reconfig( * JBM TC buffers *-----------------------------------------------------------------*/ +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) +#endif { int16_t tc_nchan_full_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; @@ -1368,7 +1375,6 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } - /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hSpatParamRendCom != NULL ) { @@ -1388,13 +1394,15 @@ 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 nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); @@ -1403,29 +1411,30 @@ static ivas_error ivas_mc_dec_reconfig( return error; } #else - int16_t nchan_out_buff, ch; - nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + int16_t nchan_out_buff, ch; + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - if ( nchan_out_buff > nchan_out_buf_old ) + if ( nchan_out_buff > nchan_out_buf_old ) + { + for ( ch = nchan_out_buf_old; ch < nchan_out_buff; ch++ ) { - for ( ch = nchan_out_buf_old; ch < nchan_out_buff; ch++ ) + /* note: these are intra-frame heap memories */ + if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ { - /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } } - else + } + else + { + for ( ch = nchan_out_buff; ch < nchan_out_buf_old; ch++ ) { - for ( ch = nchan_out_buff; ch < nchan_out_buf_old; ch++ ) - { - free( st_ivas->p_output_f[ch] ); - st_ivas->p_output_f[ch] = NULL; - } + free( st_ivas->p_output_f[ch] ); + st_ivas->p_output_f[ch] = NULL; } + } #endif +#ifndef NONBE_UNIFIED_DECODING_PATHS } #endif diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 11e71c925c6fed7f9f39f1555381275b4b973586..ce71f1307a91dc932642e0a64581cab574bfdf72 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -98,11 +98,16 @@ ivas_error ivas_td_binaural_renderer( ism_md_subframe_update = 2; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + 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, st_ivas->hCombinedOrientationData, ism_md_subframe_update, output, output_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); + +#else 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, ( 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 } @@ -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,143 @@ 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; + + /* update combined orientation access index */ + 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..fdcae487df91488a296c6bd527f92f2b28bf3515 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -49,7 +49,6 @@ #define OMASA_TDREND_MATCHING_GAIN 0.7943f - /*-------------------------------------------------------------------* * ivas_omasa_data_open() * @@ -405,41 +404,45 @@ 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 nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); - if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) { return error; } #else - nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - if ( nchan_out_buff > nchan_out_buff_old ) + if ( nchan_out_buff > nchan_out_buff_old ) + { + for ( k = nchan_out_buff_old; k < nchan_out_buff; k++ ) { - for ( k = nchan_out_buff_old; k < nchan_out_buff; k++ ) + /* note: these are intra-frame heap memories */ + if ( ( st_ivas->p_output_f[k] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ { - /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[k] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } } - else + } + else + { + for ( k = nchan_out_buff; k < nchan_out_buff_old; k++ ) { - for ( k = nchan_out_buff; k < nchan_out_buff_old; k++ ) - { - free( st_ivas->p_output_f[k] ); - st_ivas->p_output_f[k] = NULL; - } + free( st_ivas->p_output_f[k] ); + st_ivas->p_output_f[k] = NULL; } + } #endif +#ifndef NONBE_UNIFIED_DECODING_PATHS } +#endif } + return IVAS_ERR_OK; } @@ -665,6 +668,7 @@ void ivas_omasa_dirac_rend_jbm( subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; + ivas_dirac_dec_render( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_f ); ivas_omasa_separate_object_render_jbm( st_ivas, *nSamplesRendered, output_f, subframes_rendered, slots_rendered ); @@ -709,6 +713,11 @@ 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 + /* reset combined orientation access index before calling the td renderer */ + 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; @@ -767,11 +776,15 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( ivas_dirac_dec_binaural_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, nchan_transport, output_f ); +#ifdef NONBE_UNIFIED_DECODING_PATHS + /* reset combined orientation access index before calling the td renderer */ + ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); +#endif + if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } - 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..9c8f2a5b86109b357ed9ea949614fd75f13fd2fe 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -140,20 +140,65 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( return error; } - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) - { - return error; - } - 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 return IVAS_ERR_OK; } @@ -232,7 +277,12 @@ 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; - ObjRenderIvasFrame_splitBinaural( st_ivas, output, output_frame ); + + if ( ( error = ObjRenderIvasFrame_splitBinaural( st_ivas, output, output_frame ) ) != IVAS_ERR_OK ) + { + return error; + } + 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..575f14dedfffd4753900d5c76a56816c033eaf4b 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,21 @@ 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 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 + ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); @@ -585,7 +594,9 @@ ivas_error ivas_sba_dec_reconfigure( * 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; @@ -667,8 +678,10 @@ ivas_error ivas_sba_dec_reconfigure( * floating-point output audio buffers *-----------------------------------------------------------------*/ +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_5ms ) { +#endif nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); #ifdef NONBE_FIX_839_MC_RS_CHANNEL_ALLOC @@ -677,29 +690,31 @@ ivas_error ivas_sba_dec_reconfigure( return error; } #else - if ( nchan_out_buff > nchan_out_buff_old ) + if ( nchan_out_buff > nchan_out_buff_old ) + { + for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) { - for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) + /* note: these are intra-frame heap memories */ + if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ { - /* note: these are intra-frame heap memories */ - if ( ( st_ivas->p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); - } + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); } } - else + } + else + { + for ( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ ) { - for ( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ ) - { - free( st_ivas->p_output_f[ch] ); - st_ivas->p_output_f[ch] = NULL; - } + free( st_ivas->p_output_f[ch] ); + st_ivas->p_output_f[ch] = NULL; } + } #endif +#ifndef NONBE_UNIFIED_DECODING_PATHS } +#endif - return IVAS_ERR_OK; + return error; } @@ -852,6 +867,11 @@ 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..7ab8bf7fc4a19392824af09634f5581f3afdcc01 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -425,6 +425,7 @@ void ivas_ism2sba_sf( assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" ); + /* Init*/ sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); for ( j = 0; j < sba_num_chans; j++ ) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 9c6b45a2ed7b61416919417a8a0de814e371126c..0237a059a5b259878f0f097541319eb86daae255 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 ); @@ -211,7 +212,11 @@ ivas_error ivas_spar_dec_open( } /* allocate transport channels*/ - if ( ( st_ivas->hDecoderConfig->Opt_5ms || st_ivas->ivas_format == SBA_ISM_FORMAT ) && st_ivas->hTcBuffer == NULL ) +#ifndef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL || st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else + if ( st_ivas->hTcBuffer == NULL ) +#endif { int16_t nchan_to_allocate; int16_t nchan_tc; @@ -254,13 +259,14 @@ 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; @@ -1454,6 +1460,11 @@ void ivas_spar_dec_upmixer( { output_f_local[n] += 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 ( 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..9c5f8b2d789b5e73a439468cda24eda4a6389afb 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; @@ -435,6 +452,21 @@ ivas_error IVAS_DEC_Configure( 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; + } + if ( outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; + } + else + { + 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 +520,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 +532,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( } #endif +#ifndef NONBE_UNIFIED_DECODING_PATHS /*---------------------------------------------------------------------* * IVAS_DEC_Set5msFlag( ) * @@ -538,6 +575,146 @@ 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( + const 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 +746,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 +897,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 +958,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 +989,33 @@ 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 +1039,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 +1059,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 +1081,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 +1221,15 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_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 ) ) +#else 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 ) ) +#endif { numSamplesPerChannelToSplitEncode = (int16_t) ( output_Fs / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ); numSamplesPerChannelCacheSize = numSamplesPerChannelToDecode - numSamplesPerChannelToSplitEncode; @@ -1117,7 +1328,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,6 +1862,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 +1895,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 +1926,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 +1972,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 +2187,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 +3134,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 +3202,7 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "TSM mode: ON\n" ); } - +#ifndef NONBE_UNIFIED_DECODING_PATHS /*-----------------------------------------------------------------* * Print 5ms API mode info *-----------------------------------------------------------------*/ @@ -2980,6 +3211,7 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "API 5ms mode: ON\n" ); } +#endif return IVAS_ERR_OK; } @@ -3153,7 +3385,11 @@ static ivas_error evs_dec_main( v_multc( output[0], mixer_left, output[0], nOutSamples ); } +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hDecoderConfig->Opt_5ms ) +#else + if ( !st_ivas->hDecoderConfig->Opt_tsm ) +#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..8055ae2ea607ca9435d633badf45e83f46b41a61 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1861,6 +1861,11 @@ 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 +1903,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 +1922,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 +2012,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 +2028,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 +2061,11 @@ 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 +2222,171 @@ 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; + + /* update combined orientation access index */ + 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..0edeee6e38993c5febd09c598028854c630dfcd6 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -306,8 +306,12 @@ ivas_error ivas_dirac_dec_init_binaural_data( st_ivas->hDiracDecBin = hDiracDecBin; #endif - /* allocate transport channels*/ + /* allocate transport channels */ +#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL ) +#else + if ( st_ivas->hTcBuffer == NULL ) +#endif { int16_t nchan_to_allocate; int16_t n_samples_granularity; @@ -329,7 +333,6 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } - return IVAS_ERR_OK; } @@ -496,6 +499,11 @@ 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 ) @@ -632,6 +640,11 @@ 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; } @@ -847,7 +860,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 } } @@ -862,10 +879,14 @@ static void ivas_dirac_dec_binaural_internal( } } - #ifndef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_UNIFIED_DECODING_PATHS + 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[hCombinedOrientationData->subframe_idx] > 0, st_ivas->hMasaIsmData ); +#else 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 ); +#endif #endif if ( config_data.ivas_format == ISM_FORMAT ) @@ -885,9 +906,9 @@ static void ivas_dirac_dec_binaural_internal( #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, subFrameTotalEne, IIReneLimiter ); + ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, - subFrameTotalEne, IIReneLimiter, st_ivas->hMasaIsmData ); + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, subFrameTotalEne, IIReneLimiter, st_ivas->hMasaIsmData ); #endif nchanSeparateChannels = 0; @@ -900,9 +921,13 @@ static void ivas_dirac_dec_binaural_internal( nchanSeparateChannels = (uint8_t) st_ivas->nchan_ism; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat, subframe, + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); +#else ivas_dirac_dec_binaural_determine_processing_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, - nchanSeparateChannels, st_ivas->hMasaIsmData ); + hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT pMultiBinPoseData = &st_ivas->hSplitBinRend.splitrend.multiBinPoseData; diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 314f30af10af7132c07caa4952e0f15b86bb386b..a1e686020a6961ef9b1147b626b6cc65bf3cb115 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,11 @@ ivas_error ivas_td_binaural_renderer_unwrap( } /* Update the listener's location/orientation */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = TDREND_Update_listener_orientation( hBinRendererTd, ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[hCombinedOrientationData->subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[hCombinedOrientationData->subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[hCombinedOrientationData->subframe_idx] : NULL ) ) != IVAS_ERR_OK ) +#else 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 ) +#endif { return error; } @@ -363,6 +388,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 ) @@ -736,12 +766,16 @@ ivas_error ivas_td_binaural_renderer_ext( hIsmMetaData[0]->non_diegetic_flag = currentPos->non_diegetic_flag; } +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = ivas_td_binaural_renderer_unwrap( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, *hCombinedOrientationData, +#else if ( ( error = ivas_td_binaural_renderer_unwrap( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, + ( hCombinedOrientationData != NULL ) ? ( *hCombinedOrientationData )->enableCombinedOrientation : NULL, ( hCombinedOrientationData != NULL ) ? ( *hCombinedOrientationData )->Quaternions : NULL, ( hCombinedOrientationData != NULL ) ? ( *hCombinedOrientationData )->listenerPos : NULL, - 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 ) +#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 ) { return error; } @@ -776,7 +810,6 @@ ivas_error ObjRenderIvasFrame_splitBinaural( ivas_error error; push_wmops( "ObjRenderIvasFrame_splitBinaural" ); - pMultiBinPoseData = &st_ivas->hSplitBinRend.splitrend.multiBinPoseData; /* If not yet allocated, open additional instances of TD renderer */ @@ -807,7 +840,6 @@ ivas_error ObjRenderIvasFrame_splitBinaural( originalHeadRot[i] = st_ivas->hCombinedOrientationData->Quaternions[i]; } - /* Copy input audio to a processing buffer. Cannot render in-place because binaurally rendered * audio would overwrite original material, which is still needed for rendering next head pose. */ for ( i = 0; i < st_ivas->nchan_transport; ++i ) @@ -896,7 +928,6 @@ ivas_error ObjRenderIvasFrame_splitBinaural( } pop_wmops(); - return IVAS_ERR_OK; } #endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 38974ba42ea7b06998a4aa76ddde29a6f4646ddd..dbed26f7196fd1ae3fb1f5bd26885b4b69019878 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -77,7 +77,6 @@ int16_t ivas_get_nchan_buffers_dec( const int32_t ivas_total_brate /* i : total IVAS bitrate */ ); - /*----------------------------------------------------------------------------------* * Limiter prototypes *----------------------------------------------------------------------------------*/ @@ -556,13 +555,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 */ +#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 */ - const int16_t num_subframes /* i : number of subframes to render */ + const int16_t num_subframes /* i : number of subframes to render */ ); ivas_error ivas_td_binaural_renderer_ext( @@ -878,6 +881,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 +1250,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 */ @@ -1270,8 +1295,11 @@ 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 */ + COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* o : combined orientation handle */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + const int32_t fs, /* i : sampling rate */ +#endif + const int16_t num_subframes /* i : number of subframes */ ); void ivas_combined_orientation_close( @@ -1737,6 +1765,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..7c4bdd94b6e23911e77e7eade3a183f50f1f8a34 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,12 @@ void rotateFrame_sd( } /* gains for current subframe rotation */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + rotateAziEle( hTransSetup.ls_azimuth[ch_in_woLFE], hTransSetup.ls_elevation[ch_in_woLFE], &azimuth, &elevation, hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx], hTransSetup.is_planar_setup ); +#else rotateAziEle( hTransSetup.ls_azimuth[ch_in_woLFE], hTransSetup.ls_elevation[ch_in_woLFE], &azimuth, &elevation, hCombinedOrientationData->Rmat[subframe_idx], hTransSetup.is_planar_setup ); +#endif + 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 +595,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,7 +888,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, /* i : sampling rate */ +#endif + const int16_t num_subframes /* i : number of subframes */ ) { int16_t i; @@ -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,96 @@ 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 start 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 ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( hCombinedOrientationData->num_subframes == 1 || hCombinedOrientationData->sr_low_res_flag ) +#else + if ( hCombinedOrientationData->num_subframes == 1 ) +#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 c75e21f6980bdc71dd7a4654ec42ac3b3d9da4ff..fdc88ddb4a49e52bf7e87e3bcc7e7e864935123b 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 */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = ivas_combined_orientation_open( &( decDummy->hCombinedOrientationData ), sampleRate, num_subframes ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_combined_orientation_open( &( decDummy->hCombinedOrientationData ), num_subframes ) ) != IVAS_ERR_OK ) +#endif { assert( error == IVAS_ERR_OK ); } @@ -3637,7 +3643,11 @@ ivas_error IVAS_REND_Open( } /* Initilize combined orientation data */ +#ifdef NONBE_UNIFIED_DECODING_PATHS + if ( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), outputSampleRate, num_subframes ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), num_subframes ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -6382,6 +6392,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: @@ -7108,6 +7123,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: @@ -7960,6 +7980,11 @@ 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: @@ -8367,6 +8392,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: @@ -8838,6 +8868,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; }