Commit 625b3c7c authored by JÜRGEN Gerstacker's avatar JÜRGEN Gerstacker
Browse files

Merge branch 'basop-2402-simplification-of-arithmetic-codec-subfunctions-2' of...

Merge branch 'basop-2402-simplification-of-arithmetic-codec-subfunctions-2' of https://forge.3gpp.org/rep/sa4/audio/ivas-basop into basop-2402-simplification-of-arithmetic-codec-subfunctions-2
parents 3fd21166 6efe762a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -66,19 +66,29 @@ Word16 ari_start_decoding_14bits_prm_fx(
    const Word16 *p;

    val = L_deposit_l( 0 );
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC
    s->low = val;
    move32();
#endif

    p = ptr + bp; /* Q0 */

    FOR( i = 0; i < cbitsnew; i++ )
    {
        val = L_shl( val, 1 );
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC
        if ( *( p + i ) != 0 )
#else
        IF( *( p + i ) )
#endif
        {
            val = L_add( val, 1 );
        }
    }
#ifndef FIX_2402_REPL_EVS_ARI_CODEC_DEC
    s->low = L_deposit_l( 0 );
    move32();
#endif
    s->high = L_add( ari_q4new, 1 );
    move32();
    s->value = val;
+66 −55
Original line number Diff line number Diff line
@@ -68,10 +68,11 @@ static Word16 quant_ctx_fx(
static Word16 arith_decode_bits_fx(
    IGFSCFDEC_INSTANCE_HANDLE hPrivateData, /* i/o: instance handle */
    Decoder_State *st,                      /* i/o: pointer to bitstream decoder state */
    Word16 nBits                            /* i  : number of bits to decode */
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
    ,
    Word16 nBits, /* i  : number of bits to decode */
    Word16 *extra_bits_read
#else
    Word16 nBits /* i  : number of bits to decode */
#endif
)
{
@@ -105,10 +106,11 @@ static Word16 arith_decode_residual_fx(
    IGFSCFDEC_INSTANCE_HANDLE hPrivateData,  /* i/o: instance handle */
    Decoder_State *st,                       /* i/o: pointer to decoder state */
    const UWord16 *cumulativeFrequencyTable, /* i  : cumulative frequency table to be used Q0 */
    Word16 tableOffset                       /* i  : offset used to align the table */
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
    ,
    Word16 tableOffset, /* i  : offset used to align the table */
    Word16 *extra_bits_read
#else
    Word16 tableOffset /* i  : offset used to align the table */
#endif
)
{
@@ -139,30 +141,27 @@ static Word16 arith_decode_residual_fx(

    /* decode one of the tails of the distribution */
    /* decode extra with 4 bits */
    extra = arith_decode_bits_fx( hPrivateData, st, 4
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                                  ,
                                  extra_bits_read
    extra = arith_decode_bits_fx( hPrivateData, st, 4, extra_bits_read ); // Q0
#else
    extra = arith_decode_bits_fx( hPrivateData, st, 4 ); // Q0
#endif
    );                       // Q0
    IF( EQ_16( extra, 15 ) ) /* escape code 15 to indicate extra >= 15 */
    {
        /* decode addtional extra with 6 bits */
        extra = arith_decode_bits_fx( hPrivateData, st, 6
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                                      ,
                                      extra_bits_read
        extra = arith_decode_bits_fx( hPrivateData, st, 6, extra_bits_read ); // Q0
#else
        extra = arith_decode_bits_fx( hPrivateData, st, 6 ); // Q0
#endif
        );                       // Q0
        IF( EQ_16( extra, 63 ) ) /* escape code 63 to indicate extra >= 63 */
        {
            /* decode safety extra with 7 bits */
            extra = arith_decode_bits_fx( hPrivateData, st, 7
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                                          ,
                                          extra_bits_read
            extra = arith_decode_bits_fx( hPrivateData, st, 7, extra_bits_read ); // Q0
#else
            extra = arith_decode_bits_fx( hPrivateData, st, 7 ); // Q0
#endif
            ); // Q0
            extra = add( 63, extra );
        }
        extra = add( 15, extra ); // Q0
@@ -185,10 +184,11 @@ static Word16 arith_decode_residual_fx(
}

static void arith_decode_flush_fx(
    Decoder_State *st /* i/o: pointer to decoder state */
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
    ,
    Decoder_State *st, /* i/o: pointer to decoder state */
    Word16 *extra_bits_read
#else
    Decoder_State *st /* i/o: pointer to decoder state */
#endif
)
{
@@ -210,10 +210,11 @@ static void decode_sfe_vector_fx(
    Word16 t,                               /* i  : counter reset to 0 at each independent block */
    Word16 *prev_x,                         /* i  : previous vector */
    Word16 *x,                              /* o  : current vector to decode */
    Word16 length                           /* i  : number of elements to decode */
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
    ,
    Word16 length, /* i  : number of elements to decode */
    Word16 *extra_bits_read
#else
    Word16 length /* i  : number of elements to decode */
#endif
)
{
@@ -249,27 +250,30 @@ static void decode_sfe_vector_fx(
                res = ari_decode_14bits_s27_ext_fx( st, &hPrivateData->acState, (const UWord16 *) hPrivateData->cf_se00 );
#endif

                pred = arith_decode_bits_fx( hPrivateData, st, 2
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                                             ,
                                             extra_bits_read
#endif
                );                                 /* LSBs as 2 bit raw */
                pred = arith_decode_bits_fx( hPrivateData, st, 2, extra_bits_read ); /* LSBs as 2 bit raw */
                x[f] = add( shl( res, 2 ), pred );                                   // Q0
#else
                pred = arith_decode_bits_fx( hPrivateData, st, 2 ); /* LSBs as 2 bit raw */
                x[f] = add( shl( res, 2 ), pred );                  // Q0
#endif
                move16();
            }
            ELSE IF( EQ_16( f, 1 ) )
            {
                /* (t == 0) && (f == 1) */
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                res = arith_decode_residual_fx( hPrivateData,
                                                st,
                                                hPrivateData->cf_se01,
                                                hPrivateData->cf_off_se01
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                                                ,
                                                extra_bits_read
                                                hPrivateData->cf_off_se01,
                                                extra_bits_read );
#else
                res = arith_decode_residual_fx( hPrivateData,
                                                st,
                                                hPrivateData->cf_se01,
                                                hPrivateData->cf_off_se01 );
#endif
                );
                x[f] = add( x[0], res ); // Q0
                move16();                /* f - increment is 0, pred = b */
            }
@@ -282,15 +286,18 @@ static void decode_sfe_vector_fx(
                index1 = L_mac0( ( IGF_SYMBOLS_IN_TABLE + 1 ) * IGF_CTX_OFFSET, ( IGF_SYMBOLS_IN_TABLE + 1 ), ctx );
                /* index2 is IGF_CTX_OFFSET + ctx */
                index2 = L_mac0( IGF_CTX_OFFSET, 1, ctx );
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                res = arith_decode_residual_fx( hPrivateData,
                                                st,
                                                hPrivateData->cf_se02 + index1,
                                                hPrivateData->cf_off_se02[index2]
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                                                ,
                                                extra_bits_read
                                                hPrivateData->cf_off_se02[index2],
                                                extra_bits_read );
#else
                res = arith_decode_residual_fx( hPrivateData,
                                                st,
                                                hPrivateData->cf_se02 + index1,
                                                hPrivateData->cf_off_se02[index2] );
#endif
                );
                x[f] = add( x[prev_offset], res ); // Q0
                move16();                          /* pred = b */
            }
@@ -301,15 +308,18 @@ static void decode_sfe_vector_fx(
            IF( f == 0 )
            {
                /* (t == 1) && (f == 0) */
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                res = arith_decode_residual_fx( hPrivateData,
                                                st,
                                                hPrivateData->cf_se10,
                                                hPrivateData->cf_off_se10
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                                                ,
                                                extra_bits_read
                                                hPrivateData->cf_off_se10,
                                                extra_bits_read );
#else
                res = arith_decode_residual_fx( hPrivateData,
                                                st,
                                                hPrivateData->cf_se10,
                                                hPrivateData->cf_off_se10 );
#endif
                );
                x[f] = add( prev_x[f], res ); // Q0
                move16();                     /* pred = a */
            }
@@ -330,15 +340,18 @@ static void decode_sfe_vector_fx(
                /* index2 is IGF_CTX_COUNT * (IGF_CTX_OFFSET + ctx_t) + (IGF_CTX_OFFSET + ctx_f) */
                index2 = L_mac0( ( IGF_CTX_COUNT + 1 ) * IGF_CTX_OFFSET, IGF_CTX_COUNT, ctx_t );
                index2 = L_mac0( index2, 1, ctx_f );
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                res = arith_decode_residual_fx( hPrivateData,
                                                st,
                                                hPrivateData->cf_se11 + index1,
                                                hPrivateData->cf_off_se11[index2]
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                                                ,
                                                extra_bits_read
                                                hPrivateData->cf_off_se11[index2],
                                                extra_bits_read );
#else
                res = arith_decode_residual_fx( hPrivateData,
                                                st,
                                                hPrivateData->cf_se11 + index1,
                                                hPrivateData->cf_off_se11[index2] );
#endif
                );
                x[f] = add( pred, res ); // Q0
                move16();
            }
@@ -412,19 +425,17 @@ void IGFSCFDecoderDecode(
        IGFSCFDecoderReset( hPublicData );
    }

    decode_sfe_vector_fx( hPublicData, st, hPublicData->t, hPublicData->prev, sfe, hPublicData->scfCountLongBlock[igfGridIdx]
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                          ,
                          &extra_bits_read
#endif
    );
    decode_sfe_vector_fx( hPublicData, st, hPublicData->t, hPublicData->prev, sfe, hPublicData->scfCountLongBlock[igfGridIdx],
                          &extra_bits_read );

    arith_decode_flush_fx( st
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_DEC2
                           ,
                           &extra_bits_read
    arith_decode_flush_fx( st,
                           &extra_bits_read ); /* finish AC decoding */
#else
    decode_sfe_vector_fx( hPublicData, st, hPublicData->t, hPublicData->prev, sfe, hPublicData->scfCountLongBlock[igfGridIdx] );

    arith_decode_flush_fx( st ); /* finish AC decoding */
#endif
    ); /* finish AC decoding */

    /* advance history */
    Copy( sfe, hPublicData->prev, hPublicData->scfCountLongBlock[igfGridIdx] );
+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ static void stereo_dft_quantize_itd_fx(
    Word16 itd;
    Word16 input_fs_by_stereo_dft_itd_fs = 0;
    move16();
    // itd = (int16_t) ( sign( in ) * 0.5f + in );

    itd = in;
    move16();