FFmpeg
Loading...
Searching...
No Matches
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"
28
29static const uint32_t pixel_mask[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff };
30
31#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
32#define BUF_SIZE (2 * 16 * (16 + 3 + 4))
33
34#define randomize_buffers() \
35 do { \
36 uint32_t mask = pixel_mask[bit_depth - 8]; \
37 int k; \
38 for (k = 0; k < BUF_SIZE; k += 4) { \
39 uint32_t r = rnd() & mask; \
40 AV_WN32A(buf0 + k, r); \
41 AV_WN32A(buf1 + k, r); \
42 r = rnd(); \
43 AV_WN32A(dst0 + k, r); \
44 AV_WN32A(dst1 + k, r); \
45 } \
46 } while (0)
47
48#define src0 (buf0 + 3 * 2 * 16) /* h264qpel functions read data from negative src pointer offsets */
49#define src1 (buf1 + 3 * 2 * 16)
50
52{
53 LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]);
54 LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]);
55 LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
56 LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
58 int op, bit_depth, i, j;
59 declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, const uint8_t *src, ptrdiff_t stride);
60
61 for (op = 0; op < 2; op++) {
62 qpel_mc_func (*tab)[16] = op ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab;
63 const char *op_name = op ? "avg" : "put";
64
65 for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
67 for (i = 0; i < 3; i++) {
68 int size = 16 >> i;
69 for (j = 0; j < 16; j++)
70 if (check_func(tab[i][j], "%s_h264_qpel_%d_mc%d%d_%d", op_name, size, j & 3, j >> 2, bit_depth)) {
74 if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE))
75 fail();
77 }
78 }
79 }
80 report("%s", op_name);
81 }
82}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition af_astats.c:246
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
common internal and external API header
#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
#define declare_func_emms
Definition test.h:490
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:76
av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth)
Definition h264qpel.c:50
#define AV_CPU_FLAG_MMXEXT
SSE integer functions or AMD MMX ext.
Definition cpu.h:33
#define AV_CPU_FLAG_MMX
standard MMX
Definition cpu.h:32
common internal API header
#define LOCAL_ALIGNED_16(t, v,...)
void(* qpel_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
Definition qpeldsp.h:65
#define BUF_SIZE
Definition setpts.c:159
#define stride
#define SIZEOF_PIXEL
Definition h264chroma.c:28
static const uint32_t pixel_mask[5]
Definition h264dsp.c:31
#define src1
Definition h264pred.c:141
#define src0
Definition h264pred.c:140
#define randomize_buffers()
Definition h264qpel.c:34
void checkasm_check_h264qpel(void)
Definition h264qpel.c:51
#define src
Definition vp8dsp.c:248
int size
static const struct twinvq_data tab