FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
cpu.c File Reference
#include <stddef.h>
#include <stdint.h>
#include <stdatomic.h>
#include "attributes.h"
#include "cpu.h"
#include "cpu_internal.h"
#include "config.h"
#include "opt.h"
#include "common.h"

Go to the source code of this file.

Macros

#define CPUFLAG_MMXEXT   (AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT | AV_CPU_FLAG_CMOV)
 
#define CPUFLAG_3DNOW   (AV_CPU_FLAG_3DNOW | AV_CPU_FLAG_MMX)
 
#define CPUFLAG_3DNOWEXT   (AV_CPU_FLAG_3DNOWEXT | CPUFLAG_3DNOW)
 
#define CPUFLAG_SSE   (AV_CPU_FLAG_SSE | CPUFLAG_MMXEXT)
 
#define CPUFLAG_SSE2   (AV_CPU_FLAG_SSE2 | CPUFLAG_SSE)
 
#define CPUFLAG_SSE2SLOW   (AV_CPU_FLAG_SSE2SLOW | CPUFLAG_SSE2)
 
#define CPUFLAG_SSE3   (AV_CPU_FLAG_SSE3 | CPUFLAG_SSE2)
 
#define CPUFLAG_SSE3SLOW   (AV_CPU_FLAG_SSE3SLOW | CPUFLAG_SSE3)
 
#define CPUFLAG_SSSE3   (AV_CPU_FLAG_SSSE3 | CPUFLAG_SSE3)
 
#define CPUFLAG_SSE4   (AV_CPU_FLAG_SSE4 | CPUFLAG_SSSE3)
 
#define CPUFLAG_SSE42   (AV_CPU_FLAG_SSE42 | CPUFLAG_SSE4)
 
#define CPUFLAG_AVX   (AV_CPU_FLAG_AVX | CPUFLAG_SSE42)
 
#define CPUFLAG_AVXSLOW   (AV_CPU_FLAG_AVXSLOW | CPUFLAG_AVX)
 
#define CPUFLAG_XOP   (AV_CPU_FLAG_XOP | CPUFLAG_AVX)
 
#define CPUFLAG_FMA3   (AV_CPU_FLAG_FMA3 | CPUFLAG_AVX)
 
#define CPUFLAG_FMA4   (AV_CPU_FLAG_FMA4 | CPUFLAG_AVX)
 
#define CPUFLAG_AVX2   (AV_CPU_FLAG_AVX2 | CPUFLAG_AVX)
 
#define CPUFLAG_BMI2   (AV_CPU_FLAG_BMI2 | AV_CPU_FLAG_BMI1)
 
#define CPUFLAG_AESNI   (AV_CPU_FLAG_AESNI | CPUFLAG_SSE42)
 

Functions

static int get_cpu_flags (void)
 
void av_force_cpu_flags (int arg)
 Disables cpu detection and forces the specified flags. More...
 
int av_get_cpu_flags (void)
 Return the flags which specify extensions supported by the CPU. More...
 
void av_set_cpu_flags_mask (int mask)
 Set a mask on flags returned by av_get_cpu_flags(). More...
 
int av_parse_cpu_flags (const char *s)
 Parse CPU flags from a string. More...
 
int av_parse_cpu_caps (unsigned *flags, const char *s)
 Parse CPU caps from a string and update the given AV_CPU_* flags based on that. More...
 
int av_cpu_count (void)
 
size_t av_cpu_max_align (void)
 Get the maximum data alignment that may be required by FFmpeg. More...
 

Variables

static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1)
 

Macro Definition Documentation

#define CPUFLAG_MMXEXT   (AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT | AV_CPU_FLAG_CMOV)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_3DNOW   (AV_CPU_FLAG_3DNOW | AV_CPU_FLAG_MMX)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_3DNOWEXT   (AV_CPU_FLAG_3DNOWEXT | CPUFLAG_3DNOW)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_SSE   (AV_CPU_FLAG_SSE | CPUFLAG_MMXEXT)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_SSE2   (AV_CPU_FLAG_SSE2 | CPUFLAG_SSE)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_SSE2SLOW   (AV_CPU_FLAG_SSE2SLOW | CPUFLAG_SSE2)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_SSE3   (AV_CPU_FLAG_SSE3 | CPUFLAG_SSE2)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_SSE3SLOW   (AV_CPU_FLAG_SSE3SLOW | CPUFLAG_SSE3)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_SSSE3   (AV_CPU_FLAG_SSSE3 | CPUFLAG_SSE3)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_SSE4   (AV_CPU_FLAG_SSE4 | CPUFLAG_SSSE3)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_SSE42   (AV_CPU_FLAG_SSE42 | CPUFLAG_SSE4)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_AVX   (AV_CPU_FLAG_AVX | CPUFLAG_SSE42)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_AVXSLOW   (AV_CPU_FLAG_AVXSLOW | CPUFLAG_AVX)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_XOP   (AV_CPU_FLAG_XOP | CPUFLAG_AVX)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_FMA3   (AV_CPU_FLAG_FMA3 | CPUFLAG_AVX)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_FMA4   (AV_CPU_FLAG_FMA4 | CPUFLAG_AVX)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_AVX2   (AV_CPU_FLAG_AVX2 | CPUFLAG_AVX)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_BMI2   (AV_CPU_FLAG_BMI2 | AV_CPU_FLAG_BMI1)

Referenced by av_parse_cpu_flags().

#define CPUFLAG_AESNI   (AV_CPU_FLAG_AESNI | CPUFLAG_SSE42)

Referenced by av_parse_cpu_flags().

Function Documentation

static int get_cpu_flags ( void  )
static

Definition at line 52 of file cpu.c.

Referenced by av_get_cpu_flags(), and av_set_cpu_flags_mask().

void av_force_cpu_flags ( int  flags)

Disables cpu detection and forces the specified flags.

-1 is a special case that disables forcing of specific flags.

Definition at line 65 of file cpu.c.

Referenced by check_cpu_flag(), main(), and opt_cpuflags().

int av_get_cpu_flags ( void  )

Return the flags which specify extensions supported by the CPU.

The returned value is affected by av_force_cpu_flags() if that was used before. So av_get_cpu_flags() can easily be used in an application to detect the enabled cpu flags.

Definition at line 92 of file cpu.c.

Referenced by check_cpu_flag(), D(), define_8tap_2d_funcs(), ff_aac_dsp_init_x86(), ff_ac3dsp_init_arm(), ff_ac3dsp_init_x86(), ff_ac3dsp_set_downmix_x86(), ff_afir_init_x86(), ff_alacdsp_init_x86(), ff_audio_convert_init_aarch64(), ff_audio_convert_init_arm(), ff_audio_convert_init_x86(), ff_audio_mix_init_x86(), ff_audio_resample_init_aarch64(), ff_audio_resample_init_arm(), ff_audiodsp_init_arm(), ff_audiodsp_init_ppc(), ff_audiodsp_init_x86(), ff_blend_init_x86(), ff_blockdsp_init_arm(), ff_blockdsp_init_ppc(), ff_blockdsp_init_x86(), ff_bswapdsp_init_x86(), ff_bwdif_init_x86(), ff_cavsdsp_init_x86(), ff_colorspacedsp_x86_init(), ff_dcadsp_init_x86(), ff_dct_encode_init_x86(), ff_dct_init_x86(), ff_diracdsp_init_x86(), ff_dither_init_x86(), ff_dnxhdenc_init_x86(), ff_dwt_init_x86(), ff_eq_init_x86(), ff_exrdsp_init_x86(), ff_fdctdsp_init_ppc(), ff_fdctdsp_init_x86(), ff_fft_fixed_init_arm(), ff_fft_init_aarch64(), ff_fft_init_arm(), ff_fft_init_ppc(), ff_fft_init_x86(), ff_fixed_dsp_init_x86(), ff_flacdsp_init_x86(), ff_float_dsp_init_aarch64(), ff_float_dsp_init_arm(), ff_float_dsp_init_ppc(), ff_float_dsp_init_x86(), ff_fmt_convert_init_aarch64(), ff_fmt_convert_init_arm(), ff_fmt_convert_init_ppc(), ff_fmt_convert_init_x86(), ff_fspp_init_x86(), ff_g722dsp_init_arm(), ff_g722dsp_init_x86(), ff_get_cpu_max_align_aarch64(), ff_get_cpu_max_align_arm(), ff_get_cpu_max_align_ppc(), ff_get_cpu_max_align_x86(), ff_get_unscaled_swscale_aarch64(), ff_get_unscaled_swscale_arm(), ff_get_unscaled_swscale_ppc(), ff_gradfun_init_x86(), ff_h263dsp_init_x86(), ff_h264_pred_init_aarch64(), ff_h264_pred_init_arm(), ff_h264chroma_init_aarch64(), ff_h264chroma_init_arm(), ff_h264chroma_init_ppc(), ff_h264chroma_init_x86(), ff_h264dsp_init_aarch64(), ff_h264dsp_init_arm(), ff_h264dsp_init_ppc(), ff_h264dsp_init_x86(), ff_h264qpel_init_aarch64(), ff_h264qpel_init_arm(), ff_h264qpel_init_ppc(), ff_h264qpel_init_x86(), ff_hevc_dsp_init_ppc(), ff_hevc_dsp_init_x86(), ff_hevcdsp_init_arm(), ff_hpeldsp_init_aarch64(), ff_hpeldsp_init_arm(), ff_hpeldsp_init_ppc(), ff_hpeldsp_init_x86(), ff_huffyuvdsp_init_x86(), ff_huffyuvencdsp_init_x86(), ff_idctdsp_init_arm(), ff_idctdsp_init_ppc(), ff_idctdsp_init_x86(), ff_idet_init_x86(), ff_image_copy_plane_uc_from_x86(), ff_init_lls_x86(), ff_interlace_init_x86(), ff_jpeg2000dsp_init_x86(), ff_limiter_init_x86(), ff_llauddsp_init_arm(), ff_llauddsp_init_ppc(), ff_llauddsp_init_x86(), ff_llviddsp_init_ppc(), ff_llviddsp_init_x86(), ff_llvidencdsp_init_x86(), ff_lpc_init_x86(), ff_maskedmerge_init_x86(), ff_mdct15_init_x86(), ff_me_cmp_init_arm(), ff_me_cmp_init_ppc(), ff_mlpdsp_init_arm(), ff_mlpdsp_init_x86(), ff_mpadsp_init_aarch64(), ff_mpadsp_init_arm(), ff_mpadsp_init_ppc(), ff_mpadsp_init_x86(), ff_mpegvideodsp_init_ppc(), ff_mpegvideodsp_init_x86(), ff_mpegvideoencdsp_init_arm(), ff_mpegvideoencdsp_init_ppc(), ff_mpegvideoencdsp_init_x86(), ff_mpv_common_init_arm(), ff_mpv_common_init_neon(), ff_mpv_common_init_ppc(), ff_mpv_common_init_x86(), ff_noise_init_x86(), ff_opus_dsp_init_x86(), ff_pixblockdsp_init_arm(), ff_pixblockdsp_init_ppc(), ff_pixblockdsp_init_x86(), ff_pixelutils_sad_init_x86(), ff_pngdsp_init_x86(), ff_pp7_init_x86(), ff_proresdsp_init_x86(), ff_psdsp_init_aarch64(), ff_psdsp_init_arm(), ff_psdsp_init_x86(), ff_psnr_init_x86(), ff_pullup_init_x86(), ff_qpeldsp_init_x86(), ff_rdft_init_arm(), ff_removegrain_init_x86(), ff_rv34dsp_init_arm(), ff_rv34dsp_init_x86(), ff_rv40dsp_init_aarch64(), ff_rv40dsp_init_arm(), ff_rv40dsp_init_x86(), ff_sbrdsp_init_aarch64(), ff_sbrdsp_init_arm(), ff_sbrdsp_init_x86(), ff_showcqt_init_x86(), ff_spatial_idwt_init_x86(), ff_spp_init_x86(), ff_ssim_init_x86(), ff_stereo3d_init_x86(), ff_svq1enc_init_ppc(), ff_svq1enc_init_x86(), ff_sws_init_swscale_aarch64(), ff_sws_init_swscale_arm(), ff_sws_init_swscale_ppc(), ff_sws_init_swscale_x86(), ff_synth_filter_init_aarch64(), ff_synth_filter_init_arm(), ff_synth_filter_init_x86(), ff_takdsp_init_x86(), ff_tinterlace_init_x86(), ff_ttadsp_init_x86(), ff_ttaencdsp_init_x86(), ff_utvideodsp_init_x86(), ff_v210_x86_init(), ff_v210enc_init_x86(), ff_vc1dsp_init_aarch64(), ff_vc1dsp_init_arm(), ff_vc1dsp_init_ppc(), ff_vc1dsp_init_x86(), ff_videodsp_init_aarch64(), ff_videodsp_init_arm(), ff_videodsp_init_x86(), ff_volume_init_x86(), ff_vorbisdsp_init_aarch64(), ff_vorbisdsp_init_arm(), ff_vorbisdsp_init_ppc(), ff_vorbisdsp_init_x86(), ff_vp3dsp_init_arm(), ff_vp3dsp_init_ppc(), ff_vp3dsp_init_x86(), ff_vp6dsp_init_arm(), ff_vp6dsp_init_x86(), ff_vp78dsp_init_arm(), ff_vp78dsp_init_ppc(), ff_vp78dsp_init_x86(), ff_vp8dsp_init_arm(), ff_vp8dsp_init_x86(), ff_vp9dsp_init_16bpp_x86(), ff_vp9dsp_init_x86(), ff_w3fdif_init_x86(), ff_xvid_idct_init_x86(), ff_yadif_init_x86(), ff_yuv2rgb_init_ppc(), ff_yuv2rgb_init_tables_ppc(), ff_yuv2rgb_init_x86(), INIT_FUNC(), lf_mix_fns(), main(), multiple_resample(), opt_cpuflags(), pp_get_context(), PRED4x4(), rgb2rgb_init_x86(), swri_audio_convert_init_aarch64(), swri_audio_convert_init_arm(), swri_audio_convert_init_x86(), swri_resample_dsp_aarch64_init(), swri_resample_dsp_arm_init(), swri_resample_dsp_x86_init(), sws_init_context(), swscale(), thread_main(), vp9dsp_itxfm_init_aarch64(), vp9dsp_itxfm_init_arm(), vp9dsp_loopfilter_init_aarch64(), and vp9dsp_loopfilter_init_arm().

void av_set_cpu_flags_mask ( int  mask)

Set a mask on flags returned by av_get_cpu_flags().

This function is mainly useful for testing. Please use av_force_cpu_flags() and av_get_cpu_flags() instead which are more flexible

Definition at line 102 of file cpu.c.

int av_parse_cpu_flags ( const char *  s)

Parse CPU flags from a string.

The returned flags contain the specified flags as well as related unspecified flags.

This function exists only for compatibility with libav. Please use av_parse_cpu_caps() when possible.

Returns
a combination of AV_CPU_* flags, negative on error.

Definition at line 108 of file cpu.c.

int av_parse_cpu_caps ( unsigned *  flags,
const char *  s 
)

Parse CPU caps from a string and update the given AV_CPU_* flags based on that.

Returns
negative on error.

Definition at line 188 of file cpu.c.

Referenced by main(), and opt_cpuflags().

int av_cpu_count ( void  )
Returns
the number of logical CPU cores present.

Definition at line 263 of file cpu.c.

Referenced by ff_frame_thread_encoder_init(), ff_frame_thread_init(), ff_slice_thread_init(), and main().

size_t av_cpu_max_align ( void  )

Get the maximum data alignment that may be required by FFmpeg.

Note that this is affected by the build configuration and the CPU flags mask, so e.g. if the CPU supports AVX, but libavutil has been built with –disable-avx or the AV_CPU_FLAG_AVX flag has been disabled through av_set_cpu_flags_mask(), then this function will behave as if AVX is not present.

Definition at line 305 of file cpu.c.

Variable Documentation

atomic_int cpu_flags = ATOMIC_VAR_INIT(-1)
static

Definition at line 50 of file cpu.c.

Referenced by av_force_cpu_flags(), av_get_cpu_flags(), av_set_cpu_flags_mask(), define_8tap_2d_funcs(), ff_aac_dsp_init_x86(), ff_ac3dsp_init_arm(), ff_ac3dsp_init_x86(), ff_ac3dsp_set_downmix_x86(), ff_afir_init_x86(), ff_alacdsp_init_x86(), ff_audio_convert_init_aarch64(), ff_audio_convert_init_arm(), ff_audio_convert_init_x86(), ff_audio_mix_init_x86(), ff_audio_resample_init_aarch64(), ff_audio_resample_init_arm(), ff_audiodsp_init_arm(), ff_audiodsp_init_x86(), ff_blend_init_x86(), ff_blockdsp_init_arm(), ff_blockdsp_init_x86(), ff_bswapdsp_init_x86(), ff_bwdif_init_x86(), ff_cavsdsp_init_x86(), ff_colorspacedsp_x86_init(), ff_dcadsp_init_x86(), ff_dct_encode_init_x86(), ff_dct_init_x86(), ff_dither_init_x86(), ff_eq_init_x86(), ff_exrdsp_init_x86(), ff_fdctdsp_init_x86(), ff_fft_fixed_init_arm(), ff_fft_init_aarch64(), ff_fft_init_arm(), ff_fft_init_x86(), ff_fixed_dsp_init_x86(), ff_flacdsp_init_x86(), ff_float_dsp_init_aarch64(), ff_float_dsp_init_arm(), ff_float_dsp_init_x86(), ff_fmt_convert_init_aarch64(), ff_fmt_convert_init_arm(), ff_fmt_convert_init_x86(), ff_fspp_init_x86(), ff_g722dsp_init_arm(), ff_g722dsp_init_x86(), ff_get_unscaled_swscale_aarch64(), ff_get_unscaled_swscale_arm(), ff_gradfun_init_x86(), ff_h263dsp_init_x86(), ff_h264_pred_init_aarch64(), ff_h264_pred_init_arm(), ff_h264chroma_init_aarch64(), ff_h264chroma_init_arm(), ff_h264chroma_init_x86(), ff_h264dsp_init_aarch64(), ff_h264dsp_init_arm(), ff_h264dsp_init_x86(), ff_h264qpel_init_aarch64(), ff_h264qpel_init_arm(), ff_h264qpel_init_x86(), ff_hevc_dsp_init_x86(), ff_hevcdsp_init_arm(), ff_hpeldsp_init_aarch64(), ff_hpeldsp_init_arm(), ff_hpeldsp_init_x86(), ff_huffyuvdsp_init_x86(), ff_huffyuvencdsp_init_x86(), ff_idctdsp_init_arm(), ff_idctdsp_init_x86(), ff_idet_init_x86(), ff_image_copy_plane_uc_from_x86(), ff_init_lls_x86(), ff_interlace_init_x86(), ff_jpeg2000dsp_init_x86(), ff_limiter_init_x86(), ff_llauddsp_init_arm(), ff_llauddsp_init_x86(), ff_llviddsp_init_x86(), ff_llvidencdsp_init_x86(), ff_lpc_init_x86(), ff_maskedmerge_init_x86(), ff_mdct15_init_x86(), ff_me_cmp_init_arm(), ff_mlpdsp_init_arm(), ff_mlpdsp_init_x86(), ff_mpadsp_init_aarch64(), ff_mpadsp_init_arm(), ff_mpadsp_init_x86(), ff_mpegvideodsp_init_x86(), ff_mpegvideoencdsp_init_arm(), ff_mpegvideoencdsp_init_x86(), ff_mpv_common_init_arm(), ff_mpv_common_init_neon(), ff_mpv_common_init_x86(), ff_noise_init_x86(), ff_opus_dsp_init_x86(), ff_pixblockdsp_init_arm(), ff_pixblockdsp_init_x86(), ff_pixelutils_sad_init_x86(), ff_pngdsp_init_x86(), ff_pp7_init_x86(), ff_proresdsp_init_x86(), ff_psdsp_init_aarch64(), ff_psdsp_init_arm(), ff_psdsp_init_x86(), ff_psnr_init_x86(), ff_pullup_init_x86(), ff_qpeldsp_init_x86(), ff_rdft_init_arm(), ff_removegrain_init_x86(), ff_rv34dsp_init_arm(), ff_rv34dsp_init_x86(), ff_rv40dsp_init_aarch64(), ff_rv40dsp_init_arm(), ff_rv40dsp_init_x86(), ff_sbrdsp_init_aarch64(), ff_sbrdsp_init_arm(), ff_sbrdsp_init_x86(), ff_spp_init_x86(), ff_ssim_init_x86(), ff_stereo3d_init_x86(), ff_svq1enc_init_x86(), ff_sws_init_swscale_aarch64(), ff_sws_init_swscale_arm(), ff_sws_init_swscale_x86(), ff_synth_filter_init_aarch64(), ff_synth_filter_init_arm(), ff_synth_filter_init_x86(), ff_takdsp_init_x86(), ff_tinterlace_init_x86(), ff_ttadsp_init_x86(), ff_ttaencdsp_init_x86(), ff_utvideodsp_init_x86(), ff_v210_x86_init(), ff_v210enc_init_x86(), ff_vc1dsp_init_aarch64(), ff_vc1dsp_init_arm(), ff_vc1dsp_init_x86(), ff_videodsp_init_aarch64(), ff_videodsp_init_arm(), ff_videodsp_init_x86(), ff_volume_init_x86(), ff_vorbisdsp_init_aarch64(), ff_vorbisdsp_init_arm(), ff_vorbisdsp_init_x86(), ff_vp3dsp_init_arm(), ff_vp3dsp_init_x86(), ff_vp6dsp_init_arm(), ff_vp6dsp_init_x86(), ff_vp78dsp_init_arm(), ff_vp78dsp_init_x86(), ff_vp8dsp_init_arm(), ff_vp8dsp_init_x86(), ff_vp9dsp_init_16bpp_x86(), ff_vp9dsp_init_x86(), ff_w3fdif_init_x86(), ff_xvid_idct_init_x86(), ff_yadif_init_x86(), ff_yuv2rgb_init_x86(), INIT_FUNC(), lf_mix_fns(), main(), PRED4x4(), rgb2rgb_init_x86(), swri_audio_convert_init_aarch64(), swri_audio_convert_init_arm(), swri_resample_dsp_aarch64_init(), swri_resample_dsp_arm_init(), sws_init_context(), swscale(), vp9dsp_itxfm_init_aarch64(), vp9dsp_itxfm_init_arm(), vp9dsp_loopfilter_init_aarch64(), and vp9dsp_loopfilter_init_arm().