FFmpeg
h264qpel.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 #include "checkasm.h"
23 #include "libavcodec/h264qpel.h"
24 #include "libavutil/common.h"
25 #include "libavutil/internal.h"
26 #include "libavutil/intreadwrite.h"
27 
28 static const uint32_t pixel_mask[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff };
29 
30 #define SIZEOF_PIXEL ((bit_depth + 7) / 8)
31 #define BUF_SIZE (2 * 16 * (16 + 3 + 4))
32 
33 #define randomize_buffers() \
34  do { \
35  uint32_t mask = pixel_mask[bit_depth - 8]; \
36  int k; \
37  for (k = 0; k < BUF_SIZE; k += 4) { \
38  uint32_t r = rnd() & mask; \
39  AV_WN32A(buf0 + k, r); \
40  AV_WN32A(buf1 + k, r); \
41  r = rnd(); \
42  AV_WN32A(dst0 + k, r); \
43  AV_WN32A(dst1 + k, r); \
44  } \
45  } while (0)
46 
47 #define src0 (buf0 + 3 * 2 * 16) /* h264qpel functions read data from negative src pointer offsets */
48 #define src1 (buf1 + 3 * 2 * 16)
49 
51 {
57  int op, bit_depth, i, j;
59 
60  for (op = 0; op < 2; op++) {
61  qpel_mc_func (*tab)[16] = op ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab;
62  const char *op_name = op ? "avg" : "put";
63 
64  for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
66  for (i = 0; i < (op ? 3 : 4); i++) {
67  int size = 16 >> i;
68  for (j = 0; j < 16; j++)
69  if (check_func(tab[i][j], "%s_h264_qpel_%d_mc%d%d_%d", op_name, size, j & 3, j >> 2, bit_depth)) {
71  call_ref(dst0, src0, size * SIZEOF_PIXEL);
72  call_new(dst1, src1, size * SIZEOF_PIXEL);
73  if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE))
74  fail();
75  bench_new(dst1, src1, size * SIZEOF_PIXEL);
76  }
77  }
78  }
79  report("%s", op_name);
80  }
81 }
declare_func_emms
#define declare_func_emms(cpu_flags, ret,...)
Definition: checkasm.h:120
stride
int stride
Definition: mace.c:144
bit_depth
static void bit_depth(AudioStatsContext *s, uint64_t mask, uint64_t imask, AVRational *depth)
Definition: af_astats.c:254
pixel_mask
static const uint32_t pixel_mask[3]
Definition: h264qpel.c:28
check_func
#define check_func(func,...)
Definition: checkasm.h:114
BUF_SIZE
#define BUF_SIZE
Definition: h264qpel.c:31
call_ref
#define call_ref(...)
Definition: checkasm.h:129
h264qpel.h
fail
#define fail()
Definition: checkasm.h:123
tab
static const struct twinvq_data tab
Definition: twinvq_data.h:11135
checkasm.h
ff_h264qpel_init
av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth)
Definition: h264qpel.c:49
intreadwrite.h
op
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
Definition: anm.c:75
checkasm_check_h264qpel
void checkasm_check_h264qpel(void)
Definition: h264qpel.c:50
call_new
#define call_new(...)
Definition: checkasm.h:201
randomize_buffers
#define randomize_buffers()
Definition: h264qpel.c:33
src
#define src
Definition: vp8dsp.c:254
src0
#define src0
Definition: h264qpel.c:47
qpel_mc_func
void(* qpel_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
Definition: qpeldsp.h:65
size
int size
Definition: twinvq_data.h:11134
report
#define report
Definition: checkasm.h:126
bench_new
#define bench_new(...)
Definition: checkasm.h:261
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
internal.h
common.h
uint8_t
uint8_t
Definition: audio_convert.c:194
H264QpelContext
Definition: h264qpel.h:27
src1
#define src1
Definition: h264qpel.c:48
SIZEOF_PIXEL
#define SIZEOF_PIXEL
Definition: h264qpel.c:30
AV_CPU_FLAG_MMX
#define AV_CPU_FLAG_MMX
standard MMX
Definition: cpu.h:31
AV_CPU_FLAG_MMXEXT
#define AV_CPU_FLAG_MMXEXT
SSE integer functions or AMD MMX ext.
Definition: cpu.h:32
LOCAL_ALIGNED_16
#define LOCAL_ALIGNED_16(t, v,...)
Definition: internal.h:131
h
h
Definition: vp9dsp_template.c:2038