From 008229729cafec3db8b6287a25dbd75d512ad3b9 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Mon, 11 Aug 2025 14:51:39 -0400 Subject: [PATCH 01/28] Removing quality extension layer Keep QEXT just for 96 kHz input/output Signed-off-by: Jean-Marc Valin --- celt/bands.c | 231 ++++----------------------- celt/bands.h | 4 +- celt/celt.h | 12 +- celt/celt_decoder.c | 130 ++------------- celt/celt_encoder.c | 225 +++----------------------- celt/cwrs.c | 2 +- celt/modes.c | 52 ------ celt/modes.h | 8 - celt/opus_custom_demo.c | 21 --- celt/rate.c | 231 --------------------------- celt/rate.h | 3 - celt/static_modes_fixed.h | 62 ------- celt/static_modes_float.h | 62 ------- celt/vq.c | 275 +------------------------------- celt/vq.h | 6 +- include/opus_defines.h | 12 +- src/opus_decoder.c | 31 +--- src/opus_demo.c | 15 -- src/opus_encoder.c | 37 ----- src/opus_multistream_encoder.c | 6 - tests/opus_encode_regressions.c | 4 - tests/test_opus_custom.c | 3 - tests/test_opus_encode.c | 25 +-- 23 files changed, 86 insertions(+), 1371 deletions(-) diff --git a/celt/bands.c b/celt/bands.c index afde197ef..0b6190089 100644 --- a/celt/bands.c +++ b/celt/bands.c @@ -677,12 +677,6 @@ struct band_ctx { int theta_round; int disable_inv; int avoid_split_noise; -#ifdef ENABLE_QEXT - ec_ctx *ext_ec; - int extra_bits; - opus_int32 ext_total_bits; - int extra_bands; -#endif }; struct split_ctx { @@ -691,16 +685,14 @@ struct split_ctx { int iside; int delta; int itheta; -#ifdef ENABLE_QEXT int itheta_q30; -#endif int qalloc; }; static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, celt_norm *X, celt_norm *Y, int N, int *b, int B, int B0, int LM, - int stereo, int *fill ARG_QEXT(int *ext_b)) + int stereo, int *fill) { int qn; int itheta=0; @@ -839,30 +831,7 @@ static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, } celt_assert(itheta>=0); itheta = celt_udiv((opus_int32)itheta*16384, qn); -#ifdef ENABLE_QEXT - *ext_b = IMIN(*ext_b, ctx->ext_total_bits - (opus_int32)ec_tell_frac(ctx->ext_ec)); - if (*ext_b >= 2*N<ext_total_bits-ec_tell_frac(ctx->ext_ec)-1 > 2<ext_ec); - extra_bits = IMIN(12, IMAX(2, celt_sudiv(*ext_b, (2*N-1)<>30; - itheta_q30 += (1<<(extra_bits-1))-1; - itheta_q30 = IMAX(0, IMIN((1<ext_ec, itheta_q30, (1<ext_ec, (1<ext_ec) - ext_tell; - } else { - itheta_q30 = (opus_int32)itheta<<16; - } -#endif + itheta_q30 = (opus_int32)itheta<<16; if (encode && stereo) { if (itheta==0) @@ -926,9 +895,7 @@ static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, sctx->iside = iside; sctx->delta = delta; sctx->itheta = itheta; -#ifdef ENABLE_QEXT sctx->itheta_q30 = itheta_q30; -#endif sctx->qalloc = qalloc; } static unsigned quant_band_n1(struct band_ctx *ctx, celt_norm *X, celt_norm *Y, @@ -973,8 +940,7 @@ static unsigned quant_band_n1(struct band_ctx *ctx, celt_norm *X, celt_norm *Y, static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X, int N, int b, int B, celt_norm *lowband, int LM, - opus_val32 gain, int fill - ARG_QEXT(int ext_b)) + opus_val32 gain, int fill) { const unsigned char *cache; int q; @@ -1014,32 +980,20 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X, fill = (fill&1)|(fill<<1); B = (B+1)>>1; - compute_theta(ctx, &sctx, X, Y, N, &b, B, B0, LM, 0, &fill ARG_QEXT(&ext_b)); + compute_theta(ctx, &sctx, X, Y, N, &b, B, B0, LM, 0, &fill); imid = sctx.imid; iside = sctx.iside; delta = sctx.delta; itheta = sctx.itheta; qalloc = sctx.qalloc; -#ifdef FIXED_POINT -# ifdef ENABLE_QEXT (void)imid; (void)iside; +#ifdef FIXED_POINT mid = celt_cos_norm32(sctx.itheta_q30); side = celt_cos_norm32((1<<30)-sctx.itheta_q30); -# else - mid = SHL32(EXTEND32(imid), 16); - side = SHL32(EXTEND32(iside), 16); -# endif #else -# ifdef ENABLE_QEXT - (void)imid; - (void)iside; mid = celt_cos_norm2(sctx.itheta_q30*(1.f/(1<<30))); side = celt_cos_norm2(1.f-sctx.itheta_q30*(1.f/(1<<30))); -# else - mid = (1.f/32768)*imid; - side = (1.f/32768)*iside; -# endif #endif /* Give more bits to low-energy MDCTs than they would otherwise deserve */ @@ -1063,33 +1017,22 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X, if (mbits >= sbits) { cm = quant_partition(ctx, X, N, mbits, B, lowband, LM, - MULT32_32_Q31(gain,mid), fill ARG_QEXT(ext_b/2)); + MULT32_32_Q31(gain,mid), fill); rebalance = mbits - (rebalance-ctx->remaining_bits); if (rebalance > 3<>B ARG_QEXT(ext_b/2))<<(B0>>1); + MULT32_32_Q31(gain,side), fill>>B)<<(B0>>1); } else { cm = quant_partition(ctx, Y, N, sbits, B, next_lowband2, LM, - MULT32_32_Q31(gain,side), fill>>B ARG_QEXT(ext_b/2))<<(B0>>1); + MULT32_32_Q31(gain,side), fill>>B)<<(B0>>1); rebalance = sbits - (rebalance-ctx->remaining_bits); if (rebalance > 3<>BITRES; - ext_remaining_bits = ctx->ext_total_bits-(opus_int32)ec_tell_frac(ctx->ext_ec); - if (ext_remaining_bits < ((extra_bits+1)*(N-1)+N)<>BITRES; - extra_bits = IMAX(extra_bits-1, 0); - } - extra_bits = IMIN(12, extra_bits); -#endif /* This is the basic no-split case */ q = bits2pulses(m, i, LM, b); curr_bits = pulses2bits(m, i, LM, q); @@ -1111,26 +1054,11 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X, /* Finally do the actual quantization */ if (encode) { - cm = alg_quant(X, N, K, spread, B, ec, gain, ctx->resynth - ARG_QEXT(ctx->ext_ec) ARG_QEXT(extra_bits), + cm = alg_quant(X, N, K, spread, B, ec, gain, ctx->resynth, ctx->arch); } else { - cm = alg_unquant(X, N, K, spread, B, ec, gain - ARG_QEXT(ctx->ext_ec) ARG_QEXT(extra_bits)); - } -#ifdef ENABLE_QEXT - } else if (ext_b > 2*N<>BITRES; - ext_remaining_bits = ctx->ext_total_bits-ec_tell_frac(ctx->ext_ec); - if (ext_remaining_bits < ((extra_bits+1)*(N-1)+N)<>BITRES; - extra_bits = IMAX(extra_bits-1, 0); + cm = alg_unquant(X, N, K, spread, B, ec, gain); } - extra_bits = IMIN(14, extra_bits); - if (encode) cm = cubic_quant(X, N, extra_bits, B, ctx->ext_ec, gain, ctx->resynth); - else cm = cubic_unquant(X, N, extra_bits, B, ctx->ext_ec, gain); -#endif } else { /* If there's no pulse, fill the band anyway */ int j; @@ -1176,8 +1104,7 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X, return cm; } -#ifdef ENABLE_QEXT -static unsigned cubic_quant_partition(struct band_ctx *ctx, celt_norm *X, int N, int b, int B, ec_ctx *ec, int LM, opus_val32 gain, int resynth, int encode) +unsigned cubic_quant_partition(struct band_ctx *ctx, celt_norm *X, int N, int b, int B, ec_ctx *ec, int LM, opus_val32 gain, int resynth, int encode) { celt_assert(LM>=0); ctx->remaining_bits = ctx->ec->storage*8*8 - ec_tell_frac(ctx->ec); @@ -1242,14 +1169,12 @@ static unsigned cubic_quant_partition(struct band_ctx *ctx, celt_norm *X, int N, return cm; } } -#endif /* This function is responsible for encoding and decoding a band for the mono case. */ static unsigned quant_band(struct band_ctx *ctx, celt_norm *X, int N, int b, int B, celt_norm *lowband, int LM, celt_norm *lowband_out, - opus_val32 gain, celt_norm *lowband_scratch, int fill - ARG_QEXT(int ext_b)) + opus_val32 gain, celt_norm *lowband_scratch, int fill) { int N0=N; int N_B=N; @@ -1325,14 +1250,7 @@ static unsigned quant_band(struct band_ctx *ctx, celt_norm *X, deinterleave_hadamard(lowband, N_B>>recombine, B0<extra_bands && b > (3*N<m->logN[ctx->i]+8+8*LM)) { - cm = cubic_quant_partition(ctx, X, N, b, B, ctx->ec, LM, gain, ctx->resynth, encode); - } else -#endif - { - cm = quant_partition(ctx, X, N, b, B, lowband, LM, gain, fill ARG_QEXT(ext_b)); - } + cm = quant_partition(ctx, X, N, b, B, lowband, LM, gain, fill); /* This code is used by the decoder and by the resynthesis-enabled encoder */ if (ctx->resynth) @@ -1387,8 +1305,7 @@ static unsigned quant_band(struct band_ctx *ctx, celt_norm *X, static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm *Y, int N, int b, int B, celt_norm *lowband, int LM, celt_norm *lowband_out, - celt_norm *lowband_scratch, int fill - ARG_QEXT(int ext_b) ARG_QEXT(const int *cap)) + celt_norm *lowband_scratch, int fill) { int imid=0, iside=0; int inv = 0; @@ -1419,33 +1336,21 @@ static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm else OPUS_COPY(X, Y, N); } } - compute_theta(ctx, &sctx, X, Y, N, &b, B, B, LM, 1, &fill ARG_QEXT(&ext_b)); + compute_theta(ctx, &sctx, X, Y, N, &b, B, B, LM, 1, &fill); inv = sctx.inv; imid = sctx.imid; iside = sctx.iside; delta = sctx.delta; itheta = sctx.itheta; qalloc = sctx.qalloc; -#ifdef FIXED_POINT -# ifdef ENABLE_QEXT (void)imid; (void)iside; +#ifdef FIXED_POINT mid = celt_cos_norm32(sctx.itheta_q30); side = celt_cos_norm32((1<<30)-sctx.itheta_q30); -# else - mid = SHL32(EXTEND32(imid), 16); - side = SHL32(EXTEND32(iside), 16); -# endif #else -# ifdef ENABLE_QEXT - (void)imid; - (void)iside; mid = celt_cos_norm2(sctx.itheta_q30*(1.f/(1<<30))); side = celt_cos_norm2(1.f-sctx.itheta_q30*(1.f/(1<<30))); -# else - mid = (1.f/32768)*imid; - side = (1.f/32768)*iside; -# endif #endif /* This is a special case for N=2 that only works for stereo and takes @@ -1483,7 +1388,7 @@ static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm /* We use orig_fill here because we want to fold the side, but if itheta==16384, we'll have cleared the low bits of fill. */ cm = quant_band(ctx, x2, N, mbits, B, lowband, LM, lowband_out, Q31ONE, - lowband_scratch, orig_fill ARG_QEXT(ext_b)); + lowband_scratch, orig_fill); /* We don't split N=2 bands, so cm is either 1 or 0 (for a fold-collapse), and there's no need to worry about mixing with the other channel. */ y2[0] = -sign*x2[1]; @@ -1513,45 +1418,28 @@ static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm rebalance = ctx->remaining_bits; if (mbits >= sbits) { -#ifdef ENABLE_QEXT - int qext_extra = 0; - /* Reallocate any mid bits that cannot be used to extra mid bits. */ - if (cap != NULL && ext_b != 0) qext_extra = IMAX(0, IMIN(ext_b/2, mbits - cap[ctx->i]/2)); -#endif /* In stereo mode, we do not apply a scaling to the mid because we need the normalized mid for folding later. */ cm = quant_band(ctx, X, N, mbits, B, lowband, LM, lowband_out, Q31ONE, - lowband_scratch, fill ARG_QEXT(ext_b/2+qext_extra)); + lowband_scratch, fill); rebalance = mbits - (rebalance-ctx->remaining_bits); if (rebalance > 3<extra_bands) sbits = IMIN(sbits, ctx->remaining_bits); -#endif + /* For a stereo split, the high bits of fill are always zero, so no folding will be done to the side. */ - cm |= quant_band(ctx, Y, N, sbits, B, NULL, LM, NULL, side, NULL, fill>>B ARG_QEXT(ext_b/2-qext_extra)); + cm |= quant_band(ctx, Y, N, sbits, B, NULL, LM, NULL, side, NULL, fill>>B); } else { -#ifdef ENABLE_QEXT - int qext_extra = 0; - /* Reallocate any side bits that cannot be used to extra side bits. */ - if (cap != NULL && ext_b != 0) qext_extra = IMAX(0, IMIN(ext_b/2, sbits - cap[ctx->i]/2)); -#endif /* For a stereo split, the high bits of fill are always zero, so no folding will be done to the side. */ - cm = quant_band(ctx, Y, N, sbits, B, NULL, LM, NULL, side, NULL, fill>>B ARG_QEXT(ext_b/2+qext_extra)); + cm = quant_band(ctx, Y, N, sbits, B, NULL, LM, NULL, side, NULL, fill>>B); rebalance = sbits - (rebalance-ctx->remaining_bits); if (rebalance > 3<extra_bands) mbits = IMIN(mbits, ctx->remaining_bits); -#endif /* In stereo mode, we do not apply a scaling to the mid because we need the normalized mid for folding later. */ cm |= quant_band(ctx, X, N, mbits, B, lowband, LM, lowband_out, Q31ONE, - lowband_scratch, fill ARG_QEXT(ext_b/2-qext_extra)); + lowband_scratch, fill); } } @@ -1591,9 +1479,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, const celt_ener *bandE, int *pulses, int shortBlocks, int spread, int dual_stereo, int intensity, int *tf_res, opus_int32 total_bits, opus_int32 balance, ec_ctx *ec, int LM, int codedBands, - opus_uint32 *seed, int complexity, int arch, int disable_inv - ARG_QEXT(ec_ctx *ext_ec) ARG_QEXT(int *extra_pulses) - ARG_QEXT(opus_int32 ext_total_bits) ARG_QEXT(const int *cap)) + opus_uint32 *seed, int complexity, int arch, int disable_inv) { int i; opus_int32 remaining_bits; @@ -1622,12 +1508,6 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, int resynth = !encode || theta_rdo; #endif struct band_ctx ctx; -#ifdef ENABLE_QEXT - int ext_b; - opus_int32 ext_balance=0; - opus_int32 ext_tell=0; - VARDECL(unsigned char, ext_bytes_save); -#endif SAVE_STACK; M = 1<nbEBands], w); /* Make a copy. */ cm = x_cm|y_cm; ec_save = *ec; -#ifdef ENABLE_QEXT - ext_ec_save = *ext_ec; -#endif ctx_save = ctx; OPUS_COPY(X_save, X, N); OPUS_COPY(Y_save, Y, N); @@ -1833,15 +1682,12 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, ctx.theta_round = -1; x_cm = quant_band_stereo(&ctx, X, Y, N, b, B, effective_lowband != -1 ? norm+effective_lowband : NULL, LM, - last?NULL:norm+M*eBands[i]-norm_offset, lowband_scratch, cm ARG_QEXT(ext_b) ARG_QEXT(cap)); + last?NULL:norm+M*eBands[i]-norm_offset, lowband_scratch, cm); dist0 = MULT16_32_Q15(w[0], celt_inner_prod_norm_shift(X_save, X, N, arch)) + MULT16_32_Q15(w[1], celt_inner_prod_norm_shift(Y_save, Y, N, arch)); /* Save first result. */ cm2 = x_cm; ec_save2 = *ec; -#ifdef ENABLE_QEXT - ext_ec_save2 = *ext_ec; -#endif ctx_save2 = ctx; OPUS_COPY(X_save2, X, N); OPUS_COPY(Y_save2, Y, N); @@ -1852,18 +1698,9 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, bytes_buf = ec_save.buf+nstart_bytes; save_bytes = nend_bytes-nstart_bytes; OPUS_COPY(bytes_save, bytes_buf, save_bytes); -#ifdef ENABLE_QEXT - ext_nstart_bytes = ext_ec_save.offs; - ext_nend_bytes = ext_ec_save.storage; - ext_bytes_buf = ext_ec_save.buf!=NULL ? ext_ec_save.buf+ext_nstart_bytes : NULL; - ext_save_bytes = ext_nend_bytes-ext_nstart_bytes; - if (ext_save_bytes) OPUS_COPY(ext_bytes_save, ext_bytes_buf, ext_save_bytes); -#endif + /* Restore */ *ec = ec_save; -#ifdef ENABLE_QEXT - *ext_ec = ext_ec_save; -#endif ctx = ctx_save; OPUS_COPY(X, X_save, N); OPUS_COPY(Y, Y_save, N); @@ -1875,34 +1712,28 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, ctx.theta_round = 1; x_cm = quant_band_stereo(&ctx, X, Y, N, b, B, effective_lowband != -1 ? norm+effective_lowband : NULL, LM, - last?NULL:norm+M*eBands[i]-norm_offset, lowband_scratch, cm ARG_QEXT(ext_b) ARG_QEXT(cap)); + last?NULL:norm+M*eBands[i]-norm_offset, lowband_scratch, cm); dist1 = MULT16_32_Q15(w[0], celt_inner_prod_norm_shift(X_save, X, N, arch)) + MULT16_32_Q15(w[1], celt_inner_prod_norm_shift(Y_save, Y, N, arch)); if (dist0 >= dist1) { x_cm = cm2; *ec = ec_save2; -#ifdef ENABLE_QEXT - *ext_ec = ext_ec_save2; -#endif ctx = ctx_save2; OPUS_COPY(X, X_save2, N); OPUS_COPY(Y, Y_save2, N); if (!last) OPUS_COPY(norm+M*eBands[i]-norm_offset, norm_save2, N); OPUS_COPY(bytes_buf, bytes_save, save_bytes); -#ifdef ENABLE_QEXT - if (ext_save_bytes) OPUS_COPY(ext_bytes_buf, ext_bytes_save, ext_save_bytes); -#endif } } else { ctx.theta_round = 0; x_cm = quant_band_stereo(&ctx, X, Y, N, b, B, effective_lowband != -1 ? norm+effective_lowband : NULL, LM, - last?NULL:norm+M*eBands[i]-norm_offset, lowband_scratch, x_cm|y_cm ARG_QEXT(ext_b) ARG_QEXT(cap)); + last?NULL:norm+M*eBands[i]-norm_offset, lowband_scratch, x_cm|y_cm); } } else { x_cm = quant_band(&ctx, X, N, b, B, effective_lowband != -1 ? norm+effective_lowband : NULL, LM, - last?NULL:norm+M*eBands[i]-norm_offset, Q31ONE, lowband_scratch, x_cm|y_cm ARG_QEXT(ext_b)); + last?NULL:norm+M*eBands[i]-norm_offset, Q31ONE, lowband_scratch, x_cm|y_cm); } y_cm = x_cm; } diff --git a/celt/bands.h b/celt/bands.h index e7fee53f6..8d44bfb69 100644 --- a/celt/bands.h +++ b/celt/bands.h @@ -108,9 +108,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, const celt_ener *bandE, int *pulses, int shortBlocks, int spread, int dual_stereo, int intensity, int *tf_res, opus_int32 total_bits, opus_int32 balance, ec_ctx *ec, int M, int codedBands, opus_uint32 *seed, - int complexity, int arch, int disable_inv - ARG_QEXT(ec_ctx *ext_ec) ARG_QEXT(int *extra_pulses) - ARG_QEXT(opus_int32 total_ext_bits) ARG_QEXT(const int *cap)); + int complexity, int arch, int disable_inv); void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_masks, int LM, int C, int size, int start, diff --git a/celt/celt.h b/celt/celt.h index c33e11ed0..79721dbbf 100644 --- a/celt/celt.h +++ b/celt/celt.h @@ -43,13 +43,6 @@ #include "arch.h" #include "kiss_fft.h" -#ifdef ENABLE_QEXT -#define ARG_QEXT(arg) , arg -#else -#define ARG_QEXT(arg) -#endif - - #ifdef ENABLE_DEEP_PLC #include "lpcnet.h" #endif @@ -58,8 +51,6 @@ #define CELTDecoder OpusCustomDecoder #define CELTMode OpusCustomMode -#define QEXT_EXTENSION_ID 124 - #define LEAK_BANDS 19 typedef struct { @@ -175,7 +166,6 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char #ifdef ENABLE_DEEP_PLC ,LPCNetPLCState *lpcnet #endif - ARG_QEXT(const unsigned char *qext_payload) ARG_QEXT(int qext_payload_len) ); int celt_decode_with_ec(OpusCustomDecoder * OPUS_RESTRICT st, const unsigned char *data, @@ -260,7 +250,7 @@ void init_caps(const CELTMode *m,int *cap,int LM,int C); void deemphasis(celt_sig *in[], opus_res *pcm, int N, int C, int downsample, const opus_val16 *coef, celt_sig *mem, int accum); void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[], celt_glog *oldBandE, int start, int effEnd, int C, int CC, int isTransient, - int LM, int downsample, int silence, int arch ARG_QEXT(const CELTMode *qext_mode) ARG_QEXT(const celt_glog *qext_bandLogE) ARG_QEXT(int qext_end)); + int LM, int downsample, int silence, int arch); #endif #ifdef ENABLE_QEXT diff --git a/celt/celt_decoder.c b/celt/celt_decoder.c index aba91c12a..184b65921 100644 --- a/celt/celt_decoder.c +++ b/celt/celt_decoder.c @@ -126,10 +126,6 @@ struct OpusCustomDecoder { float plc_preemphasis_mem; #endif -#ifdef ENABLE_QEXT - celt_glog qext_oldBandE[2*NB_QEXT_BANDS]; -#endif - celt_sig _decode_mem[1]; /* Size = channels*(DECODE_BUFFER_SIZE+mode->overlap) */ /* celt_glog oldEBands[], Size = 2*mode->nbEBands */ /* celt_glog oldLogE[], Size = 2*mode->nbEBands */ @@ -413,7 +409,7 @@ static void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[], celt_glog *oldBandE, int start, int effEnd, int C, int CC, int isTransient, int LM, int downsample, - int silence, int arch ARG_QEXT(const CELTMode *qext_mode) ARG_QEXT(const celt_glog *qext_bandLogE) ARG_QEXT(int qext_end)) + int silence, int arch) { int c, i; int M; @@ -431,9 +427,6 @@ void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[], N = mode->shortMdctSize<Fs != 96000) qext_end=2; -#endif if (isTransient) { @@ -452,11 +445,6 @@ void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[], celt_sig *freq2; denormalise_bands(mode, X, freq, oldBandE, start, effEnd, M, downsample, silence); -#ifdef ENABLE_QEXT - if (qext_mode) - denormalise_bands(qext_mode, X, freq, qext_bandLogE, 0, qext_end, M, - downsample, silence); -#endif /* Store a temporary copy in the output buffer because the IMDCT destroys its input. */ freq2 = out_syn[1]+overlap/2; OPUS_COPY(freq2, freq, N); @@ -474,15 +462,6 @@ void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[], /* Use the output buffer as temp array before downmixing. */ denormalise_bands(mode, X+N, freq2, oldBandE+nbEBands, start, effEnd, M, downsample, silence); -#ifdef ENABLE_QEXT - if (qext_mode) - { - denormalise_bands(qext_mode, X, freq, qext_bandLogE, 0, qext_end, M, - downsample, silence); - denormalise_bands(qext_mode, X+N, freq2, qext_bandLogE+NB_QEXT_BANDS, 0, qext_end, M, - downsample, silence); - } -#endif for (i=0;imdct, &freq[b], out_syn[c]+NB*b, mode->window, overlap, shift, B, arch); } while (++crng = seed; - celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, C, C, 0, LM, st->downsample, 0, st->arch ARG_QEXT(NULL) ARG_QEXT(NULL) ARG_QEXT(0)); + celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, C, C, 0, LM, st->downsample, 0, st->arch); /* Run the postfilter with the last parameters. */ c=0; do { @@ -1089,20 +1063,11 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM RESTORE_STACK; } -#ifdef ENABLE_QEXT -static void decode_qext_stereo_params(ec_dec *ec, int qext_end, int *qext_intensity, int *qext_dual_stereo) { - *qext_intensity = ec_dec_uint(ec, qext_end+1); - if (*qext_intensity != 0) *qext_dual_stereo = ec_dec_bit_logp(ec, 1); - else *qext_dual_stereo = 0; -} -#endif - int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_res * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum #ifdef ENABLE_DEEP_PLC ,LPCNetPLCState *lpcnet #endif - ARG_QEXT(const unsigned char *qext_payload) ARG_QEXT(int qext_payload_len) ) { int c, i, N; @@ -1151,19 +1116,7 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char celt_glog max_background_increase; int decode_buffer_size; #ifdef ENABLE_QEXT - opus_int32 qext_bits; - ec_dec ext_dec; - int qext_bytes=0; - int qext_end=0; - int qext_intensity=0; - int qext_dual_stereo=0; - VARDECL(int, extra_quant); - VARDECL(int, extra_pulses); - const CELTMode *qext_mode = NULL; - CELTMode qext_mode_struct; int qext_scale; -#else -# define qext_bytes 0 #endif ALLOC_STACK; #ifdef ENABLE_QEXT @@ -1185,14 +1138,6 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char oldLogE2 = oldLogE + 2*nbEBands; backgroundLogE = oldLogE2 + 2*nbEBands; -#ifdef ENABLE_QEXT - if (qext_payload) { - ec_dec_init(&ext_dec, (unsigned char*)qext_payload, qext_payload_len); - qext_bytes = qext_payload_len; - } else { - ec_dec_init(&ext_dec, NULL, 0); - } -#endif #if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) if (st->signalling && data!=NULL) { @@ -1231,12 +1176,6 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char } while (p==255); padding--; if (len <= 0 || padding<0) return OPUS_INVALID_PACKET; -#ifdef ENABLE_QEXT - qext_bytes = padding; - if (data[len] != QEXT_EXTENSION_ID<<1) - qext_bytes=0; - ec_dec_init(&ext_dec, (unsigned char*)data+len+1, qext_bytes); -#endif } } else { @@ -1454,31 +1393,6 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char unquant_fine_energy(mode, start, end, oldBandE, NULL, fine_quant, dec, C); - ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ - -#ifdef ENABLE_QEXT - if (qext_bytes && end == nbEBands && - ((mode->Fs == 48000 && (mode->shortMdctSize==120 || mode->shortMdctSize==90)) - || (mode->Fs == 96000 && (mode->shortMdctSize==240 || mode->shortMdctSize==180)))) { - int qext_intra_ener; - compute_qext_mode(&qext_mode_struct, mode); - qext_mode = &qext_mode_struct; - qext_end = ec_dec_bit_logp(&ext_dec, 1) ? NB_QEXT_BANDS : 2; - if (C==2) decode_qext_stereo_params(&ext_dec, qext_end, &qext_intensity, &qext_dual_stereo); - qext_intra_ener = ec_tell(&ext_dec)+3<=qext_bytes*8 ? ec_dec_bit_logp(&ext_dec, 3) : 0; - unquant_coarse_energy(qext_mode, 0, qext_end, st->qext_oldBandE, - qext_intra_ener, &ext_dec, C, LM); - } - ALLOC(extra_quant, nbEBands+NB_QEXT_BANDS, int); - ALLOC(extra_pulses, nbEBands+NB_QEXT_BANDS, int); - qext_bits = ((opus_int32)qext_bytes*8< 0) { - unquant_fine_energy(mode, start, end, oldBandE, fine_quant, extra_quant, &ext_dec, C); - } -#endif - c=0; do { OPUS_MOVE(decode_mem[c], decode_mem[c]+N, decode_buffer_size-N+overlap); } while (++crng, 0, - st->arch, st->disable_inv - ARG_QEXT(&ext_dec) ARG_QEXT(extra_pulses) - ARG_QEXT(qext_bytes*(8<qext_oldBandE, NULL, &extra_quant[nbEBands], &ext_dec, C); - quant_all_bands(0, qext_mode, 0, qext_end, X, C==2 ? X+N : NULL, qext_collapse_masks, - NULL, &extra_pulses[nbEBands], shortBlocks, spread_decision, qext_dual_stereo, qext_intensity, zeros, - qext_bytes*(8<rng, 0, - st->arch, st->disable_inv, &dummy_dec, zeros, 0, NULL); - } -#endif + st->arch, st->disable_inv); if (anti_collapse_rsv > 0) { anti_collapse_on = ec_dec_bits(dec, 1); } - unquant_energy_finalise(mode, start, end, (qext_bytes > 0) ? NULL : oldBandE, + + unquant_energy_finalise(mode, start, end, oldBandE, fine_quant, fine_priority, len*8-ec_tell(dec), dec, C); + if (anti_collapse_on) anti_collapse(mode, X, collapse_masks, LM, C, N, start, end, oldBandE, oldLogE, oldLogE2, pulses, st->rng, 0, st->arch); @@ -1532,7 +1428,7 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char prefilter_and_fold(st, N); } celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, - C, CC, isTransient, LM, st->downsample, silence, st->arch ARG_QEXT(qext_mode) ARG_QEXT(st->qext_oldBandE) ARG_QEXT(qext_end)); + C, CC, isTransient, LM, st->downsample, silence, st->arch); c=0; do { st->postfilter_period=IMAX(st->postfilter_period, COMBFILTER_MINPERIOD); @@ -1591,9 +1487,6 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char } } while (++c<2); st->rng = dec->rng; -#ifdef ENABLE_QEXT - if (qext_bytes) st->rng = st->rng ^ ext_dec.rng; -#endif deemphasis(out_syn, pcm, N, CC, st->downsample, mode->preemph, st->preemph_memD, accum); st->loss_duration = 0; @@ -1603,10 +1496,6 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char RESTORE_STACK; if (ec_tell(dec) > 8*len) return OPUS_INTERNAL_ERROR; -#ifdef ENABLE_QEXT - if (qext_bytes != 0 && ec_tell(&ext_dec) > 8*qext_bytes) - return OPUS_INTERNAL_ERROR; -#endif if(ec_get_error(dec)) st->error = 1; return frame_size/st->downsample; @@ -1619,7 +1508,6 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat #ifdef ENABLE_DEEP_PLC , NULL #endif - ARG_QEXT(NULL) ARG_QEXT(0) ); } diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c index ab97ed677..248e977e9 100644 --- a/celt/celt_encoder.c +++ b/celt/celt_encoder.c @@ -82,7 +82,6 @@ struct OpusCustomEncoder { int disable_inv; int arch; #ifdef ENABLE_QEXT - int enable_qext; int qext_scale; #endif @@ -153,11 +152,9 @@ int celt_encoder_get_size(int channels) OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_get_size(const CELTMode *mode, int channels) { - int extra=0; int size; #ifdef ENABLE_QEXT int qext_scale; - extra = channels*NB_QEXT_BANDS*sizeof(celt_glog); if (mode->Fs == 96000 && (mode->shortMdctSize==240 || mode->shortMdctSize==180)) { qext_scale = 2; } else qext_scale = 1; @@ -165,11 +162,10 @@ OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_get_size(const CELTMode *mode, int size = sizeof(struct CELTEncoder) + (channels*mode->overlap-1)*sizeof(celt_sig) /* celt_sig in_mem[channels*mode->overlap]; */ + channels*QEXT_SCALE(COMBFILTER_MAXPERIOD)*sizeof(celt_sig) /* celt_sig prefilter_mem[channels*COMBFILTER_MAXPERIOD]; */ - + 4*channels*mode->nbEBands*sizeof(celt_glog) /* celt_glog oldBandE[channels*mode->nbEBands]; */ + + 4*channels*mode->nbEBands*sizeof(celt_glog); /* celt_glog oldBandE[channels*mode->nbEBands]; */ /* celt_glog oldLogE[channels*mode->nbEBands]; */ /* celt_glog oldLogE2[channels*mode->nbEBands]; */ /* celt_glog energyError[channels*mode->nbEBands]; */ - + extra; return size; } @@ -1050,8 +1046,7 @@ static celt_glog dynalloc_analysis(const celt_glog *bandLogE, const celt_glog *b int nbEBands, int start, int end, int C, int *offsets, int lsb_depth, const opus_int16 *logN, int isTransient, int vbr, int constrained_vbr, const opus_int16 *eBands, int LM, int effectiveBytes, opus_int32 *tot_boost_, int lfe, celt_glog *surround_dynalloc, - AnalysisInfo *analysis, int *importance, int *spread_weight, opus_val16 tone_freq, opus_val32 toneishness - ARG_QEXT(int qext_scale)) + AnalysisInfo *analysis, int *importance, int *spread_weight, opus_val16 tone_freq, opus_val32 toneishness, int qext_scale) { int i, c; opus_int32 tot_boost=0; @@ -1060,6 +1055,11 @@ static celt_glog dynalloc_analysis(const celt_glog *bandLogE, const celt_glog *b VARDECL(celt_glog, noise_floor); VARDECL(celt_glog, bandLogE3); SAVE_STACK; + +#ifndef ENABLE_QEXT + (void)qext_scale; +#endif + ALLOC(follower, C*nbEBands, celt_glog); ALLOC(noise_floor, C*nbEBands, celt_glog); ALLOC(bandLogE3, nbEBands, celt_glog); @@ -1403,7 +1403,7 @@ static opus_val16 tone_detect(const celt_sig *in, int CC, int N, opus_val32 *ton static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, int CC, int N, int prefilter_tapset, int *pitch, opus_val16 *gain, int *qgain, int enabled, int complexity, opus_val16 tf_estimate, - int nbAvailableBytes, AnalysisInfo *analysis, opus_val16 tone_freq, opus_val32 toneishness ARG_QEXT(int qext_scale)) + int nbAvailableBytes, AnalysisInfo *analysis, opus_val16 tone_freq, opus_val32 toneishness, int qext_scale) { int c; VARDECL(celt_sig, _pre); @@ -1420,6 +1420,10 @@ static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, int cancel_pitch=0; SAVE_STACK; +#ifndef ENABLE_QEXT + (void)qext_scale; +#endif + max_period = QEXT_SCALE(COMBFILTER_MAXPERIOD); min_period = QEXT_SCALE(COMBFILTER_MINPERIOD); mode = st->mode; @@ -1606,7 +1610,7 @@ static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32 int constrained_vbr, opus_val16 stereo_saving, int tot_boost, opus_val16 tf_estimate, int pitch_change, celt_glog maxDepth, int lfe, int has_surround_mask, celt_glog surround_masking, - celt_glog temporal_vbr ARG_QEXT(int enable_qext)) + celt_glog temporal_vbr) { /* The target rate in 8th bits per frame */ opus_int32 target; @@ -1683,9 +1687,6 @@ static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32 opus_int32 floor_depth; int bins; bins = eBands[nbEBands-2]<shortMdctSize<>2); @@ -1715,13 +1716,6 @@ static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32 return target; } -#ifdef ENABLE_QEXT -static void encode_qext_stereo_params(ec_enc *ec, int qext_end, int qext_intensity, int qext_dual_stereo) { - ec_enc_uint(ec, qext_intensity, qext_end+1); - if (qext_intensity != 0) ec_enc_bit_logp(ec, qext_dual_stereo, 1); -} -#endif - int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc) { int i, c, N; @@ -1797,27 +1791,8 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in opus_val16 tone_freq=-1; opus_val32 toneishness=0; VARDECL(celt_glog, surround_dynalloc); - int qext_bytes=0; int packet_size_cap = 1275; -#ifdef ENABLE_QEXT - int qext_scale; - int qext_end=0; - int qext_intensity=0; - int qext_dual_stereo=0; - int padding_len_bytes=0; - unsigned char *ext_payload; - opus_int32 qext_bits; - ec_enc ext_enc; - VARDECL(int, extra_quant); - VARDECL(int, extra_pulses); - VARDECL(celt_glog, error_bak); - const CELTMode *qext_mode = NULL; - CELTMode qext_mode_struct; - celt_ener qext_bandE[2*NB_QEXT_BANDS]; - celt_glog qext_bandLogE[2*NB_QEXT_BANDS]; - celt_glog *qext_oldBandE=NULL; - celt_glog qext_error[2*NB_QEXT_BANDS]; -#endif + int qext_scale=1; ALLOC_STACK; mode = st->mode; @@ -1848,7 +1823,6 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in #ifdef ENABLE_QEXT qext_scale = st->qext_scale; - if (st->enable_qext) packet_size_cap = QEXT_PACKET_SIZE_CAP; #endif prefilter_mem = st->in_mem+CC*(overlap); @@ -1992,14 +1966,6 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in nbAvailableBytes=2; ec_enc_shrink(enc, nbCompressedBytes); } -#ifdef ENABLE_QEXT - else if (st->enable_qext) { - nbCompressedBytes = IMIN(nbCompressedBytes, 1275); - nbAvailableBytes = nbCompressedBytes - nbFilledBytes; - total_bits = nbCompressedBytes*8; - ec_enc_shrink(enc, nbCompressedBytes); - } -#endif /* Pretend we've filled all the remaining bits with zeros (that's what the initialiser did anyway) */ tell = nbCompressedBytes*8; @@ -2038,7 +2004,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in enabled = ((st->lfe&&nbAvailableBytes>3) || nbAvailableBytes>12*C) && !hybrid && !silence && tell+16<=total_bits && !st->disable_pf; prefilter_tapset = st->tapset_decision; - pf_on = run_prefilter(st, in, prefilter_mem, CC, N, prefilter_tapset, &pitch_index, &gain1, &qg, enabled, st->complexity, tf_estimate, nbAvailableBytes, &st->analysis, tone_freq, toneishness ARG_QEXT(qext_scale)); + pf_on = run_prefilter(st, in, prefilter_mem, CC, N, prefilter_tapset, &pitch_index, &gain1, &qg, enabled, st->complexity, tf_estimate, nbAvailableBytes, &st->analysis, tone_freq, toneishness, qext_scale); if ((gain1 > QCONST16(.4f,15) || st->prefilter_gain > QCONST16(.4f,15)) && (!st->analysis.valid || st->analysis.tonality > .3) && (pitch_index > 1.26*st->prefilter_period || pitch_index < .79*st->prefilter_period)) pitch_change = 1; @@ -2247,7 +2213,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in maxDepth = dynalloc_analysis(bandLogE, bandLogE2, oldBandE, nbEBands, start, end, C, offsets, st->lsb_depth, mode->logN, isTransient, st->vbr, st->constrained_vbr, - eBands, LM, effectiveBytes, &tot_boost, st->lfe, surround_dynalloc, &st->analysis, importance, spread_weight, tone_freq, toneishness ARG_QEXT(qext_scale)); + eBands, LM, effectiveBytes, &tot_boost, st->lfe, surround_dynalloc, &st->analysis, importance, spread_weight, tone_freq, toneishness, qext_scale); ALLOC(tf_res, nbEBands, int); /* Disable variable tf resolution for hybrid and at very low bitrate */ @@ -2459,7 +2425,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in st->lastCodedBands, C, st->intensity, st->constrained_vbr, st->stereo_saving, tot_boost, tf_estimate, pitch_change, maxDepth, st->lfe, st->energy_mask!=NULL, surround_masking, - temporal_vbr ARG_QEXT(st->enable_qext)); + temporal_vbr); } else { target = base_target; /* Tonal frames (offset<100) need more bits than noisy (offset>100) ones. */ @@ -2531,68 +2497,6 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in /* This moves the raw bits to take into account the new compressed size */ ec_enc_shrink(enc, nbCompressedBytes); } -#ifdef ENABLE_QEXT - if (st->enable_qext) { - int new_compressedBytes; - /* Don't give any bits for the first 80 kb/s per channel. Then 80% of the excess. */ - opus_int32 offset = bitrate_to_bits(C*80000, mode->Fs, frame_size)/8; - qext_bytes = IMAX(nbCompressedBytes-1275, IMAX(0, (nbCompressedBytes-offset)*4/5)); - if (qext_bytes > 20) { - opus_int32 target; - opus_val16 scale; - target = ((nbCompressedBytes-qext_bytes/3)*8<analysis, target, LM, equiv_rate, - st->lastCodedBands, C, st->intensity, st->constrained_vbr, - st->stereo_saving, tot_boost, tf_estimate2, pitch_change, maxDepth, - st->lfe, st->energy_mask!=NULL, surround_masking, - temporal_vbr ARG_QEXT(st->enable_qext)); - target += tell; - } - scale = PSHR32(toneishness,14); - scale = Q15ONE - MULT16_16_Q15(scale, scale); - qext_bytes += MULT16_32_Q15(scale, (nbCompressedBytes-(target/(8< 20) { - new_compressedBytes = nbCompressedBytes-qext_bytes-padding_len_bytes-1; - ec_enc_shrink(enc, new_compressedBytes); - if (compressed == NULL) { - compressed = enc->buf; - } - compressed[-1] |= 0x03; /* Code 3 packet */ - enc->buf += 1+padding_len_bytes; - OPUS_MOVE(compressed+1+padding_len_bytes, compressed, new_compressedBytes); - compressed[0] = 0x41; /* Set padding */ - for (i=0;iFs == 48000 || mode->Fs == 96000) && (mode->shortMdctSize==120*qext_scale || mode->shortMdctSize==90*qext_scale)) { - compute_qext_mode(&qext_mode_struct, mode); - qext_mode = &qext_mode_struct; - qext_end = (qext_scale == 2) ? NB_QEXT_BANDS : 2; - ec_enc_bit_logp(&ext_enc, qext_end == NB_QEXT_BANDS, 1); - } - } else { - ec_enc_init(&ext_enc, NULL, 0); - qext_bytes = 0; - } - } else { - ec_enc_init(&ext_enc, NULL, 0); - } -#endif /* Bit allocation */ ALLOC(fine_quant, nbEBands, int); @@ -2633,66 +2537,13 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in quant_fine_energy(mode, start, end, oldBandE, error, NULL, fine_quant, enc, C); OPUS_CLEAR(energyError, nbEBands*CC); -#ifdef ENABLE_QEXT - if (qext_mode) - { - /* Don't bias for intra. */ - opus_val32 qext_delayedIntra=0; - qext_oldBandE = energyError + CC*nbEBands; - compute_band_energies(qext_mode, freq, qext_bandE, qext_end, C, LM, st->arch); - normalise_bands(qext_mode, freq, X, qext_bandE, qext_end, C, M); - amp2Log2(qext_mode, qext_end, qext_end, qext_bandE, qext_bandLogE, C); - if (C==2) { - qext_intensity = qext_end; - qext_dual_stereo = dual_stereo; - encode_qext_stereo_params(&ext_enc, qext_end, qext_intensity, qext_dual_stereo); - } - quant_coarse_energy(qext_mode, 0, qext_end, qext_end, qext_bandLogE, - qext_oldBandE, qext_bytes*8, qext_error, &ext_enc, - C, LM, qext_bytes, st->force_intra, - &qext_delayedIntra, st->complexity >= 4, st->loss_rate, st->lfe); - } - ALLOC(extra_quant, nbEBands+NB_QEXT_BANDS, int); - ALLOC(extra_pulses, nbEBands+NB_QEXT_BANDS, int); - ALLOC(error_bak, C*nbEBands, celt_glog); - - qext_bits = ((opus_int32)qext_bytes*8< 0) { - quant_fine_energy(mode, start, end, oldBandE, error, fine_quant, extra_quant, &ext_enc, C); - } -#endif /* Residual quantisation */ ALLOC(collapse_masks, C*nbEBands, unsigned char); quant_all_bands(1, mode, start, end, X, C==2 ? X+N : NULL, collapse_masks, bandE, pulses, shortBlocks, st->spread_decision, dual_stereo, st->intensity, tf_res, nbCompressedBytes*(8<rng, st->complexity, st->arch, st->disable_inv - ARG_QEXT(&ext_enc) ARG_QEXT(extra_pulses) - ARG_QEXT(qext_bytes*(8<spread_decision, - qext_dual_stereo, qext_intensity, zeros, qext_bytes*(8<rng, st->complexity, st->arch, st->disable_inv, &dummy_enc, zeros, 0, NULL); - } -#endif + balance, enc, LM, codedBands, &st->rng, st->complexity, st->arch, st->disable_inv); if (anti_collapse_rsv > 0) { @@ -2702,8 +2553,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in #endif ec_enc_bits(enc, anti_collapse_on, 1); } - if (qext_bytes == 0) - quant_energy_finalise(mode, start, end, oldBandE, error, fine_quant, fine_priority, nbCompressedBytes*8-ec_tell(enc), enc, C); + quant_energy_finalise(mode, start, end, oldBandE, error, fine_quant, fine_priority, nbCompressedBytes*8-ec_tell(enc), enc, C); c=0; do { for (i=start;i 0) - quant_energy_finalise(mode, start, end, NULL, error_bak, fine_quant, fine_priority, nbCompressedBytes*8-ec_tell(enc), enc, C); -#endif + if (silence) { for (i=0;iupsample, silence, st->arch ARG_QEXT(qext_mode) ARG_QEXT(qext_oldBandE) ARG_QEXT(qext_end)); + C, CC, isTransient, LM, st->upsample, silence, st->arch); c=0; do { st->prefilter_period=IMAX(st->prefilter_period, COMBFILTER_MINPERIOD); @@ -2811,14 +2658,6 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in /* If there's any room left (can only happen for very high rates), it's already filled with zeros */ ec_enc_done(enc); -#ifdef ENABLE_QEXT - ec_enc_done(&ext_enc); - if (qext_bytes > 0) - nbCompressedBytes += padding_len_bytes+2+qext_bytes; - if (qext_bytes) st->rng = st->rng ^ ext_enc.rng; - if (ec_get_error(&ext_enc)) - return OPUS_INTERNAL_ERROR; -#endif #if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) if (st->signalling) nbCompressedBytes++; @@ -3049,28 +2888,6 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) *value = st->disable_inv; } break; -#ifdef ENABLE_QEXT - case OPUS_SET_QEXT_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>1) - { - goto bad_arg; - } - st->enable_qext = value; - } - break; - case OPUS_GET_QEXT_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->enable_qext; - } - break; -#endif case OPUS_RESET_STATE: { int i; diff --git a/celt/cwrs.c b/celt/cwrs.c index 8a280ce36..18fa554e5 100644 --- a/celt/cwrs.c +++ b/celt/cwrs.c @@ -36,7 +36,7 @@ #include "mathops.h" #include "arch.h" -#if defined(CUSTOM_MODES) || defined(ENABLE_QEXT) +#if defined(CUSTOM_MODES) #define CWRS_EXTRA_ROWS #endif diff --git a/celt/modes.c b/celt/modes.c index 1f4abcf6b..74d096b5d 100644 --- a/celt/modes.c +++ b/celt/modes.c @@ -410,15 +410,6 @@ CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) mode->logN = logN; compute_pulse_cache(mode, mode->maxLM); -#ifdef ENABLE_QEXT - OPUS_CLEAR(&mode->qext_cache, 1); - if ( (mode->Fs == 48000 && (mode->shortMdctSize==120 || mode->shortMdctSize==90)) || (mode->Fs == 96000 && (mode->shortMdctSize==240 || mode->shortMdctSize==180)) ) { - CELTMode dummy; - compute_qext_mode(&dummy, mode); - compute_pulse_cache(&dummy, dummy.maxLM); - OPUS_COPY(&mode->qext_cache, &dummy.cache, 1); - } -#endif if (clt_mdct_init(&mode->mdct, 2*mode->shortMdctSize*mode->nbShortMdcts, mode->maxLM, arch) == 0) @@ -457,11 +448,6 @@ void opus_custom_mode_destroy(CELTMode *mode) } #endif /* CUSTOM_MODES_ONLY */ #ifdef CUSTOM_MODES -#ifdef ENABLE_QEXT - if (mode->qext_cache.index) opus_free((opus_int16*)mode->qext_cache.index); - if (mode->qext_cache.bits) opus_free((unsigned char*)mode->qext_cache.bits); - if (mode->qext_cache.caps) opus_free((unsigned char*)mode->qext_cache.caps); -#endif opus_free((opus_int16*)mode->eBands); opus_free((unsigned char*)mode->allocVectors); @@ -480,41 +466,3 @@ void opus_custom_mode_destroy(CELTMode *mode) #endif } #endif - -#ifdef ENABLE_QEXT - -static const opus_int16 qext_eBands_180[] = { -/* 20k 22k 24k 26k 28k 30k 32k 34k 36k 38k 40k 42k 44k 47k 48k */ - 74, 82, 90, 98, 106, 114, 122, 130, 138, 146, 154, 162, 168, 174, 180 -}; - -static const opus_int16 qext_logN_180[] = {24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 21, 21, 21}; - -/* Extra bands. */ -static const opus_int16 qext_eBands_240[] = { -/* 20k 22k 24k 26k 28k 30k 32k 34k 36k 38k 40k 42k 44k 47k 48k */ - 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240 -}; - -static const opus_int16 qext_logN_240[] = {27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27}; - -void compute_qext_mode(CELTMode *qext, const CELTMode *m) -{ - OPUS_COPY(qext, m, 1); - if (m->shortMdctSize*48000 == 120*m->Fs) { - qext->eBands = qext_eBands_240; - qext->logN = qext_logN_240; - } else if (m->shortMdctSize*48000 == 90*m->Fs) { - qext->eBands = qext_eBands_180; - qext->logN = qext_logN_180; - } else { - celt_assert(0); - } - qext->nbEBands = qext->effEBands = NB_QEXT_BANDS; - while (qext->eBands[qext->effEBands] > qext->shortMdctSize) - qext->effEBands--; - qext->nbAllocVectors = 0; - qext->allocVectors = NULL; - OPUS_COPY(&qext->cache, &m->qext_cache, 1); -} -#endif diff --git a/celt/modes.h b/celt/modes.h index 06bfc65f1..c5f978061 100644 --- a/celt/modes.h +++ b/celt/modes.h @@ -71,15 +71,7 @@ struct OpusCustomMode { const celt_coef *window; mdct_lookup mdct; PulseCache cache; -#ifdef ENABLE_QEXT - PulseCache qext_cache; -#endif }; -#ifdef ENABLE_QEXT -#define QEXT_PACKET_SIZE_CAP 3825 -#define NB_QEXT_BANDS 14 -void compute_qext_mode(CELTMode *qext, const CELTMode *m); -#endif #endif diff --git a/celt/opus_custom_demo.c b/celt/opus_custom_demo.c index 44132813e..ca2269079 100644 --- a/celt/opus_custom_demo.c +++ b/celt/opus_custom_demo.c @@ -38,11 +38,7 @@ #include #include -#ifdef ENABLE_QEXT -#define MAX_PACKET QEXT_PACKET_SIZE_CAP -#else #define MAX_PACKET 1275 -#endif static OPUS_INLINE void _opus_ctl_failed(const char *file, int line) { @@ -68,9 +64,6 @@ static void print_usage(char **argv) { fprintf (stderr, " -f32 format is 32-bit float little-endian\n"); fprintf (stderr, " -complexity <0-10> optional only when encoding\n"); fprintf (stderr, " -loss encoding (robsutness setting) and decoding (simulating loss)\n"); -#ifdef ENABLE_QEXT - fprintf (stderr, " -qext use quality extension\n"); -#endif } static void int_to_char(opus_uint32 i, unsigned char ch[4]) @@ -125,9 +118,6 @@ int main(int argc, char *argv[]) int i; #if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) double rmsd = 0; -#endif -#ifdef ENABLE_QEXT - int qext = 0; #endif int count = 0; opus_int32 skip; @@ -219,11 +209,6 @@ int main(int argc, char *argv[]) } else if( strcmp( argv[ args ], "-f32" ) == 0 ) { format = FORMAT_F32_LE; args++; -#ifdef ENABLE_QEXT - } else if( strcmp( argv[ args ], "-qext" ) == 0 ) { - qext = 1; - args++; -#endif } else { printf( "Error: unrecognized setting: %s\n\n", argv[ args ] ); print_usage( argv ); @@ -253,12 +238,6 @@ int main(int argc, char *argv[]) goto failure; } } -#ifdef ENABLE_QEXT - if(opus_custom_encoder_ctl(enc, OPUS_SET_QEXT(qext)) != OPUS_OK) { - opus_ctl_failed(); - goto failure; - } -#endif } if (!encode_only) { dec = opus_custom_decoder_create(mode, channels, &err); diff --git a/celt/rate.c b/celt/rate.c index 9eed2e1ec..139006d19 100644 --- a/celt/rate.c +++ b/celt/rate.c @@ -38,7 +38,6 @@ #include "entcode.h" #include "rate.h" -#include "quant_bands.h" static const unsigned char LOG2_FRAC_TABLE[24]={ 0, @@ -644,233 +643,3 @@ int clt_compute_allocation(const CELTMode *m, int start, int end, const int *off RESTORE_STACK; return codedBands; } -#ifdef ENABLE_QEXT - -static const unsigned char last_zero[3] = {64, 50, 0}; -static const unsigned char last_cap[3] = {110, 60, 0}; -static const unsigned char last_other[4] = {120, 112, 70, 0}; - -static void ec_enc_depth(ec_enc *enc, opus_int32 depth, opus_int32 cap, opus_int32 *last) { - int sym = 3; - if (depth==*last) sym = 2; - if (depth==cap) sym = 1; - if (depth==0) sym = 0; - if (*last == 0) { - ec_enc_icdf(enc, IMIN(sym, 2), last_zero, 7); - } else if (*last == cap) { - ec_enc_icdf(enc, IMIN(sym, 2), last_cap, 7); - } else { - ec_enc_icdf(enc, sym, last_other, 7); - } - /* We accept some redundancy if depth==last (for last different from 0 and cap). */ - if (sym == 3) ec_enc_uint(enc, depth-1, cap); - *last = depth; -} - -static int ec_dec_depth(ec_dec *dec, opus_int32 cap, opus_int32 *last) { - int depth, sym; - if (*last == 0) { - sym = ec_dec_icdf(dec, last_zero, 7); - if (sym==2) sym=3; - } else if (*last == cap) { - sym = ec_dec_icdf(dec, last_cap, 7); - if (sym==2) sym=3; - } else { - sym = ec_dec_icdf(dec, last_other, 7); - } - if (sym==0) depth=0; - else if (sym==1) depth=cap; - else if (sym==2) depth=*last; - else depth = 1 + ec_dec_uint(dec, cap); - *last = depth; - return depth; -} - -#define MSWAP16(a,b) do {opus_val16 tmp = a;a=b;b=tmp;} while(0) -static opus_val16 median_of_5_val16(const opus_val16 *x) -{ - opus_val16 t0, t1, t2, t3, t4; - t2 = x[2]; - if (x[0] > x[1]) - { - t0 = x[1]; - t1 = x[0]; - } else { - t0 = x[0]; - t1 = x[1]; - } - if (x[3] > x[4]) - { - t3 = x[4]; - t4 = x[3]; - } else { - t3 = x[3]; - t4 = x[4]; - } - if (t0 > t3) - { - MSWAP16(t0, t3); - MSWAP16(t1, t4); - } - if (t2 > t1) - { - if (t1 < t3) - return MIN16(t2, t3); - else - return MIN16(t4, t1); - } else { - if (t2 < t3) - return MIN16(t1, t3); - else - return MIN16(t2, t4); - } -} - -void clt_compute_extra_allocation(const CELTMode *m, const CELTMode *qext_mode, int start, int end, int qext_end, const celt_glog *bandLogE, const celt_glog *qext_bandLogE, - opus_int32 total, int *extra_pulses, int *extra_equant, int C, int LM, ec_ctx *ec, int encode, opus_val16 tone_freq, opus_val32 toneishness) -{ - int i; - opus_int32 last=0; - opus_val32 sum; - opus_val32 fill; - int iter; - int tot_bands; - int tot_samples; - VARDECL(int, depth); - VARDECL(opus_int32, cap); -#ifdef FUZZING - float depth_std; -#endif - SAVE_STACK; -#ifdef FUZZING - depth_std = -10.f*log(1e-8+(float)rand()/(float)RAND_MAX); - depth_std = FMAX(0, FMIN(48, depth_std)); -#endif - if (qext_mode != NULL) { - celt_assert(end==m->nbEBands); - tot_bands = end + qext_end; - tot_samples = qext_mode->eBands[qext_end]*C<eBands[end]-m->eBands[start])*C<nbEBands+qext_end;i++) { - extra_pulses[i] = extra_equant[i] = 0; - } - RESTORE_STACK; - return; - } - ALLOC(depth, tot_bands, int); - if (encode) { - VARDECL(opus_val16, flatE); - VARDECL(int, Ncoef); - VARDECL(opus_val16, min); - VARDECL(opus_val16, follower); - - ALLOC(flatE, tot_bands, opus_val16); - ALLOC(min, tot_bands, opus_val16); - ALLOC(Ncoef, tot_bands, int); - for (i=start;ieBands[i+1]-m->eBands[i])*C<logN[i] + SHL32(eMeans[i],DB_SHIFT-4) - GCONST(.0062f)*(i+5)*(i+5), DB_SHIFT-10); - min[i] = 0; - } - if (C==2) { - for (i=start;inbEBands+i] - GCONST(0.0625f)*m->logN[i] + SHL32(eMeans[i],DB_SHIFT-4) - GCONST(.0062f)*(i+5)*(i+5), DB_SHIFT-10)); - } - } - flatE[end-1] += QCONST16(2.f, 10); - if (qext_mode != NULL) { - opus_val16 min_depth = 0; - /* If we have enough bits, give at least 1 bit of depth to all higher bands. */ - if (total >= 3*C*(qext_mode->eBands[qext_end]-qext_mode->eBands[start])< 1.33f)) - min_depth = QCONST16(1.f, 10); - for (i=0;ieBands[i+1]-qext_mode->eBands[i])*C<logN[i] + SHL32(eMeans[i],DB_SHIFT-4) - GCONST(.0062f)*(end+i+5)*(end+i+5), DB_SHIFT-10); - } - if (C==2) { - for (i=0;ilogN[i] + SHL32(eMeans[i],DB_SHIFT-4) - GCONST(.0062f)*(end+i+5)*(end+i+5), DB_SHIFT-10)); - } - } - } - ALLOC(follower, tot_bands, opus_val16); - for (i=start+2;i=start;i--) { - follower[i] = MAX16(follower[i], follower[i+1]-QCONST16(1.f, 10)); - } - for (i=start;i>= BITRES; - fill = (SHL32(total, 10) + sum)/tot_samples; - /* Iteratively refine the fill level considering the depth min and cap. */ - for (iter=0;iter<10;iter++) { - sum = 0; - for (i=start;istorage*8<storage*8<>2; - extra_pulses[i] = ((((m->eBands[i+1]-m->eBands[i])<>2; - } - if (qext_mode) { - for (i=0;i>2; - extra_pulses[end+i] = ((((qext_mode->eBands[i+1]-qext_mode->eBands[i])<>2; - } - } - RESTORE_STACK; -} -#endif diff --git a/celt/rate.h b/celt/rate.h index 659c80f3a..fad5e412d 100644 --- a/celt/rate.h +++ b/celt/rate.h @@ -98,7 +98,4 @@ static OPUS_INLINE int pulses2bits(const CELTMode *m, int band, int LM, int puls int clt_compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stereo, opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth); -void clt_compute_extra_allocation(const CELTMode *m, const CELTMode *qext_mode, int start, int end, int qext_end, const celt_glog *bandLogE, const celt_glog *qext_bandLogE, - opus_int32 total, int *extra_pulses, int *extra_equant, int C, int LM, ec_ctx *ec, int encode, opus_val16 tone_freq, opus_val32 toneishness); - #endif diff --git a/celt/static_modes_fixed.h b/celt/static_modes_fixed.h index 5bac867a7..ac3340e13 100644 --- a/celt/static_modes_fixed.h +++ b/celt/static_modes_fixed.h @@ -126,34 +126,6 @@ static const unsigned char cache_caps50[168] = { 140, 66, 40, }; #endif -#ifdef ENABLE_QEXT -# ifndef DEF_QEXT_PULSE_CACHE50 -# define DEF_QEXT_PULSE_CACHE50 -static const opus_int16 qext_cache_index50[70] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, -41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 61, 61, -61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 72, 72, 72, -72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 80, 80, 80, 80, -80, 80, 80, 80, 80, 80, 80, 80, 80, 80, }; -static const unsigned char qext_cache_bits50[86] = { -40, 26, 45, 59, 70, 79, 87, 94, 100, 105, 110, 114, 118, 122, 125, -128, 131, 136, 141, 146, 150, 153, 157, 160, 163, 168, 173, 178, 182, 185, -189, 192, 195, 200, 205, 210, 214, 217, 221, 224, 227, 19, 34, 61, 83, -101, 118, 132, 145, 157, 167, 177, 186, 194, 202, 209, 216, 222, 234, 245, -254, 10, 42, 77, 107, 133, 157, 179, 200, 219, 236, 253, 7, 50, 93, -131, 165, 197, 227, 255, 5, 58, 109, 155, 197, 237, }; -static const unsigned char qext_cache_caps50[112] = { -159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 171, -171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 167, 167, 167, -167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 166, 166, 166, 166, 166, -166, 166, 166, 166, 166, 166, 166, 166, 166, 163, 163, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 165, 165, 165, 165, 165, 165, 165, -165, 165, 165, 165, 165, 165, 165, }; -# endif -#endif - #ifndef FFT_TWIDDLES48000_960 #define FFT_TWIDDLES48000_960 static const kiss_twiddle_cpx fft_twiddles48000_960[480] = { @@ -1560,9 +1532,6 @@ logN400, /* logN */ window120, /* window */ {1920, 3, {&fft_state48000_960_0, &fft_state48000_960_1, &fft_state48000_960_2, &fft_state48000_960_3, }, mdct_twiddles960}, /* mdct */ {392, cache_index50, cache_bits50, cache_caps50}, /* cache */ -#ifdef ENABLE_QEXT -{86, qext_cache_index50, qext_cache_bits50, qext_cache_caps50}, /* qext_cache */ -#endif }; #ifdef ENABLE_QEXT @@ -1731,34 +1700,6 @@ static const unsigned char cache_caps50[168] = { 140, 66, 40, }; #endif -#ifdef ENABLE_QEXT -# ifndef DEF_QEXT_PULSE_CACHE50 -# define DEF_QEXT_PULSE_CACHE50 -static const opus_int16 qext_cache_index50[70] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, -41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 61, 61, -61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 72, 72, 72, -72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 80, 80, 80, 80, -80, 80, 80, 80, 80, 80, 80, 80, 80, 80, }; -static const unsigned char qext_cache_bits50[86] = { -40, 26, 45, 59, 70, 79, 87, 94, 100, 105, 110, 114, 118, 122, 125, -128, 131, 136, 141, 146, 150, 153, 157, 160, 163, 168, 173, 178, 182, 185, -189, 192, 195, 200, 205, 210, 214, 217, 221, 224, 227, 19, 34, 61, 83, -101, 118, 132, 145, 157, 167, 177, 186, 194, 202, 209, 216, 222, 234, 245, -254, 10, 42, 77, 107, 133, 157, 179, 200, 219, 236, 253, 7, 50, 93, -131, 165, 197, 227, 255, 5, 58, 109, 155, 197, 237, }; -static const unsigned char qext_cache_caps50[112] = { -159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 171, -171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 167, 167, 167, -167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 166, 166, 166, 166, 166, -166, 166, 166, 166, 166, 166, 166, 166, 166, 163, 163, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 165, 165, 165, 165, 165, 165, 165, -165, 165, 165, 165, 165, 165, 165, }; -# endif -#endif - #ifndef FFT_TWIDDLES96000_1920 #define FFT_TWIDDLES96000_1920 static const kiss_twiddle_cpx fft_twiddles96000_1920[960] = { @@ -4425,9 +4366,6 @@ logN400, /* logN */ window240, /* window */ {3840, 3, {&fft_state96000_1920_0, &fft_state96000_1920_1, &fft_state96000_1920_2, &fft_state96000_1920_3, }, mdct_twiddles1920}, /* mdct */ {392, cache_index50, cache_bits50, cache_caps50}, /* cache */ -#ifdef ENABLE_QEXT -{86, qext_cache_index50, qext_cache_bits50, qext_cache_caps50}, /* qext_cache */ -#endif }; #endif /* ENABLE_QEXT */ diff --git a/celt/static_modes_float.h b/celt/static_modes_float.h index 1bccc3b40..06cca3f5f 100644 --- a/celt/static_modes_float.h +++ b/celt/static_modes_float.h @@ -99,34 +99,6 @@ static const unsigned char cache_caps50[168] = { 140, 66, 40, }; #endif -#ifdef ENABLE_QEXT -# ifndef DEF_QEXT_PULSE_CACHE50 -# define DEF_QEXT_PULSE_CACHE50 -static const opus_int16 qext_cache_index50[70] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, -41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 61, 61, -61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 72, 72, 72, -72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 80, 80, 80, 80, -80, 80, 80, 80, 80, 80, 80, 80, 80, 80, }; -static const unsigned char qext_cache_bits50[86] = { -40, 26, 45, 59, 70, 79, 87, 94, 100, 105, 110, 114, 118, 122, 125, -128, 131, 136, 141, 146, 150, 153, 157, 160, 163, 168, 173, 178, 182, 185, -189, 192, 195, 200, 205, 210, 214, 217, 221, 224, 227, 19, 34, 61, 83, -101, 118, 132, 145, 157, 167, 177, 186, 194, 202, 209, 216, 222, 234, 245, -254, 10, 42, 77, 107, 133, 157, 179, 200, 219, 236, 253, 7, 50, 93, -131, 165, 197, 227, 255, 5, 58, 109, 155, 197, 237, }; -static const unsigned char qext_cache_caps50[112] = { -159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 171, -171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 167, 167, 167, -167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 166, 166, 166, 166, 166, -166, 166, 166, 166, 166, 166, 166, 166, 166, 163, 163, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 165, 165, 165, 165, 165, 165, 165, -165, 165, 165, 165, 165, 165, 165, }; -# endif -#endif - #ifndef FFT_TWIDDLES48000_960 #define FFT_TWIDDLES48000_960 static const kiss_twiddle_cpx fft_twiddles48000_960[480] = { @@ -907,9 +879,6 @@ logN400, /* logN */ window120, /* window */ {1920, 3, {&fft_state48000_960_0, &fft_state48000_960_1, &fft_state48000_960_2, &fft_state48000_960_3, }, mdct_twiddles960}, /* mdct */ {392, cache_index50, cache_bits50, cache_caps50}, /* cache */ -#ifdef ENABLE_QEXT -{86, qext_cache_index50, qext_cache_bits50, qext_cache_caps50}, /* qext_cache */ -#endif }; #ifdef ENABLE_QEXT @@ -1027,34 +996,6 @@ static const unsigned char cache_caps50[168] = { 140, 66, 40, }; #endif -#ifdef ENABLE_QEXT -# ifndef DEF_QEXT_PULSE_CACHE50 -# define DEF_QEXT_PULSE_CACHE50 -static const opus_int16 qext_cache_index50[70] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, -41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 61, 61, -61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 72, 72, 72, -72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 80, 80, 80, 80, -80, 80, 80, 80, 80, 80, 80, 80, 80, 80, }; -static const unsigned char qext_cache_bits50[86] = { -40, 26, 45, 59, 70, 79, 87, 94, 100, 105, 110, 114, 118, 122, 125, -128, 131, 136, 141, 146, 150, 153, 157, 160, 163, 168, 173, 178, 182, 185, -189, 192, 195, 200, 205, 210, 214, 217, 221, 224, 227, 19, 34, 61, 83, -101, 118, 132, 145, 157, 167, 177, 186, 194, 202, 209, 216, 222, 234, 245, -254, 10, 42, 77, 107, 133, 157, 179, 200, 219, 236, 253, 7, 50, 93, -131, 165, 197, 227, 255, 5, 58, 109, 155, 197, 237, }; -static const unsigned char qext_cache_caps50[112] = { -159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 171, -171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 167, 167, 167, -167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 166, 166, 166, 166, 166, -166, 166, 166, 166, 166, 166, 166, 166, 166, 163, 163, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 165, 165, 165, 165, 165, 165, 165, -165, 165, 165, 165, 165, 165, 165, }; -# endif -#endif - #ifndef FFT_TWIDDLES96000_1920 #define FFT_TWIDDLES96000_1920 static const kiss_twiddle_cpx fft_twiddles96000_1920[960] = { @@ -2495,9 +2436,6 @@ logN400, /* logN */ window240, /* window */ {3840, 3, {&fft_state96000_1920_0, &fft_state96000_1920_1, &fft_state96000_1920_2, &fft_state96000_1920_3, }, mdct_twiddles1920}, /* mdct */ {392, cache_index50, cache_bits50, cache_caps50}, /* cache */ -#ifdef ENABLE_QEXT -{86, qext_cache_index50, qext_cache_bits50, qext_cache_caps50}, /* qext_cache */ -#endif }; #endif /* ENABLE_QEXT */ diff --git a/celt/vq.c b/celt/vq.c index fbe652fe8..759c24379 100644 --- a/celt/vq.c +++ b/celt/vq.c @@ -38,7 +38,6 @@ #include "bands.h" #include "rate.h" #include "pitch.h" -#include "SigProc_FIX.h" #if defined(FIXED_POINT) void norm_scaleup(celt_norm *X, int N, int shift) { @@ -373,190 +372,16 @@ opus_val16 op_pvq_search_c(celt_norm *X, int *iy, int K, int N, int arch) return yy; } -#ifdef ENABLE_QEXT -#include "macros.h" - -static opus_val32 op_pvq_search_N2(const celt_norm *X, int *iy, int *up_iy, int K, int up, int *refine, int shift) { - opus_val32 sum; - opus_val32 rcp_sum; - int offset; - sum = ABS32(X[0]) + ABS32(X[1]); - if (sum < EPSILON) { - iy[0] = K; - up_iy[0] = up*K; - iy[1]=up_iy[1]=0; - *refine=0; -#ifdef FIXED_POINT - return (opus_val64)K*K*up*up>>2*shift; -#else - (void)shift; - return K*(float)K*up*up; -#endif - } -#ifdef FIXED_POINT - int sum_shift; - opus_val32 X0; - sum_shift = 30-celt_ilog2(sum); - rcp_sum = celt_rcp_norm32(SHL32(sum, sum_shift)); - X0 = MULT32_32_Q31(SHL32(X[0], sum_shift), rcp_sum); - iy[0] = PSHR32(MULT32_32_Q31(SHL32(K, 8), X0), 7); - up_iy[0] = PSHR32(MULT32_32_Q31(SHL32(up*K, 8), X0), 7); -#else - rcp_sum = 1.f/sum; - iy[0] = (int)floor(.5f+K*X[0]*rcp_sum); - up_iy[0] = (int)floor(.5f+up*K*X[0]*rcp_sum); -#endif - up_iy[0] = IMAX(up*iy[0] - (up-1)/2, IMIN(up*iy[0] + (up-1)/2, up_iy[0])); - offset = up_iy[0] - up*iy[0]; - iy[1] = K-abs(iy[0]); - up_iy[1] = up*K-abs(up_iy[0]); - if (X[1] < 0) { - iy[1] = -iy[1]; - up_iy[1] = -up_iy[1]; - offset = -offset; - } - *refine = offset; -#ifdef FIXED_POINT - return (up_iy[0]*(opus_val64)up_iy[0] + up_iy[1]*(opus_val64)up_iy[1] + (1<<2*shift>>1))>>2*shift; -#else - return up_iy[0]*(opus_val64)up_iy[0] + up_iy[1]*(opus_val64)up_iy[1]; -#endif -} - -static int op_pvq_refine(const opus_val32 *Xn, int *iy, int *iy0, int K, int up, int margin, int N) { - int i; - int dir; - VARDECL(opus_val32, rounding); - int iysum = 0; - SAVE_STACK; - ALLOC(rounding, N, opus_val32); - for (i=0;i> 7; -#else - iy[i] = (int)floor(.5+tmp); -#endif - rounding[i] = tmp - SHL32(iy[i], 7); - } - if (iy != iy0) { - for (i=0;i 32) { RESTORE_STACK; - return 1; - } - dir = iysum < K ? 1 : -1; - while (iysum != K) { - opus_val32 roundval=-1000000*dir; - int roundpos=0; - for (i=0;i 0 && abs(iy[i]-up*iy0[i]) < (margin-1) && !(dir==-1 && iy[i] == 0)) { - roundval = rounding[i]; - roundpos = i; - } - } - iy[roundpos] += dir; - rounding[roundpos] -= SHL32(dir, 15); - iysum+=dir; - } RESTORE_STACK; - return 0; -} - -static opus_val32 op_pvq_search_extra(const celt_norm *X, int *iy, int *up_iy, int K, int up, int *refine, int N, int shift) { - opus_val32 rcp_sum; - opus_val32 sum=0; - int i; - int failed=0; - opus_val64 yy=0; - VARDECL(opus_val32, Xn); - SAVE_STACK; - for (i=0;i>1))>>2*shift; -#else - (void)shift; - return yy; -#endif -} -#endif - -#ifdef ENABLE_QEXT -/* Take advantage of the fact that "large" refine values are much less likely - than smaller ones. */ -static void ec_enc_refine(ec_enc *enc, opus_int32 refine, opus_int32 up, int extra_bits, int use_entropy) { - int large; - large = abs(refine)>up/2; - ec_enc_bit_logp(enc, large, use_entropy ? 3 : 1); - if (large) { - ec_enc_bits(enc, refine < 0, 1); - ec_enc_bits(enc, abs(refine)-up/2-1, extra_bits-1); - } else { - ec_enc_bits(enc, refine+up/2, extra_bits); - } -} - -static int ec_dec_refine(ec_enc *dec, opus_int32 up, int extra_bits, int use_entropy) { - int large, refine; - large = ec_dec_bit_logp(dec, use_entropy ? 3 : 1); - if (large) { - int sign = ec_dec_bits(dec, 1); - refine = ec_dec_bits(dec, extra_bits-1) + up/2+1; - if (sign) refine = -refine; - } else { - refine = (opus_int32)ec_dec_bits(dec, extra_bits)-up/2; - } - return refine; -} -#endif unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc, - opus_val32 gain, int resynth - ARG_QEXT(ec_enc *ext_enc) ARG_QEXT(int extra_bits), int arch) + opus_val32 gain, int resynth, int arch) { VARDECL(int, iy); opus_val32 yy; unsigned collapse_mask; -#ifdef ENABLE_QEXT - int yy_shift = 0; -#endif SAVE_STACK; celt_assert2(K>0, "alg_quant() needs at least one pulse"); @@ -567,45 +392,10 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc, exp_rotation(X, N, 1, B, K, spread); -#ifdef ENABLE_QEXT - if (N==2 && extra_bits >= 2) { - int refine; - int up_iy[2]; - int up; - yy_shift = IMAX(0, extra_bits-7); - up = (1<= 2) { - int i; - VARDECL(int, up_iy); - VARDECL(int, refine); - int up, use_entropy; - ALLOC(up_iy, N, int); - ALLOC(refine, N, int); - yy_shift = IMAX(0, extra_bits-7); - up = (1<storage*8 - ec_tell(ext_enc)) > (unsigned)(N-1)*(extra_bits+3)+1; - for (i=0;i1, "alg_unquant() needs at least two dimensions"); ALLOC(iy, N, int); Ryy = decode_pulses(iy, N, K, dec); -#ifdef ENABLE_QEXT - if (N==2 && extra_bits >= 2) { - int up; - int refine; - yy_shift = IMAX(0, extra_bits-7); - up = (1< 0) ? -refine : refine; - iy[0] += (refine*(opus_int64)iy[0] > 0) ? -refine : refine; - } else if (iy[1] > 0) { - iy[0] += refine; - iy[1] -= refine*(iy[0]>0?1:-1); - } else { - iy[0] -= refine; - iy[1] -= refine*(iy[0]>0?1:-1); - } -#ifdef FIXED_POINT - Ryy = (iy[0]*(opus_val64)iy[0] + iy[1]*(opus_val64)iy[1] + (1<<2*yy_shift>>1)) >> 2*yy_shift; -#else - Ryy = iy[0]*(opus_val64)iy[0] + iy[1]*(opus_val64)iy[1]; -#endif - } else if (extra_bits >= 2) { - int i; - opus_val64 yy64; - VARDECL(int, refine); - int up, use_entropy; - int sign=0; - ALLOC(refine, N, int); - yy_shift = IMAX(0, extra_bits-7); - up = (1<storage*8 - ec_tell(ext_dec)) > (unsigned)(N-1)*(extra_bits+3)+1; - for (i=0;i>1)) >> 2*yy_shift; -#else - Ryy = yy64; -#endif - } -#endif normalise_residual(iy, X, N, Ryy, gain, yy_shift); exp_rotation(X, N, -1, B, K, spread); collapse_mask = extract_collapse_mask(iy, N, B); diff --git a/celt/vq.h b/celt/vq.h index 07fa44abe..1f368a57b 100644 --- a/celt/vq.h +++ b/celt/vq.h @@ -74,8 +74,7 @@ opus_val16 op_pvq_search_c(celt_norm *X, int *iy, int K, int N, int arch); * @ret A mask indicating which blocks in the band received pulses */ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc, - opus_val32 gain, int resynth - ARG_QEXT(ec_enc *ext_enc) ARG_QEXT(int extra_bits), int arch); + opus_val32 gain, int resynth, int arch); /** Algebraic pulse decoder * @param X Decoded normalised spectrum (returned) @@ -85,8 +84,7 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc, * @ret A mask indicating which blocks in the band received pulses */ unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, - ec_dec *dec, opus_val32 gain - ARG_QEXT(ec_enc *ext_dec) ARG_QEXT(int extra_bits)); + ec_dec *dec, opus_val32 gain); void renormalise_vector(celt_norm *X, int N, opus_val32 gain, int arch); diff --git a/include/opus_defines.h b/include/opus_defines.h index 4a61406db..28ae954ba 100644 --- a/include/opus_defines.h +++ b/include/opus_defines.h @@ -175,8 +175,8 @@ extern "C" { /*#define OPUS_GET_DNN_BLOB_REQUEST 4053 */ #define OPUS_SET_OSCE_BWE_REQUEST 4054 #define OPUS_GET_OSCE_BWE_REQUEST 4055 -#define OPUS_SET_QEXT_REQUEST 4056 -#define OPUS_GET_QEXT_REQUEST 4057 + + #define OPUS_SET_IGNORE_EXTENSIONS_REQUEST 4058 #define OPUS_GET_IGNORE_EXTENSIONS_REQUEST 4059 @@ -658,14 +658,6 @@ extern "C" { * @hideinitializer */ #define OPUS_SET_DNN_BLOB(data, len) OPUS_SET_DNN_BLOB_REQUEST, opus_check_void_ptr(data), opus_check_int(len) -/** If set to 1, enables quality extension (QEXT), otherwise disables it (default). Warning: This will *hurt* audio quality unless operating at - a very high bitrate. - * @hideinitializer */ -#define OPUS_SET_QEXT(x) OPUS_SET_QEXT_REQUEST, opus_check_int(x) -/** Gets the encoder's configured quality extension (QEXT). - * @hideinitializer */ -#define OPUS_GET_QEXT(x) OPUS_GET_QEXT_REQUEST, opus_check_int_ptr(x) - /**@}*/ /** @defgroup opus_genericctls Generic CTLs diff --git a/src/opus_decoder.c b/src/opus_decoder.c index 1678e1e30..8dc86cea7 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -269,7 +269,7 @@ static int opus_packet_get_mode(const unsigned char *data) } static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, - opus_int32 len, opus_res *pcm, int frame_size, int decode_fec ARG_QEXT(opus_extension_data *ext)) + opus_int32 len, opus_res *pcm, int frame_size, int decode_fec) { void *silk_dec; CELTDecoder *celt_dec; @@ -345,7 +345,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, if (audiosize > F20) { do { - int ret = opus_decode_frame(st, NULL, 0, pcm, IMIN(audiosize, F20), 0 ARG_QEXT(NULL)); + int ret = opus_decode_frame(st, NULL, 0, pcm, IMIN(audiosize, F20), 0); if (ret<0) { RESTORE_STACK; @@ -387,7 +387,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, if (transition && mode == MODE_CELT_ONLY) { pcm_transition = pcm_transition_celt; - opus_decode_frame(st, NULL, 0, pcm_transition, IMIN(F5, audiosize), 0 ARG_QEXT(NULL)); + opus_decode_frame(st, NULL, 0, pcm_transition, IMIN(F5, audiosize), 0); } if (audiosize > frame_size) { @@ -540,7 +540,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, if (transition && mode != MODE_CELT_ONLY) { pcm_transition = pcm_transition_silk; - opus_decode_frame(st, NULL, 0, pcm_transition, IMIN(F5, audiosize), 0 ARG_QEXT(NULL)); + opus_decode_frame(st, NULL, 0, pcm_transition, IMIN(F5, audiosize), 0); } @@ -608,7 +608,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, #ifdef ENABLE_DEEP_PLC , &st->lpcnet #endif - ARG_QEXT(ext ? ext->data : NULL) ARG_QEXT(ext ? ext->len : 0)); + ); celt_decoder_ctl(celt_dec, OPUS_GET_FINAL_RANGE(&st->rangeFinal)); } else { unsigned char silence[2] = {0xFF, 0xFF}; @@ -765,7 +765,7 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, int pcm_count=0; do { int ret; - ret = opus_decode_frame(st, NULL, 0, pcm+pcm_count*st->channels, frame_size-pcm_count, 0 ARG_QEXT(NULL)); + ret = opus_decode_frame(st, NULL, 0, pcm+pcm_count*st->channels, frame_size-pcm_count, 0); if (ret<0) return ret; pcm_count += ret; @@ -820,7 +820,7 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, st->frame_size = packet_frame_size; st->stream_channels = packet_stream_channels; ret = opus_decode_frame(st, data, size[0], pcm+st->channels*(frame_size-packet_frame_size), - packet_frame_size, 1 ARG_QEXT(NULL)); + packet_frame_size, 1); if (ret<0) return ret; else { @@ -844,22 +844,7 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, for (i=0;i i) iter = iter_copy; - } - if (ext.frame != i) ext.data = NULL; -#endif - ret = opus_decode_frame(st, data, size[i], pcm+nb_samples*st->channels, frame_size-nb_samples, 0 ARG_QEXT(&ext)); + ret = opus_decode_frame(st, data, size[i], pcm+nb_samples*st->channels, frame_size-nb_samples, 0); if (ret<0) return ret; celt_assert(ret==packet_frame_size); diff --git a/src/opus_demo.c b/src/opus_demo.c index f040f9f2b..8d201436f 100644 --- a/src/opus_demo.c +++ b/src/opus_demo.c @@ -150,9 +150,6 @@ void print_usage( char* argv[] ) #ifdef ENABLE_OSCE_BWE fprintf(stderr, "-enable_osce_bwe : enable OSCE bandwidth extension for wideband signals (48 kHz sampling rate only), raises dec_complexity to 4\n"); #endif -#ifdef ENABLE_QEXT - fprintf(stderr, "-qext : enable QEXT\n" ); -#endif } #define FORMAT_S16_LE 0 @@ -463,9 +460,6 @@ int main(int argc, char *argv[]) int dred_duration=0; int ignore_extensions=0; int encoder_loss=0; -#ifdef ENABLE_QEXT - int enable_qext=0; -#endif #ifdef ENABLE_OSCE_TRAINING_DATA int silk_random_switching = 0; int silk_frame_counter = 0; @@ -743,12 +737,6 @@ int main(int argc, char *argv[]) check_decoder_option(encode_only, "-ignore_extensions"); ignore_extensions = 1; args++; -#ifdef ENABLE_QEXT - } else if( strcmp( argv[ args ], "-qext" ) == 0 ) { - check_encoder_option(decode_only, "-qext"); - enable_qext = 1; - args++; -#endif #ifdef ENABLE_OSCE_TRAINING_DATA } else if( strcmp( argv[ args ], "-silk_random_switching" ) == 0 ){ silk_random_switching = atoi( argv[ args + 1 ] ); @@ -834,9 +822,6 @@ int main(int argc, char *argv[]) #ifdef ENABLE_OSCE_TRAINING_DATA opus_encoder_ctl(enc, OPUS_SET_FORCE_MODE(MODE_SILK_ONLY)); srand(0); -#endif -#ifdef ENABLE_QEXT - opus_encoder_ctl(enc, OPUS_SET_QEXT(enable_qext)); #endif } if (!encode_only) diff --git a/src/opus_encoder.c b/src/opus_encoder.c index a74631fc2..0b8c22ee0 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -1213,10 +1213,6 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_res *pcm, int frame_si #endif ALLOC_STACK; -#ifdef ENABLE_QEXT - if (st->enable_qext) packet_size_cap = QEXT_PACKET_SIZE_CAP; -#endif - /* Just avoid insane packet sizes here, but the real bounds are applied later on. */ max_data_bytes = IMIN(packet_size_cap*6, out_data_bytes); @@ -1786,11 +1782,6 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_res *pcm, int frame_si #ifdef ENABLE_DRED curr_max = IMIN(curr_max, (max_len_sum-bitrate_to_bits(dred_bitrate_bps, st->Fs, frame_size)/8)/nb_frames); if (first_frame) curr_max += bitrate_to_bits(dred_bitrate_bps, st->Fs, frame_size)/8; -#endif -#ifdef ENABLE_QEXT - /* Leave room for signaling the extension size once we repacketize. */ - if (st->enable_qext) - curr_max -= curr_max/254; #endif curr_max = IMIN(max_len_sum-tot_size, curr_max); #ifndef DISABLE_FLOAT_API @@ -2487,13 +2478,7 @@ static opus_int32 opus_encode_frame_native(OpusEncoder *st, const opus_res *pcm, /* If false, we already busted the budget and we'll end up with a "PLC frame" */ if (ec_tell(&enc) <= 8*nb_compr_bytes) { -#ifdef ENABLE_QEXT - if (st->mode == MODE_CELT_ONLY) celt_encoder_ctl(celt_enc, OPUS_SET_QEXT(st->enable_qext)); -#endif ret = celt_encode_with_ec(celt_enc, pcm_buf, frame_size, NULL, nb_compr_bytes, &enc); -#ifdef ENABLE_QEXT - celt_encoder_ctl(celt_enc, OPUS_SET_QEXT(0)); -#endif if (ret < 0) { RESTORE_STACK; @@ -3217,28 +3202,6 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...) *value = st->dred_duration; } break; -#endif -#ifdef ENABLE_QEXT - case OPUS_SET_QEXT_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>1) - { - goto bad_arg; - } - st->enable_qext = value; - } - break; - case OPUS_GET_QEXT_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->enable_qext; - } - break; #endif case OPUS_RESET_STATE: { diff --git a/src/opus_multistream_encoder.c b/src/opus_multistream_encoder.c index 79c0d3b7d..fbdfc0548 100644 --- a/src/opus_multistream_encoder.c +++ b/src/opus_multistream_encoder.c @@ -832,11 +832,7 @@ static opus_int32 rate_allocation( } /* Max size in case the encoder decides to return six frames (6 x 20 ms = 120 ms) */ -#ifdef ENABLE_QEXT -#define MS_FRAME_TMP (6*QEXT_PACKET_SIZE_CAP+12) -#else #define MS_FRAME_TMP (6*1275+12) -#endif int opus_multistream_encode_native ( @@ -1209,7 +1205,6 @@ int opus_multistream_encoder_ctl_va_list(OpusMSEncoder *st, int request, case OPUS_GET_FORCE_CHANNELS_REQUEST: case OPUS_GET_PREDICTION_DISABLED_REQUEST: case OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST: - case OPUS_GET_QEXT_REQUEST: { OpusEncoder *enc; /* For int32* GET params, just query the first stream */ @@ -1257,7 +1252,6 @@ int opus_multistream_encoder_ctl_va_list(OpusMSEncoder *st, int request, case OPUS_SET_FORCE_CHANNELS_REQUEST: case OPUS_SET_PREDICTION_DISABLED_REQUEST: case OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST: - case OPUS_SET_QEXT_REQUEST: { int s; /* This works for int32 params */ diff --git a/tests/opus_encode_regressions.c b/tests/opus_encode_regressions.c index fb76d3eb3..a9adacfcf 100644 --- a/tests/opus_encode_regressions.c +++ b/tests/opus_encode_regressions.c @@ -1153,7 +1153,6 @@ int projection_overflow(void) opus_test_assert(err == OPUS_BAD_ARG); return 0; #endif - opus_projection_encoder_ctl(enc, OPUS_SET_QEXT(1)); data_len = opus_projection_encode(enc, pcm, 1920, data, 10000); opus_test_assert(data_len > 0 && data_len <= 10000); opus_projection_encoder_destroy(enc); @@ -1192,7 +1191,6 @@ int projection_overflow4(void) enc = opus_projection_ambisonics_encoder_create(96000, 36, 3, &streams, &coupled_streams, OPUS_APPLICATION_AUDIO, &err); - opus_projection_encoder_ctl(enc, OPUS_SET_QEXT(1)); opus_projection_encoder_ctl(enc, OPUS_SET_BITRATE(256000)); data_len = opus_projection_encode(enc, pcm, 480, data, 1000); opus_test_assert(data_len > 0 && data_len <= 1000); @@ -1212,7 +1210,6 @@ int qext_repacketize_fail(void) enc = opus_encoder_create(16000, 1, OPUS_APPLICATION_VOIP, &err); opus_encoder_ctl(enc, OPUS_SET_VBR(0)); - opus_encoder_ctl(enc, OPUS_SET_QEXT(1)); opus_encoder_ctl(enc, OPUS_SET_BITRATE(OPUS_BITRATE_MAX)); data_len = opus_encode(enc, pcm, 960, data, 9000); /* returns OPUS_INTERNAL_ERROR (-3) */ @@ -1262,7 +1259,6 @@ int qext_dred_combination(void) &coupled_streams, mapping, OPUS_APPLICATION_VOIP, &err); opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(3)); opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(12)); - opus_multistream_encoder_ctl(enc, OPUS_SET_QEXT(1)); opus_multistream_encoder_ctl(enc, OPUS_MULTISTREAM_GET_ENCODER_STATE(0, &stream_enc)); opus_encoder_ctl(stream_enc, OPUS_SET_DRED_DURATION(103)); opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(755850)); diff --git a/tests/test_opus_custom.c b/tests/test_opus_custom.c index faa84e59f..bcf7302ca 100644 --- a/tests/test_opus_custom.c +++ b/tests/test_opus_custom.c @@ -618,9 +618,6 @@ void test_opus_custom(const int num_encoders, const int num_setting_changes) { if (opus_custom_encoder_ctl(encC, OPUS_SET_COMPLEXITY(complexity)) != OPUS_OK) test_failed(); if (opus_custom_encoder_ctl(encC, OPUS_SET_PACKET_LOSS_PERC(pkt_loss)) != OPUS_OK) test_failed(); if (opus_custom_encoder_ctl(encC, OPUS_SET_LSB_DEPTH(lsb_depth)) != OPUS_OK) test_failed(); -#ifdef ENABLE_QEXT - if (opus_custom_encoder_ctl(encC, OPUS_SET_QEXT(params.qext)) != OPUS_OK) test_failed(); -#endif } else { if (opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate)) != OPUS_OK) test_failed(); diff --git a/tests/test_opus_encode.c b/tests/test_opus_encode.c index 74603e8a6..d4bab0b86 100644 --- a/tests/test_opus_encode.c +++ b/tests/test_opus_encode.c @@ -278,9 +278,6 @@ void fuzz_encoder_settings(const int num_encoders, const int num_setting_changes if(opus_encoder_ctl(enc, OPUS_SET_EXPERT_FRAME_DURATION(frame_size_enum)) != OPUS_OK) test_failed(); #ifdef ENABLE_DRED if(opus_encoder_ctl(enc, OPUS_SET_DRED_DURATION(fast_rand()%101)) != OPUS_OK) test_failed(); -#endif -#ifdef ENABLE_QEXT - if(opus_encoder_ctl(enc, OPUS_SET_QEXT(fast_rand()%2))!=OPUS_OK)test_failed(); #endif if(test_encode(enc, num_channels, frame_size, dec)) { fprintf(stderr, @@ -438,8 +435,7 @@ int run_test1(int no_fuzz) rate=rates[j]+fast_rand()%rates[j]; count=i=0; do { - int bw,len,out_samples,frame_size,unpad; - int qext=0; + int bw,len,out_samples,frame_size; frame_size=frame[j]; if((fast_rand()&255)==0) { @@ -471,10 +467,6 @@ int run_test1(int no_fuzz) OPUS_BANDWIDTH_NARROWBAND+(fast_rand()%5); if(modes[j]==2&&bw==OPUS_BANDWIDTH_MEDIUMBAND)bw+=3; if(opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(bw))!=OPUS_OK)test_failed(); -#ifdef ENABLE_QEXT - qext=fast_rand()%2; - if(opus_encoder_ctl(enc, OPUS_SET_QEXT(qext))!=OPUS_OK)test_failed(); -#endif len = opus_encode(enc, &inbuf[i<<1], frame_size, packet, MAX_PACKET); if(len<0 || len>MAX_PACKET)test_failed(); if(opus_encoder_ctl(enc, OPUS_GET_FINAL_RANGE(&enc_final_range))!=OPUS_OK)test_failed(); @@ -488,17 +480,15 @@ int run_test1(int no_fuzz) if(opus_packet_pad(packet,len,len+256)!=OPUS_OK)test_failed(); len+=256; } - unpad = 0; if((fast_rand()&3)==0) { - unpad=1; len=opus_packet_unpad(packet,len); if(len<1)test_failed(); } out_samples = opus_decode(dec, packet, len, &outbuf[i<<1], MAX_FRAME_SAMP, 0); if(out_samples!=frame_size)test_failed(); if(opus_decoder_ctl(dec, OPUS_GET_FINAL_RANGE(&dec_final_range))!=OPUS_OK)test_failed(); - if(enc_final_range!=dec_final_range && !(unpad && qext))test_failed(); + if(enc_final_range!=dec_final_range)test_failed(); /*LBRR decode*/ out_samples = opus_decode(dec_err[0], packet, len, out2buf, frame_size, (fast_rand()&3)!=0); if(out_samples!=frame_size)test_failed(); @@ -536,9 +526,8 @@ int run_test1(int no_fuzz) if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_BITRATE(rate))!=OPUS_OK)test_failed(); count=i=0; do { - int len,out_samples,frame_size,loss,unpad; + int len,out_samples,frame_size,loss; opus_int32 pred; - int qext=0; if(opus_multistream_encoder_ctl(MSenc, OPUS_GET_PREDICTION_DISABLED(&pred))!=OPUS_OK)test_failed(); if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_PREDICTION_DISABLED((int)(fast_rand()&15)<(pred?11:4)))!=OPUS_OK)test_failed(); frame_size=frame[j]; @@ -557,10 +546,6 @@ int run_test1(int no_fuzz) { if(opus_multistream_decoder_ctl(MSdec_err, OPUS_RESET_STATE)!=OPUS_OK)test_failed(); } -#ifdef ENABLE_QEXT - qext=fast_rand()%2; - if(opus_multistream_encoder_ctl(MSenc, OPUS_SET_QEXT(qext))!=OPUS_OK)test_failed(); -#endif len = opus_multistream_encode(MSenc, &inbuf[i<<1], frame_size, packet, MAX_PACKET); if(len<0 || len>MAX_PACKET)test_failed(); if(opus_multistream_encoder_ctl(MSenc, OPUS_GET_FINAL_RANGE(&enc_final_range))!=OPUS_OK)test_failed(); @@ -574,17 +559,15 @@ int run_test1(int no_fuzz) if(opus_multistream_packet_pad(packet,len,len+256,2)!=OPUS_OK)test_failed(); len+=256; } - unpad=0; if((fast_rand()&3)==0) { len=opus_multistream_packet_unpad(packet,len,2); if(len<1)test_failed(); - unpad=1; } out_samples = opus_multistream_decode(MSdec, packet, len, out2buf, MAX_FRAME_SAMP, 0); if(out_samples!=frame_size*6)test_failed(); if(opus_multistream_decoder_ctl(MSdec, OPUS_GET_FINAL_RANGE(&dec_final_range))!=OPUS_OK)test_failed(); - if(enc_final_range!=dec_final_range && !(unpad && qext))test_failed(); + if(enc_final_range!=dec_final_range)test_failed(); /*LBRR decode*/ loss=(fast_rand()&63)==0; out_samples = opus_multistream_decode(MSdec_err, packet, loss?0:len, out2buf, frame_size*6, (fast_rand()&3)!=0); From e4f10df13c33e7a5b74983d808006dac593b1b50 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Mon, 11 Aug 2025 15:25:30 -0400 Subject: [PATCH 02/28] Always use extra precision from RES24 and QEXT Remove ENABLE_RES24 option, keep QEXT just for 96 kHz support Signed-off-by: Jean-Marc Valin --- celt/_kiss_fft_guts.h | 5 - celt/arch.h | 26 - celt/celt_decoder.c | 9 +- celt/celt_encoder.c | 32 +- celt/dump_modes/Makefile | 4 +- celt/dump_modes/dump_modes.c | 69 -- celt/kiss_fft.c | 11 - celt/kiss_fft.h | 6 +- celt/mathops.h | 12 +- celt/mdct.c | 17 - celt/modes.c | 5 - celt/static_modes_fixed.h | 1922 -------------------------------- celt/tests/test_unit_mathops.c | 8 - celt/tests/test_unit_mdct.c | 4 - celt/vq.c | 6 +- configure.ac | 8 - include/opus_defines.h | 1 + src/mapping_matrix.c | 4 - src/opus_decoder.c | 36 +- src/opus_encoder.c | 46 +- tests/test_opus_custom.c | 6 +- 21 files changed, 15 insertions(+), 2222 deletions(-) diff --git a/celt/_kiss_fft_guts.h b/celt/_kiss_fft_guts.h index db443c053..fa1e37fe2 100644 --- a/celt/_kiss_fft_guts.h +++ b/celt/_kiss_fft_guts.h @@ -54,13 +54,8 @@ #define SAMP_MIN -SAMP_MAX -#ifdef ENABLE_QEXT # define S_MUL(a,b) MULT32_32_P31_ovflw(b, a) # define S_MUL2(a,b) MULT32_32_P31_ovflw(b, a) -#else -# define S_MUL(a,b) MULT16_32_Q15(b, a) -# define S_MUL2(a,b) MULT16_32_Q16(b, a) -#endif # define C_MUL(m,a,b) \ do{ (m).r = SUB32_ovflw(S_MUL((a).r,(b).r) , S_MUL((a).i,(b).i)); \ diff --git a/celt/arch.h b/celt/arch.h index 63b8ebe60..b88648beb 100644 --- a/celt/arch.h +++ b/celt/arch.h @@ -146,7 +146,6 @@ typedef opus_val32 celt_norm; typedef opus_val32 celt_ener; typedef opus_val32 celt_glog; -#ifdef ENABLE_RES24 typedef opus_val32 opus_res; #define RES_SHIFT 8 #define SIG2RES(a) PSHR32(a, SIG_SHIFT-RES_SHIFT) @@ -160,28 +159,12 @@ typedef opus_val32 opus_res; #define RES2SIG(a) SHL32((a), SIG_SHIFT-RES_SHIFT) #define MULT16_RES_Q15(a,b) MULT16_32_Q15(a,b) #define MAX_ENCODING_DEPTH 24 -#else -typedef opus_val16 opus_res; -#define RES_SHIFT 0 -#define SIG2RES(a) SIG2WORD16(a) -#define RES2INT16(a) (a) -#define RES2INT24(a) SHL32(EXTEND32(a), 8) -#define RES2FLOAT(a) ((1.f/32768.f)*(a)) -#define INT16TORES(a) (a) -#define INT24TORES(a) SAT16(PSHR32(a, 8)) -#define ADD_RES(a, b) SAT16(ADD32((a), (b))); -#define FLOAT2RES(a) FLOAT2INT16(a) -#define RES2SIG(a) SHL32(EXTEND32(a), SIG_SHIFT) -#define MULT16_RES_Q15(a,b) MULT16_16_Q15(a,b) -#define MAX_ENCODING_DEPTH 16 -#endif #define RES2VAL16(a) RES2INT16(a) #define INT16TOSIG(a) SHL32(EXTEND32(a), SIG_SHIFT) #define INT24TOSIG(a) SHL32(a, SIG_SHIFT-8) #define NORM_SHIFT 24 -#ifdef ENABLE_QEXT typedef opus_val32 celt_coef; #define COEF_ONE Q31ONE #define MULT_COEF_32(a, b) MULT32_32_P31(a,b) @@ -189,15 +172,6 @@ typedef opus_val32 celt_coef; #define MULT_COEF(a, b) MULT32_32_Q31(a,b) #define MULT_COEF_TAPS(a, b) SHL32(MULT16_16(a,b), 1) #define COEF2VAL16(x) EXTRACT16(SHR32(x, 16)) -#else -typedef opus_val16 celt_coef; -#define COEF_ONE Q15ONE -#define MULT_COEF_32(a, b) MULT16_32_Q15(a,b) -#define MAC_COEF_32_ARM(a, b, c) MAC16_32_Q16(a,b,c) -#define MULT_COEF(a, b) MULT16_16_Q15(a,b) -#define MULT_COEF_TAPS(a, b) MULT16_16_P15(a,b) -#define COEF2VAL16(x) (x) -#endif #define celt_isnan(x) 0 diff --git a/celt/celt_decoder.c b/celt/celt_decoder.c index 184b65921..d5783ff1e 100644 --- a/celt/celt_decoder.c +++ b/celt/celt_decoder.c @@ -1513,12 +1513,6 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat #if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -#if defined(FIXED_POINT) && !defined(ENABLE_RES24) -int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int16 * OPUS_RESTRICT pcm, int frame_size) -{ - return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL, 0); -} -#else int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int16 * OPUS_RESTRICT pcm, int frame_size) { int j, ret, C, N; @@ -1540,9 +1534,8 @@ int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data RESTORE_STACK; return ret; } -#endif -#if defined(FIXED_POINT) && defined(ENABLE_RES24) +#if defined(FIXED_POINT) int opus_custom_decode24(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int32 * OPUS_RESTRICT pcm, int frame_size) { return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL, 0); diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c index 248e977e9..30c374dc1 100644 --- a/celt/celt_encoder.c +++ b/celt/celt_encoder.c @@ -584,45 +584,30 @@ void celt_preemphasis(const opus_res * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTR for (i=0;isignalling==0); #endif - /* Can't produce more than 1275 output bytes for the main payload, plus any QEXT extra data. */ + /* Can't produce more than 1275 output bytes for the main payload. */ nbCompressedBytes = IMIN(nbCompressedBytes,packet_size_cap); if (st->vbr && st->bitrate!=OPUS_BITRATE_MAX) @@ -2673,12 +2658,6 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in #if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -#if defined(FIXED_POINT) && !defined(ENABLE_RES24) -int opus_custom_encode(CELTEncoder * OPUS_RESTRICT st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) -{ - return celt_encode_with_ec(st, pcm, frame_size, compressed, nbCompressedBytes, NULL); -} -#else int opus_custom_encode(CELTEncoder * OPUS_RESTRICT st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) { int j, ret, C, N; @@ -2703,10 +2682,9 @@ int opus_custom_encode(CELTEncoder * OPUS_RESTRICT st, const opus_int16 * pcm, i RESTORE_STACK; return ret; } -#endif -#if defined(FIXED_POINT) && defined(ENABLE_RES24) +#if defined(FIXED_POINT) int opus_custom_encode24(CELTEncoder * OPUS_RESTRICT st, const opus_int32 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) { return celt_encode_with_ec(st, pcm, frame_size, compressed, nbCompressedBytes, NULL); diff --git a/celt/dump_modes/Makefile b/celt/dump_modes/Makefile index c3e7e7ce7..9bd13b07d 100644 --- a/celt/dump_modes/Makefile +++ b/celt/dump_modes/Makefile @@ -12,9 +12,7 @@ SOURCES = dump_modes.c \ ../mathops.c \ ../mdct.c \ ../celt.c \ - ../kiss_fft.c \ - ../quant_bands.c \ - ../laplace.c + ../kiss_fft.c ifdef HAVE_ARM_NE10 CC = gcc diff --git a/celt/dump_modes/dump_modes.c b/celt/dump_modes/dump_modes.c index 849938fdd..7bf845fd5 100644 --- a/celt/dump_modes/dump_modes.c +++ b/celt/dump_modes/dump_modes.c @@ -100,18 +100,8 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) fprintf(file, "#ifndef DEF_WINDOW%d\n", mode->overlap); fprintf(file, "#define DEF_WINDOW%d\n", mode->overlap); fprintf (file, "static const celt_coef window%d[%d] = {\n", mode->overlap, mode->overlap); -#if defined(FIXED_POINT) && defined(ENABLE_QEXT) - fprintf(file, "#ifdef ENABLE_QEXT\n"); for (j=0;joverlap;j++) fprintf (file, WORD32 ",%c", mode->window[j],(j+6)%5==0?'\n':' '); - fprintf(file, "#else\n"); - for (j=0;joverlap;j++) - fprintf (file, WORD16 ",%c", COEF16(mode->window[j], 16),(j+6)%5==0?'\n':' '); - fprintf(file, "#endif\n"); -#else - for (j=0;joverlap;j++) - fprintf (file, WORD16 ",%c", mode->window[j],(j+6)%5==0?'\n':' '); -#endif fprintf (file, "};\n"); fprintf(file, "#endif\n"); fprintf(file, "\n"); @@ -160,46 +150,14 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) fprintf(file, "#endif\n"); fprintf(file, "\n"); - /* QEXT Pulse cache */ - if (mode->qext_cache.index != NULL) { - fprintf(file, "#ifdef ENABLE_QEXT\n"); - fprintf(file, "# ifndef DEF_QEXT_PULSE_CACHE%d\n", mode->Fs/mdctSize); - fprintf(file, "# define DEF_QEXT_PULSE_CACHE%d\n", mode->Fs/mdctSize); - fprintf (file, "static const opus_int16 qext_cache_index%d[%d] = {\n", mode->Fs/mdctSize, (mode->maxLM+2)*NB_QEXT_BANDS); - for (j=0;jmaxLM+2);j++) - fprintf (file, "%d,%c", mode->qext_cache.index[j],(j+16)%15==0?'\n':' '); - fprintf (file, "};\n"); - fprintf (file, "static const unsigned char qext_cache_bits%d[%d] = {\n", mode->Fs/mdctSize, mode->qext_cache.size); - for (j=0;jqext_cache.size;j++) - fprintf (file, "%d,%c", mode->qext_cache.bits[j],(j+16)%15==0?'\n':' '); - fprintf (file, "};\n"); - fprintf (file, "static const unsigned char qext_cache_caps%d[%d] = {\n", mode->Fs/mdctSize, (mode->maxLM+1)*2*NB_QEXT_BANDS); - for (j=0;j<(mode->maxLM+1)*2*NB_QEXT_BANDS;j++) - fprintf (file, "%d,%c", mode->qext_cache.caps[j],(j+16)%15==0?'\n':' '); - fprintf (file, "};\n"); - fprintf(file, "# endif\n"); - fprintf(file, "#endif\n"); - fprintf(file, "\n"); - } - /* FFT twiddles */ fprintf(file, "#ifndef FFT_TWIDDLES%d_%d\n", mode->Fs, mdctSize); fprintf(file, "#define FFT_TWIDDLES%d_%d\n", mode->Fs, mdctSize); fprintf (file, "static const kiss_twiddle_cpx fft_twiddles%d_%d[%d] = {\n", mode->Fs, mdctSize, mode->mdct.kfft[0]->nfft); -#if defined(FIXED_POINT) && defined(ENABLE_QEXT) - fprintf(file, "#ifdef ENABLE_QEXT\n"); for (j=0;jmdct.kfft[0]->nfft;j++) fprintf (file, "{" WORD32 ", " WORD32 "},%c", mode->mdct.kfft[0]->twiddles[j].r, mode->mdct.kfft[0]->twiddles[j].i,(j+3)%2==0?'\n':' '); - fprintf(file, "#else\n"); - for (j=0;jmdct.kfft[0]->nfft;j++) - fprintf (file, "{" WORD16 ", " WORD16 "},%c", COEF16(mode->mdct.kfft[0]->twiddles[j].r,16), COEF16(mode->mdct.kfft[0]->twiddles[j].i,16),(j+3)%2==0?'\n':' '); - fprintf(file, "#endif\n"); -#else - for (j=0;jmdct.kfft[0]->nfft;j++) - fprintf (file, "{" WORD16 ", " WORD16 "},%c", mode->mdct.kfft[0]->twiddles[j].r, mode->mdct.kfft[0]->twiddles[j].i,(j+3)%2==0?'\n':' '); -#endif fprintf (file, "};\n"); #ifdef OVERRIDE_FFT @@ -229,15 +187,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) mode->Fs, mdctSize, k); fprintf (file, "%d, /* nfft */\n", mode->mdct.kfft[k]->nfft); -#if defined(FIXED_POINT) && defined(ENABLE_QEXT) - fprintf(file, "#ifdef ENABLE_QEXT\n"); fprintf (file, WORD32 ", /* scale */\n", mode->mdct.kfft[k]->scale); - fprintf(file, "#else\n"); - fprintf (file, WORD16 ", /* scale */\n", COEF16(mode->mdct.kfft[k]->scale, 15)); - fprintf(file, "#endif\n"); -#else - fprintf (file, WORD16 ", /* scale */\n", mode->mdct.kfft[k]->scale); -#endif #ifdef FIXED_POINT fprintf (file, "%d, /* scale_shift */\n", mode->mdct.kfft[k]->scale_shift); #endif @@ -271,18 +221,8 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) fprintf (file, "static const celt_coef mdct_twiddles%d[%d] = {\n", mdctSize, mdct_twiddles_size); -#if defined(FIXED_POINT) && defined(ENABLE_QEXT) - fprintf(file, "#ifdef ENABLE_QEXT\n"); for (j=0;jmdct.trig[j],(j+6)%5==0?'\n':' '); - fprintf(file, "#else\n"); - for (j=0;jmdct.trig[j], 16),(j+6)%5==0?'\n':' '); - fprintf(file, "#endif\n"); -#else - for (j=0;jmdct.trig[j],(j+6)%5==0?'\n':' '); -#endif fprintf (file, "};\n"); @@ -324,15 +264,6 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) fprintf(file, "{%d, cache_index%d, cache_bits%d, cache_caps%d}, /* cache */\n", mode->cache.size, mode->Fs/mdctSize, mode->Fs/mdctSize, mode->Fs/mdctSize); - - fprintf(file, "#ifdef ENABLE_QEXT\n"); - if (mode->qext_cache.index != NULL) { - fprintf(file, "{%d, qext_cache_index%d, qext_cache_bits%d, qext_cache_caps%d}, /* qext_cache */\n", - mode->qext_cache.size, mode->Fs/mdctSize, mode->Fs/mdctSize, mode->Fs/mdctSize); - } else { - fprintf(file, "{0, NULL, NULL, NULL}, /* qext_cache */\n"); - } - fprintf(file, "#endif\n"); fprintf(file, "};\n"); } fprintf(file, "\n"); diff --git a/celt/kiss_fft.c b/celt/kiss_fft.c index 24400e862..4a6cf15e1 100644 --- a/celt/kiss_fft.c +++ b/celt/kiss_fft.c @@ -416,12 +416,8 @@ static void compute_twiddles(kiss_twiddle_cpx *twiddles, int nfft) #ifdef FIXED_POINT for (i=0;infft=nfft; #ifdef FIXED_POINT st->scale_shift = celt_ilog2(st->nfft); -# ifdef ENABLE_QEXT if (st->nfft == 1<scale_shift) st->scale = QCONST32(1.0f, 30); else st->scale = (((opus_int64)1073741824<scale_shift)+st->nfft/2)/st->nfft; -# else - if (st->nfft == 1<scale_shift) - st->scale = Q15ONE; - else - st->scale = (1073741824+st->nfft/2)/st->nfft>>(15-st->scale_shift); -# endif #else st->scale = 1.f/nfft; #endif diff --git a/celt/kiss_fft.h b/celt/kiss_fft.h index 20eb0b21c..52b9fc7cd 100644 --- a/celt/kiss_fft.h +++ b/celt/kiss_fft.h @@ -46,11 +46,7 @@ #include "arch.h" # define kiss_fft_scalar opus_int32 -# ifdef ENABLE_QEXT -# define COEF_SHIFT 32 -# else -# define COEF_SHIFT 16 -# endif +# define COEF_SHIFT 32 # define kiss_twiddle_scalar celt_coef diff --git a/celt/mathops.h b/celt/mathops.h index 4b6fa15cc..120e2652d 100644 --- a/celt/mathops.h +++ b/celt/mathops.h @@ -97,7 +97,7 @@ static OPUS_INLINE opus_val32 celt_maxabs16(const opus_val16 *x, int len) } #endif -#if defined(ENABLE_RES24) && defined(FIXED_POINT) +#if defined(FIXED_POINT) static OPUS_INLINE opus_res celt_maxabs_res(const opus_res *x, int len) { int i; @@ -186,7 +186,7 @@ static OPUS_INLINE float celt_atan2p_norm(float y, float x) } #endif -#if !defined(FIXED_POINT) || defined(ENABLE_QEXT) +#if !defined(FIXED_POINT) /* Computes estimated cosine values for (PI/2 * x) using only terms with even * exponents. */ static OPUS_INLINE float celt_cos_norm2(float x) @@ -441,8 +441,6 @@ static OPUS_INLINE opus_val32 celt_exp2(opus_val16 x) return VSHR32(EXTEND32(frac), -integer-2); } -#ifdef ENABLE_QEXT - /* Calculates the base-2 logarithm of a Q14 input value. The result is returned * in Q(DB_SHIFT). If the input value is 0, the function will output -32.0f. */ static OPUS_INLINE opus_val32 celt_log2_db(opus_val32 x) { @@ -524,13 +522,7 @@ static OPUS_INLINE opus_val32 celt_exp2_db(opus_val32 x) frac = celt_exp2_db_frac(x-SHL32(integer, DB_SHIFT)); /* Q28 */ return VSHR32(frac, -integer + 28 - 16); /* Q16 */ } -#else -#define celt_log2_db(x) SHL32(EXTEND32(celt_log2(x)), DB_SHIFT-10) -#define celt_exp2_db_frac(x) SHL32(celt_exp2_frac(PSHR32(x, DB_SHIFT-10)), 14) -#define celt_exp2_db(x) celt_exp2(PSHR32(x, DB_SHIFT-10)) - -#endif opus_val32 celt_rcp(opus_val32 x); diff --git a/celt/mdct.c b/celt/mdct.c index 2b8a0bce9..153712b2e 100644 --- a/celt/mdct.c +++ b/celt/mdct.c @@ -89,13 +89,8 @@ int clt_mdct_init(mdct_lookup *l,int N, int maxshift, int arch) { /* We have enough points that sine isn't necessary */ #if defined(FIXED_POINT) -#ifndef ENABLE_QEXT - for (i=0;ii,t1) - S_MUL(fp->r,t0), headroom); yi = PSHR32(S_MUL(fp->r,t1) + S_MUL(fp->i,t0), headroom); *yp1 = yr; diff --git a/celt/modes.c b/celt/modes.c index 74d096b5d..ff1284737 100644 --- a/celt/modes.c +++ b/celt/modes.c @@ -391,13 +391,8 @@ CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) for (i=0;ioverlap;i++) window[i] = Q15ONE*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap)); #else -# ifdef ENABLE_QEXT for (i=0;ioverlap;i++) window[i] = MIN32(2147483647, 2147483648*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap))); -# else - for (i=0;ioverlap;i++) - window[i] = MIN32(32767,floor(.5+32768.*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap)))); -# endif #endif mode->window = window; diff --git a/celt/static_modes_fixed.h b/celt/static_modes_fixed.h index ac3340e13..ea3b89b13 100644 --- a/celt/static_modes_fixed.h +++ b/celt/static_modes_fixed.h @@ -12,7 +12,6 @@ #ifndef DEF_WINDOW120 #define DEF_WINDOW120 static const celt_coef window120[120] = { -#ifdef ENABLE_QEXT 144497, 1300330, 3611201, 7075520, 11690888, 17454086, 24361057, 32406886, 41585775, 51891010, 63314937, 75848919, 89483305, 104207389, 120009370, @@ -37,32 +36,6 @@ static const celt_coef window120[120] = { 2144127740, 2144953807, 2145618502, 2146143741, 2146550077, 2146856618, 2147080958, 2147239113, 2147345467, 2147412716, 2147451825, 2147471991, 2147480611, 2147483254, 2147483643, -#else -2, 20, 55, 108, 178, -266, 372, 494, 635, 792, -966, 1157, 1365, 1590, 1831, -2089, 2362, 2651, 2956, 3276, -3611, 3961, 4325, 4703, 5094, -5499, 5916, 6346, 6788, 7241, -7705, 8179, 8663, 9156, 9657, -10167, 10684, 11207, 11736, 12271, -12810, 13353, 13899, 14447, 14997, -15547, 16098, 16648, 17197, 17744, -18287, 18827, 19363, 19893, 20418, -20936, 21447, 21950, 22445, 22931, -23407, 23874, 24330, 24774, 25208, -25629, 26039, 26435, 26819, 27190, -27548, 27893, 28224, 28541, 28845, -29135, 29411, 29674, 29924, 30160, -30384, 30594, 30792, 30977, 31151, -31313, 31463, 31602, 31731, 31849, -31958, 32057, 32148, 32229, 32303, -32370, 32429, 32481, 32528, 32568, -32604, 32634, 32661, 32683, 32701, -32717, 32729, 32740, 32748, 32754, -32758, 32762, 32764, 32766, 32767, -32767, 32767, 32767, 32767, 32767, -#endif }; #endif @@ -129,7 +102,6 @@ static const unsigned char cache_caps50[168] = { #ifndef FFT_TWIDDLES48000_960 #define FFT_TWIDDLES48000_960 static const kiss_twiddle_cpx fft_twiddles48000_960[480] = { -#ifdef ENABLE_QEXT {2147483647, 0}, {2147299668, -28109692}, {2146747759, -56214568}, {2145828016, -84309812}, {2144540596, -112390610}, {2142885721, -140452151}, @@ -370,248 +342,6 @@ static const kiss_twiddle_cpx fft_twiddles48000_960[480] = { {2140863673, 168489625}, {2142885721, 140452151}, {2144540596, 112390610}, {2145828016, 84309812}, {2146747759, 56214568}, {2147299668, 28109692}, -#else -{32767, 0}, {32765, -429}, -{32757, -858}, {32743, -1286}, -{32723, -1715}, {32698, -2143}, -{32667, -2571}, {32631, -2998}, -{32588, -3425}, {32541, -3851}, -{32488, -4277}, {32429, -4702}, -{32365, -5126}, {32295, -5549}, -{32219, -5971}, {32138, -6393}, -{32052, -6813}, {31960, -7232}, -{31863, -7650}, {31760, -8066}, -{31651, -8481}, {31538, -8895}, -{31419, -9307}, {31294, -9717}, -{31164, -10126}, {31029, -10533}, -{30888, -10938}, {30743, -11342}, -{30592, -11743}, {30435, -12142}, -{30274, -12540}, {30107, -12935}, -{29935, -13328}, {29758, -13719}, -{29576, -14107}, {29389, -14493}, -{29197, -14876}, {28999, -15257}, -{28797, -15636}, {28590, -16011}, -{28378, -16384}, {28161, -16754}, -{27939, -17121}, {27713, -17485}, -{27482, -17847}, {27246, -18205}, -{27005, -18560}, {26760, -18912}, -{26510, -19261}, {26255, -19606}, -{25997, -19948}, {25733, -20286}, -{25466, -20622}, {25193, -20953}, -{24917, -21281}, {24636, -21605}, -{24351, -21926}, {24062, -22243}, -{23769, -22556}, {23472, -22865}, -{23170, -23170}, {22865, -23472}, -{22556, -23769}, {22243, -24062}, -{21926, -24351}, {21605, -24636}, -{21281, -24917}, {20953, -25193}, -{20622, -25466}, {20286, -25733}, -{19948, -25997}, {19606, -26255}, -{19261, -26510}, {18912, -26760}, -{18560, -27005}, {18205, -27246}, -{17847, -27482}, {17485, -27713}, -{17121, -27939}, {16754, -28161}, -{16384, -28378}, {16011, -28590}, -{15636, -28797}, {15257, -28999}, -{14876, -29197}, {14493, -29389}, -{14107, -29576}, {13719, -29758}, -{13328, -29935}, {12935, -30107}, -{12540, -30274}, {12142, -30435}, -{11743, -30592}, {11342, -30743}, -{10938, -30888}, {10533, -31029}, -{10126, -31164}, {9717, -31294}, -{9307, -31419}, {8895, -31538}, -{8481, -31651}, {8066, -31760}, -{7650, -31863}, {7232, -31960}, -{6813, -32052}, {6393, -32138}, -{5971, -32219}, {5549, -32295}, -{5126, -32365}, {4702, -32429}, -{4277, -32488}, {3851, -32541}, -{3425, -32588}, {2998, -32631}, -{2571, -32667}, {2143, -32698}, -{1715, -32723}, {1286, -32743}, -{858, -32757}, {429, -32765}, -{0, -32767}, {-429, -32765}, -{-858, -32757}, {-1286, -32743}, -{-1715, -32723}, {-2143, -32698}, -{-2571, -32667}, {-2998, -32631}, -{-3425, -32588}, {-3851, -32541}, -{-4277, -32488}, {-4702, -32429}, -{-5126, -32365}, {-5549, -32295}, -{-5971, -32219}, {-6393, -32138}, -{-6813, -32052}, {-7232, -31960}, -{-7650, -31863}, {-8066, -31760}, -{-8481, -31651}, {-8895, -31538}, -{-9307, -31419}, {-9717, -31294}, -{-10126, -31164}, {-10533, -31029}, -{-10938, -30888}, {-11342, -30743}, -{-11743, -30592}, {-12142, -30435}, -{-12540, -30274}, {-12935, -30107}, -{-13328, -29935}, {-13719, -29758}, -{-14107, -29576}, {-14493, -29389}, -{-14876, -29197}, {-15257, -28999}, -{-15636, -28797}, {-16011, -28590}, -{-16384, -28378}, {-16754, -28161}, -{-17121, -27939}, {-17485, -27713}, -{-17847, -27482}, {-18205, -27246}, -{-18560, -27005}, {-18912, -26760}, -{-19261, -26510}, {-19606, -26255}, -{-19948, -25997}, {-20286, -25733}, -{-20622, -25466}, {-20953, -25193}, -{-21281, -24917}, {-21605, -24636}, -{-21926, -24351}, {-22243, -24062}, -{-22556, -23769}, {-22865, -23472}, -{-23170, -23170}, {-23472, -22865}, -{-23769, -22556}, {-24062, -22243}, -{-24351, -21926}, {-24636, -21605}, -{-24917, -21281}, {-25193, -20953}, -{-25466, -20622}, {-25733, -20286}, -{-25997, -19948}, {-26255, -19606}, -{-26510, -19261}, {-26760, -18912}, -{-27005, -18560}, {-27246, -18205}, -{-27482, -17847}, {-27713, -17485}, -{-27939, -17121}, {-28161, -16754}, -{-28378, -16384}, {-28590, -16011}, -{-28797, -15636}, {-28999, -15257}, -{-29197, -14876}, {-29389, -14493}, -{-29576, -14107}, {-29758, -13719}, -{-29935, -13328}, {-30107, -12935}, -{-30274, -12540}, {-30435, -12142}, -{-30592, -11743}, {-30743, -11342}, -{-30888, -10938}, {-31029, -10533}, -{-31164, -10126}, {-31294, -9717}, -{-31419, -9307}, {-31538, -8895}, -{-31651, -8481}, {-31760, -8066}, -{-31863, -7650}, {-31960, -7232}, -{-32052, -6813}, {-32138, -6393}, -{-32219, -5971}, {-32295, -5549}, -{-32365, -5126}, {-32429, -4702}, -{-32488, -4277}, {-32541, -3851}, -{-32588, -3425}, {-32631, -2998}, -{-32667, -2571}, {-32698, -2143}, -{-32723, -1715}, {-32743, -1286}, -{-32757, -858}, {-32765, -429}, -{-32767, 0}, {-32765, 429}, -{-32757, 858}, {-32743, 1286}, -{-32723, 1715}, {-32698, 2143}, -{-32667, 2571}, {-32631, 2998}, -{-32588, 3425}, {-32541, 3851}, -{-32488, 4277}, {-32429, 4702}, -{-32365, 5126}, {-32295, 5549}, -{-32219, 5971}, {-32138, 6393}, -{-32052, 6813}, {-31960, 7232}, -{-31863, 7650}, {-31760, 8066}, -{-31651, 8481}, {-31538, 8895}, -{-31419, 9307}, {-31294, 9717}, -{-31164, 10126}, {-31029, 10533}, -{-30888, 10938}, {-30743, 11342}, -{-30592, 11743}, {-30435, 12142}, -{-30274, 12540}, {-30107, 12935}, -{-29935, 13328}, {-29758, 13719}, -{-29576, 14107}, {-29389, 14493}, -{-29197, 14876}, {-28999, 15257}, -{-28797, 15636}, {-28590, 16011}, -{-28378, 16384}, {-28161, 16754}, -{-27939, 17121}, {-27713, 17485}, -{-27482, 17847}, {-27246, 18205}, -{-27005, 18560}, {-26760, 18912}, -{-26510, 19261}, {-26255, 19606}, -{-25997, 19948}, {-25733, 20286}, -{-25466, 20622}, {-25193, 20953}, -{-24917, 21281}, {-24636, 21605}, -{-24351, 21926}, {-24062, 22243}, -{-23769, 22556}, {-23472, 22865}, -{-23170, 23170}, {-22865, 23472}, -{-22556, 23769}, {-22243, 24062}, -{-21926, 24351}, {-21605, 24636}, -{-21281, 24917}, {-20953, 25193}, -{-20622, 25466}, {-20286, 25733}, -{-19948, 25997}, {-19606, 26255}, -{-19261, 26510}, {-18912, 26760}, -{-18560, 27005}, {-18205, 27246}, -{-17847, 27482}, {-17485, 27713}, -{-17121, 27939}, {-16754, 28161}, -{-16384, 28378}, {-16011, 28590}, -{-15636, 28797}, {-15257, 28999}, -{-14876, 29197}, {-14493, 29389}, -{-14107, 29576}, {-13719, 29758}, -{-13328, 29935}, {-12935, 30107}, -{-12540, 30274}, {-12142, 30435}, -{-11743, 30592}, {-11342, 30743}, -{-10938, 30888}, {-10533, 31029}, -{-10126, 31164}, {-9717, 31294}, -{-9307, 31419}, {-8895, 31538}, -{-8481, 31651}, {-8066, 31760}, -{-7650, 31863}, {-7232, 31960}, -{-6813, 32052}, {-6393, 32138}, -{-5971, 32219}, {-5549, 32295}, -{-5126, 32365}, {-4702, 32429}, -{-4277, 32488}, {-3851, 32541}, -{-3425, 32588}, {-2998, 32631}, -{-2571, 32667}, {-2143, 32698}, -{-1715, 32723}, {-1286, 32743}, -{-858, 32757}, {-429, 32765}, -{0, 32767}, {429, 32765}, -{858, 32757}, {1286, 32743}, -{1715, 32723}, {2143, 32698}, -{2571, 32667}, {2998, 32631}, -{3425, 32588}, {3851, 32541}, -{4277, 32488}, {4702, 32429}, -{5126, 32365}, {5549, 32295}, -{5971, 32219}, {6393, 32138}, -{6813, 32052}, {7232, 31960}, -{7650, 31863}, {8066, 31760}, -{8481, 31651}, {8895, 31538}, -{9307, 31419}, {9717, 31294}, -{10126, 31164}, {10533, 31029}, -{10938, 30888}, {11342, 30743}, -{11743, 30592}, {12142, 30435}, -{12540, 30274}, {12935, 30107}, -{13328, 29935}, {13719, 29758}, -{14107, 29576}, {14493, 29389}, -{14876, 29197}, {15257, 28999}, -{15636, 28797}, {16011, 28590}, -{16384, 28378}, {16754, 28161}, -{17121, 27939}, {17485, 27713}, -{17847, 27482}, {18205, 27246}, -{18560, 27005}, {18912, 26760}, -{19261, 26510}, {19606, 26255}, -{19948, 25997}, {20286, 25733}, -{20622, 25466}, {20953, 25193}, -{21281, 24917}, {21605, 24636}, -{21926, 24351}, {22243, 24062}, -{22556, 23769}, {22865, 23472}, -{23170, 23170}, {23472, 22865}, -{23769, 22556}, {24062, 22243}, -{24351, 21926}, {24636, 21605}, -{24917, 21281}, {25193, 20953}, -{25466, 20622}, {25733, 20286}, -{25997, 19948}, {26255, 19606}, -{26510, 19261}, {26760, 18912}, -{27005, 18560}, {27246, 18205}, -{27482, 17847}, {27713, 17485}, -{27939, 17121}, {28161, 16754}, -{28378, 16384}, {28590, 16011}, -{28797, 15636}, {28999, 15257}, -{29197, 14876}, {29389, 14493}, -{29576, 14107}, {29758, 13719}, -{29935, 13328}, {30107, 12935}, -{30274, 12540}, {30435, 12142}, -{30592, 11743}, {30743, 11342}, -{30888, 10938}, {31029, 10533}, -{31164, 10126}, {31294, 9717}, -{31419, 9307}, {31538, 8895}, -{31651, 8481}, {31760, 8066}, -{31863, 7650}, {31960, 7232}, -{32052, 6813}, {32138, 6393}, -{32219, 5971}, {32295, 5549}, -{32365, 5126}, {32429, 4702}, -{32488, 4277}, {32541, 3851}, -{32588, 3425}, {32631, 2998}, -{32667, 2571}, {32698, 2143}, -{32723, 1715}, {32743, 1286}, -{32757, 858}, {32765, 429}, -#endif }; #ifndef FFT_BITREV480 #define FFT_BITREV480 @@ -701,11 +431,7 @@ static const opus_int16 fft_bitrev60[60] = { #define FFT_STATE48000_960_0 static const kiss_fft_state fft_state48000_960_0 = { 480, /* nfft */ -#ifdef ENABLE_QEXT 572662306, /* scale */ -#else -17476, /* scale */ -#endif 8, /* scale_shift */ -1, /* shift */ {5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ @@ -723,11 +449,7 @@ NULL, #define FFT_STATE48000_960_1 static const kiss_fft_state fft_state48000_960_1 = { 240, /* nfft */ -#ifdef ENABLE_QEXT 572662306, /* scale */ -#else -17476, /* scale */ -#endif 7, /* scale_shift */ 1, /* shift */ {5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ @@ -745,11 +467,7 @@ NULL, #define FFT_STATE48000_960_2 static const kiss_fft_state fft_state48000_960_2 = { 120, /* nfft */ -#ifdef ENABLE_QEXT 572662306, /* scale */ -#else -17476, /* scale */ -#endif 6, /* scale_shift */ 2, /* shift */ {5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ @@ -767,11 +485,7 @@ NULL, #define FFT_STATE48000_960_3 static const kiss_fft_state fft_state48000_960_3 = { 60, /* nfft */ -#ifdef ENABLE_QEXT 572662306, /* scale */ -#else -17476, /* scale */ -#endif 5, /* scale_shift */ 3, /* shift */ {5, 12, 3, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ @@ -790,7 +504,6 @@ NULL, #ifndef MDCT_TWIDDLES960 #define MDCT_TWIDDLES960 static const celt_coef mdct_twiddles960[1800] = { -#ifdef ENABLE_QEXT 2147483468, 2147469095, 2147431723, 2147371355, 2147287990, 2147181629, 2147052273, 2146899924, 2146724584, 2146526254, 2146304937, 2146060634, 2145793349, 2145503083, 2145189842, @@ -1151,368 +864,6 @@ static const celt_coef mdct_twiddles960[1800] = { -1986694916, -2007356435, -2026642214, -2044539032, -2061034626, -2076117690, -2089777886, -2102005853, -2112793210, -2122132564, -2130017514, -2136442657, -2141403589, -2144896910, -2146920225, -#else -32767, 32767, 32767, 32766, 32765, -32763, 32761, 32759, 32756, 32753, -32750, 32746, 32742, 32738, 32733, -32728, 32722, 32717, 32710, 32704, -32697, 32690, 32682, 32674, 32666, -32657, 32648, 32639, 32629, 32619, -32609, 32598, 32587, 32576, 32564, -32552, 32539, 32526, 32513, 32500, -32486, 32472, 32457, 32442, 32427, -32411, 32395, 32379, 32362, 32345, -32328, 32310, 32292, 32274, 32255, -32236, 32217, 32197, 32177, 32157, -32136, 32115, 32093, 32071, 32049, -32027, 32004, 31981, 31957, 31933, -31909, 31884, 31859, 31834, 31809, -31783, 31756, 31730, 31703, 31676, -31648, 31620, 31592, 31563, 31534, -31505, 31475, 31445, 31415, 31384, -31353, 31322, 31290, 31258, 31226, -31193, 31160, 31127, 31093, 31059, -31025, 30990, 30955, 30920, 30884, -30848, 30812, 30775, 30738, 30701, -30663, 30625, 30587, 30548, 30509, -30470, 30430, 30390, 30350, 30309, -30269, 30227, 30186, 30144, 30102, -30059, 30016, 29973, 29930, 29886, -29842, 29797, 29752, 29707, 29662, -29616, 29570, 29524, 29477, 29430, -29383, 29335, 29287, 29239, 29190, -29142, 29092, 29043, 28993, 28943, -28892, 28842, 28791, 28739, 28688, -28636, 28583, 28531, 28478, 28425, -28371, 28317, 28263, 28209, 28154, -28099, 28044, 27988, 27932, 27876, -27820, 27763, 27706, 27648, 27591, -27533, 27474, 27416, 27357, 27298, -27238, 27178, 27118, 27058, 26997, -26936, 26875, 26814, 26752, 26690, -26628, 26565, 26502, 26439, 26375, -26312, 26247, 26183, 26119, 26054, -25988, 25923, 25857, 25791, 25725, -25658, 25592, 25524, 25457, 25389, -25322, 25253, 25185, 25116, 25047, -24978, 24908, 24838, 24768, 24698, -24627, 24557, 24485, 24414, 24342, -24270, 24198, 24126, 24053, 23980, -23907, 23834, 23760, 23686, 23612, -23537, 23462, 23387, 23312, 23237, -23161, 23085, 23009, 22932, 22856, -22779, 22701, 22624, 22546, 22468, -22390, 22312, 22233, 22154, 22075, -21996, 21916, 21836, 21756, 21676, -21595, 21515, 21434, 21352, 21271, -21189, 21107, 21025, 20943, 20860, -20777, 20694, 20611, 20528, 20444, -20360, 20276, 20192, 20107, 20022, -19937, 19852, 19767, 19681, 19595, -19509, 19423, 19336, 19250, 19163, -19076, 18988, 18901, 18813, 18725, -18637, 18549, 18460, 18372, 18283, -18194, 18104, 18015, 17925, 17835, -17745, 17655, 17565, 17474, 17383, -17292, 17201, 17110, 17018, 16927, -16835, 16743, 16650, 16558, 16465, -16372, 16279, 16186, 16093, 15999, -15906, 15812, 15718, 15624, 15529, -15435, 15340, 15245, 15150, 15055, -14960, 14864, 14769, 14673, 14577, -14481, 14385, 14288, 14192, 14095, -13998, 13901, 13804, 13706, 13609, -13511, 13414, 13316, 13218, 13119, -13021, 12923, 12824, 12725, 12626, -12527, 12428, 12329, 12230, 12130, -12030, 11930, 11831, 11730, 11630, -11530, 11430, 11329, 11228, 11128, -11027, 10926, 10824, 10723, 10622, -10520, 10419, 10317, 10215, 10113, -10011, 9909, 9807, 9704, 9602, -9499, 9397, 9294, 9191, 9088, -8985, 8882, 8778, 8675, 8572, -8468, 8364, 8261, 8157, 8053, -7949, 7845, 7741, 7637, 7532, -7428, 7323, 7219, 7114, 7009, -6905, 6800, 6695, 6590, 6485, -6380, 6274, 6169, 6064, 5958, -5853, 5747, 5642, 5536, 5430, -5325, 5219, 5113, 5007, 4901, -4795, 4689, 4583, 4476, 4370, -4264, 4157, 4051, 3945, 3838, -3732, 3625, 3518, 3412, 3305, -3198, 3092, 2985, 2878, 2771, -2664, 2558, 2451, 2344, 2237, -2130, 2023, 1916, 1809, 1702, -1594, 1487, 1380, 1273, 1166, -1059, 952, 844, 737, 630, -523, 416, 308, 201, 94, --13, -121, -228, -335, -442, --550, -657, -764, -871, -978, --1086, -1193, -1300, -1407, -1514, --1621, -1728, -1835, -1942, -2049, --2157, -2263, -2370, -2477, -2584, --2691, -2798, -2905, -3012, -3118, --3225, -3332, -3439, -3545, -3652, --3758, -3865, -3971, -4078, -4184, --4290, -4397, -4503, -4609, -4715, --4821, -4927, -5033, -5139, -5245, --5351, -5457, -5562, -5668, -5774, --5879, -5985, -6090, -6195, -6301, --6406, -6511, -6616, -6721, -6826, --6931, -7036, -7140, -7245, -7349, --7454, -7558, -7663, -7767, -7871, --7975, -8079, -8183, -8287, -8390, --8494, -8597, -8701, -8804, -8907, --9011, -9114, -9217, -9319, -9422, --9525, -9627, -9730, -9832, -9934, --10037, -10139, -10241, -10342, -10444, --10546, -10647, -10748, -10850, -10951, --11052, -11153, -11253, -11354, -11455, --11555, -11655, -11756, -11856, -11955, --12055, -12155, -12254, -12354, -12453, --12552, -12651, -12750, -12849, -12947, --13046, -13144, -13242, -13340, -13438, --13536, -13633, -13731, -13828, -13925, --14022, -14119, -14216, -14312, -14409, --14505, -14601, -14697, -14793, -14888, --14984, -15079, -15174, -15269, -15364, --15459, -15553, -15647, -15741, -15835, --15929, -16023, -16116, -16210, -16303, --16396, -16488, -16581, -16673, -16766, --16858, -16949, -17041, -17133, -17224, --17315, -17406, -17497, -17587, -17678, --17768, -17858, -17948, -18037, -18127, --18216, -18305, -18394, -18483, -18571, --18659, -18747, -18835, -18923, -19010, --19098, -19185, -19271, -19358, -19444, --19531, -19617, -19702, -19788, -19873, --19959, -20043, -20128, -20213, -20297, --20381, -20465, -20549, -20632, -20715, --20798, -20881, -20963, -21046, -21128, --21210, -21291, -21373, -21454, -21535, --21616, -21696, -21776, -21856, -21936, --22016, -22095, -22174, -22253, -22331, --22410, -22488, -22566, -22643, -22721, --22798, -22875, -22951, -23028, -23104, --23180, -23256, -23331, -23406, -23481, --23556, -23630, -23704, -23778, -23852, --23925, -23998, -24071, -24144, -24216, --24288, -24360, -24432, -24503, -24574, --24645, -24716, -24786, -24856, -24926, --24995, -25064, -25133, -25202, -25270, --25339, -25406, -25474, -25541, -25608, --25675, -25742, -25808, -25874, -25939, --26005, -26070, -26135, -26199, -26264, --26327, -26391, -26455, -26518, -26581, --26643, -26705, -26767, -26829, -26891, --26952, -27013, -27073, -27133, -27193, --27253, -27312, -27372, -27430, -27489, --27547, -27605, -27663, -27720, -27777, --27834, -27890, -27946, -28002, -28058, --28113, -28168, -28223, -28277, -28331, --28385, -28438, -28491, -28544, -28596, --28649, -28701, -28752, -28803, -28854, --28905, -28955, -29006, -29055, -29105, --29154, -29203, -29251, -29299, -29347, --29395, -29442, -29489, -29535, -29582, --29628, -29673, -29719, -29764, -29808, --29853, -29897, -29941, -29984, -30027, --30070, -30112, -30154, -30196, -30238, --30279, -30320, -30360, -30400, -30440, --30480, -30519, -30558, -30596, -30635, --30672, -30710, -30747, -30784, -30821, --30857, -30893, -30929, -30964, -30999, --31033, -31068, -31102, -31135, -31168, --31201, -31234, -31266, -31298, -31330, --31361, -31392, -31422, -31453, -31483, --31512, -31541, -31570, -31599, -31627, --31655, -31682, -31710, -31737, -31763, --31789, -31815, -31841, -31866, -31891, --31915, -31939, -31963, -31986, -32010, --32032, -32055, -32077, -32099, -32120, --32141, -32162, -32182, -32202, -32222, --32241, -32260, -32279, -32297, -32315, --32333, -32350, -32367, -32383, -32399, --32415, -32431, -32446, -32461, -32475, --32489, -32503, -32517, -32530, -32542, --32555, -32567, -32579, -32590, -32601, --32612, -32622, -32632, -32641, -32651, --32659, -32668, -32676, -32684, -32692, --32699, -32706, -32712, -32718, -32724, --32729, -32734, -32739, -32743, -32747, --32751, -32754, -32757, -32760, -32762, --32764, -32765, -32767, -32767, -32767, -32767, 32767, 32765, 32761, 32756, -32750, 32742, 32732, 32722, 32710, -32696, 32681, 32665, 32647, 32628, -32608, 32586, 32562, 32538, 32512, -32484, 32455, 32425, 32393, 32360, -32326, 32290, 32253, 32214, 32174, -32133, 32090, 32046, 32001, 31954, -31906, 31856, 31805, 31753, 31700, -31645, 31588, 31530, 31471, 31411, -31349, 31286, 31222, 31156, 31089, -31020, 30951, 30880, 30807, 30733, -30658, 30582, 30504, 30425, 30345, -30263, 30181, 30096, 30011, 29924, -29836, 29747, 29656, 29564, 29471, -29377, 29281, 29184, 29086, 28987, -28886, 28784, 28681, 28577, 28471, -28365, 28257, 28147, 28037, 27925, -27812, 27698, 27583, 27467, 27349, -27231, 27111, 26990, 26868, 26744, -26620, 26494, 26367, 26239, 26110, -25980, 25849, 25717, 25583, 25449, -25313, 25176, 25038, 24900, 24760, -24619, 24477, 24333, 24189, 24044, -23898, 23751, 23602, 23453, 23303, -23152, 22999, 22846, 22692, 22537, -22380, 22223, 22065, 21906, 21746, -21585, 21423, 21261, 21097, 20933, -20767, 20601, 20434, 20265, 20096, -19927, 19756, 19584, 19412, 19239, -19065, 18890, 18714, 18538, 18361, -18183, 18004, 17824, 17644, 17463, -17281, 17098, 16915, 16731, 16546, -16361, 16175, 15988, 15800, 15612, -15423, 15234, 15043, 14852, 14661, -14469, 14276, 14083, 13889, 13694, -13499, 13303, 13107, 12910, 12713, -12515, 12317, 12118, 11918, 11718, -11517, 11316, 11115, 10913, 10710, -10508, 10304, 10100, 9896, 9691, -9486, 9281, 9075, 8869, 8662, -8455, 8248, 8040, 7832, 7623, -7415, 7206, 6996, 6787, 6577, -6366, 6156, 5945, 5734, 5523, -5311, 5100, 4888, 4675, 4463, -4251, 4038, 3825, 3612, 3399, -3185, 2972, 2758, 2544, 2330, -2116, 1902, 1688, 1474, 1260, -1045, 831, 617, 402, 188, --27, -241, -456, -670, -885, --1099, -1313, -1528, -1742, -1956, --2170, -2384, -2598, -2811, -3025, --3239, -3452, -3665, -3878, -4091, --4304, -4516, -4728, -4941, -5153, --5364, -5576, -5787, -5998, -6209, --6419, -6629, -6839, -7049, -7258, --7467, -7676, -7884, -8092, -8300, --8507, -8714, -8920, -9127, -9332, --9538, -9743, -9947, -10151, -10355, --10558, -10761, -10963, -11165, -11367, --11568, -11768, -11968, -12167, -12366, --12565, -12762, -12960, -13156, -13352, --13548, -13743, -13937, -14131, -14324, --14517, -14709, -14900, -15091, -15281, --15470, -15659, -15847, -16035, -16221, --16407, -16593, -16777, -16961, -17144, --17326, -17508, -17689, -17869, -18049, --18227, -18405, -18582, -18758, -18934, --19108, -19282, -19455, -19627, -19799, --19969, -20139, -20308, -20475, -20642, --20809, -20974, -21138, -21301, -21464, --21626, -21786, -21946, -22105, -22263, --22420, -22575, -22730, -22884, -23037, --23189, -23340, -23490, -23640, -23788, --23935, -24080, -24225, -24369, -24512, --24654, -24795, -24934, -25073, -25211, --25347, -25482, -25617, -25750, -25882, --26013, -26143, -26272, -26399, -26526, --26651, -26775, -26898, -27020, -27141, --27260, -27379, -27496, -27612, -27727, --27841, -27953, -28065, -28175, -28284, --28391, -28498, -28603, -28707, -28810, --28911, -29012, -29111, -29209, -29305, --29401, -29495, -29587, -29679, -29769, --29858, -29946, -30032, -30118, -30201, --30284, -30365, -30445, -30524, -30601, --30677, -30752, -30825, -30897, -30968, --31038, -31106, -31172, -31238, -31302, --31365, -31426, -31486, -31545, -31602, --31658, -31713, -31766, -31818, -31869, --31918, -31966, -32012, -32058, -32101, --32144, -32185, -32224, -32262, -32299, --32335, -32369, -32401, -32433, -32463, --32491, -32518, -32544, -32568, -32591, --32613, -32633, -32652, -32669, -32685, --32700, -32713, -32724, -32735, -32744, --32751, -32757, -32762, -32766, -32767, -32767, 32764, 32755, 32741, 32720, -32694, 32663, 32626, 32583, 32535, -32481, 32421, 32356, 32286, 32209, -32128, 32041, 31948, 31850, 31747, -31638, 31523, 31403, 31278, 31148, -31012, 30871, 30724, 30572, 30415, -30253, 30086, 29913, 29736, 29553, -29365, 29172, 28974, 28771, 28564, -28351, 28134, 27911, 27684, 27452, -27216, 26975, 26729, 26478, 26223, -25964, 25700, 25432, 25159, 24882, -24601, 24315, 24026, 23732, 23434, -23133, 22827, 22517, 22204, 21886, -21565, 21240, 20912, 20580, 20244, -19905, 19563, 19217, 18868, 18516, -18160, 17802, 17440, 17075, 16708, -16338, 15964, 15588, 15210, 14829, -14445, 14059, 13670, 13279, 12886, -12490, 12093, 11693, 11291, 10888, -10482, 10075, 9666, 9255, 8843, -8429, 8014, 7597, 7180, 6760, -6340, 5919, 5496, 5073, 4649, -4224, 3798, 3372, 2945, 2517, -2090, 1661, 1233, 804, 375, --54, -483, -911, -1340, -1768, --2197, -2624, -3052, -3479, -3905, --4330, -4755, -5179, -5602, -6024, --6445, -6865, -7284, -7702, -8118, --8533, -8946, -9358, -9768, -10177, --10584, -10989, -11392, -11793, -12192, --12589, -12984, -13377, -13767, -14155, --14541, -14924, -15305, -15683, -16058, --16430, -16800, -17167, -17531, -17892, --18249, -18604, -18956, -19304, -19649, --19990, -20329, -20663, -20994, -21322, --21646, -21966, -22282, -22595, -22904, --23208, -23509, -23806, -24099, -24387, --24672, -24952, -25228, -25499, -25766, --26029, -26288, -26541, -26791, -27035, --27275, -27511, -27741, -27967, -28188, --28405, -28616, -28823, -29024, -29221, --29412, -29599, -29780, -29957, -30128, --30294, -30455, -30611, -30761, -30906, --31046, -31181, -31310, -31434, -31552, --31665, -31773, -31875, -31972, -32063, --32149, -32229, -32304, -32373, -32437, --32495, -32547, -32594, -32635, -32671, --32701, -32726, -32745, -32758, -32766, -32767, 32754, 32717, 32658, 32577, -32473, 32348, 32200, 32029, 31837, -31624, 31388, 31131, 30853, 30553, -30232, 29891, 29530, 29148, 28746, -28324, 27883, 27423, 26944, 26447, -25931, 25398, 24847, 24279, 23695, -23095, 22478, 21846, 21199, 20538, -19863, 19174, 18472, 17757, 17030, -16291, 15541, 14781, 14010, 13230, -12441, 11643, 10837, 10024, 9204, -8377, 7545, 6708, 5866, 5020, -4171, 3319, 2464, 1608, 751, --107, -965, -1822, -2678, -3532, --4383, -5232, -6077, -6918, -7754, --8585, -9409, -10228, -11039, -11843, --12639, -13426, -14204, -14972, -15730, --16477, -17213, -17937, -18648, -19347, --20033, -20705, -21363, -22006, -22634, --23246, -23843, -24423, -24986, -25533, --26062, -26573, -27066, -27540, -27995, --28431, -28848, -29245, -29622, -29979, --30315, -30630, -30924, -31197, -31449, --31679, -31887, -32074, -32239, -32381, --32501, -32600, -32675, -32729, -32759, -#endif }; #endif @@ -1538,7 +889,6 @@ window120, /* window */ #ifndef DEF_WINDOW240 #define DEF_WINDOW240 static const celt_coef window240[240] = { -#ifdef ENABLE_QEXT 36124, 325113, 903042, 1769811, 2925272, 4369225, 6101422, 8121563, 10429297, 13024223, 15905885, 19073777, 22527339, 26265958, 30288963, @@ -1587,56 +937,6 @@ static const celt_coef window240[240] = { 2147270033, 2147323012, 2147365487, 2147398940, 2147424741, 2147444152, 2147458322, 2147468290, 2147474980, 2147479203, 2147481655, 2147482918, 2147483458, 2147483623, 2147483647, -#else -1, 5, 14, 27, 45, -67, 93, 124, 159, 199, -243, 291, 344, 401, 462, -528, 598, 672, 751, 834, -921, 1012, 1108, 1208, 1312, -1420, 1532, 1649, 1769, 1894, -2023, 2155, 2292, 2433, 2577, -2726, 2878, 3035, 3195, 3358, -3526, 3697, 3872, 4050, 4232, -4418, 4607, 4799, 4995, 5194, -5397, 5602, 5811, 6023, 6238, -6456, 6676, 6900, 7127, 7356, -7588, 7822, 8059, 8299, 8541, -8785, 9032, 9280, 9531, 9784, -10039, 10295, 10554, 10814, 11076, -11339, 11603, 11869, 12137, 12405, -12675, 12945, 13217, 13489, 13762, -14035, 14310, 14584, 14859, 15134, -15410, 15685, 15961, 16236, 16511, -16786, 17060, 17334, 17607, 17880, -18152, 18423, 18692, 18961, 19229, -19496, 19761, 20025, 20287, 20548, -20807, 21064, 21320, 21574, 21825, -22075, 22322, 22567, 22810, 23051, -23289, 23525, 23758, 23989, 24217, -24442, 24664, 24884, 25100, 25314, -25525, 25733, 25937, 26139, 26337, -26533, 26725, 26913, 27099, 27281, -27460, 27636, 27808, 27977, 28142, -28304, 28463, 28618, 28770, 28919, -29064, 29205, 29344, 29478, 29610, -29738, 29863, 29984, 30103, 30217, -30329, 30438, 30543, 30645, 30744, -30839, 30932, 31022, 31109, 31192, -31273, 31351, 31426, 31499, 31568, -31635, 31700, 31761, 31821, 31877, -31932, 31984, 32033, 32081, 32126, -32169, 32210, 32249, 32286, 32321, -32354, 32385, 32415, 32443, 32469, -32494, 32517, 32538, 32559, 32578, -32595, 32612, 32627, 32641, 32654, -32666, 32678, 32688, 32697, 32706, -32713, 32720, 32726, 32732, 32737, -32742, 32746, 32749, 32752, 32755, -32757, 32759, 32761, 32763, 32764, -32765, 32766, 32766, 32767, 32767, -32767, 32767, 32767, 32767, 32767, -32767, 32767, 32767, 32767, 32767, -#endif }; #endif @@ -1703,7 +1003,6 @@ static const unsigned char cache_caps50[168] = { #ifndef FFT_TWIDDLES96000_1920 #define FFT_TWIDDLES96000_1920 static const kiss_twiddle_cpx fft_twiddles96000_1920[960] = { -#ifdef ENABLE_QEXT {2147483647, 0}, {2147437652, -14055147}, {2147299668, -28109692}, {2147069700, -42163034}, {2146747759, -56214568}, {2146333858, -70263695}, @@ -2184,488 +1483,6 @@ static const kiss_twiddle_cpx fft_twiddles96000_1920[960] = { {2145828016, 84309812}, {2146333858, 70263695}, {2146747759, 56214568}, {2147069700, 42163034}, {2147299668, 28109692}, {2147437652, 14055147}, -#else -{32767, 0}, {32767, -214}, -{32765, -429}, {32762, -643}, -{32757, -858}, {32750, -1072}, -{32743, -1286}, {32734, -1501}, -{32723, -1715}, {32711, -1929}, -{32698, -2143}, {32683, -2357}, -{32667, -2571}, {32649, -2785}, -{32631, -2998}, {32610, -3212}, -{32588, -3425}, {32565, -3638}, -{32541, -3851}, {32515, -4064}, -{32488, -4277}, {32459, -4490}, -{32429, -4702}, {32397, -4914}, -{32365, -5126}, {32330, -5338}, -{32295, -5549}, {32258, -5760}, -{32219, -5971}, {32180, -6182}, -{32138, -6393}, {32096, -6603}, -{32052, -6813}, {32007, -7022}, -{31960, -7232}, {31912, -7441}, -{31863, -7650}, {31812, -7858}, -{31760, -8066}, {31706, -8274}, -{31651, -8481}, {31595, -8688}, -{31538, -8895}, {31479, -9101}, -{31419, -9307}, {31357, -9512}, -{31294, -9717}, {31230, -9922}, -{31164, -10126}, {31097, -10330}, -{31029, -10533}, {30959, -10736}, -{30888, -10938}, {30816, -11140}, -{30743, -11342}, {30668, -11543}, -{30592, -11743}, {30514, -11943}, -{30435, -12142}, {30355, -12341}, -{30274, -12540}, {30191, -12738}, -{30107, -12935}, {30022, -13132}, -{29935, -13328}, {29847, -13524}, -{29758, -13719}, {29668, -13913}, -{29576, -14107}, {29483, -14300}, -{29389, -14493}, {29293, -14685}, -{29197, -14876}, {29099, -15067}, -{28999, -15257}, {28899, -15447}, -{28797, -15636}, {28694, -15824}, -{28590, -16011}, {28485, -16198}, -{28378, -16384}, {28270, -16569}, -{28161, -16754}, {28051, -16938}, -{27939, -17121}, {27827, -17304}, -{27713, -17485}, {27598, -17666}, -{27482, -17847}, {27364, -18026}, -{27246, -18205}, {27126, -18383}, -{27005, -18560}, {26883, -18736}, -{26760, -18912}, {26635, -19087}, -{26510, -19261}, {26383, -19434}, -{26255, -19606}, {26127, -19777}, -{25997, -19948}, {25865, -20118}, -{25733, -20286}, {25600, -20454}, -{25466, -20622}, {25330, -20788}, -{25193, -20953}, {25056, -21118}, -{24917, -21281}, {24777, -21444}, -{24636, -21605}, {24494, -21766}, -{24351, -21926}, {24207, -22085}, -{24062, -22243}, {23916, -22400}, -{23769, -22556}, {23621, -22711}, -{23472, -22865}, {23322, -23018}, -{23170, -23170}, {23018, -23322}, -{22865, -23472}, {22711, -23621}, -{22556, -23769}, {22400, -23916}, -{22243, -24062}, {22085, -24207}, -{21926, -24351}, {21766, -24494}, -{21605, -24636}, {21444, -24777}, -{21281, -24917}, {21118, -25056}, -{20953, -25193}, {20788, -25330}, -{20622, -25466}, {20454, -25600}, -{20286, -25733}, {20118, -25865}, -{19948, -25997}, {19777, -26127}, -{19606, -26255}, {19434, -26383}, -{19261, -26510}, {19087, -26635}, -{18912, -26760}, {18736, -26883}, -{18560, -27005}, {18383, -27126}, -{18205, -27246}, {18026, -27364}, -{17847, -27482}, {17666, -27598}, -{17485, -27713}, {17304, -27827}, -{17121, -27939}, {16938, -28051}, -{16754, -28161}, {16569, -28270}, -{16384, -28378}, {16198, -28485}, -{16011, -28590}, {15824, -28694}, -{15636, -28797}, {15447, -28899}, -{15257, -28999}, {15067, -29099}, -{14876, -29197}, {14685, -29293}, -{14493, -29389}, {14300, -29483}, -{14107, -29576}, {13913, -29668}, -{13719, -29758}, {13524, -29847}, -{13328, -29935}, {13132, -30022}, -{12935, -30107}, {12738, -30191}, -{12540, -30274}, {12341, -30355}, -{12142, -30435}, {11943, -30514}, -{11743, -30592}, {11543, -30668}, -{11342, -30743}, {11140, -30816}, -{10938, -30888}, {10736, -30959}, -{10533, -31029}, {10330, -31097}, -{10126, -31164}, {9922, -31230}, -{9717, -31294}, {9512, -31357}, -{9307, -31419}, {9101, -31479}, -{8895, -31538}, {8688, -31595}, -{8481, -31651}, {8274, -31706}, -{8066, -31760}, {7858, -31812}, -{7650, -31863}, {7441, -31912}, -{7232, -31960}, {7022, -32007}, -{6813, -32052}, {6603, -32096}, -{6393, -32138}, {6182, -32180}, -{5971, -32219}, {5760, -32258}, -{5549, -32295}, {5338, -32330}, -{5126, -32365}, {4914, -32397}, -{4702, -32429}, {4490, -32459}, -{4277, -32488}, {4064, -32515}, -{3851, -32541}, {3638, -32565}, -{3425, -32588}, {3212, -32610}, -{2998, -32631}, {2785, -32649}, -{2571, -32667}, {2357, -32683}, -{2143, -32698}, {1929, -32711}, -{1715, -32723}, {1501, -32734}, -{1286, -32743}, {1072, -32750}, -{858, -32757}, {643, -32762}, -{429, -32765}, {214, -32767}, -{0, -32767}, {-214, -32767}, -{-429, -32765}, {-643, -32762}, -{-858, -32757}, {-1072, -32750}, -{-1286, -32743}, {-1501, -32734}, -{-1715, -32723}, {-1929, -32711}, -{-2143, -32698}, {-2357, -32683}, -{-2571, -32667}, {-2785, -32649}, -{-2998, -32631}, {-3212, -32610}, -{-3425, -32588}, {-3638, -32565}, -{-3851, -32541}, {-4064, -32515}, -{-4277, -32488}, {-4490, -32459}, -{-4702, -32429}, {-4914, -32397}, -{-5126, -32365}, {-5338, -32330}, -{-5549, -32295}, {-5760, -32258}, -{-5971, -32219}, {-6182, -32180}, -{-6393, -32138}, {-6603, -32096}, -{-6813, -32052}, {-7022, -32007}, -{-7232, -31960}, {-7441, -31912}, -{-7650, -31863}, {-7858, -31812}, -{-8066, -31760}, {-8274, -31706}, -{-8481, -31651}, {-8688, -31595}, -{-8895, -31538}, {-9101, -31479}, -{-9307, -31419}, {-9512, -31357}, -{-9717, -31294}, {-9922, -31230}, -{-10126, -31164}, {-10330, -31097}, -{-10533, -31029}, {-10736, -30959}, -{-10938, -30888}, {-11140, -30816}, -{-11342, -30743}, {-11543, -30668}, -{-11743, -30592}, {-11943, -30514}, -{-12142, -30435}, {-12341, -30355}, -{-12540, -30274}, {-12738, -30191}, -{-12935, -30107}, {-13132, -30022}, -{-13328, -29935}, {-13524, -29847}, -{-13719, -29758}, {-13913, -29668}, -{-14107, -29576}, {-14300, -29483}, -{-14493, -29389}, {-14685, -29293}, -{-14876, -29197}, {-15067, -29099}, -{-15257, -28999}, {-15447, -28899}, -{-15636, -28797}, {-15824, -28694}, -{-16011, -28590}, {-16198, -28485}, -{-16384, -28378}, {-16569, -28270}, -{-16754, -28161}, {-16938, -28051}, -{-17121, -27939}, {-17304, -27827}, -{-17485, -27713}, {-17666, -27598}, -{-17847, -27482}, {-18026, -27364}, -{-18205, -27246}, {-18383, -27126}, -{-18560, -27005}, {-18736, -26883}, -{-18912, -26760}, {-19087, -26635}, -{-19261, -26510}, {-19434, -26383}, -{-19606, -26255}, {-19777, -26127}, -{-19948, -25997}, {-20118, -25865}, -{-20286, -25733}, {-20454, -25600}, -{-20622, -25466}, {-20788, -25330}, -{-20953, -25193}, {-21118, -25056}, -{-21281, -24917}, {-21444, -24777}, -{-21605, -24636}, {-21766, -24494}, -{-21926, -24351}, {-22085, -24207}, -{-22243, -24062}, {-22400, -23916}, -{-22556, -23769}, {-22711, -23621}, -{-22865, -23472}, {-23018, -23322}, -{-23170, -23170}, {-23322, -23018}, -{-23472, -22865}, {-23621, -22711}, -{-23769, -22556}, {-23916, -22400}, -{-24062, -22243}, {-24207, -22085}, -{-24351, -21926}, {-24494, -21766}, -{-24636, -21605}, {-24777, -21444}, -{-24917, -21281}, {-25056, -21118}, -{-25193, -20953}, {-25330, -20788}, -{-25466, -20622}, {-25600, -20454}, -{-25733, -20286}, {-25865, -20118}, -{-25997, -19948}, {-26127, -19777}, -{-26255, -19606}, {-26383, -19434}, -{-26510, -19261}, {-26635, -19087}, -{-26760, -18912}, {-26883, -18736}, -{-27005, -18560}, {-27126, -18383}, -{-27246, -18205}, {-27364, -18026}, -{-27482, -17847}, {-27598, -17666}, -{-27713, -17485}, {-27827, -17304}, -{-27939, -17121}, {-28051, -16938}, -{-28161, -16754}, {-28270, -16569}, -{-28378, -16384}, {-28485, -16198}, -{-28590, -16011}, {-28694, -15824}, -{-28797, -15636}, {-28899, -15447}, -{-28999, -15257}, {-29099, -15067}, -{-29197, -14876}, {-29293, -14685}, -{-29389, -14493}, {-29483, -14300}, -{-29576, -14107}, {-29668, -13913}, -{-29758, -13719}, {-29847, -13524}, -{-29935, -13328}, {-30022, -13132}, -{-30107, -12935}, {-30191, -12738}, -{-30274, -12540}, {-30355, -12341}, -{-30435, -12142}, {-30514, -11943}, -{-30592, -11743}, {-30668, -11543}, -{-30743, -11342}, {-30816, -11140}, -{-30888, -10938}, {-30959, -10736}, -{-31029, -10533}, {-31097, -10330}, -{-31164, -10126}, {-31230, -9922}, -{-31294, -9717}, {-31357, -9512}, -{-31419, -9307}, {-31479, -9101}, -{-31538, -8895}, {-31595, -8688}, -{-31651, -8481}, {-31706, -8274}, -{-31760, -8066}, {-31812, -7858}, -{-31863, -7650}, {-31912, -7441}, -{-31960, -7232}, {-32007, -7022}, -{-32052, -6813}, {-32096, -6603}, -{-32138, -6393}, {-32180, -6182}, -{-32219, -5971}, {-32258, -5760}, -{-32295, -5549}, {-32330, -5338}, -{-32365, -5126}, {-32397, -4914}, -{-32429, -4702}, {-32459, -4490}, -{-32488, -4277}, {-32515, -4064}, -{-32541, -3851}, {-32565, -3638}, -{-32588, -3425}, {-32610, -3212}, -{-32631, -2998}, {-32649, -2785}, -{-32667, -2571}, {-32683, -2357}, -{-32698, -2143}, {-32711, -1929}, -{-32723, -1715}, {-32734, -1501}, -{-32743, -1286}, {-32750, -1072}, -{-32757, -858}, {-32762, -643}, -{-32765, -429}, {-32767, -214}, -{-32767, 0}, {-32767, 214}, -{-32765, 429}, {-32762, 643}, -{-32757, 858}, {-32750, 1072}, -{-32743, 1286}, {-32734, 1501}, -{-32723, 1715}, {-32711, 1929}, -{-32698, 2143}, {-32683, 2357}, -{-32667, 2571}, {-32649, 2785}, -{-32631, 2998}, {-32610, 3212}, -{-32588, 3425}, {-32565, 3638}, -{-32541, 3851}, {-32515, 4064}, -{-32488, 4277}, {-32459, 4490}, -{-32429, 4702}, {-32397, 4914}, -{-32365, 5126}, {-32330, 5338}, -{-32295, 5549}, {-32258, 5760}, -{-32219, 5971}, {-32180, 6182}, -{-32138, 6393}, {-32096, 6603}, -{-32052, 6813}, {-32007, 7022}, -{-31960, 7232}, {-31912, 7441}, -{-31863, 7650}, {-31812, 7858}, -{-31760, 8066}, {-31706, 8274}, -{-31651, 8481}, {-31595, 8688}, -{-31538, 8895}, {-31479, 9101}, -{-31419, 9307}, {-31357, 9512}, -{-31294, 9717}, {-31230, 9922}, -{-31164, 10126}, {-31097, 10330}, -{-31029, 10533}, {-30959, 10736}, -{-30888, 10938}, {-30816, 11140}, -{-30743, 11342}, {-30668, 11543}, -{-30592, 11743}, {-30514, 11943}, -{-30435, 12142}, {-30355, 12341}, -{-30274, 12540}, {-30191, 12738}, -{-30107, 12935}, {-30022, 13132}, -{-29935, 13328}, {-29847, 13524}, -{-29758, 13719}, {-29668, 13913}, -{-29576, 14107}, {-29483, 14300}, -{-29389, 14493}, {-29293, 14685}, -{-29197, 14876}, {-29099, 15067}, -{-28999, 15257}, {-28899, 15447}, -{-28797, 15636}, {-28694, 15824}, -{-28590, 16011}, {-28485, 16198}, -{-28378, 16384}, {-28270, 16569}, -{-28161, 16754}, {-28051, 16938}, -{-27939, 17121}, {-27827, 17304}, -{-27713, 17485}, {-27598, 17666}, -{-27482, 17847}, {-27364, 18026}, -{-27246, 18205}, {-27126, 18383}, -{-27005, 18560}, {-26883, 18736}, -{-26760, 18912}, {-26635, 19087}, -{-26510, 19261}, {-26383, 19434}, -{-26255, 19606}, {-26127, 19777}, -{-25997, 19948}, {-25865, 20118}, -{-25733, 20286}, {-25600, 20454}, -{-25466, 20622}, {-25330, 20788}, -{-25193, 20953}, {-25056, 21118}, -{-24917, 21281}, {-24777, 21444}, -{-24636, 21605}, {-24494, 21766}, -{-24351, 21926}, {-24207, 22085}, -{-24062, 22243}, {-23916, 22400}, -{-23769, 22556}, {-23621, 22711}, -{-23472, 22865}, {-23322, 23018}, -{-23170, 23170}, {-23018, 23322}, -{-22865, 23472}, {-22711, 23621}, -{-22556, 23769}, {-22400, 23916}, -{-22243, 24062}, {-22085, 24207}, -{-21926, 24351}, {-21766, 24494}, -{-21605, 24636}, {-21444, 24777}, -{-21281, 24917}, {-21118, 25056}, -{-20953, 25193}, {-20788, 25330}, -{-20622, 25466}, {-20454, 25600}, -{-20286, 25733}, {-20118, 25865}, -{-19948, 25997}, {-19777, 26127}, -{-19606, 26255}, {-19434, 26383}, -{-19261, 26510}, {-19087, 26635}, -{-18912, 26760}, {-18736, 26883}, -{-18560, 27005}, {-18383, 27126}, -{-18205, 27246}, {-18026, 27364}, -{-17847, 27482}, {-17666, 27598}, -{-17485, 27713}, {-17304, 27827}, -{-17121, 27939}, {-16938, 28051}, -{-16754, 28161}, {-16569, 28270}, -{-16384, 28378}, {-16198, 28485}, -{-16011, 28590}, {-15824, 28694}, -{-15636, 28797}, {-15447, 28899}, -{-15257, 28999}, {-15067, 29099}, -{-14876, 29197}, {-14685, 29293}, -{-14493, 29389}, {-14300, 29483}, -{-14107, 29576}, {-13913, 29668}, -{-13719, 29758}, {-13524, 29847}, -{-13328, 29935}, {-13132, 30022}, -{-12935, 30107}, {-12738, 30191}, -{-12540, 30274}, {-12341, 30355}, -{-12142, 30435}, {-11943, 30514}, -{-11743, 30592}, {-11543, 30668}, -{-11342, 30743}, {-11140, 30816}, -{-10938, 30888}, {-10736, 30959}, -{-10533, 31029}, {-10330, 31097}, -{-10126, 31164}, {-9922, 31230}, -{-9717, 31294}, {-9512, 31357}, -{-9307, 31419}, {-9101, 31479}, -{-8895, 31538}, {-8688, 31595}, -{-8481, 31651}, {-8274, 31706}, -{-8066, 31760}, {-7858, 31812}, -{-7650, 31863}, {-7441, 31912}, -{-7232, 31960}, {-7022, 32007}, -{-6813, 32052}, {-6603, 32096}, -{-6393, 32138}, {-6182, 32180}, -{-5971, 32219}, {-5760, 32258}, -{-5549, 32295}, {-5338, 32330}, -{-5126, 32365}, {-4914, 32397}, -{-4702, 32429}, {-4490, 32459}, -{-4277, 32488}, {-4064, 32515}, -{-3851, 32541}, {-3638, 32565}, -{-3425, 32588}, {-3212, 32610}, -{-2998, 32631}, {-2785, 32649}, -{-2571, 32667}, {-2357, 32683}, -{-2143, 32698}, {-1929, 32711}, -{-1715, 32723}, {-1501, 32734}, -{-1286, 32743}, {-1072, 32750}, -{-858, 32757}, {-643, 32762}, -{-429, 32765}, {-214, 32767}, -{0, 32767}, {214, 32767}, -{429, 32765}, {643, 32762}, -{858, 32757}, {1072, 32750}, -{1286, 32743}, {1501, 32734}, -{1715, 32723}, {1929, 32711}, -{2143, 32698}, {2357, 32683}, -{2571, 32667}, {2785, 32649}, -{2998, 32631}, {3212, 32610}, -{3425, 32588}, {3638, 32565}, -{3851, 32541}, {4064, 32515}, -{4277, 32488}, {4490, 32459}, -{4702, 32429}, {4914, 32397}, -{5126, 32365}, {5338, 32330}, -{5549, 32295}, {5760, 32258}, -{5971, 32219}, {6182, 32180}, -{6393, 32138}, {6603, 32096}, -{6813, 32052}, {7022, 32007}, -{7232, 31960}, {7441, 31912}, -{7650, 31863}, {7858, 31812}, -{8066, 31760}, {8274, 31706}, -{8481, 31651}, {8688, 31595}, -{8895, 31538}, {9101, 31479}, -{9307, 31419}, {9512, 31357}, -{9717, 31294}, {9922, 31230}, -{10126, 31164}, {10330, 31097}, -{10533, 31029}, {10736, 30959}, -{10938, 30888}, {11140, 30816}, -{11342, 30743}, {11543, 30668}, -{11743, 30592}, {11943, 30514}, -{12142, 30435}, {12341, 30355}, -{12540, 30274}, {12738, 30191}, -{12935, 30107}, {13132, 30022}, -{13328, 29935}, {13524, 29847}, -{13719, 29758}, {13913, 29668}, -{14107, 29576}, {14300, 29483}, -{14493, 29389}, {14685, 29293}, -{14876, 29197}, {15067, 29099}, -{15257, 28999}, {15447, 28899}, -{15636, 28797}, {15824, 28694}, -{16011, 28590}, {16198, 28485}, -{16384, 28378}, {16569, 28270}, -{16754, 28161}, {16938, 28051}, -{17121, 27939}, {17304, 27827}, -{17485, 27713}, {17666, 27598}, -{17847, 27482}, {18026, 27364}, -{18205, 27246}, {18383, 27126}, -{18560, 27005}, {18736, 26883}, -{18912, 26760}, {19087, 26635}, -{19261, 26510}, {19434, 26383}, -{19606, 26255}, {19777, 26127}, -{19948, 25997}, {20118, 25865}, -{20286, 25733}, {20454, 25600}, -{20622, 25466}, {20788, 25330}, -{20953, 25193}, {21118, 25056}, -{21281, 24917}, {21444, 24777}, -{21605, 24636}, {21766, 24494}, -{21926, 24351}, {22085, 24207}, -{22243, 24062}, {22400, 23916}, -{22556, 23769}, {22711, 23621}, -{22865, 23472}, {23018, 23322}, -{23170, 23170}, {23322, 23018}, -{23472, 22865}, {23621, 22711}, -{23769, 22556}, {23916, 22400}, -{24062, 22243}, {24207, 22085}, -{24351, 21926}, {24494, 21766}, -{24636, 21605}, {24777, 21444}, -{24917, 21281}, {25056, 21118}, -{25193, 20953}, {25330, 20788}, -{25466, 20622}, {25600, 20454}, -{25733, 20286}, {25865, 20118}, -{25997, 19948}, {26127, 19777}, -{26255, 19606}, {26383, 19434}, -{26510, 19261}, {26635, 19087}, -{26760, 18912}, {26883, 18736}, -{27005, 18560}, {27126, 18383}, -{27246, 18205}, {27364, 18026}, -{27482, 17847}, {27598, 17666}, -{27713, 17485}, {27827, 17304}, -{27939, 17121}, {28051, 16938}, -{28161, 16754}, {28270, 16569}, -{28378, 16384}, {28485, 16198}, -{28590, 16011}, {28694, 15824}, -{28797, 15636}, {28899, 15447}, -{28999, 15257}, {29099, 15067}, -{29197, 14876}, {29293, 14685}, -{29389, 14493}, {29483, 14300}, -{29576, 14107}, {29668, 13913}, -{29758, 13719}, {29847, 13524}, -{29935, 13328}, {30022, 13132}, -{30107, 12935}, {30191, 12738}, -{30274, 12540}, {30355, 12341}, -{30435, 12142}, {30514, 11943}, -{30592, 11743}, {30668, 11543}, -{30743, 11342}, {30816, 11140}, -{30888, 10938}, {30959, 10736}, -{31029, 10533}, {31097, 10330}, -{31164, 10126}, {31230, 9922}, -{31294, 9717}, {31357, 9512}, -{31419, 9307}, {31479, 9101}, -{31538, 8895}, {31595, 8688}, -{31651, 8481}, {31706, 8274}, -{31760, 8066}, {31812, 7858}, -{31863, 7650}, {31912, 7441}, -{31960, 7232}, {32007, 7022}, -{32052, 6813}, {32096, 6603}, -{32138, 6393}, {32180, 6182}, -{32219, 5971}, {32258, 5760}, -{32295, 5549}, {32330, 5338}, -{32365, 5126}, {32397, 4914}, -{32429, 4702}, {32459, 4490}, -{32488, 4277}, {32515, 4064}, -{32541, 3851}, {32565, 3638}, -{32588, 3425}, {32610, 3212}, -{32631, 2998}, {32649, 2785}, -{32667, 2571}, {32683, 2357}, -{32698, 2143}, {32711, 1929}, -{32723, 1715}, {32734, 1501}, -{32743, 1286}, {32750, 1072}, -{32757, 858}, {32762, 643}, -{32765, 429}, {32767, 214}, -#endif }; #ifndef FFT_BITREV960 #define FFT_BITREV960 @@ -2815,11 +1632,7 @@ static const opus_int16 fft_bitrev120[120] = { #define FFT_STATE96000_1920_0 static const kiss_fft_state fft_state96000_1920_0 = { 960, /* nfft */ -#ifdef ENABLE_QEXT 572662306, /* scale */ -#else -17476, /* scale */ -#endif 9, /* scale_shift */ -1, /* shift */ {5, 192, 3, 64, 4, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ @@ -2837,11 +1650,7 @@ NULL, #define FFT_STATE96000_1920_1 static const kiss_fft_state fft_state96000_1920_1 = { 480, /* nfft */ -#ifdef ENABLE_QEXT 572662306, /* scale */ -#else -17476, /* scale */ -#endif 8, /* scale_shift */ 1, /* shift */ {5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ @@ -2859,11 +1668,7 @@ NULL, #define FFT_STATE96000_1920_2 static const kiss_fft_state fft_state96000_1920_2 = { 240, /* nfft */ -#ifdef ENABLE_QEXT 572662306, /* scale */ -#else -17476, /* scale */ -#endif 7, /* scale_shift */ 2, /* shift */ {5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ @@ -2881,11 +1686,7 @@ NULL, #define FFT_STATE96000_1920_3 static const kiss_fft_state fft_state96000_1920_3 = { 120, /* nfft */ -#ifdef ENABLE_QEXT 572662306, /* scale */ -#else -17476, /* scale */ -#endif 6, /* scale_shift */ 3, /* shift */ {5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ @@ -2904,7 +1705,6 @@ NULL, #ifndef MDCT_TWIDDLES1920 #define MDCT_TWIDDLES1920 static const celt_coef mdct_twiddles1920[3600] = { -#ifdef ENABLE_QEXT 2147483603, 2147480010, 2147470667, 2147455575, 2147434733, 2147408142, 2147375802, 2147337712, 2147293874, 2147244286, 2147188950, 2147127865, 2147061032, 2146988450, 2146910120, @@ -3625,728 +2425,6 @@ static const celt_coef mdct_twiddles1920[3600] = { -2106903043, -2112161350, -2117057750, -2121591402, -2125761531, -2129567422, -2133008422, -2136083942, -2138793455, -2141136497, -2143112666, -2144721624, -2145963095, -2146836866, -2147342788, -#else -32767, 32767, 32767, 32767, 32767, -32767, 32766, 32766, 32765, 32764, -32764, 32763, 32762, 32760, 32759, -32758, 32757, 32755, 32754, 32752, -32750, 32748, 32747, 32745, 32742, -32740, 32738, 32736, 32733, 32731, -32728, 32726, 32723, 32720, 32717, -32714, 32711, 32708, 32704, 32701, -32697, 32694, 32690, 32686, 32683, -32679, 32675, 32671, 32666, 32662, -32658, 32653, 32649, 32644, 32640, -32635, 32630, 32625, 32620, 32615, -32610, 32604, 32599, 32593, 32588, -32582, 32576, 32571, 32565, 32559, -32553, 32546, 32540, 32534, 32527, -32521, 32514, 32507, 32501, 32494, -32487, 32480, 32473, 32465, 32458, -32451, 32443, 32436, 32428, 32420, -32412, 32404, 32396, 32388, 32380, -32372, 32364, 32355, 32347, 32338, -32329, 32320, 32312, 32303, 32294, -32284, 32275, 32266, 32257, 32247, -32237, 32228, 32218, 32208, 32198, -32188, 32178, 32168, 32158, 32147, -32137, 32127, 32116, 32105, 32094, -32084, 32073, 32062, 32051, 32039, -32028, 32017, 32005, 31994, 31982, -31970, 31959, 31947, 31935, 31923, -31910, 31898, 31886, 31874, 31861, -31848, 31836, 31823, 31810, 31797, -31784, 31771, 31758, 31745, 31732, -31718, 31705, 31691, 31677, 31664, -31650, 31636, 31622, 31608, 31593, -31579, 31565, 31550, 31536, 31521, -31507, 31492, 31477, 31462, 31447, -31432, 31417, 31401, 31386, 31371, -31355, 31339, 31324, 31308, 31292, -31276, 31260, 31244, 31228, 31212, -31195, 31179, 31162, 31146, 31129, -31112, 31095, 31078, 31061, 31044, -31027, 31010, 30992, 30975, 30957, -30940, 30922, 30904, 30886, 30868, -30850, 30832, 30814, 30796, 30777, -30759, 30740, 30722, 30703, 30684, -30665, 30646, 30627, 30608, 30589, -30570, 30551, 30531, 30512, 30492, -30472, 30453, 30433, 30413, 30393, -30373, 30353, 30332, 30312, 30292, -30271, 30251, 30230, 30209, 30188, -30167, 30146, 30125, 30104, 30083, -30062, 30040, 30019, 29997, 29976, -29954, 29932, 29910, 29889, 29867, -29844, 29822, 29800, 29778, 29755, -29733, 29710, 29687, 29665, 29642, -29619, 29596, 29573, 29550, 29527, -29503, 29480, 29457, 29433, 29409, -29386, 29362, 29338, 29314, 29290, -29266, 29242, 29218, 29193, 29169, -29145, 29120, 29095, 29071, 29046, -29021, 28996, 28971, 28946, 28921, -28896, 28870, 28845, 28819, 28794, -28768, 28743, 28717, 28691, 28665, -28639, 28613, 28587, 28560, 28534, -28508, 28481, 28455, 28428, 28401, -28375, 28348, 28321, 28294, 28267, -28240, 28212, 28185, 28158, 28130, -28103, 28075, 28047, 28020, 27992, -27964, 27936, 27908, 27880, 27851, -27823, 27795, 27766, 27738, 27709, -27681, 27652, 27623, 27594, 27565, -27536, 27507, 27478, 27449, 27419, -27390, 27360, 27331, 27301, 27272, -27242, 27212, 27182, 27152, 27122, -27092, 27062, 27032, 27001, 26971, -26940, 26910, 26879, 26848, 26818, -26787, 26756, 26725, 26694, 26663, -26631, 26600, 26569, 26537, 26506, -26474, 26443, 26411, 26379, 26347, -26316, 26284, 26251, 26219, 26187, -26155, 26123, 26090, 26058, 26025, -25993, 25960, 25927, 25894, 25861, -25828, 25795, 25762, 25729, 25696, -25663, 25629, 25596, 25562, 25529, -25495, 25461, 25428, 25394, 25360, -25326, 25292, 25258, 25223, 25189, -25155, 25120, 25086, 25051, 25017, -24982, 24947, 24913, 24878, 24843, -24808, 24773, 24738, 24702, 24667, -24632, 24596, 24561, 24525, 24490, -24454, 24419, 24383, 24347, 24311, -24275, 24239, 24203, 24167, 24130, -24094, 24058, 24021, 23985, 23948, -23912, 23875, 23838, 23801, 23764, -23728, 23690, 23653, 23616, 23579, -23542, 23504, 23467, 23430, 23392, -23355, 23317, 23279, 23241, 23204, -23166, 23128, 23090, 23052, 23014, -22975, 22937, 22899, 22860, 22822, -22783, 22745, 22706, 22668, 22629, -22590, 22551, 22512, 22473, 22434, -22395, 22356, 22317, 22277, 22238, -22199, 22159, 22120, 22080, 22040, -22001, 21961, 21921, 21881, 21841, -21801, 21761, 21721, 21681, 21641, -21600, 21560, 21520, 21479, 21439, -21398, 21357, 21317, 21276, 21235, -21194, 21153, 21112, 21071, 21030, -20989, 20948, 20907, 20865, 20824, -20783, 20741, 20700, 20658, 20616, -20575, 20533, 20491, 20449, 20407, -20365, 20323, 20281, 20239, 20197, -20155, 20112, 20070, 20028, 19985, -19943, 19900, 19857, 19815, 19772, -19729, 19686, 19643, 19601, 19558, -19514, 19471, 19428, 19385, 19342, -19298, 19255, 19212, 19168, 19125, -19081, 19038, 18994, 18950, 18906, -18863, 18819, 18775, 18731, 18687, -18643, 18599, 18554, 18510, 18466, -18422, 18377, 18333, 18288, 18244, -18199, 18155, 18110, 18065, 18021, -17976, 17931, 17886, 17841, 17796, -17751, 17706, 17661, 17616, 17570, -17525, 17480, 17434, 17389, 17344, -17298, 17252, 17207, 17161, 17116, -17070, 17024, 16978, 16932, 16886, -16840, 16794, 16748, 16702, 16656, -16610, 16564, 16517, 16471, 16425, -16378, 16332, 16285, 16239, 16192, -16145, 16099, 16052, 16005, 15958, -15912, 15865, 15818, 15771, 15724, -15677, 15630, 15583, 15535, 15488, -15441, 15394, 15346, 15299, 15251, -15204, 15156, 15109, 15061, 15014, -14966, 14918, 14870, 14823, 14775, -14727, 14679, 14631, 14583, 14535, -14487, 14439, 14391, 14342, 14294, -14246, 14198, 14149, 14101, 14053, -14004, 13956, 13907, 13858, 13810, -13761, 13713, 13664, 13615, 13566, -13517, 13469, 13420, 13371, 13322, -13273, 13224, 13175, 13126, 13076, -13027, 12978, 12929, 12880, 12830, -12781, 12731, 12682, 12633, 12583, -12534, 12484, 12434, 12385, 12335, -12285, 12236, 12186, 12136, 12086, -12037, 11987, 11937, 11887, 11837, -11787, 11737, 11687, 11637, 11586, -11536, 11486, 11436, 11386, 11335, -11285, 11235, 11184, 11134, 11083, -11033, 10982, 10932, 10881, 10831, -10780, 10729, 10679, 10628, 10577, -10527, 10476, 10425, 10374, 10323, -10272, 10221, 10170, 10119, 10068, -10017, 9966, 9915, 9864, 9813, -9762, 9711, 9659, 9608, 9557, -9506, 9454, 9403, 9352, 9300, -9249, 9197, 9146, 9094, 9043, -8991, 8940, 8888, 8836, 8785, -8733, 8681, 8630, 8578, 8526, -8475, 8423, 8371, 8319, 8267, -8215, 8163, 8111, 8059, 8007, -7955, 7903, 7851, 7799, 7747, -7695, 7643, 7591, 7539, 7487, -7434, 7382, 7330, 7278, 7225, -7173, 7121, 7068, 7016, 6964, -6911, 6859, 6806, 6754, 6701, -6649, 6596, 6544, 6491, 6439, -6386, 6334, 6281, 6228, 6176, -6123, 6070, 6018, 5965, 5912, -5859, 5807, 5754, 5701, 5648, -5595, 5543, 5490, 5437, 5384, -5331, 5278, 5225, 5172, 5119, -5066, 5013, 4960, 4907, 4854, -4801, 4748, 4695, 4642, 4589, -4536, 4483, 4430, 4377, 4324, -4270, 4217, 4164, 4111, 4058, -4005, 3951, 3898, 3845, 3792, -3738, 3685, 3632, 3578, 3525, -3472, 3419, 3365, 3312, 3259, -3205, 3152, 3098, 3045, 2992, -2938, 2885, 2831, 2778, 2725, -2671, 2618, 2564, 2511, 2457, -2404, 2350, 2297, 2243, 2190, -2136, 2083, 2029, 1976, 1922, -1869, 1815, 1762, 1708, 1655, -1601, 1548, 1494, 1440, 1387, -1333, 1280, 1226, 1173, 1119, -1065, 1012, 958, 905, 851, -797, 744, 690, 637, 583, -529, 476, 422, 369, 315, -261, 208, 154, 101, 47, --7, -60, -114, -168, -221, --275, -328, -382, -436, -489, --543, -596, -650, -704, -757, --811, -864, -918, -972, -1025, --1079, -1132, -1186, -1240, -1293, --1347, -1400, -1454, -1507, -1561, --1615, -1668, -1722, -1775, -1829, --1882, -1936, -1989, -2043, -2096, --2150, -2203, -2257, -2310, -2364, --2417, -2471, -2524, -2578, -2631, --2685, -2738, -2791, -2845, -2898, --2952, -3005, -3058, -3112, -3165, --3218, -3272, -3325, -3379, -3432, --3485, -3538, -3592, -3645, -3698, --3752, -3805, -3858, -3911, -3965, --4018, -4071, -4124, -4177, -4231, --4284, -4337, -4390, -4443, -4496, --4549, -4602, -4656, -4709, -4762, --4815, -4868, -4921, -4974, -5027, --5080, -5133, -5186, -5239, -5291, --5344, -5397, -5450, -5503, -5556, --5609, -5662, -5714, -5767, -5820, --5873, -5925, -5978, -6031, -6083, --6136, -6189, -6241, -6294, -6347, --6399, -6452, -6504, -6557, -6609, --6662, -6714, -6767, -6819, -6872, --6924, -6977, -7029, -7081, -7134, --7186, -7238, -7291, -7343, -7395, --7447, -7500, -7552, -7604, -7656, --7708, -7760, -7812, -7864, -7916, --7968, -8020, -8072, -8124, -8176, --8228, -8280, -8332, -8384, -8436, --8487, -8539, -8591, -8643, -8694, --8746, -8798, -8849, -8901, -8953, --9004, -9056, -9107, -9159, -9210, --9262, -9313, -9364, -9416, -9467, --9518, -9570, -9621, -9672, -9723, --9775, -9826, -9877, -9928, -9979, --10030, -10081, -10132, -10183, -10234, --10285, -10336, -10387, -10438, -10488, --10539, -10590, -10641, -10691, -10742, --10793, -10843, -10894, -10945, -10995, --11046, -11096, -11146, -11197, -11247, --11298, -11348, -11398, -11448, -11499, --11549, -11599, -11649, -11699, -11749, --11799, -11849, -11899, -11949, -11999, --12049, -12099, -12149, -12198, -12248, --12298, -12348, -12397, -12447, -12496, --12546, -12595, -12645, -12694, -12744, --12793, -12843, -12892, -12941, -12990, --13040, -13089, -13138, -13187, -13236, --13285, -13334, -13383, -13432, -13481, --13530, -13579, -13627, -13676, -13725, --13773, -13822, -13871, -13919, -13968, --14016, -14065, -14113, -14161, -14210, --14258, -14306, -14355, -14403, -14451, --14499, -14547, -14595, -14643, -14691, --14739, -14787, -14835, -14882, -14930, --14978, -15025, -15073, -15121, -15168, --15216, -15263, -15311, -15358, -15405, --15453, -15500, -15547, -15594, -15641, --15689, -15736, -15783, -15830, -15876, --15923, -15970, -16017, -16064, -16110, --16157, -16204, -16250, -16297, -16343, --16390, -16436, -16483, -16529, -16575, --16621, -16668, -16714, -16760, -16806, --16852, -16898, -16944, -16990, -17035, --17081, -17127, -17173, -17218, -17264, --17309, -17355, -17400, -17446, -17491, --17536, -17582, -17627, -17672, -17717, --17762, -17807, -17852, -17897, -17942, --17987, -18032, -18077, -18121, -18166, --18210, -18255, -18300, -18344, -18388, --18433, -18477, -18521, -18566, -18610, --18654, -18698, -18742, -18786, -18830, --18874, -18917, -18961, -19005, -19048, --19092, -19136, -19179, -19223, -19266, --19309, -19353, -19396, -19439, -19482, --19525, -19568, -19611, -19654, -19697, --19740, -19783, -19825, -19868, -19911, --19953, -19996, -20038, -20081, -20123, --20165, -20207, -20250, -20292, -20334, --20376, -20418, -20460, -20502, -20543, --20585, -20627, -20668, -20710, -20752, --20793, -20834, -20876, -20917, -20958, --20999, -21041, -21082, -21123, -21164, --21205, -21245, -21286, -21327, -21368, --21408, -21449, -21489, -21530, -21570, --21610, -21651, -21691, -21731, -21771, --21811, -21851, -21891, -21931, -21971, --22011, -22050, -22090, -22130, -22169, --22208, -22248, -22287, -22326, -22366, --22405, -22444, -22483, -22522, -22561, --22600, -22639, -22677, -22716, -22755, --22793, -22832, -22870, -22908, -22947, --22985, -23023, -23061, -23099, -23137, --23175, -23213, -23251, -23289, -23326, --23364, -23402, -23439, -23476, -23514, --23551, -23588, -23626, -23663, -23700, --23737, -23774, -23811, -23847, -23884, --23921, -23957, -23994, -24030, -24067, --24103, -24139, -24176, -24212, -24248, --24284, -24320, -24356, -24392, -24427, --24463, -24499, -24534, -24570, -24605, --24641, -24676, -24711, -24746, -24782, --24817, -24852, -24886, -24921, -24956, --24991, -25025, -25060, -25095, -25129, --25163, -25198, -25232, -25266, -25300, --25334, -25368, -25402, -25436, -25470, --25503, -25537, -25571, -25604, -25638, --25671, -25704, -25737, -25771, -25804, --25837, -25870, -25902, -25935, -25968, --26001, -26033, -26066, -26098, -26131, --26163, -26195, -26227, -26259, -26292, --26323, -26355, -26387, -26419, -26451, --26482, -26514, -26545, -26577, -26608, --26639, -26670, -26702, -26733, -26764, --26794, -26825, -26856, -26887, -26917, --26948, -26978, -27009, -27039, -27069, --27100, -27130, -27160, -27190, -27220, --27249, -27279, -27309, -27338, -27368, --27397, -27427, -27456, -27485, -27514, --27543, -27572, -27601, -27630, -27659, --27688, -27716, -27745, -27773, -27802, --27830, -27858, -27887, -27915, -27943, --27971, -27999, -28026, -28054, -28082, --28109, -28137, -28164, -28192, -28219, --28246, -28273, -28301, -28328, -28354, --28381, -28408, -28435, -28461, -28488, --28514, -28541, -28567, -28593, -28619, --28645, -28671, -28697, -28723, -28749, --28775, -28800, -28826, -28851, -28877, --28902, -28927, -28952, -28977, -29002, --29027, -29052, -29077, -29102, -29126, --29151, -29175, -29200, -29224, -29248, --29272, -29296, -29320, -29344, -29368, --29392, -29415, -29439, -29462, -29486, --29509, -29532, -29556, -29579, -29602, --29625, -29648, -29670, -29693, -29716, --29738, -29761, -29783, -29806, -29828, --29850, -29872, -29894, -29916, -29938, --29960, -29981, -30003, -30024, -30046, --30067, -30088, -30110, -30131, -30152, --30173, -30194, -30214, -30235, -30256, --30276, -30297, -30317, -30337, -30358, --30378, -30398, -30418, -30438, -30458, --30477, -30497, -30516, -30536, -30555, --30575, -30594, -30613, -30632, -30651, --30670, -30689, -30708, -30726, -30745, --30763, -30782, -30800, -30819, -30837, --30855, -30873, -30891, -30909, -30926, --30944, -30962, -30979, -30997, -31014, --31031, -31048, -31065, -31082, -31099, --31116, -31133, -31150, -31166, -31183, --31199, -31216, -31232, -31248, -31264, --31280, -31296, -31312, -31328, -31343, --31359, -31374, -31390, -31405, -31421, --31436, -31451, -31466, -31481, -31496, --31510, -31525, -31540, -31554, -31568, --31583, -31597, -31611, -31625, -31639, --31653, -31667, -31681, -31694, -31708, --31721, -31735, -31748, -31761, -31775, --31788, -31801, -31813, -31826, -31839, --31852, -31864, -31877, -31889, -31901, --31914, -31926, -31938, -31950, -31961, --31973, -31985, -31997, -32008, -32020, --32031, -32042, -32053, -32064, -32075, --32086, -32097, -32108, -32119, -32129, --32140, -32150, -32160, -32171, -32181, --32191, -32201, -32211, -32221, -32230, --32240, -32249, -32259, -32268, -32278, --32287, -32296, -32305, -32314, -32323, --32331, -32340, -32349, -32357, -32366, --32374, -32382, -32390, -32398, -32406, --32414, -32422, -32430, -32437, -32445, --32453, -32460, -32467, -32474, -32482, --32489, -32495, -32502, -32509, -32516, --32522, -32529, -32535, -32542, -32548, --32554, -32560, -32566, -32572, -32578, --32584, -32589, -32595, -32600, -32606, --32611, -32616, -32621, -32626, -32631, --32636, -32641, -32645, -32650, -32655, --32659, -32663, -32668, -32672, -32676, --32680, -32684, -32687, -32691, -32695, --32698, -32702, -32705, -32708, -32712, --32715, -32718, -32721, -32723, -32726, --32729, -32731, -32734, -32736, -32739, --32741, -32743, -32745, -32747, -32749, --32751, -32752, -32754, -32756, -32757, --32758, -32760, -32761, -32762, -32763, --32764, -32765, -32765, -32766, -32766, --32767, -32767, -32767, -32767, -32767, -32767, 32767, 32767, 32766, 32765, -32763, 32761, 32759, 32756, 32753, -32750, 32746, 32742, 32738, 32733, -32728, 32722, 32717, 32710, 32704, -32697, 32690, 32682, 32674, 32666, -32657, 32648, 32639, 32629, 32619, -32609, 32598, 32587, 32576, 32564, -32552, 32539, 32526, 32513, 32500, -32486, 32472, 32457, 32442, 32427, -32411, 32395, 32379, 32362, 32345, -32328, 32310, 32292, 32274, 32255, -32236, 32217, 32197, 32177, 32157, -32136, 32115, 32093, 32071, 32049, -32027, 32004, 31981, 31957, 31933, -31909, 31884, 31859, 31834, 31809, -31783, 31756, 31730, 31703, 31676, -31648, 31620, 31592, 31563, 31534, -31505, 31475, 31445, 31415, 31384, -31353, 31322, 31290, 31258, 31226, -31193, 31160, 31127, 31093, 31059, -31025, 30990, 30955, 30920, 30884, -30848, 30812, 30775, 30738, 30701, -30663, 30625, 30587, 30548, 30509, -30470, 30430, 30390, 30350, 30309, -30269, 30227, 30186, 30144, 30102, -30059, 30016, 29973, 29930, 29886, -29842, 29797, 29752, 29707, 29662, -29616, 29570, 29524, 29477, 29430, -29383, 29335, 29287, 29239, 29190, -29142, 29092, 29043, 28993, 28943, -28892, 28842, 28791, 28739, 28688, -28636, 28583, 28531, 28478, 28425, -28371, 28317, 28263, 28209, 28154, -28099, 28044, 27988, 27932, 27876, -27820, 27763, 27706, 27648, 27591, -27533, 27474, 27416, 27357, 27298, -27238, 27178, 27118, 27058, 26997, -26936, 26875, 26814, 26752, 26690, -26628, 26565, 26502, 26439, 26375, -26312, 26247, 26183, 26119, 26054, -25988, 25923, 25857, 25791, 25725, -25658, 25592, 25524, 25457, 25389, -25322, 25253, 25185, 25116, 25047, -24978, 24908, 24838, 24768, 24698, -24627, 24557, 24485, 24414, 24342, -24270, 24198, 24126, 24053, 23980, -23907, 23834, 23760, 23686, 23612, -23537, 23462, 23387, 23312, 23237, -23161, 23085, 23009, 22932, 22856, -22779, 22701, 22624, 22546, 22468, -22390, 22312, 22233, 22154, 22075, -21996, 21916, 21836, 21756, 21676, -21595, 21515, 21434, 21352, 21271, -21189, 21107, 21025, 20943, 20860, -20777, 20694, 20611, 20528, 20444, -20360, 20276, 20192, 20107, 20022, -19937, 19852, 19767, 19681, 19595, -19509, 19423, 19336, 19250, 19163, -19076, 18988, 18901, 18813, 18725, -18637, 18549, 18460, 18372, 18283, -18194, 18104, 18015, 17925, 17835, -17745, 17655, 17565, 17474, 17383, -17292, 17201, 17110, 17018, 16927, -16835, 16743, 16650, 16558, 16465, -16372, 16279, 16186, 16093, 15999, -15906, 15812, 15718, 15624, 15529, -15435, 15340, 15245, 15150, 15055, -14960, 14864, 14769, 14673, 14577, -14481, 14385, 14288, 14192, 14095, -13998, 13901, 13804, 13706, 13609, -13511, 13414, 13316, 13218, 13119, -13021, 12923, 12824, 12725, 12626, -12527, 12428, 12329, 12230, 12130, -12030, 11930, 11831, 11730, 11630, -11530, 11430, 11329, 11228, 11128, -11027, 10926, 10824, 10723, 10622, -10520, 10419, 10317, 10215, 10113, -10011, 9909, 9807, 9704, 9602, -9499, 9397, 9294, 9191, 9088, -8985, 8882, 8778, 8675, 8572, -8468, 8364, 8261, 8157, 8053, -7949, 7845, 7741, 7637, 7532, -7428, 7323, 7219, 7114, 7009, -6905, 6800, 6695, 6590, 6485, -6380, 6274, 6169, 6064, 5958, -5853, 5747, 5642, 5536, 5430, -5325, 5219, 5113, 5007, 4901, -4795, 4689, 4583, 4476, 4370, -4264, 4157, 4051, 3945, 3838, -3732, 3625, 3518, 3412, 3305, -3198, 3092, 2985, 2878, 2771, -2664, 2558, 2451, 2344, 2237, -2130, 2023, 1916, 1809, 1702, -1594, 1487, 1380, 1273, 1166, -1059, 952, 844, 737, 630, -523, 416, 308, 201, 94, --13, -121, -228, -335, -442, --550, -657, -764, -871, -978, --1086, -1193, -1300, -1407, -1514, --1621, -1728, -1835, -1942, -2049, --2157, -2263, -2370, -2477, -2584, --2691, -2798, -2905, -3012, -3118, --3225, -3332, -3439, -3545, -3652, --3758, -3865, -3971, -4078, -4184, --4290, -4397, -4503, -4609, -4715, --4821, -4927, -5033, -5139, -5245, --5351, -5457, -5562, -5668, -5774, --5879, -5985, -6090, -6195, -6301, --6406, -6511, -6616, -6721, -6826, --6931, -7036, -7140, -7245, -7349, --7454, -7558, -7663, -7767, -7871, --7975, -8079, -8183, -8287, -8390, --8494, -8597, -8701, -8804, -8907, --9011, -9114, -9217, -9319, -9422, --9525, -9627, -9730, -9832, -9934, --10037, -10139, -10241, -10342, -10444, --10546, -10647, -10748, -10850, -10951, --11052, -11153, -11253, -11354, -11455, --11555, -11655, -11756, -11856, -11955, --12055, -12155, -12254, -12354, -12453, --12552, -12651, -12750, -12849, -12947, --13046, -13144, -13242, -13340, -13438, --13536, -13633, -13731, -13828, -13925, --14022, -14119, -14216, -14312, -14409, --14505, -14601, -14697, -14793, -14888, --14984, -15079, -15174, -15269, -15364, --15459, -15553, -15647, -15741, -15835, --15929, -16023, -16116, -16210, -16303, --16396, -16488, -16581, -16673, -16766, --16858, -16949, -17041, -17133, -17224, --17315, -17406, -17497, -17587, -17678, --17768, -17858, -17948, -18037, -18127, --18216, -18305, -18394, -18483, -18571, --18659, -18747, -18835, -18923, -19010, --19098, -19185, -19271, -19358, -19444, --19531, -19617, -19702, -19788, -19873, --19959, -20043, -20128, -20213, -20297, --20381, -20465, -20549, -20632, -20715, --20798, -20881, -20963, -21046, -21128, --21210, -21291, -21373, -21454, -21535, --21616, -21696, -21776, -21856, -21936, --22016, -22095, -22174, -22253, -22331, --22410, -22488, -22566, -22643, -22721, --22798, -22875, -22951, -23028, -23104, --23180, -23256, -23331, -23406, -23481, --23556, -23630, -23704, -23778, -23852, --23925, -23998, -24071, -24144, -24216, --24288, -24360, -24432, -24503, -24574, --24645, -24716, -24786, -24856, -24926, --24995, -25064, -25133, -25202, -25270, --25339, -25406, -25474, -25541, -25608, --25675, -25742, -25808, -25874, -25939, --26005, -26070, -26135, -26199, -26264, --26327, -26391, -26455, -26518, -26581, --26643, -26705, -26767, -26829, -26891, --26952, -27013, -27073, -27133, -27193, --27253, -27312, -27372, -27430, -27489, --27547, -27605, -27663, -27720, -27777, --27834, -27890, -27946, -28002, -28058, --28113, -28168, -28223, -28277, -28331, --28385, -28438, -28491, -28544, -28596, --28649, -28701, -28752, -28803, -28854, --28905, -28955, -29006, -29055, -29105, --29154, -29203, -29251, -29299, -29347, --29395, -29442, -29489, -29535, -29582, --29628, -29673, -29719, -29764, -29808, --29853, -29897, -29941, -29984, -30027, --30070, -30112, -30154, -30196, -30238, --30279, -30320, -30360, -30400, -30440, --30480, -30519, -30558, -30596, -30635, --30672, -30710, -30747, -30784, -30821, --30857, -30893, -30929, -30964, -30999, --31033, -31068, -31102, -31135, -31168, --31201, -31234, -31266, -31298, -31330, --31361, -31392, -31422, -31453, -31483, --31512, -31541, -31570, -31599, -31627, --31655, -31682, -31710, -31737, -31763, --31789, -31815, -31841, -31866, -31891, --31915, -31939, -31963, -31986, -32010, --32032, -32055, -32077, -32099, -32120, --32141, -32162, -32182, -32202, -32222, --32241, -32260, -32279, -32297, -32315, --32333, -32350, -32367, -32383, -32399, --32415, -32431, -32446, -32461, -32475, --32489, -32503, -32517, -32530, -32542, --32555, -32567, -32579, -32590, -32601, --32612, -32622, -32632, -32641, -32651, --32659, -32668, -32676, -32684, -32692, --32699, -32706, -32712, -32718, -32724, --32729, -32734, -32739, -32743, -32747, --32751, -32754, -32757, -32760, -32762, --32764, -32765, -32767, -32767, -32767, -32767, 32767, 32765, 32761, 32756, -32750, 32742, 32732, 32722, 32710, -32696, 32681, 32665, 32647, 32628, -32608, 32586, 32562, 32538, 32512, -32484, 32455, 32425, 32393, 32360, -32326, 32290, 32253, 32214, 32174, -32133, 32090, 32046, 32001, 31954, -31906, 31856, 31805, 31753, 31700, -31645, 31588, 31530, 31471, 31411, -31349, 31286, 31222, 31156, 31089, -31020, 30951, 30880, 30807, 30733, -30658, 30582, 30504, 30425, 30345, -30263, 30181, 30096, 30011, 29924, -29836, 29747, 29656, 29564, 29471, -29377, 29281, 29184, 29086, 28987, -28886, 28784, 28681, 28577, 28471, -28365, 28257, 28147, 28037, 27925, -27812, 27698, 27583, 27467, 27349, -27231, 27111, 26990, 26868, 26744, -26620, 26494, 26367, 26239, 26110, -25980, 25849, 25717, 25583, 25449, -25313, 25176, 25038, 24900, 24760, -24619, 24477, 24333, 24189, 24044, -23898, 23751, 23602, 23453, 23303, -23152, 22999, 22846, 22692, 22537, -22380, 22223, 22065, 21906, 21746, -21585, 21423, 21261, 21097, 20933, -20767, 20601, 20434, 20265, 20096, -19927, 19756, 19584, 19412, 19239, -19065, 18890, 18714, 18538, 18361, -18183, 18004, 17824, 17644, 17463, -17281, 17098, 16915, 16731, 16546, -16361, 16175, 15988, 15800, 15612, -15423, 15234, 15043, 14852, 14661, -14469, 14276, 14083, 13889, 13694, -13499, 13303, 13107, 12910, 12713, -12515, 12317, 12118, 11918, 11718, -11517, 11316, 11115, 10913, 10710, -10508, 10304, 10100, 9896, 9691, -9486, 9281, 9075, 8869, 8662, -8455, 8248, 8040, 7832, 7623, -7415, 7206, 6996, 6787, 6577, -6366, 6156, 5945, 5734, 5523, -5311, 5100, 4888, 4675, 4463, -4251, 4038, 3825, 3612, 3399, -3185, 2972, 2758, 2544, 2330, -2116, 1902, 1688, 1474, 1260, -1045, 831, 617, 402, 188, --27, -241, -456, -670, -885, --1099, -1313, -1528, -1742, -1956, --2170, -2384, -2598, -2811, -3025, --3239, -3452, -3665, -3878, -4091, --4304, -4516, -4728, -4941, -5153, --5364, -5576, -5787, -5998, -6209, --6419, -6629, -6839, -7049, -7258, --7467, -7676, -7884, -8092, -8300, --8507, -8714, -8920, -9127, -9332, --9538, -9743, -9947, -10151, -10355, --10558, -10761, -10963, -11165, -11367, --11568, -11768, -11968, -12167, -12366, --12565, -12762, -12960, -13156, -13352, --13548, -13743, -13937, -14131, -14324, --14517, -14709, -14900, -15091, -15281, --15470, -15659, -15847, -16035, -16221, --16407, -16593, -16777, -16961, -17144, --17326, -17508, -17689, -17869, -18049, --18227, -18405, -18582, -18758, -18934, --19108, -19282, -19455, -19627, -19799, --19969, -20139, -20308, -20475, -20642, --20809, -20974, -21138, -21301, -21464, --21626, -21786, -21946, -22105, -22263, --22420, -22575, -22730, -22884, -23037, --23189, -23340, -23490, -23640, -23788, --23935, -24080, -24225, -24369, -24512, --24654, -24795, -24934, -25073, -25211, --25347, -25482, -25617, -25750, -25882, --26013, -26143, -26272, -26399, -26526, --26651, -26775, -26898, -27020, -27141, --27260, -27379, -27496, -27612, -27727, --27841, -27953, -28065, -28175, -28284, --28391, -28498, -28603, -28707, -28810, --28911, -29012, -29111, -29209, -29305, --29401, -29495, -29587, -29679, -29769, --29858, -29946, -30032, -30118, -30201, --30284, -30365, -30445, -30524, -30601, --30677, -30752, -30825, -30897, -30968, --31038, -31106, -31172, -31238, -31302, --31365, -31426, -31486, -31545, -31602, --31658, -31713, -31766, -31818, -31869, --31918, -31966, -32012, -32058, -32101, --32144, -32185, -32224, -32262, -32299, --32335, -32369, -32401, -32433, -32463, --32491, -32518, -32544, -32568, -32591, --32613, -32633, -32652, -32669, -32685, --32700, -32713, -32724, -32735, -32744, --32751, -32757, -32762, -32766, -32767, -32767, 32764, 32755, 32741, 32720, -32694, 32663, 32626, 32583, 32535, -32481, 32421, 32356, 32286, 32209, -32128, 32041, 31948, 31850, 31747, -31638, 31523, 31403, 31278, 31148, -31012, 30871, 30724, 30572, 30415, -30253, 30086, 29913, 29736, 29553, -29365, 29172, 28974, 28771, 28564, -28351, 28134, 27911, 27684, 27452, -27216, 26975, 26729, 26478, 26223, -25964, 25700, 25432, 25159, 24882, -24601, 24315, 24026, 23732, 23434, -23133, 22827, 22517, 22204, 21886, -21565, 21240, 20912, 20580, 20244, -19905, 19563, 19217, 18868, 18516, -18160, 17802, 17440, 17075, 16708, -16338, 15964, 15588, 15210, 14829, -14445, 14059, 13670, 13279, 12886, -12490, 12093, 11693, 11291, 10888, -10482, 10075, 9666, 9255, 8843, -8429, 8014, 7597, 7180, 6760, -6340, 5919, 5496, 5073, 4649, -4224, 3798, 3372, 2945, 2517, -2090, 1661, 1233, 804, 375, --54, -483, -911, -1340, -1768, --2197, -2624, -3052, -3479, -3905, --4330, -4755, -5179, -5602, -6024, --6445, -6865, -7284, -7702, -8118, --8533, -8946, -9358, -9768, -10177, --10584, -10989, -11392, -11793, -12192, --12589, -12984, -13377, -13767, -14155, --14541, -14924, -15305, -15683, -16058, --16430, -16800, -17167, -17531, -17892, --18249, -18604, -18956, -19304, -19649, --19990, -20329, -20663, -20994, -21322, --21646, -21966, -22282, -22595, -22904, --23208, -23509, -23806, -24099, -24387, --24672, -24952, -25228, -25499, -25766, --26029, -26288, -26541, -26791, -27035, --27275, -27511, -27741, -27967, -28188, --28405, -28616, -28823, -29024, -29221, --29412, -29599, -29780, -29957, -30128, --30294, -30455, -30611, -30761, -30906, --31046, -31181, -31310, -31434, -31552, --31665, -31773, -31875, -31972, -32063, --32149, -32229, -32304, -32373, -32437, --32495, -32547, -32594, -32635, -32671, --32701, -32726, -32745, -32758, -32766, -#endif }; #endif diff --git a/celt/tests/test_unit_mathops.c b/celt/tests/test_unit_mathops.c index c3adb3f4c..517ef5bca 100644 --- a/celt/tests/test_unit_mathops.c +++ b/celt/tests/test_unit_mathops.c @@ -283,7 +283,6 @@ void test_atan2(void) { void testlog2_db(void) { -#if defined(ENABLE_QEXT) /* celt_log2_db test */ float error = -1; float max_error = -2; @@ -306,7 +305,6 @@ void testlog2_db(void) } } fprintf(stdout, "celt_log2_db max_error: %.7e\n", max_error); -#endif /* defined(ENABLE_QEXT) */ } void testlog2(void) @@ -340,7 +338,6 @@ void testexp2(void) void testexp2_db(void) { -#if defined(ENABLE_QEXT) float absolute_error = -1; float absolute_error_threshold = FIX_INT_TO_DOUBLE(2, 16); float relative_error_threshold = -2; @@ -371,7 +368,6 @@ void testexp2_db(void) ret = 1; } } -#endif /* defined(ENABLE_QEXT) */ } void testexp2log2(void) @@ -470,7 +466,6 @@ void testsqrt32(void) void testatan_norm(void) { -#if defined(ENABLE_QEXT) float error = -1; float max_error = -2; float error_threshold = 5.97e-08; @@ -497,12 +492,10 @@ void testatan_norm(void) } } fprintf(stdout, "celt_atan_norm max_error: %.7e\n", max_error); -#endif /* defined(ENABLE_QEXT) */ } void testatan2p_norm(void) { -#if defined(ENABLE_QEXT) float error = -1; float max_error = -2; float error_threshold = 1.2e-07; @@ -539,7 +532,6 @@ void testatan2p_norm(void) } } fprintf(stdout, "celt_atan2p_norm max_error: %.7e\n", max_error); -#endif /* defined(ENABLE_QEXT) */ } void testatan(void) diff --git a/celt/tests/test_unit_mdct.c b/celt/tests/test_unit_mdct.c index 00b3840de..d075d4452 100644 --- a/celt/tests/test_unit_mdct.c +++ b/celt/tests/test_unit_mdct.c @@ -140,11 +140,7 @@ void test1d(int nfft,int isinverse,int arch) } for (k=0;k0) { int tot_shift = NORM_SHIFT+1-k-shift; if (tot_shift >= 0) { @@ -375,7 +375,6 @@ opus_val16 op_pvq_search_c(celt_norm *X, int *iy, int K, int N, int arch) RESTORE_STACK; RESTORE_STACK; RESTORE_STACK; - unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc, opus_val32 gain, int resynth, int arch) { @@ -489,8 +488,6 @@ opus_int32 stereo_itheta(const celt_norm *X, const celt_norm *Y, int stereo, int return itheta; } -#ifdef ENABLE_QEXT - static void cubic_synthesis(celt_norm *X, int *iy, int N, int K, int face, int sign, opus_val32 gain) { int i; opus_val32 sum=0; @@ -601,4 +598,3 @@ unsigned cubic_unquant(celt_norm *X, int N, int res, int B, ec_dec *dec, opus_va RESTORE_STACK; return (1<> 7); -#endif #else output[output_rows * i] = (1/(32768.f*32768.f))*tmp; #endif diff --git a/src/opus_decoder.c b/src/opus_decoder.c index 8dc86cea7..2c9cce97d 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -216,7 +216,6 @@ OpusDecoder *opus_decoder_create(opus_int32 Fs, int channels, int *error) return st; } -#ifdef ENABLE_RES24 static void smooth_fade(const opus_res *in1, const opus_res *in2, opus_res *out, int overlap, int channels, const celt_coef *window, opus_int32 Fs) @@ -233,25 +232,6 @@ static void smooth_fade(const opus_res *in1, const opus_res *in2, } } } -#else -static void smooth_fade(const opus_res *in1, const opus_res *in2, - opus_res *out, int overlap, int channels, - const celt_coef *window, opus_int32 Fs) -{ - int i, c; - int inc = 48000/Fs; - for (c=0;cchannels;i++) { opus_val32 x; -#ifdef ENABLE_RES24 x = MULT32_32_Q16(pcm[i],gain); -#else - x = MULT16_32_P16(pcm[i],gain); -#endif pcm[i] = SATURATE(x, 32767); } } @@ -869,15 +845,6 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, #define OPTIONAL_CLIP 1 #endif -#if defined(FIXED_POINT) && !defined(ENABLE_RES24) -int opus_decode(OpusDecoder *st, const unsigned char *data, - opus_int32 len, opus_int16 *pcm, int frame_size, int decode_fec) -{ - if(frame_size<=0) - return OPUS_BAD_ARG; - return opus_decode_native(st, data, len, pcm, frame_size, decode_fec, 0, NULL, 0, NULL, 0); -} -#else int opus_decode(OpusDecoder *st, const unsigned char *data, opus_int32 len, opus_int16 *pcm, int frame_size, int decode_fec) { @@ -916,9 +883,8 @@ int opus_decode(OpusDecoder *st, const unsigned char *data, RESTORE_STACK; return ret; } -#endif -#if defined(FIXED_POINT) && defined(ENABLE_RES24) +#if defined(FIXED_POINT) int opus_decode24(OpusDecoder *st, const unsigned char *data, opus_int32 len, opus_int32 *pcm, int frame_size, int decode_fec) { diff --git a/src/opus_encoder.c b/src/opus_encoder.c index 0b8c22ee0..95f392378 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -104,9 +104,6 @@ struct OpusEncoder { #ifndef DISABLE_FLOAT_API TonalityAnalysisState analysis; #endif -#ifdef ENABLE_QEXT - int enable_qext; -#endif #define OPUS_ENCODER_RESET_START stream_channels int stream_channels; @@ -461,18 +458,10 @@ static void hp_cutoff(const opus_res *in, opus_int32 cutoff_Hz, opus_res *out, o A_Q28[ 0 ] = silk_SMULWW( r_Q22, silk_SMULWW( Fc_Q19, Fc_Q19 ) - SILK_FIX_CONST( 2.0, 22 ) ); A_Q28[ 1 ] = silk_SMULWW( r_Q22, r_Q22 ); -#if defined(FIXED_POINT) && !defined(ENABLE_RES24) - if( channels == 1 ) { - silk_biquad_alt_stride1( in, B_Q28, A_Q28, hp_mem, out, len ); - } else { - silk_biquad_alt_stride2( in, B_Q28, A_Q28, hp_mem, out, len, arch ); - } -#else silk_biquad_res( in, B_Q28, A_Q28, hp_mem, out, len, channels ); if( channels == 2 ) { silk_biquad_res( in+1, B_Q28, A_Q28, hp_mem+2, out+1, len, channels ); } -#endif } #ifdef FIXED_POINT @@ -493,12 +482,8 @@ static void dc_reject(const opus_res *in, opus_int32 cutoff_Hz, opus_res *out, o x = SHL32(x, 14-RES_SHIFT); y = x-hp_mem[2*c]; hp_mem[2*c] = hp_mem[2*c] + PSHR32(x - hp_mem[2*c], shift); -#ifdef ENABLE_RES24 /* Don't saturate if we have the headroom to avoid it. */ out[channels*i+c] = PSHR32(y, 14-RES_SHIFT); -#else - out[channels*i+c] = SATURATE(PSHR32(y, 14-RES_SHIFT), 32767); -#endif } } } @@ -1734,13 +1719,6 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_res *pcm, int frame_si * 2 frames: Code 2 with different compressed sizes * >2 frames: Code 3 VBR */ max_header_bytes = nb_frames == 2 ? 3 : (2+(nb_frames-1)*2); -#ifdef ENABLE_QEXT - /* Cover the use of the separators that are the only thing that can get us over - once we consider that we need to subtract the extension overhead in each - of the individual frames. Also consider that a separator can get our padding - from 254 to 255, which costs an extra length byte (at most once). */ - if (st->enable_qext) max_header_bytes += (nb_frames-1) + 1; -#endif if (st->use_vbr || st->user_bitrate_bps==OPUS_BITRATE_MAX) repacketize_len = out_data_bytes; @@ -1991,11 +1969,6 @@ static opus_int32 opus_encode_frame_native(OpusEncoder *st, const opus_res *pcm, } #endif } else { -#ifdef ENABLE_QEXT - /* FIXME: Avoid glitching when we switch qext on/off dynamically. */ - if (st->enable_qext) OPUS_COPY(&pcm_buf[total_buffer*st->channels], pcm, frame_size*st->channels); - else -#endif dc_reject(pcm, 3, &pcm_buf[total_buffer*st->channels], st->hp_mem, frame_size, st->channels, st->Fs); } #ifndef FIXED_POINT @@ -2381,12 +2354,6 @@ static opus_int32 opus_encode_frame_native(OpusEncoder *st, const opus_res *pcm, nb_compr_bytes = ret; } else { nb_compr_bytes = (max_data_bytes-1)-redundancy_bytes; -#ifdef ENABLE_QEXT - if (st->mode == MODE_CELT_ONLY && st->enable_qext) { - celt_assert(redundancy_bytes==0); - nb_compr_bytes = orig_max_data_bytes-1; - } -#endif #ifdef ENABLE_DRED if (st->dred_duration > 0) { @@ -2643,16 +2610,6 @@ static opus_int32 opus_encode_frame_native(OpusEncoder *st, const opus_res *pcm, -#if defined(FIXED_POINT) && !defined(ENABLE_RES24) -opus_int32 opus_encode(OpusEncoder *st, const opus_int16 *pcm, int analysis_frame_size, - unsigned char *data, opus_int32 max_data_bytes) -{ - int frame_size; - frame_size = frame_size_select(st->application, analysis_frame_size, st->variable_duration, st->Fs); - return opus_encode_native(st, pcm, frame_size, data, max_data_bytes, 16, - pcm, analysis_frame_size, 0, -2, st->channels, downmix_int, 0); -} -#else opus_int32 opus_encode(OpusEncoder *st, const opus_int16 *pcm, int analysis_frame_size, unsigned char *data, opus_int32 max_data_bytes) { @@ -2676,9 +2633,8 @@ opus_int32 opus_encode(OpusEncoder *st, const opus_int16 *pcm, int analysis_fram RESTORE_STACK; return ret; } -#endif -#if defined(FIXED_POINT) && defined(ENABLE_RES24) +#if defined(FIXED_POINT) opus_int32 opus_encode24(OpusEncoder *st, const opus_int32 *pcm, int analysis_frame_size, unsigned char *data, opus_int32 max_data_bytes) { diff --git a/tests/test_opus_custom.c b/tests/test_opus_custom.c index bcf7302ca..6331dab6c 100644 --- a/tests/test_opus_custom.c +++ b/tests/test_opus_custom.c @@ -412,11 +412,7 @@ int test_encode(TestCustomParams params) { #ifdef RESYNTH /* Resynth only works with OpusCustom encoder. Also, we don't enable it if there's a 16-bit bottleneck in the decoder that can cause clipping. */ - if (params.custom_encode && (params.custom_decode -#if !defined(FIXED_POINT) || defined(ENABLE_RES24) - || params.decoder_bit_depth > 16 -#endif - )) { + if (params.custom_encode && (params.custom_decode || params.decoder_bit_depth > 16)) { if (params.float_encode) { float* input = (float*)inbuf; float* output = (float*)outbuf; From fd0c105f093d7b3cb5f1ce297ec2ef26fb165573 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Thu, 15 Jan 2026 11:10:48 -0500 Subject: [PATCH 03/28] Rename identifiers from opus to oac --- .github/workflows/cmake.yml | 14 +- .github/workflows/dred.yml | 8 +- .gitignore | 16 +- .gitlab-ci.yml | 134 - CMakeLists.txt | 768 +- LICENSE_PLEASE_READ.txt | 22 - Makefile.am | 180 +- Makefile.unix | 70 +- README.draft | 54 - celt/_kiss_fft_guts.h | 4 +- celt/arch.h | 82 +- celt/arm/arm_celt_map.c | 120 +- celt/arm/armcpu.c | 166 +- celt/arm/armcpu.h | 30 +- celt/arm/armopts.s.in | 6 +- celt/arm/celt_fft_ne10.c | 16 +- celt/arm/celt_mdct_ne10.c | 46 +- celt/arm/celt_neon_intr.c | 16 +- celt/arm/celt_pitch_xcorr_arm.s | 60 +- celt/arm/fft_arm.h | 30 +- celt/arm/fixed_armv4.h | 6 +- celt/arm/fixed_armv5e.h | 24 +- celt/arm/mathops_arm.h | 32 +- celt/arm/mdct_arm.h | 14 +- celt/arm/meson.build | 2 +- celt/arm/pitch_arm.h | 106 +- celt/arm/pitch_neon_intr.c | 44 +- celt/bands.c | 222 +- celt/bands.h | 22 +- celt/celt.c | 52 +- celt/celt.h | 92 +- celt/celt_decoder.c | 334 +- celt/celt_encoder.c | 572 +- celt/celt_lpc.c | 94 +- celt/celt_lpc.h | 20 +- celt/cpu_support.h | 28 +- celt/cwrs.c | 82 +- celt/cwrs.h | 6 +- celt/dump_modes/Makefile | 2 +- celt/dump_modes/dump_modes.c | 18 +- celt/ecintrin.h | 6 +- celt/entcode.c | 20 +- celt/entcode.h | 42 +- celt/entdec.c | 40 +- celt/entdec.h | 8 +- celt/entenc.c | 40 +- celt/entenc.h | 10 +- celt/fixed_c5x.h | 2 +- celt/fixed_debug.h | 166 +- celt/fixed_generic.h | 78 +- celt/float_cast.h | 20 +- celt/kiss_fft.c | 52 +- celt/kiss_fft.h | 86 +- celt/laplace.c | 22 +- celt/laplace.h | 4 +- celt/mathops.c | 80 +- celt/mathops.h | 178 +- celt/mdct.c | 64 +- celt/mdct.h | 32 +- celt/meson.build | 14 +- celt/mfrngcod.h | 2 +- celt/mips/celt_mipsr1.h | 30 +- celt/mips/fixed_generic_mipsr1.h | 24 +- celt/mips/mdct_mipsr1.h | 54 +- celt/mips/pitch_mipsr1.h | 34 +- celt/modes.c | 88 +- celt/modes.h | 14 +- .../{opus_custom_demo.c => oac_custom_demo.c} | 108 +- celt/os_support.h | 38 +- celt/pitch.c | 118 +- celt/pitch.h | 54 +- celt/quant_bands.c | 94 +- celt/quant_bands.h | 6 +- celt/rate.c | 50 +- celt/rate.h | 8 +- celt/stack_alloc.h | 32 +- celt/static_modes_fixed.h | 24 +- celt/static_modes_float.h | 24 +- celt/tests/meson.build | 2 +- celt/tests/test_unit_cwrs32.c | 14 +- celt/tests/test_unit_dft.c | 12 +- celt/tests/test_unit_laplace.c | 2 +- celt/tests/test_unit_mathops.c | 78 +- celt/tests/test_unit_mdct.c | 4 +- celt/tests/test_unit_types.c | 8 +- celt/vq.c | 88 +- celt/vq.h | 20 +- celt/x86/celt_lpc_sse.h | 22 +- celt/x86/celt_lpc_sse4_1.c | 22 +- celt/x86/pitch_avx.c | 2 +- celt/x86/pitch_sse.c | 16 +- celt/x86/pitch_sse.h | 140 +- celt/x86/pitch_sse2.c | 8 +- celt/x86/pitch_sse4_1.c | 16 +- celt/x86/vq_sse.h | 12 +- celt/x86/vq_sse2.c | 8 +- celt/x86/x86_arch_macros.h | 6 +- celt/x86/x86_celt_map.c | 78 +- celt/x86/x86cpu.c | 20 +- celt/x86/x86cpu.h | 28 +- celt_headers.mk | 6 +- ...OpusBuildtype.cmake => OacBuildtype.cmake} | 4 +- cmake/{OpusConfig.cmake => OacConfig.cmake} | 36 +- cmake/OacConfig.cmake.in | 20 + ...OpusFunctions.cmake => OacFunctions.cmake} | 68 +- cmake/OacPackageVersion.cmake | 70 + cmake/OacSources.cmake | 72 + cmake/OpusConfig.cmake.in | 20 - cmake/OpusPackageVersion.cmake | 70 - cmake/OpusSources.cmake | 72 - cmake/README.md | 42 +- configure.ac | 318 +- dnn/arm/arm_dnn_map.c | 12 +- dnn/arm/dnn_arm.h | 24 +- dnn/bwe_demo.c | 2 +- dnn/common.h | 8 +- dnn/dred_coding.h | 2 +- dnn/dred_compare.c | 24 +- dnn/dred_decoder.c | 4 +- dnn/dred_decoder.h | 6 +- dnn/dred_encoder.c | 28 +- dnn/dred_encoder.h | 4 +- dnn/dred_rdovae.h | 2 +- dnn/dred_rdovae_dec.c | 12 +- dnn/dred_rdovae_enc.c | 16 +- dnn/dump_data.c | 18 +- dnn/dump_lpcnet_tables.c | 4 +- dnn/fargan.c | 40 +- dnn/fargan.h | 2 +- dnn/fargan_demo.c | 20 +- dnn/freq.c | 30 +- dnn/fwgan.c | 28 +- dnn/fwgan.h | 2 +- dnn/lossgen.c | 10 +- dnn/lpcnet.c | 46 +- dnn/lpcnet.h | 22 +- dnn/lpcnet_enc.c | 30 +- dnn/lpcnet_plc.c | 28 +- dnn/lpcnet_private.h | 6 +- dnn/lpcnet_tables.c | 2 +- dnn/meson.build | 10 +- dnn/nndsp.c | 58 +- dnn/nndsp.h | 2 +- dnn/nnet.c | 20 +- dnn/nnet.h | 10 +- dnn/nnet_arch.h | 20 +- dnn/osce.c | 90 +- dnn/osce.h | 12 +- dnn/osce_features.c | 30 +- dnn/osce_features.h | 10 +- dnn/osce_structs.h | 4 +- dnn/parse_lpcnet_weights.c | 12 +- dnn/pitchdnn.c | 6 +- dnn/test_vec.c | 2 +- dnn/torch/lossgen/export_lossgen.py | 2 +- .../export_neuralpitch_weights.py | 2 +- dnn/torch/osce/data/silk_conversion_set.py | 2 +- dnn/torch/osce/data/silk_enhancement_set.py | 2 +- dnn/torch/osce/stndrd/evaluation/evaluate.py | 14 +- .../osce/stndrd/evaluation/highband_eval.py | 6 +- .../osce/stndrd/evaluation/make_boxplots.py | 4 +- .../evaluation/make_boxplots_moctest.py | 4 +- .../osce/stndrd/evaluation/make_tables.py | 14 +- .../stndrd/evaluation/make_tables_moctest.py | 14 +- dnn/torch/osce/stndrd/evaluation/moc.py | 2 +- dnn/torch/osce/stndrd/evaluation/moc2.py | 2 +- dnn/torch/osce/stndrd/evaluation/run_nomad.py | 10 +- .../osce/stndrd/evaluation/run_osce_test.py | 32 +- dnn/torch/osce/utils/moc.py | 2 +- dnn/torch/osce/utils/silk_features.py | 4 +- dnn/torch/osce/utils/spec.py | 4 +- dnn/torch/osce/utils/templates.py | 6 +- dnn/torch/plc/export_plc.py | 2 +- dnn/torch/rdovae/export_rdovae_weights.py | 20 +- dnn/torch/rdovae/fec_encoder.py | 2 +- .../wexchange/c_export/common.py | 12 +- dnn/training_tf2/dataloader.py | 49 - dnn/training_tf2/decode_rdovae.py | 111 - dnn/training_tf2/diffembed.py | 49 - dnn/training_tf2/dump_lpcnet.py | 388 - dnn/training_tf2/dump_plc.py | 296 - dnn/training_tf2/dump_rdovae.py | 306 - dnn/training_tf2/encode_rdovae.py | 125 - dnn/training_tf2/fec_encoder.py | 256 - dnn/training_tf2/fec_packets.c | 142 - dnn/training_tf2/fec_packets.h | 34 - dnn/training_tf2/fec_packets.py | 108 - dnn/training_tf2/keraslayerdump.py | 189 - dnn/training_tf2/lossfuncs.py | 99 - dnn/training_tf2/lpcnet.py | 339 - dnn/training_tf2/lpcnet_plc.py | 101 - dnn/training_tf2/mdense.py | 95 - dnn/training_tf2/pade.py | 70 - dnn/training_tf2/parameters.py | 29 - dnn/training_tf2/plc_loader.py | 73 - dnn/training_tf2/rdovae.py | 372 - dnn/training_tf2/rdovae_exchange.py | 138 - dnn/training_tf2/rdovae_import.py | 123 - dnn/training_tf2/test_lpcnet.py | 120 - dnn/training_tf2/test_plc.py | 92 - dnn/training_tf2/tf_funcs.py | 70 - dnn/training_tf2/train_lpcnet.py | 214 - dnn/training_tf2/train_plc.py | 197 - dnn/training_tf2/train_rdovae.py | 151 - dnn/training_tf2/ulaw.py | 19 - dnn/training_tf2/uniform_noise.py | 78 - dnn/vec.h | 24 +- dnn/vec_avx.h | 32 +- dnn/vec_neon.h | 20 +- dnn/write_lpcnet_weights.c | 2 +- dnn/x86/dnn_x86.h | 28 +- dnn/x86/x86_dnn_map.c | 10 +- doc/Doxyfile.in | 26 +- doc/Makefile.am | 16 +- doc/build_draft.sh | 113 - doc/build_isobmff.sh | 50 - doc/build_oggdraft.sh | 52 - doc/draft-ietf-codec-oggopus.xml | 1873 ---- doc/draft-ietf-codec-opus-update.xml | 513 - doc/draft-ietf-codec-opus.xml | 8276 ----------------- doc/draft-ietf-payload-rtp-opus.xml | 960 -- doc/meson.build | 14 +- doc/opus_in_isobmff.css | 60 - doc/opus_in_isobmff.html | 692 -- doc/opus_logo.svg | 157 - doc/opus_update.patch | 244 - doc/release.txt | 43 - doc/trivial_example.c | 42 +- include/meson.build | 16 +- include/{opus.h => oac.h} | 852 +- include/{opus_custom.h => oac_custom.h} | 238 +- include/oac_defines.h | 860 ++ .../{opus_multistream.h => oac_multistream.h} | 390 +- .../{opus_projection.h => oac_projection.h} | 356 +- include/oac_types.h | 166 + include/opus_defines.h | 860 -- include/opus_types.h | 166 - m4/{opus-intrinsics.m4 => oac-intrinsics.m4} | 6 +- meson.build | 232 +- meson/README.md | 28 +- meson/get-version.py | 36 +- meson/read-sources-list.py | 2 +- meson_options.txt | 6 +- oac-uninstalled.pc.in | 12 + oac.m4 | 117 + oac.pc.in | 16 + oac_headers.mk | 8 + oac_sources.mk | 17 + opus-uninstalled.pc.in | 12 - opus.m4 | 117 - opus.pc.in | 16 - opus_headers.mk | 8 - opus_sources.mk | 17 - releases.sha2 | 86 - scripts/dump_rnn.py | 57 - scripts/local_build.py | 4 +- scripts/rnn_train.py | 67 - silk/A2NLSF.c | 62 +- silk/API.h | 54 +- silk/CNG.c | 46 +- silk/HP_variable_cutoff.c | 4 +- silk/Inlines.h | 50 +- silk/LPC_analysis_filter.c | 24 +- silk/LPC_fit.c | 20 +- silk/LPC_inv_pred_gain.c | 34 +- silk/LP_variable_cutoff.c | 32 +- silk/MacroCount.h | 320 +- silk/MacroDebug.h | 310 +- silk/NLSF2A.c | 36 +- silk/NLSF_VQ.c | 24 +- silk/NLSF_VQ_weights_laroia.c | 28 +- silk/NLSF_decode.c | 40 +- silk/NLSF_del_dec_quant.c | 54 +- silk/NLSF_encode.c | 58 +- silk/NLSF_stabilize.c | 16 +- silk/NLSF_unpack.c | 12 +- silk/NSQ.c | 196 +- silk/NSQ.h | 14 +- silk/NSQ_del_dec.c | 288 +- silk/PLC.c | 120 +- silk/PLC.h | 8 +- silk/SigProc_FIX.h | 388 +- silk/VAD.c | 60 +- silk/VQ_WMat_EC.c | 38 +- silk/ana_filt_bank_1.c | 26 +- silk/arm/LPC_inv_pred_gain_arm.h | 18 +- silk/arm/LPC_inv_pred_gain_neon_intr.c | 64 +- silk/arm/NSQ_del_dec_arm.h | 54 +- silk/arm/NSQ_del_dec_neon_intr.c | 380 +- silk/arm/NSQ_neon.c | 8 +- silk/arm/NSQ_neon.h | 28 +- silk/arm/SigProc_FIX_armv4.h | 6 +- silk/arm/SigProc_FIX_armv5e.h | 10 +- silk/arm/arm_silk_map.c | 78 +- silk/arm/biquad_alt_arm.h | 36 +- silk/arm/biquad_alt_neon_intr.c | 38 +- silk/arm/macros_armv4.h | 16 +- silk/arm/macros_armv5e.h | 46 +- silk/biquad_alt.c | 38 +- silk/bwexpander.c | 14 +- silk/bwexpander_32.c | 10 +- silk/check_control_input.c | 2 +- silk/code_signs.c | 36 +- silk/control.h | 78 +- silk/control_SNR.c | 4 +- silk/control_audio_bandwidth.c | 14 +- silk/control_codec.c | 70 +- silk/debug.c | 8 +- silk/debug.h | 14 +- silk/dec_API.c | 88 +- silk/decode_core.c | 50 +- silk/decode_frame.c | 26 +- silk/decode_indices.c | 50 +- silk/decode_parameters.c | 16 +- silk/decode_pitch.c | 14 +- silk/decode_pulses.c | 16 +- silk/decoder_set_fs.c | 8 +- silk/enc_API.c | 68 +- silk/encode_indices.c | 16 +- silk/encode_pulses.c | 60 +- silk/fixed/LTP_analysis_filter_FIX.c | 28 +- silk/fixed/LTP_scale_ctrl_FIX.c | 4 +- silk/fixed/apply_sine_window_FIX.c | 34 +- .../arm/warped_autocorrelation_FIX_arm.h | 24 +- .../warped_autocorrelation_FIX_neon_intr.c | 62 +- silk/fixed/autocorr_FIX.c | 12 +- silk/fixed/burg_modified_FIX.c | 78 +- silk/fixed/corrMatrix_FIX.c | 36 +- silk/fixed/encode_frame_FIX.c | 74 +- silk/fixed/find_LPC_FIX.c | 30 +- silk/fixed/find_LTP_FIX.c | 26 +- silk/fixed/find_pitch_lags_FIX.c | 30 +- silk/fixed/find_pred_coefs_FIX.c | 36 +- silk/fixed/k2a_FIX.c | 12 +- silk/fixed/k2a_Q16_FIX.c | 10 +- silk/fixed/main_FIX.h | 144 +- .../mips/warped_autocorrelation_FIX_mipsr1.h | 38 +- silk/fixed/noise_shape_analysis_FIX.c | 80 +- silk/fixed/pitch_analysis_core_FIX.c | 204 +- silk/fixed/process_gains_FIX.c | 8 +- silk/fixed/regularize_correlations_FIX.c | 10 +- silk/fixed/residual_energy16_FIX.c | 26 +- silk/fixed/residual_energy_FIX.c | 28 +- silk/fixed/schur64_FIX.c | 16 +- silk/fixed/schur_FIX.c | 16 +- silk/fixed/structs_FIX.h | 66 +- silk/fixed/vector_ops_FIX.c | 48 +- silk/fixed/warped_autocorrelation_FIX.c | 26 +- silk/fixed/x86/burg_modified_FIX_sse4_1.c | 86 +- silk/fixed/x86/vector_ops_FIX_sse4_1.c | 16 +- silk/float/LPC_analysis_filter_FLP.c | 34 +- silk/float/LPC_inv_pred_gain_FLP.c | 4 +- silk/float/LTP_analysis_filter_FLP.c | 10 +- silk/float/LTP_scale_ctrl_FLP.c | 4 +- silk/float/SigProc_FLP.h | 74 +- silk/float/apply_sine_window_FLP.c | 6 +- silk/float/autocorrelation_FLP.c | 6 +- silk/float/burg_modified_FLP.c | 8 +- silk/float/bwexpander_FLP.c | 4 +- silk/float/corrMatrix_FLP.c | 12 +- silk/float/encode_frame_FLP.c | 58 +- silk/float/energy_FLP.c | 4 +- silk/float/find_LPC_FLP.c | 8 +- silk/float/find_LTP_FLP.c | 8 +- silk/float/find_pitch_lags_FLP.c | 2 +- silk/float/find_pred_coefs_FLP.c | 6 +- silk/float/inner_product_FLP.c | 4 +- silk/float/k2a_FLP.c | 4 +- silk/float/main_FLP.h | 96 +- silk/float/noise_shape_analysis_FLP.c | 22 +- silk/float/pitch_analysis_core_FLP.c | 124 +- silk/float/process_gains_FLP.c | 10 +- silk/float/regularize_correlations_FLP.c | 4 +- silk/float/residual_energy_FLP.c | 12 +- silk/float/scale_copy_vector_FLP.c | 4 +- silk/float/scale_vector_FLP.c | 4 +- silk/float/schur_FLP.c | 4 +- silk/float/sort_FLP.c | 8 +- silk/float/structs_FLP.h | 24 +- silk/float/warped_autocorrelation_FLP.c | 6 +- silk/float/wrappers_FLP.c | 82 +- silk/float/x86/inner_product_FLP_avx2.c | 4 +- silk/gain_quant.c | 34 +- silk/init_decoder.c | 6 +- silk/init_encoder.c | 4 +- silk/inner_prod_aligned.c | 14 +- silk/interpolate.c | 14 +- silk/lin2log.c | 6 +- silk/log2lin.c | 6 +- silk/macros.h | 72 +- silk/main.h | 352 +- silk/meson.build | 10 +- silk/mips/NSQ_mips.h | 16 +- silk/mips/macros_mipsr1.h | 12 +- silk/pitch_est_defines.h | 14 +- silk/pitch_est_tables.c | 14 +- silk/process_NLSFs.c | 20 +- silk/quant_LTP_gains.c | 44 +- silk/resampler.c | 32 +- silk/resampler_down2.c | 18 +- silk/resampler_down2_3.c | 26 +- silk/resampler_private.h | 36 +- silk/resampler_private_AR2.c | 16 +- silk/resampler_private_IIR_FIR.c | 38 +- silk/resampler_private_down_FIR.c | 52 +- silk/resampler_private_up2_HQ.c | 24 +- silk/resampler_rom.c | 18 +- silk/resampler_rom.h | 24 +- silk/resampler_structs.h | 26 +- silk/shell_coder.c | 38 +- silk/sigm_Q15.c | 12 +- silk/sort.c | 32 +- silk/stereo_LR_to_MS.c | 90 +- silk/stereo_MS_to_LR.c | 48 +- silk/stereo_decode_pred.c | 8 +- silk/stereo_encode_pred.c | 6 +- silk/stereo_find_predictor.c | 20 +- silk/stereo_quant_pred.c | 8 +- silk/structs.h | 362 +- silk/sum_sqr_shift.c | 22 +- silk/table_LSF_cos.c | 2 +- silk/tables.h | 90 +- silk/tables_LTP.c | 42 +- silk/tables_NLSF_CB_NB_MB.c | 16 +- silk/tables_NLSF_CB_WB.c | 16 +- silk/tables_gain.c | 4 +- silk/tables_other.c | 42 +- silk/tables_pitch_lag.c | 12 +- silk/tables_pulses_per_block.c | 22 +- silk/tests/meson.build | 2 +- silk/tests/test_unit_LPC_inv_pred_gain.c | 12 +- silk/typedef.h | 16 +- silk/x86/NSQ_del_dec_avx2.c | 348 +- silk/x86/NSQ_del_dec_sse4_1.c | 300 +- silk/x86/NSQ_sse4_1.c | 212 +- silk/x86/SigProc_FIX_sse.h | 66 +- silk/x86/VAD_sse4_1.c | 44 +- silk/x86/VQ_WMat_EC_sse4_1.c | 48 +- silk/x86/main_sse.h | 262 +- silk/x86/x86_silk_map.c | 114 +- silk/xtensa/SigProc_FIX_lx7.h | 4 +- silk/xtensa/macros_lx7.h | 16 +- src/analysis.c | 60 +- src/analysis.h | 12 +- src/extensions.c | 196 +- src/mapping_matrix.c | 94 +- src/mapping_matrix.h | 54 +- src/meson.build | 36 +- src/mlp.c | 10 +- src/mlp.h | 12 +- src/mlp_data.c | 14 +- src/{opus.c => oac.c} | 80 +- src/{opus_compare.c => oac_compare.c} | 30 +- src/{opus_decoder.c => oac_decoder.c} | 568 +- src/{opus_demo.c => oac_demo.c} | 476 +- src/{opus_encoder.c => oac_encoder.c} | 1086 +-- src/{opus_multistream.c => oac_multistream.c} | 6 +- ...am_decoder.c => oac_multistream_decoder.c} | 270 +- ...am_encoder.c => oac_multistream_encoder.c} | 570 +- src/oac_private.h | 266 + ...ion_decoder.c => oac_projection_decoder.c} | 134 +- ...ion_encoder.c => oac_projection_encoder.c} | 174 +- src/opus_private.h | 266 - src/qext_compare.c | 24 +- src/repacketizer.c | 186 +- src/repacketizer_demo.c | 32 +- tests/meson.build | 28 +- .../{opus_build_test.sh => oac_build_test.sh} | 0 ...us_decode_fuzzer.c => oac_decode_fuzzer.c} | 42 +- ...regressions.c => oac_encode_regressions.c} | 560 +- tests/random_config.sh | 2 +- tests/run_opushd_vectors.sh | 158 - tests/run_vectors.sh | 26 +- tests/test_oac_api.c | 1916 ++++ .../{test_opus_common.h => test_oac_common.h} | 16 +- .../{test_opus_custom.c => test_oac_custom.c} | 234 +- .../{test_opus_decode.c => test_oac_decode.c} | 186 +- tests/{test_opus_dred.c => test_oac_dred.c} | 28 +- .../{test_opus_encode.c => test_oac_encode.c} | 440 +- ...pus_extensions.c => test_oac_extensions.c} | 270 +- ...test_opus_padding.c => test_oac_padding.c} | 20 +- ...pus_projection.c => test_oac_projection.c} | 152 +- tests/test_opus_api.c | 1916 ---- training/rnn_dump.py | 66 - training/rnn_train.py | 176 - training/txt2hdf5.py | 12 - 486 files changed, 15907 insertions(+), 34205 deletions(-) delete mode 100644 .gitlab-ci.yml delete mode 100644 LICENSE_PLEASE_READ.txt delete mode 100644 README.draft rename celt/{opus_custom_demo.c => oac_custom_demo.c} (83%) rename cmake/{OpusBuildtype.cmake => OacBuildtype.cmake} (93%) rename cmake/{OpusConfig.cmake => OacConfig.cmake} (78%) create mode 100644 cmake/OacConfig.cmake.in rename cmake/{OpusFunctions.cmake => OacFunctions.cmake} (75%) create mode 100644 cmake/OacPackageVersion.cmake create mode 100644 cmake/OacSources.cmake delete mode 100644 cmake/OpusConfig.cmake.in delete mode 100644 cmake/OpusPackageVersion.cmake delete mode 100644 cmake/OpusSources.cmake delete mode 100644 dnn/training_tf2/dataloader.py delete mode 100644 dnn/training_tf2/decode_rdovae.py delete mode 100644 dnn/training_tf2/diffembed.py delete mode 100755 dnn/training_tf2/dump_lpcnet.py delete mode 100755 dnn/training_tf2/dump_plc.py delete mode 100644 dnn/training_tf2/dump_rdovae.py delete mode 100644 dnn/training_tf2/encode_rdovae.py delete mode 100644 dnn/training_tf2/fec_encoder.py delete mode 100644 dnn/training_tf2/fec_packets.c delete mode 100644 dnn/training_tf2/fec_packets.h delete mode 100644 dnn/training_tf2/fec_packets.py delete mode 100644 dnn/training_tf2/keraslayerdump.py delete mode 100644 dnn/training_tf2/lossfuncs.py delete mode 100644 dnn/training_tf2/lpcnet.py delete mode 100644 dnn/training_tf2/lpcnet_plc.py delete mode 100644 dnn/training_tf2/mdense.py delete mode 100644 dnn/training_tf2/pade.py delete mode 100644 dnn/training_tf2/parameters.py delete mode 100644 dnn/training_tf2/plc_loader.py delete mode 100644 dnn/training_tf2/rdovae.py delete mode 100644 dnn/training_tf2/rdovae_exchange.py delete mode 100644 dnn/training_tf2/rdovae_import.py delete mode 100755 dnn/training_tf2/test_lpcnet.py delete mode 100644 dnn/training_tf2/test_plc.py delete mode 100644 dnn/training_tf2/tf_funcs.py delete mode 100755 dnn/training_tf2/train_lpcnet.py delete mode 100644 dnn/training_tf2/train_plc.py delete mode 100644 dnn/training_tf2/train_rdovae.py delete mode 100644 dnn/training_tf2/ulaw.py delete mode 100644 dnn/training_tf2/uniform_noise.py delete mode 100755 doc/build_draft.sh delete mode 100755 doc/build_isobmff.sh delete mode 100755 doc/build_oggdraft.sh delete mode 100644 doc/draft-ietf-codec-oggopus.xml delete mode 100644 doc/draft-ietf-codec-opus-update.xml delete mode 100644 doc/draft-ietf-codec-opus.xml delete mode 100644 doc/draft-ietf-payload-rtp-opus.xml delete mode 100644 doc/opus_in_isobmff.css delete mode 100644 doc/opus_in_isobmff.html delete mode 100644 doc/opus_logo.svg delete mode 100644 doc/opus_update.patch delete mode 100644 doc/release.txt rename include/{opus.h => oac.h} (54%) rename include/{opus_custom.h => oac_custom.h} (60%) create mode 100644 include/oac_defines.h rename include/{opus_multistream.h => oac_multistream.h} (71%) rename include/{opus_projection.h => oac_projection.h} (69%) create mode 100644 include/oac_types.h delete mode 100644 include/opus_defines.h delete mode 100644 include/opus_types.h rename m4/{opus-intrinsics.m4 => oac-intrinsics.m4} (76%) create mode 100644 oac-uninstalled.pc.in create mode 100644 oac.m4 create mode 100644 oac.pc.in create mode 100644 oac_headers.mk create mode 100644 oac_sources.mk delete mode 100644 opus-uninstalled.pc.in delete mode 100644 opus.m4 delete mode 100644 opus.pc.in delete mode 100644 opus_headers.mk delete mode 100644 opus_sources.mk delete mode 100644 releases.sha2 delete mode 100755 scripts/dump_rnn.py delete mode 100755 scripts/rnn_train.py rename src/{opus.c => oac.c} (83%) rename src/{opus_compare.c => oac_compare.c} (92%) rename src/{opus_decoder.c => oac_decoder.c} (70%) rename src/{opus_demo.c => oac_demo.c} (72%) rename src/{opus_encoder.c => oac_encoder.c} (73%) rename src/{opus_multistream.c => oac_multistream.c} (97%) rename src/{opus_multistream_decoder.c => oac_multistream_decoder.c} (62%) rename src/{opus_multistream_encoder.c => oac_multistream_encoder.c} (69%) create mode 100644 src/oac_private.h rename src/{opus_projection_decoder.c => oac_projection_decoder.c} (59%) rename src/{opus_projection_encoder.c => oac_projection_encoder.c} (76%) delete mode 100644 src/opus_private.h rename tests/{opus_build_test.sh => oac_build_test.sh} (100%) rename tests/{opus_decode_fuzzer.c => oac_decode_fuzzer.c} (74%) rename tests/{opus_encode_regressions.c => oac_encode_regressions.c} (77%) delete mode 100755 tests/run_opushd_vectors.sh create mode 100644 tests/test_oac_api.c rename tests/{test_opus_common.h => test_oac_common.h} (86%) rename tests/{test_opus_custom.c => test_oac_custom.c} (72%) rename tests/{test_opus_decode.c => test_oac_decode.c} (64%) rename tests/{test_opus_dred.c => test_oac_dred.c} (79%) rename tests/{test_opus_encode.c => test_oac_encode.c} (50%) rename tests/{test_opus_extensions.c => test_oac_extensions.c} (71%) rename tests/{test_opus_padding.c => test_oac_padding.c} (83%) rename tests/{test_opus_projection.c => test_oac_projection.c} (69%) delete mode 100644 tests/test_opus_api.c delete mode 100755 training/rnn_dump.py delete mode 100755 training/rnn_train.py delete mode 100755 training/txt2hdf5.py diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 17945345a..20a663d32 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -28,7 +28,7 @@ jobs: run: | which cmake cmake --version - cmake .. -DOPUS_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON + cmake .. -DOAC_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON - name: Build working-directory: ./build run: make -j 2 -s @@ -53,7 +53,7 @@ jobs: run: cmake --version - name: Configure working-directory: ./build - run: cmake .. -DOPUS_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc + run: cmake .. -DOAC_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc - name: Build working-directory: ./build run: cmake --build . -j 2 --config Release --target package @@ -206,25 +206,25 @@ jobs: name: "CustomModes/Linux/Lib/X64/Release", os: ubuntu-latest, config: Release, - args: "-DOPUS_CUSTOM_MODES=ON" + args: "-DOAC_CUSTOM_MODES=ON" } - { name: "AssertionsFuzz/Windows/Lib/X64/Release", os: windows-latest, config: Release, - args: -G "Visual Studio 17 2022" -A Win32 -DOPUS_ASSERTIONS=ON -DOPUS_FUZZING=ON + args: -G "Visual Studio 17 2022" -A Win32 -DOAC_ASSERTIONS=ON -DOAC_FUZZING=ON } - { name: "AssertionsFuzz/Linux/Lib/X64/Release", os: ubuntu-latest, config: Release, - args: -DOPUS_ASSERTIONS=ON -DOPUS_FUZZING=ON + args: -DOAC_ASSERTIONS=ON -DOAC_FUZZING=ON } - { name: "AssertionsFuzz/MacOSX/Lib/X64/Release", os: macos-latest, config: Release, - args: -DOPUS_ASSERTIONS=ON -DOPUS_FUZZING=ON + args: -DOAC_ASSERTIONS=ON -DOAC_FUZZING=ON } steps: @@ -249,7 +249,7 @@ jobs: run: cmake --version - name: Configure working-directory: ./build - run: cmake .. ${{ matrix.config.args }} -DCMAKE_BUILD_TYPE=${{ matrix.config.config }} -DOPUS_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON + run: cmake .. ${{ matrix.config.args }} -DCMAKE_BUILD_TYPE=${{ matrix.config.config }} -DOAC_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON - name: Build working-directory: ./build run: cmake --build . -j 2 --config ${{ matrix.config.config }} --target package diff --git a/.github/workflows/dred.yml b/.github/workflows/dred.yml index ad316357a..527ded655 100644 --- a/.github/workflows/dred.yml +++ b/.github/workflows/dred.yml @@ -18,7 +18,7 @@ jobs: name: "Windows/Lib/X64/Release", os: windows-latest, config: Release, - args: -G "Visual Studio 17 2022" -DOPUS_X86_PRESUME_AVX2=ON + args: -G "Visual Studio 17 2022" -DOAC_X86_PRESUME_AVX2=ON } - { name: "Windows/Lib/armv8/Release", @@ -30,7 +30,7 @@ jobs: name: "Linux/Lib/X64/Release", os: ubuntu-latest, config: Release, - args: -DOPUS_X86_PRESUME_AVX2=ON + args: -DOAC_X86_PRESUME_AVX2=ON } - { name: "Android/Lib/X64/Release", @@ -49,7 +49,7 @@ jobs: os: macos-latest, config: Release, # some macs are really old in githubs lab so they don't support avx - args: -DOPUS_X86_PRESUME_AVX2=OFF + args: -DOAC_X86_PRESUME_AVX2=OFF } - { name: "iOS/Lib/arm64/Release", @@ -77,7 +77,7 @@ jobs: run: mkdir build - name: Configure working-directory: ./build - run: cmake .. ${{ matrix.config.args }} -DCMAKE_BUILD_TYPE=${{ matrix.config.config }} -DOPUS_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON -DOPUS_FAST_MATH=ON -DOPUS_FLOAT_APPROX=ON -DOPUS_DRED=ON -DOPUS_OSCE=ON + run: cmake .. ${{ matrix.config.args }} -DCMAKE_BUILD_TYPE=${{ matrix.config.config }} -DOAC_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON -DOAC_FAST_MATH=ON -DOAC_FLOAT_APPROX=ON -DOAC_DRED=ON -DOAC_OSCE=ON - name: Build working-directory: ./build run: cmake --build . -j 2 --config ${{ matrix.config.config }} --target package diff --git a/.gitignore b/.gitignore index 5a49669ce..bb86fa591 100644 --- a/.gitignore +++ b/.gitignore @@ -33,8 +33,8 @@ m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 -opus_compare -opus_demo +oac_compare +oac_demo repacketizer_demo stamp-h1 test-driver @@ -46,12 +46,12 @@ trivial_example *.tar.gz *~ tests/*test -tests/test_opus_api -tests/test_opus_decode -tests/test_opus_encode -tests/test_opus_extensions -tests/test_opus_padding -tests/test_opus_projection +tests/test_oac_api +tests/test_oac_decode +tests/test_oac_encode +tests/test_oac_extensions +tests/test_oac_padding +tests/test_oac_projection celt/arm/armopts.s celt/dump_modes/dump_modes celt/tests/test_unit_cwrs32 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 6f8a81f9c..000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,134 +0,0 @@ -include: - - template: 'Workflows/Branch-Pipelines.gitlab-ci.yml' - -# https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines -workflow: - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push" - when: never - - if: $CI_COMMIT_BRANCH - - if: $CI_COMMIT_TAG - -default: - tags: - - docker - image: 'debian:bookworm-slim' - -# https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html#reference-tags -.snippets: - git_prep: - # Make sure we have a recent annotated tag, otherwise meson/get-version.py - # might fail later (e.g. shallow clone without enough history) or return - # a bogus version based on a much older tag. This can happen in merge request - # pipelines from a personal fork, as the fork might not have the latest - # upstream tags if it has been forked a long time ago. Also affects the - # git version picked up by autotools and cmake, not just meson. - - git fetch https://gitlab.xiph.org/xiph/opus.git refs/tags/v1.4:refs/tags/v1.4 - - git describe - -whitespace: - stage: test - before_script: - - apt-get update && - apt-get install -y git - script: - - git diff-tree --check origin/main HEAD - -# Make sure commits are GPG signed -ci-fairy: - stage: test - script: - - apt update - - apt install -y python3-pip git - - pip3 install --break-system-packages git+https://gitlab.freedesktop.org/freedesktop/ci-templates@7811ba9814a3bad379377241c6c6b62d78b20eac - - echo Checking commits $CI_FAIRY_BASE_COMMIT..HEAD - - ci-fairy check-commits --gpg-signed-commit $CI_FAIRY_BASE_COMMIT..HEAD - tags: - - 'docker' - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - variables: - CI_FAIRY_BASE_COMMIT: $CI_MERGE_REQUEST_DIFF_BASE_SHA - - if: $CI_PIPELINE_SOURCE != "merge_request_event" - variables: - CI_FAIRY_BASE_COMMIT: 'HEAD^1' - -autoconf: - stage: build - tags: - - avx2 - before_script: - - apt-get update && - apt-get install -y zip doxygen git automake libtool make wget - - !reference [.snippets, git_prep] - script: - - ./autogen.sh - - CFLAGS="-mavx -mfma -mavx2 -O2 -ffast-math" ./configure --enable-float-approx --enable-dred --enable-osce - - make -j16 - - DISTCHECK_CONFIGURE_FLAGS="--enable-float-approx --enable-dred --enable-osce CFLAGS='-mavx -mfma -mavx2 -O2'" make distcheck -j16 - cache: - paths: - - "src/*.o" - - "src/.libs/*.o" - - "silk/*.o" - - "silk/.libs/*.o" - - "celt/*.o" - - "celt/.libs/*.o" - -cmake: - stage: build - tags: - - avx2 - before_script: - - apt-get update && - apt-get install -y cmake ninja-build git automake libtool wget - - !reference [.snippets, git_prep] - script: - - ./autogen.sh - - mkdir build - - cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DOPUS_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON -DOPUS_FAST_MATH=ON -DOPUS_FLOAT_APPROX=ON -DOPUS_DRED=ON -DOPUS_OSCE=ON -DOPUS_X86_PRESUME_AVX2=ON - - cmake --build build - - cd build && ctest --output-on-failure -j 16 - -.meson: - image: 'debian:bookworm-slim' - stage: build - before_script: - - apt-get update && - apt-get install -y ninja-build doxygen meson git automake libtool wget - - !reference [.snippets, git_prep] - script: - - ./autogen.sh - - mkdir builddir - - meson setup -Ddeep-plc=enabled -Dosce=enabled -Ddred=enabled -Dtests=enabled -Ddocs=enabled -Dbuildtype=release builddir - - meson compile -C builddir - - meson test -C builddir - #- meson dist --no-tests -C builddir - -meson x86_64: - extends: '.meson' - tags: - - avx2 - variables: - MESON_EXTRA_ARGS: '--werror' - -meson arm64: - extends: '.meson' - tags: - - 'gstreamer-arm64-linux-docker' - variables: - # arm64 build has a compiler warning still, so let's not use --werror for now - MESON_EXTRA_ARGS: '-Dwerror=false' - -makefile: - stage: build - image: 'gcc' - before_script: - - apt-get update && - apt-get install -y zip doxygen git make wget - - !reference [.snippets, git_prep] - script: - - make -f Makefile.unix -j8 - - make -f Makefile.unix check -j8 - - make -f Makefile.unix clean diff --git a/CMakeLists.txt b/CMakeLists.txt index fcf034b19..61f23455a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,15 @@ cmake_minimum_required(VERSION 3.16) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -include(OpusPackageVersion) +include(OacPackageVersion) get_package_version(PACKAGE_VERSION PROJECT_VERSION) -project(Opus LANGUAGES C VERSION ${PROJECT_VERSION}) +project(Oac LANGUAGES C VERSION ${PROJECT_VERSION}) -include(OpusFunctions) -include(OpusBuildtype) -include(OpusConfig) -include(OpusSources) +include(OacFunctions) +include(OacBuildtype) +include(OacConfig) +include(OacSources) include(GNUInstallDirs) include(CMakeDependentOption) include(FeatureSummary) @@ -22,237 +22,237 @@ if (MSVC) endif() endif() -set(OPUS_BUILD_SHARED_LIBRARY_HELP_STR "build shared library.") -option(OPUS_BUILD_SHARED_LIBRARY ${OPUS_BUILD_SHARED_LIBRARY_HELP_STR} OFF) -if(OPUS_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS OR OPUS_BUILD_FRAMEWORK) +set(OAC_BUILD_SHARED_LIBRARY_HELP_STR "build shared library.") +option(OAC_BUILD_SHARED_LIBRARY ${OAC_BUILD_SHARED_LIBRARY_HELP_STR} OFF) +if(OAC_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS OR OAC_BUILD_FRAMEWORK) # Global flag to cause add_library() to create shared libraries if on. set(BUILD_SHARED_LIBS ON) - set(OPUS_BUILD_SHARED_LIBRARY ON) + set(OAC_BUILD_SHARED_LIBRARY ON) endif() -add_feature_info(OPUS_BUILD_SHARED_LIBRARY OPUS_BUILD_SHARED_LIBRARY ${OPUS_BUILD_SHARED_LIBRARY_HELP_STR}) +add_feature_info(OAC_BUILD_SHARED_LIBRARY OAC_BUILD_SHARED_LIBRARY ${OAC_BUILD_SHARED_LIBRARY_HELP_STR}) -set(OPUS_BUILD_TESTING_HELP_STR "build tests.") -option(OPUS_BUILD_TESTING ${OPUS_BUILD_TESTING_HELP_STR} OFF) -if(OPUS_BUILD_TESTING OR BUILD_TESTING) - set(OPUS_BUILD_TESTING ON) +set(OAC_BUILD_TESTING_HELP_STR "build tests.") +option(OAC_BUILD_TESTING ${OAC_BUILD_TESTING_HELP_STR} OFF) +if(OAC_BUILD_TESTING OR BUILD_TESTING) + set(OAC_BUILD_TESTING ON) set(BUILD_TESTING ON) endif() -add_feature_info(OPUS_BUILD_TESTING OPUS_BUILD_TESTING ${OPUS_BUILD_TESTING_HELP_STR}) +add_feature_info(OAC_BUILD_TESTING OAC_BUILD_TESTING ${OAC_BUILD_TESTING_HELP_STR}) -set(OPUS_CUSTOM_MODES_HELP_STR "enable non-Opus modes, e.g. 44.1 kHz & 2^n frames.") -option(OPUS_CUSTOM_MODES ${OPUS_CUSTOM_MODES_HELP_STR} OFF) -add_feature_info(OPUS_CUSTOM_MODES OPUS_CUSTOM_MODES ${OPUS_CUSTOM_MODES_HELP_STR}) +set(OAC_CUSTOM_MODES_HELP_STR "enable non-Oac modes, e.g. 44.1 kHz & 2^n frames.") +option(OAC_CUSTOM_MODES ${OAC_CUSTOM_MODES_HELP_STR} OFF) +add_feature_info(OAC_CUSTOM_MODES OAC_CUSTOM_MODES ${OAC_CUSTOM_MODES_HELP_STR}) -set(OPUS_BUILD_PROGRAMS_HELP_STR "build programs.") -option(OPUS_BUILD_PROGRAMS ${OPUS_BUILD_PROGRAMS_HELP_STR} OFF) -add_feature_info(OPUS_BUILD_PROGRAMS OPUS_BUILD_PROGRAMS ${OPUS_BUILD_PROGRAMS_HELP_STR}) +set(OAC_BUILD_PROGRAMS_HELP_STR "build programs.") +option(OAC_BUILD_PROGRAMS ${OAC_BUILD_PROGRAMS_HELP_STR} OFF) +add_feature_info(OAC_BUILD_PROGRAMS OAC_BUILD_PROGRAMS ${OAC_BUILD_PROGRAMS_HELP_STR}) -set(OPUS_DISABLE_INTRINSICS_HELP_STR "disable all intrinsics optimizations.") -option(OPUS_DISABLE_INTRINSICS ${OPUS_DISABLE_INTRINSICS_HELP_STR} OFF) -add_feature_info(OPUS_DISABLE_INTRINSICS OPUS_DISABLE_INTRINSICS ${OPUS_DISABLE_INTRINSICS_HELP_STR}) +set(OAC_DISABLE_INTRINSICS_HELP_STR "disable all intrinsics optimizations.") +option(OAC_DISABLE_INTRINSICS ${OAC_DISABLE_INTRINSICS_HELP_STR} OFF) +add_feature_info(OAC_DISABLE_INTRINSICS OAC_DISABLE_INTRINSICS ${OAC_DISABLE_INTRINSICS_HELP_STR}) -set(OPUS_FIXED_POINT_HELP_STR "compile as fixed-point (for machines without a fast enough FPU).") -option(OPUS_FIXED_POINT ${OPUS_FIXED_POINT_HELP_STR} OFF) -add_feature_info(OPUS_FIXED_POINT OPUS_FIXED_POINT ${OPUS_FIXED_POINT_HELP_STR}) +set(OAC_FIXED_POINT_HELP_STR "compile as fixed-point (for machines without a fast enough FPU).") +option(OAC_FIXED_POINT ${OAC_FIXED_POINT_HELP_STR} OFF) +add_feature_info(OAC_FIXED_POINT OAC_FIXED_POINT ${OAC_FIXED_POINT_HELP_STR}) -set(OPUS_ENABLE_FLOAT_API_HELP_STR "compile with the floating point API (for machines with float library).") -option(OPUS_ENABLE_FLOAT_API ${OPUS_ENABLE_FLOAT_API_HELP_STR} ON) -add_feature_info(OPUS_ENABLE_FLOAT_API OPUS_ENABLE_FLOAT_API ${OPUS_ENABLE_FLOAT_API_HELP_STR}) +set(OAC_ENABLE_FLOAT_API_HELP_STR "compile with the floating point API (for machines with float library).") +option(OAC_ENABLE_FLOAT_API ${OAC_ENABLE_FLOAT_API_HELP_STR} ON) +add_feature_info(OAC_ENABLE_FLOAT_API OAC_ENABLE_FLOAT_API ${OAC_ENABLE_FLOAT_API_HELP_STR}) -set(OPUS_FLOAT_APPROX_HELP_STR "enable floating point approximations (Ensure your platform supports IEEE 754 before enabling).") -option(OPUS_FLOAT_APPROX ${OPUS_FLOAT_APPROX_HELP_STR} OFF) -add_feature_info(OPUS_FLOAT_APPROX OPUS_FLOAT_APPROX ${OPUS_FLOAT_APPROX_HELP_STR}) +set(OAC_FLOAT_APPROX_HELP_STR "enable floating point approximations (Ensure your platform supports IEEE 754 before enabling).") +option(OAC_FLOAT_APPROX ${OAC_FLOAT_APPROX_HELP_STR} OFF) +add_feature_info(OAC_FLOAT_APPROX OAC_FLOAT_APPROX ${OAC_FLOAT_APPROX_HELP_STR}) -set(OPUS_ASSERTIONS_HELP_STR "additional software error checking.") -option(OPUS_ASSERTIONS ${OPUS_ASSERTIONS_HELP_STR} OFF) -add_feature_info(OPUS_ASSERTIONS OPUS_ASSERTIONS ${OPUS_ASSERTIONS_HELP_STR}) +set(OAC_ASSERTIONS_HELP_STR "additional software error checking.") +option(OAC_ASSERTIONS ${OAC_ASSERTIONS_HELP_STR} OFF) +add_feature_info(OAC_ASSERTIONS OAC_ASSERTIONS ${OAC_ASSERTIONS_HELP_STR}) -set(OPUS_HARDENING_HELP_STR "run-time checks that are cheap and safe for use in production.") -option(OPUS_HARDENING ${OPUS_HARDENING_HELP_STR} ON) -add_feature_info(OPUS_HARDENING OPUS_HARDENING ${OPUS_HARDENING_HELP_STR}) +set(OAC_HARDENING_HELP_STR "run-time checks that are cheap and safe for use in production.") +option(OAC_HARDENING ${OAC_HARDENING_HELP_STR} ON) +add_feature_info(OAC_HARDENING OAC_HARDENING ${OAC_HARDENING_HELP_STR}) -set(OPUS_FUZZING_HELP_STR "causes the encoder to make random decisions (do not use in production).") -option(OPUS_FUZZING ${OPUS_FUZZING_HELP_STR} OFF) -add_feature_info(OPUS_FUZZING OPUS_FUZZING ${OPUS_FUZZING_HELP_STR}) +set(OAC_FUZZING_HELP_STR "causes the encoder to make random decisions (do not use in production).") +option(OAC_FUZZING ${OAC_FUZZING_HELP_STR} OFF) +add_feature_info(OAC_FUZZING OAC_FUZZING ${OAC_FUZZING_HELP_STR}) -set(OPUS_CHECK_ASM_HELP_STR "enable bit-exactness checks between optimized and c implementations.") -option(OPUS_CHECK_ASM ${OPUS_CHECK_ASM_HELP_STR} OFF) -add_feature_info(OPUS_CHECK_ASM OPUS_CHECK_ASM ${OPUS_CHECK_ASM_HELP_STR}) +set(OAC_CHECK_ASM_HELP_STR "enable bit-exactness checks between optimized and c implementations.") +option(OAC_CHECK_ASM ${OAC_CHECK_ASM_HELP_STR} OFF) +add_feature_info(OAC_CHECK_ASM OAC_CHECK_ASM ${OAC_CHECK_ASM_HELP_STR}) -set(OPUS_DNN_FLOAT_DEBUG_HELP_STR "Run DNN computations as float for debugging purposes.") -option(OPUS_DNN_FLOAT_DEBUG ${OPUS_DNN_FLOAT_DEBUG_HELP_STR} OFF) -add_feature_info(OPUS_DNN_FLOAT_DEBUG OPUS_DNN_FLOAT_DEBUG ${OPUS_DNN_FLOAT_DEBUG_HELP_STR}) +set(OAC_DNN_FLOAT_DEBUG_HELP_STR "Run DNN computations as float for debugging purposes.") +option(OAC_DNN_FLOAT_DEBUG ${OAC_DNN_FLOAT_DEBUG_HELP_STR} OFF) +add_feature_info(OAC_DNN_FLOAT_DEBUG OAC_DNN_FLOAT_DEBUG ${OAC_DNN_FLOAT_DEBUG_HELP_STR}) -set(OPUS_INSTALL_PKG_CONFIG_MODULE_HELP_STR "install pkg-config module.") -option(OPUS_INSTALL_PKG_CONFIG_MODULE ${OPUS_INSTALL_PKG_CONFIG_MODULE_HELP_STR} ON) -add_feature_info(OPUS_INSTALL_PKG_CONFIG_MODULE OPUS_INSTALL_PKG_CONFIG_MODULE ${OPUS_INSTALL_PKG_CONFIG_MODULE_HELP_STR}) +set(OAC_INSTALL_PKG_CONFIG_MODULE_HELP_STR "install pkg-config module.") +option(OAC_INSTALL_PKG_CONFIG_MODULE ${OAC_INSTALL_PKG_CONFIG_MODULE_HELP_STR} ON) +add_feature_info(OAC_INSTALL_PKG_CONFIG_MODULE OAC_INSTALL_PKG_CONFIG_MODULE ${OAC_INSTALL_PKG_CONFIG_MODULE_HELP_STR}) -set(OPUS_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR "install CMake package config module.") -option(OPUS_INSTALL_CMAKE_CONFIG_MODULE ${OPUS_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR} ON) -add_feature_info(OPUS_INSTALL_CMAKE_CONFIG_MODULE OPUS_INSTALL_CMAKE_CONFIG_MODULE ${OPUS_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR}) +set(OAC_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR "install CMake package config module.") +option(OAC_INSTALL_CMAKE_CONFIG_MODULE ${OAC_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR} ON) +add_feature_info(OAC_INSTALL_CMAKE_CONFIG_MODULE OAC_INSTALL_CMAKE_CONFIG_MODULE ${OAC_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR}) -set(OPUS_DRED_HELP_STR "enable DRED.") -option(OPUS_DRED ${OPUS_DRED_HELP_STR} OFF) -add_feature_info(OPUS_DRED OPUS_DRED ${OPUS_DRED_HELP_STR}) +set(OAC_DRED_HELP_STR "enable DRED.") +option(OAC_DRED ${OAC_DRED_HELP_STR} OFF) +add_feature_info(OAC_DRED OAC_DRED ${OAC_DRED_HELP_STR}) -set(OPUS_OSCE_HELP_STR "enable OSCE.") -option(OPUS_OSCE ${OPUS_OSCE_HELP_STR} OFF) -add_feature_info(OPUS_OSCE OPUS_OSCE ${OPUS_OSCE_HELP_STR}) +set(OAC_OSCE_HELP_STR "enable OSCE.") +option(OAC_OSCE ${OAC_OSCE_HELP_STR} OFF) +add_feature_info(OAC_OSCE OAC_OSCE ${OAC_OSCE_HELP_STR}) if(APPLE) - set(OPUS_BUILD_FRAMEWORK_HELP_STR "build Framework bundle for Apple systems.") - option(OPUS_BUILD_FRAMEWORK ${OPUS_BUILD_FRAMEWORK_HELP_STR} OFF) - add_feature_info(OPUS_BUILD_FRAMEWORK OPUS_BUILD_FRAMEWORK ${OPUS_BUILD_FRAMEWORK_HELP_STR}) + set(OAC_BUILD_FRAMEWORK_HELP_STR "build Framework bundle for Apple systems.") + option(OAC_BUILD_FRAMEWORK ${OAC_BUILD_FRAMEWORK_HELP_STR} OFF) + add_feature_info(OAC_BUILD_FRAMEWORK OAC_BUILD_FRAMEWORK ${OAC_BUILD_FRAMEWORK_HELP_STR}) endif() if(MSVC) - set(OPUS_STATIC_RUNTIME_HELP_STR "build with static runtime library.") - option(OPUS_STATIC_RUNTIME ${OPUS_STATIC_RUNTIME_HELP_STR} OFF) - add_feature_info(OPUS_STATIC_RUNTIME OPUS_STATIC_RUNTIME ${OPUS_STATIC_RUNTIME_HELP_STR}) + set(OAC_STATIC_RUNTIME_HELP_STR "build with static runtime library.") + option(OAC_STATIC_RUNTIME ${OAC_STATIC_RUNTIME_HELP_STR} OFF) + add_feature_info(OAC_STATIC_RUNTIME OAC_STATIC_RUNTIME ${OAC_STATIC_RUNTIME_HELP_STR}) endif() -set(OPUS_FIXED_POINT_DEBUG_HELP_STR "debug fixed-point implementation.") -cmake_dependent_option(OPUS_FIXED_POINT_DEBUG - ${OPUS_FIXED_POINT_DEBUG_HELP_STR} +set(OAC_FIXED_POINT_DEBUG_HELP_STR "debug fixed-point implementation.") +cmake_dependent_option(OAC_FIXED_POINT_DEBUG + ${OAC_FIXED_POINT_DEBUG_HELP_STR} ON - "OPUS_FIXED_POINT; OPUS_FIXED_POINT_DEBUG" + "OAC_FIXED_POINT; OAC_FIXED_POINT_DEBUG" OFF) -add_feature_info(OPUS_FIXED_POINT_DEBUG OPUS_FIXED_POINT_DEBUG ${OPUS_FIXED_POINT_DEBUG_HELP_STR}) +add_feature_info(OAC_FIXED_POINT_DEBUG OAC_FIXED_POINT_DEBUG ${OAC_FIXED_POINT_DEBUG_HELP_STR}) -set(OPUS_VAR_ARRAYS_HELP_STR "use variable length arrays for stack arrays.") -cmake_dependent_option(OPUS_VAR_ARRAYS - ${OPUS_VAR_ARRAYS_HELP_STR} +set(OAC_VAR_ARRAYS_HELP_STR "use variable length arrays for stack arrays.") +cmake_dependent_option(OAC_VAR_ARRAYS + ${OAC_VAR_ARRAYS_HELP_STR} ON - "VLA_SUPPORTED; NOT OPUS_USE_ALLOCA; NOT OPUS_NONTHREADSAFE_PSEUDOSTACK" + "VLA_SUPPORTED; NOT OAC_USE_ALLOCA; NOT OAC_NONTHREADSAFE_PSEUDOSTACK" OFF) -add_feature_info(OPUS_VAR_ARRAYS OPUS_VAR_ARRAYS ${OPUS_VAR_ARRAYS_HELP_STR}) +add_feature_info(OAC_VAR_ARRAYS OAC_VAR_ARRAYS ${OAC_VAR_ARRAYS_HELP_STR}) -set(OPUS_USE_ALLOCA_HELP_STR "use alloca for stack arrays (on non-C99 compilers).") -cmake_dependent_option(OPUS_USE_ALLOCA - ${OPUS_USE_ALLOCA_HELP_STR} +set(OAC_USE_ALLOCA_HELP_STR "use alloca for stack arrays (on non-C99 compilers).") +cmake_dependent_option(OAC_USE_ALLOCA + ${OAC_USE_ALLOCA_HELP_STR} ON - "USE_ALLOCA_SUPPORTED; NOT OPUS_VAR_ARRAYS; NOT OPUS_NONTHREADSAFE_PSEUDOSTACK" + "USE_ALLOCA_SUPPORTED; NOT OAC_VAR_ARRAYS; NOT OAC_NONTHREADSAFE_PSEUDOSTACK" OFF) -add_feature_info(OPUS_USE_ALLOCA OPUS_USE_ALLOCA ${OPUS_USE_ALLOCA_HELP_STR}) +add_feature_info(OAC_USE_ALLOCA OAC_USE_ALLOCA ${OAC_USE_ALLOCA_HELP_STR}) -set(OPUS_NONTHREADSAFE_PSEUDOSTACK_HELP_STR "use a non threadsafe pseudostack when neither variable length arrays or alloca is supported.") -cmake_dependent_option(OPUS_NONTHREADSAFE_PSEUDOSTACK - ${OPUS_NONTHREADSAFE_PSEUDOSTACK_HELP_STR} +set(OAC_NONTHREADSAFE_PSEUDOSTACK_HELP_STR "use a non threadsafe pseudostack when neither variable length arrays or alloca is supported.") +cmake_dependent_option(OAC_NONTHREADSAFE_PSEUDOSTACK + ${OAC_NONTHREADSAFE_PSEUDOSTACK_HELP_STR} ON - "NOT OPUS_VAR_ARRAYS; NOT OPUS_USE_ALLOCA" + "NOT OAC_VAR_ARRAYS; NOT OAC_USE_ALLOCA" OFF) -add_feature_info(OPUS_NONTHREADSAFE_PSEUDOSTACK OPUS_NONTHREADSAFE_PSEUDOSTACK ${OPUS_NONTHREADSAFE_PSEUDOSTACK_HELP_STR}) +add_feature_info(OAC_NONTHREADSAFE_PSEUDOSTACK OAC_NONTHREADSAFE_PSEUDOSTACK ${OAC_NONTHREADSAFE_PSEUDOSTACK_HELP_STR}) -set(OPUS_FAST_MATH_HELP_STR "enable fast math (unsupported and discouraged use, as code is not well tested with this build option).") -cmake_dependent_option(OPUS_FAST_MATH - ${OPUS_FAST_MATH_HELP_STR} +set(OAC_FAST_MATH_HELP_STR "enable fast math (unsupported and discouraged use, as code is not well tested with this build option).") +cmake_dependent_option(OAC_FAST_MATH + ${OAC_FAST_MATH_HELP_STR} ON - "OPUS_FLOAT_APPROX; OPUS_FAST_MATH; FAST_MATH_SUPPORTED" + "OAC_FLOAT_APPROX; OAC_FAST_MATH; FAST_MATH_SUPPORTED" OFF) -add_feature_info(OPUS_FAST_MATH OPUS_FAST_MATH ${OPUS_FAST_MATH_HELP_STR}) +add_feature_info(OAC_FAST_MATH OAC_FAST_MATH ${OAC_FAST_MATH_HELP_STR}) -set(OPUS_STACK_PROTECTOR_HELP_STR "use stack protection.") -cmake_dependent_option(OPUS_STACK_PROTECTOR - ${OPUS_STACK_PROTECTOR_HELP_STR} +set(OAC_STACK_PROTECTOR_HELP_STR "use stack protection.") +cmake_dependent_option(OAC_STACK_PROTECTOR + ${OAC_STACK_PROTECTOR_HELP_STR} ON "STACK_PROTECTOR_SUPPORTED" OFF) -add_feature_info(OPUS_STACK_PROTECTOR OPUS_STACK_PROTECTOR ${OPUS_STACK_PROTECTOR_HELP_STR}) +add_feature_info(OAC_STACK_PROTECTOR OAC_STACK_PROTECTOR ${OAC_STACK_PROTECTOR_HELP_STR}) if(NOT MSVC) - set(OPUS_FORTIFY_SOURCE_HELP_STR "add protection against buffer overflows.") - cmake_dependent_option(OPUS_FORTIFY_SOURCE - ${OPUS_FORTIFY_SOURCE_HELP_STR} + set(OAC_FORTIFY_SOURCE_HELP_STR "add protection against buffer overflows.") + cmake_dependent_option(OAC_FORTIFY_SOURCE + ${OAC_FORTIFY_SOURCE_HELP_STR} ON "FORTIFY_SOURCE_SUPPORTED" OFF) - add_feature_info(OPUS_FORTIFY_SOURCE OPUS_FORTIFY_SOURCE ${OPUS_FORTIFY_SOURCE_HELP_STR}) + add_feature_info(OAC_FORTIFY_SOURCE OAC_FORTIFY_SOURCE ${OAC_FORTIFY_SOURCE_HELP_STR}) endif() -if(MINGW AND (OPUS_FORTIFY_SOURCE OR OPUS_STACK_PROTECTOR)) +if(MINGW AND (OAC_FORTIFY_SOURCE OR OAC_STACK_PROTECTOR)) # ssp lib is needed for security features for MINGW - list(APPEND OPUS_REQUIRED_LIBRARIES ssp) + list(APPEND OAC_REQUIRED_LIBRARIES ssp) endif() -if(OPUS_CPU_X86 OR OPUS_CPU_X64) - set(OPUS_X86_MAY_HAVE_SSE_HELP_STR "does runtime check for SSE1 support.") - cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE - ${OPUS_X86_MAY_HAVE_SSE_HELP_STR} +if(OAC_CPU_X86 OR OAC_CPU_X64) + set(OAC_X86_MAY_HAVE_SSE_HELP_STR "does runtime check for SSE1 support.") + cmake_dependent_option(OAC_X86_MAY_HAVE_SSE + ${OAC_X86_MAY_HAVE_SSE_HELP_STR} ON - "SSE1_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" + "SSE1_SUPPORTED; NOT OAC_DISABLE_INTRINSICS" OFF) - add_feature_info(OPUS_X86_MAY_HAVE_SSE OPUS_X86_MAY_HAVE_SSE ${OPUS_X86_MAY_HAVE_SSE_HELP_STR}) + add_feature_info(OAC_X86_MAY_HAVE_SSE OAC_X86_MAY_HAVE_SSE ${OAC_X86_MAY_HAVE_SSE_HELP_STR}) - set(OPUS_X86_MAY_HAVE_SSE2_HELP_STR "does runtime check for SSE2 support.") - cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE2 - ${OPUS_X86_MAY_HAVE_SSE2_HELP_STR} + set(OAC_X86_MAY_HAVE_SSE2_HELP_STR "does runtime check for SSE2 support.") + cmake_dependent_option(OAC_X86_MAY_HAVE_SSE2 + ${OAC_X86_MAY_HAVE_SSE2_HELP_STR} ON - "SSE2_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" + "SSE2_SUPPORTED; NOT OAC_DISABLE_INTRINSICS" OFF) - add_feature_info(OPUS_X86_MAY_HAVE_SSE2 OPUS_X86_MAY_HAVE_SSE2 ${OPUS_X86_MAY_HAVE_SSE2_HELP_STR}) + add_feature_info(OAC_X86_MAY_HAVE_SSE2 OAC_X86_MAY_HAVE_SSE2 ${OAC_X86_MAY_HAVE_SSE2_HELP_STR}) - set(OPUS_X86_MAY_HAVE_SSE4_1_HELP_STR "does runtime check for SSE4.1 support.") - cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE4_1 - ${OPUS_X86_MAY_HAVE_SSE4_1_HELP_STR} + set(OAC_X86_MAY_HAVE_SSE4_1_HELP_STR "does runtime check for SSE4.1 support.") + cmake_dependent_option(OAC_X86_MAY_HAVE_SSE4_1 + ${OAC_X86_MAY_HAVE_SSE4_1_HELP_STR} ON - "SSE4_1_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" + "SSE4_1_SUPPORTED; NOT OAC_DISABLE_INTRINSICS" OFF) - add_feature_info(OPUS_X86_MAY_HAVE_SSE4_1 OPUS_X86_MAY_HAVE_SSE4_1 ${OPUS_X86_MAY_HAVE_SSE4_1_HELP_STR}) + add_feature_info(OAC_X86_MAY_HAVE_SSE4_1 OAC_X86_MAY_HAVE_SSE4_1 ${OAC_X86_MAY_HAVE_SSE4_1_HELP_STR}) - set(OPUS_X86_MAY_HAVE_AVX2_HELP_STR "does runtime check for AVX FMA AVX2 support.") - cmake_dependent_option(OPUS_X86_MAY_HAVE_AVX2 - ${OPUS_X86_MAY_HAVE_AVX2_HELP_STR} + set(OAC_X86_MAY_HAVE_AVX2_HELP_STR "does runtime check for AVX FMA AVX2 support.") + cmake_dependent_option(OAC_X86_MAY_HAVE_AVX2 + ${OAC_X86_MAY_HAVE_AVX2_HELP_STR} ON - "AVX2_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" + "AVX2_SUPPORTED; NOT OAC_DISABLE_INTRINSICS" OFF) - add_feature_info(OPUS_X86_MAY_HAVE_AVX2 OPUS_X86_MAY_HAVE_AVX2 ${OPUS_X86_MAY_HAVE_AVX2_HELP_STR}) + add_feature_info(OAC_X86_MAY_HAVE_AVX2 OAC_X86_MAY_HAVE_AVX2 ${OAC_X86_MAY_HAVE_AVX2_HELP_STR}) # PRESUME depends on MAY HAVE, but PRESUME will override runtime detection - set(OPUS_X86_PRESUME_SSE_HELP_STR "assume target CPU has SSE1 support (override runtime check).") - set(OPUS_X86_PRESUME_SSE2_HELP_STR "assume target CPU has SSE2 support (override runtime check).") - if(OPUS_CPU_X64) # Assume x86_64 has up to SSE2 support - cmake_dependent_option(OPUS_X86_PRESUME_SSE - ${OPUS_X86_PRESUME_SSE_HELP_STR} + set(OAC_X86_PRESUME_SSE_HELP_STR "assume target CPU has SSE1 support (override runtime check).") + set(OAC_X86_PRESUME_SSE2_HELP_STR "assume target CPU has SSE2 support (override runtime check).") + if(OAC_CPU_X64) # Assume x86_64 has up to SSE2 support + cmake_dependent_option(OAC_X86_PRESUME_SSE + ${OAC_X86_PRESUME_SSE_HELP_STR} ON - "OPUS_X86_MAY_HAVE_SSE; NOT OPUS_DISABLE_INTRINSICS" + "OAC_X86_MAY_HAVE_SSE; NOT OAC_DISABLE_INTRINSICS" OFF) - cmake_dependent_option(OPUS_X86_PRESUME_SSE2 - ${OPUS_X86_PRESUME_SSE2_HELP_STR} + cmake_dependent_option(OAC_X86_PRESUME_SSE2 + ${OAC_X86_PRESUME_SSE2_HELP_STR} ON - "OPUS_X86_MAY_HAVE_SSE2; NOT OPUS_DISABLE_INTRINSICS" + "OAC_X86_MAY_HAVE_SSE2; NOT OAC_DISABLE_INTRINSICS" OFF) else() - cmake_dependent_option(OPUS_X86_PRESUME_SSE - ${OPUS_X86_PRESUME_SSE_HELP_STR} + cmake_dependent_option(OAC_X86_PRESUME_SSE + ${OAC_X86_PRESUME_SSE_HELP_STR} OFF - "OPUS_X86_MAY_HAVE_SSE; NOT OPUS_DISABLE_INTRINSICS" + "OAC_X86_MAY_HAVE_SSE; NOT OAC_DISABLE_INTRINSICS" OFF) - cmake_dependent_option(OPUS_X86_PRESUME_SSE2 - ${OPUS_X86_PRESUME_SSE2_HELP_STR} + cmake_dependent_option(OAC_X86_PRESUME_SSE2 + ${OAC_X86_PRESUME_SSE2_HELP_STR} OFF - "OPUS_X86_MAY_HAVE_SSE2; NOT OPUS_DISABLE_INTRINSICS" + "OAC_X86_MAY_HAVE_SSE2; NOT OAC_DISABLE_INTRINSICS" OFF) endif() - add_feature_info(OPUS_X86_PRESUME_SSE OPUS_X86_PRESUME_SSE ${OPUS_X86_PRESUME_SSE_HELP_STR}) - add_feature_info(OPUS_X86_PRESUME_SSE2 OPUS_X86_PRESUME_SSE2 ${OPUS_X86_PRESUME_SSE2_HELP_STR}) + add_feature_info(OAC_X86_PRESUME_SSE OAC_X86_PRESUME_SSE ${OAC_X86_PRESUME_SSE_HELP_STR}) + add_feature_info(OAC_X86_PRESUME_SSE2 OAC_X86_PRESUME_SSE2 ${OAC_X86_PRESUME_SSE2_HELP_STR}) - set(OPUS_X86_PRESUME_SSE4_1_HELP_STR "assume target CPU has SSE4.1 support (override runtime check).") - cmake_dependent_option(OPUS_X86_PRESUME_SSE4_1 - ${OPUS_X86_PRESUME_SSE4_1_HELP_STR} + set(OAC_X86_PRESUME_SSE4_1_HELP_STR "assume target CPU has SSE4.1 support (override runtime check).") + cmake_dependent_option(OAC_X86_PRESUME_SSE4_1 + ${OAC_X86_PRESUME_SSE4_1_HELP_STR} OFF - "OPUS_X86_MAY_HAVE_SSE4_1; NOT OPUS_DISABLE_INTRINSICS" + "OAC_X86_MAY_HAVE_SSE4_1; NOT OAC_DISABLE_INTRINSICS" OFF) - add_feature_info(OPUS_X86_PRESUME_SSE4_1 OPUS_X86_PRESUME_SSE4_1 ${OPUS_X86_PRESUME_SSE4_1_HELP_STR}) + add_feature_info(OAC_X86_PRESUME_SSE4_1 OAC_X86_PRESUME_SSE4_1 ${OAC_X86_PRESUME_SSE4_1_HELP_STR}) - set(OPUS_X86_PRESUME_AVX2_HELP_STR "assume target CPU has AVX FMA AVX2 support (override runtime check).") - cmake_dependent_option(OPUS_X86_PRESUME_AVX2 - ${OPUS_X86_PRESUME_AVX2_HELP_STR} + set(OAC_X86_PRESUME_AVX2_HELP_STR "assume target CPU has AVX FMA AVX2 support (override runtime check).") + cmake_dependent_option(OAC_X86_PRESUME_AVX2 + ${OAC_X86_PRESUME_AVX2_HELP_STR} OFF - "OPUS_X86_MAY_HAVE_AVX2; NOT OPUS_DISABLE_INTRINSICS" + "OAC_X86_MAY_HAVE_AVX2; NOT OAC_DISABLE_INTRINSICS" OFF) - add_feature_info(OPUS_X86_PRESUME_AVX2 OPUS_X86_PRESUME_AVX2 ${OPUS_X86_PRESUME_AVX2_HELP_STR}) + add_feature_info(OAC_X86_PRESUME_AVX2 OAC_X86_PRESUME_AVX2 ${OAC_X86_PRESUME_AVX2_HELP_STR}) endif() feature_summary(WHAT ALL) @@ -268,260 +268,260 @@ set_package_properties(Git PURPOSE "required to set up package version") -set(Opus_PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR}/include/opus.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_defines.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_multistream.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_projection.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_types.h) +set(Oac_PUBLIC_HEADER + ${CMAKE_CURRENT_SOURCE_DIR}/include/oac.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/oac_defines.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/oac_multistream.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/oac_projection.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/oac_types.h) -if(OPUS_CUSTOM_MODES) - list(APPEND Opus_PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_custom.h) +if(OAC_CUSTOM_MODES) + list(APPEND Oac_PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/oac_custom.h) endif() if(MSVC) - if(OPUS_STATIC_RUNTIME) + if(OAC_STATIC_RUNTIME) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") else() set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") endif() endif() -add_library(opus ${opus_headers} ${opus_sources} ${opus_sources_float} ${Opus_PUBLIC_HEADER}) -add_library(Opus::opus ALIAS opus) +add_library(oac ${oac_headers} ${oac_sources} ${oac_sources_float} ${Oac_PUBLIC_HEADER}) +add_library(Oac::oac ALIAS oac) -get_library_version(OPUS_LIBRARY_VERSION OPUS_LIBRARY_VERSION_MAJOR) -message(DEBUG "Opus library version: ${OPUS_LIBRARY_VERSION}") +get_library_version(OAC_LIBRARY_VERSION OAC_LIBRARY_VERSION_MAJOR) +message(DEBUG "Oac library version: ${OAC_LIBRARY_VERSION}") -set_target_properties(opus +set_target_properties(oac PROPERTIES SOVERSION - ${OPUS_LIBRARY_VERSION_MAJOR} + ${OAC_LIBRARY_VERSION_MAJOR} VERSION - ${OPUS_LIBRARY_VERSION} + ${OAC_LIBRARY_VERSION} PUBLIC_HEADER - "${Opus_PUBLIC_HEADER}") + "${Oac_PUBLIC_HEADER}") target_include_directories( - opus + oac PUBLIC $ $ - $ + $ PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/dnn celt silk) -target_link_libraries(opus PRIVATE ${OPUS_REQUIRED_LIBRARIES}) -target_compile_definitions(opus PRIVATE OPUS_BUILD) +target_link_libraries(oac PRIVATE ${OAC_REQUIRED_LIBRARIES}) +target_compile_definitions(oac PRIVATE OAC_BUILD) -if(OPUS_FIXED_POINT_DEBUG) - target_compile_definitions(opus PRIVATE FIXED_DEBUG) +if(OAC_FIXED_POINT_DEBUG) + target_compile_definitions(oac PRIVATE FIXED_DEBUG) endif() -if(OPUS_FORTIFY_SOURCE AND NOT MSVC) - target_compile_definitions(opus PRIVATE +if(OAC_FORTIFY_SOURCE AND NOT MSVC) + target_compile_definitions(oac PRIVATE $<$>:_FORTIFY_SOURCE=2>) endif() -if(OPUS_FLOAT_APPROX) - target_compile_definitions(opus PRIVATE FLOAT_APPROX) +if(OAC_FLOAT_APPROX) + target_compile_definitions(oac PRIVATE FLOAT_APPROX) endif() -if(OPUS_ASSERTIONS) - target_compile_definitions(opus PRIVATE ENABLE_ASSERTIONS) +if(OAC_ASSERTIONS) + target_compile_definitions(oac PRIVATE ENABLE_ASSERTIONS) endif() -if(OPUS_HARDENING) - target_compile_definitions(opus PRIVATE ENABLE_HARDENING) +if(OAC_HARDENING) + target_compile_definitions(oac PRIVATE ENABLE_HARDENING) endif() -if(OPUS_FUZZING) - target_compile_definitions(opus PRIVATE FUZZING) +if(OAC_FUZZING) + target_compile_definitions(oac PRIVATE FUZZING) endif() -if(OPUS_CHECK_ASM) - target_compile_definitions(opus PRIVATE OPUS_CHECK_ASM) +if(OAC_CHECK_ASM) + target_compile_definitions(oac PRIVATE OAC_CHECK_ASM) endif() -if(NOT OPUS_DNN_FLOAT_DEBUG) - target_compile_definitions(opus PRIVATE DISABLE_DEBUG_FLOAT) +if(NOT OAC_DNN_FLOAT_DEBUG) + target_compile_definitions(oac PRIVATE DISABLE_DEBUG_FLOAT) endif() -if(OPUS_VAR_ARRAYS) - target_compile_definitions(opus PRIVATE VAR_ARRAYS) -elseif(OPUS_USE_ALLOCA) - target_compile_definitions(opus PRIVATE USE_ALLOCA) -elseif(OPUS_NONTHREADSAFE_PSEUDOSTACK) - target_compile_definitions(opus PRIVATE NONTHREADSAFE_PSEUDOSTACK) +if(OAC_VAR_ARRAYS) + target_compile_definitions(oac PRIVATE VAR_ARRAYS) +elseif(OAC_USE_ALLOCA) + target_compile_definitions(oac PRIVATE USE_ALLOCA) +elseif(OAC_NONTHREADSAFE_PSEUDOSTACK) + target_compile_definitions(oac PRIVATE NONTHREADSAFE_PSEUDOSTACK) else() message(ERROR "Need to set a define for stack allocation") endif() -if(OPUS_CUSTOM_MODES) - target_compile_definitions(opus PRIVATE CUSTOM_MODES) +if(OAC_CUSTOM_MODES) + target_compile_definitions(oac PRIVATE CUSTOM_MODES) endif() -if(OPUS_FAST_MATH) +if(OAC_FAST_MATH) if(MSVC) - target_compile_options(opus PRIVATE /fp:fast) + target_compile_options(oac PRIVATE /fp:fast) else() - target_compile_options(opus PRIVATE -ffast-math) + target_compile_options(oac PRIVATE -ffast-math) endif() endif() -if(OPUS_STACK_PROTECTOR) +if(OAC_STACK_PROTECTOR) if(MSVC) - target_compile_options(opus PRIVATE /GS) + target_compile_options(oac PRIVATE /GS) else() - target_compile_options(opus PRIVATE -fstack-protector-strong) + target_compile_options(oac PRIVATE -fstack-protector-strong) endif() elseif(STACK_PROTECTOR_DISABLED_SUPPORTED) - target_compile_options(opus PRIVATE /GS-) + target_compile_options(oac PRIVATE /GS-) endif() if(BUILD_SHARED_LIBS) if(WIN32) - target_compile_definitions(opus PRIVATE DLL_EXPORT) + target_compile_definitions(oac PRIVATE DLL_EXPORT) elseif(HIDDEN_VISIBILITY_SUPPORTED) - set_target_properties(opus PROPERTIES C_VISIBILITY_PRESET hidden) + set_target_properties(oac PROPERTIES C_VISIBILITY_PRESET hidden) endif() endif() -add_sources_group(opus silk ${silk_headers} ${silk_sources}) -add_sources_group(opus celt ${celt_headers} ${celt_sources}) +add_sources_group(oac silk ${silk_headers} ${silk_sources}) +add_sources_group(oac celt ${celt_headers} ${celt_sources}) -if(OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_fixed}) - target_include_directories(opus PRIVATE silk/fixed) - target_compile_definitions(opus PRIVATE FIXED_POINT=1) +if(OAC_FIXED_POINT) + add_sources_group(oac silk ${silk_sources_fixed}) + target_include_directories(oac PRIVATE silk/fixed) + target_compile_definitions(oac PRIVATE FIXED_POINT=1) else() - add_sources_group(opus silk ${silk_sources_float}) - target_include_directories(opus PRIVATE silk/float) + add_sources_group(oac silk ${silk_sources_float}) + target_include_directories(oac PRIVATE silk/float) endif() -if(NOT OPUS_ENABLE_FLOAT_API) - target_compile_definitions(opus PRIVATE DISABLE_FLOAT_API) +if(NOT OAC_ENABLE_FLOAT_API) + target_compile_definitions(oac PRIVATE DISABLE_FLOAT_API) endif() -if (OPUS_DEEP_PLC OR OPUS_DRED OR OPUS_OSCE) - add_sources_group(opus lpcnet ${deep_plc_headers} ${deep_plc_sources}) - set(OPUS_DNN TRUE) +if (OAC_DEEP_PLC OR OAC_DRED OR OAC_OSCE) + add_sources_group(oac lpcnet ${deep_plc_headers} ${deep_plc_sources}) + set(OAC_DNN TRUE) else() - set(OPUS_DNN FALSE) + set(OAC_DNN FALSE) endif() -if (OPUS_DNN) - add_sources_group(opus lpcnet ${deep_plc_headers} ${deep_plc_sources}) - target_compile_definitions(opus PRIVATE ENABLE_DEEP_PLC) +if (OAC_DNN) + add_sources_group(oac lpcnet ${deep_plc_headers} ${deep_plc_sources}) + target_compile_definitions(oac PRIVATE ENABLE_DEEP_PLC) endif() -if (OPUS_DRED) - add_sources_group(opus lpcnet ${dred_headers} ${dred_sources}) - target_compile_definitions(opus PRIVATE ENABLE_DRED) +if (OAC_DRED) + add_sources_group(oac lpcnet ${dred_headers} ${dred_sources}) + target_compile_definitions(oac PRIVATE ENABLE_DRED) endif() -if (OPUS_OSCE) - add_sources_group(opus lpcnet ${osce_headers} ${osce_sources}) - target_compile_definitions(opus PRIVATE ENABLE_OSCE) +if (OAC_OSCE) + add_sources_group(oac lpcnet ${osce_headers} ${osce_sources}) + target_compile_definitions(oac PRIVATE ENABLE_OSCE) endif() -if(NOT OPUS_DISABLE_INTRINSICS) - if(((OPUS_X86_MAY_HAVE_SSE AND NOT OPUS_X86_PRESUME_SSE) OR - (OPUS_X86_MAY_HAVE_SSE2 AND NOT OPUS_X86_PRESUME_SSE2) OR - (OPUS_X86_MAY_HAVE_SSE4_1 AND NOT OPUS_X86_PRESUME_SSE4_1) OR - (OPUS_X86_MAY_HAVE_AVX2 AND NOT OPUS_X86_PRESUME_AVX2)) AND +if(NOT OAC_DISABLE_INTRINSICS) + if(((OAC_X86_MAY_HAVE_SSE AND NOT OAC_X86_PRESUME_SSE) OR + (OAC_X86_MAY_HAVE_SSE2 AND NOT OAC_X86_PRESUME_SSE2) OR + (OAC_X86_MAY_HAVE_SSE4_1 AND NOT OAC_X86_PRESUME_SSE4_1) OR + (OAC_X86_MAY_HAVE_AVX2 AND NOT OAC_X86_PRESUME_AVX2)) AND RUNTIME_CPU_CAPABILITY_DETECTION) - target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD) + target_compile_definitions(oac PRIVATE OAC_HAVE_RTCD) if(NOT MSVC) if(CPU_INFO_BY_ASM_SUPPORTED) - target_compile_definitions(opus PRIVATE CPU_INFO_BY_ASM) + target_compile_definitions(oac PRIVATE CPU_INFO_BY_ASM) elseif(CPU_INFO_BY_C_SUPPORTED) - target_compile_definitions(opus PRIVATE CPU_INFO_BY_C) + target_compile_definitions(oac PRIVATE CPU_INFO_BY_C) else() message(ERROR "Runtime cpu capability detection is enabled while CPU_INFO is not supported") endif() endif() - add_sources_group(opus celt ${celt_sources_x86_rtcd}) - add_sources_group(opus silk ${silk_sources_x86_rtcd}) - if (OPUS_DNN) - add_sources_group(opus lpcnet ${dnn_sources_x86_rtcd}) + add_sources_group(oac celt ${celt_sources_x86_rtcd}) + add_sources_group(oac silk ${silk_sources_x86_rtcd}) + if (OAC_DNN) + add_sources_group(oac lpcnet ${dnn_sources_x86_rtcd}) endif() endif() if(SSE1_SUPPORTED) - if(OPUS_X86_MAY_HAVE_SSE) - add_sources_group(opus celt ${celt_sources_sse}) - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE) + if(OAC_X86_MAY_HAVE_SSE) + add_sources_group(oac celt ${celt_sources_sse}) + target_compile_definitions(oac PRIVATE OAC_X86_MAY_HAVE_SSE) if(NOT MSVC) set_source_files_properties(${celt_sources_sse} PROPERTIES COMPILE_FLAGS -msse) endif() endif() - if(OPUS_X86_PRESUME_SSE) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE) + if(OAC_X86_PRESUME_SSE) + target_compile_definitions(oac PRIVATE OAC_X86_PRESUME_SSE) if(NOT MSVC) - target_compile_options(opus PRIVATE -msse) + target_compile_options(oac PRIVATE -msse) endif() endif() endif() if(SSE2_SUPPORTED) - if(OPUS_X86_MAY_HAVE_SSE2) - add_sources_group(opus celt ${celt_sources_sse2}) - if (OPUS_DNN) - add_sources_group(opus lpcnet ${dnn_sources_sse2}) + if(OAC_X86_MAY_HAVE_SSE2) + add_sources_group(oac celt ${celt_sources_sse2}) + if (OAC_DNN) + add_sources_group(oac lpcnet ${dnn_sources_sse2}) endif() - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE2) + target_compile_definitions(oac PRIVATE OAC_X86_MAY_HAVE_SSE2) if(NOT MSVC) set_source_files_properties(${celt_sources_sse2} ${dnn_sources_sse2} PROPERTIES COMPILE_FLAGS -msse2) endif() endif() - if(OPUS_X86_PRESUME_SSE2) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE2) + if(OAC_X86_PRESUME_SSE2) + target_compile_definitions(oac PRIVATE OAC_X86_PRESUME_SSE2) if(NOT MSVC) - target_compile_options(opus PRIVATE -msse2) + target_compile_options(oac PRIVATE -msse2) endif() endif() endif() if(SSE4_1_SUPPORTED) - if(OPUS_X86_MAY_HAVE_SSE4_1) - add_sources_group(opus celt ${celt_sources_sse4_1}) - add_sources_group(opus silk ${silk_sources_sse4_1}) - if (OPUS_DNN) - add_sources_group(opus lpcnet ${dnn_sources_sse4_1}) + if(OAC_X86_MAY_HAVE_SSE4_1) + add_sources_group(oac celt ${celt_sources_sse4_1}) + add_sources_group(oac silk ${silk_sources_sse4_1}) + if (OAC_DNN) + add_sources_group(oac lpcnet ${dnn_sources_sse4_1}) endif() - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE4_1) + target_compile_definitions(oac PRIVATE OAC_X86_MAY_HAVE_SSE4_1) if(NOT MSVC OR MSVC_CLANG_CL) set_source_files_properties(${celt_sources_sse4_1} ${silk_sources_sse4_1} ${dnn_sources_sse4_1} PROPERTIES COMPILE_FLAGS -msse4.1) endif() - if(OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_fixed_sse4_1}) + if(OAC_FIXED_POINT) + add_sources_group(oac silk ${silk_sources_fixed_sse4_1}) if(NOT MSVC OR MSVC_CLANG_CL) set_source_files_properties(${silk_sources_fixed_sse4_1} PROPERTIES COMPILE_FLAGS -msse4.1) endif() endif() endif() - if(OPUS_X86_PRESUME_SSE4_1) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE4_1) + if(OAC_X86_PRESUME_SSE4_1) + target_compile_definitions(oac PRIVATE OAC_X86_PRESUME_SSE4_1) if(NOT MSVC OR MSVC_CLANG_CL) - target_compile_options(opus PRIVATE -msse4.1) + target_compile_options(oac PRIVATE -msse4.1) endif() endif() endif() if(AVX2_SUPPORTED) - if(OPUS_X86_MAY_HAVE_AVX2) - add_sources_group(opus celt ${celt_sources_avx2}) - add_sources_group(opus silk ${silk_sources_avx2}) - if (NOT OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_float_avx2}) + if(OAC_X86_MAY_HAVE_AVX2) + add_sources_group(oac celt ${celt_sources_avx2}) + add_sources_group(oac silk ${silk_sources_avx2}) + if (NOT OAC_FIXED_POINT) + add_sources_group(oac silk ${silk_sources_float_avx2}) endif() - if (OPUS_DNN) - add_sources_group(opus lpcnet ${dnn_sources_avx2}) + if (OAC_DNN) + add_sources_group(oac lpcnet ${dnn_sources_avx2}) endif() - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_AVX2) + target_compile_definitions(oac PRIVATE OAC_X86_MAY_HAVE_AVX2) if(MSVC) set(AVX2_FLAGS "${AVX2_FLAGS} /arch:AVX2") else() @@ -529,99 +529,99 @@ if(NOT OPUS_DISABLE_INTRINSICS) endif() set_source_files_properties(${celt_sources_avx2} PROPERTIES COMPILE_FLAGS ${AVX2_FLAGS}) set_source_files_properties(${silk_sources_avx2} PROPERTIES COMPILE_FLAGS ${AVX2_FLAGS}) - if (NOT OPUS_FIXED_POINT) + if (NOT OAC_FIXED_POINT) set_source_files_properties(${silk_sources_float_avx2} PROPERTIES COMPILE_FLAGS ${AVX2_FLAGS}) endif() set_source_files_properties(${dnn_sources_avx2} PROPERTIES COMPILE_FLAGS ${AVX2_FLAGS}) endif() - if(OPUS_X86_PRESUME_AVX2) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_AVX2) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE4_1) + if(OAC_X86_PRESUME_AVX2) + target_compile_definitions(oac PRIVATE OAC_X86_PRESUME_AVX2) + target_compile_definitions(oac PRIVATE OAC_X86_PRESUME_SSE4_1) if(NOT MSVC) - target_compile_options(opus PRIVATE -mavx2 -mfma -mavx) + target_compile_options(oac PRIVATE -mavx2 -mfma -mavx) endif() endif() endif() if(MSVC) - if(AVX2_SUPPORTED AND OPUS_X86_PRESUME_AVX2) # on 64 bit and 32 bits + if(AVX2_SUPPORTED AND OAC_X86_PRESUME_AVX2) # on 64 bit and 32 bits add_definitions(/arch:AVX2) - elseif(OPUS_CPU_X86) # if AVX not supported then set SSE flag - if((SSE4_1_SUPPORTED AND OPUS_X86_PRESUME_SSE4_1) - OR (SSE2_SUPPORTED AND OPUS_X86_PRESUME_SSE2)) - target_compile_definitions(opus PRIVATE /arch:SSE2) - elseif(SSE1_SUPPORTED AND OPUS_X86_PRESUME_SSE) - target_compile_definitions(opus PRIVATE /arch:SSE) + elseif(OAC_CPU_X86) # if AVX not supported then set SSE flag + if((SSE4_1_SUPPORTED AND OAC_X86_PRESUME_SSE4_1) + OR (SSE2_SUPPORTED AND OAC_X86_PRESUME_SSE2)) + target_compile_definitions(oac PRIVATE /arch:SSE2) + elseif(SSE1_SUPPORTED AND OAC_X86_PRESUME_SSE) + target_compile_definitions(oac PRIVATE /arch:SSE) endif() endif() endif() if(COMPILER_SUPPORT_NEON) - if(OPUS_MAY_HAVE_NEON) + if(OAC_MAY_HAVE_NEON) if(RUNTIME_CPU_CAPABILITY_DETECTION) - message(STATUS "OPUS_MAY_HAVE_NEON enabling runtime detection") - target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD) - add_sources_group(opus celt ${celt_sources_arm_rtcd}) - add_sources_group(opus silk ${silk_sources_arm_rtcd}) - add_sources_group(opus lpcnet ${dnn_sources_arm_rtcd}) + message(STATUS "OAC_MAY_HAVE_NEON enabling runtime detection") + target_compile_definitions(oac PRIVATE OAC_HAVE_RTCD) + add_sources_group(oac celt ${celt_sources_arm_rtcd}) + add_sources_group(oac silk ${silk_sources_arm_rtcd}) + add_sources_group(oac lpcnet ${dnn_sources_arm_rtcd}) else() message(ERROR "Runtime cpu capability detection needed for MAY_HAVE_NEON") endif() # Do runtime check for NEON - target_compile_definitions(opus + target_compile_definitions(oac PRIVATE - OPUS_ARM_MAY_HAVE_NEON - OPUS_ARM_MAY_HAVE_NEON_INTR) + OAC_ARM_MAY_HAVE_NEON + OAC_ARM_MAY_HAVE_NEON_INTR) endif() - add_sources_group(opus celt ${celt_sources_arm_neon_intr}) - add_sources_group(opus silk ${silk_sources_arm_neon_intr}) - if (OPUS_DNN) - add_sources_group(opus lpcnet ${dnn_sources_arm_neon}) + add_sources_group(oac celt ${celt_sources_arm_neon_intr}) + add_sources_group(oac silk ${silk_sources_arm_neon_intr}) + if (OAC_DNN) + add_sources_group(oac lpcnet ${dnn_sources_arm_neon}) endif() # silk arm neon depends on main_Fix.h - target_include_directories(opus PRIVATE silk/fixed) + target_include_directories(oac PRIVATE silk/fixed) - if(OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_fixed_arm_neon_intr}) + if(OAC_FIXED_POINT) + add_sources_group(oac silk ${silk_sources_fixed_arm_neon_intr}) endif() - if(OPUS_PRESUME_NEON) - target_compile_definitions(opus + if(OAC_PRESUME_NEON) + target_compile_definitions(oac PRIVATE - OPUS_ARM_PRESUME_NEON - OPUS_ARM_PRESUME_NEON_INTR) + OAC_ARM_PRESUME_NEON + OAC_ARM_PRESUME_NEON_INTR) endif() endif() endif() -target_compile_definitions(opus +target_compile_definitions(oac PRIVATE $<$:HAVE_LRINT> $<$:HAVE_LRINTF> $<$:HAVE_ELF_AUX_INFO>) -if(OPUS_BUILD_FRAMEWORK) - set_target_properties(opus PROPERTIES +if(OAC_BUILD_FRAMEWORK) + set_target_properties(oac PROPERTIES FRAMEWORK TRUE FRAMEWORK_VERSION ${PROJECT_VERSION} - MACOSX_FRAMEWORK_IDENTIFIER org.xiph.opus + MACOSX_FRAMEWORK_IDENTIFIER org.xiph.oac MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION} MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION} XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" - OUTPUT_NAME Opus) + OUTPUT_NAME Oac) endif() -install(TARGETS opus - EXPORT OpusTargets +install(TARGETS oac + EXPORT OacTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/opus) + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/oac) -if(OPUS_INSTALL_PKG_CONFIG_MODULE) +if(OAC_INSTALL_PKG_CONFIG_MODULE) set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix ${CMAKE_INSTALL_PREFIX}) set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) @@ -630,136 +630,136 @@ if(OPUS_INSTALL_PKG_CONFIG_MODULE) if(HAVE_LIBM) set(LIBM "-lm") endif() - configure_file(opus.pc.in opus.pc) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/opus.pc + configure_file(oac.pc.in oac.pc) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/oac.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() -if(OPUS_INSTALL_CMAKE_CONFIG_MODULE) +if(OAC_INSTALL_CMAKE_CONFIG_MODULE) set(CPACK_GENERATOR TGZ) include(CPack) set(CMAKE_INSTALL_PACKAGEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) - install(EXPORT OpusTargets - NAMESPACE Opus:: + install(EXPORT OacTargets + NAMESPACE Oac:: DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}) include(CMakePackageConfigHelpers) set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) - configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/OpusConfig.cmake.in - OpusConfig.cmake + configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/OacConfig.cmake.in + OacConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} PATH_VARS INCLUDE_INSTALL_DIR INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) - write_basic_package_version_file(OpusConfigVersion.cmake + write_basic_package_version_file(OacConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpusConfig.cmake - ${CMAKE_CURRENT_BINARY_DIR}/OpusConfigVersion.cmake + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OacConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/OacConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}) endif() -if(OPUS_BUILD_PROGRAMS) +if(OAC_BUILD_PROGRAMS) # demo - if(OPUS_CUSTOM_MODES) - add_executable(opus_custom_demo ${opus_custom_demo_sources}) - target_include_directories(opus_custom_demo + if(OAC_CUSTOM_MODES) + add_executable(oac_custom_demo ${oac_custom_demo_sources}) + target_include_directories(oac_custom_demo PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(opus_custom_demo PRIVATE opus) - target_compile_definitions(opus_custom_demo PRIVATE OPUS_BUILD) + target_link_libraries(oac_custom_demo PRIVATE oac) + target_compile_definitions(oac_custom_demo PRIVATE OAC_BUILD) endif() - add_executable(opus_demo ${opus_demo_sources}) - target_include_directories(opus_demo PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_include_directories(opus_demo PRIVATE silk) # debug.h - target_include_directories(opus_demo PRIVATE celt) # arch.h - target_include_directories(opus_demo PRIVATE dnn) - target_link_libraries(opus_demo PRIVATE opus ${OPUS_REQUIRED_LIBRARIES}) - target_compile_definitions(opus_demo PRIVATE OPUS_BUILD) + add_executable(oac_demo ${oac_demo_sources}) + target_include_directories(oac_demo PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + target_include_directories(oac_demo PRIVATE silk) # debug.h + target_include_directories(oac_demo PRIVATE celt) # arch.h + target_include_directories(oac_demo PRIVATE dnn) + target_link_libraries(oac_demo PRIVATE oac ${OAC_REQUIRED_LIBRARIES}) + target_compile_definitions(oac_demo PRIVATE OAC_BUILD) # compare - add_executable(opus_compare ${opus_compare_sources}) - target_include_directories(opus_compare PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(opus_compare PRIVATE opus ${OPUS_REQUIRED_LIBRARIES}) + add_executable(oac_compare ${oac_compare_sources}) + target_include_directories(oac_compare PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + target_link_libraries(oac_compare PRIVATE oac ${OAC_REQUIRED_LIBRARIES}) endif() if(BUILD_TESTING AND NOT BUILD_SHARED_LIBS) enable_testing() # tests - add_executable(test_opus_decode ${test_opus_decode_sources}) - target_include_directories(test_opus_decode + add_executable(test_oac_decode ${test_oac_decode_sources}) + target_include_directories(test_oac_decode PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(test_opus_decode PRIVATE opus) - target_compile_definitions(test_opus_decode PRIVATE OPUS_BUILD) - if(OPUS_FIXED_POINT) - target_compile_definitions(test_opus_decode PRIVATE DISABLE_FLOAT_API) + target_link_libraries(test_oac_decode PRIVATE oac) + target_compile_definitions(test_oac_decode PRIVATE OAC_BUILD) + if(OAC_FIXED_POINT) + target_compile_definitions(test_oac_decode PRIVATE DISABLE_FLOAT_API) endif() - add_test(NAME test_opus_decode COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ + add_test(NAME test_oac_decode COMMAND ${CMAKE_COMMAND} + -DTEST_EXECUTABLE=$ -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake") - add_executable(test_opus_padding ${test_opus_padding_sources}) - target_include_directories(test_opus_padding + add_executable(test_oac_padding ${test_oac_padding_sources}) + target_include_directories(test_oac_padding PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(test_opus_padding PRIVATE opus) - add_test(NAME test_opus_padding COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ + target_link_libraries(test_oac_padding PRIVATE oac) + add_test(NAME test_oac_padding COMMAND ${CMAKE_COMMAND} + -DTEST_EXECUTABLE=$ -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake") - add_executable(test_opus_api ${test_opus_api_sources}) - target_include_directories(test_opus_api + add_executable(test_oac_api ${test_oac_api_sources}) + target_include_directories(test_oac_api PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt) - target_link_libraries(test_opus_api PRIVATE opus) - target_compile_definitions(test_opus_api PRIVATE OPUS_BUILD) - if(OPUS_FIXED_POINT) - target_compile_definitions(test_opus_api PRIVATE DISABLE_FLOAT_API) + target_link_libraries(test_oac_api PRIVATE oac) + target_compile_definitions(test_oac_api PRIVATE OAC_BUILD) + if(OAC_FIXED_POINT) + target_compile_definitions(test_oac_api PRIVATE DISABLE_FLOAT_API) endif() - add_test(NAME test_opus_api COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ + add_test(NAME test_oac_api COMMAND ${CMAKE_COMMAND} + -DTEST_EXECUTABLE=$ -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake") - add_executable(test_opus_encode ${test_opus_encode_sources}) - target_include_directories(test_opus_encode + add_executable(test_oac_encode ${test_oac_encode_sources}) + target_include_directories(test_oac_encode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt dnn) - target_link_libraries(test_opus_encode PRIVATE opus) - target_compile_definitions(test_opus_encode PRIVATE OPUS_BUILD) - add_test(NAME test_opus_encode COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ + target_link_libraries(test_oac_encode PRIVATE oac) + target_compile_definitions(test_oac_encode PRIVATE OAC_BUILD) + add_test(NAME test_oac_encode COMMAND ${CMAKE_COMMAND} + -DTEST_EXECUTABLE=$ -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake") - add_executable(test_opus_extensions ${test_opus_extensions_sources}) - target_include_directories(test_opus_extensions + add_executable(test_oac_extensions ${test_oac_extensions_sources}) + target_include_directories(test_oac_extensions PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt dnn) - target_link_libraries(test_opus_extensions PRIVATE opus) - target_compile_definitions(test_opus_extensions PRIVATE OPUS_BUILD) - add_test(NAME test_opus_extensions COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ + target_link_libraries(test_oac_extensions PRIVATE oac) + target_compile_definitions(test_oac_extensions PRIVATE OAC_BUILD) + add_test(NAME test_oac_extensions COMMAND ${CMAKE_COMMAND} + -DTEST_EXECUTABLE=$ -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake") - if(OPUS_DRED) - add_executable(test_opus_dred ${test_opus_dred_sources}) - target_include_directories(test_opus_dred + if(OAC_DRED) + add_executable(test_oac_dred ${test_oac_dred_sources}) + target_include_directories(test_oac_dred PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(test_opus_dred PRIVATE opus) - target_compile_definitions(test_opus_dred PRIVATE OPUS_BUILD) - add_test(NAME test_opus_dred COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ + target_link_libraries(test_oac_dred PRIVATE oac) + target_compile_definitions(test_oac_dred PRIVATE OAC_BUILD) + add_test(NAME test_oac_dred COMMAND ${CMAKE_COMMAND} + -DTEST_EXECUTABLE=$ -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake") endif() - if(OPUS_CUSTOM_MODES) - add_executable(test_opus_custom ${test_opus_custom_sources}) - target_include_directories(test_opus_custom + if(OAC_CUSTOM_MODES) + add_executable(test_oac_custom ${test_oac_custom_sources}) + target_include_directories(test_oac_custom PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt dnn) - target_link_libraries(test_opus_custom PRIVATE opus) - target_compile_definitions(test_opus_custom PRIVATE OPUS_BUILD) + target_link_libraries(test_oac_custom PRIVATE oac) + target_compile_definitions(test_oac_custom PRIVATE OAC_BUILD) endif() endif() diff --git a/LICENSE_PLEASE_READ.txt b/LICENSE_PLEASE_READ.txt deleted file mode 100644 index bc88efa6c..000000000 --- a/LICENSE_PLEASE_READ.txt +++ /dev/null @@ -1,22 +0,0 @@ -Contributions to the collaboration shall not be considered confidential. - -Each contributor represents and warrants that it has the right and -authority to license copyright in its contributions to the collaboration. - -Each contributor agrees to license the copyright in the contributions -under the Modified (2-clause or 3-clause) BSD License or the Clear BSD License. - -Please see the IPR statements submitted to the IETF for the complete -patent licensing details: - -Xiph.Org Foundation: -https://datatracker.ietf.org/ipr/1524/ - -Microsoft Corporation: -https://datatracker.ietf.org/ipr/1914/ - -Skype Limited: -https://datatracker.ietf.org/ipr/1602/ - -Broadcom Corporation: -https://datatracker.ietf.org/ipr/1526/ diff --git a/Makefile.am b/Makefile.am index cc03cd37b..331a10d4a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ export VERBOSE = yes AUTOMAKE_OPTIONS = subdir-objects ACLOCAL_AMFLAGS = -I m4 -lib_LTLIBRARIES = libopus.la +lib_LTLIBRARIES = liboac.la DIST_SUBDIRS = doc @@ -16,7 +16,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/celt -I$(top_srcdir)/silk include celt_sources.mk include lpcnet_sources.mk include silk_sources.mk -include opus_sources.mk +include oac_sources.mk LPCNET_SOURCES = if ENABLE_DEEP_PLC @@ -49,7 +49,7 @@ endif if DISABLE_FLOAT_API else -OPUS_SOURCES += $(OPUS_SOURCES_FLOAT) +OAC_SOURCES += $(OAC_SOURCES_FLOAT) endif if CPU_X86 @@ -111,7 +111,7 @@ if HAVE_ARM_NE10 CELT_SOURCES += $(CELT_SOURCES_ARM_NE10) endif -if OPUS_ARM_EXTERNAL_ASM +if OAC_ARM_EXTERNAL_ASM noinst_LTLIBRARIES = libarmasm.la libarmasm_la_SOURCES = $(CELT_SOURCES_ARM_ASM:.s=-gnu.S) BUILT_SOURCES = $(CELT_SOURCES_ARM_ASM:.s=-gnu.S) \ @@ -126,7 +126,7 @@ CLEANFILES = $(CELT_SOURCES_ARM_ASM:.s=-gnu.S) \ include celt_headers.mk include lpcnet_headers.mk include silk_headers.mk -include opus_headers.mk +include oac_headers.mk LPCNET_HEAD = if ENABLE_DEEP_PLC @@ -142,16 +142,16 @@ if ENABLE_LOSSGEN LPCNET_HEAD += $(LOSSGEN_HEAD) endif -libopus_la_SOURCES = $(CELT_SOURCES) $(SILK_SOURCES) $(LPCNET_SOURCES) $(OPUS_SOURCES) -libopus_la_LDFLAGS = -no-undefined -version-info @OPUS_LT_CURRENT@:@OPUS_LT_REVISION@:@OPUS_LT_AGE@ -libopus_la_LIBADD = $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM -libopus_la_LIBADD += libarmasm.la +liboac_la_SOURCES = $(CELT_SOURCES) $(SILK_SOURCES) $(LPCNET_SOURCES) $(OAC_SOURCES) +liboac_la_LDFLAGS = -no-undefined -version-info @OAC_LT_CURRENT@:@OAC_LT_REVISION@:@OAC_LT_AGE@ +liboac_la_LIBADD = $(NE10_LIBS) $(LIBM) +if OAC_ARM_EXTERNAL_ASM +liboac_la_LIBADD += libarmasm.la endif -pkginclude_HEADERS = include/opus.h include/opus_multistream.h include/opus_types.h include/opus_defines.h include/opus_projection.h +pkginclude_HEADERS = include/oac.h include/oac_multistream.h include/oac_types.h include/oac_defines.h include/oac_projection.h -noinst_HEADERS = $(OPUS_HEAD) $(SILK_HEAD) $(CELT_HEAD) $(LPCNET_HEAD) +noinst_HEADERS = $(OAC_HEAD) $(SILK_HEAD) $(CELT_HEAD) $(LPCNET_HEAD) if EXTRA_PROGRAMS noinst_PROGRAMS = celt/tests/test_unit_cwrs32 \ @@ -163,17 +163,17 @@ noinst_PROGRAMS = celt/tests/test_unit_cwrs32 \ celt/tests/test_unit_mdct \ celt/tests/test_unit_rotation \ celt/tests/test_unit_types \ - opus_compare \ - opus_demo \ + oac_compare \ + oac_demo \ repacketizer_demo \ silk/tests/test_unit_LPC_inv_pred_gain \ - tests/test_opus_api \ - tests/test_opus_decode \ - tests/test_opus_dred \ - tests/test_opus_encode \ - tests/test_opus_extensions \ - tests/test_opus_padding \ - tests/test_opus_projection \ + tests/test_oac_api \ + tests/test_oac_decode \ + tests/test_oac_dred \ + tests/test_oac_encode \ + tests/test_oac_extensions \ + tests/test_oac_padding \ + tests/test_oac_projection \ trivial_example TESTS = celt/tests/test_unit_cwrs32 \ @@ -186,70 +186,70 @@ TESTS = celt/tests/test_unit_cwrs32 \ celt/tests/test_unit_rotation \ celt/tests/test_unit_types \ silk/tests/test_unit_LPC_inv_pred_gain \ - tests/test_opus_api \ - tests/test_opus_decode \ - tests/test_opus_encode \ - tests/test_opus_extensions \ - tests/test_opus_padding \ - tests/test_opus_projection - -opus_demo_SOURCES = src/opus_demo.c + tests/test_oac_api \ + tests/test_oac_decode \ + tests/test_oac_encode \ + tests/test_oac_extensions \ + tests/test_oac_padding \ + tests/test_oac_projection + +oac_demo_SOURCES = src/oac_demo.c if ENABLE_LOSSGEN -opus_demo_SOURCES += $(LOSSGEN_SOURCES) +oac_demo_SOURCES += $(LOSSGEN_SOURCES) endif -opus_demo_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +oac_demo_LDADD = liboac.la $(NE10_LIBS) $(LIBM) repacketizer_demo_SOURCES = src/repacketizer_demo.c -repacketizer_demo_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +repacketizer_demo_LDADD = liboac.la $(NE10_LIBS) $(LIBM) -opus_compare_SOURCES = src/opus_compare.c -opus_compare_LDADD = $(LIBM) +oac_compare_SOURCES = src/oac_compare.c +oac_compare_LDADD = $(LIBM) trivial_example_SOURCES = doc/trivial_example.c -trivial_example_LDADD = libopus.la $(LIBM) +trivial_example_LDADD = liboac.la $(LIBM) -tests_test_opus_api_SOURCES = tests/test_opus_api.c tests/test_opus_common.h -tests_test_opus_api_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +tests_test_oac_api_SOURCES = tests/test_oac_api.c tests/test_oac_common.h +tests_test_oac_api_LDADD = liboac.la $(NE10_LIBS) $(LIBM) -tests_test_opus_encode_SOURCES = tests/test_opus_encode.c tests/opus_encode_regressions.c tests/test_opus_common.h -tests_test_opus_encode_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +tests_test_oac_encode_SOURCES = tests/test_oac_encode.c tests/oac_encode_regressions.c tests/test_oac_common.h +tests_test_oac_encode_LDADD = liboac.la $(NE10_LIBS) $(LIBM) -tests_test_opus_decode_SOURCES = tests/test_opus_decode.c tests/test_opus_common.h -tests_test_opus_decode_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +tests_test_oac_decode_SOURCES = tests/test_oac_decode.c tests/test_oac_common.h +tests_test_oac_decode_LDADD = liboac.la $(NE10_LIBS) $(LIBM) -tests_test_opus_padding_SOURCES = tests/test_opus_padding.c tests/test_opus_common.h -tests_test_opus_padding_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +tests_test_oac_padding_SOURCES = tests/test_oac_padding.c tests/test_oac_common.h +tests_test_oac_padding_LDADD = liboac.la $(NE10_LIBS) $(LIBM) -tests_test_opus_dred_SOURCES = tests/test_opus_dred.c tests/test_opus_common.h -tests_test_opus_dred_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +tests_test_oac_dred_SOURCES = tests/test_oac_dred.c tests/test_oac_common.h +tests_test_oac_dred_LDADD = liboac.la $(NE10_LIBS) $(LIBM) if CUSTOM_MODES -tests_test_opus_custom_SOURCES = tests/test_opus_custom.c tests/test_opus_common.h -tests_test_opus_custom_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +tests_test_oac_custom_SOURCES = tests/test_oac_custom.c tests/test_oac_common.h +tests_test_oac_custom_LDADD = liboac.la $(NE10_LIBS) $(LIBM) endif CELT_OBJ = $(CELT_SOURCES:.c=.lo) SILK_OBJ = $(SILK_SOURCES:.c=.lo) LPCNET_OBJ = $(LPCNET_SOURCES:.c=.lo) -OPUS_OBJ = $(OPUS_SOURCES:.c=.lo) +OAC_OBJ = $(OAC_SOURCES:.c=.lo) -tests_test_opus_extensions_SOURCES = tests/test_opus_extensions.c tests/test_opus_common.h -tests_test_opus_extensions_LDADD = $(OPUS_OBJ) $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM -tests_test_opus_extensions_LDADD += libarmasm.la +tests_test_oac_extensions_SOURCES = tests/test_oac_extensions.c tests/test_oac_common.h +tests_test_oac_extensions_LDADD = $(OAC_OBJ) $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) +if OAC_ARM_EXTERNAL_ASM +tests_test_oac_extensions_LDADD += libarmasm.la endif -tests_test_opus_projection_SOURCES = tests/test_opus_projection.c tests/test_opus_common.h -tests_test_opus_projection_LDADD = $(OPUS_OBJ) $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM -tests_test_opus_projection_LDADD += libarmasm.la +tests_test_oac_projection_SOURCES = tests/test_oac_projection.c tests/test_oac_common.h +tests_test_oac_projection_LDADD = $(OAC_OBJ) $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) +if OAC_ARM_EXTERNAL_ASM +tests_test_oac_projection_LDADD += libarmasm.la endif silk_tests_test_unit_LPC_inv_pred_gain_SOURCES = silk/tests/test_unit_LPC_inv_pred_gain.c silk_tests_test_unit_LPC_inv_pred_gain_LDADD = $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM +if OAC_ARM_EXTERNAL_ASM silk_tests_test_unit_LPC_inv_pred_gain_LDADD += libarmasm.la endif @@ -258,7 +258,7 @@ celt_tests_test_unit_cwrs32_LDADD = $(LIBM) celt_tests_test_unit_dft_SOURCES = celt/tests/test_unit_dft.c celt_tests_test_unit_dft_LDADD = $(CELT_OBJ) $(LPCNET_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM +if OAC_ARM_EXTERNAL_ASM celt_tests_test_unit_dft_LDADD += libarmasm.la endif @@ -273,19 +273,19 @@ celt_tests_test_unit_laplace_LDADD = $(LIBM) celt_tests_test_unit_mathops_SOURCES = celt/tests/test_unit_mathops.c celt_tests_test_unit_mathops_LDADD = $(CELT_OBJ) $(LPCNET_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM +if OAC_ARM_EXTERNAL_ASM celt_tests_test_unit_mathops_LDADD += libarmasm.la endif celt_tests_test_unit_mdct_SOURCES = celt/tests/test_unit_mdct.c celt_tests_test_unit_mdct_LDADD = $(CELT_OBJ) $(LPCNET_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM +if OAC_ARM_EXTERNAL_ASM celt_tests_test_unit_mdct_LDADD += libarmasm.la endif celt_tests_test_unit_rotation_SOURCES = celt/tests/test_unit_rotation.c celt_tests_test_unit_rotation_LDADD = $(CELT_OBJ) $(LPCNET_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM +if OAC_ARM_EXTERNAL_ASM celt_tests_test_unit_rotation_LDADD += libarmasm.la endif @@ -294,14 +294,14 @@ celt_tests_test_unit_types_LDADD = $(LIBM) endif if CUSTOM_MODES -pkginclude_HEADERS += include/opus_custom.h +pkginclude_HEADERS += include/oac_custom.h if EXTRA_PROGRAMS -noinst_PROGRAMS += opus_custom_demo -opus_custom_demo_SOURCES = celt/opus_custom_demo.c -opus_custom_demo_LDADD = libopus.la $(LIBM) +noinst_PROGRAMS += oac_custom_demo +oac_custom_demo_SOURCES = celt/oac_custom_demo.c +oac_custom_demo_LDADD = liboac.la $(LIBM) -TESTS += tests/test_opus_custom -noinst_PROGRAMS += tests/test_opus_custom +TESTS += tests/test_oac_custom +noinst_PROGRAMS += tests/test_oac_custom endif endif @@ -322,7 +322,7 @@ dump_weights_blob_LDADD = $(LIBM) dump_weights_blob_CFLAGS = $(AM_CFLAGS) -DDUMP_BINARY_WEIGHTS endif if ENABLE_DRED -TESTS += tests/test_opus_dred +TESTS += tests/test_oac_dred endif if ENABLE_LOSSGEN @@ -340,24 +340,24 @@ endif if ENABLE_QEXT noinst_PROGRAMS += qext_compare qext_compare_SOURCES = src/qext_compare.c -qext_compare_LDADD = libopus.la $(LIBM) +qext_compare_LDADD = liboac.la $(LIBM) endif endif -EXTRA_DIST = opus.pc.in \ - opus-uninstalled.pc.in \ - opus.m4 \ +EXTRA_DIST = oac.pc.in \ + oac-uninstalled.pc.in \ + oac.m4 \ Makefile.unix \ CMakeLists.txt \ cmake/CFeatureCheck.cmake \ - cmake/OpusBuildtype.cmake \ - cmake/OpusConfig.cmake \ - cmake/OpusConfig.cmake.in \ - cmake/OpusFunctions.cmake \ - cmake/OpusPackageVersion.cmake \ - cmake/OpusSources.cmake \ + cmake/OacBuildtype.cmake \ + cmake/OacConfig.cmake \ + cmake/OacConfig.cmake.in \ + cmake/OacFunctions.cmake \ + cmake/OacPackageVersion.cmake \ + cmake/OacSources.cmake \ cmake/README.md \ cmake/RunTest.cmake \ cmake/config.h.cmake.in \ @@ -386,17 +386,17 @@ EXTRA_DIST = opus.pc.in \ celt/arm/celt_pitch_xcorr_arm.s pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = opus.pc +pkgconfig_DATA = oac.pc m4datadir = $(datadir)/aclocal -m4data_DATA = opus.m4 +m4data_DATA = oac.m4 # Targets to build and install just the library without the docs -opus check-opus install-opus: export NO_DOXYGEN = 1 +oac check-oac install-oac: export NO_DOXYGEN = 1 -opus: all -check-opus: check -install-opus: install +oac: all +check-oac: check +install-oac: install # Or just the docs @@ -457,7 +457,7 @@ dist-hook: echo 'PACKAGE_VERSION="$(PACKAGE_VERSION)"' > $(top_distdir)/package_version -.PHONY: opus check-opus install-opus docs install-docs +.PHONY: oac check-oac install-oac docs install-docs # automake doesn't do dependency tracking for asm files, that I can tell $(CELT_SOURCES_ARM_ASM:%.s=%-gnu.S): celt/arm/armopts-gnu.S @@ -478,13 +478,13 @@ OPT_UNIT_TEST_OBJ = $(celt_tests_test_unit_mathops_SOURCES:.c=.o) \ if HAVE_SSE SSE_OBJ = $(CELT_SOURCES_SSE:.c=.lo) -$(SSE_OBJ): CFLAGS += $(OPUS_X86_SSE_CFLAGS) +$(SSE_OBJ): CFLAGS += $(OAC_X86_SSE_CFLAGS) endif if HAVE_SSE2 SSE2_OBJ = $(CELT_SOURCES_SSE2:.c=.lo) \ $(DNN_SOURCES_SSE2:.c=.lo) -$(SSE2_OBJ): CFLAGS += $(OPUS_X86_SSE2_CFLAGS) +$(SSE2_OBJ): CFLAGS += $(OAC_X86_SSE2_CFLAGS) endif if HAVE_SSE4_1 @@ -492,7 +492,7 @@ SSE4_1_OBJ = $(CELT_SOURCES_SSE4_1:.c=.lo) \ $(DNN_SOURCES_SSE4_1:.c=.lo) \ $(SILK_SOURCES_SSE4_1:.c=.lo) \ $(SILK_SOURCES_FIXED_SSE4_1:.c=.lo) -$(SSE4_1_OBJ): CFLAGS += $(OPUS_X86_SSE4_1_CFLAGS) +$(SSE4_1_OBJ): CFLAGS += $(OAC_X86_SSE4_1_CFLAGS) endif if HAVE_AVX2 @@ -500,7 +500,7 @@ AVX2_OBJ = $(CELT_SOURCES_AVX2:.c=.lo) \ $(SILK_SOURCES_AVX2:.c=.lo) \ $(SILK_SOURCES_FLOAT_AVX2:.c=.lo) \ $(DNN_SOURCES_AVX2:.c=.lo) -$(AVX2_OBJ): CFLAGS += $(OPUS_X86_AVX2_CFLAGS) +$(AVX2_OBJ): CFLAGS += $(OAC_X86_AVX2_CFLAGS) endif if HAVE_ARM_NEON_INTR @@ -509,7 +509,7 @@ ARM_NEON_INTR_OBJ = $(CELT_SOURCES_ARM_NEON_INTR:.c=.lo) \ $(DNN_SOURCES_NEON:.c=.lo) \ $(SILK_SOURCES_FIXED_ARM_NEON_INTR:.c=.lo) $(ARM_NEON_INTR_OBJ): CFLAGS += \ - $(OPUS_ARM_NEON_INTR_CFLAGS) $(NE10_CFLAGS) + $(OAC_ARM_NEON_INTR_CFLAGS) $(NE10_CFLAGS) endif if HAVE_ARM_DOTPROD diff --git a/Makefile.unix b/Makefile.unix index 0242992d2..87b8e2a43 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -20,13 +20,13 @@ CFLAGS := -DUSE_ALLOCA $(CFLAGS) include silk_sources.mk include celt_sources.mk -include opus_sources.mk +include oac_sources.mk ifdef FIXED_POINT SILK_SOURCES += $(SILK_SOURCES_FIXED) else SILK_SOURCES += $(SILK_SOURCES_FLOAT) -OPUS_SOURCES += $(OPUS_SOURCES_FLOAT) +OAC_SOURCES += $(OAC_SOURCES_FLOAT) endif EXESUFFIX = @@ -45,7 +45,7 @@ ldflags-from-ldlibdirs = $(addprefix -L,$(1)) ldlibs-from-libs = $(addprefix -l,$(1)) WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow -CFLAGS += -O2 -g $(WARNINGS) -DOPUS_BUILD +CFLAGS += -O2 -g $(WARNINGS) -DOAC_BUILD CINCLUDES = include silk celt ifdef FIXED_POINT @@ -81,38 +81,38 @@ ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@ # Variable definitions -LIB_NAME = opus +LIB_NAME = oac TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX) -SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES) +SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OAC_SOURCES) OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C)) -OPUSDEMO_SRCS_C = src/opus_demo.c -OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C)) +OACDEMO_SRCS_C = src/oac_demo.c +OACDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OACDEMO_SRCS_C)) -TESTOPUSAPI_SRCS_C = tests/test_opus_api.c -TESTOPUSAPI_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSAPI_SRCS_C)) +TESTOACAPI_SRCS_C = tests/test_oac_api.c +TESTOACAPI_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACAPI_SRCS_C)) -TESTOPUSDECODE_SRCS_C = tests/test_opus_decode.c -TESTOPUSDECODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSDECODE_SRCS_C)) +TESTOACDECODE_SRCS_C = tests/test_oac_decode.c +TESTOACDECODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACDECODE_SRCS_C)) -TESTOPUSENCODE_SRCS_C = tests/test_opus_encode.c tests/opus_encode_regressions.c -TESTOPUSENCODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSENCODE_SRCS_C)) +TESTOACENCODE_SRCS_C = tests/test_oac_encode.c tests/oac_encode_regressions.c +TESTOACENCODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACENCODE_SRCS_C)) -TESTOPUSEXTENSIONS_SRCS_C = tests/test_opus_extensions.c -TESTOPUSEXTENSIONS_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSEXTENSIONS_SRCS_C)) +TESTOACEXTENSIONS_SRCS_C = tests/test_oac_extensions.c +TESTOACEXTENSIONS_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACEXTENSIONS_SRCS_C)) -TESTOPUSPADDING_SRCS_C = tests/test_opus_padding.c -TESTOPUSPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSPADDING_SRCS_C)) +TESTOACPADDING_SRCS_C = tests/test_oac_padding.c +TESTOACPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACPADDING_SRCS_C)) -OPUSCOMPARE_SRCS_C = src/opus_compare.c -OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C)) +OACCOMPARE_SRCS_C = src/oac_compare.c +OACCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OACCOMPARE_SRCS_C)) -TESTS := test_opus_api test_opus_decode test_opus_encode test_opus_extensions test_opus_padding +TESTS := test_oac_api test_oac_decode test_oac_encode test_oac_extensions test_oac_padding # Rules -all: lib opus_demo opus_compare $(TESTS) +all: lib oac_demo oac_compare $(TESTS) lib: $(TARGET) @@ -122,25 +122,25 @@ check: all $(TARGET): $(OBJS) $(ARCHIVE.cmdline) -opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET) +oac_demo$(EXESUFFIX): $(OACDEMO_OBJS) $(TARGET) $(LINK.o.cmdline) -test_opus_api$(EXESUFFIX): $(TESTOPUSAPI_OBJS) $(TARGET) +test_oac_api$(EXESUFFIX): $(TESTOACAPI_OBJS) $(TARGET) $(LINK.o.cmdline) -test_opus_decode$(EXESUFFIX): $(TESTOPUSDECODE_OBJS) $(TARGET) +test_oac_decode$(EXESUFFIX): $(TESTOACDECODE_OBJS) $(TARGET) $(LINK.o.cmdline) -test_opus_encode$(EXESUFFIX): $(TESTOPUSENCODE_OBJS) $(TARGET) +test_oac_encode$(EXESUFFIX): $(TESTOACENCODE_OBJS) $(TARGET) $(LINK.o.cmdline) -test_opus_extensions$(EXESUFFIX): $(TESTOPUSEXTENSIONS_OBJS) $(TARGET) +test_oac_extensions$(EXESUFFIX): $(TESTOACEXTENSIONS_OBJS) $(TARGET) $(LINK.o.cmdline) -test_opus_padding$(EXESUFFIX): $(TESTOPUSPADDING_OBJS) $(TARGET) +test_oac_padding$(EXESUFFIX): $(TESTOACPADDING_OBJS) $(TARGET) $(LINK.o.cmdline) -opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS) +oac_compare$(EXESUFFIX): $(OACCOMPARE_OBJS) $(LINK.o.cmdline) celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)' @@ -156,12 +156,12 @@ package_version: force force: clean: - rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) \ - test_opus_api$(EXESUFFIX) test_opus_decode$(EXESUFFIX) \ - test_opus_encode$(EXESUFFIX) test_opus_extensions$(EXESUFFIX) \ - test_opus_padding$(EXESUFFIX) \ - $(OBJS) $(OPUSDEMO_OBJS) $(OPUSCOMPARE_OBJS) $(TESTOPUSAPI_OBJS) \ - $(TESTOPUSDECODE_OBJS) $(TESTOPUSENCODE_OBJS) \ - $(TESTOPUSEXTENSIONS_OBJS) $(TESTOPUSPADDING_OBJS) + rm -f oac_demo$(EXESUFFIX) oac_compare$(EXESUFFIX) $(TARGET) \ + test_oac_api$(EXESUFFIX) test_oac_decode$(EXESUFFIX) \ + test_oac_encode$(EXESUFFIX) test_oac_extensions$(EXESUFFIX) \ + test_oac_padding$(EXESUFFIX) \ + $(OBJS) $(OACDEMO_OBJS) $(OACCOMPARE_OBJS) $(TESTOACAPI_OBJS) \ + $(TESTOACDECODE_OBJS) $(TESTOACENCODE_OBJS) \ + $(TESTOACEXTENSIONS_OBJS) $(TESTOACPADDING_OBJS) .PHONY: all lib clean force check diff --git a/README.draft b/README.draft deleted file mode 100644 index 9c31bd023..000000000 --- a/README.draft +++ /dev/null @@ -1,54 +0,0 @@ -To build this source code, simply type: - -% make - -If this does not work, or if you want to change the default configuration -(e.g., to compile for a fixed-point architecture), simply edit the options -in the Makefile. - -An up-to-date implementation conforming to this standard is available in a -Git repository at https://gitlab.xiph.org/xiph/opus.git or on a website at: -https://opus-codec.org/ -However, although that implementation is expected to remain conformant -with the standard, it is the code in this RFC that shall remain normative. -To build from the git repository instead of using this RFC, follow these -steps: - -1) Clone the repository (latest implementation of this standard at the time -of publication) - -% git clone https://gitlab.xiph.org/xiph/opus.git -% cd opus - -2) Compile - -% ./autogen.sh -% ./configure -% make - -Once you have compiled the codec, there will be a opus_demo executable in -the top directory. - -Usage: opus_demo [-e] - [options] - opus_demo -d [options] - - -mode: voip | audio | restricted-lowdelay -options: --e : only runs the encoder (output the bit-stream) --d : only runs the decoder (reads the bit-stream as input) --cbr : enable constant bitrate; default: variable bitrate --cvbr : enable constrained variable bitrate; default: unconstrained --bandwidth : audio bandwidth (from narrowband to fullband); - default: sampling rate --framesize <2.5|5|10|20|40|60> : frame size in ms; default: 20 --max_payload : maximum payload size in bytes, default: 1024 --complexity : complexity, 0 (lowest) ... 10 (highest); default: 10 --inbandfec : enable SILK inband FEC --forcemono : force mono encoding, even for stereo input --dtx : enable SILK DTX --loss : simulate packet loss, in percent (0-100); default: 0 - -input and output are little endian signed 16-bit PCM files or opus bitstreams -with simple opus_demo proprietary framing. diff --git a/celt/_kiss_fft_guts.h b/celt/_kiss_fft_guts.h index fa1e37fe2..e85a69c8b 100644 --- a/celt/_kiss_fft_guts.h +++ b/celt/_kiss_fft_guts.h @@ -90,11 +90,11 @@ do {(res).r = ADD32_ovflw((res).r,(a).r); (res).i = SUB32_ovflw((res).i,(a).i); \ }while(0) -#if defined(OPUS_ARM_INLINE_ASM) +#if defined(OAC_ARM_INLINE_ASM) #include "arm/kiss_fft_armv4.h" #endif -#if defined(OPUS_ARM_INLINE_EDSP) +#if defined(OAC_ARM_INLINE_EDSP) #include "arm/kiss_fft_armv5e.h" #endif #if defined(__mips) diff --git a/celt/arch.h b/celt/arch.h index b88648beb..06730f9e1 100644 --- a/celt/arch.h +++ b/celt/arch.h @@ -34,8 +34,8 @@ #ifndef ARCH_H #define ARCH_H -#include "opus_types.h" -#include "opus_defines.h" +#include "oac_types.h" +#include "oac_defines.h" # if !defined(__GNUC_PREREQ) # if defined(__GNUC__)&&defined(__GNUC_MINOR__) @@ -46,12 +46,12 @@ # endif # endif -#if OPUS_GNUC_PREREQ(3, 0) -#define opus_likely(x) (__builtin_expect(!!(x), 1)) -#define opus_unlikely(x) (__builtin_expect(!!(x), 0)) +#if OAC_GNUC_PREREQ(3, 0) +#define oac_likely(x) (__builtin_expect(!!(x), 1)) +#define oac_unlikely(x) (__builtin_expect(!!(x), 0)) #else -#define opus_likely(x) (!!(x)) -#define opus_unlikely(x) (!!(x)) +#define oac_likely(x) (!!(x)) +#define oac_unlikely(x) (!!(x)) #endif #define CELT_SIG_SCALE 32768.f @@ -82,11 +82,11 @@ void celt_fatal(const char *str, const char *file, int line) #define celt_assert(cond) {if (!(cond)) {CELT_FATAL("assertion failed: " #cond);}} #define celt_assert2(cond, message) {if (!(cond)) {CELT_FATAL("assertion failed: " #cond "\n" message);}} -#define MUST_SUCCEED(call) celt_assert((call) == OPUS_OK) +#define MUST_SUCCEED(call) celt_assert((call) == OAC_OK) #else #define celt_assert(cond) ((void)(cond)) #define celt_assert2(cond, message) ((void)(cond)) -#define MUST_SUCCEED(call) do {if((call) != OPUS_OK) {RESTORE_STACK; return OPUS_INTERNAL_ERROR;} } while (0) +#define MUST_SUCCEED(call) do {if((call) != OAC_OK) {RESTORE_STACK; return OAC_INTERNAL_ERROR;} } while (0) #endif #if defined(ENABLE_ASSERTIONS) @@ -113,18 +113,18 @@ void celt_fatal(const char *str, const char *file, int line) /* Throughout the code, we use the following scaling for signals: FLOAT: used for float API, normalized to +/-1. INT16: used for 16-bit API, normalized to +/- 32768 - RES: internal Opus resolution, defined as +/-1. in float builds, or either 16-bit or 24-bit int for fixed-point builds + RES: internal Oac resolution, defined as +/-1. in float builds, or either 16-bit or 24-bit int for fixed-point builds SIG: internal CELT resolution: defined as +/- 32768. in float builds, or Q27 in fixed-point builds (int16 shifted by 12) */ -/* Set this if opus_int64 is a native type of the CPU. */ +/* Set this if oac_int64 is a native type of the CPU. */ /* Assume that all LP64 architectures have fast 64-bit types; also x86_64 (which can be ILP32 for x32) and Win64 (which is LLP64). */ #if defined(__x86_64__) || defined(__LP64__) || defined(_WIN64) || defined (__mips) -#define OPUS_FAST_INT64 1 +#define OAC_FAST_INT64 1 #else -#define OPUS_FAST_INT64 0 +#define OAC_FAST_INT64 0 #endif #ifdef FIXED_POINT @@ -137,16 +137,16 @@ void celt_fatal(const char *str, const char *file, int line) #ifdef FIXED_POINT -typedef opus_int16 opus_val16; -typedef opus_int32 opus_val32; -typedef opus_int64 opus_val64; +typedef oac_int16 oac_val16; +typedef oac_int32 oac_val32; +typedef oac_int64 oac_val64; -typedef opus_val32 celt_sig; -typedef opus_val32 celt_norm; -typedef opus_val32 celt_ener; -typedef opus_val32 celt_glog; +typedef oac_val32 celt_sig; +typedef oac_val32 celt_norm; +typedef oac_val32 celt_ener; +typedef oac_val32 celt_glog; -typedef opus_val32 opus_res; +typedef oac_val32 oac_res; #define RES_SHIFT 8 #define SIG2RES(a) PSHR32(a, SIG_SHIFT-RES_SHIFT) #define RES2INT16(a) SAT16(PSHR32(a, RES_SHIFT)) @@ -165,7 +165,7 @@ typedef opus_val32 opus_res; #define INT24TOSIG(a) SHL32(a, SIG_SHIFT-8) #define NORM_SHIFT 24 -typedef opus_val32 celt_coef; +typedef oac_val32 celt_coef; #define COEF_ONE Q31ONE #define MULT_COEF_32(a, b) MULT32_32_P31(a,b) #define MAC_COEF_32_ARM(c, a, b) ADD32((c), MULT32_32_Q32(a,b)) @@ -194,15 +194,15 @@ typedef opus_val32 celt_coef; #define EPSILON 1 #define VERY_SMALL 0 -#define VERY_LARGE16 ((opus_val16)32767) -#define Q15_ONE ((opus_val16)32767) +#define VERY_LARGE16 ((oac_val16)32767) +#define Q15_ONE ((oac_val16)32767) #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) #define ABS32(x) ((x) < 0 ? (-(x)) : (x)) -static OPUS_INLINE opus_int16 SAT16(opus_int32 x) { - return x > 32767 ? 32767 : x < -32768 ? -32768 : (opus_int16)x; +static OAC_INLINE oac_int16 SAT16(oac_int32 x) { + return x > 32767 ? 32767 : x < -32768 ? -32768 : (oac_int16)x; } #ifdef FIXED_DEBUG @@ -211,11 +211,11 @@ static OPUS_INLINE opus_int16 SAT16(opus_int32 x) { #include "fixed_generic.h" -#ifdef OPUS_ARM_PRESUME_AARCH64_NEON_INTR +#ifdef OAC_ARM_PRESUME_AARCH64_NEON_INTR #include "arm/fixed_arm64.h" -#elif defined (OPUS_ARM_INLINE_EDSP) +#elif defined (OAC_ARM_INLINE_EDSP) #include "arm/fixed_armv5e.h" -#elif defined (OPUS_ARM_INLINE_ASM) +#elif defined (OAC_ARM_INLINE_ASM) #include "arm/fixed_armv4.h" #elif defined (BFIN_ASM) #include "fixed_bfin.h" @@ -229,30 +229,30 @@ static OPUS_INLINE opus_int16 SAT16(opus_int32 x) { #else /* FIXED_POINT */ -typedef float opus_val16; -typedef float opus_val32; -typedef float opus_val64; +typedef float oac_val16; +typedef float oac_val32; +typedef float oac_val64; typedef float celt_sig; typedef float celt_norm; typedef float celt_ener; typedef float celt_glog; -typedef float opus_res; +typedef float oac_res; typedef float celt_coef; #ifdef FLOAT_APPROX /* This code should reliably detect NaN/inf even when -ffast-math is used. Assumes IEEE 754 format. */ -static OPUS_INLINE int celt_isnan(float x) +static OAC_INLINE int celt_isnan(float x) { - union {float f; opus_uint32 i;} in; + union {float f; oac_uint32 i;} in; in.f = x; return ((in.i>>23)&0xFF)==0xFF && (in.i&0x007FFFFF)!=0; } #else #ifdef __FAST_MATH__ -#error Cannot build libopus with -ffast-math unless FLOAT_APPROX is defined. This could result in crashes on extreme (e.g. NaN) input +#error Cannot build liboac with -ffast-math unless FLOAT_APPROX is defined. This could result in crashes on extreme (e.g. NaN) input #endif #define celt_isnan(x) ((x)!=(x)) #endif @@ -267,7 +267,7 @@ static OPUS_INLINE int celt_isnan(float x) #define EPSILON 1e-15f #define VERY_SMALL 1e-30f #define VERY_LARGE16 1e15f -#define Q15_ONE ((opus_val16)1.f) +#define Q15_ONE ((oac_val16)1.f) /* This appears to be the same speed as C99's fabsf() but it's more portable. */ #define ABS16(x) ((float)fabs(x)) @@ -312,8 +312,8 @@ static OPUS_INLINE int celt_isnan(float x) #define PSHR32_ovflw(a,shift) (a) #define MULT16_16_16(a,b) ((a)*(b)) -#define MULT16_16(a,b) ((opus_val32)(a)*(opus_val32)(b)) -#define MAC16_16(c,a,b) ((c)+(opus_val32)(a)*(opus_val32)(b)) +#define MULT16_16(a,b) ((oac_val32)(a)*(oac_val32)(b)) +#define MAC16_16(c,a,b) ((c)+(oac_val32)(a)*(oac_val32)(b)) #define MULT16_32_Q15(a,b) ((a)*(b)) #define MULT16_32_Q16(a,b) ((a)*(b)) @@ -341,8 +341,8 @@ static OPUS_INLINE int celt_isnan(float x) #define MULT_COEF(a, b) ((a)*(b)) #define MULT_COEF_TAPS(a, b) ((a)*(b)) -#define DIV32_16(a,b) (((opus_val32)(a))/(opus_val16)(b)) -#define DIV32(a,b) (((opus_val32)(a))/(opus_val32)(b)) +#define DIV32_16(a,b) (((oac_val32)(a))/(oac_val16)(b)) +#define DIV32(a,b) (((oac_val32)(a))/(oac_val32)(b)) #define SIG2RES(a) ((1/CELT_SIG_SCALE)*(a)) #define RES2INT16(a) FLOAT2INT16(a) diff --git a/celt/arm/arm_celt_map.c b/celt/arm/arm_celt_map.c index 931c011dd..52a3b48bf 100644 --- a/celt/arm/arm_celt_map.c +++ b/celt/arm/arm_celt_map.c @@ -35,11 +35,11 @@ #include "mdct.h" #include "pitch.h" -#if defined(OPUS_HAVE_RTCD) +#if defined(OAC_HAVE_RTCD) # if !defined(DISABLE_FLOAT_API) -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR) -void (*const CELT_FLOAT2INT16_IMPL[OPUS_ARCHMASK+1])(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt) = { +# if defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR) +void (*const CELT_FLOAT2INT16_IMPL[OAC_ARCHMASK+1])(const float * OAC_RESTRICT in, short * OAC_RESTRICT out, int cnt) = { celt_float2int16_c, /* ARMv4 */ celt_float2int16_c, /* EDSP */ celt_float2int16_c, /* Media */ @@ -47,18 +47,18 @@ void (*const CELT_FLOAT2INT16_IMPL[OPUS_ARCHMASK+1])(const float * OPUS_RESTRICT celt_float2int16_neon /* DOTPROD */ }; -int (*const OPUS_LIMIT2_CHECKWITHIN1_IMPL[OPUS_ARCHMASK+1])(float * samples, int cnt) = { - opus_limit2_checkwithin1_c, /* ARMv4 */ - opus_limit2_checkwithin1_c, /* EDSP */ - opus_limit2_checkwithin1_c, /* Media */ - opus_limit2_checkwithin1_neon,/* NEON */ - opus_limit2_checkwithin1_neon /* DOTPROD */ +int (*const OAC_LIMIT2_CHECKWITHIN1_IMPL[OAC_ARCHMASK+1])(float * samples, int cnt) = { + oac_limit2_checkwithin1_c, /* ARMv4 */ + oac_limit2_checkwithin1_c, /* EDSP */ + oac_limit2_checkwithin1_c, /* Media */ + oac_limit2_checkwithin1_neon,/* NEON */ + oac_limit2_checkwithin1_neon /* DOTPROD */ }; # endif # endif -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR) -opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const opus_val16 *y, int N) = { +# if defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR) +oac_val32 (*const CELT_INNER_PROD_IMPL[OAC_ARCHMASK+1])(const oac_val16 *x, const oac_val16 *y, int N) = { celt_inner_prod_c, /* ARMv4 */ celt_inner_prod_c, /* EDSP */ celt_inner_prod_c, /* Media */ @@ -66,8 +66,8 @@ opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, c celt_inner_prod_neon /* DOTPROD */ }; -void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2) = { +void (*const DUAL_INNER_PROD_IMPL[OAC_ARCHMASK+1])(const oac_val16 *x, const oac_val16 *y01, const oac_val16 *y02, + int N, oac_val32 *xy1, oac_val32 *xy2) = { dual_inner_prod_c, /* ARMv4 */ dual_inner_prod_c, /* EDSP */ dual_inner_prod_c, /* Media */ @@ -77,11 +77,11 @@ void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const o # endif # if defined(FIXED_POINT) -# if ((defined(OPUS_ARM_MAY_HAVE_NEON) && !defined(OPUS_ARM_PRESUME_NEON)) || \ - (defined(OPUS_ARM_MAY_HAVE_MEDIA) && !defined(OPUS_ARM_PRESUME_MEDIA)) || \ - (defined(OPUS_ARM_MAY_HAVE_EDSP) && !defined(OPUS_ARM_PRESUME_EDSP))) -opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, - const opus_val16 *, opus_val32 *, int, int, int) = { +# if ((defined(OAC_ARM_MAY_HAVE_NEON) && !defined(OAC_ARM_PRESUME_NEON)) || \ + (defined(OAC_ARM_MAY_HAVE_MEDIA) && !defined(OAC_ARM_PRESUME_MEDIA)) || \ + (defined(OAC_ARM_MAY_HAVE_EDSP) && !defined(OAC_ARM_PRESUME_EDSP))) +oac_val32 (*const CELT_PITCH_XCORR_IMPL[OAC_ARCHMASK+1])(const oac_val16 *, + const oac_val16 *, oac_val32 *, int, int, int) = { celt_pitch_xcorr_c, /* ARMv4 */ MAY_HAVE_EDSP(celt_pitch_xcorr), /* EDSP */ MAY_HAVE_MEDIA(celt_pitch_xcorr), /* Media */ @@ -91,9 +91,9 @@ opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, # endif # else /* !FIXED_POINT */ -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR) -void (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, - const opus_val16 *, opus_val32 *, int, int, int) = { +# if defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR) +void (*const CELT_PITCH_XCORR_IMPL[OAC_ARCHMASK+1])(const oac_val16 *, + const oac_val16 *, oac_val32 *, int, int, int) = { celt_pitch_xcorr_c, /* ARMv4 */ celt_pitch_xcorr_c, /* EDSP */ celt_pitch_xcorr_c, /* Media */ @@ -103,13 +103,13 @@ void (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, # endif # endif /* FIXED_POINT */ -#if defined(FIXED_POINT) && defined(OPUS_HAVE_RTCD) && \ - defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR) +#if defined(FIXED_POINT) && defined(OAC_HAVE_RTCD) && \ + defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR) -void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y, - opus_val32 sum[4], +void (*const XCORR_KERNEL_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y, + oac_val32 sum[4], int len ) = { xcorr_kernel_c, /* ARMv4 */ @@ -121,50 +121,50 @@ void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( #endif -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(OAC_ARM_MAY_HAVE_NEON_INTR) # if defined(HAVE_ARM_NE10) # if defined(CUSTOM_MODES) -int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = { - opus_fft_alloc_arch_c, /* ARMv4 */ - opus_fft_alloc_arch_c, /* EDSP */ - opus_fft_alloc_arch_c, /* Media */ - opus_fft_alloc_arm_neon, /* Neon with NE10 library support */ - opus_fft_alloc_arm_neon /* DOTPROD with NE10 library support */ +int (*const OAC_FFT_ALLOC_ARCH_IMPL[OAC_ARCHMASK+1])(kiss_fft_state *st) = { + oac_fft_alloc_arch_c, /* ARMv4 */ + oac_fft_alloc_arch_c, /* EDSP */ + oac_fft_alloc_arch_c, /* Media */ + oac_fft_alloc_arm_neon, /* Neon with NE10 library support */ + oac_fft_alloc_arm_neon /* DOTPROD with NE10 library support */ }; -void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = { - opus_fft_free_arch_c, /* ARMv4 */ - opus_fft_free_arch_c, /* EDSP */ - opus_fft_free_arch_c, /* Media */ - opus_fft_free_arm_neon, /* Neon with NE10 */ - opus_fft_free_arm_neon /* DOTPROD with NE10 */ +void (*const OAC_FFT_FREE_ARCH_IMPL[OAC_ARCHMASK+1])(kiss_fft_state *st) = { + oac_fft_free_arch_c, /* ARMv4 */ + oac_fft_free_arch_c, /* EDSP */ + oac_fft_free_arch_c, /* Media */ + oac_fft_free_arm_neon, /* Neon with NE10 */ + oac_fft_free_arm_neon /* DOTPROD with NE10 */ }; # endif /* CUSTOM_MODES */ -void (*const OPUS_FFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg, +void (*const OAC_FFT[OAC_ARCHMASK+1])(const kiss_fft_state *cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout) = { - opus_fft_c, /* ARMv4 */ - opus_fft_c, /* EDSP */ - opus_fft_c, /* Media */ - opus_fft_neon, /* Neon with NE10 */ - opus_fft_neon /* DOTPROD with NE10 */ + oac_fft_c, /* ARMv4 */ + oac_fft_c, /* EDSP */ + oac_fft_c, /* Media */ + oac_fft_neon, /* Neon with NE10 */ + oac_fft_neon /* DOTPROD with NE10 */ }; -void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg, +void (*const OAC_IFFT[OAC_ARCHMASK+1])(const kiss_fft_state *cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout) = { - opus_ifft_c, /* ARMv4 */ - opus_ifft_c, /* EDSP */ - opus_ifft_c, /* Media */ - opus_ifft_neon, /* Neon with NE10 */ - opus_ifft_neon /* DOTPROD with NE10 */ + oac_ifft_c, /* ARMv4 */ + oac_ifft_c, /* EDSP */ + oac_ifft_c, /* Media */ + oac_ifft_neon, /* Neon with NE10 */ + oac_ifft_neon /* DOTPROD with NE10 */ }; -void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l, +void (*const CLT_MDCT_FORWARD_IMPL[OAC_ARCHMASK+1])(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 *window, + kiss_fft_scalar * OAC_RESTRICT out, + const oac_val16 *window, int overlap, int shift, int stride, int arch) = { clt_mdct_forward_c, /* ARMv4 */ @@ -174,10 +174,10 @@ void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l, clt_mdct_forward_neon /* DOTPROD with NE10 */ }; -void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l, +void (*const CLT_MDCT_BACKWARD_IMPL[OAC_ARCHMASK+1])(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 *window, + kiss_fft_scalar * OAC_RESTRICT out, + const oac_val16 *window, int overlap, int shift, int stride, int arch) = { clt_mdct_backward_c, /* ARMv4 */ @@ -188,6 +188,6 @@ void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l, }; # endif /* HAVE_ARM_NE10 */ -# endif /* OPUS_ARM_MAY_HAVE_NEON_INTR */ +# endif /* OAC_ARM_MAY_HAVE_NEON_INTR */ -#endif /* OPUS_HAVE_RTCD */ +#endif /* OAC_HAVE_RTCD */ diff --git a/celt/arm/armcpu.c b/celt/arm/armcpu.c index f03408c10..4d486371e 100644 --- a/celt/arm/armcpu.c +++ b/celt/arm/armcpu.c @@ -25,25 +25,25 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* Original code from libtheora modified to suit to Opus */ +/* Original code from libtheora modified to suit to Oac */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#ifdef OPUS_HAVE_RTCD +#ifdef OAC_HAVE_RTCD #include "armcpu.h" #include "cpu_support.h" #include "os_support.h" -#include "opus_types.h" +#include "oac_types.h" #include "arch.h" -#define OPUS_CPU_ARM_V4_FLAG (1< -static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){ - opus_uint32 flags; +static OAC_INLINE oac_uint32 oac_cpu_capabilities(void){ + oac_uint32 flags; flags=0; - /* MSVC has no OPUS_INLINE __asm support for ARM, but it does let you __emit + /* MSVC has no OAC_INLINE __asm support for ARM, but it does let you __emit * instructions via their assembled hex code. * All of these instructions should be essentially nops. */ -# if defined(OPUS_ARM_MAY_HAVE_EDSP) || defined(OPUS_ARM_MAY_HAVE_MEDIA) \ - || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(OAC_ARM_MAY_HAVE_EDSP) || defined(OAC_ARM_MAY_HAVE_MEDIA) \ + || defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) __try{ /*PLD [r13]*/ __emit(0xF5DDF000); - flags|=OPUS_CPU_ARM_EDSP_FLAG; + flags|=OAC_CPU_ARM_EDSP_FLAG; } __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ /*Ignore exception.*/ } -# if defined(OPUS_ARM_MAY_HAVE_MEDIA) \ - || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(OAC_ARM_MAY_HAVE_MEDIA) \ + || defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) __try{ /*SHADD8 r3,r3,r3*/ __emit(0xE6333F93); - flags|=OPUS_CPU_ARM_MEDIA_FLAG; + flags|=OAC_CPU_ARM_MEDIA_FLAG; } __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ /*Ignore exception.*/ } -# if defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) __try{ /*VORR q0,q0,q0*/ __emit(0xF2200150); - flags|=OPUS_CPU_ARM_NEON_FLAG; + flags|=OAC_CPU_ARM_NEON_FLAG; } __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ /*Ignore exception.*/ @@ -96,9 +96,9 @@ static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){ /* Linux based */ #include -static opus_uint32 opus_cpu_capabilities(void) +static oac_uint32 oac_cpu_capabilities(void) { - opus_uint32 flags = 0; + oac_uint32 flags = 0; FILE *cpuinfo; /* Reading /proc/self/auxv would be easier, but that doesn't work reliably on @@ -113,34 +113,34 @@ static opus_uint32 opus_cpu_capabilities(void) while(fgets(buf, 512, cpuinfo) != NULL) { -# if defined(OPUS_ARM_MAY_HAVE_EDSP) || defined(OPUS_ARM_MAY_HAVE_MEDIA) \ - || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(OAC_ARM_MAY_HAVE_EDSP) || defined(OAC_ARM_MAY_HAVE_MEDIA) \ + || defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) /* Search for edsp and neon flag */ if(memcmp(buf, "Features", 8) == 0) { char *p; p = strstr(buf, " edsp"); if(p != NULL && (p[5] == ' ' || p[5] == '\n')) - flags |= OPUS_CPU_ARM_EDSP_FLAG; + flags |= OAC_CPU_ARM_EDSP_FLAG; -# if defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) p = strstr(buf, " neon"); if(p != NULL && (p[5] == ' ' || p[5] == '\n')) - flags |= OPUS_CPU_ARM_NEON_FLAG; + flags |= OAC_CPU_ARM_NEON_FLAG; p = strstr(buf, " asimd"); if(p != NULL && (p[6] == ' ' || p[6] == '\n')) - flags |= OPUS_CPU_ARM_NEON_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_EDSP_FLAG; + flags |= OAC_CPU_ARM_NEON_FLAG | OAC_CPU_ARM_MEDIA_FLAG | OAC_CPU_ARM_EDSP_FLAG; # endif -# if defined(OPUS_ARM_MAY_HAVE_DOTPROD) +# if defined(OAC_ARM_MAY_HAVE_DOTPROD) p = strstr(buf, " asimddp"); if(p != NULL && (p[8] == ' ' || p[8] == '\n')) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; + flags |= OAC_CPU_ARM_DOTPROD_FLAG; # endif } # endif -# if defined(OPUS_ARM_MAY_HAVE_MEDIA) \ - || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(OAC_ARM_MAY_HAVE_MEDIA) \ + || defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) /* Search for media capabilities (>= ARMv6) */ if(memcmp(buf, "CPU architecture:", 17) == 0) { @@ -148,15 +148,15 @@ static opus_uint32 opus_cpu_capabilities(void) version = atoi(buf+17); if(version >= 6) - flags |= OPUS_CPU_ARM_MEDIA_FLAG; + flags |= OAC_CPU_ARM_MEDIA_FLAG; } # endif } -#if defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR) - flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG; -# if defined(OPUS_ARM_PRESUME_DOTPROD) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; +#if defined(OAC_ARM_PRESUME_AARCH64_NEON_INTR) + flags |= OAC_CPU_ARM_EDSP_FLAG | OAC_CPU_ARM_MEDIA_FLAG | OAC_CPU_ARM_NEON_FLAG; +# if defined(OAC_ARM_PRESUME_DOTPROD) + flags |= OAC_CPU_ARM_DOTPROD_FLAG; # endif #endif @@ -169,23 +169,23 @@ static opus_uint32 opus_cpu_capabilities(void) #include #include -static opus_uint32 opus_cpu_capabilities(void) +static oac_uint32 oac_cpu_capabilities(void) { - opus_uint32 flags = 0; + oac_uint32 flags = 0; -#if defined(OPUS_ARM_MAY_HAVE_DOTPROD) +#if defined(OAC_ARM_MAY_HAVE_DOTPROD) size_t size = sizeof(uint32_t); uint32_t value = 0; if (!sysctlbyname("hw.optional.arm.FEAT_DotProd", &value, &size, NULL, 0) && value) { - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; + flags |= OAC_CPU_ARM_DOTPROD_FLAG; } #endif -#if defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR) - flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG; -# if defined(OPUS_ARM_PRESUME_DOTPROD) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; +#if defined(OAC_ARM_PRESUME_AARCH64_NEON_INTR) + flags |= OAC_CPU_ARM_EDSP_FLAG | OAC_CPU_ARM_MEDIA_FLAG | OAC_CPU_ARM_NEON_FLAG; +# if defined(OAC_ARM_PRESUME_DOTPROD) + flags |= OAC_CPU_ARM_DOTPROD_FLAG; # endif #endif return flags; @@ -194,45 +194,45 @@ static opus_uint32 opus_cpu_capabilities(void) #elif defined(HAVE_ELF_AUX_INFO) #include -static opus_uint32 opus_cpu_capabilities(void) +static oac_uint32 oac_cpu_capabilities(void) { long hwcap = 0; - opus_uint32 flags = 0; + oac_uint32 flags = 0; -# if defined(OPUS_ARM_MAY_HAVE_MEDIA) \ - || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(OAC_ARM_MAY_HAVE_MEDIA) \ + || defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) /* FreeBSD requires armv6+, which always supports media instructions */ - flags |= OPUS_CPU_ARM_MEDIA_FLAG; + flags |= OAC_CPU_ARM_MEDIA_FLAG; # endif elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap); -# if defined(OPUS_ARM_MAY_HAVE_EDSP) || defined(OPUS_ARM_MAY_HAVE_MEDIA) \ - || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(OAC_ARM_MAY_HAVE_EDSP) || defined(OAC_ARM_MAY_HAVE_MEDIA) \ + || defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) # ifdef HWCAP_EDSP if (hwcap & HWCAP_EDSP) - flags |= OPUS_CPU_ARM_EDSP_FLAG; + flags |= OAC_CPU_ARM_EDSP_FLAG; # endif -# if defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) # ifdef HWCAP_NEON if (hwcap & HWCAP_NEON) - flags |= OPUS_CPU_ARM_NEON_FLAG; + flags |= OAC_CPU_ARM_NEON_FLAG; # elif defined(HWCAP_ASIMD) if (hwcap & HWCAP_ASIMD) - flags |= OPUS_CPU_ARM_NEON_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_EDSP_FLAG; + flags |= OAC_CPU_ARM_NEON_FLAG | OAC_CPU_ARM_MEDIA_FLAG | OAC_CPU_ARM_EDSP_FLAG; # endif # endif -# if defined(OPUS_ARM_MAY_HAVE_DOTPROD) && defined(HWCAP_ASIMDDP) +# if defined(OAC_ARM_MAY_HAVE_DOTPROD) && defined(HWCAP_ASIMDDP) if (hwcap & HWCAP_ASIMDDP) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; + flags |= OAC_CPU_ARM_DOTPROD_FLAG; # endif # endif -#if defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR) - flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG; -# if defined(OPUS_ARM_PRESUME_DOTPROD) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; +#if defined(OAC_ARM_PRESUME_AARCH64_NEON_INTR) + flags |= OAC_CPU_ARM_EDSP_FLAG | OAC_CPU_ARM_MEDIA_FLAG | OAC_CPU_ARM_NEON_FLAG; +# if defined(OAC_ARM_PRESUME_DOTPROD) + flags |= OAC_CPU_ARM_DOTPROD_FLAG; # endif #endif @@ -245,11 +245,11 @@ static opus_uint32 opus_cpu_capabilities(void) #include #include -static opus_uint32 opus_cpu_capabilities(void) +static oac_uint32 oac_cpu_capabilities(void) { - opus_uint32 flags = 0; + oac_uint32 flags = 0; -#if defined(OPUS_ARM_MAY_HAVE_DOTPROD) && defined(CPU_ID_AA64ISAR0) +#if defined(OAC_ARM_MAY_HAVE_DOTPROD) && defined(CPU_ID_AA64ISAR0) const int isar0_mib[] = { CTL_MACHDEP, CPU_ID_AA64ISAR0 }; uint64_t isar0; size_t len = sizeof(isar0); @@ -257,15 +257,15 @@ static opus_uint32 opus_cpu_capabilities(void) if (sysctl(isar0_mib, 2, &isar0, &len, NULL, 0) != -1) { if (ID_AA64ISAR0_DP(isar0) >= ID_AA64ISAR0_DP_IMPL) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; + flags |= OAC_CPU_ARM_DOTPROD_FLAG; } #endif -#if defined(OPUS_ARM_PRESUME_NEON_INTR) \ - || defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR) - flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG; -# if defined(OPUS_ARM_PRESUME_DOTPROD) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; +#if defined(OAC_ARM_PRESUME_NEON_INTR) \ + || defined(OAC_ARM_PRESUME_AARCH64_NEON_INTR) + flags |= OAC_CPU_ARM_EDSP_FLAG | OAC_CPU_ARM_MEDIA_FLAG | OAC_CPU_ARM_NEON_FLAG; +# if defined(OAC_ARM_PRESUME_DOTPROD) + flags |= OAC_CPU_ARM_DOTPROD_FLAG; # endif #endif return flags; @@ -279,42 +279,42 @@ static opus_uint32 opus_cpu_capabilities(void) "your platform. Reconfigure with --disable-rtcd (or send patches)." #endif -static int opus_select_arch_impl(void) +static int oac_select_arch_impl(void) { - opus_uint32 flags = opus_cpu_capabilities(); + oac_uint32 flags = oac_cpu_capabilities(); int arch = 0; - if(!(flags & OPUS_CPU_ARM_EDSP_FLAG)) { + if(!(flags & OAC_CPU_ARM_EDSP_FLAG)) { /* Asserts ensure arch values are sequential */ - celt_assert(arch == OPUS_ARCH_ARM_V4); + celt_assert(arch == OAC_ARCH_ARM_V4); return arch; } arch++; - if(!(flags & OPUS_CPU_ARM_MEDIA_FLAG)) { - celt_assert(arch == OPUS_ARCH_ARM_EDSP); + if(!(flags & OAC_CPU_ARM_MEDIA_FLAG)) { + celt_assert(arch == OAC_ARCH_ARM_EDSP); return arch; } arch++; - if(!(flags & OPUS_CPU_ARM_NEON_FLAG)) { - celt_assert(arch == OPUS_ARCH_ARM_MEDIA); + if(!(flags & OAC_CPU_ARM_NEON_FLAG)) { + celt_assert(arch == OAC_ARCH_ARM_MEDIA); return arch; } arch++; - if(!(flags & OPUS_CPU_ARM_DOTPROD_FLAG)) { - celt_assert(arch == OPUS_ARCH_ARM_NEON); + if(!(flags & OAC_CPU_ARM_DOTPROD_FLAG)) { + celt_assert(arch == OAC_ARCH_ARM_NEON); return arch; } arch++; - celt_assert(arch == OPUS_ARCH_ARM_DOTPROD); + celt_assert(arch == OAC_ARCH_ARM_DOTPROD); return arch; } -int opus_select_arch(void) { - int arch = opus_select_arch_impl(); +int oac_select_arch(void) { + int arch = oac_select_arch_impl(); #ifdef FUZZING arch = rand()%(arch+1); #endif diff --git a/celt/arm/armcpu.h b/celt/arm/armcpu.h index 6d5803d81..5d5e8b640 100644 --- a/celt/arm/armcpu.h +++ b/celt/arm/armcpu.h @@ -28,62 +28,62 @@ #if !defined(ARMCPU_H) # define ARMCPU_H -# if defined(OPUS_ARM_MAY_HAVE_EDSP) +# if defined(OAC_ARM_MAY_HAVE_EDSP) # define MAY_HAVE_EDSP(name) name ## _edsp # else # define MAY_HAVE_EDSP(name) name ## _c # endif -# if defined(OPUS_ARM_MAY_HAVE_MEDIA) +# if defined(OAC_ARM_MAY_HAVE_MEDIA) # define MAY_HAVE_MEDIA(name) name ## _media # else # define MAY_HAVE_MEDIA(name) MAY_HAVE_EDSP(name) # endif -# if defined(OPUS_ARM_MAY_HAVE_NEON) +# if defined(OAC_ARM_MAY_HAVE_NEON) # define MAY_HAVE_NEON(name) name ## _neon # else # define MAY_HAVE_NEON(name) MAY_HAVE_MEDIA(name) # endif -# if defined(OPUS_ARM_MAY_HAVE_DOTPROD) +# if defined(OAC_ARM_MAY_HAVE_DOTPROD) # define MAY_HAVE_DOTPROD(name) name ## _dotprod # else # define MAY_HAVE_DOTPROD(name) MAY_HAVE_NEON(name) # endif -# if defined(OPUS_ARM_PRESUME_EDSP) +# if defined(OAC_ARM_PRESUME_EDSP) # define PRESUME_EDSP(name) name ## _edsp # else # define PRESUME_EDSP(name) name ## _c # endif -# if defined(OPUS_ARM_PRESUME_MEDIA) +# if defined(OAC_ARM_PRESUME_MEDIA) # define PRESUME_MEDIA(name) name ## _media # else # define PRESUME_MEDIA(name) PRESUME_EDSP(name) # endif -# if defined(OPUS_ARM_PRESUME_NEON) +# if defined(OAC_ARM_PRESUME_NEON) # define PRESUME_NEON(name) name ## _neon # else # define PRESUME_NEON(name) PRESUME_MEDIA(name) # endif -# if defined(OPUS_ARM_PRESUME_DOTPROD) +# if defined(OAC_ARM_PRESUME_DOTPROD) # define PRESUME_DOTPROD(name) name ## _dotprod # else # define PRESUME_DOTPROD(name) PRESUME_NEON(name) # endif -# if defined(OPUS_HAVE_RTCD) -int opus_select_arch(void); +# if defined(OAC_HAVE_RTCD) +int oac_select_arch(void); -#define OPUS_ARCH_ARM_V4 (0) -#define OPUS_ARCH_ARM_EDSP (1) -#define OPUS_ARCH_ARM_MEDIA (2) -#define OPUS_ARCH_ARM_NEON (3) -#define OPUS_ARCH_ARM_DOTPROD (4) +#define OAC_ARCH_ARM_V4 (0) +#define OAC_ARCH_ARM_EDSP (1) +#define OAC_ARCH_ARM_MEDIA (2) +#define OAC_ARCH_ARM_NEON (3) +#define OAC_ARCH_ARM_DOTPROD (4) # endif diff --git a/celt/arm/armopts.s.in b/celt/arm/armopts.s.in index 3d8aaf275..acb744bca 100644 --- a/celt/arm/armopts.s.in +++ b/celt/arm/armopts.s.in @@ -26,12 +26,12 @@ ; Set the following to 1 if we have EDSP instructions ; (LDRD/STRD, etc., ARMv5E and later). -OPUS_ARM_MAY_HAVE_EDSP * @OPUS_ARM_MAY_HAVE_EDSP@ +OAC_ARM_MAY_HAVE_EDSP * @OAC_ARM_MAY_HAVE_EDSP@ ; Set the following to 1 if we have ARMv6 media instructions. -OPUS_ARM_MAY_HAVE_MEDIA * @OPUS_ARM_MAY_HAVE_MEDIA@ +OAC_ARM_MAY_HAVE_MEDIA * @OAC_ARM_MAY_HAVE_MEDIA@ ; Set the following to 1 if we have NEON (some ARMv7) -OPUS_ARM_MAY_HAVE_NEON * @OPUS_ARM_MAY_HAVE_NEON@ +OAC_ARM_MAY_HAVE_NEON * @OAC_ARM_MAY_HAVE_NEON@ END diff --git a/celt/arm/celt_fft_ne10.c b/celt/arm/celt_fft_ne10.c index ea5fd7808..cdfeaacc3 100644 --- a/celt/arm/celt_fft_ne10.c +++ b/celt/arm/celt_fft_ne10.c @@ -66,12 +66,12 @@ static const int ne10_fft_scaled_support[NE10_FFTSCALED_SUPPORT_MAX] = { 480, 240, 120, 60 }; -int opus_fft_alloc_arm_neon(kiss_fft_state *st) +int oac_fft_alloc_arm_neon(kiss_fft_state *st) { int i; size_t memneeded = sizeof(struct arch_fft_state); - st->arch_fft = (arch_fft_state *)opus_alloc(memneeded); + st->arch_fft = (arch_fft_state *)oac_alloc(memneeded); if (!st->arch_fft) return -1; @@ -94,7 +94,7 @@ int opus_fft_alloc_arm_neon(kiss_fft_state *st) return 0; } -void opus_fft_free_arm_neon(kiss_fft_state *st) +void oac_fft_free_arm_neon(kiss_fft_state *st) { NE10_FFT_CFG_TYPE_T cfg; @@ -104,11 +104,11 @@ void opus_fft_free_arm_neon(kiss_fft_state *st) cfg = (NE10_FFT_CFG_TYPE_T)st->arch_fft->priv; if (cfg) NE10_FFT_DESTROY_C2C_TYPE(cfg); - opus_free(st->arch_fft); + oac_free(st->arch_fft); } #endif -void opus_fft_neon(const kiss_fft_state *st, +void oac_fft_neon(const kiss_fft_state *st, const kiss_fft_cpx *fin, kiss_fft_cpx *fout) { @@ -120,7 +120,7 @@ void opus_fft_neon(const kiss_fft_state *st, if (!st->arch_fft->is_supported) { /* This nfft length (scaled fft) not supported in NE10 */ - opus_fft_c(st, fin, fout); + oac_fft_c(st, fin, fout); } else { memcpy((void *)cfg, st->arch_fft->priv, sizeof(NE10_FFT_STATE_TYPE_T)); @@ -140,7 +140,7 @@ void opus_fft_neon(const kiss_fft_state *st, RESTORE_STACK; } -void opus_ifft_neon(const kiss_fft_state *st, +void oac_ifft_neon(const kiss_fft_state *st, const kiss_fft_cpx *fin, kiss_fft_cpx *fout) { @@ -152,7 +152,7 @@ void opus_ifft_neon(const kiss_fft_state *st, if (!st->arch_fft->is_supported) { /* This nfft length (scaled fft) not supported in NE10 */ - opus_ifft_c(st, fin, fout); + oac_ifft_c(st, fin, fout); } else { memcpy((void *)cfg, st->arch_fft->priv, sizeof(NE10_FFT_STATE_TYPE_T)); diff --git a/celt/arm/celt_mdct_ne10.c b/celt/arm/celt_mdct_ne10.c index 3531d02d1..6cbbeef97 100644 --- a/celt/arm/celt_mdct_ne10.c +++ b/celt/arm/celt_mdct_ne10.c @@ -43,8 +43,8 @@ void clt_mdct_forward_neon(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 *window, + kiss_fft_scalar * OAC_RESTRICT out, + const oac_val16 *window, int overlap, int shift, int stride, int arch) { int i; @@ -73,11 +73,11 @@ void clt_mdct_forward_neon(const mdct_lookup *l, /* Window, shuffle, fold */ { /* Temp pointers to make it really clear to the compiler what we're doing */ - const kiss_fft_scalar * OPUS_RESTRICT xp1 = in+(overlap>>1); - const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+N2-1+(overlap>>1); - kiss_fft_scalar * OPUS_RESTRICT yp = f; - const opus_val16 * OPUS_RESTRICT wp1 = window+(overlap>>1); - const opus_val16 * OPUS_RESTRICT wp2 = window+(overlap>>1)-1; + const kiss_fft_scalar * OAC_RESTRICT xp1 = in+(overlap>>1); + const kiss_fft_scalar * OAC_RESTRICT xp2 = in+N2-1+(overlap>>1); + kiss_fft_scalar * OAC_RESTRICT yp = f; + const oac_val16 * OAC_RESTRICT wp1 = window+(overlap>>1); + const oac_val16 * OAC_RESTRICT wp2 = window+(overlap>>1)-1; for(i=0;i<((overlap+3)>>2);i++) { /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ @@ -111,7 +111,7 @@ void clt_mdct_forward_neon(const mdct_lookup *l, } /* Pre-rotation */ { - kiss_fft_scalar * OPUS_RESTRICT yp = f; + kiss_fft_scalar * OAC_RESTRICT yp = f; const kiss_twiddle_scalar *t = &trig[0]; for(i=0;i>1)), arch); + oac_ifft(st, (kiss_fft_cpx *)f, (kiss_fft_cpx*)(out+(overlap>>1)), arch); /* Post-rotate and de-shuffle from both ends of the buffer at once to make it in-place. */ @@ -238,10 +238,10 @@ void clt_mdct_backward_neon(const mdct_lookup *l, /* Mirror on both sides for TDAC */ { - kiss_fft_scalar * OPUS_RESTRICT xp1 = out+overlap-1; - kiss_fft_scalar * OPUS_RESTRICT yp1 = out; - const opus_val16 * OPUS_RESTRICT wp1 = window; - const opus_val16 * OPUS_RESTRICT wp2 = window+overlap-1; + kiss_fft_scalar * OAC_RESTRICT xp1 = out+overlap-1; + kiss_fft_scalar * OAC_RESTRICT yp1 = out; + const oac_val16 * OAC_RESTRICT wp1 = window; + const oac_val16 * OAC_RESTRICT wp2 = window+overlap-1; for(i = 0; i < overlap/2; i++) { diff --git a/celt/arm/celt_neon_intr.c b/celt/arm/celt_neon_intr.c index 69b90d7dc..56d66a289 100644 --- a/celt/arm/celt_neon_intr.c +++ b/celt/arm/celt_neon_intr.c @@ -40,13 +40,13 @@ #include "../mathops.h" #include "../pitch.h" #include -#if defined(OPUS_CHECK_ASM) +#if defined(OAC_CHECK_ASM) #include #endif -#if !defined(DISABLE_FLOAT_API) && defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +#if !defined(DISABLE_FLOAT_API) && defined(OAC_ARM_MAY_HAVE_NEON_INTR) -void celt_float2int16_neon(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt) +void celt_float2int16_neon(const float * OAC_RESTRICT in, short * OAC_RESTRICT out, int cnt) { int i = 0; @@ -70,7 +70,7 @@ void celt_float2int16_neon(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT vst1_s16(&out[i + 4], asShort_b); vst1_s16(&out[i + 8], asShort_c); vst1_s16(&out[i + 12], asShort_d); -# if defined(OPUS_CHECK_ASM) +# if defined(OAC_CHECK_ASM) short out_c[BLOCK_SIZE]; int j; for(j = 0; j < BLOCK_SIZE; j++) @@ -88,7 +88,7 @@ void celt_float2int16_neon(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT } } -int opus_limit2_checkwithin1_neon(float *samples, int cnt) +int oac_limit2_checkwithin1_neon(float *samples, int cnt) { const float hardclipMin = -2.0f; const float hardclipMax = 2.0f; @@ -169,7 +169,7 @@ int opus_limit2_checkwithin1_neon(float *samples, int cnt) #if defined(FIXED_POINT) #include -void xcorr_kernel_neon_fixed(const opus_val16 * x, const opus_val16 * y, opus_val32 sum[4], int len) +void xcorr_kernel_neon_fixed(const oac_val16 * x, const oac_val16 * y, oac_val32 sum[4], int len) { int j; int32x4_t a = vld1q_s32(sum); @@ -381,8 +381,8 @@ static void xcorr_kernel_neon_float(const float32_t *x, const float32_t *y, vst1q_f32(sum, SUMM); } -void celt_pitch_xcorr_float_neon(const opus_val16 *_x, const opus_val16 *_y, - opus_val32 *xcorr, int len, int max_pitch, int arch) { +void celt_pitch_xcorr_float_neon(const oac_val16 *_x, const oac_val16 *_y, + oac_val32 *xcorr, int len, int max_pitch, int arch) { int i; (void)arch; celt_assert(max_pitch > 0); diff --git a/celt/arm/celt_pitch_xcorr_arm.s b/celt/arm/celt_pitch_xcorr_arm.s index 65a4461ff..41c9fa18f 100644 --- a/celt/arm/celt_pitch_xcorr_arm.s +++ b/celt/arm/celt_pitch_xcorr_arm.s @@ -30,26 +30,26 @@ GET celt/arm/armopts.s -IF OPUS_ARM_MAY_HAVE_EDSP +IF OAC_ARM_MAY_HAVE_EDSP EXPORT celt_pitch_xcorr_edsp ENDIF -IF OPUS_ARM_MAY_HAVE_NEON +IF OAC_ARM_MAY_HAVE_NEON EXPORT celt_pitch_xcorr_neon ENDIF -IF OPUS_ARM_MAY_HAVE_NEON +IF OAC_ARM_MAY_HAVE_NEON ; Compute sum[k]=sum(x[j]*y[j+k],j=0...len-1), k=0...3 xcorr_kernel_neon PROC xcorr_kernel_neon_start ; input: ; r3 = int len - ; r4 = opus_val16 *x - ; r5 = opus_val16 *y - ; q0 = opus_val32 sum[4] + ; r4 = oac_val16 *x + ; r5 = oac_val16 *y + ; q0 = oac_val32 sum[4] ; output: - ; q0 = opus_val32 sum[4] + ; q0 = oac_val32 sum[4] ; preserved: r0-r3, r6-r11, d2, q4-q7, q9-q15 ; internal usage: ; r12 = int j @@ -152,19 +152,19 @@ xcorr_kernel_neon_process1 MOV pc, lr ENDP -; opus_val32 celt_pitch_xcorr_neon(opus_val16 *_x, opus_val16 *_y, -; opus_val32 *xcorr, int len, int max_pitch, int arch) +; oac_val32 celt_pitch_xcorr_neon(oac_val16 *_x, oac_val16 *_y, +; oac_val32 *xcorr, int len, int max_pitch, int arch) celt_pitch_xcorr_neon PROC ; input: - ; r0 = opus_val16 *_x - ; r1 = opus_val16 *_y - ; r2 = opus_val32 *xcorr + ; r0 = oac_val16 *_x + ; r1 = oac_val16 *_y + ; r2 = oac_val32 *xcorr ; r3 = int len ; output: ; r0 = int maxcorr ; internal usage: - ; r4 = opus_val16 *x (for xcorr_kernel_neon()) - ; r5 = opus_val16 *y (for xcorr_kernel_neon()) + ; r4 = oac_val16 *x (for xcorr_kernel_neon()) + ; r5 = oac_val16 *y (for xcorr_kernel_neon()) ; r6 = int max_pitch ; r12 = int j ; q15 = int maxcorr[4] (q15 is not used by xcorr_kernel_neon()) @@ -255,7 +255,7 @@ celt_pitch_xcorr_neon_done ENDIF -IF OPUS_ARM_MAY_HAVE_EDSP +IF OAC_ARM_MAY_HAVE_EDSP ; This will get used on ARMv7 devices without NEON, so it has been optimized ; to take advantage of dual-issuing where possible. @@ -263,16 +263,16 @@ xcorr_kernel_edsp PROC xcorr_kernel_edsp_start ; input: ; r3 = int len - ; r4 = opus_val16 *_x (must be 32-bit aligned) - ; r5 = opus_val16 *_y (must be 32-bit aligned) - ; r6...r9 = opus_val32 sum[4] + ; r4 = oac_val16 *_x (must be 32-bit aligned) + ; r5 = oac_val16 *_y (must be 32-bit aligned) + ; r6...r9 = oac_val32 sum[4] ; output: - ; r6...r9 = opus_val32 sum[4] + ; r6...r9 = oac_val32 sum[4] ; preserved: r0-r5 ; internal usage ; r2 = int j - ; r12,r14 = opus_val16 x[4] - ; r10,r11 = opus_val16 y[4] + ; r12,r14 = oac_val16 x[4] + ; r10,r11 = oac_val16 y[4] STMFD sp!, {r2,r4,r5,lr} LDR r10, [r5], #4 ; Load y[0...1] SUBS r2, r3, #4 ; j = len-4 @@ -345,19 +345,19 @@ xcorr_kernel_edsp_done celt_pitch_xcorr_edsp PROC ; input: - ; r0 = opus_val16 *_x (must be 32-bit aligned) - ; r1 = opus_val16 *_y (only needs to be 16-bit aligned) - ; r2 = opus_val32 *xcorr + ; r0 = oac_val16 *_x (must be 32-bit aligned) + ; r1 = oac_val16 *_y (only needs to be 16-bit aligned) + ; r2 = oac_val32 *xcorr ; r3 = int len ; output: ; r0 = maxcorr ; internal usage - ; r4 = opus_val16 *x - ; r5 = opus_val16 *y - ; r6 = opus_val32 sum0 - ; r7 = opus_val32 sum1 - ; r8 = opus_val32 sum2 - ; r9 = opus_val32 sum3 + ; r4 = oac_val16 *x + ; r5 = oac_val16 *y + ; r6 = oac_val32 sum0 + ; r7 = oac_val32 sum1 + ; r8 = oac_val32 sum2 + ; r9 = oac_val32 sum3 ; r1 = int max_pitch ; r12 = int j ; ignored: diff --git a/celt/arm/fft_arm.h b/celt/arm/fft_arm.h index 0b78175f3..55eb14aac 100644 --- a/celt/arm/fft_arm.h +++ b/celt/arm/fft_arm.h @@ -38,33 +38,33 @@ #if defined(HAVE_ARM_NE10) -int opus_fft_alloc_arm_neon(kiss_fft_state *st); -void opus_fft_free_arm_neon(kiss_fft_state *st); +int oac_fft_alloc_arm_neon(kiss_fft_state *st); +void oac_fft_free_arm_neon(kiss_fft_state *st); -void opus_fft_neon(const kiss_fft_state *st, +void oac_fft_neon(const kiss_fft_state *st, const kiss_fft_cpx *fin, kiss_fft_cpx *fout); -void opus_ifft_neon(const kiss_fft_state *st, +void oac_ifft_neon(const kiss_fft_state *st, const kiss_fft_cpx *fin, kiss_fft_cpx *fout); -#if !defined(OPUS_HAVE_RTCD) -#define OVERRIDE_OPUS_FFT (1) +#if !defined(OAC_HAVE_RTCD) +#define OVERRIDE_OAC_FFT (1) -#define opus_fft_alloc_arch(_st, arch) \ - ((void)(arch), opus_fft_alloc_arm_neon(_st)) +#define oac_fft_alloc_arch(_st, arch) \ + ((void)(arch), oac_fft_alloc_arm_neon(_st)) -#define opus_fft_free_arch(_st, arch) \ - ((void)(arch), opus_fft_free_arm_neon(_st)) +#define oac_fft_free_arch(_st, arch) \ + ((void)(arch), oac_fft_free_arm_neon(_st)) -#define opus_fft(_st, _fin, _fout, arch) \ - ((void)(arch), opus_fft_neon(_st, _fin, _fout)) +#define oac_fft(_st, _fin, _fout, arch) \ + ((void)(arch), oac_fft_neon(_st, _fin, _fout)) -#define opus_ifft(_st, _fin, _fout, arch) \ - ((void)(arch), opus_ifft_neon(_st, _fin, _fout)) +#define oac_ifft(_st, _fin, _fout, arch) \ + ((void)(arch), oac_ifft_neon(_st, _fin, _fout)) -#endif /* OPUS_HAVE_RTCD */ +#endif /* OAC_HAVE_RTCD */ #endif /* HAVE_ARM_NE10 */ diff --git a/celt/arm/fixed_armv4.h b/celt/arm/fixed_armv4.h index d84888a77..0dfe5e6a3 100644 --- a/celt/arm/fixed_armv4.h +++ b/celt/arm/fixed_armv4.h @@ -29,7 +29,7 @@ /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ #undef MULT16_32_Q16 -static OPUS_INLINE opus_val32 MULT16_32_Q16_armv4(opus_val16 a, opus_val32 b) +static OAC_INLINE oac_val32 MULT16_32_Q16_armv4(oac_val16 a, oac_val32 b) { unsigned rd_lo; int rd_hi; @@ -46,7 +46,7 @@ static OPUS_INLINE opus_val32 MULT16_32_Q16_armv4(opus_val16 a, opus_val32 b) /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ #undef MULT16_32_Q15 -static OPUS_INLINE opus_val32 MULT16_32_Q15_armv4(opus_val16 a, opus_val32 b) +static OAC_INLINE oac_val32 MULT16_32_Q15_armv4(oac_val16 a, oac_val32 b) { unsigned rd_lo; int rd_hi; @@ -75,6 +75,6 @@ static OPUS_INLINE opus_val32 MULT16_32_Q15_armv4(opus_val16 a, opus_val32 b) /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ #undef MULT32_32_Q31 -#define MULT32_32_Q31(a,b) (opus_val32)((((opus_int64)(a)) * ((opus_int64)(b)))>>31) +#define MULT32_32_Q31(a,b) (oac_val32)((((oac_int64)(a)) * ((oac_int64)(b)))>>31) #endif diff --git a/celt/arm/fixed_armv5e.h b/celt/arm/fixed_armv5e.h index 6bf73cbac..c68a18d80 100644 --- a/celt/arm/fixed_armv5e.h +++ b/celt/arm/fixed_armv5e.h @@ -34,7 +34,7 @@ /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ #undef MULT16_32_Q16 -static OPUS_INLINE opus_val32 MULT16_32_Q16_armv5e(opus_val16 a, opus_val32 b) +static OAC_INLINE oac_val32 MULT16_32_Q16_armv5e(oac_val16 a, oac_val32 b) { int res; __asm__( @@ -50,7 +50,7 @@ static OPUS_INLINE opus_val32 MULT16_32_Q16_armv5e(opus_val16 a, opus_val32 b) /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ #undef MULT16_32_Q15 -static OPUS_INLINE opus_val32 MULT16_32_Q15_armv5e(opus_val16 a, opus_val32 b) +static OAC_INLINE oac_val32 MULT16_32_Q15_armv5e(oac_val16 a, oac_val32 b) { int res; __asm__( @@ -68,8 +68,8 @@ static OPUS_INLINE opus_val32 MULT16_32_Q15_armv5e(opus_val16 a, opus_val32 b) b must fit in 31 bits. Result fits in 32 bits. */ #undef MAC16_32_Q15 -static OPUS_INLINE opus_val32 MAC16_32_Q15_armv5e(opus_val32 c, opus_val16 a, - opus_val32 b) +static OAC_INLINE oac_val32 MAC16_32_Q15_armv5e(oac_val32 c, oac_val16 a, + oac_val32 b) { int res; __asm__( @@ -85,8 +85,8 @@ static OPUS_INLINE opus_val32 MAC16_32_Q15_armv5e(opus_val32 c, opus_val16 a, /** 16x32 multiply, followed by a 16-bit shift right and 32-bit add. Result fits in 32 bits. */ #undef MAC16_32_Q16 -static OPUS_INLINE opus_val32 MAC16_32_Q16_armv5e(opus_val32 c, opus_val16 a, - opus_val32 b) +static OAC_INLINE oac_val32 MAC16_32_Q16_armv5e(oac_val32 c, oac_val16 a, + oac_val32 b) { int res; __asm__( @@ -101,8 +101,8 @@ static OPUS_INLINE opus_val32 MAC16_32_Q16_armv5e(opus_val32 c, opus_val16 a, /** 16x16 multiply-add where the result fits in 32 bits */ #undef MAC16_16 -static OPUS_INLINE opus_val32 MAC16_16_armv5e(opus_val32 c, opus_val16 a, - opus_val16 b) +static OAC_INLINE oac_val32 MAC16_16_armv5e(oac_val32 c, oac_val16 a, + oac_val16 b) { int res; __asm__( @@ -117,7 +117,7 @@ static OPUS_INLINE opus_val32 MAC16_16_armv5e(opus_val32 c, opus_val16 a, /** 16x16 multiplication where the result fits in 32 bits */ #undef MULT16_16 -static OPUS_INLINE opus_val32 MULT16_16_armv5e(opus_val16 a, opus_val16 b) +static OAC_INLINE oac_val32 MULT16_16_armv5e(oac_val16 a, oac_val16 b) { int res; __asm__( @@ -130,10 +130,10 @@ static OPUS_INLINE opus_val32 MULT16_16_armv5e(opus_val16 a, opus_val16 b) } #define MULT16_16(a, b) (MULT16_16_armv5e(a, b)) -#ifdef OPUS_ARM_INLINE_MEDIA +#ifdef OAC_ARM_INLINE_MEDIA #undef SIG2WORD16 -static OPUS_INLINE opus_val16 SIG2WORD16_armv6(opus_val32 x) +static OAC_INLINE oac_val16 SIG2WORD16_armv6(oac_val32 x) { celt_sig res; __asm__( @@ -146,6 +146,6 @@ static OPUS_INLINE opus_val16 SIG2WORD16_armv6(opus_val32 x) } #define SIG2WORD16(x) (SIG2WORD16_armv6(x)) -#endif /* OPUS_ARM_INLINE_MEDIA */ +#endif /* OAC_ARM_INLINE_MEDIA */ #endif diff --git a/celt/arm/mathops_arm.h b/celt/arm/mathops_arm.h index b1f916997..22a9cfe86 100644 --- a/celt/arm/mathops_arm.h +++ b/celt/arm/mathops_arm.h @@ -29,9 +29,9 @@ #include "armcpu.h" #include "cpu_support.h" -#include "opus_defines.h" +#include "oac_defines.h" -# if !defined(DISABLE_FLOAT_API) && defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if !defined(DISABLE_FLOAT_API) && defined(OAC_ARM_MAY_HAVE_NEON_INTR) #include @@ -70,33 +70,33 @@ static inline float vmaxvf(float32x4_t a) #endif } -void celt_float2int16_neon(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt); -# if defined(OPUS_HAVE_RTCD) && \ - (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) +void celt_float2int16_neon(const float * OAC_RESTRICT in, short * OAC_RESTRICT out, int cnt); +# if defined(OAC_HAVE_RTCD) && \ + (defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR)) extern void -(*const CELT_FLOAT2INT16_IMPL[OPUS_ARCHMASK+1])(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt); +(*const CELT_FLOAT2INT16_IMPL[OAC_ARCHMASK+1])(const float * OAC_RESTRICT in, short * OAC_RESTRICT out, int cnt); # define OVERRIDE_FLOAT2INT16 (1) # define celt_float2int16(in, out, cnt, arch) \ - ((*CELT_FLOAT2INT16_IMPL[(arch)&OPUS_ARCHMASK])(in, out, cnt)) + ((*CELT_FLOAT2INT16_IMPL[(arch)&OAC_ARCHMASK])(in, out, cnt)) -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) +# elif defined(OAC_ARM_PRESUME_NEON_INTR) # define OVERRIDE_FLOAT2INT16 (1) # define celt_float2int16(in, out, cnt, arch) ((void)(arch), celt_float2int16_neon(in, out, cnt)) # endif -int opus_limit2_checkwithin1_neon(float * samples, int cnt); -# if defined(OPUS_HAVE_RTCD) && \ - (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) -extern int (*const OPUS_LIMIT2_CHECKWITHIN1_IMPL[OPUS_ARCHMASK+1])(float * samples, int cnt); +int oac_limit2_checkwithin1_neon(float * samples, int cnt); +# if defined(OAC_HAVE_RTCD) && \ + (defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR)) +extern int (*const OAC_LIMIT2_CHECKWITHIN1_IMPL[OAC_ARCHMASK+1])(float * samples, int cnt); # define OVERRIDE_LIMIT2_CHECKWITHIN1 (1) -# define opus_limit2_checkwithin1(samples, cnt, arch) \ - ((*OPUS_LIMIT2_CHECKWITHIN1_IMPL[(arch)&OPUS_ARCHMASK])(samples, cnt)) +# define oac_limit2_checkwithin1(samples, cnt, arch) \ + ((*OAC_LIMIT2_CHECKWITHIN1_IMPL[(arch)&OAC_ARCHMASK])(samples, cnt)) -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) +# elif defined(OAC_ARM_PRESUME_NEON_INTR) # define OVERRIDE_LIMIT2_CHECKWITHIN1 (1) -# define opus_limit2_checkwithin1(samples, cnt, arch) ((void)(arch), opus_limit2_checkwithin1_neon(samples, cnt)) +# define oac_limit2_checkwithin1(samples, cnt, arch) ((void)(arch), oac_limit2_checkwithin1_neon(samples, cnt)) # endif # endif diff --git a/celt/arm/mdct_arm.h b/celt/arm/mdct_arm.h index 14200bac4..15fd58e3d 100644 --- a/celt/arm/mdct_arm.h +++ b/celt/arm/mdct_arm.h @@ -38,22 +38,22 @@ #if defined(HAVE_ARM_NE10) /** Compute a forward MDCT and scale by 4/N, trashes the input array */ void clt_mdct_forward_neon(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 *window, int overlap, + kiss_fft_scalar * OAC_RESTRICT out, + const oac_val16 *window, int overlap, int shift, int stride, int arch); void clt_mdct_backward_neon(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 *window, int overlap, + kiss_fft_scalar * OAC_RESTRICT out, + const oac_val16 *window, int overlap, int shift, int stride, int arch); -#if !defined(OPUS_HAVE_RTCD) -#define OVERRIDE_OPUS_MDCT (1) +#if !defined(OAC_HAVE_RTCD) +#define OVERRIDE_OAC_MDCT (1) #define clt_mdct_forward(_l, _in, _out, _window, _int, _shift, _stride, _arch) \ clt_mdct_forward_neon(_l, _in, _out, _window, _int, _shift, _stride, _arch) #define clt_mdct_backward(_l, _in, _out, _window, _int, _shift, _stride, _arch) \ clt_mdct_backward_neon(_l, _in, _out, _window, _int, _shift, _stride, _arch) -#endif /* OPUS_HAVE_RTCD */ +#endif /* OAC_HAVE_RTCD */ #endif /* HAVE_ARM_NE10 */ #endif diff --git a/celt/arm/meson.build b/celt/arm/meson.build index b4dec564f..f77b7896f 100644 --- a/celt/arm/meson.build +++ b/celt/arm/meson.build @@ -5,7 +5,7 @@ celt_sources_arm_asm = configure_file(input: 'celt_pitch_xcorr_arm.s', capture: true) celt_arm_armopts_s_in = configure_file(input: 'armopts.s.in', output: 'armopts.s', - configuration: opus_conf) + configuration: oac_conf) celt_arm_armopts_s = configure_file(input: [celt_arm_armopts_s_in], output: '@BASENAME@-gnu.S', command: arm2gnu + ['@INPUT@'], diff --git a/celt/arm/pitch_arm.h b/celt/arm/pitch_arm.h index bed8b04ea..0261dd81f 100644 --- a/celt/arm/pitch_arm.h +++ b/celt/arm/pitch_arm.h @@ -30,12 +30,12 @@ # include "armcpu.h" -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N); -void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, - const opus_val16 *y02, int N, opus_val32 *xy1, opus_val32 *xy2); +# if defined(OAC_ARM_MAY_HAVE_NEON_INTR) +oac_val32 celt_inner_prod_neon(const oac_val16 *x, const oac_val16 *y, int N); +void dual_inner_prod_neon(const oac_val16 *x, const oac_val16 *y01, + const oac_val16 *y02, int N, oac_val32 *xy1, oac_val32 *xy2); -# if !defined(OPUS_HAVE_RTCD) && defined(OPUS_ARM_PRESUME_NEON) +# if !defined(OAC_HAVE_RTCD) && defined(OAC_ARM_PRESUME_NEON) # define OVERRIDE_CELT_INNER_PROD (1) # define OVERRIDE_DUAL_INNER_PROD (1) # define celt_inner_prod(x, y, N, arch) ((void)(arch), PRESUME_NEON(celt_inner_prod)(x, y, N)) @@ -44,23 +44,23 @@ void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, # endif # if !defined(OVERRIDE_CELT_INNER_PROD) -# if defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) -extern opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const opus_val16 *y, int N); +# if defined(OAC_HAVE_RTCD) && (defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR)) +extern oac_val32 (*const CELT_INNER_PROD_IMPL[OAC_ARCHMASK+1])(const oac_val16 *x, const oac_val16 *y, int N); # define OVERRIDE_CELT_INNER_PROD (1) -# define celt_inner_prod(x, y, N, arch) ((*CELT_INNER_PROD_IMPL[(arch)&OPUS_ARCHMASK])(x, y, N)) -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) +# define celt_inner_prod(x, y, N, arch) ((*CELT_INNER_PROD_IMPL[(arch)&OAC_ARCHMASK])(x, y, N)) +# elif defined(OAC_ARM_PRESUME_NEON_INTR) # define OVERRIDE_CELT_INNER_PROD (1) # define celt_inner_prod(x, y, N, arch) ((void)(arch), celt_inner_prod_neon(x, y, N)) # endif # endif # if !defined(OVERRIDE_DUAL_INNER_PROD) -# if defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) -extern void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, - const opus_val16 *y01, const opus_val16 *y02, int N, opus_val32 *xy1, opus_val32 *xy2); +# if defined(OAC_HAVE_RTCD) && (defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR)) +extern void (*const DUAL_INNER_PROD_IMPL[OAC_ARCHMASK+1])(const oac_val16 *x, + const oac_val16 *y01, const oac_val16 *y02, int N, oac_val32 *xy1, oac_val32 *xy2); # define OVERRIDE_DUAL_INNER_PROD (1) -# define dual_inner_prod(x, y01, y02, N, xy1, xy2, arch) ((*DUAL_INNER_PROD_IMPL[(arch)&OPUS_ARCHMASK])(x, y01, y02, N, xy1, xy2)) -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) +# define dual_inner_prod(x, y01, y02, N, xy1, xy2, arch) ((*DUAL_INNER_PROD_IMPL[(arch)&OAC_ARCHMASK])(x, y01, y02, N, xy1, xy2)) +# elif defined(OAC_ARM_PRESUME_NEON_INTR) # define OVERRIDE_DUAL_INNER_PROD (1) # define dual_inner_prod(x, y01, y02, N, xy1, xy2, arch) ((void)(arch), dual_inner_prod_neon(x, y01, y02, N, xy1, xy2)) # endif @@ -68,62 +68,62 @@ extern void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, # if defined(FIXED_POINT) -# if defined(OPUS_ARM_MAY_HAVE_NEON) -opus_val32 celt_pitch_xcorr_neon(const opus_val16 *_x, const opus_val16 *_y, - opus_val32 *xcorr, int len, int max_pitch, int arch); +# if defined(OAC_ARM_MAY_HAVE_NEON) +oac_val32 celt_pitch_xcorr_neon(const oac_val16 *_x, const oac_val16 *_y, + oac_val32 *xcorr, int len, int max_pitch, int arch); # endif -# if defined(OPUS_ARM_MAY_HAVE_MEDIA) +# if defined(OAC_ARM_MAY_HAVE_MEDIA) # define celt_pitch_xcorr_media MAY_HAVE_EDSP(celt_pitch_xcorr) # endif -# if defined(OPUS_ARM_MAY_HAVE_EDSP) -opus_val32 celt_pitch_xcorr_edsp(const opus_val16 *_x, const opus_val16 *_y, - opus_val32 *xcorr, int len, int max_pitch, int arch); +# if defined(OAC_ARM_MAY_HAVE_EDSP) +oac_val32 celt_pitch_xcorr_edsp(const oac_val16 *_x, const oac_val16 *_y, + oac_val32 *xcorr, int len, int max_pitch, int arch); # endif -# if defined(OPUS_HAVE_RTCD) && \ - ((defined(OPUS_ARM_MAY_HAVE_NEON) && !defined(OPUS_ARM_PRESUME_NEON)) || \ - (defined(OPUS_ARM_MAY_HAVE_MEDIA) && !defined(OPUS_ARM_PRESUME_MEDIA)) || \ - (defined(OPUS_ARM_MAY_HAVE_EDSP) && !defined(OPUS_ARM_PRESUME_EDSP))) -extern opus_val32 -(*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, - const opus_val16 *, opus_val32 *, int, int, int); +# if defined(OAC_HAVE_RTCD) && \ + ((defined(OAC_ARM_MAY_HAVE_NEON) && !defined(OAC_ARM_PRESUME_NEON)) || \ + (defined(OAC_ARM_MAY_HAVE_MEDIA) && !defined(OAC_ARM_PRESUME_MEDIA)) || \ + (defined(OAC_ARM_MAY_HAVE_EDSP) && !defined(OAC_ARM_PRESUME_EDSP))) +extern oac_val32 +(*const CELT_PITCH_XCORR_IMPL[OAC_ARCHMASK+1])(const oac_val16 *, + const oac_val16 *, oac_val32 *, int, int, int); # define OVERRIDE_PITCH_XCORR (1) # define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \ - ((*CELT_PITCH_XCORR_IMPL[(arch)&OPUS_ARCHMASK])(_x, _y, \ + ((*CELT_PITCH_XCORR_IMPL[(arch)&OAC_ARCHMASK])(_x, _y, \ xcorr, len, max_pitch, arch)) -# elif defined(OPUS_ARM_PRESUME_EDSP) || \ - defined(OPUS_ARM_PRESUME_MEDIA) || \ - defined(OPUS_ARM_PRESUME_NEON) +# elif defined(OAC_ARM_PRESUME_EDSP) || \ + defined(OAC_ARM_PRESUME_MEDIA) || \ + defined(OAC_ARM_PRESUME_NEON) # define OVERRIDE_PITCH_XCORR (1) # define celt_pitch_xcorr (PRESUME_NEON(celt_pitch_xcorr)) # endif -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(OAC_ARM_MAY_HAVE_NEON_INTR) void xcorr_kernel_neon_fixed( - const opus_val16 *x, - const opus_val16 *y, - opus_val32 sum[4], + const oac_val16 *x, + const oac_val16 *y, + oac_val32 sum[4], int len); # endif -# if defined(OPUS_HAVE_RTCD) && \ - (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) +# if defined(OAC_HAVE_RTCD) && \ + (defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR)) -extern void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y, - opus_val32 sum[4], +extern void (*const XCORR_KERNEL_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y, + oac_val32 sum[4], int len); # define OVERRIDE_XCORR_KERNEL (1) # define xcorr_kernel(x, y, sum, len, arch) \ - ((*XCORR_KERNEL_IMPL[(arch) & OPUS_ARCHMASK])(x, y, sum, len)) + ((*XCORR_KERNEL_IMPL[(arch) & OAC_ARCHMASK])(x, y, sum, len)) -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) +# elif defined(OAC_ARM_PRESUME_NEON_INTR) # define OVERRIDE_XCORR_KERNEL (1) # define xcorr_kernel(x, y, sum, len, arch) \ ((void)arch, xcorr_kernel_neon_fixed(x, y, sum, len)) @@ -132,23 +132,23 @@ extern void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( #else /* Start !FIXED_POINT */ /* Float case */ -#if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -void celt_pitch_xcorr_float_neon(const opus_val16 *_x, const opus_val16 *_y, - opus_val32 *xcorr, int len, int max_pitch, int arch); +#if defined(OAC_ARM_MAY_HAVE_NEON_INTR) +void celt_pitch_xcorr_float_neon(const oac_val16 *_x, const oac_val16 *_y, + oac_val32 *xcorr, int len, int max_pitch, int arch); #endif -# if defined(OPUS_HAVE_RTCD) && \ - (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) +# if defined(OAC_HAVE_RTCD) && \ + (defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR)) extern void -(*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, - const opus_val16 *, opus_val32 *, int, int, int); +(*const CELT_PITCH_XCORR_IMPL[OAC_ARCHMASK+1])(const oac_val16 *, + const oac_val16 *, oac_val32 *, int, int, int); # define OVERRIDE_PITCH_XCORR (1) # define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \ - ((*CELT_PITCH_XCORR_IMPL[(arch)&OPUS_ARCHMASK])(_x, _y, \ + ((*CELT_PITCH_XCORR_IMPL[(arch)&OAC_ARCHMASK])(_x, _y, \ xcorr, len, max_pitch, arch)) -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) +# elif defined(OAC_ARM_PRESUME_NEON_INTR) # define OVERRIDE_PITCH_XCORR (1) # define celt_pitch_xcorr celt_pitch_xcorr_float_neon diff --git a/celt/arm/pitch_neon_intr.c b/celt/arm/pitch_neon_intr.c index 43885f528..e63eaf54b 100644 --- a/celt/arm/pitch_neon_intr.c +++ b/celt/arm/pitch_neon_intr.c @@ -34,10 +34,10 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef FIXED_POINT -opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N) +oac_val32 celt_inner_prod_neon(const oac_val16 *x, const oac_val16 *y, int N) { int i; - opus_val32 xy; + oac_val32 xy; int16x8_t x_s16x8, y_s16x8; int32x4_t xy_s32x4 = vdupq_n_s32(0); int64x2_t xy_s64x2; @@ -65,18 +65,18 @@ opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N) xy = MAC16_16(xy, x[i], y[i]); } -#ifdef OPUS_CHECK_ASM +#ifdef OAC_CHECK_ASM celt_assert(celt_inner_prod_c(x, y, N) == xy); #endif return xy; } -void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2) +void dual_inner_prod_neon(const oac_val16 *x, const oac_val16 *y01, const oac_val16 *y02, + int N, oac_val32 *xy1, oac_val32 *xy2) { int i; - opus_val32 xy01, xy02; + oac_val32 xy01, xy02; int16x8_t x_s16x8, y01_s16x8, y02_s16x8; int32x4_t xy01_s32x4 = vdupq_n_s32(0); int32x4_t xy02_s32x4 = vdupq_n_s32(0); @@ -116,9 +116,9 @@ void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus *xy1 = xy01; *xy2 = xy02; -#ifdef OPUS_CHECK_ASM +#ifdef OAC_CHECK_ASM { - opus_val32 xy1_c, xy2_c; + oac_val32 xy1_c, xy2_c; dual_inner_prod_c(x, y01, y02, N, &xy1_c, &xy2_c); celt_assert(xy1_c == *xy1); celt_assert(xy2_c == *xy2); @@ -137,18 +137,18 @@ void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus #endif -#ifdef OPUS_CHECK_ASM +#ifdef OAC_CHECK_ASM /* This part of code simulates floating-point NEON operations. */ /* celt_inner_prod_neon_float_c_simulation() simulates the floating-point */ /* operations of celt_inner_prod_neon(), and both functions should have bit */ /* exact output. */ -static opus_val32 celt_inner_prod_neon_float_c_simulation(const opus_val16 *x, const opus_val16 *y, float *err, int N) +static oac_val32 celt_inner_prod_neon_float_c_simulation(const oac_val16 *x, const oac_val16 *y, float *err, int N) { int i; *err = 0; - opus_val32 xy, xy0 = 0, xy1 = 0, xy2 = 0, xy3 = 0; + oac_val32 xy, xy0 = 0, xy1 = 0, xy2 = 0, xy3 = 0; for (i = 0; i < N - 3; i += 4) { xy0 = MAC16_16(xy0, x[i + 0], y[i + 0]); xy1 = MAC16_16(xy1, x[i + 1], y[i + 1]); @@ -171,21 +171,21 @@ static opus_val32 celt_inner_prod_neon_float_c_simulation(const opus_val16 *x, c /* dual_inner_prod_neon_float_c_simulation() simulates the floating-point */ /* operations of dual_inner_prod_neon(), and both functions should have bit */ /* exact output. */ -static void dual_inner_prod_neon_float_c_simulation(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2, float *err) +static void dual_inner_prod_neon_float_c_simulation(const oac_val16 *x, const oac_val16 *y01, const oac_val16 *y02, + int N, oac_val32 *xy1, oac_val32 *xy2, float *err) { *xy1 = celt_inner_prod_neon_float_c_simulation(x, y01, &err[0], N); *xy2 = celt_inner_prod_neon_float_c_simulation(x, y02, &err[1], N); } -#endif /* OPUS_CHECK_ASM */ +#endif /* OAC_CHECK_ASM */ /* ========================================================================== */ -opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N) +oac_val32 celt_inner_prod_neon(const oac_val16 *x, const oac_val16 *y, int N) { int i; - opus_val32 xy; + oac_val32 xy; float32x4_t xy_f32x4 = vdupq_n_f32(0); float32x2_t xy_f32x2; @@ -214,7 +214,7 @@ opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N) xy = MAC16_16(xy, x[i], y[i]); } -#ifdef OPUS_CHECK_ASM +#ifdef OAC_CHECK_ASM { float err, res; res = celt_inner_prod_neon_float_c_simulation(x, y, &err, N); @@ -226,11 +226,11 @@ opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N) return xy; } -void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2) +void dual_inner_prod_neon(const oac_val16 *x, const oac_val16 *y01, const oac_val16 *y02, + int N, oac_val32 *xy1, oac_val32 *xy2) { int i; - opus_val32 xy01, xy02; + oac_val32 xy01, xy02; float32x4_t xy01_f32x4 = vdupq_n_f32(0); float32x4_t xy02_f32x4 = vdupq_n_f32(0); float32x2_t xy01_f32x2, xy02_f32x2; @@ -272,9 +272,9 @@ void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus *xy1 = xy01; *xy2 = xy02; -#ifdef OPUS_CHECK_ASM +#ifdef OAC_CHECK_ASM { - opus_val32 xy1_c, xy2_c; + oac_val32 xy1_c, xy2_c; float err[2]; dual_inner_prod_neon_float_c_simulation(x, y01, y02, N, &xy1_c, &xy2_c, err); /*if (ABS32(xy1_c - *xy1) > err[0]) fprintf(stderr, "dual1 fail: %g %g %g\n", xy1_c, *xy1, err[0]); diff --git a/celt/bands.c b/celt/bands.c index 0b6190089..588177eff 100644 --- a/celt/bands.c +++ b/celt/bands.c @@ -43,7 +43,7 @@ #include "quant_bands.h" #include "pitch.h" -int hysteresis_decision(opus_val16 val, const opus_val16 *thresholds, const opus_val16 *hysteresis, int N, int prev) +int hysteresis_decision(oac_val16 val, const oac_val16 *thresholds, const oac_val16 *hysteresis, int N, int prev) { int i; for (i=0;i>13; + oac_int32 tmp; + oac_int16 x2; + tmp = (4096+((oac_int32)(x)*(x)))>>13; celt_sig_assert(tmp<=32767); x2 = tmp; x2 = (32767-x2) + FRAC_MUL16(x2, (-7651 + FRAC_MUL16(x2, (8277 + FRAC_MUL16(-626, x2))))); @@ -95,22 +95,22 @@ int bitexact_log2tan(int isin,int icos) void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int LM, int arch) { int i, c, N; - const opus_int16 *eBands = m->eBands; + const oac_int16 *eBands = m->eBands; (void)arch; N = m->shortMdctSize< 0) { int shift = IMAX(0, 30 - celt_ilog2(maxval+(maxval>>14)+1) - ((((m->logN[i]+7)>>BITRES)+LM+1)>>1)); j=eBands[i]<nbEBands] = MAX32(maxval, PSHR32(celt_sqrt32(SHR32(sum,1)), shift)); @@ -122,16 +122,16 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *band } /* Normalise each band such that the energy is one. */ -void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, celt_norm * OPUS_RESTRICT X, const celt_ener *bandE, int end, int C, int M) +void normalise_bands(const CELTMode *m, const celt_sig * OAC_RESTRICT freq, celt_norm * OAC_RESTRICT X, const celt_ener *bandE, int end, int C, int M) { int i, c, N; - const opus_int16 *eBands = m->eBands; + const oac_int16 *eBands = m->eBands; N = M*m->shortMdctSize; c=0; do { i=0; do { int j,shift; - opus_val32 E; - opus_val32 g; + oac_val32 E; + oac_val32 g; E = bandE[i+c*m->nbEBands]; /* For very low energies, we need this to make sure not to prevent energy rounding from blowing up the normalized signal. */ @@ -151,12 +151,12 @@ void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, cel void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int LM, int arch) { int i, c, N; - const opus_int16 *eBands = m->eBands; + const oac_int16 *eBands = m->eBands; N = m->shortMdctSize<nbEBands] = celt_sqrt(sum); /*printf ("%f ", bandE[i+c*m->nbEBands]);*/ @@ -166,16 +166,16 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *band } /* Normalise each band such that the energy is one. */ -void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, celt_norm * OPUS_RESTRICT X, const celt_ener *bandE, int end, int C, int M) +void normalise_bands(const CELTMode *m, const celt_sig * OAC_RESTRICT freq, celt_norm * OAC_RESTRICT X, const celt_ener *bandE, int end, int C, int M) { int i, c, N; - const opus_int16 *eBands = m->eBands; + const oac_int16 *eBands = m->eBands; N = M*m->shortMdctSize; c=0; do { for (i=0;inbEBands]); + oac_val16 g = 1.f/(1e-27f+bandE[i+c*m->nbEBands]); for (j=M*eBands[i];jeBands; + celt_sig * OAC_RESTRICT f; + const celt_norm * OAC_RESTRICT x; + const oac_int16 *eBands = m->eBands; N = M*m->shortMdctSize; bound = M*eBands[end]; if (downsample!=1) @@ -215,14 +215,14 @@ void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X, for (i=start;ieBands[i+1]-m->eBands[i]; @@ -280,7 +280,7 @@ void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_mas thresh32 = SHR32(celt_exp2(-SHL16(depth, 10-BITRES)),1); thresh = MULT16_32_Q15(QCONST16(0.5f, 15), MIN32(32767,thresh32)); { - opus_val32 t; + oac_val32 t; t = N0<>1; t = SHL32(t, (7-shift)<<1); @@ -296,7 +296,7 @@ void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_mas celt_norm *X; celt_glog prev1; celt_glog prev2; - opus_val32 Ediff; + oac_val32 Ediff; celt_norm r; int renormalize=0; prev1 = prev1logE[c*m->nbEBands+i]; @@ -312,7 +312,7 @@ void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_mas #ifdef FIXED_POINT if (Ediff < GCONST(16.f)) { - opus_val32 r32 = SHR32(celt_exp2_db(-Ediff),1); + oac_val32 r32 = SHR32(celt_exp2_db(-Ediff),1); r = 2*MIN16(16383,r32); } else { r = 0; @@ -359,7 +359,7 @@ void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_mas corresponds to some quick-and-dirty perceptual experiments I ran to measure inter-aural masking (there doesn't seem to be any published data on the topic). */ -static void compute_channel_weights(celt_ener Ex, celt_ener Ey, opus_val16 w[2]) +static void compute_channel_weights(celt_ener Ex, celt_ener Ey, oac_val16 w[2]) { celt_ener minE; #ifdef FIXED_POINT @@ -376,13 +376,13 @@ static void compute_channel_weights(celt_ener Ex, celt_ener Ey, opus_val16 w[2]) w[1] = VSHR32(Ey, shift); } -static void intensity_stereo(const CELTMode *m, celt_norm * OPUS_RESTRICT X, const celt_norm * OPUS_RESTRICT Y, const celt_ener *bandE, int bandID, int N) +static void intensity_stereo(const CELTMode *m, celt_norm * OAC_RESTRICT X, const celt_norm * OAC_RESTRICT Y, const celt_ener *bandE, int bandID, int N) { int i = bandID; int j; - opus_val16 a1, a2; - opus_val16 left, right; - opus_val16 norm; + oac_val16 a1, a2; + oac_val16 left, right; + oac_val16 norm; #ifdef FIXED_POINT int shift = celt_zlog2(MAX32(bandE[i], bandE[i+m->nbEBands]))-13; #endif @@ -402,12 +402,12 @@ static void intensity_stereo(const CELTMode *m, celt_norm * OPUS_RESTRICT X, con } } -static void stereo_split(celt_norm * OPUS_RESTRICT X, celt_norm * OPUS_RESTRICT Y, int N) +static void stereo_split(celt_norm * OAC_RESTRICT X, celt_norm * OAC_RESTRICT Y, int N) { int j; for (j=0;jeBands; + const oac_int16 * OAC_RESTRICT eBands = m->eBands; int decision; int hf_sum=0; @@ -488,14 +488,14 @@ int spreading_decision(const CELTMode *m, const celt_norm *X, int *average, { int j, N, tmp=0; int tcount[3] = {0,0,0}; - const celt_norm * OPUS_RESTRICT x = X+M*eBands[i]+c*N0; + const celt_norm * OAC_RESTRICT x = X+M*eBands[i]+c*N0; N = M*(eBands[i+1]-eBands[i]); if (N<=8) continue; /* Compute rough CDF of |x[j]| */ for (j=0;j0); /* end has to be non-zero */ celt_assert(sum>=0); - sum = celt_udiv((opus_int32)sum<<8, nbBands); + sum = celt_udiv((oac_int32)sum<<8, nbBands); /* Recursive averaging */ sum = (sum+*average)>>1; *average = sum; @@ -593,7 +593,7 @@ static void deinterleave_hadamard(celt_norm *X, int N0, int stride, int hadamard for (j=0;jtheta_round == 0) { - itheta = (itheta*(opus_int32)qn+8192)>>14; + itheta = (itheta*(oac_int32)qn+8192)>>14; if (!stereo && ctx->avoid_split_noise && itheta > 0 && itheta < qn) { /* Check if the selected value of theta will cause the bit allocation to inject noise on one side. If so, make sure the energy of that side is zero. */ - int unquantized = celt_udiv((opus_int32)itheta*16384, qn); - imid = bitexact_cos((opus_int16)unquantized); - iside = bitexact_cos((opus_int16)(16384-unquantized)); + int unquantized = celt_udiv((oac_int32)itheta*16384, qn); + imid = bitexact_cos((oac_int16)unquantized); + iside = bitexact_cos((oac_int16)(16384-unquantized)); delta = FRAC_MUL16((N-1)<<7,bitexact_log2tan(iside,imid)); if (delta > *b) itheta = qn; @@ -759,7 +759,7 @@ static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, int down; /* Bias quantization towards itheta=0 and itheta=16384. */ int bias = itheta > 8192 ? 32767/qn : -32767/qn; - down = IMIN(qn-1, IMAX(0, (itheta*(opus_int32)qn + bias)>>14)); + down = IMIN(qn-1, IMAX(0, (itheta*(oac_int32)qn + bias)>>14)); if (ctx->theta_round < 0) itheta = down; else @@ -814,14 +814,14 @@ static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, if (fm < ((qn>>1)*((qn>>1) + 1)>>1)) { - itheta = (isqrt32(8*(opus_uint32)fm + 1) - 1)>>1; + itheta = (isqrt32(8*(oac_uint32)fm + 1) - 1)>>1; fs = itheta + 1; fl = itheta*(itheta + 1)>>1; } else { itheta = (2*(qn + 1) - - isqrt32(8*(opus_uint32)(ft - fm - 1) + 1))>>1; + - isqrt32(8*(oac_uint32)(ft - fm - 1) + 1))>>1; fs = qn + 1 - itheta; fl = ft - ((qn + 1 - itheta)*(qn + 2 - itheta)>>1); } @@ -830,8 +830,8 @@ static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, } } celt_assert(itheta>=0); - itheta = celt_udiv((opus_int32)itheta*16384, qn); - itheta_q30 = (opus_int32)itheta<<16; + itheta = celt_udiv((oac_int32)itheta*16384, qn); + itheta_q30 = (oac_int32)itheta<<16; if (encode && stereo) { if (itheta==0) @@ -883,8 +883,8 @@ static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, *fill &= ((1<>= 1; Y = X+N; @@ -1071,7 +1071,7 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X, fill &= cm_mask; if (!fill) { - OPUS_CLEAR(X, N); + OAC_CLEAR(X, N); } else { if (lowband == NULL) { @@ -1079,14 +1079,14 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X, for (j=0;jseed = celt_lcg_rand(ctx->seed); - X[j] = SHL32((celt_norm)((opus_int32)ctx->seed>>20), NORM_SHIFT-14); + X[j] = SHL32((celt_norm)((oac_int32)ctx->seed>>20), NORM_SHIFT-14); } cm = cm_mask; } else { /* Folded spectrum */ for (j=0;jseed = celt_lcg_rand(ctx->seed); /* About 48 dB below the "normal" folding level */ tmp = QCONST16(1.0f/256, NORM_SHIFT-4); @@ -1104,7 +1104,7 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X, return cm; } -unsigned cubic_quant_partition(struct band_ctx *ctx, celt_norm *X, int N, int b, int B, ec_ctx *ec, int LM, opus_val32 gain, int resynth, int encode) +unsigned cubic_quant_partition(struct band_ctx *ctx, celt_norm *X, int N, int b, int B, ec_ctx *ec, int LM, oac_val32 gain, int resynth, int encode) { celt_assert(LM>=0); ctx->remaining_bits = ctx->ec->storage*8*8 - ec_tell_frac(ctx->ec); @@ -1122,10 +1122,10 @@ unsigned cubic_quant_partition(struct band_ctx *ctx, celt_norm *X, int N, int b, return ret; } else { celt_norm *Y; - opus_int32 itheta_q30; - opus_val32 g1, g2; - opus_int32 theta_res; - opus_int32 qtheta; + oac_int32 itheta_q30; + oac_val32 g1, g2; + oac_int32 theta_res; + oac_int32 qtheta; int delta; int b1, b2; int cm; @@ -1174,7 +1174,7 @@ unsigned cubic_quant_partition(struct band_ctx *ctx, celt_norm *X, int N, int b, static unsigned quant_band(struct band_ctx *ctx, celt_norm *X, int N, int b, int B, celt_norm *lowband, int LM, celt_norm *lowband_out, - opus_val32 gain, celt_norm *lowband_scratch, int fill) + oac_val32 gain, celt_norm *lowband_scratch, int fill) { int N0=N; int N_B=N; @@ -1207,7 +1207,7 @@ static unsigned quant_band(struct band_ctx *ctx, celt_norm *X, if (lowband_scratch && lowband && (recombine || ((N_B&1) == 0 && tf_change<0) || B0>1)) { - OPUS_COPY(lowband_scratch, lowband, N); + OAC_COPY(lowband_scratch, lowband, N); lowband = lowband_scratch; } @@ -1285,7 +1285,7 @@ static unsigned quant_band(struct band_ctx *ctx, celt_norm *X, if (lowband_out) { int j; - opus_val16 n; + oac_val16 n; n = celt_sqrt(SHL32(EXTEND32(N0),22)); for (j=0;jbandE[ctx->i] < MIN_STEREO_ENERGY || ctx->bandE[ctx->m->nbEBands+ctx->i] < MIN_STEREO_ENERGY) { - if (ctx->bandE[ctx->i] > ctx->bandE[ctx->m->nbEBands+ctx->i]) OPUS_COPY(Y, X, N); - else OPUS_COPY(X, Y, N); + if (ctx->bandE[ctx->i] > ctx->bandE[ctx->m->nbEBands+ctx->i]) OAC_COPY(Y, X, N); + else OAC_COPY(X, Y, N); } } compute_theta(ctx, &sctx, X, Y, N, &b, B, B, LM, 1, &fill); @@ -1409,7 +1409,7 @@ static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm } } else { /* "Normal" split code */ - opus_int32 rebalance; + oac_int32 rebalance; mbits = IMAX(0, IMIN(b, (b-delta)/2)); sbits = b-mbits; @@ -1463,28 +1463,28 @@ static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm static void special_hybrid_folding(const CELTMode *m, celt_norm *norm, celt_norm *norm2, int start, int M, int dual_stereo) { int n1, n2; - const opus_int16 * OPUS_RESTRICT eBands = m->eBands; + const oac_int16 * OAC_RESTRICT eBands = m->eBands; n1 = M*(eBands[start+1]-eBands[start]); n2 = M*(eBands[start+2]-eBands[start+1]); /* Duplicate enough of the first band folding data to be able to fold the second band. Copies no data for CELT-only mode. */ - OPUS_COPY(&norm[n1], &norm[2*n1 - n2], n2-n1); + OAC_COPY(&norm[n1], &norm[2*n1 - n2], n2-n1); if (dual_stereo) - OPUS_COPY(&norm2[n1], &norm2[2*n1 - n2], n2-n1); + OAC_COPY(&norm2[n1], &norm2[2*n1 - n2], n2-n1); } #endif void quant_all_bands(int encode, const CELTMode *m, int start, int end, celt_norm *X_, celt_norm *Y_, unsigned char *collapse_masks, const celt_ener *bandE, int *pulses, int shortBlocks, int spread, - int dual_stereo, int intensity, int *tf_res, opus_int32 total_bits, - opus_int32 balance, ec_ctx *ec, int LM, int codedBands, - opus_uint32 *seed, int complexity, int arch, int disable_inv) + int dual_stereo, int intensity, int *tf_res, oac_int32 total_bits, + oac_int32 balance, ec_ctx *ec, int LM, int codedBands, + oac_uint32 *seed, int complexity, int arch, int disable_inv) { int i; - opus_int32 remaining_bits; - const opus_int16 * OPUS_RESTRICT eBands = m->eBands; - celt_norm * OPUS_RESTRICT norm, * OPUS_RESTRICT norm2; + oac_int32 remaining_bits; + const oac_int16 * OAC_RESTRICT eBands = m->eBands; + celt_norm * OAC_RESTRICT norm, * OAC_RESTRICT norm2; VARDECL(celt_norm, _norm); VARDECL(celt_norm, _lowband_scratch); VARDECL(celt_norm, X_save); @@ -1555,12 +1555,12 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, ctx.avoid_split_noise = B > 1; for (i=start;inbEBands], w); /* Make a copy. */ cm = x_cm|y_cm; ec_save = *ec; ctx_save = ctx; - OPUS_COPY(X_save, X, N); - OPUS_COPY(Y_save, Y, N); + OAC_COPY(X_save, X, N); + OAC_COPY(Y_save, Y, N); /* Encode and round down. */ ctx.theta_round = -1; x_cm = quant_band_stereo(&ctx, X, Y, N, b, B, @@ -1689,21 +1689,21 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, cm2 = x_cm; ec_save2 = *ec; ctx_save2 = ctx; - OPUS_COPY(X_save2, X, N); - OPUS_COPY(Y_save2, Y, N); + OAC_COPY(X_save2, X, N); + OAC_COPY(Y_save2, Y, N); if (!last) - OPUS_COPY(norm_save2, norm+M*eBands[i]-norm_offset, N); + OAC_COPY(norm_save2, norm+M*eBands[i]-norm_offset, N); nstart_bytes = ec_save.offs; nend_bytes = ec_save.storage; bytes_buf = ec_save.buf+nstart_bytes; save_bytes = nend_bytes-nstart_bytes; - OPUS_COPY(bytes_save, bytes_buf, save_bytes); + OAC_COPY(bytes_save, bytes_buf, save_bytes); /* Restore */ *ec = ec_save; ctx = ctx_save; - OPUS_COPY(X, X_save, N); - OPUS_COPY(Y, Y_save, N); + OAC_COPY(X, X_save, N); + OAC_COPY(Y, Y_save, N); #ifndef DISABLE_UPDATE_DRAFT if (i == start+1) special_hybrid_folding(m, norm, norm2, start, M, dual_stereo); @@ -1718,11 +1718,11 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, x_cm = cm2; *ec = ec_save2; ctx = ctx_save2; - OPUS_COPY(X, X_save2, N); - OPUS_COPY(Y, Y_save2, N); + OAC_COPY(X, X_save2, N); + OAC_COPY(Y, Y_save2, N); if (!last) - OPUS_COPY(norm+M*eBands[i]-norm_offset, norm_save2, N); - OPUS_COPY(bytes_buf, bytes_save, save_bytes); + OAC_COPY(norm+M*eBands[i]-norm_offset, norm_save2, N); + OAC_COPY(bytes_buf, bytes_save, save_bytes); } } else { ctx.theta_round = 0; diff --git a/celt/bands.h b/celt/bands.h index 8d44bfb69..de8b213c8 100644 --- a/celt/bands.h +++ b/celt/bands.h @@ -36,7 +36,7 @@ #include "entdec.h" #include "rate.h" -opus_int16 bitexact_cos(opus_int16 x); +oac_int16 bitexact_cos(oac_int16 x); int bitexact_log2tan(int isin,int icos); /** Compute the amplitude (sqrt energy) in each of the bands @@ -46,7 +46,7 @@ int bitexact_log2tan(int isin,int icos); */ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int LM, int arch); -/*void compute_noise_energies(const CELTMode *m, const celt_sig *X, const opus_val16 *tonality, celt_ener *bandE);*/ +/*void compute_noise_energies(const CELTMode *m, const celt_sig *X, const oac_val16 *tonality, celt_ener *bandE);*/ /** Normalise each band of X such that the energy in each band is equal to 1 @@ -54,15 +54,15 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *band * @param X Spectrum (returned normalised) * @param bandE Square root of the energy for each band */ -void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, celt_norm * OPUS_RESTRICT X, const celt_ener *bandE, int end, int C, int M); +void normalise_bands(const CELTMode *m, const celt_sig * OAC_RESTRICT freq, celt_norm * OAC_RESTRICT X, const celt_ener *bandE, int end, int C, int M); /** Denormalise each band of X to restore full amplitude * @param m Mode data * @param X Spectrum (returned de-normalised) * @param bandE Square root of the energy for each band */ -void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X, - celt_sig * OPUS_RESTRICT freq, const celt_glog *bandE, int start, +void denormalise_bands(const CELTMode *m, const celt_norm * OAC_RESTRICT X, + celt_sig * OAC_RESTRICT freq, const celt_glog *bandE, int start, int end, int M, int downsample, int silence); #define SPREAD_NONE (0) @@ -101,23 +101,23 @@ void haar1(celt_norm *X, int N0, int stride); * @param LM log2() of the number of 2.5 subframes in the frame * @param codedBands Last band to receive bits + 1 * @param seed Random generator seed - * @param arch Run-time architecture (see opus_select_arch()) + * @param arch Run-time architecture (see oac_select_arch()) */ void quant_all_bands(int encode, const CELTMode *m, int start, int end, celt_norm * X, celt_norm * Y, unsigned char *collapse_masks, const celt_ener *bandE, int *pulses, int shortBlocks, int spread, - int dual_stereo, int intensity, int *tf_res, opus_int32 total_bits, - opus_int32 balance, ec_ctx *ec, int M, int codedBands, opus_uint32 *seed, + int dual_stereo, int intensity, int *tf_res, oac_int32 total_bits, + oac_int32 balance, ec_ctx *ec, int M, int codedBands, oac_uint32 *seed, int complexity, int arch, int disable_inv); void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_masks, int LM, int C, int size, int start, int end, const celt_glog *logE, const celt_glog *prev1logE, - const celt_glog *prev2logE, const int *pulses, opus_uint32 seed, + const celt_glog *prev2logE, const int *pulses, oac_uint32 seed, int encode, int arch); -opus_uint32 celt_lcg_rand(opus_uint32 seed); +oac_uint32 celt_lcg_rand(oac_uint32 seed); -int hysteresis_decision(opus_val16 val, const opus_val16 *thresholds, const opus_val16 *hysteresis, int N, int prev); +int hysteresis_decision(oac_val16 val, const oac_val16 *thresholds, const oac_val16 *hysteresis, int N, int prev); #endif /* BANDS_H */ diff --git a/celt/celt.c b/celt/celt.c index c0db73739..70a2165b0 100644 --- a/celt/celt.c +++ b/celt/celt.c @@ -59,7 +59,7 @@ #endif -int resampling_factor(opus_int32 rate) +int resampling_factor(oac_int32 rate) { int ret; switch (rate) @@ -95,14 +95,14 @@ int resampling_factor(opus_int32 rate) #if !defined(OVERRIDE_COMB_FILTER_CONST) || defined(NON_STATIC_COMB_FILTER_CONST_C) /* This version should be faster on ARM */ -#ifdef OPUS_ARM_ASM +#ifdef OAC_ARM_ASM #ifndef NON_STATIC_COMB_FILTER_CONST_C static #endif -void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, +void comb_filter_const_c(oac_val32 *y, oac_val32 *x, int T, int N, celt_coef g10, celt_coef g11, celt_coef g12) { - opus_val32 x0, x1, x2, x3, x4; + oac_val32 x0, x1, x2, x3, x4; int i; x4 = SHL32(x[-T-2], 1); x3 = SHL32(x[-T-1], 1); @@ -110,7 +110,7 @@ void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, x1 = SHL32(x[-T+1], 1); for (i=0;i>3]; + ret = toOacTable[c>>3]; if (ret == 0) return -1; else return ret|(c&0x7); } -static OPUS_INLINE int fromOpus(unsigned char c) +static OAC_INLINE int fromOac(unsigned char c) { if (c<0x80) return -1; else - return fromOpusTable[(c>>3)-16] | (c&0x7); + return fromOacTable[(c>>3)-16] | (c&0x7); } #endif /* CUSTOM_MODES */ @@ -235,19 +235,19 @@ void validate_celt_decoder(CELTDecoder *st); #define VALIDATE_CELT_DECODER(st) #endif -int resampling_factor(opus_int32 rate); +int resampling_factor(oac_int32 rate); -void celt_preemphasis(const opus_res * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTRICT inp, - int N, int CC, int upsample, const opus_val16 *coef, celt_sig *mem, int clip); +void celt_preemphasis(const oac_res * OAC_RESTRICT pcmp, celt_sig * OAC_RESTRICT inp, + int N, int CC, int upsample, const oac_val16 *coef, celt_sig *mem, int clip); -void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, - opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, +void comb_filter(oac_val32 *y, oac_val32 *x, int T0, int T1, int N, + oac_val16 g0, oac_val16 g1, int tapset0, int tapset1, const celt_coef *window, int overlap, int arch); void init_caps(const CELTMode *m,int *cap,int LM,int C); #ifdef RESYNTH -void deemphasis(celt_sig *in[], opus_res *pcm, int N, int C, int downsample, const opus_val16 *coef, celt_sig *mem, int accum); +void deemphasis(celt_sig *in[], oac_res *pcm, int N, int C, int downsample, const oac_val16 *coef, celt_sig *mem, int accum); void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[], celt_glog *oldBandE, int start, int effEnd, int C, int CC, int isTransient, int LM, int downsample, int silence, int arch); diff --git a/celt/celt_decoder.c b/celt/celt_decoder.c index d5783ff1e..ac2e40816 100644 --- a/celt/celt_decoder.c +++ b/celt/celt_decoder.c @@ -84,8 +84,8 @@ /** Decoder state @brief Decoder state */ -struct OpusCustomDecoder { - const OpusCustomMode *mode; +struct OacCustomDecoder { + const OacCustomMode *mode; int overlap; int channels; int stream_channels; @@ -103,7 +103,7 @@ struct OpusCustomDecoder { /* Everything beyond this point gets cleared on a reset */ #define DECODER_RESET_START rng - opus_uint32 rng; + oac_uint32 rng; int error; int last_pitch_index; int loss_duration; @@ -112,8 +112,8 @@ struct OpusCustomDecoder { int skip_plc; int postfilter_period; int postfilter_period_old; - opus_val16 postfilter_gain; - opus_val16 postfilter_gain_old; + oac_val16 postfilter_gain; + oac_val16 postfilter_gain_old; int postfilter_tapset; int postfilter_tapset_old; int prefilter_and_fold; @@ -121,7 +121,7 @@ struct OpusCustomDecoder { celt_sig preemph_memD[2]; #ifdef ENABLE_DEEP_PLC - opus_int16 plc_pcm[PLC_UPDATE_SAMPLES]; + oac_int16 plc_pcm[PLC_UPDATE_SAMPLES]; int plc_fill; float plc_preemphasis_mem; #endif @@ -131,7 +131,7 @@ struct OpusCustomDecoder { /* celt_glog oldLogE[], Size = 2*mode->nbEBands */ /* celt_glog oldLogE2[], Size = 2*mode->nbEBands */ /* celt_glog backgroundLogE[], Size = 2*mode->nbEBands */ - /* opus_val16 lpc[], Size = channels*CELT_LPC_ORDER */ + /* oac_val16 lpc[], Size = channels*CELT_LPC_ORDER */ }; #if defined(ENABLE_HARDENING) || defined(ENABLE_ASSERTIONS) @@ -139,13 +139,13 @@ struct OpusCustomDecoder { up writing all over memory. */ void validate_celt_decoder(CELTDecoder *st) { -#if !defined(CUSTOM_MODES) && !defined(ENABLE_OPUS_CUSTOM_API) && !defined(ENABLE_QEXT) - celt_assert(st->mode == opus_custom_mode_create(48000, 960, NULL)); +#if !defined(CUSTOM_MODES) && !defined(ENABLE_OAC_CUSTOM_API) && !defined(ENABLE_QEXT) + celt_assert(st->mode == oac_custom_mode_create(48000, 960, NULL)); celt_assert(st->overlap == 120); celt_assert(st->end <= 21); #else /* From Section 4.3 in the spec: "The normal CELT layer uses 21 of those bands, - though Opus Custom (see Section 6.2) may use a different number of bands" + though Oac Custom (see Section 6.2) may use a different number of bands" Check if it's within the maximum number of Bark frequency bands instead */ celt_assert(st->end <= 25); @@ -155,9 +155,9 @@ void validate_celt_decoder(CELTDecoder *st) celt_assert(st->downsample > 0); celt_assert(st->start == 0 || st->start == 17); celt_assert(st->start < st->end); -#ifdef OPUS_ARCHMASK +#ifdef OAC_ARCHMASK celt_assert(st->arch >= 0); - celt_assert(st->arch <= OPUS_ARCHMASK); + celt_assert(st->arch <= OAC_ARCHMASK); #endif #ifndef ENABLE_QEXT celt_assert(st->last_pitch_index <= PLC_PITCH_LAG_MAX); @@ -177,14 +177,14 @@ void validate_celt_decoder(CELTDecoder *st) int celt_decoder_get_size(int channels) { #ifdef ENABLE_QEXT - const CELTMode *mode = opus_custom_mode_create(96000, 960, NULL); + const CELTMode *mode = oac_custom_mode_create(96000, 960, NULL); #else - const CELTMode *mode = opus_custom_mode_create(48000, 960, NULL); + const CELTMode *mode = oac_custom_mode_create(48000, 960, NULL); #endif - return opus_custom_decoder_get_size(mode, channels); + return oac_custom_decoder_get_size(mode, channels); } -OPUS_CUSTOM_NOSTATIC int opus_custom_decoder_get_size(const CELTMode *mode, int channels) +OAC_CUSTOM_NOSTATIC int oac_custom_decoder_get_size(const CELTMode *mode, int channels) { int size; #ifdef ENABLE_QEXT @@ -196,19 +196,19 @@ OPUS_CUSTOM_NOSTATIC int opus_custom_decoder_get_size(const CELTMode *mode, int size = sizeof(struct CELTDecoder) + (channels*(QEXT_SCALE(DECODE_BUFFER_SIZE)+mode->overlap)-1)*sizeof(celt_sig) + 4*2*mode->nbEBands*sizeof(celt_glog) - + channels*CELT_LPC_ORDER*sizeof(opus_val16); + + channels*CELT_LPC_ORDER*sizeof(oac_val16); return size; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -CELTDecoder *opus_custom_decoder_create(const CELTMode *mode, int channels, int *error) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +CELTDecoder *oac_custom_decoder_create(const CELTMode *mode, int channels, int *error) { int ret; - CELTDecoder *st = (CELTDecoder *)opus_alloc(opus_custom_decoder_get_size(mode, channels)); - ret = opus_custom_decoder_init(st, mode, channels); - if (ret != OPUS_OK) + CELTDecoder *st = (CELTDecoder *)oac_alloc(oac_custom_decoder_get_size(mode, channels)); + ret = oac_custom_decoder_init(st, mode, channels); + if (ret != OAC_OK) { - opus_custom_decoder_destroy(st); + oac_custom_decoder_destroy(st); st = NULL; } if (error) @@ -217,33 +217,33 @@ CELTDecoder *opus_custom_decoder_create(const CELTMode *mode, int channels, int } #endif /* CUSTOM_MODES */ -int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels) +int celt_decoder_init(CELTDecoder *st, oac_int32 sampling_rate, int channels) { int ret; #ifdef ENABLE_QEXT if (sampling_rate == 96000) { - return opus_custom_decoder_init(st, opus_custom_mode_create(96000, 960, NULL), channels); + return oac_custom_decoder_init(st, oac_custom_mode_create(96000, 960, NULL), channels); } #endif - ret = opus_custom_decoder_init(st, opus_custom_mode_create(48000, 960, NULL), channels); - if (ret != OPUS_OK) + ret = oac_custom_decoder_init(st, oac_custom_mode_create(48000, 960, NULL), channels); + if (ret != OAC_OK) return ret; st->downsample = resampling_factor(sampling_rate); if (st->downsample==0) - return OPUS_BAD_ARG; + return OAC_BAD_ARG; else - return OPUS_OK; + return OAC_OK; } -OPUS_CUSTOM_NOSTATIC int opus_custom_decoder_init(CELTDecoder *st, const CELTMode *mode, int channels) +OAC_CUSTOM_NOSTATIC int oac_custom_decoder_init(CELTDecoder *st, const CELTMode *mode, int channels) { if (channels < 0 || channels > 2) - return OPUS_BAD_ARG; + return OAC_BAD_ARG; if (st==NULL) - return OPUS_ALLOC_FAIL; + return OAC_ALLOC_FAIL; - OPUS_CLEAR((char*)st, opus_custom_decoder_get_size(mode, channels)); + OAC_CLEAR((char*)st, oac_custom_decoder_get_size(mode, channels)); st->mode = mode; st->overlap = mode->overlap; @@ -258,34 +258,34 @@ OPUS_CUSTOM_NOSTATIC int opus_custom_decoder_init(CELTDecoder *st, const CELTMod #else st->disable_inv = 0; #endif - st->arch = opus_select_arch(); + st->arch = oac_select_arch(); #ifdef ENABLE_QEXT if (st->mode->Fs == 96000 && (mode->shortMdctSize==240 || mode->shortMdctSize==180)) st->qext_scale = 2; else st->qext_scale = 1; #endif - opus_custom_decoder_ctl(st, OPUS_RESET_STATE); + oac_custom_decoder_ctl(st, OAC_RESET_STATE); - return OPUS_OK; + return OAC_OK; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -void opus_custom_decoder_destroy(CELTDecoder *st) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +void oac_custom_decoder_destroy(CELTDecoder *st) { - opus_free(st); + oac_free(st); } #endif /* CUSTOM_MODES */ -#if !defined(CUSTOM_MODES) && !defined(ENABLE_OPUS_CUSTOM_API) && !defined(ENABLE_QEXT) +#if !defined(CUSTOM_MODES) && !defined(ENABLE_OAC_CUSTOM_API) && !defined(ENABLE_QEXT) /* Special case for stereo with no downsampling and no accumulation. This is quite common and we can make it faster by processing both channels in the same loop, reducing overhead due to the dependency loop in the IIR filter. */ -static void deemphasis_stereo_simple(celt_sig *in[], opus_res *pcm, int N, const opus_val16 coef0, +static void deemphasis_stereo_simple(celt_sig *in[], oac_res *pcm, int N, const oac_val16 coef0, celt_sig *mem) { - celt_sig * OPUS_RESTRICT x0; - celt_sig * OPUS_RESTRICT x1; + celt_sig * OAC_RESTRICT x0; + celt_sig * OAC_RESTRICT x1; celt_sig m0, m1; int j; x0=in[0]; @@ -311,16 +311,16 @@ static void deemphasis_stereo_simple(celt_sig *in[], opus_res *pcm, int N, const #ifndef RESYNTH static #endif -void deemphasis(celt_sig *in[], opus_res *pcm, int N, int C, int downsample, const opus_val16 *coef, +void deemphasis(celt_sig *in[], oac_res *pcm, int N, int C, int downsample, const oac_val16 *coef, celt_sig *mem, int accum) { int c; int Nd; int apply_downsampling=0; - opus_val16 coef0; + oac_val16 coef0; VARDECL(celt_sig, scratch); SAVE_STACK; -#if !defined(CUSTOM_MODES) && !defined(ENABLE_OPUS_CUSTOM_API) && !defined(ENABLE_QEXT) +#if !defined(CUSTOM_MODES) && !defined(ENABLE_OAC_CUSTOM_API) && !defined(ENABLE_QEXT) /* Short version for common case. */ if (downsample == 1 && C == 2 && !accum) { @@ -333,16 +333,16 @@ void deemphasis(celt_sig *in[], opus_res *pcm, int N, int C, int downsample, con Nd = N/downsample; c=0; do { int j; - celt_sig * OPUS_RESTRICT x; - opus_res * OPUS_RESTRICT y; + celt_sig * OAC_RESTRICT x; + oac_res * OAC_RESTRICT y; celt_sig m = mem[c]; x =in[c]; y = pcm+c; -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) || defined(ENABLE_QEXT) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) || defined(ENABLE_QEXT) if (coef[1] != 0) { - opus_val16 coef1 = coef[1]; - opus_val16 coef3 = coef[3]; + oac_val16 coef1 = coef[1]; + oac_val16 coef3 = coef[3]; for (j=0;jmdct, &freq2[b], out_syn[0]+NB*b, mode->window, overlap, shift, B, arch); for (b=0;bstorage*8; tell = ec_tell(dec); @@ -529,14 +529,14 @@ static int celt_plc_pitch_search(CELTDecoder *st, celt_sig *decode_mem[2], int C #ifdef ENABLE_QEXT int qext_scale; #endif - VARDECL( opus_val16, lp_pitch_buf ); + VARDECL( oac_val16, lp_pitch_buf ); SAVE_STACK; #ifdef ENABLE_QEXT qext_scale = st->qext_scale; #else (void)st; #endif - ALLOC( lp_pitch_buf, DECODE_BUFFER_SIZE>>1, opus_val16 ); + ALLOC( lp_pitch_buf, DECODE_BUFFER_SIZE>>1, oac_val16 ); pitch_downsample(decode_mem, lp_pitch_buf, DECODE_BUFFER_SIZE>>1, C, QEXT_SCALE(2), arch); pitch_search(lp_pitch_buf+(PLC_PITCH_LAG_MAX>>1), lp_pitch_buf, @@ -547,19 +547,19 @@ static int celt_plc_pitch_search(CELTDecoder *st, celt_sig *decode_mem[2], int C return QEXT_SCALE(pitch_index); } -static void prefilter_and_fold(CELTDecoder * OPUS_RESTRICT st, int N) +static void prefilter_and_fold(CELTDecoder * OAC_RESTRICT st, int N) { int c; int CC; int i; int overlap; celt_sig *decode_mem[2]; - const OpusCustomMode *mode; + const OacCustomMode *mode; int decode_buffer_size; #ifdef ENABLE_QEXT int qext_scale; #endif - VARDECL(opus_val32, etmp); + VARDECL(oac_val32, etmp); SAVE_STACK #ifdef ENABLE_QEXT qext_scale = st->qext_scale; @@ -568,7 +568,7 @@ static void prefilter_and_fold(CELTDecoder * OPUS_RESTRICT st, int N) mode = st->mode; overlap = st->overlap; CC = st->channels; - ALLOC(etmp, overlap, opus_val32); + ALLOC(etmp, overlap, oac_val32); c=0; do { decode_mem[c] = st->_decode_mem + c*(decode_buffer_size+overlap); } while (++cchannels; celt_sig *decode_mem[2]; celt_sig *out_syn[2]; - opus_val16 *lpc; + oac_val16 *lpc; celt_glog *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE; - const OpusCustomMode *mode; + const OacCustomMode *mode; int nbEBands; int overlap; int start; int loss_duration; int curr_frame_type; - const opus_int16 *eBands; + const oac_int16 *eBands; int decode_buffer_size; int max_period; #ifdef ENABLE_QEXT @@ -690,7 +690,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM oldLogE = oldBandE + 2*nbEBands; oldLogE2 = oldLogE + 2*nbEBands; backgroundLogE = oldLogE2 + 2*nbEBands; - lpc = (opus_val16*)(backgroundLogE + 2*nbEBands); + lpc = (oac_val16*)(backgroundLogE + 2*nbEBands); loss_duration = st->loss_duration; start = st->start; @@ -713,7 +713,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM { /* Noise-based PLC/CNG */ VARDECL(celt_norm, X); - opus_uint32 seed; + oac_uint32 seed; int end; int effEnd; celt_glog decay; @@ -722,7 +722,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ c=0; do { - OPUS_MOVE(decode_mem[c], decode_mem[c]+N, + OAC_MOVE(decode_mem[c], decode_mem[c]+N, decode_buffer_size-N+overlap); } while (++c>20), NORM_SHIFT-14); + X[boffs+j] = SHL32((celt_norm)((oac_int32)seed>>20), NORM_SHIFT-14); } renormalise_vector(X+boffs, blen, Q31ONE, st->arch); } @@ -783,13 +783,13 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM int exc_length; /* Pitch-based PLC */ const celt_coef *window; - opus_val16 *exc; - opus_val16 fade = Q15ONE; + oac_val16 *exc; + oac_val16 fade = Q15ONE; int pitch_index; int curr_neural; int last_neural; - VARDECL(opus_val16, _exc); - VARDECL(opus_val16, fir_tmp); + VARDECL(oac_val16, _exc); + VARDECL(oac_val16, fir_tmp); curr_neural = curr_frame_type == FRAME_PLC_NEURAL || curr_frame_type == FRAME_DRED; last_neural = st->last_frame_type == FRAME_PLC_NEURAL || st->last_frame_type == FRAME_DRED; @@ -808,14 +808,14 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM decaying signal, but we can't get more than MAX_PERIOD. */ exc_length = IMIN(2*pitch_index, max_period); - ALLOC(_exc, max_period+CELT_LPC_ORDER, opus_val16); - ALLOC(fir_tmp, exc_length, opus_val16); + ALLOC(_exc, max_period+CELT_LPC_ORDER, oac_val16); + ALLOC(fir_tmp, exc_length, oac_val16); exc = _exc+CELT_LPC_ORDER; window = mode->window; c=0; do { - opus_val16 decay; - opus_val16 attenuation; - opus_val32 S1=0; + oac_val16 decay; + oac_val16 attenuation; + oac_val32 S1=0; celt_sig *buf; int extrapolation_offset; int extrapolation_len; @@ -827,7 +827,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM if (st->last_frame_type != FRAME_PLC_PERIODIC && !(last_neural && curr_neural)) { - opus_val32 ac[CELT_LPC_ORDER+1]; + oac_val32 ac[CELT_LPC_ORDER+1]; /* Compute LPC coefficients for the last MAX_PERIOD samples before the first loss so we can work in the excitation-filter domain. */ _celt_autocorr(exc, ac, window, overlap, @@ -854,8 +854,8 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM no overflow can happen in the IIR filter. This means: 32768*sum(abs(filter)) < 2^31 */ while (1) { - opus_val16 tmp=Q15ONE; - opus_val32 sum=QCONST16(1., SIG_SHIFT); + oac_val16 tmp=Q15ONE; + oac_val32 sum=QCONST16(1., SIG_SHIFT); for (i=0;iarch); - OPUS_COPY(exc+max_period-exc_length, fir_tmp, exc_length); + OAC_COPY(exc+max_period-exc_length, fir_tmp, exc_length); } /* Check if the waveform is decaying, and if so how fast. We do this to avoid adding energy when concealing in a segment with decaying energy. */ { - opus_val32 E1=1, E2=1; + oac_val32 E1=1, E2=1; int decay_length; #ifdef FIXED_POINT int shift = IMAX(0,2*celt_zlog2(celt_maxabs16(&exc[max_period-exc_length], exc_length))-20); @@ -892,7 +892,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM decay_length = exc_length>>1; for (i=0;i= pitch_index) { j -= pitch_index; attenuation = MULT16_16_Q15(attenuation, decay); @@ -934,7 +934,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM S1 += SHR32(MULT16_16(tmp, tmp), 11); } { - opus_val16 lpc_mem[CELT_LPC_ORDER]; + oac_val16 lpc_mem[CELT_LPC_ORDER]; /* Copy the last decoded samples (prior to the overlap region) to synthesis filter memory so we can have a continuous signal. */ for (i=0;iplc_pcm[i+j+1]*sinc_filter[3*j+1]; buf[decode_buffer_size-N+3*i+2] = sum; } - OPUS_MOVE(st->plc_pcm, &st->plc_pcm[N/3], st->plc_fill-N/3); + OAC_MOVE(st->plc_pcm, &st->plc_pcm[N/3], st->plc_fill-N/3); st->plc_fill -= N/3; for (i=0;istream_channels; - const OpusCustomMode *mode; + const OacCustomMode *mode; int nbEBands; int overlap; - const opus_int16 *eBands; + const oac_int16 *eBands; celt_glog max_background_increase; int decode_buffer_size; #ifdef ENABLE_QEXT @@ -1138,18 +1138,18 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char oldLogE2 = oldLogE + 2*nbEBands; backgroundLogE = oldLogE2 + 2*nbEBands; -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) if (st->signalling && data!=NULL) { int data0=data[0]; - /* Convert "standard mode" to Opus header */ + /* Convert "standard mode" to Oac header */ # ifndef ENABLE_QEXT if (mode->Fs==48000 && mode->shortMdctSize==120) # endif { - data0 = fromOpus(data0); + data0 = fromOac(data0); if (data0<0) - return OPUS_INVALID_PACKET; + return OAC_INVALID_PACKET; } st->end = end = IMAX(1, mode->effEBands-2*(data0>>5)); LM = (data0>>3)&0x3; @@ -1158,7 +1158,7 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char data++; len--; if (len<=0) - return OPUS_INVALID_PACKET; + return OAC_INVALID_PACKET; if (data[0] & 0x40) { int p; int padding=0; @@ -1167,7 +1167,7 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char do { int tmp; if (len<=0) - return OPUS_INVALID_PACKET; + return OAC_INVALID_PACKET; p = *data++; len--; tmp = p==255 ? 254: p; @@ -1175,7 +1175,7 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char padding += tmp; } while (p==255); padding--; - if (len <= 0 || padding<0) return OPUS_INVALID_PACKET; + if (len <= 0 || padding<0) return OAC_INVALID_PACKET; } } else { @@ -1183,9 +1183,9 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char len--; } if (LM>mode->maxLM) - return OPUS_INVALID_PACKET; + return OAC_INVALID_PACKET; if (frame_size < mode->shortMdctSize<shortMdctSize<shortMdctSize<mode->maxLM) - return OPUS_BAD_ARG; + return OAC_BAD_ARG; } M=1<1275 || pcm==NULL) - return OPUS_BAD_ARG; + return OAC_BAD_ARG; N = M*mode->shortMdctSize; c=0; do { @@ -1226,7 +1226,7 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char } #ifdef ENABLE_DEEP_PLC else { - /* FIXME: This is a bit of a hack just to make sure opus_decode_native() knows we're no longer in PLC. */ + /* FIXME: This is a bit of a hack just to make sure oac_decode_native() knows we're no longer in PLC. */ if (lpcnet) lpcnet->blend = 0; } #endif @@ -1309,8 +1309,8 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char { if (oldBandE[c*nbEBands+i] < MAXG(oldLogE[c*nbEBands+i], oldLogE2[c*nbEBands+i])) { /* If energy is going down already, continue the trend. */ - opus_val32 slope; - opus_val32 E0, E1, E2; + oac_val32 slope; + oac_val32 E0, E1, E2; E0 = oldBandE[c*nbEBands+i]; E1 = oldLogE[c*nbEBands+i]; E2 = oldLogE2[c*nbEBands+i]; @@ -1380,7 +1380,7 @@ int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char alloc_trim = tell+(6<=2&&bits>=((LM+2)<prefilter_and_fold = 0; RESTORE_STACK; if (ec_tell(dec) > 8*len) - return OPUS_INTERNAL_ERROR; + return OAC_INTERNAL_ERROR; if(ec_get_error(dec)) st->error = 1; return frame_size/st->downsample; } -int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, - int len, opus_res * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum) +int celt_decode_with_ec(CELTDecoder * OAC_RESTRICT st, const unsigned char *data, + int len, oac_res * OAC_RESTRICT pcm, int frame_size, ec_dec *dec, int accum) { return celt_decode_with_ec_dred(st, data, len, pcm, frame_size, dec, accum #ifdef ENABLE_DEEP_PLC @@ -1511,21 +1511,21 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat ); } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) -int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int16 * OPUS_RESTRICT pcm, int frame_size) +int oac_custom_decode(CELTDecoder * OAC_RESTRICT st, const unsigned char *data, int len, oac_int16 * OAC_RESTRICT pcm, int frame_size) { int j, ret, C, N; - VARDECL(opus_res, out); + VARDECL(oac_res, out); ALLOC_STACK; if (pcm==NULL) - return OPUS_BAD_ARG; + return OAC_BAD_ARG; C = st->channels; N = frame_size; - ALLOC(out, C*N, opus_res); + ALLOC(out, C*N, oac_res); ret = celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0); if (ret>0) for (j=0;jchannels; N = frame_size; - ALLOC(out, C*N, opus_res); + ALLOC(out, C*N, oac_res); ret = celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0); if (ret>0) for (j=0;jchannels; N = frame_size; - ALLOC(out, C*N, opus_res); + ALLOC(out, C*N, oac_res); ret=celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0); if (ret>0) for (j=0;j10) { goto bad_arg; @@ -1617,9 +1617,9 @@ int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...) st->complexity = value; } break; - case OPUS_GET_COMPLEXITY_REQUEST: + case OAC_GET_COMPLEXITY_REQUEST: { - opus_int32 *value = va_arg(ap, opus_int32*); + oac_int32 *value = va_arg(ap, oac_int32*); if (!value) { goto bad_arg; @@ -1629,7 +1629,7 @@ int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...) break; case CELT_SET_START_BAND_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); if (value<0 || value>=st->mode->nbEBands) goto bad_arg; st->start = value; @@ -1637,7 +1637,7 @@ int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...) break; case CELT_SET_END_BAND_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); if (value<1 || value>st->mode->nbEBands) goto bad_arg; st->end = value; @@ -1645,7 +1645,7 @@ int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...) break; case CELT_SET_CHANNELS_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); if (value<1 || value>2) goto bad_arg; st->stream_channels = value; @@ -1653,22 +1653,22 @@ int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...) break; case CELT_GET_AND_CLEAR_ERROR_REQUEST: { - opus_int32 *value = va_arg(ap, opus_int32*); + oac_int32 *value = va_arg(ap, oac_int32*); if (value==NULL) goto bad_arg; *value=st->error; st->error = 0; } break; - case OPUS_GET_LOOKAHEAD_REQUEST: + case OAC_GET_LOOKAHEAD_REQUEST: { - opus_int32 *value = va_arg(ap, opus_int32*); + oac_int32 *value = va_arg(ap, oac_int32*); if (value==NULL) goto bad_arg; *value = st->overlap/st->downsample; } break; - case OPUS_RESET_STATE: + case OAC_RESET_STATE: { int i; celt_glog *oldBandE, *oldLogE, *oldLogE2; @@ -1680,8 +1680,8 @@ int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...) oldBandE = (celt_glog*)(st->_decode_mem+(decode_buffer_size+st->overlap)*st->channels); oldLogE = oldBandE + 2*st->mode->nbEBands; oldLogE2 = oldLogE + 2*st->mode->nbEBands; - OPUS_CLEAR((char*)&st->DECODER_RESET_START, - opus_custom_decoder_get_size(st->mode, st->channels)- + OAC_CLEAR((char*)&st->DECODER_RESET_START, + oac_custom_decoder_get_size(st->mode, st->channels)- ((char*)&st->DECODER_RESET_START - (char*)st)); for (i=0;i<2*st->mode->nbEBands;i++) oldLogE[i]=oldLogE2[i]=-GCONST(28.f); @@ -1689,9 +1689,9 @@ int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...) st->last_frame_type = FRAME_NONE; } break; - case OPUS_GET_PITCH_REQUEST: + case OAC_GET_PITCH_REQUEST: { - opus_int32 *value = va_arg(ap, opus_int32*); + oac_int32 *value = va_arg(ap, oac_int32*); if (value==NULL) goto bad_arg; *value = st->postfilter_period; @@ -1707,21 +1707,21 @@ int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...) break; case CELT_SET_SIGNALLING_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); st->signalling = value; } break; - case OPUS_GET_FINAL_RANGE_REQUEST: + case OAC_GET_FINAL_RANGE_REQUEST: { - opus_uint32 * value = va_arg(ap, opus_uint32 *); + oac_uint32 * value = va_arg(ap, oac_uint32 *); if (value==0) goto bad_arg; *value=st->rng; } break; - case OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST: + case OAC_SET_PHASE_INVERSION_DISABLED_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); if(value<0 || value>1) { goto bad_arg; @@ -1729,9 +1729,9 @@ int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...) st->disable_inv = value; } break; - case OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST: + case OAC_GET_PHASE_INVERSION_DISABLED_REQUEST: { - opus_int32 *value = va_arg(ap, opus_int32*); + oac_int32 *value = va_arg(ap, oac_int32*); if (!value) { goto bad_arg; @@ -1743,11 +1743,11 @@ int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...) goto bad_request; } va_end(ap); - return OPUS_OK; + return OAC_OK; bad_arg: va_end(ap); - return OPUS_BAD_ARG; + return OAC_BAD_ARG; bad_request: va_end(ap); - return OPUS_UNIMPLEMENTED; + return OAC_UNIMPLEMENTED; } diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c index 30c374dc1..0dbd3c6ee 100644 --- a/celt/celt_encoder.c +++ b/celt/celt_encoder.c @@ -60,8 +60,8 @@ /** Encoder state @brief Encoder state */ -struct OpusCustomEncoder { - const OpusCustomMode *mode; /**< Mode used by the encoder */ +struct OacCustomEncoder { + const OacCustomMode *mode; /**< Mode used by the encoder */ int channels; int stream_channels; @@ -72,7 +72,7 @@ struct OpusCustomEncoder { int upsample; int start, end; - opus_int32 bitrate; + oac_int32 bitrate; int vbr; int signalling; int constrained_vbr; /* If zero, VBR can do whatever it likes with the rate */ @@ -88,36 +88,36 @@ struct OpusCustomEncoder { /* Everything beyond this point gets cleared on a reset */ #define ENCODER_RESET_START rng - opus_uint32 rng; + oac_uint32 rng; int spread_decision; - opus_val32 delayedIntra; + oac_val32 delayedIntra; int tonal_average; int lastCodedBands; int hf_average; int tapset_decision; int prefilter_period; - opus_val16 prefilter_gain; + oac_val16 prefilter_gain; int prefilter_tapset; #ifdef RESYNTH int prefilter_period_old; - opus_val16 prefilter_gain_old; + oac_val16 prefilter_gain_old; int prefilter_tapset_old; #endif int consec_transient; AnalysisInfo analysis; SILKInfo silk_info; - opus_val32 preemph_memE[2]; - opus_val32 preemph_memD[2]; + oac_val32 preemph_memE[2]; + oac_val32 preemph_memD[2]; /* VBR-related parameters */ - opus_int32 vbr_reservoir; - opus_int32 vbr_drift; - opus_int32 vbr_offset; - opus_int32 vbr_count; - opus_val32 overlap_max; - opus_val16 stereo_saving; + oac_int32 vbr_reservoir; + oac_int32 vbr_drift; + oac_int32 vbr_offset; + oac_int32 vbr_count; + oac_val32 overlap_max; + oac_val16 stereo_saving; int intensity; celt_glog *energy_mask; celt_glog spec_avg; @@ -143,14 +143,14 @@ struct OpusCustomEncoder { int celt_encoder_get_size(int channels) { #ifdef ENABLE_QEXT - CELTMode *mode = opus_custom_mode_create(96000, 1920, NULL); + CELTMode *mode = oac_custom_mode_create(96000, 1920, NULL); #else - CELTMode *mode = opus_custom_mode_create(48000, 960, NULL); + CELTMode *mode = oac_custom_mode_create(48000, 960, NULL); #endif - return opus_custom_encoder_get_size(mode, channels); + return oac_custom_encoder_get_size(mode, channels); } -OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_get_size(const CELTMode *mode, int channels) +OAC_CUSTOM_NOSTATIC int oac_custom_encoder_get_size(const CELTMode *mode, int channels) { int size; #ifdef ENABLE_QEXT @@ -169,16 +169,16 @@ OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_get_size(const CELTMode *mode, int return size; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -CELTEncoder *opus_custom_encoder_create(const CELTMode *mode, int channels, int *error) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +CELTEncoder *oac_custom_encoder_create(const CELTMode *mode, int channels, int *error) { int ret; - CELTEncoder *st = (CELTEncoder *)opus_alloc(opus_custom_encoder_get_size(mode, channels)); + CELTEncoder *st = (CELTEncoder *)oac_alloc(oac_custom_encoder_get_size(mode, channels)); /* init will handle the NULL case */ - ret = opus_custom_encoder_init(st, mode, channels); - if (ret != OPUS_OK) + ret = oac_custom_encoder_init(st, mode, channels); + if (ret != OAC_OK) { - opus_custom_encoder_destroy(st); + oac_custom_encoder_destroy(st); st = NULL; } if (error) @@ -187,16 +187,16 @@ CELTEncoder *opus_custom_encoder_create(const CELTMode *mode, int channels, int } #endif /* CUSTOM_MODES */ -static int opus_custom_encoder_init_arch(CELTEncoder *st, const CELTMode *mode, +static int oac_custom_encoder_init_arch(CELTEncoder *st, const CELTMode *mode, int channels, int arch) { if (channels < 0 || channels > 2) - return OPUS_BAD_ARG; + return OAC_BAD_ARG; if (st==NULL || mode==NULL) - return OPUS_ALLOC_FAIL; + return OAC_ALLOC_FAIL; - OPUS_CLEAR((char*)st, opus_custom_encoder_get_size(mode, channels)); + OAC_CLEAR((char*)st, oac_custom_encoder_get_size(mode, channels)); st->mode = mode; st->stream_channels = st->channels = channels; @@ -210,7 +210,7 @@ static int opus_custom_encoder_init_arch(CELTEncoder *st, const CELTMode *mode, st->constrained_vbr = 1; st->clip = 1; - st->bitrate = OPUS_BITRATE_MAX; + st->bitrate = OAC_BITRATE_MAX; st->vbr = 0; st->force_intra = 0; st->complexity = 5; @@ -221,62 +221,62 @@ static int opus_custom_encoder_init_arch(CELTEncoder *st, const CELTMode *mode, else st->qext_scale = 1; #endif - opus_custom_encoder_ctl(st, OPUS_RESET_STATE); + oac_custom_encoder_ctl(st, OAC_RESET_STATE); - return OPUS_OK; + return OAC_OK; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -int opus_custom_encoder_init(CELTEncoder *st, const CELTMode *mode, int channels) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +int oac_custom_encoder_init(CELTEncoder *st, const CELTMode *mode, int channels) { - return opus_custom_encoder_init_arch(st, mode, channels, opus_select_arch()); + return oac_custom_encoder_init_arch(st, mode, channels, oac_select_arch()); } #endif -int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels, +int celt_encoder_init(CELTEncoder *st, oac_int32 sampling_rate, int channels, int arch) { int ret; #ifdef ENABLE_QEXT if (sampling_rate==96000) { st->upsample = 1; - return opus_custom_encoder_init_arch(st, - opus_custom_mode_create(96000, 1920, NULL), channels, arch); + return oac_custom_encoder_init_arch(st, + oac_custom_mode_create(96000, 1920, NULL), channels, arch); } #endif - ret = opus_custom_encoder_init_arch(st, - opus_custom_mode_create(48000, 960, NULL), channels, arch); - if (ret != OPUS_OK) + ret = oac_custom_encoder_init_arch(st, + oac_custom_mode_create(48000, 960, NULL), channels, arch); + if (ret != OAC_OK) return ret; st->upsample = resampling_factor(sampling_rate); - return OPUS_OK; + return OAC_OK; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -void opus_custom_encoder_destroy(CELTEncoder *st) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +void oac_custom_encoder_destroy(CELTEncoder *st) { - opus_free(st); + oac_free(st); } #endif /* CUSTOM_MODES */ -static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int C, - opus_val16 *tf_estimate, int *tf_chan, int allow_weak_transients, - int *weak_transient, opus_val16 tone_freq, opus_val32 toneishness) +static int transient_analysis(const oac_val32 * OAC_RESTRICT in, int len, int C, + oac_val16 *tf_estimate, int *tf_chan, int allow_weak_transients, + int *weak_transient, oac_val16 tone_freq, oac_val32 toneishness) { int i; - VARDECL(opus_val16, tmp); - opus_val32 mem0,mem1; + VARDECL(oac_val16, tmp); + oac_val32 mem0,mem1; int is_transient = 0; - opus_int32 mask_metric = 0; + oac_int32 mask_metric = 0; int c; - opus_val16 tf_max; + oac_val16 tf_max; int len2; /* Forward masking: 6.7 dB/ms. */ #ifdef FIXED_POINT int forward_shift = 4; #else - opus_val16 forward_decay = QCONST16(.0625f,15); + oac_val16 forward_decay = QCONST16(.0625f,15); #endif /* Table of 6*64/x, trained on real data to minimize the average error */ static const unsigned char inv_table[128] = { @@ -293,7 +293,7 @@ static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int #ifdef FIXED_POINT int in_shift = IMAX(0, celt_ilog2(1+celt_maxabs32(in, C*len))-14); #endif - ALLOC(tmp, len, opus_val16); + ALLOC(tmp, len, oac_val16); *weak_transient = 0; /* For lower bitrates, let's be more conservative and have a forward masking @@ -311,10 +311,10 @@ static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int len2=len/2; for (c=0;coverlap; @@ -544,17 +544,17 @@ static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * OPUS int bound = B*N/upsample; for (i=0;ieBands[i+1]-m->eBands[i])<eBands[i+1]-m->eBands[i])==1; - OPUS_COPY(tmp, &X[tf_chan*N0 + (m->eBands[i]<eBands[i]<>LM, 1<storage*8; tell = ec_tell(enc); logp = isTransient ? 2 : 4; @@ -845,31 +845,31 @@ static void tf_encode(int start, int end, int isTransient, int *tf_res, int LM, static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X, const celt_glog *bandLogE, int end, int LM, int C, int N0, - AnalysisInfo *analysis, opus_val16 *stereo_saving, opus_val16 tf_estimate, - int intensity, celt_glog surround_trim, opus_int32 equiv_rate, int arch) + AnalysisInfo *analysis, oac_val16 *stereo_saving, oac_val16 tf_estimate, + int intensity, celt_glog surround_trim, oac_int32 equiv_rate, int arch) { int i; - opus_val32 diff=0; + oac_val32 diff=0; int c; int trim_index; - opus_val16 trim = QCONST16(5.f, 8); - opus_val16 logXC, logXC2; + oac_val16 trim = QCONST16(5.f, 8); + oac_val16 logXC, logXC2; /* At low bitrate, reducing the trim seems to help. At higher bitrates, it's less clear what's best, so we're keeping it as it was before, at least for now. */ if (equiv_rate < 64000) { trim = QCONST16(4.f, 8); } else if (equiv_rate < 80000) { - opus_int32 frac = (equiv_rate-64000) >> 10; + oac_int32 frac = (equiv_rate-64000) >> 10; trim = QCONST16(4.f, 8) + QCONST16(1.f/16.f, 8)*frac; } if (C==2) { - opus_val16 sum = 0; /* Q10 */ - opus_val16 minXC; /* Q10 */ + oac_val16 sum = 0; /* Q10 */ + oac_val16 minXC; /* Q10 */ /* Compute inter-channel correlation for low frequencies */ for (i=0;i<8;i++) { - opus_val32 partial; + oac_val32 partial; partial = celt_inner_prod_norm_shift(&X[m->eBands[i]<eBands[i]<eBands[i+1]-m->eBands[i])<eBands[i]<eBands[i]<eBands[i+1]-m->eBands[i])<nbEBands], 5)*(opus_int32)(2+2*i-end); + diff += SHR32(bandLogE[i+c*m->nbEBands], 5)*(oac_int32)(2+2*i-end); } } while (++cvalid) { trim -= MAX16(-QCONST16(2.f, 8), MIN16(QCONST16(2.f, 8), - (opus_val16)(QCONST16(2.f, 8)*(analysis->tonality_slope+.05f)))); + (oac_val16)(QCONST16(2.f, 8)*(analysis->tonality_slope+.05f)))); } #else (void)analysis; @@ -940,7 +940,7 @@ static int stereo_analysis(const CELTMode *m, const celt_norm *X, { int i; int thetas; - opus_val32 sumLR = EPSILON, sumMS = EPSILON; + oac_val32 sumLR = EPSILON, sumMS = EPSILON; /* Use the L1 norm to model the entropy of the L/R signal vs the M/S signal */ for (i=0;i<13;i++) @@ -948,7 +948,7 @@ static int stereo_analysis(const CELTMode *m, const celt_norm *X, int j; for (j=m->eBands[i]<eBands[i+1]<=0;i--) @@ -1111,7 +1111,7 @@ static celt_glog dynalloc_analysis(const celt_glog *bandLogE, const celt_glog *b celt_glog offset; celt_glog tmp; celt_glog *f; - OPUS_COPY(bandLogE3, &bandLogE2[c*nbEBands], end); + OAC_COPY(bandLogE3, &bandLogE2[c*nbEBands], end); if (LM==0) { /* For 2.5 ms frames, the first 8 bands have just one bin, so the energy is highly unreliable (high variance). For that reason, @@ -1187,10 +1187,10 @@ static celt_glog dynalloc_analysis(const celt_glog *bandLogE, const celt_glog *b if (i>=12) follower[i] = HALF32(follower[i]); } - /* Compensate for Opus' under-allocation on tones. */ + /* Compensate for Oac' under-allocation on tones. */ if (toneishness > QCONST32(.98f, 29)) { #ifdef FIXED_POINT - int freq_bin = PSHR32(QEXT_SCALE((opus_val32)tone_freq)*QCONST16(120/M_PI, 9), 13+9); + int freq_bin = PSHR32(QEXT_SCALE((oac_val32)tone_freq)*QCONST16(120/M_PI, 9), 13+9); #else int freq_bin = (int)floor(.5 + QEXT_SCALE(tone_freq)*120/M_PI); #endif @@ -1239,7 +1239,7 @@ static celt_glog dynalloc_analysis(const celt_glog *bandLogE, const celt_glog *b if ((!vbr || (constrained_vbr&&!isTransient)) && (tot_boost+boost_bits)>>BITRES>>3 > 2*effectiveBytes/3) { - opus_int32 cap = ((2*effectiveBytes/3)<>15; @@ -1287,11 +1287,11 @@ int acos_approx(opus_val32 x) { #endif /* Compute the LPC coefficients using a least-squares fit for both forward and backward prediction. */ -static int tone_lpc(const opus_val16 *x, int len, int delay, opus_val32 *lpc) { +static int tone_lpc(const oac_val16 *x, int len, int delay, oac_val32 *lpc) { int i; - opus_val32 r00=0, r01=0, r11=0, r02=0, r12=0, r22=0; - opus_val32 edges; - opus_val32 num0, num1, den; + oac_val32 r00=0, r01=0, r11=0, r02=0, r12=0, r22=0; + oac_val32 edges; + oac_val32 num0, num1, den; celt_assert(len > 2*delay); /* Compute correlations as if using the forward prediction covariance method. */ for (i=0;i= 5) { - VARDECL(opus_val16, pitch_buf); - ALLOC(pitch_buf, (max_period+N)>>1, opus_val16); + VARDECL(oac_val16, pitch_buf); + ALLOC(pitch_buf, (max_period+N)>>1, oac_val16); pitch_downsample(pre, pitch_buf, (max_period+N)>>1, CC, 2, st->arch); /* Don't search for the fir last 1.5 octave of the range because @@ -1480,7 +1480,7 @@ static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, } #ifndef DISABLE_FLOAT_API if (analysis->valid) - gain1 = (opus_val16)(gain1 * analysis->max_pitch_ratio); + gain1 = (oac_val16)(gain1 * analysis->max_pitch_ratio); #else (void)analysis; #endif @@ -1532,7 +1532,7 @@ static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, int i; int offset = mode->shortMdctSize-overlap; st->prefilter_period=IMAX(st->prefilter_period, COMBFILTER_MINPERIOD); - OPUS_COPY(in+c*(N+overlap), st->in_mem+c*(overlap), overlap); + OAC_COPY(in+c*(N+overlap), st->in_mem+c*(overlap), overlap); for (i=0;ishortMdctSize-overlap; - OPUS_COPY(in+c*(N+overlap)+overlap, pre[c]+max_period, N); + OAC_COPY(in+c*(N+overlap)+overlap, pre[c]+max_period, N); comb_filter(in+c*(N+overlap)+overlap+offset, pre[c]+max_period+offset, st->prefilter_period, pitch_index, overlap, -st->prefilter_gain, -0, st->prefilter_tapset, prefilter_tapset, mode->window, overlap, st->arch); @@ -1572,14 +1572,14 @@ static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, } c=0; do { - OPUS_COPY(st->in_mem+c*(overlap), in+c*(N+overlap)+N, overlap); + OAC_COPY(st->in_mem+c*(overlap), in+c*(N+overlap)+N, overlap); if (N>max_period) { - OPUS_COPY(prefilter_mem+c*max_period, pre[c]+N, max_period); + OAC_COPY(prefilter_mem+c*max_period, pre[c]+N, max_period); } else { - OPUS_MOVE(prefilter_mem+c*max_period, prefilter_mem+c*max_period+N, max_period-N); - OPUS_COPY(prefilter_mem+c*max_period+max_period-N, pre[c]+max_period, N); + OAC_MOVE(prefilter_mem+c*max_period, prefilter_mem+c*max_period+N, max_period-N); + OAC_COPY(prefilter_mem+c*max_period+max_period-N, pre[c]+max_period, N); } } while (++cnbEBands; eBands = mode->eBands; @@ -1618,41 +1618,41 @@ static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32 /*printf("%f %f %f %f %d %d ", st->analysis.activity, st->analysis.tonality, tf_estimate, st->stereo_saving, tot_boost, coded_bands);*/ #ifndef DISABLE_FLOAT_API if (analysis->valid && analysis->activity<.4) - target -= (opus_int32)((coded_bins<activity)); + target -= (oac_int32)((coded_bins<activity)); #endif /* Stereo savings */ if (C==2) { int coded_stereo_bands; int coded_stereo_dof; - opus_val16 max_frac; + oac_val16 max_frac; coded_stereo_bands = IMIN(intensity, coded_bands); coded_stereo_dof = (eBands[coded_stereo_bands]<valid && !lfe) { - opus_int32 tonal_target; + oac_int32 tonal_target; float tonal; /* Tonality boost (compensating for the average). */ tonal = MAX16(0.f,analysis->tonality-.15f)-0.12f; - tonal_target = target + (opus_int32)((coded_bins<tonality, tonal);*/ target = tonal_target; } @@ -1663,17 +1663,17 @@ static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32 if (has_surround_mask&&!lfe) { - opus_int32 surround_target = target + (opus_int32)SHR32(MULT16_16(SHR32(surround_masking,DB_SHIFT-10),coded_bins<end, st->intensity, surround_target, target, st->bitrate);*/ target = IMAX(target/4, surround_target); } { - opus_int32 floor_depth; + oac_int32 floor_depth; int bins; bins = eBands[nbEBands-2]<>2); target = IMIN(target, floor_depth); /*printf("%f %d\n", maxDepth, floor_depth);*/ @@ -1683,16 +1683,16 @@ static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32 for long. Needs tuning. */ if ((!has_surround_mask||lfe) && constrained_vbr) { - target = base_target + (opus_int32)MULT16_32_Q15(QCONST16(0.67f, 15), target-base_target); + target = base_target + (oac_int32)MULT16_32_Q15(QCONST16(0.67f, 15), target-base_target); } if (!has_surround_mask && tf_estimate < QCONST16(.2f, 14)) { - opus_val16 amount; - opus_val16 tvbr_factor; + oac_val16 amount; + oac_val16 tvbr_factor; amount = MULT16_16_Q15(QCONST16(.0000031f, 30), IMAX(0, IMIN(32000, 96000-bitrate))); tvbr_factor = SHR32(MULT16_16(SHR32(temporal_vbr, DB_SHIFT-10), amount), 10); - target += (opus_int32)MULT16_32_Q15(tvbr_factor, target); + target += (oac_int32)MULT16_32_Q15(tvbr_factor, target); } /* Don't allow more than doubling the rate */ @@ -1701,10 +1701,10 @@ static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32 return target; } -int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc) +int celt_encode_with_ec(CELTEncoder * OAC_RESTRICT st, const oac_res * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc) { int i, c, N; - opus_int32 bits; + oac_int32 bits; ec_enc _enc; VARDECL(celt_sig, in); VARDECL(celt_sig, freq); @@ -1731,50 +1731,50 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in int LM, M; int tf_select; int nbFilledBytes, nbAvailableBytes; - opus_int32 min_allowed; + oac_int32 min_allowed; int start; int end; int effEnd; int codedBands; int alloc_trim; int pitch_index=COMBFILTER_MINPERIOD; - opus_val16 gain1 = 0; + oac_val16 gain1 = 0; int dual_stereo=0; int effectiveBytes; int dynalloc_logp; - opus_int32 vbr_rate; - opus_int32 total_bits; - opus_int32 total_boost; - opus_int32 balance; - opus_int32 tell; - opus_int32 tell0_frac; + oac_int32 vbr_rate; + oac_int32 total_bits; + oac_int32 total_boost; + oac_int32 balance; + oac_int32 tell; + oac_int32 tell0_frac; int prefilter_tapset=0; int pf_on; int anti_collapse_rsv; int anti_collapse_on=0; int silence=0; int tf_chan = 0; - opus_val16 tf_estimate; + oac_val16 tf_estimate; int pitch_change=0; - opus_int32 tot_boost; - opus_val32 sample_max; + oac_int32 tot_boost; + oac_val32 sample_max; celt_glog maxDepth; - const OpusCustomMode *mode; + const OacCustomMode *mode; int nbEBands; int overlap; - const opus_int16 *eBands; + const oac_int16 *eBands; int secondMdct; int signalBandwidth; int transient_got_disabled=0; celt_glog surround_masking=0; celt_glog temporal_vbr=0; celt_glog surround_trim = 0; - opus_int32 equiv_rate; + oac_int32 equiv_rate; int hybrid; int weak_transient = 0; int enable_tf_analysis; - opus_val16 tone_freq=-1; - opus_val32 toneishness=0; + oac_val16 tone_freq=-1; + oac_val32 toneishness=0; VARDECL(celt_glog, surround_dynalloc); int packet_size_cap = 1275; int qext_scale=1; @@ -1791,7 +1791,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in if (nbCompressedBytes<2 || pcm==NULL) { RESTORE_STACK; - return OPUS_BAD_ARG; + return OAC_BAD_ARG; } frame_size *= st->upsample; @@ -1801,7 +1801,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in if (LM>mode->maxLM) { RESTORE_STACK; - return OPUS_BAD_ARG; + return OAC_BAD_ARG; } M=1<shortMdctSize; @@ -1826,7 +1826,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in nbFilledBytes=(tell+4)>>3; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) if (st->signalling && enc==NULL) { int tmp = (mode->effEBands-end)>>1; @@ -1834,16 +1834,16 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in compressed[0] = tmp<<5; compressed[0] |= LM<<3; compressed[0] |= (C==2)<<2; - /* Convert "standard mode" to Opus header */ + /* Convert "standard mode" to Oac header */ # ifndef ENABLE_QEXT if (mode->Fs==48000 && mode->shortMdctSize==120) # endif { - int c0 = toOpus(compressed[0]); + int c0 = toOac(compressed[0]); if (c0<0) { RESTORE_STACK; - return OPUS_BAD_ARG; + return OAC_BAD_ARG; } compressed[0] = c0; } @@ -1857,21 +1857,21 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in /* Can't produce more than 1275 output bytes for the main payload. */ nbCompressedBytes = IMIN(nbCompressedBytes,packet_size_cap); - if (st->vbr && st->bitrate!=OPUS_BITRATE_MAX) + if (st->vbr && st->bitrate!=OAC_BITRATE_MAX) { vbr_rate = bitrate_to_bits(st->bitrate, mode->Fs, frame_size)<signalling) vbr_rate -= 8<>(3+BITRES); } else { - opus_int32 tmp; + oac_int32 tmp; vbr_rate = 0; tmp = st->bitrate*frame_size; if (tell>1) tmp += tell*mode->Fs; - if (st->bitrate!=OPUS_BITRATE_MAX) + if (st->bitrate!=OAC_BITRATE_MAX) { nbCompressedBytes = IMAX(2, IMIN(nbCompressedBytes, (tmp+4*mode->Fs)/(8*mode->Fs)-!!st->signalling)); @@ -1881,8 +1881,8 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in effectiveBytes = nbCompressedBytes - nbFilledBytes; } nbAvailableBytes = nbCompressedBytes - nbFilledBytes; - equiv_rate = ((opus_int32)nbCompressedBytes*8*50 << (3-LM)) - (40*C+20)*((400>>LM) - 50); - if (st->bitrate != OPUS_BITRATE_MAX) + equiv_rate = ((oac_int32)nbCompressedBytes*8*50 << (3-LM)) - (40*C+20)*((400>>LM) - 50); + if (st->bitrate != OAC_BITRATE_MAX) equiv_rate = IMIN(equiv_rate, st->bitrate - (40*C+20)*((400>>LM) - 50)); if (enc==NULL) @@ -1899,8 +1899,8 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in correctly if we don't have enough bits. */ if (st->constrained_vbr) { - opus_int32 vbr_bound; - opus_int32 max_allowed; + oac_int32 vbr_bound; + oac_int32 max_allowed; /* We could use any multiple of vbr_rate as bound (depending on the delay). This is clamped to ensure we use at least two bytes if the encoder @@ -1931,7 +1931,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in #ifdef FIXED_POINT silence = (sample_max==0); #else - silence = (sample_max <= (opus_val16)1/(1<lsb_depth)); + silence = (sample_max <= (oac_val16)1/(1<lsb_depth)); #endif #ifdef FUZZING if ((rand()&0x3F)==0) @@ -1965,7 +1965,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in #endif celt_preemphasis(pcm+c, in+c*(N+overlap)+overlap, N, CC, st->upsample, mode->preemph, st->preemph_memE+c, need_clip); - OPUS_COPY(in+c*(N+overlap), &prefilter_mem[(1+c)*QEXT_SCALE(COMBFILTER_MAXPERIOD)-overlap], overlap); + OAC_COPY(in+c*(N+overlap), &prefilter_mem[(1+c)*QEXT_SCALE(COMBFILTER_MAXPERIOD)-overlap], overlap); } while (++cupsample, st->arch); /* This should catch any NaN in the CELT input. Since we're not supposed to see any (they're filtered - at the Opus layer), just abort. */ + at the Oac layer), just abort. */ celt_assert(!celt_isnan(freq[0]) && (C==1 || !celt_isnan(freq[N]))); if (CC==2&&C==1) tf_chan = 0; @@ -2057,15 +2057,15 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in amp2Log2(mode, effEnd, end, bandE, bandLogE, C); ALLOC(surround_dynalloc, C*nbEBands, celt_glog); - OPUS_CLEAR(surround_dynalloc, end); + OAC_CLEAR(surround_dynalloc, end); /* This computes how much masking takes place between surround channels */ if (!hybrid&&st->energy_mask&&!st->lfe) { int mask_end; int midband; int count_dynalloc; - opus_val32 mask_avg=0; - opus_val32 diff=0; + oac_val32 mask_avg=0; + oac_val32 diff=0; int count=0; mask_end = IMAX(2,st->lastCodedBands); for (c=0;cenergy_mask[nbEBands*c+i], GCONST(.25f)), -GCONST(2.0f)); if (mask > 0) @@ -2096,7 +2096,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in count_dynalloc=0; for(i=0;ilfe) { celt_glog follow=-QCONST32(10.0f, DB_SHIFT-5); - opus_val32 frame_avg=0; + oac_val32 frame_avg=0; celt_glog offset = shortBlocks?HALF32(SHL32(LM, DB_SHIFT-5)):0; for(i=start;ianalysis.valid) { - static const opus_val16 spread_thresholds[3] = {-QCONST16(.6f, 15), -QCONST16(.2f, 15), -QCONST16(.07f, 15)}; - static const opus_val16 spread_histeresis[3] = {QCONST16(.15f, 15), QCONST16(.07f, 15), QCONST16(.02f, 15)}; - static const opus_val16 tapset_thresholds[2] = {QCONST16(.0f, 15), QCONST16(.15f, 15)}; - static const opus_val16 tapset_histeresis[2] = {QCONST16(.1f, 15), QCONST16(.05f, 15)}; + static const oac_val16 spread_thresholds[3] = {-QCONST16(.6f, 15), -QCONST16(.2f, 15), -QCONST16(.07f, 15)}; + static const oac_val16 spread_histeresis[3] = {QCONST16(.15f, 15), QCONST16(.07f, 15), QCONST16(.02f, 15)}; + static const oac_val16 tapset_thresholds[2] = {QCONST16(.0f, 15), QCONST16(.15f, 15)}; + static const oac_val16 tapset_histeresis[2] = {QCONST16(.1f, 15), QCONST16(.05f, 15)}; st->spread_decision = hysteresis_decision(-st->analysis.tonality, spread_thresholds, spread_histeresis, 3, st->spread_decision); st->tapset_decision = hysteresis_decision(st->analysis.tonality_slope, tapset_thresholds, tapset_histeresis, 2, st->tapset_decision); } else @@ -2341,17 +2341,17 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in if (C==2) { - static const opus_val16 intensity_thresholds[21]= + static const oac_val16 intensity_thresholds[21]= /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 off*/ { 1, 2, 3, 4, 5, 6, 7, 8,16,24,36,44,50,56,62,67,72,79,88,106,134}; - static const opus_val16 intensity_histeresis[21]= + static const oac_val16 intensity_histeresis[21]= { 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4, 5, 6, 8, 8}; /* Always use MS for 2.5 ms frames until we can do a better analysis */ if (LM!=0) dual_stereo = stereo_analysis(mode, X, LM, N); - st->intensity = hysteresis_decision((opus_val16)(equiv_rate/1000), + st->intensity = hysteresis_decision((oac_val16)(equiv_rate/1000), intensity_thresholds, intensity_histeresis, 21, st->intensity); st->intensity = IMIN(end,IMAX(start, st->intensity)); } @@ -2385,10 +2385,10 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in /* Variable bitrate */ if (vbr_rate>0) { - opus_val16 alpha; - opus_int32 delta; + oac_val16 alpha; + oac_int32 delta; /* The target rate in 8th bits per frame */ - opus_int32 target, base_target; + oac_int32 target, base_target; int lm_diff = mode->maxLM - LM; /* Don't attempt to use more than 510 kb/s, even for frames smaller than 20 ms. @@ -2418,7 +2418,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in if (st->silk_info.offset > 100) target -= 18 << BITRES >> (3-LM); /* Boosting bitrate on transients and vowels with significant temporal spikes. */ - target += (opus_int32)MULT16_16_Q14(tf_estimate-QCONST16(.25f,14), (50< QCONST16(.7f,14)) @@ -2463,7 +2463,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in /* Compute the offset we need to apply in order to reach the target */ if (st->constrained_vbr) { - st->vbr_drift += (opus_int32)MULT16_32_Q15(alpha,(delta*(1<vbr_offset-st->vbr_drift); + st->vbr_drift += (oac_int32)MULT16_32_Q15(alpha,(delta*(1<vbr_offset-st->vbr_drift); st->vbr_offset = -st->vbr_drift; } /*printf ("%d\n", st->vbr_drift);*/ @@ -2489,7 +2489,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in ALLOC(fine_priority, nbEBands, int); /* bits = packet size - where we are - safety*/ - bits = (((opus_int32)nbCompressedBytes*8)<=2&&bits>=((LM+2)<analysis.valid) { int min_bandwidth; - if (equiv_rate < (opus_int32)32000*C) + if (equiv_rate < (oac_int32)32000*C) min_bandwidth = 13; - else if (equiv_rate < (opus_int32)48000*C) + else if (equiv_rate < (oac_int32)48000*C) min_bandwidth = 16; - else if (equiv_rate < (opus_int32)60000*C) + else if (equiv_rate < (oac_int32)60000*C) min_bandwidth = 18; - else if (equiv_rate < (opus_int32)80000*C) + else if (equiv_rate < (oac_int32)80000*C) min_bandwidth = 19; else min_bandwidth = 20; @@ -2521,7 +2521,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in st->lastCodedBands = codedBands; quant_fine_energy(mode, start, end, oldBandE, error, NULL, fine_quant, enc, C); - OPUS_CLEAR(energyError, nbEBands*CC); + OAC_CLEAR(energyError, nbEBands*CC); /* Residual quantisation */ ALLOC(collapse_masks, C*nbEBands, unsigned char); @@ -2565,7 +2565,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in } c=0; do { - OPUS_MOVE(st->syn_mem[c], st->syn_mem[c]+N, QEXT_SCALE(DEC_PITCH_BUF_SIZE)-N+overlap/2); + OAC_MOVE(st->syn_mem[c], st->syn_mem[c]+N, QEXT_SCALE(DEC_PITCH_BUF_SIZE)-N+overlap/2); } while (++cupsample, mode->preemph, st->preemph_memD, 0); + deemphasis(out_mem, (oac_res*)pcm, N, CC, st->upsample, mode->preemph, st->preemph_memD, 0); st->prefilter_period_old = st->prefilter_period; st->prefilter_gain_old = st->prefilter_gain; st->prefilter_tapset_old = st->prefilter_tapset; @@ -2608,13 +2608,13 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, in #endif if (CC==2&&C==1) { - OPUS_COPY(&oldBandE[nbEBands], oldBandE, nbEBands); + OAC_COPY(&oldBandE[nbEBands], oldBandE, nbEBands); } if (!isTransient) { - OPUS_COPY(oldLogE2, oldLogE, CC*nbEBands); - OPUS_COPY(oldLogE, oldBandE, CC*nbEBands); + OAC_COPY(oldLogE2, oldLogE, CC*nbEBands); + OAC_COPY(oldLogE, oldBandE, CC*nbEBands); } else { for (i=0;isignalling) nbCompressedBytes++; #endif RESTORE_STACK; if (ec_get_error(enc)) - return OPUS_INTERNAL_ERROR; + return OAC_INTERNAL_ERROR; else return nbCompressedBytes; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) -int opus_custom_encode(CELTEncoder * OPUS_RESTRICT st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) +int oac_custom_encode(CELTEncoder * OAC_RESTRICT st, const oac_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) { int j, ret, C, N; - VARDECL(opus_res, in); + VARDECL(oac_res, in); ALLOC_STACK; if (pcm==NULL) - return OPUS_BAD_ARG; + return OAC_BAD_ARG; C = st->channels; N = frame_size; - ALLOC(in, C*N, opus_res); + ALLOC(in, C*N, oac_res); for (j=0;jchannels; N = frame_size; - ALLOC(in, C*N, opus_res); + ALLOC(in, C*N, oac_res); for (j=0;jchannels; N = frame_size; - ALLOC(in, C*N, opus_res); + ALLOC(in, C*N, oac_res); for (j=0;j10) goto bad_arg; st->complexity = value; @@ -2772,7 +2772,7 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) break; case CELT_SET_START_BAND_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); if (value<0 || value>=st->mode->nbEBands) goto bad_arg; st->start = value; @@ -2780,7 +2780,7 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) break; case CELT_SET_END_BAND_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); if (value<1 || value>st->mode->nbEBands) goto bad_arg; st->end = value; @@ -2788,37 +2788,37 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) break; case CELT_SET_PREDICTION_REQUEST: { - int value = va_arg(ap, opus_int32); + int value = va_arg(ap, oac_int32); if (value<0 || value>2) goto bad_arg; st->disable_pf = value<=1; st->force_intra = value==0; } break; - case OPUS_SET_PACKET_LOSS_PERC_REQUEST: + case OAC_SET_PACKET_LOSS_PERC_REQUEST: { - int value = va_arg(ap, opus_int32); + int value = va_arg(ap, oac_int32); if (value<0 || value>100) goto bad_arg; st->loss_rate = value; } break; - case OPUS_SET_VBR_CONSTRAINT_REQUEST: + case OAC_SET_VBR_CONSTRAINT_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); st->constrained_vbr = value; } break; - case OPUS_SET_VBR_REQUEST: + case OAC_SET_VBR_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); st->vbr = value; } break; - case OPUS_SET_BITRATE_REQUEST: + case OAC_SET_BITRATE_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); - if (value<=500 && value!=OPUS_BITRATE_MAX) + oac_int32 value = va_arg(ap, oac_int32); + if (value<=500 && value!=OAC_BITRATE_MAX) goto bad_arg; value = IMIN(value, 750000*st->channels); st->bitrate = value; @@ -2826,29 +2826,29 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) break; case CELT_SET_CHANNELS_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); if (value<1 || value>2) goto bad_arg; st->stream_channels = value; } break; - case OPUS_SET_LSB_DEPTH_REQUEST: + case OAC_SET_LSB_DEPTH_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); if (value<8 || value>24) goto bad_arg; st->lsb_depth=value; } break; - case OPUS_GET_LSB_DEPTH_REQUEST: + case OAC_GET_LSB_DEPTH_REQUEST: { - opus_int32 *value = va_arg(ap, opus_int32*); + oac_int32 *value = va_arg(ap, oac_int32*); *value=st->lsb_depth; } break; - case OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST: + case OAC_SET_PHASE_INVERSION_DISABLED_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); if(value<0 || value>1) { goto bad_arg; @@ -2856,9 +2856,9 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) st->disable_inv = value; } break; - case OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST: + case OAC_GET_PHASE_INVERSION_DISABLED_REQUEST: { - opus_int32 *value = va_arg(ap, opus_int32*); + oac_int32 *value = va_arg(ap, oac_int32*); if (!value) { goto bad_arg; @@ -2866,15 +2866,15 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) *value = st->disable_inv; } break; - case OPUS_RESET_STATE: + case OAC_RESET_STATE: { int i; celt_glog *oldBandE, *oldLogE, *oldLogE2; oldBandE = (celt_glog*)(st->in_mem+st->channels*(st->mode->overlap+QEXT_SCALE2(COMBFILTER_MAXPERIOD, st->qext_scale))); oldLogE = oldBandE + st->channels*st->mode->nbEBands; oldLogE2 = oldLogE + st->channels*st->mode->nbEBands; - OPUS_CLEAR((char*)&st->ENCODER_RESET_START, - opus_custom_encoder_get_size(st->mode, st->channels)- + OAC_CLEAR((char*)&st->ENCODER_RESET_START, + oac_custom_encoder_get_size(st->mode, st->channels)- ((char*)&st->ENCODER_RESET_START - (char*)st)); for (i=0;ichannels*st->mode->nbEBands;i++) oldLogE[i]=oldLogE2[i]=-GCONST(28.f); @@ -2886,17 +2886,17 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) st->tapset_decision = 0; } break; -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) case CELT_SET_INPUT_CLIPPING_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); st->clip = value; } break; #endif case CELT_SET_SIGNALLING_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); st->signalling = value; } break; @@ -2904,14 +2904,14 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) { AnalysisInfo *info = va_arg(ap, AnalysisInfo *); if (info) - OPUS_COPY(&st->analysis, info, 1); + OAC_COPY(&st->analysis, info, 1); } break; case CELT_SET_SILK_INFO_REQUEST: { SILKInfo *info = va_arg(ap, SILKInfo *); if (info) - OPUS_COPY(&st->silk_info, info, 1); + OAC_COPY(&st->silk_info, info, 1); } break; case CELT_GET_MODE_REQUEST: @@ -2922,21 +2922,21 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) *value=st->mode; } break; - case OPUS_GET_FINAL_RANGE_REQUEST: + case OAC_GET_FINAL_RANGE_REQUEST: { - opus_uint32 * value = va_arg(ap, opus_uint32 *); + oac_uint32 * value = va_arg(ap, oac_uint32 *); if (value==0) goto bad_arg; *value=st->rng; } break; - case OPUS_SET_LFE_REQUEST: + case OAC_SET_LFE_REQUEST: { - opus_int32 value = va_arg(ap, opus_int32); + oac_int32 value = va_arg(ap, oac_int32); st->lfe = value; } break; - case OPUS_SET_ENERGY_MASK_REQUEST: + case OAC_SET_ENERGY_MASK_REQUEST: { celt_glog *value = va_arg(ap, celt_glog*); st->energy_mask = value; @@ -2946,11 +2946,11 @@ int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) goto bad_request; } va_end(ap); - return OPUS_OK; + return OAC_OK; bad_arg: va_end(ap); - return OPUS_BAD_ARG; + return OAC_BAD_ARG; bad_request: va_end(ap); - return OPUS_UNIMPLEMENTED; + return OAC_UNIMPLEMENTED; } diff --git a/celt/celt_lpc.c b/celt/celt_lpc.c index e5a1c4852..00900c700 100644 --- a/celt/celt_lpc.c +++ b/celt/celt_lpc.c @@ -35,21 +35,21 @@ #include "pitch.h" void _celt_lpc( - opus_val16 *_lpc, /* out: [0...p-1] LPC coefficients */ -const opus_val32 *ac, /* in: [0...p] autocorrelation values */ + oac_val16 *_lpc, /* out: [0...p-1] LPC coefficients */ +const oac_val32 *ac, /* in: [0...p] autocorrelation values */ int p ) { int i, j; - opus_val32 r; - opus_val32 error = ac[0]; + oac_val32 r; + oac_val32 error = ac[0]; #ifdef FIXED_POINT - opus_val32 lpc[CELT_LPC_ORDER]; + oac_val32 lpc[CELT_LPC_ORDER]; #else float *lpc = _lpc; #endif - OPUS_CLEAR(lpc, p); + OAC_CLEAR(lpc, p); #ifdef FIXED_POINT if (ac[0] != 0) #else @@ -58,12 +58,12 @@ int p { for (i = 0; i < p; i++) { /* Sum up this iteration's reflection coefficient */ - opus_val32 rr = 0; -#if defined (FIXED_POINT) && OPUS_FAST_INT64 - opus_int64 acc = 0; + oac_val32 rr = 0; +#if defined (FIXED_POINT) && OAC_FAST_INT64 + oac_int64 acc = 0; for (j = 0; j < i; j++) - acc += (opus_int64)(lpc[j]) * (opus_int64)(ac[i - j]); - rr = (opus_val32)SHR64(acc, 31); + acc += (oac_int64)(lpc[j]) * (oac_int64)(ac[i - j]); + rr = (oac_val32)SHR64(acc, 31); #else for (j = 0; j < i; j++) rr += MULT32_32_Q31(lpc[j],ac[i - j]); @@ -74,7 +74,7 @@ int p lpc[i] = SHR32(r,6); for (j = 0; j < (i+1)>>1; j++) { - opus_val32 tmp1, tmp2; + oac_val32 tmp1, tmp2; tmp1 = lpc[j]; tmp2 = lpc[i-1-j]; lpc[j] = tmp1 + MULT32_32_Q31(r,tmp2); @@ -98,7 +98,7 @@ int p This reuses the logic in silk_LPC_fit() and silk_bwexpander_32(). Any bug fixes should also be applied there. */ int iter, idx = 0; - opus_val32 maxabs, absval, chirp_Q16, chirp_minus_one_Q16; + oac_val32 maxabs, absval, chirp_Q16, chirp_minus_one_Q16; for (iter = 0; iter < 10; iter++) { maxabs = 0; @@ -131,7 +131,7 @@ int p if (iter == 10) { /* If the coeffs still do not fit into the 16 bit range after 10 iterations, fall back to the A(z)=1 filter. */ - OPUS_CLEAR(lpc, p); + OAC_CLEAR(lpc, p); _lpc[0] = 4096; /* Q12 */ } else { for (i = 0; i < p; i++) { @@ -144,35 +144,35 @@ int p void celt_fir_c( - const opus_val16 *x, - const opus_val16 *num, - opus_val16 *y, + const oac_val16 *x, + const oac_val16 *num, + oac_val16 *y, int N, int ord, int arch) { int i,j; - VARDECL(opus_val16, rnum); + VARDECL(oac_val16, rnum); SAVE_STACK; celt_assert(x != y); - ALLOC(rnum, ord, opus_val16); + ALLOC(rnum, ord, oac_val16); for(i=0;i0); celt_assert(overlap>=0); if (overlap == 0) @@ -309,7 +309,7 @@ int _celt_autocorr( xx[i] = x[i]; for (i=0;i>4)); ac0 = 1+(n<<7); if (n&1) ac0 += SHR32(MULT16_16(xptr[0],xptr[0]),ac0_shift); @@ -351,7 +351,7 @@ int _celt_autocorr( #ifdef FIXED_POINT shift = 2*shift; if (shift<=0) - ac[0] += SHL32((opus_int32)1, -shift); + ac[0] += SHL32((oac_int32)1, -shift); if (ac[0] < 268435456) { int shift2 = 29 - EC_ILOG(ac[0]); diff --git a/celt/celt_lpc.h b/celt/celt_lpc.h index e7109465f..e3f5fce7c 100644 --- a/celt/celt_lpc.h +++ b/celt/celt_lpc.h @@ -31,18 +31,18 @@ #include "arch.h" #include "cpu_support.h" -#if defined(OPUS_X86_MAY_HAVE_SSE4_1) +#if defined(OAC_X86_MAY_HAVE_SSE4_1) #include "x86/celt_lpc_sse.h" #endif #define CELT_LPC_ORDER 24 -void _celt_lpc(opus_val16 *_lpc, const opus_val32 *ac, int p); +void _celt_lpc(oac_val16 *_lpc, const oac_val32 *ac, int p); void celt_fir_c( - const opus_val16 *x, - const opus_val16 *num, - opus_val16 *y, + const oac_val16 *x, + const oac_val16 *num, + oac_val16 *y, int N, int ord, int arch); @@ -52,15 +52,15 @@ void celt_fir_c( (celt_fir_c(x, num, y, N, ord, arch)) #endif -void celt_iir(const opus_val32 *x, - const opus_val16 *den, - opus_val32 *y, +void celt_iir(const oac_val32 *x, + const oac_val16 *den, + oac_val32 *y, int N, int ord, - opus_val16 *mem, + oac_val16 *mem, int arch); -int _celt_autocorr(const opus_val16 *x, opus_val32 *ac, +int _celt_autocorr(const oac_val16 *x, oac_val32 *ac, const celt_coef *window, int overlap, int lag, int n, int arch); #endif /* CELT_LPC_H */ diff --git a/celt/cpu_support.h b/celt/cpu_support.h index 9f13d8aec..0de39cd65 100644 --- a/celt/cpu_support.h +++ b/celt/cpu_support.h @@ -28,11 +28,11 @@ #ifndef CPU_SUPPORT_H #define CPU_SUPPORT_H -#include "opus_types.h" -#include "opus_defines.h" +#include "oac_types.h" +#include "oac_defines.h" -#if defined(OPUS_HAVE_RTCD) && \ - (defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) +#if defined(OAC_HAVE_RTCD) && \ + (defined(OAC_ARM_ASM) || defined(OAC_ARM_MAY_HAVE_NEON_INTR)) #include "arm/armcpu.h" /* We currently support 5 ARM variants: @@ -42,13 +42,13 @@ * arch[3] -> NEON * arch[4] -> NEON+DOTPROD */ -#define OPUS_ARCHMASK 7 +#define OAC_ARCHMASK 7 -#elif defined(OPUS_HAVE_RTCD) && \ - ((defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE)) || \ - (defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) || \ - (defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \ - (defined(OPUS_X86_MAY_HAVE_AVX2) && !defined(OPUS_X86_PRESUME_AVX2))) +#elif defined(OAC_HAVE_RTCD) && \ + ((defined(OAC_X86_MAY_HAVE_SSE) && !defined(OAC_X86_PRESUME_SSE)) || \ + (defined(OAC_X86_MAY_HAVE_SSE2) && !defined(OAC_X86_PRESUME_SSE2)) || \ + (defined(OAC_X86_MAY_HAVE_SSE4_1) && !defined(OAC_X86_PRESUME_SSE4_1)) || \ + (defined(OAC_X86_MAY_HAVE_AVX2) && !defined(OAC_X86_PRESUME_AVX2))) #include "x86/x86cpu.h" /* We currently support 5 x86 variants: @@ -58,13 +58,13 @@ * arch[3] -> sse4.1 * arch[4] -> avx */ -#define OPUS_ARCHMASK 7 -int opus_select_arch(void); +#define OAC_ARCHMASK 7 +int oac_select_arch(void); #else -#define OPUS_ARCHMASK 0 +#define OAC_ARCHMASK 0 -static OPUS_INLINE int opus_select_arch(void) +static OAC_INLINE int oac_select_arch(void) { return 0; } diff --git a/celt/cwrs.c b/celt/cwrs.c index 18fa554e5..c763ea44a 100644 --- a/celt/cwrs.c +++ b/celt/cwrs.c @@ -46,7 +46,7 @@ with frac bits of fractional precision. Tested for all possible 32-bit inputs with frac=4, where the maximum overestimation is 0.06254243 bits.*/ -int log2_frac(opus_uint32 val, int frac) +int log2_frac(oac_uint32 val, int frac) { int l; l=EC_ILOG(val); @@ -207,14 +207,14 @@ int log2_frac(opus_uint32 val, int frac) pulses we will ever allocate for a given N=I (K=128, or however many fit in 32 bits, whichever is smaller), plus one, and the maximum N for which K=I-1 pulses fit in 32 bits. - The largest band size in an Opus Custom mode is 208. + The largest band size in an Oac Custom mode is 208. Otherwise, we can limit things to the set of N which can be achieved by - splitting a band from a standard Opus mode: 176, 144, 96, 88, 72, 64, 48, + splitting a band from a standard Oac mode: 176, 144, 96, 88, 72, 64, 48, 44, 36, 32, 24, 22, 18, 16, 8, 4, 2).*/ #if defined(CWRS_EXTRA_ROWS) -static const opus_uint32 CELT_PVQ_U_DATA[1488]={ +static const oac_uint32 CELT_PVQ_U_DATA[1488]={ #else -static const opus_uint32 CELT_PVQ_U_DATA[1272]={ +static const oac_uint32 CELT_PVQ_U_DATA[1272]={ #endif /*N=0, K=0...176:*/ 1, 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, @@ -414,7 +414,7 @@ static const opus_uint32 CELT_PVQ_U_DATA[1272]={ }; #if defined(CWRS_EXTRA_ROWS) -static const opus_uint32 *const CELT_PVQ_U_ROW[15]={ +static const oac_uint32 *const CELT_PVQ_U_ROW[15]={ CELT_PVQ_U_DATA+ 0,CELT_PVQ_U_DATA+ 208,CELT_PVQ_U_DATA+ 415, CELT_PVQ_U_DATA+ 621,CELT_PVQ_U_DATA+ 826,CELT_PVQ_U_DATA+1030, CELT_PVQ_U_DATA+1233,CELT_PVQ_U_DATA+1336,CELT_PVQ_U_DATA+1389, @@ -422,7 +422,7 @@ static const opus_uint32 *const CELT_PVQ_U_ROW[15]={ CELT_PVQ_U_DATA+1464,CELT_PVQ_U_DATA+1470,CELT_PVQ_U_DATA+1473 }; #else -static const opus_uint32 *const CELT_PVQ_U_ROW[15]={ +static const oac_uint32 *const CELT_PVQ_U_ROW[15]={ CELT_PVQ_U_DATA+ 0,CELT_PVQ_U_DATA+ 176,CELT_PVQ_U_DATA+ 351, CELT_PVQ_U_DATA+ 525,CELT_PVQ_U_DATA+ 698,CELT_PVQ_U_DATA+ 870, CELT_PVQ_U_DATA+1041,CELT_PVQ_U_DATA+1131,CELT_PVQ_U_DATA+1178, @@ -432,7 +432,7 @@ static const opus_uint32 *const CELT_PVQ_U_ROW[15]={ #endif #if defined(CUSTOM_MODES) -void get_required_bits(opus_int16 *_bits,int _n,int _maxk,int _frac){ +void get_required_bits(oac_int16 *_bits,int _n,int _maxk,int _frac){ int k; /*_maxk==0 => there's nothing to do.*/ celt_assert(_maxk>0); @@ -441,8 +441,8 @@ void get_required_bits(opus_int16 *_bits,int _n,int _maxk,int _frac){ } #endif -static opus_uint32 icwrs(int _n,const int *_y){ - opus_uint32 i; +static oac_uint32 icwrs(int _n,const int *_y){ + oac_uint32 i; int j; int k; celt_assert(_n>=2); @@ -464,19 +464,19 @@ void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){ ec_enc_uint(_enc,icwrs(_n,_y),CELT_PVQ_V(_n,_k)); } -static opus_val32 cwrsi(int _n,int _k,opus_uint32 _i,int *_y){ - opus_uint32 p; +static oac_val32 cwrsi(int _n,int _k,oac_uint32 _i,int *_y){ + oac_uint32 p; int s; int k0; - opus_int16 val; - opus_val32 yy=0; + oac_int16 val; + oac_val32 yy=0; celt_assert(_k>0); celt_assert(_n>1); while(_n>2){ - opus_uint32 q; + oac_uint32 q; /*Lots of pulses case:*/ if(_k>=_n){ - const opus_uint32 *row; + const oac_uint32 *row; row=CELT_PVQ_U_ROW[_n]; /*Are the pulses in this dimension negative?*/ p=row[_k+1]; @@ -540,7 +540,7 @@ static opus_val32 cwrsi(int _n,int _k,opus_uint32 _i,int *_y){ return yy; } -opus_val32 decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ +oac_val32 decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ return cwrsi(_n,_k,ec_dec_uint(_dec,CELT_PVQ_V(_n,_k)),_y); } @@ -549,8 +549,8 @@ opus_val32 decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ /*Computes the next row/column of any recurrence that obeys the relation u[i][j]=u[i-1][j]+u[i][j-1]+u[i-1][j-1]. _ui0 is the base case for the new row/column.*/ -static OPUS_INLINE void unext(opus_uint32 *_ui,unsigned _len,opus_uint32 _ui0){ - opus_uint32 ui1; +static OAC_INLINE void unext(oac_uint32 *_ui,unsigned _len,oac_uint32 _ui0){ + oac_uint32 ui1; unsigned j; /*This do-while will overrun the array if we don't have storage for at least 2 values.*/ @@ -565,8 +565,8 @@ static OPUS_INLINE void unext(opus_uint32 *_ui,unsigned _len,opus_uint32 _ui0){ /*Computes the previous row/column of any recurrence that obeys the relation u[i-1][j]=u[i][j]-u[i][j-1]-u[i-1][j-1]. _ui0 is the base case for the new row/column.*/ -static OPUS_INLINE void uprev(opus_uint32 *_ui,unsigned _n,opus_uint32 _ui0){ - opus_uint32 ui1; +static OAC_INLINE void uprev(oac_uint32 *_ui,unsigned _n,oac_uint32 _ui0){ + oac_uint32 ui1; unsigned j; /*This do-while will overrun the array if we don't have storage for at least 2 values.*/ @@ -580,8 +580,8 @@ static OPUS_INLINE void uprev(opus_uint32 *_ui,unsigned _n,opus_uint32 _ui0){ /*Compute V(_n,_k), as well as U(_n,0..._k+1). _u: On exit, _u[i] contains U(_n,i) for i in [0..._k+1].*/ -static opus_uint32 ncwrs_urow(unsigned _n,unsigned _k,opus_uint32 *_u){ - opus_uint32 um2; +static oac_uint32 ncwrs_urow(unsigned _n,unsigned _k,oac_uint32 *_u){ + oac_uint32 um2; unsigned len; unsigned k; len=_k+2; @@ -606,14 +606,14 @@ static opus_uint32 ncwrs_urow(unsigned _n,unsigned _k,opus_uint32 *_u){ _y: Returns the vector of pulses. _u: Must contain entries [0..._k+1] of row _n of U() on input. Its contents will be destructively modified.*/ -static opus_val32 cwrsi(int _n,int _k,opus_uint32 _i,int *_y,opus_uint32 *_u){ +static oac_val32 cwrsi(int _n,int _k,oac_uint32 _i,int *_y,oac_uint32 *_u){ int j; - opus_int16 val; - opus_val32 yy=0; + oac_int16 val; + oac_val32 yy=0; celt_assert(_n>0); j=0; do{ - opus_uint32 p; + oac_uint32 p; int s; int yj; p=_u[_k+1]; @@ -637,7 +637,7 @@ static opus_val32 cwrsi(int _n,int _k,opus_uint32 _i,int *_y,opus_uint32 *_u){ of size 1 with associated sign bits. _y: The vector of pulses, whose sum of absolute values is K. _k: Returns K.*/ -static OPUS_INLINE opus_uint32 icwrs1(const int *_y,int *_k){ +static OAC_INLINE oac_uint32 icwrs1(const int *_y,int *_k){ *_k=abs(_y[0]); return _y[0]<0; } @@ -646,9 +646,9 @@ static OPUS_INLINE opus_uint32 icwrs1(const int *_y,int *_k){ of size _n with associated sign bits. _y: The vector of pulses, whose sum of absolute values must be _k. _nc: Returns V(_n,_k).*/ -static OPUS_INLINE opus_uint32 icwrs(int _n,int _k,opus_uint32 *_nc,const int *_y, - opus_uint32 *_u){ - opus_uint32 i; +static OAC_INLINE oac_uint32 icwrs(int _n,int _k,oac_uint32 *_nc,const int *_y, + oac_uint32 *_u){ + oac_uint32 i; int j; int k; /*We can't unroll the first two iterations of the loop unless _n>=2.*/ @@ -671,7 +671,7 @@ static OPUS_INLINE opus_uint32 icwrs(int _n,int _k,opus_uint32 *_nc,const int *_ } #if defined(CUSTOM_MODES) -void get_required_bits(opus_int16 *_bits,int _n,int _maxk,int _frac){ +void get_required_bits(oac_int16 *_bits,int _n,int _maxk,int _frac){ int k; /*_maxk==0 => there's nothing to do.*/ celt_assert(_maxk>0); @@ -682,9 +682,9 @@ void get_required_bits(opus_int16 *_bits,int _n,int _maxk,int _frac){ _bits[k] = 1<<_frac; } else { - VARDECL(opus_uint32,u); + VARDECL(oac_uint32,u); SAVE_STACK; - ALLOC(u,_maxk+2U,opus_uint32); + ALLOC(u,_maxk+2U,oac_uint32); ncwrs_urow(_n,_maxk,u); for(k=1;k<=_maxk;k++) _bits[k]=log2_frac(u[k]+u[k+1],_frac); @@ -694,23 +694,23 @@ void get_required_bits(opus_int16 *_bits,int _n,int _maxk,int _frac){ #endif /* CUSTOM_MODES */ void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){ - opus_uint32 i; - VARDECL(opus_uint32,u); - opus_uint32 nc; + oac_uint32 i; + VARDECL(oac_uint32,u); + oac_uint32 nc; SAVE_STACK; celt_assert(_k>0); - ALLOC(u,_k+2U,opus_uint32); + ALLOC(u,_k+2U,oac_uint32); i=icwrs(_n,_k,&nc,_y,u); ec_enc_uint(_enc,i,nc); RESTORE_STACK; } -opus_val32 decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ - VARDECL(opus_uint32,u); +oac_val32 decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ + VARDECL(oac_uint32,u); int ret; SAVE_STACK; celt_assert(_k>0); - ALLOC(u,_k+2U,opus_uint32); + ALLOC(u,_k+2U,oac_uint32); ret = cwrsi(_n,_k,ec_dec_uint(_dec,ncwrs_urow(_n,_k,u)),_y,u); RESTORE_STACK; return ret; diff --git a/celt/cwrs.h b/celt/cwrs.h index 7cd471745..b7322fa17 100644 --- a/celt/cwrs.h +++ b/celt/cwrs.h @@ -36,13 +36,13 @@ #include "entdec.h" #ifdef CUSTOM_MODES -int log2_frac(opus_uint32 val, int frac); +int log2_frac(oac_uint32 val, int frac); #endif -void get_required_bits(opus_int16 *bits, int N, int K, int frac); +void get_required_bits(oac_int16 *bits, int N, int K, int frac); void encode_pulses(const int *_y, int N, int K, ec_enc *enc); -opus_val32 decode_pulses(int *_y, int N, int K, ec_dec *dec); +oac_val32 decode_pulses(int *_y, int N, int K, ec_dec *dec); #endif /* CWRS_H */ diff --git a/celt/dump_modes/Makefile b/celt/dump_modes/Makefile index 9bd13b07d..2d67b6352 100644 --- a/celt/dump_modes/Makefile +++ b/celt/dump_modes/Makefile @@ -17,7 +17,7 @@ SOURCES = dump_modes.c \ ifdef HAVE_ARM_NE10 CC = gcc CFLAGS += -mfpu=neon -INCLUDES += -I$(NE10_INCDIR) -DHAVE_ARM_NE10 -DOPUS_ARM_PRESUME_NEON_INTR +INCLUDES += -I$(NE10_INCDIR) -DHAVE_ARM_NE10 -DOAC_ARM_PRESUME_NEON_INTR LIBS = -L$(NE10_LIBDIR) -lNE10 SOURCES += ../arm/celt_ne10_fft.c \ dump_modes_arm_ne10.c \ diff --git a/celt/dump_modes/dump_modes.c b/celt/dump_modes/dump_modes.c index 7bf845fd5..a61fb0958 100644 --- a/celt/dump_modes/dump_modes.c +++ b/celt/dump_modes/dump_modes.c @@ -49,8 +49,8 @@ #define WORD32 FLOAT #endif -#define COEF16(x, a) ((opus_int16)SATURATE(((opus_int64)(x)+(1<<(a)>>1))>>(a), 32767)) -int opus_select_arch(void) { +#define COEF16(x, a) ((oac_int16)SATURATE(((oac_int64)(x)+(1<<(a)>>1))>>(a), 32767)) +int oac_select_arch(void) { return 0; } @@ -82,14 +82,14 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) int standard, framerate; mdctSize = mode->shortMdctSize*mode->nbShortMdcts; - standard = (mode->Fs == 400*(opus_int32)mode->shortMdctSize); + standard = (mode->Fs == 400*(oac_int32)mode->shortMdctSize); framerate = mode->Fs/mode->shortMdctSize; if (!standard) { fprintf(file, "#ifndef DEF_EBANDS%d_%d\n", mode->Fs, mdctSize); fprintf(file, "#define DEF_EBANDS%d_%d\n", mode->Fs, mdctSize); - fprintf (file, "static const opus_int16 eBands%d_%d[%d] = {\n", mode->Fs, mdctSize, mode->nbEBands+2); + fprintf (file, "static const oac_int16 eBands%d_%d[%d] = {\n", mode->Fs, mdctSize, mode->nbEBands+2); for (j=0;jnbEBands+2;j++) fprintf (file, "%d, ", mode->eBands[j]); fprintf (file, "};\n"); @@ -124,7 +124,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) fprintf(file, "#ifndef DEF_LOGN%d\n", framerate); fprintf(file, "#define DEF_LOGN%d\n", framerate); - fprintf (file, "static const opus_int16 logN%d[%d] = {\n", framerate, mode->nbEBands); + fprintf (file, "static const oac_int16 logN%d[%d] = {\n", framerate, mode->nbEBands); for (j=0;jnbEBands;j++) fprintf (file, "%d, ", mode->logN[j]); fprintf (file, "};\n"); @@ -134,7 +134,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) /* Pulse cache */ fprintf(file, "#ifndef DEF_PULSE_CACHE%d\n", mode->Fs/mdctSize); fprintf(file, "#define DEF_PULSE_CACHE%d\n", mode->Fs/mdctSize); - fprintf (file, "static const opus_int16 cache_index%d[%d] = {\n", mode->Fs/mdctSize, (mode->maxLM+2)*mode->nbEBands); + fprintf (file, "static const oac_int16 cache_index%d[%d] = {\n", mode->Fs/mdctSize, (mode->maxLM+2)*mode->nbEBands); for (j=0;jnbEBands*(mode->maxLM+2);j++) fprintf (file, "%d,%c", mode->cache.index[j],(j+16)%15==0?'\n':' '); fprintf (file, "};\n"); @@ -168,7 +168,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) { fprintf(file, "#ifndef FFT_BITREV%d\n", mode->mdct.kfft[k]->nfft); fprintf(file, "#define FFT_BITREV%d\n", mode->mdct.kfft[k]->nfft); - fprintf (file, "static const opus_int16 fft_bitrev%d[%d] = {\n", + fprintf (file, "static const oac_int16 fft_bitrev%d[%d] = {\n", mode->mdct.kfft[k]->nfft, mode->mdct.kfft[k]->nfft); for (j=0;jmdct.kfft[k]->nfft;j++) fprintf (file, "%d,%c", mode->mdct.kfft[k]->bitrev[j],(j+16)%15==0?'\n':' '); @@ -338,7 +338,7 @@ int main(int argc, char **argv) int Fs, frame; Fs = atoi(argv[2*i+1]); frame = atoi(argv[2*i+2]); - m[i] = opus_custom_mode_create(Fs, frame, NULL); + m[i] = oac_custom_mode_create(Fs, frame, NULL); if (m[i]==NULL) { fprintf(stderr,"Error creating mode with Fs=%s, frame_size=%s\n", @@ -356,7 +356,7 @@ int main(int argc, char **argv) dump_modes_arch_finalize(); #endif for (i=0;i #include #include "arch.h" #if !defined(_ecintrin_H) # define _ecintrin_H (1) -/*Some specific platforms may have optimized intrinsic or OPUS_INLINE assembly +/*Some specific platforms may have optimized intrinsic or OAC_INLINE assembly versions of these functions which can substantially improve performance. We define macros for them to allow easy incorporation of these non-ANSI features.*/ @@ -85,7 +85,7 @@ static __inline int ec_bsr(unsigned long _x){ When we need to, it can be special cased.*/ # define EC_ILOG(_x) (EC_CLZ0-EC_CLZ(_x)) #else -int ec_ilog(opus_uint32 _v); +int ec_ilog(oac_uint32 _v); # define EC_ILOG(_x) (ec_ilog(_x)) #endif #endif diff --git a/celt/entcode.c b/celt/entcode.c index 70f32016e..3939dc6d3 100644 --- a/celt/entcode.c +++ b/celt/entcode.c @@ -35,10 +35,10 @@ #if !defined(EC_CLZ) /*This is a fallback for systems where we don't know how to access a BSR or CLZ instruction (see ecintrin.h). - If you are optimizing Opus on a new platform and it has a native CLZ or - BZR (e.g. cell, MIPS, x86, etc) then making it available to Opus will be + If you are optimizing Oac on a new platform and it has a native CLZ or + BZR (e.g. cell, MIPS, x86, etc) then making it available to Oac will be an easy performance win.*/ -int ec_ilog(opus_uint32 _v){ +int ec_ilog(oac_uint32 _v){ /*On a Pentium M, this branchless version tested as the fastest on 1,000,000,000 random 32-bit integers, edging out a similar version with branches, and a 256-entry LUT version.*/ @@ -66,12 +66,12 @@ int ec_ilog(opus_uint32 _v){ /* This is a faster version of ec_tell_frac() that takes advantage of the low (1/8 bit) resolution to use just a linear function followed by a lookup to determine the exact transition thresholds. */ -opus_uint32 ec_tell_frac(ec_ctx *_this){ +oac_uint32 ec_tell_frac(ec_ctx *_this){ static const unsigned correction[8] = {35733, 38967, 42495, 46340, 50535, 55109, 60097, 65535}; - opus_uint32 nbits; - opus_uint32 r; + oac_uint32 nbits; + oac_uint32 r; int l; unsigned b; nbits=_this->nbits_total< # include "ecintrin.h" -extern const opus_uint32 SMALL_DIV_TABLE[129]; +extern const oac_uint32 SMALL_DIV_TABLE[129]; -#ifdef OPUS_ARM_ASM +#ifdef OAC_ARM_ASM #define USE_SMALL_DIV_TABLE #endif /*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a larger type, you can speed up the decoder by using it here.*/ -typedef opus_uint32 ec_window; +typedef oac_uint32 ec_window; typedef struct ec_ctx ec_ctx; typedef struct ec_ctx ec_enc; typedef struct ec_ctx ec_dec; @@ -63,9 +63,9 @@ struct ec_ctx{ /*Buffered input/output.*/ unsigned char *buf; /*The size of the buffer.*/ - opus_uint32 storage; + oac_uint32 storage; /*The offset at which the last byte containing raw bits was read/written.*/ - opus_uint32 end_offs; + oac_uint32 end_offs; /*Bits that will be read from/written at the end.*/ ec_window end_window; /*Number of valid bits in end_window.*/ @@ -74,31 +74,31 @@ struct ec_ctx{ This does not include partial bits currently in the range coder.*/ int nbits_total; /*The offset at which the next range coder byte will be read/written.*/ - opus_uint32 offs; + oac_uint32 offs; /*The number of values in the current range.*/ - opus_uint32 rng; + oac_uint32 rng; /*In the decoder: the difference between the top of the current range and the input value, minus one. In the encoder: the low end of the current range.*/ - opus_uint32 val; + oac_uint32 val; /*In the decoder: the saved normalization factor from ec_decode(). In the encoder: the number of outstanding carry propagating symbols.*/ - opus_uint32 ext; + oac_uint32 ext; /*A buffered input/output symbol, awaiting carry propagation.*/ int rem; /*Nonzero if an error occurred.*/ int error; }; -static OPUS_INLINE opus_uint32 ec_range_bytes(ec_ctx *_this){ +static OAC_INLINE oac_uint32 ec_range_bytes(ec_ctx *_this){ return _this->offs; } -static OPUS_INLINE unsigned char *ec_get_buffer(ec_ctx *_this){ +static OAC_INLINE unsigned char *ec_get_buffer(ec_ctx *_this){ return _this->buf; } -static OPUS_INLINE int ec_get_error(ec_ctx *_this){ +static OAC_INLINE int ec_get_error(ec_ctx *_this){ return _this->error; } @@ -108,7 +108,7 @@ static OPUS_INLINE int ec_get_error(ec_ctx *_this){ Return: The number of bits. This will always be slightly larger than the exact value (e.g., all rounding error is in the positive direction).*/ -static OPUS_INLINE int ec_tell(ec_ctx *_this){ +static OAC_INLINE int ec_tell(ec_ctx *_this){ return _this->nbits_total-EC_ILOG(_this->rng); } @@ -118,18 +118,18 @@ static OPUS_INLINE int ec_tell(ec_ctx *_this){ Return: The number of bits scaled by 2**BITRES. This will always be slightly larger than the exact value (e.g., all rounding error is in the positive direction).*/ -opus_uint32 ec_tell_frac(ec_ctx *_this); +oac_uint32 ec_tell_frac(ec_ctx *_this); /* Tested exhaustively for all n and for 1<=d<=256 */ -static OPUS_INLINE opus_uint32 celt_udiv(opus_uint32 n, opus_uint32 d) { +static OAC_INLINE oac_uint32 celt_udiv(oac_uint32 n, oac_uint32 d) { celt_sig_assert(d>0); #ifdef USE_SMALL_DIV_TABLE if (d>256) return n/d; else { - opus_uint32 t, q; + oac_uint32 t, q; t = EC_ILOG(d&-d); - q = (opus_uint64)SMALL_DIV_TABLE[d>>t]*(n>>(t-1))>>32; + q = (oac_uint64)SMALL_DIV_TABLE[d>>t]*(n>>(t-1))>>32; return q+(n-q*d >= d); } #else @@ -137,11 +137,11 @@ static OPUS_INLINE opus_uint32 celt_udiv(opus_uint32 n, opus_uint32 d) { #endif } -static OPUS_INLINE opus_int32 celt_sudiv(opus_int32 n, opus_int32 d) { +static OAC_INLINE oac_int32 celt_sudiv(oac_int32 n, oac_int32 d) { celt_sig_assert(d>0); #ifdef USE_SMALL_DIV_TABLE if (n<0) - return -(opus_int32)celt_udiv(-n, d); + return -(oac_int32)celt_udiv(-n, d); else return celt_udiv(n, d); #else diff --git a/celt/entdec.c b/celt/entdec.c index 027aa24bc..b3da1a0ed 100644 --- a/celt/entdec.c +++ b/celt/entdec.c @@ -116,7 +116,7 @@ static void ec_dec_normalize(ec_dec *_this){ } } -void ec_dec_init(ec_dec *_this,unsigned char *_buf,opus_uint32 _storage){ +void ec_dec_init(ec_dec *_this,unsigned char *_buf,oac_uint32 _storage){ _this->buf=_buf; _this->storage=_storage; _this->end_offs=0; @@ -151,7 +151,7 @@ unsigned ec_decode_bin(ec_dec *_this,unsigned _bits){ } void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,unsigned _ft){ - opus_uint32 s; + oac_uint32 s; s=IMUL32(_this->ext,_ft-_fh); _this->val-=s; _this->rng=_fl>0?IMUL32(_this->ext,_fh-_fl):_this->rng-s; @@ -160,9 +160,9 @@ void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,unsigned _ft){ /*The probability of having a "one" is 1/(1<<_logp).*/ int ec_dec_bit_logp(ec_dec *_this,unsigned _logp){ - opus_uint32 r; - opus_uint32 d; - opus_uint32 s; + oac_uint32 r; + oac_uint32 d; + oac_uint32 s; int ret; r=_this->rng; d=_this->val; @@ -175,10 +175,10 @@ int ec_dec_bit_logp(ec_dec *_this,unsigned _logp){ } int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb){ - opus_uint32 r; - opus_uint32 d; - opus_uint32 s; - opus_uint32 t; + oac_uint32 r; + oac_uint32 d; + oac_uint32 s; + oac_uint32 t; int ret; s=_this->rng; d=_this->val; @@ -195,11 +195,11 @@ int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb){ return ret; } -int ec_dec_icdf16(ec_dec *_this,const opus_uint16 *_icdf,unsigned _ftb){ - opus_uint32 r; - opus_uint32 d; - opus_uint32 s; - opus_uint32 t; +int ec_dec_icdf16(ec_dec *_this,const oac_uint16 *_icdf,unsigned _ftb){ + oac_uint32 r; + oac_uint32 d; + oac_uint32 s; + oac_uint32 t; int ret; s=_this->rng; d=_this->val; @@ -216,7 +216,7 @@ int ec_dec_icdf16(ec_dec *_this,const opus_uint16 *_icdf,unsigned _ftb){ return ret; } -opus_uint32 ec_dec_uint(ec_dec *_this,opus_uint32 _ft){ +oac_uint32 ec_dec_uint(ec_dec *_this,oac_uint32 _ft){ unsigned ft; unsigned s; int ftb; @@ -225,12 +225,12 @@ opus_uint32 ec_dec_uint(ec_dec *_this,opus_uint32 _ft){ _ft--; ftb=EC_ILOG(_ft); if(ftb>EC_UINT_BITS){ - opus_uint32 t; + oac_uint32 t; ftb-=EC_UINT_BITS; ft=(unsigned)(_ft>>ftb)+1; s=ec_decode(_this,ft); ec_dec_update(_this,s,s+1,ft); - t=(opus_uint32)s<error=1; return _ft; @@ -243,10 +243,10 @@ opus_uint32 ec_dec_uint(ec_dec *_this,opus_uint32 _ft){ } } -opus_uint32 ec_dec_bits(ec_dec *_this,unsigned _bits){ +oac_uint32 ec_dec_bits(ec_dec *_this,unsigned _bits){ ec_window window; int available; - opus_uint32 ret; + oac_uint32 ret; window=_this->end_window; available=_this->nend_bits; if((unsigned)available<_bits){ @@ -256,7 +256,7 @@ opus_uint32 ec_dec_bits(ec_dec *_this,unsigned _bits){ } while(available<=EC_WINDOW_SIZE-EC_SYM_BITS); } - ret=(opus_uint32)window&(((opus_uint32)1<<_bits)-1U); + ret=(oac_uint32)window&(((oac_uint32)1<<_bits)-1U); window>>=_bits; available-=_bits; _this->end_window=window; diff --git a/celt/entdec.h b/celt/entdec.h index c81f26fdb..beceab235 100644 --- a/celt/entdec.h +++ b/celt/entdec.h @@ -33,7 +33,7 @@ /*Initializes the decoder. _buf: The input buffer to use. Return: 0 on success, or a negative value on error.*/ -void ec_dec_init(ec_dec *_this,unsigned char *_buf,opus_uint32 _storage); +void ec_dec_init(ec_dec *_this,unsigned char *_buf,oac_uint32 _storage); /*Calculates the cumulative frequency for the next symbol. This can then be fed into the probability model to determine what that @@ -89,7 +89,7 @@ int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb); must be 0. _ftb: The number of bits of precision in the cumulative distribution. Return: The decoded symbol s.*/ -int ec_dec_icdf16(ec_dec *_this,const opus_uint16 *_icdf,unsigned _ftb); +int ec_dec_icdf16(ec_dec *_this,const oac_uint16 *_icdf,unsigned _ftb); /*Extracts a raw unsigned integer with a non-power-of-2 range from the stream. The bits must have been encoded with ec_enc_uint(). @@ -97,7 +97,7 @@ int ec_dec_icdf16(ec_dec *_this,const opus_uint16 *_icdf,unsigned _ftb); _ft: The number of integers that can be decoded (one more than the max). This must be at least 2, and no more than 2**32-1. Return: The decoded bits.*/ -opus_uint32 ec_dec_uint(ec_dec *_this,opus_uint32 _ft); +oac_uint32 ec_dec_uint(ec_dec *_this,oac_uint32 _ft); /*Extracts a sequence of raw bits from the stream. The bits must have been encoded with ec_enc_bits(). @@ -105,6 +105,6 @@ opus_uint32 ec_dec_uint(ec_dec *_this,opus_uint32 _ft); _ftb: The number of bits to extract. This must be between 0 and 25, inclusive. Return: The decoded bits.*/ -opus_uint32 ec_dec_bits(ec_dec *_this,unsigned _ftb); +oac_uint32 ec_dec_bits(ec_dec *_this,unsigned _ftb); #endif diff --git a/celt/entenc.c b/celt/entenc.c index ede00c848..da69c3c0b 100644 --- a/celt/entenc.c +++ b/celt/entenc.c @@ -98,7 +98,7 @@ static void ec_enc_carry_out(ec_enc *_this,int _c){ else _this->ext++; } -static OPUS_INLINE void ec_enc_normalize(ec_enc *_this){ +static OAC_INLINE void ec_enc_normalize(ec_enc *_this){ /*If the range is too small, output some bits and rescale it.*/ while(_this->rng<=EC_CODE_BOT){ ec_enc_carry_out(_this,(int)(_this->val>>EC_CODE_SHIFT)); @@ -109,7 +109,7 @@ static OPUS_INLINE void ec_enc_normalize(ec_enc *_this){ } } -void ec_enc_init(ec_enc *_this,unsigned char *_buf,opus_uint32 _size){ +void ec_enc_init(ec_enc *_this,unsigned char *_buf,oac_uint32 _size){ _this->buf=_buf; _this->end_offs=0; _this->end_window=0; @@ -126,7 +126,7 @@ void ec_enc_init(ec_enc *_this,unsigned char *_buf,opus_uint32 _size){ } void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){ - opus_uint32 r; + oac_uint32 r; r=celt_udiv(_this->rng,_ft); if(_fl>0){ _this->val+=_this->rng-IMUL32(r,(_ft-_fl)); @@ -137,7 +137,7 @@ void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){ } void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits){ - opus_uint32 r; + oac_uint32 r; r=_this->rng>>_bits; if(_fl>0){ _this->val+=_this->rng-IMUL32(r,((1U<<_bits)-_fl)); @@ -149,9 +149,9 @@ void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits){ /*The probability of having a "one" is 1/(1<<_logp).*/ void ec_enc_bit_logp(ec_enc *_this,int _val,unsigned _logp){ - opus_uint32 r; - opus_uint32 s; - opus_uint32 l; + oac_uint32 r; + oac_uint32 s; + oac_uint32 l; r=_this->rng; l=_this->val; s=r>>_logp; @@ -162,7 +162,7 @@ void ec_enc_bit_logp(ec_enc *_this,int _val,unsigned _logp){ } void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb){ - opus_uint32 r; + oac_uint32 r; r=_this->rng>>_ftb; if(_s>0){ _this->val+=_this->rng-IMUL32(r,_icdf[_s-1]); @@ -172,8 +172,8 @@ void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb){ ec_enc_normalize(_this); } -void ec_enc_icdf16(ec_enc *_this,int _s,const opus_uint16 *_icdf,unsigned _ftb){ - opus_uint32 r; +void ec_enc_icdf16(ec_enc *_this,int _s,const oac_uint16 *_icdf,unsigned _ftb){ + oac_uint32 r; r=_this->rng>>_ftb; if(_s>0){ _this->val+=_this->rng-IMUL32(r,_icdf[_s-1]); @@ -183,7 +183,7 @@ void ec_enc_icdf16(ec_enc *_this,int _s,const opus_uint16 *_icdf,unsigned _ftb){ ec_enc_normalize(_this); } -void ec_enc_uint(ec_enc *_this,opus_uint32 _fl,opus_uint32 _ft){ +void ec_enc_uint(ec_enc *_this,oac_uint32 _fl,oac_uint32 _ft){ unsigned ft; unsigned fl; int ftb; @@ -196,12 +196,12 @@ void ec_enc_uint(ec_enc *_this,opus_uint32 _fl,opus_uint32 _ft){ ft=(_ft>>ftb)+1; fl=(unsigned)(_fl>>ftb); ec_encode(_this,fl,fl+1,ft); - ec_enc_bits(_this,_fl&(((opus_uint32)1<end_window; @@ -238,16 +238,16 @@ void ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,unsigned _nbits){ } else if(_this->rng<=(EC_CODE_TOP>>_nbits)){ /*The renormalization loop has never been run.*/ - _this->val=(_this->val&~((opus_uint32)mask<val=(_this->val&~((oac_uint32)mask<error=-1; } -void ec_enc_shrink(ec_enc *_this,opus_uint32 _size){ +void ec_enc_shrink(ec_enc *_this,oac_uint32 _size){ celt_assert(_this->offs+_this->end_offs<=_size); - OPUS_MOVE(_this->buf+_size-_this->end_offs, + OAC_MOVE(_this->buf+_size-_this->end_offs, _this->buf+_this->storage-_this->end_offs,_this->end_offs); _this->storage=_size; } @@ -255,8 +255,8 @@ void ec_enc_shrink(ec_enc *_this,opus_uint32 _size){ void ec_enc_done(ec_enc *_this){ ec_window window; int used; - opus_uint32 msk; - opus_uint32 end; + oac_uint32 msk; + oac_uint32 end; int l; /*We output the minimum number of bits that ensures that the symbols encoded thus far will be decoded correctly regardless of the bits that follow.*/ @@ -285,7 +285,7 @@ void ec_enc_done(ec_enc *_this){ } /*Clear any excess space and add any remaining extra bits to the last byte.*/ if(!_this->error){ - if (_this->buf) OPUS_CLEAR(_this->buf+_this->offs, + if (_this->buf) OAC_CLEAR(_this->buf+_this->offs, _this->storage-_this->offs-_this->end_offs); if(used>0){ /*If there's no range coder data at all, give up.*/ diff --git a/celt/entenc.h b/celt/entenc.h index c7bcf006c..2937e63d5 100644 --- a/celt/entenc.h +++ b/celt/entenc.h @@ -33,7 +33,7 @@ /*Initializes the encoder. _buf: The buffer to store output bytes in. _size: The size of the buffer, in chars.*/ -void ec_enc_init(ec_enc *_this,unsigned char *_buf,opus_uint32 _size); +void ec_enc_init(ec_enc *_this,unsigned char *_buf,oac_uint32 _size); /*Encodes a symbol given its frequency information. The frequency information must be discernible by the decoder, assuming it has read only the previous symbols from the stream. @@ -71,19 +71,19 @@ void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb); The values must be monotonically non-increasing, and the last value must be 0. _ftb: The number of bits of precision in the cumulative distribution.*/ -void ec_enc_icdf16(ec_enc *_this,int _s,const opus_uint16 *_icdf,unsigned _ftb); +void ec_enc_icdf16(ec_enc *_this,int _s,const oac_uint16 *_icdf,unsigned _ftb); /*Encodes a raw unsigned integer in the stream. _fl: The integer to encode. _ft: The number of integers that can be encoded (one more than the max). This must be at least 2, and no more than 2**32-1.*/ -void ec_enc_uint(ec_enc *_this,opus_uint32 _fl,opus_uint32 _ft); +void ec_enc_uint(ec_enc *_this,oac_uint32 _fl,oac_uint32 _ft); /*Encodes a sequence of raw bits in the stream. _fl: The bits to encode. _ftb: The number of bits to encode. This must be between 1 and 25, inclusive.*/ -void ec_enc_bits(ec_enc *_this,opus_uint32 _fl,unsigned _ftb); +void ec_enc_bits(ec_enc *_this,oac_uint32 _fl,unsigned _ftb); /*Overwrites a few bits at the very start of an existing stream, after they have already been encoded. @@ -109,7 +109,7 @@ void ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,unsigned _nbits); _size: The number of bytes in the new buffer. This must be large enough to contain the bits already written, and must be no larger than the existing size.*/ -void ec_enc_shrink(ec_enc *_this,opus_uint32 _size); +void ec_enc_shrink(ec_enc *_this,oac_uint32 _size); /*Indicates that there are no more symbols to encode. All remaining output bytes are flushed to the output buffer. diff --git a/celt/fixed_c5x.h b/celt/fixed_c5x.h index ea95a998c..a7df95866 100644 --- a/celt/fixed_c5x.h +++ b/celt/fixed_c5x.h @@ -34,7 +34,7 @@ #include "dsplib.h" #undef IMUL32 -static OPUS_INLINE long IMUL32(long i, long j) +static OAC_INLINE long IMUL32(long i, long j) { long ac0, ac1; ac0 = _lmpy(i>>16,j); diff --git a/celt/fixed_debug.h b/celt/fixed_debug.h index 34c3646d6..d2861549e 100644 --- a/celt/fixed_debug.h +++ b/celt/fixed_debug.h @@ -33,19 +33,19 @@ #define FIXED_DEBUG_H #include -#include "opus_defines.h" +#include "oac_defines.h" #ifdef CELT_C -OPUS_EXPORT opus_int64 celt_mips=0; +OAC_EXPORT oac_int64 celt_mips=0; #else -extern opus_int64 celt_mips; +extern oac_int64 celt_mips; #endif -#define MULT16_16U(a,b) ((opus_uint32)(a)*(opus_uint32)(b)) -#define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(opus_uint16)(b)) +#define MULT16_16U(a,b) ((oac_uint32)(a)*(oac_uint32)(b)) +#define MULT16_16SU(a,b) ((oac_val32)(oac_val16)(a)*(oac_val32)(oac_uint16)(b)) #define MULT32_32_Q31(a,b) ADD32(ADD32(SHL32(MULT16_16(SHR32((a),16),SHR((b),16)),1), SHR32(MULT16_16SU(SHR32((a),16),((b)&0x0000ffff)),15)), SHR32(MULT16_16SU(SHR32((b),16),((a)&0x0000ffff)),15)) -#define MULT32_32_P31(a,b) ADD32(SHL32(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(opus_int32)(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff))>>(16+7)) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) ) -#define MULT32_32_P31_ovflw(a,b) ADD32_ovflw(SHL32(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(opus_int32)(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff))>>(16+7)) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) ) +#define MULT32_32_P31(a,b) ADD32(SHL32(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(oac_int32)(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff))>>(16+7)) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) ) +#define MULT32_32_P31_ovflw(a,b) ADD32_ovflw(SHL32(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(oac_int32)(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff))>>(16+7)) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) ) #define MULT32_32_Q32(a,b) ADD32(ADD32(MULT16_16(SHR((a),16),SHR((b),16)), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),16)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),16)) /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ @@ -53,8 +53,8 @@ extern opus_int64 celt_mips; #define MULT16_32_P16(a,b) MULT16_32_PX(a,b,16) -#define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits)))) -#define QCONST32(x,bits) ((opus_val32)(.5+(x)*(((opus_val64)1)<<(bits)))) +#define QCONST16(x,bits) ((oac_val16)(.5+(x)*(((oac_val32)1)<<(bits)))) +#define QCONST32(x,bits) ((oac_val32)(.5+(x)*(((oac_val64)1)<<(bits)))) #define GCONST2(x,bits) ((celt_glog)(.5+(x)*(((celt_glog)1)<<(bits)))) #define GCONST(x) GCONST2((x),DB_SHIFT) @@ -66,18 +66,18 @@ extern opus_int64 celt_mips; #define PSHR(a,b) PSHR32(a,b) /** Add two 32-bit values, ignore any overflows */ -#define ADD32_ovflw(a,b) (celt_mips+=2,(opus_val32)((opus_uint32)(a)+(opus_uint32)(b))) +#define ADD32_ovflw(a,b) (celt_mips+=2,(oac_val32)((oac_uint32)(a)+(oac_uint32)(b))) /** Subtract two 32-bit values, ignore any overflows */ -#define SUB32_ovflw(a,b) (celt_mips+=2,(opus_val32)((opus_uint32)(a)-(opus_uint32)(b))) +#define SUB32_ovflw(a,b) (celt_mips+=2,(oac_val32)((oac_uint32)(a)-(oac_uint32)(b))) /* Avoid MSVC warning C4146: unary minus operator applied to unsigned type */ /** Negate 32-bit value, ignore any overflows */ -#define NEG32_ovflw(a) (celt_mips+=2,(opus_val32)(0-(opus_uint32)(a))) +#define NEG32_ovflw(a) (celt_mips+=2,(oac_val32)(0-(oac_uint32)(a))) /** 32-bit shift left, ignoring overflows */ -#define SHL32_ovflw(a,shift) ((opus_int32)((opus_uint32)(a)<<(shift))) +#define SHL32_ovflw(a,shift) ((oac_int32)((oac_uint32)(a)<<(shift))) /** 32-bit arithmetic shift right with rounding-to-nearest, ignoring overflows */ #define PSHR32_ovflw(a,shift) (SHR32(ADD32_ovflw(a, (EXTEND32(1)<<(shift)>>1)),shift)) -static OPUS_INLINE short NEG16(int x) +static OAC_INLINE short NEG16(int x) { int res; if (!VERIFY_SHORT(x)) @@ -98,9 +98,9 @@ static OPUS_INLINE short NEG16(int x) celt_mips++; return res; } -static OPUS_INLINE int NEG32(opus_int64 x) +static OAC_INLINE int NEG32(oac_int64 x) { - opus_int64 res; + oac_int64 res; if (!VERIFY_INT(x)) { fprintf (stderr, "NEG16: input is not int: %d\n", (int)x); @@ -121,7 +121,7 @@ static OPUS_INLINE int NEG32(opus_int64 x) } #define EXTRACT16(x) EXTRACT16_(x, __FILE__, __LINE__) -static OPUS_INLINE short EXTRACT16_(int x, char *file, int line) +static OAC_INLINE short EXTRACT16_(int x, char *file, int line) { int res; if (!VERIFY_SHORT(x)) @@ -137,7 +137,7 @@ static OPUS_INLINE short EXTRACT16_(int x, char *file, int line) } #define EXTEND32(x) EXTEND32_(x, __FILE__, __LINE__) -static OPUS_INLINE int EXTEND32_(int x, char *file, int line) +static OAC_INLINE int EXTEND32_(int x, char *file, int line) { int res; if (!VERIFY_SHORT(x)) @@ -153,7 +153,7 @@ static OPUS_INLINE int EXTEND32_(int x, char *file, int line) } #define SHR16(a, shift) SHR16_(a, shift, __FILE__, __LINE__) -static OPUS_INLINE short SHR16_(int a, int shift, char *file, int line) +static OAC_INLINE short SHR16_(int a, int shift, char *file, int line) { int res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift)) @@ -175,9 +175,9 @@ static OPUS_INLINE short SHR16_(int a, int shift, char *file, int line) return res; } #define SHL16(a, shift) SHL16_(a, shift, __FILE__, __LINE__) -static OPUS_INLINE short SHL16_(int a, int shift, char *file, int line) +static OAC_INLINE short SHL16_(int a, int shift, char *file, int line) { - opus_int32 res; + oac_int32 res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift)) { fprintf (stderr, "SHL16: inputs are not short: %d %d in %s: line %d\n", a, shift, file, line); @@ -185,7 +185,7 @@ static OPUS_INLINE short SHL16_(int a, int shift, char *file, int line) celt_assert(0); #endif } - res = (opus_int32)((opus_uint32)a<>1))),shift)) +#define PSHR32(a,shift) (celt_mips--,SHR32(ADD32((a),(((oac_val32)(1)<<((shift))>>1))),shift)) #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) #define SHR64(a,shift) (celt_mips++,(a) >> (shift)) @@ -253,7 +253,7 @@ static OPUS_INLINE int SHL32_(opus_int64 a, int shift, char *file, int line) #define HALF32(x) (SHR32(x,1)) #define ADD16(a, b) ADD16_(a, b, __FILE__, __LINE__) -static OPUS_INLINE short ADD16_(int a, int b, char *file, int line) +static OAC_INLINE short ADD16_(int a, int b, char *file, int line) { int res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) @@ -276,7 +276,7 @@ static OPUS_INLINE short ADD16_(int a, int b, char *file, int line) } #define SUB16(a, b) SUB16_(a, b, __FILE__, __LINE__) -static OPUS_INLINE short SUB16_(int a, int b, char *file, int line) +static OAC_INLINE short SUB16_(int a, int b, char *file, int line) { int res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) @@ -299,9 +299,9 @@ static OPUS_INLINE short SUB16_(int a, int b, char *file, int line) } #define ADD32(a, b) ADD32_(a, b, __FILE__, __LINE__) -static OPUS_INLINE int ADD32_(opus_int64 a, opus_int64 b, char *file, int line) +static OAC_INLINE int ADD32_(oac_int64 a, oac_int64 b, char *file, int line) { - opus_int64 res; + oac_int64 res; if (!VERIFY_INT(a) || !VERIFY_INT(b)) { fprintf (stderr, "ADD32: inputs are not int: %d %d in %s: line %d\n", (int)a, (int)b, file, line); @@ -322,9 +322,9 @@ static OPUS_INLINE int ADD32_(opus_int64 a, opus_int64 b, char *file, int line) } #define SUB32(a, b) SUB32_(a, b, __FILE__, __LINE__) -static OPUS_INLINE int SUB32_(opus_int64 a, opus_int64 b, char *file, int line) +static OAC_INLINE int SUB32_(oac_int64 a, oac_int64 b, char *file, int line) { - opus_int64 res; + oac_int64 res; if (!VERIFY_INT(a) || !VERIFY_INT(b)) { fprintf (stderr, "SUB32: inputs are not int: %d %d in %s: line %d\n", (int)a, (int)b, file, line); @@ -346,9 +346,9 @@ static OPUS_INLINE int SUB32_(opus_int64 a, opus_int64 b, char *file, int line) #undef UADD32 #define UADD32(a, b) UADD32_(a, b, __FILE__, __LINE__) -static OPUS_INLINE unsigned int UADD32_(opus_uint64 a, opus_uint64 b, char *file, int line) +static OAC_INLINE unsigned int UADD32_(oac_uint64 a, oac_uint64 b, char *file, int line) { - opus_uint64 res; + oac_uint64 res; if (!VERIFY_UINT(a) || !VERIFY_UINT(b)) { fprintf (stderr, "UADD32: inputs are not uint32: %llu %llu in %s: line %d\n", (unsigned long long)a, (unsigned long long)b, file, line); @@ -370,9 +370,9 @@ static OPUS_INLINE unsigned int UADD32_(opus_uint64 a, opus_uint64 b, char *file #undef USUB32 #define USUB32(a, b) USUB32_(a, b, __FILE__, __LINE__) -static OPUS_INLINE unsigned int USUB32_(opus_uint64 a, opus_uint64 b, char *file, int line) +static OAC_INLINE unsigned int USUB32_(oac_uint64 a, oac_uint64 b, char *file, int line) { - opus_uint64 res; + oac_uint64 res; if (!VERIFY_UINT(a) || !VERIFY_UINT(b)) { fprintf (stderr, "USUB32: inputs are not uint32: %llu %llu in %s: line %d\n", (unsigned long long)a, (unsigned long long)b, file, line); @@ -400,7 +400,7 @@ static OPUS_INLINE unsigned int USUB32_(opus_uint64 a, opus_uint64 b, char *file } /* result fits in 16 bits */ -static OPUS_INLINE short MULT16_16_16(int a, int b) +static OAC_INLINE short MULT16_16_16(int a, int b) { int res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) @@ -423,9 +423,9 @@ static OPUS_INLINE short MULT16_16_16(int a, int b) } /* result fits in 32 bits */ -static OPUS_INLINE int MULT32_32_32(opus_int64 a, opus_int64 b) +static OAC_INLINE int MULT32_32_32(oac_int64 a, oac_int64 b) { - opus_int64 res; + oac_int64 res; if (!VERIFY_INT(a) || !VERIFY_INT(b)) { fprintf (stderr, "MULT32_32_32: inputs are not int: %lld %lld\n", (long long)a, (long long)b); @@ -445,9 +445,9 @@ static OPUS_INLINE int MULT32_32_32(opus_int64 a, opus_int64 b) return res; } -static OPUS_INLINE int MULT32_32_Q16(opus_int64 a, opus_int64 b) +static OAC_INLINE int MULT32_32_Q16(oac_int64 a, oac_int64 b) { - opus_int64 res; + oac_int64 res; if (!VERIFY_INT(a) || !VERIFY_INT(b)) { fprintf (stderr, "MULT32_32_Q16: inputs are not int: %lld %lld\n", (long long)a, (long long)b); @@ -455,7 +455,7 @@ static OPUS_INLINE int MULT32_32_Q16(opus_int64 a, opus_int64 b) celt_assert(0); #endif } - res = ((opus_int64)(a)*(opus_int64)(b)) >> 16; + res = ((oac_int64)(a)*(oac_int64)(b)) >> 16; if (!VERIFY_INT(res)) { fprintf (stderr, "MULT32_32_Q16: output is not int: %lld*%lld=%lld\n", (long long)a, (long long)b, (long long)res); @@ -468,9 +468,9 @@ static OPUS_INLINE int MULT32_32_Q16(opus_int64 a, opus_int64 b) } #define MULT16_16(a, b) MULT16_16_(a, b, __FILE__, __LINE__) -static OPUS_INLINE int MULT16_16_(int a, int b, char *file, int line) +static OAC_INLINE int MULT16_16_(int a, int b, char *file, int line) { - opus_int64 res; + oac_int64 res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { fprintf (stderr, "MULT16_16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); @@ -478,7 +478,7 @@ static OPUS_INLINE int MULT16_16_(int a, int b, char *file, int line) celt_assert(0); #endif } - res = ((opus_int64)a)*b; + res = ((oac_int64)a)*b; if (!VERIFY_INT(res)) { fprintf (stderr, "MULT16_16: output is not int: %d in %s: line %d\n", (int)res, file, line); @@ -493,9 +493,9 @@ static OPUS_INLINE int MULT16_16_(int a, int b, char *file, int line) #define MAC16_16(c,a,b) (celt_mips-=2,ADD32((c),MULT16_16((a),(b)))) #define MULT16_32_QX(a, b, Q) MULT16_32_QX_(a, b, Q, __FILE__, __LINE__) -static OPUS_INLINE int MULT16_32_QX_(int a, opus_int64 b, int Q, char *file, int line) +static OAC_INLINE int MULT16_32_QX_(int a, oac_int64 b, int Q, char *file, int line) { - opus_int64 res; + oac_int64 res; if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) { fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line); @@ -503,14 +503,14 @@ static OPUS_INLINE int MULT16_32_QX_(int a, opus_int64 b, int Q, char *file, int celt_assert(0); #endif } - if (ABS32(b)>=((opus_int64)(1)<<(16+Q))) + if (ABS32(b)>=((oac_int64)(1)<<(16+Q))) { fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line); #ifdef FIXED_DEBUG_ASSERT celt_assert(0); #endif } - res = (((opus_int64)a)*(opus_int64)b) >> Q; + res = (((oac_int64)a)*(oac_int64)b) >> Q; if (!VERIFY_INT(res)) { fprintf (stderr, "MULT16_32_Q%d: output is not int: %d*%d=%d in %s: line %d\n", Q, (int)a, (int)b,(int)res, file, line); @@ -526,9 +526,9 @@ static OPUS_INLINE int MULT16_32_QX_(int a, opus_int64 b, int Q, char *file, int } #define MULT16_32_PX(a, b, Q) MULT16_32_PX_(a, b, Q, __FILE__, __LINE__) -static OPUS_INLINE int MULT16_32_PX_(int a, opus_int64 b, int Q, char *file, int line) +static OAC_INLINE int MULT16_32_PX_(int a, oac_int64 b, int Q, char *file, int line) { - opus_int64 res; + oac_int64 res; if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) { fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d in %s: line %d\n\n", Q, (int)a, (int)b, file, line); @@ -536,14 +536,14 @@ static OPUS_INLINE int MULT16_32_PX_(int a, opus_int64 b, int Q, char *file, int celt_assert(0); #endif } - if (ABS32(b)>=((opus_int64)(1)<<(16+Q))) + if (ABS32(b)>=((oac_int64)(1)<<(16+Q))) { fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n\n", Q, (int)a, (int)b,file, line); #ifdef FIXED_DEBUG_ASSERT celt_assert(0); #endif } - res = ((((opus_int64)a)*(opus_int64)b) + (((opus_val32)(1)<>1))>> Q; + res = ((((oac_int64)a)*(oac_int64)b) + (((oac_val32)(1)<>1))>> Q; if (!VERIFY_INT(res)) { fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d in %s: line %d\n\n", Q, (int)a, (int)b,(int)res, file, line); @@ -562,7 +562,7 @@ static OPUS_INLINE int MULT16_32_PX_(int a, opus_int64 b, int Q, char *file, int #define MAC16_32_Q15(c,a,b) (celt_mips-=2,ADD32((c),MULT16_32_Q15((a),(b)))) #define MAC16_32_Q16(c,a,b) (celt_mips-=2,ADD32((c),MULT16_32_Q16((a),(b)))) -static OPUS_INLINE int SATURATE(int a, int b) +static OAC_INLINE int SATURATE(int a, int b) { if (a>b) a=b; @@ -572,7 +572,7 @@ static OPUS_INLINE int SATURATE(int a, int b) return a; } -static OPUS_INLINE opus_int16 SATURATE16(opus_int32 a) +static OAC_INLINE oac_int16 SATURATE16(oac_int32 a) { celt_mips+=3; if (a>32767) @@ -582,9 +582,9 @@ static OPUS_INLINE opus_int16 SATURATE16(opus_int32 a) else return a; } -static OPUS_INLINE int MULT16_16_Q11_32(int a, int b) +static OAC_INLINE int MULT16_16_Q11_32(int a, int b) { - opus_int64 res; + oac_int64 res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { fprintf (stderr, "MULT16_16_Q11: inputs are not short: %d %d\n", a, b); @@ -592,7 +592,7 @@ static OPUS_INLINE int MULT16_16_Q11_32(int a, int b) celt_assert(0); #endif } - res = ((opus_int64)a)*b; + res = ((oac_int64)a)*b; res >>= 11; if (!VERIFY_INT(res)) { @@ -604,9 +604,9 @@ static OPUS_INLINE int MULT16_16_Q11_32(int a, int b) celt_mips+=3; return res; } -static OPUS_INLINE short MULT16_16_Q13(int a, int b) +static OAC_INLINE short MULT16_16_Q13(int a, int b) { - opus_int64 res; + oac_int64 res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { fprintf (stderr, "MULT16_16_Q13: inputs are not short: %d %d\n", a, b); @@ -614,7 +614,7 @@ static OPUS_INLINE short MULT16_16_Q13(int a, int b) celt_assert(0); #endif } - res = ((opus_int64)a)*b; + res = ((oac_int64)a)*b; res >>= 13; if (!VERIFY_SHORT(res)) { @@ -626,9 +626,9 @@ static OPUS_INLINE short MULT16_16_Q13(int a, int b) celt_mips+=3; return res; } -static OPUS_INLINE short MULT16_16_Q14(int a, int b) +static OAC_INLINE short MULT16_16_Q14(int a, int b) { - opus_int64 res; + oac_int64 res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { fprintf (stderr, "MULT16_16_Q14: inputs are not short: %d %d\n", a, b); @@ -636,7 +636,7 @@ static OPUS_INLINE short MULT16_16_Q14(int a, int b) celt_assert(0); #endif } - res = ((opus_int64)a)*b; + res = ((oac_int64)a)*b; res >>= 14; if (!VERIFY_SHORT(res)) { @@ -650,9 +650,9 @@ static OPUS_INLINE short MULT16_16_Q14(int a, int b) } #define MULT16_16_Q15(a, b) MULT16_16_Q15_(a, b, __FILE__, __LINE__) -static OPUS_INLINE short MULT16_16_Q15_(int a, int b, char *file, int line) +static OAC_INLINE short MULT16_16_Q15_(int a, int b, char *file, int line) { - opus_int64 res; + oac_int64 res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); @@ -660,7 +660,7 @@ static OPUS_INLINE short MULT16_16_Q15_(int a, int b, char *file, int line) celt_assert(0); #endif } - res = ((opus_int64)a)*b; + res = ((oac_int64)a)*b; res >>= 15; if (!VERIFY_SHORT(res)) { @@ -673,9 +673,9 @@ static OPUS_INLINE short MULT16_16_Q15_(int a, int b, char *file, int line) return res; } -static OPUS_INLINE short MULT16_16_P13(int a, int b) +static OAC_INLINE short MULT16_16_P13(int a, int b) { - opus_int64 res; + oac_int64 res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { fprintf (stderr, "MULT16_16_P13: inputs are not short: %d %d\n", a, b); @@ -683,7 +683,7 @@ static OPUS_INLINE short MULT16_16_P13(int a, int b) celt_assert(0); #endif } - res = ((opus_int64)a)*b; + res = ((oac_int64)a)*b; res += 4096; if (!VERIFY_INT(res)) { @@ -703,9 +703,9 @@ static OPUS_INLINE short MULT16_16_P13(int a, int b) celt_mips+=4; return res; } -static OPUS_INLINE short MULT16_16_P14(int a, int b) +static OAC_INLINE short MULT16_16_P14(int a, int b) { - opus_int64 res; + oac_int64 res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { fprintf (stderr, "MULT16_16_P14: inputs are not short: %d %d\n", a, b); @@ -713,7 +713,7 @@ static OPUS_INLINE short MULT16_16_P14(int a, int b) celt_assert(0); #endif } - res = ((opus_int64)a)*b; + res = ((oac_int64)a)*b; res += 8192; if (!VERIFY_INT(res)) { @@ -733,9 +733,9 @@ static OPUS_INLINE short MULT16_16_P14(int a, int b) celt_mips+=4; return res; } -static OPUS_INLINE short MULT16_16_P15(int a, int b) +static OAC_INLINE short MULT16_16_P15(int a, int b) { - opus_int64 res; + oac_int64 res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { fprintf (stderr, "MULT16_16_P15: inputs are not short: %d %d\n", a, b); @@ -743,7 +743,7 @@ static OPUS_INLINE short MULT16_16_P15(int a, int b) celt_assert(0); #endif } - res = ((opus_int64)a)*b; + res = ((oac_int64)a)*b; res += 16384; if (!VERIFY_INT(res)) { @@ -766,9 +766,9 @@ static OPUS_INLINE short MULT16_16_P15(int a, int b) #define DIV32_16(a, b) DIV32_16_(a, b, __FILE__, __LINE__) -static OPUS_INLINE int DIV32_16_(opus_int64 a, opus_int64 b, char *file, int line) +static OAC_INLINE int DIV32_16_(oac_int64 a, oac_int64 b, char *file, int line) { - opus_int64 res; + oac_int64 res; if (b==0) { fprintf(stderr, "DIV32_16: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line); @@ -801,9 +801,9 @@ static OPUS_INLINE int DIV32_16_(opus_int64 a, opus_int64 b, char *file, int lin } #define DIV32(a, b) DIV32_(a, b, __FILE__, __LINE__) -static OPUS_INLINE int DIV32_(opus_int64 a, opus_int64 b, char *file, int line) +static OAC_INLINE int DIV32_(oac_int64 a, oac_int64 b, char *file, int line) { - opus_int64 res; + oac_int64 res; if (b==0) { fprintf(stderr, "DIV32: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line); @@ -832,7 +832,7 @@ static OPUS_INLINE int DIV32_(opus_int64 a, opus_int64 b, char *file, int line) return res; } -static OPUS_INLINE opus_val16 SIG2WORD16_generic(celt_sig x) +static OAC_INLINE oac_val16 SIG2WORD16_generic(celt_sig x) { x = PSHR32(x, SIG_SHIFT); x = MAX32(x, -32768); diff --git a/celt/fixed_generic.h b/celt/fixed_generic.h index ee9ea1844..7b6616abe 100644 --- a/celt/fixed_generic.h +++ b/celt/fixed_generic.h @@ -34,65 +34,65 @@ #define FIXED_GENERIC_H /** Multiply a 16-bit signed value by a 16-bit unsigned value. The result is a 32-bit signed value */ -#define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(opus_uint16)(b)) +#define MULT16_16SU(a,b) ((oac_val32)(oac_val16)(a)*(oac_val32)(oac_uint16)(b)) /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT16_32_Q16(a,b) ((opus_val32)SHR((opus_int64)((opus_val16)(a))*(b),16)) +#if OAC_FAST_INT64 +#define MULT16_32_Q16(a,b) ((oac_val32)SHR((oac_int64)((oac_val16)(a))*(b),16)) #else #define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR((b),16)), SHR(MULT16_16SU((a),((b)&0x0000ffff)),16)) #endif /** 16x32 multiplication, followed by a 16-bit shift right (round-to-nearest). Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT16_32_P16(a,b) ((opus_val32)PSHR((opus_int64)((opus_val16)(a))*(b),16)) +#if OAC_FAST_INT64 +#define MULT16_32_P16(a,b) ((oac_val32)PSHR((oac_int64)((oac_val16)(a))*(b),16)) #else #define MULT16_32_P16(a,b) ADD32(MULT16_16((a),SHR((b),16)), PSHR(MULT16_16SU((a),((b)&0x0000ffff)),16)) #endif /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT16_32_Q15(a,b) ((opus_val32)SHR((opus_int64)((opus_val16)(a))*(b),15)) +#if OAC_FAST_INT64 +#define MULT16_32_Q15(a,b) ((oac_val32)SHR((oac_int64)((oac_val16)(a))*(b),15)) #else #define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),((b)&0x0000ffff)),15)) #endif /** 32x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT32_32_Q16(a,b) ((opus_val32)SHR((opus_int64)(a)*(opus_int64)(b),16)) +#if OAC_FAST_INT64 +#define MULT32_32_Q16(a,b) ((oac_val32)SHR((oac_int64)(a)*(oac_int64)(b),16)) #else -#define MULT32_32_Q16(a,b) (ADD32(ADD32(ADD32((opus_val32)(SHR32(((opus_uint32)((a)&0x0000ffff)*(opus_uint32)((b)&0x0000ffff)),16)), MULT16_16SU(SHR32(a,16),((b)&0x0000ffff))), MULT16_16SU(SHR32(b,16),((a)&0x0000ffff))), SHL32(MULT16_16(SHR32(a,16),SHR32(b,16)),16))) +#define MULT32_32_Q16(a,b) (ADD32(ADD32(ADD32((oac_val32)(SHR32(((oac_uint32)((a)&0x0000ffff)*(oac_uint32)((b)&0x0000ffff)),16)), MULT16_16SU(SHR32(a,16),((b)&0x0000ffff))), MULT16_16SU(SHR32(b,16),((a)&0x0000ffff))), SHL32(MULT16_16(SHR32(a,16),SHR32(b,16)),16))) #endif /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT32_32_Q31(a,b) ((opus_val32)SHR((opus_int64)(a)*(opus_int64)(b),31)) +#if OAC_FAST_INT64 +#define MULT32_32_Q31(a,b) ((oac_val32)SHR((oac_int64)(a)*(oac_int64)(b),31)) #else #define MULT32_32_Q31(a,b) ADD32(ADD32(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),15)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),15)) #endif /** 32x32 multiplication, followed by a 31-bit shift right (with rounding). Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT32_32_P31(a,b) ((opus_val32)SHR(1073741824+(opus_int64)(a)*(opus_int64)(b),31)) +#if OAC_FAST_INT64 +#define MULT32_32_P31(a,b) ((oac_val32)SHR(1073741824+(oac_int64)(a)*(oac_int64)(b),31)) #define MULT32_32_P31_ovflw(a,b) MULT32_32_P31(a,b) #else -#define MULT16_16U(a,b) ((opus_uint32)(a)*(opus_uint32)(b)) -#define MULT32_32_P31(a,b) ADD32(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(opus_int32)SHR(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff)),16+7) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) ) -#define MULT32_32_P31_ovflw(a,b) ADD32_ovflw(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(opus_int32)SHR(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff)),16+7) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) ) +#define MULT16_16U(a,b) ((oac_uint32)(a)*(oac_uint32)(b)) +#define MULT32_32_P31(a,b) ADD32(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(oac_int32)SHR(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff)),16+7) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) ) +#define MULT32_32_P31_ovflw(a,b) ADD32_ovflw(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(oac_int32)SHR(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff)),16+7) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) ) #endif /** 32x32 multiplication, followed by a 32-bit shift right. Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT32_32_Q32(a,b) ((opus_val32)SHR((opus_int64)(a)*(opus_int64)(b),32)) +#if OAC_FAST_INT64 +#define MULT32_32_Q32(a,b) ((oac_val32)SHR((oac_int64)(a)*(oac_int64)(b),32)) #else #define MULT32_32_Q32(a,b) ADD32(ADD32(MULT16_16(SHR((a),16),SHR((b),16)), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),16)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),16)) #endif /** Compile-time conversion of float constant to 16-bit value */ -#define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits)))) +#define QCONST16(x,bits) ((oac_val16)(.5+(x)*(((oac_val32)1)<<(bits)))) /** Compile-time conversion of float constant to 32-bit value */ -#define QCONST32(x,bits) ((opus_val32)(.5+(x)*(((opus_int64)1)<<(bits)))) +#define QCONST32(x,bits) ((oac_val32)(.5+(x)*(((oac_int64)1)<<(bits)))) /** Compile-time conversion of float constant to log gain value */ #define GCONST2(x,bits) ((celt_glog)(.5+(x)*(((celt_glog)1)<<(bits)))) @@ -106,18 +106,18 @@ #define NEG32(x) (-(x)) /** Change a 32-bit value into a 16-bit value. The value is assumed to fit in 16-bit, otherwise the result is undefined */ -#define EXTRACT16(x) ((opus_val16)(x)) +#define EXTRACT16(x) ((oac_val16)(x)) /** Change a 16-bit value into a 32-bit value */ -#define EXTEND32(x) ((opus_val32)(x)) +#define EXTEND32(x) ((oac_val32)(x)) /** Arithmetic shift-right of a 16-bit value */ #define SHR16(a,shift) ((a) >> (shift)) /** Arithmetic shift-left of a 16-bit value */ -#define SHL16(a,shift) ((opus_int16)((opus_uint16)(a)<<(shift))) +#define SHL16(a,shift) ((oac_int16)((oac_uint16)(a)<<(shift))) /** Arithmetic shift-right of a 32-bit value */ #define SHR32(a,shift) ((a) >> (shift)) /** Arithmetic shift-left of a 32-bit value */ -#define SHL32(a,shift) ((opus_int32)((opus_uint32)(a)<<(shift))) +#define SHL32(a,shift) ((oac_int32)((oac_uint32)(a)<<(shift))) /** 32-bit arithmetic shift right with rounding-to-nearest instead of rounding down */ #define PSHR32(a,shift) (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift)) @@ -145,35 +145,35 @@ #define HALF32(x) (SHR32(x,1)) /** Add two 16-bit values */ -#define ADD16(a,b) ((opus_val16)((opus_val16)(a)+(opus_val16)(b))) +#define ADD16(a,b) ((oac_val16)((oac_val16)(a)+(oac_val16)(b))) /** Subtract two 16-bit values */ -#define SUB16(a,b) ((opus_val16)(a)-(opus_val16)(b)) +#define SUB16(a,b) ((oac_val16)(a)-(oac_val16)(b)) /** Add two 32-bit values */ -#define ADD32(a,b) ((opus_val32)(a)+(opus_val32)(b)) +#define ADD32(a,b) ((oac_val32)(a)+(oac_val32)(b)) /** Subtract two 32-bit values */ -#define SUB32(a,b) ((opus_val32)(a)-(opus_val32)(b)) +#define SUB32(a,b) ((oac_val32)(a)-(oac_val32)(b)) /** Add two 32-bit values, ignore any overflows */ -#define ADD32_ovflw(a,b) ((opus_val32)((opus_uint32)(a)+(opus_uint32)(b))) +#define ADD32_ovflw(a,b) ((oac_val32)((oac_uint32)(a)+(oac_uint32)(b))) /** Subtract two 32-bit values, ignore any overflows */ -#define SUB32_ovflw(a,b) ((opus_val32)((opus_uint32)(a)-(opus_uint32)(b))) +#define SUB32_ovflw(a,b) ((oac_val32)((oac_uint32)(a)-(oac_uint32)(b))) /* Avoid MSVC warning C4146: unary minus operator applied to unsigned type */ /** Negate 32-bit value, ignore any overflows */ -#define NEG32_ovflw(a) ((opus_val32)(0-(opus_uint32)(a))) +#define NEG32_ovflw(a) ((oac_val32)(0-(oac_uint32)(a))) /** 32-bit shift left, ignoring overflows */ #define SHL32_ovflw(a,shift) SHL32(a,shift) /** 32-bit arithmetic shift right with rounding-to-nearest, ignoring overflows */ #define PSHR32_ovflw(a,shift) (SHR32(ADD32_ovflw(a, (EXTEND32(1)<<(shift)>>1)),shift)) /** 16x16 multiplication where the result fits in 16 bits */ -#define MULT16_16_16(a,b) ((((opus_val16)(a))*((opus_val16)(b)))) +#define MULT16_16_16(a,b) ((((oac_val16)(a))*((oac_val16)(b)))) /** 32x32 multiplication where the result fits in 32 bits */ -#define MULT32_32_32(a,b) ((((opus_val32)(a))*((opus_val32)(b)))) +#define MULT32_32_32(a,b) ((((oac_val32)(a))*((oac_val32)(b)))) -/* (opus_val32)(opus_val16) gives TI compiler a hint that it's 16x16->32 multiply */ +/* (oac_val32)(oac_val16) gives TI compiler a hint that it's 16x16->32 multiply */ /** 16x16 multiplication where the result fits in 32 bits */ -#define MULT16_16(a,b) (((opus_val32)(opus_val16)(a))*((opus_val32)(opus_val16)(b))) +#define MULT16_16(a,b) (((oac_val32)(oac_val16)(a))*((oac_val32)(oac_val16)(b))) /** 16x16 multiply-add where the result fits in 32 bits */ #define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b)))) @@ -197,16 +197,16 @@ #define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15)) /** Divide a 32-bit value by a 16-bit value. Result fits in 16 bits */ -#define DIV32_16(a,b) ((opus_val16)(((opus_val32)(a))/((opus_val16)(b)))) +#define DIV32_16(a,b) ((oac_val16)(((oac_val32)(a))/((oac_val16)(b)))) /** Divide a 32-bit value by a 32-bit value. Result fits in 32 bits */ -#define DIV32(a,b) (((opus_val32)(a))/((opus_val32)(b))) +#define DIV32(a,b) (((oac_val32)(a))/((oac_val32)(b))) #if defined(__mips) #include "mips/fixed_generic_mipsr1.h" #endif -static OPUS_INLINE opus_val16 SIG2WORD16_generic(celt_sig x) +static OAC_INLINE oac_val16 SIG2WORD16_generic(celt_sig x) { x = PSHR32(x, SIG_SHIFT); x = MAX32(x, -32768); diff --git a/celt/float_cast.h b/celt/float_cast.h index 120a53695..c94a0f27f 100644 --- a/celt/float_cast.h +++ b/celt/float_cast.h @@ -65,12 +65,12 @@ #if defined(__GNUC__) && defined(__SSE__) #include -static OPUS_INLINE opus_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_ss(x));} +static OAC_INLINE oac_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_ss(x));} #elif (defined(_MSC_VER) && _MSC_VER >= 1400) && (defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1)) #include - static OPUS_INLINE opus_int32 float2int(float value) + static OAC_INLINE oac_int32 float2int(float value) { /* _mm_load_ss will generate same code as _mm_set_ss ** in _MSC_VER >= 1914 /02 so keep __mm_load__ss @@ -84,10 +84,10 @@ static OPUS_INLINE opus_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_s #include /* Win32 doesn't seem to have these functions. - ** Therefore implement OPUS_INLINE versions of these functions here. + ** Therefore implement OAC_INLINE versions of these functions here. */ - static OPUS_INLINE opus_int32 + static OAC_INLINE oac_int32 float2int (float flt) { int intgr; @@ -101,7 +101,7 @@ static OPUS_INLINE opus_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_s #elif defined(__aarch64__) #include - static OPUS_INLINE opus_int32 float2int(float flt) + static OAC_INLINE oac_int32 float2int(float flt) { return vcvtns_s32_f32(flt); } @@ -147,15 +147,15 @@ static OPUS_INLINE opus_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_s #endif #ifndef DISABLE_FLOAT_API -static OPUS_INLINE opus_int16 FLOAT2INT16(float x) +static OAC_INLINE oac_int16 FLOAT2INT16(float x) { x = x*CELT_SIG_SCALE; x = MAX32(x, -32768); x = MIN32(x, 32767); - return (opus_int16)float2int(x); + return (oac_int16)float2int(x); } -static OPUS_INLINE opus_int32 FLOAT2INT24(float x) +static OAC_INLINE oac_int32 FLOAT2INT24(float x) { x = x*(CELT_SIG_SCALE*256.f); x = MAX32(x, -16777216); @@ -163,9 +163,9 @@ static OPUS_INLINE opus_int32 FLOAT2INT24(float x) return float2int(x); } #ifdef FIXED_POINT -static OPUS_INLINE opus_int32 FLOAT2SIG(float x) +static OAC_INLINE oac_int32 FLOAT2SIG(float x) { - x = x*((opus_int32)32768<32000 || (opus_int32)p*(opus_int32)p > n) + if (p>32000 || (oac_int32)p*(oac_int32)p > n) p = n; /* no more factors, skip to end */ } n /= p; @@ -415,7 +415,7 @@ static void compute_twiddles(kiss_twiddle_cpx *twiddles, int nfft) int i; #ifdef FIXED_POINT for (i=0;infft=nfft; @@ -462,7 +462,7 @@ kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, if (st->nfft == 1<scale_shift) st->scale = QCONST32(1.0f, 30); else - st->scale = (((opus_int64)1073741824<scale_shift)+st->nfft/2)/st->nfft; + st->scale = (((oac_int64)1073741824<scale_shift)+st->nfft/2)/st->nfft; #else st->scale = 1.f/nfft; #endif @@ -485,39 +485,39 @@ kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, } /* bitrev */ - st->bitrev = bitrev = (opus_int16*)KISS_FFT_MALLOC(sizeof(opus_int16)*nfft); + st->bitrev = bitrev = (oac_int16*)KISS_FFT_MALLOC(sizeof(oac_int16)*nfft); if (st->bitrev==NULL) goto fail; compute_bitrev_table(0, bitrev, 1,1, st->factors,st); /* Initialize architecture specific fft parameters */ - if (opus_fft_alloc_arch(st, arch)) + if (oac_fft_alloc_arch(st, arch)) goto fail; } return st; fail: - opus_fft_free(st, arch); + oac_fft_free(st, arch); return NULL; } -kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch) +kiss_fft_state *oac_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch) { - return opus_fft_alloc_twiddles(nfft, mem, lenmem, NULL, arch); + return oac_fft_alloc_twiddles(nfft, mem, lenmem, NULL, arch); } -void opus_fft_free_arch_c(kiss_fft_state *st) { +void oac_fft_free_arch_c(kiss_fft_state *st) { (void)st; } -void opus_fft_free(const kiss_fft_state *cfg, int arch) +void oac_fft_free(const kiss_fft_state *cfg, int arch) { if (cfg) { - opus_fft_free_arch((kiss_fft_state *)cfg, arch); - opus_free((opus_int16*)cfg->bitrev); + oac_fft_free_arch((kiss_fft_state *)cfg, arch); + oac_free((oac_int16*)cfg->bitrev); if (cfg->shift < 0) - opus_free((kiss_twiddle_cpx*)cfg->twiddles); - opus_free((kiss_fft_state*)cfg); + oac_free((kiss_twiddle_cpx*)cfg->twiddles); + oac_free((kiss_fft_state*)cfg); } } @@ -548,7 +548,7 @@ static void fft_downshift(kiss_fft_cpx *x, int N, int *total, int step) { #define fft_downshift(x, N, total, step) #endif -void opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout ARG_FIXED(int downshift)) +void oac_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout ARG_FIXED(int downshift)) { int m2, m; int p; @@ -601,7 +601,7 @@ void opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout ARG_FIXED(int dow fft_downshift(fout, st->nfft, &downshift, downshift); } -void opus_fft_c(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) +void oac_fft_c(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) { int i; celt_coef scale; @@ -620,11 +620,11 @@ void opus_fft_c(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *f fout[st->bitrev[i]].r = S_MUL2(x.r, scale); fout[st->bitrev[i]].i = S_MUL2(x.i, scale); } - opus_fft_impl(st, fout ARG_FIXED(scale_shift)); + oac_fft_impl(st, fout ARG_FIXED(scale_shift)); } -void opus_ifft_c(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) +void oac_ifft_c(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) { int i; celt_assert2 (fin != fout, "In-place FFT not supported"); @@ -633,7 +633,7 @@ void opus_ifft_c(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx * fout[st->bitrev[i]] = fin[i]; for (i=0;infft;i++) fout[i].i = -fout[i].i; - opus_fft_impl(st, fout ARG_FIXED(0)); + oac_fft_impl(st, fout ARG_FIXED(0)); for (i=0;infft;i++) fout[i].i = -fout[i].i; } diff --git a/celt/kiss_fft.h b/celt/kiss_fft.h index 52b9fc7cd..27c733d98 100644 --- a/celt/kiss_fft.h +++ b/celt/kiss_fft.h @@ -39,13 +39,13 @@ # define kiss_fft_scalar __m128 #define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes) #else -#define KISS_FFT_MALLOC opus_alloc +#define KISS_FFT_MALLOC oac_alloc #endif #ifdef FIXED_POINT #include "arch.h" -# define kiss_fft_scalar opus_int32 +# define kiss_fft_scalar oac_int32 # define COEF_SHIFT 32 # define kiss_twiddle_scalar celt_coef @@ -53,7 +53,7 @@ /* Some 32-bit CPUs would load/store a kiss_twiddle_cpx with a single memory * access, and could benefit from additional alignment. */ -# define KISS_TWIDDLE_CPX_ALIGNMENT (sizeof(opus_int32)) +# define KISS_TWIDDLE_CPX_ALIGNMENT (sizeof(oac_int32)) #else @@ -99,8 +99,8 @@ typedef struct kiss_fft_state{ int scale_shift; #endif int shift; - opus_int16 factors[2*MAXFACTORS]; - const opus_int16 *bitrev; + oac_int16 factors[2*MAXFACTORS]; + const oac_int16 *bitrev; const kiss_twiddle_cpx *twiddles; arch_fft_state *arch_fft; } kiss_fft_state; @@ -112,16 +112,16 @@ typedef struct kiss_fft_state{ /*typedef struct kiss_fft_state* kiss_fft_cfg;*/ /** - * opus_fft_alloc + * oac_fft_alloc * * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. * - * typical usage: kiss_fft_cfg mycfg=opus_fft_alloc(1024,0,NULL,NULL); + * typical usage: kiss_fft_cfg mycfg=oac_fft_alloc(1024,0,NULL,NULL); * * The return value from fft_alloc is a cfg buffer used internally * by the fft routine or NULL. * - * If lenmem is NULL, then opus_fft_alloc will allocate a cfg buffer using malloc. + * If lenmem is NULL, then oac_fft_alloc will allocate a cfg buffer using malloc. * The returned value should be free()d when done to avoid memory leaks. * * The state can be placed in a user supplied buffer 'mem': @@ -134,12 +134,12 @@ typedef struct kiss_fft_state{ * buffer size in *lenmem. * */ -kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, const kiss_fft_state *base, int arch); +kiss_fft_state *oac_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, const kiss_fft_state *base, int arch); -kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch); +kiss_fft_state *oac_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch); /** - * opus_fft(cfg,in_out_buf) + * oac_fft(cfg,in_out_buf) * * Perform an FFT on a complex input buffer. * for a forward FFT, @@ -148,58 +148,58 @@ kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch); * Note that each element is complex and can be accessed like f[k].r and f[k].i * */ -void opus_fft_c(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); -void opus_ifft_c(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); +void oac_fft_c(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); +void oac_ifft_c(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); -void opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout ARG_FIXED(int downshift)); -void opus_ifft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout); +void oac_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout ARG_FIXED(int downshift)); +void oac_ifft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout); -void opus_fft_free(const kiss_fft_state *cfg, int arch); +void oac_fft_free(const kiss_fft_state *cfg, int arch); -void opus_fft_free_arch_c(kiss_fft_state *st); -int opus_fft_alloc_arch_c(kiss_fft_state *st); +void oac_fft_free_arch_c(kiss_fft_state *st); +int oac_fft_alloc_arch_c(kiss_fft_state *st); -#if !defined(OVERRIDE_OPUS_FFT) +#if !defined(OVERRIDE_OAC_FFT) /* Is run-time CPU detection enabled on this platform? */ -#if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) +#if defined(OAC_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) -extern int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])( +extern int (*const OAC_FFT_ALLOC_ARCH_IMPL[OAC_ARCHMASK+1])( kiss_fft_state *st); -#define opus_fft_alloc_arch(_st, arch) \ - ((*OPUS_FFT_ALLOC_ARCH_IMPL[(arch)&OPUS_ARCHMASK])(_st)) +#define oac_fft_alloc_arch(_st, arch) \ + ((*OAC_FFT_ALLOC_ARCH_IMPL[(arch)&OAC_ARCHMASK])(_st)) -extern void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])( +extern void (*const OAC_FFT_FREE_ARCH_IMPL[OAC_ARCHMASK+1])( kiss_fft_state *st); -#define opus_fft_free_arch(_st, arch) \ - ((*OPUS_FFT_FREE_ARCH_IMPL[(arch)&OPUS_ARCHMASK])(_st)) +#define oac_fft_free_arch(_st, arch) \ + ((*OAC_FFT_FREE_ARCH_IMPL[(arch)&OAC_ARCHMASK])(_st)) -extern void (*const OPUS_FFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg, +extern void (*const OAC_FFT[OAC_ARCHMASK+1])(const kiss_fft_state *cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout); -#define opus_fft(_cfg, _fin, _fout, arch) \ - ((*OPUS_FFT[(arch)&OPUS_ARCHMASK])(_cfg, _fin, _fout)) +#define oac_fft(_cfg, _fin, _fout, arch) \ + ((*OAC_FFT[(arch)&OAC_ARCHMASK])(_cfg, _fin, _fout)) -extern void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg, +extern void (*const OAC_IFFT[OAC_ARCHMASK+1])(const kiss_fft_state *cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout); -#define opus_ifft(_cfg, _fin, _fout, arch) \ - ((*OPUS_IFFT[(arch)&OPUS_ARCHMASK])(_cfg, _fin, _fout)) +#define oac_ifft(_cfg, _fin, _fout, arch) \ + ((*OAC_IFFT[(arch)&OAC_ARCHMASK])(_cfg, _fin, _fout)) -#else /* else for if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */ +#else /* else for if defined(OAC_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */ -#define opus_fft_alloc_arch(_st, arch) \ - ((void)(arch), opus_fft_alloc_arch_c(_st)) +#define oac_fft_alloc_arch(_st, arch) \ + ((void)(arch), oac_fft_alloc_arch_c(_st)) -#define opus_fft_free_arch(_st, arch) \ - ((void)(arch), opus_fft_free_arch_c(_st)) +#define oac_fft_free_arch(_st, arch) \ + ((void)(arch), oac_fft_free_arch_c(_st)) -#define opus_fft(_cfg, _fin, _fout, arch) \ - ((void)(arch), opus_fft_c(_cfg, _fin, _fout)) +#define oac_fft(_cfg, _fin, _fout, arch) \ + ((void)(arch), oac_fft_c(_cfg, _fin, _fout)) -#define opus_ifft(_cfg, _fin, _fout, arch) \ - ((void)(arch), opus_ifft_c(_cfg, _fin, _fout)) +#define oac_ifft(_cfg, _fin, _fout, arch) \ + ((void)(arch), oac_ifft_c(_cfg, _fin, _fout)) -#endif /* end if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */ -#endif /* end if !defined(OVERRIDE_OPUS_FFT) */ +#endif /* end if defined(OAC_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */ +#endif /* end if !defined(OVERRIDE_OAC_FFT) */ #endif diff --git a/celt/laplace.c b/celt/laplace.c index 218096666..0bca53779 100644 --- a/celt/laplace.c +++ b/celt/laplace.c @@ -45,7 +45,7 @@ static unsigned ec_laplace_get_freq1(unsigned fs0, int decay) { unsigned ft; ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN) - fs0; - return ft*(opus_int32)(16384-decay)>>15; + return ft*(oac_int32)(16384-decay)>>15; } void ec_laplace_encode(ec_enc *enc, int *value, unsigned fs, int decay) @@ -66,7 +66,7 @@ void ec_laplace_encode(ec_enc *enc, int *value, unsigned fs, int decay) { fs *= 2; fl += fs+2*LAPLACE_MINP; - fs = (fs*(opus_int32)decay)>>15; + fs = (fs*(oac_int32)decay)>>15; } /* Everything beyond that has probability LAPLACE_MINP. */ if (!fs) @@ -108,7 +108,7 @@ int ec_laplace_decode(ec_dec *dec, unsigned fs, int decay) { fs *= 2; fl += fs; - fs = ((fs-2*LAPLACE_MINP)*(opus_int32)decay)>>15; + fs = ((fs-2*LAPLACE_MINP)*(oac_int32)decay)>>15; fs += LAPLACE_MINP; val++; } @@ -133,10 +133,10 @@ int ec_laplace_decode(ec_dec *dec, unsigned fs, int decay) return val; } -void ec_laplace_encode_p0(ec_enc *enc, int value, opus_uint16 p0, opus_uint16 decay) +void ec_laplace_encode_p0(ec_enc *enc, int value, oac_uint16 p0, oac_uint16 decay) { int s; - opus_uint16 sign_icdf[3]; + oac_uint16 sign_icdf[3]; sign_icdf[0] = 32768-p0; sign_icdf[1] = sign_icdf[0]/2; sign_icdf[2] = 0; @@ -146,11 +146,11 @@ void ec_laplace_encode_p0(ec_enc *enc, int value, opus_uint16 p0, opus_uint16 de if (value) { int i; - opus_uint16 icdf[8]; + oac_uint16 icdf[8]; icdf[0] = IMAX(7, decay); for (i=1;i<7;i++) { - icdf[i] = IMAX(7-i, (icdf[i-1] * (opus_int32)decay) >> 15); + icdf[i] = IMAX(7-i, (icdf[i-1] * (oac_int32)decay) >> 15); } icdf[7] = 0; value--; @@ -161,11 +161,11 @@ void ec_laplace_encode_p0(ec_enc *enc, int value, opus_uint16 p0, opus_uint16 de } } -int ec_laplace_decode_p0(ec_dec *dec, opus_uint16 p0, opus_uint16 decay) +int ec_laplace_decode_p0(ec_dec *dec, oac_uint16 p0, oac_uint16 decay) { int s; int value; - opus_uint16 sign_icdf[3]; + oac_uint16 sign_icdf[3]; sign_icdf[0] = 32768-p0; sign_icdf[1] = sign_icdf[0]/2; sign_icdf[2] = 0; @@ -175,11 +175,11 @@ int ec_laplace_decode_p0(ec_dec *dec, opus_uint16 p0, opus_uint16 decay) { int i; int v; - opus_uint16 icdf[8]; + oac_uint16 icdf[8]; icdf[0] = IMAX(7, decay); for (i=1;i<7;i++) { - icdf[i] = IMAX(7-i, (icdf[i-1] * (opus_int32)decay) >> 15); + icdf[i] = IMAX(7-i, (icdf[i-1] * (oac_int32)decay) >> 15); } icdf[7] = 0; value = 1; diff --git a/celt/laplace.h b/celt/laplace.h index 8010ad975..3245a00aa 100644 --- a/celt/laplace.h +++ b/celt/laplace.h @@ -51,7 +51,7 @@ void ec_laplace_encode(ec_enc *enc, int *value, unsigned fs, int decay); int ec_laplace_decode(ec_dec *dec, unsigned fs, int decay); -int ec_laplace_decode_p0(ec_dec *dec, opus_uint16 p0, opus_uint16 decay); -void ec_laplace_encode_p0(ec_enc *enc, int value, opus_uint16 p0, opus_uint16 decay); +int ec_laplace_decode_p0(ec_dec *dec, oac_uint16 p0, oac_uint16 decay); +void ec_laplace_encode_p0(ec_enc *enc, int value, oac_uint16 p0, oac_uint16 decay); #endif diff --git a/celt/mathops.c b/celt/mathops.c index dbb3761e6..5d23b3988 100644 --- a/celt/mathops.c +++ b/celt/mathops.c @@ -42,7 +42,7 @@ /*Compute floor(sqrt(_val)) with exact arithmetic. _val must be greater than 0. This has been tested on all possible 32-bit inputs greater than 0.*/ -unsigned isqrt32(opus_uint32 _val){ +unsigned isqrt32(oac_uint32 _val){ unsigned b; unsigned g; int bshift; @@ -54,8 +54,8 @@ unsigned isqrt32(opus_uint32 _val){ bshift=(EC_ILOG(_val)-1)>>1; b=1U<= 536870912) /* 2^29 */ return 2147483647; /* 2^31 - 1 */ else if (result <= -536870912) /* -2^29 */ @@ -95,12 +95,12 @@ opus_val32 frac_div32(opus_val32 a, opus_val32 b) { } /** Reciprocal sqrt approximation in the range [0.25,1) (Q16 in, Q14 out) */ -opus_val16 celt_rsqrt_norm(opus_val32 x) +oac_val16 celt_rsqrt_norm(oac_val32 x) { - opus_val16 n; - opus_val16 r; - opus_val16 r2; - opus_val16 y; + oac_val16 n; + oac_val16 r; + oac_val16 r2; + oac_val16 y; /* Range of n is [-16384,32767] ([-0.5,1) in Q15). */ n = x-32768; /* Get a rough initial guess for the root. @@ -123,12 +123,12 @@ opus_val16 celt_rsqrt_norm(opus_val32 x) } /** Reciprocal sqrt approximation in the range [0.25,1) (Q31 in, Q29 out) */ -opus_val32 celt_rsqrt_norm32(opus_val32 x) +oac_val32 celt_rsqrt_norm32(oac_val32 x) { - opus_int32 tmp; + oac_int32 tmp; /* Use the first-order Newton-Raphson method to refine the root estimate. * r = r * (1.5 - 0.5*x*r*r) */ - opus_int32 r_q29 = SHL32(celt_rsqrt_norm(SHR32(x, 31-16)), 15); + oac_int32 r_q29 = SHL32(celt_rsqrt_norm(SHR32(x, 31-16)), 15); /* Split evaluation in steps to avoid exploding macro expansion. */ tmp = MULT32_32_Q31(r_q29, r_q29); tmp = MULT32_32_Q31(1073741824 /* Q31 */, tmp); @@ -137,15 +137,15 @@ opus_val32 celt_rsqrt_norm32(opus_val32 x) } /** Sqrt approximation (QX input, QX/2 output) */ -opus_val32 celt_sqrt(opus_val32 x) +oac_val32 celt_sqrt(oac_val32 x) { int k; - opus_val16 n; - opus_val32 rt; + oac_val16 n; + oac_val32 rt; /* These coeffs are optimized in fixed-point to minimize both RMS and max error of sqrt(x) over .25=1073741824) @@ -161,10 +161,10 @@ opus_val32 celt_sqrt(opus_val32 x) /* Perform fixed-point arithmetic to approximate the square root. When the input * is in Qx format, the output will be in Q(x/2 + 16) format. */ -opus_val32 celt_sqrt32(opus_val32 x) +oac_val32 celt_sqrt32(oac_val32 x) { int k; - opus_int32 x_frac; + oac_int32 x_frac; if (x==0) return 0; else if (x>=1073741824) @@ -181,9 +181,9 @@ opus_val32 celt_sqrt32(opus_val32 x) #define L3 8277 #define L4 -626 -static OPUS_INLINE opus_val16 _celt_cos_pi_2(opus_val16 x) +static OAC_INLINE oac_val16 _celt_cos_pi_2(oac_val16 x) { - opus_val16 x2; + oac_val16 x2; x2 = MULT16_16_P15(x,x); return ADD16(1,MIN16(32766,ADD32(SUB16(L1,x2), MULT16_16_P15(x2, ADD32(L2, MULT16_16_P15(x2, ADD32(L3, MULT16_16_P15(L4, x2 @@ -195,7 +195,7 @@ static OPUS_INLINE opus_val16 _celt_cos_pi_2(opus_val16 x) #undef L3 #undef L4 -opus_val16 celt_cos_norm(opus_val32 x) +oac_val16 celt_cos_norm(oac_val32 x) { x = x&0x0001ffff; if (x>SHL32(EXTEND32(1), 16)) @@ -220,14 +220,14 @@ opus_val16 celt_cos_norm(opus_val32 x) /* Calculates the cosine of (PI*0.5*x) where the input x ranges from -1 to 1 and * is in Q30 format. The output will also be in Q31 format. */ -opus_val32 celt_cos_norm32(opus_val32 x) +oac_val32 celt_cos_norm32(oac_val32 x) { - static const opus_val32 COS_NORM_COEFF_A0 = 134217720; /* Q27 */ - static const opus_val32 COS_NORM_COEFF_A1 = -662336704; /* Q29 */ - static const opus_val32 COS_NORM_COEFF_A2 = 544710848; /* Q31 */ - static const opus_val32 COS_NORM_COEFF_A3 = -178761936; /* Q33 */ - static const opus_val32 COS_NORM_COEFF_A4 = 29487206; /* Q35 */ - opus_int32 x_sq_q29, tmp; + static const oac_val32 COS_NORM_COEFF_A0 = 134217720; /* Q27 */ + static const oac_val32 COS_NORM_COEFF_A1 = -662336704; /* Q29 */ + static const oac_val32 COS_NORM_COEFF_A2 = 544710848; /* Q31 */ + static const oac_val32 COS_NORM_COEFF_A3 = -178761936; /* Q33 */ + static const oac_val32 COS_NORM_COEFF_A4 = 29487206; /* Q35 */ + oac_int32 x_sq_q29, tmp; /* The expected x is in the range of [-1.0f, 1.0f] */ celt_sig_assert((x >= -1073741824) && (x <= 1073741824)); /* Make cos(+/- pi/2) exactly zero. */ @@ -242,9 +242,9 @@ opus_val32 celt_cos_norm32(opus_val32 x) /* Computes a 16 bit approximate reciprocal (1/x) for a normalized Q15 input, * resulting in a Q15 output. */ -opus_val16 celt_rcp_norm16(opus_val16 x) +oac_val16 celt_rcp_norm16(oac_val16 x) { - opus_val16 r; + oac_val16 r; /* Start with a linear approximation: r = 1.8823529411764706-0.9411764705882353*n. The coefficients and the result are Q14 in the range [15420,30840].*/ @@ -263,9 +263,9 @@ opus_val16 celt_rcp_norm16(opus_val16 x) /* Computes a 32 bit approximated reciprocal (1/x) for a normalized Q31 input, * resulting in a Q30 output. The expected input range is [0.5f, 1.0f) in Q31 * and the expected output range is [1.0f, 2.0f) in Q30. */ -opus_val32 celt_rcp_norm32(opus_val32 x) +oac_val32 celt_rcp_norm32(oac_val32 x) { - opus_val32 r_q30; + oac_val32 r_q30; celt_sig_assert(x >= 1073741824); r_q30 = SHL32(EXTEND32(celt_rcp_norm16(SHR32(x, 15)-32768)), 16); /* Solving f(y) = a - 1/y using the Newton Method @@ -284,10 +284,10 @@ opus_val32 celt_rcp_norm32(opus_val32 x) } /** Reciprocal approximation (Q15 input, Q16 output) */ -opus_val32 celt_rcp(opus_val32 x) +oac_val32 celt_rcp(oac_val32 x) { int i; - opus_val16 r; + oac_val16 r; celt_sig_assert(x>0); i = celt_ilog2(x); @@ -304,7 +304,7 @@ opus_val32 celt_rcp(opus_val32 x) #ifndef DISABLE_FLOAT_API -void celt_float2int16_c(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt) +void celt_float2int16_c(const float * OAC_RESTRICT in, short * OAC_RESTRICT out, int cnt) { int i; for (i = 0; i < cnt; i++) @@ -313,7 +313,7 @@ void celt_float2int16_c(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT ou } } -int opus_limit2_checkwithin1_c(float * samples, int cnt) +int oac_limit2_checkwithin1_c(float * samples, int cnt) { int i; if (cnt <= 0) diff --git a/celt/mathops.h b/celt/mathops.h index 120e2652d..f1e0ae629 100644 --- a/celt/mathops.h +++ b/celt/mathops.h @@ -40,16 +40,16 @@ #include "os_support.h" -#if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +#if defined(OAC_ARM_MAY_HAVE_NEON_INTR) #include "arm/mathops_arm.h" #endif #define PI 3.1415926535897931 /* Multiplies two 16-bit fractional values. Bit-exactness of this macro is important */ -#define FRAC_MUL16(a,b) ((16384+((opus_int32)(opus_int16)(a)*(opus_int16)(b)))>>15) +#define FRAC_MUL16(a,b) ((16384+((oac_int32)(oac_int16)(a)*(oac_int16)(b)))>>15) -unsigned isqrt32(opus_uint32 _val); +unsigned isqrt32(oac_uint32 _val); /* CELT doesn't need it for fixed-point, by analysis.c does. */ #if !defined(FIXED_POINT) || defined(ANALYSIS_C) @@ -57,7 +57,7 @@ unsigned isqrt32(opus_uint32 _val); #define cB 0.67848403f #define cC 0.08595542f #define cE ((float)PI/2) -static OPUS_INLINE float fast_atan2f(float y, float x) { +static OAC_INLINE float fast_atan2f(float y, float x) { float x2, y2; x2 = x*x; y2 = y*y; @@ -83,11 +83,11 @@ static OPUS_INLINE float fast_atan2f(float y, float x) { #ifndef OVERRIDE_CELT_MAXABS16 -static OPUS_INLINE opus_val32 celt_maxabs16(const opus_val16 *x, int len) +static OAC_INLINE oac_val32 celt_maxabs16(const oac_val16 *x, int len) { int i; - opus_val16 maxval = 0; - opus_val16 minval = 0; + oac_val16 maxval = 0; + oac_val16 minval = 0; for (i=0;i=0 && y>=0); @@ -189,7 +189,7 @@ static OPUS_INLINE float celt_atan2p_norm(float y, float x) #if !defined(FIXED_POINT) /* Computes estimated cosine values for (PI/2 * x) using only terms with even * exponents. */ -static OPUS_INLINE float celt_cos_norm2(float x) +static OAC_INLINE float celt_cos_norm2(float x) { float x_norm_sq; int output_sign; @@ -269,17 +269,17 @@ static const float log2_y_norm_coeff[8] = { 5.849624872207641601562500e-01f, 7.004396915435791015625000e-01f, 8.073549270629882812500000e-01f, 9.068905711174011230468750e-01f}; -static OPUS_INLINE float celt_log2(float x) +static OAC_INLINE float celt_log2(float x) { - opus_int32 integer; - opus_int32 range_idx; + oac_int32 integer; + oac_int32 range_idx; union { float f; - opus_uint32 i; + oac_uint32 i; } in; in.f = x; - integer = (opus_int32)(in.i>>23)-127; - in.i = (opus_int32)in.i - (opus_int32)((opus_uint32)integer<<23); + integer = (oac_int32)(in.i>>23)-127; + in.i = (oac_int32)in.i - (oac_int32)((oac_uint32)integer<<23); /* Normalize the mantissa range from [1, 2] to [1,1.125], and then shift x * by 1.0625 to [-0.0625, 0.0625]. */ @@ -310,13 +310,13 @@ static OPUS_INLINE float celt_log2(float x) * of order 5, ensuring a controlled relative error. * exp2(x) = exp2(integer + fraction) * = exp2(integer) * exp2(fraction) */ -static OPUS_INLINE float celt_exp2(float x) +static OAC_INLINE float celt_exp2(float x) { - opus_int32 integer; + oac_int32 integer; float frac; union { float f; - opus_uint32 i; + oac_uint32 i; } res; integer = (int)floor(x); if (integer < -50) @@ -338,7 +338,7 @@ static OPUS_INLINE float celt_exp2(float x) + frac * (EXP2_COEFF_A3 + frac * (EXP2_COEFF_A4 + frac * (EXP2_COEFF_A5))))); - res.i = (opus_uint32)((opus_int32)res.i + (opus_int32)((opus_uint32)integer<<23)) & 0x7fffffff; + res.i = (oac_uint32)((oac_int32)res.i + (oac_int32)((oac_uint32)integer<<23)) & 0x7fffffff; return res.f; } @@ -362,7 +362,7 @@ static OPUS_INLINE float celt_exp2(float x) #ifndef OVERRIDE_CELT_ILOG2 /** Integer log in base2. Undefined for zero and negative numbers */ -static OPUS_INLINE opus_int16 celt_ilog2(opus_int32 x) +static OAC_INLINE oac_int16 celt_ilog2(oac_int32 x) { celt_sig_assert(x>0); return EC_ILOG(x)-1; @@ -371,31 +371,31 @@ static OPUS_INLINE opus_int16 celt_ilog2(opus_int32 x) /** Integer log in base2. Defined for zero, but not for negative numbers */ -static OPUS_INLINE opus_int16 celt_zlog2(opus_val32 x) +static OAC_INLINE oac_int16 celt_zlog2(oac_val32 x) { return x <= 0 ? 0 : celt_ilog2(x); } -opus_val16 celt_rsqrt_norm(opus_val32 x); +oac_val16 celt_rsqrt_norm(oac_val32 x); -opus_val32 celt_rsqrt_norm32(opus_val32 x); +oac_val32 celt_rsqrt_norm32(oac_val32 x); -opus_val32 celt_sqrt(opus_val32 x); +oac_val32 celt_sqrt(oac_val32 x); -opus_val32 celt_sqrt32(opus_val32 x); +oac_val32 celt_sqrt32(oac_val32 x); -opus_val16 celt_cos_norm(opus_val32 x); +oac_val16 celt_cos_norm(oac_val32 x); -opus_val32 celt_cos_norm32(opus_val32 x); +oac_val32 celt_cos_norm32(oac_val32 x); /** Base-2 logarithm approximation (log2(x)). (Q14 input, Q10 output) */ -static OPUS_INLINE opus_val16 celt_log2(opus_val32 x) +static OAC_INLINE oac_val16 celt_log2(oac_val32 x) { int i; - opus_val16 n, frac; + oac_val16 n, frac; /* -0.41509302963303146, 0.9609890551383969, -0.31836011537636605, 0.15530808010959576, -0.08556153059057618 */ - static const opus_val16 C[5] = {-6801+(1<<(13-10)), 15746, -5217, 2545, -1401}; + static const oac_val16 C[5] = {-6801+(1<<(13-10)), 15746, -5217, 2545, -1401}; if (x==0) return -32767; i = celt_ilog2(x); @@ -415,9 +415,9 @@ static OPUS_INLINE opus_val16 celt_log2(opus_val32 x) #define D2 14819 #define D3 10204 -static OPUS_INLINE opus_val32 celt_exp2_frac(opus_val16 x) +static OAC_INLINE oac_val32 celt_exp2_frac(oac_val16 x) { - opus_val16 frac; + oac_val16 frac; frac = SHL16(x, 4); return ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2 , MULT16_16_Q15(D3,frac)))))); } @@ -428,10 +428,10 @@ static OPUS_INLINE opus_val32 celt_exp2_frac(opus_val16 x) #undef D3 /** Base-2 exponential approximation (2^x). (Q10 input, Q16 output) */ -static OPUS_INLINE opus_val32 celt_exp2(opus_val16 x) +static OAC_INLINE oac_val32 celt_exp2(oac_val16 x) { int integer; - opus_val16 frac; + oac_val16 frac; integer = SHR16(x,10); if (integer>14) return 0x7f000000; @@ -443,23 +443,23 @@ static OPUS_INLINE opus_val32 celt_exp2(opus_val16 x) /* Calculates the base-2 logarithm of a Q14 input value. The result is returned * in Q(DB_SHIFT). If the input value is 0, the function will output -32.0f. */ -static OPUS_INLINE opus_val32 celt_log2_db(opus_val32 x) { +static OAC_INLINE oac_val32 celt_log2_db(oac_val32 x) { /* Q30 */ - static const opus_val32 log2_x_norm_coeff[8] = { + static const oac_val32 log2_x_norm_coeff[8] = { 1073741824, 954437184, 858993472, 780903168, 715827904, 660764224, 613566784, 572662336}; /* Q24 */ - static const opus_val32 log2_y_norm_coeff[8] = { + static const oac_val32 log2_y_norm_coeff[8] = { 0, 2850868, 5401057, 7707983, 9814042, 11751428, 13545168, 15215099}; - static const opus_val32 LOG2_COEFF_A0 = 1467383; /* Q24 */ - static const opus_val32 LOG2_COEFF_A1 = 182244800; /* Q27 */ - static const opus_val32 LOG2_COEFF_A2 = -21440512; /* Q25 */ - static const opus_val32 LOG2_COEFF_A3 = 107903336; /* Q28 */ - static const opus_val32 LOG2_COEFF_A4 = -610217024; /* Q31 */ - - opus_int32 integer, norm_coeff_idx, tmp; - opus_val32 mantissa; + static const oac_val32 LOG2_COEFF_A0 = 1467383; /* Q24 */ + static const oac_val32 LOG2_COEFF_A1 = 182244800; /* Q27 */ + static const oac_val32 LOG2_COEFF_A2 = -21440512; /* Q25 */ + static const oac_val32 LOG2_COEFF_A3 = 107903336; /* Q28 */ + static const oac_val32 LOG2_COEFF_A4 = -610217024; /* Q31 */ + + oac_int32 integer, norm_coeff_idx, tmp; + oac_val32 mantissa; if (x==0) { return -536870912; /* -32.0f */ } @@ -488,18 +488,18 @@ static OPUS_INLINE opus_val32 celt_log2_db(opus_val32 x) { /* Calculates exp2 for Q28 within a specific range (0 to 1.0) using fixed-point * arithmetic. The input number must be adjusted for Q DB_SHIFT. */ -static OPUS_INLINE opus_val32 celt_exp2_db_frac(opus_val32 x) +static OAC_INLINE oac_val32 celt_exp2_db_frac(oac_val32 x) { /* Approximation constants. */ - static const opus_int32 EXP2_COEFF_A0 = 268435440; /* Q28 */ - static const opus_int32 EXP2_COEFF_A1 = 744267456; /* Q30 */ - static const opus_int32 EXP2_COEFF_A2 = 1031451904; /* Q32 */ - static const opus_int32 EXP2_COEFF_A3 = 959088832; /* Q34 */ - static const opus_int32 EXP2_COEFF_A4 = 617742720; /* Q36 */ - static const opus_int32 EXP2_COEFF_A5 = 516104352; /* Q38 */ - opus_int32 tmp; + static const oac_int32 EXP2_COEFF_A0 = 268435440; /* Q28 */ + static const oac_int32 EXP2_COEFF_A1 = 744267456; /* Q30 */ + static const oac_int32 EXP2_COEFF_A2 = 1031451904; /* Q32 */ + static const oac_int32 EXP2_COEFF_A3 = 959088832; /* Q34 */ + static const oac_int32 EXP2_COEFF_A4 = 617742720; /* Q36 */ + static const oac_int32 EXP2_COEFF_A5 = 516104352; /* Q38 */ + oac_int32 tmp; /* Converts input value from Q24 to Q29. */ - opus_val32 x_q29 = SHL32(x, 29 - 24); + oac_val32 x_q29 = SHL32(x, 29 - 24); /* Split evaluation in steps to avoid exploding macro expansion. */ tmp = ADD32(EXP2_COEFF_A4, MULT32_32_Q31(x_q29, EXP2_COEFF_A5)); tmp = ADD32(EXP2_COEFF_A3, MULT32_32_Q31(x_q29, tmp)); @@ -510,10 +510,10 @@ static OPUS_INLINE opus_val32 celt_exp2_db_frac(opus_val32 x) /* Calculates exp2 for Q16 using fixed-point arithmetic. The input number must * be adjusted for Q DB_SHIFT. */ -static OPUS_INLINE opus_val32 celt_exp2_db(opus_val32 x) +static OAC_INLINE oac_val32 celt_exp2_db(oac_val32 x) { int integer; - opus_val32 frac; + oac_val32 frac; integer = SHR32(x,DB_SHIFT); if (integer>14) return 0x7f000000; @@ -525,31 +525,31 @@ static OPUS_INLINE opus_val32 celt_exp2_db(opus_val32 x) -opus_val32 celt_rcp(opus_val32 x); -opus_val32 celt_rcp_norm32(opus_val32 x); +oac_val32 celt_rcp(oac_val32 x); +oac_val32 celt_rcp_norm32(oac_val32 x); -#define celt_div(a,b) MULT32_32_Q31((opus_val32)(a),celt_rcp(b)) +#define celt_div(a,b) MULT32_32_Q31((oac_val32)(a),celt_rcp(b)) -opus_val32 frac_div32_q29(opus_val32 a, opus_val32 b); -opus_val32 frac_div32(opus_val32 a, opus_val32 b); +oac_val32 frac_div32_q29(oac_val32 a, oac_val32 b); +oac_val32 frac_div32(oac_val32 a, oac_val32 b); /* Computes atan(x) multiplied by 2/PI. The input value (x) should be within the * range of -1 to 1 and represented in Q30 format. The function will return the * result in Q30 format. */ -static OPUS_INLINE opus_val32 celt_atan_norm(opus_val32 x) +static OAC_INLINE oac_val32 celt_atan_norm(oac_val32 x) { /* Approximation constants. */ - static const opus_int32 ATAN_2_OVER_PI = 1367130551; /* Q31 */ - static const opus_int32 ATAN_COEFF_A03 = -715791936; /* Q31 */ - static const opus_int32 ATAN_COEFF_A05 = 857391616; /* Q32 */ - static const opus_int32 ATAN_COEFF_A07 = -1200579328; /* Q33 */ - static const opus_int32 ATAN_COEFF_A09 = 1682636672; /* Q34 */ - static const opus_int32 ATAN_COEFF_A11 = -1985085440; /* Q35 */ - static const opus_int32 ATAN_COEFF_A13 = 1583306112; /* Q36 */ - static const opus_int32 ATAN_COEFF_A15 = -598602432; /* Q37 */ - opus_int32 x_sq_q30; - opus_int32 x_q31; - opus_int32 tmp; + static const oac_int32 ATAN_2_OVER_PI = 1367130551; /* Q31 */ + static const oac_int32 ATAN_COEFF_A03 = -715791936; /* Q31 */ + static const oac_int32 ATAN_COEFF_A05 = 857391616; /* Q32 */ + static const oac_int32 ATAN_COEFF_A07 = -1200579328; /* Q33 */ + static const oac_int32 ATAN_COEFF_A09 = 1682636672; /* Q34 */ + static const oac_int32 ATAN_COEFF_A11 = -1985085440; /* Q35 */ + static const oac_int32 ATAN_COEFF_A13 = 1583306112; /* Q36 */ + static const oac_int32 ATAN_COEFF_A15 = -598602432; /* Q37 */ + oac_int32 x_sq_q30; + oac_int32 x_q31; + oac_int32 tmp; /* The expected x is in the range of [-1.0f, 1.0f] */ celt_sig_assert((x <= 1073741824) && (x >= -1073741824)); @@ -581,7 +581,7 @@ static OPUS_INLINE opus_val32 celt_atan_norm(opus_val32 x) * the value in Q30 format. Both input values (x and y) must be within the range * of 0 to 1 and represented in Q30 format. Inputs must be zero or greater, and * at least one input must be non-zero. */ -static OPUS_INLINE opus_val32 celt_atan2p_norm(opus_val32 y, opus_val32 x) +static OAC_INLINE oac_val32 celt_atan2p_norm(oac_val32 y, oac_val32 x) { celt_sig_assert(x>=0 && y>=0); if (y==0 && x==0) { @@ -602,7 +602,7 @@ static OPUS_INLINE opus_val32 celt_atan2p_norm(opus_val32 y, opus_val32 x) /* Atan approximation using a 4th order polynomial. Input is in Q15 format and normalized by pi/4. Output is in Q15 format */ -static OPUS_INLINE opus_val16 celt_atan01(opus_val16 x) +static OAC_INLINE oac_val16 celt_atan01(oac_val16 x) { return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x))))))); } @@ -613,19 +613,19 @@ static OPUS_INLINE opus_val16 celt_atan01(opus_val16 x) #undef M4 /* atan2() approximation valid for positive input values */ -static OPUS_INLINE opus_val16 celt_atan2p(opus_val16 y, opus_val16 x) +static OAC_INLINE oac_val16 celt_atan2p(oac_val16 y, oac_val16 x) { if (x==0 && y==0) { return 0; } else if (y < x) { - opus_val32 arg; + oac_val32 arg; arg = celt_div(SHL32(EXTEND32(y),15),x); if (arg >= 32767) arg = 32767; return SHR16(celt_atan01(EXTRACT16(arg)),1); } else { - opus_val32 arg; + oac_val32 arg; arg = celt_div(SHL32(EXTEND32(x),15),y); if (arg >= 32767) arg = 32767; @@ -637,16 +637,16 @@ static OPUS_INLINE opus_val16 celt_atan2p(opus_val16 y, opus_val16 x) #ifndef DISABLE_FLOAT_API -void celt_float2int16_c(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt); +void celt_float2int16_c(const float * OAC_RESTRICT in, short * OAC_RESTRICT out, int cnt); #ifndef OVERRIDE_FLOAT2INT16 #define celt_float2int16(in, out, cnt, arch) ((void)(arch), celt_float2int16_c(in, out, cnt)) #endif -int opus_limit2_checkwithin1_c(float *samples, int cnt); +int oac_limit2_checkwithin1_c(float *samples, int cnt); #ifndef OVERRIDE_LIMIT2_CHECKWITHIN1 -#define opus_limit2_checkwithin1(samples, cnt, arch) ((void)(arch), opus_limit2_checkwithin1_c(samples, cnt)) +#define oac_limit2_checkwithin1(samples, cnt, arch) ((void)(arch), oac_limit2_checkwithin1_c(samples, cnt)) #endif #endif /* DISABLE_FLOAT_API */ diff --git a/celt/mdct.c b/celt/mdct.c index 153712b2e..dd8a1ed9d 100644 --- a/celt/mdct.c +++ b/celt/mdct.c @@ -74,15 +74,15 @@ int clt_mdct_init(mdct_lookup *l,int N, int maxshift, int arch) for (i=0;i<=maxshift;i++) { if (i==0) - l->kfft[i] = opus_fft_alloc(N>>2>>i, 0, 0, arch); + l->kfft[i] = oac_fft_alloc(N>>2>>i, 0, 0, arch); else - l->kfft[i] = opus_fft_alloc_twiddles(N>>2>>i, 0, 0, l->kfft[0], arch); + l->kfft[i] = oac_fft_alloc_twiddles(N>>2>>i, 0, 0, l->kfft[0], arch); #ifndef ENABLE_TI_DSPLIB55 if (l->kfft[i]==NULL) return 0; #endif } - l->trig = trig = (kiss_twiddle_scalar*)opus_alloc((N-(N2>>maxshift))*sizeof(kiss_twiddle_scalar)); + l->trig = trig = (kiss_twiddle_scalar*)oac_alloc((N-(N2>>maxshift))*sizeof(kiss_twiddle_scalar)); if (l->trig==NULL) return 0; for (shift=0;shift<=maxshift;shift++) @@ -106,15 +106,15 @@ void clt_mdct_clear(mdct_lookup *l, int arch) { int i; for (i=0;i<=l->maxshift;i++) - opus_fft_free(l->kfft[i], arch); - opus_free((kiss_twiddle_scalar*)l->trig); + oac_fft_free(l->kfft[i], arch); + oac_free((kiss_twiddle_scalar*)l->trig); } #endif /* CUSTOM_MODES */ /* Forward MDCT trashes the input array */ #ifndef OVERRIDE_clt_mdct_forward -void clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, +void clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OAC_RESTRICT out, const celt_coef *window, int overlap, int shift, int stride, int arch) { int i; @@ -151,11 +151,11 @@ void clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scal /* Window, shuffle, fold */ { /* Temp pointers to make it really clear to the compiler what we're doing */ - const kiss_fft_scalar * OPUS_RESTRICT xp1 = in+(overlap>>1); - const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+N2-1+(overlap>>1); - kiss_fft_scalar * OPUS_RESTRICT yp = f; - const celt_coef * OPUS_RESTRICT wp1 = window+(overlap>>1); - const celt_coef * OPUS_RESTRICT wp2 = window+(overlap>>1)-1; + const kiss_fft_scalar * OAC_RESTRICT xp1 = in+(overlap>>1); + const kiss_fft_scalar * OAC_RESTRICT xp2 = in+N2-1+(overlap>>1); + kiss_fft_scalar * OAC_RESTRICT yp = f; + const celt_coef * OAC_RESTRICT wp1 = window+(overlap>>1); + const celt_coef * OAC_RESTRICT wp2 = window+(overlap>>1)-1; for(i=0;i<((overlap+3)>>2);i++) { /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ @@ -189,10 +189,10 @@ void clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scal } /* Pre-rotation */ { - kiss_fft_scalar * OPUS_RESTRICT yp = f; + kiss_fft_scalar * OAC_RESTRICT yp = f; const kiss_twiddle_scalar *t = &trig[0]; #ifdef FIXED_POINT - opus_val32 maxval=1; + oac_val32 maxval=1; #endif for(i=0;i>1); - const kiss_twiddle_scalar * OPUS_RESTRICT t = &trig[0]; - const opus_int16 * OPUS_RESTRICT bitrev = l->kfft[shift]->bitrev; + const kiss_fft_scalar * OAC_RESTRICT xp1 = in; + const kiss_fft_scalar * OAC_RESTRICT xp2 = in+stride*(N2-1); + kiss_fft_scalar * OAC_RESTRICT yp = out+(overlap>>1); + const kiss_twiddle_scalar * OAC_RESTRICT t = &trig[0]; + const oac_int16 * OAC_RESTRICT bitrev = l->kfft[shift]->bitrev; for(i=0;ikfft[shift], (kiss_fft_cpx*)(out+(overlap>>1)) ARG_FIXED(fft_shift)); + oac_fft_impl(l->kfft[shift], (kiss_fft_cpx*)(out+(overlap>>1)) ARG_FIXED(fft_shift)); /* Post-rotate and de-shuffle from both ends of the buffer at once to make it in-place. */ @@ -353,10 +353,10 @@ void clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_sca /* Mirror on both sides for TDAC */ { - kiss_fft_scalar * OPUS_RESTRICT xp1 = out+overlap-1; - kiss_fft_scalar * OPUS_RESTRICT yp1 = out; - const celt_coef * OPUS_RESTRICT wp1 = window; - const celt_coef * OPUS_RESTRICT wp2 = window+overlap-1; + kiss_fft_scalar * OAC_RESTRICT xp1 = out+overlap-1; + kiss_fft_scalar * OAC_RESTRICT yp1 = out; + const celt_coef * OAC_RESTRICT wp1 = window; + const celt_coef * OAC_RESTRICT wp2 = window+overlap-1; for(i = 0; i < overlap/2; i++) { diff --git a/celt/mdct.h b/celt/mdct.h index 529b706d9..1d9f6a2e6 100644 --- a/celt/mdct.h +++ b/celt/mdct.h @@ -42,7 +42,7 @@ #ifndef MDCT_H #define MDCT_H -#include "opus_defines.h" +#include "oac_defines.h" #include "kiss_fft.h" #include "arch.h" @@ -50,7 +50,7 @@ typedef struct { int n; int maxshift; const kiss_fft_state *kfft[4]; - const kiss_twiddle_scalar * OPUS_RESTRICT trig; + const kiss_twiddle_scalar * OAC_RESTRICT trig; } mdct_lookup; #if defined(HAVE_ARM_NE10) @@ -62,42 +62,42 @@ void clt_mdct_clear(mdct_lookup *l, int arch); /** Compute a forward MDCT and scale by 4/N, trashes the input array */ void clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, + kiss_fft_scalar * OAC_RESTRICT out, const celt_coef *window, int overlap, int shift, int stride, int arch); /** Compute a backward MDCT (no scaling) and performs weighted overlap-add (scales implicitly by 1/2) */ void clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const celt_coef * OPUS_RESTRICT window, + kiss_fft_scalar * OAC_RESTRICT out, + const celt_coef * OAC_RESTRICT window, int overlap, int shift, int stride, int arch); -#if !defined(OVERRIDE_OPUS_MDCT) +#if !defined(OVERRIDE_OAC_MDCT) /* Is run-time CPU detection enabled on this platform? */ -#if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) +#if defined(OAC_HAVE_RTCD) && defined(HAVE_ARM_NE10) -extern void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])( +extern void (*const CLT_MDCT_FORWARD_IMPL[OAC_ARCHMASK+1])( const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, const celt_coef *window, + kiss_fft_scalar * OAC_RESTRICT out, const celt_coef *window, int overlap, int shift, int stride, int arch); #define clt_mdct_forward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ - ((*CLT_MDCT_FORWARD_IMPL[(arch)&OPUS_ARCHMASK])(_l, _in, _out, \ + ((*CLT_MDCT_FORWARD_IMPL[(arch)&OAC_ARCHMASK])(_l, _in, _out, \ _window, _overlap, _shift, \ _stride, _arch)) -extern void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])( +extern void (*const CLT_MDCT_BACKWARD_IMPL[OAC_ARCHMASK+1])( const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, const celt_coef *window, + kiss_fft_scalar * OAC_RESTRICT out, const celt_coef *window, int overlap, int shift, int stride, int arch); #define clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ - (*CLT_MDCT_BACKWARD_IMPL[(arch)&OPUS_ARCHMASK])(_l, _in, _out, \ + (*CLT_MDCT_BACKWARD_IMPL[(arch)&OAC_ARCHMASK])(_l, _in, _out, \ _window, _overlap, _shift, \ _stride, _arch) -#else /* if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) */ +#else /* if defined(OAC_HAVE_RTCD) && defined(HAVE_ARM_NE10) */ #define clt_mdct_forward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ clt_mdct_forward_c(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) @@ -105,7 +105,7 @@ extern void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])( #define clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ clt_mdct_backward_c(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) -#endif /* end if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) && !defined(FIXED_POINT) */ -#endif /* end if !defined(OVERRIDE_OPUS_MDCT) */ +#endif /* end if defined(OAC_HAVE_RTCD) && defined(HAVE_ARM_NE10) && !defined(FIXED_POINT) */ +#endif /* end if !defined(OVERRIDE_OAC_MDCT) */ #endif diff --git a/celt/meson.build b/celt/meson.build index 46601ca13..a28bf2628 100644 --- a/celt/meson.build +++ b/celt/meson.build @@ -12,7 +12,7 @@ celt_neon_intr_sources = sources['CELT_SOURCES_ARM_NEON_INTR'] celt_static_libs = [] -if host_cpu_family in ['x86', 'x86_64'] and opus_conf.has('OPUS_HAVE_RTCD') +if host_cpu_family in ['x86', 'x86_64'] and oac_conf.has('OAC_HAVE_RTCD') celt_sources += sources['CELT_SOURCES_X86_RTCD'] endif @@ -23,10 +23,10 @@ foreach intr_name : ['sse', 'sse2', 'sse4_1', 'avx2', 'neon_intr'] endif intr_sources = get_variable('celt_@0@_sources'.format(intr_name)) - intr_args = get_variable('opus_@0@_args'.format(intr_name), []) + intr_args = get_variable('oac_@0@_args'.format(intr_name), []) celt_static_libs += static_library('celt_' + intr_name, intr_sources, c_args: intr_args, - include_directories: opus_includes, + include_directories: oac_includes, install: false) endforeach @@ -36,13 +36,13 @@ if (intrinsics_support.length() + asm_optimization.length() + inline_optimizatio endif if host_cpu_family in ['arm', 'aarch64'] and have_arm_intrinsics_or_asm - if opus_conf.has('OPUS_HAVE_RTCD') + if oac_conf.has('OAC_HAVE_RTCD') celt_sources += sources['CELT_SOURCES_ARM_RTCD'] endif if have_arm_ne10 celt_sources += sources['CELT_SOURCES_ARM_NE10'] endif - if opus_arm_external_asm + if oac_arm_external_asm subdir('arm') celt_static_libs += static_library('celt-armasm', celt_arm_armopts_s, celt_sources_arm_asm, @@ -55,10 +55,10 @@ if host_system == 'windows' celt_c_args += ['-DDLL_EXPORT'] endif -celt_lib = static_library('opus-celt', +celt_lib = static_library('oac-celt', celt_sources, c_args: celt_c_args, - include_directories: opus_includes, + include_directories: oac_includes, link_whole: celt_static_libs, dependencies: libm, install: false) diff --git a/celt/mfrngcod.h b/celt/mfrngcod.h index 809152a59..2b4918dfe 100644 --- a/celt/mfrngcod.h +++ b/celt/mfrngcod.h @@ -40,7 +40,7 @@ /*Bits to shift by to move a symbol into the high-order position.*/ # define EC_CODE_SHIFT (EC_CODE_BITS-EC_SYM_BITS-1) /*Carry bit of the high-order range symbol.*/ -# define EC_CODE_TOP (((opus_uint32)1U)<<(EC_CODE_BITS-1)) +# define EC_CODE_TOP (((oac_uint32)1U)<<(EC_CODE_BITS-1)) /*Low-order bit of the high-order range symbol.*/ # define EC_CODE_BOT (EC_CODE_TOP>>EC_SYM_BITS) /*The number of bits available for the last, partial symbol in the code field.*/ diff --git a/celt/mips/celt_mipsr1.h b/celt/mips/celt_mipsr1.h index 8a5d0c90a..01635544a 100644 --- a/celt/mips/celt_mipsr1.h +++ b/celt/mips/celt_mipsr1.h @@ -93,34 +93,34 @@ static inline long long MIPS_MADD(long long acc, int a, int b) { return acc; } -static inline opus_val32 MIPS_EXTR(long long acc, int shift) { - return (opus_val32)(acc >> shift); +static inline oac_val32 MIPS_EXTR(long long acc, int shift) { + return (oac_val32)(acc >> shift); } #endif #if defined (OVERRIDE_comb_filter) -void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, - opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, - const opus_val16 *window, int overlap, int arch) +void comb_filter(oac_val32 *y, oac_val32 *x, int T0, int T1, int N, + oac_val16 g0, oac_val16 g1, int tapset0, int tapset1, + const oac_val16 *window, int overlap, int arch) { int i; - opus_val32 x0, x1, x2, x3, x4; + oac_val32 x0, x1, x2, x3, x4; (void)arch; /* printf ("%d %d %f %f\n", T0, T1, g0, g1); */ - opus_val16 g00, g01, g02, g10, g11, g12; - static const opus_val16 gains[3][3] = { + oac_val16 g00, g01, g02, g10, g11, g12; + static const oac_val16 gains[3][3] = { {QCONST16(0.3066406250f, 15), QCONST16(0.2170410156f, 15), QCONST16(0.1296386719f, 15)}, {QCONST16(0.4638671875f, 15), QCONST16(0.2680664062f, 15), QCONST16(0.f, 15)}, {QCONST16(0.7998046875f, 15), QCONST16(0.1000976562f, 15), QCONST16(0.f, 15)}}; if (g0==0 && g1==0) { - /* OPT: Happens to work without the OPUS_MOVE(), but only because the current encoder already copies x to y */ + /* OPT: Happens to work without the OAC_MOVE(), but only because the current encoder already copies x to y */ if (x!=y) - OPUS_MOVE(y, x, N); + OAC_MOVE(y, x, N); return; } @@ -140,8 +140,8 @@ void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, for (i=0;i 0) { @@ -114,26 +114,26 @@ static OPUS_INLINE opus_val32 celt_maxabs16(const opus_val16 *x, int len) x01 = __builtin_mips_absq_s_ph(*x2); __builtin_mips_cmp_lt_ph(v2max, x01); v2max = __builtin_mips_pick_ph(x01, v2max); - maxlo = EXTRACT16((opus_val32)v2max); - maxhi = EXTRACT16((opus_val32)v2max >> 16); + maxlo = EXTRACT16((oac_val32)v2max); + maxhi = EXTRACT16((oac_val32)v2max >> 16); maxlo = MAX16(MAX16(maxlo, maxhi), ABS16(x[len - 1])); break; case 2: x01 = __builtin_mips_absq_s_ph(*x2); __builtin_mips_cmp_lt_ph(v2max, x01); v2max = __builtin_mips_pick_ph(x01, v2max); - maxlo = EXTRACT16((opus_val32)v2max); - maxhi = EXTRACT16((opus_val32)v2max >> 16); + maxlo = EXTRACT16((oac_val32)v2max); + maxhi = EXTRACT16((oac_val32)v2max >> 16); maxlo = MAX16(maxlo, maxhi); break; case 1: - maxlo = EXTRACT16((opus_val32)v2max); - maxhi = EXTRACT16((opus_val32)v2max >> 16); + maxlo = EXTRACT16((oac_val32)v2max); + maxhi = EXTRACT16((oac_val32)v2max >> 16); return MAX16(MAX16(maxlo, maxhi), ABS16(x[len - 1])); break; case 0: - maxlo = EXTRACT16((opus_val32)v2max); - maxhi = EXTRACT16((opus_val32)v2max >> 16); + maxlo = EXTRACT16((oac_val32)v2max); + maxhi = EXTRACT16((oac_val32)v2max >> 16); maxlo = MAX16(maxlo, maxhi); break; default: @@ -145,13 +145,13 @@ static OPUS_INLINE opus_val32 celt_maxabs16(const opus_val16 *x, int len) * in ilog2-like context it's worth to add 1 * for proper magnitude whether saturated */ - return (opus_val32)maxlo + 1; + return (oac_val32)maxlo + 1; } #elif __mips == 32 #undef MULT16_32_Q16 -#define MULT16_32_Q16(a,b) ((opus_val32)SHR((opus_int64)(SHL32((a), 16))*(b),32)) +#define MULT16_32_Q16(a,b) ((oac_val32)SHR((oac_int64)(SHL32((a), 16))*(b),32)) #endif diff --git a/celt/mips/mdct_mipsr1.h b/celt/mips/mdct_mipsr1.h index bc349cc25..790c64f72 100644 --- a/celt/mips/mdct_mipsr1.h +++ b/celt/mips/mdct_mipsr1.h @@ -107,7 +107,7 @@ static inline int S_MUL_SUB_PSR(int a, int b, int c, int d, int shift) { #if defined (OVERRIDE_clt_mdct_forward) /* Forward MDCT trashes the input array */ -void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, +void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OAC_RESTRICT out, const celt_coef *window, int overlap, int shift, int stride, int arch) { int i; @@ -144,11 +144,11 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar /* Window, shuffle, fold */ { /* Temp pointers to make it really clear to the compiler what we're doing */ - const kiss_fft_scalar * OPUS_RESTRICT xp1 = in+(overlap>>1); - const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+N2-1+(overlap>>1); - kiss_fft_scalar * OPUS_RESTRICT yp = f; - const celt_coef * OPUS_RESTRICT wp1 = window+(overlap>>1); - const celt_coef * OPUS_RESTRICT wp2 = window+(overlap>>1)-1; + const kiss_fft_scalar * OAC_RESTRICT xp1 = in+(overlap>>1); + const kiss_fft_scalar * OAC_RESTRICT xp2 = in+N2-1+(overlap>>1); + kiss_fft_scalar * OAC_RESTRICT yp = f; + const celt_coef * OAC_RESTRICT wp1 = window+(overlap>>1); + const celt_coef * OAC_RESTRICT wp2 = window+(overlap>>1)-1; for(i=0;i<((overlap+3)>>2);i++) { /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ @@ -182,10 +182,10 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar } /* Pre-rotation */ { - kiss_fft_scalar * OPUS_RESTRICT yp = f; + kiss_fft_scalar * OAC_RESTRICT yp = f; const kiss_twiddle_scalar *t = &trig[0]; #ifdef FIXED_POINT - opus_val32 maxval=1; + oac_val32 maxval=1; #endif for(i=0;i>1); - const kiss_twiddle_scalar * OPUS_RESTRICT t = &trig[0]; - const opus_int16 * OPUS_RESTRICT bitrev = l->kfft[shift]->bitrev; + const kiss_fft_scalar * OAC_RESTRICT xp1 = in; + const kiss_fft_scalar * OAC_RESTRICT xp2 = in+stride*(N2-1); + kiss_fft_scalar * OAC_RESTRICT yp = out+(overlap>>1); + const kiss_twiddle_scalar * OAC_RESTRICT t = &trig[0]; + const oac_int16 * OAC_RESTRICT bitrev = l->kfft[shift]->bitrev; for(i=0;ikfft[shift], (kiss_fft_cpx*)(out+(overlap>>1)) ARG_FIXED(fft_shift)); + oac_fft_impl(l->kfft[shift], (kiss_fft_cpx*)(out+(overlap>>1)) ARG_FIXED(fft_shift)); /* Post-rotate and de-shuffle from both ends of the buffer at once to make it in-place. */ @@ -360,10 +360,10 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala /* Mirror on both sides for TDAC */ { - kiss_fft_scalar * OPUS_RESTRICT xp1 = out+overlap-1; - kiss_fft_scalar * OPUS_RESTRICT yp1 = out; - const celt_coef * OPUS_RESTRICT wp1 = window; - const celt_coef * OPUS_RESTRICT wp2 = window+overlap-1; + kiss_fft_scalar * OAC_RESTRICT xp1 = out+overlap-1; + kiss_fft_scalar * OAC_RESTRICT yp1 = out; + const celt_coef * OAC_RESTRICT wp1 = window; + const celt_coef * OAC_RESTRICT wp2 = window+overlap-1; for(i = 0; i < overlap/2; i++) { diff --git a/celt/mips/pitch_mipsr1.h b/celt/mips/pitch_mipsr1.h index 9b73a126b..f0bae2b58 100644 --- a/celt/mips/pitch_mipsr1.h +++ b/celt/mips/pitch_mipsr1.h @@ -38,7 +38,7 @@ #if defined (__mips_dsp) && __mips == 32 -#define accumulator_t opus_int64 +#define accumulator_t oac_int64 #define MIPS_MAC(acc,a,b) \ __builtin_mips_madd((acc), (int)(a), (int)(b)) @@ -52,7 +52,7 @@ #else /* any other MIPS */ /* using madd is slower due to single accumulator */ -#define accumulator_t opus_int32 +#define accumulator_t oac_int32 #define MIPS_MAC MAC16_16 #define OVERRIDE_CELT_INNER_PROD @@ -64,8 +64,8 @@ #if defined(OVERRIDE_CELT_INNER_PROD) -static OPUS_INLINE opus_val32 celt_inner_prod(const opus_val16 *x, - const opus_val16 *y, int N, int arch) +static OAC_INLINE oac_val32 celt_inner_prod(const oac_val16 *x, + const oac_val16 *y, int N, int arch) { int j; accumulator_t acc = 0; @@ -156,13 +156,13 @@ static OPUS_INLINE opus_val32 celt_inner_prod(const opus_val16 *x, (void)arch; - return (opus_val32)acc; + return (oac_val32)acc; } #endif /* OVERRIDE_CELT_INNER_PROD */ #if defined(OVERRIDE_DUAL_INNER_PROD) -static inline void dual_inner_prod(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2, int arch) +static inline void dual_inner_prod(const oac_val16 *x, const oac_val16 *y01, const oac_val16 *y02, + int N, oac_val32 *xy1, oac_val32 *xy2, int arch) { int j; accumulator_t acc1 = 0; @@ -245,18 +245,18 @@ static inline void dual_inner_prod(const opus_val16 *x, const opus_val16 *y01, c (void)arch; - *xy1 = (opus_val32)acc1; - *xy2 = (opus_val32)acc2; + *xy1 = (oac_val32)acc1; + *xy2 = (oac_val32)acc2; } #endif /* OVERRIDE_DUAL_INNER_PROD */ #if defined(OVERRIDE_XCORR_KERNEL) -static inline void xcorr_kernel_mips(const opus_val16 * x, - const opus_val16 * y, opus_val32 sum[4], int len) +static inline void xcorr_kernel_mips(const oac_val16 * x, + const oac_val16 * y, oac_val32 sum[4], int len) { int j; - opus_val16 y_0, y_1, y_2, y_3; + oac_val16 y_0, y_1, y_2, y_3; accumulator_t sum_0, sum_1, sum_2, sum_3; sum_0 = (accumulator_t)sum[0]; @@ -269,7 +269,7 @@ static inline void xcorr_kernel_mips(const opus_val16 * x, y_2=*y++; for (j=0;jnbAllocVectors = BITALLOC_SIZE; - allocVectors = opus_alloc(sizeof(unsigned char)*(BITALLOC_SIZE*mode->nbEBands)); + allocVectors = oac_alloc(sizeof(unsigned char)*(BITALLOC_SIZE*mode->nbEBands)); if (allocVectors==NULL) { mode->allocVectors = NULL; @@ -179,7 +179,7 @@ static void compute_allocation_table(CELTMode *mode) } /* Check for standard mode */ - if (mode->Fs == 400*(opus_int32)mode->shortMdctSize) + if (mode->Fs == 400*(oac_int32)mode->shortMdctSize) { for (i=0;inbEBands;i++) allocVectors[i] = band_allocation[i]; @@ -195,15 +195,15 @@ static void compute_allocation_table(CELTMode *mode) int k; for (k=0;k mode->eBands[j]*(opus_int32)mode->Fs/mode->shortMdctSize) + if (400*(oac_int32)eband5ms[k] > mode->eBands[j]*(oac_int32)mode->Fs/mode->shortMdctSize) break; } if (k>maxBands-1) allocVectors[i*mode->nbEBands+j] = band_allocation[i*maxBands + maxBands-1]; else { - opus_int32 a0, a1; - a1 = mode->eBands[j]*(opus_int32)mode->Fs/mode->shortMdctSize - 400*(opus_int32)eband5ms[k-1]; - a0 = 400*(opus_int32)eband5ms[k] - mode->eBands[j]*(opus_int32)mode->Fs/mode->shortMdctSize; + oac_int32 a0, a1; + a1 = mode->eBands[j]*(oac_int32)mode->Fs/mode->shortMdctSize - 400*(oac_int32)eband5ms[k-1]; + a0 = 400*(oac_int32)eband5ms[k] - mode->eBands[j]*(oac_int32)mode->Fs/mode->shortMdctSize; allocVectors[i*mode->nbEBands+j] = (a0*band_allocation[i*maxBands+k-1] + a1*band_allocation[i*maxBands+k])/(a0+a1); } @@ -224,16 +224,16 @@ static void compute_allocation_table(CELTMode *mode) #endif /* CUSTOM_MODES */ -CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) +CELTMode *oac_custom_mode_create(oac_int32 Fs, int frame_size, int *error) { int i; #ifdef CUSTOM_MODES CELTMode *mode=NULL; int res; celt_coef *window; - opus_int16 *logN; + oac_int16 *logN; int LM; - int arch = opus_select_arch(); + int arch = oac_select_arch(); ALLOC_STACK; #if !defined(VAR_ARRAYS) && !defined(USE_ALLOCA) if (global_stack==NULL) @@ -251,7 +251,7 @@ CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) (frame_size<shortMdctSize*static_mode_list[i]->nbShortMdcts) { if (error) - *error = OPUS_OK; + *error = OAC_OK; return (CELTMode*)static_mode_list[i]; } } @@ -260,7 +260,7 @@ CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) #ifndef CUSTOM_MODES if (error) - *error = OPUS_BAD_ARG; + *error = OAC_BAD_ARG; return NULL; #else @@ -269,7 +269,7 @@ CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) if (Fs < 8000 || Fs > 96000) { if (error) - *error = OPUS_BAD_ARG; + *error = OAC_BAD_ARG; return NULL; } #ifdef ENABLE_QEXT @@ -279,24 +279,24 @@ CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) #endif { if (error) - *error = OPUS_BAD_ARG; + *error = OAC_BAD_ARG; return NULL; } /* Frames of less than 1ms are not supported. */ - if ((opus_int32)frame_size*1000 < Fs) + if ((oac_int32)frame_size*1000 < Fs) { if (error) - *error = OPUS_BAD_ARG; + *error = OAC_BAD_ARG; return NULL; } - if ((opus_int32)frame_size*75 >= Fs && (frame_size%16)==0) + if ((oac_int32)frame_size*75 >= Fs && (frame_size%16)==0) { LM = 3; - } else if ((opus_int32)frame_size*150 >= Fs && (frame_size%8)==0) + } else if ((oac_int32)frame_size*150 >= Fs && (frame_size%8)==0) { LM = 2; - } else if ((opus_int32)frame_size*300 >= Fs && (frame_size%4)==0) + } else if ((oac_int32)frame_size*300 >= Fs && (frame_size%4)==0) { LM = 1; } else @@ -305,14 +305,14 @@ CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) } /* Shorts longer than 3.3ms are not supported. */ - if ((opus_int32)(frame_size>>LM)*300 > Fs) + if ((oac_int32)(frame_size>>LM)*300 > Fs) { if (error) - *error = OPUS_BAD_ARG; + *error = OAC_BAD_ARG; return NULL; } - mode = opus_alloc(sizeof(CELTMode)); + mode = oac_alloc(sizeof(CELTMode)); if (mode==NULL) goto failure; mode->Fs = Fs; @@ -383,7 +383,7 @@ CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) if (mode->allocVectors==NULL) goto failure; - window = (celt_coef*)opus_alloc(mode->overlap*sizeof(*window)); + window = (celt_coef*)oac_alloc(mode->overlap*sizeof(*window)); if (window==NULL) goto failure; @@ -396,7 +396,7 @@ CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) #endif mode->window = window; - logN = (opus_int16*)opus_alloc(mode->nbEBands*sizeof(opus_int16)); + logN = (oac_int16*)oac_alloc(mode->nbEBands*sizeof(oac_int16)); if (logN==NULL) goto failure; @@ -411,22 +411,22 @@ CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) goto failure; if (error) - *error = OPUS_OK; + *error = OAC_OK; return mode; failure: if (error) - *error = OPUS_ALLOC_FAIL; + *error = OAC_ALLOC_FAIL; if (mode!=NULL) - opus_custom_mode_destroy(mode); + oac_custom_mode_destroy(mode); return NULL; #endif /* !CUSTOM_MODES */ } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -void opus_custom_mode_destroy(CELTMode *mode) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +void oac_custom_mode_destroy(CELTMode *mode) { - int arch = opus_select_arch(); + int arch = oac_select_arch(); if (mode == NULL) return; @@ -443,18 +443,18 @@ void opus_custom_mode_destroy(CELTMode *mode) } #endif /* CUSTOM_MODES_ONLY */ #ifdef CUSTOM_MODES - opus_free((opus_int16*)mode->eBands); - opus_free((unsigned char*)mode->allocVectors); + oac_free((oac_int16*)mode->eBands); + oac_free((unsigned char*)mode->allocVectors); - opus_free((opus_val16*)mode->window); - opus_free((opus_int16*)mode->logN); + oac_free((oac_val16*)mode->window); + oac_free((oac_int16*)mode->logN); - opus_free((opus_int16*)mode->cache.index); - opus_free((unsigned char*)mode->cache.bits); - opus_free((unsigned char*)mode->cache.caps); + oac_free((oac_int16*)mode->cache.index); + oac_free((unsigned char*)mode->cache.bits); + oac_free((unsigned char*)mode->cache.caps); clt_mdct_clear(&mode->mdct, arch); - opus_free((CELTMode *)mode); + oac_free((CELTMode *)mode); #else (void)arch; celt_assert(0); diff --git a/celt/modes.h b/celt/modes.h index c5f978061..8c45f72dd 100644 --- a/celt/modes.h +++ b/celt/modes.h @@ -30,7 +30,7 @@ #ifndef MODES_H #define MODES_H -#include "opus_types.h" +#include "oac_types.h" #include "celt.h" #include "arch.h" #include "mdct.h" @@ -43,7 +43,7 @@ typedef struct { int size; - const opus_int16 *index; + const oac_int16 *index; const unsigned char *bits; const unsigned char *caps; } PulseCache; @@ -51,14 +51,14 @@ typedef struct { /** Mode definition (opaque) @brief Mode definition */ -struct OpusCustomMode { - opus_int32 Fs; +struct OacCustomMode { + oac_int32 Fs; int overlap; int nbEBands; int effEBands; - opus_val16 preemph[4]; - const opus_int16 *eBands; /**< Definition for each "pseudo-critical band" */ + oac_val16 preemph[4]; + const oac_int16 *eBands; /**< Definition for each "pseudo-critical band" */ int maxLM; int nbShortMdcts; @@ -66,7 +66,7 @@ struct OpusCustomMode { int nbAllocVectors; /**< Number of lines in the matrix below */ const unsigned char *allocVectors; /**< Number of bits in each band for several rates */ - const opus_int16 *logN; + const oac_int16 *logN; const celt_coef *window; mdct_lookup mdct; diff --git a/celt/opus_custom_demo.c b/celt/oac_custom_demo.c similarity index 83% rename from celt/opus_custom_demo.c rename to celt/oac_custom_demo.c index ca2269079..e1a14459e 100644 --- a/celt/opus_custom_demo.c +++ b/celt/oac_custom_demo.c @@ -30,7 +30,7 @@ #include "config.h" #endif -#include "opus_custom.h" +#include "oac_custom.h" #include "arch.h" #include "modes.h" #include @@ -40,16 +40,16 @@ #define MAX_PACKET 1275 -static OPUS_INLINE void _opus_ctl_failed(const char *file, int line) +static OAC_INLINE void _oac_ctl_failed(const char *file, int line) { fprintf(stderr, "\n ***************************************************\n"); fprintf(stderr, " *** A fatal error was detected. ***\n"); fprintf(stderr, " ***************************************************\n"); fprintf(stderr, "En/decoder ctl function %s failed at %d for %s.\n", - file, line, opus_get_version_string()); + file, line, oac_get_version_string()); } -#define opus_ctl_failed() _opus_ctl_failed(__FILE__, __LINE__); +#define oac_ctl_failed() _oac_ctl_failed(__FILE__, __LINE__); static void print_usage(char **argv) { fprintf (stderr, "Usage: %s [-e | -d] " @@ -66,7 +66,7 @@ static void print_usage(char **argv) { fprintf (stderr, " -loss encoding (robsutness setting) and decoding (simulating loss)\n"); } -static void int_to_char(opus_uint32 i, unsigned char ch[4]) +static void int_to_char(oac_uint32 i, unsigned char ch[4]) { ch[0] = i>>24; ch[1] = (i>>16)&0xFF; @@ -74,10 +74,10 @@ static void int_to_char(opus_uint32 i, unsigned char ch[4]) ch[3] = i&0xFF; } -static opus_uint32 char_to_int(unsigned char ch[4]) +static oac_uint32 char_to_int(unsigned char ch[4]) { - return ((opus_uint32)ch[0]<<24) | ((opus_uint32)ch[1]<<16) - | ((opus_uint32)ch[2]<< 8) | (opus_uint32)ch[3]; + return ((oac_uint32)ch[0]<<24) | ((oac_uint32)ch[1]<<16) + | ((oac_uint32)ch[2]<< 8) | (oac_uint32)ch[3]; } #define check_encoder_option(decode_only, opt) do {if (decode_only) {fprintf(stderr, "option %s is only for encoding\n", opt); goto failure;}} while(0) @@ -90,7 +90,7 @@ static opus_uint32 char_to_int(unsigned char ch[4]) static const int format_size[3] = {2, 3, 4}; typedef union { - opus_int32 i; + oac_int32 i; float f; } float_bits; @@ -100,16 +100,16 @@ int main(int argc, char *argv[]) int err; int ret=1; int args; - opus_uint32 enc_final_range; - opus_uint32 dec_final_range; + oac_uint32 enc_final_range; + oac_uint32 dec_final_range; int encode_only=0, decode_only=0; char *inFile, *outFile; FILE *fin=NULL, *fout=NULL; - OpusCustomMode *mode=NULL; - OpusCustomEncoder *enc=NULL; - OpusCustomDecoder *dec=NULL; + OacCustomMode *mode=NULL; + OacCustomEncoder *enc=NULL; + OacCustomDecoder *dec=NULL; int len; - opus_int32 frame_size, channels, rate; + oac_int32 frame_size, channels, rate; int format=FORMAT_S16_LE; int bytes_per_packet=0; unsigned char data[MAX_PACKET]; @@ -120,8 +120,8 @@ int main(int argc, char *argv[]) double rmsd = 0; #endif int count = 0; - opus_int32 skip; - opus_int32 *in=NULL, *out=NULL; + oac_int32 skip; + oac_int32 *in=NULL, *out=NULL; unsigned char *fbytes=NULL; args = 1; if (argc < 7) @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) args++; } - rate = (opus_int32)atol(argv[args]); + rate = (oac_int32)atol(argv[args]); args++; if (rate != 8000 && rate != 12000 @@ -164,7 +164,7 @@ int main(int argc, char *argv[]) if (channels < 1 || channels > 2) { - fprintf(stderr, "Opus_demo supports only 1 or 2 channels.\n"); + fprintf(stderr, "Oac_demo supports only 1 or 2 channels.\n"); goto failure; } @@ -173,7 +173,7 @@ int main(int argc, char *argv[]) if (!decode_only) { - bytes_per_packet = (opus_int32)atol(argv[args]); + bytes_per_packet = (oac_int32)atol(argv[args]); args++; if (bytes_per_packet < 0 || bytes_per_packet > MAX_PACKET) { @@ -183,7 +183,7 @@ int main(int argc, char *argv[]) } } - mode = opus_custom_mode_create(rate, frame_size, NULL); + mode = oac_custom_mode_create(rate, frame_size, NULL); if (mode == NULL) { fprintf(stderr, "failed to create a mode\n"); @@ -216,38 +216,38 @@ int main(int argc, char *argv[]) } } if (!decode_only) { - enc = opus_custom_encoder_create(mode, channels, &err); + enc = oac_custom_encoder_create(mode, channels, &err); if (err != 0) { - fprintf(stderr, "Failed to create the encoder: %s\n", opus_strerror(err)); + fprintf(stderr, "Failed to create the encoder: %s\n", oac_strerror(err)); goto failure; } if (complexity >= 0) { - if(opus_custom_encoder_ctl( - enc, OPUS_SET_COMPLEXITY(complexity)) != OPUS_OK) { - opus_ctl_failed(); + if(oac_custom_encoder_ctl( + enc, OAC_SET_COMPLEXITY(complexity)) != OAC_OK) { + oac_ctl_failed(); goto failure; } } if (percent_loss >= 0) { - if(opus_custom_encoder_ctl( - enc, OPUS_SET_PACKET_LOSS_PERC((int)percent_loss)) != - OPUS_OK) { - opus_ctl_failed(); + if(oac_custom_encoder_ctl( + enc, OAC_SET_PACKET_LOSS_PERC((int)percent_loss)) != + OAC_OK) { + oac_ctl_failed(); goto failure; } } } if (!encode_only) { - dec = opus_custom_decoder_create(mode, channels, &err); + dec = oac_custom_decoder_create(mode, channels, &err); if (err != 0) { - fprintf(stderr, "Failed to create the decoder: %s\n", opus_strerror(err)); + fprintf(stderr, "Failed to create the decoder: %s\n", oac_strerror(err)); goto failure; } - if(opus_custom_decoder_ctl(dec, OPUS_GET_LOOKAHEAD(&skip)) != OPUS_OK) { - opus_ctl_failed(); + if(oac_custom_decoder_ctl(dec, OAC_GET_LOOKAHEAD(&skip)) != OAC_OK) { + oac_ctl_failed(); goto failure; } } @@ -270,8 +270,8 @@ int main(int argc, char *argv[]) fprintf (stderr, "Could not open output file %s\n", argv[argc-1]); goto failure; } - in = (opus_int32*)malloc(frame_size*channels*sizeof(opus_int32)); - out = (opus_int32*)malloc(frame_size*channels*sizeof(opus_int32)); + in = (oac_int32*)malloc(frame_size*channels*sizeof(oac_int32)); + out = (oac_int32*)malloc(frame_size*channels*sizeof(oac_int32)); fbytes = (unsigned char*)malloc(frame_size*channels*4); while (!feof(fin)) @@ -308,7 +308,7 @@ int main(int argc, char *argv[]) if (format == FORMAT_S16_LE) { for(i=0;i 0x007fff00) s = 0x007fff00; if (s < -0x007fff00) s = -0x007fff00; @@ -423,7 +423,7 @@ int main(int argc, char *argv[]) } else if (format == FORMAT_S24_LE) { for(i=0;i<(ret-skip)*channels;i++) { - opus_int32 s; + oac_int32 s; s=out[i+(skip*channels)]; if (s > 0x007fffff) s = 0x007fffff; if (s < -0x007fffff) s = -0x007fffff; @@ -479,11 +479,11 @@ int main(int argc, char *argv[]) #endif failure: /* Cleanup after ourselves. */ - if (enc) opus_custom_encoder_destroy(enc); - if (dec) opus_custom_decoder_destroy(dec); + if (enc) oac_custom_encoder_destroy(enc); + if (dec) oac_custom_decoder_destroy(dec); if (fin) fclose(fin); if (fout) fclose(fout); - if (mode) opus_custom_mode_destroy(mode); + if (mode) oac_custom_mode_destroy(mode); if (in) free(in); if (out) free(out); if (fbytes) free(fbytes); diff --git a/celt/os_support.h b/celt/os_support.h index 48d742b3d..c86bbfb0e 100644 --- a/celt/os_support.h +++ b/celt/os_support.h @@ -35,22 +35,22 @@ # include "custom_support.h" #endif -#include "opus_types.h" -#include "opus_defines.h" +#include "oac_types.h" +#include "oac_defines.h" #include #include -/** Opus wrapper for malloc(). To do your own dynamic allocation replace this function, opus_realloc, and opus_free */ -#ifndef OVERRIDE_OPUS_ALLOC -static OPUS_INLINE void *opus_alloc (size_t size) +/** Oac wrapper for malloc(). To do your own dynamic allocation replace this function, oac_realloc, and oac_free */ +#ifndef OVERRIDE_OAC_ALLOC +static OAC_INLINE void *oac_alloc (size_t size) { return malloc(size); } #endif -#ifndef OVERRIDE_OPUS_REALLOC -static OPUS_INLINE void *opus_realloc (void *ptr, size_t size) +#ifndef OVERRIDE_OAC_REALLOC +static OAC_INLINE void *oac_realloc (void *ptr, size_t size) { return realloc(ptr, size); } @@ -58,36 +58,36 @@ static OPUS_INLINE void *opus_realloc (void *ptr, size_t size) /** Used only for non-threadsafe pseudostack. If desired, this can always return the same area of memory rather than allocating a new one every time. */ -#ifndef OVERRIDE_OPUS_ALLOC_SCRATCH -static OPUS_INLINE void *opus_alloc_scratch (size_t size) +#ifndef OVERRIDE_OAC_ALLOC_SCRATCH +static OAC_INLINE void *oac_alloc_scratch (size_t size) { /* Scratch space doesn't need to be cleared */ - return opus_alloc(size); + return oac_alloc(size); } #endif -/** Opus wrapper for free(). To do your own dynamic allocation replace this function, opus_realloc, and opus_free */ -#ifndef OVERRIDE_OPUS_FREE -static OPUS_INLINE void opus_free (void *ptr) +/** Oac wrapper for free(). To do your own dynamic allocation replace this function, oac_realloc, and oac_free */ +#ifndef OVERRIDE_OAC_FREE +static OAC_INLINE void oac_free (void *ptr) { free(ptr); } #endif /** Copy n elements from src to dst. The 0* term provides compile-time type checking */ -#ifndef OVERRIDE_OPUS_COPY -#define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) +#ifndef OVERRIDE_OAC_COPY +#define OAC_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) #endif /** Copy n elements from src to dst, allowing overlapping regions. The 0* term provides compile-time type checking */ -#ifndef OVERRIDE_OPUS_MOVE -#define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) +#ifndef OVERRIDE_OAC_MOVE +#define OAC_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) #endif /** Set n elements of dst to zero */ -#ifndef OVERRIDE_OPUS_CLEAR -#define OPUS_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst)))) +#ifndef OVERRIDE_OAC_CLEAR +#define OAC_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst)))) #endif /*#ifdef __GNUC__ diff --git a/celt/pitch.c b/celt/pitch.c index fe3b0bd31..0fa83b338 100644 --- a/celt/pitch.c +++ b/celt/pitch.c @@ -42,17 +42,17 @@ #include "mathops.h" #include "celt_lpc.h" -static void find_best_pitch(opus_val32 *xcorr, opus_val16 *y, int len, +static void find_best_pitch(oac_val32 *xcorr, oac_val16 *y, int len, int max_pitch, int *best_pitch #ifdef FIXED_POINT - , int yshift, opus_val32 maxcorr + , int yshift, oac_val32 maxcorr #endif ) { int i, j; - opus_val32 Syy=1; - opus_val16 best_num[2]; - opus_val32 best_den[2]; + oac_val32 Syy=1; + oac_val16 best_num[2]; + oac_val32 best_den[2]; #ifdef FIXED_POINT int xshift; @@ -71,8 +71,8 @@ static void find_best_pitch(opus_val32 *xcorr, opus_val16 *y, int len, { if (xcorr[i]>0) { - opus_val16 num; - opus_val32 xcorr16; + oac_val16 num; + oac_val32 xcorr16; xcorr16 = EXTRACT16(VSHR32(xcorr[i], xshift)); #ifndef FIXED_POINT /* Considering the range of xcorr16, this should avoid both underflows @@ -102,13 +102,13 @@ static void find_best_pitch(opus_val32 *xcorr, opus_val16 *y, int len, } } -static void celt_fir5(opus_val16 *x, - const opus_val16 *num, +static void celt_fir5(oac_val16 *x, + const oac_val16 *num, int N) { int i; - opus_val16 num0, num1, num2, num3, num4; - opus_val32 mem0, mem1, mem2, mem3, mem4; + oac_val16 num0, num1, num2, num3, num4; + oac_val32 mem0, mem1, mem2, mem3, mem4; num0=num[0]; num1=num[1]; num2=num[2]; @@ -121,7 +121,7 @@ static void celt_fir5(opus_val16 *x, mem4=0; for (i=0;i0); celt_sig_assert(((size_t)_x&3)==0); for (i=0;i0); lag = len+max_pitch; - ALLOC(x_lp4, len>>2, opus_val16); - ALLOC(y_lp4, lag>>2, opus_val16); - ALLOC(xcorr, max_pitch>>1, opus_val32); + ALLOC(x_lp4, len>>2, oac_val16); + ALLOC(y_lp4, lag>>2, oac_val16); + ALLOC(xcorr, max_pitch>>1, oac_val32); /* Downsample by 2 again */ for (j=0;j>2;j++) @@ -372,7 +372,7 @@ void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTR #endif for (i=0;i>1;i++) { - opus_val32 sum; + oac_val32 sum; xcorr[i] = 0; if (abs(i-2*best_pitch[0])>2 && abs(i-2*best_pitch[1])>2) continue; @@ -397,7 +397,7 @@ void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTR /* Refine by pseudo-interpolation */ if (best_pitch[0]>0 && best_pitch[0]<(max_pitch>>1)-1) { - opus_val32 a, b, c; + oac_val32 a, b, c; a = xcorr[best_pitch[0]-1]; b = xcorr[best_pitch[0]]; c = xcorr[best_pitch[0]+1]; @@ -416,12 +416,12 @@ void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTR } #ifdef FIXED_POINT -static opus_val16 compute_pitch_gain(opus_val32 xy, opus_val32 xx, opus_val32 yy) +static oac_val16 compute_pitch_gain(oac_val32 xy, oac_val32 xx, oac_val32 yy) { - opus_val32 x2y2; + oac_val32 x2y2; int sx, sy, shift; - opus_val32 g; - opus_val16 den; + oac_val32 g; + oac_val16 den; if (xy == 0 || xx == 0 || yy == 0) return 0; sx = celt_ilog2(xx)-14; @@ -444,25 +444,25 @@ static opus_val16 compute_pitch_gain(opus_val32 xy, opus_val32 xx, opus_val32 yy return EXTRACT16(MAX32(-Q15ONE, MIN32(g, Q15ONE))); } #else -static opus_val16 compute_pitch_gain(opus_val32 xy, opus_val32 xx, opus_val32 yy) +static oac_val16 compute_pitch_gain(oac_val32 xy, oac_val32 xx, oac_val32 yy) { return xy/celt_sqrt(1+xx*yy); } #endif static const int second_check[16] = {0, 0, 3, 2, 3, 2, 5, 2, 3, 2, 3, 2, 5, 2, 3, 2}; -opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, - int N, int *T0_, int prev_period, opus_val16 prev_gain, int arch) +oac_val16 remove_doubling(oac_val16 *x, int maxperiod, int minperiod, + int N, int *T0_, int prev_period, oac_val16 prev_gain, int arch) { int k, i, T, T0; - opus_val16 g, g0; - opus_val16 pg; - opus_val32 xy,xx,yy,xy2; - opus_val32 xcorr[3]; - opus_val32 best_xy, best_yy; + oac_val16 g, g0; + oac_val16 pg; + oac_val32 xy,xx,yy,xy2; + oac_val32 xcorr[3]; + oac_val32 best_xy, best_yy; int offset; int minperiod0; - VARDECL(opus_val32, yy_lookup); + VARDECL(oac_val32, yy_lookup); SAVE_STACK; minperiod0 = minperiod; @@ -476,7 +476,7 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, *T0_=maxperiod-1; T = T0 = *T0_; - ALLOC(yy_lookup, maxperiod+1, opus_val32); + ALLOC(yy_lookup, maxperiod+1, oac_val32); dual_inner_prod(x, x, x-T0, N, &xx, &xy, arch); yy_lookup[0] = xx; yy=xx; @@ -493,9 +493,9 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, for (k=2;k<=15;k++) { int T1, T1b; - opus_val16 g1; - opus_val16 cont=0; - opus_val16 thresh; + oac_val16 g1; + oac_val16 cont=0; + oac_val16 thresh; T1 = celt_udiv(2*T0+k, 2*k); if (T1 < minperiod) break; diff --git a/celt/pitch.h b/celt/pitch.h index e5eecdd9a..5a7966057 100644 --- a/celt/pitch.h +++ b/celt/pitch.h @@ -37,8 +37,8 @@ #include "modes.h" #include "cpu_support.h" -#if (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT)) \ - || ((defined(OPUS_X86_MAY_HAVE_SSE4_1) || defined(OPUS_X86_MAY_HAVE_SSE2)) && defined(FIXED_POINT)) +#if (defined(OAC_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT)) \ + || ((defined(OAC_X86_MAY_HAVE_SSE4_1) || defined(OAC_X86_MAY_HAVE_SSE2)) && defined(FIXED_POINT)) #include "x86/pitch_sse.h" #endif @@ -46,26 +46,26 @@ #include "mips/pitch_mipsr1.h" #endif -#if (defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) +#if (defined(OAC_ARM_ASM) || defined(OAC_ARM_MAY_HAVE_NEON_INTR)) # include "arm/pitch_arm.h" #endif -void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x_lp, +void pitch_downsample(celt_sig * OAC_RESTRICT x[], oac_val16 * OAC_RESTRICT x_lp, int len, int C, int factor, int arch); -void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTRICT y, +void pitch_search(const oac_val16 * OAC_RESTRICT x_lp, oac_val16 * OAC_RESTRICT y, int len, int max_pitch, int *pitch, int arch); -opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, - int N, int *T0, int prev_period, opus_val16 prev_gain, int arch); +oac_val16 remove_doubling(oac_val16 *x, int maxperiod, int minperiod, + int N, int *T0, int prev_period, oac_val16 prev_gain, int arch); /* OPT: This is the kernel you really want to optimize. It gets used a lot by the prefilter and by the PLC. */ -static OPUS_INLINE void xcorr_kernel_c(const opus_val16 * x, const opus_val16 * y, opus_val32 sum[4], int len) +static OAC_INLINE void xcorr_kernel_c(const oac_val16 * x, const oac_val16 * y, oac_val32 sum[4], int len) { int j; - opus_val16 y_0, y_1, y_2, y_3; + oac_val16 y_0, y_1, y_2, y_3; celt_assert(len>=3); y_3=0; /* gcc doesn't realize that y_3 can't be used uninitialized */ y_0=*y++; @@ -73,7 +73,7 @@ static OPUS_INLINE void xcorr_kernel_c(const opus_val16 * x, const opus_val16 * y_2=*y++; for (j=0;jnbEBands]; @@ -194,7 +194,7 @@ static int quant_coarse_energy_impl(const CELTMode *m, int start, int end, f = x - MULT16_32_Q15(coef,oldE) - prev[c]; /* Rounding to nearest integer here is really important! */ qi = (f+QCONST32(.5f,DB_SHIFT))>>DB_SHIFT; - decay_bound = MAXG(-GCONST(28.f), SUB32((opus_val32)oldEBands[i+c*m->nbEBands],max_decay)); + decay_bound = MAXG(-GCONST(28.f), SUB32((oac_val32)oldEBands[i+c*m->nbEBands],max_decay)); #else f = x-coef*oldE-prev[c]; /* Rounding to nearest integer here is really important! */ @@ -244,7 +244,7 @@ static int quant_coarse_energy_impl(const CELTMode *m, int start, int end, qi = -1; error[i+c*m->nbEBands] = f - SHL32(qi,DB_SHIFT); badness += abs(qi0-qi); - q = (opus_val32)SHL32(EXTEND32(qi),DB_SHIFT); + q = (oac_val32)SHL32(EXTEND32(qi),DB_SHIFT); tmp = MULT16_32_Q15(coef,oldE) + prev[c] + q; #ifdef FIXED_POINT @@ -258,23 +258,23 @@ static int quant_coarse_energy_impl(const CELTMode *m, int start, int end, } void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, - const celt_glog *eBands, celt_glog *oldEBands, opus_uint32 budget, + const celt_glog *eBands, celt_glog *oldEBands, oac_uint32 budget, celt_glog *error, ec_enc *enc, int C, int LM, int nbAvailableBytes, - int force_intra, opus_val32 *delayedIntra, int two_pass, int loss_rate, int lfe) + int force_intra, oac_val32 *delayedIntra, int two_pass, int loss_rate, int lfe) { int intra; celt_glog max_decay; VARDECL(celt_glog, oldEBands_intra); VARDECL(celt_glog, error_intra); ec_enc enc_start_state; - opus_uint32 tell; + oac_uint32 tell; int badness1=0; - opus_int32 intra_bias; - opus_val32 new_distortion; + oac_int32 intra_bias; + oac_val32 new_distortion; SAVE_STACK; intra = force_intra || (!two_pass && *delayedIntra>2*C*(end-start) && nbAvailableBytes > (end-start)*C); - intra_bias = (opus_int32)((budget**delayedIntra*loss_rate)/(C*512)); + intra_bias = (oac_int32)((budget**delayedIntra*loss_rate)/(C*512)); new_distortion = loss_distortion(eBands, oldEBands, start, effEnd, m->nbEBands, C); tell = ec_tell(enc); @@ -296,7 +296,7 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, ALLOC(oldEBands_intra, C*m->nbEBands, celt_glog); ALLOC(error_intra, C*m->nbEBands, celt_glog); - OPUS_COPY(oldEBands_intra, oldEBands, C*m->nbEBands); + OAC_COPY(oldEBands_intra, oldEBands, C*m->nbEBands); if (two_pass || intra) { @@ -308,10 +308,10 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, { unsigned char *intra_buf; ec_enc enc_intra_state; - opus_int32 tell_intra; - opus_uint32 nstart_bytes; - opus_uint32 nintra_bytes; - opus_uint32 save_bytes; + oac_int32 tell_intra; + oac_uint32 nstart_bytes; + oac_uint32 nintra_bytes; + oac_uint32 save_bytes; int badness2; VARDECL(unsigned char, intra_bits); @@ -327,25 +327,25 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, save_bytes = ALLOC_NONE; ALLOC(intra_bits, save_bytes, unsigned char); /* Copy bits from intra bit-stream */ - OPUS_COPY(intra_bits, intra_buf, nintra_bytes - nstart_bytes); + OAC_COPY(intra_bits, intra_buf, nintra_bytes - nstart_bytes); *enc = enc_start_state; badness2 = quant_coarse_energy_impl(m, start, end, eBands, oldEBands, budget, tell, e_prob_model[LM][intra], error, enc, C, LM, 0, max_decay, lfe); - if (two_pass && (badness1 < badness2 || (badness1 == badness2 && ((opus_int32)ec_tell_frac(enc))+intra_bias > tell_intra))) + if (two_pass && (badness1 < badness2 || (badness1 == badness2 && ((oac_int32)ec_tell_frac(enc))+intra_bias > tell_intra))) { *enc = enc_intra_state; /* Copy intra bits to bit-stream */ - OPUS_COPY(intra_buf, intra_bits, nintra_bytes - nstart_bytes); - OPUS_COPY(oldEBands, oldEBands_intra, C*m->nbEBands); - OPUS_COPY(error, error_intra, C*m->nbEBands); + OAC_COPY(intra_buf, intra_bits, nintra_bytes - nstart_bytes); + OAC_COPY(oldEBands, oldEBands_intra, C*m->nbEBands); + OAC_COPY(error, error_intra, C*m->nbEBands); intra = 1; } } else { - OPUS_COPY(oldEBands, oldEBands_intra, C*m->nbEBands); - OPUS_COPY(error, error_intra, C*m->nbEBands); + OAC_COPY(oldEBands, oldEBands_intra, C*m->nbEBands); + OAC_COPY(error, error_intra, C*m->nbEBands); } if (intra) @@ -363,11 +363,11 @@ void quant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEBan /* Encode finer resolution */ for (i=start;i (opus_int32)enc->storage*8) continue; + if (ec_tell(enc)+C*extra_quant[i] > (oac_int32)enc->storage*8) continue; prev = (prev_quant!=NULL) ? prev_quant[i] : 0; c=0; do { @@ -432,11 +432,11 @@ void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_glog *old { const unsigned char *prob_model = e_prob_model[LM][intra]; int i, c; - opus_val64 prev[2] = {0, 0}; - opus_val16 coef; - opus_val16 beta; - opus_int32 budget; - opus_int32 tell; + oac_val64 prev[2] = {0, 0}; + oac_val16 coef; + oac_val16 beta; + oac_int32 budget; + oac_int32 tell; if (intra) { @@ -455,8 +455,8 @@ void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_glog *old c=0; do { int qi; - opus_val32 q; - opus_val32 tmp; + oac_val32 q; + oac_val32 tmp; /* It would be better to express this invariant as a test on C at function entry, but that isn't enough to make the static analyzer happy. */ @@ -480,7 +480,7 @@ void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_glog *old } else qi = -1; - q = (opus_val32)SHL32(EXTEND32(qi),DB_SHIFT); + q = (oac_val32)SHL32(EXTEND32(qi),DB_SHIFT); oldEBands[i+c*m->nbEBands] = MAXG(-GCONST(9.f), oldEBands[i+c*m->nbEBands]); tmp = MULT16_32_Q15(coef,oldEBands[i+c*m->nbEBands]) + prev[c] + q; @@ -499,11 +499,11 @@ void unquant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEB /* Decode finer resolution */ for (i=start;i (opus_int32)dec->storage*8) continue; + if (ec_tell(dec)+C*extra_quant[i] > (oac_int32)dec->storage*8) continue; prev = (prev_quant!=NULL) ? prev_quant[i] : 0; c=0; do { diff --git a/celt/quant_bands.h b/celt/quant_bands.h index 6677fca2c..d61ca501c 100644 --- a/celt/quant_bands.h +++ b/celt/quant_bands.h @@ -38,7 +38,7 @@ #ifdef FIXED_POINT extern const signed char eMeans[25]; #else -extern const opus_val16 eMeans[25]; +extern const oac_val16 eMeans[25]; #endif void amp2Log2(const CELTMode *m, int effEnd, int end, @@ -48,9 +48,9 @@ void log2Amp(const CELTMode *m, int start, int end, celt_ener *eBands, const celt_glog *oldEBands, int C); void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, - const celt_glog *eBands, celt_glog *oldEBands, opus_uint32 budget, + const celt_glog *eBands, celt_glog *oldEBands, oac_uint32 budget, celt_glog *error, ec_enc *enc, int C, int LM, - int nbAvailableBytes, int force_intra, opus_val32 *delayedIntra, + int nbAvailableBytes, int force_intra, oac_val32 *delayedIntra, int two_pass, int loss_rate, int lfe); void quant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, celt_glog *error, int *fine_quant, int *extra_quant, ec_enc *enc, int C); diff --git a/celt/rate.c b/celt/rate.c index 139006d19..269483921 100644 --- a/celt/rate.c +++ b/celt/rate.c @@ -53,10 +53,10 @@ static const unsigned char LOG2_FRAC_TABLE[24]={ N and K are themselves limited to 15 bits.*/ static int fits_in32(int _n, int _k) { - static const opus_int16 maxN[15] = { + static const oac_int16 maxN[15] = { 32767, 32767, 32767, 1476, 283, 109, 60, 40, 29, 24, 20, 18, 16, 14, 13}; - static const opus_int16 maxK[15] = { + static const oac_int16 maxK[15] = { 32767, 32767, 32767, 32767, 1172, 238, 95, 53, 36, 27, 22, 18, 16, 15, 13}; if (_n>=14) @@ -78,13 +78,13 @@ void compute_pulse_cache(CELTMode *m, int LM) int curr=0; int nbEntries=0; int entryN[100], entryK[100], entryI[100]; - const opus_int16 *eBands = m->eBands; + const oac_int16 *eBands = m->eBands; PulseCache *cache = &m->cache; - opus_int16 *cindex; + oac_int16 *cindex; unsigned char *bits; unsigned char *cap; - cindex = (opus_int16 *)opus_alloc(sizeof(cache->index[0])*m->nbEBands*(LM+2)); + cindex = (oac_int16 *)oac_alloc(sizeof(cache->index[0])*m->nbEBands*(LM+2)); cache->index = cindex; /* Scan for all unique band sizes */ @@ -124,14 +124,14 @@ void compute_pulse_cache(CELTMode *m, int LM) } } } - bits = (unsigned char *)opus_alloc(sizeof(unsigned char)*curr); + bits = (unsigned char *)oac_alloc(sizeof(unsigned char)*curr); cache->bits = bits; cache->size = curr; /* Compute the cache for all unique sizes */ for (i=0;icaps = cap = (unsigned char *)opus_alloc(sizeof(cache->caps[0])*(LM+1)*2*m->nbEBands); + cache->caps = cap = (unsigned char *)oac_alloc(sizeof(cache->caps[0])*(LM+1)*2*m->nbEBands); for (i=0;i<=LM;i++) { for (C=1;C<=2;C++) @@ -156,8 +156,8 @@ void compute_pulse_cache(CELTMode *m, int LM) else { const unsigned char *pcache; - opus_int32 num; - opus_int32 den; + oac_int32 num; + oac_int32 den; int LM0; int N; int offset; @@ -189,13 +189,13 @@ void compute_pulse_cache(CELTMode *m, int LM) /* Offset the number of qtheta bits by log2(N)/2 + QTHETA_OFFSET compared to their "fair share" of total/N */ - offset = ((m->logN[j]+(opus_int32)((opus_uint32)(LM0+k)<>1)-QTHETA_OFFSET; + offset = ((m->logN[j]+(oac_int32)((oac_uint32)(LM0+k)<>1)-QTHETA_OFFSET; /* The number of qtheta bits we'll allocate if the remainder is to be max_bits. The average measured cost for theta is 0.89701 times qb, approximated here as 459/512. */ - num=459*(opus_int32)((2*N-1)*offset+max_bits); - den=((opus_int32)(2*N-1)<<9)-459; + num=459*(oac_int32)((2*N-1)*offset+max_bits); + den=((oac_int32)(2*N-1)<<9)-459; qb = IMIN((num+(den>>1))/den, 57); celt_assert(qb >= 0); max_bits += qb; @@ -209,8 +209,8 @@ void compute_pulse_cache(CELTMode *m, int LM) ndof = 2*N-1-(N==2); /* The average measured cost for theta with the step PDF is 0.95164 times qb, approximated here as 487/512. */ - num = (N==2?512:487)*(opus_int32)(max_bits+ndof*offset); - den = ((opus_int32)ndof<<9)-(N==2?512:487); + num = (N==2?512:487)*(oac_int32)(max_bits+ndof*offset); + den = ((oac_int32)ndof<<9)-(N==2?512:487); qb = IMIN((num+(den>>1))/den, (N==2?64:61)); celt_assert(qb >= 0); max_bits += qb; @@ -245,21 +245,21 @@ void compute_pulse_cache(CELTMode *m, int LM) #define ALLOC_STEPS 6 -static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, int skip_start, - const int *bits1, const int *bits2, const int *thresh, const int *cap, opus_int32 total, opus_int32 *_balance, +static OAC_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, int skip_start, + const int *bits1, const int *bits2, const int *thresh, const int *cap, oac_int32 total, oac_int32 *_balance, int skip_rsv, int *intensity, int intensity_rsv, int *dual_stereo, int dual_stereo_rsv, int *bits, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth) { - opus_int32 psum; + oac_int32 psum; int lo, hi; int i, j; int logM; int stereo; int codedBands=-1; int alloc_floor; - opus_int32 left, percoeff; + oac_int32 left, percoeff; int done; - opus_int32 balance; + oac_int32 balance; SAVE_STACK; alloc_floor = C<start;) { - int tmp = bits1[j] + (mid*(opus_int32)bits2[j]>>ALLOC_STEPS); + int tmp = bits1[j] + (mid*(oac_int32)bits2[j]>>ALLOC_STEPS); if (tmp >= thresh[j] || done) { done = 1; @@ -296,7 +296,7 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, done = 0; for (j=end;j-->start;) { - int tmp = bits1[j] + ((opus_int32)lo*bits2[j]>>ALLOC_STEPS); + int tmp = bits1[j] + ((oac_int32)lo*bits2[j]>>ALLOC_STEPS); if (tmp < thresh[j] && !done) { if (tmp >= alloc_floor) @@ -439,12 +439,12 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, int N0, N, den; int offset; int NClogN; - opus_int32 excess, bit; + oac_int32 excess, bit; celt_assert(bits[j] >= 0); N0 = m->eBands[j+1]-m->eBands[j]; N=N0<1) { @@ -532,7 +532,7 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, } int clt_compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stereo, - opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth) + oac_int32 total, oac_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth) { int lo, hi, len, j; int codedBands; diff --git a/celt/rate.h b/celt/rate.h index fad5e412d..cac780a75 100644 --- a/celt/rate.h +++ b/celt/rate.h @@ -45,12 +45,12 @@ void compute_pulse_cache(CELTMode *m, int LM); -static OPUS_INLINE int get_pulses(int i) +static OAC_INLINE int get_pulses(int i) { return i<8 ? i : (8 + (i&7)) << ((i>>3)-1); } -static OPUS_INLINE int bits2pulses(const CELTMode *m, int band, int LM, int bits) +static OAC_INLINE int bits2pulses(const CELTMode *m, int band, int LM, int bits) { int i; int lo, hi; @@ -77,7 +77,7 @@ static OPUS_INLINE int bits2pulses(const CELTMode *m, int band, int LM, int bits return hi; } -static OPUS_INLINE int pulses2bits(const CELTMode *m, int band, int LM, int pulses) +static OAC_INLINE int pulses2bits(const CELTMode *m, int band, int LM, int pulses) { const unsigned char *cache; @@ -96,6 +96,6 @@ static OPUS_INLINE int pulses2bits(const CELTMode *m, int band, int LM, int puls @return Total number of bits allocated */ int clt_compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stereo, - opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth); + oac_int32 total, oac_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth); #endif diff --git a/celt/stack_alloc.h b/celt/stack_alloc.h index 04b14ff26..82443d41e 100644 --- a/celt/stack_alloc.h +++ b/celt/stack_alloc.h @@ -32,11 +32,11 @@ #ifndef STACK_ALLOC_H #define STACK_ALLOC_H -#include "opus_types.h" -#include "opus_defines.h" +#include "oac_types.h" +#include "oac_defines.h" #if (!defined (VAR_ARRAYS) && !defined (USE_ALLOCA) && !defined (NONTHREADSAFE_PSEUDOSTACK)) -#error "Opus requires one of VAR_ARRAYS, USE_ALLOCA, or NONTHREADSAFE_PSEUDOSTACK be defined to select the temporary allocation mode." +#error "Oac requires one of VAR_ARRAYS, USE_ALLOCA, or NONTHREADSAFE_PSEUDOSTACK be defined to select the temporary allocation mode." #endif #ifdef USE_ALLOCA @@ -155,7 +155,7 @@ extern char *global_stack_top; #define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) #define PUSH(stack, size, type) (VALGRIND_MAKE_MEM_NOACCESS(stack, global_stack_top-stack),ALIGN((stack),ALIGNOF(type)),VALGRIND_MAKE_MEM_UNDEFINED(stack, ((size)*sizeof(type)/sizeof(char))),(stack)+=(2*(size)*sizeof(type)/sizeof(char)),(type*)((stack)-(2*(size)*sizeof(type)/sizeof(char)))) #define RESTORE_STACK ((global_stack = _saved_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack)) -#define ALLOC_STACK char *_saved_stack; ((global_stack = (global_stack==0) ? ((global_stack_top=(char*)opus_alloc_scratch(GLOBAL_STACK_SIZE*2)+(GLOBAL_STACK_SIZE*2))-(GLOBAL_STACK_SIZE*2)) : global_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack)); _saved_stack = global_stack; +#define ALLOC_STACK char *_saved_stack; ((global_stack = (global_stack==0) ? ((global_stack_top=(char*)oac_alloc_scratch(GLOBAL_STACK_SIZE*2)+(GLOBAL_STACK_SIZE*2))-(GLOBAL_STACK_SIZE*2)) : global_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack)); _saved_stack = global_stack; #else @@ -172,7 +172,7 @@ extern char *global_stack_top; #else #define RESTORE_STACK (global_stack = _saved_stack) #endif -#define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? (scratch_ptr=(char*)opus_alloc_scratch(GLOBAL_STACK_SIZE)) : global_stack); _saved_stack = global_stack; +#define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? (scratch_ptr=(char*)oac_alloc_scratch(GLOBAL_STACK_SIZE)) : global_stack); _saved_stack = global_stack; #endif /* ENABLE_VALGRIND */ @@ -188,20 +188,20 @@ extern char *global_stack_top; #ifdef ENABLE_VALGRIND #include -#define OPUS_CHECK_ARRAY(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*sizeof(*ptr)) -#define OPUS_CHECK_VALUE(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value) -#define OPUS_CHECK_ARRAY_COND(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*sizeof(*ptr)) -#define OPUS_CHECK_VALUE_COND(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value) -#define OPUS_PRINT_INT(value) do {fprintf(stderr, #value " = %d at %s:%d\n", value, __FILE__, __LINE__);}while(0) -#define OPUS_FPRINTF fprintf +#define OAC_CHECK_ARRAY(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*sizeof(*ptr)) +#define OAC_CHECK_VALUE(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value) +#define OAC_CHECK_ARRAY_COND(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*sizeof(*ptr)) +#define OAC_CHECK_VALUE_COND(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value) +#define OAC_PRINT_INT(value) do {fprintf(stderr, #value " = %d at %s:%d\n", value, __FILE__, __LINE__);}while(0) +#define OAC_FPRINTF fprintf #else -static OPUS_INLINE int _opus_false(void) {return 0;} -#define OPUS_CHECK_ARRAY(ptr, len) _opus_false() -#define OPUS_CHECK_VALUE(value) _opus_false() -#define OPUS_PRINT_INT(value) do{}while(0) -#define OPUS_FPRINTF (void) +static OAC_INLINE int _oac_false(void) {return 0;} +#define OAC_CHECK_ARRAY(ptr, len) _oac_false() +#define OAC_CHECK_VALUE(value) _oac_false() +#define OAC_PRINT_INT(value) do{}while(0) +#define OAC_FPRINTF (void) #endif diff --git a/celt/static_modes_fixed.h b/celt/static_modes_fixed.h index ea3b89b13..30144a3ba 100644 --- a/celt/static_modes_fixed.h +++ b/celt/static_modes_fixed.h @@ -41,13 +41,13 @@ static const celt_coef window120[120] = { #ifndef DEF_LOGN400 #define DEF_LOGN400 -static const opus_int16 logN400[21] = { +static const oac_int16 logN400[21] = { 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36, }; #endif #ifndef DEF_PULSE_CACHE50 #define DEF_PULSE_CACHE50 -static const opus_int16 cache_index50[105] = { +static const oac_int16 cache_index50[105] = { -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, 82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, @@ -345,7 +345,7 @@ static const kiss_twiddle_cpx fft_twiddles48000_960[480] = { }; #ifndef FFT_BITREV480 #define FFT_BITREV480 -static const opus_int16 fft_bitrev480[480] = { +static const oac_int16 fft_bitrev480[480] = { 0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, 8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, 16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, @@ -383,7 +383,7 @@ static const opus_int16 fft_bitrev480[480] = { #ifndef FFT_BITREV240 #define FFT_BITREV240 -static const opus_int16 fft_bitrev240[240] = { +static const oac_int16 fft_bitrev240[240] = { 0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, 4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, 8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, @@ -405,7 +405,7 @@ static const opus_int16 fft_bitrev240[240] = { #ifndef FFT_BITREV120 #define FFT_BITREV120 -static const opus_int16 fft_bitrev120[120] = { +static const oac_int16 fft_bitrev120[120] = { 0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, 4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, 1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, @@ -419,7 +419,7 @@ static const opus_int16 fft_bitrev120[120] = { #ifndef FFT_BITREV60 #define FFT_BITREV60 -static const opus_int16 fft_bitrev60[60] = { +static const oac_int16 fft_bitrev60[60] = { 0, 12, 24, 36, 48, 4, 16, 28, 40, 52, 8, 20, 32, 44, 56, 1, 13, 25, 37, 49, 5, 17, 29, 41, 53, 9, 21, 33, 45, 57, 2, 14, 26, 38, 50, 6, 18, 30, 42, 54, 10, 22, 34, 46, 58, @@ -942,13 +942,13 @@ static const celt_coef window240[240] = { #ifndef DEF_LOGN400 #define DEF_LOGN400 -static const opus_int16 logN400[21] = { +static const oac_int16 logN400[21] = { 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36, }; #endif #ifndef DEF_PULSE_CACHE50 #define DEF_PULSE_CACHE50 -static const opus_int16 cache_index50[105] = { +static const oac_int16 cache_index50[105] = { -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, 82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, @@ -1486,7 +1486,7 @@ static const kiss_twiddle_cpx fft_twiddles96000_1920[960] = { }; #ifndef FFT_BITREV960 #define FFT_BITREV960 -static const opus_int16 fft_bitrev960[960] = { +static const oac_int16 fft_bitrev960[960] = { 0, 192, 384, 576, 768, 64, 256, 448, 640, 832, 128, 320, 512, 704, 896, 16, 208, 400, 592, 784, 80, 272, 464, 656, 848, 144, 336, 528, 720, 912, 32, 224, 416, 608, 800, 96, 288, 480, 672, 864, 160, 352, 544, 736, 928, @@ -1556,7 +1556,7 @@ static const opus_int16 fft_bitrev960[960] = { #ifndef FFT_BITREV480 #define FFT_BITREV480 -static const opus_int16 fft_bitrev480[480] = { +static const oac_int16 fft_bitrev480[480] = { 0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, 8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, 16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, @@ -1594,7 +1594,7 @@ static const opus_int16 fft_bitrev480[480] = { #ifndef FFT_BITREV240 #define FFT_BITREV240 -static const opus_int16 fft_bitrev240[240] = { +static const oac_int16 fft_bitrev240[240] = { 0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, 4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, 8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, @@ -1616,7 +1616,7 @@ static const opus_int16 fft_bitrev240[240] = { #ifndef FFT_BITREV120 #define FFT_BITREV120 -static const opus_int16 fft_bitrev120[120] = { +static const oac_int16 fft_bitrev120[120] = { 0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, 4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, 1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, diff --git a/celt/static_modes_float.h b/celt/static_modes_float.h index 06cca3f5f..eb32cad99 100644 --- a/celt/static_modes_float.h +++ b/celt/static_modes_float.h @@ -41,13 +41,13 @@ static const celt_coef window120[120] = { #ifndef DEF_LOGN400 #define DEF_LOGN400 -static const opus_int16 logN400[21] = { +static const oac_int16 logN400[21] = { 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36, }; #endif #ifndef DEF_PULSE_CACHE50 #define DEF_PULSE_CACHE50 -static const opus_int16 cache_index50[105] = { +static const oac_int16 cache_index50[105] = { -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, 82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, @@ -345,7 +345,7 @@ static const kiss_twiddle_cpx fft_twiddles48000_960[480] = { }; #ifndef FFT_BITREV480 #define FFT_BITREV480 -static const opus_int16 fft_bitrev480[480] = { +static const oac_int16 fft_bitrev480[480] = { 0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, 8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, 16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, @@ -383,7 +383,7 @@ static const opus_int16 fft_bitrev480[480] = { #ifndef FFT_BITREV240 #define FFT_BITREV240 -static const opus_int16 fft_bitrev240[240] = { +static const oac_int16 fft_bitrev240[240] = { 0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, 4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, 8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, @@ -405,7 +405,7 @@ static const opus_int16 fft_bitrev240[240] = { #ifndef FFT_BITREV120 #define FFT_BITREV120 -static const opus_int16 fft_bitrev120[120] = { +static const oac_int16 fft_bitrev120[120] = { 0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, 4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, 1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, @@ -419,7 +419,7 @@ static const opus_int16 fft_bitrev120[120] = { #ifndef FFT_BITREV60 #define FFT_BITREV60 -static const opus_int16 fft_bitrev60[60] = { +static const oac_int16 fft_bitrev60[60] = { 0, 12, 24, 36, 48, 4, 16, 28, 40, 52, 8, 20, 32, 44, 56, 1, 13, 25, 37, 49, 5, 17, 29, 41, 53, 9, 21, 33, 45, 57, 2, 14, 26, 38, 50, 6, 18, 30, 42, 54, 10, 22, 34, 46, 58, @@ -938,13 +938,13 @@ static const celt_coef window240[240] = { #ifndef DEF_LOGN400 #define DEF_LOGN400 -static const opus_int16 logN400[21] = { +static const oac_int16 logN400[21] = { 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36, }; #endif #ifndef DEF_PULSE_CACHE50 #define DEF_PULSE_CACHE50 -static const opus_int16 cache_index50[105] = { +static const oac_int16 cache_index50[105] = { -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, 82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, @@ -1482,7 +1482,7 @@ static const kiss_twiddle_cpx fft_twiddles96000_1920[960] = { }; #ifndef FFT_BITREV960 #define FFT_BITREV960 -static const opus_int16 fft_bitrev960[960] = { +static const oac_int16 fft_bitrev960[960] = { 0, 192, 384, 576, 768, 64, 256, 448, 640, 832, 128, 320, 512, 704, 896, 16, 208, 400, 592, 784, 80, 272, 464, 656, 848, 144, 336, 528, 720, 912, 32, 224, 416, 608, 800, 96, 288, 480, 672, 864, 160, 352, 544, 736, 928, @@ -1552,7 +1552,7 @@ static const opus_int16 fft_bitrev960[960] = { #ifndef FFT_BITREV480 #define FFT_BITREV480 -static const opus_int16 fft_bitrev480[480] = { +static const oac_int16 fft_bitrev480[480] = { 0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, 8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, 16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, @@ -1590,7 +1590,7 @@ static const opus_int16 fft_bitrev480[480] = { #ifndef FFT_BITREV240 #define FFT_BITREV240 -static const opus_int16 fft_bitrev240[240] = { +static const oac_int16 fft_bitrev240[240] = { 0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, 4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, 8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, @@ -1612,7 +1612,7 @@ static const opus_int16 fft_bitrev240[240] = { #ifndef FFT_BITREV120 #define FFT_BITREV120 -static const opus_int16 fft_bitrev120[120] = { +static const oac_int16 fft_bitrev120[120] = { 0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, 4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, 1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, diff --git a/celt/tests/meson.build b/celt/tests/meson.build index 0e6d2e627..747a0d5d2 100644 --- a/celt/tests/meson.build +++ b/celt/tests/meson.build @@ -11,7 +11,7 @@ tests = [ foreach test_name : tests exe = executable(test_name, '@0@.c'.format(test_name), - include_directories : opus_includes, + include_directories : oac_includes, link_with : [celt_lib, celt_static_libs], dependencies : libm, install : false) diff --git a/celt/tests/test_unit_cwrs32.c b/celt/tests/test_unit_cwrs32.c index f6b8ac4b0..57a1eecce 100644 --- a/celt/tests/test_unit_cwrs32.c +++ b/celt/tests/test_unit_cwrs32.c @@ -96,11 +96,11 @@ int main(void){ { int k; #if defined(SMALL_FOOTPRINT) - opus_uint32 uu[KMAX+2U]; + oac_uint32 uu[KMAX+2U]; #endif - opus_uint32 inc; - opus_uint32 nc; - opus_uint32 i; + oac_uint32 inc; + oac_uint32 nc; + oac_uint32 i; k=get_pulses(pseudo); if (k>pkmax[t])break; printf("Testing CWRS with N=%i, K=%i...\n",n,k); @@ -113,12 +113,12 @@ int main(void){ if(inc<1)inc=1; for(i=0;i1) { int k; diff --git a/celt/tests/test_unit_laplace.c b/celt/tests/test_unit_laplace.c index 9832e5e5f..c46bf9fe0 100644 --- a/celt/tests/test_unit_laplace.c +++ b/celt/tests/test_unit_laplace.c @@ -44,7 +44,7 @@ int ec_laplace_get_start_freq(int decay) { - opus_uint32 ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN+1); + oac_uint32 ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN+1); int fs = (ft*(16384-decay))/(16384+decay); return fs+LAPLACE_MINP; } diff --git a/celt/tests/test_unit_mathops.c b/celt/tests/test_unit_mathops.c index 517ef5bca..49ef771d6 100644 --- a/celt/tests/test_unit_mathops.c +++ b/celt/tests/test_unit_mathops.c @@ -55,11 +55,11 @@ int ret = 0; void testdiv(void) { - opus_int32 i; + oac_int32 i; for (i=1;i<=327670;i++) { double prod; - opus_val32 val; + oac_val32 val; val = celt_rcp(i); #ifdef FIXED_POINT prod = (1./32768./65526.)*val*i; @@ -76,11 +76,11 @@ void testdiv(void) void testsqrt(void) { - opus_int32 i; + oac_int32 i; for (i=1;i<=1000000000;i++) { double ratio; - opus_val16 val; + oac_val16 val; val = celt_sqrt(i); ratio = val/sqrt(i); if (fabs(ratio - 1) > .0005 && fabs(val-sqrt(i)) > 2) @@ -95,13 +95,13 @@ void testsqrt(void) void testbitexactcos(void) { int i; - opus_int32 min_d,max_d,last,chk; + oac_int32 min_d,max_d,last,chk; chk=max_d=0; last=min_d=32767; for(i=64;i<=16320;i++) { - opus_int32 d; - opus_int32 q=bitexact_cos(i); + oac_int32 d; + oac_int32 q=bitexact_cos(i); chk ^= q*i; d = last - q; if (d>max_d)max_d=d; @@ -119,15 +119,15 @@ void testbitexactcos(void) void testbitexactlog2tan(void) { int i,fail; - opus_int32 min_d,max_d,last,chk; + oac_int32 min_d,max_d,last,chk; fail=chk=max_d=0; last=min_d=15059; for(i=64;i<8193;i++) { - opus_int32 d; - opus_int32 mid=bitexact_cos(i); - opus_int32 side=bitexact_cos(16384-i); - opus_int32 q=bitexact_log2tan(mid,side); + oac_int32 d; + oac_int32 mid=bitexact_cos(i); + oac_int32 side=bitexact_cos(16384-i); + oac_int32 q=bitexact_log2tan(mid,side); chk ^= q*i; d = last - q; if (q!=-1*bitexact_log2tan(side,mid)) @@ -287,7 +287,7 @@ void testlog2_db(void) float error = -1; float max_error = -2; float error_threshold = 2.e-07; - opus_int32 x = 0; + oac_int32 x = 0; int q_input = 14; for (x = 8; x < 1073741824; x += (x >> 3)) { @@ -309,7 +309,7 @@ void testlog2_db(void) void testlog2(void) { - opus_val32 x; + oac_val32 x; for (x=8;x<1073741824;x+=(x>>3)) { float error = fabs((1.442695040888963387*log(x/16384.0))-celt_log2(x)/1024.0); @@ -323,7 +323,7 @@ void testlog2(void) void testexp2(void) { - opus_val16 x; + oac_val16 x; for (x=-32768;x<15360;x++) { float error1 = fabs(x/1024.0-(1.442695040888963387*log(celt_exp2(x)/65536.0))); @@ -343,7 +343,7 @@ void testexp2_db(void) float relative_error_threshold = -2; float fx; float quantized_fx; - opus_val32 x_32; + oac_val32 x_32; for (fx = -32.0; fx < 15.0; fx += 0.0007) { @@ -372,7 +372,7 @@ void testexp2_db(void) void testexp2log2(void) { - opus_val32 x; + oac_val32 x; for (x=8;x<65536;x+=(x>>3)) { float error = fabs(x-0.25*celt_exp2(celt_log2(x)))/16384; @@ -386,11 +386,11 @@ void testexp2log2(void) void testilog2(void) { - opus_val32 x; + oac_val32 x; for (x=1;x<=268435455;x+=127) { - opus_val32 lg; - opus_val32 y; + oac_val32 lg; + oac_val32 y; lg = celt_ilog2(x); if (lg<0 || lg>=31) @@ -415,7 +415,7 @@ void testrsqrt(void) float max_error = 0; float fx = 0; float quantized_fx; - opus_int32 x; + oac_int32 x; for (fx = 0.25; fx < 1.0f; fx += 0.007f) { x = DOUBLE_TO_FIX_INT(fx, 31); @@ -441,7 +441,7 @@ void testrsqrt(void) void testsqrt32(void) { - opus_int32 i; + oac_int32 i; float absolute_error; float two_LSBs = FIX_INT_TO_DOUBLE(2, 16); float relative_error_threshold; @@ -470,7 +470,7 @@ void testatan_norm(void) float max_error = -2; float error_threshold = 5.97e-08; float fx = 0; - opus_int32 x = 0; + oac_int32 x = 0; int q_input = 30; int q_output = 30; #define ATAN2_2_OVER_PI 0.636619772367581f @@ -501,8 +501,8 @@ void testatan2p_norm(void) float error_threshold = 1.2e-07; float fx = 0; float fy = 0; - opus_int32 x = 0; - opus_int32 y = 0; + oac_int32 x = 0; + oac_int32 y = 0; int q_input = 30; int q_output = 30; #define ATAN2_2_OVER_PI 0.636619772367581f @@ -546,7 +546,7 @@ void test_cos_norm32(void) float max_error = -2; float error_threshold = 1e-07; float fx = 0; - opus_int32 x = 0; + oac_int32 x = 0; int q_input = 30; int q_output = 31; for (fx = -1.0f; fx <= 1.0f; fx += 0.007f) @@ -584,7 +584,7 @@ void test_rcp_norm32(void) float max_relative_error = -1; float fx; float quantized_fx; - opus_val32 x; + oac_val32 x; int q_input = 31; for (fx = 0.5; fx <= 1.0; fx += 0.0000007) @@ -668,7 +668,7 @@ void testcelt_float2int16(int use_ref_impl, int buffer_size) { celt_float2int16_c(floatsToConvert, results, cnt); } else { - celt_float2int16(floatsToConvert, results, cnt, opus_select_arch()); + celt_float2int16(floatsToConvert, results, cnt, oac_select_arch()); } for (i = 0; i < cnt; ++i) @@ -694,12 +694,12 @@ void testcelt_float2int16(int use_ref_impl, int buffer_size) #undef MAX_BUFFER_SIZE } -void testopus_limit2_checkwithin1(int use_ref_impl) +void testoac_limit2_checkwithin1(int use_ref_impl) { #define BUFFER_SIZE 37 /* strange float count to trigger residue loop of SIMD implementation */ #define BYTE_COUNT (BUFFER_SIZE * sizeof(float)) int i, within1; - const int arch = opus_select_arch(); + const int arch = oac_select_arch(); float pattern[BUFFER_SIZE], buffer[BUFFER_SIZE]; @@ -711,10 +711,10 @@ void testopus_limit2_checkwithin1(int use_ref_impl) /* All values within -1..1: Nothing changed. Return value is implementation-dependent (not expected to recognise nothing exceeds -1..1) */ memcpy(buffer, pattern, BYTE_COUNT); - within1 = use_ref_impl ? opus_limit2_checkwithin1_c(buffer, BUFFER_SIZE) : opus_limit2_checkwithin1(buffer, BUFFER_SIZE, arch); + within1 = use_ref_impl ? oac_limit2_checkwithin1_c(buffer, BUFFER_SIZE) : oac_limit2_checkwithin1(buffer, BUFFER_SIZE, arch); if (memcmp(buffer, pattern, BYTE_COUNT) != 0) { - fprintf (stderr, "opus_limit2_checkwithin1() modified values not exceeding -1..1 (ref=%d)\n", use_ref_impl); + fprintf (stderr, "oac_limit2_checkwithin1() modified values not exceeding -1..1 (ref=%d)\n", use_ref_impl); ret = 1; } @@ -726,16 +726,16 @@ void testopus_limit2_checkwithin1(int use_ref_impl) memcpy(buffer, pattern, BYTE_COUNT); buffer[i] = replace_value; - within1 = use_ref_impl ? opus_limit2_checkwithin1_c(buffer, BUFFER_SIZE) : opus_limit2_checkwithin1(buffer, BUFFER_SIZE, arch); + within1 = use_ref_impl ? oac_limit2_checkwithin1_c(buffer, BUFFER_SIZE) : oac_limit2_checkwithin1(buffer, BUFFER_SIZE, arch); if (within1 || buffer[i] != replace_value) { - fprintf (stderr, "opus_limit2_checkwithin1() handled value exceeding -1..1 erroneously (ref=%d, i=%d)\n", use_ref_impl, i); + fprintf (stderr, "oac_limit2_checkwithin1() handled value exceeding -1..1 erroneously (ref=%d, i=%d)\n", use_ref_impl, i); ret = 1; } buffer[i] = pattern[i]; if (memcmp(buffer, pattern, BYTE_COUNT) != 0) { - fprintf (stderr, "opus_limit2_checkwithin1() modified value within -2..2 (ref=%d, i=%d)\n", use_ref_impl, i); + fprintf (stderr, "oac_limit2_checkwithin1() modified value within -2..2 (ref=%d, i=%d)\n", use_ref_impl, i); ret = 1; } } @@ -748,16 +748,16 @@ void testopus_limit2_checkwithin1(int use_ref_impl) memcpy(buffer, pattern, BYTE_COUNT); buffer[i] = replace_value; - within1 = use_ref_impl ? opus_limit2_checkwithin1_c(buffer, BUFFER_SIZE) : opus_limit2_checkwithin1(buffer, BUFFER_SIZE, arch); + within1 = use_ref_impl ? oac_limit2_checkwithin1_c(buffer, BUFFER_SIZE) : oac_limit2_checkwithin1(buffer, BUFFER_SIZE, arch); if (within1 || buffer[i] != (replace_value > 0.f ? 2.f : -2.f)) { - fprintf (stderr, "opus_limit2_checkwithin1() handled value exceeding -2..2 erroneously (ref=%d, i=%d)\n", use_ref_impl, i); + fprintf (stderr, "oac_limit2_checkwithin1() handled value exceeding -2..2 erroneously (ref=%d, i=%d)\n", use_ref_impl, i); ret = 1; } buffer[i] = pattern[i]; if (memcmp(buffer, pattern, BYTE_COUNT) != 0) { - fprintf (stderr, "opus_limit2_checkwithin1() modified value within -2..2 (ref=%d, i=%d)\n", use_ref_impl, i); + fprintf (stderr, "oac_limit2_checkwithin1() modified value within -2..2 (ref=%d, i=%d)\n", use_ref_impl, i); ret = 1; } } @@ -798,7 +798,7 @@ int main(void) testcelt_float2int16(use_ref_impl[i], 32); testcelt_float2int16(use_ref_impl[i], 127); testcelt_float2int16(use_ref_impl[i], 1031); - testopus_limit2_checkwithin1(use_ref_impl[i]); + testoac_limit2_checkwithin1(use_ref_impl[i]); } #else (void)i; diff --git a/celt/tests/test_unit_mdct.c b/celt/tests/test_unit_mdct.c index d075d4452..0928510f4 100644 --- a/celt/tests/test_unit_mdct.c +++ b/celt/tests/test_unit_mdct.c @@ -121,7 +121,7 @@ void test1d(int nfft,int isinverse,int arch) #else int shift; const mdct_lookup *cfg; - CELTMode *mode = opus_custom_mode_create(48000, 960, NULL); + CELTMode *mode = oac_custom_mode_create(48000, 960, NULL); if (nfft == 1920) shift = 0; else if (nfft == 960) shift = 1; else if (nfft == 480) shift = 2; @@ -186,7 +186,7 @@ int main(int argc,char ** argv) { int arch; ALLOC_STACK; - arch = opus_select_arch(); + arch = oac_select_arch(); if (argc>1) { int k; diff --git a/celt/tests/test_unit_types.c b/celt/tests/test_unit_types.c index 67a0fb8ed..8660be47a 100644 --- a/celt/tests/test_unit_types.c +++ b/celt/tests/test_unit_types.c @@ -29,19 +29,19 @@ #include "config.h" #endif -#include "opus_types.h" +#include "oac_types.h" #include int main(void) { - opus_int16 i = 1; + oac_int16 i = 1; i <<= 14; if (i>>14 != 1) { - fprintf(stderr, "opus_int16 isn't 16 bits\n"); + fprintf(stderr, "oac_int16 isn't 16 bits\n"); return 1; } - if (sizeof(opus_int16)*2 != sizeof(opus_int32)) + if (sizeof(oac_int16)*2 != sizeof(oac_int32)) { fprintf(stderr, "16*2 != 32\n"); return 1; diff --git a/celt/vq.c b/celt/vq.c index 75051b560..c3c18b409 100644 --- a/celt/vq.c +++ b/celt/vq.c @@ -54,27 +54,27 @@ void norm_scaledown(celt_norm *X, int N, int shift) { for (i=0;i>2*(NORM_SHIFT-14); } #endif #ifndef OVERRIDE_vq_exp_rotation1 -static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_val16 s) +static void exp_rotation1(celt_norm *X, int len, int stride, oac_val16 c, oac_val16 s) { int i; - opus_val16 ms; + oac_val16 ms; celt_norm *Xptr; Xptr = X; ms = NEG16(s); @@ -104,8 +104,8 @@ void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread) { static const int SPREAD_FACTOR[3]={15,10,5}; int i; - opus_val16 c, s; - opus_val16 gain, theta; + oac_val16 c, s; + oac_val16 gain, theta; int stride2=0; int factor; @@ -113,7 +113,7 @@ void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread) return; factor = SPREAD_FACTOR[spread-1]; - gain = celt_div((opus_val32)MULT16_16(Q15_ONE,len),(opus_val32)(len+factor*K)); + gain = celt_div((oac_val32)MULT16_16(Q15_ONE,len),(oac_val32)(len+factor*K)); theta = HALF16(MULT16_16_Q15(gain,gain)); c = celt_cos_norm(EXTEND32(theta)); @@ -146,15 +146,15 @@ void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread) } /** Normalizes the decoded integer pvq codeword to unit norm. */ -static void normalise_residual(int * OPUS_RESTRICT iy, celt_norm * OPUS_RESTRICT X, - int N, opus_val32 Ryy, opus_val32 gain, int shift) +static void normalise_residual(int * OAC_RESTRICT iy, celt_norm * OAC_RESTRICT X, + int N, oac_val32 Ryy, oac_val32 gain, int shift) { int i; #ifdef FIXED_POINT int k; #endif - opus_val32 t; - opus_val32 g; + oac_val32 t; + oac_val32 g; #ifdef FIXED_POINT k = celt_ilog2(Ryy)>>1; @@ -201,15 +201,15 @@ static unsigned extract_collapse_mask(int *iy, int N, int B) return collapse_mask; } -opus_val16 op_pvq_search_c(celt_norm *X, int *iy, int K, int N, int arch) +oac_val16 op_pvq_search_c(celt_norm *X, int *iy, int K, int N, int arch) { VARDECL(celt_norm, y); VARDECL(int, signx); int i, j; int pulsesLeft; - opus_val32 sum; - opus_val32 xy; - opus_val16 yy; + oac_val32 sum; + oac_val32 xy; + oac_val16 yy; SAVE_STACK; (void)arch; @@ -239,7 +239,7 @@ opus_val16 op_pvq_search_c(celt_norm *X, int *iy, int K, int N, int arch) /* Do a pre-search by projecting on the pyramid */ if (K > (N>>1)) { - opus_val16 rcp; + oac_val16 rcp; j=0; do { sum += X[j]; } while (++j N+3) { - opus_val16 tmp = (opus_val16)pulsesLeft; + oac_val16 tmp = (oac_val16)pulsesLeft; yy = MAC16_16(yy, tmp, tmp); yy = MAC16_16(yy, tmp, y[0]); iy[0] += pulsesLeft; @@ -297,10 +297,10 @@ opus_val16 op_pvq_search_c(celt_norm *X, int *iy, int K, int N, int arch) for (i=0;i MULT16_16(Ryy, best_num))) + if (oac_unlikely(MULT16_16(best_den, Rxy) > MULT16_16(Ryy, best_num))) { best_den = Ryy; best_num = Rxy; @@ -376,10 +376,10 @@ opus_val16 op_pvq_search_c(celt_norm *X, int *iy, int K, int N, int arch) RESTORE_STACK; RESTORE_STACK; unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc, - opus_val32 gain, int resynth, int arch) + oac_val32 gain, int resynth, int arch) { VARDECL(int, iy); - opus_val32 yy; + oac_val32 yy; unsigned collapse_mask; SAVE_STACK; @@ -406,9 +406,9 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc, /** Decode pulse vector and combine the result with the pitch vector to produce the final normalised signal in the current band. */ unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, - ec_dec *dec, opus_val32 gain) + ec_dec *dec, oac_val32 gain) { - opus_val32 Ryy; + oac_val32 Ryy; unsigned collapse_mask; VARDECL(int, iy); int yy_shift=0; @@ -426,15 +426,15 @@ unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, } #ifndef OVERRIDE_renormalise_vector -void renormalise_vector(celt_norm *X, int N, opus_val32 gain, int arch) +void renormalise_vector(celt_norm *X, int N, oac_val32 gain, int arch) { int i; #ifdef FIXED_POINT int k; #endif - opus_val32 E; - opus_val16 g; - opus_val32 t; + oac_val32 E; + oac_val16 g; + oac_val32 t; celt_norm *xptr; norm_scaledown(X, N, NORM_SHIFT-14); E = EPSILON + celt_inner_prod_norm(X, X, N, arch); @@ -455,12 +455,12 @@ void renormalise_vector(celt_norm *X, int N, opus_val32 gain, int arch) } #endif /* OVERRIDE_renormalise_vector */ -opus_int32 stereo_itheta(const celt_norm *X, const celt_norm *Y, int stereo, int N, int arch) +oac_int32 stereo_itheta(const celt_norm *X, const celt_norm *Y, int stereo, int N, int arch) { int i; int itheta; - opus_val32 mid, side; - opus_val32 Emid, Eside; + oac_val32 mid, side; + oac_val32 Emid, Eside; Emid = Eside = 0; if (stereo) @@ -488,10 +488,10 @@ opus_int32 stereo_itheta(const celt_norm *X, const celt_norm *Y, int stereo, int return itheta; } -static void cubic_synthesis(celt_norm *X, int *iy, int N, int K, int face, int sign, opus_val32 gain) { +static void cubic_synthesis(celt_norm *X, int *iy, int N, int K, int face, int sign, oac_val32 gain) { int i; - opus_val32 sum=0; - opus_val32 mag; + oac_val32 sum=0; + oac_val32 mag; #ifdef FIXED_POINT int sum_shift; int shift = IMAX(celt_ilog2(K) + celt_ilog2(N)/2 - 13, 0); @@ -517,13 +517,13 @@ static void cubic_synthesis(celt_norm *X, int *iy, int N, int K, int face, int s #endif } -unsigned cubic_quant(celt_norm *X, int N, int res, int B, ec_enc *enc, opus_val32 gain, int resynth) { +unsigned cubic_quant(celt_norm *X, int N, int res, int B, ec_enc *enc, oac_val32 gain, int resynth) { int i; int face=0; int K; VARDECL(int, iy); celt_norm faceval=-1; - opus_val32 norm; + oac_val32 norm; int sign; SAVE_STACK; ALLOC(iy, N, int); @@ -531,7 +531,7 @@ unsigned cubic_quant(celt_norm *X, int N, int res, int B, ec_enc *enc, opus_val3 /* Using odd K on transients to avoid adding pre-echo. */ if (B!=1) K=IMAX(1, K-1); if (K==1) { - if (resynth) OPUS_CLEAR(X, N); + if (resynth) OAC_CLEAR(X, N); RESTORE_STACK; return 0; } @@ -554,7 +554,7 @@ unsigned cubic_quant(celt_norm *X, int N, int res, int B, ec_enc *enc, opus_val3 iy[i] = IMIN(K-1, (MULT32_32_Q31(SHL32(X[i]+faceval, face_shift-1), norm)) >> 15); } } else { - OPUS_CLEAR(iy, N); + OAC_CLEAR(iy, N); } #else norm = .5f*K/(faceval+EPSILON); @@ -572,7 +572,7 @@ unsigned cubic_quant(celt_norm *X, int N, int res, int B, ec_enc *enc, opus_val3 return (1<> 1; @@ -62,15 +62,15 @@ void celt_fir_sse4_1(const opus_val16 *x, for (i=0;i #include "arch.h" -void xcorr_kernel_sse(const opus_val16 *x, const opus_val16 *y, opus_val32 sum[4], int len) +void xcorr_kernel_sse(const oac_val16 *x, const oac_val16 *y, oac_val32 sum[4], int len) { int j; __m128 xsum1, xsum2; @@ -76,8 +76,8 @@ void xcorr_kernel_sse(const opus_val16 *x, const opus_val16 *y, opus_val32 sum[4 } -void dual_inner_prod_sse(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2) +void dual_inner_prod_sse(const oac_val16 *x, const oac_val16 *y01, const oac_val16 *y02, + int N, oac_val32 *xy1, oac_val32 *xy2) { int i; __m128 xsum1, xsum2; @@ -105,7 +105,7 @@ void dual_inner_prod_sse(const opus_val16 *x, const opus_val16 *y01, const opus_ } } -opus_val32 celt_inner_prod_sse(const opus_val16 *x, const opus_val16 *y, +oac_val32 celt_inner_prod_sse(const oac_val16 *x, const oac_val16 *y, int N) { int i; @@ -130,8 +130,8 @@ opus_val32 celt_inner_prod_sse(const opus_val16 *x, const opus_val16 *y, return xy; } -void comb_filter_const_sse(opus_val32 *y, opus_val32 *x, int T, int N, - opus_val16 g10, opus_val16 g11, opus_val16 g12) +void comb_filter_const_sse(oac_val32 *y, oac_val32 *x, int T, int N, + oac_val16 g10, oac_val16 g11, oac_val16 g12) { int i; __m128 x0v; @@ -143,7 +143,7 @@ void comb_filter_const_sse(opus_val32 *y, opus_val32 *x, int T, int N, for (i=0;i #include "x86cpu.h" -opus_val32 celt_inner_prod_sse4_1(const opus_val16 *x, const opus_val16 *y, +oac_val32 celt_inner_prod_sse4_1(const oac_val16 *x, const oac_val16 *y, int N) { - opus_int i, dataSize16; - opus_int32 sum; + oac_int i, dataSize16; + oac_int32 sum; __m128i inVec1_76543210, inVec1_FEDCBA98, acc1; __m128i inVec2_76543210, inVec2_FEDCBA98, acc2; __m128i inVec1_3210, inVec2_3210; @@ -108,7 +108,7 @@ opus_val32 celt_inner_prod_sse4_1(const opus_val16 *x, const opus_val16 *y, return sum; } -void xcorr_kernel_sse4_1(const opus_val16 * x, const opus_val16 * y, opus_val32 sum[ 4 ], int len) +void xcorr_kernel_sse4_1(const oac_val16 * x, const oac_val16 * y, oac_val32 sum[ 4 ], int len) { int j; @@ -117,8 +117,8 @@ void xcorr_kernel_sse4_1(const opus_val16 * x, const opus_val16 * y, opus_val32 __m128i sum0, sum1, sum2, sum3, vecSum; __m128i initSum; -#ifdef OPUS_CHECK_ASM - opus_val32 sum_c[4]; +#ifdef OAC_CHECK_ASM + oac_val32 sum_c[4]; for (j=0;j<4;j++) { sum_c[j] = sum[j]; } @@ -233,7 +233,7 @@ void xcorr_kernel_sse4_1(const opus_val16 * x, const opus_val16 * y, opus_val32 initSum = _mm_add_epi32(initSum, vecSum); _mm_storeu_si128((__m128i *)(void*)sum, initSum); -#ifdef OPUS_CHECK_ASM +#ifdef OAC_CHECK_ASM celt_assert(!memcmp(sum_c, sum, sizeof(sum_c))); #endif } diff --git a/celt/x86/vq_sse.h b/celt/x86/vq_sse.h index 444503b63..77ef472c4 100644 --- a/celt/x86/vq_sse.h +++ b/celt/x86/vq_sse.h @@ -27,24 +27,24 @@ #ifndef VQ_SSE_H #define VQ_SSE_H -#if defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(FIXED_POINT) +#if defined(OAC_X86_MAY_HAVE_SSE2) && !defined(FIXED_POINT) -opus_val16 op_pvq_search_sse2(celt_norm *_X, int *iy, int K, int N, int arch); +oac_val16 op_pvq_search_sse2(celt_norm *_X, int *iy, int K, int N, int arch); -#if defined(OPUS_X86_PRESUME_SSE2) +#if defined(OAC_X86_PRESUME_SSE2) #define OVERRIDE_OP_PVQ_SEARCH #define op_pvq_search(x, iy, K, N, arch) \ (op_pvq_search_sse2(x, iy, K, N, arch)) -#elif defined(OPUS_HAVE_RTCD) +#elif defined(OAC_HAVE_RTCD) #define OVERRIDE_OP_PVQ_SEARCH -extern opus_val16 (*const OP_PVQ_SEARCH_IMPL[OPUS_ARCHMASK + 1])( +extern oac_val16 (*const OP_PVQ_SEARCH_IMPL[OAC_ARCHMASK + 1])( celt_norm *_X, int *iy, int K, int N, int arch); # define op_pvq_search(X, iy, K, N, arch) \ - ((*OP_PVQ_SEARCH_IMPL[(arch) & OPUS_ARCHMASK])(X, iy, K, N, arch)) + ((*OP_PVQ_SEARCH_IMPL[(arch) & OAC_ARCHMASK])(X, iy, K, N, arch)) #endif #endif diff --git a/celt/x86/vq_sse2.c b/celt/x86/vq_sse2.c index 4c4ebf8e2..0209a9e3e 100644 --- a/celt/x86/vq_sse2.c +++ b/celt/x86/vq_sse2.c @@ -41,7 +41,7 @@ #ifndef FIXED_POINT -opus_val16 op_pvq_search_sse2(celt_norm *_X, int *iy, int K, int N, int arch) +oac_val16 op_pvq_search_sse2(celt_norm *_X, int *iy, int K, int N, int arch) { int i, j; int pulsesLeft; @@ -62,7 +62,7 @@ opus_val16 op_pvq_search_sse2(celt_norm *_X, int *iy, int K, int N, int arch) ALLOC(X, N+3, celt_norm); ALLOC(signy, N+3, float); - OPUS_COPY(X, _X, N); + OAC_COPY(X, _X, N); X[N] = X[N+1] = X[N+2] = 0; sums = _mm_setzero_ps(); for (j=0;j N+3) { - opus_val16 tmp = (opus_val16)pulsesLeft; + oac_val16 tmp = (oac_val16)pulsesLeft; yy = MAC16_16(yy, tmp, tmp); yy = MAC16_16(yy, tmp, y[0]); iy[0] += pulsesLeft; diff --git a/celt/x86/x86_arch_macros.h b/celt/x86/x86_arch_macros.h index 975b443e9..343d63e5e 100644 --- a/celt/x86/x86_arch_macros.h +++ b/celt/x86/x86_arch_macros.h @@ -26,19 +26,19 @@ #ifdef _MSC_VER -# ifdef OPUS_X86_MAY_HAVE_SSE +# ifdef OAC_X86_MAY_HAVE_SSE # ifndef __SSE__ # define __SSE__ # endif # endif -# ifdef OPUS_X86_MAY_HAVE_SSE2 +# ifdef OAC_X86_MAY_HAVE_SSE2 # ifndef __SSE2__ # define __SSE2__ # endif # endif -# ifdef OPUS_X86_MAY_HAVE_SSE4_1 +# ifdef OAC_X86_MAY_HAVE_SSE4_1 # ifndef __SSE4_1__ # define __SSE4_1__ # endif diff --git a/celt/x86/x86_celt_map.c b/celt/x86/x86_celt_map.c index ba8eafe6a..f1e8e7646 100644 --- a/celt/x86/x86_celt_map.c +++ b/celt/x86/x86_celt_map.c @@ -35,16 +35,16 @@ #include "pitch_sse.h" #include "vq.h" -#if defined(OPUS_HAVE_RTCD) +#if defined(OAC_HAVE_RTCD) # if defined(FIXED_POINT) -#if defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1) +#if defined(OAC_X86_MAY_HAVE_SSE4_1) && !defined(OAC_X86_PRESUME_SSE4_1) -void (*const CELT_FIR_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *num, - opus_val16 *y, +void (*const CELT_FIR_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *num, + oac_val16 *y, int N, int ord, int arch @@ -56,10 +56,10 @@ void (*const CELT_FIR_IMPL[OPUS_ARCHMASK + 1])( MAY_HAVE_SSE4_1(celt_fir) /* avx */ }; -void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y, - opus_val32 sum[4], +void (*const XCORR_KERNEL_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y, + oac_val32 sum[4], int len ) = { xcorr_kernel_c, /* non-sse */ @@ -71,12 +71,12 @@ void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( #endif -#if (defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \ - (!defined(OPUS_X86_MAY_HAVE_SSE_4_1) && defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) +#if (defined(OAC_X86_MAY_HAVE_SSE4_1) && !defined(OAC_X86_PRESUME_SSE4_1)) || \ + (!defined(OAC_X86_MAY_HAVE_SSE_4_1) && defined(OAC_X86_MAY_HAVE_SSE2) && !defined(OAC_X86_PRESUME_SSE2)) -opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y, +oac_val32 (*const CELT_INNER_PROD_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y, int N ) = { celt_inner_prod_c, /* non-sse */ @@ -90,9 +90,9 @@ opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( # else -#if defined(OPUS_X86_MAY_HAVE_AVX2) && !defined(OPUS_X86_PRESUME_AVX2) +#if defined(OAC_X86_MAY_HAVE_AVX2) && !defined(OAC_X86_PRESUME_AVX2) -void (*const PITCH_XCORR_IMPL[OPUS_ARCHMASK + 1])( +void (*const PITCH_XCORR_IMPL[OAC_ARCHMASK + 1])( const float *_x, const float *_y, float *xcorr, @@ -110,12 +110,12 @@ void (*const PITCH_XCORR_IMPL[OPUS_ARCHMASK + 1])( #endif -#if defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE) +#if defined(OAC_X86_MAY_HAVE_SSE) && !defined(OAC_X86_PRESUME_SSE) -void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y, - opus_val32 sum[4], +void (*const XCORR_KERNEL_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y, + oac_val32 sum[4], int len ) = { xcorr_kernel_c, /* non-sse */ @@ -125,9 +125,9 @@ void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( MAY_HAVE_SSE(xcorr_kernel) }; -opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y, +oac_val32 (*const CELT_INNER_PROD_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y, int N ) = { celt_inner_prod_c, /* non-sse */ @@ -137,13 +137,13 @@ opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( MAY_HAVE_SSE(celt_inner_prod) }; -void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y01, - const opus_val16 *y02, +void (*const DUAL_INNER_PROD_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y01, + const oac_val16 *y02, int N, - opus_val32 *xy1, - opus_val32 *xy2 + oac_val32 *xy1, + oac_val32 *xy2 ) = { dual_inner_prod_c, /* non-sse */ MAY_HAVE_SSE(dual_inner_prod), @@ -152,14 +152,14 @@ void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( MAY_HAVE_SSE(dual_inner_prod) }; -void (*const COMB_FILTER_CONST_IMPL[OPUS_ARCHMASK + 1])( - opus_val32 *y, - opus_val32 *x, +void (*const COMB_FILTER_CONST_IMPL[OAC_ARCHMASK + 1])( + oac_val32 *y, + oac_val32 *x, int T, int N, - opus_val16 g10, - opus_val16 g11, - opus_val16 g12 + oac_val16 g10, + oac_val16 g11, + oac_val16 g12 ) = { comb_filter_const_c, /* non-sse */ MAY_HAVE_SSE(comb_filter_const), @@ -171,8 +171,8 @@ void (*const COMB_FILTER_CONST_IMPL[OPUS_ARCHMASK + 1])( #endif -#if defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2) -opus_val16 (*const OP_PVQ_SEARCH_IMPL[OPUS_ARCHMASK + 1])( +#if defined(OAC_X86_MAY_HAVE_SSE2) && !defined(OAC_X86_PRESUME_SSE2) +oac_val16 (*const OP_PVQ_SEARCH_IMPL[OAC_ARCHMASK + 1])( celt_norm *_X, int *iy, int K, int N, int arch ) = { op_pvq_search_c, /* non-sse */ diff --git a/celt/x86/x86cpu.c b/celt/x86/x86cpu.c index 2e7c32aee..664ba6f27 100644 --- a/celt/x86/x86cpu.c +++ b/celt/x86/x86cpu.c @@ -35,11 +35,11 @@ #include "pitch.h" #include "x86cpu.h" -#if defined(OPUS_HAVE_RTCD) && \ - ((defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE)) || \ - (defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) || \ - (defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \ - (defined(OPUS_X86_MAY_HAVE_AVX2) && !defined(OPUS_X86_PRESUME_AVX2))) +#if defined(OAC_HAVE_RTCD) && \ + ((defined(OAC_X86_MAY_HAVE_SSE) && !defined(OAC_X86_PRESUME_SSE)) || \ + (defined(OAC_X86_MAY_HAVE_SSE2) && !defined(OAC_X86_PRESUME_SSE2)) || \ + (defined(OAC_X86_MAY_HAVE_SSE4_1) && !defined(OAC_X86_PRESUME_SSE4_1)) || \ + (defined(OAC_X86_MAY_HAVE_AVX2) && !defined(OAC_X86_PRESUME_AVX2))) #if defined(_MSC_VER) @@ -108,7 +108,7 @@ typedef struct CPU_Feature{ int HW_AVX2; } CPU_Feature; -static void opus_cpu_feature_check(CPU_Feature *cpu_feature) +static void oac_cpu_feature_check(CPU_Feature *cpu_feature) { unsigned int info[4]; unsigned int nIds = 0; @@ -137,12 +137,12 @@ static void opus_cpu_feature_check(CPU_Feature *cpu_feature) } } -static int opus_select_arch_impl(void) +static int oac_select_arch_impl(void) { CPU_Feature cpu_feature; int arch; - opus_cpu_feature_check(&cpu_feature); + oac_cpu_feature_check(&cpu_feature); arch = 0; if (!cpu_feature.HW_SSE) @@ -172,8 +172,8 @@ static int opus_select_arch_impl(void) return arch; } -int opus_select_arch(void) { - int arch = opus_select_arch_impl(); +int oac_select_arch(void) { + int arch = oac_select_arch_impl(); #ifdef FUZZING /* Randomly downgrade the architecture. */ arch = rand()%(arch+1); diff --git a/celt/x86/x86cpu.h b/celt/x86/x86cpu.h index 1e5b6a4cb..29c5115da 100644 --- a/celt/x86/x86cpu.h +++ b/celt/x86/x86cpu.h @@ -28,40 +28,40 @@ #if !defined(X86CPU_H) # define X86CPU_H -# if defined(OPUS_X86_MAY_HAVE_SSE) +# if defined(OAC_X86_MAY_HAVE_SSE) # define MAY_HAVE_SSE(name) name ## _sse # else # define MAY_HAVE_SSE(name) name ## _c # endif -# if defined(OPUS_X86_MAY_HAVE_SSE2) +# if defined(OAC_X86_MAY_HAVE_SSE2) # define MAY_HAVE_SSE2(name) name ## _sse2 # else # define MAY_HAVE_SSE2(name) name ## _c # endif -# if defined(OPUS_X86_MAY_HAVE_SSE4_1) +# if defined(OAC_X86_MAY_HAVE_SSE4_1) # define MAY_HAVE_SSE4_1(name) name ## _sse4_1 # else # define MAY_HAVE_SSE4_1(name) name ## _c # endif -# if defined(OPUS_X86_MAY_HAVE_AVX2) +# if defined(OAC_X86_MAY_HAVE_AVX2) # define MAY_HAVE_AVX2(name) name ## _avx2 # else # define MAY_HAVE_AVX2(name) name ## _c # endif -# if defined(OPUS_HAVE_RTCD) && \ - ((defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE)) || \ - (defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) || \ - (defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \ - (defined(OPUS_X86_MAY_HAVE_AVX2) && !defined(OPUS_X86_PRESUME_AVX2))) -int opus_select_arch(void); +# if defined(OAC_HAVE_RTCD) && \ + ((defined(OAC_X86_MAY_HAVE_SSE) && !defined(OAC_X86_PRESUME_SSE)) || \ + (defined(OAC_X86_MAY_HAVE_SSE2) && !defined(OAC_X86_PRESUME_SSE2)) || \ + (defined(OAC_X86_MAY_HAVE_SSE4_1) && !defined(OAC_X86_PRESUME_SSE4_1)) || \ + (defined(OAC_X86_MAY_HAVE_AVX2) && !defined(OAC_X86_PRESUME_AVX2))) +int oac_select_arch(void); # endif -# if defined(OPUS_X86_MAY_HAVE_SSE2) -# include "opus_defines.h" +# if defined(OAC_X86_MAY_HAVE_SSE2) +# include "oac_defines.h" /*MOVD should not impose any alignment restrictions, but the C standard does, and UBSan will report errors if we actually make unaligned accesses. @@ -80,10 +80,10 @@ int opus_select_arch(void); # if defined(__clang__) # if __has_warning("-Wextra-semi-stmt") || \ __has_builtin(__builtin_rotateleft32) -# define OPUS_CLANG_8 (1) +# define OAC_CLANG_8 (1) # endif # endif -# if !defined(_MSC_VER) && !OPUS_GNUC_PREREQ(11,3) && !defined(OPUS_CLANG_8) +# if !defined(_MSC_VER) && !OAC_GNUC_PREREQ(11,3) && !defined(OAC_CLANG_8) # include # include diff --git a/celt_headers.mk b/celt_headers.mk index 7a3047f90..0ee88ea4a 100644 --- a/celt_headers.mk +++ b/celt_headers.mk @@ -3,9 +3,9 @@ celt/arch.h \ celt/bands.h \ celt/celt.h \ celt/cpu_support.h \ -include/opus_types.h \ -include/opus_defines.h \ -include/opus_custom.h \ +include/oac_types.h \ +include/oac_defines.h \ +include/oac_custom.h \ celt/cwrs.h \ celt/ecintrin.h \ celt/entcode.h \ diff --git a/cmake/OpusBuildtype.cmake b/cmake/OacBuildtype.cmake similarity index 93% rename from cmake/OpusBuildtype.cmake rename to cmake/OacBuildtype.cmake index 557cc89b3..4846d84e6 100644 --- a/cmake/OpusBuildtype.cmake +++ b/cmake/OacBuildtype.cmake @@ -1,8 +1,8 @@ # Set a default build type if none was specified -if(__opus_buildtype) +if(__oac_buildtype) return() endif() -set(__opus_buildtype INCLUDED) +set(__oac_buildtype INCLUDED) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if(CMAKE_C_FLAGS) diff --git a/cmake/OpusConfig.cmake b/cmake/OacConfig.cmake similarity index 78% rename from cmake/OpusConfig.cmake rename to cmake/OacConfig.cmake index e9319fbad..8c559fe4b 100644 --- a/cmake/OpusConfig.cmake +++ b/cmake/OacConfig.cmake @@ -1,9 +1,9 @@ -if(__opus_config) +if(__oac_config) return() endif() -set(__opus_config INCLUDED) +set(__oac_config INCLUDED) -include(OpusFunctions) +include(OacFunctions) configure_file(cmake/config.h.cmake.in config.h @ONLY) add_definitions(-DHAVE_CONFIG_H) @@ -42,7 +42,7 @@ cmake_push_check_state(RESET) include(CheckLibraryExists) check_library_exists(m floor "" HAVE_LIBM) if(HAVE_LIBM) - list(APPEND OPUS_REQUIRED_LIBRARIES m) + list(APPEND OAC_REQUIRED_LIBRARIES m) set(CMAKE_REQUIRED_LIBRARIES m) endif() @@ -53,30 +53,30 @@ cmake_pop_check_state() if(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[0-9]86|x86|X86|amd64|AMD64|x86_64)") if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(OPUS_CPU_X64 1) + set(OAC_CPU_X64 1) else() - set(OPUS_CPU_X86 1) + set(OAC_CPU_X86 1) endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64|ARM)") - set(OPUS_CPU_ARM 1) + set(OAC_CPU_ARM 1) endif() -if(NOT OPUS_DISABLE_INTRINSICS) - opus_supports_cpu_detection(RUNTIME_CPU_CAPABILITY_DETECTION) +if(NOT OAC_DISABLE_INTRINSICS) + oac_supports_cpu_detection(RUNTIME_CPU_CAPABILITY_DETECTION) endif() -if(OPUS_CPU_X86 OR OPUS_CPU_X64 AND NOT OPUS_DISABLE_INTRINSICS) - opus_detect_sse(COMPILER_SUPPORT_SIMD) -elseif(OPUS_CPU_ARM AND NOT OPUS_DISABLE_INTRINSICS) - opus_detect_neon(COMPILER_SUPPORT_NEON) +if(OAC_CPU_X86 OR OAC_CPU_X64 AND NOT OAC_DISABLE_INTRINSICS) + oac_detect_sse(COMPILER_SUPPORT_SIMD) +elseif(OAC_CPU_ARM AND NOT OAC_DISABLE_INTRINSICS) + oac_detect_neon(COMPILER_SUPPORT_NEON) if(COMPILER_SUPPORT_NEON) - option(OPUS_USE_NEON "Option to enable NEON" ON) - option(OPUS_MAY_HAVE_NEON "Does runtime check for neon support" ON) - option(OPUS_PRESUME_NEON "Assume target CPU has NEON support" OFF) + option(OAC_USE_NEON "Option to enable NEON" ON) + option(OAC_MAY_HAVE_NEON "Does runtime check for neon support" ON) + option(OAC_PRESUME_NEON "Assume target CPU has NEON support" OFF) if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") - set(OPUS_PRESUME_NEON ON) + set(OAC_PRESUME_NEON ON) elseif(CMAKE_SYSTEM_NAME MATCHES "iOS") - set(OPUS_PRESUME_NEON ON) + set(OAC_PRESUME_NEON ON) endif() endif() endif() diff --git a/cmake/OacConfig.cmake.in b/cmake/OacConfig.cmake.in new file mode 100644 index 000000000..ae49eeb21 --- /dev/null +++ b/cmake/OacConfig.cmake.in @@ -0,0 +1,20 @@ +set(OAC_VERSION @PROJECT_VERSION@) +set(OAC_VERSION_STRING @PROJECT_VERSION@) +set(OAC_VERSION_MAJOR @PROJECT_VERSION_MAJOR@) +set(OAC_VERSION_MINOR @PROJECT_VERSION_MINOR@) +set(OAC_VERSION_PATCH @PROJECT_VERSION_PATCH@) + +@PACKAGE_INIT@ + +set_and_check(OAC_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") +set(OAC_INCLUDE_DIR ${OAC_INCLUDE_DIR};${OAC_INCLUDE_DIR}/oac) +set(OAC_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@;@PACKAGE_INCLUDE_INSTALL_DIR@/oac") + +include(${CMAKE_CURRENT_LIST_DIR}/OacTargets.cmake) + +set(OAC_LIBRARY Oac::oac) +set(OAC_LIBRARIES Oac::oac) + +check_required_components(Oac) + +set(OAC_FOUND 1) diff --git a/cmake/OpusFunctions.cmake b/cmake/OacFunctions.cmake similarity index 75% rename from cmake/OpusFunctions.cmake rename to cmake/OacFunctions.cmake index 2db77d7f8..4c4130f18 100644 --- a/cmake/OpusFunctions.cmake +++ b/cmake/OacFunctions.cmake @@ -1,44 +1,44 @@ -if(__opus_functions) +if(__oac_functions) return() endif() -set(__opus_functions INCLUDED) +set(__oac_functions INCLUDED) -function(get_library_version OPUS_LIBRARY_VERSION OPUS_LIBRARY_VERSION_MAJOR) - file(STRINGS configure.ac opus_lt_current_string +function(get_library_version OAC_LIBRARY_VERSION OAC_LIBRARY_VERSION_MAJOR) + file(STRINGS configure.ac oac_lt_current_string LIMIT_COUNT 1 - REGEX "OPUS_LT_CURRENT=") + REGEX "OAC_LT_CURRENT=") string(REGEX MATCH - "OPUS_LT_CURRENT=([0-9]*)" + "OAC_LT_CURRENT=([0-9]*)" _ - ${opus_lt_current_string}) - set(OPUS_LT_CURRENT ${CMAKE_MATCH_1}) + ${oac_lt_current_string}) + set(OAC_LT_CURRENT ${CMAKE_MATCH_1}) - file(STRINGS configure.ac opus_lt_revision_string + file(STRINGS configure.ac oac_lt_revision_string LIMIT_COUNT 1 - REGEX "OPUS_LT_REVISION=") + REGEX "OAC_LT_REVISION=") string(REGEX MATCH - "OPUS_LT_REVISION=([0-9]*)" + "OAC_LT_REVISION=([0-9]*)" _ - ${opus_lt_revision_string}) - set(OPUS_LT_REVISION ${CMAKE_MATCH_1}) + ${oac_lt_revision_string}) + set(OAC_LT_REVISION ${CMAKE_MATCH_1}) - file(STRINGS configure.ac opus_lt_age_string + file(STRINGS configure.ac oac_lt_age_string LIMIT_COUNT 1 - REGEX "OPUS_LT_AGE=") + REGEX "OAC_LT_AGE=") string(REGEX MATCH - "OPUS_LT_AGE=([0-9]*)" + "OAC_LT_AGE=([0-9]*)" _ - ${opus_lt_age_string}) - set(OPUS_LT_AGE ${CMAKE_MATCH_1}) + ${oac_lt_age_string}) + set(OAC_LT_AGE ${CMAKE_MATCH_1}) - math(EXPR OPUS_LIBRARY_VERSION_MAJOR "${OPUS_LT_CURRENT} - ${OPUS_LT_AGE}") - set(OPUS_LIBRARY_VERSION_MINOR ${OPUS_LT_AGE}) - set(OPUS_LIBRARY_VERSION_PATCH ${OPUS_LT_REVISION}) + math(EXPR OAC_LIBRARY_VERSION_MAJOR "${OAC_LT_CURRENT} - ${OAC_LT_AGE}") + set(OAC_LIBRARY_VERSION_MINOR ${OAC_LT_AGE}) + set(OAC_LIBRARY_VERSION_PATCH ${OAC_LT_REVISION}) set( - OPUS_LIBRARY_VERSION - "${OPUS_LIBRARY_VERSION_MAJOR}.${OPUS_LIBRARY_VERSION_MINOR}.${OPUS_LIBRARY_VERSION_PATCH}" + OAC_LIBRARY_VERSION + "${OAC_LIBRARY_VERSION_MAJOR}.${OAC_LIBRARY_VERSION_MINOR}.${OAC_LIBRARY_VERSION_PATCH}" PARENT_SCOPE) - set(OPUS_LIBRARY_VERSION_MAJOR ${OPUS_LIBRARY_VERSION_MAJOR} PARENT_SCOPE) + set(OAC_LIBRARY_VERSION_MAJOR ${OAC_LIBRARY_VERSION_MAJOR} PARENT_SCOPE) endfunction() function(check_flag NAME FLAG) @@ -50,10 +50,10 @@ include(CheckIncludeFile) # This function determines if the compiler has support for SSE, SSE2, SSE4.1, AVX, # AVX2 and FMA. Should the target systems potentially lack SSE support, the -# OPUS_MAY_HAVE_SSE option is recommended for use. If, however, the target system is -# assured to support SSE, the OPUS_PRESUME_SSE option can be employed, thus +# OAC_MAY_HAVE_SSE option is recommended for use. If, however, the target system is +# assured to support SSE, the OAC_PRESUME_SSE option can be employed, thus # eliminating the necessity for an SSE runtime check. -function(opus_detect_sse COMPILER_SUPPORT_SIMD) +function(oac_detect_sse COMPILER_SUPPORT_SIMD) message(STATUS "Check SIMD support by compiler") check_include_file(xmmintrin.h HAVE_XMMINTRIN_H) # SSE1 if(HAVE_XMMINTRIN_H) @@ -133,7 +133,7 @@ function(opus_detect_sse COMPILER_SUPPORT_SIMD) endif() endfunction() -function(opus_detect_neon COMPILER_SUPPORT_NEON) +function(oac_detect_neon COMPILER_SUPPORT_NEON) if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64|ARM)") message(STATUS "Check NEON support by compiler") check_include_file(arm_neon.h HAVE_ARM_NEON_H) @@ -143,9 +143,9 @@ function(opus_detect_neon COMPILER_SUPPORT_NEON) endif() endfunction() -function(opus_supports_cpu_detection RUNTIME_CPU_CAPABILITY_DETECTION) +function(oac_supports_cpu_detection RUNTIME_CPU_CAPABILITY_DETECTION) set(RUNTIME_CPU_CAPABILITY_DETECTION 0 PARENT_SCOPE) - if(OPUS_CPU_X86 OR OPUS_CPU_X64) + if(OAC_CPU_X86 OR OAC_CPU_X64) if(MSVC) check_include_file(intrin.h HAVE_INTRIN_H) if(HAVE_INTRIN_H) @@ -165,7 +165,7 @@ function(opus_supports_cpu_detection RUNTIME_CPU_CAPABILITY_DETECTION) set(RUNTIME_CPU_CAPABILITY_DETECTION 1 PARENT_SCOPE) endif() endif() - elseif(OPUS_CPU_ARM) + elseif(OAC_CPU_ARM) # ARM cpu detection is implemented for Windows, Linux, Android, FreeBSD # and OpenBSD. if (CMAKE_SYSTEM_NAME MATCHES "(Windows|Linux|Android|FreeBSD|OpenBSD)") @@ -181,15 +181,15 @@ function(add_sources_group target group) source_group(${group} FILES ${ARGN}) endfunction() -function(get_opus_sources SOURCE_GROUP MAKE_FILE SOURCES) +function(get_oac_sources SOURCE_GROUP MAKE_FILE SOURCES) # read file, each item in list is one group - file(STRINGS ${MAKE_FILE} opus_sources) + file(STRINGS ${MAKE_FILE} oac_sources) # add wildcard for regex match string(CONCAT SOURCE_GROUP ${SOURCE_GROUP} ".*$") # find group - foreach(val IN LISTS opus_sources) + foreach(val IN LISTS oac_sources) if(val MATCHES ${SOURCE_GROUP}) list(LENGTH val list_length) if(${list_length} EQUAL 1) diff --git a/cmake/OacPackageVersion.cmake b/cmake/OacPackageVersion.cmake new file mode 100644 index 000000000..70a79a6f7 --- /dev/null +++ b/cmake/OacPackageVersion.cmake @@ -0,0 +1,70 @@ +if(__oac_version) + return() +endif() +set(__oac_version INCLUDED) + +function(get_package_version PACKAGE_VERSION PROJECT_VERSION) + + find_package(Git) + if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git") + execute_process(COMMAND ${GIT_EXECUTABLE} + --git-dir=${CMAKE_CURRENT_LIST_DIR}/.git describe + --tags --match "v*" OUTPUT_VARIABLE OAC_PACKAGE_VERSION) + if(OAC_PACKAGE_VERSION) + string(STRIP ${OAC_PACKAGE_VERSION}, OAC_PACKAGE_VERSION) + string(REPLACE \n + "" + OAC_PACKAGE_VERSION + ${OAC_PACKAGE_VERSION}) + string(REPLACE , + "" + OAC_PACKAGE_VERSION + ${OAC_PACKAGE_VERSION}) + + string(SUBSTRING ${OAC_PACKAGE_VERSION} + 1 + -1 + OAC_PACKAGE_VERSION) + message(STATUS "Oac package version from git repo: ${OAC_PACKAGE_VERSION}") + endif() + + elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/package_version" + AND NOT OAC_PACKAGE_VERSION) + # Not a git repo, lets' try to parse it from package_version file if exists + file(STRINGS package_version OAC_PACKAGE_VERSION + LIMIT_COUNT 1 + REGEX "PACKAGE_VERSION=") + string(REPLACE "PACKAGE_VERSION=" + "" + OAC_PACKAGE_VERSION + ${OAC_PACKAGE_VERSION}) + string(REPLACE "\"" + "" + OAC_PACKAGE_VERSION + ${OAC_PACKAGE_VERSION}) + # In case we have a unknown dist here we just replace it with 0 + string(REPLACE "unknown" + "0" + OAC_PACKAGE_VERSION + ${OAC_PACKAGE_VERSION}) + message(STATUS "Oac package version from package_version file: ${OAC_PACKAGE_VERSION}") + endif() + + if(OAC_PACKAGE_VERSION) + string(REGEX + REPLACE "^([0-9]+.[0-9]+\\.?([0-9]+)?).*" + "\\1" + OAC_PROJECT_VERSION + ${OAC_PACKAGE_VERSION}) + else() + # fail to parse version from git and package version + message(WARNING "Could not get package version.") + set(OAC_PACKAGE_VERSION 0) + set(OAC_PROJECT_VERSION 0) + endif() + + message(STATUS "Oac project version: ${OAC_PROJECT_VERSION}") + + set(PACKAGE_VERSION ${OAC_PACKAGE_VERSION} PARENT_SCOPE) + set(PROJECT_VERSION ${OAC_PROJECT_VERSION} PARENT_SCOPE) +endfunction() diff --git a/cmake/OacSources.cmake b/cmake/OacSources.cmake new file mode 100644 index 000000000..25b2bafa2 --- /dev/null +++ b/cmake/OacSources.cmake @@ -0,0 +1,72 @@ +if(__oac_sources) + return() +endif() +set(__oac_sources INCLUDED) + +include(OacFunctions) + +get_oac_sources(SILK_HEAD silk_headers.mk silk_headers) +get_oac_sources(SILK_SOURCES silk_sources.mk silk_sources) +get_oac_sources(SILK_SOURCES_FLOAT silk_sources.mk silk_sources_float) +get_oac_sources(SILK_SOURCES_FIXED silk_sources.mk silk_sources_fixed) +get_oac_sources(SILK_SOURCES_X86_RTCD silk_sources.mk silk_sources_x86_rtcd) +get_oac_sources(SILK_SOURCES_SSE4_1 silk_sources.mk silk_sources_sse4_1) +get_oac_sources(SILK_SOURCES_FIXED_SSE4_1 silk_sources.mk + silk_sources_fixed_sse4_1) +get_oac_sources(SILK_SOURCES_AVX2 silk_sources.mk silk_sources_avx2) +get_oac_sources(SILK_SOURCES_FLOAT_AVX2 silk_sources.mk silk_sources_float_avx2) +get_oac_sources(SILK_SOURCES_ARM_RTCD silk_sources.mk silk_sources_arm_rtcd) +get_oac_sources(SILK_SOURCES_ARM_NEON_INTR silk_sources.mk + silk_sources_arm_neon_intr) +get_oac_sources(SILK_SOURCES_FIXED_ARM_NEON_INTR silk_sources.mk + silk_sources_fixed_arm_neon_intr) + +get_oac_sources(OAC_HEAD oac_headers.mk oac_headers) +get_oac_sources(OAC_SOURCES oac_sources.mk oac_sources) +get_oac_sources(OAC_SOURCES_FLOAT oac_sources.mk oac_sources_float) + +get_oac_sources(CELT_HEAD celt_headers.mk celt_headers) +get_oac_sources(CELT_SOURCES celt_sources.mk celt_sources) +get_oac_sources(CELT_SOURCES_X86_RTCD celt_sources.mk celt_sources_x86_rtcd) +get_oac_sources(CELT_SOURCES_SSE celt_sources.mk celt_sources_sse) +get_oac_sources(CELT_SOURCES_SSE2 celt_sources.mk celt_sources_sse2) +get_oac_sources(CELT_SOURCES_SSE4_1 celt_sources.mk celt_sources_sse4_1) +get_oac_sources(CELT_SOURCES_AVX2 celt_sources.mk celt_sources_avx2) +get_oac_sources(CELT_SOURCES_ARM_RTCD celt_sources.mk celt_sources_arm_rtcd) +get_oac_sources(CELT_SOURCES_ARM_ASM celt_sources.mk celt_sources_arm_asm) +get_oac_sources(CELT_AM_SOURCES_ARM_ASM celt_sources.mk + celt_am_sources_arm_asm) +get_oac_sources(CELT_SOURCES_ARM_NEON_INTR celt_sources.mk + celt_sources_arm_neon_intr) +get_oac_sources(CELT_SOURCES_ARM_NE10 celt_sources.mk celt_sources_arm_ne10) + +get_oac_sources(DEEP_PLC_HEAD lpcnet_headers.mk deep_plc_headers) +get_oac_sources(DRED_HEAD lpcnet_headers.mk dred_headers) +get_oac_sources(OSCE_HEAD lpcnet_headers.mk osce_headers) +get_oac_sources(DEEP_PLC_SOURCES lpcnet_sources.mk deep_plc_sources) +get_oac_sources(DRED_SOURCES lpcnet_sources.mk dred_sources) +get_oac_sources(OSCE_SOURCES lpcnet_sources.mk osce_sources) +get_oac_sources(DNN_SOURCES_X86_RTCD lpcnet_sources.mk dnn_sources_x86_rtcd) +get_oac_sources(DNN_SOURCES_SSE2 lpcnet_sources.mk dnn_sources_sse2) +get_oac_sources(DNN_SOURCES_SSE4_1 lpcnet_sources.mk dnn_sources_sse4_1) +get_oac_sources(DNN_SOURCES_AVX2 lpcnet_sources.mk dnn_sources_avx2) +get_oac_sources(DNN_SOURCES_NEON lpcnet_sources.mk dnn_sources_arm_neon) +get_oac_sources(DNN_SOURCES_DOTPROD lpcnet_sources.mk dnn_sources_arm_dotprod) +get_oac_sources(DNN_SOURCES_ARM_RTCD lpcnet_sources.mk dnn_sources_arm_rtcd) + +get_oac_sources(oac_demo_SOURCES Makefile.am oac_demo_sources) +get_oac_sources(oac_custom_demo_SOURCES Makefile.am oac_custom_demo_sources) +get_oac_sources(oac_compare_SOURCES Makefile.am oac_compare_sources) +get_oac_sources(tests_test_oac_api_SOURCES Makefile.am test_oac_api_sources) +get_oac_sources(tests_test_oac_encode_SOURCES Makefile.am + test_oac_encode_sources) +get_oac_sources(tests_test_oac_extensions_SOURCES Makefile.am + test_oac_extensions_sources) +get_oac_sources(tests_test_oac_decode_SOURCES Makefile.am + test_oac_decode_sources) +get_oac_sources(tests_test_oac_padding_SOURCES Makefile.am + test_oac_padding_sources) +get_oac_sources(tests_test_oac_dred_SOURCES Makefile.am + test_oac_dred_sources) +get_oac_sources(tests_test_oac_custom_SOURCES Makefile.am + test_oac_custom_sources) diff --git a/cmake/OpusConfig.cmake.in b/cmake/OpusConfig.cmake.in deleted file mode 100644 index 0b21231d4..000000000 --- a/cmake/OpusConfig.cmake.in +++ /dev/null @@ -1,20 +0,0 @@ -set(OPUS_VERSION @PROJECT_VERSION@) -set(OPUS_VERSION_STRING @PROJECT_VERSION@) -set(OPUS_VERSION_MAJOR @PROJECT_VERSION_MAJOR@) -set(OPUS_VERSION_MINOR @PROJECT_VERSION_MINOR@) -set(OPUS_VERSION_PATCH @PROJECT_VERSION_PATCH@) - -@PACKAGE_INIT@ - -set_and_check(OPUS_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") -set(OPUS_INCLUDE_DIR ${OPUS_INCLUDE_DIR};${OPUS_INCLUDE_DIR}/opus) -set(OPUS_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@;@PACKAGE_INCLUDE_INSTALL_DIR@/opus") - -include(${CMAKE_CURRENT_LIST_DIR}/OpusTargets.cmake) - -set(OPUS_LIBRARY Opus::opus) -set(OPUS_LIBRARIES Opus::opus) - -check_required_components(Opus) - -set(OPUS_FOUND 1) diff --git a/cmake/OpusPackageVersion.cmake b/cmake/OpusPackageVersion.cmake deleted file mode 100644 index 447ce3b17..000000000 --- a/cmake/OpusPackageVersion.cmake +++ /dev/null @@ -1,70 +0,0 @@ -if(__opus_version) - return() -endif() -set(__opus_version INCLUDED) - -function(get_package_version PACKAGE_VERSION PROJECT_VERSION) - - find_package(Git) - if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git") - execute_process(COMMAND ${GIT_EXECUTABLE} - --git-dir=${CMAKE_CURRENT_LIST_DIR}/.git describe - --tags --match "v*" OUTPUT_VARIABLE OPUS_PACKAGE_VERSION) - if(OPUS_PACKAGE_VERSION) - string(STRIP ${OPUS_PACKAGE_VERSION}, OPUS_PACKAGE_VERSION) - string(REPLACE \n - "" - OPUS_PACKAGE_VERSION - ${OPUS_PACKAGE_VERSION}) - string(REPLACE , - "" - OPUS_PACKAGE_VERSION - ${OPUS_PACKAGE_VERSION}) - - string(SUBSTRING ${OPUS_PACKAGE_VERSION} - 1 - -1 - OPUS_PACKAGE_VERSION) - message(STATUS "Opus package version from git repo: ${OPUS_PACKAGE_VERSION}") - endif() - - elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/package_version" - AND NOT OPUS_PACKAGE_VERSION) - # Not a git repo, lets' try to parse it from package_version file if exists - file(STRINGS package_version OPUS_PACKAGE_VERSION - LIMIT_COUNT 1 - REGEX "PACKAGE_VERSION=") - string(REPLACE "PACKAGE_VERSION=" - "" - OPUS_PACKAGE_VERSION - ${OPUS_PACKAGE_VERSION}) - string(REPLACE "\"" - "" - OPUS_PACKAGE_VERSION - ${OPUS_PACKAGE_VERSION}) - # In case we have a unknown dist here we just replace it with 0 - string(REPLACE "unknown" - "0" - OPUS_PACKAGE_VERSION - ${OPUS_PACKAGE_VERSION}) - message(STATUS "Opus package version from package_version file: ${OPUS_PACKAGE_VERSION}") - endif() - - if(OPUS_PACKAGE_VERSION) - string(REGEX - REPLACE "^([0-9]+.[0-9]+\\.?([0-9]+)?).*" - "\\1" - OPUS_PROJECT_VERSION - ${OPUS_PACKAGE_VERSION}) - else() - # fail to parse version from git and package version - message(WARNING "Could not get package version.") - set(OPUS_PACKAGE_VERSION 0) - set(OPUS_PROJECT_VERSION 0) - endif() - - message(STATUS "Opus project version: ${OPUS_PROJECT_VERSION}") - - set(PACKAGE_VERSION ${OPUS_PACKAGE_VERSION} PARENT_SCOPE) - set(PROJECT_VERSION ${OPUS_PROJECT_VERSION} PARENT_SCOPE) -endfunction() diff --git a/cmake/OpusSources.cmake b/cmake/OpusSources.cmake deleted file mode 100644 index 06cb0d4fa..000000000 --- a/cmake/OpusSources.cmake +++ /dev/null @@ -1,72 +0,0 @@ -if(__opus_sources) - return() -endif() -set(__opus_sources INCLUDED) - -include(OpusFunctions) - -get_opus_sources(SILK_HEAD silk_headers.mk silk_headers) -get_opus_sources(SILK_SOURCES silk_sources.mk silk_sources) -get_opus_sources(SILK_SOURCES_FLOAT silk_sources.mk silk_sources_float) -get_opus_sources(SILK_SOURCES_FIXED silk_sources.mk silk_sources_fixed) -get_opus_sources(SILK_SOURCES_X86_RTCD silk_sources.mk silk_sources_x86_rtcd) -get_opus_sources(SILK_SOURCES_SSE4_1 silk_sources.mk silk_sources_sse4_1) -get_opus_sources(SILK_SOURCES_FIXED_SSE4_1 silk_sources.mk - silk_sources_fixed_sse4_1) -get_opus_sources(SILK_SOURCES_AVX2 silk_sources.mk silk_sources_avx2) -get_opus_sources(SILK_SOURCES_FLOAT_AVX2 silk_sources.mk silk_sources_float_avx2) -get_opus_sources(SILK_SOURCES_ARM_RTCD silk_sources.mk silk_sources_arm_rtcd) -get_opus_sources(SILK_SOURCES_ARM_NEON_INTR silk_sources.mk - silk_sources_arm_neon_intr) -get_opus_sources(SILK_SOURCES_FIXED_ARM_NEON_INTR silk_sources.mk - silk_sources_fixed_arm_neon_intr) - -get_opus_sources(OPUS_HEAD opus_headers.mk opus_headers) -get_opus_sources(OPUS_SOURCES opus_sources.mk opus_sources) -get_opus_sources(OPUS_SOURCES_FLOAT opus_sources.mk opus_sources_float) - -get_opus_sources(CELT_HEAD celt_headers.mk celt_headers) -get_opus_sources(CELT_SOURCES celt_sources.mk celt_sources) -get_opus_sources(CELT_SOURCES_X86_RTCD celt_sources.mk celt_sources_x86_rtcd) -get_opus_sources(CELT_SOURCES_SSE celt_sources.mk celt_sources_sse) -get_opus_sources(CELT_SOURCES_SSE2 celt_sources.mk celt_sources_sse2) -get_opus_sources(CELT_SOURCES_SSE4_1 celt_sources.mk celt_sources_sse4_1) -get_opus_sources(CELT_SOURCES_AVX2 celt_sources.mk celt_sources_avx2) -get_opus_sources(CELT_SOURCES_ARM_RTCD celt_sources.mk celt_sources_arm_rtcd) -get_opus_sources(CELT_SOURCES_ARM_ASM celt_sources.mk celt_sources_arm_asm) -get_opus_sources(CELT_AM_SOURCES_ARM_ASM celt_sources.mk - celt_am_sources_arm_asm) -get_opus_sources(CELT_SOURCES_ARM_NEON_INTR celt_sources.mk - celt_sources_arm_neon_intr) -get_opus_sources(CELT_SOURCES_ARM_NE10 celt_sources.mk celt_sources_arm_ne10) - -get_opus_sources(DEEP_PLC_HEAD lpcnet_headers.mk deep_plc_headers) -get_opus_sources(DRED_HEAD lpcnet_headers.mk dred_headers) -get_opus_sources(OSCE_HEAD lpcnet_headers.mk osce_headers) -get_opus_sources(DEEP_PLC_SOURCES lpcnet_sources.mk deep_plc_sources) -get_opus_sources(DRED_SOURCES lpcnet_sources.mk dred_sources) -get_opus_sources(OSCE_SOURCES lpcnet_sources.mk osce_sources) -get_opus_sources(DNN_SOURCES_X86_RTCD lpcnet_sources.mk dnn_sources_x86_rtcd) -get_opus_sources(DNN_SOURCES_SSE2 lpcnet_sources.mk dnn_sources_sse2) -get_opus_sources(DNN_SOURCES_SSE4_1 lpcnet_sources.mk dnn_sources_sse4_1) -get_opus_sources(DNN_SOURCES_AVX2 lpcnet_sources.mk dnn_sources_avx2) -get_opus_sources(DNN_SOURCES_NEON lpcnet_sources.mk dnn_sources_arm_neon) -get_opus_sources(DNN_SOURCES_DOTPROD lpcnet_sources.mk dnn_sources_arm_dotprod) -get_opus_sources(DNN_SOURCES_ARM_RTCD lpcnet_sources.mk dnn_sources_arm_rtcd) - -get_opus_sources(opus_demo_SOURCES Makefile.am opus_demo_sources) -get_opus_sources(opus_custom_demo_SOURCES Makefile.am opus_custom_demo_sources) -get_opus_sources(opus_compare_SOURCES Makefile.am opus_compare_sources) -get_opus_sources(tests_test_opus_api_SOURCES Makefile.am test_opus_api_sources) -get_opus_sources(tests_test_opus_encode_SOURCES Makefile.am - test_opus_encode_sources) -get_opus_sources(tests_test_opus_extensions_SOURCES Makefile.am - test_opus_extensions_sources) -get_opus_sources(tests_test_opus_decode_SOURCES Makefile.am - test_opus_decode_sources) -get_opus_sources(tests_test_opus_padding_SOURCES Makefile.am - test_opus_padding_sources) -get_opus_sources(tests_test_opus_dred_SOURCES Makefile.am - test_opus_dred_sources) -get_opus_sources(tests_test_opus_custom_SOURCES Makefile.am - test_opus_custom_sources) diff --git a/cmake/README.md b/cmake/README.md index d8e4978f6..1deac73d1 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -1,6 +1,6 @@ -# Using CMake for the Opus Project +# Using CMake for the Oac Project -This guide provides instructions for using CMake to build the Opus project with various configuration options. CMake is a widely used build system generator that helps manage the build process across different platforms. +This guide provides instructions for using CMake to build the Oac project with various configuration options. CMake is a widely used build system generator that helps manage the build process across different platforms. Note: Please keep in mind that software documentation can sometimes go out of date as new versions are released. It is always recommended to refer to the official CMake documentation for the most up-to-date and accurate information. You can find the official CMake documentation at [cmake.org/documentation](https://cmake.org/documentation/). @@ -14,48 +14,48 @@ Before proceeding, make sure you have the following prerequisites installed: ## Build Instructions -Follow the steps below to build the Opus project using CMake: +Follow the steps below to build the Oac project using CMake: -1. Clone the Opus repository using Git: +1. Clone the Oac repository using Git: ```shell - git clone https://gitlab.xiph.org/xiph/opus + git clone https://gitlab.xiph.org/xiph/oac ``` -2. Create a build directory within the Opus repository: +2. Create a build directory within the Oac repository: ```shell - cd opus + cd oac mkdir build cd build ``` 3. Configure the build with CMake. You can set the desired configuration options using CMake's `-D` flag. Here are some available options: - - `OPUS_BUILD_SHARED_LIBRARY`: build shared library. - - `OPUS_BUILD_TESTING`: build tests. - - `OPUS_BUILD_PROGRAMS`: build programs. - - `OPUS_CUSTOM_MODES`, enable non-Opus modes, e.g. 44.1 kHz & 2^n frames. + - `OAC_BUILD_SHARED_LIBRARY`: build shared library. + - `OAC_BUILD_TESTING`: build tests. + - `OAC_BUILD_PROGRAMS`: build programs. + - `OAC_CUSTOM_MODES`, enable non-Oac modes, e.g. 44.1 kHz & 2^n frames. For example, to enable the custom modes and build programs, use the following command: ```shell - cmake .. -DOPUS_BUILD_PROGRAMS=ON -DOPUS_BUILD_TESTING=ON + cmake .. -DOAC_BUILD_PROGRAMS=ON -DOAC_BUILD_TESTING=ON ``` -4. Build the Opus project: +4. Build the Oac project: ```shell cmake --build . ``` -5. After a successful build, you can find the compiled Opus library and associated files in the build directory. +5. After a successful build, you can find the compiled Oac library and associated files in the build directory. ## Testing with CTest -Opus provides a comprehensive test suite to ensure the functionality and correctness of the project. You can execute the tests using CTest, a part of the CMake build system. CTest allows for automated testing and provides useful features for managing and evaluating the test results. +Oac provides a comprehensive test suite to ensure the functionality and correctness of the project. You can execute the tests using CTest, a part of the CMake build system. CTest allows for automated testing and provides useful features for managing and evaluating the test results. -To run the Opus tests using CTest, follow these steps: +To run the Oac tests using CTest, follow these steps: 1. Navigate to the build directory after configuring and building the project with CMake: @@ -77,7 +77,7 @@ ctest -C Debug ## Platform Support and Bug Reporting -CMake aims to provide broad platform support, allowing the Opus project to be built and used on major operating systems and platforms. The supported platforms include: +CMake aims to provide broad platform support, allowing the Oac project to be built and used on major operating systems and platforms. The supported platforms include: - Windows - macOS @@ -85,9 +85,9 @@ CMake aims to provide broad platform support, allowing the Opus project to be bu - Android - iOS -CMake achieves platform support by generating platform-specific build files (e.g., Makefiles, Visual Studio projects) based on the target platform. This allows developers to build and configure the Opus project consistently across different operating systems and environments. +CMake achieves platform support by generating platform-specific build files (e.g., Makefiles, Visual Studio projects) based on the target platform. This allows developers to build and configure the Oac project consistently across different operating systems and environments. -While CMake strives to ensure compatibility and stability across platforms, bugs or issues may still arise in specific configurations. If you encounter any problems during the configuration process or while building the Opus project, we encourage you to file an issue in the [project's issue tracker](https://gitlab.xiph.org/xiph/opus/-/issues). +While CMake strives to ensure compatibility and stability across platforms, bugs or issues may still arise in specific configurations. If you encounter any problems during the configuration process or while building the Oac project, we encourage you to file an issue in the [project's issue tracker](https://gitlab.xiph.org/xiph/oac/-/issues). When reporting an issue, please provide the following information to help us understand and reproduce the configuration problem effectively: @@ -98,9 +98,9 @@ When reporting an issue, please provide the following information to help us und 5. Any relevant information about the platform, toolchain, or dependencies used. 6. Additional context or details that might assist in troubleshooting the issue. -By providing thorough information when reporting configuration issues, you contribute to improving the Opus project's compatibility and reliability across different platforms. +By providing thorough information when reporting configuration issues, you contribute to improving the Oac project's compatibility and reliability across different platforms. -We appreciate your help in identifying and addressing any configuration-related problems, ensuring a better experience for all users of the Opus project. +We appreciate your help in identifying and addressing any configuration-related problems, ensuring a better experience for all users of the Oac project. ## Platform Specific Examples diff --git a/configure.ac b/configure.ac index e8c05e122..6d5250c85 100644 --- a/configure.ac +++ b/configure.ac @@ -12,9 +12,9 @@ m4_define([CURRENT_VERSION], printf "unknown" fi ])) -AC_INIT([opus],[CURRENT_VERSION],[opus@xiph.org]) +AC_INIT([oac],[CURRENT_VERSION],[oac@xiph.org]) -AC_CONFIG_SRCDIR(src/opus_encoder.c) +AC_CONFIG_SRCDIR(src/oac_encoder.c) AC_CONFIG_MACRO_DIR([m4]) dnl enable silent rules on automake 1.11 and later @@ -22,13 +22,13 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # For libtool. dnl Please update these for releases. -OPUS_LT_CURRENT=11 -OPUS_LT_REVISION=1 -OPUS_LT_AGE=11 +OAC_LT_CURRENT=11 +OAC_LT_REVISION=1 +OAC_LT_AGE=11 -AC_SUBST(OPUS_LT_CURRENT) -AC_SUBST(OPUS_LT_REVISION) -AC_SUBST(OPUS_LT_AGE) +AC_SUBST(OAC_LT_CURRENT) +AC_SUBST(OAC_LT_REVISION) +AC_SUBST(OAC_LT_AGE) AM_INIT_AUTOMAKE([no-define]) AM_MAINTAINER_MODE([enable]) @@ -42,7 +42,7 @@ AC_C_INLINE AM_PROG_AS -AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS]) +AC_DEFINE([OAC_BUILD], [], [This is a build of OAC]) #Use a hacked up version of autoconf's AC_C_RESTRICT because it's not #strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3) @@ -157,7 +157,7 @@ AS_IF([test "$enable_qext" = "yes"],[ AM_CONDITIONAL([ENABLE_QEXT], [test "$enable_qext" = "yes"]) AC_ARG_ENABLE([custom-modes], - [AS_HELP_STRING([--enable-custom-modes], [enable non-Opus modes, e.g. 44.1 kHz & 2^n frames])],, + [AS_HELP_STRING([--enable-custom-modes], [enable non-Oac modes, e.g. 44.1 kHz & 2^n frames])],, [enable_custom_modes=no]) AS_IF([test "$enable_custom_modes" = "yes"],[ @@ -165,16 +165,16 @@ AS_IF([test "$enable_custom_modes" = "yes"],[ PC_BUILD="$PC_BUILD, custom modes" ]) -AC_ARG_ENABLE([opus-custom-api], - [AS_HELP_STRING([--enable-opus-custom-api], [enable Opus custom API])],, - [enable_opus_custom_api=no]) +AC_ARG_ENABLE([oac-custom-api], + [AS_HELP_STRING([--enable-oac-custom-api], [enable Oac custom API])],, + [enable_oac_custom_api=no]) -AS_IF([test "$enable_opus_custom_api" = "yes"],[ - AC_DEFINE([ENABLE_OPUS_CUSTOM_API], [1], [Opus custom API]) - PC_BUILD="$PC_BUILD, Opus custom API" +AS_IF([test "$enable_oac_custom_api" = "yes"],[ + AC_DEFINE([ENABLE_OAC_CUSTOM_API], [1], [Oac custom API]) + PC_BUILD="$PC_BUILD, Oac custom API" ]) -AM_CONDITIONAL([CUSTOM_MODES], [test "$enable_custom_modes" = "yes" || test "$enable_opus_custom_api" = "yes"]) +AM_CONDITIONAL([CUSTOM_MODES], [test "$enable_custom_modes" = "yes" || test "$enable_oac_custom_api" = "yes"]) AC_ARG_ENABLE([dred], [AS_HELP_STRING([--enable-dred], [use Deep REDundancy (DRED)])],, @@ -195,7 +195,7 @@ AS_IF([test "$enable_deep_plc" = "yes" || test "$enable_dred" = "yes" || test "$ AM_CONDITIONAL([ENABLE_DEEP_PLC], [test "$enable_deep_plc" = "yes" || test "$enable_dred" = "yes" || test "$enable_osce" = "yes" || test "$enable_osce_training_data" = "yes"]) AC_ARG_ENABLE([lossgen], - [AS_HELP_STRING([--enable-lossgen], [build opus_demo with packet loss simulator])],, + [AS_HELP_STRING([--enable-lossgen], [build oac_demo with packet loss simulator])],, [enable_lossgen=no]) AS_IF([test "$enable_lossgen" = "yes"],[ @@ -245,31 +245,31 @@ AS_IF([test x"${enable_asm}" = x"yes"],[ dnl Currently we only have asm for fixed-point #AS_IF([test "$enable_float" != "yes"],[ cpu_arm=yes - AC_DEFINE([OPUS_ARM_ASM], [], [Make use of ARM asm optimization]) + AC_DEFINE([OAC_ARM_ASM], [], [Make use of ARM asm optimization]) AS_GCC_INLINE_ASSEMBLY( [inline_optimization="ARM"], [inline_optimization="disabled"] ) - AS_ASM_ARM_EDSP([OPUS_ARM_INLINE_EDSP=1],[OPUS_ARM_INLINE_EDSP=0]) - AS_ASM_ARM_MEDIA([OPUS_ARM_INLINE_MEDIA=1], - [OPUS_ARM_INLINE_MEDIA=0]) - AS_ASM_ARM_NEON([OPUS_ARM_INLINE_NEON=1],[OPUS_ARM_INLINE_NEON=0]) + AS_ASM_ARM_EDSP([OAC_ARM_INLINE_EDSP=1],[OAC_ARM_INLINE_EDSP=0]) + AS_ASM_ARM_MEDIA([OAC_ARM_INLINE_MEDIA=1], + [OAC_ARM_INLINE_MEDIA=0]) + AS_ASM_ARM_NEON([OAC_ARM_INLINE_NEON=1],[OAC_ARM_INLINE_NEON=0]) AS_IF([test x"$inline_optimization" = x"ARM"],[ - AM_CONDITIONAL([OPUS_ARM_INLINE_ASM],[true]) - AC_DEFINE([OPUS_ARM_INLINE_ASM], 1, + AM_CONDITIONAL([OAC_ARM_INLINE_ASM],[true]) + AC_DEFINE([OAC_ARM_INLINE_ASM], 1, [Use generic ARMv4 inline asm optimizations]) - AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"],[ - AC_DEFINE([OPUS_ARM_INLINE_EDSP], [1], + AS_IF([test x"$OAC_ARM_INLINE_EDSP" = x"1"],[ + AC_DEFINE([OAC_ARM_INLINE_EDSP], [1], [Use ARMv5E inline asm optimizations]) inline_optimization="$inline_optimization (EDSP)" ]) - AS_IF([test x"$OPUS_ARM_INLINE_MEDIA" = x"1"],[ - AC_DEFINE([OPUS_ARM_INLINE_MEDIA], [1], + AS_IF([test x"$OAC_ARM_INLINE_MEDIA" = x"1"],[ + AC_DEFINE([OAC_ARM_INLINE_MEDIA], [1], [Use ARMv6 inline asm optimizations]) inline_optimization="$inline_optimization (Media)" ]) - AS_IF([test x"$OPUS_ARM_INLINE_NEON" = x"1"],[ - AC_DEFINE([OPUS_ARM_INLINE_NEON], 1, + AS_IF([test x"$OAC_ARM_INLINE_NEON" = x"1"],[ + AC_DEFINE([OAC_ARM_INLINE_NEON], 1, [Use ARM NEON inline asm optimizations]) inline_optimization="$inline_optimization (NEON)" ]) @@ -277,98 +277,98 @@ AS_IF([test x"${enable_asm}" = x"yes"],[ dnl We need Perl to translate RVCT-syntax asm to gas syntax. AC_CHECK_PROG([HAVE_PERL], perl, yes, no) AS_IF([test x"$HAVE_PERL" = x"yes"],[ - AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM],[true]) + AM_CONDITIONAL([OAC_ARM_EXTERNAL_ASM],[true]) asm_optimization="ARM" - AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"], [ - OPUS_ARM_PRESUME_EDSP=1 - OPUS_ARM_MAY_HAVE_EDSP=1 + AS_IF([test x"$OAC_ARM_INLINE_EDSP" = x"1"], [ + OAC_ARM_PRESUME_EDSP=1 + OAC_ARM_MAY_HAVE_EDSP=1 ], [ - OPUS_ARM_PRESUME_EDSP=0 - OPUS_ARM_MAY_HAVE_EDSP=0 + OAC_ARM_PRESUME_EDSP=0 + OAC_ARM_MAY_HAVE_EDSP=0 ]) - AS_IF([test x"$OPUS_ARM_INLINE_MEDIA" = x"1"], [ - OPUS_ARM_PRESUME_MEDIA=1 - OPUS_ARM_MAY_HAVE_MEDIA=1 + AS_IF([test x"$OAC_ARM_INLINE_MEDIA" = x"1"], [ + OAC_ARM_PRESUME_MEDIA=1 + OAC_ARM_MAY_HAVE_MEDIA=1 ], [ - OPUS_ARM_PRESUME_MEDIA=0 - OPUS_ARM_MAY_HAVE_MEDIA=0 + OAC_ARM_PRESUME_MEDIA=0 + OAC_ARM_MAY_HAVE_MEDIA=0 ]) - AS_IF([test x"$OPUS_ARM_INLINE_NEON" = x"1"], [ - OPUS_ARM_PRESUME_NEON=1 - OPUS_ARM_MAY_HAVE_NEON=1 + AS_IF([test x"$OAC_ARM_INLINE_NEON" = x"1"], [ + OAC_ARM_PRESUME_NEON=1 + OAC_ARM_MAY_HAVE_NEON=1 ], [ - OPUS_ARM_PRESUME_NEON=0 - OPUS_ARM_MAY_HAVE_NEON=0 + OAC_ARM_PRESUME_NEON=0 + OAC_ARM_MAY_HAVE_NEON=0 ]) AS_IF([test x"$enable_rtcd" = x"yes"],[ - AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" != x"1"],[ + AS_IF([test x"$OAC_ARM_MAY_HAVE_EDSP" != x"1"],[ AC_MSG_NOTICE( [Trying to force-enable armv5e EDSP instructions...]) - AS_ASM_ARM_EDSP_FORCE([OPUS_ARM_MAY_HAVE_EDSP=1]) + AS_ASM_ARM_EDSP_FORCE([OAC_ARM_MAY_HAVE_EDSP=1]) ]) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_MEDIA" != x"1"],[ + AS_IF([test x"$OAC_ARM_MAY_HAVE_MEDIA" != x"1"],[ AC_MSG_NOTICE( [Trying to force-enable ARMv6 media instructions...]) - AS_ASM_ARM_MEDIA_FORCE([OPUS_ARM_MAY_HAVE_MEDIA=1]) + AS_ASM_ARM_MEDIA_FORCE([OAC_ARM_MAY_HAVE_MEDIA=1]) ]) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON" != x"1"],[ + AS_IF([test x"$OAC_ARM_MAY_HAVE_NEON" != x"1"],[ AC_MSG_NOTICE( [Trying to force-enable NEON instructions...]) - AS_ASM_ARM_NEON_FORCE([OPUS_ARM_MAY_HAVE_NEON=1]) + AS_ASM_ARM_NEON_FORCE([OAC_ARM_MAY_HAVE_NEON=1]) ]) ]) rtcd_support= - AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" = x"1"],[ - AC_DEFINE(OPUS_ARM_MAY_HAVE_EDSP, 1, + AS_IF([test x"$OAC_ARM_MAY_HAVE_EDSP" = x"1"],[ + AC_DEFINE(OAC_ARM_MAY_HAVE_EDSP, 1, [Define if assembler supports EDSP instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_EDSP" = x"1"],[ - AC_DEFINE(OPUS_ARM_PRESUME_EDSP, 1, + AS_IF([test x"$OAC_ARM_PRESUME_EDSP" = x"1"],[ + AC_DEFINE(OAC_ARM_PRESUME_EDSP, 1, [Define if binary requires EDSP instruction support]) asm_optimization="$asm_optimization (EDSP)" ], [rtcd_support="$rtcd_support (EDSP)"] ) ]) - AC_SUBST(OPUS_ARM_MAY_HAVE_EDSP) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_MEDIA" = x"1"],[ - AC_DEFINE(OPUS_ARM_MAY_HAVE_MEDIA, 1, + AC_SUBST(OAC_ARM_MAY_HAVE_EDSP) + AS_IF([test x"$OAC_ARM_MAY_HAVE_MEDIA" = x"1"],[ + AC_DEFINE(OAC_ARM_MAY_HAVE_MEDIA, 1, [Define if assembler supports ARMv6 media instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_MEDIA" = x"1"],[ - AC_DEFINE(OPUS_ARM_PRESUME_MEDIA, 1, + AS_IF([test x"$OAC_ARM_PRESUME_MEDIA" = x"1"],[ + AC_DEFINE(OAC_ARM_PRESUME_MEDIA, 1, [Define if binary requires ARMv6 media instruction support]) asm_optimization="$asm_optimization (Media)" ], [rtcd_support="$rtcd_support (Media)"] ) ]) - AC_SUBST(OPUS_ARM_MAY_HAVE_MEDIA) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON" = x"1"],[ - AC_DEFINE(OPUS_ARM_MAY_HAVE_NEON, 1, + AC_SUBST(OAC_ARM_MAY_HAVE_MEDIA) + AS_IF([test x"$OAC_ARM_MAY_HAVE_NEON" = x"1"],[ + AC_DEFINE(OAC_ARM_MAY_HAVE_NEON, 1, [Define if compiler supports NEON instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_NEON" = x"1"], [ - AC_DEFINE(OPUS_ARM_PRESUME_NEON, 1, + AS_IF([test x"$OAC_ARM_PRESUME_NEON" = x"1"], [ + AC_DEFINE(OAC_ARM_PRESUME_NEON, 1, [Define if binary requires NEON instruction support]) asm_optimization="$asm_optimization (NEON)" ], [rtcd_support="$rtcd_support (NEON)"] ) ]) - AC_SUBST(OPUS_ARM_MAY_HAVE_NEON) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_DOTPROD" = x"1"],[ - AC_DEFINE(OPUS_ARM_MAY_HAVE_DOTPROD, 1, + AC_SUBST(OAC_ARM_MAY_HAVE_NEON) + AS_IF([test x"$OAC_ARM_MAY_HAVE_DOTPROD" = x"1"],[ + AC_DEFINE(OAC_ARM_MAY_HAVE_DOTPROD, 1, [Define if compiler supports DOTPROD instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_DOTPROD" = x"1"], [ - AC_DEFINE(OPUS_ARM_PRESUME_DOTPROD, 1, + AS_IF([test x"$OAC_ARM_PRESUME_DOTPROD" = x"1"], [ + AC_DEFINE(OAC_ARM_PRESUME_DOTPROD, 1, [Define if binary requires DOTPROD instruction support]) asm_optimization="$asm_optimization (DOTPROD)" ], [rtcd_support="$rtcd_support (DOTPROD)"] ) ]) - AC_SUBST(OPUS_ARM_MAY_HAVE_DOTPROD) + AC_SUBST(OAC_ARM_MAY_HAVE_DOTPROD) dnl Make sure turning on RTCD gets us at least one dnl instruction set. AS_IF([test x"$rtcd_support" != x""], @@ -397,9 +397,9 @@ AS_IF([test x"${enable_asm}" = x"yes"],[ asm_optimization="disabled" ]) -AM_CONDITIONAL([OPUS_ARM_INLINE_ASM], +AM_CONDITIONAL([OAC_ARM_INLINE_ASM], [test x"${inline_optimization%% *}" = x"ARM"]) -AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM], +AM_CONDITIONAL([OAC_ARM_EXTERNAL_ASM], [test x"${asm_optimization%% *}" = x"ARM"]) AM_CONDITIONAL([HAVE_SSE], [false]) @@ -439,7 +439,7 @@ AS_VAR_SET_IF([X86_AVX2_CFLAGS], [], [AS_VAR_SET([X86_AVX2_CFLAGS], "DEFAULT_X86 AS_VAR_SET_IF([ARM_NEON_INTR_CFLAGS], [], [AS_VAR_SET([ARM_NEON_INTR_CFLAGS], ["$RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS"])]) AS_VAR_SET_IF([ARM_DOTPROD_INTR_CFLAGS], [], [AS_VAR_SET([ARM_DOTPROD_INTR_CFLAGS], ["DEFAULT_ARM_DOTPROD_INTR_CFLAGS"])]) -AC_DEFUN([OPUS_PATH_NE10], +AC_DEFUN([OAC_PATH_NE10], [ AC_ARG_WITH(NE10, AS_HELP_STRING([--with-NE10=PFX],[prefix where libNE10 is installed (optional)]), @@ -519,11 +519,11 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ [arm*|aarch64*], [ cpu_arm=yes - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [ARM Neon], [$ARM_NEON_INTR_CFLAGS], - [OPUS_ARM_MAY_HAVE_NEON_INTR], - [OPUS_ARM_PRESUME_NEON_INTR], + [OAC_ARM_MAY_HAVE_NEON_INTR], + [OAC_ARM_PRESUME_NEON_INTR], [[#include ]], [[ @@ -532,40 +532,40 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ return (int)vgetq_lane_f32(SUMM, 0); ]] ) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"], + AS_IF([test x"$OAC_ARM_MAY_HAVE_NEON_INTR" = x"1" && test x"$OAC_ARM_PRESUME_NEON_INTR" != x"1"], [ - OPUS_ARM_NEON_INTR_CFLAGS="$ARM_NEON_INTR_CFLAGS" - AC_SUBST([OPUS_ARM_NEON_INTR_CFLAGS]) + OAC_ARM_NEON_INTR_CFLAGS="$ARM_NEON_INTR_CFLAGS" + AC_SUBST([OAC_ARM_NEON_INTR_CFLAGS]) ] ) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"], + AS_IF([test x"$OAC_ARM_MAY_HAVE_NEON_INTR" = x"1"], [ - AC_DEFINE([OPUS_ARM_MAY_HAVE_NEON_INTR], 1, [Compiler supports ARMv7/Aarch64 Neon Intrinsics]) + AC_DEFINE([OAC_ARM_MAY_HAVE_NEON_INTR], 1, [Compiler supports ARMv7/Aarch64 Neon Intrinsics]) intrinsics_support="$intrinsics_support (NEON)" - AS_IF([test x"$enable_rtcd" != x"no" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"], + AS_IF([test x"$enable_rtcd" != x"no" && test x"$OAC_ARM_PRESUME_NEON_INTR" != x"1"], [AS_IF([test x"$rtcd_support" = x"no"], [rtcd_support="ARM (NEON Intrinsics)"], [rtcd_support="$rtcd_support (NEON Intrinsics)"])]) - AS_IF([test x"$OPUS_ARM_PRESUME_NEON_INTR" = x"1"], - [AC_DEFINE([OPUS_ARM_PRESUME_NEON_INTR], 1, [Define if binary requires NEON intrinsics support])]) + AS_IF([test x"$OAC_ARM_PRESUME_NEON_INTR" = x"1"], + [AC_DEFINE([OAC_ARM_PRESUME_NEON_INTR], 1, [Define if binary requires NEON intrinsics support])]) - OPUS_PATH_NE10() + OAC_PATH_NE10() AS_IF([test x"$NE10_LIBS" != x""], [ intrinsics_support="$intrinsics_support (NE10)" AS_IF([test x"enable_rtcd" != x"" \ - && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"], + && test x"$OAC_ARM_PRESUME_NEON_INTR" != x"1"], [rtcd_support="$rtcd_support (NE10)"]) ]) - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [Aarch64 Neon], [$ARM_NEON_INTR_CFLAGS], - [OPUS_ARM_MAY_HAVE_AARCH64_NEON_INTR], - [OPUS_ARM_PRESUME_AARCH64_NEON_INTR], + [OAC_ARM_MAY_HAVE_AARCH64_NEON_INTR], + [OAC_ARM_PRESUME_AARCH64_NEON_INTR], [[#include ]], [[ @@ -575,17 +575,17 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ ]] ) - AS_IF([test x"$OPUS_ARM_PRESUME_AARCH64_NEON_INTR" = x"1"], + AS_IF([test x"$OAC_ARM_PRESUME_AARCH64_NEON_INTR" = x"1"], [ - AC_DEFINE([OPUS_ARM_PRESUME_AARCH64_NEON_INTR], 1, [Define if binary requires Aarch64 Neon Intrinsics]) + AC_DEFINE([OAC_ARM_PRESUME_AARCH64_NEON_INTR], 1, [Define if binary requires Aarch64 Neon Intrinsics]) intrinsics_support="$intrinsics_support (NEON [Aarch64])" ]) - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [Aarch64 dotprod], [$ARM_DOTPROD_INTR_CFLAGS], - [OPUS_ARM_MAY_HAVE_DOTPROD], - [OPUS_ARM_PRESUME_DOTPROD], + [OAC_ARM_MAY_HAVE_DOTPROD], + [OAC_ARM_PRESUME_DOTPROD], [[#include ]], [[ @@ -594,25 +594,25 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ acc = vdotq_s32(acc, a, b); ]] ) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_DOTPROD" = x"1" && test x"$OPUS_ARM_PRESUME_DOTPROD" != x"1"], + AS_IF([test x"$OAC_ARM_MAY_HAVE_DOTPROD" = x"1" && test x"$OAC_ARM_PRESUME_DOTPROD" != x"1"], [ - OPUS_ARM_DOTPROD_INTR_CFLAGS="$ARM_NEON_DOTPROD_CFLAGS" - AC_SUBST([OPUS_ARM_DOTPROD_INTR_CFLAGS]) + OAC_ARM_DOTPROD_INTR_CFLAGS="$ARM_NEON_DOTPROD_CFLAGS" + AC_SUBST([OAC_ARM_DOTPROD_INTR_CFLAGS]) ] ) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_DOTPROD" = x"1"], + AS_IF([test x"$OAC_ARM_MAY_HAVE_DOTPROD" = x"1"], [ - AC_DEFINE([OPUS_ARM_MAY_HAVE_DOTPROD], 1, [Compiler supports Aarch64 DOTPROD Intrinsics]) + AC_DEFINE([OAC_ARM_MAY_HAVE_DOTPROD], 1, [Compiler supports Aarch64 DOTPROD Intrinsics]) intrinsics_support="$intrinsics_support (DOTPROD)" - AS_IF([test x"$OPUS_ARM_PRESUME_DOTPROD" = x"1"], + AS_IF([test x"$OAC_ARM_PRESUME_DOTPROD" = x"1"], [ - AC_DEFINE([OPUS_ARM_PRESUME_DOTPROD], 1, [Define if binary requires Aarch64 dotprod Intrinsics]) + AC_DEFINE([OAC_ARM_PRESUME_DOTPROD], 1, [Define if binary requires Aarch64 dotprod Intrinsics]) intrinsics_support="$intrinsics_support (DOTPROD [Aarch64])" ]) - AS_IF([test x"$enable_rtcd" != x"no" && test x"$OPUS_ARM_PRESUME_DOTPROD" != x"1"], + AS_IF([test x"$enable_rtcd" != x"no" && test x"$OAC_ARM_PRESUME_DOTPROD" != x"1"], [AS_IF([test x"$rtcd_support" = x"no"], [rtcd_support="ARM (DOTPROD Intrinsics)"], [rtcd_support="$rtcd_support (DOTPROD Intrinsics)"])]) @@ -633,11 +633,11 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ [i?86|x86_64], [ cpu_x86=yes - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [SSE], [$X86_SSE_CFLAGS], - [OPUS_X86_MAY_HAVE_SSE], - [OPUS_X86_PRESUME_SSE], + [OAC_X86_MAY_HAVE_SSE], + [OAC_X86_PRESUME_SSE], [[#include #include ]], @@ -648,17 +648,17 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ return _mm_cvtss_si32(mtest); ]] ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1" && test x"$OPUS_X86_PRESUME_SSE" != x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_SSE" = x"1" && test x"$OAC_X86_PRESUME_SSE" != x"1"], [ - OPUS_X86_SSE_CFLAGS="$X86_SSE_CFLAGS" - AC_SUBST([OPUS_X86_SSE_CFLAGS]) + OAC_X86_SSE_CFLAGS="$X86_SSE_CFLAGS" + AC_SUBST([OAC_X86_SSE_CFLAGS]) ] ) - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [SSE2], [$X86_SSE2_CFLAGS], - [OPUS_X86_MAY_HAVE_SSE2], - [OPUS_X86_PRESUME_SSE2], + [OAC_X86_MAY_HAVE_SSE2], + [OAC_X86_PRESUME_SSE2], [[#include #include ]], @@ -669,17 +669,17 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ return _mm_cvtsi128_si32(mtest); ]] ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1" && test x"$OPUS_X86_PRESUME_SSE2" != x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_SSE2" = x"1" && test x"$OAC_X86_PRESUME_SSE2" != x"1"], [ - OPUS_X86_SSE2_CFLAGS="$X86_SSE2_CFLAGS" - AC_SUBST([OPUS_X86_SSE2_CFLAGS]) + OAC_X86_SSE2_CFLAGS="$X86_SSE2_CFLAGS" + AC_SUBST([OAC_X86_SSE2_CFLAGS]) ] ) - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [SSE4.1], [$X86_SSE4_1_CFLAGS], - [OPUS_X86_MAY_HAVE_SSE4_1], - [OPUS_X86_PRESUME_SSE4_1], + [OAC_X86_MAY_HAVE_SSE4_1], + [OAC_X86_PRESUME_SSE4_1], [[#include #include ]], @@ -690,17 +690,17 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ return _mm_cvtsi128_si32(mtest); ]] ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1" && test x"$OPUS_X86_PRESUME_SSE4_1" != x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_SSE4_1" = x"1" && test x"$OAC_X86_PRESUME_SSE4_1" != x"1"], [ - OPUS_X86_SSE4_1_CFLAGS="$X86_SSE4_1_CFLAGS" - AC_SUBST([OPUS_X86_SSE4_1_CFLAGS]) + OAC_X86_SSE4_1_CFLAGS="$X86_SSE4_1_CFLAGS" + AC_SUBST([OAC_X86_SSE4_1_CFLAGS]) ] ) - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [AVX2], [$X86_AVX2_CFLAGS], - [OPUS_X86_MAY_HAVE_AVX2], - [OPUS_X86_PRESUME_AVX2], + [OAC_X86_MAY_HAVE_AVX2], + [OAC_X86_PRESUME_AVX2], [[#include #include ]], @@ -718,58 +718,58 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ _mm256_xor_si256(mtest1, mtest2), _mm256_cvttps_epi32(mtest)), 0); ]] ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX2" = x"1" && test x"$OPUS_X86_PRESUME_AVX2" != x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_AVX2" = x"1" && test x"$OAC_X86_PRESUME_AVX2" != x"1"], [ - OPUS_X86_AVX2_CFLAGS="$X86_AVX2_CFLAGS" - AC_SUBST([OPUS_X86_AVX2_CFLAGS]) + OAC_X86_AVX2_CFLAGS="$X86_AVX2_CFLAGS" + AC_SUBST([OAC_X86_AVX2_CFLAGS]) ] ) AS_IF([test x"$rtcd_support" = x"no"], [rtcd_support=""]) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_SSE" = x"1"], [ - AC_DEFINE([OPUS_X86_MAY_HAVE_SSE], 1, [Compiler supports X86 SSE Intrinsics]) + AC_DEFINE([OAC_X86_MAY_HAVE_SSE], 1, [Compiler supports X86 SSE Intrinsics]) intrinsics_support="$intrinsics_support SSE" - AS_IF([test x"$OPUS_X86_PRESUME_SSE" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_SSE], 1, [Define if binary requires SSE intrinsics support])], + AS_IF([test x"$OAC_X86_PRESUME_SSE" = x"1"], + [AC_DEFINE([OAC_X86_PRESUME_SSE], 1, [Define if binary requires SSE intrinsics support])], [rtcd_support="$rtcd_support SSE"]) ], [ AC_MSG_WARN([Compiler does not support SSE intrinsics]) ]) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_SSE2" = x"1"], [ - AC_DEFINE([OPUS_X86_MAY_HAVE_SSE2], 1, [Compiler supports X86 SSE2 Intrinsics]) + AC_DEFINE([OAC_X86_MAY_HAVE_SSE2], 1, [Compiler supports X86 SSE2 Intrinsics]) intrinsics_support="$intrinsics_support SSE2" - AS_IF([test x"$OPUS_X86_PRESUME_SSE2" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_SSE2], 1, [Define if binary requires SSE2 intrinsics support])], + AS_IF([test x"$OAC_X86_PRESUME_SSE2" = x"1"], + [AC_DEFINE([OAC_X86_PRESUME_SSE2], 1, [Define if binary requires SSE2 intrinsics support])], [rtcd_support="$rtcd_support SSE2"]) ], [ AC_MSG_WARN([Compiler does not support SSE2 intrinsics]) ]) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_SSE4_1" = x"1"], [ - AC_DEFINE([OPUS_X86_MAY_HAVE_SSE4_1], 1, [Compiler supports X86 SSE4.1 Intrinsics]) + AC_DEFINE([OAC_X86_MAY_HAVE_SSE4_1], 1, [Compiler supports X86 SSE4.1 Intrinsics]) intrinsics_support="$intrinsics_support SSE4.1" - AS_IF([test x"$OPUS_X86_PRESUME_SSE4_1" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_SSE4_1], 1, [Define if binary requires SSE4.1 intrinsics support])], + AS_IF([test x"$OAC_X86_PRESUME_SSE4_1" = x"1"], + [AC_DEFINE([OAC_X86_PRESUME_SSE4_1], 1, [Define if binary requires SSE4.1 intrinsics support])], [rtcd_support="$rtcd_support SSE4.1"]) ], [ AC_MSG_WARN([Compiler does not support SSE4.1 intrinsics]) ]) - AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX2" = x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_AVX2" = x"1"], [ - AC_DEFINE([OPUS_X86_MAY_HAVE_AVX2], 1, [Compiler supports X86 AVX2 Intrinsics]) + AC_DEFINE([OAC_X86_MAY_HAVE_AVX2], 1, [Compiler supports X86 AVX2 Intrinsics]) intrinsics_support="$intrinsics_support AVX2" - AS_IF([test x"$OPUS_X86_PRESUME_AVX2" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_AVX2], 1, [Define if binary requires AVX2 intrinsics support])], + AS_IF([test x"$OAC_X86_PRESUME_AVX2" = x"1"], + [AC_DEFINE([OAC_X86_PRESUME_AVX2], 1, [Define if binary requires AVX2 intrinsics support])], [rtcd_support="$rtcd_support AVX2"]) ], [ @@ -846,29 +846,29 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ AM_CONDITIONAL([CPU_ARM], [test "$cpu_arm" = "yes"]) AM_CONDITIONAL([HAVE_ARM_DOTPROD], - [test x"$OPUS_ARM_MAY_HAVE_DOTPROD" = x"1"]) + [test x"$OAC_ARM_MAY_HAVE_DOTPROD" = x"1"]) AM_CONDITIONAL([HAVE_ARM_NEON_INTR], - [test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"]) + [test x"$OAC_ARM_MAY_HAVE_NEON_INTR" = x"1"]) AM_CONDITIONAL([HAVE_ARM_NE10], [test x"$HAVE_ARM_NE10" = x"1"]) AM_CONDITIONAL([CPU_X86], [test "$cpu_x86" = "yes"]) AM_CONDITIONAL([HAVE_SSE], - [test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"]) + [test x"$OAC_X86_MAY_HAVE_SSE" = x"1"]) AM_CONDITIONAL([HAVE_SSE2], - [test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"]) + [test x"$OAC_X86_MAY_HAVE_SSE2" = x"1"]) AM_CONDITIONAL([HAVE_SSE4_1], - [test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"]) + [test x"$OAC_X86_MAY_HAVE_SSE4_1" = x"1"]) AM_CONDITIONAL([HAVE_AVX2], - [test x"$OPUS_X86_MAY_HAVE_AVX2" = x"1"]) + [test x"$OAC_X86_MAY_HAVE_AVX2" = x"1"]) AM_CONDITIONAL([HAVE_RTCD], [test x"$enable_rtcd" = x"yes" && test x"$rtcd_support" != x"no"]) AS_IF([test x"$enable_rtcd" = x"yes"],[ AS_IF([test x"$rtcd_support" != x"no"],[ - AC_DEFINE([OPUS_HAVE_RTCD], [1], + AC_DEFINE([OAC_HAVE_RTCD], [1], [Use run-time CPU capabilities detection]) - OPUS_HAVE_RTCD=1 - AC_SUBST(OPUS_HAVE_RTCD) + OAC_HAVE_RTCD=1 + AC_SUBST(OAC_HAVE_RTCD) ]) ],[ rtcd_support="disabled" @@ -904,7 +904,7 @@ AC_ARG_ENABLE([check-asm], [enable_check_asm=no]) AS_IF([test "$enable_check_asm" = "yes"], [ - AC_DEFINE([OPUS_CHECK_ASM], [1], [Run bit-exactness checks between optimized and C implementations]) + AC_DEFINE([OAC_CHECK_ASM], [1], [Run bit-exactness checks between optimized and C implementations]) ]) AC_ARG_ENABLE([doc], @@ -954,8 +954,8 @@ AC_ARG_ENABLE([osce], ) AS_IF([test "$enable_osce" = "yes" || test "$enable_osce_training_data" = "yes"], [ - AC_DEFINE([ENABLE_OSCE], [1], [Enable Opus Speech Coding Enhancement]) - AC_DEFINE([ENABLE_OSCE_BWE], [1], [Enable Opus Speech Coding Enhancement Blind BWE]) + AC_DEFINE([ENABLE_OSCE], [1], [Enable Oac Speech Coding Enhancement]) + AC_DEFINE([ENABLE_OSCE_BWE], [1], [Enable Oac Speech Coding Enhancement Blind BWE]) ]) AM_CONDITIONAL([ENABLE_OSCE], [test "$enable_osce" = "yes" || test "$enable_osce_training_data" = "yes"]) @@ -1059,8 +1059,8 @@ AC_SUBST([PC_BUILD]) AC_CONFIG_FILES([ Makefile - opus.pc - opus-uninstalled.pc + oac.pc + oac-uninstalled.pc celt/arm/armopts.s doc/Makefile doc/Doxyfile diff --git a/dnn/arm/arm_dnn_map.c b/dnn/arm/arm_dnn_map.c index 98a2a3125..13806f6f9 100644 --- a/dnn/arm/arm_dnn_map.c +++ b/dnn/arm/arm_dnn_map.c @@ -32,11 +32,11 @@ #include "arm/armcpu.h" #include "nnet.h" -#if defined(OPUS_HAVE_RTCD) +#if defined(OAC_HAVE_RTCD) -#if (defined(OPUS_ARM_MAY_HAVE_DOTPROD) && !defined(OPUS_ARM_PRESUME_DOTPROD)) +#if (defined(OAC_ARM_MAY_HAVE_DOTPROD) && !defined(OAC_ARM_PRESUME_DOTPROD)) -void (*const DNN_COMPUTE_LINEAR_IMPL[OPUS_ARCHMASK + 1])( +void (*const DNN_COMPUTE_LINEAR_IMPL[OAC_ARCHMASK + 1])( const LinearLayer *linear, float *out, const float *in @@ -50,9 +50,9 @@ void (*const DNN_COMPUTE_LINEAR_IMPL[OPUS_ARCHMASK + 1])( #endif -#if (defined(OPUS_ARM_MAY_HAVE_DOTPROD) || defined(OPUS_ARM_MAY_HAVE_NEON)) && !defined(OPUS_ARM_PRESUME_NEON) +#if (defined(OAC_ARM_MAY_HAVE_DOTPROD) || defined(OAC_ARM_MAY_HAVE_NEON)) && !defined(OAC_ARM_PRESUME_NEON) -void (*const DNN_COMPUTE_ACTIVATION_IMPL[OPUS_ARCHMASK + 1])( +void (*const DNN_COMPUTE_ACTIVATION_IMPL[OAC_ARCHMASK + 1])( float *output, const float *input, int N, @@ -65,7 +65,7 @@ void (*const DNN_COMPUTE_ACTIVATION_IMPL[OPUS_ARCHMASK + 1])( MAY_HAVE_DOTPROD(compute_activation) /* dotprod */ }; -void (*const DNN_COMPUTE_CONV2D_IMPL[OPUS_ARCHMASK + 1])( +void (*const DNN_COMPUTE_CONV2D_IMPL[OAC_ARCHMASK + 1])( const Conv2dLayer *conv, float *out, float *mem, diff --git a/dnn/arm/dnn_arm.h b/dnn/arm/dnn_arm.h index d7ac74526..a2fe59743 100644 --- a/dnn/arm/dnn_arm.h +++ b/dnn/arm/dnn_arm.h @@ -29,7 +29,7 @@ #define DNN_ARM_H #include "cpu_support.h" -#include "opus_types.h" +#include "oac_types.h" void compute_linear_dotprod(const LinearLayer *linear, float *out, const float *in); void compute_linear_neon(const LinearLayer *linear, float *out, const float *in); @@ -40,40 +40,40 @@ void compute_activation_dotprod(float *output, const float *input, int N, int ac void compute_conv2d_neon(const Conv2dLayer *conv, float *out, float *mem, const float *in, int height, int hstride, int activation); void compute_conv2d_dotprod(const Conv2dLayer *conv, float *out, float *mem, const float *in, int height, int hstride, int activation); -#if defined(OPUS_ARM_PRESUME_DOTPROD) +#if defined(OAC_ARM_PRESUME_DOTPROD) #define OVERRIDE_COMPUTE_LINEAR #define compute_linear(linear, out, in, arch) ((void)(arch),compute_linear_dotprod(linear, out, in)) -#elif defined(OPUS_ARM_PRESUME_NEON_INTR) && !defined(OPUS_ARM_MAY_HAVE_DOTPROD) +#elif defined(OAC_ARM_PRESUME_NEON_INTR) && !defined(OAC_ARM_MAY_HAVE_DOTPROD) #define OVERRIDE_COMPUTE_LINEAR #define compute_linear(linear, out, in, arch) ((void)(arch),compute_linear_neon(linear, out, in)) -#elif defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_DOTPROD) || defined(OPUS_ARM_MAY_HAVE_NEON)) +#elif defined(OAC_HAVE_RTCD) && (defined(OAC_ARM_MAY_HAVE_DOTPROD) || defined(OAC_ARM_MAY_HAVE_NEON)) -extern void (*const DNN_COMPUTE_LINEAR_IMPL[OPUS_ARCHMASK + 1])( +extern void (*const DNN_COMPUTE_LINEAR_IMPL[OAC_ARCHMASK + 1])( const LinearLayer *linear, float *out, const float *in ); #define OVERRIDE_COMPUTE_LINEAR #define compute_linear(linear, out, in, arch) \ - ((*DNN_COMPUTE_LINEAR_IMPL[(arch) & OPUS_ARCHMASK])(linear, out, in)) + ((*DNN_COMPUTE_LINEAR_IMPL[(arch) & OAC_ARCHMASK])(linear, out, in)) #endif -#if defined(OPUS_ARM_PRESUME_NEON) +#if defined(OAC_ARM_PRESUME_NEON) #define OVERRIDE_COMPUTE_ACTIVATION #define compute_activation(output, input, N, activation, arch) ((void)(arch),compute_activation_neon(output, input, N, activation)) #define OVERRIDE_COMPUTE_CONV2D #define compute_conv2d(conv, out, mem, in, height, hstride, activation, arch) ((void)(arch),compute_conv2d_neon(conv, out, mem, in, height, hstride, activation)) -#elif defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_DOTPROD) || defined(OPUS_ARM_MAY_HAVE_NEON)) +#elif defined(OAC_HAVE_RTCD) && (defined(OAC_ARM_MAY_HAVE_DOTPROD) || defined(OAC_ARM_MAY_HAVE_NEON)) -extern void (*const DNN_COMPUTE_ACTIVATION_IMPL[OPUS_ARCHMASK + 1])( +extern void (*const DNN_COMPUTE_ACTIVATION_IMPL[OAC_ARCHMASK + 1])( float *output, const float *input, int N, @@ -81,10 +81,10 @@ extern void (*const DNN_COMPUTE_ACTIVATION_IMPL[OPUS_ARCHMASK + 1])( ); #define OVERRIDE_COMPUTE_ACTIVATION #define compute_activation(output, input, N, activation, arch) \ - ((*DNN_COMPUTE_ACTIVATION_IMPL[(arch) & OPUS_ARCHMASK])(output, input, N, activation)) + ((*DNN_COMPUTE_ACTIVATION_IMPL[(arch) & OAC_ARCHMASK])(output, input, N, activation)) -extern void (*const DNN_COMPUTE_CONV2D_IMPL[OPUS_ARCHMASK + 1])( +extern void (*const DNN_COMPUTE_CONV2D_IMPL[OAC_ARCHMASK + 1])( const Conv2dLayer *conv, float *out, float *mem, @@ -95,7 +95,7 @@ extern void (*const DNN_COMPUTE_CONV2D_IMPL[OPUS_ARCHMASK + 1])( ); #define OVERRIDE_COMPUTE_CONV2D #define compute_conv2d(conv, out, mem, in, height, hstride, activation, arch) \ - ((*DNN_COMPUTE_CONV2D_IMPL[(arch) & OPUS_ARCHMASK])(conv, out, mem, in, height, hstride, activation)) + ((*DNN_COMPUTE_CONV2D_IMPL[(arch) & OAC_ARCHMASK])(conv, out, mem, in, height, hstride, activation)) #endif diff --git a/dnn/bwe_demo.c b/dnn/bwe_demo.c index 530ff605a..8241a0a1e 100644 --- a/dnn/bwe_demo.c +++ b/dnn/bwe_demo.c @@ -56,7 +56,7 @@ int main(int argc, char **argv) { OSCEModel *osce; - arch = opus_select_arch(); + arch = oac_select_arch(); hOSCEBWE = (silk_OSCE_BWE_struct *)calloc(1, sizeof(*hOSCEBWE)); osce = (OSCEModel *)calloc(1, sizeof(*osce)); osce_load_models(osce, NULL, arch); diff --git a/dnn/common.h b/dnn/common.h index b3bec7300..3a1f7027d 100644 --- a/dnn/common.h +++ b/dnn/common.h @@ -6,10 +6,10 @@ #include #include #include -#include "opus_defines.h" +#include "oac_defines.h" #define LOG256 5.5451774445f -static OPUS_INLINE float log2_approx(float x) +static OAC_INLINE float log2_approx(float x) { int integer; float frac; @@ -28,7 +28,7 @@ static OPUS_INLINE float log2_approx(float x) #define log_approx(x) (0.69315f*log2_approx(x)) -static OPUS_INLINE float ulaw2lin(float u) +static OAC_INLINE float ulaw2lin(float u) { float s; float scale_1 = 32768.f/255.f; @@ -38,7 +38,7 @@ static OPUS_INLINE float ulaw2lin(float u) return s*scale_1*(exp(u/128.*LOG256)-1); } -static OPUS_INLINE int lin2ulaw(float x) +static OAC_INLINE int lin2ulaw(float x) { float u; float scale = 255.f/32768.f; diff --git a/dnn/dred_coding.h b/dnn/dred_coding.h index 1ce040c23..bb57cacbe 100644 --- a/dnn/dred_coding.h +++ b/dnn/dred_coding.h @@ -28,7 +28,7 @@ #ifndef DRED_CODING_H #define DRED_CODING_H -#include "opus_types.h" +#include "oac_types.h" #include "entcode.h" int compute_quantizer(int q0, int dQ, int qmax, int i); diff --git a/dnn/dred_compare.c b/dnn/dred_compare.c index 478cc2166..f3e16e64c 100644 --- a/dnn/dred_compare.c +++ b/dnn/dred_compare.c @@ -32,10 +32,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "mini_kfft.c" #define MAX(a,b) ((a)>(b) ? (a) : (b)) -#define OPUS_PI (3.14159265F) +#define OAC_PI (3.14159265F) -#define OPUS_COSF(_x) ((float)cos(_x)) -#define OPUS_SINF(_x) ((float)sin(_x)) +#define OAC_COSF(_x) ((float)cos(_x)) +#define OAC_SINF(_x) ((float)sin(_x)) static void *check_alloc(void *_ptr){ if(_ptr==NULL){ @@ -45,11 +45,11 @@ static void *check_alloc(void *_ptr){ return _ptr; } -static void *opus_malloc(size_t _size){ +static void *oac_malloc(size_t _size){ return check_alloc(malloc(_size)); } -static void *opus_realloc(void *_ptr,size_t _size){ +static void *oac_realloc(void *_ptr,size_t _size){ return check_alloc(realloc(_ptr,_size)); } @@ -114,7 +114,7 @@ static size_t read_pcm(float **_samples,FILE *_fin,int _nchannels, if(nsamples+nread>csamples){ do csamples=csamples<<1|1; while(nsamples+nread>csamples); - samples=(float *)opus_realloc(samples, + samples=(float *)oac_realloc(samples, _nchannels*csamples*sizeof(*samples)); } if (format==FORMAT_S16_LE) { @@ -156,7 +156,7 @@ static size_t read_pcm(float **_samples,FILE *_fin,int _nchannels, } nsamples+=nread; } - *_samples=(float *)opus_realloc(samples, + *_samples=(float *)oac_realloc(samples, _nchannels*nsamples*sizeof(*samples)); biquad(*_samples, mem, *_samples, b_hp, a_hp, nsamples); return nsamples; @@ -176,8 +176,8 @@ static void spectrum(float *_ps,const int *_bands, int _nbands, /* Blackman-Harris window. */ for(xj=0;xj<_window_sz;xj++){ double n = (xj+.5)/_window_sz; - window[xj]=0.35875 - 0.48829*cos(2*OPUS_PI*n) - + 0.14128*cos(4*OPUS_PI*n) - 0.01168*cos(6*OPUS_PI*n); + window[xj]=0.35875 - 0.48829*cos(2*OAC_PI*n) + + 0.14128*cos(4*OAC_PI*n) - 0.01168*cos(6*OAC_PI*n); } kfft = mini_kiss_fftr_alloc(_window_sz, 0, NULL, NULL); for(xi=0;xi<_nframes;xi++){ @@ -395,8 +395,8 @@ int compare_audio(int _argc,const char **_argv, const char *argv0){ return EXIT_FAILURE; } nframes=(xlength-test_win_size+test_win_step)/test_win_step; - X=(float *)opus_malloc(nframes*nfreqs*nchannels*sizeof(*X)); - Y=(float *)opus_malloc(nframes*yfreqs*nchannels*sizeof(*Y)); + X=(float *)oac_malloc(nframes*nfreqs*nchannels*sizeof(*X)); + Y=(float *)oac_malloc(nframes*yfreqs*nchannels*sizeof(*Y)); for(xi=2;ximodel, list); - opus_free(list); + oac_free(list); if (ret == 0) { ret = lpcnet_encoder_load_model(&enc->lpcnet_enc_state, data, len); } if (ret == 0) enc->loaded = 1; - return (ret == 0) ? OPUS_OK : OPUS_BAD_ARG; + return (ret == 0) ? OAC_OK : OAC_BAD_ARG; } void dred_encoder_reset(DREDEnc* enc) { - OPUS_CLEAR((char*)&enc->DREDENC_RESET_START, + OAC_CLEAR((char*)&enc->DREDENC_RESET_START, sizeof(DREDEnc)- ((char*)&enc->DREDENC_RESET_START - (char*)enc)); enc->input_buffer_fill = DRED_SILK_ENCODER_DELAY; @@ -76,7 +76,7 @@ void dred_encoder_reset(DREDEnc* enc) DRED_rdovae_init_encoder(&enc->rdovae_enc); } -void dred_encoder_init(DREDEnc* enc, opus_int32 Fs, int channels) +void dred_encoder_init(DREDEnc* enc, oac_int32 Fs, int channels) { enc->Fs = Fs; enc->channels = channels; @@ -94,16 +94,16 @@ static void dred_process_frame(DREDEnc *enc, int arch) celt_assert(enc->loaded); /* shift latents buffer */ - OPUS_MOVE(enc->latents_buffer + DRED_LATENT_DIM, enc->latents_buffer, (DRED_MAX_FRAMES - 1) * DRED_LATENT_DIM); - OPUS_MOVE(enc->state_buffer + DRED_STATE_DIM, enc->state_buffer, (DRED_MAX_FRAMES - 1) * DRED_STATE_DIM); + OAC_MOVE(enc->latents_buffer + DRED_LATENT_DIM, enc->latents_buffer, (DRED_MAX_FRAMES - 1) * DRED_LATENT_DIM); + OAC_MOVE(enc->state_buffer + DRED_STATE_DIM, enc->state_buffer, (DRED_MAX_FRAMES - 1) * DRED_STATE_DIM); /* calculate LPCNet features */ lpcnet_compute_single_frame_features_float(&enc->lpcnet_enc_state, enc->input_buffer, feature_buffer, arch); lpcnet_compute_single_frame_features_float(&enc->lpcnet_enc_state, enc->input_buffer + DRED_FRAME_SIZE, feature_buffer + 36, arch); /* prepare input buffer (discard LPC coefficients) */ - OPUS_COPY(input_buffer, feature_buffer, DRED_NUM_FEATURES); - OPUS_COPY(input_buffer + DRED_NUM_FEATURES, feature_buffer + 36, DRED_NUM_FEATURES); + OAC_COPY(input_buffer, feature_buffer, DRED_NUM_FEATURES); + OAC_COPY(input_buffer + DRED_NUM_FEATURES, feature_buffer + 36, DRED_NUM_FEATURES); /* run RDOVAE encoder */ dred_rdovae_encode_dframe(&enc->rdovae_enc, &enc->model, enc->latents_buffer, enc->state_buffer, input_buffer, arch); @@ -139,7 +139,7 @@ static void dred_convert_to_16k(DREDEnc *enc, const float *in, int in_len, float int i; int up; celt_assert(enc->channels*in_len <= MAX_DOWNMIX_BUFFER); - celt_assert(in_len * (opus_int32)16000 == out_len * enc->Fs); + celt_assert(in_len * (oac_int32)16000 == out_len * enc->Fs); switch(enc->Fs) { case 8000: up = 2; @@ -165,14 +165,14 @@ static void dred_convert_to_16k(DREDEnc *enc, const float *in, int in_len, float celt_assert(0); } celt_assert(up*in_len <= MAX_DOWNMIX_BUFFER); - OPUS_CLEAR(downmix, up*in_len); + OAC_CLEAR(downmix, up*in_len); if (enc->channels == 1) { for (i=0;iFs == 16000) { - OPUS_COPY(out, downmix, out_len); + OAC_COPY(out, downmix, out_len); } else if (enc->Fs == 48000 || enc->Fs == 24000) { /* ellip(7, .2, 70, 7750/24000) */ @@ -228,7 +228,7 @@ void dred_compute_latents(DREDEnc *enc, const float *pcm, int frame_size, int ex curr_offset16k += 320; dred_process_frame(enc, arch); enc->input_buffer_fill -= 2*DRED_FRAME_SIZE; - OPUS_MOVE(&enc->input_buffer[0], &enc->input_buffer[2*DRED_FRAME_SIZE], enc->input_buffer_fill); + OAC_MOVE(&enc->input_buffer[0], &enc->input_buffer[2*DRED_FRAME_SIZE], enc->input_buffer_fill); /* 15 ms (6*2.5 ms) is the ideal offset for DRED because it corresponds to our vocoder look-ahead. */ if (enc->dred_offset < 6) { enc->dred_offset += 8; @@ -242,7 +242,7 @@ void dred_compute_latents(DREDEnc *enc, const float *pcm, int frame_size, int ex } } -static void dred_encode_latents(ec_enc *enc, const float *x, const opus_uint8 *scale, const opus_uint8 *dzone, const opus_uint8 *r, const opus_uint8 *p0, int dim, int arch) { +static void dred_encode_latents(ec_enc *enc, const float *x, const oac_uint8 *scale, const oac_uint8 *dzone, const oac_uint8 *r, const oac_uint8 *p0, int dim, int arch) { int i; int q[IMAX(DRED_LATENT_DIM,DRED_STATE_DIM)]; float xq[IMAX(DRED_LATENT_DIM,DRED_STATE_DIM)]; @@ -294,7 +294,7 @@ int dred_encode_silk_frame(DREDEnc *enc, unsigned char *buf, int max_chunks, int latent_offset = enc->latent_offset; /* Delaying new DRED data when just out of silence because we already have the - main Opus payload for that frame. */ + main Oac payload for that frame. */ if (activity_mem[0] && enc->last_extra_dred_offset>0) { latent_offset = enc->last_extra_dred_offset; delayed_dred = 1; diff --git a/dnn/dred_encoder.h b/dnn/dred_encoder.h index 6987222c8..f34e7b5ac 100644 --- a/dnn/dred_encoder.h +++ b/dnn/dred_encoder.h @@ -43,7 +43,7 @@ typedef struct { LPCNetEncState lpcnet_enc_state; RDOVAEEncState rdovae_enc; int loaded; - opus_int32 Fs; + oac_int32 Fs; int channels; #define DREDENC_RESET_START input_buffer @@ -59,7 +59,7 @@ typedef struct { } DREDEnc; int dred_encoder_load_model(DREDEnc* enc, const void *data, int len); -void dred_encoder_init(DREDEnc* enc, opus_int32 Fs, int channels); +void dred_encoder_init(DREDEnc* enc, oac_int32 Fs, int channels); void dred_encoder_reset(DREDEnc* enc); void dred_deinit_encoder(DREDEnc *enc); diff --git a/dnn/dred_rdovae.h b/dnn/dred_rdovae.h index 89ea39acf..0edbc54d4 100644 --- a/dnn/dred_rdovae.h +++ b/dnn/dred_rdovae.h @@ -30,7 +30,7 @@ #include -#include "opus_types.h" +#include "oac_types.h" typedef struct RDOVAEDec RDOVAEDec; typedef struct RDOVAEEnc RDOVAEEnc; diff --git a/dnn/dred_rdovae_dec.c b/dnn/dred_rdovae_dec.c index 0c01a3bfc..b986f3bef 100644 --- a/dnn/dred_rdovae_dec.c +++ b/dnn/dred_rdovae_dec.c @@ -37,7 +37,7 @@ static void conv1_cond_init(float *mem, int len, int dilation, int *init) { if (!*init) { int i; - for (i=0;idec_hidden_init, hidden, initial_state, ACTIVATION_TANH, arch); compute_generic_dense(&model->dec_gru_init, state_init, hidden, ACTIVATION_TANH, arch); - OPUS_COPY(h->gru1_state, state_init, DEC_GRU1_STATE_SIZE); + OAC_COPY(h->gru1_state, state_init, DEC_GRU1_STATE_SIZE); counter += DEC_GRU1_STATE_SIZE; - OPUS_COPY(h->gru2_state, &state_init[counter], DEC_GRU2_STATE_SIZE); + OAC_COPY(h->gru2_state, &state_init[counter], DEC_GRU2_STATE_SIZE); counter += DEC_GRU2_STATE_SIZE; - OPUS_COPY(h->gru3_state, &state_init[counter], DEC_GRU3_STATE_SIZE); + OAC_COPY(h->gru3_state, &state_init[counter], DEC_GRU3_STATE_SIZE); counter += DEC_GRU3_STATE_SIZE; - OPUS_COPY(h->gru4_state, &state_init[counter], DEC_GRU4_STATE_SIZE); + OAC_COPY(h->gru4_state, &state_init[counter], DEC_GRU4_STATE_SIZE); counter += DEC_GRU4_STATE_SIZE; - OPUS_COPY(h->gru5_state, &state_init[counter], DEC_GRU5_STATE_SIZE); + OAC_COPY(h->gru5_state, &state_init[counter], DEC_GRU5_STATE_SIZE); h->initialized = 0; } diff --git a/dnn/dred_rdovae_enc.c b/dnn/dred_rdovae_enc.c index 22b0f90f7..af49ad858 100644 --- a/dnn/dred_rdovae_enc.c +++ b/dnn/dred_rdovae_enc.c @@ -40,7 +40,7 @@ static void conv1_cond_init(float *mem, int len, int dilation, int *init) { if (!*init) { int i; - for (i=0;ienc_gru1_input, &model->enc_gru1_recurrent, enc_state->gru1_state, buffer, arch); - OPUS_COPY(&buffer[output_index], enc_state->gru1_state, ENC_GRU1_OUT_SIZE); + OAC_COPY(&buffer[output_index], enc_state->gru1_state, ENC_GRU1_OUT_SIZE); output_index += ENC_GRU1_OUT_SIZE; conv1_cond_init(enc_state->conv1_state, ENC_CONV1_IN_SIZE, 1, &enc_state->initialized); compute_generic_dense(&model->enc_conv_dense1, conv_tmp, buffer, ACTIVATION_TANH, arch); @@ -75,7 +75,7 @@ void dred_rdovae_encode_dframe( output_index += ENC_CONV1_OUT_SIZE; compute_generic_gru(&model->enc_gru2_input, &model->enc_gru2_recurrent, enc_state->gru2_state, buffer, arch); - OPUS_COPY(&buffer[output_index], enc_state->gru2_state, ENC_GRU2_OUT_SIZE); + OAC_COPY(&buffer[output_index], enc_state->gru2_state, ENC_GRU2_OUT_SIZE); output_index += ENC_GRU2_OUT_SIZE; conv1_cond_init(enc_state->conv2_state, ENC_CONV2_IN_SIZE, 2, &enc_state->initialized); compute_generic_dense(&model->enc_conv_dense2, conv_tmp, buffer, ACTIVATION_TANH, arch); @@ -83,7 +83,7 @@ void dred_rdovae_encode_dframe( output_index += ENC_CONV2_OUT_SIZE; compute_generic_gru(&model->enc_gru3_input, &model->enc_gru3_recurrent, enc_state->gru3_state, buffer, arch); - OPUS_COPY(&buffer[output_index], enc_state->gru3_state, ENC_GRU3_OUT_SIZE); + OAC_COPY(&buffer[output_index], enc_state->gru3_state, ENC_GRU3_OUT_SIZE); output_index += ENC_GRU3_OUT_SIZE; conv1_cond_init(enc_state->conv3_state, ENC_CONV3_IN_SIZE, 2, &enc_state->initialized); compute_generic_dense(&model->enc_conv_dense3, conv_tmp, buffer, ACTIVATION_TANH, arch); @@ -91,7 +91,7 @@ void dred_rdovae_encode_dframe( output_index += ENC_CONV3_OUT_SIZE; compute_generic_gru(&model->enc_gru4_input, &model->enc_gru4_recurrent, enc_state->gru4_state, buffer, arch); - OPUS_COPY(&buffer[output_index], enc_state->gru4_state, ENC_GRU4_OUT_SIZE); + OAC_COPY(&buffer[output_index], enc_state->gru4_state, ENC_GRU4_OUT_SIZE); output_index += ENC_GRU4_OUT_SIZE; conv1_cond_init(enc_state->conv4_state, ENC_CONV4_IN_SIZE, 2, &enc_state->initialized); compute_generic_dense(&model->enc_conv_dense4, conv_tmp, buffer, ACTIVATION_TANH, arch); @@ -99,7 +99,7 @@ void dred_rdovae_encode_dframe( output_index += ENC_CONV4_OUT_SIZE; compute_generic_gru(&model->enc_gru5_input, &model->enc_gru5_recurrent, enc_state->gru5_state, buffer, arch); - OPUS_COPY(&buffer[output_index], enc_state->gru5_state, ENC_GRU5_OUT_SIZE); + OAC_COPY(&buffer[output_index], enc_state->gru5_state, ENC_GRU5_OUT_SIZE); output_index += ENC_GRU5_OUT_SIZE; conv1_cond_init(enc_state->conv5_state, ENC_CONV5_IN_SIZE, 2, &enc_state->initialized); compute_generic_dense(&model->enc_conv_dense5, conv_tmp, buffer, ACTIVATION_TANH, arch); @@ -107,10 +107,10 @@ void dred_rdovae_encode_dframe( output_index += ENC_CONV5_OUT_SIZE; compute_generic_dense(&model->enc_zdense, padded_latents, buffer, ACTIVATION_LINEAR, arch); - OPUS_COPY(latents, padded_latents, DRED_LATENT_DIM); + OAC_COPY(latents, padded_latents, DRED_LATENT_DIM); /* next, calculate initial state */ compute_generic_dense(&model->gdense1, state_hidden, buffer, ACTIVATION_TANH, arch); compute_generic_dense(&model->gdense2, padded_state, state_hidden, ACTIVATION_LINEAR, arch); - OPUS_COPY(initial_state, padded_state, DRED_STATE_DIM); + OAC_COPY(initial_state, padded_state, DRED_STATE_DIM); } diff --git a/dnn/dump_data.c b/dnn/dump_data.c index 6d1607ba1..5d987eb92 100644 --- a/dnn/dump_data.c +++ b/dnn/dump_data.c @@ -88,7 +88,7 @@ mini_kiss_fft_cpx *load_rir(const char *rir_file, mini_kiss_fft_state *fft, int for (i=0;i<240;i++) { rir[480+i] *= (1 - i/240.f); } - OPUS_CLEAR(&rir[240+480], RIR_MAX_DURATION-240-480); + OAC_CLEAR(&rir[240+480], RIR_MAX_DURATION-240-480); } for (i=0;ifft, x, X); @@ -207,7 +207,7 @@ static void rand_resp(float *a, float *b) { rand_filt(b); } -static opus_int16 float2short(float x) +static oac_int16 float2short(float x) { int i; i = (int)floor(.5+x); @@ -250,7 +250,7 @@ int main(int argc, char **argv) { FILE *f1, *f2=NULL; FILE *ffeat; FILE *fpcm=NULL; - opus_int16 pcm[FRAME_SIZE]={0}; + oac_int16 pcm[FRAME_SIZE]={0}; float speech_gain=1; LPCNetEncState *st; int training = -1; @@ -265,7 +265,7 @@ int main(int argc, char **argv) { struct rir_list rirs; #endif srand(getpid()); - arch = opus_select_arch(); + arch = oac_select_arch(); st = lpcnet_encoder_create(); argv0=argv[0]; if (argc == 5 && strcmp(argv[1], "-btrain")==0) { @@ -401,13 +401,13 @@ int main(int argc, char **argv) { } } - OPUS_CLEAR(mem, 2); + OAC_CLEAR(mem, 2); biquad(x, mem, x, b_hp, a_hp, SEQUENCE_LENGTH*FRAME_SIZE); - OPUS_CLEAR(mem, 2); + OAC_CLEAR(mem, 2); biquad(x, mem, x, b_sig, a_sig, SEQUENCE_LENGTH*FRAME_SIZE); - OPUS_CLEAR(mem, 2); + OAC_CLEAR(mem, 2); biquad(n, mem, n, b_hp, a_hp, SEQUENCE_LENGTH*FRAME_SIZE); - OPUS_CLEAR(mem, 2); + OAC_CLEAR(mem, 2); biquad(n, mem, n, b_noise, a_noise, SEQUENCE_LENGTH*FRAME_SIZE); speech_rms = weighted_rms(x); diff --git a/dnn/dump_lpcnet_tables.c b/dnn/dump_lpcnet_tables.c index 95084d6e1..4b5e52fe0 100644 --- a/dnn/dump_lpcnet_tables.c +++ b/dnn/dump_lpcnet_tables.c @@ -50,11 +50,11 @@ int main(void) { fprintf(file, "#include \"kiss_fft.h\"\n\n"); - kfft = opus_fft_alloc_twiddles(WINDOW_SIZE, NULL, NULL, NULL, 0); + kfft = oac_fft_alloc_twiddles(WINDOW_SIZE, NULL, NULL, NULL, 0); fprintf(file, "static const arch_fft_state arch_fft = {0, NULL};\n\n"); - fprintf (file, "static const opus_int16 fft_bitrev[%d] = {\n", kfft->nfft); + fprintf (file, "static const oac_int16 fft_bitrev[%d] = {\n", kfft->nfft); for (i=0;infft;i++) fprintf (file, "%d,%c", kfft->bitrev[i],(i+16)%15==0?'\n':' '); fprintf (file, "};\n\n"); diff --git a/dnn/fargan.c b/dnn/fargan.c index c35b3f0c8..04cfd859c 100644 --- a/dnn/fargan.c +++ b/dnn/fargan.c @@ -50,8 +50,8 @@ static void compute_fargan_cond(FARGANState *st, float *cond, const float *featu celt_assert(FARGAN_FEATURES+COND_NET_PEMBED_OUT_SIZE == model->cond_net_fdense1.nb_inputs); celt_assert(COND_NET_FCONV1_IN_SIZE == model->cond_net_fdense1.nb_outputs); celt_assert(COND_NET_FCONV1_OUT_SIZE == model->cond_net_fconv1.nb_outputs); - OPUS_COPY(&dense_in[NB_FEATURES], &model->cond_net_pembed.float_weights[IMAX(0,IMIN(period-32, 223))*COND_NET_PEMBED_OUT_SIZE], COND_NET_PEMBED_OUT_SIZE); - OPUS_COPY(dense_in, features, NB_FEATURES); + OAC_COPY(&dense_in[NB_FEATURES], &model->cond_net_pembed.float_weights[IMAX(0,IMIN(period-32, 223))*COND_NET_PEMBED_OUT_SIZE], COND_NET_PEMBED_OUT_SIZE); + OAC_COPY(dense_in, features, NB_FEATURES); compute_generic_dense(&model->cond_net_fdense1, conv1_in, dense_in, ACTIVATION_TANH, st->arch); compute_generic_conv1d(&model->cond_net_fconv1, fdense2_in, st->cond_conv1_state, conv1_in, COND_NET_FCONV1_IN_SIZE, ACTIVATION_TANH, st->arch); @@ -97,9 +97,9 @@ static void run_fargan_subframe(FARGANState *st, float *pcm, const float *cond, } for (i=0;ipitch_buf[PITCH_MAX_PERIOD-FARGAN_SUBFRAME_SIZE+i])); - OPUS_COPY(&fwc0_in[0], &cond[0], FARGAN_COND_SIZE); - OPUS_COPY(&fwc0_in[FARGAN_COND_SIZE], pred, FARGAN_SUBFRAME_SIZE+4); - OPUS_COPY(&fwc0_in[FARGAN_COND_SIZE+FARGAN_SUBFRAME_SIZE+4], prev, FARGAN_SUBFRAME_SIZE); + OAC_COPY(&fwc0_in[0], &cond[0], FARGAN_COND_SIZE); + OAC_COPY(&fwc0_in[FARGAN_COND_SIZE], pred, FARGAN_SUBFRAME_SIZE+4); + OAC_COPY(&fwc0_in[FARGAN_COND_SIZE+FARGAN_SUBFRAME_SIZE+4], prev, FARGAN_SUBFRAME_SIZE); compute_generic_conv1d(&model->sig_net_fwc0_conv, gru1_in, st->fwc0_mem, fwc0_in, SIG_NET_INPUT_SIZE, ACTIVATION_TANH, st->arch); celt_assert(SIG_NET_FWC0_GLU_GATE_OUT_SIZE == model->sig_net_fwc0_glu_gate.nb_outputs); @@ -108,25 +108,25 @@ static void run_fargan_subframe(FARGANState *st, float *pcm, const float *cond, compute_generic_dense(&model->sig_net_gain_dense_out, pitch_gate, gru1_in, ACTIVATION_SIGMOID, st->arch); for (i=0;isig_net_gru1_input, &model->sig_net_gru1_recurrent, st->gru1_state, gru1_in, st->arch); compute_glu(&model->sig_net_gru1_glu_gate, gru2_in, st->gru1_state, st->arch); for (i=0;isig_net_gru2_input, &model->sig_net_gru2_recurrent, st->gru2_state, gru2_in, st->arch); compute_glu(&model->sig_net_gru2_glu_gate, gru3_in, st->gru2_state, st->arch); for (i=0;isig_net_gru3_input, &model->sig_net_gru3_recurrent, st->gru3_state, gru3_in, st->arch); compute_glu(&model->sig_net_gru3_glu_gate, &skip_cat[SIG_NET_GRU1_OUT_SIZE+SIG_NET_GRU2_OUT_SIZE], st->gru3_state, st->arch); - OPUS_COPY(skip_cat, gru2_in, SIG_NET_GRU1_OUT_SIZE); - OPUS_COPY(&skip_cat[SIG_NET_GRU1_OUT_SIZE], gru3_in, SIG_NET_GRU2_OUT_SIZE); - OPUS_COPY(&skip_cat[SIG_NET_GRU1_OUT_SIZE+SIG_NET_GRU2_OUT_SIZE+SIG_NET_GRU3_OUT_SIZE], gru1_in, SIG_NET_FWC0_CONV_OUT_SIZE); + OAC_COPY(skip_cat, gru2_in, SIG_NET_GRU1_OUT_SIZE); + OAC_COPY(&skip_cat[SIG_NET_GRU1_OUT_SIZE], gru3_in, SIG_NET_GRU2_OUT_SIZE); + OAC_COPY(&skip_cat[SIG_NET_GRU1_OUT_SIZE+SIG_NET_GRU2_OUT_SIZE+SIG_NET_GRU3_OUT_SIZE], gru1_in, SIG_NET_FWC0_CONV_OUT_SIZE); for (i=0;isig_net_skip_dense, skip_out, skip_cat, ACTIVATION_TANH, st->arch); compute_glu(&model->sig_net_skip_glu_gate, skip_out, skip_out, st->arch); @@ -134,8 +134,8 @@ static void run_fargan_subframe(FARGANState *st, float *pcm, const float *cond, compute_generic_dense(&model->sig_net_sig_dense_out, pcm, skip_out, ACTIVATION_TANH, st->arch); for (i=0;ipitch_buf, &st->pitch_buf[FARGAN_SUBFRAME_SIZE], PITCH_MAX_PERIOD-FARGAN_SUBFRAME_SIZE); - OPUS_COPY(&st->pitch_buf[PITCH_MAX_PERIOD-FARGAN_SUBFRAME_SIZE], pcm, FARGAN_SUBFRAME_SIZE); + OAC_MOVE(st->pitch_buf, &st->pitch_buf[FARGAN_SUBFRAME_SIZE], PITCH_MAX_PERIOD-FARGAN_SUBFRAME_SIZE); + OAC_COPY(&st->pitch_buf[PITCH_MAX_PERIOD-FARGAN_SUBFRAME_SIZE], pcm, FARGAN_SUBFRAME_SIZE); fargan_deemphasis(pcm, &st->deemph_mem); } @@ -160,12 +160,12 @@ void fargan_cont(FARGANState *st, const float *pcm0, const float *features0) x0[i] = pcm0[i] - FARGAN_DEEMPHASIS*pcm0[i-1]; } - OPUS_COPY(&st->pitch_buf[PITCH_MAX_PERIOD-FARGAN_FRAME_SIZE], x0, FARGAN_FRAME_SIZE); + OAC_COPY(&st->pitch_buf[PITCH_MAX_PERIOD-FARGAN_FRAME_SIZE], x0, FARGAN_FRAME_SIZE); st->cont_initialized = 1; for (i=0;ilast_period); - OPUS_COPY(&st->pitch_buf[PITCH_MAX_PERIOD-FARGAN_SUBFRAME_SIZE], &x0[FARGAN_FRAME_SIZE+i*FARGAN_SUBFRAME_SIZE], FARGAN_SUBFRAME_SIZE); + OAC_COPY(&st->pitch_buf[PITCH_MAX_PERIOD-FARGAN_SUBFRAME_SIZE], &x0[FARGAN_FRAME_SIZE+i*FARGAN_SUBFRAME_SIZE], FARGAN_SUBFRAME_SIZE); } st->deemph_mem = pcm0[FARGAN_CONT_SAMPLES-1]; } @@ -174,8 +174,8 @@ void fargan_cont(FARGANState *st, const float *pcm0, const float *features0) void fargan_init(FARGANState *st) { int ret; - OPUS_CLEAR(st, 1); - st->arch = opus_select_arch(); + OAC_CLEAR(st, 1); + st->arch = oac_select_arch(); #ifndef USE_WEIGHTS_FILE ret = init_fargan(&st->model, fargan_arrays); #else @@ -189,7 +189,7 @@ int fargan_load_model(FARGANState *st, const void *data, int len) { int ret; parse_weights(&list, data, len); ret = init_fargan(&st->model, list); - opus_free(list); + oac_free(list); if (ret == 0) return 0; else return -1; } @@ -216,7 +216,7 @@ void fargan_synthesize(FARGANState *st, float *pcm, const float *features) fargan_synthesize_impl(st, pcm, features); } -void fargan_synthesize_int(FARGANState *st, opus_int16 *pcm, const float *features) +void fargan_synthesize_int(FARGANState *st, oac_int16 *pcm, const float *features) { int i; float fpcm[FARGAN_FRAME_SIZE]; diff --git a/dnn/fargan.h b/dnn/fargan.h index d44ae89be..bc1557282 100644 --- a/dnn/fargan.h +++ b/dnn/fargan.h @@ -62,7 +62,7 @@ int fargan_load_model(FARGANState *st, const void *data, int len); void fargan_cont(FARGANState *st, const float *pcm0, const float *features0); void fargan_synthesize(FARGANState *st, float *pcm, const float *features); -void fargan_synthesize_int(FARGANState *st, opus_int16 *pcm, const float *features); +void fargan_synthesize_int(FARGANState *st, oac_int16 *pcm, const float *features); #endif /* FARGAN_H */ diff --git a/dnn/fargan_demo.c b/dnn/fargan_demo.c index fe61713aa..ddb2da31f 100644 --- a/dnn/fargan_demo.c +++ b/dnn/fargan_demo.c @@ -131,12 +131,12 @@ void usage(void) { } #ifdef ENABLE_DRED -void dred_decode_latents(ec_dec *dec, float *x, const opus_uint8 *scale, const opus_uint8 *r, const opus_uint8 *p0, int dim); +void dred_decode_latents(ec_dec *dec, float *x, const oac_uint8 *scale, const oac_uint8 *r, const oac_uint8 *p0, int dim); -static opus_uint32 char_to_int(unsigned char ch[4]) +static oac_uint32 char_to_int(unsigned char ch[4]) { - return ((opus_uint32)ch[0]<<24) | ((opus_uint32)ch[1]<<16) - | ((opus_uint32)ch[2]<< 8) | (opus_uint32)ch[3]; + return ((oac_uint32)ch[0]<<24) | ((oac_uint32)ch[1]<<16) + | ((oac_uint32)ch[2]<< 8) | (oac_uint32)ch[3]; } #endif @@ -149,7 +149,7 @@ int main(int argc, char **argv) { void *data; const char *filename = "weights_blob.bin"; #endif - arch = opus_select_arch(); + arch = oac_select_arch(); if (argc < 4) usage(); if (strcmp(argv[1], "-features") == 0) mode=MODE_FEATURES; else if (strcmp(argv[1], "-fargan-synthesis") == 0) mode=MODE_FARGAN_SYNTHESIS; @@ -182,7 +182,7 @@ int main(int argc, char **argv) { net = lpcnet_encoder_create(); while (1) { float features[NB_TOTAL_FEATURES]; - opus_int16 pcm[LPCNET_FRAME_SIZE]; + oac_int16 pcm[LPCNET_FRAME_SIZE]; size_t ret; ret = fread(pcm, sizeof(pcm[0]), LPCNET_FRAME_SIZE, fin); if (feof(fin) || ret != LPCNET_FRAME_SIZE) break; @@ -204,18 +204,18 @@ int main(int argc, char **argv) { /* uncomment the following to align with Python code */ ret = fread(&in_features[0], sizeof(in_features[0]), NB_FEATURES, fin); for (i=1;i<5;i++) { - OPUS_COPY(&in_features[i*NB_FEATURES], &in_features[0], NB_FEATURES); + OAC_COPY(&in_features[i*NB_FEATURES], &in_features[0], NB_FEATURES); } fargan_cont(&fargan, zeros, in_features); while (1) { float features[NB_FEATURES]; float fpcm[LPCNET_FRAME_SIZE]; - opus_int16 pcm[LPCNET_FRAME_SIZE]; + oac_int16 pcm[LPCNET_FRAME_SIZE]; ret = fread(in_features, sizeof(features[0]), NB_FEATURES, fin); if (stop || feof(fin) || ret != NB_FEATURES) { stop++; } else { - OPUS_COPY(features, in_features, NB_FEATURES); + OAC_COPY(features, in_features, NB_FEATURES); } fargan_synthesize(&fargan, fpcm, features); for (i=0;i>1; j++) { - opus_val32 tmp1, tmp2; + oac_val32 tmp1, tmp2; tmp1 = lpc[j]; tmp2 = lpc[i-1-j]; lpc[j] = tmp1 + MULT32_32_Q31(r,tmp2); @@ -164,7 +164,7 @@ static void compute_burg_cepstrum(const float *pcm, float *burg_cepstrum, int le for (i=0;ipcm_buf, &new_pcm[SUBFRAME_SIZE], FWGAN_FRAME_SIZE-SUBFRAME_SIZE); + OAC_COPY(st->pcm_buf, &new_pcm[SUBFRAME_SIZE], FWGAN_FRAME_SIZE-SUBFRAME_SIZE); } static void apply_gain(float *pcm, float c0, float *last_gain) { @@ -178,10 +178,10 @@ static void fwgan_lpc_syn(float *pcm, float *mem, const float *lpc, float last_l for (i=0;iembed_phase, w0); /* Interleave bfcc_cond and pembed for each subframe in feat_in. */ - OPUS_COPY(&feat_in[BFCC_WITH_CORR_UPSAMPLER_FC_OUT_SIZE/4], &cond[0], BFCC_WITH_CORR_UPSAMPLER_FC_OUT_SIZE/4); - OPUS_COPY(&feat_in[0], &pembed[0], FWGAN_FRAME_SIZE/2); + OAC_COPY(&feat_in[BFCC_WITH_CORR_UPSAMPLER_FC_OUT_SIZE/4], &cond[0], BFCC_WITH_CORR_UPSAMPLER_FC_OUT_SIZE/4); + OAC_COPY(&feat_in[0], &pembed[0], FWGAN_FRAME_SIZE/2); compute_generic_conv1d(&model->feat_in_conv1_conv, rnn_in, st->cont_conv1_mem, feat_in, FEAT_IN_CONV1_CONV_IN_SIZE, ACTIVATION_LINEAR); celt_assert(FEAT_IN_NL1_GATE_OUT_SIZE == model->feat_in_nl1_gate.nb_outputs); @@ -223,10 +223,10 @@ static void run_fwgan_subframe(FWGANState *st, float *pcm, const float *cond, do if (st->cont_initialized == 1) { /* On the very first subframe we stop here. We only want to run the feat_in layer since the others are initialized via the continuation network. */ - OPUS_CLEAR(pcm, SUBFRAME_SIZE); + OAC_CLEAR(pcm, SUBFRAME_SIZE); st->cont_initialized = 2; apply_gain(pcm, c0, &st->last_gain); - OPUS_COPY(st->last_lpc, lpc, LPC_ORDER); + OAC_COPY(st->last_lpc, lpc, LPC_ORDER); return; } @@ -264,7 +264,7 @@ static void run_fwgan_subframe(FWGANState *st, float *pcm, const float *cond, do void fwgan_init(FWGANState *st) { int ret; - OPUS_CLEAR(st, 1); + OAC_CLEAR(st, 1); ret = init_fwgan(&st->model, fwgan_arrays); celt_assert(ret == 0); /* FIXME: perform arch detection. */ @@ -275,7 +275,7 @@ int fwgan_load_model(FWGANState *st, const unsigned char *data, int len) { int ret; parse_weights(&list, data, len); ret = init_fwgan(&st->model, list); - opus_free(list); + oac_free(list); if (ret == 0) return 0; else return -1; } @@ -288,7 +288,7 @@ static void fwgan_synthesize_impl(FWGANState *st, float *pcm, const float *lpc, int period; float fwgan_features[NB_FEATURES-1]; celt_assert(st->cont_initialized); - OPUS_COPY(fwgan_features, features, NB_FEATURES-2); + OAC_COPY(fwgan_features, features, NB_FEATURES-2); fwgan_features[NB_FEATURES-2] = features[NB_FEATURES-1]+.5; period = (int)floor(.1 + 50*features[NB_BANDS]+100); @@ -308,12 +308,12 @@ void fwgan_synthesize(FWGANState *st, float *pcm, const float *features) compute_wlpc(lpc, features); fwgan_synthesize_impl(st, new_pcm, lpc, features); /* Handle buffering. */ - OPUS_COPY(pcm, st->pcm_buf, FWGAN_FRAME_SIZE-SUBFRAME_SIZE); - OPUS_COPY(&pcm[FWGAN_FRAME_SIZE-SUBFRAME_SIZE], new_pcm, SUBFRAME_SIZE); - OPUS_COPY(st->pcm_buf, &new_pcm[SUBFRAME_SIZE], FWGAN_FRAME_SIZE-SUBFRAME_SIZE); + OAC_COPY(pcm, st->pcm_buf, FWGAN_FRAME_SIZE-SUBFRAME_SIZE); + OAC_COPY(&pcm[FWGAN_FRAME_SIZE-SUBFRAME_SIZE], new_pcm, SUBFRAME_SIZE); + OAC_COPY(st->pcm_buf, &new_pcm[SUBFRAME_SIZE], FWGAN_FRAME_SIZE-SUBFRAME_SIZE); } -void fwgan_synthesize_int(FWGANState *st, opus_int16 *pcm, const float *features) +void fwgan_synthesize_int(FWGANState *st, oac_int16 *pcm, const float *features) { int i; float fpcm[FWGAN_FRAME_SIZE]; diff --git a/dnn/fwgan.h b/dnn/fwgan.h index acb7014d7..6c6358a73 100644 --- a/dnn/fwgan.h +++ b/dnn/fwgan.h @@ -77,7 +77,7 @@ int fwgan_load_model(FWGANState *st, const unsigned char *data, int len); void fwgan_cont(FWGANState *st, const float *pcm0, const float *features0); void fwgan_synthesize(FWGANState *st, float *pcm, const float *features); -void fwgan_synthesize_int(FWGANState *st, opus_int16 *pcm, const float *features); +void fwgan_synthesize_int(FWGANState *st, oac_int16 *pcm, const float *features); #endif /* FWGAN_H */ diff --git a/dnn/lossgen.c b/dnn/lossgen.c index 52b5029bb..e7292d0c1 100644 --- a/dnn/lossgen.c +++ b/dnn/lossgen.c @@ -24,7 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* This packet loss simulator can be used independently of the Opus codebase. +/* This packet loss simulator can be used independently of the Oac codebase. To do that, you need to compile the following files: dnn/lossgen.c dnn/lossgen_data.c @@ -40,8 +40,8 @@ celt/os_support.h celt/arch.h celt/x86/x86_arch_macros.h - include/opus_defines.h - include/opus_types.h + include/oac_defines.h + include/oac_types.h Additionally, the code in dnn/lossgen_demo.c can be used to generate losses from the command line. @@ -156,7 +156,7 @@ int sample_loss( void lossgen_init(LossGenState *st) { int ret; - OPUS_CLEAR(st, 1); + OAC_CLEAR(st, 1); ret = init_lossgen(&st->model, lossgen_arrays); celt_assert(ret == 0); (void)ret; @@ -167,7 +167,7 @@ int lossgen_load_model(LossGenState *st, const void *data, int len) { int ret; parse_weights(&list, data, len); ret = init_lossgen(&st->model, list); - opus_free(list); + oac_free(list); if (ret == 0) return 0; else return -1; } diff --git a/dnn/lpcnet.c b/dnn/lpcnet.c index 52e81b074..eed998453 100644 --- a/dnn/lpcnet.c +++ b/dnn/lpcnet.c @@ -60,7 +60,7 @@ void rc2lpc(float *lpc, const float *rc) int i, j, k; float tmp[LPC_ORDER]; float ntmp[LPC_ORDER] = {0.0}; - OPUS_COPY(tmp, rc, LPC_ORDER); + OAC_COPY(tmp, rc, LPC_ORDER); for(i = 0; i < LPC_ORDER ; i++) { for(j = 0; j <= i-1; j++) @@ -94,15 +94,15 @@ void run_frame_network(LPCNetState *lpcnet, float *gru_a_condition, float *gru_b pitch = (int)floor(.1 + 50*features[NB_BANDS]+100); pitch = IMIN(255, IMAX(33, pitch)); net = &lpcnet->nnet; - OPUS_COPY(in, features, NB_FEATURES); + OAC_COPY(in, features, NB_FEATURES); compute_embedding(&lpcnet->model.embed_pitch, &in[NB_FEATURES], pitch); compute_conv1d(&lpcnet->model.feature_conv1, conv1_out, net->feature_conv1_state, in); - if (lpcnet->frame_count < FEATURE_CONV1_DELAY) OPUS_CLEAR(conv1_out, FEATURE_CONV1_OUT_SIZE); + if (lpcnet->frame_count < FEATURE_CONV1_DELAY) OAC_CLEAR(conv1_out, FEATURE_CONV1_OUT_SIZE); compute_conv1d(&lpcnet->model.feature_conv2, conv2_out, net->feature_conv2_state, conv1_out); - if (lpcnet->frame_count < FEATURES_DELAY) OPUS_CLEAR(conv2_out, FEATURE_CONV2_OUT_SIZE); + if (lpcnet->frame_count < FEATURES_DELAY) OAC_CLEAR(conv2_out, FEATURE_CONV2_OUT_SIZE); _lpcnet_compute_dense(&lpcnet->model.feature_dense1, dense1_out, conv2_out); _lpcnet_compute_dense(&lpcnet->model.feature_dense2, condition, dense1_out); - OPUS_COPY(rc, condition, LPC_ORDER); + OAC_COPY(rc, condition, LPC_ORDER); _lpcnet_compute_dense(&lpcnet->model.gru_a_dense_feature, gru_a_condition, condition); _lpcnet_compute_dense(&lpcnet->model.gru_b_dense_feature, gru_b_condition, condition); #ifdef END2END @@ -125,11 +125,11 @@ void run_frame_network_deferred(LPCNetState *lpcnet, const float *features) int max_buffer_size = lpcnet->model.feature_conv1.kernel_size + lpcnet->model.feature_conv2.kernel_size - 2; celt_assert(max_buffer_size <= MAX_FEATURE_BUFFER_SIZE); if (lpcnet->feature_buffer_fill == max_buffer_size) { - OPUS_MOVE(lpcnet->feature_buffer, &lpcnet->feature_buffer[NB_FEATURES], (max_buffer_size-1)*NB_FEATURES); + OAC_MOVE(lpcnet->feature_buffer, &lpcnet->feature_buffer[NB_FEATURES], (max_buffer_size-1)*NB_FEATURES); } else { lpcnet->feature_buffer_fill++; } - OPUS_COPY(&lpcnet->feature_buffer[(lpcnet->feature_buffer_fill-1)*NB_FEATURES], features, NB_FEATURES); + OAC_COPY(&lpcnet->feature_buffer[(lpcnet->feature_buffer_fill-1)*NB_FEATURES], features, NB_FEATURES); } void run_frame_network_flush(LPCNetState *lpcnet) @@ -154,15 +154,15 @@ int run_sample_network(LPCNetState *lpcnet, const float *gru_a_condition, const #if 1 compute_gru_a_input(gru_a_input, gru_a_condition, GRU_A_STATE_SIZE, &lpcnet->model.gru_a_embed_sig, last_sig, &lpcnet->model.gru_a_embed_pred, pred, &lpcnet->model.gru_a_embed_exc, last_exc); #else - OPUS_COPY(gru_a_input, gru_a_condition, 3*GRU_A_STATE_SIZE); + OAC_COPY(gru_a_input, gru_a_condition, 3*GRU_A_STATE_SIZE); accum_embedding(&lpcnet->model.gru_a_embed_sig, gru_a_input, last_sig); accum_embedding(&lpcnet->model.gru_a_embed_pred, gru_a_input, pred); accum_embedding(&lpcnet->model.gru_a_embed_exc, gru_a_input, last_exc); #endif /*compute_gru3(&gru_a, net->gru_a_state, gru_a_input);*/ compute_sparse_gru(&lpcnet->model.sparse_gru_a, net->gru_a_state, gru_a_input); - OPUS_COPY(in_b, net->gru_a_state, GRU_A_STATE_SIZE); - OPUS_COPY(gru_b_input, gru_b_condition, 3*GRU_B_STATE_SIZE); + OAC_COPY(in_b, net->gru_a_state, GRU_A_STATE_SIZE); + OAC_COPY(gru_b_input, gru_b_condition, 3*GRU_B_STATE_SIZE); compute_gruB(&lpcnet->model.gru_b, gru_b_input, net->gru_b_state, in_b); return sample_mdense(&lpcnet->model.dual_fc, net->gru_b_state, sampling_logit_table, rng); } @@ -175,7 +175,7 @@ int lpcnet_get_size() void lpcnet_reset(LPCNetState *lpcnet) { const char* rng_string="LPCNet"; - OPUS_CLEAR((char*)&lpcnet->LPCNET_RESET_START, + OAC_CLEAR((char*)&lpcnet->LPCNET_RESET_START, sizeof(LPCNetState)- ((char*)&lpcnet->LPCNET_RESET_START - (char*)lpcnet)); lpcnet->last_exc = lin2ulaw(0.f); @@ -205,7 +205,7 @@ int lpcnet_load_model(LPCNetState *st, const unsigned char *data, int len) { int ret; parse_weights(&list, data, len); ret = init_lpcnet_model(&st->model, list); - opus_free(list); + oac_free(list); if (ret == 0) return 0; else return -1; } @@ -214,33 +214,33 @@ int lpcnet_load_model(LPCNetState *st, const unsigned char *data, int len) { LPCNetState *lpcnet_create() { LPCNetState *lpcnet; - lpcnet = (LPCNetState *)opus_alloc(lpcnet_get_size(), 1); - OPUS_CLEAR(lpcnet, 1); + lpcnet = (LPCNetState *)oac_alloc(lpcnet_get_size(), 1); + OAC_CLEAR(lpcnet, 1); lpcnet_init(lpcnet); return lpcnet; } void lpcnet_destroy(LPCNetState *lpcnet) { - opus_free(lpcnet); + oac_free(lpcnet); } void lpcnet_reset_signal(LPCNetState *lpcnet) { lpcnet->deemph_mem = 0; lpcnet->last_exc = lin2ulaw(0.f); - OPUS_CLEAR(lpcnet->last_sig, LPC_ORDER); - OPUS_CLEAR(lpcnet->nnet.gru_a_state, GRU_A_STATE_SIZE); - OPUS_CLEAR(lpcnet->nnet.gru_b_state, GRU_B_STATE_SIZE); + OAC_CLEAR(lpcnet->last_sig, LPC_ORDER); + OAC_CLEAR(lpcnet->nnet.gru_a_state, GRU_A_STATE_SIZE); + OAC_CLEAR(lpcnet->nnet.gru_b_state, GRU_B_STATE_SIZE); } -void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, opus_int16 *output, int N, int preload) +void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, oac_int16 *output, int N, int preload) { int i; if (lpcnet->frame_count <= FEATURES_DELAY) { - OPUS_CLEAR(output, N); + OAC_CLEAR(output, N); return; } for (i=0;ilast_sig[1], &lpcnet->last_sig[0], LPC_ORDER-1); + OAC_MOVE(&lpcnet->last_sig[1], &lpcnet->last_sig[0], LPC_ORDER-1); lpcnet->last_sig[0] = pcm; lpcnet->last_exc = exc; pcm += PREEMPH*lpcnet->deemph_mem; @@ -272,12 +272,12 @@ void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, opus_int16 *output, int N, } } -void lpcnet_synthesize_impl(LPCNetState *lpcnet, const float *features, opus_int16 *output, int N, int preload) +void lpcnet_synthesize_impl(LPCNetState *lpcnet, const float *features, oac_int16 *output, int N, int preload) { run_frame_network(lpcnet, lpcnet->gru_a_condition, lpcnet->gru_b_condition, lpcnet->lpc, features); lpcnet_synthesize_tail_impl(lpcnet, output, N, preload); } -void lpcnet_synthesize(LPCNetState *lpcnet, const float *features, opus_int16 *output, int N) { +void lpcnet_synthesize(LPCNetState *lpcnet, const float *features, oac_int16 *output, int N) { lpcnet_synthesize_impl(lpcnet, features, output, N, 0); } diff --git a/dnn/lpcnet.h b/dnn/lpcnet.h index 4a9812466..0cbf13ec7 100644 --- a/dnn/lpcnet.h +++ b/dnn/lpcnet.h @@ -27,7 +27,7 @@ #ifndef LPCNET_H_ #define LPCNET_H_ -#include "opus_types.h" +#include "oac_types.h" #define NB_FEATURES 20 #define NB_TOTAL_FEATURES 36 @@ -73,10 +73,10 @@ void lpcnet_decoder_destroy(LPCNetDecState *st); /** Decodes a packet of LPCNET_COMPRESSED_SIZE bytes (currently 8) into LPCNET_PACKET_SAMPLES samples (currently 640). * @param [in] st LPCNetDecState*: Decoder state * @param [in] buf const unsigned char *: Compressed packet - * @param [out] pcm opus_int16 *: Decoded audio + * @param [out] pcm oac_int16 *: Decoded audio * @retval 0 Success */ -int lpcnet_decode(LPCNetDecState *st, const unsigned char *buf, opus_int16 *pcm); +int lpcnet_decode(LPCNetDecState *st, const unsigned char *buf, oac_int16 *pcm); @@ -108,19 +108,19 @@ void lpcnet_encoder_destroy(LPCNetEncState *st); /** Encodes LPCNET_PACKET_SAMPLES speech samples (currently 640) into a packet of LPCNET_COMPRESSED_SIZE bytes (currently 8). * @param [in] st LPCNetDecState*: Encoder state - * @param [in] pcm opus_int16 *: Input speech to be encoded + * @param [in] pcm oac_int16 *: Input speech to be encoded * @param [out] buf const unsigned char *: Compressed packet * @retval 0 Success */ -int lpcnet_encode(LPCNetEncState *st, const opus_int16 *pcm, unsigned char *buf); +int lpcnet_encode(LPCNetEncState *st, const oac_int16 *pcm, unsigned char *buf); /** Compute features on LPCNET_FRAME_SIZE speech samples (currently 160) and output features for one 10-ms frame. * @param [in] st LPCNetDecState*: Encoder state - * @param [in] pcm opus_int16 *: Input speech to be analyzed + * @param [in] pcm oac_int16 *: Input speech to be analyzed * @param [out] features float[NB_TOTAL_FEATURES]: Four feature vectors * @retval 0 Success */ -int lpcnet_compute_single_frame_features(LPCNetEncState *st, const opus_int16 *pcm, float features[NB_TOTAL_FEATURES], int arch); +int lpcnet_compute_single_frame_features(LPCNetEncState *st, const oac_int16 *pcm, float features[NB_TOTAL_FEATURES], int arch); /** Compute features on LPCNET_FRAME_SIZE speech samples (currently 160) and output features for one 10-ms frame. @@ -158,20 +158,20 @@ void lpcnet_destroy(LPCNetState *st); /** Synthesizes speech from an LPCNet feature vector. * @param [in] st LPCNetState*: Synthesis state * @param [in] features const float *: Compressed packet - * @param [out] output opus_int16 **: Synthesized speech + * @param [out] output oac_int16 **: Synthesized speech * @param [in] N int: Number of samples to generate * @retval 0 Success */ -void lpcnet_synthesize(LPCNetState *st, const float *features, opus_int16 *output, int N); +void lpcnet_synthesize(LPCNetState *st, const float *features, oac_int16 *output, int N); int lpcnet_plc_init(LPCNetPLCState *st); void lpcnet_plc_reset(LPCNetPLCState *st); -int lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm); +int lpcnet_plc_update(LPCNetPLCState *st, oac_int16 *pcm); -int lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm); +int lpcnet_plc_conceal(LPCNetPLCState *st, oac_int16 *pcm); void lpcnet_plc_fec_add(LPCNetPLCState *st, const float *features); diff --git a/dnn/lpcnet_enc.c b/dnn/lpcnet_enc.c index 1acd1bf62..862f2a081 100644 --- a/dnn/lpcnet_enc.c +++ b/dnn/lpcnet_enc.c @@ -62,20 +62,20 @@ int lpcnet_encoder_load_model(LPCNetEncState *st, const void *data, int len) { LPCNetEncState *lpcnet_encoder_create(void) { LPCNetEncState *st; - st = (LPCNetEncState*)opus_alloc(lpcnet_encoder_get_size()); + st = (LPCNetEncState*)oac_alloc(lpcnet_encoder_get_size()); lpcnet_encoder_init(st); return st; } void lpcnet_encoder_destroy(LPCNetEncState *st) { - opus_free(st); + oac_free(st); } static void frame_analysis(LPCNetEncState *st, kiss_fft_cpx *X, float *Ex, const float *in) { float x[WINDOW_SIZE]; - OPUS_COPY(x, st->analysis_mem, OVERLAP_SIZE); - OPUS_COPY(&x[OVERLAP_SIZE], in, FRAME_SIZE); - OPUS_COPY(st->analysis_mem, &in[FRAME_SIZE-OVERLAP_SIZE], OVERLAP_SIZE); + OAC_COPY(x, st->analysis_mem, OVERLAP_SIZE); + OAC_COPY(&x[OVERLAP_SIZE], in, FRAME_SIZE); + OAC_COPY(st->analysis_mem, &in[FRAME_SIZE-OVERLAP_SIZE], OVERLAP_SIZE); apply_window(x); forward_transform(X, x); lpcn_compute_band_energy(Ex, X); @@ -124,7 +124,7 @@ void compute_frame_features(LPCNetEncState *st, const float *in, int arch) { /* [b,a]=ellip(2, 2, 20, 1200/8000); */ static const float lp_b[2] = {-0.84946f, 1.f}; static const float lp_a[2] = {-1.54220f, 0.70781f}; - OPUS_COPY(aligned_in, &st->analysis_mem[OVERLAP_SIZE-TRAINING_OFFSET], TRAINING_OFFSET); + OAC_COPY(aligned_in, &st->analysis_mem[OVERLAP_SIZE-TRAINING_OFFSET], TRAINING_OFFSET); frame_analysis(st, X, Ex, in); st->if_features[0] = MAX16(-1.f, MIN16(1.f, (1.f/64)*(10.f*celt_log10(1e-15f + X[0].r*X[0].r)-6.f))); for (i=1;iif_features[3*i-1] = prod.i; st->if_features[3*i] = MAX16(-1.f, MIN16(1.f, (1.f/64)*(10.f*celt_log10(1e-15f + X[i].r*X[i].r + X[i].i*X[i].i)-6.f))); } - OPUS_COPY(st->prev_if, X, PITCH_IF_MAX_FREQ); + OAC_COPY(st->prev_if, X, PITCH_IF_MAX_FREQ); /*for (i=0;i<88;i++) printf("%f ", st->if_features[i]);printf("\n");*/ logMax = -2; follow = -2; @@ -151,12 +151,12 @@ void compute_frame_features(LPCNetEncState *st, const float *in, int arch) { st->features[0] -= 4; lpc_from_cepstrum(st->lpc, st->features); for (i=0;ifeatures[NB_BANDS+2+i] = st->lpc[i]; - OPUS_MOVE(st->exc_buf, &st->exc_buf[FRAME_SIZE], PITCH_MAX_PERIOD); - OPUS_MOVE(st->lp_buf, &st->lp_buf[FRAME_SIZE], PITCH_MAX_PERIOD); - OPUS_COPY(&aligned_in[TRAINING_OFFSET], in, FRAME_SIZE-TRAINING_OFFSET); - OPUS_COPY(&x[0], st->pitch_mem, LPC_ORDER); - OPUS_COPY(&x[LPC_ORDER], aligned_in, FRAME_SIZE); - OPUS_COPY(st->pitch_mem, &aligned_in[FRAME_SIZE-LPC_ORDER], LPC_ORDER); + OAC_MOVE(st->exc_buf, &st->exc_buf[FRAME_SIZE], PITCH_MAX_PERIOD); + OAC_MOVE(st->lp_buf, &st->lp_buf[FRAME_SIZE], PITCH_MAX_PERIOD); + OAC_COPY(&aligned_in[TRAINING_OFFSET], in, FRAME_SIZE-TRAINING_OFFSET); + OAC_COPY(&x[0], st->pitch_mem, LPC_ORDER); + OAC_COPY(&x[LPC_ORDER], aligned_in, FRAME_SIZE); + OAC_COPY(st->pitch_mem, &aligned_in[FRAME_SIZE-LPC_ORDER], LPC_ORDER); celt_fir(&x[LPC_ORDER], st->lpc, &st->lp_buf[PITCH_MAX_PERIOD], FRAME_SIZE, LPC_ORDER, arch); for (i=0;iexc_buf[PITCH_MAX_PERIOD+i] = st->lp_buf[PITCH_MAX_PERIOD+i] + .7f*st->pitch_filt; @@ -209,11 +209,11 @@ void preemphasis(float *y, float *mem, const float *x, float coef, int N) { static int lpcnet_compute_single_frame_features_impl(LPCNetEncState *st, float *x, float features[NB_TOTAL_FEATURES], int arch) { preemphasis(x, &st->mem_preemph, x, PREEMPHASIS, FRAME_SIZE); compute_frame_features(st, x, arch); - OPUS_COPY(features, &st->features[0], NB_TOTAL_FEATURES); + OAC_COPY(features, &st->features[0], NB_TOTAL_FEATURES); return 0; } -int lpcnet_compute_single_frame_features(LPCNetEncState *st, const opus_int16 *pcm, float features[NB_TOTAL_FEATURES], int arch) { +int lpcnet_compute_single_frame_features(LPCNetEncState *st, const oac_int16 *pcm, float features[NB_TOTAL_FEATURES], int arch) { int i; float x[FRAME_SIZE]; for (i=0;iLPCNET_PLC_RESET_START, + OAC_CLEAR((char*)&st->LPCNET_PLC_RESET_START, sizeof(LPCNetPLCState)- ((char*)&st->LPCNET_PLC_RESET_START - (char*)st)); lpcnet_encoder_init(&st->enc); - OPUS_CLEAR(st->pcm, PLC_BUF_SIZE); + OAC_CLEAR(st->pcm, PLC_BUF_SIZE); st->blend = 0; st->loss_count = 0; st->analysis_gap = 1; @@ -57,7 +57,7 @@ void lpcnet_plc_reset(LPCNetPLCState *st) { int lpcnet_plc_init(LPCNetPLCState *st) { int ret; - st->arch = opus_select_arch(); + st->arch = oac_select_arch(); fargan_init(&st->fargan); lpcnet_encoder_init(&st->enc); st->loaded = 0; @@ -77,7 +77,7 @@ int lpcnet_plc_load_model(LPCNetPLCState *st, const void *data, int len) { int ret; parse_weights(&list, data, len); ret = init_plcmodel(&st->model, list); - opus_free(list); + oac_free(list); if (ret == 0) { ret = lpcnet_encoder_load_model(&st->enc, data, len); } @@ -94,7 +94,7 @@ void lpcnet_plc_fec_add(LPCNetPLCState *st, const float *features) { return; } celt_assert(st->fec_fill_pos < PLC_MAX_FEC); - OPUS_COPY(&st->fec[st->fec_fill_pos][0], features, NB_FEATURES); + OAC_COPY(&st->fec[st->fec_fill_pos][0], features, NB_FEATURES); st->fec_fill_pos++; } @@ -118,10 +118,10 @@ static int get_fec_or_pred(LPCNetPLCState *st, float *out) { if (st->fec_read_pos != st->fec_fill_pos && st->fec_skip==0) { float plc_features[2*NB_BANDS+NB_FEATURES+1] = {0}; float discard[NB_FEATURES]; - OPUS_COPY(out, &st->fec[st->fec_read_pos][0], NB_FEATURES); + OAC_COPY(out, &st->fec[st->fec_read_pos][0], NB_FEATURES); st->fec_read_pos++; /* Update PLC state using FEC, so without Burg features. */ - OPUS_COPY(&plc_features[2*NB_BANDS], out, NB_FEATURES); + OAC_COPY(&plc_features[2*NB_BANDS], out, NB_FEATURES); plc_features[2*NB_BANDS+NB_FEATURES] = -1; compute_plc_pred(st, discard, plc_features); return 1; @@ -134,19 +134,19 @@ static int get_fec_or_pred(LPCNetPLCState *st, float *out) { } static void queue_features(LPCNetPLCState *st, const float *features) { - OPUS_MOVE(&st->cont_features[0], &st->cont_features[NB_FEATURES], (CONT_VECTORS-1)*NB_FEATURES); - OPUS_COPY(&st->cont_features[(CONT_VECTORS-1)*NB_FEATURES], features, NB_FEATURES); + OAC_MOVE(&st->cont_features[0], &st->cont_features[NB_FEATURES], (CONT_VECTORS-1)*NB_FEATURES); + OAC_COPY(&st->cont_features[(CONT_VECTORS-1)*NB_FEATURES], features, NB_FEATURES); } /* In this causal version of the code, the DNN model implemented by compute_plc_pred() needs to generate two feature vectors to conceal the first lost packet.*/ -int lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm) { +int lpcnet_plc_update(LPCNetPLCState *st, oac_int16 *pcm) { int i; if (st->analysis_pos - FRAME_SIZE >= 0) st->analysis_pos -= FRAME_SIZE; else st->analysis_gap = 1; if (st->predict_pos - FRAME_SIZE >= 0) st->predict_pos -= FRAME_SIZE; - OPUS_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE-FRAME_SIZE); + OAC_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE-FRAME_SIZE); for (i=0;ipcm[PLC_BUF_SIZE-FRAME_SIZE+i] = (1.f/32768.f)*pcm[i]; st->loss_count = 0; st->blend = 0; @@ -154,7 +154,7 @@ int lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm) { } static const float att_table[10] = {0, 0, -.2, -.2, -.4, -.4, -.8, -.8, -1.6, -1.6}; -int lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm) { +int lpcnet_plc_conceal(LPCNetPLCState *st, oac_int16 *pcm) { int i; celt_assert(st->loaded); if (st->blend == 0) { @@ -169,7 +169,7 @@ int lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm) { lpcnet_compute_single_frame_features_float(&st->enc, x, st->features, st->arch); if ((!st->analysis_gap || count>0) && st->analysis_pos >= st->predict_pos) { queue_features(st, st->features); - OPUS_COPY(&plc_features[2*NB_BANDS], st->features, NB_FEATURES); + OAC_COPY(&plc_features[2*NB_BANDS], st->features, NB_FEATURES); plc_features[2*NB_BANDS+NB_FEATURES] = 1; st->plc_bak[0] = st->plc_bak[1]; st->plc_bak[1] = st->plc_net; @@ -200,7 +200,7 @@ int lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm) { if (st->analysis_pos - FRAME_SIZE >= 0) st->analysis_pos -= FRAME_SIZE; else st->analysis_gap = 1; st->predict_pos = PLC_BUF_SIZE; - OPUS_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE-FRAME_SIZE); + OAC_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE-FRAME_SIZE); for (i=0;ipcm[PLC_BUF_SIZE-FRAME_SIZE+i] = (1.f/32768.f)*pcm[i]; st->blend = 1; return 0; diff --git a/dnn/lpcnet_private.h b/dnn/lpcnet_private.h index 69ba12bd0..904162e9c 100644 --- a/dnn/lpcnet_private.h +++ b/dnn/lpcnet_private.h @@ -81,9 +81,9 @@ void run_frame_network_deferred(LPCNetState *lpcnet, const float *features); void run_frame_network_flush(LPCNetState *lpcnet); -void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, opus_int16 *output, int N, int preload); -void lpcnet_synthesize_impl(LPCNetState *lpcnet, const float *features, opus_int16 *output, int N, int preload); -void lpcnet_synthesize_blend_impl(LPCNetState *lpcnet, const opus_int16 *pcm_in, opus_int16 *output, int N); +void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, oac_int16 *output, int N, int preload); +void lpcnet_synthesize_impl(LPCNetState *lpcnet, const float *features, oac_int16 *output, int N, int preload); +void lpcnet_synthesize_blend_impl(LPCNetState *lpcnet, const oac_int16 *pcm_in, oac_int16 *output, int N); void run_frame_network(LPCNetState *lpcnet, float *gru_a_condition, float *gru_b_condition, float *lpc, const float *features); diff --git a/dnn/lpcnet_tables.c b/dnn/lpcnet_tables.c index 71ab37834..32b08a975 100644 --- a/dnn/lpcnet_tables.c +++ b/dnn/lpcnet_tables.c @@ -8,7 +8,7 @@ static const arch_fft_state arch_fft = {0, NULL}; -static const opus_int16 fft_bitrev[320] = { +static const oac_int16 fft_bitrev[320] = { 0, 64, 128, 192, 256, 16, 80, 144, 208, 272, 32, 96, 160, 224, 288, 48, 112, 176, 240, 304, 4, 68, 132, 196, 260, 20, 84, 148, 212, 276, 36, 100, 164, 228, 292, 52, 116, 180, 244, 308, 8, 72, 136, 200, 264, diff --git a/dnn/meson.build b/dnn/meson.build index 7b324016c..af89db3d6 100644 --- a/dnn/meson.build +++ b/dnn/meson.build @@ -17,15 +17,15 @@ dnn_sources_avx2 = sources['DNN_SOURCES_AVX2'] dnn_sources_neon_intr = sources['DNN_SOURCES_NEON'] dnn_sources_dotprod_intr = sources['DNN_SOURCES_DOTPROD'] -dnn_includes = [opus_includes] +dnn_includes = [oac_includes] dnn_static_libs = [] -if host_cpu_family in ['x86', 'x86_64'] and opus_conf.has('OPUS_HAVE_RTCD') +if host_cpu_family in ['x86', 'x86_64'] and oac_conf.has('OAC_HAVE_RTCD') dnn_sources += sources['DNN_SOURCES_X86_RTCD'] endif if host_cpu_family in ['arm', 'aarch64'] and have_arm_intrinsics_or_asm - if opus_conf.has('OPUS_HAVE_RTCD') + if oac_conf.has('OAC_HAVE_RTCD') dnn_sources += sources['DNN_SOURCES_ARM_RTCD'] endif endif @@ -38,7 +38,7 @@ foreach intr_name : ['sse2', 'sse4_1', 'avx2', 'neon_intr', 'dotprod_intr'] intr_sources = get_variable('dnn_sources_' + intr_name) - intr_args = get_variable('opus_@0@_args'.format(intr_name), []) + intr_args = get_variable('oac_@0@_args'.format(intr_name), []) dnn_static_libs += static_library('dnn_' + intr_name, intr_sources, c_args: intr_args, include_directories: dnn_includes, @@ -52,7 +52,7 @@ endif if opt_deep_plc.enabled() - dnn_lib = static_library('opus-dnn', + dnn_lib = static_library('oac-dnn', dnn_sources, c_args: dnn_c_args, include_directories: dnn_includes, diff --git a/dnn/nndsp.c b/dnn/nndsp.c index 9d1d2765b..86a711959 100644 --- a/dnn/nndsp.c +++ b/dnn/nndsp.c @@ -47,17 +47,17 @@ void init_adaconv_state(AdaConvState *hAdaConv) { - OPUS_CLEAR(hAdaConv, 1); + OAC_CLEAR(hAdaConv, 1); } void init_adacomb_state(AdaCombState *hAdaComb) { - OPUS_CLEAR(hAdaComb, 1); + OAC_CLEAR(hAdaComb, 1); } void init_adashape_state(AdaShapeState *hAdaShape) { - OPUS_CLEAR(hAdaShape, 1); + OAC_CLEAR(hAdaShape, 1); } void compute_overlap_window(float *window, int overlap_size) @@ -168,9 +168,9 @@ void adaconv_process_frame( celt_assert(left_padding == kernel_size - 1); /* currently only supports causal version. Non-causal version not difficult to implement but will require third loop */ celt_assert(kernel_size < frame_size); - OPUS_CLEAR(output_buffer, ADACONV_MAX_FRAME_SIZE * ADACONV_MAX_OUTPUT_CHANNELS); - OPUS_CLEAR(kernel_buffer, ADACONV_MAX_KERNEL_SIZE * ADACONV_MAX_INPUT_CHANNELS * ADACONV_MAX_OUTPUT_CHANNELS); - OPUS_CLEAR(input_buffer, ADACONV_MAX_INPUT_CHANNELS * (ADACONV_MAX_FRAME_SIZE + ADACONV_MAX_KERNEL_SIZE)); + OAC_CLEAR(output_buffer, ADACONV_MAX_FRAME_SIZE * ADACONV_MAX_OUTPUT_CHANNELS); + OAC_CLEAR(kernel_buffer, ADACONV_MAX_KERNEL_SIZE * ADACONV_MAX_INPUT_CHANNELS * ADACONV_MAX_OUTPUT_CHANNELS); + OAC_CLEAR(input_buffer, ADACONV_MAX_INPUT_CHANNELS * (ADACONV_MAX_FRAME_SIZE + ADACONV_MAX_KERNEL_SIZE)); #ifdef DEBUG_NNDSP print_float_vector("x_in", x_in, in_channels * frame_size); @@ -179,8 +179,8 @@ void adaconv_process_frame( /* prepare input */ for (i_in_channels=0; i_in_channels < in_channels; i_in_channels ++) { - OPUS_COPY(input_buffer + i_in_channels * (kernel_size + frame_size), hAdaConv->history + i_in_channels * kernel_size, kernel_size); - OPUS_COPY(input_buffer + kernel_size + i_in_channels * (kernel_size + frame_size), x_in + frame_size * i_in_channels, frame_size); + OAC_COPY(input_buffer + i_in_channels * (kernel_size + frame_size), hAdaConv->history + i_in_channels * kernel_size, kernel_size); + OAC_COPY(input_buffer + kernel_size + i_in_channels * (kernel_size + frame_size), x_in + frame_size * i_in_channels, frame_size); } p_input = input_buffer + kernel_size; @@ -207,11 +207,11 @@ void adaconv_process_frame( { for (i_in_channels = 0; i_in_channels < in_channels; i_in_channels++) { - OPUS_CLEAR(kernel0, ADACONV_MAX_KERNEL_SIZE); - OPUS_CLEAR(kernel1, ADACONV_MAX_KERNEL_SIZE); + OAC_CLEAR(kernel0, ADACONV_MAX_KERNEL_SIZE); + OAC_CLEAR(kernel1, ADACONV_MAX_KERNEL_SIZE); - OPUS_COPY(kernel0, hAdaConv->last_kernel + KERNEL_INDEX(i_out_channels, i_in_channels, 0), kernel_size); - OPUS_COPY(kernel1, kernel_buffer + KERNEL_INDEX(i_out_channels, i_in_channels, 0), kernel_size); + OAC_COPY(kernel0, hAdaConv->last_kernel + KERNEL_INDEX(i_out_channels, i_in_channels, 0), kernel_size); + OAC_COPY(kernel1, kernel_buffer + KERNEL_INDEX(i_out_channels, i_in_channels, 0), kernel_size); celt_pitch_xcorr(kernel0, p_input + i_in_channels * (frame_size + kernel_size) - left_padding, channel_buffer0, ADACONV_MAX_KERNEL_SIZE, overlap_size, arch); celt_pitch_xcorr(kernel1, p_input + i_in_channels * (frame_size + kernel_size) - left_padding, channel_buffer1, ADACONV_MAX_KERNEL_SIZE, frame_size, arch); for (i_sample = 0; i_sample < overlap_size; i_sample++) @@ -226,7 +226,7 @@ void adaconv_process_frame( } } - OPUS_COPY(x_out, output_buffer, out_channels * frame_size); + OAC_COPY(x_out, output_buffer, out_channels * frame_size); #ifdef DEBUG_NNDSP print_float_vector("x_out", x_out, out_channels * frame_size); @@ -235,9 +235,9 @@ void adaconv_process_frame( /* buffer update */ for (i_in_channels=0; i_in_channels < in_channels; i_in_channels ++) { - OPUS_COPY(hAdaConv->history + i_in_channels * kernel_size, p_input + i_in_channels * (frame_size + kernel_size) + frame_size - kernel_size, kernel_size); + OAC_COPY(hAdaConv->history + i_in_channels * kernel_size, p_input + i_in_channels * (frame_size + kernel_size) + frame_size - kernel_size, kernel_size); } - OPUS_COPY(hAdaConv->last_kernel, kernel_buffer, kernel_size * in_channels * out_channels); + OAC_COPY(hAdaConv->last_kernel, kernel_buffer, kernel_size * in_channels * out_channels); } void adacomb_process_frame( @@ -273,12 +273,12 @@ void adacomb_process_frame( (void) feature_dim; /* ToDo: figure out whether we might need this information */ - OPUS_CLEAR(output_buffer, ADACOMB_MAX_FRAME_SIZE); - OPUS_CLEAR(kernel_buffer, ADACOMB_MAX_KERNEL_SIZE); - OPUS_CLEAR(input_buffer, ADACOMB_MAX_FRAME_SIZE + ADACOMB_MAX_LAG + ADACOMB_MAX_KERNEL_SIZE); + OAC_CLEAR(output_buffer, ADACOMB_MAX_FRAME_SIZE); + OAC_CLEAR(kernel_buffer, ADACOMB_MAX_KERNEL_SIZE); + OAC_CLEAR(input_buffer, ADACOMB_MAX_FRAME_SIZE + ADACOMB_MAX_LAG + ADACOMB_MAX_KERNEL_SIZE); - OPUS_COPY(input_buffer, hAdaComb->history, kernel_size + ADACOMB_MAX_LAG); - OPUS_COPY(input_buffer + kernel_size + ADACOMB_MAX_LAG, x_in, frame_size); + OAC_COPY(input_buffer, hAdaComb->history, kernel_size + ADACOMB_MAX_LAG); + OAC_COPY(input_buffer + kernel_size + ADACOMB_MAX_LAG, x_in, frame_size); p_input = input_buffer + kernel_size + ADACOMB_MAX_LAG; /* calculate new kernel and new gain */ @@ -300,10 +300,10 @@ void adacomb_process_frame( print_float_vector("adacomb_gain", &gain, 1); #endif - OPUS_CLEAR(kernel, ADACOMB_MAX_KERNEL_SIZE); - OPUS_CLEAR(last_kernel, ADACOMB_MAX_KERNEL_SIZE); - OPUS_COPY(kernel, kernel_buffer, kernel_size); - OPUS_COPY(last_kernel, hAdaComb->last_kernel, kernel_size); + OAC_CLEAR(kernel, ADACOMB_MAX_KERNEL_SIZE); + OAC_CLEAR(last_kernel, ADACOMB_MAX_KERNEL_SIZE); + OAC_COPY(kernel, kernel_buffer, kernel_size); + OAC_COPY(last_kernel, hAdaComb->last_kernel, kernel_size); celt_pitch_xcorr(last_kernel, &p_input[- left_padding - hAdaComb->last_pitch_lag], output_buffer_last, ADACOMB_MAX_KERNEL_SIZE, overlap_size, arch); @@ -322,15 +322,15 @@ void adacomb_process_frame( { output_buffer[i_sample] = global_gain * (output_buffer[i_sample] + p_input[i_sample]); } - OPUS_COPY(x_out, output_buffer, frame_size); + OAC_COPY(x_out, output_buffer, frame_size); #ifdef DEBUG_NNDSP print_float_vector("x_out", x_out, frame_size); #endif /* buffer update */ - OPUS_COPY(hAdaComb->last_kernel, kernel_buffer, kernel_size); - OPUS_COPY(hAdaComb->history, p_input + frame_size - kernel_size - ADACOMB_MAX_LAG, kernel_size + ADACOMB_MAX_LAG); + OAC_COPY(hAdaComb->last_kernel, kernel_buffer, kernel_size); + OAC_COPY(hAdaComb->history, p_input + frame_size - kernel_size - ADACOMB_MAX_LAG, kernel_size + ADACOMB_MAX_LAG); hAdaComb->last_pitch_lag = pitch_lag; hAdaComb->last_global_gain = global_gain; } @@ -367,9 +367,9 @@ void adashape_process_frame( tenv_size = frame_size / avg_pool_k; tenv = in_buffer + feature_dim; - OPUS_CLEAR(tenv, tenv_size + 1); + OAC_CLEAR(tenv, tenv_size + 1); - OPUS_COPY(in_buffer, features, feature_dim); + OAC_COPY(in_buffer, features, feature_dim); /* calculate temporal envelope */ mean = 0; diff --git a/dnn/nndsp.h b/dnn/nndsp.h index 1bce70d10..6bb85a4c3 100644 --- a/dnn/nndsp.h +++ b/dnn/nndsp.h @@ -28,7 +28,7 @@ #ifndef NNDSP_H #define NNDSP_H -#include "opus_types.h" +#include "oac_types.h" #include "nnet.h" #include diff --git a/dnn/nnet.c b/dnn/nnet.c index eab08d219..88f8a0369 100644 --- a/dnn/nnet.c +++ b/dnn/nnet.c @@ -32,7 +32,7 @@ #include #include -#include "opus_types.h" +#include "oac_types.h" #include "arch.h" #include "nnet.h" #include "dred_rdovae_constants.h" @@ -126,11 +126,11 @@ void compute_generic_conv1d(const LinearLayer *layer, float *output, float *mem, float tmp[MAX_CONV_INPUTS_ALL]; celt_assert(input != output); celt_assert(layer->nb_inputs <= MAX_CONV_INPUTS_ALL); - if (layer->nb_inputs!=input_size) OPUS_COPY(tmp, mem, layer->nb_inputs-input_size); - OPUS_COPY(&tmp[layer->nb_inputs-input_size], input, input_size); + if (layer->nb_inputs!=input_size) OAC_COPY(tmp, mem, layer->nb_inputs-input_size); + OAC_COPY(&tmp[layer->nb_inputs-input_size], input, input_size); compute_linear(layer, output, tmp, arch); compute_activation(output, output, layer->nb_outputs, activation, arch); - if (layer->nb_inputs!=input_size) OPUS_COPY(mem, &tmp[input_size], layer->nb_inputs-input_size); + if (layer->nb_inputs!=input_size) OAC_COPY(mem, &tmp[input_size], layer->nb_inputs-input_size); } void compute_generic_conv1d_dilation(const LinearLayer *layer, float *output, float *mem, const float *input, int input_size, int dilation, int activation, int arch) @@ -140,14 +140,14 @@ void compute_generic_conv1d_dilation(const LinearLayer *layer, float *output, fl int i; celt_assert(input != output); celt_assert(layer->nb_inputs <= MAX_CONV_INPUTS_ALL); - if (dilation==1) OPUS_COPY(tmp, mem, layer->nb_inputs-input_size); - else for (i=0;inb_inputs-input_size], input, input_size); + if (dilation==1) OAC_COPY(tmp, mem, layer->nb_inputs-input_size); + else for (i=0;inb_inputs-input_size], input, input_size); compute_linear(layer, output, tmp, arch); compute_activation(output, output, layer->nb_outputs, activation, arch); - if (dilation==1) OPUS_COPY(mem, &tmp[input_size], layer->nb_inputs-input_size); + if (dilation==1) OAC_COPY(mem, &tmp[input_size], layer->nb_inputs-input_size); else { - OPUS_COPY(mem, &mem[input_size], input_size*dilation*(ksize-1)-input_size); - OPUS_COPY(&mem[input_size*dilation*(ksize-1)-input_size], input, input_size); + OAC_COPY(mem, &mem[input_size], input_size*dilation*(ksize-1)-input_size); + OAC_COPY(&mem[input_size*dilation*(ksize-1)-input_size], input, input_size); } } diff --git a/dnn/nnet.h b/dnn/nnet.h index 8a44170b1..680871b90 100644 --- a/dnn/nnet.h +++ b/dnn/nnet.h @@ -29,7 +29,7 @@ #define NNET_H_ #include -#include "opus_types.h" +#include "oac_types.h" #define ACTIVATION_LINEAR 0 #define ACTIVATION_SIGMOID 1 @@ -66,7 +66,7 @@ typedef struct { typedef struct { const float *bias; const float *subias; - const opus_int8 *weights; + const oac_int8 *weights; const float *float_weights; const int *weights_idx; const float *diag; @@ -134,11 +134,11 @@ void compute_activation_c(float *output, const float *input, int N, int activati void compute_conv2d_c(const Conv2dLayer *conv, float *out, float *mem, const float *in, int height, int hstride, int activation); -#if defined(OPUS_ARM_MAY_HAVE_DOTPROD) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +#if defined(OAC_ARM_MAY_HAVE_DOTPROD) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) #include "arm/dnn_arm.h" #endif -#if defined(OPUS_X86_MAY_HAVE_SSE2) +#if defined(OAC_X86_MAY_HAVE_SSE2) #include "x86/dnn_x86.h" #endif @@ -154,7 +154,7 @@ void compute_conv2d_c(const Conv2dLayer *conv, float *out, float *mem, const flo #define compute_conv2d(conv, out, mem, in, height, hstride, activation, arch) ((void)(arch),compute_conv2d_c(conv, out, mem, in, height, hstride, activation)) #endif -#if defined(__x86_64__) && !defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_MAY_HAVE_AVX2) &&!defined(SUPPRESS_PERF_WARNINGS) +#if defined(__x86_64__) && !defined(OAC_X86_MAY_HAVE_SSE4_1) && !defined(OAC_X86_MAY_HAVE_AVX2) &&!defined(SUPPRESS_PERF_WARNINGS) #if defined(_MSC_VER) #pragma message ("Only SSE and SSE2 are available. On newer machines, enable SSSE3/AVX/AVX2 to get better performance") #else diff --git a/dnn/nnet_arch.h b/dnn/nnet_arch.h index a855250ad..a2a40c3b0 100644 --- a/dnn/nnet_arch.h +++ b/dnn/nnet_arch.h @@ -40,7 +40,7 @@ /* Force vectorization on for DNN code because some of the loops rely on compiler vectorization rather than explicitly using intrinsics. */ -#if OPUS_GNUC_PREREQ(5,1) +#if OAC_GNUC_PREREQ(5,1) #define GCC_POP_OPTIONS #pragma GCC push_options #pragma GCC optimize("tree-vectorize") @@ -49,7 +49,7 @@ #define MAX_ACTIVATIONS (4096) -static OPUS_INLINE void vec_swish(float *y, const float *x, int N) +static OAC_INLINE void vec_swish(float *y, const float *x, int N) { int i; float tmp[MAX_ACTIVATIONS]; @@ -59,7 +59,7 @@ static OPUS_INLINE void vec_swish(float *y, const float *x, int N) y[i] = x[i]*tmp[i]; } -static OPUS_INLINE float relu(float x) +static OAC_INLINE float relu(float x) { return x < 0 ? 0 : x; } @@ -94,7 +94,7 @@ void RTCD_SUF(compute_activation_)(float *output, const float *input, int N, int output[i] = relu(input[i]); } else if (activation == ACTIVATION_SOFTMAX) { #ifdef SOFTMAX_HACK - OPUS_COPY(output, input, N); + OAC_COPY(output, input, N); /*for (i=0;isubias; #endif } - else OPUS_CLEAR(out, N); + else OAC_CLEAR(out, N); if (bias != NULL) { for (i=0;iin_channels*(height+conv->kheight-1); celt_assert(conv->ktime*time_stride <= MAX_CONV2D_INPUTS); - OPUS_COPY(in_buf, mem, (conv->ktime-1)*time_stride); - OPUS_COPY(&in_buf[(conv->ktime-1)*time_stride], in, time_stride); - OPUS_COPY(mem, &in_buf[time_stride], (conv->ktime-1)*time_stride); + OAC_COPY(in_buf, mem, (conv->ktime-1)*time_stride); + OAC_COPY(&in_buf[(conv->ktime-1)*time_stride], in, time_stride); + OAC_COPY(mem, &in_buf[time_stride], (conv->ktime-1)*time_stride); bias = conv->bias; if (conv->kheight == 3 && conv->ktime == 3) conv2d_3x3_float(out, conv->float_weights, conv->in_channels, conv->out_channels, in_buf, height, hstride); diff --git a/dnn/osce.c b/dnn/osce.c index 5f2752cab..56a9a3adb 100644 --- a/dnn/osce.c +++ b/dnn/osce.c @@ -68,7 +68,7 @@ static void print_int_array(FILE *fid, const char *name, const int *array, int } } -static void print_int8_array(FILE *fid, const char *name, const opus_int8 *array, int n) +static void print_int8_array(FILE *fid, const char *name, const oac_int8 *array, int n) { int i; for (i = 0; i < n; i++) @@ -141,7 +141,7 @@ static void compute_lace_numbits_embedding(float *emb, float numbits, int dim, f static int init_lace(LACE *hLACE, const WeightArray *weights) { int ret = 0; - OPUS_CLEAR(hLACE, 1); + OAC_CLEAR(hLACE, 1); celt_assert(weights != NULL); ret = init_lacelayers(&hLACE->layers, weights); @@ -153,7 +153,7 @@ static int init_lace(LACE *hLACE, const WeightArray *weights) static void reset_lace_state(LACEState *state) { - OPUS_CLEAR(state, 1); + OAC_CLEAR(state, 1); init_adacomb_state(&state->cf1_state); init_adacomb_state(&state->cf2_state); @@ -183,9 +183,9 @@ static void lace_feature_net( /* scaling and dimensionality reduction */ for (i_subframe = 0; i_subframe < 4; i_subframe ++) { - OPUS_COPY(input_buffer, features + i_subframe * LACE_NUM_FEATURES, LACE_NUM_FEATURES); - OPUS_COPY(input_buffer + LACE_NUM_FEATURES, hLACE->layers.lace_pitch_embedding.float_weights + periods[i_subframe] * LACE_PITCH_EMBEDDING_DIM, LACE_PITCH_EMBEDDING_DIM); - OPUS_COPY(input_buffer + LACE_NUM_FEATURES + LACE_PITCH_EMBEDDING_DIM, numbits_embedded, 2 * LACE_NUMBITS_EMBEDDING_DIM); + OAC_COPY(input_buffer, features + i_subframe * LACE_NUM_FEATURES, LACE_NUM_FEATURES); + OAC_COPY(input_buffer + LACE_NUM_FEATURES, hLACE->layers.lace_pitch_embedding.float_weights + periods[i_subframe] * LACE_PITCH_EMBEDDING_DIM, LACE_PITCH_EMBEDDING_DIM); + OAC_COPY(input_buffer + LACE_NUM_FEATURES + LACE_PITCH_EMBEDDING_DIM, numbits_embedded, 2 * LACE_NUMBITS_EMBEDDING_DIM); compute_generic_conv1d( &hLACE->layers.lace_fnet_conv1, @@ -198,7 +198,7 @@ static void lace_feature_net( } /* subframe accumulation */ - OPUS_COPY(input_buffer, output_buffer, 4 * LACE_HIDDEN_FEATURE_DIM); + OAC_COPY(input_buffer, output_buffer, 4 * LACE_HIDDEN_FEATURE_DIM); compute_generic_conv1d( &hLACE->layers.lace_fnet_conv2, output_buffer, @@ -210,7 +210,7 @@ static void lace_feature_net( ); /* tconv upsampling */ - OPUS_COPY(input_buffer, output_buffer, 4 * LACE_COND_DIM); + OAC_COPY(input_buffer, output_buffer, 4 * LACE_COND_DIM); compute_generic_dense( &hLACE->layers.lace_fnet_tconv, output_buffer, @@ -220,7 +220,7 @@ static void lace_feature_net( ); /* GRU */ - OPUS_COPY(input_buffer, output_buffer, 4 * LACE_COND_DIM); + OAC_COPY(input_buffer, output_buffer, 4 * LACE_COND_DIM); for (i_subframe = 0; i_subframe < 4; i_subframe++) { compute_generic_gru( @@ -230,7 +230,7 @@ static void lace_feature_net( input_buffer + i_subframe * LACE_COND_DIM, arch ); - OPUS_COPY(output + i_subframe * LACE_COND_DIM, state->feature_net_gru_state, LACE_COND_DIM); + OAC_COPY(output + i_subframe * LACE_COND_DIM, state->feature_net_gru_state, LACE_COND_DIM); } } @@ -406,7 +406,7 @@ static void compute_nolace_numbits_embedding(float *emb, float numbits, int dim, static int init_nolace(NoLACE *hNoLACE, const WeightArray *weights) { int ret = 0; - OPUS_CLEAR(hNoLACE, 1); + OAC_CLEAR(hNoLACE, 1); celt_assert(weights != NULL); ret = init_nolacelayers(&hNoLACE->layers, weights); @@ -418,7 +418,7 @@ static int init_nolace(NoLACE *hNoLACE, const WeightArray *weights) static void reset_nolace_state(NoLACEState *state) { - OPUS_CLEAR(state, 1); + OAC_CLEAR(state, 1); init_adacomb_state(&state->cf1_state); init_adacomb_state(&state->cf2_state); @@ -454,9 +454,9 @@ static void nolace_feature_net( /* scaling and dimensionality reduction */ for (i_subframe = 0; i_subframe < 4; i_subframe ++) { - OPUS_COPY(input_buffer, features + i_subframe * NOLACE_NUM_FEATURES, NOLACE_NUM_FEATURES); - OPUS_COPY(input_buffer + NOLACE_NUM_FEATURES, hNoLACE->layers.nolace_pitch_embedding.float_weights + periods[i_subframe] * NOLACE_PITCH_EMBEDDING_DIM, NOLACE_PITCH_EMBEDDING_DIM); - OPUS_COPY(input_buffer + NOLACE_NUM_FEATURES + NOLACE_PITCH_EMBEDDING_DIM, numbits_embedded, 2 * NOLACE_NUMBITS_EMBEDDING_DIM); + OAC_COPY(input_buffer, features + i_subframe * NOLACE_NUM_FEATURES, NOLACE_NUM_FEATURES); + OAC_COPY(input_buffer + NOLACE_NUM_FEATURES, hNoLACE->layers.nolace_pitch_embedding.float_weights + periods[i_subframe] * NOLACE_PITCH_EMBEDDING_DIM, NOLACE_PITCH_EMBEDDING_DIM); + OAC_COPY(input_buffer + NOLACE_NUM_FEATURES + NOLACE_PITCH_EMBEDDING_DIM, numbits_embedded, 2 * NOLACE_NUMBITS_EMBEDDING_DIM); compute_generic_conv1d( &hNoLACE->layers.nolace_fnet_conv1, @@ -469,7 +469,7 @@ static void nolace_feature_net( } /* subframe accumulation */ - OPUS_COPY(input_buffer, output_buffer, 4 * NOLACE_HIDDEN_FEATURE_DIM); + OAC_COPY(input_buffer, output_buffer, 4 * NOLACE_HIDDEN_FEATURE_DIM); compute_generic_conv1d( &hNoLACE->layers.nolace_fnet_conv2, output_buffer, @@ -481,7 +481,7 @@ static void nolace_feature_net( ); /* tconv upsampling */ - OPUS_COPY(input_buffer, output_buffer, 4 * NOLACE_COND_DIM); + OAC_COPY(input_buffer, output_buffer, 4 * NOLACE_COND_DIM); compute_generic_dense( &hNoLACE->layers.nolace_fnet_tconv, output_buffer, @@ -491,7 +491,7 @@ static void nolace_feature_net( ); /* GRU */ - OPUS_COPY(input_buffer, output_buffer, 4 * NOLACE_COND_DIM); + OAC_COPY(input_buffer, output_buffer, 4 * NOLACE_COND_DIM); for (i_subframe = 0; i_subframe < 4; i_subframe++) { compute_generic_gru( @@ -501,7 +501,7 @@ static void nolace_feature_net( input_buffer + i_subframe * NOLACE_COND_DIM, arch ); - OPUS_COPY(output + i_subframe * NOLACE_COND_DIM, state->feature_net_gru_state, NOLACE_COND_DIM); + OAC_COPY(output + i_subframe * NOLACE_COND_DIM, state->feature_net_gru_state, NOLACE_COND_DIM); } } @@ -596,7 +596,7 @@ static void nolace_process_20ms_frame( } /* update feature buffer */ - OPUS_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); + OAC_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); #ifdef DEBUG_NOLACE fwrite(x_buffer1, sizeof(float), 4 * NOLACE_FRAME_SIZE, f_postcf1); @@ -637,7 +637,7 @@ static void nolace_process_20ms_frame( } /* update feature buffer */ - OPUS_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); + OAC_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); #ifdef DEBUG_NOLACE fwrite(x_buffer1, sizeof(float), 4 * NOLACE_FRAME_SIZE, f_postcf2); @@ -677,7 +677,7 @@ static void nolace_process_20ms_frame( } /* update feature buffer */ - OPUS_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); + OAC_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); #ifdef DEBUG_NOLACE fwrite(x_buffer2, sizeof(float), 4 * NOLACE_FRAME_SIZE * NOLACE_AF1_OUT_CHANNELS, f_postaf1); @@ -734,7 +734,7 @@ static void nolace_process_20ms_frame( } /* update feature buffer */ - OPUS_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); + OAC_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); #ifdef DEBUG_NOLACE fwrite(x_buffer1, sizeof(float), 4 * NOLACE_FRAME_SIZE * NOLACE_AF2_OUT_CHANNELS, f_postaf2); @@ -791,7 +791,7 @@ static void nolace_process_20ms_frame( } /* update feature buffer */ - OPUS_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); + OAC_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); /* third shape-mix round */ for (i_subframe = 0; i_subframe < 4; i_subframe++) @@ -899,7 +899,7 @@ static void bbwe_feature_net( fwrite(output_buffer + i_frame * BBWENET_FNET_CONV1_OUT_SIZE, sizeof(float), BBWENET_FNET_CONV1_OUT_SIZE, f_conv1); #endif } - OPUS_COPY(input_buffer, output_buffer, num_frames * BBWENET_FNET_CONV1_OUT_SIZE); + OAC_COPY(input_buffer, output_buffer, num_frames * BBWENET_FNET_CONV1_OUT_SIZE); /* second conv layer */ for (i_frame = 0; i_frame < num_frames; i_frame++) @@ -917,7 +917,7 @@ static void bbwe_feature_net( fwrite(output_buffer + i_frame * BBWENET_FNET_CONV2_OUT_SIZE, sizeof(float), BBWENET_FNET_CONV2_OUT_SIZE, f_conv2); #endif } - OPUS_COPY(input_buffer, output_buffer, num_frames * BBWENET_FNET_CONV2_OUT_SIZE); + OAC_COPY(input_buffer, output_buffer, num_frames * BBWENET_FNET_CONV2_OUT_SIZE); /* tconv upsampling*/ for (i_frame = 0; i_frame < num_frames; i_frame++) @@ -933,7 +933,7 @@ static void bbwe_feature_net( fwrite(output_buffer + i_frame * BBWENET_FNET_TCONV_OUT_CHANNELS * BBWENET_FNET_TCONV_STRIDE, sizeof(float), BBWENET_FNET_TCONV_OUT_CHANNELS * BBWENET_FNET_TCONV_STRIDE, f_tconv); #endif } - OPUS_COPY(input_buffer, output_buffer, num_frames * BBWENET_FNET_TCONV_OUT_CHANNELS * BBWENET_FNET_TCONV_STRIDE); + OAC_COPY(input_buffer, output_buffer, num_frames * BBWENET_FNET_TCONV_OUT_CHANNELS * BBWENET_FNET_TCONV_STRIDE); /* GRU */ celt_assert(BBWENET_FNET_TCONV_STRIDE == 2); @@ -949,7 +949,7 @@ static void bbwe_feature_net( #ifdef DEBUG_BBWENET fwrite(state->feature_net_gru_state, sizeof(float), BBWENET_FNET_GRU_STATE_SIZE, f_gru); #endif - OPUS_COPY(output + i_subframe * BBWENET_FNET_GRU_STATE_SIZE, state->feature_net_gru_state, BBWENET_FNET_GRU_STATE_SIZE); + OAC_COPY(output + i_subframe * BBWENET_FNET_GRU_STATE_SIZE, state->feature_net_gru_state, BBWENET_FNET_GRU_STATE_SIZE); } } @@ -1001,8 +1001,8 @@ static void interpol_3_2(resamp_state *state, float *x_out, const float *x_in, i celt_assert(num_samples < 8 * BBWENET_FRAME_SIZE16); celt_assert(num_samples % 2 == 0); - OPUS_COPY(buffer, state->interpol_buffer, DELAY_SAMPLES); - OPUS_COPY(buffer + DELAY_SAMPLES, x_in, num_samples); + OAC_COPY(buffer, state->interpol_buffer, DELAY_SAMPLES); + OAC_COPY(buffer + DELAY_SAMPLES, x_in, num_samples); for (i_sample = 0; i_sample < num_samples; i_sample+=2) { @@ -1035,7 +1035,7 @@ static void interpol_3_2(resamp_state *state, float *x_out, const float *x_in, i } /* copy last samples to buffer */ - OPUS_COPY(state->interpol_buffer, buffer + num_samples, DELAY_SAMPLES); + OAC_COPY(state->interpol_buffer, buffer + num_samples, DELAY_SAMPLES); } static void upsamp_2x(resamp_state *state, float *x_out, const float *x_in, int num_samples) @@ -1049,7 +1049,7 @@ static void upsamp_2x(resamp_state *state, float *x_out, const float *x_in, int celt_assert(num_samples > 1); celt_assert(num_samples < 4 * BBWENET_FRAME_SIZE16); - OPUS_COPY(buffer, x_in, num_samples); + OAC_COPY(buffer, x_in, num_samples); for (k = 0; k < num_samples; k++) { @@ -1349,7 +1349,7 @@ static void bbwenet_process_frames( static void reset_bbwenet_state(BBWENetState *state) { - OPUS_CLEAR(state, 1); + OAC_CLEAR(state, 1); init_adaconv_state(&state->af1_state); init_adaconv_state(&state->af2_state); @@ -1361,7 +1361,7 @@ static void reset_bbwenet_state(BBWENetState *state) static int init_bbwenet(BBWENet *hBBWENET, const WeightArray *weights) { int ret = 0; - OPUS_CLEAR(hBBWENET, 1); + OAC_CLEAR(hBBWENET, 1); celt_assert(weights != NULL); ret = init_bbwenetlayers(&hBBWENET->layers, weights); @@ -1382,7 +1382,7 @@ void osce_reset(silk_OSCE_struct *hOSCE, int method) { OSCEState *state = &hOSCE->state; - OPUS_CLEAR(&hOSCE->features, 1); + OAC_CLEAR(&hOSCE->features, 1); switch(method) { @@ -1410,7 +1410,7 @@ void osce_reset(silk_OSCE_struct *hOSCE, int method) void osce_bwe_reset(silk_OSCE_BWE_struct *hOSCEBWE) { int k; - OPUS_CLEAR(&hOSCEBWE->features, 1); + OAC_CLEAR(&hOSCEBWE->features, 1); #if 1 /* weird python initialization: Fix eventually! */ for (k = 0; k <= OSCE_BWE_MAX_INSTAFREQ_BIN; k ++) @@ -1478,9 +1478,9 @@ int osce_load_models(OSCEModel *model, const void *data, int len) void osce_bwe( OSCEModel *model, /* I OSCE model struct */ silk_OSCE_BWE_struct *psOSCEBWE, /* I/O OSCE BWE state */ - opus_int16 xq48[], /* O bandwidth-extended speech */ - opus_int16 xq16[], /* I Decoded speech */ - opus_int32 xq16_len, /* I Length of xq16 in samples */ + oac_int16 xq48[], /* O bandwidth-extended speech */ + oac_int16 xq16[], /* I Decoded speech */ + oac_int32 xq16_len, /* I Length of xq16 in samples */ int arch /* I Run-time architecture */ ) { @@ -1521,7 +1521,7 @@ void osce_bwe( #endif /* scale and delay output */ - OPUS_COPY(xq48, psOSCEBWE->state.bbwenet.outbut_buffer, OSCE_BWE_OUTPUT_DELAY); + OAC_COPY(xq48, psOSCEBWE->state.bbwenet.outbut_buffer, OSCE_BWE_OUTPUT_DELAY); for (i = 0; i < 3 * xq16_len - OSCE_BWE_OUTPUT_DELAY; i++) { float tmp = 32768.f * out_buffer[i]; @@ -1547,8 +1547,8 @@ void osce_enhance_frame( OSCEModel *model, /* I OSCE model struct */ silk_decoder_state *psDec, /* I/O Decoder state */ silk_decoder_control *psDecCtrl, /* I Decoder control */ - opus_int16 xq[], /* I/O Decoded speech */ - opus_int32 num_bits, /* I Size of SILK payload in bits */ + oac_int16 xq[], /* I/O Decoded speech */ + oac_int32 num_bits, /* I Size of SILK payload in bits */ int arch /* I Run-time architecture */ ) { @@ -1582,7 +1582,7 @@ void osce_enhance_frame( switch(method) { case OSCE_METHOD_NONE: - OPUS_COPY(out_buffer, in_buffer, 320); + OAC_COPY(out_buffer, in_buffer, 320); break; #ifndef DISABLE_LACE case OSCE_METHOD_LACE: @@ -1625,7 +1625,7 @@ void osce_enhance_frame( float tmp; int16_t itmp; float lpc_buffer[16] = {0}; - opus_int16 *A_Q12, *B_Q14; + oac_int16 *A_Q12, *B_Q14; (void) num_bits; (void) arch; @@ -1660,7 +1660,7 @@ void osce_enhance_frame( if (psDec->osce.features.reset > 1) { - OPUS_COPY(out_buffer, in_buffer, 320); + OAC_COPY(out_buffer, in_buffer, 320); psDec->osce.features.reset --; } else if (psDec->osce.features.reset) diff --git a/dnn/osce.h b/dnn/osce.h index 915e6ba23..3e05ec861 100644 --- a/dnn/osce.h +++ b/dnn/osce.h @@ -29,7 +29,7 @@ #define OSCE_H -#include "opus_types.h" +#include "oac_types.h" /*#include "osce_config.h"*/ #ifndef DISABLE_LACE #include "lace_data.h" @@ -80,8 +80,8 @@ void osce_enhance_frame( OSCEModel *model, /* I OSCE model struct */ silk_decoder_state *psDec, /* I/O Decoder state */ silk_decoder_control *psDecCtrl, /* I Decoder control */ - opus_int16 xq[], /* I/O Decoded speech */ - opus_int32 num_bits, /* I Size of SILK payload in bits */ + oac_int16 xq[], /* I/O Decoded speech */ + oac_int32 num_bits, /* I Size of SILK payload in bits */ int arch /* I Run-time architecture */ ); @@ -93,9 +93,9 @@ void osce_reset(silk_OSCE_struct *hOSCE, int method); void osce_bwe( OSCEModel *model, /* I OSCE model struct */ silk_OSCE_BWE_struct *psOSCEBWE, /* I/O OSCE BWE state */ - opus_int16 xq48[], /* O bandwidth-extended speech */ - opus_int16 xq16[], /* I Decoded speech */ - opus_int32 xq16_len, /* I Length of xq16 in samples */ + oac_int16 xq48[], /* O bandwidth-extended speech */ + oac_int16 xq16[], /* I Decoded speech */ + oac_int32 xq16_len, /* I Length of xq16 in samples */ int arch /* I Run-time architecture */ ); diff --git a/dnn/osce_features.c b/dnn/osce_features.c index 8e1fa1a73..ddaf7d2b7 100644 --- a/dnn/osce_features.c +++ b/dnn/osce_features.c @@ -226,7 +226,7 @@ static void mag_spec_320_onesided(float *out, float *in) } -static void calculate_log_spectrum_from_lpc(float *spec, opus_int16 *a_q12, int lpc_order) +static void calculate_log_spectrum_from_lpc(float *spec, oac_int16 *a_q12, int lpc_order) { float buffer[OSCE_SPEC_WINDOW_SIZE] = {0}; int i; @@ -371,8 +371,8 @@ void osce_calculate_features( float *features, /* O input features */ float *numbits, /* O numbits and smoothed numbits */ int *periods, /* O pitch lags on subframe basis */ - const opus_int16 xq[], /* I Decoded speech */ - opus_int32 num_bits /* I Size of SILK payload in bits */ + const oac_int16 xq[], /* I Decoded speech */ + oac_int32 num_bits /* I Size of SILK payload in bits */ ) { int num_subframes, num_samples; @@ -388,7 +388,7 @@ void osce_calculate_features( } #endif - /*OPUS_CLEAR(buffer, 1);*/ + /*OAC_CLEAR(buffer, 1);*/ memset(buffer, 0, sizeof(buffer)); num_subframes = psDec->nb_subfr; @@ -404,7 +404,7 @@ void osce_calculate_features( { buffer[OSCE_FEATURES_MAX_HISTORY + n] = (float) xq[n] / (1U<<15); } - OPUS_COPY(buffer, psFeatures->signal_history, OSCE_FEATURES_MAX_HISTORY); + OAC_COPY(buffer, psFeatures->signal_history, OSCE_FEATURES_MAX_HISTORY); for (k = 0; k < num_subframes; k++) { @@ -419,7 +419,7 @@ void osce_calculate_features( } else { - OPUS_COPY(pfeatures + OSCE_CLEAN_SPEC_START, pfeatures + OSCE_CLEAN_SPEC_START - OSCE_FEATURE_DIM, OSCE_CLEAN_SPEC_LENGTH); + OAC_COPY(pfeatures + OSCE_CLEAN_SPEC_START, pfeatures + OSCE_CLEAN_SPEC_START - OSCE_FEATURE_DIM, OSCE_CLEAN_SPEC_LENGTH); } /* noisy cepstrum from signal (update every other frame) */ @@ -429,7 +429,7 @@ void osce_calculate_features( } else { - OPUS_COPY(pfeatures + OSCE_NOISY_CEPSTRUM_START, pfeatures + OSCE_NOISY_CEPSTRUM_START - OSCE_FEATURE_DIM, OSCE_NOISY_CEPSTRUM_LENGTH); + OAC_COPY(pfeatures + OSCE_NOISY_CEPSTRUM_START, pfeatures + OSCE_NOISY_CEPSTRUM_START - OSCE_FEATURE_DIM, OSCE_NOISY_CEPSTRUM_LENGTH); } /* pitch hangover and zero value replacement */ @@ -454,7 +454,7 @@ void osce_calculate_features( } /* buffer update */ - OPUS_COPY(psFeatures->signal_history, &buffer[num_samples], OSCE_FEATURES_MAX_HISTORY); + OAC_COPY(psFeatures->signal_history, &buffer[num_samples], OSCE_FEATURES_MAX_HISTORY); } @@ -462,7 +462,7 @@ void osce_calculate_features( void osce_bwe_calculate_features( OSCEBWEFeatureState *psFeatures, /* I/O BWE feature state */ float *features, /* O input features */ - const opus_int16 xq[], /* I Decoded speech */ + const oac_int16 xq[], /* I Decoded speech */ int num_samples /* I number of input samples */ ) { @@ -481,20 +481,20 @@ void osce_bwe_calculate_features( for (frame = 0; frame < num_frames; frame++) { /* clear features */ - OPUS_CLEAR(features + frame * OSCE_BWE_FEATURE_DIM, OSCE_BWE_FEATURE_DIM); + OAC_CLEAR(features + frame * OSCE_BWE_FEATURE_DIM, OSCE_BWE_FEATURE_DIM); lmspec = features + frame * OSCE_BWE_FEATURE_DIM; instafreq = lmspec + OSCE_BWE_NUM_BANDS; - const opus_int16 *x = xq + frame * OSCE_BWE_HALF_WINDOW_SIZE; + const oac_int16 *x = xq + frame * OSCE_BWE_HALF_WINDOW_SIZE; - OPUS_COPY(buffer, psFeatures->signal_history, OSCE_BWE_HALF_WINDOW_SIZE); + OAC_COPY(buffer, psFeatures->signal_history, OSCE_BWE_HALF_WINDOW_SIZE); for (n = 0; n < OSCE_BWE_HALF_WINDOW_SIZE; n++) { buffer[n + OSCE_BWE_HALF_WINDOW_SIZE] = (float) x[n] / (1U<<15); } /* update signal history buffer */ - OPUS_COPY(psFeatures->signal_history, buffer + OSCE_BWE_HALF_WINDOW_SIZE, OSCE_BWE_HALF_WINDOW_SIZE); + OAC_COPY(psFeatures->signal_history, buffer + OSCE_BWE_HALF_WINDOW_SIZE, OSCE_BWE_HALF_WINDOW_SIZE); /* apply window */ for (n = 0; n < OSCE_BWE_WINDOW_SIZE; n ++) @@ -537,7 +537,7 @@ void osce_bwe_calculate_features( } /* update instafreq buffer */ - OPUS_COPY(psFeatures->last_spec, spec, 2 * OSCE_BWE_MAX_INSTAFREQ_BIN + 2); + OAC_COPY(psFeatures->last_spec, spec, 2 * OSCE_BWE_MAX_INSTAFREQ_BIN + 2); } } #endif /* ENABLE_OSCE_BWE */ @@ -554,7 +554,7 @@ void osce_cross_fade_10ms(float *x_enhanced, float *x_in, int length) } -void osce_bwe_cross_fade_10ms(opus_int16 *x_fadein, opus_int16 *x_fadeout, int length) +void osce_bwe_cross_fade_10ms(oac_int16 *x_fadein, oac_int16 *x_fadeout, int length) { int i; celt_assert(length >= 480); diff --git a/dnn/osce_features.h b/dnn/osce_features.h index ae276c99b..024db48c3 100644 --- a/dnn/osce_features.h +++ b/dnn/osce_features.h @@ -30,7 +30,7 @@ #include "structs.h" -#include "opus_types.h" +#include "oac_types.h" #define OSCE_NUMBITS_BUGFIX @@ -40,19 +40,19 @@ void osce_calculate_features( float *features, /* O input features */ float *numbits, /* O numbits and smoothed numbits */ int *periods, /* O pitch lags on subframe basis */ - const opus_int16 xq[], /* I Decoded speech */ - opus_int32 num_bits /* I Size of SILK payload in bits */ + const oac_int16 xq[], /* I Decoded speech */ + oac_int32 num_bits /* I Size of SILK payload in bits */ ); #ifdef ENABLE_OSCE_BWE void osce_bwe_calculate_features( OSCEBWEFeatureState *psFeatures, /* I/O BWE feature state */ float *features, /* O input features */ - const opus_int16 xq[], /* I Decoded speech */ + const oac_int16 xq[], /* I Decoded speech */ int num_samples /* I number of input samples */ ); #endif void osce_cross_fade_10ms(float *x_enhanced, float *x_in, int length); -void osce_bwe_cross_fade_10ms(opus_int16 *x_fadein, opus_int16* x_fadeout, int length); +void osce_bwe_cross_fade_10ms(oac_int16 *x_fadein, oac_int16* x_fadeout, int length); #endif diff --git a/dnn/osce_structs.h b/dnn/osce_structs.h index b44ee7723..a0ea23e0b 100644 --- a/dnn/osce_structs.h +++ b/dnn/osce_structs.h @@ -28,7 +28,7 @@ #ifndef OSCE_STRUCTS_H #define OSCE_STRUCTS_H -#include "opus_types.h" +#include "oac_types.h" #include "osce_config.h" #ifndef DISABLE_LACE #include "lace_data.h" @@ -70,7 +70,7 @@ typedef struct { float feature_net_conv1_state[BBWENET_FNET_CONV1_STATE_SIZE]; float feature_net_conv2_state[BBWENET_FNET_CONV2_STATE_SIZE]; float feature_net_gru_state[BBWENET_FNET_GRU_STATE_SIZE]; - opus_int16 outbut_buffer[OSCE_BWE_OUTPUT_DELAY]; + oac_int16 outbut_buffer[OSCE_BWE_OUTPUT_DELAY]; AdaConvState af1_state; AdaConvState af2_state; AdaConvState af3_state; diff --git a/dnn/parse_lpcnet_weights.c b/dnn/parse_lpcnet_weights.c index 1e6549680..287dd8dcc 100644 --- a/dnn/parse_lpcnet_weights.c +++ b/dnn/parse_lpcnet_weights.c @@ -56,7 +56,7 @@ int parse_weights(WeightArray **list, const void *data, int len) { int nb_arrays=0; int capacity=20; - *list = (WeightArray*)opus_alloc(capacity*sizeof(WeightArray)); + *list = (WeightArray*)oac_alloc(capacity*sizeof(WeightArray)); while (len > 0) { int ret; WeightArray array = {NULL, 0, 0, 0}; @@ -65,11 +65,11 @@ int parse_weights(WeightArray **list, const void *data, int len) if (nb_arrays+1 >= capacity) { /* Make sure there's room for the ending NULL element too. */ capacity = capacity*3/2; - *list = (WeightArray*)opus_realloc(*list, capacity*sizeof(WeightArray)); + *list = (WeightArray*)oac_realloc(*list, capacity*sizeof(WeightArray)); } (*list)[nb_arrays++] = array; } else { - opus_free(*list); + oac_free(*list); *list = NULL; return -1; } @@ -150,7 +150,7 @@ int linear_init(LinearLayer *layer, const WeightArray *arrays, int total_blocks; if ((layer->weights_idx = (const int*)find_idx_check(arrays, weights_idx, nb_inputs, nb_outputs, &total_blocks)) == NULL) return 1; if (weights != NULL) { - if ((layer->weights = (const opus_int8*)find_array_check(arrays, weights, SPARSE_BLOCK_SIZE*total_blocks*sizeof(layer->weights[0]))) == NULL) return 1; + if ((layer->weights = (const oac_int8*)find_array_check(arrays, weights, SPARSE_BLOCK_SIZE*total_blocks*sizeof(layer->weights[0]))) == NULL) return 1; } if (float_weights != NULL) { layer->float_weights = (const float*)opt_array_check(arrays, float_weights, SPARSE_BLOCK_SIZE*total_blocks*sizeof(layer->float_weights[0]), &err); @@ -158,7 +158,7 @@ int linear_init(LinearLayer *layer, const WeightArray *arrays, } } else { if (weights != NULL) { - if ((layer->weights = (const opus_int8*)find_array_check(arrays, weights, nb_inputs*nb_outputs*sizeof(layer->weights[0]))) == NULL) return 1; + if ((layer->weights = (const oac_int8*)find_array_check(arrays, weights, nb_inputs*nb_outputs*sizeof(layer->weights[0]))) == NULL) return 1; } if (float_weights != NULL) { layer->float_weights = (const float*)opt_array_check(arrays, float_weights, nb_inputs*nb_outputs*sizeof(layer->float_weights[0]), &err); @@ -230,7 +230,7 @@ int main() printf("found %s: size %d\n", list[i].name, list[i].size); } printf("%p\n", list[i].name); - opus_free(list); + oac_free(list); munmap(data, len); close(fd); return 0; diff --git a/dnn/pitchdnn.c b/dnn/pitchdnn.c index 5cf96e7f9..056e80aa4 100644 --- a/dnn/pitchdnn.c +++ b/dnn/pitchdnn.c @@ -32,7 +32,7 @@ float compute_pitchdnn( compute_generic_dense(&model->dense_if_upsampler_1, if1_out, if_features, ACTIVATION_TANH, arch); compute_generic_dense(&model->dense_if_upsampler_2, &downsampler_in[NB_XCORR_FEATURES], if1_out, ACTIVATION_TANH, arch); /* xcorr*/ - OPUS_COPY(&conv1_tmp1[1], xcorr_features, NB_XCORR_FEATURES); + OAC_COPY(&conv1_tmp1[1], xcorr_features, NB_XCORR_FEATURES); compute_conv2d(&model->conv2d_1, &conv1_tmp2[1], st->xcorr_mem1, conv1_tmp1, NB_XCORR_FEATURES, NB_XCORR_FEATURES+2, ACTIVATION_TANH, arch); compute_conv2d(&model->conv2d_2, downsampler_in, st->xcorr_mem2, conv1_tmp2, NB_XCORR_FEATURES, NB_XCORR_FEATURES, ACTIVATION_TANH, arch); @@ -59,7 +59,7 @@ float compute_pitchdnn( void pitchdnn_init(PitchDNNState *st) { int ret; - OPUS_CLEAR(st, 1); + OAC_CLEAR(st, 1); #ifndef USE_WEIGHTS_FILE ret = init_pitchdnn(&st->model, pitchdnn_arrays); #else @@ -73,7 +73,7 @@ int pitchdnn_load_model(PitchDNNState *st, const void *data, int len) { int ret; parse_weights(&list, data, len); ret = init_pitchdnn(&st->model, list); - opus_free(list); + oac_free(list); if (ret == 0) return 0; else return -1; } diff --git a/dnn/test_vec.c b/dnn/test_vec.c index d14d2502a..df8f1776b 100644 --- a/dnn/test_vec.c +++ b/dnn/test_vec.c @@ -1,6 +1,6 @@ #include #include -#include "opus_types.h" +#include "oac_types.h" #include "arch.h" #include "common.h" #include "tansig_table.h" diff --git a/dnn/torch/lossgen/export_lossgen.py b/dnn/torch/lossgen/export_lossgen.py index 15a65c36c..3ba0f282c 100644 --- a/dnn/torch/lossgen/export_lossgen.py +++ b/dnn/torch/lossgen/export_lossgen.py @@ -55,7 +55,7 @@ def c_export(args, model): writer = CWriter(os.path.join(args.output_dir, "lossgen_data"), message=message, model_struct_name='LossGen', enable_binary_blob=False, add_typedef=True) writer.header.write( f""" -#include "opus_types.h" +#include "oac_types.h" """ ) diff --git a/dnn/torch/neural-pitch/export_neuralpitch_weights.py b/dnn/torch/neural-pitch/export_neuralpitch_weights.py index 577ec882e..1c782e27d 100644 --- a/dnn/torch/neural-pitch/export_neuralpitch_weights.py +++ b/dnn/torch/neural-pitch/export_neuralpitch_weights.py @@ -55,7 +55,7 @@ def c_export(args, model): writer = CWriter(os.path.join(args.output_dir, "pitchdnn_data"), message=message, model_struct_name='PitchDNN') writer.header.write( f""" -#include "opus_types.h" +#include "oac_types.h" """ ) diff --git a/dnn/torch/osce/data/silk_conversion_set.py b/dnn/torch/osce/data/silk_conversion_set.py index 8f6467561..c13af3ded 100644 --- a/dnn/torch/osce/data/silk_conversion_set.py +++ b/dnn/torch/osce/data/silk_conversion_set.py @@ -45,7 +45,7 @@ def __init__(self, pitch_hangover=8, num_bands_clean_spec=64, num_bands_noisy_spec=18, - noisy_spec_scale='opus', + noisy_spec_scale='oac', noisy_apply_dct=True, add_offset=False, add_double_lag_acorr=False diff --git a/dnn/torch/osce/data/silk_enhancement_set.py b/dnn/torch/osce/data/silk_enhancement_set.py index fd18c4def..0af0f8c51 100644 --- a/dnn/torch/osce/data/silk_enhancement_set.py +++ b/dnn/torch/osce/data/silk_enhancement_set.py @@ -47,7 +47,7 @@ def __init__(self, pitch_hangover=8, num_bands_clean_spec=64, num_bands_noisy_spec=18, - noisy_spec_scale='opus', + noisy_spec_scale='oac', noisy_apply_dct=True, add_double_lag_acorr=False, ): diff --git a/dnn/torch/osce/stndrd/evaluation/evaluate.py b/dnn/torch/osce/stndrd/evaluation/evaluate.py index 54700dbe4..31a000622 100644 --- a/dnn/torch/osce/stndrd/evaluation/evaluate.py +++ b/dnn/torch/osce/stndrd/evaluation/evaluate.py @@ -64,25 +64,25 @@ def get_itemlist(folder): def process_item(folder, item, bitrate, metric): fs, x_clean = wavfile.read(os.path.join(folder, 'clean', f"{item}_{bitrate}_clean.wav")) - fs, x_opus = wavfile.read(os.path.join(folder, 'opus', f"{item}_{bitrate}_opus.wav")) + fs, x_oac = wavfile.read(os.path.join(folder, 'oac', f"{item}_{bitrate}_oac.wav")) fs, x_lace = wavfile.read(os.path.join(folder, 'lace', f"{item}_{bitrate}_lace.wav")) fs, x_nolace = wavfile.read(os.path.join(folder, 'nolace', f"{item}_{bitrate}_nolace.wav")) x_clean = x_clean.astype(np.float32) / 2**15 - x_opus = x_opus.astype(np.float32) / 2**15 + x_oac = x_oac.astype(np.float32) / 2**15 x_lace = x_lace.astype(np.float32) / 2**15 x_nolace = x_nolace.astype(np.float32) / 2**15 if metric == 'pesq': - result = [pesq(fs, x_clean, x_opus), pesq(fs, x_clean, x_lace), pesq(fs, x_clean, x_nolace)] + result = [pesq(fs, x_clean, x_oac), pesq(fs, x_clean, x_lace), pesq(fs, x_clean, x_nolace)] elif metric =='moc': - result = [compare(x_clean, x_opus), compare(x_clean, x_lace), compare(x_clean, x_nolace)] + result = [compare(x_clean, x_oac), compare(x_clean, x_lace), compare(x_clean, x_nolace)] elif metric =='moc2': - result = [compare2(x_clean, x_opus), compare2(x_clean, x_lace), compare2(x_clean, x_nolace)] + result = [compare2(x_clean, x_oac), compare2(x_clean, x_lace), compare2(x_clean, x_nolace)] # elif metric == 'warpq': - # result = [warpq(x_clean, x_opus), warpq(x_clean, x_lace), warpq(x_clean, x_nolace)] + # result = [warpq(x_clean, x_oac), warpq(x_clean, x_lace), warpq(x_clean, x_nolace)] elif metric == 'laceloss': - result = [laceloss_compare(x_clean, x_opus), laceloss_compare(x_clean, x_lace), laceloss_compare(x_clean, x_nolace)] + result = [laceloss_compare(x_clean, x_oac), laceloss_compare(x_clean, x_lace), laceloss_compare(x_clean, x_nolace)] else: raise ValueError(f'unknown metric {metric}') diff --git a/dnn/torch/osce/stndrd/evaluation/highband_eval.py b/dnn/torch/osce/stndrd/evaluation/highband_eval.py index eb9a0682e..d522f86ef 100644 --- a/dnn/torch/osce/stndrd/evaluation/highband_eval.py +++ b/dnn/torch/osce/stndrd/evaluation/highband_eval.py @@ -9,8 +9,8 @@ parser.add_argument('ref_wav', type=str, help='reference wav file') parser.add_argument('test_wav', type=str, help='test wav file') -opus_eband5ms = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 34, 40, 48, 60, 78, 100] -opus_eband10ms = [2 * b for b in opus_eband5ms] +oac_eband5ms = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 34, 40, 48, 60, 78, 100] +oac_eband10ms = [2 * b for b in oac_eband5ms] def create_filter_bank(band_limits, num_bins, normalize=False): filters = [] @@ -27,7 +27,7 @@ def create_filter_bank(band_limits, num_bins, normalize=False): fb = np.concatenate(filters, axis=0) return fb -fb = create_filter_bank(opus_eband10ms, 241) +fb = create_filter_bank(oac_eband10ms, 241) highband_idx = -4 func = lambda x : x ** 0.25 diff --git a/dnn/torch/osce/stndrd/evaluation/make_boxplots.py b/dnn/torch/osce/stndrd/evaluation/make_boxplots.py index f7ea778a8..88b00a96e 100644 --- a/dnn/torch/osce/stndrd/evaluation/make_boxplots.py +++ b/dnn/torch/osce/stndrd/evaluation/make_boxplots.py @@ -66,7 +66,7 @@ def load_data(folder): def plot_data(filename, data, title=None): compare_dict = dict() for br in data.keys(): - compare_dict[f'Opus {br/1000:.1f} kb/s'] = data[br][:, 0] + compare_dict[f'Oac {br/1000:.1f} kb/s'] = data[br][:, 0] compare_dict[f'LACE {br/1000:.1f} kb/s'] = data[br][:, 1] compare_dict[f'NoLACE {br/1000:.1f} kb/s'] = data[br][:, 2] @@ -80,7 +80,7 @@ def plot_data(filename, data, title=None): red = '#ff5745' blue = '#007dbc' colors = [black, red, blue] - legend_elements = [Patch(facecolor=colors[0], label='Opus SILK'), + legend_elements = [Patch(facecolor=colors[0], label='Oac SILK'), Patch(facecolor=colors[1], label='LACE'), Patch(facecolor=colors[2], label='NoLACE')] diff --git a/dnn/torch/osce/stndrd/evaluation/make_boxplots_moctest.py b/dnn/torch/osce/stndrd/evaluation/make_boxplots_moctest.py index ca65aba91..f1d347f09 100644 --- a/dnn/torch/osce/stndrd/evaluation/make_boxplots_moctest.py +++ b/dnn/torch/osce/stndrd/evaluation/make_boxplots_moctest.py @@ -63,7 +63,7 @@ def load_data(folder): def plot_data(filename, data, title=None): compare_dict = dict() for br in data.keys(): - compare_dict[f'Opus {br/1000:.1f} kb/s'] = data[br][:, 0] + compare_dict[f'Oac {br/1000:.1f} kb/s'] = data[br][:, 0] compare_dict[f'LACE (MOC only) {br/1000:.1f} kb/s'] = data[br][:, 1] compare_dict[f'LACE (MOC + TD) {br/1000:.1f} kb/s'] = data[br][:, 2] @@ -73,7 +73,7 @@ def plot_data(filename, data, title=None): "font.size": 32 }) colors = ['pink', 'lightblue', 'lightgreen'] - legend_elements = [Patch(facecolor=colors[0], label='Opus SILK'), + legend_elements = [Patch(facecolor=colors[0], label='Oac SILK'), Patch(facecolor=colors[1], label='MOC loss only'), Patch(facecolor=colors[2], label='MOC + TD loss')] diff --git a/dnn/torch/osce/stndrd/evaluation/make_tables.py b/dnn/torch/osce/stndrd/evaluation/make_tables.py index 560801276..dd080cc19 100644 --- a/dnn/torch/osce/stndrd/evaluation/make_tables.py +++ b/dnn/torch/osce/stndrd/evaluation/make_tables.py @@ -67,12 +67,12 @@ def make_table(filename, data, title=None): # mean values tbl = PrettyTable() - tbl.field_names = ['bitrate (bps)', 'Opus', 'LACE', 'NoLACE'] + tbl.field_names = ['bitrate (bps)', 'Oac', 'LACE', 'NoLACE'] for br in data.keys(): - opus = data[br][:, 0] + oac = data[br][:, 0] lace = data[br][:, 1] nolace = data[br][:, 2] - tbl.add_row([br, f"{float(opus.mean()):.3f} ({float(opus.std()):.2f})", f"{float(lace.mean()):.3f} ({float(lace.std()):.2f})", f"{float(nolace.mean()):.3f} ({float(nolace.std()):.2f})"]) + tbl.add_row([br, f"{float(oac.mean()):.3f} ({float(oac.std()):.2f})", f"{float(lace.mean()):.3f} ({float(lace.std()):.2f})", f"{float(nolace.mean()):.3f} ({float(nolace.std()):.2f})"]) with open(filename + ".txt", "w") as f: f.write(str(tbl)) @@ -90,11 +90,11 @@ def make_diff_table(filename, data, title=None): # mean values tbl = PrettyTable() - tbl.field_names = ['bitrate (bps)', 'LACE - Opus', 'NoLACE - Opus'] + tbl.field_names = ['bitrate (bps)', 'LACE - Oac', 'NoLACE - Oac'] for br in data.keys(): - opus = data[br][:, 0] - lace = data[br][:, 1] - opus - nolace = data[br][:, 2] - opus + oac = data[br][:, 0] + lace = data[br][:, 1] - oac + nolace = data[br][:, 2] - oac tbl.add_row([br, f"{float(lace.mean()):.3f} ({float(lace.std()):.2f})", f"{float(nolace.mean()):.3f} ({float(nolace.std()):.2f})"]) with open(filename + ".txt", "w") as f: diff --git a/dnn/torch/osce/stndrd/evaluation/make_tables_moctest.py b/dnn/torch/osce/stndrd/evaluation/make_tables_moctest.py index 37718068a..9872f013c 100644 --- a/dnn/torch/osce/stndrd/evaluation/make_tables_moctest.py +++ b/dnn/torch/osce/stndrd/evaluation/make_tables_moctest.py @@ -64,12 +64,12 @@ def make_table(filename, data, title=None): # mean values tbl = PrettyTable() - tbl.field_names = ['bitrate (bps)', 'Opus', 'LACE', 'NoLACE'] + tbl.field_names = ['bitrate (bps)', 'Oac', 'LACE', 'NoLACE'] for br in data.keys(): - opus = data[br][:, 0] + oac = data[br][:, 0] lace = data[br][:, 1] nolace = data[br][:, 2] - tbl.add_row([br, f"{float(opus.mean()):.3f} ({float(opus.std()):.2f})", f"{float(lace.mean()):.3f} ({float(lace.std()):.2f})", f"{float(nolace.mean()):.3f} ({float(nolace.std()):.2f})"]) + tbl.add_row([br, f"{float(oac.mean()):.3f} ({float(oac.std()):.2f})", f"{float(lace.mean()):.3f} ({float(lace.std()):.2f})", f"{float(nolace.mean()):.3f} ({float(nolace.std()):.2f})"]) with open(filename + ".txt", "w") as f: f.write(str(tbl)) @@ -87,11 +87,11 @@ def make_diff_table(filename, data, title=None): # mean values tbl = PrettyTable() - tbl.field_names = ['bitrate (bps)', 'LACE - Opus', 'NoLACE - Opus'] + tbl.field_names = ['bitrate (bps)', 'LACE - Oac', 'NoLACE - Oac'] for br in data.keys(): - opus = data[br][:, 0] - lace = data[br][:, 1] - opus - nolace = data[br][:, 2] - opus + oac = data[br][:, 0] + lace = data[br][:, 1] - oac + nolace = data[br][:, 2] - oac tbl.add_row([br, f"{float(lace.mean()):.3f} ({float(lace.std()):.2f})", f"{float(nolace.mean()):.3f} ({float(nolace.std()):.2f})"]) with open(filename + ".txt", "w") as f: diff --git a/dnn/torch/osce/stndrd/evaluation/moc.py b/dnn/torch/osce/stndrd/evaluation/moc.py index ebc07d07f..38440aeaf 100644 --- a/dnn/torch/osce/stndrd/evaluation/moc.py +++ b/dnn/torch/osce/stndrd/evaluation/moc.py @@ -98,7 +98,7 @@ def rect_fb(band_limits, num_bins=None): def compare(x, y, apply_vad=False): - """ Modified version of opus_compare for 16 kHz mono signals + """ Modified version of oac_compare for 16 kHz mono signals Args: x (np.ndarray): reference input signal scaled to [-1, 1] diff --git a/dnn/torch/osce/stndrd/evaluation/moc2.py b/dnn/torch/osce/stndrd/evaluation/moc2.py index 6726ab121..7710c038f 100644 --- a/dnn/torch/osce/stndrd/evaluation/moc2.py +++ b/dnn/torch/osce/stndrd/evaluation/moc2.py @@ -98,7 +98,7 @@ def rect_fb(band_limits, num_bins=None): def _compare(x, y, apply_vad=False, factor=1): - """ Modified version of opus_compare for 16 kHz mono signals + """ Modified version of oac_compare for 16 kHz mono signals Args: x (np.ndarray): reference input signal scaled to [-1, 1] diff --git a/dnn/torch/osce/stndrd/evaluation/run_nomad.py b/dnn/torch/osce/stndrd/evaluation/run_nomad.py index 0267bc925..dda10203f 100644 --- a/dnn/torch/osce/stndrd/evaluation/run_nomad.py +++ b/dnn/torch/osce/stndrd/evaluation/run_nomad.py @@ -97,18 +97,18 @@ def nomad_process_all(folder, full_reference=False, device=None): items = get_itemlist(folder) with tempfile.TemporaryDirectory() as dir: cleandir = os.path.join(dir, 'clean') - opusdir = os.path.join(dir, 'opus') + oacdir = os.path.join(dir, 'oac') lacedir = os.path.join(dir, 'lace') nolacedir = os.path.join(dir, 'nolace') # prepare files - for d in [cleandir, opusdir, lacedir, nolacedir]: os.makedirs(d) + for d in [cleandir, oacdir, lacedir, nolacedir]: os.makedirs(d) for br in bitrates: for item in items: - for cond in ['clean', 'opus', 'lace', 'nolace']: + for cond in ['clean', 'oac', 'lace', 'nolace']: shutil.copyfile(os.path.join(folder, cond, f"{item}_{br}_{cond}.wav"), os.path.join(dir, cond, f"{item}_{br}.wav")) - nomad_opus, ref_embeddings = nomad_wrapper(cleandir, opusdir, full_reference=full_reference, ref_embeddings=None) + nomad_oac, ref_embeddings = nomad_wrapper(cleandir, oacdir, full_reference=full_reference, ref_embeddings=None) nomad_lace, ref_embeddings = nomad_wrapper(cleandir, lacedir, full_reference=full_reference, ref_embeddings=ref_embeddings) nomad_nolace, ref_embeddings = nomad_wrapper(cleandir, nolacedir, full_reference=full_reference, ref_embeddings=ref_embeddings) @@ -117,7 +117,7 @@ def nomad_process_all(folder, full_reference=False, device=None): results[br] = np.zeros((len(items), 3)) for i, item in enumerate(items): key = f"{item}_{br}" - results[br][i, 0] = nomad_opus[key] + results[br][i, 0] = nomad_oac[key] results[br][i, 1] = nomad_lace[key] results[br][i, 2] = nomad_nolace[key] diff --git a/dnn/torch/osce/stndrd/evaluation/run_osce_test.py b/dnn/torch/osce/stndrd/evaluation/run_osce_test.py index 956d6d106..a6a337a17 100644 --- a/dnn/torch/osce/stndrd/evaluation/run_osce_test.py +++ b/dnn/torch/osce/stndrd/evaluation/run_osce_test.py @@ -14,17 +14,17 @@ parser.add_argument('inputdir', type=str, help='Input folder with test items') parser.add_argument('outputdir', type=str, help='Output folder') parser.add_argument('bitrate', type=int, help='bitrate to test') -parser.add_argument('--reference_opus_demo', type=str, default='./opus_demo', help='reference opus_demo binary for generating bitstreams and reference output') +parser.add_argument('--reference_oac_demo', type=str, default='./oac_demo', help='reference oac_demo binary for generating bitstreams and reference output') parser.add_argument('--encoder_options', type=str, default="", help='encoder options (e.g. -complexity 5)') -parser.add_argument('--test_opus_demo', type=str, default='./opus_demo', help='opus_demo binary under test') -parser.add_argument('--test_opus_demo_options', type=str, default='-dec_complexity 7', help='options for test opus_demo (e.g. "-dec_complexity 7")') +parser.add_argument('--test_oac_demo', type=str, default='./oac_demo', help='oac_demo binary under test') +parser.add_argument('--test_oac_demo_options', type=str, default='-dec_complexity 7', help='options for test oac_demo (e.g. "-dec_complexity 7")') parser.add_argument('--dec_fs', type=int, default=16000, help='decoder sampling frequency (default: 16000)') parser.add_argument('--verbose', type=int, default=0, help='verbosity level: 0 for quiet (default), 1 for reporting individual test results, 2 for reporting per-item scores in failed tests') -def run_opus_encoder(opus_demo_path, input_pcm_path, bitstream_path, application, fs, num_channels, bitrate, options=[], verbose=False): +def run_oac_encoder(oac_demo_path, input_pcm_path, bitstream_path, application, fs, num_channels, bitrate, options=[], verbose=False): call_args = [ - opus_demo_path, + oac_demo_path, "-e", application, str(fs), @@ -53,10 +53,10 @@ def run_opus_encoder(opus_demo_path, input_pcm_path, bitstream_path, application return 0 -def run_opus_decoder(opus_demo_path, bitstream_path, output_pcm_path, fs, num_channels, options=[], verbose=False): +def run_oac_decoder(oac_demo_path, bitstream_path, output_pcm_path, fs, num_channels, options=[], verbose=False): call_args = [ - opus_demo_path, + oac_demo_path, "-d", str(fs), str(num_channels) @@ -96,7 +96,7 @@ def sox(*call_args): except: return 1 -def process_clip_factory(ref_opus_demo, test_opus_demo, enc_options, test_options, dec_fs=16000): +def process_clip_factory(ref_oac_demo, test_oac_demo, enc_options, test_options, dec_fs=16000): def process_clip(clip_path, processdir, bitrate): # derive paths clipname = os.path.splitext(os.path.split(clip_path)[1])[0] @@ -109,11 +109,11 @@ def process_clip(clip_path, processdir, bitrate): sox(clip_path, pcm_path) # run encoder - run_opus_encoder(ref_opus_demo, pcm_path, bitstream_path, "voip", 16000, 1, bitrate, enc_options) + run_oac_encoder(ref_oac_demo, pcm_path, bitstream_path, "voip", 16000, 1, bitrate, enc_options) # run decoder - run_opus_decoder(ref_opus_demo, bitstream_path, ref_path, dec_fs, 1) - run_opus_decoder(test_opus_demo, bitstream_path, test_path, dec_fs, 1, options=test_options) + run_oac_decoder(ref_oac_demo, bitstream_path, ref_path, dec_fs, 1) + run_oac_decoder(test_oac_demo, bitstream_path, test_path, dec_fs, 1, options=test_options) # resample if dec_fs != 16000 if dec_fs != 16000: @@ -134,7 +134,7 @@ def process_clip(clip_path, processdir, bitrate): return process_clip -def main(inputdir, outputdir, bitrate, reference_opus_demo, test_opus_demo, enc_option_string, test_option_string, dec_fs, verbose): +def main(inputdir, outputdir, bitrate, reference_oac_demo, test_oac_demo, enc_option_string, test_option_string, dec_fs, verbose): # load clips list with open(os.path.join(inputdir, 'clips.yml'), "r") as f: @@ -144,7 +144,7 @@ def main(inputdir, outputdir, bitrate, reference_opus_demo, test_opus_demo, enc_ enc_options = enc_option_string.split() test_options = test_option_string.split() - process_clip = process_clip_factory(reference_opus_demo, test_opus_demo, enc_options, test_options, dec_fs=dec_fs) + process_clip = process_clip_factory(reference_oac_demo, test_oac_demo, enc_options, test_options, dec_fs=dec_fs) os.makedirs(outputdir, exist_ok=True) processdir = os.path.join(outputdir, 'process') @@ -201,9 +201,9 @@ def main(inputdir, outputdir, bitrate, reference_opus_demo, test_opus_demo, enc_ main(args.inputdir, args.outputdir, args.bitrate, - args.reference_opus_demo, - args.test_opus_demo, + args.reference_oac_demo, + args.test_oac_demo, args.encoder_options, - args.test_opus_demo_options, + args.test_oac_demo_options, args.dec_fs, args.verbose) diff --git a/dnn/torch/osce/utils/moc.py b/dnn/torch/osce/utils/moc.py index 677dc6194..ddeb37248 100644 --- a/dnn/torch/osce/utils/moc.py +++ b/dnn/torch/osce/utils/moc.py @@ -69,7 +69,7 @@ def rect_fb(band_limits, num_bins=None): def compare(x, y, apply_vad=False): - """ Modified version of opus_compare for 16 kHz mono signals + """ Modified version of oac_compare for 16 kHz mono signals Args: x (np.ndarray): reference input signal scaled to [-1, 1] diff --git a/dnn/torch/osce/utils/silk_features.py b/dnn/torch/osce/utils/silk_features.py index 8c5dbf056..f670904f7 100644 --- a/dnn/torch/osce/utils/silk_features.py +++ b/dnn/torch/osce/utils/silk_features.py @@ -58,7 +58,7 @@ def silk_feature_factory(no_pitch_value=256, pitch_hangover=8, num_bands_clean_spec=64, num_bands_noisy_spec=18, - noisy_spec_scale='opus', + noisy_spec_scale='oac', noisy_apply_dct=True, add_double_lag_acorr=False ): @@ -105,7 +105,7 @@ def load_inference_data(path, pitch_hangover=8, num_bands_clean_spec=64, num_bands_noisy_spec=18, - noisy_spec_scale='opus', + noisy_spec_scale='oac', noisy_apply_dct=True, add_double_lag_acorr=False, **kwargs): diff --git a/dnn/torch/osce/utils/spec.py b/dnn/torch/osce/utils/spec.py index 2f4015b40..b4acfe5a7 100644 --- a/dnn/torch/osce/utils/spec.py +++ b/dnn/torch/osce/utils/spec.py @@ -72,11 +72,11 @@ def create_filter_bank(num_bands, n_fft=320, fs=16000, scale='bark', round_cente f1 = fs / n_fft * (num_bins - 1) fstep = fs / n_fft - if scale == 'opus': + if scale == 'oac': bins_5ms = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 34, 40] fac = 1000 * n_fft / fs / 5 if num_bands != 18: - print("warning: requested Opus filter bank with num_bands != 18. Adjusting num_bands.") + print("warning: requested Oac filter bank with num_bands != 18. Adjusting num_bands.") num_bands = 18 center_bins = np.array([fac * bin for bin in bins_5ms]) else: diff --git a/dnn/torch/osce/utils/templates.py b/dnn/torch/osce/utils/templates.py index 8cf25e8f0..3f5b73c6e 100644 --- a/dnn/torch/osce/utils/templates.py +++ b/dnn/torch/osce/utils/templates.py @@ -66,7 +66,7 @@ 'acorr_radius': 2, 'num_bands_clean_spec': 64, 'num_bands_noisy_spec': 18, - 'noisy_spec_scale': 'opus', + 'noisy_spec_scale': 'oac', 'pitch_hangover': 0, }, 'training': { @@ -350,7 +350,7 @@ 'acorr_radius': 2, 'num_bands_clean_spec': 64, 'num_bands_noisy_spec': 18, - 'noisy_spec_scale': 'opus', + 'noisy_spec_scale': 'oac', 'pitch_hangover': 0, }, 'training': { @@ -408,7 +408,7 @@ 'acorr_radius': 2, 'num_bands_clean_spec': 64, 'num_bands_noisy_spec': 18, - 'noisy_spec_scale': 'opus', + 'noisy_spec_scale': 'oac', 'pitch_hangover': 0, }, 'discriminator': { diff --git a/dnn/torch/plc/export_plc.py b/dnn/torch/plc/export_plc.py index 7f153c4c5..53bce3fe1 100644 --- a/dnn/torch/plc/export_plc.py +++ b/dnn/torch/plc/export_plc.py @@ -55,7 +55,7 @@ def c_export(args, model): writer = CWriter(os.path.join(args.output_dir, "plc_data"), message=message, model_struct_name='PLCModel') writer.header.write( f""" -#include "opus_types.h" +#include "oac_types.h" """ ) diff --git a/dnn/torch/rdovae/export_rdovae_weights.py b/dnn/torch/rdovae/export_rdovae_weights.py index d75c7b34e..8ea7942dc 100644 --- a/dnn/torch/rdovae/export_rdovae_weights.py +++ b/dnn/torch/rdovae/export_rdovae_weights.py @@ -92,10 +92,10 @@ def dump_statistical_model(writer, w, name, xmlout): p0_q8 = p0_q8[:, mask] N = r_q8.shape[-1] - print_vector(writer.source, quant_scales_q8, f'dred_{name}_quant_scales_q8', dtype='opus_uint8', static=False) - print_vector(writer.source, dead_zone_q8, f'dred_{name}_dead_zone_q8', dtype='opus_uint8', static=False) - print_vector(writer.source, r_q8, f'dred_{name}_r_q8', dtype='opus_uint8', static=False) - print_vector(writer.source, p0_q8, f'dred_{name}_p0_q8', dtype='opus_uint8', static=False) + print_vector(writer.source, quant_scales_q8, f'dred_{name}_quant_scales_q8', dtype='oac_uint8', static=False) + print_vector(writer.source, dead_zone_q8, f'dred_{name}_dead_zone_q8', dtype='oac_uint8', static=False) + print_vector(writer.source, r_q8, f'dred_{name}_r_q8', dtype='oac_uint8', static=False) + print_vector(writer.source, p0_q8, f'dred_{name}_p0_q8', dtype='oac_uint8', static=False) print_xml(xmlout, quant_scales_q8, "Scale", "scale", name) print_xml(xmlout, dead_zone_q8, "Dead zone", "deadzone", name) @@ -104,10 +104,10 @@ def dump_statistical_model(writer, w, name, xmlout): writer.header.write( f""" -extern const opus_uint8 dred_{name}_quant_scales_q8[{levels * N}]; -extern const opus_uint8 dred_{name}_dead_zone_q8[{levels * N}]; -extern const opus_uint8 dred_{name}_r_q8[{levels * N}]; -extern const opus_uint8 dred_{name}_p0_q8[{levels * N}]; +extern const oac_uint8 dred_{name}_quant_scales_q8[{levels * N}]; +extern const oac_uint8 dred_{name}_dead_zone_q8[{levels * N}]; +extern const oac_uint8 dred_{name}_r_q8[{levels * N}]; +extern const oac_uint8 dred_{name}_p0_q8[{levels * N}]; """ ) @@ -128,7 +128,7 @@ def c_export(args, model): for writer in [enc_writer, dec_writer]: writer.header.write( f""" -#include "opus_types.h" +#include "oac_types.h" #include "dred_rdovae.h" @@ -139,7 +139,7 @@ def c_export(args, model): stats_writer.header.write( f""" -#include "opus_types.h" +#include "oac_types.h" #include "dred_rdovae_constants.h" diff --git a/dnn/torch/rdovae/fec_encoder.py b/dnn/torch/rdovae/fec_encoder.py index 20ab4ac3a..dac28471a 100644 --- a/dnn/torch/rdovae/fec_encoder.py +++ b/dnn/torch/rdovae/fec_encoder.py @@ -33,7 +33,7 @@ os.environ['CUDA_VISIBLE_DEVICES'] = "" -parser = argparse.ArgumentParser(description='Encode redundancy for Opus neural FEC. Designed for use with voip application and 20ms frames') +parser = argparse.ArgumentParser(description='Encode redundancy for Oac neural FEC. Designed for use with voip application and 20ms frames') parser.add_argument('input', metavar='', help='audio input (.wav or .raw or .pcm as int16)') parser.add_argument('checkpoint', metavar='', help='model checkpoint') diff --git a/dnn/torch/weight-exchange/wexchange/c_export/common.py b/dnn/torch/weight-exchange/wexchange/c_export/common.py index 5801c7e8a..b314a3507 100644 --- a/dnn/torch/weight-exchange/wexchange/c_export/common.py +++ b/dnn/torch/weight-exchange/wexchange/c_export/common.py @@ -40,10 +40,10 @@ def print_vector(writer, vector, name, dtype='float', reshape_8x4=False, static= dtype_suffix = { 'float' : 'float', - 'opus_uint8' : 'uint8', - 'opus_int8' : 'int8', - 'opus_uint16' : 'uint16', - 'opus_int16' : 'int16', + 'oac_uint8' : 'uint8', + 'oac_int8' : 'int8', + 'oac_uint16' : 'uint16', + 'oac_int16' : 'int16', 'int' : 'int', 'qweight': 'qweight' } @@ -164,7 +164,7 @@ def print_sparse_weight(writer, A, name, scale=1/128, have_diag=True, quantize=F W = np.concatenate([W, vblock]) idx[pos] = nb_nonzero - if quantize: print_vector(writer, W, name + '_int8', reshape_8x4=False, dtype='opus_int8') + if quantize: print_vector(writer, W, name + '_int8', reshape_8x4=False, dtype='oac_int8') print_vector(writer, W0, name + '_float', reshape_8x4=False, dtype='float', debug_float=quantize) print_vector(writer, idx, name + '_idx', reshape_8x4=False, dtype='int') @@ -237,7 +237,7 @@ def print_linear_layer(writer : CWriter, else: if quantize: weight_q = quantize_weight(weight, scale) - print_vector(writer, weight_q, name + "_weights_int8", dtype='opus_int8', reshape_8x4=True) + print_vector(writer, weight_q, name + "_weights_int8", dtype='oac_int8', reshape_8x4=True) print_vector(writer, weight, name + "_weights_float", dtype='float', reshape_8x4=False, debug_float=quantize) diff --git a/dnn/training_tf2/dataloader.py b/dnn/training_tf2/dataloader.py deleted file mode 100644 index ed441c1e3..000000000 --- a/dnn/training_tf2/dataloader.py +++ /dev/null @@ -1,49 +0,0 @@ -import numpy as np -from tensorflow.keras.utils import Sequence -from ulaw import lin2ulaw - -def lpc2rc(lpc): - #print("shape is = ", lpc.shape) - order = lpc.shape[-1] - rc = 0*lpc - for i in range(order, 0, -1): - rc[:,:,i-1] = lpc[:,:,-1] - ki = rc[:,:,i-1:i].repeat(i-1, axis=2) - lpc = (lpc[:,:,:-1] - ki*lpc[:,:,-2::-1])/(1-ki*ki) - return rc - -class LPCNetLoader(Sequence): - def __init__(self, data, features, periods, batch_size, e2e=False, lookahead=2): - self.batch_size = batch_size - self.nb_batches = np.minimum(np.minimum(data.shape[0], features.shape[0]), periods.shape[0])//self.batch_size - self.data = data[:self.nb_batches*self.batch_size, :] - self.features = features[:self.nb_batches*self.batch_size, :] - self.periods = periods[:self.nb_batches*self.batch_size, :] - self.e2e = e2e - self.lookahead = lookahead - self.on_epoch_end() - - def on_epoch_end(self): - self.indices = np.arange(self.nb_batches*self.batch_size) - np.random.shuffle(self.indices) - - def __getitem__(self, index): - data = self.data[self.indices[index*self.batch_size:(index+1)*self.batch_size], :, :] - in_data = data[: , :, :1] - out_data = data[: , :, 1:] - features = self.features[self.indices[index*self.batch_size:(index+1)*self.batch_size], :, :-16] - periods = self.periods[self.indices[index*self.batch_size:(index+1)*self.batch_size], :, :] - outputs = [out_data] - inputs = [in_data, features, periods] - if self.lookahead > 0: - lpc = self.features[self.indices[index*self.batch_size:(index+1)*self.batch_size], 4-self.lookahead:-self.lookahead, -16:] - else: - lpc = self.features[self.indices[index*self.batch_size:(index+1)*self.batch_size], 4:, -16:] - if self.e2e: - outputs.append(lpc2rc(lpc)) - else: - inputs.append(lpc) - return (inputs, outputs) - - def __len__(self): - return self.nb_batches diff --git a/dnn/training_tf2/decode_rdovae.py b/dnn/training_tf2/decode_rdovae.py deleted file mode 100644 index f9bf9bf62..000000000 --- a/dnn/training_tf2/decode_rdovae.py +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2021-2022 Amazon - Copyright (c) 2018-2019 Mozilla - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' - -# Train an LPCNet model - -import argparse -#from plc_loader import PLCLoader - -parser = argparse.ArgumentParser(description='Train a PLC model') - -parser.add_argument('bits', metavar='', help='binary features file (int16)') -parser.add_argument('output', metavar='', help='output features') -parser.add_argument('--model', metavar='', default='rdovae', help='PLC model python definition (without .py)') -group1 = parser.add_mutually_exclusive_group() -group1.add_argument('--weights', metavar='', help='model weights') -parser.add_argument('--cond-size', metavar='', default=1024, type=int, help='number of units in conditioning network (default 1024)') -parser.add_argument('--batch-size', metavar='', default=1, type=int, help='batch size to use (default 128)') -parser.add_argument('--seq-length', metavar='', default=1000, type=int, help='sequence length to use (default 1000)') - - -args = parser.parse_args() - -import importlib -rdovae = importlib.import_module(args.model) - -import sys -import numpy as np -from tensorflow.keras.optimizers import Adam -from tensorflow.keras.callbacks import ModelCheckpoint, CSVLogger -import tensorflow.keras.backend as K -import h5py - -import tensorflow as tf -from rdovae import pvq_quantize -from rdovae import apply_dead_zone - -# Try reducing batch_size if you run out of memory on your GPU -batch_size = args.batch_size - -model, encoder, decoder, qembedding = rdovae.new_rdovae_model(nb_used_features=20, nb_bits=80, batch_size=batch_size, cond_size=args.cond_size) -model.load_weights(args.weights) - -lpc_order = 16 -nbits=80 - - -bits_file = args.bits -sequence_size = args.seq_length - -# u for unquantised, load 16 bit PCM samples and convert to mu-law - - -bits = np.memmap(bits_file + "-syms.f32", dtype='float32', mode='r') -nb_sequences = len(bits)//(40*sequence_size)//batch_size*batch_size -bits = bits[:nb_sequences*sequence_size*40] - -bits = np.reshape(bits, (nb_sequences, sequence_size//2, 20*4)) -print(bits.shape) - -lambda_val = 0.001 * np.ones((nb_sequences, sequence_size//2, 1)) -quant_id = np.round(3.8*np.log(lambda_val/.0002)).astype('int16') -quant_id = quant_id[:,:,0] -quant_embed = qembedding(quant_id) -quant_scale = tf.math.softplus(quant_embed[:,:,:nbits]) -dead_zone = tf.math.softplus(quant_embed[:, :, nbits : 2 * nbits]) - -bits = bits*quant_scale -bits = np.round(apply_dead_zone([bits, dead_zone]).numpy()) -bits = bits/quant_scale - - -state = np.memmap(bits_file + "-state.f32", dtype='float32', mode='r') - -state = np.reshape(state, (nb_sequences, sequence_size//2, 24)) -state = state[:,-1,:] -state = pvq_quantize(state, 82) -#state = state/(1e-15+tf.norm(state, axis=-1,keepdims=True)) - -print("shapes are:") -print(bits.shape) -print(state.shape) - -bits = bits[:,1::2,:] -features = decoder.predict([bits, state], batch_size=batch_size) - -features.astype('float32').tofile(args.output) diff --git a/dnn/training_tf2/diffembed.py b/dnn/training_tf2/diffembed.py deleted file mode 100644 index e04ae154b..000000000 --- a/dnn/training_tf2/diffembed.py +++ /dev/null @@ -1,49 +0,0 @@ -""" -Modification of Tensorflow's Embedding Layer: - 1. Not restricted to be the first layer of a model - 2. Differentiable (allows non-integer lookups) - - For non integer lookup, this layer linearly interpolates between the adjacent embeddings in the following way to preserver gradient flow - - E = (1 - frac(x))*embed(floor(x)) + frac(x)*embed(ceil(x)) -""" - -import tensorflow as tf -from tensorflow.keras.layers import Layer - -class diff_Embed(Layer): - """ - Parameters: - - units: int - Dimension of the Embedding - - dict_size: int - Number of Embeddings to lookup - - pcm_init: boolean - Initialized for the embedding matrix - """ - def __init__(self, units=128, dict_size = 256, pcm_init = True, initializer = None, **kwargs): - super(diff_Embed, self).__init__(**kwargs) - self.units = units - self.dict_size = dict_size - self.pcm_init = pcm_init - self.initializer = initializer - - def build(self, input_shape): - w_init = tf.random_normal_initializer() - if self.pcm_init: - w_init = self.initializer - self.w = tf.Variable(initial_value=w_init(shape=(self.dict_size, self.units),dtype='float32'),trainable=True) - - def call(self, inputs): - alpha = inputs - tf.math.floor(inputs) - alpha = tf.expand_dims(alpha,axis = -1) - alpha = tf.tile(alpha,[1,1,1,self.units]) - inputs = tf.cast(inputs,'int32') - M = (1 - alpha)*tf.gather(self.w,inputs) + alpha*tf.gather(self.w,tf.clip_by_value(inputs + 1, 0, 255)) - return M - - def get_config(self): - config = super(diff_Embed, self).get_config() - config.update({"units": self.units}) - config.update({"dict_size" : self.dict_size}) - config.update({"pcm_init" : self.pcm_init}) - config.update({"initializer" : self.initializer}) - return config \ No newline at end of file diff --git a/dnn/training_tf2/dump_lpcnet.py b/dnn/training_tf2/dump_lpcnet.py deleted file mode 100755 index 97ce0cedd..000000000 --- a/dnn/training_tf2/dump_lpcnet.py +++ /dev/null @@ -1,388 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2017-2018 Mozilla - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' - -import os -import io -import lpcnet -import sys -import numpy as np -from tensorflow.keras.optimizers import Adam -from tensorflow.keras.layers import Layer, GRU, Dense, Conv1D, Embedding -from ulaw import ulaw2lin, lin2ulaw -from mdense import MDense -from diffembed import diff_Embed -from parameters import get_parameter -import h5py -import re -import argparse - - -# no cuda devices needed -os.environ['CUDA_VISIBLE_DEVICES'] = "" - -# Flag for dumping e2e (differentiable lpc) network weights -flag_e2e = False - - -max_rnn_neurons = 1 -max_conv_inputs = 1 -max_mdense_tmp = 1 - -def printVector(f, vector, name, dtype='float', dotp=False): - global array_list - if dotp: - vector = vector.reshape((vector.shape[0]//4, 4, vector.shape[1]//8, 8)) - vector = vector.transpose((2, 0, 3, 1)) - v = np.reshape(vector, (-1)); - #print('static const float ', name, '[', len(v), '] = \n', file=f) - if name not in array_list: - array_list.append(name) - f.write('#ifndef USE_WEIGHTS_FILE\n') - f.write('#define WEIGHTS_{}_DEFINED\n'.format(name)) - f.write('#define WEIGHTS_{}_TYPE WEIGHT_TYPE_{}\n'.format(name, dtype)) - f.write('static const {} {}[{}] = {{\n '.format(dtype, name, len(v))) - for i in range(0, len(v)): - f.write('{}'.format(v[i])) - if (i!=len(v)-1): - f.write(',') - else: - break; - if (i%8==7): - f.write("\n ") - else: - f.write(" ") - #print(v, file=f) - f.write('\n};\n') - f.write('#endif\n\n') - return; - -def printSparseVector(f, A, name, have_diag=True): - N = A.shape[0] - M = A.shape[1] - W = np.zeros((0,), dtype='int') - W0 = np.zeros((0,)) - if have_diag: - diag = np.concatenate([np.diag(A[:,:N]), np.diag(A[:,N:2*N]), np.diag(A[:,2*N:])]) - A[:,:N] = A[:,:N] - np.diag(np.diag(A[:,:N])) - A[:,N:2*N] = A[:,N:2*N] - np.diag(np.diag(A[:,N:2*N])) - A[:,2*N:] = A[:,2*N:] - np.diag(np.diag(A[:,2*N:])) - printVector(f, diag, name + '_diag') - AQ = np.minimum(127, np.maximum(-128, np.round(A*128))).astype('int') - idx = np.zeros((0,), dtype='int') - for i in range(M//8): - pos = idx.shape[0] - idx = np.append(idx, -1) - nb_nonzero = 0 - for j in range(N//4): - block = A[j*4:(j+1)*4, i*8:(i+1)*8] - qblock = AQ[j*4:(j+1)*4, i*8:(i+1)*8] - if np.sum(np.abs(block)) > 1e-10: - nb_nonzero = nb_nonzero + 1 - idx = np.append(idx, j*4) - vblock = qblock.transpose((1,0)).reshape((-1,)) - W0 = np.concatenate([W0, block.reshape((-1,))]) - W = np.concatenate([W, vblock]) - idx[pos] = nb_nonzero - f.write('#ifdef DOT_PROD\n') - printVector(f, W, name, dtype='qweight') - f.write('#else /*DOT_PROD*/\n') - printVector(f, W0, name, dtype='qweight') - f.write('#endif /*DOT_PROD*/\n') - #idx = np.tile(np.concatenate([np.array([N]), np.arange(N)]), 3*N//16) - printVector(f, idx, name + '_idx', dtype='int') - return AQ - -def dump_layer_ignore(self, f, hf): - print("ignoring layer " + self.name + " of type " + self.__class__.__name__) - return False -Layer.dump_layer = dump_layer_ignore - -def dump_sparse_gru(self, f, hf): - global max_rnn_neurons - name = 'sparse_' + self.name - print("printing layer " + name + " of type sparse " + self.__class__.__name__) - weights = self.get_weights() - qweights = printSparseVector(f, weights[1], name + '_recurrent_weights') - printVector(f, weights[-1], name + '_bias') - subias = weights[-1].copy() - subias[1,:] = subias[1,:] - np.sum(qweights*(1./128),axis=0) - printVector(f, subias, name + '_subias') - if hasattr(self, 'activation'): - activation = self.activation.__name__.upper() - else: - activation = 'TANH' - if hasattr(self, 'reset_after') and not self.reset_after: - reset_after = 0 - else: - reset_after = 1 - neurons = weights[0].shape[1]//3 - max_rnn_neurons = max(max_rnn_neurons, neurons) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - model_struct.write(' SparseGRULayer {};\n'.format(name)); - model_init.write(' if (sparse_gru_init(&model->{}, arrays, "{}_bias", "{}_subias", "{}_recurrent_weights_diag", "{}_recurrent_weights", "{}_recurrent_weights_idx", {}, ACTIVATION_{}, {})) return 1;\n' - .format(name, name, name, name, name, name, weights[0].shape[1]//3, activation, reset_after)) - return True - -def dump_grub(self, f, hf, gru_a_size): - global max_rnn_neurons - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - qweight = printSparseVector(f, weights[0][:gru_a_size, :], name + '_weights', have_diag=False) - - f.write('#ifdef DOT_PROD\n') - qweight2 = np.clip(np.round(128.*weights[1]).astype('int'), -128, 127) - printVector(f, qweight2, name + '_recurrent_weights', dotp=True, dtype='qweight') - f.write('#else /*DOT_PROD*/\n') - printVector(f, weights[1], name + '_recurrent_weights') - f.write('#endif /*DOT_PROD*/\n') - - printVector(f, weights[-1], name + '_bias') - subias = weights[-1].copy() - subias[0,:] = subias[0,:] - np.sum(qweight*(1./128.),axis=0) - subias[1,:] = subias[1,:] - np.sum(qweight2*(1./128.),axis=0) - printVector(f, subias, name + '_subias') - if hasattr(self, 'activation'): - activation = self.activation.__name__.upper() - else: - activation = 'TANH' - if hasattr(self, 'reset_after') and not self.reset_after: - reset_after = 0 - else: - reset_after = 1 - neurons = weights[0].shape[1]//3 - max_rnn_neurons = max(max_rnn_neurons, neurons) - model_struct.write(' GRULayer {};\n'.format(name)); - model_init.write(' if (gru_init(&model->{}, arrays, "{}_bias", "{}_subias", "{}_weights", "{}_weights_idx", "{}_recurrent_weights", {}, {}, ACTIVATION_{}, {})) return 1;\n' - .format(name, name, name, name, name, name, gru_a_size, weights[0].shape[1]//3, activation, reset_after)) - return True - -def dump_gru_layer_dummy(self, f, hf): - name = self.name - weights = self.get_weights() - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - return True; - -GRU.dump_layer = dump_gru_layer_dummy - -def dump_dense_layer_impl(name, weights, bias, activation, f, hf): - printVector(f, weights, name + '_weights') - printVector(f, bias, name + '_bias') - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights.shape[1])) - model_struct.write(' DenseLayer {};\n'.format(name)); - model_init.write(' if (dense_init(&model->{}, arrays, "{}_bias", "{}_weights", {}, {}, ACTIVATION_{})) return 1;\n' - .format(name, name, name, weights.shape[0], weights.shape[1], activation)) - -def dump_dense_layer(self, f, hf): - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - activation = self.activation.__name__.upper() - dump_dense_layer_impl(name, weights[0], weights[1], activation, f, hf) - return False - -Dense.dump_layer = dump_dense_layer - -def dump_mdense_layer(self, f, hf): - global max_mdense_tmp - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - printVector(f, np.transpose(weights[0], (0, 2, 1)), name + '_weights') - printVector(f, np.transpose(weights[1], (1, 0)), name + '_bias') - printVector(f, np.transpose(weights[2], (1, 0)), name + '_factor') - activation = self.activation.__name__.upper() - max_mdense_tmp = max(max_mdense_tmp, weights[0].shape[0]*weights[0].shape[2]) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[0])) - model_struct.write(' MDenseLayer {};\n'.format(name)); - model_init.write(' if (mdense_init(&model->{}, arrays, "{}_bias", "{}_weights", "{}_factor", {}, {}, {}, ACTIVATION_{})) return 1;\n' - .format(name, name, name, name, weights[0].shape[1], weights[0].shape[0], weights[0].shape[2], activation)) - return False -MDense.dump_layer = dump_mdense_layer - -def dump_conv1d_layer(self, f, hf): - global max_conv_inputs - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - printVector(f, weights[0], name + '_weights') - printVector(f, weights[-1], name + '_bias') - activation = self.activation.__name__.upper() - max_conv_inputs = max(max_conv_inputs, weights[0].shape[1]*weights[0].shape[0]) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[2])) - hf.write('#define {}_STATE_SIZE ({}*{})\n'.format(name.upper(), weights[0].shape[1], (weights[0].shape[0]-1))) - hf.write('#define {}_DELAY {}\n'.format(name.upper(), (weights[0].shape[0]-1)//2)) - model_struct.write(' Conv1DLayer {};\n'.format(name)); - model_init.write(' if (conv1d_init(&model->{}, arrays, "{}_bias", "{}_weights", {}, {}, {}, ACTIVATION_{})) return 1;\n' - .format(name, name, name, weights[0].shape[1], weights[0].shape[0], weights[0].shape[2], activation)) - return True -Conv1D.dump_layer = dump_conv1d_layer - - -def dump_embedding_layer_impl(name, weights, f, hf): - printVector(f, weights, name + '_weights') - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights.shape[1])) - model_struct.write(' EmbeddingLayer {};\n'.format(name)); - model_init.write(' if (embedding_init(&model->{}, arrays, "{}_weights", {}, {})) return 1;\n' - .format(name, name, weights.shape[0], weights.shape[1])) - -def dump_embedding_layer(self, f, hf): - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights()[0] - dump_embedding_layer_impl(name, weights, f, hf) - return False -Embedding.dump_layer = dump_embedding_layer -diff_Embed.dump_layer = dump_embedding_layer - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument('model_file', type=str, help='model weight h5 file') - parser.add_argument('--nnet-header', type=str, help='name of c header file for dumped model', default='nnet_data.h') - parser.add_argument('--nnet-source', type=str, help='name of c source file for dumped model', default='nnet_data.c') - parser.add_argument('--lpc-gamma', type=float, help='LPC weighting factor. If not specified I will attempt to read it from the model file with 1 as default', default=None) - parser.add_argument('--lookahead', type=float, help='Features lookahead. If not specified I will attempt to read it from the model file with 2 as default', default=None) - - args = parser.parse_args() - - filename = args.model_file - with h5py.File(filename, "r") as f: - units = min(f['model_weights']['gru_a']['gru_a']['recurrent_kernel:0'].shape) - units2 = min(f['model_weights']['gru_b']['gru_b']['recurrent_kernel:0'].shape) - cond_size = min(f['model_weights']['feature_dense1']['feature_dense1']['kernel:0'].shape) - e2e = 'rc2lpc' in f['model_weights'] - - model, _, _ = lpcnet.new_lpcnet_model(rnn_units1=units, rnn_units2=units2, flag_e2e = e2e, cond_size=cond_size) - model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy']) - #model.summary() - - model.load_weights(filename, by_name=True) - - cfile = args.nnet_source - hfile = args.nnet_header - - f = open(cfile, 'w') - hf = open(hfile, 'w') - model_struct = io.StringIO() - model_init = io.StringIO() - model_struct.write('typedef struct {\n') - model_init.write('#ifndef DUMP_BINARY_WEIGHTS\n') - model_init.write('int init_lpcnet_model(LPCNetModel *model, const WeightArray *arrays) {\n') - array_list = [] - - f.write('/*This file is automatically generated from a Keras model*/\n') - f.write('/*based on model {}*/\n\n'.format(sys.argv[1])) - f.write('#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif\n\n#include "nnet.h"\n#include "{}"\n\n'.format(hfile)) - - hf.write('/*This file is automatically generated from a Keras model*/\n\n') - hf.write('#ifndef RNN_DATA_H\n#define RNN_DATA_H\n\n#include "nnet.h"\n\n') - - if e2e: - hf.write('/* This is an end-to-end model */\n') - hf.write('#define END2END\n\n') - else: - hf.write('/* This is *not* an end-to-end model */\n') - hf.write('/* #define END2END */\n\n') - - # LPC weighting factor - if type(args.lpc_gamma) == type(None): - lpc_gamma = get_parameter(model, 'lpc_gamma', 1) - else: - lpc_gamma = args.lpc_gamma - - hf.write('/* LPC weighting factor */\n') - hf.write('#define LPC_GAMMA ' + str(lpc_gamma) +'f\n\n') - - # look-ahead - if type(args.lookahead) == type(None): - lookahead = get_parameter(model, 'lookahead', 2) - else: - lookahead = args.lookahead - - hf.write('/* Features look-ahead */\n') - hf.write('#define FEATURES_DELAY ' + str(lookahead) +'\n\n') - - embed_size = lpcnet.embed_size - - E = model.get_layer('embed_sig').get_weights()[0] - W = model.get_layer('gru_a').get_weights()[0][:embed_size,:] - dump_embedding_layer_impl('gru_a_embed_sig', np.dot(E, W), f, hf) - W = model.get_layer('gru_a').get_weights()[0][embed_size:2*embed_size,:] - dump_embedding_layer_impl('gru_a_embed_pred', np.dot(E, W), f, hf) - W = model.get_layer('gru_a').get_weights()[0][2*embed_size:3*embed_size,:] - dump_embedding_layer_impl('gru_a_embed_exc', np.dot(E, W), f, hf) - W = model.get_layer('gru_a').get_weights()[0][3*embed_size:,:] - #FIXME: dump only half the biases - b = model.get_layer('gru_a').get_weights()[2] - dump_dense_layer_impl('gru_a_dense_feature', W, b[:len(b)//2], 'LINEAR', f, hf) - - W = model.get_layer('gru_b').get_weights()[0][model.rnn_units1:,:] - b = model.get_layer('gru_b').get_weights()[2] - # Set biases to zero because they'll be included in the GRU input part - # (we need regular and SU biases) - dump_dense_layer_impl('gru_b_dense_feature', W, 0*b[:len(b)//2], 'LINEAR', f, hf) - dump_grub(model.get_layer('gru_b'), f, hf, model.rnn_units1) - - layer_list = [] - for i, layer in enumerate(model.layers): - if layer.dump_layer(f, hf): - layer_list.append(layer.name) - - dump_sparse_gru(model.get_layer('gru_a'), f, hf) - - f.write('#ifndef USE_WEIGHTS_FILE\n') - f.write('const WeightArray lpcnet_arrays[] = {\n') - for name in array_list: - f.write('#ifdef WEIGHTS_{}_DEFINED\n'.format(name)) - f.write(' {{"{}", WEIGHTS_{}_TYPE, sizeof({}), {}}},\n'.format(name, name, name, name)) - f.write('#endif\n') - f.write(' {NULL, 0, 0, NULL}\n};\n') - f.write('#endif\n') - - model_init.write(' return 0;\n}\n') - model_init.write('#endif\n') - f.write(model_init.getvalue()) - - hf.write('#define MAX_RNN_NEURONS {}\n\n'.format(max_rnn_neurons)) - hf.write('#define MAX_CONV_INPUTS {}\n\n'.format(max_conv_inputs)) - hf.write('#define MAX_MDENSE_TMP {}\n\n'.format(max_mdense_tmp)) - - - hf.write('typedef struct {\n') - for i, name in enumerate(layer_list): - hf.write(' float {}_state[{}_STATE_SIZE];\n'.format(name, name.upper())) - hf.write('} NNetState;\n\n') - - model_struct.write('} LPCNetModel;\n\n') - hf.write(model_struct.getvalue()) - hf.write('int init_lpcnet_model(LPCNetModel *model, const WeightArray *arrays);\n\n') - hf.write('\n\n#endif\n') - - f.close() - hf.close() diff --git a/dnn/training_tf2/dump_plc.py b/dnn/training_tf2/dump_plc.py deleted file mode 100755 index a490ade1d..000000000 --- a/dnn/training_tf2/dump_plc.py +++ /dev/null @@ -1,296 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2021-2022 Amazon - Copyright (c) 2017-2018 Mozilla - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' - -import lpcnet_plc -import io -import sys -import numpy as np -from tensorflow.keras.optimizers import Adam -from tensorflow.keras.layers import Layer, GRU, Dense, Conv1D, Embedding -import h5py -import re - -# Flag for dumping e2e (differentiable lpc) network weights -flag_e2e = False - -max_rnn_neurons = 1 -max_conv_inputs = 1 - -def printVector(f, vector, name, dtype='float', dotp=False): - global array_list - if dotp: - vector = vector.reshape((vector.shape[0]//4, 4, vector.shape[1]//8, 8)) - vector = vector.transpose((2, 0, 3, 1)) - v = np.reshape(vector, (-1)); - #print('static const float ', name, '[', len(v), '] = \n', file=f) - if name not in array_list: - array_list.append(name) - f.write('#ifndef USE_WEIGHTS_FILE\n') - f.write('#define WEIGHTS_{}_DEFINED\n'.format(name)) - f.write('#define WEIGHTS_{}_TYPE WEIGHT_TYPE_{}\n'.format(name, dtype)) - f.write('static const {} {}[{}] = {{\n '.format(dtype, name, len(v))) - for i in range(0, len(v)): - f.write('{}'.format(v[i])) - if (i!=len(v)-1): - f.write(',') - else: - break; - if (i%8==7): - f.write("\n ") - else: - f.write(" ") - #print(v, file=f) - f.write('\n};\n') - f.write('#endif\n\n') - return; - -def printSparseVector(f, A, name, have_diag=True): - N = A.shape[0] - M = A.shape[1] - W = np.zeros((0,), dtype='int') - W0 = np.zeros((0,)) - if have_diag: - diag = np.concatenate([np.diag(A[:,:N]), np.diag(A[:,N:2*N]), np.diag(A[:,2*N:])]) - A[:,:N] = A[:,:N] - np.diag(np.diag(A[:,:N])) - A[:,N:2*N] = A[:,N:2*N] - np.diag(np.diag(A[:,N:2*N])) - A[:,2*N:] = A[:,2*N:] - np.diag(np.diag(A[:,2*N:])) - printVector(f, diag, name + '_diag') - AQ = np.minimum(127, np.maximum(-128, np.round(A*128))).astype('int') - idx = np.zeros((0,), dtype='int') - for i in range(M//8): - pos = idx.shape[0] - idx = np.append(idx, -1) - nb_nonzero = 0 - for j in range(N//4): - block = A[j*4:(j+1)*4, i*8:(i+1)*8] - qblock = AQ[j*4:(j+1)*4, i*8:(i+1)*8] - if np.sum(np.abs(block)) > 1e-10: - nb_nonzero = nb_nonzero + 1 - idx = np.append(idx, j*4) - vblock = qblock.transpose((1,0)).reshape((-1,)) - W0 = np.concatenate([W0, block.reshape((-1,))]) - W = np.concatenate([W, vblock]) - idx[pos] = nb_nonzero - f.write('#ifdef DOT_PROD\n') - printVector(f, W, name, dtype='qweight') - f.write('#else /*DOT_PROD*/\n') - printVector(f, W0, name, dtype='qweight') - f.write('#endif /*DOT_PROD*/\n') - #idx = np.tile(np.concatenate([np.array([N]), np.arange(N)]), 3*N//16) - printVector(f, idx, name + '_idx', dtype='int') - return AQ - -def dump_layer_ignore(self, f, hf): - print("ignoring layer " + self.name + " of type " + self.__class__.__name__) - return False -Layer.dump_layer = dump_layer_ignore - -def dump_sparse_gru(self, f, hf): - global max_rnn_neurons - name = 'sparse_' + self.name - print("printing layer " + name + " of type sparse " + self.__class__.__name__) - weights = self.get_weights() - qweights = printSparseVector(f, weights[1], name + '_recurrent_weights') - printVector(f, weights[-1], name + '_bias') - subias = weights[-1].copy() - subias[1,:] = subias[1,:] - np.sum(qweights*(1./128),axis=0) - printVector(f, subias, name + '_subias') - if hasattr(self, 'activation'): - activation = self.activation.__name__.upper() - else: - activation = 'TANH' - if hasattr(self, 'reset_after') and not self.reset_after: - reset_after = 0 - else: - reset_after = 1 - neurons = weights[0].shape[1]//3 - max_rnn_neurons = max(max_rnn_neurons, neurons) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - model_struct.write(' SparseGRULayer {};\n'.format(name)); - model_init.write(' if (sparse_gru_init(&model->{}, arrays, "{}_bias", "{}_subias", "{}_recurrent_weights_diag", "{}_recurrent_weights", "{}_recurrent_weights_idx", {}, ACTIVATION_{}, {})) return 1;\n' - .format(name, name, name, name, name, name, weights[0].shape[1]//3, activation, reset_after)) - return True - -def dump_gru_layer(self, f, hf): - global max_rnn_neurons - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - qweight = printSparseVector(f, weights[0], name + '_weights', have_diag=False) - - f.write('#ifdef DOT_PROD\n') - qweight2 = np.clip(np.round(128.*weights[1]).astype('int'), -128, 127) - printVector(f, qweight2, name + '_recurrent_weights', dotp=True, dtype='qweight') - f.write('#else /*DOT_PROD*/\n') - printVector(f, weights[1], name + '_recurrent_weights') - f.write('#endif /*DOT_PROD*/\n') - - printVector(f, weights[-1], name + '_bias') - subias = weights[-1].copy() - subias[0,:] = subias[0,:] - np.sum(qweight*(1./128.),axis=0) - subias[1,:] = subias[1,:] - np.sum(qweight2*(1./128.),axis=0) - printVector(f, subias, name + '_subias') - if hasattr(self, 'activation'): - activation = self.activation.__name__.upper() - else: - activation = 'TANH' - if hasattr(self, 'reset_after') and not self.reset_after: - reset_after = 0 - else: - reset_after = 1 - neurons = weights[0].shape[1]//3 - max_rnn_neurons = max(max_rnn_neurons, neurons) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - model_struct.write(' GRULayer {};\n'.format(name)); - model_init.write(' if (gru_init(&model->{}, arrays, "{}_bias", "{}_subias", "{}_weights", "{}_weights_idx", "{}_recurrent_weights", {}, {}, ACTIVATION_{}, {})) return 1;\n' - .format(name, name, name, name, name, name, weights[0].shape[0], weights[0].shape[1]//3, activation, reset_after)) - return True -GRU.dump_layer = dump_gru_layer - -def dump_gru_layer_dummy(self, f, hf): - name = self.name - weights = self.get_weights() - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - return True; - -#GRU.dump_layer = dump_gru_layer_dummy - -def dump_dense_layer_impl(name, weights, bias, activation, f, hf): - printVector(f, weights, name + '_weights') - printVector(f, bias, name + '_bias') - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights.shape[1])) - model_struct.write(' DenseLayer {};\n'.format(name)); - model_init.write(' if (dense_init(&model->{}, arrays, "{}_bias", "{}_weights", {}, {}, ACTIVATION_{})) return 1;\n' - .format(name, name, name, weights.shape[0], weights.shape[1], activation)) - -def dump_dense_layer(self, f, hf): - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - activation = self.activation.__name__.upper() - dump_dense_layer_impl(name, weights[0], weights[1], activation, f, hf) - return False - -Dense.dump_layer = dump_dense_layer - -def dump_conv1d_layer(self, f, hf): - global max_conv_inputs - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - printVector(f, weights[0], name + '_weights') - printVector(f, weights[-1], name + '_bias') - activation = self.activation.__name__.upper() - max_conv_inputs = max(max_conv_inputs, weights[0].shape[1]*weights[0].shape[0]) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[2])) - hf.write('#define {}_STATE_SIZE ({}*{})\n'.format(name.upper(), weights[0].shape[1], (weights[0].shape[0]-1))) - hf.write('#define {}_DELAY {}\n'.format(name.upper(), (weights[0].shape[0]-1)//2)) - model_struct.write(' Conv1DLayer {};\n'.format(name)); - model_init.write(' if (conv1d_init(&model->{}, arrays, "{}_bias", "{}_weights", {}, {}, {}, ACTIVATION_{})) return 1;\n' - .format(name, name, name, weights[0].shape[1], weights[0].shape[0], weights[0].shape[2], activation)) - return True -Conv1D.dump_layer = dump_conv1d_layer - - - -filename = sys.argv[1] -with h5py.File(filename, "r") as f: - units = min(f['model_weights']['plc_gru1']['plc_gru1']['recurrent_kernel:0'].shape) - units2 = min(f['model_weights']['plc_gru2']['plc_gru2']['recurrent_kernel:0'].shape) - cond_size = f['model_weights']['plc_dense1']['plc_dense1']['kernel:0'].shape[1] - -model = lpcnet_plc.new_lpcnet_plc_model(rnn_units=units, cond_size=cond_size) -model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy']) -#model.summary() - -model.load_weights(filename, by_name=True) - -if len(sys.argv) > 2: - cfile = sys.argv[2]; - hfile = sys.argv[3]; -else: - cfile = 'plc_data.c' - hfile = 'plc_data.h' - - -f = open(cfile, 'w') -hf = open(hfile, 'w') -model_struct = io.StringIO() -model_init = io.StringIO() -model_struct.write('typedef struct {\n') -model_init.write('#ifndef DUMP_BINARY_WEIGHTS\n') -model_init.write('int init_plc_model(PLCModel *model, const WeightArray *arrays) {\n') -array_list = [] - - -f.write('/*This file is automatically generated from a Keras model*/\n') -f.write('/*based on model {}*/\n\n'.format(sys.argv[1])) -f.write('#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif\n\n#include "nnet.h"\n#include "{}"\n\n'.format(hfile)) - -hf.write('/*This file is automatically generated from a Keras model*/\n\n') -hf.write('#ifndef PLC_DATA_H\n#define PLC_DATA_H\n\n#include "nnet.h"\n\n') - -layer_list = [] -for i, layer in enumerate(model.layers): - if layer.dump_layer(f, hf): - layer_list.append(layer.name) - -#dump_sparse_gru(model.get_layer('gru_a'), f, hf) -f.write('#ifndef USE_WEIGHTS_FILE\n') -f.write('const WeightArray lpcnet_plc_arrays[] = {\n') -for name in array_list: - f.write('#ifdef WEIGHTS_{}_DEFINED\n'.format(name)) - f.write(' {{"{}", WEIGHTS_{}_TYPE, sizeof({}), {}}},\n'.format(name, name, name, name)) - f.write('#endif\n') -f.write(' {NULL, 0, 0, NULL}\n};\n') -f.write('#endif\n') - -model_init.write(' return 0;\n}\n') -model_init.write('#endif\n') -f.write(model_init.getvalue()) - - -hf.write('#define PLC_MAX_RNN_NEURONS {}\n\n'.format(max_rnn_neurons)) -#hf.write('#define PLC_MAX_CONV_INPUTS {}\n\n'.format(max_conv_inputs)) - -hf.write('typedef struct {\n') -for i, name in enumerate(layer_list): - hf.write(' float {}_state[{}_STATE_SIZE];\n'.format(name, name.upper())) -hf.write('} PLCNetState;\n\n') - -model_struct.write('} PLCModel;\n\n') -hf.write(model_struct.getvalue()) -hf.write('int init_plc_model(PLCModel *model, const WeightArray *arrays);\n\n') - -hf.write('\n\n#endif\n') - -f.close() -hf.close() diff --git a/dnn/training_tf2/dump_rdovae.py b/dnn/training_tf2/dump_rdovae.py deleted file mode 100644 index 1858c8a49..000000000 --- a/dnn/training_tf2/dump_rdovae.py +++ /dev/null @@ -1,306 +0,0 @@ -""" -/* Copyright (c) 2022 Amazon - Written by Jan Buethe */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -""" - - -import argparse -from ftplib import parse150 -import os - -os.environ['CUDA_VISIBLE_DEVICES'] = "" - -parser = argparse.ArgumentParser() - -parser.add_argument('weights', metavar="", type=str, help='model weight file in hdf5 format') -parser.add_argument('--cond-size', type=int, help="conditioning size (default: 256)", default=256) -parser.add_argument('--latent-dim', type=int, help="dimension of latent space (default: 80)", default=80) -parser.add_argument('--quant-levels', type=int, help="number of quantization steps (default: 16)", default=16) - -args = parser.parse_args() - -# now import the heavy stuff -import tensorflow as tf -import numpy as np -from keraslayerdump import dump_conv1d_layer, dump_dense_layer, dump_gru_layer, printVector -from rdovae import new_rdovae_model - -def start_header(header_fid, header_name): - header_guard = os.path.basename(header_name)[:-2].upper() + "_H" - header_fid.write( -f""" -#ifndef {header_guard} -#define {header_guard} - -""" - ) - -def finish_header(header_fid): - header_fid.write( -""" -#endif - -""" - ) - -def start_source(source_fid, header_name, weight_file): - source_fid.write( -f""" -/* this source file was automatically generated from weight file {weight_file} */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "{header_name}" - -""" - ) - -def finish_source(source_fid): - pass - - -def dump_statistical_model(qembedding, f, fh): - w = qembedding.weights[0].numpy() - levels, dim = w.shape - N = dim // 6 - - print("dumping statistical model") - quant_scales = tf.math.softplus(w[:, : N]).numpy() - dead_zone = 0.05 * tf.math.softplus(w[:, N : 2 * N]).numpy() - r = tf.math.sigmoid(w[:, 5 * N : 6 * N]).numpy() - p0 = tf.math.sigmoid(w[:, 4 * N : 5 * N]).numpy() - p0 = 1 - r ** (0.5 + 0.5 * p0) - - quant_scales_q8 = np.round(quant_scales * 2**8).astype(np.uint16) - dead_zone_q10 = np.round(dead_zone * 2**10).astype(np.uint16) - r_q15 = np.round(r * 2**15).astype(np.uint16) - p0_q15 = np.round(p0 * 2**15).astype(np.uint16) - - printVector(f, quant_scales_q8, 'dred_quant_scales_q8', dtype='opus_uint16', static=False) - printVector(f, dead_zone_q10, 'dred_dead_zone_q10', dtype='opus_uint16', static=False) - printVector(f, r_q15, 'dred_r_q15', dtype='opus_uint16', static=False) - printVector(f, p0_q15, 'dred_p0_q15', dtype='opus_uint16', static=False) - - fh.write( -f""" -extern const opus_uint16 dred_quant_scales_q8[{levels * N}]; -extern const opus_uint16 dred_dead_zone_q10[{levels * N}]; -extern const opus_uint16 dred_r_q15[{levels * N}]; -extern const opus_uint16 dred_p0_q15[{levels * N}]; - -""" - ) - -if __name__ == "__main__": - - model, encoder, decoder, qembedding = new_rdovae_model(20, args.latent_dim, cond_size=args.cond_size, nb_quant=args.quant_levels) - model.load_weights(args.weights) - - - - - # encoder - encoder_dense_names = [ - 'enc_dense1', - 'enc_dense3', - 'enc_dense5', - 'enc_dense7', - 'enc_dense8', - 'gdense1', - 'gdense2' - ] - - encoder_gru_names = [ - 'enc_dense2', - 'enc_dense4', - 'enc_dense6' - ] - - encoder_conv1d_names = [ - 'bits_dense' - ] - - source_fid = open("dred_rdovae_enc_data.c", 'w') - header_fid = open("dred_rdovae_enc_data.h", 'w') - - start_header(header_fid, "dred_rdovae_enc_data.h") - start_source(source_fid, "dred_rdovae_enc_data.h", os.path.basename(args.weights)) - - header_fid.write( -f""" -#include "dred_rdovae_constants.h" - -#include "nnet.h" -""" - ) - - # dump GRUs - max_rnn_neurons_enc = max( - [ - dump_gru_layer(encoder.get_layer(name), source_fid, header_fid, dotp=True, sparse=True) - for name in encoder_gru_names - ] - ) - - # dump conv layers - max_conv_inputs = max( - [ - dump_conv1d_layer(encoder.get_layer(name), source_fid, header_fid) - for name in encoder_conv1d_names - ] - ) - - # dump Dense layers - for name in encoder_dense_names: - layer = encoder.get_layer(name) - dump_dense_layer(layer, source_fid, header_fid) - - # some global constants - header_fid.write( -f""" - -#define DRED_ENC_MAX_RNN_NEURONS {max_rnn_neurons_enc} - -#define DRED_ENC_MAX_CONV_INPUTS {max_conv_inputs} - -""" - ) - - finish_header(header_fid) - finish_source(source_fid) - - header_fid.close() - source_fid.close() - - # statistical model - source_fid = open("dred_rdovae_stats_data.c", 'w') - header_fid = open("dred_rdovae_stats_data.h", 'w') - - start_header(header_fid, "dred_rdovae_stats_data.h") - start_source(source_fid, "dred_rdovae_stats_data.h", os.path.basename(args.weights)) - - header_fid.write( -""" - -#include "opus_types.h" - -""" - ) - - dump_statistical_model(qembedding, source_fid, header_fid) - - finish_header(header_fid) - finish_source(source_fid) - - header_fid.close() - source_fid.close() - - # decoder - decoder_dense_names = [ - 'state1', - 'state2', - 'state3', - 'dec_dense1', - 'dec_dense3', - 'dec_dense5', - 'dec_dense7', - 'dec_dense8', - 'dec_final' - ] - - decoder_gru_names = [ - 'dec_dense2', - 'dec_dense4', - 'dec_dense6' - ] - - source_fid = open("dred_rdovae_dec_data.c", 'w') - header_fid = open("dred_rdovae_dec_data.h", 'w') - - start_header(header_fid, "dred_rdovae_dec_data.h") - start_source(source_fid, "dred_rdovae_dec_data.h", os.path.basename(args.weights)) - - header_fid.write( -f""" -#include "dred_rdovae_constants.h" - -#include "nnet.h" -""" - ) - - - # dump GRUs - max_rnn_neurons_dec = max( - [ - dump_gru_layer(decoder.get_layer(name), source_fid, header_fid, dotp=True, sparse=True) - for name in decoder_gru_names - ] - ) - - # dump Dense layers - for name in decoder_dense_names: - layer = decoder.get_layer(name) - dump_dense_layer(layer, source_fid, header_fid) - - # some global constants - header_fid.write( -f""" - -#define DRED_DEC_MAX_RNN_NEURONS {max_rnn_neurons_dec} - -""" - ) - - finish_header(header_fid) - finish_source(source_fid) - - header_fid.close() - source_fid.close() - - # common constants - header_fid = open("dred_rdovae_constants.h", 'w') - start_header(header_fid, "dred_rdovae_constants.h") - - header_fid.write( -f""" -#define DRED_NUM_FEATURES 20 - -#define DRED_LATENT_DIM {args.latent_dim} - -#define DRED_STATE_DIM {24} - -#define DRED_NUM_QUANTIZATION_LEVELS {qembedding.weights[0].shape[0]} - -#define DRED_MAX_RNN_NEURONS {max(max_rnn_neurons_enc, max_rnn_neurons_dec)} - -#define DRED_MAX_CONV_INPUTS {max_conv_inputs} -""" - ) - - finish_header(header_fid) \ No newline at end of file diff --git a/dnn/training_tf2/encode_rdovae.py b/dnn/training_tf2/encode_rdovae.py deleted file mode 100644 index f144fc48e..000000000 --- a/dnn/training_tf2/encode_rdovae.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2021-2022 Amazon - Copyright (c) 2018-2019 Mozilla - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' - -# Train an LPCNet model - -import argparse -#from plc_loader import PLCLoader - -parser = argparse.ArgumentParser(description='Train a PLC model') - -parser.add_argument('features', metavar='', help='binary features file (float32)') -parser.add_argument('output', metavar='', help='trained model file (.h5)') -parser.add_argument('--model', metavar='', default='rdovae', help='PLC model python definition (without .py)') -group1 = parser.add_mutually_exclusive_group() -group1.add_argument('--weights', metavar='', help='model weights') -parser.add_argument('--cond-size', metavar='', default=1024, type=int, help='number of units in conditioning network (default 1024)') -parser.add_argument('--batch-size', metavar='', default=1, type=int, help='batch size to use (default 128)') -parser.add_argument('--seq-length', metavar='', default=1000, type=int, help='sequence length to use (default 1000)') - - -args = parser.parse_args() - -import importlib -rdovae = importlib.import_module(args.model) - -from rdovae import apply_dead_zone - -import sys -import numpy as np -from tensorflow.keras.optimizers import Adam -from tensorflow.keras.callbacks import ModelCheckpoint, CSVLogger -import tensorflow.keras.backend as K -import h5py - -import tensorflow as tf -from rdovae import pvq_quantize - -# Try reducing batch_size if you run out of memory on your GPU -batch_size = args.batch_size - -model, encoder, decoder, qembedding = rdovae.new_rdovae_model(nb_used_features=20, nb_bits=80, batch_size=batch_size, cond_size=args.cond_size) -model.load_weights(args.weights) - -lpc_order = 16 - -feature_file = args.features -nb_features = model.nb_used_features + lpc_order -nb_used_features = model.nb_used_features -sequence_size = args.seq_length - -# u for unquantised, load 16 bit PCM samples and convert to mu-law - - -features = np.memmap(feature_file, dtype='float32', mode='r') -nb_sequences = len(features)//(nb_features*sequence_size)//batch_size*batch_size -features = features[:nb_sequences*sequence_size*nb_features] - -features = np.reshape(features, (nb_sequences, sequence_size, nb_features)) -print(features.shape) -features = features[:, :, :nb_used_features] -#features = np.random.randn(73600, 1000, 17) - - -bits, gru_state_dec = encoder.predict([features], batch_size=batch_size) -(gru_state_dec).astype('float32').tofile(args.output + "-state.f32") - - -#dist = rdovae.feat_dist_loss(features, quant_out) -#rate = rdovae.sq1_rate_loss(features, model_bits) -#rate2 = rdovae.sq_rate_metric(features, model_bits) -#print(dist, rate, rate2) - -print("shapes are:") -print(bits.shape) -print(gru_state_dec.shape) - -features.astype('float32').tofile(args.output + "-input.f32") -#quant_out.astype('float32').tofile(args.output + "-enc_dec.f32") -nbits=80 -bits.astype('float32').tofile(args.output + "-syms.f32") - -lambda_val = 0.0002 * np.ones((nb_sequences, sequence_size//2, 1)) -quant_id = np.round(3.8*np.log(lambda_val/.0002)).astype('int16') -quant_id = quant_id[:,:,0] -quant_embed = qembedding(quant_id) -quant_scale = tf.math.softplus(quant_embed[:,:,:nbits]) -dead_zone = tf.math.softplus(quant_embed[:, :, nbits : 2 * nbits]) - -bits = bits*quant_scale -bits = np.round(apply_dead_zone([bits, dead_zone]).numpy()) -bits = bits/quant_scale - -gru_state_dec = pvq_quantize(gru_state_dec, 82) -#gru_state_dec = gru_state_dec/(1e-15+tf.norm(gru_state_dec, axis=-1,keepdims=True)) -gru_state_dec = gru_state_dec[:,-1,:] -dec_out = decoder([bits[:,1::2,:], gru_state_dec]) - -print(dec_out.shape) - -dec_out.numpy().astype('float32').tofile(args.output + "-quant_out.f32") diff --git a/dnn/training_tf2/fec_encoder.py b/dnn/training_tf2/fec_encoder.py deleted file mode 100644 index 15ef12b2c..000000000 --- a/dnn/training_tf2/fec_encoder.py +++ /dev/null @@ -1,256 +0,0 @@ -""" -/* Copyright (c) 2022 Amazon - Written by Jan Buethe and Jean-Marc Valin */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -""" -import os -import subprocess -import argparse - - -import numpy as np -from scipy.io import wavfile -import tensorflow as tf - -from rdovae import new_rdovae_model, pvq_quantize, apply_dead_zone, sq_rate_metric -from fec_packets import write_fec_packets, read_fec_packets - - -debug = False - -if debug: - args = type('dummy', (object,), - { - 'input' : 'item1.wav', - 'weights' : 'testout/rdovae_alignment_fix_1024_120.h5', - 'enc_lambda' : 0.0007, - 'output' : "test_0007.fec", - 'cond_size' : 1024, - 'num_redundancy_frames' : 64, - 'extra_delay' : 0, - 'dump_data' : './dump_data' - })() - os.environ['CUDA_VISIBLE_DEVICES']="" -else: - parser = argparse.ArgumentParser(description='Encode redundancy for Opus neural FEC. Designed for use with voip application and 20ms frames') - - parser.add_argument('input', metavar='', help='audio input (.wav or .raw or .pcm as int16)') - parser.add_argument('weights', metavar='', help='trained model file (.h5)') -# parser.add_argument('enc_lambda', metavar='', type=float, help='lambda for controlling encoder rate') - parser.add_argument('output', type=str, help='output file (will be extended with .fec)') - - parser.add_argument('--dump-data', type=str, default='./dump_data', help='path to dump data executable (default ./dump_data)') - parser.add_argument('--cond-size', metavar='', default=1024, type=int, help='number of units in conditioning network (default 1024)') - parser.add_argument('--quant-levels', type=int, help="number of quantization steps (default: 40)", default=40) - parser.add_argument('--num-redundancy-frames', default=64, type=int, help='number of redundancy frames (20ms) per packet (default 64)') - parser.add_argument('--extra-delay', default=0, type=int, help="last features in packet are calculated with the decoder aligned samples, use this option to add extra delay (in samples at 16kHz)") - parser.add_argument('--lossfile', type=str, help='file containing loss trace (0 for frame received, 1 for lost)') - - parser.add_argument('--debug-output', action='store_true', help='if set, differently assembled features are written to disk') - - args = parser.parse_args() - -model, encoder, decoder, qembedding = new_rdovae_model(nb_used_features=20, nb_bits=80, batch_size=1, nb_quant=args.quant_levels, cond_size=args.cond_size) -model.load_weights(args.weights) - -lpc_order = 16 - -## prepare input signal -# SILK frame size is 20ms and LPCNet subframes are 10ms -subframe_size = 160 -frame_size = 2 * subframe_size - -# 91 samples delay to align with SILK decoded frames -silk_delay = 91 - -# prepend zeros to have enough history to produce the first package -zero_history = (args.num_redundancy_frames - 1) * frame_size - -# dump data has a (feature) delay of 10ms -dump_data_delay = 160 - -total_delay = silk_delay + zero_history + args.extra_delay - dump_data_delay - -# load signal -if args.input.endswith('.raw') or args.input.endswith('.pcm') or args.input.endswith('.sw'): - signal = np.fromfile(args.input, dtype='int16') - -elif args.input.endswith('.wav'): - fs, signal = wavfile.read(args.input) -else: - raise ValueError(f'unknown input signal format: {args.input}') - -# fill up last frame with zeros -padded_signal_length = len(signal) + total_delay -tail = padded_signal_length % frame_size -right_padding = (frame_size - tail) % frame_size - -signal = np.concatenate((np.zeros(total_delay, dtype=np.int16), signal, np.zeros(right_padding, dtype=np.int16))) - -padded_signal_file = os.path.splitext(args.input)[0] + '_padded.raw' -signal.tofile(padded_signal_file) - -# write signal and call dump_data to create features - -feature_file = os.path.splitext(args.input)[0] + '_features.f32' -command = f"{args.dump_data} -test {padded_signal_file} {feature_file}" -r = subprocess.run(command, shell=True) -if r.returncode != 0: - raise RuntimeError(f"command '{command}' failed with exit code {r.returncode}") - -# load features -nb_features = model.nb_used_features + lpc_order -nb_used_features = model.nb_used_features - -# load features -features = np.fromfile(feature_file, dtype='float32') -num_subframes = len(features) // nb_features -num_subframes = 2 * (num_subframes // 2) -num_frames = num_subframes // 2 - -features = np.reshape(features, (1, -1, nb_features)) -features = features[:, :, :nb_used_features] -features = features[:, :num_subframes, :] - -#variable quantizer depending on the delay -q0 = 3 -q1 = 15 -quant_id = np.round(q1 + (q0-q1)*np.arange(args.num_redundancy_frames//2)/args.num_redundancy_frames).astype('int16') -#print(quant_id) - -quant_embed = qembedding(quant_id) - -# run encoder -print("running fec encoder...") -symbols, gru_state_dec = encoder.predict(features) - -# apply quantization -nsymbols = 80 -quant_scale = tf.math.softplus(quant_embed[:, :nsymbols]).numpy() -dead_zone = tf.math.softplus(quant_embed[:, nsymbols : 2 * nsymbols]).numpy() -#symbols = apply_dead_zone([symbols, dead_zone]).numpy() -#qsymbols = np.round(symbols) -quant_gru_state_dec = pvq_quantize(gru_state_dec, 82) - -# rate estimate -hard_distr_embed = tf.math.sigmoid(quant_embed[:, 4 * nsymbols : ]).numpy() -#rate_input = np.concatenate((qsymbols, hard_distr_embed, enc_lambda), axis=-1) -#rates = sq_rate_metric(None, rate_input, reduce=False).numpy() - -# run decoder -input_length = args.num_redundancy_frames // 2 -offset = args.num_redundancy_frames - 1 - -packets = [] -packet_sizes = [] - -sym_batch = np.zeros((num_frames-offset, args.num_redundancy_frames//2, nsymbols), dtype='float32') -quant_state = quant_gru_state_dec[0, offset:num_frames, :] -#pack symbols for batch processing -for i in range(offset, num_frames): - sym_batch[i-offset, :, :] = symbols[0, i - 2 * input_length + 2 : i + 1 : 2, :] - -#quantize symbols -sym_batch = sym_batch * quant_scale -sym_batch = apply_dead_zone([sym_batch, dead_zone]).numpy() -sym_batch = np.round(sym_batch) - -hard_distr_embed = np.broadcast_to(hard_distr_embed, (sym_batch.shape[0], sym_batch.shape[1], 2*sym_batch.shape[2])) -fake_lambda = np.ones((sym_batch.shape[0], sym_batch.shape[1], 1), dtype='float32') -rate_input = np.concatenate((sym_batch, hard_distr_embed, fake_lambda), axis=-1) -rates = sq_rate_metric(None, rate_input, reduce=False).numpy() -#print(rates.shape) -print("average rate = ", np.mean(rates[args.num_redundancy_frames:,:])) - -#sym_batch.tofile('qsyms.f32') - -sym_batch = sym_batch / quant_scale -#print(sym_batch.shape, quant_state.shape) -#features = decoder.predict([sym_batch, quant_state]) -features = decoder([sym_batch, quant_state]) - -#for i in range(offset, num_frames): -# print(f"processing frame {i - offset}...") -# features = decoder.predict([qsymbols[:, i - 2 * input_length + 2 : i + 1 : 2, :], quant_embed_dec[:, i - 2 * input_length + 2 : i + 1 : 2, :], quant_gru_state_dec[:, i, :]]) -# packets.append(features) -# packet_size = 8 * int((np.sum(rates[:, i - 2 * input_length + 2 : i + 1 : 2]) + 7) / 8) + 64 -# packet_sizes.append(packet_size) - - -# write packets -packet_file = args.output + '.fec' if not args.output.endswith('.fec') else args.output -#write_fec_packets(packet_file, packets, packet_sizes) - - -#print(f"average redundancy rate: {int(round(sum(packet_sizes) / len(packet_sizes) * 50 / 1000))} kbps") - -if args.lossfile != None: - loss = np.loadtxt(args.lossfile, dtype='int16') - fec_out = np.zeros((features.shape[0]*2, features.shape[-1]), dtype='float32') - foffset = -2 - ptr = 0; - count = 2; - for i in range(features.shape[0]): - if (loss[i] == 0) or (i == features.shape[0]-1): - fec_out[ptr:ptr+count,:] = features[i, foffset:, :] - #print("filled ", count) - foffset = -2 - ptr = ptr+count - count = 2 - else: - count = count + 2 - foffset = foffset - 2 - - fec_out_full = np.zeros((fec_out.shape[0], nb_features), dtype=np.float32) - fec_out_full[:, :nb_used_features] = fec_out - - fec_out_full.tofile(packet_file[:-4] + f'_fec.f32') - - -#create packets array like in the original version for debugging purposes -for i in range(offset, num_frames): - packets.append(features[i-offset:i-offset+1, :, :]) - -if args.debug_output: - import itertools - - #batches = [2, 4] - batches = [4] - #offsets = [0, 4, 20] - offsets = [0, (args.num_redundancy_frames - 2)*2] - # sanity checks - # 1. concatenate features at offset 0 - for batch, offset in itertools.product(batches, offsets): - - stop = packets[0].shape[1] - offset - print(batch, offset, stop) - test_features = np.concatenate([packet[:,stop - batch: stop, :] for packet in packets[::batch//2]], axis=1) - - test_features_full = np.zeros((test_features.shape[1], nb_features), dtype=np.float32) - test_features_full[:, :nb_used_features] = test_features[0, :, :] - - print(f"writing debug output {packet_file[:-4] + f'_tf_batch{batch}_offset{offset}.f32'}") - test_features_full.tofile(packet_file[:-4] + f'_tf_batch{batch}_offset{offset}.f32') diff --git a/dnn/training_tf2/fec_packets.c b/dnn/training_tf2/fec_packets.c deleted file mode 100644 index ee08ba95c..000000000 --- a/dnn/training_tf2/fec_packets.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright (c) 2022 Amazon - Written by Jan Buethe */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include - -#include "fec_packets.h" - -int get_fec_frame(const char * const filename, float *features, int packet_index, int subframe_index) -{ - - int16_t version; - int16_t header_size; - int16_t num_packets; - int16_t packet_size; - int16_t subframe_size; - int16_t subframes_per_packet; - int16_t num_features; - long offset; - - FILE *fid = fopen(filename, "rb"); - - /* read header */ - if (fread(&version, sizeof(version), 1, fid) != 1) goto error; - if (fread(&header_size, sizeof(header_size), 1, fid) != 1) goto error; - if (fread(&num_packets, sizeof(num_packets), 1, fid) != 1) goto error; - if (fread(&packet_size, sizeof(packet_size), 1, fid) != 1) goto error; - if (fread(&subframe_size, sizeof(subframe_size), 1, fid) != 1) goto error; - if (fread(&subframes_per_packet, sizeof(subframes_per_packet), 1, fid) != 1) goto error; - if (fread(&num_features, sizeof(num_features), 1, fid) != 1) goto error; - - /* check if indices are valid */ - if (packet_index >= num_packets || subframe_index >= subframes_per_packet) - { - fprintf(stderr, "get_fec_frame: index out of bounds\n"); - goto error; - } - - /* calculate offset in file (+ 2 is for rate) */ - offset = header_size + packet_index * packet_size + 2 + subframe_index * subframe_size; - fseek(fid, offset, SEEK_SET); - - /* read features */ - if (fread(features, sizeof(*features), num_features, fid) != num_features) goto error; - - fclose(fid); - return 0; - -error: - fclose(fid); - return 1; -} - -int get_fec_rate(const char * const filename, int packet_index) -{ - int16_t version; - int16_t header_size; - int16_t num_packets; - int16_t packet_size; - int16_t subframe_size; - int16_t subframes_per_packet; - int16_t num_features; - long offset; - int16_t rate; - - FILE *fid = fopen(filename, "rb"); - - /* read header */ - if (fread(&version, sizeof(version), 1, fid) != 1) goto error; - if (fread(&header_size, sizeof(header_size), 1, fid) != 1) goto error; - if (fread(&num_packets, sizeof(num_packets), 1, fid) != 1) goto error; - if (fread(&packet_size, sizeof(packet_size), 1, fid) != 1) goto error; - if (fread(&subframe_size, sizeof(subframe_size), 1, fid) != 1) goto error; - if (fread(&subframes_per_packet, sizeof(subframes_per_packet), 1, fid) != 1) goto error; - if (fread(&num_features, sizeof(num_features), 1, fid) != 1) goto error; - - /* check if indices are valid */ - if (packet_index >= num_packets) - { - fprintf(stderr, "get_fec_rate: index out of bounds\n"); - goto error; - } - - /* calculate offset in file (+ 2 is for rate) */ - offset = header_size + packet_index * packet_size; - fseek(fid, offset, SEEK_SET); - - /* read rate */ - if (fread(&rate, sizeof(rate), 1, fid) != 1) goto error; - - fclose(fid); - return (int) rate; - -error: - fclose(fid); - return -1; -} - -#if 0 -int main() -{ - float features[20]; - int i; - - if (get_fec_frame("../test.fec", &features[0], 0, 127)) - { - return 1; - } - - for (i = 0; i < 20; i ++) - { - printf("%d %f\n", i, features[i]); - } - - printf("rate: %d\n", get_fec_rate("../test.fec", 0)); - -} -#endif \ No newline at end of file diff --git a/dnn/training_tf2/fec_packets.h b/dnn/training_tf2/fec_packets.h deleted file mode 100644 index 01b128b17..000000000 --- a/dnn/training_tf2/fec_packets.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2022 Amazon - Written by Jan Buethe */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FEC_PACKETS_H -#define FEC_PACKETS_H - -int get_fec_frame(const char * const filename, float *features, int packet_index, int subframe_index); -int get_fec_rate(const char * const filename, int packet_index); - -#endif diff --git a/dnn/training_tf2/fec_packets.py b/dnn/training_tf2/fec_packets.py deleted file mode 100644 index 6acbe9d2c..000000000 --- a/dnn/training_tf2/fec_packets.py +++ /dev/null @@ -1,108 +0,0 @@ -""" -/* Copyright (c) 2022 Amazon - Written by Jan Buethe */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -""" - -import numpy as np - - - -def write_fec_packets(filename, packets, rates=None): - """ writes packets in binary format """ - - assert np.dtype(np.float32).itemsize == 4 - assert np.dtype(np.int16).itemsize == 2 - - # derive some sizes - num_packets = len(packets) - subframes_per_packet = packets[0].shape[-2] - num_features = packets[0].shape[-1] - - # size of float is 4 - subframe_size = num_features * 4 - packet_size = subframe_size * subframes_per_packet + 2 # two bytes for rate - - version = 1 - # header size (version, header_size, num_packets, packet_size, subframe_size, subrames_per_packet, num_features) - header_size = 14 - - with open(filename, 'wb') as f: - - # header - f.write(np.int16(version).tobytes()) - f.write(np.int16(header_size).tobytes()) - f.write(np.int16(num_packets).tobytes()) - f.write(np.int16(packet_size).tobytes()) - f.write(np.int16(subframe_size).tobytes()) - f.write(np.int16(subframes_per_packet).tobytes()) - f.write(np.int16(num_features).tobytes()) - - # packets - for i, packet in enumerate(packets): - if type(rates) == type(None): - rate = 0 - else: - rate = rates[i] - - f.write(np.int16(rate).tobytes()) - - features = np.flip(packet, axis=-2) - f.write(features.astype(np.float32).tobytes()) - - -def read_fec_packets(filename): - """ reads packets from binary format """ - - assert np.dtype(np.float32).itemsize == 4 - assert np.dtype(np.int16).itemsize == 2 - - with open(filename, 'rb') as f: - - # header - version = np.frombuffer(f.read(2), dtype=np.int16).item() - header_size = np.frombuffer(f.read(2), dtype=np.int16).item() - num_packets = np.frombuffer(f.read(2), dtype=np.int16).item() - packet_size = np.frombuffer(f.read(2), dtype=np.int16).item() - subframe_size = np.frombuffer(f.read(2), dtype=np.int16).item() - subframes_per_packet = np.frombuffer(f.read(2), dtype=np.int16).item() - num_features = np.frombuffer(f.read(2), dtype=np.int16).item() - - dummy_features = np.zeros((1, subframes_per_packet, num_features), dtype=np.float32) - - # packets - rates = [] - packets = [] - for i in range(num_packets): - - rate = np.frombuffer(f.read(2), dtype=np.int16).item - rates.append(rate) - - features = np.reshape(np.frombuffer(f.read(subframe_size * subframes_per_packet), dtype=np.float32), dummy_features.shape) - packet = np.flip(features, axis=-2) - packets.append(packet) - - return packets \ No newline at end of file diff --git a/dnn/training_tf2/keraslayerdump.py b/dnn/training_tf2/keraslayerdump.py deleted file mode 100644 index 5abc1488e..000000000 --- a/dnn/training_tf2/keraslayerdump.py +++ /dev/null @@ -1,189 +0,0 @@ -'''Copyright (c) 2017-2018 Mozilla - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' - -""" helper functions for dumping some Keras layers to C files """ - -import numpy as np - - -def printVector(f, vector, name, dtype='float', dotp=False, static=True): - """ prints vector as one-dimensional C array """ - if dotp: - vector = vector.reshape((vector.shape[0]//4, 4, vector.shape[1]//8, 8)) - vector = vector.transpose((2, 0, 3, 1)) - v = np.reshape(vector, (-1)) - if static: - f.write('static const {} {}[{}] = {{\n '.format(dtype, name, len(v))) - else: - f.write('const {} {}[{}] = {{\n '.format(dtype, name, len(v))) - for i in range(0, len(v)): - f.write('{}'.format(v[i])) - if (i!=len(v)-1): - f.write(',') - else: - break; - if (i%8==7): - f.write("\n ") - else: - f.write(" ") - f.write('\n};\n\n') - return vector - -def printSparseVector(f, A, name, have_diag=True): - N = A.shape[0] - M = A.shape[1] - W = np.zeros((0,), dtype='int') - W0 = np.zeros((0,)) - if have_diag: - diag = np.concatenate([np.diag(A[:,:N]), np.diag(A[:,N:2*N]), np.diag(A[:,2*N:])]) - A[:,:N] = A[:,:N] - np.diag(np.diag(A[:,:N])) - A[:,N:2*N] = A[:,N:2*N] - np.diag(np.diag(A[:,N:2*N])) - A[:,2*N:] = A[:,2*N:] - np.diag(np.diag(A[:,2*N:])) - printVector(f, diag, name + '_diag') - AQ = np.minimum(127, np.maximum(-128, np.round(A*128))).astype('int') - idx = np.zeros((0,), dtype='int') - for i in range(M//8): - pos = idx.shape[0] - idx = np.append(idx, -1) - nb_nonzero = 0 - for j in range(N//4): - block = A[j*4:(j+1)*4, i*8:(i+1)*8] - qblock = AQ[j*4:(j+1)*4, i*8:(i+1)*8] - if np.sum(np.abs(block)) > 1e-10: - nb_nonzero = nb_nonzero + 1 - idx = np.append(idx, j*4) - vblock = qblock.transpose((1,0)).reshape((-1,)) - W0 = np.concatenate([W0, block.reshape((-1,))]) - W = np.concatenate([W, vblock]) - idx[pos] = nb_nonzero - f.write('#ifdef DOT_PROD\n') - printVector(f, W, name, dtype='qweight') - f.write('#else /*DOT_PROD*/\n') - printVector(f, W0, name, dtype='qweight') - f.write('#endif /*DOT_PROD*/\n') - printVector(f, idx, name + '_idx', dtype='int') - return AQ - -def dump_sparse_gru(self, f, hf): - name = 'sparse_' + self.name - print("printing layer " + name + " of type sparse " + self.__class__.__name__) - weights = self.get_weights() - qweights = printSparseVector(f, weights[1], name + '_recurrent_weights') - printVector(f, weights[-1], name + '_bias') - subias = weights[-1].copy() - subias[1,:] = subias[1,:] - np.sum(qweights*(1./128),axis=0) - printVector(f, subias, name + '_subias') - if hasattr(self, 'activation'): - activation = self.activation.__name__.upper() - else: - activation = 'TANH' - if hasattr(self, 'reset_after') and not self.reset_after: - reset_after = 0 - else: - reset_after = 1 - neurons = weights[0].shape[1]//3 - max_rnn_neurons = neurons - f.write('const SparseGRULayer {} = {{\n {}_bias,\n {}_subias,\n {}_recurrent_weights_diag,\n {}_recurrent_weights,\n {}_recurrent_weights_idx,\n {}, ACTIVATION_{}, {}\n}};\n\n' - .format(name, name, name, name, name, name, weights[0].shape[1]//3, activation, reset_after)) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('extern const SparseGRULayer {};\n\n'.format(name)); - return max_rnn_neurons - -def dump_gru_layer(self, f, hf, dotp=False, sparse=False): - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - if sparse: - qweight = printSparseVector(f, weights[0], name + '_weights', have_diag=False) - else: - qweight = printVector(f, weights[0], name + '_weights') - - if dotp: - f.write('#ifdef DOT_PROD\n') - qweight2 = np.clip(np.round(128.*weights[1]).astype('int'), -128, 127) - printVector(f, qweight2, name + '_recurrent_weights', dotp=True, dtype='qweight') - f.write('#else /*DOT_PROD*/\n') - else: - qweight2 = weights[1] - - printVector(f, weights[1], name + '_recurrent_weights') - if dotp: - f.write('#endif /*DOT_PROD*/\n') - - printVector(f, weights[-1], name + '_bias') - subias = weights[-1].copy() - subias[0,:] = subias[0,:] - np.sum(qweight*(1./128.),axis=0) - subias[1,:] = subias[1,:] - np.sum(qweight2*(1./128.),axis=0) - printVector(f, subias, name + '_subias') - if hasattr(self, 'activation'): - activation = self.activation.__name__.upper() - else: - activation = 'TANH' - if hasattr(self, 'reset_after') and not self.reset_after: - reset_after = 0 - else: - reset_after = 1 - neurons = weights[0].shape[1]//3 - max_rnn_neurons = neurons - f.write('const GRULayer {} = {{\n {}_bias,\n {}_subias,\n {}_weights,\n {},\n {}_recurrent_weights,\n {}, {}, ACTIVATION_{}, {}\n}};\n\n' - .format(name, name, name, name, name + "_weights_idx" if sparse else "NULL", name, weights[0].shape[0], weights[0].shape[1]//3, activation, reset_after)) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('extern const GRULayer {};\n\n'.format(name)); - return max_rnn_neurons - -def dump_dense_layer_impl(name, weights, bias, activation, f, hf): - printVector(f, weights, name + '_weights') - printVector(f, bias, name + '_bias') - f.write('const DenseLayer {} = {{\n {}_bias,\n {}_weights,\n {}, {}, ACTIVATION_{}\n}};\n\n' - .format(name, name, name, weights.shape[0], weights.shape[1], activation)) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights.shape[1])) - hf.write('extern const DenseLayer {};\n\n'.format(name)); - -def dump_dense_layer(self, f, hf): - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - activation = self.activation.__name__.upper() - dump_dense_layer_impl(name, weights[0], weights[1], activation, f, hf) - return False - -def dump_conv1d_layer(self, f, hf): - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - printVector(f, weights[0], name + '_weights') - printVector(f, weights[-1], name + '_bias') - activation = self.activation.__name__.upper() - max_conv_inputs = weights[0].shape[1]*weights[0].shape[0] - f.write('const Conv1DLayer {} = {{\n {}_bias,\n {}_weights,\n {}, {}, {}, ACTIVATION_{}\n}};\n\n' - .format(name, name, name, weights[0].shape[1], weights[0].shape[0], weights[0].shape[2], activation)) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[2])) - hf.write('#define {}_STATE_SIZE ({}*{})\n'.format(name.upper(), weights[0].shape[1], (weights[0].shape[0]-1))) - hf.write('#define {}_DELAY {}\n'.format(name.upper(), (weights[0].shape[0]-1)//2)) - hf.write('extern const Conv1DLayer {};\n\n'.format(name)); - return max_conv_inputs diff --git a/dnn/training_tf2/lossfuncs.py b/dnn/training_tf2/lossfuncs.py deleted file mode 100644 index 78be1fd61..000000000 --- a/dnn/training_tf2/lossfuncs.py +++ /dev/null @@ -1,99 +0,0 @@ -""" -Custom Loss functions and metrics for training/analysis -""" - -from tf_funcs import * -import tensorflow as tf - -# The following loss functions all expect the lpcnet model to output the lpc prediction - -# Computing the excitation by subtracting the lpc prediction from the target, followed by minimizing the cross entropy -def res_from_sigloss(): - def loss(y_true,y_pred): - p = y_pred[:,:,0:1] - model_out = y_pred[:,:,2:] - e_gt = tf_l2u(y_true - p) - e_gt = tf.round(e_gt) - e_gt = tf.cast(e_gt,'int32') - sparse_cel = tf.keras.losses.SparseCategoricalCrossentropy(reduction=tf.keras.losses.Reduction.NONE)(e_gt,model_out) - return sparse_cel - return loss - -# Interpolated and Compensated Loss (In case of end to end lpcnet) -# Interpolates between adjacent embeddings based on the fractional value of the excitation computed (similar to the embedding interpolation) -# Also adds a probability compensation (to account for matching cross entropy in the linear domain), weighted by gamma -def interp_mulaw(gamma = 1): - def loss(y_true,y_pred): - y_true = tf.cast(y_true, 'float32') - p = y_pred[:,:,0:1] - real_p = y_pred[:,:,1:2] - model_out = y_pred[:,:,2:] - e_gt = tf_l2u(y_true - p) - exc_gt = tf_l2u(y_true - real_p) - prob_compensation = tf.squeeze((K.abs(e_gt - 128)/128.0)*K.log(256.0)) - regularization = tf.squeeze((K.abs(exc_gt - 128)/128.0)*K.log(256.0)) - alpha = e_gt - tf.math.floor(e_gt) - alpha = tf.tile(alpha,[1,1,256]) - e_gt = tf.cast(e_gt,'int32') - e_gt = tf.clip_by_value(e_gt,0,254) - interp_probab = (1 - alpha)*model_out + alpha*tf.roll(model_out,shift = -1,axis = -1) - sparse_cel = tf.keras.losses.SparseCategoricalCrossentropy(reduction=tf.keras.losses.Reduction.NONE)(e_gt,interp_probab) - loss_mod = sparse_cel + prob_compensation + gamma*regularization - return loss_mod - return loss - -# Same as above, except a metric -def metric_oginterploss(y_true,y_pred): - p = y_pred[:,:,0:1] - model_out = y_pred[:,:,2:] - e_gt = tf_l2u(y_true - p) - prob_compensation = tf.squeeze((K.abs(e_gt - 128)/128.0)*K.log(256.0)) - alpha = e_gt - tf.math.floor(e_gt) - alpha = tf.tile(alpha,[1,1,256]) - e_gt = tf.cast(e_gt,'int32') - e_gt = tf.clip_by_value(e_gt,0,254) - interp_probab = (1 - alpha)*model_out + alpha*tf.roll(model_out,shift = -1,axis = -1) - sparse_cel = tf.keras.losses.SparseCategoricalCrossentropy(reduction=tf.keras.losses.Reduction.NONE)(e_gt,interp_probab) - loss_mod = sparse_cel + prob_compensation - return loss_mod - -# Interpolated cross entropy loss metric -def metric_icel(y_true, y_pred): - p = y_pred[:,:,0:1] - model_out = y_pred[:,:,2:] - e_gt = tf_l2u(y_true - p) - alpha = e_gt - tf.math.floor(e_gt) - alpha = tf.tile(alpha,[1,1,256]) - e_gt = tf.cast(e_gt,'int32') - e_gt = tf.clip_by_value(e_gt,0,254) #Check direction - interp_probab = (1 - alpha)*model_out + alpha*tf.roll(model_out,shift = -1,axis = -1) - sparse_cel = tf.keras.losses.SparseCategoricalCrossentropy(reduction=tf.keras.losses.Reduction.NONE)(e_gt,interp_probab) - return sparse_cel - -# Non-interpolated (rounded) cross entropy loss metric -def metric_cel(y_true, y_pred): - y_true = tf.cast(y_true, 'float32') - p = y_pred[:,:,0:1] - model_out = y_pred[:,:,2:] - e_gt = tf_l2u(y_true - p) - e_gt = tf.round(e_gt) - e_gt = tf.cast(e_gt,'int32') - e_gt = tf.clip_by_value(e_gt,0,255) - sparse_cel = tf.keras.losses.SparseCategoricalCrossentropy(reduction=tf.keras.losses.Reduction.NONE)(e_gt,model_out) - return sparse_cel - -# Variance metric of the output excitation -def metric_exc_sd(y_true,y_pred): - p = y_pred[:,:,0:1] - e_gt = tf_l2u(y_true - p) - sd_egt = tf.keras.losses.MeanSquaredError(reduction=tf.keras.losses.Reduction.NONE)(e_gt,128) - return sd_egt - -def loss_matchlar(): - def loss(y_true,y_pred): - model_rc = y_pred[:,:,:16] - #y_true = lpc2rc(y_true) - loss_lar_diff = K.log((1.01 + model_rc)/(1.01 - model_rc)) - K.log((1.01 + y_true)/(1.01 - y_true)) - loss_lar_diff = tf.square(loss_lar_diff) - return tf.reduce_mean(loss_lar_diff, axis=-1) - return loss diff --git a/dnn/training_tf2/lpcnet.py b/dnn/training_tf2/lpcnet.py deleted file mode 100644 index 497f75722..000000000 --- a/dnn/training_tf2/lpcnet.py +++ /dev/null @@ -1,339 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2018 Mozilla - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' - -import math -import tensorflow as tf -from tensorflow.keras.models import Model -from tensorflow.keras.layers import Input, GRU, Dense, Embedding, Reshape, Concatenate, Lambda, Conv1D, Multiply, Add, Bidirectional, MaxPooling1D, Activation, GaussianNoise -from tensorflow.compat.v1.keras.layers import CuDNNGRU -from tensorflow.keras import backend as K -from tensorflow.keras.constraints import Constraint -from tensorflow.keras.initializers import Initializer -from tensorflow.keras.callbacks import Callback -from mdense import MDense -import numpy as np -import h5py -import sys -from tf_funcs import * -from diffembed import diff_Embed -from parameters import set_parameter - -frame_size = 160 -pcm_bits = 8 -embed_size = 128 -pcm_levels = 2**pcm_bits - -def interleave(p, samples): - p2=tf.expand_dims(p, 3) - nb_repeats = pcm_levels//(2*p.shape[2]) - p3 = tf.reshape(tf.repeat(tf.concat([1-p2, p2], 3), nb_repeats), (-1, samples, pcm_levels)) - return p3 - -def tree_to_pdf(p, samples): - return interleave(p[:,:,1:2], samples) * interleave(p[:,:,2:4], samples) * interleave(p[:,:,4:8], samples) * interleave(p[:,:,8:16], samples) \ - * interleave(p[:,:,16:32], samples) * interleave(p[:,:,32:64], samples) * interleave(p[:,:,64:128], samples) * interleave(p[:,:,128:256], samples) - -def tree_to_pdf_train(p): - #FIXME: try not to hardcode the 2400 samples (15 frames * 160 samples/frame) - return tree_to_pdf(p, 2400) - -def tree_to_pdf_infer(p): - return tree_to_pdf(p, 1) - -def quant_regularizer(x): - Q = 128 - Q_1 = 1./Q - #return .01 * tf.reduce_mean(1 - tf.math.cos(2*3.1415926535897931*(Q*x-tf.round(Q*x)))) - return .01 * tf.reduce_mean(K.sqrt(K.sqrt(1.0001 - tf.math.cos(2*3.1415926535897931*(Q*x-tf.round(Q*x)))))) - -class Sparsify(Callback): - def __init__(self, t_start, t_end, interval, density, quantize=False): - super(Sparsify, self).__init__() - self.batch = 0 - self.t_start = t_start - self.t_end = t_end - self.interval = interval - self.final_density = density - self.quantize = quantize - - def on_batch_end(self, batch, logs=None): - #print("batch number", self.batch) - self.batch += 1 - if self.quantize or (self.batch > self.t_start and (self.batch-self.t_start) % self.interval == 0) or self.batch >= self.t_end: - #print("constrain"); - layer = self.model.get_layer('gru_a') - w = layer.get_weights() - p = w[1] - nb = p.shape[1]//p.shape[0] - N = p.shape[0] - #print("nb = ", nb, ", N = ", N); - #print(p.shape) - #print ("density = ", density) - for k in range(nb): - density = self.final_density[k] - if self.batch < self.t_end and not self.quantize: - r = 1 - (self.batch-self.t_start)/(self.t_end - self.t_start) - density = 1 - (1-self.final_density[k])*(1 - r*r*r) - A = p[:, k*N:(k+1)*N] - A = A - np.diag(np.diag(A)) - #This is needed because of the CuDNNGRU strange weight ordering - A = np.transpose(A, (1, 0)) - L=np.reshape(A, (N//4, 4, N//8, 8)) - S=np.sum(L*L, axis=-1) - S=np.sum(S, axis=1) - SS=np.sort(np.reshape(S, (-1,))) - thresh = SS[round(N*N//32*(1-density))] - mask = (S>=thresh).astype('float32') - mask = np.repeat(mask, 4, axis=0) - mask = np.repeat(mask, 8, axis=1) - mask = np.minimum(1, mask + np.diag(np.ones((N,)))) - #This is needed because of the CuDNNGRU strange weight ordering - mask = np.transpose(mask, (1, 0)) - p[:, k*N:(k+1)*N] = p[:, k*N:(k+1)*N]*mask - #print(thresh, np.mean(mask)) - if self.quantize and ((self.batch > self.t_start and (self.batch-self.t_start) % self.interval == 0) or self.batch >= self.t_end): - if self.batch < self.t_end: - threshold = .5*(self.batch - self.t_start)/(self.t_end - self.t_start) - else: - threshold = .5 - quant = np.round(p*128.) - res = p*128.-quant - mask = (np.abs(res) <= threshold).astype('float32') - p = mask/128.*quant + (1-mask)*p - - w[1] = p - layer.set_weights(w) - -class SparsifyGRUB(Callback): - def __init__(self, t_start, t_end, interval, grua_units, density, quantize=False): - super(SparsifyGRUB, self).__init__() - self.batch = 0 - self.t_start = t_start - self.t_end = t_end - self.interval = interval - self.final_density = density - self.grua_units = grua_units - self.quantize = quantize - - def on_batch_end(self, batch, logs=None): - #print("batch number", self.batch) - self.batch += 1 - if self.quantize or (self.batch > self.t_start and (self.batch-self.t_start) % self.interval == 0) or self.batch >= self.t_end: - #print("constrain"); - layer = self.model.get_layer('gru_b') - w = layer.get_weights() - p = w[0] - N = p.shape[0] - M = p.shape[1]//3 - for k in range(3): - density = self.final_density[k] - if self.batch < self.t_end and not self.quantize: - r = 1 - (self.batch-self.t_start)/(self.t_end - self.t_start) - density = 1 - (1-self.final_density[k])*(1 - r*r*r) - A = p[:, k*M:(k+1)*M] - #This is needed because of the CuDNNGRU strange weight ordering - A = np.reshape(A, (M, N)) - A = np.transpose(A, (1, 0)) - N2 = self.grua_units - A2 = A[:N2, :] - L=np.reshape(A2, (N2//4, 4, M//8, 8)) - S=np.sum(L*L, axis=-1) - S=np.sum(S, axis=1) - SS=np.sort(np.reshape(S, (-1,))) - thresh = SS[round(M*N2//32*(1-density))] - mask = (S>=thresh).astype('float32') - mask = np.repeat(mask, 4, axis=0) - mask = np.repeat(mask, 8, axis=1) - A = np.concatenate([A2*mask, A[N2:,:]], axis=0) - #This is needed because of the CuDNNGRU strange weight ordering - A = np.transpose(A, (1, 0)) - A = np.reshape(A, (N, M)) - p[:, k*M:(k+1)*M] = A - #print(thresh, np.mean(mask)) - if self.quantize and ((self.batch > self.t_start and (self.batch-self.t_start) % self.interval == 0) or self.batch >= self.t_end): - if self.batch < self.t_end: - threshold = .5*(self.batch - self.t_start)/(self.t_end - self.t_start) - else: - threshold = .5 - quant = np.round(p*128.) - res = p*128.-quant - mask = (np.abs(res) <= threshold).astype('float32') - p = mask/128.*quant + (1-mask)*p - - w[0] = p - layer.set_weights(w) - - -class PCMInit(Initializer): - def __init__(self, gain=.1, seed=None): - self.gain = gain - self.seed = seed - - def __call__(self, shape, dtype=None): - num_rows = 1 - for dim in shape[:-1]: - num_rows *= dim - num_cols = shape[-1] - flat_shape = (num_rows, num_cols) - if self.seed is not None: - np.random.seed(self.seed) - a = np.random.uniform(-1.7321, 1.7321, flat_shape) - #a[:,0] = math.sqrt(12)*np.arange(-.5*num_rows+.5,.5*num_rows-.4)/num_rows - #a[:,1] = .5*a[:,0]*a[:,0]*a[:,0] - a = a + np.reshape(math.sqrt(12)*np.arange(-.5*num_rows+.5,.5*num_rows-.4)/num_rows, (num_rows, 1)) - return self.gain * a.astype("float32") - - def get_config(self): - return { - 'gain': self.gain, - 'seed': self.seed - } - -class WeightClip(Constraint): - '''Clips the weights incident to each hidden unit to be inside a range - ''' - def __init__(self, c=2): - self.c = c - - def __call__(self, p): - # Ensure that abs of adjacent weights don't sum to more than 127. Otherwise there's a risk of - # saturation when implementing dot products with SSSE3 or AVX2. - return self.c*p/tf.maximum(self.c, tf.repeat(tf.abs(p[:, 1::2])+tf.abs(p[:, 0::2]), 2, axis=1)) - #return K.clip(p, -self.c, self.c) - - def get_config(self): - return {'name': self.__class__.__name__, - 'c': self.c} - -constraint = WeightClip(0.992) - -def new_lpcnet_model(rnn_units1=384, rnn_units2=16, nb_used_features=20, batch_size=128, training=False, adaptation=False, quantize=False, flag_e2e = False, cond_size=128, lpc_order=16, lpc_gamma=1., lookahead=2): - pcm = Input(shape=(None, 1), batch_size=batch_size) - dpcm = Input(shape=(None, 3), batch_size=batch_size) - feat = Input(shape=(None, nb_used_features), batch_size=batch_size) - pitch = Input(shape=(None, 1), batch_size=batch_size) - dec_feat = Input(shape=(None, cond_size)) - dec_state1 = Input(shape=(rnn_units1,)) - dec_state2 = Input(shape=(rnn_units2,)) - - padding = 'valid' if training else 'same' - fconv1 = Conv1D(cond_size, 3, padding=padding, activation='tanh', name='feature_conv1') - fconv2 = Conv1D(cond_size, 3, padding=padding, activation='tanh', name='feature_conv2') - pembed = Embedding(256, 64, name='embed_pitch') - cat_feat = Concatenate()([feat, Reshape((-1, 64))(pembed(pitch))]) - - cfeat = fconv2(fconv1(cat_feat)) - - fdense1 = Dense(cond_size, activation='tanh', name='feature_dense1') - fdense2 = Dense(cond_size, activation='tanh', name='feature_dense2') - - if flag_e2e and quantize: - fconv1.trainable = False - fconv2.trainable = False - fdense1.trainable = False - fdense2.trainable = False - - cfeat = fdense2(fdense1(cfeat)) - - error_calc = Lambda(lambda x: tf_l2u(x[0] - tf.roll(x[1],1,axis = 1))) - if flag_e2e: - lpcoeffs = diff_rc2lpc(name = "rc2lpc")(cfeat) - else: - lpcoeffs = Input(shape=(None, lpc_order), batch_size=batch_size) - - real_preds = diff_pred(name = "real_lpc2preds")([pcm,lpcoeffs]) - weighting = lpc_gamma ** np.arange(1, 17).astype('float32') - weighted_lpcoeffs = Lambda(lambda x: x[0]*x[1])([lpcoeffs, weighting]) - tensor_preds = diff_pred(name = "lpc2preds")([pcm,weighted_lpcoeffs]) - past_errors = error_calc([pcm,tensor_preds]) - - embed = diff_Embed(name='embed_sig',initializer = PCMInit()) - cpcm = Concatenate()([tf_l2u(pcm),tf_l2u(tensor_preds),past_errors]) - cpcm = GaussianNoise(.3)(cpcm) - cpcm = Reshape((-1, embed_size*3))(embed(cpcm)) - cpcm_decoder = Reshape((-1, embed_size*3))(embed(dpcm)) - - - rep = Lambda(lambda x: K.repeat_elements(x, frame_size, 1)) - - quant = quant_regularizer if quantize else None - - if training: - rnn = CuDNNGRU(rnn_units1, return_sequences=True, return_state=True, name='gru_a', stateful=True, - recurrent_constraint = constraint, recurrent_regularizer=quant) - rnn2 = CuDNNGRU(rnn_units2, return_sequences=True, return_state=True, name='gru_b', stateful=True, - kernel_constraint=constraint, recurrent_constraint = constraint, kernel_regularizer=quant, recurrent_regularizer=quant) - else: - rnn = GRU(rnn_units1, return_sequences=True, return_state=True, recurrent_activation="sigmoid", reset_after='true', name='gru_a', stateful=True, - recurrent_constraint = constraint, recurrent_regularizer=quant) - rnn2 = GRU(rnn_units2, return_sequences=True, return_state=True, recurrent_activation="sigmoid", reset_after='true', name='gru_b', stateful=True, - kernel_constraint=constraint, recurrent_constraint = constraint, kernel_regularizer=quant, recurrent_regularizer=quant) - - rnn_in = Concatenate()([cpcm, rep(cfeat)]) - md = MDense(pcm_levels, activation='sigmoid', name='dual_fc') - gru_out1, _ = rnn(rnn_in) - gru_out1 = GaussianNoise(.005)(gru_out1) - gru_out2, _ = rnn2(Concatenate()([gru_out1, rep(cfeat)])) - ulaw_prob = Lambda(tree_to_pdf_train)(md(gru_out2)) - - if adaptation: - rnn.trainable=False - rnn2.trainable=False - md.trainable=False - embed.Trainable=False - - m_out = Concatenate(name='pdf')([tensor_preds,real_preds,ulaw_prob]) - if not flag_e2e: - model = Model([pcm, feat, pitch, lpcoeffs], m_out) - else: - model = Model([pcm, feat, pitch], [m_out, cfeat]) - model.rnn_units1 = rnn_units1 - model.rnn_units2 = rnn_units2 - model.nb_used_features = nb_used_features - model.frame_size = frame_size - - if not flag_e2e: - encoder = Model([feat, pitch], cfeat) - dec_rnn_in = Concatenate()([cpcm_decoder, dec_feat]) - else: - encoder = Model([feat, pitch], [cfeat,lpcoeffs]) - dec_rnn_in = Concatenate()([cpcm_decoder, dec_feat]) - dec_gru_out1, state1 = rnn(dec_rnn_in, initial_state=dec_state1) - dec_gru_out2, state2 = rnn2(Concatenate()([dec_gru_out1, dec_feat]), initial_state=dec_state2) - dec_ulaw_prob = Lambda(tree_to_pdf_infer)(md(dec_gru_out2)) - - if flag_e2e: - decoder = Model([dpcm, dec_feat, dec_state1, dec_state2], [dec_ulaw_prob, state1, state2]) - else: - decoder = Model([dpcm, dec_feat, dec_state1, dec_state2], [dec_ulaw_prob, state1, state2]) - - # add parameters to model - set_parameter(model, 'lpc_gamma', lpc_gamma, dtype='float64') - set_parameter(model, 'flag_e2e', flag_e2e, dtype='bool') - set_parameter(model, 'lookahead', lookahead, dtype='int32') - - return model, encoder, decoder diff --git a/dnn/training_tf2/lpcnet_plc.py b/dnn/training_tf2/lpcnet_plc.py deleted file mode 100644 index 618e0084e..000000000 --- a/dnn/training_tf2/lpcnet_plc.py +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2021-2022 Amazon - Copyright (c) 2018-2019 Mozilla - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' - -import math -import tensorflow as tf -from tensorflow.keras.models import Model -from tensorflow.keras.layers import Input, GRU, Dense, Embedding, Reshape, Concatenate, Lambda, Conv1D, Multiply, Add, Bidirectional, MaxPooling1D, Activation, GaussianNoise -from tensorflow.compat.v1.keras.layers import CuDNNGRU -from tensorflow.keras import backend as K -from tensorflow.keras.constraints import Constraint -from tensorflow.keras.initializers import Initializer -from tensorflow.keras.callbacks import Callback -import numpy as np - -def quant_regularizer(x): - Q = 128 - Q_1 = 1./Q - #return .01 * tf.reduce_mean(1 - tf.math.cos(2*3.1415926535897931*(Q*x-tf.round(Q*x)))) - return .01 * tf.reduce_mean(K.sqrt(K.sqrt(1.0001 - tf.math.cos(2*3.1415926535897931*(Q*x-tf.round(Q*x)))))) - - -class WeightClip(Constraint): - '''Clips the weights incident to each hidden unit to be inside a range - ''' - def __init__(self, c=2): - self.c = c - - def __call__(self, p): - # Ensure that abs of adjacent weights don't sum to more than 127. Otherwise there's a risk of - # saturation when implementing dot products with SSSE3 or AVX2. - return self.c*p/tf.maximum(self.c, tf.repeat(tf.abs(p[:, 1::2])+tf.abs(p[:, 0::2]), 2, axis=1)) - #return K.clip(p, -self.c, self.c) - - def get_config(self): - return {'name': self.__class__.__name__, - 'c': self.c} - -constraint = WeightClip(0.992) - -def new_lpcnet_plc_model(rnn_units=256, nb_used_features=20, nb_burg_features=36, batch_size=128, training=False, adaptation=False, quantize=False, cond_size=128): - feat = Input(shape=(None, nb_used_features+nb_burg_features), batch_size=batch_size) - lost = Input(shape=(None, 1), batch_size=batch_size) - - fdense1 = Dense(cond_size, activation='tanh', name='plc_dense1') - - cfeat = Concatenate()([feat, lost]) - cfeat = fdense1(cfeat) - #cfeat = Conv1D(cond_size, 3, padding='causal', activation='tanh', name='plc_conv1')(cfeat) - - quant = quant_regularizer if quantize else None - - if training: - rnn = CuDNNGRU(rnn_units, return_sequences=True, return_state=True, name='plc_gru1', stateful=True, - kernel_constraint=constraint, recurrent_constraint = constraint, kernel_regularizer=quant, recurrent_regularizer=quant) - rnn2 = CuDNNGRU(rnn_units, return_sequences=True, return_state=True, name='plc_gru2', stateful=True, - kernel_constraint=constraint, recurrent_constraint = constraint, kernel_regularizer=quant, recurrent_regularizer=quant) - else: - rnn = GRU(rnn_units, return_sequences=True, return_state=True, recurrent_activation="sigmoid", reset_after='true', name='plc_gru1', stateful=True, - kernel_constraint=constraint, recurrent_constraint = constraint, kernel_regularizer=quant, recurrent_regularizer=quant) - rnn2 = GRU(rnn_units, return_sequences=True, return_state=True, recurrent_activation="sigmoid", reset_after='true', name='plc_gru2', stateful=True, - kernel_constraint=constraint, recurrent_constraint = constraint, kernel_regularizer=quant, recurrent_regularizer=quant) - - gru_out1, _ = rnn(cfeat) - gru_out1 = GaussianNoise(.005)(gru_out1) - gru_out2, _ = rnn2(gru_out1) - - out_dense = Dense(nb_used_features, activation='linear', name='plc_out') - plc_out = out_dense(gru_out2) - - model = Model([feat, lost], plc_out) - model.rnn_units = rnn_units - model.cond_size = cond_size - model.nb_used_features = nb_used_features - model.nb_burg_features = nb_burg_features - - return model diff --git a/dnn/training_tf2/mdense.py b/dnn/training_tf2/mdense.py deleted file mode 100644 index 844ae23e6..000000000 --- a/dnn/training_tf2/mdense.py +++ /dev/null @@ -1,95 +0,0 @@ -from tensorflow.keras import backend as K -from tensorflow.keras.layers import Layer, InputSpec -from tensorflow.keras import activations -from tensorflow.keras import initializers, regularizers, constraints -import numpy as np -import math - -class MDense(Layer): - - def __init__(self, outputs, - channels=2, - activation=None, - use_bias=True, - kernel_initializer='glorot_uniform', - bias_initializer='zeros', - kernel_regularizer=None, - bias_regularizer=None, - activity_regularizer=None, - kernel_constraint=None, - bias_constraint=None, - **kwargs): - if 'input_shape' not in kwargs and 'input_dim' in kwargs: - kwargs['input_shape'] = (kwargs.pop('input_dim'),) - super(MDense, self).__init__(**kwargs) - self.units = outputs - self.channels = channels - self.activation = activations.get(activation) - self.use_bias = use_bias - self.kernel_initializer = initializers.get(kernel_initializer) - self.bias_initializer = initializers.get(bias_initializer) - self.kernel_regularizer = regularizers.get(kernel_regularizer) - self.bias_regularizer = regularizers.get(bias_regularizer) - self.activity_regularizer = regularizers.get(activity_regularizer) - self.kernel_constraint = constraints.get(kernel_constraint) - self.bias_constraint = constraints.get(bias_constraint) - self.input_spec = InputSpec(min_ndim=2) - self.supports_masking = True - - def build(self, input_shape): - assert len(input_shape) >= 2 - input_dim = input_shape[-1] - - self.kernel = self.add_weight(shape=(self.units, input_dim, self.channels), - initializer=self.kernel_initializer, - name='kernel', - regularizer=self.kernel_regularizer, - constraint=self.kernel_constraint) - if self.use_bias: - self.bias = self.add_weight(shape=(self.units, self.channels), - initializer=self.bias_initializer, - name='bias', - regularizer=self.bias_regularizer, - constraint=self.bias_constraint) - else: - self.bias = None - self.factor = self.add_weight(shape=(self.units, self.channels), - initializer='ones', - name='factor', - regularizer=self.bias_regularizer, - constraint=self.bias_constraint) - self.input_spec = InputSpec(min_ndim=2, axes={-1: input_dim}) - self.built = True - - def call(self, inputs): - output = K.dot(inputs, self.kernel) - if self.use_bias: - output = output + self.bias - output = K.tanh(output) * self.factor - output = K.sum(output, axis=-1) - if self.activation is not None: - output = self.activation(output) - return output - - def compute_output_shape(self, input_shape): - assert input_shape and len(input_shape) >= 2 - assert input_shape[-1] - output_shape = list(input_shape) - output_shape[-1] = self.units - return tuple(output_shape) - - def get_config(self): - config = { - 'units': self.units, - 'activation': activations.serialize(self.activation), - 'use_bias': self.use_bias, - 'kernel_initializer': initializers.serialize(self.kernel_initializer), - 'bias_initializer': initializers.serialize(self.bias_initializer), - 'kernel_regularizer': regularizers.serialize(self.kernel_regularizer), - 'bias_regularizer': regularizers.serialize(self.bias_regularizer), - 'activity_regularizer': regularizers.serialize(self.activity_regularizer), - 'kernel_constraint': constraints.serialize(self.kernel_constraint), - 'bias_constraint': constraints.serialize(self.bias_constraint) - } - base_config = super(MDense, self).get_config() - return dict(list(base_config.items()) + list(config.items())) diff --git a/dnn/training_tf2/pade.py b/dnn/training_tf2/pade.py deleted file mode 100644 index f88f425c9..000000000 --- a/dnn/training_tf2/pade.py +++ /dev/null @@ -1,70 +0,0 @@ -# Optimizing a rational function to optimize a tanh() approximation - -import numpy as np -import tensorflow as tf -from tensorflow.keras.models import Model -from tensorflow.keras.layers import Input, GRU, Dense, Embedding, Reshape, Concatenate, Lambda, Conv1D, Multiply, Add, Bidirectional, MaxPooling1D, Activation -import tensorflow.keras.backend as K -from tensorflow.keras.optimizers import Adam, SGD - -def my_loss1(y_true, y_pred): - return 1*K.mean(K.square(y_true-y_pred)) + 1*K.max(K.square(y_true-y_pred), axis=1) - -def my_loss2(y_true, y_pred): - return .1*K.mean(K.square(y_true-y_pred)) + 1*K.max(K.square(y_true-y_pred), axis=1) - -def my_loss3(y_true, y_pred): - return .01*K.mean(K.square(y_true-y_pred)) + 1*K.max(K.square(y_true-y_pred), axis=1) - -# Using these initializers to seed the approximation -# with a reasonable starting point -def num_init(shape, dtype=None): - rr = tf.constant([[945], [105], [1]], dtype=dtype) - #rr = tf.constant([[946.56757], [98.01368], [0.66841]], dtype=dtype) - print(rr) - return rr - -def den_init(shape, dtype=None): - rr = tf.constant([[945], [420], [15]], dtype=dtype) - #rr = tf.constant([[946.604], [413.342], [12.465]], dtype=dtype) - print(rr) - return rr - - -x = np.arange(-10, 10, .01) -N = len(x) -x = np.reshape(x, (1, -1, 1)) -x2 = x*x - -x2in = np.concatenate([x2*0 + 1, x2, x2*x2], axis=2) -yout = np.tanh(x) - - -model_x = Input(shape=(None, 1,)) -model_x2 = Input(shape=(None, 3,)) - -num = Dense(1, name='num', use_bias=False, kernel_initializer=num_init) -den = Dense(1, name='den', use_bias=False, kernel_initializer=den_init) - -def ratio(x): - return tf.minimum(1., tf.maximum(-1., x[0]*x[1]/x[2])) - -out_layer = Lambda(ratio) -output = out_layer([model_x, num(model_x2), den(model_x2)]) - -model = Model([model_x, model_x2], output) -model.summary() - -model.compile(Adam(0.05, beta_1=0.9, beta_2=0.9, decay=2e-5), loss='mean_squared_error') -model.fit([x, x2in], yout, batch_size=1, epochs=500000, validation_split=0.0) - -model.compile(Adam(0.001, beta_2=0.9, decay=1e-4), loss=my_loss1) -model.fit([x, x2in], yout, batch_size=1, epochs=50000, validation_split=0.0) - -model.compile(Adam(0.0001, beta_2=0.9, decay=1e-4), loss=my_loss2) -model.fit([x, x2in], yout, batch_size=1, epochs=50000, validation_split=0.0) - -model.compile(Adam(0.00001, beta_2=0.9, decay=1e-4), loss=my_loss3) -model.fit([x, x2in], yout, batch_size=1, epochs=50000, validation_split=0.0) - -model.save_weights('tanh.h5') diff --git a/dnn/training_tf2/parameters.py b/dnn/training_tf2/parameters.py deleted file mode 100644 index 3621a4e4f..000000000 --- a/dnn/training_tf2/parameters.py +++ /dev/null @@ -1,29 +0,0 @@ -""" module for handling extra model parameters for tf.keras models """ - -import tensorflow as tf - - -def set_parameter(model, parameter_name, parameter_value, dtype='float32'): - """ stores parameter_value as non-trainable weight with name parameter_name:0 """ - - weights = [weight for weight in model.weights if weight.name == (parameter_name + ":0")] - - if len(weights) == 0: - model.add_weight(parameter_name, trainable=False, initializer=tf.keras.initializers.Constant(parameter_value), dtype=dtype) - elif len(weights) == 1: - weights[0].assign(parameter_value) - else: - raise ValueError(f"more than one weight starting with {parameter_name}:0 in model") - - -def get_parameter(model, parameter_name, default=None): - """ returns parameter value if parameter is present in model and otherwise default """ - - weights = [weight for weight in model.weights if weight.name == (parameter_name + ":0")] - - if len(weights) == 0: - return default - elif len(weights) > 1: - raise ValueError(f"more than one weight starting with {parameter_name}:0 in model") - else: - return weights[0].numpy().item() diff --git a/dnn/training_tf2/plc_loader.py b/dnn/training_tf2/plc_loader.py deleted file mode 100644 index a9bd41d87..000000000 --- a/dnn/training_tf2/plc_loader.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2021-2022 Amazon - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' - -import numpy as np -from tensorflow.keras.utils import Sequence - -class PLCLoader(Sequence): - def __init__(self, features, lost, nb_burg_features, batch_size): - self.batch_size = batch_size - self.nb_batches = features.shape[0]//self.batch_size - self.features = features[:self.nb_batches*self.batch_size, :, :] - self.lost = lost.astype('float') - self.lost = self.lost[:(len(self.lost)//features.shape[1]-1)*features.shape[1]] - self.nb_burg_features = nb_burg_features - self.on_epoch_end() - - def on_epoch_end(self): - self.indices = np.arange(self.nb_batches*self.batch_size) - np.random.shuffle(self.indices) - offset = np.random.randint(0, high=self.features.shape[1]) - self.lost_offset = np.reshape(self.lost[offset:-self.features.shape[1]+offset], (-1, self.features.shape[1])) - self.lost_indices = np.random.randint(0, high=self.lost_offset.shape[0], size=self.nb_batches*self.batch_size) - - def __getitem__(self, index): - features = self.features[self.indices[index*self.batch_size:(index+1)*self.batch_size], :, :] - burg_lost = (np.random.rand(features.shape[0], features.shape[1]) > .1).astype('float') - burg_lost = np.reshape(burg_lost, (features.shape[0], features.shape[1], 1)) - burg_mask = np.tile(burg_lost, (1,1,self.nb_burg_features)) - - lost = self.lost_offset[self.lost_indices[index*self.batch_size:(index+1)*self.batch_size], :] - lost = np.reshape(lost, (features.shape[0], features.shape[1], 1)) - lost_mask = np.tile(lost, (1,1,features.shape[2])) - in_features = features*lost_mask - in_features[:,:,:self.nb_burg_features] = in_features[:,:,:self.nb_burg_features]*burg_mask - - #For the first frame after a loss, we don't have valid features, but the Burg estimate is valid. - #in_features[:,1:,self.nb_burg_features:] = in_features[:,1:,self.nb_burg_features:]*lost_mask[:,:-1,self.nb_burg_features:] - out_lost = np.copy(lost) - #out_lost[:,1:,:] = out_lost[:,1:,:]*out_lost[:,:-1,:] - - out_features = np.concatenate([features[:,:,self.nb_burg_features:], 1.-out_lost], axis=-1) - burg_sign = 2*burg_lost - 1 - # last dim is 1 for received packet, 0 for lost packet, and -1 when just the Burg info is missing - inputs = [in_features*lost_mask, lost*burg_sign] - outputs = [out_features] - return (inputs, outputs) - - def __len__(self): - return self.nb_batches diff --git a/dnn/training_tf2/rdovae.py b/dnn/training_tf2/rdovae.py deleted file mode 100644 index 6240120d1..000000000 --- a/dnn/training_tf2/rdovae.py +++ /dev/null @@ -1,372 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2022 Amazon - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' - -import math -import tensorflow as tf -from tensorflow.keras.models import Model -from tensorflow.keras.layers import Input, GRU, Dense, Embedding, Reshape, Concatenate, Lambda, Conv1D, Multiply, Add, Bidirectional, MaxPooling1D, Activation, GaussianNoise, AveragePooling1D, RepeatVector -from tensorflow.compat.v1.keras.layers import CuDNNGRU -from tensorflow.keras import backend as K -from tensorflow.keras.constraints import Constraint -from tensorflow.keras.initializers import Initializer -from tensorflow.keras.callbacks import Callback -from tensorflow.keras.regularizers import l1 -import numpy as np -import h5py -from uniform_noise import UniformNoise - -class WeightClip(Constraint): - '''Clips the weights incident to each hidden unit to be inside a range - ''' - def __init__(self, c=2): - self.c = c - - def __call__(self, p): - # Ensure that abs of adjacent weights don't sum to more than 127. Otherwise there's a risk of - # saturation when implementing dot products with SSSE3 or AVX2. - return self.c*p/tf.maximum(self.c, tf.repeat(tf.abs(p[:, 1::2])+tf.abs(p[:, 0::2]), 2, axis=1)) - #return K.clip(p, -self.c, self.c) - - def get_config(self): - return {'name': self.__class__.__name__, - 'c': self.c} - -constraint = WeightClip(0.496) - -def soft_quantize(x): - #x = 4*x - #x = x - (.25/np.math.pi)*tf.math.sin(2*np.math.pi*x) - #x = x - (.25/np.math.pi)*tf.math.sin(2*np.math.pi*x) - #x = x - (.25/np.math.pi)*tf.math.sin(2*np.math.pi*x) - return x - -def noise_quantize(x): - return soft_quantize(x + (K.random_uniform((128, 16, 80))-.5) ) - -def hard_quantize(x): - x = soft_quantize(x) - quantized = tf.round(x) - return x + tf.stop_gradient(quantized - x) - -def apply_dead_zone(x): - d = x[1]*.05 - x = x[0] - y = x - d*tf.math.tanh(x/(.1+d)) - return y - -def rate_loss(y_true,y_pred): - log2_e = 1.4427 - n = y_pred.shape[-1] - C = n - log2_e*np.math.log(np.math.gamma(n)) - k = K.sum(K.abs(y_pred), axis=-1) - p = 1.5 - #rate = C + (n-1)*log2_e*tf.math.log((k**p + (n/5)**p)**(1/p)) - rate = C + (n-1)*log2_e*tf.math.log(k + .112*n**2/(n/1.8+k) ) - return K.mean(rate) - -eps=1e-6 -def safelog2(x): - log2_e = 1.4427 - return log2_e*tf.math.log(eps+x) - -def feat_dist_loss(y_true,y_pred): - lambda_1 = 1./K.sqrt(y_pred[:,:,:,-1]) - y_pred = y_pred[:,:,:,:-1] - ceps = y_pred[:,:,:,:18] - y_true[:,:,:18] - pitch = 2*(y_pred[:,:,:,18:19] - y_true[:,:,18:19])/(y_true[:,:,18:19] + 2) - corr = y_pred[:,:,:,19:] - y_true[:,:,19:] - pitch_weight = K.square(K.maximum(0., y_true[:,:,19:]+.5)) - return K.mean(lambda_1*K.mean(K.square(ceps) + 10*(1/18.)*K.abs(pitch)*pitch_weight + (1/18.)*K.square(corr), axis=-1)) - -def sq1_rate_loss(y_true,y_pred): - lambda_val = K.sqrt(y_pred[:,:,-1]) - y_pred = y_pred[:,:,:-1] - log2_e = 1.4427 - n = y_pred.shape[-1]//3 - r = (y_pred[:,:,2*n:]) - p0 = (y_pred[:,:,n:2*n]) - p0 = 1-r**(.5+.5*p0) - y_pred = y_pred[:,:,:n] - y_pred = soft_quantize(y_pred) - - y0 = K.maximum(0., 1. - K.abs(y_pred))**2 - rate = -y0*safelog2(p0*r**K.abs(y_pred)) - (1-y0)*safelog2(.5*(1-p0)*(1-r)*r**(K.abs(y_pred)-1)) - rate = -safelog2(-.5*tf.math.log(r)*r**K.abs(y_pred)) - rate = -safelog2((1-r)/(1+r)*r**K.abs(y_pred)) - #rate = -safelog2(- tf.math.sinh(.5*tf.math.log(r))* r**K.abs(y_pred) - tf.math.cosh(K.maximum(0., .5 - K.abs(y_pred))*tf.math.log(r)) + 1) - rate = lambda_val*K.sum(rate, axis=-1) - return K.mean(rate) - -def sq2_rate_loss(y_true,y_pred): - lambda_val = K.sqrt(y_pred[:,:,-1]) - y_pred = y_pred[:,:,:-1] - log2_e = 1.4427 - n = y_pred.shape[-1]//3 - r = y_pred[:,:,2*n:] - p0 = y_pred[:,:,n:2*n] - p0 = 1-r**(.5+.5*p0) - #theta = K.minimum(1., .5 + 0*p0 - 0.04*tf.math.log(r)) - #p0 = 1-r**theta - y_pred = tf.round(y_pred[:,:,:n]) - y0 = K.maximum(0., 1. - K.abs(y_pred))**2 - rate = -y0*safelog2(p0*r**K.abs(y_pred)) - (1-y0)*safelog2(.5*(1-p0)*(1-r)*r**(K.abs(y_pred)-1)) - rate = lambda_val*K.sum(rate, axis=-1) - return K.mean(rate) - -def sq_rate_metric(y_true,y_pred, reduce=True): - y_pred = y_pred[:,:,:-1] - log2_e = 1.4427 - n = y_pred.shape[-1]//3 - r = y_pred[:,:,2*n:] - p0 = y_pred[:,:,n:2*n] - p0 = 1-r**(.5+.5*p0) - #theta = K.minimum(1., .5 + 0*p0 - 0.04*tf.math.log(r)) - #p0 = 1-r**theta - y_pred = tf.round(y_pred[:,:,:n]) - y0 = K.maximum(0., 1. - K.abs(y_pred))**2 - rate = -y0*safelog2(p0*r**K.abs(y_pred)) - (1-y0)*safelog2(.5*(1-p0)*(1-r)*r**(K.abs(y_pred)-1)) - rate = K.sum(rate, axis=-1) - if reduce: - rate = K.mean(rate) - return rate - -def pvq_quant_search(x, k): - x = x/tf.reduce_sum(tf.abs(x), axis=-1, keepdims=True) - kx = k*x - y = tf.round(kx) - newk = k - - for j in range(10): - #print("y = ", y) - #print("iteration ", j) - abs_y = tf.abs(y) - abs_kx = tf.abs(kx) - kk=tf.reduce_sum(abs_y, axis=-1) - #print("sums = ", kk) - plus = 1.000001*tf.reduce_min((abs_y+.5)/(abs_kx+1e-15), axis=-1) - minus = .999999*tf.reduce_max((abs_y-.5)/(abs_kx+1e-15), axis=-1) - #print("plus = ", plus) - #print("minus = ", minus) - factor = tf.where(kk>k, minus, plus) - factor = tf.where(kk==k, tf.ones_like(factor), factor) - #print("scale = ", factor) - factor = tf.expand_dims(factor, axis=-1) - #newk = newk * (k/kk)**.2 - newk = newk*factor - kx = newk*x - #print("newk = ", newk) - #print("unquantized = ", newk*x) - y = tf.round(kx) - - #print(y) - #print(K.mean(K.sum(K.abs(y), axis=-1))) - return y - -def pvq_quantize(x, k): - x = x/(1e-15+tf.norm(x, axis=-1,keepdims=True)) - quantized = pvq_quant_search(x, k) - quantized = quantized/(1e-15+tf.norm(quantized, axis=-1,keepdims=True)) - return x + tf.stop_gradient(quantized - x) - - -def var_repeat(x): - return tf.repeat(tf.expand_dims(x[0], 1), K.shape(x[1])[1], axis=1) - -nb_state_dim = 24 - -def new_rdovae_encoder(nb_used_features=20, nb_bits=17, bunch=4, nb_quant=40, batch_size=128, cond_size=128, cond_size2=256, training=False): - feat = Input(shape=(None, nb_used_features), batch_size=batch_size) - - gru = CuDNNGRU if training else GRU - enc_dense1 = Dense(cond_size2, activation='tanh', kernel_constraint=constraint, name='enc_dense1') - enc_dense2 = gru(cond_size, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, name='enc_dense2') - enc_dense3 = Dense(cond_size2, activation='tanh', kernel_constraint=constraint, name='enc_dense3') - enc_dense4 = gru(cond_size, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, name='enc_dense4') - enc_dense5 = Dense(cond_size2, activation='tanh', kernel_constraint=constraint, name='enc_dense5') - enc_dense6 = gru(cond_size, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, name='enc_dense6') - enc_dense7 = Dense(cond_size, activation='tanh', kernel_constraint=constraint, name='enc_dense7') - enc_dense8 = Dense(cond_size, activation='tanh', kernel_constraint=constraint, name='enc_dense8') - - #bits_dense = Dense(nb_bits, activation='linear', name='bits_dense') - bits_dense = Conv1D(nb_bits, 4, padding='causal', activation='linear', name='bits_dense') - - zero_out = Lambda(lambda x: 0*x) - inputs = Reshape((-1, 2*nb_used_features))(feat) - d1 = enc_dense1(inputs) - d2 = enc_dense2(d1) - d3 = enc_dense3(d2) - d4 = enc_dense4(d3) - d5 = enc_dense5(d4) - d6 = enc_dense6(d5) - d7 = enc_dense7(d6) - d8 = enc_dense8(d7) - pre_out = Concatenate()([d1, d2, d3, d4, d5, d6, d7, d8]) - enc_out = bits_dense(pre_out) - global_dense1 = Dense(128, activation='tanh', name='gdense1') - global_dense2 = Dense(nb_state_dim, activation='tanh', name='gdense2') - global_bits = global_dense2(global_dense1(pre_out)) - - encoder = Model([feat], [enc_out, global_bits], name='encoder') - return encoder - -def new_rdovae_decoder(nb_used_features=20, nb_bits=17, bunch=4, nb_quant=40, batch_size=128, cond_size=128, cond_size2=256, training=False): - bits_input = Input(shape=(None, nb_bits), batch_size=batch_size, name="dec_bits") - gru_state_input = Input(shape=(nb_state_dim,), batch_size=batch_size, name="dec_state") - - - gru = CuDNNGRU if training else GRU - dec_dense1 = Dense(cond_size2, activation='tanh', kernel_constraint=constraint, name='dec_dense1') - dec_dense2 = gru(cond_size, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, name='dec_dense2') - dec_dense3 = Dense(cond_size2, activation='tanh', kernel_constraint=constraint, name='dec_dense3') - dec_dense4 = gru(cond_size, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, name='dec_dense4') - dec_dense5 = Dense(cond_size2, activation='tanh', kernel_constraint=constraint, name='dec_dense5') - dec_dense6 = gru(cond_size, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, name='dec_dense6') - dec_dense7 = Dense(cond_size, activation='tanh', kernel_constraint=constraint, name='dec_dense7') - dec_dense8 = Dense(cond_size, activation='tanh', kernel_constraint=constraint, name='dec_dense8') - - dec_final = Dense(bunch*nb_used_features, activation='linear', name='dec_final') - - time_reverse = Lambda(lambda x: K.reverse(x, 1)) - #time_reverse = Lambda(lambda x: x) - #gru_state_rep = RepeatVector(64//bunch)(gru_state_input) - - #gru_state_rep = Lambda(var_repeat, output_shape=(None, nb_state_dim)) ([gru_state_input, bits_input]) - gru_state1 = Dense(cond_size, name="state1", activation='tanh')(gru_state_input) - gru_state2 = Dense(cond_size, name="state2", activation='tanh')(gru_state_input) - gru_state3 = Dense(cond_size, name="state3", activation='tanh')(gru_state_input) - - dec1 = dec_dense1(time_reverse(bits_input)) - dec2 = dec_dense2(dec1, initial_state=gru_state1) - dec3 = dec_dense3(dec2) - dec4 = dec_dense4(dec3, initial_state=gru_state2) - dec5 = dec_dense5(dec4) - dec6 = dec_dense6(dec5, initial_state=gru_state3) - dec7 = dec_dense7(dec6) - dec8 = dec_dense8(dec7) - output = Reshape((-1, nb_used_features))(dec_final(Concatenate()([dec1, dec2, dec3, dec4, dec5, dec6, dec7, dec8]))) - decoder = Model([bits_input, gru_state_input], time_reverse(output), name='decoder') - decoder.nb_bits = nb_bits - decoder.bunch = bunch - return decoder - -def new_split_decoder(decoder): - nb_bits = decoder.nb_bits - bunch = decoder.bunch - bits_input = Input(shape=(None, nb_bits), name="split_bits") - gru_state_input = Input(shape=(None,nb_state_dim), name="split_state") - - range_select = Lambda(lambda x: x[0][:,x[1]:x[2],:]) - elem_select = Lambda(lambda x: x[0][:,x[1],:]) - points = [0, 100, 200, 300, 400] - outputs = [] - for i in range(len(points)-1): - begin = points[i]//bunch - end = points[i+1]//bunch - state = elem_select([gru_state_input, end-1]) - bits = range_select([bits_input, begin, end]) - outputs.append(decoder([bits, state])) - output = Concatenate(axis=1)(outputs) - split = Model([bits_input, gru_state_input], output, name="split") - return split - -def tensor_concat(x): - #n = x[1]//2 - #x = x[0] - n=2 - y = [] - for i in range(n-1): - offset = 2 * (n-1-i) - tmp = K.concatenate([x[i][:, offset:, :], x[-1][:, -offset:, :]], axis=-2) - y.append(tf.expand_dims(tmp, axis=0)) - y.append(tf.expand_dims(x[-1], axis=0)) - return Concatenate(axis=0)(y) - - -def new_rdovae_model(nb_used_features=20, nb_bits=17, bunch=4, nb_quant=40, batch_size=128, cond_size=128, cond_size2=256, training=False): - - feat = Input(shape=(None, nb_used_features), batch_size=batch_size) - quant_id = Input(shape=(None,), batch_size=batch_size) - lambda_val = Input(shape=(None, 1), batch_size=batch_size) - lambda_bunched = AveragePooling1D(pool_size=bunch//2, strides=bunch//2, padding="valid")(lambda_val) - lambda_up = Lambda(lambda x: K.repeat_elements(x, 2, axis=-2))(lambda_val) - - qembedding = Embedding(nb_quant, 6*nb_bits, name='quant_embed', embeddings_initializer='zeros') - quant_embed_dec = qembedding(quant_id) - quant_scale = Activation('softplus')(Lambda(lambda x: x[:,:,:nb_bits], name='quant_scale_embed')(quant_embed_dec)) - - encoder = new_rdovae_encoder(nb_used_features, nb_bits, bunch, nb_quant, batch_size, cond_size, cond_size2, training=training) - ze, gru_state_dec = encoder([feat]) - ze = Multiply()([ze, quant_scale]) - - decoder = new_rdovae_decoder(nb_used_features, nb_bits, bunch, nb_quant, batch_size, cond_size, cond_size2, training=training) - split_decoder = new_split_decoder(decoder) - - dead_zone = Activation('softplus')(Lambda(lambda x: x[:,:,nb_bits:2*nb_bits], name='dead_zone_embed')(quant_embed_dec)) - soft_distr_embed = Activation('sigmoid')(Lambda(lambda x: x[:,:,2*nb_bits:4*nb_bits], name='soft_distr_embed')(quant_embed_dec)) - hard_distr_embed = Activation('sigmoid')(Lambda(lambda x: x[:,:,4*nb_bits:], name='hard_distr_embed')(quant_embed_dec)) - - noisequant = UniformNoise() - hardquant = Lambda(hard_quantize) - dzone = Lambda(apply_dead_zone) - dze = dzone([ze,dead_zone]) - ndze = noisequant(dze) - dze_quant = hardquant(dze) - - div = Lambda(lambda x: x[0]/x[1]) - dze_quant = div([dze_quant,quant_scale]) - ndze_unquant = div([ndze,quant_scale]) - - mod_select = Lambda(lambda x: x[0][:,x[1]::bunch//2,:]) - gru_state_dec = Lambda(lambda x: pvq_quantize(x, 82))(gru_state_dec) - combined_output = [] - unquantized_output = [] - cat = Concatenate(name="out_cat") - for i in range(bunch//2): - dze_select = mod_select([dze_quant, i]) - ndze_select = mod_select([ndze_unquant, i]) - state_select = mod_select([gru_state_dec, i]) - - tmp = split_decoder([dze_select, state_select]) - tmp = cat([tmp, lambda_up]) - combined_output.append(tmp) - - tmp = split_decoder([ndze_select, state_select]) - tmp = cat([tmp, lambda_up]) - unquantized_output.append(tmp) - - concat = Lambda(tensor_concat, name="output") - combined_output = concat(combined_output) - unquantized_output = concat(unquantized_output) - - e2 = Concatenate(name="hard_bits")([dze, hard_distr_embed, lambda_val]) - e = Concatenate(name="soft_bits")([dze, soft_distr_embed, lambda_val]) - - - model = Model([feat, quant_id, lambda_val], [combined_output, unquantized_output, e, e2], name="end2end") - model.nb_used_features = nb_used_features - - return model, encoder, decoder, qembedding diff --git a/dnn/training_tf2/rdovae_exchange.py b/dnn/training_tf2/rdovae_exchange.py deleted file mode 100644 index 3249677d4..000000000 --- a/dnn/training_tf2/rdovae_exchange.py +++ /dev/null @@ -1,138 +0,0 @@ -""" -/* Copyright (c) 2022 Amazon - Written by Jan Buethe */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -""" - - -import argparse -import os -import sys - -os.environ['CUDA_VISIBLE_DEVICES'] = "" - -parser = argparse.ArgumentParser() - -parser.add_argument('weights', metavar="", type=str, help='model weight file in hdf5 format') -parser.add_argument('output', metavar="", type=str, help='output exchange folder') -parser.add_argument('--cond-size', type=int, help="conditioning size (default: 256)", default=256) -parser.add_argument('--latent-dim', type=int, help="dimension of latent space (default: 80)", default=80) -parser.add_argument('--quant-levels', type=int, help="number of quantization steps (default: 16)", default=16) - -args = parser.parse_args() - -# now import the heavy stuff -from rdovae import new_rdovae_model -from wexchange.tf import dump_tf_weights, load_tf_weights - - -exchange_name = { - 'enc_dense1' : 'encoder_stack_layer1_dense', - 'enc_dense3' : 'encoder_stack_layer3_dense', - 'enc_dense5' : 'encoder_stack_layer5_dense', - 'enc_dense7' : 'encoder_stack_layer7_dense', - 'enc_dense8' : 'encoder_stack_layer8_dense', - 'gdense1' : 'encoder_state_layer1_dense', - 'gdense2' : 'encoder_state_layer2_dense', - 'enc_dense2' : 'encoder_stack_layer2_gru', - 'enc_dense4' : 'encoder_stack_layer4_gru', - 'enc_dense6' : 'encoder_stack_layer6_gru', - 'bits_dense' : 'encoder_stack_layer9_conv', - 'qembedding' : 'statistical_model_embedding', - 'state1' : 'decoder_state1_dense', - 'state2' : 'decoder_state2_dense', - 'state3' : 'decoder_state3_dense', - 'dec_dense1' : 'decoder_stack_layer1_dense', - 'dec_dense3' : 'decoder_stack_layer3_dense', - 'dec_dense5' : 'decoder_stack_layer5_dense', - 'dec_dense7' : 'decoder_stack_layer7_dense', - 'dec_dense8' : 'decoder_stack_layer8_dense', - 'dec_final' : 'decoder_stack_layer9_dense', - 'dec_dense2' : 'decoder_stack_layer2_gru', - 'dec_dense4' : 'decoder_stack_layer4_gru', - 'dec_dense6' : 'decoder_stack_layer6_gru' -} - - -if __name__ == "__main__": - - model, encoder, decoder, qembedding = new_rdovae_model(20, args.latent_dim, cond_size=args.cond_size, nb_quant=args.quant_levels) - model.load_weights(args.weights) - - os.makedirs(args.output, exist_ok=True) - - # encoder - encoder_dense_names = [ - 'enc_dense1', - 'enc_dense3', - 'enc_dense5', - 'enc_dense7', - 'enc_dense8', - 'gdense1', - 'gdense2' - ] - - encoder_gru_names = [ - 'enc_dense2', - 'enc_dense4', - 'enc_dense6' - ] - - encoder_conv1d_names = [ - 'bits_dense' - ] - - - for name in encoder_dense_names + encoder_gru_names + encoder_conv1d_names: - print(f"writing layer {exchange_name[name]}...") - dump_tf_weights(os.path.join(args.output, exchange_name[name]), encoder.get_layer(name)) - - # qembedding - print(f"writing layer {exchange_name['qembedding']}...") - dump_tf_weights(os.path.join(args.output, exchange_name['qembedding']), qembedding) - - # decoder - decoder_dense_names = [ - 'state1', - 'state2', - 'state3', - 'dec_dense1', - 'dec_dense3', - 'dec_dense5', - 'dec_dense7', - 'dec_dense8', - 'dec_final' - ] - - decoder_gru_names = [ - 'dec_dense2', - 'dec_dense4', - 'dec_dense6' - ] - - for name in decoder_dense_names + decoder_gru_names: - print(f"writing layer {exchange_name[name]}...") - dump_tf_weights(os.path.join(args.output, exchange_name[name]), decoder.get_layer(name)) diff --git a/dnn/training_tf2/rdovae_import.py b/dnn/training_tf2/rdovae_import.py deleted file mode 100644 index bc8b460d0..000000000 --- a/dnn/training_tf2/rdovae_import.py +++ /dev/null @@ -1,123 +0,0 @@ -""" -/* Copyright (c) 2022 Amazon - Written by Jan Buethe */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -""" - - -import argparse -import os -import sys - -os.environ['CUDA_VISIBLE_DEVICES'] = "" - -parser = argparse.ArgumentParser() - -parser.add_argument('input', metavar="", type=str, help='input exchange folder') -parser.add_argument('weights', metavar="", type=str, help='model weight file in hdf5 format') -parser.add_argument('--cond-size', type=int, help="conditioning size (default: 256)", default=256) -parser.add_argument('--latent-dim', type=int, help="dimension of latent space (default: 80)", default=80) -parser.add_argument('--quant-levels', type=int, help="number of quantization steps (default: 16)", default=16) - -args = parser.parse_args() - -# now import the heavy stuff -from rdovae import new_rdovae_model -from wexchange.tf import load_tf_weights - - -exchange_name = { - 'enc_dense1' : 'encoder_stack_layer1_dense', - 'enc_dense3' : 'encoder_stack_layer3_dense', - 'enc_dense5' : 'encoder_stack_layer5_dense', - 'enc_dense7' : 'encoder_stack_layer7_dense', - 'enc_dense8' : 'encoder_stack_layer8_dense', - 'gdense1' : 'encoder_state_layer1_dense', - 'gdense2' : 'encoder_state_layer2_dense', - 'enc_dense2' : 'encoder_stack_layer2_gru', - 'enc_dense4' : 'encoder_stack_layer4_gru', - 'enc_dense6' : 'encoder_stack_layer6_gru', - 'bits_dense' : 'encoder_stack_layer9_conv', - 'qembedding' : 'statistical_model_embedding', - 'state1' : 'decoder_state1_dense', - 'state2' : 'decoder_state2_dense', - 'state3' : 'decoder_state3_dense', - 'dec_dense1' : 'decoder_stack_layer1_dense', - 'dec_dense3' : 'decoder_stack_layer3_dense', - 'dec_dense5' : 'decoder_stack_layer5_dense', - 'dec_dense7' : 'decoder_stack_layer7_dense', - 'dec_dense8' : 'decoder_stack_layer8_dense', - 'dec_final' : 'decoder_stack_layer9_dense', - 'dec_dense2' : 'decoder_stack_layer2_gru', - 'dec_dense4' : 'decoder_stack_layer4_gru', - 'dec_dense6' : 'decoder_stack_layer6_gru' -} - -if __name__ == "__main__": - - model, encoder, decoder, qembedding = new_rdovae_model(20, args.latent_dim, cond_size=args.cond_size, nb_quant=args.quant_levels) - - encoder_layers = [ - 'enc_dense1', - 'enc_dense3', - 'enc_dense5', - 'enc_dense7', - 'enc_dense8', - 'gdense1', - 'gdense2', - 'enc_dense2', - 'enc_dense4', - 'enc_dense6', - 'bits_dense' - ] - - decoder_layers = [ - 'state1', - 'state2', - 'state3', - 'dec_dense1', - 'dec_dense3', - 'dec_dense5', - 'dec_dense7', - 'dec_dense8', - 'dec_final', - 'dec_dense2', - 'dec_dense4', - 'dec_dense6' - ] - - for name in encoder_layers: - print(f"loading weight for layer {name}...") - load_tf_weights(os.path.join(args.input, exchange_name[name]), encoder.get_layer(name)) - - print(f"loading weight for layer qembedding...") - load_tf_weights(os.path.join(args.input, exchange_name['qembedding']), qembedding) - - for name in decoder_layers: - print(f"loading weight for layer {name}...") - load_tf_weights(os.path.join(args.input, exchange_name[name]), decoder.get_layer(name)) - - model.save(args.weights) diff --git a/dnn/training_tf2/test_lpcnet.py b/dnn/training_tf2/test_lpcnet.py deleted file mode 100755 index ca551e63c..000000000 --- a/dnn/training_tf2/test_lpcnet.py +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2018 Mozilla - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' -import argparse -import sys - -import h5py -import numpy as np - -import lpcnet -from ulaw import ulaw2lin, lin2ulaw - - -parser = argparse.ArgumentParser() -parser.add_argument('model-file', type=str, help='model weight h5 file') -parser.add_argument('--lpc-gamma', type=float, help='LPC weighting factor. WARNING: giving an inconsistent value here will severely degrade performance', default=1) - -args = parser.parse_args() - -filename = args.model_file -with h5py.File(filename, "r") as f: - units = min(f['model_weights']['gru_a']['gru_a']['recurrent_kernel:0'].shape) - units2 = min(f['model_weights']['gru_b']['gru_b']['recurrent_kernel:0'].shape) - cond_size = min(f['model_weights']['feature_dense1']['feature_dense1']['kernel:0'].shape) - e2e = 'rc2lpc' in f['model_weights'] - - -model, enc, dec = lpcnet.new_lpcnet_model(training = False, rnn_units1=units, rnn_units2=units2, flag_e2e = e2e, cond_size=cond_size, batch_size=1) - -model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy']) -#model.summary() - - -feature_file = sys.argv[2] -out_file = sys.argv[3] -frame_size = model.frame_size -nb_features = 36 -nb_used_features = model.nb_used_features - -features = np.fromfile(feature_file, dtype='float32') -features = np.resize(features, (-1, nb_features)) -nb_frames = 1 -feature_chunk_size = features.shape[0] -pcm_chunk_size = frame_size*feature_chunk_size - -features = np.reshape(features, (nb_frames, feature_chunk_size, nb_features)) -periods = (.1 + 50*features[:,:,18:19]+100).astype('int16') - - - -model.load_weights(filename); - -order = 16 - -pcm = np.zeros((nb_frames*pcm_chunk_size, )) -fexc = np.zeros((1, 1, 3), dtype='int16')+128 -state1 = np.zeros((1, model.rnn_units1), dtype='float32') -state2 = np.zeros((1, model.rnn_units2), dtype='float32') - -mem = 0 -coef = 0.85 - -lpc_weights = np.array([args.lpc_gamma ** (i + 1) for i in range(16)]) - -fout = open(out_file, 'wb') - -skip = order + 1 -for c in range(0, nb_frames): - if not e2e: - cfeat = enc.predict([features[c:c+1, :, :nb_used_features], periods[c:c+1, :, :]]) - else: - cfeat,lpcs = enc.predict([features[c:c+1, :, :nb_used_features], periods[c:c+1, :, :]]) - for fr in range(0, feature_chunk_size): - f = c*feature_chunk_size + fr - if not e2e: - a = features[c, fr, nb_features-order:] * lpc_weights - else: - a = lpcs[c,fr] - for i in range(skip, frame_size): - pred = -sum(a*pcm[f*frame_size + i - 1:f*frame_size + i - order-1:-1]) - fexc[0, 0, 1] = lin2ulaw(pred) - - p, state1, state2 = dec.predict([fexc, cfeat[:, fr:fr+1, :], state1, state2]) - #Lower the temperature for voiced frames to reduce noisiness - p *= np.power(p, np.maximum(0, 1.5*features[c, fr, 19] - .5)) - p = p/(1e-18 + np.sum(p)) - #Cut off the tail of the remaining distribution - p = np.maximum(p-0.002, 0).astype('float64') - p = p/(1e-8 + np.sum(p)) - - fexc[0, 0, 2] = np.argmax(np.random.multinomial(1, p[0,0,:], 1)) - pcm[f*frame_size + i] = pred + ulaw2lin(fexc[0, 0, 2]) - fexc[0, 0, 0] = lin2ulaw(pcm[f*frame_size + i]) - mem = coef*mem + pcm[f*frame_size + i] - #print(mem) - np.array([np.round(mem)], dtype='int16').tofile(fout) - skip = 0 diff --git a/dnn/training_tf2/test_plc.py b/dnn/training_tf2/test_plc.py deleted file mode 100644 index 0c0ac25fa..000000000 --- a/dnn/training_tf2/test_plc.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2021-2022 Amazon - Copyright (c) 2018-2019 Mozilla - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' - -# Train an LPCNet model - -import argparse -from plc_loader import PLCLoader - -parser = argparse.ArgumentParser(description='Test a PLC model') - -parser.add_argument('weights', metavar='', help='weights file (.h5)') -parser.add_argument('features', metavar='', help='binary features file (float32)') -parser.add_argument('output', metavar='', help='reconstructed file (float32)') -parser.add_argument('--model', metavar='', default='lpcnet_plc', help='PLC model python definition (without .py)') -group1 = parser.add_mutually_exclusive_group() - -parser.add_argument('--gru-size', metavar='', default=256, type=int, help='number of units in GRU (default 256)') -parser.add_argument('--cond-size', metavar='', default=128, type=int, help='number of units in conditioning network (default 128)') - - -args = parser.parse_args() - -import importlib -lpcnet = importlib.import_module(args.model) - -import sys -import numpy as np -from tensorflow.keras.optimizers import Adam -from tensorflow.keras.callbacks import ModelCheckpoint, CSVLogger -import tensorflow.keras.backend as K -import h5py - -import tensorflow as tf -#gpus = tf.config.experimental.list_physical_devices('GPU') -#if gpus: -# try: -# tf.config.experimental.set_virtual_device_configuration(gpus[0], [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=5120)]) -# except RuntimeError as e: -# print(e) - -model = lpcnet.new_lpcnet_plc_model(rnn_units=args.gru_size, batch_size=1, training=False, quantize=False, cond_size=args.cond_size) -model.compile() - -lpc_order = 16 - -feature_file = args.features -nb_features = model.nb_used_features + lpc_order -nb_used_features = model.nb_used_features - -# u for unquantised, load 16 bit PCM samples and convert to mu-law - -features = np.loadtxt(feature_file) -print(features.shape) -sequence_size = features.shape[0] -lost = np.reshape(features[:,-1:], (1, sequence_size, 1)) -features = features[:,:nb_used_features] -features = np.reshape(features, (1, sequence_size, nb_used_features)) - - -model.load_weights(args.weights) - -features = features*lost -out = model.predict([features, lost]) - -out = features + (1-lost)*out - -np.savetxt(args.output, out[0,:,:]) diff --git a/dnn/training_tf2/tf_funcs.py b/dnn/training_tf2/tf_funcs.py deleted file mode 100644 index b86f075cf..000000000 --- a/dnn/training_tf2/tf_funcs.py +++ /dev/null @@ -1,70 +0,0 @@ -""" -Tensorflow/Keras helper functions to do the following: - 1. \mu law <-> Linear domain conversion - 2. Differentiable prediction from the input signal and LP coefficients - 3. Differentiable transformations Reflection Coefficients (RCs) <-> LP Coefficients -""" -from tensorflow.keras.layers import Lambda, Multiply, Layer, Concatenate -from tensorflow.keras import backend as K -import tensorflow as tf - -# \mu law <-> Linear conversion functions -scale = 255.0/32768.0 -scale_1 = 32768.0/255.0 -def tf_l2u(x): - s = K.sign(x) - x = K.abs(x) - u = (s*(128*K.log(1+scale*x)/K.log(256.0))) - u = K.clip(128 + u, 0, 255) - return u - -def tf_u2l(u): - u = tf.cast(u,"float32") - u = u - 128.0 - s = K.sign(u) - u = K.abs(u) - return s*scale_1*(K.exp(u/128.*K.log(256.0))-1) - -# Differentiable Prediction Layer -# Computes the LP prediction from the input lag signal and the LP coefficients -# The inputs xt and lpc conform with the shapes in lpcnet.py (the '2400' is coded keeping this in mind) -class diff_pred(Layer): - def call(self, inputs, lpcoeffs_N = 16, frame_size = 160): - xt = inputs[0] - lpc = inputs[1] - - rept = Lambda(lambda x: K.repeat_elements(x , frame_size, 1)) - zpX = Lambda(lambda x: K.concatenate([0*x[:,0:lpcoeffs_N,:], x],axis = 1)) - cX = Lambda(lambda x: K.concatenate([x[:,(lpcoeffs_N - i):(lpcoeffs_N - i + 2400),:] for i in range(lpcoeffs_N)],axis = 2)) - - pred = -Multiply()([rept(lpc),cX(zpX(xt))]) - - return K.sum(pred,axis = 2,keepdims = True) - -# Differentiable Transformations (RC <-> LPC) computed using the Levinson Durbin Recursion -class diff_rc2lpc(Layer): - def call(self, inputs, lpcoeffs_N = 16): - def pred_lpc_recursive(input): - temp = (input[0] + K.repeat_elements(input[1],input[0].shape[2],2)*K.reverse(input[0],axes = 2)) - temp = Concatenate(axis = 2)([temp,input[1]]) - return temp - Llpc = Lambda(pred_lpc_recursive) - inputs = inputs[:,:,:lpcoeffs_N] - lpc_init = inputs - for i in range(1,lpcoeffs_N): - lpc_init = Llpc([lpc_init[:,:,:i],K.expand_dims(inputs[:,:,i],axis = -1)]) - return lpc_init - -class diff_lpc2rc(Layer): - def call(self, inputs, lpcoeffs_N = 16): - def pred_rc_recursive(input): - ki = K.repeat_elements(K.expand_dims(input[1][:,:,0],axis = -1),input[0].shape[2],2) - temp = (input[0] - ki*K.reverse(input[0],axes = 2))/(1 - ki*ki) - temp = Concatenate(axis = 2)([temp,input[1]]) - return temp - Lrc = Lambda(pred_rc_recursive) - rc_init = inputs - for i in range(1,lpcoeffs_N): - j = (lpcoeffs_N - i + 1) - rc_init = Lrc([rc_init[:,:,:(j - 1)],rc_init[:,:,(j - 1):]]) - return rc_init diff --git a/dnn/training_tf2/train_lpcnet.py b/dnn/training_tf2/train_lpcnet.py deleted file mode 100755 index 60e2b56f5..000000000 --- a/dnn/training_tf2/train_lpcnet.py +++ /dev/null @@ -1,214 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2018 Mozilla - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' - -# Train an LPCNet model - -import argparse -import os - -from dataloader import LPCNetLoader - -parser = argparse.ArgumentParser(description='Train an LPCNet model') - -parser.add_argument('features', metavar='', help='binary features file (float32)') -parser.add_argument('data', metavar='