-
Notifications
You must be signed in to change notification settings - Fork 8
/
10574.diff
189 lines (172 loc) · 7.62 KB
/
10574.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
commit 2dffbafc910846896f1fb77b4a47173ba26f781e
Author: Cheng Chen <[email protected]>
Date: Fri Sep 21 11:59:06 2018 -0700
Fix a fuzzer bug for loop filter bitmask
Horizontal loop filter takes two edges to filter together.
This CL fix the bug where the next edge is out of bound of current
64x64 block.
BUG=oss-fuzz:10574
Change-Id: I3fbe27ec1c33a1bb9728413b3b883539653b7fdb
diff --git a/av1/common/av1_loopfilter.c b/av1/common/av1_loopfilter.c
index ff24a3e264..0b2446fc47 100644
--- a/av1/common/av1_loopfilter.c
+++ b/av1/common/av1_loopfilter.c
@@ -1313,154 +1313,164 @@ static void highbd_filter_selectively_vert_row2(
static void filter_selectively_horiz(uint8_t *s, int pitch, int plane,
int subsampling, uint64_t mask_16x16,
uint64_t mask_8x8, uint64_t mask_4x4,
const loop_filter_info_n *lfi_n,
const uint8_t *lfl) {
uint64_t mask;
int count;
const int step = 1 << subsampling;
const unsigned int two_block_mask = subsampling ? 5 : 3;
+ int offset = 0;
for (mask = mask_16x16 | mask_8x8 | mask_4x4; mask; mask >>= step * count) {
const loop_filter_thresh *lfi = lfi_n->lfthr + *lfl;
- // Next block's thresholds.
- const loop_filter_thresh *lfin = lfi_n->lfthr + *(lfl + step);
- (void)lfin;
+ // Next block's thresholds, when it is within current 64x64 block.
+ // If it is out of bound, its mask is zero, and it points to current edge's
+ // filter parameters, instead of next edge's.
+ int next_edge = step;
+ if (offset + next_edge >= MI_SIZE_64X64) next_edge = 0;
+ const loop_filter_thresh *lfin = lfi_n->lfthr + *(lfl + next_edge);
count = 1;
if (mask & 1) {
if (mask_16x16 & 1) {
// chroma plane filters less pixels introduced in deblock_13tap
// experiment
LpfFunc lpf_horizontal =
plane ? aom_lpf_horizontal_6 : aom_lpf_horizontal_14;
if ((mask_16x16 & two_block_mask) == two_block_mask) {
if (plane) {
aom_lpf_horizontal_6_dual(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, lfin->mblim, lfin->lim,
lfin->hev_thr);
} else {
aom_lpf_horizontal_14_dual(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, lfin->mblim, lfin->lim,
lfin->hev_thr);
}
count = 2;
} else {
lpf_horizontal(s, pitch, lfi->mblim, lfi->lim, lfi->hev_thr);
}
} else if (mask_8x8 & 1) {
// chroma plane filters less pixels introduced in deblock_13tap
// experiment
LpfFunc lpf_horizontal =
plane ? aom_lpf_horizontal_6 : aom_lpf_horizontal_8;
if ((mask_8x8 & two_block_mask) == two_block_mask) {
if (plane) {
aom_lpf_horizontal_6_dual(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, lfin->mblim, lfin->lim,
lfin->hev_thr);
} else {
aom_lpf_horizontal_8_dual(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, lfin->mblim, lfin->lim,
lfin->hev_thr);
}
count = 2;
} else {
lpf_horizontal(s, pitch, lfi->mblim, lfi->lim, lfi->hev_thr);
}
} else if (mask_4x4 & 1) {
if ((mask_4x4 & two_block_mask) == two_block_mask) {
aom_lpf_horizontal_4_dual(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, lfin->mblim, lfin->lim,
lfin->hev_thr);
count = 2;
} else {
aom_lpf_horizontal_4(s, pitch, lfi->mblim, lfi->lim, lfi->hev_thr);
}
}
}
s += 4 * count;
lfl += step * count;
mask_16x16 >>= step * count;
mask_8x8 >>= step * count;
mask_4x4 >>= step * count;
+ offset += step * count;
}
}
static void highbd_filter_selectively_horiz(
uint16_t *s, int pitch, int plane, int subsampling, uint64_t mask_16x16,
uint64_t mask_8x8, uint64_t mask_4x4, const loop_filter_info_n *lfi_n,
uint8_t *lfl, int bd) {
uint64_t mask;
int count;
const int step = 1 << subsampling;
const unsigned int two_block_mask = subsampling ? 5 : 3;
+ int offset = 0;
for (mask = mask_16x16 | mask_8x8 | mask_4x4; mask; mask >>= step * count) {
const loop_filter_thresh *lfi = lfi_n->lfthr + *lfl;
- // Next block's thresholds.
- const loop_filter_thresh *lfin = lfi_n->lfthr + *(lfl + step);
- (void)lfin;
+ // Next block's thresholds, when it is within current 64x64 block.
+ // If it is out of bound, its mask is zero, and it points to current edge's
+ // filter parameters, instead of next edge's.
+ int next_edge = step;
+ if (offset + next_edge >= MI_SIZE_64X64) next_edge = 0;
+ const loop_filter_thresh *lfin = lfi_n->lfthr + *(lfl + next_edge);
count = 1;
if (mask & 1) {
if (mask_16x16 & 1) {
HbdLpfFunc highbd_lpf_horizontal =
plane ? aom_highbd_lpf_horizontal_6 : aom_highbd_lpf_horizontal_14;
if ((mask_16x16 & two_block_mask) == two_block_mask) {
if (plane) {
aom_highbd_lpf_horizontal_6_dual_c(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, lfin->mblim,
lfin->lim, lfin->hev_thr, bd);
} else {
aom_highbd_lpf_horizontal_14_dual_c(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, lfin->mblim,
lfin->lim, lfin->hev_thr, bd);
}
count = 2;
} else {
highbd_lpf_horizontal(s, pitch, lfi->mblim, lfi->lim, lfi->hev_thr,
bd);
}
} else if (mask_8x8 & 1) {
HbdLpfFunc highbd_lpf_horizontal =
plane ? aom_highbd_lpf_horizontal_6 : aom_highbd_lpf_horizontal_8;
if ((mask_8x8 & two_block_mask) == two_block_mask) {
if (plane) {
aom_highbd_lpf_horizontal_6_dual_c(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, lfin->mblim,
lfin->lim, lfin->hev_thr, bd);
} else {
aom_highbd_lpf_horizontal_8_dual_c(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, lfin->mblim,
lfin->lim, lfin->hev_thr, bd);
}
count = 2;
} else {
highbd_lpf_horizontal(s, pitch, lfi->mblim, lfi->lim, lfi->hev_thr,
bd);
}
} else if (mask_4x4 & 1) {
if ((mask_4x4 & two_block_mask) == two_block_mask) {
aom_highbd_lpf_horizontal_4_dual_c(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, lfin->mblim,
lfin->lim, lfin->hev_thr, bd);
count = 2;
} else {
aom_highbd_lpf_horizontal_4(s, pitch, lfi->mblim, lfi->lim,
lfi->hev_thr, bd);
}
}
}
s += 4 * count;
lfl += step * count;
mask_16x16 >>= step * count;
mask_8x8 >>= step * count;
mask_4x4 >>= step * count;
+ offset += step * count;
}
}