LCOV - code coverage report
Current view: top level - tests/checkasm - sw_rgb.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 30 31 96.8 %
Date: 2018-04-19 23:07:36 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  * This file is part of FFmpeg.
       4             :  *
       5             :  * FFmpeg is free software; you can redistribute it and/or modify
       6             :  * it under the terms of the GNU General Public License as published by
       7             :  * the Free Software Foundation; either version 2 of the License, or
       8             :  * (at your option) any later version.
       9             :  *
      10             :  * FFmpeg is distributed in the hope that it will be useful,
      11             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13             :  * GNU General Public License for more details.
      14             :  *
      15             :  * You should have received a copy of the GNU General Public License along
      16             :  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
      17             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             :  */
      19             : 
      20             : #include <string.h>
      21             : 
      22             : #include "libavutil/common.h"
      23             : #include "libavutil/intreadwrite.h"
      24             : #include "libavutil/mem.h"
      25             : 
      26             : #include "libswscale/rgb2rgb.h"
      27             : 
      28             : #include "checkasm.h"
      29             : 
      30             : #define randomize_buffers(buf, size)      \
      31             :     do {                                  \
      32             :         int j;                            \
      33             :         for (j = 0; j < size; j+=4)       \
      34             :             AV_WN32(buf + j, rnd());      \
      35             :     } while (0)
      36             : 
      37             : static const uint8_t width[] = {12, 16, 20, 32, 36, 128};
      38             : 
      39             : #define MAX_STRIDE 128
      40             : 
      41          65 : static void check_shuffle_bytes(void * func, const char * report)
      42             : {
      43             :     int i;
      44          65 :     LOCAL_ALIGNED_32(uint8_t, src0, [MAX_STRIDE]);
      45          65 :     LOCAL_ALIGNED_32(uint8_t, src1, [MAX_STRIDE]);
      46          65 :     LOCAL_ALIGNED_32(uint8_t, dst0, [MAX_STRIDE]);
      47          65 :     LOCAL_ALIGNED_32(uint8_t, dst1, [MAX_STRIDE]);
      48             : 
      49          65 :     declare_func_emms(AV_CPU_FLAG_MMX, void, const uint8_t *src, uint8_t *dst, int src_size);
      50             : 
      51          65 :     memset(dst0, 0, MAX_STRIDE);
      52          65 :     memset(dst1, 0, MAX_STRIDE);
      53          65 :     randomize_buffers(src0, MAX_STRIDE);
      54          65 :     memcpy(src1, src0, MAX_STRIDE);
      55             : 
      56          65 :     if (check_func(func, "%s", report)) {
      57          84 :         for (i = 0; i < 6; i ++) {
      58          72 :             call_ref(src0, dst0, width[i]);
      59          72 :             call_new(src1, dst1, width[i]);
      60          72 :             if (memcmp(dst0, dst1, MAX_STRIDE))
      61           0 :                 fail();
      62             :         }
      63          12 :         bench_new(src0, dst0, width[5]);
      64             :     }
      65          65 : }
      66             : 
      67          13 : void checkasm_check_sw_rgb(void)
      68             : {
      69          13 :     ff_sws_rgb2rgb_init();
      70             : 
      71          13 :     check_shuffle_bytes(shuffle_bytes_2103, "shuffle_bytes_2103");
      72          13 :     report("shuffle_bytes_2103");
      73             : 
      74          13 :     check_shuffle_bytes(shuffle_bytes_0321, "shuffle_bytes_0321");
      75          13 :     report("shuffle_bytes_0321");
      76             : 
      77          13 :     check_shuffle_bytes(shuffle_bytes_1230, "shuffle_bytes_1230");
      78          13 :     report("shuffle_bytes_1230");
      79             : 
      80          13 :     check_shuffle_bytes(shuffle_bytes_3012, "shuffle_bytes_3012");
      81          13 :     report("shuffle_bytes_3012");
      82             : 
      83          13 :     check_shuffle_bytes(shuffle_bytes_3210, "shuffle_bytes_3210");
      84          13 :     report("shuffle_bytes_3210");
      85          13 : }

Generated by: LCOV version 1.13