[FFmpeg-devel] [RFC] use av_get_cpu_flags for real runtime CPU detection in swscale
Måns Rullgård
mans
Wed Sep 8 18:49:43 CEST 2010
Janne Grunau <janne-ffmpeg at jannau.net> writes:
> On Wed, Sep 08, 2010 at 05:24:02PM +0100, M?ns Rullg?rd wrote:
>> Janne Grunau <janne-ffmpeg at jannau.net> writes:
>>
>> > @@ -722,7 +723,26 @@ static int handle_jpeg(enum PixelFormat *format)
>> >
>> > static int update_flags_cpu(int flags)
>> > {
>> > -#if !CONFIG_RUNTIME_CPUDETECT //ensure that the flags match the compiled variant if cpudetect is off
>> > +#if CONFIG_RUNTIME_CPUDETECT
>> > + int cpuflags;
>> > +
>> > + if (!(flags & SWS_CPU_CAPS_FORCE)) {
>> > + flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC|SWS_CPU_CAPS_BFIN);
>> > +
>> > + cpuflags = av_get_cpu_flags();
>> > +
>> > + if (ARCH_X86 && cpuflags & AV_CPU_FLAG_MMX)
>> > + flags |= SWS_CPU_CAPS_MMX;
>> > + if (ARCH_X86 && cpuflags & AV_CPU_FLAG_MMX2)
>> > + flags |= SWS_CPU_CAPS_MMX2;
>> > + if (ARCH_X86 && cpuflags & AV_CPU_FLAG_3DNOW)
>> > + flags |= SWS_CPU_CAPS_3DNOW;;
>> > + if (ARCH_X86 && cpuflags & AV_CPU_FLAG_SSE2)
>> > + flags |= SWS_CPU_CAPS_SSE2;
>> > + if (ARCH_PPC && cpuflags & AV_CPU_FLAG_ALTIVEC)
>> > + flags |= SWS_CPU_CAPS_ALTIVEC;
>>
>> Why not change libswscale to use the AV_CPU_FLAG_ values directly?
>> That would avoid this mess entirely.
>
> API change, flags are passed in the same parameter as the other
> algorithm options which would conflict with AV_CPU_FLAG_
So fix the API. Having two conflicting sets of CPU capability flags
is a recipe for trouble.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list