Restructuring in quant_band()
This commit is contained in:
parent
293b9f1977
commit
a18c75e55a
1 changed files with 82 additions and 76 deletions
158
libcelt/bands.c
158
libcelt/bands.c
|
@ -532,49 +532,52 @@ static void quant_band(int encode, const CELTMode *m, int i, celt_norm *X, celt_
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Band recombining to increase frequency resolution */
|
if (!stereo && level == 0)
|
||||||
if (!stereo && B > 1 && level == 0 && tf_change>0)
|
|
||||||
{
|
{
|
||||||
while (B>1 && tf_change>0)
|
/* Band recombining to increase frequency resolution */
|
||||||
|
if (!stereo && B > 1 && level == 0 && tf_change>0)
|
||||||
{
|
{
|
||||||
B>>=1;
|
while (B>1 && tf_change>0)
|
||||||
N_B<<=1;
|
{
|
||||||
if (encode)
|
B>>=1;
|
||||||
haar1(X, N_B, B);
|
N_B<<=1;
|
||||||
if (lowband)
|
if (encode)
|
||||||
haar1(lowband, N_B, B);
|
haar1(X, N_B, B);
|
||||||
recombine++;
|
if (lowband)
|
||||||
tf_change--;
|
haar1(lowband, N_B, B);
|
||||||
|
recombine++;
|
||||||
|
tf_change--;
|
||||||
|
}
|
||||||
|
B0=B;
|
||||||
|
N_B0 = N_B;
|
||||||
}
|
}
|
||||||
B0=B;
|
|
||||||
N_B0 = N_B;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Increasing the time resolution */
|
/* Increasing the time resolution */
|
||||||
if (!stereo && level==0)
|
if (!stereo && level==0)
|
||||||
{
|
{
|
||||||
while ((N_B&1) == 0 && tf_change<0 && B <= (1<<LM))
|
while ((N_B&1) == 0 && tf_change<0 && B <= (1<<LM))
|
||||||
|
{
|
||||||
|
if (encode)
|
||||||
|
haar1(X, N_B, B);
|
||||||
|
if (lowband)
|
||||||
|
haar1(lowband, N_B, B);
|
||||||
|
B <<= 1;
|
||||||
|
N_B >>= 1;
|
||||||
|
time_divide++;
|
||||||
|
tf_change++;
|
||||||
|
}
|
||||||
|
B0 = B;
|
||||||
|
N_B0 = N_B;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reorganize the samples in time order instead of frequency order */
|
||||||
|
if (!stereo && B0>1 && level==0)
|
||||||
{
|
{
|
||||||
if (encode)
|
if (encode)
|
||||||
haar1(X, N_B, B);
|
deinterleave_vector(X, N_B, B0);
|
||||||
if (lowband)
|
if (lowband)
|
||||||
haar1(lowband, N_B, B);
|
deinterleave_vector(lowband, N_B, B0);
|
||||||
B <<= 1;
|
|
||||||
N_B >>= 1;
|
|
||||||
time_divide++;
|
|
||||||
tf_change++;
|
|
||||||
}
|
}
|
||||||
B0 = B;
|
|
||||||
N_B0 = N_B;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reorganize the samples in time order instead of frequency order */
|
|
||||||
if (!stereo && B0>1 && level==0)
|
|
||||||
{
|
|
||||||
if (encode)
|
|
||||||
deinterleave_vector(X, N_B, B0);
|
|
||||||
if (lowband)
|
|
||||||
deinterleave_vector(lowband, N_B, B0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we need more than 32 bits, try splitting the band in two. */
|
/* If we need more than 32 bits, try splitting the band in two. */
|
||||||
|
@ -802,49 +805,52 @@ static void quant_band(int encode, const CELTMode *m, int i, celt_norm *X, celt_
|
||||||
/* This code is used by the decoder and by the resynthesis-enabled encoder */
|
/* This code is used by the decoder and by the resynthesis-enabled encoder */
|
||||||
if (resynth)
|
if (resynth)
|
||||||
{
|
{
|
||||||
int k;
|
|
||||||
|
|
||||||
/* Undo the sample reorganization going from time order to frequency order */
|
|
||||||
if (!stereo && B0>1 && level==0)
|
|
||||||
{
|
|
||||||
interleave_vector(X, N_B, B0);
|
|
||||||
if (lowband)
|
|
||||||
interleave_vector(lowband, N_B, B0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Undo time-freq changes that we did earlier */
|
|
||||||
N_B = N_B0;
|
|
||||||
B = B0;
|
|
||||||
for (k=0;k<time_divide;k++)
|
|
||||||
{
|
|
||||||
B >>= 1;
|
|
||||||
N_B <<= 1;
|
|
||||||
haar1(X, N_B, B);
|
|
||||||
if (lowband)
|
|
||||||
haar1(lowband, N_B, B);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (k=0;k<recombine;k++)
|
|
||||||
{
|
|
||||||
haar1(X, N_B, B);
|
|
||||||
if (lowband)
|
|
||||||
haar1(lowband, N_B, B);
|
|
||||||
N_B>>=1;
|
|
||||||
B <<= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scale output for later folding */
|
|
||||||
if (lowband_out && !stereo)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
celt_word16 n;
|
|
||||||
n = celt_sqrt(SHL32(EXTEND32(N0),22));
|
|
||||||
for (j=0;j<N0;j++)
|
|
||||||
lowband_out[j] = MULT16_16_Q15(n,X[j]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stereo)
|
if (stereo)
|
||||||
|
{
|
||||||
stereo_merge(X, Y, mid, side, N);
|
stereo_merge(X, Y, mid, side, N);
|
||||||
|
} else if (level == 0)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
|
||||||
|
/* Undo the sample reorganization going from time order to frequency order */
|
||||||
|
if (B0>1)
|
||||||
|
{
|
||||||
|
interleave_vector(X, N_B, B0);
|
||||||
|
if (lowband)
|
||||||
|
interleave_vector(lowband, N_B, B0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Undo time-freq changes that we did earlier */
|
||||||
|
N_B = N_B0;
|
||||||
|
B = B0;
|
||||||
|
for (k=0;k<time_divide;k++)
|
||||||
|
{
|
||||||
|
B >>= 1;
|
||||||
|
N_B <<= 1;
|
||||||
|
haar1(X, N_B, B);
|
||||||
|
if (lowband)
|
||||||
|
haar1(lowband, N_B, B);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (k=0;k<recombine;k++)
|
||||||
|
{
|
||||||
|
haar1(X, N_B, B);
|
||||||
|
if (lowband)
|
||||||
|
haar1(lowband, N_B, B);
|
||||||
|
N_B>>=1;
|
||||||
|
B <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scale output for later folding */
|
||||||
|
if (lowband_out)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
celt_word16 n;
|
||||||
|
n = celt_sqrt(SHL32(EXTEND32(N0),22));
|
||||||
|
for (j=0;j<N0;j++)
|
||||||
|
lowband_out[j] = MULT16_16_Q15(n,X[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue