Commit 2761d08d authored by vaclav's avatar vaclav
Browse files

FIX_532_ISM_MD_INACTIVE, step 1

parent b3ff8488
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -329,7 +329,11 @@ typedef enum

#define ISM_NB_BITS_METADATA_NOMINAL            ( ( SCE_CORE_16k_LOW_LIMIT - ACELP_16k_LOW_LIMIT ) / FRAMES_PER_SEC ) /* nominal number of metadata bits - used for configuration of Core-Coder modules */

#ifdef FIX_532_ISM_MD_INACTIVE
#define ISM_METADATA_INACTIVE_FLAG_BITS         1 /* flag to signal whether MD are sent in low-rate inactive frame */
#else
#define ISM_METADATA_VAD_FLAG_BITS              1
#endif
#define ISM_METADATA_FLAG_BITS                  2

#define ISM_NO_META                             0
@@ -383,6 +387,9 @@ typedef enum
#define ISM_Q_STEP_LOW                          (ISM_Q_STEP * 2)
#define ISM_Q_STEP_BORDER_LOW                   (ISM_Q_STEP_BORDER * 2)

#ifdef FIX_532_ISM_MD_INACTIVE
#define BRATE_ISM_INACTIVE                      2450 /* CoreCoder bitrate in ISM inactive frames */
#endif

