| Line | Branch | Exec | Source | 
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2013 Paul B Mahol | ||
| 3 | * | ||
| 4 | * This file is part of FFmpeg. | ||
| 5 | * | ||
| 6 | * FFmpeg 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 | * FFmpeg 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 FFmpeg; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | #ifndef AVFILTER_BLEND_INIT_H | ||
| 22 | #define AVFILTER_BLEND_INIT_H | ||
| 23 | |||
| 24 | #include "config.h" | ||
| 25 | #include "libavutil/attributes.h" | ||
| 26 | #include "libavutil/imgutils.h" | ||
| 27 | #include "blend.h" | ||
| 28 | |||
| 29 | #define DEPTH 8 | ||
| 30 | #include "blend_modes.c" | ||
| 31 | |||
| 32 | #undef DEPTH | ||
| 33 | #define DEPTH 9 | ||
| 34 | #include "blend_modes.c" | ||
| 35 | |||
| 36 | #undef DEPTH | ||
| 37 | #define DEPTH 10 | ||
| 38 | #include "blend_modes.c" | ||
| 39 | |||
| 40 | #undef DEPTH | ||
| 41 | #define DEPTH 12 | ||
| 42 | #include "blend_modes.c" | ||
| 43 | |||
| 44 | #undef DEPTH | ||
| 45 | #define DEPTH 14 | ||
| 46 | #include "blend_modes.c" | ||
| 47 | |||
| 48 | #undef DEPTH | ||
| 49 | #define DEPTH 16 | ||
| 50 | #include "blend_modes.c" | ||
| 51 | |||
| 52 | #undef DEPTH | ||
| 53 | #define DEPTH 32 | ||
| 54 | #include "blend_modes.c" | ||
| 55 | |||
| 56 | #define COPY(src, depth) \ | ||
| 57 | static void blend_copy ## src##_##depth(const uint8_t *top, ptrdiff_t top_linesize, \ | ||
| 58 | const uint8_t *bottom, ptrdiff_t bottom_linesize,\ | ||
| 59 | uint8_t *dst, ptrdiff_t dst_linesize, \ | ||
| 60 | ptrdiff_t width, ptrdiff_t height, \ | ||
| 61 | FilterParams *param, SliceParams *sliceparam) \ | ||
| 62 | { \ | ||
| 63 | av_image_copy_plane(dst, dst_linesize, src, src ## _linesize, \ | ||
| 64 | width * depth / 8, height); \ | ||
| 65 | } | ||
| 66 | |||
| 67 | ✗ | COPY(top, 8) | |
| 68 | ✗ | COPY(bottom, 8) | |
| 69 | |||
| 70 | ✗ | COPY(top, 16) | |
| 71 | ✗ | COPY(bottom, 16) | |
| 72 | |||
| 73 | ✗ | COPY(top, 32) | |
| 74 | ✗ | COPY(bottom, 32) | |
| 75 | |||
| 76 | #undef COPY | ||
| 77 | |||
| 78 | #define BLEND_NORMAL(name, type) \ | ||
| 79 | static void blend_normal_##name(const uint8_t *_top, ptrdiff_t top_linesize, \ | ||
| 80 | const uint8_t *_bottom, ptrdiff_t bottom_linesize,\ | ||
| 81 | uint8_t *_dst, ptrdiff_t dst_linesize, \ | ||
| 82 | ptrdiff_t width, ptrdiff_t height, \ | ||
| 83 | FilterParams *param, SliceParams *sliceparam) \ | ||
| 84 | { \ | ||
| 85 | const float opacity = param->opacity; \ | ||
| 86 | \ | ||
| 87 | for (int i = 0; i < height; i++) { \ | ||
| 88 | const type *top = (const type*)_top; \ | ||
| 89 | const type *bottom = (const type*)_bottom; \ | ||
| 90 | type *dst = (type*)_dst; \ | ||
| 91 | for (int j = 0; j < width; j++) { \ | ||
| 92 | dst[j] = top[j] * opacity + bottom[j] * (1.f - opacity); \ | ||
| 93 | } \ | ||
| 94 | _dst += dst_linesize; \ | ||
| 95 | _top += top_linesize; \ | ||
| 96 | _bottom += bottom_linesize; \ | ||
| 97 | } \ | ||
| 98 | } | ||
| 99 | |||
| 100 | ✗ | BLEND_NORMAL(8bit, uint8_t) | |
| 101 | ✗ | BLEND_NORMAL(16bit, uint16_t) | |
| 102 | ✗ | BLEND_NORMAL(32bit, float) | |
| 103 | |||
| 104 | #define DEFINE_INIT_BLEND_FUNC(depth, nbits) \ | ||
| 105 | static av_cold void init_blend_func_##depth##_##nbits##bit(FilterParams *param) \ | ||
| 106 | { \ | ||
| 107 | switch (param->mode) { \ | ||
| 108 | case BLEND_ADDITION: param->blend = blend_addition_##depth##bit; break; \ | ||
| 109 | case BLEND_GRAINMERGE: param->blend = blend_grainmerge_##depth##bit; break; \ | ||
| 110 | case BLEND_AND: param->blend = blend_and_##nbits##bit; break; \ | ||
| 111 | case BLEND_AVERAGE: param->blend = blend_average_##nbits##bit; break; \ | ||
| 112 | case BLEND_BURN: param->blend = blend_burn_##depth##bit; break; \ | ||
| 113 | case BLEND_DARKEN: param->blend = blend_darken_##nbits##bit; break; \ | ||
| 114 | case BLEND_DIFFERENCE: param->blend = blend_difference_##nbits##bit; break; \ | ||
| 115 | case BLEND_GRAINEXTRACT: param->blend = blend_grainextract_##depth##bit; break; \ | ||
| 116 | case BLEND_DIVIDE: param->blend = blend_divide_##depth##bit; break; \ | ||
| 117 | case BLEND_DODGE: param->blend = blend_dodge_##depth##bit; break; \ | ||
| 118 | case BLEND_EXCLUSION: param->blend = blend_exclusion_##depth##bit; break; \ | ||
| 119 | case BLEND_EXTREMITY: param->blend = blend_extremity_##depth##bit; break; \ | ||
| 120 | case BLEND_FREEZE: param->blend = blend_freeze_##depth##bit; break; \ | ||
| 121 | case BLEND_GLOW: param->blend = blend_glow_##depth##bit; break; \ | ||
| 122 | case BLEND_HARDLIGHT: param->blend = blend_hardlight_##depth##bit; break; \ | ||
| 123 | case BLEND_HARDMIX: param->blend = blend_hardmix_##depth##bit; break; \ | ||
| 124 | case BLEND_HEAT: param->blend = blend_heat_##depth##bit; break; \ | ||
| 125 | case BLEND_LIGHTEN: param->blend = blend_lighten_##nbits##bit; break; \ | ||
| 126 | case BLEND_LINEARLIGHT: param->blend = blend_linearlight_##depth##bit; break; \ | ||
| 127 | case BLEND_MULTIPLY: param->blend = blend_multiply_##depth##bit; break; \ | ||
| 128 | case BLEND_MULTIPLY128: param->blend = blend_multiply128_##depth##bit; break; \ | ||
| 129 | case BLEND_NEGATION: param->blend = blend_negation_##depth##bit; break; \ | ||
| 130 | case BLEND_NORMAL: param->blend = blend_normal_##nbits##bit; break; \ | ||
| 131 | case BLEND_OR: param->blend = blend_or_##nbits##bit; break; \ | ||
| 132 | case BLEND_OVERLAY: param->blend = blend_overlay_##depth##bit; break; \ | ||
| 133 | case BLEND_PHOENIX: param->blend = blend_phoenix_##depth##bit; break; \ | ||
| 134 | case BLEND_PINLIGHT: param->blend = blend_pinlight_##depth##bit; break; \ | ||
| 135 | case BLEND_REFLECT: param->blend = blend_reflect_##depth##bit; break; \ | ||
| 136 | case BLEND_SCREEN: param->blend = blend_screen_##depth##bit; break; \ | ||
| 137 | case BLEND_SOFTLIGHT: param->blend = blend_softlight_##depth##bit; break; \ | ||
| 138 | case BLEND_SUBTRACT: param->blend = blend_subtract_##nbits##bit; break; \ | ||
| 139 | case BLEND_VIVIDLIGHT: param->blend = blend_vividlight_##depth##bit; break; \ | ||
| 140 | case BLEND_XOR: param->blend = blend_xor_##nbits##bit; break; \ | ||
| 141 | case BLEND_SOFTDIFFERENCE:param->blend=blend_softdifference_##depth##bit;break; \ | ||
| 142 | case BLEND_GEOMETRIC: param->blend = blend_geometric_##nbits##bit; break; \ | ||
| 143 | case BLEND_HARMONIC: param->blend = blend_harmonic_##nbits##bit; break; \ | ||
| 144 | case BLEND_BLEACH: param->blend = blend_bleach_##depth##bit; break; \ | ||
| 145 | case BLEND_STAIN: param->blend = blend_stain_##depth##bit; break; \ | ||
| 146 | case BLEND_INTERPOLATE: param->blend = blend_interpolate_##depth##bit; break; \ | ||
| 147 | case BLEND_HARDOVERLAY: param->blend = blend_hardoverlay_##depth##bit; break; \ | ||
| 148 | } \ | ||
| 149 | } | ||
| 150 | 
        17/41✓ Branch 0 taken 13 times. 
          ✓ Branch 1 taken 13 times. 
          ✓ Branch 2 taken 13 times. 
          ✓ Branch 3 taken 13 times. 
          ✗ Branch 4 not taken. 
          ✓ Branch 5 taken 13 times. 
          ✓ Branch 6 taken 13 times. 
          ✓ Branch 7 taken 17 times. 
          ✗ Branch 8 not taken. 
          ✗ Branch 9 not taken. 
          ✗ Branch 10 not taken. 
          ✓ Branch 11 taken 13 times. 
          ✗ Branch 12 not taken. 
          ✗ Branch 13 not taken. 
          ✗ Branch 14 not taken. 
          ✓ Branch 15 taken 13 times. 
          ✗ Branch 16 not taken. 
          ✓ Branch 17 taken 13 times. 
          ✗ Branch 18 not taken. 
          ✓ Branch 19 taken 13 times. 
          ✗ Branch 20 not taken. 
          ✓ Branch 21 taken 13 times. 
          ✗ Branch 22 not taken. 
          ✓ Branch 23 taken 13 times. 
          ✗ Branch 24 not taken. 
          ✓ Branch 25 taken 13 times. 
          ✗ Branch 26 not taken. 
          ✗ Branch 27 not taken. 
          ✓ Branch 28 taken 13 times. 
          ✗ Branch 29 not taken. 
          ✓ Branch 30 taken 13 times. 
          ✗ Branch 31 not taken. 
          ✓ Branch 32 taken 13 times. 
          ✗ Branch 33 not taken. 
          ✗ Branch 34 not taken. 
          ✗ Branch 35 not taken. 
          ✗ Branch 36 not taken. 
          ✗ Branch 37 not taken. 
          ✗ Branch 38 not taken. 
          ✗ Branch 39 not taken. 
          ✗ Branch 40 not taken. 
         | 
      225 | DEFINE_INIT_BLEND_FUNC(8, 8) | 
