Commit 829fbe1d authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Update LC3plus version to v1.6.1

parent 1ecb9137
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line

DisableFormat: true
SortIncludes: Never

DisableFormat: true
SortIncludes: Never

DisableFormat: true
SortIncludes: Never
+5 −5
Original line number Diff line number Diff line
/******************************************************************************
*                        ETSI TS 103 634 V1.5.1                               *
*                        ETSI TS 103 634 V1.6.1                               *
*              Low Complexity Communication Codec Plus (LC3plus)              *
*                                                                             *
* Copyright licence is solely granted through ETSI Intellectual Property      *
@@ -12,7 +12,7 @@
#include "functions.h"

void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT* gain, LC3_INT target, LC3_INT nBits, LC3_INT* gainChange, LC3_INT fs_idx
    , LC3_INT16 hrmode, LC3_INT16 frame_dms
    , LC3_INT16 hrmode, LC3PLUS_FrameDuration frame_dms
    )
{
    LC3_FLOAT delta;
@@ -20,7 +20,7 @@ void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_
    LC3_INT   gg_idx_inc;
    LC3_FLOAT factor;

    if (frame_dms == 25)
    if (frame_dms == LC3PLUS_FRAME_DURATION_2p5MS)
    {
        if (target < 520)
        {
@@ -28,11 +28,11 @@ void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_
        } else {
            factor = 4;
        }
    } else if (frame_dms == 50)
    } else if (frame_dms == LC3PLUS_FRAME_DURATION_5MS)
    {
        factor = 2;
    }
    else if (frame_dms == 75)
    else if (frame_dms == LC3PLUS_FRAME_DURATION_7p5MS)
    {
        factor = 1.2;
    }
+6 −5
Original line number Diff line number Diff line
/******************************************************************************
*                        ETSI TS 103 634 V1.5.1                               *
*                        ETSI TS 103 634 V1.6.1                               *
*              Low Complexity Communication Codec Plus (LC3plus)              *
*                                                                             *
* Copyright licence is solely granted through ETSI Intellectual Property      *
@@ -500,11 +500,12 @@ void fec_encoder(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_INT16 dat
        
        assert((slot_bytes >= FEC_SLOT_BYTES_MIN && slot_bytes <= FEC_SLOT_BYTES_MAX) &&
               "fec_encoder: slot_bytes out of range");
        tmp -= mode == 1 ? 1 : n_codewords * (mode - 1);                                 // reed solomon redundancy
        tmp -= slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode]; // crc1
        tmp -= (n_pccw > 0) && (mode > 1) ? crc2_bytes_by_mode[mode] : 0;                // crc2
        tmp -= mode == 1 ? 1 : n_codewords * (mode - 1);                                 /* reed solomon redundancy */
        tmp -= slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode]; /* crc1 */
        tmp -= (n_pccw > 0) && (mode > 1) ? crc2_bytes_by_mode[mode] : 0;                /* crc2 */
        assert(data_bytes == tmp && "fec_encoder: inconsistent payload size");
        assert(n_codewords - n_pccw >= 6);
        (void)tmp;
    }

    /* data preproc: re-ordering and hash extension */
@@ -1194,7 +1195,7 @@ FEC_STATIC LC3_INT32 rs16_detect_and_correct(LC3_UINT8 *iobuf, LC3_INT32 n_symb,
        }
        }
    }
    assert(n_mode_candidates <= 4); // suppress false gcc warning when OPTIM=3
    assert(n_mode_candidates <= 4); /*  suppress false gcc warning when OPTIM=3 */
    
    /* sort mode candidates by risk */
    for (i = 0; i < n_mode_candidates; i++)
