diff --git a/apps/decoder.c b/apps/decoder.c index 8382facc89b9494bfb7858d37604aaeb5914a5e6..52c01979ab2b1822b171bddbbb3de8d64e9cf220 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -71,12 +71,11 @@ static #define NUM_BITS_SID_IVAS_5K2 104 #define MAX_OUTPUT_PCM_BUFFER_SIZE ( ( IVAS_MAX_OUTPUT_CHANNELS + IVAS_MAX_NUM_OBJECTS ) * IVAS_MAX_FRAME_SIZE ) - -#define IVAS_PUBLIC_ORIENT_TRK_NONE ( 0 ) -#define IVAS_PUBLIC_ORIENT_TRK_REF ( 1 ) -#define IVAS_PUBLIC_ORIENT_TRK_AVG ( 2 ) -#define IVAS_PUBLIC_ORIENT_TRK_REF_VEC ( 3 ) -#define IVAS_PUBLIC_ORIENT_TRK_REF_VEC_LEV ( 4 ) +#define ORIENT_TRK_NONE ( 0 ) +#define ORIENT_TRK_REF ( 1 ) +#define ORIENT_TRK_AVG ( 2 ) +#define ORIENT_TRK_REF_VEC ( 3 ) +#define ORIENT_TRK_REF_VEC_LEV ( 4 ) #ifdef VARIABLE_SPEED_DECODING #define VARIABLE_SPEED_FETCH_FRAMESIZE_MS 20 @@ -343,7 +342,7 @@ int main( } /* sanity check */ - if ( arg.orientation_tracking != IVAS_PUBLIC_ORIENT_TRK_REF ) + if ( arg.orientation_tracking != ORIENT_TRK_REF ) { fprintf( stderr, "\nError: Reference rotation file can be used in '-otr ref' mode only.\n\n" ); goto cleanup; @@ -370,7 +369,7 @@ int main( } /* sanity check */ - if ( arg.orientation_tracking != IVAS_PUBLIC_ORIENT_TRK_REF_VEC && arg.orientation_tracking != IVAS_PUBLIC_ORIENT_TRK_REF_VEC_LEV ) + if ( arg.orientation_tracking != ORIENT_TRK_REF_VEC && arg.orientation_tracking != ORIENT_TRK_REF_VEC_LEV ) { fprintf( stderr, "\nError: Reference trajectory file can be used in '-otr ref_vec' or '-otr ref_vec_lev' mode only.\n\n" ); goto cleanup; @@ -1026,7 +1025,7 @@ static bool parseCmdlIVAS_dec( arg->enableHeadRotation = false; arg->headrotTrajFileName = NULL; - arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_NONE; + arg->orientation_tracking = ORIENT_TRK_NONE; arg->enableReferenceRotation = false; arg->headrotTrajFileName = NULL; arg->enableReferenceVectorTracking = false; @@ -1310,23 +1309,23 @@ static bool parseCmdlIVAS_dec( if ( strcmp( argv_to_upper, "NONE" ) == 0 ) { - arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_NONE; + arg->orientation_tracking = ORIENT_TRK_NONE; } else if ( strcmp( argv_to_upper, "REF" ) == 0 ) { - arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_REF; + arg->orientation_tracking = ORIENT_TRK_REF; } else if ( strcmp( argv_to_upper, "AVG" ) == 0 ) { - arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_AVG; + arg->orientation_tracking = ORIENT_TRK_AVG; } else if ( strcmp( argv_to_upper, "REF_VEC" ) == 0 ) { - arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_REF_VEC; + arg->orientation_tracking = ORIENT_TRK_REF_VEC; } else if ( strcmp( argv_to_upper, "REF_VEC_LEV" ) == 0 ) { - arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_REF_VEC_LEV; + arg->orientation_tracking = ORIENT_TRK_REF_VEC_LEV; } else { @@ -1762,7 +1761,7 @@ static ivas_error initOnFirstGoodFrame( IVAS_DEC_HANDLE hIvasDec, /* i/o: */ const DecArguments arg, /* i : */ const int16_t numInitialBadFrames, /* i : */ -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT uint16_t *numOutSamples, /* i/o: */ int16_t *vec_pos_len, /* i/o: */ #else @@ -1890,22 +1889,18 @@ static ivas_error initOnFirstGoodFrame( else { #endif - if ( *pRemainingDelayNumSamples < -#if defined( SPLIT_REND_WITH_HEAD_ROT ) - *numOutSamples + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( *pRemainingDelayNumSamples < *numOutSamples ) #else - numOutSamples + if ( *pRemainingDelayNumSamples < numOutSamples ) #endif - ) { - if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, -#if defined( SPLIT_REND_WITH_HEAD_ROT ) - *numOutSamples +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, *numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) #else - numOutSamples + if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) #endif - * *pNumOutChannels - - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); return error; @@ -1914,13 +1909,11 @@ static ivas_error initOnFirstGoodFrame( } else { - *pRemainingDelayNumSamples -= -#if defined( SPLIT_REND_WITH_HEAD_ROT ) - *numOutSamples +#ifdef SPLIT_REND_WITH_HEAD_ROT + *pRemainingDelayNumSamples -= *numOutSamples; #else - numOutSamples + *pRemainingDelayNumSamples -= numOutSamples; #endif - ; } #ifdef SPLIT_REND_WITH_HEAD_ROT } @@ -2010,10 +2003,9 @@ static ivas_error initOnFirstGoodFrame( } } -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( *hSplitRendFileReadWrite != NULL ) { - int16_t enable5ms; if ( numOutSamples == NULL || vec_pos_len == NULL ) @@ -2021,7 +2013,10 @@ static ivas_error initOnFirstGoodFrame( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ); + if ( ( error = IVAS_DEC_Get5msFlag( hIvasDec, &enable5ms ) ) != IVAS_ERR_OK ) + { + return error; + } /* 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 ( enable5ms ) @@ -2040,11 +2035,13 @@ static ivas_error initOnFirstGoodFrame( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * decodeG192() * * Read G.192 bitstream and decode in regular decoder *---------------------------------------------------------------------*/ + static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, @@ -2073,7 +2070,7 @@ static ivas_error decodeG192( int16_t nOutChannels = 0; int16_t delayNumSamples = -1; int16_t delayNumSamples_orig[3]; -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT uint16_t nOutSamples = 0; #else int16_t nOutSamples = 0; @@ -2094,7 +2091,6 @@ static ivas_error decodeG192( IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; 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; - #ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_SPLIT_REND_BITS_DATA splitRendBits; SplitFileReadWrite *hSplitRendFileReadWrite; @@ -2249,8 +2245,7 @@ static ivas_error decodeG192( { 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 ) ); + fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); goto cleanup; } } @@ -2260,12 +2255,11 @@ static ivas_error decodeG192( 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 + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2359,42 +2353,36 @@ static ivas_error decodeG192( #ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, - (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), - &splitRendBits, - &nSamplesRendered_loop, - &needNewFrame ); - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; - if ( error != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetSplitBinauralBitstream: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } + + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; } else { #endif - error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, -#if defined SPLIT_REND_WITH_HEAD_ROT - IVAS_DEC_PCM_INT16, - (void *) + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) + +#else + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) + #endif - ( pcmBuf + nOutChannels * nSamplesRendered ), - &nSamplesRendered_loop, - &needNewFrame ); - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; - if ( error != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif - } while ( nSamplesRendered < nOutSamples && error == IVAS_ERR_OK ); if ( error == IVAS_ERR_END_OF_FILE ) @@ -2418,7 +2406,7 @@ static ivas_error decodeG192( hIvasDec, arg, numInitialBadFrames, -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT &nOutSamples, &vec_pos_len, #else @@ -2453,11 +2441,10 @@ static ivas_error decodeG192( if ( decodedGoodFrame ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( hSplitRendFileReadWrite != NULL ) && ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written, - splitRendBits.codec, splitRendBits.pose_correction, - splitRendBits.codec_frame_size_ms ) != IVAS_ERR_OK ) + splitRendBits.codec, splitRendBits.pose_correction, splitRendBits.codec_frame_size_ms ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to write to bitstream file!\n" ); goto cleanup; @@ -2465,11 +2452,10 @@ static ivas_error decodeG192( } else { - if ( ( hSplitRendFileReadWrite != NULL ) && ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written, - splitRendBits.codec, splitRendBits.pose_correction, - splitRendBits.codec_frame_size_ms ) != IVAS_ERR_OK ) + splitRendBits.codec, splitRendBits.pose_correction, splitRendBits.codec_frame_size_ms ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to write to bitstream file!\n" ); goto cleanup; @@ -2619,21 +2605,17 @@ static ivas_error decodeG192( if ( arg.enableHeadRotation ) { IVAS_QUATERNION Quaternion; - - if ( ( error = HeadRotationFileReading( headRotReader, &Quaternion, &Pos[0] ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); goto cleanup; } - - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0 #ifdef SPLIT_REND_WITH_HEAD_ROT - , - DEFAULT_AXIS + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0 ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2641,13 +2623,12 @@ static ivas_error decodeG192( } /* decode and get samples */ - if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, -#if defined SPLIT_REND_WITH_HEAD_ROT - IVAS_DEC_PCM_INT16, - (void *) + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) #endif - pcmBuf, - &nSamplesFlushed ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2862,10 +2843,8 @@ static ivas_error printBitstreamInfoVoip( else { auPtr = au; /* might have been set to RTP packet in prev call */ - rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, - &nextPacketRcvTime_ms, - &isAMRWB_IOmode, &frameTypeIndex, &qBit, - &auPtr, (uint16_t *) &auSizeBits ); + rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSizeBits ); + /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */ rtpTimeStamp = rtpTimeStamp / 16; } @@ -3027,10 +3006,8 @@ static ivas_error decodeVoIP( else { auPtr = au; /* might have been set to RTP packet in prev call */ - rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, - &nextPacketRcvTime_ms, - &isAMRWB_IOmode, &frameTypeIndex, &qBit, - &auPtr, (uint16_t *) &auSize ); + rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSize ); + /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */ rtpTimeStamp = rtpTimeStamp / 16; } @@ -3065,7 +3042,7 @@ static ivas_error decodeVoIP( while ( 1 ) { -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT uint16_t nOutSamples = 0; #else int16_t nOutSamples = 0; @@ -3075,6 +3052,7 @@ static ivas_error decodeVoIP( #else nOutSamples = (int16_t) ( arg.output_Fs / 1000 * JBM_FRONTEND_FETCH_FRAMESIZE_MS ); #endif + /* read all packets with a receive time smaller than the system time */ while ( nextPacketRcvTime_ms <= systemTime_ms ) { @@ -3127,11 +3105,10 @@ static ivas_error decodeVoIP( /* decode and get samples */ if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, -#if defined SPLIT_REND_WITH_HEAD_ROT - IVAS_DEC_PCM_INT16, - (void *) +#ifdef SPLIT_REND_WITH_HEAD_ROT + IVAS_DEC_PCM_INT16, (void *) #endif - pcmBuf, + pcmBuf, systemTime_ms #ifdef SUPPORT_JBM_TRACEFILE , @@ -3144,7 +3121,6 @@ static ivas_error decodeVoIP( goto cleanup; } - /* write JBM Offset file entry */ if ( jbmOffsetWriter != NULL ) { @@ -3176,14 +3152,14 @@ static ivas_error decodeVoIP( if ( decodedGoodFrame ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - SplitFileReadWrite *hSplitRendFileReadWrite = NULL; #endif + error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT &nOutSamples, NULL, #else @@ -3218,7 +3194,6 @@ static ivas_error decodeVoIP( } } - /* Write current frame */ if ( decodedGoodFrame ) { diff --git a/apps/encoder.c b/apps/encoder.c index 2b4016bcb8789bb3523532a9e373721edbb7b036..b5162a5a025075d6cee4cdbd42f13dde5909b482 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -406,25 +406,16 @@ int main( } break; case IVAS_ENC_INPUT_SBA: - if ( ( error = - IVAS_ENC_ConfigureForAmbisonics( - hIvasEnc, - arg.inputFs, - totalBitrate, - arg.max_bwidth_user, - bandwidth, - arg.dtxConfig, - arg.inputFormatConfig.sba.order, - arg.inputFormatConfig.sba.isPlanar, + if ( ( error = IVAS_ENC_ConfigureForAmbisonics( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba.order, arg.inputFormatConfig.sba.isPlanar, #ifdef DEBUG_AGC_ENCODER_CMD_OPTION - arg.agc, + arg.agc, #endif - arg.pca + arg.pca #ifdef DEBUG_SBA_AUDIO_DUMP - , - &numTransportChannels + , + &numTransportChannels #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForAmbisonics failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; @@ -445,7 +436,6 @@ int main( goto cleanup; } break; - case IVAS_ENC_INPUT_SBA_ISM: if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK ) { @@ -453,7 +443,6 @@ int main( exit( -1 ); } break; - case IVAS_ENC_INPUT_MASA_ISM: if ( ( error = IVAS_ENC_ConfigureForMASAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masa_ism.numObjects, arg.inputFormatConfig.masa_ism.masaVariant ) ) != IVAS_ERR_OK ) { @@ -461,7 +450,6 @@ int main( exit( -1 ); } break; - default: fprintf( stderr, "\nInvalid input type\n\n" ); goto cleanup; @@ -512,6 +500,7 @@ int main( fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); goto cleanup; } + int16_t inFileNumChannels = 0; error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels ); switch ( error ) @@ -546,9 +535,7 @@ int main( } } - const int16_t numIsmInputs = ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_MASA_ISM || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM ) - ? arg.inputFormatConfig.ism.numObjects - : 0; + const int16_t numIsmInputs = ( arg.inputFormat == IVAS_ENC_INPUT_ISM || arg.inputFormat == IVAS_ENC_INPUT_MASA_ISM || arg.inputFormat == IVAS_ENC_INPUT_SBA_ISM ) ? arg.inputFormatConfig.ism.numObjects : 0; for ( i = 0; i < numIsmInputs; ++i ) { diff --git a/apps/renderer.c b/apps/renderer.c index edf7fb51c7b80ab49b2f96152851957d9b6683fe..d11ff01c765584ddec65725b0c34e407d80fb359 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -447,21 +447,16 @@ static void printSupportedAudioConfigs( void ); static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ); -static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer #ifdef SPLIT_REND_WITH_HEAD_ROT - , - const int16_t cldfb_in, - IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna -#endif -); +static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna ); -static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer -#ifdef SPLIT_REND_WITH_HEAD_ROT - , - const int16_t cldfb_in, - IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn +static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer, const int16_t cldfb_in, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn ); +#else +static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer ); + +static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer ); #endif -); + /*------------------------------------------------------------------------------------------* * Local functions @@ -527,7 +522,12 @@ static int16_t getTotalNumInChannels( fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } - IVAS_REND_GetNumAllObjects( hIvasRend, &numInputChannels ); /* In case of MASA output, modify the numInputChannels to contain all objects. Otherwise, keep the original value. */ + + /* In case of MASA output, modify the numInputChannels to contain all objects. Otherwise, keep the original value. */ + if ( ( error = IVAS_REND_GetNumAllObjects( hIvasRend, &numInputChannels ) ) != IVAS_ERR_OK ) + { + return error; + } totalNumInChannels += numInputChannels; } @@ -675,21 +675,21 @@ static int16_t get_cldfb_in_flag( const IVAS_AUDIO_CONFIG audioConfig, IVAS_RENDER_CONFIG_DATA *renderConfig ) { - int16_t cldfb_in; + int16_t cldfb_in_flag; - cldfb_in = 0; + cldfb_in_flag = 0; if ( renderConfig->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { #ifdef DEBUGGING - cldfb_in = 1; + cldfb_in_flag = 1; #endif if ( audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { - cldfb_in = 1; + cldfb_in_flag = 1; } } - return cldfb_in; + return cldfb_in_flag; } @@ -740,7 +740,7 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS]; IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS]; - int16_t cldfb_in, CLDFBframeSize_smpls; + int16_t cldfb_in_flag, CLDFBframeSize_smpls; SplitRendBFIFileReader *splitRendBFIReader = NULL; #endif Vector3PairFileReader *referenceVectorReader = NULL; @@ -897,12 +897,11 @@ int main( else { /* With single-format input, all information is given on command line. */ - setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders #ifdef SPLIT_REND_WITH_HEAD_ROT - , - &hSplitRendFileReadWrite + setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders, &hSplitRendFileReadWrite ); +#else + setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders ); #endif - ); } /* Check that there is allowed configuration for MASA format output */ @@ -960,6 +959,7 @@ int main( inFileSampleRate = args.sampleRate; } #endif + switch ( error ) { case IVAS_ERR_OK: @@ -1011,8 +1011,7 @@ int main( IVAS_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS] = { 0 }; #endif - if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, - ( args.framing_5ms ) ? 1 : 4 ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain, ( args.framing_5ms ) ? 1 : 4 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1027,7 +1026,7 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT CLDFBframeSize_smpls = 0; - cldfb_in = 0; + cldfb_in_flag = 0; #endif if ( args.renderConfigFilePath[0] != '\0' ) @@ -1098,14 +1097,15 @@ int main( if ( !is_split_post_rend_mode( &args ) ) { CLDFBframeSize_smpls = frameSize_smpls * 2; - cldfb_in = get_cldfb_in_flag( args.outConfig.audioConfig, &renderConfig ); + cldfb_in_flag = get_cldfb_in_flag( args.outConfig.audioConfig, &renderConfig ); } #endif } if ( ( error = IVAS_REND_SetOrientationTrackingMode( hIvasRend, args.orientation_tracking ) ) != IVAS_ERR_OK ) { - return error; + fprintf( stderr, "Error in IVAS_REND_SetOrientationTrackingMode(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); } /* Set up output custom layout configuration */ @@ -1113,7 +1113,8 @@ int main( { if ( ( error = IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( hIvasRend, args.outConfig.outSetupCustom ) ) != IVAS_ERR_OK ) { - return error; + fprintf( stderr, "Error in IVAS_REND_ConfigureCustomOutputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); } } @@ -1131,8 +1132,17 @@ int main( /* Set the total number of objects */ if ( args.inConfig.numAudioObjects > 0 ) { - IVAS_REND_SetTotalNumberOfObjects( hIvasRend, args.inConfig.numAudioObjects ); - IVAS_REND_SetIsmMetadataDelay( hIvasRend, args.syncMdDelay ); + if ( ( error = IVAS_REND_SetTotalNumberOfObjects( hIvasRend, args.inConfig.numAudioObjects ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_SetTotalNumberOfObjects(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + if ( ( error = IVAS_REND_SetIsmMetadataDelay( hIvasRend, args.syncMdDelay ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_SetIsmMetadataDelay(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } IVAS_REND_LfePanMtx lfePanMatrix; @@ -1165,7 +1175,8 @@ int main( { if ( ( error = IVAS_REND_ConfigureCustomInputLoudspeakerLayout( hIvasRend, mcIds[i], args.inConfig.inSetupCustom ) ) != IVAS_ERR_OK ) { - return error; + fprintf( stderr, "Error in IVAS_REND_ConfigureCustomInputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); } } @@ -1294,12 +1305,11 @@ int main( } } - const int16_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds, masaIds #ifdef SPLIT_REND_WITH_HEAD_ROT - , - splitBinIds + const int16_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds, masaIds, splitBinIds ); +#else + const int16_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds, masaIds ); #endif - ); if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels ) { @@ -1318,21 +1328,29 @@ int main( int16_t numOutChannels; if ( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + fprintf( stderr, "Error in IVAS_REND_NumOutChannels(): %s\n", ivas_error_to_string( error ) ); exit( -1 ); } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( cldfb_in ) + if ( cldfb_in_flag ) { - IVAS_REND_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate ); + if ( ( error = IVAS_REND_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_openCldfb(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { - IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ); - error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outputFilePath, delayNumSamples_temp, delayTimeScale_temp ); - if ( error != IVAS_ERR_OK ) + if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of renderer!\n" ); + exit( -1 ); + } + + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outputFilePath, delayNumSamples_temp, delayTimeScale_temp ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.outputFilePath ); exit( -1 ); @@ -1343,15 +1361,20 @@ int main( { if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ); - error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outMetadataFilePath, delayNumSamples_temp, delayTimeScale_temp ); - if ( error != IVAS_ERR_OK ) + if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of renderer!\n" ); + exit( -1 ); + } + + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outMetadataFilePath, delayNumSamples_temp, delayTimeScale_temp ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.outMetadataFilePath ); exit( -1 ); } } #endif + if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); @@ -1366,7 +1389,7 @@ int main( inpInt16Buffer = malloc( inBufferSize * sizeof( int16_t ) ); #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( cldfb_in == 0 ) + if ( cldfb_in_flag == 0 ) { inFloatBuffer = malloc( inBufferSize * sizeof( float ) ); inBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; @@ -1382,11 +1405,11 @@ int main( } outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) ); - inBuffer.config.is_cldfb = cldfb_in; + inBuffer.config.is_cldfb = cldfb_in_flag; inBuffer.config.numChannels = (int16_t) totalNumInChannels; inBuffer.data = inFloatBuffer; - outBuffer.config.is_cldfb = cldfb_in; + outBuffer.config.is_cldfb = cldfb_in_flag; outBuffer.config.numChannels = (int16_t) numOutChannels; outBuffer.data = outFloatBuffer; @@ -1497,12 +1520,11 @@ int main( } /* Convert from int to float and from interleaved to packed */ - convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inBuffer.config.is_cldfb, cldfbAna + convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer, inBuffer.config.is_cldfb, cldfbAna ); +#else + convertInputBuffer( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inFloatBuffer ); #endif - ); int16_t num_subframes, sf_idx; num_subframes = ( args.framing_5ms ) ? 1 : IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; @@ -1559,13 +1581,12 @@ int main( fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } - if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - DEFAULT_AXIS + if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos, DEFAULT_AXIS, sf_idx ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos, sf_idx ) ) != IVAS_ERR_OK ) #endif - , - sf_idx ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1586,8 +1607,17 @@ int main( if ( splitRendBFIReader != NULL && splitBinNeedsNewFrame ) { int16_t bfi; - SplitRendBFIFileReading( splitRendBFIReader, &bfi ); - IVAS_REND_SetSplitRendBFI( hIvasRend, bfi ); + if ( ( error = SplitRendBFIFileReading( splitRendBFIReader, &bfi ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in SplitRendBFIFileReading(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } + + if ( ( error = IVAS_REND_SetSplitRendBFI( hIvasRend, bfi ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } #endif @@ -1609,8 +1639,7 @@ int main( } for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) { - if ( ( error = IVAS_REND_SetExternalOrientation( hIvasRend, &quatBuffer[sf_idx], enableHeadRotation[sf_idx], enableExternalOrientation[sf_idx], enableRotationInterpolation[sf_idx], numFramesToTargetOrientation[sf_idx], - sf_idx ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_REND_SetExternalOrientation( hIvasRend, &quatBuffer[sf_idx], enableHeadRotation[sf_idx], enableExternalOrientation[sf_idx], enableRotationInterpolation[sf_idx], numFramesToTargetOrientation[sf_idx], sf_idx ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error setting External Orientation: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1753,7 +1782,7 @@ int main( } #endif -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( args.inConfig.numBinBuses != 0 ) { if ( ( error = IVAS_REND_GetSplitBinauralSamples( hIvasRend, outBuffer, &splitBinNeedsNewFrame ) ) != IVAS_ERR_OK ) @@ -1762,8 +1791,7 @@ int main( exit( -1 ); } } - else if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || - args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + else if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( ( error = IVAS_REND_GetSplitBinauralBitstream( hIvasRend, outBuffer, &bitsBuffer ) ) != IVAS_ERR_OK ) { @@ -1783,7 +1811,7 @@ int main( #endif exit( -1 ); } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT } #endif @@ -1792,13 +1820,11 @@ int main( /* Convert from float to int and from packed to interleaved. * Values in outFloatBuffer are guaranteed to be within range INT16_MIN:INT16_MAX */ - convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer #ifdef SPLIT_REND_WITH_HEAD_ROT - , - cldfb_in, - cldfbSyn + convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer, cldfb_in_flag, cldfbSyn ); +#else + convertOutputBuffer( outFloatBuffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer ); #endif - ); if ( delayNumSamples == -1 ) { @@ -1813,6 +1839,7 @@ int main( fprintf( stderr, "\nUnable to get delay of renderer!\n" ); exit( -1 ); } + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( is_split_post_rend_mode( &args ) && ( hSplitRendFileReadWrite != NULL ) ) { @@ -1821,6 +1848,7 @@ int main( delayNumSamples += (int16_t) roundf( (float) pre_rend_delay_ns * delayTimeScale / 1000000000.f ); } #endif + delayNumSamples_orig = delayNumSamples; } else @@ -1831,7 +1859,7 @@ int main( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( hSplitRendFileReadWrite != NULL ) && is_split_pre_rend_mode( &args ) ) + if ( is_split_pre_rend_mode( &args ) ) { if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, @@ -1841,6 +1869,7 @@ int main( exit( -1 ); } } + if ( audioWriter != NULL ) { #endif @@ -1909,26 +1938,42 @@ int main( if ( numInputFormats == 1 ) { - IVAS_REND_GetMasaMetadata( hIvasRend, &hMetaOutput, inputType1 ); + if ( ( error = IVAS_REND_GetMasaMetadata( hIvasRend, &hMetaOutput, inputType1 ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_GetMasaMetadata(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } else { if ( args.inConfig.numAmbisonicsBuses > 0 && args.inConfig.numMultiChannelBuses > 0 ) { inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED; - IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ); + if ( ( error = IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_MergeMasaMetadata(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } if ( ( args.inConfig.numAmbisonicsBuses > 0 || args.inConfig.numMultiChannelBuses > 0 ) && args.inConfig.numMasaBuses > 0 ) { inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA; - IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ); + if ( ( error = IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_MergeMasaMetadata(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } if ( ( args.inConfig.numAmbisonicsBuses > 0 || args.inConfig.numMultiChannelBuses > 0 || args.inConfig.numMasaBuses > 0 ) && args.inConfig.numAudioObjects > 0 ) { inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED; - IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ); + if ( ( error = IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error in IVAS_REND_MergeMasaMetadata(): %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } } } @@ -2018,15 +2063,12 @@ int main( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( cldfb_in ) + if ( cldfb_in_flag ) { IVAS_REND_closeCldfb( cldfbAna, cldfbSyn ); } - if ( hSplitRendFileReadWrite != NULL ) - { - split_rend_reader_writer_close( &hSplitRendFileReadWrite ); - } + split_rend_reader_writer_close( &hSplitRendFileReadWrite ); #endif for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) @@ -3760,7 +3802,7 @@ static void convertInputBuffer( float *floatBuffer #ifdef SPLIT_REND_WITH_HEAD_ROT , - const int16_t cldfb_in, + const int16_t cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna #endif ) @@ -3768,8 +3810,9 @@ static void convertInputBuffer( int16_t chnl, smpl, i; i = 0; + #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( cldfb_in ) + if ( cldfb_in_flag ) { int16_t slotIdx, numCldfbBands, numFloatPcmSamples; float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; @@ -3847,7 +3890,7 @@ static void convertOutputBuffer( int16_t *intBuffer #ifdef SPLIT_REND_WITH_HEAD_ROT , - const int16_t cldfb_in, + const int16_t cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn #endif ) @@ -3858,7 +3901,7 @@ static void convertOutputBuffer( i = 0; #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( cldfb_in ) + if ( cldfb_in_flag ) { int16_t slotIdx, numCldfbBands, numPcmSamples, b; float fIn[IVAS_MAX_OUTPUT_CHANNELS][IVAS_MAX_FRAME_SIZE]; diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 857a6e19c25359a059706489158647dfab919f85..6ef9cc8ec2aeedf62b806966607ea2fe204b6bbd 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -1662,8 +1662,7 @@ static ivas_error write_indices_element( reset_indices_enc( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot ); } - reset_indices_enc( sts[0]->hBstr, - sts[0]->hBstr->nb_ind_tot ); + reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); } else { @@ -1674,8 +1673,7 @@ static ivas_error write_indices_element( for ( n = 0; n < n_channels; n++ ) { - reset_indices_enc( sts[n]->hBstr, - sts[n]->hBstr->nb_ind_tot ); + reset_indices_enc( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot ); } } diff --git a/lib_com/ivas_arith.c b/lib_com/ivas_arith.c index 3b8b75138b5d88880e48435726a258583e821c7f..0957d4ae5063e7641ce22503dc51f49738e60e88 100644 --- a/lib_com/ivas_arith.c +++ b/lib_com/ivas_arith.c @@ -95,6 +95,12 @@ static uint16_t ivas_ari_get_symbol( } +/*--------------------------------------------------------------- + * Function ivas_ari_decode_14bits_bit_ext_1_lfe() + * + * + *-------------------------------------------------------------*/ + uint16_t ivas_ari_decode_14bits_bit_ext_1_lfe( Decoder_State *st, Tastat *s, @@ -164,6 +170,12 @@ uint16_t ivas_ari_decode_14bits_bit_ext_1_lfe( } +/*--------------------------------------------------------------- + * Function ivas_ari_done_decoding_14bits_ext_1_lfe() + * + * + *-------------------------------------------------------------*/ + void ivas_ari_done_decoding_14bits_ext_1_lfe( Decoder_State *st, const int16_t extra_bits_read ) @@ -216,6 +228,7 @@ void ivas_ari_done_encoding_14bits( return; } + /*--------------------------------------------------------------- * Function ivas_ari_encode_14bits_ext() * diff --git a/lib_com/ivas_avq_pos_reorder_com.c b/lib_com/ivas_avq_pos_reorder_com.c index 6f75fa220129801be54f2a2cb7ac809d86111057..c75d20533b4dcf37357fbf252d19ccfb0e8500e3 100644 --- a/lib_com/ivas_avq_pos_reorder_com.c +++ b/lib_com/ivas_avq_pos_reorder_com.c @@ -47,7 +47,7 @@ void ordr_esti( const int16_t svLength, /* i : sub-vector index */ int16_t *Mpos, /* i/o: dominant sub-vector position from ACV */ - int16_t svOrder[], /* i/o: AVQ sub-vecotr order */ + int16_t svOrder[], /* i/o: AVQ sub-vector order */ const int16_t Nsv /* i : total sub-vectors in a sub-frames */ ) { diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index df48167c013956c7408e5e3c439acce5cb9257fb..b7f24440b440bbed4ae42574344081a807ab8586 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -121,7 +121,7 @@ typedef enum RENDERER_OSBA_LS } RENDERER_TYPE; -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT typedef enum { PCM_INT16, @@ -367,6 +367,7 @@ typedef enum #ifndef FIX_747_ISM_TODOS #define BRATE_ISM_INACTIVE 2450 /* CoreCoder bitrate in ISM inactive frames */ #endif +/* ISM modes */ typedef enum { ISM_MODE_NONE, @@ -374,8 +375,8 @@ typedef enum ISM_MODE_PARAM, /* parametric ISM */ ISM_MASA_MODE_MASA_ONE_OBJ, /* MASA ISM mode when one object is encoded separately and remainder using MASA parameters */ ISM_MASA_MODE_PARAM_ONE_OBJ, /* MASA ISM mode when one object is encoded separately and remainder using parametric object model */ - ISM_MASA_MODE_DISC, /* MASA ISM mode when all objects are encoded separarately */ - ISM_SBA_MODE_DISC /* MASA ISM mode when all objects are encoded separarately */ + ISM_MASA_MODE_DISC, /* MASA ISM mode when all objects are encoded separarately */ + ISM_SBA_MODE_DISC /* SBA ISM mode when all objects are encoded separarately */ } ISM_MODE; @@ -977,12 +978,12 @@ typedef enum #define DIRAC_SLOT_NS 1250000L /* time duration of a time slot, 1.25ms (==DELAY_RENERER_NS/MAX_PARAM_SPATIAL_SUBFRAMES) */ #define DIRAC_SLOT_ENC_NS 5000000L -#define DIRAC_MONO_THRESH_SILENCE 3e4f -#define DIRAC_MONO_NORM_FACTOR 1e13f -#define DIRAC_MONO_ONE_ON_NORM_FACTOR (1.f / 1e13f) -#define DIRAC_MONO_MAX_THRESH 1e6f -#define DIRAC_MONO_MIN_THRESH 1e2f -#define DIRAC_MONO_FRAME_THRESH 15 /* 30ms */ +#define DIRAC_MONO_THRESH_SILENCE 3e4f +#define DIRAC_MONO_NORM_FACTOR 1e13f +#define DIRAC_MONO_ONE_ON_NORM_FACTOR (1.f / 1e13f) +#define DIRAC_MONO_MAX_THRESH 1e6f +#define DIRAC_MONO_MIN_THRESH 1e2f +#define DIRAC_MONO_FRAME_THRESH 15 /* 30ms */ typedef enum { @@ -1503,12 +1504,12 @@ typedef enum ANY_YAW, PITCH_ONLY, ANY_ROLL, - PRED_ONLY, + PRED_ONLY, #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - PRED_ROLL_ONLY, + PRED_ROLL_ONLY, #endif - COM_GAIN_ONLY, - LR_GAIN_ONLY + COM_GAIN_ONLY, + LR_GAIN_ONLY } IVAS_SPLIT_REND_POSE_TYPE; #endif diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 366a8a38cced9a97e9489915fe376538259040c3..d51f88943c96af6eb71490eb75acca0e1e3bbbfb 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -49,8 +49,6 @@ static void ivas_get_active_bins( const int16_t **pActive_bins, const int16_t **pActive_bins_abs, const int16_t **pStart_offset, const int16_t **pStart_offset_ab, const int32_t sampling_rate ); static void ivas_get_ld_fb_resp( float **ppIdeal_FRs_re, float **ppIdeal_FRs_im, float **ppNew_FRs_re, float **ppNew_FRs_im, const int16_t *pActive_bins, const int16_t *pStart_offset, const int16_t num_bands, const int16_t delay, const int32_t sampling_rate ); -static const float *ivas_get_cheby_ramp( const int16_t delay ); -static void ivas_get_hanning_win( const int16_t len, float *pH_win ); static ivas_error ivas_filterbank_setup( IVAS_FB_MIXER_HANDLE hFbMixer, const int32_t sampling_rate ); static ivas_error ivas_fb_mixer_get_window( const int16_t fade_len, const int32_t sampling_rate, const float **pWindow ); @@ -317,7 +315,6 @@ ivas_error ivas_FB_mixer_open( } else { - /* ignore all the deeper filter bank stuff for now */ hFbMixer->num_diff_bands = 0; } @@ -399,7 +396,6 @@ void ivas_FB_mixer_close( num_chs_alloc = max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ); } - for ( i = 0; i < num_chs_alloc; i++ ) { free( hFbMixer->ppFilterbank_prior_input[i] ); @@ -560,9 +556,7 @@ void ivas_fb_mixer_get_windowed_fr( rev_offset = (int16_t) ( 2 * mdft_len - hFbMixer->ana_window_offset ); set_zero( fr_in_block, offset ); - for ( ch_idx = 0; ch_idx < - nchan_fb_in; - ch_idx++ ) + for ( ch_idx = 0; ch_idx < nchan_fb_in; ch_idx++ ) { mvr2r( &hFbMixer->ppFilterbank_prior_input[ch_idx][offset + hFbMixer->fb_cfg->windowed_fr_offset], &fr_in_block[offset], n_old_samples - offset ); mvr2r( pcm_in[ch_idx], &fr_in_block[n_old_samples], n_new_samples ); diff --git a/lib_com/ivas_filters.c b/lib_com/ivas_filters.c index d89370e7951c9a45b9ebaeeb9ab56b2786c3fd29..579e9d17c6f3dfd444407559bb1d39d593fe4272 100644 --- a/lib_com/ivas_filters.c +++ b/lib_com/ivas_filters.c @@ -109,7 +109,8 @@ void ivas_filters_init( void ivas_filter_process( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ float *pIn_Out, /* i/o: signal subject to filtering */ - const int16_t length ) /* i : filter order */ + const int16_t length /* i : filter order */ +) { switch ( filter_state->order ) diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index e1bdcfabc0b6c4767d8895a0b32dc0e4ac95f6d0..344f346d474405ff1e7199235380252c08a5759b 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -534,7 +534,7 @@ float ism_dequant_meta( void ivas_param_ism_config( PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i/o: IVAS Param ISM Config Structure */ - const int16_t nchan_obj /* i : number of ISM channels */ + const int16_t nchan_obj /* i : number of ISM channels */ ) { int16_t i; @@ -557,6 +557,7 @@ void ivas_param_ism_config( hParamIsm->last_dmx_gain = 1.0f; set_f( hParamIsm->last_cardioid_left, 1.0f, MAX_NUM_OBJECTS ); + return; } diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 5076dc6661b6a548a2851e6960bf73c799eb19a5..17e4b477314b3023a41dac3b0755fe9fd38347a2 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -169,7 +169,6 @@ void generate_gridEq( SPHERICAL_GRID_DATA *data /* o : data structure for grid */ ) { - int32_t cum_n, cum_n_prev; float theta; int16_t i; @@ -256,7 +255,6 @@ void ivas_masa_set_coding_config( } idx_bands = i; - if ( config->numberOfDirections > 1 ) { nTwoDirBands = config->joinedSubframes ? masa_twodir_bands_joined[i] : masa_twodir_bands[i]; @@ -355,7 +353,7 @@ void masa_sample_rate_band_correction( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ const uint8_t maxBand, /* i : max band */ uint8_t is_encoder, /* i : signals if called at encoder */ - MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ + MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ ) { uint8_t band, sf; @@ -924,9 +922,9 @@ void ivas_omasa_modify_masa_energy_ratios( *---------------------------------------------------------------*/ void distribute_evenly_ism( - int16_t *idx, /* o : index values */ - const int16_t K, /* i : sum of indexes */ - const int16_t nchan_ism /* i : number of objects */ + int16_t *idx, /* o : index values */ + const int16_t K, /* i : sum of indexes */ + const int16_t nchan_ism /* i : number of objects */ ) { int16_t i; diff --git a/lib_com/ivas_mdft_imdft.c b/lib_com/ivas_mdft_imdft.c index ad9d19a9107824ed92f8da3e6d5f965b34464bda..0b03f63d90cb7cec236bc42b69d92eeae430b5ef 100644 --- a/lib_com/ivas_mdft_imdft.c +++ b/lib_com/ivas_mdft_imdft.c @@ -231,10 +231,10 @@ void ivas_mdft( float im[L_FRAME48k]; int16_t j, len_by_2; const float *pTwid; + len_by_2 = mdft_length >> 1; - ivas_get_mdft_twid_factors( mdft_length, - &pTwid ); + ivas_get_mdft_twid_factors( mdft_length, &pTwid ); if ( mdft_length == input_length ) { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 328f19c2c37d633a4fa9236cc0c9910907efb962..17fb7412fdeb8da014f5755bca1e7ac0a5dff146 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -253,7 +253,7 @@ ivas_error ivas_compute_core_buffers( /*! r: number of clipped samples */ uint32_t ivas_syn_output( - float *synth[], /* i/o: float synthesis signal */ + float *synth[], /* i/o: float synthesis signal */ const int16_t output_frame, /* i : output frame length (one channel) */ const int16_t n_channels, /* i : number of output channels */ int16_t *synth_out /* o : integer 16 bits synthesis signal */ @@ -301,9 +301,9 @@ void stereo_dmx_evs_close_encoder( ivas_error ivas_dec( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else int16_t *data /* o : output synthesis signal */ #endif @@ -312,11 +312,11 @@ ivas_error ivas_dec( ivas_error ivas_dec_setup( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -657,11 +657,11 @@ ivas_error ivas_mc_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t idx, /* i : LS config. index */ uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -785,7 +785,7 @@ ivas_error ivas_jbm_dec_render( const uint16_t nSamplesAsked, /* i : number of samples wanted */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -802,11 +802,11 @@ ivas_error ivas_jbm_dec_flush_renderer( const MC_MODE mc_mode_old, /* i : old MC mode */ const ISM_MODE ism_mode_old, /* i : old ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -849,14 +849,15 @@ int16_t ivas_jbm_dec_get_num_tc_channels( void ivas_jbm_dec_copy_tc_no_tsm( Decoder_Struct *st_ivas, float *tc[], - const int16_t output_frame ); + const int16_t output_frame +); void ivas_jbm_dec_get_md_map_even_spacing( - const int16_t len, /* i : length of the modfied frames in metadata slots */ - const int16_t subframe_len, /* i : default length of a subframe */ - const int16_t offset, /* i : current read offset into the md buffer */ - const int16_t buf_len, /* i : length of the metadata buffer */ - int16_t *map /* o : metadata index map */ + const int16_t len, /* i : length of the modfied frames in metadata slots */ + const int16_t subframe_len, /* i : default length of a subframe */ + const int16_t offset, /* i : current read offset into the md buffer */ + const int16_t buf_len, /* i : length of the metadata buffer */ + int16_t *map /* o : metadata index map */ ); TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( @@ -868,7 +869,7 @@ 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 int32_t output_Fs /* i : sampling rate */ ); ivas_error ivas_jbm_dec_tc_buffer_open( @@ -1071,11 +1072,11 @@ ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change*/ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -1105,10 +1106,10 @@ void ivas_param_ism_dec_digest_tc( ); void ivas_ism_param_dec_tc_gain_ajust( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamples, /* i : number of samples to be compensate */ - const uint16_t nFadeLength, /* i : length of the crossfade in samples */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamples, /* i : number of samples to be compensate */ + const uint16_t nFadeLength, /* i : length of the crossfade in samples */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); void ivas_param_ism_dec_render( @@ -2657,7 +2658,7 @@ void sns_avq_cod_stereo( void sns_avq_dec( int16_t *index, /* i : Quantization indices */ float SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */ - const int16_t L_frame, + const int16_t L_frame, /* i : frame length */ const int16_t numlpc /* i : Number of sets of lpc */ ); @@ -3595,17 +3596,17 @@ void ivas_dirac_enc_close( const int32_t input_Fs /* i : input sampling_rate */ ); -void ivas_dirac_enc( +ivas_error ivas_dirac_enc( DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ float *data_f[], /* i/o: SBA channels */ - float **ppIn_FR_real, /* o : real freq domain values */ - float **ppIn_FR_imag, /* o : imag freq domain values */ - const int16_t input_frame, /* i : input frame length */ - const int16_t dtx_vad, /* i : DTX vad flag */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - int16_t hodirac_flag /* i : hodirac flag */ + float **ppIn_FR_real, /* o : real freq domain values */ + float **ppIn_FR_imag, /* o : imag freq domain values */ + const int16_t input_frame, /* i : input frame length */ + const int16_t dtx_vad, /* i : DTX vad flag */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const int16_t hodirac_flag /* i : hodirac flag */ ); ivas_error ivas_dirac_config( @@ -3675,8 +3676,8 @@ void ivas_dirac_dec_set_md_map( void ivas_dirac_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport /* i : number of transport channels */ - ,const int16_t num_subframes /* i : number of subframes to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t num_subframes /* i : number of subframes to render */ ); void ivas_dirac_dec_render( @@ -3790,18 +3791,18 @@ void ivas_mc_paramupmix_dec_read_BS( ); void ivas_mc_paramupmix_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + const int16_t nSamplesForRendering /* i : number of samples provided */ ); void ivas_mc_paramupmix_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *input_f[], /* i : core-coder transport channels */ - float *output_f[] /* i/o: synthesized core-coder transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *input_f[], /* i : core-coder transport channels */ + float *output_f[] /* i/o: synthesized core-coder transport channels */ ); void ivas_param_mc_metadata_open( @@ -4143,7 +4144,7 @@ ivas_error ivas_sba_linear_renderer( float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t output_frame, /* i : output frame length per channel */ const int16_t nchan_in, /* i : number of input ambisonics channels */ - const int16_t nchan_ism, + const int16_t nchan_ism, const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup, /* i : output format setup */ const float hoa_dec_mtx[] /* i : HOA decoding mtx */ @@ -4261,7 +4262,7 @@ int16_t ivas_get_sba_num_TCs( void ivas_spar_set_bitrate_config( ivas_spar_md_com_cfg *pSpar_md_cfg, /* i/o: SPAR MD config. handle */ const int16_t table_idx, /* i : config. table index */ - const int16_t num_bands, /* i : number of bands */ + const int16_t num_bands, /* i : number of bands */ const int16_t dirac2spar_md_flag, const int16_t enc_flag, const int16_t pca_flag, @@ -4354,7 +4355,7 @@ ivas_error ivas_sba_dec_digest_tc( const int16_t nSamplesForRendering /* i : number of samples provided */ ); -void ivas_sba_dec_render( +ivas_error ivas_sba_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ @@ -4396,8 +4397,8 @@ ivas_error ivas_spar_md_enc_process( const int16_t nchan_inp, const int16_t sba_order, /* i : Ambisonic (SBA) order */ float *prior_mixer[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH], /* i : prior mixer_matrix */ - const int16_t dyn_active_w_flag, /* i : flag to indicate dynamic active W */ - const int16_t dirac_mono_flag /* i : flag to indicate mono only mode in SBA */ + const int16_t dyn_active_w_flag, /* i : flag to indicate dynamic active W */ + const int16_t dirac_mono_flag /* i : flag to indicate mono only mode in SBA */ ); void ivas_compute_spar_params( @@ -4564,7 +4565,7 @@ ivas_error ivas_spar_covar_enc_open( const int32_t input_Fs, /* i : input sampling rate */ const int16_t nchan_inp, /* i : number of input channels */ const COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC */ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); void ivas_spar_covar_enc_close( @@ -4986,11 +4987,11 @@ void ivas_masa_enc_reconfigure( ivas_error ivas_masa_dec_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ); @@ -5183,8 +5184,7 @@ void update_bits_next_block( void ivas_masa_prerender( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *output[], /* i/o: synthesized core-coder transport channels */ - const int16_t output_frame /* i : output frame length per channel */ - , + const int16_t output_frame, /* i : output frame length per channel */ const int16_t nchan_remapped /* i : number of transports used in core */ ); @@ -5680,39 +5680,39 @@ void ivas_osba_enc( const int32_t input_Fs /* i : input sampling rate */ #ifdef FIX_732_PLANAR_SBA_OSBA , - const int16_t sba_planar /* i : planar SBA flag*/ + const int16_t sba_planar /* i : planar SBA flag */ #endif ); ivas_error ivas_masa_ism_data_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); ivas_error ivas_sba_ism_separate_object_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); ivas_error ivas_osba_dirac_td_binaural( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* o : output synthesis signal */ - const int16_t output_frame /* i : output frame length per channel */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* o : output synthesis signal */ + const int16_t output_frame /* i : output frame length per channel */ ); ivas_error ivas_osba_ism_metadata_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int32_t ism_total_brate, /* i : ISM total bitrate */ - int16_t *nchan_ism, /* o : number of ISM separated channels */ - int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ + int16_t *nchan_ism, /* o : number of ISM separated channels */ + int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ); ivas_error ivas_osba_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: core-coder transport channels/object output */ - const int16_t output_frame /* i : output frame length per channel */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output_f[], /* i/o: core-coder transport channels/object output */ + const int16_t output_frame /* i : output frame length per channel */ ); void ivas_masa_ism_data_close( - MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ + MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ ); @@ -5735,11 +5735,11 @@ ivas_error ivas_omasa_enc_config( ivas_error ivas_omasa_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ); diff --git a/lib_com/ivas_qmetadata_com.c b/lib_com/ivas_qmetadata_com.c index ffd843d8a8699afae230d7db6a2f956ea3fd661c..d3b11da6d86ec630c2d3efb0d90712c8d91e301c 100644 --- a/lib_com/ivas_qmetadata_com.c +++ b/lib_com/ivas_qmetadata_com.c @@ -130,7 +130,6 @@ ivas_error ivas_qmetadata_allocate_memory( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for Q MetaData" ); } - for ( dir = 0; dir < hQMetaData->no_directions; dir++ ) { hQMetaData->q_direction[dir].cfg.nbands = nbands; @@ -336,6 +335,7 @@ ivas_error only_reduce_bits_direction( } } } + rem = reduce_bits; /* -coding_subbands*no_subframes*red_times; */ while ( n < rem ) { @@ -372,6 +372,7 @@ ivas_error only_reduce_bits_direction( reduce_bits = 0; } + if ( ind_order[0] == -1 ) { for ( j = 0; j < coding_subbands; j++ ) @@ -409,11 +410,11 @@ ivas_error only_reduce_bits_direction( *---------------------------------------------------------------*/ void update_bits_next_block( - IVAS_QDIRECTION *q_direction, /* i/o: qdirection */ - int16_t *p_diff, /* i/o: bits to be transferred */ - const int16_t j, /* i : subband to update bit alloc to */ - const int16_t max_i, /* i : number of subbands */ - const int16_t max_k /* i : n umber of subframes */ + IVAS_QDIRECTION *q_direction, /* i/o: qdirection */ + int16_t *p_diff, /* i/o: bits to be transferred */ + const int16_t j, /* i : subband to update bit alloc to*/ + const int16_t max_i, /* i : number of subbands */ + const int16_t max_k /* i : n umber of subframes */ ) { int16_t diff; diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index ca0981dd34f501080901a2c6c83c732597a2c6e7..06232fe64e79a130d8b16a6091c199efad8519d3 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -887,11 +887,11 @@ const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] = { /* When AGC is ON additional (AGC_BITS_PER_CH+1) bits may be taken from each core-coder channel so minimum core-coder bitrate per channel can be min core-coder bitrates as per the table - AGC_BITS_PER_CH */ - { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 10000, 8150, 13150 } }, + { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 10000, 8150, 13150 } }, { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, - { 16400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 13200, 11350, 16350 } }, - { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, + { 16400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 13200, 11350, 16350 } }, + { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, { 24400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0,{ { 16400, 14850, 24350 } }, { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index baf899e1f501b20489a039e992e068a64ed7fcd0..778a7bb90dff68229e7fc15b099e5e0ae9063f86 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -237,6 +237,7 @@ int16_t ivas_sba_get_nchan_metadata( return ( nb_channels ); } + /*-------------------------------------------------------------------* * ivas_sba_get_spar_hoa_ch_ind() * diff --git a/lib_com/ivas_stereo_psychlpc_com.c b/lib_com/ivas_stereo_psychlpc_com.c index aa24ef6b80bea06369a7a6028d11f14a2f83138f..ac94d56b0224fe07d8e896dcb5197622559e663b 100644 --- a/lib_com/ivas_stereo_psychlpc_com.c +++ b/lib_com/ivas_stereo_psychlpc_com.c @@ -68,8 +68,7 @@ static void SpectrumWeighting_Init( * initialize a PsychoacousticParameters structure *-------------------------------------------------------------------*/ -ivas_error -PsychoacousticParameters_Init( +ivas_error PsychoacousticParameters_Init( const int32_t sr_core, /* i : sampling rate of core-coder */ const int16_t nBins, /* i : Number of bins (spectral lines) */ const int8_t nBands, /* i : Number of spectrum subbands */ diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 9e91517d4d38867c68a4ddc596705b13adcdb1c4..d443129ab2de9596ee63544dc9ff798a5fdbdd42 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -65,7 +65,6 @@ static const float ivas_hadamard_decorr_APD_coeff[IVAS_APD_16_SECT][IVAS_APD_16_ { 0.4f, -0.4f, -0.4f, 0.4f, -0.4f, 0.4f, 0.4f, -0.4f, -0.4f, 0.4f, 0.4f, -0.4f, 0.4f, -0.4f, -0.4f, 0.4f } }; - /* For R = 3.^([0:obj.parm_APD_nSections-1]/4); */ static const float ivas_three_pow_frac[IVAS_MAX_DECORR_APD_SECTIONS] = { 1.000000000000000f, @@ -86,7 +85,6 @@ static const float ivas_three_pow_frac[IVAS_MAX_DECORR_APD_SECTIONS] = { 61.54669053777900f, }; - #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN ( 2.0f ) #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR ( 3.0f ) @@ -348,6 +346,7 @@ static int16_t ivas_get_APD_filt_orders( { APD_filt_orders[i] = (int16_t) ceil( output_Fs * IVAS_DECORR_PARM_APD_TAU * R[i] / sum_R ); } + return num_apd_sections; } @@ -387,6 +386,7 @@ static void ivas_td_decorr_init( * * APD IIR filter *-----------------------------------------------------------------------------------------*/ + void ivas_td_decorr_APD_iir_filter( ivas_td_decorr_APD_filt_state_t *filter_state, float *pIn_out, @@ -465,7 +465,6 @@ void ivas_td_decorr_process( int16_t i, j; float in_duck_gain[L_FRAME48k], out_duck_gain[L_FRAME48k]; - /* Look-ahead delay */ mvr2r( pcm_in[0], ppOut_pcm[0], output_frame ); delay_signal( ppOut_pcm[0], output_frame, hTdDecorr->look_ahead_buf, hTdDecorr->offset ); diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 6679a70a0e88a6c6e807d3add4159d62a47a04c9..ee7a06ca7d9b7300b7fd00eff316ef8ccf6ed775 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -75,7 +75,7 @@ float sumAbs( void mvc2c( const uint8_t x[], /* i : input vector */ uint8_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ + const int16_t n /* i : vector size */ ) { int16_t i; diff --git a/lib_com/prot.h b/lib_com/prot.h index 8f2a8f8e135a1f6748a0ea82f808b503a7cddada..babc0b3141687232ed6be9ad06411d3f3df6c6b1 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2266,7 +2266,7 @@ void read_next_force( ivas_error init_encoder( Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ const int16_t idchan, /* i : channel ID */ const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ const int16_t interval_SID, /* i : interval for SID update */ @@ -2274,7 +2274,7 @@ ivas_error init_encoder( const ISM_MODE ism_mode /* i : ISM mode */ #ifdef IGF_MEMORY_ALLOC_OPT , - const int32_t element_brate + const int32_t element_brate /* element bitrate */ #endif ); @@ -4089,7 +4089,7 @@ void AVQ_encmux( void ordr_esti( const int16_t k, /* i : sub-vector index */ int16_t *Mpos, /* i/o: dominant sub-vector position from ACV */ - int16_t svOrder[], /* i/o: AVQ sub-vecotr order */ + int16_t svOrder[], /* i/o: AVQ sub-vector order */ const int16_t Nsv /* i : total sub-vectors in a sub-frames */ ); diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index 4b8e5ab9e8965aa006c83c24b4b1e8c4e7848fa8..39815e6333f63d26649f33fdf03aefed826ee2e6 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -220,7 +220,6 @@ ivas_error evs_dec( } } - if ( st->codec_mode == MODE1 ) { /*------------------------------------------------------------------* @@ -252,7 +251,6 @@ ivas_error evs_dec( return error; } - /*---------------------------------------------------------------------* * ACELP core decoding * HQ core decoding diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index a094710f061747f71253f74435bef6f374a411b9..86944e55f21c8b85e80b1b8f0839d6440534a6d7 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -186,7 +186,6 @@ ivas_error init_decoder( st->old_bfi_cnt = 0; - /*-----------------------------------------------------------------* * parameters for AC mode (GSC) *-----------------------------------------------------------------*/ @@ -247,7 +246,6 @@ ivas_error init_decoder( st->hPFstat = NULL; } - /*-----------------------------------------------------------------* * HF (6-7kHz) (zero) BWE parameters *-----------------------------------------------------------------*/ @@ -356,7 +354,6 @@ ivas_error init_decoder( st->hHQ_nbfec = NULL; } - /*-----------------------------------------------------------------* * TBE parameters *-----------------------------------------------------------------*/ @@ -719,9 +716,7 @@ ivas_error init_decoder( } st->cngTDLevel = 0.f; - st->lp_noise = -20.0f; - st->force_lpd_reset = 0; /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 7f8796440c443b5bc950986cc3fb1a8be4ba1a6f..cda75af2ff22d7d508eb69e94e69a5b6c74b356e 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -394,7 +394,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( set_zero( hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx], hBinRenConvModule->numTapsArray[bandIdx] ); set_zero( hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx], hBinRenConvModule->numTapsArray[bandIdx] ); #endif - if ( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftBRIRReal[bandIdx][tmp]; @@ -417,7 +416,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( set_zero( hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx], hBinRenConvModule->numTaps ); set_zero( hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx], hBinRenConvModule->numTaps ); #endif - if ( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftHRIRReal[bandIdx][tmp]; @@ -480,6 +478,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------------* * ivas_init_binaural_hrtf() * @@ -586,7 +585,7 @@ static ivas_error ivas_alloc_pppMem( *-------------------------------------------------------------------------*/ ivas_error ivas_allocate_binaural_hrtf( - HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ + HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ const AUDIO_CONFIG input_config, /* i : input audio configuration */ const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ const RENDERER_TYPE renderer_type, /* i : renderer type */ @@ -740,7 +739,7 @@ ivas_error ivas_allocate_binaural_hrtf( *-------------------------------------------------------------------------*/ static ivas_error ivas_binaural_hrtf_open( - HRTFS_FASTCONV_HANDLE *hHrtfFastConv, /* i : fastconv HRTF handle */ + HRTFS_FASTCONV_HANDLE *hHrtfFastConv, /* i : fastconv HRTF handle */ const AUDIO_CONFIG input_config, /* i : output configuration */ const RENDERER_TYPE renderer_type /* i : renderer type */ ) @@ -763,7 +762,6 @@ static ivas_error ivas_binaural_hrtf_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for FastConv HRTF tables" ); } - ivas_init_binaural_hrtf( HrtfFastConv ); if ( input_config == IVAS_AUDIO_CONFIG_BINAURAL || renderer_type == RENDERER_BINAURAL_FASTCONV ) @@ -855,6 +853,7 @@ static ivas_error ivas_binaural_hrtf_open( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------------* * ivas_binaural_obtain_DMX() * @@ -1028,7 +1027,10 @@ ivas_error ivas_rend_openCldfbRend( hBinRenderer->hInputSetup->is_loudspeaker_setup = 0; hBinRenderer->hInputSetup->output_config = inConfig; - getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ); + if ( ( error = getAudioConfigNumChannels( inConfig, &hBinRenderer->hInputSetup->nchan_out_woLFE ) ) != IVAS_ERR_OK ) + { + return error; + } if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { @@ -1158,12 +1160,11 @@ ivas_error ivas_binRenderer_open( IVAS_OUTPUT_SETUP out_setup; /* Allocate memories and buffers needed for convolutional module in CICP19 */ - if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv #ifdef SPLIT_REND_WITH_HEAD_ROT - , - hBinRenderer->numPoses + if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1184,12 +1185,11 @@ ivas_error ivas_binRenderer_open( else { /* Allocate memories and buffers needed for convolutional module */ - if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv #ifdef SPLIT_REND_WITH_HEAD_ROT - , - hBinRenderer->numPoses + if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1230,9 +1230,7 @@ ivas_error ivas_binRenderer_open( /* Allocate memories needed for reverb module */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( ( error = ivas_binaural_reverb_open( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, - RENDERER_BINAURAL_FASTCONV, - st_ivas->hHrtfFastConv, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_binaural_reverb_open( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, RENDERER_BINAURAL_FASTCONV, st_ivas->hHrtfFastConv, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } @@ -1335,7 +1333,6 @@ static void ivas_binRenderer_convModuleClose( free( hBinRenConvModule->filterTapsRightImag ); hBinRenConvModule->filterTapsRightImag = NULL; - #ifdef SPLIT_REND_WITH_HEAD_ROT for ( posIdx = 0; posIdx < num_poses; posIdx++ ) { @@ -1418,12 +1415,11 @@ void ivas_binRenderer_close( if ( ( *hBinRenderer )->hBinRenConvModule != NULL ) { - ivas_binRenderer_convModuleClose( hBinRenderer #ifdef SPLIT_REND_WITH_HEAD_ROT - , - ( *hBinRenderer )->numPoses + ivas_binRenderer_convModuleClose( hBinRenderer, ( *hBinRenderer )->numPoses ); +#else + ivas_binRenderer_convModuleClose( hBinRenderer ); #endif - ); } if ( ( *hBinRenderer )->hReverb != NULL ) @@ -1437,6 +1433,7 @@ void ivas_binRenderer_close( return; } + /*------------------------------------------------------------------------- * ivas_free_pppHrtfMem() * @@ -1617,10 +1614,7 @@ void ivas_binaural_cldfb( } else { - cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), - Cldfb_RealBuffer[idx_in][slot_idx], - Cldfb_ImagBuffer[idx_in][slot_idx], - maxBand, st_ivas->cldfbAnaDec[idx_in] ); + cldfbAnalysis_ts( &( output_f[ch][maxBand * index_slot] ), Cldfb_RealBuffer[idx_in][slot_idx], Cldfb_ImagBuffer[idx_in][slot_idx], maxBand, st_ivas->cldfbAnaDec[idx_in] ); idx_in++; } } @@ -1649,19 +1643,15 @@ void ivas_binaural_cldfb( } /* Implement binaural rendering */ - ivas_binRenderer( - st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT - &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, -#endif - st_ivas->hCombinedOrientationData, - subframeIdx, - JBM_CLDFB_SLOTS_IN_SUBFRAME, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - NULL, + 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 ); +#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 ); #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 ) @@ -1826,18 +1816,11 @@ void ivas_binaural_cldfb_sf( } /* Implement binaural rendering */ - ivas_binRenderer( - st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT - &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, + 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 ); #endif - st_ivas->hCombinedOrientationData, - subframeIdx, - st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], - 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 ) @@ -2055,6 +2038,7 @@ void ivas_binRenderer( float reverbIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float inRe[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float inIm[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; + ivas_binaural_obtain_DMX( numTimeSlots, hBinRenderer, RealBuffer, ImagBuffer, inRe, inIm ); for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) @@ -2090,7 +2074,6 @@ void ivas_binRenderer( } pop_wmops(); - return; } @@ -2111,7 +2094,7 @@ void ivas_rend_CldfbMultiBinRendProcess( float Cldfb_Out_Real[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ float Cldfb_Out_Imag[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int16_t low_res_pre_rend_rot, - int16_t num_subframes ) + const int16_t num_subframes ) { int16_t slot_idx, ch_idx, idx, pose_idx, i, j; int16_t sf_idx; @@ -2160,15 +2143,11 @@ void ivas_rend_CldfbMultiBinRendProcess( head_track_post.Quaternions[0] = ivas_split_rend_get_sf_rot_data( pHeadRotData->headPositionsPostRend, sf_idx ); #endif - ivas_binRenderer( hCldfbRend, - pMultiBinPoseData, - *pCombinedOrientationData, - sf_idx, - MAX_PARAM_SPATIAL_SUBFRAMES, #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - &head_track_post, + 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 ); +#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 - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); for ( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) { diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index ee949f8665f4322fa45c9c4825e5a20aa747815e..e15cb85d1b6fd3453b131e89d77c4540db9c0d70 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -97,7 +97,6 @@ ivas_error ivas_core_dec( ivas_error error; error = IVAS_ERR_OK; - push_wmops( "ivas_core_dec" ); /*------------------------------------------------------------------* @@ -334,7 +333,6 @@ ivas_error ivas_core_dec( return error; } - flag_sec_CNA = -1; if ( hCPE != NULL ) { @@ -469,7 +467,6 @@ ivas_error ivas_core_dec( return error; } - /* for FD-CNG we need the delay compensation in the synth, so do this afterwards */ if ( sba_dirac_stereo_flag && hSCE && st->core_brate == SID_2k40 && st->cng_type == FD_CNG ) { @@ -652,8 +649,7 @@ ivas_error ivas_core_dec( mvr2r( tmp_buffer, st->hb_prev_synth_buffer, tmps ); } - if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) /* IVAS-19: the logic seems to be not consistent between TD and DFT stereo and SCE -> verification needed also whether 1) it is correct here and 2) the DFT->(LR)TD transition is correct */ - || ( hCPE->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) + if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) || ( hCPE->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) { /* Delay hb_synth */ delay_signal( hb_synth[n], output_frame, st->hb_prev_synth_buffer, tmps ); diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 25767099ae13f0a1ba77a98a08e537af13fa2aa7..eb6dd72e41d14ebea6f58491a37cc54478931552 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -237,6 +237,7 @@ ivas_error ivas_corecoder_dec_reconfig( { st_ivas->element_mode_init = IVAS_CPE_MDCT; } + if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 5318ec07a4c3749a6beebcbd0ee519149924974b..7bf06e18ee6410496b25826405482dfca4c7b0b9 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -389,10 +389,7 @@ ivas_error ivas_cpe_dec( { if ( !st_ivas->bfi ) { - tdm_configure_dec( - st_ivas->ivas_format, - st_ivas->ism_mode, - hCPE, &tdm_ratio_idx, nb_bits_metadata ); + tdm_configure_dec( st_ivas->ivas_format, st_ivas->ism_mode, hCPE, &tdm_ratio_idx, nb_bits_metadata ); sts[1]->bit_stream = sts[0]->bit_stream + ( sts[0]->total_brate / FRAMES_PER_SEC ); } diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 40b93b18e0818e2ef7f3be3662ce79cc745e9e8c..6602c344c166ebbf8ad9f5d236194528c6f5cea6 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -53,7 +53,7 @@ ivas_error ivas_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -74,7 +74,7 @@ ivas_error ivas_dec( ivas_error error; int16_t num_md_sub_frames; int32_t ism_total_brate; -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t nchan_out_syn_output; #endif @@ -105,7 +105,7 @@ ivas_error ivas_dec( return error; } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------* * Binaural split rendering setup *----------------------------------------------------------------*/ @@ -309,12 +309,11 @@ ivas_error ivas_dec( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -815,15 +814,12 @@ ivas_error ivas_dec( } else { -#endif if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, - st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES -#ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, + st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, p_output, output_Fs, MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) - { return error; } @@ -1087,7 +1083,7 @@ ivas_error ivas_dec( * - float to integer conversion *----------------------------------------------------------------*/ -#if defined SPLIT_REND_WITH_HEAD_ROT +#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; @@ -1101,17 +1097,15 @@ ivas_error ivas_dec( #endif { #ifndef DISABLE_LIMITER - ivas_limiter_dec( st_ivas->hLimiter, p_output, -#if defined SPLIT_REND_WITH_HEAD_ROT - nchan_out_syn_output, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out_syn_output, output_frame, st_ivas->BER_detect ); #else - nchan_out, + ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, output_frame, st_ivas->BER_detect ); #endif - output_frame, st_ivas->BER_detect ); #endif } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT switch ( pcm_resolution ) { case PCM_INT16: @@ -1119,18 +1113,13 @@ ivas_error ivas_dec( #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output( p_output, output_frame, -#if defined SPLIT_REND_WITH_HEAD_ROT - nchan_out_syn_output, +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_syn_output( p_output, output_frame, nchan_out_syn_output, (int16_t *) data ); #else - nchan_out, + ivas_syn_output( p_output, output_frame, nchan_out, data ); #endif -#if defined SPLIT_REND_WITH_HEAD_ROT - (int16_t *) -#endif - data ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT break; case PCM_FLOAT32: ivas_syn_output_f( p_output, output_frame, nchan_out_syn_output, (float *) data ); @@ -1140,6 +1129,7 @@ ivas_error ivas_dec( break; } #endif + /*----------------------------------------------------------------* * Common updates *----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_decision_matrix_dec.c b/lib_dec/ivas_decision_matrix_dec.c index d238d43df72607a2b0963f6c8df72dd1e08f2ff7..fcbff7f0ed3ddfd242d1872e5b5f989584b0ec98 100644 --- a/lib_dec/ivas_decision_matrix_dec.c +++ b/lib_dec/ivas_decision_matrix_dec.c @@ -174,7 +174,6 @@ void ivas_decision_matrix_dec( } else if ( st->idchan == 1 && st->element_mode == IVAS_CPE_TD ) { - *sharpFlag = 0; if ( st->coder_type == GENERIC || st->coder_type == VOICED ) { @@ -256,8 +255,7 @@ void ivas_decision_matrix_dec( } else if ( st->bwidth == SWB || st->bwidth == FB ) { - if ( st->total_brate >= MIN_BRATE_SWB_BWE /*&& (*coder_type != AUDIO || st->total_brate >= (MIN_BWE_PRI_BRATE+600))*/ - || ( st->total_brate >= MIN_MIN_BRATE_LRTD_SWB_BWE && st->element_mode == IVAS_CPE_TD && st->bwidth == SWB && st->tdm_LRTD_flag ) || ( element_brate < IVAS_16k4 && st->total_brate >= MIN_MIN_BRATE_LRTD_SWB_BWE && st->element_mode == IVAS_CPE_TD && st->bwidth == SWB ) ) + if ( st->total_brate >= MIN_BRATE_SWB_BWE || ( st->total_brate >= MIN_MIN_BRATE_LRTD_SWB_BWE && st->element_mode == IVAS_CPE_TD && st->bwidth == SWB && st->tdm_LRTD_flag ) || ( element_brate < IVAS_16k4 && st->total_brate >= MIN_MIN_BRATE_LRTD_SWB_BWE && st->element_mode == IVAS_CPE_TD && st->bwidth == SWB ) ) { /* read the SWB TBE/BWE selection bit */ tmp = get_next_indice( st, 1 ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 39bd4eeecc3870492724e644cdc118a0bde080fb..eeb582bc22a8161826bb0bc9934d77c345450ff6 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -90,7 +90,6 @@ static ivas_error ivas_dirac_dec_config_internal( st_ivas->hDirAC = hDirAC; } - /*-----------------------------------------------------------------* * DirAC main configuration *-----------------------------------------------------------------*/ @@ -110,6 +109,7 @@ static ivas_error ivas_dirac_dec_config_internal( return error; } + static ivas_error ivas_dirac_rend_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ @@ -596,15 +596,8 @@ static ivas_error ivas_dirac_rend_config( if ( ( flag_config == DIRAC_OPEN && hDirACRend->proto_signal_decorr_on ) || ( flag_config == DIRAC_RECONFIGURE && ( hDirACRend->proto_signal_decorr_on && !proto_signal_decorr_on_old ) ) ) { - if ( ( error = ivas_dirac_dec_decorr_open( &( hDirACRend->h_freq_domain_decorr_ap_params ), - &( hDirACRend->h_freq_domain_decorr_ap_state ), - hSpatParamRendCom->num_freq_bands, - hDirACRend->num_outputs_diff, - hDirACRend->num_protos_diff, - hDirACRend->synthesisConf, - hDirACRend->frequency_axis, - nchan_transport > 2 ? 4 : nchan_transport, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_decorr_open( &( hDirACRend->h_freq_domain_decorr_ap_params ), &( hDirACRend->h_freq_domain_decorr_ap_state ), hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff, + hDirACRend->num_protos_diff, hDirACRend->synthesisConf, hDirACRend->frequency_axis, nchan_transport > 2 ? 4 : nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -685,11 +678,11 @@ static ivas_error ivas_dirac_rend_config( } } - if ( flag_config == DIRAC_OPEN ) { hDirACRend->buffer_energy = NULL; } + if ( ( flag_config == DIRAC_OPEN && hDirAC->hConfig->dec_param_estim == TRUE ) || ( flag_config == DIRAC_RECONFIGURE && ( hDirAC->hConfig->dec_param_estim == TRUE && dec_param_estim_old == FALSE ) ) ) { hDirACRend->index_buffer_intensity = 0; @@ -788,7 +781,6 @@ ivas_error ivas_dirac_dec_config( hodirac_flag = ivas_get_hodirac_flag( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ); dec_param_estim_old = ( dec_config_flag == DIRAC_RECONFIGURE ) ? st_ivas->hDirAC->hConfig->dec_param_estim : FALSE; - sparfoa_flag = 0; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA && st_ivas->ivas_format == SBA_FORMAT && !hodirac_flag ) { @@ -940,19 +932,11 @@ ivas_error ivas_dirac_dec_config( ivas_dirac_dec_get_frequency_axis( frequency_axis, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSpatParamRendCom->num_freq_bands ); #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN - if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), - &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), + if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, #else - if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params ), - &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ), + if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, #endif - st_ivas->hSpatParamRendCom->num_freq_bands, - BINAURAL_CHANNELS, - BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, - frequency_axis, - BINAURAL_CHANNELS, - st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + DIRAC_SYNTHESIS_PSD_LS, frequency_axis, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -1051,7 +1035,7 @@ void ivas_dirac_dec_read_BS( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata */ int16_t *nb_bits, /* o : number of bits read */ - const int16_t last_bit_pos, /* i : last read bitstream position*/ + const int16_t last_bit_pos, /* i : last read bitstream position */ const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) @@ -1208,7 +1192,7 @@ void ivas_qmetadata_to_dirac( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ + const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) { @@ -1618,11 +1602,10 @@ void ivas_dirac_dec_set_md_map( *------------------------------------------------------------------------*/ void ivas_dirac_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport /* i : number of transport channels */ - , - const int16_t num_subframes /* i : number of subframes to render */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t num_subframes /* i : number of subframes to render */ ) { int16_t subframe_idx; @@ -2428,11 +2411,11 @@ void ivas_dirac_dec_render_sf( #endif /* Perform binaural rendering */ - ivas_binRenderer( st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT - &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, + 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 ); #endif - st_ivas->hCombinedOrientationData, subframe_idx, hSpatParamRendCom->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 ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a6ff01f3c986aa83977e7a1d594bd6497f865eaa..31de52db2b219ec79a49701c3f07fee8f91c0058 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -72,22 +72,22 @@ static ivas_error ivas_dec_reconfig_split_rend( ) { ivas_error error; - int16_t cldfb_in, num_ch, ch, isCldfbNeeded, i, pcm_out; + int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; SPLIT_REND_WRAPPER *hSplitRendWrapper; #ifndef OSBA_SPLIT_RENDERING CLDFB_TYPE cldfbMode; #endif hSplitRendWrapper = &st_ivas->hSplitBinRend.splitrend; - pcm_out = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - cldfb_in = 0; + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = 0; if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { - cldfb_in = 1; + cldfb_in_flag = 1; } ivas_renderSplitGetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, st_ivas->hHeadTrackData->sr_pose_pred_axis ); @@ -98,26 +98,27 @@ static ivas_error ivas_dec_reconfig_split_rend( #else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) { - cldfb_in = 0; + cldfb_in_flag = 0; } #endif + if ( st_ivas->renderer_type != RENDERER_DISABLE ) { - if ( cldfb_in == 0 ) + if ( cldfb_in_flag == 0 ) { isCldfbNeeded = 1; #ifndef OSBA_SPLIT_RENDERING cldfbMode = CLDFB_ANALYSIS; #endif } - else if ( st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && cldfb_in ) + else if ( st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) { isCldfbNeeded = 1; #ifndef OSBA_SPLIT_RENDERING cldfbMode = CLDFB_SYNTHESIS; #endif } - else if ( pcm_out && cldfb_in ) + else if ( pcm_out_flag && cldfb_in_flag ) { isCldfbNeeded = 1; #ifndef OSBA_SPLIT_RENDERING @@ -143,13 +144,12 @@ static ivas_error ivas_dec_reconfig_split_rend( for ( ch = 0; ch < num_ch; ch++ ) { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), #ifndef OSBA_SPLIT_RENDERING - cldfbMode, + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), cldfbMode, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) #else - CLDFB_ANALYSIS, + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) #endif - st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); } @@ -158,9 +158,7 @@ static ivas_error ivas_dec_reconfig_split_rend( #ifdef OSBA_SPLIT_RENDERING for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), - CLDFB_SYNTHESIS, - st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } @@ -178,6 +176,7 @@ static ivas_error ivas_dec_reconfig_split_rend( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; } } + #ifdef OSBA_SPLIT_RENDERING for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -188,6 +187,7 @@ static ivas_error ivas_dec_reconfig_split_rend( } } #endif + free( hSplitRendWrapper->hCldfbHandles ); hSplitRendWrapper->hCldfbHandles = NULL; } @@ -224,22 +224,22 @@ static ivas_error ivas_dec_init_split_rend( ) { ivas_error error; - int16_t cldfb_in, pcm_out; + int16_t cldfb_in_flag, pcm_out_flag; - pcm_out = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; - cldfb_in = 0; + pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + cldfb_in_flag = 0; if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { - cldfb_in = 1; + cldfb_in_flag = 1; } ivas_renderSplitGetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, st_ivas->hHeadTrackData->sr_pose_pred_axis ); - if ( cldfb_in == 1 && ( st_ivas->hSplitBinRend.splitrend.multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) + if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend.splitrend.multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) { if ( ( st_ivas->hSplitBinRend.hCldfbDataOut = (IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) { @@ -247,25 +247,20 @@ static ivas_error ivas_dec_init_split_rend( } } - if ( ( error = ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, - &st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, - ( cldfb_in == 0 ), - pcm_out ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_split_rend_choose_default_codec( &st_ivas->hRenderConfig->split_rend_config.codec, &st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, cldfb_in_flag, pcm_out_flag ) ) != IVAS_ERR_OK ) { return error; } + #ifdef OSBA_SPLIT_RENDERING if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) { - cldfb_in = 0; + cldfb_in_flag = 0; } #endif - error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, - &st_ivas->hRenderConfig->split_rend_config, - st_ivas->hDecoderConfig->output_Fs, - cldfb_in, pcm_out, - st_ivas->hDecoderConfig->Opt_5ms ); + 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 ); + return error; } #endif @@ -280,9 +275,9 @@ static ivas_error ivas_dec_init_split_rend( ivas_error ivas_dec_setup( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else int16_t *data /* o : output synthesis signal */ #endif @@ -307,6 +302,9 @@ ivas_error ivas_dec_setup( ivas_read_format( st_ivas, &num_bits_read ); + /*-------------------------------------------------------------------* + * Read other signling (ISM/MC mode, number of channels, etc.) + *-------------------------------------------------------------------*/ if ( is_DTXrate( ivas_total_brate ) == 0 ) { @@ -336,11 +334,11 @@ ivas_error ivas_dec_setup( st_ivas->nchan_ism = nchan_ism; - if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -397,11 +395,12 @@ ivas_error ivas_dec_setup( } else { - if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -409,11 +408,12 @@ ivas_error ivas_dec_setup( } else { - if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) + { return error; } @@ -434,11 +434,11 @@ ivas_error ivas_dec_setup( /* reconfigure in case a change of operation mode is detected */ if ( ( ivas_total_brate > IVAS_SID_5k2 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) || ( st_ivas->ini_active_frame == 0 ) ) { - if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -480,6 +480,7 @@ ivas_error ivas_dec_setup( else { 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 ); + /*correct number of CPEs for discrete ISM coding*/ if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { @@ -510,12 +511,17 @@ ivas_error ivas_dec_setup( num_bits_read += MC_LS_SETUP_BITS; /* select MC format mode; reconfigure the MC format decoder */ - ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) + { + return error; + } +#else + if ( ( error = ivas_mc_dec_config( st_ivas, idx, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } #endif - - data ); } /*-------------------------------------------------------------------* @@ -536,7 +542,6 @@ ivas_error ivas_dec_setup( { st_ivas->element_mode_init = 0 + IVAS_CPE_DFT; } - /* (*num_bits_read)++; */ } else { @@ -633,11 +638,11 @@ ivas_error ivas_dec_setup( st_ivas->ism_mode = (ISM_MODE) ( idx + 1 ); } - if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_ism_dec_config( st_ivas, st_ivas->ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -896,6 +901,7 @@ int16_t getNumChanSynthesis( n = st_ivas->nchan_transport; } } + return n; } @@ -961,7 +967,6 @@ ivas_error ivas_init_decoder_front( st_ivas->hDecoderConfig->force_rend = -1; #endif - /*-------------------------------------------------------------------* * Allocate and initialize Custom loudspeaker layout handle *--------------------------------------------------------------------*/ @@ -996,8 +1001,7 @@ ivas_error ivas_init_decoder_front( if ( st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - if ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), - ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_external_orientation_open( &( st_ivas->hExtOrientationData ), ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) { return error; } @@ -1009,8 +1013,7 @@ ivas_error ivas_init_decoder_front( if ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - if ( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), - ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_combined_orientation_open( &( st_ivas->hCombinedOrientationData ), ( st_ivas->hDecoderConfig->Opt_5ms ) ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) { return error; } @@ -1098,6 +1101,10 @@ ivas_error ivas_init_decoder( hDecoderConfig->last_ivas_total_brate = ivas_total_brate; st_ivas->last_active_ivas_total_brate = ivas_total_brate; + /*-----------------------------------------------------------------* + * Set number of output channels for EXTERNAL output config. + *-----------------------------------------------------------------*/ + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) @@ -1540,6 +1547,7 @@ ivas_error ivas_init_decoder( st_ivas->nchan_transport += st_ivas->nchan_ism; } #endif + if ( st_ivas->nCPE > 1 ) { if ( ( error = create_mct_dec( st_ivas ) ) != IVAS_ERR_OK ) @@ -1553,6 +1561,7 @@ ivas_error ivas_init_decoder( st_ivas->nchan_transport -= st_ivas->nchan_ism; } #endif + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) @@ -1895,7 +1904,6 @@ ivas_error ivas_init_decoder( set_f( st_ivas->mem_hp20_out[i], 0.0f, L_HP20_MEM ); } - /*-------------------------------------------------------------------* * Allocate and initialize rendering handles *--------------------------------------------------------------------*/ @@ -1977,13 +1985,13 @@ ivas_error ivas_init_decoder( } } - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT - , - st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -2072,6 +2080,7 @@ ivas_error ivas_init_decoder( return error; } } + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ @@ -2164,10 +2173,8 @@ ivas_error ivas_init_decoder( /*-----------------------------------------------------------------* * Allocate and initialize JBM struct + buffer *-----------------------------------------------------------------*/ - if ( - st_ivas->hDecoderConfig->Opt_5ms && - st_ivas->hTcBuffer == NULL ) + if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); @@ -2634,12 +2641,12 @@ void ivas_destroy_dec( #endif /* Crend handle */ - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); #endif - ); /* Reverb handle */ ivas_reverb_close( &st_ivas->hReverb ); @@ -2660,6 +2667,7 @@ void ivas_destroy_dec( free( st_ivas->hMonoDmxRenderer ); st_ivas->hMonoDmxRenderer = NULL; } + /* MASA ISM structure */ ivas_masa_ism_data_close( &st_ivas->hMasaIsmData ); @@ -2689,6 +2697,7 @@ void ivas_destroy_dec( /* CRend binaural renderer handle */ ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); + /* Fastconv HRTF memories */ ivas_binaural_hrtf_close( &st_ivas->hHrtfFastConv ); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 00ba167fcf84d389ef192008d9bccd4b9362c6b6..550a00978e7e2fb1cb7527e4bf0f7d8ffd1f6145 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -51,9 +51,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( const int16_t nchan_transport_old, /* i : last number of transport channels */ const ISM_MODE last_ism_mode, /* i : last ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else int16_t *data /* o : output synthesis signal */ #endif @@ -83,8 +83,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( st_ivas->ism_mode = ism_mode; nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas ); - 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 ) + 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; } @@ -121,7 +120,9 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* select the renderer */ ivas_renderer_select( st_ivas ); + ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); + if ( ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) && ( st_ivas->ism_mode == ISM_MODE_DISC ) ) { ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->hDecoderConfig->output_config ); @@ -142,10 +143,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) @@ -238,12 +240,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( #endif /* Open Crend Binaural renderer */ - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT - , - st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -326,12 +327,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( } /* close the crend binaural renderer */ - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , - st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); #endif - ); } } @@ -435,9 +435,9 @@ ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + void *data /* o : output synthesis signal */ #else int16_t *data /* o : output synthesis signal */ #endif @@ -480,7 +480,7 @@ ivas_error ivas_ism_dec_config( if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) { if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) @@ -507,7 +507,7 @@ ivas_error ivas_ism_dec_config( if ( st_ivas->ism_mode != last_ism_mode ) { if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index cf5d6311b9ec61d276011d31b23e135579aac551..69402d1c35d196464a3014158f17598c1e2f2a06 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -96,11 +96,11 @@ ivas_error ivas_ism_dtx_dec( st_ivas->ism_mode = ism_mode_bstr; } - if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, NULL, -#if defined SPLIT_REND_WITH_HEAD_ROT - PCM_NOT_KNOW, +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, NULL, PCM_NOT_KNOW, NULL ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, NULL, NULL ) ) != IVAS_ERR_OK ) #endif - NULL ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 82f07ffe3e37d6143c6472c03197decc3acecef3..812c9915bbe68d4d5fe0fa3f45a5d8440b0be359 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -50,9 +50,9 @@ static void decode_angle_indices( DEC_CORE_HANDLE st0, ISM_METADATA_ANGLE_HANDLE angle, const int16_t non_diegetic_flag, int16_t *flag_abs_azimuth ); - static int16_t decode_radius( DEC_CORE_HANDLE st0, int16_t *last_radius_idx, int16_t *flag_abs_radius ); + /*-------------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------------*/ @@ -580,8 +580,7 @@ ivas_error ivas_ism_metadata_dec( } } - if ( ( error = ivas_ism_config( ism_total_brate, *nchan_transport, nchan_ism, hIsmMeta, ism_extmeta_bitstream, null_metadata_flag, ism_imp, element_brate, total_brate, nb_bits_metadata, - masa_ism_flag ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_config( ism_total_brate, *nchan_transport, nchan_ism, hIsmMeta, ism_extmeta_bitstream, null_metadata_flag, ism_imp, element_brate, total_brate, nb_bits_metadata, masa_ism_flag ) ) != IVAS_ERR_OK ) { return error; } @@ -698,8 +697,7 @@ ivas_error ivas_ism_metadata_dec_create( if ( element_brate_tmp != NULL ) { - if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, n_ISms, n_ISms, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, - 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, n_ISms, n_ISms, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 4b452eba33c0003309d2f51d10996e584f2f691a..2f05b5ce8daf073f67f220d853d08fa2bf9808a3 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -94,6 +94,7 @@ static void ivas_param_ism_dec_dequant_powrat( return; } + static void ivas_ism_get_interpolator( const int16_t subframe_nbslots, float *interpolator ) @@ -275,6 +276,7 @@ static void ivas_param_ism_compute_mixing_matrix( } direct_power[w] = sqrtf( direct_power[w] ); } + /* Compute mixing matrix */ computeMixingMatricesISM( nchan_transport, num_wave, nchan_out_woLFE, response_matrix, direct_power, cx_diag[bin_idx], cy_diag, proto_matrix, 1, PARAM_MC_REG_SX, PARAM_MC_REG_GHAT, mixing_matrix[bin_idx] ); @@ -871,12 +873,12 @@ void ivas_param_ism_dec( } } } + ivas_ism_param_dec_tc_gain_ajust( st_ivas, output_frame, output_frame / 2, p_tc ); + for ( ch = 0; ch < nchan_transport; ch++ ) { - /*-----------------------------------------------------------------* - * CLDFB Analysis - *-----------------------------------------------------------------*/ + /* CLDFB Analysis */ for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) { cldfbAnalysis_ts( &( output_f[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), Cldfb_RealBuffer_in[ch][slot_idx], Cldfb_ImagBuffer_in[ch][slot_idx], hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); @@ -893,6 +895,7 @@ void ivas_param_ism_dec( /* Compute mixing matrix */ ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hDirAC, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, mixing_matrix ); + /* subframe loop for synthesis*/ for ( subframe_idx = 0; subframe_idx < hSpatParamRendCom->nb_subframes; subframe_idx++ ) { @@ -989,7 +992,6 @@ void ivas_ism_dec_digest_tc( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); if ( st_ivas->renderer_type == RENDERER_TD_PANNING || @@ -1026,6 +1028,7 @@ void ivas_ism_dec_digest_tc( { ivas_jbm_dec_get_adapted_linear_interpolator( (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator ); } + /* also get the gains here */ num_objects = st_ivas->nchan_transport; for ( i = 0; i < num_objects; i++ ) @@ -1034,10 +1037,7 @@ void ivas_ism_dec_digest_tc( if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_STEREO ) { - ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, - st_ivas->hIsmMetaData[i]->elevation, - &st_ivas->hIsmRendererData->gains[i][0], - &st_ivas->hIsmRendererData->gains[i][1] ); + ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &st_ivas->hIsmRendererData->gains[i][0], &st_ivas->hIsmRendererData->gains[i][1] ); } else { @@ -1218,6 +1218,7 @@ void ivas_param_ism_dec_digest_tc( mvr2r( RealBuffer, &hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); mvr2r( ImagBuffer, &hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); } + ivas_param_ism_collect_slot( hDirAC, &hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag ); } } @@ -1244,10 +1245,10 @@ void ivas_param_ism_dec_digest_tc( *-------------------------------------------------------------------------*/ void ivas_ism_param_dec_tc_gain_ajust( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamples, /* i : number of samples to be compensate */ - const uint16_t nFadeLength, /* i : length of the crossfade in samples */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamples, /* i : number of samples to be compensate */ + const uint16_t nFadeLength, /* i : length of the crossfade in samples */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ ) { @@ -1259,7 +1260,6 @@ void ivas_ism_param_dec_tc_gain_ajust( ene_sum = 0.0f; last_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain; - for ( i = 0; i < nSamples; i++ ) { ene_tc += transport_channels_f[0][i] * transport_channels_f[0][i] + transport_channels_f[1][i] * transport_channels_f[1][i]; // L*L + R*R @@ -1291,11 +1291,13 @@ void ivas_ism_param_dec_tc_gain_ajust( transport_channels_f[1][i] *= gain; } } + st_ivas->hDirAC->hParamIsm->last_dmx_gain = gain; return; } + /*-------------------------------------------------------------------------* * ivas_ism_param_dec_render_sf() * @@ -1319,7 +1321,6 @@ static void ivas_ism_param_dec_render_sf( float *Cldfb_ImagBuffer_in[PARAM_ISM_MAX_DMX]; DIRAC_DEC_HANDLE hDirAC; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - int16_t slot_idx_start; int16_t idx_in; int16_t idx_lfe; @@ -1352,8 +1353,7 @@ static void ivas_ism_param_dec_render_sf( /* Compute bandwise rendering to target LS using covariance rendering */ ivas_param_ism_render_slot( hDirAC, hSpatParamRendCom, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, - Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirAC->hParamIsmRendering->mixing_matrix_lin, index_slot, slot_idx, - nchan_out_woLFE, nchan_transport ); + Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirAC->hParamIsmRendering->mixing_matrix_lin, index_slot, slot_idx, nchan_out_woLFE, nchan_transport ); } /* CLDFB Synthesis */ @@ -1381,8 +1381,8 @@ static void ivas_ism_param_dec_render_sf( RealBuffer[i] = Cldfb_RealBuffer[idx_in][i]; ImagBuffer[i] = Cldfb_ImagBuffer[idx_in][i]; } - cldfbSynthesis( RealBuffer, ImagBuffer, output_f[ch], - hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); + + cldfbSynthesis( RealBuffer, ImagBuffer, output_f[ch], hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); idx_in++; } } diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index b86741139900836c087342a91be6a8f2b0890388..de719d508a949135dfaa0b63f7ff7e76118a5b7c 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -183,10 +183,7 @@ void ivas_ism_render( { if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_STEREO ) { - ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, - st_ivas->hIsmMetaData[i]->elevation, - &gains[i][0], - &gains[i][1] ); + ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, st_ivas->hIsmMetaData[i]->elevation, &gains[i][0], &gains[i][1] ); } else { @@ -243,6 +240,7 @@ void ivas_ism_render( return; } + /*-------------------------------------------------------------------------* * ivas_ism_render_sf() * @@ -274,12 +272,9 @@ void ivas_ism_render_sf( set_f( output_f[i], 0.0f, n_samples_to_render ); } - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[0] ) { - ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, - n_samples_to_render, - st_ivas->hIsmRendererData->interpolator ); + ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); interp_offset = 0; } @@ -601,6 +596,7 @@ void ivas_omasa_separate_object_render( return; } + /*-------------------------------------------------------------------------* * ivas_omasa_separate_object_render_jbm() * diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 556000b72c98691d8f23e2f4a297e7035497651c..004855330a8957deb3c34f27fcec5d20d68b6736 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -773,9 +773,9 @@ ivas_error ivas_jbm_dec_render( const uint16_t nSamplesAsked, /* i : number of samples wanted */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else int16_t *data /* o : output synthesis signal */ #endif @@ -968,7 +968,10 @@ ivas_error ivas_jbm_dec_render( } else /* SBA_MODE_SPAR */ { - ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); + if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK ) + { + return error; + } } } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) @@ -979,7 +982,7 @@ ivas_error ivas_jbm_dec_render( { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { - if ( ( ivas_omasa_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_omasa_dirac_td_binaural_jbm( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ) ) != IVAS_ERR_OK ) { return error; } @@ -1165,11 +1168,11 @@ ivas_error ivas_jbm_dec_render( st_ivas->hTcBuffer->n_samples_discard = 0; } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->Opt_Limiter ) #endif { - if ( !( st_ivas->ivas_format == MONO_FORMAT ) ) + if ( st_ivas->ivas_format != MONO_FORMAT ) { #ifndef DISABLE_LIMITER ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect ); @@ -1177,7 +1180,7 @@ ivas_error ivas_jbm_dec_render( } } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT switch ( pcm_resolution ) { case PCM_INT16: @@ -1185,13 +1188,13 @@ ivas_error ivas_jbm_dec_render( #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output( p_output, *nSamplesRendered, nchan_out, -#if defined SPLIT_REND_WITH_HEAD_ROT - (int16_t *) +#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_syn_output( p_output, *nSamplesRendered, nchan_out, (int16_t *) data ); +#else + ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); #endif - data ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT break; case PCM_FLOAT32: ivas_syn_output_f( p_output, *nSamplesRendered, nchan_out, (float *) data ); @@ -1201,6 +1204,7 @@ ivas_error ivas_jbm_dec_render( break; } #endif + *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; pop_wmops(); @@ -1223,7 +1227,7 @@ ivas_error ivas_jbm_dec_flush_renderer( const MC_MODE mc_mode_old, /* i : old MC mode */ const ISM_MODE ism_mode_old, /* i : old ISM mode */ uint16_t *nSamplesRendered, /* o : number of samples flushed */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -1378,7 +1382,7 @@ ivas_error ivas_jbm_dec_flush_renderer( } /* Only write out the valid data*/ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->Opt_Limiter ) #endif { @@ -1390,7 +1394,7 @@ ivas_error ivas_jbm_dec_flush_renderer( } } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT switch ( pcm_resolution ) { case PCM_INT16: @@ -1399,12 +1403,12 @@ ivas_error ivas_jbm_dec_flush_renderer( st_ivas->noClipping += #endif ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT (int16_t *) #endif data ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT break; case PCM_FLOAT32: ivas_syn_output_f( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (float *) data ); @@ -1702,16 +1706,12 @@ int16_t ivas_jbm_dec_get_num_tc_channels( } if ( st_ivas->ivas_format == SBA_FORMAT ) { - if ( -#ifndef NONBE_FIX_770_PLANAR_SBA_JBM - ( st_ivas->sba_planar && num_tc >= 3 ) || - ( -#endif - num_tc == 3 -#ifndef NONBE_FIX_770_PLANAR_SBA_JBM - ) + +#ifdef NONBE_FIX_770_PLANAR_SBA_JBM + if ( num_tc == 3 ) +#else + if ( ( st_ivas->sba_planar && num_tc >= 3 ) || num_tc == 3 ) #endif - ) { num_tc++; } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index af152d2a8dc989c2bd5ea2528a582673d5becacb..37cff3347e5b70f7de3bef37605564b2d6ddde07 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -76,7 +76,9 @@ static ivas_error ivas_masa_dec_config( Decoder_Struct *st_ivas ); static int16_t ivas_decode_masaism_metadata( IVAS_QMETADATA_HANDLE hQMetaData, MASA_DECODER_HANDLE hMasa, MASA_ISM_DATA_HANDLE hMasaIsmData, const int16_t nchan_ism, uint16_t *bit_stream, int16_t *next_bit_pos, const int16_t idx_separated_object, const int16_t ism_imp, const int16_t dirac_bs_md_write_idx, const int16_t dirac_md_buffer_length ); static void decode_index_slice( int16_t index, int16_t *ratio_idx_ism, const int16_t nchan_ism, const int16_t K ); + static void decode_ism_ratios( uint16_t *bit_stream, int16_t *next_bit_pos, float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], float ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t nbands, const int16_t nblocks, const int16_t idx_separated_object ); + static void read_ism_ratio_index( int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t numCodingBands, const int16_t sf, int16_t ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], uint16_t *bit_stream, int16_t *next_bit_pos, float *masa_to_total_energy_ratio, const int16_t idx_sep_obj, int16_t *num_zeros ); @@ -404,8 +406,7 @@ ivas_error ivas_masa_decode( return error; } - ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, - st_ivas->ivas_format, st_ivas->ism_mode, 0 ); + ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, st_ivas->ivas_format, st_ivas->ism_mode, 0 ); hQMetaData->metadata_max_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC; @@ -582,8 +583,7 @@ ivas_error ivas_masa_dec_open( } } - ivas_masa_set_elements( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, - st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); + ivas_masa_set_elements( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); mvs2s( DirAC_block_grouping, hMasa->config.block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); mvs2s( MASA_band_grouping_24, hMasa->config.band_grouping, MASA_FREQUENCY_BANDS + 1 ); @@ -834,11 +834,10 @@ static ivas_error ivas_masa_dec_config( *-------------------------------------------------------------------*/ void ivas_masa_prerender( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* i/o: synthesized core-coder transport channels */ - const int16_t output_frame /* i : output frame length per channel */ - , - const int16_t nchan_remapped /* i : number of transports used in core */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float *output[], /* i/o: synthesized core-coder transport channels */ + const int16_t output_frame, /* i : output frame length per channel */ + const int16_t nchan_remapped /* i : number of transports used in core */ ) { if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nchan_transport == 2 && nchan_remapped == 1 ) @@ -887,7 +886,7 @@ static void index_16bits( } -/* Used to replicate subframe data when there is only one subframe sent */ +/* Replicate subframe data when there is only one subframe sent */ static void replicate_subframes( IVAS_QMETADATA_HANDLE hQMetaData ) { @@ -953,7 +952,7 @@ static void restore_lowbitrate_masa( } } } - hQMetaData->q_direction->cfg.nblocks = 4; /* Set just to be sure */ + hQMetaData->q_direction->cfg.nblocks = 4; } else { @@ -977,7 +976,7 @@ static void restore_lowbitrate_masa( } } } - hQMetaData->q_direction->cfg.nbands = numCodingBands; /* Set just to be sure */ + hQMetaData->q_direction->cfg.nbands = numCodingBands; } return; @@ -1007,6 +1006,7 @@ static ivas_error init_lfe_synth_data( set_zero( hMasa->hMasaLfeSynth->lfeToTotalEnergyRatio, MAX_PARAM_SPATIAL_SUBFRAMES ); hMasa->hMasaLfeSynth->lfeGainPrevIndex = 0; + if ( st_ivas->hOutSetup.separateChannelEnabled && ( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || output_config == IVAS_AUDIO_CONFIG_5_1_2 || @@ -1225,11 +1225,11 @@ static int16_t decode_lfe_to_total_energy_ratio( *-------------------------------------------------------------------*/ ivas_error ivas_masa_dec_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else int16_t *data /* o : output synthesis signal */ #endif @@ -1421,12 +1421,12 @@ ivas_error ivas_masa_dec_reconfigure( { return error; } - - /*-----------------------------------------------------------------* - * Set-up MASA coding elements and bitrates - *-----------------------------------------------------------------*/ } + /*-----------------------------------------------------------------* + * Set-up MASA coding elements and bitrates + *-----------------------------------------------------------------*/ + ism_total_brate = 0; if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->nSCE > 0 && ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) ) { @@ -1436,8 +1436,7 @@ ivas_error ivas_masa_dec_reconfigure( } } - ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, - st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); + ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->ivas_format, st_ivas->ism_mode, ism_total_brate ); if ( st_ivas->ivas_format == MASA_FORMAT ) { @@ -1485,7 +1484,7 @@ ivas_error ivas_masa_dec_reconfigure( if ( n_samples_granularity < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif data ) ) != IVAS_ERR_OK ) @@ -1604,7 +1603,6 @@ void ivas_spar_param_to_masa_param_mapping( } else { - mixer_mat_index = ( ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) == 1 ) ? 0 : ( sf - SPAR_META_DELAY_SUBFRAMES ); for ( band = 0; band < SPAR_DIRAC_SPLIT_START_BAND; band++ ) { @@ -1680,6 +1678,7 @@ void ivas_spar_param_to_masa_param_mapping( { inCovarianceMtx[0][0] = transportSignalEnergies[0][bin]; /* In case of 2TC, use actual energies */ } + /* Decorrelated channels assumed to have the same energy as the source channel */ inCovarianceMtx[1][1] = inCovarianceMtx[0][0]; inCovarianceMtx[2][2] = inCovarianceMtx[0][0]; @@ -1929,10 +1928,11 @@ static void create_masa_ext_out_meta( } static void decode_index_slice( - int16_t index, /* i : index to decode */ - int16_t *ratio_idx_ism, /* o : decodec array of integers */ - const int16_t nchan_ism, /* i : number of elements in array (objects) */ - const int16_t K ) /* i : sum of array elements */ + int16_t index, /* i : index to decode */ + int16_t *ratio_idx_ism, /* o : decodec array of integers */ + const int16_t nchan_ism, /* i : number of elements in array (objects) */ + const int16_t K /* i : sum of array elements */ +) { int16_t i, j, sum, elem; int16_t base[MAX_NUM_OBJECTS]; @@ -2374,6 +2374,7 @@ static int16_t ivas_decode_masaism_metadata( /* read ISM metadata */ calculate_nbits_meta( nchan_ism, energy_ratio_ism, hMasaIsmData->masa_to_total_energy_ratio, nblocks, nbands, bits_ism, idx_separated_object, ism_imp ); + for ( obj = 0; obj < nchan_ism; obj++ ) { index = 0; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index f713b47b6cd1c12222a74f87181b77aafb3c6b6f..6bdba5039aff0990d699a2861f631fb723286f2f 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -100,6 +100,7 @@ static ivas_error param_mc_get_diff_proto_info( const float *proto_mtx, const ui #ifndef NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION static void ivas_param_mc_mc2sba_cldfb( IVAS_OUTPUT_SETUP hTransSetup, float *hoa_encoder, const int16_t slot_idx, float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], const int16_t nBands, const float gain_lfe ); #endif + static void ivas_param_mc_get_param_band_mapping( const int16_t n_target_bands, const int16_t *target_band_grouping, const int16_t n_source_bands, const int16_t *source_band_grouping, PARAM_MC_PARAMETER_BAND_MAPPING *parameter_band_mapping ); static void ivas_param_mc_bs_decode_parameter_values( uint16_t bit_buffer[], int16_t *bit_pos, const int16_t max_bits, int16_t *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const int16_t map_size_wo_lfe, const int16_t map_size, const int16_t num_lfe_bands, const int16_t band_step, const int16_t num_param_bands, float *value_buffer ); @@ -246,7 +247,6 @@ ivas_error ivas_param_mc_dec_open( param_mc_set_num_synth_bands( output_Fs, hParamMC ); - /* Band Grouping */ if ( hParamMC->hMetadataPMC->num_parameter_bands == 20 ) { @@ -323,9 +323,7 @@ ivas_error ivas_param_mc_dec_open( if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) { - matrix_product( hParamMC->ls_conv_dmx_matrix, nchan_out_cov, nchan_out_transport, 0, - ivas_param_mc_conf[config_index].dmx_fac, nchan_out_transport, nchan_transport, 0, - proto_matrix ); + matrix_product( hParamMC->ls_conv_dmx_matrix, nchan_out_cov, nchan_out_transport, 0, ivas_param_mc_conf[config_index].dmx_fac, nchan_out_transport, nchan_transport, 0, proto_matrix ); if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) { @@ -379,15 +377,8 @@ ivas_error ivas_param_mc_dec_open( ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, hParamMC->num_freq_bands ); - if ( ( error = ivas_dirac_dec_decorr_open( &( hParamMC->h_freq_domain_decorr_ap_params ), - &( hParamMC->h_freq_domain_decorr_ap_state ), - hParamMC->num_freq_bands, - hParamMC->num_outputs_diff, - hParamMC->diff_proto_info->num_protos_diff, - DIRAC_SYNTHESIS_COV_MC_LS, - frequency_axis, - nchan_transport, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_decorr_open( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, hParamMC->diff_proto_info->num_protos_diff, + DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis, nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -409,22 +400,14 @@ ivas_error ivas_param_mc_dec_open( } /* output synthesis */ - if ( ( error = ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ), - &( hParamMC->h_output_synthesis_cov_state ), - hParamMC->max_band_decorr, - PARAM_MC_MAX_NSLOTS, - hParamMC->hMetadataPMC->num_parameter_bands, - max_param_band_residual, - nchan_transport, - nchan_out_cov, - proto_matrix ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, + hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix ) ) != IVAS_ERR_OK ) { return error; } ivas_param_mc_dec_compute_interpolator( 0, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hParamMC->h_output_synthesis_params.interpolator ); - /* Head or external rotation */ if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) { @@ -459,9 +442,7 @@ ivas_error ivas_param_mc_dec_open( ivas_param_mc_dec_init( hParamMC, nchan_transport, nchan_out_cov ); - if ( - st_ivas->hDecoderConfig->Opt_5ms && - hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) + if ( st_ivas->hDecoderConfig->Opt_5ms && hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) { int16_t n_cldfb_slots; @@ -481,6 +462,7 @@ ivas_error ivas_param_mc_dec_open( 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 ); + if ( st_ivas->hTcBuffer == NULL ) { if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) @@ -748,7 +730,6 @@ ivas_error ivas_param_mc_dec_reconfig( param_mc_set_num_synth_bands( output_Fs, hParamMC ); - /* set max parameter band for abs cov */ k = 0; while ( hParamMC->band_grouping[k] <= PARAM_MC_MAX_BAND_ABS_COV_DEC ) @@ -893,15 +874,8 @@ ivas_error ivas_param_mc_dec_reconfig( ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, hParamMC->num_freq_bands ); - if ( ( error = ivas_dirac_dec_decorr_open( &( hParamMC->h_freq_domain_decorr_ap_params ), - &( hParamMC->h_freq_domain_decorr_ap_state ), - hParamMC->num_freq_bands, - hParamMC->num_outputs_diff, - hParamMC->diff_proto_info->num_protos_diff, - DIRAC_SYNTHESIS_COV_MC_LS, - frequency_axis, - nchan_transport, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_decorr_open( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, + hParamMC->diff_proto_info->num_protos_diff, DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis, nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -941,15 +915,8 @@ ivas_error ivas_param_mc_dec_reconfig( set_zero( tmp_buf, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); /* output synthesis */ - if ( ( error = ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ), - &( hParamMC->h_output_synthesis_cov_state ), - hParamMC->max_band_decorr, - PARAM_MC_MAX_NSLOTS, - hParamMC->hMetadataPMC->num_parameter_bands, - max_param_band_residual, - nchan_transport, - nchan_out_cov, - proto_matrix ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, + hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix ) ) != IVAS_ERR_OK ) { return error; } @@ -958,7 +925,6 @@ ivas_error ivas_param_mc_dec_reconfig( ivas_dirac_dec_output_synthesis_cov_init( &( hParamMC->h_output_synthesis_cov_state ), nchan_transport, nchan_out_cov, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual ); - /* map old to new parameter banding, only for same number of TCs, needs some more thought for changing number of TCs */ if ( num_param_bands_old != hParamMC->hMetadataPMC->num_parameter_bands && nchan_transport_old == nchan_transport ) { @@ -1133,7 +1099,6 @@ void ivas_param_mc_dec_close( hParamMC->diff_proto_info = NULL; } - /* States */ /* free prototype signal buffers */ if ( hParamMC->proto_frame_f != NULL ) @@ -1783,17 +1748,23 @@ void ivas_param_mc_dec_render( } } #endif - ivas_binRenderer( st_ivas->hBinRenderer, + #ifdef SPLIT_REND_WITH_HEAD_ROT - &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, +#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_DEBUG NULL, #endif - st_ivas->hCombinedOrientationData, - subframe_idx, - hParamMC->subframe_nbslots[subframe_idx], - Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + st_ivas->hCombinedOrientationData, subframe_idx, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); +#endif #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 ) @@ -2189,6 +2160,7 @@ static int16_t ivas_param_mc_range_decoder_LC( * * compute the interpolator used in the final synthesis *------------------------------------------------------------------------*/ + static void ivas_param_mc_dec_compute_interpolator( const uint16_t bAttackPresent, /* i : flag indicating if we have a transient in the current frame */ const uint16_t attackPos, /* i : position of the transient */ diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 972f3ae5d265e78646c6d4f43d2732f5f117efce..ed002ccc660c063ef6719cdf1aad22d2820d2bfa 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -59,7 +59,7 @@ static void ps_pred_process( MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, float qmf_m static void ps_pred_process_sf( MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, DECODER_TC_BUFFER_HANDLE hTcBuffer, float qmf_mod_re[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float qmf_mod_im[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float qmf_side_re[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float qmf_side_im[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float *param_interpol, const int16_t ch, const int16_t slots_rendered ); #ifdef SPLIT_REND_WITH_HEAD_ROT -static void ivas_mc_paramupmix_dec_sf( Decoder_Struct *st_ivas, float *output_f[MAX_OUTPUT_CHANNELS], int16_t slot_index_start ); +static void ivas_mc_paramupmix_dec_sf( Decoder_Struct *st_ivas, float *output_f[MAX_OUTPUT_CHANNELS], const int16_t slot_index_start ); #else static void ivas_mc_paramupmix_dec_sf( Decoder_Struct *st_ivas, float *output_f[MAX_OUTPUT_CHANNELS] ); #endif @@ -153,7 +153,6 @@ void ivas_mc_paramupmix_dec_read_BS( } pop_wmops(); - return; } @@ -211,7 +210,6 @@ void ivas_mc_paramupmix_dec( hMCParamUpmix = st_ivas->hMCParamUpmix; assert( hMCParamUpmix ); - push_wmops( "mc_paramupmix_dec" ); set_s( channel_active, 0, MAX_CICP_CHANNELS ); @@ -319,6 +317,7 @@ void ivas_mc_paramupmix_dec( } idx_in += 2; } + #ifdef NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION if ( st_ivas->hCombinedOrientationData && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { @@ -328,6 +327,7 @@ void ivas_mc_paramupmix_dec( } } #endif + #ifdef SPLIT_REND_WITH_HEAD_ROT /*LFE handling for split rendering cases*/ if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) @@ -367,20 +367,19 @@ void ivas_mc_paramupmix_dec( #endif /* Implement binaural rendering */ - ivas_binRenderer( st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT - &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, +#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 ); #endif - st_ivas->hCombinedOrientationData, - subframeIdx, /* TODO (5ms) : tmu2Dlb please verify */ - JBM_CLDFB_SLOTS_IN_SUBFRAME, +#else + ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, subframeIdx, /* TODO (5ms) : tmu2Dlb please verify */ 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 ); - + Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_subfr, Cldfb_ImagBuffer_subfr ); +#endif #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 ) @@ -396,6 +395,7 @@ void ivas_mc_paramupmix_dec( } } #endif + for ( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) { for ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ ) @@ -489,7 +489,6 @@ void ivas_mc_paramupmix_dec( } pop_wmops(); - return; } @@ -502,14 +501,13 @@ void ivas_mc_paramupmix_dec( void ivas_mc_paramupmix_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels*/ + const int16_t nSamplesForRendering /* i : number of samples provided */ ) { MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; hMCParamUpmix = st_ivas->hMCParamUpmix; assert( hMCParamUpmix ); - push_wmops( "ivas_mc_paramupmix_dec_digest_tc" ); ivas_param_upmix_dec_decorr_subframes( st_ivas, nSamplesForRendering ); @@ -520,6 +518,7 @@ void ivas_mc_paramupmix_dec_digest_tc( ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hMCParamUpmix->param_interpolator ); pop_wmops(); + return; } @@ -615,6 +614,7 @@ void ivas_mc_paramupmix_dec_render( *nSamplesAvailable = ( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered ) * slot_size; pop_wmops(); + return; } @@ -661,9 +661,11 @@ ivas_error ivas_mc_paramupmix_dec_open( assert( 0 && "Number of TC not supported for MC ParamUpmix!" ); #endif } + #ifdef NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION hMCParamUpmix->hoa_encoder = NULL; #endif + /*-----------------------------------------------------------------* * set input parameters *-----------------------------------------------------------------*/ @@ -699,9 +701,7 @@ ivas_error ivas_mc_paramupmix_dec_open( /* allocate transport channels*/ hMCParamUpmix->free_param_interpolator = 0; hMCParamUpmix->param_interpolator = NULL; - if ( - st_ivas->hDecoderConfig->Opt_5ms == 1 && - st_ivas->hTcBuffer == NULL ) + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 && st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; int16_t nchan_tc; @@ -787,11 +787,14 @@ void ivas_mc_paramupmix_dec_close( return; } + + /*------------------------------------------------------------------------- * ivas_param_upmix_dec_decorr_subframes() * * *------------------------------------------------------------------------*/ + static void paramupmix_td_decorr_process_jbm( ivas_td_decorr_state_t *hTdDecorr[], /* i/o: SPAR Covar. decoder handle */ float *pcm_in[], /* i : input audio channels */ @@ -838,8 +841,9 @@ static void paramupmix_td_decorr_process_jbm( return; } + static void ivas_param_upmix_dec_decorr_subframes( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nSamplesForRendering ) { MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; @@ -879,10 +883,10 @@ static void ivas_param_upmix_dec_decorr_subframes( } pop_wmops(); - return; } + /*****************************************************************************************/ /* local functions */ /*****************************************************************************************/ @@ -1035,7 +1039,7 @@ static void ivas_mc_paramupmix_dec_sf( float *output_f[MAX_OUTPUT_CHANNELS] /* i/o: synthesized core-coder transport channels */ #ifdef SPLIT_REND_WITH_HEAD_ROT , - int16_t slot_index_start + const int16_t slot_index_start #endif ) { @@ -1111,6 +1115,7 @@ static void ivas_mc_paramupmix_dec_sf( } } } + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); @@ -1184,16 +1189,11 @@ static void ivas_mc_paramupmix_dec_sf( #endif /* Implement binaural rendering */ - ivas_binRenderer( st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT - &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, + 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 ); #endif - st_ivas->hCombinedOrientationData, - subframeIdx, - 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 ) @@ -1213,7 +1213,6 @@ static void ivas_mc_paramupmix_dec_sf( } #endif - /* Implement CLDFB synthesis */ for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -1290,6 +1289,7 @@ static void ivas_mc_paramupmix_dec_sf( st_ivas->hTcBuffer->subframes_rendered++; pop_wmops(); + return; } diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index f7b12126acaa75beff526953363192a772ac9e2e..faffe1a1b4b92b4209a4e48436deb69a5aa22f12 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -88,8 +88,7 @@ void ivas_mct_side_bits( for ( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - if ( - st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -115,8 +114,7 @@ void ivas_mct_side_bits( { st = sts[ch]; - if ( - st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { chBitRatios[ch] = 0; st->bits_frame_channel = 0; @@ -203,8 +201,7 @@ void ivas_mct_core_dec( for ( ch = 0, i = 0; ch < nChannels; ch++ ) { - if ( - sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 43af6876a3d2651e2c6654928ff4f74d9cf67c67..efd369b5343a2662a1282b29be2a0d3a787cfc08 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -54,14 +54,12 @@ * Local function prototypes *-----------------------------------------------------------------------*/ -static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT +static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, const PCM_RESOLUTION pcm_resolution, void *data ); #else - int16_t *data /* o : output synthesis signal */ +static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, uint16_t *nSamplesRendered, int16_t *data ); #endif -); + /*--------------------------------------------------------------------------* * ivas_mct_dec() @@ -378,6 +376,7 @@ ivas_error create_mct_dec( cp_bitrate = st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport * CPE_CHANNELS; } #endif + /* indicate LFE for appropriate core-coder channel */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { @@ -515,6 +514,7 @@ ivas_error mct_dec_reconfigure( cp_bitrate = st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport * CPE_CHANNELS; } #endif + /* set correct nominal bitrates and igf config already here, otherwise we * run into a number of problems */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) @@ -657,11 +657,11 @@ ivas_error ivas_mc_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t idx, /* i : LS config. index */ uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ) { @@ -669,8 +669,6 @@ ivas_error ivas_mc_dec_config( MC_MODE last_mc_mode; ivas_error error; - error = IVAS_ERR_OK; - /* store last frame MC mode */ last_mc_mode = st_ivas->mc_mode; @@ -692,18 +690,22 @@ ivas_error ivas_mc_dec_config( { if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode ) { - ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ); + + { + return error; + } } } st_ivas->transport_config = signaled_config; } - return error; + return IVAS_ERR_OK; } @@ -716,11 +718,11 @@ ivas_error ivas_mc_dec_config( static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ) { @@ -803,11 +805,11 @@ static ivas_error ivas_mc_dec_reconfig( tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, +#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 ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -822,7 +824,6 @@ static ivas_error ivas_mc_dec_reconfig( } } - if ( st_ivas->mc_mode == MC_MODE_MCT ) { st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) ); @@ -962,11 +963,8 @@ static ivas_error ivas_mc_dec_reconfig( ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); } - if ( st_ivas->hLFE != NULL ) - { - /* LFE handle */ - ivas_lfe_dec_close( &( st_ivas->hLFE ) ); - } + /* LFE handle */ + ivas_lfe_dec_close( &( st_ivas->hLFE ) ); #endif } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) @@ -1010,11 +1008,8 @@ static ivas_error ivas_mc_dec_reconfig( } #ifdef NONBE_FIX_722_MEMORY_LEAK_IN_PARAMUPMIX - if ( st_ivas->hLFE != NULL ) - { - /* LFE handle */ - ivas_lfe_dec_close( &( st_ivas->hLFE ) ); - } + /* LFE handle */ + ivas_lfe_dec_close( &( st_ivas->hLFE ) ); #endif } @@ -1063,7 +1058,6 @@ static ivas_error ivas_mc_dec_reconfig( if ( st->hHQ_core == NULL ) { - if ( ( st->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); @@ -1127,7 +1121,6 @@ static ivas_error ivas_mc_dec_reconfig( } } - /*-----------------------------------------------------------------* * re-configure HP20 memories *-----------------------------------------------------------------*/ @@ -1137,10 +1130,10 @@ static ivas_error ivas_mc_dec_reconfig( return error; } - /*-----------------------------------------------------------------* * Allocate the LFE handle that is coded separately after the allocation of the core coders *-----------------------------------------------------------------*/ + if ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && st_ivas->hLFE == NULL ) { int32_t binauralization_delay_ns = st_ivas->binaural_latency_ns; @@ -1226,12 +1219,12 @@ static ivas_error ivas_mc_dec_reconfig( if ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend != NULL ) && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hIntSetup.output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) #endif { - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); #endif - ); } if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) ) @@ -1272,12 +1265,11 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 1 + if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper, 1 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); } @@ -1301,12 +1293,11 @@ static ivas_error ivas_mc_dec_reconfig( } else if ( st_ivas->hCrendWrapper == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT - , - st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1347,6 +1338,7 @@ static ivas_error ivas_mc_dec_reconfig( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) { int16_t tc_nchan_full_new; diff --git a/lib_dec/ivas_mct_dec_mct.c b/lib_dec/ivas_mct_dec_mct.c index 987a9cc72f25a60b4e820972aeb8ae6c4fcb4b8e..881c35119cdbaef891ac4f8adde4cef504241a95 100644 --- a/lib_dec/ivas_mct_dec_mct.c +++ b/lib_dec/ivas_mct_dec_mct.c @@ -99,8 +99,7 @@ void ivas_mct_dec_mct( /*first get core and overlap info for all channels*/ for ( ch = 0; ch < nchan; ch++ ) { - if ( - hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { hMCT->mc_global_ild[ch] = get_next_indice( sts[0], SMDCT_GLOBAL_ILD_BITS ); } @@ -124,8 +123,7 @@ void ivas_mct_dec_mct( for ( ch = 0; ch < nchan; ch++ ) { - if ( - sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { nchan_active++; } @@ -305,8 +303,7 @@ void mctStereoIGF_dec( if ( sum_s( singleChEle, ( hMCT->nchan_out_woLFE ) ) != 0 ) { - for ( ch = 0; ch < ( hMCT->nchan_out_woLFE ); - ch++ ) + for ( ch = 0; ch < ( hMCT->nchan_out_woLFE ); ch++ ) { if ( singleChEle[ch] ) { diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index a7aa2c770116d5580710033dd538c6abe9e3a18f..d189cdc5422fa5b2b729dae7ff76195da2833406 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -197,6 +197,7 @@ static void dec_prm_tcx_sidebits( getTCXparam( st, st0, hm_cfg, param, 0, 0, ( ( ch > 0 ) && ( tnsSize ) && ( tnsSize[0] + tnsSize[1] > 0 ) ? tnsSize : NULL ), p_param, nTnsBitsTCX10, 0 ); st->side_bits_frame_channel = st0->next_bit_pos - start_bit_pos; + return; } @@ -523,7 +524,6 @@ void ivas_mdct_core_invQ( TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode_bfi; push_wmops( "mdct_core_invQ" ); - sts = hCPE->hCoreCoder; bfi = sts[0]->bfi; noise_gen_mode_bfi = NOISE_GEN_MODE_UNDEF; @@ -1043,8 +1043,7 @@ void ivas_mdct_core_tns_ns( L_frameTCX_glob[ch] = st->hTcxDec->L_frameTCX / nSubframes[ch]; L_spec[ch] = st->hTcxCfg->tcx_coded_lines / nSubframes[ch]; - if ( - ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) || ( st->bfi && st->core == ACELP_CORE ) ) /* indicates LFE with no content, or odd number of channels */ + if ( ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) || ( st->bfi && st->core == ACELP_CORE ) ) /* indicates LFE with no content, or odd number of channels */ { if ( st->hTonalMDCTConc != NULL ) { diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 7ee5382408b715496c8102b70ccd5ca7e6fffd11..599bee9ff9d1414dda3b1e6e1c483332d7f77ea4 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -187,6 +187,7 @@ void ivas_mono_stereo_downmix_mcmasa( return; } + #ifdef FIX_764_HARM_CODE /*------------------------------------------------------------------------- * ivas_apply_non_diegetic_panning() diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 25964d2420976712d2aa06df46279ccdf54246a7..2536618bb78a407dd36f203117b9a5c98eb9ac81 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -82,9 +82,7 @@ ivas_error ivas_td_binaural_renderer( int16_t ism_md_subframe_update; int16_t nchan_transport; - nchan_transport = ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - ? st_ivas->nchan_ism - : st_ivas->nchan_transport; + nchan_transport = ( st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ? st_ivas->nchan_ism : st_ivas->nchan_transport; if ( st_ivas->hDecoderConfig->Opt_delay_comp ) { @@ -100,18 +98,11 @@ ivas_error ivas_td_binaural_renderer( ism_md_subframe_update = 2; } - 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 ); + 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 ); } @@ -216,14 +207,20 @@ ivas_error ivas_td_binaural_renderer_sf( } if ( subframe_idx == ism_md_subframe_update_jbm ) { - TDREND_Update_object_positions( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ); + if ( ( error = TDREND_Update_object_positions( st_ivas->hBinRendererTd, nchan_ism, st_ivas->ivas_format, st_ivas->hIsmMetaData ) ) != IVAS_ERR_OK ) + { + return error; + } } /* Update the listener's location/orientation */ - TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, - ( 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 ); + if ( ( error = TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, + ( 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 ) + { + return error; + } if ( st_ivas->hRenderConfig != NULL && st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 240731d674515198717350fe2fd4feb9c485307d..ec95599c03203df994ff2639ba3919e9a1e70373 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -92,7 +92,6 @@ ivas_error ivas_omasa_data_open( hMasaIsmData->q_azimuth_old[ch] = 0.0f; } - for ( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ ) { set_s( hMasaIsmData->azimuth_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); @@ -154,7 +153,7 @@ void ivas_omasa_data_close( ivas_error ivas_omasa_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -202,11 +201,11 @@ ivas_error ivas_omasa_dec_config( { st_ivas->hCPE[0]->nchan_out = 1; } - else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, +#ifdef SPLIT_REND_WITH_HEAD_ROT + else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + else if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -632,8 +631,7 @@ void ivas_omasa_dirac_rend( dirac_read_idx = st_ivas->hSpatParamRendCom->dirac_read_idx; - ivas_dirac_dec( st_ivas, output, st_ivas->nchan_transport, - MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_dirac_dec( st_ivas, output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); st_ivas->hSpatParamRendCom->dirac_read_idx = dirac_read_idx; /* Original read index is needed for the next function which will update it again */ @@ -706,8 +704,7 @@ ivas_error ivas_omasa_dirac_td_binaural( delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport, - MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 9759e1c7c28d36d2219ad473e1fdcb1f2f6325d4..39efa31c91f2c61da66a5bfacaab24b4cb18087e 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -65,6 +65,8 @@ ivas_error ivas_masa_ism_data_open( return IVAS_ERR_OK; } + + /*-------------------------------------------------------------------* * ivas_masa_ism_data_close() * @@ -127,7 +129,6 @@ ivas_error ivas_sba_ism_separate_object_renderer_open( set_zero( st_ivas->hMasaIsmData->delayBuffer[i], st_ivas->hMasaIsmData->delayBuffer_size ); } - return IVAS_ERR_OK; } @@ -164,8 +165,7 @@ ivas_error ivas_osba_dirac_td_binaural( } #ifdef OSBA_SPLIT_RENDERING - if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && - st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( 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++ ) @@ -183,8 +183,7 @@ ivas_error ivas_osba_dirac_td_binaural( } else { - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[channel_offset], st_ivas->nchan_transport, - MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[channel_offset], st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); } #ifdef DEBUG_OSBA @@ -200,8 +199,7 @@ ivas_error ivas_osba_dirac_td_binaural( } #endif #ifdef OSBA_SPLIT_RENDERING - if ( ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + 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 slot_idx, num_cldfb_bands, b, nchan_transport_orig; float Cldfb_RealBuffer[CLDFB_NO_CHANNELS_MAX]; @@ -280,7 +278,6 @@ ivas_error ivas_osba_ism_metadata_dec( nchan_transport_ism = st_ivas->nchan_ism; *nchan_ism = st_ivas->nchan_ism; - /* decode ISM metadata */ if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, &nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) @@ -291,6 +288,7 @@ ivas_error ivas_osba_ism_metadata_dec( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------------* * ivas_osba_render() * diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 56ed6b8ccef69046a0f7914eed8ffcc54c5458c5..d622e4cf1e94152282f096692b2bf1371810b1b8 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -1124,6 +1124,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( return; } + /*------------------------------------------------------------------------- * ivas_ls_setup_conversion_process_param_mc() * @@ -1149,7 +1150,6 @@ void ivas_lssetupconversion_process_param_mc( LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; push_wmops( "LS_Renderer_Process_Param_MC" ); - /* inits */ inChannels = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; outChannels = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; @@ -1197,7 +1197,6 @@ void ivas_lssetupconversion_process_param_mc( Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx] += tmpDMXSig; targetEnergy[chOutIdx][bandIdx] += tmpDMXSig * tmpDMXSig; - tmpDMXSig = dmxCoeff * Cldfb_ImagBuffer_tmp[chInIdx][bandIdx]; Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx] += tmpDMXSig; targetEnergy[chOutIdx][bandIdx] += tmpDMXSig * tmpDMXSig; diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 40d9a6cdbed3a0c7da32349d5b201401813d2f0a..9acaebf7a04e80ef69cb2d06937b56c3b6d8f0d4 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -362,8 +362,7 @@ void ivas_renderer_select( *renderer_type = RENDERER_DIRAC; ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ - if ( ivas_format == SBA_FORMAT && - ( output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO ) ) + if ( ivas_format == SBA_FORMAT && ( output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO ) ) { if ( output_config == IVAS_AUDIO_CONFIG_HOA2 || output_config == IVAS_AUDIO_CONFIG_FOA ) { @@ -481,6 +480,7 @@ void ivas_renderer_select( else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { *internal_config = output_config; + /* No rendering for 1TC to Mono or Stereo and 2TC to Stereo */ if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) { diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index f9ea70702ba118a8bc796cc30cb75ff74b66932f..0ec2fa24a2b39c945287bb5648fad7f504d9f8a7 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -200,7 +200,6 @@ void stereo_dft_dec_core_switching( #if defined( DEBUG_MODE_DFT ) && defined( DEBUG_STEREO_DFT_NOCORE ) stereo_dft_dec_analyze( hCPE, output, DFT, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_NOCORE, 0, 0 ); #else - /* resample DFT analysis memories in case of internal sampling rate change */ if ( st->last_L_frame != st->L_frame && st->last_L_frame <= L_FRAME16k && st->L_frame <= L_FRAME16k ) { @@ -442,7 +441,6 @@ void stereo_dft_dec_core_switching( } #endif - /*----------------------------------------------------------------* * enhanced stereo filling: allpass filter *----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index f949a16decbc11c75c22dda1c14f4601e3a7985b..728c295ac56177795b266b81e70422dda67546a2 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -55,7 +55,6 @@ static int16_t ivas_qmetadata_raw_decode_dir( IVAS_QDIRECTION *q_direction, uint static uint16_t ivas_qmetadata_DecodeQuasiUniform( const uint16_t *bitstream, int16_t *index, const uint16_t alphabet_size ); - static int16_t ivas_qmetadata_ReorderElevationDecoded( const int16_t elev_dist, const int16_t elev_avg, const int16_t elev_alph ); static int16_t read_directions( IVAS_QDIRECTION *q_direction, const uint8_t coding_subbands, const uint8_t masa_subframes, uint16_t *bitstream, int16_t *pbit_pos, int16_t *ind_order ); @@ -548,7 +547,6 @@ int16_t ivas_qmetadata_dec_decode( #ifdef DEBUGGING assert( ( diff_bits <= 0 ) || ( q_direction->not_in_2D == 0 ) ); #endif - /* Read raw-coded bits*/ for ( b = start_band; b < nbands; b++ ) { @@ -1075,7 +1073,6 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( /* move 2 dir data to its correct subband */ if ( bits_sph_idx == 11 ) { - int16_t nblocks; d = hQMetaData->q_direction[1].cfg.nbands - 1; nblocks = hQMetaData->q_direction[0].cfg.nblocks; @@ -1316,7 +1313,6 @@ int16_t ivas_qmetadata_dec_sid_decode( } else { - /* Decode diffuseness*/ for ( b = start_band; b < nbands; b++ ) { @@ -1351,9 +1347,7 @@ int16_t ivas_qmetadata_dec_sid_decode( q_direction->band_data[b].spherical_index[i] = value; } - deindex_spherical_component( q_direction->band_data[b].spherical_index[0], &avg_azimuth, &avg_elevation, - &q_direction->band_data[b].azimuth_index[0], &q_direction->band_data[b].elevation_index[0], q_direction->band_data[b].bits_sph_idx[0], - q_direction->cfg.mc_ls_setup ); + deindex_spherical_component( q_direction->band_data[b].spherical_index[0], &avg_azimuth, &avg_elevation, &q_direction->band_data[b].azimuth_index[0], &q_direction->band_data[b].elevation_index[0], q_direction->band_data[b].bits_sph_idx[0], q_direction->cfg.mc_ls_setup ); ivas_qmetadata_azimuth_elevation_to_direction_vector( avg_azimuth, avg_elevation, avg_direction_vector ); ivas_qmetadata_azimuth_elevation_to_direction_vector( q_direction->band_data[b].azimuth[nblocks - 1], q_direction->band_data[b].elevation[nblocks - 1], direction_vector ); @@ -1982,8 +1976,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( } /*decode elevation*/ - q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); } } } @@ -2047,8 +2040,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( } /*decode elevation*/ - q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); } } } @@ -2084,8 +2076,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( } /*decode elevation*/ - q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[b].elevation[m] = deindex_elevation( &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); } } } @@ -2114,10 +2105,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( } else { - q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], - q_direction->band_data[b].bits_sph_idx[m], - q_direction->band_data[b].elevation_index[m], 0, - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->band_data[b].elevation_index[m], 0, q_direction->cfg.mc_ls_setup ); } } } @@ -2150,10 +2138,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( } else { - q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], - q_direction->band_data[b].bits_sph_idx[m], - q_direction->band_data[b].elevation_index[m], 0, - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->band_data[b].elevation_index[m], 0, q_direction->cfg.mc_ls_setup ); } if ( ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) && ( nblocks > 1 ) ) { @@ -2228,9 +2213,7 @@ static int16_t ivas_qmetadata_raw_decode_dir_512( } else { - deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], - &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], - q_direction->cfg.mc_ls_setup ); + deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); } } } @@ -2285,8 +2268,7 @@ static int16_t ivas_qmetadata_raw_decode_dir( q_direction->band_data[b].elevation_index[m] = 0; azith_alph = no_phi_masa[bits_direction_masa[diff_idx] - 1][0]; q_direction->band_data[b].azimuth_index[m] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, azith_alph ); - q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], 0, 1, - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[b].azimuth[m] = deindex_azimuth( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], 0, 1, q_direction->cfg.mc_ls_setup ); } } } @@ -2343,8 +2325,7 @@ static uint16_t ivas_qmetadata_DecodeQuasiUniform( *------------------------------------------------------------------------*/ /*! r: Value decoded from the bitstream */ -int16_t -ivas_qmetadata_DecodeExtendedGR( +int16_t ivas_qmetadata_DecodeExtendedGR( uint16_t *bitstream, /* i : pointer to the bitstream to read */ int16_t *index, /* i/o: position in the bitstream to start reading (gets updated with reading) */ const int16_t alph_size, /* i : size of the alphabet, used to calculate the number of bits needed */ @@ -2733,13 +2714,9 @@ static int16_t decode_azimuth( } else { - q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, - q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - ( q_direction->band_data[idx_subband].bits_sph_idx[k] == 2 ) ); + q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - ( q_direction->band_data[idx_subband].bits_sph_idx[k] == 2 ) ); - q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], - q_direction->band_data[idx_subband].bits_sph_idx[k], - q_direction->band_data[idx_subband].elevation_index[k], 1, - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], q_direction->band_data[idx_subband].bits_sph_idx[k], q_direction->band_data[idx_subband].elevation_index[k], 1, q_direction->cfg.mc_ls_setup ); } } } @@ -2760,12 +2737,8 @@ static int16_t decode_azimuth( { if ( no_phi_masa[q_direction->band_data[idx_subband].bits_sph_idx[k] - 1][q_direction->band_data[idx_subband].elevation_index[k]] > 1 ) { - q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, - q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - byteBuffer ); - q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], - q_direction->band_data[idx_subband].bits_sph_idx[k], - q_direction->band_data[idx_subband].elevation_index[k], 1, - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - byteBuffer ); + q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], q_direction->band_data[idx_subband].bits_sph_idx[k], q_direction->band_data[idx_subband].elevation_index[k], 1, q_direction->cfg.mc_ls_setup ); } else { @@ -2795,13 +2768,9 @@ static int16_t decode_azimuth( { if ( no_phi_masa[q_direction->band_data[idx_subband].bits_sph_idx[k] - 1][q_direction->band_data[idx_subband].elevation_index[k]] > 1 ) { - q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, - q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - 1 - byteBuffer ); + q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], MASA_GR_ORD_AZ - 1 - byteBuffer ); q_direction->band_data[idx_subband].azimuth_index[k] += min_idx; - q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], - q_direction->band_data[idx_subband].bits_sph_idx[k], - q_direction->band_data[idx_subband].elevation_index[k], 1, - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[idx_subband].azimuth[k] = deindex_azimuth( q_direction->band_data[idx_subband].azimuth_index[k], q_direction->band_data[idx_subband].bits_sph_idx[k], q_direction->band_data[idx_subband].elevation_index[k], 1, q_direction->cfg.mc_ls_setup ); } else { @@ -2901,8 +2870,7 @@ static int16_t decode_elevation( if ( q_direction->band_data[j].elevation_index[k] < MASA_NO_INDEX ) { q_direction->band_data[j].elevation_index[k] = same_idx; - q_direction->band_data[j].elevation[k] = deindex_elevation( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k], - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[j].elevation[k] = deindex_elevation( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k], q_direction->cfg.mc_ls_setup ); } } } @@ -2917,8 +2885,7 @@ static int16_t decode_elevation( if ( q_direction->band_data[j].elevation_index[k] < MASA_NO_INDEX ) { q_direction->band_data[j].elevation_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[j].elevation_m_alphabet[k], GR_ord_elevation ); - q_direction->band_data[j].elevation[k] = deindex_elevation( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k], - q_direction->cfg.mc_ls_setup ); + q_direction->band_data[j].elevation[k] = deindex_elevation( &q_direction->band_data[j].elevation_index[k], q_direction->band_data[j].bits_sph_idx[k], q_direction->cfg.mc_ls_setup ); } } } @@ -2986,9 +2953,7 @@ static int16_t decode_fixed_rate( q_direction->band_data[b].spherical_index[m] = value; nbits += q_direction->band_data[b].bits_sph_idx[m]; - deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], - &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], - q_direction->cfg.mc_ls_setup ); + deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->cfg.mc_ls_setup ); } return nbits; @@ -3101,6 +3066,7 @@ static void set_zero_direction( const int16_t len ) { int16_t k; + for ( k = 0; k < len; k++ ) { q_direction->band_data[idx_band].azimuth[k] = 0; @@ -3476,7 +3442,6 @@ static ivas_error read_huf( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong Huffman codeword for average index in coherence encoding." ); } #endif - *num_bits_read = end_pos; return IVAS_ERR_OK; @@ -3536,6 +3501,7 @@ static int16_t read_GR_min_removed_data( decoded_idx[j] += min_index; } } + #ifdef DEBUGGING assert( nbits == *p_bit_pos - bit_pos ); #endif @@ -3777,6 +3743,7 @@ static int16_t read_coherence_data( #ifdef NONBE_FIX_760_COHERENCE_MASA int16_t extra_cv; #endif + coding_subbands = hQMetaData->q_direction[idx_dir].cfg.nbands; #ifdef NONBE_FIX_760_COHERENCE_MASA extra_cv = (int16_t) ( coding_subbands / MASA_FACTOR_CV_COH ); diff --git a/lib_dec/ivas_qspherical_dec.c b/lib_dec/ivas_qspherical_dec.c index c56217326aac1c743585e35add5386c69977c4ba..a3dc21f0c3c12666c62a917f5f80c896c6433c42 100644 --- a/lib_dec/ivas_qspherical_dec.c +++ b/lib_dec/ivas_qspherical_dec.c @@ -40,11 +40,6 @@ #include "prot.h" -/*-----------------------------------------------------------------------* - * Local function prototypes - *-----------------------------------------------------------------------*/ - - /*-------------------------------------------------------------------* * deindex_elevation() * diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index fc191e0deb938034ac1997daa6042ab7c776f4ab..cc7b13618decb8266d035e0f5e1de6d6ad535917 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -559,7 +559,7 @@ const float ivas_split_rend_relative_one_axis_pos_angles_hq[SPLIT_REND_MAX_ONE_A const int16_t ivas_split_rend_band_grouping[MAX_SPLIT_REND_MD_BANDS + 1] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 20, 25, 30, 35, 40, 50, 60 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 20, 25, 30, 35, 40, 50, 60 }; const int32_t ivas_split_rend_huff_p_d_consts[IVAS_SPLIT_REND_D_QUANT_PNTS][3] = diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 8ff8bcc48e991010f090a115c72150ecc125031a..595c4fd6ac306e69508f844bb007ce006d5f5b69 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -212,8 +212,7 @@ ivas_error ivas_sba_dec_reconfigure( ivas_spar_md_dec_matrix_close( st_ivas->hSpar->hMdDec, num_channels ); num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - if ( ( error = ivas_spar_md_dec_matrix_open( st_ivas->hSpar->hMdDec, num_channels, - num_md_sub_frames ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_matrix_open( st_ivas->hSpar->hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK ) { return error; } @@ -289,12 +288,14 @@ ivas_error ivas_sba_dec_reconfigure( { ivas_binRenderer_close( &st_ivas->hBinRenderer ); } + #ifdef NONBE_FIX_736_FOA_BR_SWITCH if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) { return error; } #endif + #ifndef NONBE_FIX_736_FOA_BR_SWITCH if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) ) || ( last_ivas_total_brate > IVAS_256k && ivas_total_brate <= IVAS_256k ) || ( last_ivas_total_brate <= IVAS_256k && ivas_total_brate > IVAS_256k ) ) #else @@ -327,14 +328,6 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef NONBE_FIX_736_FOA_BR_SWITCH else { -#endif -#ifndef NONBE_FIX_736_FOA_BR_SWITCH - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif -#ifdef NONBE_FIX_736_FOA_BR_SWITCH int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); @@ -350,12 +343,12 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } #endif + if ( st_ivas->renderer_type == RENDERER_DISABLE ) { ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); - vbap_free_data( &( st_ivas->hVBAPdata ) ); } @@ -524,6 +517,7 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * JBM TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->Opt_5ms == 1 ) { int16_t tc_nchan_to_allocate; @@ -596,6 +590,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } + /*-------------------------------------------------------------------* * ivas_sba_dec_digest_tc() * @@ -686,7 +681,7 @@ ivas_error ivas_sba_dec_digest_tc( * *-------------------------------------------------------------------*/ -void ivas_sba_dec_render( +ivas_error ivas_sba_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ @@ -700,6 +695,7 @@ void ivas_sba_dec_render( SPAR_DEC_HANDLE hSpar; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; float *output_f_local[MAX_OUTPUT_CHANNELS]; + ivas_error error; hSpar = st_ivas->hSpar; hSpatParamRendCom = st_ivas->hSpatParamRendCom; @@ -744,9 +740,10 @@ void ivas_sba_dec_render( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC ) { - ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, - 0, - st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); + if ( ( error = ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, 0, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) + { + return error; + } } if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots ) @@ -763,5 +760,5 @@ void ivas_sba_dec_render( *nSamplesAvailableNext = ( hSpar->num_slots - hSpar->slots_rendered ) * slot_size; - return; + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 7a9b76c10bc48eb6202d6c0ca2bedc8afff276f0..a853a007289d672b06165ae98ba50b8cf47e78e9 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -180,6 +180,7 @@ static int16_t ivas_sba_dirac_stereo_band_config( return nbands; } + static float get_panning( const int16_t aziDeg, const int16_t eleDeg ) @@ -214,6 +215,7 @@ static float get_panning( return panning; } + /*-------------------------------------------------------------------* * map_params_dirac_to_stereo() * @@ -246,7 +248,6 @@ static void map_params_dirac_to_stereo( float subframe_band_nrg[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; float smooth_long_avg[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; float smooth_short_avg[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; - float *side_gain, *res_pred_gain; IVAS_QDIRECTION *q_direction; @@ -877,22 +878,18 @@ void ivas_sba_dirac_stereo_dec( } /* mapping of DirAC parameters (azimuth, elevation, diffuseness) to DFT Stereo parameters (side gain, prediction gain) */ - map_params_dirac_to_stereo( hStereoDft, st_ivas->hQMetaData, tmp_synth, DFT[0], - st_ivas->ivas_format == MC_FORMAT, + map_params_dirac_to_stereo( hStereoDft, st_ivas->hQMetaData, tmp_synth, DFT[0], st_ivas->ivas_format == MC_FORMAT, ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame, ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) ); + if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) { set_f( hStereoDft->res_pred_gain, 1.f, 3 * STEREO_DFT_BAND_MAX ); } /* DFT Stereo upmix */ - stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, - ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, - ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, - st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ) ); + stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, + st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); /* DFT synthesis */ stereo_dft_dec_synthesize( hCPE, DFT, 0, output[0], output_frame ); @@ -924,8 +921,7 @@ void ivas_sba_dirac_stereo_dec( /* upmix ACELP BWE */ ivas_sba_dirac_stereo_compute_hb_gain( hStereoDft, hb_gain ); - ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame, - ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); + ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth, hb_gain, output_frame, ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); /* add HB to ACELP core */ v_add( output[0], hb_synth_stereo[0], output[0], output_frame ); diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 169d7ac99afbce678dd9d1a685e88970b54c7269..17812eabf7b949bb91b34e55579db40586377ea2 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -76,7 +76,6 @@ void ivas_sba2mc_cldfb( int16_t nb_channels_in; push_wmops( "ivas_sba2mc_cldfb" ); - nb_channels_in = hInSetup.nchan_out_woLFE; assert( ( nb_channels_in == 16 ) && ( nb_channels_out == 11 ) && "ivas_sba2mc_cldfb; only HOA3 to CICP19 is for now supported!" ); @@ -124,7 +123,6 @@ void ivas_sba2mc_cldfb( } pop_wmops(); - return; } @@ -152,7 +150,6 @@ void ivas_mc2sba( int16_t sba_num_chans; assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); - /* Init*/ sba_num_chans = ( sba_order + 1 ) * ( sba_order + 1 ); for ( j = 0; j < sba_num_chans; j++ ) @@ -212,6 +209,7 @@ void ivas_mc2sba( return; } + #ifdef NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION /*-------------------------------------------------------------------------* * ivas_param_mc_mc2sba_cldfb() @@ -289,6 +287,7 @@ void ivas_param_mc_mc2sba_cldfb( } #endif + /*-------------------------------------------------------------------* * ivas_sba_remapTCs() * @@ -731,8 +730,7 @@ void ivas_sba_mix_matrix_determiner( /* Mixing matrix determiner */ num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; - ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, - num_md_sub_frames ); + ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, num_md_sub_frames ); return; } diff --git a/lib_dec/ivas_sns_dec.c b/lib_dec/ivas_sns_dec.c index 99fe5eb523dc1932cbe55d4cb2a3d27437e76ab8..18eb18e788590827fad1eb6f9d71d541d688b962 100644 --- a/lib_dec/ivas_sns_dec.c +++ b/lib_dec/ivas_sns_dec.c @@ -128,9 +128,9 @@ static void sns_2st_dec( void sns_avq_dec( int16_t *index, /* i : Quantization indices */ - float SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */ - const int16_t L_frame, - const int16_t numlpc /* i : Number of sets of lpc */ + float SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */ + const int16_t L_frame, /* i : frame length */ + const int16_t numlpc /* i : Number of sets of lpc */ ) { int16_t i, nbi, last; @@ -194,7 +194,6 @@ void sns_avq_dec_stereo( if ( stereo_mode == 2 ) { /* MS coding */ - sns_1st_dec( *indexl++, TCX_20_CORE, L_frame, mid_q ); sns_2st_dec( mid_q, indexl ); @@ -217,7 +216,6 @@ void sns_avq_dec_stereo( else { /* LR decoding */ - sns_1st_dec( *indexl++, TCX_20_CORE, L_frame, SNS_Ql ); sns_2st_dec( SNS_Ql, indexl ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index a0f2fd32f165fc2996f00a063f9a2a1f68fe86b4..77a45ef45bf5d5acb8ccf2efc074c4b96bdd1fae 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -52,7 +52,7 @@ * Local function prototypes *--------------------------------------------------------------------*/ -static void ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 ); +static ivas_error ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 ); /*------------------------------------------------------------------------- @@ -72,7 +72,7 @@ ivas_error ivas_spar_dec_open( IVAS_FB_CFG *fb_cfg; int16_t i, j, b, active_w_mixing; int32_t output_Fs; - int16_t num_decor_chs; + int16_t num_decor_chs, map_idx; error = IVAS_ERR_OK; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); @@ -114,9 +114,7 @@ ivas_error ivas_spar_dec_open( } /* MD handle */ - if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format, - st_ivas->last_active_ivas_total_brate /* i : IVAS last active bitrate */ - ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal, st_ivas->sid_format, st_ivas->last_active_ivas_total_brate ) ) != IVAS_ERR_OK ) { return error; } @@ -206,13 +204,10 @@ ivas_error ivas_spar_dec_open( hSpar->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; /* init render timeslot mapping */ + set_s( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); + for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) { - int16_t map_idx; - set_s( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) - { - hSpar->render_to_md_map[map_idx] = map_idx; - } + hSpar->render_to_md_map[map_idx] = map_idx; } /* allocate transport channels*/ @@ -237,6 +232,7 @@ ivas_error ivas_spar_dec_open( { nchan_to_allocate = 2 * BINAURAL_CHANNELS; } + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; @@ -314,7 +310,6 @@ ivas_error ivas_spar_dec( ivas_error error; push_wmops( "ivas_spar_decode" ); - error = IVAS_ERR_OK; hDecoderConfig = st_ivas->hDecoderConfig; @@ -346,6 +341,7 @@ ivas_error ivas_spar_dec( { last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); } + if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 ) { last_bit_pos -= SID_FORMAT_NBITS; @@ -367,7 +363,14 @@ ivas_error ivas_spar_dec( st0->total_brate = hDecoderConfig->ivas_total_brate; /* to avoid BER detect */ } - ivas_spar_dec_MD( st_ivas, st0 ); + /*---------------------------------------------------------------------* + * Decode SPAR metadata + *---------------------------------------------------------------------*/ + + if ( ( error = ivas_spar_dec_MD( st_ivas, st0 ) ) != IVAS_ERR_OK ) + { + return error; + } *nb_bits_read = st0->next_bit_pos + nb_bits_read_orig; st0->bit_stream = bit_stream_orig; @@ -408,15 +411,13 @@ static int16_t ivas_get_spar_table_idx_from_coded_idx( for ( i = 0; i < IVAS_SPAR_BR_TABLE_LEN; i++ ) { ind1[j] = 0; - if ( ( ivas_spar_br_table_consts[i].ivas_total_brate == ivas_total_brate ) && - ( ivas_spar_br_table_consts[i].sba_order == sba_order ) ) + if ( ( ivas_spar_br_table_consts[i].ivas_total_brate == ivas_total_brate ) && ( ivas_spar_br_table_consts[i].sba_order == sba_order ) ) { ind1[j++] = i; } } assert( j > 0 ); - *bitlen = ivas_get_bits_to_encode( j - 1 ); ind2 = get_next_indice( st0, *bitlen ); @@ -725,7 +726,7 @@ int16_t ivas_is_res_channel( * IVAS SPAR MD decoder *-------------------------------------------------------------------*/ -static void ivas_spar_dec_MD( +static ivas_error ivas_spar_dec_MD( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ Decoder_State *st0 /* i/o: decoder state structure - for bitstream handling*/ ) @@ -733,6 +734,7 @@ static void ivas_spar_dec_MD( int16_t num_channels, table_idx, num_bands_out, bfi, sba_order; int32_t ivas_total_brate; int16_t num_md_sub_frames; + ivas_error error; DECODER_CONFIG_HANDLE hDecoderConfig = st_ivas->hDecoderConfig; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; @@ -746,8 +748,7 @@ static void ivas_spar_dec_MD( bfi = st_ivas->bfi; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; num_channels = ivas_sba_get_nchan_metadata( sba_order, ivas_total_brate ); - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; @@ -774,7 +775,10 @@ static void ivas_spar_dec_MD( hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking; } - ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order ); + if ( ( error = ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order ) ) != IVAS_ERR_OK ) + { + return error; + } } } @@ -831,7 +835,7 @@ static void ivas_spar_dec_MD( } pop_wmops(); - return; + return IVAS_ERR_OK; } @@ -1193,8 +1197,10 @@ void ivas_spar_dec_set_render_map( hSpar->num_slots = nCldfbTs; hSpar->slots_rendered = 0; hSpar->subframes_rendered = 0; + set_s( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hSpar->subframe_nbslots, &hSpar->nb_subframes ); + st_ivas->hTcBuffer->nb_subframes = hSpar->nb_subframes; mvs2s( hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hSpar->nb_subframes ); ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, 1, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hSpar->render_to_md_map ); @@ -1219,16 +1225,9 @@ void ivas_spar_dec_set_render_params( int16_t num_bands_out; hSpar = st_ivas->hSpar; - - /*---------------------------------------------------------------------* - * Gen umx mat - *---------------------------------------------------------------------*/ - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; - ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi, - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ) ); + ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); ivas_spar_dec_set_render_map( st_ivas, n_cldfb_slots ); @@ -1461,8 +1460,7 @@ void ivas_spar_dec_upmixer_sf( num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands; numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); slot_idx_start = hSpar->slots_rendered; for ( i = 0; i < nchan_internal; i++ ) diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 9df593b1528bb435f79ddd05f89817589fc313e1..b7ede322b3fb4ddf485304d7b705e5371b5700f7 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -90,6 +90,7 @@ static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder * * Allocate and initialize SPAR MD decoder matrices *------------------------------------------------------------------------*/ + ivas_error ivas_spar_md_dec_matrix_open( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const int16_t num_channels, /* i : number of internal channels */ @@ -262,7 +263,7 @@ ivas_error ivas_spar_md_dec_matrix_open( int16_t ivas_get_spar_dec_md_num_subframes( const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int32_t ivas_last_active_brate /* i : IVAS last active bitrate */ + const int32_t ivas_last_active_brate /* i : IVAS last active bitrate */ ) { int16_t num_subframes; @@ -351,6 +352,7 @@ ivas_error ivas_spar_md_dec_open( * * Deallocate SPAR MD decoder matrices *------------------------------------------------------------------------*/ + void ivas_spar_md_dec_matrix_close( ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ const int16_t num_channels /* i : number of internal channels */ @@ -500,6 +502,7 @@ ivas_error ivas_spar_md_dec_init( int16_t i, j; int16_t nchan_transport; float pFC[IVAS_MAX_NUM_BANDS], PR_minmax[2]; + ivas_error error; ivas_sba_get_spar_hoa_md_flag( sba_order, hDecoderConfig->ivas_total_brate, &hMdDec->spar_hoa_md_flag, &hMdDec->spar_hoa_dirac2spar_md_flag ); @@ -517,7 +520,10 @@ ivas_error ivas_spar_md_dec_init( pFC[i] = ivas_fb_fcs_12band_1ms[i] * hDecoderConfig->output_Fs * 0.5f; } - ivas_spar_set_dec_config( hMdDec, nchan_transport, pFC ); + if ( ( error = ivas_spar_set_dec_config( hMdDec, nchan_transport, pFC ) ) != IVAS_ERR_OK ) + { + return error; + } if ( nchan_transport != 2 && ( ( hMdDec->spar_md_cfg.remix_unmix_order == 2 ) || ( hMdDec->spar_md_cfg.remix_unmix_order == 1 ) ) ) { @@ -629,6 +635,7 @@ static ivas_error ivas_spar_set_dec_config( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function ivas_dec_mono_sba_handling() * @@ -663,6 +670,7 @@ static void ivas_dec_mono_sba_handling( } } } + /* Combine the SPAR prediction coefs flag with the azimuth, elevation and energy ratio flag.*/ #ifdef NONBE_FIX_698_SBA_MSAN mono_flag = mono_flag && ivas_spar_chk_zero_coefs( st_ivas ); @@ -692,8 +700,11 @@ static void ivas_dec_mono_sba_handling( } } } + + return; } + /*-----------------------------------------------------------------------------------------* * Function ivas_spar_md_dec_process() * @@ -720,9 +731,7 @@ void ivas_spar_md_dec_process( num_md_chs = ivas_sba_get_nchan_metadata( sba_order, st_ivas->hDecoderConfig->ivas_total_brate ); - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ); - + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); if ( hMdDec->spar_md_cfg.nchan_transport > 1 && hMdDec->spar_md_cfg.nchan_transport <= 3 ) { @@ -762,8 +771,7 @@ void ivas_spar_md_dec_process( /* SPAR to DirAC conversion */ if ( hMdDec->spar_hoa_dirac2spar_md_flag == 1 ) { - ivas_spar_to_dirac( st_ivas, hMdDec, dtx_vad, num_bands_out, bw, - dyn_active_w_flag ); + ivas_spar_to_dirac( st_ivas, hMdDec, dtx_vad, num_bands_out, bw, dyn_active_w_flag ); } /* set correct number of bands*/ @@ -891,8 +899,7 @@ int16_t ivas_spar_chk_zero_coefs( ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[0]; #ifndef NONBE_FIX_698_SBA_MSAN - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); for ( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { #endif @@ -938,6 +945,7 @@ int16_t ivas_spar_chk_zero_coefs( #ifndef NONBE_FIX_698_SBA_MSAN } #endif + return mono; } @@ -1593,6 +1601,7 @@ static void ivas_spar_dec_parse_md_bs( } ivas_parse_parameter_bitstream_dtx( &hMdDec->spar_md, st0, *bands_bw, *nB, hMdDec->spar_md_cfg.num_dmx_chans_per_band, hMdDec->spar_md_cfg.num_decorr_per_band ); + #ifdef NONBE_FIX_723_SBA_BR_SWITCH_MSAN active_brate = ( ivas_total_brate > IVAS_SID_5k2 ) ? ivas_total_brate : last_active_brate; @@ -1842,6 +1851,7 @@ static void ivas_decode_arith_bs( } } } + ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, pred_cell_dims, PRED_COEFF ); } @@ -1874,7 +1884,6 @@ static void ivas_decode_arith_bs( ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, drct_cell_dims, DRCT_COEFF ); } - ivas_arith_decode_cmplx_cell_array( &hMdDec->arith_coeffs.drct_arith_re[qsi], &hMdDec->arith_coeffs.drct_arith_re_diff[qsi], st0, drct_cell_dims, pDo_diff, nB, symbol_arr_re, symbol_arr_old_re ); @@ -2278,6 +2287,7 @@ static void ivas_parse_parameter_bitstream_dtx( int16_t pr_q_lvls, pr, pd, pd_q_lvls, pr_pd_bits; int16_t pr_q_lvls1, pr_q_lvls2, pr_idx1, pr_idx2, pr_pr_bits; int16_t zero_pad_bits, sid_bits_len; + sid_bits_len = st0->next_bit_pos; pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; @@ -2458,6 +2468,7 @@ void ivas_spar_to_dirac( int16_t active_w_vlbr; int16_t i, num_subframes; int16_t active_w; + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; active_w = ( dyn_active_w_flag == 1 ) || ( hMdDec->spar_md_cfg.active_w == 1 ); sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); @@ -2465,7 +2476,6 @@ void ivas_spar_to_dirac( end_band = min( num_bands_out, SPAR_DIRAC_SPLIT_START_BAND ) / bw; hDirAC = st_ivas->hDirAC; - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; hSpatParamRendCom = st_ivas->hSpatParamRendCom; dirac_to_spar_md_bands = st_ivas->hSpar->dirac_to_spar_md_bands; @@ -2637,9 +2647,7 @@ void ivas_spar_to_dirac( /* DirAC MD averaged over 4 subframes and converted to SPAR format similar to encoder processing */ if ( hMdDec->spar_md_cfg.nchan_transport > 1 ) { - ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, - st_ivas->hQMetaData->useLowerRes, active_w_vlbr, - dyn_active_w_flag ); + ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr, dyn_active_w_flag ); /* temporarily copy frame-wise prediction coefficients in DirAC bands*/ for ( pred_idx = 0; pred_idx < FOA_CHANNELS - 1; pred_idx++ ) @@ -2652,11 +2660,9 @@ void ivas_spar_to_dirac( } int16_t num_md_sub_frames; - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ); - ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, num_md_sub_frames, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, - end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr, - dyn_active_w_flag ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, num_md_sub_frames, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out / bw, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL, st_ivas->hQMetaData->useLowerRes, active_w_vlbr, dyn_active_w_flag ); + if ( st_ivas->hQMetaData->useLowerRes && dtx_vad ) { for ( band = SPAR_DIRAC_SPLIT_START_BAND; band < IVAS_MAX_NUM_BANDS; band++ ) @@ -2674,6 +2680,7 @@ void ivas_spar_to_dirac( } } } + /* expand DirAC TC 20ms MD for residual channels to all subframes*/ for ( block = 0; block < num_md_sub_frames; block++ ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index ea03911edfae881deb9316454a85b29fc8840426..95154d74a16ed649ec2df0a8757a6c870b0762ad 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -553,6 +553,7 @@ typedef struct ivas_mc_paramupmix_dec_data_structure #ifdef NONBE_FIX_727_MC_PARAMUPMIX_HEADROTATION float *hoa_encoder; #endif + } MC_PARAMUPMIX_DEC_DATA, *MC_PARAMUPMIX_DEC_HANDLE; @@ -817,6 +818,7 @@ typedef struct ivas_binaural_rendering_struct } BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; #endif + /*----------------------------------------------------------------------------------* * MASA decoder structures *----------------------------------------------------------------------------------*/ @@ -886,72 +888,9 @@ typedef struct ivas_masa_ism_data_structure /*----------------------------------------------------------------------------------* - * Decoder configuration structure + * JBM structures *----------------------------------------------------------------------------------*/ -typedef struct decoder_config_structure -{ - int32_t ivas_total_brate; /* IVAS total bitrate in bps */ - int32_t last_ivas_total_brate; /* last IVAS total bitrate in bps */ - int32_t output_Fs; /* output signal sampling frequency in Hz */ - int16_t nchan_out; /* number of output audio channels */ - AUDIO_CONFIG output_config; /* output audio configuration */ - int16_t Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ - int16_t Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ - int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ - int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ - IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ - int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ - float non_diegetic_pan_gain; /* non diegetic panning gain*/ - int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - int16_t Opt_ExternalOrientation; /* indiates whether external orientations are used */ -#ifdef FIX_708_DPID_COMMAND_LINE - int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ -#endif -#ifdef FIX_708_AEID_COMMAND_LINE - int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ -#endif - - /* temp. development parameters */ -#ifdef DEBUGGING - int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ -#endif - int16_t Opt_tsm; -#ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t Opt_Limiter; -#endif - int16_t Opt_5ms; - int16_t Opt_delay_comp; /* flag indicating delay compensation active */ - -} DECODER_CONFIG, *DECODER_CONFIG_HANDLE; - -#ifdef SPLIT_REND_WITH_HEAD_ROT -typedef struct -{ - float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - -} IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE; - -typedef struct -{ - float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - AUDIO_CONFIG config; - -} IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA, *IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE; - -typedef struct -{ - IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE hMultiBinCldfbData; /*scratch buffer for frame by frame processing*/ - IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/ - SPLIT_REND_WRAPPER splitrend; - IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE hCldfbDataOut; /*buffer to store cldfb data before binauralization*/ - float *tdDataOut; /*buffer to store TD data before binauralization*/ - int16_t numTdSamplesPerChannelCached; -} IVAS_DEC_SPLIT_REND_WRAPPER; -#endif - typedef struct decoder_tc_buffer_structure { float *tc_buffer; /* the buffer itself */ @@ -995,6 +934,80 @@ typedef struct jbm_metadata_structure } JBM_METADATA, *JBM_METADATA_HANDLE; +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*----------------------------------------------------------------------------------* + * Split rendering structures + *----------------------------------------------------------------------------------*/ + +typedef struct +{ + float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + +} IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA, *IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE; + +typedef struct +{ + float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + AUDIO_CONFIG config; + +} IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA, *IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE; + +typedef struct +{ + IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE hMultiBinCldfbData; /*scratch buffer for frame by frame processing*/ + IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits; /*scratch buffer for frame by frame processing*/ + SPLIT_REND_WRAPPER splitrend; + IVAS_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE hCldfbDataOut; /*buffer to store cldfb data before binauralization*/ + float *tdDataOut; /*buffer to store TD data before binauralization*/ + int16_t numTdSamplesPerChannelCached; + +} IVAS_DEC_SPLIT_REND_WRAPPER; +#endif + + +/*----------------------------------------------------------------------------------* + * Decoder configuration structure + *----------------------------------------------------------------------------------*/ + +typedef struct decoder_config_structure +{ + int32_t ivas_total_brate; /* IVAS total bitrate in bps */ + int32_t last_ivas_total_brate; /* last IVAS total bitrate in bps */ + int32_t output_Fs; /* output signal sampling frequency in Hz */ + int16_t nchan_out; /* number of output audio channels */ + AUDIO_CONFIG output_config; /* output audio configuration */ + int16_t Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ + int16_t Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ + int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ + int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ + IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ + int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ + float non_diegetic_pan_gain; /* non diegetic panning gain*/ + int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ + int16_t Opt_ExternalOrientation; /* indiates whether external orientations are used */ +#ifdef FIX_708_DPID_COMMAND_LINE + int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ +#endif +#ifdef FIX_708_AEID_COMMAND_LINE + int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ +#endif + + /* temp. development parameters */ +#ifdef DEBUGGING + int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ +#endif + int16_t Opt_tsm; +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t Opt_Limiter; +#endif + int16_t Opt_5ms; + int16_t Opt_delay_comp; /* flag indicating delay compensation active */ + +} DECODER_CONFIG, *DECODER_CONFIG_HANDLE; + + /*----------------------------------------------------------------------------------* * * Main IVAS decoder structure @@ -1079,7 +1092,7 @@ typedef struct Decoder_Struct MONO_DOWNMIX_RENDERER_HANDLE hMonoDmxRenderer; /* Mono downmix structure */ CREND_WRAPPER_HANDLE hCrendWrapper; /* Crend handle */ REVERB_HANDLE hReverb; /* Reverb handle */ - HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ + HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */ LSSETUP_CUSTOM_HANDLE hLsSetupCustom; /* Custom LS configuration handle */ @@ -1096,7 +1109,7 @@ typedef struct Decoder_Struct int16_t flag_omasa_brate; #ifdef SPLIT_REND_WITH_HEAD_ROT - IVAS_DEC_SPLIT_REND_WRAPPER hSplitBinRend; /* split binuaral rendering handle */ + IVAS_DEC_SPLIT_REND_WRAPPER hSplitBinRend; /* split binuaral rendering handle */ #endif /* JBM module */ @@ -1106,7 +1119,7 @@ typedef struct Decoder_Struct #ifdef DEBUGGING int32_t noClipping; /* number of clipped samples */ #endif - int32_t last_active_ivas_total_brate; + int32_t last_active_ivas_total_brate; int16_t ism_extmeta_active; /* Extended metadata active in decoder */ int16_t ism_extmeta_cnt; /* Change frame counter for extended metadata */ diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 276081237bc13b7ab89d659afc6cc37bb37ab38a..5953e93ed3001161c8a0bc8650278c531cdda391 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -261,7 +261,6 @@ static void stereo_dft_generate_comfort_noise( hStereoCng->cm[b] = hStereoCng->coh[b]; } } - else if ( hStereoCng->nr_dft_frames < CM_INIT && hStereoCng->nr_sid_frames < SID_INIT ) { if ( hStereoCng->nr_corr_frames > CORR_INIT ) @@ -273,7 +272,6 @@ static void stereo_dft_generate_comfort_noise( hStereoCng->cm[b] = ( 1 - A_GFILT ) * hStereoCng->coh[b] + A_GFILT * hStereoCng->cm[b]; } } - else { hStereoCng->cm[b] = ( 1 - A_GFILT ) * hStereoCng->coh[b] + A_GFILT * hStereoCng->cm[b]; @@ -578,6 +576,7 @@ static void stereo_dft_generate_comfort_noise( ptr_level++; } } + /* Compute noise level */ lp_noise = 0.0f; ptr_level = hFdCngCom->cngNoiseLevel; @@ -677,8 +676,7 @@ void stereo_dtf_cng( for ( n = 0; n < CPE_CHANNELS; n++ ) { - stereo_dft_generate_comfort_noise( hCPE->hStereoDft, hCPE->hStereoCng, hCPE->last_element_mode, sts[0], DFT, sts[1], - hCPE->hStereoTCA->targetGain, n, output_frame ); + stereo_dft_generate_comfort_noise( hCPE->hStereoDft, hCPE->hStereoCng, hCPE->last_element_mode, sts[0], DFT, sts[1], hCPE->hStereoTCA->targetGain, n, output_frame ); } } } @@ -733,6 +731,7 @@ void stereo_cng_dec_update( } hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->active_frame_counter = hCPE->hStereoCng->active_frame_counter; + return; } diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 24a9c7347b083cfaec6ab168a17d0a6fc6669c1a..5c515aeb2a7a6d7e54c6f5ad86d60765420ed664 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -294,8 +294,7 @@ ivas_error stereo_dft_dec_create( stereo_dft_config( hStereoDft_loc->hConfig, element_brate, &tmpS, &tmpS ); } - stereo_dft_dec_open( hStereoDft_loc, output_Fs, - nchan_transport ); + stereo_dft_dec_open( hStereoDft_loc, output_Fs, nchan_transport ); *hStereoDft = hStereoDft_loc; @@ -366,7 +365,6 @@ static void stereo_dft_dec_open( hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->band_res[0], hStereoDft->NFFT, DEC ); hStereoDft->hb_stefi_delay = NS2SA( output_Fs, STEREO_DFT_TD_STEFI_DELAY_NS ); - if ( nchan_transport > 2 ) { hStereoDft->min_smooth_gains = min_smooth_gains2; @@ -405,10 +403,6 @@ void stereo_dft_dec_reset( set_s( hStereoDft->side_gain_index, 15, STEREO_DFT_BAND_MAX ); set_s( hStereoDft->side_gain_index_previous, 15, STEREO_DFT_BAND_MAX ); - /*IPD*/ - - /*ITD*/ - /*residual prediction*/ set_s( hStereoDft->res_pred_mode, hStereoDft->hConfig->res_pred_mode, STEREO_DFT_DEC_DFT_NB ); for ( i = 0; i < STEREO_DFT_PAST_MAX; i++ ) @@ -421,7 +415,6 @@ void stereo_dft_dec_reset( set_s( hStereoDft->res_pred_index_previous, 0, STEREO_DFT_BAND_MAX ); - for ( i = 0; i < STEREO_DFT_BAND_MAX; i++ ) { hStereoDft->res_gains_ind[0][i] = 15.f; @@ -446,6 +439,7 @@ void stereo_dft_dec_reset( hStereoDft->bpf_error_signal_last = 0.0f; hStereoDft->bpf_error_ratio_mem = 1.0f; hStereoDft->res_hb_nrg_mem = 0.0f; + /*reset parameters*/ set_zero( hStereoDft->side_gain, STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX ); set_zero( hStereoDft->gipd, STEREO_DFT_DEC_DFT_NB ); @@ -518,7 +512,6 @@ void stereo_dft_dec_reset( hStereoDft->g_L_prev = 0.f; hStereoDft->g_R_prev = 0.f; - return; } @@ -1162,7 +1155,6 @@ void stereo_dft_dec( HANDLE_FD_CNG_DEC hFdCngDec = st0->hFdCngDec; HANDLE_FD_CNG_COM hFdCngCom = hFdCngDec->hFdCngCom; int16_t *cna_seed = &( hFdCngCom->seed ); - float DFT_W, DFT_Y; output_frame = (int16_t) ( st0->output_Fs / FRAMES_PER_SEC ); @@ -1206,11 +1198,7 @@ void stereo_dft_dec( /* Smoothing for the current frame */ if ( sba_dirac_stereo_flag ) { - ivas_sba_dirac_stereo_smooth_parameters( hStereoDft, - hMdDec, - cross_fade_start_offset, - output_Fs, - num_md_sub_frames ); + ivas_sba_dirac_stereo_smooth_parameters( hStereoDft, hMdDec, cross_fade_start_offset, output_Fs, num_md_sub_frames ); } else { @@ -1304,7 +1292,6 @@ void stereo_dft_dec( } } - #ifdef DEBUGGING if ( dbgflag( "write_res" ) ) { @@ -1316,7 +1303,6 @@ void stereo_dft_dec( dbgread( pDFT_RES, sizeof( float ), 2 * hStereoDft->band_limits[hStereoDft->res_cod_band_max], "dec_res.float" ); } #endif - /* Apply active DMX */ /* pDFT_RES is used for the second channel in inactive frames */ if ( hStereoDft->frame_sid_nodata && !sba_dirac_stereo_flag ) @@ -1357,7 +1343,6 @@ void stereo_dft_dec( dbgwrite( &g, sizeof( float ), 1, 1, "./res/stereo_dft_dec_g.pcm" ); } #endif - /* No residual coding in inactive frames, instead pDFT_RES is used for the second channel */ if ( b >= hStereoDft->res_cod_band_max && !hStereoDft->frame_sid_nodata && !( sba_dirac_stereo_flag && hMdDec ) ) { @@ -1396,6 +1381,7 @@ void stereo_dft_dec( DFT_L[2 * i + 1] = ( 1 + g ) * pDFT_DMX[2 * i + 1] + gamma * pDFT_RES[2 * i + 1]; DFT_R[2 * i + 1] = ( 1 - g ) * pDFT_DMX[2 * i + 1] - gamma * pDFT_RES[2 * i + 1]; } + if ( pgIpd[0] != 0.f ) { c0 = cosf( pgIpd[0] ); @@ -1537,11 +1523,8 @@ void stereo_dft_dec( } else { - - for ( i = hStereoDft->band_limits[b]; i < min( stop, hStereoDft->band_limits[b + 1] ); i++ ) { - tmp = g * pDFT_DMX[2 * i] + pDFT_RES[2 * i] + DFT_PRED_RES[2 * i]; DFT_L[2 * i] = pDFT_DMX[2 * i] + tmp; @@ -1810,7 +1793,6 @@ void stereo_dft_dec_res( } } #endif - mvr2r( win, output, L_FRAME8k ); #ifdef DEBUG_MODE_DFT @@ -1824,7 +1806,6 @@ void stereo_dft_dec_res( dbgwrite( tmp, sizeof( int16_t ), L_FRAME8k, 1, "./res/stereo_dft_dec_res_decoded.pcm" ); } #endif - if ( hCPE->hCoreCoder[0]->core == ACELP_CORE ) { /* bass post-filter */ @@ -1931,7 +1912,6 @@ void stereo_dft_dec_read_BS( assert( *nb_bits <= 800 ); #endif - /*------------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -2469,6 +2449,7 @@ void stereo_dft_dec_read_BS( return; } + /*------------------------------------------------------------------------- * stereo_dft_compute_td_stefi_params() * @@ -2927,7 +2908,6 @@ void stereo_dft_generate_res_pred( } pop_wmops(); - return; } diff --git a/lib_dec/ivas_stereo_dft_dec_dmx.c b/lib_dec/ivas_stereo_dft_dec_dmx.c index 561f9d016b1c6a69173f92b13500eaa75024a5af..e9bb3bc49a0b62f9fd71004b6c3a2fe33c4f5d05 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx.c @@ -57,10 +57,8 @@ void stereo_dft_dmx_out_reset( STEREO_DFT_DMX_DATA_HANDLE hStereoDftDmx /* i/o: DFT stereo DMX decoder */ ) { - { - hStereoDftDmx->targetGain = 1.0f; - hStereoDftDmx->prevTargetGain = 1.0f; - } + hStereoDftDmx->targetGain = 1.0f; + hStereoDftDmx->prevTargetGain = 1.0f; set_zero( hStereoDftDmx->memOutHB, NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) ); set_zero( hStereoDftDmx->memTransitionHB, NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) ); @@ -124,7 +122,6 @@ void stereo_dft_unify_dmx( dmx_nrg = stereo_dft_dmx_swb_nrg( DFT[0], DFT[0] + STEREO_DFT32MS_N_MAX, min( hStereoDft->NFFT, STEREO_DFT32MS_N_32k ) ); } - /* Analyze nature of current frame */ hStereoDft->trans = ( ( ( st0->clas_dec == ONSET ) || ( st0->clas_dec == SIN_ONSET ) || ( st0->clas_dec == UNVOICED_CLAS ) || ( st0->clas_dec == UNVOICED_TRANSITION ) ) || ( st0->stab_fac <= 0.25f ) ) || ( st0->core == TCX_20_CORE && ( ( st0->hTcxCfg->tcx_last_overlap_mode == MIN_OVERLAP ) || ( st0->hTcxCfg->tcx_last_overlap_mode == HALF_OVERLAP ) ) ) || ( st0->core == TCX_10_CORE ); @@ -243,6 +240,7 @@ void stereo_dft_unify_dmx( return; } + /*-------------------------------------------------------------------* * add_HB_to_mono_dmx() * diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c index 1da2cc3682cb173fb92df5d611495ddc7204600a..aad34a87515f5410acb2d2e6b539cf187c2a8d0e 100644 --- a/lib_dec/ivas_stereo_icbwe_dec.c +++ b/lib_dec/ivas_stereo_icbwe_dec.c @@ -68,10 +68,10 @@ static void ic_bwe_dec_reset( set_f( hStereoICBWE->memShb_fsout_nonref, 0, INTERP_3_2_MEM_LEN ); hStereoICBWE->syn_dm_phase_nonref = 0; - return; } + /*-------------------------------------------------------------------* * stereo_icBWE_dec() * diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 2d2a40d21fbaacbe896e57c517ed57db117e897d..0610447a6f73cc8993f6818fa4c7e6375179b50d 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -270,13 +270,12 @@ void stereo_decoder_tcx( } } } - else +#ifdef DEBUGGING + else if ( mdct_stereo_mode[k] != SMDCT_DUAL_MONO ) { - if ( mdct_stereo_mode[k] != SMDCT_DUAL_MONO ) - { - assert( !"Not supported MDCT stereo mode!\n" ); - } + assert( !"Not supported MDCT stereo mode!\n" ); } +#endif if ( igf ) { @@ -308,10 +307,12 @@ void stereo_decoder_tcx( } } } +#ifdef DEBUGGING else if ( hStereoMdct->IGFStereoMode[k] != SMDCT_DUAL_MONO ) { assert( !"Not supported MDCT stereo mode!\n" ); } +#endif } if ( !mct_on ) diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 62ca749f405a258745496e5dcb629a30b8e30395..d91fdf4b568797ed0d8090ccd01752dd9fa0d662 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -44,6 +44,12 @@ #include "wmc_auto.h" #include +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ + +#define DFT2TD_CORR_THRESH 0.9f + /*-------------------------------------------------------------------* * Function allocate_CoreCoder_TCX() @@ -421,8 +427,7 @@ ivas_error stereo_memory_dec( deallocate_CoreCoder( hCPE->hCoreCoder[1] ); /* allocate DFT stereo data structure */ - if ( ( error = stereo_dft_dec_create( &( hCPE->hStereoDft ), hCPE->element_brate, output_Fs, 0, - nchan_transport ) ) != IVAS_ERR_OK ) + if ( ( error = stereo_dft_dec_create( &( hCPE->hStereoDft ), hCPE->element_brate, output_Fs, 0, nchan_transport ) ) != IVAS_ERR_OK ) { return error; } @@ -1180,8 +1185,12 @@ void synchro_synthesis( /*----------------------------------------------------------------* * TD/MDCT stereo synchro *----------------------------------------------------------------*/ + if ( sba_dirac_stereo_flag ) + { return; + } + if ( hCPE->element_mode == IVAS_CPE_TD || hCPE->element_mode == IVAS_CPE_MDCT ) { /* handling of DFT->TD switching */ @@ -1783,8 +1792,6 @@ static float ncross_corr_self( * switching from DFT stereo to TD stereo *-------------------------------------------------------------------*/ -#define DFT2TD_CORR_THRESH 0.9f - void smooth_dft2td_transition( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ float *output[CPE_CHANNELS], /* i/o: synthesis @external Fs */ diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index 630129c474b4b37678ae4c69e1476959085dc70f..41018cae2542af3ed3962c5c59e3d61fdcb0ddfd 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -77,6 +77,7 @@ void stereo_td_init_dec( return; } + /*-------------------------------------------------------------------* * tdm_configure_dec() * @@ -272,9 +273,7 @@ void tdm_configure_dec( * bitbudget distribution between channels (taking into account also metadata bitbudget) *----------------------------------------------------------------*/ - tdm_bit_alloc( ivas_format, - ism_mode, - hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, + tdm_bit_alloc( ivas_format, ism_mode, hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), &hStereoTD->tdm_low_rate_mode, sts[1]->coder_type, *tdm_ratio_idx, hStereoTD->tdm_Pitch_reuse_flag, sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, tdm_inst_ratio_idx ); @@ -400,6 +399,7 @@ static void tdm_upmix_fade( return; } + /*-------------------------------------------------------------------* * stereo_tdm_combine() * diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index 37af3fb124aec05cc875c2bba60cab432d22b9fc..d2c72d62af9b79ad98175fc462c67bab7dc24a96 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -46,12 +46,14 @@ /*-----------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------*/ + /* The SVD is sensitive to changes to the following constants, so please be careful when trying to tune things */ #define SVD_MINIMUM_VALUE 1e-32f /* minimum value */ #define CONVERGENCE_FACTOR 1.19209290e-07f /* factor for SVD convergence */ #define SVD_MAX_NUM_ITERATION 75 /* maximum number of interations before exiting the SVD */ #define SVD_ZERO_FLUSH_THRESHOLD 1.0e-20f + /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_vbap.c b/lib_dec/ivas_vbap.c index 4098c62763774822c1162b0718e8f6d056520eaf..52e92ed7e3726b50eac18e8718a84369e5d022a0 100644 --- a/lib_dec/ivas_vbap.c +++ b/lib_dec/ivas_vbap.c @@ -156,9 +156,8 @@ ivas_error vbap_init_data( VBAP_HANDLE *hVBAPdata, /* i/o: handle for VBAP data structure that will be initialized */ const float *speaker_node_azi_deg, /* i : vector of speaker node azimuths (positive left) */ const float *speaker_node_ele_deg, /* i : vector of speaker node elevations (positive up) */ - const int16_t num_speaker_nodes /* i : number of speaker nodes in the set */ - , - const IVAS_FORMAT ivas_format /* i : IVAS format */ + const int16_t num_speaker_nodes, /* i : number of speaker nodes in the set */ + const IVAS_FORMAT ivas_format /* i : IVAS format */ ) { /* Variables */ @@ -467,12 +466,11 @@ void vbap_free_data( *-------------------------------------------------------------------------*/ void vbap_determine_gains( - const VBAP_HANDLE hVBAPdata, /* i : prepared VBAP structure */ - float *gains, /* o : gain vector for loudspeakers for given direction */ - const int16_t azi_deg, /* i : azimuth in degrees for panning direction (positive left)*/ - const int16_t ele_deg /* i : elevation in degrees for panning direction (positive up)*/ - , - const int16_t use_object_mode /* i : select between object mode panning and spatial mode panning */ + const VBAP_HANDLE hVBAPdata, /* i : prepared VBAP structure */ + float *gains, /* o : gain vector for loudspeakers for given direction */ + const int16_t azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ + const int16_t ele_deg, /* i : elevation in degrees for panning direction (positive up) */ + const int16_t use_object_mode /* i : select between object mode panning and spatial mode panning */ ) { /* This function formulates gains for the given angle. The triplet-selection has been pre-formulated. */ @@ -765,9 +763,8 @@ static void determine_virtual_speaker_node_division_gains( int16_t connections[][2], /* i : vector of all connections */ const enum VirtualSpeakerNodeType type, /* i : virtual speaker node typel */ const int16_t max_num_connections, /* i : max number of connections */ - const int16_t num_speaker_nodes /* i : max number of speaker nodes */ - , - const int16_t use_object_mode /* i : use VBAP in object panning mode vs. spatial panning mode */ + const int16_t num_speaker_nodes, /* i : max number of speaker nodes */ + const int16_t use_object_mode /* i : use VBAP in object panning mode vs. spatial panning mode */ ) { /* When node type is VIRTUAL_SPEAKER_NODE_DISTRIBUTE_ENERGY, the gains of the virtual node diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 2fe0879db189eff9a5e6d1075f5c9ecfb12fadf0..d44592c1c8c819c159218c372da660d903b8516b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -106,7 +106,7 @@ static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); static int16_t IVAS_DEC_VoIP_GetRenderGranularity( Decoder_Struct *st_ivas ); static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ); static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferGranularity, uint8_t *nTransportChannels, uint8_t *nOutChannels, uint16_t *nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const IVAS_DEC_PCM_TYPE pcmType, void *data #else @@ -116,7 +116,7 @@ static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferG static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, int16_t *nOutSamples ); static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *pcmBuf ); static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf #else @@ -125,11 +125,13 @@ static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const u #endif ); static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, int16_t *nSamplesBuffered ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT 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, int32_t offset ); +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, int16_t nZeroSamples ); #endif + + /*---------------------------------------------------------------------* * IVAS_DEC_Open() * @@ -473,7 +475,8 @@ ivas_error IVAS_DEC_Configure( return error; } -#if defined( SPLIT_REND_WITH_HEAD_ROT ) + +#ifdef SPLIT_REND_WITH_HEAD_ROT /*---------------------------------------------------------------------* * IVAS_DEC_EnableSplitRendering( ) * @@ -481,7 +484,7 @@ ivas_error IVAS_DEC_Configure( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_EnableSplitRendering( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ) { DECODER_CONFIG_HANDLE hDecoderConfig; @@ -708,7 +711,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( static ivas_error _GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, void *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #else @@ -738,7 +741,7 @@ static ivas_error _GetSamples( #endif if ( ( error = evs_dec_main( st_ivas, *nOutSamples, NULL, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT (int16_t *) #endif pcmBuf ) ) != IVAS_ERR_OK ) @@ -750,8 +753,7 @@ static ivas_error _GetSamples( { /* run the main IVAS decoding routine */ if ( ( error = ivas_dec( st_ivas, - -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_resolution, #endif pcmBuf ) ) != IVAS_ERR_OK ) @@ -769,10 +771,12 @@ static ivas_error _GetSamples( return error; } + + ivas_error IVAS_DEC_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked, /* i: number of samples wanted by the caller */ -#if defined SPLIT_REND_WITH_HEAD_ROT + const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ +#ifdef SPLIT_REND_WITH_HEAD_ROT const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ void *pcmBuf, /* o : output synthesis signal */ #else @@ -832,7 +836,7 @@ ivas_error IVAS_DEC_GetSamples( { /* setup */ if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) #else @@ -843,14 +847,15 @@ ivas_error IVAS_DEC_GetSamples( { return error; } -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT /* :TODO: change nSamplesAsked also if we are in 5ms 0dof split rendering... */ #endif } + if ( !hIvasDec->st_ivas->hDecoderConfig->Opt_5ms ) { if ( ( error = _GetSamples( hIvasDec, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_type_API_to_internal( pcmType ), #endif pcmBuf, nOutSamples ) ) != IVAS_ERR_OK ) @@ -874,10 +879,15 @@ ivas_error IVAS_DEC_GetSamples( { int16_t nResidualSamples, nSamplesTcsScaled; nSamplesRendered += nSamplesRendered_loop; + if ( nTransportChannels != hIvasDec->nTransportChannelsOld ) { - IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ); + if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) + { + return error; + } } + /* decode TCs only */ if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { @@ -904,8 +914,6 @@ ivas_error IVAS_DEC_GetSamples( nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; /* render IVAS frames */ - - if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; @@ -921,10 +929,11 @@ ivas_error IVAS_DEC_GetSamples( } hIvasDec->hasBeenFedFrame = false; } + /* render IVAS frames directly to the output buffer */ nSamplesToRender = nSamplesAsked - nSamplesRendered; if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) #else @@ -954,13 +963,20 @@ ivas_error IVAS_DEC_GetSamples( return error; } -#if defined SPLIT_REND_WITH_HEAD_ROT + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * IVAS_DEC_GetSplitBinauralBitstream( ) + * + * + *---------------------------------------------------------------------*/ + ivas_error IVAS_DEC_GetSplitBinauralBitstream( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ - IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits, /* o : bitstream output for split rendering mode*/ - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* indication that the decoder needs a new frame */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ + IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits, /* o : bitstream output for split rendering mode */ + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { Decoder_Struct *st_ivas; @@ -978,7 +994,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_error error; IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend; int16_t max_band; - int16_t pcm_out; + int16_t pcm_out_flag; int16_t td_input; int16_t numPoses; @@ -990,11 +1006,15 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( *needNewFrame = FALSE; hSplitBinRend = &st_ivas->hSplitBinRend; - ivas_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, hSplitRendBits ); + + if ( ( error = ivas_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, hSplitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; - if ( st_ivas->hDecoderConfig->Opt_5ms && - hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && + 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 ) ) { @@ -1004,8 +1024,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( if ( hSplitBinRend->tdDataOut == NULL ) { /* Allocate enough space to save all decoded samples that will not be split encoded directly after decoding */ - hSplitBinRend->tdDataOut = malloc( numSamplesPerChannelCacheSize * BINAURAL_CHANNELS * numPoses * sizeof( float ) ); - if ( hSplitBinRend->tdDataOut == NULL ) + if ( ( hSplitBinRend->tdDataOut = malloc( numSamplesPerChannelCacheSize * BINAURAL_CHANNELS * numPoses * sizeof( float ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } @@ -1025,14 +1044,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( if ( numSamplesPerChannelToDecode == numSamplesPerChannelToSplitEncode || hSplitBinRend->numTdSamplesPerChannelCached == 0 ) { /* Decode and render */ - error = IVAS_DEC_GetSamples( - hIvasDec, - numSamplesPerChannelToDecode, - IVAS_DEC_PCM_FLOAT, - pcmBuf, - nOutSamples, - needNewFrame ); - if ( error != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { return error; } @@ -1082,54 +1094,46 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( { pOutput[i] = output[i]; } + max_band = (int16_t) ( ( BINAURAL_MAXBANDS * output_Fs ) / 48000 ); - pcm_out = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; + pcm_out_flag = ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; td_input = st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC; - error = ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend, - st_ivas->hHeadTrackData->Quaternions[0], - st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, - st_ivas->hRenderConfig->split_rend_config.codec, - st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, - hSplitBinRend->hSplitRendBits, - hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural, - hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural, - max_band, - pOutput, - - 1, - td_input, - pcm_out ); - if ( error != IVAS_ERR_OK ) + if ( ( error = ivas_renderMultiBinToSplitBinaural( &hSplitBinRend->splitrend, + st_ivas->hHeadTrackData->Quaternions[0], + st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, + st_ivas->hRenderConfig->split_rend_config.codec, + st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, + hSplitBinRend->hSplitRendBits, + hSplitBinRend->hMultiBinCldfbData->Cldfb_RealBuffer_Binaural, + hSplitBinRend->hMultiBinCldfbData->Cldfb_ImagBuffer_Binaural, + max_band, + pOutput, + 1, + !td_input, + pcm_out_flag ) ) != IVAS_ERR_OK ) { return error; } /* convert to int16 with limiting for BINAURAL_SPLIT_PCM */ - if ( pcm_out ) + if ( pcm_out_flag ) { if ( st_ivas->hDecoderConfig->Opt_5ms ) { #ifndef DISABLE_LIMITER - ivas_limiter_dec( st_ivas->hLimiter, pOutput, - st_ivas->hDecoderConfig->nchan_out, - numSamplesPerChannelToSplitEncode, st_ivas->BER_detect ); + ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToSplitEncode, st_ivas->BER_detect ); #endif } else { - ivas_limiter_dec( st_ivas->hLimiter, pOutput, - st_ivas->hDecoderConfig->nchan_out, - numSamplesPerChannelToSplitEncode, st_ivas->BER_detect ); + ivas_limiter_dec( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToSplitEncode, st_ivas->BER_detect ); } - #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output( pOutput, numSamplesPerChannelToSplitEncode, - st_ivas->hDecoderConfig->nchan_out, - (int16_t *) pcmBuf_out ); + ivas_syn_output( pOutput, numSamplesPerChannelToSplitEncode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); } free( st_ivas->hSplitBinRend.hMultiBinCldfbData ); @@ -1151,7 +1155,7 @@ static ivas_error IVAS_DEC_Setup( uint8_t *nTransportChannels, /* o : number of decoded transport PCM channels */ uint8_t *nOutChannels, /* o : number of decoded out channels (PCM or CLDFB) */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ void *data /* o : output synthesis signal */ #else @@ -1195,7 +1199,7 @@ static ivas_error IVAS_DEC_Setup( if ( st_ivas->bfi == 0 ) { if ( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_type_API_to_internal( pcmType ), #endif data ) ) != IVAS_ERR_OK ) @@ -1311,7 +1315,7 @@ static ivas_error IVAS_DEC_GetRenderedSamples( const uint16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renerer pipeline */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf #else @@ -1333,7 +1337,7 @@ static ivas_error IVAS_DEC_GetRenderedSamples( /* run the main IVAS decoding routine */ if ( ( error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcm_type_API_to_internal( pcmType ), #endif pcmBuf ) ) != IVAS_ERR_OK ) @@ -1556,7 +1560,7 @@ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ IVAS_VECTOR3 Pos, /* i : listener position */ - const int16_t subframe_idx /*subframe index*/ + const int16_t subframe_idx /* i : subframe index */ #ifdef SPLIT_REND_WITH_HEAD_ROT , const IVAS_SPLIT_REND_ROT_AXIS rot_axis @@ -1667,7 +1671,7 @@ ivas_error IVAS_DEC_FeedExternalOrientationData( int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const int16_t subframe_idx /*i : subframe index*/ + const int16_t subframe_idx /* i : subframe index */ ) { EXTERNAL_ORIENTATION_HANDLE hExternalOrientationData; @@ -2268,7 +2272,7 @@ ivas_error IVAS_DEC_VoIP_SetScale( ivas_error IVAS_DEC_VoIP_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf, #else @@ -2280,7 +2284,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( JbmTraceFileWriterFn jbmWriterFn, void *jbmWriter #endif - ) { Decoder_Struct *st_ivas; @@ -2414,7 +2417,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* codec mode to use not known yet - simply output silence */ /* directly set output zero */ int16_t nSamplesToZero = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT set_pcm_buffer_to_zero( pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), pcmType, nSamplesToZero * nOutChannels ); #else set_s( pcmBuf + nSamplesRendered * nOutChannels, 0, nSamplesToZero * nOutChannels ); @@ -2431,7 +2434,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* render IVAS frames directly to the output buffer */ if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), #else @@ -2441,12 +2444,15 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { return error; } + nSamplesRendered += nSamplesRendered_loop; } } + return error; } + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_Flush( ) * @@ -2456,7 +2462,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( ivas_error IVAS_DEC_Flush( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf, #else @@ -2469,14 +2475,13 @@ ivas_error IVAS_DEC_Flush( uint16_t nSamplesToRender; uint16_t nSamplesFlushedLocal; - error = IVAS_ERR_OK; - *nSamplesFlushed = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); nSamplesToRender = (uint16_t) *nSamplesFlushed; + /* render IVAS frames */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT pcmType, #endif pcmBuf ) ) != IVAS_ERR_OK ) @@ -2484,7 +2489,7 @@ ivas_error IVAS_DEC_Flush( return error; } - return error; + return IVAS_ERR_OK; } @@ -3083,10 +3088,7 @@ static ivas_error evs_dec_main( v_multc( output[0], mixer_left, output[0], nOutSamples ); } - - if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hDecoderConfig->Opt_5ms - - ) + if ( !st_ivas->hDecoderConfig->Opt_tsm && st_ivas->hDecoderConfig->Opt_5ms ) { ivas_jbm_dec_copy_tc_no_tsm( st_ivas, p_output, nOutSamples ); } @@ -3115,7 +3117,6 @@ static ivas_error evs_dec_main( #ifdef DEBUGGING - /*---------------------------------------------------------------------* * IVAS_DEC_GetBer_detect_flag() * @@ -3523,8 +3524,18 @@ ivas_error IVAS_DEC_GetCldfbSamples( } #endif -#if defined SPLIT_REND_WITH_HEAD_ROT -void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, int32_t offset ) + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * pcm_buffer_offset() + * + * + *---------------------------------------------------------------------*/ + +static void *pcm_buffer_offset( + void *buffer, + const IVAS_DEC_PCM_TYPE pcmType, + const int32_t offset ) { switch ( pcmType ) { diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 70a04226f2f04f115ee53ce745809e0fe4b76105..22d39c9ed644c90e97dd6efa4784fe0be2e988e1 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -74,7 +74,7 @@ typedef enum _IVAS_DEC_FORCED_REND_MODE } IVAS_DEC_FORCED_REND_MODE; #endif -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT typedef enum _IVAS_DEC_PCM_TYPE { IVAS_DEC_PCM_INT16, @@ -126,7 +126,7 @@ ivas_error IVAS_DEC_Configure( const IVAS_AUDIO_CONFIG outputConfig, /* i : audio 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 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 */ @@ -160,29 +160,27 @@ ivas_error IVAS_DEC_FeedFrame_Serial( /*! r: decoder error code */ ivas_error IVAS_DEC_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked, /* i: number of samples wanted by the caller */ -#if defined SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf, /* o : output synthesis signal */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else - int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ + int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* indication that the decoder needs a new frame */ + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error IVAS_DEC_GetSplitBinauralBitstream( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ - IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits, /* o : bitstream output for split rendering mode */ - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* indication that the decoder needs a new frame */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + void *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ + IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits, /* o : bitstream output for split rendering mode */ + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ); -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT /*! r: decoder error code */ ivas_error IVAS_DEC_GetSplitRendBits( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ @@ -209,20 +207,20 @@ ivas_error IVAS_DEC_GetObjectMetadata( /*! r: error code */ ivas_error IVAS_DEC_GetMasaMetadata( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ - uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ + uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ ); /*! r: error code */ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ - IVAS_VECTOR3 Pos, /* i : listener position */ - const int16_t subframe_idx /*subframe index*/ + IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ + IVAS_VECTOR3 Pos, /* i : listener position */ + const int16_t subframe_idx /* i : subframe index */ #ifdef SPLIT_REND_WITH_HEAD_ROT , - IVAS_SPLIT_REND_ROT_AXIS rot_axis /*i : external control for rotation axis for split rendering */ + IVAS_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ #endif ); @@ -241,12 +239,12 @@ ivas_error IVAS_DEC_FeedRefVectorData( /*! r: error code */ ivas_error IVAS_DEC_FeedExternalOrientationData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION orientation, /* i : external orientation data */ - int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ - int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ - int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ - int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const int16_t subframe_idx /*i : subframe index*/ + IVAS_QUATERNION orientation, /* i : external orientation data */ + int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ + int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ + int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ + int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const int16_t subframe_idx /* i : subframe index */ ); /*! r: error code */ @@ -270,11 +268,11 @@ ivas_error IVAS_DEC_VoIP_SetScale( ivas_error IVAS_DEC_VoIP_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf, #else - int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ + int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif const uint32_t systemTimestamp_ms /* i : current system timestamp */ #ifdef SUPPORT_JBM_TRACEFILE @@ -286,11 +284,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( ivas_error IVAS_DEC_Flush( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT const IVAS_DEC_PCM_TYPE pcmType, void *pcmBuf, #else - int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ + int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ #endif int16_t *nSamplesFlushed /* o : number of samples flushed */ ); @@ -305,18 +303,17 @@ ivas_error IVAS_DEC_EnableVoIP( ); #ifdef SPLIT_REND_WITH_HEAD_ROT - /*! r: error code */ ivas_error IVAS_DEC_EnableSplitRendering( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ); #endif + ivas_error IVAS_DEC_Get5msFlag( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *enable5ms /* o : 5ms flag */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *enable5ms /* o : 5ms flag */ ); - #ifdef DEBUGGING bool IVAS_DEC_GetBerDetectFlag( IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ @@ -380,8 +377,8 @@ ivas_error IVAS_DEC_GetHrtfHandle( /*! r: error code */ ivas_error IVAS_DEC_GetHrtfCRendHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF /* o : Set of HRTF handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF /* o : Set of HRTF handle */ ); ivas_error IVAS_DEC_GetHrtfFastConvHandle( @@ -403,7 +400,7 @@ ivas_error IVAS_DEC_GetRenderConfig( /*! r: error code*/ ivas_error IVAS_DEC_GetDefaultRenderConfig( - IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ + IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ ); /*! r: error code*/ diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index c971cf0e21f1d08f3f3c0ca19c4d774e6f4ffc0f..1201d9a30470bf9f5c1a68a60b47692256b1e3e5 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1064,7 +1064,6 @@ typedef struct Decoder_State AMRWB_IO_DEC_HANDLE hAmrwb_IO; - /*----------------------------------------------------------------------------------* * SC-VBR parameters *----------------------------------------------------------------------------------*/ @@ -1159,7 +1158,6 @@ typedef struct Decoder_State FD_BWE_DEC_HANDLE hBWE_FD; - /*----------------------------------------------------------------------------------* * LD music post-filter *----------------------------------------------------------------------------------*/ @@ -1177,7 +1175,6 @@ typedef struct Decoder_State TCX_DEC_HANDLE hTcxDec; - /*----------------------------------------------------------------------------------* * Mode 2 *----------------------------------------------------------------------------------*/ @@ -1336,7 +1333,7 @@ typedef struct Decoder_State TEC_DEC_HANDLE hTECDec; /*----------------------------------------------------------------------------------* - * Stereo/IVAS parameters + * IVAS parameters *----------------------------------------------------------------------------------*/ int16_t tdm_LRTD_flag; /* LRTD stereo mode flag */ diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index 34f250742f21f5b6d5fefda0aa778610cea67022..606c8aaaf98b43a1c02e08ffd97254f3f5bc7b4d 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -255,8 +255,7 @@ void dtx( /* reset the bitstream (IVAS format signaling was already written) */ if ( st->element_mode != IVAS_CPE_MDCT && st->hBstr != NULL ) { - reset_indices_enc( st->hBstr, - st->hBstr->nb_ind_tot ); + reset_indices_enc( st->hBstr, st->hBstr->nb_ind_tot ); } } diff --git a/lib_enc/enc_ppp.c b/lib_enc/enc_ppp.c index 25e5124eed80fb82ddae4eb96437256b5db96c3a..b5b7e45483e8b28f3f3570055cc187b40dcf99e4 100644 --- a/lib_enc/enc_ppp.c +++ b/lib_enc/enc_ppp.c @@ -169,9 +169,7 @@ ivas_error encod_ppp( } /* delete previous indices */ - reset_indices_enc( hBstr, - hBstr->nb_ind_tot ); - + reset_indices_enc( hBstr, hBstr->nb_ind_tot ); /* signaling matrix (writing of signaling bits) */ signaling_enc( st ); diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index eb35d9629b7cf46250322748a8476cfca7ca5034..407121d59dbd77cdc6efc706cc95bb27ca568b02 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -923,11 +923,9 @@ void stereoFdCngCoherence( else if ( sts[0]->core_brate <= SID_2k40 && sts[1]->core_brate <= SID_2k40 ) { /* case: no VAD for both channels -> INACTIVE FRAME */ - reset_indices_enc( sts[0]->hBstr, - sts[0]->hBstr->nb_ind_tot ); + reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); - reset_indices_enc( sts[1]->hBstr, - sts[1]->hBstr->nb_ind_tot ); + reset_indices_enc( sts[1]->hBstr, sts[1]->hBstr->nb_ind_tot ); /* synchronize SID sending for variable SID rate */ if ( sts[0]->core_brate != sts[1]->core_brate ) diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index c7b8ab3190c17c165afb04a90d12b0847911d13d..c40c7aa59b69ce9f354cd0568c6ea84b9011387f 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -55,7 +55,7 @@ ivas_error init_encoder( Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ const int16_t idchan, /* i : channel ID */ const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ const int16_t interval_SID, /* i : interval for SID update */ @@ -63,7 +63,7 @@ ivas_error init_encoder( const ISM_MODE ism_mode /* i : ISM mode */ #ifdef IGF_MEMORY_ALLOC_OPT , - const int32_t element_brate + const int32_t element_brate /* i : element bitrate */ #endif ) { @@ -873,6 +873,7 @@ ivas_error init_encoder( /*-----------------------------------------------------------------* * Transient detector *-----------------------------------------------------------------*/ + if ( ( st->hTranDet = (TRAN_DET_HANDLE) malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index d6424bf9597fb78a37cf7f12783927f6050e4009..c80e463ebaca4e4d32814eb255761514a7322881 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -96,6 +96,7 @@ ivas_error ivas_corecoder_enc_reconfig( /*-----------------------------------------------------------------* * Switching between SCE(s)/CPE(s)/MCT *-----------------------------------------------------------------*/ + #ifdef NONBE_FIX_752_OSBA_MISCONFIG_MCT if ( nchan_transport_real == nchan_transport_old_real && st_ivas->nSCE == nSCE_old && st_ivas->nCPE == nCPE_old ) /* in McMASA, nchan_transport may be the same, but nSCE/nCPE differs */ #else @@ -294,15 +295,10 @@ ivas_error ivas_corecoder_enc_reconfig( mvr2r( input_buff[sce_id], st_ivas->hSCE[sce_id]->hCoreCoder[0]->input_buff, len_inp_memory ); } - /* only reset indices if it is not the first index list, this already contains the IVAS format bits */ if ( sce_id > 0 || hEncoderConfig->ivas_format == MASA_ISM_FORMAT ) { - reset_indices_enc( st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr, - st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->nb_ind_tot ); - } - else - { + reset_indices_enc( st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr, st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->nb_ind_tot ); } } } @@ -325,11 +321,7 @@ ivas_error ivas_corecoder_enc_reconfig( ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->nSCE > 0 ) || ( hEncoderConfig->ivas_format == MASA_ISM_FORMAT && st_ivas->nSCE > 0 ) ) { - reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); - } - else - { + reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); } } } @@ -360,11 +352,7 @@ ivas_error ivas_corecoder_enc_reconfig( /* only reset indices if it is not the first index list, this already contains the IVAS format bits */ if ( cpe_id * CPE_CHANNELS + n > 0 || ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->nSCE > 0 ) ) { - reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); - } - else - { + reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_ind_tot ); } if ( hEncoderConfig->Opt_DTX_ON ) @@ -449,13 +437,7 @@ ivas_error ivas_corecoder_enc_reconfig( st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); #ifdef IGF_MEMORY_ALLOC_OPT - if ( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, - st_ivas->hCPE[0]->hCoreCoder[n]->igf, - 1, - st_ivas->hCPE[0]->element_brate, - st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, - st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, - st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) + if ( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) { return error; } @@ -535,13 +517,7 @@ ivas_error ivas_corecoder_enc_reconfig( st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); #ifdef IGF_MEMORY_ALLOC_OPT - if ( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, - st_ivas->hCPE[0]->hCoreCoder[n]->igf, - 1, - st_ivas->hCPE[0]->element_brate, - st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, - st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, - st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) + if ( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index e3362d816af3f9c8c014f4c14d41b9d91718ec99..18a609ccd69a5fae9289255316d43c64ef4f8a39 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -279,10 +279,8 @@ ivas_error ivas_cpe_enc( } - if ( hCPE->element_mode != IVAS_CPE_MDCT && ( hCPE->element_brate != hCPE->last_element_brate || hCPE->last_element_mode != hCPE->element_mode || - sts[0]->ini_frame == 0 || - ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) || - sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ + if ( hCPE->element_mode != IVAS_CPE_MDCT && ( hCPE->element_brate != hCPE->last_element_brate || hCPE->last_element_mode != hCPE->element_mode || sts[0]->ini_frame == 0 || + ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ { if ( st_ivas->hQMetaData != NULL ) { @@ -575,10 +573,7 @@ ivas_error ivas_cpe_enc( { tdm_ol_pitch_comparison( hCPE, pitch_fr, voicing_fr ); - tdm_configure_enc( - ivas_format, - st_ivas->ism_mode, - hCPE, Etot_last, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata ); + tdm_configure_enc( ivas_format, st_ivas->ism_mode, hCPE, Etot_last, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata ); if ( hEncoderConfig->Opt_DTX_ON ) { @@ -916,11 +911,10 @@ ivas_error create_cpe_enc( st->total_brate = hCPE->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; - if ( ( error = init_encoder( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, #ifdef IGF_MEMORY_ALLOC_OPT - ISM_MODE_NONE, hCPE->element_brate ) ) != IVAS_ERR_OK ) + if ( ( error = init_encoder( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, ISM_MODE_NONE, hCPE->element_brate ) ) != IVAS_ERR_OK ) #else - ISM_MODE_NONE ) ) != IVAS_ERR_OK ) + if ( ( error = init_encoder( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, ISM_MODE_NONE ) ) != IVAS_ERR_OK ) #endif { return error; diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index bc9968dcb52a4b0b44fb9792d3d93067a0d5d899..e4447a15566ee50b975f24500b1b7daa708efe39 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -346,8 +346,7 @@ void ivas_decision_matrix_enc( } } - if ( st->element_mode >= IVAS_CPE_DFT && st->core == ACELP_CORE && ( st->extl == SWB_TBE || st->extl == FB_TBE ) && - !( st->element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag ) ) + if ( st->element_mode >= IVAS_CPE_DFT && st->core == ACELP_CORE && ( st->extl == SWB_TBE || st->extl == FB_TBE ) && !( st->element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag ) ) { icbwe_brate += STEREO_ICBWE_MSFLAG_BITS * FRAMES_PER_SEC; } @@ -413,7 +412,6 @@ void ivas_signaling_enc( push_indice( hBstr, IND_SMODE, ind, NBITS_ELEMENT_MODE ); } - /*-------------------------------------------------------------------------- * Write band-width info *--------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index a82f5beea460ecbf7d26ee870bed9d94ec16ee85..dc34471640f4cc32654967e1523a55687a1b18bf 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -163,6 +163,7 @@ ivas_error ivas_dirac_enc_open( st_ivas->hDirAC = hDirAC; st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; + return error; } @@ -280,7 +281,7 @@ void ivas_dirac_enc_close( * *------------------------------------------------------------------------*/ -void ivas_dirac_enc( +ivas_error ivas_dirac_enc( DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ @@ -290,12 +291,14 @@ void ivas_dirac_enc( const int16_t input_frame, /* i : input frame length */ const int16_t dtx_vad, /* i : DTX vad flag */ const IVAS_FORMAT ivas_format, /* i : ivas format */ - int16_t hodirac_flag ) /* i : hodirac flag */ + const int16_t hodirac_flag /* i : hodirac flag */ +) { int16_t orig_dirac_bands; float dir[3], avg_dir[3]; float energySum, vecLen; int16_t i, j, b, i_ts; + ivas_error error; push_wmops( "ivas_dirac_enc" ); ivas_dirac_param_est_enc( hDirAC, hQMetaData->q_direction, hQMetaData->useLowerRes, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, ivas_format, hodirac_flag, hodirac_flag ? HOA2_CHANNELS : FOA_CHANNELS, &( hDirAC->mono_frame_count ), &( hQMetaData->dirac_mono_flag ) ); @@ -323,7 +326,10 @@ void ivas_dirac_enc( } } - ivas_qmetadata_enc_encode( hMetaData, hQMetaData, hodirac_flag ); + if ( ( error = ivas_qmetadata_enc_encode( hMetaData, hQMetaData, hodirac_flag ) ) != IVAS_ERR_OK ) + { + return error; + } } else { @@ -398,7 +404,7 @@ void ivas_dirac_enc( } pop_wmops(); - return; + return IVAS_ERR_OK; } @@ -409,11 +415,11 @@ void ivas_dirac_enc( *-------------------------------------------------------------------------*/ static int16_t ivas_dirac_get_mono_flag( - const int16_t *band_grouping, /* i : Band grouping for estimation */ - float Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */ - float Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */ - const int16_t nchan_ana, /* i : number of analysis channels */ - int16_t *mono_frame_count ) /* i/o : current number of mono frames count */ + const int16_t *band_grouping, /* i : Band grouping for estimation */ + float Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */ + float Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */ + const int16_t nchan_ana, /* i : number of analysis channels */ + int16_t *mono_frame_count ) /* i/o: current number of mono frames count */ { int16_t brange[2]; int16_t i, j, ch_idx; @@ -473,6 +479,7 @@ static int16_t ivas_dirac_get_mono_flag( } } } + /* If any band contains multi-channel content it's not mono */ if ( any_mc_band ) { @@ -486,6 +493,7 @@ static int16_t ivas_dirac_get_mono_flag( local_mono_flag = 1; } } + /* Hysteresis - only after DIRAC_MONO_FRAME_THRESH frames on mono will the actual mono flag be set */ if ( local_mono_flag ) { @@ -787,9 +795,7 @@ void ivas_dirac_param_est_enc( } if ( !hodirac_flag ) - { - for ( band_m_idx = 0; band_m_idx < hDirAC->hConfig->nbands; band_m_idx++ ) { renormalization_factor[band_m_idx] = EPSILON; diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index dfe8106a04d5da1caf496d7ae1d0126c34acd1d9..1dabf0b1dc6e6210697faf2319f52c8d7272517a 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -244,7 +244,7 @@ ivas_error ivas_enc( /* SBA/MASA metadata encoding and SBA/MASA metadata bitstream writing */ hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - if ( st_ivas->hQMetaData != NULL && ivas_format != SBA_FORMAT ) + if ( st_ivas->hQMetaData != NULL && ivas_format == MASA_FORMAT ) { ivas_masa_estimate_energy( st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport ); /* energy-estimation uses TF-resolution: 4x24 */ @@ -252,8 +252,8 @@ ivas_error ivas_enc( { return error; } - if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, - ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, + + if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) { return error; @@ -395,14 +395,13 @@ ivas_error ivas_enc( #ifndef NONBE_CR_FIX_735_SBA_HP20_BRATE_SWITCHING ivas_osba_enc_reconfig( st_ivas ); #endif + /* Analyze objects and determine needed audio signals */ - ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, - hEncoderConfig->input_Fs #ifdef FIX_732_PLANAR_SBA_OSBA - , - hEncoderConfig->sba_planar + ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, hEncoderConfig->input_Fs, hEncoderConfig->sba_planar ); +#else + ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, hEncoderConfig->input_Fs ); #endif - ); if ( st_ivas->ism_mode == ISM_MODE_NONE ) { @@ -479,7 +478,6 @@ ivas_error ivas_enc( } else { - n = hEncoderConfig->nchan_ism; #ifndef FIX_759_CODE_COVERAGE_OSBA st = st_ivas->hCPE[0]->hCoreCoder[0]; @@ -640,9 +638,7 @@ ivas_error ivas_enc( ivas_mcmasa_enc( st_ivas->hMcMasa, st_ivas->hQMetaData, st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport, nchan_inp ); if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1, - ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 - - ) ) != IVAS_ERR_OK ) + ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 3ecb96c31fabdaf1f66254c81bf049a2c138a699..0eb88dcc1684ac09aac11dcdee19479829275477 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -115,6 +115,7 @@ ivas_error ivas_spar_covar_enc_open( return error; } + /*------------------------------------------------------------------------- * ivas_spar_covar_enc_close() * @@ -295,9 +296,7 @@ void ivas_enc_cov_handler_process( pFb->fb_bin_to_band.pp_short_stride_bin_to_band, pFb->fb_bin_to_band.p_short_stride_start_bin_per_band, pFb->fb_bin_to_band.p_short_stride_num_bins_per_band, - start_band, end_band, - cov_real, - HOA_md_ind ); + start_band, end_band, cov_real, HOA_md_ind ); if ( is_sba ) { @@ -413,7 +412,6 @@ static void ivas_band_cov( { for ( j = i; j < num_chans; j++ ) { - int16_t i1 = HOA_md_ind[i]; int16_t j1 = HOA_md_ind[j]; diff --git a/lib_enc/ivas_entropy_coder.c b/lib_enc/ivas_entropy_coder.c index 741338fbf206a540a913b657ef666aa0ff63b4e6..0157711bdd92a8269f9be3c99503220938c935af 100644 --- a/lib_enc/ivas_entropy_coder.c +++ b/lib_enc/ivas_entropy_coder.c @@ -208,6 +208,7 @@ static int16_t ivas_arithCoder_encode_array_diff( return -1; } } + return 0; } diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 9f9acdbaf2ca3b1c565fffe387e14d830286b2ca..52c3b8cd45c474b9a11bfaf6107b8a3d20717616 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -53,8 +53,8 @@ *-----------------------------------------------------------------------------------------*/ ivas_error front_vad( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */ - Encoder_State *st, /* i/o: encoder state structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */ + Encoder_State *st, /* i/o: encoder state structure */ const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: FrontVad handles */ const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ @@ -82,7 +82,6 @@ ivas_error front_vad( ivas_error error; error = IVAS_ERR_OK; - push_wmops( "front_vad" ); if ( hCPE != NULL ) @@ -301,7 +300,6 @@ ivas_error front_vad_create( set_f( hFrontVad->delay_buf, 0, hFrontVad->delay_samples ); } - *hFrontVad_out = hFrontVad; return IVAS_ERR_OK; @@ -388,9 +386,7 @@ ivas_error front_vad_spar( ivas_error error; push_wmops( "front_vad_SPAR" ); - error = IVAS_ERR_OK; - hFrontVad = hSpar->hFrontVad; st = hSpar->hCoreCoderVAD; @@ -493,6 +489,5 @@ ivas_error front_vad_spar( } pop_wmops(); - return error; } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 4a870d5977fee90a1d6e8b9a7c7d47da0f23292f..ac6f81cea54bf6683a1eb209b6842d2ef1b9ba7e 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -235,6 +235,7 @@ int16_t getNumChanAnalysis( { n = st_ivas->hEncoderConfig->nchan_ism + ( st_ivas->sba_analysis_order + 1 ) * ( st_ivas->sba_analysis_order + 1 ); } + return n; } @@ -373,6 +374,7 @@ ivas_error ivas_init_encoder( int16_t sce_id, cpe_id; IVAS_FORMAT ivas_format; int32_t input_Fs, ivas_total_brate; + int32_t element_brate_tmp[MAX_NUM_OBJECTS]; ENCODER_CONFIG_HANDLE hEncoderConfig; ivas_error error; @@ -484,7 +486,6 @@ ivas_error ivas_init_encoder( return error; } - /* prepare stereo downmix for EVS */ if ( hEncoderConfig->stereo_dmx_evs == 1 ) { @@ -508,8 +509,6 @@ ivas_error ivas_init_encoder( } else if ( ivas_format == ISM_FORMAT ) { - int32_t element_brate_tmp[MAX_NUM_OBJECTS]; - st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate ); if ( ( error = ivas_ism_metadata_enc_create( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK ) @@ -594,7 +593,6 @@ ivas_error ivas_init_encoder( for ( n = 0; n < CPE_CHANNELS; n++ ) { - if ( hEncoderConfig->Opt_DTX_ON ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1; @@ -612,7 +610,6 @@ ivas_error ivas_init_encoder( } else if ( ivas_format == MASA_ISM_FORMAT ) { - int32_t element_brate_tmp[MAX_NUM_OBJECTS]; int32_t ism_total_brate; int16_t k; @@ -673,7 +670,6 @@ ivas_error ivas_init_encoder( } else if ( ivas_format == SBA_ISM_FORMAT ) { - int32_t element_brate_tmp[MAX_NUM_OBJECTS]; st_ivas->ism_mode = ISM_MODE_NONE; if ( ivas_total_brate >= IVAS_256k ) @@ -706,12 +702,10 @@ ivas_error ivas_init_encoder( if ( st_ivas->ism_mode == ISM_MODE_NONE ) { - sce_id = 0; /* allocate and initialize SBA core-coders */ if ( st_ivas->nchan_transport == 1 ) { - - if ( ( error = create_sce_enc( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK ) + if ( ( error = create_sce_enc( st_ivas, 0, ivas_total_brate ) ) != IVAS_ERR_OK ) { return error; } @@ -736,7 +730,6 @@ ivas_error ivas_init_encoder( else { /* allocate and initialize MCT core coder */ - st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index c502bedf6cd299161e7fe9c45fb9729ec8263f07..1277d0d887fccdf689c89162c3f9469db876ee68 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -167,9 +167,7 @@ int16_t ivas_ism_dtx_enc( if ( dtx_flag ) { /* reset the bitstream (IVAS format signaling was already written) */ - reset_indices_enc( hSCE[0]->hCoreCoder[0]->hBstr, - - hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot ); + reset_indices_enc( hSCE[0]->hCoreCoder[0]->hBstr, hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot ); } /*------------------------------------------------------------------* diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index e143c51ce9deeca86aac0aa2c25dcc402e9a7026..259153e89b284abc8dfcd317816f7d362e07aab6 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -325,6 +325,7 @@ ivas_error ivas_ism_enc( /*----------------------------------------------------------------* * Core codec configuration *----------------------------------------------------------------*/ + #ifdef IGF_MEMORY_ALLOC_OPT /* IGF reconfiguration */ if ( hSCE->last_element_brate != hSCE->element_brate || st->last_bwidth != st->bwidth ) @@ -481,8 +482,7 @@ ivas_error ivas_ism_enc_config( st_ivas->nSCE = st_ivas->nchan_transport; st_ivas->nCPE = 0; - if ( ( error = ivas_ism_config( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, - 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_config( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index a98e42739bf00eed07871c03530d7104de3b14ea..c44491cc2f65546908d503fc0c78c157018c4b7d 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -137,8 +137,7 @@ ivas_error ivas_masa_enc_open( } } - ivas_masa_set_elements( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, - hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate ); + ivas_masa_set_elements( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate ); mvs2s( DirAC_block_grouping, hMasa->config.block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); mvs2s( MASA_band_grouping_24, hMasa->config.band_grouping, MASA_FREQUENCY_BANDS + 1 ); @@ -253,6 +252,7 @@ ivas_error ivas_masa_encode( int16_t masa_sid_descriptor; int16_t low_bitrate_mode; int32_t masa_total_brate; + ivas_error error; masa_sid_descriptor = -1; h_orig_metadata = NULL; @@ -475,8 +475,7 @@ ivas_error ivas_masa_encode( if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { /* encode MASA/ISM energy ratios */ - ivas_encode_masaism_metadata( hMasa, hQMetaData, hMetaData, hIsmMetaData, nchan_ism, low_bitrate_mode, hOMasa->nCodingBands, hOMasa->nSubframes, - idx_separated_object, ism_imp ); + ivas_encode_masaism_metadata( hMasa, hQMetaData, hMetaData, hIsmMetaData, nchan_ism, low_bitrate_mode, hOMasa->nCodingBands, hOMasa->nSubframes, idx_separated_object, ism_imp ); } else { @@ -497,16 +496,25 @@ ivas_error ivas_masa_encode( { if ( masa_total_brate >= IVAS_512k ) { - ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 16, 4 ); + if ( ( error = ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 16, 4 ) ) != IVAS_ERR_OK ) + { + return error; + } } else { - ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 11, 3 ); + if ( ( error = ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 11, 3 ) ) != IVAS_ERR_OK ) + { + return error; + } } } else { - ivas_qmetadata_enc_encode( hMetaData, hQMetaData, 0 ); + if ( ( error = ivas_qmetadata_enc_encode( hMetaData, hQMetaData, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } } if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) @@ -691,8 +699,8 @@ ivas_error ivas_masa_enc_config( } } - ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, - ivas_format, st_ivas->ism_mode, ism_total_brate ); + ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE, ivas_format, st_ivas->ism_mode, ism_total_brate ); + hQMetaData->is_masa_ivas_format = 1; if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) @@ -856,7 +864,6 @@ ivas_error ivas_masa_enc_config( set_c( (int8_t *) hMasa->data.twoDirBands, 1, hMasa->config.numCodingBands ); } - /* Transmit stereo signals using a mono downmix at lowest bitrates */ if ( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && st_ivas->nCPE == 1 && st_ivas->hCPE[0]->hStereoDft != NULL && st_ivas->hCPE[0]->hStereoDft->hConfig != NULL ) { @@ -974,6 +981,7 @@ static void combine_freqbands_and_subframes( } } } + if ( numCodingBands <= MAX_REDUCED_NBANDS ) { /* reduce metadata *frequency* resolution. time resolution is not touched */ @@ -1109,6 +1117,13 @@ static void combine_freqbands_and_subframes( return; } + +/*-------------------------------------------------------------------* + * ivas_masa_combine_directions() + * + * + *-------------------------------------------------------------------*/ + void ivas_masa_combine_directions( MASA_ENCODER_HANDLE hMasa ) { @@ -1467,10 +1482,7 @@ static void detect_metadata_composition( /* Check surround coherence separately if we do not have already knowledge of coherence */ if ( cohPresent == FALSE ) { - cohPresent = ivas_masa_surrcoh_signicant( hMeta->common_meta.surround_coherence, - hMeta->common_meta.diffuse_to_total_ratio, - nSubFrames, - MASA_FREQUENCY_BANDS ); + cohPresent = ivas_masa_surrcoh_signicant( hMeta->common_meta.surround_coherence, hMeta->common_meta.diffuse_to_total_ratio, nSubFrames, MASA_FREQUENCY_BANDS ); } /* Set output flags */ @@ -1982,8 +1994,7 @@ void ivas_masa_enc_reconfigure( } } - ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, - st_ivas->hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate ); + ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &tmp, &tmp, &tmp, st_ivas->hEncoderConfig->ivas_format, st_ivas->ism_mode, ism_total_brate ); } return; @@ -2617,8 +2628,10 @@ void ivas_merge_masa_metadata( { energyTimesRatioMASA[1] = 0.0f; } + /* target is original MASA diffuseness */ total_diff_nrg = eneBand * hMeta->common_meta.diffuse_to_total_ratio[sf][band]; + /* criterion is mean of ISM ratio and new ratio */ energyTimesRatioISM = ( hOMasaMeta->directional_meta[0].energy_ratio[sf][band] + ( 1.0f - total_diff_nrg / ( EPSILON + eneBand + hMasa->data.hOmasaData->energy_ism[sf][band] ) ) ) / 2.0f * hMasa->data.hOmasaData->energy_ism[sf][band]; @@ -3605,7 +3618,9 @@ static void ivas_encode_masaism_metadata( } } } + calculate_nbits_meta( nchan_ism, hOmasaData->q_energy_ratio_ism, hOmasaData->masa_to_total_energy_ratio, numSf, numCodingBands, bits_ism, idx_separated_object, ism_imp ); + /* quantize directions */ for ( obj = 0; obj < nchan_ism; obj++ ) { diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c old mode 100755 new mode 100644 index 46c2382e428b7f5464807c98aec13e8c739d1a43..d340362e3ff8902b470c28f0aa7e9c0106c0847b --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -216,6 +216,7 @@ ivas_error ivas_mct_enc( } } } + /* reconfiguration in case of bitrate switching */ if ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) { @@ -266,6 +267,7 @@ ivas_error ivas_mct_enc( { hCPE->hCoreCoder[0]->hBstr->ind_list = st_ivas->hCPE[cpe_id - 1]->hCoreCoder[1]->hBstr->ind_list + st_ivas->hCPE[cpe_id - 1]->hCoreCoder[1]->hBstr->nb_ind_tot; } + ivas_mdct_quant_coder( hCPE, hMCT->tnsBits[cpe_id], hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], 1 ); /* update input samples buffer (as done in ivas_cpe_enc() for other than MCT coding) */ @@ -348,13 +350,13 @@ ivas_error create_mct_enc( } cp_bitrate = ivas_total_brate / hMCT->nchan_out_woLFE * CPE_CHANNELS; - #ifdef NONBE_FIX_752_OSBA_MISCONFIG_MCT if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { cp_bitrate = ivas_total_brate / st_ivas->nchan_transport * CPE_CHANNELS; } #endif + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { for ( n = 0; n < CPE_CHANNELS; n++ ) @@ -744,6 +746,7 @@ static ivas_error ivas_mc_enc_reconfig( ivas_param_mc_enc_close( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs ); ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs ); + /* De-allocate McMasa-related handles */ ivas_mcmasa_enc_close( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs ); @@ -822,7 +825,9 @@ static ivas_error ivas_mc_enc_reconfig( ivas_masa_enc_close( &( st_ivas->hMasa ) ); st_ivas->hMasa = NULL; } + ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs ); + if ( last_mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hLFE != NULL ) { /* LFE handle */ @@ -874,7 +879,9 @@ static ivas_error ivas_mc_enc_reconfig( } ivas_param_mc_enc_close( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs ); + ivas_mc_paramupmix_enc_close( &( st_ivas->hMCParamUpmix ), st_ivas->hEncoderConfig->input_Fs ); + if ( last_mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hLFE != NULL ) { /* LFE handle */ @@ -942,9 +949,11 @@ static ivas_error ivas_mc_enc_reconfig( } st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode ); + /* set last core to TCX20 */ st->last_core = TCX_20_CORE; } + if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { ivas_mcmasa_split_brate( st_ivas->hMcMasa->separateChannelEnabled, st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); diff --git a/lib_enc/ivas_mct_enc_mct.c b/lib_enc/ivas_mct_enc_mct.c index 842007dd939be096ab6e2bc8c30b5ecd9ded5a3f..c5df49bf02686f1b3b6d51814f2be8c3b8ed6e59 100755 --- a/lib_enc/ivas_mct_enc_mct.c +++ b/lib_enc/ivas_mct_enc_mct.c @@ -39,6 +39,11 @@ #include "wmc_auto.h" #include + +/*--------------------------------------------------------------* + * Local constants + *---------------------------------------------------------------*/ + #define SPAR_CORR_THRES 0.9f #define DEFAULT_CORR_THRES 0.3f @@ -224,11 +229,9 @@ static void getBestCorrelation( *_ch2 = -1; *max_corr = 0.f; - for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE ); - ch1++ ) + for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE ); ch1++ ) { - for ( ch2 = ch1 + 1; ch2 < ( hMCT->nchan_out_woLFE ); - ch2++ ) + for ( ch2 = ch1 + 1; ch2 < ( hMCT->nchan_out_woLFE ); ch2++ ) { if ( fabsf( *max_corr ) < fabsf( xCorrMatrix[ch1][ch2] ) ) { @@ -309,11 +312,9 @@ static void updateCorrelationMatrix( int16_t ch1, ch2, n; /* correlation: */ - for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE ); - ch1++ ) + for ( ch1 = 0; ch1 < ( hMCT->nchan_out_woLFE ); ch1++ ) { - for ( ch2 = ch1; ch2 < ( hMCT->nchan_out_woLFE ); - ch2++ ) + for ( ch2 = ch1; ch2 < ( hMCT->nchan_out_woLFE ); ch2++ ) { if ( sts[ch1]->core == sts[ch2]->core && sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) @@ -766,8 +767,7 @@ void write_mct_bitstream( /* first write core info and overlap mode for all channels */ for ( ch = 0; ch < nchan; ch++ ) { - if ( - hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { push_next_indice( hBstr, hMCT->mc_global_ild[ch], SMDCT_GLOBAL_ILD_BITS ); } @@ -777,8 +777,7 @@ void write_mct_bitstream( { for ( ch = 0; ch < nchan; ch++ ) { - if ( - sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { push_next_indice( hBstr, hMCT->lowE_ch[ch], 1 ); } @@ -898,8 +897,7 @@ void mctStereoIGF_enc( /* channel elements that are coded separately detected */ if ( sum_s( singleChEle, ( hMCT->nchan_out_woLFE ) ) != 0 ) { - for ( ch = 0; ch < ( hMCT->nchan_out_woLFE ); - ch++ ) + for ( ch = 0; ch < ( hMCT->nchan_out_woLFE ); ch++ ) { if ( singleChEle[ch] ) { diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index 5f232d8168d6d6a646ae8765e395d034e9e40405..a566f5a83af3284e41a75431200e000625620eec 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -90,7 +90,10 @@ ivas_error ivas_omasa_enc_open( hOMasa->num_Cldfb_instances = numAnalysisChannels; for ( i = 0; i < hOMasa->num_Cldfb_instances; i++ ) { - openCldfb( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, st_ivas->hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS ); + if ( ( error = openCldfb( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, st_ivas->hEncoderConfig->input_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } } /* intensity 3-dim */ @@ -665,10 +668,10 @@ void ivas_set_ism_importance_interformat( *--------------------------------------------------------------------------*/ void ivas_set_surplus_brate_enc( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ #ifdef DEBUG_MODE_INFO , - const int16_t *nb_bits_metadata /* i : number of metadata bits */ + const int16_t *nb_bits_metadata /* i : number of metadata bits */ #endif ) { diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 6c7553ffffeecfc2a754832888373979e0df61b2..521d8e70cad3e6898f38d2f55bc0b95ce5b3f57a 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -280,8 +280,9 @@ ivas_error ivas_osba_enc_reconfig( old_mem_hp20_in = NULL; } } - ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), - &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + + ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + hSpar = st_ivas->hSpar; if ( st_ivas->nchan_transport == 1 ) @@ -334,6 +335,7 @@ ivas_error ivas_osba_enc_reconfig( /*-----------------------------------------------------------------* * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ + if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { #ifndef NONBE_FIX_752_OSBA_MISCONFIG_MCT @@ -388,11 +390,11 @@ void ivas_osba_enc( const int16_t input_frame, /* i : Input frame size */ const int16_t nchan_ism, /* i : Number of objects for parameter analysis */ const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ - const int32_t input_Fs /* i : input sampling rate*/ + const int16_t sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ + const int32_t input_Fs /* i : input sampling rate */ #ifdef FIX_732_PLANAR_SBA_OSBA , - const int16_t sba_planar /* i : planar SBA flag*/ + const int16_t sba_planar /* i : planar SBA flag */ #endif ) { diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index 9969669b93c56e34cfb2d9558d50179a8c374ff0..cd1d50775a8bd70879e5b2054301f577a71ed3af 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -63,9 +63,7 @@ static int16_t ivas_qmetadata_entropy_encode_dir( BSTR_ENC_HANDLE hMetaData, IVA static int16_t ivas_qmetadata_raw_encode_dir( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, const int16_t nbands, const int16_t start_band ); -int16_t -ivas_qmetadata_encode_extended_gr_length( const uint16_t value, const uint16_t alphabet_size, const int16_t gr_param ); - +int16_t ivas_qmetadata_encode_extended_gr_length( const uint16_t value, const uint16_t alphabet_size, const int16_t gr_param ); static int16_t ivas_qmetadata_get_optimal_gr_param( uint16_t *unsigned_data, const int16_t count, const int16_t gr_param_count, int16_t *opt_gr_size ); @@ -467,8 +465,7 @@ ivas_error ivas_qmetadata_enc_encode( /* Encode quantized directions with EC band-wise */ if ( ( total_bits_1dir + bits_surround_coh <= hQMetaData->qmetadata_max_bit_req ) && ( bits_dir[d] + bits_diff[d] + bits_coherence[d] + bits_signaling[d] > total_bits_1dir ) && q_direction->cfg.nblocks > 1 ) { - restore_metadata_buffer( hMetaData, next_ind_start, - bit_pos_start ); + restore_metadata_buffer( hMetaData, next_ind_start, bit_pos_start ); /* Write signaling */ push_next_indice( hMetaData, 1, 1 ); /*Write 1 bit to signal no EC frame-wise (EC1)*/ @@ -545,8 +542,7 @@ ivas_error ivas_qmetadata_enc_encode( /*Bit budget exceeded, bit reduction strategy?*/ extra_bits = 0; - restore_metadata_buffer( hMetaData, next_ind_start, - bit_pos_start ); + restore_metadata_buffer( hMetaData, next_ind_start, bit_pos_start ); push_next_indice( hMetaData, 1, 1 ); /*Write 1 bit to signal no EC frame-wise (EC1)*/ if ( nblocks > 1 ) @@ -985,7 +981,6 @@ void ivas_qmetadata_enc_sid_encode( } else { - metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; } @@ -2630,6 +2625,7 @@ static int16_t ivas_qmetadata_entropy_encode_dir( } avg_elevation_index = squant( abs_theta, &avg_elevation, theta_cb, no_th ); + if ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) { assert( avg_elevation >= 0 ); @@ -2646,7 +2642,9 @@ static int16_t ivas_qmetadata_entropy_encode_dir( } avg_elevation *= sign_th; } + avg_azimuth_index = (uint16_t) ( quantize_phi( avg_azimuth + 180, 0, &avg_azimuth, avg_azimuth_alphabet ) ); + /* Elevation only if not 2D */ if ( q_direction->not_in_2D > 0 ) { @@ -2818,6 +2816,7 @@ static int16_t ivas_qmetadata_entropy_encode_dir( { all_zero_dist_azimuth_indexes = 0; } + if ( ( idx >= MASA_LIMIT_IDX_AVG_AZI ) && ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) && ( use_adapt_avg == 1 ) ) { if ( idx % nblocks == 0 ) @@ -4772,7 +4771,6 @@ static int16_t encode_spread_coherence_1sf( GR_ord = 1; idx_shift = 0; - /* number of codevectors added dependent on number of subbands */ extra_cv = coding_subbands / MASA_FACTOR_CV_COH; for ( j = 0; j < coding_subbands; j++ ) @@ -5331,7 +5329,6 @@ static int16_t encode_surround_coherence_hr( } } - return nbits; } diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 318bc90ddd2a454a209c2862ff84a3e4a2d7e6c9..011cb3aded124d3657eb8ea437c6da79060329bc 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -198,8 +198,9 @@ ivas_error ivas_sba_enc_reconfigure( old_mem_hp20_in = NULL; } } - ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), - &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + + ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); + hSpar = st_ivas->hSpar; if ( st_ivas->nchan_transport == 1 ) diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index e297d747a8397eebcd1067ba263a8d2c62aa880a..8567693244da9fec85017a01bbcc1230b637d781 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -371,12 +371,11 @@ ivas_error create_sce_enc( st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; - if ( ( error = init_encoder( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode #ifdef IGF_MEMORY_ALLOC_OPT - , - hSCE->element_brate + if ( ( error = init_encoder( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode, hSCE->element_brate ) ) != IVAS_ERR_OK ) +#else + if ( ( error = init_encoder( st, st_ivas, 0, st_ivas->hEncoderConfig->var_SID_rate_flag, st_ivas->hEncoderConfig->interval_SID, 0, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 5bf18e1ea7eefab8ba9146bbe6fe959b61b178f6..f39e70dfeaa08ec25ead2ec4323113fdcc756bb6 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -185,8 +185,7 @@ ivas_error ivas_spar_enc_open( * Configuration - set SPAR high-level parameters *-----------------------------------------------------------------*/ - ivas_spar_config( hEncoderConfig->ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), - &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 ); + ivas_spar_config( hEncoderConfig->ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 ); if ( st_ivas->nchan_transport == 1 ) { @@ -224,12 +223,11 @@ ivas_error ivas_spar_enc_open( hSpar->hCoreCoderVAD->total_brate = hEncoderConfig->ivas_total_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ hSpar->hCoreCoderVAD->mct_chan_mode = MCT_CHAN_MODE_IGNORE; - if ( ( error = init_encoder( hSpar->hCoreCoderVAD, st_ivas, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode #ifdef IGF_MEMORY_ALLOC_OPT - , - hSpar->hCoreCoderVAD->total_brate + if ( ( error = init_encoder( hSpar->hCoreCoderVAD, st_ivas, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode, hSpar->hCoreCoderVAD->total_brate ) ) != IVAS_ERR_OK ) +#else + if ( ( error = init_encoder( hSpar->hCoreCoderVAD, st_ivas, 0, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 1, st_ivas->ism_mode ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -508,7 +506,10 @@ static ivas_error ivas_spar_cov_md_process( if ( hSpar->hMdEnc->spar_hoa_md_flag == 0 ) { - ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag ); + if ( ( error = ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag ) ) != IVAS_ERR_OK ) + { + return error; + } } if ( hSpar->hMdEnc->spar_hoa_dirac2spar_md_flag ) @@ -556,7 +557,7 @@ static ivas_error ivas_spar_cov_md_process( if ( hSpar->hMdEnc->spar_hoa_md_flag ) { - ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag ); + error = ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag ); } return error; @@ -696,7 +697,10 @@ static ivas_error ivas_spar_enc_process( hodirac_flag = ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ); - ivas_dirac_enc( st_ivas->hDirAC, hQMetaData, hMetaData, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ); + if ( ( error = ivas_dirac_enc( st_ivas->hDirAC, hQMetaData, hMetaData, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ) ) != IVAS_ERR_OK ) + { + return error; + } /* Set Energy Ratio to 0.0 if the mono flag has been set */ if ( hQMetaData->dirac_mono_flag ) diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 4e97037f1e41a60ea012c908878c5e5e0b31e9d2..8b21c62a6bcac8808be1257929729bd50eb03a02 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -68,12 +68,11 @@ typedef enum ivas_strats_t static void ivas_band_mixer( float *cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t num_ch, int16_t *num_bands, int16_t red_band_fact ); - static int16_t ivas_get_huffman_coded_bs( ivas_spar_md_enc_state_t *hMdEnc, BSTR_ENC_HANDLE hMetaData, const int16_t nB, const int16_t qsi, const int16_t bands_bw ); static int16_t ivas_get_arith_coded_bs( ivas_spar_md_enc_state_t *hMdEnc, BSTR_ENC_HANDLE hMetaData, const int16_t *pDo_diff, const int16_t bands_bw, const int16_t nB, const int16_t qsi, const int16_t strat, const int32_t ivas_total_brate ); -static ivas_error ivas_spar_set_enc_config( ivas_spar_md_enc_state_t *hMdEnc, int16_t *max_freq_per_chan, const int16_t nchan_transport, float *pFC, const int16_t nchan_inp ); +static void ivas_spar_set_enc_config( ivas_spar_md_enc_state_t *hMdEnc, int16_t *max_freq_per_chan, const int16_t nchan_transport, float *pFC, const int16_t nchan_inp ); static void ivas_select_next_strat( ivas_strats_t prior_strat, ivas_strats_t cs[MAX_QUANT_STRATS], const int16_t dmx_switch, const int16_t dtx_vad ); @@ -318,7 +317,7 @@ ivas_error ivas_spar_md_enc_init( * Set configuration for SPAR MD encoder *-----------------------------------------------------------------------------------------*/ -static ivas_error ivas_spar_set_enc_config( +static void ivas_spar_set_enc_config( ivas_spar_md_enc_state_t *hMdEnc, int16_t *max_freq_per_chan, const int16_t nchan_transport, @@ -357,7 +356,7 @@ static ivas_error ivas_spar_set_enc_config( hMdEnc->spar_md_cfg.num_decorr_per_band[i] = hMdEnc->num_umx_ch - tmp_dmx_ch; } - return IVAS_ERR_OK; + return; } @@ -448,8 +447,7 @@ static void write_metadata_buffer( if ( hMetaData->nb_bits_tot > 0 ) { - restore_metadata_buffer( hMetaData, next_ind_start, - bit_pos_start ); + restore_metadata_buffer( hMetaData, next_ind_start, bit_pos_start ); } for ( i = 0; i < hMetaData_tmp->nb_ind_tot; i++ ) diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 596c0dcfb61df22d6e457deb017ca25445078942..64446f3e518407abb7d25b5e1220fc3d50659708 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -481,9 +481,7 @@ void tdm_configure_enc( * bitbudget distribution between channels (taking into account also metadata bitbudget) *----------------------------------------------------------------*/ - tdm_bit_alloc( ivas_format, - ism_mode, - hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, + tdm_bit_alloc( ivas_format, ism_mode, hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), &( hStereoTD->tdm_low_rate_mode ), sts[1]->coder_type, tdm_ratio_bit_alloc_idx, hStereoTD->tdm_Pitch_reuse_flag, sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, hStereoTD->tdm_inst_ratio_idx ); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index c1e768fef0ea749825a7355e3705a561c30dc636..1abced2ead052f378af9da5c1a21fa445a471c80 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -124,11 +124,6 @@ ivas_error IVAS_ENC_Open( ( *phIvasEnc )->maxBandwidthUser = false; resetIsmMetadataProvidedFlags( *phIvasEnc ); - /*-----------------------------------------------------------------* - * Initialize indices - *-----------------------------------------------------------------*/ - - /*-----------------------------------------------------------------* * Allocate IVAS-codec encoder state *-----------------------------------------------------------------*/ diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index b7582ed9e428dd310c5bfb9cb539231cffe5dbb2..a69bb1bf356f59be088d386fb5c4b73b5ad636b1 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -203,13 +203,13 @@ ivas_error IVAS_ENC_ConfigureForObjects( /*! r: encoder error code */ ivas_error IVAS_ENC_ConfigureForMASAObjects( - IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const int32_t inputFs, /* i : input sampling frequency */ - const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ - const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ - const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const uint16_t numObjects, /* i : number of objects to be encoded */ - const int16_t masaVariant /* i : index specifying the number of MASA transport channels */ + IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ + const int32_t inputFs, /* i : input sampling frequency */ + const int32_t bitrate, /* i : requested bitrate of the ouput bitstream */ + const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ + const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ + const uint16_t numObjects, /* i : number of objects to be encoded */ + const int16_t masaVariant /* i : index specifying the number of MASA transport channels */ ); /*! r: encoder error code */ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index ee30669e3de561b8d2acb555512cc20c1826a0cf..0b1772ec9bff63fb85c4bdb475e74e1646327f44 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1108,6 +1108,8 @@ typedef struct tcx_enc_structure int16_t tns_ms_flag[2]; } TCX_ENC_DATA, *TCX_ENC_HANDLE; + + /*----------------------------------------------------------------------------------* * * Main Core encoder structure @@ -1272,7 +1274,6 @@ typedef struct enc_core_structure int16_t tdm_pc; /* pitch stability - used in TD stereo */ - /*----------------------------------------------------------------------------------* * General signal buffers *----------------------------------------------------------------------------------*/ @@ -1358,7 +1359,6 @@ typedef struct enc_core_structure SC_VBR_ENC_HANDLE hSC_VBR; - /*----------------------------------------------------------------------------------* * HQ core parameters *----------------------------------------------------------------------------------*/ @@ -1450,7 +1450,6 @@ typedef struct enc_core_structure float *wspeech_enc; float *synth; - int16_t enableTcxLpc; /* global toggle for the TCX LPC quantizer */ int16_t envWeighted; /* are is{p,f}_old_q[] weighted or not? */ @@ -1537,9 +1536,8 @@ typedef struct enc_core_structure int16_t tfa_flag; float tfa_enr[N_TEC_TFA_SUBFR]; - /*---------------------------------------------------------------* - * Stereo/IVAS parameters + * IVAS parameters *---------------------------------------------------------------*/ int16_t tdm_LRTD_flag; /* LRTD stereo mode flag */ diff --git a/lib_rend/ivas_PredDecoder.c b/lib_rend/ivas_PredDecoder.c index 3ba8c88138e68a432714c617ae31df3708d25c10..a0642ff0ea80b989f003e1945b771b373c075ffe 100644 --- a/lib_rend/ivas_PredDecoder.c +++ b/lib_rend/ivas_PredDecoder.c @@ -54,7 +54,6 @@ ivas_error CreatePredictionDecoder( const int32_t iNumBlocks ) { int16_t n; - PredictionDecoder *psPredictionDecoder = NULL; if ( ( psPredictionDecoder = (PredictionDecoder *) malloc( sizeof( PredictionDecoder ) ) ) == NULL ) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index f023fcdbc777a4fb4b93ecfc920a0184e315c143..b79d329d9660d2d0bf73de5e43e4b9650482c6b1 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -105,6 +105,7 @@ static ivas_error ivas_hrtf_open( ) { HRTFS_HANDLE hHrtf; + ivas_error error; if ( *hHrtf_out == NULL ) { @@ -113,7 +114,10 @@ static ivas_error ivas_hrtf_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder\n" ); } - ivas_hrtf_init( hHrtf ); + if ( ( error = ivas_hrtf_init( hHrtf ) ) != IVAS_ERR_OK ) + { + return error; + } *hHrtf_out = hHrtf; } @@ -122,7 +126,7 @@ static ivas_error ivas_hrtf_open( return IVAS_ERR_INTERNAL; } - return ( IVAS_ERR_OK ); + return IVAS_ERR_OK; } @@ -132,19 +136,19 @@ static ivas_error ivas_hrtf_open( * Close hHrtf handle *------------------------------------------------------------------------*/ -static ivas_error ivas_hrtf_close( +static void ivas_hrtf_close( HRTFS_HANDLE *hHrtf /* i/o: HRTF handle */ ) { if ( *hHrtf == NULL || hHrtf == NULL ) { - return IVAS_ERR_WRONG_PARAMS; + return; } free( *hHrtf ); *hHrtf = NULL; - return IVAS_ERR_OK; + return; } /*------------------------------------------------------------------------- @@ -933,6 +937,8 @@ static ivas_error ivas_shoebox_output_init( shoebox_output_t *hShoeboxOutput /* i/o: shoebox_output_t handle */ ) { + ivas_error error; + if ( hShoeboxOutput == NULL ) { return IVAS_ERR_WRONG_PARAMS; @@ -941,10 +947,25 @@ static ivas_error ivas_shoebox_output_init( hShoeboxOutput->n_sources = 0; hShoeboxOutput->n_ref = 0; - ivas_shoebox_data_init( &hShoeboxOutput->times ); - ivas_shoebox_data_init( &hShoeboxOutput->gains ); - ivas_shoebox_data_init( &hShoeboxOutput->az_angle ); - ivas_shoebox_data_init( &hShoeboxOutput->el_angle ); + if ( ( error = ivas_shoebox_data_init( &hShoeboxOutput->times ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_shoebox_data_init( &hShoeboxOutput->gains ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_shoebox_data_init( &hShoeboxOutput->az_angle ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_shoebox_data_init( &hShoeboxOutput->el_angle ) ) != IVAS_ERR_OK ) + { + return error; + } return IVAS_ERR_OK; } @@ -995,6 +1016,7 @@ static ivas_error ivas_shoebox_obj_init( ) { int16_t i; + ivas_error error; if ( hShoeboxObj == NULL ) { @@ -1028,7 +1050,10 @@ static ivas_error ivas_shoebox_obj_init( hShoeboxObj->soundspeed = 0.0f; hShoeboxObj->air_coeff = 0.0f; - ivas_shoebox_config_init_params( &hShoeboxObj->cal ); + if ( ( error = ivas_shoebox_config_init_params( &hShoeboxObj->cal ) ) != IVAS_ERR_OK ) + { + return error; + } return IVAS_ERR_OK; } @@ -1045,6 +1070,7 @@ static ivas_error ivas_er_init_handle( ) { int16_t i; + ivas_error error; if ( reflections == NULL ) { @@ -1078,8 +1104,15 @@ static ivas_error ivas_er_init_handle( reflections->circ_buffers = NULL; reflections->closest_ch_idx = NULL; - ivas_shoebox_output_init( &reflections->shoebox_data ); - ivas_shoebox_obj_init( &reflections->shoebox_lib ); + if ( ( error = ivas_shoebox_output_init( &reflections->shoebox_data ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_shoebox_obj_init( &reflections->shoebox_lib ) ) != IVAS_ERR_OK ) + { + return error; + } return IVAS_ERR_OK; } @@ -1179,12 +1212,11 @@ ivas_error ivas_rend_openMultiBinCrend( { ivas_error error; - if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs #ifdef SPLIT_REND_WITH_HEAD_ROT - , - pMultiBinPoseData->num_poses + if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1223,12 +1255,12 @@ ivas_error ivas_rend_openCrend( #endif error = IVAS_ERR_OK; - if ( ( error = ivas_rend_initCrendWrapper( pCrend + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - num_poses + if ( ( error = ivas_rend_initCrendWrapper( pCrend, num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_initCrendWrapper( pCrend ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1334,7 +1366,11 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); } - ivas_er_init_handle( hCrend->reflections ); + if ( ( error = ivas_er_init_handle( hCrend->reflections ) ) != IVAS_ERR_OK ) + { + return error; + } + hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er; hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; @@ -1349,7 +1385,7 @@ ivas_error ivas_rend_openCrend( if ( ( error = ivas_er_init( hCrend->reflections, inConfig ) ) != IVAS_ERR_OK ) { return error; - }; + } } else { @@ -1524,6 +1560,7 @@ void ivas_rend_closeCldfbRend( } #endif + /*-----------------------------------------------------------------------------------------* * Function ivas_rend_crendConvolver() * @@ -1555,12 +1592,13 @@ static ivas_error ivas_rend_crendConvolver( float pOut[L_FRAME48k * 2]; float tmp_out_re[L_FRAME48k], tmp_out_im[L_FRAME48k]; CREND_HANDLE hCrend; + ivas_error error; + #ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = pCrend->hCrend[pos_idx]; #else hCrend = pCrend->hCrend; #endif - ivas_error error; if ( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ) != IVAS_ERR_OK ) { @@ -1725,17 +1763,16 @@ ivas_error ivas_rend_crendProcess( float pcm_tmp[BINAURAL_CHANNELS][L_FRAME48k]; float *p_pcm_tmp[BINAURAL_CHANNELS]; IVAS_REND_AudioConfigType inConfigType; + int8_t combinedOrientationEnabled; ivas_error error; - CREND_HANDLE hCrend; + #ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = pCrend->hCrend[pos_idx]; #else hCrend = pCrend->hCrend; #endif - int8_t combinedOrientationEnabled; - combinedOrientationEnabled = 0; if ( hCombinedOrientationData != NULL ) { @@ -1800,12 +1837,11 @@ ivas_error ivas_rend_crendProcess( if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED || inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) { - if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, output, p_pcm_tmp, output_Fs, subframe_idx #ifdef SPLIT_REND_WITH_HEAD_ROT - , - pos_idx + if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, output, p_pcm_tmp, output_Fs, subframe_idx, pos_idx ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, output, p_pcm_tmp, output_Fs, subframe_idx ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_dirac_ana.c b/lib_rend/ivas_dirac_ana.c index 8e07698fbd1c3171d3d5994f614e72c66283439b..2391d7cfac42fc5de7d549d0b369efb067d39288 100644 --- a/lib_rend/ivas_dirac_ana.c +++ b/lib_rend/ivas_dirac_ana.c @@ -103,7 +103,10 @@ ivas_error ivas_dirac_ana_open( hDirAC->num_Cldfb_instances = numAnalysisChannels; for ( i = 0; i < hDirAC->num_Cldfb_instances; i++ ) { - openCldfb( &( hDirAC->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ); + if ( ( error = openCldfb( &( hDirAC->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } } /* intensity 3-dim */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index eb93a449c6cab1f83f117e31e383d004ab411ef5..ddc379d2cd70bb820b077535842c719fad2adf81 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -234,14 +234,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( if ( hDiracDecBin->hReverb == NULL ) #endif { - if ( ( error = ivas_binaural_reverb_open( &hDiracDecBin->hReverb, - nBins, - CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, - st_ivas->hIntSetup.output_config, - output_Fs, - RENDERER_BINAURAL_PARAMETRIC_ROOM, - st_ivas->hHrtfFastConv, - st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_binaural_reverb_open( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, st_ivas->hIntSetup.output_config, output_Fs, RENDERER_BINAURAL_PARAMETRIC_ROOM, st_ivas->hHrtfFastConv, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) { return error; } @@ -559,9 +552,8 @@ void ivas_dirac_dec_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport /* i : number of transport channels */ - , - const int16_t num_subframes /* i : number of subframes to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t num_subframes /* i : number of subframes to render */ ) { int16_t subframe; diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 568341abe1b54d815190e78f00d17a224a856616..6da208fa9b7a16c65ff727a01f0c3c197156f570 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -88,12 +88,12 @@ static void normalizePanningGains( float *direct_response, const int16_t num_cha *------------------------------------------------------------------------*/ ivas_error ivas_dirac_dec_output_synthesis_open( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - RENDERER_TYPE renderer_type, /* i : renderer type */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ + DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ + RENDERER_TYPE renderer_type, /* i : renderer type */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ ) { int16_t idx, ch_idx; @@ -626,120 +626,117 @@ void ivas_dirac_dec_output_synthesis_process_slot( h_dirac_output_synthesis_state->diffuse_power_factor ); } } - else // ( dec_param_estim == TRUE ) - if ( dec_param_estim == TRUE ) + else if ( dec_param_estim == TRUE ) + { + /* compute direct responses */ + ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, + hDirACRend, + hVBAPdata, + NULL, + NULL, + azimuth, + elevation, + md_idx, + NULL, + sh_rot_max_order, + p_Rmat, + hodirac_flag ); + + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { + ivas_dirac_dec_compute_gain_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); - /* compute direct responses */ - ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, - hDirACRend, - hVBAPdata, - NULL, - NULL, - azimuth, - elevation, - md_idx, - NULL, - sh_rot_max_order, - p_Rmat, - hodirac_flag ); + v_multc( h_dirac_output_synthesis_state->direct_power_factor, + 0.25f, + h_dirac_output_synthesis_state->direct_power_factor, + num_freq_bands ); + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + 0.25f, + h_dirac_output_synthesis_state->diffuse_power_factor, + num_freq_bands ); - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + /*Direct gain*/ + for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) { - ivas_dirac_dec_compute_gain_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); - - - v_multc( h_dirac_output_synthesis_state->direct_power_factor, - 0.25f, - h_dirac_output_synthesis_state->direct_power_factor, - num_freq_bands ); - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - 0.25f, - h_dirac_output_synthesis_state->diffuse_power_factor, - num_freq_bands ); - - /*Direct gain*/ - for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) + int16_t k; + if ( ch_idx != 0 ) { - int16_t k; - if ( ch_idx != 0 ) - { - float a, b, c; + float a, b, c; - /*Directonal sound gain nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) - { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); - } - for ( ; k < num_freq_bands; k++ ) - { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); - } + /*Directonal sound gain nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); } - else + for ( ; k < num_freq_bands; k++ ) { - /*Diffuseness modellling nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); - } - for ( ; k < num_freq_bands; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); - } + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); } } - - /*Directional gain (panning)*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) - { - v_mult( h_dirac_output_synthesis_state->direct_power_factor, - &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], - aux_buf, - num_freq_bands ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - num_freq_bands ); - } - - /*Diffuse gain*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) + else { - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - hDirACRend->diffuse_response_function[ch_idx], - aux_buf, - num_freq_bands_diff ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - num_freq_bands_diff ); + /*Diffuseness modellling nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); + } + for ( ; k < num_freq_bands; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); + } } + } - return; + /*Directional gain (panning)*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) + { + v_mult( h_dirac_output_synthesis_state->direct_power_factor, + &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], + aux_buf, + num_freq_bands ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + num_freq_bands ); } - else + + /*Diffuse gain*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) { - /* compute reference and diffuse power factor for this frame */ - ivas_dirac_dec_compute_power_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + hDirACRend->diffuse_response_function[ch_idx], + aux_buf, + num_freq_bands_diff ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + num_freq_bands_diff ); } + + return; + } + else + { + /* compute reference and diffuse power factor for this frame */ + ivas_dirac_dec_compute_power_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); } + } diff_start_band = 0; if ( h_dirac_output_synthesis_params->use_onset_filters ) @@ -1746,11 +1743,11 @@ static void ivas_dirac_dec_get_response_split_order( *------------------------------------------------------------------------*/ void ivas_dirac_dec_compute_directional_responses( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ - DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ - const MASA_DECODER_HANDLE hMasa, /* i : MASA decoder structure */ - MASA_ISM_DATA_HANDLE hMasaIsm, /* i : MASA_ISM data structure */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ + DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ + const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ + const MASA_DECODER_HANDLE hMasa, /* i : MASA decoder structure */ + MASA_ISM_DATA_HANDLE hMasaIsm, /* i : MASA_ISM data structure */ const int16_t *azimuth, const int16_t *elevation, const int16_t md_idx, @@ -1860,6 +1857,7 @@ void ivas_dirac_dec_compute_directional_responses( { /* Synthesize the first direction */ spreadCoherencePanningHoa( azimuth[k], elevation[k], hSpatParamRendCom->spreadCoherence[md_idx][k], direct_response_hoa, num_channels_dir, hDirACRend->hOutSetup.ambisonics_order ); + /* Synthesize the second direction and combine the gains */ if ( hSpatParamRendCom->numParametricDirections == 2 ) { @@ -2035,6 +2033,7 @@ void ivas_dirac_dec_compute_directional_responses( } normalizePanningGains( direct_response_ls, num_channels_dir ); } + /* Synthesize surrounding coherence */ if ( surCohRatio != NULL && surCohRatio[k] > 0.f ) { @@ -2052,6 +2051,7 @@ void ivas_dirac_dec_compute_directional_responses( } } } + normalizePanningGains( direct_response_ls, num_channels_dir ); /* Set computed gains */ diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 669d38fa2161cf1192d965a25c93bacb23be5463..6709b9b4e09eb586740881e29daade1dc5408f3c 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -184,6 +184,12 @@ ivas_error ivas_dirac_allocate_parameters( } +/*------------------------------------------------------------------------- + * ivas_spat_hSpatParamRendCom_config() + * + * + *-------------------------------------------------------------------------*/ + ivas_error ivas_spat_hSpatParamRendCom_config( SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: IVAS decoder structure */ const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ @@ -221,7 +227,6 @@ ivas_error ivas_spat_hSpatParamRendCom_config( *hSpatParamRendCom_out = hSpatParamRendCom; } - if ( flag_config == DIRAC_OPEN ) { hSpatParamRendCom->slot_size = (int16_t) ( ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX ); @@ -240,6 +245,7 @@ ivas_error ivas_spat_hSpatParamRendCom_config( /*-----------------------------------------------------------------* * set input parameters *-----------------------------------------------------------------*/ + if ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && flag_config == DIRAC_RECONFIGURE ) { if ( hodirac_flag && hSpatParamRendCom->azimuth2 == NULL ) @@ -321,6 +327,12 @@ ivas_error ivas_spat_hSpatParamRendCom_config( } +/*------------------------------------------------------------------------- + * ivas_spat_hSpatParamRendCom_close() + * + * + *-------------------------------------------------------------------------*/ + void ivas_spat_hSpatParamRendCom_close( SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out ) { @@ -338,6 +350,13 @@ void ivas_spat_hSpatParamRendCom_close( return; } + +/*------------------------------------------------------------------------- + * ivas_dirac_rend_close() + * + * + *-------------------------------------------------------------------------*/ + void ivas_dirac_rend_close( DIRAC_REND_HANDLE *hDirACRend_out ) { @@ -442,8 +461,8 @@ void ivas_dirac_rend_close( *-------------------------------------------------------------------------*/ void ivas_dirac_deallocate_parameters( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ + const int16_t params_flag /* i : set of parameters flag */ ) { int16_t i; @@ -818,6 +837,12 @@ ivas_error ivas_dirac_alloc_mem( } +/*------------------------------------------------------------------------- + * ivas_dirac_free_mem() + * + * + *-------------------------------------------------------------------------*/ + void ivas_dirac_free_mem( DIRAC_DEC_STACK_MEM_HANDLE hDirAC_mem ) { @@ -934,18 +959,20 @@ void ivas_dirac_dec_get_frequency_axis( /*------------------------------------------------------------------------- - * Local functions + * initDiffuseResponses() + * + * *-------------------------------------------------------------------------*/ void initDiffuseResponses( float *diffuse_response_function, const int16_t num_channels, - AUDIO_CONFIG output_config, - IVAS_OUTPUT_SETUP hOutSetup, + const AUDIO_CONFIG output_config, + const IVAS_OUTPUT_SETUP hOutSetup, const int16_t ambisonics_order, const IVAS_FORMAT ivas_format, int16_t *num_ele_spk_no_diffuse_rendering, - AUDIO_CONFIG transport_config ) + const AUDIO_CONFIG transport_config ) { int16_t i, l, k, idx, num_horizontal_speakers; *num_ele_spk_no_diffuse_rendering = 0; @@ -1044,6 +1071,12 @@ void initDiffuseResponses( } +/*------------------------------------------------------------------------- + * protoSignalComputation_shd() + * + * + *-------------------------------------------------------------------------*/ + void protoSignalComputation_shd( float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], @@ -1200,6 +1233,12 @@ void protoSignalComputation_shd( } +/*------------------------------------------------------------------------- + * protoSignalComputation1() + * + * + *-------------------------------------------------------------------------*/ + void protoSignalComputation1( float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], @@ -1234,6 +1273,12 @@ void protoSignalComputation1( } +/*------------------------------------------------------------------------- + * protoSignalComputation2() + * + * + *-------------------------------------------------------------------------*/ + void protoSignalComputation2( float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], @@ -1555,6 +1600,12 @@ void protoSignalComputation2( } +/*------------------------------------------------------------------------- + * protoSignalComputation4() + * + * + *-------------------------------------------------------------------------*/ + void protoSignalComputation4( float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], @@ -1718,7 +1769,6 @@ void computeDirectionAngles( float x, y, z, radius; for ( k = 0; k < num_frequency_bands; ++k ) - { intensityNorm = *( intensity_real_x ) * *( intensity_real_x ) + *( intensity_real_y ) * *( intensity_real_y ) + diff --git a/lib_rend/ivas_efap.c b/lib_rend/ivas_efap.c index 42ef8beaa3249d8ee4cb25a09cf62cc049fea268..40f5e731202e300447975a2abfd3f5ee6c3ad57a 100644 --- a/lib_rend/ivas_efap.c +++ b/lib_rend/ivas_efap.c @@ -213,7 +213,6 @@ ivas_error efap_init_data( return error; } - /* Memory allocation for the tmp buffer long */ if ( ( efap->bufferLong = (float *) malloc( efap->vtxData.numVtx * sizeof( float ) ) ) == NULL ) { @@ -396,7 +395,6 @@ static ivas_error poly_init( return error; } - /* set isNaN for ghost loudspeakers */ for ( n = 0; n < efap->vtxData.numVtx; ++n ) { @@ -469,7 +467,6 @@ static ivas_error poly_init( return error; } - #ifdef DEBUG_EFAP_POLY_TOFILE static void get_poly_select( EFAP_POLYSET_DATA *polyData /* o : Polygon data structure */ @@ -508,7 +505,6 @@ static void get_poly_select( } #endif - /*-------------------------------------------------------------------------* * sphere_triangulation() * @@ -2281,4 +2277,6 @@ static void sph2cart( pos[0] = cosf( azi * PI_OVER_180 ) * cosf( ele * PI_OVER_180 ); pos[1] = sinf( azi * PI_OVER_180 ) * cosf( ele * PI_OVER_180 ); pos[2] = sinf( ele * PI_OVER_180 ); + + return; } diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index 380afccca3643bbd48882f90e5d96658201a615d..3394e018b7a88685c789deb42ea2afa69238a9e5 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -140,7 +140,9 @@ ivas_error ivas_HRTF_fastconv_binary_open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FASTCONV HRTF tables!" ); } + ivas_init_binaural_hrtf( *hHrtfFastConv ); + return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_mcmasa_ana.c b/lib_rend/ivas_mcmasa_ana.c index 671cf568930cc993f3567eae80e4427d219d06d1..7ed4aeb0df58e8bae9796b8def729febb8a93240 100644 --- a/lib_rend/ivas_mcmasa_ana.c +++ b/lib_rend/ivas_mcmasa_ana.c @@ -173,7 +173,10 @@ ivas_error ivas_mcmasa_ana_open( hMcMasa->num_Cldfb_instances = numAnalysisChannels; for ( i = 0; i < hMcMasa->num_Cldfb_instances; i++ ) { - openCldfb( &( hMcMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ); + if ( ( error = openCldfb( &( hMcMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } } /* intensity 3-dim */ diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index ba57717b8f7aba4d22cda4689c4eb31d45e16fd4..3db14715aa75c47ecb17bcbe149391dda422104d 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -187,10 +187,25 @@ ivas_error ivas_td_binaural_open_unwrap( DirAtten_p->ConeOuterAngle = 360.0f; DirAtten_p->ConeOuterGain = 1.0f; - TDREND_MIX_SRC_SetPos( pBinRendTd, nS, Pos ); - TDREND_MIX_SRC_SetDir( pBinRendTd, nS, Dir ); - TDREND_MIX_SRC_SetPlayState( pBinRendTd, nS, TDREND_PLAYSTATUS_PLAYING ); - TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ); + if ( ( error = TDREND_MIX_SRC_SetPos( pBinRendTd, nS, Pos ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = TDREND_MIX_SRC_SetDir( pBinRendTd, nS, Dir ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = TDREND_MIX_SRC_SetPlayState( pBinRendTd, nS, TDREND_PLAYSTATUS_PLAYING ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ) ) != IVAS_ERR_OK ) + { + return error; + } } } @@ -212,7 +227,11 @@ ivas_error ivas_td_binaural_open_unwrap( DirAtten_p->ConeOuterAngle = directivity[nS * 3 + 1]; DirAtten_p->ConeOuterGain = directivity[nS * 3 + 2]; } - TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ); + + if ( ( error = TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ) ) != IVAS_ERR_OK ) + { + return error; + } } } @@ -253,6 +272,7 @@ void ivas_td_binaural_close( return; } + /*---------------------------------------------------------------------* * ivas_td_binaural_renderer_unwrap() * @@ -272,9 +292,8 @@ ivas_error ivas_td_binaural_renderer_unwrap( 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 */ + const int16_t output_frame, /* i : output frame length */ + const int16_t num_subframes /* i : number of subframes to render */ ) { int16_t subframe_length; @@ -308,10 +327,18 @@ ivas_error ivas_td_binaural_renderer_unwrap( if ( subframe_idx == ism_md_subframe_update ) { /* Update object position(s) */ - TDREND_Update_object_positions( hBinRendererTd, num_src, ivas_format, hIsmMetaData ); + if ( ( error = TDREND_Update_object_positions( hBinRendererTd, num_src, ivas_format, hIsmMetaData ) ) != IVAS_ERR_OK ) + { + return error; + } } + /* Update the listener's location/orientation */ - TDREND_Update_listener_orientation( hBinRendererTd, ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[subframe_idx] : NULL ); + 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 ) + { + return error; + } + if ( hReverb != NULL ) { if ( ( error = ivas_reverb_process( hReverb, transport_config, 0, output, p_reverb_signal, subframe_idx ) ) != IVAS_ERR_OK ) @@ -360,7 +387,7 @@ ivas_error TDREND_GetMix( float *output[], /* i/o: ISM object synth / rendered output in 0,1 */ const int16_t subframe_length, /* i/o: subframe length */ const int16_t subframe_idx, /* i : Subframe index to 5 ms subframe */ - const int16_t ism_md_subframe_update /* Number of subframes to delay ism metadata to sync with audio */ + const int16_t ism_md_subframe_update /* i : Number of subframes to delay ism metadata to sync with audio */ ) { int16_t i; @@ -449,7 +476,7 @@ static void TDREND_Clear_Update_flags( * Update object position(s) *---------------------------------------------------------------------*/ -void TDREND_Update_object_positions( +ivas_error TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ const int16_t num_src, /* i : number of sources to render */ const IVAS_FORMAT in_format, /* i : Format of input sources */ @@ -460,6 +487,7 @@ void TDREND_Update_object_positions( int16_t nS; float Pos[3]; float Dir[3]; + ivas_error error; DirAtten_p = hBinRendererTd->DirAtten_p; @@ -473,16 +501,25 @@ void TDREND_Update_object_positions( angles_to_vec( hIsmMetaData[nS]->radius, hIsmMetaData[nS]->azimuth, hIsmMetaData[nS]->elevation, Pos ); angles_to_vec( 1.0f, hIsmMetaData[nS]->yaw, hIsmMetaData[nS]->pitch, Dir ); + if ( ( error = TDREND_MIX_SRC_SetPos( hBinRendererTd, nS, Pos ) ) != IVAS_ERR_OK ) + { + return error; + } - TDREND_MIX_SRC_SetPos( hBinRendererTd, nS, Pos ); - TDREND_MIX_SRC_SetDirAtten( hBinRendererTd, nS, DirAtten_p ); + if ( ( error = TDREND_MIX_SRC_SetDirAtten( hBinRendererTd, nS, DirAtten_p ) ) != IVAS_ERR_OK ) + { + return error; + } if ( hIsmMetaData[nS]->non_diegetic_flag ) { Pos[0] = 0; Pos[1] = hIsmMetaData[nS]->azimuth / 90.f; Pos[2] = 0; - TDREND_MIX_SRC_SetPos( hBinRendererTd, nS, Pos ); + if ( ( error = TDREND_MIX_SRC_SetPos( hBinRendererTd, nS, Pos ) ) != IVAS_ERR_OK ) + { + return error; + } hBinRendererTd->Sources[nS]->SrcSpatial_p->PosType = TDREND_POSTYPE_NON_DIEGETIC; } else @@ -490,11 +527,14 @@ void TDREND_Update_object_positions( hBinRendererTd->Sources[nS]->SrcSpatial_p->PosType = TDREND_POSTYPE_ABSOLUTE; } - TDREND_MIX_SRC_SetDir( hBinRendererTd, nS, Dir ); + if ( ( error = TDREND_MIX_SRC_SetDir( hBinRendererTd, nS, Dir ) ) != IVAS_ERR_OK ) + { + return error; + } } } - return; + return IVAS_ERR_OK; } @@ -504,7 +544,7 @@ void TDREND_Update_object_positions( * Update listener orientation (s) *---------------------------------------------------------------------*/ -void TDREND_Update_listener_orientation( +ivas_error TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ const int16_t headRotEnabled, /* i : Headrotation flag */ const IVAS_QUATERNION *headPosition, /* i : Listener orientation */ @@ -515,6 +555,7 @@ void TDREND_Update_listener_orientation( float UpVec[3]; float Rmat[3][3]; float Pos_p[3]; + ivas_error error; if ( headRotEnabled ) { @@ -561,9 +602,9 @@ void TDREND_Update_listener_orientation( /* Set the listener position and orientation:*/ TDREND_MIX_LIST_SetPos( hBinRendererTd, Pos_p ); - TDREND_MIX_LIST_SetOrient( hBinRendererTd, FrontVec, UpVec ); + error = TDREND_MIX_LIST_SetOrient( hBinRendererTd, FrontVec, UpVec ); - return; + return error; } diff --git a/lib_rend/ivas_omasa_ana.c b/lib_rend/ivas_omasa_ana.c index f669a6767167702c2ca5962f3485d8bd67cadeb2..7284acb8cfc2761943cc9d64abd89830764e7696 100644 --- a/lib_rend/ivas_omasa_ana.c +++ b/lib_rend/ivas_omasa_ana.c @@ -105,7 +105,10 @@ ivas_error ivas_omasa_ana_open( hOMasa->num_Cldfb_instances = numAnalysisChannels; for ( i = 0; i < hOMasa->num_Cldfb_instances; i++ ) { - openCldfb( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ); + if ( ( error = openCldfb( &( hOMasa->cldfbAnaEnc[i] ), CLDFB_ANALYSIS, input_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } } for ( ; i < MAX_NUM_OBJECTS; i++ ) @@ -255,7 +258,6 @@ void ivas_omasa_ana( float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - /* Estimate MASA parameters from the objects */ ivas_omasa_param_est_ana( hOMasa, data_in_f, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, input_frame, nchan_ism ); @@ -514,11 +516,16 @@ static void ivas_omasa_dmx( mvr2r( data_out_f[i], data_in_f[i], input_frame ); } - return; } +/*--------------------------------------------------------------------------* + * computeIntensityVector_ana() + * + * + *--------------------------------------------------------------------------*/ + void computeIntensityVector_ana( const int16_t *band_grouping, /* i : Band grouping for estimation */ float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ @@ -558,6 +565,12 @@ void computeIntensityVector_ana( } +/*--------------------------------------------------------------------------* + * computeReferencePower_ana() + * + * + *--------------------------------------------------------------------------*/ + void computeReferencePower_ana( const int16_t *band_grouping, /* i : Band grouping for estimation */ float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index 92f2b6d7b380f342ef3b36a7756dc6ed8c5add59..ff24510c58bfd90e1c6870c8df34e017bbb83403 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -48,9 +48,7 @@ * Local constants *------------------------------------------------------------------------------------------*/ -#define MAX_TRACKED_ANGLE_AVG_ORIENT PI_OVER_2 -#define MAX_TRACKED_ANGLE_REF_ORIENT EVS_PI -#define OTR_UPDATE_RATE (float) FRAMES_PER_SEC /* rate of the Process() calls [Hz]; 1x per IVAS frame */ +#define OTR_UPDATE_RATE (float) FRAMES_PER_SEC /* rate of the Process() calls [Hz]; 1x per IVAS frame */ /*------------------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 34c54eae0e3526fd32c7174dc51ba51cc34e498d..f3cada0ab30416c424974498fb235ede7c7e5461 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -94,7 +94,7 @@ void ivas_limiter_close( void ivas_limiter_dec ( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ + float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ const int16_t num_channels, /* i : number of channels to be processed */ const int16_t output_frame, /* i : number of samples per channel in the buffer */ const int16_t BER_detect /* i : BER detect flag */ @@ -161,8 +161,8 @@ void ivas_dirac_dec_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport /* i : number of transport channels */ - ,const int16_t num_subframes /* i : number of subframes to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t num_subframes /* i : number of subframes to render */ ); void ivas_dirac_dec_binaural_render( @@ -208,12 +208,12 @@ void ivas_dirac_free_mem( void initDiffuseResponses( float *diffuse_response_function, const int16_t num_channels, - AUDIO_CONFIG output_config, - IVAS_OUTPUT_SETUP hOutSetup, + const AUDIO_CONFIG output_config, + const IVAS_OUTPUT_SETUP hOutSetup, const int16_t ambisonics_order, const IVAS_FORMAT ivas_format, int16_t *num_ele_spk_no_diffuse_rendering, - AUDIO_CONFIG transport_config + const AUDIO_CONFIG transport_config ); void computeIntensityVector_dec( @@ -505,7 +505,6 @@ void ivas_dirac_deallocate_parameters( ); - /*----------------------------------------------------------------------------------* * HRTF *----------------------------------------------------------------------------------*/ @@ -535,11 +534,11 @@ void ivas_HRTF_parambin_binary_close( ); ivas_error ivas_HRTF_CRend_binary_open( - HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ + HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ ); void ivas_HRTF_CRend_binary_close( - HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ + HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ ); @@ -560,8 +559,8 @@ ivas_error ivas_td_binaural_renderer_unwrap( const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ 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 output_frame, /* i : output frame length */ + const int16_t num_subframes /* i : number of subframes to render */ ); ivas_error ivas_td_binaural_renderer_ext( @@ -572,8 +571,8 @@ ivas_error ivas_td_binaural_renderer_ext( const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ const REVERB_HANDLE hReverb, /* i : Reverberator handle */ const int16_t ism_md_subframe_update_ext, /* i : Metadata Delay in subframes to sync with audio delay */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t output_frame, /* i : output frame length */ + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t output_frame, /* i : output frame length */ float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ); @@ -602,21 +601,21 @@ void ivas_td_binaural_close( ); ivas_error TDREND_GetMix( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - float *output[], /* i/o: ISM object synth / rendered output in 0,1 */ - const int16_t subframe_length, /* i/o: subframe length */ - const int16_t subframe_idx, /* i : Subframe index to 5 ms subframe */ - const int16_t ism_md_subframe_update /* Number of subframes to delay metadata to sync with audio */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + float *output[], /* i/o: ISM object synth/rendered output in 0,1 */ + const int16_t subframe_length, /* i/o: subframe length */ + const int16_t subframe_idx, /* i : Subframe index to 5 ms subframe */ + const int16_t ism_md_subframe_update /* i : Number of subframes to delay metadata to sync with audio */ ); -void TDREND_Update_listener_orientation( +ivas_error TDREND_Update_listener_orientation( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ const int16_t headRotEnabled, /* i : Headrotation flag */ const IVAS_QUATERNION *headPosition, /* i : Listener orientation */ const IVAS_VECTOR3 *Pos /* i : Listener Position */ ); -void TDREND_Update_object_positions( +ivas_error TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD Renderer handle */ const int16_t num_src, /* i : number of sources to render */ const IVAS_FORMAT in_format, /* i : Format of input sources */ @@ -832,7 +831,7 @@ void ivas_rend_closeCrend( ); ivas_error ivas_hrtf_init( - HRTFS_DATA *hHrtf /* i/o: HRTF handle */ + HRTFS_DATA *hHrtf /* i/o: HRTF handle */ ); ivas_error ivas_rend_initCrendWrapper( @@ -852,8 +851,8 @@ ivas_error ivas_rend_crendProcess( IVAS_OUTPUT_SETUP_HANDLE hIntSetup, EFAP_HANDLE hEFAPdata, float *output[], /* i/o: input/output audio channels */ - const int32_t output_Fs - ,const int16_t num_subframes /* i : number of subframes to render */ + const int32_t output_Fs, + const int16_t num_subframes /* i : number of subframes to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT , const int16_t pos_idx @@ -1067,7 +1066,7 @@ void ivas_reverb_calc_color_levels( float *pTarget_color_R ); -void ivas_reverb_prepare_cldfb_params( +ivas_error ivas_reverb_prepare_cldfb_params( IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, @@ -1108,7 +1107,7 @@ void ivas_reverb_get_hrtf_set_properties( void ivas_shoebox_config_init( shoebox_config_t *cal, - RENDER_CONFIG_HANDLE pConfig + RENDER_CONFIG_HANDLE pConfig ); void ivas_shoebox_init( @@ -1130,7 +1129,7 @@ void ivas_shoebox_set_scene ( *-----------------------------------------------------------------------------------*/ ivas_error ivas_er_init( - er_struct_t *reflections, + er_struct_t *reflections, const AUDIO_CONFIG inConfig ); @@ -1249,9 +1248,8 @@ void rotateFrame_sd_cldfb( ); ivas_error ivas_external_orientation_open( - EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData /* o : external orientation handle */ - , - const int16_t num_subframes + EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData, /* o : external orientation handle */ + const int16_t num_subframes /* i : number of subframes */ ); void ivas_external_orientation_close( @@ -1259,9 +1257,8 @@ void ivas_external_orientation_close( ); ivas_error ivas_combined_orientation_open( - COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* o : combined orientation handle */ - , - const int16_t num_subframes + COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* o : combined orientation handle */ + const int16_t num_subframes /* i : number of subframes */ ); void ivas_combined_orientation_close( @@ -1362,13 +1359,15 @@ ivas_error ivas_orient_trk_Process( ); #ifdef SPLIT_REND_WITH_HEAD_ROT -void ivas_set_split_rend_ht_setup( - IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); /*----------------------------------------------------------------------------------* * Split binaural renderer prototypes *----------------------------------------------------------------------------------*/ +void ivas_set_split_rend_ht_setup( + IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData +); + ivas_error ivas_set_split_rend_setup( IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, IVAS_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, @@ -1385,13 +1384,12 @@ void ivas_init_split_post_rend_handles( ); ivas_error ivas_split_renderer_open( - SPLIT_REND_WRAPPER *hSplitBinRend, - const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int32_t output_Fs, - const int16_t is_cldfb_in, - const int16_t is_pcm_out - , - const int16_t is_5ms_frame + SPLIT_REND_WRAPPER *hSplitBinRend, + const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const int32_t output_Fs, + const int16_t cldfb_in_flag, + const int16_t pcm_out_flag, + const int16_t is_5ms_frame ); void ivas_split_renderer_close( @@ -1405,7 +1403,7 @@ ivas_error ivas_splitBinLCLDEncOpen( const int32_t iDataRate ); void ivas_splitBinLCLDEncClose( - BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc + BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc ); void ivas_splitBinLCLDEncProcess( @@ -1437,8 +1435,8 @@ void ivas_splitBinLCLDDecProcess( ivas_error ivas_splitBinPreRendOpen( BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - , +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + , const int32_t output_Fs #endif ); @@ -1446,17 +1444,17 @@ ivas_error ivas_splitBinPreRendOpen( ivas_error ivas_splitBinPostRendOpen( BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const int32_t output_Fs + const int32_t output_Fs ); void ivas_init_multi_bin_pose_data( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); void ivas_renderSplitGetMultiBinPoseData( const IVAS_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const IVAS_SPLIT_REND_ROT_AXIS rot_axis + const IVAS_SPLIT_REND_ROT_AXIS rot_axis ); void ivas_renderSplitUpdateNoCorrectionPoseData( @@ -1466,7 +1464,7 @@ void ivas_renderSplitUpdateNoCorrectionPoseData( ivas_error ivas_renderMultiBinToSplitBinaural( SPLIT_REND_WRAPPER *hSplitBin, - const IVAS_QUATERNION headPosition, + const IVAS_QUATERNION headPosition, const int32_t SplitRendBitRate, IVAS_SPLIT_REND_CODEC splitCodec, int16_t codec_frame_size_ms, @@ -1475,20 +1473,20 @@ ivas_error ivas_renderMultiBinToSplitBinaural( float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int16_t max_bands, float *output[], - const int16_t low_res_pre_rend_rot, - int16_t td_input, - const int16_t pcm_out + const int16_t low_res_pre_rend_rot, + const int16_t cldfb_in_flag, + const int16_t pcm_out_flag ); void ivas_rend_CldfbSplitPreRendProcess( const BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - const IVAS_QUATERNION headPosition, + const IVAS_QUATERNION headPosition, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], ivas_split_rend_bits_t *pBits, - const int32_t target_md_bits, - const int16_t low_res_pre_rend_rot + const int32_t target_md_bits, + const int16_t low_res_pre_rend_rot ); void ivas_rend_CldfbSplitPostRendProcess( @@ -1498,18 +1496,18 @@ void ivas_rend_CldfbSplitPostRendProcess( float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float output[][L_FRAME48k], - const int16_t is_cldfb_in + const int16_t cldfb_in_flag ); void ivas_splitBinPreRendClose( - BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend + BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend ); void ivas_splitBinPostRendClose( BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend ); void ivas_splitBinPostRendMdDec( - ivas_split_rend_bits_t *pBits, + ivas_split_rend_bits_t *pBits, BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG @@ -1553,7 +1551,7 @@ void ivas_log_cldfb2wav_data( const int16_t num_chs, const int16_t num_freq_bands, const int32_t output_Fs, - const int16_t start_slot_idx, + const int16_t start_slot_idx, const int16_t md_band_idx, const char *filename ); @@ -1562,9 +1560,9 @@ void ivas_log_cldfb2wav_data( void ivas_SplitRenderer_GetRotMd( BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ + float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ - const int16_t low_res + const int16_t low_res ); void ivas_SplitRenderer_PostRenderer( @@ -1727,9 +1725,8 @@ void ivas_rend_CldfbMultiBinRendProcess( float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_Out_Real[MAX_HEAD_ROT_POSES*BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ float Cldfb_Out_Imag[MAX_HEAD_ROT_POSES*BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const int16_t low_res_pre_rend_rot - , - int16_t num_subframes + const int16_t low_res_pre_rend_rot, + const int16_t num_subframes ); ivas_error ivas_rend_openCldfb( @@ -1814,13 +1811,13 @@ int32_t ivas_get_lcld_bitrate( int32_t ivas_get_split_rend_md_target_brate( const int32_t SplitRendBitRate, - const int16_t pcm_out + const int16_t pcm_out_flag ); int32_t ivas_get_lc3plus_bitrate( const int32_t SplitRendBitRate, - const IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode -, int16_t split_prerender_frame_size_ms + const IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int16_t split_prerender_frame_size_ms ); int8_t ivas_get_lc3plus_bitrate_id( @@ -1829,13 +1826,13 @@ int8_t ivas_get_lc3plus_bitrate_id( int32_t ivas_get_lc3plus_size_from_id( const int8_t SplitRendBitRateId, - const IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode -,int16_t split_prerender_frame_size_ms + const IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int16_t split_prerender_frame_size_ms ); ivas_error ivas_split_rend_validate_config( const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int16_t is_pcm_out + const int16_t pcm_out_flag ); void ivas_split_rend_get_quant_params( @@ -1855,13 +1852,12 @@ void ivas_split_rend_get_quant_params( int16_t *num_complex_bands ); -ivas_error -ivas_split_rend_choose_default_codec( +ivas_error ivas_split_rend_choose_default_codec( IVAS_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ - int16_t *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ - int16_t isRenderingInTd, /* i : flag: is rendering done in TD? */ - int16_t pcm_out /*i : flag to indicate PCM output*/ - ); + int16_t *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ + const int16_t cldfb_in_flag, /* i : flag indicating rendering in CLDFB */ + const int16_t pcm_out_flag /* i : flag to indicate PCM output */ +); #endif diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index eb905caa1d7b3be9e6c63a589b593bf706d9120a..7d5982b7d4def317fe97efffde1ba5223dfae2dc 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -371,8 +371,7 @@ ivas_error ivas_er_compute_reflections( if ( reflections->circ_len == circ_len ) { /* circ buffers exist and size is the same */ - set_f( reflections->circ_buffers, 0.0f, - reflections->shoebox_data.n_sources * reflections->circ_len ); + set_f( reflections->circ_buffers, 0.0f, reflections->shoebox_data.n_sources * reflections->circ_len ); } else { diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index a06c00c76e9f3dada7124aba5d0fc06246d60b4c..ee9b67c3b27b7307c2ec59a52301c57a68b9e6a4 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -56,11 +56,6 @@ #define CLDFB_SLOTS_PER_SECOND 800 /* Used for initializing reverb */ - -/*------------------------------------------------------------------------------------------* - * Local constants - *------------------------------------------------------------------------------------------*/ - #define INNER_BLK_SIZE 80 /* size of data blocks used for more efficient delay line and IIR filter processing */ /* should be a divisor of the frame length at any sampling rate and an even number*/ #define FFT_FILTER_WND_FLAT_REGION ( 0.40f ) /* flat section (==1) length of FFT filter window, in proportion to overlap */ @@ -1091,7 +1086,7 @@ ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ - const float *lr_energy_and_iac[], /* precomuputed lr energies and iac*/ + const float *lr_energy_and_iac[], /* i : precomuputed lr energies and iac */ RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ const int32_t output_Fs /* i : output sampling rate */ ) @@ -1810,6 +1805,7 @@ ivas_error ivas_binaural_reverb_open( const float *revTimes; float t60[CLDFB_NO_CHANNELS_MAX]; float ene[CLDFB_NO_CHANNELS_MAX]; + ivas_error error; if ( ( *hReverbPr = (REVERB_STRUCT_HANDLE) malloc( sizeof( REVERB_STRUCT ) ) ) == NULL ) { @@ -1912,7 +1908,10 @@ ivas_error ivas_binaural_reverb_open( if ( ( roomAcoustics ) && ( roomAcoustics->override ) ) { - ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfFastConv, output_config, false, sampling_rate, t60, ene ); + if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfFastConv, output_config, false, sampling_rate, t60, ene ) ) != IVAS_ERR_OK ) + { + return error; + } ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, t60, ene ); ivas_binaural_reverb_setPreDelay( hReverb, (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ) ); } @@ -1929,6 +1928,7 @@ ivas_error ivas_binaural_reverb_open( ivas_binaural_reverb_setPreDelay( hReverb, 10 ); } } + return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index bafaaa7faf262662dcc3513da62176a009846499..23d7592ce6a219c6ec2d153b512fa3e46cf9b11a 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -67,7 +67,7 @@ typedef struct cldfb_convolver_state float filter_states_im[BINAURAL_CONVBANDS][CLDFB_CONVOLVER_NTAPS_MAX]; } cldfb_convolver_state; -static void ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ); +static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ); /*-----------------------------------------------------------------------------------------* @@ -76,7 +76,7 @@ static void ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HAN * Prepares reverb parameters for CLDFB-based reverberator *-----------------------------------------------------------------------------------------*/ -void ivas_reverb_prepare_cldfb_params( +ivas_error ivas_reverb_prepare_cldfb_params( IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, @@ -89,10 +89,10 @@ void ivas_reverb_prepare_cldfb_params( float fc[CLDFB_NO_CHANNELS_MAX]; float avg_pwr_left[CLDFB_NO_CHANNELS_MAX]; float avg_pwr_right[CLDFB_NO_CHANNELS_MAX]; - float delay_diff, ln_1e6_inverted, exp_argument; const float dist = DEFAULT_SRC_DIST; const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; + ivas_error error; for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -113,14 +113,17 @@ void ivas_reverb_prepare_cldfb_params( pOutput_ene[idx] *= expf( exp_argument ); } - ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ); + if ( ( error = ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ) ) != IVAS_ERR_OK ) + { + return error; + } for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { pOutput_ene[idx] *= 0.5f * ( avg_pwr_left[idx] + avg_pwr_right[idx] ) * dmx_gain_2; } - return; + return IVAS_ERR_OK; } @@ -196,7 +199,7 @@ static void ivas_cldfb_convolver( * Function converts CLDFB filter taps into time-domain data *-----------------------------------------------------------------------------------------*/ -static void get_IR_from_filter_taps( +static ivas_error get_IR_from_filter_taps( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const int16_t hrtf_idx, const AUDIO_CONFIG input_audio_config, @@ -214,6 +217,7 @@ static void get_IR_from_filter_taps( float out_CLDFB_real[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX]; /* o : real part of Binaural signals */ float out_CLDFB_imag[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX]; /* o : imag part of Binaural signals */ float dirac_pls[CLDFB_NO_CHANNELS_MAX + 1]; + ivas_error error; block_len = (int16_t) ( sampling_rate * INV_CLDFB_BANDWIDTH ); block_count = N_INITIAL_IGNORED_FRAMES + ( pulse_length / block_len ); @@ -309,9 +313,18 @@ static void get_IR_from_filter_taps( } } - openCldfb( &handle_cldfb_analysis, CLDFB_ANALYSIS, sampling_rate, CLDFB_PROTOTYPE_5_00MS ); - openCldfb( &handle_cldfb_synthesis_l, CLDFB_SYNTHESIS, sampling_rate, CLDFB_PROTOTYPE_5_00MS ); - openCldfb( &handle_cldfb_synthesis_r, CLDFB_SYNTHESIS, sampling_rate, CLDFB_PROTOTYPE_5_00MS ); + if ( ( error = openCldfb( &handle_cldfb_analysis, CLDFB_ANALYSIS, sampling_rate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = openCldfb( &handle_cldfb_synthesis_l, CLDFB_SYNTHESIS, sampling_rate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = openCldfb( &handle_cldfb_synthesis_r, CLDFB_SYNTHESIS, sampling_rate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + { + return error; + } /* Main loop for convolving dirac pulse with CLDFB filter taps */ for ( block_idx = 0; block_idx < block_count; block_idx++ ) @@ -357,7 +370,7 @@ static void get_IR_from_filter_taps( deleteCldfb( &handle_cldfb_synthesis_l ); deleteCldfb( &handle_cldfb_synthesis_r ); - return; + return IVAS_ERR_OK; } @@ -369,7 +382,7 @@ static void get_IR_from_filter_taps( * Uses fastconv renderer filter taps to compute energies *-----------------------------------------------------------------------------------------*/ -static void ivas_reverb_get_cldfb_hrtf_set_properties( +static ivas_error ivas_reverb_get_cldfb_hrtf_set_properties( AUDIO_CONFIG input_audio_config, const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const int16_t use_brir, @@ -382,6 +395,7 @@ static void ivas_reverb_get_cldfb_hrtf_set_properties( int16_t freq_idx, hrtf_idx, hrtf_count; float hrtf_count_inverted; int16_t fft_size, IR_length, log2_fft_size, half_fft_size, freq_count; + ivas_error error; fft_size = RV_FILTER_MAX_FFT_SIZE; IR_length = CLDFB_NO_CHANNELS_MAX * ( ( fft_size + CLDFB_NO_CHANNELS_MAX - 1 ) / CLDFB_NO_CHANNELS_MAX ); @@ -415,7 +429,10 @@ static void ivas_reverb_get_cldfb_hrtf_set_properties( Loop over all the HRTFs available */ for ( hrtf_idx = 0; hrtf_idx < hrtf_count; hrtf_idx++ ) { - get_IR_from_filter_taps( hHrtfFastConv, hrtf_idx, input_audio_config, use_brir, sampling_rate, IR_length, current_HRTF_data_L, current_HRTF_data_R ); + if ( ( error = get_IR_from_filter_taps( hHrtfFastConv, hrtf_idx, input_audio_config, use_brir, sampling_rate, IR_length, current_HRTF_data_L, current_HRTF_data_R ) ) != IVAS_ERR_OK ) + { + return error; + } /* Perform forward FFT on both L/R channels */ fft_rel( current_HRTF_data_L, (int16_t) fft_size, (int16_t) log2_fft_size ); @@ -451,7 +468,7 @@ static void ivas_reverb_get_cldfb_hrtf_set_properties( avg_pwr_right[freq_idx] *= hrtf_count_inverted; } - return; + return IVAS_ERR_OK; } @@ -463,7 +480,7 @@ static void ivas_reverb_get_cldfb_hrtf_set_properties( * to CLDFB bin center frequencies *-----------------------------------------------------------------------------------------*/ -static void ivas_reverb_get_fastconv_hrtf_set_energies( +static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, @@ -477,6 +494,7 @@ static void ivas_reverb_get_fastconv_hrtf_set_energies( float avg_pwr_right_fft[FFT_SPECTRUM_SIZE]; float input_fc[FFT_SPECTRUM_SIZE]; float output_fc[CLDFB_NO_CHANNELS_MAX]; + ivas_error error; for ( freq_idx = 0; freq_idx < FFT_SPECTRUM_SIZE; freq_idx++ ) { @@ -488,9 +506,12 @@ static void ivas_reverb_get_fastconv_hrtf_set_energies( output_fc[freq_idx] = (float) ( ( 2 * freq_idx + 1 ) * cldfb_freq_halfstep ); } - ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ); + if ( ( error = ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ) ) != IVAS_ERR_OK ) + { + return error; + } ivas_reverb_interpolate_acoustic_data( FFT_SPECTRUM_SIZE, input_fc, avg_pwr_left_fft, avg_pwr_right_fft, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); - return; + return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index fac6056f35c557be5c9f12a4c4bfc589a77f61ae..b6a81bca91c88225dc31fb24f8077896d63d6c49 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -417,6 +417,7 @@ void rotateFrame_shd( tmpRot[n - m1] += cross_fade[i] * SHrotmat[n][m] * output[m][subframe_idx * subframe_len + i] + ( 1 - cross_fade[i] ) * SHrotmat_prev[n][m] * output[m][subframe_idx * subframe_len + i]; } } + /* write back the result */ for ( n = m1; n < m2; n++ ) { @@ -486,7 +487,6 @@ void rotateFrame_sd( float gains_prev[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; float output_tmp[MAX_CICP_CHANNELS][L_FRAME48k]; float cross_fade[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; - push_wmops( "rotateFrame_sd" ); nchan = hTransSetup.nchan_out_woLFE + hTransSetup.num_lfe; @@ -498,7 +498,6 @@ void rotateFrame_sd( cross_fade[i] = i * tmp; } - for ( ch_in = 0; ch_in < nchan; ch_in++ ) { /* zero output and gain buffers */ @@ -544,7 +543,6 @@ void rotateFrame_sd( } } - /* gains for current subframe rotation */ rotateAziEle( hTransSetup.ls_azimuth[ch_in_woLFE], hTransSetup.ls_elevation[ch_in_woLFE], &azimuth, &elevation, hCombinedOrientationData->Rmat[subframe_idx], hTransSetup.is_planar_setup ); if ( hEFAPdata != NULL && ( hTransSetup.ls_azimuth[ch_in_woLFE] != azimuth || hTransSetup.ls_elevation[ch_in_woLFE] != elevation ) ) @@ -600,7 +598,6 @@ void rotateFrame_sd( } pop_wmops(); - return; } @@ -725,7 +722,6 @@ void rotateFrame_sd_cldfb( float *p_real, *p_imag; int16_t nInChannels; int16_t isPlanar; - push_wmops( "rotateFrame_sd_cldfb" ); nInChannels = hOutputSetup->nchan_out_woLFE; @@ -739,7 +735,6 @@ void rotateFrame_sd_cldfb( } } - /* rotation of Euler angles */ for ( n = 0; n < nInChannels; n++ ) { @@ -816,9 +811,9 @@ void rotateFrame_sd_cldfb( *-----------------------------------------------------------------------*/ ivas_error ivas_external_orientation_open( - EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData /* o : external orientation handle */ - , - const int16_t num_subframes ) + EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData, /* o : external orientation handle */ + const int16_t num_subframes /* i : number of subframes */ +) { int16_t i; @@ -875,9 +870,9 @@ void ivas_external_orientation_close( *-----------------------------------------------------------------------*/ ivas_error ivas_combined_orientation_open( - COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* o : combined orientation handle */ - , - const int16_t num_subframes ) + COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* o : combined orientation handle */ + const int16_t num_subframes /* i : number of subframes */ +) { int16_t i; int16_t j; @@ -1020,14 +1015,11 @@ ivas_error combine_external_and_head_orientations_dec( } #endif - return combine_external_and_head_orientations( - pHeadRotQuaternion, - listenerPos, + return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, #ifdef SPLIT_REND_WITH_HEAD_ROT - sr_pose_pred_axis, + sr_pose_pred_axis, #endif - hExtOrientationData, - hCombinedOrientationData ); + hExtOrientationData, hCombinedOrientationData ); } @@ -1076,14 +1068,11 @@ ivas_error combine_external_and_head_orientations_rend( } } - return combine_external_and_head_orientations( - headRotQuaternions, - listenerPos, + return combine_external_and_head_orientations( headRotQuaternions, listenerPos, #ifdef SPLIT_REND_WITH_HEAD_ROT - sr_pose_pred_axis, + sr_pose_pred_axis, #endif - hExtOrientationData, - hCombinedOrientationData ); + hExtOrientationData, hCombinedOrientationData ); } @@ -1098,7 +1087,7 @@ ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ IVAS_VECTOR3 *listenerPos, /* i : listener position */ #ifdef SPLIT_REND_WITH_HEAD_ROT - IVAS_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis*/ + IVAS_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis */ #endif EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ @@ -1177,7 +1166,7 @@ ivas_error combine_external_and_head_orientations( if ( hExtOrientationData->enableRotationInterpolation[i] == 1 && hExtOrientationData->enableExternalOrientation[i] > 0 ) { - if ( hCombinedOrientationData->isInterpolationOngoing == TRUE && hCombinedOrientationData->interpolationCoefficient <= 1.0f && are_orientations_same( &hCombinedOrientationData->Quaternions_ext_interpolation_target, &hExtOrientationData->Quaternions[i] ) == true ) + if ( hCombinedOrientationData->isInterpolationOngoing == true && hCombinedOrientationData->interpolationCoefficient <= 1.0f && are_orientations_same( &hCombinedOrientationData->Quaternions_ext_interpolation_target, &hExtOrientationData->Quaternions[i] ) == true ) { /* Continue interpolation */ QuaternionSlerp( hCombinedOrientationData->Quaternions_ext_interpolation_start, hCombinedOrientationData->Quaternions_ext_interpolation_target, hCombinedOrientationData->interpolationCoefficient, &hCombinedOrientationData->Quaternions[i] ); @@ -1349,11 +1338,11 @@ ivas_error combine_external_and_head_orientations( * *------------------------------------------------------------------------*/ -void external_target_interpolation( - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ - , - const int16_t i ) +static void external_target_interpolation( + EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ + const int16_t i /* i : subframe index */ +) { /* Sanity check for number of frames */ hExtOrientationData->numFramesToTargetOrientation[i] = min( hExtOrientationData->numFramesToTargetOrientation[i], hCombinedOrientationData->maximumFramesToTargetOrientation ); diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index 468f61f0de2ea9be447c075a0885c61af8bd68fb..6fc30a4770c8ec8f36898aecd5f49d720ae76966 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -68,8 +68,8 @@ void ivas_sba_prototype_renderer( int16_t firstInCh, inChEnd, firstOutCh, outChEnd; int16_t slot_idx_start, md_idx; int16_t num_md_sub_frames; - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, - st_ivas->last_active_ivas_total_brate ); + + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); push_wmops( "ivas_sba_prototype_renderer" ); diff --git a/lib_rend/ivas_splitRendererPLC.c b/lib_rend/ivas_splitRendererPLC.c index 3753787df7ed50d9f84946272c626ed306c6398a..0c75b55eb6df5adc34549767aa7843ef781c0db9 100644 --- a/lib_rend/ivas_splitRendererPLC.c +++ b/lib_rend/ivas_splitRendererPLC.c @@ -459,7 +459,6 @@ void ivas_splitBinRendPLC_xf( } } - return; } @@ -486,47 +485,50 @@ void ivas_splitBinRendPLC( /* Indicate that next transition will be from a bad frame */ hSplitRendPLC->prev_bfi = 1; - { + #if CLDFB_PLC_XF > 0 - for ( i = 0; i < CLDFB_PLC_XF; i++ ) - { - xf_alp[i] = 1.0f - ( i + 1.0f ) / ( CLDFB_PLC_XF + 1.0f ); - } + for ( i = 0; i < CLDFB_PLC_XF; i++ ) + { + xf_alp[i] = 1.0f - ( i + 1.0f ) / ( CLDFB_PLC_XF + 1.0f ); + } #endif - for ( n = 0; n < num_chs; n++ ) + for ( n = 0; n < num_chs; n++ ) + { + for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { - for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + for ( k = 0; k < CLDFB_NO_COL_MAX; k++ ) { - for ( k = 0; k < CLDFB_NO_COL_MAX; k++ ) - { - prev_real[k] = hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i]; - prev_imag[k] = hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i]; - } - adaptive_polar_ext_plc( prev_real, prev_imag, rec_real, rec_imag + prev_real[k] = hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i]; + prev_imag[k] = hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i]; + } + + adaptive_polar_ext_plc( prev_real, prev_imag, rec_real, rec_imag #if CLDFB_PLC_XF > 0 - , - xf_alp, hSplitRendPLC->CldfbPLC_state.xf_bet[n][i] + , + xf_alp, hSplitRendPLC->CldfbPLC_state.xf_bet[n][i] #endif - ); - for ( k = 0; k < CLDFB_NO_COL_MAX; k++ ) - { - Cldfb_RealBuffer_Binaural[n][k][i] = rec_real[k]; - hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i] = rec_real[k]; - Cldfb_ImagBuffer_Binaural[n][k][i] = rec_imag[k]; - hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i] = rec_imag[k]; - } + ); + + for ( k = 0; k < CLDFB_NO_COL_MAX; k++ ) + { + Cldfb_RealBuffer_Binaural[n][k][i] = rec_real[k]; + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i] = rec_real[k]; + Cldfb_ImagBuffer_Binaural[n][k][i] = rec_imag[k]; + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i] = rec_imag[k]; + } + #if CLDFB_PLC_XF > 0 - for ( k = CLDFB_NO_COL_MAX; k < CLDFB_NO_COL_MAX + CLDFB_PLC_XF; k++ ) - { - hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i] = rec_real[k]; - hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i] = rec_imag[k]; - } -#endif + for ( k = CLDFB_NO_COL_MAX; k < CLDFB_NO_COL_MAX + CLDFB_PLC_XF; k++ ) + { + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinReal[n][k][i] = rec_real[k]; + hSplitRendPLC->CldfbPLC_state.Cldfb_Prev_BinImag[n][k][i] = rec_imag[k]; } +#endif } } + /* Check bf counter */ if ( hSplitRendPLC->bf_count++ >= SR_PLC_FADE_START ) { diff --git a/lib_rend/ivas_splitRendererPost.c b/lib_rend/ivas_splitRendererPost.c index 042f34d9e065e2d7983d841ad9ecc475f94815c3..68bfb726ad090b94f37cf51a738421f71ebfc8f0 100644 --- a/lib_rend/ivas_splitRendererPost.c +++ b/lib_rend/ivas_splitRendererPost.c @@ -62,7 +62,6 @@ ivas_error ivas_splitBinPostRendOpen( ivas_error error; int16_t ch; - error = IVAS_ERR_OK; if ( ( hBinRend = (BIN_HR_SPLIT_POST_REND_HANDLE) malloc( sizeof( BIN_HR_SPLIT_POST_REND ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for bin split post renderer Module \n" ) ); @@ -113,7 +112,7 @@ ivas_error ivas_splitBinPostRendOpen( ivas_split_rend_init_huff_cfg( &hBinRend->huff_cfg ); *hBinHrSplitPostRend = hBinRend; - return error; + return IVAS_ERR_OK; } @@ -244,6 +243,12 @@ static int16_t ivas_split_rend_huffman_decode_opt( return (int16_t) ind; } +/*-----------------------------------------------------------------------------------------* + * Function ivas_split_rend_unquant_md() + * + * + *-----------------------------------------------------------------------------------------*/ + static void ivas_split_rend_unquant_md( BIN_HR_SPLIT_REND_MD_HANDLE hMd, IVAS_SPLIT_REND_POSE_TYPE pose_type, @@ -1095,7 +1100,8 @@ void ivas_splitBinPostRendMdDec( * *-----------------------------------------------------------------------------------------*/ -static void wrap_around_angle( float *a ) +static void wrap_around_angle( + float *a ) { if ( ( *a ) > 180.0f ) { @@ -1108,13 +1114,15 @@ static void wrap_around_angle( float *a ) return; } + /*-----------------------------------------------------------------------------------------* * Function wrap_around_angle() * * *-----------------------------------------------------------------------------------------*/ -static void wrap_around_ypr( IVAS_QUATERNION *Quaternions ) +static void wrap_around_ypr( + IVAS_QUATERNION *Quaternions ) { /*only if quat is actually yaw, pitch , roll angles*/ if ( Quaternions->w == -3.0f ) @@ -1133,9 +1141,13 @@ static void wrap_around_ypr( IVAS_QUATERNION *Quaternions ) * *-----------------------------------------------------------------------------------------*/ -static float get_interp_fact( float p[MAX_HEAD_ROT_POSES], float p_t, int16_t ind[2] ) +static float get_interp_fact( + float p[MAX_HEAD_ROT_POSES], + const float p_t, + const int16_t ind[2] ) { float n, d, interp_fact; + if ( ind[0] != ind[1] ) { n = p[ind[0]] - p[ind[1]]; @@ -1176,6 +1188,7 @@ static void get_nearest_pose_ind( ind[0] = 0; ind[1] = 0; min_diff = 360.0f; + /*find the closest pose from assumed poses*/ for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { @@ -1525,8 +1538,6 @@ static void interpolate_rend_md( idx2 = interp_roll_pose_idx[1]; if ( ( idx1 != 0 ) || ( idx2 != 0 ) ) { - - interpolate_pred_matrix( rot_md, sf_idx, band_idx, interp_roll_pose_idx, interp_roll_fact, mix_mat_re3, mix_mat_im3 ); ivas_mat_mult_2by2_complex( mix_mat_re, mix_mat_im, mix_mat_re3, mix_mat_im3, mix_mat_re1, mix_mat_im1 ); @@ -1591,15 +1602,8 @@ void ivas_SplitRenderer_PostRenderer( #endif sf_idx_md = 0; - get_interpolation_vars( pMultiBinPoseData, - &hBinPostRenderer->QuaternionsPre[sf_idx_md], - &Quaternion_act, - interp_yaw_pose_idx, - interp_pitch_pose_idx, - interp_roll_pose_idx, - &interp_yaw_fact, - &interp_pitch_fact, - &interp_roll_fact ); + get_interpolation_vars( pMultiBinPoseData, &hBinPostRenderer->QuaternionsPre[sf_idx_md], &Quaternion_act, interp_yaw_pose_idx, interp_pitch_pose_idx, interp_roll_pose_idx, &interp_yaw_fact, &interp_pitch_fact, &interp_roll_fact ); + for ( b = 0; b < num_md_bands; b++ ) { for ( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) @@ -1822,9 +1826,7 @@ static void ivas_rend_CldfbSplitPostRendProcessTdIn( /* Implement CLDFB analysis */ for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { - for ( slot_idx = 0; - slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; - slot_idx++ ) + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { cldfbAnalysis_ts( &( output[ch_idx][num_cldfb_bands * slot_idx] ), Cldfb_RealBuffer_Binaural[ch_idx][slot_idx], @@ -1834,12 +1836,7 @@ static void ivas_rend_CldfbSplitPostRendProcessTdIn( } } - ivas_SplitRenderer_PostRenderer( - hBinHrSplitPostRend, - pMultiBinPoseData, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - QuaternionPost ); + ivas_SplitRenderer_PostRenderer( hBinHrSplitPostRend, pMultiBinPoseData, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, QuaternionPost ); /* Implement CLDFB synthesis */ for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) @@ -1847,17 +1844,13 @@ static void ivas_rend_CldfbSplitPostRendProcessTdIn( float *RealBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; float *ImagBuffer[CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES]; - for ( slot_idx = 0; - slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; - slot_idx++ ) + for ( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { RealBuffer[slot_idx] = Cldfb_RealBuffer_Binaural[ch_idx][slot_idx]; ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch_idx][slot_idx]; } - cldfbSynthesis( RealBuffer, ImagBuffer, &( output[ch_idx][0] ), - num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, - hBinHrSplitPostRend->cldfbSyn[ch_idx] ); + cldfbSynthesis( RealBuffer, ImagBuffer, &( output[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); } return; @@ -1877,7 +1870,7 @@ void ivas_rend_CldfbSplitPostRendProcess( float Cldfb_RealBuffer_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float output[][L_FRAME48k], - const int16_t is_cldfb_in ) + const int16_t cldfb_in_flag ) { int16_t ch_idx, slot_idx, num_cldfb_bands; @@ -1885,21 +1878,14 @@ void ivas_rend_CldfbSplitPostRendProcess( num_cldfb_bands = hBinHrSplitPostRend->cldfbSyn[0]->no_channels; - if ( is_cldfb_in == 0 ) + if ( cldfb_in_flag == 0 ) { - ivas_rend_CldfbSplitPostRendProcessTdIn( hBinHrSplitPostRend, pMultiBinPoseData, - QuaternionPost, - output ); + ivas_rend_CldfbSplitPostRendProcessTdIn( hBinHrSplitPostRend, pMultiBinPoseData, QuaternionPost, output ); pop_wmops(); return; } - ivas_SplitRenderer_PostRenderer( - hBinHrSplitPostRend, - pMultiBinPoseData, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - QuaternionPost ); + ivas_SplitRenderer_PostRenderer( hBinHrSplitPostRend, pMultiBinPoseData, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, QuaternionPost ); /* Implement CLDFB synthesis */ for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) @@ -1913,13 +1899,10 @@ void ivas_rend_CldfbSplitPostRendProcess( ImagBuffer[slot_idx] = Cldfb_ImagBuffer_Binaural[ch_idx][slot_idx]; } - cldfbSynthesis( RealBuffer, ImagBuffer, &( output[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, - hBinHrSplitPostRend->cldfbSyn[ch_idx] ); + cldfbSynthesis( RealBuffer, ImagBuffer, &( output[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); } - pop_wmops(); - return; } diff --git a/lib_rend/ivas_splitRendererPre.c b/lib_rend/ivas_splitRendererPre.c index 91cbd044ee4df3b2514883635ac6e89323e03e4a..2be6e7429d61ccfec3fc575ab9b94cf5a9a6076c 100644 --- a/lib_rend/ivas_splitRendererPre.c +++ b/lib_rend/ivas_splitRendererPre.c @@ -472,7 +472,7 @@ static void ivas_split_rend_quant_md( float fix_pos_rot_mat[][BINAURAL_CHANNELS] #ifdef SPLIT_REND_PRED_QUANT_63_PNTS , - float pred_1byquantstep + const float pred_1byquantstep #endif ) { @@ -1238,12 +1238,11 @@ static void ivas_SplitRenderer_quant_code( overhead_bits = pBits->bits_written - overhead_bits + quant_strat_bits + 1; /* 1 for base2 vs huff */ - get_base2_bits( - hBinHrSplitPreRend, pMultiBinPoseData, num_subframes, num_quant_strats, pred_real_bands_yaw, pred_imag_bands_yaw, + get_base2_bits( hBinHrSplitPreRend, pMultiBinPoseData, num_subframes, num_quant_strats, pred_real_bands_yaw, pred_imag_bands_yaw, #ifdef SPLIT_REND_PRED_QUANT_63_PNTS - pred_quant_pnts_yaw, + pred_quant_pnts_yaw, #endif - d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, base2bits ); + d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, base2bits ); for ( q = 0; q < num_quant_strats; q++ ) { @@ -1360,6 +1359,7 @@ static void ivas_SplitRenderer_quant_code( pred_real_bands_roll[q], pred_imag_bands_roll[q], pBits ); + huff_bits = pBits->bits_written - huff_bits; if ( ( target_md_bits >= ( base2bits[q] + overhead_bits ) ) || ( target_md_bits >= ( huff_bits + overhead_bits ) ) || ( q == ( num_quant_strats - 1 ) ) ) @@ -1484,7 +1484,6 @@ void ivas_SplitRenderer_GetRotMd( float cov_oo_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; float cov_io_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; int16_t real_only = 0; - int16_t pos_idx, b, sf_idx, start_slot_idx, num_slots, num_subframes, ch_s_idx1, ch_s_idx2; int16_t num_md_bands, num_poses; const int16_t *pBand_grouping = ivas_split_rend_band_grouping; @@ -1537,7 +1536,6 @@ void ivas_SplitRenderer_GetRotMd( } pop_wmops(); - return; } @@ -1562,13 +1560,7 @@ void ivas_rend_CldfbSplitPreRendProcess( ivas_SplitRenderer_GetRotMd( hBinHrSplitPreRend, pMultiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, low_res_pre_rend_rot ); - ivas_SplitRenderer_quant_code( - hBinHrSplitPreRend, - headPosition, - pMultiBinPoseData, - pBits, - low_res_pre_rend_rot, - target_md_bits ); + ivas_SplitRenderer_quant_code( hBinHrSplitPreRend, headPosition, pMultiBinPoseData, pBits, low_res_pre_rend_rot, target_md_bits ); #ifdef SPLIT_POSE_CORRECTION_DEBUG float tmpCrendBuffer[2][L_FRAME48k], quant_val, step, minv, maxv; @@ -1663,7 +1655,6 @@ void ivas_rend_CldfbSplitPreRendProcess( #endif pop_wmops(); - return; } @@ -1684,13 +1675,12 @@ ivas_error ivas_splitBinPreRendOpen( ) { BIN_HR_SPLIT_PRE_REND_HANDLE hBinRend; - ivas_error error; #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + ivas_error error; int16_t ch; #endif int16_t pos_idx, sf_idx, bandIdx; - error = IVAS_ERR_OK; if ( ( hBinRend = (BIN_HR_SPLIT_PRE_REND_HANDLE) malloc( sizeof( BIN_HR_SPLIT_PRE_REND ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for bin split pre renderer Module \n" ) ); @@ -1735,12 +1725,15 @@ ivas_error ivas_splitBinPreRendOpen( ivas_split_rend_init_huff_cfg( &hBinRend->huff_cfg ); #ifdef SPLIT_POSE_CORRECTION_DEBUG - ivas_splitBinPostRendOpen( &hBinRend->hBinHrSplitPostRend, pMultiBinPoseData, 48000 ); + if ( ( error = ivas_splitBinPostRendOpen( &hBinRend->hBinHrSplitPostRend, pMultiBinPoseData, 48000 ) ) != IVAS_ERR_OK ) + { + return error; + } #endif *hBinHrSplitPreRend = hBinRend; - return error; + return IVAS_ERR_OK; } @@ -1782,6 +1775,13 @@ void ivas_splitBinPreRendClose( return; } + +/*-------------------------------------------------------------------------* + * ivas_set_split_rend_ht_setup() + * + * + *-------------------------------------------------------------------------*/ + void ivas_set_split_rend_ht_setup( IVAS_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ) @@ -1802,8 +1802,11 @@ void ivas_set_split_rend_ht_setup( } } } + return; } + + /*-------------------------------------------------------------------------* * ivas_set_split_rend_setup() * @@ -1817,7 +1820,9 @@ ivas_error ivas_set_split_rend_setup( IVAS_SPLIT_REND_BITS_HANDLE hSplitRendBits ) { int16_t sf, i, j; + hSplitBinRend->hSplitRendBits = hSplitRendBits; + if ( ( hSplitBinRend->hMultiBinCldfbData = (IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( IVAS_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); @@ -1877,15 +1882,18 @@ void ivas_init_split_rend_handles( return; } + /*------------------------------------------------------------------------- * Function split_renderer_open_lc3plus() * * *------------------------------------------------------------------------*/ -static ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWrapper, - const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int32_t OutSampleRate, - const int16_t is_5ms_frame ) + +static ivas_error split_renderer_open_lc3plus( + SPLIT_REND_WRAPPER *hSplitRendWrapper, + const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const int32_t OutSampleRate, + const int16_t is_5ms_frame ) { ivas_error error; int16_t i, delayBufferLength; @@ -1905,16 +1913,13 @@ static ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWra config.channels = BINAURAL_CHANNELS; - error = IVAS_LC3PLUS_ENC_Open( config, ivas_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, (int16_t) ( config.ivas_frame_duration_us / 1000 ) ), - &hSplitRendWrapper->hLc3plusEnc ); - if ( error != IVAS_ERR_OK ) + if ( ( error = IVAS_LC3PLUS_ENC_Open( config, ivas_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, (int16_t) ( config.ivas_frame_duration_us / 1000 ) ), &hSplitRendWrapper->hLc3plusEnc ) ) != IVAS_ERR_OK ) { return error; } /* This returns delay of entire LC3plus chain (enc + dec) */ - error = IVAS_LC3PLUS_ENC_GetDelay( hSplitRendWrapper->hLc3plusEnc, &hSplitRendWrapper->lc3plusDelaySamples ); - if ( error != IVAS_ERR_OK ) + if ( ( error = IVAS_LC3PLUS_ENC_GetDelay( hSplitRendWrapper->hLc3plusEnc, &hSplitRendWrapper->lc3plusDelaySamples ) ) != IVAS_ERR_OK ) { return error; } @@ -1954,17 +1959,20 @@ static ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWra return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * Function ivas_split_renderer_open() * * *------------------------------------------------------------------------*/ -ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, - const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int32_t OutSampleRate, - const int16_t is_cldfb_in, - const int16_t is_pcm_out, - const int16_t is_5ms_frame ) + +ivas_error ivas_split_renderer_open( + SPLIT_REND_WRAPPER *hSplitRendWrapper, + const IVAS_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, + const int32_t OutSampleRate, + const int16_t cldfb_in_flag, + const int16_t pcm_out_flag, + const int16_t is_5ms_frame ) { ivas_error error, ch, num_ch; #ifndef OSBA_SPLIT_RENDERING @@ -1975,21 +1983,19 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, cldfbMode = CLDFB_ANALYSIS; #endif - if ( ( error = ivas_split_rend_validate_config( pSplitRendConfig, is_pcm_out ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_split_rend_validate_config( pSplitRendConfig, pcm_out_flag ) ) != IVAS_ERR_OK ) { return error; } - error = IVAS_ERR_OK; - - if ( is_cldfb_in == 0 ) + if ( cldfb_in_flag == 0 ) { isCldfbNeeded = 1; #ifndef OSBA_SPLIT_RENDERING cldfbMode = CLDFB_ANALYSIS; #endif } - else if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && is_cldfb_in ) + else if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) { #ifdef OSBA_SPLIT_RENDERING isCldfbNeeded = 1; @@ -1998,7 +2004,7 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, cldfbMode = CLDFB_SYNTHESIS; #endif } - else if ( is_pcm_out && is_cldfb_in ) + else if ( pcm_out_flag && cldfb_in_flag ) { #ifdef OSBA_SPLIT_RENDERING isCldfbNeeded = 1; @@ -2029,7 +2035,6 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, } #endif - num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; for ( ch = 0; ch < num_ch; ch++ ) @@ -2049,9 +2054,7 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, #ifdef OSBA_SPLIT_RENDERING for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), - CLDFB_SYNTHESIS, - OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } @@ -2072,13 +2075,11 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, } } - if ( is_pcm_out == 0 ) + if ( pcm_out_flag == 0 ) { if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS ) { - error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, - is_5ms_frame ); - if ( error != IVAS_ERR_OK ) + if ( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, is_5ms_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -2092,7 +2093,7 @@ ivas_error ivas_split_renderer_open( SPLIT_REND_WRAPPER *hSplitRendWrapper, } } - return error; + return IVAS_ERR_OK; } @@ -2237,7 +2238,7 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural( const int16_t max_bands, float *in[], const int16_t low_res_pre_rend_rot, - const int16_t pcm_out ) + const int16_t pcm_out_flag ) { ivas_error error; int32_t bit_len, available_bits, target_md_bits, actual_md_bits; @@ -2277,9 +2278,9 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural( } actual_md_bits = pBits->bits_written; - if ( ( hSplitBin->multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) || ( !useLc3plus && !pcm_out ) ) + if ( ( hSplitBin->multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) || ( !useLc3plus && !pcm_out_flag ) ) { - if ( !useLc3plus && codec_frame_size_ms != 20 && !pcm_out ) + if ( !useLc3plus && codec_frame_size_ms != 20 && !pcm_out_flag ) { return IVAS_ERROR( IVAS_ERR_INVALID_INPUT_BUFFER_SIZE, "Unsupported framing for LCLD codec!" ); } @@ -2318,21 +2319,14 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural( if ( hSplitBin->multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - target_md_bits = ivas_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out ) * L_FRAME48k / 48000; + target_md_bits = ivas_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000; actual_md_bits = pBits->bits_written; - ivas_rend_CldfbSplitPreRendProcess( - hSplitBin->hBinHrSplitPreRend, - headPosition, - &hSplitBin->multiBinPoseData, - Cldfb_In_BinReal, - Cldfb_In_BinImag, - pBits, - target_md_bits, - low_res_pre_rend_rot ); + + ivas_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot ); } - if ( pcm_out == 0 ) + if ( pcm_out_flag == 0 ) { pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; pBits->codec = useLc3plus ? IVAS_SPLIT_REND_CODEC_LC3PLUS : IVAS_SPLIT_REND_CODEC_LCLD; @@ -2343,12 +2337,8 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural( actual_md_bits = pBits->bits_written - actual_md_bits; available_bits -= actual_md_bits; pBits->codec_frame_size_ms = 20; - ivas_splitBinLCLDEncProcess( - hSplitBin->hSplitBinLCLDEnc, - Cldfb_In_BinReal, - Cldfb_In_BinImag, - available_bits, - pBits ); + + ivas_splitBinLCLDEncProcess( hSplitBin->hSplitBinLCLDEnc, Cldfb_In_BinReal, Cldfb_In_BinImag, available_bits, pBits ); } else { @@ -2365,7 +2355,7 @@ static ivas_error ivas_renderMultiTDBinToSplitBinaural( } /*zero pad*/ - if ( pcm_out ) + if ( pcm_out_flag ) { bit_len = SplitRendBitRate / FRAMES_PER_SEC; } @@ -2473,13 +2463,13 @@ ivas_error ivas_renderMultiBinToSplitBinaural( const int16_t max_bands, float *output[], const int16_t low_res_pre_rend_rot, - int16_t td_input, - const int16_t pcm_out ) + const int16_t cldfb_in_flag, + const int16_t pcm_out_flag ) { ivas_error error; int32_t bit_len, target_md_bits, actual_md_bits, available_bits; - error = IVAS_ERR_OK; + error = IVAS_ERR_OK; push_wmops( "ivas_renderMultiBinToSplitBinaural" ); if ( hSplitBin->multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) @@ -2491,21 +2481,17 @@ ivas_error ivas_renderMultiBinToSplitBinaural( /* Needs to be done at runtime. If this was in another API function, * there would be no guarantee that the user did not change * the split rendering config before calling the main rendering function */ - if ( ( error = ivas_split_rend_choose_default_codec( &splitCodec, &codec_frame_size_ms, td_input, pcm_out ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_split_rend_choose_default_codec( &splitCodec, &codec_frame_size_ms, cldfb_in_flag, pcm_out_flag ) ) != IVAS_ERR_OK ) { return error; } - if ( td_input ) + if ( cldfb_in_flag == 0 ) { /*TD input*/ /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ - error = ivas_renderMultiTDBinToSplitBinaural( hSplitBin, - headPosition, - SplitRendBitRate, - codec_frame_size_ms, - pBits, max_bands, output, - low_res_pre_rend_rot, pcm_out ); + error = ivas_renderMultiTDBinToSplitBinaural( hSplitBin, headPosition, SplitRendBitRate, codec_frame_size_ms, pBits, max_bands, output, low_res_pre_rend_rot, pcm_out_flag ); + pop_wmops(); return error; } @@ -2519,21 +2505,13 @@ ivas_error ivas_renderMultiBinToSplitBinaural( actual_md_bits = pBits->bits_written; if ( hSplitBin->multiBinPoseData.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - target_md_bits = ivas_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out ) * L_FRAME48k / 48000; + target_md_bits = ivas_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000; actual_md_bits = pBits->bits_written; - ivas_rend_CldfbSplitPreRendProcess( - hSplitBin->hBinHrSplitPreRend, - headPosition, - &hSplitBin->multiBinPoseData, - Cldfb_In_BinReal, - Cldfb_In_BinImag, - pBits, - target_md_bits, - low_res_pre_rend_rot ); + ivas_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot ); } - if ( pcm_out == 0 ) + if ( pcm_out_flag == 0 ) { pBits->codec = splitCodec; pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; @@ -2588,6 +2566,7 @@ ivas_error ivas_renderMultiBinToSplitBinaural( Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx]; Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx]; } + #ifndef OSBA_SPLIT_RENDERING cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, output[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] ); #else @@ -2601,7 +2580,7 @@ ivas_error ivas_renderMultiBinToSplitBinaural( /*zero pad*/ /*TODO: do this inside the LCLD ENC codec */ - if ( pcm_out ) + if ( pcm_out_flag ) { bit_len = SplitRendBitRate / FRAMES_PER_SEC; } diff --git a/lib_rend/ivas_splitRenderer_utils.c b/lib_rend/ivas_splitRenderer_utils.c index 0e371c9f6dd749877caae5350f24f285d5809a13..3583294f61cc16cbeaddac3c1e26e5fde4627412 100644 --- a/lib_rend/ivas_splitRenderer_utils.c +++ b/lib_rend/ivas_splitRenderer_utils.c @@ -503,11 +503,11 @@ void ivas_log_cldfb2wav_data( int32_t ivas_get_split_rend_md_target_brate( const int32_t SplitRendBitRate, - const int16_t pcm_out ) + const int16_t pcm_out_flag ) { int32_t md_bitrate; - if ( pcm_out == 1 ) + if ( pcm_out_flag == 1 ) { md_bitrate = SplitRendBitRate; } @@ -577,22 +577,28 @@ int32_t ivas_get_lcld_bitrate( { return SplitRendBitRate; } + return -1; } + /*------------------------------------------------------------------------- * Function ivas_get_lc3plus_bitrate() * * *------------------------------------------------------------------------*/ -int32_t ivas_get_lc3plus_bitrate( const int32_t SplitRendBitRate, IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, int16_t split_prerender_frame_size_ms ) + +int32_t ivas_get_lc3plus_bitrate( + const int32_t SplitRendBitRate, + IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int16_t split_prerender_frame_size_ms ) { if ( poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - int32_t inBandMdBps = (int32_t) ( 8 * 1000 / - split_prerender_frame_size_ms ); + int32_t inBandMdBps = (int32_t) ( 8 * 1000 / split_prerender_frame_size_ms ); return ivas_get_lcld_bitrate( SplitRendBitRate, poseCorrectionMode ) - inBandMdBps; } + if ( poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) { return SplitRendBitRate; @@ -640,6 +646,7 @@ int8_t ivas_get_lc3plus_bitrate_id( break; } } + return -1; } @@ -649,7 +656,11 @@ int8_t ivas_get_lc3plus_bitrate_id( * * *------------------------------------------------------------------------*/ -int32_t ivas_get_lc3plus_size_from_id( const int8_t SplitRendBitRateId, IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, int16_t split_prerender_frame_size_ms ) + +int32_t ivas_get_lc3plus_size_from_id( + const int8_t SplitRendBitRateId, + const IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int16_t split_prerender_frame_size_ms ) { int32_t bitrate; @@ -687,12 +698,10 @@ int32_t ivas_get_lc3plus_size_from_id( const int8_t SplitRendBitRateId, IVAS_SPL } } - bitrate = ivas_get_lc3plus_bitrate( bitrate, poseCorrectionMode, - split_prerender_frame_size_ms ); + bitrate = ivas_get_lc3plus_bitrate( bitrate, poseCorrectionMode, split_prerender_frame_size_ms ); /* Return size in bytes */ - return (int32_t) ( bitrate * - split_prerender_frame_size_ms / 1000 / 8 ); + return (int32_t) ( bitrate * split_prerender_frame_size_ms / 1000 / 8 ); } @@ -731,8 +740,8 @@ ivas_error ivas_split_rend_validate_config( { return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Invalid framing for LCLD codec" ); } - if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && - ( pSplitRendConfig->codec_frame_size_ms != 5 && pSplitRendConfig->codec_frame_size_ms != 10 ) ) + + if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && ( pSplitRendConfig->codec_frame_size_ms != 5 && pSplitRendConfig->codec_frame_size_ms != 10 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Invalid framing for LC3plus codec" ); } @@ -1070,17 +1079,19 @@ void ivas_init_multi_bin_pose_data( * * *------------------------------------------------------------------------*/ -ivas_error -ivas_split_rend_choose_default_codec( IVAS_SPLIT_REND_CODEC *pCodec, - int16_t *pCodec_frame_size_ms, - int16_t isRenderingInTd, - int16_t pcm_out ) + +ivas_error ivas_split_rend_choose_default_codec( + IVAS_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ + int16_t *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ + const int16_t cldfb_in_flag, /* i : flag indicating rendering in TD */ + const int16_t pcm_out_flag /* i : flag to indicate PCM output */ +) { - if ( pcm_out == 0 ) + if ( pcm_out_flag == 0 ) { if ( *pCodec == IVAS_SPLIT_REND_CODEC_DEFAULT ) { - *pCodec = isRenderingInTd ? IVAS_SPLIT_REND_CODEC_LC3PLUS : IVAS_SPLIT_REND_CODEC_LCLD; + *pCodec = cldfb_in_flag ? IVAS_SPLIT_REND_CODEC_LCLD : IVAS_SPLIT_REND_CODEC_LC3PLUS; } } else diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index d4e177167eca24883454db5be02e945073e255c4..87566670acce011e2e78ed7a9571f246a5088467 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -66,7 +66,6 @@ #define MAX_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) #endif - #define MAX_BIN_DELAY_SAMPLES 50 /* Maximum supported rendering latency for binaural IRs */ /* Frame size required when rendering to binaural */ @@ -275,7 +274,9 @@ struct IVAS_REND * Local functions *-------------------------------------------------------------------*/ -static ivas_error allocateInputBaseBufferData( float **data, const int16_t data_size ) +static ivas_error allocateInputBaseBufferData( + float **data, + const int16_t data_size ) { *data = (float *) malloc( data_size * sizeof( float ) ); if ( *data == NULL ) @@ -286,7 +287,8 @@ static ivas_error allocateInputBaseBufferData( float **data, const int16_t data_ return IVAS_ERR_OK; } -static void freeInputBaseBufferData( float **data ) +static void freeInputBaseBufferData( + float **data ) { if ( *data != NULL ) { @@ -297,7 +299,9 @@ static void freeInputBaseBufferData( float **data ) return; } -static ivas_error allocateMcLfeDelayBuffer( float **lfeDelayBuffer, const int16_t data_size ) +static ivas_error allocateMcLfeDelayBuffer( + float **lfeDelayBuffer, + const int16_t data_size ) { *lfeDelayBuffer = (float *) malloc( data_size * sizeof( float ) ); if ( *lfeDelayBuffer == NULL ) @@ -308,7 +312,8 @@ static ivas_error allocateMcLfeDelayBuffer( float **lfeDelayBuffer, const int16_ return IVAS_ERR_OK; } -static void freeMcLfeDelayBuffer( float **lfeDelayBuffer ) +static void freeMcLfeDelayBuffer( + float **lfeDelayBuffer ) { if ( *lfeDelayBuffer != NULL ) { @@ -738,6 +743,7 @@ static ivas_error initLimiter( return IVAS_ERR_OK; } + static LSSETUP_CUSTOM_STRUCT defaultCustomLs( void ) { @@ -757,6 +763,7 @@ static LSSETUP_CUSTOM_STRUCT defaultCustomLs( return ls; } + static ivas_error getSpeakerAzimuths( AUDIO_CONFIG config, const float **azimuths ) @@ -791,6 +798,7 @@ static ivas_error getSpeakerAzimuths( return IVAS_ERR_OK; } + static ivas_error getSpeakerElevations( AUDIO_CONFIG config, const float **elevations ) @@ -825,6 +833,7 @@ static ivas_error getSpeakerElevations( return IVAS_ERR_OK; } + static ivas_error getAmbisonicsOrder( AUDIO_CONFIG config, int16_t *order ) @@ -847,6 +856,7 @@ static ivas_error getAmbisonicsOrder( return IVAS_ERR_OK; } + static int16_t getNumLfeChannels( input_mc *inputMc ) { @@ -908,6 +918,7 @@ static ivas_error getMcConfigValues( int16_t *is_planar ) { int16_t i; + ivas_error error; *lfe_idx = -1; *is_planar = 1; @@ -931,16 +942,28 @@ static ivas_error getMcConfigValues( break; case IVAS_AUDIO_CONFIG_MONO: case IVAS_AUDIO_CONFIG_STEREO: - getSpeakerAzimuths( inConfig, azimuth ); - getSpeakerElevations( inConfig, elevation ); + if ( ( error = getSpeakerAzimuths( inConfig, azimuth ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = getSpeakerElevations( inConfig, elevation ) ) != IVAS_ERR_OK ) + { + return error; + } break; case IVAS_AUDIO_CONFIG_5_1: case IVAS_AUDIO_CONFIG_7_1: case IVAS_AUDIO_CONFIG_5_1_2: case IVAS_AUDIO_CONFIG_5_1_4: case IVAS_AUDIO_CONFIG_7_1_4: - getSpeakerAzimuths( inConfig, azimuth ); - getSpeakerElevations( inConfig, elevation ); + if ( ( error = getSpeakerAzimuths( inConfig, azimuth ) ) != IVAS_ERR_OK ) + { + return error; + } + if ( ( error = getSpeakerElevations( inConfig, elevation ) ) != IVAS_ERR_OK ) + { + return error; + } *lfe_idx = LFE_CHANNEL; *is_planar = ( inConfig == IVAS_AUDIO_CONFIG_5_1 || inConfig == IVAS_AUDIO_CONFIG_7_1 ) ? 1 : 0; break; @@ -952,6 +975,7 @@ static ivas_error getMcConfigValues( return IVAS_ERR_OK; } + static ivas_error initEfap( EFAP_WRAPPER *pEfapWrapper, AUDIO_CONFIG outConfig, @@ -1018,6 +1042,7 @@ static ivas_error initEfap( return IVAS_ERR_OK; } + static ivas_error getEfapGains( EFAP_WRAPPER efapWrapper, const float azi, @@ -1080,6 +1105,7 @@ static ivas_error getEfapGains( return IVAS_ERR_OK; } + static ivas_error initHeadRotation( IVAS_REND_HANDLE hIvasRend ) { @@ -1206,6 +1232,7 @@ static IVAS_REND_AudioObjectPosition defaultObjectPosition( return pos; } + #ifdef FIX_518_ISM_BRIR_EXTREND static int8_t checkObjectPositionChanged( IVAS_REND_AudioObjectPosition *currentPos, @@ -1216,6 +1243,7 @@ static int8_t checkObjectPositionChanged( } #endif + static rendering_context getRendCtx( IVAS_REND_HANDLE hIvasRend ) { @@ -1288,6 +1316,7 @@ static bool isIoConfigPairSupported( return true; } + static ivas_error initIsmMasaRendering( input_ism *inputIsm, const int32_t inSampleRate ) @@ -1300,12 +1329,11 @@ static ivas_error initIsmMasaRendering( inputIsm->tdRendWrapper.hHrtfTD = NULL; } - ivas_rend_closeCrend( &inputIsm->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputIsm->crendWrapper ); #endif - ); ivas_reverb_close( &inputIsm->hReverb ); @@ -1392,11 +1420,7 @@ static ivas_error setRendInputActiveIsm( /* Open TD renderer wrappers */ for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { - if ( ( error = ivas_td_binaural_open_ext( &inputIsm->splitTdRendWrappers[i], - inConfig, - hRendCfg, - NULL, - *inputIsm->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_open_ext( &inputIsm->splitTdRendWrappers[i], inConfig, hRendCfg, NULL, *inputIsm->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -1442,12 +1466,11 @@ static ivas_error setRendInputActiveIsm( } else if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { - if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT - , - rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses + if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1473,13 +1496,11 @@ static void clearInputIsm( initRendInputBase( &inputIsm->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); /* Free input's internal handles */ - - ivas_rend_closeCrend( &inputIsm->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputIsm->crendWrapper ); #endif - ); ivas_reverb_close( &inputIsm->hReverb ); @@ -2175,14 +2196,11 @@ static ivas_error initMcBinauralRendering( inputMc->splitTdRendWrappers[i].hHrtfTD = NULL; } } -#endif - ivas_rend_closeCrend( &inputMc->crendWrapper -#ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputMc->crendWrapper ); #endif - ); ivas_reverb_close( &inputMc->hReverb ); @@ -2248,16 +2266,14 @@ static ivas_error initMcBinauralRendering( } } - { - if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT - , - ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 + if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, NULL, outSampleRate ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) - { - return error; - } + + { + return error; } /* Initialise the EFAP handle for rotation on input layout */ @@ -2295,12 +2311,11 @@ static ivas_error initMcMasaRendering( inputMc->tdRendWrapper.hHrtfTD = NULL; } - ivas_rend_closeCrend( &inputMc->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputMc->crendWrapper ); #endif - ); ivas_reverb_close( &inputMc->hReverb ); @@ -2486,12 +2501,12 @@ static void clearInputMc( efap_free_data( &inputMc->efapInWrapper.hEfap ); } - ivas_rend_closeCrend( &inputMc->crendWrapper + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputMc->crendWrapper ); #endif - ); ivas_reverb_close( &inputMc->hReverb ); @@ -2617,7 +2632,12 @@ static ivas_error updateSplitPostRendPanGains( ivas_error error; rendering_context rendCtx; int16_t numOutChannels; - getAudioConfigNumChannels( outConfig, &numOutChannels ); + + if ( ( error = getAudioConfigNumChannels( outConfig, &numOutChannels ) ) != IVAS_ERR_OK ) + { + + return error; + } rendCtx = inputSplitPostRend->base.ctx; ivas_renderSplitGetMultiBinPoseData( &hRendCfg->split_rend_config, &inputSplitPostRend->splitPostRendWrapper.multiBinPoseData, rendCtx.pHeadRotData->sr_pose_pred_axis ); @@ -2694,12 +2714,12 @@ static ivas_error updateSbaPanGains( else #endif { - if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT - , - rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) + { return error; } @@ -2712,12 +2732,11 @@ static ivas_error updateSbaPanGains( return error; } - if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate #ifdef SPLIT_REND_WITH_HEAD_ROT - , - rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -2759,18 +2778,14 @@ static ivas_error setRendInputActiveSplitPostRend( rendCtx = inputSplitPostRend->base.ctx; outConfig = *rendCtx.pOutConfig; - if ( ( error = allocateInputBaseBufferData( &inputSplitPostRend->bufferData, - MAX_CLDFB_BIN_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) + if ( ( error = allocateInputBaseBufferData( &inputSplitPostRend->bufferData, MAX_CLDFB_BIN_BUFFER_LENGTH ) ) != IVAS_ERR_OK ) { return error; } - initRendInputBase( &inputSplitPostRend->base, inConfig, id, rendCtx, - inputSplitPostRend->bufferData, - MAX_CLDFB_BIN_BUFFER_LENGTH ); + initRendInputBase( &inputSplitPostRend->base, inConfig, id, rendCtx, inputSplitPostRend->bufferData, MAX_CLDFB_BIN_BUFFER_LENGTH ); inputSplitPostRend->numCachedSamples = 0; - if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg ) ) != IVAS_ERR_OK ) { return error; @@ -2787,12 +2802,11 @@ static ivas_error initSbaMasaRendering( { ivas_error error; - ivas_rend_closeCrend( &inputSba->crendWrapper #ifdef SPLIT_REND_WITH_HEAD_ROT - , - inputSba->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses + ivas_rend_closeCrend( &inputSba->crendWrapper, inputSba->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); +#else + ivas_rend_closeCrend( &inputSba->crendWrapper ); #endif - ); if ( ( error = ivas_dirac_ana_open( &inputSba->hDirAC, inSampleRate ) ) != IVAS_ERR_OK ) { @@ -2834,6 +2848,7 @@ static ivas_error setRendInputActiveSba( { return error; } + #ifdef SPLIT_REND_WITH_HEAD_ROT initRendInputBase( &inputSba->base, inConfig, id, rendCtx, inputSba->bufferData, MAX_CLDFB_BUFFER_LENGTH ); #else @@ -3279,15 +3294,13 @@ static DecoderDummy *initDecoderDummy( ivas_orient_trk_Init( decDummy->hHeadTrackData->OrientationTracker ); /* External orientations */ - if ( ( error = ivas_external_orientation_open( &( decDummy->hExtOrientationData ), - num_subframes ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_external_orientation_open( &( decDummy->hExtOrientationData ), num_subframes ) ) != IVAS_ERR_OK ) { assert( error == IVAS_ERR_OK ); } /* Combined orientations */ - if ( ( error = ivas_combined_orientation_open( &( decDummy->hCombinedOrientationData ), - num_subframes ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_combined_orientation_open( &( decDummy->hCombinedOrientationData ), num_subframes ) ) != IVAS_ERR_OK ) { assert( error == IVAS_ERR_OK ); } @@ -3349,6 +3362,7 @@ static ivas_error setRendInputActiveMasa( { return error; } + if ( getAudioConfigType( outConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) { inputMasa->metadataHasBeenFed = false; @@ -3359,12 +3373,11 @@ static ivas_error setRendInputActiveMasa( } else { - inputMasa->decDummy = initDecoderDummy( *rendCtx.pOutSampleRate, numInChannels, outConfig, 0 #ifdef SPLIT_REND_WITH_HEAD_ROT - , - rendCtx.pSplitRendWrapper + inputMasa->decDummy = initDecoderDummy( *rendCtx.pOutSampleRate, numInChannels, outConfig, 0, rendCtx.pSplitRendWrapper ); +#else + inputMasa->decDummy = initDecoderDummy( *rendCtx.pOutSampleRate, numInChannels, outConfig, 0 ); #endif - ); inputMasa->metadataHasBeenFed = false; @@ -3505,8 +3518,15 @@ static void clearInputMasa( #ifdef SPLIT_REND_WITH_HEAD_ROT - -static ivas_error initSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REND_AudioBuffer *pSplitRendEncBuffer, const IVAS_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, IVAS_REND_HeadRotData headRotData, const int32_t outputSampleRate, const AUDIO_CONFIG outConfig, const int16_t cldfb_in, const int16_t is_5ms_frame ) +static ivas_error initSplitRend( + SPLIT_REND_WRAPPER *pSplitRendWrapper, + IVAS_REND_AudioBuffer *pSplitRendEncBuffer, + const IVAS_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, + IVAS_REND_HeadRotData headRotData, + const int32_t outputSampleRate, + const AUDIO_CONFIG outConfig, + const int16_t cldfb_in_flag, + const int16_t is_5ms_frame ) { ivas_error error; IVAS_REND_AudioBufferConfig bufConfig; @@ -3522,8 +3542,7 @@ static ivas_error initSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REN ivas_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData ); } - if ( ( error = ivas_split_renderer_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, - is_5ms_frame ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_split_renderer_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, is_5ms_frame ) ) != IVAS_ERR_OK ) { return error; } @@ -3533,8 +3552,8 @@ static ivas_error initSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REN bufConfig.numChannels = BINAURAL_CHANNELS * pSplitRendWrapper->multiBinPoseData.num_poses; bufConfig.is_cldfb = 1; pSplitRendEncBuffer->config = bufConfig; - pSplitRendEncBuffer->data = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( float ) ); - if ( pSplitRendEncBuffer->data == NULL ) + + if ( ( pSplitRendEncBuffer->data = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( float ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } @@ -3555,6 +3574,12 @@ static ivas_error initSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REN #endif +/*------------------------------------------------------------------------- + * IVAS_REND_Open() + * + * + *------------------------------------------------------------------------*/ + ivas_error IVAS_REND_Open( IVAS_REND_HANDLE *phIvasRend, const int32_t outputSampleRate, @@ -3623,15 +3648,13 @@ ivas_error IVAS_REND_Open( } /* Initialize external orientation data */ - if ( ( error = ivas_external_orientation_open( &( hIvasRend->hExternalOrientationData ), - num_subframes ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_external_orientation_open( &( hIvasRend->hExternalOrientationData ), num_subframes ) ) != IVAS_ERR_OK ) { return error; } /* Initilize combined orientation data */ - if ( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), - num_subframes ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), num_subframes ) ) != IVAS_ERR_OK ) { return error; } @@ -3712,6 +3735,7 @@ ivas_error IVAS_REND_Open( hIvasRend->inputsMasa[i].bufferData = NULL; hIvasRend->inputsMasa[i].hMasaPrerend = NULL; } + #ifdef SPLIT_REND_WITH_HEAD_ROT for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; ++i ) { @@ -3788,6 +3812,12 @@ static ivas_error validateCustomLsLayout( } +/*-------------------------------------------------------------------* + * IVAS_REND_ConfigureCustomOutputLoudspeakerLayout() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( IVAS_REND_HANDLE hIvasRend, const IVAS_CUSTOM_LS_DATA layout ) @@ -3874,6 +3904,12 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( } +/*-------------------------------------------------------------------* + * IVAS_REND_NumOutChannels() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_NumOutChannels( IVAS_REND_CONST_HANDLE hIvasRend, int16_t *numOutChannels ) @@ -4194,34 +4230,19 @@ ivas_error IVAS_REND_AddInput( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( - ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && - hIvasRend->splitRendEncBuffer.data == NULL && hIvasRend->hRendererConfig != NULL ) + if ( ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && hIvasRend->splitRendEncBuffer.data == NULL && hIvasRend->hRendererConfig != NULL ) { - int16_t cldfb_in; - cldfb_in = getCldfbRendFlag( hIvasRend, getAudioConfigType( inConfig ) ); - + int16_t cldfb_in_flag; + cldfb_in_flag = getCldfbRendFlag( hIvasRend, getAudioConfigType( inConfig ) ); #ifdef FIX_658_SPLIT_REND_MASA - error = - ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, - &hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - ( cldfb_in == 0 ), - hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ); - if ( error != IVAS_ERR_OK ) + if ( ( error = ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, &hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, cldfb_in_flag, hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) != IVAS_ERR_OK ) { return error; } #endif - if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, - &hIvasRend->splitRendEncBuffer, - &hIvasRend->hRendererConfig->split_rend_config, - hIvasRend->headRotData, - hIvasRend->sampleRateOut, - hIvasRend->outputConfig, - cldfb_in, - ( hIvasRend->num_subframes == 1 ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, ( hIvasRend->num_subframes == 1 ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -4491,7 +4512,7 @@ ivas_error IVAS_REND_SetInputLfePos( * * *-------------------------------------------------------------------*/ - +/* ToDo; unused function */ ivas_error IVAS_REND_RemoveInput( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_REND_InputId inputId /* i : ID of the input */ @@ -4545,7 +4566,7 @@ ivas_error IVAS_REND_RemoveInput( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_GetInputNumChannels( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ const IVAS_REND_InputId inputId, /* i : ID of the input */ int16_t *numChannels /* o : number of channels of the input */ ) @@ -4580,7 +4601,7 @@ ivas_error IVAS_REND_GetInputNumChannels( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_GetNumAllObjects( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ int16_t *numChannels /* o : number of all objects */ ) { @@ -4605,9 +4626,9 @@ ivas_error IVAS_REND_GetNumAllObjects( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_GetDelay( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ - int16_t *nSamples, /* o : Renderer delay in samples */ - int32_t *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer state */ + int16_t *nSamples, /* o : Renderer delay in samples */ + int32_t *timeScale /* o : Time scale of the delay, equal to renderer output sampling rate */ ) { /* TODO tmu : this function only returns the maximum delay across all inputs @@ -4846,7 +4867,7 @@ ivas_error IVAS_REND_FeedInputObjectMetadata( /*-------------------------------------------------------------------* - * IVAS_REND_FeedInputObjectMetadata() + * IVAS_REND_FeedInputObjectMetadataToOMasa() * * *-------------------------------------------------------------------*/ @@ -4919,7 +4940,7 @@ ivas_error IVAS_REND_FeedInputMasaMetadata( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_InitConfig( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const AUDIO_CONFIG outAudioConfig /* i : output audioConfig */ ) { @@ -5080,28 +5101,20 @@ int16_t IVAS_REND_FeedRenderConfig( /* Must re-initialize split rendering config in case renderer config is updated after adding renderer inputs */ #ifdef FIX_658_SPLIT_REND_MASA - /*if its not initialized yet then no need to re-initialize, initialization will happen while adding inputs*/ + /* if its not initialized yet then no need to re-initialize, initialization will happen while adding inputs*/ if ( hIvasRend->splitRendEncBuffer.data != NULL && hIvasRend->hRendererConfig != NULL ) #endif { - int16_t cldfb_in; - cldfb_in = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); + int16_t cldfb_in_flag; + cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); closeSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); - if ( ( error = ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, - &hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - ( cldfb_in == 0 ), - hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) != IVAS_ERR_OK ) + + if ( ( error = ivas_split_rend_choose_default_codec( &hIvasRend->hRendererConfig->split_rend_config.codec, &hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, cldfb_in_flag, hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, - &hIvasRend->splitRendEncBuffer, - &hIvasRend->hRendererConfig->split_rend_config, - hIvasRend->headRotData, - hIvasRend->sampleRateOut, - hIvasRend->outputConfig, - cldfb_in, - ( hIvasRend->num_subframes == 1 ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + + if ( ( error = initSplitRend( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, ( hIvasRend->num_subframes == 1 ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -5111,7 +5124,8 @@ int16_t IVAS_REND_FeedRenderConfig( return IVAS_ERR_OK; } -#if defined SPLIT_REND_WITH_HEAD_ROT + +#ifdef SPLIT_REND_WITH_HEAD_ROT /*-------------------------------------------------------------------* * IVAS_REND_FeedSplitBinauralBitstream() * @@ -5119,8 +5133,8 @@ int16_t IVAS_REND_FeedRenderConfig( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_FeedSplitBinauralBitstream( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const IVAS_REND_InputId inputId, /* i : ID of the input */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_InputId inputId, /* i : ID of the input */ IVAS_REND_BitstreamBuffer *hBits /* i : buffer for input bitstream */ ) { @@ -5154,17 +5168,16 @@ ivas_error IVAS_REND_FeedSplitBinauralBitstream( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_SetHeadRotation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ - const IVAS_VECTOR3 Pos /* i : listener positions for next rendering call */ + const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - IVAS_SPLIT_REND_ROT_AXIS rot_axis + IVAS_SPLIT_REND_ROT_AXIS rot_axis, #endif - , const int16_t sf_idx ) { IVAS_QUATERNION rotQuat; + ivas_error error; /* Validate function arguments */ if ( hIvasRend == NULL ) @@ -5188,7 +5201,11 @@ ivas_error IVAS_REND_SetHeadRotation( rotQuat = headRot; } - ivas_orient_trk_Process( hIvasRend->headRotData.hOrientationTracker, rotQuat, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hIvasRend->headRotData.headPositions[sf_idx] ); + if ( ( error = ivas_orient_trk_Process( hIvasRend->headRotData.hOrientationTracker, rotQuat, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hIvasRend->headRotData.headPositions[sf_idx] ) ) != IVAS_ERR_OK ) + { + return error; + } + hIvasRend->headRotData.Pos[sf_idx] = Pos; #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -5198,9 +5215,15 @@ ivas_error IVAS_REND_SetHeadRotation( return IVAS_ERR_OK; } -ivas_error -IVAS_REND_DisableHeadRotation( - IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ + +/*-------------------------------------------------------------------* + * IVAS_REND_DisableHeadRotation() + * + * + *-------------------------------------------------------------------*/ + +ivas_error IVAS_REND_DisableHeadRotation( + IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ ) { /* Validate function arguments */ @@ -5210,9 +5233,11 @@ IVAS_REND_DisableHeadRotation( } hIvasRend->headRotData.headRotEnabled = 0; + return IVAS_ERR_OK; } + #ifdef SPLIT_REND_WITH_HEAD_ROT /*-------------------------------------------------------------------* * IVAS_REND_SetSplitRendBFI() @@ -5220,8 +5245,7 @@ IVAS_REND_DisableHeadRotation( * *-------------------------------------------------------------------*/ -ivas_error -IVAS_REND_SetSplitRendBFI( +ivas_error IVAS_REND_SetSplitRendBFI( IVAS_REND_HANDLE hIvasRend, const int16_t bfi ) { @@ -5280,7 +5304,7 @@ ivas_error IVAS_REND_SetReferenceRotation( * * *-------------------------------------------------------------------*/ - +// ToDo: not used ivas_error IVAS_REND_GetMainOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer for main orientation */ @@ -5307,7 +5331,7 @@ ivas_error IVAS_REND_GetMainOrientation( * * *-------------------------------------------------------------------*/ - +// ToDo: not used ivas_error IVAS_REND_GetTrackedRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_QUATERNION *pRotation /* i/o: Quaternion pointer processed rotation */ @@ -5364,10 +5388,9 @@ ivas_error IVAS_REND_SetExternalOrientation( int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const int16_t sf_idx /*i : subframe index*/ + const int16_t sf_idx /* i : subframe index */ ) { - /* Validate function arguments */ if ( hIvasRend == NULL || hIvasRend->hExternalOrientationData == NULL ) { @@ -5399,7 +5422,7 @@ ivas_error IVAS_REND_SetExternalOrientation( *---------------------------------------------------------------------*/ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( - IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ + IVAS_REND_HANDLE hIvasRend /* i/o: Renderer handle */ ) { if ( hIvasRend == NULL ) @@ -5416,7 +5439,7 @@ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( * * *---------------------------------------------------------------------*/ - +// ToDo: not used ivas_error IVAS_REND_GetCombinedOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer processed orientation */ @@ -5531,9 +5554,13 @@ static void renderBufferChannel( return; } -static ivas_error chooseCrossfade( const IVAS_REND_HeadRotData *headRotData, const float **pCrossfade ) + +static ivas_error chooseCrossfade( + const IVAS_REND_HeadRotData *headRotData, + const float **pCrossfade ) { *pCrossfade = headRotData->crossfade; + return IVAS_ERR_OK; } @@ -5553,7 +5580,6 @@ static ivas_error rotateFrameMc( const float *crossfade; int16_t num_subframes; int16_t subframe_idx, subframe_len; - int16_t azimuth, elevation; int16_t is_planar_setup, lfe_idx; int16_t nchan; @@ -5586,9 +5612,7 @@ static ivas_error rotateFrameMc( nchan = pInCustomLs->num_spk + pInCustomLs->num_lfe; } - if ( ( error = getMcConfigValues( inConfig, - pInCustomLs, - &ls_azimuth, &ls_elevation, &lfe_idx, &is_planar_setup ) ) != IVAS_ERR_OK ) + if ( ( error = getMcConfigValues( inConfig, pInCustomLs, &ls_azimuth, &ls_elevation, &lfe_idx, &is_planar_setup ) ) != IVAS_ERR_OK ) { return error; } @@ -5815,10 +5839,8 @@ static ivas_error renderIsmToBinaural( ism_md_subframe_update_ext = (int16_t) round( ismInput->ism_metadata_delay_ms / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); copyBufferTo2dArray( ismInput->base.inputBuffer, tmpTDRendBuffer ); - if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, - ismInput->hReverb, ism_md_subframe_update_ext, - *ismInput->base.ctx.pOutSampleRate, - outAudio.config.numSamplesPerChannel, tmpTDRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, + *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpTDRendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -5830,7 +5852,10 @@ static ivas_error renderIsmToBinaural( return IVAS_ERR_OK; } -static int16_t getNumSubframesInBuffer( const IVAS_REND_AudioBuffer *buffer, int32_t sampleRate ) + +static int16_t getNumSubframesInBuffer( + const IVAS_REND_AudioBuffer *buffer, + const int32_t sampleRate ) { #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t cldfb2tdSampleFact; @@ -5853,6 +5878,7 @@ static int16_t getNumSubframesInBuffer( const IVAS_REND_AudioBuffer *buffer, int #endif } + static ivas_error renderIsmToBinauralRoom( input_ism *ismInput, IVAS_REND_AudioBuffer outAudio ) @@ -5978,14 +6004,10 @@ static ivas_error renderIsmToBinauralRoom( rotatedPos.elevation = ismInput->currentPos.elevation; } - position_changed = !ismInput->firstFrameRendered || - checkObjectPositionChanged( &rotatedPos, &rotatedPosPrev ); + position_changed = !ismInput->firstFrameRendered || checkObjectPositionChanged( &rotatedPos, &rotatedPosPrev ); /* set previous gains if this is the first frame */ - if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper, - rotatedPosPrev.azimuth, - rotatedPosPrev.elevation, - ismInput->prev_pan_gains ) ) != IVAS_ERR_OK ) + if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper, rotatedPosPrev.azimuth, rotatedPosPrev.elevation, ismInput->prev_pan_gains ) ) != IVAS_ERR_OK ) { return error; } @@ -6010,7 +6032,6 @@ static ivas_error renderIsmToBinauralRoom( } #endif - /* intermediate rendering to 7_1_4 */ tmpMcBuffer = ismInput->base.inputBuffer; @@ -6040,6 +6061,7 @@ static ivas_error renderIsmToBinauralRoom( { mvr2r( Rmat[i], ismInput->rot_mat_prev[i], 3 ); } + #ifdef FIX_518_ISM_BRIR_EXTREND if ( position_changed ) { @@ -6047,15 +6069,18 @@ static ivas_error renderIsmToBinauralRoom( } #endif + /* render 7_1_4 with BRIRs */ +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ) -#ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ), 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, + NULL, NULL, NULL, NULL, p_tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *ismInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) + #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -6083,16 +6108,8 @@ static ivas_error renderIsmToBinauralReverb( ism_md_subframe_update_ext = (int16_t) round( ismInput->ism_metadata_delay_ms / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); copyBufferTo2dArray( ismInput->base.inputBuffer, tmpRendBuffer ); - if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, - ismInput->base.inConfig, - NULL, - ismInput->base.ctx.pCombinedOrientationData, - &ismInput->currentPos, - ismInput->hReverb, - ism_md_subframe_update_ext, - *ismInput->base.ctx.pOutSampleRate, - outAudio.config.numSamplesPerChannel, - tmpRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, + ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6123,8 +6140,7 @@ static ivas_error renderIsmToMc( push_wmops( "renderIsmToMc" ); #ifdef FIX_518_ISM_BRIR_EXTREND - position_changed = !ismInput->firstFrameRendered || - checkObjectPositionChanged( &ismInput->currentPos, &ismInput->previousPos ); + position_changed = !ismInput->firstFrameRendered || checkObjectPositionChanged( &ismInput->currentPos, &ismInput->previousPos ); #else /* TODO(sgi): Possible optimization: less processing needed if position didn't change */ #endif @@ -6256,8 +6272,7 @@ static ivas_error renderIsmToSba( } #ifdef FIX_518_ISM_BRIR_EXTREND - position_changed = !ismInput->firstFrameRendered || - checkObjectPositionChanged( &ismInput->currentPos, &ismInput->previousPos ); + position_changed = !ismInput->firstFrameRendered || checkObjectPositionChanged( &ismInput->currentPos, &ismInput->previousPos ); /* set previous gains if this is the first frame */ if ( !ismInput->firstFrameRendered ) @@ -6392,17 +6407,8 @@ static ivas_error renderIsmToSplitBinaural( } /* Render */ - error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &ismInput->tdRendWrapper : &ismInput->splitTdRendWrappers[pos_idx - 1], - ismInput->base.inConfig, - NULL, - ismInput->base.ctx.pCombinedOrientationData, - &ismInput->currentPos, - NULL, - ism_md_subframe_update_ext, - *ismInput->base.ctx.pOutSampleRate, - output_frame, - tmpProcessing ); - if ( error != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &ismInput->tdRendWrapper : &ismInput->splitTdRendWrappers[pos_idx - 1], ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, + NULL, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, output_frame, tmpProcessing ) ) != IVAS_ERR_OK ) { return error; } @@ -6684,13 +6690,8 @@ static ivas_error renderMcToBinaural( { copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); - if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, - mcInput->base.ctx.pCombinedOrientationData, - NULL, - mcInput->hReverb, - 0, - *mcInput->base.ctx.pOutSampleRate, - mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb, + 0, *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6704,10 +6705,7 @@ static ivas_error renderMcToBinaural( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); - if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, - &mcInput->customLsInput, - mcInput->base.ctx.pHeadRotData, - mcInput->base.ctx.pCombinedOrientationData, + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, #ifdef SPLIT_REND_WITH_HEAD_ROT mcInput->rot_gains_prev[0], #else @@ -6727,13 +6725,13 @@ static ivas_error renderMcToBinaural( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ), 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -6799,12 +6797,8 @@ static ivas_error renderMcToBinauralRoom( { copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); - if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, - mcInput->base.ctx.pCombinedOrientationData, - NULL, mcInput->hReverb, - 0, - *mcInput->base.ctx.pOutSampleRate, - mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb, + 0, *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6818,10 +6812,7 @@ static ivas_error renderMcToBinauralRoom( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); - if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, - &mcInput->customLsInput, - mcInput->base.ctx.pHeadRotData, - mcInput->base.ctx.pCombinedOrientationData, + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, #ifdef SPLIT_REND_WITH_HEAD_ROT mcInput->rot_gains_prev[0], #else @@ -6841,13 +6832,13 @@ static ivas_error renderMcToBinauralRoom( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ), 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -6917,10 +6908,7 @@ static ivas_error renderMcCustomLsToBinauralRoom( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); - if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, - &mcInput->customLsInput, - mcInput->base.ctx.pHeadRotData, - mcInput->base.ctx.pCombinedOrientationData, + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, #ifdef SPLIT_REND_WITH_HEAD_ROT mcInput->rot_gains_prev[0], #else @@ -6952,14 +6940,13 @@ static ivas_error renderMcCustomLsToBinauralRoom( copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer ); /* call CREND */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, - p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, + p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ), 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, + p_tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &outAudio, *mcInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -7144,16 +7131,8 @@ static ivas_error renderMcToSplitBinaural( #endif /* Render */ - if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], - mcInput->base.inConfig, - &mcInput->customLsInput, - &pCombinedOrientationDataLocal, - NULL, - mcInput->hReverb, - 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ - *mcInput->base.ctx.pOutSampleRate, - mcInput->base.inputBuffer.config.numSamplesPerChannel, - tmpRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, + NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -7178,18 +7157,13 @@ static ivas_error renderMcToSplitBinaural( /* perform rotation in source format to tmpRotBuffer */ pCombinedOrientationDataLocal = &combinedOrientationDataLocal; - if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, - mcInput->base.inConfig, - &mcInput->customLsInput, - mcInput->base.ctx.pHeadRotData, - &pCombinedOrientationDataLocal, + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, &pCombinedOrientationDataLocal, #ifdef SPLIT_REND_WITH_HEAD_ROT mcInput->rot_gains_prev[pos_idx], #else mcInput->rot_gains_prev, #endif - mcInput->efapInWrapper.hEfap, - tmpRotBuffer ) ) != IVAS_ERR_OK ) + mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -7197,15 +7171,7 @@ static ivas_error renderMcToSplitBinaural( copyBufferTo2dArray( tmpRotBuffer, tmpRendBuffer ); /* call CREND (rotation already performed) */ - if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, - mcInput->base.inConfig, - outConfig, - NULL, - NULL, - NULL, - NULL, - p_tmpRendBuffer, - *mcInput->base.ctx.pOutSampleRate, + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &mcInput->base.inputBuffer, *mcInput->base.ctx.pOutSampleRate ), #ifdef SPLIT_REND_WITH_HEAD_ROT pos_idx @@ -7409,8 +7375,7 @@ static ivas_error splitBinLc3plusDecode( } /* Read LC3plus bitstream size info */ lc3plusBitrateId = ivas_split_rend_bitstream_read_int32( bits, 8 ); - lc3plusBitstreamSize = ivas_get_lc3plus_size_from_id( (int8_t) lc3plusBitrateId, pose_correction, - (int16_t) ( hSplitBin->hLc3plusDec->config.ivas_frame_duration_us / 1000 ) ); + lc3plusBitstreamSize = ivas_get_lc3plus_size_from_id( (int8_t) lc3plusBitrateId, pose_correction, (int16_t) ( hSplitBin->hLc3plusDec->config.ivas_frame_duration_us / 1000 ) ); for ( int16_t i = 0; i < BINAURAL_CHANNELS * hSplitBin->multiBinPoseData.num_poses; ++i ) { @@ -7439,8 +7404,7 @@ static ivas_error renderSplitBinauralWithPostRot( float Cldfb_RealBuffer_Binaural_5ms[MAX_PARAM_SPATIAL_SUBFRAMES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural_5ms[MAX_PARAM_SPATIAL_SUBFRAMES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; IVAS_QUATERNION QuaternionsPost[MAX_PARAM_SPATIAL_SUBFRAMES]; - int16_t sf_idx; - + int16_t sf_idx, ch_idx; ivas_split_rend_bits_t bits; float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float tmpCrendBuffer_sf[BINAURAL_CHANNELS][L_FRAME48k]; @@ -7453,11 +7417,8 @@ static ivas_error renderSplitBinauralWithPostRot( int16_t numSamplesPerChannelCacheSize, numColPerChannelCacheSize; float *readPtr, *writePtr; - isPostRendInputCldfb = 0; - push_wmops( "renderSplitBinauralWithPostRot" ); - error = IVAS_ERR_OK; pCombinedOrientationData = *splitBinInput->base.ctx.pCombinedOrientationData; @@ -7516,14 +7477,14 @@ static ivas_error renderSplitBinauralWithPostRot( { if ( !SplitRendBFI ) { - ivas_splitBinPostRendMdDec( &bits, hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - , - hSplitBin->hBinHrSplitPreRend + ivas_splitBinPostRendMdDec( &bits, hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData, hSplitBin->hBinHrSplitPreRend ); +#else + ivas_splitBinPostRendMdDec( &bits, hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData ); #endif - ); } } + /*copy pose correction after MD is parsed*/ hSplitBin->multiBinPoseData.poseCorrectionMode = bits.pose_correction; @@ -7548,12 +7509,7 @@ static ivas_error renderSplitBinauralWithPostRot( { if ( bits.codec == IVAS_SPLIT_REND_CODEC_LCLD ) { - ivas_splitBinLCLDDecProcess( - hSplitBin->hSplitBinLCLDDec, - &bits, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - SplitRendBFI ); + ivas_splitBinLCLDDecProcess( hSplitBin->hSplitBinLCLDDec, &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, SplitRendBFI ); /* copy data over to 5ms buffer */ for ( chnlIdx = 0; chnlIdx < BINAURAL_CHANNELS; ++chnlIdx ) @@ -7564,6 +7520,7 @@ static ivas_error renderSplitBinauralWithPostRot( mvr2r( Cldfb_ImagBuffer_Binaural[chnlIdx][slotIdx], Cldfb_ImagBuffer_Binaural_5ms[sf_idx][chnlIdx][slotIdx], CLDFB_NO_CHANNELS_MAX ); } } + /* cache the remaining 15ms */ splitBinInput->numCachedSamples = numColPerChannelCacheSize; writePtr = splitBinInput->bufferData; @@ -7584,19 +7541,15 @@ static ivas_error renderSplitBinauralWithPostRot( } else { - error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, bits.pose_correction ); - if ( error != IVAS_ERR_OK ) + if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, bits.pose_correction ) ) != IVAS_ERR_OK ) { return error; } + /* cache the remaining 15ms */ splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; - mvr2r( &tmpCrendBuffer[0][outBufNumSamplesPerChannel], - splitBinInput->bufferData, - numSamplesPerChannelCacheSize ); - mvr2r( &tmpCrendBuffer[1][outBufNumSamplesPerChannel], - splitBinInput->bufferData + numSamplesPerChannelCacheSize, - numSamplesPerChannelCacheSize ); + mvr2r( &tmpCrendBuffer[0][outBufNumSamplesPerChannel], splitBinInput->bufferData, numSamplesPerChannelCacheSize ); + mvr2r( &tmpCrendBuffer[1][outBufNumSamplesPerChannel], splitBinInput->bufferData + numSamplesPerChannelCacheSize, numSamplesPerChannelCacheSize ); } } else @@ -7629,12 +7582,8 @@ static ivas_error renderSplitBinauralWithPostRot( else { int16_t readOffset = numSamplesPerChannelCacheSize - splitBinInput->numCachedSamples; - mvr2r( splitBinInput->bufferData + readOffset, - &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], - outBufNumSamplesPerChannel ); - mvr2r( splitBinInput->bufferData + readOffset + numSamplesPerChannelCacheSize, - &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], - outBufNumSamplesPerChannel ); + mvr2r( splitBinInput->bufferData + readOffset, &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); + mvr2r( splitBinInput->bufferData + readOffset + numSamplesPerChannelCacheSize, &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); splitBinInput->numCachedSamples -= outBufNumSamplesPerChannel; } } @@ -7651,7 +7600,7 @@ static ivas_error renderSplitBinauralWithPostRot( if ( bits.pose_correction == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE && isPostRendInputCldfb ) { /* 0DOF with LCLD codec requires CLDFB synthesis */ - int16_t ch_idx, slot_idx; + int16_t slot_idx; for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { @@ -7673,27 +7622,13 @@ static ivas_error renderSplitBinauralWithPostRot( } else if ( bits.pose_correction == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - mvr2r( &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], - tmpCrendBuffer_sf[0], - outBufNumSamplesPerChannel ); - mvr2r( &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], - tmpCrendBuffer_sf[1], - outBufNumSamplesPerChannel ); - ivas_rend_CldfbSplitPostRendProcess( - hSplitBin->hBinHrSplitPostRend, - &hSplitBin->multiBinPoseData, - QuaternionsPost[sf_idx], - Cldfb_RealBuffer_Binaural_5ms[sf_idx], - Cldfb_ImagBuffer_Binaural_5ms[sf_idx], - tmpCrendBuffer_sf, - isPostRendInputCldfb ); - - mvr2r( tmpCrendBuffer_sf[0], - &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], - outBufNumSamplesPerChannel ); - mvr2r( tmpCrendBuffer_sf[1], - &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], - outBufNumSamplesPerChannel ); + mvr2r( &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], tmpCrendBuffer_sf[0], outBufNumSamplesPerChannel ); + mvr2r( &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], tmpCrendBuffer_sf[1], outBufNumSamplesPerChannel ); + + ivas_rend_CldfbSplitPostRendProcess( hSplitBin->hBinHrSplitPostRend, &hSplitBin->multiBinPoseData, QuaternionsPost[sf_idx], Cldfb_RealBuffer_Binaural_5ms[sf_idx], Cldfb_ImagBuffer_Binaural_5ms[sf_idx], tmpCrendBuffer_sf, isPostRendInputCldfb ); + + mvr2r( tmpCrendBuffer_sf[0], &tmpCrendBuffer[0][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); + mvr2r( tmpCrendBuffer_sf[1], &tmpCrendBuffer[1][sf_idx * outBufNumSamplesPerChannel], outBufNumSamplesPerChannel ); } } } @@ -7701,7 +7636,6 @@ static ivas_error renderSplitBinauralWithPostRot( { if ( splitBinInput->base.inConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { - int16_t ch_idx; for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { set_zero( tmpCrendBuffer[ch_idx], outAudio.config.numSamplesPerChannel ); @@ -7796,10 +7730,7 @@ static ivas_error renderSbaToMultiBinaural( assert( sbaInput->crendWrapper->hCrend[0]->hReverb == NULL ); /* call CREND */ - if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, - NULL, NULL, NULL, NULL, - p_tmpCrendBuffer, - *sbaInput->base.ctx.pOutSampleRate, + if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, getNumSubframesInBuffer( &sbaInput->base.inputBuffer, *sbaInput->base.ctx.pOutSampleRate ), #ifdef SPLIT_REND_WITH_HEAD_ROT pos_idx @@ -7825,34 +7756,29 @@ static ivas_error renderSbaToMultiBinaural( free( tmpRotBuffer.data ); pop_wmops(); - return IVAS_ERR_OK; } -static ivas_error renderSbaToMultiBinauralCldfb( input_sba *sbaInput, - float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const int16_t low_res_pre_rend_rot, - int16_t num_subframes ) + +static ivas_error renderSbaToMultiBinauralCldfb( + input_sba *sbaInput, + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + const int16_t low_res_pre_rend_rot, + const int16_t num_subframes ) { float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; copyBufferToCLDFBarray( sbaInput->base.inputBuffer, Cldfb_RealBuffer, Cldfb_ImagBuffer ); - ivas_rend_CldfbMultiBinRendProcess( - sbaInput->cldfbRendWrapper.hCldfbRend, - sbaInput->base.ctx.pCombinedOrientationData, - &sbaInput->base.ctx.pSplitRendWrapper->multiBinPoseData, - Cldfb_RealBuffer, - Cldfb_ImagBuffer, - Cldfb_Out_Real, - Cldfb_Out_Imag, - low_res_pre_rend_rot, - num_subframes ); + ivas_rend_CldfbMultiBinRendProcess( sbaInput->cldfbRendWrapper.hCldfbRend, sbaInput->base.ctx.pCombinedOrientationData, &sbaInput->base.ctx.pSplitRendWrapper->multiBinPoseData, + Cldfb_RealBuffer, Cldfb_ImagBuffer, Cldfb_Out_Real, Cldfb_Out_Imag, low_res_pre_rend_rot, num_subframes ); + return IVAS_ERR_OK; } + static ivas_error renderSbaToSplitBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, @@ -7871,11 +7797,12 @@ static ivas_error renderSbaToSplitBinaural( if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == IVAS_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { - renderSbaToMultiBinauralCldfb( sbaInput, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - low_res_pre_rend_rot, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ); + if ( ( renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, low_res_pre_rend_rot, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) + { + return error; + } + accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } else @@ -7916,11 +7843,13 @@ static ivas_error renderSbaToBinaural( { float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - renderSbaToMultiBinauralCldfb( sbaInput, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - 0, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ); + + if ( ( error = renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, 0, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) + { + return error; + } + accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } else @@ -7954,15 +7883,13 @@ static ivas_error renderSbaToBinaural( /* copy input for in-place rotation */ mvr2r( sbaInput->base.inputBuffer.data, tmpRotBuffer.data, tmpRotBuffer.config.numChannels * tmpRotBuffer.config.numSamplesPerChannel ); - if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, - sbaInput->base.ctx.pCombinedOrientationData, #ifdef SPLIT_REND_WITH_HEAD_ROT - sbaInput->rot_gains_prev[0], + if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev[0], tmpRotBuffer ) ) != IVAS_ERR_OK ) #else - sbaInput->rot_gains_prev, + if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev, tmpRotBuffer ) ) != IVAS_ERR_OK ) #endif - tmpRotBuffer ) ) != IVAS_ERR_OK ) - { return error; } @@ -7976,14 +7903,13 @@ static ivas_error renderSbaToBinaural( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, - NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ), 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -7996,6 +7922,7 @@ static ivas_error renderSbaToBinaural( return IVAS_ERR_OK; } + static ivas_error renderSbaToBinauralRoom( input_sba *sbaInput, const AUDIO_CONFIG outConfig, @@ -8081,12 +8008,11 @@ static ivas_error renderSbaToBinauralRoom( /* call CREND */ if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ), 0 ) ) != IVAS_ERR_OK ) +#else + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -8104,6 +8030,7 @@ static ivas_error renderSbaToBinauralRoom( return IVAS_ERR_OK; } + #ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error renderInputSplitBin( input_split_post_rend *splitBinInput, @@ -8126,8 +8053,7 @@ static ivas_error renderInputSplitBin( switch ( outConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL: - error = renderSplitBinauralWithPostRot( splitBinInput, outAudio, - SplitRendBFI ); + error = renderSplitBinauralWithPostRot( splitBinInput, outAudio, SplitRendBFI ); break; default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; @@ -8137,7 +8063,8 @@ static ivas_error renderInputSplitBin( } #endif -static ivas_error renderSbaToMasa( + +static void renderSbaToMasa( input_sba *sbaInput, IVAS_REND_AudioBuffer outAudio ) { @@ -8151,9 +8078,10 @@ static ivas_error renderSbaToMasa( pop_wmops(); - return IVAS_ERR_OK; + return; } + static ivas_error renderInputSba( input_sba *sbaInput, const AUDIO_CONFIG outConfig, @@ -8161,7 +8089,7 @@ static ivas_error renderInputSba( { ivas_error error; IVAS_REND_AudioBuffer inAudio; -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t cldfb2tdSampleFact; #endif @@ -8247,8 +8175,7 @@ static ivas_error renderActiveInputsSplitBin( continue; } - if ( ( error = renderInputSplitBin( pCurrentInput, hIvasRend->outputConfig, outAudio, - hIvasRend->splitRendBFI ) ) != IVAS_ERR_OK ) + if ( ( error = renderInputSplitBin( pCurrentInput, hIvasRend->outputConfig, outAudio, hIvasRend->splitRendBFI ) ) != IVAS_ERR_OK ) { return error; } @@ -8284,6 +8211,7 @@ static ivas_error renderActiveInputsSba( return IVAS_ERR_OK; } + static void copyMasaMetadataToDiracRenderer( MASA_METADATA_FRAME *meta, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom ) @@ -8326,6 +8254,7 @@ static void copyMasaMetadataToDiracRenderer( return; } + static void renderMasaToMc( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio ) @@ -8343,13 +8272,11 @@ static void renderMasaToMc( if ( masaInput->decDummy->renderer_type == RENDERER_STEREO_PARAMETRIC ) { - ivas_dirac_dec_binaural( masaInput->decDummy, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, masaInput->base.inputBuffer.config.numChannels, - getNumSubframesInBuffer( &outAudio, *masaInput->base.ctx.pOutSampleRate ) ); + ivas_dirac_dec_binaural( masaInput->decDummy, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, masaInput->base.inputBuffer.config.numChannels, getNumSubframesInBuffer( &outAudio, *masaInput->base.ctx.pOutSampleRate ) ); } else { - ivas_dirac_dec( masaInput->decDummy, tmpBuffer, masaInput->base.inputBuffer.config.numChannels, - getNumSubframesInBuffer( &outAudio, *masaInput->base.ctx.pOutSampleRate ) ); + ivas_dirac_dec( masaInput->decDummy, tmpBuffer, masaInput->base.inputBuffer.config.numChannels, getNumSubframesInBuffer( &outAudio, *masaInput->base.ctx.pOutSampleRate ) ); } accumulate2dArrayToBuffer( tmpBuffer_buff, &outAudio ); @@ -8357,6 +8284,7 @@ static void renderMasaToMc( return; } + static void renderMasaToSba( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio ) @@ -8372,14 +8300,14 @@ static void renderMasaToSba( copyBufferTo2dArray( masaInput->base.inputBuffer, tmpBuffer_buff ); copyMasaMetadataToDiracRenderer( &masaInput->masaMetadata, masaInput->decDummy->hSpatParamRendCom ); - ivas_dirac_dec( masaInput->decDummy, tmpBuffer, masaInput->base.inputBuffer.config.numChannels, - getNumSubframesInBuffer( &outAudio, *masaInput->base.ctx.pOutSampleRate ) ); + ivas_dirac_dec( masaInput->decDummy, tmpBuffer, masaInput->base.inputBuffer.config.numChannels, getNumSubframesInBuffer( &outAudio, *masaInput->base.ctx.pOutSampleRate ) ); accumulate2dArrayToBuffer( tmpBuffer_buff, &outAudio ); return; } + static void renderMasaToBinaural( input_masa *masaInput, IVAS_REND_AudioBuffer outAudio @@ -8420,8 +8348,7 @@ static void renderMasaToBinaural( } #endif - ivas_dirac_dec_binaural( masaInput->decDummy, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, masaInput->base.inputBuffer.config.numChannels, - getNumSubframesInBuffer( &outAudio, *masaInput->base.ctx.pOutSampleRate ) ); + ivas_dirac_dec_binaural( masaInput->decDummy, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer, masaInput->base.inputBuffer.config.numChannels, getNumSubframesInBuffer( &outAudio, *masaInput->base.ctx.pOutSampleRate ) ); #ifdef SPLIT_REND_WITH_HEAD_ROT if ( is_split_rend_mode ) @@ -8573,7 +8500,7 @@ static ivas_error renderInputMasa( IVAS_REND_AudioBuffer outAudio ) { IVAS_REND_AudioBuffer inAudio; -#if defined( SPLIT_REND_WITH_HEAD_ROT ) +#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t cldfb2tdSampleFact; #endif @@ -8613,12 +8540,12 @@ static ivas_error renderInputMasa( switch ( outConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL: - renderMasaToBinaural( masaInput, outAudio + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 0 + renderMasaToBinaural( masaInput, outAudio, 0 ); +#else + renderMasaToBinaural( masaInput, outAudio ); #endif - ); break; /* ToDo */ // #ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG @@ -8632,12 +8559,11 @@ static ivas_error renderInputMasa( #ifdef SPLIT_REND_WITH_HEAD_ROT_PARAMBIN case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: - renderMasaToBinaural( masaInput, outAudio #ifdef SPLIT_REND_WITH_HEAD_ROT - , - 1 + renderMasaToBinaural( masaInput, outAudio, 1 ); +#else + renderMasaToBinaural( masaInput, outAudio ); #endif - ); break; #endif default: @@ -8700,7 +8626,7 @@ static ivas_error renderActiveInputsMasa( ivas_error IVAS_REND_GetMasaMetadata( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to analyzed MASA metadata */ - IVAS_REND_AudioConfigType inputType /* i : Input type */ + const IVAS_REND_AudioConfigType inputType /* i : Input type */ ) { if ( hIvasRend == NULL ) @@ -8739,8 +8665,8 @@ ivas_error IVAS_REND_GetMasaMetadata( ivas_error IVAS_REND_MergeMasaMetadata( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to merged metadata */ - IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ - IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ + const IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ + const IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ ) { MASA_DECODER_EXT_OUT_META_HANDLE inMeta2; @@ -8808,7 +8734,6 @@ ivas_error IVAS_REND_MergeMasaMetadata( ivas_prerend_merge_masa_metadata( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1, inMeta2, inputType2, *inEne2 ); ( *hMasaExtOutMeta )->descriptiveMeta.numberOfChannels = hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_MASA1 ? 0u : 1u; - return IVAS_ERR_OK; } @@ -8987,6 +8912,7 @@ static ivas_error getSamplesInternal( set_zero( outAudio.data, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel ); } #endif + if ( ( error = renderActiveInputsIsm( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) { return error; @@ -9006,6 +8932,7 @@ static ivas_error getSamplesInternal( { return error; } + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = renderActiveInputsSplitBin( hIvasRend, outAudio ) ) != IVAS_ERR_OK ) { @@ -9035,7 +8962,7 @@ static ivas_error getSamplesInternal( if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { ivas_split_rend_bits_t bits; - int16_t td_input; + int16_t cldfb_in_flag; float Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; int16_t ch; @@ -9048,31 +8975,31 @@ static ivas_error getSamplesInternal( if ( outAudio.config.is_cldfb == 1 ) { - td_input = 0; + cldfb_in_flag = 1; copyBufferToCLDFBarray( outAudio, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); } else { - td_input = 1; + cldfb_in_flag = 0; copyBufferTo2dArray( outAudio, tmpBinaural_buff ); } /* Encode split rendering bitstream */ convertBitsBufferToInternalBitsBuff( *hBits, &bits ); - error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, - hIvasRend->headRotData.headPositions[0], - hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, - hIvasRend->hRendererConfig->split_rend_config.codec, - hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, - Cldfb_RealBuffer_Binaural, - Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), - tmpBinaural, - 1, - td_input, - ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ); - if ( error != IVAS_ERR_OK ) + + if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, + hIvasRend->headRotData.headPositions[0], + hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, + hIvasRend->hRendererConfig->split_rend_config.codec, + hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, + &bits, + Cldfb_RealBuffer_Binaural, + Cldfb_ImagBuffer_Binaural, + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + tmpBinaural, + 1, + cldfb_in_flag, + ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -9092,6 +9019,7 @@ static ivas_error getSamplesInternal( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * IVAS_REND_GetSamples() * @@ -9103,25 +9031,34 @@ ivas_error IVAS_REND_GetSamples( IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ ) { - return getSamplesInternal( hIvasRend, outAudio + #ifdef SPLIT_REND_WITH_HEAD_ROT - , - NULL + return getSamplesInternal( hIvasRend, outAudio, NULL ); + +#else + return getSamplesInternal( hIvasRend, outAudio ); #endif - ); } + #ifdef SPLIT_REND_WITH_HEAD_ROT +/*-------------------------------------------------------------------* + * IVAS_REND_GetSplitBinauralBitstream() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetSplitBinauralBitstream( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ IVAS_REND_BitstreamBuffer *hBits /* o : buffer for output bitstream */ ) { - int16_t cldfb_in; + int16_t cldfb_in_flag; + + cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); + hIvasRend->splitRendEncBuffer.config.is_cldfb = cldfb_in_flag; - cldfb_in = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); - hIvasRend->splitRendEncBuffer.config.is_cldfb = cldfb_in; if ( hIvasRend->hRendererConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && ( hIvasRend->hRendererConfig->split_rend_config.dof == 0 || hIvasRend->hRendererConfig->split_rend_config.poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) { @@ -9131,13 +9068,20 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( { hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel = (int16_t) ( hIvasRend->sampleRateOut / FRAMES_PER_SEC ); } - hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel *= cldfb_in ? 2 : 1; + hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel *= cldfb_in_flag ? 2 : 1; /* hIvasRend->splitRendEncBuffer used for BINAURAL_SPLIT_CODED output outAudio used for BINAURAL_SPLIT_PCM output */ return getSamplesInternal( hIvasRend, outAudio, hBits ); } + +/*-------------------------------------------------------------------* + * IVAS_REND_GetSplitBinauralSamples() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetSplitBinauralSamples( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ @@ -9234,20 +9178,21 @@ void IVAS_REND_Close( * *-------------------------------------------------------------------*/ -int16_t IVAS_REND_openCldfb( +ivas_error IVAS_REND_openCldfb( IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], - IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS], const int16_t num_in_chs, const int16_t num_out_chs, const int32_t output_Fs ) { int16_t n; + ivas_error error; for ( n = 0; n < num_in_chs; n++ ) { - if ( openCldfb( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { - return -1; + return error; } } for ( ; n < IVAS_MAX_INPUT_CHANNELS; n++ ) @@ -9257,17 +9202,17 @@ int16_t IVAS_REND_openCldfb( for ( n = 0; n < num_out_chs; n++ ) { - if ( openCldfb( &( cldfbSyn[n] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( cldfbSyn[n] ), CLDFB_SYNTHESIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { - return -1; + return error; } } - for ( ; n < IVAS_MAX_INPUT_CHANNELS; n++ ) + for ( ; n < IVAS_MAX_OUTPUT_CHANNELS; n++ ) { cldfbSyn[n] = NULL; } - return 0; + return IVAS_ERR_OK; } @@ -9279,7 +9224,7 @@ int16_t IVAS_REND_openCldfb( void IVAS_REND_closeCldfb( IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], - IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS] ) + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS] ) { int16_t n; @@ -9290,7 +9235,10 @@ void IVAS_REND_closeCldfb( deleteCldfb( &( cldfbAna[n] ) ); cldfbAna[n] = NULL; } + } + for ( n = 0; n < IVAS_MAX_OUTPUT_CHANNELS; n++ ) + { if ( cldfbSyn[n] != NULL ) { deleteCldfb( &( cldfbSyn[n] ) ); diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 6eb779b8baad51f7aebce4f59cf99c955e486e1e..c1d7360a46c04e2de69b264fd856d267f9a3a3eb 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -141,9 +141,8 @@ ivas_error IVAS_REND_Open( const int32_t outputSampleRate, /* i : output sampling rate */ const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ const int16_t nonDiegeticPan, /* i : non-diegetic object flag */ - const float nonDiegeticPanGain /* i : non-diegetic panning gain */ - , - const int16_t num_subframes + const float nonDiegeticPanGain, /* i : non-diegetic panning gain */ + const int16_t num_subframes /* i : number of subframes */ ); /* Note: this will reset custom LFE routings set for any MC input */ @@ -251,17 +250,19 @@ int16_t IVAS_REND_FeedRenderConfig( const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ ); -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error IVAS_REND_FeedSplitBinauralBitstream( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_REND_InputId inputId, /* i : ID of the input */ IVAS_REND_BitstreamBuffer *hBits /* i : buffer for input bitstream */ ); + ivas_error IVAS_REND_GetSplitBinauralSamples( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ bool* needNewFrame ); + ivas_error IVAS_REND_GetSplitBinauralBitstream( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ @@ -272,12 +273,11 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( ivas_error IVAS_REND_SetHeadRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ - const IVAS_VECTOR3 Pos /* i : listener positions for next rendering call */ + const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - IVAS_SPLIT_REND_ROT_AXIS rot_axis + IVAS_SPLIT_REND_ROT_AXIS rot_axis, #endif -, const int16_t sf_idx + const int16_t sf_idx ); /* Head rotation becomes enabled by calling IVAS_REND_SetHeadRotation. Use this to disable. */ @@ -323,8 +323,8 @@ ivas_error IVAS_REND_SetExternalOrientation( int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ - int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const int16_t sf_idx /*i : subframe index*/ + int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const int16_t sf_idx /* i : subframe index */ ); ivas_error IVAS_REND_CombineHeadAndExternalOrientation( @@ -337,16 +337,16 @@ ivas_error IVAS_REND_GetCombinedOrientation( ); ivas_error IVAS_REND_GetMasaMetadata( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to analyzed MASA metadata */ - IVAS_REND_AudioConfigType inputType /* i : Input type */ + const IVAS_REND_AudioConfigType inputType /* i : Input type */ ); ivas_error IVAS_REND_MergeMasaMetadata( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to merged metadata */ - IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ - IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ + const IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ + const IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ ); ivas_error IVAS_REND_SetTotalNumberOfObjects( @@ -379,9 +379,9 @@ void IVAS_REND_Close( #ifdef SPLIT_REND_WITH_HEAD_ROT /* Split binaural rendering functions */ -int16_t IVAS_REND_openCldfb( +ivas_error IVAS_REND_openCldfb( IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], - IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS], + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS], const int16_t num_in_chs, const int16_t num_out_chs, const int32_t output_Fs @@ -389,7 +389,7 @@ int16_t IVAS_REND_openCldfb( void IVAS_REND_closeCldfb( IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS], - IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS] + IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_OUTPUT_CHANNELS] ); void IVAS_REND_cldfbAnalysis_ts_wrapper( diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 95d9b7c881c670d2658c59a8b43099661e9b6320..650768457954cce72d36277ef0e4f1e228d9e47b 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -706,6 +706,7 @@ static ivas_error create_HRTF_from_rawdata( uint32_t mem_size; char *hrtf_data_rptr; float *pOut_to_bin_wptr; + ivas_error error; if ( *hHRTF == NULL ) { @@ -714,7 +715,10 @@ static ivas_error create_HRTF_from_rawdata( return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Can not allocate memory for HRTF binary data\n" ); } - ivas_hrtf_init( *hHRTF ); + if ( ( error = ivas_hrtf_init( *hHRTF ) ) != IVAS_ERR_OK ) + { + return error; + } } else { diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index 86db58bb7ff855589f012c32ca06685a27ffa837..40028c2ad88913dddc4dcba6b9aa923ed9a3f625 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -52,7 +52,8 @@ ivas_error split_rend_writer_open( const int32_t delayTimeScale ); /* Closes the split renderer reader/writer and deallocates memory */ -ivas_error split_rend_reader_writer_close( SplitFileReadWrite **hhSplitRendFileReadWrite ); +ivas_error split_rend_reader_writer_close( + SplitFileReadWrite **hhSplitRendFileReadWrite ); /*write split rend coded bitstream to file */ ivas_error split_rend_write_bitstream_to_file(