Loading lib_dec/ivas_osba_dec.c 0 → 100644 +365 −0 Original line number Diff line number Diff line /****************************************************************************************************** (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other contributors to this repository. All Rights Reserved. This software is protected by copyright law and by international treaties. The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other contributors to this repository retain full ownership rights in their respective contributions in the software. This notice grants no license of any kind, including but not limited to patent license, nor is any license granted by implication, estoppel or otherwise. Contributors are required to enter into the IVAS codec Public Collaboration agreement before making contributions. This software is provided "AS IS", without any express or implied warranties. The software is in the development stage. It is intended exclusively for experts who have experience with such software and solely for the purpose of inspection. All implied warranties of non-infringement, merchantability and fitness for a particular purpose are hereby disclaimed and excluded. Any dispute, controversy or claim arising under or in relation to providing this software shall be submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ #include "options.h" #include <stdlib.h> #include "ivas_cnst.h" #include "ivas_prot.h" #include "prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" #endif #ifdef OSBA_DISC_OBJ_MCT /*-------------------------------------------------------------------* * ivas_masa_ism_data_open() * * Allocate and initialize MASA_ISM rendering handle *-------------------------------------------------------------------*/ ivas_error ivas_masa_ism_data_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) { MASA_ISM_DATA_HANDLE hMasaIsmData; int16_t ch, bin; int16_t sf, obj_idx; if ( ( hMasaIsmData = (MASA_ISM_DATA_HANDLE) malloc( sizeof( MASA_ISM_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA ISM data\n" ) ); } #if 0 for ( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) { for ( ch = 0; ch < 2; ch++ ) { hMasaIsmData->ismPreprocMatrix[ch][ch][bin] = 1.0f; hMasaIsmData->ismPreprocMatrix[1 - ch][ch][bin] = 0.0f; hMasaIsmData->eneMoveIIR[ch][bin] = 0.0f; hMasaIsmData->enePreserveIIR[ch][bin] = 0.0f; } hMasaIsmData->preprocEneTarget[bin] = 0.0f; hMasaIsmData->preprocEneRealized[bin] = 0.0f; } hMasaIsmData->objectsMoved = 0; hMasaIsmData->delayBuffer = NULL; for ( ch = 0; ch < st_ivas->nchan_ism; ch++ ) { hMasaIsmData->q_elevation_old[ch] = 0.0f; hMasaIsmData->q_azimuth_old[ch] = 0.0f; } for ( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ ) { set_s( hMasaIsmData->azimuth_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); set_s( hMasaIsmData->elevation_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ ) { set_zero( hMasaIsmData->energy_ratio_ism[obj_idx][sf], CLDFB_NO_CHANNELS_MAX ); } } set_s( hMasaIsmData->azimuth_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); set_s( hMasaIsmData->elevation_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); #endif st_ivas->hMasaIsmData = hMasaIsmData; return IVAS_ERR_OK; } /*-------------------------------------------------------------------* * ivas_masa_ism_data_close() * * Deallocate MASA_ISM rendering handle *-------------------------------------------------------------------*/ void ivas_masa_ism_data_close( MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ ) { int16_t i; if ( hMasaIsmData == NULL || *hMasaIsmData == NULL ) { return; } if ( ( *hMasaIsmData )->delayBuffer != NULL ) { for ( i = 0; i < ( *hMasaIsmData )->delayBuffer_nchan; i++ ) { free( ( *hMasaIsmData )->delayBuffer[i] ); } free( ( *hMasaIsmData )->delayBuffer ); ( *hMasaIsmData )->delayBuffer = NULL; } free( *hMasaIsmData ); *hMasaIsmData = NULL; return; } /*-------------------------------------------------------------------------* * ivas_masa_ism_separate_object_renderer_open() * * Open structures, reserve memory, and init values. *-------------------------------------------------------------------------*/ ivas_error ivas_masa_ism_separate_object_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { int16_t interpolator_length; int16_t i; int16_t init_interpolator_length; st_ivas->hMasaIsmData->delayBuffer_nchan = st_ivas->nchan_ism; st_ivas->hMasaIsmData->delayBuffer_size = (int16_t) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES ); if ( ( st_ivas->hMasaIsmData->delayBuffer = (float **) malloc( st_ivas->hMasaIsmData->delayBuffer_nchan * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); } for ( i = 0; i < st_ivas->hMasaIsmData->delayBuffer_nchan; i++ ) { if ( ( st_ivas->hMasaIsmData->delayBuffer[i] = (float *) malloc( st_ivas->hMasaIsmData->delayBuffer_size * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); } set_zero( st_ivas->hMasaIsmData->delayBuffer[i], st_ivas->hMasaIsmData->delayBuffer_size ); } return IVAS_ERR_OK; } /*--------------------------------------------------------------------------* * ivas_omasa_dirac_td_binaural() * * Binaural rendering in OMASA format *--------------------------------------------------------------------------*/ ivas_error ivas_omasa_dirac_td_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output[][L_FRAME48k], /* o : output synthesis signal */ const int16_t output_frame /* i : output frame length per channel */ ) { int16_t n; float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; float gain = 0.7943f; /* Todo Nokia: Temporary gain for roughly matching the loudness of other processing paths. */ ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; #ifdef SBA_AND_OBJECTS int16_t channel_offset; #endif for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { p_sepobj[n] = &data_separated_objects[n][0]; } #ifdef SBA_AND_OBJECTS channel_offset = st_ivas->nchan_transport; if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->nchan_transport == 3 ) /* channels are remapped in ivas_sba_remapTCs() */ { channel_offset = 4; } channel_offset = 0; #endif for ( n = 0; n < st_ivas->nchan_ism; n++ ) { #ifdef SBA_AND_OBJECTS mvr2r( output[channel_offset + n], data_separated_objects[n], output_frame ); #else mvr2r( output[2 + n], data_separated_objects[n], output_frame ); #endif // v_multc( data_separated_objects[n], gain, data_separated_objects[n], output_frame ); } #if 1 { int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; for ( int t = 0; t < output_frame; t++ ) { for ( int c = 0; c < 4; c++ ) { int16_t val = (int16_t) ( data_separated_objects[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "sep_obj.raw" ); } } } #endif for ( n = 0; n < st_ivas->nchan_ism; n++ ) { delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } #if 1 { int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; for ( int t = 0; t < output_frame; t++ ) { for ( int c = 0; c < 4; c++ ) { int16_t val = (int16_t) ( data_separated_objects[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "sep_obj_delay.raw" ); } } } #endif #ifdef SBA_AND_OBJECTS if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { ivas_sba_upmixer_renderer( st_ivas, &output[MAX_NUM_OBJECTS], output_frame ); } else { ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[MAX_NUM_OBJECTS], st_ivas->nchan_transport ); } #else ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport ); #endif #if 1 { int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; for ( int t = 0; t < output_frame; t++ ) { for ( int c = 4; c < 4 + nchan; c++ ) { int16_t val = (int16_t) ( output[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "int_dec_bin_hoa.raw" ); } } } #endif if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK ) { return error; } #if 1 { int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; for ( int t = 0; t < output_frame; t++ ) { for ( int c = 0; c < nchan; c++ ) { int16_t val = (int16_t) ( p_sepobj[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "int_dec_bin_obj.raw" ); } } } #endif for ( n = 0; n < BINAURAL_CHANNELS; n++ ) { #if 0 v_add( output[MAX_NUM_OBJECTS + n], p_sepobj[n], output[n], output_frame ); #else int16_t i; for(i=0; i<output_frame; i++) { output[n][i]=0.5f*output[MAX_NUM_OBJECTS + n][i]+0.5f*p_sepobj[n][i] ; } #endif } return IVAS_ERR_OK; } ivas_error ivas_osba_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int32_t ism_total_brate, /* i : ISM total bitrate */ int16_t *nchan_ism, /* o : number of ISM separated channels */ int16_t *nchan_transport_ism, /* o : number of ISM TCs */ const int16_t dirac_bs_md_write_idx, /* i : DirAC bitstream write index */ int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ) { int16_t n, block; int16_t azimuth_ism, elevation_ism, meta_write_index; ivas_error error; /* set ISM parameters */ *nchan_ism = st_ivas->nchan_ism; *nchan_transport_ism = st_ivas->nchan_ism; /* decode ISM metadata */ if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) { return error; } #if 0 if ( st_ivas->hDirAC != NULL ) { if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { azimuth_ism = (int16_t) ( st_ivas->hIsmMetaData[n]->azimuth + 0.5f ); elevation_ism = (int16_t) ( st_ivas->hIsmMetaData[n]->elevation + 0.5f ); for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) { meta_write_index = ( dirac_bs_md_write_idx + block ) % st_ivas->hDirAC->dirac_md_buffer_length; st_ivas->hMasaIsmData->azimuth_ism[n][meta_write_index] = azimuth_ism; st_ivas->hMasaIsmData->elevation_ism[n][meta_write_index] = elevation_ism; } } } } #endif return IVAS_ERR_OK; } #endif lib_enc/ivas_enc.c +8 −0 Original line number Diff line number Diff line Loading @@ -61,7 +61,11 @@ ivas_error ivas_enc( ENCODER_CONFIG_HANDLE hEncoderConfig; BSTR_ENC_HANDLE hMetaData; Encoder_State *st; /* used for bitstream handling */ #ifdef OSBA_DISC_OBJ_MCT int16_t nb_bits_metadata[MAX_SCE + 1]; #else int16_t nb_bits_metadata[MAX_SCE]; #endif #ifdef SBA_AND_OBJECTS float data_f[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; #else Loading @@ -87,7 +91,11 @@ ivas_error ivas_enc( input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); n_samples_chan = n_samples / nchan_inp; #ifdef OSBA_DISC_OBJ_MCT set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); #else set_s( nb_bits_metadata, 0, MAX_SCE ); #endif /*----------------------------------------------------------------* * convert 'short' input data to 'float' Loading Loading
lib_dec/ivas_osba_dec.c 0 → 100644 +365 −0 Original line number Diff line number Diff line /****************************************************************************************************** (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other contributors to this repository. All Rights Reserved. This software is protected by copyright law and by international treaties. The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other contributors to this repository retain full ownership rights in their respective contributions in the software. This notice grants no license of any kind, including but not limited to patent license, nor is any license granted by implication, estoppel or otherwise. Contributors are required to enter into the IVAS codec Public Collaboration agreement before making contributions. This software is provided "AS IS", without any express or implied warranties. The software is in the development stage. It is intended exclusively for experts who have experience with such software and solely for the purpose of inspection. All implied warranties of non-infringement, merchantability and fitness for a particular purpose are hereby disclaimed and excluded. Any dispute, controversy or claim arising under or in relation to providing this software shall be submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ #include "options.h" #include <stdlib.h> #include "ivas_cnst.h" #include "ivas_prot.h" #include "prot.h" #include "ivas_prot_rend.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" #endif #ifdef OSBA_DISC_OBJ_MCT /*-------------------------------------------------------------------* * ivas_masa_ism_data_open() * * Allocate and initialize MASA_ISM rendering handle *-------------------------------------------------------------------*/ ivas_error ivas_masa_ism_data_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) { MASA_ISM_DATA_HANDLE hMasaIsmData; int16_t ch, bin; int16_t sf, obj_idx; if ( ( hMasaIsmData = (MASA_ISM_DATA_HANDLE) malloc( sizeof( MASA_ISM_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA ISM data\n" ) ); } #if 0 for ( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) { for ( ch = 0; ch < 2; ch++ ) { hMasaIsmData->ismPreprocMatrix[ch][ch][bin] = 1.0f; hMasaIsmData->ismPreprocMatrix[1 - ch][ch][bin] = 0.0f; hMasaIsmData->eneMoveIIR[ch][bin] = 0.0f; hMasaIsmData->enePreserveIIR[ch][bin] = 0.0f; } hMasaIsmData->preprocEneTarget[bin] = 0.0f; hMasaIsmData->preprocEneRealized[bin] = 0.0f; } hMasaIsmData->objectsMoved = 0; hMasaIsmData->delayBuffer = NULL; for ( ch = 0; ch < st_ivas->nchan_ism; ch++ ) { hMasaIsmData->q_elevation_old[ch] = 0.0f; hMasaIsmData->q_azimuth_old[ch] = 0.0f; } for ( obj_idx = 0; obj_idx < MAX_NUM_OBJECTS; obj_idx++ ) { set_s( hMasaIsmData->azimuth_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); set_s( hMasaIsmData->elevation_ism[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ ) { set_zero( hMasaIsmData->energy_ratio_ism[obj_idx][sf], CLDFB_NO_CHANNELS_MAX ); } } set_s( hMasaIsmData->azimuth_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); set_s( hMasaIsmData->elevation_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); #endif st_ivas->hMasaIsmData = hMasaIsmData; return IVAS_ERR_OK; } /*-------------------------------------------------------------------* * ivas_masa_ism_data_close() * * Deallocate MASA_ISM rendering handle *-------------------------------------------------------------------*/ void ivas_masa_ism_data_close( MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ ) { int16_t i; if ( hMasaIsmData == NULL || *hMasaIsmData == NULL ) { return; } if ( ( *hMasaIsmData )->delayBuffer != NULL ) { for ( i = 0; i < ( *hMasaIsmData )->delayBuffer_nchan; i++ ) { free( ( *hMasaIsmData )->delayBuffer[i] ); } free( ( *hMasaIsmData )->delayBuffer ); ( *hMasaIsmData )->delayBuffer = NULL; } free( *hMasaIsmData ); *hMasaIsmData = NULL; return; } /*-------------------------------------------------------------------------* * ivas_masa_ism_separate_object_renderer_open() * * Open structures, reserve memory, and init values. *-------------------------------------------------------------------------*/ ivas_error ivas_masa_ism_separate_object_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { int16_t interpolator_length; int16_t i; int16_t init_interpolator_length; st_ivas->hMasaIsmData->delayBuffer_nchan = st_ivas->nchan_ism; st_ivas->hMasaIsmData->delayBuffer_size = (int16_t) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES ); if ( ( st_ivas->hMasaIsmData->delayBuffer = (float **) malloc( st_ivas->hMasaIsmData->delayBuffer_nchan * sizeof( float * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); } for ( i = 0; i < st_ivas->hMasaIsmData->delayBuffer_nchan; i++ ) { if ( ( st_ivas->hMasaIsmData->delayBuffer[i] = (float *) malloc( st_ivas->hMasaIsmData->delayBuffer_size * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); } set_zero( st_ivas->hMasaIsmData->delayBuffer[i], st_ivas->hMasaIsmData->delayBuffer_size ); } return IVAS_ERR_OK; } /*--------------------------------------------------------------------------* * ivas_omasa_dirac_td_binaural() * * Binaural rendering in OMASA format *--------------------------------------------------------------------------*/ ivas_error ivas_omasa_dirac_td_binaural( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output[][L_FRAME48k], /* o : output synthesis signal */ const int16_t output_frame /* i : output frame length per channel */ ) { int16_t n; float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; float gain = 0.7943f; /* Todo Nokia: Temporary gain for roughly matching the loudness of other processing paths. */ ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; #ifdef SBA_AND_OBJECTS int16_t channel_offset; #endif for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) { p_sepobj[n] = &data_separated_objects[n][0]; } #ifdef SBA_AND_OBJECTS channel_offset = st_ivas->nchan_transport; if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->nchan_transport == 3 ) /* channels are remapped in ivas_sba_remapTCs() */ { channel_offset = 4; } channel_offset = 0; #endif for ( n = 0; n < st_ivas->nchan_ism; n++ ) { #ifdef SBA_AND_OBJECTS mvr2r( output[channel_offset + n], data_separated_objects[n], output_frame ); #else mvr2r( output[2 + n], data_separated_objects[n], output_frame ); #endif // v_multc( data_separated_objects[n], gain, data_separated_objects[n], output_frame ); } #if 1 { int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; for ( int t = 0; t < output_frame; t++ ) { for ( int c = 0; c < 4; c++ ) { int16_t val = (int16_t) ( data_separated_objects[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "sep_obj.raw" ); } } } #endif for ( n = 0; n < st_ivas->nchan_ism; n++ ) { delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } #if 1 { int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; for ( int t = 0; t < output_frame; t++ ) { for ( int c = 0; c < 4; c++ ) { int16_t val = (int16_t) ( data_separated_objects[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "sep_obj_delay.raw" ); } } } #endif #ifdef SBA_AND_OBJECTS if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { ivas_sba_upmixer_renderer( st_ivas, &output[MAX_NUM_OBJECTS], output_frame ); } else { ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[MAX_NUM_OBJECTS], st_ivas->nchan_transport ); } #else ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, output, st_ivas->nchan_transport ); #endif #if 1 { int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; for ( int t = 0; t < output_frame; t++ ) { for ( int c = 4; c < 4 + nchan; c++ ) { int16_t val = (int16_t) ( output[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "int_dec_bin_hoa.raw" ); } } } #endif if ( ( error = ivas_td_binaural_renderer( st_ivas, p_sepobj, output_frame ) ) != IVAS_ERR_OK ) { return error; } #if 1 { int16_t nchan = st_ivas->hOutSetup.nchan_out_woLFE; for ( int t = 0; t < output_frame; t++ ) { for ( int c = 0; c < nchan; c++ ) { int16_t val = (int16_t) ( p_sepobj[c][t] + 0.5f ); dbgwrite( &val, sizeof( int16_t ), 1, 1, "int_dec_bin_obj.raw" ); } } } #endif for ( n = 0; n < BINAURAL_CHANNELS; n++ ) { #if 0 v_add( output[MAX_NUM_OBJECTS + n], p_sepobj[n], output[n], output_frame ); #else int16_t i; for(i=0; i<output_frame; i++) { output[n][i]=0.5f*output[MAX_NUM_OBJECTS + n][i]+0.5f*p_sepobj[n][i] ; } #endif } return IVAS_ERR_OK; } ivas_error ivas_osba_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int32_t ism_total_brate, /* i : ISM total bitrate */ int16_t *nchan_ism, /* o : number of ISM separated channels */ int16_t *nchan_transport_ism, /* o : number of ISM TCs */ const int16_t dirac_bs_md_write_idx, /* i : DirAC bitstream write index */ int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ) { int16_t n, block; int16_t azimuth_ism, elevation_ism, meta_write_index; ivas_error error; /* set ISM parameters */ *nchan_ism = st_ivas->nchan_ism; *nchan_transport_ism = st_ivas->nchan_ism; /* decode ISM metadata */ if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) { return error; } #if 0 if ( st_ivas->hDirAC != NULL ) { if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { azimuth_ism = (int16_t) ( st_ivas->hIsmMetaData[n]->azimuth + 0.5f ); elevation_ism = (int16_t) ( st_ivas->hIsmMetaData[n]->elevation + 0.5f ); for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) { meta_write_index = ( dirac_bs_md_write_idx + block ) % st_ivas->hDirAC->dirac_md_buffer_length; st_ivas->hMasaIsmData->azimuth_ism[n][meta_write_index] = azimuth_ism; st_ivas->hMasaIsmData->elevation_ism[n][meta_write_index] = elevation_ism; } } } } #endif return IVAS_ERR_OK; } #endif
lib_enc/ivas_enc.c +8 −0 Original line number Diff line number Diff line Loading @@ -61,7 +61,11 @@ ivas_error ivas_enc( ENCODER_CONFIG_HANDLE hEncoderConfig; BSTR_ENC_HANDLE hMetaData; Encoder_State *st; /* used for bitstream handling */ #ifdef OSBA_DISC_OBJ_MCT int16_t nb_bits_metadata[MAX_SCE + 1]; #else int16_t nb_bits_metadata[MAX_SCE]; #endif #ifdef SBA_AND_OBJECTS float data_f[MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; #else Loading @@ -87,7 +91,11 @@ ivas_error ivas_enc( input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); n_samples_chan = n_samples / nchan_inp; #ifdef OSBA_DISC_OBJ_MCT set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); #else set_s( nb_bits_metadata, 0, MAX_SCE ); #endif /*----------------------------------------------------------------* * convert 'short' input data to 'float' Loading