| 151 | ✗ | DEFINE_INIT_BLEND_FUNC(9, 16) | |
| 152 | ✗ | DEFINE_INIT_BLEND_FUNC(10, 16) | |
| 153 | ✗ | DEFINE_INIT_BLEND_FUNC(12, 16) | |
| 154 | ✗ | DEFINE_INIT_BLEND_FUNC(14, 16) | |
| 155 | 
        13/41✓ Branch 0 taken 13 times. 
          ✓ Branch 1 taken 13 times. 
          ✓ Branch 2 taken 13 times. 
          ✓ Branch 3 taken 13 times. 
          ✗ Branch 4 not taken. 
          ✓ Branch 5 taken 13 times. 
          ✓ Branch 6 taken 13 times. 
          ✓ Branch 7 taken 13 times. 
          ✗ Branch 8 not taken. 
          ✗ Branch 9 not taken. 
          ✗ Branch 10 not taken. 
          ✓ Branch 11 taken 13 times. 
          ✗ Branch 12 not taken. 
          ✗ Branch 13 not taken. 
          ✗ Branch 14 not taken. 
          ✗ Branch 15 not taken. 
          ✗ Branch 16 not taken. 
          ✓ Branch 17 taken 13 times. 
          ✗ Branch 18 not taken. 
          ✗ Branch 19 not taken. 
          ✗ Branch 20 not taken. 
          ✓ Branch 21 taken 13 times. 
          ✗ Branch 22 not taken. 
          ✓ Branch 23 taken 13 times. 
          ✗ Branch 24 not taken. 
          ✓ Branch 25 taken 13 times. 
          ✗ Branch 26 not taken. 
          ✗ Branch 27 not taken. 
          ✗ Branch 28 not taken. 
          ✗ Branch 29 not taken. 
          ✓ Branch 30 taken 26 times. 
          ✗ Branch 31 not taken. 
          ✗ Branch 32 not taken. 
          ✗ Branch 33 not taken. 
          ✗ Branch 34 not taken. 
          ✗ Branch 35 not taken. 
          ✗ Branch 36 not taken. 
          ✗ Branch 37 not taken. 
          ✗ Branch 38 not taken. 
          ✗ Branch 39 not taken. 
          ✗ Branch 40 not taken. 
         | 
      182 | DEFINE_INIT_BLEND_FUNC(16, 16) | 
