mc.h (6935B)
1 /* 2 * Copyright © 2018, VideoLAN and dav1d authors 3 * Copyright © 2018, Two Orioles, LLC 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice, this 10 * list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #ifndef DAV1D_SRC_MC_H 29 #define DAV1D_SRC_MC_H 30 31 #include <stdint.h> 32 #include <stddef.h> 33 34 #include "common/bitdepth.h" 35 36 #include "src/levels.h" 37 38 #define decl_mc_fn(name) \ 39 void (name)(pixel *dst, ptrdiff_t dst_stride, \ 40 const pixel *src, ptrdiff_t src_stride, \ 41 int w, int h, int mx, int my HIGHBD_DECL_SUFFIX) 42 typedef decl_mc_fn(*mc_fn); 43 44 #define decl_mc_scaled_fn(name) \ 45 void (name)(pixel *dst, ptrdiff_t dst_stride, \ 46 const pixel *src, ptrdiff_t src_stride, \ 47 int w, int h, int mx, int my, int dx, int dy HIGHBD_DECL_SUFFIX) 48 typedef decl_mc_scaled_fn(*mc_scaled_fn); 49 50 #define decl_warp8x8_fn(name) \ 51 void (name)(pixel *dst, ptrdiff_t dst_stride, \ 52 const pixel *src, ptrdiff_t src_stride, \ 53 const int16_t *abcd, int mx, int my HIGHBD_DECL_SUFFIX) 54 typedef decl_warp8x8_fn(*warp8x8_fn); 55 56 #define decl_mct_fn(name) \ 57 void (name)(int16_t *tmp, const pixel *src, ptrdiff_t src_stride, \ 58 int w, int h, int mx, int my HIGHBD_DECL_SUFFIX) 59 typedef decl_mct_fn(*mct_fn); 60 61 #define decl_mct_scaled_fn(name) \ 62 void (name)(int16_t *tmp, const pixel *src, ptrdiff_t src_stride, \ 63 int w, int h, int mx, int my, int dx, int dy HIGHBD_DECL_SUFFIX) 64 typedef decl_mct_scaled_fn(*mct_scaled_fn); 65 66 #define decl_warp8x8t_fn(name) \ 67 void (name)(int16_t *tmp, const ptrdiff_t tmp_stride, \ 68 const pixel *src, ptrdiff_t src_stride, \ 69 const int16_t *abcd, int mx, int my HIGHBD_DECL_SUFFIX) 70 typedef decl_warp8x8t_fn(*warp8x8t_fn); 71 72 #define decl_avg_fn(name) \ 73 void (name)(pixel *dst, ptrdiff_t dst_stride, \ 74 const int16_t *tmp1, const int16_t *tmp2, int w, int h \ 75 HIGHBD_DECL_SUFFIX) 76 typedef decl_avg_fn(*avg_fn); 77 78 #define decl_w_avg_fn(name) \ 79 void (name)(pixel *dst, ptrdiff_t dst_stride, \ 80 const int16_t *tmp1, const int16_t *tmp2, int w, int h, int weight \ 81 HIGHBD_DECL_SUFFIX) 82 typedef decl_w_avg_fn(*w_avg_fn); 83 84 #define decl_mask_fn(name) \ 85 void (name)(pixel *dst, ptrdiff_t dst_stride, \ 86 const int16_t *tmp1, const int16_t *tmp2, int w, int h, \ 87 const uint8_t *mask HIGHBD_DECL_SUFFIX) 88 typedef decl_mask_fn(*mask_fn); 89 90 #define decl_w_mask_fn(name) \ 91 void (name)(pixel *dst, ptrdiff_t dst_stride, \ 92 const int16_t *tmp1, const int16_t *tmp2, int w, int h, \ 93 uint8_t *mask, int sign HIGHBD_DECL_SUFFIX) 94 typedef decl_w_mask_fn(*w_mask_fn); 95 96 #define decl_blend_fn(name) \ 97 void (name)(pixel *dst, ptrdiff_t dst_stride, const pixel *tmp, \ 98 int w, int h, const uint8_t *mask) 99 typedef decl_blend_fn(*blend_fn); 100 101 #define decl_blend_dir_fn(name) \ 102 void (name)(pixel *dst, ptrdiff_t dst_stride, const pixel *tmp, int w, int h) 103 typedef decl_blend_dir_fn(*blend_dir_fn); 104 105 #define decl_emu_edge_fn(name) \ 106 void (name)(intptr_t bw, intptr_t bh, intptr_t iw, intptr_t ih, intptr_t x, intptr_t y, \ 107 pixel *dst, ptrdiff_t dst_stride, const pixel *src, ptrdiff_t src_stride) 108 typedef decl_emu_edge_fn(*emu_edge_fn); 109 110 #define decl_resize_fn(name) \ 111 void (name)(pixel *dst, ptrdiff_t dst_stride, \ 112 const pixel *src, ptrdiff_t src_stride, \ 113 int dst_w, int h, int src_w, int dx, int mx HIGHBD_DECL_SUFFIX) 114 typedef decl_resize_fn(*resize_fn); 115 116 #define decl_8tap_gen(decl_name, fn_name, opt) \ 117 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_regular, opt)); \ 118 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_regular_smooth, opt)); \ 119 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_regular_sharp, opt)); \ 120 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_smooth_regular, opt)); \ 121 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_smooth, opt)); \ 122 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_smooth_sharp, opt)); \ 123 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_sharp_regular, opt)); \ 124 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_sharp_smooth, opt)); \ 125 decl_##decl_name##_fn(BF(dav1d_##fn_name##_8tap_sharp, opt)) 126 127 #define decl_8tap_fns(opt) \ 128 decl_8tap_gen(mc, put, opt); \ 129 decl_8tap_gen(mct, prep, opt) 130 131 #define init_8tap_gen(name, opt) \ 132 init_##name##_fn(FILTER_2D_8TAP_REGULAR, 8tap_regular, opt); \ 133 init_##name##_fn(FILTER_2D_8TAP_REGULAR_SMOOTH, 8tap_regular_smooth, opt); \ 134 init_##name##_fn(FILTER_2D_8TAP_REGULAR_SHARP, 8tap_regular_sharp, opt); \ 135 init_##name##_fn(FILTER_2D_8TAP_SMOOTH_REGULAR, 8tap_smooth_regular, opt); \ 136 init_##name##_fn(FILTER_2D_8TAP_SMOOTH, 8tap_smooth, opt); \ 137 init_##name##_fn(FILTER_2D_8TAP_SMOOTH_SHARP, 8tap_smooth_sharp, opt); \ 138 init_##name##_fn(FILTER_2D_8TAP_SHARP_REGULAR, 8tap_sharp_regular, opt); \ 139 init_##name##_fn(FILTER_2D_8TAP_SHARP_SMOOTH, 8tap_sharp_smooth, opt); \ 140 init_##name##_fn(FILTER_2D_8TAP_SHARP, 8tap_sharp, opt) 141 142 #define init_8tap_fns(opt) \ 143 init_8tap_gen(mc, opt); \ 144 init_8tap_gen(mct, opt) 145 146 typedef struct Dav1dMCDSPContext { 147 mc_fn mc[N_2D_FILTERS]; 148 mc_scaled_fn mc_scaled[N_2D_FILTERS]; 149 mct_fn mct[N_2D_FILTERS]; 150 mct_scaled_fn mct_scaled[N_2D_FILTERS]; 151 avg_fn avg; 152 w_avg_fn w_avg; 153 mask_fn mask; 154 w_mask_fn w_mask[3 /* 444, 422, 420 */]; 155 blend_fn blend; 156 blend_dir_fn blend_v; 157 blend_dir_fn blend_h; 158 warp8x8_fn warp8x8; 159 warp8x8t_fn warp8x8t; 160 emu_edge_fn emu_edge; 161 resize_fn resize; 162 } Dav1dMCDSPContext; 163 164 bitfn_decls(void dav1d_mc_dsp_init, Dav1dMCDSPContext *c); 165 166 #endif /* DAV1D_SRC_MC_H */