summaryrefslogtreecommitdiff
path: root/libavcodec/aaccoder.c
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2015-06-26 21:16:34 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-06-29 16:44:40 +0200
commit7c10b87b5744179f16411f5981e96738021ec7ca (patch)
tree3c2dde11cc45c0fe3ce67124084064e14bd4021d /libavcodec/aaccoder.c
parentda8b228977406b1be95d7881e38651f4e61d1fc6 (diff)
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>
Diffstat (limited to 'libavcodec/aaccoder.c')
-rw-r--r--libavcodec/aaccoder.c37
1 files changed, 37 insertions, 0 deletions
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)