| 156 | ✗ | DEFINE_INIT_BLEND_FUNC(32, 32) | |
| 157 | |||
| 158 | 407 | av_unused static void ff_blend_init(FilterParams *param, int depth) | |
| 159 | { | ||
| 160 | 
        2/8✓ Branch 0 taken 225 times. 
          ✗ Branch 1 not taken. 
          ✗ Branch 2 not taken. 
          ✗ Branch 3 not taken. 
          ✗ Branch 4 not taken. 
          ✓ Branch 5 taken 182 times. 
          ✗ Branch 6 not taken. 
          ✗ Branch 7 not taken. 
         | 
      407 | switch (depth) { | 
| 161 | 225 | case 8: | |
| 162 | 225 | init_blend_func_8_8bit(param); | |
| 163 | 225 | break; | |
| 164 | ✗ | case 9: | |
| 165 | ✗ | init_blend_func_9_16bit(param); | |
| 166 | ✗ | break; | |
| 167 | ✗ | case 10: | |
| 168 | ✗ | init_blend_func_10_16bit(param); | |
| 169 | ✗ | break; | |
| 170 | ✗ | case 12: | |
| 171 | ✗ | init_blend_func_12_16bit(param); | |
| 172 | ✗ | break; | |
| 173 | ✗ | case 14: | |
| 174 | ✗ | init_blend_func_14_16bit(param); | |
| 175 | ✗ | break; | |
| 176 | 182 | case 16: | |
| 177 | 182 | init_blend_func_16_16bit(param); | |
| 178 | 182 | break; | |
| 179 | ✗ | case 32: | |
| 180 | ✗ | init_blend_func_32_32bit(param); | |
| 181 | ✗ | break; | |
| 182 | } | ||
| 183 | |||
| 184 | 
        1/4✗ Branch 0 not taken. 
          ✓ Branch 1 taken 407 times. 
          ✗ Branch 2 not taken. 
          ✗ Branch 3 not taken. 
         | 
      407 | if (param->opacity == 0 && param->mode != BLEND_NORMAL) { | 
| 185 | ✗ | param->blend = depth > 8 ? depth > 16 ? blend_copytop_32 : blend_copytop_16 : blend_copytop_8; | |
| 186 | 
        1/2✗ Branch 0 not taken. 
          ✓ Branch 1 taken 407 times. 
         | 
      407 | } else if (param->mode == BLEND_NORMAL) { | 
| 187 | ✗ | if (param->opacity == 1) | |
| 188 | ✗ | param->blend = depth > 8 ? depth > 16 ? blend_copytop_32 : blend_copytop_16 : blend_copytop_8; | |
| 189 | ✗ | else if (param->opacity == 0) | |
| 190 | ✗ | param->blend = depth > 8 ? depth > 16 ? blend_copybottom_32 : blend_copybottom_16 : blend_copybottom_8; | |
| 191 | } | ||
| 192 | |||
| 193 | #if ARCH_X86 | ||
| 194 | 407 | ff_blend_init_x86(param, depth); | |
| 195 | #endif | ||
| 196 | 407 | } | |
| 197 | |||
| 198 | #endif /* AVFILTER_BLEND_INIT_H */ | ||
| 199 |