LCOV - code coverage report
Current view: top level - tests/checkasm - sw_rgb.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 59 61 96.7 %
Date: 2018-05-20 11:54:08 Functions: 3 3 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             : static const struct {uint8_t w, h, s;} planes[] = {
      39             :     {12,16,12}, {16,16,16}, {20,23,25}, {32,18,48}, {8,128,16}, {128,128,128}
      40             : };
      41             : 
      42             : #define MAX_STRIDE 128
      43             : #define MAX_HEIGHT 128
      44             : 
      45          65 : static void check_shuffle_bytes(void * func, const char * report)
      46             : {
      47             :     int i;
      48          65 :     LOCAL_ALIGNED_32(uint8_t, src0, [MAX_STRIDE]);
      49          65 :     LOCAL_ALIGNED_32(uint8_t, src1, [MAX_STRIDE]);
      50          65 :     LOCAL_ALIGNED_32(uint8_t, dst0, [MAX_STRIDE]);
      51          65 :     LOCAL_ALIGNED_32(uint8_t, dst1, [MAX_STRIDE]);
      52             : 
      53          65 :     declare_func_emms(AV_CPU_FLAG_MMX, void, const uint8_t *src, uint8_t *dst, int src_size);
      54             : 
      55          65 :     memset(dst0, 0, MAX_STRIDE);
      56          65 :     memset(dst1, 0, MAX_STRIDE);
      57          65 :     randomize_buffers(src0, MAX_STRIDE);
      58          65 :     memcpy(src1, src0, MAX_STRIDE);
      59             : 
      60          65 :     if (check_func(func, "%s", report)) {
      61          84 :         for (i = 0; i < 6; i ++) {
      62          72 :             call_ref(src0, dst0, width[i]);
      63          72 :             call_new(src1, dst1, width[i]);
      64          72 :             if (memcmp(dst0, dst1, MAX_STRIDE))
      65           0 :                 fail();
      66             :         }
      67          12 :         bench_new(src0, dst0, width[5]);
      68             :     }
      69          65 : }
      70             : 
      71          13 : static void check_uyvy_to_422p(void)
      72             : {
      73             :     int i;
      74             : 
      75          13 :     LOCAL_ALIGNED_32(uint8_t, src0, [MAX_STRIDE * MAX_HEIGHT * 2]);
      76          13 :     LOCAL_ALIGNED_32(uint8_t, src1, [MAX_STRIDE * MAX_HEIGHT * 2]);
      77          13 :     LOCAL_ALIGNED_32(uint8_t, dst_y_0, [MAX_STRIDE * MAX_HEIGHT]);
      78          13 :     LOCAL_ALIGNED_32(uint8_t, dst_y_1, [MAX_STRIDE * MAX_HEIGHT]);
      79          13 :     LOCAL_ALIGNED_32(uint8_t, dst_u_0, [(MAX_STRIDE/2) * MAX_HEIGHT]);
      80          13 :     LOCAL_ALIGNED_32(uint8_t, dst_u_1, [(MAX_STRIDE/2) * MAX_HEIGHT]);
      81          13 :     LOCAL_ALIGNED_32(uint8_t, dst_v_0, [(MAX_STRIDE/2) * MAX_HEIGHT]);
      82          13 :     LOCAL_ALIGNED_32(uint8_t, dst_v_1, [(MAX_STRIDE/2) * MAX_HEIGHT]);
      83             : 
      84          13 :     declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
      85             :                       const uint8_t *src, int width, int height,
      86             :                       int lumStride, int chromStride, int srcStride);
      87             : 
      88          13 :     randomize_buffers(src0, MAX_STRIDE * MAX_HEIGHT * 2);
      89          13 :     memcpy(src1, src0, MAX_STRIDE * MAX_HEIGHT * 2);
      90             : 
      91          13 :     if (check_func(uyvytoyuv422, "uyvytoyuv422")) {
      92          35 :         for (i = 0; i < 6; i ++) {
      93          30 :             memset(dst_y_0, 0, MAX_STRIDE * MAX_HEIGHT);
      94          30 :             memset(dst_y_1, 0, MAX_STRIDE * MAX_HEIGHT);
      95          30 :             memset(dst_u_0, 0, (MAX_STRIDE/2) * MAX_HEIGHT);
      96          30 :             memset(dst_u_1, 0, (MAX_STRIDE/2) * MAX_HEIGHT);
      97          30 :             memset(dst_v_0, 0, (MAX_STRIDE/2) * MAX_HEIGHT);
      98          30 :             memset(dst_v_1, 0, (MAX_STRIDE/2) * MAX_HEIGHT);
      99             : 
     100          30 :             call_ref(dst_y_0, dst_u_0, dst_v_0, src0, planes[i].w, planes[i].h,
     101             :                      MAX_STRIDE, MAX_STRIDE / 2, planes[i].s);
     102          30 :             call_new(dst_y_1, dst_u_1, dst_v_1, src1, planes[i].w, planes[i].h,
     103             :                      MAX_STRIDE, MAX_STRIDE / 2, planes[i].s);
     104          60 :             if (memcmp(dst_y_0, dst_y_1, MAX_STRIDE * MAX_HEIGHT) ||
     105          60 :                 memcmp(dst_u_0, dst_u_1, (MAX_STRIDE/2) * MAX_HEIGHT) ||
     106          30 :                 memcmp(dst_v_0, dst_v_1, (MAX_STRIDE/2) * MAX_HEIGHT))
     107           0 :                 fail();
     108             :         }
     109           5 :         bench_new(dst_y_1, dst_u_1, dst_v_1, src1, planes[5].w, planes[5].h,
     110             :                   MAX_STRIDE, MAX_STRIDE / 2, planes[5].s);
     111             :     }
     112          13 : }
     113             : 
     114          13 : void checkasm_check_sw_rgb(void)
     115             : {
     116          13 :     ff_sws_rgb2rgb_init();
     117             : 
     118          13 :     check_shuffle_bytes(shuffle_bytes_2103, "shuffle_bytes_2103");
     119          13 :     report("shuffle_bytes_2103");
     120             : 
     121          13 :     check_shuffle_bytes(shuffle_bytes_0321, "shuffle_bytes_0321");
     122          13 :     report("shuffle_bytes_0321");
     123             : 
     124          13 :     check_shuffle_bytes(shuffle_bytes_1230, "shuffle_bytes_1230");
     125          13 :     report("shuffle_bytes_1230");
     126             : 
     127          13 :     check_shuffle_bytes(shuffle_bytes_3012, "shuffle_bytes_3012");
     128          13 :     report("shuffle_bytes_3012");
     129             : 
     130          13 :     check_shuffle_bytes(shuffle_bytes_3210, "shuffle_bytes_3210");
     131          13 :     report("shuffle_bytes_3210");
     132             : 
     133          13 :     check_uyvy_to_422p();
     134          13 :     report("uyvytoyuv422");
     135          13 : }

Generated by: LCOV version 1.13