aacenc: add support for coding of intensity stereo scalefactor indices

This commit adds support for the coding of intensity stereo scalefactor indices.
It does not do any marking of such bands and as such does no functional changes
to the encoder. It removes any old twoloop specific code for PNS and moves it
into a seperate function which handles setting of scalefactor indices for
PNS and IS bands.

Reviewed-by: Claudio Freire <klaussfreire@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Rostislav Pehlivanov 2015-06-26 21:16:34 +01:00 committed by Michael Niedermayer
parent da8b228977
commit 7c10b87b57
2 changed files with 42 additions and 1 deletions

View File

@ -595,6 +595,43 @@ typedef struct TrellisPath {
#define TRELLIS_STAGES 121
#define TRELLIS_STATES (SCALE_MAX_DIFF+1)
static void set_special_band_scalefactors(AACEncContext *s, SingleChannelElement *sce)
{
int w, g, start = 0;
int minscaler_n = sce->sf_idx[0], minscaler_i = sce->sf_idx[0];
int bands = 0;
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
start = 0;
for (g = 0; g < sce->ics.num_swb; g++) {
if (sce->band_type[w*16+g] == INTENSITY_BT || sce->band_type[w*16+g] == INTENSITY_BT2) {
sce->sf_idx[w*16+g] = av_clip(ceilf(log2f(sce->is_ener[w*16+g])*2), -155, 100);
minscaler_i = FFMIN(minscaler_i, sce->sf_idx[w*16+g]);
bands++;
} else if (sce->band_type[w*16+g] == NOISE_BT) {
sce->sf_idx[w*16+g] = av_clip(4+log2f(sce->pns_ener[w*16+g])*2, -100, 155);
minscaler_n = FFMIN(minscaler_n, sce->sf_idx[w*16+g]);
bands++;
}
start += sce->ics.swb_sizes[g];
}
}
if (!bands)
return;
/* Clip the scalefactor indices */
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
for (g = 0; g < sce->ics.num_swb; g++) {
if (sce->band_type[w*16+g] == INTENSITY_BT || sce->band_type[w*16+g] == INTENSITY_BT2) {
sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler_i, minscaler_i + SCALE_MAX_DIFF);
} else if (sce->band_type[w*16+g] == NOISE_BT) {
sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler_n, minscaler_n + SCALE_MAX_DIFF);
}
}
}
}
static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s,
SingleChannelElement *sce,
const float lambda)

View File

@ -389,7 +389,7 @@ static void encode_scale_factors(AVCodecContext *avctx, AACEncContext *s,
SingleChannelElement *sce)
{
int diff, off_sf = sce->sf_idx[0], off_pns = sce->sf_idx[0] - NOISE_OFFSET;
int noise_flag = 1;
int off_is = 0, noise_flag = 1;
int i, w;
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
@ -402,6 +402,10 @@ static void encode_scale_factors(AVCodecContext *avctx, AACEncContext *s,
put_bits(&s->pb, NOISE_PRE_BITS, diff + NOISE_PRE);
continue;
}
} else if (sce->band_type[w*16 + i] == INTENSITY_BT ||
sce->band_type[w*16 + i] == INTENSITY_BT2) {
diff = sce->sf_idx[w*16 + i] - off_is;
off_is = sce->sf_idx[w*16 + i];
} else {
diff = sce->sf_idx[w*16 + i] - off_sf;
off_sf = sce->sf_idx[w*16 + i];