/**
* Save current output configuration if and only if it has been locked.
*/
-static void push_output_configuration(AACContext *ac) {
+static int push_output_configuration(AACContext *ac) {
+ int pushed = 0;
+
if (ac->oc[1].status == OC_LOCKED || ac->oc[0].status == OC_NONE) {
ac->oc[0] = ac->oc[1];
+ pushed = 1;
}
ac->oc[1].status = OC_NONE;
+ return pushed;
}
/**
if (get_bits1(gb))
skip_bits(gb, 3); // mixdown_coeff_index and pseudo_surround
- if (get_bits_left(gb) < 4 * (num_front + num_side + num_back + num_lfe + num_assoc_data + num_cc)) {
+ if (get_bits_left(gb) < 5 * (num_front + num_side + num_back + num_cc) + 4 *(num_lfe + num_assoc_data + num_cc)) {
av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err);
return -1;
}
AAC_RENAME_32(ff_mdct_init)(&ac->mdct_small, 8, 1, 1.0 / RANGE15(128.0));
AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ltp, 11, 0, RANGE15(-2.0));
#if !USE_FIXED
- ret = ff_mdct15_init(&ac->mdct480, 1, 5, -1.0f);
+ ret = ff_mdct15_init(&ac->mdct480, 1, 5, 1.0f/(16*1024*960));
if (ret < 0)
return ret;
#endif
coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1);
sign = get_bits(gb, 1);
- scale = AAC_RENAME(cce_scale)[get_bits(gb, 2)];
+#if USE_FIXED
+ scale = get_bits(gb, 2);
+#else
+ scale = cce_scale[get_bits(gb, 2)];
+#endif
if ((ret = decode_ics(ac, sce, gb, 0, 0)))
return ret;
cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb);
gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0;
gain_cache = GET_GAIN(scale, gain);
+#if USE_FIXED
+ if ((abs(gain_cache)-1024) >> 3 > 30)
+ return AVERROR(ERANGE);
+#endif
}
if (coup->coupling_point == AFTER_IMDCT) {
coup->gain[c][0] = gain_cache;
t >>= 1;
}
gain_cache = GET_GAIN(scale, t) * s;
+#if USE_FIXED
+ if ((abs(gain_cache)-1024) >> 3 > 30)
+ return AVERROR(ERANGE);
+#endif
}
}
coup->gain[c][idx] = gain_cache;
* @param decode 1 if tool is used normally, 0 if tool is used in LTP.
* @param coef spectral coefficients
*/
-static void apply_tns(INTFLOAT coef[1024], TemporalNoiseShaping *tns,
+static void apply_tns(INTFLOAT coef_param[1024], TemporalNoiseShaping *tns,
IndividualChannelStream *ics, int decode)
{
const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb);
int bottom, top, order, start, end, size, inc;
INTFLOAT lpc[TNS_MAX_ORDER];
INTFLOAT tmp[TNS_MAX_ORDER+1];
+ UINTFLOAT *coef = coef_param;
for (w = 0; w < ics->num_windows; w++) {
bottom = ics->num_swb;
// ar filter
for (m = 0; m < size; m++, start += inc)
for (i = 1; i <= FFMIN(m, order); i++)
- coef[start] -= AAC_MUL26(coef[start - i * inc], lpc[i - 1]);
+ coef[start] -= AAC_MUL26((INTFLOAT)coef[start - i * inc], lpc[i - 1]);
} else {
// ma filter
for (m = 0; m < size; m++, start += inc) {
}
#if !USE_FIXED
if (n == 480)
- ac->mdct480->imdct_half(ac->mdct480, buf, in, 1, -1.f/(16*1024*960));
+ ac->mdct480->imdct_half(ac->mdct480, buf, in, 1);
else
#endif
ac->mdct.imdct_half(&ac->mdct_ld, buf, in);
int j;
/* preparation for resampler */
for(j = 0; j<samples; j++){
- che->ch[0].ret[j] = (int32_t)av_clipl_int32((int64_t)che->ch[0].ret[j]<<7)+0x8000;
+ che->ch[0].ret[j] = (int32_t)av_clip64((int64_t)che->ch[0].ret[j]*128, INT32_MIN, INT32_MAX-0x8000)+0x8000;
if(type == TYPE_CPE)
- che->ch[1].ret[j] = (int32_t)av_clipl_int32((int64_t)che->ch[1].ret[j]<<7)+0x8000;
+ che->ch[1].ret[j] = (int32_t)av_clip64((int64_t)che->ch[1].ret[j]*128, INT32_MIN, INT32_MAX-0x8000)+0x8000;
}
}
#endif /* USE_FIXED */
case TYPE_PCE: {
uint8_t layout_map[MAX_ELEM_ID*4][3];
int tags;
- push_output_configuration(ac);
+
+ int pushed = push_output_configuration(ac);
+ if (pce_found && !pushed) {
+ err = AVERROR_INVALIDDATA;
+ goto fail;
+ }
+
tags = decode_pce(avctx, &ac->oc[1].m4ac, layout_map, gb,
payload_alignment);
if (tags < 0) {