LCOV - code coverage report
Current view: top level - tests/checkasm - v210enc.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 8 8 100.0 %
Date: 2017-10-18 21:45:51 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2015 Henrik Gramner
       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             : #include "checkasm.h"
      23             : #include "libavcodec/v210enc.h"
      24             : #include "libavutil/common.h"
      25             : #include "libavutil/internal.h"
      26             : #include "libavutil/intreadwrite.h"
      27             : 
      28             : #define BUF_SIZE 512
      29             : 
      30             : #define randomize_buffers(mask)                        \
      31             :     do {                                               \
      32             :         int i, size = sizeof(*y0);                     \
      33             :         for (i = 0; i < BUF_SIZE; i += 4 / size) {     \
      34             :             uint32_t r = rnd() & mask;                 \
      35             :             AV_WN32A(y0 + i, r);                       \
      36             :             AV_WN32A(y1 + i, r);                       \
      37             :         }                                              \
      38             :         for (i = 0; i < BUF_SIZE / 2; i += 4 / size) { \
      39             :             uint32_t r = rnd() & mask;                 \
      40             :             AV_WN32A(u0 + i, r);                       \
      41             :             AV_WN32A(u1 + i, r);                       \
      42             :             r = rnd() & mask;                          \
      43             :             AV_WN32A(v0 + i, r);                       \
      44             :             AV_WN32A(v1 + i, r);                       \
      45             :         }                                              \
      46             :         for (i = 0; i < width * 8 / 3; i += 4) {       \
      47             :             uint32_t r = rnd();                        \
      48             :             AV_WN32A(dst0 + i, r);                     \
      49             :             AV_WN32A(dst1 + i, r);                     \
      50             :         }                                              \
      51             :     } while (0)
      52             : 
      53             : #define check_pack_line(type, mask)                                                \
      54             :     do {                                                                           \
      55             :         LOCAL_ALIGNED_16(type, y0, [BUF_SIZE]);                                    \
      56             :         LOCAL_ALIGNED_16(type, y1, [BUF_SIZE]);                                    \
      57             :         LOCAL_ALIGNED_16(type, u0, [BUF_SIZE / 2]);                                \
      58             :         LOCAL_ALIGNED_16(type, u1, [BUF_SIZE / 2]);                                \
      59             :         LOCAL_ALIGNED_16(type, v0, [BUF_SIZE / 2]);                                \
      60             :         LOCAL_ALIGNED_16(type, v1, [BUF_SIZE / 2]);                                \
      61             :         LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE * 8 / 3]);                       \
      62             :         LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE * 8 / 3]);                       \
      63             :                                                                                    \
      64             :         declare_func(void, const type * y, const type * u, const type * v,         \
      65             :                      uint8_t * dst, ptrdiff_t width);                              \
      66             :         ptrdiff_t width, step = 12 / sizeof(type);                                 \
      67             :                                                                                    \
      68             :         for (width = step; width < BUF_SIZE - 15; width += step) {                 \
      69             :             int y_offset  = rnd() & 15;                                            \
      70             :             int uv_offset = y_offset / 2;                                          \
      71             :             randomize_buffers(mask);                                               \
      72             :             call_ref(y0 + y_offset, u0 + uv_offset, v0 + uv_offset, dst0, width);  \
      73             :             call_new(y1 + y_offset, u1 + uv_offset, v1 + uv_offset, dst1, width);  \
      74             :             if (memcmp(y0, y1, BUF_SIZE) || memcmp(u0, u1, BUF_SIZE / 2) ||        \
      75             :                 memcmp(v0, v1, BUF_SIZE / 2) || memcmp(dst0, dst1, width * 8 / 3)) \
      76             :                 fail();                                                            \
      77             :             bench_new(y1 + y_offset, u1 + uv_offset, v1 + uv_offset, dst1, width); \
      78             :         }                                                                          \
      79             :     } while (0)
      80             : 
      81          13 : void checkasm_check_v210enc(void)
      82             : {
      83             :     V210EncContext h;
      84             : 
      85          13 :     ff_v210enc_init(&h);
      86             : 
      87          13 :     if (check_func(h.pack_line_8, "v210_planar_pack_8"))
      88           4 :         check_pack_line(uint8_t, 0xffffffff);
      89             : 
      90          13 :     if (check_func(h.pack_line_10, "v210_planar_pack_10"))
      91           3 :         check_pack_line(uint16_t, 0x03ff03ff);
      92             : 
      93          13 :     report("planar_pack");
      94          13 : }

Generated by: LCOV version 1.13