LCOV - code coverage report
Current view: top level - src/tests/checkasm - llviddsp.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 25 27 92.6 %
Date: 2017-06-23 19:00:59 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2016 Alexandra Hájková
       3             :  *
       4             :  * This file is part of FFmpeg.
       5             :  *
       6             :  * FFmpeg is free software; you can redistribute it and/or modify
       7             :  * it under the terms of the GNU General Public License as published by
       8             :  * the Free Software Foundation; either version 2 of the License, or
       9             :  * (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
      14             :  * GNU General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU General Public License along
      17             :  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
      18             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      19             :  */
      20             : 
      21             : #include <string.h>
      22             : 
      23             : #include "libavutil/common.h"
      24             : #include "libavutil/intreadwrite.h"
      25             : #include "libavutil/mem.h"
      26             : 
      27             : #include "libavcodec/lossless_videodsp.h"
      28             : 
      29             : #include "checkasm.h"
      30             : 
      31             : #define randomize_buffers(buf, size)     \
      32             :     do {                                 \
      33             :         int j;                           \
      34             :         for (j = 0; j < size; j++)       \
      35             :             buf[j] = rnd() & 0xFF;       \
      36             :     } while (0)
      37             : 
      38          13 : static void check_add_bytes(LLVidDSPContext c, int width)
      39             : {
      40          13 :     uint8_t *src0 = av_mallocz(width);
      41          13 :     uint8_t *src1 = av_mallocz(width);
      42          13 :     uint8_t *dst0 = av_mallocz(width);
      43          13 :     uint8_t *dst1 = av_mallocz(width);
      44          13 :     declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, ptrdiff_t w);
      45             : 
      46          13 :     if (!src0 || !src1 || !dst0 || !dst1)
      47           0 :         fail();
      48             : 
      49          13 :     randomize_buffers(src0, width);
      50          13 :     memcpy(src1, src0, width);
      51             : 
      52          13 :     if (check_func(c.add_bytes, "add_bytes")) {
      53           2 :         call_ref(dst0, src0, width);
      54           2 :         call_new(dst1, src1, width);
      55           2 :         if (memcmp(dst0, dst1, width))
      56           0 :             fail();
      57           2 :         bench_new(dst1, src1, width);
      58             :     }
      59             : 
      60          13 :     av_free(src0);
      61          13 :     av_free(src1);
      62          13 :     av_free(dst0);
      63          13 :     av_free(dst1);
      64          13 : }
      65             : 
      66          13 : void checkasm_check_llviddsp(void)
      67             : {
      68             :     LLVidDSPContext c;
      69          13 :     int width = 16 * av_clip(rnd(), 16, 128);
      70             : 
      71          13 :     ff_llviddsp_init(&c);
      72             : 
      73          13 :     check_add_bytes(c, width);
      74             : 
      75          13 :     report("add_bytes");
      76          13 : }

Generated by: LCOV version 1.13