X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Faacdec_fixed.c;h=9b2145c729051bfaa968f66d5793318fc13d4e1f;hb=5e546864b09379910721b35a14713982d933d9dd;hp=f96999efb41aebec8c7814477380d8787326ea30;hpb=23f447294487958e0c7e8c01b9f9abedb1c7ba78;p=ffmpeg diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c index f96999efb41..9b2145c7290 100644 --- a/libavcodec/aacdec_fixed.c +++ b/libavcodec/aacdec_fixed.c @@ -162,7 +162,7 @@ static void vector_pow43(int *coefs, int len) } } -static void subband_scale(int *dst, int *src, int scale, int offset, int len) +static void subband_scale(int *dst, int *src, int scale, int offset, int len, void *log_context) { int ssign = scale < 0 ? -1 : 1; int s = FFABS(scale); @@ -189,18 +189,18 @@ static void subband_scale(int *dst, int *src, int scale, int offset, int len) dst[i] = out * (unsigned)ssign; } } else { - av_log(NULL, AV_LOG_ERROR, "Overflow in subband_scale()\n"); + av_log(log_context, AV_LOG_ERROR, "Overflow in subband_scale()\n"); } } static void noise_scale(int *coefs, int scale, int band_energy, int len) { - int ssign = scale < 0 ? -1 : 1; - int s = FFABS(scale); + int s = -scale; unsigned int round; int i, out, c = exp2tab[s & 3]; int nlz = 0; + av_assert0(s >= 0); while (band_energy > 0x7fff) { band_energy >>= 1; nlz++; @@ -216,15 +216,20 @@ static void noise_scale(int *coefs, int scale, int band_energy, int len) round = s ? 1 << (s-1) : 0; for (i=0; i> 32); - coefs[i] = ((int)(out+round) >> s) * ssign; + coefs[i] = -((int)(out+round) >> s); } } else { s = s + 32; - round = 1 << (s-1); - for (i=0; i> s); - coefs[i] = out * ssign; + if (s > 0) { + round = 1 << (s-1); + for (i=0; i> s); + coefs[i] = -out; + } + } else { + for (i=0; i> 37); - dest[group * 128 + k] += (tmp + round) >> shift; + dest[group * 128 + k] += (tmp + (int64_t)round) >> shift; } } } @@ -417,7 +422,7 @@ static void apply_independent_coupling_fixed(AACContext *ac, int i, c, shift, round, tmp; const int gain = cce->coup.gain[index][0]; const int *src = cce->ch[0].ret; - int *dest = target->ret; + unsigned int *dest = target->ret; const int len = 1024 << (ac->oc[1].m4ac.sbr == 1); c = cce_scale_fixed[gain & 7]; @@ -436,7 +441,7 @@ static void apply_independent_coupling_fixed(AACContext *ac, else { for (i = 0; i < len; i++) { tmp = (int)(((int64_t)src[i] * c + (int64_t)0x1000000000) >> 37); - dest[i] += tmp * (1 << shift); + dest[i] += tmp * (1U << shift); } } } @@ -456,7 +461,7 @@ AVCodec ff_aac_fixed_decoder = { AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_NONE }, .capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .channel_layouts = aac_channel_layout, .profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles), .flush = flush,