diff --git a/apps/decoder.c b/apps/decoder.c index b98658eba0cd7086b76e8503d6e7080ce01fbb13..e210ebe95e7e431d4b3fa2684ee1594545e48831 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1580,7 +1580,11 @@ static ivas_error initOnFirstGoodFrame( /* Duplicate good first frame metadata to fill the beginning of stream. */ MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta = NULL; +#ifdef FIX_470_MASA_JBM_EXT + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); return error; @@ -1878,7 +1882,11 @@ static ivas_error decodeG192( else if ( bsFormat == IVAS_DEC_BS_MASA ) { MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta; +#ifdef FIX_470_MASA_JBM_EXT + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2426,7 +2434,11 @@ static ivas_error decodeVoIP( else if ( bsFormat == IVAS_DEC_BS_MASA ) { MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta; +#ifdef FIX_470_MASA_JBM_EXT + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 1 ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2838,7 +2850,11 @@ static ivas_error decodeVariableSpeed( else if ( bsFormat == IVAS_DEC_BS_MASA ) { MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta; +#ifdef FIX_470_MASA_JBM_EXT + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 1 ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -3008,7 +3024,11 @@ static ivas_error decodeVariableSpeed( else if ( bsFormat == IVAS_DEC_BS_MASA ) { MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta; +#ifdef FIX_470_MASA_JBM_EXT + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index a4b7e1c5d58448802cf612ff74a2aed008f04d64..b950fe51e7bc4685c29c04b9b350e2852bb52dc8 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -214,6 +214,9 @@ typedef enum #define MAX_JBM_L_FRAME_NS 40000000L #define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH #define MAX_CLDFB_DIGEST_CHANNELS 4 +#ifdef FIX_470_MASA_JBM_EXT +#define MASA_JBM_RINGBUFFER_FRAMES 3 +#endif typedef enum { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index e188a04430761bd872f88c9a1aad8f71f49821e3..7e95c097e440489ce0f2198ccba45d54ac2e52ce 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -821,10 +821,21 @@ void ivas_jbm_dec_get_md_map( int16_t *map /* o : metadata index map */ ); -int16_t ivas_jbm_dec_get_num_tc_channels( +int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); +#ifdef FIX_470_MASA_JBM_EXT +void ivas_jbm_dec_get_md_map_even_spacing( + const int16_t default_len, /* i : default frame length in metadata slots */ + const int16_t len, /* i : length of the modfied frames in metadata slots */ + const int16_t subframe_len, /* i : default length of a subframe */ + const int16_t offset, /* i : current read offset into the md buffer */ + const int16_t buf_len, /* i : length of the metadata buffer */ + int16_t *map /* o : metadata index map */ +); +#endif + TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); @@ -861,6 +872,16 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#ifdef FIX_470_MASA_JBM_EXT +ivas_error ivas_jbm_dec_metadata_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void ivas_jbm_masa_sf_to_sf_map( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); +#endif + /*----------------------------------------------------------------------------------* * ISM prototypes diff --git a/lib_com/options.h b/lib_com/options.h index e51736a79f1ce27b32fa6e781a6eba17427770b1..da7b1801785183f2409982d494ce69ec81cc169c 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,7 @@ #define FIX_522_ISM_FIRST_SID /* VA: fix ISM decoder crash if first received frame is an SID */ +#define FIX_470_MASA_JBM_EXT /* Nokia: Issue 470, fix MASA EXT output with JBM */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 521baa405fb62bf525cd5ea966438e2d71c7262b..622d314181956d3fa96a143d4d35e7490ae99f39 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -2158,7 +2158,15 @@ void ivas_dirac_dec_set_md_map( set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); +#ifdef FIX_470_MASA_JBM_EXT + if ( st_ivas->ivas_format == MASA_FORMAT ) + { + ivas_jbm_dec_get_md_map_even_spacing( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, 0, hDirAC->dirac_md_buffer_length, hDirAC->render_to_md_map ); + } + else if ( hDirAC->hConfig == NULL || hDirAC->hConfig->dec_param_estim == 0 ) +#else if ( hDirAC->hConfig == NULL || hDirAC->hConfig->dec_param_estim == 0 ) +#endif { ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, 0, hDirAC->dirac_md_buffer_length, hDirAC->render_to_md_map ); } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 00b8d49d0c1403978025df68ab9543e944679fc3..45bbac0faba3b13b3587bd1f0ed540349bb0840b 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1462,6 +1462,19 @@ ivas_error ivas_init_decoder( } } +#ifdef FIX_470_MASA_JBM_EXT + if ( st_ivas->hJbmMetadata == NULL ) + { + if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) + { + if ( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#endif + return error; } @@ -1686,6 +1699,9 @@ void ivas_initialize_handles_dec( st_ivas->hCombinedOrientationData = NULL; st_ivas->hTcBuffer = NULL; +#ifdef FIX_470_MASA_JBM_EXT + st_ivas->hJbmMetadata = NULL; +#endif return; } @@ -1886,6 +1902,14 @@ void ivas_destroy_dec( ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer ); +#ifdef FIX_470_MASA_JBM_EXT + if ( st_ivas->hJbmMetadata != NULL ) + { + free( st_ivas->hJbmMetadata ); + st_ivas->hJbmMetadata = NULL; + } +#endif + /* main IVAS handle */ free( st_ivas ); diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6871747db6cd16f61b4988dcef7e1ac89a599c2f..5222104ee87187584262d0a71799c292985a47a4 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -54,6 +54,12 @@ static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSample static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); +#ifdef FIX_470_MASA_JBM_EXT +static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas ); + +static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t nCldfbTs ); +#endif + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc() @@ -196,6 +202,12 @@ ivas_error ivas_jbm_dec_tc( { return error; } +#ifdef FIX_470_MASA_JBM_EXT + if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) + { + ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); + } +#endif } } else if ( st_ivas->ivas_format == SBA_FORMAT ) @@ -537,6 +549,12 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); +#ifdef FIX_470_MASA_JBM_EXT + if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) + { + ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); + } +#endif } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { @@ -1229,6 +1247,72 @@ void ivas_jbm_dec_get_md_map( } +#ifdef FIX_470_MASA_JBM_EXT +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_get_md_map_even_spacing() + * + * Get an meta data map adapted to a time scale modified IVAS frame. Distribute slots evenly across the modified frame. + *--------------------------------------------------------------------------*/ +void ivas_jbm_dec_get_md_map_even_spacing( + const int16_t default_len, /* i : default frame length in metadata slots */ + const int16_t len, /* i : length of the modfied frames in metadata slots */ + const int16_t subframe_len, /* i : default length of a subframe */ + const int16_t offset, /* i : current read offset into the md buffer */ + const int16_t buf_len, /* i : length of the metadata buffer */ + int16_t *map /* o : metadata index map */ +) +{ + int16_t map_idx, sf_idx, sf_length, increment, subframes_written; + float decimal, decimal_sum, eps; + int16_t subframe_map_length[MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef DEBUGGING + assert( default_len % 2 == 0 ); +#endif + + /* subframe map length */ + sf_length = len / subframe_len; + if ( len % subframe_len == 0 ) + { + /* even subframes */ + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + subframe_map_length[sf_idx] = sf_length; + } + } + else + { + /* uneven subframes */ + decimal = ( (float) len / (float) subframe_len ) - (float) sf_length; + decimal_sum = decimal; + eps = 0.001f; + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + increment = (int16_t) floorf( decimal_sum + eps ); + subframe_map_length[sf_idx] = sf_length + increment; + if ( increment > 0 ) + { + decimal_sum -= 1.0f; + } + decimal_sum += decimal; + } + } + + /* map slots to subframes */ + sf_idx = 0; + subframes_written = 0; + for ( map_idx = 0; map_idx < len; map_idx++ ) + { + map[map_idx] = ( offset + sf_idx ) % buf_len; + if ( map_idx - subframes_written >= subframe_map_length[sf_idx] - 1 ) + { + subframes_written += subframe_map_length[sf_idx]; + ++sf_idx; + } + } +} +#endif + + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_num_tc_channels() * @@ -1817,3 +1901,175 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( return buffer_mode; } + + +#ifdef FIX_470_MASA_JBM_EXT +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_metadata_open() + * + * Open structure for metadata buffering in JBM + *--------------------------------------------------------------------------*/ +ivas_error ivas_jbm_dec_metadata_open( + Decoder_Struct *st_ivas ) +{ + JBM_METADATA_HANDLE hJbmMetadata; + if ( ( hJbmMetadata = (JBM_METADATA_HANDLE) malloc( sizeof( JBM_METADATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM metadata handle\n" ) ); + } + hJbmMetadata->sf_write_idx = 0; + hJbmMetadata->sf_md_buffer_length = MASA_JBM_RINGBUFFER_FRAMES * MAX_PARAM_SPATIAL_SUBFRAMES; + + hJbmMetadata->slot_write_idx = 0; + hJbmMetadata->slot_read_idx = 0; + hJbmMetadata->slot_md_buffer_length = MASA_JBM_RINGBUFFER_FRAMES * MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; + + st_ivas->hJbmMetadata = hJbmMetadata; + + return IVAS_ERR_OK; +} + + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_copy_masa_meta_to_buffer() + * + * Copy decoded MASA metadata to a ring buffer + *--------------------------------------------------------------------------*/ +static void ivas_jbm_dec_copy_masa_meta_to_buffer( + Decoder_Struct *st_ivas ) +{ + int16_t sf, dir, band; + JBM_METADATA_HANDLE hJbmMetadata; + MASA_DECODER_EXT_OUT_META *extOutMeta; + int16_t write_idx; + + hJbmMetadata = st_ivas->hJbmMetadata; + extOutMeta = st_ivas->hMasa->data.extOutMeta; + + for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + write_idx = ( hJbmMetadata->sf_write_idx + sf ) % hJbmMetadata->sf_md_buffer_length; + + for ( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ ) + { + for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + { + hJbmMetadata->directionIndexBuffer[dir][write_idx][band] = extOutMeta->directionIndex[dir][sf][band]; + hJbmMetadata->directToTotalRatioBuffer[dir][write_idx][band] = extOutMeta->directToTotalRatio[dir][sf][band]; + hJbmMetadata->spreadCoherenceBuffer[dir][write_idx][band] = extOutMeta->spreadCoherence[dir][sf][band]; + } + } + + for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + { + hJbmMetadata->diffuseToTotalRatioBuffer[write_idx][band] = extOutMeta->diffuseToTotalRatio[sf][band]; + hJbmMetadata->surroundCoherenceBuffer[write_idx][band] = extOutMeta->surroundCoherence[sf][band]; + } + + hJbmMetadata->numberOfDirections[write_idx] = extOutMeta->descriptiveMeta.numberOfDirections; + } +} + + +/*--------------------------------------------------------------------------* + * ivas_jbm_masa_sf_to_slot_map() + * + * Map input MASA metadata subframes to slots in JBM processing + *--------------------------------------------------------------------------*/ +static void ivas_jbm_masa_sf_to_slot_map( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +) +{ + int16_t sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME]; + int16_t num_slots_in_subfr; + JBM_METADATA_HANDLE hJbmMetadata; + int16_t slot_idx; + int16_t write_idx, sf_index; + + /* Set values */ + hJbmMetadata = st_ivas->hJbmMetadata; + num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; + + /* Map input subframes to slots */ + ivas_jbm_dec_get_md_map_even_spacing( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, 0, MAX_PARAM_SPATIAL_SUBFRAMES, sf_to_slot_map ); + + for ( slot_idx = 0; slot_idx < nCldfbTs; slot_idx++ ) + { + write_idx = ( hJbmMetadata->slot_write_idx + slot_idx ) % hJbmMetadata->slot_md_buffer_length; + sf_index = ( hJbmMetadata->sf_write_idx + sf_to_slot_map[slot_idx] ) % hJbmMetadata->sf_md_buffer_length; + + hJbmMetadata->sf_to_slot_map[write_idx] = sf_index; + } + + hJbmMetadata->sf_write_idx = ( hJbmMetadata->sf_write_idx + MAX_PARAM_SPATIAL_SUBFRAMES ) % hJbmMetadata->sf_md_buffer_length; + hJbmMetadata->slot_write_idx = ( hJbmMetadata->slot_write_idx + nCldfbTs ) % hJbmMetadata->slot_md_buffer_length; +} + + +/*--------------------------------------------------------------------------* + * ivas_jbm_masa_sf_to_sf_map() + * + * Map input MASA metadata subframes to output subframes in JBM processing + *--------------------------------------------------------------------------*/ +void ivas_jbm_masa_sf_to_sf_map( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + int16_t sf_to_sf_map[MAX_PARAM_SPATIAL_SUBFRAMES]; + JBM_METADATA_HANDLE hJbmMetadata; + MASA_DECODER_EXT_OUT_META *extOutMeta; + int16_t slot_read_idx, sf_read_idx; + int16_t sf_idx; + int16_t dir, band; + uint8_t numberOfDirections; + + /* Set values */ + hJbmMetadata = st_ivas->hJbmMetadata; + extOutMeta = st_ivas->hMasa->data.extOutMeta; + + /* Map slots to subframes */ + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + slot_read_idx = ( hJbmMetadata->slot_read_idx + 2 ) % hJbmMetadata->slot_md_buffer_length; /* Take the latter one of the middle slots of the output subframe */ + sf_to_sf_map[sf_idx] = hJbmMetadata->sf_to_slot_map[slot_read_idx]; + hJbmMetadata->slot_read_idx = ( hJbmMetadata->slot_read_idx + CLDFB_SLOTS_PER_SUBFRAME ) % hJbmMetadata->slot_md_buffer_length; + } + + /* Copy mapped metadata to the EXT meta buffer for writing */ + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + sf_read_idx = sf_to_sf_map[sf_idx]; + + for ( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ ) + { + for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + { + extOutMeta->directionIndex[dir][sf_idx][band] = hJbmMetadata->directionIndexBuffer[dir][sf_read_idx][band]; + extOutMeta->directToTotalRatio[dir][sf_idx][band] = hJbmMetadata->directToTotalRatioBuffer[dir][sf_read_idx][band]; + extOutMeta->spreadCoherence[dir][sf_idx][band] = hJbmMetadata->spreadCoherenceBuffer[dir][sf_read_idx][band]; + } + } + + for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + { + extOutMeta->diffuseToTotalRatio[sf_idx][band] = hJbmMetadata->diffuseToTotalRatioBuffer[sf_read_idx][band]; + extOutMeta->surroundCoherence[sf_idx][band] = hJbmMetadata->surroundCoherenceBuffer[sf_read_idx][band]; + } + } + + /* Determine the number of directions for the frame to be written */ + numberOfDirections = 0; + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) + { + sf_read_idx = sf_to_sf_map[sf_idx]; + + if ( hJbmMetadata->numberOfDirections[sf_read_idx] == 1 ) + { + numberOfDirections = 1; + break; + } + } + extOutMeta->descriptiveMeta.numberOfDirections = numberOfDirections; +} +#endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 27375db6fa6cd67165b9f3198b6fb6b6a150c649..ad767f0e308c3d94707125b0792dc7f675fce887 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1221,6 +1221,27 @@ typedef struct decoder_tc_buffer_structure } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; +#ifdef FIX_470_MASA_JBM_EXT +typedef struct jbm_metadata_structure +{ + int16_t sf_write_idx; + int16_t sf_md_buffer_length; + + uint16_t directionIndexBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + uint8_t directToTotalRatioBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + uint8_t spreadCoherenceBuffer[MASA_MAXIMUM_DIRECTIONS][MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + uint8_t surroundCoherenceBuffer[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + uint8_t diffuseToTotalRatioBuffer[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES][MASA_FREQUENCY_BANDS]; + uint8_t numberOfDirections[MAX_PARAM_SPATIAL_SUBFRAMES * MASA_JBM_RINGBUFFER_FRAMES]; /* Descriptive metadata, value is 0 or 1 */ + + int16_t slot_read_idx; + int16_t slot_write_idx; + int16_t slot_md_buffer_length; + + int16_t sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME * MASA_JBM_RINGBUFFER_FRAMES]; +} JBM_METADATA, *JBM_METADATA_HANDLE; +#endif + /*----------------------------------------------------------------------------------* * @@ -1312,6 +1333,9 @@ typedef struct Decoder_Struct /* JBM module */ DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM structure */ +#ifdef FIX_470_MASA_JBM_EXT + JBM_METADATA_HANDLE hJbmMetadata; /* Structure for metadata buffering in JBM */ +#endif #ifdef DEBUGGING int32_t noClipping; /* number of clipped samples */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index e46fe70028fa5025388605e5bdf6a005d7d1f03e..f06a107065f2036c805a327f01183f65f9899a86 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1105,8 +1105,14 @@ ivas_error IVAS_DEC_GetObjectMetadata( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetMasaMetadata( +#ifdef FIX_470_MASA_JBM_EXT + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ + uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ +#else IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ +#endif ) { if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -1119,6 +1125,13 @@ ivas_error IVAS_DEC_GetMasaMetadata( return IVAS_ERR_WRONG_MODE; } +#ifdef FIX_470_MASA_JBM_EXT + if ( getFromJbmBuffer ) + { + ivas_jbm_masa_sf_to_sf_map( hIvasDec->st_ivas ); + } +#endif + *hMasaExtOutMeta = hIvasDec->st_ivas->hMasa->data.extOutMeta; return IVAS_ERR_OK; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index f28b4c1672182442848d7f6817a0e3195f802c20..ebcdd099c80da0eefb9519e848d5cd71399655ee 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -184,8 +184,14 @@ ivas_error IVAS_DEC_GetObjectMetadata( /*! r: error code */ ivas_error IVAS_DEC_GetMasaMetadata( +#ifdef FIX_470_MASA_JBM_EXT + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ + uint8_t getFromJbmBuffer /* i : get metadata from a JBM buffer */ +#else IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ +#endif ); /*! r: error code */