You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1034 lines
42KB

  1. /*
  2. * AAC coefficients encoder
  3. * Copyright (C) 2008-2009 Konstantin Shishkov
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * AAC coefficients encoder
  24. */
  25. /***********************************
  26. * TODOs:
  27. * speedup quantizer selection
  28. * add sane pulse detection
  29. ***********************************/
  30. #include "libavutil/libm.h" // brought forward to work around cygwin header breakage
  31. #include <float.h>
  32. #include "libavutil/mathematics.h"
  33. #include "mathops.h"
  34. #include "avcodec.h"
  35. #include "put_bits.h"
  36. #include "aac.h"
  37. #include "aacenc.h"
  38. #include "aactab.h"
  39. #include "aacenctab.h"
  40. #include "aacenc_utils.h"
  41. #include "aacenc_quantization.h"
  42. #include "aacenc_is.h"
  43. #include "aacenc_tns.h"
  44. #include "aacenc_ltp.h"
  45. #include "aacenc_pred.h"
  46. #include "libavcodec/aaccoder_twoloop.h"
  47. /* Parameter of f(x) = a*(lambda/100), defines the maximum fourier spread
  48. * beyond which no PNS is used (since the SFBs contain tone rather than noise) */
  49. #define NOISE_SPREAD_THRESHOLD 0.9f
  50. /* Parameter of f(x) = a*(100/lambda), defines how much PNS is allowed to
  51. * replace low energy non zero bands */
  52. #define NOISE_LAMBDA_REPLACE 1.948f
  53. #include "libavcodec/aaccoder_trellis.h"
  54. /**
  55. * structure used in optimal codebook search
  56. */
  57. typedef struct BandCodingPath {
  58. int prev_idx; ///< pointer to the previous path point
  59. float cost; ///< path cost
  60. int run;
  61. } BandCodingPath;
  62. /**
  63. * Encode band info for single window group bands.
  64. */
  65. static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce,
  66. int win, int group_len, const float lambda)
  67. {
  68. BandCodingPath path[120][CB_TOT_ALL];
  69. int w, swb, cb, start, size;
  70. int i, j;
  71. const int max_sfb = sce->ics.max_sfb;
  72. const int run_bits = sce->ics.num_windows == 1 ? 5 : 3;
  73. const int run_esc = (1 << run_bits) - 1;
  74. int idx, ppos, count;
  75. int stackrun[120], stackcb[120], stack_len;
  76. float next_minrd = INFINITY;
  77. int next_mincb = 0;
  78. abs_pow34_v(s->scoefs, sce->coeffs, 1024);
  79. start = win*128;
  80. for (cb = 0; cb < CB_TOT_ALL; cb++) {
  81. path[0][cb].cost = 0.0f;
  82. path[0][cb].prev_idx = -1;
  83. path[0][cb].run = 0;
  84. }
  85. for (swb = 0; swb < max_sfb; swb++) {
  86. size = sce->ics.swb_sizes[swb];
  87. if (sce->zeroes[win*16 + swb]) {
  88. for (cb = 0; cb < CB_TOT_ALL; cb++) {
  89. path[swb+1][cb].prev_idx = cb;
  90. path[swb+1][cb].cost = path[swb][cb].cost;
  91. path[swb+1][cb].run = path[swb][cb].run + 1;
  92. }
  93. } else {
  94. float minrd = next_minrd;
  95. int mincb = next_mincb;
  96. next_minrd = INFINITY;
  97. next_mincb = 0;
  98. for (cb = 0; cb < CB_TOT_ALL; cb++) {
  99. float cost_stay_here, cost_get_here;
  100. float rd = 0.0f;
  101. if (cb >= 12 && sce->band_type[win*16+swb] < aac_cb_out_map[cb] ||
  102. cb < aac_cb_in_map[sce->band_type[win*16+swb]] && sce->band_type[win*16+swb] > aac_cb_out_map[cb]) {
  103. path[swb+1][cb].prev_idx = -1;
  104. path[swb+1][cb].cost = INFINITY;
  105. path[swb+1][cb].run = path[swb][cb].run + 1;
  106. continue;
  107. }
  108. for (w = 0; w < group_len; w++) {
  109. FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(win+w)*16+swb];
  110. rd += quantize_band_cost(s, &sce->coeffs[start + w*128],
  111. &s->scoefs[start + w*128], size,
  112. sce->sf_idx[(win+w)*16+swb], aac_cb_out_map[cb],
  113. lambda / band->threshold, INFINITY, NULL, NULL, 0);
  114. }
  115. cost_stay_here = path[swb][cb].cost + rd;
  116. cost_get_here = minrd + rd + run_bits + 4;
  117. if ( run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run]
  118. != run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run+1])
  119. cost_stay_here += run_bits;
  120. if (cost_get_here < cost_stay_here) {
  121. path[swb+1][cb].prev_idx = mincb;
  122. path[swb+1][cb].cost = cost_get_here;
  123. path[swb+1][cb].run = 1;
  124. } else {
  125. path[swb+1][cb].prev_idx = cb;
  126. path[swb+1][cb].cost = cost_stay_here;
  127. path[swb+1][cb].run = path[swb][cb].run + 1;
  128. }
  129. if (path[swb+1][cb].cost < next_minrd) {
  130. next_minrd = path[swb+1][cb].cost;
  131. next_mincb = cb;
  132. }
  133. }
  134. }
  135. start += sce->ics.swb_sizes[swb];
  136. }
  137. //convert resulting path from backward-linked list
  138. stack_len = 0;
  139. idx = 0;
  140. for (cb = 1; cb < CB_TOT_ALL; cb++)
  141. if (path[max_sfb][cb].cost < path[max_sfb][idx].cost)
  142. idx = cb;
  143. ppos = max_sfb;
  144. while (ppos > 0) {
  145. av_assert1(idx >= 0);
  146. cb = idx;
  147. stackrun[stack_len] = path[ppos][cb].run;
  148. stackcb [stack_len] = cb;
  149. idx = path[ppos-path[ppos][cb].run+1][cb].prev_idx;
  150. ppos -= path[ppos][cb].run;
  151. stack_len++;
  152. }
  153. //perform actual band info encoding
  154. start = 0;
  155. for (i = stack_len - 1; i >= 0; i--) {
  156. cb = aac_cb_out_map[stackcb[i]];
  157. put_bits(&s->pb, 4, cb);
  158. count = stackrun[i];
  159. memset(sce->zeroes + win*16 + start, !cb, count);
  160. //XXX: memset when band_type is also uint8_t
  161. for (j = 0; j < count; j++) {
  162. sce->band_type[win*16 + start] = cb;
  163. start++;
  164. }
  165. while (count >= run_esc) {
  166. put_bits(&s->pb, run_bits, run_esc);
  167. count -= run_esc;
  168. }
  169. put_bits(&s->pb, run_bits, count);
  170. }
  171. }
  172. typedef struct TrellisPath {
  173. float cost;
  174. int prev;
  175. } TrellisPath;
  176. #define TRELLIS_STAGES 121
  177. #define TRELLIS_STATES (SCALE_MAX_DIFF+1)
  178. static void set_special_band_scalefactors(AACEncContext *s, SingleChannelElement *sce)
  179. {
  180. int w, g, start = 0;
  181. int minscaler_n = sce->sf_idx[0], minscaler_i = sce->sf_idx[0];
  182. int bands = 0;
  183. for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
  184. start = 0;
  185. for (g = 0; g < sce->ics.num_swb; g++) {
  186. if (sce->band_type[w*16+g] == INTENSITY_BT || sce->band_type[w*16+g] == INTENSITY_BT2) {
  187. sce->sf_idx[w*16+g] = av_clip(roundf(log2f(sce->is_ener[w*16+g])*2), -155, 100);
  188. minscaler_i = FFMIN(minscaler_i, sce->sf_idx[w*16+g]);
  189. bands++;
  190. } else if (sce->band_type[w*16+g] == NOISE_BT) {
  191. sce->sf_idx[w*16+g] = av_clip(3+ceilf(log2f(sce->pns_ener[w*16+g])*2), -100, 155);
  192. minscaler_n = FFMIN(minscaler_n, sce->sf_idx[w*16+g]);
  193. bands++;
  194. }
  195. start += sce->ics.swb_sizes[g];
  196. }
  197. }
  198. if (!bands)
  199. return;
  200. /* Clip the scalefactor indices */
  201. for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
  202. for (g = 0; g < sce->ics.num_swb; g++) {
  203. if (sce->band_type[w*16+g] == INTENSITY_BT || sce->band_type[w*16+g] == INTENSITY_BT2) {
  204. sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler_i, minscaler_i + SCALE_MAX_DIFF);
  205. } else if (sce->band_type[w*16+g] == NOISE_BT) {
  206. sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler_n, minscaler_n + SCALE_MAX_DIFF);
  207. }
  208. }
  209. }
  210. }
  211. static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s,
  212. SingleChannelElement *sce,
  213. const float lambda)
  214. {
  215. int q, w, w2, g, start = 0;
  216. int i, j;
  217. int idx;
  218. TrellisPath paths[TRELLIS_STAGES][TRELLIS_STATES];
  219. int bandaddr[TRELLIS_STAGES];
  220. int minq;
  221. float mincost;
  222. float q0f = FLT_MAX, q1f = 0.0f, qnrgf = 0.0f;
  223. int q0, q1, qcnt = 0;
  224. for (i = 0; i < 1024; i++) {
  225. float t = fabsf(sce->coeffs[i]);
  226. if (t > 0.0f) {
  227. q0f = FFMIN(q0f, t);
  228. q1f = FFMAX(q1f, t);
  229. qnrgf += t*t;
  230. qcnt++;
  231. }
  232. }
  233. if (!qcnt) {
  234. memset(sce->sf_idx, 0, sizeof(sce->sf_idx));
  235. memset(sce->zeroes, 1, sizeof(sce->zeroes));
  236. return;
  237. }
  238. //minimum scalefactor index is when minimum nonzero coefficient after quantizing is not clipped
  239. q0 = av_clip(coef2minsf(q0f), 0, SCALE_MAX_POS-1);
  240. //maximum scalefactor index is when maximum coefficient after quantizing is still not zero
  241. q1 = av_clip(coef2maxsf(q1f), 1, SCALE_MAX_POS);
  242. if (q1 - q0 > 60) {
  243. int q0low = q0;
  244. int q1high = q1;
  245. //minimum scalefactor index is when maximum nonzero coefficient after quantizing is not clipped
  246. int qnrg = av_clip_uint8(log2f(sqrtf(qnrgf/qcnt))*4 - 31 + SCALE_ONE_POS - SCALE_DIV_512);
  247. q1 = qnrg + 30;
  248. q0 = qnrg - 30;
  249. if (q0 < q0low) {
  250. q1 += q0low - q0;
  251. q0 = q0low;
  252. } else if (q1 > q1high) {
  253. q0 -= q1 - q1high;
  254. q1 = q1high;
  255. }
  256. }
  257. // q0 == q1 isn't really a legal situation
  258. if (q0 == q1) {
  259. // the following is indirect but guarantees q1 != q0 && q1 near q0
  260. q1 = av_clip(q0+1, 1, SCALE_MAX_POS);
  261. q0 = av_clip(q1-1, 0, SCALE_MAX_POS - 1);
  262. }
  263. for (i = 0; i < TRELLIS_STATES; i++) {
  264. paths[0][i].cost = 0.0f;
  265. paths[0][i].prev = -1;
  266. }
  267. for (j = 1; j < TRELLIS_STAGES; j++) {
  268. for (i = 0; i < TRELLIS_STATES; i++) {
  269. paths[j][i].cost = INFINITY;
  270. paths[j][i].prev = -2;
  271. }
  272. }
  273. idx = 1;
  274. abs_pow34_v(s->scoefs, sce->coeffs, 1024);
  275. for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
  276. start = w*128;
  277. for (g = 0; g < sce->ics.num_swb; g++) {
  278. const float *coefs = &sce->coeffs[start];
  279. float qmin, qmax;
  280. int nz = 0;
  281. bandaddr[idx] = w * 16 + g;
  282. qmin = INT_MAX;
  283. qmax = 0.0f;
  284. for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
  285. FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
  286. if (band->energy <= band->threshold || band->threshold == 0.0f) {
  287. sce->zeroes[(w+w2)*16+g] = 1;
  288. continue;
  289. }
  290. sce->zeroes[(w+w2)*16+g] = 0;
  291. nz = 1;
  292. for (i = 0; i < sce->ics.swb_sizes[g]; i++) {
  293. float t = fabsf(coefs[w2*128+i]);
  294. if (t > 0.0f)
  295. qmin = FFMIN(qmin, t);
  296. qmax = FFMAX(qmax, t);
  297. }
  298. }
  299. if (nz) {
  300. int minscale, maxscale;
  301. float minrd = INFINITY;
  302. float maxval;
  303. //minimum scalefactor index is when minimum nonzero coefficient after quantizing is not clipped
  304. minscale = coef2minsf(qmin);
  305. //maximum scalefactor index is when maximum coefficient after quantizing is still not zero
  306. maxscale = coef2maxsf(qmax);
  307. minscale = av_clip(minscale - q0, 0, TRELLIS_STATES - 1);
  308. maxscale = av_clip(maxscale - q0, 0, TRELLIS_STATES);
  309. if (minscale == maxscale) {
  310. maxscale = av_clip(minscale+1, 1, TRELLIS_STATES);
  311. minscale = av_clip(maxscale-1, 0, TRELLIS_STATES - 1);
  312. }
  313. maxval = find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], s->scoefs+start);
  314. for (q = minscale; q < maxscale; q++) {
  315. float dist = 0;
  316. int cb = find_min_book(maxval, sce->sf_idx[w*16+g]);
  317. for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
  318. FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
  319. dist += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g],
  320. q + q0, cb, lambda / band->threshold, INFINITY, NULL, NULL, 0);
  321. }
  322. minrd = FFMIN(minrd, dist);
  323. for (i = 0; i < q1 - q0; i++) {
  324. float cost;
  325. cost = paths[idx - 1][i].cost + dist
  326. + ff_aac_scalefactor_bits[q - i + SCALE_DIFF_ZERO];
  327. if (cost < paths[idx][q].cost) {
  328. paths[idx][q].cost = cost;
  329. paths[idx][q].prev = i;
  330. }
  331. }
  332. }
  333. } else {
  334. for (q = 0; q < q1 - q0; q++) {
  335. paths[idx][q].cost = paths[idx - 1][q].cost + 1;
  336. paths[idx][q].prev = q;
  337. }
  338. }
  339. sce->zeroes[w*16+g] = !nz;
  340. start += sce->ics.swb_sizes[g];
  341. idx++;
  342. }
  343. }
  344. idx--;
  345. mincost = paths[idx][0].cost;
  346. minq = 0;
  347. for (i = 1; i < TRELLIS_STATES; i++) {
  348. if (paths[idx][i].cost < mincost) {
  349. mincost = paths[idx][i].cost;
  350. minq = i;
  351. }
  352. }
  353. while (idx) {
  354. sce->sf_idx[bandaddr[idx]] = minq + q0;
  355. minq = FFMAX(paths[idx][minq].prev, 0);
  356. idx--;
  357. }
  358. //set the same quantizers inside window groups
  359. for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w])
  360. for (g = 0; g < sce->ics.num_swb; g++)
  361. for (w2 = 1; w2 < sce->ics.group_len[w]; w2++)
  362. sce->sf_idx[(w+w2)*16+g] = sce->sf_idx[w*16+g];
  363. }
  364. static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s,
  365. SingleChannelElement *sce,
  366. const float lambda)
  367. {
  368. int start = 0, i, w, w2, g;
  369. float uplim[128], maxq[128];
  370. int minq, maxsf;
  371. float distfact = ((sce->ics.num_windows > 1) ? 85.80 : 147.84) / lambda;
  372. int last = 0, lastband = 0, curband = 0;
  373. float avg_energy = 0.0;
  374. if (sce->ics.num_windows == 1) {
  375. start = 0;
  376. for (i = 0; i < 1024; i++) {
  377. if (i - start >= sce->ics.swb_sizes[curband]) {
  378. start += sce->ics.swb_sizes[curband];
  379. curband++;
  380. }
  381. if (sce->coeffs[i]) {
  382. avg_energy += sce->coeffs[i] * sce->coeffs[i];
  383. last = i;
  384. lastband = curband;
  385. }
  386. }
  387. } else {
  388. for (w = 0; w < 8; w++) {
  389. const float *coeffs = &sce->coeffs[w*128];
  390. curband = start = 0;
  391. for (i = 0; i < 128; i++) {
  392. if (i - start >= sce->ics.swb_sizes[curband]) {
  393. start += sce->ics.swb_sizes[curband];
  394. curband++;
  395. }
  396. if (coeffs[i]) {
  397. avg_energy += coeffs[i] * coeffs[i];
  398. last = FFMAX(last, i);
  399. lastband = FFMAX(lastband, curband);
  400. }
  401. }
  402. }
  403. }
  404. last++;
  405. avg_energy /= last;
  406. if (avg_energy == 0.0f) {
  407. for (i = 0; i < FF_ARRAY_ELEMS(sce->sf_idx); i++)
  408. sce->sf_idx[i] = SCALE_ONE_POS;
  409. return;
  410. }
  411. for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
  412. start = w*128;
  413. for (g = 0; g < sce->ics.num_swb; g++) {
  414. float *coefs = &sce->coeffs[start];
  415. const int size = sce->ics.swb_sizes[g];
  416. int start2 = start, end2 = start + size, peakpos = start;
  417. float maxval = -1, thr = 0.0f, t;
  418. maxq[w*16+g] = 0.0f;
  419. if (g > lastband) {
  420. maxq[w*16+g] = 0.0f;
  421. start += size;
  422. for (w2 = 0; w2 < sce->ics.group_len[w]; w2++)
  423. memset(coefs + w2*128, 0, sizeof(coefs[0])*size);
  424. continue;
  425. }
  426. for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
  427. for (i = 0; i < size; i++) {
  428. float t = coefs[w2*128+i]*coefs[w2*128+i];
  429. maxq[w*16+g] = FFMAX(maxq[w*16+g], fabsf(coefs[w2*128 + i]));
  430. thr += t;
  431. if (sce->ics.num_windows == 1 && maxval < t) {
  432. maxval = t;
  433. peakpos = start+i;
  434. }
  435. }
  436. }
  437. if (sce->ics.num_windows == 1) {
  438. start2 = FFMAX(peakpos - 2, start2);
  439. end2 = FFMIN(peakpos + 3, end2);
  440. } else {
  441. start2 -= start;
  442. end2 -= start;
  443. }
  444. start += size;
  445. thr = pow(thr / (avg_energy * (end2 - start2)), 0.3 + 0.1*(lastband - g) / lastband);
  446. t = 1.0 - (1.0 * start2 / last);
  447. uplim[w*16+g] = distfact / (1.4 * thr + t*t*t + 0.075);
  448. }
  449. }
  450. memset(sce->sf_idx, 0, sizeof(sce->sf_idx));
  451. abs_pow34_v(s->scoefs, sce->coeffs, 1024);
  452. for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
  453. start = w*128;
  454. for (g = 0; g < sce->ics.num_swb; g++) {
  455. const float *coefs = &sce->coeffs[start];
  456. const float *scaled = &s->scoefs[start];
  457. const int size = sce->ics.swb_sizes[g];
  458. int scf, prev_scf, step;
  459. int min_scf = -1, max_scf = 256;
  460. float curdiff;
  461. if (maxq[w*16+g] < 21.544) {
  462. sce->zeroes[w*16+g] = 1;
  463. start += size;
  464. continue;
  465. }
  466. sce->zeroes[w*16+g] = 0;
  467. scf = prev_scf = av_clip(SCALE_ONE_POS - SCALE_DIV_512 - log2f(1/maxq[w*16+g])*16/3, 60, 218);
  468. for (;;) {
  469. float dist = 0.0f;
  470. int quant_max;
  471. for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
  472. int b;
  473. dist += quantize_band_cost(s, coefs + w2*128,
  474. scaled + w2*128,
  475. sce->ics.swb_sizes[g],
  476. scf,
  477. ESC_BT,
  478. lambda,
  479. INFINITY,
  480. &b, NULL,
  481. 0);
  482. dist -= b;
  483. }
  484. dist *= 1.0f / 512.0f / lambda;
  485. quant_max = quant(maxq[w*16+g], ff_aac_pow2sf_tab[POW_SF2_ZERO - scf + SCALE_ONE_POS - SCALE_DIV_512], ROUND_STANDARD);
  486. if (quant_max >= 8191) { // too much, return to the previous quantizer
  487. sce->sf_idx[w*16+g] = prev_scf;
  488. break;
  489. }
  490. prev_scf = scf;
  491. curdiff = fabsf(dist - uplim[w*16+g]);
  492. if (curdiff <= 1.0f)
  493. step = 0;
  494. else
  495. step = log2f(curdiff);
  496. if (dist > uplim[w*16+g])
  497. step = -step;
  498. scf += step;
  499. scf = av_clip_uint8(scf);
  500. step = scf - prev_scf;
  501. if (FFABS(step) <= 1 || (step > 0 && scf >= max_scf) || (step < 0 && scf <= min_scf)) {
  502. sce->sf_idx[w*16+g] = av_clip(scf, min_scf, max_scf);
  503. break;
  504. }
  505. if (step > 0)
  506. min_scf = prev_scf;
  507. else
  508. max_scf = prev_scf;
  509. }
  510. start += size;
  511. }
  512. }
  513. minq = sce->sf_idx[0] ? sce->sf_idx[0] : INT_MAX;
  514. for (i = 1; i < 128; i++) {
  515. if (!sce->sf_idx[i])
  516. sce->sf_idx[i] = sce->sf_idx[i-1];
  517. else
  518. minq = FFMIN(minq, sce->sf_idx[i]);
  519. }
  520. if (minq == INT_MAX)
  521. minq = 0;
  522. minq = FFMIN(minq, SCALE_MAX_POS);
  523. maxsf = FFMIN(minq + SCALE_MAX_DIFF, SCALE_MAX_POS);
  524. for (i = 126; i >= 0; i--) {
  525. if (!sce->sf_idx[i])
  526. sce->sf_idx[i] = sce->sf_idx[i+1];
  527. sce->sf_idx[i] = av_clip(sce->sf_idx[i], minq, maxsf);
  528. }
  529. }
  530. static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s,
  531. SingleChannelElement *sce,
  532. const float lambda)
  533. {
  534. int i, w, w2, g;
  535. int minq = 255;
  536. memset(sce->sf_idx, 0, sizeof(sce->sf_idx));
  537. for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
  538. for (g = 0; g < sce->ics.num_swb; g++) {
  539. for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
  540. FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
  541. if (band->energy <= band->threshold) {
  542. sce->sf_idx[(w+w2)*16+g] = 218;
  543. sce->zeroes[(w+w2)*16+g] = 1;
  544. } else {
  545. sce->sf_idx[(w+w2)*16+g] = av_clip(SCALE_ONE_POS - SCALE_DIV_512 + log2f(band->threshold), 80, 218);
  546. sce->zeroes[(w+w2)*16+g] = 0;
  547. }
  548. minq = FFMIN(minq, sce->sf_idx[(w+w2)*16+g]);
  549. }
  550. }
  551. }
  552. for (i = 0; i < 128; i++) {
  553. sce->sf_idx[i] = 140;
  554. //av_clip(sce->sf_idx[i], minq, minq + SCALE_MAX_DIFF - 1);
  555. }
  556. //set the same quantizers inside window groups
  557. for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w])
  558. for (g = 0; g < sce->ics.num_swb; g++)
  559. for (w2 = 1; w2 < sce->ics.group_len[w]; w2++)
  560. sce->sf_idx[(w+w2)*16+g] = sce->sf_idx[w*16+g];
  561. }
  562. static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
  563. {
  564. FFPsyBand *band;
  565. int w, g, w2, i;
  566. int wlen = 1024 / sce->ics.num_windows;
  567. int bandwidth, cutoff;
  568. float *PNS = &s->scoefs[0*128], *PNS34 = &s->scoefs[1*128];
  569. float *NOR34 = &s->scoefs[3*128];
  570. uint8_t nextband[128];
  571. const float lambda = s->lambda;
  572. const float freq_mult = avctx->sample_rate*0.5f/wlen;
  573. const float thr_mult = NOISE_LAMBDA_REPLACE*(100.0f/lambda);
  574. const float spread_threshold = FFMIN(0.75f, NOISE_SPREAD_THRESHOLD*FFMAX(0.5f, lambda/100.f));
  575. const float dist_bias = av_clipf(4.f * 120 / lambda, 0.25f, 4.0f);
  576. const float pns_transient_energy_r = FFMIN(0.7f, lambda / 140.f);
  577. int refbits = avctx->bit_rate * 1024.0 / avctx->sample_rate
  578. / ((avctx->flags & CODEC_FLAG_QSCALE) ? 2.0f : avctx->channels)
  579. * (lambda / 120.f);
  580. /** Keep this in sync with twoloop's cutoff selection */
  581. float rate_bandwidth_multiplier = 1.5f;
  582. int prev = -1000, prev_sf = -1;
  583. int frame_bit_rate = (avctx->flags & CODEC_FLAG_QSCALE)
  584. ? (refbits * rate_bandwidth_multiplier * avctx->sample_rate / 1024)
  585. : (avctx->bit_rate / avctx->channels);
  586. frame_bit_rate *= 1.15f;
  587. if (avctx->cutoff > 0) {
  588. bandwidth = avctx->cutoff;
  589. } else {
  590. bandwidth = FFMAX(3000, AAC_CUTOFF_FROM_BITRATE(frame_bit_rate, 1, avctx->sample_rate));
  591. }
  592. cutoff = bandwidth * 2 * wlen / avctx->sample_rate;
  593. memcpy(sce->band_alt, sce->band_type, sizeof(sce->band_type));
  594. ff_init_nextband_map(sce, nextband);
  595. for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
  596. int wstart = w*128;
  597. for (g = 0; g < sce->ics.num_swb; g++) {
  598. int noise_sfi;
  599. float dist1 = 0.0f, dist2 = 0.0f, noise_amp;
  600. float pns_energy = 0.0f, pns_tgt_energy, energy_ratio, dist_thresh;
  601. float sfb_energy = 0.0f, threshold = 0.0f, spread = 2.0f;
  602. float min_energy = -1.0f, max_energy = 0.0f;
  603. const int start = wstart+sce->ics.swb_offset[g];
  604. const float freq = (start-wstart)*freq_mult;
  605. const float freq_boost = FFMAX(0.88f*freq/NOISE_LOW_LIMIT, 1.0f);
  606. if (freq < NOISE_LOW_LIMIT || (start-wstart) >= cutoff)
  607. continue;
  608. for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
  609. band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
  610. sfb_energy += band->energy;
  611. spread = FFMIN(spread, band->spread);
  612. threshold += band->threshold;
  613. if (!w2) {
  614. min_energy = max_energy = band->energy;
  615. } else {
  616. min_energy = FFMIN(min_energy, band->energy);
  617. max_energy = FFMAX(max_energy, band->energy);
  618. }
  619. }
  620. /* Ramps down at ~8000Hz and loosens the dist threshold */
  621. dist_thresh = av_clipf(2.5f*NOISE_LOW_LIMIT/freq, 0.5f, 2.5f) * dist_bias;
  622. /* PNS is acceptable when all of these are true:
  623. * 1. high spread energy (noise-like band)
  624. * 2. near-threshold energy (high PE means the random nature of PNS content will be noticed)
  625. * 3. on short window groups, all windows have similar energy (variations in energy would be destroyed by PNS)
  626. *
  627. * At this stage, point 2 is relaxed for zeroed bands near the noise threshold (hole avoidance is more important)
  628. */
  629. if ((!sce->zeroes[w*16+g] && !ff_sfdelta_can_remove_band(sce, nextband, prev_sf, w*16+g)) ||
  630. ((sce->zeroes[w*16+g] || !sce->band_alt[w*16+g]) && sfb_energy < threshold*sqrtf(1.0f/freq_boost)) || spread < spread_threshold ||
  631. (!sce->zeroes[w*16+g] && sce->band_alt[w*16+g] && sfb_energy > threshold*thr_mult*freq_boost) ||
  632. min_energy < pns_transient_energy_r * max_energy ) {
  633. sce->pns_ener[w*16+g] = sfb_energy;
  634. if (!sce->zeroes[w*16+g])
  635. prev_sf = sce->sf_idx[w*16+g];
  636. continue;
  637. }
  638. pns_tgt_energy = sfb_energy*FFMIN(1.0f, spread*spread);
  639. noise_sfi = av_clip(roundf(log2f(pns_tgt_energy)*2), -100, 155); /* Quantize */
  640. noise_amp = -ff_aac_pow2sf_tab[noise_sfi + POW_SF2_ZERO]; /* Dequantize */
  641. if (prev != -1000) {
  642. int noise_sfdiff = noise_sfi - prev + SCALE_DIFF_ZERO;
  643. if (noise_sfdiff < 0 || noise_sfdiff > 2*SCALE_MAX_DIFF) {
  644. if (!sce->zeroes[w*16+g])
  645. prev_sf = sce->sf_idx[w*16+g];
  646. continue;
  647. }
  648. }
  649. for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
  650. float band_energy, scale, pns_senergy;
  651. const int start_c = (w+w2)*128+sce->ics.swb_offset[g];
  652. band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
  653. for (i = 0; i < sce->ics.swb_sizes[g]; i+=2) {
  654. double rnd[2];
  655. av_bmg_get(&s->lfg, rnd);
  656. PNS[i+0] = (float)rnd[0];
  657. PNS[i+1] = (float)rnd[1];
  658. }
  659. band_energy = s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]);
  660. scale = noise_amp/sqrtf(band_energy);
  661. s->fdsp->vector_fmul_scalar(PNS, PNS, scale, sce->ics.swb_sizes[g]);
  662. pns_senergy = s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]);
  663. pns_energy += pns_senergy;
  664. abs_pow34_v(NOR34, &sce->coeffs[start_c], sce->ics.swb_sizes[g]);
  665. abs_pow34_v(PNS34, PNS, sce->ics.swb_sizes[g]);
  666. dist1 += quantize_band_cost(s, &sce->coeffs[start_c],
  667. NOR34,
  668. sce->ics.swb_sizes[g],
  669. sce->sf_idx[(w+w2)*16+g],
  670. sce->band_alt[(w+w2)*16+g],
  671. lambda/band->threshold, INFINITY, NULL, NULL, 0);
  672. /* Estimate rd on average as 5 bits for SF, 4 for the CB, plus spread energy * lambda/thr */
  673. dist2 += band->energy/(band->spread*band->spread)*lambda*dist_thresh/band->threshold;
  674. }
  675. if (g && sce->band_type[w*16+g-1] == NOISE_BT) {
  676. dist2 += 5;
  677. } else {
  678. dist2 += 9;
  679. }
  680. energy_ratio = pns_tgt_energy/pns_energy; /* Compensates for quantization error */
  681. sce->pns_ener[w*16+g] = energy_ratio*pns_tgt_energy;
  682. if (sce->zeroes[w*16+g] || !sce->band_alt[w*16+g] || (energy_ratio > 0.85f && energy_ratio < 1.25f && dist2 < dist1)) {
  683. sce->band_type[w*16+g] = NOISE_BT;
  684. sce->zeroes[w*16+g] = 0;
  685. prev = noise_sfi;
  686. }
  687. if (!sce->zeroes[w*16+g])
  688. prev_sf = sce->sf_idx[w*16+g];
  689. }
  690. }
  691. }
  692. static void mark_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
  693. {
  694. FFPsyBand *band;
  695. int w, g, w2;
  696. int wlen = 1024 / sce->ics.num_windows;
  697. int bandwidth, cutoff;
  698. const float lambda = s->lambda;
  699. const float freq_mult = avctx->sample_rate*0.5f/wlen;
  700. const float spread_threshold = FFMIN(0.75f, NOISE_SPREAD_THRESHOLD*FFMAX(0.5f, lambda/100.f));
  701. const float pns_transient_energy_r = FFMIN(0.7f, lambda / 140.f);
  702. int refbits = avctx->bit_rate * 1024.0 / avctx->sample_rate
  703. / ((avctx->flags & CODEC_FLAG_QSCALE) ? 2.0f : avctx->channels)
  704. * (lambda / 120.f);
  705. /** Keep this in sync with twoloop's cutoff selection */
  706. float rate_bandwidth_multiplier = 1.5f;
  707. int frame_bit_rate = (avctx->flags & CODEC_FLAG_QSCALE)
  708. ? (refbits * rate_bandwidth_multiplier * avctx->sample_rate / 1024)
  709. : (avctx->bit_rate / avctx->channels);
  710. frame_bit_rate *= 1.15f;
  711. if (avctx->cutoff > 0) {
  712. bandwidth = avctx->cutoff;
  713. } else {
  714. bandwidth = FFMAX(3000, AAC_CUTOFF_FROM_BITRATE(frame_bit_rate, 1, avctx->sample_rate));
  715. }
  716. cutoff = bandwidth * 2 * wlen / avctx->sample_rate;
  717. memcpy(sce->band_alt, sce->band_type, sizeof(sce->band_type));
  718. for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
  719. for (g = 0; g < sce->ics.num_swb; g++) {
  720. float sfb_energy = 0.0f, threshold = 0.0f, spread = 2.0f;
  721. float min_energy = -1.0f, max_energy = 0.0f;
  722. const int start = sce->ics.swb_offset[g];
  723. const float freq = start*freq_mult;
  724. const float freq_boost = FFMAX(0.88f*freq/NOISE_LOW_LIMIT, 1.0f);
  725. if (freq < NOISE_LOW_LIMIT || start >= cutoff) {
  726. sce->can_pns[w*16+g] = 0;
  727. continue;
  728. }
  729. for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
  730. band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
  731. sfb_energy += band->energy;
  732. spread = FFMIN(spread, band->spread);
  733. threshold += band->threshold;
  734. if (!w2) {
  735. min_energy = max_energy = band->energy;
  736. } else {
  737. min_energy = FFMIN(min_energy, band->energy);
  738. max_energy = FFMAX(max_energy, band->energy);
  739. }
  740. }
  741. /* PNS is acceptable when all of these are true:
  742. * 1. high spread energy (noise-like band)
  743. * 2. near-threshold energy (high PE means the random nature of PNS content will be noticed)
  744. * 3. on short window groups, all windows have similar energy (variations in energy would be destroyed by PNS)
  745. */
  746. sce->pns_ener[w*16+g] = sfb_energy;
  747. if (sfb_energy < threshold*sqrtf(1.5f/freq_boost) || spread < spread_threshold || min_energy < pns_transient_energy_r * max_energy) {
  748. sce->can_pns[w*16+g] = 0;
  749. } else {
  750. sce->can_pns[w*16+g] = 1;
  751. }
  752. }
  753. }
  754. }
  755. static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
  756. {
  757. int start = 0, i, w, w2, g, sid_sf_boost, prev_mid, prev_side;
  758. uint8_t nextband0[128], nextband1[128];
  759. float M[128], S[128];
  760. float *L34 = s->scoefs, *R34 = s->scoefs + 128, *M34 = s->scoefs + 128*2, *S34 = s->scoefs + 128*3;
  761. const float lambda = s->lambda;
  762. const float mslambda = FFMIN(1.0f, lambda / 120.f);
  763. SingleChannelElement *sce0 = &cpe->ch[0];
  764. SingleChannelElement *sce1 = &cpe->ch[1];
  765. if (!cpe->common_window)
  766. return;
  767. /** Scout out next nonzero bands */
  768. ff_init_nextband_map(sce0, nextband0);
  769. ff_init_nextband_map(sce1, nextband1);
  770. prev_mid = sce0->sf_idx[0];
  771. prev_side = sce1->sf_idx[0];
  772. for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) {
  773. start = 0;
  774. for (g = 0; g < sce0->ics.num_swb; g++) {
  775. float bmax = bval2bmax(g * 17.0f / sce0->ics.num_swb) / 0.0045f;
  776. cpe->ms_mask[w*16+g] = 0;
  777. if (!sce0->zeroes[w*16+g] && !sce1->zeroes[w*16+g]) {
  778. float Mmax = 0.0f, Smax = 0.0f;
  779. /* Must compute mid/side SF and book for the whole window group */
  780. for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
  781. for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
  782. M[i] = (sce0->coeffs[start+(w+w2)*128+i]
  783. + sce1->coeffs[start+(w+w2)*128+i]) * 0.5;
  784. S[i] = M[i]
  785. - sce1->coeffs[start+(w+w2)*128+i];
  786. }
  787. abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]);
  788. abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]);
  789. for (i = 0; i < sce0->ics.swb_sizes[g]; i++ ) {
  790. Mmax = FFMAX(Mmax, M34[i]);
  791. Smax = FFMAX(Smax, S34[i]);
  792. }
  793. }
  794. for (sid_sf_boost = 0; sid_sf_boost < 4; sid_sf_boost++) {
  795. float dist1 = 0.0f, dist2 = 0.0f;
  796. int B0 = 0, B1 = 0;
  797. int minidx;
  798. int mididx, sididx;
  799. int midcb, sidcb;
  800. minidx = FFMIN(sce0->sf_idx[w*16+g], sce1->sf_idx[w*16+g]);
  801. mididx = av_clip(minidx, 0, SCALE_MAX_POS - SCALE_DIV_512);
  802. sididx = av_clip(minidx - sid_sf_boost * 3, 0, SCALE_MAX_POS - SCALE_DIV_512);
  803. if (!cpe->is_mask[w*16+g] && sce0->band_type[w*16+g] != NOISE_BT && sce1->band_type[w*16+g] != NOISE_BT
  804. && ( !ff_sfdelta_can_replace(sce0, nextband0, prev_mid, mididx, w*16+g)
  805. || !ff_sfdelta_can_replace(sce1, nextband1, prev_side, sididx, w*16+g))) {
  806. /* scalefactor range violation, bad stuff, will decrease quality unacceptably */
  807. continue;
  808. }
  809. midcb = find_min_book(Mmax, mididx);
  810. sidcb = find_min_book(Smax, sididx);
  811. /* No CB can be zero */
  812. midcb = FFMAX(1,midcb);
  813. sidcb = FFMAX(1,sidcb);
  814. for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
  815. FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g];
  816. FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g];
  817. float minthr = FFMIN(band0->threshold, band1->threshold);
  818. int b1,b2,b3,b4;
  819. for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
  820. M[i] = (sce0->coeffs[start+(w+w2)*128+i]
  821. + sce1->coeffs[start+(w+w2)*128+i]) * 0.5;
  822. S[i] = M[i]
  823. - sce1->coeffs[start+(w+w2)*128+i];
  824. }
  825. abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
  826. abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
  827. abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]);
  828. abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]);
  829. dist1 += quantize_band_cost(s, &sce0->coeffs[start + (w+w2)*128],
  830. L34,
  831. sce0->ics.swb_sizes[g],
  832. sce0->sf_idx[(w+w2)*16+g],
  833. sce0->band_type[(w+w2)*16+g],
  834. lambda / band0->threshold, INFINITY, &b1, NULL, 0);
  835. dist1 += quantize_band_cost(s, &sce1->coeffs[start + (w+w2)*128],
  836. R34,
  837. sce1->ics.swb_sizes[g],
  838. sce1->sf_idx[(w+w2)*16+g],
  839. sce1->band_type[(w+w2)*16+g],
  840. lambda / band1->threshold, INFINITY, &b2, NULL, 0);
  841. dist2 += quantize_band_cost(s, M,
  842. M34,
  843. sce0->ics.swb_sizes[g],
  844. sce0->sf_idx[(w+w2)*16+g],
  845. sce0->band_type[(w+w2)*16+g],
  846. lambda / minthr, INFINITY, &b3, NULL, 0);
  847. dist2 += quantize_band_cost(s, S,
  848. S34,
  849. sce1->ics.swb_sizes[g],
  850. sce1->sf_idx[(w+w2)*16+g],
  851. sce1->band_type[(w+w2)*16+g],
  852. mslambda / (minthr * bmax), INFINITY, &b4, NULL, 0);
  853. B0 += b1+b2;
  854. B1 += b3+b4;
  855. dist1 -= B0;
  856. dist2 -= B1;
  857. }
  858. cpe->ms_mask[w*16+g] = dist2 <= dist1 && B1 < B0;
  859. if (cpe->ms_mask[w*16+g]) {
  860. /* Setting the M/S mask is useful with I/S or PNS, but only the flag */
  861. if (!cpe->is_mask[w*16+g] && sce0->band_type[w*16+g] != NOISE_BT && sce1->band_type[w*16+g] != NOISE_BT) {
  862. sce0->sf_idx[w*16+g] = mididx;
  863. sce1->sf_idx[w*16+g] = sididx;
  864. sce0->band_type[w*16+g] = midcb;
  865. sce1->band_type[w*16+g] = sidcb;
  866. }
  867. break;
  868. } else if (B1 > B0) {
  869. /* More boost won't fix this */
  870. break;
  871. }
  872. }
  873. }
  874. if (!sce0->zeroes[w*16+g] && sce0->band_type[w*16+g] < RESERVED_BT)
  875. prev_mid = sce0->sf_idx[w*16+g];
  876. if (!sce1->zeroes[w*16+g] && !cpe->is_mask[w*16+g] && sce1->band_type[w*16+g] < RESERVED_BT)
  877. prev_side = sce1->sf_idx[w*16+g];
  878. start += sce0->ics.swb_sizes[g];
  879. }
  880. }
  881. }
  882. AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB] = {
  883. [AAC_CODER_FAAC] = {
  884. search_for_quantizers_faac,
  885. encode_window_bands_info,
  886. quantize_and_encode_band,
  887. ff_aac_encode_tns_info,
  888. ff_aac_encode_ltp_info,
  889. ff_aac_encode_main_pred,
  890. ff_aac_adjust_common_pred,
  891. ff_aac_adjust_common_ltp,
  892. ff_aac_apply_main_pred,
  893. ff_aac_apply_tns,
  894. ff_aac_update_ltp,
  895. ff_aac_ltp_insert_new_frame,
  896. set_special_band_scalefactors,
  897. search_for_pns,
  898. mark_pns,
  899. ff_aac_search_for_tns,
  900. ff_aac_search_for_ltp,
  901. search_for_ms,
  902. ff_aac_search_for_is,
  903. ff_aac_search_for_pred,
  904. },
  905. [AAC_CODER_ANMR] = {
  906. search_for_quantizers_anmr,
  907. encode_window_bands_info,
  908. quantize_and_encode_band,
  909. ff_aac_encode_tns_info,
  910. ff_aac_encode_ltp_info,
  911. ff_aac_encode_main_pred,
  912. ff_aac_adjust_common_pred,
  913. ff_aac_adjust_common_ltp,
  914. ff_aac_apply_main_pred,
  915. ff_aac_apply_tns,
  916. ff_aac_update_ltp,
  917. ff_aac_ltp_insert_new_frame,
  918. set_special_band_scalefactors,
  919. search_for_pns,
  920. mark_pns,
  921. ff_aac_search_for_tns,
  922. ff_aac_search_for_ltp,
  923. search_for_ms,
  924. ff_aac_search_for_is,
  925. ff_aac_search_for_pred,
  926. },
  927. [AAC_CODER_TWOLOOP] = {
  928. search_for_quantizers_twoloop,
  929. codebook_trellis_rate,
  930. quantize_and_encode_band,
  931. ff_aac_encode_tns_info,
  932. ff_aac_encode_ltp_info,
  933. ff_aac_encode_main_pred,
  934. ff_aac_adjust_common_pred,
  935. ff_aac_adjust_common_ltp,
  936. ff_aac_apply_main_pred,
  937. ff_aac_apply_tns,
  938. ff_aac_update_ltp,
  939. ff_aac_ltp_insert_new_frame,
  940. set_special_band_scalefactors,
  941. search_for_pns,
  942. mark_pns,
  943. ff_aac_search_for_tns,
  944. ff_aac_search_for_ltp,
  945. search_for_ms,
  946. ff_aac_search_for_is,
  947. ff_aac_search_for_pred,
  948. },
  949. [AAC_CODER_FAST] = {
  950. search_for_quantizers_fast,
  951. encode_window_bands_info,
  952. quantize_and_encode_band,
  953. ff_aac_encode_tns_info,
  954. ff_aac_encode_ltp_info,
  955. ff_aac_encode_main_pred,
  956. ff_aac_adjust_common_pred,
  957. ff_aac_adjust_common_ltp,
  958. ff_aac_apply_main_pred,
  959. ff_aac_apply_tns,
  960. ff_aac_update_ltp,
  961. ff_aac_ltp_insert_new_frame,
  962. set_special_band_scalefactors,
  963. search_for_pns,
  964. mark_pns,
  965. ff_aac_search_for_tns,
  966. ff_aac_search_for_ltp,
  967. search_for_ms,
  968. ff_aac_search_for_is,
  969. ff_aac_search_for_pred,
  970. },
  971. };