[FFmpeg-devel] [PATCH] runtime cpu detection for emms

Måns Rullgård mans
Mon Aug 30 23:44:57 CEST 2010


Alex Converse <alex.converse at gmail.com> writes:

> 2010/8/29 M?ns Rullg?rd <mans at mansr.com>:
>> Aurelien Jacobs <aurel at gnuage.org> writes:
>>
>>> Hi,
>>>
>>> Recent change to emms() made it the only MMX dependent function which
>>> don't support runtime cpu detection.
>>> Attached patch restore this feature without the need for a global
>>> mm_flags, and without the overhead of a mm_support() call for each
>>> emms().
>>>
>>> Aurel
>>>
>>> diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
>>> index 3b5ca12..1584b89 100644
>>> --- a/libavcodec/dsputil.h
>>> +++ b/libavcodec/dsputil.h
>>> @@ -627,14 +627,9 @@ void ff_mlp_init_x86(DSPContext* c, AVCodecContext *avctx);
>>>
>>> ?#if HAVE_MMX
>>>
>>> +extern void (*ff_emms)(void);
>>> ?#undef emms_c
>>> -
>>> -static inline void emms(void)
>>> -{
>>> - ? ?__asm__ volatile ("emms;":::"memory");
>>> -}
>>> -
>>> -#define emms_c() emms()
>>> +#define emms_c() ff_emms()
>>>
>>> ?#elif ARCH_ARM
>>>
>>> diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c
>>> index a24ed62..0b7de41 100644
>>> --- a/libavcodec/x86/dsputil_mmx.c
>>> +++ b/libavcodec/x86/dsputil_mmx.c
>>> @@ -228,6 +228,15 @@ DECLARE_ALIGNED(16, const double, ff_pd_2)[2] = { 2.0, 2.0 };
>>> ?/***********************************/
>>> ?/* standard MMX */
>>>
>>> +static void emms_null(void) ?{ }
>>> +static void emms_mmx(void) ? { __asm__ volatile ("emms;":::"memory"); }
>>> +static void emms_init(void)
>>> +{
>>> + ? ?ff_emms = mm_support() & FF_MM_MMX ? emms_mmx : emms_null;
>>> + ? ?ff_emms();
>>> +}
>>> +void (*ff_emms)(void) = emms_init;
>>
>> This is worse than the original.
>>
>
> Suppose we put emms() in the DSP context and put the onus of calling
> it on codecs that actually use MMX accelerated video functions?

Unacceptable.

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



More information about the ffmpeg-devel mailing list