[FFmpeg-devel] Removing DCE

Matt Oliver protogonoi at gmail.com
Wed Jan 11 09:35:06 EET 2017


On 23 December 2016 at 19:40, Nicolas George <george at nsup.org> wrote:

> Le primidi 1er nivôse, an CCXXV, Michael Niedermayer a écrit :
> > how hard would it be to write a preprocessor like tool to convert
> > all if (ARCH/HAVE/CONFIG_SYMBOL ...)
> > to
> > #if
> > ?
>
> For a very general case, quite hard, but we do not need it.
>
> If we stick to a few reasonable cosmetic conventions on the affected
> blocks (at a guess: correct indentation of the braces, balanced
> parentheses in the condition; we want to do that anyway), then it should
> be quite easy to write a preprocessor like that.
>
> I do not know how to integrate that in the build system, though. That is
> the annoying part IMHO.
>

Looking at the code there are a couple (only small number admittedly) of
complex sections of code using DCE that would make a preprocessor tool
potentially rather complex and difficult to handle. I wouldn't like to
attempt to do it thats for sure.

I wouldn't mind a patch which did that, even if it meant adding a line for
> every file which did that.
> I'm not a preprocessor wizard but couldn't you hide all that in a macro,
> like:
>
> INIT_ARCH_CODEPATH(ARCH_X86, ff_aac_dsp_init_x86(s)))
>
> if you define the macro in config.h somehow such that the preprocessor
> doesn't evaluate whether ARCH_X86 is defined?


I think it would be possible to write a macro similar to that that can be
used to replace all the existing occurrences of things like:
if (ARCH_X86)
        ff_aac_dsp_init_x86(s);

with
SELECT_DCE(ARCH_X86, ff_aac_dsp_init_x86(s));

although all those occurrences can just be easily replaced with:
#if ARCH_X86
        ff_aac_dsp_init_x86(s);
#endif

Which one is chosen is simply a matter of preference, either one works fine
for me.

Its mainly for the more complicated sections of code where DCE is actually
used to test whether the code at least compiles correctly that a simple
macro wont suffice if you intend to wrap the whole block. However it is
only the function calls that cause errors so the rest of the code can be
left intact and only the function calls themselves get wrapped in some sort
of macro like above.

So any existing function call that causes linker errors can be wrapped in a
macro like SELECT_DCE (or whatever name you wish to give it) which would
fix all the current issues.

I have the time coming up to replace all the problem functions calls with
something like the above, so let me know whether that would be an
acceptable approach.


More information about the ffmpeg-devel mailing list