Commit 338cf486 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

Merge branch 'arithmetic_huffman_coder_changes' into 'main'

SBA MAX MD limit changes (needs further change for DirAC MD limit)

See merge request !522
parents 5808c9ae f6513e34
Loading
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1021,6 +1021,10 @@ typedef enum
/* AGC constants */
#define AGC_BITS_PER_CH                         3
#define AGC_EMAX                                0
#ifdef ARITH_HUFF_CODER_CHANGES
#define AGC_SIGNALLING_BITS                     1
#define IVAS_SPAR_ARITH_OVERSHOOT_BITS               (16)
#endif

/* Common SPAR metadata constants */
#define IVAS_ACTIVEW_DM_F_SCALE                 0.5f
@@ -1749,11 +1753,17 @@ typedef enum
#define IVAS_16K_12BANDS_ACTIVE_BANDS           10

#define SPAR_DIRAC_SPLIT_START_BAND             8 
#define DIRAC_TO_SPAR_HBR_PRED_CHS                     (FOA_CHANNELS - 1)
#define SPAR_DTX_BANDS                          2
#define DIRAC_DTX_BANDS                         2
#define SPAR_DIRAC_DTX_BANDS                    ( SPAR_DTX_BANDS + DIRAC_DTX_BANDS )
#define CLDFB_PAR_WEIGHT_START_BAND             7

#ifdef ARITH_HUFF_CODER_CHANGES
#define QUANT_STRAT_0                           0
#define QUANT_STRAT_2                           2
#endif 


/*----------------------------------------------------------------------------------*
 * Limiter constants
+73 −1
Original line number Diff line number Diff line
@@ -329,6 +329,70 @@ void ivas_dirac_config_bands(
    return;
}

#ifdef ARITH_HUFF_CODER_CHANGES
void ivas_get_dirac_sba_max_md_bits(
    const int32_t sba_total_brate,
    int16_t *bits_frame_nominal,
    int16_t *metadata_max_bits,
    int16_t *qmetadata_max_bit_req,
    int16_t nbands )
{
    if ( sba_total_brate <= IVAS_13k2 )
    {
        *bits_frame_nominal = ACELP_9k60 / FRAMES_PER_SEC;
        *metadata_max_bits = 70;
    }
    else if ( sba_total_brate <= IVAS_16k4 )
    {
        *bits_frame_nominal = ACELP_13k20 / FRAMES_PER_SEC;
        *metadata_max_bits = 80;
    }
    else if ( sba_total_brate <= IVAS_24k4 )
    {
        *bits_frame_nominal = ACELP_16k40 / FRAMES_PER_SEC;
        *metadata_max_bits = 103;
    }
    else if ( sba_total_brate <= IVAS_32k )
    {
        *bits_frame_nominal = ACELP_32k / FRAMES_PER_SEC;
        *metadata_max_bits = 214;
    }
    else if ( sba_total_brate <= IVAS_48k )
    {
        *bits_frame_nominal = IVAS_48k / FRAMES_PER_SEC;
        *metadata_max_bits = 240;
    }
    else if ( sba_total_brate <= IVAS_64k )
    {
        *bits_frame_nominal = IVAS_64k / FRAMES_PER_SEC;
        *metadata_max_bits = 200;
    }
    else if ( sba_total_brate <= IVAS_80k )
    {
        *bits_frame_nominal = IVAS_80k / FRAMES_PER_SEC;
        *metadata_max_bits = 200;
    }
    else if ( sba_total_brate <= IVAS_96k )
    {
        *bits_frame_nominal = IVAS_96k / FRAMES_PER_SEC;
        *metadata_max_bits = 200;
    }
    else if ( sba_total_brate <= IVAS_128k )
    {
        *bits_frame_nominal = IVAS_128k / FRAMES_PER_SEC;
        *metadata_max_bits = 250;
    }
    else
    {
        *bits_frame_nominal = (int16_t) ( sba_total_brate / FRAMES_PER_SEC );
        *metadata_max_bits = MAX16B; /* no limit */
    }
    *metadata_max_bits = (int16_t) ceilf( (float) *metadata_max_bits * nbands / 5 );
    *qmetadata_max_bit_req = QMETADATA_MAXBIT_REQ_SBA >> 1;

    return;
}
#endif

/*-------------------------------------------------------------------------
 * ivas_dirac_sba_config()
@@ -427,7 +491,14 @@ ivas_error ivas_dirac_sba_config(
            }
#endif
        }

#ifdef ARITH_HUFF_CODER_CHANGES
        ivas_get_dirac_sba_max_md_bits(
            sba_total_brate,
            &hQMetaData->bits_frame_nominal,
            &hQMetaData->metadata_max_bits,
            &hQMetaData->qmetadata_max_bit_req,
            hQMetaData->q_direction[0].cfg.nbands );
#else
        if ( sba_total_brate <= IVAS_13k2 )
        {
            hQMetaData->bits_frame_nominal = ACELP_9k60 / FRAMES_PER_SEC;
@@ -481,6 +552,7 @@ ivas_error ivas_dirac_sba_config(

        hQMetaData->metadata_max_bits = (int16_t) ceilf( (float) hQMetaData->metadata_max_bits * hQMetaData->q_direction[0].cfg.nbands / 5 );
        hQMetaData->qmetadata_max_bit_req = QMETADATA_MAXBIT_REQ_SBA >> 1;
#endif

        return error;
    }
+31 −2
Original line number Diff line number Diff line
@@ -114,6 +114,10 @@ ivas_error ivas_spar_md_enc_init
ivas_error ivas_sba_enc_reconfigure( 
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder structure                  */
);
#ifdef ARITH_HUFF_CODER_CHANGES
int16_t ivas_sba_get_max_md_bits(
    Encoder_Struct *st_ivas );
