diff --git a/apps/decoder.c b/apps/decoder.c index b078c2441e79184f712047d6fe466f963393aa3d..ffbc64c90ad3f8946c16c7a0a4d91f6dbbd84779 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -605,6 +605,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 ) ); @@ -690,11 +694,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 && @@ -873,6 +879,7 @@ cleanup: free( arg.aeSequence.pID ); free( arg.aeSequence.pValidity ); } + #ifdef DEBUG_SBA_AUDIO_DUMP IVAS_DEC_GetSbaDebugParams( hIvasDec, &numOutChannels, &numTransportChannels, &pca_ingest_channels ); @@ -1269,7 +1276,6 @@ static bool parseCmdlIVAS_dec( } #endif #endif /* #ifdef DEBUGGING */ - else if ( strcmp( argv_to_upper, "-MIME" ) == 0 ) { arg->inputFormat = IVAS_DEC_INPUT_FORMAT_MIME; @@ -1294,6 +1300,7 @@ static bool parseCmdlIVAS_dec( { int32_t tmp; i++; + if ( i < argc - 3 ) { if ( !is_digits_only( argv[i] ) ) @@ -1327,7 +1334,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 ); @@ -1436,6 +1442,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; @@ -1634,6 +1641,7 @@ static bool parseCmdlIVAS_dec( /*-----------------------------------------------------------------* * Option not recognized *-----------------------------------------------------------------*/ + else { fprintf( stderr, "Error: Unknown option %s or wrong number of parameters!\n\n", argv[i] ); @@ -1888,6 +1896,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() @@ -1913,7 +1950,7 @@ static ivas_error initOnFirstGoodFrame( IVAS_RTP *srRtp, /* 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 */ @@ -2058,7 +2095,7 @@ static ivas_error initOnFirstGoodFrame( return IVAS_ERR_FAILED_ALLOC; } - for ( int16_t i = 0; i < numInitialBadFrames; ++i ) + for ( i = 0; i < numInitialBadFrames; ++i ) { if ( isSplitRend ) { @@ -2118,7 +2155,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 ) { @@ -2127,10 +2164,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; @@ -2180,7 +2217,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 ) { @@ -2205,6 +2242,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" ); @@ -2331,7 +2369,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" ); @@ -2408,8 +2445,6 @@ static ivas_error decodeG192( while ( 1 ) { - /* Read next frame if not enough samples availble */ - /* reference vector */ if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 ) { @@ -2458,16 +2493,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 { @@ -2681,9 +2707,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 { @@ -2692,11 +2715,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++; @@ -2771,7 +2794,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 ) @@ -2811,6 +2834,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 ) ); @@ -2825,6 +2849,7 @@ static ivas_error decodeG192( } } } + vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; #ifdef WMOPS if ( vec_pos_update == 0 ) @@ -2843,8 +2868,6 @@ static ivas_error decodeG192( { int16_t nSamplesFlushed; - /* Feed into decoder */ - /* reference vector */ if ( arg.enableReferenceVectorTracking ) { @@ -2896,7 +2919,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 ) ); @@ -2910,7 +2933,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 ) @@ -2949,6 +2972,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 ) ); @@ -3143,7 +3167,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 ); } @@ -3246,11 +3278,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" ); @@ -3282,7 +3316,6 @@ static ivas_error decodeVoIP( goto cleanup; } - #ifdef SUPPORT_JBM_TRACEFILE if ( arg.jbmTraceFilename != NULL ) { @@ -3293,8 +3326,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 ) @@ -3417,16 +3450,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 { @@ -3434,8 +3458,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; } } @@ -3461,11 +3484,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; } } @@ -3779,6 +3800,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 ) ); @@ -3831,10 +3853,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 ) ); @@ -3850,7 +3871,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 ) @@ -3890,6 +3911,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 dc051562c9f54d4004dc3ff9d0f999d2bfd4acc4..ec9a75ac1954556e3750c9f7f26da1ec83cffa81 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1336,7 +1336,6 @@ static bool parseCmdlIVAS_enc( ++i; } - /*-----------------------------------------------------------------* * Complexity Level *-----------------------------------------------------------------*/ @@ -2236,6 +2235,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 3e038de0a4000857adab7af4b4b314d840e268bf..19d2a96dfd5a08288aaf69be007ef1481c19ab58 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -676,7 +676,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 @@ -967,12 +967,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 { @@ -996,8 +996,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 */ @@ -1072,21 +1070,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 { @@ -1128,6 +1118,7 @@ enum TOTAL_DECD_QUANT_STRATS }; + /*----------------------------------------------------------------------------------* * MASA constants *----------------------------------------------------------------------------------*/ @@ -1141,7 +1132,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 @@ -1189,8 +1179,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 @@ -1212,18 +1200,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 */ @@ -1296,6 +1277,7 @@ typedef enum #define MCMASA_MIN_SPEAKERS_SEPARATE_CENTER 4 + /*----------------------------------------------------------------------------------* * MCT constants *----------------------------------------------------------------------------------*/ @@ -1367,6 +1349,7 @@ typedef struct const int16_t (*beta)[2]; } HUFF_NODE_TABLE; + /*----------------------------------------------------------------------------------* * Parametric MC Constants *----------------------------------------------------------------------------------*/ @@ -1418,6 +1401,7 @@ typedef enum #define PARAM_MC_MDFT_NO_SLOTS 8 #define PARAM_MC_CLDFB_TO_MDFT_FAC 2 + /*----------------------------------------------------------------------------------* * LFE Coding Constants *----------------------------------------------------------------------------------*/ @@ -1577,7 +1561,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 36ad0d009cc854aacd4c70450b71712b4e26c4df..0e2689fb928d062404a9fb02213a73f3454f0762 100644 --- a/lib_com/ivas_omasa_com.c +++ b/lib_com/ivas_omasa_com.c @@ -394,7 +394,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 old mode 100644 new mode 100755 index 3e8f951eff62e0aba074b342bd1688ebefac42c9..101fbe5f554bbf4dbfee1c8af1d6be6120ca48f1 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -645,9 +645,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( @@ -712,8 +712,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 */ @@ -768,29 +768,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*/ ); void ivas_apply_non_diegetic_panning( @@ -821,7 +823,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 */ @@ -852,7 +854,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( @@ -1013,7 +1015,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 */ @@ -1080,7 +1082,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 */ ); @@ -1135,9 +1137,9 @@ void ivas_param_ism_dec_prepare_renderer( 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[] /* i/o: synthesized core-coder TCs / rendered signal*/ ); @@ -2948,7 +2950,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( @@ -3463,8 +3464,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 */ @@ -3532,7 +3532,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 */ @@ -3656,21 +3656,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( @@ -3706,9 +3706,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 */ ); @@ -3746,7 +3746,6 @@ void computeDiffuseness( float *diffuseness ); - void ivas_dirac_dec_get_response( const int16_t azimuth, const int16_t elevation, @@ -3807,9 +3806,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 */ ); @@ -3882,9 +3881,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 */ ); @@ -3991,24 +3990,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( @@ -4017,33 +4016,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 */ @@ -4343,9 +4342,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 */ ); @@ -4834,25 +4833,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, @@ -5108,7 +5088,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( @@ -5156,7 +5136,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( @@ -5167,7 +5147,7 @@ ivas_error ivas_allocate_binaural_hrtf( 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 @@ -5264,7 +5244,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( @@ -5308,7 +5288,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 */ @@ -5443,8 +5422,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 */ @@ -5459,9 +5438,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( @@ -5609,9 +5587,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 431613466e96b6939e14289ed57a86c75c4c6262..adbe50669c93a419f2f362cf5804bc06fbc2f3f9 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -1471,7 +1471,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 c624212fc3060e0b874a32170932fbf5c9183f11..476a11b10010bdcecd6518bdb45163645e2876c8 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -702,10 +702,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 3a0bbfba0f6d4b7b72f0fcce050f94031111c854..33899619854cf9e0f25b5a6b16b4beaf1985a2e3 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( @@ -1288,8 +1289,8 @@ void ivas_binaural_add_LFE( *-------------------------------------------------------------------------*/ 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 8094a09052575ccb1f213b90f9d09bc78d9fd63a..dc2a10270cc5b01a8f873282bc42583ba32c3598 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -85,8 +85,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; @@ -190,7 +188,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 ); @@ -576,7 +573,7 @@ ivas_error ivas_cpe_dec( #endif pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -665,8 +662,6 @@ ivas_error create_cpe_dec( ivas_error error; int32_t cpe_brate; - error = IVAS_ERR_OK; - /*-----------------------------------------------------------------* * Allocate CPE handle *-----------------------------------------------------------------*/ @@ -942,7 +937,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 857fdf6078687c33268344a0c041400db79f4e95..99497a71d4609f912be6f5a5d23f58e013fee3f0 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; @@ -2548,6 +2547,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 ac639b7dbaf021ae5e16bf0007bc0767cfa53c72..0f90f7948b74db1f1f6204795bb385a28e973712 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 */ @@ -571,7 +571,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; @@ -782,14 +782,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; @@ -1002,7 +999,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 */ ) { @@ -1708,6 +1705,7 @@ ivas_error ivas_init_decoder( ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( 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++ ) @@ -1761,6 +1759,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; @@ -1868,12 +1867,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; } @@ -2221,7 +2216,6 @@ ivas_error ivas_init_decoder( } #endif - /*-----------------------------------------------------------------* * Allocate and initialize HP20 filter memories *-----------------------------------------------------------------*/ @@ -2263,7 +2257,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 ) ) { 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 410449b7b150477be919ae40d75cbdcc72cb11f1..ced4cdbdd15d0647aba2bc8b970d20df7516c377 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 f364e5e1a065ee2884eea64e26c6e1963ad094af..5a09c2fc93260741e75fbec77da577d757f71c8b 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -197,9 +197,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, @@ -994,7 +994,6 @@ static void ivas_ism_param_dec_tc_gain_adjust( const int16_t nFadeLength, /* i : length of the crossfade in samples */ float *p_data_f[] /* i : synthesized core-coder transport channels/DirAC output*/ ) - { int16_t i; float gain, ene_tc, ene_sum, grad; @@ -1010,10 +1009,12 @@ static void ivas_ism_param_dec_tc_gain_adjust( 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++ ) @@ -1145,11 +1146,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[] /* i/o: synthesized core-coder TCs / rendered 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; @@ -1264,7 +1265,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 a3855196dd08660376353593a0d618ddef32c250..44ff6fd25550d2f498a5ad4925105de6f1e805fe 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 ) { @@ -1394,9 +1396,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 ) ) @@ -1429,7 +1433,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 ); } } @@ -1441,7 +1445,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 f689275098ccc9cf7c441883487222dfe5b30e6b..c67f42258749e268ff476e8fadb61e3a77c8849d 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++ ) { @@ -839,7 +836,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; } @@ -1532,11 +1529,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; @@ -1629,6 +1626,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++ ) @@ -1766,8 +1764,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 ) @@ -2668,9 +2665,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; @@ -2784,6 +2778,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 65904b2183c1416ad8bcbb7d6609f20c2c39d420..be6f2d6d784c660732b8b8347aea6ee8a73953ac 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 bc492bd1ab6a786b742d003e5827d58704503d1d..479c88f00ccf804a7bf71f6ee7a620f4e26523e8 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; } @@ -1304,78 +1303,77 @@ 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; - - 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 = BINAURAL_CHANNELS; - if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) - { - tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; - } - else if ( st_ivas->hOutSetup.separateChannelEnabled ) - { - tc_nchan_allocate_new++; - } + int16_t tc_nchan_full_new; + DECODER_TC_BUFFER_HANDLE hTcBuffer; - 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 ) + 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 = BINAURAL_CHANNELS; + if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) { - tc_nchan_full_new = 0; + tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + else if ( st_ivas->hOutSetup.separateChannelEnabled ) { - 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; + 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; - } - } + tc_nchan_full_new = tc_nchan_allocate_new; + } - /* 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 e9d347e15d2374e10de827ae5e4c39282b68ec93..5bb62c94c4a36712f31c0355d85383f27e1b7523 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -753,7 +753,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 ) @@ -916,11 +916,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] ); } } @@ -952,6 +948,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]; @@ -1145,11 +1142,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] ); } } @@ -1220,6 +1213,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]; @@ -1247,6 +1241,7 @@ void ivas_omasa_render_objects_from_mix( } } } + for ( slot = 0; slot < CLDFB_NO_COL_MAX; slot++ ) { for ( bin = 0; bin < nBins; bin++ ) @@ -1272,6 +1267,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 9b3041c09a543af98a9d35741c88dc633e2282a9..3bafadcaf5a3000ede0547c9f242de1f4adaf888 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; @@ -151,6 +151,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 1f66f3f3089886b6608e892f383aa747f33f7796..0b22904e5861f8e281227e733e7dee0fa732a0ed 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -76,7 +76,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 ); @@ -164,7 +163,6 @@ void ivas_renderer_select( if ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation || st_ivas->hCombinedOrientationData ) { - 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 649cda2f12ec66d8ed21152910c30f21e116448d..f86def39c8cdf5b77bb77f744409402b43fcd6c1 --- 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; @@ -116,8 +117,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; @@ -177,30 +182,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 ); } } @@ -208,23 +213,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 ) { @@ -233,11 +234,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; } @@ -263,7 +264,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 ) @@ -345,21 +345,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; } } @@ -373,7 +373,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; } /*-----------------------------------------------------------------* @@ -381,6 +381,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 ) @@ -561,7 +562,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 ) { @@ -571,24 +572,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]; } } @@ -689,11 +690,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 8538411328524c0103695b93bfd5af13ef2d1ba1..ce71f036de1919c9c0da04a2beca8faf4e679134 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 dd8bf56d42f0eb8b633836b5250cdbb37bfb075e..40e3a090a37a19a6f8e4e8b329737bb2d18ef662 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 dcfb151479c73f0c89d74607ea7a0ab443b94d72..2c6f51f0ecaef3490127ca4f018fb0dce6dc6dca 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 */ @@ -1008,8 +1008,8 @@ typedef struct decoder_config_structure int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ int16_t Opt_ObjEdit_on; /* indicates whether object editing option is used */ 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 */ + IVAS_RENDER_FRAMESIZE render_framesize; /* rendering frame size */ + int16_t Opt_delay_comp; /* flag indicating delay compensation active */ } DECODER_CONFIG, *DECODER_CONFIG_HANDLE; @@ -1080,6 +1080,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 */ @@ -1109,11 +1110,10 @@ 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 */ + SBA_ISM_DATA_HANDLE hSbaIsmData; /* OSBA rendering handle */ IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAcousticEnvironments; /* Acoustic environment array */ uint16_t acousticEnvironmentsCount; /* Number of acoustic environments in the array*/ - int16_t flag_omasa_brate; 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.c b/lib_dec/lib_dec.c index b6b8efc3a5cdfca8769acdc2a609b262e9052dcf..b56ac3d6b204bd51c686e3d26e2146065db84499 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -5705,7 +5705,7 @@ static void setDiegeticInputPI( st_ivas->hCombinedOrientationData->isDiegeticInputPI[i] = diegeticPIValues[i]; } - st_ivas->hCombinedOrientationData->isDiegeticInputPISet = true; + st_ivas->hCombinedOrientationData->isDiegeticInputPISet = TRUE; } return; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index f62087b9af80dcbaa68a43d292c05f81e1aa9890..bf2dae736af125604f32a10640235bdeb55abf1b 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -173,7 +173,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 */ @@ -356,7 +356,7 @@ 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 */ + const IVAS_RENDER_FRAMESIZE render_framesize/* i : render framesize */ ); ivas_error IVAS_DEC_GetRenderFramesize( @@ -553,14 +553,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 fb5d6f63b02d74138d90f78ca482f7cabef20ce5..dc3ba6fcfe2df4ecb07b94b81b6d9f687c78615a 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 *----------------------------------------------------------------*/ @@ -712,7 +712,6 @@ ivas_error ivas_cpe_enc( } } - /*----------------------------------------------------------------* * Core Encoder *----------------------------------------------------------------*/ @@ -801,10 +800,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; } @@ -828,8 +827,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; @@ -1067,7 +1064,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 8f6eb68b96a4efa2f43c9f3e87361b48b2a11ff0..9cc7c959179a0017efafd1983f3c6c02c91b10dc 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -562,8 +562,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 336e5fcbfe905367258a625a89215ad678aba837..2c2ba840a4cdd25858393353f3da444a4e89f58b 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -752,13 +752,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 5d1f56ab30c3243eb0f0187e1b32761ee14979d7..2a13cfd94647d5c963d643afc83850c59b9d0249 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 8017d101c973db0a6f398099ac0167580f614c12..435b247edcaac91f8388d0dfe1936244b828f241 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -119,7 +119,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 7088abc5111e84e926f3ddde35e588a6aff336d1..ff596e4eceb788df9b8d4f2a5dbe71faf7894741 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; @@ -1455,8 +1469,8 @@ ivas_error IVAS_ENC_SetChannelAwareConfig( return setChannelAwareConfig( hIvasEnc, rfConfig ); } - #ifdef DEBUGGING + /*---------------------------------------------------------------------* * IVAS_ENC_SetForcedMode() * @@ -1490,8 +1504,8 @@ ivas_error IVAS_ENC_SetForcedMode( return IVAS_ERR_OK; } -#endif /* DEBUGGING */ +#endif /* DEBUGGING */ /*---------------------------------------------------------------------* * IVAS_ENC_GetDefaultBandwidth() @@ -1499,7 +1513,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; @@ -1518,9 +1533,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; @@ -1535,9 +1552,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; @@ -1573,6 +1592,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; @@ -2019,6 +2043,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; @@ -2170,6 +2199,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 */ @@ -2308,6 +2342,7 @@ static ivas_error fecIndicatorApiToInternal( } #ifdef DEBUGGING + /*---------------------------------------------------------------------* * forcedModeApiToInternal() * @@ -2348,8 +2383,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 f7fe0db32ebeba38eeec378a57c47154a8031046..49d0a464ee440bf70c38f770d6c11b9eb20a0501 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 "lc3plus.h" /*-----------------------------------------------------------------------------------------* * Function ISAR_LC3PLUS_LC3plusErrToIvasErr() diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 91346675023091f478cd4a637e93d0347e1d052e..3f379de0c49e33652efc758be6077a04dc0fa26c 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; @@ -1146,15 +1146,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; @@ -1343,7 +1344,8 @@ ivas_error ivas_rend_openCrend( *------------------------------------------------------------------------*/ void ivas_rend_closeCrend( - CREND_WRAPPER_HANDLE *pCrend ) + CREND_WRAPPER_HANDLE *pCrend /* i/o: Crend wrapper handle */ +) { int16_t i; int16_t pos_idx; @@ -1362,6 +1364,7 @@ void ivas_rend_closeCrend( for ( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) { hCrend = ( *pCrend )->hCrend[pos_idx]; + if ( hCrend != NULL ) { for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) @@ -1392,6 +1395,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 f8e7211fe7f6f85ca09d0e2d3d8e2f04020af400..1ce81d947557e42003249483e5a66b58ef68f091 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 ); @@ -339,6 +337,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } + return IVAS_ERR_OK; } @@ -433,18 +432,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; @@ -458,6 +457,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[ch]; @@ -1061,6 +1061,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; @@ -1449,6 +1450,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, @@ -1796,7 +1798,6 @@ static void ivas_dirac_dec_binaural_process_output( decSlotImPointer = NULL; } - for ( bin = 0; bin < nBins; bin++ ) { float gain; @@ -1971,6 +1972,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], @@ -2543,10 +2545,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++ ) { @@ -2572,7 +2571,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 */ ) { @@ -3287,6 +3286,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, @@ -3403,7 +3408,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 ); ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, @@ -3508,6 +3512,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 4432133cd4206f10ba9d42cafe73ded976b474b3..0ff41b07eb32b99acaaea8d87e1fd2251e877a1d 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 a4e15c79dea1ae54e130d550b50e21d8c296049a..36388a65368a8afe6bfc0e4a7d34cdebb78b9a39 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; } @@ -663,12 +664,12 @@ ivas_error TDREND_Update_listener_orientation( *---------------------------------------------------------------------*/ ivas_error ivas_td_binaural_open_ext( - TDREND_WRAPPER *pTDRend, /* i/o: TD Renderer wrapper structure */ - const AUDIO_CONFIG inConfig, /* i : input audio configuration */ - RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ - LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ - const int32_t outFs, /* i : output sampling rate */ - const int16_t object_id /* i : Object ID */ + TDREND_WRAPPER *pTDRend, /* i/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 */ + const int16_t object_id /* i : Object ID */ ) { int16_t nchan_transport; @@ -676,7 +677,6 @@ ivas_error ivas_td_binaural_open_ext( IVAS_FORMAT ivas_format; IVAS_OUTPUT_SETUP hTransSetup; ivas_error error; - float *distAtt = NULL; float *directivity = NULL; @@ -710,7 +710,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 ); } @@ -724,7 +724,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 967d70bb8e5fd62688d419868c8b5c4617940410..0312e2b0a41905a7d91206c17c05faea6eb946de 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,10 +660,10 @@ ivas_error ivas_td_binaural_open_unwrap( ); ivas_error ivas_td_binaural_open_ext( - TDREND_WRAPPER *pTDRend, /* i/o: TD Renderer wrapper structure */ - const AUDIO_CONFIG inConfig, /* i : input audio configuration */ - RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ - LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ + 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 */ const int16_t object_id /* i : Object ID */ ); @@ -670,10 +673,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( @@ -745,11 +748,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 */ @@ -893,15 +898,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( @@ -1123,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, @@ -1147,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], @@ -1170,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 */ ); @@ -1201,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( @@ -1297,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 */ @@ -1312,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 *----------------------------------------------------------------------------------*/ @@ -1444,19 +1450,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 3f9e3aef0ffee1397b9fdf2fe79797cde5c8da37..2d7ca13f99e50e3b5d7fbc0d77ef7b1b122922e7 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -985,6 +985,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 */ @@ -1879,10 +1880,7 @@ ivas_error ivas_binaural_reverb_init( if ( roomAcoustics != NULL ) { - if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, revTimes, revEne ) ) != IVAS_ERR_OK ) - { - return error; - } + ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, revTimes, revEne ); /* Convert preDelay from seconds to CLDFB slots as needed by binaural reverb */ preDelay = (int16_t) roundf( roomAcoustics->acousticPreDelay * CLDFB_SLOTS_PER_SECOND ); 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 880408e69d184b3c8aba26db1eecc380f09a4aa8..34ec9d4b0687654f04d4a6fe7d3bdaddd43b3652 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 3910ddea87cb7d32755e6db6dafd51c0dcbf30e3..48af1bf1194841b245b6f7630939200445a1a46f 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_LS_CHANNELS - 1]; float gains[MAX_LS_CHANNELS][MAX_LS_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,6 +703,7 @@ 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 */ @@ -812,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 ); @@ -827,9 +825,9 @@ ivas_error ivas_combined_orientation_open( for ( i = 0; i < ( 1 + IVAS_MAX_NUM_OBJECTS ); i++ ) { - ( *hCombinedOrientationData )->isDiegeticInputPI[i] = true; + ( *hCombinedOrientationData )->isDiegeticInputPI[i] = TRUE; } - ( *hCombinedOrientationData )->isDiegeticInputPISet = false; + ( *hCombinedOrientationData )->isDiegeticInputPISet = FALSE; return IVAS_ERR_OK; } @@ -935,7 +933,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 */ @@ -1079,6 +1077,7 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->Quaternion_frozen_head = identity; hCombinedOrientationData->isHeadRotationFrozen = 0; } + /* Disable head rotation if diegetic PI data indicating non-diegetic audio is received */ if ( hCombinedOrientationData->isDiegeticInputPISet && !hCombinedOrientationData->isDiegeticInputPI[0] && !hCombinedOrientationData->isDiegeticInputPI[1] && !hCombinedOrientationData->isDiegeticInputPI[2] && !hCombinedOrientationData->isDiegeticInputPI[3] && !hCombinedOrientationData->isDiegeticInputPI[4] ) { 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 bcb948d05d5648e060e6e72d59a42cbf6e8e04f7..02dfff84c6841af4c7bd132ecb1fdbda665e30e8 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,8 +707,9 @@ typedef struct ivas_combined_orientation_struct int16_t cur_subframe_samples_rendered; int16_t subframe_idx_start; int16_t cur_subframe_samples_rendered_start; - bool isDiegeticInputPI[1 + IVAS_MAX_NUM_OBJECTS]; - bool isDiegeticInputPISet; + int8_t isDiegeticInputPI[1 + IVAS_MAX_NUM_OBJECTS]; + int8_t isDiegeticInputPISet; + } COMBINED_ORIENTATION_DATA, *COMBINED_ORIENTATION_HANDLE; /*----------------------------------------------------------------------------------* @@ -1264,7 +1262,6 @@ typedef struct ivas_hrtf_fastconv_struct } HRTFS_FASTCONV, *HRTFS_FASTCONV_HANDLE; - typedef struct ivas_hrtf_statistics_struct { const float *average_energy_l; @@ -1317,6 +1314,7 @@ typedef struct ivas_LS_setupconversion_matrix { int16_t index; float value; + } LS_CONVERSION_MATRIX; typedef struct ivas_LS_setupconversion_mapping @@ -1324,6 +1322,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 @@ -1410,6 +1409,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 ed8c0f008f886d81f81f53cd7b057bec0efd1a45..390a7455f3c476e265767994fe5a67adf5ae3abb 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -552,8 +552,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; @@ -639,8 +641,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 ) { @@ -741,7 +744,7 @@ static LSSETUP_CUSTOM_STRUCT defaultCustomLs( static ivas_error getSpeakerAzimuths( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, const float **azimuths ) { switch ( config ) @@ -776,7 +779,7 @@ static ivas_error getSpeakerAzimuths( static ivas_error getSpeakerElevations( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, const float **elevations ) { switch ( config ) @@ -811,7 +814,7 @@ static ivas_error getSpeakerElevations( static ivas_error getAmbisonicsOrder( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, int16_t *order ) { switch ( config ) @@ -854,7 +857,7 @@ static int16_t getNumLfeChannels( } static ivas_error getNumNonLfeChannelsInSpeakerLayout( - AUDIO_CONFIG config, + const AUDIO_CONFIG config, int16_t *numNonLfeChannels ) { switch ( config ) @@ -886,7 +889,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, @@ -954,7 +957,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; @@ -2343,7 +2346,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; @@ -2507,7 +2510,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], RENDERER_MAX_OUTPUT_CHANNELS ); @@ -2588,6 +2590,7 @@ static ivas_error setRendInputActiveMc( { return error; } + initRendInputBase( &inputMc->base, inConfig, id, rendCtx, inputMc->bufferData, MAX_BUFFER_LENGTH ); setZeroPanMatrix( inputMc->panGains ); @@ -2879,7 +2882,7 @@ static ivas_error updateSbaPanGains( static ivas_error initSbaMasaRendering( input_sba *inputSba, - int32_t inSampleRate ) + const int32_t inSampleRate ) { ivas_error error; @@ -3459,7 +3462,7 @@ ivas_error IVAS_REND_GetNumOutChannels( 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 @@ -3471,7 +3474,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; @@ -3673,8 +3676,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; @@ -4963,6 +4967,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; @@ -5024,8 +5033,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; @@ -5051,8 +5060,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; @@ -5100,13 +5109,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 */ @@ -5159,8 +5168,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; @@ -5181,11 +5190,13 @@ ivas_error IVAS_REND_GetCombinedOrientation( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* - * IVAS_REND_GetCombinedOrientation() + * IVAS_REND_GetReverbRoomSize() * * *---------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetReverbRoomSize( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_ROOM_SIZE_T *reverbRoomSize /* o : Reverb room size */ @@ -5211,11 +5222,13 @@ ivas_error IVAS_REND_GetReverbRoomSize( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_REND_GetCombinedOrientation() * * *---------------------------------------------------------------------*/ + ivas_error IVAS_REND_SetReverbRoomSize( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_ROOM_SIZE_T reverbRoomSize /* i : Reverb room size */ @@ -5783,7 +5796,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, @@ -5934,7 +5950,6 @@ static ivas_error renderIsmToSba( int16_t numOutChannels; pan_vector currentPanGains; ivas_error error; - error = IVAS_ERR_OK; push_wmops( "renderIsmToSba" ); @@ -5983,7 +5998,7 @@ static ivas_error renderIsmToSba( } pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -6209,7 +6224,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; @@ -6363,7 +6378,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 ) @@ -6452,7 +6470,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 ) @@ -6531,7 +6552,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 ) @@ -6549,7 +6573,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; @@ -7137,7 +7164,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 ); @@ -7214,7 +7244,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 ); @@ -7235,7 +7268,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; @@ -7826,7 +7862,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 int16_t sync_md_delay /* i : ISM Metadata Delay in ms to sync with audio delay */ ) { @@ -8048,7 +8084,8 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( { pSplitEncBufConfig->numSamplesPerChannel = (int16_t) ( hIvasRend->sampleRateOut / FRAMES_PER_SEC ); } - pSplitEncBufConfig->numSamplesPerChannel *= cldfb_in_flag ? 2 : 1; + + hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel *= cldfb_in_flag ? 2 : 1; num_poses_orig = hIvasRend->splitRendWrapper->multiBinPoseData.num_poses; ISAR_PRE_REND_GetMultiBinPoseData( pSplitRendConfig, @@ -8259,6 +8296,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 ) @@ -8474,6 +8516,7 @@ ivas_error IVAS_REND_GetHrtfParamBinHandle( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_REND_GetHrtfStatisticsHandle( ) * @@ -8508,8 +8551,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 ); @@ -8803,7 +8844,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; } @@ -8852,7 +8893,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( @@ -8874,8 +8915,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 */ @@ -9012,7 +9051,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( @@ -9025,8 +9064,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 267b24b6ea1525090b3583db6bb8a9e10fa46891..241fe0fe98476071f3d641c46f0fc5f3f2758f5b 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -125,7 +125,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 */ @@ -323,13 +322,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( @@ -345,11 +344,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 */ ); @@ -358,21 +357,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 938b5c1595024042c0ebc845fdfe9439d11b9c1c..a43086c1225b07a35d86a5c22d83b4c4d8b9248f 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/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c index 3c7c942b17e142e19e2da7764de2a0b368e136cd..e198c791eddbe09c4197149411310ea2778afb15 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -29,18 +29,18 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ + #include #include #include #include "common_api_types.h" - - #include "ivas_rtp_internal.h" #include "ivas_bpool.h" #include "ivas_queue.h" #include "ivas_error_utils.h" #include "mutex.h" + #define IVAS_MAX_BYTES_PER_FRAME ( ( IVAS_MAX_BITS_PER_FRAME + 7 ) >> 3 ) #define MAX_TOC_PER_FRAME ( 2u ) /* Main ToC Byte + SR-ToC byte */ @@ -227,6 +227,8 @@ static void InitRtpHeader( { memset( header, 0, sizeof( *header ) ); header->version = 2; + + return; } static ivas_error PackRtpHeader( diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index d874342c11b839c9526f361f8df35bba42423f25..90ffc62edee40c1b53a3e30aefd5a4d00299bf13 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 1122878f8a5c8f84d8f50d73c33d644926bc5084..9f49f23317050d0f931597e779338ccf57a7f711 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 3f269a68717c6d1a55196bb04c5304bb1315dcb7..0e882194fc2fb0157e9db8f614d1161a340034d6 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 1ecd603b32a752b4f819a3636bdedfd1179c4209..7385181cfe6b289852bf666428f53410d7f59071 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