Commit c9b5b081 authored by vaclav's avatar vaclav
Browse files

- accept UNIFY_MD_QUANTIZER

- remove MD_Q_PARAM_BE, MD_SMOOTH_PARAM_BE, and DTX_PARAM_BE
parent 874a29c8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -340,7 +340,7 @@ typedef enum
#else
#define PARAM_ISM_DTX_COH_SCA_BITS              4
#endif
#if (defined DISCRETE_ISM_DTX_CNG && defined UNIFY_MD_QUANTIZER )
#ifdef DISCRETE_ISM_DTX_CNG
#define ISM_DTX_AZI_BITS_HIGH                   8
#define ISM_DTX_ELE_BITS_HIGH                   7
#define ISM_Q_STEP_HIGH                         (ISM_Q_STEP / 2)
+7 −83
Original line number Diff line number Diff line
@@ -359,17 +359,14 @@ int16_t ism_quant_meta(
    const float val,           /* i  : scalar value to quantize        */
    float *valQ,               /* o  : quantized value                 */
    const float borders[],     /* i  : level borders                   */
#ifdef UNIFY_MD_QUANTIZER
    const float q_step,        /* i  : quantization step               */
    const float q_step_border, /* i  : quantization step at the border */
#endif
    const int16_t cbsize       /* i  : codebook size                   */
)
{
    int16_t idx, idx_start;
    float qlow, step;

#ifdef UNIFY_MD_QUANTIZER
    if ( val <= borders[1] )
    {
        qlow = borders[0];
@@ -388,26 +385,6 @@ int16_t ism_quant_meta(
        idx_start = (int16_t) ( cbsize - 1 - ( borders[3] - borders[2] ) / q_step_border );
        step = q_step_border;
    }
#else
    if ( val <= borders[1] )
    {
        qlow = borders[0];
        idx_start = 0;
        step = ISM_Q_STEP_BORDER;
    }
    else if ( val <= borders[2] )
    {
        qlow = borders[1];
        idx_start = (int16_t) ( ( borders[1] - borders[0] ) / ISM_Q_STEP_BORDER );
        step = ISM_Q_STEP;
    }
    else
    {
        qlow = borders[2];
        idx_start = (int16_t) ( cbsize - 1 - ( borders[3] - borders[2] ) / ISM_Q_STEP_BORDER );
        step = ISM_Q_STEP_BORDER;
    }
#endif

    idx = idx_start + (int16_t) max( 0.f, min( cbsize - 1, ( ( val - qlow ) / step + 0.5f ) ) );
    *valQ = ( idx - idx_start ) * step + qlow;
@@ -426,17 +403,14 @@ int16_t ism_quant_meta(
float ism_dequant_meta(
    const int16_t idx,         /* i  : quantizer index              */
    const float borders[],     /* i  : level borders                */
#ifdef UNIFY_MD_QUANTIZER
    const float q_step,        /* i  : quantization step               */
    const float q_step_border, /* i  : quantization step at the border */
#endif
    const int16_t cbsize       /* i  : codebook size                */
)
{
    int16_t idx_start;
    float qlow, step, valQ;

#ifdef UNIFY_MD_QUANTIZER
    if ( idx <= ( borders[1] - borders[0] ) / q_step_border )
    {
        qlow = borders[0];
@@ -455,26 +429,6 @@ float ism_dequant_meta(
        idx_start = (int16_t) ( cbsize - 1 - ( borders[3] - borders[2] ) / q_step_border );
        step = q_step_border;
    }
#else
    if ( idx <= ( borders[1] - borders[0] ) / ISM_Q_STEP_BORDER )
    {
        qlow = borders[0];
        idx_start = 0;
        step = ISM_Q_STEP_BORDER;
    }
    else if ( idx <= cbsize - 1 - ( borders[3] - borders[2] ) / ISM_Q_STEP_BORDER )
    {
        qlow = borders[1];
        idx_start = (int16_t) ( ( borders[1] - borders[0] ) / ISM_Q_STEP_BORDER );
        step = ISM_Q_STEP;
    }
    else
    {
        qlow = borders[2];
        idx_start = (int16_t) ( cbsize - 1 - ( borders[3] - borders[2] ) / ISM_Q_STEP_BORDER );
        step = ISM_Q_STEP_BORDER;
    }
#endif

    valQ = ( idx - idx_start ) * step + qlow;

@@ -575,7 +529,6 @@ void update_last_metadata(
 * Set quantization bits based on the number of coded objects
 *----------------------------------------------------------------*/

#ifdef UNIFY_MD_QUANTIZER
void ivas_get_ism_sid_quan_bitbudget(
    const int16_t num_obj,    /* i  : number of objects                 */
    int16_t *nBits_azimuth,   /* o  : number of Q bits for azimuth      */
@@ -604,33 +557,4 @@ void ivas_get_ism_sid_quan_bitbudget(

    return;
}
#else
/*! r: low resolution flag */
int16_t ivas_get_ism_sid_quan_bitbudget(
    const int16_t num_obj,    /* i  : number of objects                 */
    int16_t *nBits_azimuth,   /* o  : number of Q bits for azimuth      */
    int16_t *nBits_elevation, /* o  : number of Q bits for elevation    */
    int16_t *nBits_coh,       /* o  : number of Q bits for coherence    */
    int16_t *nBits_sce_id     /* o  : number of Q bits for sce_id_dtx   */
)
{
    int16_t low_res_q;

    low_res_q = 0;
    *nBits_azimuth = ISM_AZIMUTH_NBITS;
    *nBits_elevation = ISM_ELEVATION_NBITS;
    *nBits_coh = ISM_DTX_COH_SCA_BITS;
    *nBits_sce_id = 1;

    if ( num_obj >= 3 )
    {
        low_res_q = 1;
        *nBits_azimuth = PARAM_ISM_DTX_AZI_BITS;
        *nBits_elevation = PARAM_ISM_DTX_ELE_BITS;
        *nBits_sce_id = 2;
    }

    return low_res_q;
}
#endif
#endif
+1 −21
Original line number Diff line number Diff line
@@ -777,10 +777,8 @@ int16_t ism_quant_meta(
    const float val,                                            /* i  : scalar value to quantize                    */
    float *valQ,                                                /* o  : quantized value                             */
    const float borders[],                                      /* i  : level borders                               */
#ifdef UNIFY_MD_QUANTIZER
    const float q_step,                                         /* i  : quantization step                           */
    const float q_step_border,                                  /* i  : quantization step at the border             */
#endif
    const int16_t cbsize                                        /* i  : codebook size                               */
);

@@ -788,10 +786,8 @@ int16_t ism_quant_meta(
float ism_dequant_meta(
    const int16_t idx,                                          /* i  : quantizer index                             */
    const float borders[],                                      /* i  : level borders                               */
#ifdef UNIFY_MD_QUANTIZER
    const float q_step,                                         /* i  : quantization step                           */
    const float q_step_border,                                  /* i  : quantization step at the border             */
#endif
    const int16_t cbsize                                        /* i  : codebook size                               */
);

@@ -924,11 +920,7 @@ ivas_error ivas_ism_dtx_open(

#ifdef DISCRETE_ISM_DTX_CNG
/*! r: indication of DTX frame */
#ifdef DTX_PARAM_BE
int16_t ivas_ism_dtx_enc_COMMON(
#else
int16_t ivas_ism_dtx_enc(
#endif
    ISM_DTX_HANDLE hISMDTX,                                     /* i/o: ISM DTX handle                              */
    SCE_ENC_HANDLE hSCE[MAX_SCE],                               /* i/o: SCE encoder structure                       */
    const int16_t num_obj,                                      /* i  : number of objects                           */
@@ -938,8 +930,7 @@ int16_t ivas_ism_dtx_enc(
    int16_t md_diff_flag[],                                     /* o  : metadata differential flag                  */
    int16_t *sid_flag                                           /* o  : indication of SID frame                     */
);
#endif
#if ( !defined DISCRETE_ISM_DTX_CNG || defined DTX_PARAM_BE )
#else
/*! r: indication of DTX frame */
int16_t ivas_ism_dtx_enc(
    Encoder_Struct *st_ivas,                                    /* i/o: IVAS encoder structure                      */
@@ -1018,7 +1009,6 @@ void update_last_metadata(
    const int16_t updt_flag[]                                   /* i  : last metadata update flag                   */
);

#ifdef UNIFY_MD_QUANTIZER
/*! r: low resolution flag */
void ivas_get_ism_sid_quan_bitbudget(
    const int16_t num_obj,                                      /* i  : number of objects                           */
@@ -1029,16 +1019,6 @@ void ivas_get_ism_sid_quan_bitbudget(
    int16_t *nBits_coh,                                         /* o  : number of Q bits for coherence              */
    int16_t *nBits_sce_id                                       /* o  : number of Q bits for sce_id_dtx             */
);
#else
/*! r: low resolution flag */
int16_t ivas_get_ism_sid_quan_bitbudget(
    const int16_t num_obj,                                      /* i  : number of objects                           */
    int16_t *nBits_azimuth,                                     /* o  : number of Q bits for azimuth                */
    int16_t *nBits_elevation,                                   /* o  : number of Q bits for elevation              */
    int16_t *nBits_coh,                                         /* o  : number of Q bits for coherence              */
    int16_t *nBits_sce_id                                       /* o  : number of Q bits for sce_id_dtx             */
);
#endif
#endif
#endif

+3 −7
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/" */
@@ -67,7 +67,7 @@
/*#define DEBUG_MODE_DIRAC*/                    /* output most important DIRAC parameters to the subdirectory "res/" */
/*#define DEBUG_MODE_MDCT*/                     /* output most important MDCT parameters to the subdirectory "res/" */
/*#define DEBUG_MODE_PARAM_MC */                /* output Parametric MC paramters to the subdirectory "res/" */
#define DEBUG_MODE_PARAM_ISM                /* output Parametric ISM paramters to the subdirectory "res/" */
/*#define DEBUG_MODE_PARAM_ISM*/                /* output Parametric ISM paramters to the subdirectory "res/" */
/*#define DEBUG_MODE_INFO_TWEAK*/               /* enable command line switch to specify subdirectory for debug info output inside "./res/" */
/*#define DEBUG_MODE_INFO_PLC */                /* define to output PLC related parameters */
/*#define DEBUG_MODE_INFO_ALLRAD*/              /* define to output generated HOA decoding mtx */
@@ -160,15 +160,11 @@
#define SMOOTH_WITH_TRANS_DET
#endif

#define TUNE_360_OBJECT_WITH_NOISE                      /* VA: issue 360: consider objects being speech+noise for active speech coding */

#define DISCRETE_ISM_DTX_CNG                            /* FhG/VA: contribution 15 - DTX/CNG for (discrete) ISM */
/*#define MD_Q_PARAM_BE*/
/*#define MD_SMOOTH_PARAM_BE*/
/*#define DTX_PARAM_BE*/
#define UNIFY_MD_QUANTIZER
#define DISC_CNG

#define TUNE_360_OBJECT_WITH_NOISE      // VA: issue 360: consider objects being speech+noise for active speech coding */


/* ################## End DEVELOPMENT switches ######################### */
+17 −167
Original line number Diff line number Diff line
@@ -378,11 +378,7 @@ ivas_error ivas_ism_metadata_dec(
                    }
                    else /* ISM_MODE_DISC */
                    {
#ifdef UNIFY_MD_QUANTIZER
                        hIsmMetaData->azimuth = ism_dequant_meta( idx_azimuth, ism_azimuth_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_AZIMUTH_NBITS );
#else
                        hIsmMetaData->azimuth = ism_dequant_meta( idx_azimuth, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS );
#endif
                    }

                    /*----------------------------------------------------------------*
@@ -444,11 +440,7 @@ ivas_error ivas_ism_metadata_dec(
                    }
                    else /* ISM_MODE_DISC */
                    {
#ifdef UNIFY_MD_QUANTIZER
                        hIsmMetaData->elevation = ism_dequant_meta( idx_elevation, ism_elevation_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_ELEVATION_NBITS );
#else
                        hIsmMetaData->elevation = ism_dequant_meta( idx_elevation, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS );
#endif
                    }

                    /*----------------------------------------------------------------*
@@ -557,9 +549,6 @@ ivas_error ivas_ism_metadata_dec(
#ifdef DISCRETE_ISM_DTX_CNG
    if ( hISMDTX.ism_dtx_hangover_cnt < IVAS_ISM_DTX_HO_MAX )
    {
#ifdef MD_SMOOTH_PARAM_BE
        if ( ism_mode != ISM_MODE_PARAM )
#endif
        ism_metadata_smooth( hIsmMeta, ism_total_brate, num_obj );
    }
    hISMDTX.ism_dtx_hangover_cnt = min( ( hISMDTX.ism_dtx_hangover_cnt )++, IVAS_ISM_DTX_HO_MAX );
@@ -686,70 +675,6 @@ ivas_error create_ism_metadata_dec(


#ifdef DISCRETE_ISM_DTX_CNG
#ifndef UNIFY_MD_QUANTIZER
/*-------------------------------------------------------------------*
 * ivas_ism_dec_dequantize_DOA_dtx()
 *
 *
 *-------------------------------------------------------------------*/

static void ivas_ism_dec_dequantize_DOA_dtx(
    const int16_t azi_bits,
    const int16_t ele_bits,
    const int16_t azi_idx,
    const int16_t ele_idx,
    float *azi_val,
    float *ele_val )
{
    int16_t nbits, npoints, angle_spacing, az_alpha, ele_alpha, tmp_alpha;

    /* Step 1: Determine angle spacing/n_points based on minimum value among elevation/azimuth bits */
    nbits = min( azi_bits, ele_bits );

    if ( nbits == ISM_ELEVATION_NBITS )
    {
        angle_spacing = 5;
    }
    else
    {
        angle_spacing = (int16_t) ( ( 180.f / (float) ( 1 << nbits ) ) + 0.5f );
    }

    npoints = (int16_t) ( ( 90 / angle_spacing ) + 0.5f );

    /* sanity check */
    if ( angle_spacing == 360 )
    {
        assert( azi_idx == 0 );
        assert( ele_idx == 0 );

        *azi_val = 0.f;
        *ele_val = 0.f;
        return;
    }

    /* Get the azimuth and elevation values */
    ele_alpha = 2 * npoints - 1;
    assert( ( 0 <= ele_idx ) && ( ele_idx < ele_alpha ) );
    *ele_val = (float) ( ( ele_idx - npoints ) * angle_spacing );

    az_alpha = 4 * npoints - 1;
    assert( ( 0 <= azi_idx ) && ( azi_idx < az_alpha ) );
    tmp_alpha = (int16_t) ( azi_idx * ( 360.f / az_alpha ) );

    if ( tmp_alpha > 180.0f )
    {
        *azi_val = ( (float) tmp_alpha ) - 360.0f;
    }
    else
    {
        *azi_val = (float) tmp_alpha;
    }

    return;
}
#endif

/*-------------------------------------------------------------------*
 * ivas_ism_metadata_sid_dec()
 *
@@ -769,12 +694,8 @@ ivas_error ivas_ism_metadata_sid_dec(
    int16_t nb_bits_metadata[]      /* o  : number of metadata bits     */
)
{
#ifdef UNIFY_MD_QUANTIZER
    int16_t i, ch, nb_bits_start, last_bit_pos;
    float q_step, q_step_border;
#else
    int16_t i, ch, nb_bits_start, last_bit_pos, low_res_q;
#endif
    int16_t idx, idx_azimuth, idx_elevation;
    int16_t nBits_azimuth, nBits_elevation, nBits_coh, nBits_sce_id;
    int16_t md_diff_flag[MAX_NUM_OBJECTS];
@@ -786,9 +707,6 @@ ivas_error ivas_ism_metadata_sid_dec(

    if ( ism_total_brate == FRAME_NO_DATA )
    {
#ifdef MD_SMOOTH_PARAM_BE
        if ( ism_mode != ISM_MODE_PARAM )
#endif
        ism_metadata_smooth( hIsmMeta, ism_total_brate, num_obj );

        return IVAS_ERR_OK;
@@ -831,11 +749,7 @@ ivas_error ivas_ism_metadata_sid_dec(
         * Set quantization bits based on the number of coded objects
         *----------------------------------------------------------------*/

#ifdef UNIFY_MD_QUANTIZER
        ivas_get_ism_sid_quan_bitbudget( num_obj, &nBits_azimuth, &nBits_elevation, &q_step, &q_step_border, &nBits_coh, &nBits_sce_id );
#else
        low_res_q = ivas_get_ism_sid_quan_bitbudget( num_obj, &nBits_azimuth, &nBits_elevation, &nBits_coh, &nBits_sce_id );
#endif

        /*----------------------------------------------------------------*
         * Spatial parameters, loop over TCs - 1
@@ -897,70 +811,14 @@ ivas_error ivas_ism_metadata_sid_dec(

            if ( md_diff_flag[ch] == 1 )
            {
#ifndef UNIFY_MD_QUANTIZER
                if ( low_res_q )
                {
                    idx_azimuth = get_next_indice( st0, nBits_azimuth );
                    idx_elevation = get_next_indice( st0, nBits_elevation );

                    ivas_ism_dec_dequantize_DOA_dtx( nBits_azimuth, nBits_elevation, idx_azimuth, idx_elevation, &( hIsmMetaData->azimuth ), &( hIsmMetaData->elevation ) );
                }
                else
#endif
                {
                /* Azimuth decoding */
                idx_azimuth = get_next_indice( st0, nBits_azimuth );

#ifndef UNIFY_MD_QUANTIZER
                    /* azimuth is on a circle - check for diff coding for -180° -> 180° and vice versa changes */
                    if ( idx_azimuth > ( 1 << ISM_AZIMUTH_NBITS ) - 1 )
                    {
                        idx_azimuth -= ( 1 << ISM_AZIMUTH_NBITS ) - 1; /* +180° -> -180° */
                    }
                    else if ( idx_azimuth < 0 )
                    {
                        idx_azimuth += ( 1 << ISM_AZIMUTH_NBITS ) - 1; /* -180° -> +180° */
                    }

                    /* +180° == -180° */
                    if ( idx_azimuth == ( 1 << ISM_AZIMUTH_NBITS ) - 1 )
                    {
                        idx_azimuth = 0;
                    }

                    /* sanity check in case of FER or BER */
                    if ( idx_azimuth < 0 || idx_azimuth > ( 1 << ISM_AZIMUTH_NBITS ) - 1 )
                    {
                        idx_azimuth = hIsmMetaData->last_azimuth_idx;
                    }

                    hIsmMetaData->azimuth = ism_dequant_meta( idx_azimuth, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS );
#else
                hIsmMetaData->azimuth = ism_dequant_meta( idx_azimuth, ism_azimuth_borders, q_step, q_step_border, 1 << nBits_azimuth );
#endif

                /* Elevation decoding */
                idx_elevation = get_next_indice( st0, nBits_elevation );
#ifndef UNIFY_MD_QUANTIZER

                    /* sanity check in case of FER or BER */
                    if ( idx_elevation < 0 || idx_elevation > ( 1 << ISM_ELEVATION_NBITS ) - 1 )
                    {
                        idx_elevation = hIsmMetaData->last_elevation_idx;
                    }

                    /* Elevation dequantization */
                    hIsmMetaData->elevation = ism_dequant_meta( idx_elevation, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS );
#else
                hIsmMetaData->elevation = ism_dequant_meta( idx_elevation, ism_elevation_borders, q_step, q_step_border, 1 << nBits_elevation );
#endif
                }

#ifdef MD_Q_PARAM_BE
                if ( ism_mode != ISM_MODE_PARAM )
#endif
                {
#ifdef UNIFY_MD_QUANTIZER
                /* update last indexes to correspond to active frames coding */
                if ( nBits_azimuth > ISM_AZIMUTH_NBITS )
                {
@@ -972,11 +830,6 @@ ivas_error ivas_ism_metadata_sid_dec(
                    hIsmMetaData->last_azimuth_idx = idx_azimuth << ( ISM_AZIMUTH_NBITS - nBits_azimuth );
                    hIsmMetaData->last_elevation_idx = idx_elevation << ( ISM_ELEVATION_NBITS - nBits_elevation );
                }
#else
                    hIsmMetaData->last_azimuth_idx = idx_azimuth;
                    hIsmMetaData->last_elevation_idx = idx_elevation;
#endif
                }

                /* save for smoothing metadata evolution */
                hIsmMetaData->last_true_azimuth = hIsmMetaData->azimuth;
@@ -993,9 +846,6 @@ ivas_error ivas_ism_metadata_sid_dec(
    }

    /* smooth the metadata evolution */
#ifdef MD_SMOOTH_PARAM_BE
    if ( ism_mode != ISM_MODE_PARAM )
#endif
    ism_metadata_smooth( hIsmMeta, ism_total_brate, num_obj );

    return IVAS_ERR_OK;
Loading