* add sane pulse detection
***********************************/
+#include "libavutil/thread.h"
#include "libavutil/float_dsp.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "psymodel.h"
+static AVOnce aac_table_init = AV_ONCE_INIT;
+
/**
* Make AAC audio config object.
* @see 1.6.2.1 "Syntax - AudioSpecificConfig"
for (w2 = 0; w2 < ics->group_len[w]; w2++) {
int start = (w+w2) * 128;
for (g = 0; g < ics->num_swb; g++) {
- if (!cpe->ms_mask[w*16 + g] && !cpe->is_mask[w*16 + g]) {
+ /* ms_mask can be used for other purposes in PNS and I/S,
+ * so must not apply M/S if any band uses either, even if
+ * 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) {
start += ics->swb_sizes[g];
continue;
}
for (ch = 0; ch < chans; ch++) { /* TNS and PNS */
sce = &cpe->ch[ch];
s->cur_channel = start_ch + ch;
- if (s->options.pns && s->coder->search_for_pns)
- s->coder->search_for_pns(s, avctx, sce);
if (s->options.tns && s->coder->search_for_tns)
s->coder->search_for_tns(s, sce);
if (s->options.tns && s->coder->apply_tns_filt)
s->coder->apply_tns_filt(s, sce);
if (sce->tns.present)
tns_mode = 1;
+ if (s->options.pns && s->coder->search_for_pns)
+ s->coder->search_for_pns(s, avctx, sce);
}
s->cur_channel = start_ch;
if (s->options.intensity_stereo) { /* Intensity Stereo */
s->lambda = FFMIN(s->lambda * ratio, 65536.f);
/* Keep iterating if we must reduce and lambda is in the sky */
- if ((s->lambda < 300.f || ratio > 0.9f) && (s->lambda > 10.f || ratio < 1.1f)) {
+ if (ratio > 0.9f && ratio < 1.1f) {
break;
} else {
if (is_mode || ms_mode || tns_mode || pred_mode) {
return AVERROR(ENOMEM);
}
+static av_cold void aac_encode_init_tables(void)
+{
+ ff_aac_tableinit();
+}
+
static av_cold int aac_encode_init(AVCodecContext *avctx)
{
AACEncContext *s = avctx->priv_data;
avctx->profile = FF_PROFILE_AAC_MAIN;
WARN_IF(1,
"Chainging profile to \"aac_main\"\n");
- ERROR_IF(s->options.pred,
+ ERROR_IF(s->options.ltp,
"LTP prediction unavailable in the \"aac_main\" profile\n");
}
s->profile = avctx->profile;
s->coder = &ff_aac_coders[s->options.coder];
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;
}
s->psypp = ff_psy_preprocess_init(avctx);
ff_lpc_init(&s->lpc, 2*avctx->frame_size, TNS_MAX_ORDER, FF_LPC_TYPE_LEVINSON);
- if (HAVE_MIPSDSPR1)
+ if (HAVE_MIPSDSP)
ff_aac_coder_init_mips(s);
- ff_aac_tableinit();
+ if ((ret = ff_thread_once(&aac_table_init, &aac_encode_init_tables)) != 0)
+ return AVERROR_UNKNOWN;
ff_af_queue_init(avctx, &s->afq);
.encode2 = aac_encode_frame,
.close = aac_encode_end,
.supported_samplerates = mpeg4audio_sample_rates,
- .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY |
- AV_CODEC_CAP_EXPERIMENTAL,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
+ .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
.priv_class = &aacenc_class,