Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
* Copyright (c) 2018 Yingming Fan <yingmingfan@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 |
|
|
|
23 |
|
|
#include "libavutil/intreadwrite.h" |
24 |
|
|
#include "libavutil/mem_internal.h" |
25 |
|
|
|
26 |
|
|
#include "libavcodec/vvc/dsp.h" |
27 |
|
|
#include "libavcodec/vvc/ctu.h" |
28 |
|
|
|
29 |
|
|
#include "checkasm.h" |
30 |
|
|
|
31 |
|
|
static const uint32_t pixel_mask[3] = { 0xffffffff, 0x03ff03ff, 0x0fff0fff }; |
32 |
|
|
static const uint32_t sao_size[] = {8, 16, 32, 48, 64, 80, 96, 112, 128}; |
33 |
|
|
|
34 |
|
|
#define SIZEOF_PIXEL ((bit_depth + 7) / 8) |
35 |
|
|
#define PIXEL_STRIDE (2*MAX_CTU_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) //same with sao_edge src_stride |
36 |
|
|
#define BUF_SIZE (PIXEL_STRIDE * (MAX_CTU_SIZE+2) * 2) //+2 for top and bottom row, *2 for high bit depth |
37 |
|
|
#define OFFSET_THRESH (1 << (bit_depth - 5)) |
38 |
|
|
#define OFFSET_LENGTH 5 |
39 |
|
|
|
40 |
|
|
#define randomize_buffers(buf0, buf1, size) \ |
41 |
|
|
do { \ |
42 |
|
|
uint32_t mask = pixel_mask[(bit_depth - 8) >> 1]; \ |
43 |
|
|
int k; \ |
44 |
|
|
for (k = 0; k < size; k += 4) { \ |
45 |
|
|
uint32_t r = rnd() & mask; \ |
46 |
|
|
AV_WN32A(buf0 + k, r); \ |
47 |
|
|
AV_WN32A(buf1 + k, r); \ |
48 |
|
|
} \ |
49 |
|
|
} while (0) |
50 |
|
|
|
51 |
|
|
#define randomize_buffers2(buf, size) \ |
52 |
|
|
do { \ |
53 |
|
|
uint32_t max_offset = OFFSET_THRESH; \ |
54 |
|
|
int k; \ |
55 |
|
|
if (bit_depth == 8) { \ |
56 |
|
|
for (k = 0; k < size; k++) { \ |
57 |
|
|
uint8_t r = rnd() % max_offset; \ |
58 |
|
|
buf[k] = r; \ |
59 |
|
|
} \ |
60 |
|
|
} else { \ |
61 |
|
|
for (k = 0; k < size; k++) { \ |
62 |
|
|
uint16_t r = rnd() % max_offset; \ |
63 |
|
|
buf[k] = r; \ |
64 |
|
|
} \ |
65 |
|
|
} \ |
66 |
|
|
} while (0) |
67 |
|
|
|
68 |
|
✗ |
static void check_sao_band(VVCDSPContext *h, int bit_depth) |
69 |
|
|
{ |
70 |
|
✗ |
PIXEL_RECT(dst0, MAX_CTU_SIZE, MAX_CTU_SIZE); |
71 |
|
✗ |
PIXEL_RECT(dst1, MAX_CTU_SIZE, MAX_CTU_SIZE); |
72 |
|
✗ |
LOCAL_ALIGNED_32(uint8_t, src0, [BUF_SIZE]); |
73 |
|
✗ |
LOCAL_ALIGNED_32(uint8_t, src1, [BUF_SIZE]); |
74 |
|
|
int16_t offset_val[OFFSET_LENGTH]; |
75 |
|
✗ |
const int left_class = rnd()%32; |
76 |
|
✗ |
const int walign = 16; |
77 |
|
|
|
78 |
|
✗ |
for (int i = 0; i < FF_ARRAY_ELEMS(sao_size); i++) { |
79 |
|
✗ |
const int block_size = sao_size[i]; |
80 |
|
✗ |
const int prev_size = i > 0 ? sao_size[i - 1] : 0; |
81 |
|
✗ |
ptrdiff_t stride = PIXEL_STRIDE*SIZEOF_PIXEL; |
82 |
|
✗ |
declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t dst_stride, ptrdiff_t src_stride, |
83 |
|
|
const int16_t *sao_offset_val, int sao_left_class, int width, int height); |
84 |
|
|
|
85 |
|
✗ |
if (check_func(h->sao.band_filter[i], "vvc_sao_band_%d_%d", block_size, bit_depth)) { |
86 |
|
|
|
87 |
|
✗ |
for (int w = prev_size + 4; w <= block_size; w += 4) { |
88 |
|
✗ |
randomize_buffers(src0, src1, BUF_SIZE); |
89 |
|
✗ |
randomize_buffers2(offset_val, OFFSET_LENGTH); |
90 |
|
✗ |
CLEAR_PIXEL_RECT(dst0); |
91 |
|
✗ |
CLEAR_PIXEL_RECT(dst1); |
92 |
|
|
|
93 |
|
✗ |
call_ref(dst0, src0, dst0_stride, stride, offset_val, left_class, w, block_size); |
94 |
|
✗ |
call_new(dst1, src1, dst1_stride, stride, offset_val, left_class, w, block_size); |
95 |
|
✗ |
checkasm_check_pixel_padded_align(dst0, dst0_stride, dst1, dst1_stride, w, block_size, "dst", walign, 1); |
96 |
|
|
} |
97 |
|
✗ |
bench_new(dst1, src1, dst1_stride, stride, offset_val, left_class, block_size, block_size); |
98 |
|
|
} |
99 |
|
|
} |
100 |
|
✗ |
} |
101 |
|
|
|
102 |
|
✗ |
static void check_sao_edge(VVCDSPContext *h, int bit_depth) |
103 |
|
|
{ |
104 |
|
✗ |
PIXEL_RECT(dst0, MAX_CTU_SIZE, MAX_CTU_SIZE); |
105 |
|
✗ |
PIXEL_RECT(dst1, MAX_CTU_SIZE, MAX_CTU_SIZE); |
106 |
|
✗ |
LOCAL_ALIGNED_32(uint8_t, src0, [BUF_SIZE]); |
107 |
|
✗ |
LOCAL_ALIGNED_32(uint8_t, src1, [BUF_SIZE]); |
108 |
|
|
int16_t offset_val[OFFSET_LENGTH]; |
109 |
|
✗ |
const int eo = rnd()%4; |
110 |
|
✗ |
const int walign = 16; |
111 |
|
|
|
112 |
|
✗ |
for (int i = 0; i < FF_ARRAY_ELEMS(sao_size); i++) { |
113 |
|
✗ |
int block_size = sao_size[i]; |
114 |
|
✗ |
int prev_size = i > 0 ? sao_size[i - 1] : 0; |
115 |
|
✗ |
int offset = (AV_INPUT_BUFFER_PADDING_SIZE + PIXEL_STRIDE)*SIZEOF_PIXEL; |
116 |
|
✗ |
declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t stride_dst, |
117 |
|
|
const int16_t *sao_offset_val, int eo, int width, int height); |
118 |
|
|
|
119 |
|
✗ |
if (check_func(h->sao.edge_filter[i], "vvc_sao_edge_%d_%d", block_size, bit_depth)) { |
120 |
|
✗ |
for (int w = prev_size + 4; w <= block_size; w += 4) { |
121 |
|
✗ |
randomize_buffers(src0, src1, BUF_SIZE); |
122 |
|
✗ |
randomize_buffers2(offset_val, OFFSET_LENGTH); |
123 |
|
✗ |
CLEAR_PIXEL_RECT(dst0); |
124 |
|
✗ |
CLEAR_PIXEL_RECT(dst1); |
125 |
|
|
|
126 |
|
✗ |
call_ref(dst0, src0 + offset, dst0_stride, offset_val, eo, w, block_size); |
127 |
|
✗ |
call_new(dst1, src1 + offset, dst1_stride, offset_val, eo, w, block_size); |
128 |
|
✗ |
checkasm_check_pixel_padded_align(dst0, dst0_stride, dst1, dst1_stride, w, block_size, "dst", walign, 1); |
129 |
|
|
} |
130 |
|
✗ |
bench_new(dst1, src1 + offset, dst1_stride, offset_val, eo, block_size, block_size); |
131 |
|
|
} |
132 |
|
|
} |
133 |
|
✗ |
} |
134 |
|
|
|
135 |
|
✗ |
void checkasm_check_vvc_sao(void) |
136 |
|
|
{ |
137 |
|
|
int bit_depth; |
138 |
|
|
|
139 |
|
✗ |
for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) { |
140 |
|
|
VVCDSPContext h; |
141 |
|
|
|
142 |
|
✗ |
ff_vvc_dsp_init(&h, bit_depth); |
143 |
|
✗ |
check_sao_band(&h, bit_depth); |
144 |
|
|
} |
145 |
|
✗ |
report("sao_band"); |
146 |
|
|
|
147 |
|
✗ |
for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) { |
148 |
|
|
VVCDSPContext h; |
149 |
|
|
|
150 |
|
✗ |
ff_vvc_dsp_init(&h, bit_depth); |
151 |
|
✗ |
check_sao_edge(&h, bit_depth); |
152 |
|
|
} |
153 |
|
✗ |
report("sao_edge"); |
154 |
|
✗ |
} |
155 |
|
|
|