Commit 06de14fa authored by Louis Liu's avatar Louis Liu
Browse files

Update IVAS SBA 768kbps

parent f471ac60
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -1139,16 +1139,24 @@ typedef enum
{
    MP_SYNTHESISE_BYPASS = 0,
    MP_SYNTHESISE_PANNING_HOA3,
    MP_SYNTHESISE_HOA2,
    MP_SYNTHESISE_HOA3
} MP_Synthesis_Cfg;

#define MP_ORDER2CH( order )                    ( int16_t )( ( ( int16_t )( order ) + 1 ) * ( ( int16_t )( order ) + 1))
#define MP_ORDER2SH( order )                    ( int16_t )( ( ( int16_t )( order ) + 1 ) * ( ( int16_t )( order ) + 1))

#define MP_TRANSPORT_MODE                       0
#define MP_ANALYSIS_MODE                        1

#define MP_FB_MDFT                              0
#define MP_FB_MDCT                              1

#define MP_DELAY_ENC_NS                         1000000L
#define MP_DIRAC_DELAY_CMP_ENC_NS               500000L
#define MP_OVERLAP_5MS_NS                       5000000L

#define MP_CHANNELS_ZOA                         MP_ORDER2CH( SBA_FOA_ORDER - 1 )
#define MP_CHANNELS_FOA                         MP_ORDER2CH( SBA_FOA_ORDER )
#define MP_CHANNELS_HOA2                        MP_ORDER2CH( SBA_HOA2_ORDER )
#define MP_CHANNELS_HOA3                        MP_ORDER2CH( SBA_HOA3_ORDER )
@@ -1159,7 +1167,8 @@ typedef enum
#define MP_VL_NBANDS                            45
#define MP_DELAY_PARAM_DEC_SFR                  1
#define MP_MAX_AVERG_ENERGY_SLOTS               32
#define MP_MAX_GROUP_TRANSPORT_CFG              4
#define MP_MAX_AVERG_DIRS                       10
#define MP_MAX_GROUP_TRANSPORT_CFG              ( 3 * 4 )
#define MP_MAX_GROUP_TRANSPORT                  2

#define MP_MIN_DIRECTIONS                       2
@@ -1179,15 +1188,19 @@ typedef enum

#define MP_NBITS_DIR                            2
#define MP_NBITS_VL                             10
#define MP_NBITS_GAIN                           4
#define MP_NBITS_GAIN                           5

#define MP_DIFF_HUFFMAN_MODE                    0
#define MP_FLC_MODE                             1
#define MP_MIN_Q_GAIN                           -55.f
#define MP_MIN_Q_GAIN                           -75.f
#define MP_DELTA_Q_GAIN                         0.1f
#define MP_MAX_HUFFMAN_BITS                     20
#define MP_Q_GAIN_TABLE_SIZE                    ( 15 + 1 )
#define MP_Q_GAIN_TABLE_SIZE                    ( ( 15 + 1 ) * 2)
#define MP_DIFF_HUFFMAN_SIZE                    ( 2 * MP_Q_GAIN_TABLE_SIZE - 1 )

#define MP_MAX_CHANNELS_DECORR                  4
#define MP_MAX_DECORR_CONFIG                    ( 3 * 4 )
#define MP_FREQ_DECORRELATION_COEFF             ( 0.282094777f )
#endif

/*----------------------------------------------------------------------------------*
+57 −11
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ int16_t ivas_mp_get_transport_channels(
                nchan_transport = MP_ORDER2CH( SBA_HOA2_ORDER );
                break;
            case SBA_HOA3_ORDER:
                nchan_transport = MP_ORDER2CH( SBA_HOA2_ORDER );
                nchan_transport = MP_ORDER2CH( SBA_HOA2_ORDER ) - 1; /* HOA2 -> 2H1V */
                break;
            default:
                break;
@@ -130,6 +130,55 @@ int16_t ivas_mp_get_transport_channels(
    return nchan_transport;
}

int16_t ivas_mp_channel_index_to_sba_order( const int16_t ch_idx )
{
    int16_t order;

    order = 0;
    if ( ch_idx == 0 )
    {
        order = 0;
    }
    else if ( ch_idx > 0 && ch_idx < FOA_CHANNELS )
    {
        order = SBA_FOA_ORDER;
    }
    else if ( ch_idx >= FOA_CHANNELS && ch_idx < MP_ORDER2CH( SBA_HOA2_ORDER ) )
    {
        order = SBA_HOA2_ORDER;
    }
    else if ( ch_idx >= MP_ORDER2CH( SBA_HOA2_ORDER ) )
    {
        order = SBA_HOA3_ORDER;
    }

    return order;
}

