FFmpeg
hevc_deblock.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #include <string.h>
20 
21 #include "libavutil/intreadwrite.h"
22 #include "libavutil/mem_internal.h"
23 
24 #include "libavcodec/avcodec.h"
25 #include "libavcodec/hevcdsp.h"
26 
27 #include "checkasm.h"
28 
29 static const uint32_t pixel_mask[3] = { 0xffffffff, 0x03ff03ff, 0x0fff0fff };
30 
31 #define SIZEOF_PIXEL ((bit_depth + 7) / 8)
32 #define BUF_STRIDE (8 * 2)
33 #define BUF_LINES (8)
34 #define BUF_OFFSET (BUF_STRIDE * BUF_LINES)
35 #define BUF_SIZE (BUF_STRIDE * BUF_LINES + BUF_OFFSET * 2)
36 
37 #define randomize_buffers(buf0, buf1, size) \
38  do { \
39  uint32_t mask = pixel_mask[(bit_depth - 8) >> 1]; \
40  int k; \
41  for (k = 0; k < size; k += 4) { \
42  uint32_t r = rnd() & mask; \
43  AV_WN32A(buf0 + k, r); \
44  AV_WN32A(buf1 + k, r); \
45  } \
46  } while (0)
47 
49 {
50  int32_t tc[2] = { 0, 0 };
51  // no_p, no_q can only be { 0,0 } for the simpler assembly (non *_c
52  // variant) functions, see deblocking_filter_CTB() in hevc_filter.c
53  uint8_t no_p[2] = { 0, 0 };
54  uint8_t no_q[2] = { 0, 0 };
55  LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
56  LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
57 
58  declare_func(void, uint8_t *pix, ptrdiff_t stride, int32_t *tc, uint8_t *no_p, uint8_t *no_q);
59 
60  if (check_func(h->hevc_h_loop_filter_chroma, "hevc_h_loop_filter_chroma%d", bit_depth)) {
61  for (int i = 0; i < 4; i++) {
62  randomize_buffers(buf0, buf1, BUF_SIZE);
63  // see betatable[] in hevc_filter.c
64  tc[0] = (rnd() & 63) + (rnd() & 1);
65  tc[1] = (rnd() & 63) + (rnd() & 1);
66 
67  call_ref(buf0 + BUF_OFFSET, BUF_STRIDE, tc, no_p, no_q);
68  call_new(buf1 + BUF_OFFSET, BUF_STRIDE, tc, no_p, no_q);
69  if (memcmp(buf0, buf1, BUF_SIZE))
70  fail();
71  }
72  bench_new(buf1 + BUF_OFFSET, BUF_STRIDE, tc, no_p, no_q);
73  }
74 
75  if (check_func(h->hevc_v_loop_filter_chroma, "hevc_v_loop_filter_chroma%d", bit_depth)) {
76  for (int i = 0; i < 4; i++) {
77  randomize_buffers(buf0, buf1, BUF_SIZE);
78  // see betatable[] in hevc_filter.c
79  tc[0] = (rnd() & 63) + (rnd() & 1);
80  tc[1] = (rnd() & 63) + (rnd() & 1);
81 
82  call_ref(buf0 + BUF_OFFSET, BUF_STRIDE, tc, no_p, no_q);
83  call_new(buf1 + BUF_OFFSET, BUF_STRIDE, tc, no_p, no_q);
84  if (memcmp(buf0, buf1, BUF_SIZE))
85  fail();
86  }
87  bench_new(buf1 + BUF_OFFSET, BUF_STRIDE, tc, no_p, no_q);
88  }
89 }
90 
92 {
93  int bit_depth;
94 
95  for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) {
99  }
100  report("chroma");
101 }
mem_internal.h
check_func
#define check_func(func,...)
Definition: checkasm.h:170
call_ref
#define call_ref(...)
Definition: checkasm.h:185
bit_depth
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition: af_astats.c:245
fail
#define fail()
Definition: checkasm.h:179
checkasm.h
rnd
#define rnd()
Definition: checkasm.h:163
intreadwrite.h
BUF_STRIDE
#define BUF_STRIDE
Definition: hevc_deblock.c:32
randomize_buffers
#define randomize_buffers(buf0, buf1, size)
Definition: hevc_deblock.c:37
hevcdsp.h
call_new
#define call_new(...)
Definition: checkasm.h:288
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition: mem_internal.h:135
BUF_SIZE
#define BUF_SIZE
Definition: hevc_deblock.c:35
check_deblock_chroma
static void check_deblock_chroma(HEVCDSPContext *h, int bit_depth)
Definition: hevc_deblock.c:48
HEVCDSPContext
Definition: hevcdsp.h:47
report
#define report
Definition: checkasm.h:182
bench_new
#define bench_new(...)
Definition: checkasm.h:358
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:245
avcodec.h
stride
#define stride
Definition: h264pred_template.c:537
pixel_mask
static const uint32_t pixel_mask[3]
Definition: hevc_deblock.c:29
ff_hevc_dsp_init
void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
Definition: hevcdsp.c:128
checkasm_check_hevc_deblock
void checkasm_check_hevc_deblock(void)
Definition: hevc_deblock.c:91
tc
#define tc
Definition: regdef.h:69
declare_func
#define declare_func(ret,...)
Definition: checkasm.h:174
BUF_OFFSET
#define BUF_OFFSET
Definition: hevc_deblock.c:34
int32_t
int32_t
Definition: audioconvert.c:56
h
h
Definition: vp9dsp_template.c:2038