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 | 21949646 | static int chroma_tc(const 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 10974823 times.
✓ Branch 1 taken 10974823 times.
|
21949646 | if (c_idx == 1) |
56 | 10974823 | offset = s->ps.pps->cb_qp_offset; | |
57 | else | ||
58 | 10974823 | offset = s->ps.pps->cr_qp_offset; | |
59 | |||
60 | 21949646 | qp_i = av_clip(qp_y + offset, 0, 57); | |
61 |
2/2✓ Branch 0 taken 18469918 times.
✓ Branch 1 taken 3479728 times.
|
21949646 | if (s->ps.sps->chroma_format_idc == 1) { |
62 |
2/2✓ Branch 0 taken 3089925 times.
✓ Branch 1 taken 15379993 times.
|
18469918 | if (qp_i < 30) |
63 | 3089925 | qp = qp_i; | |
64 |
2/2✓ Branch 0 taken 153221 times.
✓ Branch 1 taken 15226772 times.
|
15379993 | else if (qp_i > 43) |
65 | 153221 | qp = qp_i - 6; | |
66 | else | ||
67 | 15226772 | qp = qp_c[qp_i - 30]; | |
68 | } else { | ||
69 | 3479728 | qp = av_clip(qp_i, 0, 51); | |
70 | } | ||
71 | |||
72 | 21949646 | idxt = av_clip(qp + DEFAULT_INTRA_TC_OFFSET + tc_offset, 0, 53); | |
73 | 21949646 | return tctable[idxt]; | |
74 | } | ||
75 | |||
76 | 1388429 | static int get_qPy_pred(HEVCLocalContext *lc, const HEVCContext *s, | |
77 | int xBase, int yBase, int log2_cb_size) | ||
78 | { | ||
79 | 1388429 | int ctb_size_mask = (1 << s->ps.sps->log2_ctb_size) - 1; | |
80 | 1388429 | int MinCuQpDeltaSizeMask = (1 << (s->ps.sps->log2_ctb_size - | |
81 | 1388429 | s->ps.pps->diff_cu_qp_delta_depth)) - 1; | |
82 | 1388429 | int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask); | |
83 | 1388429 | int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask); | |
84 | 1388429 | int min_cb_width = s->ps.sps->min_cb_width; | |
85 | 1388429 | int x_cb = xQgBase >> s->ps.sps->log2_min_cb_size; | |
86 | 1388429 | int y_cb = yQgBase >> s->ps.sps->log2_min_cb_size; | |
87 |
2/2✓ Branch 0 taken 946076 times.
✓ Branch 1 taken 442353 times.
|
2334505 | int availableA = (xBase & ctb_size_mask) && |
88 |
2/2✓ Branch 0 taken 808982 times.
✓ Branch 1 taken 137094 times.
|
946076 | (xQgBase & ctb_size_mask); |
89 |
2/2✓ Branch 0 taken 928403 times.
✓ Branch 1 taken 460026 times.
|
2316832 | int availableB = (yBase & ctb_size_mask) && |
90 |
2/2✓ Branch 0 taken 806801 times.
✓ Branch 1 taken 121602 times.
|
928403 | (yQgBase & ctb_size_mask); |
91 | int qPy_pred, qPy_a, qPy_b; | ||
92 | |||
93 | // qPy_pred | ||
94 |
5/6✓ Branch 0 taken 1300753 times.
✓ Branch 1 taken 87676 times.
✓ Branch 2 taken 18735 times.
✓ Branch 3 taken 1282018 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18735 times.
|
1388429 | if (lc->first_qp_group || (!xQgBase && !yQgBase)) { |
95 | 87676 | lc->first_qp_group = !lc->tu.is_cu_qp_delta_coded; | |
96 | 87676 | qPy_pred = s->sh.slice_qp; | |
97 | } else { | ||
98 | 1300753 | qPy_pred = lc->qPy_pred; | |
99 | } | ||
100 | |||
101 | // qPy_a | ||
102 |
2/2✓ Branch 0 taken 579447 times.
✓ Branch 1 taken 808982 times.
|
1388429 | if (availableA == 0) |
103 | 579447 | qPy_a = qPy_pred; | |
104 | else | ||
105 | 808982 | qPy_a = s->qp_y_tab[(x_cb - 1) + y_cb * min_cb_width]; | |
106 | |||
107 | // qPy_b | ||
108 |
2/2✓ Branch 0 taken 581628 times.
✓ Branch 1 taken 806801 times.
|
1388429 | if (availableB == 0) |
109 | 581628 | qPy_b = qPy_pred; | |
110 | else | ||
111 | 806801 | 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 | 1388429 | return (qPy_a + qPy_b + 1) >> 1; | |
117 | } | ||
118 | |||
119 | 1388429 | void ff_hevc_set_qPy(HEVCLocalContext *lc, int xBase, int yBase, int log2_cb_size) | |
120 | { | ||
121 | 1388429 | const HEVCContext *const s = lc->parent; | |
122 | 1388429 | int qp_y = get_qPy_pred(lc, s, xBase, yBase, log2_cb_size); | |
123 | |||
124 |
2/2✓ Branch 0 taken 369824 times.
✓ Branch 1 taken 1018605 times.
|
1388429 | if (lc->tu.cu_qp_delta != 0) { |
125 | 369824 | int off = s->ps.sps->qp_bd_offset; | |
126 |
1/2✓ Branch 0 taken 369824 times.
✗ Branch 1 not taken.
|
369824 | lc->qp_y = FFUMOD(qp_y + lc->tu.cu_qp_delta + 52 + 2 * off, |
127 | 369824 | 52 + off) - off; | |
128 | } else | ||
129 | 1018605 | lc->qp_y = qp_y; | |
130 | 1388429 | } | |
131 | |||
132 | 114741094 | static int get_qPy(const HEVCContext *s, int xC, int yC) | |
133 | { | ||
134 | 114741094 | int log2_min_cb_size = s->ps.sps->log2_min_cb_size; | |
135 | 114741094 | int x = xC >> log2_min_cb_size; | |
136 | 114741094 | int y = yC >> log2_min_cb_size; | |
137 | 114741094 | return s->qp_y_tab[x + y * s->ps.sps->min_cb_width]; | |
138 | } | ||
139 | |||
140 | 380584 | static void copy_CTB(uint8_t *dst, const uint8_t *src, int width, int height, | |
141 | ptrdiff_t stride_dst, ptrdiff_t stride_src) | ||
142 | { | ||
143 | int i, j; | ||
144 | |||
145 |
2/2✓ Branch 0 taken 55839 times.
✓ Branch 1 taken 324745 times.
|
380584 | if (((intptr_t)dst | (intptr_t)src | stride_dst | stride_src) & 15) { |
146 |
2/2✓ Branch 0 taken 2424664 times.
✓ Branch 1 taken 55839 times.
|
2480503 | for (i = 0; i < height; i++) { |
147 |
2/2✓ Branch 0 taken 16962448 times.
✓ Branch 1 taken 2424664 times.
|
19387112 | for (j = 0; j < width - 7; j+=8) |
148 | 16962448 | AV_COPY64U(dst+j, src+j); | |
149 | 2424664 | dst += stride_dst; | |
150 | 2424664 | src += stride_src; | |
151 | } | ||
152 |
2/2✓ Branch 0 taken 55639 times.
✓ Branch 1 taken 200 times.
|
55839 | if (width&7) { |
153 | 55639 | dst += ((width>>3)<<3) - stride_dst * height; | |
154 | 55639 | src += ((width>>3)<<3) - stride_src * height; | |
155 | 55639 | width &= 7; | |
156 |
2/2✓ Branch 0 taken 2423064 times.
✓ Branch 1 taken 55639 times.
|
2478703 | for (i = 0; i < height; i++) { |
157 |
2/2✓ Branch 0 taken 5291136 times.
✓ Branch 1 taken 2423064 times.
|
7714200 | for (j = 0; j < width; j++) |
158 | 5291136 | dst[j] = src[j]; | |
159 | 2423064 | dst += stride_dst; | |
160 | 2423064 | src += stride_src; | |
161 | } | ||
162 | } | ||
163 | } else { | ||
164 |
2/2✓ Branch 0 taken 17100104 times.
✓ Branch 1 taken 324745 times.
|
17424849 | for (i = 0; i < height; i++) { |
165 |
2/2✓ Branch 0 taken 86949840 times.
✓ Branch 1 taken 17100104 times.
|
104049944 | for (j = 0; j < width; j+=16) |
166 | 86949840 | AV_COPY128(dst+j, src+j); | |
167 | 17100104 | dst += stride_dst; | |
168 | 17100104 | src += stride_src; | |
169 | } | ||
170 | } | ||
171 | 380584 | } | |
172 | |||
173 | 1340747 | static void copy_pixel(uint8_t *dst, const uint8_t *src, int pixel_shift) | |
174 | { | ||
175 |
2/2✓ Branch 0 taken 222166 times.
✓ Branch 1 taken 1118581 times.
|
1340747 | if (pixel_shift) |
176 | 222166 | *(uint16_t *)dst = *(uint16_t *)src; | |
177 | else | ||
178 | 1118581 | *dst = *src; | |
179 | 1340747 | } | |
180 | |||
181 | 1290795 | static void copy_vert(uint8_t *dst, const uint8_t *src, | |
182 | int pixel_shift, int height, | ||
183 | ptrdiff_t stride_dst, ptrdiff_t stride_src) | ||
184 | { | ||
185 | int i; | ||
186 |
2/2✓ Branch 0 taken 1110523 times.
✓ Branch 1 taken 180272 times.
|
1290795 | if (pixel_shift == 0) { |
187 |
2/2✓ Branch 0 taken 52325936 times.
✓ Branch 1 taken 1110523 times.
|
53436459 | for (i = 0; i < height; i++) { |
188 | 52325936 | *dst = *src; | |
189 | 52325936 | dst += stride_dst; | |
190 | 52325936 | src += stride_src; | |
191 | } | ||
192 | } else { | ||
193 |
2/2✓ Branch 0 taken 11234032 times.
✓ Branch 1 taken 180272 times.
|
11414304 | for (i = 0; i < height; i++) { |
194 | 11234032 | *(uint16_t *)dst = *(uint16_t *)src; | |
195 | 11234032 | dst += stride_dst; | |
196 | 11234032 | src += stride_src; | |
197 | } | ||
198 | } | ||
199 | 1290795 | } | |
200 | |||
201 | 491477 | static void copy_CTB_to_hv(const HEVCContext *s, const uint8_t *src, | |
202 | ptrdiff_t stride_src, int x, int y, int width, int height, | ||
203 | int c_idx, int x_ctb, int y_ctb) | ||
204 | { | ||
205 | 491477 | int sh = s->ps.sps->pixel_shift; | |
206 | 491477 | int w = s->ps.sps->width >> s->ps.sps->hshift[c_idx]; | |
207 | 491477 | int h = s->ps.sps->height >> s->ps.sps->vshift[c_idx]; | |
208 | |||
209 | /* copy horizontal edges */ | ||
210 | 491477 | memcpy(s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb) * w + x) << sh), | |
211 | 491477 | src, width << sh); | |
212 | 491477 | memcpy(s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 1) * w + x) << sh), | |
213 | 491477 | src + stride_src * (height - 1), width << sh); | |
214 | |||
215 | /* copy vertical edges */ | ||
216 | 491477 | copy_vert(s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb) * h + y) << sh), src, sh, height, 1 << sh, stride_src); | |
217 | |||
218 | 491477 | 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); | |
219 | 491477 | } | |
220 | |||
221 | 380584 | static void restore_tqb_pixels(const HEVCContext *s, | |
222 | uint8_t *src1, const uint8_t *dst1, | ||
223 | ptrdiff_t stride_src, ptrdiff_t stride_dst, | ||
224 | int x0, int y0, int width, int height, int c_idx) | ||
225 | { | ||
226 |
2/2✓ Branch 0 taken 376295 times.
✓ Branch 1 taken 4289 times.
|
380584 | if ( s->ps.pps->transquant_bypass_enable_flag || |
227 |
3/4✓ Branch 0 taken 104 times.
✓ Branch 1 taken 376191 times.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
|
376295 | (s->ps.sps->pcm.loop_filter_disable_flag && s->ps.sps->pcm_enabled_flag)) { |
228 | int x, y; | ||
229 | 4393 | int min_pu_size = 1 << s->ps.sps->log2_min_pu_size; | |
230 | 4393 | int hshift = s->ps.sps->hshift[c_idx]; | |
231 | 4393 | int vshift = s->ps.sps->vshift[c_idx]; | |
232 | 4393 | int x_min = ((x0 ) >> s->ps.sps->log2_min_pu_size); | |
233 | 4393 | int y_min = ((y0 ) >> s->ps.sps->log2_min_pu_size); | |
234 | 4393 | int x_max = ((x0 + width ) >> s->ps.sps->log2_min_pu_size); | |
235 | 4393 | int y_max = ((y0 + height) >> s->ps.sps->log2_min_pu_size); | |
236 | 4393 | int len = (min_pu_size >> hshift) << s->ps.sps->pixel_shift; | |
237 |
2/2✓ Branch 0 taken 49472 times.
✓ Branch 1 taken 4393 times.
|
53865 | for (y = y_min; y < y_max; y++) { |
238 |
2/2✓ Branch 0 taken 632704 times.
✓ Branch 1 taken 49472 times.
|
682176 | for (x = x_min; x < x_max; x++) { |
239 |
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]) { |
240 | int n; | ||
241 | 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); | |
242 | 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); | |
243 |
2/2✓ Branch 0 taken 704 times.
✓ Branch 1 taken 264 times.
|
968 | for (n = 0; n < (min_pu_size >> vshift); n++) { |
244 | 704 | memcpy(src, dst, len); | |
245 | 704 | src += stride_src; | |
246 | 704 | dst += stride_dst; | |
247 | } | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | } | ||
252 | 380584 | } | |
253 | |||
254 | #define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)]) | ||
255 | |||
256 | 1194581 | static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, int x, int y) | |
257 | { | ||
258 | static const uint8_t sao_tab[8] = { 0, 1, 2, 2, 3, 3, 4, 4 }; | ||
259 | int c_idx; | ||
260 | int edges[4]; // 0 left 1 top 2 right 3 bottom | ||
261 | 1194581 | int x_ctb = x >> s->ps.sps->log2_ctb_size; | |
262 | 1194581 | int y_ctb = y >> s->ps.sps->log2_ctb_size; | |
263 | 1194581 | int ctb_addr_rs = y_ctb * s->ps.sps->ctb_width + x_ctb; | |
264 | 1194581 | int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs]; | |
265 | 1194581 | SAOParams *sao = &CTB(s->sao, x_ctb, y_ctb); | |
266 | // flags indicating unfilterable edges | ||
267 | 1194581 | uint8_t vert_edge[] = { 0, 0 }; | |
268 | 1194581 | uint8_t horiz_edge[] = { 0, 0 }; | |
269 | 1194581 | uint8_t diag_edge[] = { 0, 0, 0, 0 }; | |
270 | 1194581 | uint8_t lfase = CTB(s->filter_slice_edges, x_ctb, y_ctb); | |
271 |
2/2✓ Branch 0 taken 170200 times.
✓ Branch 1 taken 1024381 times.
|
1364781 | uint8_t no_tile_filter = s->ps.pps->tiles_enabled_flag && |
272 |
2/2✓ Branch 0 taken 16664 times.
✓ Branch 1 taken 153536 times.
|
170200 | !s->ps.pps->loop_filter_across_tiles_enabled_flag; |
273 |
4/4✓ Branch 0 taken 1177917 times.
✓ Branch 1 taken 16664 times.
✓ Branch 2 taken 51490 times.
✓ Branch 3 taken 1126427 times.
|
1194581 | uint8_t restore = no_tile_filter || !lfase; |
274 | 1194581 | uint8_t left_tile_edge = 0; | |
275 | 1194581 | uint8_t right_tile_edge = 0; | |
276 | 1194581 | uint8_t up_tile_edge = 0; | |
277 | 1194581 | uint8_t bottom_tile_edge = 0; | |
278 | |||
279 | 1194581 | edges[0] = x_ctb == 0; | |
280 | 1194581 | edges[1] = y_ctb == 0; | |
281 | 1194581 | edges[2] = x_ctb == s->ps.sps->ctb_width - 1; | |
282 | 1194581 | edges[3] = y_ctb == s->ps.sps->ctb_height - 1; | |
283 | |||
284 |
2/2✓ Branch 0 taken 68154 times.
✓ Branch 1 taken 1126427 times.
|
1194581 | if (restore) { |
285 |
2/2✓ Branch 0 taken 64585 times.
✓ Branch 1 taken 3569 times.
|
68154 | if (!edges[0]) { |
286 |
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]]; |
287 |
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; |
288 | } | ||
289 |
2/2✓ Branch 0 taken 64586 times.
✓ Branch 1 taken 3568 times.
|
68154 | if (!edges[2]) { |
290 |
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]]; |
291 |
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; |
292 | } | ||
293 |
2/2✓ Branch 0 taken 61940 times.
✓ Branch 1 taken 6214 times.
|
68154 | if (!edges[1]) { |
294 |
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]]; |
295 |
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; |
296 | } | ||
297 |
2/2✓ Branch 0 taken 61970 times.
✓ Branch 1 taken 6184 times.
|
68154 | if (!edges[3]) { |
298 |
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]]; |
299 |
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; |
300 | } | ||
301 |
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]) { |
302 |
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; |
303 | } | ||
304 |
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]) { |
305 |
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; |
306 | } | ||
307 |
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]) { |
308 |
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; |
309 | } | ||
310 |
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]) { |
311 |
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; |
312 | } | ||
313 | } | ||
314 | |||
315 |
4/4✓ Branch 0 taken 4778132 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 3583647 times.
✓ Branch 3 taken 1194581 times.
|
4778228 | for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) { |
316 | 3583647 | int x0 = x >> s->ps.sps->hshift[c_idx]; | |
317 | 3583647 | int y0 = y >> s->ps.sps->vshift[c_idx]; | |
318 | 3583647 | ptrdiff_t stride_src = s->frame->linesize[c_idx]; | |
319 | 3583647 | int ctb_size_h = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->hshift[c_idx]; | |
320 | 3583647 | int ctb_size_v = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->vshift[c_idx]; | |
321 | 3583647 | int width = FFMIN(ctb_size_h, (s->ps.sps->width >> s->ps.sps->hshift[c_idx]) - x0); | |
322 | 3583647 | int height = FFMIN(ctb_size_v, (s->ps.sps->height >> s->ps.sps->vshift[c_idx]) - y0); | |
323 | 3583647 | int tab = sao_tab[(FFALIGN(width, 8) >> 3) - 1]; | |
324 | 3583647 | uint8_t *src = &s->frame->data[c_idx][y0 * stride_src + (x0 << s->ps.sps->pixel_shift)]; | |
325 | ptrdiff_t stride_dst; | ||
326 | uint8_t *dst; | ||
327 | |||
328 |
3/3✓ Branch 0 taken 111662 times.
✓ Branch 1 taken 379815 times.
✓ Branch 2 taken 3092170 times.
|
3583647 | switch (sao->type_idx[c_idx]) { |
329 | 111662 | case SAO_BAND: | |
330 | 111662 | copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx, | |
331 | x_ctb, y_ctb); | ||
332 |
2/2✓ Branch 0 taken 110901 times.
✓ Branch 1 taken 761 times.
|
111662 | if (s->ps.pps->transquant_bypass_enable_flag || |
333 |
3/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 110893 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
110901 | (s->ps.sps->pcm.loop_filter_disable_flag && s->ps.sps->pcm_enabled_flag)) { |
334 | 769 | dst = lc->edge_emu_buffer; | |
335 | 769 | stride_dst = 2*MAX_PB_SIZE; | |
336 | 769 | copy_CTB(dst, src, width << s->ps.sps->pixel_shift, height, stride_dst, stride_src); | |
337 | 769 | s->hevcdsp.sao_band_filter[tab](src, dst, stride_src, stride_dst, | |
338 | 769 | sao->offset_val[c_idx], sao->band_position[c_idx], | |
339 | width, height); | ||
340 | 769 | restore_tqb_pixels(s, src, dst, stride_src, stride_dst, | |
341 | x, y, width, height, c_idx); | ||
342 | } else { | ||
343 | 110893 | s->hevcdsp.sao_band_filter[tab](src, src, stride_src, stride_src, | |
344 | 110893 | sao->offset_val[c_idx], sao->band_position[c_idx], | |
345 | width, height); | ||
346 | } | ||
347 | 111662 | sao->type_idx[c_idx] = SAO_APPLIED; | |
348 | 111662 | break; | |
349 | 379815 | case SAO_EDGE: | |
350 | { | ||
351 | 379815 | int w = s->ps.sps->width >> s->ps.sps->hshift[c_idx]; | |
352 | 379815 | int h = s->ps.sps->height >> s->ps.sps->vshift[c_idx]; | |
353 | 379815 | int left_edge = edges[0]; | |
354 | 379815 | int top_edge = edges[1]; | |
355 | 379815 | int right_edge = edges[2]; | |
356 | 379815 | int bottom_edge = edges[3]; | |
357 | 379815 | int sh = s->ps.sps->pixel_shift; | |
358 | int left_pixels, right_pixels; | ||
359 | |||
360 | 379815 | stride_dst = 2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE; | |
361 | 379815 | dst = lc->edge_emu_buffer + stride_dst + AV_INPUT_BUFFER_PADDING_SIZE; | |
362 | |||
363 |
2/2✓ Branch 0 taken 353846 times.
✓ Branch 1 taken 25969 times.
|
379815 | if (!top_edge) { |
364 | 353846 | int left = 1 - left_edge; | |
365 | 353846 | int right = 1 - right_edge; | |
366 | const uint8_t *src1[2]; | ||
367 | uint8_t *dst1; | ||
368 | int src_idx, pos; | ||
369 | |||
370 | 353846 | dst1 = dst - stride_dst - (left << sh); | |
371 | 353846 | src1[0] = src - stride_src - (left << sh); | |
372 | 353846 | src1[1] = s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb - 1) * w + x0 - left) << sh); | |
373 | 353846 | pos = 0; | |
374 |
2/2✓ Branch 0 taken 337157 times.
✓ Branch 1 taken 16689 times.
|
353846 | if (left) { |
375 | 337157 | src_idx = (CTB(s->sao, x_ctb-1, y_ctb-1).type_idx[c_idx] == | |
376 | SAO_APPLIED); | ||
377 | 337157 | copy_pixel(dst1, src1[src_idx], sh); | |
378 | 337157 | pos += (1 << sh); | |
379 | } | ||
380 | 353846 | src_idx = (CTB(s->sao, x_ctb, y_ctb-1).type_idx[c_idx] == | |
381 | SAO_APPLIED); | ||
382 | 353846 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); | |
383 |
2/2✓ Branch 0 taken 336836 times.
✓ Branch 1 taken 17010 times.
|
353846 | if (right) { |
384 | 336836 | pos += width << sh; | |
385 | 336836 | src_idx = (CTB(s->sao, x_ctb+1, y_ctb-1).type_idx[c_idx] == | |
386 | SAO_APPLIED); | ||
387 | 336836 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); | |
388 | } | ||
389 | } | ||
390 |
2/2✓ Branch 0 taken 349818 times.
✓ Branch 1 taken 29997 times.
|
379815 | if (!bottom_edge) { |
391 | 349818 | int left = 1 - left_edge; | |
392 | 349818 | int right = 1 - right_edge; | |
393 | const uint8_t *src1[2]; | ||
394 | uint8_t *dst1; | ||
395 | int src_idx, pos; | ||
396 | |||
397 | 349818 | dst1 = dst + height * stride_dst - (left << sh); | |
398 | 349818 | src1[0] = src + height * stride_src - (left << sh); | |
399 | 349818 | src1[1] = s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 2) * w + x0 - left) << sh); | |
400 | 349818 | pos = 0; | |
401 |
2/2✓ Branch 0 taken 333702 times.
✓ Branch 1 taken 16116 times.
|
349818 | if (left) { |
402 | 333702 | src_idx = (CTB(s->sao, x_ctb-1, y_ctb+1).type_idx[c_idx] == | |
403 | SAO_APPLIED); | ||
404 | 333702 | copy_pixel(dst1, src1[src_idx], sh); | |
405 | 333702 | pos += (1 << sh); | |
406 | } | ||
407 | 349818 | src_idx = (CTB(s->sao, x_ctb, y_ctb+1).type_idx[c_idx] == | |
408 | SAO_APPLIED); | ||
409 | 349818 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); | |
410 |
2/2✓ Branch 0 taken 333052 times.
✓ Branch 1 taken 16766 times.
|
349818 | if (right) { |
411 | 333052 | pos += width << sh; | |
412 | 333052 | src_idx = (CTB(s->sao, x_ctb+1, y_ctb+1).type_idx[c_idx] == | |
413 | SAO_APPLIED); | ||
414 | 333052 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); | |
415 | } | ||
416 | } | ||
417 | 379815 | left_pixels = 0; | |
418 |
2/2✓ Branch 0 taken 361114 times.
✓ Branch 1 taken 18701 times.
|
379815 | if (!left_edge) { |
419 |
2/2✓ Branch 0 taken 307841 times.
✓ Branch 1 taken 53273 times.
|
361114 | if (CTB(s->sao, x_ctb-1, y_ctb).type_idx[c_idx] == SAO_APPLIED) { |
420 | 307841 | copy_vert(dst - (1 << sh), | |
421 | 307841 | s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb - 1) * h + y0) << sh), | |
422 | 307841 | sh, height, stride_dst, 1 << sh); | |
423 | } else { | ||
424 | 53273 | left_pixels = 1; | |
425 | } | ||
426 | } | ||
427 | 379815 | right_pixels = 0; | |
428 |
2/2✓ Branch 0 taken 360687 times.
✓ Branch 1 taken 19128 times.
|
379815 | if (!right_edge) { |
429 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 360687 times.
|
360687 | if (CTB(s->sao, x_ctb+1, y_ctb).type_idx[c_idx] == SAO_APPLIED) { |
430 | ✗ | copy_vert(dst + (width << sh), | |
431 | ✗ | s->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 2) * h + y0) << sh), | |
432 | ✗ | sh, height, stride_dst, 1 << sh); | |
433 | } else { | ||
434 | 360687 | right_pixels = 1; | |
435 | } | ||
436 | } | ||
437 | |||
438 | 379815 | copy_CTB(dst - (left_pixels << sh), | |
439 | 379815 | src - (left_pixels << sh), | |
440 | 379815 | (width + left_pixels + right_pixels) << sh, | |
441 | height, stride_dst, stride_src); | ||
442 | |||
443 | 379815 | copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx, | |
444 | x_ctb, y_ctb); | ||
445 | 379815 | s->hevcdsp.sao_edge_filter[tab](src, dst, stride_src, sao->offset_val[c_idx], | |
446 | sao->eo_class[c_idx], width, height); | ||
447 | 379815 | s->hevcdsp.sao_edge_restore[restore](src, dst, | |
448 | stride_src, stride_dst, | ||
449 | sao, | ||
450 | edges, width, | ||
451 | height, c_idx, | ||
452 | vert_edge, | ||
453 | horiz_edge, | ||
454 | diag_edge); | ||
455 | 379815 | restore_tqb_pixels(s, src, dst, stride_src, stride_dst, | |
456 | x, y, width, height, c_idx); | ||
457 | 379815 | sao->type_idx[c_idx] = SAO_APPLIED; | |
458 | 379815 | break; | |
459 | } | ||
460 | } | ||
461 | } | ||
462 | 1194581 | } | |
463 | |||
464 | 2057768 | static int get_pcm(const HEVCContext *s, int x, int y) | |
465 | { | ||
466 | 2057768 | int log2_min_pu_size = s->ps.sps->log2_min_pu_size; | |
467 | int x_pu, y_pu; | ||
468 | |||
469 |
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) |
470 | ✗ | return 2; | |
471 | |||
472 | 2057768 | x_pu = x >> log2_min_pu_size; | |
473 | 2057768 | y_pu = y >> log2_min_pu_size; | |
474 | |||
475 |
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) |
476 | 1408 | return 2; | |
477 | 2056360 | return s->is_pcm[y_pu * s->ps.sps->min_pu_width + x_pu]; | |
478 | } | ||
479 | |||
480 | #define TC_CALC(qp, bs) \ | ||
481 | tctable[av_clip((qp) + DEFAULT_INTRA_TC_OFFSET * ((bs) - 1) + \ | ||
482 | (tc_offset & -2), \ | ||
483 | 0, MAX_QP + DEFAULT_INTRA_TC_OFFSET)] | ||
484 | |||
485 | 1411602 | static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0) | |
486 | { | ||
487 | uint8_t *src; | ||
488 | int x, y; | ||
489 | int chroma, beta; | ||
490 | int32_t c_tc[2], tc[2]; | ||
491 | 1411602 | uint8_t no_p[2] = { 0 }; | |
492 | 1411602 | uint8_t no_q[2] = { 0 }; | |
493 | |||
494 | 1411602 | int log2_ctb_size = s->ps.sps->log2_ctb_size; | |
495 | int x_end, x_end2, y_end; | ||
496 | 1411602 | int ctb_size = 1 << log2_ctb_size; | |
497 | 1411602 | int ctb = (x0 >> log2_ctb_size) + | |
498 | 1411602 | (y0 >> log2_ctb_size) * s->ps.sps->ctb_width; | |
499 | 1411602 | int cur_tc_offset = s->deblock[ctb].tc_offset; | |
500 | 1411602 | int cur_beta_offset = s->deblock[ctb].beta_offset; | |
501 | int left_tc_offset, left_beta_offset; | ||
502 | int tc_offset, beta_offset; | ||
503 | 2910585 | int pcmf = (s->ps.sps->pcm_enabled_flag && | |
504 |
4/4✓ Branch 0 taken 87381 times.
✓ Branch 1 taken 1324221 times.
✓ Branch 2 taken 87325 times.
✓ Branch 3 taken 56 times.
|
2823148 | s->ps.sps->pcm.loop_filter_disable_flag) || |
505 |
2/2✓ Branch 0 taken 4570 times.
✓ Branch 1 taken 1406976 times.
|
1411546 | s->ps.pps->transquant_bypass_enable_flag; |
506 | |||
507 |
2/2✓ Branch 0 taken 1338498 times.
✓ Branch 1 taken 73104 times.
|
1411602 | if (x0) { |
508 | 1338498 | left_tc_offset = s->deblock[ctb - 1].tc_offset; | |
509 | 1338498 | left_beta_offset = s->deblock[ctb - 1].beta_offset; | |
510 | } else { | ||
511 | 73104 | left_tc_offset = 0; | |
512 | 73104 | left_beta_offset = 0; | |
513 | } | ||
514 | |||
515 | 1411602 | x_end = x0 + ctb_size; | |
516 |
2/2✓ Branch 0 taken 25296 times.
✓ Branch 1 taken 1386306 times.
|
1411602 | if (x_end > s->ps.sps->width) |
517 | 25296 | x_end = s->ps.sps->width; | |
518 | 1411602 | y_end = y0 + ctb_size; | |
519 |
2/2✓ Branch 0 taken 96157 times.
✓ Branch 1 taken 1315445 times.
|
1411602 | if (y_end > s->ps.sps->height) |
520 | 96157 | y_end = s->ps.sps->height; | |
521 | |||
522 | 1411602 | tc_offset = cur_tc_offset; | |
523 | 1411602 | beta_offset = cur_beta_offset; | |
524 | |||
525 | 1411602 | x_end2 = x_end; | |
526 |
2/2✓ Branch 0 taken 1338499 times.
✓ Branch 1 taken 73103 times.
|
1411602 | if (x_end2 != s->ps.sps->width) |
527 | 1338499 | x_end2 -= 8; | |
528 |
2/2✓ Branch 0 taken 10139052 times.
✓ Branch 1 taken 1411602 times.
|
11550654 | for (y = y0; y < y_end; y += 8) { |
529 | // vertical filtering luma | ||
530 |
4/4✓ Branch 0 taken 9609055 times.
✓ Branch 1 taken 529997 times.
✓ Branch 2 taken 77016935 times.
✓ Branch 3 taken 10139052 times.
|
87155987 | for (x = x0 ? x0 : 8; x < x_end; x += 8) { |
531 | 77016935 | const int bs0 = s->vertical_bs[(x + y * s->bs_width) >> 2]; | |
532 | 77016935 | const int bs1 = s->vertical_bs[(x + (y + 4) * s->bs_width) >> 2]; | |
533 |
4/4✓ Branch 0 taken 59696610 times.
✓ Branch 1 taken 17320325 times.
✓ Branch 2 taken 89497 times.
✓ Branch 3 taken 59607113 times.
|
77016935 | if (bs0 || bs1) { |
534 | 17409822 | const int qp = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1; | |
535 | |||
536 | 17409822 | beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)]; | |
537 | |||
538 |
2/2✓ Branch 0 taken 17320325 times.
✓ Branch 1 taken 89497 times.
|
17409822 | tc[0] = bs0 ? TC_CALC(qp, bs0) : 0; |
539 |
2/2✓ Branch 0 taken 17313684 times.
✓ Branch 1 taken 96138 times.
|
17409822 | tc[1] = bs1 ? TC_CALC(qp, bs1) : 0; |
540 | 17409822 | src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->ps.sps->pixel_shift)]; | |
541 |
2/2✓ Branch 0 taken 186079 times.
✓ Branch 1 taken 17223743 times.
|
17409822 | if (pcmf) { |
542 | 186079 | no_p[0] = get_pcm(s, x - 1, y); | |
543 | 186079 | no_p[1] = get_pcm(s, x - 1, y + 4); | |
544 | 186079 | no_q[0] = get_pcm(s, x, y); | |
545 | 186079 | no_q[1] = get_pcm(s, x, y + 4); | |
546 | 186079 | s->hevcdsp.hevc_v_loop_filter_luma_c(src, | |
547 | 186079 | s->frame->linesize[LUMA], | |
548 | beta, tc, no_p, no_q); | ||
549 | } else | ||
550 | 17223743 | s->hevcdsp.hevc_v_loop_filter_luma(src, | |
551 | 17223743 | s->frame->linesize[LUMA], | |
552 | beta, tc, no_p, no_q); | ||
553 | } | ||
554 | } | ||
555 | |||
556 |
2/2✓ Branch 0 taken 118968 times.
✓ Branch 1 taken 10020084 times.
|
10139052 | if(!y) |
557 | 118968 | continue; | |
558 | |||
559 | // horizontal filtering luma | ||
560 |
4/4✓ Branch 0 taken 9499593 times.
✓ Branch 1 taken 520491 times.
✓ Branch 2 taken 76674959 times.
✓ Branch 3 taken 10020084 times.
|
86695043 | for (x = x0 ? x0 - 8 : 0; x < x_end2; x += 8) { |
561 | 76674959 | const int bs0 = s->horizontal_bs[( x + y * s->bs_width) >> 2]; | |
562 | 76674959 | const int bs1 = s->horizontal_bs[((x + 4) + y * s->bs_width) >> 2]; | |
563 |
4/4✓ Branch 0 taken 59032526 times.
✓ Branch 1 taken 17642433 times.
✓ Branch 2 taken 106170 times.
✓ Branch 3 taken 58926356 times.
|
76674959 | if (bs0 || bs1) { |
564 | 17748603 | const int qp = (get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1; | |
565 | |||
566 |
2/2✓ Branch 0 taken 15531371 times.
✓ Branch 1 taken 2217232 times.
|
17748603 | tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset; |
567 |
2/2✓ Branch 0 taken 15531371 times.
✓ Branch 1 taken 2217232 times.
|
17748603 | beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset; |
568 | |||
569 | 17748603 | beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)]; | |
570 |
2/2✓ Branch 0 taken 17642433 times.
✓ Branch 1 taken 106170 times.
|
17748603 | tc[0] = bs0 ? TC_CALC(qp, bs0) : 0; |
571 |
2/2✓ Branch 0 taken 17627708 times.
✓ Branch 1 taken 120895 times.
|
17748603 | tc[1] = bs1 ? TC_CALC(qp, bs1) : 0; |
572 | 17748603 | src = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->ps.sps->pixel_shift)]; | |
573 |
2/2✓ Branch 0 taken 187803 times.
✓ Branch 1 taken 17560800 times.
|
17748603 | if (pcmf) { |
574 | 187803 | no_p[0] = get_pcm(s, x, y - 1); | |
575 | 187803 | no_p[1] = get_pcm(s, x + 4, y - 1); | |
576 | 187803 | no_q[0] = get_pcm(s, x, y); | |
577 | 187803 | no_q[1] = get_pcm(s, x + 4, y); | |
578 | 187803 | s->hevcdsp.hevc_h_loop_filter_luma_c(src, | |
579 | 187803 | s->frame->linesize[LUMA], | |
580 | beta, tc, no_p, no_q); | ||
581 | } else | ||
582 | 17560800 | s->hevcdsp.hevc_h_loop_filter_luma(src, | |
583 | 17560800 | s->frame->linesize[LUMA], | |
584 | beta, tc, no_p, no_q); | ||
585 | } | ||
586 | } | ||
587 | } | ||
588 | |||
589 |
2/2✓ Branch 0 taken 1411554 times.
✓ Branch 1 taken 48 times.
|
1411602 | if (s->ps.sps->chroma_format_idc) { |
590 |
2/2✓ Branch 0 taken 2823108 times.
✓ Branch 1 taken 1411554 times.
|
4234662 | for (chroma = 1; chroma <= 2; chroma++) { |
591 | 2823108 | int h = 1 << s->ps.sps->hshift[chroma]; | |
592 | 2823108 | int v = 1 << s->ps.sps->vshift[chroma]; | |
593 | |||
594 | // vertical filtering chroma | ||
595 |
2/2✓ Branch 0 taken 10612400 times.
✓ Branch 1 taken 2823108 times.
|
13435508 | for (y = y0; y < y_end; y += (8 * v)) { |
596 |
4/4✓ Branch 0 taken 543280 times.
✓ Branch 1 taken 10069120 times.
✓ Branch 2 taken 40889998 times.
✓ Branch 3 taken 10612400 times.
|
51502398 | for (x = x0 ? x0 : 8 * h; x < x_end; x += (8 * h)) { |
597 | 40889998 | const int bs0 = s->vertical_bs[(x + y * s->bs_width) >> 2]; | |
598 | 40889998 | const int bs1 = s->vertical_bs[(x + (y + (4 * v)) * s->bs_width) >> 2]; | |
599 | |||
600 |
4/4✓ Branch 0 taken 35251484 times.
✓ Branch 1 taken 5638514 times.
✓ Branch 2 taken 128734 times.
✓ Branch 3 taken 35122750 times.
|
40889998 | if ((bs0 == 2) || (bs1 == 2)) { |
601 | 5767248 | const int qp0 = (get_qPy(s, x - 1, y) + get_qPy(s, x, y) + 1) >> 1; | |
602 | 5767248 | const int qp1 = (get_qPy(s, x - 1, y + (4 * v)) + get_qPy(s, x, y + (4 * v)) + 1) >> 1; | |
603 | |||
604 |
2/2✓ Branch 0 taken 5638514 times.
✓ Branch 1 taken 128734 times.
|
5767248 | c_tc[0] = (bs0 == 2) ? chroma_tc(s, qp0, chroma, tc_offset) : 0; |
605 |
2/2✓ Branch 0 taken 5633506 times.
✓ Branch 1 taken 133742 times.
|
5767248 | c_tc[1] = (bs1 == 2) ? chroma_tc(s, qp1, chroma, tc_offset) : 0; |
606 | 5767248 | 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)]; | |
607 |
2/2✓ Branch 0 taken 70838 times.
✓ Branch 1 taken 5696410 times.
|
5767248 | if (pcmf) { |
608 | 70838 | no_p[0] = get_pcm(s, x - 1, y); | |
609 | 70838 | no_p[1] = get_pcm(s, x - 1, y + (4 * v)); | |
610 | 70838 | no_q[0] = get_pcm(s, x, y); | |
611 | 70838 | no_q[1] = get_pcm(s, x, y + (4 * v)); | |
612 | 70838 | s->hevcdsp.hevc_v_loop_filter_chroma_c(src, | |
613 | 70838 | s->frame->linesize[chroma], | |
614 | c_tc, no_p, no_q); | ||
615 | } else | ||
616 | 5696410 | s->hevcdsp.hevc_v_loop_filter_chroma(src, | |
617 | 5696410 | s->frame->linesize[chroma], | |
618 | c_tc, no_p, no_q); | ||
619 | } | ||
620 | } | ||
621 | |||
622 |
2/2✓ Branch 0 taken 237912 times.
✓ Branch 1 taken 10374488 times.
|
10612400 | if(!y) |
623 | 237912 | continue; | |
624 | |||
625 | // horizontal filtering chroma | ||
626 |
2/2✓ Branch 0 taken 9850216 times.
✓ Branch 1 taken 524272 times.
|
10374488 | tc_offset = x0 ? left_tc_offset : cur_tc_offset; |
627 | 10374488 | x_end2 = x_end; | |
628 |
2/2✓ Branch 0 taken 9850224 times.
✓ Branch 1 taken 524264 times.
|
10374488 | if (x_end != s->ps.sps->width) |
629 | 9850224 | x_end2 = x_end - 8 * h; | |
630 |
4/4✓ Branch 0 taken 9850216 times.
✓ Branch 1 taken 524272 times.
✓ Branch 2 taken 40554718 times.
✓ Branch 3 taken 10374488 times.
|
50929206 | for (x = x0 ? x0 - 8 * h : 0; x < x_end2; x += (8 * h)) { |
631 | 40554718 | const int bs0 = s->horizontal_bs[( x + y * s->bs_width) >> 2]; | |
632 | 40554718 | const int bs1 = s->horizontal_bs[((x + 4 * h) + y * s->bs_width) >> 2]; | |
633 |
4/4✓ Branch 0 taken 35215124 times.
✓ Branch 1 taken 5339594 times.
✓ Branch 2 taken 134102 times.
✓ Branch 3 taken 35081022 times.
|
40554718 | if ((bs0 == 2) || (bs1 == 2)) { |
634 |
2/2✓ Branch 0 taken 5339594 times.
✓ Branch 1 taken 134102 times.
|
5473696 | const int qp0 = bs0 == 2 ? (get_qPy(s, x, y - 1) + get_qPy(s, x, y) + 1) >> 1 : 0; |
635 |
2/2✓ Branch 0 taken 5338032 times.
✓ Branch 1 taken 135664 times.
|
5473696 | const int qp1 = bs1 == 2 ? (get_qPy(s, x + (4 * h), y - 1) + get_qPy(s, x + (4 * h), y) + 1) >> 1 : 0; |
636 | |||
637 |
2/2✓ Branch 0 taken 5339594 times.
✓ Branch 1 taken 134102 times.
|
5473696 | c_tc[0] = bs0 == 2 ? chroma_tc(s, qp0, chroma, tc_offset) : 0; |
638 |
2/2✓ Branch 0 taken 5338032 times.
✓ Branch 1 taken 135664 times.
|
5473696 | c_tc[1] = bs1 == 2 ? chroma_tc(s, qp1, chroma, cur_tc_offset) : 0; |
639 | 5473696 | 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)]; | |
640 |
2/2✓ Branch 0 taken 69722 times.
✓ Branch 1 taken 5403974 times.
|
5473696 | if (pcmf) { |
641 | 69722 | no_p[0] = get_pcm(s, x, y - 1); | |
642 | 69722 | no_p[1] = get_pcm(s, x + (4 * h), y - 1); | |
643 | 69722 | no_q[0] = get_pcm(s, x, y); | |
644 | 69722 | no_q[1] = get_pcm(s, x + (4 * h), y); | |
645 | 69722 | s->hevcdsp.hevc_h_loop_filter_chroma_c(src, | |
646 | 69722 | s->frame->linesize[chroma], | |
647 | c_tc, no_p, no_q); | ||
648 | } else | ||
649 | 5403974 | s->hevcdsp.hevc_h_loop_filter_chroma(src, | |
650 | 5403974 | s->frame->linesize[chroma], | |
651 | c_tc, no_p, no_q); | ||
652 | } | ||
653 | } | ||
654 | } | ||
655 | } | ||
656 | } | ||
657 | 1411602 | } | |
658 | |||
659 | 228722991 | static int boundary_strength(const HEVCContext *s, const MvField *curr, const MvField *neigh, | |
660 | const RefPicList *neigh_refPicList) | ||
661 | { | ||
662 |
4/4✓ Branch 0 taken 145410402 times.
✓ Branch 1 taken 83312589 times.
✓ Branch 2 taken 141069872 times.
✓ Branch 3 taken 4340530 times.
|
228722991 | if (curr->pred_flag == PF_BI && neigh->pred_flag == PF_BI) { |
663 | // same L0 and L1 | ||
664 |
2/2✓ Branch 0 taken 139371733 times.
✓ Branch 1 taken 1698139 times.
|
141069872 | if (s->ref->refPicList[0].list[curr->ref_idx[0]] == neigh_refPicList[0].list[neigh->ref_idx[0]] && |
665 |
2/2✓ Branch 0 taken 18325892 times.
✓ Branch 1 taken 121045841 times.
|
139371733 | s->ref->refPicList[0].list[curr->ref_idx[0]] == s->ref->refPicList[1].list[curr->ref_idx[1]] && |
666 |
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]]) { |
667 |
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 || |
668 |
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) && |
669 |
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 || |
670 |
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)) |
671 | 410243 | return 1; | |
672 | else | ||
673 | 17777196 | return 0; | |
674 |
2/2✓ Branch 0 taken 121184294 times.
✓ Branch 1 taken 1698139 times.
|
122882433 | } else if (neigh_refPicList[0].list[neigh->ref_idx[0]] == s->ref->refPicList[0].list[curr->ref_idx[0]] && |
675 |
2/2✓ Branch 0 taken 120607941 times.
✓ Branch 1 taken 576353 times.
|
121184294 | neigh_refPicList[1].list[neigh->ref_idx[1]] == s->ref->refPicList[1].list[curr->ref_idx[1]]) { |
676 |
4/4✓ Branch 0 taken 116996991 times.
✓ Branch 1 taken 3610950 times.
✓ Branch 2 taken 116139479 times.
✓ Branch 3 taken 857512 times.
|
120607941 | if (FFABS(neigh->mv[0].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 4 || |
677 |
4/4✓ Branch 0 taken 115665951 times.
✓ Branch 1 taken 473528 times.
✓ Branch 2 taken 150249 times.
✓ Branch 3 taken 115515702 times.
|
116139479 | FFABS(neigh->mv[1].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 4) |
678 | 5092239 | return 1; | |
679 | else | ||
680 | 115515702 | return 0; | |
681 |
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]] && |
682 |
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]]) { |
683 |
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 || |
684 |
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) |
685 | 74847 | return 1; | |
686 | else | ||
687 | 77090 | return 0; | |
688 | } else { | ||
689 | 2122555 | return 1; | |
690 | } | ||
691 |
4/4✓ Branch 0 taken 83312589 times.
✓ Branch 1 taken 4340530 times.
✓ Branch 2 taken 78993850 times.
✓ Branch 3 taken 4318739 times.
|
87653119 | } else if ((curr->pred_flag != PF_BI) && (neigh->pred_flag != PF_BI)){ // 1 MV |
692 | Mv A, B; | ||
693 | int ref_A, ref_B; | ||
694 | |||
695 |
2/2✓ Branch 0 taken 67549235 times.
✓ Branch 1 taken 11444615 times.
|
78993850 | if (curr->pred_flag & 1) { |
696 | 67549235 | A = curr->mv[0]; | |
697 | 67549235 | ref_A = s->ref->refPicList[0].list[curr->ref_idx[0]]; | |
698 | } else { | ||
699 | 11444615 | A = curr->mv[1]; | |
700 | 11444615 | ref_A = s->ref->refPicList[1].list[curr->ref_idx[1]]; | |
701 | } | ||
702 | |||
703 |
2/2✓ Branch 0 taken 67564332 times.
✓ Branch 1 taken 11429518 times.
|
78993850 | if (neigh->pred_flag & 1) { |
704 | 67564332 | B = neigh->mv[0]; | |
705 | 67564332 | ref_B = neigh_refPicList[0].list[neigh->ref_idx[0]]; | |
706 | } else { | ||
707 | 11429518 | B = neigh->mv[1]; | |
708 | 11429518 | ref_B = neigh_refPicList[1].list[neigh->ref_idx[1]]; | |
709 | } | ||
710 | |||
711 |
2/2✓ Branch 0 taken 75315215 times.
✓ Branch 1 taken 3678635 times.
|
78993850 | if (ref_A == ref_B) { |
712 |
4/4✓ Branch 0 taken 73436017 times.
✓ Branch 1 taken 1879198 times.
✓ Branch 2 taken 626551 times.
✓ Branch 3 taken 72809466 times.
|
75315215 | if (FFABS(A.x - B.x) >= 4 || FFABS(A.y - B.y) >= 4) |
713 | 2505749 | return 1; | |
714 | else | ||
715 | 72809466 | return 0; | |
716 | } else | ||
717 | 3678635 | return 1; | |
718 | } | ||
719 | |||
720 | 8659269 | return 1; | |
721 | } | ||
722 | |||
723 | 19754321 | void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, int x0, int y0, | |
724 | int log2_trafo_size) | ||
725 | { | ||
726 | 19754321 | const HEVCContext *s = lc->parent; | |
727 | 19754321 | const MvField *tab_mvf = s->ref->tab_mvf; | |
728 | 19754321 | int log2_min_pu_size = s->ps.sps->log2_min_pu_size; | |
729 | 19754321 | int log2_min_tu_size = s->ps.sps->log2_min_tb_size; | |
730 | 19754321 | int min_pu_width = s->ps.sps->min_pu_width; | |
731 | 19754321 | int min_tu_width = s->ps.sps->min_tb_width; | |
732 | 19754321 | int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width + | |
733 | 19754321 | (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA; | |
734 | int boundary_upper, boundary_left; | ||
735 | int i, j, bs; | ||
736 | |||
737 |
4/4✓ Branch 0 taken 19456795 times.
✓ Branch 1 taken 297526 times.
✓ Branch 2 taken 15325981 times.
✓ Branch 3 taken 4130814 times.
|
19754321 | boundary_upper = y0 > 0 && !(y0 & 7); |
738 |
2/2✓ Branch 0 taken 15325981 times.
✓ Branch 1 taken 4428340 times.
|
19754321 | if (boundary_upper && |
739 |
2/2✓ Branch 0 taken 1999846 times.
✓ Branch 1 taken 13326135 times.
|
15325981 | ((!s->sh.slice_loop_filter_across_slices_enabled_flag && |
740 |
2/2✓ Branch 0 taken 501429 times.
✓ Branch 1 taken 1498417 times.
|
1999846 | lc->boundary_flags & BOUNDARY_UPPER_SLICE && |
741 |
2/2✓ Branch 0 taken 440329 times.
✓ Branch 1 taken 61100 times.
|
501429 | (y0 % (1 << s->ps.sps->log2_ctb_size)) == 0) || |
742 |
2/2✓ Branch 0 taken 429711 times.
✓ Branch 1 taken 14835170 times.
|
15264881 | (!s->ps.pps->loop_filter_across_tiles_enabled_flag && |
743 |
2/2✓ Branch 0 taken 114253 times.
✓ Branch 1 taken 315458 times.
|
429711 | lc->boundary_flags & BOUNDARY_UPPER_TILE && |
744 |
2/2✓ Branch 0 taken 19889 times.
✓ Branch 1 taken 94364 times.
|
114253 | (y0 % (1 << s->ps.sps->log2_ctb_size)) == 0))) |
745 | 80989 | boundary_upper = 0; | |
746 | |||
747 |
2/2✓ Branch 0 taken 15244992 times.
✓ Branch 1 taken 4509329 times.
|
19754321 | if (boundary_upper) { |
748 | 30489984 | const RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ? | |
749 |
2/2✓ Branch 0 taken 2097633 times.
✓ Branch 1 taken 13147359 times.
|
15244992 | ff_hevc_get_ref_list(s, s->ref, x0, y0 - 1) : |
750 | 13147359 | s->ref->refPicList; | |
751 | 15244992 | int yp_pu = (y0 - 1) >> log2_min_pu_size; | |
752 | 15244992 | int yq_pu = y0 >> log2_min_pu_size; | |
753 | 15244992 | int yp_tu = (y0 - 1) >> log2_min_tu_size; | |
754 | 15244992 | int yq_tu = y0 >> log2_min_tu_size; | |
755 | |||
756 |
2/2✓ Branch 0 taken 47807246 times.
✓ Branch 1 taken 15244992 times.
|
63052238 | for (i = 0; i < (1 << log2_trafo_size); i += 4) { |
757 | 47807246 | int x_pu = (x0 + i) >> log2_min_pu_size; | |
758 | 47807246 | int x_tu = (x0 + i) >> log2_min_tu_size; | |
759 | 47807246 | const MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; | |
760 | 47807246 | const MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; | |
761 | 47807246 | uint8_t top_cbf_luma = s->cbf_luma[yp_tu * min_tu_width + x_tu]; | |
762 | 47807246 | uint8_t curr_cbf_luma = s->cbf_luma[yq_tu * min_tu_width + x_tu]; | |
763 | |||
764 |
4/4✓ Branch 0 taken 34994460 times.
✓ Branch 1 taken 12812786 times.
✓ Branch 2 taken 1226306 times.
✓ Branch 3 taken 33768154 times.
|
47807246 | if (curr->pred_flag == PF_INTRA || top->pred_flag == PF_INTRA) |
765 | 14039092 | bs = 2; | |
766 |
4/4✓ Branch 0 taken 26922071 times.
✓ Branch 1 taken 6846083 times.
✓ Branch 2 taken 2738763 times.
✓ Branch 3 taken 24183308 times.
|
33768154 | else if (curr_cbf_luma || top_cbf_luma) |
767 | 9584846 | bs = 1; | |
768 | else | ||
769 | 24183308 | bs = boundary_strength(s, curr, top, rpl_top); | |
770 | 47807246 | s->horizontal_bs[((x0 + i) + y0 * s->bs_width) >> 2] = bs; | |
771 | } | ||
772 | } | ||
773 | |||
774 | // bs for vertical TU boundaries | ||
775 |
4/4✓ Branch 0 taken 19555789 times.
✓ Branch 1 taken 198532 times.
✓ Branch 2 taken 15424975 times.
✓ Branch 3 taken 4130814 times.
|
19754321 | boundary_left = x0 > 0 && !(x0 & 7); |
776 |
2/2✓ Branch 0 taken 15424975 times.
✓ Branch 1 taken 4329346 times.
|
19754321 | if (boundary_left && |
777 |
2/2✓ Branch 0 taken 2020355 times.
✓ Branch 1 taken 13404620 times.
|
15424975 | ((!s->sh.slice_loop_filter_across_slices_enabled_flag && |
778 |
2/2✓ Branch 0 taken 68545 times.
✓ Branch 1 taken 1951810 times.
|
2020355 | lc->boundary_flags & BOUNDARY_LEFT_SLICE && |
779 |
2/2✓ Branch 0 taken 59894 times.
✓ Branch 1 taken 8651 times.
|
68545 | (x0 % (1 << s->ps.sps->log2_ctb_size)) == 0) || |
780 |
2/2✓ Branch 0 taken 441443 times.
✓ Branch 1 taken 14974881 times.
|
15416324 | (!s->ps.pps->loop_filter_across_tiles_enabled_flag && |
781 |
2/2✓ Branch 0 taken 59900 times.
✓ Branch 1 taken 381543 times.
|
441443 | lc->boundary_flags & BOUNDARY_LEFT_TILE && |
782 |
2/2✓ Branch 0 taken 13608 times.
✓ Branch 1 taken 46292 times.
|
59900 | (x0 % (1 << s->ps.sps->log2_ctb_size)) == 0))) |
783 | 22259 | boundary_left = 0; | |
784 | |||
785 |
2/2✓ Branch 0 taken 15402716 times.
✓ Branch 1 taken 4351605 times.
|
19754321 | if (boundary_left) { |
786 | 30805432 | const RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ? | |
787 |
2/2✓ Branch 0 taken 245955 times.
✓ Branch 1 taken 15156761 times.
|
15402716 | ff_hevc_get_ref_list(s, s->ref, x0 - 1, y0) : |
788 | 15156761 | s->ref->refPicList; | |
789 | 15402716 | int xp_pu = (x0 - 1) >> log2_min_pu_size; | |
790 | 15402716 | int xq_pu = x0 >> log2_min_pu_size; | |
791 | 15402716 | int xp_tu = (x0 - 1) >> log2_min_tu_size; | |
792 | 15402716 | int xq_tu = x0 >> log2_min_tu_size; | |
793 | |||
794 |
2/2✓ Branch 0 taken 48764896 times.
✓ Branch 1 taken 15402716 times.
|
64167612 | for (i = 0; i < (1 << log2_trafo_size); i += 4) { |
795 | 48764896 | int y_pu = (y0 + i) >> log2_min_pu_size; | |
796 | 48764896 | int y_tu = (y0 + i) >> log2_min_tu_size; | |
797 | 48764896 | const MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; | |
798 | 48764896 | const MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; | |
799 | 48764896 | uint8_t left_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xp_tu]; | |
800 | 48764896 | uint8_t curr_cbf_luma = s->cbf_luma[y_tu * min_tu_width + xq_tu]; | |
801 | |||
802 |
4/4✓ Branch 0 taken 35874518 times.
✓ Branch 1 taken 12890378 times.
✓ Branch 2 taken 1358220 times.
✓ Branch 3 taken 34516298 times.
|
48764896 | if (curr->pred_flag == PF_INTRA || left->pred_flag == PF_INTRA) |
803 | 14248598 | bs = 2; | |
804 |
4/4✓ Branch 0 taken 27607546 times.
✓ Branch 1 taken 6908752 times.
✓ Branch 2 taken 2769615 times.
✓ Branch 3 taken 24837931 times.
|
34516298 | else if (curr_cbf_luma || left_cbf_luma) |
805 | 9678367 | bs = 1; | |
806 | else | ||
807 | 24837931 | bs = boundary_strength(s, curr, left, rpl_left); | |
808 | 48764896 | s->vertical_bs[(x0 + (y0 + i) * s->bs_width) >> 2] = bs; | |
809 | } | ||
810 | } | ||
811 | |||
812 |
4/4✓ Branch 0 taken 10184396 times.
✓ Branch 1 taken 9569925 times.
✓ Branch 2 taken 7334386 times.
✓ Branch 3 taken 2850010 times.
|
19754321 | if (log2_trafo_size > log2_min_pu_size && !is_intra) { |
813 | 7334386 | const RefPicList *rpl = s->ref->refPicList; | |
814 | |||
815 | // bs for TU internal horizontal PU boundaries | ||
816 |
2/2✓ Branch 0 taken 9525849 times.
✓ Branch 1 taken 7334386 times.
|
16860235 | for (j = 8; j < (1 << log2_trafo_size); j += 8) { |
817 | 9525849 | int yp_pu = (y0 + j - 1) >> log2_min_pu_size; | |
818 | 9525849 | int yq_pu = (y0 + j) >> log2_min_pu_size; | |
819 | |||
820 |
2/2✓ Branch 0 taken 89850876 times.
✓ Branch 1 taken 9525849 times.
|
99376725 | for (i = 0; i < (1 << log2_trafo_size); i += 4) { |
821 | 89850876 | int x_pu = (x0 + i) >> log2_min_pu_size; | |
822 | 89850876 | const MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; | |
823 | 89850876 | const MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; | |
824 | |||
825 | 89850876 | bs = boundary_strength(s, curr, top, rpl); | |
826 | 89850876 | s->horizontal_bs[((x0 + i) + (y0 + j) * s->bs_width) >> 2] = bs; | |
827 | } | ||
828 | } | ||
829 | |||
830 | // bs for TU internal vertical PU boundaries | ||
831 |
2/2✓ Branch 0 taken 33720470 times.
✓ Branch 1 taken 7334386 times.
|
41054856 | for (j = 0; j < (1 << log2_trafo_size); j += 4) { |
832 | 33720470 | int y_pu = (y0 + j) >> log2_min_pu_size; | |
833 | |||
834 |
2/2✓ Branch 0 taken 89850876 times.
✓ Branch 1 taken 33720470 times.
|
123571346 | for (i = 8; i < (1 << log2_trafo_size); i += 8) { |
835 | 89850876 | int xp_pu = (x0 + i - 1) >> log2_min_pu_size; | |
836 | 89850876 | int xq_pu = (x0 + i) >> log2_min_pu_size; | |
837 | 89850876 | const MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; | |
838 | 89850876 | const MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; | |
839 | |||
840 | 89850876 | bs = boundary_strength(s, curr, left, rpl); | |
841 | 89850876 | s->vertical_bs[((x0 + i) + (y0 + j) * s->bs_width) >> 2] = bs; | |
842 | } | ||
843 | } | ||
844 | } | ||
845 | 19754321 | } | |
846 | |||
847 | #undef LUMA | ||
848 | #undef CB | ||
849 | #undef CR | ||
850 | |||
851 | 1413642 | void ff_hevc_hls_filter(HEVCLocalContext *lc, int x, int y, int ctb_size) | |
852 | { | ||
853 | 1413642 | const HEVCContext *const s = lc->parent; | |
854 | 1413642 | int x_end = x >= s->ps.sps->width - ctb_size; | |
855 | 1413642 | int skip = 0; | |
856 |
1/2✓ Branch 0 taken 1413642 times.
✗ Branch 1 not taken.
|
1413642 | if (s->avctx->skip_loop_filter >= AVDISCARD_ALL || |
857 |
5/6✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 1410582 times.
✓ Branch 2 taken 2040 times.
✓ Branch 3 taken 1020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2040 times.
|
1413642 | (s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && !IS_IDR(s)) || |
858 |
2/2✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 1410582 times.
|
1411602 | (s->avctx->skip_loop_filter >= AVDISCARD_NONINTRA && |
859 |
1/2✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
|
1020 | s->sh.slice_type != HEVC_SLICE_I) || |
860 |
2/2✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 1410582 times.
|
1411602 | (s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && |
861 |
1/2✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
|
1020 | s->sh.slice_type == HEVC_SLICE_B) || |
862 |
3/4✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 1410582 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1020 times.
|
1412622 | (s->avctx->skip_loop_filter >= AVDISCARD_NONREF && |
863 | 1020 | ff_hevc_nal_is_nonref(s->nal_unit_type))) | |
864 | 2040 | skip = 1; | |
865 | |||
866 |
2/2✓ Branch 0 taken 1411602 times.
✓ Branch 1 taken 2040 times.
|
1413642 | if (!skip) |
867 | 1411602 | deblocking_filter_CTB(s, x, y); | |
868 |
4/4✓ Branch 0 taken 1196652 times.
✓ Branch 1 taken 216990 times.
✓ Branch 2 taken 1194612 times.
✓ Branch 3 taken 2040 times.
|
2608254 | if (s->ps.sps->sao_enabled && !skip) { |
869 | 1194612 | int y_end = y >= s->ps.sps->height - ctb_size; | |
870 |
4/4✓ Branch 0 taken 1091041 times.
✓ Branch 1 taken 103571 times.
✓ Branch 2 taken 1035620 times.
✓ Branch 3 taken 55421 times.
|
1194612 | if (y && x) |
871 | 1035620 | sao_filter_CTB(lc, s, x - ctb_size, y - ctb_size); | |
872 |
4/4✓ Branch 0 taken 1130485 times.
✓ Branch 1 taken 64127 times.
✓ Branch 2 taken 94836 times.
✓ Branch 3 taken 1035649 times.
|
1194612 | if (x && y_end) |
873 | 94836 | sao_filter_CTB(lc, s, x - ctb_size, y); | |
874 |
4/4✓ Branch 0 taken 1091041 times.
✓ Branch 1 taken 103571 times.
✓ Branch 2 taken 55420 times.
✓ Branch 3 taken 1035621 times.
|
1194612 | if (y && x_end) { |
875 | 55420 | sao_filter_CTB(lc, s, x, y - ctb_size); | |
876 |
2/2✓ Branch 0 taken 497 times.
✓ Branch 1 taken 54923 times.
|
55420 | if (s->threads_type & FF_THREAD_FRAME ) |
877 | 497 | ff_thread_report_progress(&s->ref->tf, y, 0); | |
878 | } | ||
879 |
4/4✓ Branch 0 taken 64126 times.
✓ Branch 1 taken 1130486 times.
✓ Branch 2 taken 8705 times.
✓ Branch 3 taken 55421 times.
|
1194612 | if (x_end && y_end) { |
880 | 8705 | sao_filter_CTB(lc, s, x , y); | |
881 |
2/2✓ Branch 0 taken 31 times.
✓ Branch 1 taken 8674 times.
|
8705 | if (s->threads_type & FF_THREAD_FRAME ) |
882 | 31 | ff_thread_report_progress(&s->ref->tf, y + ctb_size, 0); | |
883 | } | ||
884 |
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) |
885 | ✗ | ff_thread_report_progress(&s->ref->tf, y + ctb_size - 4, 0); | |
886 | 1413642 | } | |
887 | |||
888 | 1413673 | void ff_hevc_hls_filters(HEVCLocalContext *lc, int x_ctb, int y_ctb, int ctb_size) | |
889 | { | ||
890 | 1413673 | int x_end = x_ctb >= lc->parent->ps.sps->width - ctb_size; | |
891 | 1413673 | int y_end = y_ctb >= lc->parent->ps.sps->height - ctb_size; | |
892 |
4/4✓ Branch 0 taken 1294585 times.
✓ Branch 1 taken 119088 times.
✓ Branch 2 taken 1230922 times.
✓ Branch 3 taken 63663 times.
|
1413673 | if (y_ctb && x_ctb) |
893 | 1230922 | ff_hevc_hls_filter(lc, x_ctb - ctb_size, y_ctb - ctb_size, ctb_size); | |
894 |
4/4✓ Branch 0 taken 1294585 times.
✓ Branch 1 taken 119088 times.
✓ Branch 2 taken 63662 times.
✓ Branch 3 taken 1230923 times.
|
1413673 | if (y_ctb && x_end) |
895 | 63662 | ff_hevc_hls_filter(lc, x_ctb, y_ctb - ctb_size, ctb_size); | |
896 |
4/4✓ Branch 0 taken 1340500 times.
✓ Branch 1 taken 73173 times.
✓ Branch 2 taken 109549 times.
✓ Branch 3 taken 1230951 times.
|
1413673 | if (x_ctb && y_end) |
897 | 109549 | ff_hevc_hls_filter(lc, x_ctb - ctb_size, y_ctb, ctb_size); | |
898 | 1413673 | } | |
899 |