LCOV - code coverage report
Current view: top level - libavfilter/x86 - vf_blend_init.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 79 82 96.3 %
Date: 2018-05-20 11:54:08 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2015 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             : #include "libavutil/attributes.h"
      22             : #include "libavutil/cpu.h"
      23             : #include "libavutil/x86/cpu.h"
      24             : #include "libavfilter/blend.h"
      25             : 
      26             : #define BLEND_FUNC(name, opt) \
      27             : void ff_blend_##name##_##opt(const uint8_t *top, ptrdiff_t top_linesize,       \
      28             :                              const uint8_t *bottom, ptrdiff_t bottom_linesize, \
      29             :                              uint8_t *dst, ptrdiff_t dst_linesize,             \
      30             :                              ptrdiff_t width, ptrdiff_t height,                \
      31             :                              struct FilterParams *param, double *values, int starty);
      32             : 
      33             : BLEND_FUNC(addition, sse2)
      34             : BLEND_FUNC(addition, avx2)
      35             : BLEND_FUNC(grainmerge, sse2)
      36             : BLEND_FUNC(grainmerge, avx2)
      37             : BLEND_FUNC(average, sse2)
      38             : BLEND_FUNC(average, avx2)
      39             : BLEND_FUNC(and, sse2)
      40             : BLEND_FUNC(and, avx2)
      41             : BLEND_FUNC(darken, sse2)
      42             : BLEND_FUNC(darken, avx2)
      43             : BLEND_FUNC(grainextract, sse2)
      44             : BLEND_FUNC(grainextract, avx2)
      45             : BLEND_FUNC(multiply, sse2)
      46             : BLEND_FUNC(multiply, avx2)
      47             : BLEND_FUNC(screen, sse2)
      48             : BLEND_FUNC(screen, avx2)
      49             : BLEND_FUNC(hardmix, sse2)
      50             : BLEND_FUNC(hardmix, avx2)
      51             : BLEND_FUNC(divide, sse2)
      52             : BLEND_FUNC(lighten, sse2)
      53             : BLEND_FUNC(lighten, avx2)
      54             : BLEND_FUNC(or, sse2)
      55             : BLEND_FUNC(or, avx2)
      56             : BLEND_FUNC(phoenix, sse2)
      57             : BLEND_FUNC(phoenix, avx2)
      58             : BLEND_FUNC(subtract, sse2)
      59             : BLEND_FUNC(subtract, avx2)
      60             : BLEND_FUNC(xor, sse2)
      61             : BLEND_FUNC(xor, avx2)
      62             : BLEND_FUNC(difference, sse2)
      63             : BLEND_FUNC(difference, ssse3)
      64             : BLEND_FUNC(difference, avx2)
      65             : BLEND_FUNC(extremity, sse2)
      66             : BLEND_FUNC(extremity, ssse3)
      67             : BLEND_FUNC(extremity, avx2)
      68             : BLEND_FUNC(negation, sse2)
      69             : BLEND_FUNC(negation, ssse3)
      70             : BLEND_FUNC(negation, avx2)
      71             : 
      72             : #if ARCH_X86_64
      73             : BLEND_FUNC(addition_16, sse2)
      74             : BLEND_FUNC(addition_16, avx2)
      75             : BLEND_FUNC(grainmerge_16, sse4)
      76             : BLEND_FUNC(grainmerge_16, avx2)
      77             : BLEND_FUNC(average_16, sse2)
      78             : BLEND_FUNC(average_16, avx2)
      79             : BLEND_FUNC(and_16, sse2)
      80             : BLEND_FUNC(and_16, avx2)
      81             : BLEND_FUNC(darken_16, sse4)
      82             : BLEND_FUNC(darken_16, avx2)
      83             : BLEND_FUNC(grainextract_16, sse4)
      84             : BLEND_FUNC(grainextract_16, avx2)
      85             : BLEND_FUNC(difference_16, sse4)
      86             : BLEND_FUNC(difference_16, avx2)
      87             : BLEND_FUNC(extremity_16, sse4)
      88             : BLEND_FUNC(extremity_16, avx2)
      89             : BLEND_FUNC(negation_16, sse4)
      90             : BLEND_FUNC(negation_16, avx2)
      91             : BLEND_FUNC(lighten_16, sse4)
      92             : BLEND_FUNC(lighten_16, avx2)
      93             : BLEND_FUNC(or_16, sse2)
      94             : BLEND_FUNC(or_16, avx2)
      95             : BLEND_FUNC(phoenix_16, sse4)
      96             : BLEND_FUNC(phoenix_16, avx2)
      97             : BLEND_FUNC(subtract_16, sse2)
      98             : BLEND_FUNC(subtract_16, avx2)
      99             : BLEND_FUNC(xor_16, sse2)
     100             : BLEND_FUNC(xor_16, avx2)
     101             : #endif /* ARCH_X86_64 */
     102             : 
     103         407 : av_cold void ff_blend_init_x86(FilterParams *param, int is_16bit)
     104             : {
     105         407 :     int cpu_flags = av_get_cpu_flags();
     106             : 
     107         407 :     if (!is_16bit) {
     108         225 :         if (EXTERNAL_SSE2(cpu_flags) && param->opacity == 1) {
     109         153 :             switch (param->mode) {
     110           9 :             case BLEND_ADDITION:     param->blend = ff_blend_addition_sse2;     break;
     111           9 :             case BLEND_GRAINMERGE:   param->blend = ff_blend_grainmerge_sse2;   break;
     112           9 :             case BLEND_AND:          param->blend = ff_blend_and_sse2;          break;
     113           9 :             case BLEND_AVERAGE:      param->blend = ff_blend_average_sse2;      break;
     114           9 :             case BLEND_DARKEN:       param->blend = ff_blend_darken_sse2;       break;
     115           9 :             case BLEND_GRAINEXTRACT: param->blend = ff_blend_grainextract_sse2; break;
     116           0 :             case BLEND_DIVIDE:       param->blend = ff_blend_divide_sse2;       break;
     117           9 :             case BLEND_HARDMIX:      param->blend = ff_blend_hardmix_sse2;      break;
     118           9 :             case BLEND_LIGHTEN:      param->blend = ff_blend_lighten_sse2;      break;
     119           9 :             case BLEND_MULTIPLY:     param->blend = ff_blend_multiply_sse2;     break;
     120           9 :             case BLEND_OR:           param->blend = ff_blend_or_sse2;           break;
     121           9 :             case BLEND_PHOENIX:      param->blend = ff_blend_phoenix_sse2;      break;
     122           9 :             case BLEND_SCREEN:       param->blend = ff_blend_screen_sse2;       break;
     123           9 :             case BLEND_SUBTRACT:     param->blend = ff_blend_subtract_sse2;     break;
     124           9 :             case BLEND_XOR:          param->blend = ff_blend_xor_sse2;          break;
     125           9 :             case BLEND_DIFFERENCE:   param->blend = ff_blend_difference_sse2;   break;
     126           9 :             case BLEND_EXTREMITY:    param->blend = ff_blend_extremity_sse2;    break;
     127           9 :             case BLEND_NEGATION:     param->blend = ff_blend_negation_sse2;     break;
     128             :             }
     129             :         }
     130         225 :         if (EXTERNAL_SSSE3(cpu_flags) && param->opacity == 1) {
     131         119 :             switch (param->mode) {
     132           7 :             case BLEND_DIFFERENCE: param->blend = ff_blend_difference_ssse3; break;
     133           7 :             case BLEND_EXTREMITY:  param->blend = ff_blend_extremity_ssse3;  break;
     134           7 :             case BLEND_NEGATION:   param->blend = ff_blend_negation_ssse3;   break;
     135             :             }
     136             :         }
     137             : 
     138         225 :         if (EXTERNAL_AVX2_FAST(cpu_flags) && param->opacity == 1) {
     139          17 :             switch (param->mode) {
     140           1 :             case BLEND_ADDITION:     param->blend = ff_blend_addition_avx2;     break;
     141           1 :             case BLEND_GRAINMERGE:   param->blend = ff_blend_grainmerge_avx2;   break;
     142           1 :             case BLEND_AND:          param->blend = ff_blend_and_avx2;          break;
     143           1 :             case BLEND_AVERAGE:      param->blend = ff_blend_average_avx2;      break;
     144           1 :             case BLEND_DARKEN:       param->blend = ff_blend_darken_avx2;       break;
     145           1 :             case BLEND_GRAINEXTRACT: param->blend = ff_blend_grainextract_avx2; break;
     146           1 :             case BLEND_HARDMIX:      param->blend = ff_blend_hardmix_avx2;      break;
     147           1 :             case BLEND_LIGHTEN:      param->blend = ff_blend_lighten_avx2;      break;
     148           1 :             case BLEND_MULTIPLY:     param->blend = ff_blend_multiply_avx2;     break;
     149           1 :             case BLEND_OR:           param->blend = ff_blend_or_avx2;           break;
     150           1 :             case BLEND_PHOENIX:      param->blend = ff_blend_phoenix_avx2;      break;
     151           1 :             case BLEND_SCREEN:       param->blend = ff_blend_screen_avx2;       break;
     152           1 :             case BLEND_SUBTRACT:     param->blend = ff_blend_subtract_avx2;     break;
     153           1 :             case BLEND_XOR:          param->blend = ff_blend_xor_avx2;          break;
     154           1 :             case BLEND_DIFFERENCE:   param->blend = ff_blend_difference_avx2;   break;
     155           1 :             case BLEND_EXTREMITY:    param->blend = ff_blend_extremity_avx2;    break;
     156           1 :             case BLEND_NEGATION:     param->blend = ff_blend_negation_avx2;     break;
     157             :             }
     158             :         }
     159             :     } else { /* is_16_bit */
     160             : #if ARCH_X86_64
     161         182 :         if (EXTERNAL_SSE2(cpu_flags) && param->opacity == 1) {
     162         126 :             switch (param->mode) {
     163           9 :             case BLEND_ADDITION: param->blend = ff_blend_addition_16_sse2; break;
     164           9 :             case BLEND_AND:      param->blend = ff_blend_and_16_sse2;      break;
     165           9 :             case BLEND_AVERAGE:  param->blend = ff_blend_average_16_sse2;  break;
     166           9 :             case BLEND_OR:       param->blend = ff_blend_or_16_sse2;       break;
     167          18 :             case BLEND_SUBTRACT: param->blend = ff_blend_subtract_16_sse2; break;
     168           0 :             case BLEND_XOR:      param->blend = ff_blend_xor_16_sse2;      break;
     169             :             }
     170             :         }
     171         182 :         if (EXTERNAL_SSE4(cpu_flags) && param->opacity == 1) {
     172          84 :             switch (param->mode) {
     173           6 :             case BLEND_GRAINMERGE: param->blend = ff_blend_grainmerge_16_sse4; break;
     174           6 :             case BLEND_DARKEN:   param->blend = ff_blend_darken_16_sse4;     break;
     175           6 :             case BLEND_GRAINEXTRACT: param->blend = ff_blend_grainextract_16_sse4; break;
     176           6 :             case BLEND_DIFFERENCE: param->blend = ff_blend_difference_16_sse4; break;
     177           6 :             case BLEND_EXTREMITY:  param->blend = ff_blend_extremity_16_sse4;    break;
     178           6 :             case BLEND_NEGATION:  param->blend = ff_blend_negation_16_sse4;     break;
     179           6 :             case BLEND_LIGHTEN:  param->blend = ff_blend_lighten_16_sse4;    break;
     180           6 :             case BLEND_PHOENIX:  param->blend = ff_blend_phoenix_16_sse4;    break;
     181             :             }
     182             :         }
     183         182 :         if (EXTERNAL_AVX2_FAST(cpu_flags) && param->opacity == 1) {
     184          14 :             switch (param->mode) {
     185           1 :             case BLEND_ADDITION: param->blend = ff_blend_addition_16_avx2; break;
     186           1 :             case BLEND_GRAINMERGE: param->blend = ff_blend_grainmerge_16_avx2;   break;
     187           1 :             case BLEND_AND:      param->blend = ff_blend_and_16_avx2;      break;
     188           1 :             case BLEND_AVERAGE:  param->blend = ff_blend_average_16_avx2;  break;
     189           1 :             case BLEND_DARKEN:   param->blend = ff_blend_darken_16_avx2;   break;
     190           1 :             case BLEND_GRAINEXTRACT: param->blend = ff_blend_grainextract_16_avx2; break;
     191           1 :             case BLEND_DIFFERENCE: param->blend = ff_blend_difference_16_avx2; break;
     192           1 :             case BLEND_EXTREMITY:  param->blend = ff_blend_extremity_16_avx2;    break;
     193           1 :             case BLEND_NEGATION:  param->blend = ff_blend_negation_16_avx2;     break;
     194           1 :             case BLEND_LIGHTEN:  param->blend = ff_blend_lighten_16_avx2;  break;
     195           1 :             case BLEND_OR:       param->blend = ff_blend_or_16_avx2;       break;
     196           1 :             case BLEND_PHOENIX:  param->blend = ff_blend_phoenix_16_avx2;  break;
     197           2 :             case BLEND_SUBTRACT: param->blend = ff_blend_subtract_16_avx2; break;
     198           0 :             case BLEND_XOR:      param->blend = ff_blend_xor_16_avx2;      break;
     199             :             }
     200             :         }
     201             : #endif /* ARCH_X86_64 */
     202             :     }
     203         407 : }

Generated by: LCOV version 1.13