/* Copyright (c) 2022 Amazon Written by 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. */ #include #include #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "celt/entenc.h" #include "celt/vq.h" #include "celt/cwrs.h" #include "celt/laplace.h" #define LATENT_DIM 80 #define PVQ_DIM 24 #define PVQ_K 82 static void encode_pvq(const int *iy, int N, int K, ec_enc *enc) { int fits; celt_assert(N==24 || N==12 || N==6); fits = (N==24 && K<=9) || (N==12 && K<=16) || (N==6); /*printf("encode(%d,%d), fits=%d\n", N, K, fits);*/ if (fits) encode_pulses(iy, N, K, enc); else { int N2 = N/2; int K0=0; int i; for (i=0;i #define DATA_SIZE 10000 int main() { ec_enc enc; ec_dec dec; int iter; int bytes; opus_int16 scale[LATENT_DIM]; opus_int16 dzone[LATENT_DIM]; opus_int16 r[LATENT_DIM]; opus_int16 p0[LATENT_DIM]; unsigned char *ptr; int k; for (k=0;k