* add sane pulse detection
***********************************/
+#include "libavutil/libm.h"
#include "libavutil/thread.h"
#include "libavutil/float_dsp.h"
#include "libavutil/opt.h"
float *audio)
{
int i;
- float *output = sce->ret_buf;
+ const float *output = sce->ret_buf;
apply_window[sce->ics.window_sequence[0]](s->fdsp, sce, audio);
* ms_mask is set.
*/
if (!cpe->ms_mask[w*16 + g] || cpe->is_mask[w*16 + g]
- || cpe->ch[0].band_type[w*16 + g] == NOISE_BT
- || cpe->ch[1].band_type[w*16 + g] == NOISE_BT) {
+ || cpe->ch[0].band_type[w*16 + g] >= NOISE_BT
+ || cpe->ch[1].band_type[w*16 + g] >= NOISE_BT) {
start += ics->swb_sizes[g];
continue;
}
chans = tag == TYPE_CPE ? 2 : 1;
cpe = &s->cpe[i];
for (ch = 0; ch < chans; ch++) {
+ int k;
float clip_avoidance_factor;
sce = &cpe->ch[ch];
ics = &sce->ics;
s->mdct1024.mdct_calc(&s->mdct1024, sce->lcoeffs, sce->ret_buf);
}
- if (isnan(cpe->ch->coeffs[0])) {
- av_log(avctx, AV_LOG_ERROR, "Input contains NaN\n");
- return AVERROR(EINVAL);
+ for (k = 0; k < 1024; k++) {
+ if (!isfinite(cpe->ch[ch].coeffs[k])) {
+ av_log(avctx, AV_LOG_ERROR, "Input contains NaN/+-Inf\n");
+ return AVERROR(EINVAL);
+ }
}
avoid_clipping(s, sce);
}
sce->band_type[w] = 0;
}
s->psy.bitres.alloc = -1;
- s->psy.bitres.bits = avctx->frame_bits / s->channels;
+ s->psy.bitres.bits = s->last_frame_pb_count / s->channels;
s->psy.model->analyze(&s->psy, start_ch, coeffs, wi);
if (s->psy.bitres.alloc > 0) {
/* Lambda unused here on purpose, we need to take psy's unscaled allocation */
put_bits(&s->pb, 3, TYPE_END);
flush_put_bits(&s->pb);
- avctx->frame_bits = put_bits_count(&s->pb);
+
+ s->last_frame_pb_count = put_bits_count(&s->pb);
+
s->lambda_sum += s->lambda;
s->lambda_count++;
s->channels = avctx->channels;
s->chan_map = aac_chan_configs[s->channels-1];
s->lambda = avctx->global_quality > 0 ? avctx->global_quality : 120;
+ s->last_frame_pb_count = 0;
avctx->extradata_size = 5;
avctx->frame_size = 1024;
avctx->initial_padding = 1024;
if (s->options.coder != AAC_CODER_TWOLOOP) {
ERROR_IF(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL,
"Coders other than twoloop require -strict -2 and some may be removed in the future\n");
- WARN_IF(s->options.coder == AAC_CODER_FAAC,
- "The FAAC-like coder will be removed in the near future, please use twoloop!\n");
s->options.intensity_stereo = 0;
s->options.pns = 0;
}
+ ERROR_IF(s->options.ltp && avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL,
+ "The LPT profile requires experimental compliance, add -strict -2 to enable!\n");
+
if ((ret = dsp_init(avctx, s)) < 0)
goto fail;
#define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
static const AVOption aacenc_options[] = {
- {"aac_coder", "Coding algorithm", offsetof(AACEncContext, options.coder), AV_OPT_TYPE_INT, {.i64 = AAC_CODER_TWOLOOP}, -1, AAC_CODER_NB-1, AACENC_FLAGS, "coder"},
- {"faac", "FAAC-inspired method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_FAAC}, INT_MIN, INT_MAX, AACENC_FLAGS, "coder"},
+ {"aac_coder", "Coding algorithm", offsetof(AACEncContext, options.coder), AV_OPT_TYPE_INT, {.i64 = AAC_CODER_TWOLOOP}, 0, AAC_CODER_NB-1, AACENC_FLAGS, "coder"},
{"anmr", "ANMR method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_ANMR}, INT_MIN, INT_MAX, AACENC_FLAGS, "coder"},
{"twoloop", "Two loop searching method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_TWOLOOP}, INT_MIN, INT_MAX, AACENC_FLAGS, "coder"},
{"fast", "Constant quantizer", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_FAST}, INT_MIN, INT_MAX, AACENC_FLAGS, "coder"},