filters/overlay/intel/masked_rowprep_sse41.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // masked_rowprep_sse41.h | ||
| 2 | // SSE4.1 rowprep function declarations. | ||
| 3 | // Implementations and explicit instantiations are in masked_rowprep_sse41.cpp. | ||
| 4 | // | ||
| 5 | // simd_magic_div_32 is kept inline here — used inside masked_merge_sse41_impl.hpp | ||
| 6 | // hot loops and must remain inlineable within those TUs. | ||
| 7 | |||
| 8 | #pragma once | ||
| 9 | |||
| 10 | #if defined(_MSC_VER) | ||
| 11 | #include <intrin.h> | ||
| 12 | #else | ||
| 13 | #include <smmintrin.h> // SSE4.1 (includes SSSE3/SSE2 transitively) | ||
| 14 | #endif | ||
| 15 | |||
| 16 | #include "../blend_common.h" // MaskMode, MagicDiv, magic_div_rt, AVS_FORCEINLINE | ||
| 17 | #include <vector> | ||
| 18 | #include <cstdint> | ||
| 19 | |||
| 20 | // --------------------------------------------------------------------------- | ||
| 21 | // simd_magic_div_32 | ||
| 22 | // Inline here: used by masked_merge_sse41_impl.hpp in inner blend loops. | ||
| 23 | // Pure SSE2 arithmetic; __target__("sse4.1") only for _mm_blend_ps. | ||
| 24 | // --------------------------------------------------------------------------- | ||
| 25 | #if defined(GCC) || defined(CLANG) | ||
| 26 | __attribute__((__target__("sse4.1"))) | ||
| 27 | #endif | ||
| 28 | static AVS_FORCEINLINE __m128i simd_magic_div_32(__m128i val, uint32_t magic, int shift) { | ||
| 29 | 1868 | __m128i v_magic = _mm_set1_epi64x(magic); | |
| 30 | 934 | __m128i res_02 = _mm_mul_epu32(val, v_magic); | |
| 31 | 934 | __m128i res_13 = _mm_mul_epu32(_mm_srli_si128(val, 4), v_magic); | |
| 32 | 934 | res_02 = _mm_srli_epi64(res_02, 32 + shift); | |
| 33 | 1868 | res_13 = _mm_srli_epi64(res_13, 32 + shift); | |
| 34 | 2802 | return _mm_castps_si128(_mm_blend_ps( | |
| 35 | _mm_castsi128_ps(res_02), | ||
| 36 | _mm_castsi128_ps(_mm_slli_epi64(res_13, 32)), | ||
| 37 | 10 // 0b1010 | ||
| 38 | 934 | )); | |
| 39 | } | ||
| 40 | |||
| 41 | // --------------------------------------------------------------------------- | ||
| 42 | // prepare_effective_mask_for_row_sse41 | ||
| 43 | // Declared here; defined + explicitly instantiated in masked_rowprep_sse41.cpp. | ||
| 44 | // --------------------------------------------------------------------------- | ||
| 45 | template<MaskMode maskMode, typename pixel_t, bool full_opacity = true> | ||
| 46 | const pixel_t* prepare_effective_mask_for_row_sse41( | ||
| 47 | const pixel_t* maskp, | ||
| 48 | int mask_pitch, | ||
| 49 | int width, | ||
| 50 | std::vector<pixel_t>& buf, | ||
| 51 | int opacity_i = 0, | ||
| 52 | int half = 0, | ||
| 53 | MagicDiv magic = {}); | ||
| 54 | |||
| 55 | template<MaskMode maskMode, bool full_opacity = true> | ||
| 56 | const float* prepare_effective_mask_for_row_float_sse41( | ||
| 57 | const float* maskp, | ||
| 58 | int mask_pitch, | ||
| 59 | int width, | ||
| 60 | std::vector<float>& buf, | ||
| 61 | float opacity = 0); | ||
| 62 |