avcodec/aac_tablegen: speed up table initialization

Multimedia / FFmpeg - Ganesh Ajjanagadde [gmail.com] - 27 November 2015 05:38 UTC

This speeds up aac_tablegen to a ludicruous degree (~97%), i.e to the point where it can be argued that runtime initialization can always be done instead of hard-coded tables. The only cost is essentially a trivial increase in the stack size.

Even if one does not care about this, the patch also improves accuracy as detailed below.

Performance: Benchmark obtained by looping 10^4 times over ff_aac_tableinit.

Sample benchmark (x86-64, Haswell, GNU/Linux): old: 1295292 decicycles in ff_aac_tableinit, 512 runs, 0 skips 1275981 decicycles in ff_aac_tableinit, 1024 runs, 0 skips 1272932 decicycles in ff_aac_tableinit, 2048 runs, 0 skips 1262164 decicycles in ff_aac_tableinit, 4096 runs, 0 skips 1256720 decicycles in ff_aac_tableinit, 8192 runs, 0 skips

new: 21112 decicycles in ff_aac_tableinit, 511 runs, 1 skips 21269 decicycles in ff_aac_tableinit, 1023 runs, 1 skips 21352 decicycles in ff_aac_tableinit, 2043 runs, 5 skips 21386 decicycles in ff_aac_tableinit, 4080 runs, 16 skips 21299 decicycles in ff_aac_tableinit, 8173 runs, 19 skips

Accuracy: The previous code was resulting in needless loss of accuracy due to the pow being called in succession. As an illustration of this: ff_aac_pow34sf_tab[3] old : 0.000000000007598092294225 new : 0.000000000007598091426864 real: 0.000000000007598091778545

truncated to float old : 0.000000000007598092294225 new : 0.000000000007598091426864 real: 0.000000000007598091426864

showing that the old value was not correctly rounded. This affects a large number of elements of the array.

Patch tested with FATE.

96786a1 avcodec/aac_tablegen: speed up table initialization
libavcodec/aac_tablegen.h | 41 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)

  • Share