Commit 794bda24 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'enc_sat_fixes_basop_instrumentation_changes' into 'main'

Partial fix for Encoder saturating when copying vectors and q-doc, basops and instrumentation

See merge request !1055
parents c374ed75 057d940a
Loading
Loading
Loading
Loading
Loading
+0 −57
Original line number Diff line number Diff line
@@ -83,12 +83,6 @@ ivas_error create_sce_enc(
    const int32_t element_brate                                 /* i  : element bitrate                         */
);

ivas_error create_evs_sce_enc(
    Encoder_Struct *st_ivas,    /* i/o: IVAS encoder structure      */
    const int16_t sce_id,       /* i  : SCE # identifier            */
    const int32_t element_brate /* i  : element bitrate             */
);

ivas_error create_cpe_enc(
    Encoder_Struct *st_ivas,                                    /* i/o: IVAS encoder structure                  */
    const int16_t cpe_id,                                       /* i  : CPE # identifier                        */
@@ -99,15 +93,6 @@ ivas_error create_mct_enc_fx(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder structure                  */
);

ivas_error ivas_sba_enc_reconfigure(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder structure                  */
);

void destroy_sce_enc(
    SCE_ENC_HANDLE hSCE,                                        /* i/o: SCE encoder structure                   */
    Flag is_evs                                                 /* i  : Flag to indicate EVS encoder            */  
);

void destroy_cpe_enc(
    CPE_ENC_HANDLE hCPE                                         /* i/o: CPE encoder structure                   */
);
@@ -1215,41 +1200,6 @@ void add_HB_to_mono_dmx(
 * Range Coder prototypes
 *----------------------------------------------------------------------------------*/

void rc_uni_enc_init(
    RangeUniEncState *rc_st_enc                                 /* i/o: RC state handle                     */
);

void rc_uni_enc_encode_fast(
    RangeUniEncState *rc_st_enc,                                /* i/o: RC state handle                     */
    const uint16_t cum_freq,                                    /* i  : Cumulative frequency up to symbol   */
    const uint16_t sym_freq,                                    /* i  : Symbol frequency                    */
    const uint16_t tot_shift                                    /* i  : Total frequency as a power of 2     */
);

void rc_uni_enc_encode_symbol_fastS(
    RangeUniEncState *rc_st_enc,                                /* i/o: Encoder state                       */
    const uint16_t symbol,                                      /* i  : Symbol to encode                    */
    const uint16_t cum_freq[],                                  /* i  : Cumulative frequency up to symbol   */
    const uint16_t sym_freq[],                                  /* i  : Symbol frequency                    */
    const uint16_t tot_shift                                    /* i  : Total frequency as a power of 2     */
);

void rc_uni_enc_encode_bits(
    RangeUniEncState *rc_st_enc,                                /* i/o: RC state handle                     */
    const uint16_t value,                                       /* i  : Value to encode                     */
    const int16_t bits                                          /* i  : Number of bits                      */
);

/*! r: Total number of bits produced */
int16_t rc_uni_enc_virtual_finish(
    RangeUniEncState *rc_st_enc                                 /* i  : RC state handle                     */
);

/*! r: Total number of bits produced */
int16_t rc_uni_enc_finish(
    RangeUniEncState *rc_st_enc                                 /* i/o: RC state handle                     */
);

void rc_uni_dec_init(
    RangeUniDecState *rc_st_dec,                                /* i/o: RC state handle                     */
    uint16_t *bit_buffer,                                       /* i  : Bit buffer                          */
@@ -1403,13 +1353,6 @@ void stereo_icBWE_decproc(
 * Stereo classifiers prototypes
 *----------------------------------------------------------------------------------*/

/*! r: element mode */
int16_t select_stereo_mode(
    CPE_ENC_HANDLE hCPE,                                        /* i/o: CPE encoder structure                           */
    const IVAS_FORMAT ivas_format                               /* i  : IVAS format                                     */
);


void stereo_classifier_features(
    STEREO_CLASSIF_HANDLE hStereoClassif,                       /* i/o: stereo classifier structure                     */
    const int16_t idchan,                                       /* i  : channel ID                                      */
+32 −11
Original line number Diff line number Diff line
@@ -53,6 +53,17 @@ void ivas_masa_dec_close_fx(
    MASA_DECODER_HANDLE *hMasa /* i/o: MASA metadata structure                         */
);

ivas_error create_evs_sce_enc_fx(
    Encoder_Struct *st_ivas,   /* i/o: IVAS encoder structure      */
    const Word16 sce_id,       /* i  : SCE # identifier            */
    const Word32 element_brate /* i  : element bitrate             */
);

void destroy_sce_enc_fx(
    SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure                   */
    Flag is_evs          /* i  : Flag to indicate EVS encoder            */
);

void generate_gridEq_fx(
    SPHERICAL_GRID_DATA *data /* o  : data structure for grid  */
);
@@ -2801,18 +2812,18 @@ Word16 mdct_classifier_ivas_fx(
 * Range Coder prototypes
 *----------------------------------------------------------------------------------*/

void rc_uni_enc_init(
void rc_uni_enc_init_fx(
    RangeUniEncState *rc_st_enc /* i/o: RC state handle                     */
);

void rc_uni_enc_encode_fast(
void rc_uni_enc_encode_fast_fx(
    RangeUniEncState *rc_st_enc, /* i/o: RC state handle                     */
    const UWord16 cum_freq,      /* i  : Cumulative frequency up to symbol   */
    const UWord16 sym_freq,      /* i  : Symbol frequency                    */
    const UWord16 tot_shift      /* i  : Total frequency as a power of 2     */
);

void rc_uni_enc_encode_symbol_fastS(
void rc_uni_enc_encode_symbol_fastS_fx(
    RangeUniEncState *rc_st_enc, /* i/o: Encoder state                       */
    const UWord16 symbol,        /* i  : Symbol to encode                    */
    const UWord16 cum_freq[],    /* i  : Cumulative frequency up to symbol   */
@@ -2821,16 +2832,16 @@ void rc_uni_enc_encode_symbol_fastS(
);

/*! r: Total number of bits produced */
Word16 rc_uni_enc_finish(
Word16 rc_uni_enc_finish_fx(
    RangeUniEncState *rc_st_enc /* i/o: RC state handle                     */
);

/*! r: Total number of bits produced */
Word16 rc_uni_enc_virtual_finish(
Word16 rc_uni_enc_virtual_finish_fx(
    RangeUniEncState *rc_st_enc /* i  : RC state handle                     */
);

void rc_uni_enc_encode_bits(
void rc_uni_enc_encode_bits_fx(
    RangeUniEncState *rc_st_enc, /* i/o: RC state handle                     */
    const UWord16 value,         /* i  : Value to encode                     */
    const Word16 bits            /* i  : Number of bits                      */
@@ -3097,6 +3108,12 @@ void ivas_smc_mode_selection_fx(
    const Word16 flag_spitch    /* i  : flag to indicate very short stable pitch*/
);

/*! r: element mode */
Word16 select_stereo_mode_fx(
    CPE_ENC_HANDLE hCPE,          /* i/o: CPE encoder structure                           */
    const IVAS_FORMAT ivas_format /* i  : IVAS format                                     */
);

void stereo_classifier_features_ivas_fx(
    STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure                     */
    const Word16 idchan,                  /* i  : channel ID                                      */
@@ -4278,7 +4295,7 @@ void stereo_dft_dec_read_BS_fx(
    const Word16 ivas_format               /* i  : ivas format				Q0*/
);

Word16 write_bitstream_adapt_GR(
Word16 write_bitstream_adapt_GR_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle                    */
    const Word16 ind,      /* i  : bitstream index                             */
    const Word16 *in,      /* i  : values to be written in bitstream           */
@@ -4304,7 +4321,7 @@ Word16 adapt_GR_ief_fx(
    const Word16 try_diff           /*  i  : diff coding allowed 1/0                          */
);

Word16 adapt_GR_rpg1_ief(
Word16 adapt_GR_rpg1_ief_fx(
    const Word16 *in,       /*  i  : res pred gains input vector                       */
    Word16 *in_diff,        /*  o  : encoded symbols in case of differential encoding  */
    const Word16 *prev,     /*  i  : previous frame data                               */
@@ -4318,14 +4335,14 @@ Word16 adapt_GR_rpg1_ief(
    const Word16 try_diff   /*  i  : diff coding allowed 1/0                           */
);

Word16 write_GR1(
Word16 write_GR1_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle    */
    const Word16 ind,      /* i  : bitstream index             */
    const Word16 *in,      /* i  : data to be encoded          */
    const Word16 len       /* i  : input data length           */
);

Word16 write_bitstream_GR(
Word16 write_bitstream_GR_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
    const Word16 ind,      /* i  : bitstream index          */
    const Word16 *in,      /* i  : input vector             */
@@ -4757,7 +4774,7 @@ void stereo_mdct2dft_update_fx(
    Word32 synth0_fx[]   /* i/o: synthesis @output Fs, ch0    Q11*/
);

Word16 write_GR0(
Word16 write_GR0_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle    */
    const Word16 ind,      /* i  : bitstream index             */
    const Word16 *in,      /* i  : data to be encoded          */
@@ -4856,6 +4873,10 @@ ivas_error ivas_cldfb_dec_reconfig_fx(
    const Word16 numCldfbSyntheses_old /* i  : number of CLDFB synthesis instances in previous frame */
);

ivas_error ivas_sba_enc_reconfigure_fx(
    Encoder_Struct *st_ivas /* i/o: IVAS encoder structure                  */
);

Word16 ivas_sba_get_order_fx(
    const Word16 nb_channels, /* i  : Number of ambisonic channels            */
    const Word16 sba_planar   /* i  : SBA planar flag                         */
+5 −0
Original line number Diff line number Diff line
@@ -218,6 +218,11 @@ Word32 sum2_fx( /* o : sum of all squared vector elements
                const Word16 lvec  /* i  : length of i   vector                */
);
Word64 sum2_fx_no_sat(                    /* o  : sum of all squared vector elements    Q(2x)*/
                       const Word16 *vec, /* i  : i   vector                          Qx*/
                       const Word16 lvec  /* i  : length of i   vector                */
);
Word16 sign_fx(
    const Word32 x /* i  : input value of x                                */
);
+18 −0
Original line number Diff line number Diff line
@@ -401,6 +401,24 @@ Word32 sum2_fx( /* o : sum of all squared vector elements
    return L_tmp;
}

Word64 sum2_fx_no_sat(                    /* o  : sum of all squared vector elements    Q(2*Qx)*/
                       const Word16 *vec, /* i  : input vector                          Qx*/
                       const Word16 lvec  /* i  : length of input vector                */
)
{
    Word16 i;
    Word64 sum;

    sum = 0;
    move64();
    FOR( i = 0; i < lvec; i++ )
    {
        sum = W_mac0_16_16( sum, vec[i], vec[i] ); // 2*Qx
    }

    return sum;
}

Word32 sum_32_fx(
    const Word32 *vec, /* i  : input vector                          */
    const Word16 lvec, /* i  : length of input vector                */
+10 −9
Original line number Diff line number Diff line
@@ -841,7 +841,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(

        /*Start Encoding*/
        /* Initialize range encoder */
        rc_uni_enc_init( &rc_st_enc );
        rc_uni_enc_init_fx( &rc_st_enc );

        /*Main Loop through the 2-tuples*/
        b1_i = -1;
@@ -909,7 +909,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
            {
                pki = ari_lookup_s17_LC[t + ( ( lev1 + 1 ) << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
                move16();
                rc_uni_enc_encode_symbol_fastS( &rc_st_enc, VAL_ESC, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode ESC symbol */
                rc_uni_enc_encode_symbol_fastS_fx( &rc_st_enc, VAL_ESC, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode ESC symbol */

                *lsbs_bits-- = s_and( a1, 1 );
                *lsbs_bits-- = s_and( b1, 1 );
@@ -927,7 +927,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(

            pki = ari_lookup_s17_LC[t + ( ( lev1 + 1 ) << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
            move16();
            rc_uni_enc_encode_symbol_fastS( &rc_st_enc, a1 + A_THRES * b1, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode MSB symbol */
            rc_uni_enc_encode_symbol_fastS_fx( &rc_st_enc, a1 + A_THRES * b1, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode MSB symbol */

            /*Confirm that there is no overflow, i.e. bit-budget has not exceeded */

@@ -1009,7 +1009,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(

        /*Start Encoding*/
        /* Initialize range encoder */
        rc_uni_enc_init( &rc_st_enc );
        rc_uni_enc_init_fx( &rc_st_enc );

        /*Main Loop through the 2-tuples*/
        FOR( k = 0; k < lastnz; k += 2 )
@@ -1064,7 +1064,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
            {
                pki = ari_lookup_s17_LC[t + ( ( rateQ ) << NBITS_CONTEXT ) + ( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )];
                move16();
                rc_uni_enc_encode_symbol_fastS( &rc_st_enc, VAL_ESC, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode ESC symbol */
                rc_uni_enc_encode_symbol_fastS_fx( &rc_st_enc, VAL_ESC, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode ESC symbol */

                *lsbs_bits-- = s_and( a1, 1 );
                *lsbs_bits-- = s_and( b1, 1 );
@@ -1082,8 +1082,9 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
            }

            move16();

            pki = ari_lookup_s17_LC[t + ( ( rateQ ) << NBITS_CONTEXT ) + ( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )];                              /* Q0 */
            rc_uni_enc_encode_symbol_fastS( &rc_st_enc, a1 + A_THRES * b1, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode MSB symbol */
            rc_uni_enc_encode_symbol_fastS_fx( &rc_st_enc, a1 + A_THRES * b1, cum_freq_ari_pk_s17_LC_ext[pki], sym_freq_ari_pk_s17_LC_ext[pki], 14 ); /* Encode MSB symbol */

            /*Confirm that there is no overflow, i.e. bit-budget has not exceeded */

@@ -1105,7 +1106,7 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx(
    }

    /* Finish range encoder */
    rc_tot_bits = rc_uni_enc_finish( &rc_st_enc ); /* No. of bits consumed by range coder	Q0*/
    rc_tot_bits = rc_uni_enc_finish_fx( &rc_st_enc ); /* No. of bits consumed by range coder	Q0*/
    bp = add( rc_tot_bits, nbbits_ntuples );          /* Update bitstream pointer	Q0*/

    /* Cross-check that there is no overflow */
Loading