typedef enum 
{
@@ -399,8 +406,13 @@ enum
    IND_ISM_EXTENDED_FLAG = IND_ISM_NUM_OBJECTS + MAX_NUM_OBJECTS,
    IND_ISM_EXTENDED_NDP_FLAG, 
    IND_ISM_METADATA_FLAG,
#ifdef FIX_532_ISM_MD_INACTIVE
    IND_ISM_MD_INACTIVE_FLAG = IND_ISM_METADATA_FLAG + MAX_NUM_OBJECTS,
    IND_ISM_NOISY_SPEECH_FLAG = IND_ISM_MD_INACTIVE_FLAG + MAX_NUM_OBJECTS,
#else
    IND_ISM_VAD_FLAG = IND_ISM_METADATA_FLAG + MAX_NUM_OBJECTS,
    IND_ISM_NOISY_SPEECH_FLAG = IND_ISM_VAD_FLAG + MAX_NUM_OBJECTS,
#endif
    IND_ISM_SCE_ID_DTX,
    IND_ISM_DTX_COH_SCA,

+62 −5
Original line number Diff line number Diff line
@@ -49,10 +49,14 @@
 * Local constants
 *-----------------------------------------------------------------------*/

#ifdef FIX_532_ISM_MD_INACTIVE
#define BITS_ISM_INACTIVE ( BRATE_ISM_INACTIVE / FRAMES_PER_SEC )
#else
#define FRMS_PER_SECOND ( 1000000000 / FRAME_SIZE_NS )

#define BRATE_ISM_INACTIVE 2450 /* CoreCoder bitrate in ISM inactive frames */
#define BITS_ISM_INACTIVE  ( BRATE_ISM_INACTIVE / FRMS_PER_SECOND )
#endif

#define BETA_ISM_LOW_IMP    0.6f
#define BETA_ISM_MEDIUM_IMP 0.8f
@@ -74,7 +78,11 @@ static void bitbudget_to_brate(

    for ( i = 0; i < N; i++ )
    {
#ifdef FIX_532_ISM_MD_INACTIVE
        y[i] = FRAMES_PER_SEC * x[i];
#else
        y[i] = FRMS_PER_SECOND * x[i];
#endif
    }

    return;
@@ -93,7 +101,9 @@ ivas_error ivas_ism_config(
    const int16_t nchan_ism,                  /* i  : number of objects              */
    ISM_METADATA_HANDLE hIsmMeta[],           /* i/o: ISM metadata handles           */
    const int16_t ism_extended_metadata_flag, /* i  : extended metadata flag         */
#ifndef FIX_532_ISM_MD_INACTIVE
    const int16_t localVAD[MAX_NUM_OBJECTS], /* i  : local VAD flag                 */
#endif
    const int16_t ism_imp[],   /* i  : ISM importance flags           */
    int32_t element_brate[],   /* o  : element bitrate per object     */
    int32_t total_brate[],     /* o  : total bitrate per object       */
@@ -120,12 +130,20 @@ ivas_error ivas_ism_config(
    {
        for ( ch = 0; ch < n_ISms; ch++ )
        {
#ifdef FIX_532_ISM_MD_INACTIVE
            ism_metadata_flag_global |= ism_imp[ch];
#else
            ism_metadata_flag_global |= hIsmMeta[ch]->ism_metadata_flag;
#endif
        }
    }

    /* decision about bitrates per channel - constant during the session (at one ivas_total_brate) */
#ifdef FIX_532_ISM_MD_INACTIVE
    bits_ism = (int16_t) ( ism_total_brate / FRAMES_PER_SEC );
#else
    bits_ism = (int16_t) ( ism_total_brate / FRMS_PER_SECOND );
#endif
    set_s( bits_element, bits_ism / n_ISms, n_ISms );
    bits_element[n_ISms - 1] += bits_ism % n_ISms;
    bitbudget_to_brate( bits_element, element_brate, n_ISms );
@@ -146,10 +164,17 @@ ivas_error ivas_ism_config(

        for ( ch = 0; ch < n_ISms; ch++ )
        {
#ifdef FIX_532_ISM_MD_INACTIVE
            if ( ism_imp[ch] == ISM_NO_META )
            {
                nb_bits_metadata[0] += ISM_METADATA_INACTIVE_FLAG_BITS;
            }
#else
            if ( hIsmMeta[ch]->ism_metadata_flag == 0 )
            {
                nb_bits_metadata[0] += ISM_METADATA_VAD_FLAG_BITS;
            }
#endif
        }
    }

@@ -175,7 +200,11 @@ ivas_error ivas_ism_config(
        diff = 0;
        for ( ch = 0; ch < n_ISms; ch++ )
        {
#ifdef FIX_532_ISM_MD_INACTIVE
            if ( ism_imp[ch] == ISM_NO_META )
#else
            if ( hIsmMeta[ch]->ism_metadata_flag == 0 && localVAD[ch] == 0 )
#endif
            {
                diff += bits_CoreCoder[ch] - BITS_ISM_INACTIVE;
                bits_CoreCoder[ch] = BITS_ISM_INACTIVE;
@@ -212,18 +241,34 @@ ivas_error ivas_ism_config(
        {
            int16_t limit;

#ifdef FIX_532_ISM_MD_INACTIVE
            limit = MIN_BRATE_SWB_BWE / FRAMES_PER_SEC;
#else
            limit = MIN_BRATE_SWB_BWE / FRMS_PER_SECOND;
#endif
            if ( element_brate[ch] < MIN_BRATE_SWB_STEREO ) /* replicate function set_bw() -> check the coded audio band-width */
            {
#ifdef FIX_532_ISM_MD_INACTIVE
                limit = MIN_BRATE_WB_BWE / FRAMES_PER_SEC;
#else
                limit = MIN_BRATE_WB_BWE / FRMS_PER_SECOND;
#endif
            }
            else if ( element_brate[ch] >= SCE_CORE_16k_LOW_LIMIT ) /* replicate function set_ACELP_flag() -> it is not intended to switch the ACELP internal sampling rate within an object */
            {
                /*limit = SCE_CORE_16k_LOW_LIMIT;*/
#ifdef FIX_532_ISM_MD_INACTIVE
                limit = ( ACELP_16k_LOW_LIMIT + SWB_TBE_1k6 ) / FRAMES_PER_SEC;
#else
                limit = ( ACELP_16k_LOW_LIMIT + SWB_TBE_1k6 ) / FRMS_PER_SECOND;
#endif
            }

#ifdef FIX_532_ISM_MD_INACTIVE
            if ( ism_imp[ch] == ISM_NO_META )
#else
            if ( ism_imp[ch] == ISM_NO_META && localVAD[ch] == 0 )
#endif
            {
                tmp = BITS_ISM_INACTIVE;
            }
@@ -270,10 +315,18 @@ ivas_error ivas_ism_config(
        diff = 0;
        for ( ch = 0; ch < n_ISms; ch++ )
        {
#ifdef FIX_532_ISM_MD_INACTIVE
            limit_high = IVAS_512k / FRAMES_PER_SEC;
#else
            limit_high = IVAS_512k / FRMS_PER_SECOND;
#endif
            if ( element_brate[ch] < SCE_CORE_16k_LOW_LIMIT ) /* replicate function set_ACELP_flag() -> it is not intended to switch the ACELP internal sampling rate within an object */
            {
#ifdef FIX_532_ISM_MD_INACTIVE
                limit_high = ACELP_12k8_HIGH_LIMIT / FRAMES_PER_SEC;
#else
                limit_high = ACELP_12k8_HIGH_LIMIT / FRMS_PER_SECOND;
#endif
            }

            tmp = (int16_t) min( bits_CoreCoder[ch], limit_high );
@@ -316,7 +369,11 @@ ivas_error ivas_ism_config(
    if ( nb_bits_metadata != NULL )
    {
        int32_t tmpL;
#ifdef FIX_532_ISM_MD_INACTIVE
        tmpL = sum_l( total_brate, n_ISms ) + bits_side * FRAMES_PER_SEC;
#else
        tmpL = sum_l( total_brate, n_ISms ) + bits_side * FRMS_PER_SECOND;
#endif
        if ( sum_l( element_brate, n_ISms ) != tmpL )
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "\nError: Mismatch in ISM bit-budget distribution. Exiting!\n" );
+2 −0
Original line number Diff line number Diff line
@@ -885,7 +885,9 @@ ivas_error ivas_ism_config(
    const int16_t nchan_ism,                                    /* i  : number of objects                           */
    ISM_METADATA_HANDLE hIsmMeta[],                             /* i/o: ISM metadata handles                        */
    const int16_t ism_extended_metadata_flag,                   /* i  : extended metadata flag                      */
#ifndef FIX_532_ISM_MD_INACTIVE
    const int16_t localVAD[MAX_NUM_OBJECTS],                    /* i  : local VAD flag                              */
#endif
    const int16_t ism_imp[],                                    /* i  : ISM importance flags                        */
    int32_t element_brate[],                                    /* o  : element bitrate per object                  */
    int32_t total_brate[],                                      /* o  : total bitrate per object                    */
+3 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@

#ifdef DEBUGGING

/*#define DEBUG_MODE_INFO*/                     /* output most important parameters to the subdirectory "res/" */
#define DEBUG_MODE_INFO                     /* output most important parameters to the subdirectory "res/" */
#ifdef DEBUG_MODE_INFO
/*#define DEBUG_MODE_ACELP*/                    /* output most important ACELP core parameters to the subdirectory "res/" */
/*#define DEBUG_MODE_TCX*/                      /* output most important TCX core parameters to the subdirectory "res/" */
@@ -242,6 +242,8 @@
#define BINAURAL_AUDIO_CMDLINE
#define FIX_570_TCX_LPC_WRITE                           /* FhG: fix issue 570: LPC bitstream writer in TCX */

#define FIX_532_ISM_MD_INACTIVE                         /* VA: issue 532: impprove MD coding in ISM inactive frames */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */

+4 −0
Original line number Diff line number Diff line
@@ -84,7 +84,11 @@ static ivas_error ivas_ism_bitrate_switching(
    ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
    st_ivas->ism_mode = ism_mode;

#ifdef FIX_532_ISM_MD_INACTIVE
    if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, element_brate_tmp, NULL, NULL ) ) != IVAS_ERR_OK )
#else
    if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL ) ) != IVAS_ERR_OK )
#endif
    {
        return error;
    }
Loading