int16_t ivas_mp_get_nchan_metadata(
    const int32_t total_bitrate,
    const int16_t sba_order_input,
    const int16_t nchan_transport )
{
    int16_t nchan_metadata;

    nchan_metadata = MP_ORDER2CH( sba_order_input ) - nchan_transport;

    if ( total_bitrate == IVAS_768k )
    {
        if ( sba_order_input == SBA_FOA_ORDER )
        {
            nchan_metadata = 0;
        }
        else
        {
            nchan_metadata = MP_ORDER2CH( sba_order_input ) - nchan_transport;
        }
    }

    return nchan_metadata;
}

int16_t ivas_mp_get_internal_analysis_sba_order(
    const int32_t total_bitrate,
    const int16_t sba_order_input,
@@ -208,10 +257,7 @@ void ivas_mp_config_open(
        }
        else if ( sba_order_input == SBA_HOA3_ORDER )
        {
            if ( hConfig->nchan_transport == 9 )
            {
                mvs2s( ivas_mp_transport_channels_HOA2_table, hConfig->transport_channels_map, MP_MAX_CHANNELS_TRANSPORT );
            }
            mvs2s( ivas_mp_transport_channels_2H1V_table, hConfig->transport_channels_map, MP_MAX_CHANNELS_TRANSPORT );
        }
    }

