summaryrefslogtreecommitdiff
path: root/libavcodec/aacenc_is.c
diff options
context:
space:
mode:
authorClaudio Freire <klaussfreire@gmail.com>2016-01-08 05:16:18 -0300
committerClaudio Freire <klaussfreire@gmail.com>2016-01-13 05:28:34 -0300
commit4dcb69cc12d00d46f93a07178e2087a8d27c8f64 (patch)
treecb97064df3dfb39ed17e408e5befc810443dac11 /libavcodec/aacenc_is.c
parent509f168017462cf301d16e3c406337072c81c783 (diff)
AAC encoder: in IS, fix index of sf_idx, band_type
Correct addressing of sf_idx and band_type arrays in I/S code. Both arrays don't guarantee valid values for subwindows at all times, depending on which coder is being used, which could result in reading of garbage values. Instead, only the first subwindow in the window group has to be used, ie: use w*16+g instead of (w+w2)*16+g
Diffstat (limited to 'libavcodec/aacenc_is.c')
-rw-r--r--libavcodec/aacenc_is.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/libavcodec/aacenc_is.c b/libavcodec/aacenc_is.c
index 4f7ec19f96..ac4789a492 100644
--- a/libavcodec/aacenc_is.c
+++ b/libavcodec/aacenc_is.c
@@ -53,7 +53,7 @@ struct AACISError ff_aac_is_encoding_err(AACEncContext *s, ChannelElement *cpe,
for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g];
FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g];
- int is_band_type, is_sf_idx = FFMAX(1, sce0->sf_idx[(w+w2)*16+g]-4);
+ int is_band_type, is_sf_idx = FFMAX(1, sce0->sf_idx[w*16+g]-4);
float e01_34 = phase*pow(ener1/ener0, 3.0/4.0);
float maxval, dist_spec_err = 0.0f;
float minthr = FFMIN(band0->threshold, band1->threshold);
@@ -66,13 +66,13 @@ struct AACISError ff_aac_is_encoding_err(AACEncContext *s, ChannelElement *cpe,
is_band_type = find_min_book(maxval, is_sf_idx);
dist1 += quantize_band_cost(s, &L[start + (w+w2)*128], L34,
sce0->ics.swb_sizes[g],
- sce0->sf_idx[(w+w2)*16+g],
- sce0->band_type[(w+w2)*16+g],
+ sce0->sf_idx[w*16+g],
+ sce0->band_type[w*16+g],
s->lambda / band0->threshold, INFINITY, NULL, NULL, 0);
dist1 += quantize_band_cost(s, &R[start + (w+w2)*128], R34,
sce1->ics.swb_sizes[g],
- sce1->sf_idx[(w+w2)*16+g],
- sce1->band_type[(w+w2)*16+g],
+ sce1->sf_idx[w*16+g],
+ sce1->band_type[w*16+g],
s->lambda / band1->threshold, INFINITY, NULL, NULL, 0);
dist2 += quantize_band_cost(s, IS, I34, sce0->ics.swb_sizes[g],
is_sf_idx, is_band_type,
@@ -118,11 +118,6 @@ void ff_aac_search_for_is(AACEncContext *s, AVCodecContext *avctx, ChannelElemen
ff_sfdelta_can_remove_band(sce1, nextband1, prev_sf1, w*16+g)) {
float ener0 = 0.0f, ener1 = 0.0f, ener01 = 0.0f, ener01p = 0.0f;
struct AACISError ph_err1, ph_err2, *best;
- if (sce0->band_type[w*16+g] == NOISE_BT ||
- sce1->band_type[w*16+g] == NOISE_BT) {
- start += sce0->ics.swb_sizes[g];
- continue;
- }
for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
float coef0 = fabsf(sce0->coeffs[start+(w+w2)*128+i]);