#endif

void destroy_sce_enc(
    SCE_ENC_HANDLE hSCE                                         /* i/o: SCE encoder structure                   */
@@ -3599,6 +3603,15 @@ void ivas_dirac_config_bands(
    IVAS_FB_MIXER_HANDLE hFbMdft
);

#ifdef ARITH_HUFF_CODER_CHANGES
void ivas_get_dirac_sba_max_md_bits(
    const int32_t sba_total_brate,
    int16_t *bits_frame_nominal,
    int16_t *metadata_max_bits,
    int16_t *qmetadata_max_bit_req,
    int16_t nbands );
#endif

ivas_error ivas_dirac_sba_config(
    IVAS_QMETADATA_HANDLE hQMetaData,                           /* i/o: q_metadata handle                                    */
    int16_t *nchan_transport,                                   /* o  : number of transport channel needed for MASA format   */
@@ -4449,6 +4462,13 @@ void ivas_spar_set_bitrate_config(
    ivas_spar_md_com_cfg *pSpar_md_cfg,                         /* i/o: SPAR MD config. handle                  */
    const int16_t table_idx,                                    /* i  : config. table index                     */
    const int16_t num_bands                                     /* i  : number of bands                         */
#ifdef ARITH_HUFF_CODER_CHANGES
    ,
    const int16_t dirac2spar_md_flag,
    const int16_t enc_flag,
    const int16_t pca_flag,
    const int16_t agc_flag
#endif
);

void ivas_spar_bitrate_dist(
@@ -4964,7 +4984,16 @@ int16_t ivas_get_bits_to_encode(
void ivas_huffman_encode( ivas_huffman_cfg_t *huff_cfg, int16_t in, int16_t *hcode, int16_t *hlen );
void ivas_spar_huff_coeffs_com_init( ivas_huff_coeffs_t *pHuff_coeffs, ivas_spar_md_com_cfg *pSpar_cfg, const int16_t table_idx, const int16_t enc_dec );
void ivas_spar_arith_coeffs_com_init( ivas_arith_coeffs_t *pArith_coeffs, ivas_spar_md_com_cfg *pSpar_cfg, const int16_t table_idx, const int16_t enc_dec );
void ivas_arith_encode_cmplx_cell_array(ivas_arith_t *pArith_re, ivas_arith_t *pArith_re_diff, const int16_t *pDo_diff, const int16_t nB, int16_t *pSymbol_re, int16_t *pSymbol_old_re, ivas_cell_dim_t *pCell_dims, BSTR_ENC_HANDLE hMetaData, const int16_t any_diff);
#ifdef ARITH_HUFF_CODER_CHANGES
int16_t ivas_arith_encode_cmplx_cell_array(
#else
void ivas_arith_encode_cmplx_cell_array(
#endif
ivas_arith_t *pArith_re, ivas_arith_t *pArith_re_diff, const int16_t *pDo_diff, const int16_t nB, int16_t *pSymbol_re, int16_t *pSymbol_old_re, ivas_cell_dim_t *pCell_dims, BSTR_ENC_HANDLE hMetaData, const int16_t any_diff 
#ifdef ARITH_HUFF_CODER_CHANGES
  , int32_t wc_strat_arith
#endif
);
ivas_error ivas_huffman_decode( ivas_huffman_cfg_t *huff_cfg, Decoder_State *st0, int16_t *dec_out );
void ivas_arith_decode_cmplx_cell_array( ivas_arith_t *pArith_re, ivas_arith_t *pArith_re_diff, Decoder_State *st0, ivas_cell_dim_t *pCell_dims, int16_t *pDo_diff, const int16_t nB, int16_t *pSymbol_re, int16_t *pSymbol_re_old );

+7 −1
Original line number Diff line number Diff line
@@ -935,7 +935,13 @@ const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] =
    { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },
    { 256000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } },
    { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 31, 1, 1, 1 } }, 1, 2, 0 },
    { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },
#ifdef ARITH_HUFF_CODER_CHANGES
    { 1, 1, 1, 1 }
#else
    { 31, 1, 1, 1 }
#endif
 }, 1, 2, 0 },
    { 384000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 100000, 100000, 128000 },{ 79850, 79850, 104000 },{ 66600, 66600, 104000 } },   // not yet optimized
    { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },
+0 −1
Original line number Diff line number Diff line
@@ -328,7 +328,6 @@ extern const float McMASA_LFEGain_vectors[64];
extern const float ism_azimuth_borders[4];
extern const float ism_elevation_borders[4];


/*----------------------------------------------------------------------------------*
 * Param ISM ROM tables
 *----------------------------------------------------------------------------------*/
Loading