[FFmpeg-user] Weird cross platform support in ffmpeg

Александр cool.ipatovo at gmail.com
Tue May 31 14:03:59 EEST 2022

I tried to build ffmpeg 4.4 library and link with it and I received
multiple unresolved references. I came across on unusual architecture in
ffmpeg for multiple platforms.The library has many places with code like

void foo()
    if (ARCH_MIPS) // maybe #if ARCH_MIPS (...) #endif should be used instead?
    if (ARCH_PPC)
    if (ARCH_ARM)
    if (ARCH_AARCH64)

This code leads to linker errors because there is no any stub methods for
other platforms. I observed root MakeFile, it optionally includes platform
dependent code for each library (path like $(LIB_SUBDIR)/$(ARCH)/MakeFile)
where each foo_<arch> is defined.

So, how does it work? In my opinion preprocessor directive #if should be
used, otherwise we will receive unresolved reference on any platform. Maybe
I missed something? because this code appears frequently for example:

   1. utils.c : ff_yuv2rgb_init_tables_ppc
   2. swscale_unscaled.c : ff_get_unscaled_swscale_ppc,
   ff_get_unscaled_swscale_arm, ff_get_unscaled_swscale_aarch64
   3. cpu.c : ff_get_cpu_max_align_x86, ff_get_cpu_max_align_mips
   4. float_dsp.c : ff_float_dsp_init_aarch64, ff_float_dsp_init_ppc,
   5. etc.

More information about the ffmpeg-user mailing list