FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pixblockdsp.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Tiancheng "Timothy" Gu
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/pixblockdsp.h"
24 #include "libavutil/common.h"
25 #include "libavutil/internal.h"
26 #include "libavutil/intreadwrite.h"
27 
28 #define BUF_UNITS 8
29 #define BUF_SIZE (BUF_UNITS * 128 + 8 * BUF_UNITS)
30 
31 #define randomize_buffers() \
32  do { \
33  int i; \
34  for (i = 0; i < BUF_SIZE; i += 4) { \
35  uint32_t r = rnd(); \
36  AV_WN32A(src10 + i, r); \
37  AV_WN32A(src11 + i, r); \
38  r = rnd(); \
39  AV_WN32A(src20 + i, r); \
40  AV_WN32A(src21 + i, r); \
41  r = rnd(); \
42  AV_WN32A(dst0_ + i, r); \
43  AV_WN32A(dst1_ + i, r); \
44  } \
45  } while (0)
46 
47 #define check_get_pixels(type) \
48  do { \
49  int i; \
50  declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t *block, const uint8_t *pixels, ptrdiff_t line_size); \
51  \
52  for (i = 0; i < BUF_UNITS; i++) { \
53  int src_offset = i * 64 * sizeof(type) + 8 * i; /* Test various alignments */ \
54  int dst_offset = i * 64; /* dst must be aligned */ \
55  randomize_buffers(); \
56  call_ref(dst0 + dst_offset, src10 + src_offset, 8); \
57  call_new(dst1 + dst_offset, src11 + src_offset, 8); \
58  if (memcmp(src10, src11, BUF_SIZE)|| memcmp(dst0, dst1, BUF_SIZE)) \
59  fail(); \
60  bench_new(dst1 + dst_offset, src11 + src_offset, 8); \
61  } \
62  } while (0)
63 
64 #define check_diff_pixels(type) \
65  do { \
66  int i; \
67  declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t *av_restrict block, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride); \
68  \
69  for (i = 0; i < BUF_UNITS; i++) { \
70  int src_offset = i * 64 * sizeof(type) + 8 * i; /* Test various alignments */ \
71  int dst_offset = i * 64; /* dst must be aligned */ \
72  randomize_buffers(); \
73  call_ref(dst0 + dst_offset, src10 + src_offset, src20 + src_offset, 8); \
74  call_new(dst1 + dst_offset, src11 + src_offset, src21 + src_offset, 8); \
75  if (memcmp(src10, src11, BUF_SIZE) || memcmp(src20, src21, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE)) \
76  fail(); \
77  bench_new(dst1 + dst_offset, src11 + src_offset, src21 + src_offset, 8); \
78  } \
79  } while (0)
80 
82 {
89  uint16_t *dst0 = (uint16_t *)dst0_;
90  uint16_t *dst1 = (uint16_t *)dst1_;
92  AVCodecContext avctx = {
94  };
95 
96  ff_pixblockdsp_init(&h, &avctx);
97 
98  if (check_func(h.get_pixels, "get_pixels"))
100 
101  report("get_pixels");
102 
103  if (check_func(h.diff_pixels, "diff_pixels"))
105 
106  report("diff_pixels");
107 }
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:2741
#define report
Definition: checkasm.h:119
void checkasm_check_pixblockdsp(void)
Definition: pixblockdsp.c:81
uint8_t
void(* diff_pixels)(int16_t *av_restrict block, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride)
Definition: pixblockdsp.h:32
#define BUF_SIZE
Definition: pixblockdsp.c:29
void(* get_pixels)(int16_t *av_restrict block, const uint8_t *pixels, ptrdiff_t stride)
Definition: pixblockdsp.h:29
av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx)
Definition: pixblockdsp.c:81
common internal API header
main external API structure.
Definition: avcodec.h:1518
#define check_func(func,...)
Definition: checkasm.h:107
#define check_diff_pixels(type)
Definition: pixblockdsp.c:64
common internal and external API header
#define LOCAL_ALIGNED_16(t, v,...)
Definition: internal.h:131
#define check_get_pixels(type)
Definition: pixblockdsp.c:47