FFmpeg
Loading...
Searching...
No Matches
blockdsp.c
Go to the documentation of this file.
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
23#include "checkasm.h"
24
25#include "libavcodec/blockdsp.h"
26
27#include "libavutil/common.h"
28#include "libavutil/internal.h"
31
32#define randomize_buffers(size) \
33 do { \
34 int i; \
35 for (i = 0; i < size; i++) { \
36 uint16_t r = rnd(); \
37 AV_WN16A(buf0 + i, r); \
38 AV_WN16A(buf1 + i, r); \
39 } \
40 } while (0)
41
42#define check_clear(func, size) \
43do { \
44 if (check_func(h.func, "blockdsp." #func)) { \
45 declare_func(void, int16_t *block); \
46 randomize_buffers(size); \
47 call_ref(buf0); \
48 call_new(buf1); \
49 if (memcmp(buf0, buf1, sizeof(*buf0) * size)) \
50 fail(); \
51 bench_new(buf0); \
52 } \
53} while (0)
54
56 LOCAL_ALIGNED_16(uint8_t, buf0_16, [16 * 16]);
57 LOCAL_ALIGNED_16(uint8_t, buf1_16, [16 * 16]);
58
59 for (int t = 0; t < 2; ++t) {
60 uint8_t *buf0 = buf0_16 + t * /* force 8 byte alignment */ 8;
61 uint8_t *buf1 = buf1_16 + t * /* force 8 byte alignment */ 8;
62 int n = 16 - 8 * t;
63 declare_func(void, uint8_t *block, uint8_t value,
64 ptrdiff_t line_size, int h);
65 if (check_func(h->fill_block_tab[t], "blockdsp.fill_block_tab[%d]", t)) {
66 uint8_t value = rnd();
67 memset(buf0, 0, sizeof(*buf0) * n * n);
68 memset(buf1, 0, sizeof(*buf1) * n * n);
69 call_ref(buf0, value, n, n);
70 call_new(buf1, value, n, n);
71 if (memcmp(buf0, buf1, sizeof(*buf0) * n * n))
72 fail();
73 bench_new(buf0, value, n, n);
74 }
75 }
76}
77
79{
80 LOCAL_ALIGNED_32(uint16_t, buf0, [6 * 8 * 8]);
81 LOCAL_ALIGNED_32(uint16_t, buf1, [6 * 8 * 8]);
82
84
86
87 check_clear(clear_block, 8 * 8);
88 check_clear(clear_blocks, 8 * 8 * 6);
89
90 check_fill(&h);
91
92 report("blockdsp");
93}
#define rnd
Definition checkasm.h:136
common internal and external API header
static int16_t block[64]
Definition dct.c:125
double value
Definition eval.c:102
#define declare_func
Definition test.h:489
#define fail
Definition test.h:479
#define bench_new
Definition test.h:487
#define check_func
Definition test.h:481
#define call_new
Definition test.h:486
#define call_ref
Definition test.h:485
#define report
Definition test.h:480
av_cold void ff_blockdsp_init(BlockDSPContext *c)
Definition blockdsp.c:58
common internal API header
#define LOCAL_ALIGNED_32(t, v,...)
#define LOCAL_ALIGNED_16(t, v,...)
void checkasm_check_blockdsp(void)
Definition blockdsp.c:78
static void check_fill(BlockDSPContext *h)
Definition blockdsp.c:55
#define check_clear(func, size)
Definition blockdsp.c:42