filters/overlay/OF_darken.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Avisynth v2.5. Copyright 2002 Ben Rudiak-Gould et al. | ||
| 2 | // http://avisynth.nl | ||
| 3 | |||
| 4 | // This program is free software; you can redistribute it and/or modify | ||
| 5 | // it under the terms of the GNU General Public License as published by | ||
| 6 | // the Free Software Foundation; either version 2 of the License, or | ||
| 7 | // (at your option) any later version. | ||
| 8 | // | ||
| 9 | // This program is distributed in the hope that it will be useful, | ||
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | // GNU General Public License for more details. | ||
| 13 | // | ||
| 14 | // You should have received a copy of the GNU General Public License | ||
| 15 | // along with this program; if not, write to the Free Software | ||
| 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit | ||
| 17 | // http://www.gnu.org/copyleft/gpl.html . | ||
| 18 | // | ||
| 19 | // Linking Avisynth statically or dynamically with other modules is making a | ||
| 20 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU | ||
| 21 | // General Public License cover the whole combination. | ||
| 22 | // | ||
| 23 | // As a special exception, the copyright holders of Avisynth give you | ||
| 24 | // permission to link Avisynth with independent modules that communicate with | ||
| 25 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license | ||
| 26 | // terms of these independent modules, and to copy and distribute the | ||
| 27 | // resulting combined work under terms of your choice, provided that | ||
| 28 | // every copy of the combined work is accompanied by a complete copy of | ||
| 29 | // the source code of Avisynth (the version of Avisynth used to produce the | ||
| 30 | // combined work), being distributed under the terms of the GNU General | ||
| 31 | // Public License plus this exception. An independent module is a module | ||
| 32 | // which is not derived from or based on Avisynth, such as 3rd-party filters, | ||
| 33 | // import and export plugins, or graphical user interfaces. | ||
| 34 | |||
| 35 | // Overlay (c) 2003, 2004 by Klaus Post | ||
| 36 | |||
| 37 | #include "overlayfunctions.h" | ||
| 38 | |||
| 39 | #include "blend_common.h" | ||
| 40 | #ifdef INTEL_INTRINSICS | ||
| 41 | #include "intel/blend_common_sse.h" | ||
| 42 | #endif | ||
| 43 | |||
| 44 | #include <stdint.h> | ||
| 45 | #include <type_traits> | ||
| 46 | |||
| 47 | 4 | void OL_DarkenImage::DoBlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask) { | |
| 48 |
2/2✓ Branch 2 → 3 taken 2 times.
✓ Branch 2 → 7 taken 2 times.
|
4 | if(of_mode == OF_Darken) { |
| 49 |
1/2✓ Branch 3 → 4 taken 2 times.
✗ Branch 3 → 5 not taken.
|
2 | if (bits_per_pixel == 8) |
| 50 | 2 | BlendImageMask<uint8_t, true, true>(base, overlay, mask); | |
| 51 | ✗ | else if(bits_per_pixel <= 16) | |
| 52 | ✗ | BlendImageMask<uint16_t, true, true>(base, overlay, mask); | |
| 53 | //else if(bits_per_pixel == 32) | ||
| 54 | // BlendImageMask<float>(base, overlay, mask); | ||
| 55 | } | ||
| 56 | else { | ||
| 57 | // OF_Lighten | ||
| 58 |
1/2✓ Branch 7 → 8 taken 2 times.
✗ Branch 7 → 9 not taken.
|
2 | if (bits_per_pixel == 8) |
| 59 | 2 | BlendImageMask<uint8_t, true, false>(base, overlay, mask); | |
| 60 | ✗ | else if(bits_per_pixel <= 16) | |
| 61 | ✗ | BlendImageMask<uint16_t, true, false>(base, overlay, mask); | |
| 62 | //else if(bits_per_pixel == 32) | ||
| 63 | // BlendImageMask<float>(base, overlay, mask); | ||
| 64 | } | ||
| 65 | 4 | } | |
| 66 | |||
| 67 | 8 | void OL_DarkenImage::DoBlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay) { | |
| 68 |
2/2✓ Branch 2 → 3 taken 4 times.
✓ Branch 2 → 7 taken 4 times.
|
8 | if(of_mode == OF_Darken) { |
| 69 |
1/2✓ Branch 3 → 4 taken 4 times.
✗ Branch 3 → 5 not taken.
|
4 | if (bits_per_pixel == 8) |
| 70 | 4 | BlendImageMask<uint8_t, false, true>(base, overlay, nullptr); | |
| 71 | ✗ | else if(bits_per_pixel <= 16) | |
| 72 | ✗ | BlendImageMask<uint16_t, false, true>(base, overlay, nullptr); | |
| 73 | //else if(bits_per_pixel == 32) | ||
| 74 | // BlendImageMask<float>(base, overlay, mask); | ||
| 75 | } | ||
| 76 | else { | ||
| 77 | // OF_Lighten | ||
| 78 |
1/2✓ Branch 7 → 8 taken 4 times.
✗ Branch 7 → 9 not taken.
|
4 | if (bits_per_pixel == 8) |
| 79 | 4 | BlendImageMask<uint8_t, false, false>(base, overlay, nullptr); | |
| 80 | ✗ | else if(bits_per_pixel <= 16) | |
| 81 | ✗ | BlendImageMask<uint16_t, false, false>(base, overlay, nullptr); | |
| 82 | //else if(bits_per_pixel == 32) | ||
| 83 | // BlendImageMask<float>(base, overlay, mask); | ||
| 84 | } | ||
| 85 | 8 | } | |
| 86 | |||
| 87 | // float not supported yet | ||
| 88 | template<typename pixel_t, bool maskMode, bool of_darken> | ||
| 89 | 12 | void OL_DarkenImage::BlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask) { | |
| 90 | |||
| 91 | 12 | pixel_t* baseY = reinterpret_cast<pixel_t *>(base->GetPtr(PLANAR_Y)); | |
| 92 | 12 | pixel_t* baseU = reinterpret_cast<pixel_t *>(base->GetPtr(PLANAR_U)); | |
| 93 | 12 | pixel_t* baseV = reinterpret_cast<pixel_t *>(base->GetPtr(PLANAR_V)); | |
| 94 | |||
| 95 | 12 | pixel_t* ovY = reinterpret_cast<pixel_t *>(overlay->GetPtr(PLANAR_Y)); | |
| 96 | 12 | pixel_t* ovU = reinterpret_cast<pixel_t *>(overlay->GetPtr(PLANAR_U)); | |
| 97 | 12 | pixel_t* ovV = reinterpret_cast<pixel_t *>(overlay->GetPtr(PLANAR_V)); | |
| 98 | |||
| 99 | pixel_t* maskY; | ||
| 100 | pixel_t* maskU; | ||
| 101 | pixel_t* maskV; | ||
| 102 | if constexpr (maskMode) { | ||
| 103 | 4 | maskY = reinterpret_cast<pixel_t *>(mask->GetPtr(PLANAR_Y)); | |
| 104 | 4 | maskU = reinterpret_cast<pixel_t *>(mask->GetPtr(PLANAR_U)); | |
| 105 | 4 | maskV = reinterpret_cast<pixel_t *>(mask->GetPtr(PLANAR_V)); | |
| 106 | } else { | ||
| 107 | 8 | maskY = nullptr; | |
| 108 | 8 | maskU = nullptr; | |
| 109 | 8 | maskV = nullptr; | |
| 110 | } | ||
| 111 | |||
| 112 | 12 | const int half_pixel_value = (sizeof(pixel_t) == 1) ? 128 : (1 << (bits_per_pixel - 1)); | |
| 113 | 12 | const int max_pixel_value = (sizeof(pixel_t) == 1) ? 255 : (1 << bits_per_pixel) - 1; | |
| 114 | 12 | const int basepitch = (base->pitch) / sizeof(pixel_t); | |
| 115 | 12 | const int overlaypitch = (overlay->pitch) / sizeof(pixel_t); | |
| 116 | int maskpitch; | ||
| 117 | if constexpr (maskMode) { | ||
| 118 | 4 | maskpitch = (mask->pitch) / sizeof(pixel_t); | |
| 119 | } else { | ||
| 120 | 8 | maskpitch = 0; | |
| 121 | } | ||
| 122 | |||
| 123 | 12 | const MagicDiv magic = get_magic_div(bits_per_pixel); | |
| 124 | |||
| 125 | // eff on the max_pixel_value scale; only used in the opacity_f!=1.0f branch below. | ||
| 126 | // Finer opacity granularity at >8-bit than the old fixed 0..256 scale. | ||
| 127 | 12 | const int opacity_i = (int)(opacity_f * max_pixel_value + 0.5f); | |
| 128 | 12 | const int rounder = max_pixel_value / 2; | |
| 129 | |||
| 130 | 12 | int w = base->w(); | |
| 131 | 12 | int h = base->h(); | |
| 132 |
6/16void OL_DarkenImage::BlendImageMask<unsigned char, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 11 → 12 taken 3 times.
✓ Branch 11 → 19 taken 1 time.
void OL_DarkenImage::BlendImageMask<unsigned char, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 11 → 12 taken 3 times.
✓ Branch 11 → 19 taken 1 time.
void OL_DarkenImage::BlendImageMask<unsigned char, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 14 → 15 taken 2 times.
✗ Branch 14 → 29 not taken.
void OL_DarkenImage::BlendImageMask<unsigned char, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 14 → 15 taken 2 times.
✗ Branch 14 → 29 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 13 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 13 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 29 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 29 not taken.
|
12 | if (opacity_f == 1.0f) { |
| 133 | // full opacity - optimize | ||
| 134 | if constexpr (maskMode) { | ||
| 135 | // opacity_f == 1.0f && maskMode | ||
| 136 |
4/8void OL_DarkenImage::BlendImageMask<unsigned char, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 28 → 16 taken 4 times.
✓ Branch 28 → 49 taken 2 times.
void OL_DarkenImage::BlendImageMask<unsigned char, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 28 → 16 taken 4 times.
✓ Branch 28 → 49 taken 2 times.
void OL_DarkenImage::BlendImageMask<unsigned short, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 28 → 16 not taken.
✗ Branch 28 → 49 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 28 → 16 not taken.
✗ Branch 28 → 49 not taken.
|
12 | for (int y = 0; y < h; y++) { |
| 137 |
4/8void OL_DarkenImage::BlendImageMask<unsigned char, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 26 → 17 taken 16 times.
✓ Branch 26 → 27 taken 4 times.
void OL_DarkenImage::BlendImageMask<unsigned char, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 26 → 17 taken 16 times.
✓ Branch 26 → 27 taken 4 times.
void OL_DarkenImage::BlendImageMask<unsigned short, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 26 → 17 not taken.
✗ Branch 26 → 27 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 26 → 17 not taken.
✗ Branch 26 → 27 not taken.
|
40 | for (int x = 0; x < w; x++) { |
| 138 | bool cmp; | ||
| 139 | if constexpr (of_darken) | ||
| 140 | 16 | cmp = ovY[x] < baseY[x]; | |
| 141 | else | ||
| 142 | 16 | cmp = ovY[x] > baseY[x]; | |
| 143 |
4/8void OL_DarkenImage::BlendImageMask<unsigned char, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 17 → 18 taken 8 times.
✓ Branch 17 → 25 taken 8 times.
void OL_DarkenImage::BlendImageMask<unsigned char, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 17 → 18 taken 8 times.
✓ Branch 17 → 25 taken 8 times.
void OL_DarkenImage::BlendImageMask<unsigned short, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 25 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 25 not taken.
|
32 | if (cmp) { |
| 144 | 16 | uint32_t maskYx = maskY[x]; | |
| 145 | 16 | uint32_t maskUx = maskU[x]; | |
| 146 | 16 | uint32_t maskVx = maskV[x]; | |
| 147 | 16 | baseY[x] = (pixel_t)magic_div_rt<pixel_t>((max_pixel_value - maskYx)*(uint32_t)baseY[x] + maskYx * (uint32_t)ovY[x], magic); | |
| 148 | 16 | baseU[x] = (pixel_t)magic_div_rt<pixel_t>((max_pixel_value - maskUx)*(uint32_t)baseU[x] + maskUx * (uint32_t)ovU[x], magic); | |
| 149 | 32 | baseV[x] = (pixel_t)magic_div_rt<pixel_t>((max_pixel_value - maskVx)*(uint32_t)baseV[x] + maskVx * (uint32_t)ovV[x], magic); | |
| 150 | } | ||
| 151 | } | ||
| 152 | 8 | maskY += maskpitch; | |
| 153 | 8 | maskU += maskpitch; | |
| 154 | 8 | maskV += maskpitch; | |
| 155 | |||
| 156 | 8 | baseY += basepitch; | |
| 157 | 8 | baseU += basepitch; | |
| 158 | 8 | baseV += basepitch; | |
| 159 | |||
| 160 | 8 | ovY += overlaypitch; | |
| 161 | 8 | ovU += overlaypitch; | |
| 162 | 8 | ovV += overlaypitch; | |
| 163 | } | ||
| 164 | } else { | ||
| 165 | // opacity_f == 1.0f && !maskMode | ||
| 166 | if constexpr (of_darken) { | ||
| 167 | #ifdef INTEL_INTRINSICS | ||
| 168 |
2/4✓ Branch 12 → 13 taken 3 times.
✗ Branch 12 → 34 not taken.
✓ Branch 13 → 14 taken 3 times.
✗ Branch 13 → 15 not taken.
|
3 | if (sizeof(pixel_t)==1 && (env->GetCPUFlags() & CPUF_SSE4_1)) { |
| 169 |
1/2✓ Branch 14 → 33 taken 3 times.
✗ Branch 14 → 34 not taken.
|
3 | overlay_darken_sse41((BYTE *)baseY, (BYTE *)baseU, (BYTE *)baseV, (BYTE *)ovY, (BYTE *)ovU, (BYTE *)ovV, basepitch, overlaypitch, w, h); |
| 170 | ✗ | } else if (sizeof(pixel_t)==1 && (env->GetCPUFlags() & CPUF_SSE2)) { | |
| 171 | ✗ | overlay_darken_sse2((BYTE *)baseY, (BYTE *)baseU, (BYTE *)baseV, (BYTE *)ovY, (BYTE *)ovU, (BYTE *)ovV, basepitch, overlaypitch, w, h); | |
| 172 | } else | ||
| 173 | #ifdef X86_32 | ||
| 174 | if (sizeof(pixel_t)==1 && (env->GetCPUFlags() & CPUF_MMX)) { | ||
| 175 | overlay_darken_mmx((BYTE *)baseY, (BYTE *)baseU, (BYTE *)baseV, (BYTE *)ovY, (BYTE *)ovU, (BYTE *)ovV, basepitch, overlaypitch, w, h); | ||
| 176 | } else | ||
| 177 | #endif | ||
| 178 | #endif | ||
| 179 | { | ||
| 180 | |||
| 181 | ✗ | overlay_darken_c<pixel_t>((BYTE *)baseY, (BYTE *)baseU, (BYTE *)baseV, (BYTE *)ovY, (BYTE *)ovU, (BYTE *)ovV, basepitch, overlaypitch, w, h); | |
| 182 | } | ||
| 183 | } else { | ||
| 184 | // OF_Lighten | ||
| 185 | #ifdef INTEL_INTRINSICS | ||
| 186 |
2/4✓ Branch 12 → 13 taken 3 times.
✗ Branch 12 → 34 not taken.
✓ Branch 13 → 14 taken 3 times.
✗ Branch 13 → 15 not taken.
|
3 | if (sizeof(pixel_t)==1 && (env->GetCPUFlags() & CPUF_SSE4_1)) { |
| 187 |
1/2✓ Branch 14 → 33 taken 3 times.
✗ Branch 14 → 34 not taken.
|
3 | overlay_lighten_sse41((BYTE *)baseY, (BYTE *)baseU, (BYTE *)baseV, (BYTE *)ovY, (BYTE *)ovU, (BYTE *)ovV, basepitch, overlaypitch, w, h); |
| 188 | ✗ | } else if (sizeof(pixel_t)==1 && (env->GetCPUFlags() & CPUF_SSE2)) { | |
| 189 | ✗ | overlay_lighten_sse2((BYTE *)baseY, (BYTE *)baseU, (BYTE *)baseV, (BYTE *)ovY, (BYTE *)ovU, (BYTE *)ovV, basepitch, overlaypitch, w, h); | |
| 190 | } else | ||
| 191 | #ifdef X86_32 | ||
| 192 | if (sizeof(pixel_t)==1 && (env->GetCPUFlags() & CPUF_MMX)) { | ||
| 193 | overlay_lighten_mmx((BYTE *)baseY, (BYTE *)baseU, (BYTE *)baseV, (BYTE *)ovY, (BYTE *)ovU, (BYTE *)ovV, basepitch, overlaypitch, w, h); | ||
| 194 | } else | ||
| 195 | #endif | ||
| 196 | #endif | ||
| 197 | { | ||
| 198 | ✗ | overlay_lighten_c<pixel_t>((BYTE *)baseY, (BYTE *)baseU, (BYTE *)baseV, (BYTE *)ovY, (BYTE *)ovU, (BYTE *)ovV, basepitch, overlaypitch, w, h); | |
| 199 | } | ||
| 200 | } | ||
| 201 | |||
| 202 | } | ||
| 203 | } else { | ||
| 204 | // opacity_f != 1.0f && maskMode | ||
| 205 |
4/16void OL_DarkenImage::BlendImageMask<unsigned char, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 32 → 20 taken 3 times.
✓ Branch 32 → 33 taken 1 time.
void OL_DarkenImage::BlendImageMask<unsigned char, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 32 → 20 taken 3 times.
✓ Branch 32 → 33 taken 1 time.
void OL_DarkenImage::BlendImageMask<unsigned char, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 48 → 30 not taken.
✗ Branch 48 → 49 not taken.
void OL_DarkenImage::BlendImageMask<unsigned char, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 48 → 30 not taken.
✗ Branch 48 → 49 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 26 → 14 not taken.
✗ Branch 26 → 27 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 26 → 14 not taken.
✗ Branch 26 → 27 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 48 → 30 not taken.
✗ Branch 48 → 49 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 48 → 30 not taken.
✗ Branch 48 → 49 not taken.
|
8 | for (int y = 0; y < h; y++) { |
| 206 |
4/16void OL_DarkenImage::BlendImageMask<unsigned char, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 30 → 21 taken 15 times.
✓ Branch 30 → 31 taken 3 times.
void OL_DarkenImage::BlendImageMask<unsigned char, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 30 → 21 taken 15 times.
✓ Branch 30 → 31 taken 3 times.
void OL_DarkenImage::BlendImageMask<unsigned char, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 46 → 31 not taken.
✗ Branch 46 → 47 not taken.
void OL_DarkenImage::BlendImageMask<unsigned char, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 46 → 31 not taken.
✗ Branch 46 → 47 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 24 → 15 not taken.
✗ Branch 24 → 25 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 24 → 15 not taken.
✗ Branch 24 → 25 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 46 → 31 not taken.
✗ Branch 46 → 47 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 46 → 31 not taken.
✗ Branch 46 → 47 not taken.
|
36 | for (int x = 0; x < w; x++) { |
| 207 | bool cmp; | ||
| 208 | if constexpr (of_darken) | ||
| 209 | 15 | cmp = ovY[x] < baseY[x]; | |
| 210 | else | ||
| 211 | 15 | cmp = ovY[x] > baseY[x]; | |
| 212 |
4/16void OL_DarkenImage::BlendImageMask<unsigned char, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 21 → 22 taken 6 times.
✓ Branch 21 → 29 taken 9 times.
void OL_DarkenImage::BlendImageMask<unsigned char, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 21 → 22 taken 6 times.
✓ Branch 21 → 29 taken 9 times.
void OL_DarkenImage::BlendImageMask<unsigned char, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 45 not taken.
void OL_DarkenImage::BlendImageMask<unsigned char, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 45 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 23 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 23 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 45 not taken.
void OL_DarkenImage::BlendImageMask<unsigned short, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 45 not taken.
|
30 | if (cmp) { |
| 213 | // eff on the max_pixel_value scale; mask == max_pixel_value when absent. | ||
| 214 | uint32_t effY, effU, effV; // effective masks/opacity/their combinations | ||
| 215 | if constexpr (maskMode) { | ||
| 216 | ✗ | effY = magic_div_rt<pixel_t>((uint32_t)maskY[x] * (uint32_t)opacity_i + rounder, magic); | |
| 217 | ✗ | effU = magic_div_rt<pixel_t>((uint32_t)maskU[x] * (uint32_t)opacity_i + rounder, magic); | |
| 218 | ✗ | effV = magic_div_rt<pixel_t>((uint32_t)maskV[x] * (uint32_t)opacity_i + rounder, magic); | |
| 219 | } else { | ||
| 220 | 12 | effY = (uint32_t)opacity_i; | |
| 221 | 12 | effU = (uint32_t)opacity_i; | |
| 222 | 12 | effV = (uint32_t)opacity_i; | |
| 223 | } | ||
| 224 | 12 | baseY[x] = (pixel_t)magic_div_rt<pixel_t>((max_pixel_value - effY)*(uint32_t)baseY[x] + effY*(uint32_t)ovY[x] + rounder, magic); | |
| 225 | 12 | baseU[x] = (pixel_t)magic_div_rt<pixel_t>((max_pixel_value - effU)*(uint32_t)baseU[x] + effU*(uint32_t)ovU[x] + rounder, magic); | |
| 226 | 24 | baseV[x] = (pixel_t)magic_div_rt<pixel_t>((max_pixel_value - effV)*(uint32_t)baseV[x] + effV*(uint32_t)ovV[x] + rounder, magic); | |
| 227 | } | ||
| 228 | } | ||
| 229 | 6 | baseY += basepitch; | |
| 230 | 6 | baseU += basepitch; | |
| 231 | 6 | baseV += basepitch; | |
| 232 | |||
| 233 | 6 | ovY += overlaypitch; | |
| 234 | 6 | ovU += overlaypitch; | |
| 235 | 6 | ovV += overlaypitch; | |
| 236 | |||
| 237 | if constexpr (maskMode) { | ||
| 238 | ✗ | maskY += maskpitch; | |
| 239 | ✗ | maskU += maskpitch; | |
| 240 | ✗ | maskV += maskpitch; | |
| 241 | } | ||
| 242 | } | ||
| 243 | } | ||
| 244 | 12 | } | |
| 245 | |||
| 246 |