shithub: opus

Download patch

ref: 227537c994c2fbec9c542693c566e342bd8b5243
parent: 2f5b51c94a43afc544659e71a976f55d101c8ab8
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Mon Jan 24 19:08:27 EST 2022

Avoiding more symbol clashes with Opus

--- a/dnn/Makefile.am
+++ b/dnn/Makefile.am
@@ -8,7 +8,6 @@
 
 lib_LTLIBRARIES = liblpcnet.la
 noinst_HEADERS = arch.h  \
-		 celt_lpc.h  \
 		 common.h  \
 		 freq.h  \
 		 _kiss_fft_guts.h  \
@@ -36,7 +35,6 @@
 	pitch.c \
 	freq.c \
 	kiss_fft.c \
-	celt_lpc.c \
 	lpcnet_plc.c
 
 liblpcnet_la_LIBADD = $(DEPS_LIBS) $(lrintf_lib) $(LIBM)
@@ -49,12 +47,12 @@
 lpcnet_demo_LDADD = liblpcnet.la
 
 
-#DUMP_SOURCES = freq.c kiss_fft.c pitch.c celt_lpc.c lpcnet_dec.c lpcnet_enc.c ceps_codebooks.c common.c
+#DUMP_SOURCES = freq.c kiss_fft.c pitch.c lpcnet_dec.c lpcnet_enc.c ceps_codebooks.c common.c
 #DUMP_OBJ = $(DUMP_SOURCES:.c=.lo)
 #dump_data_SOURCES = dump_data.c
 #dump_data_LDADD = $(DUMP_OBJ) $(LIBM)
 
-dump_data_SOURCES = common.c dump_data.c freq.c kiss_fft.c pitch.c celt_lpc.c lpcnet_dec.c lpcnet_enc.c ceps_codebooks.c
+dump_data_SOURCES = common.c dump_data.c freq.c kiss_fft.c pitch.c lpcnet_dec.c lpcnet_enc.c ceps_codebooks.c
 dump_data_LDADD = $(LIBM)
 dump_data_CFLAGS = $(AM_CFLAGS)
 
--- a/dnn/celt_lpc.c
+++ /dev/null
@@ -1,93 +1,0 @@
-/* Copyright (c) 2009-2010 Xiph.Org Foundation
-   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.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "celt_lpc.h"
-#include "arch.h"
-#include "common.h"
-#include "pitch.h"
-
-float _celt_lpc(
-      opus_val16       *_lpc, /* out: [0...p-1] LPC coefficients      */
-      opus_val16 *rc,
-const opus_val32 *ac,  /* in:  [0...p] autocorrelation values  */
-int          p
-)
-{
-   int i, j;
-   opus_val32 r;
-   opus_val32 error = ac[0];
-#ifdef FIXED_POINT
-   opus_val32 lpc[LPC_ORDER];
-#else
-   float *lpc = _lpc;
-#endif
-
-   RNN_CLEAR(lpc, p);
-   RNN_CLEAR(rc, p);
-   if (ac[0] != 0)
-   {
-      for (i = 0; i < p; i++) {
-         /* Sum up this iteration's reflection coefficient */
-         opus_val32 rr = 0;
-         for (j = 0; j < i; j++)
-            rr += MULT32_32_Q31(lpc[j],ac[i - j]);
-         rr += SHR32(ac[i + 1],3);
-         r = -SHL32(rr,3)/error;
-         rc[i] = r;
-         /*  Update LPC coefficients and total error */
-         lpc[i] = SHR32(r,3);
-         for (j = 0; j < (i+1)>>1; j++)
-         {
-            opus_val32 tmp1, tmp2;
-            tmp1 = lpc[j];
-            tmp2 = lpc[i-1-j];
-            lpc[j]     = tmp1 + MULT32_32_Q31(r,tmp2);
-            lpc[i-1-j] = tmp2 + MULT32_32_Q31(r,tmp1);
-         }
-
-         error = error - MULT32_32_Q31(MULT32_32_Q31(r,r),error);
-         /* Bail out once we get 30 dB gain */
-#ifdef FIXED_POINT
-         if (error<SHR32(ac[0],10))
-            break;
-#else
-         if (error<.001f*ac[0])
-            break;
-#endif
-      }
-   }
-#ifdef FIXED_POINT
-   for (i=0;i<p;i++)
-      _lpc[i] = ROUND16(lpc[i],16);
-#endif
-   return error;
-}
-
--- a/dnn/celt_lpc.h
+++ /dev/null
@@ -1,42 +1,0 @@
-/* Copyright (c) 2009-2010 Xiph.Org Foundation
-   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.
-*/
-
-#ifndef PLC_H
-#define PLC_H
-
-#include "arch.h"
-#include "common.h"
-
-#if defined(OPUS_X86_MAY_HAVE_SSE4_1)
-#include "x86/celt_lpc_sse.h"
-#endif
-
-#define LPC_ORDER 16
-
-float _celt_lpc(opus_val16 *_lpc, opus_val16 *rc, const opus_val32 *ac, int p);
-
-#endif /* PLC_H */
--- a/dnn/dump_data.c
+++ b/dnn/dump_data.c
@@ -38,7 +38,6 @@
 #include "freq.h"
 #include "pitch.h"
 #include "arch.h"
