[xiph-commits] r13572 - trunk/ghost/libghost
jm at svn.xiph.org
jm at svn.xiph.org
Sun Aug 19 17:35:15 PDT 2007
Author: jm
Date: 2007-08-19 17:35:14 -0700 (Sun, 19 Aug 2007)
New Revision: 13572
Added:
trunk/ghost/libghost/ceft.c
trunk/ghost/libghost/ceft.h
Modified:
trunk/ghost/libghost/Makefile.am
trunk/ghost/libghost/ghost.c
trunk/ghost/libghost/ghost.h
Log:
some new idea -- probably won't work, but let's see.
Modified: trunk/ghost/libghost/Makefile.am
===================================================================
--- trunk/ghost/libghost/Makefile.am 2007-08-19 09:36:24 UTC (rev 13571)
+++ trunk/ghost/libghost/Makefile.am 2007-08-20 00:35:14 UTC (rev 13572)
@@ -9,15 +9,15 @@
lib_LTLIBRARIES = libghost.la
# Sources for compilation in the library
-libghost_la_SOURCES = adpcm.c fftwrap.c filterbank.c ghost.c lifting.c lpc.c \
- misc.c pitch.c sinusoids.c smallft.c vorbis_psy.c
+libghost_la_SOURCES = adpcm.c ceft.c fftwrap.c filterbank.c ghost.c lifting.c \
+ lpc.c misc.c pitch.c sinusoids.c smallft.c vorbis_psy.c
#noinst_HEADERS =
libghost_la_LDFLAGS = -version-info @GHOST_LT_CURRENT@:@GHOST_LT_REVISION@:@GHOST_LT_AGE@
-noinst_HEADERS = adpcm.h arch.h fftwrap.h filterbank.h ghost.h lifting.h lpc.h \
- misc.h pitch.h smallft.h vorbis_psy.h
+noinst_HEADERS = adpcm.h arch.h ceft.h fftwrap.h filterbank.h ghost.h lifting.h \
+ lpc.h misc.h pitch.h smallft.h vorbis_psy.h
noinst_PROGRAMS = testghost
testghost_SOURCES = testghost.c
Added: trunk/ghost/libghost/ceft.c
===================================================================
--- trunk/ghost/libghost/ceft.c (rev 0)
+++ trunk/ghost/libghost/ceft.c 2007-08-20 00:35:14 UTC (rev 13572)
@@ -0,0 +1,95 @@
+/* Copyright (C) 2007
+
+ Code-Excited Fourier Transform -- This is highly experimental and
+ it's not clear at all it even has a remote chance of working
+
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "ceft.h"
+#include "filterbank.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include "fftwrap.h"
+
+#define BARK_BANDS 20
+
+struct CEFTState_ {
+ FilterBank *bank;
+ void *frame_fft;
+ int length;
+};
+
+CEFTState *ceft_init(int len)
+{
+ CEFTState *st = malloc(sizeof(CEFTState));
+ st->length = len;
+ st->frame_fft = spx_fft_init(st->length);
+ st->bank = filterbank_new(BARK_BANDS, 48000, st->length>>1, 0);
+ return st;
+}
+
+void ceft_encode(CEFTState *st, float *in, float *out)
+{
+ float bark[BARK_BANDS];
+ float Xps[st->length>>1];
+ float X[st->length];
+ int i;
+
+ spx_fft_float(st->frame_fft, in, X);
+
+ Xps[0] = .1+X[0]*X[0];
+ for (i=1;i<st->length>>1;i++)
+ Xps[i] = .1+X[2*i-1]*X[2*i-1] + X[2*i]*X[2*i];
+
+ filterbank_compute_bank(st->bank, Xps, bark);
+ filterbank_compute_psd(st->bank, bark, Xps);
+ X[0] /= Xps[0];
+ for (i=1;i<st->length>>1;i++)
+ {
+ X[2*i-1] /= Xps[i];
+ X[2*i] /= Xps[i];
+ }
+ X[st->length-1] /= Xps[(st->length>>1)-1];
+ /*
+ for(i=0;i<st->length;i++)
+ printf ("%f ", X[i]);
+ printf ("\n");
+ */
+ X[0] *= Xps[0];
+ for (i=1;i<st->length>>1;i++)
+ {
+ X[2*i-1] *= Xps[i];
+ X[2*i] *= Xps[i];
+ }
+ X[st->length-1] *= Xps[(st->length>>1)-1];
+#if 0
+ for(i=0;i<BARK_BANDS;i++)
+ {
+ printf("%f ", bark[i]);
+ }
+ printf ("\n");
+#endif
+ /*
+ for(i=0;i<st->length;i++)
+ printf ("%f ", X[i]);
+ printf ("\n");
+ */
+
+ spx_ifft_float(st->frame_fft, X, out);
+
+}
+
Added: trunk/ghost/libghost/ceft.h
===================================================================
--- trunk/ghost/libghost/ceft.h (rev 0)
+++ trunk/ghost/libghost/ceft.h 2007-08-20 00:35:14 UTC (rev 13572)
@@ -0,0 +1,25 @@
+/* Copyright (C) 2007
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+struct CEFTState_;
+
+typedef struct CEFTState_ CEFTState;
+
+CEFTState *ceft_init(int len);
+
+void ceft_encode(CEFTState *st, float *in, float *out);
+
Modified: trunk/ghost/libghost/ghost.c
===================================================================
--- trunk/ghost/libghost/ghost.c 2007-08-19 09:36:24 UTC (rev 13571)
+++ trunk/ghost/libghost/ghost.c 2007-08-20 00:35:14 UTC (rev 13572)
@@ -35,7 +35,6 @@
#define SINUSOIDS 30
#define MASK_LPC_ORDER 10
-#define BARK_BANDS 20
void fir_mem2(const spx_sig_t *x, const spx_coef_t *num, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
{
@@ -137,14 +136,14 @@
for (i=st->lpc_order;i<st->lpc_length;i++)
st->lpc_window[i] = .5-.5*cos(2*M_PI*(i-st->lpc_order)/(st->lpc_length-st->lpc_order));
#endif
- st->bank = filterbank_new(BARK_BANDS, 48000, st->length>>1, 0);
st->big_fft = spx_fft_init(PCM_BUF_SIZE);
- st->frame_fft = spx_fft_init(st->length);
st->lpc_fft = spx_fft_init(st->lpc_length);
for (i=0;i<PCM_BUF_SIZE;i++)
st->big_window[i] = .5-.5*cos(2*M_PI*(i+1)/PCM_BUF_SIZE);
st->adpcm = adpcm_init(8);
+ st->ceft = ceft_init(st->length);
+
return st;
}
@@ -156,12 +155,9 @@
void ghost_encode(GhostEncState *st, float *pcm)
{
int i;
- float gain;
float curve[PCM_BUF_SIZE>>1];
float awk1[MASK_LPC_ORDER], awk2[MASK_LPC_ORDER];
- float X[st->length];
float mask_gain;
- float bark[BARK_BANDS];
int q[st->advance];
for (i=0;i<PCM_BUF_SIZE-st->advance;i++)
@@ -201,18 +197,6 @@
for (i=0;i<st->length;i++)
x[i] = st->analysis_window[i]*st->current_frame[i];
- spx_fft_float(st->frame_fft, x, X);
- X[0] = X[0]*X[0];
- for (i=1;i<st->length>>1;i++)
- X[i] = X[2*i-1]*X[2*i-1] + X[2*i]*X[2*i];
- filterbank_compute_bank32(st->bank, X, bark);
-#if 0
- for(i=0;i<BARK_BANDS;i++)
- {
- printf("%f ", bark[i]);
- }
- printf ("\n");
-#endif
//extract_sinusoids(x, wi, st->window, ai, bi, y, SINUSOIDS, st->length);
//nb_sinusoids=1;
//wi[0] = 0.42745;
@@ -328,6 +312,9 @@
noise[i] = ener*sqrt(12.)*((((float)(rand()))/RAND_MAX)-.5);
}
+#if 0
+ ceft_encode(st->ceft, noise, noise);
+#else
/*for (i=0;i<st->advance;i++)
printf ("%f\n", noise[i]);
printf ("\n");*/
@@ -341,7 +328,7 @@
for (i=0;i<st->advance;i++)
noise[i] *= mask_gain;
iir_mem2(noise, awk1, noise, st->advance, MASK_LPC_ORDER, st->noise_mem2);
-
+#endif
/*for (i=0;i<st->advance;i++)
pcm[i] = st->current_frame[i]-st->new_noise[i];*/
Modified: trunk/ghost/libghost/ghost.h
===================================================================
--- trunk/ghost/libghost/ghost.h 2007-08-19 09:36:24 UTC (rev 13571)
+++ trunk/ghost/libghost/ghost.h 2007-08-20 00:35:14 UTC (rev 13572)
@@ -26,6 +26,7 @@
#include "vorbis_psy.h"
#include "adpcm.h"
#include "filterbank.h"
+#include "ceft.h"
typedef struct {
float *pcm_buf;
@@ -53,11 +54,10 @@
int lpc_length;
int lpc_order;
- FilterBank *bank;
void *big_fft;
- void *frame_fft;
void *lpc_fft;
ADPCMState *adpcm;
+ CEFTState *ceft;
} GhostEncState;
GhostEncState *ghost_encoder_state_new(int sampling_rate);
More information about the commits
mailing list