LCOV - code coverage report
Current view: top level - src/tests/checkasm - hevc_add_res.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 26 27 96.3 %
Date: 2017-08-17 10:06:07 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/intreadwrite.h"
      24             : 
      25             : #include "libavcodec/hevcdsp.h"
      26             : 
      27             : #include "checkasm.h"
      28             : 
      29             : #define randomize_buffers(buf, size)            \
      30             :     do {                                        \
      31             :         int j;                                  \
      32             :         for (j = 0; j < size; j++) {            \
      33             :             int16_t r = rnd();                  \
      34             :             AV_WN16A(buf + j, r >> 3);          \
      35             :         }                                       \
      36             :     } while (0)
      37             : 
      38             : #define randomize_buffers2(buf, size)             \
      39             :     do {                                          \
      40             :         int j;                                    \
      41             :         for (j = 0; j < size; j++)                \
      42             :             AV_WN16A(buf + j * 2, rnd() & 0x3FF); \
      43             :     } while (0)
      44             : 
      45          39 : static void check_add_res(HEVCDSPContext h, int bit_depth)
      46             : {
      47             :     int i;
      48          39 :     LOCAL_ALIGNED_32(int16_t, res0, [32 * 32]);
      49          39 :     LOCAL_ALIGNED_32(int16_t, res1, [32 * 32]);
      50          39 :     LOCAL_ALIGNED_32(uint8_t, dst0, [32 * 32 * 2]);
      51          39 :     LOCAL_ALIGNED_32(uint8_t, dst1, [32 * 32 * 2]);
      52             : 
      53         195 :     for (i = 2; i <= 5; i++) {
      54         156 :         int block_size = 1 << i;
      55         156 :         int size = block_size * block_size;
      56         156 :         ptrdiff_t stride = block_size << (bit_depth > 8);
      57         156 :         declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t *res, ptrdiff_t stride);
      58             : 
      59         156 :         randomize_buffers(res0, size);
      60         156 :         randomize_buffers2(dst0, size);
      61         156 :         memcpy(res1, res0, sizeof(*res0) * size);
      62         156 :         memcpy(dst1, dst0, sizeof(int16_t) * size);
      63             : 
      64         156 :         if (check_func(h.add_residual[i - 2], "add_res_%dx%d_%d", block_size, block_size, bit_depth)) {
      65          26 :             call_ref(dst0, res0, stride);
      66          26 :             call_new(dst1, res1, stride);
      67          26 :             if (memcmp(dst0, dst1, size))
      68           0 :                 fail();
      69          26 :             bench_new(dst1, res1, stride);
      70             :         }
      71             :     }
      72          39 : }
      73             : 
      74          13 : void checkasm_check_hevc_add_res(void)
      75             : {
      76             :     int bit_depth;
      77             : 
      78          52 :     for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
      79             :         HEVCDSPContext h;
      80             : 
      81          39 :         ff_hevc_dsp_init(&h, bit_depth);
      82          39 :         check_add_res(h, bit_depth);
      83             :     }
      84          13 :     report("add_residual");
      85          13 : }

Generated by: LCOV version 1.13