History

aacenc: add SIMD optimizations for abs_pow34 and quantization

Performance improvements: quant_bands: with: 681 decicycles in quant_bands, 8388453 runs, 155 skips without: 1190 decicycles in quant_bands, 8388386 runs, 222 skips Around 42% for the function Twoloop coder: abs_pow34: with/without: 7.82s/8.17s Around 4% for the entire encoder Both: with/without: 7.15s/8.17s Around 12% for the entire encoder Fast coder: abs_pow34: with/without: 3.40s/3.77s Around 10% for the entire encoder Both: with/without: 3.02s/3.77s Around 20% faster for the entire encoder

Rostislav Pehlivanov committed 10 years ago

Commit d2ae5f71 parent 3b02f6d13 files · +170 −26Browse files

Showing the changes to libavcodec/aaccoder.c (1 of 13 files). Show all

Unified · Split

libavcodec/aaccoder.c+14−13
@@ -88,7 +88,7 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce · 87 unmodified lines
88 float next_minrd = INFINITY;88 float next_minrd = INFINITY;
89 int next_mincb = 0;89 int next_mincb = 0;
90 90
91 abs_pow34_v(s->scoefs, sce->coeffs, 1024);91 s->abs_pow34(s->scoefs, sce->coeffs, 1024);
92 start = win*128;92 start = win*128;
93 for (cb = 0; cb < CB_TOT_ALL; cb++) {93 for (cb = 0; cb < CB_TOT_ALL; cb++) {
94 path[0][cb].cost = 0.0f;94 path[0][cb].cost = 0.0f;
@@ -299,7 +299,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 204 unmodified lines
299 }299 }
300 }300 }
301 idx = 1;301 idx = 1;
302 abs_pow34_v(s->scoefs, sce->coeffs, 1024);302 s->abs_pow34(s->scoefs, sce->coeffs, 1024);
303 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {303 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
304 start = w*128;304 start = w*128;
305 for (g = 0; g < sce->ics.num_swb; g++) {305 for (g = 0; g < sce->ics.num_swb; g++) {
@@ -446,7 +446,7 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, · 140 unmodified lines
446 446
447 if (!allz)447 if (!allz)
448 return;448 return;
449 abs_pow34_v(s->scoefs, sce->coeffs, 1024);449 s->abs_pow34(s->scoefs, sce->coeffs, 1024);
450 ff_quantize_band_cost_cache_init(s);450 ff_quantize_band_cost_cache_init(s);
451 451
452 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {452 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
@@ -652,8 +652,8 @@ static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne · 199 unmodified lines
652 s->fdsp->vector_fmul_scalar(PNS, PNS, scale, sce->ics.swb_sizes[g]);652 s->fdsp->vector_fmul_scalar(PNS, PNS, scale, sce->ics.swb_sizes[g]);
653 pns_senergy = s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]);653 pns_senergy = s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]);
654 pns_energy += pns_senergy;654 pns_energy += pns_senergy;
655 abs_pow34_v(NOR34, &sce->coeffs[start_c], sce->ics.swb_sizes[g]);655 s->abs_pow34(NOR34, &sce->coeffs[start_c], sce->ics.swb_sizes[g]);
656 abs_pow34_v(PNS34, PNS, sce->ics.swb_sizes[g]);656 s->abs_pow34(PNS34, PNS, sce->ics.swb_sizes[g]);
657 dist1 += quantize_band_cost(s, &sce->coeffs[start_c],657 dist1 += quantize_band_cost(s, &sce->coeffs[start_c],
658 NOR34,658 NOR34,
659 sce->ics.swb_sizes[g],659 sce->ics.swb_sizes[g],
@@ -757,8 +757,9 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe) · 97 unmodified lines
757{757{
758 int start = 0, i, w, w2, g, sid_sf_boost, prev_mid, prev_side;758 int start = 0, i, w, w2, g, sid_sf_boost, prev_mid, prev_side;
759 uint8_t nextband0[128], nextband1[128];759 uint8_t nextband0[128], nextband1[128];
760 float M[128], S[128];760 float *M = s->scoefs + 128*0, *S = s->scoefs + 128*1;
761 float *L34 = s->scoefs, *R34 = s->scoefs + 128, *M34 = s->scoefs + 128*2, *S34 = s->scoefs + 128*3;761 float *L34 = s->scoefs + 128*2, *R34 = s->scoefs + 128*3;
762 float *M34 = s->scoefs + 128*4, *S34 = s->scoefs + 128*5;
762 const float lambda = s->lambda;763 const float lambda = s->lambda;
763 const float mslambda = FFMIN(1.0f, lambda / 120.f);764 const float mslambda = FFMIN(1.0f, lambda / 120.f);
764 SingleChannelElement *sce0 = &cpe->ch[0];765 SingleChannelElement *sce0 = &cpe->ch[0];
@@ -789,8 +790,8 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe) · 24 unmodified lines
789 S[i] = M[i]790 S[i] = M[i]
790 - sce1->coeffs[start+(w+w2)*128+i];791 - sce1->coeffs[start+(w+w2)*128+i];
791 }792 }
792 abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]);793 s->abs_pow34(M34, M, sce0->ics.swb_sizes[g]);
793 abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]);794 s->abs_pow34(S34, S, sce0->ics.swb_sizes[g]);
794 for (i = 0; i < sce0->ics.swb_sizes[g]; i++ ) {795 for (i = 0; i < sce0->ics.swb_sizes[g]; i++ ) {
795 Mmax = FFMAX(Mmax, M34[i]);796 Mmax = FFMAX(Mmax, M34[i]);
796 Smax = FFMAX(Smax, S34[i]);797 Smax = FFMAX(Smax, S34[i]);
@@ -833,10 +834,10 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe) · 36 unmodified lines
833 - sce1->coeffs[start+(w+w2)*128+i];834 - sce1->coeffs[start+(w+w2)*128+i];
834 }835 }
835 836
836 abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);837 s->abs_pow34(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
837 abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);838 s->abs_pow34(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
838 abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]);839 s->abs_pow34(M34, M, sce0->ics.swb_sizes[g]);
839 abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]);840 s->abs_pow34(S34, S, sce0->ics.swb_sizes[g]);
840 dist1 += quantize_band_cost(s, &sce0->coeffs[start + (w+w2)*128],841 dist1 += quantize_band_cost(s, &sce0->coeffs[start + (w+w2)*128],
841 L34,842 L34,
842 sce0->ics.swb_sizes[g],843 sce0->ics.swb_sizes[g],

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t