LCOV - code coverage report
Current view: top level - tests/checkasm - vf_threshold.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 36 37 97.3 %
Date: 2017-12-18 06:23:41 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * This file is part of FFmpeg.
       3             :  *
       4             :  * FFmpeg 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             :  * FFmpeg 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 along
      15             :  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #include <string.h>
      20             : #include "checkasm.h"
      21             : #include "libavfilter/threshold.h"
      22             : #include "libavutil/intreadwrite.h"
      23             : 
      24             : #define WIDTH 256
      25             : #define WIDTH_PADDED 256 + 32
      26             : 
      27             : #define randomize_buffers(buf, size)     \
      28             :     do {                                 \
      29             :        int j;                            \
      30             :        uint8_t *tmp_buf = (uint8_t *)buf;\
      31             :        for (j = 0; j < size; j++)        \
      32             :            tmp_buf[j] = rnd() & 0xFF;    \
      33             :     } while (0)
      34             : 
      35          26 : static void check_threshold(int depth){
      36          26 :     LOCAL_ALIGNED_32(uint8_t, in       , [WIDTH_PADDED]);
      37          26 :     LOCAL_ALIGNED_32(uint8_t, threshold, [WIDTH_PADDED]);
      38          26 :     LOCAL_ALIGNED_32(uint8_t, min      , [WIDTH_PADDED]);
      39          26 :     LOCAL_ALIGNED_32(uint8_t, max      , [WIDTH_PADDED]);
      40          26 :     LOCAL_ALIGNED_32(uint8_t, out_ref  , [WIDTH_PADDED]);
      41          26 :     LOCAL_ALIGNED_32(uint8_t, out_new  , [WIDTH_PADDED]);
      42          26 :     ptrdiff_t line_size = WIDTH_PADDED;
      43          26 :     int w = WIDTH;
      44             : 
      45          26 :     declare_func(void, const uint8_t *in, const uint8_t *threshold,
      46             :                  const uint8_t *min, const uint8_t *max, uint8_t *out,
      47             :                  ptrdiff_t ilinesize, ptrdiff_t tlinesize,
      48             :                  ptrdiff_t flinesize, ptrdiff_t slinesize,
      49             :                  ptrdiff_t olinesize, int w, int h);
      50             : 
      51             :     ThresholdContext s;
      52          26 :     s.depth = depth;
      53          26 :     ff_threshold_init(&s);
      54             : 
      55          26 :     memset(in,     0, WIDTH_PADDED);
      56          26 :     memset(threshold, 0, WIDTH_PADDED);
      57          26 :     memset(min, 0, WIDTH_PADDED);
      58          26 :     memset(max, 0, WIDTH_PADDED);
      59          26 :     memset(out_ref, 0, WIDTH_PADDED);
      60          26 :     memset(out_new, 0, WIDTH_PADDED);
      61          26 :     randomize_buffers(in, WIDTH);
      62          26 :     randomize_buffers(threshold, WIDTH);
      63          26 :     randomize_buffers(min, WIDTH);
      64          26 :     randomize_buffers(max, WIDTH);
      65             : 
      66          26 :     if (depth == 16)
      67          13 :         w /= 2;
      68             : 
      69          26 :     if (check_func(s.threshold, "threshold%d", depth)) {
      70           6 :         call_ref(in, threshold, min, max, out_ref, line_size, line_size, line_size, line_size, line_size, w, 1);
      71           6 :         call_new(in, threshold, min, max, out_new, line_size, line_size, line_size, line_size, line_size, w, 1);
      72           6 :         if (memcmp(out_ref, out_new, WIDTH))
      73           0 :             fail();
      74           6 :         bench_new(in, threshold, min, max, out_new, line_size, line_size, line_size, line_size, line_size, w, 1);
      75             :     }
      76          26 : }
      77             : 
      78          13 : void checkasm_check_vf_threshold(void)
      79             : {
      80          13 :     check_threshold(8);
      81          13 :     report("threshold8");
      82             : 
      83          13 :     check_threshold(16);
      84          13 :     report("threshold16");
      85          13 : }

Generated by: LCOV version 1.13