diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 87f503a314a9b45d2a55b632fb559692c3547861..816a73ab3aef264322d580aa937e20193428d51f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1031,7 +1031,7 @@ check-first-frame-is-sid: expose_as: "logs-sidstart" expire_in: "5 days" -lc3plus-ensure-no-code-changes: +.lc3plus-ensure-no-code-changes: extends: - .test-job-linux - .rules-merge-request diff --git a/lib_lc3plus/adjust_global_gain.c b/lib_lc3plus/adjust_global_gain.c index e7674dd7101b7079137738cd85e859562c1ed0ce..e4ccd48a73dc7076604c0ec4a893b7dc338c2462 100644 --- a/lib_lc3plus/adjust_global_gain.c +++ b/lib_lc3plus/adjust_global_gain.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -15,11 +15,14 @@ void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_ , LC3_INT16 hrmode, LC3_INT16 frame_dms ) { - LC3_FLOAT delta = 0; - LC3_INT delta2 = 0; + LC3_FLOAT delta; + LC3_INT delta2; LC3_INT gg_idx_inc; +#ifdef CR8_G_ADD_75MS + LC3_FLOAT factor; +#else LC3_INT factor; - +#endif if (frame_dms == 25) { @@ -32,7 +35,14 @@ void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_ } else if (frame_dms == 50) { factor = 2; - } else + } +#ifdef CR8_G_ADD_75MS + else if (frame_dms == 75) + { + factor = 1.2; + } +#endif + else { factor = 1; } @@ -60,7 +70,7 @@ void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_ if (hrmode) { if (nBits > target) { - gg_idx_inc = (int) factor * (((nBits - target)/ delta) + 1); + gg_idx_inc = (int) (factor * (((nBits - target)/ delta) + 1)); gg_idx_inc = MIN(gg_idx_inc, 10 * factor); *gg_idx += gg_idx_inc; diff --git a/lib_lc3plus/al_fec_fl.c b/lib_lc3plus/al_fec_fl.c index 0cae36dade9bf580d3774b942dec6eb24b3cf62d..dc233ceb289f7c16fac8c795429231f9575de24e 100644 --- a/lib_lc3plus/al_fec_fl.c +++ b/lib_lc3plus/al_fec_fl.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/apply_global_gain.c b/lib_lc3plus/apply_global_gain.c index c67432e2c3bebcc30da1912ea0c63813f3471d46..43cdcd6facf105aa07423a58d8b99f87273534cb 100644 --- a/lib_lc3plus/apply_global_gain.c +++ b/lib_lc3plus/apply_global_gain.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -13,7 +13,7 @@ void processApplyGlobalGain_fl(LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off) { - LC3_FLOAT gg = 0; + LC3_FLOAT gg; gg = LC3_POW(10, (LC3_FLOAT)(global_gain_idx + global_gain_off) / 28); diff --git a/lib_lc3plus/ari_codec.c b/lib_lc3plus/ari_codec.c index 80c75fcf0cebcf278e4522643ab460beb46cc5bf..4ced06e9a10701322c81ec915204cf386c4011ac 100644 --- a/lib_lc3plus/ari_codec.c +++ b/lib_lc3plus/ari_codec.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -13,26 +13,126 @@ static void ac_shift_fl(Encoder_State_fl* st); static void ac_encode_fl(Encoder_State_fl* st, LC3_INT sym_freq, LC3_INT cum_freq); -static void tns_order_freq_enc(LC3_INT enable_lpc_weighting, LC3_INT order, LC3_INT* symfreq, LC3_INT* cumfreq); -static void tns_coef_freq_enc(LC3_INT k, LC3_INT idx, LC3_INT* symfreq, LC3_INT* cumfreq); -static void ac_freq_fl(LC3_INT pki, LC3_INT s, LC3_INT* symfreq, LC3_INT* cumfreq); static void ac_finalize_fl(Encoder_State_fl* st); static void write_uint_forward_fl(Encoder_State_fl* st, LC3_INT val, LC3_INT numbits); static void ari_enc_init(Encoder_State_fl* st, LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side); static LC3_INT sign(LC3_INT x); + +#ifdef CR9_SIMPLIFY_ARI_DECODER +static void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit); +#else static void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit, LC3_INT *bp, Decoder_State_fl* st_fl, LC3_INT from_left); +#endif + +#ifdef CR9_SIMPLIFY_ARI_DECODER static 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); -static void tns_order_freq(LC3_INT enable_lpc_weighting, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); -static void tns_coef_freq(LC3_INT k, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); +#else +static 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); +#endif + +#ifdef CR9_SIMPLIFY_ARI_DECODER +static LC3_INT32 ac_decode_fl(Decoder_State_fl* st, const LC3_INT16* sym_freq, LC3_INT32 num_sym, LC3_UINT8* ptr, LC3_INT32* bp, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side, LC3_INT16 cur_bin); +#else static LC3_INT ac_decode_fl(Decoder_State_fl* st, LC3_INT* sym_freq, LC3_INT* cum_freq, LC3_INT num_sym, LC3_UINT8* ptr, LC3_INT* bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side); -static void ac_freq(LC3_INT pki, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); -static void findNonZero(LC3_INT* in, LC3_INT* out, LC3_INT len, LC3_INT* outLen); +#endif + +#ifdef CR9_SIMPLIFY_ARI_DECODER +static LC3_INT16 pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side, LC3_INT16 cur_bin); +#else static void pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side); +#endif + static void calculate_nfseed(LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed); +static void findNonZero(LC3_INT* in, LC3_INT len, LC3_INT* outLen); + +#ifndef CR9_SIMPLIFY_ARI_DECODER +static void ac_freq(LC3_INT pki, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); + +static void tns_coef_freq(LC3_INT k, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); + +static void tns_order_freq(LC3_INT enable_lpc_weighting, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); + +void ac_freq(LC3_INT pki, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) +{ + LC3_INT i = 0, j = 0; + + *numsym = 18 - 1; + + j = 0; + for (i = 1; i <= *numsym; i++) { + symfreq[j] = ari_spec_cumfreq_fl[pki][i]; + j++; + } + + for (i = 0; i < *numsym; i++) { + symfreq[i] -= ari_spec_cumfreq_fl[pki][i]; + } + + for (i = 0; i < *numsym; i++) { + cumfreq[i] = ari_spec_cumfreq_fl[pki][i]; + } +} + +void tns_coef_freq(LC3_INT k, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) +{ + LC3_INT i = 0, j = 0; + + *numsym = 18 - 1; + + j = 0; + for (i = 1; i <= *numsym; i++) { + symfreq[j] = ari_tns_freq_cf[k][i]; + j++; + } + + for (i = 0; i < *numsym; i++) { + symfreq[i] -= ari_tns_freq_cf[k][i]; + } + + for (i = 0; i < *numsym; i++) { + cumfreq[i] = ari_tns_freq_cf[k][i]; + } +} + +void tns_order_freq(LC3_INT enable_lpc_weighting, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) +{ + LC3_INT i = 0, j = 0; + + *numsym = 8; + + j = 0; + for (i = 1; i < 9; i++) { + symfreq[j] = ari_tns_order_cf[enable_lpc_weighting][i]; + j++; + } + + for (i = 0; i < *numsym; i++) { + symfreq[i] -= ari_tns_order_cf[enable_lpc_weighting][i]; + } + + for (i = 0; i < *numsym; i++) { + cumfreq[i] = ari_tns_order_cf[enable_lpc_weighting][i]; + } +} + +#endif + +void findNonZero(LC3_INT* in, LC3_INT len, LC3_INT* outLen) +{ + LC3_INT i = 0, j = 0; + + for (i = 0; i < len; i++) { + if (in[i] != 0) { + j++; + } + } + + *outLen = j; +} void calculate_nfseed(LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed) { - LC3_INT k = 0; + LC3_INT k; *nf_seed = 0; @@ -46,6 +146,102 @@ void calculate_nfseed(LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed) } } +#ifdef CR9_SIMPLIFY_ARI_DECODER +static LC3_INT16 pc_check_bytes(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, offset; +#ifdef WMOPS + push_wmops("pc_check_bytes"); +#endif + + if (st_fl->pc_bytes > 0) + { + if (!from_left && mask_side != 1) + { + return 0; + } + + if (st_fl->pc_c_bp_side > 0 && *bp_side < 0) + { + assert(mask_side == 1); + assert(st_fl->pc_b_right != -1); + *bp_side = st_fl->pc_b_right; + + return 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_b_right == -1) + { + offset = -1; + if (!st_fl->pc_enc) + { + offset = offset + st_fl->pc_bytes; + } + + if ((bp_side_local + offset - bp_local) == st_fl->pc_bytes) + { + st_fl->pc_b_left = bp_local + 1; + st_fl->pc_b_right = bp_side_local - 1; + + if (st_fl->pc_enc) + { + assert(st_fl->pc_b_right - st_fl->pc_b_left + 1 == st_fl->pc_bytes); + return 1; + } + } + } + + if (!st_fl->pc_enc && st_fl->pc_b_right > -1) + { + if (from_left && *bp == st_fl->pc_b_left) + { + *bp = 0; + st_fl->pc_c_bp = 1; + } + + if (!from_left && bp_side_local == st_fl->pc_b_right) + { + *bp_side = st_fl->pc_bytes - 1; + st_fl->pc_c_bp_side = 1; + } + + if (st_fl->pc_bfi == 2) + { + + 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)) + { + 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))) + { + st_fl->pc_inv_bin = MIN(st_fl->pc_inv_bin, cur_bin); + return 0; + } + } + } + } + +#ifdef WMOPS + pop_wmops(); +#endif + return 0; +} + +#else + static void pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side) { LC3_INT32 bp_local, bp_side_local, offset; @@ -130,6 +326,35 @@ static void pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 fro return; } +#endif + +#ifdef CR9_SIMPLIFY_ARI_DECODER +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; + + if (!st_fl->pc_enc) + { + *bp = *bp + st_fl->pc_bytes; + } + + st_fl->ac_low_fl = 0; + + st_fl->ac_range_fl = (LC3_UINT32) 16777215; /* 2^24 -1 */ + for (i = 0; i < 3; i++) { + if(pc_check_bytes(bp, st_fl, from_left, mask_side, bp_side, 0) != 0) + { + return; + } + + st_fl->ac_low_fl = (st_fl->ac_low_fl << 8) + (LC3_UINT32)ptr[*bp]; + *bp = *bp + 1; + } + + st_fl->BER_detect = 0; +} + +#else 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) { @@ -153,145 +378,573 @@ void ac_dec_init_fl(LC3_UINT8* ptr, LC3_INT* bp, Decoder_State_fl* st_fl, LC3_IN st_fl->BER_detect = 0; } -void tns_order_freq(LC3_INT enable_lpc_weighting, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) -{ - LC3_INT i = 0, j = 0; +#endif + +/* Returns val */ +#ifdef CR9_SIMPLIFY_ARI_DECODER +LC3_INT32 ac_decode_fl(Decoder_State_fl* st, const LC3_INT16* freq, LC3_INT32 num_sym, LC3_UINT8* ptr, LC3_INT32* bp, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side, LC3_INT16 cur_bin) +{ + LC3_INT val, tmp, symfreq_loc; +#ifdef WMOPS + push_wmops("ac_decode_fl"); +#endif + + tmp = st->ac_range_fl >> 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])) { + val--; + } + + symfreq_loc = freq[val + 1] - freq[val]; + + st->ac_low_fl = st->ac_low_fl - tmp * freq[val]; + st->ac_range_fl = tmp * symfreq_loc; + + 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) + { + st->BER_detect = 1; + return 1; + } + + st->ac_low_fl = st->ac_low_fl << 8; + st->ac_low_fl = st->ac_low_fl + ptr[*bp]; + *bp = *bp + 1; + st->ac_range_fl = st->ac_range_fl << 8; + } + +#ifdef WMOPS + pop_wmops(); +#endif + return val; +} + +#else + +LC3_INT ac_decode_fl(Decoder_State_fl* st, LC3_INT* sym_freq, LC3_INT* cum_freq, LC3_INT num_sym, LC3_UINT8* ptr, LC3_INT* bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side) +{ + LC3_INT val = 0, tmp = 0; + + + tmp = st->ac_range_fl >> 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 * cum_freq[val])) { + val--; + } + + st->ac_low_fl = st->ac_low_fl - tmp * cum_freq[val]; + st->ac_range_fl = tmp * sym_freq[val]; + + while (st->ac_range_fl < pow(2, 16)) { + st->ac_low_fl = st->ac_low_fl << 8; + st->ac_low_fl = ((LC3_INT)st->ac_low_fl) & ((LC3_INT)(pow(2, 24) - 1)); + + pc_check_bytes(bp, st, from_left, mask_side, bp_side); + + st->ac_low_fl = st->ac_low_fl + ptr[*bp]; + *bp = *bp + 1; + st->ac_range_fl = st->ac_range_fl << 8; + } + + return val; +} + + +#endif + +#ifdef CR9_SIMPLIFY_ARI_DECODER +void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit) +{ + if (ptr[*bp_side] & *mask_side) { + *bit = 1; + } else { + *bit = 0; + } + + if (*mask_side == 128) { + *mask_side = 1; + *bp_side = *bp_side - 1; + } else { + *mask_side = *mask_side * 2; + } +} + +#else + +void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit, LC3_INT *bp, Decoder_State_fl* st_fl, LC3_INT from_left) +{ + *bit = 0; + + UNUSED(bp); + UNUSED(st_fl); + UNUSED(from_left); + + if (ptr[*bp_side] & *mask_side) { + *bit = 1; + } else { + *bit = 0; + } + + if (*mask_side == 128) { + *mask_side = 1; + *bp_side = *bp_side - 1; + } else { + *mask_side = *mask_side * 2; + } +} + +#endif + +#ifdef CR9_SIMPLIFY_ARI_DECODER +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_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 +) +{ + Decoder_State_fl st; + LC3_INT a, b, t, bp; + LC3_INT c; + LC3_INT nbits_side, extra_bits; + LC3_UINT8* ptr; + LC3_INT n, k, lev; + LC3_INT max_lev, tmp; + LC3_INT bit, lev1, pki, sym, save_lev[MAX_LEN], idx_len, total_bits, nbits_ari, rateFlag; + +#ifdef WMOPS + push_wmops("processAriDecoder_fl"); +#endif + + total_bits = 8 * numbytes; + rateFlag = 0; + + memset(&st, 0, sizeof(st)); + + st.pc_bytes = (n_pc + 1) >> 1; + st.pc_b_left = numbytes + 1; + st.pc_b_right = -1; + st.pc_enc = enc; + st.pc_bfi = *bfi; + st.pc_be_bp_left = floor(be_bp_left / 8); + st.pc_be_bp_right = floor(be_bp_right / 8) - 1; + *spec_inv_idx = L_spec + 1; + assert(st.pc_be_bp_right < st.pc_bytes || st.pc_bytes == 0); + + /* Rate flag */ + if (fs_idx != 5) + { + if (total_bits > (160 + fs_idx * 160)) { + rateFlag = 512; + } + } + + /* Init */ + c = 0; + t = 0; + bp = 0; + + *b_left = -1; + + ptr = bytes; + + /* Start Decoding */ + ac_dec_init_fl(ptr, &bp, &st, 1, mask_side, &bp_side); + + /* Decode TNS data */ + tmp = MAXLAG; + + + if (frame_dms <= 50) + { + tmp /= 2; + } + + /* Decode TNS data */ + for (n = 0; n < tns_numfilters; n++) { + + if (tns_order[n] > 0) { + tns_order[n] = ac_decode_fl(&st, &ari_tns_order_cf[enable_lpc_weighting][0], 8, ptr, &bp, 1, mask_side, &bp_side, 0); + + tns_order[n] = tns_order[n] + 1; + + if (tns_order[n] > tmp || st.BER_detect > 0) + { + goto ber_detect; + } + + for (k = 0; k < tns_order[n]; k++) { + if (bp_side < bp) + { + *bfi = 1; + return; + } + + tns_idx[n * 8 + k] = ac_decode_fl(&st, &ari_tns_freq_cf[k][0], 17, ptr, &bp, 1, mask_side, &bp_side, 0); + + if (st.BER_detect > 0) + { + goto ber_detect; + } + } + } + } + + /* Spectral data */ + for (k = 0; k < lastnz; k = k + 2) { + /* Context */ + t = c + rateFlag; + + if (k > (L_spec >> 1)) { + t = t + 256; + } + + /* Decode amplitude */ + x[k] = 0; + x[k + 1] = 0; + + if (hrmode == 1) { + max_lev = 13 + 8; + } else { + max_lev = 13; + } + + 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) { + break; + } + + if (lsbMode == 0 || lev > 0) { + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + x[k] = x[k] + (bit << lev); + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + x[k + 1] = x[k + 1] + (bit << lev); + } + } + + if ((lev - 1) == 13 && sym == 16) + { + goto ber_detect; + } + + if (hrmode == 0) { + lev = MIN(lev, 13); + } + + if (lsbMode == 1) { + save_lev[k] = lev; + } + + a = sym & 3; + b = sym >> 2; + + x[k] = x[k] + (a << lev); + x[k + 1] = x[k + 1] + (b << lev); + + /* Decode signs */ + if (x[k] > 0) { + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + if (bit == 1) { + x[k] = -x[k]; + } + } + + if (x[k + 1] > 0) { + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + if (bit == 1) { + x[k + 1] = -x[k + 1]; + } + } + + /* Context */ + lev1 = MIN(lev, 3); + if (lev1 <= 1) { + t = 1 + (a + b) * (lev1 + 1); + } else { + t = 12 + lev1; + } + + c = (c & 15) * 16 + t; + + if (((bp - bp_side) > 3 && (st.pc_c_bp == st.pc_c_bp_side))) { - *numsym = 8; + if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) + { + *bfi = 2; + calculate_nfseed(x, k, nf_seed); + return; + } - j = 0; - for (i = 1; i < 9; i++) { - symfreq[j] = ari_tns_order_cf[enable_lpc_weighting][i]; - j++; + *bfi = 1; + return; + } + + if (st.BER_detect > 0) + { + goto ber_detect; + } } - for (i = 0; i < *numsym; i++) { - symfreq[i] -= ari_tns_order_cf[enable_lpc_weighting][i]; - } + /* Residual bits */ + nbits_side = total_bits - (8 * bp_side + 8 - (31 - clz_func(mask_side))); + nbits_ari = (bp - 3) * 8; + extra_bits = 25 - (31 - clz_func(st.ac_range_fl)); - for (i = 0; i < *numsym; i++) { - cumfreq[i] = ari_tns_order_cf[enable_lpc_weighting][i]; + if (enc == 0) + { + if (st.pc_c_bp == 0) + { + nbits_ari = (bp - st.pc_bytes - 3) * 8; + } else { + nbits_ari = (bp + st.pc_b_left - st.pc_bytes - 3) * 8; + } + + if (st.pc_c_bp_side != 0) + { + nbits_side = total_bits - 8 * (st.pc_b_left) + 8 * (st.pc_bytes - bp_side) - (8 - LC3_LOGTWO(mask_side)); + } } -} -/* Returns val */ -LC3_INT ac_decode_fl(Decoder_State_fl* st, LC3_INT* sym_freq, LC3_INT* cum_freq, LC3_INT num_sym, LC3_UINT8* ptr, LC3_INT* bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side) -{ - LC3_INT val = 0, tmp = 0; + *nbits_residual = total_bits - (nbits_side + nbits_ari + extra_bits); - tmp = st->ac_range_fl >> 10; - - if (st->ac_low_fl >= (LC3_UINT32)(tmp << 10)) { - st->BER_detect = 1; + if (*nbits_residual < 0) { + if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) + { + *bfi = 2; + calculate_nfseed(x, k, nf_seed); + return; + } + + *bfi = 1; + return; } - val = num_sym - 1; + if (lsbMode == 0) { + findNonZero(x, L_spec, &idx_len); - while (st->ac_low_fl < (LC3_UINT32)(tmp * cum_freq[val])) { - val--; - } + if (hrmode) + { + idx_len *= EXT_RES_ITER_MAX; + } + *nbits_residual = MIN(*nbits_residual, idx_len); + *residualPresent = 1; - st->ac_low_fl = st->ac_low_fl - tmp * cum_freq[val]; - st->ac_range_fl = tmp * sym_freq[val]; + memset(resBits, 0, MAX_RESBITS_LEN); - while (st->ac_range_fl < pow(2, 16)) { - st->ac_low_fl = st->ac_low_fl << 8; - st->ac_low_fl = ((LC3_INT)st->ac_low_fl) & ((LC3_INT)(pow(2, 24) - 1)); - - pc_check_bytes(bp, st, from_left, mask_side, bp_side); - - st->ac_low_fl = st->ac_low_fl + ptr[*bp]; - *bp = *bp + 1; - st->ac_range_fl = st->ac_range_fl << 8; - } + for (k = 0; k < *nbits_residual; k++) { + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect_res; + } + read_bit_fl(ptr, &mask_side, &bp_side, &tmp); + + resBits[k >> 3] |= tmp << (k & 7); + } + } else { + for (k = 0; k < lastnz; k = k + 2) { + if (save_lev[k] > 0) { + if (*nbits_residual == 0) { + break; + } - return val; -} + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect_res; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + *nbits_residual = *nbits_residual - 1; -void tns_coef_freq(LC3_INT k, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) -{ - LC3_INT i = 0, j = 0; + if (bit == 1) { + if (x[k] > 0) { + x[k] = x[k] + 1; + } else if (x[k] < 0) { + x[k] = x[k] - 1; + } else { + if (*nbits_residual == 0) { + break; + } - *numsym = 18 - 1; + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect_res; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + *nbits_residual = *nbits_residual - 1; - j = 0; - for (i = 1; i <= *numsym; i++) { - symfreq[j] = ari_tns_freq_cf[k][i]; - j++; - } + if (bit == 0) { + x[k] = 1; + } else { + x[k] = -1; + } + } + } - for (i = 0; i < *numsym; i++) { - symfreq[i] -= ari_tns_freq_cf[k][i]; - } + if (*nbits_residual == 0) { + break; + } - for (i = 0; i < *numsym; i++) { - cumfreq[i] = ari_tns_freq_cf[k][i]; - } -} + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect_res; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + *nbits_residual = *nbits_residual - 1; -void ac_freq(LC3_INT pki, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) -{ - LC3_INT i = 0, j = 0; + if (bit == 1) { + if (x[k + 1] > 0) { + x[k + 1] = x[k + 1] + 1; + } else if (x[k + 1] < 0) { + x[k + 1] = x[k + 1] - 1; + } else { + if (*nbits_residual == 0) { + break; + } - *numsym = 18 - 1; + if(pc_check_bytes(&bp, &st, 0, mask_side, &bp_side, k) != 0) + { + goto ber_detect_res; + } + read_bit_fl(ptr, &mask_side, &bp_side, &bit); + + *nbits_residual = *nbits_residual - 1; - j = 0; - for (i = 1; i <= *numsym; i++) { - symfreq[j] = ari_spec_cumfreq_fl[pki][i]; - j++; + if (bit == 0) { + x[k + 1] = 1; + } else { + x[k + 1] = -1; + } + } + } + } + } } - for (i = 0; i < *numsym; i++) { - symfreq[i] -= ari_spec_cumfreq_fl[pki][i]; - } + /* Noise-filling seed */ + calculate_nfseed(x, L_spec, nf_seed); - for (i = 0; i < *numsym; i++) { - cumfreq[i] = ari_spec_cumfreq_fl[pki][i]; + /* Zero frame flag */ + if (lastnz == 2 && x[0] == 0 && x[1] == 0 && gg_idx == 0 && fac_ns_idx == 7) { + *zero_frame = 1; + } else { + *zero_frame = 0; } -} - -void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit, LC3_INT *bp, Decoder_State_fl* st_fl, LC3_INT from_left) -{ - *bit = 0; - UNUSED(bp); - UNUSED(st_fl); - UNUSED(from_left); - - if (ptr[*bp_side] & *mask_side) { - *bit = 1; + if (enc) + { + if (st.pc_bytes > 0) + { + if (st.pc_b_left > numbytes) + { + *b_left = bp_side - st.pc_bytes; + } + } } else { - *bit = 0; + if (st.pc_bytes > 0) + { + if (st.pc_b_left > numbytes) + { + *b_left = bp_side; + } + } } - - if (*mask_side == 128) { - *mask_side = 1; - *bp_side = *bp_side - 1; - } else { - *mask_side = *mask_side * 2; + + if ((*bfi == 2) && (*spec_inv_idx == (L_spec + 1))) + { + *bfi = 0; } -} + + *spec_inv_idx = *spec_inv_idx - 1; -void findNonZero(LC3_INT* in, LC3_INT* out, LC3_INT len, LC3_INT* outLen) -{ - LC3_INT i = 0, j = 0; + goto bail; - for (i = 0; i < len; i++) { - if (in[i] != 0) { - out[j] = i; - j++; - } - } +/* goto for bit error handling */ +ber_detect: + *bfi = 1; + *b_left = st.pc_b_left; - *outLen = j; + if (st.pc_inv_bin > 0 && (st.pc_inv_bin - L_spec) <= 0) + { + *spec_inv_idx = st.pc_inv_bin; + *bfi = 2; + *resBits = 0; + *zero_frame = 0; + /* Noise Filling seed */ + calculate_nfseed(x, *spec_inv_idx, nf_seed); + } + goto bail; + +/* goto for bit error handling in residual signal */ +ber_detect_res: + *b_left = st.pc_b_left; + *resBits = 0; + *bfi = 0; + *zero_frame = 0; + /* Noise Filling seed */ + calculate_nfseed(x, *spec_inv_idx, nf_seed); + goto bail; + +/* goto, because of dynmem out */ +bail: + +#ifdef WMOPS + pop_wmops(); +#endif + /* Avoid warning "label at end of compound statement" when WMOPS is inactive */ + (void)0; } +#else + + 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_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_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 ) { @@ -303,7 +956,7 @@ void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT n = 0, k = 0, lev = 0; LC3_INT max_lev = 0, tmp = 0; LC3_INT sym_freq[MAX_LEN] = {0}, cum_freq[MAX_LEN] = {0}, numsym = 0, bit = 0, lev1 = 0, pki = 0, sym = 0, - save_lev[MAX_LEN] = {0}, idx_len = 0, total_bits = 0, nbits_ari = 0, idx[MAX_LEN] = {0}, rateFlag = 0; + save_lev[MAX_LEN] = {0}, idx_len = 0, total_bits = 0, nbits_ari = 0, rateFlag = 0; total_bits = 8 * numbytes; @@ -641,7 +1294,7 @@ void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, } if (lsbMode == 0) { - findNonZero(x, idx, L_spec, &idx_len); + findNonZero(x, L_spec, &idx_len); if (hrmode) { idx_len *= EXT_RES_ITER_MAX; @@ -826,22 +1479,24 @@ void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, *spec_inv_idx = *spec_inv_idx - 1; } +#endif + void ac_encode_fl(Encoder_State_fl* st, LC3_INT sym_freq, LC3_INT cum_freq) { - LC3_INT r = 0; + LC3_INT r; r = st->range >> 10; - st->low = st->low + r * cum_freq; + st->low += r * cum_freq; if ((st->low >> 24) == 1) { st->carry = 1; } - st->low = (st->low) & ((LC3_INT)pow(2, 24) - 1); + st->low &= (16777215); /* 2^24 -1 */ st->range = r * sym_freq; - while (st->range < (LC3_INT)pow(2, 16)) { - st->range = st->range << 8; + while (st->range < 65536) { /* 2^16 */ + st->range <<= 8; ac_shift_fl(st); } } @@ -867,47 +1522,30 @@ void ac_shift_fl(Encoder_State_fl* st) } st->low = st->low << 8; - st->low = (st->low) & ((LC3_INT)pow(2, 24) - 1); -} - -void tns_order_freq_enc(LC3_INT enable_lpc_weighting, LC3_INT order, LC3_INT* symfreq, LC3_INT* cumfreq) -{ - *symfreq = tns_freq_cf[enable_lpc_weighting][order] - tns_freq_cf[enable_lpc_weighting][order - 1]; - *cumfreq = tns_freq_cf[enable_lpc_weighting][order - 1]; -} - -void tns_coef_freq_enc(LC3_INT k, LC3_INT idx, LC3_INT* symfreq, LC3_INT* cumfreq) -{ - *symfreq = tns_cf[k][idx + 1] - tns_cf[k][idx]; - *cumfreq = tns_cf[k][idx]; + st->low = (st->low) & (16777215); /* 2^24 - 1 */ } -void ac_freq_fl(LC3_INT pki, LC3_INT s, LC3_INT* symfreq, LC3_INT* cumfreq) -{ - *symfreq = ari_spec_cumfreq_fl[pki][s + 1] - ari_spec_cumfreq_fl[pki][s]; - *cumfreq = ari_spec_cumfreq_fl[pki][s]; -} void ac_finalize_fl(Encoder_State_fl* st) { LC3_INT bits = 0, mask = 0, val = 0, over1 = 0, high = 0, over2 = 0, c = 0, b = 0; - bits = 24 - floor(LC3_LOGTWO(st->range)); - mask = ((LC3_INT)pow(2, 24) - 1) >> bits; + bits = 24 - (31 - clz_func(st->range)); + mask = 16777215 >> bits; val = st->low + mask; over1 = val >> 24; - val = (val) & ((LC3_INT)pow(2, 24) - 1); + val = (val) & 16777215; high = st->low + st->range; over2 = high >> 24; - high = high & ((LC3_INT)pow(2, 24) - 1); - val = val & (((LC3_INT)pow(2, 24) - 1) - mask); + high = high & 16777215; + val = val & (16777215 - mask); if (over1 == over2) { if (val + mask >= high) { bits = bits + 1; mask = mask >> 1; - val = ((st->low + mask) & ((LC3_INT)pow(2, 24) - 1)) & (((LC3_INT)pow(2, 24) - 1) - mask); + val = ((st->low + mask) & (16777215)) & (16777215 - mask); } if (val < st->low) { @@ -949,7 +1587,7 @@ void ac_finalize_fl(Encoder_State_fl* st) void write_uint_forward_fl(Encoder_State_fl* st, LC3_INT val, LC3_INT numbits) { - LC3_INT k = 0, bit = 0, mask = 128; + LC3_INT k, bit, mask = 128; for (k = 0; k < numbits; k++) { bit = val & mask; @@ -971,7 +1609,7 @@ void ari_enc_init(Encoder_State_fl* st, LC3_UINT8* bytes, LC3_INT* bp_side, LC3_ st->mask_side = mask_side; st->bp = 0; st->low = 0; - st->range = (LC3_INT)pow(2, 24) - 1; + st->range = 16777215; st->cache = -1; st->carry = 0; st->carry_count = 0; @@ -992,11 +1630,16 @@ void processAriEncoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT* tns_idx, LC3_INT lastnz, LC3_INT* codingdata, uint8_t* res_bits, LC3_INT resBitsLen, LC3_INT lsbMode, LC3_INT nbbits, LC3_INT enable_lpc_weighting) { - LC3_INT total_bits = 0, cumfreq = 0, symfreq = 0, k = 0, i = 0, j = 0, lev = 0, lev1 = 0; - LC3_INT bit1 = 0, bit2 = 0, lsb1 = 0, lsb2 = 0, a = 0, b = 0, bit = 0, pki = 0, nbits_side = 0; - LC3_INT nbits_residual_enc = 0, nbits_ari = 0, lsbs[MAX_LEN] = {0}, lsbsLen = 0; + LC3_INT total_bits, cumfreq, symfreq, k, i, j, lev, lev1; + LC3_INT bit1, bit2, lsb1, lsb2, a, b, bit, pki, nbits_side; + LC3_INT nbits_residual_enc, nbits_ari, lsbs[MAX_LEN], lsbsLen = 0; + LC3_INT abs_x_k, abs_x_kp1; Encoder_State_fl st; +#ifdef WMOPS + push_wmops("processAriEncoder_fl"); +#endif + ari_enc_init(&st, bytes, &bp_side, &mask_side); total_bits = nbbits; @@ -1004,11 +1647,13 @@ void processAriEncoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, /* TNS data */ for (i = 0; i < tns_numfilters; i++) { if (tns_order[i] > 0) { - tns_order_freq_enc(enable_lpc_weighting, tns_order[i], &symfreq, &cumfreq); + symfreq = tns_freq_cf[enable_lpc_weighting][tns_order[i]] - tns_freq_cf[enable_lpc_weighting][tns_order[i] - 1]; + cumfreq = tns_freq_cf[enable_lpc_weighting][tns_order[i] - 1]; ac_encode_fl(&st, symfreq, cumfreq); for (j = 0; j < tns_order[i]; j++) { - tns_coef_freq_enc(j, tns_idx[i * 8 + j], &symfreq, &cumfreq); + symfreq = tns_cf[j][tns_idx[i * 8 + j] + 1] - tns_cf[j][tns_idx[i * 8 + j]]; + cumfreq = tns_cf[j][tns_idx[i * 8 + j]]; ac_encode_fl(&st, symfreq, cumfreq); } } @@ -1016,14 +1661,18 @@ void processAriEncoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, /* Spectral data */ for (k = 0; k < lastnz; k = k + 2) { + abs_x_k = abs(x[k]); + abs_x_kp1 = abs(x[k + 1]); for (lev = 0; lev < codingdata[1]; lev++) { lev1 = MIN(lev, 3); pki = ari_spec_lookup_fl[codingdata[0] + lev1 * 1024]; - ac_freq_fl(pki, 16, &symfreq, &cumfreq); + symfreq = ari_spec_cumfreq_fl[pki][17] - ari_spec_cumfreq_fl[pki][16]; + cumfreq = ari_spec_cumfreq_fl[pki][16]; ac_encode_fl(&st, symfreq, cumfreq); - bit1 = (abs(x[k]) >> lev) & 1; - bit2 = (abs(x[k + 1]) >> lev) & 1; + bit1 = (abs_x_k >> lev) & 1; + bit2 = (abs_x_kp1 >> lev) & 1; + if (lsbMode == 1 && lev == 0) { lsb1 = bit1; @@ -1037,11 +1686,12 @@ void processAriEncoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, lev1 = MIN(MAX(codingdata[1], 0), 3); pki = ari_spec_lookup_fl[codingdata[0] + lev1 * 1024]; - ac_freq_fl(pki, codingdata[2], &symfreq, &cumfreq); + symfreq = ari_spec_cumfreq_fl[pki][codingdata[2] + 1] - ari_spec_cumfreq_fl[pki][codingdata[2]]; + cumfreq = ari_spec_cumfreq_fl[pki][codingdata[2]]; ac_encode_fl(&st, symfreq, cumfreq); - a = abs(x[k]); - b = abs(x[k + 1]); + a = abs_x_k; + b = abs_x_kp1; if (lsbMode == 1 && codingdata[1] > 0) { a = a >> 1; @@ -1079,8 +1729,8 @@ void processAriEncoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, } /* Residual bits */ - nbits_side = total_bits - (8 * (*(st.bp_side) + 1) + 8 - LC3_LOGTWO(*(st.mask_side))); - nbits_ari = (st.bp + 1) * 8 + 25 - floor(LC3_LOGTWO(st.range)); + nbits_side = total_bits - (8 * (*(st.bp_side) + 1) + 8 - (31 - clz_func(*(st.mask_side)))); + nbits_ari = 8 * (st.bp + 1) + 25 - (31 - clz_func(st.range )) ; if (st.cache >= 0) { nbits_ari = nbits_ari + 8; @@ -1118,5 +1768,8 @@ void processAriEncoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, } ac_finalize_fl(&st); +#ifdef WMOPS + pop_wmops(); +#endif } diff --git a/lib_lc3plus/attack_detector.c b/lib_lc3plus/attack_detector.c index c9f7c0a94c0be6529592f96793969ff5b2edb5b4..ec70b63b67a40882736b075ae25bff6e07720c33 100644 --- a/lib_lc3plus/attack_detector.c +++ b/lib_lc3plus/attack_detector.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -14,26 +14,19 @@ void attack_detector_fl(LC3_FLOAT* in, LC3_INT frame_size, LC3_INT fs, LC3_INT* lastAttackPosition, LC3_FLOAT* accNrg, LC3_INT* attackFlag, LC3_FLOAT* attdec_filter_mem, LC3_INT attackHandlingOn, LC3_INT attdec_nblocks, LC3_INT attdec_hangover_threshold) { - LC3_FLOAT f_sig[160] = {0}, block_nrg[4] = {0}, sum = 0, tmpEne = 0, *ptr = NULL, tmp[162] = {0}; - LC3_INT i = 0, j = 0, attackPosition = 0; - LC3_FLOAT mval = 0; - LC3_INT frame_size_16k = attdec_nblocks * 40; - - - ptr = &tmp[2]; - - + LC3_FLOAT f_sig[160], block_nrg[4], sum, tmpEne, *ptr, tmp[162]; + LC3_INT i, j, attackPosition; + LC3_FLOAT mval; + LC3_INT frame_size_16k; if (attackHandlingOn) { - /* Decimate 96, 48 and 32 kHz signals to 16 kHz */ - if (fs == 96000) { - for (i = 0; i < frame_size;) { - ptr[j] = in[i] + in[i + 1] + in[i + 2] + in[i + 3] + in[i + 4] + in[i + 5]; - i = i + 6; - j++; - } - mval = 1e-5; - } else if (fs == 48000) { + + mval = 0; j = 0; + frame_size_16k = attdec_nblocks * 40; + ptr = &tmp[2]; + + /* Decimate 48 and 32 kHz signals to 16 kHz */ + if (fs == 48000) { j = 0; for (i = 0; i < frame_size;) { ptr[j] = (in[i] + in[i + 1] + in[i + 2]); @@ -47,13 +40,6 @@ void attack_detector_fl(LC3_FLOAT* in, LC3_INT frame_size, LC3_INT fs, LC3_INT* i = i + 2; j++; } - } else if (fs == 24000) { - j = 0; - for (i = 0; i < frame_size;) { - ptr[j] = (in[i] + (in[i + 1] + in[i + 2]) / 2.0); - i = i + 3; - j++; - } } /* Filter */ diff --git a/lib_lc3plus/clib.h b/lib_lc3plus/clib.h index bd709278086b82b878ad95d1b7699ddfa4d7e0f2..6588af717d16a41a92d3ca12753528588bb9d4c1 100644 --- a/lib_lc3plus/clib.h +++ b/lib_lc3plus/clib.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,6 +11,7 @@ #ifndef CLIB_H #define CLIB_H +#include "options.h" #include #include #include diff --git a/lib_lc3plus/constants.c b/lib_lc3plus/constants.c index 8189761a04c12632f10a502e51f0479efbdc00fe..306a8925640108c59b01b3b1e1b77220f3b0d8c0 100644 --- a/lib_lc3plus/constants.c +++ b/lib_lc3plus/constants.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -48,10 +48,10 @@ ENTRY_DCT2_15, ENTRY_DCT2_16 }; -const LC3_INT ari_tns_order_cf[2][9] = {{0, 3, 12, 35, 89, 200, 390, 658, 1024}, +const LC3_INT16 ari_tns_order_cf[2][9] = {{0, 3, 12, 35, 89, 200, 390, 658, 1024}, {0, 14, 56, 156, 313, 494, 672, 839, 1024}}; -const LC3_INT ari_tns_freq_cf[8][18] = { +const LC3_INT16 ari_tns_freq_cf[8][18] = { {0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023, 1024}, {0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023, 1024}, {0, 1, 2, 3, 4, 13, 56, 162, 361, 578, 788, 929, 1003, 1020, 1021, 1022, 1023, 1024}, @@ -279,7 +279,7 @@ const LC3_INT ari_spec_lookup_fl[4096] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -const LC3_INT ari_spec_cumfreq_fl[64][18] = { +const LC3_INT16 ari_spec_cumfreq_fl[64][18] = { {0, 1, 2, 177, 225, 226, 227, 336, 372, 543, 652, 699, 719, 768, 804, 824, 834, 1024}, {0, 18, 44, 61, 71, 98, 135, 159, 175, 197, 229, 251, 265, 282, 308, 328, 341, 1024}, {0, 71, 163, 212, 237, 318, 420, 481, 514, 556, 613, 652, 675, 697, 727, 749, 764, 1024}, @@ -653,6 +653,22 @@ const LC3_FLOAT quants_thr_tns[18] = {-1, 1}; /* SNS */ +const LC3_FLOAT sns_W[6] = {0.0833333333333333, 0.166666666666667, 0.250000000000000, 0.250000000000000, 0.166666666666667, 0.0833333333333333}; + +const LC3_FLOAT sns_preemph_8[64] = {1, 1.05250028527773, 1.10775685050971, 1.16591440117983, 1.22712523985119, 1.29154966501488, 1.35935639087853, 1.43072298919376, 1.50583635427984, 1.58489319246111, 1.66810053720006, 1.75567629127500, 1.84784979742229, 1.94486243893736, 2.04696827180752, 2.15443469003188, 2.26754312587080, 2.38658978685858, 2.51188643150958, 2.64376118574910, 2.78255940220713, 2.92864456462524, 3.08239923974514, 3.24422607917163, 3.41454887383360, 3.59381366380463, 3.78248990638938, 3.98107170553497, 4.19007910578667, 4.41005945417674, 4.64158883361278, 4.88527357151939, 5.14175182768393, 5.41169526546464, 5.69581081073769, 5.99484250318941, 6.30957344480193, 6.64082785063484, 6.98947320727349, 7.35642254459641, 7.74263682681127, 8.14912746902074, 8.57695898590894, 9.02725177948457, 9.50118507318144, 10, 10.5250028527773, 11.0775685050971, 11.6591440117983, 12.2712523985119, 12.9154966501488, 13.5935639087853, 14.3072298919376, 15.0583635427984, 15.8489319246111, 16.6810053720006, 17.5567629127500, 18.4784979742229, 19.4486243893736, 20.4696827180752, 21.5443469003188, 22.6754312587080, 23.8658978685858, 25.1188643150958}; + +const LC3_FLOAT sns_preemph_16[64] = {1, 1.06800043251458, 1.14062492385132, 1.21818791201012, 1.30102521691083, 1.38949549437314, 1.48398178896757, 1.58489319246111, 1.69266661503788, 1.80776867696343, 1.93069772888325, 2.06198600950222, 2.20220194998738, 2.35195263507096, 2.51188643150958, 2.68269579527973, 2.86512026966378, 3.05994968720720, 3.26802758941013, 3.49025487895958, 3.72759372031494, 3.98107170553497, 4.25178630338289, 4.54090961097248, 4.84969342852820, 5.17947467923121, 5.53168119761723, 5.90783791158795, 6.30957344480193, 6.73862716803095, 7.19685673001152, 7.68624610039774, 8.20891415963826, 8.76712387296868, 9.36329208823941, 10, 10.6800043251458, 11.4062492385132, 12.1818791201012, 13.0102521691083, 13.8949549437314, 14.8398178896756, 15.8489319246111, 16.9266661503788, 18.0776867696343, 19.3069772888325, 20.6198600950222, 22.0220194998738, 23.5195263507096, 25.1188643150958, 26.8269579527973, 28.6512026966378, 30.5994968720720, 32.6802758941013, 34.9025487895958, 37.2759372031494, 39.8107170553497, 42.5178630338289, 45.4090961097248, 48.4969342852820, 51.7947467923121, 55.3168119761723, 59.0783791158795, 63.0957344480193}; + +const LC3_FLOAT sns_preemph_24[64] = {1, 1.08372885005949, 1.17446822045126, 1.27280509398106, 1.37937560084995, 1.49486913370923, 1.62003280726413, 1.75567629127500, 1.90267704822016, 2.06198600950222, 2.23463372691659, 2.42173703917547, 2.62450629661210, 2.84425319080132, 3.08239923974514, 3.34048498351325, 3.62017994982380, 3.92329345403096, 4.25178630338289, 4.60778348126382, 4.99358789347315, 5.41169526546464, 5.86481028691437, 6.35586410805477, 6.88803330095657, 7.46476040841712, 8.08977621338348, 8.76712387296868, 9.50118507318144, 10.2967083735613, 11.1588399250775, 12.0931567600021, 13.1057028691062, 14.2030282995578, 15.3922315264422, 16.6810053720006, 18.0776867696343, 19.5913106945915, 21.2316686102078, 23.0093718077846, 24.9359200498416, 27.0237759607902, 29.2864456462524, 31.7385660625428, 34.3959997014966, 37.2759372031494, 40.3970085600588, 43.7794036326358, 47.4450027550866, 51.4175182768393, 55.7226479550717, 60.3882411906196, 65.4444791826252, 70.9240701673285, 76.8624610039774, 83.2980664765827, 90.2725177948458, 97.8309319017829, 106.022203330167, 114.899320495775, 124.519708473503, 134.945600473732, 146.244440421985, 158.489319246111}; + +const LC3_FLOAT sns_preemph_32[64] = {1, 1.09968889964399, 1.20931567600021, 1.32987102506290, 1.46244440421985, 1.60823387766704, 1.76855694330186, 1.94486243893736, 2.13874363543396, 2.35195263507096, 2.58641620527597, 2.84425319080132, 3.12779366170121, 3.43959997014966, 3.78248990638938, 4.15956216307185, 4.57422433810926, 5.03022372910014, 5.53168119761723, 6.08312840938905, 6.68954878691415, 7.35642254459641, 8.08977621338348, 8.89623710246182, 9.78309319017829, 10.7583589854218, 11.8308479546535, 13.0102521691083, 14.3072298919376, 15.7335018968185, 17.3019573884589, 19.0267704822017, 20.9235282953511, 23.0093718077846, 25.3031507648021, 27.8255940220712, 30.5994968720720, 33.6499270449086, 37.0044512451161, 40.6933842716715, 44.7500629725045, 49.2111475092328, 54.1169526546464, 59.5118121168741, 65.4444791826252, 71.9685673001152, 79.1430345832182, 87.0327166153056, 95.7089123677128, 105.250028527773, 115.742288059206, 127.280509398106, 139.968963326130, 153.922315264422, 169.266661503788, 186.140668735512, 204.696827180752, 225.102828643018, 247.543081937190, 272.220379389991, 299.357729472049, 329.200372123041, 362.017994982380, 398.107170553497}; + +const LC3_FLOAT sns_preemph_48[64] = {1, 1.11588399250775, 1.24519708473503, 1.38949549437314, 1.55051577983262, 1.73019573884589, 1.93069772888325, 2.15443469003188, 2.40409918350997, 2.68269579527973, 2.99357729472049, 3.34048498351325, 3.72759372031494, 4.15956216307185, 4.64158883361278, 5.17947467923121, 5.77969288415331, 6.44946677103762, 7.19685673001152, 8.03085722139151, 8.96150501946605, 10, 11.1588399250775, 12.4519708473503, 13.8949549437314, 15.5051577983262, 17.3019573884589, 19.3069772888325, 21.5443469003188, 24.0409918350997, 26.8269579527973, 29.9357729472049, 33.4048498351324, 37.2759372031494, 41.5956216307185, 46.4158883361278, 51.7947467923121, 57.7969288415332, 64.4946677103762, 71.9685673001152, 80.3085722139151, 89.6150501946605, 100, 111.588399250775, 124.519708473503, 138.949549437314, 155.051577983263, 173.019573884589, 193.069772888325, 215.443469003188, 240.409918350997, 268.269579527972, 299.357729472049, 334.048498351324, 372.759372031494, 415.956216307185, 464.158883361278, 517.947467923121, 577.969288415331, 644.946677103762, 719.685673001152, 803.085722139151, 896.150501946605, 1000}; + +const LC3_FLOAT sns_preemph_96[64] = {1, 1.13231759012767, 1.28214312491253, 1.45179321339972, 1.64389099276047, 1.86140668735512, 2.10770353447348, 2.38658978685858, 2.70237759607902, 3.05994968720720, 3.46483485573037, 3.92329345403096, 4.44241418923200, 5.03022372910014, 5.69581081073769, 6.44946677103762, 7.30284467178980, 8.26913947983772, 9.36329208823941, 10.6022203330167, 12.0050805774841, 13.5935639087853, 15.3922315264422, 17.4288945087081, 19.7350438286898, 22.3463372691659, 25.3031507648021, 28.6512026966378, 32.4422607917163, 36.7349425579696, 41.5956216307185, 47.0994540447575, 53.3315403002887, 60.3882411906196, 68.3786677370108, 77.4263682681127, 87.6712387296868, 99.2716857619066, 112.407075989833, 127.280509398106, 144.121959671886, 163.191830060146, 184.784979742229, 209.235282953511, 236.920791363601, 268.269579527972, 303.766363795677, 343.959997014966, 389.471954920307, 441.005945417674, 499.358789347315, 565.432740962822, 640.249438626305, 724.965701425931, 820.891415963825, 929.509789880649, 1052.50028527773, 1191.76458663437, 1349.45600473732, 1528.01277126748, 1730.19573884589, 1959.13106945914, 2218.35857131422, 2511.88643150958}; + +const LC3_FLOAT *sns_preemph_all[6] = {sns_preemph_8, sns_preemph_16, sns_preemph_24, sns_preemph_32, sns_preemph_48, sns_preemph_96}; + const LC3_FLOAT sns_vq_far_adj_gains_fl[8] = {1.05859375000000, 1.23706054687500, 1.43920898437500, 1.98950195312500, 2.49877929687500, 3.13110351562500, 4.11816406250000, 4.85400390625000}; @@ -983,6 +999,31 @@ const LC3_INT BW_cutoff_bits_all[MAX_BW_BANDS_NUMBER] = {0, 1, 2, 2, 3, 0}; const LC3_INT BW_cutoff_bin_all_5ms[MAX_BW_BANDS_NUMBER] = {40, 80, 120, 160, 200, 200}; const LC3_INT BW_cutoff_bin_all_2_5ms[MAX_BW_BANDS_NUMBER] = {20, 40, 60, 80, 100, 100}; +#ifdef CR8_G_ADD_75MS +const LC3_INT BW_cutoff_bin_all_7_5ms[] = {60, 120, 180, 240, 300, 300}; +const LC3_INT bands_number_7_5ms_HR [] = {60, 64, 64, 64, 64, 64}; +const LC3_INT bands_number_7_5ms [] = {60, 64, 64, 64, 64}; + +const LC3_INT BW_warp_idx_start_16k_7_5ms[4] = {51, 0, 0, 0}; +const LC3_INT BW_warp_idx_stop_16k_7_5ms[4] = {63, 0, 0, 0}; + +const LC3_INT BW_warp_idx_start_24k_7_5ms[4] = {45, 58, 0, 0}; +const LC3_INT BW_warp_idx_stop_24k_7_5ms[4] = {55, 63, 0, 0}; + +const LC3_INT BW_warp_idx_start_32k_7_5ms[4] = {42, 53, 60, 0}; +const LC3_INT BW_warp_idx_stop_32k_7_5ms[4] = {51, 58, 63, 0}; + +const LC3_INT BW_warp_idx_start_48k_7_5ms[4] = {40, 51, 57, 61}; +const LC3_INT BW_warp_idx_stop_48k_7_5ms[4] = {48, 55, 60, 63}; + +const LC3_INT brickwall_dist_7_5ms[4] = {4, 4, 3, 2}; + +const LC3_INT* BW_warp_idx_start_all_7_5ms[4] = {BW_warp_idx_start_16k_7_5ms, BW_warp_idx_start_24k_7_5ms, + BW_warp_idx_start_32k_7_5ms, BW_warp_idx_start_48k_7_5ms}; +const LC3_INT* BW_warp_idx_stop_all_7_5ms[4] = {BW_warp_idx_stop_16k_7_5ms, BW_warp_idx_stop_24k_7_5ms, + BW_warp_idx_stop_32k_7_5ms, BW_warp_idx_stop_48k_7_5ms}; +#endif + /* Arithmetic coding */ const LC3_INT tns_cf[8][18] = {{0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023, 1024}, {0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023, 1024}, @@ -998,6 +1039,2372 @@ const LC3_INT tns_freq_cf[2][9] = {{0, 3, 12, 35, 89, 200, 390, 658, 1024}, {0, /* MDCT Windows */ +#ifdef CR8_G_ADD_75MS + +const LC3_FLOAT MDCT_HRA_WINDOW_480_7_5ms[720] = { + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 6.809599915345237e-08, 2.716186708704376e-07, 6.424371293934969e-07, + 1.260808101892957e-06, 2.229378921489615e-06, 3.679074029772919e-06, 5.774505277720125e-06, 8.719889849723028e-06, + 1.276556063788606e-05, 1.821508881356302e-05, 2.543302196376427e-05, 3.485323086760931e-05, 4.698784831976895e-05, + 6.243677337396717e-05, 8.189770380196378e-05, 1.061766484618177e-04, 1.361988597286949e-04, 1.730201142776986e-04, + 2.178382584565609e-04, 2.720049223973359e-04, 3.370372950540977e-04, 4.146298406925523e-04, 5.066658261806472e-04, + 6.152285179265661e-04, 7.426118976760646e-04, 8.913307378108167e-04, 1.064129869478226e-03, 1.263992471022180e-03, + 1.494147199957892e-03, 1.758073989316892e-03, 2.059508328742228e-03, 2.402443852384859e-03, 2.791133059566779e-03, + 3.230086000439834e-03, 3.724066767561293e-03, 4.278087645481125e-03, 4.897400784114414e-03, 5.587487277846723e-03, + 6.354043550947961e-03, 7.202964970873775e-03, 8.140326634299601e-03, 9.172361296110928e-03, 1.030543443887801e-02, + 1.154601650935216e-02, 1.290065237897715e-02, 1.437592811702264e-02, 1.597843519739845e-02, 1.771473229314812e-02, + 1.959130484567766e-02, 2.161452262855616e-02, 2.379059555782150e-02, 2.612552803171593e-02, 2.862507211224012e-02, + 3.129467988842215e-02, 3.413945538633399e-02, 3.716410641324389e-02, 4.037289674248027e-02, 4.376959906123697e-02, + 4.735744911533900e-02, 5.113910149261011e-02, 5.511658748968899e-02, 5.929127550571237e-02, 6.366383440006920e-02, + 6.823420024032127e-02, 7.300154685033973e-02, 7.796426054773728e-02, 8.311991943385708e-02, 8.846527756905853e-02, + 9.399625433100661e-02, 9.970792921440458e-02, 1.055945422874181e-01, 1.116495004733158e-01, 1.178654910777398e-01, + 1.242343970754217e-01, 1.307472697698447e-01, 1.373944835632858e-01, 1.441657329773458e-01, 1.510500827600614e-01, + 1.580360226424669e-01, 1.651115279124688e-01, 1.722641255794418e-01, 1.794809657536407e-01, 1.867488977915941e-01, + 1.940545506994020e-01, 2.013844172328433e-01, 2.087249410855671e-01, 2.160626065146083e-01, 2.233840297164879e-01, + 2.306760512375861e-01, 2.379258286796330e-01, 2.451209289452065e-01, 2.522494192591140e-01, 2.592999561994307e-01, + 2.662618719765588e-01, 2.731252572097561e-01, 2.798810394677779e-01, 2.865210568632502e-01, 2.930381260187334e-01, + 2.994261037557683e-01, 3.056799418961772e-01, 3.117957346072421e-01, 3.177707577688937e-01, 3.236034998916132e-01, + 3.292936841683654e-01, 3.348422813026286e-01, 3.402515128176158e-01, 3.455248446193337e-01, 3.506669706583936e-01, + 3.556837866127393e-01, 3.605823535957678e-01, 3.653708519817664e-01, 3.700585255329578e-01, 3.746556161093967e-01, + 3.791732893437698e-01, 3.836235517669143e-01, 3.880191599752360e-01, 3.923735225365686e-01, 3.967005954344419e-01, + 4.010147719499705e-01, 4.053307679732117e-01, 4.096635038192941e-01, 4.140279836962412e-01, 4.184391740286457e-01, + 4.229118818818259e-01, 4.274606347526876e-01, 4.320995629945984e-01, 4.368422861229869e-01, 4.417018042055877e-01, + 4.466903954763946e-01, 4.518195212263102e-01, 4.570997389177666e-01, 4.625406243474134e-01, 4.681507035432432e-01, + 4.739373949335071e-01, 4.799069621682588e-01, 4.860644778142650e-01, 4.924137979843949e-01, 4.989575478073994e-01, + 5.056971174969224e-01, 5.126326686429926e-01, 5.197631502279640e-01, 5.270863237641458e-01, 5.345987968637925e-01, + 5.422960644846202e-01, 5.501725570458306e-01, 5.582216945803693e-01, 5.664359460778171e-01, 5.748068931775395e-01, + 5.833252973915712e-01, 5.919811700691291e-01, 6.007638443572958e-01, 6.096620484629849e-01, 6.186639795774059e-01, + 6.277573778837434e-01, 6.369296001295948e-01, 6.461676923061090e-01, 6.554584610342162e-01, 6.647885433136285e-01, + 6.741444743414929e-01, 6.835127531540456e-01, 6.928799058859592e-01, 7.022325464781733e-01, 7.115574346958600e-01, + 7.208415313440352e-01, 7.300720505895358e-01, 7.392365093150189e-01, 7.483227734438597e-01, 7.573191011847887e-01, + 7.662141831523945e-01, 7.749971793247219e-01, 7.836577528026495e-01, 7.921861003379914e-01, 8.005729795988183e-01, + 8.088097331417404e-01, 8.168883090622450e-01, 8.248012782960292e-01, 8.325418485469714e-01, 8.401038748212752e-01, + 8.474818665528070e-01, 8.546709913119690e-01, 8.616670751000000e-01, 8.684665992426276e-01, 8.750666939117441e-01, + 8.814651283214563e-01, 8.876602976655703e-01, 8.936512068873075e-01, 8.994374513987017e-01, 9.050191948964271e-01, + 9.103971444522861e-01, 9.155725230896603e-01, 9.205470400910444e-01, 9.253228593153561e-01, 9.299025658359243e-01, + 9.342891312395554e-01, 9.384858779525852e-01, 9.424964429799174e-01, 9.463247414564011e-01, 9.499749304154305e-01, + 9.534513731762839e-01, 9.567586047388893e-01, 9.599012985520849e-01, 9.628842349891718e-01, 9.657122718232282e-01, + 9.683903169452684e-01, 9.709233035123621e-01, 9.733161676521148e-01, 9.755738287865520e-01, 9.777011725747500e-01, + 9.797030364119408e-01, 9.815841973655319e-01, 9.833493623777330e-01, 9.850031605220572e-01, 9.865501370683191e-01, + 9.879947490888552e-01, 9.893413623279752e-01, 9.905942490570202e-01, 9.917575866483249e-01, 9.928354566216883e-01, + 9.938318439453252e-01, 9.947506364078684e-01, 9.955956239169538e-01, 9.963704976211798e-01, 9.970788487938620e-01, + 9.977241674570765e-01, 9.983098407613983e-01, 9.988391511690631e-01, 9.993152745149454e-01, 9.997412780400421e-01, + 1.000120118505655e+00, 1.000454640503141e+00, 1.000747575074179e+00, 1.001001538750552e+00, 1.001219033111063e+00, + 1.001402444937498e+00, 1.001554047032278e+00, 1.001675999738891e+00, 1.001770353183267e+00, 1.001839050231077e+00, + 1.001883930133431e+00, 1.001906732812431e+00, 1.001909103719272e+00, 1.001892599181639e+00, 1.001858692144366e+00, + 1.001808778198111e+00, 1.001744181785080e+00, 1.001666162468790e+00, 1.001575921156133e+00, 1.001474606164513e+00, + 1.001363319034069e+00, 1.001243119994661e+00, 1.001115033008877e+00, 1.000980050325283e+00, 1.000839136490102e+00, + 1.000693231779806e+00, 1.000543255031507e+00, 1.000390105861922e+00, 1.000234666278804e+00, 1.000077801700791e+00, + 9.999203614123487e-01, 9.997631784897281e-01, 9.996070692418051e-01, 9.994528322168238e-01, 9.993012468388005e-01, + 9.991530718675707e-01, 9.990090391528494e-01, 9.988698631596843e-01, 9.987362319429512e-01, 9.986087958497237e-01, + 9.984881744259831e-01, 9.983749534239558e-01, 9.982696819855041e-01, 9.981728700145615e-01, 9.980849857504854e-01, + 9.980064535530436e-01, 9.979376519085494e-01, 9.978789116654476e-01, 9.978305145064250e-01, 9.977926916628833e-01, + 9.977656228763698e-01, 9.977494356103552e-01, 9.977442045145120e-01, 9.977499511424820e-01, 9.977666439229387e-01, + 9.977941983826280e-01, 9.978324776189644e-01, 9.978812930187096e-01, 9.979404052182159e-01, 9.980095252997591e-01, + 9.980883162175314e-01, 9.981763944459758e-01, 9.982733318422902e-01, 9.983786577141155e-01, 9.984918610826710e-01, + 9.986123931308583e-01, 9.987396698251857e-01, 9.988730746997222e-01, 9.990119617896823e-01, 9.991556587016854e-01, + 9.993034698072086e-01, 9.994546795452566e-01, 9.996085558198406e-01, 9.997643534774231e-01, 9.999213178491362e-01, + 1.000078688342232e+00, 1.000235702064949e+00, 1.000391597468710e+00, 1.000545617991395e+00, 1.000697015685261e+00, + 1.000845054812993e+00, 1.000989015395319e+00, 1.001128196693676e+00, 1.001261920611439e+00, 1.001389534997449e+00, + 1.001510416835741e+00, 1.001623975305719e+00, 1.001729654697400e+00, 1.001826937166789e+00, 1.001915345317049e+00, + 1.001994444591742e+00, 1.002063845467139e+00, 1.002123205431461e+00, 1.002172230739781e+00, 1.002210677934335e+00, + 1.002238355121073e+00, 1.002255122994435e+00, 1.002260895603584e+00, 1.002255640854628e+00, 1.002239380744737e+00, + 1.002212191325473e+00, 1.002174202394129e+00, 1.002125596913369e+00, 1.002066610160972e+00, 1.001997528613025e+00, + 1.001918688565458e+00, 1.001830474500286e+00, 1.001733317204479e+00, 1.001627691650788e+00, 1.001514114651268e+00, + 1.001393142295620e+00, 1.001265367187681e+00, 1.001131415494648e+00, 1.000991943824643e+00, 1.000847635949292e+00, + 1.000699199388794e+00, 1.000547361877802e+00, 1.000392867731002e+00, 1.000236474127865e+00, 1.000078947336370e+00, + 9.999210588958194e-01, 9.997635817789274e-01, 9.996072865534386e-01, 9.994529375633210e-01, 9.993012891494056e-01, + 9.991530819289113e-01, 9.990090391528497e-01, 9.988698631596844e-01, 9.987362319429512e-01, 9.986087958497240e-01, + 9.984881744259831e-01, 9.983749534239558e-01, 9.982696819855044e-01, 9.981728700145615e-01, 9.980849857504854e-01, + 9.980064535530438e-01, 9.979376519085497e-01, 9.978789116654476e-01, 9.978305145064252e-01, 9.977926916628833e-01, + 9.977656228763698e-01, 9.977494356103552e-01, 9.977442045145120e-01, 9.977499511424820e-01, 9.977666439229387e-01, + 9.977941983826278e-01, 9.978324776189643e-01, 9.978812930187095e-01, 9.979404052182158e-01, 9.980095252997588e-01, + 9.980883162175312e-01, 9.981763944459756e-01, 9.982733318422901e-01, 9.983786577141153e-01, 9.984918610826709e-01, + 9.986123931308580e-01, 9.987396698251855e-01, 9.988730746997220e-01, 9.990119617896820e-01, 9.991556587016851e-01, + 9.993034698072083e-01, 9.994546795452562e-01, 9.996085558198403e-01, 9.997643534774228e-01, 9.999213178491358e-01, + 1.000078688342232e+00, 1.000235702064949e+00, 1.000391597468709e+00, 1.000545617991395e+00, 1.000697015685261e+00, + 1.000845054812992e+00, 1.000989015395319e+00, 1.001128196693676e+00, 1.001261920611439e+00, 1.001389534997449e+00, + 1.001510416835740e+00, 1.001623975305719e+00, 1.001729654697400e+00, 1.001826937166789e+00, 1.001915345317049e+00, + 1.001994444591742e+00, 1.002063845467139e+00, 1.002123205431461e+00, 1.002172230739781e+00, 1.002210677934335e+00, + 1.002238355121073e+00, 1.002255122994435e+00, 1.002260895603584e+00, 1.002255640854628e+00, 1.002239380744737e+00, + 1.002212191325473e+00, 1.002174202394129e+00, 1.002125596913369e+00, 1.002066610160972e+00, 1.001997528613026e+00, + 1.001918688565458e+00, 1.001830474500286e+00, 1.001733317204480e+00, 1.001627691650788e+00, 1.001514114651269e+00, + 1.001393142295620e+00, 1.001265367187681e+00, 1.001131415494648e+00, 1.000991943824644e+00, 1.000847625870882e+00, + 1.000699157018909e+00, 1.000547256415431e+00, 1.000392650246594e+00, 1.000236070641674e+00, 1.000078249725773e+00, + 9.999199133992033e-01, 9.997617746889341e-01, 9.996045266479927e-01, 9.994488347910435e-01, 9.992953290608048e-01, + 9.991445953265840e-01, 9.989971664237720e-01, 9.988535127515954e-01, 9.987140324557005e-01, 9.985790412319091e-01, + 9.984487617975299e-01, 9.983233130864525e-01, 9.982026992336113e-01, 9.980867984227458e-01, 9.979753516783147e-01, + 9.978679516874593e-01, 9.977640317406775e-01, 9.976628548799390e-01, 9.975635033400763e-01, 9.974648683632181e-01, + 9.973656404566504e-01, 9.972643001519088e-01, 9.971591093072504e-01, 9.970481029773169e-01, 9.969290818533281e-01, + 9.967996052552075e-01, 9.966569846345418e-01, 9.964982775252248e-01, 9.963202818581681e-01, 9.961195305388424e-01, + 9.958922861728758e-01, 9.956345358167873e-01, 9.953419856293327e-01, 9.950100553049441e-01, 9.946338721852209e-01, + 9.942082649678485e-01, 9.937277569649872e-01, 9.931865589047922e-01, 9.925785613196768e-01, 9.918973266220812e-01, + 9.911360810312226e-01, 9.902877065805247e-01, 9.893447335026750e-01, 9.882993333547356e-01, 9.871433133064559e-01, + 9.858681120677728e-01, 9.844647979734713e-01, 9.829240697712801e-01, 9.812362606719703e-01, 9.793913462143841e-01, + 9.773789564736696e-01, 9.751883930968924e-01, 9.728086515871036e-01, 9.702284491761823e-01, 9.674362585304656e-01, + 9.644203474241703e-01, 9.611688243973939e-01, 9.576696902919403e-01, 9.539108954335166e-01, 9.498804021071905e-01, + 9.455662518583811e-01, 9.409566370477763e-01, 9.360399759985500e-01, 9.308049910005284e-01, 9.252407883802984e-01, + 9.193369398095318e-01, 9.130835640061534e-01, 9.064714079838252e-01, 8.994919270231900e-01, 8.921373625716933e-01, + 8.844008173252615e-01, 8.762763268021769e-01, 8.677589267845028e-01, 8.588447160727389e-01, 8.495309140724763e-01, + 8.398159128053756e-01, 8.296993230087498e-01, 8.191820140566964e-01, 8.082661474997362e-01, 7.969552040782567e-01, + 7.852540041171052e-01, 7.731687212540459e-01, 7.607068894934714e-01, 7.478774036088883e-01, 7.346905129436833e-01, + 7.211578086800342e-01, 7.072922046612431e-01, 6.931079118639383e-01, 6.786204066243602e-01, 6.638463927281081e-01, + 6.488037574761728e-01, 6.335115218426407e-01, 6.179897848420400e-01, 6.022596622277155e-01, 5.863432196477422e-01, + 5.702634003925362e-01, 5.540439478792599e-01, 5.377093230331162e-01, 5.212846167453395e-01, 5.047954576127168e-01, + 4.882679151942771e-01, 4.717283990576996e-01, 4.552035539311637e-01, 4.387201513257116e-01, 4.223049780484175e-01, + 4.059847220871455e-01, 3.897858564125437e-01, 3.737345213109408e-01, 3.578564059314520e-01, 3.421766298000327e-01, + 3.267196251203117e-01, 3.115090207434621e-01, 2.965675287446095e-01, 2.819168345887702e-01, 2.675774919024606e-01, + 2.535688228855250e-01, 2.399088253991666e-01, 2.266140877488131e-01, 2.136997121429473e-01, 2.011792477505556e-01, + 1.890646342002475e-01, 1.773661562639070e-01, 1.660924103481652e-01, 1.552502832800154e-01, 1.448449437210769e-01, + 1.348798463815727e-01, 1.253567490336474e-01, 1.162757421482153e-01, 1.076352908043133e-01, 9.943228834915691e-02, + 9.166212112492260e-02, 8.431874342855604e-02, 7.739476173713079e-02, 7.088152711641457e-02, 6.476923463670382e-02, + 5.904702854937628e-02, 5.370311193097759e-02, 4.872485947931735e-02, 4.409893214762228e-02, 3.981139232728093e-02, + 3.584781833555012e-02, 3.219341702973252e-02, 2.883313345136149e-02, 2.575175650013100e-02, 2.293401974481060e-02, + 2.036469659423059e-02, 1.802868917267256e-02, 1.591111036782373e-02, 1.399735864319379e-02, 1.227318532813230e-02, + 1.072475421518567e-02, 9.338693404676062e-03, 8.102139438575821e-03, 7.002773858835369e-03, 6.028852408470130e-03, + 5.169227166401885e-03, 4.413361969047579e-03, 3.751341522971312e-03, 3.173874653799314e-03, 2.672292167462025e-03, + 2.238539821235712e-03, 1.865166914682179e-03, 1.545311015180633e-03, 1.272679330109336e-03, 1.041527228687644e-03, + 8.466344018536364e-04, 6.832791291344422e-04, 5.472110980420254e-04, 4.346231948339177e-04, 3.421226562082296e-04, + 2.667019402979896e-04, 2.057096427837635e-04, 1.568217505967225e-04, 1.180134920282553e-04, 8.753200853960576e-05, + 6.387004057159679e-05, 4.574078753977487e-05, 3.205407126647298e-05, 2.189390259660641e-05, 1.449752303895666e-05, + 9.235966977587421e-06, 5.596164823995474e-06, 3.164580913106852e-06, 1.612338255148207e-06, 6.816185333295410e-07, + 1.708705677347936e-07, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; + +const LC3_FLOAT MDCT_HRA_WINDOW_960_7_5ms[1440] = { + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 4.814997152662380e-08, + 1.190718835543930e-07, 2.207853347953071e-07, 3.606855997228003e-07, 5.473208818980691e-07, 7.905197136719171e-07, + 1.101521714920831e-06, 1.493116418344220e-06, 1.979790786588690e-06, 2.577885657879143e-06, 3.305761290579034e-06, + 4.183972154098288e-06, 5.235451095160501e-06, 6.485702988281604e-06, 7.963007956558409e-06, 9.698634223646832e-06, + 1.172706063036777e-05, 1.408620881991443e-05, 1.681768506430009e-05, 1.996703167159834e-05, 2.358398787878628e-05, + 2.772276009869224e-05, 3.244230135176009e-05, 3.780659967415316e-05, 4.388497525322647e-05, 5.075238599968363e-05, + 5.848974122290910e-05, 6.718422303212972e-05, 7.692961504132544e-05, 8.782663791029826e-05, 9.998329120814524e-05, + 1.135152010387006e-04, 1.285459728204526e-04, 1.452075485661517e-04, 1.636405679599540e-04, 1.839947324826567e-04, + 2.064291717885308e-04, 2.311128114906271e-04, 2.582247414653769e-04, 2.879545837420285e-04, 3.205028589981173e-04, + 3.560813506389657e-04, 3.949134653973109e-04, 4.372345893487853e-04, 4.832924382002834e-04, 5.333474006714636e-04, + 5.876728737549225e-04, 6.465555886081460e-04, 7.102959258003701e-04, 7.792082186101814e-04, 8.536210430451991e-04, + 9.338774932337428e-04, 1.020335440820132e-03, 1.113367776980400e-03, 1.213362635663867e-03, 1.320723596658401e-03, + 1.435869867073428e-03, 1.559236439835012e-03, 1.691274227791697e-03, 1.832450172038491e-03, 1.983247323079433e-03, + 2.144164893466752e-03, 2.315718280576775e-03, 2.498439058209637e-03, 2.692874935731413e-03, 2.899589683513746e-03, + 3.119163023467312e-03, 3.352190483511667e-03, 3.599283214875066e-03, 3.861067771173851e-03, 4.138185848281871e-03, + 4.431293984066133e-03, 4.741063217135362e-03, 5.068178703823501e-03, 5.413339292709984e-03, 5.777257056063160e-03, + 6.160656777682084e-03, 6.564275396705108e-03, 6.988861407050997e-03, 7.435174212259442e-03, 7.903983435603223e-03, + 8.396068185452360e-03, 8.912216275983018e-03, 9.453223403438580e-03, 1.001989227826831e-02, 1.061303171358943e-02, + 1.123345567054105e-02, 1.188198226122286e-02, 1.255943271003813e-02, 1.326663027438758e-02, 1.400439912578959e-02, + 1.477356319263120e-02, 1.557494496588335e-02, 1.640936426924359e-02, 1.727763699529732e-02, 1.818057380941704e-02, + 1.911897882324480e-02, 2.009364823972783e-02, 2.110536897180007e-02, 2.215491723692114e-02, 2.324305712980262e-02, + 2.437053917576323e-02, 2.553809886726559e-02, 2.674645518629135e-02, 2.799630911531313e-02, 2.928834213971679e-02, + 3.062321474461790e-02, 3.200156490910068e-02, 3.342400660098604e-02, 3.489112827530663e-02, 3.640349137973180e-02, + 3.796162887024292e-02, 3.956604374040874e-02, 4.121720756765420e-02, 4.291555907994722e-02, 4.466150274635713e-02, + 4.645540739495172e-02, 4.829760486151040e-02, 5.018838867252923e-02, 5.212801276598264e-02, 5.411669025328793e-02, + 5.615459222588953e-02, 5.824184660984119e-02, 6.037853707171543e-02, 6.256470197911304e-02, 6.480033341897713e-02, + 6.708537627683842e-02, 6.941972738003349e-02, 7.180323470784016e-02, 7.423569667136878e-02, 7.671686146593476e-02, + 7.924642649851196e-02, 8.182403789273630e-02, 8.444929007378586e-02, 8.712172543531613e-02, 8.984083409047044e-02, + 9.260605370882179e-02, 9.541676944092861e-02, 9.827231393200973e-02, 1.011719674260564e-01, 1.041149579615082e-01, + 1.071004616594233e-01, 1.101276031048689e-01, 1.131954558220525e-01, 1.163031145055895e-01, 1.194495144788202e-01, + 1.226335917234308e-01, 1.258542330378917e-01, 1.291102796186627e-01, 1.324005282765081e-01, 1.357237327475410e-01, + 1.390786051045917e-01, 1.424638172681925e-01, 1.458780026156580e-01, 1.493197576864202e-01, 1.527876439815144e-01, + 1.562801898548664e-01, 1.597958924937929e-01, 1.633332199858745e-01, 1.668906134691307e-01, 1.704664893621876e-01, + 1.740592416709001e-01, 1.776672443676665e-01, 1.812888538394568e-01, 1.849224114003725e-01, 1.885662458643452e-01, + 1.922186761734047e-01, 1.958780140767561e-01, 1.995425668557404e-01, 2.032106400895931e-01, 2.068805404567710e-01, + 2.105505785664793e-01, 2.142190718149099e-01, 2.178843472605934e-01, 2.215447445131696e-01, 2.251986186298022e-01, + 2.288443430133839e-01, 2.324803123066372e-01, 2.361049452761597e-01, 2.397166876804412e-01, 2.433140151158676e-01, + 2.468954358347107e-01, 2.504594935291377e-01, 2.540047700752680e-01, 2.575298882313734e-01, 2.610335142843411e-01, + 2.645143606385947e-01, 2.679711883417369e-01, 2.714028095412598e-01, 2.748080898667649e-01, 2.781859507322435e-01, + 2.815353715530788e-01, 2.848553918725547e-01, 2.881451133928004e-01, 2.914037019052332e-01, 2.946303891157192e-01, + 2.978244743598311e-01, 3.009853262037530e-01, 3.041123839265586e-01, 3.072051588797733e-01, 3.102632357203233e-01, + 3.132862735131834e-01, 3.162740067002296e-01, 3.192262459320352e-01, 3.221428787595638e-01, 3.250238701829489e-01, + 3.278692630547906e-01, 3.306791783356554e-01, 3.334538151997121e-01, 3.361934509887193e-01, 3.388984410128472e-01, + 3.415692181971050e-01, 3.442062925724498e-01, 3.468102506109446e-01, 3.493817544046665e-01, 3.519215406883794e-01, + 3.544304197063321e-01, 3.569092739238819e-01, 3.593590565850064e-01, 3.617807901171322e-01, 3.641755643850764e-01, + 3.665445347962969e-01, 3.688889202600189e-01, 3.712100010032212e-01, 3.735091162468620e-01, 3.757876617461321e-01, + 3.780470871989401e-01, 3.802888935272475e-01, 3.825146300362834e-01, 3.847258914570857e-01, 3.869243148782224e-01, + 3.891115765729500e-01, 3.912893887284619e-01, 3.934594960842652e-01, 3.956236724870978e-01, 3.977837173701507e-01, + 3.999414521646988e-01, 4.020987166525755e-01, 4.042573652681952e-01, 4.064192633591230e-01, 4.085862834144205e-01, + 4.107603012702034e-01, 4.129431923020324e-01, 4.151368276138986e-01, 4.173430702336651e-01, 4.195637713248997e-01, + 4.218007664250568e-01, 4.240558717199467e-01, 4.263308803643829e-01, 4.286275588587793e-01, 4.309476434913423e-01, + 4.332928368553010e-01, 4.356648044503836e-01, 4.380651713774884e-01, 4.404955191351588e-01, 4.429573825261284e-01, + 4.454522466818012e-01, 4.479815442120949e-01, 4.505466524876126e-01, 4.531488910606020e-01, 4.557895192306389e-01, + 4.584697337604117e-01, 4.611906667464130e-01, 4.639533836487439e-01, 4.667588814836276e-01, 4.696080871816153e-01, + 4.725018561138271e-01, 4.754409707879499e-01, 4.784261397150824e-01, 4.814579964478883e-01, 4.845370987899071e-01, + 4.876639281752684e-01, 4.908388892174636e-01, 4.940623094252686e-01, 4.973344390833572e-01, 5.006554512946366e-01, + 5.040254421808312e-01, 5.074444312373949e-01, 5.109123618383964e-01, 5.144291018866259e-01, 5.179944446038284e-01, + 5.216081094556281e-01, 5.252697432054461e-01, 5.289789210914528e-01, 5.327351481204011e-01, 5.365378604720108e-01, + 5.403864270074484e-01, 5.442801508753474e-01, 5.482182712087564e-01, 5.521999649063806e-01, 5.562243484914785e-01, + 5.602904800418288e-01, 5.643973611842344e-01, 5.685439391471354e-01, 5.727291088650085e-01, 5.769517151283868e-01, + 5.812105547734755e-01, 5.855043789055335e-01, 5.898318951503732e-01, 5.941917699285435e-01, 5.985826307469763e-01, + 6.030030685030957e-01, 6.074516397966441e-01, 6.119268692446796e-01, 6.164272517954765e-01, 6.209512550372698e-01, + 6.254973214980470e-01, 6.300638709328106e-01, 6.346493025949689e-01, 6.392519974887557e-01, 6.438703205997779e-01, + 6.485026231010093e-01, 6.531472445317767e-01, 6.578025149474425e-01, 6.624667570377041e-01, 6.671382882115985e-01, + 6.718154226474637e-01, 6.764964733062689e-01, 6.811797539068755e-01, 6.858635808619125e-01, 6.905462751730997e-01, + 6.952261642849390e-01, 6.999015838958201e-01, 7.045708797256799e-01, 7.092324092394289e-01, 7.138845433254541e-01, + 7.185256679285629e-01, 7.231541856368034e-01, 7.277685172216439e-01, 7.323671031310492e-01, 7.369484049350288e-01, + 7.415109067232617e-01, 7.460531164544494e-01, 7.505735672570528e-01, 7.550708186811053e-01, 7.595434579008099e-01, + 7.639901008676322e-01, 7.684093934136257e-01, 7.728000123047261e-01, 7.771606662437623e-01, 7.814900968229372e-01, + 7.857870794255352e-01, 7.900504240766176e-01, 7.942789762424746e-01, 7.984716175785987e-01, 8.026272666259650e-01, + 8.067448794553850e-01, 8.108234502597368e-01, 8.148620118938579e-01, 8.188596363619152e-01, 8.228154352520715e-01, + 8.267285601182841e-01, 8.305982028090957e-01, 8.344235957432927e-01, 8.382040121323370e-01, 8.419387661495058e-01, + 8.456272130457134e-01, 8.492687492120119e-01, 8.528628121888369e-01, 8.564088806220885e-01, 8.599064741662098e-01, + 8.633551533344737e-01, 8.667545192967644e-01, 8.701042136252025e-01, 8.734039179880492e-01, 8.766533537923937e-01, + 8.798522817762424e-01, 8.830005015507004e-01, 8.860978510930465e-01, 8.891442061916122e-01, 8.921394798434883e-01, + 8.950836216061893e-01, 8.979766169045416e-01, 9.008184862941767e-01, 9.036092846831453e-01, 9.063491005132949e-01, + 9.090380549031886e-01, 9.116763007544754e-01, 9.142640218237603e-01, 9.168014317621422e-01, 9.192887731247262e-01, + 9.217263163525492e-01, 9.241143587294502e-01, 9.264532233165643e-01, 9.287432578672022e-01, 9.309848337249814e-01, + 9.331783447081556e-01, 9.353242059831766e-01, 9.374228529305666e-01, 9.394747400062335e-01, 9.414803396013999e-01, + 9.434401409043077e-01, 9.453546487668929e-01, 9.472243825795639e-01, 9.490498751572118e-01, 9.508316716394957e-01, + 9.525703284083868e-01, 9.542664120258422e-01, 9.559204981943715e-01, 9.575331707431241e-01, 9.591050206419620e-01, + 9.606366450458275e-01, 9.621286463715110e-01, 9.635816314087369e-01, 9.649962104672655e-01, 9.663729965614801e-01, + 9.677126046337026e-01, 9.690156508172226e-01, 9.702827517397986e-01, 9.715145238681151e-01, 9.727115828934468e-01, + 9.738745431585201e-01, 9.750040171253210e-01, 9.761006148833546e-01, 9.771649436976386e-01, 9.781976075954760e-01, + 9.791992069908698e-01, 9.801703383452239e-01, 9.811115938628175e-01, 9.820235612193683e-01, 9.829068233218750e-01, + 9.837619580977977e-01, 9.845895383115438e-01, 9.853901314061559e-01, 9.861642993680373e-01, 9.869125986125210e-01, + 9.876355798880896e-01, 9.883337881970466e-01, 9.890077627304957e-01, 9.896580368155167e-01, 9.902851378725152e-01, + 9.908895873808024e-01, 9.914719008505681e-01, 9.920325877995377e-01, 9.925721517327187e-01, 9.930910901238019e-01, + 9.935898943969245e-01, 9.940690499076552e-01, 9.945290359222332e-01, 9.949703255942541e-01, 9.953933859381526e-01, + 9.957986777990047e-01, 9.961866558183331e-01, 9.965577683957455e-01, 9.969124576463969e-01, 9.972511593543985e-01, + 9.975743029224325e-01, 9.978823113179629e-01, 9.981756010165178e-01, 9.984545819426528e-01, 9.987196574092618e-01, + 9.989712240559885e-01, 9.992096717875499e-01, 9.994353837128311e-01, 9.996487360856312e-01, 9.998500982479841e-01, + 1.000039832576952e+00, 1.000218294435816e+00, 1.000385832130536e+00, 1.000542786872366e+00, 1.000689492747415e+00, + 1.000826276693953e+00, 1.000953458488153e+00, 1.001071350738924e+00, 1.001180258892415e+00, 1.001280481246664e+00, + 1.001372308976828e+00, 1.001456026171296e+00, 1.001531909878933e+00, 1.001600230167594e+00, 1.001661250193955e+00, + 1.001715226284630e+00, 1.001762408028438e+00, 1.001803038379606e+00, 1.001837353771603e+00, 1.001865584241233e+00, + 1.001887953562516e+00, 1.001904679389828e+00, 1.001915973409726e+00, 1.001922041500763e+00, 1.001923083900631e+00, + 1.001919295379834e+00, 1.001910865421132e+00, 1.001897978403901e+00, 1.001880813792572e+00, 1.001859546328272e+00, + 1.001834346222781e+00, 1.001805379353926e+00, 1.001772807461511e+00, 1.001736788342922e+00, 1.001697476047539e+00, + 1.001655021069100e+00, 1.001609570535228e+00, 1.001561268393305e+00, 1.001510255591984e+00, 1.001456670257582e+00, + 1.001400647864737e+00, 1.001342321400680e+00, 1.001281821522569e+00, 1.001219276707368e+00, 1.001154813393807e+00, + 1.001088556116027e+00, 1.001020627628542e+00, 1.000951149022254e+00, 1.000880239831253e+00, 1.000808018130249e+00, + 1.000734600622500e+00, 1.000660102718162e+00, 1.000584638603047e+00, 1.000508321297830e+00, 1.000431262707766e+00, + 1.000353573663063e+00, 1.000275363950073e+00, 1.000196742333506e+00, 1.000117816569928e+00, 1.000038693412811e+00, + 9.999594786094657e-01, 9.998802768901784e-01, 9.998011919499361e-01, 9.997223264231200e-01, 9.996437818515729e-01, + 9.995656586464663e-01, 9.994880560443949e-01, 9.994110720581462e-01, 9.993348034225887e-01, 9.992593455361456e-01, + 9.991847923983630e-01, 9.991112365446738e-01, 9.990387692132843e-01, 9.989674755310745e-01, 9.988974493950561e-01, + 9.988287760995599e-01, 9.987615392519850e-01, 9.986958206712464e-01, 9.986317002885794e-01, 9.985692560508309e-01, + 9.985085638263473e-01, 9.984496973135677e-01, 9.983927279524338e-01, 9.983377248387103e-01, 9.982847546413267e-01, + 9.982338815228151e-01, 9.981851670629547e-01, 9.981386701856864e-01, 9.980944470893998e-01, 9.980525511806362e-01, + 9.980130330113137e-01, 9.979759402195160e-01, 9.979413174739102e-01, 9.979092064218532e-01, 9.978796456412409e-01, + 9.978526705961338e-01, 9.978283135962164e-01, 9.978066037601111e-01, 9.977875669825975e-01, 9.977712259057413e-01, + 9.977575998939762e-01, 9.977467050131418e-01, 9.977385540135004e-01, 9.977331563167335e-01, 9.977305180069234e-01, + 9.977306418255271e-01, 9.977335271703227e-01, 9.977391700983312e-01, 9.977475633326937e-01, 9.977586962734870e-01, + 9.977725550124530e-01, 9.977891223516203e-01, 9.978083778257809e-01, 9.978302977287913e-01, 9.978548551436590e-01, + 9.978820199763681e-01, 9.979117589934062e-01, 9.979440358629286e-01, 9.979788111995230e-01, 9.980160426125044e-01, + 9.980556847576850e-01, 9.980976893925572e-01, 9.981420054348167e-01, 9.981885790241626e-01, 9.982373535872919e-01, + 9.982882699060266e-01, 9.983412661884745e-01, 9.983962781431597e-01, 9.984532390560278e-01, 9.985120798702389e-01, + 9.985727292686638e-01, 9.986351137589832e-01, 9.986991577612992e-01, 9.987647836981626e-01, 9.988319120869124e-01, + 9.989004616342260e-01, 9.989703493327806e-01, 9.990414905599119e-01, 9.991137991781697e-01, 9.991871876376540e-01, + 9.992615670800187e-01, 9.993368474440421e-01, 9.994129375726286e-01, 9.994897453211379e-01, 9.995671776669227e-01, + 9.996451408199485e-01, 9.997235403343790e-01, 9.998022812210010e-01, 9.998812680603694e-01, 9.999604051165407e-01, + 1.000039596451276e+00, 1.000118746038578e+00, 1.000197757879446e+00, 1.000276536116704e+00, 1.000354985149791e+00, + 1.000433009749368e+00, 1.000510515171617e+00, 1.000587407272111e+00, 1.000663592619100e+00, 1.000738978606112e+00, + 1.000813473563716e+00, 1.000886986870324e+00, 1.000959429061901e+00, 1.001030711940457e+00, 1.001100748681180e+00, + 1.001169453938098e+00, 1.001236743948124e+00, 1.001302536633371e+00, 1.001366751701609e+00, 1.001429310744728e+00, + 1.001490137335098e+00, 1.001549157119701e+00, 1.001606297911910e+00, 1.001661489780803e+00, 1.001714665137891e+00, + 1.001765758821160e+00, 1.001814708176293e+00, 1.001861453134992e+00, 1.001905936290265e+00, 1.001948102968611e+00, + 1.001987901298963e+00, 1.002025282278336e+00, 1.002060199834045e+00, 1.002092610882449e+00, 1.002122475384096e+00, + 1.002149756395215e+00, 1.002174420115472e+00, 1.002196435931912e+00, 1.002215776459027e+00, 1.002232417574884e+00, + 1.002246338453259e+00, 1.002257521591717e+00, 1.002265952835595e+00, 1.002271621397855e+00, 1.002274519874744e+00, + 1.002274644257259e+00, 1.002271993938374e+00, 1.002266571716010e+00, 1.002258383791734e+00, 1.002247439765192e+00, + 1.002233752624241e+00, 1.002217338730821e+00, 1.002198217802551e+00, 1.002176412890066e+00, 1.002151950350129e+00, + 1.002124859814529e+00, 1.002095174154815e+00, 1.002062929442886e+00, 1.002028164907501e+00, 1.001990922886739e+00, + 1.001951248776490e+00, 1.001909190975020e+00, 1.001864800823684e+00, 1.001818132543870e+00, 1.001769243170239e+00, + 1.001718192480350e+00, 1.001665042920779e+00, 1.001609859529789e+00, 1.001552709856694e+00, 1.001493663877992e+00, + 1.001432793910387e+00, 1.001370174520822e+00, 1.001305882433629e+00, 1.001239996434927e+00, 1.001172597274394e+00, + 1.001103767564540e+00, 1.001033591677623e+00, 1.000962155640339e+00, 1.000889547026422e+00, 1.000815854847318e+00, + 1.000741169441052e+00, 1.000665582359457e+00, 1.000589186253905e+00, 1.000512074759701e+00, 1.000434342379282e+00, + 1.000356084364390e+00, 1.000277396597363e+00, 1.000198375471716e+00, 1.000119117772151e+00, 1.000039720554179e+00, + 9.999602810234808e-01, 9.998808964152024e-01, 9.998016638733073e-01, 9.997226803301702e-01, 9.996440423865509e-01, + 9.995658461921156e-01, 9.994881873266507e-01, 9.994111606821270e-01, 9.993348603457636e-01, 9.992593794842417e-01, + 9.991848102292076e-01, 9.991112435642227e-01, 9.990387692132843e-01, 9.989674755310747e-01, 9.988974493950561e-01, + 9.988287760995599e-01, 9.987615392519850e-01, 9.986958206712466e-01, 9.986317002885796e-01, 9.985692560508309e-01, + 9.985085638263473e-01, 9.984496973135679e-01, 9.983927279524338e-01, 9.983377248387103e-01, 9.982847546413269e-01, + 9.982338815228151e-01, 9.981851670629547e-01, 9.981386701856864e-01, 9.980944470893998e-01, 9.980525511806362e-01, + 9.980130330113137e-01, 9.979759402195162e-01, 9.979413174739102e-01, 9.979092064218532e-01, 9.978796456412409e-01, + 9.978526705961338e-01, 9.978283135962164e-01, 9.978066037601111e-01, 9.977875669825975e-01, 9.977712259057413e-01, + 9.977575998939762e-01, 9.977467050131418e-01, 9.977385540135004e-01, 9.977331563167335e-01, 9.977305180069234e-01, + 9.977306418255271e-01, 9.977335271703227e-01, 9.977391700983312e-01, 9.977475633326937e-01, 9.977586962734870e-01, + 9.977725550124529e-01, 9.977891223516203e-01, 9.978083778257809e-01, 9.978302977287912e-01, 9.978548551436589e-01, + 9.978820199763679e-01, 9.979117589934061e-01, 9.979440358629285e-01, 9.979788111995229e-01, 9.980160426125043e-01, + 9.980556847576849e-01, 9.980976893925571e-01, 9.981420054348165e-01, 9.981885790241625e-01, 9.982373535872917e-01, + 9.982882699060264e-01, 9.983412661884743e-01, 9.983962781431595e-01, 9.984532390560276e-01, 9.985120798702387e-01, + 9.985727292686636e-01, 9.986351137589830e-01, 9.986991577612990e-01, 9.987647836981624e-01, 9.988319120869121e-01, + 9.989004616342257e-01, 9.989703493327803e-01, 9.990414905599115e-01, 9.991137991781693e-01, 9.991871876376537e-01, + 9.992615670800183e-01, 9.993368474440417e-01, 9.994129375726283e-01, 9.994897453211377e-01, 9.995671776669224e-01, + 9.996451408199482e-01, 9.997235403343787e-01, 9.998022812210007e-01, 9.998812680603690e-01, 9.999604051165404e-01, + 1.000039596451276e+00, 1.000118746038578e+00, 1.000197757879445e+00, 1.000276536116703e+00, 1.000354985149791e+00, + 1.000433009749367e+00, 1.000510515171617e+00, 1.000587407272111e+00, 1.000663592619099e+00, 1.000738978606111e+00, + 1.000813473563715e+00, 1.000886986870324e+00, 1.000959429061901e+00, 1.001030711940456e+00, 1.001100748681180e+00, + 1.001169453938098e+00, 1.001236743948123e+00, 1.001302536633371e+00, 1.001366751701609e+00, 1.001429310744728e+00, + 1.001490137335098e+00, 1.001549157119701e+00, 1.001606297911910e+00, 1.001661489780802e+00, 1.001714665137891e+00, + 1.001765758821160e+00, 1.001814708176293e+00, 1.001861453134991e+00, 1.001905936290265e+00, 1.001948102968610e+00, + 1.001987901298963e+00, 1.002025282278336e+00, 1.002060199834045e+00, 1.002092610882449e+00, 1.002122475384096e+00, + 1.002149756395215e+00, 1.002174420115472e+00, 1.002196435931912e+00, 1.002215776459027e+00, 1.002232417574884e+00, + 1.002246338453259e+00, 1.002257521591717e+00, 1.002265952835595e+00, 1.002271621397855e+00, 1.002274519874744e+00, + 1.002274644257259e+00, 1.002271993938374e+00, 1.002266571716010e+00, 1.002258383791734e+00, 1.002247439765192e+00, + 1.002233752624241e+00, 1.002217338730821e+00, 1.002198217802551e+00, 1.002176412890066e+00, 1.002151950350129e+00, + 1.002124859814529e+00, 1.002095174154815e+00, 1.002062929442886e+00, 1.002028164907501e+00, 1.001990922886739e+00, + 1.001951248776490e+00, 1.001909190975020e+00, 1.001864800823684e+00, 1.001818132543870e+00, 1.001769243170239e+00, + 1.001718192480350e+00, 1.001665042920779e+00, 1.001609859529789e+00, 1.001552709856694e+00, 1.001493663877992e+00, + 1.001432793910387e+00, 1.001370174520822e+00, 1.001305882433629e+00, 1.001239996434927e+00, 1.001172597274394e+00, + 1.001103767564540e+00, 1.001033591677624e+00, 1.000962155640339e+00, 1.000889539994377e+00, 1.000815836987349e+00, + 1.000741135442554e+00, 1.000665525360320e+00, 1.000589097525086e+00, 1.000511943342175e+00, 1.000434154669159e+00, + 1.000355823641039e+00, 1.000277042489024e+00, 1.000197903352750e+00, 1.000118498085805e+00, 1.000038918054429e+00, + 9.999592539292592e-01, 9.998795954700279e-01, 9.998000313030908e-01, 9.997206486917303e-01, 9.996415332991556e-01, + 9.995627689441696e-01, 9.994844373494816e-01, 9.994066178826749e-01, 9.993293872898719e-01, 9.992528194221602e-01, + 9.991769849548788e-01, 9.991019510999088e-01, 9.990277813111228e-01, 9.989545349832153e-01, 9.988822671441485e-01, + 9.988110281415057e-01, 9.987408633230653e-01, 9.986718127119733e-01, 9.986039106768975e-01, 9.985371855976206e-01, + 9.984716595265433e-01, 9.984073478466060e-01, 9.983442589261942e-01, 9.982823937715852e-01, 9.982217456775688e-01, + 9.981622998768528e-01, 9.981040331889378e-01, 9.980469136691089e-01, 9.979909002582600e-01, 9.979359424342189e-01, + 9.978819798653003e-01, 9.978289420667763e-01, 9.977767480609429e-01, 9.977253060414770e-01, 9.976745130427335e-01, + 9.976242546146024e-01, 9.975744045035392e-01, 9.975248243403034e-01, 9.974753633349420e-01, 9.974258579794437e-01, + 9.973761317584910e-01, 9.973259948686257e-01, 9.972752439461025e-01, 9.972236618036201e-01, 9.971710171760355e-01, + 9.971170644751025e-01, 9.970615435531658e-01, 9.970041794756773e-01, 9.969446823022998e-01, 9.968827468762742e-01, + 9.968180526216487e-01, 9.967502633478675e-01, 9.966790270611490e-01, 9.966039757819899e-01, 9.965247253680732e-01, + 9.964408753417748e-01, 9.963520087214246e-01, 9.962576918554058e-01, 9.961574742581648e-01, 9.960508884471466e-01, + 9.959374497796830e-01, 9.958166562888472e-01, 9.956879885173003e-01, 9.955509093482032e-01, 9.954048638322855e-01, + 9.952492790102677e-01, 9.950835637298708e-01, 9.949071084567831e-01, 9.947192850790569e-01, 9.945194467045426e-01, + 9.943069274511299e-01, 9.940810422297355e-01, 9.938410865201561e-01, 9.935863361401250e-01, 9.933160470081145e-01, + 9.930294549006624e-01, 9.927257752052461e-01, 9.924042026699723e-01, 9.920639111516145e-01, 9.917040533637881e-01, + 9.913237606273204e-01, 9.909221426251413e-01, 9.904982871642726e-01, 9.900512599477517e-01, 9.895801043595820e-01, + 9.890838412660165e-01, 9.885614688367104e-01, 9.880119623894829e-01, 9.874342742625883e-01, 9.868273337185698e-01, + 9.861900468838825e-01, 9.855212967285775e-01, 9.848199430904010e-01, 9.840848227476926e-01, 9.833147495454723e-01, + 9.825085145790535e-01, 9.816648864394526e-01, 9.807826115247470e-01, 9.798604144213754e-01, 9.788969983591844e-01, + 9.778910457438047e-01, 9.768412187696544e-01, 9.757461601165864e-01, 9.746044937328510e-01, 9.734148257066850e-01, + 9.721757452284399e-01, 9.708858256447525e-01, 9.695436256058197e-01, 9.681476903063706e-01, 9.666965528204767e-01, + 9.651887355298391e-01, 9.636227516447159e-01, 9.619971068161570e-01, 9.603103008377231e-01, 9.585608294343847e-01, + 9.567471861358257e-01, 9.548678642309127e-01, 9.529213587996556e-01, 9.509061688185575e-01, 9.488207993348687e-01, + 9.466637637048801e-01, 9.444335858910574e-01, 9.421288028125191e-01, 9.397479667430725e-01, 9.372896477508165e-01, + 9.347524361730808e-01, 9.321349451203507e-01, 9.294358130026688e-01, 9.266537060719486e-01, 9.237873209735582e-01, + 9.208353873005455e-01, 9.177966701438771e-01, 9.146699726321402e-01, 9.114541384542267e-01, 9.081480543586499e-01, + 9.047506526232865e-01, 9.012609134895138e-01, 8.976778675548984e-01, 8.940005981188177e-01, 8.902282434756291e-01, + 8.863599991502473e-01, 8.823951200712559e-01, 8.783329226769567e-01, 8.741727869500308e-01, 8.699141583767795e-01, + 8.655565498272043e-01, 8.610995433524644e-01, 8.565427918965455e-01, 8.518860209192624e-01, 8.471290299279841e-01, + 8.422716939157602e-01, 8.373139647037767e-01, 8.322558721863335e-01, 8.270975254767841e-01, 8.218391139531005e-01, + 8.164809082019563e-01, 8.110232608604324e-01, 8.054666073546400e-01, 7.998114665347398e-01, 7.940584412060114e-01, + 7.882082185557775e-01, 7.822615704761332e-01, 7.762193537825687e-01, 7.700825103286711e-01, 7.638520670172276e-01, + 7.575291357081170e-01, 7.511149130234813e-01, 7.446106800507299e-01, 7.380178019439980e-01, 7.313377274247339e-01, + 7.245719881821328e-01, 7.177221981741801e-01, 7.107900528300912e-01, 7.037773281549656e-01, 6.966858797374927e-01, + 6.895176416615646e-01, 6.822746253226608e-01, 6.749589181498854e-01, 6.675726822345424e-01, 6.601181528661474e-01, + 6.525976369767750e-01, 6.450135114946609e-01, 6.373682216079785e-01, 6.296642789397278e-01, 6.219042596346939e-01, + 6.140908023594462e-01, 6.062266062163840e-01, 5.983144285728536e-01, 5.903570828064187e-01, 5.823574359673894e-01, + 5.743184063597853e-01, 5.662429610419641e-01, 5.581341132482169e-01, 5.499949197327134e-01, 5.418284780372742e-01, + 5.336379236845493e-01, 5.254264272982935e-01, 5.171971916525543e-01, 5.089534486517354e-01, 5.006984562436330e-01, + 4.924354952677195e-01, 4.841678662411154e-01, 4.758988860848792e-01, 4.676318847934465e-01, 4.593702020502552e-01, + 4.511171837928217e-01, 4.428761787307617e-01, 4.346505348204885e-01, 4.264435957005810e-01, 4.182586970920628e-01, + 4.100991631681045e-01, 4.019683028979270e-01, 3.938694063699639e-01, 3.858057410996029e-01, 3.777805483271167e-01, + 3.697970393116528e-01, 3.618583916274267e-01, 3.539677454685226e-01, 3.461281999689568e-01, 3.383428095449016e-01, + 3.306145802661934e-01, 3.229464662644602e-01, 3.153413661853912e-01, 3.078021196928487e-01, 3.003315040326600e-01, + 2.929322306640503e-01, 2.856069419667691e-01, 2.783582080320176e-01, 2.711885235453130e-01, 2.641003047694161e-01, + 2.570958866354019e-01, 2.501775199498664e-01, 2.433473687261406e-01, 2.366075076472159e-01, 2.299599196678819e-01, + 2.234064937633224e-01, 2.169490228311333e-01, 2.105892017533920e-01, 2.043286256250337e-01, 1.981687881543829e-01, + 1.921110802412354e-01, 1.861567887374030e-01, 1.803070953941089e-01, 1.745630760000725e-01, 1.689256997135387e-01, + 1.633958285908989e-01, 1.579742173139196e-01, 1.526615131169428e-01, 1.474582559147575e-01, 1.423648786311610e-01, + 1.373817077275422e-01, 1.325089639301291e-01, 1.277467631538520e-01, 1.230951176200877e-01, 1.185539371648735e-01, + 1.141230307335134e-01, 1.098021080568559e-01, 1.055907815038885e-01, 1.014885681047006e-01, 9.749489173728383e-02, + 9.360908547110176e-02, 8.983039405984916e-02, 8.615797657535108e-02, 8.259090917411954e-02, 7.912818798769637e-02, + 7.576873212756439e-02, 7.251138679510837e-02, 6.935492648685226e-02, 6.629805828499362e-02, 6.333942522309385e-02, + 6.047760971667378e-02, 5.771113704839873e-02, 5.503847889751997e-02, 5.245805690326935e-02, 4.996824625197753e-02, + 4.756737927780486e-02, 4.525374906713279e-02, 4.302561305686507e-02, 4.088119661712488e-02, 3.881869660910822e-02, + 3.683628490916042e-02, 3.493211189048053e-02, 3.310430985422298e-02, 3.135099640215624e-02, 2.967027774345144e-02, + 2.806025192860465e-02, 2.651901200394490e-02, 2.504464908064207e-02, 2.363525531259980e-02, 2.228892677809941e-02, + 2.100376626054477e-02, 1.977788592414561e-02, 1.860940988086348e-02, 1.749647664542867e-02, 1.643724147571549e-02, + 1.542987859623567e-02, 1.447258330297169e-02, 1.356357394822445e-02, 1.270109380458789e-02, 1.188341280758823e-02, + 1.110882917693435e-02, 1.037567091671765e-02, 9.682297195274189e-03, 9.027099605776615e-03, 8.408503308959755e-03, + 7.824968059698375e-03, 7.274989119451309e-03, 6.757098056859764e-03, 6.269863439040749e-03, 5.811891416348594e-03, + 5.381826203588412e-03, 4.978350460855568e-03, 4.600185577345007e-03, 4.246091861623697e-03, 3.914868641989499e-03, + 3.605354280650456e-03, 3.316426105550754e-03, 3.047000263743920e-03, 2.796031500270941e-03, 2.562512866541615e-03, + 2.345475362242355e-03, 2.143987514803593e-03, 1.957154900455791e-03, 1.784119610885449e-03, 1.624059669472490e-03, + 1.476188401048562e-03, 1.339753759063066e-03, 1.214037613980937e-03, 1.098355006663937e-03, 9.920533704065749e-04, + 8.945117252091245e-04, 8.051398477746440e-04, 7.233774206148687e-04, 6.486931635421752e-04, 5.805839507121312e-04, + 5.185739162640836e-04, 4.622135514864277e-04, 4.110787963092279e-04, 3.647701278002823e-04, 3.229116482121258e-04, + 2.851501749972799e-04, 2.511543350778764e-04, 2.206136655240024e-04, 1.932377226631928e-04, 1.687552015118974e-04, + 1.469130672888079e-04, 1.274757006400757e-04, 1.102240580780130e-04, 9.495484900818888e-05, 8.147973059522124e-05, + 6.962452159532738e-05, 5.922843616409273e-05, 5.014333853121625e-05, 4.223301932042882e-05, 3.537249418257647e-05, + 2.944732530322636e-05, 2.435296624327736e-05, 1.999413047212912e-05, 1.628418385815330e-05, 1.314456129070047e-05, + 1.050420752185282e-05, 8.299042234809909e-06, 6.471449269445341e-06, 4.969789864549787e-06, 3.747939711067031e-06, + 2.764849551822885e-06, 1.984129011158285e-06, 1.373653290393152e-06, 9.051923062411747e-07, 5.540616821452014e-07, + 2.987940262820261e-07, 1.208186781658135e-07, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; + +const LC3_FLOAT MDCT_WINDOW_80_7_5ms[120] = {0.00295060859318731, + 0.00717541131643851, + 0.0137695373537175, + 0.0230953556487727, + 0.0354036229832600, + 0.0508289303571015, + 0.0694696292595147, + 0.0913884277813343, + 0.116604574829623, + 0.145073545983920, + 0.176711174053461, + 0.211342952955480, + 0.248768614459915, + 0.288701101746986, + 0.330823871149994, + 0.374814544406725, + 0.420308013047231, + 0.466904917964874, + 0.514185341357833, + 0.561710040666941, + 0.609026346152434, + 0.655671016213410, + 0.701218384229819, + 0.745240678762236, + 0.787369206048433, + 0.827223833436804, + 0.864513675018828, + 0.898977414612621, + 0.930407517984552, + 0.958599937397485, + 0.983447719378423, + 1.00488283328902, + 1.02285380727854, + 1.03740494796704, + 1.04859791420260, + 1.05656184342744, + 1.06149370624356, + 1.06362578371698, + 1.06325972797388, + 1.06074504835117, + 1.05643589789450, + 1.05069500101126, + 1.04392434506884, + 1.03647724602858, + 1.02872867366600, + 1.02106485991803, + 1.01400658226217, + 1.00727455010293, + 1.00172249743714, + 0.997309591666583, + 0.993985158260167, + 0.991683334808959, + 0.990325325024913, + 0.989822612537615, + 0.990074733989367, + 0.990975314368959, + 0.992412851225652, + 0.994273149357862, + 0.996439157431590, + 0.998791615753409, + 1.00120984620569, + 1.00357356747961, + 1.00575983636472, + 1.00764515369282, + 1.00910687229055, + 1.01002476446464, + 1.01028203168272, + 1.00976918870054, + 1.00838641217324, + 1.00605123898466, + 1.00269766615693, + 0.998280464458421, + 0.992777986793980, + 0.986186892168957, + 0.977634164392255, + 0.967447269570116, + 0.955129725416117, + 0.940389877411592, + 0.922959279964298, + 0.902607349937268, + 0.879202688562948, + 0.852641749726566, + 0.822881271616311, + 0.789971715171577, + 0.754030327670636, + 0.715255741732847, + 0.673936911240907, + 0.630414716229245, + 0.585078857908467, + 0.538398518296620, + 0.490833753173281, + 0.442885823257372, + 0.395091024053755, + 0.348004343198510, + 0.302196710240947, + 0.258227430580528, + 0.216641416438901, + 0.177922121520115, + 0.142480547128767, + 0.110652194335372, + 0.0826995966952829, + 0.0588334516201313, + 0.0392030848454565, + 0.0238629107447942, + 0.0126976223424625, + 0.00535665361021599, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0}; + +const LC3_FLOAT MDCT_WINDOW_160_7_5ms[240] = {0.00220824874304665, + 0.00381014419509035, + 0.00591552473428981, + 0.00858361456803004, + 0.0118759722608345, + 0.0158335301409709, + 0.0204918651551601, + 0.0258883592892154, + 0.0320415894481754, + 0.0389616721239547, + 0.0466742169139349, + 0.0551849337276135, + 0.0645038384438376, + 0.0746411071480673, + 0.0856000161887899, + 0.0973846702504817, + 0.109993602538973, + 0.123419277472281, + 0.137655456547628, + 0.152690437463956, + 0.168513362640497, + 0.185093104613143, + 0.202410419487986, + 0.220450365133188, + 0.239167940620308, + 0.258526168288333, + 0.278498538773636, + 0.299038431599591, + 0.320104862365552, + 0.341658622243036, + 0.363660034025212, + 0.386062695189504, + 0.408815272459443, + 0.431871045845866, + 0.455176987704814, + 0.478676592635263, + 0.502324813138104, + 0.526060916224847, + 0.549831282885023, + 0.573576882777006, + 0.597241338441034, + 0.620770242419397, + 0.644099662433612, + 0.667176381676395, + 0.689958853765865, + 0.712379980093130, + 0.734396371869479, + 0.755966688050532, + 0.777036981101517, + 0.797558113689794, + 0.817490855531114, + 0.836796949640853, + 0.855447309567916, + 0.873400798399116, + 0.890635718969808, + 0.907128770123878, + 0.922848783570288, + 0.937763322534182, + 0.951860206252747, + 0.965130600153629, + 0.977556540546725, + 0.989126208677996, + 0.999846919168316, + 1.00970072970387, + 1.01868228690835, + 1.02681455085919, + 1.03408981275172, + 1.04051195662940, + 1.04610836852236, + 1.05088564953428, + 1.05486288757866, + 1.05807220584955, + 1.06053413867011, + 1.06227661751764, + 1.06333815026019, + 1.06375556676696, + 1.06356632061806, + 1.06282155753012, + 1.06155995891758, + 1.05981709158148, + 1.05765876038451, + 1.05512005736540, + 1.05223985071955, + 1.04908778571338, + 1.04569859514623, + 1.04210830682439, + 1.03838098558867, + 1.03455276253936, + 1.03067199718128, + 1.02679166694268, + 1.02295558402234, + 1.01920733213785, + 1.01587288719722, + 1.01221017459353, + 1.00884559103696, + 1.00577851248622, + 1.00300261849896, + 1.00051460180915, + 0.998309228756053, + 0.996378601374572, + 0.994718132279737, + 0.993316215711850, + 0.992166956964939, + 0.991258602708851, + 0.990581103872326, + 0.990123118186375, + 0.989873711994700, + 0.989818706664725, + 0.989946800178719, + 0.990243175367708, + 0.990695563551443, + 0.991288540103593, + 0.992009469063567, + 0.992842692750141, + 0.993775066630664, + 0.994790397982872, + 0.995875533622126, + 0.997014367015673, + 0.998192870684212, + 0.999394506476233, + 1.00060586036830, + 1.00181040094441, + 1.00299457368229, + 1.00414154805357, + 1.00523688409909, + 1.00626392589064, + 1.00720890358777, + 1.00805489381465, + 1.00878801634839, + 1.00939182206005, + 1.00985295821773, + 1.01015529301117, + 1.01028601830489, + 1.01022987870331, + 1.00997540773688, + 1.00950845528029, + 1.00881848315592, + 1.00789488400120, + 1.00672875785417, + 1.00530991398353, + 1.00363456081898, + 1.00169363479295, + 0.999485662869670, + 0.997006370229165, + 0.994254686877395, + 0.991231967393677, + 0.987937115334337, + 0.984375124686103, + 0.979890963312768, + 0.975269878842859, + 0.970180498004025, + 0.964580026820328, + 0.958425533515528, + 0.951684013845583, + 0.944320232231505, + 0.936290624169877, + 0.927580506944232, + 0.918153413723035, + 0.907976524013806, + 0.897050058479312, + 0.885351360384818, + 0.872857926504400, + 0.859579818650462, + 0.845502615038655, + 0.830619943301480, + 0.814946648157534, + 0.798489377529441, + 0.781262449660145, + 0.763291769255088, + 0.744590843420388, + 0.725199287080917, + 0.705153668360855, + 0.684490544603819, + 0.663245209931378, + 0.641477161661819, + 0.619235333635541, + 0.596559132542786, + 0.573519989364814, + 0.550173851023454, + 0.526568538230013, + 0.502781158663802, + 0.478860889056198, + 0.454877894349081, + 0.430898122898976, + 0.406993964205627, + 0.383234030582781, + 0.359680098334456, + 0.336408100091304, + 0.313496418152647, + 0.291010565493871, + 0.269019585108746, + 0.247584347561867, + 0.226788433385199, + 0.206677770653849, + 0.187310343238419, + 0.168739644125069, + 0.151012382058898, + 0.134171842279709, + 0.118254662325635, + 0.103290733977460, + 0.0893117360272552, + 0.0763429786604178, + 0.0644077291458590, + 0.0535243714739393, + 0.0437084452819923, + 0.0349667099153409, + 0.0272984629264830, + 0.0206895808034878, + 0.0151125125235276, + 0.0105228753811890, + 0.00685547314312078, + 0.00402351119094097, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0}; + +const LC3_FLOAT MDCT_WINDOW_240_7_5ms[360] = {0.00197084907651299, + 0.00295060859318731, + 0.00412447721346795, + 0.00552688663943736, + 0.00717541131643851, + 0.00908757730429167, + 0.0112819105170366, + 0.0137695373537175, + 0.0165600266160529, + 0.0196650894549232, + 0.0230953556487727, + 0.0268612893898298, + 0.0309632559743172, + 0.0354036229832600, + 0.0401915610110090, + 0.0453331403333732, + 0.0508289303571015, + 0.0566815447853484, + 0.0628935304464015, + 0.0694696292595147, + 0.0764106313680933, + 0.0837160015651998, + 0.0913884277813343, + 0.0994294007679240, + 0.107834724972307, + 0.116604574829623, + 0.125736502786435, + 0.135226811339595, + 0.145073545983920, + 0.155273818664872, + 0.165822194234144, + 0.176711174053461, + 0.187928775884881, + 0.199473179818881, + 0.211342952955480, + 0.223524554031808, + 0.236003099651800, + 0.248768614459915, + 0.261813810748989, + 0.275129160854431, + 0.288701101746986, + 0.302514033630995, + 0.316558805236645, + 0.330823871149994, + 0.345295566673095, + 0.359963991566213, + 0.374814544406725, + 0.389831816553239, + 0.405001009601585, + 0.420308013047231, + 0.435739515285996, + 0.451277817354750, + 0.466904917964874, + 0.482609040567348, + 0.498375466266412, + 0.514185341357833, + 0.530021478313683, + 0.545869351788699, + 0.561710040666941, + 0.577528151441720, + 0.593304696426258, + 0.609026346152434, + 0.624674188938691, + 0.640227554714632, + 0.655671016213410, + 0.670995934643907, + 0.686184558797250, + 0.701218384229819, + 0.716078448562218, + 0.730756084155059, + 0.745240678762236, + 0.759515121573879, + 0.773561955408612, + 0.787369206048433, + 0.800923137730798, + 0.814211386313193, + 0.827223833436804, + 0.839952374193807, + 0.852386102361013, + 0.864513675018828, + 0.876324078835538, + 0.887814288392476, + 0.898977414612621, + 0.909803318928109, + 0.920284311925309, + 0.930407517984552, + 0.940169652216635, + 0.949567794930265, + 0.958599937397485, + 0.967260260011783, + 0.975545165941725, + 0.983447719378423, + 0.990971957260661, + 0.998119268644039, + 1.00488283328902, + 1.01125773114014, + 1.01724436218938, + 1.02285380727854, + 1.02808733870912, + 1.03293706325880, + 1.03740494796704, + 1.04150164119898, + 1.04523235573095, + 1.04859791420260, + 1.05160339500287, + 1.05425505026848, + 1.05656184342744, + 1.05853400282251, + 1.06017413540787, + 1.06149370624356, + 1.06249943033024, + 1.06320577147234, + 1.06362578371698, + 1.06376486534444, + 1.06363777833448, + 1.06325972797388, + 1.06264695324506, + 1.06180496269951, + 1.06074504835117, + 1.05948491573959, + 1.05804533277758, + 1.05643589789450, + 1.05466217871738, + 1.05274047445925, + 1.05069500101126, + 1.04853893535431, + 1.04627898264892, + 1.04392434506884, + 1.04149539738413, + 1.03901002688052, + 1.03647724602858, + 1.03390792836167, + 1.03131989375422, + 1.02872867366600, + 1.02614831936266, + 1.02358988084027, + 1.02106485991803, + 1.01856261937655, + 1.01655770337597, + 1.01400658226217, + 1.01162952586308, + 1.00938590180064, + 1.00727455010293, + 1.00529616458224, + 1.00344525988730, + 1.00172249743714, + 1.00012792446354, + 0.998657533466906, + 0.997309591666583, + 0.996083571092922, + 0.994976568981429, + 0.993985158260167, + 0.993107530052222, + 0.992341305231054, + 0.991683334808959, + 0.991130069631426, + 0.990678325164172, + 0.990325325024913, + 0.990067562181601, + 0.989901281872290, + 0.989822612537615, + 0.989827845401607, + 0.989913241125937, + 0.990074733989367, + 0.990308255838731, + 0.990609851788114, + 0.990975314368959, + 0.991400330446183, + 0.991880966170107, + 0.992412851225652, + 0.992991779075812, + 0.993613381385812, + 0.994273149357862, + 0.994966957785808, + 0.995690370111366, + 0.996439157431590, + 0.997208572194836, + 0.997994274967679, + 0.998791615753409, + 0.999596061975986, + 1.00040410125588, + 1.00120984620569, + 1.00200975605034, + 1.00279924168624, + 1.00357356747961, + 1.00432828318722, + 1.00505850186763, + 1.00575983636472, + 1.00642766968907, + 1.00705768272393, + 1.00764515369282, + 1.00818549211731, + 1.00867426536962, + 1.00910687229055, + 1.00947915891906, + 1.00978659331994, + 1.01002476446464, + 1.01018953828983, + 1.01027669068480, + 1.01028203168272, + 1.01020174265116, + 1.01003208083751, + 1.00976918870054, + 1.00940938607321, + 1.00894931012624, + 1.00838641217324, + 1.00771780306692, + 1.00694030579691, + 1.00605123898466, + 1.00504879328336, + 1.00393182763047, + 1.00269766615693, + 1.00134427117215, + 0.999872091899038, + 0.998280464458421, + 0.996566569174198, + 0.994731737005642, + 0.992777986793980, + 0.990701374188107, + 0.988504165244528, + 0.986186892168957, + 0.983711988683984, + 0.980584643109501, + 0.977634164392255, + 0.974455033150736, + 0.971062915561309, + 0.967447269570116, + 0.963593926287407, + 0.959491398347322, + 0.955129725416117, + 0.950501325912076, + 0.945592810314402, + 0.940389877411592, + 0.934886760414132, + 0.929080558710635, + 0.922959279964298, + 0.916509579192867, + 0.909724456073370, + 0.902607349937268, + 0.895155083757719, + 0.887356154208250, + 0.879202688562948, + 0.870699697841629, + 0.861847424457935, + 0.852641749726566, + 0.843077833241503, + 0.833154904680532, + 0.822881271616311, + 0.812257596919709, + 0.801285439243471, + 0.789971715171577, + 0.778318177172464, + 0.766337710411639, + 0.754030327670636, + 0.741407990945757, + 0.728477500803539, + 0.715255741732847, + 0.701751739457159, + 0.687975631811811, + 0.673936911240907, + 0.659652573201310, + 0.645139489066839, + 0.630414716229245, + 0.615483621927165, + 0.600365851941398, + 0.585078857908467, + 0.569649536456405, + 0.554084809831234, + 0.538398518296620, + 0.522614737753751, + 0.506756804966295, + 0.490833753173273, + 0.474866032652527, + 0.458876565810813, + 0.442885823257372, + 0.426906539230033, + 0.410970973391487, + 0.395091024053754, + 0.379291327017083, + 0.363587416985863, + 0.348004343198509, + 0.332563200617546, + 0.317287484882341, + 0.302196710240947, + 0.287309402575471, + 0.272643991600386, + 0.258227430580528, + 0.244072856174013, + 0.230208977382347, + 0.216641416438901, + 0.203398480689705, + 0.190486161546394, + 0.177922121520115, + 0.165726674483589, + 0.153906396679985, + 0.142480547128767, + 0.131453980101158, + 0.120841778238095, + 0.110652194335372, + 0.100891734193622, + 0.0915718850864754, + 0.0826995966952829, + 0.0742815528886268, + 0.0663242381533172, + 0.0588334516201312, + 0.0518140676237795, + 0.0452698345565108, + 0.0392030848454564, + 0.0336144159421411, + 0.0285023308156286, + 0.0238629107447942, + 0.0196894226553178, + 0.0159720527024086, + 0.0126976223424625, + 0.00984937739446455, + 0.00740724463299836, + 0.00535665361021599, + 0.00383226551874691, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0}; + +const LC3_FLOAT MDCT_WINDOW_320_7_5ms[480] = {0.00184833037060189, + 0.00256481839443054, + 0.00336762117525576, + 0.00428736617294702, + 0.00533830142913148, + 0.00652679222980445, + 0.00786112587274496, + 0.00934628179329417, + 0.0109916867707302, + 0.0128011172432759, + 0.0147805910526259, + 0.0169307043075075, + 0.0192592307040902, + 0.0217696937210109, + 0.0244685982614465, + 0.0273556542738590, + 0.0304319230257638, + 0.0336980463900663, + 0.0371583577255157, + 0.0408148179520755, + 0.0446708068423474, + 0.0487262995262562, + 0.0529820632544155, + 0.0574382469666485, + 0.0620968579875224, + 0.0669609766608529, + 0.0720298363678982, + 0.0773039146477137, + 0.0827825574095362, + 0.0884682101593173, + 0.0943607566451845, + 0.100460272003600, + 0.106763823750452, + 0.113273679440610, + 0.119986420273010, + 0.126903520680586, + 0.134020853127777, + 0.141339556870128, + 0.148857211288972, + 0.156573685338126, + 0.164484622056357, + 0.172589076538143, + 0.180879089820471, + 0.189354319600685, + 0.198012243528402, + 0.206854140994642, + 0.215875318757054, + 0.225068672370813, + 0.234427407249969, + 0.243948313710515, + 0.253627992837806, + 0.263464060987933, + 0.273450494478137, + 0.283582188986510, + 0.293853469478657, + 0.304257373461563, + 0.314790914011331, + 0.325449123426950, + 0.336227409661803, + 0.347118760290707, + 0.358120176960450, + 0.369224663378337, + 0.380427792871280, + 0.391720022741618, + 0.403097022154837, + 0.414551955216869, + 0.426081718612424, + 0.437676318481682, + 0.449330195657235, + 0.461034855039307, + 0.472786043282829, + 0.484576777178737, + 0.496401706766520, + 0.508252457556495, + 0.520122078483965, + 0.532002077000542, + 0.543888089744156, + 0.555771601181136, + 0.567645738774683, + 0.579502786315012, + 0.591335034592786, + 0.603138367473440, + 0.614904171685981, + 0.626623941105601, + 0.638288834425202, + 0.649893374776772, + 0.661432360150173, + 0.672902513906348, + 0.684293749833449, + 0.695600459535883, + 0.706811783648976, + 0.717923424519233, + 0.728931385727289, + 0.739832772797360, + 0.750618982371933, + 0.761284053417755, + 0.771818918701624, + 0.782220991963992, + 0.792481330455120, + 0.802599447723046, + 0.812565229501908, + 0.822377128920089, + 0.832030518374920, + 0.841523207674513, + 0.850848312948314, + 0.860002411781952, + 0.868979880825105, + 0.877778346729487, + 0.886395903955835, + 0.894829420791081, + 0.903077625660289, + 0.911132652155618, + 0.918993585364937, + 0.926652936933657, + 0.934111420416517, + 0.941364344292899, + 0.948412967370989, + 0.955255629597394, + 0.961892013137868, + 0.968316362908677, + 0.974530156362119, + 0.980528338141726, + 0.986313927767294, + 0.991886048619893, + 0.997246344766401, + 1.00239189664458, + 1.00731946437583, + 1.01202707343585, + 1.01651654151239, + 1.02079430268870, + 1.02486081579449, + 1.02871470580975, + 1.03235170271917, + 1.03577375047282, + 1.03898431507401, + 1.04198785539891, + 1.04478564357336, + 1.04737818412200, + 1.04976743149521, + 1.05195404554314, + 1.05394289856216, + 1.05573463147380, + 1.05734176732398, + 1.05875726493872, + 1.05998674447371, + 1.06103671687069, + 1.06190651084450, + 1.06260369490638, + 1.06313289329257, + 1.06350237394105, + 1.06370980806189, + 1.06376322346189, + 1.06366764604617, + 1.06343011818702, + 1.06305656438567, + 1.06255421036890, + 1.06192234666436, + 1.06116701778323, + 1.06029468923457, + 1.05931468949374, + 1.05823464730377, + 1.05705890752753, + 1.05578948247366, + 1.05442978686656, + 1.05298792590271, + 1.05147505164534, + 1.04989930053323, + 1.04826212949578, + 1.04656690601558, + 1.04481699264239, + 1.04302124919620, + 1.04118768090749, + 1.03932339102548, + 1.03743168416508, + 1.03551757331127, + 1.03358510598971, + 1.03164370854303, + 1.02969954597728, + 1.02775943851786, + 1.02582718703711, + 1.02390791088663, + 1.02200805068553, + 1.02013910120702, + 1.01826310081338, + 1.01687901084998, + 1.01492194818759, + 1.01309662336946, + 1.01134205244082, + 1.00965912296053, + 1.00805036388672, + 1.00651754025099, + 1.00505799251731, + 1.00366956090429, + 1.00235327309256, + 1.00110980844711, + 0.999937523064020, + 0.998834523778354, + 0.997800605926859, + 0.996835755847371, + 0.995938881156864, + 0.995108458955550, + 0.994343411090332, + 0.993642921198198, + 0.993005832427090, + 0.992430983777039, + 0.991917492640328, + 0.991463898014730, + 0.991068213957297, + 0.990729218448801, + 0.990446224564421, + 0.990217818551850, + 0.990041963066712, + 0.989917085260000, + 0.989841974698949, + 0.989815048293785, + 0.989834329137160, + 0.989898210724722, + 0.990005403060575, + 0.990154189263867, + 0.990342426919530, + 0.990568458991084, + 0.990830952741348, + 0.991128037927190, + 0.991457565684290, + 0.991817880927468, + 0.992207558971979, + 0.992624757299280, + 0.993067358412365, + 0.993533398279548, + 0.994021410066004, + 0.994529685133772, + 0.995055963618118, + 0.995598350543474, + 0.996155580104219, + 0.996725626776922, + 0.997306092208332, + 0.997895213854288, + 0.998491440631921, + 0.999092889987779, + 0.999697062575683, + 1.00030302922321, + 1.00090793360789, + 1.00151083855774, + 1.00210922561456, + 1.00270118453373, + 1.00328512996467, + 1.00385925649825, + 1.00442110963133, + 1.00496860132761, + 1.00550040380694, + 1.00601454845283, + 1.00650869083178, + 1.00698103862634, + 1.00743004105679, + 1.00785364005500, + 1.00824961843285, + 1.00861603623935, + 1.00895137836214, + 1.00925389667459, + 1.00952134193584, + 1.00975175133162, + 1.00994371466878, + 1.01009549736651, + 1.01020487679019, + 1.01027007304515, + 1.01028975233683, + 1.01026226969627, + 1.01018561543197, + 1.01005819682879, + 1.00987881783672, + 1.00964593048934, + 1.00935753319733, + 1.00901228181564, + 1.00860959436079, + 1.00814836659263, + 1.00762674316571, + 1.00704343050616, + 1.00639774980144, + 1.00568876793126, + 1.00491558583432, + 1.00407767878127, + 1.00317428837606, + 1.00220424207009, + 1.00116683614142, + 1.00006248083959, + 0.998891421862267, + 0.997652251800105, + 0.996343855540476, + 0.994967462022130, + 0.993524663018428, + 0.992013926907702, + 0.990433283134003, + 0.988785147009912, + 0.987072680860489, + 0.985297442611976, + 0.983401161131380, + 0.980949417765551, + 0.978782729044635, + 0.976468238349044, + 0.974042850200711, + 0.971498848279787, + 0.968829967901758, + 0.966030973927894, + 0.963095103865114, + 0.960018197689881, + 0.956795738404679, + 0.953426266696235, + 0.949903482303963, + 0.946222115168414, + 0.942375819502639, + 0.938361701514345, + 0.934177797863119, + 0.929823123908876, + 0.925292319504672, + 0.920580120066111, + 0.915679792968200, + 0.910590604293827, + 0.905315030158709, + 0.899852756107195, + 0.894199497118493, + 0.888350152427933, + 0.882301631337498, + 0.876054874152525, + 0.869612384940706, + 0.862972799329697, + 0.856135197574920, + 0.849098178607312, + 0.841857024342112, + 0.834414055019111, + 0.826774616875239, + 0.818939244026861, + 0.810904891487294, + 0.802675318450619, + 0.794253750525830, + 0.785641661592052, + 0.776838608661742, + 0.767853193256071, + 0.758685180670574, + 0.749330657713362, + 0.739809171155050, + 0.730109944357775, + 0.720247780620101, + 0.710224160990164, + 0.700044325846151, + 0.689711889540493, + 0.679231154104663, + 0.668608178924739, + 0.657850996784250, + 0.646965718233652, + 0.635959616622744, + 0.624840335899161, + 0.613603502679100, + 0.602265090642188, + 0.590829083373282, + 0.579309407943056, + 0.567711124002091, + 0.556037415675143, + 0.544293664349262, + 0.532489768053648, + 0.520636084113626, + 0.508743272768040, + 0.496811166041365, + 0.484849880708936, + 0.472868107365031, + 0.460875918379489, + 0.448881080632702, + 0.436891038772751, + 0.424912022350783, + 0.412960603164169, + 0.401035896287704, + 0.389157866744938, + 0.377322198811674, + 0.365543766863001, + 0.353832356425067, + 0.342196115433984, + 0.330644820108683, + 0.319187558989871, + 0.307833309339190, + 0.296588181651645, + 0.285463716536022, + 0.274462408857763, + 0.263609584476890, + 0.252883101143323, + 0.242323488971182, + 0.231925746284170, + 0.221690837369583, + 0.211638057695031, + 0.201766920294530, + 0.192082235818342, + 0.182589160013263, + 0.173305996740759, + 0.164229200045030, + 0.155362654247925, + 0.146717078597741, + 0.138299391415146, + 0.130105078076731, + 0.122145309929155, + 0.114423458192169, + 0.106941075992303, + 0.0997025893446062, + 0.0927124283374869, + 0.0859737427062027, + 0.0794893311195214, + 0.0732616579460535, + 0.0672934102310889, + 0.0615874081007633, + 0.0561458002593222, + 0.0509700747035652, + 0.0460617047145777, + 0.0414220116926541, + 0.0370514188750623, + 0.0329494666227939, + 0.0291153326941312, + 0.0255476401323823, + 0.0222437711282860, + 0.0192000658979791, + 0.0164122204526698, + 0.0138747611120131, + 0.0115806352990988, + 0.00952213664221592, + 0.00769137379581469, + 0.00607207833119310, + 0.00462581216874268, + 0.00360685164162597, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0}; + +const LC3_FLOAT MDCT_WINDOW_480_7_5ms[720] = {0.00172152668161197, + 0.00220824874304665, + 0.00268901752259534, + 0.00322613341770658, + 0.00381014419509035, + 0.00445371931718418, + 0.00515369239968132, + 0.00591552473428981, + 0.00673869158441088, + 0.00762861840690755, + 0.00858361456803004, + 0.00960938437461376, + 0.0107060753216012, + 0.0118759722608345, + 0.0131190129731594, + 0.0144390107858867, + 0.0158335301409709, + 0.0173063081075865, + 0.0188584711217331, + 0.0204918651551601, + 0.0222061476414017, + 0.0240057166241995, + 0.0258883592892154, + 0.0278552325915007, + 0.0299059145401639, + 0.0320415894481754, + 0.0342610013298592, + 0.0365680972732117, + 0.0389616721239547, + 0.0414435823556703, + 0.0440140795515652, + 0.0466742169139349, + 0.0494214624989609, + 0.0522588488991433, + 0.0551849337276135, + 0.0582005142844991, + 0.0613059844876918, + 0.0645038384438376, + 0.0677913922780715, + 0.0711707832894713, + 0.0746411071480673, + 0.0782028053093391, + 0.0818549520793733, + 0.0856000161887899, + 0.0894357617466231, + 0.0933642589167916, + 0.0973846702504817, + 0.101496717842215, + 0.105698760137915, + 0.109993602538973, + 0.114378287000688, + 0.118853507644691, + 0.123419277472281, + 0.128075996686182, + 0.132820580592162, + 0.137655456547628, + 0.142578647864983, + 0.147590521689500, + 0.152690437463956, + 0.157878852729327, + 0.163152528516638, + 0.168513362640497, + 0.173957968965553, + 0.179484736541084, + 0.185093104613143, + 0.190784835080141, + 0.196556497277956, + 0.202410419487986, + 0.208345433427595, + 0.214359824832231, + 0.220450365133188, + 0.226617296379634, + 0.232856279279332, + 0.239167940620308, + 0.245550641734726, + 0.252003950801656, + 0.258526168288333, + 0.265118407626359, + 0.271775911320379, + 0.278498538773636, + 0.285284606228892, + 0.292132459126393, + 0.299038431599591, + 0.306004255968647, + 0.313026529044311, + 0.320104862365552, + 0.327237324371911, + 0.334423209544169, + 0.341658622243036, + 0.348944976164519, + 0.356279251911600, + 0.363660034025212, + 0.371085146360032, + 0.378554326716481, + 0.386062695189504, + 0.393610553614044, + 0.401195224753282, + 0.408815272459443, + 0.416468460349459, + 0.424155411395509, + 0.431871045845866, + 0.439614743914448, + 0.447384019490353, + 0.455176987704814, + 0.462990137501968, + 0.470824618788539, + 0.478676592635263, + 0.486545433113577, + 0.494428714400322, + 0.502324813138104, + 0.510229471464589, + 0.518142926555815, + 0.526060916224847, + 0.533982817654487, + 0.541906816785495, + 0.549831282885023, + 0.557751233747995, + 0.565667636233856, + 0.573576882777006, + 0.581476665547768, + 0.589364661090802, + 0.597241338441034, + 0.605102013194533, + 0.612946170296527, + 0.620770242419397, + 0.628572093800007, + 0.636348526182129, + 0.644099662433612, + 0.651820973301216, + 0.659513821705787, + 0.667176381676395, + 0.674806795170392, + 0.682400710845902, + 0.689958853765865, + 0.697475722348889, + 0.704950144755303, + 0.712379980093130, + 0.719765434054233, + 0.727103832924324, + 0.734396371869479, + 0.741638560666120, + 0.748829639427782, + 0.755966688050532, + 0.763049259441822, + 0.770072273456679, + 0.777036981101517, + 0.783941107955561, + 0.790781256570410, + 0.797558113689794, + 0.804271380965317, + 0.810914900592988, + 0.817490855531114, + 0.823997093771197, + 0.830432785018494, + 0.836796949640853, + 0.843089297972628, + 0.849305847142233, + 0.855447309567916, + 0.861511036513329, + 0.867496280683677, + 0.873400798399116, + 0.879227518344298, + 0.884972438304695, + 0.890635718969808, + 0.896217172709751, + 0.901716413868111, + 0.907128770123878, + 0.912456578161017, + 0.917697260839682, + 0.922848783570288, + 0.927909917257080, + 0.932882596476862, + 0.937763322534182, + 0.942553355949148, + 0.947252428176398, + 0.951860206252747, + 0.956376059930715, + 0.960800601653643, + 0.965130600153629, + 0.969366688856792, + 0.973508812191284, + 0.977556540546725, + 0.981507226076202, + 0.985364580290061, + 0.989126208677996, + 0.992794200680601, + 0.996367545084978, + 0.999846919168316, + 1.00322812484515, + 1.00651341182191, + 1.00970072970387, + 1.01279028960634, + 1.01578293436089, + 1.01868228690835, + 1.02148657041020, + 1.02419771842881, + 1.02681455085919, + 1.02933598109997, + 1.03176042993634, + 1.03408981275172, + 1.03632325851578, + 1.03846360765363, + 1.04051195662940, + 1.04246831469554, + 1.04433331015458, + 1.04610836852236, + 1.04779018315657, + 1.04938333555913, + 1.05088564953428, + 1.05229923461622, + 1.05362521849064, + 1.05486288757866, + 1.05601520650228, + 1.05708745929907, + 1.05807220584955, + 1.05897524171920, + 1.05979446723066, + 1.06053413867011, + 1.06119411863264, + 1.06177365556482, + 1.06227661751764, + 1.06270323725515, + 1.06305568550874, + 1.06333815026019, + 1.06354799718407, + 1.06368606790043, + 1.06375556676696, + 1.06375743495314, + 1.06369358352060, + 1.06356632061806, + 1.06337707389149, + 1.06312781969919, + 1.06282155753012, + 1.06245781539243, + 1.06203634281998, + 1.06155995891758, + 1.06102951018466, + 1.06044796508355, + 1.05981709158148, + 1.05914162811841, + 1.05842135887536, + 1.05765876038451, + 1.05685377407703, + 1.05600761436100, + 1.05512005736540, + 1.05419504543825, + 1.05323345555133, + 1.05223985071955, + 1.05121667551754, + 1.05016636928704, + 1.04908778571338, + 1.04798366418119, + 1.04685333764799, + 1.04569859514623, + 1.04452056473031, + 1.04332348168164, + 1.04210830682439, + 1.04087907347658, + 1.03963603298779, + 1.03838098558867, + 1.03711402960368, + 1.03583813453316, + 1.03455276253936, + 1.03326200062149, + 1.03196749756726, + 1.03067199718128, + 1.02937563931250, + 1.02808243736505, + 1.02679166694268, + 1.02550635249346, + 1.02422655030626, + 1.02295558402234, + 1.02169298956325, + 1.02044474846015, + 1.01920733213785, + 1.01799991915642, + 1.01716021719396, + 1.01587288719722, + 1.01461782929950, + 1.01339738080134, + 1.01221017459353, + 1.01105651618772, + 1.00993443649479, + 1.00884559103696, + 1.00778955760958, + 1.00676790147273, + 1.00577851248622, + 1.00482173369676, + 1.00389592016124, + 1.00300261849896, + 1.00214090725866, + 1.00131212703156, + 1.00051460180915, + 0.999748987566388, + 0.999013486065174, + 0.998309228756053, + 0.997634933573802, + 0.996991885118110, + 0.996378601374572, + 0.995795982324256, + 0.995242217431553, + 0.994718132279737, + 0.994222121603521, + 0.993755313270097, + 0.993316215711850, + 0.992905809264804, + 0.992522421568056, + 0.992166956964939, + 0.991837703847481, + 0.991535508409853, + 0.991258602708851, + 0.991007878425042, + 0.990781722666477, + 0.990581103872326, + 0.990404336010644, + 0.990252266515061, + 0.990123118186375, + 0.990017725942080, + 0.989934325251675, + 0.989873711994700, + 0.989834110063609, + 0.989816358516333, + 0.989818706664725, + 0.989841997633560, + 0.989884437608375, + 0.989946800178719, + 0.990027287179467, + 0.990126680433027, + 0.990243175367708, + 0.990377593567359, + 0.990528133732004, + 0.990695563551443, + 0.990878043253865, + 0.991076301696221, + 0.991288540103593, + 0.991515601979036, + 0.991755665863857, + 0.992009469063567, + 0.992275155432533, + 0.992553486464066, + 0.992842692750141, + 0.993143533338714, + 0.993454079661184, + 0.993775066630664, + 0.994104689071308, + 0.994443741563539, + 0.994790397982872, + 0.995145361143570, + 0.995506799575831, + 0.995875533622126, + 0.996249681496846, + 0.996629918576519, + 0.997014367015673, + 0.997403799406302, + 0.997796404470102, + 0.998192870684212, + 0.998591285561368, + 0.998992436297826, + 0.999394506476233, + 0.999798247074188, + 1.00020179363827, + 1.00060586036830, + 1.00100857991068, + 1.00141070171451, + 1.00181040094441, + 1.00220846208708, + 1.00260295839583, + 1.00299457368229, + 1.00338147727724, + 1.00376443633841, + 1.00414154805357, + 1.00451348039620, + 1.00487832134478, + 1.00523688409909, + 1.00558730293553, + 1.00593027172440, + 1.00626392589064, + 1.00658905174666, + 1.00690380235195, + 1.00720890358777, + 1.00750238011098, + 1.00778498234605, + 1.00805489381465, + 1.00831286819921, + 1.00855699900640, + 1.00878801634839, + 1.00900404770905, + 1.00920593286756, + 1.00939182206005, + 1.00956244042490, + 1.00971589673993, + 1.00985295821773, + 1.00997177407911, + 1.01007316964863, + 1.01015529301117, + 1.01021893264234, + 1.01026224628852, + 1.01028601830489, + 1.01028841501360, + 1.01027029664166, + 1.01022987870331, + 1.01016802275824, + 1.01008292457433, + 1.00997540773688, + 1.00984368712353, + 1.00968863285475, + 1.00950845528029, + 1.00930404459694, + 1.00907371350998, + 1.00881848315592, + 1.00853675084589, + 1.00822946750346, + 1.00789488400120, + 1.00753391386376, + 1.00714487786153, + 1.00672875785417, + 1.00628392789102, + 1.00581145628420, + 1.00530991398353, + 1.00478052727780, + 1.00422176605486, + 1.00363456081898, + 1.00301719093886, + 1.00237067322585, + 1.00169363479295, + 1.00098748810560, + 1.00025107545667, + 0.999485662869670, + 0.998689592389690, + 0.997863666433377, + 0.997006370229165, + 0.996119199129118, + 0.995201403855962, + 0.994254686877395, + 0.993277595101281, + 0.992270650602836, + 0.991231967393677, + 0.990163285718553, + 0.989064393522322, + 0.987937115334337, + 0.986779736108308, + 0.985592773084236, + 0.984375124686103, + 0.983129287890062, + 0.981348462911328, + 0.979890963312768, + 0.978400458984906, + 0.976860435411572, + 0.975269878842859, + 0.973627353241612, + 0.971931340983223, + 0.970180498004025, + 0.968372651965257, + 0.966506952259707, + 0.964580026820328, + 0.962592317588312, + 0.960540986343273, + 0.958425533515528, + 0.956244393275019, + 0.953998415902893, + 0.951684013845583, + 0.949301185363779, + 0.946846884329832, + 0.944320232231505, + 0.941718404323327, + 0.939042579646710, + 0.936290624169877, + 0.933464049736310, + 0.930560853876881, + 0.927580506944232, + 0.924519591719516, + 0.921378471441385, + 0.918153413723035, + 0.914844695613022, + 0.911451651601712, + 0.907976524013806, + 0.904417545083186, + 0.900776307727862, + 0.897050058479312, + 0.893238397854931, + 0.889338680564778, + 0.885351360384818, + 0.881274022956677, + 0.877109637913966, + 0.872857926504400, + 0.868519505092655, + 0.864092796449043, + 0.859579818650462, + 0.854976006559576, + 0.850285220126345, + 0.845502615038655, + 0.840630470320405, + 0.835667925492783, + 0.830619943301480, + 0.825482006990559, + 0.820258908705916, + 0.814946648157534, + 0.809546695921391, + 0.804059977858176, + 0.798489377529441, + 0.792831417318078, + 0.787090668112010, + 0.781262449660145, + 0.775353946896531, + 0.769363612973808, + 0.763291769255088, + 0.757139016438538, + 0.750901711179744, + 0.744590843420388, + 0.738205135983222, + 0.731738075019976, + 0.725199287080917, + 0.718588225289593, + 0.711905686689260, + 0.705153668360855, + 0.698332634155137, + 0.691444101223867, + 0.684490544603819, + 0.677470119276872, + 0.670388375375255, + 0.663245209931378, + 0.656045780075394, + 0.648788626910908, + 0.641477161661819, + 0.634114322697443, + 0.626702000288600, + 0.619235333635541, + 0.611720595766813, + 0.604161612008372, + 0.596559132542786, + 0.588914400742527, + 0.581234783414194, + 0.573519989364814, + 0.565770615838341, + 0.557988067156798, + 0.550173851023454, + 0.542330193938633, + 0.534460798055783, + 0.526568538230013, + 0.518656324106017, + 0.510728812610530, + 0.502781158663802, + 0.494819490990687, + 0.486845139248642, + 0.478860889056187, + 0.470869928237011, + 0.462875144056541, + 0.454877894349081, + 0.446882512027806, + 0.438889324991181, + 0.430898122898976, + 0.422918322377786, + 0.414950877976117, + 0.406993964205624, + 0.399052648395750, + 0.391134613511556, + 0.383234030582781, + 0.375354652658444, + 0.367502059648862, + 0.359680098334456, + 0.351887311977221, + 0.344130165828257, + 0.336408100091303, + 0.328728966167385, + 0.321090505163296, + 0.313496418152647, + 0.305951564939720, + 0.298454318724068, + 0.291010565493870, + 0.283621109377504, + 0.276285415057373, + 0.269019585108745, + 0.261812445205796, + 0.254659232371968, + 0.247584347561867, + 0.240578694191260, + 0.233647008666278, + 0.226788433385199, + 0.220001991767835, + 0.213301325170393, + 0.206677770653848, + 0.200140409104345, + 0.193683630277597, + 0.187310343238419, + 0.181027383883625, + 0.174839476062309, + 0.168739644125069, + 0.162737273481917, + 0.156825277050683, + 0.151012382058898, + 0.145298229536747, + 0.139687469382981, + 0.134171842279709, + 0.128762544136019, + 0.123455562073148, + 0.118254662325635, + 0.113159676766305, + 0.108171439273590, + 0.103290733977459, + 0.0985202977906343, + 0.0938600022604814, + 0.0893117360272552, + 0.0848752102882993, + 0.0805523737322188, + 0.0763429786604177, + 0.0722489245608881, + 0.0682699119548786, + 0.0644077291458590, + 0.0606620002841447, + 0.0570343711147243, + 0.0535243714739393, + 0.0501334689685108, + 0.0468610789607730, + 0.0437084452819923, + 0.0406748365259497, + 0.0377612269065632, + 0.0349667099153408, + 0.0322919274833124, + 0.0297357668703102, + 0.0272984629264830, + 0.0249787185611126, + 0.0227762541832071, + 0.0206895808034878, + 0.0187178169347065, + 0.0168593417528780, + 0.0151125125235276, + 0.0134757094495118, + 0.0119462709121848, + 0.0105228753811890, + 0.00920130941284003, + 0.00798124316373271, + 0.00685547314312078, + 0.00582657334385164, + 0.00487838525422656, + 0.00402351119094097, + 0.00315418662758696, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0}; +#endif /* #ifdef CR8_G_ADD_75MS */ + const LC3_FLOAT MDCT_WINDOW_80_2_5ms[40] = { 6.737914289329320e-03, 2.732289618100209e-02, 6.163560962361236e-02, 1.119125037883055e-01, 1.787053464784875e-01, 2.607525136824537e-01, 3.549776504187033e-01, 4.567696724165073e-01, 5.605239559005871e-01, 6.603665285212146e-01, @@ -3080,6 +5487,12 @@ const LC3_FLOAT* MDCT_WINS_10ms[2][6] = { {NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_10ms, MDCT_HRA_WINDOW_960_10ms}}; const LC3_INT MDCT_la_zeroes[6] = {30, 60, 90, 120, 180, 360}; +#ifdef CR8_G_ADD_75MS +const LC3_FLOAT* MDCT_WINS_7_5ms[2][6] = { + {MDCT_WINDOW_80_7_5ms, MDCT_WINDOW_160_7_5ms, MDCT_WINDOW_240_7_5ms, MDCT_WINDOW_320_7_5ms, MDCT_WINDOW_480_7_5ms, NULL}, + {NULL , NULL , NULL , NULL , MDCT_HRA_WINDOW_480_7_5ms, MDCT_HRA_WINDOW_960_7_5ms}}; +const LC3_INT32 MDCT_la_zeroes_7_5ms[6] = {14, 28, 42, 56, 84, 168}; +#endif const LC3_FLOAT* MDCT_WINS_2_5ms[2][6] = { {MDCT_WINDOW_80_2_5ms, MDCT_WINDOW_160_2_5ms, MDCT_WINDOW_240_2_5ms, MDCT_WINDOW_320_2_5ms, MDCT_WINDOW_480_2_5ms, @@ -3094,11 +5507,12 @@ const LC3_INT MDCT_la_zeroes_5ms[6] = {10, 20, 30, 40, 60, 120}; const LC3_INT MDCT_WINDOWS_LENGTHS_10ms[6] = {160, 320, 480, 640, 960, 1920}; /* Last 960 dummy */ -const LC3_INT MDCT_WINDOWS_LENGTHS_2_5ms[6] = {40, 80, 120, 160, 240, 480}; - +const LC3_INT MDCT_WINDOWS_LENGTHS_7_5ms[6] = {120, 240, 360, 480, 720, 1440}; /* Last 960 dummy */ const LC3_INT MDCT_WINDOWS_LENGTHS_5ms[6] = {80, 160, 240, 320, 480, 960}; +const LC3_INT MDCT_WINDOWS_LENGTHS_2_5ms[6] = {40, 80, 120, 160, 240, 480}; + /* Per band energy */ const LC3_INT ACC_COEFF_PER_BAND_8[65] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, @@ -3209,8 +5623,97 @@ const LC3_INT* ACC_COEFF_PER_BAND_5ms[5] = {ACC_COEFF_PER_BAND_8_5ms, ACC_COEFF_ ACC_COEFF_PER_BAND_24_5ms, ACC_COEFF_PER_BAND_32_5ms, ACC_COEFF_PER_BAND_48_5ms}; +#ifdef CR8_G_ADD_75MS +const LC3_INT ACC_COEFF_PER_BAND_8_7_5ms[61] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60}; + +const LC3_INT ACC_COEFF_PER_BAND_16_7_5ms[65] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 65, 68, + 71, 74, 77, 80, 83, 86, 90, 94, 98, 102, 106, 110, 115, 120}; + +const LC3_INT ACC_COEFF_PER_BAND_24_7_5ms[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 52, 55, 58, 61, 64, + 67, 70, 74, 78, 82, 86, 90, 95, 100, 105, 110, 115, 121, 127, 134, 141, 148, 155, 163, 171, 180}; + +const LC3_INT ACC_COEFF_PER_BAND_32_7_5ms[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 45, 48, 51, 54, 57, 60, 63, 67, 71, 75, + 79, 84, 89, 94, 99, 105, 111, 117, 124, 131, 138, 146, 154, 163, 172, 182, 192, 203, 215, 227, 240}; + +const LC3_INT ACC_COEFF_PER_BAND_48_7_5ms[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 43, 46, 49, 52, 55, 59, 63, 67, 71, 75, 80, 85, + 90, 96, 102, 108, 115, 122, 129, 137, 146, 155, 165, 175, 186, 197, 209, 222, 236, 251, 266, 283, 300}; + +const LC3_INT ACC_COEFF_PER_BAND_48_7_5ms_HR[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, + 24, 26, 28, 30, 32, 34, 36, 38, 41, 44, 47, 50, 53, 56, 60, 64, 68, 73, 78, 83, 89, 95, + 101, 108, 115, 122, 130, 139, 148, 158, 168, 179, 191, 203, 217, 231, 246, 262, 279, 298, 317, 338, 360}; + +const LC3_INT ACC_COEFF_PER_BAND_96_7_5ms_HR[65] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, + 24, 26, 28, 30, 32, 35, 38, 41, 44, 48, 52, 56, 61, 66, 71, 77, 83, 90, 97, 105, + 114, 123, 132, 143, 155, 167, 180, 195, 210, 227, 245, 265, 286, 309, 334, 360, 389, 420, 454, 490, + 529, 572, 617, 667, 720}; + +const LC3_INT* ACC_COEFF_PER_BAND_7_5ms_HR[6] = {NULL, NULL, + NULL, NULL, + ACC_COEFF_PER_BAND_48_7_5ms_HR, ACC_COEFF_PER_BAND_96_7_5ms_HR}; + +const LC3_INT* ACC_COEFF_PER_BAND_7_5ms[5] = {ACC_COEFF_PER_BAND_8_7_5ms , ACC_COEFF_PER_BAND_16_7_5ms, + ACC_COEFF_PER_BAND_24_7_5ms, ACC_COEFF_PER_BAND_32_7_5ms, + ACC_COEFF_PER_BAND_48_7_5ms}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_8_7_5ms[61] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_16_7_5ms[61] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_24_7_5ms[61] = { + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_32_7_5ms[81] = { + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, + 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_48_7_5ms[61] = { + 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, + 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210, 216, 222, 228, 234, 240, 246, + 252, 258, 264, 270, 276, 282, 288, 294, 300, 306, 312, 318, 324, 330, 336, 342, 348, 354, 360}; + +const LC3_INT ACC_COEFF_PER_BAND_PLC_96_7_5ms[81] = { + 0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, + 189, 198, 207, 216, 225, 234, 243, 252, 261, 270, 279, 288, 297, 306, 315, 324, 333, 342, 351, 360, 369, + 378, 387, 396, 405, 414, 423, 432, 441, 450, 459, 468, 477, 486, 495, 504, 513, 522, 531, 540, 549, 558, + 567, 576, 585, 594, 603, 612, 621, 630, 639, 648, 657, 666, 675, 684, 693, 702, 711, 720}; + +const LC3_INT* ACC_COEFF_PER_BAND_PLC_7_5ms[] = { + ACC_COEFF_PER_BAND_PLC_8_7_5ms, ACC_COEFF_PER_BAND_PLC_16_7_5ms, ACC_COEFF_PER_BAND_PLC_24_7_5ms, + ACC_COEFF_PER_BAND_PLC_32_7_5ms, ACC_COEFF_PER_BAND_PLC_48_7_5ms, ACC_COEFF_PER_BAND_PLC_96_7_5ms}; +#endif + /* Near Nyquist detector */ const LC3_INT NN_thresh = 30; +/* Tone detector */ +#ifdef CR8_E_TONE_DETECTOR +const LC3_INT32 TD_HR_thresh_10ms = 83402; +const LC3_INT32 TD_HR_thresh_7_5ms = 743496; +const LC3_INT32 TD_HR_thresh_5ms = 382564; +const LC3_INT32 TD_HR_thresh_2_5ms = 301695; +#endif // CR8_E_TONE_DETECTOR const LC3_INT32 xavg_N_grp[5] = { 4, 5, 6, 7, 8 }; @@ -3219,6 +5722,42 @@ const LC3_INT32 xavg_N_grp[5] = { 4, 5, 6, 7, 8 }; const LC3_INT32 gwlpr[MAX_LGW+1] = { 1, 3*QUOT_LPR_LTR, 5*QUOT_LPR_LTR, 9*QUOT_LPR_LTR, 17*QUOT_LPR_LTR, 33*QUOT_LPR_LTR, 49*QUOT_LPR_LTR, 65*QUOT_LPR_LTR, 81*QUOT_LPR_LTR, 97*QUOT_LPR_LTR}; +#ifdef CR8_A_PLC_FADEOUT_TUNING +/* PLC_FADEOUT_TUNING, extended table ranging from 30 ms to 140 ms */ +const LC3_INT16 fade_scheme_tab[24 / 2][3] = { +#if 0 + /* burst_att_thresh indicates when muting POW_ATT_TABLE[att_per_frame_idx] should be used first time it is 1.0 though */ + /* burst_att_thresh ==2 --> gains [ 1.0, 32767/32768.0(first table value used) , first muted, .... ]*/ + /* burst_att_thresh ==5 --> gains [ 1.0, 1.0, 1,0 1,0, 32767/32768.0(first table value used) , first muted,... ]*/ + /* beta_mute_thr ==4 --> start of final attenuation attenuate AvgMix */ +#endif + /* tabled {att_per_frame_idx_p3dB , burst_att_thresh, beta_mute_thr } */ + { 1, 2, 0 + 2 + 2 }, /* 30 ms, 0.3 dB delta att in slow mutephase nominal_fadeout=0 */ + { 1, 3, 0 + 3 + 2 }, /* 40 ms, 0.3 dB delta att in slow mutephase */ + { 3, 3, 1 + 3 + 1 }, /* 50 ms, 0.3 dB delta att in slow mutephase */ + { 3, 4, 1 + 4 + 1}, /* 60 ms, 0.3 dB delta att in slow mutephase */ + { 5, 4, 3 + 4 + 1 }, /* 70 ms, 0.3 dB delta att in slow mutephase */ + { 5, 5, 3 + 5 + 1 }, /* 80 ms, 0.3 dB delta att in slow mutephase */ + { 7, 5, 7 + 5 }, /* 90 ms, 0.3 dB delta att in slow mutephase */ + { 7, 5, 7 + 5 + 1}, /* 100 ms, 0.3 dB delta att in slow mutephase */ + { 9, 5, 9 + 5 }, /* 110 ms, 0.3 dB delta att in slow mutephase */ + { 9, 5, 9 + 5 + 1}, /* 120 ms, 0.3 dB delta att in slow mutephase nominal_fadeout=1 */ + { 11, 5, 15 + 5 },/* 130 ms, 0.3 dB delta att in slow mutephase */ + { 11, 6, 15 + 6 },/* 140 ms, 0.3 dB delta att in slow mutephase nominal 3GPP */ + +}; +#if 0 +/*fade_scheme_tab[ind][0] att_per _fram_index , "points" to first column in POW_ATT TABLES */ +/*fade_scheme_tab[ind][1] is burst_att_thresh, the number of non_muted 1.0 gain frames */ +/*fade_scheme_tab[ind][2] is beta_mute_thr, the location of the start of final muting */ +#endif + + + +/*compressed ATH Abolute hearing THreshold function weights at band borders */ +const LC3_FLOAT scATHFx[MAX_LGW - 2] = { .455444335937500 , 0.930755615234375 , 0.973083496093750 , 0.999969482421875 , 0.908508300781250 , 0.775665283203125 , 0.5 }; +#endif + const LC3_FLOAT PhECU_whr16ms_NB[128]={ 8.000000000000002e-02, 8.393536376804722e-02, 9.567411990702857e-02, 1.150154150448081e-01, 1.416283142591582e-01, 1.750574634660318e-01, 2.147308806541882e-01, 2.599697426559885e-01, 3.099999999999999e-01, 3.639656211120587e-01, @@ -3801,3 +6340,7 @@ const LC3_INT* ACC_COEFF_PER_BAND_PLC_5ms[] = { const LC3_INT32 mdct_grp_bins[10] = { 4, 14, 24, 44, 84, 164, 244, 324, 404, 484 }; +#if defined(CR8_A_PLC_FADEOUT_TUNING) +const LC3_INT16 plc_fadeout_param_maxlen[4] = {800, 400, 266, 200}; +const LC3_INT16 plc_fadeout_param_maxbytes[4] = {27, 14, 9, 7}; +#endif diff --git a/lib_lc3plus/constants.h b/lib_lc3plus/constants.h index c0c9e286e55c72bd40851c91fe7229e22d9ef261..6d58a5798addb1c4f07581a6d53d811c08604e40 100644 --- a/lib_lc3plus/constants.h +++ b/lib_lc3plus/constants.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,6 +11,7 @@ #ifndef CONSTANTS_H #define CONSTANTS_H +#include "options.h" #include "defines.h" #include "structs.h" @@ -18,13 +19,15 @@ extern const Complex dct2_16[16]; /* Ari coder */ -extern const LC3_INT ari_tns_order_cf[2][9]; -extern const LC3_INT ari_tns_freq_cf[8][18]; +extern const LC3_INT16 ari_tns_order_cf[2][9]; +extern const LC3_INT16 ari_tns_freq_cf[8][18]; extern const LC3_INT ari_spec_lookup_fl[4096]; -extern const LC3_INT ari_spec_cumfreq_fl[64][18]; +extern const LC3_INT16 ari_spec_cumfreq_fl[64][18]; extern const LC3_INT ari_spec_bits_fl[64][17]; /* SNS */ +extern const LC3_FLOAT sns_W[6]; +extern const LC3_FLOAT *sns_preemph_all[6]; extern const LC3_FLOAT sns_LFCB[8][32]; extern const LC3_FLOAT sns_HFCB[8][32]; extern const LC3_INT pvq_enc_A[16][11]; @@ -128,6 +131,16 @@ extern const LC3_INT BW_cutoff_bin_all_5ms_HR[MAX_BW_BANDS_NUMBER]; extern const LC3_INT BW_cutoff_bin_all[MAX_BW_BANDS_NUMBER]; extern const LC3_INT BW_cutoff_bits_all[MAX_BW_BANDS_NUMBER]; +#ifdef CR8_G_ADD_75MS +extern const LC3_INT BW_cutoff_bin_all_7_5ms[MAX_BW_BANDS_NUMBER]; +extern const LC3_INT bands_number_7_5ms[6]; +extern const LC3_INT bands_number_7_5ms_HR[6]; +extern const LC3_INT* BW_warp_idx_start_all_7_5ms[4]; +extern const LC3_INT* BW_warp_idx_stop_all_7_5ms[4]; +extern const LC3_INT brickwall_dist_7_5ms[4]; +extern const LC3_INT* ACC_COEFF_PER_BAND_PLC_7_5ms[]; +#endif + /* Arithmetic coding */ extern const LC3_INT tns_cf[8][18]; extern const LC3_INT tns_freq_cf[2][9]; @@ -150,7 +163,6 @@ extern const LC3_FLOAT MDCT_WINDOW_480_2_5ms[240]; extern const LC3_FLOAT* MDCT_WINS_2_5ms[2][6]; extern const LC3_INT MDCT_la_zeroes_2_5ms[6]; - extern const LC3_FLOAT MDCT_WINDOW_80_5ms[80]; extern const LC3_FLOAT MDCT_WINDOW_160_5ms[160]; extern const LC3_FLOAT MDCT_WINDOW_240_5ms[240]; @@ -159,12 +171,15 @@ extern const LC3_FLOAT MDCT_WINDOW_480_5ms[480]; extern const LC3_FLOAT* MDCT_WINS_5ms[2][6]; extern const LC3_INT MDCT_la_zeroes_5ms[6]; -extern const LC3_INT MDCT_WINDOWS_LENGTHS_10ms[6]; - -extern const LC3_INT MDCT_WINDOWS_LENGTHS_2_5ms[6]; - +#ifdef CR8_G_ADD_75MS +extern const LC3_FLOAT* MDCT_WINS_7_5ms[2][6]; +extern const LC3_INT32 MDCT_la_zeroes_7_5ms[6]; +#endif +extern const LC3_INT MDCT_WINDOWS_LENGTHS_10ms[6]; +extern const LC3_INT MDCT_WINDOWS_LENGTHS_7_5ms[6]; extern const LC3_INT MDCT_WINDOWS_LENGTHS_5ms[6]; +extern const LC3_INT MDCT_WINDOWS_LENGTHS_2_5ms[6]; /* Per band energy */ extern const LC3_INT* ACC_COEFF_PER_BAND[6]; @@ -173,17 +188,31 @@ extern const LC3_INT* ACC_COEFF_PER_BAND_HR[6]; extern const LC3_INT* ACC_COEFF_PER_BAND_2_5ms_HR[6]; extern const LC3_INT* ACC_COEFF_PER_BAND_2_5ms[5]; +#ifdef CR8_G_ADD_75MS +extern const LC3_INT* ACC_COEFF_PER_BAND_7_5ms_HR[6]; +extern const LC3_INT* ACC_COEFF_PER_BAND_7_5ms[5]; +#endif extern const LC3_INT* ACC_COEFF_PER_BAND_5ms_HR[6]; extern const LC3_INT* ACC_COEFF_PER_BAND_5ms[5]; /* Near Nyquist detector */ extern const LC3_INT NN_thresh; - +/* Tone detector */ +#ifdef CR8_E_TONE_DETECTOR +extern const LC3_INT32 TD_HR_thresh_10ms; +extern const LC3_INT32 TD_HR_thresh_7_5ms; +extern const LC3_INT32 TD_HR_thresh_5ms; +extern const LC3_INT32 TD_HR_thresh_2_5ms; +#endif // CR8_E_TONE_DETECTOR extern const LC3_INT32 xavg_N_grp[5]; extern const LC3_FLOAT *hannOla_wins[5]; extern const LC3_INT32 gwlpr[MAX_LGW+1]; +#ifdef CR8_A_PLC_FADEOUT_TUNING +extern const LC3_INT16 fade_scheme_tab[24 / 2][3]; +extern const LC3_FLOAT scATHFx[MAX_LGW - 2]; +#endif extern const LC3_INT32 mdct_grp_bins[10]; extern const LC3_FLOAT* PhECU_whr16ms_wins[5]; @@ -200,4 +229,9 @@ extern const LC3_FLOAT plc_tdc_lpc_48[17]; extern const LC3_FLOAT plc_tdc_lpc_96[17]; extern const LC3_FLOAT plc_tdc_lpc_8_25ms[9]; +#if defined(CR8_A_PLC_FADEOUT_TUNING) +extern const LC3_INT16 plc_fadeout_param_maxlen[4]; +extern const LC3_INT16 plc_fadeout_param_maxbytes[4]; #endif + +#endif /* CONSTANTS_H */ diff --git a/lib_lc3plus/cutoff_bandwidth.c b/lib_lc3plus/cutoff_bandwidth.c index 642b2afda2ef1848f5b232a4caf9d0770db6ef57..c2d37312eb17c23d750b816d34a6c46d7cd49888 100644 --- a/lib_lc3plus/cutoff_bandwidth.c +++ b/lib_lc3plus/cutoff_bandwidth.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -13,7 +13,7 @@ void process_cutoff_bandwidth(LC3_FLOAT *d_fl, LC3_INT len, LC3_INT bw_bin) { - LC3_INT i = 0; + LC3_INT i; if (len > bw_bin){ for (i = -1; i < 3; i++) { diff --git a/lib_lc3plus/dct4.c b/lib_lc3plus/dct4.c index 8fd5784b287477aeffd3ee987e81527f755f2163..9b12627d71e53e585d771098c839cfb87fcf0d5e 100644 --- a/lib_lc3plus/dct4.c +++ b/lib_lc3plus/dct4.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -30,18 +30,17 @@ void dct2_apply(Dct2* dct, const LC3_FLOAT* input, LC3_FLOAT* output) { Complex tmp1[MAX_LEN]; Complex tmp2[MAX_LEN]; - int i = 0; - const int len = dct->length; + int i; assert(input != output); - for (i = 0; i < len / 2; i++) { + for (i = 0; i < 8; i++) { tmp1[i] = cmplx(input[i * 2], 0); - tmp1[len - i - 1] = cmplx(input[i * 2 + 1], 0); + tmp1[16 - i - 1] = cmplx(input[i * 2 + 1], 0); } fft_apply(&dct->fft, tmp1, tmp2); - for (i = 0; i < len; i++) { + for (i = 0; i < 16; i++) { output[i] = cmul(tmp2[i], dct2_16[i]).r; } output[0] /= (LC3_FLOAT)1.414213562373095; /* SQRT(2) */ @@ -50,7 +49,7 @@ void dct2_apply(Dct2* dct, const LC3_FLOAT* input, LC3_FLOAT* output) void dct4_init(Dct4* dct, int length) { - int i = 0; + int i; assert(length <= MAX_LEN); dct->length = length; dct->twid1 = calloc(sizeof(*dct->twid1), length / 2); @@ -81,13 +80,13 @@ void dct4_apply(Dct4* dct, const LC3_FLOAT* input, LC3_FLOAT* output) const LC3_FLOAT norm = (LC3_FLOAT)1.0 / LC3_SQRT((LC3_FLOAT)(len >> 1)); assert(input != output); - for (i = 0; i < len / 2; i++) { + for (i = 0; i < len >> 1; i++) { tmp1[i] = cmul(cmplx(input[i * 2], input[len - i * 2 - 1]), dct->twid1[i]); } fft_apply(&dct->fft, tmp1, tmp2); - for (i = 0; i < len / 2; i++) { + for (i = 0; i < len >> 1; i++) { Complex t = cmul(tmp2[i], dct->twid2[i]); output[i * 2] = t.r * norm; output[len - i * 2 - 1] = -t.i * norm; diff --git a/lib_lc3plus/dec_entropy.c b/lib_lc3plus/dec_entropy.c index d8512a1068b49c042f627936fa46b0b3df21339b..f072b82d6f7c62847cdf40d9631654f95df8d63f 100644 --- a/lib_lc3plus/dec_entropy.c +++ b/lib_lc3plus/dec_entropy.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -32,7 +32,7 @@ void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* void read_uint_fl(LC3_INT nbits, LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* val) { - LC3_INT bit = 0, i = 0; + LC3_INT bit, i; read_bit_fl(ptr, mask_side, bp_side, val); @@ -131,8 +131,8 @@ void processDecoderEntropy_fl(LC3_UINT8* bytes, LC3_INT numbytes, LC3_INT* mask_ LC3_INT* lsbMode, LC3_INT frame_dms) { - LC3_INT plc_trigger_bw = 0, plc_trigger_last_nz = 0, plc_trigger_SNS1 = 0, plc_trigger_SNS2 = 0, tmp = 0, bit = 0, - submodeMSB = 0, i = 0, ltpf_tmp[3] = {0}, ind = 0, submodeLSB = 0, bp_side_local = 0, mask_side_local = 0; + LC3_INT plc_trigger_bw, plc_trigger_last_nz, plc_trigger_SNS1, plc_trigger_SNS2, tmp, bit, + submodeMSB, i, ltpf_tmp[3], ind, submodeLSB, bp_side_local, mask_side_local; LC3_UINT8* ptr; LC3_INT gainMSBbits[4] = {1, 1, 2, 2}; @@ -174,7 +174,7 @@ void processDecoderEntropy_fl(LC3_UINT8* bytes, LC3_INT numbytes, LC3_INT* mask_ } /* Last non-zero tuple */ - read_uint_fl(ceil(LC3_LOGTWO(N / 2)), ptr, &mask_side_local, &bp_side_local, lastnz); + read_uint_fl(ceil(LC3_LOGTWO(N >> 1)), ptr, &mask_side_local, &bp_side_local, lastnz); *lastnz = (*lastnz + 1) * 2; if (*lastnz > N) { diff --git a/lib_lc3plus/dec_lc3_fl.c b/lib_lc3plus/dec_lc3_fl.c index 88c528b0f639178567a55b87a2084a20cc9b8864..7389ffa53e3dd15d57c9ddd55686478bca71c264 100644 --- a/lib_lc3plus/dec_lc3_fl.c +++ b/lib_lc3plus/dec_lc3_fl.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -58,17 +58,13 @@ static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs bfi = 2; switch (decoder->frame_dms) { -# ifdef ENABLE_025_DMS_MODE case 25: max_bw_stopband = max_bw_stopband >> 2; break; -# endif -# ifdef ENABLE_050_DMS_MODE case 50: max_bw_stopband = max_bw_stopband >> 1; break; -# endif -# ifdef ENABLE_075_DMS_MODE +# ifdef CR8_G_ADD_75MS case 75: max_bw_stopband = 3 * (max_bw_stopband >> 2); break; @@ -151,7 +147,11 @@ static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs &h_DecSetup->PlcAdvSetup->cum_fading_slow, &h_DecSetup->PlcAdvSetup->cum_fading_fast, h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->sqQdec_fl, h_DecSetup->spec_inv_idx, decoder->yLen, bfi, decoder->frame_dms, h_DecSetup->concealMethod, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_param[0], - &h_DecSetup->PlcAdvSetup->cum_fflcAtten); + &h_DecSetup->PlcAdvSetup->cum_fflcAtten +#ifdef CR8_A_PLC_FADEOUT_TUNING + , h_DecSetup->PlcAdvSetup->plc_fadeout_type +#endif + ); /* IMDCT */ if (h_DecSetup->concealMethod == 4 || bfi != 1 ) @@ -171,6 +171,9 @@ static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs bfi, h_DecSetup->ltpf_param, h_DecSetup->ltpf_param_mem, h_DecSetup->ltpf_conf_beta_idx, h_DecSetup->ltpf_conf_beta, h_DecSetup->concealMethod, h_DecSetup->alpha , &h_DecSetup->ltpf_mem_active +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + , &h_DecSetup->rel_pitch_change, decoder->hrmode, decoder->frame_dms +#endif ); { diff --git a/lib_lc3plus/defines.h b/lib_lc3plus/defines.h index d978fa4e15e73671ee23cb4eedad8eb9b681ba01..d9251c018199acd00168afb1398a7782c8c3e3b5 100644 --- a/lib_lc3plus/defines.h +++ b/lib_lc3plus/defines.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,6 +11,7 @@ #ifndef DEFINES_H #define DEFINES_H +#include "options.h" #include "stdint.h" @@ -24,13 +25,14 @@ typedef int8_t LC3_INT8; typedef uint32_t LC3_UINT32; /* Release defines */ -// #define ENABLE_2_5MS_MODE +#define ENABLE_2_5MS_MODE #define ENABLE_5MS_MODE +#define ENABLE_075_DMS_MODE #define ENABLE_10_MS_MODE #define ENABLE_ADVANCED_PLC_FL #define ENABLE_ADVANCED_PLC_FL_DEFAULT #define ENABLE_BW_CONTROLLER -//#define ENABLE_HR_MODE_FL +#define ENABLE_HR_MODE_FL #define ENABLE_PADDING #define ENABLE_RFRAME_FL #define ENABLE_PLC @@ -41,20 +43,89 @@ typedef uint32_t LC3_UINT32; #define ENABLE_FRAME_MS_FLAG #define ENABLE_HR_MODE_FL_FLAG +#define CR8_G_ADD_75MS + #ifndef NO_POST_REL_CHANGES /* Post-release non-bitexact changes */ +#define CR8_A_PLC_FADEOUT_TUNING /* Adapt PLC fadeout to avoid gaps in signal */ +#define CR9_D_FLOATING_POINT_CODE_SIMPLIFICATIONS +#define CR9_F_PITCH_WIN_LEN_FIX /* Increase window length for pitch calculation */ +#define CR9_G_IMPROVE_TDC /* summarize G,H,J,L,N */ +#ifdef CR9_G_IMPROVE_TDC +# define CR9_G_PLC_NS_TDC_FIX /* Always use TDC if pitch > 0 */ +# define CR9_H_REMOVE_SWITCH_TO_PLC_NS +# define CR9_J_SLOW_TDC_FADEOUT +# define CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER +# ifdef ENABLE_HR_MODE_FL +# ifdef PLC_TUNING_SHORT_FADEOUT +# define CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH +# endif +# endif +#endif /* CR9_G_IMPROVE_TDC */ +#define CR9_I_INC_TDC_FADEOUT_LEN +#define CR9_K_REDUCE_NORM_CORR_TH #endif /* NO_POST_REL_CHANGES */ +#ifdef CR9_D_FLOATING_POINT_CODE_SIMPLIFICATIONS +# define CR9_SIMPLIFY_LOOP +# define CR9_LTPF_REWRITE +# define CR9_QUANT_SPEC_REWRITE +# define CR9_SIMPLIFY_ARI_DECODER +#endif + +#ifdef CR8_A_PLC_FADEOUT_TUNING +#define MAX_UINT8 255 +# ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER +# ifdef CR9_K_REDUCE_NORM_CORR_TH +# define THRESH_100_DMS_TDC_CNT 9 +# define THRESH_100_DMS_NS_CNT 7 +# define THRESH_100_DMS_TDC_NS_CNT 73 +# define THRESH_075_DMS_TDC_CNT 7 +# define THRESH_075_DMS_NS_CNT 7 +# define THRESH_075_DMS_TDC_NS_CNT 87 +# define THRESH_050_DMS_TDC_CNT 22 +# define THRESH_050_DMS_NS_CNT 15 +# define THRESH_050_DMS_TDC_NS_CNT 141 +# define THRESH_025_DMS_TDC_CNT 20 +# define THRESH_025_DMS_NS_CNT 21 +# define THRESH_025_DMS_TDC_NS_CNT 278 +# else +# define THRESH_100_DMS_TDC_CNT 3 +# define THRESH_100_DMS_NS_CNT 35 +# define THRESH_100_DMS_TDC_NS_CNT 114 +# define THRESH_075_DMS_TDC_CNT 6 +# define THRESH_075_DMS_NS_CNT 37 +# define THRESH_075_DMS_TDC_NS_CNT 130 +# define THRESH_050_DMS_TDC_CNT 12 +# define THRESH_050_DMS_NS_CNT 55 +# define THRESH_050_DMS_TDC_NS_CNT 227 +# define THRESH_025_DMS_TDC_CNT 10 +# define THRESH_025_DMS_NS_CNT 138 +# define THRESH_025_DMS_TDC_NS_CNT 431 +# endif +# else +# define FAC1_FADEOUT 0.2 +# define FAC2_FADEOUT 1.5 +# define FAC3_FADEOUT 1.75 +# endif +#define REL_PITCH_THRESH 0.36 +#define PLC_LONGTERM_ANALYSIS_MS 200 /* Analysis window 2000 ms / 10 ms */ + +#define PLC_LONGTERM_ANALYSIS_STARTUP_FILL 0.5f /* required buffer fill amount, set to 0.0 to not require any fill at all */ + + +#endif + /* Precision Defines */ -#define LC3_FABS(x) (fabsf(x)) -#define LC3_POW(x, y) (powf(x, y)) +#define LC3_FABS(x) (fabsf(x)) +#define LC3_POW(x, y) (powf(x, y)) #define LC3_LOGTEN(x) (log10f(x)) -#define LC3_LOGTWO(x) (log2f(x)) -# define LC3_COS(x) (cos(x)) -# define LC3_SIN(x) (sin(x)) -#define LC3_SQRT(x) (sqrtf(x)) -#define LC3_EXP(x) (expf(x)) +#define LC3_LOGTWO(x) (log2f(x)) +#define LC3_COS(x) (cos(x)) +#define LC3_SIN(x) (sin(x)) +#define LC3_SQRT(x) (sqrtf(x)) +#define LC3_EXP(x) (expf(x)) # define MAX_BR 320000 /* 400 * 800 */ # define MIN_BR_100DMS 16000 /* 20 * 800 * 100/100 */ @@ -62,10 +133,20 @@ typedef uint32_t LC3_UINT32; # define MIN_BR_050DMS 32000 /* 20 * 800 * 100/ 50 */ # define MAX_BR_050DMS_NB 260800 /* 163 * 800 * 100/ 50 */ # define MAX_BR_100DMS_NB 114400 /* for 100ms at 8kHz */ - # define MAX_BR_100DMS_WB 221600 /* for 100ms at 16kHz */ # define MAX_BR_100DMS_SSWB 314400 /* for 100ms at 24kHz */ +#ifdef CR8_G_ADD_75MS +# define MIN_BR_075DMS_48KHZ_HR ((int)124800/ 800/2)* 800 +# define MIN_BR_075DMS_96KHZ_HR ((int)149600/ 800/2)* 800 +# define MIN_BR_075DMS 21334 /* ceil( 20 * 800 * 100/ 75) */ +# define MAX_BR_075DMS 426667 /* ceil(400 * 800 * 100/ 75) */ +# define MAX_BR_075DMS_NB 152534 /* ceil(143 * 800 * 100/ 75) */ +# define MAX_BR_075DMS_WB 295467 /* ceil(277 * 800 * 100/ 75) */ +# define MAX_BR_075DMS_SSWB 419200 /* ceil(393 * 800 * 100/ 75) */ +#endif +# define CR8_E_TONE_DETECTOR /* Tone detector for hrmode to deactivate TNS - improves SNR and THD+N */ + typedef int32_t LC3_INT32; # if defined(__xtensa__) @@ -76,7 +157,26 @@ typedef int32_t LC3_INT32; # define ALIGNMENT_BALLOC_RED 7 # endif +#ifndef CR8_A_PLC_FADEOUT_TUNING # define PLC2_FADEOUT_IN_MS 30 +#endif + +#ifdef CR8_A_PLC_FADEOUT_TUNING +/* PLC2/PhEcu fading settings */ +/* PLC2/PHEcu muting Table setup settings */ +# define PLC2_FADEOUT_IN_MS_MIN 30 /* Table min */ +# define PLC2_FADEOUT_IN_MS_MAX 140 /* Table max */ +# define PLC2_FADEOUT_RES 10 /* 10 ms steps used in fadeout constant tables */ + +/* current active settings */ +# define PLC2_FADEOUT_IN_MS 30 /* 30 P800 fadeout optimized */ +#if 0 +# define PLC2_FADEOUT_LONG_IN_MS 50 /* 50 ABBA test */ +#endif +# define PLC2_FADEOUT_LONG_IN_MS 120 /* 120 MUSHRA, && stable tonal fadeout optimized */ + +#endif + # define PHECU_FRES 62.5 # define PHECU_C_JACOB 1.1429 # define MAX_LGW 9 /* LGW48K + 1 !! */ @@ -108,16 +208,21 @@ typedef int32_t LC3_INT32; # define TDC_L_FIR_HP 11 # define PLC3_HPBLENDTHROTTLE 30 /* higher numbers increase throttled blending from hp filtered to unfiltered uv excitation (0 is no throttle) */ +#ifdef CR9_I_INC_TDC_FADEOUT_LEN +# define PLC_FADEOUT_TYPE_1_IN_MS 200 +#endif # define PLC_FADEOUT_IN_MS 60 /* fade-out to zero in ms for TD-PLC and NS, minimum value is 20 */ # define PLC4_TRANSIT_START_IN_MS 20 /* begin of transition time for noise substitution for voiced signals */ # define PLC4_TRANSIT_END_IN_MS PLC_FADEOUT_IN_MS /* end of transition time for noise substitution */ # define PLC34_ATTEN_FAC_100 0.5000 /* attenuation factor for NS and TDC @ 10 ms*/ +#ifdef CR8_G_ADD_75MS +# define PLC34_ATTEN_FAC_075 0.5946 /* attenuation factor for NS and TDC @ 7.5 ms */ +#endif # define PLC34_ATTEN_FAC_050 0.7071 /* attenuation factor for NS and TDC @ 5.0 ms*/ # define PLC34_ATTEN_FAC_025 0.8409 /* attenuation factor for NS and TDC @ 2.5 ms*/ # define FEC_SLOT_BYTES_MIN 40 -# define FEC_SLOT_BYTES_MAX 400 - +# define FEC_SLOT_BYTES_MAX 400 # define LC3_CONST_POW_2_M15 3.051757812500000e-05 # define LC3_CONST_POW_2_23 8388608 @@ -134,16 +239,30 @@ typedef int32_t LC3_INT32; #define G192_ONE 0x0081 #define READ_G192FER /* Allow C executable to also read G192 formatted FER files */ +#ifdef DEBUG +#ifdef READ_G192FER +# define READ_G192_FER_BYTE /* Allow C executable to also read G192 byte formatted FER files 0x20=BAD , 0x21=Good */ +#endif +#endif + + # define LC3_EPS (1.1e-7f) #define M_PI 3.14159265358979323846 /* FUNCTION MACROS */ #define CEILING(x, y) (((x) + (y)-1) / (y)) + + +#ifdef CR8_A_PLC_FADEOUT_TUNING +#define FRAME2FS_IDX_10MS(x) (x<500 ? (x/100) : 5) /* 80 -> 0, 160 -> 1, 240 -> 2, 320 -> 3, 480 -> 4 , 960 -> 5*/ +#define FS2FS_IDX(x) ((x) == 96000 ? 5 : (x) / 10000) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4, 96000 -> 5 */ +#else #define FRAME2FS_IDX(x) (x / 100) /* 80 -> 0, 160 -> 1, 240 -> 2, 320 -> 3, 480 -> 4*/ #define FS2FS_IDX(x) \ (x / 10000) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4 \ */ +#endif #define UNUSED(x) (void)(x) /* silence unused parameter warning */ #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -159,6 +278,7 @@ typedef int32_t LC3_INT32; /* OPTIONS */ +#define MAX_LEN_NR 480 #define MAX_SR 96000 #define EXT_RES_ITER_MAX 20 #define MAX_BW_BANDS_NUMBER 6 diff --git a/lib_lc3plus/detect_cutoff_warped.c b/lib_lc3plus/detect_cutoff_warped.c index 9392867208e6d9270092e5789153a267c68f13e8..239da4255fcfb10335c7505711c5cdcbf1845296 100644 --- a/lib_lc3plus/detect_cutoff_warped.c +++ b/lib_lc3plus/detect_cutoff_warped.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -13,10 +13,10 @@ void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx) { - const LC3_INT *warp_idx_start = NULL, *warp_idx_stop = NULL; - LC3_INT counter = 0, brickwall = 0, i = 0, stop = 0, dist = 0; - LC3_FLOAT d2_mean = 0, d2_sum = 0, e_diff = 0, thr = 0; - const LC3_INT *bw_dist = NULL; + const LC3_INT *warp_idx_start, *warp_idx_stop; + LC3_INT counter, brickwall = 0, i, stop, dist; + LC3_FLOAT d2_mean, d2_sum, e_diff, thr; + const LC3_INT *bw_dist; warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; @@ -33,6 +33,13 @@ void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_d warp_idx_stop = BW_warp_idx_stop_all_5ms[fs_idx - 1]; bw_dist = brickwall_dist; break; +#ifdef CR8_G_ADD_75MS + case 75: + warp_idx_start = BW_warp_idx_start_all_7_5ms[fs_idx - 1]; + warp_idx_stop = BW_warp_idx_stop_all_7_5ms[fs_idx - 1]; + bw_dist = brickwall_dist_7_5ms; + break; +#endif case 100: warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; diff --git a/lib_lc3plus/enc_entropy.c b/lib_lc3plus/enc_entropy.c index a7ff8cd70006ea601d7ffa0b579989a3258ba9f7..23423b5d809734869c165e9fdd62e1fed9ab68ad 100644 --- a/lib_lc3plus/enc_entropy.c +++ b/lib_lc3plus/enc_entropy.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,6 +11,9 @@ #include "options.h" #include "functions.h" +static const LC3_INT gainMSBbits[4] = {1, 1, 2, 2}; +static const LC3_INT gainLSBbits[4] = {0, 1, 0, 1}; + void processEncoderEntropy_fl(LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, LC3_INT bw_cutoff_idx, LC3_INT lastnz, LC3_INT N, LC3_INT lsbMode, LC3_INT gg_idx, LC3_INT num_tns_filters, LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* scf_idx, LC3_INT fac_ns_idx @@ -18,8 +21,8 @@ void processEncoderEntropy_fl(LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_ ) { LC3_UINT8* ptr; - LC3_INT i = 0, submodeMSB = 0, submodeLSB = 0, tmp = 0, gainMSB = 0, gainLSB = 0; - LC3_INT gainMSBbits[4] = {1, 1, 2, 2}, gainLSBbits[4] = {0, 1, 0, 1}; + LC3_INT i, submodeMSB, submodeLSB, tmp, gainMSB, gainLSB; + LC3_INT16 lastnzTrigger[5] = {63, 127, 127, 255, 255}; @@ -38,7 +41,7 @@ void processEncoderEntropy_fl(LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_ } else { - write_uint_backward_fl(ptr, bp_side, mask_side, lastnz / 2 - 1, ceil(LC3_LOGTWO(N / 2))); + write_uint_backward_fl(ptr, bp_side, mask_side, lastnz / 2 - 1, ceil(LC3_LOGTWO(N >> 1))); } /* LSB mode bit */ @@ -100,27 +103,25 @@ void processEncoderEntropy_fl(LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_ void write_uint_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT val, LC3_INT numbits) { - LC3_INT k = 0, bit = 0; + LC3_INT k, bit; for (k = 0; k < numbits; k++) { bit = val & 1; write_bit_backward_fl(ptr, bp_side, mask_side, bit); - val = val / 2; + val = val >> 1; } } void write_bit_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT bit) { - if (bit == 0) { - ptr[*bp_side] = ptr[*bp_side] & (255 - *mask_side); - } else { + if (bit != 0) { ptr[*bp_side] = ptr[*bp_side] | *mask_side; - } + } if (*mask_side == 128) { *mask_side = 1; *bp_side = *bp_side - 1; } else { - *mask_side = *mask_side * 2; + *mask_side = *mask_side << 1; } } diff --git a/lib_lc3plus/enc_lc3_fl.c b/lib_lc3plus/enc_lc3_fl.c index c89f7244ca8e03bc7593d0a49ebc873f14981c8c..404b80fb4b10fbb313bbc5d286048728e0bee509 100644 --- a/lib_lc3plus/enc_lc3_fl.c +++ b/lib_lc3plus/enc_lc3_fl.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -62,14 +62,22 @@ static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s /* Pitch estimation */ processOlpa_fl(h_EncSetup->s_12k8, h_EncSetup->olpa_mem_s12k8, h_EncSetup->olpa_mem_s6k4, - &h_EncSetup->olpa_mem_pitch, &T0_out, &normcorr, s_12k8_len, encoder->frame_dms); + &h_EncSetup->olpa_mem_pitch, +#ifdef CR9_F_PITCH_WIN_LEN_FIX + &h_EncSetup->pitch_flag, +#endif + &T0_out, &normcorr, s_12k8_len, encoder->frame_dms); /* LTPF encoder */ process_ltpf_coder_fl(h_EncSetup->s_12k8, s_12k8_len + 1, h_EncSetup->ltpf_enable, T0_out, normcorr, encoder->frame_dms, h_EncSetup->ltpf_mem_in, encoder->ltpf_mem_in_len, &h_EncSetup->ltpf_mem_normcorr, &h_EncSetup->ltpf_mem_ltpf_on, &h_EncSetup->ltpf_mem_pitch, h_EncSetup->ltpf_param, &h_EncSetup->ltpf_mem_mem_normcorr, - <pfBits); + <pfBits +#ifdef CR9_K_REDUCE_NORM_CORR_TH + ,encoder->hrmode +#endif +); /* Attack detector */ attack_detector_fl(h_EncSetup->s_in_scaled, encoder->frame_length, encoder->fs, &h_EncSetup->attdec_position, @@ -79,8 +87,12 @@ static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s /* Per-band energy */ processPerBandEnergy_fl(encoder->bands_number, encoder->bands_offset, encoder->hrmode, encoder->frame_dms, h_EncSetup->ener, d_fl); /* Near Nyquist detector */ - processNearNyquistdetector_fl(&encoder->near_nyquist_flag, encoder->fs_idx, encoder->near_nyquist_index, encoder->bands_number, h_EncSetup->ener); - + processNearNyquistdetector_fl(&encoder->near_nyquist_flag, encoder->fs_idx, encoder->near_nyquist_index, encoder->bands_number, h_EncSetup->ener +#ifdef CR8_E_TONE_DETECTOR + , encoder->frame_dms, encoder->hrmode ); +#else + ); +#endif /* Disable LTPF if nyquist detector triggers or -lfe mode is active*/ if (encoder->near_nyquist_flag != 0 || h_EncSetup->lfe == 1) { @@ -100,8 +112,8 @@ static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s BW_cutoff_idx = 0; } - processSnsComputeScf_fl(h_EncSetup->ener, encoder->tilt, encoder->bands_number, h_EncSetup->scf, - h_EncSetup->attdec_detected, encoder->sns_damping, encoder->attdec_damping); + processSnsComputeScf_fl(h_EncSetup->ener, encoder->bands_number, h_EncSetup->scf, + h_EncSetup->attdec_detected, encoder->sns_damping, encoder->attdec_damping, encoder->fs_idx); /* SNS Quantizer */ process_snsQuantizesScf_Enc(h_EncSetup->scf, h_EncSetup->L_scf_idx, h_EncSetup->scf_q, h_EncSetup->dct2StructSNS); diff --git a/lib_lc3plus/estimate_global_gain.c b/lib_lc3plus/estimate_global_gain.c index df9b1f5f238f39cfe0c41ae58c398b8746a970df..fdaa977c0644c7d72e4949d298cd2ce835160868 100644 --- a/lib_lc3plus/estimate_global_gain.c +++ b/lib_lc3plus/estimate_global_gain.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -19,9 +19,9 @@ void processEstimateGlobalGain_fl(LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC ) { - LC3_INT i = 0, N = 0, offset = 0, j = 0, iszero = 0; - LC3_FLOAT g_min = 0, x_max = 0, tmp = 0, ind = 0, ind_min = 0, target = 0, fac = 0, ener = 0; - LC3_FLOAT en[MAX_LEN / 4] = {0}; + LC3_INT i, N, offset, j, iszero, fac; + LC3_FLOAT g_min, x_max, tmp, ind, ind_min, target, ener; + LC3_FLOAT en[MAX_LEN / 4]; LC3_FLOAT reg_val = 4.656612873077393e-10; if (*old_targetBits < 0) { @@ -61,7 +61,7 @@ void processEstimateGlobalGain_fl(LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC } else { g_min = x_max / (32767 - 0.375); } - /* Prevent positive rounding errors from LC3_LOGTEN function */ + /* Prevent positive rounding errors from LC3_LOG10 function */ ind_min = 28.0 * LC3_LOGTEN(g_min); ind_min = ceil(ind_min + LC3_FABS(ind_min) * LC3_EPS); @@ -85,8 +85,9 @@ void processEstimateGlobalGain_fl(LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC fac = 256; offset = 255 + quantizedGainOff; - for (i = 0; i < 8; i++) { - fac = fac * 0.5; + for (i = 0; i < 8; i++) + { + fac = fac >> 1; offset = offset - fac; ener = 0; iszero = 1; diff --git a/lib_lc3plus/fft/cfft.c b/lib_lc3plus/fft/cfft.c index 4bd8d29ade753c2c594dc34d0680fbdb3b9c5e8a..e8a6304ee17ec78ed1fc056c3af0628b6e23b84f 100644 --- a/lib_lc3plus/fft/cfft.c +++ b/lib_lc3plus/fft/cfft.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -8,6 +8,7 @@ ******************************************************************************/ + #include "options.h" #include "cfft.h" #include "iisfft.h" /* for M_PIl */ diff --git a/lib_lc3plus/fft/cfft.h b/lib_lc3plus/fft/cfft.h index 3902b4c396d152f621d5f61cbfe03c853fabc26e..6ba8dfccd372823a10726793c87d8daa652b90dd 100644 --- a/lib_lc3plus/fft/cfft.h +++ b/lib_lc3plus/fft/cfft.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -9,6 +9,7 @@ +#include "options.h" #include "../functions.h" #ifndef CFFT_H diff --git a/lib_lc3plus/fft/fft_15_16.h b/lib_lc3plus/fft/fft_15_16.h index 83ca77353b5c83df31ef3bd2c278a251ab5d4240..c527f1bf5625413c85da3c5f7026f8ed71f66ea2 100644 --- a/lib_lc3plus/fft/fft_15_16.h +++ b/lib_lc3plus/fft/fft_15_16.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/fft/fft_240_480.h b/lib_lc3plus/fft/fft_240_480.h index c1d96c87b8016d516ff5cd96687309a11f450cd9..18a0c8707a871b091ff60d0f59262e500d89ff9f 100644 --- a/lib_lc3plus/fft/fft_240_480.h +++ b/lib_lc3plus/fft/fft_240_480.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/fft/fft_2_9.h b/lib_lc3plus/fft/fft_2_9.h index 54f4f839dfcba878cdf037f9940d49982c58c3c0..55fe84f3b779057b5c65c63587b262cf20b7cf15 100644 --- a/lib_lc3plus/fft/fft_2_9.h +++ b/lib_lc3plus/fft/fft_2_9.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/fft/fft_32.h b/lib_lc3plus/fft/fft_32.h index 48b891108b88b53a9529c32d035b1aba981c4968..803923a0158c42dc3f0d88ae81cb5765e6acf8a5 100644 --- a/lib_lc3plus/fft/fft_32.h +++ b/lib_lc3plus/fft/fft_32.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/fft/fft_384_768.h b/lib_lc3plus/fft/fft_384_768.h index 47f42e90d6546a945a4857a14a43bbc90ec2cfe9..bd89393c174c8f14b4b2db5fee253f0a41e803c8 100644 --- a/lib_lc3plus/fft/fft_384_768.h +++ b/lib_lc3plus/fft/fft_384_768.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/fft/fft_60_128.h b/lib_lc3plus/fft/fft_60_128.h index 75f1aaef45cf21c69b717e39a63cdff31f2c984b..e5a88ccad873d19fb1757cc14df1be36d6502b50 100644 --- a/lib_lc3plus/fft/fft_60_128.h +++ b/lib_lc3plus/fft/fft_60_128.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/fft/fft_generic.h b/lib_lc3plus/fft/fft_generic.h index e517ffb2501daf1d5e4ff16fcb1bb9197d6a616e..903875ab5a7b6ef471e4898ca3a868d49bebeb67 100644 --- a/lib_lc3plus/fft/fft_generic.h +++ b/lib_lc3plus/fft/fft_generic.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/fft/iis_fft.c b/lib_lc3plus/fft/iis_fft.c index b1f8ab5ab8d42629700fa31642587bb93f4900e5..30ae240200b48660d57df9a92d490f301551c2ab 100644 --- a/lib_lc3plus/fft/iis_fft.c +++ b/lib_lc3plus/fft/iis_fft.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -15,8 +15,8 @@ #include #include #include - #include "iis_fft.h" + /**************************************************************************************************/ /* AFFT uses two fft implementations @@ -25,7 +25,6 @@ fast lengths, check the fft_n function. */ - #define FFT_COMPLEX 1 #define FFT_REAL 2 diff --git a/lib_lc3plus/fft/iis_fft.h b/lib_lc3plus/fft/iis_fft.h index b658930fa7cf51fae7861d9a1dca2c46671e7fdb..b70a3719d3d671c8e47f4191955fbe78ae8076a0 100644 --- a/lib_lc3plus/fft/iis_fft.h +++ b/lib_lc3plus/fft/iis_fft.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,6 +11,7 @@ #ifndef IIS_FFT_H #define IIS_FFT_H +#include "options.h" #include "../structs.h" #include "../defines.h" #include "cfft.h" diff --git a/lib_lc3plus/fft/iisfft.c b/lib_lc3plus/fft/iisfft.c index 227d2b6037c8fef97141631b512e6736987603b9..cdf7f8d2a8faf2d494a4693eba9cbc0682fb786f 100644 --- a/lib_lc3plus/fft/iisfft.c +++ b/lib_lc3plus/fft/iisfft.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -8,8 +8,8 @@ ******************************************************************************/ -#include "options.h" +#include "options.h" #include #include /* for mmove */ #include diff --git a/lib_lc3plus/fft/iisfft.h b/lib_lc3plus/fft/iisfft.h index 7b448e2bbeca4f093791f039e885c42c94688af2..b45e73cdec772d0f494ba1d45c79b75cf2e1e82b 100644 --- a/lib_lc3plus/fft/iisfft.h +++ b/lib_lc3plus/fft/iisfft.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,6 +11,7 @@ #ifndef IISFFT_H #define IISFFT_H +#include "options.h" #include "../defines.h" #ifndef M_PIl diff --git a/lib_lc3plus/functions.h b/lib_lc3plus/functions.h index 7a529a25d7acbe5e90b00b6d72f5199fa2f0ae47..b0997e85fac8d5e7973c498885bfab736bead53c 100644 --- a/lib_lc3plus/functions.h +++ b/lib_lc3plus/functions.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,6 +11,7 @@ #ifndef FUNCTIONS_H #define FUNCTIONS_H +#include "options.h" #include "clib.h" #include "defines.h" #include "float.h" @@ -106,8 +107,11 @@ void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3 void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx); -void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4, LC3_INT* mem_old_T0, LC3_INT* T0_out, - LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms); +void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4, LC3_INT* mem_old_T0, +#ifdef CR9_F_PITCH_WIN_LEN_FIX + LC3_INT* pitch_flag, +#endif + LC3_INT* T0_out,LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms); void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits, LC3_INT* order_out, LC3_INT* rc_idx, LC3_INT* tns_numfilters, LC3_INT* bits_out @@ -117,14 +121,18 @@ void levinsonDurbin(LC3_FLOAT* r, LC3_FLOAT* out_lev, LC3_FLOAT* rc_unq, LC3_FLO void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs); -void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor); +void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor, LC3_INT fs_idx); void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT* gains_LC3_INT); void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx); void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, - const LC3_INT bands_number, const LC3_FLOAT* ener); - + const LC3_INT bands_number, const LC3_FLOAT* ener +#ifdef CR8_E_TONE_DETECTOR + , const LC3_INT16 frame_dms, const LC3_INT16 hrmode ); +#else + ); +#endif void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT* d2, LC3_FLOAT* d); void ProcessingIMDCT_fl(LC3_FLOAT* y, LC3_INT yLen, const LC3_FLOAT* win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x, @@ -134,12 +142,19 @@ void ProcessingITDA_WIN_OLA_fl(LC3_FLOAT* x_tda, LC3_INT32 yLen, const LC3_FLOAT void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, LC3_FLOAT* mem_old_x, LC3_INT memLen, LC3_FLOAT* mem_norm_corr_past, LC3_INT* mem_on, LC3_FLOAT* mem_pitch, - LC3_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits); + LC3_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits +#ifdef CR9_K_REDUCE_NORM_CORR_TH + ,LC3_INT16 hrmode +#endif +); void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT fs, LC3_FLOAT* mem_old_x, LC3_FLOAT* mem_old_y, LC3_INT* mem_pitch_LC3_INT, LC3_INT* mem_pitch_fr, LC3_FLOAT* mem_gain, LC3_INT* mem_beta_idx, LC3_INT bfi, LC3_INT* param, LC3_INT* mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, LC3_FLOAT damping , LC3_INT *mem_ltpf_active +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + , LC3_FLOAT *rel_pitch_change, LC3_INT hrmode, LC3_INT frame_dms +#endif ); void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], @@ -225,10 +240,19 @@ void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, LC3_INT32 ns_nbLostCmpt, LC3_FLOAT *stabFac, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast, LC3_FLOAT *spec_prev, LC3_FLOAT *spec, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 bfi, LC3_INT32 frame_dms, LC3_INT32 concealMethod, LC3_INT32 pitch_present_bfi1, LC3_INT32 pitch_present_bfi2, - LC3_FLOAT *cum_fflcAtten); + LC3_FLOAT *cum_fflcAtten +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ); + void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb, LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow, - LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx); + LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ); void plc_phEcu_F0_refine_first(LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, const LC3_INT32 Xabs_len, LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm); @@ -253,7 +277,12 @@ void plc_phEcu_spec_ana(LC3_FLOAT* xfp, LC3_INT32 xfp_len, const LC3_FLOAT* LC3_FLOAT* f0hzLtpBinPtr, LC3_FLOAT* f0gainLtpPtr, LC3_INT32 bw_idx, Fft* PhEcu_Fft); void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est, LC3_INT32 time_offs, Complex* X, LC3_INT32 X_len, LC3_FLOAT* mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT* alpha, LC3_FLOAT* beta, LC3_FLOAT* Xavg, - LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, LC3_FLOAT *corr_phase_dbg, + LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT16 fadeout, /* needed for DC muting */ + LC3_INT16* nonpure_tone_flag_ptr, /* i/o: flag */ +#endif + LC3_FLOAT *corr_phase_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg); void plc_phEcu_rec_frame(Complex *X_in, LC3_INT32 xfp_len, LC3_INT32 Lecu, const LC3_FLOAT *whr, const LC3_FLOAT *winMDCT, LC3_INT32 Lprot, LC3_FLOAT *xfp, LC3_INT32 time_offs, LC3_FLOAT *x_out, @@ -268,12 +297,21 @@ void plc_phEcu_tba_per_band_gain(LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FL void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *grp_pow_change, LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec, - LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames, LC3_FLOAT *thresh_dbg); + LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames, + LC3_FLOAT *thresh_dbg +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ); void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, - LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg); + LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ); void plc_phEcu_hq_ecu( LC3_FLOAT *f0binPtr, LC3_FLOAT *f0ltpGainPtr, LC3_FLOAT *xfp, LC3_INT16 prev_bfi, LC3_INT32 *short_flag_prev, @@ -287,6 +325,10 @@ void plc_phEcu_hq_ecu( LC3_FLOAT *st_beta_mute, LC3_FLOAT *st_mag_chg_1st, LC3_FLOAT *st_Xavg, LC3_INT32 LA_ZEROS, LC3_FLOAT *x_tda, LC3_FLOAT *xsubst_dbg, Complex *X_out_m_dbg, LC3_INT32 *seed_dbg, LC3_FLOAT *mag_chg_dbg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg, LC3_FLOAT *corr_phase_dbg ,Fft* PhEcu_Fft,Fft* PhEcu_Ifft +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type, + LC3_INT16 *nonpure_tone_flag_ptr +#endif ); void processTdcPreemphasis_fl(LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT32 n_bands); @@ -296,7 +338,11 @@ void processTdcInverseOdft_fl(LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out, void processTdcApply_fl(const LC3_INT32 pitch_LC3_INT, const LC3_FLOAT *preemphFac, const LC3_FLOAT* A, const LC3_INT32 lpc_order, const LC3_FLOAT* pcmbufHist, const LC3_INT32 max_len_pcm_plc, const LC3_INT32 N, const LC3_INT32 frame_dms, const LC3_INT32 SampRate, const LC3_INT32 nbLostCmpt, const LC3_INT32 overlap, const LC3_FLOAT *stabFac, LC3_FLOAT harmonicBuf[MAX_PITCH], LC3_FLOAT synthHist[M], - LC3_INT32* fract, LC3_INT16* seed, LC3_FLOAT* gain_c, LC3_FLOAT* alpha, LC3_FLOAT* synth); + LC3_INT32* fract, LC3_INT16* seed, LC3_FLOAT* gain_c, LC3_FLOAT* alpha, LC3_FLOAT* synth +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + ,LC3_UINT8 plc_fadeout_type +#endif +); void* balloc(void* base, size_t* base_size, size_t size); diff --git a/lib_lc3plus/imdct.c b/lib_lc3plus/imdct.c index 5d38aa6cc78077272ea68a12eb0bcf05a5d714ee..b1b5d4b43b9ac9b54d48834fbb5c4cece45f9727 100644 --- a/lib_lc3plus/imdct.c +++ b/lib_lc3plus/imdct.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -14,8 +14,8 @@ /* Function expects already flipped window */ void ProcessingIMDCT_fl(LC3_FLOAT* y, LC3_INT yLen, const LC3_FLOAT* win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x, Dct4* dct) { - LC3_FLOAT x_tda[MAX_LEN] = {0}, x_ov[2 * MAX_LEN] = {0}; - LC3_INT i = 0, j = 0; + LC3_FLOAT x_tda[MAX_LEN], x_ov[2 * MAX_LEN]; + LC3_INT i, j; /* Flip imdct window up to down */ i = winLen - 1; @@ -61,7 +61,7 @@ void ProcessingIMDCT_fl(LC3_FLOAT* y, LC3_INT yLen, const LC3_FLOAT* win, LC3_IN void ProcessingITDA_WIN_OLA_fl(LC3_FLOAT* x_tda, LC3_INT32 yLen, const LC3_FLOAT* win, LC3_INT32 winLen, LC3_INT32 last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x) { - LC3_FLOAT x_ov[2 * MAX_LEN] = {0}; + LC3_FLOAT x_ov[2 * MAX_LEN]; LC3_INT32 i, j; move_float(x_ov, &x_tda[yLen / 2], yLen / 2); diff --git a/lib_lc3plus/lc3.c b/lib_lc3plus/lc3.c index 17d2ccb71296628426a4edbb9598145b700ecf1f..f09c53a5386fbf839d505a10bc0015d714734101 100644 --- a/lib_lc3plus/lc3.c +++ b/lib_lc3plus/lc3.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -71,6 +71,9 @@ static int lc3plus_frame_size_supported(float frame_ms) { case 25: /* fallthru */ case 50: /* fallthru */ +#ifdef CR8_G_ADD_75MS + case 75: /* fallthru */ +#endif case 100: return 1; default: break; } @@ -102,7 +105,6 @@ int32_t lc3_enc_supported_lfe(void) LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]) { int ch = 0; - RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); RETURN_IF((uintptr_t)encoder % 4 != 0, LC3PLUS_ALIGN_ERROR); RETURN_IF(!lc3plus_samplerate_supported(samplerate), LC3PLUS_SAMPLERATE_ERROR); @@ -198,7 +200,6 @@ LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, int frame_dms) LC3PLUS_Error lc3plus_enc_set_bandwidth(LC3PLUS_Enc *encoder, int bandwidth) { LC3_INT effective_fs; - RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); #ifdef ENABLE_HR_MODE_FL_FLAG RETURN_IF(encoder->hrmode == 1, LC3PLUS_HRMODE_BW_ERROR); @@ -359,7 +360,7 @@ LC3PLUS_Error lc3plus_free_encoder_structs(LC3PLUS_Enc* encoder) LC3PLUS_Error lc3plus_free_decoder_structs(LC3PLUS_Dec* decoder) { - int ch = 0; + int ch = 0; RETURN_IF(!decoder, LC3PLUS_NULL_ERROR); for (ch = 0; ch < decoder->channels; ch++) { @@ -388,7 +389,6 @@ LC3PLUS_Error lc3plus_enc_set_ep_mode(LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmod { LC3PLUS_EpMode oldEpmode; LC3PLUS_Error error; - RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); RETURN_IF((unsigned)epmode > LC3PLUS_EP_HIGH, LC3PLUS_EPMODE_ERROR); oldEpmode = encoder->epmode; diff --git a/lib_lc3plus/lc3.h b/lib_lc3plus/lc3.h index 3e45438fede66c23bfeb2efc0b3927e7a46e78d0..0981cea84b9ee01072eb44c7c4ab01e7d11af2be 100644 --- a/lib_lc3plus/lc3.h +++ b/lib_lc3plus/lc3.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -25,6 +25,7 @@ #define LC3PLUS_H #ifndef _MSC_VER +#include "options.h" #include #else typedef unsigned char uint8_t; @@ -36,7 +37,7 @@ typedef __int32 int32_t; #define LC3PLUS_VERSION_INT(major, minor, micro) (((major) << 16) | ((minor) << 8) | (micro)) /*! Version number to ensure header and binary are matching. */ -#define LC3PLUS_VERSION LC3PLUS_VERSION_INT(1, 6, 9) +#define LC3PLUS_VERSION LC3PLUS_VERSION_INT(1, 7, 2) /*! Maximum number of supported channels. The actual binary might support * less, use lc3plus_channels_supported() to check. */ diff --git a/lib_lc3plus/lc3plus_fft.c b/lib_lc3plus/lc3plus_fft.c index 14f443f860d995f76b063ecbbe8636f54b52720f..f1fc8fe714590f7565ef85e735ca5070dadcb9e7 100644 --- a/lib_lc3plus/lc3plus_fft.c +++ b/lib_lc3plus/lc3plus_fft.c @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * * estoppel or otherwise. * ******************************************************************************/ - + #include "options.h" #include "functions.h" @@ -19,11 +19,11 @@ void fft_init(Fft* fft, int length) HANDLE_IIS_FFT handle = NULL; IIS_FFT_ERROR error = 0; assert(length % 2 == 0); - + fft->length = length; - + error = LC3_IIS_CFFT_Create(&handle, length, IIS_FFT_FWD); - + assert(error == IIS_FFT_NO_ERROR); fft->handle = handle; } @@ -31,10 +31,10 @@ void fft_init(Fft* fft, int length) void fft_free(Fft* fft) { IIS_FFT_ERROR error = 0; - + if (fft) { error = LC3_IIS_CFFT_Destroy((HANDLE_IIS_FFT *) &fft->handle); - + assert(error == IIS_FFT_NO_ERROR); memset(fft, 0, sizeof(*fft)); } @@ -82,7 +82,7 @@ void fft_apply(Fft* fft, const Complex* input, Complex* output) { IIS_FFT_ERROR error = 0; error = LC3_IIS_FFT_Apply_CFFT(fft->handle, input, output); - + assert(error == IIS_FFT_NO_ERROR); } @@ -90,10 +90,11 @@ void fft_apply(Fft* fft, const Complex* input, Complex* output) void real_fft_apply(Fft* fft, const LC3_FLOAT* input, LC3_FLOAT* output) { IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; - + UNUSED(error); - error = LC3_IIS_FFT_Apply_RFFT(fft->handle, input, output); + error = LC3_IIS_FFT_Apply_RFFT(fft->handle, input, output); assert(error == IIS_FFT_NO_ERROR); } + diff --git a/lib_lc3plus/license.h b/lib_lc3plus/license.h index d9d6c89675d4fadc0455effff0f0edae8fc2193c..266f91a1656a6ff187e3c2f0cf1b3c39c9274ffc 100644 --- a/lib_lc3plus/license.h +++ b/lib_lc3plus/license.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -8,11 +8,12 @@ ******************************************************************************/ +#include "options.h" #include "defines.h" static const char *const LICENSE = "*******************************************************************************\n" - "* ETSI TS 103 634 V1.4.1 *\n" + "* ETSI TS 103 634 V1.4.3 *\n" "* Low Complexity Communication Codec Plus (LC3plus) *\n" "* Floating Point Software V%i.%i.%iETSI, " __DATE__ " *\n" "* Copyright licence is solely granted through ETSI Intellectual Property *\n" diff --git a/lib_lc3plus/ltpf_coder.c b/lib_lc3plus/ltpf_coder.c index fac8c481c003aee4bf8fb8b2d03b921cd33a047f..286d8fa166bd26e29c3a09c1f3b2d610ad599526 100644 --- a/lib_lc3plus/ltpf_coder.c +++ b/lib_lc3plus/ltpf_coder.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -15,7 +15,7 @@ static LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len); LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) { - LC3_INT max_i = 0, i = 0; + LC3_INT max_i = 0, i; LC3_FLOAT max = 0; if (len <= 0) { @@ -34,16 +34,29 @@ LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, LC3_FLOAT* mem_old_x, LC3_INT memLen, LC3_FLOAT* mem_norm_corr_past, LC3_INT* mem_on, LC3_FLOAT* mem_pitch, - LC3_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits) + LC3_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits +#ifdef CR9_K_REDUCE_NORM_CORR_TH + , LC3_INT16 hrmode +#endif +) { - LC3_FLOAT buffer[LTPF_MEMIN_LEN + LEN_12K8 + 1 + (LEN_12K8 >> 2)] = {0}, sum = 0, buf_tmp[MAX_LEN] = {0}, cor_up[MAX_LEN] = {0}, *x; - LC3_INT i = 0, j = 0, k = 0, n = 0, step = 0, N = 0, ltpf_active = 0, pitch_search_delta = 0, + LC3_FLOAT buffer[LTPF_MEMIN_LEN + LEN_12K8 + 1 + (LEN_12K8 >> 2)], sum = 0, cor_up[(MAX_PITCH_12K8 - MIN_PITCH_12K8) / 2] = {0}, *x; + LC3_INT i, j, n, step, N, ltpf_active, pitch_search_delta, pitch_search_upsamp = 0, pitch_search_L_interpol1 = 0, t0_min = 0, t0_max = 0, t_min = 0, t_max = 0, temp2 = 0, t1 = 0, pitch_int = 0, pitch_fr = 0, midpoint = 0, delta_up = 0, delta_down = 0, pitch_index = 0, gain = 0, acflen = 0; - LC3_FLOAT norm_corr = 0, cor[MAX_LEN] = {0}, cor_int[MAX_LEN] = {0}, currFrame[MAX_LEN] = {0}, predFrame[MAX_LEN] = {0}, sum1 = 0, sum2 = 0, sum3 = 0; + LC3_FLOAT cor_tmp, cor_int_tmp, norm_corr = 0, cor[MAX_LEN_NR], cor_int[MAX_LEN_NR], sum1 = 0, sum2 = 0, sum3 = 0; LC3_FLOAT pitch = 0; +#ifdef CR9_K_REDUCE_NORM_CORR_TH + LC3_FLOAT normCorrTh = 0.0f; + if (hrmode) { + normCorrTh = 0.4; + } else { + normCorrTh = 0.6; + } +#endif + /* Signal Buffer */ N = xLen - 1; x = &buffer[memLen]; @@ -59,7 +72,11 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC pitch_search_upsamp = 4; pitch_search_L_interpol1 = 4; +#ifdef CR9_K_REDUCE_NORM_CORR_TH + if (pitch_ol_norm_corr > normCorrTh) { +#else if (pitch_ol_norm_corr > 0.6) { +#endif /* Search Bounds */ t0_min = pitch_ol - pitch_search_delta; t0_max = pitch_ol + pitch_search_delta; @@ -83,19 +100,24 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC sum1 += x[j] * x[j]; sum2 += x[j - t_min] * x[j - t_min]; } + + /* Do first iteration outside of loop */ + sum = mac_loop(x, &x[-t_min], acflen); + + sum3 = LC3_SQRT(sum1 * sum2) + 1.00e-05; + norm_corr = sum / sum3; + + norm_corr = MAX(0, norm_corr); + cor[0] = norm_corr; /* Compute Cross-Correlation */ - for (i = t_min; i <= t_max; i++) { - sum = 0; - for (j = 0; j < acflen; j++) { - sum += x[j] * x[j - i]; - } + for (i = t_min + 1; i <= t_max; i++) { + sum = mac_loop(x, &x[-i], acflen); - if (i > t_min) { - sum2 = sum2 + x[-i]*x[-i] + sum2 = sum2 + x[-i]*x[-i] - x[acflen - 1 - ( i - 1 )]*x[acflen - 1 - ( i - 1 )]; - } - sum3 = LC3_SQRT(sum1 * sum2) + LC3_POW(10, -5); + + sum3 = LC3_SQRT(sum1 * sum2) + 1.00e-05; norm_corr = sum / sum3; norm_corr = MAX(0, norm_corr); @@ -104,13 +126,7 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC } /* Find Integer Pitch-Lag */ - j = 0; - for (i = pitch_search_L_interpol1; i <= t_max - t_min - pitch_search_L_interpol1; i++) { - buf_tmp[j] = cor[i]; - j++; - } - - temp2 = searchMaxIndice(buf_tmp, j); + temp2 = searchMaxIndice(&cor[pitch_search_L_interpol1], t_max - t_min - pitch_search_L_interpol1 - pitch_search_L_interpol1 + 1); t1 = temp2 + t0_min; assert(t1 >= t0_min && t1 <= t0_max); @@ -128,13 +144,7 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC } for (i = 0; i < pitch_search_upsamp * (t0_max - t0_min + 1); i++) { - sum = 0; - - k = 0; - for (j = i; j < i + 32; j++) { - sum += cor_up[j] * inter4_1[k]; - k++; - } + sum = mac_loop(&cor_up[i], (const LC3_FLOAT *)inter4_1, 32); cor_int[i] = sum; } @@ -153,14 +163,15 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC } else { delta_down = pitch_search_upsamp - step; } - + j = 0; for (i = midpoint - delta_down - 1; i <= midpoint + delta_up; i = i + step) { - buf_tmp[j] = cor_int[i]; + cor[j] = cor_int[i]; j++; } - temp2 = searchMaxIndice(buf_tmp, ((midpoint + delta_up) - (midpoint - delta_down)) / step + 1); + + temp2 = searchMaxIndice(cor, ((midpoint + delta_up) - (midpoint - delta_down)) / step + 1); pitch_fr = temp2 * step - delta_down; if (pitch_fr >= 0) { @@ -188,34 +199,25 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC pitch = (LC3_FLOAT) pitch_int + (LC3_FLOAT) pitch_fr / 4.0; + /* Normalized Correlation */ + sum1 = sum2 = sum3 = 0; for (n = 0; n < acflen; n++) { - currFrame[n] = x[n + 1] * enc_inter_filter[0][0] + + cor_tmp = x[n + 1] * enc_inter_filter[0][0] + x[n] * enc_inter_filter[0][1] + x[n - 1] * enc_inter_filter[0][2]; - predFrame[n] = x[n - pitch_int + 1] * enc_inter_filter[pitch_fr][0] + + cor_int_tmp = x[n - pitch_int + 1] * enc_inter_filter[pitch_fr][0] + x[n - pitch_int] * enc_inter_filter[pitch_fr][1] + x[n - pitch_int - 1] * enc_inter_filter[pitch_fr][2] + x[n - pitch_int - 2] * enc_inter_filter[pitch_fr][3]; + + sum1 += cor_tmp * cor_int_tmp; + sum2 += cor_tmp * cor_tmp; + sum3 += cor_int_tmp * cor_int_tmp; } - /* Normalized Correlation */ - sum1 = sum2 = sum3 = 0; - - for (i = 0; i < acflen; i++) { - sum1 += currFrame[i] * predFrame[i]; - } - - for (i = 0; i < acflen; i++) { - sum2 += currFrame[i] * currFrame[i]; - } - - for (i = 0; i < acflen; i++) { - sum3 += predFrame[i] * predFrame[i]; - } - - sum2 = LC3_SQRT(sum2 * sum3) + LC3_POW(10, -5); + sum2 = LC3_SQRT(sum2 * sum3) + 1.00e-05; norm_corr = sum1 / sum2; assert(norm_corr >= -1.00001 && norm_corr <= 1.00001); diff --git a/lib_lc3plus/ltpf_decoder.c b/lib_lc3plus/ltpf_decoder.c index a40c85213a13afa678bd1e4cbff6a62b5169086a..e95a274a46907cbb213f16c8f81006f86e1113ef 100644 --- a/lib_lc3plus/ltpf_decoder.c +++ b/lib_lc3plus/ltpf_decoder.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -16,18 +16,31 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f LC3_INT* param, LC3_INT* mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, LC3_FLOAT damping , LC3_INT *mem_ltpf_active +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + , LC3_FLOAT *rel_pitch_change, LC3_INT hrmode, LC3_INT frame_dms +#endif ) { - LC3_INT i = 0, j = 0, n = 0, N = 0, L_past_x = 0, N4 = 0, N34 = 0, - pitch_int = 0, pitch_fr = 0, p1 = 0, p2 = 0, L_past_y = 0, inter_len = 0, tilt_len = 0, - tilt_len_r = 0, inter_len_r = 0, old_x_len = 0, old_y_len = 0; - - LC3_FLOAT conf_alpha = 0, gain = 0, a1[MAX_LEN] = {0}, a2[MAX_LEN] = {0}, b1[MAX_LEN] = {0}, b2[MAX_LEN] = {0}, - buf_x[4 * MAX_LEN] = {0}, buf_y[4 * MAX_LEN] = {0}, buf_z[4 * MAX_LEN] = {0}, pitch = 0, sum1 = 0, sum2 = 0; - + LC3_INT i, j, n, N, L_past_x, N4, N34, + pitch_int, pitch_fr, p1, p2, L_past_y, inter_len, tilt_len = 0, + tilt_len_r, inter_len_r, old_x_len, old_y_len; + + LC3_FLOAT conf_alpha, gain, a1[12], a2[12], b1[11], b2[11], + buf_x[4 * MAX_LEN], buf_y[4 * MAX_LEN], buf_z[4 * MAX_LEN], pitch, sum1, sum2; +#ifdef CR9_LTPF_REWRITE + LC3_FLOAT *p_x, *p_y, *p_y2, *p_x_init, *p_y_init, *p_a1, *p_b1, *p_a2, *p_b2, fade_fac, current_fade_fac_up, current_fade_fac_down; +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + LC3_FLOAT pitch_fl_c_old, pitch_delta; +#endif const LC3_FLOAT *inter_filter[4], *tilt_filter[4]; - +#ifdef WMOPS + push_wmops("process_ltpf_decoder_fl"); +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + pitch_fl_c_old = (LC3_FLOAT) *mem_pitch_int + (LC3_FLOAT)*mem_pitch_fr / 4.0; +#endif conf_alpha = 0.85; if (bfi != 1) { @@ -213,6 +226,13 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f } /* First quarter of the current frame: cross-fading */ +#ifdef CR9_LTPF_REWRITE + fade_fac = 1. / (LC3_FLOAT) N4; + current_fade_fac_up = 0.f; + current_fade_fac_down = 1.f; + (void) p_x; (void) p_y; (void) p_a1; (void) p_b1; +#endif + if (mem_param[1] == 0 && param[1] == 0) { memmove(&buf_y[L_past_y], &buf_x[L_past_x], sizeof(LC3_FLOAT) * N4); @@ -232,8 +252,14 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f j++; } +#ifdef CR9_LTPF_REWRITE + buf_y[L_past_y + n] = buf_x[L_past_x + n] - current_fade_fac_down * sum1 + + current_fade_fac_down * sum2; + current_fade_fac_down -= fade_fac; +#else buf_y[L_past_y + n] = buf_x[L_past_x + n] - (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum1 + (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum2; +#endif } } else if (mem_param[1] == 0 && param[1] == 1) { @@ -252,7 +278,12 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f j++; } +#ifdef CR9_LTPF_REWRITE + buf_y[L_past_y + n] = buf_x[L_past_x + n] - current_fade_fac_up * sum1 + current_fade_fac_up * sum2; + current_fade_fac_up += fade_fac; +#else buf_y[L_past_y + n] = buf_x[L_past_x + n] - ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum1 + ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum2; +#endif } } else if (*mem_pitch_int == pitch_int && *mem_pitch_fr == pitch_fr) { for (n = 0; n < N4; n++) { @@ -273,6 +304,69 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f buf_y[L_past_y + n] = buf_x[L_past_x + n] - sum1 + sum2; } } else { +#ifdef CR9_LTPF_REWRITE + p_x_init = &buf_x[L_past_x]; + p_y_init = &buf_y[L_past_y - p1 + inter_len - 1]; + p_y2 = &buf_y[L_past_y]; + for (n = 0; n < N4; n++) { + sum1 = 0; + sum2 = 0; + p_b1 = b1; + p_x = p_x_init; + for (i = tilt_len; i >= 0; i--) { + sum1 += *p_b1 * *p_x; + p_b1++; + p_x--; + } + + p_y = p_y_init; + p_a1 = a1; + for (i = 2*inter_len - 1; i >= 0; i--) { + sum2 += *p_a1 * *p_y; + p_a1++; + p_y--; + } + + *p_y2 = *p_x_init - current_fade_fac_down * sum1 + + current_fade_fac_down * sum2; + current_fade_fac_down -= fade_fac; + p_x_init++; + p_y_init++; + p_y2++; + } + + move_float(buf_z, buf_y, (old_y_len + xLen)); + p_x_init = &buf_z[L_past_y]; /* buf z in this case */ + p_y_init = &buf_y[L_past_y - p2 + inter_len - 1]; + p_y2 = &buf_y[L_past_y]; + + for (n = 0; n < N4; n++) { + sum1 = 0; + sum2 = 0; + j = 0; + p_x = p_x_init; + p_b2 = b2; + for (i = tilt_len; i >= 0; i--) { + sum1 += *p_b2 * *p_x; + p_b2++; + p_x--; + } + + p_y = p_y_init; + p_a2 = a2; + for (i = 2*inter_len - 1; i >= 0; i--) { + sum2 += *p_a2 * *p_y; + p_a2++; + p_y--; + } + + *p_y2 = *p_x_init - current_fade_fac_up * sum1 + current_fade_fac_up * sum2; + current_fade_fac_up += fade_fac; + p_x_init++; + p_y_init++; + p_y2++; + } +#else for (n = 0; n < N4; n++) { sum1 = 0; sum2 = 0; @@ -292,7 +386,7 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum2; } - memmove(buf_z, buf_y, sizeof(LC3_FLOAT) * 4 * MAX_LEN); + memmove(buf_z, buf_y, sizeof(LC3_FLOAT) * (old_y_len + xLen)); for (n = 0; n < N4; n++) { sum1 = 0; @@ -311,8 +405,45 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f buf_y[L_past_y + n] = buf_z[L_past_y + n] - ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum1 + ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum2; } +#endif } +#ifdef CR9_LTPF_REWRITE + /* Second quarter of the current frame */ + if (param[1] == 0) { + move_float(&buf_y[L_past_y + N4], &buf_x[L_past_x + N4], + ((L_past_x + N4 + N34) - (L_past_x + N4))); + } else { + p_x_init = &buf_x[L_past_x + N4]; + p_y_init = &buf_y[L_past_y + N4 - p2 + inter_len - 1]; + p_y2 = &buf_y[L_past_y + N4]; + for (n = 0; n < N34; n++) { + sum1 = 0; + sum2 = 0; + p_b2 = b2; + p_x = p_x_init; + + for (i = 0; i <= tilt_len; i++) { + sum1 += *p_b2 * *p_x; + p_b2++; + p_x--; + } + + p_a2 = a2; + p_y = p_y_init; + + for (i = 2*inter_len - 1; i >= 0; i--) { + sum2 += *p_a2 * *p_y; + p_a2++; + p_y--; + } + p_y_init++; + *p_y2 = *p_x_init - sum1 + sum2; + p_x_init++; + p_y2++; + } + } +#else /* Second quarter of the current frame */ if (param[1] == 0) { memmove(&buf_y[L_past_y + N4], &buf_x[L_past_x + N4], @@ -336,7 +467,7 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f buf_y[L_past_y + N4 + n] = buf_x[L_past_x + N4 + n] - sum1 + sum2; } } - +#endif /* Output */ move_float(y, &buf_y[L_past_y], N); @@ -353,4 +484,14 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f *mem_pitch_fr = pitch_fr; *mem_gain = gain; *mem_beta_idx = conf_beta_idx; +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + if (bfi == 0 && hrmode == 1 && (frame_dms == 50 || frame_dms == 25)){ + pitch_delta = LC3_FABS(pitch_fl_c_old - (LC3_FLOAT)pitch_int - (LC3_FLOAT)(pitch_fr / 4.0)); + *rel_pitch_change = pitch_delta / MAX(pitch_fl_c_old, 1); + } +#endif + +#ifdef WMOPS + pop_wmops(); +#endif } diff --git a/lib_lc3plus/mdct.c b/lib_lc3plus/mdct.c index 11618b9465d4e3303f4251a50142f1f3b2954f31..ff4075977d1703dd8bfe1a6b834510b358eee3c0 100644 --- a/lib_lc3plus/mdct.c +++ b/lib_lc3plus/mdct.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -31,6 +31,26 @@ static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT h return NULL; } } +#ifdef CR8_G_ADD_75MS + else if (frame_dms == 75) { + switch (length) { + case 60: + return MDCT_WINS_7_5ms[hrmode][0]; + case 120: + return MDCT_WINS_7_5ms[hrmode][1]; + case 180: + return MDCT_WINS_7_5ms[hrmode][2]; + case 240: + return MDCT_WINS_7_5ms[hrmode][3]; + case 360: + return MDCT_WINS_7_5ms[hrmode][4]; + case 720: + return MDCT_WINS_7_5ms[hrmode][5]; + default: + return NULL; + } + } +#endif else if (frame_dms == 50) { switch (length) { case 40: @@ -74,10 +94,15 @@ void mdct_init(Mdct* mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC { if (frame_dms == 100) { mdct->leading_zeros = MDCT_la_zeroes[fs_idx]; - } + } +#ifdef CR8_G_ADD_75MS + else if (frame_dms == 75) { + mdct->leading_zeros = MDCT_la_zeroes_7_5ms[fs_idx]; + } +#endif else if (frame_dms == 50) { mdct->leading_zeros = MDCT_la_zeroes_5ms[fs_idx]; - } + } else if (frame_dms == 25) { mdct->leading_zeros = MDCT_la_zeroes_2_5ms[fs_idx]; } @@ -103,8 +128,8 @@ void mdct_free(Mdct* mdct) void mdct_apply(const LC3_FLOAT* input, LC3_FLOAT* output, Mdct* mdct) { - LC3_FLOAT tmp[MAX_LEN * 2] = {0}; - LC3_INT i = 0; + LC3_FLOAT tmp[MAX_LEN * 2]; + LC3_INT i; LC3_INT hlen; move_float(tmp, mdct->mem, mdct->mem_length); diff --git a/lib_lc3plus/mdct_shaping.c b/lib_lc3plus/mdct_shaping.c index 18761925042015e48be9b8e9f9bbb2ea46a0e376..d3ca7dd953b35d25cbbb96b8526b89d5d2402671 100644 --- a/lib_lc3plus/mdct_shaping.c +++ b/lib_lc3plus/mdct_shaping.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -13,11 +13,15 @@ void processMdctShaping_fl(LC3_FLOAT x[], LC3_FLOAT scf[], const LC3_INT bands_offset[], LC3_INT fdns_npts) { - LC3_INT i = 0, j = 0; + LC3_INT i, j; + LC3_FLOAT val; + j = 0; for (i = 0; i < fdns_npts; i++) { + val = scf[i]; + for (; j < bands_offset[i + 1]; j++) { - x[j] = x[j] * scf[i]; + x[j] = x[j] * val; } } } diff --git a/lib_lc3plus/near_nyquist_detector.c b/lib_lc3plus/near_nyquist_detector.c index ce94351302bcce089ac5c764420ae8fb4487cff2..e18eb52112d376c2b8be7034164b25edacc10df2 100644 --- a/lib_lc3plus/near_nyquist_detector.c +++ b/lib_lc3plus/near_nyquist_detector.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,32 +7,86 @@ * estoppel or otherwise. * ******************************************************************************/ -#include "functions.h" #include "options.h" +#include "functions.h" void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, - const LC3_INT bands_number, const LC3_FLOAT* ener) + const LC3_INT bands_number, const LC3_FLOAT* ener +#ifdef CR8_E_TONE_DETECTOR + , const LC3_INT16 frame_dms, const LC3_INT16 hrmode) +#else +) +#endif { *near_nyquist_flag = 0; +#ifdef CR8_E_TONE_DETECTOR + if (hrmode == 0){ +#endif + if (fs_idx < 4) + { + LC3_INT i = 0; + LC3_FLOAT ener_low = FLT_EPSILON, ener_high = 0; + + for (i=0; i NN_thresh * ener_low){ + *near_nyquist_flag = 1; + } + } +#ifdef CR8_E_TONE_DETECTOR + } + else // hrmode == 1 { - LC3_INT i = 0; - LC3_FLOAT ener_low = FLT_EPSILON, ener_high = 0; + // inverse spectral flatness = mean(energy) ./ 2^(mean(log2(energy))); + LC3_INT32 td_thresh, i = 0; + LC3_FLOAT mean_ener = 0, mean_ener_log2 = 0, inv_flatness = 0; - for (i=0; i NN_thresh * ener_low){ - *near_nyquist_flag = 1; + // calculate geometric mean + for (i = 0; i < bands_number; i++) + { + if (ener[i] != 0) { + mean_ener_log2 += LC3_LOGTWO(ener[i]); + } } + mean_ener_log2 = mean_ener_log2 / bands_number; + + inv_flatness = mean_ener / LC3_POW(2,mean_ener_log2); + + if (inv_flatness > td_thresh) { + *near_nyquist_flag = 1; + } } +#endif // CR8_E_TONE_DETECTOR } diff --git a/lib_lc3plus/noise_factor.c b/lib_lc3plus/noise_factor.c index c5aa582e456812b02a60d7a27d3ad935e55fb210..9cf130348f74dafed4f62698fa48a62ab1e71a2c 100644 --- a/lib_lc3plus/noise_factor.c +++ b/lib_lc3plus/noise_factor.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -15,94 +15,111 @@ void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3 LC3_INT target_bytes ) { - LC3_INT sumZeroLines = 0, kZeroLines = 0, startOffset = 0, nTransWidth = 0, end = 0, start = 0, i = 0, j = 0, k = 0, - allZeros = 0, m = 0; - LC3_FLOAT fac_ns_unq = 0, mean = 0, idx = 0, nsf1 = 0, nsf2 = 0; - LC3_INT zeroLines[MAX_LEN] = {0}, zL1[MAX_LEN] = {0}, zL2[MAX_LEN] = {0}; + LC3_INT sumZeroLines = 0, kZeroLines = 0, startOffset = 0, nTransWidth = 0, i = 0, j = 0, k = 0, m = 0, nzeros = 0; + LC3_FLOAT fac_ns_unq = 0, idx = 0, nsf1 = 0, nsf2 = 0; + LC3_INT zeroLines[MAX_LEN]; switch (frame_dms) { case 25: - nTransWidth = 4; + nTransWidth = 1; startOffset = 6; break; case 50: - nTransWidth = 4; + nTransWidth = 1; startOffset = 12; break; +#ifdef CR8_G_ADD_75MS + case 75: + nTransWidth = 2; + startOffset = 18; + break; +#endif case 100: - nTransWidth = 8; + nTransWidth = 3; startOffset = 24; break; } - for (k = startOffset; k < BW_cutoff_idx; k++) { - allZeros = 1; - - start = k - (nTransWidth - 2) / 2; - end = MIN(BW_cutoff_idx - 1, k + (nTransWidth - 2) / 2); - - for (i = start; i <= end; i++) { - if (xq[i] != 0) { - allZeros = 0; - } + for (k = startOffset - nTransWidth; k < startOffset + nTransWidth; k++) + { + if (xq[k] != 0) + { + nzeros = -2 * nTransWidth - 1; + } + if (xq[k] == 0) + { + nzeros ++; + } + } + for (k = startOffset; k < BW_cutoff_idx - nTransWidth; k++) + { + if (xq[k + nTransWidth] != 0) + { + nzeros = -2 * nTransWidth - 1; } + if (xq[k + nTransWidth] == 0) + { + nzeros ++; + } + if (nzeros >= 0) + { + zeroLines[j++] = k; + } + } - if (allZeros == 1) { - zeroLines[j] = k + 1; - kZeroLines++; - j++; + for (k = BW_cutoff_idx - nTransWidth; k < BW_cutoff_idx; k++) + { + nzeros ++; + if (nzeros >= 0) + { + zeroLines[j++] = k; } } - for (i = 0; i < kZeroLines; i++) { - sumZeroLines += zeroLines[i]; + if (j == 0) { + fac_ns_unq = 0; } + else + { + kZeroLines = j; - if (sumZeroLines > 0) { + fac_ns_unq = 0; for (j = 0; j < kZeroLines; j++) { - mean += LC3_FABS(x[zeroLines[j] - 1]); + fac_ns_unq += LC3_FABS(x[zeroLines[j]]); } - fac_ns_unq = mean / (gg * kZeroLines); - } else { - fac_ns_unq = 0; - } + fac_ns_unq /= (gg) * kZeroLines; + + + + if (kZeroLines > 1 && target_bytes <= 20 && frame_dms == 100) { + + j = 0, k = 0, nsf1 = 0, nsf2 = 0, sumZeroLines = 0; + + for (i = 0; i < kZeroLines; i++) { + sumZeroLines += zeroLines[i]; + } - if (kZeroLines > 0) - { - if (target_bytes <= 20 && frame_dms == 100) { - j = 0, k = 0; m = floor(sumZeroLines / kZeroLines); for (i = 0; i < kZeroLines; i++) { if (zeroLines[i] <= m) { - zL1[j] = zeroLines[i]; j++; + nsf1 += LC3_FABS(x[zeroLines[i]]); } - - if (zeroLines[i] > m) { - zL2[k] = zeroLines[i]; + else { + nsf2 += LC3_FABS(x[zeroLines[i]]); k++; } } - mean = 0; - for (i = 0; i < j; i++) { - mean += LC3_FABS(x[zL1[i] - 1]) / gg; - } - - nsf1 = mean / j; - - mean = 0; - for (i = 0; i < k; i++) { - mean += LC3_FABS(x[zL2[i] - 1]) / gg; - } - - nsf2 = mean / k; + nsf1 /= (gg) * j; + nsf2 /= (gg) * k; fac_ns_unq = MIN(nsf1, nsf2); } + } idx = round(8 - 16 * fac_ns_unq); diff --git a/lib_lc3plus/noise_filling.c b/lib_lc3plus/noise_filling.c index 7fac5e0f72de7b66130fcbbd93ee99e794543d3e..1ae4c8ab8c842ec16fb42b1697c17d3215219e14 100644 --- a/lib_lc3plus/noise_filling.c +++ b/lib_lc3plus/noise_filling.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -13,8 +13,8 @@ void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx) { - LC3_INT zeroLines[MAX_LEN] = {0}; - LC3_INT nTransWidth = 0, startOffset = 0, i = 0, j = 0, k = 0, start = 0, end = 0, allZeros = 0, kZeroLines = 0; + LC3_INT zeroLines[MAX_LEN]; + LC3_INT nTransWidth, startOffset, j, k, nzeros = 0, kZeroLines; LC3_FLOAT fac_ns = 0; switch (frame_dms) @@ -27,6 +27,12 @@ void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, nTransWidth = 1; startOffset = 12; break; +#ifdef CR8_G_ADD_75MS + case 75: + nTransWidth = 2; + startOffset = 18; + break; +#endif case 100: nTransWidth = 3; startOffset = 24; @@ -37,25 +43,44 @@ void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, j = 0; - for (k = startOffset; k < bw_stopband; k++) { - allZeros = 1; - - start = k - nTransWidth; - end = MIN(bw_stopband - 1, k + nTransWidth); - - for (i = start; i <= end; i++) { - if (xq[i] != 0) { - allZeros = 0; - } + for (k = startOffset - nTransWidth; k < startOffset + nTransWidth; k++) + { + if (xq[k] != 0) + { + nzeros = -2 * nTransWidth - 1; + } + if (xq[k] == 0) + { + nzeros ++; + } + } + for (k = startOffset; k < bw_stopband - nTransWidth; k++) + { + if (xq[k + nTransWidth] != 0) + { + nzeros = -2 * nTransWidth - 1; + } + if (xq[k + nTransWidth] == 0) + { + nzeros ++; + } + if (nzeros >= 0) + { + zeroLines[j++] = k; } + } - if (allZeros == 1) { - zeroLines[j] = k; - kZeroLines++; - j++; + for (k = bw_stopband - nTransWidth; k < bw_stopband; k++) + { + nzeros ++; + if (nzeros >= 0) + { + zeroLines[j++] = k; } } + kZeroLines = j; + for (k = 0; k < kZeroLines; k++) { nfseed = (13849 + (nfseed + 32768) * 31821) & 65535; nfseed -= 32768; diff --git a/lib_lc3plus/olpa.c b/lib_lc3plus/olpa.c index 6bec50952e5966214080221eb36e156b9ba0b176..b1b8f2171c41f6c621ff4f671c6a870d2ba2729c 100644 --- a/lib_lc3plus/olpa.c +++ b/lib_lc3plus/olpa.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,29 +11,24 @@ #include "options.h" #include "functions.h" -static void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_FLOAT len_buf, LC3_INT len_input); -static LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len); +static void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_INT32 len_input); +static LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT32 len); -void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_FLOAT len_buf, LC3_INT len_input) +void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_INT32 len_input) { - LC3_INT i = 0, j = 0; - LC3_FLOAT sum = 0; /* a = 1, so denominator == 1, nothing to do here */ + LC3_INT32 i, j; - for (i = 0; i < len_input; i++) { - j = 0; - sum = 0; - for (j = 0; (j < len_buf) && (j <= i); j++) { - sum += buf[j] * in[i - j]; - } - out[i] = sum; + j = 0; + for (i = 4; i < len_input; i += 2) { + out[j++] = (buf[0] * in[i]) + (buf[1] * in[i - 1]) + (buf[2] * in[i - 2]) + (buf[3] * in[i - 3]) + (buf[4] * in[i - 4]); } } LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) { - LC3_INT max_i = 0, i = 0; + LC3_INT max_i = 0, i; LC3_FLOAT max = in[0]; if (len <= 0) { @@ -50,52 +45,84 @@ LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) return max_i; } -void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4, LC3_INT* mem_old_T0, LC3_INT* T0_out, - LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms) +void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4, LC3_INT* mem_old_T0, +#ifdef CR9_F_PITCH_WIN_LEN_FIX + LC3_INT* pitch_flag, +#endif + LC3_INT* T0_out, LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms) { LC3_FLOAT norm_corr = 0, sum = 0, sum0 = 0, sum1 = 0, sum2 = 0, norm_corr2 = 0, *s6k4; - LC3_FLOAT buf[LEN_6K4 + MAX_PITCH_6K4] = {0}, filt_out[LEN_12K8 + 3] = {0}, d_wsp[LEN_6K4] = {0}, R0[RANGE_PITCH_6K4] = {0}, R[RANGE_PITCH_6K4] = {0}; /* constant length */ - LC3_INT i = 0, j = 0, len2 = 0, T0 = 0, T02 = 0, min_pitch = 0, max_pitch = 0, L = 0, mem_in_len = 0, acflen = 0; - + LC3_FLOAT buf[LEN_6K4 + MAX_PITCH_6K4 + MAX_LEN], R0[RANGE_PITCH_6K4]; /* constant length */ + LC3_INT i = 0, len2 = 0, T0 = 0, T02 = 0, min_pitch = 0, max_pitch = 0, L = 0, mem_in_len = 0, acflen = 0, delta = 0; - mem_in_len = MAX_PITCH_6K4; len2 = len / 2; +#ifdef CR9_F_PITCH_WIN_LEN_FIX + switch(frame_dms) + { + case 50: + delta = len / 2; + acflen = len2 * 2; + break; + + case 25: + delta = 3*(len /2); + acflen = len2*4; + break; + + default: +#endif + delta = 0; acflen = len2; +#ifdef CR9_F_PITCH_WIN_LEN_FIX + } +#endif + + mem_in_len = MAX_PITCH_6K4 + delta; + +#ifndef CR9_F_PITCH_WIN_LEN_FIX if (frame_dms == 25) { mem_in_len += 16; acflen += 16; } +#endif /* Downsampling */ move_float(buf, mem_s12k8, 3); move_float(&buf[3], s_12k8, len); move_float(mem_s12k8, &buf[len], 3); - filter_olpa(buf, filt_out, olpa_down2, 5, len + 3); - for (i = 4, j = 0; i < len + 3; i = i + 2) { - d_wsp[j] = filt_out[i]; - j++; - } + filter_olpa(buf, R0, olpa_down2, len + 3); /* Compute autocorrelation */ +#ifdef CR9_F_PITCH_WIN_LEN_FIX + s6k4 = &buf[mem_in_len - delta]; + move_float(&buf[mem_in_len], R0, len2); + move_float(buf, mem_s6k4, mem_in_len); + move_float(mem_s6k4, &buf[len2], mem_in_len); +#else s6k4 = &buf[mem_in_len]; move_float(buf, mem_s6k4, mem_in_len); - move_float(s6k4, d_wsp, len2); + move_float(s6k4, R0, len2); move_float(mem_s6k4, &buf[len2], mem_in_len); if (frame_dms == 25) { s6k4 = s6k4 - 16; } +#endif for (i = MIN_PITCH_6K4; i <= MAX_PITCH_6K4; i++) { - sum = 0; - for (j = 0; j < acflen; j++) { - sum += s6k4[j] * s6k4[j - i]; - } + sum = mac_loop(s6k4, &s6k4[-i], acflen); R0[i - MIN_PITCH_6K4] = sum; } /* Weight autocorrelation and find maximum */ - move_float(R, R0, RANGE_PITCH_6K4); + + /* Second try in the neighborhood of the previous pitch */ + min_pitch = MAX(MIN_PITCH_6K4, *mem_old_T0 - 4); + max_pitch = MIN(MAX_PITCH_6K4, *mem_old_T0 + 4); + + L = searchMaxIndice(&R0[min_pitch - MIN_PITCH_6K4], max_pitch - min_pitch + 1 ); + T02 = L + min_pitch; + for (i = 0; i < RANGE_PITCH_6K4; i++) { R0[i] = R0[i] * olpa_acw[i]; } @@ -104,22 +131,17 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4 /* Compute normalized correlation */ sum0 = sum1 = sum2 = 0; + for (i = 0; i < acflen; i++) { sum0 += s6k4[i] * s6k4[i - T0]; sum1 += s6k4[i - T0] * s6k4[i - T0]; sum2 += s6k4[i] * s6k4[i]; } sum1 = sum1 * sum2; - sum1 = LC3_SQRT(sum1) + LC3_POW(10.0, -5.0); + sum1 = LC3_SQRT(sum1) + 1.00e-05; norm_corr = sum0 / sum1; norm_corr = MAX(0, norm_corr); - /* Second try in the neighborhood of the previous pitch */ - min_pitch = MAX(MIN_PITCH_6K4, *mem_old_T0 - 4); - max_pitch = MIN(MAX_PITCH_6K4, *mem_old_T0 + 4); - L = searchMaxIndice(&R[min_pitch - MIN_PITCH_6K4], max_pitch - min_pitch + 1 ); - T02 = L + min_pitch; - if (T02 != T0) { sum0 = sum1 = sum2 = 0; for (i = 0; i < acflen; i++) { @@ -128,7 +150,7 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4 sum2 += s6k4[i] * s6k4[i]; } sum1 = sum1 * sum2; - sum1 = LC3_SQRT(sum1) + LC3_POW(10.0, -5.0); + sum1 = LC3_SQRT(sum1) + 1.00e-05; norm_corr2 = sum0 / sum1; norm_corr2 = MAX(0, norm_corr2); @@ -138,7 +160,41 @@ void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4 } } +#ifdef CR9_F_PITCH_WIN_LEN_FIX + switch(frame_dms) + { + case 50: + if (*pitch_flag == 1) + { + *mem_old_T0 = T0; + *pitch_flag = 0; + } + else + { + *pitch_flag += 1; + } + break; + + case 25: + if (*pitch_flag == 3) + { + *mem_old_T0 = T0; + *pitch_flag = 0; + } + else + { + *pitch_flag += 1; + } + break; + + default: +#endif *mem_old_T0 = T0; +#ifdef CR9_F_PITCH_WIN_LEN_FIX + } +#endif + *T0_out = T0 * 2.0; *normcorr_out = norm_corr; + } diff --git a/lib_lc3plus/pc_apply.c b/lib_lc3plus/pc_apply.c index 1d1bc40005b4d9382cb951570a6dbf569d5ab19a..4ca871f2fcca7b5c38ce7b24e9ebe73c41950fa3 100644 --- a/lib_lc3plus/pc_apply.c +++ b/lib_lc3plus/pc_apply.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/pc_classify.c b/lib_lc3plus/pc_classify.c index 71196edb89692cf1ebdbf8a1508e31174e92b8ae..9fa5f38d9cb232cee8f6b900c83e50d49f3ba99e 100644 --- a/lib_lc3plus/pc_classify.c +++ b/lib_lc3plus/pc_classify.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/pc_main.c b/lib_lc3plus/pc_main.c index 268ee94d2a383cf043d99089da3829907702c9c4..ead43deefe080feecf14ea8bb97cbd811945fa11 100644 --- a/lib_lc3plus/pc_main.c +++ b/lib_lc3plus/pc_main.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/pc_update.c b/lib_lc3plus/pc_update.c index 57539b50797673f624e35305a0bddb11614911b2..214ced77d07db3eaee4e9fe37d40822bc71a0b03 100644 --- a/lib_lc3plus/pc_update.c +++ b/lib_lc3plus/pc_update.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/per_band_energy.c b/lib_lc3plus/per_band_energy.c index db1b5b2d0f411925327aacd78ace3c30ce239b47..ec34c3d7dad0ac45baf99d87e4e23ebacd51c181 100644 --- a/lib_lc3plus/per_band_energy.c +++ b/lib_lc3plus/per_band_energy.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -13,8 +13,8 @@ void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT* d2, LC3_FLOAT* d) { - LC3_INT i = 0, j = 0, start = 0, stop = 0, maxBwBin = 0; - LC3_FLOAT sum = 0; + LC3_INT i, j, start, stop, maxBwBin; + LC3_FLOAT sum; # ifdef ENABLE_HR_MODE_FL if (hrmode) @@ -40,6 +40,11 @@ void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_ maxBwBin = maxBwBin >> 1; break; # endif +#ifdef CR8_G_ADD_75MS + case 75: + maxBwBin = (maxBwBin >> 2) * 3; + break; +#endif } for (i = 0; i < bands_number; i++) { diff --git a/lib_lc3plus/plc_classify.c b/lib_lc3plus/plc_classify.c index 619a1f7419b1301242a9bb9264b5f7fe77330c89..e45f08747d85c29eedc3fc9020ceb7852913187a 100644 --- a/lib_lc3plus/plc_classify.c +++ b/lib_lc3plus/plc_classify.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,6 +11,87 @@ #include "options.h" #include "functions.h" +#ifdef CR8_A_PLC_FADEOUT_TUNING + +static LC3_INT32 change_bit_at_position(LC3_INT32 value, LC3_UINT8 bit_position, LC3_INT8 bit) +{ + LC3_INT32 helper_mask = ~(1 << bit_position); + LC3_INT32 tmp = value & helper_mask; + tmp = tmp | (bit << bit_position); + return tmp; +} + +static void update_bit_and_byte_positions(LC3_INT16 longterm_analysis_counter_max_bytebuffer, LC3_INT8 *byte_position, LC3_INT8 *bit_position) +{ + if (*bit_position == 30) + { + *bit_position = 0; + + if ((*byte_position - longterm_analysis_counter_max_bytebuffer) < -1) + { + *byte_position = *byte_position + 1; + } else { + *byte_position = 0; + } + } else { + *bit_position = *bit_position + 1; + } +} + +static void array_insert_and_shift(LC3_INT32 *array, LC3_UINT8 value, LC3_INT16 longterm_analysis_counter_max, LC3_INT16 *overall_counter, LC3_INT8 *byte_position, LC3_INT8 *bit_position) +{ + LC3_INT32 current_byte = 0; + + if (overall_counter != NULL) + { + *overall_counter = MIN(*overall_counter + 1, longterm_analysis_counter_max); + } + + current_byte = array[*byte_position]; + + current_byte = change_bit_at_position(current_byte, *bit_position, value); + + array[*byte_position] = current_byte; +} + +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER +static void array_calculate(LC3_INT32 *array_tdc, LC3_INT32 *array_ns, int length, LC3_INT16 *counter_tdc, LC3_INT16 *counter_ns, LC3_INT16 longterm_analysis_counter_max) +#else +static void array_calculate(LC3_INT32 *array_tdc, LC3_INT32 *array_ns, int length, LC3_INT16 *counter_tdc, LC3_INT16 *counter_ns, LC3_INT16 *counter_phecu, LC3_INT16 overall_counter, LC3_INT16 longterm_analysis_counter_max) +#endif +{ + int i, k; + LC3_INT32 current_byte_tdc = 0, current_byte_ns = 0; + LC3_INT16 counter_loc_tdc = 0, counter_loc_ns = 0, counter_tmp = 0; + + for (i = length - 1; i >= 0; i--) + { + current_byte_tdc = array_tdc[i]; + current_byte_ns = array_ns[i]; + + for (k = 0; k < 30; k++) + { + counter_loc_tdc += ((current_byte_tdc >> k) & 1); + counter_loc_ns += ((current_byte_ns >> k) & 1); + counter_tmp++; + + /* Break from both loops if full 2s buffer has been evaluated */ + if (counter_tmp >= longterm_analysis_counter_max) + { + i = -1; + k = 30; + break; + } + } + } + + *counter_tdc = counter_loc_tdc; + *counter_ns = counter_loc_ns; +#ifndef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + *counter_phecu = overall_counter - counter_loc_tdc - counter_loc_ns; +#endif +} +#endif static void plc_xcorr_lc(LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_INT32 pitch_int, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 fs, LC3_FLOAT *xcorr); static void spectral_centroid_lc(LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT *bands_offset, LC3_INT32 bands_number, LC3_INT32 framelength, LC3_INT32 fs, LC3_FLOAT *sc); @@ -22,21 +103,46 @@ void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *n ) { LC3_FLOAT sc, class; - +#ifdef CR8_A_PLC_FADEOUT_TUNING + int fs_idx_tmp; +#endif + if (plcAd) { *xcorr = 0; } +#ifdef CR8_A_PLC_FADEOUT_TUNING + fs_idx_tmp = FS2FS_IDX(fs); + /* Save statistics for 24 kHz, 48 kHz and 96 kHz */ + if ((bfi == 1) || ((bfi >= 0) && (bfi <= 2) && ((fs_idx_tmp == 2) || (fs_idx_tmp == 4) || (fs_idx_tmp == 5)))) /* Partial Concealment PC(bfi==2) requires allowing value 2 to pass thru as well */ +#else if (bfi == 1) +#endif { +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (bfi == 1) + { + *nbLostCmpt = *nbLostCmpt + 1; + } +#else *nbLostCmpt = *nbLostCmpt + 1; +#endif /* Use pitch correlation at ltpf integer lag if available */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + if ((*nbLostCmpt == 1) || (bfi != 1) )/* PC(bfi==2) requires allowing 2 to pass thru as well */ +#else if (*nbLostCmpt == 1) +#endif { +#ifdef CR8_A_PLC_FADEOUT_TUNING + *concealMethod = 4; /* Noise Substitution */ + UNUSED(plcMeth); +#else *concealMethod = plcMeth; // this is a dangerous mapping! - +#endif + /* Advanced PLC */ if (pitch_int > 0) { @@ -44,24 +150,53 @@ void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *n plc_xcorr_lc(plcAd->pcmbufHist, plcAd->max_len_pcm_plc, pitch_int, framelength, frame_dms, fs, xcorr); spectral_centroid_lc(plcAd->scf_q_old, tilt, band_offsets, bands_number, framelength, fs, &sc); - class = *xcorr * 7640.0/32768.0 - sc - 5112.0/32768.0; - + class = *xcorr * 7640.0 / 32768.0 - sc - 5112.0 / 32768.0; + if (class <= 0) { if (frame_dms == 100 && hrmode == 0) { *concealMethod = 2; /* PhaseEcu selected */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#endif } else { +#ifndef CR9_G_PLC_NS_TDC_FIX *concealMethod = 4; /* Noise Substitution */ +#endif +#ifdef CR8_A_PLC_FADEOUT_TUNING + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#endif } } +#ifdef CR8_A_PLC_FADEOUT_TUNING + else { + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 1, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 0, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + } +#endif } else { *concealMethod = 4; /* Noise Substitution */ +#ifdef CR8_A_PLC_FADEOUT_TUNING + array_insert_and_shift(plcAd->plc_longterm_advc_tdc, 0, plcAd->longterm_analysis_counter_max, &plcAd->overall_counter, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); + array_insert_and_shift(plcAd->plc_longterm_advc_ns, 1, plcAd->longterm_analysis_counter_max, NULL, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#endif } + +#ifdef CR8_A_PLC_FADEOUT_TUNING +# ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + array_calculate(plcAd->plc_longterm_advc_tdc, plcAd->plc_longterm_advc_ns, plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_plcTdc, &plcAd->longterm_counter_plcNsAdv, plcAd->longterm_analysis_counter_max); +# else + array_calculate(plcAd->plc_longterm_advc_tdc, plcAd->plc_longterm_advc_ns, plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_plcTdc, &plcAd->longterm_counter_plcNsAdv, &plcAd->longterm_counter_plcPhaseEcu, plcAd->overall_counter, plcAd->longterm_analysis_counter_max); +# endif + update_bit_and_byte_positions(plcAd->longterm_analysis_counter_max_bytebuffer, &plcAd->longterm_counter_byte_position, &plcAd->longterm_counter_bit_position); +#endif } } } diff --git a/lib_lc3plus/plc_compute_stab_fac.c b/lib_lc3plus/plc_compute_stab_fac.c index 4a1111a2c7317f29d815fe0c0346d314b9e17569..a81af2218b920bddbda5b181b32ba4a55fced329 100644 --- a/lib_lc3plus/plc_compute_stab_fac.c +++ b/lib_lc3plus/plc_compute_stab_fac.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/plc_damping_scrambling.c b/lib_lc3plus/plc_damping_scrambling.c index ecea32be5fa151684a7ced58dd0c5d7e04b045d7..a863c1621a01fd8bf5ace1b40d58044fb32ec66b 100644 --- a/lib_lc3plus/plc_damping_scrambling.c +++ b/lib_lc3plus/plc_damping_scrambling.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -17,7 +17,11 @@ void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, LC3_INT32 ns_nbLostCmpt, LC3_FLOAT *stabFac, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast, LC3_FLOAT *spec_prev, LC3_FLOAT *spec, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 bfi, LC3_INT32 frame_dms, LC3_INT32 concealMethod, LC3_INT32 pitch_present_bfi1, LC3_INT32 pitch_present_bfi2, - LC3_FLOAT *cum_fflcAtten) + LC3_FLOAT *cum_fflcAtten +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ) { LC3_INT32 processDampScramb; @@ -31,15 +35,33 @@ void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, { processDampScramb = 1; } + +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (ns_nbLostCmpt == 1) + { + *cum_fading_slow = 1; + *cum_fading_fast = 1; + *cum_fflcAtten = 1; + } +#endif + if ( bfi == 1 ) { processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt, stabFac, processDampScramb, cum_fflcAtten, - pitch_present_bfi1, frame_dms, cum_fading_slow, cum_fading_fast, ns_seed, 0); + pitch_present_bfi1, frame_dms, cum_fading_slow, cum_fading_fast, ns_seed, 0 +#ifdef CR8_A_PLC_FADEOUT_TUNING + , plc_fadeout_type +#endif + ); } else /* bfi == 2 */ { processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt_pc, stabFac, processDampScramb, cum_fflcAtten, - pitch_present_bfi2, frame_dms, cum_fading_slow, cum_fading_fast, pc_seed, spec_inv_idx); + pitch_present_bfi2, frame_dms, cum_fading_slow, cum_fading_fast, pc_seed, spec_inv_idx +#ifdef CR8_A_PLC_FADEOUT_TUNING + , plc_fadeout_type +#endif + ); processPlcUpdateSpec_fl(spec_prev, spec, yLen); } } @@ -47,13 +69,18 @@ void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb, LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow, - LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx) + LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ) { LC3_INT32 plc_start_inFrames, plc_end_inFrames, plc_duration_inFrames, x, b, i, ad_ThreshFac_start; LC3_FLOAT slow, fast, linFuncStartStop, randThreshold, ad_ThreshFac_end, ad_threshFac, frame_energy, mean_energy, energThreshold, fac, m, n, fflcAtten, cum_fading_slow_local, cum_fading_fast_local; frame_energy = 0; +#ifndef CR8_A_PLC_FADEOUT_TUNING /* Main process */ if (nbLostCmpt == 1) { @@ -61,6 +88,7 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n *cum_fading_fast = 1; *cum_fflcAtten = 1; } +#endif slow = 0.8 + 0.2 * (*stabFac); fast = 0.3 + 0.2 * (*stabFac); @@ -75,64 +103,104 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n slow = LC3_SQRT(slow); fast = LC3_SQRT(fast); break; +#ifdef CR8_G_ADD_75MS + case 75: + slow = LC3_SQRT(LC3_SQRT(slow*slow*slow)); + fast = LC3_SQRT(LC3_SQRT(fast*fast*fast)); + break; +#endif } - *cum_fading_slow = *cum_fading_slow * slow; - *cum_fading_fast = *cum_fading_fast * fast; - - if (processDampScramb == 1) +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type == 0) { - fflcAtten = 1; - cum_fading_slow_local = *cum_fading_slow; - cum_fading_fast_local = *cum_fading_fast; - - if (spec_inv_idx == 0) - { - if (nbLostCmpt * frame_dms > PLC_FADEOUT_IN_MS * 10) - { - fflcAtten = 0; - *cum_fflcAtten = 0; - } - else if (nbLostCmpt * frame_dms > 200) - { - switch(frame_dms) - { - case 25: fflcAtten = PLC34_ATTEN_FAC_025; break; - case 50: fflcAtten = PLC34_ATTEN_FAC_050; break; - case 100: fflcAtten = PLC34_ATTEN_FAC_100; break; - } - } - - - *cum_fflcAtten = *cum_fflcAtten * fflcAtten; - cum_fading_slow_local = *cum_fading_slow * *cum_fflcAtten; - cum_fading_fast_local = *cum_fading_fast * *cum_fflcAtten; - } +#endif + *cum_fading_slow = *cum_fading_slow * slow; + *cum_fading_fast = *cum_fading_fast * fast; +#ifdef CR8_A_PLC_FADEOUT_TUNING + } +#endif + + if (processDampScramb == 1) + { +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type != 0) + { + if (nbLostCmpt < (4 * (100.0 / (LC3_FLOAT)frame_dms))) { + cum_fading_slow_local = 1.0; + } + else if (nbLostCmpt < (8 * (100.0 / (LC3_FLOAT)frame_dms))) { + cum_fading_slow_local = 0.9; + } + else { + cum_fading_slow_local = 0.85; + } - if (pitch_present == 0) - { - plc_start_inFrames = 1; - } else { - plc_start_inFrames = floor(PLC4_TRANSIT_START_IN_MS / (frame_dms / 10.0)); - } + *cum_fading_slow = *cum_fading_slow * cum_fading_slow_local; + cum_fading_slow_local = *cum_fading_slow; + } + else { +#endif + fflcAtten = 1; + cum_fading_slow_local = *cum_fading_slow; + cum_fading_fast_local = *cum_fading_fast; - plc_end_inFrames = floor(PLC4_TRANSIT_END_IN_MS / (frame_dms / 10.0)); - plc_duration_inFrames = plc_end_inFrames - plc_start_inFrames; + if (spec_inv_idx == 0) + { + if (nbLostCmpt * frame_dms > PLC_FADEOUT_IN_MS * 10) + { + fflcAtten = 0; + *cum_fflcAtten = 0; + } + else if (nbLostCmpt * frame_dms > 200) + { + switch (frame_dms) + { + case 25: fflcAtten = PLC34_ATTEN_FAC_025; break; + case 50: fflcAtten = PLC34_ATTEN_FAC_050; break; +#ifdef CR8_G_ADD_75MS + case 75: fflcAtten = PLC34_ATTEN_FAC_075; break; +#endif + case 100: fflcAtten = PLC34_ATTEN_FAC_100; break; + } + } - if (nbLostCmpt <= plc_start_inFrames) - { - linFuncStartStop = 1; - } else if (nbLostCmpt >= plc_end_inFrames) - { - linFuncStartStop = 0; - } else { - x = nbLostCmpt; - m = -1.0 / plc_duration_inFrames; - b = -plc_end_inFrames; - linFuncStartStop = m * (x + b); - } - - randThreshold = -32768 * linFuncStartStop; + + *cum_fflcAtten = *cum_fflcAtten * fflcAtten; + cum_fading_slow_local = *cum_fading_slow * *cum_fflcAtten; + cum_fading_fast_local = *cum_fading_fast * *cum_fflcAtten; + } + + if (pitch_present == 0) + { + plc_start_inFrames = 1; + } + else { + plc_start_inFrames = floor(PLC4_TRANSIT_START_IN_MS / (frame_dms / 10.0)); + } + + plc_end_inFrames = floor(PLC4_TRANSIT_END_IN_MS / (frame_dms / 10.0)); + plc_duration_inFrames = plc_end_inFrames - plc_start_inFrames; + + if (nbLostCmpt <= plc_start_inFrames) + { + linFuncStartStop = 1; + } + else if (nbLostCmpt >= plc_end_inFrames) + { + linFuncStartStop = 0; + } + else { + x = nbLostCmpt; + m = -1.0 / plc_duration_inFrames; + b = -plc_end_inFrames; + linFuncStartStop = m * (x + b); + } + + randThreshold = -32768 * linFuncStartStop; +#ifdef CR8_A_PLC_FADEOUT_TUNING + } +#endif for (i = spec_inv_idx; i < yLen; i++) { @@ -146,37 +214,52 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n if (*seed < 0) { +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type != 0 || pitch_present == 0 || *seed < randThreshold ) +#else if (pitch_present == 0 || *seed < randThreshold) +#endif { spec[i] = -spec[i]; } } } - ad_ThreshFac_start = 10; - ad_ThreshFac_end = 1.2; - ad_threshFac = (ad_ThreshFac_start - ad_ThreshFac_end) * linFuncStartStop + ad_ThreshFac_end; - - if (spec_inv_idx < yLen) +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type == 0) { - for (i = spec_inv_idx; i < yLen; i++) +#endif + ad_ThreshFac_start = 10; + ad_ThreshFac_end = 1.2; + ad_threshFac = (ad_ThreshFac_start - ad_ThreshFac_end) * linFuncStartStop + ad_ThreshFac_end; + + if (spec_inv_idx < yLen) + { + for (i = spec_inv_idx; i < yLen; i++) + { + frame_energy = frame_energy + (spec[i] * spec[i]); + } + + mean_energy = frame_energy * 1 / (yLen - spec_inv_idx); + } + else { - frame_energy = frame_energy + (spec[i] * spec[i]); + mean_energy = 0; } - mean_energy = frame_energy * 1 / (yLen - spec_inv_idx); + energThreshold = LC3_SQRT(ad_threshFac * mean_energy); + fac = (cum_fading_slow_local - cum_fading_fast_local) * energThreshold; +#ifdef CR8_A_PLC_FADEOUT_TUNING } - else - { - mean_energy = 0; - } - - energThreshold = LC3_SQRT(ad_threshFac * mean_energy); - fac = (cum_fading_slow_local - cum_fading_fast_local) * energThreshold; +#endif for (i = spec_inv_idx; i < yLen; i++) { +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type != 0 || LC3_FABS(spec[i]) < energThreshold ) +#else if (LC3_FABS(spec[i]) < energThreshold) +#endif { m = cum_fading_slow_local; n = 0; diff --git a/lib_lc3plus/plc_main.c b/lib_lc3plus/plc_main.c index df3fd184d903c169de288fd2630816b027129b3f..4fc19f6053d6fe8ffd8c3102462d7dd3ab938a11 100644 --- a/lib_lc3plus/plc_main.c +++ b/lib_lc3plus/plc_main.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -24,6 +24,16 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* LC3_INT16 prev_bfi_plc2; LC3_FLOAT phEcu_env_stab_local[1]; LC3_FLOAT phEcu_pfind_sens[1]; + +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT16 consecutiveLostThreshold = 0; +#endif + +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + LC3_INT16 thresh_tdc_cnt; + LC3_INT16 thresh_ns_cnt; + LC3_INT16 thresh_tdc_ns_cnt; +#endif prev_bfi_plc2 = 1; if (PlcSetup->nbLostCmpt == 0) @@ -53,14 +63,114 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* if (bfi == 1) { +# ifdef CR8_A_PLC_FADEOUT_TUNING + switch(decoder->frame_dms) + { + case 25: + consecutiveLostThreshold = 16; +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + thresh_tdc_cnt = THRESH_025_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_025_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_025_DMS_TDC_NS_CNT; +#endif + break; + case 50: consecutiveLostThreshold = 8; +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + thresh_tdc_cnt = THRESH_050_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_050_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_050_DMS_TDC_NS_CNT; +#endif + break; + case 75: consecutiveLostThreshold = 6; +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + thresh_tdc_cnt = THRESH_075_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_075_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_075_DMS_TDC_NS_CNT; +#endif + break; + case 100: consecutiveLostThreshold = 4; +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + thresh_tdc_cnt = THRESH_100_DMS_TDC_CNT; + thresh_ns_cnt = THRESH_100_DMS_NS_CNT; + thresh_tdc_ns_cnt = THRESH_100_DMS_TDC_NS_CNT; +#endif + break; + default: assert(0); + } + + if (decoder->fs_idx == 2 || decoder->fs_idx >= 4) + { +#ifdef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + if (PlcAdvSetup->longterm_counter_plcTdc < thresh_tdc_cnt){ + PlcAdvSetup->plc_fadeout_type = 1; + } + else if (PlcAdvSetup->longterm_counter_plcNsAdv < thresh_ns_cnt){ + PlcAdvSetup->plc_fadeout_type = 1; + } + else if (PlcAdvSetup->longterm_counter_plcTdc + PlcAdvSetup->longterm_counter_plcNsAdv < thresh_tdc_ns_cnt){ + PlcAdvSetup->plc_fadeout_type = 1; + } + else { + PlcAdvSetup->plc_fadeout_type = 0; + } +#else + if (((PlcAdvSetup->longterm_counter_plcPhaseEcu < PlcAdvSetup->longterm_counter_plcTdc*FAC1_FADEOUT) || + (PlcAdvSetup->longterm_counter_plcPhaseEcu < PlcAdvSetup->longterm_counter_plcNsAdv*FAC1_FADEOUT)) && + (PlcAdvSetup->longterm_counter_plcTdc / (PlcAdvSetup->longterm_counter_plcNsAdv + LC3_EPS) < FAC2_FADEOUT)) + { + PlcAdvSetup->plc_fadeout_type = 0; + } else { + if ((PlcAdvSetup->longterm_counter_plcPhaseEcu > FAC3_FADEOUT * PlcAdvSetup->longterm_counter_plcTdc) || + (PlcAdvSetup->longterm_counter_plcPhaseEcu > FAC3_FADEOUT * PlcAdvSetup->longterm_counter_plcNsAdv)) + { + PlcAdvSetup->plc_fadeout_type = 1; + } else { + PlcAdvSetup->plc_fadeout_type = 0; + } + } +#endif + + if ((PlcAdvSetup->overall_counter - (int)(PLC_LONGTERM_ANALYSIS_STARTUP_FILL * PlcAdvSetup->longterm_analysis_counter_max)) < 0) + { + PlcAdvSetup->plc_fadeout_type = 0; + } +#ifndef CR9_H_REMOVE_SWITCH_TO_PLC_NS + if (PlcSetup->nbLostCmpt >= consecutiveLostThreshold && PlcAdvSetup->plc_fadeout_type == 1) + { + if ( h_DecSetup->concealMethod == 3 ) + { + h_DecSetup->concealMethod = 4; + } + } +#endif +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + if (h_DecSetup->rel_pitch_change > REL_PITCH_THRESH && hrmode == 1 && (decoder->frame_dms == 50 || decoder->frame_dms == 25) ){ + PlcAdvSetup->plc_fadeout_type = 2; + } else +#endif + if ( h_DecSetup->concealMethod != 2 ) { + /* not PhECU */ + if (PlcSetup->nbLostCmpt < consecutiveLostThreshold ) + { + PlcAdvSetup->plc_fadeout_type = 0; + } + } + } else { + PlcAdvSetup->plc_fadeout_type = 0; + } +# endif + +#ifdef PLC_CR8_A_PRINTF + printf("plc_fadeout_type = %d\n", PlcAdvSetup->plc_fadeout_type); +#endif switch (h_DecSetup->concealMethod) { case 2: { LC3_FLOAT pitch_fl_c; - + assert(decoder->fs_idx == floor(decoder->fs / 10000)); - // phaseECU supports only 10ms framing + /* phaseECU supports only 10ms framing*/ assert(PlcSetup->nbLostCmpt != 0 || decoder->frame_dms == 100); if (decoder->frame_dms != 100) @@ -155,6 +265,10 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* , &(PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft), &(PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft) +#ifdef CR8_A_PLC_FADEOUT_TUNING + ,PlcAdvSetup->plc_fadeout_type, + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_nonpure_tone_flag) /* nonpure tone flag */ +#endif ); @@ -162,8 +276,7 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* h_DecSetup->imdct_mem, synth); move_float(syntM_fl_c, synth, decoder->frame_length); - - + } } break; @@ -180,7 +293,11 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* processTdcApply_fl(ltpf_pitch_int, &PlcAdvSetup->PlcTdcSetup.preemphFac, A, PlcAdvSetup->PlcTdcSetup.lpcorder, PlcAdvSetup->pcmbufHist, PlcAdvSetup->max_len_pcm_plc, decoder->frame_length, decoder->frame_dms, decoder->fs, PlcSetup->nbLostCmpt, decoder->frame_length - decoder->la_zeroes, &PlcAdvSetup->stabFac, PlcAdvSetup->PlcTdcSetup.harmonicBuf, PlcAdvSetup->PlcTdcSetup.synthHist, &PlcAdvSetup->PlcTdcSetup.fract, &PlcAdvSetup->PlcTdcSetup.seed, &PlcAdvSetup->PlcTdcSetup.gain_c, - &h_DecSetup->alpha, synth); + &h_DecSetup->alpha, synth +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + ,PlcAdvSetup->plc_fadeout_type +#endif +); processTdcTdac_fl(synth, decoder->imdct_win, decoder->frame_length, decoder->la_zeroes, h_DecSetup->imdct_mem); memmove(syntM_fl_c, synth, sizeof(LC3_FLOAT) * decoder->frame_length); diff --git a/lib_lc3plus/plc_noise_substitution.c b/lib_lc3plus/plc_noise_substitution.c index 4913ee53e5f2ac954d9f1e12f81b5979c49baf60..92f8b3cf214f7cc84abc33fa51dacbec4330cd81 100644 --- a/lib_lc3plus/plc_noise_substitution.c +++ b/lib_lc3plus/plc_noise_substitution.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/plc_phecu_f0_refine_first.c b/lib_lc3plus/plc_phecu_f0_refine_first.c index 11ebf276b151b9c4f58f37de5632863aa8341ae1..2a580024f037c2bb842ba777a1e73b2a8b9e2e45 100644 --- a/lib_lc3plus/plc_phecu_f0_refine_first.c +++ b/lib_lc3plus/plc_phecu_f0_refine_first.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/plc_phecu_fec_hq.c b/lib_lc3plus/plc_phecu_fec_hq.c index c25466c3e995a0310ce70c92f81070558dc6d87e..4aebbfa88545a47e611bcf6fb992af5e819eaaae 100644 --- a/lib_lc3plus/plc_phecu_fec_hq.c +++ b/lib_lc3plus/plc_phecu_fec_hq.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/plc_phecu_hq_ecu.c b/lib_lc3plus/plc_phecu_hq_ecu.c index 5b1978bcabfe7995abd483962079984e38e1ab71..112d965a4963e6775c418c137e4c37c6fb8dbf1b 100644 --- a/lib_lc3plus/plc_phecu_hq_ecu.c +++ b/lib_lc3plus/plc_phecu_hq_ecu.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -13,6 +13,7 @@ #include "functions.h" + void plc_phEcu_hq_ecu( LC3_FLOAT *f0binPtr, LC3_FLOAT *f0ltpGainPtr, LC3_FLOAT *xfp, LC3_INT16 prev_bfi, LC3_INT32 *short_flag_prev, LC3_INT32 fs, @@ -24,7 +25,12 @@ void plc_phEcu_hq_ecu( LC3_FLOAT *xsubst_dbg, Complex *X_out_m_dbg, LC3_INT32 *seed_dbg, LC3_FLOAT *mag_chg_dbg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg, LC3_FLOAT *corr_phase_dbg, - Fft *PhEcu_Fft, Fft *PhEcu_Ifft) + Fft *PhEcu_Fft, Fft *PhEcu_Ifft +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type, LC3_INT16 *nonpure_tone_flag_ptr /* nonpure tone flag */ +#endif + + ) { LC3_INT32 i; LC3_INT32 fs_idx, L, Lprot, n_grp, Lecu, LXsav, Lxfp_inuse; @@ -48,6 +54,8 @@ void plc_phEcu_hq_ecu( Lxfp_inuse = (LC3_INT32)(L*(3.75/10.0)); } + + UNUSED(env_stabPtr); UNUSED(xsubst_dbg); UNUSED(X_out_m_dbg); @@ -69,12 +77,20 @@ void plc_phEcu_hq_ecu( xfp_local_rnd[i] = 0.0; } } +#ifdef CR8_A_PLC_FADEOUT_TUNING + *nonpure_tone_flag_ptr = -1; /* set nonpure tone flag for new analysis */ +#endif *time_offs = 0; burst_len = (*time_offs / L + 1); plc_phEcu_trans_burst_ana_sub(fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr , old_grp_shape, old_EwPtr, st_beta_mute, - st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL); + st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL + +#ifdef CR8_A_PLC_FADEOUT_TUNING + ,plc_fadeout_type +#endif + ); plc_phEcu_spec_ana(xfp_local_rnd, Lprot, winWhr, pfind_sensPtr, plocs, n_plocs, f0est, X_sav_m, &LXsav, f0binPtr, f0ltpGainPtr, fs_idx, PhEcu_Fft); } @@ -85,7 +101,11 @@ void plc_phEcu_hq_ecu( burst_len = ((*time_offs / L) + 1); plc_phEcu_trans_burst_ana_sub(fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr, old_grp_shape, old_EwPtr, st_beta_mute, - st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL); + st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL +#ifdef CR8_A_PLC_FADEOUT_TUNING + ,plc_fadeout_type +#endif + ); } @@ -100,6 +120,12 @@ void plc_phEcu_hq_ecu( /* inplace X_out_m update */ plc_phEcu_subst_spec(plocs, *n_plocs, f0est, *time_offs, X_out_m, LXsav, mag_chg, &seed, alpha, beta, st_Xavg, t_adv, Lprot, delta_corr, +#ifdef CR8_A_PLC_FADEOUT_TUNING + plc_fadeout_type, + nonpure_tone_flag_ptr, /* nonpure_tone_flag , a state updated here */ +#endif + + NULL, NULL, NULL); diff --git a/lib_lc3plus/plc_phecu_lf_peak_analysis.c b/lib_lc3plus/plc_phecu_lf_peak_analysis.c index 0bcc98d7a489b37cdf94f118131188d17ca1a5ba..225aa52560ca009e822fc97eae5c650e400bbfbf 100644 --- a/lib_lc3plus/plc_phecu_lf_peak_analysis.c +++ b/lib_lc3plus/plc_phecu_lf_peak_analysis.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/plc_phecu_rec_frame.c b/lib_lc3plus/plc_phecu_rec_frame.c index 0e6570743ae7f8464e17d0b891a389ee3b1cccd0..e56cb3dd759de8a5985f1cecc0c9675fd9d257d5 100644 --- a/lib_lc3plus/plc_phecu_rec_frame.c +++ b/lib_lc3plus/plc_phecu_rec_frame.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -51,7 +51,12 @@ void plc_phEcu_rec_frame(Complex *X_in, UNUSED(ifft_out_dbg); UNUSED(xsubst_dbg); UNUSED(xsubst_LL); - fs_idx = FRAME2FS_IDX(L); + +#ifdef CR8_A_PLC_FADEOUT_TUNING + fs_idx = FRAME2FS_IDX_10MS(L); +#else + fs_idx = FRAME2FS_IDX(L); +#endif hannOla = hannOla_wins[fs_idx]; X_in[0].i = X_in[Lprot / 2].r; /* move fs/2 real to imag part of X_in[0]*/ diff --git a/lib_lc3plus/plc_phecu_setf0hz.c b/lib_lc3plus/plc_phecu_setf0hz.c index b14327e2b2af0f4c04c1f9bc633e0ac06a1a2114..7bdb0a8c5cf4aedf41d4c55cc31b2b62fb2bb792 100644 --- a/lib_lc3plus/plc_phecu_setf0hz.c +++ b/lib_lc3plus/plc_phecu_setf0hz.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/plc_phecu_spec_ana.c b/lib_lc3plus/plc_phecu_spec_ana.c index b49690030596c08363f4168b5b6d1abd8c9d3b7b..313b33877718c764ef49353db37b38e8334ce8e2 100644 --- a/lib_lc3plus/plc_phecu_spec_ana.c +++ b/lib_lc3plus/plc_phecu_spec_ana.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/plc_phecu_subst_spec.c b/lib_lc3plus/plc_phecu_subst_spec.c index 43f806339b8ed85c9b5a1ebae1f1586210dda817..d494af826f5806ccfb4fe1bacf13074293a3cd28 100644 --- a/lib_lc3plus/plc_phecu_subst_spec.c +++ b/lib_lc3plus/plc_phecu_subst_spec.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -13,35 +13,47 @@ #include "functions.h" #include "constants.h" - static LC3_INT32 own_rand(LC3_INT32 seed); static Complex valley_magnitude_adj(Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOAT cos_F); static LC3_INT32 rand_phase(LC3_INT32 seed_in, LC3_FLOAT* cos_F); +#ifdef CR8_A_PLC_FADEOUT_TUNING + +#define ONE_SIDED_SINE_WIDTH (4) /* expected pure sine main lobe maximum width (4+1+4) bins *62.5 hz/bin => approx 560 Hz total width */ + +static LC3_INT16 plc_phEcu_nonpure_tone_ana(const LC3_INT32* plocs, const LC3_INT32 n_plocs, const Complex* X, const LC3_FLOAT* Xavg, const LC3_INT32 Lprot); +#endif + void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est, LC3_INT32 time_offs, Complex* X, LC3_INT32 X_len, LC3_FLOAT* mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT* alpha, LC3_FLOAT* beta, LC3_FLOAT* Xavg, - LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, LC3_FLOAT *corr_phase_dbg, + LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT16 fadeout, /* need for DC muting */ + LC3_INT16* nonpure_tone_flag_ptr, +#endif + LC3_FLOAT *corr_phase_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg) { LC3_INT32 i, i2, lprotBy2Minus1, one_peak_flag_mask, noise_mag_scale; LC3_INT32 t_adv; - LC3_FLOAT corr_phase[MAX_PLC_NPLOCS] = {0}; - LC3_FLOAT cos_F, mag_chg_local, alpha_local, beta_local, tmp; + LC3_FLOAT corr_phase[MAX_PLC_NPLOCS] = {0}; + LC3_FLOAT cos_F, mag_chg_local, alpha_local, beta_local, tmp; Complex X_i, X_i_new; LC3_INT32 segmentLen, e; LC3_FLOAT Xph; LC3_FLOAT seed_local; - LC3_INT32 binCounter, subInd; - + LC3_INT32 binCounter = 1, subInd = 0; +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT16 fs_idx; +#endif + UNUSED(corr_phase_dbg); UNUSED(X_i_new_re_dbg); UNUSED(X_i_new_im_dbg); seed_local = (LC3_FLOAT) *seed; - - lprotBy2Minus1 = imin(320, Lprot/2 - 1); /* limit to 20 KHz */ - + lprotBy2Minus1 = imin(320, Lprot/2 - 1); /* limit to 20 KHz */ t_adv = t_adv_in + time_offs; @@ -49,15 +61,33 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est, corr_phase[i] = (LC3_FLOAT)2.0 * (LC3_FLOAT)M_PI * (f0est[i]/Lprot)*(LC3_FLOAT)t_adv; } - // EVOLVE PHASE ----------------- - binCounter = 1; - subInd = 0; one_peak_flag_mask = -1; +#ifdef CR8_A_PLC_FADEOUT_TUNING + fs_idx = (LC3_INT16)LC3_FLOOR((LC3_FLOAT)Lprot / 160.0); /* aquire, fs_idx for 10 ms frame sizes */ + if (n_plocs < 3 && n_plocs > 0) + { + one_peak_flag_mask = 0; /* initial crude single tone detection, only using n_plocs as a result from peak_locator() dynamics as input */ + + if ( (*nonpure_tone_flag_ptr < 0 ) + && ( (fs_idx == 2) /*SemiSWB 24 kHz */ || (fs_idx >= 4) /* FB 48 kHz */ ) + ) + { + /* in the first lost frame analyze spectra to possibly reverse initial pure sine assumption */ + *nonpure_tone_flag_ptr = plc_phEcu_nonpure_tone_ana(plocs, n_plocs, X, Xavg, Lprot ); + } + + if ( *nonpure_tone_flag_ptr > 0 ) { + one_peak_flag_mask = -1; /* actually revert single pure tone detection */ /* 0-> mute all surrounding valley bins in evolution , 0xff -> generate noise in all valleys */ + } + + } +#else if (n_plocs < 3 && n_plocs > 0) { one_peak_flag_mask = 0; } +#endif noise_mag_scale = 0; if (n_plocs == 0 || time_offs != 0) { @@ -69,6 +99,32 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est, X[X_len-1] = realtoc(0); } +#ifdef CR8_A_PLC_FADEOUT_TUNING +#if 0 + /* align DC fs/2 muting to BASOP */ +#endif + /* binary selection of fadeout scheme */ + assert(PLC2_FADEOUT_LONG_IN_MS >= PLC2_FADEOUT_IN_MS_MIN && PLC2_FADEOUT_IN_MS >= PLC2_FADEOUT_IN_MS_MIN); + assert(PLC2_FADEOUT_LONG_IN_MS <= PLC2_FADEOUT_IN_MS_MAX && PLC2_FADEOUT_IN_MS <= PLC2_FADEOUT_IN_MS_MAX); + i = (PLC2_FADEOUT_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; + + if (fadeout != 0) + { + i = (PLC2_FADEOUT_LONG_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; + } + + /* calculate local burst_len for securing DC and fs/2 muting */ + i2 = (time_offs / ((Lprot * 100) / 160)) + 1; /* burst_len */ + + if (i2 > (fade_scheme_tab[i][1] + 1)) + { + /* start DC scaling attenuation */ + X[0].r = alpha[0] * X[0].r; + + /* start fs/by2 attenuation */ + X[X_len - 1].r = alpha[(xavg_N_grp[fs_idx] - 1)] * X[X_len - 1].r; + } +#endif if (n_plocs != 0) { for (i = 0; i < n_plocs; i++) { @@ -221,11 +277,11 @@ void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est, } static LC3_INT32 own_rand(LC3_INT32 seed) { - LC3_INT32 retSeed; - assert(seed <= 32767 && seed >= -32768); - retSeed = (13849 + (seed + 32768) * 31821) & 65535; - retSeed -= 32768; - assert(retSeed <= 32767 && retSeed >= -32768); + LC3_INT32 retSeed; + assert(seed <= 32767 && seed >= -32768); + retSeed = (13849 + (seed + 32768) * 31821) & 65535; + retSeed -= 32768; + assert(retSeed <= 32767 && retSeed >= -32768); return retSeed; } @@ -245,3 +301,164 @@ static LC3_INT32 rand_phase(LC3_INT32 seed_in, LC3_FLOAT* cos_F) { return (LC3_INT32) seed; } + +#ifdef CR8_A_PLC_FADEOUT_TUNING + +static LC3_INT16 plc_phEcu_nonpure_tone_ana(const LC3_INT32* plocs, const LC3_INT32 n_plocs, const Complex* X, const LC3_FLOAT* Xavg, const LC3_INT32 Lprot) +{ + + LC3_INT16 nonpure_tone_detect; + LC3_INT16 n_ind, tone_ind, low_ind, high_ind; + LC3_FLOAT peak_amp, peak_amp2, valley_amp, x_abs[(1 + 2 * ONE_SIDED_SINE_WIDTH + 2 * 1)]; + LC3_INT16 sineband_ind_low, sineband_ind_high; + LC3_INT16 i, fs_idx, N_grp; + LC3_FLOAT tmp, tmp_dB, tot_inc_HF, tot_inc_LF; + + + + /* use compressed hearing sensitivity curve to allow more deviation in highest and lowest bands */ + /* ROM table LC3_FLOAT scATHFx[MAX_LGW - 1] */ + + /* init */ + nonpure_tone_detect = 0; + tot_inc_HF = 0.0; + tot_inc_LF = 0.0; + + /* limit single sine optimization to when 2 peaks are close enough to represent a single sinusoid */ + if (n_plocs == 2 && (plocs[1] - plocs[0]) >= ONE_SIDED_SINE_WIDTH) /* NB, plocs is an ordered vector */ + { + nonpure_tone_detect |= 0x1; + } + + /* local bin wise dynamics analysis, if 2 peaks, we do the analysis based on the location of the largest peak */ + { + tone_ind = 0; + plc_phEcu_fft_spec2_sqrt_approx(&(X[plocs[0]]), 1, &peak_amp); /* get 1st peak amplitude = approx_sqrt(Re^2+Im^2) */ + + + if ((n_plocs - 2) == 0) + { + plc_phEcu_fft_spec2_sqrt_approx(&(X[plocs[1]]), 1, &peak_amp2); /* get 2nd peak amplitude */ + if (peak_amp2 > peak_amp) + { + tone_ind = 1; + peak_amp = peak_amp2; + } + } + + low_ind = MAX(1, plocs[tone_ind] - (ONE_SIDED_SINE_WIDTH + 1)); /* DC is not allowed as valley */ + high_ind = MIN((Lprot >> 1) - 2, plocs[tone_ind] + (ONE_SIDED_SINE_WIDTH + 1)); /* Fs/2 is not allowed as valley */ + + n_ind = high_ind - low_ind + 1; + + /* find lowest amplitudes around the assumed main lobe center location */ + plc_phEcu_fft_spec2_sqrt_approx(&(X[low_ind]), n_ind, x_abs); + valley_amp = peak_amp; + for (i = 0; i < n_ind; i++) { + valley_amp = MIN(x_abs[i], valley_amp); + } + + /* at least a localized amplitude ratio of 16 (24 dB) required to declare a pure sinusoid */ + if (peak_amp < 16 * valley_amp) /* 1/16 easily implemented in BASOP */ + { + + nonpure_tone_detect |= 0x2;/* not a pure tone due to too low local SNR */ + + } + } + + /* analyze LF/ HF bands energy dynamics vs the assumed single tone band ( one or two peaks found) */ + { + fs_idx = (LC3_INT16)floor(Lprot / 160); /* fs_idx */ + assert(fs_idx < 5); + + /* Xavg , is a vector of rather rough MDCT based band energy estimates in perceptually motivated bands. from approx the last 26 ms of synthesis */ + + /* eval amplitude relations for assumed tonal band vs lower and higher bands */ + N_grp = xavg_N_grp[fs_idx]; /* { 4 NB , 5 WB , 6 SSWB , 7 SWB, 8 FB }; */ + + /* establish band(s) with assumed sinusoid tone */ + /* if tone freq location is below first MDCT-band definition, use first band as location anyway */ + i = 0; /* band 0 , 1 , 2 , 3 , ...*/ + while (plocs[tone_ind] >= gwlpr[i + 1]) { /* gwplr= [ 1, 12(750Hz), 20(1250Hz) , 36 , .. */ + /* dct-inds "0"...11, 12...19, 20...35, 36 ... */ + i++; + } + sineband_ind_low = i; + sineband_ind_high = i; /* typically in the same band as low */ + + /* a single tone may end up on a band border + , handle case when assumed tone is more or less right in between two perceptual bands +/-4 62.5 Hz */ + if ((sineband_ind_high > 0) && + (plocs[tone_ind] - ONE_SIDED_SINE_WIDTH) >= gwlpr[sineband_ind_high + 1] + ) { + sineband_ind_low = sineband_ind_high - 1; + } + + if ( (sineband_ind_low < (N_grp - 1)) && + (plocs[tone_ind] + ONE_SIDED_SINE_WIDTH) >= gwlpr[sineband_ind_low + 1] + ) { + sineband_ind_high = sineband_ind_low + 1; + } + } + + + + /* intraframe(26 ms), weighted LB and HB envelope dynamics/variation analysis */ + /* envelope analysis , + require at least two HF or two LF bands in the envelope taper/roll-off analysis , otherwise skip this condition */ + + + if (nonpure_tone_detect == 0 && + (((sineband_ind_high + 2) < N_grp) || + ((sineband_ind_low - 2) >= 1) + ) + ) + { + /* delta taper-off analysis solution, less sensitive to input bandwidth limitation and levels */ + +#if 0 + /* note: in BASOP the Xavg ratios below are calculated in log2 domain on a maximally upshifted Xavg vector. + if Xavg is an all zero vector in BASOP, then the nonpure_tone_detect flag is or'ed with 0x100 , + to trigger normal valley noise generation */ +#endif + + /* verify that an assumed clean sine does not have any odd HF content indications by thresholding the accumulated delta rise in LF/HF side lobes */ + for (i = (sineband_ind_high + 1); i < (N_grp - 1); i++) { + tmp = (Xavg[i + 1] + LC3_EPS) / (Xavg[i] + LC3_EPS); + tmp_dB = 20.0*LC3_LOGTEN(tmp); + if ((Xavg[i] + LC3_EPS) > (Xavg[i + 1] + LC3_EPS)) { + tmp_dB = 0; + } + tot_inc_HF += scATHFx[i] * tmp_dB; /* i is ATH factor between band i, i+1 based on Hearing sensitivity */ + } + + /* verify that an assumed clean sine does not have any odd LF content by thresholding the accumulated LF reverse up tilt */ + for (i = MAX(0, (sineband_ind_low - 1)); i > 0; i--) { + tmp = (Xavg[i - 1] + LC3_EPS) / (Xavg[i] + LC3_EPS); + tmp_dB = 20.0*LC3_LOGTEN(tmp); /* switch to log2() to simplify BASOP */ + + if ((Xavg[i - 1] + LC3_EPS) < (Xavg[i] + LC3_EPS)) { + tmp_dB = 0; + } + tot_inc_LF += scATHFx[i - 1] * tmp_dB; /* "psycho" scale using i-1 is ATH factor between band i-1, i , based on Hearing sensitivity */ + } + + if (tot_inc_HF > 4.5){ /* 4.5 dB in log2 is 0.7474 */ + nonpure_tone_detect |= 0x10; /* still not a pure tone, too great HF side increase */ + } + + if (tot_inc_LF > 4.5) { /* 4.5 dB limit in 4.5 = 20log10(x) corresponds to limit value 0.7474 in log2(x) */ + nonpure_tone_detect |= 0x20; /* still not a pure tone, too great accumulated LF side increase */ + } + + /* verify that an assumed clean sine does not have any odd LF+HF content by thresholding the accumulated LF+HF unexpected tilt */ + if ((tot_inc_LF + tot_inc_HF) > 6.0) { /* 6 dB limit in 20log10(x) corresponds to limit value 1.0 in log2(x) */ + nonpure_tone_detect |= 0x40; /* still not a pure tone, to great LF+HF side variation/increase */ + } + } /* bands available*/ + + return nonpure_tone_detect; +} +#endif /* CR8_A_PLC_FADEOUT_TUNING */ + diff --git a/lib_lc3plus/plc_phecu_tba_per_band_gain.c b/lib_lc3plus/plc_phecu_tba_per_band_gain.c index 9f585f28dd8104991b5598f8f029df55f69d0433..507f45a647d1a6c15ca0533de989fda31fdd1fa1 100644 --- a/lib_lc3plus/plc_phecu_tba_per_band_gain.c +++ b/lib_lc3plus/plc_phecu_tba_per_band_gain.c @@ -1,19 +1,19 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * * estoppel or otherwise. * ******************************************************************************/ - + #include "options.h" #include "defines.h" #include "functions.h" -void plc_phEcu_tba_per_band_gain(LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change) +void plc_phEcu_tba_per_band_gain(LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change) { LC3_INT32 i; @@ -39,6 +39,5 @@ void plc_phEcu_tba_per_band_gain(LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FL } - return; + return; } - diff --git a/lib_lc3plus/plc_phecu_tba_spect_Xavg.c b/lib_lc3plus/plc_phecu_tba_spect_Xavg.c index 600b9714e45865fb437ea653d8de8e2dab182a23..b4727cfd4cc77275fe9d60500b4676c32ebd5e26 100644 --- a/lib_lc3plus/plc_phecu_tba_spect_Xavg.c +++ b/lib_lc3plus/plc_phecu_tba_spect_Xavg.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c b/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c index e5f0d3caae0d71e0600e9281e0e84f7c781489b4..3b58d92b427b0b456ac795bad23a10df60c9621c 100644 --- a/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c +++ b/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -40,11 +40,29 @@ const LC3_INT32 POW_ATT_TABLE0[OFF_FRAMES_LIMIT + 1] = { 32767, 31293, 29885, 28 #ifdef PLC2_FADEOUT_IN_MS #if PLC2_FADEOUT_IN_MS == 0 -/* default setting only requieres two tables */ +#ifndef CR8_A_PLC_FADEOUT_TUNING +/* default setting only requires two tables */ const Word16* const POW_ATT_TABLES[1 + 2] = { NULL, POW_ATT_TABLE1/*1 0.3dB steps */ , POW_ATT_TABLE0/*2 0.4 dB steps*/, }; +#endif #else + +#ifdef CR8_A_PLC_FADEOUT_TUNING +const LC3_INT32 POW_ATT_TABLE_p3x9_14_7[OFF_FRAMES_LIMIT + 1] = { + 32767, + 31656, 30581, 29543, 28540, 27571, 26635, 25731, 24857, 24013, /* 9 times .3dB steps , 14 6 dB steps, 7 muted steps */ + 12007, 6003, 3002, 1501, 750, 375, 188, 94, 47, 23, 12, 6, 3, 1, + 0, 0, 0, 0, 0, 0, 0 }; + +const LC3_INT32 POW_ATT_TABLE_p4x9_14_7[OFF_FRAMES_LIMIT + 1] = +{ 32767, + 31293, 29885, 28540, 27255, 26029, 24857, 23738, 22670, 21650, /* 9 times .4dB steps , 14 6 dB steps, 7 muted steps */ + 10825, 5413, 2706, 1353, 677, 338, 169, 85, 42, 21, 11, 5, 3, 1, + 0, 0,0,0,0,0,0 }; +#endif + + const LC3_INT32 POW_ATT_TABLE_p3x8_6[] = { 32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 12865, 6433, 3216, 1608, 804, 402, 201, 101, 50, 25, 13, 6, @@ -81,6 +99,23 @@ const LC3_INT32 POW_ATT_TABLE_p4x1_6[OFF_FRAMES_LIMIT + 1] = { 32, 16, 8, 4, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +#ifdef CR8_A_PLC_FADEOUT_TUNING +#if 0 +/* POW_ATT_TABLES now ordered logically based on initial slow muting phase time */ +/* POW_ATT_TABLES[ind] is used after the initial gain==1.0 no energy muting phase */ +#endif +const LC3_INT32 *const POW_ATT_TABLES[1 + 12] = +{ NULL, +/*0.3dB col , 0.4dB col */ +/* 1*/POW_ATT_TABLE_p3x1_6, POW_ATT_TABLE_p4x1_6, /* 0 0.3dB, 16 6dB, 14mute */ /* 0.4dB version */ /* old short mute tabs */ +/* 3*/POW_ATT_TABLE_p3x2_6, POW_ATT_TABLE_p4x2_6, /* 1 0.3dB, 15 6dB ,14mute */ /* 0.4dB version */ +/* 5*/POW_ATT_TABLE_p3x4_6, POW_ATT_TABLE_p4x4_6, /* 3 0.3dB, 15 6dB , 12 mute */ /* 0.4dB version */ +/* 7*/POW_ATT_TABLE_p3x8_6, POW_ATT_TABLE_p4x8_6, /* 7 0.3dB, 15 6dB , 8 mute */ /* 0.4dB version */ +/* 9*/POW_ATT_TABLE_p3x9_14_7, POW_ATT_TABLE_p4x9_14_7, /* 9 0.3dB, 14 6dB , 7 mute */ /* 0.4dB version */ /* opt 120 ms */ +/*11*/POW_ATT_TABLE1, POW_ATT_TABLE0, /* 15 0.3dB, 14 6dB , 1 mute */ /* 0.4dB version */ /* original curves */ +}; + +#else const LC3_INT32* const POW_ATT_TABLES[1 + 10] = { NULL, @@ -90,13 +125,18 @@ const LC3_INT32* const POW_ATT_TABLES[1 + 10] = POW_ATT_TABLE_p3x2_6, POW_ATT_TABLE_p4x2_6, /* .3dB x2, 30 6dB steps */ /* .4dB x2, 30 6dB steps */ POW_ATT_TABLE_p3x1_6, POW_ATT_TABLE_p4x1_6 /* .3dB x1, 30 6dB steps */ /* .4dB x1, 30 6dB steps */ }; +#endif #endif #endif void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *grp_pow_change, LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec, - LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames_dbg, LC3_FLOAT *thresh_dbg) + LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames_dbg, LC3_FLOAT *thresh_dbg +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif + ) { LC3_INT32 i; @@ -108,14 +148,19 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL LC3_INT32 burst_att_thresh; LC3_INT32 att_per_frame_idx; LC3_INT32 att_always, attDegreeFrames; - +#ifndef CR8_A_PLC_FADEOUT_TUNING LC3_INT32 FADEOUT_IN_MS, PLC_P800_SPEECH_FADEOUT_IN_FRAMES, PLC2_FADEOUT_IN_FRAMES, BURST_ATT_THRESH_PRE; +#endif const LC3_INT32 *TABLEQ15; +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT32 beta_mute_thr; /* time threshold in 10 ms frames to start beta - noise attenuation */ +#endif +#ifndef CR8_A_PLC_FADEOUT_TUNING LC3_INT32 BURST_ATT_THRESH; /* start attenuate with losses in a row, also starts FADE2AVG actions */ - LC3_INT32 ATT_PER_FRAME; /* initial msuic attenuation table ptr, actually implemented in table lookup! */ + LC3_INT32 ATT_PER_FRAME; /* initial msuic attenuation table ptr, actually implemented in table lookup! */ LC3_INT32 BETA_MUTE_THR; /* time threshold in 10 ms frames to start beta - noise attenuation */ - +#endif UNUSED(attDegreeFrames_dbg); /* constants setup */ @@ -123,32 +168,31 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL XavgFadeinFactor = -1.0; - if (PLC2_FADEOUT_IN_MS != 0) +#ifndef CR8_A_PLC_FADEOUT_TUNING + if (PLC2_FADEOUT_IN_MS < 0) { - if (PLC2_FADEOUT_IN_MS < 0) - { - FADEOUT_IN_MS = PLC_FADEOUT_IN_MS; /* % use TDC - SETTING as input */ - } - else - { - FADEOUT_IN_MS = PLC2_FADEOUT_IN_MS; /* % use a PLC2 individual settinsg */ - } - - PLC_P800_SPEECH_FADEOUT_IN_FRAMES = (LC3_INT32) LC3_FLOOR((LC3_FLOAT)FADEOUT_IN_MS / (LC3_FLOAT)10.0); /* % nominal svaleu for speech */ + FADEOUT_IN_MS = PLC_FADEOUT_IN_MS; /* % use TDC - SETTING as basic input */ + } + else + { + FADEOUT_IN_MS = PLC2_FADEOUT_IN_MS; /* % use a PLC2 individual settings */ + } +#endif - PLC2_FADEOUT_IN_FRAMES = MIN(OFF_FRAMES_LIMIT, MAX(6, 3 * PLC_P800_SPEECH_FADEOUT_IN_FRAMES)); /* for PLC2 we typically maintain energy 3x longer */ +#ifndef CR8_A_PLC_FADEOUT_TUNING + PLC_P800_SPEECH_FADEOUT_IN_FRAMES = (LC3_INT32)LC3_FLOOR((LC3_FLOAT)FADEOUT_IN_MS / (LC3_FLOAT)10.0); /* % nominal value for speech */ - BURST_ATT_THRESH_PRE = MIN(5, MAX(1, (1 * PLC2_FADEOUT_IN_FRAMES) / 6)); /* nominal 20-40 ms to start actual muting, will be thresh +1 fot assumed music */ + PLC2_FADEOUT_IN_FRAMES = MIN(OFF_FRAMES_LIMIT, MAX(6, 3 * PLC_P800_SPEECH_FADEOUT_IN_FRAMES)); /* for PLC2 we typically maintain energy 3x longer */ - ATT_PER_FRAME = MIN(10, MAX(2, 2 * (6 - BURST_ATT_THRESH_PRE))); /* % we let the BURST_ATT_thresh control the initial table selection */ - BURST_ATT_THRESH = MIN(BURST_ATT_THRESH_PRE, 4); - BETA_MUTE_THR = MIN(4 + (OFF_FRAMES_LIMIT / 2) + 1, MAX(4, BURST_ATT_THRESH + 1 + (LC3_INT32)LC3_POW((LC3_FLOAT)2.0,BURST_ATT_THRESH_PRE - (LC3_FLOAT)1))); /* nominal time to start mandatory decrease of Xavg */ - } + BURST_ATT_THRESH_PRE = MIN(5, MAX(1, (1 * PLC2_FADEOUT_IN_FRAMES) / 6)); /* nominal 20-40 ms to start actual muting, will be thresh +1 */ + ATT_PER_FRAME = MIN(10, MAX(2, 2 * (6 - BURST_ATT_THRESH_PRE))); /* % we let the BURST_ATT_thresh control the initial table selection */ + BURST_ATT_THRESH = MIN(BURST_ATT_THRESH_PRE, 4); + BETA_MUTE_THR = MIN(4 + (OFF_FRAMES_LIMIT / 2) + 1, MAX(4, BURST_ATT_THRESH + 1 + (LC3_INT32)LC3_POW((LC3_FLOAT)2.0, BURST_ATT_THRESH_PRE - (LC3_FLOAT)1))); /* nominal time to start mandatory decrease of Xavg */ - - /* Initialize in the same way as done in trans_burst_ana_fx(), even though this is not really needed */ +/* Initialize in the same way as done in trans_burst_ana_fx(), even though this is not really needed */ burst_att_thresh = BURST_ATT_THRESH; att_per_frame_idx = ATT_PER_FRAME; +#endif /* 10ms constants */ @@ -158,10 +202,26 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL max_increase_grp_pow_lin = (LC3_FLOAT)1.0*LC3_POW((LC3_FLOAT)10.0, max_increase_grp_pow / (LC3_FLOAT)10.0)*(LC3_FLOAT)(32767.0 / 32768.0); +#ifndef CR8_A_PLC_FADEOUT_TUNING /* envelope setting */ burst_att_thresh = BURST_ATT_THRESH + 1; att_per_frame_idx = ATT_PER_FRAME - 1; +#endif +#ifdef CR8_A_PLC_FADEOUT_TUNING + if (plc_fadeout_type != 0) + { + i = (PLC2_FADEOUT_LONG_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; /*a long fading table entry in fade_scheme_tab */ + } else { + i = (PLC2_FADEOUT_IN_MS - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES; /* a shorter fading entry in fade_scheme_tab */ + } + assert(i >= 0 && i <= ((PLC2_FADEOUT_IN_MS_MAX - PLC2_FADEOUT_IN_MS_MIN) / PLC2_FADEOUT_RES) && "fade_scheme_tab index error"); + + att_per_frame_idx = fade_scheme_tab[i][0]; + burst_att_thresh = fade_scheme_tab[i][1]; /* number of 1.0 frames before muting/mixing phase */ + /* band gain muting may can take place earlier due to a band transient */ + beta_mute_thr = fade_scheme_tab[i][2]; /* muting of Xavg contribution start when slow fadeout is over */ +#endif attDegreeFrames = 0; if (burst_len > burst_att_thresh) @@ -203,7 +263,6 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL /* transient processing */ /* transients may be both rise and decay transients !! */ - if(LC3_FABS(grp_pow_change[i]) >= thresh_tr_dB) { @@ -233,13 +292,20 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL assert(burst_len >= 2); /* states used here */ tr_dec[i] = 0; +#ifndef CR8_A_PLC_FADEOUT_TUNING if (PLC_FADEOUT_IN_MS > 0) +#endif { +#ifdef CR8_A_PLC_FADEOUT_TUNING + assert(att_per_frame_idx >= 1 && att_per_frame_idx <= (10+2)); +#else assert(att_per_frame_idx >= 1 && att_per_frame_idx <= 10); +#endif TABLEQ15 = POW_ATT_TABLES[att_per_frame_idx]; att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT) TABLEQ15[MIN(OFF_FRAMES_LIMIT, attDegreeFrames )] / (LC3_FLOAT)32768.0); /* Table idx 0...N-1 therefore no + 1 */ att_val[i] = att_val[i]; } +#ifndef CR8_A_PLC_FADEOUT_TUNING else { @@ -252,7 +318,7 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT)POW_ATT_TABLE1[MIN(OFF_FRAMES_LIMIT, attDegreeFrames)] / (LC3_FLOAT)32768.0); } } - +#endif if ( (att_val[i] != 0) && (att_val[i] * (LC3_FLOAT)32768.0 < (LC3_FLOAT)0.5) ) { @@ -270,8 +336,12 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL } - +#ifdef CR8_A_PLC_FADEOUT_TUNING + /* note beta_mute decreased once per frame, not once per band */ + if (i == 0 && burst_len > beta_mute_thr) +#else if(burst_len > BETA_MUTE_THR) +#endif { *stPhECU_beta_mute = *stPhECU_beta_mute * (LC3_FLOAT)BETA_MUTE_FAC; } diff --git a/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c b/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c index c860cd6ce3d69968dbd7b217ae7f363a7e791e27..d4d8f15e20c3826e4292336c35052e8928e97e38 100644 --- a/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c +++ b/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c @@ -1,22 +1,28 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * * estoppel or otherwise. * ******************************************************************************/ - + #include "options.h" #include "defines.h" #include "functions.h" -void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, - LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, + + +void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, + LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute, - LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg) + LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg +#ifdef CR8_A_PLC_FADEOUT_TUNING + , LC3_UINT8 plc_fadeout_type +#endif +) { LC3_FLOAT gr_pow_left[MAX_LGW]; LC3_FLOAT gr_pow_right[MAX_LGW]; @@ -28,7 +34,7 @@ void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_IN LC3_INT32 attDegreeFrames; LC3_FLOAT thresh_dbg; - + UNUSED(tr_dec_dbg); UNUSED(gpc_dbg); @@ -40,8 +46,13 @@ void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_IN } + plc_phEcu_tba_trans_dect_gains(burst_len, n_grp, grp_pow_change, stPhECU_beta_mute, stPhECU_mag_chg_1st, alpha, beta, mag_chg, ph_dith, tr_dec, att_val, &attDegreeFrames, &thresh_dbg +#ifdef CR8_A_PLC_FADEOUT_TUNING + , plc_fadeout_type +#endif + ); + - plc_phEcu_tba_trans_dect_gains(burst_len, n_grp, grp_pow_change, stPhECU_beta_mute, stPhECU_mag_chg_1st, alpha, beta, mag_chg, ph_dith, tr_dec, att_val, &attDegreeFrames, &thresh_dbg); return; } diff --git a/lib_lc3plus/plc_tdc.c b/lib_lc3plus/plc_tdc.c index 1a1a408f4d9d3b6216f048c34704735256eb5562..89d745543382512c6e1c01e71669034ef0d49951 100644 --- a/lib_lc3plus/plc_tdc.c +++ b/lib_lc3plus/plc_tdc.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -8,11 +8,11 @@ ******************************************************************************/ -#include "options.h" /***************************************************************************\ * contents/description: Main function for Time domain concealment \***************************************************************************/ +#include "options.h" #include #include "functions.h" @@ -61,6 +61,9 @@ void processTdcApply_fl(const LC3_INT32 pitch_int, LC3_FLOAT* gain_c, LC3_FLOAT* alpha, LC3_FLOAT* synth +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + ,LC3_UINT8 plc_fadeout_type +#endif ) { LC3_FLOAT step, step_n; @@ -77,6 +80,9 @@ void processTdcApply_fl(const LC3_INT32 pitch_int, LC3_FLOAT alphaPrev; LC3_FLOAT throttle; LC3_INT32 frame_dms_idx, nbLostFramesInRow_mod; +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + LC3_INT32 plc_fadeout_len = 0; +#endif memset(synth_mem, 0, M * sizeof(LC3_FLOAT)); memset(scratchSpace, 0, (MAX_LEN_PCM_PLC + MDCT_MEM_LEN_MAX + MAX_LEN_PCM_PLC + 1 + M) * sizeof(LC3_FLOAT)); @@ -91,7 +97,20 @@ void processTdcApply_fl(const LC3_INT32 pitch_int, beforeNextInc = beforeNextIncArray[frame_dms_idx][nbLostFramesInRow_mod]; nextInc = nextIncArray [frame_dms_idx][nbLostFramesInRow_mod]; +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + if (plc_fadeout_type == 1){ + plc_fadeout_len = PLC_FADEOUT_TYPE_1_IN_MS; + } + else{ + plc_fadeout_len = PLC_FADEOUT_IN_MS; + } +#endif + +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + if (nbLostCmpt_loc > plc_fadeout_len/10) +#else if (nbLostCmpt_loc > PLC_FADEOUT_IN_MS/10) +#endif { gain_p = 0; *gain_c = 0; @@ -198,7 +217,14 @@ void processTdcApply_fl(const LC3_INT32 pitch_int, { alphaPrev = *alpha; } - + +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + if (plc_fadeout_type == 2){ + *alpha = LC3_POW(0.5,(nbLostFramesInRow + LC3_ROUND(100.0/frame_dms) - 1) * frame_dms/100.0); + } + else{ +#endif + if (nextInc != 0) { switch (nbLostCmpt_loc) @@ -231,7 +257,14 @@ void processTdcApply_fl(const LC3_INT32 pitch_int, switch (frame_dms) { case 25: *alpha *= PLC34_ATTEN_FAC_025; break; +#ifdef CR9_J_SLOW_TDC_FADEOUT + case 50: *alpha *= PLC34_ATTEN_FAC_025; break; +#else case 50: *alpha *= PLC34_ATTEN_FAC_050; break; +#endif +#ifdef CR8_G_ADD_75MS + case 75: *alpha *= PLC34_ATTEN_FAC_075; break; +#endif case 100: *alpha *= PLC34_ATTEN_FAC_100; break; } } @@ -240,7 +273,9 @@ void processTdcApply_fl(const LC3_INT32 pitch_int, { gain_p = *alpha; } - +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + } +#endif /*---------------------------------------------------------------* * Construct the harmonic part * * Last pitch cycle of the previous frame is repeatedly copied. * @@ -377,7 +412,11 @@ void processTdcApply_fl(const LC3_INT32 pitch_int, *----------------------------------------------------------*/ if (beforeNextInc != 0) { +#ifdef CR9_I_INC_TDC_FADEOUT_LEN + if (nbLostCmpt_loc == plc_fadeout_len/10) +#else if (nbLostCmpt_loc == PLC_FADEOUT_IN_MS/10) +#endif { gain_h = 1; step = 1.0f/(LC3_FLOAT)N; diff --git a/lib_lc3plus/plc_tdc_tdac.c b/lib_lc3plus/plc_tdc_tdac.c index 329361b14c7f995b74a6ca2de051011c81ec088c..3c8e99b0e6ca847f3e70f2c642b151c59ed8878c 100644 --- a/lib_lc3plus/plc_tdc_tdac.c +++ b/lib_lc3plus/plc_tdc_tdac.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/plc_update.c b/lib_lc3plus/plc_update.c index a151420eb7484c7fca0aaa3af5b67f4f994eec27..4ec4e86341df96511f70cfe6d94659c44ed2ba31 100644 --- a/lib_lc3plus/plc_update.c +++ b/lib_lc3plus/plc_update.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,8 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ -#include "functions.h" #include "options.h" +#include "functions.h" void processPlcUpdate_fl(PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, diff --git a/lib_lc3plus/quantize_spec.c b/lib_lc3plus/quantize_spec.c index 7886b4586d6e412a8c9aa44dbf004ed738ec61a6..78d3486539caabddcd41c8bd49d61f858881130e 100644 --- a/lib_lc3plus/quantize_spec.c +++ b/lib_lc3plus/quantize_spec.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,58 +11,118 @@ #include "options.h" #include "functions.h" -static LC3_INT sign(LC3_FLOAT x); - -LC3_INT sign(LC3_FLOAT x) +LC3_INT32 find_last_nz_pair(LC3_INT32 x[], LC3_INT32 length); +LC3_INT32 find_last_nz_pair(LC3_INT32 x[], LC3_INT32 length) { - if (x > 0) - return 1; + LC3_INT32 last_nz, lobs[4]; LC3_INT32 stage, i; + + lobs[0] = 4; + + lobs[1] = (length >> 1); /* length/2 */ + + lobs[2] = (lobs[1]+ (length >> 2)); + + lobs[3] = (lobs[2]+ (length >> 3)); + - if (x < 0) - return -1; + last_nz = 0; + + i = length; + + for (stage = 3; stage >= 0; --stage) + { + /* unmapped kernel */ + for (; i >= lobs[stage]; i -= 2) + { + if (x[i - 2] != 0) + { + last_nz = MAX(last_nz, i); + } + if (x[i - 1] != 0) + { + last_nz = MAX(last_nz, i); + } + } + if (last_nz > 0) + { + break; + } + } - return 0; + return MAX(last_nz, 2); } + void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT nt, LC3_INT totalBits, LC3_INT* nbits, LC3_INT* nbits2, LC3_INT fs, LC3_INT* lastnzout, LC3_INT* codingdata, LC3_INT* lsbMode, LC3_INT mode, LC3_INT target, LC3_INT hrmode) { - LC3_INT rateFlag = 0, i = 0, lastnz2 = 0, m = 0, maxlev = 0, k = 0; - LC3_INT nbits_lsb = 0; - LC3_INT c = 0; - LC3_INT a = 0, b = 0, lev1 = 0, sym = 0, t = 0, pki = 0; - LC3_INT a1_msb = 0, b1_msb = 0; - LC3_INT lastnz = 1; + LC3_INT rateFlag, i, lastnz2, m, maxlev, k; + LC3_INT nbits_lsb; + LC3_INT c; + LC3_INT a, b, lev1, sym, t, pki; + LC3_INT a1_msb, b1_msb; + LC3_INT lastnz = 1, nt_half; LC3_FLOAT offset = 0.375; + LC3_INT32 bits, bits2; +#ifdef CR9_QUANT_SPEC_REWRITE + LC3_FLOAT inv_gain; +#endif + + assert(target >= 0); + + nbits_lsb = 0; + + nt_half = nt >> 1; + rateFlag = 0; c = 0; + if (hrmode) { offset = 0.5; } - /* Quantization */ + +#ifdef CR9_QUANT_SPEC_REWRITE + inv_gain = 1.0 / gain; +#endif + for (i = 0; i < nt; i++) { - xq[i] = trunc(x[i] / gain + offset * sign(x[i])); + if (x[i] > 0) + { +#ifdef CR9_QUANT_SPEC_REWRITE + xq[i] = (LC3_INT32) ( x[i] * inv_gain + offset); +#else + xq[i] = (LC3_INT32) ( x[i] / gain + offset); +#endif + } + else + { +#ifdef CR9_QUANT_SPEC_REWRITE + xq[i] = -((LC3_INT32) (-x[i] * inv_gain + offset)); +#else + xq[i] = -((LC3_INT32) (-x[i] / gain + offset)); +#endif + } if (hrmode == 0) { assert(xq[i] <= 32767 && xq[i] >= -32768); } } /* Rate flag */ - - if ((fs < 48000 && totalBits > 320 + (fs / 8000 - 2) * 160) || (fs == 48000 && totalBits > 800)) { + if (fs != 96000 && (totalBits > (160 + FS2FS_IDX(fs) * 160))) + { rateFlag = 512; } /* Init */ - if (mode == 0 && ((fs < 48000 && totalBits >= 640 + (fs / 8000 - 2) * 160) || (fs == 48000 && totalBits >= 1120))) { + if (fs != 96000 && (mode == 0 && (totalBits >= (480 + FS2FS_IDX(fs) * 160)))) + { mode = 1; } /* Last non-zero 2-tuple */ - for (i = nt - 2; i >= 2; i = i - 2) { if (xq[i + 1] != 0 || xq[i] != 0) { lastnz = i + 1; @@ -70,21 +130,24 @@ void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT } } - - if (mode < 0) { + if (mode < 0) + { lastnz2 = lastnz + 1; - } else { + } + else + { lastnz2 = 2; } - *nbits = 0; - *nbits2 = 0; + bits = bits2 = 0; /* Calculate number of estimated bits */ - for (k = 0; k < lastnz; k = k + 2) { + for (k = 0; k < lastnz; k = k + 2) + { t = c + rateFlag; - if (k > nt / 2) { + if (k > nt_half) + { t += 256; } @@ -94,29 +157,36 @@ void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT b = abs(xq[k + 1]); m = MAX(a, b); - if (m == 0) { + if (m == 0) + { maxlev = -1; - } else { + } + else + { maxlev = 29 - (clz_func(MAX(m, 3)) - 1); } codingdata[1] = maxlev; if (mode <= 0) { - *nbits = *nbits + MIN(a, 1) * 2048; - *nbits = *nbits + MIN(b, 1) * 2048; + bits = bits + (MIN(a, 1) << 11); + bits = bits + (MIN(b, 1) << 11); } lev1 = 0; - while (MAX(a, b) >= 4) { - pki = ari_spec_lookup_fl[t + lev1 * 1024]; - *nbits = *nbits + ari_spec_bits_fl[pki][16]; + while (MAX(a, b) >= 4) + { + pki = ari_spec_lookup_fl[t + lev1 * 1024]; + bits = bits + ari_spec_bits_fl[pki][16]; - if (lev1 == 0 && mode > 0) { + if (lev1 == 0 && mode > 0) + { nbits_lsb += 2; - } else { - *nbits = *nbits + 2 * 2048; + } + else + { + bits = bits + 2 * 2048; } a = a >> 1; @@ -127,68 +197,84 @@ void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT pki = ari_spec_lookup_fl[t + lev1 * 1024]; sym = a + 4 * b; codingdata[2] = sym; - codingdata += 3; - *nbits = *nbits + ari_spec_bits_fl[pki][sym]; + codingdata += 3; + bits = bits + ari_spec_bits_fl[pki][sym]; - if (mode > 0) { + if (mode > 0) + { a1_msb = abs(xq[k]); b1_msb = abs(xq[k + 1]); - if (lev1 > 0) { + if (lev1 > 0) + { a1_msb = a1_msb >> 1; b1_msb = b1_msb >> 1; - if (a1_msb == 0 && xq[k] != 0) { + if (a1_msb == 0 && xq[k] != 0) + { nbits_lsb++; } - if (b1_msb == 0 && xq[k + 1] != 0) { + if (b1_msb == 0 && xq[k + 1] != 0) + { nbits_lsb++; } } - *nbits = *nbits + MIN(a1_msb, 1) * 2048; - *nbits = *nbits + MIN(b1_msb, 1) * 2048; + bits = bits + (MIN(a1_msb, 1) << 11); + bits = bits + (MIN(b1_msb, 1) << 11); } - if (mode >= 0 && (abs(xq[k]) != 0 || abs(xq[k + 1]) != 0) && *nbits <= target * 2048) { + if (mode >= 0 && (abs(xq[k]) != 0 || abs(xq[k + 1]) != 0) && bits <= target * 2048) + { lastnz2 = k + 2; - *nbits2 = *nbits; + bits2 = bits; } lev1 = lev1 - 1; - if (lev1 <= 0) { + + if (lev1 <= 0) + { t = 1 + (a + b) * (lev1 + 2); - } else { + } + else + { t = 13 + lev1; } c = (c & 15) * 16 + t; } - /* Number of bits */ - *nbits = ceil((LC3_FLOAT)*nbits / 2048.0); + *nbits = (bits + 2047) >> 11; // Exactly same as ceil((LC3_FLOAT)*nbits / 2048.0); - if (mode >= 0) { - *nbits2 = ceil((LC3_FLOAT)*nbits2 / 2048.0); - } else { + if (mode >= 0) + { + *nbits2 = (bits2 + 2047) >> 11; //ceil((LC3_FLOAT)*nbits2 / 2048.0); + } + else + { *nbits2 = *nbits; } - if (mode > 0) { - *nbits += nbits_lsb; + if (mode > 0) + { + *nbits += nbits_lsb; *nbits2 += nbits_lsb; } /* Truncation of high-frequency coefficients */ - for (i = lastnz2; i <= lastnz; i++) { + for (i = lastnz2; i <= lastnz; i++) + { xq[i] = 0; } /* Truncation of LSBs */ - if (mode > 0 && *nbits > target) { + if (mode > 0 && *nbits > target) + { *lsbMode = 1; - } else { + } + else + { *lsbMode = 0; } diff --git a/lib_lc3plus/reorder_bitstream.c b/lib_lc3plus/reorder_bitstream.c index 77b50d7a13ba0dc8ffda32396bb5342b6438961d..61880dbd0943af7612b396748127b54cd2367ada 100644 --- a/lib_lc3plus/reorder_bitstream.c +++ b/lib_lc3plus/reorder_bitstream.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * diff --git a/lib_lc3plus/resamp12k8.c b/lib_lc3plus/resamp12k8.c index 0cab5daae94fdd67d480dd8d3b2f7ef2cd55db4f..fd8caad7c03a57f5198ee189e5a2cc1dc39987f2 100644 --- a/lib_lc3plus/resamp12k8.c +++ b/lib_lc3plus/resamp12k8.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -16,15 +16,13 @@ void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3 { - LC3_INT len_12k8 = 0, N12k8 = 0, i = 0, k = 0; - LC3_FLOAT mac = 0, buf_out[120 + MAX_LEN] = {0}, bufdown[128] = {0}, buf[120 + MAX_LEN] = {0}; + LC3_INT len_12k8, N12k8, i, k; + LC3_FLOAT mac, bufdown[128], buf[120 + MAX_LEN]; LC3_INT32 index_int, index_frac, resamp_upfac, resamp_delay, resamp_off_int, resamp_off_frac; LC3_FLOAT u_11, u_21, u_1, u_2; - const LC3_FLOAT *filter; const LC3_FLOAT *filt_input, *filt_coeff; - switch (frame_dms) { case 25: @@ -33,6 +31,11 @@ void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3 case 50: len_12k8 = LEN_12K8 / 2; break; +#ifdef CR8_G_ADD_75MS + case 75: + len_12k8 = (LEN_12K8 / 4) * 3; + break; +#endif case 100: len_12k8 = LEN_12K8; break; @@ -46,8 +49,6 @@ void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3 memmove(&buf[mem_in_len], x, x_len * sizeof(LC3_FLOAT)); memmove(mem_in, &buf[x_len], mem_in_len * sizeof(LC3_FLOAT)); - - filter = lp_filter[fs_idx]; /* Upsampling & Low-pass Filtering & Downsampling */ @@ -97,11 +98,11 @@ void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3 mem_50[1] = (LC3_FLOAT)u_21; /* Output Buffer */ - memmove(buf_out, mem_out, mem_out_len * sizeof(LC3_FLOAT)); + memmove(buf, mem_out, mem_out_len * sizeof(LC3_FLOAT)); - memmove(&buf_out[mem_out_len], bufdown, len_12k8 * sizeof(LC3_FLOAT)); + memmove(&buf[mem_out_len], bufdown, len_12k8 * sizeof(LC3_FLOAT)); - memmove(y, buf_out, (*y_len + 1) * sizeof(LC3_FLOAT)); + memmove(y, buf, (*y_len + 1) * sizeof(LC3_FLOAT)); - memmove(mem_out, &buf_out[N12k8], mem_out_len * sizeof(LC3_FLOAT)); + memmove(mem_out, &buf[N12k8], mem_out_len * sizeof(LC3_FLOAT)); } diff --git a/lib_lc3plus/residual_coding.c b/lib_lc3plus/residual_coding.c index 42094d275f2a2cfb6b42b92dd0ad21f79b503fd1..bcd6637310b0e54e13b7260286b4827153250da7 100644 --- a/lib_lc3plus/residual_coding.c +++ b/lib_lc3plus/residual_coding.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -19,7 +19,7 @@ void processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_I LC3_INT iter=0; LC3_FLOAT offset; LC3_INT iter_max = 1; - LC3_INT nz_idx[MAX_LEN] = {0}; + LC3_INT nz_idx[MAX_LEN]; LC3_INT N_nz = 0, idx = 0; diff --git a/lib_lc3plus/residual_decoding.c b/lib_lc3plus/residual_decoding.c index 97fd94afc35e19d43c5a7866bbffb92758cdad96..5085d999af8e6c9c40c510377c4e6b7385421d05 100644 --- a/lib_lc3plus/residual_decoding.c +++ b/lib_lc3plus/residual_decoding.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -18,7 +18,7 @@ void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec LC3_INT k = 0, n = 0; LC3_FLOAT offset1 = 0, offset2 = 0; LC3_FLOAT offset = 0; - LC3_INT nz_idx[MAX_LEN] = {0}; + LC3_INT nz_idx[MAX_LEN]; LC3_INT N_nz = 0, idx = 0; LC3_INT iter = 0, iter_max = 1; @@ -65,7 +65,7 @@ void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec break; } } - offset /= 2; + offset *= 0.5; iter ++; } } diff --git a/lib_lc3plus/setup_com_lc3.c b/lib_lc3plus/setup_com_lc3.c index 17054d1ffcfdd63015e0e169b199ae606379217f..cecbfd7762fa9b3183817bcb17ebfddc66493a55 100644 --- a/lib_lc3plus/setup_com_lc3.c +++ b/lib_lc3plus/setup_com_lc3.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -7,8 +7,8 @@ * estoppel or otherwise. * ******************************************************************************/ -#include "functions.h" #include "options.h" +#include "functions.h" LC3_FLOAT array_max_abs(LC3_FLOAT *in, LC3_INT32 len) { diff --git a/lib_lc3plus/setup_dec_lc3.c b/lib_lc3plus/setup_dec_lc3.c index c14309720ec4e0cae213b81d64ef7b170a5b651d..517a48b4921e81ae0d653be4f6f5ce9b4a3770d2 100644 --- a/lib_lc3plus/setup_dec_lc3.c +++ b/lib_lc3plus/setup_dec_lc3.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -19,8 +19,8 @@ int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels) { - int ch = 0; - size_t size = sizeof(LC3PLUS_Dec); + int ch = 0; + size_t size = sizeof(LC3PLUS_Dec); size_t frame_len = DYN_MAX_LEN_EXT(samplerate); void *PlcAdvSetup = NULL; @@ -34,6 +34,11 @@ int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels) HANDLE_IIS_FFT handle_fft_phaseecu; HANDLE_IIS_FFT handle_ifft_phaseecu; LC3_FLOAT *q_old_res; + +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT32 * plc_longterm_advc_tdc = NULL, *plc_longterm_advc_ns = NULL; + LC3_INT16 longterm_analysis_counter_max = 0, longterm_analysis_counter_max_bytebuffer = 0; +#endif for (ch = 0; ch < channels; ch++) { DecSetup* setup = balloc(decoder, &size, sizeof(DecSetup)); @@ -57,6 +62,15 @@ int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels) sine_table1_phecu = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((CODEC_FS(samplerate) * 16) / 1000) / 2 + 1)); sine_table2_phecu = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((CODEC_FS(samplerate) * 16) / 1000) / 2 + 1)); + +#ifdef CR8_A_PLC_FADEOUT_TUNING + longterm_analysis_counter_max = plc_fadeout_param_maxlen[0]; + longterm_analysis_counter_max_bytebuffer = plc_fadeout_param_maxbytes[0]; + + + plc_longterm_advc_tdc = balloc(decoder, &size, sizeof(LC3_INT32) * longterm_analysis_counter_max_bytebuffer); + plc_longterm_advc_ns = balloc(decoder, &size, sizeof(LC3_INT32) * longterm_analysis_counter_max_bytebuffer); +#endif q_old_res = balloc(decoder, &size, sizeof(LC3_FLOAT) * frame_len); @@ -80,6 +94,14 @@ int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels) setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu->sine_table = sine_table1_phecu; setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu->sine_table = sine_table2_phecu; + +#ifdef CR8_A_PLC_FADEOUT_TUNING + setup->PlcAdvSetup->longterm_analysis_counter_max = longterm_analysis_counter_max; + setup->PlcAdvSetup->longterm_analysis_counter_max_bytebuffer = longterm_analysis_counter_max_bytebuffer; + + setup->PlcAdvSetup->plc_longterm_advc_tdc = plc_longterm_advc_tdc; + setup->PlcAdvSetup->plc_longterm_advc_ns = plc_longterm_advc_ns; +#endif setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = (CODEC_FS(samplerate) * 16) / 1000; real_fft_init(&(setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &(setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu)); @@ -104,10 +126,12 @@ LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, L decoder->plcMeth = plc_mode; decoder->hrmode = hrmode != 0; - + +#ifndef CR8_A_PLC_FADEOUT_TUNING if (decoder->fs_idx > 4) { decoder->fs_idx = 5; } +#endif decoder->channels = channels; decoder->frame_ms = 10; decoder->frame_dms = 100; @@ -175,6 +199,21 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) decoder->yLen /= 2; decoder->bands_number = bands_number_5ms[decoder->fs_idx]; } +#ifdef CR8_G_ADD_75MS + if (decoder->frame_ms == 7.5) + { + decoder->frame_length = (decoder->frame_length >> 2) * 3; + decoder->yLen = (decoder->yLen / 4) * 3; + if (decoder->hrmode) + { + decoder->bands_number = bands_number_7_5ms_HR[decoder->fs_idx]; + } + else + { + decoder->bands_number = bands_number_7_5ms[decoder->fs_idx]; + } + } +# endif if (decoder->hrmode) { @@ -221,6 +260,20 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) } decoder->cutoffBins = BW_cutoff_bin_all_5ms; } +#ifdef CR8_G_ADD_75MS + else if (decoder->frame_ms == 7.5) + { + if (decoder->hrmode) + { + decoder->bands_offset = ACC_COEFF_PER_BAND_7_5ms_HR[decoder->fs_idx]; + } + else + { + decoder->bands_offset = ACC_COEFF_PER_BAND_7_5ms[decoder->fs_idx]; + } + decoder->cutoffBins = BW_cutoff_bin_all_7_5ms; + } +# endif decoder->n_bandsPLC = MIN(decoder->frame_length, 80); @@ -246,6 +299,19 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) decoder->n_bandsPLC = 60; } } +# ifdef CR8_G_ADD_75MS + else if (decoder->frame_ms == 7.5) + { + decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC_7_5ms[decoder->fs_idx]; + + if (decoder->fs != 32000 && decoder->fs != 96000) + if (decoder->fs != 32000) + { + decoder->n_bandsPLC = 60; + } + } +# endif + assert(decoder->bands_offsetPLC); if (decoder->frame_ms == 10) { @@ -263,6 +329,13 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) decoder->imdct_laZeros = MDCT_la_zeroes_5ms[decoder->fs_idx]; decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_5ms[decoder->fs_idx]; } +#ifdef CR8_G_ADD_75MS + else if (decoder->frame_ms == 7.5) { + decoder->imdct_win = MDCT_WINS_7_5ms[decoder->hrmode][decoder->fs_idx]; + decoder->imdct_laZeros = MDCT_la_zeroes_7_5ms[decoder->fs_idx]; + decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_7_5ms[decoder->fs_idx]; + } +# endif decoder->la_zeroes = decoder->imdct_laZeros; @@ -307,6 +380,11 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) setup->PlcAdvSetup->cum_fading_fast = 1; setup->PlcAdvSetup->cum_fading_slow = 1; setup->PlcAdvSetup->cum_fflcAtten = 1; + +#ifdef CR8_A_PLC_FADEOUT_TUNING + setup->PlcAdvSetup->longterm_analysis_counter_max = plc_fadeout_param_maxlen[(decoder->frame_dms / 25) - 1]; + setup->PlcAdvSetup->longterm_analysis_counter_max_bytebuffer = plc_fadeout_param_maxbytes[(decoder->frame_dms / 25) - 1]; +#endif if (decoder->fs_idx <= 4 && decoder->frame_dms == 100) { @@ -340,6 +418,9 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) } setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient */ setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_num_plocs = 0; +#ifdef CR8_A_PLC_FADEOUT_TUNING + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_nonpure_tone_flag = -1; /* nonpure tone flag, -1==new calc., 0==pure, 1==nonpure */ +#endif } } } @@ -362,6 +443,12 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes) maxBytes = 375; minBytes = MIN_NBYTES; break; +#ifdef CR8_G_ADD_75MS + case 75: + maxBytes = 625; + minBytes = MIN_NBYTES; + break; +#endif case 100: maxBytes = 625; minBytes = MIN_NBYTES; @@ -406,6 +493,12 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes) setup->enable_lpc_weighting = (setup->total_bits < 240); totalBits = setup->total_bits * 2 - 160; } +# ifdef CR8_G_ADD_75MS + if (decoder->frame_ms == 7.5) { + setup->enable_lpc_weighting = (setup->total_bits < 360); + totalBits = round(setup->total_bits * 10 / 7.5); + } +# endif if (decoder->frame_length > 40 * ((LC3_FLOAT) (decoder->frame_dms) / 10.0)) { setup->N_red_tns = 40 * ((LC3_FLOAT) (decoder->frame_dms) / 10.0); diff --git a/lib_lc3plus/setup_dec_lc3.h b/lib_lc3plus/setup_dec_lc3.h index 6ed0f438ea7601d9646d9c821730f1ae9c1a630f..3ae6b139772945416e5976ecd110ac34e4f35add 100644 --- a/lib_lc3plus/setup_dec_lc3.h +++ b/lib_lc3plus/setup_dec_lc3.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,6 +11,7 @@ #ifndef SETUP_DEC_LC3_FL_H #define SETUP_DEC_LC3_FL_H +#include "options.h" #include "constants.h" /* Channel state and bitrate-derived values go in this struct */ @@ -49,6 +50,9 @@ typedef struct { LC3_FLOAT x_fl[MAX_LEN]; LC3_FLOAT imdct_mem[MAX_LEN]; LC3_FLOAT alpha; +#ifdef CR9_N_SHORT_FADE_FOR_UNSTABLE_PITCH + LC3_FLOAT rel_pitch_change; +#endif Dct4 dct4structImdct; diff --git a/lib_lc3plus/setup_enc_lc3.c b/lib_lc3plus/setup_enc_lc3.c index 986b43d6085443e801d293370634cd30bf9c7b6d..a7c94a44e2ef669e521040986d18ccd8740f45f1 100644 --- a/lib_lc3plus/setup_enc_lc3.c +++ b/lib_lc3plus/setup_enc_lc3.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -42,9 +42,12 @@ LC3PLUS_Error FillEncSetup(LC3PLUS_Enc* encoder, int samplerate, int channels encoder->fs_in = samplerate; encoder->fs_idx = FS2FS_IDX(encoder->fs); encoder->frame_dms = 100; + +#ifndef CR8_A_PLC_FADEOUT_TUNING if (encoder->fs_idx > 4) { encoder->fs_idx = 5; } +#endif encoder->hrmode = hrmode != 0; @@ -103,6 +106,7 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder) encoder->yLen = MIN(MAX_BW, encoder->frame_length); encoder->sns_damping = 0.85; } + encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; encoder->bands_number = 64; encoder->nSubdivisions = 3; @@ -140,19 +144,46 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder) encoder->attdec_damping = 0.5; encoder->attdec_hangover_thresh = 2; } - else if (encoder->frame_ms == 2.5) { - encoder->la_zeroes = MDCT_la_zeroes_2_5ms[encoder->fs_idx]; +#ifdef CR8_G_ADD_75MS + else if (encoder->frame_ms == 7.5) { if (encoder->hrmode) { - encoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms_HR[encoder->fs_idx]; + encoder->bands_offset = ACC_COEFF_PER_BAND_7_5ms_HR[encoder->fs_idx]; } else { - encoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms[encoder->fs_idx]; + encoder->bands_offset = ACC_COEFF_PER_BAND_7_5ms[encoder->fs_idx]; } - encoder->cutoffBins = BW_cutoff_bin_all_2_5ms; + encoder->la_zeroes = MDCT_la_zeroes_7_5ms[encoder->fs_idx]; + encoder->cutoffBins = BW_cutoff_bin_all_7_5ms; + encoder->attdec_nblocks = 3; + encoder->attdec_damping = 0.3; + encoder->attdec_hangover_thresh = 1; + + encoder->frame_length = (encoder->frame_length >> 2) * 3; + encoder->yLen = (encoder->yLen >> 2) * 3; + + encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; + if (encoder->hrmode) + { + encoder->bands_number = bands_number_7_5ms_HR[encoder->fs_idx]; + } + else + { + encoder->bands_number = bands_number_7_5ms[encoder->fs_idx]; + } + encoder->nSubdivisions = 3; + encoder->near_nyquist_index = encoder->bands_number - 4; + encoder->r12k8_mem_out_len = ceil(2.0 * ((LC3_FLOAT) encoder->frame_length / 2.0 - (LC3_FLOAT) encoder->la_zeroes) * 12800.0 / (LC3_FLOAT) encoder->fs - 8.0); } +#endif else if (encoder->frame_ms == 5) { + encoder->frame_length = encoder->frame_length >> 1; + encoder->yLen /= 2; + encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; + encoder->bands_number = bands_number_5ms[encoder->fs_idx]; + encoder->nSubdivisions = 2; + encoder->near_nyquist_index = encoder->bands_number - 3; encoder->la_zeroes = MDCT_la_zeroes_5ms[encoder->fs_idx]; if (encoder->hrmode) { @@ -164,8 +195,17 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder) } encoder->cutoffBins = BW_cutoff_bin_all_5ms; } - - if (encoder->frame_ms == 2.5) { + else if (encoder->frame_ms == 2.5) { + encoder->la_zeroes = MDCT_la_zeroes_2_5ms[encoder->fs_idx]; + if (encoder->hrmode) + { + encoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms_HR[encoder->fs_idx]; + } + else + { + encoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms[encoder->fs_idx]; + } + encoder->cutoffBins = BW_cutoff_bin_all_2_5ms; encoder->frame_length = encoder->frame_length >> 2; encoder->yLen /= 4; encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; @@ -182,22 +222,14 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder) encoder->near_nyquist_index = encoder->bands_number - 2; encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + (LEN_12K8 >> 2); } - - - if (encoder->frame_ms == 5) { - encoder->frame_length = encoder->frame_length >> 1; - encoder->yLen /= 2; - encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; - encoder->bands_number = bands_number_5ms[encoder->fs_idx]; - encoder->nSubdivisions = 2; - encoder->near_nyquist_index = encoder->bands_number - 3; - } for (ch = 0; ch < encoder->channels; ch++) { setup = encoder->channel_setup[ch]; setup->olpa_mem_pitch = 17; - +#ifdef CR9_F_PITCH_WIN_LEN_FIX + setup->pitch_flag = 0; +#endif if (setup->mdctStruct.mem != NULL) { mdct_free(&setup->mdctStruct); mdct_init(&setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode); @@ -219,9 +251,9 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) int ch = 0, bitsTmp = 0, minBR = 0, maxBR = 0, totalBytes = 0; LC3_INT channel_bytes = 0, max_bytes = 0; +#ifdef ENABLE_HR_MODE_FL if (encoder->hrmode) { -#ifdef ENABLE_HR_MODE_FL switch (encoder->frame_dms) { case 25: @@ -236,6 +268,14 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) else if (encoder->fs == 96000) {minBR = MIN_BR_50MS_96KHZ_HR;} else { return LC3PLUS_HRMODE_ERROR;} break; +#ifdef CR8_G_ADD_75MS + case 75: + maxBR = 500000; + if (encoder->fs == 48000) {minBR = MIN_BR_075DMS_48KHZ_HR;} + else if (encoder->fs == 96000) {minBR = MIN_BR_075DMS_96KHZ_HR;} + else {return LC3PLUS_HRMODE_ERROR;} + break; +#endif case 100: maxBR = 500000; if (encoder->fs == 48000) {minBR = MIN_BR_100MS_48KHZ_HR;} @@ -245,9 +285,9 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) default: return LC3PLUS_HRMODE_ERROR; } -#endif } else +#endif /* ENABLE_HR_MODE_FL */ { minBR = (MIN_NBYTES << 3); maxBR = MAX_BR; @@ -268,6 +308,20 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) default: break; } break; +#ifdef CR8_G_ADD_75MS + case 75: + minBR = MIN_BR_075DMS; + maxBR = MAX_BR_075DMS; + /* have additional limitations for 7.5ms */ + switch (encoder->fs_in) + { + case 8000: maxBR = MAX_BR_075DMS_NB ; break; + case 16000: maxBR = MAX_BR_075DMS_WB ; break; + case 24000: maxBR = MAX_BR_075DMS_SSWB; break; + default: break; + } + break; +#endif case 100: /* have additional limitations for 10ms */ minBR = MIN_BR_100DMS; @@ -388,6 +442,11 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) setup->targetBitsAri = setup->total_bits; setup->enable_lpc_weighting = setup->total_bits < 480; +#ifdef CR8_G_ADD_75MS + if (encoder->frame_ms == 7.5) { + setup->enable_lpc_weighting = setup->total_bits < 360; + } +#endif if (encoder->frame_ms == 5) { setup->enable_lpc_weighting = setup->total_bits < 240; } @@ -433,6 +492,11 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) if (encoder->frame_ms == 5) { bitsTmp = bitsTmp * 2 - 160; } +#ifdef CR8_G_ADD_75MS + if (encoder->frame_ms == 7.5) { + bitsTmp = round(bitsTmp * 10 / 7.5); + } +#endif if (bitsTmp < 400 + (encoder->fs_idx - 1) * 80) { setup->ltpf_enable = 1; @@ -461,6 +525,14 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) encoder->sns_damping = 6881.0/32768.0; } } +#ifdef CR8_G_ADD_75MS + if (encoder->frame_ms == 7.5) + { + if (setup->total_bits > 3*4400/4) { + encoder->sns_damping = 5898.0/32768.0; + } + } +#endif if (encoder->frame_ms == 5) { if (setup->total_bits > 4600/2) { @@ -487,6 +559,12 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) { setup->regBits +=2; } +#ifdef CR8_G_ADD_75MS + if (encoder->frame_ms == 7.5) + { + setup->regBits +=1; + } +#endif if (encoder->frame_ms == 2.5) { setup->regBits -= 6; @@ -502,6 +580,12 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) { setup->regBits += 0; } +#ifdef CR8_G_ADD_75MS + if (encoder->frame_ms == 7.5) + { + setup->regBits +=2; + } +#endif if (encoder->frame_ms == 10) { setup->regBits += 5; @@ -538,9 +622,11 @@ void update_enc_bandwidth(LC3PLUS_Enc* encoder, int bandwidth) { encoder->bandwidth = bandwidth; index = FS2FS_IDX(bandwidth); +#ifndef CR8_A_PLC_FADEOUT_TUNING if (index > 4) { index = 5; } +#endif encoder->bw_ctrl_cutoff_bin = encoder->cutoffBins[index]; } } diff --git a/lib_lc3plus/setup_enc_lc3.h b/lib_lc3plus/setup_enc_lc3.h index 31f0cbeb50edfb2f21c87c29192f3539f9045401..43c29e12bcd73d3d9865fb4e706da2f724bc3d23 100644 --- a/lib_lc3plus/setup_enc_lc3.h +++ b/lib_lc3plus/setup_enc_lc3.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,6 +11,7 @@ #ifndef SETUP_ENC_LC3_FL_H #define SETUP_ENC_LC3_FL_H +#include "options.h" #include "constants.h" /* Channel state and bitrate-derived values go in this struct */ @@ -22,7 +23,11 @@ typedef struct { LC3_FLOAT attdec_acc_energy; LC3_FLOAT r12k8_mem_50[2]; LC3_FLOAT r12k8_mem_in[120]; +#ifdef CR8_G_ADD_75MS + LC3_FLOAT r12k8_mem_out[44]; +#else LC3_FLOAT r12k8_mem_out[24]; +#endif LC3_FLOAT olpa_mem_s12k8[3]; LC3_FLOAT olpa_mem_s6k4[LEN_6K4 + MAX_PITCH_6K4 + 16]; LC3_FLOAT ltpf_mem_in[LTPF_MEMIN_LEN + LEN_12K8 + 1]; @@ -44,6 +49,9 @@ typedef struct { LC3_INT tns_bits; LC3_INT targetBitsQuant; LC3_INT olpa_mem_pitch; +#ifdef CR9_F_PITCH_WIN_LEN_FIX + LC3_INT pitch_flag; +#endif LC3_INT ltpf_mem_ltpf_on; LC3_INT mem_targetBits; LC3_INT mem_specBits; diff --git a/lib_lc3plus/sns_compute_scf.c b/lib_lc3plus/sns_compute_scf.c index 5cb041925bbcf0dc5b8a0c47f0b5d8aa07d01bd1..586fd9ef669a4449dbd204ae2ff56365ba2767e7 100644 --- a/lib_lc3plus/sns_compute_scf.c +++ b/lib_lc3plus/sns_compute_scf.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,12 +11,16 @@ #include "options.h" #include "functions.h" -void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor) +void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor, LC3_INT fs_idx) { - LC3_INT bands_number = 0, d = 0, i = 0, j = 0, n = 0, n2 = 0, n4 = 0, mapping[64] = {0}; - LC3_FLOAT tmp[64] = {0}, x_tmp1[MAX_LEN] = {0}, x_tmp2[MAX_LEN] = {0}, sum = 0, mean = 0, xl4[16] = {0}, nf = 0, xl[64] = {0}, gains_smooth[M] = {0}, ratio = 0; - LC3_FLOAT W[6] = {1.0 / 12.0, 2.0 / 12.0, 3.0 / 12.0, 3.0 / 12.0, 2.0 / 12.0, 1.0 / 12.0}; - + LC3_INT bands_number, d, i, j, n, n2, n4, mapping[64]; + LC3_FLOAT x_tmp1[MAX_LEN], sum, mean, nf, gains_smooth[M], ratio; + LC3_FLOAT sum_gains_smooth; + const LC3_FLOAT* sns_preemph; + + sum_gains_smooth = 0; sum = 0; + sns_preemph = sns_preemph_all[fs_idx]; + bands_number = xLen; assert(bands_number <= 64); @@ -28,13 +32,14 @@ void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT { j = 0; for (i = 0; i < 2 * d; i = i + 2) { - tmp[i] = x[j]; - tmp[i + 1] = x[j]; + x_tmp1[i] = x[j]; + x_tmp1[i + 1] = x[j]; j++; } - move_float(&tmp[2 * d], &x[d], 64 - 2 * d); - } else if (ceil(64.0 / (LC3_FLOAT) xLen) == 4) + move_float(&x_tmp1[2 * d], &x[d], 64 - 2 * d); + } + else if (bands_number < 32) { ratio = LC3_FABS((LC3_FLOAT) (1.0 - 32.0 / (LC3_FLOAT) xLen)); n4 = round(ratio * xLen); @@ -60,13 +65,13 @@ void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT for (i = 0; i < 64; i++) { - tmp[i] = x[mapping[i] - 1]; + x_tmp1[i] = x[mapping[i] - 1]; } } else { assert(0 && "Unsupported number of bands!"); } - move_float(x, tmp, 64); + move_float(x, x_tmp1, 64); bands_number = 64; xLen = bands_number; @@ -76,20 +81,17 @@ void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT /* Smoothing */ x_tmp1[0] = x[0]; + move_float(&x_tmp1[1], &x[0], 63); - move_float(&x_tmp1[1], &x[0], xLen - 1); - - move_float(&x_tmp2[0], &x[1], xLen - 1); - - x_tmp2[xLen - 1] = x[xLen - 1]; - - for (i = 0; i < xLen; i++) { - x[i] = 0.5 * x[i] + 0.25 * (x_tmp1[i] + x_tmp2[i]); + for (i = 0; i < 63; i++) { + x[i] = 0.5 * x[i] + 0.25 * (x_tmp1[i] + x[i + 1]); } + + x[63] = 0.5 * x[63] + 0.25 * (x_tmp1[63] + x[63]); /* Pre-emphasis */ - for (i = 0; i < xLen; i++) { - x[i] = x[i] * LC3_POW(10.0, (LC3_FLOAT)i * (LC3_FLOAT)tilt / ((LC3_FLOAT)bands_number - 1.0) / 10.0); + for (i = 0; i < 64; i++) { + x[i] = x[i] * sns_preemph[i]; } /* Noise floor at -40dB */ @@ -97,10 +99,10 @@ void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT sum += x[i]; } - mean = sum / (LC3_FLOAT)xLen; + mean = sum * 0.015625; /* 1/64 */ - nf = mean * LC3_POW(10.0, -40.0 / 10.0); - nf = MAX(nf, LC3_POW(2.0, -32.0)); + nf = mean * 1.00e-04; + nf = MAX(nf, 2.328306436538696e-10); for (i = 0; i < 64; i++) { if (x[i] < nf) { @@ -110,45 +112,40 @@ void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT /* Log-domain */ for (i = 0; i < 64; i++) { - xl[i] = LC3_LOGTWO(x[i]) / 2.0; + x[i] = LC3_LOGTWO(x[i]) * 0.5; } /* Downsampling */ - for (n = 0; n < bands_number / 4; n++) { + for (n = 0; n < 16; n++) { if (n == 0) { - tmp[0] = xl[0]; + x_tmp1[0] = x[0]; - move_float(&tmp[1], &xl[0], 5); + move_float(&x_tmp1[1], &x[0], 5); - } else if (n == (bands_number / 4 - 1)) { - move_float(tmp, &xl[59], 5); + } else if (n == 15) { + move_float(x_tmp1, &x[59], 5); - tmp[5] = xl[63]; + x_tmp1[5] = x[63]; } else { - move_float(tmp, &xl[n * 4 - 1], ((n * 4 + 5 - 1) - (n * 4 - 1) + 1)); + move_float(x_tmp1, &x[n * 4 - 1], ((n * 4 + 5 - 1) - (n * 4 - 1) + 1)); } sum = 0; for (i = 0; i < 6; i++) { - sum += tmp[i] * W[i]; + sum += x_tmp1[i] * sns_W[i]; } - xl4[n] = sum; + gains_smooth[n] = sum; + sum_gains_smooth += sum; } /* Remove mean and scaling */ + mean = sum_gains_smooth / 16.0; - sum = 0; - for (i = 0; i < bands_number / 4; i++) { - sum += xl4[i]; - } - - mean = sum / ((LC3_FLOAT)bands_number / 4.0); - - for (i = 0; i < bands_number / 4; i++) { - gains[i] = sns_damping * (xl4[i] - mean); + for (i = 0; i < 16; i++) { + gains[i] = sns_damping * (gains_smooth[i] - mean); } /* Smoothing */ diff --git a/lib_lc3plus/sns_interpolate_scf.c b/lib_lc3plus/sns_interpolate_scf.c index 4419397890d890f097d538b3ee4799ca1a14c7b9..fea81e6be5684a180452a10b23d02e5a759a6dd4 100644 --- a/lib_lc3plus/sns_interpolate_scf.c +++ b/lib_lc3plus/sns_interpolate_scf.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -13,23 +13,23 @@ void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT* gains_int) { - LC3_INT i = 0, n = 0, d = 0, n4 = 0; - LC3_FLOAT tmp[MAX_BANDS_NUMBER_PLC] = {0}, ratio = 0; + LC3_INT i, n, d, n4; + LC3_FLOAT tmp[MAX_BANDS_NUMBER_PLC], ratio; /* Interpolation */ gains_int[0] = gains[0]; gains_int[1] = gains[0]; - for (n = 0; n <= 14; n++) { - gains_int[n * 4 + 2] = gains[n] + (gains[n + 1] - gains[n]) / 8.0; - gains_int[n * 4 + 3] = gains[n] + 3.0 * (gains[n + 1] - gains[n]) / 8.0; - gains_int[n * 4 + 4] = gains[n] + 5.0 * (gains[n + 1] - gains[n]) / 8.0; - gains_int[n * 4 + 5] = gains[n] + 7.0 * (gains[n + 1] - gains[n]) / 8.0; + for (n = 0; n <= 14; n++) { + gains_int[n * 4 + 2] = gains[n] + (gains[n + 1] - gains[n]) * 0.125; + gains_int[n * 4 + 3] = gains[n] + (gains[n + 1] - gains[n]) * 0.375; + gains_int[n * 4 + 4] = gains[n] + (gains[n + 1] - gains[n]) * 0.625; + gains_int[n * 4 + 5] = gains[n] + (gains[n + 1] - gains[n]) * 0.875; } - gains_int[62] = gains[15] + (gains[15] - gains[14]) / 8.0; - gains_int[63] = gains[15] + 3.0 * (gains[15] - gains[14]) / 8.0; + gains_int[62] = gains[15] + (gains[15] - gains[14]) * 0.125; + gains_int[63] = gains[15] + (gains[15] - gains[14]) * 0.375; /* For 5ms */ @@ -53,7 +53,8 @@ void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT } move_float(gains_int, tmp, d); - } else if (ceil(64.0 / (LC3_FLOAT) bands_number) == 4) + } + else if (bands_number < 32) { ratio = LC3_FABS((LC3_FLOAT) ((LC3_FLOAT)1.0 - (LC3_FLOAT)32.0 / (LC3_FLOAT) bands_number)); n4 = LC3_ROUND(ratio * (LC3_FLOAT)bands_number); diff --git a/lib_lc3plus/sns_quantize_scf.c b/lib_lc3plus/sns_quantize_scf.c index 704127cce71fdab61027a76f66f9382859048ed4..3cb81aee9ce1c85bb87827f242976cc02aa62d89 100644 --- a/lib_lc3plus/sns_quantize_scf.c +++ b/lib_lc3plus/sns_quantize_scf.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -421,7 +421,7 @@ LC3_INT find_last_indice_le(LC3_INT compare, const LC3_INT* array, LC3_INT len) void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pulses) { - LC3_INT leading_sign = 0, idx = 0, k_delta = 0, pos = 0; + LC3_INT leading_sign, idx, k_delta = 0, pos; leading_sign = 1 - 2 * LS_ind; @@ -454,9 +454,9 @@ void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pu void process_snsQuantizesScf_Dec(LC3_INT* scf_idx, LC3_FLOAT* scf_q) { - LC3_INT i = 0, submode = 0; + LC3_INT i, submode; LC3_INT pulses2[6] = {0}, pulses[M] = {0}; - LC3_FLOAT st2_vector[M] = {0}, st2_vector_idct[M] = {0}, sum = 0; + LC3_FLOAT st2_vector[M], st2_vector_idct[M], sum = 0; /* Decode first stage */ @@ -505,13 +505,18 @@ void process_snsQuantizesScf_Dec(LC3_INT* scf_idx, LC3_FLOAT* scf_q) idct_II(st2_vector, st2_vector_idct, M); /* Gain */ + /* Add stage 1 and stage 2 */ +#ifdef CR9_SIMPLIFY_LOOP + for (i = 0; i < M; i++) { + scf_q[i] += st2_vector_idct[i] * sns_dec_gains[submode][scf_idx[3]]; + } +#else for (i = 0; i < M; i++) { st2_vector_idct[i] = st2_vector_idct[i] * sns_dec_gains[submode][scf_idx[3]]; } - /* Add stage 1 and stage 2 */ - for (i = 0; i < M; i++) { scf_q[i] = scf_q[i] + st2_vector_idct[i]; } +#endif } diff --git a/lib_lc3plus/structs.h b/lib_lc3plus/structs.h index fea377da412ed0c7c1df662d74537495d911353c..e311824b7fcf58b8c2363cb4bf9bfde23aa7494e 100644 --- a/lib_lc3plus/structs.h +++ b/lib_lc3plus/structs.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,6 +11,7 @@ #ifndef STRUCTS_H #define STRUCTS_H +#include "options.h" #include "defines.h" #include "fft/iisfft.h" @@ -66,6 +67,7 @@ typedef struct { LC3_INT32 pc_be_bp_left; LC3_INT32 pc_be_bp_right; LC3_INT32 pc_return; + LC3_INT16 pc_inv_bin; } Decoder_State_fl; typedef struct { @@ -154,6 +156,9 @@ typedef struct { LC3_INT32 PhECU_num_plocs; HANDLE_IIS_FFT handle_fft_phaseecu; HANDLE_IIS_FFT handle_ifft_phaseecu; +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT16 PhECU_nonpure_tone_flag; /* BASOP Word16 PhECU_nonpure_tone_flag*/ +#endif } PlcPhEcuSetup; @@ -179,8 +184,24 @@ typedef struct { LC3_FLOAT cum_fflcAtten; LC3_FLOAT scf_q_old[M]; LC3_FLOAT scf_q_old_old[M]; - PlcPhEcuSetup PlcPhEcuSetup; + PlcPhEcuSetup PlcPhEcuSetup; + +#ifdef CR8_A_PLC_FADEOUT_TUNING + LC3_INT16 longterm_counter_plcTdc; +# ifndef CR9_L_RETRAIN_FADEOUT_TYPE_CLASSIFIER + LC3_INT16 longterm_counter_plcPhaseEcu; +# endif + LC3_INT16 longterm_counter_plcNsAdv; + LC3_INT16 longterm_analysis_counter_max; /* Maximum longterm frames number */ + LC3_INT16 longterm_analysis_counter_max_bytebuffer; /* Same as above but reduced for circular bit-buffer */ + LC3_INT32 *plc_longterm_advc_tdc; + LC3_INT32 *plc_longterm_advc_ns; + LC3_UINT8 plc_fadeout_type; + LC3_UINT8 plc_fadeout_type_first; + LC3_INT16 overall_counter; + LC3_INT8 longterm_counter_byte_position; + LC3_INT8 longterm_counter_bit_position; +#endif } PlcAdvSetup; - #endif diff --git a/lib_lc3plus/tns_coder.c b/lib_lc3plus/tns_coder.c index ff3883d2b5fa964a7a2c4a4523757432d080a5cb..e9301af9df8187d51317e49da9372a78cd6fa4bb 100644 --- a/lib_lc3plus/tns_coder.c +++ b/lib_lc3plus/tns_coder.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -14,35 +14,22 @@ static void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen); static void levdown(LC3_FLOAT* anxt, LC3_FLOAT* out_a, LC3_INT* len); static void poly2rc(LC3_FLOAT* a, LC3_FLOAT* out, LC3_INT len); -static LC3_INT findRC_idx(const LC3_FLOAT* in1, const LC3_FLOAT* in2, LC3_FLOAT checkValue); void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen) { - LC3_INT i = 0, m = 0; - LC3_FLOAT sum = 0, tmp_buf[MAX_LEN] = {0}; + LC3_INT32 m; - for (m = -lag; m <= lag; m++) { - /* Append zeros and input vector */ - zero_float(tmp_buf, abs(m)); - - move_float(&tmp_buf[abs(m)], in, inLen - abs(m)); - - /* Calculate sum */ - sum = 0; - - for (i = 0; i < inLen; i++) { - sum += in[i] * tmp_buf[i]; - } - - out[m + lag] = sum; + for (m = 0; m <= lag; m++) { + /* Calculate correlation */ + out[m] = mac_loop(in, &in[m], (inLen - m)); } } void levinsonDurbin(LC3_FLOAT* r, LC3_FLOAT* out_lev, LC3_FLOAT* rc_unq, LC3_FLOAT* error, LC3_INT len) { - LC3_INT t = 0, i = 0, j = 0; - LC3_FLOAT g = 0, v = 0, sum = 0, buf_tmp[MAX_LEN] = {0}; + LC3_INT t, i, j; + LC3_FLOAT g, v, sum, buf_tmp[10]; g = r[1] / r[0]; out_lev[0] = g; @@ -51,7 +38,6 @@ void levinsonDurbin(LC3_FLOAT* r, LC3_FLOAT* out_lev, LC3_FLOAT* rc_unq, LC3_FLO rc_unq[0] = -g; for (t = 1; t < len; t++) { - zero_float(buf_tmp, len + 1); sum = 0; for (i = 1; i <= t; i++) { @@ -91,33 +77,33 @@ void levinsonDurbin(LC3_FLOAT* r, LC3_FLOAT* out_lev, LC3_FLOAT* rc_unq, LC3_FLO void levdown(LC3_FLOAT* anxt, LC3_FLOAT* out_a, LC3_INT* len) { - LC3_INT i = 0, j = 0; - LC3_FLOAT tmp_buf[8] = {0}, tmp_buf1[8] = {0}, tmp_buf2[8] = {0}, knxt = 0; + LC3_INT32 i, j; + LC3_FLOAT tmp_buf[8], knxt; + LC3_FLOAT norm; + memset(tmp_buf, 0, 8 * sizeof(LC3_FLOAT)); /* Initial length = 9 */ /* Drop the leading 1 */ - move_float(&tmp_buf[0], &anxt[1], (*len - 1)); - *len = *len - 1; /* Lenght = 8 */ /* Last coefficient */ - knxt = tmp_buf[*len - 1]; /* At [7] */ + knxt = anxt[*len]; /* At [7] */ *len = *len - 1; /* Lenght = 7 */ - move_float(tmp_buf1, tmp_buf, *len); - j = 0; for (i = *len - 1; i >= 0; i--) { - tmp_buf2[j] = knxt * tmp_buf[i]; + tmp_buf[j] = knxt * anxt[i + 1]; j++; } + + norm = 1.0 / (1.0 - (LC3_FABS(knxt)) * (LC3_FABS(knxt))); out_a[0] = 1; for (i = 0; i < *len; i++) { - out_a[i + 1] = (tmp_buf1[i] - tmp_buf2[i]) / (1.0 - (LC3_FABS(knxt)) * (LC3_FABS(knxt))); + out_a[i + 1] = (anxt[i + 1] - tmp_buf[i]) * norm; } *len = *len + 1; /* Length = 8 */ @@ -125,8 +111,8 @@ void levdown(LC3_FLOAT* anxt, LC3_FLOAT* out_a, LC3_INT* len) void poly2rc(LC3_FLOAT* a, LC3_FLOAT* out, LC3_INT len) { - LC3_INT k = 0, i = 0, len_old = 0; - LC3_FLOAT buf[9] = {0}; + LC3_INT k, i, len_old; + LC3_FLOAT buf[9]; len_old = len; @@ -155,30 +141,21 @@ void poly2rc(LC3_FLOAT* a, LC3_FLOAT* out, LC3_INT len) } } -LC3_INT findRC_idx(const LC3_FLOAT* in1, const LC3_FLOAT* in2, LC3_FLOAT checkValue) -{ - LC3_INT i = 0, ret = 0; - - for (i = 0; i < 17; i++) { - if (checkValue <= in1[i] && checkValue > in2[i]) { - ret = i; - } - } - - return ret; -} void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits, LC3_INT* order_out, LC3_INT* rc_idx, LC3_INT* tns_numfilters, LC3_INT* bits_out , LC3_INT16 near_nyquist_flag ) { - LC3_INT i = 0, stopfreq[2] = {0}, startfreq[2] = {0}, f = 0, numfilters = 0, maxOrder = 0, bits = 0, sub = 0, - subdiv_startfreq = 0, subdiv_stopfreq = 0, j = 0, rc_idx_tmp[8] = {0}, order_tmp[8] = {0}, tmp = 0, tns = 0; - LC3_FLOAT minPGfac = 0, minPredictionGain = 0, maxPG = 0, xcorr_out[MAX_LEN] = {0}, buf_tmp[MAX_LEN] = {0}, sum = 0, - subdiv_len = 0, nSubdivisions = 0, r[9] = {0}, out_lev[9] = {0}, rc_unq[9] = {0}, error_lev = 0, predGain = 0, - alpha = 0, rc[8] = {0}, st[9] = {0}, s = 0, tmpSave = 0, tmp_fl = 0; + LC3_INT i, stopfreq[2], startfreq[2], f, numfilters, maxOrder, bits, sub, + subdiv_startfreq, subdiv_stopfreq, j, rc_idx_tmp[MAXLAG], order_tmp, tmp, tns; + LC3_FLOAT minPGfac, minPredictionGain, maxPG, xcorr_out[MAXLAG + 1], sum, + subdiv_len, nSubdivisions, r[MAXLAG + 1], rc_unq[MAXLAG + 1], error_lev, predGain, + alpha, rc[MAXLAG], st[MAXLAG + 1] = {0}, s, tmpSave, tmp_fl; const LC3_INT* order; + LC3_FLOAT inv_sum, x_val; + LC3_FLOAT alpha_loc; + LC3_INT32 iIndex; /* Init */ @@ -188,8 +165,10 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L numfilters = 1; } - if (N > 40 * ((LC3_FLOAT) (frame_dms) / 10.0)) { - N = 40 * ((LC3_FLOAT) (frame_dms) / 10.0); + /* 40 * frame_dms / 10 = 4 * frame_dms */ + if (N > 4 * frame_dms) + { + N = 4 * frame_dms; fs = 40000; } @@ -213,21 +192,21 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L maxOrder = 4; nSubdivisions = 2.0; break; +#ifdef CR8_G_ADD_75MS + case 75: + maxOrder = 8; + nSubdivisions = 3; + break; +#endif case 100: maxOrder = 8; nSubdivisions = 3.0; break; } - minPGfac = 0.85; - maxPG = 2; minPredictionGain = 1.5; - if ((frame_dms >= 50 && nBits >= 48 * ((LC3_FLOAT) frame_dms / 10.0)) || frame_dms == 25) { - maxPG = minPredictionGain; - } - - if ((frame_dms >= 50 && nBits >= 48 * ((LC3_FLOAT) frame_dms / 10.0)) || frame_dms == 25) { + if (nBits >= 4.8 * frame_dms) { order = order1_tns; } else { order = order2_tns; @@ -249,32 +228,53 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L for (f = 0; f < numfilters; f++) { subdiv_len = ((LC3_FLOAT)stopfreq[f] + 1.0 - (LC3_FLOAT)startfreq[f]) / nSubdivisions; - zero_float(r, 9); + zero_float(r, MAXLAG+1); for (sub = 1; sub <= nSubdivisions; sub++) { subdiv_startfreq = floor(subdiv_len * (sub - 1)) + startfreq[f] - 1; subdiv_stopfreq = floor(subdiv_len * sub) + startfreq[f] - 1; + +#ifdef CR8_G_ADD_75MS + if (fs == 32000 && frame_dms == 75) + { + if (subdiv_startfreq == 83) + { + subdiv_startfreq = 82; + } + + if (subdiv_stopfreq == 83) + { + subdiv_stopfreq = 82; + } + + if (subdiv_startfreq == 160) + { + subdiv_startfreq = 159; + } + + if (subdiv_stopfreq == 160) + { + subdiv_stopfreq = 159; + } + } +#endif sum = 0; for (i = subdiv_startfreq; i < subdiv_stopfreq; i++) { sum += x[i] * x[i]; } - if (sum < LC3_EPS) - { - zero_float(r, 9); + if (sum < LC3_EPS) { + zero_float(r, MAXLAG+1); r[0] = 1; break; } - move_float(buf_tmp, &x[subdiv_startfreq], subdiv_stopfreq - subdiv_startfreq); - - xcorr(buf_tmp, xcorr_out, maxOrder, subdiv_stopfreq - subdiv_startfreq); + xcorr(&x[subdiv_startfreq], xcorr_out, maxOrder, subdiv_stopfreq - subdiv_startfreq); - j = 0; - for (i = maxOrder; i >= 0; i--) { - r[j] = r[j] + xcorr_out[i] / sum; - j++; + inv_sum = 1.0 / sum; + for (i = 0; i <= maxOrder; i++) { + r[i] = r[i] + xcorr_out[i] * inv_sum; } } @@ -282,7 +282,7 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L r[i] = r[i] * lagw_tns[i]; } - levinsonDurbin(r, out_lev, rc_unq, &error_lev, maxOrder); + levinsonDurbin(r, xcorr_out, rc_unq, &error_lev, maxOrder); predGain = r[0] / error_lev; @@ -295,34 +295,50 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L bits++; if (tns == 1) { + minPGfac = 0.85; + maxPG = 2; + if (nBits >= 4.8 * frame_dms) { + maxPG = minPredictionGain; + } + /* LPC weighting */ if (predGain < maxPG) { alpha = (maxPG - predGain) * (minPGfac - 1.0) / (maxPG - minPredictionGain) + 1.0; + alpha_loc = 1; for (i = 0; i <= maxOrder; i++) { - out_lev[i] = out_lev[i] * LC3_POW(alpha, i); + xcorr_out[i] = xcorr_out[i] * alpha_loc; + alpha_loc *= alpha; } - poly2rc(out_lev, rc_unq, maxOrder + 1); + poly2rc(xcorr_out, rc_unq, maxOrder + 1); } /* PARCOR Quantization */ - for (i = 0; i < maxOrder; i++) { - rc_idx_tmp[i] = findRC_idx(&quants_thr_tns[1], &quants_thr_tns[0], rc_unq[i]); + for (i = 0; i < maxOrder; i++) + { + iIndex = 1; + x_val = rc_unq[i]; + + while ((iIndex < 17) && (x_val > quants_thr_tns[iIndex - 1])) + { + iIndex = (iIndex + 1); + } + rc_idx_tmp[i] = (iIndex - 2); } /* Filter Order */ - j = 0; + order_tmp = 0; for (i = 0; i < maxOrder; i++) { rc[i] = quants_pts_tns[rc_idx_tmp[i]]; if (rc[i] != 0) { - order_tmp[j] = i + 1; - j++; + order_tmp = i + 1; } } - order_out[f] = order_tmp[j - 1]; + order_out[f] = order_tmp; + // Disable TNS if order is 0: if (order_out[f] == 0) { tns = 0; @@ -344,6 +360,9 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L rc_idx[i] = rc_idx_tmp[j]; j++; } + } else { +tns_disabled: + order_out[f] = 0; } /* Filtering */ @@ -367,7 +386,6 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L } } } -tns_disabled: *tns_numfilters = numfilters; *bits_out = bits; diff --git a/lib_lc3plus/tns_decoder.c b/lib_lc3plus/tns_decoder.c index d3aeefc3a379a224273e7cc7b7be1eee545af774..f4dff52f396f21d5ec260d04fafa062aa4d6cb1b 100644 --- a/lib_lc3plus/tns_decoder.c +++ b/lib_lc3plus/tns_decoder.c @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -13,8 +13,9 @@ void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs) { - LC3_INT startfreq[2] = {0}, stopfreq[2] = {0}, f = 0, i = 0, j = 0, m = 0, l = 0, rc_idx_f[9] = {0}; - LC3_FLOAT rc[9] = {0}, s = 0, st[9] = {0}; + LC3_INT startfreq[2], stopfreq[2], f, i, j, m, l; + LC3_FLOAT rc[9], s, st[9] = {0}; + LC3_INT order_tmp; if (numfilters == 2) { startfreq[0] = floor(600 * N * 2 / fs) + 1; @@ -27,19 +28,20 @@ void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT } for (f = 0; f < numfilters; f++) { - if (order[f] > 0) { + order_tmp = order[f]; + + if (order_tmp > 0) { j = 0; - for (i = f * 8; i < f * 8 + 8; i++) { - rc_idx_f[j] = rc_idx[i]; - rc[j] = quants_pts_tns[rc_idx_f[j]]; + for (i = f * 8; i < f * 8 + order_tmp; i++) { + rc[j] = quants_pts_tns[rc_idx[i]]; j++; } for (m = startfreq[f]; m <= stopfreq[f]; m++) { - s = x[m - 1] - rc[order[f] - 1] * st[order[f] - 1]; + s = x[m - 1] - rc[order_tmp - 1] * st[order_tmp - 1]; - for (l = order[f] - 2; l >= 0; l--) { + for (l = order_tmp - 2; l >= 0; l--) { s = s - rc[l] * st[l]; st[l + 1] = rc[l] * s + st[l]; } diff --git a/lib_lc3plus/util.h b/lib_lc3plus/util.h index 7ef6dedef7600c79a45549dabb1c4cf4d2d37f7f..adf422cff6b354906980aa1c271814cf25fa36bf 100644 --- a/lib_lc3plus/util.h +++ b/lib_lc3plus/util.h @@ -1,5 +1,5 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * +* ETSI TS 103 634 V1.4.3 * * Low Complexity Communication Codec Plus (LC3plus) * * * * Copyright licence is solely granted through ETSI Intellectual Property * @@ -11,6 +11,7 @@ #ifndef UTIL_H #define UTIL_H +#include "options.h" #include "clib.h" #include "math.h" @@ -51,18 +52,50 @@ static inline LC3_FLOAT sqrf(LC3_FLOAT x) { return x * x; } /* convenience wrappers around memmove */ static inline void move_float(LC3_FLOAT *dst, const LC3_FLOAT *src, LC3_INT len) { +#ifdef WMOPS + LC3_INT i; + for (i = 0; i < len; i++) + { + dst[i] = src[i]; + } +#else memmove(dst, src, len * sizeof(LC3_FLOAT)); +#endif } static inline void move_int(LC3_INT *dst, const LC3_INT *src, LC3_INT len) { +#ifdef WMOPS + LC3_INT i; + for (i = 0; i < len; i++) + { + dst[i] = src[i]; + } +#else memmove(dst, src, len * sizeof(LC3_INT)); +#endif } /* convenience wrappers around memset */ static inline void zero_float(LC3_FLOAT *x, LC3_INT len) { +#ifdef WMOPS + LC3_INT i; + for (i = 0; i < len; i++) + { + x[i] = 0; + } +#else memset(x, 0, len * sizeof(LC3_FLOAT)); +#endif } static inline void zero_int(LC3_INT *x, LC3_INT len) { +#ifdef WMOPS + LC3_INT i; + for (i = 0; i < len; i++) + { + x[i] = 0; + } +#else memset(x, 0, len * sizeof(LC3_INT)); +#endif } /* multiply float vectors element by element, in-place */