Mercurial > libavcodec.hg
comparison aaccoder.c @ 12265:b120f1854e35 libavcodec
aacenc: TLS: Save maximum values for each swb in a table.
This gives an almost 20% speedup.
| author | alexc |
|---|---|
| date | Sat, 24 Jul 2010 17:11:51 +0000 |
| parents | aff96d44f992 |
| children |
comparison
equal
deleted
inserted
replaced
| 12264:aff96d44f992 | 12265:b120f1854e35 |
|---|---|
| 695 const float lambda) | 695 const float lambda) |
| 696 { | 696 { |
| 697 int start = 0, i, w, w2, g; | 697 int start = 0, i, w, w2, g; |
| 698 int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels; | 698 int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels; |
| 699 float dists[128], uplims[128]; | 699 float dists[128], uplims[128]; |
| 700 float maxvals[128]; | |
| 700 int fflag, minscaler; | 701 int fflag, minscaler; |
| 701 int its = 0; | 702 int its = 0; |
| 702 int allz = 0; | 703 int allz = 0; |
| 703 float minthr = INFINITY; | 704 float minthr = INFINITY; |
| 704 | 705 |
| 736 } | 737 } |
| 737 | 738 |
| 738 if (!allz) | 739 if (!allz) |
| 739 return; | 740 return; |
| 740 abs_pow34_v(s->scoefs, sce->coeffs, 1024); | 741 abs_pow34_v(s->scoefs, sce->coeffs, 1024); |
| 742 | |
| 743 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { | |
| 744 start = w*128; | |
| 745 for (g = 0; g < sce->ics.num_swb; g++) { | |
| 746 const float *scaled = s->scoefs + start; | |
| 747 maxvals[w*16+g] = find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled); | |
| 748 start += sce->ics.swb_sizes[g]; | |
| 749 } | |
| 750 } | |
| 751 | |
| 741 //perform two-loop search | 752 //perform two-loop search |
| 742 //outer loop - improve quality | 753 //outer loop - improve quality |
| 743 do { | 754 do { |
| 744 int tbits, qstep; | 755 int tbits, qstep; |
| 745 minscaler = sce->sf_idx[0]; | 756 minscaler = sce->sf_idx[0]; |
| 761 if (sce->zeroes[w*16+g] || sce->sf_idx[w*16+g] >= 218) { | 772 if (sce->zeroes[w*16+g] || sce->sf_idx[w*16+g] >= 218) { |
| 762 start += sce->ics.swb_sizes[g]; | 773 start += sce->ics.swb_sizes[g]; |
| 763 continue; | 774 continue; |
| 764 } | 775 } |
| 765 minscaler = FFMIN(minscaler, sce->sf_idx[w*16+g]); | 776 minscaler = FFMIN(minscaler, sce->sf_idx[w*16+g]); |
| 766 cb = find_min_book(find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled), sce->sf_idx[w*16+g]); | 777 cb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]); |
| 767 for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { | 778 for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { |
| 768 int b; | 779 int b; |
| 769 dist += quantize_band_cost(s, coefs + w2*128, | 780 dist += quantize_band_cost(s, coefs + w2*128, |
| 770 scaled + w2*128, | 781 scaled + w2*128, |
| 771 sce->ics.swb_sizes[g], | 782 sce->ics.swb_sizes[g], |
| 800 } while (qstep); | 811 } while (qstep); |
| 801 | 812 |
| 802 fflag = 0; | 813 fflag = 0; |
| 803 minscaler = av_clip(minscaler, 60, 255 - SCALE_MAX_DIFF); | 814 minscaler = av_clip(minscaler, 60, 255 - SCALE_MAX_DIFF); |
| 804 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { | 815 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { |
| 805 start = w*128; | |
| 806 for (g = 0; g < sce->ics.num_swb; g++) { | 816 for (g = 0; g < sce->ics.num_swb; g++) { |
| 807 int prevsc = sce->sf_idx[w*16+g]; | 817 int prevsc = sce->sf_idx[w*16+g]; |
| 808 const float *scaled = s->scoefs + start; | |
| 809 if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60) { | 818 if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60) { |
| 810 if (find_min_book(find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled), sce->sf_idx[w*16+g]-1)) | 819 if (find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]-1)) |
| 811 sce->sf_idx[w*16+g]--; | 820 sce->sf_idx[w*16+g]--; |
| 812 else //Try to make sure there is some energy in every band | 821 else //Try to make sure there is some energy in every band |
| 813 sce->sf_idx[w*16+g]-=2; | 822 sce->sf_idx[w*16+g]-=2; |
| 814 } | 823 } |
| 815 sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler, minscaler + SCALE_MAX_DIFF); | 824 sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler, minscaler + SCALE_MAX_DIFF); |
| 816 sce->sf_idx[w*16+g] = FFMIN(sce->sf_idx[w*16+g], 219); | 825 sce->sf_idx[w*16+g] = FFMIN(sce->sf_idx[w*16+g], 219); |
| 817 if (sce->sf_idx[w*16+g] != prevsc) | 826 if (sce->sf_idx[w*16+g] != prevsc) |
| 818 fflag = 1; | 827 fflag = 1; |
| 819 sce->band_type[w*16+g] = find_min_book(find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled), sce->sf_idx[w*16+g]); | 828 sce->band_type[w*16+g] = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]); |
| 820 start += sce->ics.swb_sizes[g]; | |
| 821 } | 829 } |
| 822 } | 830 } |
| 823 its++; | 831 its++; |
| 824 } while (fflag && its < 10); | 832 } while (fflag && its < 10); |
| 825 } | 833 } |
