[FFmpeg-devel] FASTDIV macro

Siarhei Siamashka siarhei.siamashka
Sun Nov 9 01:15:43 CET 2008


On Saturday 08 November 2008, M?ns Rullg?rd wrote:
> libavutil/internal.h defines a macro, FASTDIV(), for fast 32/16-bit
> division my means of multiplying by a table value.  If the
> architecture is not ARM or x86, which have asm versions, this macro is
> defined as a normal division if CONFIG_FASTDIV is not set.  The odd
> thing is, nothing ever sets CONFIG_FASTDIV.  Something is clearly not
> right here.

A right thing here would be a patch with a description like "Enabling FASTDIV
macro for architecture X improves performance of FFmpeg on this use case by Y
percents..."

> I see these alternatives to fix it:

I think you first need to provide some kind of convincing proof that it is
broken. This macro is definitely useful for ARM processors without instruction
for hardware division. In other cases I suspect that something like what is
done by FASTDIV macro could be somehow implemented in silicon itself (some
cases of division could be performed faster than the others). Even a benchark
of FASTDIV vs. native division for modern x86 cores would be interesting to
see.

> 1. Always use the table multiplication.
> 2. Enable CONFIG_FASTDIV by default.
> 3. Disable CONFIG_FASTDIV by default, adding configure option to
>    enable.
> 4. Always use plain division if no asm available.
>
> Opinions?
>
> There is also a question of where this macro belongs.  It uses a table
> defined in lavc, and its only use outside lavc is in ff_sqrt(), which
> is only used in lavc.  Would it make sense to move these to
> lavc/mathops.h, where other similar macros are defined?
> Alternatively, mathops.h could be moved to lavu.  I'd like it to be
> consistent.  The same goes for a number of other macros of this type.

-- 
Best regards,
Siarhei Siamashka




More information about the ffmpeg-devel mailing list