[FFmpeg-devel] [patch][OpenHEVC]added ASM functions for epel + qpel

James Almer jamrial at gmail.com
Sat Mar 8 01:28:02 CET 2014


On 06/03/14 12:40 PM, Pierre Edouard Lepere wrote:
> +void ff_hevcdsp_init_x86(HEVCDSPContext *c, const int bit_depth)
> +{
> +    int mm_flags = av_get_cpu_flags();
> +
> +    if (bit_depth == 8) {
> +        if (EXTERNAL_MMX(mm_flags)) {
> +
> +            if (EXTERNAL_MMXEXT(mm_flags)) {
> +#if ARCH_X86_32 && HAVE_MMXEXT_EXTERNAL
> +                /* MMEXT optimizations */
> +#endif /* ARCH_X86_32 && HAVE_MMXEXT_EXTERNAL */
> +
> +                if (EXTERNAL_SSE2(mm_flags)) {
> +
> +                }
> +                if (EXTERNAL_SSSE3(mm_flags) && ARCH_X86_64) {

[...]

> +                }
> +                if (EXTERNAL_SSE4(mm_flags) && ARCH_X86_64) {

[...]

> +                }
> +                if (EXTERNAL_AVX(mm_flags)) {
> +                }
> +            }
> +        }
> +    } else if (bit_depth == 10) {
> +        if (EXTERNAL_MMX(mm_flags)) {
> +            if (EXTERNAL_MMXEXT(mm_flags)) {
> +                if (EXTERNAL_SSE2(mm_flags)) {
> +                }
> +                if (EXTERNAL_SSE4(mm_flags) && ARCH_X86_64) {

[...]

> +                }
> +                if (EXTERNAL_AVX(mm_flags)) {
> +                }
> +            }
> +        }
> +    }
> +}

There's no need to chain ifs like this, and there's no need to 
check for flags of instruction sets you're not going to use.

So for the functions you're declaring atm, something like this 
will look cleaner:

#if ARCH_X86_64
    if (bit_depth == 8) {
        if (EXTERNAL_SSSE3(mm_flags)) {
           /* 8bit x86_64 SSSE3 init */
        }
        if (EXTERNAL_SSE4(mm_flags)) {
           /* 8bit x86_64 SSE4 init */
        }
    } else if (bit_depth == 10) {
        if (EXTERNAL_SSE4(mm_flags)) {
           /* 10bit x86_64 SSE4 init */
        }
    }
#endif /* ARCH_X86_64 */

New checks and function pointers can be added and/or moved as 
needed.


More information about the ffmpeg-devel mailing list