Commit 31dc1fdb authored by TYAGIRIS's avatar TYAGIRIS
Browse files

rtyag review comments inline

parent 698d49f5
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
@@ -2145,6 +2145,56 @@ void ivas_spar_set_bitrate_config(
    pSpar_md_cfg->tgt_bits_per_blk += md_coding_bits_header;
    pSpar_md_cfg->max_bits_per_blk += md_coding_bits_header;

    /*rtyag: IMO this is where we should have the check and compute worst case MD bits

what we want to check is 
if (pSpar_md_cfg->max_bits_per_blk - md_coding_bits_header >= base2(PR_bits_perband + P_bits_perband + C_bits_perband)*num_bands)
if above condition is not true then assert(0);
Here, we dont really need to account for AGC or PCA as we have been taking AGC and PCA bits from core coder always. 

pSpar_md_cfg->max_bits_per_blk is what you should use to bail out of arith/huff coder during processing.

 

When it comes to reporting the max MD bits for bitstream indices allocation then that should be
what we write in hMetaData handle in worst case
i.e. pSpar_md_cfg->max_bits_per_blk  + AGC max bits + PCA max bits + DirAC max bits

AGC bits can be computed as
if(hSpar->AGC_Enable)
{
AGC_bits = (ndmx == 1)?AGC_BITS_PER_CH : AGC_SIGNALLING_BITS + AGC_BITS_PER_CH*ndmx
}
else
{
AGC_bits = AGC_SIGNALLING_BITS
}

PCA bits can be computed as
 if (hEncoderConfig->Opt_PCA_ON  )
 {
 PCA_bits = 1 + IVAS_PCA_QBITS + IVAS_PCA_QBITS - 1;
 }
 else
 {
        if ( ivas_total_brate == PCA_BRATE && sba_order == SBA_FOA_ORDER )
        {
          PCA_bits = 1;
         }
        else
         {
          PCA_bits = 0;
         }
 }



 for dirac_bits, try using
 min(hQMetaData->metadata_max_bits+1, 500); (note: 500 is a temp value, actual value will come from FhG.
 If you see self test failure with 500 then increase it in steps of 100 until you see BE results)

 */

    return;
}

+9 −0
Original line number Diff line number Diff line
@@ -452,6 +452,15 @@ static ivas_error ivas_spar_enc_process(

    push_wmops( "ivas_spar_enc_process" );

    /*
    rtyag : for debugging,

    store the start_nb_bits = hMetaData->nb_bits_tot here and then at the end of this function
    compute total_md_bits = hMetaData->nb_bits_tot - start_nb_bits;
    and the assert (total_md_bits <= hMdEnc->max_md_bits_sba), this should pass for all self tests

    */

    /*-----------------------------------------------------------------------------------------*
     * Initialization
     *-----------------------------------------------------------------------------------------*/
+7 −0
Original line number Diff line number Diff line
@@ -213,6 +213,9 @@ ivas_error ivas_spar_md_enc_open(
    }

#ifdef ARITH_HUFF_CODER_CHANGES
    /*rtyag : this should be moved to ivas_spar_set_bitrate_config() after we calculate
        pSpar_md_cfg->max_bits_per_blk, refer to my comment in  ivas_spar_set_bitrate_config()
        */
    /*calculate the worst case strat vlaue*/
    table_idx = ivas_get_spar_table_idx( hEncoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL );
    if ( ( ivas_spar_br_table_consts[table_idx].q_lvls[2][0] == 1 &&
@@ -237,6 +240,7 @@ ivas_error ivas_spar_md_enc_open(
    n_input = ivas_sba_get_nchan_metadata( sba_order );
    n_dmx = ivas_spar_br_table_consts[table_idx].nchan_transport;
    n_dec = n_input - n_dmx;
    /*rtyag : please use (int16_t)ceilf(log2f(q_lvls[][])), no need to add +1*/
    bits_PR = ( (int16_t) log2( ivas_spar_br_table_consts[table_idx].q_lvls[quant_strat][0] ) + 1 ) * ( n_input - 1 );
    bits_C = ( (int16_t) log2( ivas_spar_br_table_consts[table_idx].q_lvls[quant_strat][1] ) + 1 ) * ( ( n_dmx - 1 ) * n_dec );
    bits_P = ( (int16_t) log2( ivas_spar_br_table_consts[table_idx].q_lvls[quant_strat][2] ) + 1 ) * n_dec;
@@ -247,7 +251,10 @@ ivas_error ivas_spar_md_enc_open(
    {
        printf( "wc_coarse_strat is greater than table_cal_wc!" );
    }
    /*rtyag : rename it to hMdEnc->max_md_bits_sba and refer to my comment in ivas_spar_set_bitrate_config() on how to compute it*/
    hMdEnc->wc_strat = wc_coarse_strat;
    /*rtyag : we dont need to malloc, we just need to report this hMdEnc->max_md_bits_sba value.
        Please refer to my comment in ivas_spar_set_bitrate_config() function*/
    hMdEnc->wc_coarse_strat_buff = (Indice *) malloc( wc_coarse_strat * sizeof( Indice ) );
#endif
    *hMdEnc_in = hMdEnc;