[FFmpeg-devel] [PATCH] swscale: fix build with --enable-runtime-cpudetect --disable-mmx/mmx2/amd3dnow

Måns Rullgård mans
Wed Feb 2 20:57:18 CET 2011


Anssi Hannula <anssi.hannula at iki.fi> writes:

> On 02.02.2011 20:22, M?ns Rullg?rd wrote:
>> Anssi Hannula <anssi.hannula at iki.fi> writes:
>> 
>>> Commit 0fc29f2708a "swscale: simplify selection of optimizations to
>>> compile." (25 Aug 2010) changed the behaviour so that with
>>> --enable-runtime-cpudetect --disable-mmx/mmx2/amd3dnow the instruction
>>> sets are actually disabled.
>>>
>>> However, ff_getSwsFunc() still calls the respective initialization
>>> functions which no longer exist, causing a build failure.
>>>
>>> Fix that by putting those calls under #if as well.
>>> ---
>>>  libswscale/swscale.c |   15 +++++++++++----
>>>  1 files changed, 11 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/libswscale/swscale.c b/libswscale/swscale.c
>>> index 375171f..8d7bb73 100644
>>> --- a/libswscale/swscale.c
>>> +++ b/libswscale/swscale.c
>>> @@ -1262,19 +1262,26 @@ SwsFunc ff_getSwsFunc(SwsContext *c)
>>>
>>>  #if ARCH_X86
>>>      // ordered per speed fastest first
>>> +#if COMPILE_MMX2
>>>      if (flags & SWS_CPU_CAPS_MMX2) {
>>>          sws_init_swScale_MMX2(c);
>>>          return swScale_MMX2;
>>> -    } else if (flags & SWS_CPU_CAPS_3DNOW) {
>>> +    }
>>> +#endif
>>> +#if COMPILE_3DNOW
>>> +    if (flags & SWS_CPU_CAPS_3DNOW) {
>>>          sws_init_swScale_3DNow(c);
>>>          return swScale_3DNow;
>>> -    } else if (flags & SWS_CPU_CAPS_MMX) {
>>> +    }
>>> +#endif
>>> +#if COMPILE_MMX
>>> +    if (flags & SWS_CPU_CAPS_MMX) {
>>>          sws_init_swScale_MMX(c);
>>>          return swScale_MMX;
>>> -    } else {
>>> +    }
>>> +#endif
>> 
>> I somehow suspect these should be HAVE_FOO instead, but this file is
>> an ifdef jungle and I could be wrong.
>
> The COMPILE_FOO are defined to HAVE_FOO when runtime cpudetection is in
> use. However, as the actual compilation of those functions depends
> directly on COMPILE_FOO (and only indirectly on HAVE_FOO), I had thought
> it is better to make the calls depend on the same #define.

Luca has plans for cleaning up this mess.  We should wait for him to
weigh in on this.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list