| 669 | } |
| 670 | |
| 671 | static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, |
| 672 | SingleChannelElement *sce, |
| 673 | const float lambda) |
| 674 | { |
| 675 | int start = 0, i, w, w2, g; |
| 676 | float uplim[128], maxq[128]; |
| 677 | int minq, maxsf; |
| 678 | float distfact = ((sce->ics.num_windows > 1) ? 85.80 : 147.84) / lambda; |
| 679 | int last = 0, lastband = 0, curband = 0; |
| 680 | float avg_energy = 0.0; |
| 681 | if (sce->ics.num_windows == 1) { |
| 682 | start = 0; |
| 683 | for (i = 0; i < 1024; i++) { |
| 684 | if (i - start >= sce->ics.swb_sizes[curband]) { |
| 685 | start += sce->ics.swb_sizes[curband]; |
| 686 | curband++; |
| 687 | } |
| 688 | if (sce->coeffs[i]) { |
| 689 | avg_energy += sce->coeffs[i] * sce->coeffs[i]; |
| 690 | last = i; |
| 691 | lastband = curband; |
| 692 | } |
| 693 | } |
| 694 | } else { |
| 695 | for (w = 0; w < 8; w++) { |
| 696 | const float *coeffs = sce->coeffs + w*128; |
| 697 | start = 0; |
| 698 | for (i = 0; i < 128; i++) { |
| 699 | if (i - start >= sce->ics.swb_sizes[curband]) { |
| 700 | start += sce->ics.swb_sizes[curband]; |
| 701 | curband++; |
| 702 | } |
| 703 | if (coeffs[i]) { |
| 704 | avg_energy += coeffs[i] * coeffs[i]; |
| 705 | last = FFMAX(last, i); |
| 706 | lastband = FFMAX(lastband, curband); |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | } |
| 711 | last++; |
| 712 | avg_energy /= last; |
| 713 | if (avg_energy == 0.0f) { |
| 714 | for (i = 0; i < FF_ARRAY_ELEMS(sce->sf_idx); i++) |
| 715 | sce->sf_idx[i] = SCALE_ONE_POS; |
| 716 | return; |
| 717 | } |
| 718 | for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { |
| 719 | start = w*128; |
| 720 | for (g = 0; g < sce->ics.num_swb; g++) { |
| 721 | float *coefs = sce->coeffs + start; |
| 722 | const int size = sce->ics.swb_sizes[g]; |
| 723 | int start2 = start, end2 = start + size, peakpos = start; |
| 724 | float maxval = -1, thr = 0.0f, t; |
| 725 | maxq[w*16+g] = 0.0f; |
| 726 | if (g > lastband) { |
| 727 | maxq[w*16+g] = 0.0f; |
| 728 | start += size; |
nothing calls this directly
no test coverage detected