ref: 6c3788cb536c519fe5cee63f63c706a07c47fc62
parent: dc68eb231f98533b61d5451233a1d518729946cf
author: Jean-Marc Valin <[email protected]>
date: Sun Jun 20 18:48:50 EDT 2010
Removing old PCL, added plc.h
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,7 @@
CELT_MAJOR_VERSION=0
CELT_MINOR_VERSION=8
CELT_MICRO_VERSION=0
-CELT_EXTRA_VERSION=-git
+CELT_EXTRA_VERSION=
CELT_VERSION=$CELT_MAJOR_VERSION.$CELT_MINOR_VERSION.$CELT_MICRO_VERSION$CELT_EXTRA_VERSION
LIBCELT_SUFFIX=0
--- a/libcelt/Makefile.am
+++ b/libcelt/Makefile.am
@@ -16,7 +16,7 @@
# Sources for compilation in the library
libcelt@LIBCELT_SUFFIX@_la_SOURCES = bands.c celt.c cwrs.c ecintrin.h entcode.c \
entdec.c entenc.c header.c kiss_fft.c laplace.c mdct.c \
- modes.c pitch.c quant_bands.c rangedec.c rangeenc.c rate.c \
+ modes.c pitch.c plc.c quant_bands.c rangedec.c rangeenc.c rate.c \
vq.c
libcelt@LIBCELT_SUFFIX@_la_LDFLAGS = -version-info @CELT_LT_CURRENT@:@CELT_LT_REVISION@:@CELT_LT_AGE@
@@ -25,7 +25,7 @@
cwrs.h ecintrin.h entcode.h entdec.h entenc.h fixed_generic.h float_cast.h \
kfft_double.h kiss_fft.h laplace.h mdct.h mfrngcod.h \
mathops.h modes.h os_support.h pitch.h \
- quant_bands.h rate.h stack_alloc.h vq.h plc.c
+ quant_bands.h rate.h stack_alloc.h vq.h plc.h
noinst_PROGRAMS = testcelt dump_modes
testcelt_SOURCES = testcelt.c
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -51,13 +51,8 @@
#include "mathops.h"
#include "float_cast.h"
#include <stdarg.h>
+#include "plc.h"
-#define LPC_ORDER 24
-#define NEW_PLC
-#if !defined(FIXED_POINT) || defined(NEW_PLC)
-#include "plc.c"
-#endif
-
static const celt_word16 preemph = QCONST16(0.8f,15);
#ifdef FIXED_POINT
@@ -1296,11 +1291,7 @@
/* DECODER */
/* */
/**********************************************************************/
-#ifdef NEW_PLC
#define DECODE_BUFFER_SIZE 2048
-#else
-#define DECODE_BUFFER_SIZE MAX_PERIOD
-#endif
#define DECODERVALID 0x4c434454
#define DECODERPARTIAL 0x5444434c
@@ -1326,9 +1317,7 @@
celt_word16 *oldBandE;
-#ifdef NEW_PLC
celt_word16 *lpc;
-#endif
int last_pitch_index;
int loss_count;
@@ -1395,16 +1384,12 @@
st->preemph_memD = (celt_sig*)celt_alloc(C*sizeof(celt_sig));
-#ifdef NEW_PLC
st->lpc = (celt_word16*)celt_alloc(C*LPC_ORDER*sizeof(celt_word16));
-#endif
st->loss_count = 0;
if ((st->decode_mem!=NULL) && (st->out_mem!=NULL) && (st->oldBandE!=NULL) &&
-#ifdef NEW_PLC
(st->lpc!=NULL) &&
-#endif
(st->preemph_memD!=NULL))
{
if (error)
@@ -1447,10 +1432,7 @@
celt_free(st->decode_mem);
celt_free(st->oldBandE);
celt_free(st->preemph_memD);
-
-#ifdef NEW_PLC
celt_free(st->lpc);
-#endif
st->marker = DECODERFREED;
@@ -1495,19 +1477,6 @@
fade = 0;
}
-#ifndef NEW_PLC
- offset = MAX_PERIOD-pitch_index;
- ALLOC(freq,C*N, celt_sig); /**< Interleaved signal MDCTs */
- while (offset+len >= MAX_PERIOD)
- offset -= pitch_index;
- compute_mdcts(st->mode, 0, st->out_mem+offset*C, freq, C, LM);
- for (i=0;i<C*N;i++)
- freq[i] = ADD32(VERY_SMALL, MULT16_32_Q15(fade,freq[i]));
-
- CELT_MOVE(st->out_mem, st->out_mem+C*N, C*(MAX_PERIOD+st->mode->overlap-N));
- /* Compute inverse MDCTs */
- compute_inv_mdcts(st->mode, 0, freq, -1, 0, st->out_mem, C, LM);
-#else
for (c=0;c<C;c++)
{
/* FIXME: This is more memory than necessary */
@@ -1624,7 +1593,6 @@
for (i=0;i<N-overlap;i++)
st->out_mem[C*(MAX_PERIOD-N+overlap+i)+c] = MULT16_32_Q15(fade, e[overlap+i]);
}
-#endif
deemphasis(st->out_mem, pcm, N, C, preemph, st->preemph_memD);
@@ -1935,9 +1903,7 @@
st->loss_count = 0;
-#ifdef NEW_PLC
CELT_MEMSET(st->lpc, 0, C*LPC_ORDER);
-#endif
}
break;
default:
--- a/libcelt/mathops.h
+++ b/libcelt/mathops.h
@@ -42,6 +42,8 @@
#include "entcode.h"
#include "os_support.h"
+
+
#ifndef OVERRIDE_FIND_MAX16
static inline int find_max16(celt_word16 *x, int len)
{
@@ -108,6 +110,7 @@
#define celt_atan atan
#define celt_rcp(x) (1.f/(x))
#define celt_div(a,b) ((a)/(b))
+#define frac_div32(a,b) ((float)(a)/(b))
#ifdef FLOAT_APPROX
@@ -377,6 +380,21 @@
#define celt_div(a,b) MULT32_32_Q31((celt_word32)(a),celt_rcp(b))
+static celt_word32 frac_div32(celt_word32 a, celt_word32 b)
+{
+ celt_word16 rcp;
+ celt_word32 result, rem;
+ int shift = 30-celt_ilog2(b);
+ a = SHL32(a,shift);
+ b = SHL32(b,shift);
+
+ /* 16-bit reciprocal */
+ rcp = ROUND16(celt_rcp(ROUND16(b,16)),2);
+ result = SHL32(MULT16_32_Q15(rcp, a),1);
+ rem = a-MULT32_32_Q31(result, b);
+ result += SHL32(MULT16_32_Q15(rcp, rem),1);
+ return result;
+}
#define M1 32767
#define M2 -21
--- a/libcelt/plc.c
+++ b/libcelt/plc.c
@@ -1,27 +1,43 @@
+/* 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:
-#ifndef NEW_PLC
-#define NEW_PLC
-#endif
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
-#ifdef FIXED_POINT
-static celt_word32 frac_div32(celt_word32 a, celt_word32 b)
-{
- celt_word16 rcp;
- celt_word32 result, rem;
- int shift = 30-celt_ilog2(b);
- a = SHL32(a,shift);
- b = SHL32(b,shift);
+ - 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.
- /* 16-bit reciprocal */
- rcp = ROUND16(celt_rcp(ROUND16(b,16)),2);
- result = SHL32(MULT16_32_Q15(rcp, a),1);
- rem = a-MULT32_32_Q31(result, b);
- result += SHL32(MULT16_32_Q15(rcp, rem),1);
- return result;
-}
-#else
-#define frac_div32(a,b) ((float)(a)/(b))
+ - Neither the name of the Xiph.org Foundation nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ 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.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
#endif
+
+#include "plc.h"
+#include "stack_alloc.h"
+#include "mathops.h"
+
+
void _celt_lpc(
--- /dev/null
+++ b/libcelt/plc.h
@@ -1,0 +1,59 @@
+/* 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.
+
+ - Neither the name of the Xiph.org Foundation nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ 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.
+*/
+
+#ifndef PLC_H
+#define PLC_H
+
+#include "arch.h"
+
+#define LPC_ORDER 24
+
+void _celt_lpc(celt_word16 *_lpc, const celt_word32 *ac, int p);
+
+void fir(const celt_word16 *x,
+ const celt_word16 *num,
+ celt_word16 *y,
+ int N,
+ int ord,
+ celt_word16 *mem);
+
+void iir(const celt_word32 *x,
+ const celt_word16 *den,
+ celt_word32 *y,
+ int N,
+ int ord,
+ celt_word16 *mem);
+
+
+void _celt_autocorr(const celt_word16 *x, celt_word32 *ac, const celt_word16 *window, int overlap, int lag, int n);
+
+
+#endif /* PLC_H */
--- a/tests/mathops-test.c
+++ b/tests/mathops-test.c
@@ -122,7 +122,7 @@
celt_word32 x;
for (x=8;x<1073741824;x+=(x>>3))
{
- float error = fabs((1.442695040888963387*log(x/16384.0))-celt_log2(x)/256.0);
+ float error = fabs((1.442695040888963387*log(x/16384.0))-celt_log2(x)/1024.0);
if (error>0.003)
{
fprintf (stderr, "celt_log2 failed: x = %ld, error = %f\n", (long)x,error);