Directory: | ../../../ffmpeg/ |
---|---|
File: | src/libavcodec/hevc_filter.c |
Date: | 2022-07-05 19:52:29 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 542 | 547 | 99.1% |
Branches: | 489 | 505 | 96.8% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * HEVC video decoder | ||
3 | * | ||
4 | * Copyright (C) 2012 - 2013 Guillaume Martres | ||
5 | * Copyright (C) 2013 Seppo Tomperi | ||
6 | * Copyright (C) 2013 Wassim Hamidouche | ||
7 | * | ||
8 | * This file is part of FFmpeg. | ||
9 | * | ||
10 | * FFmpeg is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU Lesser General Public | ||
12 | * License as published by the Free Software Foundation; either | ||
13 | * version 2.1 of the License, or (at your option) any later version. | ||
14 | * | ||
15 | * FFmpeg is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18 | * Lesser General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU Lesser General Public | ||
21 | * License along with FFmpeg; if not, write to the Free Software | ||
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
23 | */ | ||
24 | |||
25 | #include "libavutil/common.h" | ||
26 | #include "libavutil/internal.h" | ||
27 | |||
28 | #include "hevcdec.h" | ||
29 | #include "threadframe.h" | ||
30 | |||
31 | #define LUMA 0 | ||
32 | #define CB 1 | ||
33 | #define CR 2 | ||
34 | |||
35 | static const uint8_t tctable[54] = { | ||
36 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // QP 0...18 | ||
37 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, // QP 19...37 | ||
38 | 5, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 24 // QP 38...53 | ||
39 | }; | ||
40 | |||
41 | static const uint8_t betatable[52] = { | ||
42 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, // QP 0...18 | ||
43 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, // QP 19...37 | ||
44 | 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64 // QP 38...51 | ||
45 | }; | ||
46 | |||
47 | 21758756 | static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset) | |
48 | { | ||
49 | static const int qp_c[] = { | ||
50 | 29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37 | ||
51 | }; | ||
52 | int qp, qp_i, offset, idxt; | ||
53 | |||
54 | // slice qp offset is not used for deblocking | ||
55 |
2/2✓ Branch 0 taken 10879378 times.
✓ Branch 1 taken 10879378 times.
|
21758756 | if (c_idx == 1) |
56 | 10879378 | offset = s->ps.pps->cb_qp_offset; | |
57 | else | ||
58 | 10879378 | offset = s->ps.pps->cr_qp_offset; | |
59 | |||
60 | 21758756 | qp_i = av_clip(qp_y + offset, 0, 57); | |
61 |
2/2✓ Branch 0 taken 18279028 times.
✓ Branch 1 taken 3479728 times.
|
21758756 | if (s->ps.sps->chroma_format_idc == 1) { |
62 |
2/2✓ Branch 0 taken 2947419 times.
✓ Branch 1 taken 15331609 times.
|
18279028 | if (qp_i < 30) |
63 | 2947419 | qp = qp_i; | |
64 |
2/2✓ Branch 0 taken 153221 times.
✓ Branch 1 taken 15178388 times.
|
15331609 | else if (qp_i > 43) |
65 | 153221 | qp = qp_i - 6; | |
66 | else | ||
67 | 15178388 | qp = qp_c[qp_i - 30]; | |
68 | } else { | ||
69 | 3479728 | qp = av_clip(qp_i, 0, 51); | |
70 | } | ||
71 | |||
72 | 21758756 | idxt = av_clip(qp + DEFAULT_INTRA_TC_OFFSET + tc_offset, 0, 53); | |
73 | 21758756 | return tctable[idxt]; | |
74 | } | ||
75 | |||
76 | 1351388 | static int get_qPy_pred(HEVCContext *s, int xBase, int yBase, int log2_cb_size) | |
77 | { | ||
78 | 1351388 | HEVCLocalContext *lc = s->HEVClc; | |
79 | 1351388 | int ctb_size_mask = (1 << s->ps.sps->log2_ctb_size) - 1; | |
80 | 1351388 | int MinCuQpDeltaSizeMask = (1 << (s->ps.sps->log2_ctb_size - | |
81 | 1351388 | s->ps.pps->diff_cu_qp_delta_depth)) - 1; | |
82 | 1351388 | int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask); | |
83 | 1351388 | int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask); | |
84 | 1351388 | int min_cb_width = s->ps.sps->min_cb_width; | |
85 | 1351388 | int x_cb = xQgBase >> s->ps.sps->log2_min_cb_size; | |
86 | 1351388 | int y_cb = yQgBase >> s->ps.sps->log2_min_cb_size; | |
87 |
2/2✓ Branch 0 taken 923504 times.
✓ Branch 1 taken 427884 times.
|
2274892 | int availableA = (xBase & ctb_size_mask) && |
88 |
2/2✓ Branch 0 taken 786410 times.
✓ Branch 1 taken 137094 times.
|
923504 | (xQgBase & ctb_size_mask); |
89 |
2/2✓ Branch 0 taken 905287 times.
✓ Branch 1 taken 446101 times.
|
2256675 | int availableB = (yBase & ctb_size_mask) && |
90 |
2/2✓ Branch 0 taken 783685 times.
✓ Branch 1 taken 121602 times.
|
905287 | (yQgBase & ctb_size_mask); |
91 | int qPy_pred, qPy_a, qPy_b; | ||
92 | |||
93 | // qPy_pred | ||
94 |
5/6✓ Branch 0 taken 1263730 times.
✓ Branch 1 taken 87658 times.
✓ Branch 2 taken 18268 times.
✓ Branch 3 taken 1245462 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18268 times.
|
1351388 | if (lc->first_qp_group || (!xQgBase && !yQgBase)) { |
95 | 87658 | lc->first_qp_group = !lc->tu.is_cu_qp_delta_coded; | |
96 | 87658 | qPy_pred = s->sh.slice_qp; | |
97 | } else { | ||
98 | 1263730 | qPy_pred = lc->qPy_pred; | |
99 | } | ||
100 | |||
101 | // qPy_a | ||
102 |
2/2✓ Branch 0 taken 564978 times.
✓ Branch 1 taken 786410 times.
|
1351388 | if (availableA == 0) |
103 | 564978 | qPy_a = qPy_pred; | |
104 | else | ||
105 | 786410 | qPy_a = s->qp_y_tab[(x_cb - 1) + y_cb * min_cb_width]; | |
106 | |||
107 | // qPy_b | ||
108 |
2/2✓ Branch 0 taken 567703 times.
✓ Branch 1 taken 783685 times.
|
1351388 | if (availableB == 0) |
109 | 567703 | qPy_b = qPy_pred; | |
110 | else | ||
111 | 783685 | qPy_b = s->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width]; | |
112 | |||
113 | av_assert2(qPy_a >= -s->ps.sps->qp_bd_offset && qPy_a < 52); | ||
114 | av_assert2(qPy_b >= -s->ps.sps->qp_bd_offset && qPy_b < 52); | ||
115 | |||
116 | 1351388 | return (qPy_a + qPy_b + 1) >> 1; | |
117 | } | ||
118 | |||
119 | 1351388 | void ff_hevc_set_qPy(HEVCContext *s, int xBase, int yBase, int log2_cb_size) | |
120 | { | ||
121 | 1351388 | int qp_y = get_qPy_pred(s, xBase, yBase, log2_cb_size); | |
122 | |||
123 |
2/2✓ Branch 0 taken 368705 times.
✓ Branch 1 taken 982683 times.
|
1351388 | if (s->HEVClc->tu.cu_qp_delta != 0) { |
124 | 368705 | int off = s->ps.sps->qp_bd_offset; | |
125 |
1/2✓ Branch 0 taken 368705 times.
✗ Branch 1 not taken.
|
368705 | s->HEVClc->qp_y = FFUMOD(qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off, |
126 | 368705 | 52 + off) - off; | |
127 | } else | ||
128 | 982683 | s->HEVClc->qp_y = qp_y; | |
129 | 1351388 | } | |
130 | |||
131 | 114013690 | static int get_qPy(HEVCContext *s, int xC, int yC) | |
132 | { | ||
133 | 114013690 | int log2_min_cb_size = s->ps.sps->log2_min_cb_size; | |
134 | 114013690 | int x = xC >> log2_min_cb_size; | |
135 | 114013690 | int y = yC >> log2_min_cb_size; | |
136 | 114013690 | return s->qp_y_tab[x + y * s->ps.sps->min_cb_width]; | |
137 | } | ||
138 | |||
139 | 375578 | static void copy_CTB(uint8_t *dst, const uint8_t *src, int width, int height, | |
140 | ptrdiff_t stride_dst, ptrdiff_t stride_src) | ||
141 | { | ||
142 | int i, j; | ||
143 | |||
144 |
2/2✓ Branch 0 taken 55091 times.
✓ Branch 1 taken 320487 times.
|
375578 | if (((intptr_t)dst | (intptr_t)src | stride_dst | stride_src) & 15) { |
145 |
2/2✓ Branch 0 taken 2391520 times.
✓ Branch 1 taken 55091 times.
|
2446611 | for (i = 0; i < height; i++) { |
146 |
2/2✓ Branch 0 taken 19144688 times.
✓ Branch 1 taken 2391520 times.
|
21536208 | for (j = 0; j < width; j+=8) |
147 | 19144688 | AV_COPY64U(dst+j, src+j); | |
148 | 2391520 | dst += stride_dst; | |
149 | 2391520 | src += stride_src; | |
150 | } | ||
151 | } else { | ||
152 |
2/2✓ Branch 0 taken 16921008 times.
✓ Branch 1 taken 320487 times.
|
17241495 | for (i = 0; i < height; i++) { |
153 |
2/2✓ Branch 0 taken 86241624 times.
✓ Branch 1 taken 16921008 times.
|
103162632 | for (j = 0; j < width; j+=16) |
154 | 86241624 | AV_COPY128(dst+j, src+j); | |
155 | 16921008 | dst += stride_dst; | |
156 | 16921008 | src += stride_src; | |
157 | } | ||
158 | } | ||
159 | 375578 | } | |
160 | |||
161 | 1322618 | static void copy_pixel(uint8_t *dst, const uint8_t *src, int pixel_shift) | |
162 | { | ||
163 |
2/2✓ Branch 0 taken 222166 times.
✓ Branch 1 taken 1100452 times.
|
1322618 | if (pixel_shift) |
164 | 222166 | *(uint16_t *)dst = *(uint16_t *)src; | |
165 | else | ||
166 | 1100452 | *dst = *src; | |
167 | 1322618 | } | |
168 | |||
169 | 1275554 | static void copy_vert(uint8_t *dst, const uint8_t *src, | |
170 | int pixel_shift, int height, | ||
171 | ptrdiff_t stride_dst, ptrdiff_t stride_src) | ||
172 | { | ||
173 | int i; | ||
174 |
2/2✓ Branch 0 taken 1095282 times.
✓ Branch 1 taken 180272 times.
|
1275554 | if (pixel_shift == 0) { |
175 |
2/2✓ Branch 0 taken 51668768 times.
✓ Branch 1 taken 1095282 times.
|
52764050 | for (i = 0; i < height; i++) { |
176 | 51668768 | *dst = *src; | |
177 | 51668768 | dst += stride_dst; | |
178 | 51668768 | src += stride_src; | |
179 | } | ||
180 | } else { | ||
181 |
2/2✓ Branch 0 taken 11234032 times.
✓ Branch 1 taken 180272 times.
|
11414304 | for (i = 0; i < height; i++) { |
182 | 11234032 | *(uint16_t *)dst = *(uint16_t *)src; | |
183 | 11234032 | dst += stride_dst; | |
184 | 11234032 | src += stride_src; | |
185 | } | ||
186 | } | ||
187 | 1275554 | } | |
188 | |||
189 | 485862 | static void copy_CTB_to_hv(HEVCContext *s, const uint8_t *src, | |
190 | ptrdiff_t stride_src, int x, int y, int width, int height, | ||
191 | int c_idx, int x_ctb, int y_ctb) | ||
192 | { | ||
193 | 485862 | int sh = s->ps.sps->pixel_shift; | |
194 | 485862 | int w = s->ps.sps->width >> s->ps.sps->hshift[c_idx]; | |
195 | 485862 | int h = s->ps.sps->height >> s->ps.sps->vshift[c_idx]; | |
196 | |||
197 | /* copy horizontal edges */ | ||
198 | 485862 | memcpy(s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb) * w + x) << sh), | |
199 | 485862 | src, width << sh); | |
200 | 485862 | memcpy(s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 1) * w + x) << sh), | |
201 | 485862 | src + stride_src * (height - 1), width << sh); | |
202 | |||
203 | /* copy vertical edges */ | ||
204 | 485862 | copy_vert(s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb) * h + y) << sh), src, sh, height, 1 << sh, stride_src); | |
205 | |||
206 | 485862 | copy_vert(s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 1) * h + y) << sh), src + ((width - 1) << sh), sh, height, 1 << sh, stride_src); | |
207 | 485862 | } | |
208 | |||
209 | 375578 | static void restore_tqb_pixels(HEVCContext *s, | |
210 | uint8_t *src1, const uint8_t *dst1, | ||
211 | ptrdiff_t stride_src, ptrdiff_t stride_dst, | ||
212 | int x0, int y0, int width, int height, int c_idx) | ||
213 | { | ||
214 |
2/2✓ Branch 0 taken 371289 times.
✓ Branch 1 taken 4289 times.
|
375578 | if ( s->ps.pps->transquant_bypass_enable_flag || |
215 |
3/4✓ Branch 0 taken 104 times.
✓ Branch 1 taken 371185 times.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
|
371289 | (s->ps.sps->pcm.loop_filter_disable_flag && s->ps.sps->pcm_enabled_flag)) { |
216 | int x, y; | ||
217 | 4393 | int min_pu_size = 1 << s->ps.sps->log2_min_pu_size; | |
218 | 4393 | int hshift = s->ps.sps->hshift[c_idx]; | |
219 | 4393 | int vshift = s->ps.sps->vshift[c_idx]; | |
220 | 4393 | int x_min = ((x0 ) >> s->ps.sps->log2_min_pu_size); | |
221 | 4393 | int y_min = ((y0 ) >> s->ps.sps->log2_min_pu_size); | |
222 | 4393 | int x_max = ((x0 + width ) >> s->ps.sps->log2_min_pu_size); | |
223 | 4393 | int y_max = ((y0 + height) >> s->ps.sps->log2_min_pu_size); | |
224 | 4393 | int len = (min_pu_size >> hshift) << s->ps.sps->pixel_shift; | |
225 |
2/2✓ Branch 0 taken 49472 times.
✓ Branch 1 taken 4393 times.
|
53865 | for (y = y_min; y < y_max; y++) { |
226 |
2/2✓ Branch 0 taken 632704 times.
✓ Branch 1 taken 49472 times.
|
682176 | for (x = x_min; x < x_max; x++) { |
227 |
2/2✓ Branch 0 taken 264 times.
✓ Branch 1 taken 632440 times.
|
632704 | if (s->is_pcm[y * s->ps.sps->min_pu_width + x]) { |
228 | int n; | ||
229 | 264 | uint8_t *src = src1 + (((y << s->ps.sps->log2_min_pu_size) - y0) >> vshift) * stride_src + ((((x << s->ps.sps->log2_min_pu_size) - x0) >> hshift) << s->ps.sps->pixel_shift); | |
230 | 264 | const uint8_t *dst = dst1 + (((y << s->ps.sps->log2_min_pu_size) - y0) >> vshift) * stride_dst + ((((x << s->ps.sps->log2_min_pu_size) - x0) >> hshift) << s->ps.sps->pixel_shift); | |
231 |
2/2✓ Branch 0 taken 704 times.
✓ Branch 1 taken 264 times.
|
968 | for (n = 0; n < (min_pu_size >> vshift); n++) { |
232 | 704 | memcpy(src, dst, len); | |
233 | 704 | src += stride_src; | |
234 | 704 | dst += stride_dst; | |
235 | } | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | 375578 | } | |
241 | |||
242 | #define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)]) | ||
243 | |||
244 | 1184633 | static void sao_filter_CTB(HEVCContext *s, int x, int y) | |
245 | { | ||
246 | static const uint8_t sao_tab[8] = { 0, 1, 2, 2, 3, 3, 4, 4 }; | ||
247 | 1184633 | HEVCLocalContext *lc = s->HEVClc; | |
248 | int c_idx; | ||
249 | int edges[4]; // 0 left 1 top 2 right 3 bottom | ||
250 | 1184633 | int x_ctb = x >> s->ps.sps->log2_ctb_size; | |
251 | 1184633 | int y_ctb = y >> s->ps.sps->log2_ctb_size; | |
252 | 1184633 | int ctb_addr_rs = y_ctb * s->ps.sps->ctb_width + x_ctb; | |
253 | 1184633 | int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs]; | |
254 | 1184633 | SAOParams *sao = &CTB(s->sao, x_ctb, y_ctb); | |
255 | // flags indicating unfilterable edges | ||
256 | 1184633 | uint8_t vert_edge[] = { 0, 0 }; | |
257 | 1184633 | uint8_t horiz_edge[] = { 0, 0 }; | |
258 | 1184633 | uint8_t diag_edge[] = { 0, 0, 0, 0 }; | |
259 | 1184633 | uint8_t lfase = CTB(s->filter_slice_edges, x_ctb, y_ctb); | |
260 |
2/2✓ Branch 0 taken 170200 times.
✓ Branch 1 taken 1014433 times.
|
1354833 | uint8_t no_tile_filter = s->ps.pps->tiles_enabled_flag && |
261 |
2/2✓ Branch 0 taken 16664 times.
✓ Branch 1 taken 153536 times.
|
170200 | !s->ps.pps->loop_filter_across_tiles_enabled_flag; |
262 |
4/4✓ Branch 0 taken 1167969 times.
✓ Branch 1 taken 16664 times.
✓ Branch 2 taken 51490 times.
✓ Branch 3 taken 1116479 times.
|
1184633 | uint8_t restore = no_tile_filter || !lfase; |
263 | 1184633 | uint8_t left_tile_edge = 0; | |
264 | 1184633 | uint8_t right_tile_edge = 0; | |
265 | 1184633 | uint8_t up_tile_edge = 0; | |
266 | 1184633 | uint8_t bottom_tile_edge = 0; | |
267 | |||
268 | 1184633 | edges[0] = x_ctb == 0; | |
269 | 1184633 | edges[1] = y_ctb == 0; | |
270 | 1184633 | edges[2] = x_ctb == s->ps.sps->ctb_width - 1; | |
271 | 1184633 | edges[3] = y_ctb == s->ps.sps->ctb_height - 1; | |
272 | |||
273 |
2/2✓ Branch 0 taken 68154 times.
✓ Branch 1 taken 1116479 times.
|
1184633 | if (restore) { |
274 |
2/2✓ Branch 0 taken 64585 times.
✓ Branch 1 taken 3569 times.
|
68154 | if (!edges[0]) { |
275 |
4/4✓ Branch 0 taken 16242 times.
✓ Branch 1 taken 48343 times.
✓ Branch 2 taken 836 times.
✓ Branch 3 taken 15406 times.
|
64585 | left_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1]]; |
276 |
6/6✓ Branch 0 taken 48343 times.
✓ Branch 1 taken 16242 times.
✓ Branch 2 taken 48136 times.
✓ Branch 3 taken 207 times.
✓ Branch 4 taken 836 times.
✓ Branch 5 taken 63542 times.
|
64585 | vert_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb - 1, y_ctb)) || left_tile_edge; |
277 | } | ||
278 |
2/2✓ Branch 0 taken 64586 times.
✓ Branch 1 taken 3568 times.
|
68154 | if (!edges[2]) { |
279 |
4/4✓ Branch 0 taken 16242 times.
✓ Branch 1 taken 48344 times.
✓ Branch 2 taken 836 times.
✓ Branch 3 taken 15406 times.
|
64586 | right_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs+1]]; |
280 |
6/6✓ Branch 0 taken 48344 times.
✓ Branch 1 taken 16242 times.
✓ Branch 2 taken 48137 times.
✓ Branch 3 taken 207 times.
✓ Branch 4 taken 836 times.
✓ Branch 5 taken 63543 times.
|
64586 | vert_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb + 1, y_ctb)) || right_tile_edge; |
281 | } | ||
282 |
2/2✓ Branch 0 taken 61940 times.
✓ Branch 1 taken 6214 times.
|
68154 | if (!edges[1]) { |
283 |
4/4✓ Branch 0 taken 15931 times.
✓ Branch 1 taken 46009 times.
✓ Branch 2 taken 1440 times.
✓ Branch 3 taken 14491 times.
|
61940 | up_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->ps.sps->ctb_width]]; |
284 |
6/6✓ Branch 0 taken 46009 times.
✓ Branch 1 taken 15931 times.
✓ Branch 2 taken 44569 times.
✓ Branch 3 taken 1440 times.
✓ Branch 4 taken 1440 times.
✓ Branch 5 taken 59060 times.
|
61940 | horiz_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb, y_ctb - 1)) || up_tile_edge; |
285 | } | ||
286 |
2/2✓ Branch 0 taken 61970 times.
✓ Branch 1 taken 6184 times.
|
68154 | if (!edges[3]) { |
287 |
4/4✓ Branch 0 taken 15931 times.
✓ Branch 1 taken 46039 times.
✓ Branch 2 taken 1440 times.
✓ Branch 3 taken 14491 times.
|
61970 | bottom_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs + s->ps.sps->ctb_width]]; |
288 |
6/6✓ Branch 0 taken 46039 times.
✓ Branch 1 taken 15931 times.
✓ Branch 2 taken 44599 times.
✓ Branch 3 taken 1440 times.
✓ Branch 4 taken 1440 times.
✓ Branch 5 taken 59090 times.
|
61970 | horiz_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb, y_ctb + 1)) || bottom_tile_edge; |
289 | } | ||
290 |
4/4✓ Branch 0 taken 64585 times.
✓ Branch 1 taken 3569 times.
✓ Branch 2 taken 58971 times.
✓ Branch 3 taken 5614 times.
|
68154 | if (!edges[0] && !edges[1]) { |
291 |
8/8✓ Branch 0 taken 43443 times.
✓ Branch 1 taken 15528 times.
✓ Branch 2 taken 41859 times.
✓ Branch 3 taken 1584 times.
✓ Branch 4 taken 56588 times.
✓ Branch 5 taken 799 times.
✓ Branch 6 taken 1332 times.
✓ Branch 7 taken 55256 times.
|
58971 | diag_edge[0] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb - 1, y_ctb - 1)) || left_tile_edge || up_tile_edge; |
292 | } | ||
293 |
4/4✓ Branch 0 taken 61940 times.
✓ Branch 1 taken 6214 times.
✓ Branch 2 taken 58972 times.
✓ Branch 3 taken 2968 times.
|
68154 | if (!edges[1] && !edges[2]) { |
294 |
8/8✓ Branch 0 taken 43444 times.
✓ Branch 1 taken 15528 times.
✓ Branch 2 taken 41860 times.
✓ Branch 3 taken 1584 times.
✓ Branch 4 taken 56589 times.
✓ Branch 5 taken 799 times.
✓ Branch 6 taken 1332 times.
✓ Branch 7 taken 55257 times.
|
58972 | diag_edge[1] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb + 1, y_ctb - 1)) || right_tile_edge || up_tile_edge; |
295 | } | ||
296 |
4/4✓ Branch 0 taken 64586 times.
✓ Branch 1 taken 3568 times.
✓ Branch 2 taken 59001 times.
✓ Branch 3 taken 5585 times.
|
68154 | if (!edges[2] && !edges[3]) { |
297 |
8/8✓ Branch 0 taken 43473 times.
✓ Branch 1 taken 15528 times.
✓ Branch 2 taken 41889 times.
✓ Branch 3 taken 1584 times.
✓ Branch 4 taken 56618 times.
✓ Branch 5 taken 799 times.
✓ Branch 6 taken 1332 times.
✓ Branch 7 taken 55286 times.
|
59001 | diag_edge[2] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb + 1, y_ctb + 1)) || right_tile_edge || bottom_tile_edge; |
298 | } | ||
299 |
4/4✓ Branch 0 taken 64585 times.
✓ Branch 1 taken 3569 times.
✓ Branch 2 taken 59000 times.
✓ Branch 3 taken 5585 times.
|
68154 | if (!edges[0] && !edges[3]) { |
300 |
8/8✓ Branch 0 taken 43472 times.
✓ Branch 1 taken 15528 times.
✓ Branch 2 taken 41888 times.
✓ Branch 3 taken 1584 times.
✓ Branch 4 taken 56617 times.
✓ Branch 5 taken 799 times.
✓ Branch 6 taken 1332 times.
✓ Branch 7 taken 55285 times.
|
59000 | diag_edge[3] = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb - 1, y_ctb + 1)) || left_tile_edge || bottom_tile_edge; |
301 | } | ||
302 | } | ||
303 | |||
304 |
4/4✓ Branch 0 taken 4738340 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 3553803 times.
✓ Branch 3 taken 1184633 times.
|
4738436 | for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) { |
305 | 3553803 | int x0 = x >> s->ps.sps->hshift[c_idx]; | |
306 | 3553803 | int y0 = y >> s->ps.sps->vshift[c_idx]; | |
307 | 3553803 | ptrdiff_t stride_src = s->frame->linesize[c_idx]; | |
308 | 3553803 | int ctb_size_h = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->hshift[c_idx]; | |
309 | 3553803 | int ctb_size_v = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->vshift[c_idx]; | |
310 | 3553803 | int width = FFMIN(ctb_size_h, (s->ps.sps->width >> s->ps.sps->hshift[c_idx]) - x0); | |
311 | 3553803 | int height = FFMIN(ctb_size_v, (s->ps.sps->height >> s->ps.sps->vshift[c_idx]) - y0); | |
312 | 3553803 | int tab = sao_tab[(FFALIGN(width, 8) >> 3) - 1]; | |
313 | 3553803 | uint8_t *src = &s->frame->data[c_idx][y0 * stride_src + (x0 << s->ps.sps->pixel_shift)]; | |
314 | ptrdiff_t stride_dst; | ||
315 | uint8_t *dst; | ||
316 | |||
317 |
3/3✓ Branch 0 taken 111053 times.
✓ Branch 1 taken 374809 times.
✓ Branch 2 taken 3067941 times.
|
3553803 | switch (sao->type_idx[c_idx]) { |
318 | 111053 | case SAO_BAND: | |
319 | 111053 | copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx, | |
320 | x_ctb, y_ctb); | ||
321 |
2/2✓ Branch 0 taken 110292 times.
✓ Branch 1 taken 761 times.
|
111053 | if (s->ps.pps->transquant_bypass_enable_flag || |
322 |
3/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 110284 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
110292 | (s->ps.sps->pcm.loop_filter_disable_flag && s->ps.sps->pcm_enabled_flag)) { |
323 | 769 | dst = lc->edge_emu_buffer; | |
324 | 769 | stride_dst = 2*MAX_PB_SIZE; | |
325 | 769 | copy_CTB(dst, src, width << s->ps.sps->pixel_shift, height, stride_dst, stride_src); | |
326 | 769 | s->hevcdsp.sao_band_filter[tab](src, dst, stride_src, stride_dst, | |
327 | 769 | sao->offset_val[c_idx], sao->band_position[c_idx], | |
328 | width, height); | ||
329 | 769 | restore_tqb_pixels(s, src, dst, stride_src, stride_dst, | |
330 | x, y, width, height, c_idx); | ||
331 | } else { | ||
332 | 110284 | s->hevcdsp.sao_band_filter[tab](src, src, stride_src, stride_src, | |
333 | 110284 | sao->offset_val[c_idx], sao->band_position[c_idx], | |
334 | width, height); | ||
335 | } | ||
336 | 111053 | sao->type_idx[c_idx] = SAO_APPLIED; | |
337 | 111053 | break; | |
338 | 374809 | case SAO_EDGE: | |
339 | { | ||
340 | 374809 | int w = s->ps.sps->width >> s->ps.sps->hshift[c_idx]; | |
341 | 374809 | int h = s->ps.sps->height >> s->ps.sps->vshift[c_idx]; | |
342 | 374809 | int left_edge = edges[0]; | |
343 | 374809 | int top_edge = edges[1]; | |
344 | 374809 | int right_edge = edges[2]; | |
345 | 374809 | int bottom_edge = edges[3]; | |
346 | 374809 | int sh = s->ps.sps->pixel_shift; | |
347 | int left_pixels, right_pixels; | ||
348 | |||
349 | 374809 | stride_dst = 2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE; | |
350 | 374809 | dst = lc->edge_emu_buffer + stride_dst + AV_INPUT_BUFFER_PADDING_SIZE; | |
351 | |||
352 |
2/2✓ Branch 0 taken 349082 times.
✓ Branch 1 taken 25727 times.
|
374809 | if (!top_edge) { |
353 | 349082 | int left = 1 - left_edge; | |
354 | 349082 | int right = 1 - right_edge; | |
355 | const uint8_t *src1[2]; | ||
356 | uint8_t *dst1; | ||
357 | int src_idx, pos; | ||
358 | |||
359 | 349082 | dst1 = dst - stride_dst - (left << sh); | |
360 | 349082 | src1[0] = src - stride_src - (left << sh); | |
361 | 349082 | src1[1] = s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb - 1) * w + x0 - left) << sh); | |
362 | 349082 | pos = 0; | |
363 |
2/2✓ Branch 0 taken 332621 times.
✓ Branch 1 taken 16461 times.
|
349082 | if (left) { |
364 | 332621 | src_idx = (CTB(s->sao, x_ctb-1, y_ctb-1).type_idx[c_idx] == | |
365 | SAO_APPLIED); | ||
366 | 332621 | copy_pixel(dst1, src1[src_idx], sh); | |
367 | 332621 | pos += (1 << sh); | |
368 | } | ||
369 | 349082 | src_idx = (CTB(s->sao, x_ctb, y_ctb-1).type_idx[c_idx] == | |
370 | SAO_APPLIED); | ||
371 | 349082 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); | |
372 |
2/2✓ Branch 0 taken 332191 times.
✓ Branch 1 taken 16891 times.
|
349082 | if (right) { |
373 | 332191 | pos += width << sh; | |
374 | 332191 | src_idx = (CTB(s->sao, x_ctb+1, y_ctb-1).type_idx[c_idx] == | |
375 | SAO_APPLIED); | ||
376 | 332191 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); | |
377 | } | ||
378 | } | ||
379 |
2/2✓ Branch 0 taken 345176 times.
✓ Branch 1 taken 29633 times.
|
374809 | if (!bottom_edge) { |
380 | 345176 | int left = 1 - left_edge; | |
381 | 345176 | int right = 1 - right_edge; | |
382 | const uint8_t *src1[2]; | ||
383 | uint8_t *dst1; | ||
384 | int src_idx, pos; | ||
385 | |||
386 | 345176 | dst1 = dst + height * stride_dst - (left << sh); | |
387 | 345176 | src1[0] = src + height * stride_src - (left << sh); | |
388 | 345176 | src1[1] = s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 2) * w + x0 - left) << sh); | |
389 | 345176 | pos = 0; | |
390 |
2/2✓ Branch 0 taken 329287 times.
✓ Branch 1 taken 15889 times.
|
345176 | if (left) { |
391 | 329287 | src_idx = (CTB(s->sao, x_ctb-1, y_ctb+1).type_idx[c_idx] == | |
392 | SAO_APPLIED); | ||
393 | 329287 | copy_pixel(dst1, src1[src_idx], sh); | |
394 | 329287 | pos += (1 << sh); | |
395 | } | ||
396 | 345176 | src_idx = (CTB(s->sao, x_ctb, y_ctb+1).type_idx[c_idx] == | |
397 | SAO_APPLIED); | ||
398 | 345176 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); | |
399 |
2/2✓ Branch 0 taken 328519 times.
✓ Branch 1 taken 16657 times.
|
345176 | if (right) { |
400 | 328519 | pos += width << sh; | |
401 | 328519 | src_idx = (CTB(s->sao, x_ctb+1, y_ctb+1).type_idx[c_idx] == | |
402 | SAO_APPLIED); | ||
403 | 328519 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); | |
404 | } | ||
405 | } | ||
406 | 374809 | left_pixels = 0; | |
407 |
2/2✓ Branch 0 taken 356355 times.
✓ Branch 1 taken 18454 times.
|
374809 | if (!left_edge) { |
408 |
2/2✓ Branch 0 taken 303830 times.
✓ Branch 1 taken 52525 times.
|
356355 | if (CTB(s->sao, x_ctb-1, y_ctb).type_idx[c_idx] == SAO_APPLIED) { |
409 | 303830 | copy_vert(dst - (1 << sh), | |
410 | 303830 | s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb - 1) * h + y0) << sh), | |
411 | 303830 | sh, height, stride_dst, 1 << sh); | |
412 | } else { | ||
413 | 52525 | left_pixels = 1; | |
414 | } | ||
415 | } | ||
416 | 374809 | right_pixels = 0; | |
417 |
2/2✓ Branch 0 taken 355806 times.
✓ Branch 1 taken 19003 times.
|
374809 | if (!right_edge) { |
418 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 355806 times.
|
355806 | if (CTB(s->sao, x_ctb+1, y_ctb).type_idx[c_idx] == SAO_APPLIED) { |
419 | ✗ | copy_vert(dst + (width << sh), | |
420 | ✗ | s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 2) * h + y0) << sh), | |
421 | ✗ | sh, height, stride_dst, 1 << sh); | |
422 | } else { | ||
423 | 355806 | right_pixels = 1; | |
424 | } | ||
425 | } | ||
426 | |||
427 | 374809 | copy_CTB(dst - (left_pixels << sh), | |
428 | 374809 | src - (left_pixels << sh), | |
429 | 374809 | (width + left_pixels + right_pixels) << sh, | |
430 | height, stride_dst, stride_src); | ||
431 | |||
432 | 374809 | copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx, | |
433 | x_ctb, y_ctb); | ||
434 | 374809 | s->hevcdsp.sao_edge_filter[tab](src, dst, stride_src, sao->offset_val[c_idx], | |
435 | sao->eo_class[c_idx], width, height); | ||
436 | 374809 | s->hevcdsp.sao_edge_restore[restore](src, dst, | |
437 | stride_src, stride_dst, | ||
438 | sao, | ||
439 | edges, width, | ||
440 | height, c_idx, | ||
441 | vert_edge, | ||
442 | horiz_edge, | ||
443 | diag_edge); | ||
444 | 374809 | restore_tqb_pixels(s, src, dst, stride_src, stride_dst, | |
445 | x, y, width, height, c_idx); | ||
446 | 374809 | sao->type_idx[c_idx] = SAO_APPLIED; | |
447 | 374809 | break; | |
448 | } | ||
449 | } | ||
450 | } | ||
451 | 1184633 | } | |
452 | |||
453 | 2057768 | static int get_pcm(HEVCContext *s, int x, int y) | |
454 | { | ||
455 | 2057768 | int log2_min_pu_size = s->ps.sps->log2_min_pu_size; | |
456 | int x_pu, y_pu; | ||
457 | |||
458 |
2/4✓ Branch 0 taken 2057768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2057768 times.
|
2057768 | if (x < 0 || y < 0) |
459 | ✗ | return 2; | |
460 | |||
461 | 2057768 | x_pu = x >> log2_min_pu_size; | |
462 | 2057768 | y_pu = y >> log2_min_pu_size; | |
463 | |||
464 |
3/4✓ Branch 0 taken 2057768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1408 times.
✓ Branch 3 taken 2056360 times.
|
2057768 | if (x_pu >= s->ps.sps->min_pu_width || y_pu >= s->ps.sps->min_pu_height) |
465 | 1408 | return 2; | |
466 | 2056360 | return s->is_pcm[y_pu * s->ps.sps->min_pu_width + x_pu]; | |
467 | } | ||
468 | |||
469 | #define TC_CALC(qp, bs) \ | ||
470 | tctable[av_clip((qp) + DEFAULT_INTRA_TC_OFFSET * ((bs) - 1) + \ | ||
471 | (tc_offset & -2), \ | ||
472 | 0, MAX_QP + DEFAULT_INTRA_TC_OFFSET)] | ||
473 | |||
474 | 1401654 | static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0) | |
475 | { | ||
476 | uint8_t *src; | ||
477 | int x, y; | ||
478 | int chroma, beta; | ||
479 | int32_t c_tc[2], tc[2]; | ||
480 | 1401654 | uint8_t no_p[2] = { 0 }; | |
481 | 1401654 | uint8_t no_q[2] = { 0 }; | |
482 | |||
483 | 1401654 | int log2_ctb_size = s->ps.sps->log2_ctb_size; | |
484 | int x_end, x_end2, y_end; | ||
485 | 1401654 | int ctb_size = 1 << log2_ctb_size; | |
486 | 1401654 | int ctb = (x0 >> log2_ctb_size) + | |
487 | 1401654 | (y0 >> log2_ctb_size) * s->ps.sps->ctb_width; | |
488 | 1401654 | int cur_tc_offset = s->deblock[ctb].tc_offset; | |
489 | 1401654 | int cur_beta_offset = s->deblock[ctb].beta_offset; | |
490 | int left_tc_offset, left_beta_offset; | ||
491 | int tc_offset, beta_offset; | ||
492 | 2890689 | int pcmf = (s->ps.sps->pcm_enabled_flag && | |
493 |
4/4✓ Branch 0 taken 87381 times.
✓ Branch 1 taken 1314273 times.
✓ Branch 2 taken 87325 times.
✓ Branch 3 taken 56 times.
|
2803252 | s->ps.sps->pcm.loop_filter_disable_flag) || |
494 |
2/2✓ Branch 0 taken 4570 times.
✓ Branch 1 taken 1397028 times.
|
1401598 | s->ps.pps->transquant_bypass_enable_flag; |
495 | |||
496 |
2/2✓ Branch 0 taken 1328904 times.
✓ Branch 1 taken 72750 times.
|
1401654 | if (x0) { |
497 | 1328904 | left_tc_offset = s->deblock[ctb - 1].tc_offset; | |
498 | 1328904 | left_beta_offset = s->deblock[ctb - 1].beta_offset; | |
499 | } else { | ||
500 | 72750 | left_tc_offset = 0; | |
501 | 72750 | left_beta_offset = 0; | |
502 | } | ||
503 | |||
504 | 1401654 | x_end = x0 + ctb_size; | |
505 |
2/2✓ Branch 0 taken 25296 times.
✓ Branch 1 taken 1376358 times.
|
1401654 | if (x_end > s->ps.sps->width) |
506 | 25296 | x_end = s->ps.sps->width; | |
507 | 1401654 | y_end = y0 + ctb_size; | |
508 |
2/2✓ Branch 0 taken 95617 times.
✓ Branch 1 taken 1306037 times.
|
1401654 | if (y_end > s->ps.sps->height) |
509 | 95617 | y_end = s->ps.sps->height; | |
510 | |||
511 | 1401654 | tc_offset = cur_tc_offset; | |
512 | 1401654 | beta_offset = cur_beta_offset; | |
513 | |||
514 | 1401654 | x_end2 = x_end; | |
515 |
2/2✓ Branch 0 taken 1328905 times.
✓ Branch 1 taken 72749 times.
|
1401654 | if (x_end2 != s->ps.sps->width) |
516 | 1328905 | x_end2 -= 8; | |
517 |
2/2✓ Branch 0 taken 10060008 times.
✓ Branch 1 taken 1401654 times.
|
11461662 | for (y = y0; y < y_end; y += 8) { |
518 | // vertical filtering luma | ||
519 |
4/4✓ Branch 0 taken 9532825 times.
✓ Branch 1 taken 527183 times.
✓ Branch 2 taken 76387397 times.
✓ Branch 3 taken 10060008 times.
|
86447405 | for (x = x0 ? x0 : 8; x < x_end; x += 8) { |
520 | 76387397 | const int bs0 = s->vertical_bs[(x + y * s->bs_width) >> 2]; | |
521 | 76387397 | const int bs1 = s->vertical_bs[(x + (y + 4) * s->bs_width) >> 2]; | |
522 |
4/4✓ Branch 0 taken 59149119 times.
✓ Branch 1 taken 17238278 times.
✓ Branch 2 taken 89322 times.
✓ Branch 3 taken 59059797 times.
|
76387397 | if (bs0 || bs1) { |
523 | 17327600 | const int qp = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1; | |
524 | |||
525 | 17327600 | beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)]; | |
526 | |||
527 |
2/2✓ Branch 0 taken 17238278 times.
✓ Branch 1 taken 89322 times.
|
17327600 | tc[0] = bs0 ? TC_CALC(qp, bs0) : 0; |
528 |
2/2✓ Branch 0 taken 17231609 times.
✓ Branch 1 taken 95991 times.
|
17327600 | tc[1] = bs1 ? TC_CALC(qp, bs1) : 0; |
529 | 17327600 | src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->ps.sps->pixel_shift)]; | |
530 |
2/2✓ Branch 0 taken 186079 times.
✓ Branch 1 taken 17141521 times.
|
17327600 | if (pcmf) { |
531 | 186079 | no_p[0] = get_pcm(s, x - 1, y); | |
532 | 186079 | no_p[1] = get_pcm(s, x - 1, y + 4); | |
533 | 186079 | no_q[0] = get_pcm(s, x, y); | |
534 | 186079 | no_q[1] = get_pcm(s, x, y + 4); | |
535 | 186079 | s->hevcdsp.hevc_v_loop_filter_luma_c(src, | |
536 | 186079 | s->frame->linesize[LUMA], | |
537 | beta, tc, no_p, no_q); | ||
538 | } else | ||
539 | 17141521 | s->hevcdsp.hevc_v_loop_filter_luma(src, | |
540 | 17141521 | s->frame->linesize[LUMA], | |
541 | beta, tc, no_p, no_q); | ||
542 | } | ||
543 | } | ||
544 | |||
545 |
2/2✓ Branch 0 taken 118364 times.
✓ Branch 1 taken 9941644 times.
|
10060008 | if(!y) |
546 | 118364 | continue; | |
547 | |||
548 | // horizontal filtering luma | ||
549 |
4/4✓ Branch 0 taken 9423945 times.
✓ Branch 1 taken 517699 times.
✓ Branch 2 taken 76047439 times.
✓ Branch 3 taken 9941644 times.
|
85989083 | for (x = x0 ? x0 - 8 : 0; x < x_end2; x += 8) { |
550 | 76047439 | const int bs0 = s->horizontal_bs[( x + y * s->bs_width) >> 2]; | |
551 | 76047439 | const int bs1 = s->horizontal_bs[((x + 4) + y * s->bs_width) >> 2]; | |
552 |
4/4✓ Branch 0 taken 58494010 times.
✓ Branch 1 taken 17553429 times.
✓ Branch 2 taken 105984 times.
✓ Branch 3 taken 58388026 times.
|
76047439 | if (bs0 || bs1) { |
553 | 17659413 | const int qp = (get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1; | |
554 | |||
555 |
2/2✓ Branch 0 taken 15452975 times.
✓ Branch 1 taken 2206438 times.
|
17659413 | tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset; |
556 |
2/2✓ Branch 0 taken 15452975 times.
✓ Branch 1 taken 2206438 times.
|
17659413 | beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset; |
557 | |||
558 | 17659413 | beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)]; | |
559 |
2/2✓ Branch 0 taken 17553429 times.
✓ Branch 1 taken 105984 times.
|
17659413 | tc[0] = bs0 ? TC_CALC(qp, bs0) : 0; |
560 |
2/2✓ Branch 0 taken 17538719 times.
✓ Branch 1 taken 120694 times.
|
17659413 | tc[1] = bs1 ? TC_CALC(qp, bs1) : 0; |
561 | 17659413 | src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->ps.sps->pixel_shift)]; | |
562 |
2/2✓ Branch 0 taken 187803 times.
✓ Branch 1 taken 17471610 times.
|
17659413 | if (pcmf) { |
563 | 187803 | no_p[0] = get_pcm(s, x, y - 1); | |
564 | 187803 | no_p[1] = get_pcm(s, x + 4, y - 1); | |
565 | 187803 | no_q[0] = get_pcm(s, x, y); | |
566 | 187803 | no_q[1] = get_pcm(s, x + 4, y); | |
567 | 187803 | s->hevcdsp.hevc_h_loop_filter_luma_c(src, | |
568 | 187803 | s->frame->linesize[LUMA], | |
569 | beta, tc, no_p, no_q); | ||
570 | } else | ||
571 | 17471610 | s->hevcdsp.hevc_h_loop_filter_luma(src, | |
572 | 17471610 | s->frame->linesize[LUMA], | |
573 | beta, tc, no_p, no_q); | ||
574 | } | ||
575 | } | ||
576 | } | ||
577 | |||
578 |
2/2✓ Branch 0 taken 1401606 times.
✓ Branch 1 taken 48 times.
|
1401654 | if (s->ps.sps->chroma_format_idc) { |
579 |
2/2✓ Branch 0 taken 2803212 times.
✓ Branch 1 taken 1401606 times.
|
4204818 | for (chroma = 1; chroma <= 2; chroma++) { |
580 | 2803212 | int h = 1 << s->ps.sps->hshift[chroma]; | |
581 | 2803212 | int v = 1 << s->ps.sps->vshift[chroma]; | |
582 | |||
583 | // vertical filtering chroma | ||
584 |
2/2✓ Branch 0 taken 10532816 times.
✓ Branch 1 taken 2803212 times.
|
13336028 | for (y = y0; y < y_end; y += (8 * v)) { |
585 |
4/4✓ Branch 0 taken 540448 times.
✓ Branch 1 taken 9992368 times.
✓ Branch 2 taken 40574494 times.
✓ Branch 3 taken 10532816 times.
|
51107310 | for (x = x0 ? x0 : 8 * h; x < x_end; x += (8 * h)) { |
586 | 40574494 | const int bs0 = s->vertical_bs[(x + y * s->bs_width) >> 2]; | |
587 | 40574494 | const int bs1 = s->vertical_bs[(x + (y + (4 * v)) * s->bs_width) >> 2]; | |
588 | |||
589 |
4/4✓ Branch 0 taken 34983978 times.
✓ Branch 1 taken 5590516 times.
✓ Branch 2 taken 128404 times.
✓ Branch 3 taken 34855574 times.
|
40574494 | if ((bs0 == 2) || (bs1 == 2)) { |
590 | 5718920 | const int qp0 = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1; | |
591 | 5718920 | const int qp1 = (get_qPy(s, x - 1, y + (4 * v)) + get_qPy(s, x, y + (4 * v)) + 1) >> 1; | |
592 | |||
593 |
2/2✓ Branch 0 taken 5590516 times.
✓ Branch 1 taken 128404 times.
|
5718920 | c_tc[0] = (bs0 == 2) ? chroma_tc(s, qp0, chroma, tc_offset) : 0; |
594 |
2/2✓ Branch 0 taken 5586248 times.
✓ Branch 1 taken 132672 times.
|
5718920 | c_tc[1] = (bs1 == 2) ? chroma_tc(s, qp1, chroma, tc_offset) : 0; |
595 | 5718920 | src = &s->frame->data[chroma][(y >> s->ps.sps->vshift[chroma]) * s->frame->linesize[chroma] + ((x >> s->ps.sps->hshift[chroma]) << s->ps.sps->pixel_shift)]; | |
596 |
2/2✓ Branch 0 taken 70838 times.
✓ Branch 1 taken 5648082 times.
|
5718920 | if (pcmf) { |
597 | 70838 | no_p[0] = get_pcm(s, x - 1, y); | |
598 | 70838 | no_p[1] = get_pcm(s, x - 1, y + (4 * v)); | |
599 | 70838 | no_q[0] = get_pcm(s, x, y); | |
600 | 70838 | no_q[1] = get_pcm(s, x, y + (4 * v)); | |
601 | 70838 | s->hevcdsp.hevc_v_loop_filter_chroma_c(src, | |
602 | 70838 | s->frame->linesize[chroma], | |
603 | c_tc, no_p, no_q); | ||
604 | } else | ||
605 | 5648082 | s->hevcdsp.hevc_v_loop_filter_chroma(src, | |
606 | 5648082 | s->frame->linesize[chroma], | |
607 | c_tc, no_p, no_q); | ||
608 | } | ||
609 | } | ||
610 | |||
611 |
2/2✓ Branch 0 taken 236704 times.
✓ Branch 1 taken 10296112 times.
|
10532816 | if(!y) |
612 | 236704 | continue; | |
613 | |||
614 | // horizontal filtering chroma | ||
615 |
2/2✓ Branch 0 taken 9774628 times.
✓ Branch 1 taken 521484 times.
|
10296112 | tc_offset = x0 ? left_tc_offset : cur_tc_offset; |
616 | 10296112 | x_end2 = x_end; | |
617 |
2/2✓ Branch 0 taken 9774636 times.
✓ Branch 1 taken 521476 times.
|
10296112 | if (x_end != s->ps.sps->width) |
618 | 9774636 | x_end2 = x_end - 8 * h; | |
619 |
4/4✓ Branch 0 taken 9774628 times.
✓ Branch 1 taken 521484 times.
✓ Branch 2 taken 40241214 times.
✓ Branch 3 taken 10296112 times.
|
50537326 | for (x = x0 ? x0 - 8 * h : 0; x < x_end2; x += (8 * h)) { |
620 | 40241214 | const int bs0 = s->horizontal_bs[( x + y * s->bs_width) >> 2]; | |
621 | 40241214 | const int bs1 = s->horizontal_bs[((x + 4 * h) + y * s->bs_width) >> 2]; | |
622 |
4/4✓ Branch 0 taken 34949422 times.
✓ Branch 1 taken 5291792 times.
✓ Branch 2 taken 133752 times.
✓ Branch 3 taken 34815670 times.
|
40241214 | if ((bs0 == 2) || (bs1 == 2)) { |
623 |
2/2✓ Branch 0 taken 5291792 times.
✓ Branch 1 taken 133752 times.
|
5425544 | const int qp0 = bs0 == 2 ? (get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1 : 0; |
624 |
2/2✓ Branch 0 taken 5290200 times.
✓ Branch 1 taken 135344 times.
|
5425544 | const int qp1 = bs1 == 2 ? (get_qPy(s, x + (4 * h), y - 1) + get_qPy(s, x + (4 * h), y) + 1) >> 1 : 0; |
625 | |||
626 |
2/2✓ Branch 0 taken 5291792 times.
✓ Branch 1 taken 133752 times.
|
5425544 | c_tc[0] = bs0 == 2 ? chroma_tc(s, qp0, chroma, tc_offset) : 0; |
627 |
2/2✓ Branch 0 taken 5290200 times.
✓ Branch 1 taken 135344 times.
|
5425544 | c_tc[1] = bs1 == 2 ? chroma_tc(s, qp1, chroma, cur_tc_offset) : 0; |
628 | 5425544 | src = &s->frame->data[chroma][(y >> s->ps.sps->vshift[1]) * s->frame->linesize[chroma] + ((x >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)]; | |
629 |
2/2✓ Branch 0 taken 69722 times.
✓ Branch 1 taken 5355822 times.
|
5425544 | if (pcmf) { |
630 | 69722 | no_p[0] = get_pcm(s, x, y - 1); | |
631 | 69722 | no_p[1] = get_pcm(s, x + (4 * h), y - 1); | |
632 | 69722 | no_q[0] = get_pcm(s, x, y); | |
633 | 69722 | no_q[1] = get_pcm(s, x + (4 * h), y); | |
634 | 69722 | s->hevcdsp.hevc_h_loop_filter_chroma_c(src, | |
635 | 69722 | s->frame->linesize[chroma], | |
636 | c_tc, no_p, no_q); | ||
637 | } else | ||
638 | 5355822 | s->hevcdsp.hevc_h_loop_filter_chroma(src, | |
639 | 5355822 | s->frame->linesize[chroma], | |
640 | c_tc, no_p, no_q); | ||
641 | } | ||
642 | } | ||
643 | } | ||
644 | } | ||
645 | } | ||
646 | 1401654 | } | |
647 | |||
648 | 226767198 | static int boundary_strength(HEVCContext *s, MvField *curr, MvField *neigh, | |
649 | RefPicList *neigh_refPicList) | ||
650 | { | ||
651 |
4/4✓ Branch 0 taken 144855024 times.
✓ Branch 1 taken 81912174 times.
✓ Branch 2 taken 140524332 times.
✓ Branch 3 taken 4330692 times.
|
226767198 | if (curr->pred_flag == PF_BI && neigh->pred_flag == PF_BI) { |
652 | // same L0 and L1 | ||
653 |
2/2✓ Branch 0 taken 138826193 times.
✓ Branch 1 taken 1698139 times.
|
140524332 | if (s->ref->refPicList[0].list[curr->ref_idx[0]] == neigh_refPicList[0].list[neigh->ref_idx[0]] && |
654 |
2/2✓ Branch 0 taken 18325892 times.
✓ Branch 1 taken 120500301 times.
|
138826193 | s->ref->refPicList[0].list[curr->ref_idx[0]] == s->ref->refPicList[1].list[curr->ref_idx[1]] && |
655 |
2/2✓ Branch 0 taken 18187439 times.
✓ Branch 1 taken 138453 times.
|
18325892 | neigh_refPicList[0].list[neigh->ref_idx[0]] == neigh_refPicList[1].list[neigh->ref_idx[1]]) { |
656 |
4/4✓ Branch 0 taken 17897806 times.
✓ Branch 1 taken 289633 times.
✓ Branch 2 taken 17826743 times.
✓ Branch 3 taken 71063 times.
|
18187439 | if ((FFABS(neigh->mv[0].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 4 || |
657 |
4/4✓ Branch 0 taken 17767568 times.
✓ Branch 1 taken 59175 times.
✓ Branch 2 taken 13332 times.
✓ Branch 3 taken 17754236 times.
|
17826743 | FFABS(neigh->mv[1].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 4) && |
658 |
4/4✓ Branch 0 taken 180411 times.
✓ Branch 1 taken 252792 times.
✓ Branch 2 taken 119748 times.
✓ Branch 3 taken 60663 times.
|
433203 | (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 4 || |
659 |
4/4✓ Branch 0 taken 45021 times.
✓ Branch 1 taken 74727 times.
✓ Branch 2 taken 22061 times.
✓ Branch 3 taken 22960 times.
|
119748 | FFABS(neigh->mv[0].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[1].y) >= 4)) |
660 | 410243 | return 1; | |
661 | else | ||
662 | 17777196 | return 0; | |
663 |
2/2✓ Branch 0 taken 120638754 times.
✓ Branch 1 taken 1698139 times.
|
122336893 | } else if (neigh_refPicList[0].list[neigh->ref_idx[0]] == s->ref->refPicList[0].list[curr->ref_idx[0]] && |
664 |
2/2✓ Branch 0 taken 120062401 times.
✓ Branch 1 taken 576353 times.
|
120638754 | neigh_refPicList[1].list[neigh->ref_idx[1]] == s->ref->refPicList[1].list[curr->ref_idx[1]]) { |
665 |
4/4✓ Branch 0 taken 116459015 times.
✓ Branch 1 taken 3603386 times.
✓ Branch 2 taken 115602363 times.
✓ Branch 3 taken 856652 times.
|
120062401 | if (FFABS(neigh->mv[0].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 4 || |
666 |
4/4✓ Branch 0 taken 115129399 times.
✓ Branch 1 taken 472964 times.
✓ Branch 2 taken 149713 times.
✓ Branch 3 taken 114979686 times.
|
115602363 | FFABS(neigh->mv[1].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 4) |
667 | 5082715 | return 1; | |
668 | else | ||
669 | 114979686 | return 0; | |
670 |
2/2✓ Branch 0 taken 704498 times.
✓ Branch 1 taken 1569994 times.
|
2274492 | } else if (neigh_refPicList[1].list[neigh->ref_idx[1]] == s->ref->refPicList[0].list[curr->ref_idx[0]] && |
671 |
2/2✓ Branch 0 taken 151937 times.
✓ Branch 1 taken 552561 times.
|
704498 | neigh_refPicList[0].list[neigh->ref_idx[0]] == s->ref->refPicList[1].list[curr->ref_idx[1]]) { |
672 |
4/4✓ Branch 0 taken 100560 times.
✓ Branch 1 taken 51377 times.
✓ Branch 2 taken 88008 times.
✓ Branch 3 taken 12552 times.
|
151937 | if (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 4 || |
673 |
4/4✓ Branch 0 taken 80010 times.
✓ Branch 1 taken 7998 times.
✓ Branch 2 taken 2920 times.
✓ Branch 3 taken 77090 times.
|
88008 | FFABS(neigh->mv[0].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[1].y) >= 4) |
674 | 74847 | return 1; | |
675 | else | ||
676 | 77090 | return 0; | |
677 | } else { | ||
678 | 2122555 | return 1; | |
679 | } | ||
680 |
4/4✓ Branch 0 taken 81912174 times.
✓ Branch 1 taken 4330692 times.
✓ Branch 2 taken 77605507 times.
✓ Branch 3 taken 4306667 times.
|
86242866 | } else if ((curr->pred_flag != PF_BI) && (neigh->pred_flag != PF_BI)){ // 1 MV |
681 | Mv A, B; | ||
682 | int ref_A, ref_B; | ||
683 | |||
684 |
2/2✓ Branch 0 taken 66207074 times.
✓ Branch 1 taken 11398433 times.
|
77605507 | if (curr->pred_flag & 1) { |
685 | 66207074 | A = curr->mv[0]; | |
686 | 66207074 | ref_A = s->ref->refPicList[0].list[curr->ref_idx[0]]; | |
687 | } else { | ||
688 | 11398433 | A = curr->mv[1]; | |
689 | 11398433 | ref_A = s->ref->refPicList[1].list[curr->ref_idx[1]]; | |
690 | } | ||
691 | |||
692 |
2/2✓ Branch 0 taken 66222013 times.
✓ Branch 1 taken 11383494 times.
|
77605507 | if (neigh->pred_flag & 1) { |
693 | 66222013 | B = neigh->mv[0]; | |
694 | 66222013 | ref_B = neigh_refPicList[0].list[neigh->ref_idx[0]]; | |
695 | } else { | ||
696 | 11383494 | B = neigh->mv[1]; | |
697 | 11383494 | ref_B = neigh_refPicList[1].list[neigh->ref_idx[1]]; | |
698 | } | ||
699 | |||
700 |
2/2✓ Branch 0 taken 73930099 times.
✓ Branch 1 taken 3675408 times.
|
77605507 | if (ref_A == ref_B) { |
701 |
4/4✓ Branch 0 taken 72078188 times.
✓ Branch 1 taken 1851911 times.
✓ Branch 2 taken 622011 times.
✓ Branch 3 taken 71456177 times.
|
73930099 | if (FFABS(A.x - B.x) >= 4 || FFABS(A.y - B.y) >= 4) |
702 | 2473922 | return 1; | |
703 | else | ||
704 | 71456177 | return 0; | |
705 | } else | ||
706 | 3675408 | return 1; | |
707 | } | ||
708 | |||
709 | 8637359 | return 1; | |
710 | } | ||
711 | |||
712 | 19678541 | void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, | |
713 | int log2_trafo_size) | ||
714 | { | ||
715 | 19678541 | HEVCLocalContext *lc = s->HEVClc; | |
716 | 19678541 | MvField *tab_mvf = s->ref->tab_mvf; | |
717 | 19678541 | int log2_min_pu_size = s->ps.sps->log2_min_pu_size; | |
718 | 19678541 | int log2_min_tu_size = s->ps.sps->log2_min_tb_size; | |
719 | 19678541 | int min_pu_width = s->ps.sps->min_pu_width; | |
720 | 19678541 | int min_tu_width = s->ps.sps->min_tb_width; | |
721 | 19678541 | int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width + | |
722 | 19678541 | (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA; | |
723 | int boundary_upper, boundary_left; | ||
724 | int i, j, bs; | ||
725 | |||
726 |
4/4✓ Branch 0 taken 19382088 times.
✓ Branch 1 taken 296453 times.
✓ Branch 2 taken 15264706 times.
✓ Branch 3 taken 4117382 times.
|
19678541 | boundary_upper = y0 > 0 && !(y0 & 7); |
727 |
2/2✓ Branch 0 taken 15264706 times.
✓ Branch 1 taken 4413835 times.
|
19678541 | if (boundary_upper && |
728 |
2/2✓ Branch 0 taken 1999846 times.
✓ Branch 1 taken 13264860 times.
|
15264706 | ((!s->sh.slice_loop_filter_across_slices_enabled_flag && |
729 |
2/2✓ Branch 0 taken 501429 times.
✓ Branch 1 taken 1498417 times.
|
1999846 | lc->boundary_flags & BOUNDARY_UPPER_SLICE && |
730 |
2/2✓ Branch 0 taken 440329 times.
✓ Branch 1 taken 61100 times.
|
501429 | (y0 % (1 << s->ps.sps->log2_ctb_size)) == 0) || |
731 |
2/2✓ Branch 0 taken 429711 times.
✓ Branch 1 taken 14773895 times.
|
15203606 | (!s->ps.pps->loop_filter_across_tiles_enabled_flag && |
732 |
2/2✓ Branch 0 taken 114253 times.
✓ Branch 1 taken 315458 times.
|
429711 | lc->boundary_flags & BOUNDARY_UPPER_TILE && |
733 |
2/2✓ Branch 0 taken 19889 times.
✓ Branch 1 taken 94364 times.
|
114253 | (y0 % (1 << s->ps.sps->log2_ctb_size)) == 0))) |
734 | 80989 | boundary_upper = 0; | |
735 | |||
736 |
2/2✓ Branch 0 taken 15183717 times.
✓ Branch 1 taken 4494824 times.
|
19678541 | if (boundary_upper) { |
737 | 30367434 | RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ? | |
738 |
2/2✓ Branch 0 taken 2095047 times.
✓ Branch 1 taken 13088670 times.
|
15183717 | ff_hevc_get_ref_list(s, s->ref, x0, y0 - 1) : |
739 | 13088670 | s->ref->refPicList; | |
740 | 15183717 | int yp_pu = (y0 - 1) >> log2_min_pu_size; | |
741 | 15183717 | int yq_pu = y0 >> log2_min_pu_size; | |
742 | 15183717 | int yp_tu = (y0 - 1) >> log2_min_tu_size; | |
743 | 15183717 | int yq_tu = y0 >> log2_min_tu_size; | |
744 | |||
745 |
2/2✓ Branch 0 taken 47530150 times.
✓ Branch 1 taken 15183717 times.
|
62713867 | for (i = 0; i < (1 << log2_trafo_size); i += 4) { |
746 | 47530150 | int x_pu = (x0 + i) >> log2_min_pu_size; | |
747 | 47530150 | int x_tu = (x0 + i) >> log2_min_tu_size; | |
748 | 47530150 | MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; | |
749 | 47530150 | MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; | |
750 | 47530150 | uint8_t top_cbf_luma = s->cbf_luma[yp_tu * min_tu_width + x_tu]; | |
751 | 47530150 | uint8_t curr_cbf_luma = s->cbf_luma[yq_tu * min_tu_width + x_tu]; | |
752 | |||
753 |
4/4✓ Branch 0 taken 34820640 times.
✓ Branch 1 taken 12709510 times.
✓ Branch 2 taken 1216688 times.
✓ Branch 3 taken 33603952 times.
|
47530150 | if (curr->pred_flag == PF_INTRA || top->pred_flag == PF_INTRA) |
754 | 13926198 | bs = 2; | |
755 |
4/4✓ Branch 0 taken 26773705 times.
✓ Branch 1 taken 6830247 times.
✓ Branch 2 taken 2729887 times.
✓ Branch 3 taken 24043818 times.
|
33603952 | else if (curr_cbf_luma || top_cbf_luma) |
756 | 9560134 | bs = 1; | |
757 | else | ||
758 | 24043818 | bs = boundary_strength(s, curr, top, rpl_top); | |
759 | 47530150 | s->horizontal_bs[((x0 + i) + y0 * s->bs_width) >> 2] = bs; | |
760 | } | ||
761 | } | ||
762 | |||
763 | // bs for vertical TU boundaries | ||
764 |
4/4✓ Branch 0 taken 19480939 times.
✓ Branch 1 taken 197602 times.
✓ Branch 2 taken 15363557 times.
✓ Branch 3 taken 4117382 times.
|
19678541 | boundary_left = x0 > 0 && !(x0 & 7); |
765 |
2/2✓ Branch 0 taken 15363557 times.
✓ Branch 1 taken 4314984 times.
|
19678541 | if (boundary_left && |
766 |
2/2✓ Branch 0 taken 2020355 times.
✓ Branch 1 taken 13343202 times.
|
15363557 | ((!s->sh.slice_loop_filter_across_slices_enabled_flag && |
767 |
2/2✓ Branch 0 taken 68545 times.
✓ Branch 1 taken 1951810 times.
|
2020355 | lc->boundary_flags & BOUNDARY_LEFT_SLICE && |
768 |
2/2✓ Branch 0 taken 59894 times.
✓ Branch 1 taken 8651 times.
|
68545 | (x0 % (1 << s->ps.sps->log2_ctb_size)) == 0) || |
769 |
2/2✓ Branch 0 taken 441443 times.
✓ Branch 1 taken 14913463 times.
|
15354906 | (!s->ps.pps->loop_filter_across_tiles_enabled_flag && |
770 |
2/2✓ Branch 0 taken 59900 times.
✓ Branch 1 taken 381543 times.
|
441443 | lc->boundary_flags & BOUNDARY_LEFT_TILE && |
771 |
2/2✓ Branch 0 taken 13608 times.
✓ Branch 1 taken 46292 times.
|
59900 | (x0 % (1 << s->ps.sps->log2_ctb_size)) == 0))) |
772 | 22259 | boundary_left = 0; | |
773 | |||
774 |
2/2✓ Branch 0 taken 15341298 times.
✓ Branch 1 taken 4337243 times.
|
19678541 | if (boundary_left) { |
775 | 30682596 | RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ? | |
776 |
2/2✓ Branch 0 taken 245689 times.
✓ Branch 1 taken 15095609 times.
|
15341298 | ff_hevc_get_ref_list(s, s->ref, x0 - 1, y0) : |
777 | 15095609 | s->ref->refPicList; | |
778 | 15341298 | int xp_pu = (x0 - 1) >> log2_min_pu_size; | |
779 | 15341298 | int xq_pu = x0 >> log2_min_pu_size; | |
780 | 15341298 | int xp_tu = (x0 - 1) >> log2_min_tu_size; | |
781 | 15341298 | int xq_tu = x0 >> log2_min_tu_size; | |
782 | |||
783 |
2/2✓ Branch 0 taken 48483764 times.
✓ Branch 1 taken 15341298 times.
|
63825062 | for (i = 0; i < (1 << log2_trafo_size); i += 4) { |
784 | 48483764 | int y_pu = (y0 + i) >> log2_min_pu_size; | |
785 | 48483764 | int y_tu = (y0 + i) >> log2_min_tu_size; | |
786 | 48483764 | MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; | |
787 | 48483764 | MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; | |
788 | 48483764 | uint8_t left_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xp_tu]; | |
789 | 48483764 | uint8_t curr_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xq_tu]; | |
790 | |||
791 |
4/4✓ Branch 0 taken 35697452 times.
✓ Branch 1 taken 12786312 times.
✓ Branch 2 taken 1348922 times.
✓ Branch 3 taken 34348530 times.
|
48483764 | if (curr->pred_flag == PF_INTRA || left->pred_flag == PF_INTRA) |
792 | 14135234 | bs = 2; | |
793 |
4/4✓ Branch 0 taken 27456125 times.
✓ Branch 1 taken 6892405 times.
✓ Branch 2 taken 2761305 times.
✓ Branch 3 taken 24694820 times.
|
34348530 | else if (curr_cbf_luma || left_cbf_luma) |
794 | 9653710 | bs = 1; | |
795 | else | ||
796 | 24694820 | bs = boundary_strength(s, curr, left, rpl_left); | |
797 | 48483764 | s->vertical_bs[(x0 + (y0 + i) * s->bs_width) >> 2] = bs; | |
798 | } | ||
799 | } | ||
800 | |||
801 |
4/4✓ Branch 0 taken 10135480 times.
✓ Branch 1 taken 9543061 times.
✓ Branch 2 taken 7309963 times.
✓ Branch 3 taken 2825517 times.
|
19678541 | if (log2_trafo_size > log2_min_pu_size && !is_intra) { |
802 | 7309963 | RefPicList *rpl = s->ref->refPicList; | |
803 | |||
804 | // bs for TU internal horizontal PU boundaries | ||
805 |
2/2✓ Branch 0 taken 9460067 times.
✓ Branch 1 taken 7309963 times.
|
16770030 | for (j = 8; j < (1 << log2_trafo_size); j += 8) { |
806 | 9460067 | int yp_pu = (y0 + j - 1) >> log2_min_pu_size; | |
807 | 9460067 | int yq_pu = (y0 + j) >> log2_min_pu_size; | |
808 | |||
809 |
2/2✓ Branch 0 taken 89014280 times.
✓ Branch 1 taken 9460067 times.
|
98474347 | for (i = 0; i < (1 << log2_trafo_size); i += 4) { |
810 | 89014280 | int x_pu = (x0 + i) >> log2_min_pu_size; | |
811 | 89014280 | MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; | |
812 | 89014280 | MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; | |
813 | |||
814 | 89014280 | bs = boundary_strength(s, curr, top, rpl); | |
815 | 89014280 | s->horizontal_bs[((x0 + i) + (y0 + j) * s->bs_width) >> 2] = bs; | |
816 | } | ||
817 | } | ||
818 | |||
819 | // bs for TU internal vertical PU boundaries | ||
820 |
2/2✓ Branch 0 taken 33540060 times.
✓ Branch 1 taken 7309963 times.
|
40850023 | for (j = 0; j < (1 << log2_trafo_size); j += 4) { |
821 | 33540060 | int y_pu = (y0 + j) >> log2_min_pu_size; | |
822 | |||
823 |
2/2✓ Branch 0 taken 89014280 times.
✓ Branch 1 taken 33540060 times.
|
122554340 | for (i = 8; i < (1 << log2_trafo_size); i += 8) { |
824 | 89014280 | int xp_pu = (x0 + i - 1) >> log2_min_pu_size; | |
825 | 89014280 | int xq_pu = (x0 + i) >> log2_min_pu_size; | |
826 | 89014280 | MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; | |
827 | 89014280 | MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; | |
828 | |||
829 | 89014280 | bs = boundary_strength(s, curr, left, rpl); | |
830 | 89014280 | s->vertical_bs[((x0 + i) + (y0 + j) * s->bs_width) >> 2] = bs; | |
831 | } | ||
832 | } | ||
833 | } | ||
834 | 19678541 | } | |
835 | |||
836 | #undef LUMA | ||
837 | #undef CB | ||
838 | #undef CR | ||
839 | |||
840 | 1403694 | void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size) | |
841 | { | ||
842 | 1403694 | int x_end = x >= s->ps.sps->width - ctb_size; | |
843 | 1403694 | int skip = 0; | |
844 |
1/2✓ Branch 0 taken 1403694 times.
✗ Branch 1 not taken.
|
1403694 | if (s->avctx->skip_loop_filter >= AVDISCARD_ALL || |
845 |
5/6✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 1400634 times.
✓ Branch 2 taken 2040 times.
✓ Branch 3 taken 1020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2040 times.
|
1403694 | (s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && !IS_IDR(s)) || |
846 |
2/2✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 1400634 times.
|
1401654 | (s->avctx->skip_loop_filter >= AVDISCARD_NONINTRA && |
847 |
1/2✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
|
1020 | s->sh.slice_type != HEVC_SLICE_I) || |
848 |
2/2✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 1400634 times.
|
1401654 | (s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && |
849 |
1/2✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
|
1020 | s->sh.slice_type == HEVC_SLICE_B) || |
850 |
3/4✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 1400634 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1020 times.
|
1402674 | (s->avctx->skip_loop_filter >= AVDISCARD_NONREF && |
851 | 1020 | ff_hevc_nal_is_nonref(s->nal_unit_type))) | |
852 | 2040 | skip = 1; | |
853 | |||
854 |
2/2✓ Branch 0 taken 1401654 times.
✓ Branch 1 taken 2040 times.
|
1403694 | if (!skip) |
855 | 1401654 | deblocking_filter_CTB(s, x, y); | |
856 |
4/4✓ Branch 0 taken 1186704 times.
✓ Branch 1 taken 216990 times.
✓ Branch 2 taken 1184664 times.
✓ Branch 3 taken 2040 times.
|
2588358 | if (s->ps.sps->sao_enabled && !skip) { |
857 | 1184664 | int y_end = y >= s->ps.sps->height - ctb_size; | |
858 |
4/4✓ Branch 0 taken 1081697 times.
✓ Branch 1 taken 102967 times.
✓ Branch 2 taken 1026608 times.
✓ Branch 3 taken 55089 times.
|
1184664 | if (y && x) |
859 | 1026608 | sao_filter_CTB(s, x - ctb_size, y - ctb_size); | |
860 |
4/4✓ Branch 0 taken 1120891 times.
✓ Branch 1 taken 63773 times.
✓ Branch 2 taken 94254 times.
✓ Branch 3 taken 1026637 times.
|
1184664 | if (x && y_end) |
861 | 94254 | sao_filter_CTB(s, x - ctb_size, y); | |
862 |
4/4✓ Branch 0 taken 1081697 times.
✓ Branch 1 taken 102967 times.
✓ Branch 2 taken 55088 times.
✓ Branch 3 taken 1026609 times.
|
1184664 | if (y && x_end) { |
863 | 55088 | sao_filter_CTB(s, x, y - ctb_size); | |
864 |
2/2✓ Branch 0 taken 497 times.
✓ Branch 1 taken 54591 times.
|
55088 | if (s->threads_type & FF_THREAD_FRAME ) |
865 | 497 | ff_thread_report_progress(&s->ref->tf, y, 0); | |
866 | } | ||
867 |
4/4✓ Branch 0 taken 63772 times.
✓ Branch 1 taken 1120892 times.
✓ Branch 2 taken 8683 times.
✓ Branch 3 taken 55089 times.
|
1184664 | if (x_end && y_end) { |
868 | 8683 | sao_filter_CTB(s, x , y); | |
869 |
2/2✓ Branch 0 taken 31 times.
✓ Branch 1 taken 8652 times.
|
8683 | if (s->threads_type & FF_THREAD_FRAME ) |
870 | 31 | ff_thread_report_progress(&s->ref->tf, y + ctb_size, 0); | |
871 | } | ||
872 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 219030 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
219030 | } else if (s->threads_type & FF_THREAD_FRAME && x_end) |
873 | ✗ | ff_thread_report_progress(&s->ref->tf, y + ctb_size - 4, 0); | |
874 | 1403694 | } | |
875 | |||
876 | 1403725 | void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size) | |
877 | { | ||
878 | 1403725 | int x_end = x_ctb >= s->ps.sps->width - ctb_size; | |
879 | 1403725 | int y_end = y_ctb >= s->ps.sps->height - ctb_size; | |
880 |
4/4✓ Branch 0 taken 1285241 times.
✓ Branch 1 taken 118484 times.
✓ Branch 2 taken 1221910 times.
✓ Branch 3 taken 63331 times.
|
1403725 | if (y_ctb && x_ctb) |
881 | 1221910 | ff_hevc_hls_filter(s, x_ctb - ctb_size, y_ctb - ctb_size, ctb_size); | |
882 |
4/4✓ Branch 0 taken 1285241 times.
✓ Branch 1 taken 118484 times.
✓ Branch 2 taken 63330 times.
✓ Branch 3 taken 1221911 times.
|
1403725 | if (y_ctb && x_end) |
883 | 63330 | ff_hevc_hls_filter(s, x_ctb, y_ctb - ctb_size, ctb_size); | |
884 |
4/4✓ Branch 0 taken 1330906 times.
✓ Branch 1 taken 72819 times.
✓ Branch 2 taken 108967 times.
✓ Branch 3 taken 1221939 times.
|
1403725 | if (x_ctb && y_end) |
885 | 108967 | ff_hevc_hls_filter(s, x_ctb - ctb_size, y_ctb, ctb_size); | |
886 | 1403725 | } | |
887 |