Commit 6f7e83d8 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Pre-emphasis, plus a few minor tweaks

parent 41af4215
......@@ -8,12 +8,27 @@
<primarylanguage>C</primarylanguage>
<ignoreparts/>
<projectname>celt</projectname>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description/>
<defaultencoding/>
</general>
<kdevautoproject>
<general>
<useconfiguration>default</useconfiguration>
</general>
<run/>
<run>
<mainprogram/>
<programargs/>
<globaldebugarguments/>
<globalcwd/>
<useglobalprogram>true</useglobalprogram>
<terminal>false</terminal>
<autocompile>false</autocompile>
<autoinstall>false</autoinstall>
<autokdesu>false</autokdesu>
<envvars/>
</run>
<configurations>
<optimized>
<builddir>optimized</builddir>
......@@ -41,7 +56,20 @@
<kdevdebugger>
<general>
<dbgshell>libtool</dbgshell>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
<raiseGDBOnStart>false</raiseGDBOnStart>
</general>
<display>
<staticmembers>false</staticmembers>
<demanglenames>true</demanglenames>
<outputradix>10</outputradix>
</display>
</kdevdebugger>
<kdevdoctreeview>
<ignoretocs>
......@@ -103,13 +131,12 @@
<used>false</used>
<version>3</version>
<includestyle>3</includestyle>
<root>/usr/share/qt3</root>
<root></root>
<designerintegration>EmbeddedKDevDesigner</designerintegration>
<qmake>/usr/bin/qmake-qt3</qmake>
<designer>/usr/bin/designer</designer>
<qmake></qmake>
<designer></designer>
<designerpluginpaths/>
</qt>
<references/>
<codecompletion>
<automaticCodeCompletion>false</automaticCodeCompletion>
<automaticArgumentsHint>true</automaticArgumentsHint>
......@@ -133,7 +160,27 @@
<alwaysIncludeNamespaces>false</alwaysIncludeNamespaces>
<includePaths>.;</includePaths>
</codecompletion>
<creategettersetter>
<prefixGet/>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
<inlineGet>true</inlineGet>
<inlineSet>true</inlineSet>
</creategettersetter>
<splitheadersource>
<enabled>false</enabled>
<synchronize>true</synchronize>
<orientation>Vertical</orientation>
</splitheadersource>
<references/>
</kdevcppsupport>
<cppsupportpart>
<filetemplates>
<interfacesuffix>.h</interfacesuffix>
<implementationsuffix>.cpp</implementationsuffix>
</filetemplates>
</cppsupportpart>
<kdevfileview>
<groups>
<hidenonprojectfiles>false</hidenonprojectfiles>
......
......@@ -35,14 +35,6 @@
#ifndef ARCH_H
#define ARCH_H
#ifndef SPEEX_VERSION
#define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */
#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */
#define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */
#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */
#define SPEEX_VERSION "speex-1.2beta4" /**< Speex version string. */
#endif
/* A couple test to catch stupid option combinations */
#ifdef FIXED_POINT
......@@ -74,9 +66,8 @@
#endif
#ifndef OUTSIDE_SPEEX
#include "speex/speex_types.h"
#endif
typedef int spx_int32_t;
typedef short spx_int16_t;
#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */
#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */
......
......@@ -45,7 +45,8 @@ struct CELTState_ {
int nb_blocks;
float preemph;
float preemph_mem;
float preemph_memE;
float preemph_memD;
mdct_lookup mdct_lookup;
void *fft;
......@@ -78,6 +79,8 @@ CELTState *celt_encoder_new(int blockSize, int blocksPerFrame)
st->out_mem = celt_alloc(MAX_PERIOD*sizeof(float));
for (i=0;i<N;i++)
st->window[i] = st->window[2*N-i-1] = sin(.5*M_PI* sin(.5*M_PI*(i+.5)/N) * sin(.5*M_PI*(i+.5)/N));
st->preemph = 0.8;
return st;
}
......@@ -99,6 +102,32 @@ void celt_encoder_destroy(CELTState *st)
celt_free(st);
}
static void haar1(float *X, int N)
{
int i;
for (i=0;i<N;i+=2)
{
float a, b;
a = X[i];
b = X[i+1];
X[i] = .707107f*(a+b);
X[i+1] = .707107f*(a-b);
}
}
static void inv_haar1(float *X, int N)
{
int i;
for (i=0;i<N;i+=2)
{
float a, b;
a = X[i];
b = X[i+1];
X[i] = .707107f*(a+b);
X[i+1] = .707107f*(a-b);
}
}
static void compute_mdcts(mdct_lookup *mdct_lookup, float *window, float *in, float *out, int N, int B)
{
int i;
......@@ -135,10 +164,13 @@ int celt_encode(CELTState *st, short *pcm)
for (i=0;i<N;i++)
in[i] = st->in_mem[i];
for (;i<(B+1)*N;i++)
in[i] = pcm[i-N];
{
float tmp = pcm[i-N];
in[i] = tmp - st->preemph*st->preemph_memE;
st->preemph_memE = tmp;
}
for (i=0;i<N;i++)
st->in_mem[i] = pcm[(B-1)*N+i];
st->in_mem[i] = in[B*N+i];
/* Compute MDCTs */
compute_mdcts(&st->mdct_lookup, st->window, in, X, N, B);
......@@ -160,10 +192,11 @@ int celt_encode(CELTState *st, short *pcm)
for (j=0;j<B*N;j++)
printf ("%f ", P[j]);
printf ("\n");*/
//haar1(X, B*N);
//haar1(P, B*N);
/* Band normalisation */
compute_bands(X, B, bandE);
//for (i=0;i<NBANDS;i++) printf("%f ",bandE[i]);printf("\n");
normalise_bands(X, B, bandE);
compute_bands(P, B, bandEp);
......@@ -194,6 +227,8 @@ int celt_encode(CELTState *st, short *pcm)
/* Synthesis */
denormalise_bands(X, B, bandE);
//inv_haar1(X, B*N);
CELT_MOVE(st->out_mem, st->out_mem+B*N, MAX_PERIOD-B*N);
/* Compute inverse MDCTs */
for (i=0;i<B;i++)
......@@ -213,7 +248,11 @@ int celt_encode(CELTState *st, short *pcm)
st->mdct_overlap[j] = x[N+j];
for (j=0;j<N;j++)
pcm[i*N+j] = (short)floor(.5+st->out_mem[MAX_PERIOD+(i-B)*N+j]);
{
float tmp = st->out_mem[MAX_PERIOD+(i-B)*N+j] + st->preemph*st->preemph_memD;
st->preemph_memD = tmp;
pcm[i*N+j] = (short)floor(.5+tmp);
}
}
return 0;
......
......@@ -56,9 +56,9 @@ void find_spectral_pitch(void *fft, float *x, float *y, int lag, int len, int *p
X[0] = X[lag-1] = 0;
spx_ifft(fft, X, xx);
float max_corr=-1;
float max_corr=-1e10;
//int pitch;
*pitch = -1;
*pitch = 0;
for (i=0;i<lag-len;i++)
{
//printf ("%f ", xx[i]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment