1 /* 2 * Copyright (c) 2012-2019 Fredrik Mellbin 3 * 4 * This file is part of VapourSynth. 5 * 6 * VapourSynth is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * VapourSynth is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with VapourSynth; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef GENERIC_H 22 #define GENERIC_H 23 24 #include <stddef.h> 25 #include <stdint.h> 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 struct vs_generic_params { 32 uint16_t maxval; 33 34 /* Prewitt, Sobel. */ 35 float scale; 36 37 /* Minimum, Maximum, Deflate, Inflate. */ 38 uint16_t threshold; 39 float thresholdf; 40 41 /* Minimum, Maximum. */ 42 uint8_t stencil; 43 44 /* Convolution. */ 45 unsigned matrixsize; 46 int16_t matrix[25]; 47 float matrixf[25]; 48 float div; 49 float bias; 50 uint8_t saturate; 51 }; 52 53 #define DECL(kernel, pixel, isa) void vs_generic_##kernel##_##pixel##_##isa(const void *src, ptrdiff_t src_stride, void *dst, ptrdiff_t dst_stride, const struct vs_generic_params *params, unsigned width, unsigned height); 54 #define DECL_3x3(kernel, pixel, isa) DECL(3x3_##kernel, pixel, isa) 55 56 DECL_3x3(prewitt, byte, c) 57 DECL_3x3(prewitt, word, c) 58 DECL_3x3(prewitt, float, c) 59 60 DECL_3x3(sobel, byte, c) 61 DECL_3x3(sobel, word, c) 62 DECL_3x3(sobel, float, c) 63 64 DECL_3x3(min, byte, c) 65 DECL_3x3(min, word, c) 66 DECL_3x3(min, float, c) 67 68 DECL_3x3(max, byte, c) 69 DECL_3x3(max, word, c) 70 DECL_3x3(max, float, c) 71 72 DECL_3x3(median, byte, c) 73 DECL_3x3(median, word, c) 74 DECL_3x3(median, float, c) 75 76 DECL_3x3(deflate, byte, c) 77 DECL_3x3(deflate, word, c) 78 DECL_3x3(deflate, float, c) 79 80 DECL_3x3(inflate, byte, c) 81 DECL_3x3(inflate, word, c) 82 DECL_3x3(inflate, float, c) 83 84 DECL_3x3(conv, byte, c) 85 DECL_3x3(conv, word, c) 86 DECL_3x3(conv, float, c) 87 88 DECL(5x5_conv, byte, c) 89 DECL(5x5_conv, word, c) 90 DECL(5x5_conv, float, c) 91 92 DECL(1d_conv_h, byte, c) 93 DECL(1d_conv_h, word, c) 94 DECL(1d_conv_h, float, c) 95 96 DECL(1d_conv_v, byte, c) 97 DECL(1d_conv_v, word, c) 98 DECL(1d_conv_v, float, c) 99 100 #ifdef VS_TARGET_CPU_X86 101 DECL_3x3(prewitt, byte, sse2) 102 DECL_3x3(prewitt, word, sse2) 103 DECL_3x3(prewitt, float, sse2) 104 105 DECL_3x3(sobel, byte, sse2) 106 DECL_3x3(sobel, word, sse2) 107 DECL_3x3(sobel, float, sse2) 108 109 DECL_3x3(min, byte, sse2) 110 DECL_3x3(min, word, sse2) 111 DECL_3x3(min, float, sse2) 112 113 DECL_3x3(max, byte, sse2) 114 DECL_3x3(max, word, sse2) 115 DECL_3x3(max, float, sse2) 116 117 DECL_3x3(median, byte, sse2) 118 DECL_3x3(median, word, sse2) 119 DECL_3x3(median, float, sse2) 120 121 DECL_3x3(deflate, byte, sse2) 122 DECL_3x3(deflate, word, sse2) 123 DECL_3x3(deflate, float, sse2) 124 125 DECL_3x3(inflate, byte, sse2) 126 DECL_3x3(inflate, word, sse2) 127 DECL_3x3(inflate, float, sse2) 128 129 DECL_3x3(conv, byte, sse2) 130 DECL_3x3(conv, word, sse2) 131 DECL_3x3(conv, float, sse2) 132 133 DECL_3x3(prewitt, byte, avx2) 134 DECL_3x3(prewitt, word, avx2) 135 DECL_3x3(prewitt, float, avx2) 136 137 DECL_3x3(sobel, byte, avx2) 138 DECL_3x3(sobel, word, avx2) 139 DECL_3x3(sobel, float, avx2) 140 141 DECL_3x3(min, byte, avx2) 142 DECL_3x3(min, word, avx2) 143 DECL_3x3(min, float, avx2) 144 145 DECL_3x3(max, byte, avx2) 146 DECL_3x3(max, word, avx2) 147 DECL_3x3(max, float, avx2) 148 149 DECL_3x3(median, byte, avx2) 150 DECL_3x3(median, word, avx2) 151 DECL_3x3(median, float, avx2) 152 153 DECL_3x3(deflate, byte, avx2) 154 DECL_3x3(deflate, word, avx2) 155 DECL_3x3(deflate, float, avx2) 156 157 DECL_3x3(inflate, byte, avx2) 158 DECL_3x3(inflate, word, avx2) 159 DECL_3x3(inflate, float, avx2) 160 161 DECL_3x3(conv, byte, avx2) 162 DECL_3x3(conv, word, avx2) 163 DECL_3x3(conv, float, avx2) 164 #endif 165 166 #undef DECL_3x3 167 #undef DECL 168 169 #ifdef __cplusplus 170 } 171 #endif 172 173 #endif