ref: bf0eaada0ae488421358a5df58c116f77152d78e
parent: 07bb3f01b4d93bebe02b05f618036d8a8dc0272a
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Wed Jun 21 21:14:08 EDT 2023
Remove useless LPCNet files
--- a/dnn/_kiss_fft_guts.h
+++ /dev/null
@@ -1,182 +1,0 @@
-/*Copyright (c) 2003-2004, Mark Borgerding
-
- All rights reserved.
-
- 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 KISS_FFT_GUTS_H
-#define KISS_FFT_GUTS_H
-
-#define MIN(a,b) ((a)<(b) ? (a):(b))
-#define MAX(a,b) ((a)>(b) ? (a):(b))
-
-/* kiss_fft.h
- defines kiss_fft_scalar as either short or a float type
- and defines
- typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */
-#include "kiss_fft.h"
-
-/*
- Explanation of macros dealing with complex math:
-
- C_MUL(m,a,b) : m = a*b
- C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise
- C_SUB( res, a,b) : res = a - b
- C_SUBFROM( res , a) : res -= a
- C_ADDTO( res , a) : res += a
- * */
-#ifdef FIXED_POINT
-#include "arch.h"
-
-
-#define SAMP_MAX 2147483647
-#define TWID_MAX 32767
-#define TRIG_UPSCALE 1
-
-#define SAMP_MIN -SAMP_MAX
-
-
-# define S_MUL(a,b) MULT16_32_Q15(b, a)
-
-# define C_MUL(m,a,b) \
- do{ (m).r = SUB32_ovflw(S_MUL((a).r,(b).r) , S_MUL((a).i,(b).i)); \
- (m).i = ADD32_ovflw(S_MUL((a).r,(b).i) , S_MUL((a).i,(b).r)); }while(0)
-
-# define C_MULC(m,a,b) \
- do{ (m).r = ADD32_ovflw(S_MUL((a).r,(b).r) , S_MUL((a).i,(b).i)); \
- (m).i = SUB32_ovflw(S_MUL((a).i,(b).r) , S_MUL((a).r,(b).i)); }while(0)
-
-# define C_MULBYSCALAR( c, s ) \
- do{ (c).r = S_MUL( (c).r , s ) ;\
- (c).i = S_MUL( (c).i , s ) ; }while(0)
-
-# define DIVSCALAR(x,k) \
- (x) = S_MUL( x, (TWID_MAX-((k)>>1))/(k)+1 )
-
-# define C_FIXDIV(c,div) \
- do { DIVSCALAR( (c).r , div); \
- DIVSCALAR( (c).i , div); }while (0)
-
-#define C_ADD( res, a,b)\
- do {(res).r=ADD32_ovflw((a).r,(b).r); (res).i=ADD32_ovflw((a).i,(b).i); \
- }while(0)
-#define C_SUB( res, a,b)\
- do {(res).r=SUB32_ovflw((a).r,(b).r); (res).i=SUB32_ovflw((a).i,(b).i); \
- }while(0)
-#define C_ADDTO( res , a)\
- do {(res).r = ADD32_ovflw((res).r, (a).r); (res).i = ADD32_ovflw((res).i,(a).i);\
- }while(0)
-
-#define C_SUBFROM( res , a)\
- 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)
-#include "arm/kiss_fft_armv4.h"
-#endif
-
-#if defined(OPUS_ARM_INLINE_EDSP)
-#include "arm/kiss_fft_armv5e.h"
-#endif
-#if defined(MIPSr1_ASM)
-#include "mips/kiss_fft_mipsr1.h"
-#endif
-
-#else /* not FIXED_POINT*/
-
-# define S_MUL(a,b) ( (a)*(b) )
-#define C_MUL(m,a,b) \
- do{ (m).r = (a).r*(b).r - (a).i*(b).i;\
- (m).i = (a).r*(b).i + (a).i*(b).r; }while(0)
-#define C_MULC(m,a,b) \
- do{ (m).r = (a).r*(b).r + (a).i*(b).i;\
- (m).i = (a).i*(b).r - (a).r*(b).i; }while(0)
-
-#define C_MUL4(m,a,b) C_MUL(m,a,b)
-
-# define C_FIXDIV(c,div) /* NOOP */
-# define C_MULBYSCALAR( c, s ) \
- do{ (c).r *= (s);\
- (c).i *= (s); }while(0)
-#endif
-
-#ifndef CHECK_OVERFLOW_OP
-# define CHECK_OVERFLOW_OP(a,op,b) /* noop */
-#endif
-
-#ifndef C_ADD
-#define C_ADD( res, a,b)\
- do { \
- CHECK_OVERFLOW_OP((a).r,+,(b).r)\
- CHECK_OVERFLOW_OP((a).i,+,(b).i)\
- (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \
- }while(0)
-#define C_SUB( res, a,b)\
- do { \
- CHECK_OVERFLOW_OP((a).r,-,(b).r)\
- CHECK_OVERFLOW_OP((a).i,-,(b).i)\
- (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \
- }while(0)
-#define C_ADDTO( res , a)\
- do { \
- CHECK_OVERFLOW_OP((res).r,+,(a).r)\
- CHECK_OVERFLOW_OP((res).i,+,(a).i)\
- (res).r += (a).r; (res).i += (a).i;\
- }while(0)
-
-#define C_SUBFROM( res , a)\
- do {\
- CHECK_OVERFLOW_OP((res).r,-,(a).r)\
- CHECK_OVERFLOW_OP((res).i,-,(a).i)\
- (res).r -= (a).r; (res).i -= (a).i; \
- }while(0)
-#endif /* C_ADD defined */
-
-#ifdef FIXED_POINT
-/*# define KISS_FFT_COS(phase) TRIG_UPSCALE*floor(MIN(32767,MAX(-32767,.5+32768 * cos (phase))))
-# define KISS_FFT_SIN(phase) TRIG_UPSCALE*floor(MIN(32767,MAX(-32767,.5+32768 * sin (phase))))*/
-# define KISS_FFT_COS(phase) floor(.5+TWID_MAX*cos (phase))
-# define KISS_FFT_SIN(phase) floor(.5+TWID_MAX*sin (phase))
-# define HALF_OF(x) ((x)>>1)
-#elif defined(USE_SIMD)
-# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) )
-# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) )
-# define HALF_OF(x) ((x)*_mm_set1_ps(.5f))
-#else
-# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase)
-# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase)
-# define HALF_OF(x) ((x)*.5f)
-#endif
-
-#define kf_cexp(x,phase) \
- do{ \
- (x)->r = KISS_FFT_COS(phase);\
- (x)->i = KISS_FFT_SIN(phase);\
- }while(0)
-
-#define kf_cexp2(x,phase) \
- do{ \
- (x)->r = TRIG_UPSCALE*celt_cos_norm((phase));\
- (x)->i = TRIG_UPSCALE*celt_cos_norm((phase)-32768);\
-}while(0)
-
-#endif /* KISS_FFT_GUTS_H */
--- a/dnn/ceps_vq_train.c
+++ /dev/null
@@ -1,619 +1,0 @@
-
-#include <valgrind/memcheck.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#define COEF 0.0f
-#define MAX_ENTRIES 16384
-
-#define MULTI 4
-#define MULTI_MASK (MULTI-1)
-
-void compute_weights(const float *x, float *w, int ndim)
-{
- int i;
- w[0] = MIN(x[0], x[1]-x[0]);
- for (i=1;i<ndim-1;i++)
- w[i] = MIN(x[i]-x[i-1], x[i+1]-x[i]);
- w[ndim-1] = MIN(x[ndim-1]-x[ndim-2], M_PI-x[ndim-1]);
-
- for (i=0;i<ndim;i++)
- w[i] = 1./(.01+w[i]);
- w[0]*=3;
- w[1]*=2;
- /*
- for (i=0;i<ndim;i++)
- w[i] = 1;*/
-}
-
-int find_nearest(const float *codebook, int nb_entries, const float *x, int ndim, float *dist)
-{
- int i, j;
- float min_dist = 1e15;
- int nearest = 0;
-
- for (i=0;i<nb_entries;i++)
- {
- float dist=0;
- for (j=0;j<ndim;j++)
- dist += (x[j]-codebook[i*ndim+j])*(x[j]-codebook[i*ndim+j]);
- if (dist<min_dist)
- {
- min_dist = dist;
- nearest = i;
- }
- }
- if (dist)
- *dist = min_dist;
- return nearest;
-}
-
-int find_nearest_multi(const float *codebook, int nb_entries, const float *x, int ndim, float *dist, int sign)
-{
- int i, j;
- float min_dist = 1e15;
- int nearest = 0;
-
- for (i=0;i<nb_entries;i++)
- {
- int offset;
- float dist=0;
- offset = (i&MULTI_MASK)*ndim;
- for (j=0;j<ndim;j++)
- dist += (x[offset+j]-codebook[i*ndim+j])*(x[offset+j]-codebook[i*ndim+j]);
- if (dist<min_dist)
- {
- min_dist = dist;
- nearest = i;
- }
- }
- if (sign) {
- for (i=0;i<nb_entries;i++)
- {
- int offset;
- float dist=0;
- offset = (i&MULTI_MASK)*ndim;
- for (j=0;j<ndim;j++)
- dist += (x[offset+j]+codebook[i*ndim+j])*(x[offset+j]+codebook[i*ndim+j]);
- if (dist<min_dist)
- {
- min_dist = dist;
- nearest = i+nb_entries;
- }
- }
- }
- if (dist)
- *dist = min_dist;
- return nearest;
-}
-
-
-int find_nearest_weighted(const float *codebook, int nb_entries, float *x, const float *w, int ndim)
-{
- int i, j;
- float min_dist = 1e15;
- int nearest = 0;
-
- for (i=0;i<nb_entries;i++)
- {
- float dist=0;
- for (j=0;j<ndim;j++)
- dist += w[j]*(x[j]-codebook[i*ndim+j])*(x[j]-codebook[i*ndim+j]);
- if (dist<min_dist)
- {
- min_dist = dist;
- nearest = i;
- }
- }
- return nearest;
-}
-
-int quantize_lsp(const float *x, const float *codebook1, const float *codebook2,
- const float *codebook3, int nb_entries, float *xq, int ndim)
-{
- int i, n1, n2, n3;
- float err[ndim], err2[ndim], err3[ndim];
- float w[ndim], w2[ndim], w3[ndim];
-
- w[0] = MIN(x[0], x[1]-x[0]);
- for (i=1;i<ndim-1;i++)
- w[i] = MIN(x[i]-x[i-1], x[i+1]-x[i]);
- w[ndim-1] = MIN(x[ndim-1]-x[ndim-2], M_PI-x[ndim-1]);
-
- /*
- for (i=0;i<ndim;i++)
- w[i] = 1./(.003+w[i]);
- w[0]*=3;
- w[1]*=2;*/
- compute_weights(x, w, ndim);
-
- for (i=0;i<ndim;i++)
- err[i] = x[i]-COEF*xq[i];
- n1 = find_nearest(codebook1, nb_entries, err, ndim, NULL);
-
- for (i=0;i<ndim;i++)
- {
- xq[i] = COEF*xq[i] + codebook1[ndim*n1+i];
- err[i] -= codebook1[ndim*n1+i];
- }
- for (i=0;i<ndim/2;i++)
- {
- err2[i] = err[2*i];
- err3[i] = err[2*i+1];
- w2[i] = w[2*i];
- w3[i] = w[2*i+1];
- }
- n2 = find_nearest_weighted(codebook2, nb_entries, err2, w2, ndim/2);
- n3 = find_nearest_weighted(codebook3, nb_entries, err3, w3, ndim/2);
-
- for (i=0;i<ndim/2;i++)
- {
- xq[2*i] += codebook2[ndim*n2/2+i];
- xq[2*i+1] += codebook3[ndim*n3/2+i];
- }
- return 0;
-}
-
-void split(float *codebook, int nb_entries, int ndim)
-{
- int i,j;
- for (i=0;i<nb_entries;i++)
- {
- for (j=0;j<ndim;j++)
- {
- float delta = .01*(rand()/(float)RAND_MAX-.5);
- codebook[i*ndim+j] += delta;
- codebook[(i+nb_entries)*ndim+j] = codebook[i*ndim+j] - delta;
- }
- }
-}
-
-
-void split1(float *codebook, int nb_entries, const float *data, int nb_vectors, int ndim)
-{
- int i,j;
- int nearest[nb_vectors];
- float dist[nb_entries];
- int count[nb_entries];
- int worst;
- for (i=0;i<nb_entries;i++)
- dist[i] = 0;
- for (i=0;i<nb_entries;i++)
- count[i]=0;
- for (i=0;i<nb_vectors;i++)
- {
- float d;
- nearest[i] = find_nearest(codebook, nb_entries, data+i*ndim, ndim, &d);
- dist[nearest[i]] += d;
- count[nearest[i]]++;
- }
-
- worst=0;
- for (i=1;i<nb_entries;i++)
- {
- if (dist[i] > dist[worst])
- worst=i;
- }
-
- for (j=0;j<ndim;j++)
- {
- float delta = .001*(rand()/(float)RAND_MAX-.5);
- codebook[worst*ndim+j] += delta;
- codebook[nb_entries*ndim+j] = codebook[worst*ndim+j] - delta;
- }
-}
-
-
-
-void update(float *data, int nb_vectors, float *codebook, int nb_entries, int ndim)
-{
- int i,j;
- int count[nb_entries];
- int nearest[nb_vectors];
- double err=0;
-
- for (i=0;i<nb_entries;i++)
- count[i] = 0;
-
- for (i=0;i<nb_vectors;i++)
- {
- float dist;
- nearest[i] = find_nearest(codebook, nb_entries, data+i*ndim, ndim, &dist);
- err += dist;
- }
- printf("RMS error = %f\n", sqrt(err/nb_vectors/ndim));
- for (i=0;i<nb_entries*ndim;i++)
- codebook[i] = 0;
-
- for (i=0;i<nb_vectors;i++)
- {
- int n = nearest[i];
- count[n]++;
- for (j=0;j<ndim;j++)
- codebook[n*ndim+j] += data[i*ndim+j];
- }
-
- float w2=0;
- int min_count = 1000000000;
- int small=0;
- for (i=0;i<nb_entries;i++)
- {
- for (j=0;j<ndim;j++)
- codebook[i*ndim+j] *= (1./count[i]);
- w2 += (count[i]/(float)nb_vectors)*(count[i]/(float)nb_vectors);
- if (count[i] < min_count) min_count = count[i];
- small += (count[i] < 50);
- }
- fprintf(stderr, "%f / %d, min = %d, small=%d\n", 1./w2, nb_entries, min_count, small);
-}
-
-void update_multi(float *data, int nb_vectors, float *codebook, int nb_entries, int ndim, int sign)
-{
- int i,j;
- int count[nb_entries];
- int idcount[8]={0};
- int nearest[nb_vectors];
- double err=0;
-
- for (i=0;i<nb_entries;i++)
- count[i] = 0;
-
- for (i=0;i<nb_vectors;i++)
- {
- float dist;
- nearest[i] = find_nearest_multi(codebook, nb_entries, data+MULTI*i*ndim, ndim, &dist, sign);
- err += dist;
- }
- printf("RMS error = %f\n", sqrt(err/nb_vectors/ndim));
- for (i=0;i<nb_entries*ndim;i++)
- codebook[i] = 0;
-
- for (i=0;i<nb_vectors;i++)
- {
- int n = nearest[i] % nb_entries;
- float sign = nearest[i] < nb_entries ? 1 : -1;
- count[n]++;
- idcount[(n&MULTI_MASK) + 4*(sign!=1)]++;
- for (j=0;j<ndim;j++)
- codebook[n*ndim+j] += sign*data[(MULTI*i + (n&MULTI_MASK))*ndim+j];
- }
-
- float w2=0;
- int min_count = 1000000000;
- int small=0;
- for (i=0;i<nb_entries;i++)
- {
- for (j=0;j<ndim;j++)
- codebook[i*ndim+j] *= (1./count[i]);
- w2 += (count[i]/(float)nb_vectors)*(count[i]/(float)nb_vectors);
- if (count[i] < min_count) min_count = count[i];
- small += (count[i] < 50);
- }
- fprintf(stderr, "%d %d %d %d %d %d %d %d ", idcount[0], idcount[1], idcount[2], idcount[3], idcount[4], idcount[5], idcount[6], idcount[7]);
- fprintf(stderr, "| %f / %d, min = %d, small=%d\n", 1./w2, nb_entries, min_count, small);
-}
-
-
-void update_weighted(float *data, float *weight, int nb_vectors, float *codebook, int nb_entries, int ndim)
-{
- int i,j;
- float count[MAX_ENTRIES][ndim];
- int nearest[nb_vectors];
-
- for (i=0;i<nb_entries;i++)
- for (j=0;j<ndim;j++)
- count[i][j] = 0;
-
- for (i=0;i<nb_vectors;i++)
- {
- nearest[i] = find_nearest_weighted(codebook, nb_entries, data+i*ndim, weight+i*ndim, ndim);
- }
- for (i=0;i<nb_entries*ndim;i++)
- codebook[i] = 0;
-
- for (i=0;i<nb_vectors;i++)
- {
- int n = nearest[i];
- for (j=0;j<ndim;j++)
- {
- float w = sqrt(weight[i*ndim+j]);
- count[n][j]+=w;
- codebook[n*ndim+j] += w*data[i*ndim+j];
- }
- }
-
- //float w2=0;
- for (i=0;i<nb_entries;i++)
- {
- for (j=0;j<ndim;j++)
- codebook[i*ndim+j] *= (1./count[i][j]);
- //w2 += (count[i]/(float)nb_vectors)*(count[i]/(float)nb_vectors);
- }
- //fprintf(stderr, "%f / %d\n", 1./w2, nb_entries);
-}
-
-void vq_train(float *data, int nb_vectors, float *codebook, int nb_entries, int ndim)
-{
- int i, j, e;
- e = 1;
- for (j=0;j<ndim;j++)
- codebook[j] = 0;
- for (i=0;i<nb_vectors;i++)
- for (j=0;j<ndim;j++)
- codebook[j] += data[i*ndim+j];
- for (j=0;j<ndim;j++)
- codebook[j] *= (1./nb_vectors);
-
-
- while (e< nb_entries)
- {
-#if 1
- split(codebook, e, ndim);
- e<<=1;
-#else
- split1(codebook, e, data, nb_vectors, ndim);
- e++;
-#endif
- fprintf(stderr, "%d\n", e);
- for (j=0;j<4;j++)
- update(data, nb_vectors, codebook, e, ndim);
- }
- for (j=0;j<20;j++)
- update(data, nb_vectors, codebook, e, ndim);
-}
-
-void vq_train_multi(float *data, int nb_vectors, float *codebook, int nb_entries, int ndim, int sign)
-{
- int i, j, e;
-#if 1
- for (e=0;e<MULTI;e++) {
- for (j=0;j<ndim;j++)
- codebook[e*ndim+j] = 0;
- for (i=0;i<nb_vectors;i++)
- for (j=0;j<ndim;j++)
- codebook[e*ndim+j] += data[(MULTI*i+e)*ndim+j];
- for (j=0;j<ndim;j++) {
- float delta = .01*(rand()/(float)RAND_MAX-.5);
- codebook[e*ndim+j] *= (1./nb_vectors);
- codebook[e*ndim+j] += delta;
- }
- }
-#else
- for (i=0;i<MULTI*ndim;i++) codebook[i] = .01*(rand()/(float)RAND_MAX-.5);
-#endif
- e = MULTI;
- for (j=0;j<10;j++)
- update_multi(data, nb_vectors, codebook, e, ndim, sign);
-
- while (e < nb_entries)
- {
- split(codebook, e, ndim);
- e<<=1;
- fprintf(stderr, "%d\n", e);
- for (j=0;j<4;j++)
- update_multi(data, nb_vectors, codebook, e, ndim, sign);
- }
- for (j=0;j<20;j++)
- update_multi(data, nb_vectors, codebook, e, ndim, sign);
-}
-
-
-void vq_train_weighted(float *data, float *weight, int nb_vectors, float *codebook, int nb_entries, int ndim)
-{
- int i, j, e;
- e = 1;
- for (j=0;j<ndim;j++)
- codebook[j] = 0;
- for (i=0;i<nb_vectors;i++)
- for (j=0;j<ndim;j++)
- codebook[j] += data[i*ndim+j];
- for (j=0;j<ndim;j++)
- codebook[j] *= (1./nb_vectors);
-
-
- while (e< nb_entries)
- {
-#if 0
- split(codebook, e, ndim);
- e<<=1;
-#else
- split1(codebook, e, data, nb_vectors, ndim);
- e++;
-#endif
- fprintf(stderr, "%d\n", e);
- for (j=0;j<ndim;j++)
- update_weighted(data, weight, nb_vectors, codebook, e, ndim);
- }
-}
-
-
-int main(int argc, char **argv)
-{
- int i,j;
- int nb_vectors, nb_entries, nb_entries1, nb_entries2a, nb_entries2b, ndim, ndim0, total_dim;
- float *data, *pred, *multi_data, *multi_data2, *qdata;
- float *codebook, *codebook2, *codebook3, *codebook_diff2, *codebook_diff4;
- float *delta;
- double err;
- FILE *fout;
-
- ndim = atoi(argv[1]);
- ndim0 = ndim-1;
- total_dim = atoi(argv[2]);
- nb_vectors = atoi(argv[3]);
- nb_entries = 1<<atoi(argv[4]);
- nb_entries1 = 1024;
- nb_entries2a = 4096;
- nb_entries2b = 64;
-
- data = malloc((nb_vectors*ndim+total_dim)*sizeof(*data));
- qdata = malloc((nb_vectors*ndim+total_dim)*sizeof(*qdata));
- pred = malloc(nb_vectors*ndim0*sizeof(*pred));
- multi_data = malloc(MULTI*nb_vectors*ndim*sizeof(*multi_data));
- multi_data2 = malloc(MULTI*nb_vectors*ndim*sizeof(*multi_data));
- codebook = malloc(nb_entries*ndim0*sizeof(*codebook));
- codebook2 = malloc(nb_entries1*ndim0*sizeof(*codebook2));
- codebook3 = malloc(nb_entries1*ndim0*sizeof(*codebook3));
- codebook_diff4 = malloc(nb_entries2a*ndim*sizeof(*codebook_diff4));
- codebook_diff2 = malloc(nb_entries2b*ndim*sizeof(*codebook_diff2));
-
- for (i=0;i<nb_vectors;i++)
- {
- fread(&data[i*ndim], sizeof(float), total_dim, stdin);
- if (feof(stdin))
- break;
- }
- nb_vectors = i;
- VALGRIND_CHECK_MEM_IS_DEFINED(data, nb_entries*ndim);
-
- for (i=0;i<4;i++)
- {
- for (j=0;j<ndim0;j++)
- pred[i*ndim0+j] = 0;
- }
- for (i=4;i<nb_vectors;i++)
- {
- for (j=0;j<ndim0;j++)
- pred[i*ndim0+j] = data[i*ndim+j+1] - COEF*data[(i-4)*ndim+j+1];
- }
-#if 1
- VALGRIND_CHECK_MEM_IS_DEFINED(pred, nb_entries*ndim0);
- vq_train(pred, nb_vectors, codebook, nb_entries, ndim0);
-
- delta = malloc(nb_vectors*ndim0*sizeof(*data));
- err = 0;
- for (i=0;i<nb_vectors;i++)
- {
- int nearest = find_nearest(codebook, nb_entries, &pred[i*ndim0], ndim0, NULL);
- qdata[i*ndim] = data[i*ndim];
- for (j=0;j<ndim0;j++)
- {
- qdata[i*ndim+j+1] = codebook[nearest*ndim0+j];
- delta[i*ndim0+j] = pred[i*ndim0+j] - codebook[nearest*ndim0+j];
- err += delta[i*ndim0+j]*delta[i*ndim0+j];
- }
- //printf("\n");
- }
- fprintf(stderr, "Cepstrum RMS error: %f\n", sqrt(err/nb_vectors/ndim));
-
- vq_train(delta, nb_vectors, codebook2, nb_entries1, ndim0);
-
- err=0;
- for (i=0;i<nb_vectors;i++)
- {
- int n1;
- n1 = find_nearest(codebook2, nb_entries1, &delta[i*ndim0], ndim0, NULL);
- for (j=0;j<ndim0;j++)
- {
- qdata[i*ndim+j+1] += codebook2[n1*ndim0+j];
- //delta[i*ndim0+j] = delta[i*ndim0+j] - codebook2[n1*ndim0+j];
- delta[i*ndim0+j] = data[i*ndim+j+1] - qdata[i*ndim+j+1];
- err += delta[i*ndim0+j]*delta[i*ndim0+j];
- }
- }
- fprintf(stderr, "Cepstrum RMS error after stage 2: %f)\n", sqrt(err/nb_vectors/ndim));
-
- vq_train(delta, nb_vectors, codebook3, nb_entries1, ndim0);
- err=0;
- for (i=0;i<nb_vectors;i++)
- {
- int n1;
- n1 = find_nearest(codebook3, nb_entries1, &delta[i*ndim0], ndim0, NULL);
- for (j=0;j<ndim0;j++)
- {
- qdata[i*ndim+j+1] += codebook3[n1*ndim0+j];
- //delta[i*ndim0+j] = delta[i*ndim0+j] - codebook2[n1*ndim0+j];
- delta[i*ndim0+j] = data[i*ndim+j+1] - qdata[i*ndim+j+1];
- err += delta[i*ndim0+j]*delta[i*ndim0+j];
- }
- }
- fprintf(stderr, "Cepstrum RMS error after stage 3: %f)\n", sqrt(err/nb_vectors/ndim));
-#else
- qdata = data;
-#endif
- for (i=0;i<nb_vectors-4;i++)
- {
- for (j=0;j<ndim;j++)
- multi_data[MULTI*i*ndim+j] = data[(i+1)*ndim+j] - .5*(qdata[i*ndim+j]+qdata[(i+2)*ndim+j]);
- for (j=0;j<ndim;j++)
- multi_data[(MULTI*i+1)*ndim+j] = data[(i+1)*ndim+j] - .5*(qdata[i*ndim+j]+qdata[(i+2)*ndim+j]);
- for (j=0;j<ndim;j++)
- multi_data[(MULTI*i+2)*ndim+j] = data[(i+1)*ndim+j] - qdata[i*ndim+j];
- for (j=0;j<ndim;j++)
- multi_data[(MULTI*i+3)*ndim+j] = data[(i+1)*ndim+j] - qdata[(i+2)*ndim+j];
- //for (j=0;j<4*ndim;j++) printf("%f ", multi_data[MULTI*i*ndim + j]);
- //printf("\n");
- }
-
- for (i=0;i<nb_vectors-4;i++)
- {
- for (j=0;j<ndim;j++)
- multi_data2[MULTI*i*ndim+j] = data[(i+2)*ndim+j] - .5*(qdata[i*ndim+j]+qdata[(i+4)*ndim+j]);
- for (j=0;j<ndim;j++)
- multi_data2[(MULTI*i+1)*ndim+j] = data[(i+2)*ndim+j] - .5*(qdata[i*ndim+j]+qdata[(i+4)*ndim+j]);
- for (j=0;j<ndim;j++)
- multi_data2[(MULTI*i+2)*ndim+j] = data[(i+2)*ndim+j] - qdata[i*ndim+j];
- for (j=0;j<ndim;j++)
- multi_data2[(MULTI*i+3)*ndim+j] = data[(i+2)*ndim+j] - qdata[(i+4)*ndim+j];
- }
-
- vq_train_multi(multi_data2, nb_vectors-4, codebook_diff4, nb_entries2a, ndim, 1);
-
- printf("done\n");
- vq_train_multi(multi_data, nb_vectors-4, codebook_diff2, nb_entries2b, ndim, 0);
-
-
- fout = fopen("ceps_codebooks.c", "w");
- fprintf(fout, "/* This file is automatically generated */\n\n");
- fprintf(fout, "float ceps_codebook1[%d*%d] = {\n",nb_entries, ndim0);
-
- for (i=0;i<nb_entries;i++)
- {
- for (j=0;j<ndim0;j++)
- fprintf(fout, "%f, ", codebook[i*ndim0+j]);
- fprintf(fout, "\n");
- }
- fprintf(fout, "};\n\n");
-
- fprintf(fout, "float ceps_codebook2[%d*%d] = {\n",nb_entries1, ndim0);
- for (i=0;i<nb_entries1;i++)
- {
- for (j=0;j<ndim0;j++)
- fprintf(fout, "%f, ", codebook2[i*ndim0+j]);
- fprintf(fout, "\n");
- }
- fprintf(fout, "};\n\n");
-
- fprintf(fout, "float ceps_codebook3[%d*%d] = {\n",nb_entries1, ndim0);
- for (i=0;i<nb_entries1;i++)
- {
- for (j=0;j<ndim0;j++)
- fprintf(fout, "%f, ", codebook3[i*ndim0+j]);
- fprintf(fout, "\n");
- }
- fprintf(fout, "};\n\n");
-
- fprintf(fout, "float ceps_codebook_diff4[%d*%d] = {\n",nb_entries2a, ndim);
- for (i=0;i<nb_entries2a;i++)
- {
- for (j=0;j<ndim;j++)
- fprintf(fout, "%f, ", codebook_diff4[i*ndim+j]);
- fprintf(fout, "\n");
- }
- fprintf(fout, "};\n\n");
-
- fprintf(fout, "float ceps_codebook_diff2[%d*%d] = {\n",nb_entries2b, ndim);
- for (i=0;i<nb_entries2b;i++)
- {
- for (j=0;j<ndim;j++)
- fprintf(fout, "%f, ", codebook_diff2[i*ndim+j]);
- fprintf(fout, "\n");
- }
- fprintf(fout, "};\n\n");
-
- fclose(fout);
- return 0;
-}
--- a/dnn/kiss_fft.c
+++ /dev/null
@@ -1,601 +1,0 @@
-/*Copyright (c) 2003-2004, Mark Borgerding
- Lots of modifications by Jean-Marc Valin
- Copyright (c) 2005-2007, Xiph.Org Foundation
- Copyright (c) 2008, Xiph.Org Foundation, CSIRO
-
- All rights reserved.
-
- 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.*/
-
-/* This code is originally from Mark Borgerding's KISS-FFT but has been
- heavily modified to better suit Opus */
-
-#ifndef SKIP_CONFIG_H
-# ifdef HAVE_CONFIG_H
-# include "config.h"
-# endif
-#endif
-
-#include "_kiss_fft_guts.h"
-#define CUSTOM_MODES
-
-/* The guts header contains all the multiplication and addition macros that are defined for
- complex numbers. It also delares the kf_ internal functions.
-*/
-
-static void kf_bfly2(
- kiss_fft_cpx * Fout,
- int m,
- int N
- )
-{
- kiss_fft_cpx * Fout2;
- int i;
- (void)m;
-#ifdef CUSTOM_MODES
- if (m==1)
- {
- celt_assert(m==1);
- for (i=0;i<N;i++)
- {
- kiss_fft_cpx t;
- Fout2 = Fout + 1;
- t = *Fout2;
- C_SUB( *Fout2 , *Fout , t );
- C_ADDTO( *Fout , t );
- Fout += 2;
- }
- } else
-#endif
- {
- opus_val16 tw;
- tw = QCONST16(0.7071067812f, 15);
- /* We know that m==4 here because the radix-2 is just after a radix-4 */
- celt_assert(m==4);
- for (i=0;i<N;i++)
- {
- kiss_fft_cpx t;
- Fout2 = Fout + 4;
- t = Fout2[0];
- C_SUB( Fout2[0] , Fout[0] , t );
- C_ADDTO( Fout[0] , t );
-
- t.r = S_MUL(ADD32_ovflw(Fout2[1].r, Fout2[1].i), tw);
- t.i = S_MUL(SUB32_ovflw(Fout2[1].i, Fout2[1].r), tw);
- C_SUB( Fout2[1] , Fout[1] , t );
- C_ADDTO( Fout[1] , t );
-
- t.r = Fout2[2].i;
- t.i = -Fout2[2].r;
- C_SUB( Fout2[2] , Fout[2] , t );
- C_ADDTO( Fout[2] , t );
-
- t.r = S_MUL(SUB32_ovflw(Fout2[3].i, Fout2[3].r), tw);
- t.i = S_MUL(NEG32_ovflw(ADD32_ovflw(Fout2[3].i, Fout2[3].r)), tw);
- C_SUB( Fout2[3] , Fout[3] , t );
- C_ADDTO( Fout[3] , t );
- Fout += 8;
- }
- }
-}
-
-static void kf_bfly4(
- kiss_fft_cpx * Fout,
- const size_t fstride,
- const kiss_fft_state *st,
- int m,
- int N,
- int mm
- )
-{
- int i;
-
- if (m==1)
- {
- /* Degenerate case where all the twiddles are 1. */
- for (i=0;i<N;i++)
- {
- kiss_fft_cpx scratch0, scratch1;
-
- C_SUB( scratch0 , *Fout, Fout[2] );
- C_ADDTO(*Fout, Fout[2]);
- C_ADD( scratch1 , Fout[1] , Fout[3] );
- C_SUB( Fout[2], *Fout, scratch1 );
- C_ADDTO( *Fout , scratch1 );
- C_SUB( scratch1 , Fout[1] , Fout[3] );
-
- Fout[1].r = ADD32_ovflw(scratch0.r, scratch1.i);
- Fout[1].i = SUB32_ovflw(scratch0.i, scratch1.r);
- Fout[3].r = SUB32_ovflw(scratch0.r, scratch1.i);
- Fout[3].i = ADD32_ovflw(scratch0.i, scratch1.r);
- Fout+=4;
- }
- } else {
- int j;
- kiss_fft_cpx scratch[6];
- const kiss_twiddle_cpx *tw1,*tw2,*tw3;
- const int m2=2*m;
- const int m3=3*m;
- kiss_fft_cpx * Fout_beg = Fout;
- for (i=0;i<N;i++)
- {
- Fout = Fout_beg + i*mm;
- tw3 = tw2 = tw1 = st->twiddles;
- /* m is guaranteed to be a multiple of 4. */
- for (j=0;j<m;j++)
- {
- C_MUL(scratch[0],Fout[m] , *tw1 );
- C_MUL(scratch[1],Fout[m2] , *tw2 );
- C_MUL(scratch[2],Fout[m3] , *tw3 );
-
- C_SUB( scratch[5] , *Fout, scratch[1] );
- C_ADDTO(*Fout, scratch[1]);
- C_ADD( scratch[3] , scratch[0] , scratch[2] );
- C_SUB( scratch[4] , scratch[0] , scratch[2] );
- C_SUB( Fout[m2], *Fout, scratch[3] );
- tw1 += fstride;
- tw2 += fstride*2;
- tw3 += fstride*3;
- C_ADDTO( *Fout , scratch[3] );
-
- Fout[m].r = ADD32_ovflw(scratch[5].r, scratch[4].i);
- Fout[m].i = SUB32_ovflw(scratch[5].i, scratch[4].r);
- Fout[m3].r = SUB32_ovflw(scratch[5].r, scratch[4].i);
- Fout[m3].i = ADD32_ovflw(scratch[5].i, scratch[4].r);
- ++Fout;
- }
- }
- }
-}
-
-
-#ifndef RADIX_TWO_ONLY
-
-static void kf_bfly3(
- kiss_fft_cpx * Fout,
- const size_t fstride,
- const kiss_fft_state *st,
- int m,
- int N,
- int mm
- )
-{
- int i;
- size_t k;
- const size_t m2 = 2*m;
- const kiss_twiddle_cpx *tw1,*tw2;
- kiss_fft_cpx scratch[5];
- kiss_twiddle_cpx epi3;
-
- kiss_fft_cpx * Fout_beg = Fout;
-#ifdef FIXED_POINT
- /*epi3.r = -16384;*/ /* Unused */
- epi3.i = -28378;
-#else
- epi3 = st->twiddles[fstride*m];
-#endif
- for (i=0;i<N;i++)
- {
- Fout = Fout_beg + i*mm;
- tw1=tw2=st->twiddles;
- /* For non-custom modes, m is guaranteed to be a multiple of 4. */
- k=m;
- do {
-
- C_MUL(scratch[1],Fout[m] , *tw1);
- C_MUL(scratch[2],Fout[m2] , *tw2);
-
- C_ADD(scratch[3],scratch[1],scratch[2]);
- C_SUB(scratch[0],scratch[1],scratch[2]);
- tw1 += fstride;
- tw2 += fstride*2;
-
- Fout[m].r = SUB32_ovflw(Fout->r, HALF_OF(scratch[3].r));
- Fout[m].i = SUB32_ovflw(Fout->i, HALF_OF(scratch[3].i));
-
- C_MULBYSCALAR( scratch[0] , epi3.i );
-
- C_ADDTO(*Fout,scratch[3]);
-
- Fout[m2].r = ADD32_ovflw(Fout[m].r, scratch[0].i);
- Fout[m2].i = SUB32_ovflw(Fout[m].i, scratch[0].r);
-
- Fout[m].r = SUB32_ovflw(Fout[m].r, scratch[0].i);
- Fout[m].i = ADD32_ovflw(Fout[m].i, scratch[0].r);
-
- ++Fout;
- } while(--k);
- }
-}
-
-
-#ifndef OVERRIDE_kf_bfly5
-static void kf_bfly5(
- kiss_fft_cpx * Fout,
- const size_t fstride,
- const kiss_fft_state *st,
- int m,
- int N,
- int mm
- )
-{
- kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4;
- int i, u;
- kiss_fft_cpx scratch[13];
- const kiss_twiddle_cpx *tw;
- kiss_twiddle_cpx ya,yb;
- kiss_fft_cpx * Fout_beg = Fout;
-
-#ifdef FIXED_POINT
- ya.r = 10126;
- ya.i = -31164;
- yb.r = -26510;
- yb.i = -19261;
-#else
- ya = st->twiddles[fstride*m];
- yb = st->twiddles[fstride*2*m];
-#endif
- tw=st->twiddles;
-
- for (i=0;i<N;i++)
- {
- Fout = Fout_beg + i*mm;
- Fout0=Fout;
- Fout1=Fout0+m;
- Fout2=Fout0+2*m;
- Fout3=Fout0+3*m;
- Fout4=Fout0+4*m;
-
- /* For non-custom modes, m is guaranteed to be a multiple of 4. */
- for ( u=0; u<m; ++u ) {
- scratch[0] = *Fout0;
-
- C_MUL(scratch[1] ,*Fout1, tw[u*fstride]);
- C_MUL(scratch[2] ,*Fout2, tw[2*u*fstride]);
- C_MUL(scratch[3] ,*Fout3, tw[3*u*fstride]);
- C_MUL(scratch[4] ,*Fout4, tw[4*u*fstride]);
-
- C_ADD( scratch[7],scratch[1],scratch[4]);
- C_SUB( scratch[10],scratch[1],scratch[4]);
- C_ADD( scratch[8],scratch[2],scratch[3]);
- C_SUB( scratch[9],scratch[2],scratch[3]);
-
- Fout0->r = ADD32_ovflw(Fout0->r, ADD32_ovflw(scratch[7].r, scratch[8].r));
- Fout0->i = ADD32_ovflw(Fout0->i, ADD32_ovflw(scratch[7].i, scratch[8].i));
-
- scratch[5].r = ADD32_ovflw(scratch[0].r, ADD32_ovflw(S_MUL(scratch[7].r,ya.r), S_MUL(scratch[8].r,yb.r)));
- scratch[5].i = ADD32_ovflw(scratch[0].i, ADD32_ovflw(S_MUL(scratch[7].i,ya.r), S_MUL(scratch[8].i,yb.r)));
-
- scratch[6].r = ADD32_ovflw(S_MUL(scratch[10].i,ya.i), S_MUL(scratch[9].i,yb.i));
- scratch[6].i = NEG32_ovflw(ADD32_ovflw(S_MUL(scratch[10].r,ya.i), S_MUL(scratch[9].r,yb.i)));
-
- C_SUB(*Fout1,scratch[5],scratch[6]);
- C_ADD(*Fout4,scratch[5],scratch[6]);
-
- scratch[11].r = ADD32_ovflw(scratch[0].r, ADD32_ovflw(S_MUL(scratch[7].r,yb.r), S_MUL(scratch[8].r,ya.r)));
- scratch[11].i = ADD32_ovflw(scratch[0].i, ADD32_ovflw(S_MUL(scratch[7].i,yb.r), S_MUL(scratch[8].i,ya.r)));
- scratch[12].r = SUB32_ovflw(S_MUL(scratch[9].i,ya.i), S_MUL(scratch[10].i,yb.i));
- scratch[12].i = SUB32_ovflw(S_MUL(scratch[10].r,yb.i), S_MUL(scratch[9].r,ya.i));
-
- C_ADD(*Fout2,scratch[11],scratch[12]);
- C_SUB(*Fout3,scratch[11],scratch[12]);
-
- ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4;
- }
- }
-}
-#endif /* OVERRIDE_kf_bfly5 */
-
-
-#endif
-
-
-#ifdef CUSTOM_MODES
-
-static
-void compute_bitrev_table(
- int Fout,
- opus_int16 *f,
- const size_t fstride,
- int in_stride,
- opus_int16 * factors,
- const kiss_fft_state *st
- )
-{
- const int p=*factors++; /* the radix */
- const int m=*factors++; /* stage's fft length/p */
-
- /*printf ("fft %d %d %d %d %d %d\n", p*m, m, p, s2, fstride*in_stride, N);*/
- if (m==1)
- {
- int j;
- for (j=0;j<p;j++)
- {
- *f = Fout+j;
- f += fstride*in_stride;
- }
- } else {
- int j;
- for (j=0;j<p;j++)
- {
- compute_bitrev_table( Fout , f, fstride*p, in_stride, factors,st);
- f += fstride*in_stride;
- Fout += m;
- }
- }
-}
-
-/* facbuf is populated by p1,m1,p2,m2, ...
- where
- p[i] * m[i] = m[i-1]
- m0 = n */
-static
-int kf_factor(int n,opus_int16 * facbuf)
-{
- int p=4;
- int i;
- int stages=0;
- int nbak = n;
-
- /*factor out powers of 4, powers of 2, then any remaining primes */
- do {
- while (n % p) {
- switch (p) {
- case 4: p = 2; break;
- case 2: p = 3; break;
- default: p += 2; break;
- }
- if (p>32000 || (opus_int32)p*(opus_int32)p > n)
- p = n; /* no more factors, skip to end */
- }
- n /= p;
-#ifdef RADIX_TWO_ONLY
- if (p!=2 && p != 4)
-#else
- if (p>5)
-#endif
- {
- return 0;
- }
- facbuf[2*stages] = p;
- if (p==2 && stages > 1)
- {
- facbuf[2*stages] = 4;
- facbuf[2] = 2;
- }
- stages++;
- } while (n > 1);
- n = nbak;
- /* Reverse the order to get the radix 4 at the end, so we can use the
- fast degenerate case. It turns out that reversing the order also
- improves the noise behaviour. */
- for (i=0;i<stages/2;i++)
- {
- int tmp;
- tmp = facbuf[2*i];
- facbuf[2*i] = facbuf[2*(stages-i-1)];
- facbuf[2*(stages-i-1)] = tmp;
- }
- for (i=0;i<stages;i++)
- {
- n /= facbuf[2*i];
- facbuf[2*i+1] = n;
- }
- return 1;
-}
-
-static void compute_twiddles(kiss_twiddle_cpx *twiddles, int nfft)
-{
- int i;
-#ifdef FIXED_POINT
- for (i=0;i<nfft;++i) {
- opus_val32 phase = -i;
- kf_cexp2(twiddles+i, DIV32(SHL32(phase,17),nfft));
- }
-#else
- for (i=0;i<nfft;++i) {
- const double pi=3.14159265358979323846264338327;
- double phase = ( -2*pi /nfft ) * i;
- kf_cexp(twiddles+i, phase );
- }
-#endif
-}
-
-int opus_fft_alloc_arch_c(kiss_fft_state *st) {
- (void)st;
- return 0;
-}
-
-/*
- *
- * Allocates all necessary storage space for the fft and ifft.
- * The return value is a contiguous block of memory. As such,
- * It can be freed with free().
- * */
-kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem,
- const kiss_fft_state *base, int arch)
-{
- kiss_fft_state *st=NULL;
- size_t memneeded = sizeof(struct kiss_fft_state); /* twiddle factors*/
-
- if ( lenmem==NULL ) {
- st = ( kiss_fft_state*)KISS_FFT_MALLOC( memneeded );
- }else{
- if (mem != NULL && *lenmem >= memneeded)
- st = (kiss_fft_state*)mem;
- *lenmem = memneeded;
- }
- if (st) {
- opus_int16 *bitrev;
- kiss_twiddle_cpx *twiddles;
-
- st->nfft=nfft;
-#ifdef FIXED_POINT
- st->scale_shift = celt_ilog2(st->nfft);
- if (st->nfft == 1<<st->scale_shift)
- st->scale = Q15ONE;
- else
- st->scale = (1073741824+st->nfft/2)/st->nfft>>(15-st->scale_shift);
-#else
- st->scale = 1.f/nfft;
-#endif
- if (base != NULL)
- {
- st->twiddles = base->twiddles;
- st->shift = 0;
- while (st->shift < 32 && nfft<<st->shift != base->nfft)
- st->shift++;
- if (st->shift>=32)
- goto fail;
- } else {
- st->twiddles = twiddles = (kiss_twiddle_cpx*)KISS_FFT_MALLOC(sizeof(kiss_twiddle_cpx)*nfft);
- compute_twiddles(twiddles, nfft);
- st->shift = -1;
- }
- if (!kf_factor(nfft,st->factors))
- {
- goto fail;
- }
-
- /* bitrev */
- st->bitrev = bitrev = (opus_int16*)KISS_FFT_MALLOC(sizeof(opus_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))
- goto fail;
- }
- return st;
-fail:
- opus_fft_free(st, arch);
- return NULL;
-}
-
-kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch)
-{
- return opus_fft_alloc_twiddles(nfft, mem, lenmem, NULL, arch);
-}
-
-void opus_fft_free_arch_c(kiss_fft_state *st) {
- (void)st;
-}
-
-void opus_fft_free(const kiss_fft_state *cfg, int arch)
-{
- if (cfg)
- {
- opus_fft_free_arch((kiss_fft_state *)cfg, arch);
- free((opus_int16*)cfg->bitrev);
- if (cfg->shift < 0)
- free((kiss_twiddle_cpx*)cfg->twiddles);
- free((kiss_fft_state*)cfg);
- }
-}
-
-#endif /* CUSTOM_MODES */
-
-void opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout)
-{
- int m2, m;
- int p;
- int L;
- int fstride[MAXFACTORS];
- int i;
- int shift;
-
- /* st->shift can be -1 */
- shift = st->shift>0 ? st->shift : 0;
-
- fstride[0] = 1;
- L=0;
- do {
- p = st->factors[2*L];
- m = st->factors[2*L+1];
- fstride[L+1] = fstride[L]*p;
- L++;
- } while(m!=1);
- m = st->factors[2*L-1];
- for (i=L-1;i>=0;i--)
- {
- if (i!=0)
- m2 = st->factors[2*i-1];
- else
- m2 = 1;
- switch (st->factors[2*i])
- {
- case 2:
- kf_bfly2(fout, m, fstride[i]);
- break;
- case 4:
- kf_bfly4(fout,fstride[i]<<shift,st,m, fstride[i], m2);
- break;
- #ifndef RADIX_TWO_ONLY
- case 3:
- kf_bfly3(fout,fstride[i]<<shift,st,m, fstride[i], m2);
- break;
- case 5:
- kf_bfly5(fout,fstride[i]<<shift,st,m, fstride[i], m2);
- break;
- #endif
- }
- m = m2;
- }
-}
-
-void opus_fft_c(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout)
-{
- int i;
- opus_val16 scale;
-#ifdef FIXED_POINT
- /* Allows us to scale with MULT16_32_Q16(), which is faster than
- MULT16_32_Q15() on ARM. */
- int scale_shift = st->scale_shift-1;
-#endif
- scale = st->scale;
-
- celt_assert2 (fin != fout, "In-place FFT not supported");
- /* Bit-reverse the input */
- for (i=0;i<st->nfft;i++)
- {
- kiss_fft_cpx x = fin[i];
- fout[st->bitrev[i]].r = SHR32(MULT16_32_Q16(scale, x.r), scale_shift);
- fout[st->bitrev[i]].i = SHR32(MULT16_32_Q16(scale, x.i), scale_shift);
- }
- opus_fft_impl(st, fout);
-}
-
-
-void opus_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");
- /* Bit-reverse the input */
- for (i=0;i<st->nfft;i++)
- fout[st->bitrev[i]] = fin[i];
- for (i=0;i<st->nfft;i++)
- fout[i].i = -fout[i].i;
- opus_fft_impl(st, fout);
- for (i=0;i<st->nfft;i++)
- fout[i].i = -fout[i].i;
-}
--- a/dnn/kiss_fft.h
+++ /dev/null
@@ -1,202 +1,0 @@
-/*Copyright (c) 2003-2004, Mark Borgerding
- Lots of modifications by Jean-Marc Valin
- Copyright (c) 2005-2007, Xiph.Org Foundation
- Copyright (c) 2008, Xiph.Org Foundation, CSIRO
-
- All rights reserved.
-
- 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 KISS_FFT_H
-#define KISS_FFT_H
-
-#include <stdlib.h>
-#include <math.h>
-#include "arch.h"
-
-#include <stdlib.h>
-#define lpcnet_alloc(x) malloc(x)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef USE_SIMD
-# include <xmmintrin.h>
-# define kiss_fft_scalar __m128
-#define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes)
-#else
-#define KISS_FFT_MALLOC lpcnet_alloc
-#endif
-
-#ifdef FIXED_POINT
-#include "arch.h"
-
-# define kiss_fft_scalar opus_int32
-# define kiss_twiddle_scalar opus_int16
-
-
-#else
-# ifndef kiss_fft_scalar
-/* default is float */
-# define kiss_fft_scalar float
-# define kiss_twiddle_scalar float
-# define KF_SUFFIX _celt_single
-# endif
-#endif
-
-typedef struct {
- kiss_fft_scalar r;
- kiss_fft_scalar i;
-}kiss_fft_cpx;
-
-typedef struct {
- kiss_twiddle_scalar r;
- kiss_twiddle_scalar i;
-}kiss_twiddle_cpx;
-
-#define MAXFACTORS 8
-/* e.g. an fft of length 128 has 4 factors
- as far as kissfft is concerned
- 4*4*4*2
- */
-
-typedef struct arch_fft_state{
- int is_supported;
- void *priv;
-} arch_fft_state;
-
-typedef struct kiss_fft_state{
- int nfft;
- opus_val16 scale;
-#ifdef FIXED_POINT
- int scale_shift;
-#endif
- int shift;
- opus_int16 factors[2*MAXFACTORS];
- const opus_int16 *bitrev;
- const kiss_twiddle_cpx *twiddles;
- arch_fft_state *arch_fft;
-} kiss_fft_state;
-
-#if defined(HAVE_ARM_NE10)
-#include "arm/fft_arm.h"
-#endif
-
-/*typedef struct kiss_fft_state* kiss_fft_cfg;*/
-
-/**
- * opus_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);
- *
- * 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.
- * The returned value should be free()d when done to avoid memory leaks.
- *
- * The state can be placed in a user supplied buffer 'mem':
- * If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
- * then the function places the cfg in mem and the size used in *lenmem
- * and returns mem.
- *
- * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
- * then the function returns NULL and places the minimum cfg
- * 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 *opus_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch);
-
-/**
- * opus_fft(cfg,in_out_buf)
- *
- * Perform an FFT on a complex input buffer.
- * for a forward FFT,
- * fin should be f[0] , f[1] , ... ,f[nfft-1]
- * fout will be F[0] , F[1] , ... ,F[nfft-1]
- * 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 opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout);
-void opus_ifft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout);
-
-void opus_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);
-
-#if !defined(OVERRIDE_OPUS_FFT)
-/* Is run-time CPU detection enabled on this platform? */
-#if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10))
-
-extern int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])(
- kiss_fft_state *st);
-
-#define opus_fft_alloc_arch(_st, arch) \
- ((*OPUS_FFT_ALLOC_ARCH_IMPL[(arch)&OPUS_ARCHMASK])(_st))
-
-extern void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])(
- kiss_fft_state *st);
-#define opus_fft_free_arch(_st, arch) \
- ((*OPUS_FFT_FREE_ARCH_IMPL[(arch)&OPUS_ARCHMASK])(_st))
-
-extern void (*const OPUS_FFT[OPUS_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))
-
-extern void (*const OPUS_IFFT[OPUS_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))
-
-#else /* else for if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */
-
-#define opus_fft_alloc_arch(_st, arch) \
- ((void)(arch), opus_fft_alloc_arch_c(_st))
-
-#define opus_fft_free_arch(_st, arch) \
- ((void)(arch), opus_fft_free_arch_c(_st))
-
-#define opus_fft(_cfg, _fin, _fout, arch) \
- ((void)(arch), opus_fft_c(_cfg, _fin, _fout))
-
-#define opus_ifft(_cfg, _fin, _fout, arch) \
- ((void)(arch), opus_ifft_c(_cfg, _fin, _fout))
-
-#endif /* end if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */
-#endif /* end if !defined(OVERRIDE_OPUS_FFT) */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
--- a/dnn/opus_types.h
+++ /dev/null
@@ -1,159 +1,0 @@
-/* (C) COPYRIGHT 1994-2002 Xiph.Org Foundation */
-/* Modified 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.
-*/
-/* opus_types.h based on ogg_types.h from libogg */
-
-/**
- @file opus_types.h
- @brief Opus reference implementation types
-*/
-#ifndef OPUS_TYPES_H
-#define OPUS_TYPES_H
-
-/* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */
-#if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H))
-#include <stdint.h>
-
- typedef int16_t opus_int16;
- typedef uint16_t opus_uint16;
- typedef int32_t opus_int32;
- typedef uint32_t opus_uint32;
-#elif defined(_WIN32)
-
-# if defined(__CYGWIN__)
-# include <_G_config.h>
- typedef _G_int32_t opus_int32;
- typedef _G_uint32_t opus_uint32;
- typedef _G_int16 opus_int16;
- typedef _G_uint16 opus_uint16;
-# elif defined(__MINGW32__)
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
- typedef int opus_int32;
- typedef unsigned int opus_uint32;
-# elif defined(__MWERKS__)
- typedef int opus_int32;
- typedef unsigned int opus_uint32;
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
-# else
- /* MSVC/Borland */
- typedef __int32 opus_int32;
- typedef unsigned __int32 opus_uint32;
- typedef __int16 opus_int16;
- typedef unsigned __int16 opus_uint16;
-# endif
-
-#elif defined(__MACOS__)
-
-# include <sys/types.h>
- typedef SInt16 opus_int16;
- typedef UInt16 opus_uint16;
- typedef SInt32 opus_int32;
- typedef UInt32 opus_uint32;
-
-#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
-
-# include <sys/types.h>
- typedef int16_t opus_int16;
- typedef u_int16_t opus_uint16;
- typedef int32_t opus_int32;
- typedef u_int32_t opus_uint32;
-
-#elif defined(__BEOS__)
-
- /* Be */
-# include <inttypes.h>
- typedef int16 opus_int16;
- typedef u_int16 opus_uint16;
- typedef int32_t opus_int32;
- typedef u_int32_t opus_uint32;
-
-#elif defined (__EMX__)
-
- /* OS/2 GCC */
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
- typedef int opus_int32;
- typedef unsigned int opus_uint32;
-
-#elif defined (DJGPP)
-
- /* DJGPP */
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
- typedef int opus_int32;
- typedef unsigned int opus_uint32;
-
-#elif defined(R5900)
-
- /* PS2 EE */
- typedef int opus_int32;
- typedef unsigned opus_uint32;
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
-
-#elif defined(__SYMBIAN32__)
-
- /* Symbian GCC */
- typedef signed short opus_int16;
- typedef unsigned short opus_uint16;
- typedef signed int opus_int32;
- typedef unsigned int opus_uint32;
-
-#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
-
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
- typedef long opus_int32;
- typedef unsigned long opus_uint32;
-
-#elif defined(CONFIG_TI_C6X)
-
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
- typedef int opus_int32;
- typedef unsigned int opus_uint32;
-
-#else
-
- /* Give up, take a reasonable guess */
- typedef short opus_int16;
- typedef unsigned short opus_uint16;
- typedef int opus_int32;
- typedef unsigned int opus_uint32;
-
-#endif
-
-#define opus_int int /* used for counters etc; at least 16 bits */
-#define opus_int64 long long
-#define opus_int8 signed char
-
-#define opus_uint unsigned int /* used for counters etc; at least 16 bits */
-#define opus_uint64 unsigned long long
-#define opus_uint8 unsigned char
-
-#endif /* OPUS_TYPES_H */
--- a/dnn/pitch.c
+++ /dev/null
@@ -1,84 +1,0 @@
-/* Copyright (c) 2007-2008 CSIRO
- Copyright (c) 2007-2009 Xiph.Org Foundation
- Written by Jean-Marc Valin */
-/**
- @file pitch.c
- @brief Pitch analysis
- */
-
-/*
- 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.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pitch.h"
-#include "common.h"
-#include "math.h"
-
-
-
-void celt_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y,
- opus_val32 *xcorr, int len, int max_pitch)
-{
-
-#if 0 /* This is a simple version of the pitch correlation that should work
- well on DSPs like Blackfin and TI C5x/C6x */
- int i, j;
- for (i=0;i<max_pitch;i++)
- {
- opus_val32 sum = 0;
- for (j=0;j<len;j++)
- sum = MAC16_16(sum, _x[j], _y[i+j]);
- xcorr[i] = sum;
- }
-
-#else /* Unrolled version of the pitch correlation -- runs faster on x86 and ARM */
- int i;
- /*The EDSP version requires that max_pitch is at least 1, and that _x is
- 32-bit aligned.
- Since it's hard to put asserts in assembly, put them here.*/
- celt_assert(max_pitch>0);
- celt_assert((((unsigned char *)_x-(unsigned char *)NULL)&3)==0);
- for (i=0;i<max_pitch-3;i+=4)
- {
- opus_val32 sum[4]={0,0,0,0};
- xcorr_kernel(_x, _y+i, sum, len);
- xcorr[i]=sum[0];
- xcorr[i+1]=sum[1];
- xcorr[i+2]=sum[2];
- xcorr[i+3]=sum[3];
- }
- /* In case max_pitch isn't a multiple of 4, do non-unrolled version. */
- for (;i<max_pitch;i++)
- {
- opus_val32 sum;
- sum = celt_inner_prod(_x, _y+i, len);
- xcorr[i] = sum;
- }
-#endif
-}
-
--- a/dnn/test_lpcnet.c
+++ /dev/null
@@ -1,69 +1,0 @@
-/* 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.
-*/
-
-#include <math.h>
-#include <stdio.h>
-#include "arch.h"
-#include "lpcnet.h"
-#include "freq.h"
-
-
-int main(int argc, char **argv) {
- FILE *fin, *fout;
- LPCNetState *net;
- net = lpcnet_create();
- if (argc != 3)
- {
- fprintf(stderr, "usage: test_lpcnet <features.f32> <output.pcm>\n");
- return 0;
- }
- fin = fopen(argv[1], "rb");
- if (fin == NULL) {
- fprintf(stderr, "Can't open %s\n", argv[1]);
- exit(1);
- }
-
- fout = fopen(argv[2], "wb");
- if (fout == NULL) {
- fprintf(stderr, "Can't open %s\n", argv[2]);
- exit(1);
- }
-
- while (1) {
- float in_features[NB_TOTAL_FEATURES];
- float features[NB_FEATURES];
- short pcm[FRAME_SIZE];
- fread(in_features, sizeof(features[0]), NB_TOTAL_FEATURES, fin);
- if (feof(fin)) break;
- RNN_COPY(features, in_features, NB_FEATURES);
- lpcnet_synthesize(net, features, pcm, FRAME_SIZE);
- fwrite(pcm, sizeof(pcm[0]), FRAME_SIZE, fout);
- }
- fclose(fin);
- fclose(fout);
- lpcnet_destroy(net);
- return 0;
-}
--- a/lpcnet_headers.mk
+++ b/lpcnet_headers.mk
@@ -5,6 +5,7 @@
silk/dred_encoder.h \
dnn/include/dred_rdovae.h \
dnn/include/lpcnet.h \
+dnn/arch.h \
dnn/burg.h \
dnn/common.h \
dnn/freq.h \
--
⑨