diff --git a/libcelt/Makefile.am b/libcelt/Makefile.am index 708f6018..4281a134 100644 --- a/libcelt/Makefile.am +++ b/libcelt/Makefile.am @@ -17,7 +17,7 @@ libcelt_la_SOURCES = bands.c celt.c cwrs.c fftwrap.c mdct.c modes.c pitch.c \ libcelt_la_LDFLAGS = -version-info @CELT_LT_CURRENT@:@CELT_LT_REVISION@:@CELT_LT_AGE@ noinst_HEADERS = arch.h bands.h celt.h cwrs.h fftwrap.h mdct.h modes.h \ - os_support.h pitch.h psy.h quant_bands.h quant_pitch.h smallft.h vq.h + os_support.h pgain_table.h pitch.h psy.h quant_bands.h quant_pitch.h smallft.h vq.h noinst_PROGRAMS = testcelt testcelt_SOURCES = testcelt.c diff --git a/libcelt/bands.c b/libcelt/bands.c index 1219c0c2..7db4bad7 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -170,13 +170,21 @@ void compute_pitch_gain(const CELTMode *m, float *X, float *P, float *gains, flo //gain = Sxy/(2*(pbank[i+1]-pbank[i])); //if (i<3) //gain *= 1+.02*gain; - if (gain > .90) - gain = .90; - if (gain < 0.0) - gain = 0.0; - + if (gain > 1.f) + gain = 1.f; + if (gain < 0.0f) + gain = 0.0f; + /* We need to be a bit conservative, otherwise residual doesn't quantise well */ + gain *= .9f; gains[i] = gain; + //printf ("%f ", 1-sqrt(1-gain*gain)); } + /*if(rand()%10==0) + { + for (i=0;inbPBands;i++) + printf ("%f ", 1-sqrt(1-gains[i]*gains[i])); + printf ("\n"); + }*/ for (i=B*pBands[m->nbPBands];inbPBands+1];i++) P[i] = 0; } diff --git a/libcelt/modes.c b/libcelt/modes.c index 48303d4e..56362b2b 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -32,12 +32,12 @@ #include "modes.h" #define NBANDS 18 -#define PBANDS 5 +#define PBANDS 8 #define PITCH_END 37 #define NBANDS128 15 -#define PBANDS128 5 -#define PITCH_END128 36 +#define PBANDS128 8 +#define PITCH_END128 45 static const float means[15] = { 14.8621, 12.6918, 10.2978, 9.5862, 10.3784, @@ -58,25 +58,28 @@ static const int decay18[18] = { }; const int qbank0[NBANDS +2] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 19, 22, 26, 31, 37, 45, 56, 71, 91, 116, 128}; -const int pbank0[PBANDS +2] = {0, 4, 8, 12, 19, PITCH_END, 128}; -const int qpulses0[NBANDS ] = {7, 5, 5, 4, 4, 3, 3, 2, 3, 2, 2, 2, 2, 0, 0, 0, 0, 0}; +const int pbank0[PBANDS +2] = {0, 2, 4, 6, 8, 12, 19, 31, PITCH_END, 128}; +//const int pbank0[PBANDS +2] = {0, 4, 8, 12, 19, PITCH_END, 128}; +const int qpulses0[NBANDS ] = {7, 5, 5, 4, 4, 3, 3, 2, 3, 2, 2, 2, 2, 1, 0, 0, 0, 0}; //const int qpulses0[NBANDS ] = {7, 5, 5, 5, 4, 4, 3, 3, 3, 3, 4, 3, 3, -2, 0, 0, 0, 0}; const int qbank1[NBANDS128+2] = {0, 2, 4, 6, 8, 12, 16, 20, 24, 28, 36, 44, 52, 68, 84, 116, 128}; -const int qpulses1[NBANDS128] = {7, 5, 5, 5, 4, 5, 4, 5, 5, 4, -2, 0, 0, 0, 0}; +const int qpulses1[NBANDS128] = {7, 5, 5, 5, 4, 5, 4, 5, 5, 4, 2, 0, 0, 0, 0}; const int qpulses2[NBANDS128] = {28,24,20,16,24,20, 18, 12, 10, 10,-7, -4, 0, 0, 0}; const int qpulses2s[NBANDS128] ={38,30,24,20,24,20, 18, 16, 14, 20,-20,-14, -8, -8, -5}; -const int pbank1[PBANDS128+2] = {0, 4, 8, 12, 20, PITCH_END128, 128}; +const int pbank1[PBANDS128+2] = {0, 2, 4, 6, 8, 12, 20, 28, PITCH_END128, 128}; +//const int pbank1[PBANDS128+2] = {0, 4, 8, 12, 20, PITCH_END128, 128}; #define NBANDS256 15 -#define PBANDS256 5 -#define PITCH_END256 72 +#define PBANDS256 8 +#define PITCH_END256 88 const int qbank3[NBANDS256+2] = {0, 4, 8, 12, 16, 24, 32, 40, 48, 56, 72, 88, 104, 126, 168, 232, 256}; -const int pbank3[PBANDS256+2] = {0, 8, 16, 24, 40, PITCH_END256, 256}; +//const int pbank3[PBANDS256+2] = {0, 8, 16, 24, 40, PITCH_END256, 256}; +const int pbank3[PBANDS256+2] = {0, 4, 8, 12, 16, 24, 40, 56, PITCH_END128, 128}; const CELTMode mode0 = { 128, /**< overlap */ diff --git a/libcelt/quant_pitch.c b/libcelt/quant_pitch.c index eac77698..83f79090 100644 --- a/libcelt/quant_pitch.c +++ b/libcelt/quant_pitch.c @@ -30,7 +30,9 @@ */ #include "quant_pitch.h" - +#include +#include "pgain_table.h" + static const float cdbk_pitch[]={ 0.00826816, 0.00646836, 0.00520978, 0.00632398, 0.0108199 , 0.723347, 0.0985132, 0.630212, 0.0546661, 0.0246779 , 0.802152, 0.759963, 0.453441, 0.384415, 0.0625198 , @@ -93,18 +95,38 @@ void quant_pitch(float *gains, int len, ec_enc *enc) { int i, id; float g2[len]; +#if 0 for (i=0;i