Commit e6c9f3a1 authored by Rostislav Pehlivanov's avatar Rostislav Pehlivanov

aacenc: reset special bands in the main frame encoding function

This commit moves the resetting of special bands (above RESERVED_BT)
to the main frame encoding function rather than the way it was done
previously in their corresponding search_for_... functions.

The reason why special bands need to be reset is that while normal
bands get chosen for every frame by the coder (twoloop by default)
the coders do not touch any special sfbs and will therefore
make them persist throughout the file.

If we zero them out any bands left unmarked will be chosen by
the second part of the coder (the trellis function in aaccoder.c).
Signed-off-by: 's avatarRostislav Pehlivanov <atomnuker@gmail.com>
parent 32be264c
...@@ -1081,11 +1081,6 @@ static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne ...@@ -1081,11 +1081,6 @@ static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne
const float spread_threshold = NOISE_SPREAD_THRESHOLD*(lambda/120.f); const float spread_threshold = NOISE_SPREAD_THRESHOLD*(lambda/120.f);
const float thr_mult = NOISE_LAMBDA_NUMERATOR/lambda; const float thr_mult = NOISE_LAMBDA_NUMERATOR/lambda;
/* Coders !twoloop don't reset the band_types */
for (w = 0; w < 128; w++)
if (sce->band_type[w] == NOISE_BT)
sce->band_type[w] = 0;
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
start = 0; start = 0;
for (g = 0; g < sce->ics.num_swb; g++) { for (g = 0; g < sce->ics.num_swb; g++) {
......
...@@ -560,8 +560,13 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -560,8 +560,13 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
memset(cpe->ms_mask, 0, sizeof(cpe->ms_mask)); memset(cpe->ms_mask, 0, sizeof(cpe->ms_mask));
put_bits(&s->pb, 3, tag); put_bits(&s->pb, 3, tag);
put_bits(&s->pb, 4, chan_el_counter[tag]++); put_bits(&s->pb, 4, chan_el_counter[tag]++);
for (ch = 0; ch < chans; ch++) for (ch = 0; ch < chans; ch++) {
coeffs[ch] = cpe->ch[ch].coeffs; sce = &cpe->ch[ch];
coeffs[ch] = sce->coeffs;
for (w = 0; w < 128; w++)
if (sce->band_type[w] > RESERVED_BT)
sce->band_type[w] = 0;
}
s->psy.model->analyze(&s->psy, start_ch, coeffs, wi); s->psy.model->analyze(&s->psy, start_ch, coeffs, wi);
for (ch = 0; ch < chans; ch++) { for (ch = 0; ch < chans; ch++) {
s->cur_channel = start_ch + ch; s->cur_channel = start_ch + ch;
......
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