diff --git a/apps/decoder.c b/apps/decoder.c index 50c8b043e94fe205bf3259bc0bb2f97cc6970c2c..ae7675cd78ec42f429cc2ae3d61cee989904170b 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -593,6 +593,10 @@ int main( } } #else + /*-----------------------------------------------------------------* + * Print config information + *-----------------------------------------------------------------*/ + if ( ( error = IVAS_DEC_PrintConfig( hIvasDec, 1, arg.voipMode ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_PrintConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -639,11 +643,13 @@ int main( fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] ); goto cleanup; } + if ( ( error = RenderConfigReader_getDistanceAttenuation( renderConfigReader, renderConfig.distAtt ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to get Distance Attenuation \n\n" ); goto cleanup; } + 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 && @@ -806,6 +812,7 @@ cleanup: free( arg.aeSequence.pID ); free( arg.aeSequence.pValidity ); } + #ifdef DEBUG_SBA_AUDIO_DUMP IVAS_DEC_GetSbaDebugParams( hIvasDec, &numOutChannels, &numTransportChannels, &pca_ingest_channels ); @@ -1186,7 +1193,6 @@ static bool parseCmdlIVAS_dec( } #endif #endif /* #ifdef DEBUGGING */ - else if ( strcmp( argv_to_upper, "-MIME" ) == 0 ) { arg->inputFormat = IVAS_DEC_INPUT_FORMAT_MIME; @@ -1211,6 +1217,7 @@ static bool parseCmdlIVAS_dec( { int32_t tmp; i++; + if ( i < argc - 3 ) { if ( !is_digits_only( argv[i] ) ) @@ -1244,7 +1251,6 @@ static bool parseCmdlIVAS_dec( } else if ( strcmp( argv_to_upper, "-OTR" ) == 0 ) { - strncpy( argv_to_upper, argv[i + 1], sizeof( argv_to_upper ) - 1 ); argv_to_upper[sizeof( argv_to_upper ) - 1] = '\0'; to_upper( argv_to_upper ); @@ -1353,6 +1359,7 @@ static bool parseCmdlIVAS_dec( strncpy( argv_to_upper, argv[i], sizeof( argv_to_upper ) - 1 ); argv_to_upper[sizeof( argv_to_upper ) - 1] = '\0'; to_upper( argv_to_upper ); + if ( ( strcmp( argv_to_upper, "CENTER" ) == 0 ) || ( strchr( argv_to_upper, 'C' ) != NULL ) ) { arg->non_diegetic_pan_gain = 0.f; @@ -1508,6 +1515,7 @@ static bool parseCmdlIVAS_dec( /*-----------------------------------------------------------------* * Option not recognized *-----------------------------------------------------------------*/ + else { fprintf( stderr, "Error: Unknown option %s or wrong number of parameters!\n\n", argv[i] ); @@ -1735,6 +1743,35 @@ static int16_t app_own_random( int16_t *seed ) } #endif +/*---------------------------------------------------------------------* + * resetHeadRotation() + * + * + *---------------------------------------------------------------------*/ + +static void resetHeadRotation( + const int16_t num_subframes, /* i : number of subframes */ + IVAS_QUATERNION *pQuaternion, /* o : head-tracking data */ + IVAS_VECTOR3 *pPos /* o : listener position */ + +) +{ + int16_t i; + + for ( i = 0; i < num_subframes; i++ ) + { + pQuaternion[i].w = -3.0f; + pQuaternion[i].x = 0.0f; + pQuaternion[i].y = 0.0f; + pQuaternion[i].z = 0.0f; + pPos[i].x = 0.0f; + pPos[i].y = 0.0f; + pPos[i].z = 0.0f; + } + + return; +} + /*---------------------------------------------------------------------* * initOnFirstGoodFrame() @@ -1759,7 +1796,7 @@ static ivas_error initOnFirstGoodFrame( uint16_t *pNumObj, /* o : */ SplitFileReadWrite **splitRendWriter ) { - int16_t isSplitRend, isSplitCoded; + int16_t i, j, isSplitRend, isSplitCoded; ivas_error error = IVAS_ERR_UNKNOWN; /* Now delay, number of output channels and frame size are known */ @@ -1870,7 +1907,7 @@ static ivas_error initOnFirstGoodFrame( } memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) ); - for ( int16_t i = 0; i < numInitialBadFrames; ++i ) + for ( i = 0; i < numInitialBadFrames; ++i ) { if ( *splitRendWriter != NULL ) { @@ -1892,7 +1929,6 @@ static ivas_error initOnFirstGoodFrame( } else { - if ( *pRemainingDelayNumSamples < *numOutSamples ) { if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, *numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) @@ -1929,7 +1965,7 @@ static ivas_error initOnFirstGoodFrame( return error; } - for ( int16_t i = 0; i < *pNumObj; ++i ) + for ( i = 0; i < *pNumObj; ++i ) { if ( ( error = IsmFileWriter_open( arg.outputWavFilename, i, &ismWriters[i] ) ) != IVAS_ERR_OK ) { @@ -1938,10 +1974,10 @@ static ivas_error initOnFirstGoodFrame( } } - for ( int16_t j = 0; j < numInitialBadFrames; ++j ) + for ( j = 0; j < numInitialBadFrames; ++j ) { /* write zero metadata */ - for ( int16_t i = 0; i < *pNumObj; ++i ) + for ( i = 0; i < *pNumObj; ++i ) { IVAS_ISM_METADATA IsmMetadata; @@ -1991,7 +2027,7 @@ static ivas_error initOnFirstGoodFrame( return error; } - for ( int16_t j = 0; j < numInitialBadFrames; ++j ) + for ( j = 0; j < numInitialBadFrames; ++j ) { if ( ( error = MasaFileWriter_writeFrame( *ppMasaWriter, hMasaExtOutMeta, &delayMs ) ) != IVAS_ERR_OK ) { @@ -2016,6 +2052,7 @@ static ivas_error initOnFirstGoodFrame( fprintf( stderr, "\nError getting render frame size in samples\n" ); return error; } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, vec_pos_len ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); @@ -2136,7 +2173,6 @@ static ivas_error decodeG192( /* we always start with needing a new frame */ needNewFrame = true; - if ( !arg.quietModeEnabled ) { fprintf( stdout, "\n------ Running the decoder ------\n\n" ); @@ -2213,8 +2249,6 @@ static ivas_error decodeG192( while ( 1 ) { - /* Read next frame if not enough samples availble */ - /* reference vector */ if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 ) { @@ -2255,7 +2289,7 @@ static ivas_error decodeG192( fprintf( stderr, "\nIVAS_DEC_GetNumOrientationSubframes failed: \n" ); goto cleanup; } - /* Head-tracking input simulation */ + /* Head-tracking input simulation */ if ( arg.enableHeadRotation ) { @@ -2263,16 +2297,7 @@ static ivas_error decodeG192( if ( headRotReader == NULL ) { - for ( i = 0; i < num_subframes; i++ ) - { - Quaternions[i].w = -3.0f; - Quaternions[i].x = 0.0f; - Quaternions[i].y = 0.0f; - Quaternions[i].z = 0.0f; - Pos[i].x = 0.0f; - Pos[i].y = 0.0f; - Pos[i].z = 0.0f; - } + resetHeadRotation( num_subframes, Quaternions, Pos ); } else { @@ -2486,9 +2511,6 @@ static ivas_error decodeG192( fprintf( stderr, "\nError in IVAS_DEC_GetSplitBinauralBitstream: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; } else { @@ -2497,11 +2519,11 @@ static ivas_error decodeG192( fprintf( stderr, "\nError in IVAS_DEC_GetSamplesRenderer(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; } + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; + if ( needNewFrame ) { frame++; @@ -2576,7 +2598,7 @@ static ivas_error decodeG192( } } - /* Write ISm metadata to external file(s) */ + /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM ) @@ -2616,6 +2638,7 @@ static ivas_error decodeG192( { fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2630,6 +2653,7 @@ static ivas_error decodeG192( } } } + vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; #ifdef WMOPS if ( vec_pos_update == 0 ) @@ -2648,8 +2672,6 @@ static ivas_error decodeG192( { int16_t nSamplesFlushed; - /* Feed into decoder */ - /* reference vector */ if ( arg.enableReferenceVectorTracking ) { @@ -2701,7 +2723,7 @@ static ivas_error decodeG192( } } - /* decode and get samples */ + /* flush remaining audio */ if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2715,7 +2737,7 @@ static ivas_error decodeG192( goto cleanup; } - /* Write ISm metadata to external file(s) */ + /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM ) @@ -2754,6 +2776,7 @@ static ivas_error decodeG192( { fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2962,7 +2985,15 @@ cleanup: #endif #ifdef SUPPORT_JBM_TRACEFILE -static ivas_error writeJbmTraceFileFrameWrapper( const void *data, void *writer ) +/*---------------------------------------------------------------------* + * writeJbmTraceFileFrameWrapper() + * + * + *---------------------------------------------------------------------*/ + +static ivas_error writeJbmTraceFileFrameWrapper( + const void *data, + void *writer ) { return JbmTraceFileWriter_writeFrame( data, writer ); } @@ -3041,11 +3072,13 @@ static ivas_error decodeVoIP( fprintf( stderr, "\nError getting render frame size in samples\n" ); return error; } + if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nOutSamples ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); return error; } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, &vec_pos_len ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); @@ -3087,7 +3120,6 @@ static ivas_error decodeVoIP( goto cleanup; } - #ifdef SUPPORT_JBM_TRACEFILE if ( arg.jbmTraceFilename != NULL ) { @@ -3098,8 +3130,8 @@ static ivas_error decodeVoIP( } fprintf( stdout, "JBM trace file: %s\n", arg.jbmTraceFilename ); } -#endif +#endif if ( arg.jbmOffsetFilename != NULL ) { if ( ( error = JbmOffsetFileWriter_open( arg.jbmOffsetFilename, &jbmOffsetWriter ) ) != IVAS_ERR_OK ) @@ -3124,6 +3156,7 @@ static ivas_error decodeVoIP( /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */ rtpTimeStamp = rtpTimeStamp / 16; } + if ( error != IVAS_ERR_OK || rtpdumpDepackerError != EVS_RTPDUMP_DEPACKER_NO_ERROR ) { fprintf( stderr, "failed to read first RTP packet\n" ); @@ -3186,6 +3219,7 @@ static ivas_error decodeVoIP( goto cleanup; } } + int16_t num_subframes; if ( ( error = IVAS_DEC_GetNumOrientationSubframes( hIvasDec, &num_subframes ) ) != IVAS_ERR_OK ) { @@ -3193,7 +3227,6 @@ static ivas_error decodeVoIP( goto cleanup; } - /* Head-tracking input simulation */ /* Head-tracking input simulation */ if ( arg.enableHeadRotation ) { @@ -3201,16 +3234,7 @@ static ivas_error decodeVoIP( if ( headRotReader == NULL ) { - for ( i = 0; i < num_subframes; i++ ) - { - Quaternions[i].w = -3.0f; - Quaternions[i].x = 0.0f; - Quaternions[i].y = 0.0f; - Quaternions[i].z = 0.0f; - Pos[i].x = 0.0f; - Pos[i].y = 0.0f; - Pos[i].z = 0.0f; - } + resetHeadRotation( num_subframes, Quaternions, Pos ); } else { @@ -3218,8 +3242,7 @@ static ivas_error decodeVoIP( { if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), - RotationFileReader_getFilePath( headRotReader ) ); + fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( headRotReader ) ); goto cleanup; } } @@ -3245,11 +3268,9 @@ static ivas_error decodeVoIP( for ( i = 0; i < num_subframes; i++ ) { - if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternions[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError %s while reading external orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), - RotationFileReader_getFilePath( externalOrientationFileReader ) ); + fprintf( stderr, "\nError %s while reading external orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( externalOrientationFileReader ) ); goto cleanup; } } @@ -3294,13 +3315,12 @@ static ivas_error decodeVoIP( else { auPtr = au; /* might have been set to RTP packet in prev call */ - rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, - &nextPacketRcvTime_ms, - &isAMRWB_IOmode, &frameTypeIndex, &qBit, - &auPtr, (uint16_t *) &auSize ); + rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSize ); + /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */ rtpTimeStamp = rtpTimeStamp / 16; } + if ( error == IVAS_ERR_END_OF_FILE || rtpdumpDepackerError == EVS_RTPDUMP_DEPACKER_EOF ) { /* finished reading */ @@ -3321,7 +3341,6 @@ static ivas_error decodeVoIP( break; } - /* decode and get samples */ while ( nSamplesRendered < nOutSamples ) { @@ -3485,6 +3504,7 @@ static ivas_error decodeVoIP( { fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 1 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -3522,10 +3542,9 @@ static ivas_error decodeVoIP( #endif } - int16_t nSamplesFlushed = 0; - /* decode and get samples */ + /* flush remaining audio */ if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -3541,7 +3560,7 @@ static ivas_error decodeVoIP( goto cleanup; } - /* Write ISm metadata to external file(s) */ + /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM ) @@ -3581,6 +3600,7 @@ static ivas_error decodeVoIP( { fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); diff --git a/apps/encoder.c b/apps/encoder.c index 9bf625bc972c3e94cff543cfe01b5b47f93ec185..2841683bba4744ccfff8b2fa38b93491eb23105b 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1198,7 +1198,6 @@ static bool parseCmdlIVAS_enc( ++i; } - /*-----------------------------------------------------------------* * Complexity Level *-----------------------------------------------------------------*/ @@ -2013,6 +2012,7 @@ static bool readBitrate( fprintf( stderr, "Error: cannot read the bitrate profile file\n\n" ); usage_enc(); + return false; } diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index d42da1b4228054c9f9db503821a9ebab1d86a9e7..04992e76b14b95ab40257b0510195dffe6dd9ff0 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -675,7 +675,7 @@ enum #define ECLVQ_GLOBAL_GAIN_FACTOR ( 20.0f * 127.0f / 90.0f ) #define ECLVQ_INV_GLOBAL_GAIN_FACTOR ( 1.0f / ( 20.0f * 127.0f / 90.0f ) ) -/* the currently defined configuration indexes are: +/* the defined configuration indexes are: 0: un-optimized using uniform 4 bit parameters (reserved) 1: optimized for 32 kbps target SNR 2: optimized for 32 kbps target bits @@ -963,12 +963,12 @@ typedef enum #define DIRAC_SLOT_NS 1250000L /* time duration of a time slot, 1.25ms (==DELAY_RENERER_NS/MAX_PARAM_SPATIAL_SUBFRAMES) */ #define DIRAC_SLOT_ENC_NS 5000000L -#define DIRAC_MONO_THRESH_SILENCE 3e4f -#define DIRAC_MONO_NORM_FACTOR 1e13f -#define DIRAC_MONO_ONE_ON_NORM_FACTOR (1.f / 1e13f) -#define DIRAC_MONO_MAX_THRESH 1e6f -#define DIRAC_MONO_MIN_THRESH 1e2f -#define DIRAC_MONO_FRAME_THRESH 15 /* 30ms */ +#define DIRAC_MONO_THRESH_SILENCE 3e4f +#define DIRAC_MONO_NORM_FACTOR 1e13f +#define DIRAC_MONO_ONE_ON_NORM_FACTOR (1.f / 1e13f) +#define DIRAC_MONO_MAX_THRESH 1e6f +#define DIRAC_MONO_MIN_THRESH 1e2f +#define DIRAC_MONO_FRAME_THRESH 15 /* 30ms */ typedef enum { @@ -992,8 +992,6 @@ typedef enum #define IVAS_SPAR_P_LOWERTRI ((IVAS_SPAR_MAX_CH - 1) * (IVAS_SPAR_MAX_CH - 2)) >> 1 #define IVAS_SPAR_MAX_C_COEFF (IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS) * ( IVAS_SPAR_MAX_DMX_CHS - 1) -#define IVAS_SPAR_HOA3_NP_CHS 8 /* number of higher order non-planar channels */ - #define SPAR_NUM_CODING_STRAT_BITS 3 /* AGC constants */ @@ -1068,21 +1066,13 @@ enum #define IVAS_DECORR_PARM_APD_TAU 20e-3f /* IVAS SBA PCA */ -#define IVAS_PCA_NB_SUBR 20 /* 80 -> 0.25 ms, 40 -> 0.5 ms... */ -#define IVAS_PCA_COV_THRES 3e-5f -#define IVAS_PCA_QUAT_EPS 1e-7f #define IVAS_PCA_QBITS 19 #define IVAS_PCA_N1 91 -#define IVAS_PCA_N1_EQ ( (IVAS_PCA_N1-1)/2 ) -#define IVAS_PCA_BIT_LEN ( 1 + ( IVAS_PCA_QBITS - 1 + IVAS_PCA_QBITS ) ) #define IVAS_PCA_INTERP 4 #define IVAS_PCA_N_SLOTS 40 #define IVAS_PCA_LEN_INTERP_Q ( IVAS_PCA_INTERP * IVAS_PCA_N_SLOTS ) #define IVAS_PCA_DELAY_CMP 24 #define IVAS_PCA_LEN_INTERP_EIG_DEC ( (IVAS_PCA_N_SLOTS+IVAS_PCA_DELAY_CMP)*16) -#define IVAS_PCA_THRES_MIN_DOT 0.8f -#define IVAS_PCA_THRES_MIN_DOT2 0.0f -#define IVAS_PCA_THRES_DIST_ALT 6.0f typedef enum { @@ -1124,6 +1114,7 @@ enum TOTAL_DECD_QUANT_STRATS }; + /*----------------------------------------------------------------------------------* * MASA constants *----------------------------------------------------------------------------------*/ @@ -1137,7 +1128,6 @@ enum #define MASA_MAXIMUM_DIRECTIONS 2 #define MASA_MAX_TRANSPORT_CHANNELS 2 - #define MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS 5 #define MASA_DELTA_AZI_DCT0 30 @@ -1185,8 +1175,6 @@ enum #define HR_MASA_ER_LEVELS 16 #define MAX_REDUCED_NBANDS 18 /* max number of subbands that is less than the default value 24 */ -#define LIMIT_ER_ELEVATION_ENC 4 -#define LIMIT_ER_SIMPLE_ENC 6 #define LIMIT_USE_COMMON 3 #define MASA_COHERENCE_TOLERANCE 0.1f @@ -1208,18 +1196,11 @@ enum #define MASA_LIMIT_IDX_AVG_AZI 4 #define MASA_NO_POINTS_EQUATOR 430 -#define MASA_NO_CIRCLES 121 -#define MASA_ASIN_OFFSET 0.0064471690266724975f -#define MASA_NTOT2_FAC 32768.00566947353f -#define MASA_ANGLE_AT_EQUATOR 0.012894427382667f -#define MASA_ANGLE_AT_EQUATOR_DEG 0.738796268264740f -#define MASA_INV_ANGLE_AT_EQUATOR_DEG 1.353553128183453f #define MASA_STEREO_MIN_BITRATE IVAS_24k4 #define MAXIMUM_OMASA_FREQ_BANDS 8 /* Corresponds to maximum number of coding bands at 32 kbps */ #define OMASA_STEREO_SW_CNT_MAX 100 #define MASA_BIT_REDUCT_PARAM 10 #define MASA_MAXIMUM_TWO_DIR_BANDS 24 -#define NBITS_HR_COH 4 #define OMASA_TDREND_MATCHING_GAIN 0.7943f #define OMASA_GAIN_EDIT_THR 0.06f /* OMASA gain change threshold */ #define OMASA_AZI_EDIT_THR 1.0f /* OMASA-DISC azimuth change threshold */ @@ -1291,6 +1272,7 @@ typedef enum #define MCMASA_MIN_SPEAKERS_SEPARATE_CENTER 4 + /*----------------------------------------------------------------------------------* * MCT constants *----------------------------------------------------------------------------------*/ @@ -1362,6 +1344,7 @@ typedef struct const int16_t (*beta)[2]; } HUFF_NODE_TABLE; + /*----------------------------------------------------------------------------------* * Parametric MC Constants *----------------------------------------------------------------------------------*/ @@ -1413,6 +1396,7 @@ typedef enum #define PARAM_MC_MDFT_NO_SLOTS 8 #define PARAM_MC_CLDFB_TO_MDFT_FAC 2 + /*----------------------------------------------------------------------------------* * LFE Coding Constants *----------------------------------------------------------------------------------*/ @@ -1570,7 +1554,6 @@ typedef enum } SFX_OpMode_t; - /*----------------------------------------------------------------------------------* * Reverberator constants *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index c48931391c5a29360c9f598e323bd8651a1fd9d4..d9ffa5159a696ad6c5144f431fd38908bc88e7a7 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -158,6 +158,7 @@ ivas_error ivas_dirac_config( hConfig->nbands = 5; spar_dirac_split_band = 0; } + hConfig->enc_param_start_band = 0; hConfig->dec_param_estim = FALSE; if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) /* skip for MASA decoder */ @@ -326,7 +327,7 @@ void ivas_get_dirac_sba_max_md_bits( int16_t *metadata_max_bits, int16_t *qmetadata_max_bit_req, const int16_t nbands, - IVAS_FORMAT ivas_format ) + const IVAS_FORMAT ivas_format ) { if ( sba_total_brate <= IVAS_13k2 ) { @@ -383,6 +384,7 @@ void ivas_get_dirac_sba_max_md_bits( *bits_frame_nominal = (int16_t) ( sba_total_brate / FRAMES_PER_SEC ); *metadata_max_bits = MAX16B; /* no limit */ } + *metadata_max_bits = (int16_t) min( (float) MAX16B, ceilf( (float) *metadata_max_bits * nbands / 5 ) ); *qmetadata_max_bit_req = QMETADATA_MAXBIT_REQ_SBA >> 1; @@ -397,12 +399,13 @@ void ivas_get_dirac_sba_max_md_bits( *------------------------------------------------------------------------*/ ivas_error ivas_dirac_sba_config( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - int16_t *element_mode, /* i/o: element mode of the core coder */ - int32_t sba_total_brate, /* i : SBA total bitrate */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const int16_t nbands, /* i : number of frequency bands */ - IVAS_FORMAT ivas_format ) + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ + int16_t *element_mode, /* i/o: element mode of the core coder */ + int32_t sba_total_brate, /* i : SBA total bitrate */ + const int16_t sba_order, /* i : Ambisonic (SBA) order */ + const int16_t nbands, /* i : number of frequency bands */ + const IVAS_FORMAT ivas_format /* i : IVAS format */ +) { int16_t nbands_coded; int16_t hodirac_flag; diff --git a/lib_com/ivas_entropy_coder_common.c b/lib_com/ivas_entropy_coder_common.c index 015fab85e9dbeae9b10b0084e8a5e385bb8baac3..f6bc76ed1c532339002736951e61c0f057313827 100644 --- a/lib_com/ivas_entropy_coder_common.c +++ b/lib_com/ivas_entropy_coder_common.c @@ -78,7 +78,7 @@ void ivas_wrap_arround( * get cumulative frequency model *-----------------------------------------------------------------------------------------*/ -void ivas_get_cum_freq_model( +static void ivas_get_cum_freq_model( const int16_t *pFreq_model, const int16_t length, int16_t *pCum_freq_model ) @@ -102,7 +102,7 @@ void ivas_get_cum_freq_model( * Map the ivas_arith_pred_r_consts and ivas_huff_pred_r_consts tables *-----------------------------------------------------------------------------------------*/ -int16_t ivas_map_num_pred_r_to_idx( +static int16_t ivas_map_num_pred_r_to_idx( const int16_t num_quant_points_pred_r, const int16_t active_w_flag ) { @@ -160,7 +160,7 @@ int16_t ivas_map_num_pred_r_to_idx( * Map the ivas_arith_drct_r_consts and ivas_huff_drct_r_consts tables *-----------------------------------------------------------------------------------------*/ -int16_t ivas_map_num_drct_r_to_idx( +static int16_t ivas_map_num_drct_r_to_idx( const int16_t num_quant_points_drct_r ) { int16_t drct_r_to_idx = -1; @@ -182,6 +182,7 @@ int16_t ivas_map_num_drct_r_to_idx( assert( !"Forbidden value for DRCT quantization strategy index" ); break; } + return drct_r_to_idx; } @@ -192,7 +193,7 @@ int16_t ivas_map_num_drct_r_to_idx( * Map the ivas_arith_decd_r_consts and ivas_huff_decd_r_consts tables *-----------------------------------------------------------------------------------------*/ -int16_t ivas_map_num_decd_r_to_idx( +static int16_t ivas_map_num_decd_r_to_idx( const int16_t num_quant_points_decd_r ) { int16_t decd_r_to_idx = -1; diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index 589552874a12b8e5c9ba24cfdf408b376738c6d4..fcc79ffefc82f02667763d2a2f8f7950780a1baa 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -148,7 +148,7 @@ ivas_error ivas_ism_config( bits_element[n_ISms - 1] += bits_ism % n_ISms; bitbudget_to_brate( bits_element, element_brate, n_ISms ); - /* count ISm common signaling bits */ + /* count ISM common signaling bits */ if ( hIsmMeta != NULL ) { nb_bits_metadata[0] += n_ISms * ISM_METADATA_FLAG_BITS + nchan_ism; @@ -500,11 +500,11 @@ int16_t ism_quant_meta( /*! r: dequantized value */ float ism_dequant_meta( - const int16_t idx, /* i : quantizer index */ - const float borders[], /* i : level borders */ - const float q_step, /* i : quantization step */ - const float q_step_border, /* i : quantization step at the border */ - const int16_t cbsize /* i : codebook size */ + const int16_t idx, /* i : quantizer index */ + const float borders[], /* i : level borders */ + const float q_step, /* i : quantization step */ + const float q_step_border, /* i : quantization step at the border */ + const int16_t cbsize /* i : codebook size */ ) { int16_t idx_start; diff --git a/lib_com/ivas_limiter.c b/lib_com/ivas_limiter.c index 97922af9c6ccab527bd94e6a5ecc0dabac1471c1..3f5217ed99220bb325ebb8eff6cf9f3217e7e521 100644 --- a/lib_com/ivas_limiter.c +++ b/lib_com/ivas_limiter.c @@ -127,6 +127,7 @@ ivas_error ivas_limiter_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Limiter handle\n" ) ); } + hLimiter->sampling_rate = sampling_rate; hLimiter->gain = 1.f; hLimiter->release_heuristic = 0.f; @@ -337,7 +338,6 @@ void limiter_process( if ( apply_limiting ) { - /* 99% time constants of the gain curve * * The denominator of the second argument determines after how many diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 7e6aba8645aa81a0ef07bb3bceb90e67559c6a67..d93ebefa9a0e0029482bf039505781d3fc73da6e 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -49,8 +49,14 @@ *---------------------------------------------------------------*/ #define MASA_EXTRA_BAND_META_BITS 40 - -#define MASA_SMALL_INC_META_BITS 10 +#define MASA_SMALL_INC_META_BITS 10 + +#define MASA_NO_CIRCLES 121 +#define MASA_ASIN_OFFSET 0.0064471690266724975f +#define MASA_NTOT2_FAC 32768.00566947353f +#define MASA_ANGLE_AT_EQUATOR 0.012894427382667f +#define MASA_ANGLE_AT_EQUATOR_DEG 0.738796268264740f +#define MASA_INV_ANGLE_AT_EQUATOR_DEG 1.353553128183453f /*--------------------------------------------------------------- diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com.c index 4042dd959b6e5a5e0ce4c18ca96f9685c118933e..9c5d183e313309faa55c762e47182f457ed303d2 100644 --- a/lib_com/ivas_omasa_com.c +++ b/lib_com/ivas_omasa_com.c @@ -392,7 +392,7 @@ void ivas_combined_format_brate_sanity( * * ---------------------------------------------------------------*/ -/*!r : number of bits for ISM ratio index */ +/*! r: number of bits for ISM ratio index */ int16_t bits_index_ism_ratio( const int16_t nchan_ism /* i : number of objects */ ) diff --git a/lib_com/ivas_pca_tools.c b/lib_com/ivas_pca_tools.c index 0c54551bee4be7927efdfd136b8f11bf4b32c039..aa67a583fb12ab64a5b9ba63d3384026e7e8191b 100644 --- a/lib_com/ivas_pca_tools.c +++ b/lib_com/ivas_pca_tools.c @@ -44,6 +44,14 @@ #include "prot.h" +/*-----------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------*/ + +#define IVAS_PCA_QUAT_EPS 1e-7f +#define IVAS_PCA_N1_EQ ( ( IVAS_PCA_N1 - 1 ) / 2 ) + + /*---------------------------------------------------------------------* * eye_matrix() * diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index e0dbc245d7330874fcf609d890e9674f7a56d0d7..2d8948fe5c52dd7a462701b373a1ef0683bd1ce1 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -253,7 +253,7 @@ ivas_error ivas_compute_core_buffers( /*! r: number of clipped samples */ uint32_t ivas_syn_output( - float *synth[], /* i/o: float synthesis signal */ + float *synth[], /* i/o: float synthesis signal */ const int16_t output_frame, /* i : output frame length (one channel) */ const int16_t n_channels, /* i : number of output channels */ int16_t *synth_out /* o : integer 16 bits synthesis signal */ @@ -637,9 +637,9 @@ void set_transient_stereo( /*! r: preliminary flag to force ACELP */ int16_t transient_analysis( - TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */ - const float cor_map_LT[], /* i : LT correlation map */ - const float multi_harm_limit /* i : multi harminic threshold */ + TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */ + const float cor_map_LT[], /* i : LT correlation map */ + const float multi_harm_limit /* i : multi harminic threshold */ ); void ivas_post_proc( @@ -704,8 +704,8 @@ void output_debug_mode_info_dec( const int16_t output_frame, float pitch_buf[CPE_CHANNELS][NB_SUBFR16k] ); -#endif +#endif /*! r: flag indicating a valid bitrate */ int16_t is_IVAS_bitrate( const int32_t ivas_total_brate /* i : IVAS total bitrate */ @@ -760,29 +760,31 @@ int16_t get_igf_startline( ); float rand_triangular_signed( - int16_t *seed ); + int16_t *seed +); + Word16 matrix_product_fx( - const Word32 *X_fx, /* i : left hand matrix Qx*/ - const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ - const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ - const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ - const Word32 *Y_fx, /* i : right hand matrix Qy*/ - const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ - const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ - const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ - Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Qx + Qy - 31*/ + const Word32 *X_fx, /* i : left hand matrix Qx*/ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y_fx, /* i : right hand matrix Qy*/ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Qx + Qy - 31*/ ); Word16 matrix_product_q30_fx( - const Word32 *X_fx, /* i : left hand matrix Q31*/ - const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ - const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ - const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ - const Word32 *Y_fx, /* i : right hand matrix Q25*/ - const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ - const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ - const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ - Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Q30*/ + const Word32 *X_fx, /* i : left hand matrix Q31*/ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y_fx, /* i : right hand matrix Q25*/ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Q30*/ ); @@ -809,7 +811,7 @@ ivas_error ivas_jbm_dec_tc( ivas_error ivas_jbm_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of samples wanted */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ @@ -841,7 +843,7 @@ void ivas_dec_prepare_renderer( ); ivas_error ivas_jbm_dec_set_discard_samples( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ + Decoder_Struct *st_ivas /* i/o: main IVAS decoder structure */ ); void ivas_jbm_dec_get_adapted_linear_interpolator( @@ -1009,7 +1011,7 @@ void ivas_ism_reset_metadata_handle_dec( ivas_error ivas_ism_enc( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *data[], /* i : input signal [channels][samples] */ + float *data[], /* i : input signal [channels][samples] */ const int16_t input_frame, /* i : input frame length per channel */ int16_t *nb_bits_metadata, /* i : number of metadata bits */ const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ @@ -1076,7 +1078,7 @@ void ivas_param_ism_enc_close( ); void ivas_ism_metadata_close( - ISM_METADATA_HANDLE hIsmMetaData[], /* i/o : object metadata handles */ + ISM_METADATA_HANDLE hIsmMetaData[], /* i/o: object metadata handles */ const int16_t first_idx /* i : index of first handle to deallocate */ ); @@ -1139,9 +1141,9 @@ void ivas_ism_param_dec_tc_gain_ajust( #endif void ivas_param_ism_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *output_f[] /* o : rendered time signal */ ); @@ -2953,7 +2955,6 @@ ivas_error stereo_memory_enc( float *tdm_last_ratio, /* o : TD stereo last ratio */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t nchan_transport /* i : number transport chans */ - ); ivas_error stereo_memory_dec( @@ -3468,8 +3469,7 @@ void ivas_dirac_param_est_enc( const int16_t nchan_fb_in, int16_t *mono_frame_count, int16_t *dirac_mono_flag - ); - +); void ivas_sba_config( const int32_t sba_total_brate, /* i : SBA total bitrate */ @@ -3537,7 +3537,7 @@ int16_t ivas_sba_spar_sid_bitlen( void ivas_sba_get_spar_hoa_ch_ind( const int16_t num_md_chs, /* i : number of MD channels */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] + int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] /* o : channel indexes */ ); /*! r: flag indicating to code SPAR HOA MD for all bands */ @@ -3661,21 +3661,21 @@ void ivas_get_dirac_sba_max_md_bits( int16_t *metadata_max_bits, int16_t *qmetadata_max_bit_req, const int16_t nbands, - IVAS_FORMAT ivas_format + const IVAS_FORMAT ivas_format ); ivas_error ivas_dirac_sba_config( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ int16_t *element_mode, /* o : element mode of the core coder */ int32_t sba_total_brate, /* i : SBA total bitrate */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ + const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int16_t nbands, /* i : number of frequency bands */ - IVAS_FORMAT ivas_format + const IVAS_FORMAT ivas_format /* i : IVAS format */ ); ivas_error ivas_dirac_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_configopen /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + const DIRAC_CONFIG_FLAG flag_configopen /* i : Flag determining if we open or reconfigure the DirAC decoder */ ); void ivas_dirac_dec_close( @@ -3711,9 +3711,9 @@ void ivas_dirac_dec_set_md_map( void ivas_dirac_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of sampels rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *output_f[] /* o : rendered time signal */ ); @@ -3751,7 +3751,6 @@ void computeDiffuseness( float *diffuseness ); - void ivas_dirac_dec_get_response( const int16_t azimuth, const int16_t elevation, @@ -3812,9 +3811,9 @@ void ivas_mc_paramupmix_dec_digest_tc( void ivas_mc_paramupmix_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *input_f[], /* i : core-coder transport channels */ float *output_f[] /* i/o: synthesized core-coder transport channels */ ); @@ -3887,9 +3886,9 @@ void ivas_param_mc_dec_prepare_renderer( void ivas_param_mc_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *output_f[] /* o : rendered time signal */ ); @@ -3996,24 +3995,24 @@ int16_t computeMixingMatricesResidual( /*! r: error or success */ int16_t svd( - float InputMatrix[][MAX_OUTPUT_CHANNELS], /* i : matrix to be decomposed (M) */ - float singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* o : left singular vectors (U) */ - float singularValues[MAX_OUTPUT_CHANNELS], /* o : singular values vector (S) */ - float singularVectors_Right[][MAX_OUTPUT_CHANNELS], /* o : right singular vectors (V) */ - const int16_t nChannelsL, /* i : number of rows in the matrix to be decomposed */ - const int16_t nChannelsC /* i : number of columns in the matrix to be decomposed */ + float InputMatrix[][MAX_OUTPUT_CHANNELS], /* i : matrix to be decomposed (M) */ + float singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* o : left singular vectors (U) */ + float singularValues[MAX_OUTPUT_CHANNELS], /* o : singular values vector (S) */ + float singularVectors_Right[][MAX_OUTPUT_CHANNELS], /* o : right singular vectors (V) */ + const int16_t nChannelsL, /* i : number of rows in the matrix to be decomposed */ + const int16_t nChannelsC /* i : number of columns in the matrix to be decomposed */ ); ivas_error ivas_dirac_dec_output_synthesis_cov_open( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: handle for the covariance synthesis state */ - const int16_t max_band_decorr, /* i : uppermost frequency band where decorrelation is applied */ - const int16_t interp_length, /* i : length for interpolating the mixing matrices in time slots */ - const int16_t num_param_bands, /* i : number of parameter bands */ - const int16_t num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ - const int16_t nchan_in, /* i : number of input (transport) channels */ - const int16_t nchan_out, /* i : number of output channels */ - const float *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */ + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ + DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: handle for the covariance synthesis state */ + const int16_t max_band_decorr, /* i : uppermost frequency band where decorrelation is applied */ + const int16_t interp_length, /* i : length for interpolating the mixing matrices in time slots */ + const int16_t num_param_bands, /* i : number of parameter bands */ + const int16_t num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation) */ + const int16_t nchan_in, /* i : number of input (transport) channels */ + const int16_t nchan_out, /* i : number of output channels */ + const float *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */ ); void ivas_dirac_dec_output_synthesis_get_interpolator( @@ -4022,33 +4021,33 @@ void ivas_dirac_dec_output_synthesis_get_interpolator( ); void ivas_dirac_dec_output_synthesis_cov_init( - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: pointer to the state of the covariance synthesis */ - const int16_t nchan_in, /* i : number of input (tranport) channels */ - const int16_t nchan_out, /* i : number of output channels */ - const int16_t n_param_bands, /* i : number of total parameter bands */ - const int16_t n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ + DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: pointer to the state of the covariance synthesis */ + const int16_t nchan_in, /* i : number of input (tranport) channels */ + const int16_t nchan_out, /* i : number of output channels */ + const int16_t n_param_bands, /* i : number of total parameter bands */ + const int16_t n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ ); void ivas_dirac_dec_output_synthesis_cov_close( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i : handle for the covariance synthesis parameters */ - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */ + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i : handle for the covariance synthesis parameters */ + DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */ ); void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( - float *RealBuffer, /* i : input channel filter bank samples (real part) */ - float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ - float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (real part) */ - float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (imaginary part) */ - const int16_t param_band, /* i : parameter band */ - PARAM_MC_DEC_HANDLE hParamMC, /* i : handle to Parametric MC state */ - const int16_t nchan_in /* i : number of input channels */ + float *RealBuffer, /* i : input channel filter bank samples (real part) */ + float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ + float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (real part) */ + float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (imaginary part) */ + const int16_t param_band, /* i : parameter band */ + PARAM_MC_DEC_HANDLE hParamMC, /* i : handle to Parametric MC state */ + const int16_t nchan_in /* i : number of input channels */ ); void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( float *Cldfb_RealBuffer_in, /* i : input channel filter bank samples (real part) */ float *Cldfb_ImagBuffer_in, /* i : input channel filter bank samples (imaginary part) */ - float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (real part) */ - float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (imaginary part) */ + float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (real part) */ + float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (imaginary part)*/ float *mixing_matrix[], /* i : parameter band wise mixing matrices (direct part) */ float *mixing_matrix_res[], /* i : parameter band wise mixing matrices (residual part) */ const uint16_t slot_idx_sfr, /* i : time slot index for the current slot within the current subframe */ @@ -4136,7 +4135,7 @@ ivas_error ivas_sba_linear_renderer( float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t output_frame, /* i : output frame length per channel */ const int16_t nchan_in, /* i : number of input ambisonics channels */ - const int16_t nchan_ism, /* i : number of objects */ + const int16_t nchan_ism, /* i : number of objects */ const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup /* i : output format setup */ ); @@ -4253,7 +4252,7 @@ int16_t ivas_get_sba_num_TCs( void ivas_spar_set_bitrate_config( ivas_spar_md_com_cfg *pSpar_md_cfg, /* i/o: SPAR MD config. handle */ const int16_t table_idx, /* i : config. table index */ - const int16_t num_bands, /* i : number of bands */ + const int16_t num_bands, /* i : number of bands */ const int16_t dirac2spar_md_flag, const int16_t enc_flag, const int16_t pca_flag, @@ -4348,9 +4347,9 @@ void ivas_sba_dec_digest_tc( ivas_error ivas_sba_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *output_f[] /* o : rendered time signal */ ); @@ -4545,7 +4544,7 @@ ivas_error ivas_spar_covar_enc_open( const int32_t input_Fs, /* i : input sampling rate */ const int16_t nchan_inp, /* i : number of input channels */ const COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC */ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); void ivas_spar_covar_enc_close( @@ -4839,25 +4838,6 @@ void ivas_wrap_arround( const int16_t length ); -void ivas_get_cum_freq_model( - const int16_t *pFreq_model, - const int16_t length, - int16_t *pCum_freq_model -); - -int16_t ivas_map_num_pred_r_to_idx( - const int16_t num_quant_points_pred_r, - const int16_t active_w_flag -); - -int16_t ivas_map_num_drct_r_to_idx( - const int16_t num_quant_points_drct_r -); - -int16_t ivas_map_num_decd_r_to_idx( - const int16_t num_quant_points_decd_r -); - /* Quantization utilities */ void ivas_quantise_real_values( const float *values, @@ -5113,7 +5093,7 @@ void masa_sample_rate_band_correction( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ const uint8_t maxBand, /* i : max band */ uint8_t is_encoder, /* i : signals if called at encoder */ - MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ + MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ ); void invdct4_transform( @@ -5161,7 +5141,7 @@ void ivas_binaural_hrtf_close( ); void ivas_init_binaural_hrtf( - HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ + HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ ); ivas_error ivas_allocate_binaural_hrtf( @@ -5186,7 +5166,7 @@ void ivas_binaural_cldfb_sf( void ivas_binRenderer( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i : pose correction data handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ const int16_t numTimeSlots, /* i : number of time slots to process */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG @@ -5248,7 +5228,7 @@ void ivas_param_mc_mc2sba_cldfb( float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ const int16_t nBands, /* i : number of synth CLDFB bands */ - const float gain_lfe /* i : gain applied to LFE */ + const float gain_lfe /* i : gain applied to LFE */ ); void ivas_ism2sba_sf( @@ -5292,7 +5272,6 @@ void ivas_ls_setup_conversion_close( LSSETUP_CONVERSION_HANDLE *hLsSetUpConversion /* i/o: LS converter handle */ ); - void ivas_ls_setup_conversion( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ const int16_t input_chans, /* i : number of input channels to the renderer */ @@ -5427,8 +5406,8 @@ void lls_interp_n( void computeReferencePower_enc( const int16_t *band_grouping, /* i : Band grouping for estimation */ - float Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */ - float Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */ + float Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */ + float Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */ float *reference_power, /* o : Estimated power */ const int16_t enc_param_start_band, /* i : first band to process */ const int16_t num_freq_bands, /* i : Number of frequency bands */ @@ -5443,9 +5422,8 @@ ivas_error ivas_mono_dmx_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); - void ivas_mono_dmx_renderer_close( - MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ + MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/o: Mono downmix structure */ ); void ivas_ism_mono_dmx( @@ -5593,9 +5571,9 @@ ivas_error ivas_osba_data_open( ivas_error ivas_osba_dirac_td_binaural_jbm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *output_f[] /* o : rendered time signal */ ); diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 7d84b0a739b693fa261eb70795f245ac8097c545..e72b18f723aeb20180b27d4787b0c79c4317a413 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -1467,7 +1467,7 @@ const int16_t remix_order_set[1][DIRAC_MAX_ANA_CHANS] = { /* WYZX --> WYXZ... */ const int16_t HOA_keep_ind[IVAS_SPAR_MAX_FB_IN_CHAN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15}; const int16_t HOA_keep_ind_spar[IVAS_SPAR_MAX_CH] = {0, 1, 2, 3, 4, 8, 9, 10, 10, 10, 10}; -const int16_t HOA_keep_ind_spar512[IVAS_SPAR_MAX_CH] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; +const int16_t HOA_keep_ind_spar512[IVAS_SPAR_MAX_CH] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; /*----------------------------------------------------------------------* diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index ea284a6abf6104de3a530239caaa2e1ab7a56b2f..fc7f40ce2914bae1483c7cf4a6fdde59cb500b0a 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -223,11 +223,11 @@ int16_t ivas_sba_get_nchan_metadata( * *-------------------------------------------------------------------*/ -/*! r: flag indicating to code SPAR HOA MD for all bands */ void ivas_sba_get_spar_hoa_ch_ind( - const int16_t num_md_chs, /* i : number of MD channels */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] ) + const int16_t num_md_chs, /* i : number of MD channels */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] /* o : channel indexes */ +) { int16_t ch; const int16_t *hoa_ind; diff --git a/lib_com/prot.h b/lib_com/prot.h index 18b6c30c5c8e96896c5cdd24b425549b85eb75e0..afb0594efc6b11c8ff5fe2b47dec8c50136c305e 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -735,10 +735,10 @@ 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 */ + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ const int16_t flag_binaural_split_coded /* i : split rendering on/off flag */ ); diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 4b2c4c7d0730f215a9a9e4e5be207181a2f10b0b..716aa5284ed23db0f5a5e72e4bbb88aff2ab67af 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -53,16 +53,18 @@ *------------------------------------------------------------------------*/ #define REVERB_INPUT_DOWNMIX_CHANNELS ( 11 ) + /* Downmix table for sparse frequency domain reverberator */ -const float dmxmtx_table[BINAURAL_CHANNELS][REVERB_INPUT_DOWNMIX_CHANNELS] = { +static const float dmxmtx_table[BINAURAL_CHANNELS][REVERB_INPUT_DOWNMIX_CHANNELS] = { { 1.0f, 0.0f, 0.70709997f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.70709997f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f }, }; + /*------------------------------------------------------------------------- * ivas_binRenderer_filterModule() * - * + * Filtering module for FastConv binaural renderer *-------------------------------------------------------------------------*/ static void ivas_binRenderer_filterModule( @@ -352,7 +354,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } } - hBinRenderer->hBinRenConvModule = hBinRenConvModule; return IVAS_ERR_OK; @@ -481,7 +482,7 @@ ivas_error ivas_allocate_binaural_hrtf( /*-------------------------------------------------------------------------* * ivas_binaural_hrtf_open() * - * + * Allocate and initialize HRTF FastConv binaural renderer handle *-------------------------------------------------------------------------*/ static ivas_error ivas_binaural_hrtf_open( @@ -781,7 +782,7 @@ static void ivas_binaural_obtain_DMX( /*------------------------------------------------------------------------- * ivas_rend_openCldfbRend() * - * Allocate and initialize CLDFB fast conv renderer handle + * Allocate and initialize CLDFB fastconv renderer handle *------------------------------------------------------------------------*/ ivas_error ivas_rend_openCldfbRend( @@ -999,6 +1000,7 @@ ivas_error ivas_binRenderer_open( if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { pRoomAcoustics = ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ? &( st_ivas->hRenderConfig->roomAcoustics ) : NULL; + if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, @@ -1577,8 +1579,8 @@ void ivas_binaural_cldfb_sf( *-------------------------------------------------------------------------*/ void ivas_binRenderer( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ - const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ + const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i : pose correction data handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ const int16_t numTimeSlots, /* i : number of time slots to render */ #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index dea4a372110ab591c868549e88e0eba7b6e734d1..bfa29f727b8287778735296b5707b6f03b58249c 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -83,8 +83,6 @@ ivas_error ivas_cpe_dec( int32_t cpe_brate; int32_t element_brate_ref; - error = IVAS_ERR_OK; - push_wmops( "ivas_cpe_dec" ); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -188,7 +186,6 @@ ivas_error ivas_cpe_dec( } else { - /* Note: This only works for stereo operation. If DTX would be applied for multiple CPEs a different bitrate signaling is needed */ if ( ivas_total_brate <= IVAS_SID_5k2 ) { stereo_dft_config( hConfigDft, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); @@ -598,7 +595,7 @@ ivas_error ivas_cpe_dec( #endif pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -621,8 +618,6 @@ ivas_error create_cpe_dec( ivas_error error; int32_t cpe_brate; - error = IVAS_ERR_OK; - /*-----------------------------------------------------------------* * Allocate CPE handle *-----------------------------------------------------------------*/ @@ -898,7 +893,7 @@ ivas_error create_cpe_dec( st_ivas->hCPE[cpe_id] = hCPE; - return error; + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index cfc4b0bc308c94f2b0cb9fc2f994a0f89d8ca291..7765d49a281637ddb73ac4e84275d8423890084b 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -53,8 +53,8 @@ *-----------------------------------------------------------------------*/ static ivas_error ivas_dirac_dec_config_internal( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_config_inp /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const DIRAC_CONFIG_FLAG flag_config_inp /* i : Flag determining if we open or reconfigure the DirAC decoder */ ) { DIRAC_DEC_HANDLE hDirAC; @@ -110,8 +110,8 @@ static ivas_error ivas_dirac_dec_config_internal( static ivas_error ivas_dirac_rend_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const DIRAC_CONFIG_FLAG flag_config_inp, /* i : Flag determining if we open or reconfigure the DirAC decoder */ const int16_t dec_param_estim_old ) { DIRAC_DEC_HANDLE hDirAC; @@ -750,8 +750,8 @@ static ivas_error ivas_dirac_rend_config( *-------------------------------------------------------------------------*/ ivas_error ivas_dirac_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_config_inp /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const DIRAC_CONFIG_FLAG flag_config_inp /* i : Flag determining if we open or reconfigure the DirAC decoder */ ) { ivas_error error; @@ -903,9 +903,8 @@ ivas_error ivas_dirac_dec_config( ivas_dirac_dec_get_frequency_axis( frequency_axis, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSpatParamRendCom->num_freq_bands ); - if ( ( error = ivas_dirac_dec_decorr_open( - &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, frequency_axis, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, + DIRAC_SYNTHESIS_PSD_LS, frequency_axis, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -1542,12 +1541,12 @@ void ivas_dirac_dec_set_md_map( *------------------------------------------------------------------------*/ void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -2480,6 +2479,7 @@ void ivas_dirac_dec_render_sf( } } } + hSpatParamRendCom->slots_rendered += hSpatParamRendCom->subframe_nbslots[subframe_idx]; hSpatParamRendCom->subframes_rendered++; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 0d3610065b7597d8d40e52eb6a0179075f70b516..03cba849d4dcd89dc75647a2cd6e19941b27f9e5 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -58,7 +58,7 @@ static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); /*-------------------------------------------------------------------* * ivas_set_audio_config_from_sba_order() * - * + * Set audio configuration from the SBA order *-------------------------------------------------------------------*/ /*! r: audio configuration */ @@ -464,7 +464,7 @@ ivas_error ivas_dec_setup( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - int16_t k, idx, num_bits_read; + int16_t k, n, idx, num_bits_read; int16_t nchan_ism, element_mode_flag; Decoder_State *st; int32_t ivas_total_brate; @@ -675,14 +675,11 @@ ivas_error ivas_dec_setup( /*correct number of CPEs for discrete ISM coding*/ if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - { - int16_t n; - - n = st_ivas->nchan_transport + st_ivas->nchan_ism; - st_ivas->nCPE = ( n + 1 ) >> 1; - } + n = st_ivas->nchan_transport + st_ivas->nchan_ism; + st_ivas->nCPE = ( n + 1 ) >> 1; } } + if ( ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ) == ISM_SBA_MODE_DISC ) { st_ivas->ism_mode = ISM_SBA_MODE_DISC; @@ -895,7 +892,7 @@ ivas_error ivas_dec_setup( *-------------------------------------------------------------------*/ static ivas_error ivas_read_format( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ int16_t *num_bits_read /* o : number of IVAS signaling bits read from the bitstream */ ) { @@ -1541,6 +1538,7 @@ ivas_error ivas_init_decoder( ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); } + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) @@ -1594,6 +1592,7 @@ ivas_error ivas_init_decoder( /* if we start in ISM_MODE_NONE in MASA_ISM, that appears as normal MASA, but we may change to a mode with ISMs */ st_ivas->ism_extmeta_active = -1; st_ivas->ism_extmeta_cnt = 0; + if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; @@ -1701,12 +1700,8 @@ ivas_error ivas_init_decoder( if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - { - int16_t n_all; - - n_all = st_ivas->nchan_transport + st_ivas->nchan_ism; - st_ivas->nCPE = ( n_all + 1 ) >> 1; - } + n = st_ivas->nchan_transport + st_ivas->nchan_ism; + st_ivas->nCPE = ( n + 1 ) >> 1; st_ivas->element_mode_init = IVAS_CPE_MDCT; } @@ -2054,7 +2049,6 @@ ivas_error ivas_init_decoder( } #endif - /*-----------------------------------------------------------------* * Allocate and initialize HP20 filter memories *-----------------------------------------------------------------*/ @@ -2096,7 +2090,6 @@ ivas_error ivas_init_decoder( return error; } } - /* ParamISM is handled separately from other common config */ else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) { @@ -2392,7 +2385,6 @@ ivas_error ivas_init_decoder( st_ivas->p_output_f[n] = NULL; } - return error; } @@ -3211,7 +3203,7 @@ static ivas_error doSanityChecks_IVAS( { return IVAS_ERROR( IVAS_ERR_INVALID_FORCE_MODE, "Incorrect debug configuration: Cannot force CLDFB renderer in combination with TD renderer HRTF file" ); } -#endif +#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 3164218b41bd57525569775acd208ae842e39088..7c1396339660422df4c1588c212cc65b8d863c10 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -59,8 +59,6 @@ void ivas_ism_dtx_dec( Decoder_State *st; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - - nchan_ism_prev = st_ivas->nchan_ism; if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 ) diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 1a1e4161d4d923b2853d0df30f46308240ec037e..bc2a62a5ec2926393a1e17df0bda297d03639055 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -205,6 +205,7 @@ ivas_error ivas_ism_metadata_dec( /*----------------------------------------------------------------* * Read ISM common signaling *----------------------------------------------------------------*/ + if ( ism_mode == ISM_SBA_MODE_DISC ) { /* number of objects was read in ivas_dec_setup() */ @@ -448,6 +449,7 @@ ivas_error ivas_ism_metadata_dec( hIsmMetaData->last_true_elevation = hIsmMetaData->elevation; } } + /* save number of metadata bits read */ if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) { @@ -787,6 +789,7 @@ static void decode_angle_indices( nbits_diff_angle1++; } } + idx_angle1 = angle->last_angle1_idx + sgn * diff; } @@ -935,6 +938,7 @@ static int16_t decode_radius( nbits_diff_radius++; } } + idx_radius = *last_radius_idx + sgn * diff; } @@ -1006,7 +1010,7 @@ void ivas_ism_metadata_sid_dec( if ( !bfi ) { /*----------------------------------------------------------------* - * ISm common signaling + * ISM common signaling *----------------------------------------------------------------*/ /* number of objects was already read in ivas_ism_get_dtx_dec() */ diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index a5a6f90f02cc859148455d9167175498198daf13..62c0fed1ccf94a23fb803b743007d39a122a66da 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -199,9 +199,9 @@ static void ivas_param_ism_collect_slot( static void ivas_param_ism_compute_mixing_matrix( - const int16_t nchan_ism, /* i : number of ISM channels */ - PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ - ISM_DTX_DATA_DEC hISMDTX, /* i : ISM DTX handle */ + const int16_t nchan_ism, /* i : number of ISM channels */ + PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ + ISM_DTX_DATA_DEC hISMDTX, /* i : ISM DTX handle */ float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN], const int16_t nchan_transport, const int16_t nchan_out_woLFE, @@ -1052,7 +1052,6 @@ void ivas_ism_param_dec_tc_gain_ajust( #endif float *p_data_f[] /* i : synthesized core-coder transport channels/DirAC output*/ ) - { int16_t i; float gain, ene_tc, ene_sum, grad; @@ -1068,10 +1067,12 @@ void ivas_ism_param_dec_tc_gain_ajust( ene_sum += ( p_data_f[0][i] + p_data_f[1][i] ) * ( p_data_f[0][i] + p_data_f[1][i] ); /* (L+R)*(L+R) */ } gain = sqrtf( ene_tc / ( ene_sum + EPSILON ) ); + if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 ) { /* Smoothing */ gain = 0.75f * gain + 0.25f * last_gain; + /* 10ms ramp */ grad = ( gain - last_gain ) / (float) nFadeLength; /* slope between two consecutive gains, 480 samples length */ for ( i = 0; i < ( nFadeLength ); i++ ) @@ -1203,11 +1204,11 @@ static void ivas_ism_param_dec_render_sf( *-------------------------------------------------------------------------*/ void ivas_param_ism_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t ch, slots_to_render, first_sf, last_sf, subframe_idx; @@ -1322,7 +1323,6 @@ void ivas_param_ism_params_to_masa_param_mapping( hSpatParamRendCom = st_ivas->hSpatParamRendCom; hMasaIsmData = st_ivas->hMasaIsmData; nBins = hSpatParamRendCom->num_freq_bands; - if ( st_ivas->hISMDTX.dtx_flag ) { float energy_ratio; diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 34d528b0e3d8687e9f6a0ee67a505b3505aed97e..19efc65a0aef6adf5db5b3ad6c0a08077dac5b47 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -181,6 +181,7 @@ ivas_error ivas_masa_decode( byteBuffer = st->bit_stream[( st->next_bit_pos )--]; byteBuffer = st->bit_stream[( st->next_bit_pos )--]; *nb_bits_read += MASA_HEADER_BITS; + /* read number of directions */ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; ( *nb_bits_read )++; @@ -291,6 +292,7 @@ ivas_error ivas_masa_decode( ( *nb_bits_read ) += ISM_METADATA_INACTIVE_FLAG_BITS; } } + st_ivas->flag_omasa_brate = 0; if ( st_ivas->nchan_ism >= 3 && ivas_total_brate == IVAS_128k ) { @@ -1393,9 +1395,11 @@ ivas_error ivas_masa_dec_reconfigure( { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ } + sts = st_ivas->hCPE[cpe_id]->hCoreCoder; sts[0]->bit_stream = bit_stream + num_bits; num_bits += (int16_t) ( st_ivas->hCPE[cpe_id]->element_brate / FRAMES_PER_SEC ); + if ( ( ivas_total_brate < MASA_STEREO_MIN_BITRATE && last_ivas_total_brate >= MASA_STEREO_MIN_BITRATE ) || ( ivas_total_brate < MASA_STEREO_MIN_BITRATE && last_ivas_total_brate == FRAME_NO_DATA ) || ( ivas_total_brate < MASA_STEREO_MIN_BITRATE && last_ivas_total_brate == IVAS_SID_5k2 ) ) @@ -1428,7 +1432,7 @@ ivas_error ivas_masa_dec_reconfigure( if ( st_ivas->hDiracDecBin[pos_idx] != NULL ) { /* regularization factor is bitrate-dependent */ - st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, ivas_total_brate ); } } @@ -1440,7 +1444,7 @@ ivas_error ivas_masa_dec_reconfigure( if ( st_ivas->hDiracDecBin[0] != NULL ) { - 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[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 643781bfccf630d912ba540ad8ae61aac41fd294..4891e7fec8d4be0d916dcce8ec28ecb6fad6cb98 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -33,9 +33,6 @@ #include #include "options.h" #include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" @@ -46,11 +43,8 @@ #ifdef DEBUGGING #include "debug.h" #endif -#ifdef DEBUG_PLOT -#include "deb_out.h" -#endif #include "wmc_auto.h" -#include "rom_dec.h" + /*-----------------------------------------------------------------------* * Local constants @@ -100,6 +94,7 @@ static void ivas_param_mc_get_param_band_mapping( const int16_t n_target_bands, static void ivas_param_mc_bs_decode_parameter_values( uint16_t bit_buffer[], int16_t *bit_pos, const int16_t max_bits, int16_t *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const int16_t map_size_wo_lfe, const int16_t map_size, const int16_t num_lfe_bands, const int16_t band_step, const int16_t num_param_bands, float *value_buffer ); + /*------------------------------------------------------------------------- * ivas_param_mc_dec_open() * @@ -505,6 +500,7 @@ static void ivas_param_mc_get_param_band_mapping( int16_t lower = target_band_grouping[target_band_idx]; int16_t source_band_in_target_band_cnt = 0; float norm_fac = 1.0f; + source_band_cnt_total = 0; for ( source_band_idx = 0; source_band_idx < n_source_bands; source_band_idx++ ) { @@ -526,6 +522,7 @@ static void ivas_param_mc_get_param_band_mapping( } } norm_fac = 1.0f / ( (float) source_band_cnt_total ); + for ( source_band_idx = 0; source_band_idx < source_band_in_target_band_cnt; source_band_idx++ ) { @@ -650,7 +647,6 @@ ivas_error ivas_param_mc_dec_reconfig( float *ild_q_old = hParamMC->icld_q; float *icc_q_old = hParamMC->icc_q; - /* init arrays for the quantized parameters */ if ( ( hParamMC->icc_q = (float *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe * sizeof( float ) ) ) == NULL ) { @@ -841,7 +837,7 @@ ivas_error ivas_param_mc_dec_reconfig( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } - if ( ( param_mc_get_diff_proto_info( proto_matrix, nchan_transport, nchan_out_cov, hParamMC->diff_proto_info ) ) != IVAS_ERR_OK ) + if ( ( error = param_mc_get_diff_proto_info( proto_matrix, nchan_transport, nchan_out_cov, hParamMC->diff_proto_info ) ) != IVAS_ERR_OK ) { return error; } @@ -952,7 +948,6 @@ ivas_error ivas_param_mc_dec_reconfig( set_zero( hParamMC->proto_frame_f, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands ); } - if ( nchan_transport_old != nchan_transport ) { if ( hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) @@ -1001,6 +996,7 @@ ivas_error ivas_param_mc_dec_reconfig( } } } + return error; } @@ -1538,7 +1534,6 @@ void ivas_param_mc_dec_prepare_renderer( mvr2r( cx, cx_next_band, nchan_transport * nchan_transport ); } - for ( is_next_band = 0; is_next_band < 2; is_next_band++ ) { if ( is_next_band && skip_next_band ) @@ -1573,11 +1568,11 @@ void ivas_param_mc_dec_prepare_renderer( *------------------------------------------------------------------------*/ void ivas_param_mc_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still to render */ + float *output_f[] /* o : rendered time signal */ ) { PARAM_MC_DEC_HANDLE hParamMC; @@ -1670,6 +1665,7 @@ void ivas_param_mc_dec_render( slots_to_render += hParamMC->subframe_nbslots[subframe_idx]; } } + slot_idx_start = hParamMC->slots_rendered; slot_idx_start_cldfb_synth = 0; for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) @@ -1807,8 +1803,7 @@ void ivas_param_mc_dec_render( #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG NULL, #endif - st_ivas->hCombinedOrientationData, - hParamMC->subframe_nbslots[subframe_idx], + st_ivas->hCombinedOrientationData, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) @@ -2705,9 +2700,6 @@ static void param_mc_set_num_synth_bands( switch ( output_Fs ) { - case 8000: - max_param_band_synth = param_mc_bands_coded[NB]; - break; case 16000: max_param_band_synth = param_mc_bands_coded[WB]; break; @@ -2821,6 +2813,7 @@ static ivas_error param_mc_get_diff_proto_info( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } + if ( ( p_diff_proto_info->proto_fac = (float **) malloc( p_diff_proto_info->num_protos_diff * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index c06e8b3fa18632bff589fa6d452bcd57394a3f1b..2493c17581f7cbf913285705d203c2c7772651bb 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -33,14 +33,12 @@ #include #include "options.h" #include -#include "cnst.h" #include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" -#include "math.h" #ifdef DEBUGGING #include "debug.h" #endif @@ -48,7 +46,6 @@ #include "deb_out.h" #endif #include "wmc_auto.h" -#include "rom_dec.h" /*-----------------------------------------------------------------------* @@ -216,9 +213,9 @@ void ivas_mc_paramupmix_dec_digest_tc( void ivas_mc_paramupmix_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *input_f[], /* i : core-coder transport channels */ float *output_f[] /* i/o: synthesized core-coder transport channels */ ) @@ -259,20 +256,19 @@ void ivas_mc_paramupmix_dec_render( #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif - { - for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) - { - int16_t n_samples_sf = slot_size * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]; - ivas_mc_paramupmix_dec_sf( st_ivas, output_f_local ); - for ( ch = 0; ch < min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) ); ch++ ) - { - output_f_local[ch] += n_samples_sf; - } + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) + { + int16_t n_samples_sf = slot_size * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]; + ivas_mc_paramupmix_dec_sf( st_ivas, output_f_local ); - /* update combined orientation access index */ - ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); + for ( ch = 0; ch < min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) ); ch++ ) + { + output_f_local[ch] += n_samples_sf; } + + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); } *nSamplesAvailable = ( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered ) * slot_size; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 3300eb7965b34dcf949d2370339bcd3b357db8ac..a3b42f1930cded9e1e2d4923b7649fc85a06c524 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -324,7 +324,6 @@ ivas_error ivas_mct_dec( dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.cpe", 0, cpe_id, DEC ) ); } #endif - pop_wmops(); return error; } @@ -1161,6 +1160,7 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) ) { ivas_binRenderer_close( &st_ivas->hBinRenderer ); + if ( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) { efap_free_data( &st_ivas->hEFAPdata ); @@ -1266,69 +1266,69 @@ static ivas_error ivas_mc_dec_reconfig( /*-----------------------------------------------------------------* * JBM TC buffers *-----------------------------------------------------------------*/ - { - int16_t tc_nchan_full_new; - DECODER_TC_BUFFER_HANDLE hTcBuffer; - hTcBuffer = st_ivas->hTcBuffer; - tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); - tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - tc_nchan_allocate_new = tc_nchan_tc_new; - tc_nchan_full_new = tc_nchan_tc_new; - tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); + int16_t tc_nchan_full_new; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; - tc_nchan_full_new = tc_nchan_allocate_new; - } + hTcBuffer = st_ivas->hTcBuffer; + tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + tc_nchan_allocate_new = tc_nchan_tc_new; + tc_nchan_full_new = tc_nchan_tc_new; - if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) - { - tc_nchan_full_new = 0; - } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) - { - tc_nchan_allocate_new = MC_PARAMUPMIX_MAX_INPUT_CHANS; - tc_buffer_mode_new = TC_BUFFER_MODE_RENDERER; - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) - { - tc_buffer_mode_new = TC_BUFFER_MODE_BUFFER; - tc_nchan_tc_new = st_ivas->hDecoderConfig->nchan_out; - tc_nchan_allocate_new = tc_nchan_tc_new; - } - tc_nchan_full_new = tc_nchan_allocate_new; - } + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; + tc_nchan_full_new = tc_nchan_allocate_new; + } - /* reconfigure buffer */ - if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || - hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new || - tc_granularity_new != hTcBuffer->n_samples_granularity ) - { - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK ) - { - return error; - } - } - /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ - if ( st_ivas->hSpatParamRendCom != NULL ) + if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) + { + tc_nchan_full_new = 0; + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { + tc_nchan_allocate_new = MC_PARAMUPMIX_MAX_INPUT_CHANS; + tc_buffer_mode_new = TC_BUFFER_MODE_RENDERER; + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) { - st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; - st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots; - st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered; - mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + tc_buffer_mode_new = TC_BUFFER_MODE_BUFFER; + tc_nchan_tc_new = st_ivas->hDecoderConfig->nchan_out; + tc_nchan_allocate_new = tc_nchan_tc_new; } - else if ( st_ivas->hParamMC != NULL ) + tc_nchan_full_new = tc_nchan_allocate_new; + } + + /* reconfigure buffer */ + if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || + hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new || + tc_granularity_new != hTcBuffer->n_samples_granularity ) + { + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK ) { - st_ivas->hParamMC->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hParamMC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; - st_ivas->hParamMC->num_slots = st_ivas->hTcBuffer->num_slots; - st_ivas->hParamMC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; - mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + return error; } } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ + if ( st_ivas->hSpatParamRendCom != NULL ) + { + st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots; + st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } + else if ( st_ivas->hParamMC != NULL ) + { + st_ivas->hParamMC->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hParamMC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + st_ivas->hParamMC->num_slots = st_ivas->hTcBuffer->num_slots; + st_ivas->hParamMC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } + /*-----------------------------------------------------------------* * floating-point output audio buffers *-----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 40ae744154afeed3afacbeb54cc644809b73c3ce..f0560b015dea4034b36b921c11c7ae5f6e2690db 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -82,7 +82,7 @@ ivas_error ivas_mono_dmx_renderer_open( *-------------------------------------------------------------------------*/ void ivas_mono_dmx_renderer_close( - MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ + MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/o: Mono downmix structure */ ) { if ( hMonoDmxRenderer == NULL || *hMonoDmxRenderer == NULL ) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index ff47b1b9a77fa56f539ca737a201d2fff16f22b5..e2f501a97115e43540d9d8962e2826e7c8c76f9b 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -228,6 +228,7 @@ ivas_error ivas_td_binaural_renderer_sf( { return error; } + if ( st_ivas->hRenderConfig != NULL && st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { if ( ( error = ivas_reverb_process( st_ivas->hReverb, st_ivas->transport_config, 0, tc_local, p_reverb_signal, 0 ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index beaf645fa0d1bfad365e0136c0f1025bd71ab945..feca940952d15c4a05f9f6ee70bbe7ff9b920595 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -762,7 +762,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm( ivas_dirac_dec_binaural_render( st_ivas, nSamplesAsked, nSamplesRendered, nSamplesAvailable, nchan_transport, output_f ); - /* reset combined orientation access index before calling the td renderer */ + /* update combined orientation access index */ ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) @@ -925,11 +925,7 @@ void ivas_omasa_combine_separate_ism_with_masa( { for ( n = 0; n < nchan_in; n++ ) { - cldfbAnalysis_ts( - &( output[n][nBins * slot] ), - inRe[n][slot], - inIm[n][slot], - nBins, st_ivas->cldfbAnaDec[n] ); + cldfbAnalysis_ts( &( output[n][nBins * slot] ), inRe[n][slot], inIm[n][slot], nBins, st_ivas->cldfbAnaDec[n] ); } } @@ -961,6 +957,7 @@ void ivas_omasa_combine_separate_ism_with_masa( eneMasa[sf][band] += inRe[n][slot][bin] * inRe[n][slot][bin] + inIm[n][slot][bin] * inIm[n][slot][bin]; } } + for ( bin = brange[0]; bin < brange[1]; bin++ ) { eneIsm[sf][band] += inRe[MASA_MAX_TRANSPORT_CHANNELS][slot][bin] * inRe[MASA_MAX_TRANSPORT_CHANNELS][slot][bin] + inIm[MASA_MAX_TRANSPORT_CHANNELS][slot][bin] * inIm[MASA_MAX_TRANSPORT_CHANNELS][slot][bin]; @@ -1154,11 +1151,7 @@ void ivas_omasa_render_objects_from_mix( { for ( n = 0; n < nchan_transport; n++ ) { - cldfbAnalysis_ts( - &( output[n][nBins * slot] ), - inRe[n][slot], - inIm[n][slot], - nBins, st_ivas->cldfbAnaDec[n] ); + cldfbAnalysis_ts( &( output[n][nBins * slot] ), inRe[n][slot], inIm[n][slot], nBins, st_ivas->cldfbAnaDec[n] ); } } @@ -1229,6 +1222,7 @@ void ivas_omasa_render_objects_from_mix( } } } + for ( slot = 0; slot < CLDFB_NO_COL_MAX; slot++ ) { md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[slot]; @@ -1256,6 +1250,7 @@ void ivas_omasa_render_objects_from_mix( } } } + for ( slot = 0; slot < CLDFB_NO_COL_MAX; slot++ ) { for ( bin = 0; bin < nBins; bin++ ) @@ -1281,6 +1276,7 @@ void ivas_omasa_render_objects_from_mix( } } } + for ( n = 0; n < MASA_MAX_TRANSPORT_CHANNELS; n++ ) { for ( slot = 0; slot < CLDFB_NO_COL_MAX; slot++ ) diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index afa273fdbbe25ec2021be6237c0233efd30f5d57..41bfa4c7ef9347dee793b39f990a3d43334731a5 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -125,11 +125,11 @@ void ivas_osba_data_close( *--------------------------------------------------------------------------*/ ivas_error ivas_osba_dirac_td_binaural_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t n; @@ -153,6 +153,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( return error; } + /* update combined orientation access index */ ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); 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_output_config.c b/lib_dec/ivas_output_config.c index 430b57afa20dbbe874fe3b7c78638efa2e1d7c97..3e3ce1121632597f9d73b6996d18b3ee9a5459df 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -56,7 +56,6 @@ void ivas_renderer_select( AUDIO_CONFIG *internal_config; AUDIO_CONFIG output_config; AUDIO_CONFIG transport_config; - int16_t nchan_internal; renderer_type = &( st_ivas->renderer_type ); @@ -157,7 +156,6 @@ void ivas_renderer_select( if ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); if ( nchan_internal == 2 ) { diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index deaf021649b74b234935ecffb318f87bbf98f7cb..265afe1464900ca7eea7bf640f8507cf690f1e64 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -379,7 +379,6 @@ const uint16_t * const sym_freq_ECSQ_tab_abs_lsbs[1 + 4] = * DirAC ROM tables *----------------------------------------------------------------------------------*/ - const float dirac_dithering_azi_scale[DIRAC_DIFFUSE_LEVELS] = { 6.716062e-01f, 1.011837e+00f, 1.799065e+00f, 2.824915e+00f, 4.800879e+00f, 9.206031e+00f, 1.469832e+01f, 2.566224e+01f diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index 063921501a2441bd67060b04b109bc2bf61f773d..10ab3b013e8e4e4c9ef154096b21341f3bd5c404 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -92,7 +92,6 @@ extern const uint16_t *const sym_freq_ECSQ_tab_abs_lsbs[1 + 4]; * DirAC ROM tables *----------------------------------------------------------------------------------*/ - extern const float dirac_dithering_azi_scale[DIRAC_DIFFUSE_LEVELS]; extern const float dirac_dithering_ele_scale[DIRAC_DIFFUSE_LEVELS]; @@ -105,4 +104,4 @@ extern const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_df0; extern const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_df; extern const HUFF_NODE_TABLE ivas_mc_paramupmix_huff_nodes_dt; -#endif +#endif /* IVAS_ROM_DEC_H */ diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c old mode 100644 new mode 100755 index ade8e11b020756b9b0dff0cec52800e2410b7335..28304399ecf1946a95d97efdc3abde0b3d1d6abc --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -106,6 +106,7 @@ ivas_error ivas_sba_dec_reconfigure( { int16_t nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; AUDIO_CONFIG intern_config_old; + int16_t sba_order_internal; int16_t numCldfbAnalyses_old, numCldfbSyntheses_old; int16_t sba_dirac_stereo_flag_old; int32_t ivas_total_brate; @@ -117,8 +118,12 @@ ivas_error ivas_sba_dec_reconfigure( ivas_error error; ISM_MODE ism_mode_old; int16_t granularity_new; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + SPAR_DEC_HANDLE hSpar; int16_t nchan_transport; + hTcBuffer = st_ivas->hTcBuffer; + hSpar = st_ivas->hSpar; ism_mode_old = st_ivas->ism_mode; hDecoderConfig = st_ivas->hDecoderConfig; ivas_total_brate = hDecoderConfig->ivas_total_brate; @@ -171,30 +176,30 @@ ivas_error ivas_sba_dec_reconfigure( /* make sure the changed number of slots in the last subframe is not lost in the following steps */ if ( st_ivas->hSpatParamRendCom != NULL ) { - st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1]; } - st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + hSpar->subframe_nbslots[hSpar->nb_subframes - 1] = hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1]; } } /* save old */ - if ( ism_mode_old != ISM_SBA_MODE_DISC && st_ivas->hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER ) + if ( ism_mode_old != ISM_SBA_MODE_DISC && hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER ) { - if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) + if ( st_ivas->hDirAC == NULL && hSpar != NULL ) { - st_ivas->hTcBuffer->num_slots = st_ivas->hSpar->num_slots; - st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpar->nb_subframes; - st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpar->slots_rendered; - st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpar->subframes_rendered; - mvs2s( st_ivas->hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + hTcBuffer->num_slots = hSpar->num_slots; + hTcBuffer->nb_subframes = hSpar->nb_subframes; + hTcBuffer->slots_rendered = hSpar->slots_rendered; + hTcBuffer->subframes_rendered = hSpar->subframes_rendered; + mvs2s( hSpar->subframe_nbslots, hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } else if ( st_ivas->hSpatParamRendCom != NULL ) { - st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; - st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; - st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; - st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; - mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; + hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; + hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; + hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; + mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } } @@ -202,23 +207,19 @@ ivas_error ivas_sba_dec_reconfigure( * Allocate, initialize, and configure SBA handles *-----------------------------------------------------------------*/ - int16_t sba_order_internal; - SPAR_DEC_HANDLE hSpar; - hSpar = st_ivas->hSpar; - sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); if ( hSpar != NULL ) { if ( ( hSpar->hPCA != NULL ) && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE ) || ( st_ivas->sba_order != 1 ) ) ) { - free( st_ivas->hSpar->hPCA ); + free( hSpar->hPCA ); hSpar->hPCA = NULL; } if ( nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) || ( last_ivas_total_brate >= IVAS_512k && ivas_total_brate < IVAS_512k ) || ( last_ivas_total_brate < IVAS_512k && ivas_total_brate >= IVAS_512k ) ) { - ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 ); + ivas_spar_dec_close( &hSpar, hDecoderConfig->output_Fs, 1 ); if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK ) { @@ -227,11 +228,11 @@ ivas_error ivas_sba_dec_reconfigure( } else if ( last_ivas_total_brate < IVAS_24k4 && ivas_total_brate >= IVAS_24k4 ) { - num_channels = st_ivas->hSpar->hMdDec->spar_md_cfg.num_umx_chs; - ivas_spar_md_dec_matrix_close( st_ivas->hSpar->hMdDec, num_channels ); + num_channels = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + ivas_spar_md_dec_matrix_close( hSpar->hMdDec, num_channels ); num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - if ( ( error = ivas_spar_md_dec_matrix_open( st_ivas->hSpar->hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_matrix_open( hSpar->hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK ) { return error; } @@ -257,7 +258,6 @@ ivas_error ivas_sba_dec_reconfigure( } } - hSpar = st_ivas->hSpar; st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); if ( st_ivas->nchan_transport == 1 ) @@ -339,21 +339,21 @@ ivas_error ivas_sba_dec_reconfigure( { int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; - st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); + hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); if ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) { - st_ivas->hSpar->enc_param_start_band = 0; + hSpar->enc_param_start_band = 0; set_c( (int8_t *) st_ivas->hQMetaData->twoDirBands, (int8_t) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), - st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); + hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); if ( st_ivas->hDirAC ) { - st_ivas->hDirAC->hConfig->enc_param_start_band = st_ivas->hSpar->enc_param_start_band; + st_ivas->hDirAC->hConfig->enc_param_start_band = hSpar->enc_param_start_band; } } @@ -367,7 +367,7 @@ ivas_error ivas_sba_dec_reconfigure( if ( st_ivas->hDirAC != NULL ) { - st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; + hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; } /*-----------------------------------------------------------------* @@ -375,6 +375,7 @@ ivas_error ivas_sba_dec_reconfigure( *-----------------------------------------------------------------*/ nchan_transport = st_ivas->nchan_transport; + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -555,7 +556,7 @@ ivas_error ivas_sba_dec_reconfigure( } } - if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode || granularity_new != st_ivas->hTcBuffer->n_samples_granularity ) + if ( tc_nchan_tc != hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != hTcBuffer->nchan_transport_internal || tc_buffer_mode != hTcBuffer->tc_buffer_mode || granularity_new != hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ) != IVAS_ERR_OK ) { @@ -565,24 +566,24 @@ ivas_error ivas_sba_dec_reconfigure( } /* resync SPAR and DirAC JBM info from TC Buffer */ - if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) + if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == hTcBuffer->n_samples_granularity ) { - mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); - st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + mvs2s( hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + st_ivas->hSpatParamRendCom->nb_subframes = hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->subframes_rendered = hTcBuffer->subframes_rendered; } - mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); - st_ivas->hSpar->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + mvs2s( hTcBuffer->subframe_nbslots, hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + hSpar->nb_subframes = hTcBuffer->nb_subframes; + hSpar->subframes_rendered = hTcBuffer->subframes_rendered; if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size; + int16_t granularityMultiplier = hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size; int16_t n; for ( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ ) { - st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier; - st_ivas->hSpar->subframe_nbslots[n] = st_ivas->hSpatParamRendCom->subframe_nbslots[n]; + st_ivas->hSpatParamRendCom->subframe_nbslots[n] = hTcBuffer->subframe_nbslots[n] * granularityMultiplier; + hSpar->subframe_nbslots[n] = st_ivas->hSpatParamRendCom->subframe_nbslots[n]; } } @@ -684,11 +685,11 @@ void ivas_sba_dec_digest_tc( *-------------------------------------------------------------------*/ ivas_error ivas_sba_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 1aece93bb9febcd24cba7498d47ed39f221da904..142c761f58a67fe7a3949aaebec177f985a9b66f 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -185,11 +185,7 @@ void ivas_mc2sba( idx_in++; /* get HOA response for direction (ACN/SN3D)*/ - ivas_dirac_dec_get_response( - azimuth, - elevation, - gains, - sba_order ); + ivas_dirac_dec_get_response( azimuth, elevation, gains, sba_order ); for ( j = 0; j < sba_num_chans; j++ ) { diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 148b58487224f538e1ac1b1c4290d4f027233db1..d94b373b53f3643e7ec30ec32edd46fff0058090 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -62,11 +62,9 @@ ivas_error ivas_sce_dec( float outputHB[1][L_FRAME48k]; /* 'float' buffer for output HB synthesis, one channel */ SCE_DEC_HANDLE hSCE; Decoder_State *st; - int32_t ivas_total_brate, last_ivas_total_brate; + int32_t ivas_total_brate; ivas_error error; - error = IVAS_ERR_OK; - push_wmops( "ivas_sce_dec" ); hSCE = st_ivas->hSCE[sce_id]; @@ -75,7 +73,6 @@ ivas_error ivas_sce_dec( st->BER_detect |= st_ivas->BER_detect; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; if ( st_ivas->ivas_format == ISM_FORMAT ) { @@ -101,7 +98,7 @@ ivas_error ivas_sce_dec( { st->total_brate = FRAME_NO_DATA; } - else if ( !st_ivas->bfi && st_ivas->ivas_format != ISM_FORMAT && last_ivas_total_brate <= IVAS_SID_5k2 ) + else if ( !st_ivas->bfi && st_ivas->ivas_format != ISM_FORMAT && st_ivas->hDecoderConfig->last_ivas_total_brate <= IVAS_SID_5k2 ) { st->total_brate = hSCE->element_brate - nb_bits_metadata * FRAMES_PER_SEC; } @@ -257,13 +254,13 @@ ivas_error ivas_sce_dec( output_Fs = st_ivas->hDecoderConfig->output_Fs; /*----------------------------------------------------------------* - * LB synthesis synchronization between IVAS formats + * LB synthesis synchronization between coding tools *----------------------------------------------------------------*/ delay_signal( output[0], output_frame, st->prev_synth_buffer, NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); /*----------------------------------------------------------------* - * HB synthesis synchronization between IVAS formats + * HB synthesis synchronization between coding tools *----------------------------------------------------------------*/ delay_signal( outputHB[0], output_frame, hSCE->prev_hb_synth, NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) ); @@ -314,7 +311,7 @@ ivas_error ivas_sce_dec( pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -335,7 +332,6 @@ ivas_error create_sce_dec( ivas_error error; int16_t output_frame; - error = IVAS_ERR_OK; output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); /*-----------------------------------------------------------------* @@ -430,7 +426,7 @@ ivas_error create_sce_dec( hSCE->hCoreCoder[0] = st; st_ivas->hSCE[sce_id] = hSCE; - return error; + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 98dc1ad3fa7e31c6b606e448b48887915d8725c1..6add11c8f656e9363bb7e8a6a5b45098c35ede26 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1130,6 +1130,7 @@ static void ivas_spar_calc_smooth_facs( } } } + return; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 89d53452bb5c449e2577ccf17c2a48ee2fcddae3..76ed22f4da52c3d1ebd7ef4d187217d5168a4fa5 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -609,6 +609,7 @@ typedef struct ivas_spar_md_dec_state_t int16_t first_valid_frame; ivas_band_coeffs_t *band_coeffs_prev; int16_t base_band_coeffs_age[IVAS_MAX_NUM_BANDS]; + } ivas_spar_md_dec_state_t; @@ -765,7 +766,6 @@ typedef struct mct_dec_block_data_struct } MCT_DEC_BLOCK_DATA, *MCT_DEC_BLOCK_DATA_HANDLE; - typedef struct mct_dec_data_structure { int16_t nchan_out_woLFE; /* number of active channels within multi-channel configuration */ @@ -1012,9 +1012,9 @@ typedef struct decoder_config_structure /* temp. development parameters */ 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 */ - IVAS_RENDER_FRAMESIZE render_framesize; - int16_t Opt_delay_comp; /* flag indicating delay compensation active */ + int16_t Opt_tsm; /* indicates whether time scaling modification is activated */ + IVAS_RENDER_FRAMESIZE render_framesize; /* rendering frame size */ + int16_t Opt_delay_comp; /* flag indicating delay compensation active */ } DECODER_CONFIG, *DECODER_CONFIG_HANDLE; @@ -1085,6 +1085,7 @@ typedef struct Decoder_Struct int16_t sba_planar; /* Ambisonic (SBA) planar flag */ int16_t sba_analysis_order; /* Ambisonic (SBA) order used for analysis and coding */ int16_t sba_dirac_stereo_flag; /* flag indicating stereo output for SBA DirAC modes with 1 TC */ + int16_t flag_omasa_brate; /* OMASA bitrate adjustment flag */ /* rendering modules */ RENDERER_TYPE renderer_type; /* renderer type */ @@ -1114,9 +1115,7 @@ typedef struct Decoder_Struct DIRAC_REND_HANDLE hDirACRend; /* DirAC renderer handle */ SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; /* Spatial parametric (DirAC rend, ParamBin, ParamISM) rendering common data handle. */ MASA_ISM_DATA_HANDLE hMasaIsmData; /* OMASA rendering handle */ - SBA_ISM_DATA_HANDLE hSbaIsmData; /* OSBA rendering handle */ - - int16_t flag_omasa_brate; + SBA_ISM_DATA_HANDLE hSbaIsmData; /* OSBA rendering handle */ ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; /* ISAR split binaural rendering handle */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1]; /* TD object renderer handles */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 588399ef2ad1714f7934eae25ee6c785c74a696e..523f6c51c7c8d9ed594818906028ecab710db672 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -183,7 +183,7 @@ ivas_error IVAS_DEC_PrepareRenderer( /*! r: decoder error code */ ivas_error IVAS_DEC_GetSamplesRenderer( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ + const int16_t nSamplesAsked, /* i : number of samples requested */ const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ void *pcmBuf, /* o : output synthesis signal */ int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ @@ -344,33 +344,33 @@ ivas_error IVAS_DEC_EnableSplitRendering( ); ivas_error IVAS_DEC_SetRenderFramesize( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_RENDER_FRAMESIZE render_framesize /* i : render framesize */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_FRAMESIZE render_framesize/* i : render framesize */ ); ivas_error IVAS_DEC_GetRenderFramesize( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */ ); ivas_error IVAS_DEC_GetRenderFramesizeSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *render_framesize /* o : render framesize in samples */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *render_framesize /* o : render framesize in samples */ ); ivas_error IVAS_DEC_GetReferencesUpdateFrequency( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *update_frequency /* o : update frequency */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *update_frequency /* o : update frequency */ ); ivas_error IVAS_DEC_GetNumOrientationSubframes( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *num_subframes /* o : render framesize */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *num_subframes /* o : render framesize */ ); ivas_error IVAS_DEC_GetRenderFramesizeMs( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint32_t *render_framesize /* o : render framesize in samples */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint32_t *render_framesize /* o : render framesize in samples */ ); #ifdef DEBUGGING @@ -504,7 +504,7 @@ ivas_error IVAS_DEC_HasDecodedFirstGoodFrame( /*! r: true if decoder has no data in VoIP jitter buffer */ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked + const int16_t nSamplesAsked /* i : number of samples requested */ ); ivas_error IVAS_DEC_VoIP_Get_CA_offset( @@ -529,14 +529,14 @@ const char *IVAS_DEC_GetErrorMessage( ivas_error IVAS_DEC_PrintConfig( const IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ - const bool quietModeEnabled, /* i : quiet mode flag: if true, reduces the amount of config info printed */ + const bool quietModeEnabled, /* i : quiet mode flag: if true, reduces the amount of config info printed */ const bool voipMode ); #ifdef DEBUGGING void IVAS_DEC_PrintConfigWithBitstream( IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ - const bool quietModeEnabled, /* i : quiet mode flag: if true, reduces the amount of config info printed */ + const bool quietModeEnabled, /* i : quiet mode flag: if true, reduces the amount of config info printed */ uint16_t bit_stream[], /* i : bitstream buffer */ const int16_t num_bits /* i : number of bits in bitstream */ ); diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 597275de1e6b29f003b324d45bcda4939d6b9b8d..f814ec02c91973eac7dd480c6df5868de7b419cb 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -414,7 +414,7 @@ ivas_error pre_proc_front_ivas( dummy = st->mem_preemph; preemph( new_inp_12k8 - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy ); } - else /* IVAS_SCE or IVAS_CPE_MDCT */ + else /* IVAS_SCE */ { preemph( new_inp_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph ); dummy = st->mem_preemph; diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 7c5b66cb8ca5f650ab98d7c24ccafb800a315059..5122ea41feb91811e20d0b9f66b07a30025d2453 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -113,7 +113,6 @@ ivas_error ivas_cpe_enc( int32_t element_brate_ref; int16_t last_bits_frame_nominal; /* last_bits_frame_nominal for M or PCh channel */ - error = IVAS_ERR_OK; push_wmops( "ivas_cpe_enc" ); hCPE = st_ivas->hCPE[cpe_id]; @@ -172,7 +171,6 @@ ivas_error ivas_cpe_enc( /*----------------------------------------------------------------* * Stereo technology selection - * Front-VAD on input L and R channels *----------------------------------------------------------------*/ if ( sts[0]->ini_frame > 0 && st_ivas->hMCT == NULL ) @@ -182,6 +180,10 @@ ivas_error ivas_cpe_enc( stereo_mode_combined_format_enc( st_ivas, hCPE ); + /*----------------------------------------------------------------* + * Front-VAD on input L and R channels + *----------------------------------------------------------------*/ + if ( ( error = front_vad( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_LR, NULL, NULL ) ) != IVAS_ERR_OK ) { return error; @@ -285,7 +287,6 @@ ivas_error ivas_cpe_enc( sts[n]->element_mode = hCPE->element_mode; } - if ( hCPE->element_mode != IVAS_CPE_MDCT && ( hCPE->element_brate != hCPE->last_element_brate || hCPE->last_element_mode != hCPE->element_mode || sts[0]->ini_frame == 0 || ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ { @@ -302,7 +303,6 @@ ivas_error ivas_cpe_enc( } else { - /* note; "bits_frame_nominal" needed in TD stereo as well */ stereo_dft_config( hConfigDft, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } } @@ -468,8 +468,8 @@ ivas_error ivas_cpe_enc( dbgwrite( sts[0]->input - NS2SA( sts[0]->input_Fs, ACELP_LOOK_NS ), sizeof( float ), input_frame, 1, fname( debug_dir, "input_DMX", n, sts[n]->id_element, ENC ) ); } dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, sts[0]->id_element, ENC ) ); -#endif +#endif /*----------------------------------------------------------------* * Front Pre-processing *----------------------------------------------------------------*/ @@ -708,7 +708,6 @@ ivas_error ivas_cpe_enc( } } - /*----------------------------------------------------------------* * Core Encoder *----------------------------------------------------------------*/ @@ -797,10 +796,10 @@ ivas_error ivas_cpe_enc( float tmpF = ivas_total_brate / 1000.0f; dbgwrite( &tmpF, sizeof( float ), 1, input_frame, fname( debug_dir, "element_brate", 0, cpe_id, ENC ) ); } -#endif +#endif pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -824,8 +823,6 @@ ivas_error create_cpe_enc( ENCODER_CONFIG_HANDLE hEncoderConfig; ivas_error error; - error = IVAS_ERR_OK; - hEncoderConfig = st_ivas->hEncoderConfig; ivas_format = hEncoderConfig->ivas_format; @@ -1063,7 +1060,7 @@ ivas_error create_cpe_enc( st_ivas->hCPE[cpe_id] = hCPE; - return error; + return IVAS_ERR_OK; } diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index db2e60fada703ae07198684798ebe0859e058598..3177a2a2a58e5f7b38cbce7fa854cae427cf868a 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -557,8 +557,8 @@ ivas_error ivas_enc( float tmpF = ivas_total_brate / 1000.0f; dbgwrite( &tmpF, sizeof( float ), 1, input_frame, "res/ivas_total_brate" ); } -#endif +#endif pop_wmops(); return error; } diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index bfe47d07a57c5c2c50e2adfe27e4f8c87c9435b2..6b9962c48fc70a9d4be6fe60600d8fb84d3b70e6 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -144,7 +144,7 @@ ivas_error front_vad( } } - /* Only run VAD if DTX is on and TD stereo or unified stereo is selected */ + /* Only run VAD if DTX is on and Unified stereo is selected */ if ( hFrontVads[0] != NULL && element_mode != IVAS_CPE_MDCT ) { #ifdef DEBUGGING diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 9e42dd8bea5f4f2a2ab9da18cb2750860c9390e7..eda9d4d5d05abba2bb8e1e9c69ad1a8e8f8206eb 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -742,13 +742,9 @@ ivas_error ivas_init_encoder( else { /* allocate and initialize MCT core coder */ + int16_t n_all = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; + st_ivas->nCPE = ( n_all + 1 ) >> 1; - { - int16_t n_all; - - n_all = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; - st_ivas->nCPE = ( n_all + 1 ) >> 1; - } for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index a8c224d1768aabfe47aa0117aa0a9393e1181c01..d50544d206f0fbba7e370c01519dac6bd6f5a0ca 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -255,14 +255,12 @@ ivas_error ivas_ism_metadata_enc( if ( ( fabsf( hIsmMeta[ch]->azimuth - hIsmMeta[ch]->last_true_azimuth ) > ISM_MD_FEC_DIFF ) || ( fabsf( hIsmMeta[ch]->elevation - hIsmMeta[ch]->last_true_elevation ) > ISM_MD_FEC_DIFF ) || ( fabsf( hIsmMeta[ch]->radius - hIsmMeta[ch]->last_true_radius ) > ISM_MD_RAD_FEC_DIFF ) ) { - lowrate_metadata_flag[ch] = 1; hIsmMeta[ch]->ism_md_inc_diff_cnt = 0; } else if ( hIsmMeta[ch]->ism_md_inc_diff_cnt < ISM_MD_INC_DIFF_CNT_MAX ) { - lowrate_metadata_flag[ch] = 1; if ( hIsmMeta[ch]->ism_md_inc_diff_cnt % 2 == 0 ) @@ -449,6 +447,7 @@ ivas_error ivas_ism_metadata_enc( /*----------------------------------------------------------------* * Quantize and encode radius, yaw, and pitch *----------------------------------------------------------------*/ + if ( ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) && ism_extended_metadata_flag ) { idx_angle1_abs = ism_quant_meta( hIsmMetaData->yaw, &valQ, ism_azimuth_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_AZIMUTH_NBITS ); @@ -571,9 +570,10 @@ ivas_error ivas_ism_metadata_enc( pop_wmops(); return error; } + if ( ism_mode == ISM_MODE_PARAM ) { - /* Keep the metdata transmission as is during active parts */ + /* Keep the metadata transmission as is during active parts */ /* But send the flag with 1 bit */ push_next_indice( hBstr, hParamIsm->flag_noisy_speech, 1 ); @@ -876,12 +876,12 @@ ivas_error ivas_ism_metadata_enc_create( *-------------------------------------------------------------------------*/ static void encode_radius( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - int16_t *last_radius_idx, /* i/o: last radius index */ - int16_t *radius_diff_cnt, /* i/o: radius diff coding counter */ - const int16_t last_ism_metadata_flag, /* last frame ism_metadata_flag */ - const int16_t idx_radius_abs, /* i : Azimuth index */ - int16_t *flag_abs_radius /* o : Radius encoding mode */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + int16_t *last_radius_idx, /* i/o: last radius index */ + int16_t *radius_diff_cnt, /* i/o: radius diff coding counter */ + const int16_t last_ism_metadata_flag, /* i : last frame ism_metadata_flag */ + const int16_t idx_radius_abs, /* i : Azimuth index */ + int16_t *flag_abs_radius /* o : Radius encoding mode */ ) { int16_t idx_radius, nbits_diff_radius, diff; @@ -1251,7 +1251,7 @@ void ivas_ism_metadata_sid_enc( nBits_start = hBstr->nb_bits_tot; /*----------------------------------------------------------------* - * Write ISm common signaling + * Write ISM common signaling *----------------------------------------------------------------*/ /* write number of objects - unary coding */ diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index ed2692373b03e42048d17ddf1c5a5c6243a39fb5..1daa9b3a002d8939f9a57d2e0212d6344aa024fc 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -176,7 +176,7 @@ static void ivas_param_ism_compute_obj_parameters( static void ivas_param_ism_enc_quantize_DOA( - const int16_t nchan_ism, /* i : number of ISM channels */ + const int16_t nchan_ism, /* i : number of ISM channels */ ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS], /* i : ISM metadata */ PARAM_ISM_CONFIG_HANDLE hParamIsm /* i/o: Param ISM encoder handle */ ) @@ -184,7 +184,6 @@ static void ivas_param_ism_enc_quantize_DOA( int16_t i, azi_idx, ele_idx; float valQ; - /* Loop over objects */ for ( i = 0; i < nchan_ism; i++ ) { @@ -297,10 +296,12 @@ void ivas_param_ism_stereo_dmx( ene_dmx += stereo_dmx[0][j] * stereo_dmx[0][j] + stereo_dmx[1][j] * stereo_dmx[1][j]; } dmx_gain = sqrtf( ene_data / ( ene_dmx + EPSILON ) ); + /* Smoothing */ if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 ) { dmx_gain = 0.75f * dmx_gain + 0.25f * last_dmx_gain; + /* 10ms ramp */ grad = ( dmx_gain - last_dmx_gain ) * 2.0f / (float) input_frame; /* slope between two consecutive gains, 480 samples length */ for ( i = 0; i < ( input_frame / 2 ); i++ ) @@ -351,9 +352,6 @@ ivas_error ivas_param_ism_enc_open( int32_t input_Fs; ivas_error error; - error = IVAS_ERR_OK; - - /* Assign memory to Param Object handle */ if ( ( hParamIsm = (PARAM_ISM_CONFIG_HANDLE) malloc( sizeof( PARAM_ISM_CONFIG_DATA ) ) ) == NULL ) { @@ -362,7 +360,6 @@ ivas_error ivas_param_ism_enc_open( input_Fs = st_ivas->hEncoderConfig->input_Fs; - /* set FB config. */ if ( ( error = ivas_fb_set_cfg( &fb_cfg, ISM_FORMAT, st_ivas->hEncoderConfig->nchan_inp, 0, 0, input_Fs, 0 ) ) != IVAS_ERR_OK ) { @@ -394,7 +391,7 @@ ivas_error ivas_param_ism_enc_open( st_ivas->hParamIsm = hParamIsm; - return error; + return IVAS_ERR_OK; } @@ -405,8 +402,8 @@ ivas_error ivas_param_ism_enc_open( *-------------------------------------------------------------------------*/ void ivas_param_ism_enc_close( - PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */ - const int32_t input_Fs /* i : input sampling_rate */ + PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */ + const int32_t input_Fs /* i : input sampling_rate */ ) { if ( hParamIsm == NULL || *hParamIsm == NULL ) diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 0da38f8e2e6ab52f01bef0aeb72fe0c138885db5..b910d826fff4f1230cde1e9edee29aa179dbe175 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -476,12 +476,14 @@ ivas_error ivas_masa_encode( push_next_indice( hMetaData, 0, MASA_HEADER_BITS ); hQMetaData->metadata_max_bits -= MASA_HEADER_BITS; } + if ( !( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MODE_NONE && nchan_ism > 2 ) ) { /* write number of directions */ push_next_indice( hMetaData, hQMetaData->no_directions - 1, 1 ); hQMetaData->metadata_max_bits -= 1; } + /* write subframe mode */ push_next_indice( hMetaData, hQMetaData->q_direction[0].cfg.nblocks == 1 ? 1 : 0, MASA_SUBFRAME_BITS ); hQMetaData->metadata_max_bits -= MASA_SUBFRAME_BITS; @@ -2153,7 +2155,7 @@ static void average_masa_metadata( *-------------------------------------------------------------------*/ static void copy_masa_metadata_subframe( - const MASA_METADATA_HANDLE hMetaFrom, /* i : MASA frame metdata to be copied */ + const MASA_METADATA_HANDLE hMetaFrom, /* i : MASA frame metadata to be copied */ const uint8_t sfFrom, /* i : subframe index of the copy source */ MASA_METADATA_HANDLE hMetaTo, /* o : MASA frame metadata copy destination */ const uint8_t sfTo /* i : subframe index of the copy target */ @@ -2650,6 +2652,7 @@ void ivas_merge_masa_metadata( int16_t merge_dest; float dir_sum; uint8_t band_n_dirs; + if ( numDirections == 1 || ( numDirections == 2 && hMasa->data.twoDirBands[band] == 0 ) ) { band_n_dirs = 1; @@ -2786,7 +2789,6 @@ static void quantize_ratio_ism_vector( { if ( no_ism_loc > 1 ) { - dist = 0.0f; div = 1.0f / (float) ( max_sum_idx ); diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 993954560791bb819e23e8bf56bad7e3fc1a9ce8..b38e8fc0e33f3df6744e78983c8a9e739cc6c3b1 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -51,6 +51,7 @@ static void ivas_osba_render_ism_to_sba( float *data_in_f[], float data_out_f[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_sba, const int16_t nchan_ism, ISM_METADATA_HANDLE hIsmMeta[], float prev_gains[][MAX_INPUT_CHANNELS], const float interpolator[L_FRAME48k] ); + /*-------------------------------------------------------------------* * ivas_merge_sba_transports() * @@ -92,9 +93,7 @@ ivas_error ivas_osba_enc_open( int16_t i; OSBA_ENC_HANDLE hOSba; int16_t input_frame; - ivas_error error; int16_t len; - error = IVAS_ERR_OK; if ( ( hOSba = (OSBA_ENC_HANDLE) malloc( sizeof( OSBA_ENC_DATA ) ) ) == NULL ) { @@ -130,7 +129,7 @@ ivas_error ivas_osba_enc_open( st_ivas->hOSba = hOSba; - return error; + return IVAS_ERR_OK; } @@ -181,12 +180,11 @@ ivas_error ivas_osba_enc_reconfig( int32_t ivas_total_brate; ivas_error error; ENCODER_CONFIG_HANDLE hEncoderConfig; - + int16_t nchan_transport; error = IVAS_ERR_OK; hEncoderConfig = st_ivas->hEncoderConfig; ivas_total_brate = hEncoderConfig->ivas_total_brate; - int16_t nchan_transport; if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) { @@ -287,6 +285,7 @@ ivas_error ivas_osba_enc_reconfig( { hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; } + if ( nchan_transport_old != st_ivas->nchan_transport || ( ivas_total_brate < IVAS_512k && hEncoderConfig->last_ivas_total_brate >= IVAS_512k ) || ( ivas_total_brate >= IVAS_512k && hEncoderConfig->last_ivas_total_brate < IVAS_512k ) ) { /* FB mixer handle */ @@ -295,7 +294,9 @@ ivas_error ivas_osba_enc_reconfig( ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, 0 ); hDirAC->hFbMixer = NULL; } + spar_reconfig_flag = 1; + ivas_spar_enc_close( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); if ( ( error = ivas_spar_enc_open( st_ivas, spar_reconfig_flag ) ) != IVAS_ERR_OK ) @@ -303,15 +304,19 @@ ivas_error ivas_osba_enc_reconfig( return error; } } + st_ivas->hSpar->spar_reconfig_flag = spar_reconfig_flag; + if ( ( error = ivas_dirac_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) { return error; } + if ( st_ivas->hQMetaData->q_direction->cfg.nbands != nbands_old || st_ivas->hQMetaData->no_directions != ndir_old ) { int16_t dir, j, i; IVAS_QDIRECTION *q_direction = st_ivas->hQMetaData->q_direction; + for ( dir = 0; dir < st_ivas->hQMetaData->no_directions; dir++ ) { for ( j = 0; j < q_direction[dir].cfg.nbands; j++ ) @@ -324,6 +329,7 @@ ivas_error ivas_osba_enc_reconfig( } } } + hSpar->enc_param_start_band = hDirAC->hConfig->enc_param_start_band; /*-----------------------------------------------------------------* @@ -331,12 +337,11 @@ ivas_error ivas_osba_enc_reconfig( *-----------------------------------------------------------------*/ nchan_transport = st_ivas->nchan_transport; + if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - { - nchan_transport = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; - st_ivas->nCPE = ( nchan_transport + 1 ) >> 1; - } + nchan_transport = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; + st_ivas->nCPE = ( nchan_transport + 1 ) >> 1; } else if ( old_ism_mode == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE ) { @@ -405,6 +410,7 @@ void ivas_osba_enc( else { int16_t azimuth, elevation; + /* delay ISM input channels to match the SBA encoder delay */ for ( n = 0; n < nchan_ism; n++ ) { @@ -477,7 +483,7 @@ static void ivas_osba_render_ism_to_sba( } } - /* Gain with loudness-matching gains */ + /* Gain with loudness-matching gains */ // TODO return; } diff --git a/lib_enc/ivas_pca_enc.c b/lib_enc/ivas_pca_enc.c index ae04ba29b3af6be052bd457dc79b3a687c6d9b04..08c2a15a18febb7428a256ecb2a7c943fb94ac37 100644 --- a/lib_enc/ivas_pca_enc.c +++ b/lib_enc/ivas_pca_enc.c @@ -47,6 +47,11 @@ * Local constants *-----------------------------------------------------------------------*/ +#define IVAS_PCA_COV_THRES 3e-5f +#define IVAS_PCA_THRES_MIN_DOT 0.8f +#define IVAS_PCA_THRES_MIN_DOT2 0.0f +#define IVAS_PCA_THRES_DIST_ALT 6.0f + #define IVAS_PCA_SM_FAC 0.0234375f #define IVAS_PCA_N_ITER_QR 10 diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 913fe907542f53f549525d32fd9ce63a3930eedc..30779a7666b9dbae7d489aab51e3dbf0c136e4ac 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -92,8 +92,6 @@ ivas_error ivas_sce_enc( push_wmops( "ivas_sce_enc" ); - error = IVAS_ERR_OK; - hSCE = st_ivas->hSCE[sce_id]; st = hSCE->hCoreCoder[0]; ivas_format = st_ivas->hEncoderConfig->ivas_format; @@ -293,7 +291,7 @@ ivas_error ivas_sce_enc( pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -313,8 +311,6 @@ ivas_error create_sce_enc( Encoder_State *st; ivas_error error; - error = IVAS_ERR_OK; - /*-----------------------------------------------------------------* * Allocate SCE handle *-----------------------------------------------------------------*/ @@ -376,7 +372,7 @@ ivas_error create_sce_enc( st_ivas->hSCE[sce_id] = hSCE; - return error; + return IVAS_ERR_OK; } diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs.c index bf516cb97439c21daef70b57c2be26dcbd254cd5..178429d5569c33ba79f2a22b8f1629e58cffb727 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -112,7 +112,7 @@ #define STEREO_DMX_EVS_SGC_GMAX 1.4142f #define STEREO_DMX_EVS_SGC_GMIN 0.7071f -#define STEREO_DMX_EVS_IPD_ILD_THRES 3.16f // 5dB +#define STEREO_DMX_EVS_IPD_ILD_THRES 3.16f /* 5dB */ #define STEREO_DMX_EVS_IPD_SF_THRES 0.05f /*-----------------------------------------------------------------------* diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 705f3364e4788a153df3b81ed809d0e433ed714e..254d9c39efdea4218d2f9986bbf593e22c069b32 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -267,7 +267,6 @@ ivas_error IVAS_ENC_ConfigureForStereo( { Encoder_Struct *st_ivas; ENCODER_CONFIG_HANDLE hEncoderConfig; - ivas_error error; if ( ( error = doCommonConfigureChecks( hIvasEnc ) ) != IVAS_ERR_OK ) @@ -353,7 +352,9 @@ ivas_error IVAS_ENC_ConfigureForMASAObjects( { return IVAS_ERR_TOO_MANY_INPUTS; } + st_ivas = hIvasEnc->st_ivas; + switch ( masaVariant ) { case IVAS_ENC_MASA_2CH: @@ -439,8 +440,6 @@ ivas_error IVAS_ENC_FeedObjectMetadata( { ivas_error error; - error = IVAS_ERR_OK; - if ( !hIvasEnc->isConfigured ) { return IVAS_ERR_NOT_CONFIGURED; @@ -456,9 +455,7 @@ ivas_error IVAS_ENC_FeedObjectMetadata( return IVAS_ERR_INVALID_INDEX; } - error = ivas_set_ism_metadata( hIvasEnc->st_ivas->hIsmMetaData[ismIndex], metadata.azimuth, metadata.elevation, metadata.radius, metadata.yaw, metadata.pitch, metadata.non_diegetic_flag ); - - if ( error != IVAS_ERR_OK ) + if ( ( error = ivas_set_ism_metadata( hIvasEnc->st_ivas->hIsmMetaData[ismIndex], metadata.azimuth, metadata.elevation, metadata.radius, metadata.yaw, metadata.pitch, metadata.non_diegetic_flag ) ) != IVAS_ERR_OK ) { return error; } @@ -517,8 +514,8 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( { return error; } -#endif +#endif hEncoderConfig->Opt_PCA_ON = (int16_t) Opt_PCA_ON; hIvasEnc->maxBandwidthUser = max_bwidth_user; @@ -648,6 +645,11 @@ ivas_error IVAS_ENC_FeedMasaMetadata( IVAS_MASA_METADATA_HANDLE hMasaMetadata /* i : MASA metadata for current frame */ ) { + if ( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + if ( !hIvasEnc->isConfigured ) { return IVAS_ERR_NOT_CONFIGURED; @@ -988,8 +990,8 @@ static ivas_error configureEncoder( { return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "AGC supported in SBA format at bitrates >= 24.4 kbps only." ); } -#endif +#endif if ( hEncoderConfig->Opt_PCA_ON && !( ( hEncoderConfig->ivas_format == SBA_FORMAT || hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) && hEncoderConfig->ivas_total_brate == PCA_BRATE && hEncoderConfig->sba_order == SBA_FOA_ORDER ) ) { return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "PCA supported at SBA FOA 256 kbps only." ); @@ -1045,6 +1047,11 @@ ivas_error IVAS_ENC_GetDelay( { ENCODER_CONFIG_HANDLE hEncoderConfig; + if ( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + hEncoderConfig = hIvasEnc->st_ivas->hEncoderConfig; if ( !hIvasEnc->isConfigured ) @@ -1078,17 +1085,19 @@ static int16_t getInputBufferSize( return (int16_t) ( st_ivas->hEncoderConfig->input_Fs * st_ivas->hEncoderConfig->nchan_inp / FRAMES_PER_SEC ); } + /*---------------------------------------------------------------------* * IVAS_ENC_GetNumInChannels() * * *---------------------------------------------------------------------*/ + ivas_error IVAS_ENC_GetNumInChannels( const IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ int16_t *numInChannels /* o : total number of samples expected in the input buffer for current encoder configuration */ ) { - if ( hIvasEnc == NULL || numInChannels == NULL ) + if ( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL || numInChannels == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -1120,7 +1129,7 @@ ivas_error IVAS_ENC_GetInputBufferSize( return IVAS_ERR_NOT_CONFIGURED; } - if ( inputBufferSize == NULL ) + if ( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL || inputBufferSize == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -1154,6 +1163,11 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( error = IVAS_ERR_OK; + if ( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL || inputBuffer == NULL || outputBitStream == NULL || numOutBits == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + if ( !hIvasEnc->isConfigured ) { return IVAS_ERR_NOT_CONFIGURED; @@ -1448,8 +1462,8 @@ ivas_error IVAS_ENC_SetChannelAwareConfig( return setChannelAwareConfig( hIvasEnc, rfConfig ); } - #ifdef DEBUGGING + /*---------------------------------------------------------------------* * IVAS_ENC_SetForcedMode() * @@ -1483,8 +1497,8 @@ ivas_error IVAS_ENC_SetForcedMode( return IVAS_ERR_OK; } -#endif /* DEBUGGING */ +#endif /* DEBUGGING */ /*---------------------------------------------------------------------* * IVAS_ENC_GetDefaultBandwidth() @@ -1492,7 +1506,8 @@ ivas_error IVAS_ENC_SetForcedMode( * *---------------------------------------------------------------------*/ -IVAS_ENC_BANDWIDTH IVAS_ENC_GetDefaultBandwidth( const bool isEVS ) +IVAS_ENC_BANDWIDTH IVAS_ENC_GetDefaultBandwidth( + const bool isEVS ) { IVAS_ENC_BANDWIDTH bwidth = IVAS_ENC_BANDWIDTH_FB; @@ -1511,9 +1526,11 @@ IVAS_ENC_BANDWIDTH IVAS_ENC_GetDefaultBandwidth( const bool isEVS ) * *---------------------------------------------------------------------*/ -IVAS_ENC_DTX_CONFIG IVAS_ENC_GetDefaultDtxConfig( void ) +IVAS_ENC_DTX_CONFIG IVAS_ENC_GetDefaultDtxConfig( + void ) { IVAS_ENC_DTX_CONFIG defaultDtxConfig; + defaultDtxConfig.enabled = false; defaultDtxConfig.SID_interval = 0; defaultDtxConfig.variable_SID_rate = false; @@ -1528,9 +1545,11 @@ IVAS_ENC_DTX_CONFIG IVAS_ENC_GetDefaultDtxConfig( void ) * *---------------------------------------------------------------------*/ -IVAS_ENC_CHANNEL_AWARE_CONFIG IVAS_ENC_GetDefaultChannelAwareConfig( void ) +IVAS_ENC_CHANNEL_AWARE_CONFIG IVAS_ENC_GetDefaultChannelAwareConfig( + void ) { IVAS_ENC_CHANNEL_AWARE_CONFIG defaultCaConfig; + defaultCaConfig.channelAwareModeEnabled = 0; defaultCaConfig.fec_indicator = IVAS_ENC_FEC_HI; defaultCaConfig.fec_offset = 0; @@ -1566,6 +1585,11 @@ static ivas_error printConfigInfo_enc( int16_t newBandwidthApi; ivas_error error; + if ( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + st_ivas = hIvasEnc->st_ivas; hEncoderConfig = st_ivas->hEncoderConfig; @@ -2012,6 +2036,11 @@ static ivas_error sanitizeBandwidth( ENCODER_CONFIG_HANDLE hEncoderConfig; int16_t max_bwidth_tmp; + if ( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + hEncoderConfig = hIvasEnc->st_ivas->hEncoderConfig; max_bwidth_tmp = hIvasEnc->newBandwidthApi; @@ -2163,6 +2192,11 @@ static ivas_error setBandwidth( int16_t newBandwidth; ENCODER_CONFIG_HANDLE hEncoderConfig; + if ( hIvasEnc == NULL || hIvasEnc->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + hEncoderConfig = hIvasEnc->st_ivas->hEncoderConfig; /* Convert bandwidth from API type */ @@ -2301,6 +2335,7 @@ static ivas_error fecIndicatorApiToInternal( } #ifdef DEBUGGING + /*---------------------------------------------------------------------* * forcedModeApiToInternal() * @@ -2341,8 +2376,8 @@ static ivas_error forcedModeApiToInternal( return IVAS_ERR_OK; } -#endif +#endif /*---------------------------------------------------------------------* * IVAS_ENC_PrintConfig() diff --git a/lib_enc/q_gain2p.c b/lib_enc/q_gain2p.c index 8e8ae02168d3d5097139e23df88b7e1b04b97e72..a6830a6edd810bffb36721003096cbb2d2749b69 100644 --- a/lib_enc/q_gain2p.c +++ b/lib_enc/q_gain2p.c @@ -237,13 +237,13 @@ int16_t Mode2_gain_enc_mless( *---------------------------------------------------------------------*/ static int16_t gain_enc_uv( - const float *code, /* i : algebraic excitation */ - const int16_t lcode, /* i ) : Subframe size */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - ACELP_CbkCorr *coeff, /* i/o : correlations , -2,, -2 and 2 */ - float *past_gcode, /* i/o : past gain of code */ - float *gain_inov /* o : unscaled innovation gain */ + const float *code, /* i : algebraic excitation */ + const int16_t lcode, /* i : Subframe size */ + float *gain_pit, /* o : quantized pitch gain */ + float *gain_code, /* o : quantized codebook gain */ + ACELP_CbkCorr *coeff, /* i/o: correlations , -2,, -2 and 2 */ + float *past_gcode, /* i/o: past gain of code */ + float *gain_inov /* o : unscaled innovation gain */ ) { int16_t index; diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c index 4236c9ced7cc64a4615b798d79b0ab1a0ac14300..cfd0dfa42b85759212b3e524ce467261c5389b87 100644 --- a/lib_isar/isar_lc3plus_common.c +++ b/lib_isar/isar_lc3plus_common.c @@ -30,10 +30,9 @@ *******************************************************************************************************/ +#include #include "options.h" #include "isar_lc3plus_common.h" -#include "ivas_error.h" -#include "lc3.h" /*-----------------------------------------------------------------------------------------* * Function ISAR_LC3PLUS_LC3plusErrToIvasErr() diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index fde81489512622a108605b02a7cd1e15bac97a42..dc71bd38469b41dd6aaec61909771d7703c333cd 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -40,7 +40,6 @@ #include #include "ivas_rom_binaural_crend_head.h" #include "ivas_stat_rend.h" -#include "lib_rend.h" #ifdef DEBUGGING #include "debug.h" #endif @@ -1056,8 +1055,9 @@ static ivas_error ivas_er_init_handle( *------------------------------------------------------------------------*/ ivas_error ivas_rend_initCrendWrapper( - CREND_WRAPPER_HANDLE *pCrend, - const int16_t num_poses ) + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const int16_t num_poses /* i : number of poses */ +) { int16_t i; CREND_HANDLE hCrend; @@ -1141,15 +1141,16 @@ ivas_error ivas_rend_openMultiBinCrend( *------------------------------------------------------------------------*/ ivas_error ivas_rend_openCrend( - CREND_WRAPPER_HANDLE *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - RENDER_CONFIG_DATA *hRendCfg, - HRTFS_CREND_HANDLE hHrtfCrend, - HRTFS_STATISTICS_HANDLE hHrtfStatistics, - const int32_t output_Fs, - const int16_t ext_rend_flag, - const int16_t num_poses ) + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const RENDER_CONFIG_HANDLE hRendCfg, /* i : Renderer configuration handle */ + const HRTFS_CREND_HANDLE hHrtfCrend, /* i : Crend HRTF handle */ + HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t ext_rend_flag, /* i : flag indicating external renderer */ + const int16_t num_poses /* i : number of poses */ +) { int16_t i, subframe_length; int32_t max_total_ir_len; @@ -1158,8 +1159,6 @@ ivas_error ivas_rend_openCrend( ivas_error error; int16_t pos_idx; - error = IVAS_ERR_OK; - if ( ( error = ivas_rend_initCrendWrapper( pCrend, num_poses ) ) != IVAS_ERR_OK ) { return error; @@ -1340,8 +1339,9 @@ ivas_error ivas_rend_openCrend( *------------------------------------------------------------------------*/ void ivas_rend_closeCrend( - CREND_WRAPPER_HANDLE *pCrend, - const int16_t num_poses ) + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const int16_t num_poses /* i : number of poses */ +) { int16_t i; int16_t pos_idx; @@ -1360,6 +1360,7 @@ void ivas_rend_closeCrend( for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { hCrend = ( *pCrend )->hCrend[pos_idx]; + if ( hCrend != NULL ) { for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) @@ -1390,6 +1391,7 @@ void ivas_rend_closeCrend( free( hCrend->lfe_delay_line ); hCrend->lfe_delay_line = NULL; } + if ( hCrend->freq_buffer_re_diffuse[0] != NULL ) { free( hCrend->freq_buffer_re_diffuse[0] ); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index cc1bccb131955da0c19949855baa2db5f55a8f97..a13449b6b46388ec2e2215ac8ca16cf5b7a16e42 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -41,7 +41,6 @@ #include "ivas_rom_binauralRenderer.h" #include "ivas_rom_rend.h" #include "ivas_rom_com.h" - #ifdef DEBUGGING #include "debug.h" #endif @@ -195,7 +194,6 @@ ivas_error ivas_dirac_dec_init_binaural_data( set_zero( hDiracDecBin->ChCrossImOutPrev, nBins ); hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; - for ( bin = 0; bin < nBins; bin++ ) { binCenterFreq = ( (float) bin + CLDFB_HALF_BIN_FREQUENCY_OFFSET ) / (float) nBins * ( (float) output_Fs / 2.0f ); @@ -331,6 +329,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } + return IVAS_ERR_OK; } @@ -425,18 +424,18 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( /*------------------------------------------------------------------------- - * void ivas_dirac_dec_binaural_render() - * + * ivas_dirac_dec_binaural_render() * + * Parametric binaural renderer process *------------------------------------------------------------------------*/ void ivas_dirac_dec_binaural_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - const int16_t nchan_transport, /* i : number of transport channels */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -452,6 +451,7 @@ void ivas_dirac_dec_binaural_render( #ifdef DEBUGGING assert( hSpatParamRendCom ); #endif + for ( ch = 0; ch < nchan_out; ch++ ) { output_f_local[ch] = output_f_local_buff[ch]; @@ -1066,6 +1066,7 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( { IIReneLimiterFactor = 8.0f + ( 1.0f - qualityBasedSmFactor ); } + for ( bin = 0; bin < nBins; bin++ ) { float eneRatio; @@ -1454,6 +1455,7 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( return; } + static void ivas_dirac_dec_binaural_determine_processing_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, @@ -1801,7 +1803,6 @@ static void ivas_dirac_dec_binaural_process_output( decSlotImPointer = NULL; } - for ( bin = 0; bin < nBins; bin++ ) { float gain; @@ -1976,6 +1977,7 @@ static void adaptTransportSignalsHeadtracked( return; } + static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked( COMBINED_ORIENTATION_HANDLE hHeadTrackData, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], @@ -2549,10 +2551,7 @@ static void hrtfShGetHrtf( { float shVec[HRTF_SH_CHANNELS]; - ivas_dirac_dec_get_response( aziDeg, - eleDeg, - shVec, - HRTF_SH_ORDER ); + ivas_dirac_dec_get_response( aziDeg, eleDeg, shVec, HRTF_SH_ORDER ); for ( k = 0; k < HRTF_SH_CHANNELS; k++ ) { @@ -2578,7 +2577,7 @@ static void hrtfShGetHrtf( /*! r: Configured reqularization factor value */ float configure_reqularization_factor( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int32_t ivas_total_brate /* i : IVAS total bitrate */ ) { @@ -3288,6 +3287,12 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( } +/*-------------------------------------------------------------------* + * ivas_masa_ext_rend_parambin_internal() + * + * + *-------------------------------------------------------------------*/ + static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, @@ -3404,7 +3409,6 @@ static void ivas_masa_ext_rend_parambin_internal( /* Always using CLDFB decorrelation in MASA EXT renderer */ max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; - ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, subFrameTotalEne, IIReneLimiter ); @@ -3512,6 +3516,12 @@ static void ivas_masa_ext_rend_parambin_internal( } +/*-------------------------------------------------------------------* + * ivas_masa_ext_rend_parambin_render() + * + * + *-------------------------------------------------------------------*/ + void ivas_masa_ext_rend_parambin_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 9480e6374b0875378ce9f5aba99db7b816323175..b548d0ec5a309b1366173f616c70faf59c731de4 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -54,7 +54,7 @@ ivas_error ivas_dirac_allocate_parameters( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ + const int16_t params_flag /* i : set of parameters flag */ ) { int16_t i; @@ -191,8 +191,8 @@ ivas_error ivas_dirac_allocate_parameters( *-------------------------------------------------------------------------*/ ivas_error ivas_spat_hSpatParamRendCom_config( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data handle */ + const DIRAC_CONFIG_FLAG flag_config_inp, /* i : Flag determining if we open or reconfigure the DirAC decoder */ const int16_t dec_param_estim_flag, const IVAS_FORMAT ivas_format, const MC_MODE mc_mode, @@ -335,18 +335,19 @@ ivas_error ivas_spat_hSpatParamRendCom_config( *-------------------------------------------------------------------------*/ void ivas_spat_hSpatParamRendCom_close( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out ) + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom /* i/o: common spatial renderer data handle */ +) { - if ( hSpatParamRendCom_out == NULL || *hSpatParamRendCom_out == NULL ) + if ( hSpatParamRendCom == NULL || *hSpatParamRendCom == NULL ) { return; } - ivas_dirac_deallocate_parameters( *hSpatParamRendCom_out, 1 ); - ivas_dirac_deallocate_parameters( *hSpatParamRendCom_out, 2 ); + ivas_dirac_deallocate_parameters( *hSpatParamRendCom, 1 ); + ivas_dirac_deallocate_parameters( *hSpatParamRendCom, 2 ); - free( *hSpatParamRendCom_out ); - *hSpatParamRendCom_out = NULL; + free( *hSpatParamRendCom ); + *hSpatParamRendCom = NULL; return; } @@ -359,7 +360,8 @@ void ivas_spat_hSpatParamRendCom_close( *-------------------------------------------------------------------------*/ void ivas_dirac_rend_close( - DIRAC_REND_HANDLE *hDirACRend_out ) + DIRAC_REND_HANDLE *hDirACRend_out /* i/o: DirAC renderer handle */ +) { int16_t i, j; DIRAC_REND_HANDLE hDirACRend; @@ -1032,6 +1034,7 @@ void initDiffuseResponses( diffuse_response_function[i] = 0.f; } } + /* Diffuse only to horizontal plane if enough loudspeakers */ if ( num_horizontal_speakers > 2 ) { @@ -2086,7 +2089,13 @@ void rotateAziEle_DirAC( return; } -/* A reduced rewrite of the corresponding decoder side function */ + +/*------------------------------------------------------------------------- + * ivas_masa_ext_dirac_render_sf() + * + * A reduced rewrite of the corresponding decoder side function + *------------------------------------------------------------------------*/ + static void ivas_masa_ext_dirac_render_sf( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: IVAS decoder structure */ float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ @@ -2385,7 +2394,6 @@ static void ivas_masa_ext_dirac_render_sf( ivas_dirac_dec_output_synthesis_get_interpolator( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( Cldfb_RealBuffer, @@ -2463,6 +2471,13 @@ static void ivas_masa_ext_dirac_render_sf( return; } + +/*------------------------------------------------------------------------- + * ivas_masa_ext_dirac_render() + * + * MASA external renderer + *------------------------------------------------------------------------*/ + void ivas_masa_ext_dirac_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ float *output_f[], /* i/o: input/output signals in time domain */ diff --git a/lib_rend/ivas_masa_merge.c b/lib_rend/ivas_masa_merge.c index 37ee8cc7ef5620e987c5b30f8a854a66272ade8f..9e47160b43eb249876ff04119a04b8c0a2ab455f 100644 --- a/lib_rend/ivas_masa_merge.c +++ b/lib_rend/ivas_masa_merge.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "lib_rend.h" #include "ivas_prot_rend.h" #include "ivas_prot.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index df7c0d7a63e09e6ac5cac9061229e44767682a53..d81a28e976e9ca9941e0b813467efba3a2228b66 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -84,8 +84,6 @@ ivas_error ivas_td_binaural_open_unwrap( int16_t nchan_rend; ivas_error error; - error = IVAS_ERR_OK; - if ( ( pBinRendTd = malloc( sizeof( BINAURAL_TD_OBJECT_RENDERER ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); @@ -210,6 +208,7 @@ ivas_error ivas_td_binaural_open_unwrap( { return error; } + if ( ( error = TDREND_MIX_SRC_SetDistAtten( pBinRendTd, nS, &DistAtten ) ) != IVAS_ERR_OK ) { return error; @@ -249,10 +248,12 @@ ivas_error ivas_td_binaural_open_unwrap( DistAtten.RefDist = distAtt[1]; DistAtten.RollOffFactor = distAtt[2]; } + if ( ( error = TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ) ) != IVAS_ERR_OK ) { return error; } + if ( ( error = TDREND_MIX_SRC_SetDistAtten( pBinRendTd, nS, &DistAtten ) ) != IVAS_ERR_OK ) { return error; @@ -267,7 +268,7 @@ ivas_error ivas_td_binaural_open_unwrap( *binaural_latency_ns = (int32_t) ( ( *hBinRendererTd )->HrFiltSet_p->latency_s * 1000000000.f ); } - return error; + return IVAS_ERR_OK; } @@ -465,6 +466,7 @@ ivas_error TDREND_GetMix( { TDREND_SRC_REND_UpdateFiltersFromSpatialParams( hBinRendererTd, SrcRend_p, SrcSpatial_p, Src_p->hrf_left_prev, Src_p->hrf_right_prev, hrf_left_delta, hrf_right_delta, &intp_count, &Src_p->filterlength, &Src_p->itd, &Src_p->Gain, Src_p ); + #ifdef NONBE_1300_TDREND_LARGE_ITD /* For large ITD values at lower sampling rate, check if the transition can be done */ if ( Src_p->itd * Src_p->previtd < 0 ) @@ -674,18 +676,18 @@ ivas_error TDREND_Update_listener_orientation( *---------------------------------------------------------------------*/ ivas_error ivas_td_binaural_open_ext( - TDREND_WRAPPER *pTDRend, - AUDIO_CONFIG inConfig, - RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ - LSSETUP_CUSTOM_STRUCT *customLsInput, - const int32_t outFs ) + TDREND_WRAPPER_HANDLE pTDRend, /* o : TD Renderer wrapper structure */ + const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ + const RENDER_CONFIG_HANDLE hRendCfg, /* i : Renderer configuration */ + const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ + const int32_t output_Fs /* i : output sampling rate */ +) { int16_t nchan_transport; AUDIO_CONFIG transport_config; IVAS_FORMAT ivas_format; IVAS_OUTPUT_SETUP hTransSetup; ivas_error error; - float *distAtt = NULL; float *directivity = NULL; @@ -719,7 +721,7 @@ ivas_error ivas_td_binaural_open_ext( distAtt = hRendCfg->distAtt; } - return ivas_td_binaural_open_unwrap( pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, directivity, distAtt, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns ); + return ivas_td_binaural_open_unwrap( pTDRend->hHrtfTD, output_Fs, nchan_transport, ivas_format, transport_config, directivity, distAtt, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns ); } @@ -733,7 +735,7 @@ ivas_error ivas_td_binaural_open_ext( ivas_error ivas_td_binaural_renderer_ext( const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ - const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ + const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* i : Combined head and external orientations */ const IVAS_ISM_METADATA *currentPos, /* i : Object position */ const REVERB_HANDLE hReverb, /* i : Reverberator handle */ diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 355c5e13be3f08a18e9a2ae62a8d025deed3a1bf..2b6699c94036f1fb75cb59ffa08ef3c031fb509a 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -182,9 +182,9 @@ ivas_error TDREND_MIX_SRC_SetDirAtten( --------------------------------------------------------------------*/ ivas_error TDREND_MIX_SRC_SetDistAtten( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const TDREND_DistAtten_t *DistAtten_p /* i : Distance attenuation specifier */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const TDREND_DistAtten_t *DistAtten_p /* i : Distance attenuation specifier */ ) { TDREND_SRC_SPATIAL_t *SrcSpatial_p; @@ -208,7 +208,7 @@ ivas_error TDREND_MIX_SRC_SetDistAtten( --------------------------------------------------------------------*/ ivas_error TDREND_MIX_SRC_SetPlayState( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ const TDREND_PlayStatus_t PlayStatus /* i : Play state */ ) @@ -294,18 +294,18 @@ static void TDREND_SRC_REND_Init( --------------------------------------------------------------------*/ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ - TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ - float *hrf_left_prev, /* o : Left filter */ - float *hrf_right_prev, /* o : Right filter */ - float *hrf_left_delta, /* o : Left filter interpolation delta */ - float *hrf_right_delta, /* o : Right filter interpolation delta */ - int16_t *intp_count, /* o : Interpolation count */ - int16_t *filterlength, /* o : Length of filters */ - int16_t *itd, /* o : ITD value */ - float *Gain, /* o : Gain value */ - TDREND_SRC_t *Src_p /* i/o: Source pointer */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ + TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ + float *hrf_left_prev, /* o : Left filter */ + float *hrf_right_prev, /* o : Right filter */ + float *hrf_left_delta, /* o : Left filter interpolation delta */ + float *hrf_right_delta, /* o : Right filter interpolation delta */ + int16_t *intp_count, /* o : Interpolation count */ + int16_t *filterlength, /* o : Length of filters */ + int16_t *itd, /* o : ITD value */ + float *Gain, /* o : Gain value */ + TDREND_SRC_t *Src_p /* i/o: Source pointer */ ) { TDREND_MIX_Listener_t *Listener_p; @@ -708,7 +708,8 @@ ivas_error TDREND_SRC_Alloc( --------------------------------------------------------------------*/ void TDREND_SRC_Dealloc( - TDREND_SRC_t *Src_p ) + TDREND_SRC_t *Src_p /* i/o: Source to deallocate */ +) { if ( Src_p == NULL ) { diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index 0bab4c34e05020f8a91f9f505c911ea996e4f76d..88fe856853e9ac223fd8e8fda73f289e8e2fc6a6 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -40,7 +40,6 @@ #include "debug.h" #endif #include -#include #include "wmc_auto.h" @@ -396,7 +395,7 @@ static void VectorRotationToQuaternion( *-------------------------------------------------------------------*/ ivas_error ivas_orient_trk_Init( - ivas_orient_trk_state_t *pOTR ) /* i/o : orientation tracker handle */ + ivas_orient_trk_state_t *pOTR ) /* i/o: orientation tracker handle */ { IVAS_QUATERNION identity; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 121d9128816dc8b855b84e580eb5d872ccf9a1d9..016876fa513ec5b37b1b2b712f1f66d113db9fec 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -46,13 +46,14 @@ * General renderer declarations *----------------------------------------------------------------------------------*/ +/*! r: audio configuration type */ IVAS_REND_AudioConfigType getAudioConfigType( - const AUDIO_CONFIG config + const AUDIO_CONFIG config /* i : audio configuration */ ); ivas_error getAudioConfigNumChannels( - const AUDIO_CONFIG config, - int16_t *numChannels + const AUDIO_CONFIG config, /* i : audio configuration */ + int16_t *numChannels /* o : number of audio channels */ ); @@ -182,16 +183,16 @@ void vbap_determine_gains( *----------------------------------------------------------------------------------*/ void ivas_sba_prototype_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ - const int16_t subframe /* i : Subframe to render */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ + const int16_t subframe /* i : Subframe to render */ ); ivas_error ivas_sba_get_hoa_dec_matrix( - const IVAS_OUTPUT_SETUP hOutSetup, /* i : target output setup */ - float **hoa_dec_mtx, /* o : ALLRAD decoder matrix */ - const int16_t ambisonics_order /* i : Ambisonics order */ + const IVAS_OUTPUT_SETUP hOutSetup, /* i : target output setup */ + float **hoa_dec_mtx, /* o : ALLRAD decoder matrix */ + const int16_t ambisonics_order /* i : Ambisonics order */ ); void ivas_dirac_dec_binaural_sba_gain( @@ -201,40 +202,41 @@ void ivas_dirac_dec_binaural_sba_gain( ); void ivas_dirac_dec_binaural_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - const int16_t nchan_transport, /* i : number of transport channels */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ); void ivas_masa_ext_rend_parambin_render( - MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t num_subframes, /* i : number of subframes to render */ - const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ + MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t num_subframes, /* i : number of subframes to render */ + const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ float Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ float Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* o : rendered orientations for split rend. imag part of cldfb */ ); + ivas_error ivas_dirac_dec_init_binaural_data( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - HRTFS_PARAMBIN_HANDLE *phHrtfParambin /* i : HRTF structure for rendering */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + HRTFS_PARAMBIN_HANDLE *phHrtfParambin /* i : HRTF structure for rendering */ ); void ivas_dirac_dec_close_binaural_data( - DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */ + DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */ ); ivas_error ivas_dirac_dec_binaural_copy_hrtfs( - HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ + HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ ); /*! r: Configured reqularization factor value */ float configure_reqularization_factor( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int32_t ivas_total_brate /* i : total IVAS bitrate */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const int32_t ivas_total_brate /* i : total IVAS bitrate */ ); ivas_error ivas_dirac_alloc_mem( @@ -517,8 +519,8 @@ void ivas_dirac_dec_get_frequency_axis( ); ivas_error ivas_spat_hSpatParamRendCom_config( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, - const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data handle */ + const DIRAC_CONFIG_FLAG flag_config_inp, /* i : Flag determining if we open or reconfigure the DirAC decoder */ const int16_t dec_param_estim_flag, const IVAS_FORMAT ivas_format, const MC_MODE mc_mode, @@ -528,29 +530,30 @@ ivas_error ivas_spat_hSpatParamRendCom_config( ); void ivas_spat_hSpatParamRendCom_close( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom /* i/o: common spatial renderer data handle */ ); void ivas_dirac_rend_close( - DIRAC_REND_HANDLE *hDirACRend_out + DIRAC_REND_HANDLE *hDirACRend_out /* i/o: DirAC renderer handle */ ); ivas_error ivas_dirac_allocate_parameters( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ + const int16_t params_flag /* i : set of parameters flag */ ); void ivas_dirac_deallocate_parameters( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ + const int16_t params_flag /* i : set of parameters flag */ ); void ivas_masa_ext_dirac_render( - MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ - float *output_f[], /* i/o: input/output signals in time domain */ - const int16_t num_subframes /* i : number of subframes to render */ + MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ + float *output_f[], /* i/o: input/output signals in time domain */ + const int16_t num_subframes /* i : number of subframes to render */ ); + /*----------------------------------------------------------------------------------* * HRTF *----------------------------------------------------------------------------------*/ @@ -564,7 +567,7 @@ void ivas_HRTF_binary_close( ); ivas_error ivas_HRTF_fastconv_binary_open( - HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ + HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ ); void ivas_HRTF_fastconv_binary_close( @@ -633,7 +636,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( ivas_error ivas_td_binaural_renderer_ext( const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ - const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ + const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData,/* i : Combined head and external orientations */ const IVAS_ISM_METADATA *currentPos, /* i : Object position */ const REVERB_HANDLE hReverb, /* i : Reverberator handle */ @@ -657,11 +660,11 @@ ivas_error ivas_td_binaural_open_unwrap( ); ivas_error ivas_td_binaural_open_ext( - TDREND_WRAPPER *pTDRend, - const AUDIO_CONFIG inConfig, - RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ - LSSETUP_CUSTOM_STRUCT *customLsInput, - const int32_t output_Fs + TDREND_WRAPPER_HANDLE pTDRend, /* o : TD Renderer wrapper structure */ + const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ + const RENDER_CONFIG_HANDLE hRendCfg, /* i : Renderer configuration */ + const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ + const int32_t output_Fs /* i : output sampling rate */ ); void ivas_td_binaural_close( @@ -669,10 +672,10 @@ void ivas_td_binaural_close( ); ivas_error TDREND_GetMix( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ float *output[], /* i/o: ISM object synth/rendered output in 0,1 */ - const int16_t subframe_length, /* i/o: subframe length */ - const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ + const int16_t subframe_length, /* i/o: subframe length */ + const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ ); ivas_error TDREND_Update_listener_orientation( @@ -744,11 +747,13 @@ ivas_error TDREND_MIX_SRC_SetDirAtten( const int16_t SrcInd, /* i : Source index */ const TDREND_DirAtten_t *DirAtten_p /* i : Directional attenuation specifier */ ); + ivas_error TDREND_MIX_SRC_SetDistAtten( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ const TDREND_DistAtten_t *DistAtten_p /* i : Distance attenuation specifier */ ); + ivas_error TDREND_MIX_SRC_SetPlayState( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ @@ -892,15 +897,15 @@ void TDREND_firfilt( *----------------------------------------------------------------------------------*/ ivas_error ivas_rend_openCrend( - CREND_WRAPPER_HANDLE *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - RENDER_CONFIG_DATA *hRendCfg, - HRTFS_CREND_HANDLE hHrtfCrend, - HRTFS_STATISTICS_HANDLE hHrtfStatistics, - const int32_t output_Fs, - const int16_t ext_rend_flag, - const int16_t num_poses + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const RENDER_CONFIG_HANDLE hRendCfg, /* i : Renderer configuration handle */ + const HRTFS_CREND_HANDLE hHrtfCrend, /* i : Crend HRTF handle */ + HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t ext_rend_flag, /* i : flag indicating external renderer */ + const int16_t num_poses /* i : number of poses */ ); void ivas_rend_closeCrend( @@ -913,8 +918,8 @@ ivas_error ivas_Crend_hrtf_init( ); ivas_error ivas_rend_initCrendWrapper( - CREND_WRAPPER_HANDLE *pCrend, - const int16_t num_poses + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const int16_t num_poses /* i : number of poses */ ); ivas_error ivas_rend_crendProcessSubframe( @@ -946,8 +951,7 @@ ivas_error ivas_binaural_reverb_init( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ const int32_t sampling_rate, /* i : sampling rate */ const float *defaultTimes, /* i : default reverberation times */ - const float *defaultEne /* i : default reverberation energies */ - , + const float *defaultEne, /* i : default reverberation energies */ float *earlyEne /* i/o: Early part energies to be modified */ ); @@ -1124,12 +1128,13 @@ void ivas_reverb_calc_color_levels( float *pTarget_color_R ); -ivas_error ivas_reverb_prepare_cldfb_params( +void ivas_reverb_prepare_cldfb_params( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_STATISTICS_HANDLE hHrtfStatistics, const int32_t output_Fs, float *pOutput_t60, - float *pOutput_ene ); + float *pOutput_ene +); void ivas_reverb_interpolate_acoustic_data( const int16_t input_table_size, @@ -1148,16 +1153,16 @@ void ivas_reverb_interpolate_acoustic_data( *-----------------------------------------------------------------------------------*/ void ivas_shoebox_config_init( - shoebox_config_t *cal, - RENDER_CONFIG_HANDLE pConfig + shoebox_config_t *cal, /* i/o: shoebox_config_t handle */ + const RENDER_CONFIG_HANDLE hRendCfg /* i : Renderer configuration handle */ ); void ivas_shoebox_init( - shoebox_obj_t *obj, - shoebox_config_t *cal + shoebox_obj_t *obj, /* i/o: shoebox_obj_t handle */ + const shoebox_config_t *cal /* i : shoebox_config_t handle */ ); -void ivas_shoebox_set_scene ( +void ivas_shoebox_set_scene( shoebox_obj_t *obj, shoebox_output_t *ER_PARAMS, const float list_pos[3], @@ -1171,29 +1176,29 @@ void ivas_shoebox_set_scene ( *-----------------------------------------------------------------------------------*/ ivas_error ivas_er_init( - er_struct_t *reflections, - const AUDIO_CONFIG inConfig + er_struct_t *reflections, /* i/o: early reflections handle */ + const AUDIO_CONFIG inConfig /* i : Input config */ ); ivas_error ivas_er_set_reflections_mode( - er_struct_t *reflections, - const AUDIO_CONFIG inConfig + er_struct_t *reflections, /* i/o: early reflections handle */ + const AUDIO_CONFIG inConfig /* i : Input config */ ); ivas_error ivas_er_compute_reflections( - er_struct_t *reflections + er_struct_t *reflections /* i/o: early reflections handle */ ); ivas_error ivas_er_encoder_init( - er_struct_t *reflections + er_struct_t *reflections /* i/o: early reflections handle */ ); ivas_error ivas_er_process( - er_struct_t *reflections, - const int16_t frame_size, - const int16_t subframe_idx, - float **io, - const AUDIO_CONFIG inConfig + er_struct_t *reflections, /* i/o: early reflections handle */ + const int16_t subframe_size, /* i : subframe length */ + const int16_t subframe_idx, /* i : subframe index */ + float *in[], /* i/o: input/output buffer */ + const AUDIO_CONFIG inConfig /* i : Input config */ ); @@ -1202,18 +1207,18 @@ ivas_error ivas_er_process( *-----------------------------------------------------------------------------------*/ ivas_error ivas_headTrack_open( - HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ ); void ivas_headTrack_close( - HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ); void Euler2Quat( - const float yaw, /* i : yaw (x) */ - const float pitch, /* i : pitch (y) */ - const float roll, /* i : roll (z) */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ + const float yaw, /* i : yaw (x) */ + const float pitch, /* i : pitch (y) */ + const float roll, /* i : roll (z) */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ ); float rad2deg( @@ -1298,14 +1303,13 @@ void rotateFrame_sd_cldfb( ); ivas_error ivas_external_orientation_open( - EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData, /* o : external orientation handle */ - const int16_t num_subframes /* i : number of subframes */ + EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData, /* o : external orientation handle */ + const int16_t num_subframes /* i : number of subframes */ ); void ivas_external_orientation_close( - EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData /* i/o: external orientation handle */ + EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData /* i/o: external orientation handle */ ); - ivas_error ivas_combined_orientation_open( COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* o : combined orientation handle */ const int32_t fs, /* i : sampling rate */ @@ -1313,21 +1317,22 @@ ivas_error ivas_combined_orientation_open( ); void ivas_combined_orientation_close( - COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* i/o: combined orientation handle */ + COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* i/o: combined orientation handle */ ); ivas_error combine_external_and_head_orientations_dec( - HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ + HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ + EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ); ivas_error combine_external_and_head_orientations_rend( - IVAS_REND_HeadRotData *hHeadTrackData, /* i : head track handle */ - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ + IVAS_REND_HeadRotData *hHeadTrackData, /* i : head track handle */ + EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ); + /*----------------------------------------------------------------------------------* * Renderer configuration *----------------------------------------------------------------------------------*/ @@ -1451,19 +1456,19 @@ void ivas_omasa_ana_close( ); void computeIntensityVector_ana( - const int16_t *band_grouping, /* i : Band grouping for estimation */ - float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ - float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ - const int16_t num_frequency_bands, /* i : Number of frequency bands */ - float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity vector */ + const int16_t *band_grouping, /* i : Band grouping for estimation */ + float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX],/* i : Real part of input signal */ + float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX],/* i : Imag part of input signal */ + const int16_t num_frequency_bands, /* i : Number of frequency bands */ + float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity vector */ ); void computeReferencePower_ana( - const int16_t *band_grouping, /* i : Band grouping for estimation */ - float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ - float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ - float *reference_power, /* o : Estimated power */ - const int16_t num_freq_bands /* i : Number of frequency bands */ + const int16_t *band_grouping, /* i : Band grouping for estimation */ + float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX],/* i : Real part of input signal */ + float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX],/* i : Imag part of input signal */ + float *reference_power, /* o : Estimated power */ + const int16_t num_freq_bands /* i : Number of frequency bands */ ); void ivas_create_masa_out_meta( diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index 564f57f171c53083dbf5cd5013cd8084b118118a..eb384dc86a71f601b89caf819dadc0cae72d8766 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -35,7 +35,6 @@ #include #include "prot.h" #include "rom_dec.h" -#include "lib_rend.h" #include "ivas_prot_rend.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" @@ -70,8 +69,9 @@ static uint16_t LC_mixing_7_1_4[11] = { 0, 1, 2, 3, 4, 3, 4, 0, 1, 3, 4 }; *-----------------------------------------------------------------------------------------*/ ivas_error ivas_er_init( - er_struct_t *reflections, - const AUDIO_CONFIG inConfig ) + er_struct_t *reflections, /* i/o: early reflections handle */ + const AUDIO_CONFIG inConfig /* i : Input config */ +) { ivas_error error; uint8_t i; @@ -138,8 +138,9 @@ ivas_error ivas_er_init( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_er_set_reflections_mode( - er_struct_t *reflections, - const AUDIO_CONFIG inConfig ) + er_struct_t *reflections, /* i/o: early reflections handle */ + const AUDIO_CONFIG inConfig /* i : Input config */ +) { ivas_error error; uint16_t ch; @@ -254,7 +255,8 @@ ivas_error ivas_er_set_reflections_mode( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_er_encoder_init( - er_struct_t *reflections ) + er_struct_t *reflections /* i/o: early reflections handle */ +) { ivas_error error = IVAS_ERR_OK; uint16_t i, j, src_idx; @@ -329,7 +331,8 @@ ivas_error ivas_er_encoder_init( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_er_compute_reflections( - er_struct_t *reflections ) + er_struct_t *reflections /* i/o: early reflections handle */ +) { ivas_error error = IVAS_ERR_OK; uint16_t circ_len, i, j; @@ -421,13 +424,13 @@ Takes a buffer of N channels, returns a buffer of N*6 channels containing the ea reflections (one per wall). The process is a delay line architecture *-----------------------------------------------------------------------------------------*/ - ivas_error ivas_er_process( - er_struct_t *reflections, - const int16_t subframe_size, - const int16_t subframe_idx, - float **io, - const AUDIO_CONFIG inConfig ) + er_struct_t *reflections, /* i/o: early reflections handle */ + const int16_t subframe_size, /* i : subframe length */ + const int16_t subframe_idx, /* i : subframe index */ + float *in[], /* i/o: input/output buffer */ + const AUDIO_CONFIG inConfig /* i : Input config */ +) { ivas_error error = IVAS_ERR_OK; uint16_t i, j, k, subframe_offset; @@ -486,7 +489,7 @@ ivas_error ivas_er_process( { for ( j = 0; j < subframe_size; j++ ) { - buffer_ch[samp_idx++] = io[in_ch_idx][j + subframe_offset]; + buffer_ch[samp_idx++] = in[in_ch_idx][j + subframe_offset]; samp_idx = samp_idx % reflections->circ_len; } } @@ -495,7 +498,7 @@ ivas_error ivas_er_process( { for ( j = 0; j < subframe_size; j++ ) { - buffer_ch[samp_idx++] += io[in_ch_idx][j + subframe_offset]; + buffer_ch[samp_idx++] += in[in_ch_idx][j + subframe_offset]; samp_idx = samp_idx % reflections->circ_len; } } @@ -531,7 +534,7 @@ ivas_error ivas_er_process( /* Pull reflection from circ buffer and apply gain */ for ( k = 0; k < subframe_size; k++ ) { - io[ref_out_idx][k + subframe_offset] += buffer_ch[samp_idx++] * ref_gain; + in[ref_out_idx][k + subframe_offset] += buffer_ch[samp_idx++] * ref_gain; samp_idx = samp_idx % reflections->circ_len; } } diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 2811a3c4d03ec644555e7daa56eca3dd233f1638..c4ca334877562b4cb3894e7d92d29319b9f23c98 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -987,6 +987,7 @@ static ivas_error setup_FDN_branches( { int16_t nr_coefs, branch_idx, channel_idx; ivas_error error; + error = IVAS_ERR_OK; /* initialize feedback branches */ @@ -1859,12 +1860,14 @@ static ivas_error ivas_binaural_reverb_open( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * ivas_binaural_reverb_init() * * Allocate and initialize binaural room reverberator handle * for CLDFB renderers *------------------------------------------------------------------------*/ + ivas_error ivas_binaural_reverb_init( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ @@ -1873,9 +1876,8 @@ ivas_error ivas_binaural_reverb_init( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ const int32_t sampling_rate, /* i : sampling rate */ const float *defaultTimes, /* i : default reverberation times */ - const float *defaultEne /* i : default reverberation energies */ - , - float *earlyEne /* i/o: Early part energies to be modified */ + const float *defaultEne, /* i : default reverberation energies */ + float *earlyEne /* i/o: Early part energies to be modified */ ) { ivas_error error; @@ -1883,19 +1885,10 @@ ivas_error ivas_binaural_reverb_init( float revTimes[CLDFB_NO_CHANNELS_MAX]; float revEne[CLDFB_NO_CHANNELS_MAX]; - error = IVAS_ERR_OK; - if ( roomAcoustics != NULL ) { + ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, revTimes, revEne ); - if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, - hHrtfStatistics, - sampling_rate, - revTimes, - revEne ) ) != IVAS_ERR_OK ) - { - return error; - } preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); } else @@ -1939,6 +1932,7 @@ ivas_error ivas_binaural_reverb_init( return error; } + /*------------------------------------------------------------------------- * ivas_binaural_reverb_close() * diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index 855d47673cf13a6c40daa4be91eb53e95b1b4739..fd8b5cf79cbe1489e55090a825fa2fe8564b4e04 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -50,7 +50,6 @@ #define CLDFB_CONVOLVER_NTAPS_MAX ( 16 ) #define FFT_SPECTRUM_SIZE ( 1 + ( RV_FILTER_MAX_FFT_SIZE / 2 ) ) -#define N_INITIAL_IGNORED_FRAMES 4 /*-----------------------------------------------------------------------------------------* * Local function prototypes @@ -68,13 +67,14 @@ typedef struct cldfb_convolver_state static void ivas_reverb_set_energies( const float *avg_pwr_l, const float *avg_pwr_r, const int32_t sampling_rate, float *avg_pwr_l_out, float *avg_pwr_r_out ); + /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_prepare_cldfb_params() * * Prepares reverb parameters for CLDFB-based reverberator *-----------------------------------------------------------------------------------------*/ -ivas_error ivas_reverb_prepare_cldfb_params( +void ivas_reverb_prepare_cldfb_params( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_STATISTICS_HANDLE hHrtfStatistics, const int32_t output_Fs, @@ -115,7 +115,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( pOutput_ene[idx] *= 0.5f * ( avg_pwr_left[idx] + avg_pwr_right[idx] ) * dmx_gain_2; } - return IVAS_ERR_OK; + return; } @@ -137,7 +137,9 @@ static void ivas_reverb_set_energies( const int16_t cldfb_freq_halfstep = IVAS_MAX_SAMPLING_RATE / ( 4 * IVAS_CLDFB_NO_CHANNELS_MAX ); float input_fc[FFT_SPECTRUM_SIZE]; float output_fc[IVAS_CLDFB_NO_CHANNELS_MAX]; - const int16_t avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; + int16_t avg_pwr_len; + + avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; for ( freq_idx = 0; freq_idx < avg_pwr_len; freq_idx++ ) { @@ -150,4 +152,6 @@ static void ivas_reverb_set_energies( } ivas_reverb_interpolate_acoustic_data( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, IVAS_CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); + + return; } diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index 927287ecd96a2b33cb061c32d40013623da77469..b1a85337304077797781882c2553df9406c1d0c5 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -41,6 +41,7 @@ #include "ivas_cnst.h" #include "ivas_stat_rend.h" + /*----------------------------------------------------------------------------------* * DirAC renderer ROM tables *----------------------------------------------------------------------------------*/ @@ -63,6 +64,7 @@ extern const float ap_split_frequencies[DIRAC_DECORR_NUM_SPLIT_BANDS + 1]; extern const int16_t sba_map_tc[11]; extern const int16_t sba_map_tc_512[11]; + /*----------------------------------------------------------------------------------* * FASTCONV and PARAMETRIC binaural renderer ROM tables *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 84484aba2219af4b12f74900305af8ed7eaa94cc..b05efa9ba9d10567fd9ba44d727264f8cf24b69b 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -80,6 +80,7 @@ ivas_error ivas_headTrack_open( ( *hHeadTrackData )->lrSwitchInterpVal = 0.0f; ( *hHeadTrackData )->lrSwitchedCurrent = 0; ( *hHeadTrackData )->lrSwitchedNext = 0; + if ( ( ( *hHeadTrackData )->OrientationTracker = (ivas_orient_trk_state_t *) malloc( sizeof( ivas_orient_trk_state_t ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Orientation tracking" ); @@ -257,7 +258,6 @@ void rotateFrame_shd( int16_t i, l, n, m; int16_t m1, m2; int16_t shd_rot_max_order; - float tmp; float tmpRot[2 * HEADROT_ORDER + 1]; float SHrotmat_prev[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM]; @@ -364,7 +364,6 @@ void rotateFrame_sd( int16_t nchan, index_lfe; int16_t ch_in, ch_in_woLFE, ch_out, ch_out_woLFE; int16_t azimuth, elevation; - float tmp; float tmp_gains[MAX_CICP_CHANNELS - 1]; float gains[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; @@ -693,7 +692,6 @@ ivas_error ivas_external_orientation_open( const int16_t num_subframes /* i : number of subframes */ ) { - int16_t i; IVAS_QUATERNION identity; @@ -705,7 +703,9 @@ ivas_error ivas_external_orientation_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for external orientation memory\n" ) ); } + ( *hExtOrientationData )->num_subframes = num_subframes; + /* Enable head rotation and disable external orientation as default */ for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { @@ -715,6 +715,7 @@ ivas_error ivas_external_orientation_open( ( *hExtOrientationData )->numFramesToTargetOrientation[i] = 0; ( *hExtOrientationData )->Quaternions[i] = identity; } + return IVAS_ERR_OK; } @@ -810,7 +811,6 @@ ivas_error ivas_combined_orientation_open( ( *hCombinedOrientationData )->Quaternion_frozen_ext = identity; ( *hCombinedOrientationData )->Quaternion_frozen_head = identity; - set_zero( ( *hCombinedOrientationData )->chEneIIR[0], MASA_FREQUENCY_BANDS ); set_zero( ( *hCombinedOrientationData )->chEneIIR[1], MASA_FREQUENCY_BANDS ); set_zero( ( *hCombinedOrientationData )->procChEneIIR[0], MASA_FREQUENCY_BANDS ); @@ -930,7 +930,7 @@ ivas_error combine_external_and_head_orientations_rend( * NOTE that the external orientations are inversed. *------------------------------------------------------------------------*/ -ivas_error combine_external_and_head_orientations( +static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ IVAS_VECTOR3 *listenerPos, /* i : listener position */ ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis */ diff --git a/lib_rend/ivas_shoebox.c b/lib_rend/ivas_shoebox.c index fced52304b2f94fa14b17c7ad8d39240471d79f0..b7fdf73da4c7bb2025bed02c8a3ff8831cb09157 100644 --- a/lib_rend/ivas_shoebox.c +++ b/lib_rend/ivas_shoebox.c @@ -61,8 +61,8 @@ *-----------------------------------------------------------------------------------------*/ void ivas_shoebox_config_init( - shoebox_config_t *cal, - RENDER_CONFIG_HANDLE hRenderConfig /* i : Renderer configuration handle */ + shoebox_config_t *cal, /* i/o: shoebox_config_t handle */ + const RENDER_CONFIG_HANDLE hRenderConfig /* i : Renderer configuration handle */ ) { int16_t wall_idx; @@ -95,8 +95,9 @@ void ivas_shoebox_config_init( *-----------------------------------------------------------------------------------------*/ void ivas_shoebox_init( - shoebox_obj_t *obj, - shoebox_config_t *cal ) + shoebox_obj_t *obj, /* i/o: shoebox_obj_t handle */ + const shoebox_config_t *cal /* i : shoebox_config_t handle */ +) { uint16_t i; @@ -359,9 +360,11 @@ void ivas_shoebox_set_scene( float out_tmp; int32_t i, j, k, n; int32_t loop_ub; + /* ------------- SET FLAGS ------------- */ obj->isCartesian = isCartesian; obj->isRelative = isRelative; + /* ------------- CHECK DIMENSIONS ------------- */ if ( ER_PARAMS->n_sources > obj->MAX_SOURCES ) { @@ -371,11 +374,13 @@ void ivas_shoebox_set_scene( { obj->nSrc = ER_PARAMS->n_sources; } + /* ---------- RESET DATA HOLDERS ---------- */ set_f( &obj->src_pos[0], 0.0f, 75U ); obj->list_pos[0] = list_pos[0]; obj->list_pos[1] = list_pos[1]; obj->list_pos[2] = list_pos[2]; + /* ---------- ADJUST LISTENER ------------- */ if ( obj->isZHeight != 0 ) { @@ -440,13 +445,16 @@ void ivas_shoebox_set_scene( { float im_pos[3]; float path_dist; + /* Retrieve coordinate and surface sign */ coord = ( (int32_t) ceilf( ( ( (float) loop_ub ) + 1.0f ) / 2.0f ) ) - 1; rcoselev = ( ( (float) loop_ub ) + 1.0f ) + ( ER_PARAMS->n_ref * ( ( ( (float) j ) + 1.0f ) - 1.0f ) ); + /* Initialize image position coordinates */ im_pos[0] = tmp_pos[0]; im_pos[1] = tmp_pos[1]; im_pos[2] = tmp_pos[2]; + /* Calculate image projection coordinate based on current surface axis */ if ( ( loop_ub + 1 ) < 3 ) { @@ -460,31 +468,29 @@ void ivas_shoebox_set_scene( { scale = obj->cal.room_H; } - im_pos[coord] = - tmp_pos[coord] + - ( 2.0f * ( ( ( ( -( 1.0f - ( fmodf( ( (float) loop_ub ) + 1.0f, 2.0f ) * 2.0f ) ) ) * scale ) / 2.0f ) - tmp_pos[coord] ) ); + + im_pos[coord] = tmp_pos[coord] + ( 2.0f * ( ( ( ( -( 1.0f - ( fmodf( ( (float) loop_ub ) + 1.0f, 2.0f ) * 2.0f ) ) ) * scale ) / 2.0f ) - tmp_pos[coord] ) ); + /* 0. Get euclidean distance from IMAGE SOURCE [N,W] to LIST */ scale = ER_EUCLIDEAN_SCALE; path_dist = shoebox_get_euclidian_distance_internal( obj, im_pos, &scale ); path_dist = scale * sqrtf( path_dist ); + /* 1. Compute time-of arrival (TOA) */ ER_PARAMS->times.data[( (int32_t) rcoselev ) - 1] = path_dist / obj->soundspeed; + /* 2./3. DOA */ - ER_PARAMS->az_angle.data[( (int32_t) rcoselev ) - 1] = - rad2deg( - atan2f( im_pos[1] - obj->list_pos[1], im_pos[0] - obj->list_pos[0] ) ); - ER_PARAMS->el_angle.data[( (int32_t) rcoselev ) - 1] = - rad2deg( - asinf( ( im_pos[2] - obj->list_pos[2] ) / path_dist ) ); + ER_PARAMS->az_angle.data[( (int32_t) rcoselev ) - 1] = rad2deg( atan2f( im_pos[1] - obj->list_pos[1], im_pos[0] - obj->list_pos[0] ) ); + ER_PARAMS->el_angle.data[( (int32_t) rcoselev ) - 1] = rad2deg( asinf( ( im_pos[2] - obj->list_pos[2] ) / path_dist ) ); + /* 4. Compute gain taking into account air and surface absorption */ /* and propagation loss */ if ( path_dist < out_tmp ) { path_dist = out_tmp; } - ER_PARAMS->gains.data[( (int32_t) rcoselev ) - 1] = - ( ( 1.0f - obj->cal.abs_coeff[loop_ub] ) * ( out_tmp / path_dist ) ) - ( path_dist * obj->air_coeff ); + ER_PARAMS->gains.data[( (int32_t) rcoselev ) - 1] = ( ( 1.0f - obj->cal.abs_coeff[loop_ub] ) * ( out_tmp / path_dist ) ) - ( path_dist * obj->air_coeff ); } } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index e990c336f69e0d8c2e45520c92754ff21f3a992d..b06da43911be1d8cae59d554ba2bb536ef6e2fac 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -412,7 +412,6 @@ typedef struct vbap_vs_triplet_structure } VBAP_VS_TRIPLET; - /* Storage structure for fast runtime triplet search */ typedef struct triplet_search_structure { @@ -422,7 +421,6 @@ typedef struct triplet_search_structure } VBAP_SEARCH_STRUCT; - /* VBAP data structure. Contains the formed virtual surface arrangement * and supporting data. */ typedef struct vbap_data_structure { @@ -484,7 +482,6 @@ typedef struct ivas_binaural_reverb_struct } REVERB_STRUCT, *REVERB_STRUCT_HANDLE; - /* Diffuse sound directional distribution data structure */ typedef struct ivas_diffuse_distribution_data_structure { @@ -710,6 +707,7 @@ typedef struct ivas_combined_orientation_struct int16_t cur_subframe_samples_rendered; int16_t subframe_idx_start; int16_t cur_subframe_samples_rendered_start; + } COMBINED_ORIENTATION_DATA, *COMBINED_ORIENTATION_HANDLE; /*----------------------------------------------------------------------------------* @@ -1262,7 +1260,6 @@ typedef struct ivas_hrtf_fastconv_struct } HRTFS_FASTCONV, *HRTFS_FASTCONV_HANDLE; - typedef struct ivas_hrtf_statistics_struct { const float *average_energy_l; @@ -1272,6 +1269,7 @@ typedef struct ivas_hrtf_statistics_struct float *average_energy_r_dyn; float *inter_aural_coherence_dyn; int16_t fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ + } HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; @@ -1314,6 +1312,7 @@ typedef struct ivas_LS_setupconversion_matrix { int16_t index; float value; + } LS_CONVERSION_MATRIX; typedef struct ivas_LS_setupconversion_mapping @@ -1321,6 +1320,7 @@ typedef struct ivas_LS_setupconversion_mapping AUDIO_CONFIG input_config; AUDIO_CONFIG output_config; const LS_CONVERSION_MATRIX *conversion_matrix; + } LS_CONVERSION_MAPPING; typedef struct ivas_mono_downmix_renderer_struct @@ -1391,6 +1391,7 @@ typedef struct ivas_masa_external_rendering_struct HANDLE_CLDFB_FILTER_BANK cldfbAnaRend[MASA_MAX_TRANSPORT_CHANNELS]; HANDLE_CLDFB_FILTER_BANK cldfbSynRend[MAX_OUTPUT_CHANNELS]; + } MASA_EXT_REND_DATA, *MASA_EXT_REND_HANDLE; /*----------------------------------------------------------------------------------* diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 2d77b66ed67f1a287b1ed9a2ef145badee6e80ca..08b409940bedbb7630972fed5ea2eba754fbd604 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -536,8 +536,10 @@ static ivas_error validateOutputAudioConfig( * *-------------------------------------------------------------------*/ +/*! r: audio configuration type */ IVAS_REND_AudioConfigType getAudioConfigType( - const AUDIO_CONFIG config ) + const AUDIO_CONFIG config /* i : audio configuration */ +) { IVAS_REND_AudioConfigType type; @@ -623,8 +625,9 @@ static ivas_error validateOutputSampleRate( *-------------------------------------------------------------------*/ ivas_error getAudioConfigNumChannels( - const AUDIO_CONFIG config, - int16_t *numChannels ) + const AUDIO_CONFIG config, /* i : audio configuration */ + int16_t *numChannels /* o : number of audio channels */ +) { switch ( config ) { @@ -725,7 +728,7 @@ static LSSETUP_CUSTOM_STRUCT defaultCustomLs( static ivas_error getSpeakerAzimuths( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, const float **azimuths ) { switch ( config ) @@ -760,7 +763,7 @@ static ivas_error getSpeakerAzimuths( static ivas_error getSpeakerElevations( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, const float **elevations ) { switch ( config ) @@ -795,7 +798,7 @@ static ivas_error getSpeakerElevations( static ivas_error getAmbisonicsOrder( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, int16_t *order ) { switch ( config ) @@ -838,7 +841,7 @@ static int16_t getNumLfeChannels( } static ivas_error getNumNonLfeChannelsInSpeakerLayout( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, int16_t *numNonLfeChannels ) { switch ( config ) @@ -870,7 +873,7 @@ static ivas_error getNumNonLfeChannelsInSpeakerLayout( } static ivas_error getMcConfigValues( - AUDIO_CONFIG inConfig, + const AUDIO_CONFIG inConfig, const LSSETUP_CUSTOM_STRUCT *pInCustomLs, const float **azimuth, const float **elevation, @@ -938,7 +941,7 @@ static ivas_error getMcConfigValues( static ivas_error initEfap( EFAP_WRAPPER *pEfapWrapper, - AUDIO_CONFIG outConfig, + const AUDIO_CONFIG outConfig, const LSSETUP_CUSTOM_STRUCT *pCustomLsOut ) { ivas_error error; @@ -2044,7 +2047,7 @@ static ivas_error initMcBinauralRendering( RENDER_CONFIG_DATA *hRendCfg, IVAS_DEC_HRTF_CREND_HANDLE hMixconv, HRTFS_STATISTICS_HANDLE hHrtfStatistics, - uint8_t reconfigureFlag ) + const uint8_t reconfigureFlag ) { ivas_error error; int16_t i; @@ -2208,7 +2211,6 @@ static lfe_routing defaultLfeRouting( lfe_routing routing; /* Set all output gains to zero, then route each input LFE consecutively to the next available output LFE. */ - for ( i = 0; i < RENDERER_MAX_INPUT_LFE_CHANNELS; ++i ) { set_zero( routing.lfePanMtx[i], IVAS_MAX_OUTPUT_CHANNELS ); @@ -2289,6 +2291,7 @@ static ivas_error setRendInputActiveMc( { return error; } + initRendInputBase( &inputMc->base, inConfig, id, rendCtx, inputMc->bufferData, MAX_BUFFER_LENGTH ); setZeroPanMatrix( inputMc->panGains ); @@ -2578,7 +2581,7 @@ static ivas_error updateSbaPanGains( static ivas_error initSbaMasaRendering( input_sba *inputSba, - int32_t inSampleRate ) + const int32_t inSampleRate ) { ivas_error error; @@ -2644,7 +2647,7 @@ static ivas_error setRendInputActiveSba( return error; } - return error; + return IVAS_ERR_OK; } @@ -3152,7 +3155,7 @@ ivas_error IVAS_REND_NumOutChannels( static IVAS_REND_InputId makeInputId( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, const int32_t inputIndex ) { /* Put config type in second byte (from LSB), put index + 1 in first byte @@ -3164,7 +3167,7 @@ static IVAS_REND_InputId makeInputId( static ivas_error getInputById( IVAS_REND_HANDLE hIvasRend, - IVAS_REND_InputId inputId, + const IVAS_REND_InputId inputId, void **ppInput ) { int32_t inputIndex; @@ -3341,8 +3344,9 @@ static ivas_error findFreeInputSlot( *------------------------------------------------------------------------*/ static int16_t getCldfbRendFlag( - IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ - const IVAS_REND_AudioConfigType new_configType ) + IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + const IVAS_REND_AudioConfigType new_configType /* i : new Input audio config. type */ +) { int16_t i; int16_t numMasaInputs = 0, numSbaInputs = 0, numIsmInputs = 0, numMcInputs = 0; @@ -4552,6 +4556,11 @@ ivas_error IVAS_REND_SetSplitRendBFI( const int16_t bfi /* i : bad frame indicator */ ) { + if ( hIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + hIvasRend->splitRendBFI = bfi; return IVAS_ERR_OK; @@ -4613,8 +4622,8 @@ ivas_error IVAS_REND_SetReferenceRotation( *-------------------------------------------------------------------*/ // ToDo: not used ivas_error IVAS_REND_GetMainOrientation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer for main orientation */ + const IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_QUATERNION *pOrientation /* o : Quaternion pointer for main orientation */ ) { ivas_error error; @@ -4640,8 +4649,8 @@ ivas_error IVAS_REND_GetMainOrientation( *-------------------------------------------------------------------*/ // ToDo: not used ivas_error IVAS_REND_GetTrackedRotation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *pRotation /* i/o: Quaternion pointer processed rotation */ + const IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_QUATERNION *pRotation /* o : Quaternion pointer processed rotation */ ) { ivas_error error; @@ -4689,13 +4698,13 @@ ivas_error IVAS_REND_SetReferenceVector( *---------------------------------------------------------------------*/ ivas_error IVAS_REND_SetExternalOrientation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *orientation, /* i : external orientation data */ - int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ - int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ - int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ - int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const int16_t sf_idx /* i : subframe index */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_QUATERNION *orientation, /* i : external orientation data */ + const int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ + const int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ + const int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ + const int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const int16_t sf_idx /* i : subframe index */ ) { /* Validate function arguments */ @@ -4748,8 +4757,8 @@ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( *---------------------------------------------------------------------*/ // ToDo: not used ivas_error IVAS_REND_GetCombinedOrientation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer processed orientation */ + const IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer processed orientation */ ) { int16_t i; @@ -5297,7 +5306,10 @@ static ivas_error renderIsmToBinauralRoom( } tmpMcBuffer.config.numChannels = tmp; - tmpMcBuffer.data = malloc( tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels * sizeof( float ) ); + if ( ( tmpMcBuffer.data = malloc( tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderIsmToBinauralRoom()\n" ) ); + } set_zero( tmpMcBuffer.data, tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels ); renderBufferChannelLerp( ismInput->base.inputBuffer, 0, @@ -5448,7 +5460,6 @@ static ivas_error renderIsmToSba( int16_t numOutChannels; pan_vector currentPanGains; ivas_error error; - error = IVAS_ERR_OK; push_wmops( "renderIsmToSba" ); @@ -5497,7 +5508,7 @@ static ivas_error renderIsmToSba( } pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -5693,7 +5704,7 @@ static ivas_error renderInputIsm( static ivas_error renderActiveInputsIsm( - IVAS_REND_HANDLE hIvasRend, + const IVAS_REND_HANDLE hIvasRend, IVAS_REND_AudioBuffer outAudio ) { int16_t i; @@ -5848,7 +5859,10 @@ static ivas_error renderMcToBinaural( if ( combinedOrientationEnabled ) { tmpRotBuffer = mcInput->base.inputBuffer; - tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + if ( ( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderMcToBinaural()\n" ) ); + } 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, mcInput->rot_gains_prev[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) @@ -5937,7 +5951,10 @@ static ivas_error renderMcToBinauralRoom( if ( combinedOrientationEnabled ) { tmpRotBuffer = mcInput->base.inputBuffer; - tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + if ( ( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderMcToBinauralRoom()\n" ) ); + } 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, mcInput->rot_gains_prev[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) @@ -6016,7 +6033,10 @@ static ivas_error renderMcCustomLsToBinauralRoom( if ( combinedOrientationEnabled ) { tmpRotBuffer = mcInput->base.inputBuffer; - tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + if ( ( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderMcCustomLsToBinauralRoom()\n" ) ); + } 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, mcInput->rot_gains_prev[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) @@ -6034,7 +6054,10 @@ static ivas_error renderMcCustomLsToBinauralRoom( } tmpMcBuffer.config.numChannels = tmp; - tmpMcBuffer.data = malloc( tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels * sizeof( float ) ); + if ( ( tmpMcBuffer.data = malloc( tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderMcCustomLsToBinauralRoom()\n" ) ); + } set_zero( tmpMcBuffer.data, tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels ); tmpBufPtr = ( combinedOrientationEnabled ) ? &tmpRotBuffer : &mcInput->base.inputBuffer; @@ -6622,7 +6645,10 @@ static ivas_error renderSbaToBinaural( if ( combinedOrientationEnabled ) { tmpRotBuffer = sbaInput->base.inputBuffer; - tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + if ( ( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderSbaToBinaural()\n" ) ); + } /* copy input for in-place rotation */ mvr2r( sbaInput->base.inputBuffer.data, tmpRotBuffer.data, tmpRotBuffer.config.numChannels * tmpRotBuffer.config.numSamplesPerChannel ); @@ -6699,7 +6725,10 @@ static ivas_error renderSbaToBinauralRoom( if ( combinedOrientationEnabled ) { tmpRotBuffer = sbaInput->base.inputBuffer; - tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); + if ( ( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderSbaToBinauralRoom()\n" ) ); + } /* copy input for in-place rotation */ mvr2r( sbaInput->base.inputBuffer.data, tmpRotBuffer.data, tmpRotBuffer.config.numChannels * tmpRotBuffer.config.numSamplesPerChannel ); @@ -6720,7 +6749,10 @@ static ivas_error renderSbaToBinauralRoom( } tmpMcBuffer.config.numChannels = tmp; - tmpMcBuffer.data = malloc( tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels * sizeof( float ) ); + if ( ( tmpMcBuffer.data = malloc( tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for renderSbaToBinauralRoom()\n" ) ); + } set_zero( tmpMcBuffer.data, tmpMcBuffer.config.numChannels * tmpMcBuffer.config.numSamplesPerChannel ); tmpBufPtr = ( combinedOrientationEnabled ) ? &tmpRotBuffer : &sbaInput->base.inputBuffer; @@ -7310,7 +7342,7 @@ ivas_error IVAS_REND_SetTotalNumberOfObjects( *---------------------------------------------------------------------*/ ivas_error IVAS_REND_SetIsmMetadataDelay( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ const float sync_md_delay /* i : ISM Metadata Delay in ms to sync with audio delay */ ) { @@ -7569,6 +7601,11 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( { int16_t cldfb_in_flag; + if ( hIvasRend == NULL || hIvasRend->hRendererConfig == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN ); hIvasRend->splitRendEncBuffer.config.is_cldfb = cldfb_in_flag; if ( hIvasRend->hRendererConfig->split_rend_config.dof == 0 || hIvasRend->hRendererConfig->split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) @@ -7579,6 +7616,7 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( { hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel = (int16_t) ( hIvasRend->sampleRateOut / FRAMES_PER_SEC ); } + hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel *= cldfb_in_flag ? 2 : 1; /* hIvasRend->splitRendEncBuffer used for BINAURAL_SPLIT_CODED output @@ -7710,6 +7748,11 @@ ivas_error IVAS_REND_openCldfb( int16_t n; ivas_error error; + if ( cldfbAna == NULL || cldfbSyn == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + for ( n = 0; n < num_in_chs; n++ ) { if ( ( error = openCldfb( &( cldfbAna[n] ), CLDFB_ANALYSIS, output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) @@ -7925,6 +7968,7 @@ ivas_error IVAS_REND_GetHrtfParamBinHandle( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_REND_GetHrtfStatisticsHandle( ) * @@ -7959,8 +8003,6 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( DIRAC_REND_HANDLE hDirACRend; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - error = IVAS_ERR_OK; - hDirACRend = NULL; output_Fs = *( inputMasa->base.ctx.pOutSampleRate ); @@ -8254,7 +8296,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( } /* output synthesis */ - if ( ( ivas_dirac_dec_output_synthesis_open( hSpatParamRendCom, hDirACRend, RENDERER_DIRAC, nchan_transport, output_Fs, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_output_synthesis_open( hSpatParamRendCom, hDirACRend, RENDERER_DIRAC, nchan_transport, output_Fs, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -8303,7 +8345,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( inputMasa->hMasaExtRend->hDirACRend = hDirACRend; - return error; + return IVAS_ERR_OK; } static ivas_error ivas_masa_ext_rend_parambin_init( @@ -8325,8 +8367,6 @@ static ivas_error ivas_masa_ext_rend_parambin_init( int16_t pos_idx; const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics; - error = IVAS_ERR_OK; - phHrtfParambin = inputMasa->hMasaExtRend->hHrtfParambin; /* Set common variables and defaults */ @@ -8463,7 +8503,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( inputMasa->hMasaExtRend->hDiracDecBin[pos_idx] = hDiracDecBin; } - return error; + return IVAS_ERR_OK; } static ivas_error initMasaExtRenderer( @@ -8476,8 +8516,6 @@ static ivas_error initMasaExtRenderer( ivas_error error; MASA_EXT_REND_HANDLE hMasaExtRend; - error = IVAS_ERR_OK; - if ( ( hMasaExtRend = (MASA_EXT_REND_HANDLE) malloc( sizeof( MASA_EXT_REND_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA external renderer structure\n" ) ); diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index f71a1a5384af99db36a33a7ac77f696011c1fb36..e20b6ee31b86b0d98c31ae92ea8d241b0f497411 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -68,6 +68,7 @@ typedef struct int16_t isar_frame_size_ms; int16_t lc3plus_highres; } IVAS_REND_BitstreamBufferConfig; + typedef struct { IVAS_REND_BitstreamBufferConfig config; @@ -122,7 +123,6 @@ ivas_error IVAS_REND_Open( const int16_t num_subframes /* i : number of subframes */ ); -/* Note: this will reset custom LFE routings set for any MC input */ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_CUSTOM_LS_DATA layout /* i : custom loudspeaker layout for renderer output */ @@ -304,13 +304,13 @@ ivas_error IVAS_REND_SetReferenceRotation( ); ivas_error IVAS_REND_GetMainOrientation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer for main orientation */ + const IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_QUATERNION *pOrientation /* o : Quaternion pointer for main orientation */ ); ivas_error IVAS_REND_GetTrackedRotation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *pRotation /* i/o: Quaternion pointer for processed rotation */ + const IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_QUATERNION *pRotation /* o : Quaternion pointer for processed rotation */ ); ivas_error IVAS_REND_SetReferenceVector( @@ -326,11 +326,11 @@ ivas_error IVAS_REND_SetSplitRendBFI( ivas_error IVAS_REND_SetExternalOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *orientation, /* i : external orientation data */ - int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ - int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ - int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ - int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const IVAS_QUATERNION *orientation, /* i : external orientation data */ + const int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ + const int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ + const int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ + const int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ const int16_t sf_idx /* i : subframe index */ ); @@ -339,21 +339,21 @@ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( ); ivas_error IVAS_REND_GetCombinedOrientation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer processed orientation */ ); ivas_error IVAS_REND_GetMasaMetadata( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to analyzed MASA metadata */ - const IVAS_REND_AudioConfigType inputType /* i : Input type */ + const IVAS_REND_AudioConfigType inputType /* i : Input type */ ); ivas_error IVAS_REND_MergeMasaMetadata( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to merged metadata */ - const IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ - const IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ + const IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ + const IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ ); ivas_error IVAS_REND_SetTotalNumberOfObjects( diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 727e660dfb926c98983caff10cadee0872ee3407..184b34d895143f2fbc33a82b086b6074c7530861 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -64,7 +64,7 @@ typedef enum typedef struct ivas_hrtfs_header_t { - int32_t rend_type; + HRTF_READER_RENDERER_TYPE rend_type; int32_t input_cfg; int32_t frequency; uint32_t data_size; diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index 48c87a88eae79e998a5dc7774c9962932d7f5f5f..270d4a84feb91c8fb70a1249f3bb848978d21545 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -51,7 +51,7 @@ struct LsCustomFileReader ivas_error CustomLsReader_open( const char *LsFilePath, /* i : LS custom layout file name */ - LsCustomFileReader **hLsCustomReader /* o : LsCustomFileReader handle */ + LsCustomFileReader **hLsCustomReader /* o : LsCustomFileReader handle */ ) { LsCustomFileReader *self; @@ -234,7 +234,7 @@ static void CustomLoudspeakerLayout_print_info( *-------------------------------------------------------------------------*/ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading( - LsCustomFileReader *hLsCustomReader, /* i/o: LsCustomFileReader handle */ + LsCustomFileReader *hLsCustomReader, /* i/o: LsCustomFileReader handle */ IVAS_CUSTOM_LS_DATA *hLsCustomData /* o : Custom loudspeaker setup data */ ) { @@ -378,7 +378,7 @@ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading( * Retrun error message for custom loudspeaker setup error *-------------------------------------------------------------------------*/ -/*!r : custom LS error message */ +/*! r: custom LS error message */ const char *CustomLoudspeakerLayout_getError( LS_CUSTOM_FILEREADER_ERROR error /* i : custom LS error */ ) diff --git a/lib_util/ls_custom_file_reader.h b/lib_util/ls_custom_file_reader.h index 46b20a4ff013827acf56198b2b6f917952f21201..cb484ebe514d7f759b92a8dc64befcde781ade91 100644 --- a/lib_util/ls_custom_file_reader.h +++ b/lib_util/ls_custom_file_reader.h @@ -64,7 +64,7 @@ typedef enum _LS_CUSTOM_FILEREADER_ERROR ivas_error CustomLsReader_open( const char *LsFilePath, /* i : LS custom layout file name */ - LsCustomFileReader **hLsCustomReader /* o : LsCustomFileReader handle */ + LsCustomFileReader **hLsCustomReader /* o : LsCustomFileReader handle */ ); /*-----------------------------------------------------------------------* @@ -84,7 +84,7 @@ void CustomLsReader_close( *-------------------------------------------------------------------------*/ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading( - LsCustomFileReader *hLsCustomReader, /* i/o: LsCustomFileReader handle */ + LsCustomFileReader *hLsCustomReader, /* i/o: LsCustomFileReader handle */ IVAS_CUSTOM_LS_DATA *hLsCustomData /* o : Custom loudspeaker setup data */ ); diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 2cb76f96e6e105fc1c0fa0511000d17d6584e5e1..f942068ca45d9f5cd129daee900bd332bf565fdd 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -32,7 +32,6 @@ #include "masa_file_reader.h" #include "ivas_prot.h" -#include "ivas_stat_com.h" #include "ivas_rom_com.h" /* load 'ivasmasaFormatDescriptor[8]' */ #include #include diff --git a/lib_util/masa_file_writer.c b/lib_util/masa_file_writer.c index 8cac01ff5ab2ad8963d7850cfe367c2590640fb1..9150c67ed7e1c94f703b85693607510fc0fb9a90 100644 --- a/lib_util/masa_file_writer.c +++ b/lib_util/masa_file_writer.c @@ -31,9 +31,7 @@ *******************************************************************************************************/ #include "masa_file_writer.h" -#include "ivas_stat_com.h" #include "ivas_stat_dec.h" -#include "ivas_cnst.h" #include #include #include diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c index 9bdd20e45343aac7bf6828575850638678267184..007d03c7763bab7ae34a6b93429d92802e43a163 100644 --- a/lib_util/mime_io.c +++ b/lib_util/mime_io.c @@ -33,9 +33,9 @@ #include "mime_io.h" #include "mime.h" #include "prot.h" -#include "string.h" #include #include +#include #include