filters/overlay/OF_softhardlight.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 <stdint.h> | ||
| 40 | #include <type_traits> | ||
| 41 | |||
| 42 | 2 | void OL_SoftLightImage::DoBlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask) { | |
| 43 |
2/2✓ Branch 2 → 3 taken 1 time.
✓ Branch 2 → 7 taken 1 time.
|
2 | if(of_mode == OF_SoftLight) { |
| 44 |
1/2✓ Branch 3 → 4 taken 1 time.
✗ Branch 3 → 5 not taken.
|
1 | if (bits_per_pixel == 8) |
| 45 | 1 | BlendImageMask<uint8_t, true, false>(base, overlay, mask); | |
| 46 | ✗ | else if(bits_per_pixel <= 16) | |
| 47 | ✗ | BlendImageMask<uint16_t, true, false>(base, overlay, mask); | |
| 48 | //else if(bits_per_pixel == 32) | ||
| 49 | // BlendImageMask<float>(base, overlay, mask); | ||
| 50 | } else { | ||
| 51 | // OF_HardLight | ||
| 52 |
1/2✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 9 not taken.
|
1 | if (bits_per_pixel == 8) |
| 53 | 1 | BlendImageMask<uint8_t, true, true>(base, overlay, mask); | |
| 54 | ✗ | else if(bits_per_pixel <= 16) | |
| 55 | ✗ | BlendImageMask<uint16_t, true, true>(base, overlay, mask); | |
| 56 | //else if(bits_per_pixel == 32) | ||
| 57 | // BlendImageMask<float>(base, overlay, mask); | ||
| 58 | } | ||
| 59 | 2 | } | |
| 60 | |||
| 61 | 2 | void OL_SoftLightImage::DoBlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay) { | |
| 62 |
2/2✓ Branch 2 → 3 taken 1 time.
✓ Branch 2 → 7 taken 1 time.
|
2 | if(of_mode == OF_SoftLight) { |
| 63 |
1/2✓ Branch 3 → 4 taken 1 time.
✗ Branch 3 → 5 not taken.
|
1 | if (bits_per_pixel == 8) |
| 64 | 1 | BlendImageMask<uint8_t, false, false>(base, overlay, nullptr); | |
| 65 | ✗ | else if(bits_per_pixel <= 16) | |
| 66 | ✗ | BlendImageMask<uint16_t, false, false>(base, overlay, nullptr); | |
| 67 | //else if(bits_per_pixel == 32) | ||
| 68 | // BlendImage<float>(base, overlay); | ||
| 69 | } | ||
| 70 | else { | ||
| 71 | // OF_HardLight | ||
| 72 |
1/2✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 9 not taken.
|
1 | if (bits_per_pixel == 8) |
| 73 | 1 | BlendImageMask<uint8_t, false, true>(base, overlay, nullptr); | |
| 74 | ✗ | else if(bits_per_pixel <= 16) | |
| 75 | ✗ | BlendImageMask<uint16_t, false, true>(base, overlay, nullptr); | |
| 76 | //else if(bits_per_pixel == 32) | ||
| 77 | // BlendImageMask<float>(base, overlay, mask); | ||
| 78 | } | ||
| 79 | 2 | } | |
| 80 | |||
| 81 | template<typename pixel_t, bool maskMode, bool hardLight> | ||
| 82 | 4 | void OL_SoftLightImage::BlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask) { | |
| 83 | 4 | pixel_t* baseY = reinterpret_cast<pixel_t *>(base->GetPtr(PLANAR_Y)); | |
| 84 | 4 | pixel_t* baseU = reinterpret_cast<pixel_t *>(base->GetPtr(PLANAR_U)); | |
| 85 | 4 | pixel_t* baseV = reinterpret_cast<pixel_t *>(base->GetPtr(PLANAR_V)); | |
| 86 | |||
| 87 | 4 | pixel_t* ovY = reinterpret_cast<pixel_t *>(overlay->GetPtr(PLANAR_Y)); | |
| 88 | 4 | pixel_t* ovU = reinterpret_cast<pixel_t *>(overlay->GetPtr(PLANAR_U)); | |
| 89 | 4 | pixel_t* ovV = reinterpret_cast<pixel_t *>(overlay->GetPtr(PLANAR_V)); | |
| 90 | |||
| 91 | 4 | pixel_t* maskY = maskMode ? reinterpret_cast<pixel_t *>(mask->GetPtr(PLANAR_Y)) : nullptr; | |
| 92 | 4 | pixel_t* maskU = maskMode ? reinterpret_cast<pixel_t *>(mask->GetPtr(PLANAR_U)) : nullptr; | |
| 93 | 4 | pixel_t* maskV = maskMode ? reinterpret_cast<pixel_t *>(mask->GetPtr(PLANAR_V)) : nullptr; | |
| 94 | |||
| 95 | 4 | const int half_pixel_value = (sizeof(pixel_t) == 1) ? 128 : (1 << (bits_per_pixel - 1)); | |
| 96 | 4 | const int max_pixel_value = (sizeof(pixel_t) == 1) ? 255 : (1 << bits_per_pixel) - 1; | |
| 97 | 4 | const int pixel_range = max_pixel_value + 1; | |
| 98 | 4 | const int SHIFT = (sizeof(pixel_t) == 1) ? 5 : 5 + (bits_per_pixel - 8); | |
| 99 | 4 | const int MASK_CORR_SHIFT = (sizeof(pixel_t) == 1) ? 8 : bits_per_pixel; | |
| 100 | 4 | const int OPACITY_SHIFT = 8; // opacity always max 0..256 | |
| 101 | 4 | const int over32 = (1 << SHIFT); // 32 | |
| 102 | 4 | const int basepitch = (base->pitch) / sizeof(pixel_t); | |
| 103 | 4 | const int overlaypitch = (overlay->pitch) / sizeof(pixel_t); | |
| 104 | 4 | const int maskpitch = maskMode ? (mask->pitch) / sizeof(pixel_t) : 0; | |
| 105 | |||
| 106 | // avoid "uint16*uint16 can't get into int32" overflows | ||
| 107 | typedef typename std::conditional < sizeof(pixel_t) == 1, int, typename std::conditional < sizeof(pixel_t) == 2, int64_t, float>::type >::type result_t; | ||
| 108 | |||
| 109 | 4 | int w = base->w(); | |
| 110 | 4 | int h = base->h(); | |
| 111 | |||
| 112 |
4/16void OL_SoftLightImage::BlendImageMask<unsigned char, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 27 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned char, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 10 → 11 taken 1 time.
✗ Branch 10 → 28 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned char, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 13 → 14 taken 1 time.
✗ Branch 13 → 28 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned char, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 13 → 14 taken 1 time.
✗ Branch 13 → 29 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 27 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 28 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 28 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 29 not taken.
|
4 | if (opacity == 256) { |
| 113 |
8/16void OL_SoftLightImage::BlendImageMask<unsigned char, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 26 → 12 taken 2 times.
✓ Branch 26 → 43 taken 1 time.
void OL_SoftLightImage::BlendImageMask<unsigned char, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 27 → 12 taken 2 times.
✓ Branch 27 → 45 taken 1 time.
void OL_SoftLightImage::BlendImageMask<unsigned char, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 27 → 15 taken 2 times.
✓ Branch 27 → 44 taken 1 time.
void OL_SoftLightImage::BlendImageMask<unsigned char, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 28 → 15 taken 2 times.
✓ Branch 28 → 46 taken 1 time.
void OL_SoftLightImage::BlendImageMask<unsigned short, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 26 → 12 not taken.
✗ Branch 26 → 43 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 27 → 12 not taken.
✗ Branch 27 → 45 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 27 → 15 not taken.
✗ Branch 27 → 44 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 28 → 15 not taken.
✗ Branch 28 → 46 not taken.
|
12 | for (int y = 0; y < h; y++) { |
| 114 |
8/16void OL_SoftLightImage::BlendImageMask<unsigned char, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 23 → 13 taken 8 times.
✓ Branch 23 → 24 taken 2 times.
void OL_SoftLightImage::BlendImageMask<unsigned char, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 24 → 13 taken 8 times.
✓ Branch 24 → 25 taken 2 times.
void OL_SoftLightImage::BlendImageMask<unsigned char, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 25 → 16 taken 8 times.
✓ Branch 25 → 26 taken 2 times.
void OL_SoftLightImage::BlendImageMask<unsigned char, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✓ Branch 26 → 16 taken 8 times.
✓ Branch 26 → 27 taken 2 times.
void OL_SoftLightImage::BlendImageMask<unsigned short, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 23 → 13 not taken.
✗ Branch 23 → 24 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 24 → 13 not taken.
✗ Branch 24 → 25 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 25 → 16 not taken.
✗ Branch 25 → 26 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 26 → 16 not taken.
✗ Branch 26 → 27 not taken.
|
40 | for (int x = 0; x < w; x++) { |
| 115 | int Y; | ||
| 116 | if(hardLight) | ||
| 117 | 16 | Y = (int)baseY[x] + ((int)ovY[x])*2 - half_pixel_value*2; | |
| 118 | else | ||
| 119 | 16 | Y = (int)baseY[x] + (int)ovY[x] - half_pixel_value; | |
| 120 | 32 | int U = baseU[x] + ovU[x] - half_pixel_value; | |
| 121 | 32 | int V = baseV[x] + ovV[x] - half_pixel_value; | |
| 122 | if(maskMode) { | ||
| 123 | 16 | result_t mY = maskY[x]; | |
| 124 | 16 | result_t mU = maskU[x]; | |
| 125 | 16 | result_t mV = maskV[x]; | |
| 126 | 16 | Y = (int)(((Y*mY) + ((pixel_range - mY)*baseY[x])) >> MASK_CORR_SHIFT); | |
| 127 | 16 | U = (int)(((U*mU) + ((pixel_range - mU)*baseU[x])) >> MASK_CORR_SHIFT); | |
| 128 | 16 | V = (int)(((V*mV) + ((pixel_range - mV)*baseV[x])) >> MASK_CORR_SHIFT); | |
| 129 | } | ||
| 130 |
4/16void OL_SoftLightImage::BlendImageMask<unsigned char, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 14 → 15 not taken.
✓ Branch 14 → 17 taken 8 times.
void OL_SoftLightImage::BlendImageMask<unsigned char, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 15 → 16 not taken.
✓ Branch 15 → 18 taken 8 times.
void OL_SoftLightImage::BlendImageMask<unsigned char, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 16 → 17 not taken.
✓ Branch 16 → 19 taken 8 times.
void OL_SoftLightImage::BlendImageMask<unsigned char, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 17 → 18 not taken.
✓ Branch 17 → 20 taken 8 times.
void OL_SoftLightImage::BlendImageMask<unsigned short, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 14 → 15 not taken.
✗ Branch 14 → 17 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 18 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 16 → 17 not taken.
✗ Branch 16 → 19 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 20 not taken.
|
32 | if (Y>max_pixel_value) { // Apply overbrightness to UV |
| 131 | ✗ | int multiplier = max(0,pixel_range + over32 -Y); // 0 to 32 | |
| 132 | ✗ | U = ((U*( multiplier)) + (half_pixel_value*(over32-multiplier)))>>SHIFT; | |
| 133 | ✗ | V = ((V*( multiplier)) + (half_pixel_value*(over32-multiplier)))>>SHIFT; | |
| 134 | ✗ | Y = max_pixel_value; | |
| 135 |
4/16void OL_SoftLightImage::BlendImageMask<unsigned char, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 17 → 18 not taken.
✓ Branch 17 → 20 taken 8 times.
void OL_SoftLightImage::BlendImageMask<unsigned char, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 18 → 19 not taken.
✓ Branch 18 → 21 taken 8 times.
void OL_SoftLightImage::BlendImageMask<unsigned char, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 19 → 20 not taken.
✓ Branch 19 → 22 taken 8 times.
void OL_SoftLightImage::BlendImageMask<unsigned char, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 20 → 21 not taken.
✓ Branch 20 → 23 taken 8 times.
void OL_SoftLightImage::BlendImageMask<unsigned short, false, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 20 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, false, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 21 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, true, false>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 19 → 20 not taken.
✗ Branch 19 → 22 not taken.
void OL_SoftLightImage::BlendImageMask<unsigned short, true, true>(ImageOverlayInternal*, ImageOverlayInternal*, ImageOverlayInternal*):
✗ Branch 20 → 21 not taken.
✗ Branch 20 → 23 not taken.
|
32 | } else if (Y<0) { // Apply superdark to UV |
| 136 | ✗ | int multiplier = min(-Y,over32); // 0 to 32 | |
| 137 | ✗ | U = ((U*(over32 - multiplier)) + (half_pixel_value*( multiplier)))>>SHIFT; | |
| 138 | ✗ | V = ((V*(over32 - multiplier)) + (half_pixel_value*( multiplier)))>>SHIFT; | |
| 139 | ✗ | Y = 0; | |
| 140 | } | ||
| 141 | 32 | baseY[x] = (pixel_t)Y; | |
| 142 | 32 | baseU[x] = (pixel_t)clamp(U, 0, max_pixel_value); | |
| 143 | 32 | baseV[x] = (pixel_t)clamp(V, 0, max_pixel_value); | |
| 144 | } | ||
| 145 | 8 | baseY += basepitch; | |
| 146 | 8 | baseU += basepitch; | |
| 147 | 8 | baseV += basepitch; | |
| 148 | |||
| 149 | 8 | ovY += overlaypitch; | |
| 150 | 8 | ovU += overlaypitch; | |
| 151 | 8 | ovV += overlaypitch; | |
| 152 | |||
| 153 | if(maskMode) { | ||
| 154 | 4 | maskY += maskpitch; | |
| 155 | 4 | maskU += maskpitch; | |
| 156 | 4 | maskV += maskpitch; | |
| 157 | } | ||
| 158 | } // for y | ||
| 159 | } else { | ||
| 160 | ✗ | for (int y = 0; y < h; y++) { | |
| 161 | ✗ | for (int x = 0; x < w; x++) { | |
| 162 | int Y; | ||
| 163 | if (hardLight) | ||
| 164 | ✗ | Y = (int)baseY[x] + ((int)ovY[x])*2 - half_pixel_value*2; | |
| 165 | else | ||
| 166 | ✗ | Y = (int)baseY[x] + (int)ovY[x] - half_pixel_value; | |
| 167 | ✗ | int U = baseU[x] + ovU[x] - half_pixel_value; | |
| 168 | ✗ | int V = baseV[x] + ovV[x] - half_pixel_value; | |
| 169 | if(maskMode) { | ||
| 170 | ✗ | result_t mY = (maskY[x] * opacity) >> OPACITY_SHIFT; | |
| 171 | ✗ | result_t mU = (maskU[x] * opacity) >> OPACITY_SHIFT; | |
| 172 | ✗ | result_t mV = (maskV[x] * opacity) >> OPACITY_SHIFT; | |
| 173 | ✗ | Y = (int)(((Y*mY) + ((pixel_range - mY)*baseY[x])) >> MASK_CORR_SHIFT); | |
| 174 | ✗ | U = (int)(((U*mU) + ((pixel_range - mU)*baseU[x])) >> MASK_CORR_SHIFT); | |
| 175 | ✗ | V = (int)(((V*mV) + ((pixel_range - mV)*baseV[x])) >> MASK_CORR_SHIFT); | |
| 176 | } | ||
| 177 | else { | ||
| 178 | ✗ | Y = ((Y*opacity) + (inv_opacity*baseY[x])) >> OPACITY_SHIFT; | |
| 179 | ✗ | U = ((U*opacity) + (inv_opacity*baseU[x])) >> OPACITY_SHIFT; | |
| 180 | ✗ | V = ((V*opacity) + (inv_opacity*baseV[x])) >> OPACITY_SHIFT; | |
| 181 | } | ||
| 182 | ✗ | if (Y>max_pixel_value) { // Apply overbrightness to UV | |
| 183 | ✗ | int multiplier = max(0,pixel_range + over32 -Y); // 0 to 32 | |
| 184 | ✗ | U = ((U*( multiplier)) + (half_pixel_value*(over32-multiplier)))>>SHIFT; | |
| 185 | ✗ | V = ((V*( multiplier)) + (half_pixel_value*(over32-multiplier)))>>SHIFT; | |
| 186 | ✗ | Y = max_pixel_value; | |
| 187 | ✗ | } else if (Y<0) { // Apply superdark to UV | |
| 188 | ✗ | int multiplier = min(-Y,over32); // 0 to 32 | |
| 189 | ✗ | U = ((U*(over32 - multiplier)) + (half_pixel_value*( multiplier)))>>SHIFT; | |
| 190 | ✗ | V = ((V*(over32 - multiplier)) + (half_pixel_value*( multiplier)))>>SHIFT; | |
| 191 | ✗ | Y = 0; | |
| 192 | } | ||
| 193 | ✗ | baseY[x] = (pixel_t)Y; | |
| 194 | ✗ | baseU[x] = (pixel_t)clamp(U, 0, max_pixel_value); | |
| 195 | ✗ | baseV[x] = (pixel_t)clamp(V, 0, max_pixel_value); | |
| 196 | } | ||
| 197 | ✗ | baseY += basepitch; | |
| 198 | ✗ | baseU += basepitch; | |
| 199 | ✗ | baseV += basepitch; | |
| 200 | |||
| 201 | ✗ | ovY += overlaypitch; | |
| 202 | ✗ | ovU += overlaypitch; | |
| 203 | ✗ | ovV += overlaypitch; | |
| 204 | |||
| 205 | if(maskMode) { | ||
| 206 | ✗ | maskY += maskpitch; | |
| 207 | ✗ | maskU += maskpitch; | |
| 208 | ✗ | maskV += maskpitch; | |
| 209 | } | ||
| 210 | } // for x | ||
| 211 | } // for y | ||
| 212 | 4 | } | |
| 213 | |||
| 214 |