diff options
author | Henrik Gramner <gramner@twoorioles.com> | 2019-05-09 21:39:08 +0300 |
---|---|---|
committer | Henrik Gramner <henrik@gramner.com> | 2019-05-10 00:35:04 +0300 |
commit | 8d2dd439005f72e2f73fc6155f0c2245cbf3227f (patch) | |
tree | 53ccb8ad8bd2fb4839eaf1e9f0e06596e4b7ccb1 /src | |
parent | d400361524ce739db30d552a9e54809d812710c6 (diff) |
Add __attribute__((cold)) to rarely used functions
Diffstat (limited to 'src')
-rw-r--r-- | src/arm/cdef_init_tmpl.c | 3 | ||||
-rw-r--r-- | src/arm/cpu.c | 4 | ||||
-rw-r--r-- | src/arm/loopfilter_init_tmpl.c | 2 | ||||
-rw-r--r-- | src/arm/looprestoration_init_tmpl.c | 4 | ||||
-rw-r--r-- | src/cdef_tmpl.c | 2 | ||||
-rw-r--r-- | src/cpu.c | 4 | ||||
-rw-r--r-- | src/cpu.h | 2 | ||||
-rw-r--r-- | src/ipred_tmpl.c | 2 | ||||
-rw-r--r-- | src/itx_tmpl.c | 2 | ||||
-rw-r--r-- | src/lib.c | 14 | ||||
-rw-r--r-- | src/log.c | 6 | ||||
-rw-r--r-- | src/loopfilter_tmpl.c | 2 | ||||
-rw-r--r-- | src/looprestoration_tmpl.c | 2 | ||||
-rw-r--r-- | src/mc_tmpl.c | 2 | ||||
-rw-r--r-- | src/qm.c | 4 | ||||
-rw-r--r-- | src/wedge.c | 26 | ||||
-rw-r--r-- | src/win32/thread.c | 16 | ||||
-rw-r--r-- | src/x86/cdef_init_tmpl.c | 2 | ||||
-rw-r--r-- | src/x86/cpu.c | 4 | ||||
-rw-r--r-- | src/x86/ipred_init_tmpl.c | 2 | ||||
-rw-r--r-- | src/x86/itx_init_tmpl.c | 2 | ||||
-rw-r--r-- | src/x86/loopfilter_init_tmpl.c | 2 | ||||
-rw-r--r-- | src/x86/looprestoration_init_tmpl.c | 3 | ||||
-rw-r--r-- | src/x86/mc_init_tmpl.c | 2 |
24 files changed, 59 insertions, 55 deletions
diff --git a/src/arm/cdef_init_tmpl.c b/src/arm/cdef_init_tmpl.c index a7d58ff..6719163 100644 --- a/src/arm/cdef_init_tmpl.c +++ b/src/arm/cdef_init_tmpl.c @@ -24,7 +24,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "common/attributes.h" #include "src/cpu.h" #include "src/cdef.h" @@ -72,7 +71,7 @@ DEFINE_FILTER(4, 4, 8) #endif -void bitfn(dav1d_cdef_dsp_init_arm)(Dav1dCdefDSPContext *const c) { +COLD void bitfn(dav1d_cdef_dsp_init_arm)(Dav1dCdefDSPContext *const c) { const unsigned flags = dav1d_get_cpu_flags(); if (!(flags & DAV1D_ARM_CPU_FLAG_NEON)) return; diff --git a/src/arm/cpu.c b/src/arm/cpu.c index e2767a0..a7a96b6 100644 --- a/src/arm/cpu.c +++ b/src/arm/cpu.c @@ -27,6 +27,8 @@ #include "config.h" +#include "common/attributes.h" + #include "src/arm/cpu.h" #if defined(HAVE_GETAUXVAL) && ARCH_ARM @@ -73,7 +75,7 @@ static unsigned parse_proc_cpuinfo(const char *flag) { } #endif -unsigned dav1d_get_cpu_flags_arm(void) { +COLD unsigned dav1d_get_cpu_flags_arm(void) { unsigned flags = 0; #if ARCH_AARCH64 flags |= DAV1D_ARM_CPU_FLAG_NEON; diff --git a/src/arm/loopfilter_init_tmpl.c b/src/arm/loopfilter_init_tmpl.c index de4e8d2..1394b76 100644 --- a/src/arm/loopfilter_init_tmpl.c +++ b/src/arm/loopfilter_init_tmpl.c @@ -33,7 +33,7 @@ decl_loopfilter_sb_fn(dav1d_lpf_v_sb_y_neon); decl_loopfilter_sb_fn(dav1d_lpf_h_sb_uv_neon); decl_loopfilter_sb_fn(dav1d_lpf_v_sb_uv_neon); -void bitfn(dav1d_loop_filter_dsp_init_arm)(Dav1dLoopFilterDSPContext *const c) { +COLD void bitfn(dav1d_loop_filter_dsp_init_arm)(Dav1dLoopFilterDSPContext *const c) { const unsigned flags = dav1d_get_cpu_flags(); if (!(flags & DAV1D_ARM_CPU_FLAG_NEON)) return; diff --git a/src/arm/looprestoration_init_tmpl.c b/src/arm/looprestoration_init_tmpl.c index 31cabb7..07c56c7 100644 --- a/src/arm/looprestoration_init_tmpl.c +++ b/src/arm/looprestoration_init_tmpl.c @@ -27,8 +27,6 @@ #include "src/cpu.h" #include "src/looprestoration.h" - -#include "common/attributes.h" #include "src/tables.h" #if BITDEPTH == 8 @@ -258,7 +256,7 @@ static void sgr_filter_neon(pixel *const dst, const ptrdiff_t dst_stride, #endif // ARCH_AARCH64 #endif // BITDEPTH == 8 -void bitfn(dav1d_loop_restoration_dsp_init_arm)(Dav1dLoopRestorationDSPContext *const c) { +COLD void bitfn(dav1d_loop_restoration_dsp_init_arm)(Dav1dLoopRestorationDSPContext *const c) { const unsigned flags = dav1d_get_cpu_flags(); if (!(flags & DAV1D_ARM_CPU_FLAG_NEON)) return; diff --git a/src/cdef_tmpl.c b/src/cdef_tmpl.c index d7fde6a..7a82d8b 100644 --- a/src/cdef_tmpl.c +++ b/src/cdef_tmpl.c @@ -254,7 +254,7 @@ static int cdef_find_dir_c(const pixel *img, const ptrdiff_t stride, return best_dir; } -void bitfn(dav1d_cdef_dsp_init)(Dav1dCdefDSPContext *const c) { +COLD void bitfn(dav1d_cdef_dsp_init)(Dav1dCdefDSPContext *const c) { c->dir = cdef_find_dir_c; c->fb[0] = cdef_filter_block_8x8_c; c->fb[1] = cdef_filter_block_4x8_c; @@ -32,7 +32,7 @@ static unsigned flags_mask = -1; -unsigned dav1d_get_cpu_flags(void) { +COLD unsigned dav1d_get_cpu_flags(void) { static unsigned flags; static uint8_t checked = 0; @@ -49,6 +49,6 @@ unsigned dav1d_get_cpu_flags(void) { return flags & flags_mask; } -void dav1d_set_cpu_flags_mask(const unsigned mask) { +COLD void dav1d_set_cpu_flags_mask(const unsigned mask) { flags_mask = mask; } @@ -30,6 +30,8 @@ #include "config.h" +#include "common/attributes.h" + #include "dav1d/common.h" #if ARCH_AARCH64 || ARCH_ARM diff --git a/src/ipred_tmpl.c b/src/ipred_tmpl.c index a6eb999..09be553 100644 --- a/src/ipred_tmpl.c +++ b/src/ipred_tmpl.c @@ -725,7 +725,7 @@ static void pal_pred_c(pixel *dst, const ptrdiff_t stride, } } -void bitfn(dav1d_intra_pred_dsp_init)(Dav1dIntraPredDSPContext *const c) { +COLD void bitfn(dav1d_intra_pred_dsp_init)(Dav1dIntraPredDSPContext *const c) { c->intra_pred[DC_PRED ] = ipred_dc_c; c->intra_pred[DC_128_PRED ] = ipred_dc_128_c; c->intra_pred[TOP_DC_PRED ] = ipred_dc_top_c; diff --git a/src/itx_tmpl.c b/src/itx_tmpl.c index 9708d97..4742785 100644 --- a/src/itx_tmpl.c +++ b/src/itx_tmpl.c @@ -193,7 +193,7 @@ static void inv_txfm_add_wht_wht_4x4_c(pixel *dst, const ptrdiff_t stride, memset(coeff, 0, sizeof(*coeff) * 4 * 4); } -void bitfn(dav1d_itx_dsp_init)(Dav1dInvTxfmDSPContext *const c) { +COLD void bitfn(dav1d_itx_dsp_init)(Dav1dInvTxfmDSPContext *const c) { #define assign_itx_all_fn64(w, h, pfx) \ c->itxfm_add[pfx##TX_##w##X##h][DCT_DCT ] = \ inv_txfm_add_dct_dct_##w##x##h##_c @@ -46,17 +46,17 @@ #include "src/wedge.h" #include "src/film_grain.h" -static void init_internal(void) { +static COLD void init_internal(void) { dav1d_init_wedge_masks(); dav1d_init_interintra_masks(); dav1d_init_qm_tables(); } -const char *dav1d_version(void) { +COLD const char *dav1d_version(void) { return DAV1D_VERSION; } -void dav1d_default_settings(Dav1dSettings *const s) { +COLD void dav1d_default_settings(Dav1dSettings *const s) { s->n_frame_threads = 1; s->n_tile_threads = 1; s->apply_grain = 1; @@ -71,9 +71,7 @@ void dav1d_default_settings(Dav1dSettings *const s) { static void close_internal(Dav1dContext **const c_out, int flush); -int dav1d_open(Dav1dContext **const c_out, - const Dav1dSettings *const s) -{ +COLD int dav1d_open(Dav1dContext **const c_out, const Dav1dSettings *const s) { static pthread_once_t initted = PTHREAD_ONCE_INIT; pthread_once(&initted, init_internal); @@ -432,12 +430,12 @@ void dav1d_flush(Dav1dContext *const c) { c->frame_thread.next = 0; } -void dav1d_close(Dav1dContext **const c_out) { +COLD void dav1d_close(Dav1dContext **const c_out) { validate_input(c_out != NULL); close_internal(c_out, 1); } -static void close_internal(Dav1dContext **const c_out, int flush) { +static COLD void close_internal(Dav1dContext **const c_out, int flush) { Dav1dContext *const c = *c_out; if (!c) return; @@ -36,14 +36,14 @@ #include "src/internal.h" #include "src/log.h" -void dav1d_log_default_callback(void *const cookie, - const char *const format, va_list ap) +COLD void dav1d_log_default_callback(void *const cookie, + const char *const format, va_list ap) { vfprintf(stderr, format, ap); } #if CONFIG_LOG -void dav1d_log(Dav1dContext *const c, const char *const format, ...) { +COLD void dav1d_log(Dav1dContext *const c, const char *const format, ...) { validate_input(c != NULL); if (!c->logger.callback) diff --git a/src/loopfilter_tmpl.c b/src/loopfilter_tmpl.c index 1a9d7ef..6ea744f 100644 --- a/src/loopfilter_tmpl.c +++ b/src/loopfilter_tmpl.c @@ -244,7 +244,7 @@ static void loop_filter_v_sb128uv_c(pixel *dst, const ptrdiff_t stride, } } -void bitfn(dav1d_loop_filter_dsp_init)(Dav1dLoopFilterDSPContext *const c) { +COLD void bitfn(dav1d_loop_filter_dsp_init)(Dav1dLoopFilterDSPContext *const c) { c->loop_filter_sb[0][0] = loop_filter_h_sb128y_c; c->loop_filter_sb[0][1] = loop_filter_v_sb128y_c; c->loop_filter_sb[1][0] = loop_filter_h_sb128uv_c; diff --git a/src/looprestoration_tmpl.c b/src/looprestoration_tmpl.c index 08af2b0..20ed670 100644 --- a/src/looprestoration_tmpl.c +++ b/src/looprestoration_tmpl.c @@ -573,7 +573,7 @@ static void selfguided_c(pixel *p, const ptrdiff_t p_stride, } } -void bitfn(dav1d_loop_restoration_dsp_init)(Dav1dLoopRestorationDSPContext *const c) { +COLD void bitfn(dav1d_loop_restoration_dsp_init)(Dav1dLoopRestorationDSPContext *const c) { c->wiener = wiener_c; c->selfguided = selfguided_c; diff --git a/src/mc_tmpl.c b/src/mc_tmpl.c index b1fe67a..9fe3515 100644 --- a/src/mc_tmpl.c +++ b/src/mc_tmpl.c @@ -912,7 +912,7 @@ static void resize_c(pixel *dst, const ptrdiff_t dst_stride, } while (--h); } -void bitfn(dav1d_mc_dsp_init)(Dav1dMCDSPContext *const c) { +COLD void bitfn(dav1d_mc_dsp_init)(Dav1dMCDSPContext *const c) { #define init_mc_fns(type, name) do { \ c->mc [type] = put_##name##_c; \ c->mc_scaled [type] = put_##name##_scaled_c; \ @@ -29,6 +29,8 @@ #include <string.h> +#include "common/attributes.h" + #include "src/qm.h" static const uint8_t qm_tbl_4x4_t[][2][10] = { @@ -3104,7 +3106,7 @@ static void untriangle(uint8_t *dst, const uint8_t *src, const int sz) { } } -void dav1d_init_qm_tables(void) { +COLD void dav1d_init_qm_tables(void) { // This function is guaranteed to be called only once for (int i = 0; i < 15; i++) diff --git a/src/wedge.c b/src/wedge.c index 533d7b7..2c29283 100644 --- a/src/wedge.c +++ b/src/wedge.c @@ -155,7 +155,7 @@ static void copy2d(uint8_t *dst, const uint8_t *src, } } -static void init_chroma(uint8_t *chroma, const uint8_t *luma, +static COLD void init_chroma(uint8_t *chroma, const uint8_t *luma, const int sign, const int w, const int h, const int ss_ver) { for (int y = 0; y < h; y += 1 + ss_ver) { @@ -169,12 +169,12 @@ static void init_chroma(uint8_t *chroma, const uint8_t *luma, } } -static void fill2d_16x2(uint8_t *dst, const int w, const int h, - const enum BlockSize bs, - const uint8_t (*const master)[64 * 64], - const wedge_code_type *const cb, - uint8_t *masks_444, uint8_t *masks_422, - uint8_t *masks_420, const unsigned signs) +static COLD void fill2d_16x2(uint8_t *dst, const int w, const int h, + const enum BlockSize bs, + const uint8_t (*const master)[64 * 64], + const wedge_code_type *const cb, + uint8_t *masks_444, uint8_t *masks_422, + uint8_t *masks_420, const unsigned signs) { uint8_t *ptr = dst; for (int n = 0; n < 16; n++) { @@ -222,7 +222,7 @@ static void fill2d_16x2(uint8_t *dst, const int w, const int h, } } -void dav1d_init_wedge_masks(void) { +COLD void dav1d_init_wedge_masks(void) { // This function is guaranteed to be called only once enum WedgeMasterLineType { @@ -304,10 +304,10 @@ const uint8_t *dav1d_ii_masks[N_BS_SIZES][3][N_INTER_INTRA_PRED_MODES] = { #undef set #undef set1 -static void build_nondc_ii_masks(uint8_t *const mask_v, - uint8_t *const mask_h, - uint8_t *const mask_sm, - const int w, const int h, const int step) +static COLD void build_nondc_ii_masks(uint8_t *const mask_v, + uint8_t *const mask_h, + uint8_t *const mask_sm, + const int w, const int h, const int step) { static const uint8_t ii_weights_1d[] = { 60, 52, 45, 39, 34, 30, 26, 22, 19, 17, 15, 13, 11, 10, 8, 7, @@ -323,7 +323,7 @@ static void build_nondc_ii_masks(uint8_t *const mask_v, } } -void dav1d_init_interintra_masks(void) { +COLD void dav1d_init_interintra_masks(void) { // This function is guaranteed to be called only once memset(ii_dc_mask, 32, 32 * 32); diff --git a/src/win32/thread.c b/src/win32/thread.c index 2c2a578..c579ba4 100644 --- a/src/win32/thread.c +++ b/src/win32/thread.c @@ -33,17 +33,19 @@ #include <stdlib.h> #include <windows.h> +#include "common/attributes.h" + #include "src/thread.h" -static unsigned __stdcall thread_entrypoint(void *const data) { +static COLD unsigned __stdcall thread_entrypoint(void *const data) { pthread_t *const t = data; t->arg = t->func(t->arg); return 0; } -int dav1d_pthread_create(pthread_t *const thread, - const pthread_attr_t *const attr, - void *(*const func)(void*), void *const arg) +COLD int dav1d_pthread_create(pthread_t *const thread, + const pthread_attr_t *const attr, + void *(*const func)(void*), void *const arg) { const unsigned stack_size = attr ? attr->stack_size : 0; thread->func = func; @@ -53,7 +55,7 @@ int dav1d_pthread_create(pthread_t *const thread, return !thread->h; } -int dav1d_pthread_join(pthread_t *const thread, void **const res) { +COLD int dav1d_pthread_join(pthread_t *const thread, void **const res) { if (WaitForSingleObject(thread->h, INFINITE)) return 1; @@ -63,8 +65,8 @@ int dav1d_pthread_join(pthread_t *const thread, void **const res) { return !CloseHandle(thread->h); } -int dav1d_pthread_once(pthread_once_t *const once_control, - void (*const init_routine)(void)) +COLD int dav1d_pthread_once(pthread_once_t *const once_control, + void (*const init_routine)(void)) { BOOL pending = FALSE; diff --git a/src/x86/cdef_init_tmpl.c b/src/x86/cdef_init_tmpl.c index 99521aa..44f4315 100644 --- a/src/x86/cdef_init_tmpl.c +++ b/src/x86/cdef_init_tmpl.c @@ -44,7 +44,7 @@ decl_cdef_dir_fn(dav1d_cdef_dir_avx2); decl_cdef_dir_fn(dav1d_cdef_dir_sse4); decl_cdef_dir_fn(dav1d_cdef_dir_ssse3); -void bitfn(dav1d_cdef_dsp_init_x86)(Dav1dCdefDSPContext *const c) { +COLD void bitfn(dav1d_cdef_dsp_init_x86)(Dav1dCdefDSPContext *const c) { const unsigned flags = dav1d_get_cpu_flags(); if (!(flags & DAV1D_X86_CPU_FLAG_SSSE3)) return; diff --git a/src/x86/cpu.c b/src/x86/cpu.c index 82c403c..476e535 100644 --- a/src/x86/cpu.c +++ b/src/x86/cpu.c @@ -29,12 +29,14 @@ #include <stdint.h> +#include "common/attributes.h" + #include "src/x86/cpu.h" void dav1d_cpu_cpuid(uint32_t *info, int leaf); uint64_t dav1d_cpu_xgetbv(int xcr); -unsigned dav1d_get_cpu_flags_x86(void) { +COLD unsigned dav1d_get_cpu_flags_x86(void) { uint32_t info[4] = {0}, n_ids; unsigned flags = 0; diff --git a/src/x86/ipred_init_tmpl.c b/src/x86/ipred_init_tmpl.c index 427f0fa..677dfdf 100644 --- a/src/x86/ipred_init_tmpl.c +++ b/src/x86/ipred_init_tmpl.c @@ -75,7 +75,7 @@ decl_cfl_ac_fn(dav1d_ipred_cfl_ac_444_ssse3); decl_pal_pred_fn(dav1d_pal_pred_ssse3); -void bitfn(dav1d_intra_pred_dsp_init_x86)(Dav1dIntraPredDSPContext *const c) { +COLD void bitfn(dav1d_intra_pred_dsp_init_x86)(Dav1dIntraPredDSPContext *const c) { const unsigned flags = dav1d_get_cpu_flags(); if (!(flags & DAV1D_X86_CPU_FLAG_SSSE3)) return; diff --git a/src/x86/itx_init_tmpl.c b/src/x86/itx_init_tmpl.c index c4987ae..7d0c58c 100644 --- a/src/x86/itx_init_tmpl.c +++ b/src/x86/itx_init_tmpl.c @@ -98,7 +98,7 @@ decl_itx_fn(dav1d_inv_txfm_add_dct_dct_64x16_ssse3); decl_itx_fn(dav1d_inv_txfm_add_dct_dct_64x32_ssse3); decl_itx_fn(dav1d_inv_txfm_add_dct_dct_64x64_ssse3); -void bitfn(dav1d_itx_dsp_init_x86)(Dav1dInvTxfmDSPContext *const c) { +COLD void bitfn(dav1d_itx_dsp_init_x86)(Dav1dInvTxfmDSPContext *const c) { #define assign_itx_fn(pfx, w, h, type, type_enum, ext) \ c->itxfm_add[pfx##TX_##w##X##h][type_enum] = \ dav1d_inv_txfm_add_##type##_##w##x##h##_##ext diff --git a/src/x86/loopfilter_init_tmpl.c b/src/x86/loopfilter_init_tmpl.c index 0da2f2b..7a2efd6 100644 --- a/src/x86/loopfilter_init_tmpl.c +++ b/src/x86/loopfilter_init_tmpl.c @@ -33,7 +33,7 @@ decl_loopfilter_sb_fn(dav1d_lpf_v_sb_y_avx2); decl_loopfilter_sb_fn(dav1d_lpf_h_sb_uv_avx2); decl_loopfilter_sb_fn(dav1d_lpf_v_sb_uv_avx2); -void bitfn(dav1d_loop_filter_dsp_init_x86)(Dav1dLoopFilterDSPContext *const c) { +COLD void bitfn(dav1d_loop_filter_dsp_init_x86)(Dav1dLoopFilterDSPContext *const c) { const unsigned flags = dav1d_get_cpu_flags(); if (!(flags & DAV1D_X86_CPU_FLAG_AVX2)) return; diff --git a/src/x86/looprestoration_init_tmpl.c b/src/x86/looprestoration_init_tmpl.c index 9068008..2c0f04d 100644 --- a/src/x86/looprestoration_init_tmpl.c +++ b/src/x86/looprestoration_init_tmpl.c @@ -28,7 +28,6 @@ #include "src/cpu.h" #include "src/looprestoration.h" -#include "common/attributes.h" #include "common/intops.h" #include "src/tables.h" @@ -211,7 +210,7 @@ DEF_LR_FILTERS(avx2) # endif #endif -void bitfn(dav1d_loop_restoration_dsp_init_x86)(Dav1dLoopRestorationDSPContext *const c) { +COLD void bitfn(dav1d_loop_restoration_dsp_init_x86)(Dav1dLoopRestorationDSPContext *const c) { const unsigned flags = dav1d_get_cpu_flags(); if (!(flags & DAV1D_X86_CPU_FLAG_SSSE3)) return; diff --git a/src/x86/mc_init_tmpl.c b/src/x86/mc_init_tmpl.c index 0e33cd4..6a9515f 100644 --- a/src/x86/mc_init_tmpl.c +++ b/src/x86/mc_init_tmpl.c @@ -93,7 +93,7 @@ decl_warp8x8t_fn(dav1d_warp_affine_8x8t_avx2); decl_emu_edge_fn(dav1d_emu_edge_avx2); decl_emu_edge_fn(dav1d_emu_edge_ssse3); -void bitfn(dav1d_mc_dsp_init_x86)(Dav1dMCDSPContext *const c) { +COLD void bitfn(dav1d_mc_dsp_init_x86)(Dav1dMCDSPContext *const c) { #define init_mc_fn(type, name, suffix) \ c->mc[type] = dav1d_put_##name##_##suffix #define init_mct_fn(type, name, suffix) \ |