diff options
author | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-10-27 21:11:45 -0400 |
---|---|---|
committer | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-11-04 08:15:24 -0500 |
commit | fd0bf457b734beee6715254ea264118dc4993507 (patch) | |
tree | 5974340246a5e8e90f711933dc018c81880ee1ee /libavcodec/aacsbr_template.c | |
parent | bc55cec57e5d804f8cc9596a6f3878c1bda0ae56 (diff) | |
download | ffmpeg-fd0bf457b734beee6715254ea264118dc4993507.tar.gz |
avcodec/aacsbr_template: replace qsort with AV_QSORT
When sbr->reset is set in encode_frame, a bunch of qsort calls might get made.
Thus, there is the potential of calling qsort whenever the spectral
contents change.
AV_QSORT is substantially faster due to the inlining of the comparison callback.
Thus, the increase in performance should be worth the increase in binary size.
Tested with FATE.
Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Diffstat (limited to 'libavcodec/aacsbr_template.c')
-rw-r--r-- | libavcodec/aacsbr_template.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c index d31b71e0a8..9561ba014e 100644 --- a/libavcodec/aacsbr_template.c +++ b/libavcodec/aacsbr_template.c @@ -32,6 +32,8 @@ * @author Zoran Basaric ( zoran.basaric@imgtec.com ) */ +#include "libavutil/qsort.h" + av_cold void AAC_RENAME(ff_aac_sbr_init)(void) { static const struct { @@ -138,8 +140,8 @@ static void sbr_make_f_tablelim(SpectralBandReplication *sbr) memcpy(sbr->f_tablelim + sbr->n[0] + 1, patch_borders + 1, (sbr->num_patches - 1) * sizeof(patch_borders[0])); - qsort(sbr->f_tablelim, sbr->num_patches + sbr->n[0], - sizeof(sbr->f_tablelim[0]), + AV_QSORT(sbr->f_tablelim, sbr->num_patches + sbr->n[0], + uint16_t, qsort_comparison_function_int16); sbr->n_lim = sbr->n[0] + sbr->num_patches - 1; @@ -296,7 +298,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, if (spectrum->bs_stop_freq < 14) { sbr->k[2] = stop_min; make_bands(stop_dk, stop_min, 64, 13); - qsort(stop_dk, 13, sizeof(stop_dk[0]), qsort_comparison_function_int16); + AV_QSORT(stop_dk, 13, int16_t, qsort_comparison_function_int16); for (k = 0; k < spectrum->bs_stop_freq; k++) sbr->k[2] += stop_dk[k]; } else if (spectrum->bs_stop_freq == 14) { @@ -389,7 +391,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, make_bands(vk0+1, sbr->k[0], sbr->k[1], num_bands_0); - qsort(vk0 + 1, num_bands_0, sizeof(vk0[1]), qsort_comparison_function_int16); + AV_QSORT(vk0 + 1, num_bands_0, int16_t, qsort_comparison_function_int16); vdk0_max = vk0[num_bands_0]; vk0[0] = sbr->k[0]; @@ -430,13 +432,13 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, if (vdk1_min < vdk0_max) { int change; - qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16); + AV_QSORT(vk1 + 1, num_bands_1, int16_t, qsort_comparison_function_int16); change = FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1); vk1[1] += change; vk1[num_bands_1] -= change; } - qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16); + AV_QSORT(vk1 + 1, num_bands_1, int16_t, qsort_comparison_function_int16); vk1[0] = sbr->k[1]; for (k = 1; k <= num_bands_1; k++) { |