Commit 751cc390 authored by vaclav's avatar vaclav
Browse files

- introduce OMASA_BRATE_TD

- fix for 2ISM @64 kbps in ROM table
parent 6711b564
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2793,7 +2793,7 @@ int32_t sep_object_brate[][MAX_NUM_OBJECTS] =
#endif
    {IVAS_13k2, 0, 0, 0},                          /* 48k  */
#ifdef OMASA_BRATE_FIX
    {16000,     12500, 0, 0},                      /* 64k  */
    {16000,     12000, 0, 0},                      /* 64k  */
#else
    {16000,     IVAS_13k2, 0, 0},                  /* 64k  */
#endif
+2 −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/" */
@@ -165,6 +165,7 @@
#define OMASA_BRATE /* VA: combined format bit-budget distribution */
#define OMASA_BRATE_FIX // fix at lowest bitrates and 1 inactive ISM - more verification/tuning needed
#define OMASA_BRATE_FIX_ALT
#define OMASA_BRATE_TD // support of bitrate adaptation n TD stereo - work in progress
#define DEBUG_VA // output 'res/brate_ism' and 'res_brate_masa' bit-rates debugging files

#endif
+3 −0
Original line number Diff line number Diff line
@@ -296,6 +296,9 @@ ivas_error ivas_cpe_dec(
        /* signal bitrate for BW selection in the SCh */
        sts[0]->bits_frame_channel = 0;
        sts[1]->bits_frame_channel = (int16_t) ( hCPE->element_brate / FRAMES_PER_SEC );
#ifdef OMASA_BRATE_TD
        sts[1]->bits_frame_channel += (int16_t) ( hCPE->brate_surplus / FRAMES_PER_SEC );
#endif
        if ( st_ivas->hQMetaData != NULL )
        {
            sts[1]->bits_frame_channel -= st_ivas->hQMetaData->metadata_max_bits;
+4 −0
Original line number Diff line number Diff line
@@ -767,7 +767,11 @@ ivas_error stereo_memory_dec(
        if ( hCPE->hCoreCoder[0]->bfi == 0 )
        {
            st = hCPE->hCoreCoder[1];
#ifdef OMASA_BRATE_TD
            hCPE->hStereoTD->tdm_LRTD_flag = get_indice_st( hCPE->hCoreCoder[0], hCPE->element_brate + hCPE->brate_surplus, (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata + ( hCPE->brate_surplus / FRAMES_PER_SEC ) - TDM_SECONDARY_SIGNALLING - TDM_RATIO_BITS - TDM_LP_REUSE_BITS - TDM_LR_CONTENT_BITS ), TDM_LR_CONTENT_BITS );
#else
            hCPE->hStereoTD->tdm_LRTD_flag = get_indice_st( hCPE->hCoreCoder[0], hCPE->element_brate, (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata - TDM_SECONDARY_SIGNALLING - TDM_RATIO_BITS - TDM_LP_REUSE_BITS - TDM_LR_CONTENT_BITS ), TDM_LR_CONTENT_BITS );
#endif

            if ( hCPE->hStereoTD->tdm_LRTD_flag )
            {
+42 −0
Original line number Diff line number Diff line
@@ -94,10 +94,19 @@ void tdm_configure_dec(
    int16_t tdm_tmp_SM_LRTD_flag;
    int16_t mod_ct, core, bits_offset;
    int16_t idx_LRTD_pri_side, tdm_inst_ratio_idx;
#ifdef OMASA_BRATE_TD
    int32_t element_brate_adapt;
    int16_t bstr_last_pos;
#endif

    hStereoTD = hCPE->hStereoTD;
    sts = hCPE->hCoreCoder;

#ifdef OMASA_BRATE_TD
    element_brate_adapt = hCPE->element_brate + hCPE->brate_surplus;
    bstr_last_pos = (int16_t) ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata + (int16_t) ( hCPE->brate_surplus / FRAMES_PER_SEC );
#endif

    /*----------------------------------------------------------------*
     * Decode CoreCoder signaling
     *----------------------------------------------------------------*/
@@ -123,7 +132,11 @@ void tdm_configure_dec(

    /* Get few parameters needed to decode the bitrate allocated to each channel */
    /* Get the coder_type of the secondary channel (last parameter on 2 bits) */
#ifdef OMASA_BRATE_TD
    sts[1]->coder_type = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - nb_bits_metadata - TDM_SECONDARY_SIGNALLING, TDM_SECONDARY_SIGNALLING );
#else
    sts[1]->coder_type = get_indice_st( sts[0], hCPE->element_brate, (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata - TDM_SECONDARY_SIGNALLING ), TDM_SECONDARY_SIGNALLING );
#endif

    /* Get the LRTD config flag:  1 = LRTD configuration, favor closer bitrate per channel;
                                  0 = Pri/Sec configuration, bitrates linked wrt. the mono */
@@ -151,19 +164,31 @@ void tdm_configure_dec(
     *----------------------------------------------------------------*/

    /* Get the correlation ratio */
#ifdef OMASA_BRATE_TD
    *tdm_ratio_idx = get_indice_st( sts[0], element_brate_adapt, (int16_t) ( bstr_last_pos - TDM_SECONDARY_SIGNALLING - TDM_RATIO_BITS ), TDM_RATIO_BITS );
#else
    *tdm_ratio_idx = get_indice_st( sts[0], hCPE->element_brate, (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata - TDM_SECONDARY_SIGNALLING - TDM_RATIO_BITS ), TDM_RATIO_BITS );
#endif

    hStereoTD->tdm_use_IAWB_Ave_lpc = 0;
    if ( sts[1]->coder_type == INACTIVE )
    {
        /* Get the flag on the LPC reusage type (primary channel of ave LPC */
#ifdef OMASA_BRATE_TD
        hStereoTD->tdm_use_IAWB_Ave_lpc = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SECONDARY_SIGNALLING - TDM_RATIO_BITS - TDM_LP_REUSE_BITS, TDM_LP_REUSE_BITS );
#else
        hStereoTD->tdm_use_IAWB_Ave_lpc = get_indice_st( sts[0], hCPE->element_brate, (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata - TDM_SECONDARY_SIGNALLING - TDM_RATIO_BITS - TDM_LP_REUSE_BITS ), TDM_LP_REUSE_BITS );
#endif
        hStereoTD->tdm_lp_reuse_flag = 1;
    }
    else
    {
        /* Get the flag on the LPC reusage */
#ifdef OMASA_BRATE_TD
        hStereoTD->tdm_lp_reuse_flag = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SECONDARY_SIGNALLING - TDM_RATIO_BITS - TDM_LP_REUSE_BITS, TDM_LP_REUSE_BITS );
#else
        hStereoTD->tdm_lp_reuse_flag = get_indice_st( sts[0], hCPE->element_brate, (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata - TDM_SECONDARY_SIGNALLING - TDM_RATIO_BITS - TDM_LP_REUSE_BITS ), TDM_LP_REUSE_BITS );
#endif
    }

    sts[0]->tdm_LRTD_flag = hStereoTD->tdm_LRTD_flag; /* the flag was already read in function stereo_memory_dec() */
@@ -219,7 +244,11 @@ void tdm_configure_dec(
        int16_t tmpS = 20;
        if ( hStereoTD->tdm_LRTD_flag == 0 )
        {
#ifdef OMASA_BRATE_TD
            tmpS = get_indice_st( sts[0], element_brate_adapt, (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + STEREO_BITS_TCA_CHAN + STEREO_BITS_TCA_CORRSTATS ), STEREO_BITS_TCA_GD );
#else
            tmpS = get_indice_st( sts[0], hCPE->element_brate, (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + STEREO_BITS_TCA_CHAN + STEREO_BITS_TCA_CORRSTATS ), STEREO_BITS_TCA_GD );
#endif
        }
        hCPE->hStereoDftDmx->targetGain = usdequant( tmpS, STEREO_TCA_GDMIN, STEREO_TCA_GDSTEP );
        hCPE->hStereoDftDmx->targetGain = powf( 10, hCPE->hStereoDftDmx->targetGain );
@@ -228,9 +257,15 @@ void tdm_configure_dec(
    {
        if ( hStereoTD->tdm_LRTD_flag == 0 )
        {
#ifdef OMASA_BRATE_TD
            hCPE->hStereoTCA->refChanIndx = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS, STEREO_BITS_TCA_CHAN );
            hCPE->hStereoTCA->indx_ica_NCShift = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + STEREO_BITS_TCA_CHAN, STEREO_BITS_TCA_CORRSTATS );
            hCPE->hStereoTCA->indx_ica_gD = get_indice_st( sts[0], element_brate_adapt, bstr_last_pos - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + STEREO_BITS_TCA_CHAN + STEREO_BITS_TCA_CORRSTATS, STEREO_BITS_TCA_GD );
#else
            hCPE->hStereoTCA->refChanIndx = get_indice_st( sts[0], hCPE->element_brate, (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ), STEREO_BITS_TCA_CHAN );
            hCPE->hStereoTCA->indx_ica_NCShift = get_indice_st( sts[0], hCPE->element_brate, (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + STEREO_BITS_TCA_CHAN ), STEREO_BITS_TCA_CORRSTATS );
            hCPE->hStereoTCA->indx_ica_gD = get_indice_st( sts[0], hCPE->element_brate, (int16_t) ( ( hCPE->element_brate / FRAMES_PER_SEC ) - nb_bits_metadata - TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + STEREO_BITS_TCA_CHAN + STEREO_BITS_TCA_CORRSTATS ), STEREO_BITS_TCA_GD );
#endif
        }
        else
        {
@@ -265,7 +300,14 @@ void tdm_configure_dec(
     * bitbudget distribution between channels (taking into account also metadata bitbudget)
     *----------------------------------------------------------------*/

#ifdef OMASA_BRATE_TD
    tdm_bit_alloc( hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus,
                   hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ),
                   &hStereoTD->tdm_low_rate_mode, sts[1]->coder_type, *tdm_ratio_idx, hStereoTD->tdm_Pitch_reuse_flag,
                   sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, tdm_inst_ratio_idx );
#else
    tdm_bit_alloc( hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC, hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), &hStereoTD->tdm_low_rate_mode, sts[1]->coder_type, *tdm_ratio_idx, hStereoTD->tdm_Pitch_reuse_flag, sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, tdm_inst_ratio_idx );
#endif

    return;
}
Loading