diff --git a/apps/decoder.c b/apps/decoder.c index 736e6130ffd953212dfa44acf2fbd555653767af..09b40cda9c1dde8462669a93d8a6e275ceea9c4f 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -489,7 +489,7 @@ int main( { if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "\nSplit rendering configure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } @@ -671,8 +671,7 @@ int main( } #endif #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || - arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( asked_frame_size != IVAS_RENDER_FRAMESIZE_20MS && ( renderConfig.split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE || @@ -722,6 +721,7 @@ int main( } renderConfig.roomAcoustics.override = true; } + #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* ISAR frame size is set from command line, not renderer config file. @@ -1477,7 +1477,7 @@ static bool parseCmdlIVAS_dec( arg->outputMdFilename = argv[i + 1]; if ( arg->outputMdFilename[0] == '\0' ) { - fprintf( stderr, "Error: output metadata file path not specified\n\n" ); + fprintf( stderr, "Error: Split rendering output metadata file path not specified\n\n" ); usage_dec(); return false; } @@ -1903,6 +1903,9 @@ static ivas_error initOnFirstGoodFrame( #endif ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t isSplitRend, isSplitCoded; +#endif ivas_error error = IVAS_ERR_UNKNOWN; /* Now delay, number of output channels and frame size are known */ @@ -1913,7 +1916,19 @@ static ivas_error initOnFirstGoodFrame( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error ); + return error; + } + + if ( ( error = IVAS_DEC_is_split_rendering_coded_out( hIvasDec, &isSplitCoded ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error ); + return error; + } + + if ( isSplitRend ) { pFullDelayNumSamples[0] = 0; } @@ -1940,7 +1955,7 @@ static ivas_error initOnFirstGoodFrame( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + if ( isSplitRend ) { /* Open split rendering metadata writer */ int16_t delayNumSamples_temp[3]; @@ -1959,39 +1974,23 @@ static ivas_error initOnFirstGoodFrame( return error; } - if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, - &splitRendCodec, - &poseCorrection, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - &splitRendIsarFrameSizeMs, -#endif - &splitRendCodecFrameSizeMs #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - &lc3plusHighRes + if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, &splitRendCodec, &poseCorrection, &splitRendIsarFrameSizeMs, &splitRendCodecFrameSizeMs, &lc3plusHighRes ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, &splitRendCodec, &poseCorrection, &splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to get split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); return error; } - if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) ) + if ( isSplitCoded ) { - if ( ( error = split_rend_writer_open( splitRendWriter, - arg.outputWavFilename, - delayNumSamples_temp[0], - delayTimeScale_temp, - splitRendCodec, - poseCorrection, - splitRendCodecFrameSizeMs #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - splitRendIsarFrameSizeMs, - arg.output_Fs, - lc3plusHighRes + if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK ) +#else + if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); return error; @@ -2005,20 +2004,11 @@ static ivas_error initOnFirstGoodFrame( return IVAS_ERR_INVALID_SPLIT_REND_CONFIG; } - if ( ( error = split_rend_writer_open( splitRendWriter, - arg.outputMdFilename, - delayNumSamples_temp[0], - delayTimeScale_temp, - splitRendCodec, - poseCorrection, - splitRendCodecFrameSizeMs #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - splitRendIsarFrameSizeMs, - arg.output_Fs, - lc3plusHighRes + if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK ) +#else + if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); return error; @@ -2026,7 +2016,7 @@ static ivas_error initOnFirstGoodFrame( } } - if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 ) + if ( !isSplitCoded ) { #endif /* Open audio writer and write all previously skipped bad frames now that frame size is known */ @@ -2264,6 +2254,19 @@ static ivas_error decodeG192( int16_t vec_pos_update, vec_pos_len; #ifdef SPLIT_REND_WITH_HEAD_ROT SplitFileReadWrite *splitRendWriter = NULL; + int16_t isSplitRend, isSplitCoded; + + if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error ); + return error; + } + + if ( ( error = IVAS_DEC_is_split_rendering_coded_out( hIvasDec, &isSplitCoded ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error ); + return error; + } #endif #ifdef FIX_1053_REVERB_RECONFIGURATION @@ -2291,6 +2294,7 @@ static ivas_error decodeG192( } } #endif + for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { ismWriters[i] = NULL; @@ -2586,7 +2590,7 @@ static ivas_error decodeG192( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + if ( isSplitRend ) { if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) { @@ -2602,10 +2606,8 @@ static ivas_error decodeG192( #endif #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 { fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2668,7 +2670,7 @@ static ivas_error decodeG192( if ( decodedGoodFrame ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) + if ( isSplitRend ) { if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK ) { @@ -2677,7 +2679,7 @@ static ivas_error decodeG192( } } - if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 ) + if ( !isSplitCoded ) { #endif if ( delayNumSamples < nOutSamples ) @@ -2950,6 +2952,7 @@ static ivas_error decodeG192( *------------------------------------------------------------------------------------------*/ memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) ); + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( afWriter != NULL ) { @@ -3360,12 +3363,11 @@ static ivas_error decodeVoIP( 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; @@ -3452,7 +3454,6 @@ static ivas_error decodeVoIP( /* decode and get samples */ - #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 4113ea494f59876b042cf7aa3e1a16f588f52adc..756ecf5f5e9550113d5fcc937eb7da83e1c5db3c 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -229,6 +229,7 @@ static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ); static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer ); + /*------------------------------------------------------------------------------------------* * Local functions *------------------------------------------------------------------------------------------*/ @@ -275,10 +276,6 @@ static int16_t getTotalNumInChannels( return totalNumInChannels; } -/*------------------------------------------------------------------------------------------* - * Local functions - *------------------------------------------------------------------------------------------*/ - static const CmdLnParser_Option *findOptionById( const int32_t id ) { @@ -440,6 +437,7 @@ static bool checkRequiredArgs( return !missingRequiredArg; } + static CmdlnArgs defaultArgs( const char *executableName ) { @@ -470,6 +468,7 @@ static CmdlnArgs defaultArgs( return args; } + static void parseOption( const int32_t optionId, char **optionValues, @@ -562,6 +561,7 @@ static void parseOption( return; } + static CmdlnArgs parseCmdlnArgs( const int argc, char **argv ) @@ -600,6 +600,7 @@ static void printSupportedAudioConfigs( void ) return; } + /*--------------------------------------------------------------------------* * convertInputBuffer() * @@ -638,6 +639,7 @@ static void convertInputBuffer( return; } + /*--------------------------------------------------------------------------* * convertOutputBuffer() * @@ -679,6 +681,7 @@ static void convertOutputBuffer( return; } + /*------------------------------------------------------------------------------------------* * main() * @@ -738,6 +741,9 @@ int main( bitsBuffer.config.codec_frame_size_ms = 20; #endif + /*------------------------------------------------------------------------------------------* + * Parse command-line arguments + *------------------------------------------------------------------------------------------*/ CmdlnArgs args = parseCmdlnArgs( argc, argv ); @@ -745,6 +751,10 @@ int main( convert_backslash( args.outputFilePath ); convert_backslash( args.headRotationFilePath ); + /*------------------------------------------------------------------------------------------* + * Open head-rotation file + *------------------------------------------------------------------------------------------*/ + if ( !isEmptyString( args.headRotationFilePath ) ) { if ( RotationFileReader_open( args.headRotationFilePath, &headRotReader ) != IVAS_ERR_OK ) @@ -754,12 +764,20 @@ int main( } } + /*------------------------------------------------------------------------------------------* + * Open BFI file + *------------------------------------------------------------------------------------------*/ + if ( !isEmptyString( args.splitRendBFIFilePath ) ) { convert_backslash( args.splitRendBFIFilePath ); SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); } + /*------------------------------------------------------------------------------------------* + * Open input files + *------------------------------------------------------------------------------------------*/ + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int32_t inFileSampleRate = 0; #endif @@ -867,6 +885,11 @@ int main( exit( -1 ); } } + + /*------------------------------------------------------------------------------------------* + * Open ISAR handle + *------------------------------------------------------------------------------------------*/ + const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_BINAURAL; if ( ( error = ISAR_POST_REND_open( &hIsarPostRend, args.sampleRate, args.outConfig.audioConfig, true, 0, 0.0, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) @@ -875,7 +898,10 @@ int main( exit( -1 ); } - /* === Configure === */ + /*------------------------------------------------------------------------------------------* + * Configuration + *------------------------------------------------------------------------------------------*/ + if ( ( error = ISAR_POST_REND_InitConfig( hIsarPostRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in Renderer Config Init: %s\n", ivas_error_to_string( error ) ); @@ -900,9 +926,7 @@ int main( } } - ISAR_POST_REND_InputId splitBinIds[RENDERER_MAX_BIN_INPUTS]; - for ( i = 0; i < RENDERER_MAX_BIN_INPUTS; i++ ) { splitBinIds[i] = 0u; @@ -918,7 +942,6 @@ int main( } const int16_t totalNumInChannels = getTotalNumInChannels( hIsarPostRend, splitBinIds ); - if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels ) { fprintf( stderr, "Number of channels in input file does not match selected configuration\n" ); @@ -926,13 +949,16 @@ int main( } int16_t numOutChannels = 2; - if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); exit( -1 ); } + /*------------------------------------------------------------------------------------------* + * Allocate processing buffers + *------------------------------------------------------------------------------------------*/ + inBufferSize = frameSize_smpls * totalNumInChannels; outBufferSize = frameSize_smpls * numOutChannels; inpInt16Buffer = malloc( inBufferSize * sizeof( int16_t ) ); @@ -985,6 +1011,13 @@ int main( fprintf( stdout, "\n\n-- Start the ISAR post renderer (quiet mode) --\n\n" ); } + /*------------------------------------------------------------------------------------------* + * Loop for every frame of data + * - Read the input data + * - Run the post-rendering + * - Write the data into output file + *------------------------------------------------------------------------------------------*/ + while ( 1 ) { int16_t num_in_channels; @@ -1215,7 +1248,10 @@ int main( } #endif - /* === Close === */ + /*------------------------------------------------------------------------------------------* + * Close files and deallocate resources + *------------------------------------------------------------------------------------------*/ + free( inpInt16Buffer ); free( inFloatBuffer ); free( outInt16Buffer ); diff --git a/apps/renderer.c b/apps/renderer.c index 6a9f1048f31b6172043654890b20b5255f35c4bd..42ed96ce73c847ebf388c1aafd472f3df2ef8a6a 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -660,6 +660,7 @@ static int16_t get_cldfb_in_flag( return cldfb_in_flag; } + static int16_t is_split_pre_rend_mode( CmdlnArgs *args ) { @@ -774,6 +775,7 @@ int main( bitsBuffer.config.codec_frame_size_ms = 20; #endif #endif + for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { lfeRoutingConfigs[i] = NULL; @@ -837,6 +839,7 @@ int main( SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); } #endif + if ( !isEmptyString( args.externalOrientationFilePath ) ) { if ( RotationFileReader_open( args.externalOrientationFilePath, &externalOrientationFileReader ) != IVAS_ERR_OK ) @@ -1074,7 +1077,6 @@ int main( } #endif - if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK ) { #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1385,16 +1387,15 @@ int main( if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { - - IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, - &bitsBuffer.config.codec, - &bitsBuffer.config.poseCorrection, - &bitsBuffer.config.codec_frame_size_ms #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - &bitsBuffer.config.isar_frame_size_ms + if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms ) ) != IVAS_ERR_OK ) #endif - ); + { + fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader()!\n" ); + exit( -1 ); + } if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) { @@ -1402,20 +1403,11 @@ int main( exit( -1 ); } - if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, - args.outputFilePath, - delayNumSamples_temp, - delayTimeScale_temp, - bitsBuffer.config.codec, - bitsBuffer.config.poseCorrection, - bitsBuffer.config.codec_frame_size_ms #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - bitsBuffer.config.isar_frame_size_ms, - args.sampleRate, - bitsBuffer.config.lc3plus_highres + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outputFilePath, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) +#else + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outputFilePath, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.outputFilePath ); exit( -1 ); @@ -1426,16 +1418,15 @@ int main( { if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - - IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, - &bitsBuffer.config.codec, - &bitsBuffer.config.poseCorrection, - &bitsBuffer.config.codec_frame_size_ms #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - &bitsBuffer.config.isar_frame_size_ms + if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms ) ) != IVAS_ERR_OK ) #endif - ); + { + fprintf( stderr, "\nError in IVAS_REND_GetSplitRendBitstreamHeader()!\n" ); + exit( -1 ); + } if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) { @@ -1443,20 +1434,11 @@ int main( exit( -1 ); } - if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, - args.outMetadataFilePath, - delayNumSamples_temp, - delayTimeScale_temp, - bitsBuffer.config.codec, - bitsBuffer.config.poseCorrection, - bitsBuffer.config.codec_frame_size_ms #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - bitsBuffer.config.isar_frame_size_ms, - args.sampleRate, - bitsBuffer.config.lc3plus_highres + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outMetadataFilePath, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) +#else + if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, args.outMetadataFilePath, delayNumSamples_temp, delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.outMetadataFilePath ); exit( -1 ); @@ -1842,7 +1824,7 @@ int main( { if ( ( error = IVAS_REND_GetSplitBinauralBitstream( hIvasRend, outBuffer, &bitsBuffer ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + fprintf( stderr, "Error in IVAS_REND_GetSplitBinauralBitstream(): %s\n", ivas_error_to_string( error ) ); exit( -1 ); } } @@ -1852,7 +1834,7 @@ int main( if ( ( error = IVAS_REND_GetSamples( hIvasRend, outBuffer ) ) != IVAS_ERR_OK ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - fprintf( stderr, "Error %s\n", ivas_error_to_string( error ) ); + fprintf( stderr, "Error in IVAS_REND_GetSamples()%s\n", ivas_error_to_string( error ) ); #else fprintf( stderr, "Error in getting samples\n" ); #endif @@ -2058,7 +2040,6 @@ int main( } #endif - if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( 1000 / IVAS_NUM_FRAMES_PER_SEC / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); @@ -2097,6 +2078,7 @@ cleanup: free( bitsBufferData ); } #endif + #ifdef FIX_1053_REVERB_RECONFIGURATION if ( args.aeSequence.count > 0 ) { diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 07715a9ef4f78d1208634252d6911616b86c6ed4..0d596030ce1e810c4e11d17dbca57546e2f44921 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -277,7 +277,7 @@ typedef struct _ISAR_SPLIT_REND_CONFIG 2 - (2dof correction. By default YAW and PITCH correction) 3 - (3dof correction. By default YAW, PITCH and ROLL correction) */ - int16_t codec_delay_ms; /*PLACEHOLDER (currently being ignored) : look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/ + int16_t codec_delay_ms; /* look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t isar_frame_size_ms; /* ISAR bit stream frame size in milliseconds */ #endif @@ -348,6 +348,7 @@ typedef struct #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t is_cldfb; #endif + } IVAS_REND_AudioBufferConfig; typedef struct diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 2d62e340a80cfd83c059a6875a28b44e3358aee2..fa17c75daae1a53ff25ad6d11380529f721f0981 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -55,8 +55,8 @@ int32_t get_delay( const int32_t io_fs, /* i : input/output sampling frequency */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ #ifdef SPLIT_REND_WITH_HEAD_ROT - HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ - const AUDIO_CONFIG output_config /* i : decoder output config */ + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ + const int16_t flag_binaural_split_coded /* i : split rendering on/off flag */ #else HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ #endif @@ -103,7 +103,7 @@ int32_t get_delay( delay = IVAS_DEC_DELAY_NS; #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) + if ( !flag_binaural_split_coded ) { #endif if ( hCldfb != NULL ) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c2bf977774330444627dcd4f290d320fae3bbe0b..258a8b0f9187638629d9ec0c664e5210420276cd 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5185,7 +5185,7 @@ void ivas_binaural_cldfb_sf( void ivas_binRenderer( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ #endif COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ const int16_t numTimeSlots, /* i : number of time slots to process */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 1e08bbfec1a493099b8b17963340d0cf893bb429..f9d9648575c1ce8b3c4b8facae5891afcc441f50 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -724,13 +724,14 @@ int16_t lev_dur( /*! r: delay value in ns */ int32_t get_delay( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t io_fs, /* i : input/output sampling frequency */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ + const int16_t enc_dec, /* i : encoder/decoder flag */ + const int32_t io_fs, /* i : input/output sampling frequency */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - const AUDIO_CONFIG output_config /* i : decoder output config */ + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ + const int16_t flag_binaural_split_coded /* i : split rendering on/off flag */ +#else + HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ #endif ); diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index d1d2d6f7bcf28925ad4bccd3f4a4f0896213e934..7258a684892176fd74a48ee916a4b3436121ef71 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -405,6 +405,7 @@ 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]; @@ -2215,13 +2216,14 @@ void ivas_rend_CldfbMultiBinRendProcess( head_track_post.num_quaternions = 0; head_track_post.shd_rot_max_order = -1; head_track_post.Quaternions[0] = ivas_split_rend_get_sf_rot_data( pHeadRotData->headPositionsPostRend, sf_idx ); -#endif +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, &head_track_post, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); #else ivas_binRenderer( hCldfbRend, pMultiBinPoseData, *pCombinedOrientationData, MAX_PARAM_SPATIAL_SUBFRAMES, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer_sfIn, Cldfb_ImagBuffer_sfIn ); #endif + for ( pose_idx = 0; pose_idx < hCldfbRend->numPoses; pose_idx++ ) { for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index bbbd8d9f97974ca5f2d0fc60c46e8eb20c906fba..692782bda8ecee2306615c87796f397c4ebe9af4 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -924,7 +924,6 @@ ivas_error ivas_dirac_dec_config( #else if ( !st_ivas->hDiracDecBin->useTdDecorr ) #endif - { #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params == NULL ) @@ -2381,17 +2380,16 @@ void ivas_dirac_dec_render_sf( #endif /* Perform binaural rendering */ - ivas_binRenderer( st_ivas->hBinRenderer, #ifdef SPLIT_REND_WITH_HEAD_ROT - ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, + ivas_binRenderer( st_ivas->hBinRenderer, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], +#else + ivas_binRenderer( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], #endif - - st_ivas->hCombinedOrientationData, - hSpatParamRendCom->subframe_nbslots[subframe_idx], #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, #endif Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 9b29070053204464818ffc59ee636f6e353c9597..94bddfd1209fa7901b9ed4ecfeb886334e02f9ff 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -37,11 +37,6 @@ #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "prot.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT -#include "lib_isar_pre_rend.h" -#include "isar_prot.h" -#include "isar_stat.h" -#endif #include #include #include @@ -63,186 +58,6 @@ static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ); #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT -static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); - - -/*-------------------------------------------------------------------* - * ivas_dec_reconfig_split_rend() - * - * IVAS decoder split rend reconfig - *-------------------------------------------------------------------*/ - -static ivas_error ivas_dec_reconfig_split_rend( - Decoder_Struct *st_ivas /* i : IVAS decoder structure */ -) -{ - ivas_error error; - int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; - SPLIT_REND_WRAPPER *hSplitRendWrapper; - - hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend; - 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_flag = 1; - } - - ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); - - isCldfbNeeded = 0; - - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || - ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) - { - cldfb_in_flag = 0; - } - - if ( st_ivas->renderer_type != RENDERER_DISABLE ) - { - if ( cldfb_in_flag == 0 ) - { - isCldfbNeeded = 1; - } - else if ( st_ivas->hRenderConfig->split_rend_config.codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) - { - isCldfbNeeded = 1; - } - else if ( pcm_out_flag && cldfb_in_flag ) - { - isCldfbNeeded = 1; - } - } - else if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) - { - isCldfbNeeded = 1; - } - - if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL ) - { - if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); - } - - num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; - for ( ch = 0; ch < num_ch; ch++ ) - { - hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; - } - - num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; - - for ( ch = 0; ch < num_ch; ch++ ) - { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, 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" ) ); - } - } - - 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 ) - { - return error; - } - } - } - else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) - { - num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; - for ( ch = 0; ch < num_ch; ch++ ) - { - if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) - { - deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); - hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; - } - } - - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) - { - deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); - hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; - } - } - - free( hSplitRendWrapper->hCldfbHandles ); - hSplitRendWrapper->hCldfbHandles = NULL; - } - - if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) && - ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) && - !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) /* td-rend not needed? */ - { - for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) - { - if ( st_ivas->hTdRendHandles[i] != NULL ) - { - st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; - ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] ); - } - } - } - - return IVAS_ERR_OK; -} - - -/*-------------------------------------------------------------------* - * ivas_dec_init_split_rend() - * - * IVAS decoder split rend init - *-------------------------------------------------------------------*/ - -static ivas_error ivas_dec_init_split_rend( - Decoder_Struct *st_ivas /* i : IVAS decoder structure */ -) -{ - ivas_error error; - int16_t cldfb_in_flag, pcm_out_flag; - int16_t mixed_td_cldfb_flag; - - 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_flag = 1; - } - - ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); - - if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) - { - if ( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); - } - } - - mixed_td_cldfb_flag = 0; - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || - ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) - { - mixed_td_cldfb_flag = 1; - } - - error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); - return error; -} -#endif #ifdef NONBE_FIX_1052_SBA_EXT static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ) @@ -277,8 +92,8 @@ 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) */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + 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 @@ -458,7 +273,6 @@ ivas_error ivas_dec_setup( #else if ( ( error = ivas_omasa_dec_config( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - { return error; } @@ -750,20 +564,6 @@ ivas_error ivas_dec_setup( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT - /*-----------------------------------------------------------------* - * reconfig split rendering as renderer might change after bitrate switching - *-----------------------------------------------------------------*/ - - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - { - if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif - /*----------------------------------------------------------------* * Reset bitstream pointers *----------------------------------------------------------------*/ @@ -1334,21 +1134,6 @@ ivas_error ivas_init_decoder( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT - /*-----------------------------------------------------------------* - * Initialize binuaral split rendering - *-----------------------------------------------------------------*/ - - if ( st_ivas->hSplitBinRend != NULL && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || - ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) ) - { - if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif - /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ @@ -2852,7 +2637,6 @@ void ivas_destroy_dec( #endif /* Crend handle */ - #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); #else @@ -3008,6 +2792,7 @@ void ivas_init_dec_get_num_cldfb_instances( *numCldfbAnalyses = st_ivas->nchan_transport + 1; } } + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDiracDecBin[0]->useTdDecorr ) #else diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 35752bdd225c23812dd3809f7ef659b216ed17c0..5be65a9e49b419c6bf4201782fc5275359c83f71 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -424,17 +424,15 @@ ivas_error ivas_ism_dec_config( if ( st_ivas->ini_active_frame != 0 ) { /* ISM bit-rate switching */ + if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) { - 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, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) - { - return error; - } + { + return error; } } } @@ -454,11 +452,11 @@ ivas_error ivas_ism_dec_config( /* ISM mode switching */ if ( st_ivas->ism_mode != last_ism_mode ) { - if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 883f170d608f7a00ba4dac9208d2d386e011bf5e..c6b1c22b5bdf00976fc1a5647847e7d8746a63de 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1344,9 +1344,6 @@ ivas_error ivas_jbm_dec_render( } else { -#endif - -#if defined SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else @@ -1406,7 +1403,7 @@ ivas_error ivas_jbm_dec_render( if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && !st_ivas->hDecoderConfig->Opt_Headrotation ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - /*handled in CLDFB domain already*/ + /* handled in CLDFB domain already */ if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #endif { @@ -1508,7 +1505,7 @@ ivas_error ivas_jbm_dec_render( nchan_out_syn_output = nchan_out; } - if ( st_ivas->hDecoderConfig->Opt_Limiter ) + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) #endif { if ( st_ivas->ivas_format != MONO_FORMAT ) @@ -1568,7 +1565,7 @@ ivas_error ivas_jbm_dec_flush_renderer( uint16_t *nSamplesRendered, /* o : number of samples flushed */ #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 @@ -1811,7 +1808,7 @@ ivas_error ivas_jbm_dec_flush_renderer( /* Only write out the valid data*/ #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( st_ivas->hDecoderConfig->Opt_Limiter ) + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) #endif { if ( st_ivas->ivas_format != MONO_FORMAT ) @@ -1830,12 +1827,11 @@ ivas_error ivas_jbm_dec_flush_renderer( #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, #ifdef SPLIT_REND_WITH_HEAD_ROT - (int16_t *) + ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) data ); +#else + ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, data ); #endif - data ); - #ifdef SPLIT_REND_WITH_HEAD_ROT break; case PCM_FLOAT32: diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index c1542e3d8babc4d710abbd94845c9041d097b627..afe78367fad74e0a3beb431adbd4362208b175b7 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1491,6 +1491,7 @@ ivas_error ivas_masa_dec_reconfigure( /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDiracDecBin[0] != NULL ) #else diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 20e40412de2d8430748850d5fa0ea40ef309484e..39b74728e1b4eb0c6e606a7fc734b83ba0ab4fec 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -725,7 +725,6 @@ ivas_error ivas_mc_dec_config( #else if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - { return error; } @@ -1269,7 +1268,6 @@ 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 { - #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); #else diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 2e464e1641a66332561423f881ecf93600867b4e..8a1a9604779ccc447b6ed7653f1b0b55eeb96e7b 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -189,11 +189,11 @@ void ivas_omasa_data_close( *--------------------------------------------------------------------------*/ ivas_error ivas_omasa_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + 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 */ + 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 @@ -482,7 +482,6 @@ ivas_error ivas_omasa_dec_config( #else if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) #endif - { return error; } @@ -823,6 +822,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index cca48cd7041d19e0eb99c1db40c4f910166ddea7..f49adaccfec0cee5a44e0d1b5379e91d7d4f5e1b 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -170,10 +170,12 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( num_cldfb_bands = st_ivas->hSplitBinRend->splitrend.hCldfbHandles->cldfbAna[0]->no_channels; nchan_transport_orig = st_ivas->nchan_transport; st_ivas->nchan_transport = st_ivas->nchan_ism; + if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, output_f, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; } + st_ivas->nchan_transport = nchan_transport_orig; cldfb_slots = *nSamplesRendered / num_cldfb_bands; @@ -199,7 +201,6 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( else { #endif - if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_sepobj, *nSamplesRendered ) ) != IVAS_ERR_OK ) { return error; @@ -216,6 +217,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index a547d96ac06596135212b49a26ae75c0dd2f3d3a..86ec1cd02ad45ee237b733d87398dfcb5e3774da 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -157,11 +157,11 @@ void ivas_renderer_select( { *internal_config = IVAS_AUDIO_CONFIG_HOA3; - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL #ifdef SPLIT_REND_WITH_HEAD_ROT - || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL ) #endif - ) { *renderer_type = RENDERER_BINAURAL_FASTCONV; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 110b45b15ff39221701ad10762f723d445ca9059..a83a51db1db5c9d979544be46a7239f6c345a69f 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -205,11 +205,11 @@ ivas_error ivas_sba_dec_reconfigure( } else { - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL #ifdef SPLIT_REND_WITH_HEAD_ROT - || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL ) #endif - ) { renderer_type_new = RENDERER_BINAURAL_FASTCONV; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index ed4653e1049f9f48d87f1ff93a49ed9a95b6efe1..94d070077e430597fa52f7d28afdf0c14ae0bf5d 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -40,7 +40,6 @@ #include "stat_dec.h" #include "ivas_stat_com.h" #include "ivas_stat_rend.h" -#include "isar_stat.h" /*----------------------------------------------------------------------------------* @@ -1026,9 +1025,6 @@ typedef struct decoder_config_structure int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ #endif int16_t Opt_tsm; /* indicates whether time scaling modification is activated */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t Opt_Limiter; -#endif IVAS_RENDER_FRAMESIZE render_framesize; int16_t Opt_delay_comp; /* flag indicating delay compensation active */ @@ -1140,7 +1136,7 @@ typedef struct Decoder_Struct #ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; /* ISAR split binaural rendering handle */ - BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1]; + BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1]; /* TD object renderer handles */ #endif /* JBM module */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 9f59528a0c12306f1137782b232e6f9ce55042ea..c11dcb78bc60ea4b329ca23d7477276851ffccc8 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -128,6 +128,8 @@ static PCM_RESOLUTION pcm_type_API_to_internal( const IVAS_DEC_PCM_TYPE pcmType static void *pcm_buffer_offset( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int32_t offset ); static ivas_error set_pcm_buffer_to_zero( void *buffer, const IVAS_DEC_PCM_TYPE pcmType, const int16_t nZeroSamples ); static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); +static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); +static ivas_error ivas_dec_init_split_rend( Decoder_Struct *st_ivas ); static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); #endif @@ -253,6 +255,7 @@ ivas_error IVAS_DEC_Open( return IVAS_ERR_WRONG_PARAMS; } + #ifdef SPLIT_REND_WITH_HEAD_ROT /*-------------------------------------------------------------------------* * isar_set_split_rend_setup() @@ -264,7 +267,7 @@ static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ ) { splitRendBits->bits_read = 0; @@ -315,9 +318,6 @@ static void init_decoder_config( hDecoderConfig->Opt_non_diegetic_pan = 0; hDecoderConfig->non_diegetic_pan_gain = 0; hDecoderConfig->Opt_tsm = 0; -#ifdef SPLIT_REND_WITH_HEAD_ROT - hDecoderConfig->Opt_Limiter = 1; -#endif hDecoderConfig->Opt_delay_comp = 0; hDecoderConfig->Opt_ExternalOrientation = 0; hDecoderConfig->Opt_dpid_on = 0; @@ -553,14 +553,10 @@ 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; - ivas_error error; - - error = IVAS_ERR_OK; - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -572,9 +568,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( hDecoderConfig->Opt_Headrotation = 1; hDecoderConfig->render_framesize = IVAS_RENDER_FRAMESIZE_20MS; - hDecoderConfig->Opt_Limiter = 0; - - return error; + return IVAS_ERR_OK; } #endif @@ -910,13 +904,13 @@ 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 */ #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 */ + 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 */ #endif int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o :indication that the decoder needs a new frame */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { ivas_error error; @@ -989,7 +983,6 @@ ivas_error IVAS_DEC_GetSamples( if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { /* setup */ - #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ) ) ) != IVAS_ERR_OK ) #else @@ -1103,11 +1096,11 @@ ivas_error IVAS_DEC_GetSamples( *---------------------------------------------------------------------*/ 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 */ - ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o : 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 */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits, /* o : output split rendering bits */ + 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; @@ -1154,7 +1147,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( numSamplesPerChannelToDecode *= (int16_t) st_ivas->hDecoderConfig->render_framesize; } - if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) == 0 ) + if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 ) { return IVAS_ERR_WRONG_PARAMS; } @@ -1176,7 +1169,6 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( } } - /* Decode and render */ if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { @@ -1246,6 +1238,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Quaternion.y = 0.0f; Quaternion.z = 0.0f; } + if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hSplitBinRend->splitrend, Quaternion, st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, @@ -1258,7 +1251,6 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, max_band, pOutput, 1, !td_input, pcm_out_flag, ro_md_flag ) ) != IVAS_ERR_OK ) - { return error; } @@ -1356,6 +1348,31 @@ static ivas_error IVAS_DEC_Setup( *nTransportChannels = (uint8_t) st_ivas->hTcBuffer->nchan_transport_jbm; *nTcBufferGranularity = (uint16_t) st_ivas->hTcBuffer->n_samples_granularity; *nOutChannels = (uint8_t) st_ivas->hDecoderConfig->nchan_out; + + +#ifdef SPLIT_REND_WITH_HEAD_ROT + /*-----------------------------------------------------------------* + * ISAR: + * - initialize ISAR handle at the first frame + * - reconfigure the ISAR handle in case of bitrate switching (renderer might change) + *-----------------------------------------------------------------*/ + if ( st_ivas->ini_frame == 0 && ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) ) ) + { + if ( ( error = ivas_dec_init_split_rend( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + if ( ( error = ivas_dec_reconfig_split_rend( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + +#endif } return IVAS_ERR_OK; @@ -1452,10 +1469,10 @@ static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ 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 */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renderer pipeline */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf /* o : output synthesis signal */ #else int16_t *pcmBuf #endif @@ -2132,24 +2149,11 @@ static ivas_error copyRendererConfigStruct( mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS ); + #ifdef SPLIT_REND_WITH_HEAD_ROT - /* TODO: This seems wrong. Why set default instead of copying from hRCin? - * Currently seems to work because we only ever copy from a default-initialized handle anyway */ - hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k; - hRCout->split_rend_config.dof = 3; - hRCout->split_rend_config.hq_mode = 0; - hRCout->split_rend_config.codec_delay_ms = 0; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - hRCout->split_rend_config.isar_frame_size_ms = 20; -#endif - hRCout->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ - hRCout->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; - hRCout->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; - hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - hRCout->split_rend_config.lc3plus_highres = hRCin->split_rend_config.lc3plus_highres; -#endif + hRCout->split_rend_config = hRCin->split_rend_config; #endif + hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; @@ -2376,7 +2380,7 @@ ivas_error IVAS_DEC_GetDelay( hDecoderConfig = st_ivas->hDecoderConfig; #ifdef SPLIT_REND_WITH_HEAD_ROT - nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0], hDecoderConfig->output_config ) ); + nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0], hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ); #else nSamples[1] = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0] ) ); #endif @@ -2654,8 +2658,8 @@ 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 */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf, + 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 */ #endif @@ -2876,8 +2880,8 @@ 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 */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf, + 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 */ #endif @@ -3519,6 +3523,7 @@ static ivas_error evs_dec_main( st_ivas->noClipping += #endif ivas_syn_output( p_output, nOutSamples, st_ivas->hDecoderConfig->nchan_out, pcm_buf_local ); + mvs2r( pcm_buf_local, floatBuf, nOutSamples * st_ivas->hDecoderConfig->nchan_out ); } else @@ -3840,16 +3845,15 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ - ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ -#endif + int16_t *pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ + int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ + int16_t *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ +#else int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - int16_t *pLc3plusHighRes #endif ) { @@ -3865,6 +3869,7 @@ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( *pIsar_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms; *pLc3plusHighRes = hIvasDec->st_ivas->hRenderConfig->split_rend_config.lc3plus_highres; #endif + return IVAS_ERR_OK; } @@ -4078,27 +4083,202 @@ static void ivas_destroy_handle_isar( * *---------------------------------------------------------------------*/ -int16_t IVAS_DEC_is_split_rendering_enabled( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_enabled( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *isSplitRend /* o : flag to indicate if split rendering is enabled */ ) { Decoder_Struct *st_ivas; - int16_t isSplitRend; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + st_ivas = hIvasDec->st_ivas; - isSplitRend = 0; - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || - ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) + *isSplitRend = is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ); + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ivas_dec_reconfig_split_rend() + * + * IVAS decoder split rend reconfig + *-------------------------------------------------------------------*/ + +static ivas_error ivas_dec_reconfig_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; + SPLIT_REND_WRAPPER *hSplitRendWrapper; + + hSplitRendWrapper = &st_ivas->hSplitBinRend->splitrend; + 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_flag = 1; + } + + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + + isCldfbNeeded = 0; + + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + cldfb_in_flag = 0; + } + + if ( st_ivas->renderer_type != RENDERER_DISABLE ) + { + if ( cldfb_in_flag == 0 ) + { + isCldfbNeeded = 1; + } + else if ( st_ivas->hRenderConfig->split_rend_config.codec == ISAR_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) + { + isCldfbNeeded = 1; + } + else if ( pcm_out_flag && cldfb_in_flag ) + { + isCldfbNeeded = 1; + } + } + else if ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) { - isSplitRend = 1; + isCldfbNeeded = 1; } - return isSplitRend; + if ( isCldfbNeeded == 1 && hSplitRendWrapper->hCldfbHandles == NULL ) + { + if ( ( hSplitRendWrapper->hCldfbHandles = (CLDFB_HANDLES_WRAPPER_HANDLE) malloc( sizeof( CLDFB_HANDLES_WRAPPER ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB handles\n" ) ); + } + + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } + + num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; + + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, 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" ) ); + } + } + + 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 ) + { + return error; + } + } + } + else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) + { + num_ch = MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; + for ( ch = 0; ch < num_ch; ch++ ) + { + if ( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] != NULL ) + { + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; + } + } + + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) + { + deleteCldfb( &hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ); + hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; + } + } + + free( hSplitRendWrapper->hCldfbHandles ); + hSplitRendWrapper->hCldfbHandles = NULL; + } + + if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) && + ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) && + !( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) + { + if ( st_ivas->hTdRendHandles[i] != NULL ) + { + st_ivas->hTdRendHandles[i]->HrFiltSet_p = NULL; + ivas_td_binaural_close( &st_ivas->hTdRendHandles[i] ); + } + } + } + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ivas_dec_init_split_rend() + * + * IVAS decoder split rend init + *-------------------------------------------------------------------*/ + +static ivas_error ivas_dec_init_split_rend( + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ +) +{ + ivas_error error; + int16_t cldfb_in_flag, pcm_out_flag; + int16_t mixed_td_cldfb_flag; + + 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_flag = 1; + } + + ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); + + if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) + { + if ( ( st_ivas->hSplitBinRend->hCldfbDataOut = (ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_CLDFB_OUT_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for cldfb data out buffer\n" ) ); + } + } + + mixed_td_cldfb_flag = 0; + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) || + ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + { + mixed_td_cldfb_flag = 1; + } + + error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); + + return error; } @@ -4108,26 +4288,29 @@ int16_t IVAS_DEC_is_split_rendering_enabled( * *---------------------------------------------------------------------*/ -int16_t IVAS_DEC_is_split_rendering_coded_out( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_coded_out( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *isSplitCoded /* o : flag to indicate if split rendering is enabled */ ) { Decoder_Struct *st_ivas; - int16_t isSplitCoded; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + st_ivas = hIvasDec->st_ivas; - isSplitCoded = 0; + + *isSplitCoded = 0; if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan && st_ivas->hRenderConfig->split_rend_config.dof == 0 ) ) { - isSplitCoded = 1; + *isSplitCoded = 1; } - return isSplitCoded; + return IVAS_ERR_OK; } #endif diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index bafbf36dace0112580f621a01166171d6dccfc98..6a0589e89798e0625c04a67212ed6f037e68821c 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -179,16 +179,15 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( /*! r: decoder error code */ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ - ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ -#endif - int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - int16_t *pLc3plusHighRes /* o: pointer to LC3plus High-Res setting */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + int16_t *pIsar_frame_size_ms, /* o : pointer to ISAR frame size setting */ + int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ + int16_t *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ +#else + int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ #endif ); @@ -201,11 +200,16 @@ ivas_error IVAS_DEC_GetCldfbSamples( int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ ); -int16_t IVAS_DEC_is_split_rendering_enabled( - IVAS_DEC_HANDLE hIvasDec /* i: IVAS decoder handle */ +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_enabled( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *isSplitRend /* o : flag to indicate if split rendering is enabled */ ); -int16_t IVAS_DEC_is_split_rendering_coded_out( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ + +/*! r: decoder error code */ +ivas_error IVAS_DEC_is_split_rendering_coded_out( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *isSplitCoded /* o : flag to indicate if split rendering is enabled */ ); #endif @@ -287,9 +291,9 @@ ivas_error IVAS_DEC_TSM_SetQuality( 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 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf, +#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 */ #endif @@ -304,8 +308,8 @@ 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 */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf, + 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 */ #endif diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 4a4be817345a9cedb37036c02ebdc5a9f0b66992..ccdc82d122f68c1482a3594c61f9c80921713d13 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1058,7 +1058,7 @@ ivas_error IVAS_ENC_GetDelay( } #ifdef SPLIT_REND_WITH_HEAD_ROT - *delay = NS2SA( hEncoderConfig->input_Fs, get_delay( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL, IVAS_AUDIO_CONFIG_INVALID ) ); + *delay = NS2SA( hEncoderConfig->input_Fs, get_delay( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL, 0 ) ); #else *delay = NS2SA( hEncoderConfig->input_Fs, get_delay( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL ) ); #endif diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c index 48031a865dbd0e0b58669438f615d1ecf1dab123..bec61755c0b161ff4f2e3d7105e0aaf87a3da314 100644 --- a/lib_isar/isar_PredDecoder.c +++ b/lib_isar/isar_PredDecoder.c @@ -40,6 +40,7 @@ #include "isar_rom_lcld_tables.h" #include "wmc_auto.h" + /*-------------------------------------------------------------------* * Function CreatePredictionDecoder() * @@ -64,6 +65,7 @@ ivas_error CreatePredictionDecoder( psPredictionDecoder->iNumBlocks = iNumBlocks; psPredictionDecoder->iNumSubSets = LCLD_BLOCKS_PER_FRAME / psPredictionDecoder->iNumBlocks; psPredictionDecoder->iSubSetId = 0; + /* PLC_IMPROVEMENT */ if ( ( psPredictionDecoder->ppiDecodingFailedPrev = (int32_t **) malloc( sizeof( int32_t * ) * iChannels ) ) == NULL ) { @@ -77,6 +79,7 @@ ivas_error CreatePredictionDecoder( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD decoder Module \n" ) ); } + for ( n = 0; n < iChannels; n++ ) { int32_t k; @@ -99,6 +102,7 @@ ivas_error CreatePredictionDecoder( psPredictionDecoder->ppiDecodingFailedPrev[n][k] = 0; } } + if ( ( psPredictionDecoder->piPredChanEnable = (int32_t *) malloc( sizeof( int32_t ) * iChannels ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); @@ -241,13 +245,14 @@ void DeletePredictionDecoder( return; } + /*-------------------------------------------------------------------* * Function ReadPredictors() * * *-------------------------------------------------------------------*/ -int32_t ReadPredictors( +int16_t ReadPredictors( PredictionDecoder *psPredictionDecoder, ISAR_SPLIT_REND_BITS_HANDLE pBits ) { @@ -270,6 +275,7 @@ int32_t ReadPredictors( { psPredictionDecoder->iSubSetId = 0; } + for ( c = 0; c < psPredictionDecoder->iChannels; c++ ) { psPredictionDecoder->piPredChanEnable[c] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, psPredictionDecoder->iNumSubSets ); @@ -337,8 +343,15 @@ int32_t ReadPredictors( return iBitsRead; } -/* PLC_IMPROVEMENT */ -void SetDecodingPassed( PredictionDecoder *psPredictionDecoder ) + +/*-------------------------------------------------------------------* + * Function SetDecodingPassed() + * + * + *-------------------------------------------------------------------*/ + +void SetDecodingPassed( + PredictionDecoder *psPredictionDecoder ) { int32_t n, ch; for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) @@ -348,8 +361,19 @@ void SetDecodingPassed( PredictionDecoder *psPredictionDecoder ) psPredictionDecoder->ppiDecodingFailed[ch][n] = 0; } } + + return; } -int32_t AnyDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) + + +/*-------------------------------------------------------------------* + * Function AnyDecodingUnresolved() + * + * + *-------------------------------------------------------------------*/ + +int32_t AnyDecodingUnresolved( + PredictionDecoder *psPredictionDecoder ) { int32_t n, ch; for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) @@ -365,9 +389,18 @@ int32_t AnyDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) return 0; } -void UpdateDecodingFailedStatus( PredictionDecoder *psPredictionDecoder ) + +/*-------------------------------------------------------------------* + * Function UpdateDecodingFailedStatus() + * + * + *-------------------------------------------------------------------*/ + +void UpdateDecodingFailedStatus( + PredictionDecoder *psPredictionDecoder ) { int32_t n, ch; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) { for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) @@ -375,9 +408,19 @@ void UpdateDecodingFailedStatus( PredictionDecoder *psPredictionDecoder ) psPredictionDecoder->ppiDecodingFailedPrev[ch][n] = psPredictionDecoder->ppiDecodingFailed[ch][n]; } } + + return; } -void UpdateDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) + +/*-------------------------------------------------------------------* + * Function UpdateDecodingUnresolved() + * + * + *-------------------------------------------------------------------*/ + +void UpdateDecodingUnresolved( + PredictionDecoder *psPredictionDecoder ) { int32_t n, ch; @@ -398,8 +441,11 @@ void UpdateDecodingUnresolved( PredictionDecoder *psPredictionDecoder ) } } } + + return; } + /*-------------------------------------------------------------------* * Function ApplyInversePredictors() * @@ -412,6 +458,7 @@ void ApplyInversePredictors( float ***pppfImag ) { int32_t c; + for ( c = 0; c < psPredictionDecoder->iChannels; c++ ) { if ( psPredictionDecoder->piPredChanEnable[c] > 0 ) diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c index 676aa917e6f780ee36a861ed2083da3fc1d5fb7e..3e00c8bedaf9c95979fc63178f471ad9eeb5f80f 100644 --- a/lib_isar/isar_PredEncoder.c +++ b/lib_isar/isar_PredEncoder.c @@ -46,13 +46,17 @@ * * *-------------------------------------------------------------------*/ + static void activate_bit( int32_t *state, const int32_t bit_id ) { ( *state ) |= ( 1 << bit_id ); + + return; } + /*-------------------------------------------------------------------* * Function deactivate_bit() * @@ -64,16 +68,29 @@ static void deactivate_bit( const int32_t bit_id ) { ( *state ) &= ( ~( 1 << bit_id ) ); + + return; } -void UpdatePredictionSubSetId( PredictionEncoder *psPredictionEncoder ) + +/*-------------------------------------------------------------------* + * Function UpdatePredictionSubSetId() + * + * + *-------------------------------------------------------------------*/ + +void UpdatePredictionSubSetId( + PredictionEncoder *psPredictionEncoder ) { if ( ++psPredictionEncoder->iSubSetId == psPredictionEncoder->iNumSubSets ) { psPredictionEncoder->iSubSetId = 0; } + + return; } + /*-------------------------------------------------------------------* * Function CreatePredictionEncoder() * @@ -496,6 +513,8 @@ void ComputePredictors( } } } + + return; } diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index d93f9ae39f7b0f2fac02a21309086c42eb6273d6..f98d0cc7ca389fb40d8613177dd65b0dfd8eaa93 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -63,25 +63,25 @@ typedef enum } ISAR_SPLIT_REND_POSE_TYPE; -#define CLDFB_PLC_XF 2 /* Length of cross-fade into first good frame after frame loss in CLDFB cols. */ - -#define SPLIT_REND_MAX_YAW_ONLY_POSES 2 -#define SPLIT_REND_MAX_PITCH_ONLY_POSES 2 -#define SPLIT_REND_MAX_ROLL_ONLY_POSES 2 -#define SPLIT_REND_MAX_ONE_AXIS_MD_POSES 2 -#define MAX_EXTRAPOLATION_ANGLE 15.0f /* this means additional 15 degrees can be extrapolated on top of MD probing poses*/ - -#define MAX_HEAD_ROT_POSES ( 2 + SPLIT_REND_MAX_YAW_ONLY_POSES + SPLIT_REND_MAX_PITCH_ONLY_POSES + SPLIT_REND_MAX_ROLL_ONLY_POSES ) -#define MAX_SPLIT_REND_MD_BANDS 20 -#define MAX_SPLIT_MD_SUBFRAMES 1 -#define COMPLEX_MD_BAND_THRESH MAX_SPLIT_REND_MD_BANDS +#define CLDFB_PLC_XF 2 /* Length of cross-fade into first good frame after frame loss in CLDFB cols. */ + +#define SPLIT_REND_MAX_YAW_ONLY_POSES 2 +#define SPLIT_REND_MAX_PITCH_ONLY_POSES 2 +#define SPLIT_REND_MAX_ROLL_ONLY_POSES 2 +#define SPLIT_REND_MAX_ONE_AXIS_MD_POSES 2 +#define MAX_EXTRAPOLATION_ANGLE 15.0f /* this means additional 15 degrees can be extrapolated on top of MD probing poses*/ + +#define MAX_HEAD_ROT_POSES ( 2 + SPLIT_REND_MAX_YAW_ONLY_POSES + SPLIT_REND_MAX_PITCH_ONLY_POSES + SPLIT_REND_MAX_ROLL_ONLY_POSES ) +#define MAX_SPLIT_REND_MD_BANDS 20 +#define MAX_SPLIT_MD_SUBFRAMES 1 +#define COMPLEX_MD_BAND_THRESH MAX_SPLIT_REND_MD_BANDS #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS -#define COMPLEX_MD_BAND_THRESH_LOW 4 -#define COMPLEX_MD_BAND_THRESH_HIGH 10 +#define COMPLEX_MD_BAND_THRESH_LOW 4 +#define COMPLEX_MD_BAND_THRESH_HIGH 10 #else -#define COMPLEX_MD_BAND_THRESH_LOW 5 +#define COMPLEX_MD_BAND_THRESH_LOW 5 #endif -#define SPLIT_REND_RO_MD_BAND_THRESH 4 +#define SPLIT_REND_RO_MD_BAND_THRESH 4 #define ISAR_SPLIT_REND_NUM_QUANT_STRATS 4 #define ISAR_SPLIT_REND_PRED_63QUANT_PNTS 63 @@ -91,11 +91,11 @@ typedef enum #define ISAR_SPLIT_REND_PRED_MIN_VAL -1.4f #define ISAR_SPLIT_REND_PRED_MAX_VAL 1.4f -#define ISAR_SPLIT_REND_PITCH_G_MIN_VAL 0.5f -#define ISAR_SPLIT_REND_PITCH_G_MAX_VAL 1.5f -#define ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS ISAR_SPLIT_REND_D_QUANT_PNTS -#define ISAR_SPLIT_REND_D_MIN_VAL 0.0f -#define ISAR_SPLIT_REND_D_MAX_VAL 1.0f +#define ISAR_SPLIT_REND_PITCH_G_MIN_VAL 0.5f +#define ISAR_SPLIT_REND_PITCH_G_MAX_VAL 1.5f +#define ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS ISAR_SPLIT_REND_D_QUANT_PNTS +#define ISAR_SPLIT_REND_D_MIN_VAL 0.0f +#define ISAR_SPLIT_REND_D_MAX_VAL 1.0f #define ISAR_SPLIT_REND_PRED_ROLL_Q_STEP ( ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) / ( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) ) #define ISAR_SPLIT_REND_PRED_ROLL_1BYQ_STEP ( ( ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) ) @@ -104,30 +104,30 @@ typedef enum #define ISAR_SPLIT_REND_PRED63_Q_STEP ( ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) / ( ISAR_SPLIT_REND_PRED_63QUANT_PNTS - 1 ) ) #define ISAR_SPLIT_REND_PRED63_1BYQ_STEP ( ( ISAR_SPLIT_REND_PRED_63QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PRED_MAX_VAL - ISAR_SPLIT_REND_PRED_MIN_VAL ) ) -#define ISAR_SPLIT_REND_D_Q_STEP ( ( ISAR_SPLIT_REND_D_MAX_VAL - ISAR_SPLIT_REND_D_MIN_VAL ) / ( ISAR_SPLIT_REND_D_QUANT_PNTS - 1 ) ) -#define ISAR_SPLIT_REND_D_1BYQ_STEP ( ( ISAR_SPLIT_REND_D_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_D_MAX_VAL - ISAR_SPLIT_REND_D_MIN_VAL ) ) -#define ISAR_SPLIT_REND_PITCH_G_Q_STEP ( ( ISAR_SPLIT_REND_PITCH_G_MAX_VAL - ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) / ( ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 ) ) -#define ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP ( ( ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PITCH_G_MAX_VAL - ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) ) +#define ISAR_SPLIT_REND_D_Q_STEP ( ( ISAR_SPLIT_REND_D_MAX_VAL - ISAR_SPLIT_REND_D_MIN_VAL ) / ( ISAR_SPLIT_REND_D_QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_D_1BYQ_STEP ( ( ISAR_SPLIT_REND_D_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_D_MAX_VAL - ISAR_SPLIT_REND_D_MIN_VAL ) ) +#define ISAR_SPLIT_REND_PITCH_G_Q_STEP ( ( ISAR_SPLIT_REND_PITCH_G_MAX_VAL - ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) / ( ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 ) ) +#define ISAR_SPLIT_REND_PITCH_G_1BYQ_STEP ( ( ISAR_SPLIT_REND_PITCH_G_QUANT_PNTS - 1 ) / ( ISAR_SPLIT_REND_PITCH_G_MAX_VAL - ISAR_SPLIT_REND_PITCH_G_MIN_VAL ) ) -#define ISAR_SPLIT_REND_HEAD_POSE_BITS 9 -#define ISAR_SPLIT_REND_DOF_BITS 2 -#define ISAR_SPLIT_REND_HQ_MODE_BITS 1 -#define ISAR_SPLIT_REND_ROT_AXIS_BITS 3 -#define ISAR_SPLIT_REND_RO_FLAG_BITS 1 +#define ISAR_SPLIT_REND_HEAD_POSE_BITS 9 +#define ISAR_SPLIT_REND_DOF_BITS 2 +#define ISAR_SPLIT_REND_HQ_MODE_BITS 1 +#define ISAR_SPLIT_REND_ROT_AXIS_BITS 3 +#define ISAR_SPLIT_REND_RO_FLAG_BITS 1 #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS -#define IVAS_LC3PLUS_MAX_NUM_DECODERS 2 +#define IVAS_LC3PLUS_MAX_NUM_DECODERS 2 #endif /*----------------------------------------------------------------------------------* * Split rendering bitrate constants *----------------------------------------------------------------------------------*/ -#define SPLIT_REND_256k 256000 -#define SPLIT_REND_320k 320000 -#define SPLIT_REND_384k 384000 -#define SPLIT_REND_512k 512000 -#define SPLIT_REND_768k 768000 +#define SPLIT_REND_256k 256000 +#define SPLIT_REND_320k 320000 +#define SPLIT_REND_384k 384000 +#define SPLIT_REND_512k 512000 +#define SPLIT_REND_768k 768000 /* == ISAR_MAX_SPLIT_REND_BITRATE */ #endif /*SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c index 7a9010335f2690c40b4931a374575113efcea973..d7a992274f597c118d0470ef0a51f660751b5eac 100644 --- a/lib_isar/isar_lc3plus_common.c +++ b/lib_isar/isar_lc3plus_common.c @@ -57,8 +57,17 @@ ivas_error ISAR_LC3PLUS_LC3plusErrToIvasErr( return IVAS_ERR_INTERNAL; } + + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS -ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtpError ) +/*-----------------------------------------------------------------------------------------* + * Function IVAS_LC3PLUS_LC3plusRtpErrToIvasErr() + * + * + *-----------------------------------------------------------------------------------------*/ + +ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( + const LC3PLUS_RTP_ERR lc3PlusRtpError ) { switch ( lc3PlusRtpError ) { diff --git a/lib_isar/isar_lc3plus_common.h b/lib_isar/isar_lc3plus_common.h index 13decaf944f66782242f51c8c09bed0b17da9806..a9ec8c8cbdf444c56ea161123aa3100c632534ce 100644 --- a/lib_isar/isar_lc3plus_common.h +++ b/lib_isar/isar_lc3plus_common.h @@ -48,13 +48,13 @@ typedef struct LC3PLUS_CONFIG { /*! frame duration in microseconds [10000, 5000, 2500] */ int16_t lc3plus_frame_duration_us; - /*! isar frame duration in microseconds [20000, 10000, 5000] */ + /*! ISAR frame duration in microseconds [20000, 10000, 5000] */ int16_t isar_frame_duration_us; /*! sampling rate*/ int32_t samplerate; /*! number of channels */ int16_t channels; -#if defined ISAR_BITSTREAM_UPDATE_LC3PLUS || defined ISAR_BITSTREAM_UPDATE_LC3PLUS +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /*! high resolution mode enabled (1) or disabled (0)*/ int16_t high_res_mode_enabled; #endif diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index 565f55e8cc5ee90cb679e1789b96684762001732..b32d8f6e2087ee1e10277ac85d3daa581f26c76f 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -63,7 +63,6 @@ static void isar_LC3PLUS_DEC_FreeSubframeDecodingMatrix( } #endif - /*------------------------------------------------------------------------- * ISAR_LC3PLUS_DEC_Open() * @@ -71,8 +70,8 @@ static void isar_LC3PLUS_DEC_FreeSubframeDecodingMatrix( *------------------------------------------------------------------------*/ ivas_error ISAR_LC3PLUS_DEC_Open( - const LC3PLUS_CONFIG config, /* i : LC3plus decoder configuration */ - ISAR_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ + const LC3PLUS_CONFIG config, /* i : LC3plus decoder configuration */ + ISAR_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ ) { LC3PLUS_Error err; @@ -101,7 +100,6 @@ ivas_error ISAR_LC3PLUS_DEC_Open( return IVAS_ERROR( IVAS_ERR_INIT_ERROR, "Maximum number of channels exceeds IVAS_LC3PLUS_MAX_NUM_DECODERS\n" ); } #else - if ( 0 == config.lc3plus_frame_duration_us ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid lc3plus_frame_duration_us (0)\n" ); @@ -109,7 +107,6 @@ ivas_error ISAR_LC3PLUS_DEC_Open( numLC3plusFramesPerIvasFrame = (int16_t) ( config.isar_frame_duration_us / config.lc3plus_frame_duration_us ); #endif - ( *handle )->num_decs = 0; ( *handle )->pcm_conversion_buffer = NULL; ( *handle )->handles = NULL; @@ -171,6 +168,7 @@ ivas_error ISAR_LC3PLUS_DEC_Open( #else err = lc3plus_dec_init( ( *handle )->handles[iCh], config.samplerate, 1, LC3PLUS_PLC_ADVANCED, 0 ); #endif + if ( LC3PLUS_OK != err ) { ISAR_LC3PLUS_DEC_Close( handle ); @@ -197,8 +195,8 @@ ivas_error ISAR_LC3PLUS_DEC_Open( ISAR_LC3PLUS_DEC_Close( handle ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); } -#endif +#endif ( *handle )->selective_decoding_states[iCh]->has_skipped_a_frame = 0; ( *handle )->selective_decoding_states[iCh]->shall_decode_cached_frame = 0; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS @@ -216,11 +214,13 @@ ivas_error ISAR_LC3PLUS_DEC_Open( ISAR_LC3PLUS_DEC_Close( handle ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity = 400 /*LC3plus max non-HR octet count*/; #else ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity = 400 /*LC3plus max non-HR octet count*/ * numLC3plusFramesPerIvasFrame; #endif + if ( ( ( *handle )->bitstream_caches[iCh]->bitstream_cache = malloc( ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity ) ) == NULL ) { ISAR_LC3PLUS_DEC_Close( handle ); @@ -393,8 +393,8 @@ ivas_error ISAR_LC3PLUS_DEC_SetSelectiveDecodingMatrix( return IVAS_ERR_OK; } -#endif +#endif /*------------------------------------------------------------------------- * ISAR_LC3PLUS_DEC_GetDelay() @@ -413,6 +413,7 @@ ivas_error ISAR_LC3PLUS_DEC_GetDelay( { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "ISAR_LC3PLUS_DEC_HANDLE is NULL\n" ); } + if ( NULL == delayInSamples ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "delayInSamples is NULL\n" ); @@ -773,8 +774,8 @@ static ivas_error isar_LC3PLUS_DEC_Decode_or_Conceal_internal( handle->selective_decoding_states[iDec]->frame_actions[iLc3plusFrame] = DEC_ACTION_DECODE_AND_USE; } } - #endif + return IVAS_ERR_OK; } diff --git a/lib_isar/isar_lc3plus_dec.h b/lib_isar/isar_lc3plus_dec.h index 91af70cef2ef3f192883d2c72c462cd3d29fe451..3c54a4d4b15a23d084a891dd40aeb378928e0e4d 100644 --- a/lib_isar/isar_lc3plus_dec.h +++ b/lib_isar/isar_lc3plus_dec.h @@ -90,7 +90,7 @@ typedef struct ISAR_LC3PLUS_DEC_HANDLE } * ISAR_LC3PLUS_DEC_HANDLE; ivas_error ISAR_LC3PLUS_DEC_Open( - const LC3PLUS_CONFIG config, /* i : decoder configuration */ + const LC3PLUS_CONFIG config, /* i : decoder configuration */ ISAR_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ ); @@ -128,7 +128,8 @@ ivas_error ISAR_LC3PLUS_DEC_AllocateSubframeDecodingMatrix( int16_t ***subframeChannelMatrix, const uint32_t num_decs ); -void ISAR_LC3PLUS_DEC_FreeSubframeDecodingMatrix( int16_t **subframeChannelMatrix ); +void ISAR_LC3PLUS_DEC_FreeSubframeDecodingMatrix( + int16_t **subframeChannelMatrix ); #endif #endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index da2c1d48f047b8ecbe725b6d2e53430598d07f74..215506dc6133530a6d1f007d05bfd76f7887b4ff 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -40,11 +40,10 @@ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS static const LC3PLUS_RTP_FDL s_fdl_request = LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA; -#endif -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS -static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, - int32_t per_channel_bitrate ) +static int32_t limit_per_channel_bitrate( + LC3PLUS_CONFIG config, + const int32_t per_channel_bitrate ) { if ( config.high_res_mode_enabled ) { @@ -79,6 +78,7 @@ static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, assert( false && "unreachable" ); return -1; } + #endif #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -118,6 +118,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( { return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid number of channels\n" ); } + #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS bitsPerSecondPerChannel = bitsPerSecond / config.channels; #endif @@ -131,6 +132,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid isar_frame_duration_us\n" ); } #endif + encoder_size = lc3plus_enc_get_size( config.samplerate, 1 ); if ( 0 == encoder_size ) { @@ -141,6 +143,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ( *handle )->config = config; ( *handle )->frame_type_descriptors = NULL; @@ -159,6 +162,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( ( *handle )->handles[i] = NULL; } ( *handle )->num_encs = config.channels; + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS num_lc3plus_media_times_per_ivas_frame = config.isar_frame_duration_us / config.lc3plus_frame_duration_us; ( *handle )->fdl_request = s_fdl_request; @@ -196,6 +200,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( ISAR_LC3PLUS_ENC_Close( handle ); return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_set_frame_dms failed\n" ); } + #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS err = lc3plus_enc_set_bitrate( ( *handle )->handles[iCh], bitsPerSecondPerChannel ); if ( err != LC3PLUS_OK ) @@ -229,6 +234,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( for ( uint32_t iEnc = 0; iEnc < ( *handle )->num_encs; ++iEnc ) { int32_t ftd_index = iEnc + iMediaTime * ( *handle )->num_encs; + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ( *handle )->frame_type_descriptors[ftd_index].frame_data_length = 0; /* will be set to the correct value in IVAS_LC3PLUS_ENC_SetBitrate */ #else @@ -240,6 +246,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( } ( *handle )->frame_type_descriptors[ftd_index].frame_data_length = lc3plus_num_bytes_per_frame; #endif + if ( 0 != LC3PLUS_RTP_ftd_bwr_from_samplerate( &( *handle )->frame_type_descriptors[ftd_index].bwr, config.samplerate, config.high_res_mode_enabled ) ) { ISAR_LC3PLUS_ENC_Close( handle ); @@ -285,6 +292,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( } #endif #endif + return IVAS_ERR_OK; } @@ -305,6 +313,7 @@ ivas_error IVAS_LC3PLUS_ENC_SetBitrate( int32_t availableOctetsPerIsarFrame; int32_t actualOctetsPerFrame; LC3PLUS_Error err; + ivas_error ivas_err; int32_t iFtd; int32_t fdrLength; int32_t lc3plusPacketRate; @@ -331,12 +340,12 @@ ivas_error IVAS_LC3PLUS_ENC_SetBitrate( } minPayloadOverhead = fdrLength + ( numSubframes * LC3PLUS_RTP_FTD_MIN_SIZE ); targetLc3PlusBitratePerChannel = ( availableOctetsPerIsarFrame - minPayloadOverhead ) / handle->config.channels * 8 * lc3plusPacketRate / numLc3plusMediaTimesPerIvasFrame; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( targetLc3PlusBitratePerChannel <= 0 ) { return IVAS_ERROR( IVAS_ERR_LC3PLUS_INVALID_BITRATE, "available LC3plus bitrate <= 0\n" ); } -#endif + targetLc3PlusBitratePerChannel = limit_per_channel_bitrate( handle->config, targetLc3PlusBitratePerChannel ); targetLc3PlusOctetCount = targetLc3PlusBitratePerChannel / 8 / lc3plusPacketRate; /* check resulting octet count. If it requires larger than 1-byte length fields, decrease the bitrate by enough to make room for the additional length field */ @@ -359,7 +368,7 @@ ivas_error IVAS_LC3PLUS_ENC_SetBitrate( } } - // update FTD settings after bitrate change + /* update FTD settings after bitrate change */ for ( int32_t iMediaTime = 0; iMediaTime < numLc3plusMediaTimesPerIvasFrame; ++iMediaTime ) { for ( uint32_t iEnc = 0; iEnc < handle->num_encs; ++iEnc ) @@ -374,15 +383,16 @@ ivas_error IVAS_LC3PLUS_ENC_SetBitrate( } } - // TODO: remove sanity checks? - if ( ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( handle, &actualOctetsPerFrame ) != IVAS_ERR_OK ) + if ( ( ivas_err = ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( handle, &actualOctetsPerFrame ) ) != IVAS_ERR_OK ) { - return IVAS_ERROR( IVAS_ERR_INTERNAL, "ISAR_LC3PLUS_ENC_GetOutputBitstreamSize failed\n" ); + return ivas_err; } + if ( actualOctetsPerFrame > availableOctetsPerIsarFrame ) { return IVAS_ERROR( IVAS_ERR_INTERNAL, "Bitrate reduction logic failed\n" ); } + return IVAS_ERR_OK; } #endif @@ -451,6 +461,7 @@ ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( #else int32_t bitstreamSizeMultiplier; #endif + if ( NULL == handle ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Enc_Wrap_Handle is NULL\n" ); @@ -472,6 +483,7 @@ ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( num_lc3plus_media_times_per_ivas_frame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; #endif + *bsSize = 0; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int32_t fdl_request_length; @@ -482,14 +494,17 @@ ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( } *bsSize += fdl_request_length; #endif + for ( uint32_t iEnc = 0; iEnc < handle->num_encs; iEnc++ ) { if ( NULL == handle->handles[iEnc] ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3plus encoder handle is NULL\n" ); } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS lc3plus_frame_data_length = lc3plus_enc_get_num_bytes( handle->handles[iEnc] ); + for ( iMediaTime = 0; iMediaTime < num_lc3plus_media_times_per_ivas_frame; ++iMediaTime ) { ftd_index = iEnc + iMediaTime * handle->num_encs; @@ -538,12 +553,14 @@ void ISAR_LC3PLUS_ENC_Close( { return; } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( NULL != ( *handle )->frame_type_descriptors ) { free( ( *handle )->frame_type_descriptors ); } #endif + for ( uint32_t iEnc = 0; iEnc < ( *handle )->num_encs; iEnc++ ) { if ( NULL != ( *handle )->handles[iEnc] ) @@ -552,6 +569,7 @@ void ISAR_LC3PLUS_ENC_Close( free( ( *handle )->handles[iEnc] ); } } + if ( NULL != ( *handle )->pcm_conversion_buffer ) { free( ( *handle )->pcm_conversion_buffer ); @@ -615,6 +633,7 @@ ivas_error ISAR_LC3PLUS_ENC_Encode( { return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS num_media_times = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; numSamplesPerLC3plusChannel = handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / num_media_times; @@ -659,14 +678,17 @@ ivas_error ISAR_LC3PLUS_ENC_Encode( err = lc3plus_enc16( handle->handles[iEnc], &handle->pcm_conversion_buffer, bitstream_out_iter, &num_bytes, NULL ); #endif pop_wmops(); + if ( err != LC3PLUS_OK ) { return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc16 failed\n" ); } + if ( 0 == num_bytes ) { return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_enc16 did not produce output\n" ); } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( num_bytes != (int32_t) handle->frame_type_descriptors[ftdIndex].frame_data_length ) { diff --git a/lib_isar/isar_lc3plus_payload.c b/lib_isar/isar_lc3plus_payload.c index b240897655ab4da7c58f7ffbc602c9adb0eefff5..d16ce18b88ee601fb0466ff65600644db96f4e07 100644 --- a/lib_isar/isar_lc3plus_payload.c +++ b/lib_isar/isar_lc3plus_payload.c @@ -36,9 +36,16 @@ #include "isar_lc3plus_payload.h" #include "options.h" + #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS -static LC3PLUS_RTP_ERR s_frame_duration_ms_from_fdi( int32_t *frame_duration_us, const LC3PLUS_RTP_FTD_FDI fdi ) +/*------------------------------------------------------------------------- + * Local functions + *------------------------------------------------------------------------*/ + +static LC3PLUS_RTP_ERR s_frame_duration_ms_from_fdi( + int32_t *frame_duration_us, + const LC3PLUS_RTP_FTD_FDI fdi ) { if ( NULL == frame_duration_us ) { @@ -59,10 +66,14 @@ static LC3PLUS_RTP_ERR s_frame_duration_ms_from_fdi( int32_t *frame_duration_us, default: return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -static LC3PLUS_RTP_ERR s_sampling_rate_hz_from_bwr( int32_t *sample_rate_hz, const LC3PLUS_RTP_FTD_BWR bwr ) + +static LC3PLUS_RTP_ERR s_sampling_rate_hz_from_bwr( + int32_t *sample_rate_hz, + const LC3PLUS_RTP_FTD_BWR bwr ) { if ( NULL == sample_rate_hz ) { @@ -97,10 +108,14 @@ static LC3PLUS_RTP_ERR s_sampling_rate_hz_from_bwr( int32_t *sample_rate_hz, con default: return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -static LC3PLUS_RTP_ERR s_high_resolution_flag_from_bwr( int16_t *high_resolution_flag, const LC3PLUS_RTP_FTD_BWR bwr ) + +static LC3PLUS_RTP_ERR s_high_resolution_flag_from_bwr( + int16_t *high_resolution_flag, + const LC3PLUS_RTP_FTD_BWR bwr ) { if ( NULL == high_resolution_flag ) { @@ -135,10 +150,20 @@ static LC3PLUS_RTP_ERR s_high_resolution_flag_from_bwr( int16_t *high_resolution default: return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -LC3PLUS_RTP_ERR LC3PLUS_RTP_frame_data_length_get_size( int32_t *length, const LC3PLUS_RTP_FDL frameDataLengthValue ) + +/*------------------------------------------------------------------------- + * LC3PLUS_RTP_frame_data_length_get_size() + * + * + *------------------------------------------------------------------------*/ + +LC3PLUS_RTP_ERR LC3PLUS_RTP_frame_data_length_get_size( + int32_t *length, + const LC3PLUS_RTP_FDL frameDataLengthValue ) { if ( frameDataLengthValue == LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA || frameDataLengthValue == LC3PLUS_RTP_FDL_SPEECH_BAD || frameDataLengthValue == LC3PLUS_RTP_FDL_SPEECH_SID ) { @@ -160,10 +185,14 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_frame_data_length_get_size( int32_t *length, const L { return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -static LC3PLUS_RTP_ERR s_frame_data_length_pack( const LC3PLUS_RTP_FDL frameDataLengthValue, uint8_t *dst ) + +static LC3PLUS_RTP_ERR s_frame_data_length_pack( + const LC3PLUS_RTP_FDL frameDataLengthValue, + uint8_t *dst ) { int32_t frame_data_length_size; LC3PLUS_RTP_ERR err; @@ -195,41 +224,56 @@ static LC3PLUS_RTP_ERR s_frame_data_length_pack( const LC3PLUS_RTP_FDL frameData *dst++ = LC3PLUS_RTP_FDL_EXTENSION_VALUE; *dst = frameDataLengthValueToWrite >> 0 & LC3PLUS_RTP_FDL_EXTENSION_VALUE; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -static int32_t s_get_size_from_fdl( const LC3PLUS_RTP_FDL fdl ) + +static int32_t s_get_size_from_fdl( + const LC3PLUS_RTP_FDL fdl ) { if ( fdl >= LC3PLUS_RTP_FDL_LENGTH_1_MIN && fdl <= LC3PLUS_RTP_FDL_LENGTH_3_MAX ) { return fdl; } + return 0; } -static bool s_fdl_is_magic_value( const LC3PLUS_RTP_FDL fdl ) + +static bool s_fdl_is_magic_value( + const LC3PLUS_RTP_FDL fdl ) { if ( fdl == LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA || fdl == LC3PLUS_RTP_FDL_SPEECH_SID || fdl == LC3PLUS_RTP_FDL_SPEECH_BAD ) { return true; } + return false; } -static bool s_fdl_value_is_valid_request( const LC3PLUS_RTP_FDL fdl_request ) + +static bool s_fdl_value_is_valid_request( + const LC3PLUS_RTP_FDL fdl_request ) { /* LC3PLUS_RTP_FDL_SPEECH_SID && LC3PLUS_RTP_FDL_SPEECH_SID are not valid values for the FDL request */ if ( fdl_request == LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA || ( fdl_request >= LC3PLUS_RTP_FDL_LENGTH_1_MIN && fdl_request <= LC3PLUS_RTP_FDL_LENGTH_3_MAX ) ) { return true; } + return false; } -static LC3PLUS_RTP_ERR s_frame_data_length_parse( LC3PLUS_RTP_FDL *frame_data_length_value, const uint8_t *src, const size_t remaining_capacity ) + +static LC3PLUS_RTP_ERR s_frame_data_length_parse( + LC3PLUS_RTP_FDL *frame_data_length_value, + const uint8_t *src, + const size_t remaining_capacity ) { int32_t frame_data_length_size; LC3PLUS_RTP_ERR err; + if ( NULL == src || NULL == frame_data_length_value || remaining_capacity < 1 ) { return LC3PLUS_RTP_ERR_NULL_PTR; @@ -258,14 +302,21 @@ static LC3PLUS_RTP_ERR s_frame_data_length_parse( LC3PLUS_RTP_FDL *frame_data_le { return err; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -static LC3PLUS_RTP_ERR s_parse_ftd( const uint8_t *p_read, LC3PLUS_RTP_FTD *receiver_ftd, int32_t *num_bytes_read, const size_t remaining_capacity ) + +static LC3PLUS_RTP_ERR s_parse_ftd( + const uint8_t *p_read, + LC3PLUS_RTP_FTD *receiver_ftd, + int32_t *num_bytes_read, + const size_t remaining_capacity ) { int32_t frame_data_block_size; LC3PLUS_RTP_FDL fdl; LC3PLUS_RTP_ERR err; + if ( NULL == p_read || NULL == receiver_ftd || NULL == num_bytes_read || remaining_capacity < LC3PLUS_RTP_FTD_MIN_SIZE ) { return LC3PLUS_RTP_ERR_NULL_PTR; @@ -298,9 +349,17 @@ static LC3PLUS_RTP_ERR s_parse_ftd( const uint8_t *p_read, LC3PLUS_RTP_FTD *rece return err; } *num_bytes_read += length_field_size; + return LC3PLUS_RTP_ERR_NO_ERROR; } + +/*------------------------------------------------------------------------- + * LC3PLUS_RTP_payload_serialize() + * + * + *------------------------------------------------------------------------*/ + LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_serialize( uint8_t *serialized_buffer, const size_t serialized_buffer_capacity, @@ -397,9 +456,11 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_serialize( } *packed_buffer_actual_size = bytes_written + lc3plus_frame_size_sum; assert( *packed_buffer_actual_size <= serialized_buffer_capacity ); + return LC3PLUS_RTP_ERR_NO_ERROR; } + static LC3PLUS_RTP_ERR s_ftds_parse( LC3PLUS_RTP_FTD *receiver_ftds, const int32_t receiver_ftds_num_max, @@ -428,6 +489,7 @@ static LC3PLUS_RTP_ERR s_ftds_parse( { return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } + { int32_t num_bytes_read_sum = 0; const int32_t min_num_bytes_per_ftd = 2; @@ -521,9 +583,17 @@ static LC3PLUS_RTP_ERR s_ftds_parse( p_read++; } } + return LC3PLUS_RTP_ERR_NO_ERROR; } + +/*------------------------------------------------------------------------- + * LC3PLUS_RTP_payload_deserialize() + * + * + *------------------------------------------------------------------------*/ + LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_deserialize( LC3PLUS_RTP_PAYLOAD *payload, uint8_t *serialized_buffer, @@ -724,10 +794,21 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_deserialize( { return LC3PLUS_RTP_ERR_GENERIC_ERROR; } + return LC3PLUS_RTP_ERR_NO_ERROR; } -LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_bwr_from_samplerate( LC3PLUS_RTP_FTD_BWR *bwr, const int32_t sampling_rate, const int32_t high_res_enabled ) + +/*------------------------------------------------------------------------- + * LC3PLUS_RTP_ftd_bwr_from_samplerate() + * + * + *------------------------------------------------------------------------*/ + +LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_bwr_from_samplerate( + LC3PLUS_RTP_FTD_BWR *bwr, + const int32_t sampling_rate, + const int32_t high_res_enabled ) { if ( NULL == bwr ) { @@ -795,7 +876,16 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_bwr_from_samplerate( LC3PLUS_RTP_FTD_BWR *bwr, c return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } -LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( LC3PLUS_RTP_FTD_FDI *fdi, const int32_t frame_duration_us ) + +/*------------------------------------------------------------------------- + * LC3PLUS_RTP_ftd_fdi_from_frame_duration_us() + * + * + *------------------------------------------------------------------------*/ + +LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( + LC3PLUS_RTP_FTD_FDI *fdi, + const int32_t frame_duration_us ) { if ( NULL == fdi ) { diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index f8d13cf7ff403644485db762d8a734af5e4e9279..41b00806d75738d6afaff2b4e03fc86b28cc4347 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -60,6 +60,7 @@ typedef struct TableNode int32_t *piDifference; int32_t *piLength; } TableNode; + typedef struct TableList { TableNode *poOrderedTop; @@ -102,26 +103,41 @@ struct LCLD_DECODER PredictionDecoder *psPredictionDecoder; - NoiseGen *psNoiseGen; }; + +/*------------------------------------------------------------------------------------------* + * Local functions declarations + *------------------------------------------------------------------------------------------*/ + static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, const int32_t num, const uint16_t ( *ppuiEncTable )[2], const int32_t iSize, const int32_t iReadLength, uint32_t *iTables ); + static TableNode *CreateTableList( const int32_t iReadLength ); + static void DeleteTableList( TableList *ptable_list, int32_t iTables ); + static TableNode *GetNextTable( const int32_t iIndex, TableList *table_list, TableNode *poParent, const int32_t iReadLength, uint32_t *iTablesCreated ); + static void AddcodeTableList( TableList *ptable_list, const int32_t iLength, const int32_t iCode, const int32_t iCodeIndex, const int32_t iReadLength, uint32_t *iTables ); + static void CompleteTables( LCLDDecoder *psLCLDDecoder, const int32_t n, TableList *ptable_list, const int32_t iReadLength, const int32_t iTablesCreated ); -static TableNode *CreateTableList( const int32_t iReadLength ) + +/*------------------------------------------------------------------------------------------* + * Local functions + *------------------------------------------------------------------------------------------*/ + +static TableNode *CreateTableList( + const int32_t iReadLength ) { int32_t n; int32_t iMaxTables; TableNode *ptable_top; + iMaxTables = 1 << iReadLength; ptable_top = (TableNode *) malloc( sizeof( TableNode ) ); - ptable_top->ppoNextTable = - (TableNode **) malloc( iMaxTables * sizeof( TableNode * ) ); + ptable_top->ppoNextTable = (TableNode **) malloc( iMaxTables * sizeof( TableNode * ) ); ptable_top->piCodeIndex = (int32_t *) malloc( iMaxTables * sizeof( int32_t ) ); ptable_top->piDifference = (int32_t *) malloc( iMaxTables * sizeof( int32_t ) ); ptable_top->piLength = (int32_t *) malloc( iMaxTables * sizeof( int32_t ) ); @@ -135,15 +151,18 @@ static TableNode *CreateTableList( const int32_t iReadLength ) return ptable_top; } -static void DeleteTableList( TableList *ptable_list, int32_t iTables ) + + +static void DeleteTableList( + TableList *ptable_list, + int32_t iTables ) { TableNode *node; node = ptable_list->poOrderedTop; - while ( ( iTables ) ) + while ( iTables ) { - TableNode *node1 = node; node = node1->poOrderedNext; if ( node1->piCodeIndex != NULL ) @@ -168,12 +187,22 @@ static void DeleteTableList( TableList *ptable_list, int32_t iTables ) } iTables--; } + if ( ptable_list != NULL ) { free( ptable_list ); } + + return; } -static TableNode *GetNextTable( const int32_t iIndex, TableList *table_list, TableNode *poParent, const int32_t iReadLength, uint32_t *iTablesCreated ) + + +static TableNode *GetNextTable( + const int32_t iIndex, + TableList *table_list, + TableNode *poParent, + const int32_t iReadLength, + uint32_t *iTablesCreated ) { TableNode *poNextNode; @@ -194,16 +223,21 @@ static TableNode *GetNextTable( const int32_t iIndex, TableList *table_list, Tab return poNextNode; } -static void CompleteTables( LCLDDecoder *psLCLDDecoder, const int32_t n, TableList *ptable_list, const int32_t iReadLength, const int32_t iTablesCreated ) -{ + +static void CompleteTables( + LCLDDecoder *psLCLDDecoder, + const int32_t n, + TableList *ptable_list, + const int32_t iReadLength, + const int32_t iTablesCreated ) +{ int32_t iMaxTables; int32_t j; TableNode *poNode; iMaxTables = 1 << iReadLength; - psLCLDDecoder->c_apauiHuffDecTable_RAM[n] = - malloc( iTablesCreated * iMaxTables * sizeof( uint32_t ) ); + psLCLDDecoder->c_apauiHuffDecTable_RAM[n] = malloc( iTablesCreated * iMaxTables * sizeof( uint32_t ) ); poNode = ptable_list->poOrderedTop; for ( j = 0; j < iTablesCreated; j++ ) @@ -222,8 +256,18 @@ static void CompleteTables( LCLDDecoder *psLCLDDecoder, const int32_t n, TableLi } poNode = poNode->poOrderedNext; } + + return; } -static void AddcodeTableList( TableList *ptable_list, const int32_t iLength, const int32_t iCode, const int32_t iCodeIndex, const int32_t iReadLength, uint32_t *iTables ) + + +static void AddcodeTableList( + TableList *ptable_list, + const int32_t iLength, + const int32_t iCode, + const int32_t iCodeIndex, + const int32_t iReadLength, + uint32_t *iTables ) { int32_t iDifference; int32_t iMask; @@ -231,8 +275,8 @@ static void AddcodeTableList( TableList *ptable_list, const int32_t iLength, con int32_t iIndex; int32_t iCodeLow; int32_t iCodeHigh; - TableNode *poNode; + poNode = ptable_list->poOrderedTop; iMask = ( 1 << iReadLength ) - 1; iCurrentLength = iLength; @@ -256,19 +300,29 @@ static void AddcodeTableList( TableList *ptable_list, const int32_t iLength, con poNode->piDifference[iIndex] = iDifference; poNode->piLength[iIndex] = iLength; } + + return; } -static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, const int32_t num, const uint16_t ( *ppuiEncTable )[2], const int32_t iSize, const int32_t iReadLength, uint32_t *iTables ) + +static void CreateDecodeTable( + LCLDDecoder *psLCLDDecoder, + const int32_t num, + const uint16_t ( *ppuiEncTable )[2], + const int32_t iSize, + const int32_t iReadLength, + uint32_t *iTables ) { int32_t n; uint32_t **ppsort_enc_table; TableList *ptable_list; + ptable_list = (TableList *) malloc( sizeof( TableList ) ); ppsort_enc_table = (uint32_t **) malloc( iSize * sizeof( int32_t * ) ); + for ( n = 0; n < iSize; n++ ) { - ppsort_enc_table[n] = (uint32_t *) malloc( 3 * sizeof( int32_t ) ); ppsort_enc_table[n][0] = (uint32_t) ppuiEncTable[n][0]; ppsort_enc_table[n][1] = (uint32_t) ppuiEncTable[n][1]; @@ -322,8 +376,7 @@ static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, const int32_t num, co iLength = ppsort_enc_table[n][0]; iCode = ppsort_enc_table[n][1]; iCodeIndex = ppsort_enc_table[n][2]; - AddcodeTableList( ptable_list, iLength, iCode, iCodeIndex, iReadLength, - iTables ); + AddcodeTableList( ptable_list, iLength, iCode, iCodeIndex, iReadLength, iTables ); } CompleteTables( psLCLDDecoder, num, ptable_list, iReadLength, *iTables ); @@ -332,7 +385,10 @@ static void CreateDecodeTable( LCLDDecoder *psLCLDDecoder, const int32_t num, co { free( ppsort_enc_table[n] ); } + free( ppsort_enc_table ); + + return; } @@ -540,7 +596,8 @@ ivas_error CreateLCLDDecoder( * *------------------------------------------------------------------------------------------*/ -void DeleteLCLDDecoder( LCLDDecoder *psLCLDDecoder ) +void DeleteLCLDDecoder( + LCLDDecoder *psLCLDDecoder ) { int32_t k, n; @@ -695,8 +752,11 @@ void DeleteLCLDDecoder( LCLDDecoder *psLCLDDecoder ) free( psLCLDDecoder ); } + + return; } + /*------------------------------------------------------------------------------------------* * Local function declarations * @@ -722,14 +782,24 @@ static int32_t ReadHuff( const uint32_t ( *pauiHuffDecTable )[HUFF_DEC_TABLE_SIZ static int32_t ReadRMSEnvelope( const int32_t iChannels, const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiRMSEnvelope, ISAR_SPLIT_REND_BITS_HANDLE pBits ); static int32_t ReadAllocInformation( int32_t *piAllocOffset, ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t -ReadLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, const int32_t iNumBands, const int32_t iNumChannels, int32_t **ppiDecodingUnresolved, int32_t **ppiPredEnable, const int32_t iNumSubSets, const int32_t iSubSetId, int32_t ***pppiAlloc, int32_t ***pppiSignReal, int32_t ***pppiSignImag, int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t **ppiDecodingFailed, ISAR_SPLIT_REND_BITS_HANDLE pBits, uint32_t ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ); + +static int32_t ReadLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, const int32_t iNumBands, const int32_t iNumChannels, int32_t **ppiDecodingUnresolved, int32_t **ppiPredEnable, const int32_t iNumSubSets, const int32_t iSubSetId, int32_t ***pppiAlloc, int32_t ***pppiSignReal, int32_t ***pppiSignImag, int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t **ppiDecodingFailed, ISAR_SPLIT_REND_BITS_HANDLE pBits, uint32_t ( *c_apauiHuffDecTables[2 * ALLOC_TABLE_SIZE] )[HUFF_DEC_TABLE_SIZE] ); + static void ComputeAllocation( const int32_t iChannels, const int32_t *piNumGroups, const int32_t iNumBands, int32_t ***pppiSMR, const int32_t iAllocOffset, int32_t ***pppiAlloc ); -void SetDecodingUnresolved( LCLDDecoder *psLCLDDecoder ) + +/*------------------------------------------------------------------------------------------* + * function LSetDecodingUnresolved() + * + * + *------------------------------------------------------------------------------------------*/ + +void SetDecodingUnresolved( + LCLDDecoder *psLCLDDecoder ) { int32_t n, ch; PredictionDecoder *psPredictionDecoder = psLCLDDecoder->psPredictionDecoder; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) { for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) @@ -739,12 +809,23 @@ void SetDecodingUnresolved( LCLDDecoder *psLCLDDecoder ) psPredictionDecoder->ppiDecodingFailedPrev[ch][n] = 1; } } + + return; } -int32_t AnyDecodingFailedPrev( LCLDDecoder *psLCLDDecoder ) + +/*------------------------------------------------------------------------------------------* + * function AnyDecodingFailedPrev() + * + * + *------------------------------------------------------------------------------------------*/ + +int16_t AnyDecodingFailedPrev( + LCLDDecoder *psLCLDDecoder ) { int32_t n, ch; PredictionDecoder *psPredictionDecoder = psLCLDDecoder->psPredictionDecoder; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) { for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) @@ -755,13 +836,22 @@ int32_t AnyDecodingFailedPrev( LCLDDecoder *psLCLDDecoder ) } } } + return 0; } -int32_t AnyDecodingFailed( LCLDDecoder *psLCLDDecoder ) +/*------------------------------------------------------------------------------------------* + * function AnyDecodingFailed() + * + * + *------------------------------------------------------------------------------------------*/ + +int16_t AnyDecodingFailed( + LCLDDecoder *psLCLDDecoder ) { int32_t n, ch; PredictionDecoder *psPredictionDecoder = psLCLDDecoder->psPredictionDecoder; + for ( ch = 0; ch < psPredictionDecoder->iChannels; ch++ ) { for ( n = 0; n < psPredictionDecoder->iNumSubSets; n++ ) @@ -772,24 +862,56 @@ int32_t AnyDecodingFailed( LCLDDecoder *psLCLDDecoder ) } } } + return 0; } -int32_t **GetDecodingFailedStatus( LCLDDecoder *psLCLDDecoder ) + +/*------------------------------------------------------------------------------------------* + * function GetDecodingFailedStatus() + * + * + *------------------------------------------------------------------------------------------*/ + +int32_t **GetDecodingFailedStatus( + LCLDDecoder *psLCLDDecoder ) { return psLCLDDecoder->psPredictionDecoder->ppiDecodingFailed; } -int16_t GetNumSubSets( LCLDDecoder *psLCLDDecoder ) + +/*------------------------------------------------------------------------------------------* + * function GetNumSubSets() + * + * + *------------------------------------------------------------------------------------------*/ + +int16_t GetNumSubSets( + LCLDDecoder *psLCLDDecoder ) { return (int16_t) psLCLDDecoder->psPredictionDecoder->iNumSubSets; } -int32_t **GetDecodingFailedPrevStatus( LCLDDecoder *psLCLDDecoder ) + +/*------------------------------------------------------------------------------------------* + * function GetDecodingFailedPrevStatus() + * + * + *------------------------------------------------------------------------------------------*/ + +int32_t **GetDecodingFailedPrevStatus( + LCLDDecoder *psLCLDDecoder ) { return psLCLDDecoder->psPredictionDecoder->ppiDecodingFailedPrev; } + +/*------------------------------------------------------------------------------------------* + * function UnpackReal() + * + * + *------------------------------------------------------------------------------------------*/ + static void UnpackReal( const int32_t iChannels, const int32_t iNumBlocks, @@ -797,6 +919,7 @@ static void UnpackReal( float ***pppfImag ) { int32_t ch, b, n; + for ( ch = 0; ch < iChannels; ch++ ) { for ( b = 0; b < LCLD_BANDS; b++ ) @@ -812,8 +935,11 @@ static void UnpackReal( } } } + + return; } + /*------------------------------------------------------------------------------------------* * Function DecodeLCLDFrame() * @@ -822,7 +948,7 @@ static void UnpackReal( int32_t DecodeLCLDFrame( LCLDDecoder *psLCLDDecoder, - ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ float ***pppfLCLDReal, float ***pppfLCLDImag ) { @@ -843,7 +969,6 @@ int32_t DecodeLCLDFrame( ReadRMSEnvelope( psLCLDDecoder->iChannels, (const int32_t *) psLCLDDecoder->piNumGroups, psLCLDDecoder->iNumBands, psLCLDDecoder->pppiRMSEnvelope, pBits ); - ReadAllocInformation( &psLCLDDecoder->iAllocOffset, pBits ); if ( psLCLDDecoder->iChannels == 2 && psLCLDDecoder->iCommonGrouping == 1 ) @@ -1001,6 +1126,7 @@ static void ApplyRMSEnvelope( return; } + static void ReplaceSign( const int32_t iNumBlocks, const int32_t iNumLCLDBands, @@ -1133,6 +1259,7 @@ static void InvMSCoding( int32_t n; int32_t phaseIdx; float fPred; + phaseIdx = piLRPhaseDiffs[bMSPred] - PHASE_MIN_VAL; fPred = dequantPred( piMSPredCoefs[bMSPred] ); for ( n = 0; n < piBandwidths[b]; n++ ) @@ -1181,7 +1308,6 @@ static void InvMSCoding( } -/* Currently only the number of bands in frame */ static int32_t ReadHeaderInformation( int32_t *piNumBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ) @@ -1263,7 +1389,9 @@ static int32_t ReadMSInformation( } } } + anyNonZero = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + if ( anyNonZero ) { piLRPhaseDiffs[0] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PHASE_BAND0_BITS ); @@ -1284,7 +1412,9 @@ static int32_t ReadMSInformation( piLRPhaseDiffs[n] = 0; } } + anyNonZero = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); + if ( anyNonZero ) { piMSPredCoefs[0] = ISAR_SPLIT_REND_BITStream_read_int32( pBits, PRED_BAND0_BITS ); @@ -1322,6 +1452,7 @@ static int32_t ReadMSInformation( return iBitsRead; } + static int32_t ReadGroupInformation( const int32_t iChannels, const int32_t iNumBlocks, @@ -1524,6 +1655,7 @@ static int32_t ReadAllocInformation( return iBitsRead; } + static int32_t ReadLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, @@ -1682,6 +1814,7 @@ static int32_t ReadLCLDData( return iBitsRead; } + static void ComputeAllocation( const int32_t iChannels, const int32_t *piNumGroups, diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 3d110a5a3043d467e640c0cb44396ba064f5849f..a24e11b69191116e0759e661d373a9ad6c0966f1 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -80,10 +80,10 @@ struct LCLD_ENCODER int32_t ***pppiQLCLDReal; int32_t ***pppiQLCLDImag; - PredictionEncoder *psPredictionEncoder; }; + /*------------------------------------------------------------------------------------------* * Function Quantize() * @@ -97,6 +97,7 @@ static int32_t Quantize( const int32_t iMaxVal ) { int32_t iVal; + if ( fVal > 0.0f ) { iVal = (int32_t) ( fScale * fVal + 0.5f ); @@ -112,6 +113,7 @@ static int32_t Quantize( return iVal; } + /*------------------------------------------------------------------------------------------* * Function UnQuantize() * @@ -124,6 +126,7 @@ static float UnQuantize( const int32_t iSign ) { float fVal; + if ( iSign == 0 ) { fVal = fScale * (float) iVal; @@ -132,9 +135,11 @@ static float UnQuantize( { fVal = -fScale * (float) iVal; } + return fVal; } + static void PackReal( const int32_t iChannels, const int32_t iNumBlocks, @@ -142,6 +147,7 @@ static void PackReal( float ***pppfImag ) { int32_t ch, b, n; + for ( ch = 0; ch < iChannels; ch++ ) { for ( b = 0; b < LCLD_BANDS; b++ ) @@ -155,6 +161,8 @@ static void PackReal( } } } + + return; } /*------------------------------------------------------------------------------------------* @@ -208,6 +216,7 @@ ivas_error CreateLCLDEncoder( psLCLDEncoder->iNumBlocks = iNumBlocks; } psLCLDEncoder->iMSMode = 0; + if ( ( psLCLDEncoder->piMSFlags = (int32_t *) malloc( MAX_BANDS * sizeof( int32_t ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); @@ -252,7 +261,6 @@ ivas_error CreateLCLDEncoder( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); } - if ( ( psLCLDEncoder->pppiLCLDSignReal = (int32_t ***) malloc( psLCLDEncoder->iChannels * sizeof( int32_t ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); @@ -273,7 +281,6 @@ ivas_error CreateLCLDEncoder( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LCLD encoder Module \n" ) ); } - for ( n = 0; n < iChannels; n++ ) { int32_t k; @@ -416,6 +423,7 @@ void DeleteLCLDEncoder( } free( psLCLDEncoder->ppiGroupLengths ); } + if ( psLCLDEncoder->pppiRMSEnvelope != NULL ) { for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) @@ -527,6 +535,7 @@ void DeleteLCLDEncoder( return; } + /*------------------------------------------------------------------------------------------* * Local function declarations *------------------------------------------------------------------------------------------*/ @@ -539,7 +548,7 @@ static int32_t CountLCLDBits( const int32_t iNumGroups, const int32_t *piGroupLe static int32_t WriteHeaderInformation( const int32_t iNumBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); -static int32_t WriteMSInformation( const int32_t iNumBands, const int32_t iMSMode, const int32_t *piMSFlags, const int32_t *piLRPhaseDiffs, const int32_t *piMSPredCoefs, int32_t iNumMSPredBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); +static int32_t WriteMSInformation( const int32_t iNumBands, const int32_t iMSMode, const int32_t *piMSFlags, const int32_t *piLRPhaseDiffs, const int32_t *piMSPredCoefs, const int32_t iNumMSPredBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ); static int32_t WriteGroupInformation( const int32_t iChannels, const int32_t iCommonGrouping, const int32_t *piNumGroups, int32_t **ppiGroupLengths, ISAR_SPLIT_REND_BITS_HANDLE pBits ); @@ -551,6 +560,7 @@ static int32_t WriteLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLeng static int32_t ComputeAllocation( const int32_t iChannels, const int32_t *piNumGroups, int32_t **ppiGroupLengths, const int32_t iNumBands, const int32_t *piBandwidths, float ***pppfReal, float ***pppfImag, int32_t ***pppiSMR, const int32_t iAvailableBits, int32_t *piAllocOffset, int32_t ***pppiAlloc, int32_t ***pppiQReal, int32_t ***pppiQImag, int32_t ***pppiSignReal, int32_t ***pppiSignImag, PredictionEncoder *psPredictionEncoder ); + /*------------------------------------------------------------------------------------------* * Function EncodeLCLDFrame() * @@ -565,7 +575,7 @@ int32_t EncodeLCLDFrame( const int32_t available_bits, ISAR_SPLIT_REND_BITS_HANDLE pBits ) { - int32_t n; + int32_t k, n; int32_t iAvailableBits, iBitsWritten; int32_t iNumMSBands = 0; int32_t iAudioBitsWritten; @@ -600,7 +610,6 @@ int32_t EncodeLCLDFrame( } } - /* Compute Grouping and RMS Envelopes */ if ( psLCLDEncoder->iChannels == 2 && psLCLDEncoder->iCommonGrouping == 1 ) { @@ -662,17 +671,14 @@ int32_t EncodeLCLDFrame( pBits ); } - iBitsWritten += WritePredictors( psLCLDEncoder->psPredictionEncoder, pBits ); iBitsWritten += WriteGroupInformation( psLCLDEncoder->iChannels, psLCLDEncoder->iCommonGrouping, (const int32_t *) psLCLDEncoder->piNumGroups, psLCLDEncoder->ppiGroupLengths, pBits ); iBitsWritten += WriteRMSEnvelope( psLCLDEncoder->iChannels, (const int32_t *) psLCLDEncoder->piNumGroups, psLCLDEncoder->iNumBands, psLCLDEncoder->pppiRMSEnvelope, pBits ); - if ( psLCLDEncoder->iChannels == 2 && psLCLDEncoder->iCommonGrouping == 1 ) { - int32_t k; for ( k = 0; k < psLCLDEncoder->piNumGroups[0]; k++ ) { PerceptualModelStereo( psLCLDEncoder->iNumBands, @@ -689,7 +695,6 @@ int32_t EncodeLCLDFrame( { for ( n = 0; n < psLCLDEncoder->iChannels; n++ ) { - int32_t k; for ( k = 0; k < psLCLDEncoder->piNumGroups[n]; k++ ) { PerceptualModel( psLCLDEncoder->iNumBands, @@ -713,6 +718,7 @@ int32_t EncodeLCLDFrame( fprintf( fid, "%d %d\n", psLCLDEncoder->psPredictionEncoder->iSubSetId, psLCLDEncoder->psPredictionEncoder->piPredChanEnable[n] ); } #endif + iAvailableBits -= iBitsWritten; ComputeAllocation( psLCLDEncoder->iChannels, (const int32_t *) psLCLDEncoder->piNumGroups, @@ -731,8 +737,8 @@ int32_t EncodeLCLDFrame( psLCLDEncoder->pppiLCLDSignImag, psLCLDEncoder->psPredictionEncoder ); - iBitsWritten += WriteAllocInformation( psLCLDEncoder->iAllocOffset, - pBits ); + iBitsWritten += WriteAllocInformation( psLCLDEncoder->iAllocOffset, pBits ); + iAudioBitsWritten = iBitsWritten; iBitsWritten += WriteLCLDData( psLCLDEncoder->piNumGroups, psLCLDEncoder->ppiGroupLengths, @@ -1036,6 +1042,7 @@ static int32_t MSModeCalculation( fprintf( fid, "%d %d %d %d %d\n", iMsInfoBits, piMsPredInfoBits[MS_PHASE_AND_PRED], piMsPredInfoBits[MS_PRED_ONLY], piMsPredInfoBits[MS_PHASE_ONLY], iActualInfoBits ); } #endif + if ( *piMSMode != MS_OFF ) { iFBOffset = 0; @@ -1154,6 +1161,7 @@ static void RemoveRMSEnvelope( return; } + static void QuantizeSpectrumDPCM_Opt( const int32_t iNumGroups, const int32_t *piGroupLengths, @@ -1264,8 +1272,11 @@ static void QuantizeSpectrumDPCM_Opt( iFBOffset++; } /* bandwidth */ } /* bands */ + + return; } + static int32_t CountLCLDBits( const int32_t iNumGroups, const int32_t *piGroupLengths, @@ -1298,8 +1309,10 @@ static int32_t CountLCLDBits( { const uint16_t( *pauiHuffmanTable )[2] = NULL; const uint16_t( *pauiHuffmanTableDPCM )[2] = NULL; + pauiHuffmanTable = c_apauiHuffEncTabels[iAlloc]; pauiHuffmanTableDPCM = c_apauiHuffEncTabels[ALLOC_TABLE_SIZE + iAlloc]; + for ( m = 0; m < piBandwidths[b]; m++ ) { int32_t iQuantValue1; @@ -1378,7 +1391,7 @@ static int32_t WriteMSInformation( const int32_t *piMSFlags, const int32_t *piLRPhaseDiff, const int32_t *piMSPredCoef, - int32_t iNumMSPredBands, + const int32_t iNumMSPredBands, ISAR_SPLIT_REND_BITS_HANDLE pBits ) { int32_t iBitsWritten; @@ -1386,6 +1399,7 @@ static int32_t WriteMSInformation( #ifdef DEBUG_WRITE_MS_PRED int32_t iBitsWrittenTmp = 0; #endif + iBitsWritten = 0; ISAR_SPLIT_REND_BITStream_write_int32( pBits, iMSMode, 2 ); iBitsWritten += 2; @@ -1422,6 +1436,7 @@ static int32_t WriteMSInformation( break; } } + ISAR_SPLIT_REND_BITStream_write_int32( pBits, anyNonZero, 1 ); iBitsWritten++; @@ -1616,6 +1631,7 @@ static int32_t WriteAllocInformation( return iBitsWritten; } + static int32_t WriteLCLDData( const int32_t *piNumGroups, int32_t **ppiGroupLengths, @@ -1746,6 +1762,7 @@ static int32_t WriteLCLDData( return iBitsWritten; } + static int32_t ComputeAllocation( const int32_t iChannels, const int32_t *piNumGroups, @@ -1881,13 +1898,14 @@ static int32_t ComputeAllocation( } } +#ifdef DEBUGGING /* printf("%d\n",*piAllocOffset); printf("%d\t%d\t%d\n",pppiAlloc[0][0][0],pppiAlloc[0][0][1],pppiAlloc[0][0][22]); printf("%d\t%d\t%d\t%d\n",*piAllocOffset,iAvailableBits,iBitsUsed,iAvailableBits - iBitsUsed); */ - +#endif return iBitsUsed; } #endif diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index b685ad284be6761182256f1b6c1ab99fd05fdfaf..dd269b9a43c6550a5103de927c14716b2e50f563 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -249,6 +249,7 @@ typedef struct PREDICTION_ENCODER int32_t **ppiA1Mag; int32_t **ppiA1Phase; + } PredictionEncoder; ivas_error CreatePredictionEncoder( @@ -314,7 +315,7 @@ void DeletePredictionDecoder( PredictionDecoder *psPredictionDecoder ); -int32_t ReadPredictors( +int16_t ReadPredictors( PredictionDecoder *psPredictionDecoder, ISAR_SPLIT_REND_BITS_HANDLE pBits ); @@ -326,10 +327,10 @@ void UpdatePredictionSubSetId( void SetDecodingUnresolved( LCLDDecoder *psLCLDDecoder); -int32_t AnyDecodingFailedPrev( +int16_t AnyDecodingFailedPrev( LCLDDecoder *psLCLDDecoder); -int32_t AnyDecodingFailed( +int16_t AnyDecodingFailed( LCLDDecoder *psLCLDDecoder); int32_t **GetDecodingFailedStatus( diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 7431b7bc950cdca71949191dd86f81f00a177c01..cce9764aeefbc5044c040f6d32724187fef6f348 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -33,19 +33,22 @@ #ifndef ISAR_PROT_H #define ISAR_PROT_H - #include "isar_stat.h" - #ifdef SPLIT_REND_WITH_HEAD_ROT - #include #include "options.h" #include "ivas_error.h" #include "lib_isar_post_rend.h" + +/* clang-format off */ +/*----------------------------------------------------------------------------------* + * General ISAR prototypes + *----------------------------------------------------------------------------------*/ + ivas_error isar_splitBinPreRendOpen( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, /* i/o: binaural pre-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG , const int32_t output_Fs @@ -53,67 +56,78 @@ ivas_error isar_splitBinPreRendOpen( ); ivas_error split_renderer_open_lc3plus( - SPLIT_REND_WRAPPER *hSplitRendWrapper, - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int32_t OutSampleRate, + SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renderer handle */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */ + const int32_t output_Fs, /* i : output sampling rate */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - const IVAS_RENDER_FRAMESIZE ivas_frame_size + const IVAS_RENDER_FRAMESIZE ivas_frame_size /* i : IVAS frame size */ #else - const int16_t num_subframes + const int16_t num_subframes /* i : number of subframes */ #endif ); void isar_splitBinPreRendClose( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend ); + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend /* i/o: binaural pre-renderer handle */ +); void lc3plusTimeAlignCldfbPoseCorr( - SPLIT_REND_WRAPPER *hSplitBin, - float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ); + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, real part */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* i/o: Binaural signals, imag. part */ +); ivas_error splitRendLc3plusEncodeAndWrite( - SPLIT_REND_WRAPPER *hSplitBin, - ISAR_SPLIT_REND_BITS_HANDLE pBits, + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - const int32_t available_bits, + const int32_t available_bits, /* i : available bit-budget */ #else - const int32_t SplitRendBitRate, + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ #endif - float *in[] ); + float *in[] /* i/o: PCM in/out buffer */ +); +/*! r: parameter value */ int32_t ISAR_SPLIT_REND_BITStream_read_int32( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t bits ); + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int32_t bits /* i : number of bits to be read */ +); void ISAR_SPLIT_REND_BITStream_write_int32( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t val, - const int32_t bits ); + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int32_t val, /* i : parameter value */ + const int32_t bits /* i : number of bits to be written */ +); ivas_error isar_splitBinLCLDEncOpen( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, /* o : ISAR LCLD encoder handle */ const int32_t iSampleRate, const int16_t iChannels, const int32_t iDataRate, const int16_t iNumBlocks, - const int16_t iNumIterations ); + const int16_t iNumIterations +); ivas_error isar_splitBinRendPLCOpen( - ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, - const int16_t iNumSubSets ); + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, /* i/o: ISAR PLC handle */ + const int16_t iNumSubSets +); void isar_splitBinRendPLCClose( - ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC ); + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC /* i/o: ISAR PLC handle */ +); ivas_error isar_splitBinLCLDDecOpen( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, /* i/o: ISAR LCLD decoder handle */ const int32_t iSampleRate, const int16_t iChannels, const int16_t iNumBlocks, - const int16_t iNumIterations ); + const int16_t iNumIterations +); void isar_splitBinLCLDDecClose( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec ); + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec /* o : ISAR LCLD decoder handle */ +); void isar_splitBinRendPLCsaveState( ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, @@ -121,7 +135,8 @@ void isar_splitBinRendPLCsaveState( float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int16_t num_chs, const int16_t iNumBlocks, - const int16_t iNumIterations ); + const int16_t iNumIterations +); void isar_splitBinRendPLC_xf( ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, @@ -131,7 +146,8 @@ void isar_splitBinRendPLC_xf( const int16_t iNumBlocks, const int16_t iNumIterations, int32_t **ppiDecodingFailed, - int32_t **ppiDecodingFailedPrev ); + int32_t **ppiDecodingFailedPrev +); void isar_splitBinRendPLC( ISAR_SPLIT_REND_PLC_HANDLE hSplitRendPLC, @@ -140,7 +156,8 @@ void isar_splitBinRendPLC( const int16_t num_chs, const int16_t iNumBlocks, const int16_t iNumIterations, - int32_t **ppiDecodingFailed ); + int32_t **ppiDecodingFailed +); #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG void isar_log_cldfb2wav_data( @@ -152,51 +169,61 @@ void isar_log_cldfb2wav_data( const int32_t output_Fs, const int16_t start_slot_idx, const int16_t md_band_idx, - const char *filename ); -#endif + const char *filename +); +#endif void isar_splitBinLCLDDecProcess( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - 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 bfi ); + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, /* i/o: ISAR LCLD decoder handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, real part */ + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, imag. part */ + const int16_t bfi /* i : BFI flag */ +); void set_fix_rotation_mat( float fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +); void isar_splitBinLCLDEncClose( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc ); + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc /* i/o: ISAR LCLD encoder handle */ +); void isar_splitBinLCLDEncProcess( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, /* i/o: ISAR LCLD encoder handle */ float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int32_t available_bits, - ISAR_SPLIT_REND_BITS_HANDLE pBits ); + ISAR_SPLIT_REND_BITS_HANDLE pBits /* i/o: ISAR bits handle */ +); void set_pose_types( - ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1],/* o : ISAR pose type */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +); void isar_split_rend_init_huff_cfg( - ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg ); + ISAR_BIN_HR_SPLIT_REND_HUFF_HANDLE pHuff_cfg +); ivas_error isar_splitBinPostRendOpen( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const int32_t output_Fs ); + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const int32_t output_Fs /* i : output sampling rate */ +); void isar_splitBinPostRendClose( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend ); + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend /* i/o: binaural post-renderer handle */ +); void isar_SplitRenderer_getdiagdiff( int16_t in_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], int16_t out_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], const int16_t sign, const int16_t min_val, - const int16_t max_val ); + const int16_t max_val +); void isar_split_rend_get_quant_params( const int16_t num_md_bands, @@ -211,30 +238,28 @@ void isar_split_rend_get_quant_params( int16_t pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS const int16_t ro_flag, -#endif int16_t *num_quant_strats -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - , +#else + int16_t *num_quant_strats, int16_t *num_complex_bands #endif ); void isar_splitBinPostRendMdDec( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend -#else - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + , + BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend /* i/o: binaural pre-renderer handle */ #endif ); void Quat2EulerDegree( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float *yaw, /* o : yaw */ - float *pitch, /* o : pitch */ - float *roll /* o : roll */ + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ ); void isar_mat_mult_2by2_complex( @@ -243,156 +268,171 @@ void isar_mat_mult_2by2_complex( float in_re2[2][2], float in_im2[2][2], float out_re2[2][2], - float out_im2[2][2] ); + float out_im2[2][2] +); void isar_rend_CldfbSplitPostRendProcess( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const IVAS_QUATERNION QuaternionPost, 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 cldfb_in_flag ); + const int16_t cldfb_in_flag +); void isar_rend_CldfbSplitPreRendProcess( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - 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], - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t target_md_bits, - const int16_t low_res_pre_rend_rot, - const int16_t ro_md_flag ); + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, real part */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, imag. part */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int32_t target_md_bits, /* i : ISAR MD bitrate */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t ro_md_flag /* i : real only metadata for yaw flag */ +); ivas_error isar_renderMultiTDBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, - const IVAS_QUATERNION headPosition, - const int32_t SplitRendBitRate, + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - const int16_t isar_frame_size_ms, + const int16_t isar_frame_size_ms, /* i : ISAR bit stream frame size in ms */ #endif - const int16_t codec_frame_size_ms, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int16_t max_bands, - float *in[], - const int16_t low_res_pre_rend_rot, - const int16_t pcm_out_flag, - const int16_t ro_md_flag ); + const int16_t codec_frame_size_ms, /* i : ISAR frame length in ms */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int16_t max_bands, /* i : CLDFB bands */ + float *in[], /* i/o: PCM in/out buffer */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t pcm_out_flag, /* i : flag to indicate PCM output */ + const int16_t ro_md_flag /* i : real only metadata for yaw flag */ +); void isar_init_multi_bin_pose_data( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +); void isar_renderSplitGetMultiBinPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const ISAR_SPLIT_REND_ROT_AXIS rot_axis ); + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ +); #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS int16_t isar_renderSplitGetRot_axisNumBits( - const int16_t dof ); + const int16_t dof +); ISAR_SPLIT_REND_ROT_AXIS isar_renderSplitGetRot_axisFromCode( const int16_t dof, - const int16_t code ); + const int16_t code +); int16_t isar_renderSplitGetCodeFromRot_axis( const int16_t dof, const ISAR_SPLIT_REND_ROT_AXIS rot_axis, - int16_t *num_bits ); + int16_t *num_bits +); #endif void isar_init_split_post_rend_handles( - ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper ); + ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer post-renderer handle */ +); void isar_set_split_rend_ht_setup( - SPLIT_REND_WRAPPER *hSplitrend, - IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], - float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] ); + SPLIT_REND_WRAPPER *hSplitrend, /* i/o: Split renderer pre-renderer handle */ + IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], /* i/o: External orientation in quaternions */ + float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] /* o : real-space rotation matrix */ +); #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*! r: LC3plus bitrate */ int32_t isar_get_lc3plus_bitrate( - const int32_t SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const int16_t split_prerender_frame_size_ms ); -#endif + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ + const int16_t split_prerender_frame_size_ms /* i : ISAR frame length in ms */ +); +#endif #ifdef LC3PLUS_LEA_COMPAT_BITRATES_48_6 int32_t isar_get_lc3plus_bitrate( - const int32_t SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const int32_t nChannels, - const int32_t codecFrameDurationUs ); + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ + const int32_t nChannels, /* i : number of channels */ + const int32_t lc3plus_frame_duration_us /* i : ISAR frame length in us */ +); #endif ivas_error isar_split_rend_validate_config( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int16_t pcm_out_flag ); + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */ + const int16_t pcm_out_flag /* i : flag to indicate PCM output */ +); +/*! r: LCLD codec bitrate */ int32_t isar_get_lcld_bitrate( - const int32_t SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode ); + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode /* i : ISAR pose correction mode */ +); #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*! r: LC3plus codec bitrate ID */ int8_t isar_get_lc3plus_bitrate_id( - const int32_t SplitRendBitRate ); -#endif + const int32_t SplitRendBitRate /* i : ISAR bitrate */ +); +#endif +/*! r: ISAR MD bitrate */ int32_t isar_get_split_rend_md_target_brate( - const int32_t SplitRendBitRate, - const int16_t pcm_out_flag ); + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const int16_t pcm_out_flag /* i : flag to indicate PCM output */ +); #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ivas_error isar_framesize_to_ms( - const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ - int16_t *ms /* o : frame size in ms */ + const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ + int16_t *ms /* o : frame size in ms */ ); #endif ivas_error isar_split_rend_choose_default_codec( - ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ + ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ + int16_t *pIsar_frame_size_ms, /* i/o: pointer to ISAR frame size setting */ #endif - 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 */ - const int16_t num_subframes /* i : number of subframes */ + 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 */ + const int16_t num_subframes /* i : number of subframes */ ); -void ISAR_SPLIT_REND_BITStream_init( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t buf_len_bytes, - uint8_t *pbuf ); - -void isar_split_rend_huffman_dec_init_min_max_len( - isar_split_rend_huffman_cfg_t *p_huff_cfg ); - -int16_t wrap_a( - int16_t val, - const int16_t min_val, - const int16_t max_val ); - #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*! r: LC3plus bitrate */ int32_t isar_get_lc3plus_size_from_id( const int8_t SplitRendBitRateId, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const int16_t split_prerender_frame_size_ms ); -#endif + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ + const int16_t split_prerender_frame_size_ms /* i : ISAR frame length in ms */ +); +#endif void isar_renderSplitUpdateNoCorrectionPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ); + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +); int32_t get_bit( const int32_t state, - const int32_t bit_id ); + const int32_t bit_id +); +/*! r: ISAR audio type */ ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( - const IVAS_AUDIO_CONFIG config ); + const IVAS_AUDIO_CONFIG config /* i : audio configuration */ +); void isar_init_split_rend_handles( - SPLIT_REND_WRAPPER *hSplitRendWrapper ); + SPLIT_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer pre-renderer handle */ +); #endif diff --git a/lib_isar/isar_rom_lcld_tables.c b/lib_isar/isar_rom_lcld_tables.c index 7143c81349b475f49274e298494f8f35d4524daa..b84ce70efa47e8b778f1f3ac940e3a520f40a182 100644 --- a/lib_isar/isar_rom_lcld_tables.c +++ b/lib_isar/isar_rom_lcld_tables.c @@ -38,6 +38,11 @@ #include "isar_lcld_prot.h" /* clang-format off */ + +/*----------------------------------------------------------------------* + * ISAR binaural rendering LCLD ROM tables + *-----------------------------------------------------------------------*/ + const int32_t c_aiNumLcldBandsPerBand[MAX_BANDS_48] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21, 24, 27, 31, 37, 43, 50, 60 }; diff --git a/lib_isar/isar_rom_lcld_tables.h b/lib_isar/isar_rom_lcld_tables.h index cfad1b7fc390ad3f7d366e0e8feea92c8f8f4d10..ae9bf73480740a885ce8054528004ef2b2518d6d 100644 --- a/lib_isar/isar_rom_lcld_tables.h +++ b/lib_isar/isar_rom_lcld_tables.h @@ -36,11 +36,10 @@ #include #include "options.h" + #ifdef SPLIT_REND_WITH_HEAD_ROT #ifndef M_PI - #define M_PI 3.14159265358979323846264338327950288f - #endif #define LCLD_BLOCKS_PER_FRAME ( 16 ) @@ -126,6 +125,11 @@ extern const int32_t c_aaiSpreadFunction48[MAX_BANDS_48 * MAX_BANDS_48]; #define PRED_QUANT_FILTER_PHASE_MIN ( -16 ) #define PRED_QUANT_FILTER_PHASE_MAX ( 15 ) + +/*----------------------------------------------------------------------* + * ISAR binaural rendering LCLD ROM tables + *-----------------------------------------------------------------------*/ + extern const uint16_t c_aauiLCLDHuffEnc1[16][2]; extern const uint16_t c_aauiLCLDHuffEnc2[16][2]; extern const uint16_t c_aauiLCLDHuffEnc3[25][2]; diff --git a/lib_isar/isar_rom_post_rend.c b/lib_isar/isar_rom_post_rend.c index f73a2526b8e4bab4ed39989245df003253fe7e7c..70bd87ebcac9d43c7793b1d5860eabea04aacd05 100644 --- a/lib_isar/isar_rom_post_rend.c +++ b/lib_isar/isar_rom_post_rend.c @@ -43,7 +43,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------* - * Binuaral split rendering ROM tables + * ISAR binaural split post-rendering ROM tables *-----------------------------------------------------------------------*/ /* rotations in this array are relative to ref rotation */ diff --git a/lib_isar/isar_rom_post_rend.h b/lib_isar/isar_rom_post_rend.h index 043ba5b2138a9b24af9ade5e5572a11dae30a946..2f5a1a1eec9a691103666d189020a5b9e667cc7b 100644 --- a/lib_isar/isar_rom_post_rend.h +++ b/lib_isar/isar_rom_post_rend.h @@ -43,7 +43,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------* - * Binuaral split rendering ROM tables + * ISAR binarual split post-rendering ROM tables *-----------------------------------------------------------------------*/ extern const float isar_split_rend_relative_yaw_pos_angles[SPLIT_REND_MAX_YAW_ONLY_POSES]; diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c index 95362d50ed49e18034333606018a14a02796a192..993c714bdb76338f48c5c18200a94c9da192e2ef 100644 --- a/lib_isar/isar_splitRend_lcld_dec.c +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -49,7 +49,7 @@ *------------------------------------------------------------------------*/ ivas_error isar_splitBinLCLDDecOpen( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec, /* i/o: ISAR LCLD decoder handle */ const int32_t iSampleRate, const int16_t iChannels, const int16_t iNumBlocks, @@ -127,7 +127,8 @@ ivas_error isar_splitBinLCLDDecOpen( *------------------------------------------------------------------------*/ void isar_splitBinLCLDDecClose( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec ) + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE *hSplitBinLCLDDec /* o : ISAR LCLD decoder handle */ +) { int16_t n; @@ -169,11 +170,12 @@ void isar_splitBinLCLDDecClose( *------------------------------------------------------------------------*/ void isar_splitBinLCLDDecProcess( - ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - 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 bfi ) + ISAR_BIN_HR_SPLIT_LCLD_DEC_HANDLE hSplitBinLCLDDec, /* i/o: ISAR LCLD decoder handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, real part */ + float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, imag. part */ + const int16_t bfi /* i : BFI flag */ +) { int16_t k, n; int16_t itr; diff --git a/lib_isar/isar_splitRend_lcld_enc.c b/lib_isar/isar_splitRend_lcld_enc.c index ebeaacab9ca0f9cfb69e8307922c0363dd9911fb..95efee22b03ccf2ac42cdf6c709ea6b6f25d6de2 100644 --- a/lib_isar/isar_splitRend_lcld_enc.c +++ b/lib_isar/isar_splitRend_lcld_enc.c @@ -48,7 +48,7 @@ *------------------------------------------------------------------------*/ ivas_error isar_splitBinLCLDEncOpen( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc, /* o : ISAR LCLD handle */ const int32_t iSampleRate, const int16_t iChannels, const int32_t iDataRate, @@ -121,7 +121,8 @@ ivas_error isar_splitBinLCLDEncOpen( *------------------------------------------------------------------------*/ void isar_splitBinLCLDEncClose( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc ) + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE *hSplitBinLCLDEnc /* i/o: ISAR LCLD handle */ +) { if ( ( *hSplitBinLCLDEnc ) != NULL ) { @@ -157,11 +158,12 @@ void isar_splitBinLCLDEncClose( *------------------------------------------------------------------------*/ void isar_splitBinLCLDEncProcess( - ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, + ISAR_BIN_HR_SPLIT_LCLD_ENC_HANDLE hSplitBinLCLDEnc, /* i/o: ISAR LCLD encoder handle */ float Cldfb_In_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_In_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int32_t available_bits, - ISAR_SPLIT_REND_BITS_HANDLE pBits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits /* i/o: ISAR bits handle */ +) { int32_t iBitsWritten, itr, available_bits_itr, rem_itr, available_bits_local; push_wmops( "isar_splitBinLCLDEncProcess" ); diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index e781676d5f366658dfa5624a3d91a1f4adba1fbb..ebf5c294b32bb0e402e0aed995f4342141acd348 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -318,7 +318,7 @@ static void adaptive_polar_ext_plc( *------------------------------------------------------------------------*/ ivas_error isar_splitBinRendPLCOpen( - ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC, /* i/o: ISAR PLC handle */ const int16_t iNumSubSets ) { ivas_error error; @@ -348,7 +348,8 @@ ivas_error isar_splitBinRendPLCOpen( *------------------------------------------------------------------------*/ void isar_splitBinRendPLCClose( - ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC ) + ISAR_SPLIT_REND_PLC_HANDLE *phSplitRendPLC /* i/o: ISAR PLC handle */ +) { if ( ( *phSplitRendPLC ) != NULL ) { @@ -502,7 +503,6 @@ void isar_splitBinRendPLC( } } - /* Check bf counter */ fade_start_cntr = SR_PLC_FADE_START * CLDFB_NO_COL_MAX / iNumCols; mute_cntr = SR_PLC_MUTE * CLDFB_NO_COL_MAX / iNumCols; diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 6ea2d2539f450e4fefa0aef920ecc18c29abbf43..375868aa2e3d20ca21605451cdb03947ff584513 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -46,16 +46,12 @@ #endif #include "wmc_auto.h" + /*---------------------------------------------------------------------* * Local function declarations *---------------------------------------------------------------------*/ -static void isar_SplitRenderer_PostRenderer( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - float Cldfb_RealBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ - float Cldfb_ImagBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ - const IVAS_QUATERNION Quaternion_act ); +static void isar_SplitRenderer_PostRenderer( ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, float Cldfb_RealBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], const IVAS_QUATERNION Quaternion_act ); /*------------------------------------------------------------------------- @@ -65,9 +61,10 @@ static void isar_SplitRenderer_PostRenderer( *------------------------------------------------------------------------*/ ivas_error isar_splitBinPostRendOpen( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const int32_t output_Fs ) + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const int32_t output_Fs /* i : output sampling rate */ +) { ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinRend; ivas_error error; @@ -134,7 +131,8 @@ ivas_error isar_splitBinPostRendOpen( *------------------------------------------------------------------------*/ void isar_splitBinPostRendClose( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend ) + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE *hBinHrSplitPostRend /* i/o: binaural post-renderer handle */ +) { int16_t ch; @@ -183,7 +181,7 @@ void isar_splitBinPostRendClose( static int16_t isar_split_rend_huffman_decode_opt( isar_split_rend_huffman_cfg_t *huff_cfg, - ISAR_SPLIT_REND_BITS_HANDLE pBits, + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ const int16_t *idx_trav_list ) { int32_t i, ind, code, num_bits, code_b, num_bits_read; @@ -221,6 +219,7 @@ static int16_t isar_split_rend_huffman_decode_opt( return (int16_t) ind; } + /*-----------------------------------------------------------------------------------------* * Function isar_split_rend_unquant_md() * @@ -326,9 +325,9 @@ static void isar_split_rend_unquant_md( *-----------------------------------------------------------------------------------------*/ static void isar_splitBinPostRendMdBase2Dec( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const int16_t num_subframes, const int16_t pred_real_bands_yaw, const int16_t pred_imag_bands_yaw, @@ -524,9 +523,9 @@ static void isar_splitBinPostRendMdBase2Dec( *-----------------------------------------------------------------------------------------*/ static void isar_splitBinPostRendMdHuffDec( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const int16_t num_subframes, const int16_t pred_real_bands_yaw, const int16_t pred_imag_bands_yaw, @@ -719,9 +718,9 @@ static void isar_splitBinPostRendMdHuffDec( *-----------------------------------------------------------------------------------------*/ void isar_splitBinPostRendMdDec( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG , BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend @@ -1157,6 +1156,7 @@ static void wrap_around_angle( { ( *a ) = ( *a ) + 360; } + return; } @@ -1177,6 +1177,7 @@ static void wrap_around_ypr( wrap_around_angle( &Quaternions->y ); wrap_around_angle( &Quaternions->z ); } + return; } @@ -1269,7 +1270,7 @@ static void get_nearest_pose_ind( *-----------------------------------------------------------------------------------------*/ static void get_interpolation_vars( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const IVAS_QUATERNION *Quaternions_ref, const IVAS_QUATERNION *Quaternions_act, int16_t interp_yaw_pose_idx[2], @@ -1547,8 +1548,8 @@ static void interpolate_rend_md( *-----------------------------------------------------------------------------------------*/ static void isar_SplitRenderer_PostRenderer( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ const IVAS_QUATERNION Quaternion_act ) @@ -1610,7 +1611,6 @@ static void isar_SplitRenderer_PostRenderer( } } - #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES - 1; pos_idx++ ) { @@ -1647,9 +1647,6 @@ static void isar_SplitRenderer_PostRenderer( } } -#endif - -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) #else pos_idx = 0; @@ -1782,8 +1779,8 @@ static void isar_SplitRenderer_PostRenderer( fname ); } } -#endif +#endif pop_wmops(); return; } @@ -1796,8 +1793,8 @@ static void isar_SplitRenderer_PostRenderer( *-----------------------------------------------------------------------------------------*/ static void isar_rend_CldfbSplitPostRendProcessTdIn( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const IVAS_QUATERNION QuaternionPost, float output[][L_FRAME48k] ) { @@ -1847,8 +1844,8 @@ static void isar_rend_CldfbSplitPostRendProcessTdIn( *-----------------------------------------------------------------------------------------*/ void isar_rend_CldfbSplitPostRendProcess( - ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend, /* i/o: binaural post-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const IVAS_QUATERNION QuaternionPost, 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], @@ -1897,7 +1894,8 @@ void isar_rend_CldfbSplitPostRendProcess( *-----------------------------------------------------------------------------------------*/ void isar_init_split_post_rend_handles( - ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper ) + ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer post-renderer handle */ +) { hSplitRendWrapper->hBinHrSplitPostRend = NULL; hSplitRendWrapper->hSplitBinLCLDDec = NULL; diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 3db6abf319e2badeb5bc749dbd26f1b156776177..dbb25e7214d6d2d295a4d1ff8f14fac8f7193ef6 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -54,13 +54,8 @@ * Local function declarations *---------------------------------------------------------------------*/ -static void isar_SplitRenderer_GetRotMd( - ISAR_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_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : Reference Binaural signals */ - const int16_t low_res, - const int16_t ro_md_flag ); +static void isar_SplitRenderer_GetRotMd( ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const int16_t low_res, const int16_t ro_md_flag ); + /*------------------------------------------------------------------------- * Local functions @@ -500,6 +495,7 @@ static void isar_split_rend_quant_md( { hMd->pred_mat_re[ch1][ch1] = hMd->pred_mat_re2[ch1]; } + hMd->pred_mat_re[1][0] = 0.0f; hMd->pred_mat_re[0][1] = 0.0f; @@ -577,12 +573,15 @@ static void isar_split_rend_quant_md( return; } + #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS -static void get_lr_gains( float cov_in[][BINAURAL_CHANNELS], - float cov_out[][BINAURAL_CHANNELS], - float gains[BINAURAL_CHANNELS] ) +static void get_lr_gains( + float cov_in[][BINAURAL_CHANNELS], + float cov_out[][BINAURAL_CHANNELS], + float gains[BINAURAL_CHANNELS] ) { int16_t i; + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { gains[i] = cov_in[i][i]; @@ -596,10 +595,12 @@ static void get_lr_gains( float cov_in[][BINAURAL_CHANNELS], gains[i] = sqrtf( gains[i] ); } } + return; } #endif + static void ComputeCoeffs( float cov_ii_re[][BINAURAL_CHANNELS], float cov_ii_im[][BINAURAL_CHANNELS], @@ -622,6 +623,7 @@ static void ComputeCoeffs( if ( pose_type == PITCH_ONLY ) { float gd_tmp[BINAURAL_CHANNELS]; + #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS get_lr_gains( cov_ii_re, cov_oo_re, gd_tmp ); #else @@ -639,6 +641,7 @@ static void ComputeCoeffs( } } #endif + hMd->gd = gd_tmp[0]; hMd->gd2 = gd_tmp[1]; } @@ -647,8 +650,10 @@ static void ComputeCoeffs( if ( real_only ) { float gd_tmp[BINAURAL_CHANNELS]; + #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS get_lr_gains( cov_ii_re, cov_oo_re, gd_tmp ); + for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { hMd->pred_mat_re[i][i] = gd_tmp[i]; @@ -672,6 +677,7 @@ static void ComputeCoeffs( set_zero( hMd->pred_mat_im[i], BINAURAL_CHANNELS ); } #endif + hMd->pred_mat_re[1][0] = 0.0f; hMd->pred_mat_re[0][1] = 0.0f; } @@ -680,6 +686,7 @@ static void ComputeCoeffs( #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS get_lr_gains( cov_ii_re, cov_oo_re, hMd->pred_mat_re2 ); #endif + cov_norm_fact = GetNormFact( cov_ii_re, cov_ii_im, cov_io_re, cov_io_im, cov_oo_re ); /* normalize the covariance */ @@ -759,8 +766,8 @@ static void ComputeCoeffs( static void get_base2_bits( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const int16_t num_subframes, const int16_t num_quant_strats, const int16_t pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], @@ -833,8 +840,8 @@ static void get_base2_bits( static void isar_SplitRenderer_code_md_base2( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const int16_t num_subframes, const int16_t pred_real_bands_yaw, const int16_t pred_imag_bands_yaw, @@ -843,7 +850,8 @@ static void isar_SplitRenderer_code_md_base2( const int16_t bands_pitch, const int16_t pred_real_bands_roll, const int16_t pred_imag_bands_roll, - ISAR_SPLIT_REND_BITS_HANDLE pBits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits /* i/o: ISAR bits handle */ +) { int16_t pos_idx, b, ch1, ch2, sf_idx; int16_t min_pred_idx, min_gd_idx, min_p_gd_idx, pred_code_len, gd_code_len, p_gd_code_len, num_poses; @@ -907,7 +915,6 @@ static void isar_SplitRenderer_code_md_base2( } } #else - for ( b = 0; b < pred_imag_bands_yaw; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; @@ -940,6 +947,7 @@ static void isar_SplitRenderer_code_md_base2( } } #endif + for ( b = 0; b < d_bands_yaw; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; @@ -1047,8 +1055,8 @@ static void isar_SplitRenderer_code_md_base2( static void isar_SplitRenderer_code_md_huff( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const int16_t num_subframes, const int16_t pred_real_bands_yaw, const int16_t pred_imag_bands_yaw, @@ -1057,7 +1065,8 @@ static void isar_SplitRenderer_code_md_huff( const int16_t bands_pitch, const int16_t pred_real_bands_roll, const int16_t pred_imag_bands_roll, - ISAR_SPLIT_REND_BITS_HANDLE pBits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits /* i/o: ISAR bits handle */ +) { int16_t pos_idx, b, ch1, ch2, sf_idx, num_poses; int16_t sym_adj_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; @@ -1267,15 +1276,16 @@ static void isar_SplitRenderer_code_md_huff( static void isar_SplitRenderer_quant_code( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - const IVAS_QUATERNION headPosition, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int16_t low_res_pre_rend_rot, + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - const int16_t ro_md_flag, + const int16_t ro_md_flag, /* i : real only metadata for yaw flag */ #endif - const int32_t target_md_bits ) + const int32_t target_md_bits /* i : ISAR MD bitrate */ +) { #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS int16_t q, num_subframes, sf_idx, pos_idx, b, num_quant_strats; @@ -1308,12 +1318,14 @@ static void isar_SplitRenderer_quant_code( ISAR_SPLIT_REND_BITStream_write_int32( pBits, pMultiBinPoseData->dof, ISAR_SPLIT_REND_DOF_BITS ); ISAR_SPLIT_REND_BITStream_write_int32( pBits, pMultiBinPoseData->hq_mode, ISAR_SPLIT_REND_HQ_MODE_BITS ); + #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS rot_axis_code = isar_renderSplitGetCodeFromRot_axis( pMultiBinPoseData->dof, pMultiBinPoseData->rot_axis, &num_bits ); if ( num_bits > 0 ) { ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) rot_axis_code, num_bits ); } + ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) ro_md_flag, ISAR_SPLIT_REND_RO_FLAG_BITS ); #else ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) pMultiBinPoseData->rot_axis, ISAR_SPLIT_REND_ROT_AXIS_BITS ); @@ -1349,13 +1361,13 @@ static void isar_SplitRenderer_quant_code( pred_quant_pnts_yaw, pred_quantstep_yaw, pred_1byquantstep_yaw, d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, &num_quant_strats, &num_complex_bands ); #endif + quant_strat_bits = (int32_t) ceilf( log2f( num_quant_strats ) ); 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, - pred_quant_pnts_yaw, - d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, base2bits ); + pred_quant_pnts_yaw, d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, base2bits ); for ( q = 0; q < num_quant_strats; q++ ) { @@ -1441,8 +1453,7 @@ static void isar_SplitRenderer_quant_code( ISAR_SPLIT_REND_BITStream_write_int32( pBits, q, quant_strat_bits ); isar_SplitRenderer_code_md_base2( hBinHrSplitPreRend, pMultiBinPoseData, num_subframes, pred_real_bands_yaw[q], pred_imag_bands_yaw[q], - pred_quant_pnts_yaw[q], - d_bands_yaw[q], bands_pitch[q], pred_real_bands_roll[q], pred_imag_bands_roll[q], pBits ); + pred_quant_pnts_yaw[q], d_bands_yaw[q], bands_pitch[q], pred_real_bands_roll[q], pred_imag_bands_roll[q], pBits ); } break; } @@ -1525,8 +1536,8 @@ static void isar_SplitRenderer_quant_code( } } } -#endif +#endif return; } @@ -1538,12 +1549,13 @@ static void isar_SplitRenderer_quant_code( *------------------------------------------------------------------------*/ static void isar_SplitRenderer_GetRotMd( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i/o: binaural renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ 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 ro_md_flag ) + const int16_t ro_md_flag /* i : Flag to indicate real only metadata for yaw */ +) { float cov_ii_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; float cov_oo_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; @@ -1622,15 +1634,16 @@ static void isar_SplitRenderer_GetRotMd( *------------------------------------------------------------------------*/ void isar_rend_CldfbSplitPreRendProcess( - const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, - 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], - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t target_md_bits, - const int16_t low_res_pre_rend_rot, - const int16_t ro_md_flag ) + const ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE hBinHrSplitPreRend, /* i : binaural pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, real part */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Binaural signals, imag. part */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int32_t target_md_bits, /* i : ISAR MD bitrate */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t ro_md_flag /* i : real only metadata for yaw flag */ +) { push_wmops( "isar_rend_CldfbSplitPreRendProcess" ); @@ -1745,8 +1758,8 @@ void isar_rend_CldfbSplitPreRendProcess( *------------------------------------------------------------------------*/ ivas_error isar_splitBinPreRendOpen( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend, /* i/o: binaural pre-renderer handle */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* o : pose correction data handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG , const int32_t output_Fs @@ -1784,8 +1797,8 @@ ivas_error isar_splitBinPreRendOpen( } } } -#endif +#endif for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses - 1; pos_idx++ ) { for ( sf_idx = 0; sf_idx < MAX_SPLIT_MD_SUBFRAMES; sf_idx++ ) @@ -1809,8 +1822,8 @@ ivas_error isar_splitBinPreRendOpen( { return error; } -#endif +#endif *hBinHrSplitPreRend = hBinRend; return IVAS_ERR_OK; @@ -1824,7 +1837,8 @@ ivas_error isar_splitBinPreRendOpen( *------------------------------------------------------------------------*/ void isar_splitBinPreRendClose( - ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend ) + ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE *hBinHrSplitPreRend /* i/o: binaural pre-renderer handle */ +) { if ( ( *hBinHrSplitPreRend ) != NULL ) { @@ -1863,11 +1877,13 @@ void isar_splitBinPreRendClose( *-------------------------------------------------------------------------*/ void isar_set_split_rend_ht_setup( - SPLIT_REND_WRAPPER *hSplitrend, - IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], - float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] ) + SPLIT_REND_WRAPPER *hSplitrend, /* i/o: Split renderer pre-renderer handle */ + IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES], /* i/o: External orientation in quaternions */ + float Rmat[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] /* o : real-space rotation matrix */ +) { int16_t sf, i, j; + if ( hSplitrend->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { for ( sf = 1; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) @@ -1895,7 +1911,8 @@ void isar_set_split_rend_ht_setup( *------------------------------------------------------------------------*/ void isar_init_split_rend_handles( - SPLIT_REND_WRAPPER *hSplitRendWrapper ) + SPLIT_REND_WRAPPER *hSplitRendWrapper /* i/o: Split renderer pre-renderer handle */ +) { int16_t i; @@ -1915,6 +1932,7 @@ void isar_init_split_rend_handles( return; } + /*------------------------------------------------------------------------- * Function split_renderer_open_lc3plus() * @@ -1922,13 +1940,13 @@ void isar_init_split_rend_handles( *------------------------------------------------------------------------*/ ivas_error split_renderer_open_lc3plus( - SPLIT_REND_WRAPPER *hSplitRendWrapper, - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int32_t OutSampleRate, + SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i/o: Split renderer pre-renderer handle */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i : Split renderer pre-renderer config */ + const int32_t output_Fs, /* i : output sampling rate */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - const IVAS_RENDER_FRAMESIZE isar_frame_size + const IVAS_RENDER_FRAMESIZE isar_frame_size /* i : IVAS frame size */ #else - const int16_t num_subframes + const int16_t num_subframes /* i : number of subframes */ #endif ) { @@ -1956,7 +1974,7 @@ ivas_error split_renderer_open_lc3plus( #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS config.isar_frame_duration_us = ( pSplitRendConfig->dof == 0 ) ? config.lc3plus_frame_duration_us * num_subframes : 20000; #endif - config.samplerate = OutSampleRate; + config.samplerate = output_Fs; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS config.isar_frame_duration_us = isar_frame_size_ms * 1000; @@ -1967,17 +1985,15 @@ ivas_error split_renderer_open_lc3plus( #endif config.channels = BINAURAL_CHANNELS; - if ( ( error = ISAR_LC3PLUS_ENC_Open( config, #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS #ifdef LC3PLUS_LEA_COMPAT_BITRATES_48_6 - isar_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, config.channels, config.lc3plus_frame_duration_us ), + if ( ( error = ISAR_LC3PLUS_ENC_Open( config, isar_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, config.channels, config.lc3plus_frame_duration_us ), &hSplitRendWrapper->hLc3plusEnc ) ) != IVAS_ERR_OK ) #else - isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode ), + if ( ( error = ISAR_LC3PLUS_ENC_Open( config, isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode ), &hSplitRendWrapper->hLc3plusEnc ) ) != IVAS_ERR_OK ) #endif #else - isar_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, (int16_t) ( config.isar_frame_duration_us / 1000 ) ), + if ( ( error = ISAR_LC3PLUS_ENC_Open( config, isar_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, (int16_t) ( config.isar_frame_duration_us / 1000 ) ), &hSplitRendWrapper->hLc3plusEnc ) ) != IVAS_ERR_OK ) #endif - &hSplitRendWrapper->hLc3plusEnc ) ) != IVAS_ERR_OK ) { return error; } @@ -1991,7 +2007,7 @@ ivas_error split_renderer_open_lc3plus( /* Alocate buffers for delay compensation */ if ( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) { - delayBufferLength = (int16_t) ( OutSampleRate / (int32_t) FRAMES_PER_SECOND + hSplitRendWrapper->lc3plusDelaySamples ); + delayBufferLength = (int16_t) ( output_Fs / (int32_t) FRAMES_PER_SECOND + hSplitRendWrapper->lc3plusDelaySamples ); for ( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i ) { if ( ( hSplitRendWrapper->lc3plusDelayBuffers[i] = malloc( delayBufferLength * sizeof( float ) ) ) == NULL ) @@ -2005,8 +2021,8 @@ ivas_error split_renderer_open_lc3plus( else { /* Delay is always expected to be exactly 2 CLDFB columns */ - assert( hSplitRendWrapper->lc3plusDelaySamples % ( OutSampleRate / FRAMES_PER_SEC / CLDFB_NO_COL_MAX ) == 0 ); - assert( hSplitRendWrapper->lc3plusDelaySamples / ( OutSampleRate / FRAMES_PER_SEC / CLDFB_NO_COL_MAX ) == 2 ); + assert( hSplitRendWrapper->lc3plusDelaySamples % ( output_Fs / FRAMES_PER_SEC / CLDFB_NO_COL_MAX ) == 0 ); + assert( hSplitRendWrapper->lc3plusDelaySamples / ( output_Fs / FRAMES_PER_SEC / CLDFB_NO_COL_MAX ) == 2 ); delayBufferLength = 2 /* Columns */ * 2 /* real and imag */ * CLDFB_NO_CHANNELS_MAX; for ( i = 0; i < hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; ++i ) @@ -2031,16 +2047,15 @@ ivas_error split_renderer_open_lc3plus( *------------------------------------------------------------------------*/ ivas_error splitRendLc3plusEncodeAndWrite( - SPLIT_REND_WRAPPER *hSplitBin, - ISAR_SPLIT_REND_BITS_HANDLE pBits, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - const int32_t available_bits, -#endif + const int32_t available_bits, /* i : available bit-budget */ #else - const int32_t SplitRendBitRate, + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ #endif - float *in[] ) + float *in[] /* i/o: PCM in/out buffer */ +) { ivas_error error; int16_t i; @@ -2073,8 +2088,8 @@ ivas_error splitRendLc3plusEncodeAndWrite( #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS ISAR_SPLIT_REND_BITStream_write_int32( pBits, isar_get_lc3plus_bitrate_id( SplitRendBitRate ), 8 ); -#endif +#endif /* Write bitstream */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( ( error = ISAR_LC3PLUS_ENC_Encode( hSplitBin->hLc3plusEnc, channel_ptrs, &pBits->bits_buf[pBits->bits_written / 8], lc3plusBitstreamSize ) ) != IVAS_ERR_OK ) @@ -2092,9 +2107,11 @@ ivas_error splitRendLc3plusEncodeAndWrite( #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS pBits->isar_frame_size_ms = (int16_t) ( hSplitBin->hLc3plusEnc->config.isar_frame_duration_us / 1000 ); #endif + return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * Function isar_renderMultiTDBinToSplitBinaural() * @@ -2102,19 +2119,20 @@ ivas_error splitRendLc3plusEncodeAndWrite( *------------------------------------------------------------------------*/ ivas_error isar_renderMultiTDBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, - const IVAS_QUATERNION headPosition, - const int32_t SplitRendBitRate, + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - const int16_t isar_frame_size_ms, + const int16_t isar_frame_size_ms, /* i : ISAR bit stream frame size in ms */ #endif - const int16_t codec_frame_size_ms, - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int16_t max_bands, - float *in[], - const int16_t low_res_pre_rend_rot, - const int16_t pcm_out_flag, - const int16_t ro_md_flag ) + const int16_t codec_frame_size_ms, /* i : ISAR frame length in ms */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int16_t max_bands, /* i : CLDFB bands */ + float *in[], /* i/o: PCM in/out buffer */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t pcm_out_flag, /* i : flag to indicate PCM output */ + const int16_t ro_md_flag /* i : real only metadata for yaw flag */ +) { ivas_error error; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS @@ -2203,8 +2221,8 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS actual_md_bits = pBits->bits_written; -#endif +#endif isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot, ro_md_flag ); } @@ -2232,7 +2250,6 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( else { #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS #ifdef LC3PLUS_LEA_COMPAT_BITRATES_48_6 if ( pBits->pose_correction == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) { @@ -2245,11 +2262,8 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( #else available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; #endif + if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, available_bits, in ) ) != IVAS_ERR_OK ) -#else - available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; - if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, in ) ) != IVAS_ERR_OK ) -#endif #else if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, in ) ) != IVAS_ERR_OK ) #endif @@ -2300,9 +2314,10 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( *------------------------------------------------------------------------*/ void lc3plusTimeAlignCldfbPoseCorr( - SPLIT_REND_WRAPPER *hSplitBin, - float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renderer handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: Binaural signals, real part */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* ii/: Binaural signals, imag. part */ +) { float Cldfb_In_BinReal_tmp[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][2][CLDFB_NO_CHANNELS_MAX]; float Cldfb_In_BinImag_tmp[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][2][CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 81961fd94910400892e7e4e3500a0ddf8f3dccbe..15aa6cc2672de6f590e48d3e4496c65dbb49830a 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -79,33 +79,13 @@ void isar_mat_mult_2by2_complex( } -/*------------------------------------------------------------------------- - * Function ISAR_SPLIT_REND_BITStream_init() - * - * - *------------------------------------------------------------------------*/ - -void ISAR_SPLIT_REND_BITStream_init( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t buf_len_bytes, - uint8_t *pbuf ) -{ - pBits->bits_buf = pbuf; - pBits->buf_len = buf_len_bytes; - pBits->bits_read = 0; - pBits->bits_written = 0; - - return; -} - - /*------------------------------------------------------------------------- * Function isar_split_rend_huffman_dec_init_min_max_len() * * *------------------------------------------------------------------------*/ -void isar_split_rend_huffman_dec_init_min_max_len( +static void isar_split_rend_huffman_dec_init_min_max_len( isar_split_rend_huffman_cfg_t *p_huff_cfg ) { int16_t i, code_len; @@ -257,7 +237,8 @@ void isar_split_rend_init_huff_cfg( void set_fix_rotation_mat( float fix_pos_rot_mat[][BINAURAL_CHANNELS][BINAURAL_CHANNELS], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +) { float yaw_a, cos_yaw, sin_yaw; int16_t pos_idx; @@ -286,8 +267,9 @@ void set_fix_rotation_mat( *------------------------------------------------------------------------*/ void set_pose_types( - ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1], /* o : ISAR pose type */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i : pose correction data handle */ +) { int16_t pos_idx; @@ -317,7 +299,7 @@ void set_pose_types( * *------------------------------------------------------------------------*/ -int16_t wrap_a( +static int16_t wrap_a( int16_t val, const int16_t min_val, const int16_t max_val ) @@ -366,17 +348,19 @@ void isar_SplitRenderer_getdiagdiff( * *------------------------------------------------------------------------*/ +/*! r: parameter value */ int32_t ISAR_SPLIT_REND_BITStream_read_int32( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t bits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int32_t bits /* i : number of bits to be read */ +) { int32_t val, k, bit_val; #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG assert( ( pBits->bits_written - pBits->bits_read ) >= bits ); assert( bits <= 32 ); -#endif +#endif /* write bit by bit */ val = 0; for ( k = bits - 1; k >= 0; k-- ) @@ -397,9 +381,10 @@ int32_t ISAR_SPLIT_REND_BITStream_read_int32( *------------------------------------------------------------------------*/ void ISAR_SPLIT_REND_BITStream_write_int32( - ISAR_SPLIT_REND_BITS_HANDLE pBits, - const int32_t val, - const int32_t bits ) + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits handle */ + const int32_t val, /* i : parameter value */ + const int32_t bits /* i : number of bits to be written */ +) { int32_t mask, k; @@ -483,9 +468,11 @@ void isar_log_cldfb2wav_data( * *------------------------------------------------------------------------*/ +/*! r: ISAR MD bitrate */ int32_t isar_get_split_rend_md_target_brate( - const int32_t SplitRendBitRate, - const int16_t pcm_out_flag ) + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const int16_t pcm_out_flag /* i : flag to indicate PCM output */ +) { int32_t md_bitrate; @@ -529,9 +516,11 @@ int32_t isar_get_split_rend_md_target_brate( * *------------------------------------------------------------------------*/ +/*! r: LCLD codec bitrate */ int32_t isar_get_lcld_bitrate( - const int32_t SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode ) + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode /* i : ISAR pose correction mode */ +) { if ( poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { @@ -563,6 +552,7 @@ int32_t isar_get_lcld_bitrate( return -1; } + #ifdef LC3PLUS_LEA_COMPAT_BITRATES_48_6 /*------------------------------------------------------------------------- * Function isar_get_lc3plus_bitrate() @@ -571,18 +561,22 @@ int32_t isar_get_lcld_bitrate( *------------------------------------------------------------------------*/ int32_t isar_get_lc3plus_bitrate( - const int32_t SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const int32_t nChannels, - const int32_t codecFrameDurationUs ) + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ + const int32_t nChannels, /* i : number of channels */ + const int32_t codecFrameDurationUs /* i : ISAR frame length in us */ +) { int32_t bitrate; + bitrate = isar_get_lcld_bitrate( SplitRendBitRate, poseCorrectionMode ); + /* Check for LC3plus LEA 48_6 LC3 compatibility mode signalling */ if ( ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE == poseCorrectionMode && bitrate == 256000 && nChannels == 2 && codecFrameDurationUs == 10000 ) { bitrate = 2 * 126000; } + return bitrate; } #endif @@ -595,9 +589,10 @@ int32_t isar_get_lc3plus_bitrate( * *------------------------------------------------------------------------*/ +/*! r: LC3plus bitrate */ int32_t isar_get_lc3plus_bitrate( - const int32_t SplitRendBitRate, - ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, + const int32_t SplitRendBitRate, /* i : ISAR bitrate */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ const int16_t split_prerender_frame_size_ms ) { if ( poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) @@ -623,8 +618,10 @@ int32_t isar_get_lc3plus_bitrate( * *------------------------------------------------------------------------*/ +/*! r: LC3plus codec bitrate ID */ int8_t isar_get_lc3plus_bitrate_id( - const int32_t SplitRendBitRate ) + const int32_t SplitRendBitRate /* i : ISAR bitrate */ +) { switch ( SplitRendBitRate ) { @@ -664,10 +661,12 @@ int8_t isar_get_lc3plus_bitrate_id( * *------------------------------------------------------------------------*/ +/*! r: LC3plus bitrate */ int32_t isar_get_lc3plus_size_from_id( const int8_t SplitRendBitRateId, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const int16_t split_prerender_frame_size_ms ) + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, /* i : ISAR pose correction mode */ + const int16_t split_prerender_frame_size_ms /* i : ISAR frame length in ms */ +) { int32_t bitrate; @@ -712,7 +711,6 @@ int32_t isar_get_lc3plus_size_from_id( } #endif - /*------------------------------------------------------------------------- * Function isar_split_rend_validate_config() * @@ -720,8 +718,9 @@ int32_t isar_get_lc3plus_size_from_id( *------------------------------------------------------------------------*/ ivas_error isar_split_rend_validate_config( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, - const int16_t is_pcm_out ) + const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renderer config */ + const int16_t pcm_out_flag /* i : flag to indicate PCM output */ +) { /* Valid DOF range is 0-3 */ if ( pSplitRendConfig->dof < 0 || pSplitRendConfig->dof > 3 ) @@ -756,7 +755,7 @@ ivas_error isar_split_rend_validate_config( } /* Validate bitrate */ - if ( is_pcm_out == 0 ) + if ( pcm_out_flag == 0 ) { switch ( pSplitRendConfig->splitRendBitRate ) { @@ -861,10 +860,9 @@ void isar_split_rend_get_quant_params( int16_t pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS const int16_t ro_flag, -#endif int16_t *num_quant_strats -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - , +#else + int16_t *num_quant_strats, int16_t *num_complex_bands #endif ) @@ -936,6 +934,7 @@ void isar_split_rend_get_quant_params( return; } + #ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS /*------------------------------------------------------------------------- * Function isar_renderSplitGetRot_axisNumBits() @@ -955,9 +954,11 @@ int16_t isar_renderSplitGetRot_axisNumBits( { num_bits = 0; } + return num_bits; } + /*------------------------------------------------------------------------- * Function isar_renderSplitGetRot_axisFromCode() * @@ -993,6 +994,7 @@ ISAR_SPLIT_REND_ROT_AXIS isar_renderSplitGetRot_axisFromCode( return rot_axis; } + /*------------------------------------------------------------------------- * Function isar_renderSplitGetCodeFromRot_axis() * @@ -1005,6 +1007,7 @@ int16_t isar_renderSplitGetCodeFromRot_axis( int16_t *num_bits ) { int16_t code = 0; + if ( dof == 1 ) { code = (int16_t) rot_axis; @@ -1030,6 +1033,7 @@ int16_t isar_renderSplitGetCodeFromRot_axis( } #endif + /*------------------------------------------------------------------------- * Function isar_renderSplitGetMultiBinPoseData() * @@ -1037,9 +1041,10 @@ int16_t isar_renderSplitGetCodeFromRot_axis( *------------------------------------------------------------------------*/ void isar_renderSplitGetMultiBinPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const ISAR_SPLIT_REND_ROT_AXIS rot_axis ) + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ +) { int16_t pos_idx, num_yaw_poses, num_pitch_poses, num_roll_poses; const float *relative_yaw_angles; @@ -1180,8 +1185,9 @@ void isar_renderSplitGetMultiBinPoseData( *------------------------------------------------------------------------*/ void isar_renderSplitUpdateNoCorrectionPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +) { pMultiBinPoseData->num_poses = 1; assert( pSplit_rend_config->dof == 0 ); @@ -1200,7 +1206,8 @@ void isar_renderSplitUpdateNoCorrectionPoseData( *------------------------------------------------------------------------*/ void isar_init_multi_bin_pose_data( - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData ) + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData /* i/o: pose correction data handle */ +) { int16_t pos_idx; @@ -1218,7 +1225,14 @@ void isar_init_multi_bin_pose_data( return; } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS +/*------------------------------------------------------------------------- + * Function isar_framesize_to_ms() + * + * + *------------------------------------------------------------------------*/ + ivas_error isar_framesize_to_ms( const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ int16_t *ms /* o : frame size in ms */ @@ -1253,7 +1267,7 @@ ivas_error isar_framesize_to_ms( ivas_error isar_split_rend_choose_default_codec( ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ + int16_t *pIsar_frame_size_ms, /* i/o: pointer to ISAR frame size setting */ #endif 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 */ @@ -1288,15 +1302,18 @@ ivas_error isar_split_rend_choose_default_codec( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unknown split codec value" ); } } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - if ( *pIsar_frame_size_ms == 0 ) /* isar frame size hasn't been set yet - use default for current configuration */ + if ( *pIsar_frame_size_ms == 0 ) /* ISAR frame size hasn't been set yet - use default for current configuration */ { *pIsar_frame_size_ms = 20; } #endif + return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * Function get_bit() * diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index 627099d90afd3b5db987630b4953028ec529f486..dd527afaf78e0718e31e3a7939078d11b70f0b6a 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -58,6 +58,103 @@ * ISAR post rend structs *-------------------------------------------------------------------*/ +/* binaural split rendering head rotation data structure */ +typedef struct ivas_binaural_head_rot_split_rendering_md_struct +{ + float pred_mat_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float pred_mat_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float gd; + float gd2; + int16_t pred_mat_re_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t pred_mat_im_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + int16_t gd_idx; + int16_t gd2_idx; + +} BIN_HR_SPLIT_REND_MD, *BIN_HR_SPLIT_REND_MD_HANDLE; + +typedef struct ivas_split_rend_huffman_cfg_t +{ + const int32_t *codebook; + int16_t min_len; + int16_t max_len; + int16_t sym_len; + +} ivas_split_rend_huffman_cfg_t; + +typedef struct ivas_binaural_head_rot_split_rendering_huff_struct +{ + ivas_split_rend_huffman_cfg_t pred[2]; + int16_t pred_idx_trav[2][ISAR_SPLIT_REND_PRED_63QUANT_PNTS]; + int16_t pred_base2_code_len[2]; + ivas_split_rend_huffman_cfg_t pred_roll; + int16_t pred_roll_idx_trav[ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS]; + int16_t pred_roll_base2_code_len; + ivas_split_rend_huffman_cfg_t gd; + int16_t gd_base2_code_len; + int16_t gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + ivas_split_rend_huffman_cfg_t p_gd; + int16_t p_gd_base2_code_len; + int16_t p_gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + ivas_split_rend_huffman_cfg_t p_gd_diff; + int16_t p_gd_diff_base2_code_len; + int16_t p_gd_diff_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; + +} BIN_HR_SPLIT_REND_HUFF, *BIN_HR_SPLIT_REND_HUFF_HANDLE; + +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG +typedef struct ivas_binaural_head_rot_split_post_rendering_struct +{ + BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; + IVAS_QUATERNION QuaternionsPre[MAX_PARAM_SPATIAL_SUBFRAMES]; + int16_t low_Res; + + float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; + BIN_HR_SPLIT_REND_HUFF huff_cfg; + float mixer_mat_re[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float mixer_mat_im[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + float gd_mem[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS]; + int16_t cf_flag; + HANDLE_CLDFB_FILTER_BANK cldfbAna[BINAURAL_CHANNELS]; + HANDLE_CLDFB_FILTER_BANK cldfbSyn[BINAURAL_CHANNELS]; + HANDLE_CLDFB_FILTER_BANK cldfbSynReconsBinDec[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS]; + +} BIN_HR_SPLIT_POST_REND, *BIN_HR_SPLIT_POST_REND_HANDLE; +#endif + +typedef struct ivas_binaural_head_rot_split_pre_rendering_struct +{ + BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES - 1][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; + float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; + BIN_HR_SPLIT_REND_HUFF huff_cfg; +#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG + HANDLE_CLDFB_FILTER_BANK cldfbSynRotBinDec[MAX_HEAD_ROT_POSES + 1][BINAURAL_CHANNELS]; +#endif + +#ifdef SPLIT_POSE_CORRECTION_DEBUG + BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend; +#endif + +} BIN_HR_SPLIT_PRE_REND, *BIN_HR_SPLIT_PRE_REND_HANDLE; + +typedef struct +{ + float Cldfb_Prev_BinReal[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; + float Cldfb_Prev_BinImag[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; + float xf_bet[2][CLDFB_NO_CHANNELS_MAX][CLDFB_PLC_XF]; + +} CLDFB_PLC, *CLDFB_PLC_HANDLE; + +typedef struct +{ + CLDFB_PLC CldfbPLC_state; + int16_t prev_bfi; + int16_t bf_count; + int16_t iNumSubSets; + +} SPLIT_REND_PLC_STRUCT, *SPLIT_REND_PLC_HANDLE; + typedef struct { int8_t headRotEnabled; @@ -141,10 +238,6 @@ typedef struct isar_binaural_head_rot_split_pre_rendering_struct } ISAR_BIN_HR_SPLIT_PRE_REND, *ISAR_BIN_HR_SPLIT_PRE_REND_HANDLE; -/*----------------------------------------------------------------------------------* - * Output configuration for renderer (e.g. DirAC, MASA, Binaural Renderer...) - *----------------------------------------------------------------------------------*/ - typedef struct isar_binaural_head_rot_split_rendering_lcld_enc_struct { void *pLcld_enc; diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 12fc8e6e43991f911abf3582958b5e24fa9c78f5..53595aa88a7c5e486b42df5555f43fbef983e447 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -33,7 +33,6 @@ #include "options.h" #include "lib_isar_post_rend.h" -#include "isar_stat.h" #include "isar_prot.h" #include "prot.h" #include "ivas_prot.h" @@ -61,6 +60,7 @@ int32_t ISAR_POST_REND_void_func( void ) * Local types *-------------------------------------------------------------------*/ +#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS /* EFAP wrapper to simplify writing panning gains to a vector that includes LFE channels */ typedef struct { @@ -69,6 +69,7 @@ typedef struct const LSSETUP_CUSTOM_STRUCT *pCustomLsSetup; /* Pointer to main custom LS struct from renderer handle - doesn't need freeing */ } EFAP_WRAPPER; +#endif /* Lightweight helper struct that gathers all information required for rendering * any config to any other config. Used to simplify signatures of rendering functions. * @@ -92,7 +93,7 @@ typedef struct #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRenderConfig; #endif -} rendering_context; +} rendering_context_isar; /* Common base for input structs */ typedef struct @@ -101,13 +102,13 @@ typedef struct ISAR_POST_REND_InputId id; IVAS_REND_AudioBuffer inputBuffer; float gain; /* Linear, not in dB */ - rendering_context ctx; + rendering_context_isar ctx; int32_t numNewSamplesPerChannel; /* Used to keep track how much new audio was fed before rendering current frame */ -} input_base; +} input_base_isar; typedef struct { - input_base base; + input_base_isar base; ISAR_SPLIT_POST_REND_WRAPPER splitPostRendWrapper; float *bufferData; int16_t numCachedSamples; /* Number of decoded samples in bufferData that have not yet been played out */ @@ -137,14 +138,17 @@ struct ISAR_POST_REND int16_t num_subframes; }; + /*-------------------------------------------------------------------* - * getAudioConfigType() + * ISAR_POST_REND_AudioConfigType() * * *-------------------------------------------------------------------*/ +/*! r: ISAR audio type */ ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( - const AUDIO_CONFIG config ) + const AUDIO_CONFIG config /* i : audio configuration */ +) { ISAR_POST_REND_AudioConfigType type; @@ -164,10 +168,6 @@ ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( } -/*-------------------------------------------------------------------* - * Local function prototypes - *-------------------------------------------------------------------*/ - /*-------------------------------------------------------------------* * Local functions *-------------------------------------------------------------------*/ @@ -185,6 +185,7 @@ static ivas_error allocateInputBaseBufferData( return IVAS_ERR_OK; } + static void freeInputBaseBufferData( float **data ) { @@ -226,6 +227,7 @@ static void convertBitsBufferToInternalBitsBuff( return; } + static void convertInternalBitsBuffToBitsBuffer( ISAR_POST_REND_BitstreamBuffer *hOutBits, const ISAR_SPLIT_REND_BITS_DATA bits ) @@ -245,6 +247,7 @@ static void convertInternalBitsBuffToBitsBuffer( return; } + static void copyBufferTo2dArray( const IVAS_REND_AudioBuffer buffer, float array[][L_FRAME48k] ) @@ -267,6 +270,7 @@ static void copyBufferTo2dArray( return; } + static void accumulate2dArrayToBuffer( float array[][L_FRAME48k], const IVAS_REND_AudioBuffer *buffer ) @@ -286,13 +290,14 @@ static void accumulate2dArrayToBuffer( return; } +#ifndef DISABLE_LIMITER + /*-------------------------------------------------------------------* * limitRendererOutput() * * In-place saturation control for multichannel buffers with adaptive release time *-------------------------------------------------------------------*/ -#ifndef DISABLE_LIMITER /*! r: number of clipped output samples */ static int32_t limitRendererOutput( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ @@ -337,8 +342,8 @@ static int32_t limitRendererOutput( return numClipping; } -#endif +#endif /*-------------------------------------------------------------------* * validateOutputSampleRate() @@ -433,10 +438,10 @@ static ivas_error initHeadRotation( static void initRendInputBase( - input_base *inputBase, + input_base_isar *inputBase, const AUDIO_CONFIG inConfig, const IVAS_REND_InputId id, - const rendering_context rendCtx, + const rendering_context_isar rendCtx, float *dataBuf, const int16_t dataBufSize ) { @@ -458,10 +463,10 @@ static void initRendInputBase( } -static rendering_context getRendCtx( +static rendering_context_isar getRendCtx( ISAR_POST_REND_HANDLE hIvasRend ) { - rendering_context ctx; + rendering_context_isar ctx; /* Note: when refactoring this, always take the ADDRESS of a member of the * renderer struct, so that the context stores a POINTER to the member, even @@ -483,7 +488,7 @@ static ivas_error getRendInputNumChannels( int16_t *numInChannels ) { /* Using a void pointer for this function to be reusable for any input type (input_ism, input_mc, input_sba). - Assumptions: - input_base is always the first member in the input struct */ + Assumptions: - input_base_isar is always the first member in the input struct */ (void) rendInput; *numInChannels = 2; @@ -503,7 +508,7 @@ static ivas_error updateSplitPostRendPanGains( ) { ivas_error error; - rendering_context rendCtx; + rendering_context_isar rendCtx; LC3PLUS_CONFIG config; int16_t iNumBlocksPerFrame, iNumLCLDIterationsPerFrame; @@ -561,8 +566,7 @@ static ivas_error updateSplitPostRendPanGains( } else if ( hRendCfg->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) { - if ( ( error = ISAR_LC3PLUS_DEC_Open( config, - &inputSplitPostRend->splitPostRendWrapper.hLc3plusDec ) ) != IVAS_ERR_OK ) + if ( ( error = ISAR_LC3PLUS_DEC_Open( config, &inputSplitPostRend->splitPostRendWrapper.hLc3plusDec ) ) != IVAS_ERR_OK ) { return error; } @@ -589,7 +593,7 @@ static ivas_error setRendInputActiveSplitPostRend( ) { ivas_error error; - rendering_context rendCtx; + rendering_context_isar rendCtx; AUDIO_CONFIG outConfig; input_split_post_rend *inputSplitPostRend; @@ -605,12 +609,11 @@ static ivas_error setRendInputActiveSplitPostRend( initRendInputBase( &inputSplitPostRend->base, inConfig, id, rendCtx, inputSplitPostRend->bufferData, MAX_CLDFB_BIN_BUFFER_LENGTH ); inputSplitPostRend->numCachedSamples = 0; - if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - num_subframes +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg ) ) != IVAS_ERR_OK ) +#else + if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg, num_subframes ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -622,7 +625,7 @@ static ivas_error setRendInputActiveSplitPostRend( static void clearInputSplitRend( input_split_post_rend *inputSplitRend ) { - rendering_context rendCtx; + rendering_context_isar rendCtx; rendCtx = inputSplitRend->base.ctx; @@ -656,13 +659,13 @@ static void clearInputSplitRend( *------------------------------------------------------------------------*/ ivas_error ISAR_POST_REND_open( - ISAR_POST_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ - const int32_t outputSampleRate, /* i : output sampling rate */ - const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ - const bool asHrtfBinary, /* i : load hrtf binary file */ - const int16_t nonDiegeticPan, /* i : non-diegetic object flag */ - const float nonDiegeticPanGain, /* i : non-diegetic panning gain */ - const int16_t num_subframes /* i : number of subframes */ + ISAR_POST_REND_HANDLE *phIvasRend, /* i/o: Pointer to renderer handle */ + const int32_t outputSampleRate, /* i : output sampling rate */ + const IVAS_AUDIO_CONFIG outConfig, /* i : output audio config */ + const bool asHrtfBinary, /* i : load hrtf binary file */ + const int16_t nonDiegeticPan, /* i : non-diegetic object flag */ + const float nonDiegeticPanGain, /* i : non-diegetic panning gain */ + const int16_t num_subframes /* i : number of subframes */ ) { int16_t i; @@ -741,8 +744,8 @@ ivas_error ISAR_POST_REND_open( *-------------------------------------------------------------------*/ ivas_error ISAR_POST_REND_NumOutChannels( - ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ - int16_t *numOutChannels /* o : number of output channels */ + ISAR_POST_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + int16_t *numOutChannels /* o : number of output channels */ ) { /* Validate function arguments */ @@ -775,7 +778,7 @@ static ivas_error getInputById( { int32_t inputIndex; IVAS_REND_AudioConfigType configType; - input_base *pInputBase; + input_base_isar *pInputBase; /* Reverse makeInputId() */ inputIndex = ( inputId & 0xFF ) - 1; @@ -811,6 +814,7 @@ static ivas_error getInputById( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * ISAR_POST_REND_SetInputGain() * @@ -823,7 +827,7 @@ ivas_error ISAR_POST_REND_SetInputGain( const float gain /* i : linear gain (not in dB) */ ) { - input_base *inputBase; + input_base_isar *inputBase; ivas_error error; /* Validate function arguments */ @@ -843,6 +847,7 @@ ivas_error ISAR_POST_REND_SetInputGain( return IVAS_ERR_OK; } + static ivas_error getConstInputById( ISAR_POST_REND_CONST_HANDLE hIvasRend, const ISAR_POST_REND_InputId inputId, @@ -850,7 +855,7 @@ static ivas_error getConstInputById( { int32_t inputIndex; IVAS_REND_AudioConfigType configType; - const input_base *pInputBase; + const input_base_isar *pInputBase; /* Reverse makeInputId() */ inputIndex = ( inputId & 0xFF ) - 1; @@ -896,21 +901,21 @@ static ivas_error findFreeInputSlot( /* Using a void pointer and a separately provided size is a hack for this function to be reusable for arrays of any input type (input_ism, input_mc, input_sba, input_masa). Assumptions: - - input_base is always the first member in the input struct + - input_base_isar is always the first member in the input struct - provided size is correct */ int32_t i; bool canAddInput; const uint8_t *pByte; - const input_base *pInputBase; + const input_base_isar *pInputBase; canAddInput = false; /* Find first unused input in array */ for ( i = 0, pByte = inputs; i < maxInputs; ++i, pByte += inputStructSize ) { - pInputBase = (const input_base *) pByte; + pInputBase = (const input_base_isar *) pByte; if ( pInputBase->inConfig == IVAS_AUDIO_CONFIG_INVALID ) { @@ -945,12 +950,12 @@ ivas_error ISAR_POST_REND_AddInput( int32_t maxNumInputsOfType; void *inputsArray; int32_t inputStructSize; - ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, ISAR_SPLIT_REND_CONFIG_DATA * -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - int16_t + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, ISAR_SPLIT_REND_CONFIG_DATA * ); +#else + ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, ISAR_SPLIT_REND_CONFIG_DATA *, int16_t ); #endif - ); int32_t inputIndex; /* Validate function arguments */ @@ -978,12 +983,12 @@ ivas_error ISAR_POST_REND_AddInput( } *inputId = makeInputId( inConfig, inputIndex ); - if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, &hIvasRend->splitRenderConfig -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - hIvasRend->num_subframes + +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS + if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, &hIvasRend->splitRenderConfig ) ) != IVAS_ERR_OK ) +#else + if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, &hIvasRend->splitRenderConfig, hIvasRend->num_subframes ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1005,7 +1010,7 @@ ivas_error ISAR_POST_REND_GetInputNumChannels( ) { ivas_error error; - const input_base *pInput; + const input_base_isar *pInput; /* Validate function arguments */ if ( hIvasRend == NULL || numChannels == NULL ) @@ -1096,7 +1101,7 @@ ivas_error ISAR_POST_REND_FeedInputAudio( ) { ivas_error error; - input_base *inputBase; + input_base_isar *inputBase; int16_t numInputChannels; int16_t cldfb2tdSampleFact; @@ -1231,6 +1236,7 @@ int16_t ISAR_POST_REND_GetRenderConfig( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * ISAR_POST_REND_FeedSplitBinauralBitstream() * @@ -1244,7 +1250,7 @@ ivas_error ISAR_POST_REND_FeedSplitBinauralBitstream( ) { ivas_error error; - input_base *inputBase; + input_base_isar *inputBase; input_split_post_rend *inputSplitPostRend; /* Validate function arguments */ @@ -1321,8 +1327,8 @@ ivas_error ISAR_POST_REND_SetHeadRotation( *-------------------------------------------------------------------*/ ivas_error ISAR_POST_REND_SetSplitRendBFI( - ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const int16_t bfi /* i: BFI flag */ + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const int16_t bfi /* i : BFI flag */ ) { hIvasRend->splitRendBFI = bfi; @@ -1335,7 +1341,6 @@ ivas_error ISAR_POST_REND_SetSplitRendBFI( * Local functions *-------------------------------------------------------------------*/ - static ivas_error splitBinLc3plusDecode( ISAR_SPLIT_POST_REND_WRAPPER *hSplitBin, ISAR_SPLIT_REND_BITS_HANDLE bits, @@ -1368,6 +1373,7 @@ static ivas_error splitBinLc3plusDecode( { ++bits->bits_read; } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* Size is in bytes */ assert( ( bits->bits_written - bits->bits_read ) % 8 == 0 ); @@ -1446,8 +1452,8 @@ static ivas_error renderSplitBinauralWithPostRot( { ivas_frame_duration_us = splitBinInput->splitPostRendWrapper.hLc3plusDec->config.isar_frame_duration_us; } -#endif +#endif iNumLCLDIterationsPerFrame = 1; iNumBlocksPerFrame = CLDFB_NO_COL_MAX; if ( splitBinInput->splitPostRendWrapper.hSplitBinLCLDDec != NULL ) @@ -1491,6 +1497,7 @@ static ivas_error renderSplitBinauralWithPostRot( { isPostRendInputCldfb = 1; } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS numSamplesPerChannelCacheSize = (int16_t) ( *splitBinInput->base.ctx.pOutSampleRate * bits.isar_frame_size_ms / 1000 ) - outBufNumSamplesPerChannel; #else @@ -1540,11 +1547,11 @@ static ivas_error renderSplitBinauralWithPostRot( } else { - if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - bits.pose_correction, + if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, bits.pose_correction, SplitRendBFI ) ) != IVAS_ERR_OK ) +#else + if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer, SplitRendBFI ) ) != IVAS_ERR_OK ) #endif - SplitRendBFI ) ) != IVAS_ERR_OK ) { return error; } @@ -1672,6 +1679,7 @@ static ivas_error renderSplitBinauralWithPostRot( return error; } + static ivas_error renderInputSplitBin( input_split_post_rend *splitBinInput, const AUDIO_CONFIG outConfig, @@ -1703,6 +1711,7 @@ static ivas_error renderInputSplitBin( return error; } + static ivas_error renderActiveInputsSplitBin( ISAR_POST_REND_HANDLE hIvasRend, IVAS_REND_AudioBuffer outAudio ) @@ -1797,6 +1806,7 @@ ivas_error ISAR_POST_REND_getSamples( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * ISAR_POST_REND_GetSplitBinauralSamples() * @@ -1804,8 +1814,8 @@ ivas_error ISAR_POST_REND_getSamples( *-------------------------------------------------------------------*/ ivas_error ISAR_POST_REND_GetSplitBinauralSamples( - ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ bool *needNewFrame ) { ivas_error error; @@ -1854,15 +1864,22 @@ void ISAR_POST_REND_Close( } +/*-------------------------------------------------------------------* + * ISAR_REND_SetSplitRendBitstreamHeader() + * + * + *-------------------------------------------------------------------*/ + ivas_error ISAR_REND_SetSplitRendBitstreamHeader( - ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ - const ISAR_SPLIT_REND_CODEC codec, /* o: codec setting */ - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o: pose correction mode */ - const int16_t codec_frame_size_ms /* i: codec frame size setting */ + ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + const ISAR_SPLIT_REND_CODEC codec, /* o : codec setting */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o : pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - const int16_t isar_frame_size_ms, /* i: isar codec frame size setting */ - const int16_t lc3plus_highres /* i: LC3plus Hig-Res setting. Ignored if codec is not LC3plus */ + const int16_t codec_frame_size_ms, /* i : codec frame size setting */ + const int16_t isar_frame_size_ms, /* i : ISAR codec frame size setting */ + const int16_t lc3plus_highres /* i : LC3plus Hig-Res setting. Ignored if codec is not LC3plus */ +#else + const int16_t codec_frame_size_ms /* i : codec frame size setting */ #endif ) { @@ -1870,6 +1887,7 @@ ivas_error ISAR_REND_SetSplitRendBitstreamHeader( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + hIvasRend->splitRenderConfig.codec = codec; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hIvasRend->splitRenderConfig.isar_frame_size_ms = isar_frame_size_ms; @@ -1879,6 +1897,7 @@ ivas_error ISAR_REND_SetSplitRendBitstreamHeader( #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hIvasRend->splitRenderConfig.lc3plus_highres = lc3plus_highres; #endif + return IVAS_ERR_OK; } @@ -1895,8 +1914,15 @@ int32_t ISAR_POST_REND_GetNoCLipping( return hIvasRend->numClipping; } + +/*-------------------------------------------------------------------* + * ISAR_POST_REND_GetCntFramesLimited() + * + * + *-------------------------------------------------------------------*/ + int32_t ISAR_POST_REND_GetCntFramesLimited( - ISAR_POST_REND_CONST_HANDLE hIvasRend ) + ISAR_POST_REND_HANDLE hIvasRend ) { if ( hIvasRend->hLimiter == NULL ) { diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h index 7c06895e689c2412ce69baa182445268025bab0a..f219e34075c4737275f02cf601d82999b412bd61 100644 --- a/lib_isar/lib_isar_post_rend.h +++ b/lib_isar/lib_isar_post_rend.h @@ -44,14 +44,14 @@ int32_t ISAR_POST_REND_void_func( void ); #else /*---------------------------------------------------------------------* - * Renderer constants + * ISAR post-renderer constants *---------------------------------------------------------------------*/ #define RENDERER_MAX_ISAR_MD_INPUTS 1 #define RENDERER_MAX_BIN_INPUTS 1 /*---------------------------------------------------------------------* - * Renderer structures + * ISAR post-renderer structures *---------------------------------------------------------------------*/ typedef struct @@ -101,7 +101,7 @@ typedef enum _ISAR_POST_REND_COMPLEXITY_LEVEL /* clang-format off */ /*----------------------------------------------------------------------------------* - * Renderer function prototypes + * ISAR post-renderer function prototypes *----------------------------------------------------------------------------------*/ /* Functions to be called before rendering */ @@ -187,13 +187,13 @@ ivas_error ISAR_POST_REND_SetHeadRotation( ivas_error ISAR_POST_REND_SetSplitRendBFI( ISAR_POST_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const int16_t bfi /* i: BFI flag */ + const int16_t bfi /* i : BFI flag */ ); ivas_error ISAR_POST_REND_getSamples( ISAR_POST_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 */ ); /* Functions to be called after rendering */ @@ -204,23 +204,24 @@ void ISAR_POST_REND_Close( ivas_error ISAR_REND_SetSplitRendBitstreamHeader( ISAR_POST_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ - const ISAR_SPLIT_REND_CODEC codec, /* o: codec setting */ - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o: pose correction mode */ - const int16_t codec_frame_size_ms /* i: codec frame size setting */ + const ISAR_SPLIT_REND_CODEC codec, /* o : codec setting */ + const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o : pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - const int16_t isar_frame_size_ms, /* i: isar frame size setting */ - const int16_t lc3plus_highres /* i: LC3plus Hig-Res setting. Ignored if codec is not LC3plus */ + const int16_t codec_frame_size_ms, /* i : codec frame size setting */ + const int16_t isar_frame_size_ms, /* i : ISAR codec frame size setting */ + const int16_t lc3plus_highres /* i : LC3plus Hig-Res setting. Ignored if codec is not LC3plus */ +#else + const int16_t codec_frame_size_ms /* i : codec frame size setting */ #endif ); #ifdef DEBUGGING int32_t ISAR_POST_REND_GetNoCLipping( - ISAR_POST_REND_HANDLE hIvasRend /* i : Renderer handle */ + ISAR_POST_REND_HANDLE hIvasRend /* i : Renderer handle */ ); int32_t ISAR_POST_REND_GetCntFramesLimited( - ISAR_POST_REND_CONST_HANDLE hIvasRend /* i : Renderer handle */ + ISAR_POST_REND_HANDLE hIvasRend /* i : Renderer handle */ ); #endif diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 15e08660e5a0e517388f4d7e1dd323a6109e7955..c0b5e06f6b2ba4447bd6f8be0ccaa32b1da365ef 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -54,22 +54,6 @@ int32_t ISAR_PRE_REND_void_func( void ) #else -/*-------------------------------------------------------------------* - * Local constants - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * Local types - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * Local function prototypes - *-------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------* - * Local functions - *-------------------------------------------------------------------*/ - /*------------------------------------------------------------------------- * Function ISAR_PRE_REND_open() * @@ -77,37 +61,28 @@ int32_t ISAR_PRE_REND_void_func( void ) *------------------------------------------------------------------------*/ ivas_error ISAR_PRE_REND_open( - SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ - ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ - const int32_t output_Fs, /* i: output sampling rate */ - const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ - const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ + ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i : Flag to indicate PCM output */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i: IVAS frame size */ + const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i : IVAS frame size */ #else - const int16_t num_subframes, /* i: number of subframes */ + const int16_t num_subframes, /* i : number of subframes */ #endif - const int16_t mixed_td_cldfb_flag /* i: Flag to indicate combined TD and CLDFB input */ + const int16_t mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ ) { ivas_error error, ch, num_ch; uint8_t isCldfbNeeded = 0; - int16_t cldfb_in_flag_local = cldfb_in_flag; - if ( ( error = isar_split_rend_choose_default_codec( &( pSplitRendConfig->codec ), -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - &pSplitRendConfig->isar_frame_size_ms, -#endif - &pSplitRendConfig->codec_frame_size_ms, - cldfb_in_flag_local, - pcm_out_flag, (int16_t) #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - ivas_frame_size + if ( ( error = isar_split_rend_choose_default_codec( &( pSplitRendConfig->codec ), &pSplitRendConfig->isar_frame_size_ms, &pSplitRendConfig->codec_frame_size_ms, cldfb_in_flag_local, pcm_out_flag, (int16_t) ivas_frame_size ) ) != IVAS_ERR_OK ) #else - num_subframes + if ( ( error = isar_split_rend_choose_default_codec( &( pSplitRendConfig->codec ), &pSplitRendConfig->codec_frame_size_ms, cldfb_in_flag_local, pcm_out_flag, (int16_t) num_subframes ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -158,9 +133,7 @@ ivas_error ISAR_PRE_REND_open( for ( ch = 0; ch < num_ch; ch++ ) { - if ( ( error = openCldfb( &( hSplitBinRend->hCldfbHandles->cldfbAna[ch] ), - CLDFB_ANALYSIS, - output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( hSplitBinRend->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } @@ -177,12 +150,11 @@ ivas_error ISAR_PRE_REND_open( if ( pSplitRendConfig->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - if ( ( error = isar_splitBinPreRendOpen( &hSplitBinRend->hBinHrSplitPreRend, &hSplitBinRend->multiBinPoseData #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - , - OutSampleRate + if ( ( error = isar_splitBinPreRendOpen( &hSplitBinRend->hBinHrSplitPreRend, &hSplitBinRend->multiBinPoseData, OutSampleRate ) ) != IVAS_ERR_OK ) +#else + if ( ( error = isar_splitBinPreRendOpen( &hSplitBinRend->hBinHrSplitPreRend, &hSplitBinRend->multiBinPoseData ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -192,13 +164,11 @@ ivas_error ISAR_PRE_REND_open( { if ( pSplitRendConfig->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) { - if ( ( error = split_renderer_open_lc3plus( hSplitBinRend, pSplitRendConfig, output_Fs, #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - ivas_frame_size + if ( ( error = split_renderer_open_lc3plus( hSplitBinRend, pSplitRendConfig, output_Fs, ivas_frame_size ) ) != IVAS_ERR_OK ) #else - num_subframes + if ( ( error = split_renderer_open_lc3plus( hSplitBinRend, pSplitRendConfig, output_Fs, num_subframes ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -218,6 +188,7 @@ ivas_error ISAR_PRE_REND_open( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * Function ISAR_PRE_REND_close() * @@ -225,8 +196,8 @@ ivas_error ISAR_PRE_REND_open( *------------------------------------------------------------------------*/ void ISAR_PRE_REND_close( - SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ - IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renderer handle */ + IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ ) { int16_t i; @@ -297,6 +268,7 @@ void ISAR_PRE_REND_close( return; } + /*-------------------------------------------------------------------------* * ISAR_PRE_REND_GetMultiBinPoseData() * @@ -304,14 +276,17 @@ void ISAR_PRE_REND_close( *-------------------------------------------------------------------------*/ void ISAR_PRE_REND_GetMultiBinPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i: Split renderer pre-renerer config */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ - const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i: Rotation axis */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : Rotation axis */ ) { isar_renderSplitGetMultiBinPoseData( pSplit_rend_config, pMultiBinPoseData, rot_axis ); + + return; } + /*------------------------------------------------------------------------- * Function ISAR_PRE_REND_MultiBinToSplitBinaural() * @@ -319,23 +294,23 @@ void ISAR_PRE_REND_GetMultiBinPoseData( *------------------------------------------------------------------------*/ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ - const IVAS_QUATERNION headPosition, /* i: head rotation QUATERNION */ - const int32_t SplitRendBitRate, /* i: Split renderer bitrate */ - ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const int32_t SplitRendBitRate, /* i : Split renderer bitrate */ + ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - const int16_t isar_frame_size_ms, /* i: ISAR framesize */ + const int16_t isar_frame_size_ms, /* i : ISAR framesize */ #endif - int16_t codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ - ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits struct handle */ - float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ - float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ - const int16_t max_bands, /* i: CLDFB bands */ - float *output[], /* i/o: PCM in/out buffer */ - const int16_t low_res_pre_rend_rot, /* i: low time resolution pre-renderer flag */ - const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ - const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ - const int16_t ro_md_flag /* i: Flag to indicate real only metadata for yaw */ + int16_t codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits struct handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ + const int16_t max_bands, /* i : CLDFB bands */ + float *output[], /* i/o: PCM in/out buffer */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i : Flag to indicate PCM output */ + const int16_t ro_md_flag /* i : Flag to indicate real only metadata for yaw */ ) { ivas_error error; @@ -358,19 +333,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( { /*TD input*/ /*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/ - error = isar_renderMultiTDBinToSplitBinaural( hSplitBin, - headPosition, - SplitRendBitRate, #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - isar_frame_size_ms, + error = isar_renderMultiTDBinToSplitBinaural( hSplitBin, headPosition, SplitRendBitRate, isar_frame_size_ms, codec_frame_size_ms, pBits, max_bands, output, low_res_pre_rend_rot, pcm_out_flag, ro_md_flag ); +#else + error = isar_renderMultiTDBinToSplitBinaural( hSplitBin, headPosition, SplitRendBitRate, codec_frame_size_ms, pBits, max_bands, output, low_res_pre_rend_rot, pcm_out_flag, ro_md_flag ); #endif - codec_frame_size_ms, - pBits, - max_bands, - output, - low_res_pre_rend_rot, - pcm_out_flag, - ro_md_flag ); pop_wmops(); return error; @@ -391,6 +358,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( #ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS actual_md_bits = pBits->bits_written; + #endif isar_rend_CldfbSplitPreRendProcess( hSplitBin->hBinHrSplitPreRend, headPosition, &hSplitBin->multiBinPoseData, Cldfb_In_BinReal, Cldfb_In_BinImag, pBits, target_md_bits, low_res_pre_rend_rot, ro_md_flag ); @@ -446,6 +414,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( #else available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; #endif + if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, available_bits, output ) ) != IVAS_ERR_OK ) #else if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, output ) ) != IVAS_ERR_OK ) diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index a1e658ac123ba0dd78dbec8b1e75be99206e2a7e..0cfbde0909d7d5f54c11dcd26346e1921dd49480 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -42,50 +42,56 @@ int32_t ISAR_PRE_REND_void_func( void ); #else +/* clang-format off */ +/*----------------------------------------------------------------------------------* + * ISAR pre-renderer function prototypes + *----------------------------------------------------------------------------------*/ + ivas_error ISAR_PRE_REND_open( - SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ - ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ - const int32_t output_Fs, /* i: output sampling rate */ - const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ - const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ + ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i : Flag to indicate PCM output */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i: IVAS frame size */ + const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i : IVAS frame size */ #else - const int16_t num_subframes, /* i: number of subframes */ + const int16_t num_subframes, /* i : number of subframes */ #endif - const int16_t mixed_td_cldfb_flag /* i: Flag to indicate combined TD and CLDFB input */ + const int16_t mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ ); void ISAR_PRE_REND_close( - SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ - IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ + SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renderer handle */ + IVAS_REND_AudioBuffer *pSplitRendEncBuffer /* i/o: Split renderer data buffer */ ); void ISAR_PRE_REND_GetMultiBinPoseData( - const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i: Split renderer pre-renerer config */ - MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ - const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i: Rotation axis */ + const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, /* i : Split renderer pre-renderer config */ + MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : Rotation axis */ ); ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( - SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ - const IVAS_QUATERNION headPosition, /* i: head rotation QUATERNION */ - const int32_t SplitRendBitRate, /* i: Split renderer bitrate */ - ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ + SPLIT_REND_WRAPPER *hSplitBin, /* i/o: Split renderer pre-renerer handle */ + const IVAS_QUATERNION headPosition, /* i : head rotation QUATERNION */ + const int32_t SplitRendBitRate, /* i : Split renderer bitrate */ + ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - const int16_t isar_frame_size_ms, /* i: ISAR framesize */ + const int16_t isar_frame_size_ms, /* i : ISAR framesize */ #endif - int16_t codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ - ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits struct handle */ - float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ - float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ - const int16_t max_bands, /* i: CLDFB bands */ - float *output[], /* i/o: PCM in/out buffer */ - const int16_t low_res_pre_rend_rot, /* i: low time resolution pre-renderer flag */ - const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ - const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ - const int16_t ro_md_flag /* i: Flag to indicate real only metadata for yaw */ + int16_t codec_frame_size_ms, /* i/o: ISAR transport codec framesize */ + ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: ISAR bits struct handle */ + float Cldfb_In_BinReal[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ + float Cldfb_In_BinImag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB imag buffer */ + const int16_t max_bands, /* i : CLDFB bands */ + float *output[], /* i/o: PCM in/out buffer */ + const int16_t low_res_pre_rend_rot, /* i : low time resolution pre-renderer flag */ + const int16_t cldfb_in_flag, /* i : Flag to indicate CLDFB or time doamin input */ + const int16_t pcm_out_flag, /* i : Flag to indicate PCM output */ + const int16_t ro_md_flag /* i : Flag to indicate real only metadata for yaw */ ); +/* clang-format on */ #endif #endif /* LIB_ISAR_PRE_REND_H */ diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index d7d24d1d5890d98e6f80190fe64c7150fd452488..98710e10e8f1fd224d602c1b1add8159382bbd6d 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1216,18 +1216,7 @@ ivas_error ivas_rend_openMultiBinCrend( const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, const int32_t output_Fs ) { - ivas_error error; - -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, NULL /* hHrtfStatistics */, 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 - { - return error; - } - - return error; + return ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, NULL /* hHrtfStatistics */, output_Fs, pMultiBinPoseData->num_poses ); } #endif @@ -1871,10 +1860,11 @@ ivas_error ivas_rend_crendProcessSubframe( float *input_f[], /* i : transport channels */ float *output[], /* i/o: input/output audio channels */ const int16_t n_samples_to_render, /* i : output frame length per channel */ - const int32_t output_Fs /* i : output sampling rate */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - const int16_t pos_idx + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t pos_idx /* i : pose index */ +#else + const int32_t output_Fs /* i : output sampling rate */ #endif ) { @@ -1991,7 +1981,6 @@ ivas_error ivas_rend_crendProcessSubframe( if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0, pos_idx ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0 ) ) != IVAS_ERR_OK ) - #endif { return error; @@ -2056,149 +2045,6 @@ ivas_error ivas_rend_crendProcessSubframe( #ifdef SPLIT_REND_WITH_HEAD_ROT -/*-----------------------------------------------------------------------------------------* - * Function ivas_rend_crend_ProcessSplitBin() - * - * Process call for IVAS Crend renderer - *-----------------------------------------------------------------------------------------*/ - -ivas_error ivas_rend_crendProcessSplitBin( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const DECODER_CONFIG_HANDLE hDecoderConfig, - const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - float *output[], - const int32_t output_Fs ) -{ - int16_t i, j; - int16_t sf; - int16_t pos_idx, output_frame; - ivas_error error; - float gain_lfe; - float tmpLfeBuffer[L_FRAME48k]; - float tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - float *p_tmpInputBuffer[MAX_OUTPUT_CHANNELS]; - float tmpSplitBinBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; - COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; - - output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); - - /* copy input */ - for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) - { - mvr2r( output[i], tmpInputBuffer[i], output_frame ); - } - - for ( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) - { - p_tmpInputBuffer[i] = tmpInputBuffer[i]; - } - - /* save current head positions */ - pCombinedOrientationDataLocal = hCombinedOrientationData; - combinedOrientationDataLocal = *pCombinedOrientationDataLocal; - if ( pMultiBinPoseData->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) - { - for ( sf = 1; sf < hCombinedOrientationData->num_subframes; ++sf ) - { - combinedOrientationDataLocal.Quaternions[sf] = combinedOrientationDataLocal.Quaternions[0]; - for ( i = 0; i < 3; i++ ) - { - for ( j = 0; j < 3; j++ ) - { - combinedOrientationDataLocal.Rmat[sf][i][j] = combinedOrientationDataLocal.Rmat[0][i][j]; - } - } - } - } - - /* copy LFE to tmpLfeBuffer and apply gain only once */ - if ( hIntSetup->num_lfe > 0 && hIntSetup->index_lfe[0] != -1 ) - { - mvr2r( output[hIntSetup->index_lfe[0]], tmpLfeBuffer, output_frame ); - gain_lfe = ( ( pCrend != NULL ) && ( pCrend->hHrtfCrend != NULL ) ) ? pCrend->hHrtfCrend->gain_lfe : GAIN_LFE; - v_multc( tmpLfeBuffer, gain_lfe, tmpLfeBuffer, output_frame ); - } - else - { - set_zero( tmpLfeBuffer, output_frame ); - } - - for ( pos_idx = 0; pos_idx < pMultiBinPoseData->num_poses; ++pos_idx ) - { - /* Update head positions */ - - IVAS_QUATERNION Quaternions_orig[MAX_PARAM_SPATIAL_SUBFRAMES], Quaternions_abs; - for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) - { - Quaternions_orig[i] = combinedOrientationDataLocal.Quaternions[i]; - Quaternions_abs.w = -3.0f; - Quat2EulerDegree( combinedOrientationDataLocal.Quaternions[i], &Quaternions_abs.z, &Quaternions_abs.y, &Quaternions_abs.x ); /*order in Quat2Euler seems to be reversed ?*/ - - Quaternions_abs.x += pMultiBinPoseData->relative_head_poses[pos_idx][0]; - Quaternions_abs.y += pMultiBinPoseData->relative_head_poses[pos_idx][1]; - Quaternions_abs.z += pMultiBinPoseData->relative_head_poses[pos_idx][2]; - combinedOrientationDataLocal.Quaternions[i] = Quaternions_abs; - QuatToRotMat( combinedOrientationDataLocal.Quaternions[i], combinedOrientationDataLocal.Rmat[i] ); - } - - - /* render inplace to first two channels of tmpInputBuffer */ - pCombinedOrientationDataLocal = &combinedOrientationDataLocal; - - for ( i = 0; i < 3; i++ ) - { - mvr2r( hCombinedOrientationData->Rmat_prev[pos_idx][i], pCombinedOrientationDataLocal->Rmat_prev[0][i], 3 ); - } - - if ( ( error = ivas_rend_crendProcessSubframe( pCrend, inConfig, outConfig, hDecoderConfig, pCombinedOrientationDataLocal, hIntSetup, hEFAPdata, - NULL, p_tmpInputBuffer, p_tmpInputBuffer, output_frame, output_Fs, pos_idx ) ) != IVAS_ERR_OK ) - { - return error; - } - - for ( i = 0; i < 3; i++ ) - { - mvr2r( pCombinedOrientationDataLocal->Rmat_prev[0][i], hCombinedOrientationData->Rmat_prev[pos_idx][i], 3 ); - } - - for ( i = 0; i < BINAURAL_CHANNELS; ++i ) - { - /* accumulate LFE to output */ - v_add( tmpInputBuffer[i], tmpLfeBuffer, tmpInputBuffer[i], output_frame ); - - /* move to split bin output buffer */ - mvr2r( tmpInputBuffer[i], tmpSplitBinBuffer[pos_idx * BINAURAL_CHANNELS + i], output_frame ); - } - - /* overwrite rendered channels with input again for next iteration */ - for ( i = 0; i < hIntSetup->nchan_out_woLFE; ++i ) - { - mvr2r( output[i], tmpInputBuffer[i], output_frame ); - } - - /* restore original headrotation data */ - for ( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) - { - combinedOrientationDataLocal.Quaternions[i] = Quaternions_orig[i]; - } - } - - /* copy split binaural rendered signals to final output */ - for ( i = 0; i < BINAURAL_CHANNELS * pMultiBinPoseData->num_poses; ++i ) - { - mvr2r( tmpSplitBinBuffer[i], output[i], output_frame ); - } - - return IVAS_ERR_OK; -} - - /*-----------------------------------------------------------------------------------------* * Function ivas_rend_crend_ProcessSubframesSplitBin() * @@ -2206,10 +2052,10 @@ ivas_error ivas_rend_crendProcessSplitBin( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_rend_crendProcessSubframesSplitBin( - const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ - const AUDIO_CONFIG inConfig, /* i : input audio configuration */ - const AUDIO_CONFIG outConfig, /* i : output audio configuration */ - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ @@ -2231,7 +2077,6 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( float tmpInputBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float *p_tmpInputBuffer[MAX_OUTPUT_CHANNELS]; float tmpSplitBinBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - COMBINED_ORIENTATION_DATA combinedOrientationDataLocal; COMBINED_ORIENTATION_HANDLE pCombinedOrientationDataLocal; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 82ee76a49a84cf8aaaa26c9a9858db6a1a02c0ce..cbcc0465b0533d0a875d24d4339c72684aefa38e 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -134,6 +134,7 @@ static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtR static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, float *output_f[], const int16_t subframe ); #endif + /*------------------------------------------------------------------------- * ivas_dirac_dec_init_binaural_data() * @@ -288,6 +289,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( if ( !hDiracDecBin->useTdDecorr && !( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) ) { ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, nBins ); + if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), &( hDiracDecBin->h_freq_domain_decorr_ap_state ), nBins, @@ -787,8 +789,8 @@ static void ivas_dirac_dec_binaural_internal( #ifndef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Rmat, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, st_ivas->hMasaIsmData ); -#endif +#endif if ( config_data.ivas_format == ISM_FORMAT ) { max_band_decorr = 0; @@ -802,7 +804,6 @@ static void ivas_dirac_dec_binaural_internal( max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; } - #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, subFrameTotalEne, IIReneLimiter ); @@ -1157,6 +1158,7 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( return; } + static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, @@ -2215,9 +2217,8 @@ static void ivas_dirac_dec_binaural_process_output( const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, - const int16_t subframe #ifdef SPLIT_REND_WITH_HEAD_ROT - , + const int16_t subframe, float outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], @@ -2225,6 +2226,8 @@ static void ivas_dirac_dec_binaural_process_output( float decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const uint8_t recompute +#else + const int16_t subframe #endif ) { @@ -2270,6 +2273,7 @@ static void ivas_dirac_dec_binaural_process_output( { #endif ivas_dirac_dec_decorrelate_slot( hDiracDecBin, nBins, slot, inRe, inIm, decSlotRe, decSlotIm ); + #ifdef SPLIT_REND_WITH_HEAD_ROT for ( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -3512,6 +3516,7 @@ static void ivas_masa_ext_rend_parambin_internal( #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, subFrameTotalEne, IIReneLimiter ); + ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, subFrameTotalEne, IIReneLimiter, NULL ); diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 81cf8fc884541170b876d396f23d3d0b60a999c5..d85f8063ffecdc7d6d9a98bf07b5037738f9739c 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -466,3 +466,29 @@ ivas_error ivas_output_buff_dec( return IVAS_ERR_OK; } + + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*---------------------------------------------------------------------* + * is_split_rendering_enabled() + * + * + *---------------------------------------------------------------------*/ + +/*! r: flag to indicate if split rendering is enabled */ +int16_t is_split_rendering_enabled( + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ + const IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* i : Render config data structure */ +) +{ + if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || + ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && hDecoderConfig->Opt_non_diegetic_pan && hRenderConfig->split_rend_config.dof == 0 ) ) + { + return 1; + } + else + { + return 0; + } +} +#endif diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 7f557c7f19a95a7e6dd831f0cf854b9a872d2bee..9ccbc180ecc6efe9ef3c8bb31da85de03fcdb9d1 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -77,6 +77,14 @@ int16_t ivas_get_nchan_buffers_dec( const int32_t ivas_total_brate /* i : total IVAS bitrate */ ); +#ifdef SPLIT_REND_WITH_HEAD_ROT +/*! r: flag to indicate if split rendering is enabled */ +int16_t is_split_rendering_enabled( + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ + const IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* i : Render config data structure */ +); +#endif + /*----------------------------------------------------------------------------------* * TD decorr. function prototypes @@ -886,7 +894,7 @@ ivas_error ivas_rend_openCrend( void ivas_rend_closeCrend( #ifdef SPLIT_REND_WITH_HEAD_ROT - CREND_WRAPPER_HANDLE *pCrend , + CREND_WRAPPER_HANDLE *pCrend, const int16_t num_poses #else CREND_WRAPPER_HANDLE *pCrend @@ -918,10 +926,11 @@ ivas_error ivas_rend_crendProcessSubframe( float *input_f[], /* i : transport channels */ float *output[], /* i/o: input/output audio channels */ const int16_t n_samples_to_render, /* i : output frame length per channel */ - const int32_t output_Fs /* i : output sampling rate */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , - const int16_t pos_idx + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t pos_idx /* i : pose index */ +#else + const int32_t output_Fs /* i : output sampling rate */ #endif ); @@ -1539,19 +1548,6 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( const int32_t output_Fs /* i : output sampling rate */ ); -ivas_error ivas_rend_crendProcessSplitBin( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - const DECODER_CONFIG_HANDLE hDecoderConfig, - const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - float *output[], - const int32_t output_Fs -); - ivas_error ivas_rend_openMultiBinCrend( CREND_WRAPPER_HANDLE *pCrend, const AUDIO_CONFIG inConfig, diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index 4583d65fd64bb485d546e04a2da3e1848b87a016..17c4f11a0be9afe7b30204c60131481b90135c6d 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -131,13 +131,16 @@ ivas_error ivas_render_config_init_from_rom( ( *hRenderConfig )->directivity[i * 3 + 1] = 360.0f; /* Back cone */ ( *hRenderConfig )->directivity[i * 3 + 2] = 1.0f; /* Back attenuation */ } + #ifdef CONF_DISTATT ( *hRenderConfig )->distAtt[0] = 15.75f; /* Default max dist */ ( *hRenderConfig )->distAtt[1] = 1.0f; /* Default ref dist */ ( *hRenderConfig )->distAtt[2] = 1.0f; /* Default rolloff factor */ #endif + #ifdef SPLIT_REND_WITH_HEAD_ROT - ( *hRenderConfig )->split_rend_config.splitRendBitRate = SPLIT_REND_768k; + /* ISAR-related parameters */ + ( *hRenderConfig )->split_rend_config.splitRendBitRate = ISAR_MAX_SPLIT_REND_BITRATE; ( *hRenderConfig )->split_rend_config.dof = 3; ( *hRenderConfig )->split_rend_config.hq_mode = 0; ( *hRenderConfig )->split_rend_config.codec_delay_ms = 0; diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 46814b435b2b998aa699a862b2c84d4efa3b39ca..487ed7ff17ef511a5fe3112d7ca6c411a34b32c8 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -49,19 +49,14 @@ * Local funtion declarations *-----------------------------------------------------------------------*/ -static ivas_error combine_external_and_head_orientations( - IVAS_QUATERNION *headRotQuaternions, - IVAS_VECTOR3 *listenerPos, + #ifdef SPLIT_REND_WITH_HEAD_ROT - ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis*/ +static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, IVAS_VECTOR3 *listenerPos, ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); +#else +static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, IVAS_VECTOR3 *listenerPos, EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); #endif - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); -static void external_target_interpolation( - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - const int16_t i ); +static void external_target_interpolation( EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, const int16_t i ); static bool are_orientations_same( const IVAS_QUATERNION *orientation1, const IVAS_QUATERNION *orientation2 ); @@ -922,11 +917,11 @@ ivas_error combine_external_and_head_orientations_dec( } #endif - return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, #ifdef SPLIT_REND_WITH_HEAD_ROT - sr_pose_pred_axis, + return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, sr_pose_pred_axis, hExtOrientationData, hCombinedOrientationData ); +#else + return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, hExtOrientationData, hCombinedOrientationData ); #endif - hExtOrientationData, hCombinedOrientationData ); } @@ -975,11 +970,11 @@ ivas_error combine_external_and_head_orientations_rend( } } - return combine_external_and_head_orientations( headRotQuaternions, listenerPos, #ifdef SPLIT_REND_WITH_HEAD_ROT - sr_pose_pred_axis, + return combine_external_and_head_orientations( headRotQuaternions, listenerPos, sr_pose_pred_axis, hExtOrientationData, hCombinedOrientationData ); +#else + return combine_external_and_head_orientations( headRotQuaternions, listenerPos, hExtOrientationData, hCombinedOrientationData ); #endif - hExtOrientationData, hCombinedOrientationData ); } @@ -1615,11 +1610,11 @@ void ivas_combined_orientation_update_index( { if ( hCombinedOrientationData != NULL ) { - if ( hCombinedOrientationData->num_subframes == 1 #ifdef SPLIT_REND_WITH_HEAD_ROT - || hCombinedOrientationData->sr_low_res_flag + if ( hCombinedOrientationData->num_subframes == 1 || hCombinedOrientationData->sr_low_res_flag ) +#else + if ( hCombinedOrientationData->num_subframes == 1 ) #endif - ) { /* only one orientation available anyway or split rendering with low resolution*/ hCombinedOrientationData->subframe_idx = 0; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index db5c99ab7052e03e4c3d9cc1a82a78e9b614b631..973810bc968f7e1eafe334eab6140bd915f687ce 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1378,149 +1378,6 @@ typedef struct ivas_hrtfs_statistics_struct int16_t fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ } HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; -#ifdef SPLIT_REND_WITH_HEAD_ROT -/*----------------------------------------------------------------------------------* - * Binaural split rendering structures - *----------------------------------------------------------------------------------*/ - -/* binaural split rendering head rotation data structure */ -typedef struct ivas_binaural_head_rot_split_rendering_md_struct -{ - float pred_mat_re[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - float pred_mat_im[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - float gd; - float gd2; - int16_t pred_mat_re_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - int16_t pred_mat_im_idx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - int16_t gd_idx; - int16_t gd2_idx; - -} BIN_HR_SPLIT_REND_MD, *BIN_HR_SPLIT_REND_MD_HANDLE; - -typedef struct ivas_split_rend_huffman_cfg_t -{ - const int32_t *codebook; - int16_t min_len; - int16_t max_len; - int16_t sym_len; - -} ivas_split_rend_huffman_cfg_t; - -typedef struct ivas_binaural_head_rot_split_rendering_huff_struct -{ - ivas_split_rend_huffman_cfg_t pred[2]; - int16_t pred_idx_trav[2][ISAR_SPLIT_REND_PRED_63QUANT_PNTS]; - int16_t pred_base2_code_len[2]; - ivas_split_rend_huffman_cfg_t pred_roll; - int16_t pred_roll_idx_trav[ISAR_SPLIT_REND_ROLL_PRED_QUANT_PNTS]; - int16_t pred_roll_base2_code_len; - ivas_split_rend_huffman_cfg_t gd; - int16_t gd_base2_code_len; - int16_t gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; - ivas_split_rend_huffman_cfg_t p_gd; - int16_t p_gd_base2_code_len; - int16_t p_gd_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; - ivas_split_rend_huffman_cfg_t p_gd_diff; - int16_t p_gd_diff_base2_code_len; - int16_t p_gd_diff_idx_trav[ISAR_SPLIT_REND_D_QUANT_PNTS]; - -} BIN_HR_SPLIT_REND_HUFF, *BIN_HR_SPLIT_REND_HUFF_HANDLE; - - -typedef struct ivas_binaural_head_rot_split_post_rendering_struct -{ - BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; - IVAS_QUATERNION QuaternionsPre[MAX_PARAM_SPATIAL_SUBFRAMES]; - int16_t low_Res; - - float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; - BIN_HR_SPLIT_REND_HUFF huff_cfg; -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - float mixer_mat_re[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - float mixer_mat_im[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - float gd_mem[MAX_HEAD_ROT_POSES][MAX_SPLIT_REND_MD_BANDS]; -#else - float mixer_mat_re[1][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - float mixer_mat_im[1][MAX_SPLIT_REND_MD_BANDS][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - float gd_mem[1][MAX_SPLIT_REND_MD_BANDS]; -#endif - int16_t cf_flag; - HANDLE_CLDFB_FILTER_BANK cldfbAna[BINAURAL_CHANNELS]; - HANDLE_CLDFB_FILTER_BANK cldfbSyn[BINAURAL_CHANNELS]; -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - HANDLE_CLDFB_FILTER_BANK cldfbSynReconsBinDec[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS]; -#endif - -} BIN_HR_SPLIT_POST_REND, *BIN_HR_SPLIT_POST_REND_HANDLE; - -typedef struct ivas_binaural_head_rot_split_pre_rendering_struct -{ - BIN_HR_SPLIT_REND_MD rot_md[MAX_HEAD_ROT_POSES - 1][MAX_SPLIT_MD_SUBFRAMES][MAX_SPLIT_REND_MD_BANDS]; - float fix_pos_rot_mat[MAX_HEAD_ROT_POSES - 1][BINAURAL_CHANNELS][BINAURAL_CHANNELS]; - ISAR_SPLIT_REND_POSE_TYPE pose_type[MAX_HEAD_ROT_POSES - 1]; - BIN_HR_SPLIT_REND_HUFF huff_cfg; -#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - HANDLE_CLDFB_FILTER_BANK cldfbSynRotBinDec[MAX_HEAD_ROT_POSES + 1][BINAURAL_CHANNELS]; -#endif - -#ifdef SPLIT_POSE_CORRECTION_DEBUG - BIN_HR_SPLIT_POST_REND_HANDLE hBinHrSplitPostRend; -#endif - -} BIN_HR_SPLIT_PRE_REND, *BIN_HR_SPLIT_PRE_REND_HANDLE; - -typedef struct ivas_binaural_head_rot_split_rendering_lcld_enc_struct -{ - void *pLcld_enc; - int16_t iChannels; - LCLDEncoder *psLCLDEncoder; - float ***pppfLCLDReal; - float ***pppfLCLDImag; -#ifdef CLDFB_DEBUG - FILE *cldfbIn; - int16_t numFrame; -#endif - int16_t iNumIterations; - int16_t iNumBlocks; - -} BIN_HR_SPLIT_LCLD_ENC, *BIN_HR_SPLIT_LCLD_ENC_HANDLE; - -typedef struct -{ - float Cldfb_Prev_BinReal[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_Prev_BinImag[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX + CLDFB_PLC_XF][CLDFB_NO_CHANNELS_MAX]; - float xf_bet[2][CLDFB_NO_CHANNELS_MAX][CLDFB_PLC_XF]; -} CLDFB_PLC, *CLDFB_PLC_HANDLE; - -typedef struct -{ - CLDFB_PLC CldfbPLC_state; - int16_t prev_bfi; - int16_t bf_count; - int16_t iNumSubSets; - -} SPLIT_REND_PLC_STRUCT, *SPLIT_REND_PLC_HANDLE; - -typedef struct ivas_binaural_head_rot_split_rendering_lcld_dec_struct -{ - void *pLcld_dec; - int32_t iChannels; - LCLDDecoder *psLCLDDecoder; - float ***pppfDecLCLDReal; - float ***pppfDecLCLDImag; -#ifdef CLDFB_DEBUG - FILE *cldfbOut; - int16_t numFrame; -#endif - SPLIT_REND_PLC_HANDLE hSplitRendPLC; - int16_t iNumBlocks; - int16_t iNumIterations; - -} BIN_HR_SPLIT_LCLD_DEC, *BIN_HR_SPLIT_LCLD_DEC_HANDLE; - -#endif - /*----------------------------------------------------------------------------------* * Limiter structure @@ -1595,8 +1452,17 @@ typedef struct ivas_LS_setup_custom } LSSETUP_CUSTOM_STRUCT, *LSSETUP_CUSTOM_HANDLE; -#ifdef SPLIT_REND_WITH_HEAD_ROT +/* Channel types in a channel-based config */ +typedef enum +{ + CHANNEL_TYPE_UNUSED = 0, + CHANNEL_TYPE_SPEAKER, + CHANNEL_TYPE_LFE +} ChannelType; + + +#ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------------------* * CLDFB renderer wrapper *----------------------------------------------------------------------------------*/ @@ -1608,17 +1474,8 @@ typedef struct HRTFS_FASTCONV_HANDLE hHrtfFastConv; } CLDFB_REND_WRAPPER; - #endif -/* Channel types in a channel-based config */ -typedef enum -{ - CHANNEL_TYPE_UNUSED = 0, - CHANNEL_TYPE_SPEAKER, - CHANNEL_TYPE_LFE - -} ChannelType; /*----------------------------------------------------------------------------------* * MASA external renderer structure diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 087c86118eb79a42c641ef313e3447fefa27dfcc..06840fbcdba6bf356ff594ab22b3fdfe9259f0f3 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -35,9 +35,10 @@ #include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_prot.h" -#include "isar_stat.h" #include "lib_isar_pre_rend.h" +#endif #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_rend.h" @@ -251,17 +252,9 @@ static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG static void freeMasaExtRenderer( MASA_EXT_REND_HANDLE *hMasaExtRendOut ); #ifdef SPLIT_REND_WITH_HEAD_ROT -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 ); +static void 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 ); -static ivas_error renderSbaToMultiBinaural( - input_sba *sbaInput, - const AUDIO_CONFIG outConfig, - float out[][L_FRAME48k] ); +static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, float out[][L_FRAME48k] ); #endif /*-------------------------------------------------------------------* @@ -644,7 +637,6 @@ static ivas_error validateOutputSampleRate( else { #endif - /* Otherwise rendering to binaural, support the same set as IVAS decoder */ switch ( sampleRate ) { @@ -3487,6 +3479,12 @@ static ivas_error findFreeInputSlot( #ifdef SPLIT_REND_WITH_HEAD_ROT +/*------------------------------------------------------------------------- + * Function getCldfbRendFlag() + * + * + *------------------------------------------------------------------------*/ + static int16_t getCldfbRendFlag( IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ const IVAS_REND_AudioConfigType new_configType ) @@ -3590,7 +3588,6 @@ static ivas_error ivas_pre_rend_init( #endif - /*-------------------------------------------------------------------* * IVAS_REND_AddInput() * @@ -4374,7 +4371,7 @@ int16_t IVAS_REND_GetRenderConfig( mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); #ifdef SPLIT_REND_WITH_HEAD_ROT - hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k; + hRCout->split_rend_config.splitRendBitRate = ISAR_MAX_SPLIT_REND_BITRATE; hRCout->split_rend_config.dof = 3; hRCout->split_rend_config.hq_mode = 0; hRCout->split_rend_config.codec_delay_ms = 0; @@ -4520,6 +4517,7 @@ int16_t IVAS_REND_FeedRenderConfig( } } #endif + if ( pMasaInput->hMasaExtRend->hReverb != NULL ) { ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hReverb ); @@ -4760,8 +4758,9 @@ ivas_error IVAS_REND_DisableHeadRotation( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_SetSplitRendBFI( - IVAS_REND_HANDLE hIvasRend, - const int16_t bfi ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const int16_t bfi /* i : bad frame indicator */ +) { hIvasRend->splitRendBFI = bfi; @@ -5365,6 +5364,7 @@ static ivas_error renderIsmToBinaural( } #ifdef SPLIT_REND_WITH_HEAD_ROT + static int16_t getNumSubframesInBuffer( const IVAS_REND_AudioBuffer *buffer, const int32_t sampleRate ) @@ -5379,6 +5379,7 @@ static int16_t getNumSubframesInBuffer( return (int16_t) ( buffer->config.numSamplesPerChannel / ( sampleRate / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES * cldfb2tdSampleFact ) ); } + #endif static ivas_error renderIsmToBinauralRoom( @@ -5525,7 +5526,6 @@ static ivas_error renderIsmToBinauralRoom( mvr2r( currentPanGains, ismInput->prev_pan_gains, MAX_OUTPUT_CHANNELS ); } - /* render 7_1_4 with BRIRs */ #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, @@ -5533,7 +5533,6 @@ static ivas_error renderIsmToBinauralRoom( #else if ( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, *ismInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) - #endif { return error; @@ -6123,7 +6122,6 @@ static ivas_error renderMcToBinaural( #else if ( ( error = renderLfeToBinaural( mcInput, outAudio ) ) != IVAS_ERR_OK ) #endif - { return error; } @@ -6189,13 +6187,11 @@ 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, #ifdef SPLIT_REND_WITH_HEAD_ROT - mcInput->rot_gains_prev[0], + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) #else - mcInput->rot_gains_prev, + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) #endif - mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6283,13 +6279,11 @@ 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, #ifdef SPLIT_REND_WITH_HEAD_ROT - mcInput->rot_gains_prev[0], + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) #else - mcInput->rot_gains_prev, + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) #endif - mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6515,7 +6509,6 @@ static ivas_error renderMcToSplitBinaural( * 4. LFE mixing * 5. tmpSplitBinBuffer accumulated to outBuffer */ - /* copy input for in-place rotation */ set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); @@ -6803,7 +6796,8 @@ static ivas_error renderSbaToMultiBinaural( return IVAS_ERR_OK; } -static ivas_error renderSbaToMultiBinauralCldfb( + +static void 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], @@ -6818,7 +6812,7 @@ static ivas_error renderSbaToMultiBinauralCldfb( 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; + return; } @@ -6831,26 +6825,19 @@ static ivas_error renderSbaToSplitBinaural( ivas_error error; 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 low_res_pre_rend_rot; - - low_res_pre_rend_rot = 1; push_wmops( "renderSbaToSplitBinaural" ); - error = IVAS_ERR_OK; if ( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { - 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; - } + renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, 1, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ); accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } else { - if ( ( renderSbaToMultiBinaural( sbaInput, outConfig, tmpCrendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = renderSbaToMultiBinaural( sbaInput, outConfig, tmpCrendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -6859,7 +6846,7 @@ static ivas_error renderSbaToSplitBinaural( } pop_wmops(); - return error; + return IVAS_ERR_OK; } #endif @@ -6885,11 +6872,8 @@ 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]; - if ( ( error = renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, 0, - getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) - { - return error; - } + renderSbaToMultiBinauralCldfb( sbaInput, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, 0, + getNumSubframesInBuffer( &outAudio, *sbaInput->base.ctx.pOutSampleRate ) ); accumulateCLDFBArrayToBuffer( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } @@ -7012,13 +6996,11 @@ static ivas_error renderSbaToBinauralRoom( 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], + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev[0], tmpRotBuffer ) ) != IVAS_ERR_OK ) #else - sbaInput->rot_gains_prev, + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev, tmpRotBuffer ) ) != IVAS_ERR_OK ) #endif - tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -7966,14 +7948,22 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( return getSamplesInternal( hIvasRend, outAudio, hBits ); } + +/*-------------------------------------------------------------------* + * IVAS_REND_GetSplitRendBitstreamHeader() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetSplitRendBitstreamHeader( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ - ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ - ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ - int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - int16_t *pIsar_frame_size_ms /* o: pointer to isar frame size setting */ + int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ + int16_t *pIsar_frame_size_ms /* o : pointer to ISAR frame size setting */ +#else + int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ #endif ) { @@ -7981,12 +7971,14 @@ ivas_error IVAS_REND_GetSplitRendBitstreamHeader( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + *pCodec = hIvasRend->hRendererConfig->split_rend_config.codec; *pCodec_frame_size_ms = hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms; #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS *pIsar_frame_size_ms = hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms; #endif *poseCorrection = hIvasRend->hRendererConfig->split_rend_config.poseCorrectionMode; + return IVAS_ERR_OK; } @@ -8819,6 +8811,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif + /* External renderer uses constant regularization factor */ hDiracDecBin->reqularizationFactor = 0.4f; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 768a53cfa52e2d0126961a7eb11032c16a00f727..edd2b3b3c20527e33d84bdb00a0783d0edf15a11 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -256,7 +256,7 @@ 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_BitstreamBuffer *hBits /* i : buffer for input bitstream */ + IVAS_REND_BitstreamBuffer *hBits /* i : buffer for input bitstream */ ); ivas_error IVAS_REND_GetSplitBinauralSamples( @@ -272,13 +272,14 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( ); ivas_error IVAS_REND_GetSplitRendBitstreamHeader( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ - ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ - ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ - int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - int16_t *pIsar_frame_size_ms /* o: pointer to isar frame size setting */ + int16_t *pCodec_frame_size_ms, /* o : pointer to codec frame size setting */ + int16_t *pIsar_frame_size_ms /* o : pointer to ISAR frame size setting */ +#else + int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ #endif ); #endif @@ -326,8 +327,9 @@ ivas_error IVAS_REND_SetReferenceVector( #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error IVAS_REND_SetSplitRendBFI( - IVAS_REND_HANDLE hIvasRend, - const int16_t bfi); + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const int16_t bfi /* i : bad frame indicator */ +); #endif ivas_error IVAS_REND_SetExternalOrientation( diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index 9ca1000770d09fdb4761905604af3cda20cb15fb..9122201f09bc53c0b1dcf16b6399cb26321b80db 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -98,8 +98,9 @@ ivas_error SplitRendBFIFileReader_open( *-----------------------------------------------------------------------*/ ivas_error SplitRendBFIFileReading( - SplitRendBFIFileReader *SplitRendBFIReader, /* i/o: SplitRendBFIFileReader handle */ - int16_t *bfi ) + SplitRendBFIFileReader *SplitRendBFIReader, /* i/o: SplitRendBFIFileReader handle */ + int16_t *bfi /* o : bad frame indicator */ +) { if ( SplitRendBFIReader->txtfile ? 1 != fscanf( SplitRendBFIReader->bfiFile, "%hd", bfi ) : 1 != fread( bfi, sizeof( *bfi ), 1, SplitRendBFIReader->bfiFile ) ) { diff --git a/lib_util/split_rend_bfi_file_reader.h b/lib_util/split_rend_bfi_file_reader.h index f0af65254411fcd7c3b0f8f19e3abcc7f82510ea..f993cbdfd69f34b1203f937e849e0f453308aec5 100644 --- a/lib_util/split_rend_bfi_file_reader.h +++ b/lib_util/split_rend_bfi_file_reader.h @@ -45,7 +45,8 @@ ivas_error SplitRendBFIFileReader_open( ivas_error SplitRendBFIFileReading( SplitRendBFIFileReader *SplitRendBFIReader, /* i/o: SplitRendBFIFileReader handle */ - int16_t *bfi ); + int16_t *bfi /* o : bad frame indicator */ +); void SplitRendBFIFileReader_close( SplitRendBFIFileReader **SplitRendBFIReader /* i/o: SplitRendBFIFileReader handle */ diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 6a676235be767e8ca22ce41af3cc77db9b583f54..6d0a3ccf24f424ce2e63a8cd6c44917e1732af2f 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include "options.h" #include "split_render_file_read_write.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include @@ -66,12 +65,13 @@ ivas_error split_rend_reader_open( char *filename, ISAR_SPLIT_REND_CODEC *codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, - int16_t *codec_frame_size_ms #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , + int16_t *codec_frame_size_ms, int16_t *isar_frame_size_ms, int32_t *sampling_rate, int16_t *lc3plus_highres +#else + int16_t *codec_frame_size_ms #endif ) { @@ -120,22 +120,26 @@ ivas_error split_rend_reader_open( { return IVAS_ERR_FAILED_FILE_READ; } + /* read transport codec frame size signalling */ if ( fread( codec_frame_size_ms, sizeof( *codec_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_READ; } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - /* read isar bitstream frame size signalling */ + /* read ISAR bitstream frame size signalling */ if ( fread( isar_frame_size_ms, sizeof( *isar_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_READ; } + /* read sampling rate signalling */ if ( fread( sampling_rate, sizeof( *sampling_rate ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_READ; } + /* read LC3plus highres signalling */ if ( fread( lc3plus_highres, sizeof( *lc3plus_highres ), 1, hSplitRendFileReadWrite->file ) != 1 ) { @@ -162,12 +166,13 @@ ivas_error split_rend_writer_open( const int32_t delayTimeScale, ISAR_SPLIT_REND_CODEC codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, - int16_t codec_frame_size_ms #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , + const int16_t codec_frame_size_ms, const int16_t isar_frame_size_ms, const int32_t sampling_rate, const int16_t lc3plus_highres +#else + const int16_t codec_frame_size_ms #endif ) { @@ -215,22 +220,26 @@ ivas_error split_rend_writer_open( { return IVAS_ERR_FAILED_FILE_WRITE; } + /* Write transport codec frame size signalling */ if ( fwrite( &codec_frame_size_ms, sizeof( codec_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_WRITE; } + #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - /* Write isar bit stream frame size signalling */ + /* Write ISAR bit stream frame size signalling */ if ( fwrite( &isar_frame_size_ms, sizeof( isar_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_WRITE; } + /* Write sampling rate signalling */ if ( fwrite( &sampling_rate, sizeof( sampling_rate ), 1, hSplitRendFileReadWrite->file ) != 1 ) { return IVAS_ERR_FAILED_FILE_WRITE; } + /* Write LC3plus highres signalling */ if ( fwrite( &lc3plus_highres, sizeof( lc3plus_highres ), 1, hSplitRendFileReadWrite->file ) != 1 ) { diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index ea277cfc52a57caf2e0412561306569441494b02..3966c636799934b6a5c85c0ef83dc2da5de8c182 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -38,23 +38,23 @@ typedef struct SplitFileReadWrite SplitFileReadWrite; -/* Allocates and initializes a a split renderer reader instance */ +/* Allocates and initializes a a split renderer reader instance */ ivas_error split_rend_reader_open( SplitFileReadWrite **hhSplitRendFileReadWrite, char *filename, ISAR_SPLIT_REND_CODEC *codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, - int16_t *codec_frame_size_ms #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , + int16_t *codec_frame_size_ms, int16_t *isar_frame_size_ms, int32_t *sampling_rate, int16_t *lc3plus_highres +#else + int16_t *codec_frame_size_ms #endif ); - -/* Allocates and initializes a a split renderer writer instance */ +/* Allocates and initializes a a split renderer writer instance */ ivas_error split_rend_writer_open( SplitFileReadWrite **hhSplitRendFileReadWrite, char *filename, @@ -62,17 +62,17 @@ ivas_error split_rend_writer_open( const int32_t delayTimeScale, ISAR_SPLIT_REND_CODEC codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, - int16_t codec_frame_size_ms #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - , + const int16_t codec_frame_size_ms, const int16_t isar_frame_size_ms, const int32_t sampling_rate, const int16_t lc3plus_highres +#else + const int16_t codec_frame_size_ms #endif ); - -/* Closes the split renderer reader/writer and deallocates memory */ +/* Closes the split renderer reader/writer and deallocates memory */ void split_rend_reader_writer_close( SplitFileReadWrite **hhSplitRendFileReadWrite );