Commit b1ab6c1a authored by vaclav's avatar vaclav
Browse files

Merge branch '92-spar-code-redundancies-2' into 'main'

Resolve "SPAR code redundancies" rev2

See merge request !225
parents ffa86e78 4ca7f198
Loading
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -831,8 +831,13 @@ typedef enum {
 * SBA Constants
 *----------------------------------------------------------------------------------*/

#define SBA_FOA_ORDER                           1
#define SBA_HOA2_ORDER                          2
#define SBA_HOA3_ORDER                          3

#define SBA_PLANAR_BITS                         1
#define SBA_ORDER_BITS                          2

#define SBA_MIN_BRATE_HOA                       IVAS_256k
#define SBA_NHARM_HOA3                          16
#define SBA_T_DESIGN_11_SIZE                    70
+16 −16
Original line number Diff line number Diff line
@@ -903,57 +903,57 @@ const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] =
{
/* When AGC is ON additional (AGC_BITS_PER_CH+1) bits may be taken from each core-coder channel
   so minimum core-coder bitrate per channel can be min core-coder bitrates as per the table - AGC_BITS_PER_CH */
    { 24400, 0, 1, FB, 24000, 1, WYXZ, 1, 0,{ { 16400, 14850, 24350 } },
    { 24400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0,{ { 16400, 14850, 24350 } },
    { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 },

    { 32000, 0, 1, FB, 24000, 1, WYXZ, 1, 0,{ { 24000, 20450, 31950 } },
    { 32000, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0,{ { 24000, 20450, 31950 } },
    { { 21, 1, 5, 1 },{ 15, 1, 5, 1 },{ 15, 1, 3, 1 } }, 0, 0, 0 },

    { 48000, 0, 1, FB, 24000, 2, WYXZ, 0, 0,{ { 24000, 21000, 31950 },{ 16000, 15000, 20400 } },
    { 48000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0,{ { 24000, 21000, 31950 },{ 16000, 15000, 20400 } },
    { { 15, 7, 5, 1 },{ 15, 7, 3, 1 },{ 7, 7, 3, 1 } }, 1, 0, 0 },

    { 64000, 0, 1, FB, 24000, 2, WYXZ, 0, 0,{ { 38000, 34050, 56000 },{ 16000, 15600, 20400 } },{ { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 1, 0 },
    { 64000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0,{ { 38000, 34050, 56000 },{ 16000, 15600, 20400 } },{ { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 1, 0 },

    { 80000, 0, 1, FB, 24000, 2, WYXZ, 0, 0,{ { 46000, 43000, 56000 },{ 24000, 23000, 31950 } },
    { 80000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0,{ { 46000, 43000, 56000 },{ 24000, 23000, 31950 } },
    { { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 0, 0 },

    { 96000, 0, 1, FB, 24000, 3, WYXZ, 0, 0,{ { 47000, 42600, 56000 },{ 23000, 22600, 31950 },{ 16000, 15600, 20400 } },
    { 96000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 47000, 42600, 56000 },{ 23000, 22600, 31950 },{ 16000, 15600, 20400 } },
    { { 21, 9, 9, 1 },{ 21, 7, 5, 1 },{ 21, 7, 5, 1 } }, 1, 0, 0 },

    { 128000, 0, 1, FB, 24000, 3, WYXZ, 0, 0,{ { 55000, 50000, 56000 },{ 36000, 36000, 56000 },{ 27000, 27000, 31950 } },
    { 128000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 55000, 50000, 56000 },{ 36000, 36000, 56000 },{ 27000, 27000, 31950 } },
    { { 21, 11, 9, 1 },{ 21, 9, 7, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 },

    { 160000, 0, 1, FB, 24000, 3, WYXZ, 0, 0,{ { 74000, 70900, 112000 },{ 41000, 40050, 56000 },{ 35000, 34050, 56000 } },
    { 160000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 74000, 70900, 112000 },{ 41000, 40050, 56000 },{ 35000, 34050, 56000 } },
    { { 21, 11, 11, 1 },{ 21, 9, 9, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 },

    { 192000, 0, 1, FB, 24000, 3, WYXZ, 0, 0,{ { 90000, 87900, 112000 },{ 50000, 48050, 56000 },{ 42000, 41050, 56000 } },
    { 192000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 90000, 87900, 112000 },{ 50000, 48050, 56000 },{ 42000, 41050, 56000 } },
    { { 21, 11, 11, 1 },{ 21, 9, 9, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 },

    { 256000, 0, 1, FB, 24000, 4, WYXZ, 0, 0,{ { 90000, 85000, 112000 },{ 70000, 69000, 112000 },{ 50000, 48950, 56000 },{ 36400, 35600, 56000 } },
    { 256000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 90000, 85000, 112000 },{ 70000, 69000, 112000 },{ 50000, 48950, 56000 },{ 36400, 35600, 56000 } },
    { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },

    { 256000, 0, 2, FB, 24000, 4, WYXZ, 0, 0,{ { 84650, 83000, 112000 },{ 65850, 64550, 56000 },{ 47000, 46100, 48000 },{ 28200, 27650, 40000 } },
    { 256000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 84650, 83000, 112000 },{ 65850, 64550, 56000 },{ 47000, 46100, 48000 },{ 28200, 27650, 40000 } },
    { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },

    { 256000, 0, 3, FB, 24000, 4, WYXZ, 0, 0,{ { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } },
    { 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 },

    { 384000, 0, 1, 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 },

    { 384000, 0, 2, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, // just added as a place holder, not necessarily operational
    { 384000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, // just added as a place holder, not necessarily operational
    { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },

    { 384000, 0, 3, FB, 24000, 4, WYXZ, 0, 0,{ { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } },  // just added as a place holder, not necessarily operational
    { 384000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } },  // just added as a place holder, not necessarily operational
    { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },

    { 512000, 0, 1, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 }, {118450, 118450, 128000 } }, // not yet optimized
    { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },

    { 512000, 0, 2, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 97700, 93300, 128000 } }, // not yet optimized
    { 512000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 97700, 93300, 128000 } }, // not yet optimized
    { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },

    { 512000, 0, 3, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 127200, 122550, 128000 },{ 76300, 73550, 128000 } },  // not yet optimized
    { 512000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 127200, 122550, 128000 },{ 76300, 73550, 128000 } },  // not yet optimized
    { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },
};

+5 −5
Original line number Diff line number Diff line
@@ -212,7 +212,7 @@ int16_t ivas_sba_get_analysis_order(
    if ( ivas_total_brate < SBA_MIN_BRATE_HOA )
    {
        /* Hard coding the sba_analysis_order as 1 as higher not supported below SBA_MIN_BRATE_HOA bitrate */
        sba_analysis_order = 1;
        sba_analysis_order = SBA_FOA_ORDER;
    }

    return sba_analysis_order;
@@ -231,15 +231,15 @@ int16_t ivas_sba_get_order_transport(
{
    int16_t sba_order;

    sba_order = 1;
    sba_order = SBA_FOA_ORDER;

    if ( nchan_transport > 6 )
    {
        sba_order = 3;
        sba_order = SBA_HOA3_ORDER;
    }
    else if ( nchan_transport > 4 )
    {
        sba_order = 2;
        sba_order = SBA_HOA2_ORDER;
    }

    return ( sba_order );
@@ -286,7 +286,7 @@ int16_t ivas_sba_get_nchan_metadata(
{
    int16_t nb_channels;

    if ( sba_order == 1 )
    if ( sba_order == SBA_FOA_ORDER )
    {
        nb_channels = FOA_CHANNELS;
    }
+9 −15
Original line number Diff line number Diff line
@@ -1667,8 +1667,8 @@ void ivas_get_spar_md_from_dirac(

    remix_order = remix_order_set[hSpar_md_cfg->remix_unmix_order];

    num_ch = 2 * order + 2;
    hoa2_ch = 6;
    num_ch = ivas_sba_get_nchan_metadata( order );
    hoa2_ch = ivas_sba_get_nchan_metadata( SBA_HOA2_ORDER );
    foa_ch = FOA_CHANNELS;
    diff_norm_order1 = 3.0f;
    diff_norm_order2 = 5.0f;
@@ -1687,6 +1687,7 @@ void ivas_get_spar_md_from_dirac(
    {
        float P_norm[3];
        int16_t idx;

        ndm = hSpar_md_cfg->num_dmx_chans_per_band[start_band - 1];
        P_norm[0] = 0.0f;
        for ( i = 0; i < max( 0, foa_ch - ndm ); i++ )
@@ -1754,7 +1755,7 @@ void ivas_get_spar_md_from_dirac(
                    int16_t num_ch_order, hoa2_ch_order;

                    num_ch_order = ivas_sba_get_nchan( order, 0 );
                    hoa2_ch_order = 9;
                    hoa2_ch_order = ivas_sba_get_nchan( SBA_HOA2_ORDER, 0 );

                    for ( ch = 0; ch < num_ch_order; ch++ )
                    {
@@ -2109,17 +2110,7 @@ void ivas_spar_set_bitrate_config(
    pSpar_md_cfg->agc_bits_ch_idx = ivas_spar_br_table_consts[table_idx].agc_bits_ch_idx;
    ivas_spar_get_uniform_quant_strat( pSpar_md_cfg, table_idx );

    if ( pSpar_md_cfg->quant_strat->C.q_levels[0] == 0 || pSpar_md_cfg->quant_strat->C.q_levels[1] == 0 || pSpar_md_cfg->quant_strat->PR.q_levels[0] == 0 || pSpar_md_cfg->quant_strat->PR.q_levels[1] == 0 || pSpar_md_cfg->quant_strat->P_c.q_levels[0] == 0 || pSpar_md_cfg->quant_strat->P_c.q_levels[1] == 0 || pSpar_md_cfg->quant_strat->P_r.q_levels[0] == 0 || pSpar_md_cfg->quant_strat->P_r.q_levels[1] == 0 )
    {
        pSpar_md_cfg->gen_bs = 0;
    }
    else
    {
        if ( 0 != pSpar_md_cfg->gen_bs )
        {
    pSpar_md_cfg->quant_strat_bits = ivas_get_bits_to_encode( MAX_QUANT_STRATS );
        }
    }

    /* BLOCK: getEntropyCoderModels */

@@ -2138,11 +2129,12 @@ void ivas_spar_set_bitrate_config(
        total_bits += (int16_t) ( ivas_spar_br_table_consts[table_idx].core_brs[i][0] / FRAMES_PER_SEC );
        max_bits += (int16_t) ( ivas_spar_br_table_consts[table_idx].core_brs[i][1] / FRAMES_PER_SEC );
    }
    pSpar_md_cfg->tgt_bits_per_blk = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - SBA_PLANAR_BITS - SBA_ORDER_BITS - length - total_bits;

    pSpar_md_cfg->tgt_bits_per_blk = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - SBA_PLANAR_BITS - SBA_ORDER_BITS - length - total_bits;
    pSpar_md_cfg->max_bits_per_blk = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - SBA_PLANAR_BITS - SBA_ORDER_BITS - length - max_bits;

    md_coding_bits_header = SPAR_NUM_CODING_STRAT_BITS + pSpar_md_cfg->quant_strat_bits;

    pSpar_md_cfg->tgt_bits_per_blk -= md_coding_bits_header;
    pSpar_md_cfg->max_bits_per_blk -= md_coding_bits_header;

@@ -2151,9 +2143,11 @@ 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;

    return;
}


#ifdef FIX_I1_113
/*-----------------------------------------------------------------------------------------*
 * Function ivas_spar_bitrate_dist()
+0 −1
Original line number Diff line number Diff line
@@ -229,7 +229,6 @@ typedef struct ivas_spar_md_com_cfg
    int16_t active_w;
    int16_t remix_unmix_order;
    ivas_quant_strat_t quant_strat[MAX_QUANT_STRATS];
    int16_t gen_bs;
    int16_t quant_strat_bits;
    int16_t nchan_transport;
    int16_t num_quant_strats;
Loading