+1 −1
Original line number Diff line number Diff line
/******************************************************************************
*                        ETSI TS 103 634 V1.5.1                               *
*                        ETSI TS 103 634 V1.6.1                               *
*              Low Complexity Communication Codec Plus (LC3plus)              *
*                                                                             *
* Copyright licence is solely granted through ETSI Intellectual Property      *
+95 −17
Original line number Diff line number Diff line
/******************************************************************************
*                        ETSI TS 103 634 V1.5.1                               *
*                        ETSI TS 103 634 V1.6.1                               *
*              Low Complexity Communication Codec Plus (LC3plus)              *
*                                                                             *
* Copyright licence is solely granted through ETSI Intellectual Property      *
@@ -90,7 +90,9 @@ static LC3_INT16 pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT3
            {
                bp_side_local = bp_side_local + 1;
            }
        } else {
        } 
        else 
        {
            bp_local = bp_local - 1;
        }
        
@@ -131,12 +133,16 @@ static LC3_INT16 pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT3
            
            if (st_fl->pc_bfi == 2)
            {
                
#ifdef CR13_B_FIX_PC_BINS
                if (st_fl->pc_c_bp_side && (*bp_side + 1) <= st_fl->pc_be_bp_right)
#else
                if ((st_fl->pc_c_bp && (*bp + 1) >= st_fl->pc_be_bp_left) || (st_fl->pc_c_bp_side && (*bp_side + 1) <= st_fl->pc_be_bp_right))
#endif
                {
                    st_fl->pc_inv_bin = cur_bin;
                    return 1;
                } else if ((st_fl->pc_c_bp && *bp >= 0) || (st_fl->pc_c_bp_side && *bp_side <= (st_fl->pc_bytes - 1)))
                } 
                else if ((st_fl->pc_c_bp && *bp >= 0) || (st_fl->pc_c_bp_side && *bp_side <= (st_fl->pc_bytes - 1)))
                {
                    st_fl->pc_inv_bin = MIN(st_fl->pc_inv_bin, cur_bin);
                    return 0;
@@ -151,6 +157,53 @@ static LC3_INT16 pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT3
    return 0;
}

#ifdef CR13_B_FIX_PC_BINS
static LC3_INT16 pc_check_bytes_ac_decode(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32* bp_side, LC3_INT16 cur_bin)
{
    LC3_INT32 bp_local, bp_side_local;
#ifdef WMOPS
    push_wmops("pc_check_bytes");
#endif

    if (st_fl->pc_bytes > 0)
    {
        bp_local = *bp;
        bp_side_local = *bp_side;

        if (from_left)
        {
            if (mask_side == 1)
            {
                bp_side_local = bp_side_local + 1;
            }
        }
        else 
        {
            bp_local = bp_local - 1;
        }

 
        if (!st_fl->pc_enc && st_fl->pc_b_right > -1)
        {

            if (st_fl->pc_bfi == 2)
            {
                if ((st_fl->pc_c_bp && (*bp) > st_fl->pc_be_bp_left))
                {
                    st_fl->pc_inv_bin = cur_bin;
                    return 1;
                }
            }
        }
    }

#ifdef WMOPS
    pop_wmops();
#endif   
    return 0;
}
#endif

void ac_dec_init_fl(LC3_UINT8* ptr, LC3_INT* bp, Decoder_State_fl* st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side)
{
    LC3_INT i;
@@ -184,15 +237,25 @@ LC3_INT32 ac_decode_fl(Decoder_State_fl* st, const LC3_INT16* freq, LC3_INT32 nu
    push_wmops("ac_decode_fl");    
#endif

#ifdef CR13_B_FIX_PC_BINS
    if (pc_check_bytes_ac_decode(bp, st, from_left, mask_side, bp_side, cur_bin) != 0)
    {
        st->BER_detect = 1;
        return 0;
    }
#endif

    tmp = st->ac_range_fl >> 10;

    if (st->ac_low_fl >= (LC3_UINT32)(tmp << 10)) {
    if (st->ac_low_fl >= (LC3_UINT32)(tmp << 10)) 
    {
        st->BER_detect = 1;
    }

    val = num_sym - 1;

    while (st->ac_low_fl < (LC3_UINT32)(tmp * freq[val])) {
    while (st->ac_low_fl < (LC3_UINT32)(tmp * freq[val])) 
    {
        val--;
    }
    
@@ -201,7 +264,8 @@ LC3_INT32 ac_decode_fl(Decoder_State_fl* st, const LC3_INT16* freq, LC3_INT32 nu
    st->ac_low_fl   = st->ac_low_fl - tmp * freq[val];
    st->ac_range_fl = tmp * symfreq_loc;

    while (st->ac_range_fl < 65536) {
    while (st->ac_range_fl < 65536) 
    {
        st->ac_low_fl   = ((LC3_INT32)st->ac_low_fl) & ((LC3_INT32)(16777215));

        if(pc_check_bytes(bp, st, from_left, mask_side, bp_side, cur_bin) != 0)
@@ -241,7 +305,7 @@ void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT*
void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT L_spec, LC3_INT fs_idx, LC3_INT enable_lpc_weighting,
                          LC3_INT tns_numfilters, LC3_INT lsbMode, LC3_INT lastnz, LC3_INT* bfi, LC3_INT* tns_order, LC3_INT fac_ns_idx,
                          LC3_INT gg_idx, uint8_t * resBits, LC3_INT* x, LC3_INT* nf_seed, LC3_INT* tns_idx, LC3_INT* zero_frame, LC3_INT numbytes,
                          LC3_INT* nbits_residual, LC3_INT* residualPresent, LC3_INT frame_dms,
                          LC3_INT* nbits_residual, LC3_INT* residualPresent, LC3PLUS_FrameDuration frame_dms,
                          LC3_INT32 n_pc, LC3_INT32 be_bp_left, LC3_INT32 be_bp_right, LC3_INT32 enc, LC3_INT32 *b_left, LC3_INT32 *spec_inv_idx,
                          LC3_INT hrmode
)
@@ -298,7 +362,7 @@ void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side,
    tmp = MAXLAG;
    

    if (frame_dms <= 50)
    if (frame_dms <= LC3PLUS_FRAME_DURATION_5MS)
    {
        tmp /= 2;
    }
@@ -334,11 +398,13 @@ void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side,
    }

    /* Spectral data */
    for (k = 0; k < lastnz; k = k + 2) {
    for (k = 0; k < lastnz; k = k + 2) 
    {
        /* Context */
        t = c + rateFlag;

        if (k > (L_spec >> 1)) {
        if (k > (L_spec >> 1)) 
        {
            t = t + 256;
        }

@@ -346,23 +412,29 @@ void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side,
        x[k]     = 0;
        x[k + 1] = 0;

        if (hrmode == 1) {
        if (hrmode == 1) 
        {
            max_lev = 13 + 8;
        } else {
        } 
        else
        {
            max_lev = 13;
        }

        for (lev = 0; lev <= max_lev; lev++) {
        for (lev = 0; lev <= max_lev; lev++) 
        {
            lev1 = MIN(lev, 3);
            pki  = ari_spec_lookup_fl[t + lev1 * 1024];

            sym = ac_decode_fl(&st, &ari_spec_cumfreq_fl[pki][0], 17, ptr, &bp, 1, mask_side, &bp_side, k);

            if (sym < 16) {
            if (sym < 16) 
            {
                break;
            }

            if (lsbMode == 0 || lev > 0) {
            if (lsbMode == 0 || lev > 0) 
            {
                if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0)
                {
                    goto ber_detect;
@@ -495,6 +567,12 @@ void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side,
        {
            idx_len *= EXT_RES_ITER_MAX;
        }
#ifdef CR9_C_ADD_1p25MS
        if (frame_dms == LC3PLUS_FRAME_DURATION_1p25MS) {
            idx_len *= 3;
        }
#endif

        *nbits_residual  = MIN(*nbits_residual, idx_len);
        *residualPresent = 1;

Loading