[FFmpeg-devel] [PATCHv2 2/3] avcodec/mpegaudio_tablegen: speed up table generation

Ganesh Ajjanagadde gajjanagadde at gmail.com
Thu Nov 26 17:58:43 CET 2015


On Thu, Nov 26, 2015 at 10:44 AM, Ganesh Ajjanagadde
<gajjanagadde at gmail.com> wrote:
> On Thu, Nov 26, 2015 at 10:37 AM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
>> Hi,
>>
>> On Thu, Nov 26, 2015 at 10:23 AM, Ganesh Ajjanagadde
>> <gajjanagadde at gmail.com> wrote:
>>>
>>> This does some miscellaneous stuff mainly avoiding the usage of pow to
>>> achieve significant speedups. This is not speed critical, but is
>>> unnecessary latency and cycles wasted for a user.
>>>
>>> All tables tested and are identical to the old ones
>>> (bit-exact even in floating point case).
>>>
>>> Sample benchmark (x86-64, Haswell, GNU/Linux):
>>> old:
>>> 102329530 decicycles in mpegaudio_tableinit,       1 runs,      0 skips
>>>
>>> new:
>>> 34111900 decicycles in mpegaudio_tableinit,       1 runs,      0 skips
>>>
>>> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>>> ---
>>>  libavcodec/mpegaudio_tablegen.h | 21 +++++++++++++++------
>>>  1 file changed, 15 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/libavcodec/mpegaudio_tablegen.h
>>> b/libavcodec/mpegaudio_tablegen.h
>>> index 86b2cd3..6cd5ad6 100644
>>> --- a/libavcodec/mpegaudio_tablegen.h
>>> +++ b/libavcodec/mpegaudio_tablegen.h
>>> @@ -29,9 +29,11 @@
>>>
>>>  #define TABLE_4_3_SIZE (8191 + 16)*4
>>>  #if CONFIG_HARDCODED_TABLES
>>> +#include "libavutil/tablegen.h"
>>>  #define mpegaudio_tableinit()
>>>  #include "libavcodec/mpegaudio_tables.h"
>>>  #else
>>> +#include "libavutil/libm.h"
>>
>>
>> I don't think this works yet. Check mpegaudio_tablegen.c (it should be
>> obvious why it does this):
>>
>> #include <stdlib.h>
>> #define CONFIG_HARDCODED_TABLES 0
>> #include "mpegaudio_tablegen.h"
>> #include "tableprint.h"
>>
>> Note that this is the table generation which runs on the host platform. So,
>> the location where you add this, is important. I would recommend including
>> tablegen.h inside mpegaudio_tablegen.c, and then including libavutil/libm.h
>> outside the scope of this header, e.g. in users of this header, if
>> tablegen.h wasn't included. Make sure make checkheaders passes after your
>> changes, and the build works with as well as without hardcoded_tables.
>
> I did a build test with and without hardcoded , did not think of
> checkheaders, will recheck and correct depending on the result.

checkheaders also passes with just this patch (both with or without
hardcoded). Nevertheless, I agree with you and have now posted v3,
tested with/without checkheaders and with/without
--enable-hardcoded-tables.

[...]
>
>>
>> Ronald


More information about the ffmpeg-devel mailing list