FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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"
29 #include "libavutil/intreadwrite.h"
30 
31 #define randomize_buffers(size) \
32  do { \
33  int i; \
34  for (i = 0; i < size; i++) { \
35  uint16_t r = rnd(); \
36  AV_WN16A(buf0 + i, r); \
37  AV_WN16A(buf1 + i, r); \
38  } \
39  } while (0)
40 
41 #define check_clear(func, size) \
42 do { \
43  if (check_func(h.func, "blockdsp." #func)) { \
44  declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t *block); \
45  randomize_buffers(size); \
46  call_ref(buf0); \
47  call_new(buf1); \
48  if (memcmp(buf0, buf1, sizeof(*buf0) * size)) \
49  fail(); \
50  bench_new(buf0); \
51  } \
52 } while (0)
53 
55 {
56  LOCAL_ALIGNED_32(uint16_t, buf0, [6 * 8 * 8]);
57  LOCAL_ALIGNED_32(uint16_t, buf1, [6 * 8 * 8]);
58 
59  AVCodecContext avctx = { 0 };
61 
62  ff_blockdsp_init(&h, &avctx);
63 
64  check_clear(clear_block, 8 * 8);
65  check_clear(clear_blocks, 8 * 8 * 6);
66 
67  report("blockdsp");
68 }
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
Definition: blockdsp.c:60
#define report
Definition: checkasm.h:112
common internal API header
main external API structure.
Definition: avcodec.h:1761
#define check_clear(func, size)
Definition: blockdsp.c:41
#define LOCAL_ALIGNED_32(t, v,...)
Definition: internal.h:130
common internal and external API header
void checkasm_check_blockdsp(void)
Definition: blockdsp.c:54