43#ifndef AVCODEC_AACCODER_NMR_H
44#define AVCODEC_AACCODER_NMR_H
58#define NMR_SFBITS(d) ff_aac_scalefactor_bits[av_clip((d) + SCALE_DIFF_ZERO, 0, 2*SCALE_MAX_DIFF)]
74#define NMR_PNS_HOLE_FRAC 0.5f
75#define NMR_PNS_HOLE_SPREAD 0.5f
78#define NMR_PNS_HOLE_LAM 20.0f
82#define NMR_RC_K_CBR 0.5f
87#define NMR_RC_CORR 1.5f
90#define NMR_RC_CAPK 3.0f
106#define NMR_VBR_ANCHOR (-0.75f)
107#define NMR_VBR_TMIN (-3.8f)
113#define NMR_ABR_TMIN (-3.0f)
114#define NMR_ABR_TMAX 2.5f
118#define NMR_ABR_K 0.003f
119#define NMR_ABR_EMA 0.0023f
120#define NMR_ABR_STEP 0.15f
121#define NMR_ABR_HOLD 120
124#define NMR_ABR_BOOT_GAIN 1.2f
125#define NMR_ABR_TOL 0.02f
126#define NMR_ABR_BOOTS 6
127#define NMR_ABR_SETTLE 100
131#define NMR_INFL_HF 0.10f
134#define NMR_CBR_BUF 1536
138#define NMR_SLEW_RUN 1.15f
139#define NMR_RC_CITERS 3
143#define NMR_TRANS_PM 2.0f
147#define NMR_ZERO_STICKY 0.5f
151#define NMR_GROUP_KEEP 0.25f
155#define NMR_HF_TAPER 0.08f
156#define NMR_HF_TAPER_KNEE 8000.0f
160#define NMR_BURST_GAP 10
161#define NMR_BURST_GAIN 8.0f
164#define NMR_SHORT_BOOST 2.0f
165#define NMR_RC_FITERS 4
166#define NMR_RC_TRACK 0.1f
169#define NMR_PNS_NDGATE 4.0f
173#define NMR_PNS_MAX_ET 8.0f
177#define NMR_PNS_LAM 100.0f
180#define NMR_PNS_ENTER 0.7f
181#define NMR_PNS_STAY 1.4f
196 const int *blo,
const int *bnc,
int step,
197 const int *act,
int nact,
int destbits,
int *chosen,
198 float lo_l,
float hi_l,
int iters)
208 for (
int it = 0; it < iters; it++) {
209 lam =
sqrtf(lo_l * hi_l);
214 for (
int o = 0; o < bnc[
b0]; o++)
215 dp[o] = nd[
b0][o] + lam * nb[
b0][o];
217 for (
int k = 1; k < nact; k++) {
218 int b = act[k], pb = act[k-1];
219 memcpy(dpp, dp,
sizeof(dp));
220 for (
int o = 0; o < bnc[
b]; o++)
221 node[o] = nd[
b][o] + lam * nb[
b][o];
223 s->aacdsp.nmr_trellis_step(dp, bp[k], dpp, node, lamsf,
224 bnc[
b], bnc[pb], blo[
b] - blo[pb], step,
229 int beo = 0,
b = act[nact-1];
231 for (
int o = 0; o < bnc[
b]; o++)
232 if (dp[o] < bec) { bec = dp[o]; beo = o; }
234 for (
int k = nact-1; k > 0; k--)
235 chosen[act[k-1]] = bp[k][chosen[act[k]]];
239 for (
int k = 0; k < nact; k++)
240 total += nb[act[k]][chosen[act[k]]];
241 for (
int k = 1; k < nact; k++)
242 total +=
NMR_SFBITS((blo[act[k]]+chosen[act[k]]*step) - (blo[act[k-1]]+chosen[act[k-1]]*step));
248 if (total > destbits)
259 int start,
int lo,
int step,
int maxn,
float invthr,
260 float maxval,
float *nd_row,
int *nb_row)
263 for (
int o = 0; o < maxn && lo + o*step <=
SCALE_MAX_POS; o++) {
275 nd_row[ncand] = (dist - btot) * invthr;
276 nb_row[ncand] = btot;
286 for (
int i = 0;
i < 128;
i++) {
303 int allz = 0, cutoff = 1024, nbnd = 0;
305 uint8_t *zprev =
s->nmr->zero_prev[
s->cur_channel & 15];
307 memset(zprev, 1, 128);
322 const float pm_p1 = 0.1f, pm_p2 = 2.0f, pm_p3 = 4.0f;
324 float t1 = FLT_MAX, t2 = FLT_MAX;
327 float th =
b->threshold;
329 b->threshold =
FFMAX(
c, th*pm_p1);
335 float sum = 0.0f, esum = 0.0f;
int n = 0;
338 if (
b->energy >
b->threshold &&
b->threshold > 0.0f) { sum +=
b->threshold; esum +=
b->energy; n++; }
343 float mean =
FFMIN(sum / n, (esum / n) * expf(-12.0f * (
float)
M_LN10 / 10.0f));
346 if (
b->energy >
b->threshold &&
b->threshold > 0.0f)
359 float a_ae = 0.50f, a_at = 0.18f;
362 a_ae += (0.35f - a_ae) *
s->nmr->press;
363 a_at += (0.3f - a_at) *
s->nmr->press;
368 float uplim = 0.0f, ener = 0.0f, spread = 2.0f;
381 if ((t->
cur_ch & 1) &&
s->nmr &&
s->nmr->pair &&
382 s->nmr->smode_band[(t->
cur_ch >> 1) & 7][
w*16+
g] == 1) {
383 const FFPsyBand *
mb = &
s->psy.ch[
s->cur_channel - 1].psy_bands[
w*16+
g];
387 const FFPsyBand *bb = &
s->psy.ch[
s->cur_channel].psy_bands[(
w+w2)*16+
g];
391 zthr_mul *= 0.25f + 0.75f *
av_clipf(ratio / 0.3f, 0.0f, 1.0f);
405 FFPsyBand *band = &
s->psy.ch[
s->cur_channel].psy_bands[(
w+w2)*16+
g];
422 FFPsyBand *band = &
s->psy.ch[
s->cur_channel].psy_bands[(
w+w2)*16+
g];
423 if (sce->
zeroes[(
w+w2)*16+
g] && start < cutoff &&
434 if (nz && ener > 0.0f && uplim > 0.0f) {
435 uplim = expf(a_ae * logf(ener) + a_at * logf(uplim));
437 uplim *= powf(10.0f, hftdb * 0.1f);
446 t->
thr[
w*16+
g] = uplim;
459 s->nmr->thr_prev_ok[ci]) {
461 if (t->
thr[
g] > 0.0f &&
s->nmr->thr_prev[ci][
g] > 0.0f)
465 s->nmr->thr_prev[ci][
g] = t->
thr[
g];
466 s->nmr->thr_prev_ok[ci] = 1;
468 s->nmr->thr_prev_ok[t->
cur_ch & 15] = 0;
471 s->aacdsp.abs_pow34(
s->scoefs, sce->
coeffs, 1024);
476 for (
int i = 0;
i < 128;
i++)
480 for (
int w = 0;
w < 8;
w++) {
487 for (
int g =
FFMIN(bottom2, mmm2);
g <
FFMIN(top2, mmm2);
g++) {
491 const FFPsyBand *pb = &
s->psy.ch[
s->cur_channel].psy_bands[
w*16+
g];
492 for (
int k = s0; k < s1; k++)
518 float invthr = 1.0f /
FFMAX(t->
thr[
w*16+
g], 1e-9f);
520 invthr, t->
maxvals[
w*16+
g], nd[nbnd], nb[nbnd]);
521 if (t->
tnsg[
w*16+
g] > 1.0f)
522 for (
int o = 0; o < ncand; o++)
523 nd[nbnd][o] *= t->
tnsg[
w*16+
g];
533 t->
bst[nbnd] = start;
535 t->
bnc[nbnd] = ncand;
544 for (
int b = 0;
b < nbnd;
b++) {
556 for (
int k = 0; k < t->
nact; k++)
558 for (
int k = 1; k < t->
nact; k++)
568 for (
int k = 0; k < nsl; k++) {
583 int destbits,
float lo_l,
float hi_l,
int iters)
586 for (
int it = 0; it < iters; it++) {
587 lam =
sqrtf(lo_l * hi_l);
592 if (total > destbits)
608 for (
int k = 0; k < nsl; k++) {
611 for (
int b_ = 0; b_ < t->
nact; b_++) {
623 return n ? ndsum / n :
NAN;
630 int step,
float target,
float lo_l,
float hi_l,
634 for (
int it = 0; it < iters; it++) {
636 lam =
sqrtf(lo_l * hi_l);
639 if (isnan(st) || it == iters - 1)
656 for (
int b = 0;
b < t->
nbnd;
b++) {
677 uint8_t nextband[128];
714 int last = sce->
sf_idx[0];
731 const float lambda,
NMRSlot *
const *sl,
int nsl,
732 int chans,
int rc_eligible,
int rc_global,
733 int rc_rate_frame,
int rc_bmax)
737 int destbits = avctx->
bit_rate * 1024.0 / avctx->
sample_rate / bch * (lambda / 120.f) * chans;
740 float rc_off = 1.0f, lam_dem = 0.0f;
746 for (
int k = 0; k < nsl; k++)
747 is8_any |= sl[k]->is8;
751 float *vslew_st = &
s->nmr->lam_slew;
752 if (nsl == 1 &&
s->channels > 1) {
753 vslew_st = &
s->nmr->lam_slew_ch[sl[0]->
cur_ch & 15];
754 if (*vslew_st <= 0.0f)
755 *vslew_st =
s->nmr->lam_slew;
758 if (
s->psy.bitres.alloc >= 0)
759 destbits =
s->psy.bitres.alloc *
761 if (rc_global &&
s->psy.bitres.alloc >= 0) {
764 destbits = (rr +
av_clipd(
s->nmr->rc_fill / 2.0, -0.3 * rr, 0.3 * rr)) * chans /
s->channels;
765 }
else if (rc_eligible &&
s->psy.bitres.alloc >= 0) {
769 destbits =
FFMIN(destbits, 5800 * chans);
772 if (
s->nmr->side_inited)
773 destbits =
av_clip(destbits - (
int)(
s->nmr->side_ema * chans /
s->channels), 64, 5800 * chans);
777 if (
s->nmr->run_burst > 1.0f) {
778 int extra = destbits * (
s->nmr->run_burst - 1.0f);
779 int avail =
FFMAX(0, (
int)((
s->nmr->rc_fill + rc_bmax / 2) * (
int64_t)chans /
s->channels));
780 destbits =
av_clip(destbits +
FFMIN(extra, avail), 64, 6800 * chans);
784 int abr = !vbr &&
s->options.rc == 1 && avctx->
bit_rate > 0 &&
s->nmr;
789 vbr_t =
s->nmr->abr_t;
800 if (vbr && is8_any) {
806 float lam0 = *vslew_st > 0.0f ?
FFMIN(*vslew_st, 1e4f) : 0.0f;
807 float *infl = &
s->nmr->vbr_infl[sl[0]->
cur_ch & 15];
817 float st0, ehf = 0.0f, etot = 0.0f, hfw;
824 for (
int k = 0; k < nsl; k++)
825 for (
int b_ = 0; b_ < sl[k]->
nact; b_++) {
826 int b = sl[k]->
act[b_], bi = sl[k]->
bidx[
b];
827 float en = sl[k]->
pener[bi];
828 int bin = sl[k]->
bst[
b] - sl[k]->
bw[
b]*128;
830 if (bin * (avctx->
sample_rate * 4.0f) / 1024.0f > 6000.0f)
834 *infl = isnan(st0) ? 0.0f :
av_clipf(st0 - vbr_t, 0.0f, 4.0f) * hfw;
849 if (lam > lam0 * kup || lam < lam0 / 4.0f) {
850 lam =
av_clipf(lam, lam0 / 4.0f, lam0 * kup);
857 float lam0 =
s->nmr->lam[sl[0]->
cur_ch];
860 lam0 =
FFMIN(lam0, 1e4f);
863 if (lam < lam0/16.0f || lam > lam0*16.0f)
868 }
else if (rc_global) {
873 int tot, hardcap, rc_cap;
876 cen =
s->nmr->lam_rc * rc_off;
880 if (is8_any &&
s->nmr->run_burst > 1.0f)
881 lo /=
s->nmr->run_burst;
886 for (
int k = 0; k < nsl; k++)
888 hardcap =
av_clip((
int)(5800.f *
FFMIN(1.f, lambda / 120.f)), 256, 5800) * chans;
890 rc_cap =
FFMIN(hardcap, (
s->nmr->rc_fill + rc_rate_frame + rc_bmax) * chans /
s->channels);
901 for (
int k = 0; k < nsl; k++)
903 if (tot > rc_cap &&
s->nmr->rc_fill <= -(rc_bmax * 9 / 10)) {
915 s->nmr->rc_sat_frame = 1;
917 for (
int k = 0; k < nsl; k++)
926 float lam0 =
s->nmr->lam[sl[0]->
cur_ch];
930 if (lam < lam0/16.0f || lam > lam0*16.0f)
945 for (
int k = 0; k < nsl; k++) {
952 s->aacdsp.abs_pow34(
s->scoefs, t->
sce->
coeffs, 1024);
954 for (
int b = 0;
b < t->
nbnd;
b++) {
962 for (
int o = 0; o < ncand; o++)
969 if (vbr && !vbr_subst) {
970 float infl2 = is8_any ?
s->nmr->vbr_infl[sl[0]->
cur_ch & 15] : 0.0f;
995 for (
int k = 0; k < nsl; k++)
996 subst += sl[k]->nact;
1006 subst = vbr_subst && subst >= 8 && !isnan(st_fin) &&
1007 st_fin > vbr_t - 0.5f && st_fin < vbr_t + 0.5f;
1009 if (*vslew_st > 0.0f) {
1018 *vslew_st =
s->nmr->lam_slew = lam;
1019 }
else if (is8_any && *vslew_st > 0.0f) {
1025 float lam0 =
FFMIN(*vslew_st, 1e4f);
1026 if (lam > lam0 * kup || lam < lam0 / 4.0f) {
1027 lam =
av_clipf(lam, lam0 / 4.0f, lam0 * kup);
1040 int hardcap =
av_clip((
int)(5800.f *
FFMIN(1.f, lambda / lam_ref)), 256, 5800) * chans;
1042 if (
s->nmr->side_inited)
1043 hardcap =
FFMAX(hardcap - (
int)(
FFMAX(
s->nmr->side_ema, 0.0f) * chans /
s->channels), 256);
1044 for (
int k = 0; k < nsl; k++)
1046 if (abr &&
s->nmr->abr_ema < rc_rate_frame) {
1061 float dshape = 1.0f;
1063 if (
s->psy.bitres.alloc > 0) {
1064 float *aema = &
s->nmr->abr_alloc_ema;
1065 if (*aema <= 0.0f) *aema =
s->psy.bitres.alloc;
1066 else *aema += 0.01f * (
s->psy.bitres.alloc - *aema);
1067 dshape =
av_clipf(
s->psy.bitres.alloc / *aema, 0.6f, 1.7f);
1069 fill = (int)((rc_rate_frame + (rc_rate_frame - (
int)
s->nmr->abr_ema)) * dshape) *
1070 chans /
s->channels;
1071 fill =
FFMIN3(fill, 3 * rc_rate_frame * chans /
s->channels / 2, hardcap);
1077 float flo = lam / 64.0f;
1078 if (*vslew_st > 0.0f)
1082 *vslew_st =
s->nmr->lam_slew = lam;
1084 for (
int k = 0; k < nsl; k++)
1088 if (tot > hardcap) {
1091 for (
int k = 0; k < nsl; k++)
1099 while (tot > hardcap) {
1101 for (
int k = 0; k < nsl; k++) {
1104 int hi = 1,
b, w0,
g;
1107 for (
int b_ = 2; b_ < t->
nact; b_++)
1113 sce->
zeroes[(w0+w2)*16+
g] = 1;
1114 memmove(&t->
act[hi], &t->
act[hi + 1], (t->
nact - hi - 1) *
sizeof(t->
act[0]));
1128 int hardcap =
av_clip((
int)(5800.f *
FFMIN(1.f, lambda / 120.f)), 256, 5800) * chans;
1129 int tot = 0, rc_cap;
1130 for (
int k = 0; k < nsl; k++)
1132 rc_cap =
FFMIN(hardcap, (
s->nmr->rc_fill + rc_rate_frame + rc_bmax) * chans /
s->channels);
1143 int fbits = (rc_rate_frame -
headroom) * chans /
s->channels;
1147 for (
int k = 0; k < nsl; k++)
1151 if (
s->nmr->lam_slew > 0.0f) {
1157 kdn = (is8_any &&
s->nmr->run_burst > 1.0f) ?
NMR_SLEW *
s->nmr->run_burst :
1159 if (lam >
s->nmr->lam_slew * kup || lam < s->nmr->lam_slew / kdn) {
1160 lam =
av_clipf(lam,
s->nmr->lam_slew / kdn,
s->nmr->lam_slew * kup);
1168 s->nmr->lam_slew = lam;
1169 }
else if (rc_eligible && !vbr) {
1174 int fbits = (rc_rate_frame -
headroom) * chans /
s->channels;
1176 for (
int k = 0; k < nsl; k++)
1182 if (!vbr || vbr_subst)
1183 for (
int k = 0; k < nsl; k++)
1184 s->nmr->lam[sl[k]->
cur_ch] = lam;
1187 float ndsum = 0.0f;
int ndn = 0;
1188 for (
int k = 0; k < nsl; k++) {
1191 for (
int b_ = 0; b_ < t->
nact; b_++) {
1200 if (ndn >= 8 && !is8_any) {
1201 float nd = ndsum / ndn;
1202 s->nmr->nd_ema =
s->nmr->nd_ema > 0.0f ?
1203 0.95f *
s->nmr->nd_ema + 0.05f * nd : nd;
1207 float *ema = is8_any ? &
s->nmr->lam_short_ema : &
s->nmr->lam_long_ema;
1208 *ema = *ema > 0.0f ? 0.9f * *ema + 0.1f * lam : lam;
1212 s->nmr->lam_floor =
s->nmr->lam_floor > 0.0f ?
1213 fminf(
s->nmr->lam_floor * 1.02f, lam) : lam;
1218 ramp =
s->nmr->lam_long_ema > 0.0f ?
1220 (350.0f *
scale - 120.0f *
scale), 0.0f, 1.0f) : 0.0f;
1222 if (
s->nmr->nd_ema > 0.0f)
1223 ramp *=
av_clipf((
s->nmr->lam_long_ema *
s->nmr->nd_ema - 60.0f) /
1224 (120.0f - 60.0f), 0.0f, 1.0f);
1225 s->nmr->press = ramp;
1230 float c =
s->nmr->lam_rc * powf(lam_dem / rc_off /
s->nmr->lam_rc,
NMR_RC_TRACK);
1232 }
else if (rc_eligible) {
1236 for (
int k = 0; k < nsl; k++)
1237 nbnd_max =
FFMAX(nbnd_max, sl[k]->nbnd);
1238 if (nbnd_max >= 8) {
1239 s->nmr->lam_rc =
av_clipf(lam, 1e-4f, 1e4f);
1240 s->nmr->lam_slew =
s->nmr->lam_rc;
1247 for (
int k = 0; k < nsl; k++) {
1253 for (
int b = 1;
b < t->
nbnd;
b++) {
1254 int bi = t->
bidx[
b];
1255 float spread = t->
pspread[bi];
1256 float nmr_pns, cost_keep, cost_pns, frac;
1262 int was =
s->nmr->pns_prev[t->
cur_ch & 15][bi];
1264 int want = 0, force_exit = 0;
1278 }
else if (lam > pns_lam) {
1283 nmr_pns =
FFMAX(0.0f, t->
pener[bi] * (1.0f - spread*spread))
1287 want = cost_pns < cost_keep *
bias;
1292 uint8_t *ron = &
s->nmr->pns_run_on [t->
cur_ch & 15][bi];
1293 uint8_t *roff = &
s->nmr->pns_run_off[t->
cur_ch & 15][bi];
1295 if (want) {
if (*ron < 255) (*ron)++; *roff = 0; }
1296 else {
if (*roff < 255) (*roff)++; *ron = 0; }
1298 want = was && *roff < 2;
1315 for (
int b_ = 0; b_ < t->
nact; b_++)
1317 t->
act[n++] = t->
act[b_];
1320 pns_total += pns_count;
1326 if (rc_global || vbr)
1334 for (
int k = 0; k < nsl; k++) {
1336 uint8_t *pp =
s->nmr->pns_prev[t->
cur_ch & 15];
1337 uint8_t now[128] = {0};
1338 for (
int b = 0;
b < t->
nbnd;
b++)
1340 now[t->
bidx[
b]] = 1;
1341 memcpy(pp, now, 128);
1343 for (
int k = 0; k < nsl; k++)
1363 int rc_global, defer;
1366 s->nmr->counted[
s->cur_channel] = 0;
1383 }
else if (
s->last_frame_pb_count > 0) {
1393 (
s->last_frame_pb_count - n->
abr_ema);
1520 rc_global = rc_eligible && n->
rc_gl;
1524 defer = n->
pair && rc_global;
1541 int nsl = 0, chans = 1;
1546 sl[nsl++] = &n->
slot[0];
1548 sl[nsl++] = &n->
slot[1];
1549 }
else if (t->
nact) {
1555 rc_eligible, rc_global, rc_rate_frame, rc_bmax);
AAC definitions and structures.
#define SCALE_MAX_DIFF
maximum scalefactor difference allowed by standard
@ INTENSITY_BT
Scalefactor data are intensity stereo positions (in phase).
@ INTENSITY_BT2
Scalefactor data are intensity stereo positions (out of phase).
@ RESERVED_BT
Band types following are encoded differently from others.
@ NOISE_BT
Spectral data are scaled white noise not coded in the bitstream.
#define SCALE_MAX_POS
scalefactor index maximum value
static void search_for_quantizers_nmr(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, const float lambda)
static float nmr_solve_slots(AACEncContext *s, NMRSlot *const *sl, int nsl, int step, int destbits, float lo_l, float hi_l, int iters)
static int nmr_setup_channel(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, NMRSlot *t)
static void nmr_solve_group(AVCodecContext *avctx, AACEncContext *s, const float lambda, NMRSlot *const *sl, int nsl, int chans, int rc_eligible, int rc_global, int rc_rate_frame, int rc_bmax)
#define NMR_PNS_HOLE_SPREAD
#define NMR_PNS_HOLE_FRAC
static float nmr_solve_slots_nd(AACEncContext *s, NMRSlot *const *sl, int nsl, int step, float target, float lo_l, float hi_l, int iters)
static int nmr_slot_bits(const NMRSlot *t, const int(*nb)[NMR_NCAND], int step)
static int nmr_eval_slots(AACEncContext *s, NMRSlot *const *sl, int nsl, int step, float lam)
static int nmr_band_curve(AACEncContext *s, SingleChannelElement *sce, int w, int g, int start, int lo, int step, int maxn, float invthr, float maxval, float *nd_row, int *nb_row)
#define NMR_SFBITS(d)
AAC encoder NMR scalefactor coder.
static float nmr_solve(AACEncContext *s, const float(*nd)[NMR_NCAND], const int(*nb)[NMR_NCAND], const int *blo, const int *bnc, int step, const int *act, int nact, int destbits, int *chosen, float lo_l, float hi_l, int iters)
Viterbi over the coding sequence act[0..nact-1] (indices into the per-band curves nd/nb),...
#define NMR_ABR_BOOT_GAIN
static float nmr_nd_stat(AACEncContext *s, NMRSlot *const *sl, int nsl)
#define NMR_HF_TAPER_KNEE
static void nmr_commit_channel(AACEncContext *s, NMRSlot *t)
static void nmr_bail_channel(SingleChannelElement *sce)
void ff_quantize_band_cost_cache_init(struct AACEncContext *s)
#define NMR_NCAND
per-band scalefactor candidates above the finest codeable sf (NMR coder)
static float quantize_band_cost_cached(struct AACEncContext *s, int w, int g, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, float *energy, int rtz)
static void ff_init_nextband_map(const SingleChannelElement *sce, uint8_t *nextband)
static int find_min_book(float maxval, int sf)
static float find_max_val(int group_len, int swb_size, const float *scaled)
static uint8_t coef2minsf(float coef)
Return the minimum scalefactor where the quantized coef does not clip.
static int ff_sfdelta_can_remove_band(const SingleChannelElement *sce, const uint8_t *nextband, int prev_sf, int band)
const uint8_t ff_aac_scalefactor_bits[121]
static const int8_t filt[NUMTAPS *2]
static float win(SuperEqualizerContext *s, float n, int N)
Libavcodec external API header.
#define i(width, name, range_min, range_max)
static __device__ float sqrtf(float a)
static __device__ float fabsf(float a)
float fminf(float, float)
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale.
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static int headroom(int *la)
int frames_since_short
long-block frames since the last short run (the "gap"): large = isolated transient
int64_t win_frame_num
frame the window history was last advanced for
NMRSlot slot[2]
pair slots (solo solves use slot 0)
int rc_sat_frame
the current frame hit a saturated overage
int rc_satrun
consecutive frames with saturated reservoir debt (cap escalation)
int abr_longs
long frames seen during bootstrap
float run_burst
transient bit-burst factor, set at run start and held across the short run
int64_t abr_frame_num
once-per-frame servo guard
float abr_ema
EMA of real frame bits.
int rc_fill
virtual bit reservoir fill, + = bits saved vs nominal
float abr_t
current nd target (log2 dist/mask)
int rc_gl
rc_global latched at frame start: the corridor bootstrap must not flip the CPE defer logic between ch...
float lam_short_ema
smoothed operating lambda of short frames
int64_t rc_frame_num
frame the reservoir was last advanced for
float lam_long_ema
smoothed operating lambda of long frames
int pending
slot 0 holds a deferred first channel
int abr_boots
open-loop corrections fired so far
float abr_glide
pending set-point correction, drained per-frame (no discrete quality steps)
int abr_booted
seed correction applied (re-armed while the rate is still off)
int abr_hold
frames since the target last stepped
int prev_was_short
previous frame was a short block (for run-start detection)
float lam_rc
global-lambda rate control: operating lambda, 0 until bootstrapped
int rc_fill_seeded
reservoir seeded full at stream start (decoder buffer starts full)
float abr_acc
accumulated set-point correction
int pair
current element is a CPE: pool the pair budget
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
int global_quality
Global quality for codecs which cannot change it per frame.
int64_t frame_num
Frame counter, set by libavcodec.
int bit_rate_tolerance
number of bits the bitstream is allowed to diverge from the reference.
int64_t bit_rate
the average bitrate
int sample_rate
samples per second
int flags
AV_CODEC_FLAG_*.
single band psychoacoustic information
uint8_t max_sfb
number of scalefactor bands per group
int num_swb
number of scalefactor window bands
const uint8_t * swb_sizes
table of scalefactor band sizes for a particular window
enum WindowSequence window_sequence[2]
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
NMR coder per-band candidate cost curves (~96 KiB) and rate-control carry-over.
float pspread[128]
band tonality spread (1 = noise)
float tnsg[128]
TNS synthesis gain per band for THIS solve (1 = uncovered), M/S-aware (pair max)
int bst[128]
window group, swb, coef start
struct SingleChannelElement * sce
int bnc[128]
number of candidates
uint8_t hftx[128]
band strongly HF-tapered: excluded from the nd stat (deficit is by design)
float thr_real[128]
real masking threshold (PNS gates)
uint8_t is_pns[128]
band coded as noise
int si
curve-bank index (nd/nb slot)
float pener[128]
band energy (PNS noise target)
float thr[128]
allocation-law effective threshold
int bidx[128]
sce band index (w*16+g)
int nbnd
coded-band count, 0 = nothing codeable
int blo[128]
finest candidate scalefactor
int act[128]
active (non-PNS) band coding order
int is8
EIGHT_SHORT frame.
int cur_ch
encoder channel index (psy/cache context)
Single Channel Element - used for both SCE and LFE elements.
uint8_t zeroes[128]
band is not coded
float coeffs[1024]
coefficients for IMDCT, maybe processed
uint8_t can_pns[128]
band is allowed to PNS (informative)
float pns_ener[128]
Noise energy values.
enum BandType band_type[128]
band types
IndividualChannelStream ics
int sf_idx[128]
scalefactor indices
static double cb(void *priv, double x, double y)
static float mean(const float *input, int size)
static double b0(void *priv, double x, double y)
static int bias(int x, int c)