Skip to content
Snippets Groups Projects
Commit 896471dc authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Disabling the folding sign bit

parent a2012d8d
No related branches found
No related tags found
No related merge requests found
......@@ -413,11 +413,7 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, ce
/* If pitch isn't available, use intra-frame prediction */
if (eBands[i] >= m->pitchEnd || q<=0)
{
q -= 1;
if (q<0)
intra_fold(m, X+C*eBands[i], eBands[i+1]-eBands[i], norm, P+C*eBands[i], eBands[i], B);
else
intra_prediction(m, X+C*eBands[i], W+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], B, enc);
intra_fold(m, X+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], B);
}
if (q > 0)
......@@ -500,11 +496,7 @@ void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P,
/* If pitch isn't available, use intra-frame prediction */
if (eBands[i] >= m->pitchEnd || q<=0)
{
q -= 1;
if (q<0)
intra_fold(m, X+C*eBands[i], eBands[i+1]-eBands[i], norm, P+C*eBands[i], eBands[i], B);
else
intra_unquant(m, X+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], B, dec);
intra_fold(m, X+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], B);
}
if (q > 0)
......
......@@ -69,16 +69,7 @@ celt_int16_t **compute_alloc_cache(CELTMode *m, int C)
int pulses = j;
/* For bands where there's no pitch, id 1 corresponds to intra prediction
with no pulse. id 2 means intra prediction with one pulse, and so on.*/
if (eBands[i] >= m->pitchEnd)
pulses -= 1;
if (pulses < 0)
bits[i][j] = 0;
else {
bits[i][j] = get_required_bits(N, pulses, BITRES);
/* Add the intra-frame prediction sign bit */
if (eBands[i] >= m->pitchEnd)
bits[i][j] += (1<<BITRES);
}
bits[i][j] = get_required_bits(N, pulses, BITRES);
}
for (;j<MAX_PULSES;j++)
bits[i][j] = BITOVERFLOW;
......
......@@ -304,58 +304,18 @@ static void fold(const CELTMode *m, int N, celt_norm_t *Y, celt_norm_t * restric
#define KGAIN 6
void intra_prediction(const CELTMode *m, celt_norm_t * restrict x, celt_mask_t *W, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B, ec_enc *enc)
void intra_fold(const CELTMode *m, celt_norm_t * restrict x, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B)
{
int j;
celt_word16_t s = 1;
int sign;
celt_word16_t pred_gain;
celt_word32_t xy=0;
const int C = CHANNELS(m);
pred_gain = celt_div((celt_word32_t)MULT16_16(Q15_ONE,N),(celt_word32_t)(N+KGAIN*K));
fold(m, N, Y, P, N0, B);
for (j=0;j<C*N;j++)
xy = MAC16_16(xy, P[j], x[j]);
if (xy<0)
{
s = -1;
sign = 1;
} else {
s = 1;
sign = 0;
}
ec_enc_bits(enc,sign,1);
renormalise_vector(P, s*pred_gain, C*N, 1);
}
void intra_unquant(const CELTMode *m, celt_norm_t *x, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B, ec_dec *dec)
{
celt_word16_t s;
celt_word16_t pred_gain;
const int C = CHANNELS(m);
if (ec_dec_bits(dec, 1) == 0)
s = 1;
if (K==0)
pred_gain = Q15ONE;
else
s = -1;
pred_gain = celt_div((celt_word32_t)MULT16_16(Q15_ONE,N),(celt_word32_t)(N+KGAIN*K));
fold(m, N, Y, P, N0, B);
renormalise_vector(P, s*pred_gain, C*N, 1);
}
void intra_fold(const CELTMode *m, celt_norm_t *x, int N, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B)
{
const int C = CHANNELS(m);
pred_gain = celt_div((celt_word32_t)MULT16_16(Q15_ONE,N),(celt_word32_t)(N+KGAIN*K));
fold(m, N, Y, P, N0, B);
renormalise_vector(P, Q15ONE, C*N, 1);
renormalise_vector(P, pred_gain, C*N, 1);
}
......@@ -73,13 +73,7 @@ void renormalise_vector(celt_norm_t *X, celt_word16_t value, int N, int stride);
* @param P Pitch vector (it is assumed that p+x is a unit vector)
* @param B Stride (number of channels multiplied by the number of MDCTs per frame)
* @param N0 Number of valid offsets
* @param enc Entropy encoder state
*/
void intra_prediction(const CELTMode *m, celt_norm_t * restrict x, celt_mask_t *W, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B, ec_enc *enc);
void intra_unquant(const CELTMode *m, celt_norm_t *x, int N, int K, celt_norm_t *Y, celt_norm_t *P, int N0, int B, ec_dec *dec);
/** Encode the entire band as a "fold" from other parts of the spectrum. No bits required (only use is case of an emergency!) */
void intra_fold(const CELTMode *m, celt_norm_t *x, int N, celt_norm_t *Y, celt_norm_t *P, int N0, int B);
void intra_fold(const CELTMode *m, celt_norm_t * restrict x, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int N0, int B);
#endif /* VQ_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment