FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
videodsp.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Ronald S. Bultje <rsbultje@gmail.com>
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/videodsp.h"
24 #include "libavutil/internal.h"
25 #include "libavutil/intreadwrite.h"
26 
27 #define randomize_buffers(w, h) \
28  do { \
29  int i; \
30  for (i = 0; i < w * h * sizeof(*src0); i += 4) \
31  AV_WN32A(((uint8_t *) src0) + i, rnd()); \
32  } while (0)
33 
34 #define iter_1d(type, fix, fix_val, var, var_start, var_end) \
35  for (fix = fix_val, var = var_start; var <= var_end; var++) { \
36  call_ref((type *) dst0, (const type *) (src0 + y * pw + x), \
37  bw * sizeof(type), pw * sizeof(type), \
38  bw, bh, x, y, pw, ph); \
39  call_new((type *) dst1, (const type *) (src1 + y * pw + x), \
40  bw * sizeof(type), pw * sizeof(type), \
41  bw, bh, x, y, pw, ph); \
42  if (memcmp(dst0, dst1, bw * bh * sizeof(type))) \
43  fail(); \
44  bench_new((type *) dst1, (const type *) (src1 + y * pw + x),\
45  bw * sizeof(type), pw * sizeof(type), \
46  bw, bh, x, y, pw, ph); \
47  }
48 
49 #define check_emu_edge_size(type, src_w, src_h, dst_w, dst_h) \
50  do { \
51  LOCAL_ALIGNED_16(type, src0, [src_w * src_h]); \
52  LOCAL_ALIGNED_16(type, src1, [src_w * src_h]); \
53  int bw = dst_w, bh = dst_h; \
54  int pw = src_w, ph = src_h; \
55  int y, x; \
56  randomize_buffers(src_w, src_h); \
57  memcpy(src1, src0, pw * ph * sizeof(type)); \
58  iter_1d(type, y, 0 - src_h, x, 0 - src_w, src_w - 0); \
59  iter_1d(type, x, src_w - 0, y, 0 - src_h, src_h - 0); \
60  iter_1d(type, y, src_h - 0, x, 0 - src_w, src_w - 0); \
61  iter_1d(type, x, 0 - src_w, y, 0 - src_h, src_h - 0); \
62  } while (0)
63 
64 #define check_emu_edge(type) \
65  do { \
66  LOCAL_ALIGNED_16(type, dst0, [64 * 64]); \
67  LOCAL_ALIGNED_16(type, dst1, [64 * 64]); \
68  declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, \
69  void, type *dst, const type *src, \
70  ptrdiff_t dst_linesize, \
71  ptrdiff_t src_linesize, \
72  int block_w, int block_h, \
73  int src_x, int src_y, \
74  int src_w, int src_h); \
75  check_emu_edge_size(type, 16, 1, 64, 64); \
76  check_emu_edge_size(type, 16, 16, 64, 64); \
77  check_emu_edge_size(type, 64, 64, 64, 64); \
78  } while (0)
79 
81 {
82  VideoDSPContext vdsp;
83 
84  ff_videodsp_init(&vdsp, 8);
85  if (check_func(vdsp.emulated_edge_mc, "emulated_edge_mc_8"))
87 
88  report("emulated_edge_mc");
89 }
#define check_emu_edge(type)
Definition: videodsp.c:64
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
Definition: videodsp.c:38
#define report
Definition: checkasm.h:112
void(* emulated_edge_mc)(uint8_t *dst, const uint8_t *src, ptrdiff_t dst_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
Definition: videodsp.h:63
uint8_t
common internal API header
#define check_func(func,...)
Definition: checkasm.h:100
void checkasm_check_videodsp(void)
Definition: videodsp.c:80
Core video DSP helper functions.