-#include "celt_lpc.h"
 #include <assert.h>
 #include "lpcnet.h"
 #include "lpcnet_private.h"
--- a/dnn/freq.c
+++ b/dnn/freq.c
@@ -37,7 +37,6 @@
 #include "freq.h"
 #include "pitch.h"
 #include "arch.h"
-#include "celt_lpc.h"
 #include <assert.h>
 
 #define SQUARE(x) ((x)*(x))
@@ -59,7 +58,51 @@
 } CommonState;
 
 
+float _lpcnet_lpc(
+      opus_val16 *lpc, /* out: [0...p-1] LPC coefficients      */
+      opus_val16 *rc,
+const opus_val32 *ac,  /* in:  [0...p] autocorrelation values  */
+int          p
+)
+{
+   int i, j;
+   opus_val32 r;
+   opus_val32 error = ac[0];
 
+   RNN_CLEAR(lpc, p);
+   RNN_CLEAR(rc, p);
+   if (ac[0] != 0)
+   {
+      for (i = 0; i < p; i++) {
+         /* Sum up this iteration's reflection coefficient */
+         opus_val32 rr = 0;
+         for (j = 0; j < i; j++)
+            rr += MULT32_32_Q31(lpc[j],ac[i - j]);
+         rr += SHR32(ac[i + 1],3);
+         r = -SHL32(rr,3)/error;
+         rc[i] = r;
+         /*  Update LPC coefficients and total error */
+         lpc[i] = SHR32(r,3);
+         for (j = 0; j < (i+1)>>1; j++)
+         {
+            opus_val32 tmp1, tmp2;
+            tmp1 = lpc[j];
+            tmp2 = lpc[i-1-j];
+            lpc[j]     = tmp1 + MULT32_32_Q31(r,tmp2);
+            lpc[i-1-j] = tmp2 + MULT32_32_Q31(r,tmp1);
+         }
+
+         error = error - MULT32_32_Q31(MULT32_32_Q31(r,r),error);
+         /* Bail out once we get 30 dB gain */
+         if (error<.001f*ac[0])
+            break;
+      }
+   }
+   return error;
+}
+
+
+
 void compute_band_energy(float *bandE, const kiss_fft_cpx *X) {
   int i;
   float sum[NB_BANDS] = {0};
@@ -224,7 +267,7 @@
    ac[0] += ac[0]*1e-4 + 320/12/38.;
    /* Lag windowing. */
    for (i=1;i<LPC_ORDER+1;i++) ac[i] *= (1 - 6e-5*i*i);
-   e = _celt_lpc(lpc, rc, ac, LPC_ORDER);
+   e = _lpcnet_lpc(lpc, rc, ac, LPC_ORDER);
    return e;
 }
 
--- a/dnn/freq.h
+++ b/dnn/freq.h
@@ -26,6 +26,8 @@
 
 #include "kiss_fft.h"
 
+#define LPC_ORDER 16
+
 #define PREEMPHASIS (0.85f)
 
 #define FRAME_SIZE_5MS (2)
--- a/dnn/lpcnet_dec.c
+++ b/dnn/lpcnet_dec.c
@@ -37,7 +37,6 @@
 #include "freq.h"
 #include "pitch.h"
 #include "arch.h"
-#include "celt_lpc.h"
 #include <assert.h>
 #include "lpcnet_private.h"
 #include "lpcnet.h"
--- a/dnn/lpcnet_enc.c
+++ b/dnn/lpcnet_enc.c
@@ -37,7 +37,6 @@
 #include "freq.h"
 #include "pitch.h"
 #include "arch.h"
-#include "celt_lpc.h"
 #include <assert.h>
 #include "lpcnet_private.h"
 #include "lpcnet.h"
--- a/dnn/lpcnet_private.h
+++ b/dnn/lpcnet_private.h
@@ -6,7 +6,6 @@
 #include "freq.h"
 #include "lpcnet.h"
 #include "nnet_data.h"
-#include "celt_lpc.h"
 #include "kiss99.h"
 
 #define BITS_PER_CHAR 8
--- a/dnn/pitch.c
+++ b/dnn/pitch.c
@@ -37,7 +37,6 @@
 
 #include "pitch.h"
 #include "common.h"
-#include "celt_lpc.h"
 #include "math.h"
 
 
--