Commit 1f7ede43 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Fix for new stream shared

parent fb5f45af
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -9969,6 +9969,12 @@ Word16 usdequant_fx( /* Qx*/
                     const Word16 delta /* i: quantization step Qy*/
);
Word32 usdequant32_fx(                    /* Qx*/
                     const Word16 idx,  /* i: quantizer index Q0*/
                     const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/
                     const Word32 delta /* i: quantization step Qy*/
);
Word16 usquant_fx(                     /* o: index of the winning codeword   */
                   const Word16 x,     /* i: scalar value to quantize        Qx*/
                   Word16 *xq,         /* o: quantized value                 Qx*/
+24 −0
Original line number Diff line number Diff line
@@ -284,6 +284,30 @@ Word16 usdequant_fx( /* Qx*/
    return ( g );
}

Word32 usdequant32_fx(                    /* Qx*/
                       const Word16 idx,  /* i: quantizer index Q0*/
                       const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/
                       const Word32 delta /* i: quantization step Qx-1*/
)
{
    Word32 g;
    Word64 L_tmp;

    /*g = idx * delta + qlow;*/
    L_tmp = W_deposit32_l( qlow ); /*Qx */
    L_tmp = W_mac_32_16( L_tmp, delta, idx );
    IF( GE_64( L_tmp, MAX_32 ) )
    {
        g = MAX_32;
        move32();
    }
    ELSE
    {
        g = W_extract_l(L_tmp); /*Qx */
    }
    return ( g );
}

/*-------------------------------------------------------------------*
 * usquant()
 *
+16 −9
Original line number Diff line number Diff line
@@ -72,8 +72,7 @@ static Word16 read_coherence_data_fx( UWord16 *bitstream, Word16 *p_bit_pos, IVA
static Word16 ivas_qmetadata_raw_decode_dir_512_fx( IVAS_QDIRECTION *q_direction, UWord16 *bitstream, Word16 *index, const Word16 nbands, const Word16 start_band, const SPHERICAL_GRID_DATA *sph_grid16 );
static Word16 read_surround_coherence( UWord16 *bitstream, Word16 *p_bit_pos, IVAS_QMETADATA *hQMetaData );
static ivas_error read_huf( Word16 *num_bits_read, const UWord16 *bitstream, UWord16 *out, const Word16 start_pos, const Word16 len, const Word16 *huff_code, const Word16 max_len );
const Word16 inv_dfRatio_qsteps[9] = { 0, 0, ONE_IN_Q14, 0, 5461, 0, 0, 0, 2341 }; // Q14

const Word32 inv_dfRatio_qsteps[9] = { 0, 0, ONE_IN_Q30, 0, 357913941, 0, 0, 0, 153391689 }; // Q30

/*-----------------------------------------------------------------------*
 * Global function definitions
@@ -223,7 +222,7 @@ Word16 ivas_qmetadata_dec_decode(
            IF( EQ_16( hQMetaData->twoDirBands[b], 1 ) )
            {
                Word32 diffRatio_fx, dir1ratio_fx, dir2ratio_fx;
                Word16 dfRatio_fx;
                Word32 dfRatio_fx;
                Word16 dfRatio_qsteps;

                diffRatio_fx = diffuseness_reconstructions_fx[hQMetaData->q_direction[0].band_data[b].energy_ratio_index[0]]; // Q30
@@ -233,16 +232,24 @@ Word16 ivas_qmetadata_dec_decode(
                /* already encoded as total and ratios in HO-DirAC */
                IF( hodirac_flag )
                {

                    dfRatio_fx = usdequant_fx( hQMetaData->q_direction[1].band_data[dir2band].energy_ratio_index[0], 0 /* Q15 */, inv_dfRatio_qsteps[dfRatio_qsteps] ); // Q15
                    dfRatio_fx = usdequant32_fx( hQMetaData->q_direction[1].band_data[dir2band].energy_ratio_index[0], 0 /* Q15 */, inv_dfRatio_qsteps[dfRatio_qsteps] ); // Q31
                    dir1ratio_fx = L_sub( ONE_IN_Q30, diffRatio_fx );
                    dir2ratio_fx = L_shl( (Word32) dfRatio_fx, Q15 ); /*Q30*/
                    dir2ratio_fx = L_shr( dfRatio_fx, 1 ); /*Q30*/
                }
                ELSE
                {
                    IF( EQ_16( hQMetaData->q_direction[1].band_data[dir2band].energy_ratio_index[0], sub( dfRatio_qsteps, 1 ) ) )
                    {
                        dfRatio_fx = MAX_32; // Q31
                        move16();
                        dir1ratio_fx = L_sub( ONE_IN_Q30, diffRatio_fx ); // Q30
                    }
                    ELSE
                    {
                    dfRatio_fx = usdequant_fx( hQMetaData->q_direction[1].band_data[dir2band].energy_ratio_index[0], shr( MAX_16, 1 ), shr( inv_dfRatio_qsteps[dfRatio_qsteps], 1 ) ); // Q15
                        dfRatio_fx = usdequant32_fx( hQMetaData->q_direction[1].band_data[dir2band].energy_ratio_index[0], L_shr( MAX_32, 1 ), L_shr( inv_dfRatio_qsteps[dfRatio_qsteps], 1 ) ); // Q31
                        dir1ratio_fx = Mpy_32_32( L_sub( ONE_IN_Q30, diffRatio_fx ), dfRatio_fx );                                                                                               // Q30
                    }

                    dir1ratio_fx = Mpy_32_16_1( L_sub( ONE_IN_Q30, diffRatio_fx ), dfRatio_fx ); // Q30
                    dir2ratio_fx = L_sub( L_sub( ONE_IN_Q30, diffRatio_fx ), dir1ratio_fx ); // Q30
                }