Has been marked for removal for over a month and has not been improved
or touched at all since it was implemented.
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
... | ... |
@@ -392,175 +392,6 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, |
392 | 392 |
sce->sf_idx[(w+w2)*16+g] = sce->sf_idx[w*16+g]; |
393 | 393 |
} |
394 | 394 |
|
395 |
- |
|
396 |
-static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, |
|
397 |
- SingleChannelElement *sce, |
|
398 |
- const float lambda) |
|
399 |
-{ |
|
400 |
- int start = 0, i, w, w2, g; |
|
401 |
- float uplim[128], maxq[128]; |
|
402 |
- int minq, maxsf; |
|
403 |
- float distfact = ((sce->ics.num_windows > 1) ? 85.80 : 147.84) / lambda; |
|
404 |
- int last = 0, lastband = 0, curband = 0; |
|
405 |
- float avg_energy = 0.0; |
|
406 |
- if (sce->ics.num_windows == 1) { |
|
407 |
- start = 0; |
|
408 |
- for (i = 0; i < 1024; i++) { |
|
409 |
- if (i - start >= sce->ics.swb_sizes[curband]) { |
|
410 |
- start += sce->ics.swb_sizes[curband]; |
|
411 |
- curband++; |
|
412 |
- } |
|
413 |
- if (sce->coeffs[i]) { |
|
414 |
- avg_energy += sce->coeffs[i] * sce->coeffs[i]; |
|
415 |
- last = i; |
|
416 |
- lastband = curband; |
|
417 |
- } |
|
418 |
- } |
|
419 |
- } else { |
|
420 |
- for (w = 0; w < 8; w++) { |
|
421 |
- const float *coeffs = &sce->coeffs[w*128]; |
|
422 |
- curband = start = 0; |
|
423 |
- for (i = 0; i < 128; i++) { |
|
424 |
- if (i - start >= sce->ics.swb_sizes[curband]) { |
|
425 |
- start += sce->ics.swb_sizes[curband]; |
|
426 |
- curband++; |
|
427 |
- } |
|
428 |
- if (coeffs[i]) { |
|
429 |
- avg_energy += coeffs[i] * coeffs[i]; |
|
430 |
- last = FFMAX(last, i); |
|
431 |
- lastband = FFMAX(lastband, curband); |
|
432 |
- } |
|
433 |
- } |
|
434 |
- } |
|
435 |
- } |
|
436 |
- last++; |
|
437 |
- avg_energy /= last; |
|
438 |
- if (avg_energy == 0.0f) { |
|
439 |
- for (i = 0; i < FF_ARRAY_ELEMS(sce->sf_idx); i++) |
|
440 |
- sce->sf_idx[i] = SCALE_ONE_POS; |
|
441 |
- return; |
|
442 |
- } |
|
443 |
- for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { |
|
444 |
- start = w*128; |
|
445 |
- for (g = 0; g < sce->ics.num_swb; g++) { |
|
446 |
- float *coefs = &sce->coeffs[start]; |
|
447 |
- const int size = sce->ics.swb_sizes[g]; |
|
448 |
- int start2 = start, end2 = start + size, peakpos = start; |
|
449 |
- float maxval = -1, thr = 0.0f, t; |
|
450 |
- maxq[w*16+g] = 0.0f; |
|
451 |
- if (g > lastband) { |
|
452 |
- maxq[w*16+g] = 0.0f; |
|
453 |
- start += size; |
|
454 |
- for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) |
|
455 |
- memset(coefs + w2*128, 0, sizeof(coefs[0])*size); |
|
456 |
- continue; |
|
457 |
- } |
|
458 |
- for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { |
|
459 |
- for (i = 0; i < size; i++) { |
|
460 |
- float t = coefs[w2*128+i]*coefs[w2*128+i]; |
|
461 |
- maxq[w*16+g] = FFMAX(maxq[w*16+g], fabsf(coefs[w2*128 + i])); |
|
462 |
- thr += t; |
|
463 |
- if (sce->ics.num_windows == 1 && maxval < t) { |
|
464 |
- maxval = t; |
|
465 |
- peakpos = start+i; |
|
466 |
- } |
|
467 |
- } |
|
468 |
- } |
|
469 |
- if (sce->ics.num_windows == 1) { |
|
470 |
- start2 = FFMAX(peakpos - 2, start2); |
|
471 |
- end2 = FFMIN(peakpos + 3, end2); |
|
472 |
- } else { |
|
473 |
- start2 -= start; |
|
474 |
- end2 -= start; |
|
475 |
- } |
|
476 |
- start += size; |
|
477 |
- thr = pow(thr / (avg_energy * (end2 - start2)), 0.3 + 0.1*(lastband - g) / lastband); |
|
478 |
- t = 1.0 - (1.0 * start2 / last); |
|
479 |
- uplim[w*16+g] = distfact / (1.4 * thr + t*t*t + 0.075); |
|
480 |
- } |
|
481 |
- } |
|
482 |
- memset(sce->sf_idx, 0, sizeof(sce->sf_idx)); |
|
483 |
- abs_pow34_v(s->scoefs, sce->coeffs, 1024); |
|
484 |
- for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { |
|
485 |
- start = w*128; |
|
486 |
- for (g = 0; g < sce->ics.num_swb; g++) { |
|
487 |
- const float *coefs = &sce->coeffs[start]; |
|
488 |
- const float *scaled = &s->scoefs[start]; |
|
489 |
- const int size = sce->ics.swb_sizes[g]; |
|
490 |
- int scf, prev_scf, step; |
|
491 |
- int min_scf = -1, max_scf = 256; |
|
492 |
- float curdiff; |
|
493 |
- if (maxq[w*16+g] < 21.544) { |
|
494 |
- sce->zeroes[w*16+g] = 1; |
|
495 |
- start += size; |
|
496 |
- continue; |
|
497 |
- } |
|
498 |
- sce->zeroes[w*16+g] = 0; |
|
499 |
- scf = prev_scf = av_clip(SCALE_ONE_POS - SCALE_DIV_512 - log2f(1/maxq[w*16+g])*16/3, 60, 218); |
|
500 |
- for (;;) { |
|
501 |
- float dist = 0.0f; |
|
502 |
- int quant_max; |
|
503 |
- |
|
504 |
- for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { |
|
505 |
- int b; |
|
506 |
- dist += quantize_band_cost(s, coefs + w2*128, |
|
507 |
- scaled + w2*128, |
|
508 |
- sce->ics.swb_sizes[g], |
|
509 |
- scf, |
|
510 |
- ESC_BT, |
|
511 |
- lambda, |
|
512 |
- INFINITY, |
|
513 |
- &b, NULL, |
|
514 |
- 0); |
|
515 |
- dist -= b; |
|
516 |
- } |
|
517 |
- dist *= 1.0f / 512.0f / lambda; |
|
518 |
- quant_max = quant(maxq[w*16+g], ff_aac_pow2sf_tab[POW_SF2_ZERO - scf + SCALE_ONE_POS - SCALE_DIV_512], ROUND_STANDARD); |
|
519 |
- if (quant_max >= 8191) { // too much, return to the previous quantizer |
|
520 |
- sce->sf_idx[w*16+g] = prev_scf; |
|
521 |
- break; |
|
522 |
- } |
|
523 |
- prev_scf = scf; |
|
524 |
- curdiff = fabsf(dist - uplim[w*16+g]); |
|
525 |
- if (curdiff <= 1.0f) |
|
526 |
- step = 0; |
|
527 |
- else |
|
528 |
- step = log2f(curdiff); |
|
529 |
- if (dist > uplim[w*16+g]) |
|
530 |
- step = -step; |
|
531 |
- scf += step; |
|
532 |
- scf = av_clip_uint8(scf); |
|
533 |
- step = scf - prev_scf; |
|
534 |
- if (FFABS(step) <= 1 || (step > 0 && scf >= max_scf) || (step < 0 && scf <= min_scf)) { |
|
535 |
- sce->sf_idx[w*16+g] = av_clip(scf, min_scf, max_scf); |
|
536 |
- break; |
|
537 |
- } |
|
538 |
- if (step > 0) |
|
539 |
- min_scf = prev_scf; |
|
540 |
- else |
|
541 |
- max_scf = prev_scf; |
|
542 |
- } |
|
543 |
- start += size; |
|
544 |
- } |
|
545 |
- } |
|
546 |
- minq = sce->sf_idx[0] ? sce->sf_idx[0] : INT_MAX; |
|
547 |
- for (i = 1; i < 128; i++) { |
|
548 |
- if (!sce->sf_idx[i]) |
|
549 |
- sce->sf_idx[i] = sce->sf_idx[i-1]; |
|
550 |
- else |
|
551 |
- minq = FFMIN(minq, sce->sf_idx[i]); |
|
552 |
- } |
|
553 |
- if (minq == INT_MAX) |
|
554 |
- minq = 0; |
|
555 |
- minq = FFMIN(minq, SCALE_MAX_POS); |
|
556 |
- maxsf = FFMIN(minq + SCALE_MAX_DIFF, SCALE_MAX_POS); |
|
557 |
- for (i = 126; i >= 0; i--) { |
|
558 |
- if (!sce->sf_idx[i]) |
|
559 |
- sce->sf_idx[i] = sce->sf_idx[i+1]; |
|
560 |
- sce->sf_idx[i] = av_clip(sce->sf_idx[i], minq, maxsf); |
|
561 |
- } |
|
562 |
-} |
|
563 |
- |
|
564 | 395 |
static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, |
565 | 396 |
SingleChannelElement *sce, |
566 | 397 |
const float lambda) |
... | ... |
@@ -951,28 +782,6 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe) |
951 | 951 |
} |
952 | 952 |
|
953 | 953 |
AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB] = { |
954 |
- [AAC_CODER_FAAC] = { |
|
955 |
- search_for_quantizers_faac, |
|
956 |
- encode_window_bands_info, |
|
957 |
- quantize_and_encode_band, |
|
958 |
- ff_aac_encode_tns_info, |
|
959 |
- ff_aac_encode_ltp_info, |
|
960 |
- ff_aac_encode_main_pred, |
|
961 |
- ff_aac_adjust_common_pred, |
|
962 |
- ff_aac_adjust_common_ltp, |
|
963 |
- ff_aac_apply_main_pred, |
|
964 |
- ff_aac_apply_tns, |
|
965 |
- ff_aac_update_ltp, |
|
966 |
- ff_aac_ltp_insert_new_frame, |
|
967 |
- set_special_band_scalefactors, |
|
968 |
- search_for_pns, |
|
969 |
- mark_pns, |
|
970 |
- ff_aac_search_for_tns, |
|
971 |
- ff_aac_search_for_ltp, |
|
972 |
- search_for_ms, |
|
973 |
- ff_aac_search_for_is, |
|
974 |
- ff_aac_search_for_pred, |
|
975 |
- }, |
|
976 | 954 |
[AAC_CODER_ANMR] = { |
977 | 955 |
search_for_quantizers_anmr, |
978 | 956 |
encode_window_bands_info, |
... | ... |
@@ -983,8 +983,6 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) |
983 | 983 |
if (s->options.coder != AAC_CODER_TWOLOOP) { |
984 | 984 |
ERROR_IF(avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL, |
985 | 985 |
"Coders other than twoloop require -strict -2 and some may be removed in the future\n"); |
986 |
- WARN_IF(s->options.coder == AAC_CODER_FAAC, |
|
987 |
- "The FAAC-like coder will be removed in the near future, please use twoloop!\n"); |
|
988 | 986 |
s->options.intensity_stereo = 0; |
989 | 987 |
s->options.pns = 0; |
990 | 988 |
} |
... | ... |
@@ -1029,8 +1027,7 @@ fail: |
1029 | 1029 |
|
1030 | 1030 |
#define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM |
1031 | 1031 |
static const AVOption aacenc_options[] = { |
1032 |
- {"aac_coder", "Coding algorithm", offsetof(AACEncContext, options.coder), AV_OPT_TYPE_INT, {.i64 = AAC_CODER_TWOLOOP}, -1, AAC_CODER_NB-1, AACENC_FLAGS, "coder"}, |
|
1033 |
- {"faac", "FAAC-inspired method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_FAAC}, INT_MIN, INT_MAX, AACENC_FLAGS, "coder"}, |
|
1032 |
+ {"aac_coder", "Coding algorithm", offsetof(AACEncContext, options.coder), AV_OPT_TYPE_INT, {.i64 = AAC_CODER_TWOLOOP}, 0, AAC_CODER_NB-1, AACENC_FLAGS, "coder"}, |
|
1034 | 1033 |
{"anmr", "ANMR method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_ANMR}, INT_MIN, INT_MAX, AACENC_FLAGS, "coder"}, |
1035 | 1034 |
{"twoloop", "Two loop searching method", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_TWOLOOP}, INT_MIN, INT_MAX, AACENC_FLAGS, "coder"}, |
1036 | 1035 |
{"fast", "Constant quantizer", 0, AV_OPT_TYPE_CONST, {.i64 = AAC_CODER_FAST}, INT_MIN, INT_MAX, AACENC_FLAGS, "coder"}, |