[FFmpeg-devel] [PATCH] intmath.h: add an ff_log2_nz

Ganesh Ajjanagadde gajjanag at mit.edu
Thu Dec 17 18:51:06 CET 2015


On Thu, Dec 17, 2015 at 9:29 AM, Rostislav Pehlivanov
<atomnuker at gmail.com> wrote:
> This commit adds a raw integer log2 function (which directly maps to a
> builtin). This was needed as the Daala entropy coding system requires a
> raw log2 and the existing ff_log2 OR'd the argument with 1.
>
> The C implementation was taken from Daala's source code, which
> got it from someplace else as a search reveals more similar
> implementations. It was described as the fastest
> implementation tested on a Pentium MMX, but considering its simplicity
> this statement is still probably valid to this day.

Likely not the fastest, pretty confident a de-Bruijn based approach is
faster on modern hardware:
https://www.klittlepage.com/2013/12/21/twelve-days-2013-de-bruijn-sequences/,
or just google for it.

Nevertheless, I am willing to accept this for an initial patch: people
who care about performance on non gcc/clang platforms can study this
and do the needful.

>
> While the native Daala decoder is still in development, this required
> piece might prove useful to other parts of the code, such as access to
> the __builtin_clz.

Don't want to duplicate work here, see
https://ffmpeg.org/pipermail/ffmpeg-devel/2015-December/185350.html
and discussion therein. I don't know if they should go into the same
patch.

Or put in other words, I will hold off on my end, go ahead with this
stuff (with/without the stuff in the link). Once your patch is in,
depending on whether/how you incorporate things, I will return to the
patch.

[...]


More information about the ffmpeg-devel mailing list