From 7c10b87b5744179f16411f5981e96738021ec7ca Mon Sep 17 00:00:00 2001 From: Rostislav Pehlivanov Date: Fri, 26 Jun 2015 21:16:34 +0100 Subject: 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 Signed-off-by: Michael Niedermayer --- libavcodec/aaccoder.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'libavcodec/aaccoder.c') diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 2f99924821..cd996b2430 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -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) -- cgit v1.2.3