Don't destroy stereo history when switching to mono.
The first version of the mono decoder with stereo output collapsed the historic energy values stored for anti-collapse down to one channel (by taking the max). This means that a subsequent switch back would continue on using the the maximum of the two values instead of the original history, which would make anti-collapse produce louder noise (and potentially more pre-echo than otherwise). This patch moves the max into the anti_collapse function itself, and does not store the values back into the source array, so the full stereo history is maintained if subsequent frames switch back. It also fixes an encoder mismatch, which never took the max (assuming, apparently, that the output channel count would never change).
This commit is contained in:
parent
948d27c9bc
commit
682b6cf1ad
3 changed files with 14 additions and 7 deletions
|
@ -1454,7 +1454,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
|
|||
#endif
|
||||
if (anti_collapse_on)
|
||||
{
|
||||
anti_collapse(st->mode, X, collapse_masks, LM, C, N,
|
||||
anti_collapse(st->mode, X, collapse_masks, LM, C, CC, N,
|
||||
st->start, st->end, oldBandE, oldLogE, oldLogE2, pulses, st->rng);
|
||||
}
|
||||
|
||||
|
@ -2204,8 +2204,6 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
|
|||
for (i=0;i<st->mode->nbEBands;i++)
|
||||
{
|
||||
oldBandE[i]=MAX16(oldBandE[i],oldBandE[st->mode->nbEBands+i]);
|
||||
oldLogE[i]=MAX16(oldLogE[i],oldLogE[st->mode->nbEBands+i]);
|
||||
oldLogE2[i]=MAX16(oldLogE2[i],oldLogE2[st->mode->nbEBands+i]);
|
||||
backgroundLogE[i]=MAX16(backgroundLogE[i],backgroundLogE[st->mode->nbEBands+i]);
|
||||
}
|
||||
}
|
||||
|
@ -2341,7 +2339,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
|
|||
fine_quant, fine_priority, len*8-ec_dec_tell(dec, 0), dec, C);
|
||||
|
||||
if (anti_collapse_on)
|
||||
anti_collapse(st->mode, X, collapse_masks, LM, C, N,
|
||||
anti_collapse(st->mode, X, collapse_masks, LM, C, CC, N,
|
||||
st->start, st->end, oldBandE, oldLogE, oldLogE2, pulses, st->rng);
|
||||
|
||||
log2Amp(st->mode, st->start, st->end, bandE, oldBandE, C);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue