diff options
author | Mans Rullgard <mans@mansr.com> | 2012-04-21 18:31:10 +0400 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2012-04-22 15:30:45 +0400 |
commit | d526c5338d50d12a54fd95130030c60070707d3e (patch) | |
tree | 5cac97b8414872d2bdf977292e63ef8edf3eb49a /libavcodec/arm | |
parent | d7458bc8c62ae1cb2ffc805b989fcddf4029dda6 (diff) |
ARM: allow runtime masking of CPU features
This allows masking CPU features with the -cpuflags avconv option
which is useful for testing different optimisations without rebuilding.
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavcodec/arm')
-rw-r--r-- | libavcodec/arm/ac3dsp_init_arm.c | 8 | ||||
-rw-r--r-- | libavcodec/arm/dcadsp_init_arm.c | 6 | ||||
-rw-r--r-- | libavcodec/arm/dsputil_init_arm.c | 10 | ||||
-rw-r--r-- | libavcodec/arm/dsputil_init_vfp.c | 5 | ||||
-rw-r--r-- | libavcodec/arm/fft_fixed_init_arm.c | 6 | ||||
-rw-r--r-- | libavcodec/arm/fft_init_arm.c | 13 | ||||
-rw-r--r-- | libavcodec/arm/fmtconvert_init_arm.c | 7 | ||||
-rw-r--r-- | libavcodec/arm/h264dsp_init_arm.c | 6 | ||||
-rw-r--r-- | libavcodec/arm/h264pred_init_arm.c | 6 | ||||
-rw-r--r-- | libavcodec/arm/mpegaudiodsp_init_arm.c | 6 | ||||
-rw-r--r-- | libavcodec/arm/mpegvideo_arm.c | 10 | ||||
-rw-r--r-- | libavcodec/arm/sbrdsp_init_arm.c | 5 | ||||
-rw-r--r-- | libavcodec/arm/vp56dsp_init_arm.c | 6 | ||||
-rw-r--r-- | libavcodec/arm/vp8dsp_init_arm.c | 6 |
14 files changed, 76 insertions, 24 deletions
diff --git a/libavcodec/arm/ac3dsp_init_arm.c b/libavcodec/arm/ac3dsp_init_arm.c index aed11f4bb8..d7cb95b669 100644 --- a/libavcodec/arm/ac3dsp_init_arm.c +++ b/libavcodec/arm/ac3dsp_init_arm.c @@ -19,6 +19,8 @@ */ #include <stdint.h> + +#include "libavutil/arm/cpu.h" #include "libavutil/attributes.h" #include "libavcodec/ac3dsp.h" #include "config.h" @@ -39,13 +41,15 @@ void ff_ac3_update_bap_counts_arm(uint16_t mant_cnt[16], uint8_t *bap, int len); av_cold void ff_ac3dsp_init_arm(AC3DSPContext *c, int bit_exact) { + int cpu_flags = av_get_cpu_flags(); + c->update_bap_counts = ff_ac3_update_bap_counts_arm; - if (HAVE_ARMV6) { + if (have_armv6(cpu_flags)) { c->bit_alloc_calc_bap = ff_ac3_bit_alloc_calc_bap_armv6; } - if (HAVE_NEON) { + if (have_neon(cpu_flags)) { c->ac3_exponent_min = ff_ac3_exponent_min_neon; c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_neon; c->ac3_lshift_int16 = ff_ac3_lshift_int16_neon; diff --git a/libavcodec/arm/dcadsp_init_arm.c b/libavcodec/arm/dcadsp_init_arm.c index ec7016ef20..f0375c9710 100644 --- a/libavcodec/arm/dcadsp_init_arm.c +++ b/libavcodec/arm/dcadsp_init_arm.c @@ -19,6 +19,8 @@ */ #include "config.h" + +#include "libavutil/arm/cpu.h" #include "libavutil/attributes.h" #include "libavcodec/dcadsp.h" @@ -27,6 +29,8 @@ void ff_dca_lfe_fir_neon(float *out, const float *in, const float *coefs, av_cold void ff_dcadsp_init_arm(DCADSPContext *s) { - if (HAVE_NEON) + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) s->lfe_fir = ff_dca_lfe_fir_neon; } diff --git a/libavcodec/arm/dsputil_init_arm.c b/libavcodec/arm/dsputil_init_arm.c index bc94b08d2a..0c1563df93 100644 --- a/libavcodec/arm/dsputil_init_arm.c +++ b/libavcodec/arm/dsputil_init_arm.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/arm/cpu.h" #include "libavcodec/dsputil.h" #include "dsputil_arm.h" @@ -76,6 +77,7 @@ static void simple_idct_arm_add(uint8_t *dest, int line_size, DCTELEM *block) void ff_dsputil_init_arm(DSPContext* c, AVCodecContext *avctx) { const int high_bit_depth = avctx->bits_per_raw_sample > 8; + int cpu_flags = av_get_cpu_flags(); ff_put_pixels_clamped = c->put_pixels_clamped; ff_add_pixels_clamped = c->add_pixels_clamped; @@ -117,8 +119,8 @@ void ff_dsputil_init_arm(DSPContext* c, AVCodecContext *avctx) c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_arm; } - if (HAVE_ARMV5TE) ff_dsputil_init_armv5te(c, avctx); - if (HAVE_ARMV6) ff_dsputil_init_armv6(c, avctx); - if (HAVE_ARMVFP) ff_dsputil_init_vfp(c, avctx); - if (HAVE_NEON) ff_dsputil_init_neon(c, avctx); + if (have_armv5te(cpu_flags)) ff_dsputil_init_armv5te(c, avctx); + if (have_armv6(cpu_flags)) ff_dsputil_init_armv6(c, avctx); + if (have_vfp(cpu_flags)) ff_dsputil_init_vfp(c, avctx); + if (have_neon(cpu_flags)) ff_dsputil_init_neon(c, avctx); } diff --git a/libavcodec/arm/dsputil_init_vfp.c b/libavcodec/arm/dsputil_init_vfp.c index 9cda890411..d5e2d3b4ef 100644 --- a/libavcodec/arm/dsputil_init_vfp.c +++ b/libavcodec/arm/dsputil_init_vfp.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/arm/cpu.h" #include "libavcodec/dsputil.h" #include "dsputil_arm.h" @@ -28,7 +29,9 @@ void ff_vector_fmul_reverse_vfp(float *dst, const float *src0, void ff_dsputil_init_vfp(DSPContext* c, AVCodecContext *avctx) { - if (!HAVE_VFPV3) + int cpu_flags = av_get_cpu_flags(); + + if (!have_vfpv3(cpu_flags)) c->vector_fmul = ff_vector_fmul_vfp; c->vector_fmul_reverse = ff_vector_fmul_reverse_vfp; } diff --git a/libavcodec/arm/fft_fixed_init_arm.c b/libavcodec/arm/fft_fixed_init_arm.c index be412cde05..5601ba1a5c 100644 --- a/libavcodec/arm/fft_fixed_init_arm.c +++ b/libavcodec/arm/fft_fixed_init_arm.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/arm/cpu.h" + #define CONFIG_FFT_FLOAT 0 #include "libavcodec/fft.h" @@ -27,7 +29,9 @@ void ff_mdct_fixed_calcw_neon(FFTContext *s, FFTDouble *o, const FFTSample *i); av_cold void ff_fft_fixed_init_arm(FFTContext *s) { - if (HAVE_NEON) { + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) { s->fft_permutation = FF_FFT_PERM_SWAP_LSBS; s->fft_calc = ff_fft_fixed_calc_neon; diff --git a/libavcodec/arm/fft_init_arm.c b/libavcodec/arm/fft_init_arm.c index b2c3b721fd..9ec620f2d2 100644 --- a/libavcodec/arm/fft_init_arm.c +++ b/libavcodec/arm/fft_init_arm.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/arm/cpu.h" #include "libavcodec/fft.h" #include "libavcodec/rdft.h" #include "libavcodec/synth_filter.h" @@ -39,7 +40,9 @@ void ff_synth_filter_float_neon(FFTContext *imdct, av_cold void ff_fft_init_arm(FFTContext *s) { - if (HAVE_NEON) { + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) { s->fft_permute = ff_fft_permute_neon; s->fft_calc = ff_fft_calc_neon; #if CONFIG_MDCT @@ -54,7 +57,9 @@ av_cold void ff_fft_init_arm(FFTContext *s) #if CONFIG_RDFT av_cold void ff_rdft_init_arm(RDFTContext *s) { - if (HAVE_NEON) + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) s->rdft_calc = ff_rdft_calc_neon; } #endif @@ -62,7 +67,9 @@ av_cold void ff_rdft_init_arm(RDFTContext *s) #if CONFIG_DCA_DECODER av_cold void ff_synth_filter_init_arm(SynthFilterContext *s) { - if (HAVE_NEON) + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) s->synth_filter_float = ff_synth_filter_float_neon; } #endif diff --git a/libavcodec/arm/fmtconvert_init_arm.c b/libavcodec/arm/fmtconvert_init_arm.c index 92e07f17a0..94352636c2 100644 --- a/libavcodec/arm/fmtconvert_init_arm.c +++ b/libavcodec/arm/fmtconvert_init_arm.c @@ -20,6 +20,7 @@ #include <stdint.h> +#include "libavutil/arm/cpu.h" #include "libavcodec/avcodec.h" #include "libavcodec/fmtconvert.h" @@ -33,11 +34,13 @@ void ff_float_to_int16_vfp(int16_t *dst, const float *src, long len); void ff_fmt_convert_init_arm(FmtConvertContext *c, AVCodecContext *avctx) { - if (HAVE_ARMVFP && HAVE_ARMV6) { + int cpu_flags = av_get_cpu_flags(); + + if (have_vfp(cpu_flags) && have_armv6(cpu_flags)) { c->float_to_int16 = ff_float_to_int16_vfp; } - if (HAVE_NEON) { + if (have_neon(cpu_flags)) { c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_neon; if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { diff --git a/libavcodec/arm/h264dsp_init_arm.c b/libavcodec/arm/h264dsp_init_arm.c index 1c331a495d..b4277a514f 100644 --- a/libavcodec/arm/h264dsp_init_arm.c +++ b/libavcodec/arm/h264dsp_init_arm.c @@ -20,6 +20,7 @@ #include <stdint.h> +#include "libavutil/arm/cpu.h" #include "libavcodec/dsputil.h" #include "libavcodec/h264dsp.h" @@ -97,5 +98,8 @@ static void ff_h264dsp_init_neon(H264DSPContext *c, const int bit_depth, const i void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) { - if (HAVE_NEON) ff_h264dsp_init_neon(c, bit_depth, chroma_format_idc); + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) + ff_h264dsp_init_neon(c, bit_depth, chroma_format_idc); } diff --git a/libavcodec/arm/h264pred_init_arm.c b/libavcodec/arm/h264pred_init_arm.c index 5fc07bc137..808cc54d5a 100644 --- a/libavcodec/arm/h264pred_init_arm.c +++ b/libavcodec/arm/h264pred_init_arm.c @@ -20,6 +20,7 @@ #include <stdint.h> +#include "libavutil/arm/cpu.h" #include "libavcodec/h264pred.h" void ff_pred16x16_vert_neon(uint8_t *src, int stride); @@ -76,5 +77,8 @@ static void ff_h264_pred_init_neon(H264PredContext *h, int codec_id, const int b void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, int bit_depth, const int chroma_format_idc) { - if (HAVE_NEON) ff_h264_pred_init_neon(h, codec_id, bit_depth, chroma_format_idc); + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) + ff_h264_pred_init_neon(h, codec_id, bit_depth, chroma_format_idc); } diff --git a/libavcodec/arm/mpegaudiodsp_init_arm.c b/libavcodec/arm/mpegaudiodsp_init_arm.c index 94a55787ad..a9804e976c 100644 --- a/libavcodec/arm/mpegaudiodsp_init_arm.c +++ b/libavcodec/arm/mpegaudiodsp_init_arm.c @@ -19,6 +19,8 @@ */ #include <stdint.h> + +#include "libavutil/arm/cpu.h" #include "libavcodec/mpegaudiodsp.h" #include "config.h" @@ -27,7 +29,9 @@ void ff_mpadsp_apply_window_fixed_armv6(int32_t *synth_buf, int32_t *window, void ff_mpadsp_init_arm(MPADSPContext *s) { - if (HAVE_ARMV6) { + int cpu_flags = av_get_cpu_flags(); + + if (have_armv6(cpu_flags)) { s->apply_window_fixed = ff_mpadsp_apply_window_fixed_armv6; } } diff --git a/libavcodec/arm/mpegvideo_arm.c b/libavcodec/arm/mpegvideo_arm.c index 26eed89930..cce90c75ea 100644 --- a/libavcodec/arm/mpegvideo_arm.c +++ b/libavcodec/arm/mpegvideo_arm.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/arm/cpu.h" #include "libavcodec/avcodec.h" #include "libavcodec/dsputil.h" #include "libavcodec/mpegvideo.h" @@ -40,11 +41,12 @@ void ff_dct_unquantize_h263_intra_neon(MpegEncContext *s, DCTELEM *block, void ff_MPV_common_init_arm(MpegEncContext *s) { -#if HAVE_ARMV5TE - ff_MPV_common_init_armv5te(s); -#endif + int cpu_flags = av_get_cpu_flags(); + + if (have_armv5te(cpu_flags)) + ff_MPV_common_init_armv5te(s); - if (HAVE_NEON) { + if (have_neon(cpu_flags)) { s->dct_unquantize_h263_intra = ff_dct_unquantize_h263_intra_neon; s->dct_unquantize_h263_inter = ff_dct_unquantize_h263_inter_neon; } diff --git a/libavcodec/arm/sbrdsp_init_arm.c b/libavcodec/arm/sbrdsp_init_arm.c index 04294cc401..4da7967b49 100644 --- a/libavcodec/arm/sbrdsp_init_arm.c +++ b/libavcodec/arm/sbrdsp_init_arm.c @@ -19,6 +19,7 @@ */ #include "config.h" +#include "libavutil/arm/cpu.h" #include "libavutil/attributes.h" #include "libavcodec/sbrdsp.h" @@ -51,7 +52,9 @@ void ff_sbr_hf_apply_noise_3_neon(float Y[64][2], const float *s_m, av_cold void ff_sbrdsp_init_arm(SBRDSPContext *s) { - if (HAVE_NEON) { + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) { s->sum64x5 = ff_sbr_sum64x5_neon; s->sum_square = ff_sbr_sum_square_neon; s->neg_odd_64 = ff_sbr_neg_odd_64_neon; diff --git a/libavcodec/arm/vp56dsp_init_arm.c b/libavcodec/arm/vp56dsp_init_arm.c index 598960251a..691db584da 100644 --- a/libavcodec/arm/vp56dsp_init_arm.c +++ b/libavcodec/arm/vp56dsp_init_arm.c @@ -19,6 +19,8 @@ */ #include <stdint.h> + +#include "libavutil/arm/cpu.h" #include "libavcodec/avcodec.h" #include "libavcodec/vp56dsp.h" @@ -27,7 +29,9 @@ void ff_vp6_edge_filter_ver_neon(uint8_t *yuv, int stride, int t); void ff_vp56dsp_init_arm(VP56DSPContext *s, enum CodecID codec) { - if (codec != CODEC_ID_VP5 && HAVE_NEON) { + int cpu_flags = av_get_cpu_flags(); + + if (codec != CODEC_ID_VP5 && have_neon(cpu_flags)) { s->edge_filter_hor = ff_vp6_edge_filter_hor_neon; s->edge_filter_ver = ff_vp6_edge_filter_ver_neon; } diff --git a/libavcodec/arm/vp8dsp_init_arm.c b/libavcodec/arm/vp8dsp_init_arm.c index 83f36345f5..29c64d4079 100644 --- a/libavcodec/arm/vp8dsp_init_arm.c +++ b/libavcodec/arm/vp8dsp_init_arm.c @@ -17,6 +17,8 @@ */ #include <stdint.h> + +#include "libavutil/arm/cpu.h" #include "libavcodec/vp8dsp.h" void ff_vp8_luma_dc_wht_neon(DCTELEM block[4][4][16], DCTELEM dc[16]); @@ -83,7 +85,9 @@ VP8_MC(bilin4_hv); av_cold void ff_vp8dsp_init_arm(VP8DSPContext *dsp) { - if (HAVE_NEON) { + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) { dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_neon; dsp->vp8_luma_dc_wht_dc = ff_vp8_luma_dc_wht_dc_neon; |