@@ -226,7 +272,7 @@ void ivas_mp_config_open(

int16_t ivas_mp_metadata_open(
    MP_META_DATA_HANDLE hQMetadata,
    const int16_t nchan_reference_gain,
    const int16_t nchan_metadata,
    const int32_t total_bitrate )
{
    ivas_error error;
@@ -239,15 +285,15 @@ int16_t ivas_mp_metadata_open(

    set_s( hQMetadata->frame_basis_idx, 0, MP_MAX_DIRECTIONS );

    hQMetadata->nchan_reference_gain = nchan_reference_gain;
    hQMetadata->nchan_reference_gain = nchan_metadata;

    if ( nchan_reference_gain > 0 )
    if ( nchan_metadata > 0 )
    {
        if ( ( hQMetadata->q_reference_gain = (int16_t ***) malloc( nchan_reference_gain * sizeof( int16_t ** ) ) ) == NULL )
        if ( ( hQMetadata->q_reference_gain = (int16_t ***) malloc( nchan_metadata * sizeof( int16_t ** ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MP metadata structure!\n" ) );
        }
        for ( ch = 0; ch < nchan_reference_gain; ch++ )
        for ( ch = 0; ch < nchan_metadata; ch++ )
        {
            if ( ( hQMetadata->q_reference_gain[ch] = (int16_t **) malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t * ) ) ) == NULL )
            {
@@ -262,7 +308,7 @@ int16_t ivas_mp_metadata_open(
            }
        }

        for ( ch = 0; ch < nchan_reference_gain; ch++ )
        for ( ch = 0; ch < nchan_metadata; ch++ )
        {
            for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
            {
+77 −39
Original line number Diff line number Diff line
@@ -46,16 +46,16 @@
#include "wmc_auto.h"

#ifdef IVAS_SBA_MP_768KBPS
const int16_t ivas_mp_dirac_band_group_48kHz[MP_MAX_NBANDS + 1] = {
    0, 1, 2, 3, 4, 5, 6, 7, 11, 17, 25, 40, 60
const int16_t ivas_mp_dirac_band_group_16kHz[MP_MAX_NBANDS + 1] = {
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 15, 20
};

const int16_t ivas_mp_dirac_band_group_32kHz[MP_MAX_NBANDS + 1] = {
    0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 17, 25, 40
};

const int16_t ivas_mp_dirac_band_group_16kHz[MP_MAX_NBANDS + 1] = {
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 15, 20
const int16_t ivas_mp_dirac_band_group_48kHz[MP_MAX_NBANDS + 1] = {
    0, 1, 2, 3, 4, 5, 6, 7, 11, 17, 25, 40, 60
};

const int16_t ivas_mp_direction_component_mask_table[MP_CHANNELS_HOA3] = {
@@ -75,6 +75,10 @@ const int16_t ivas_mp_transport_channels_HOA2_table[MP_MAX_CHANNELS_TRANSPORT] =
    0, 1, 2, 3, 4, 5, 6, 7, 8
};

const int16_t ivas_mp_transport_channels_2H1V_table[MP_MAX_CHANNELS_TRANSPORT] = {
    0, 1, 2, 3, 4, 5, 7, 8
};

const int16_t ivas_mp_vl_sfb[MP_VL_NBANDS] = {
    0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, 80,
    88, 96, 108, 120, 132, 144, 164, 184, 204, 226, 248, 270, 292,
@@ -82,48 +86,82 @@ const int16_t ivas_mp_vl_sfb[MP_VL_NBANDS] = {
    704, 800, 960
};

const MP_DECORR_CONFIG ivas_mp_decorrelation_cfg_table[MP_MAX_DECORR_CONFIG] = {
    { SBA_HOA3_ORDER, IVAS_768k, 2, { 9, 15 }, 8 },
};

const MP_TCS_DMX_CONFIG ivas_mp_TCs_dmx_cfg_table[MP_MAX_GROUP_TRANSPORT_CFG] = {
    { SBA_FOA_ORDER, IVAS_768k, 4, 1, { 4, 0 }, { { 0, 1, 2, 3 } }, 208000, { 1.f, 0.f } },
    { SBA_HOA2_ORDER, IVAS_768k, 9, 2, { 4, 5 }, { { 0, 1, 2, 3 }, { 4, 5, 6, 7 } }, 116000, { 0.55f, 0.45f } },
    { SBA_HOA3_ORDER, IVAS_768k, 9, 2, { 4, 5 }, { { 0, 1, 2, 3 }, { 4, 5, 6, 7 } }, 112000, { 0.575f, 0.425f } }
    { SBA_FOA_ORDER, IVAS_768k, 4, 1, { 4, 0 }, 208000, { 1.f, 0.f } },
    { SBA_HOA2_ORDER, IVAS_768k, 9, 2, { 4, 5 }, 116000, { 0.55f, 0.45f } },
    { SBA_HOA3_ORDER, IVAS_768k, 8, 2, { 4, 4 }, 112000, { 0.625f, 0.375f } },
};

const int16_t ivas_mp_q_gain_table[MP_Q_GAIN_TABLE_SIZE] = {
    -55, -45, -40, -35, -30, -25, -22, -19, -16, -13, -10, -6, -4, -2, 0, 2
    ( (int16_t) ( MP_MIN_Q_GAIN ) ), -65, -55, -50, -45, -40, -35, -30, -28, -26, -24, -22, -20, -18, -16, -14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, 14, 17, 20 // 2.383918403484545
};

const Huffman_codebook ivas_diff_huffman_codebook_table[MP_Q_GAIN_TABLE_SIZE * 2 - 1] = {
    { 0, 1, 1 },         /* 1 */
    { 1, 3, 3 },         /* 011 */
    { -1, 0, 2 },        /* 00 */
    { -2, 4, 4 },        /* 0100 */
    { 2, 11, 5 },        /* 01011 */
    { -3, 20, 6 },       /* 010100 */
    { -4, 171, 9 },      /* 010101011 */
    { 3, 43, 7 },        /* 0101011 */
    { 4, 84, 8 },        /* 01010100 */
    { -5, 683, 11 },     /* 01010101011 */
    { 5, 340, 10 },      /* 0101010100 */
    { 6, 2731, 13 },     /* 0101010101011 */
    { 7, 5457, 14 },     /* 01010101010001 */
    { -6, 2730, 13 },    /* 0101010101010 */
    { -7, 10917, 15 },   /* 010101010100101 */
    { -8, 43673, 17 },   /* 01010101010011001 */
    { 9, 21839, 16 },    /* 0101010101001111 */
    { 8, 10916, 15 },    /* 010101010100100 */
    { 10, 10912, 15 },   /* 010101010100000 */
    { -9, 87349, 18 },   /* 010101010100110101 */
    { -10, 43652, 17 },  /* 01010101010000100 */
    { 12, 43675, 17 },   /* 01010101010011011 */
    { 14, 21838, 16 },   /* 0101010101001110 */
    { 11, 21827, 16 },   /* 0101010101000011 */
    { 15, 87307, 18 },   /* 010101010100001011 */
    { 13, 43672, 17 },   /* 01010101010011000 */
    { -12, 174612, 19 }, /* 0101010101000010100 */
    { -15, 174613, 19 }, /* 0101010101000010101 */
    { -13, 349392, 20 }, /* 01010101010011010000 */
    { -14, 349393, 20 }, /* 01010101010011010001 */
    { -11, 174697, 19 }  /* 0101010101001101001 */
    { 0, 1, 1 },          /* 0 -> 1 */
    { -1, 1, 2 },         /* 10 -> 01 */
    { 1, 0, 3 },          /* 111 -> 000 */
    { -2, 4, 5 },         /* 11011 -> 00100 */
    { 2, 5, 5 },          /* 11010 -> 00101 */
    { -3, 12, 6 },        /* 110011 -> 001100 */
    { 3, 13, 6 },         /* 110010 -> 001101 */
    { -4, 15, 6 },        /* 110000 -> 001111 */
    { 4, 28, 7 },         /* 1100011 -> 0011100 */
    { -5, 117, 9 },       /* 110001010 -> 001110101 */
    { 5, 116, 9 },        /* 110001011 -> 001110100 */
    { -6, 237, 10 },      /* 1100010010 -> 0011101101 */
    { -8, 1906, 13 },     /* 1100010001101 -> 0011101110010 */
    { 6, 236, 10 },       /* 1100010011 -> 0011101100 */
    { 8, 1904, 13 },      /* 1100010001111 -> 0011101110000 */
    { 7, 477, 11 },       /* 11000100010 -> 00111011101 */
    { -7, 479, 11 },      /* 11000100000 -> 00111011111 */
    { 9, 1915, 13 },      /* 1100010000100 -> 0011101111011 */
    { -9, 3824, 14 },     /* 11000100001111 -> 00111011110000 */
    { 22, 3811, 14 },     /* 11000100011100 -> 00111011100011 */
    { 10, 3825, 14 },     /* 11000100001110 -> 00111011110001 */
    { 14, 15256, 16 },    /* 1100010001100111 -> 0011101110011000 */
    { 21, 30632, 17 },    /* 11000100001010111 -> 00111011110101000 */
    { -22, 3827, 14 },    /* 11000100001100 -> 00111011110011 */
    { -11, 7656, 15 },    /* 110001000010111 -> 001110111101000 */
    { -10, 7629, 15 },    /* 110001000110010 -> 001110111001101 */
    { -21, 61231, 18 },   /* 110001000011010000 -> 001110111100101111 */
    { 11, 7621, 15 },     /* 110001000111010 -> 001110111000101 */
    { 12, 7652, 15 },     /* 110001000011011 -> 001110111100100 */
    { 13, 7659, 15 },     /* 110001000010100 -> 001110111101011 */
    { 16, 15314, 16 },    /* 1100010000101101 -> 0011101111010010 */
    { 19, 15261, 16 },    /* 1100010001100010 -> 0011101110011101 */
    { 18, 15257, 16 },    /* 1100010001100110 -> 0011101110011001 */
    { -12, 15240, 16 },   /* 1100010001110111 -> 0011101110001000 */
    { -15, 30483, 17 },   /* 11000100011101100 -> 00111011100010011 */
    { -14, 15317, 16 },   /* 1100010000101010 -> 0011101111010101 */
    { -13, 15263, 16 },   /* 1100010001100000 -> 0011101110011111 */
    { 17, 15306, 16 },    /* 1100010000110101 -> 0011101111001010 */
    { 15, 15262, 16 },    /* 1100010001100001 -> 0011101110011110 */
    { 20, 15315, 16 },    /* 1100010000101100 -> 0011101111010011 */
    { -16, 30520, 17 },   /* 11000100011000111 -> 00111011100111000 */
    { -17, 60964, 18 },   /* 110001000111011011 -> 001110111000100100 */
    { -19, 30633, 17 },   /* 11000100001010110 -> 00111011110101001 */
    { -20, 30614, 17 },   /* 11000100001101001 -> 00111011110010110 */
    { -18, 60965, 18 },   /* 110001000111011010 -> 001110111000100101 */
    { -29, 244172, 20 },  /* 11000100011000110011 -> 00111011100111001100 */
    { -31, 61230, 18 },   /* 110001000011010001 -> 001110111100101110 */
    { 31, 61042, 18 },    /* 110001000110001101 -> 001110111001110010 */
    { 30, 976700, 22 },   /* 1100010001100011000011 -> 0011101110011100111100 */
    { 28, 976701, 22 },   /* 1100010001100011000010 -> 0011101110011100111101 */
    { -25, 488349, 21 },  /* 110001000110001100010 -> 001110111001110011101 */
    { -26, 3906770, 24 }, /* 110001000110001100101101 -> 001110111001110011010010 */
    { -30, 976702, 22 },  /* 1100010001100011000001 -> 0011101110011100111110 */
    { -27, 976703, 22 },  /* 1100010001100011000000 -> 0011101110011100111111 */
    { 23, 488348, 21 },   /* 110001000110001100011 -> 001110111001110011100 */
    { 25, 1953384, 23 },  /* 11000100011000110010111 -> 00111011100111001101000 */
    { 26, 1953390, 23 },  /* 11000100011000110010001 -> 00111011100111001101110 */
    { -28, 976693, 22 },  /* 1100010001100011001010 -> 0011101110011100110101 */
    { 24, 3906771, 24 },  /* 110001000110001100101100 -> 001110111001110011010011 */
    { -23, 976694, 22 },  /* 1100010001100011001001 -> 0011101110011100110110 */
    { -24, 1953391, 23 }, /* 11000100011000110010000 -> 00111011100111001101111 */
};

const float ivas_mp_basis_matrix_R1[MP_MAX_NB_COEFFS][MP_COLS_R1] = {
+10 −1
Original line number Diff line number Diff line
@@ -4544,6 +4544,15 @@ int16_t ivas_mp_get_transport_channels(
    const int16_t sba_order_input
);

int16_t ivas_mp_channel_index_to_sba_order(
    const int16_t ch_idx
);

int16_t ivas_mp_get_nchan_metadata(
    const int32_t total_bitrate,
    const int16_t sba_order_input,
    const int16_t nchan_transport );

int16_t ivas_mp_get_internal_analysis_sba_order(
    const int32_t total_bitrate,
    const int16_t sba_order_input,
@@ -4560,7 +4569,7 @@ void ivas_mp_config_open(

int16_t ivas_mp_metadata_open(
    MP_META_DATA_HANDLE hQMetadata,
    const int16_t nchan_reference_gain,
    const int16_t nchan_metadata,
    const int32_t total_bitrate 
);

+4 −2
Original line number Diff line number Diff line
@@ -196,16 +196,18 @@ extern const int16_t ivas_pca_offset_index2[2692];
extern const int16_t ivas_pca_offset_n2[IVAS_PCA_N1];

#ifdef IVAS_SBA_MP_768KBPS
extern const int16_t ivas_mp_dirac_band_group_48kHz[MP_MAX_NBANDS + 1];
extern const int16_t ivas_mp_dirac_band_group_32kHz[MP_MAX_NBANDS + 1];
extern const int16_t ivas_mp_dirac_band_group_16kHz[MP_MAX_NBANDS + 1];
extern const int16_t ivas_mp_dirac_band_group_32kHz[MP_MAX_NBANDS + 1];
extern const int16_t ivas_mp_dirac_band_group_48kHz[MP_MAX_NBANDS + 1];
extern const int16_t ivas_mp_direction_component_mask_table[MP_CHANNELS_HOA3];

/* Transport channels configuration */
extern const int16_t ivas_mp_transport_channels_FOA_table[MP_MAX_CHANNELS_TRANSPORT];
extern const int16_t ivas_mp_transport_channels_HOA2_table[MP_MAX_CHANNELS_TRANSPORT];
extern const int16_t ivas_mp_transport_channels_2H1V_table[MP_MAX_CHANNELS_TRANSPORT];

extern const int16_t ivas_mp_vl_sfb[MP_VL_NBANDS];
extern const MP_DECORR_CONFIG ivas_mp_decorrelation_cfg_table[MP_MAX_DECORR_CONFIG];
extern const MP_TCS_DMX_CONFIG ivas_mp_TCs_dmx_cfg_table[MP_MAX_GROUP_TRANSPORT_CFG];

/* Huffman coding */
Loading