Commit 23e654ff authored by Gregory Maxwell's avatar Gregory Maxwell Committed by Jean-Marc Valin
Browse files

Allow all even frame sizes, change the selection of number of short MDCTs per...

Allow all even frame sizes, change the selection of number of short MDCTs per frame to be more intelligent.
parent 0527f373
......@@ -261,7 +261,7 @@ static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig_t * re
RESTORE_STACK;
} else {
const mdct_lookup *lookup = &mode->shortMdct;
const int overlap = mode->shortMdctSize;
const int overlap = mode->overlap;
const int N = mode->shortMdctSize;
int b, c;
VARDECL(celt_word32_t, x);
......@@ -312,7 +312,7 @@ static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig_t
for (j=0;j<N;j++)
tmp[j] = X[C*j+c];
/* Prevents problems from the imdct doing the overlap-add */
CELT_MEMSET(x+N4, 0, overlap);
CELT_MEMSET(x+N4, 0, N);
mdct_backward(lookup, tmp, x, mode->window, overlap);
celt_assert(transient_shift == 0);
/* The first and last part would need to be set to zero if we actually
......@@ -335,7 +335,7 @@ static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig_t
ALLOC(x, 2*N, celt_word32_t);
ALLOC(tmp, N, celt_word32_t);
/* Prevents problems from the imdct doing the overlap-add */
CELT_MEMSET(x+N4, 0, overlap);
CELT_MEMSET(x+N4, 0, N2);
for (b=0;b<B;b++)
{
/* De-interleaving the sub-frames */
......
......@@ -338,24 +338,35 @@ CELTMode *celt_mode_create(celt_int32_t Fs, int channels, int frame_size, int *e
mode->eBands = compute_ebands(Fs, frame_size, &mode->nbEBands);
compute_pbands(mode, res);
mode->ePredCoef = QCONST16(.8f,15);
if (frame_size <= 64)
if (frame_size > 384 && (frame_size%8)==0)
{
mode->nbShortMdcts = 4;
} else if (frame_size > 384 && (frame_size%10)==0)
{
mode->nbShortMdcts = 5;
} else if (frame_size > 256 && (frame_size%6)==0)
{
mode->nbShortMdcts = 3;
} else if (frame_size > 256 && (frame_size%8)==0)
{
mode->nbShortMdcts = 1;
} else if (frame_size <= 256)
mode->nbShortMdcts = 4;
} else if (frame_size > 64 && (frame_size%4)==0)
{
mode->nbShortMdcts = 2;
} else if (frame_size <= 384)
mode->nbShortMdcts = 2;
} else if (frame_size > 128 && (frame_size%6)==0)
{
mode->nbShortMdcts = 3;
} else {
mode->nbShortMdcts = 4;
mode->nbShortMdcts = 3;
} else
{
mode->nbShortMdcts = 1;
}
if (mode->nbShortMdcts > 1)
mode->overlap = frame_size/mode->nbShortMdcts;
mode->overlap = ((frame_size/mode->nbShortMdcts)>>2)<<2; /* Overlap must be divisible by 4 */
else
mode->overlap = frame_size/2;
mode->overlap = (frame_size>>3)<<2;
compute_allocation_table(mode, res);
/*printf ("%d bands\n", mode->nbEBands);*/
......
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