LCOV - code coverage report
Current view: top level - tests/checkasm - hevc_idct.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 41 43 95.3 %
Date: 2017-12-17 23:02:56 Functions: 3 3 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);               \
      35             :         }                                       \
      36             :     } while (0)
      37             : 
      38          39 : static void check_idct(HEVCDSPContext h, int bit_depth)
      39             : {
      40             :     int i;
      41          39 :     LOCAL_ALIGNED(32, int16_t, coeffs0, [32 * 32]);
      42          39 :     LOCAL_ALIGNED(32, int16_t, coeffs1, [32 * 32]);
      43             : 
      44         195 :     for (i = 2; i <= 5; i++) {
      45         156 :         int block_size = 1 << i;
      46         156 :         int size = block_size * block_size;
      47         156 :         int col_limit = block_size;
      48         156 :         declare_func(void, int16_t *coeffs, int col_limit);
      49             : 
      50         156 :         randomize_buffers(coeffs0, size);
      51         156 :         memcpy(coeffs1, coeffs0, sizeof(*coeffs0) * size);
      52         156 :         if (check_func(h.idct[i - 2], "hevc_idct_%dx%d_%d", block_size, block_size, bit_depth)) {
      53          28 :             call_ref(coeffs0, col_limit);
      54          28 :             call_new(coeffs1, col_limit);
      55          28 :             if (memcmp(coeffs0, coeffs1, sizeof(*coeffs0) * size))
      56           0 :                 fail();
      57          28 :             bench_new(coeffs1, col_limit);
      58             :         }
      59             :     }
      60          39 : }
      61             : 
      62          39 : static void check_idct_dc(HEVCDSPContext h, int bit_depth)
      63             : {
      64             :     int i;
      65          39 :     LOCAL_ALIGNED(32, int16_t, coeffs0, [32 * 32]);
      66          39 :     LOCAL_ALIGNED(32, int16_t, coeffs1, [32 * 32]);
      67             : 
      68         195 :     for (i = 2; i <= 5; i++) {
      69         156 :         int block_size = 1 << i;
      70         156 :         int size = block_size * block_size;
      71         156 :         declare_func_emms(AV_CPU_FLAG_MMXEXT, void, int16_t *coeffs);
      72             : 
      73         156 :         randomize_buffers(coeffs0, size);
      74         156 :         memcpy(coeffs1, coeffs0, sizeof(*coeffs0) * size);
      75             : 
      76         156 :         if (check_func(h.idct_dc[i - 2], "hevc_idct_%dx%d_dc_%d", block_size, block_size, bit_depth)) {
      77          26 :             call_ref(coeffs0);
      78          26 :             call_new(coeffs1);
      79          26 :             if (memcmp(coeffs0, coeffs1, sizeof(*coeffs0) * size))
      80           0 :                 fail();
      81          26 :             bench_new(coeffs1);
      82             :         }
      83             :     }
      84          39 : }
      85             : 
      86          13 : void checkasm_check_hevc_idct(void)
      87             : {
      88             :     int bit_depth;
      89             : 
      90          52 :     for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
      91             :         HEVCDSPContext h;
      92             : 
      93          39 :         ff_hevc_dsp_init(&h, bit_depth);
      94          39 :         check_idct_dc(h, bit_depth);
      95             :     }
      96          13 :     report("idct_dc");
      97             : 
      98          52 :     for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
      99             :         HEVCDSPContext h;
     100             : 
     101          39 :         ff_hevc_dsp_init(&h, bit_depth);
     102          39 :         check_idct(h, bit_depth);
     103             :     }
     104          13 :     report("idct");
     105          13 : }

Generated by: LCOV version 1.13