| 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 "libavcodec/progressframe.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 | 21123398 | static int chroma_tc(const HEVCPPS *pps, const HEVCSPS *sps, | |
| 48 | int qp_y, int c_idx, int tc_offset) | ||
| 49 | { | ||
| 50 | static const int qp_c[] = { | ||
| 51 | 29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37 | ||
| 52 | }; | ||
| 53 | int qp, qp_i, offset, idxt; | ||
| 54 | |||
| 55 | // slice qp offset is not used for deblocking | ||
| 56 |
2/2✓ Branch 0 taken 10561699 times.
✓ Branch 1 taken 10561699 times.
|
21123398 | if (c_idx == 1) |
| 57 | 10561699 | offset = pps->cb_qp_offset; | |
| 58 | else | ||
| 59 | 10561699 | offset = pps->cr_qp_offset; | |
| 60 | |||
| 61 | 21123398 | qp_i = av_clip(qp_y + offset, 0, 57); | |
| 62 |
2/2✓ Branch 0 taken 18879174 times.
✓ Branch 1 taken 2244224 times.
|
21123398 | if (sps->chroma_format_idc == 1) { |
| 63 |
2/2✓ Branch 0 taken 4023542 times.
✓ Branch 1 taken 14855632 times.
|
18879174 | if (qp_i < 30) |
| 64 | 4023542 | qp = qp_i; | |
| 65 |
2/2✓ Branch 0 taken 186816 times.
✓ Branch 1 taken 14668816 times.
|
14855632 | else if (qp_i > 43) |
| 66 | 186816 | qp = qp_i - 6; | |
| 67 | else | ||
| 68 | 14668816 | qp = qp_c[qp_i - 30]; | |
| 69 | } else { | ||
| 70 | 2244224 | qp = av_clip(qp_i, 0, 51); | |
| 71 | } | ||
| 72 | |||
| 73 | 21123398 | idxt = av_clip(qp + DEFAULT_INTRA_TC_OFFSET + tc_offset, 0, 53); | |
| 74 | 21123398 | return tctable[idxt]; | |
| 75 | } | ||
| 76 | |||
| 77 | 2092606 | static int get_qPy_pred(HEVCLocalContext *lc, const HEVCContext *s, | |
| 78 | const HEVCLayerContext *l, | ||
| 79 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 80 | int xBase, int yBase, int log2_cb_size) | ||
| 81 | { | ||
| 82 | 2092606 | int ctb_size_mask = (1 << sps->log2_ctb_size) - 1; | |
| 83 | 2092606 | int MinCuQpDeltaSizeMask = (1 << (sps->log2_ctb_size - | |
| 84 | 2092606 | pps->diff_cu_qp_delta_depth)) - 1; | |
| 85 | 2092606 | int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask); | |
| 86 | 2092606 | int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask); | |
| 87 | 2092606 | int min_cb_width = sps->min_cb_width; | |
| 88 | 2092606 | int x_cb = xQgBase >> sps->log2_min_cb_size; | |
| 89 | 2092606 | int y_cb = yQgBase >> sps->log2_min_cb_size; | |
| 90 |
2/2✓ Branch 0 taken 1131860 times.
✓ Branch 1 taken 960746 times.
|
3224466 | int availableA = (xBase & ctb_size_mask) && |
| 91 |
2/2✓ Branch 0 taken 802433 times.
✓ Branch 1 taken 329427 times.
|
1131860 | (xQgBase & ctb_size_mask); |
| 92 |
2/2✓ Branch 0 taken 1080899 times.
✓ Branch 1 taken 1011707 times.
|
3173505 | int availableB = (yBase & ctb_size_mask) && |
| 93 |
2/2✓ Branch 0 taken 800654 times.
✓ Branch 1 taken 280245 times.
|
1080899 | (yQgBase & ctb_size_mask); |
| 94 | int qPy_pred, qPy_a, qPy_b; | ||
| 95 | |||
| 96 | // qPy_pred | ||
| 97 |
5/6✓ Branch 0 taken 1994952 times.
✓ Branch 1 taken 97654 times.
✓ Branch 2 taken 27812 times.
✓ Branch 3 taken 1967140 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27812 times.
|
2092606 | if (lc->first_qp_group || (!xQgBase && !yQgBase)) { |
| 98 | 97654 | lc->first_qp_group = !lc->tu.is_cu_qp_delta_coded; | |
| 99 | 97654 | qPy_pred = s->sh.slice_qp; | |
| 100 | } else { | ||
| 101 | 1994952 | qPy_pred = lc->qPy_pred; | |
| 102 | } | ||
| 103 | |||
| 104 | // qPy_a | ||
| 105 |
2/2✓ Branch 0 taken 1290173 times.
✓ Branch 1 taken 802433 times.
|
2092606 | if (availableA == 0) |
| 106 | 1290173 | qPy_a = qPy_pred; | |
| 107 | else | ||
| 108 | 802433 | qPy_a = l->qp_y_tab[(x_cb - 1) + y_cb * min_cb_width]; | |
| 109 | |||
| 110 | // qPy_b | ||
| 111 |
2/2✓ Branch 0 taken 1291952 times.
✓ Branch 1 taken 800654 times.
|
2092606 | if (availableB == 0) |
| 112 | 1291952 | qPy_b = qPy_pred; | |
| 113 | else | ||
| 114 | 800654 | qPy_b = l->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width]; | |
| 115 | |||
| 116 | av_assert2(qPy_a >= -sps->qp_bd_offset && qPy_a < 52); | ||
| 117 | av_assert2(qPy_b >= -sps->qp_bd_offset && qPy_b < 52); | ||
| 118 | |||
| 119 | 2092606 | return (qPy_a + qPy_b + 1) >> 1; | |
| 120 | } | ||
| 121 | |||
| 122 | 2092606 | void ff_hevc_set_qPy(HEVCLocalContext *lc, | |
| 123 | const HEVCLayerContext *l, const HEVCPPS *pps, | ||
| 124 | int xBase, int yBase, int log2_cb_size) | ||
| 125 | { | ||
| 126 | 2092606 | const HEVCSPS *const sps = pps->sps; | |
| 127 | 2092606 | const HEVCContext *const s = lc->parent; | |
| 128 | 2092606 | int qp_y = get_qPy_pred(lc, s, l, pps, sps, xBase, yBase, log2_cb_size); | |
| 129 | |||
| 130 |
2/2✓ Branch 0 taken 485047 times.
✓ Branch 1 taken 1607559 times.
|
2092606 | if (lc->tu.cu_qp_delta != 0) { |
| 131 | 485047 | int off = sps->qp_bd_offset; | |
| 132 |
1/2✓ Branch 0 taken 485047 times.
✗ Branch 1 not taken.
|
485047 | lc->qp_y = FFUMOD(qp_y + lc->tu.cu_qp_delta + 52 + 2 * off, |
| 133 | 485047 | 52 + off) - off; | |
| 134 | } else | ||
| 135 | 1607559 | lc->qp_y = qp_y; | |
| 136 | 2092606 | } | |
| 137 | |||
| 138 | 125221772 | static int get_qPy(const HEVCSPS *sps, const int8_t *qp_y_tab, int xC, int yC) | |
| 139 | { | ||
| 140 | 125221772 | int log2_min_cb_size = sps->log2_min_cb_size; | |
| 141 | 125221772 | int x = xC >> log2_min_cb_size; | |
| 142 | 125221772 | int y = yC >> log2_min_cb_size; | |
| 143 | 125221772 | return qp_y_tab[x + y * sps->min_cb_width]; | |
| 144 | } | ||
| 145 | |||
| 146 | 577513 | static void copy_CTB(uint8_t *dst, const uint8_t *src, int width, int height, | |
| 147 | ptrdiff_t stride_dst, ptrdiff_t stride_src) | ||
| 148 | { | ||
| 149 | int i, j; | ||
| 150 | |||
| 151 |
2/2✓ Branch 0 taken 79472 times.
✓ Branch 1 taken 498041 times.
|
577513 | if (((intptr_t)dst | (intptr_t)src | stride_dst | stride_src) & 15) { |
| 152 |
2/2✓ Branch 0 taken 3234344 times.
✓ Branch 1 taken 79472 times.
|
3313816 | for (i = 0; i < height; i++) { |
| 153 |
2/2✓ Branch 0 taken 20718384 times.
✓ Branch 1 taken 3234344 times.
|
23952728 | for (j = 0; j < width - 7; j+=8) |
| 154 | 20718384 | AV_COPY64U(dst+j, src+j); | |
| 155 | 3234344 | dst += stride_dst; | |
| 156 | 3234344 | src += stride_src; | |
| 157 | } | ||
| 158 |
2/2✓ Branch 0 taken 79338 times.
✓ Branch 1 taken 134 times.
|
79472 | if (width&7) { |
| 159 | 79338 | dst += ((width>>3)<<3) - stride_dst * height; | |
| 160 | 79338 | src += ((width>>3)<<3) - stride_src * height; | |
| 161 | 79338 | width &= 7; | |
| 162 |
2/2✓ Branch 0 taken 3233272 times.
✓ Branch 1 taken 79338 times.
|
3312610 | for (i = 0; i < height; i++) { |
| 163 |
2/2✓ Branch 0 taken 6885424 times.
✓ Branch 1 taken 3233272 times.
|
10118696 | for (j = 0; j < width; j++) |
| 164 | 6885424 | dst[j] = src[j]; | |
| 165 | 3233272 | dst += stride_dst; | |
| 166 | 3233272 | src += stride_src; | |
| 167 | } | ||
| 168 | } | ||
| 169 | } else { | ||
| 170 |
2/2✓ Branch 0 taken 22527064 times.
✓ Branch 1 taken 498041 times.
|
23025105 | for (i = 0; i < height; i++) { |
| 171 |
2/2✓ Branch 0 taken 101790608 times.
✓ Branch 1 taken 22527064 times.
|
124317672 | for (j = 0; j < width; j+=16) |
| 172 | 101790608 | AV_COPY128(dst+j, src+j); | |
| 173 | 22527064 | dst += stride_dst; | |
| 174 | 22527064 | src += stride_src; | |
| 175 | } | ||
| 176 | } | ||
| 177 | 577513 | } | |
| 178 | |||
| 179 | 2115529 | static void copy_pixel(uint8_t *dst, const uint8_t *src, int pixel_shift) | |
| 180 | { | ||
| 181 |
2/2✓ Branch 0 taken 198877 times.
✓ Branch 1 taken 1916652 times.
|
2115529 | if (pixel_shift) |
| 182 | 198877 | *(uint16_t *)dst = *(uint16_t *)src; | |
| 183 | else | ||
| 184 | 1916652 | *dst = *src; | |
| 185 | 2115529 | } | |
| 186 | |||
| 187 | 1840185 | static void copy_vert(uint8_t *dst, const uint8_t *src, | |
| 188 | int pixel_shift, int height, | ||
| 189 | ptrdiff_t stride_dst, ptrdiff_t stride_src) | ||
| 190 | { | ||
| 191 | int i; | ||
| 192 |
2/2✓ Branch 0 taken 1679244 times.
✓ Branch 1 taken 160941 times.
|
1840185 | if (pixel_shift == 0) { |
| 193 |
2/2✓ Branch 0 taken 70853672 times.
✓ Branch 1 taken 1679244 times.
|
72532916 | for (i = 0; i < height; i++) { |
| 194 | 70853672 | *dst = *src; | |
| 195 | 70853672 | dst += stride_dst; | |
| 196 | 70853672 | src += stride_src; | |
| 197 | } | ||
| 198 | } else { | ||
| 199 |
2/2✓ Branch 0 taken 9906752 times.
✓ Branch 1 taken 160941 times.
|
10067693 | for (i = 0; i < height; i++) { |
| 200 | 9906752 | *(uint16_t *)dst = *(uint16_t *)src; | |
| 201 | 9906752 | dst += stride_dst; | |
| 202 | 9906752 | src += stride_src; | |
| 203 | } | ||
| 204 | } | ||
| 205 | 1840185 | } | |
| 206 | |||
| 207 | 680409 | static void copy_CTB_to_hv(const HEVCLayerContext *l, const HEVCSPS *sps, | |
| 208 | const uint8_t *src, | ||
| 209 | ptrdiff_t stride_src, int x, int y, int width, int height, | ||
| 210 | int c_idx, int x_ctb, int y_ctb) | ||
| 211 | { | ||
| 212 | 680409 | int sh = sps->pixel_shift; | |
| 213 | 680409 | int w = sps->width >> sps->hshift[c_idx]; | |
| 214 | 680409 | int h = sps->height >> sps->vshift[c_idx]; | |
| 215 | |||
| 216 | /* copy horizontal edges */ | ||
| 217 | 680409 | memcpy(l->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb) * w + x) << sh), | |
| 218 | 680409 | src, width << sh); | |
| 219 | 680409 | memcpy(l->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 1) * w + x) << sh), | |
| 220 | 680409 | src + stride_src * (height - 1), width << sh); | |
| 221 | |||
| 222 | /* copy vertical edges */ | ||
| 223 | 680409 | copy_vert(l->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb) * h + y) << sh), src, sh, height, 1 << sh, stride_src); | |
| 224 | |||
| 225 | 680409 | copy_vert(l->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 1) * h + y) << sh), src + ((width - 1) << sh), sh, height, 1 << sh, stride_src); | |
| 226 | 680409 | } | |
| 227 | |||
| 228 | 577513 | static void restore_tqb_pixels(const HEVCLayerContext *l, | |
| 229 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 230 | uint8_t *src1, const uint8_t *dst1, | ||
| 231 | ptrdiff_t stride_src, ptrdiff_t stride_dst, | ||
| 232 | int x0, int y0, int width, int height, int c_idx) | ||
| 233 | { | ||
| 234 |
2/2✓ Branch 0 taken 574323 times.
✓ Branch 1 taken 3190 times.
|
577513 | if (pps->transquant_bypass_enable_flag || |
| 235 |
3/4✓ Branch 0 taken 52 times.
✓ Branch 1 taken 574271 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
|
574323 | (sps->pcm_loop_filter_disabled && sps->pcm_enabled)) { |
| 236 | int x, y; | ||
| 237 | 3242 | int min_pu_size = 1 << sps->log2_min_pu_size; | |
| 238 | 3242 | int hshift = sps->hshift[c_idx]; | |
| 239 | 3242 | int vshift = sps->vshift[c_idx]; | |
| 240 | 3242 | int x_min = ((x0 ) >> sps->log2_min_pu_size); | |
| 241 | 3242 | int y_min = ((y0 ) >> sps->log2_min_pu_size); | |
| 242 | 3242 | int x_max = ((x0 + width ) >> sps->log2_min_pu_size); | |
| 243 | 3242 | int y_max = ((y0 + height) >> sps->log2_min_pu_size); | |
| 244 | 3242 | int len = (min_pu_size >> hshift) << sps->pixel_shift; | |
| 245 |
2/2✓ Branch 0 taken 37372 times.
✓ Branch 1 taken 3242 times.
|
40614 | for (y = y_min; y < y_max; y++) { |
| 246 |
2/2✓ Branch 0 taken 489472 times.
✓ Branch 1 taken 37372 times.
|
526844 | for (x = x_min; x < x_max; x++) { |
| 247 |
2/2✓ Branch 0 taken 132 times.
✓ Branch 1 taken 489340 times.
|
489472 | if (l->is_pcm[y * sps->min_pu_width + x]) { |
| 248 | int n; | ||
| 249 | 132 | uint8_t *src = src1 + | |
| 250 | 132 | (((y << sps->log2_min_pu_size) - y0) >> vshift) * stride_src + | |
| 251 | 132 | ((((x << sps->log2_min_pu_size) - x0) >> hshift) << sps->pixel_shift); | |
| 252 | 132 | const uint8_t *dst = dst1 + | |
| 253 | 132 | (((y << sps->log2_min_pu_size) - y0) >> vshift) * stride_dst + | |
| 254 | 132 | ((((x << sps->log2_min_pu_size) - x0) >> hshift) << sps->pixel_shift); | |
| 255 | |||
| 256 |
2/2✓ Branch 0 taken 352 times.
✓ Branch 1 taken 132 times.
|
484 | for (n = 0; n < (min_pu_size >> vshift); n++) { |
| 257 | 352 | memcpy(src, dst, len); | |
| 258 | 352 | src += stride_src; | |
| 259 | 352 | dst += stride_dst; | |
| 260 | } | ||
| 261 | } | ||
| 262 | } | ||
| 263 | } | ||
| 264 | } | ||
| 265 | 577513 | } | |
| 266 | |||
| 267 | #define CTB(tab, x, y) ((tab)[(y) * sps->ctb_width + (x)]) | ||
| 268 | |||
| 269 | 1724555 | static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCLayerContext *l, | |
| 270 | const HEVCContext *s, | ||
| 271 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 272 | int x, int y) | ||
| 273 | { | ||
| 274 | static const uint8_t sao_tab[8] = { 0, 1, 2, 2, 3, 3, 4, 4 }; | ||
| 275 | int c_idx; | ||
| 276 | int edges[4]; // 0 left 1 top 2 right 3 bottom | ||
| 277 | 1724555 | int x_ctb = x >> sps->log2_ctb_size; | |
| 278 | 1724555 | int y_ctb = y >> sps->log2_ctb_size; | |
| 279 | 1724555 | int ctb_addr_rs = y_ctb * sps->ctb_width + x_ctb; | |
| 280 | 1724555 | int ctb_addr_ts = pps->ctb_addr_rs_to_ts[ctb_addr_rs]; | |
| 281 | 1724555 | SAOParams *sao = &CTB(l->sao, x_ctb, y_ctb); | |
| 282 | // flags indicating unfilterable edges | ||
| 283 | 1724555 | uint8_t vert_edge[] = { 0, 0 }; | |
| 284 | 1724555 | uint8_t horiz_edge[] = { 0, 0 }; | |
| 285 | 1724555 | uint8_t diag_edge[] = { 0, 0, 0, 0 }; | |
| 286 | 1724555 | uint8_t lfase = CTB(l->filter_slice_edges, x_ctb, y_ctb); | |
| 287 |
2/2✓ Branch 0 taken 545136 times.
✓ Branch 1 taken 1179419 times.
|
2269691 | uint8_t no_tile_filter = pps->tiles_enabled_flag && |
| 288 |
2/2✓ Branch 0 taken 14824 times.
✓ Branch 1 taken 530312 times.
|
545136 | !pps->loop_filter_across_tiles_enabled_flag; |
| 289 |
4/4✓ Branch 0 taken 1709731 times.
✓ Branch 1 taken 14824 times.
✓ Branch 2 taken 116844 times.
✓ Branch 3 taken 1592887 times.
|
1724555 | uint8_t restore = no_tile_filter || !lfase; |
| 290 | 1724555 | uint8_t left_tile_edge = 0; | |
| 291 | 1724555 | uint8_t right_tile_edge = 0; | |
| 292 | 1724555 | uint8_t up_tile_edge = 0; | |
| 293 | 1724555 | uint8_t bottom_tile_edge = 0; | |
| 294 | |||
| 295 | 1724555 | edges[0] = x_ctb == 0; | |
| 296 | 1724555 | edges[1] = y_ctb == 0; | |
| 297 | 1724555 | edges[2] = x_ctb == sps->ctb_width - 1; | |
| 298 | 1724555 | edges[3] = y_ctb == sps->ctb_height - 1; | |
| 299 | |||
| 300 |
2/2✓ Branch 0 taken 131668 times.
✓ Branch 1 taken 1592887 times.
|
1724555 | if (restore) { |
| 301 |
2/2✓ Branch 0 taken 126020 times.
✓ Branch 1 taken 5648 times.
|
131668 | if (!edges[0]) { |
| 302 |
4/4✓ Branch 0 taken 14448 times.
✓ Branch 1 taken 111572 times.
✓ Branch 2 taken 744 times.
✓ Branch 3 taken 13704 times.
|
126020 | left_tile_edge = no_tile_filter && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs-1]]; |
| 303 |
6/6✓ Branch 0 taken 111572 times.
✓ Branch 1 taken 14448 times.
✓ Branch 2 taken 111388 times.
✓ Branch 3 taken 184 times.
✓ Branch 4 taken 744 times.
✓ Branch 5 taken 125092 times.
|
126020 | vert_edge[0] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb - 1, y_ctb)) || left_tile_edge; |
| 304 | } | ||
| 305 |
2/2✓ Branch 0 taken 126021 times.
✓ Branch 1 taken 5647 times.
|
131668 | if (!edges[2]) { |
| 306 |
4/4✓ Branch 0 taken 14448 times.
✓ Branch 1 taken 111573 times.
✓ Branch 2 taken 744 times.
✓ Branch 3 taken 13704 times.
|
126021 | right_tile_edge = no_tile_filter && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs+1]]; |
| 307 |
6/6✓ Branch 0 taken 111573 times.
✓ Branch 1 taken 14448 times.
✓ Branch 2 taken 111389 times.
✓ Branch 3 taken 184 times.
✓ Branch 4 taken 744 times.
✓ Branch 5 taken 125093 times.
|
126021 | vert_edge[1] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb + 1, y_ctb)) || right_tile_edge; |
| 308 | } | ||
| 309 |
2/2✓ Branch 0 taken 121868 times.
✓ Branch 1 taken 9800 times.
|
131668 | if (!edges[1]) { |
| 310 |
4/4✓ Branch 0 taken 14171 times.
✓ Branch 1 taken 107697 times.
✓ Branch 2 taken 1280 times.
✓ Branch 3 taken 12891 times.
|
121868 | up_tile_edge = no_tile_filter && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs - sps->ctb_width]]; |
| 311 |
6/6✓ Branch 0 taken 107697 times.
✓ Branch 1 taken 14171 times.
✓ Branch 2 taken 106417 times.
✓ Branch 3 taken 1280 times.
✓ Branch 4 taken 1280 times.
✓ Branch 5 taken 119308 times.
|
121868 | horiz_edge[0] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb, y_ctb - 1)) || up_tile_edge; |
| 312 | } | ||
| 313 |
2/2✓ Branch 0 taken 121898 times.
✓ Branch 1 taken 9770 times.
|
131668 | if (!edges[3]) { |
| 314 |
4/4✓ Branch 0 taken 14171 times.
✓ Branch 1 taken 107727 times.
✓ Branch 2 taken 1280 times.
✓ Branch 3 taken 12891 times.
|
121898 | bottom_tile_edge = no_tile_filter && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs + sps->ctb_width]]; |
| 315 |
6/6✓ Branch 0 taken 107727 times.
✓ Branch 1 taken 14171 times.
✓ Branch 2 taken 106447 times.
✓ Branch 3 taken 1280 times.
✓ Branch 4 taken 1280 times.
✓ Branch 5 taken 119338 times.
|
121898 | horiz_edge[1] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb, y_ctb + 1)) || bottom_tile_edge; |
| 316 | } | ||
| 317 |
4/4✓ Branch 0 taken 126020 times.
✓ Branch 1 taken 5648 times.
✓ Branch 2 taken 117011 times.
✓ Branch 3 taken 9009 times.
|
131668 | if (!edges[0] && !edges[1]) { |
| 318 |
8/8✓ Branch 0 taken 103199 times.
✓ Branch 1 taken 13812 times.
✓ Branch 2 taken 101791 times.
✓ Branch 3 taken 1408 times.
✓ Branch 4 taken 114892 times.
✓ Branch 5 taken 711 times.
✓ Branch 6 taken 1184 times.
✓ Branch 7 taken 113708 times.
|
117011 | diag_edge[0] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb - 1, y_ctb - 1)) || left_tile_edge || up_tile_edge; |
| 319 | } | ||
| 320 |
4/4✓ Branch 0 taken 121868 times.
✓ Branch 1 taken 9800 times.
✓ Branch 2 taken 117012 times.
✓ Branch 3 taken 4856 times.
|
131668 | if (!edges[1] && !edges[2]) { |
| 321 |
8/8✓ Branch 0 taken 103200 times.
✓ Branch 1 taken 13812 times.
✓ Branch 2 taken 101792 times.
✓ Branch 3 taken 1408 times.
✓ Branch 4 taken 114893 times.
✓ Branch 5 taken 711 times.
✓ Branch 6 taken 1184 times.
✓ Branch 7 taken 113709 times.
|
117012 | diag_edge[1] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb + 1, y_ctb - 1)) || right_tile_edge || up_tile_edge; |
| 322 | } | ||
| 323 |
4/4✓ Branch 0 taken 126021 times.
✓ Branch 1 taken 5647 times.
✓ Branch 2 taken 117041 times.
✓ Branch 3 taken 8980 times.
|
131668 | if (!edges[2] && !edges[3]) { |
| 324 |
8/8✓ Branch 0 taken 103229 times.
✓ Branch 1 taken 13812 times.
✓ Branch 2 taken 101821 times.
✓ Branch 3 taken 1408 times.
✓ Branch 4 taken 114922 times.
✓ Branch 5 taken 711 times.
✓ Branch 6 taken 1184 times.
✓ Branch 7 taken 113738 times.
|
117041 | diag_edge[2] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb + 1, y_ctb + 1)) || right_tile_edge || bottom_tile_edge; |
| 325 | } | ||
| 326 |
4/4✓ Branch 0 taken 126020 times.
✓ Branch 1 taken 5648 times.
✓ Branch 2 taken 117040 times.
✓ Branch 3 taken 8980 times.
|
131668 | if (!edges[0] && !edges[3]) { |
| 327 |
8/8✓ Branch 0 taken 103228 times.
✓ Branch 1 taken 13812 times.
✓ Branch 2 taken 101820 times.
✓ Branch 3 taken 1408 times.
✓ Branch 4 taken 114921 times.
✓ Branch 5 taken 711 times.
✓ Branch 6 taken 1184 times.
✓ Branch 7 taken 113737 times.
|
117040 | diag_edge[3] = (!lfase && CTB(l->tab_slice_address, x_ctb, y_ctb) != CTB(l->tab_slice_address, x_ctb - 1, y_ctb + 1)) || left_tile_edge || bottom_tile_edge; |
| 328 | } | ||
| 329 | } | ||
| 330 | |||
| 331 |
4/4✓ Branch 0 taken 6898124 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 5173617 times.
✓ Branch 3 taken 1724555 times.
|
6898172 | for (c_idx = 0; c_idx < (sps->chroma_format_idc ? 3 : 1); c_idx++) { |
| 332 | 5173617 | int x0 = x >> sps->hshift[c_idx]; | |
| 333 | 5173617 | int y0 = y >> sps->vshift[c_idx]; | |
| 334 | 5173617 | ptrdiff_t stride_src = s->cur_frame->f->linesize[c_idx]; | |
| 335 | 5173617 | int ctb_size_h = (1 << (sps->log2_ctb_size)) >> sps->hshift[c_idx]; | |
| 336 | 5173617 | int ctb_size_v = (1 << (sps->log2_ctb_size)) >> sps->vshift[c_idx]; | |
| 337 | 5173617 | int width = FFMIN(ctb_size_h, (sps->width >> sps->hshift[c_idx]) - x0); | |
| 338 | 5173617 | int height = FFMIN(ctb_size_v, (sps->height >> sps->vshift[c_idx]) - y0); | |
| 339 | 5173617 | int tab = sao_tab[(FFALIGN(width, 8) >> 3) - 1]; | |
| 340 | 5173617 | uint8_t *src = &s->cur_frame->f->data[c_idx][y0 * stride_src + (x0 << sps->pixel_shift)]; | |
| 341 | ptrdiff_t stride_dst; | ||
| 342 | uint8_t *dst; | ||
| 343 | |||
| 344 |
3/3✓ Branch 0 taken 103414 times.
✓ Branch 1 taken 576995 times.
✓ Branch 2 taken 4493208 times.
|
5173617 | switch (sao->type_idx[c_idx]) { |
| 345 | 103414 | case SAO_BAND: | |
| 346 | 103414 | copy_CTB_to_hv(l, sps, src, stride_src, x0, y0, width, height, c_idx, | |
| 347 | x_ctb, y_ctb); | ||
| 348 |
2/2✓ Branch 0 taken 102900 times.
✓ Branch 1 taken 514 times.
|
103414 | if (pps->transquant_bypass_enable_flag || |
| 349 |
3/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 102896 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
102900 | (sps->pcm_loop_filter_disabled && sps->pcm_enabled)) { |
| 350 | 518 | dst = lc->edge_emu_buffer; | |
| 351 | 518 | stride_dst = 2*MAX_PB_SIZE; | |
| 352 | 518 | copy_CTB(dst, src, width << sps->pixel_shift, height, stride_dst, stride_src); | |
| 353 | 518 | s->hevcdsp.sao_band_filter[tab](src, dst, stride_src, stride_dst, | |
| 354 | 518 | sao->offset_val[c_idx], sao->band_position[c_idx], | |
| 355 | width, height); | ||
| 356 | 518 | restore_tqb_pixels(l, pps, sps, src, dst, stride_src, stride_dst, | |
| 357 | x, y, width, height, c_idx); | ||
| 358 | } else { | ||
| 359 | 102896 | s->hevcdsp.sao_band_filter[tab](src, src, stride_src, stride_src, | |
| 360 | 102896 | sao->offset_val[c_idx], sao->band_position[c_idx], | |
| 361 | width, height); | ||
| 362 | } | ||
| 363 | 103414 | sao->type_idx[c_idx] = SAO_APPLIED; | |
| 364 | 103414 | break; | |
| 365 | 576995 | case SAO_EDGE: | |
| 366 | { | ||
| 367 | 576995 | int w = sps->width >> sps->hshift[c_idx]; | |
| 368 | 576995 | int h = sps->height >> sps->vshift[c_idx]; | |
| 369 | 576995 | int left_edge = edges[0]; | |
| 370 | 576995 | int top_edge = edges[1]; | |
| 371 | 576995 | int right_edge = edges[2]; | |
| 372 | 576995 | int bottom_edge = edges[3]; | |
| 373 | 576995 | int sh = sps->pixel_shift; | |
| 374 | int left_pixels, right_pixels; | ||
| 375 | |||
| 376 | 576995 | stride_dst = 2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE; | |
| 377 | 576995 | dst = lc->edge_emu_buffer + stride_dst + AV_INPUT_BUFFER_PADDING_SIZE; | |
| 378 | |||
| 379 |
2/2✓ Branch 0 taken 550636 times.
✓ Branch 1 taken 26359 times.
|
576995 | if (!top_edge) { |
| 380 | 550636 | int left = 1 - left_edge; | |
| 381 | 550636 | int right = 1 - right_edge; | |
| 382 | const uint8_t *src1[2]; | ||
| 383 | uint8_t *dst1; | ||
| 384 | int src_idx, pos; | ||
| 385 | |||
| 386 | 550636 | dst1 = dst - stride_dst - (left << sh); | |
| 387 | 550636 | src1[0] = src - stride_src - (left << sh); | |
| 388 | 550636 | src1[1] = l->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb - 1) * w + x0 - left) << sh); | |
| 389 | 550636 | pos = 0; | |
| 390 |
2/2✓ Branch 0 taken 532609 times.
✓ Branch 1 taken 18027 times.
|
550636 | if (left) { |
| 391 | 532609 | src_idx = (CTB(l->sao, x_ctb-1, y_ctb-1).type_idx[c_idx] == | |
| 392 | SAO_APPLIED); | ||
| 393 | 532609 | copy_pixel(dst1, src1[src_idx], sh); | |
| 394 | 532609 | pos += (1 << sh); | |
| 395 | } | ||
| 396 | 550636 | src_idx = (CTB(l->sao, x_ctb, y_ctb-1).type_idx[c_idx] == | |
| 397 | SAO_APPLIED); | ||
| 398 | 550636 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); | |
| 399 |
2/2✓ Branch 0 taken 530321 times.
✓ Branch 1 taken 20315 times.
|
550636 | if (right) { |
| 400 | 530321 | pos += width << sh; | |
| 401 | 530321 | src_idx = (CTB(l->sao, x_ctb+1, y_ctb-1).type_idx[c_idx] == | |
| 402 | SAO_APPLIED); | ||
| 403 | 530321 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); | |
| 404 | } | ||
| 405 | } | ||
| 406 |
2/2✓ Branch 0 taken 544946 times.
✓ Branch 1 taken 32049 times.
|
576995 | if (!bottom_edge) { |
| 407 | 544946 | int left = 1 - left_edge; | |
| 408 | 544946 | int right = 1 - right_edge; | |
| 409 | const uint8_t *src1[2]; | ||
| 410 | uint8_t *dst1; | ||
| 411 | int src_idx, pos; | ||
| 412 | |||
| 413 | 544946 | dst1 = dst + height * stride_dst - (left << sh); | |
| 414 | 544946 | src1[0] = src + height * stride_src - (left << sh); | |
| 415 | 544946 | src1[1] = l->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 2) * w + x0 - left) << sh); | |
| 416 | 544946 | pos = 0; | |
| 417 |
2/2✓ Branch 0 taken 527552 times.
✓ Branch 1 taken 17394 times.
|
544946 | if (left) { |
| 418 | 527552 | src_idx = (CTB(l->sao, x_ctb-1, y_ctb+1).type_idx[c_idx] == | |
| 419 | SAO_APPLIED); | ||
| 420 | 527552 | copy_pixel(dst1, src1[src_idx], sh); | |
| 421 | 527552 | pos += (1 << sh); | |
| 422 | } | ||
| 423 | 544946 | src_idx = (CTB(l->sao, x_ctb, y_ctb+1).type_idx[c_idx] == | |
| 424 | SAO_APPLIED); | ||
| 425 | 544946 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); | |
| 426 |
2/2✓ Branch 0 taken 525047 times.
✓ Branch 1 taken 19899 times.
|
544946 | if (right) { |
| 427 | 525047 | pos += width << sh; | |
| 428 | 525047 | src_idx = (CTB(l->sao, x_ctb+1, y_ctb+1).type_idx[c_idx] == | |
| 429 | SAO_APPLIED); | ||
| 430 | 525047 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); | |
| 431 | } | ||
| 432 | } | ||
| 433 | 576995 | left_pixels = 0; | |
| 434 |
2/2✓ Branch 0 taken 557107 times.
✓ Branch 1 taken 19888 times.
|
576995 | if (!left_edge) { |
| 435 |
2/2✓ Branch 0 taken 479367 times.
✓ Branch 1 taken 77740 times.
|
557107 | if (CTB(l->sao, x_ctb-1, y_ctb).type_idx[c_idx] == SAO_APPLIED) { |
| 436 | 479367 | copy_vert(dst - (1 << sh), | |
| 437 | 479367 | l->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb - 1) * h + y0) << sh), | |
| 438 | 479367 | sh, height, stride_dst, 1 << sh); | |
| 439 | } else { | ||
| 440 | 77740 | left_pixels = 1; | |
| 441 | } | ||
| 442 | } | ||
| 443 | 576995 | right_pixels = 0; | |
| 444 |
2/2✓ Branch 0 taken 554675 times.
✓ Branch 1 taken 22320 times.
|
576995 | if (!right_edge) { |
| 445 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 554675 times.
|
554675 | if (CTB(l->sao, x_ctb+1, y_ctb).type_idx[c_idx] == SAO_APPLIED) { |
| 446 | ✗ | copy_vert(dst + (width << sh), | |
| 447 | ✗ | l->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 2) * h + y0) << sh), | |
| 448 | ✗ | sh, height, stride_dst, 1 << sh); | |
| 449 | } else { | ||
| 450 | 554675 | right_pixels = 1; | |
| 451 | } | ||
| 452 | } | ||
| 453 | |||
| 454 | 576995 | copy_CTB(dst - (left_pixels << sh), | |
| 455 | 576995 | src - (left_pixels << sh), | |
| 456 | 576995 | (width + left_pixels + right_pixels) << sh, | |
| 457 | height, stride_dst, stride_src); | ||
| 458 | |||
| 459 | 576995 | copy_CTB_to_hv(l, sps, src, stride_src, x0, y0, width, height, c_idx, | |
| 460 | x_ctb, y_ctb); | ||
| 461 | 576995 | s->hevcdsp.sao_edge_filter[tab](src, dst, stride_src, sao->offset_val[c_idx], | |
| 462 | sao->eo_class[c_idx], width, height); | ||
| 463 | 576995 | s->hevcdsp.sao_edge_restore[restore](src, dst, | |
| 464 | stride_src, stride_dst, | ||
| 465 | sao, | ||
| 466 | edges, width, | ||
| 467 | height, c_idx, | ||
| 468 | vert_edge, | ||
| 469 | horiz_edge, | ||
| 470 | diag_edge); | ||
| 471 | 576995 | restore_tqb_pixels(l, pps, sps, src, dst, stride_src, stride_dst, | |
| 472 | x, y, width, height, c_idx); | ||
| 473 | 576995 | sao->type_idx[c_idx] = SAO_APPLIED; | |
| 474 | 576995 | break; | |
| 475 | } | ||
| 476 | } | ||
| 477 | } | ||
| 478 | 1724555 | } | |
| 479 | |||
| 480 | 1729548 | static int get_pcm(const HEVCSPS *sps, const uint8_t *is_pcm, int x, int y) | |
| 481 | { | ||
| 482 | 1729548 | int log2_min_pu_size = sps->log2_min_pu_size; | |
| 483 | int x_pu, y_pu; | ||
| 484 | |||
| 485 |
2/4✓ Branch 0 taken 1729548 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1729548 times.
|
1729548 | if (x < 0 || y < 0) |
| 486 | ✗ | return 2; | |
| 487 | |||
| 488 | 1729548 | x_pu = x >> log2_min_pu_size; | |
| 489 | 1729548 | y_pu = y >> log2_min_pu_size; | |
| 490 | |||
| 491 |
3/4✓ Branch 0 taken 1729548 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 932 times.
✓ Branch 3 taken 1728616 times.
|
1729548 | if (x_pu >= sps->min_pu_width || y_pu >= sps->min_pu_height) |
| 492 | 932 | return 2; | |
| 493 | 1728616 | return is_pcm[y_pu * sps->min_pu_width + x_pu]; | |
| 494 | } | ||
| 495 | |||
| 496 | #define TC_CALC(qp, bs) \ | ||
| 497 | tctable[av_clip((qp) + DEFAULT_INTRA_TC_OFFSET * ((bs) - 1) + \ | ||
| 498 | (tc_offset & -2), \ | ||
| 499 | 0, MAX_QP + DEFAULT_INTRA_TC_OFFSET)] | ||
| 500 | |||
| 501 | 1991882 | static void deblocking_filter_CTB(const HEVCContext *s, const HEVCLayerContext *l, | |
| 502 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 503 | int x0, int y0) | ||
| 504 | { | ||
| 505 | 1991882 | uint8_t **data = s->cur_frame->f->data; | |
| 506 | 1991882 | int *linesize = s->cur_frame->f->linesize; | |
| 507 | |||
| 508 | uint8_t *src; | ||
| 509 | int x, y; | ||
| 510 | int chroma, beta; | ||
| 511 | int32_t c_tc[2], tc[2]; | ||
| 512 | 1991882 | uint8_t no_p[2] = { 0 }; | |
| 513 | 1991882 | uint8_t no_q[2] = { 0 }; | |
| 514 | |||
| 515 | 1991882 | int log2_ctb_size = sps->log2_ctb_size; | |
| 516 | int x_end, x_end2, y_end; | ||
| 517 | 1991882 | int ctb_size = 1 << log2_ctb_size; | |
| 518 | 1991882 | int ctb = (x0 >> log2_ctb_size) + | |
| 519 | 1991882 | (y0 >> log2_ctb_size) * sps->ctb_width; | |
| 520 | 1991882 | int cur_tc_offset = l->deblock[ctb].tc_offset; | |
| 521 | 1991882 | int cur_beta_offset = l->deblock[ctb].beta_offset; | |
| 522 | int left_tc_offset, left_beta_offset; | ||
| 523 | int tc_offset, beta_offset; | ||
| 524 | 4065552 | int pcmf = (sps->pcm_enabled && | |
| 525 |
4/4✓ Branch 0 taken 81788 times.
✓ Branch 1 taken 1910094 times.
✓ Branch 2 taken 81760 times.
✓ Branch 3 taken 28 times.
|
3983736 | sps->pcm_loop_filter_disabled) || |
| 526 |
2/2✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 1987702 times.
|
1991854 | pps->transquant_bypass_enable_flag; |
| 527 | |||
| 528 |
2/2✓ Branch 0 taken 1903308 times.
✓ Branch 1 taken 88574 times.
|
1991882 | if (x0) { |
| 529 | 1903308 | left_tc_offset = l->deblock[ctb - 1].tc_offset; | |
| 530 | 1903308 | left_beta_offset = l->deblock[ctb - 1].beta_offset; | |
| 531 | } else { | ||
| 532 | 88574 | left_tc_offset = 0; | |
| 533 | 88574 | left_beta_offset = 0; | |
| 534 | } | ||
| 535 | |||
| 536 | 1991882 | x_end = x0 + ctb_size; | |
| 537 |
2/2✓ Branch 0 taken 25100 times.
✓ Branch 1 taken 1966782 times.
|
1991882 | if (x_end > sps->width) |
| 538 | 25100 | x_end = sps->width; | |
| 539 | 1991882 | y_end = y0 + ctb_size; | |
| 540 |
2/2✓ Branch 0 taken 100062 times.
✓ Branch 1 taken 1891820 times.
|
1991882 | if (y_end > sps->height) |
| 541 | 100062 | y_end = sps->height; | |
| 542 | |||
| 543 | 1991882 | tc_offset = cur_tc_offset; | |
| 544 | 1991882 | beta_offset = cur_beta_offset; | |
| 545 | |||
| 546 | 1991882 | x_end2 = x_end; | |
| 547 |
2/2✓ Branch 0 taken 1903309 times.
✓ Branch 1 taken 88573 times.
|
1991882 | if (x_end2 != sps->width) |
| 548 | 1903309 | x_end2 -= 8; | |
| 549 |
2/2✓ Branch 0 taken 12997276 times.
✓ Branch 1 taken 1991882 times.
|
14989158 | for (y = y0; y < y_end; y += 8) { |
| 550 | // vertical filtering luma | ||
| 551 |
4/4✓ Branch 0 taken 12374343 times.
✓ Branch 1 taken 622933 times.
✓ Branch 2 taken 92779883 times.
✓ Branch 3 taken 12997276 times.
|
105777159 | for (x = x0 ? x0 : 8; x < x_end; x += 8) { |
| 552 | 92779883 | const int bs0 = l->vertical_bs[(x + y * l->bs_width) >> 2]; | |
| 553 | 92779883 | const int bs1 = l->vertical_bs[(x + (y + 4) * l->bs_width) >> 2]; | |
| 554 |
4/4✓ Branch 0 taken 72508442 times.
✓ Branch 1 taken 20271441 times.
✓ Branch 2 taken 94758 times.
✓ Branch 3 taken 72413684 times.
|
92779883 | if (bs0 || bs1) { |
| 555 | 20366199 | const int qp = (get_qPy(sps, l->qp_y_tab, x - 1, y) + | |
| 556 | 20366199 | get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1; | |
| 557 | |||
| 558 | 20366199 | beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)]; | |
| 559 | |||
| 560 |
2/2✓ Branch 0 taken 20271441 times.
✓ Branch 1 taken 94758 times.
|
20366199 | tc[0] = bs0 ? TC_CALC(qp, bs0) : 0; |
| 561 |
2/2✓ Branch 0 taken 20264251 times.
✓ Branch 1 taken 101948 times.
|
20366199 | tc[1] = bs1 ? TC_CALC(qp, bs1) : 0; |
| 562 | 20366199 | src = &data[LUMA][y * linesize[LUMA] + (x << sps->pixel_shift)]; | |
| 563 |
2/2✓ Branch 0 taken 162338 times.
✓ Branch 1 taken 20203861 times.
|
20366199 | if (pcmf) { |
| 564 | 162338 | no_p[0] = get_pcm(sps, l->is_pcm, x - 1, y); | |
| 565 | 162338 | no_p[1] = get_pcm(sps, l->is_pcm, x - 1, y + 4); | |
| 566 | 162338 | no_q[0] = get_pcm(sps, l->is_pcm, x, y); | |
| 567 | 162338 | no_q[1] = get_pcm(sps, l->is_pcm, x, y + 4); | |
| 568 | 162338 | s->hevcdsp.hevc_v_loop_filter_luma_c(src, linesize[LUMA], | |
| 569 | beta, tc, no_p, no_q); | ||
| 570 | } else | ||
| 571 | 20203861 | s->hevcdsp.hevc_v_loop_filter_luma(src, linesize[LUMA], | |
| 572 | beta, tc, no_p, no_q); | ||
| 573 | } | ||
| 574 | } | ||
| 575 | |||
| 576 |
2/2✓ Branch 0 taken 141357 times.
✓ Branch 1 taken 12855919 times.
|
12997276 | if(!y) |
| 577 | 141357 | continue; | |
| 578 | |||
| 579 | // horizontal filtering luma | ||
| 580 |
4/4✓ Branch 0 taken 12243457 times.
✓ Branch 1 taken 612462 times.
✓ Branch 2 taken 92394520 times.
✓ Branch 3 taken 12855919 times.
|
105250439 | for (x = x0 ? x0 - 8 : 0; x < x_end2; x += 8) { |
| 581 | 92394520 | const int bs0 = l->horizontal_bs[( x + y * l->bs_width) >> 2]; | |
| 582 | 92394520 | const int bs1 = l->horizontal_bs[((x + 4) + y * l->bs_width) >> 2]; | |
| 583 |
4/4✓ Branch 0 taken 71763388 times.
✓ Branch 1 taken 20631132 times.
✓ Branch 2 taken 112245 times.
✓ Branch 3 taken 71651143 times.
|
92394520 | if (bs0 || bs1) { |
| 584 | 20743377 | const int qp = (get_qPy(sps, l->qp_y_tab, x, y - 1) + | |
| 585 | 20743377 | get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1; | |
| 586 | |||
| 587 |
2/2✓ Branch 0 taken 17885210 times.
✓ Branch 1 taken 2858167 times.
|
20743377 | tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset; |
| 588 |
2/2✓ Branch 0 taken 17885210 times.
✓ Branch 1 taken 2858167 times.
|
20743377 | beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset; |
| 589 | |||
| 590 | 20743377 | beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)]; | |
| 591 |
2/2✓ Branch 0 taken 20631132 times.
✓ Branch 1 taken 112245 times.
|
20743377 | tc[0] = bs0 ? TC_CALC(qp, bs0) : 0; |
| 592 |
2/2✓ Branch 0 taken 20616173 times.
✓ Branch 1 taken 127204 times.
|
20743377 | tc[1] = bs1 ? TC_CALC(qp, bs1) : 0; |
| 593 | 20743377 | src = &data[LUMA][y * linesize[LUMA] + (x << sps->pixel_shift)]; | |
| 594 |
2/2✓ Branch 0 taken 163973 times.
✓ Branch 1 taken 20579404 times.
|
20743377 | if (pcmf) { |
| 595 | 163973 | no_p[0] = get_pcm(sps, l->is_pcm, x, y - 1); | |
| 596 | 163973 | no_p[1] = get_pcm(sps, l->is_pcm, x + 4, y - 1); | |
| 597 | 163973 | no_q[0] = get_pcm(sps, l->is_pcm, x, y); | |
| 598 | 163973 | no_q[1] = get_pcm(sps, l->is_pcm, x + 4, y); | |
| 599 | 163973 | s->hevcdsp.hevc_h_loop_filter_luma_c(src, linesize[LUMA], | |
| 600 | beta, tc, no_p, no_q); | ||
| 601 | } else | ||
| 602 | 20579404 | s->hevcdsp.hevc_h_loop_filter_luma(src, linesize[LUMA], | |
| 603 | beta, tc, no_p, no_q); | ||
| 604 | } | ||
| 605 | } | ||
| 606 | } | ||
| 607 | |||
| 608 |
2/2✓ Branch 0 taken 1991858 times.
✓ Branch 1 taken 24 times.
|
1991882 | if (sps->chroma_format_idc) { |
| 609 |
2/2✓ Branch 0 taken 3983716 times.
✓ Branch 1 taken 1991858 times.
|
5975574 | for (chroma = 1; chroma <= 2; chroma++) { |
| 610 | 3983716 | int h = 1 << sps->hshift[chroma]; | |
| 611 | 3983716 | int v = 1 << sps->vshift[chroma]; | |
| 612 | |||
| 613 | // vertical filtering chroma | ||
| 614 |
2/2✓ Branch 0 taken 13412496 times.
✓ Branch 1 taken 3983716 times.
|
17396212 | for (y = y0; y < y_end; y += (8 * v)) { |
| 615 |
4/4✓ Branch 0 taken 635108 times.
✓ Branch 1 taken 12777388 times.
✓ Branch 2 taken 48473228 times.
✓ Branch 3 taken 13412496 times.
|
61885724 | for (x = x0 ? x0 : 8 * h; x < x_end; x += (8 * h)) { |
| 616 | 48473228 | const int bs0 = l->vertical_bs[(x + y * l->bs_width) >> 2]; | |
| 617 | 48473228 | const int bs1 = l->vertical_bs[(x + (y + (4 * v)) * l->bs_width) >> 2]; | |
| 618 | |||
| 619 |
4/4✓ Branch 0 taken 43076134 times.
✓ Branch 1 taken 5397094 times.
✓ Branch 2 taken 195384 times.
✓ Branch 3 taken 42880750 times.
|
48473228 | if ((bs0 == 2) || (bs1 == 2)) { |
| 620 | 5592478 | const int qp0 = (get_qPy(sps, l->qp_y_tab, x - 1, y) + | |
| 621 | 5592478 | get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1; | |
| 622 | 5592478 | const int qp1 = (get_qPy(sps, l->qp_y_tab, x - 1, y + (4 * v)) + | |
| 623 | 5592478 | get_qPy(sps, l->qp_y_tab, x, y + (4 * v)) + 1) >> 1; | |
| 624 | |||
| 625 |
2/2✓ Branch 0 taken 5397094 times.
✓ Branch 1 taken 195384 times.
|
5592478 | c_tc[0] = (bs0 == 2) ? chroma_tc(pps, sps, qp0, chroma, tc_offset) : 0; |
| 626 |
2/2✓ Branch 0 taken 5409950 times.
✓ Branch 1 taken 182528 times.
|
5592478 | c_tc[1] = (bs1 == 2) ? chroma_tc(pps, sps, qp1, chroma, tc_offset) : 0; |
| 627 | 5592478 | src = &data[chroma][(y >> sps->vshift[chroma]) * linesize[chroma] + ((x >> sps->hshift[chroma]) << sps->pixel_shift)]; | |
| 628 |
2/2✓ Branch 0 taken 53552 times.
✓ Branch 1 taken 5538926 times.
|
5592478 | if (pcmf) { |
| 629 | 53552 | no_p[0] = get_pcm(sps, l->is_pcm, x - 1, y); | |
| 630 | 53552 | no_p[1] = get_pcm(sps, l->is_pcm, x - 1, y + (4 * v)); | |
| 631 | 53552 | no_q[0] = get_pcm(sps, l->is_pcm, x, y); | |
| 632 | 53552 | no_q[1] = get_pcm(sps, l->is_pcm, x, y + (4 * v)); | |
| 633 | 53552 | s->hevcdsp.hevc_v_loop_filter_chroma_c(src, linesize[chroma], | |
| 634 | c_tc, no_p, no_q); | ||
| 635 | } else | ||
| 636 | 5538926 | s->hevcdsp.hevc_v_loop_filter_chroma(src, linesize[chroma], | |
| 637 | c_tc, no_p, no_q); | ||
| 638 | } | ||
| 639 | } | ||
| 640 | |||
| 641 |
2/2✓ Branch 0 taken 282702 times.
✓ Branch 1 taken 13129794 times.
|
13412496 | if(!y) |
| 642 | 282702 | continue; | |
| 643 | |||
| 644 | // horizontal filtering chroma | ||
| 645 |
2/2✓ Branch 0 taken 12515626 times.
✓ Branch 1 taken 614168 times.
|
13129794 | tc_offset = x0 ? left_tc_offset : cur_tc_offset; |
| 646 | 13129794 | x_end2 = x_end; | |
| 647 |
2/2✓ Branch 0 taken 12515634 times.
✓ Branch 1 taken 614160 times.
|
13129794 | if (x_end != sps->width) |
| 648 | 12515634 | x_end2 = x_end - 8 * h; | |
| 649 |
4/4✓ Branch 0 taken 12515626 times.
✓ Branch 1 taken 614168 times.
✓ Branch 2 taken 48094048 times.
✓ Branch 3 taken 13129794 times.
|
61223842 | for (x = x0 ? x0 - 8 * h : 0; x < x_end2; x += (8 * h)) { |
| 650 | 48094048 | const int bs0 = l->horizontal_bs[( x + y * l->bs_width) >> 2]; | |
| 651 | 48094048 | const int bs1 = l->horizontal_bs[((x + 4 * h) + y * l->bs_width) >> 2]; | |
| 652 |
4/4✓ Branch 0 taken 42940460 times.
✓ Branch 1 taken 5153588 times.
✓ Branch 2 taken 199574 times.
✓ Branch 3 taken 42740886 times.
|
48094048 | if ((bs0 == 2) || (bs1 == 2)) { |
| 653 | 5153588 | const int qp0 = bs0 == 2 ? (get_qPy(sps, l->qp_y_tab, x, y - 1) + | |
| 654 |
2/2✓ Branch 0 taken 5153588 times.
✓ Branch 1 taken 199574 times.
|
10506750 | get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1 : 0; |
| 655 | 5162766 | const int qp1 = bs1 == 2 ? (get_qPy(sps, l->qp_y_tab, x + (4 * h), y - 1) + | |
| 656 |
2/2✓ Branch 0 taken 5162766 times.
✓ Branch 1 taken 190396 times.
|
10515928 | get_qPy(sps, l->qp_y_tab, x + (4 * h), y) + 1) >> 1 : 0; |
| 657 | |||
| 658 |
2/2✓ Branch 0 taken 5153588 times.
✓ Branch 1 taken 199574 times.
|
5353162 | c_tc[0] = bs0 == 2 ? chroma_tc(pps, sps, qp0, chroma, tc_offset) : 0; |
| 659 |
2/2✓ Branch 0 taken 5162766 times.
✓ Branch 1 taken 190396 times.
|
5353162 | c_tc[1] = bs1 == 2 ? chroma_tc(pps, sps, qp1, chroma, cur_tc_offset) : 0; |
| 660 | 5353162 | src = &data[chroma][(y >> sps->vshift[1]) * linesize[chroma] + ((x >> sps->hshift[1]) << sps->pixel_shift)]; | |
| 661 |
2/2✓ Branch 0 taken 52524 times.
✓ Branch 1 taken 5300638 times.
|
5353162 | if (pcmf) { |
| 662 | 52524 | no_p[0] = get_pcm(sps, l->is_pcm, x, y - 1); | |
| 663 | 52524 | no_p[1] = get_pcm(sps, l->is_pcm, x + (4 * h), y - 1); | |
| 664 | 52524 | no_q[0] = get_pcm(sps, l->is_pcm, x, y); | |
| 665 | 52524 | no_q[1] = get_pcm(sps, l->is_pcm, x + (4 * h), y); | |
| 666 | 52524 | s->hevcdsp.hevc_h_loop_filter_chroma_c(src, linesize[chroma], | |
| 667 | c_tc, no_p, no_q); | ||
| 668 | } else | ||
| 669 | 5300638 | s->hevcdsp.hevc_h_loop_filter_chroma(src, linesize[chroma], | |
| 670 | c_tc, no_p, no_q); | ||
| 671 | } | ||
| 672 | } | ||
| 673 | } | ||
| 674 | } | ||
| 675 | } | ||
| 676 | 1991882 | } | |
| 677 | |||
| 678 | 283342892 | static int boundary_strength(const HEVCContext *s, const MvField *curr, const MvField *neigh, | |
| 679 | const RefPicList *neigh_refPicList) | ||
| 680 | { | ||
| 681 |
4/4✓ Branch 0 taken 161523794 times.
✓ Branch 1 taken 121819098 times.
✓ Branch 2 taken 156916950 times.
✓ Branch 3 taken 4606844 times.
|
283342892 | if (curr->pred_flag == PF_BI && neigh->pred_flag == PF_BI) { |
| 682 | // same L0 and L1 | ||
| 683 |
2/2✓ Branch 0 taken 155122465 times.
✓ Branch 1 taken 1794485 times.
|
156916950 | if (s->cur_frame->refPicList[0].list[curr->ref_idx[0]] == neigh_refPicList[0].list[neigh->ref_idx[0]] && |
| 684 |
2/2✓ Branch 0 taken 19763541 times.
✓ Branch 1 taken 135358924 times.
|
155122465 | s->cur_frame->refPicList[0].list[curr->ref_idx[0]] == s->cur_frame->refPicList[1].list[curr->ref_idx[1]] && |
| 685 |
2/2✓ Branch 0 taken 19615565 times.
✓ Branch 1 taken 147976 times.
|
19763541 | neigh_refPicList[0].list[neigh->ref_idx[0]] == neigh_refPicList[1].list[neigh->ref_idx[1]]) { |
| 686 |
4/4✓ Branch 0 taken 19303511 times.
✓ Branch 1 taken 312054 times.
✓ Branch 2 taken 19225592 times.
✓ Branch 3 taken 77919 times.
|
19615565 | if ((FFABS(neigh->mv[0].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 4 || |
| 687 |
4/4✓ Branch 0 taken 19162846 times.
✓ Branch 1 taken 62746 times.
✓ Branch 2 taken 14791 times.
✓ Branch 3 taken 19148055 times.
|
19225592 | FFABS(neigh->mv[1].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 4) && |
| 688 |
4/4✓ Branch 0 taken 191635 times.
✓ Branch 1 taken 275875 times.
✓ Branch 2 taken 126031 times.
✓ Branch 3 taken 65604 times.
|
467510 | (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 4 || |
| 689 |
4/4✓ Branch 0 taken 47296 times.
✓ Branch 1 taken 78735 times.
✓ Branch 2 taken 23641 times.
✓ Branch 3 taken 23655 times.
|
126031 | FFABS(neigh->mv[0].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[1].y) >= 4)) |
| 690 | 443855 | return 1; | |
| 691 | else | ||
| 692 | 19171710 | return 0; | |
| 693 |
2/2✓ Branch 0 taken 135506900 times.
✓ Branch 1 taken 1794485 times.
|
137301385 | } else if (neigh_refPicList[0].list[neigh->ref_idx[0]] == s->cur_frame->refPicList[0].list[curr->ref_idx[0]] && |
| 694 |
2/2✓ Branch 0 taken 134895210 times.
✓ Branch 1 taken 611690 times.
|
135506900 | neigh_refPicList[1].list[neigh->ref_idx[1]] == s->cur_frame->refPicList[1].list[curr->ref_idx[1]]) { |
| 695 |
4/4✓ Branch 0 taken 131058202 times.
✓ Branch 1 taken 3837008 times.
✓ Branch 2 taken 130145600 times.
✓ Branch 3 taken 912602 times.
|
134895210 | if (FFABS(neigh->mv[0].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 4 || |
| 696 |
4/4✓ Branch 0 taken 129639097 times.
✓ Branch 1 taken 506503 times.
✓ Branch 2 taken 162606 times.
✓ Branch 3 taken 129476491 times.
|
130145600 | FFABS(neigh->mv[1].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 4) |
| 697 | 5418719 | return 1; | |
| 698 | else | ||
| 699 | 129476491 | return 0; | |
| 700 |
2/2✓ Branch 0 taken 741301 times.
✓ Branch 1 taken 1664874 times.
|
2406175 | } else if (neigh_refPicList[1].list[neigh->ref_idx[1]] == s->cur_frame->refPicList[0].list[curr->ref_idx[0]] && |
| 701 |
2/2✓ Branch 0 taken 161113 times.
✓ Branch 1 taken 580188 times.
|
741301 | neigh_refPicList[0].list[neigh->ref_idx[0]] == s->cur_frame->refPicList[1].list[curr->ref_idx[1]]) { |
| 702 |
4/4✓ Branch 0 taken 105771 times.
✓ Branch 1 taken 55342 times.
✓ Branch 2 taken 92108 times.
✓ Branch 3 taken 13663 times.
|
161113 | if (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 4 || |
| 703 |
4/4✓ Branch 0 taken 83453 times.
✓ Branch 1 taken 8655 times.
✓ Branch 2 taken 3128 times.
✓ Branch 3 taken 80325 times.
|
92108 | FFABS(neigh->mv[0].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[0].y - curr->mv[1].y) >= 4) |
| 704 | 80788 | return 1; | |
| 705 | else | ||
| 706 | 80325 | return 0; | |
| 707 | } else { | ||
| 708 | 2245062 | return 1; | |
| 709 | } | ||
| 710 |
4/4✓ Branch 0 taken 121819098 times.
✓ Branch 1 taken 4606844 times.
✓ Branch 2 taken 117220842 times.
✓ Branch 3 taken 4598256 times.
|
126425942 | } else if ((curr->pred_flag != PF_BI) && (neigh->pred_flag != PF_BI)){ // 1 MV |
| 711 | Mv A, B; | ||
| 712 | int ref_A, ref_B; | ||
| 713 | |||
| 714 |
2/2✓ Branch 0 taken 104103050 times.
✓ Branch 1 taken 13117792 times.
|
117220842 | if (curr->pred_flag & 1) { |
| 715 | 104103050 | A = curr->mv[0]; | |
| 716 | 104103050 | ref_A = s->cur_frame->refPicList[0].list[curr->ref_idx[0]]; | |
| 717 | } else { | ||
| 718 | 13117792 | A = curr->mv[1]; | |
| 719 | 13117792 | ref_A = s->cur_frame->refPicList[1].list[curr->ref_idx[1]]; | |
| 720 | } | ||
| 721 | |||
| 722 |
2/2✓ Branch 0 taken 104119322 times.
✓ Branch 1 taken 13101520 times.
|
117220842 | if (neigh->pred_flag & 1) { |
| 723 | 104119322 | B = neigh->mv[0]; | |
| 724 | 104119322 | ref_B = neigh_refPicList[0].list[neigh->ref_idx[0]]; | |
| 725 | } else { | ||
| 726 | 13101520 | B = neigh->mv[1]; | |
| 727 | 13101520 | ref_B = neigh_refPicList[1].list[neigh->ref_idx[1]]; | |
| 728 | } | ||
| 729 | |||
| 730 |
2/2✓ Branch 0 taken 112715731 times.
✓ Branch 1 taken 4505111 times.
|
117220842 | if (ref_A == ref_B) { |
| 731 |
4/4✓ Branch 0 taken 109417069 times.
✓ Branch 1 taken 3298662 times.
✓ Branch 2 taken 1202966 times.
✓ Branch 3 taken 108214103 times.
|
112715731 | if (FFABS(A.x - B.x) >= 4 || FFABS(A.y - B.y) >= 4) |
| 732 | 4501628 | return 1; | |
| 733 | else | ||
| 734 | 108214103 | return 0; | |
| 735 | } else | ||
| 736 | 4505111 | return 1; | |
| 737 | } | ||
| 738 | |||
| 739 | 9205100 | return 1; | |
| 740 | } | ||
| 741 | |||
| 742 | 21201458 | void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayerContext *l, | |
| 743 | const HEVCPPS *pps, | ||
| 744 | int x0, int y0, int log2_trafo_size) | ||
| 745 | { | ||
| 746 | 21201458 | const HEVCSPS *const sps = pps->sps; | |
| 747 | 21201458 | const HEVCContext *s = lc->parent; | |
| 748 | 21201458 | const MvField *tab_mvf = s->cur_frame->tab_mvf; | |
| 749 | 21201458 | int log2_min_pu_size = sps->log2_min_pu_size; | |
| 750 | 21201458 | int log2_min_tu_size = sps->log2_min_tb_size; | |
| 751 | 21201458 | int min_pu_width = sps->min_pu_width; | |
| 752 | 21201458 | int min_tu_width = sps->min_tb_width; | |
| 753 | 21201458 | int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width + | |
| 754 | 21201458 | (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA; | |
| 755 | int boundary_upper, boundary_left; | ||
| 756 | int i, j, bs; | ||
| 757 | |||
| 758 |
4/4✓ Branch 0 taken 20877828 times.
✓ Branch 1 taken 323630 times.
✓ Branch 2 taken 17010892 times.
✓ Branch 3 taken 3866936 times.
|
21201458 | boundary_upper = y0 > 0 && !(y0 & 7); |
| 759 |
2/2✓ Branch 0 taken 17010892 times.
✓ Branch 1 taken 4190566 times.
|
21201458 | if (boundary_upper && |
| 760 |
2/2✓ Branch 0 taken 2115920 times.
✓ Branch 1 taken 14894972 times.
|
17010892 | ((!s->sh.slice_loop_filter_across_slices_enabled_flag && |
| 761 |
2/2✓ Branch 0 taken 481682 times.
✓ Branch 1 taken 1634238 times.
|
2115920 | lc->boundary_flags & BOUNDARY_UPPER_SLICE && |
| 762 |
2/2✓ Branch 0 taken 423697 times.
✓ Branch 1 taken 57985 times.
|
481682 | (y0 % (1 << sps->log2_ctb_size)) == 0) || |
| 763 |
4/4✓ Branch 0 taken 16376353 times.
✓ Branch 1 taken 576554 times.
✓ Branch 2 taken 224293 times.
✓ Branch 3 taken 16152060 times.
|
16952907 | ((!pps->loop_filter_across_tiles_enabled_flag || lc->tile_bs_defer) && |
| 764 |
2/2✓ Branch 0 taken 230823 times.
✓ Branch 1 taken 570024 times.
|
800847 | lc->boundary_flags & BOUNDARY_UPPER_TILE && |
| 765 |
2/2✓ Branch 0 taken 46638 times.
✓ Branch 1 taken 184185 times.
|
230823 | (y0 % (1 << sps->log2_ctb_size)) == 0))) |
| 766 | 104623 | boundary_upper = 0; | |
| 767 | |||
| 768 |
2/2✓ Branch 0 taken 16906269 times.
✓ Branch 1 taken 4295189 times.
|
21201458 | if (boundary_upper) { |
| 769 | 33812538 | const RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ? | |
| 770 |
2/2✓ Branch 0 taken 2024378 times.
✓ Branch 1 taken 14881891 times.
|
16906269 | ff_hevc_get_ref_list(s->cur_frame, x0, y0 - 1) : |
| 771 | 14881891 | s->cur_frame->refPicList; | |
| 772 | 16906269 | int yp_pu = (y0 - 1) >> log2_min_pu_size; | |
| 773 | 16906269 | int yq_pu = y0 >> log2_min_pu_size; | |
| 774 | 16906269 | int yp_tu = (y0 - 1) >> log2_min_tu_size; | |
| 775 | 16906269 | int yq_tu = y0 >> log2_min_tu_size; | |
| 776 | |||
| 777 |
2/2✓ Branch 0 taken 56383364 times.
✓ Branch 1 taken 16906269 times.
|
73289633 | for (i = 0; i < (1 << log2_trafo_size); i += 4) { |
| 778 | 56383364 | int x_pu = (x0 + i) >> log2_min_pu_size; | |
| 779 | 56383364 | int x_tu = (x0 + i) >> log2_min_tu_size; | |
| 780 | 56383364 | const MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; | |
| 781 | 56383364 | const MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; | |
| 782 | 56383364 | uint8_t top_cbf_luma = l->cbf_luma[yp_tu * min_tu_width + x_tu]; | |
| 783 | 56383364 | uint8_t curr_cbf_luma = l->cbf_luma[yq_tu * min_tu_width + x_tu]; | |
| 784 | |||
| 785 |
4/4✓ Branch 0 taken 44299374 times.
✓ Branch 1 taken 12083990 times.
✓ Branch 2 taken 1612832 times.
✓ Branch 3 taken 42686542 times.
|
56383364 | if (curr->pred_flag == PF_INTRA || top->pred_flag == PF_INTRA) |
| 786 | 13696822 | bs = 2; | |
| 787 |
4/4✓ Branch 0 taken 32696553 times.
✓ Branch 1 taken 9989989 times.
✓ Branch 2 taken 3918113 times.
✓ Branch 3 taken 28778440 times.
|
42686542 | else if (curr_cbf_luma || top_cbf_luma) |
| 788 | 13908102 | bs = 1; | |
| 789 | else | ||
| 790 | 28778440 | bs = boundary_strength(s, curr, top, rpl_top); | |
| 791 | 56383364 | l->horizontal_bs[((x0 + i) + y0 * l->bs_width) >> 2] = bs; | |
| 792 | } | ||
| 793 | } | ||
| 794 | |||
| 795 | // bs for vertical TU boundaries | ||
| 796 |
4/4✓ Branch 0 taken 20979114 times.
✓ Branch 1 taken 222344 times.
✓ Branch 2 taken 17112178 times.
✓ Branch 3 taken 3866936 times.
|
21201458 | boundary_left = x0 > 0 && !(x0 & 7); |
| 797 |
2/2✓ Branch 0 taken 17112178 times.
✓ Branch 1 taken 4089280 times.
|
21201458 | if (boundary_left && |
| 798 |
2/2✓ Branch 0 taken 2137727 times.
✓ Branch 1 taken 14974451 times.
|
17112178 | ((!s->sh.slice_loop_filter_across_slices_enabled_flag && |
| 799 |
2/2✓ Branch 0 taken 62563 times.
✓ Branch 1 taken 2075164 times.
|
2137727 | lc->boundary_flags & BOUNDARY_LEFT_SLICE && |
| 800 |
2/2✓ Branch 0 taken 54742 times.
✓ Branch 1 taken 7821 times.
|
62563 | (x0 % (1 << sps->log2_ctb_size)) == 0) || |
| 801 |
4/4✓ Branch 0 taken 16514133 times.
✓ Branch 1 taken 590224 times.
✓ Branch 2 taken 226851 times.
✓ Branch 3 taken 16287282 times.
|
17104357 | ((!pps->loop_filter_across_tiles_enabled_flag || lc->tile_bs_defer) && |
| 802 |
2/2✓ Branch 0 taken 118844 times.
✓ Branch 1 taken 698231 times.
|
817075 | lc->boundary_flags & BOUNDARY_LEFT_TILE && |
| 803 |
2/2✓ Branch 0 taken 28609 times.
✓ Branch 1 taken 90235 times.
|
118844 | (x0 % (1 << sps->log2_ctb_size)) == 0))) |
| 804 | 36430 | boundary_left = 0; | |
| 805 | |||
| 806 |
2/2✓ Branch 0 taken 17075748 times.
✓ Branch 1 taken 4125710 times.
|
21201458 | if (boundary_left) { |
| 807 | 34151496 | const RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ? | |
| 808 |
2/2✓ Branch 0 taken 282025 times.
✓ Branch 1 taken 16793723 times.
|
17075748 | ff_hevc_get_ref_list(s->cur_frame, x0 - 1, y0) : |
| 809 | 16793723 | s->cur_frame->refPicList; | |
| 810 | 17075748 | int xp_pu = (x0 - 1) >> log2_min_pu_size; | |
| 811 | 17075748 | int xq_pu = x0 >> log2_min_pu_size; | |
| 812 | 17075748 | int xp_tu = (x0 - 1) >> log2_min_tu_size; | |
| 813 | 17075748 | int xq_tu = x0 >> log2_min_tu_size; | |
| 814 | |||
| 815 |
2/2✓ Branch 0 taken 57505472 times.
✓ Branch 1 taken 17075748 times.
|
74581220 | for (i = 0; i < (1 << log2_trafo_size); i += 4) { |
| 816 | 57505472 | int y_pu = (y0 + i) >> log2_min_pu_size; | |
| 817 | 57505472 | int y_tu = (y0 + i) >> log2_min_tu_size; | |
| 818 | 57505472 | const MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; | |
| 819 | 57505472 | const MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; | |
| 820 | 57505472 | uint8_t left_cbf_luma = l->cbf_luma[y_tu * min_tu_width + xp_tu]; | |
| 821 | 57505472 | uint8_t curr_cbf_luma = l->cbf_luma[y_tu * min_tu_width + xq_tu]; | |
| 822 | |||
| 823 |
4/4✓ Branch 0 taken 45354270 times.
✓ Branch 1 taken 12151202 times.
✓ Branch 2 taken 1761294 times.
✓ Branch 3 taken 43592976 times.
|
57505472 | if (curr->pred_flag == PF_INTRA || left->pred_flag == PF_INTRA) |
| 824 | 13912496 | bs = 2; | |
| 825 |
4/4✓ Branch 0 taken 33538237 times.
✓ Branch 1 taken 10054739 times.
✓ Branch 2 taken 3965670 times.
✓ Branch 3 taken 29572567 times.
|
43592976 | else if (curr_cbf_luma || left_cbf_luma) |
| 826 | 14020409 | bs = 1; | |
| 827 | else | ||
| 828 | 29572567 | bs = boundary_strength(s, curr, left, rpl_left); | |
| 829 | 57505472 | l->vertical_bs[(x0 + (y0 + i) * l->bs_width) >> 2] = bs; | |
| 830 | } | ||
| 831 | } | ||
| 832 | |||
| 833 |
4/4✓ Branch 0 taken 12204027 times.
✓ Branch 1 taken 8997431 times.
✓ Branch 2 taken 9472978 times.
✓ Branch 3 taken 2731049 times.
|
21201458 | if (log2_trafo_size > log2_min_pu_size && !is_intra) { |
| 834 | 9472978 | const RefPicList *rpl = s->cur_frame->refPicList; | |
| 835 | |||
| 836 | // bs for TU internal horizontal PU boundaries | ||
| 837 |
2/2✓ Branch 0 taken 12213676 times.
✓ Branch 1 taken 9472978 times.
|
21686654 | for (j = 8; j < (1 << log2_trafo_size); j += 8) { |
| 838 | 12213676 | int yp_pu = (y0 + j - 1) >> log2_min_pu_size; | |
| 839 | 12213676 | int yq_pu = (y0 + j) >> log2_min_pu_size; | |
| 840 | |||
| 841 |
2/2✓ Branch 0 taken 112431040 times.
✓ Branch 1 taken 12213676 times.
|
124644716 | for (i = 0; i < (1 << log2_trafo_size); i += 4) { |
| 842 | 112431040 | int x_pu = (x0 + i) >> log2_min_pu_size; | |
| 843 | 112431040 | const MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; | |
| 844 | 112431040 | const MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; | |
| 845 | |||
| 846 | 112431040 | bs = boundary_strength(s, curr, top, rpl); | |
| 847 | 112431040 | l->horizontal_bs[((x0 + i) + (y0 + j) * l->bs_width) >> 2] = bs; | |
| 848 | } | ||
| 849 | } | ||
| 850 | |||
| 851 | // bs for TU internal vertical PU boundaries | ||
| 852 |
2/2✓ Branch 0 taken 43373308 times.
✓ Branch 1 taken 9472978 times.
|
52846286 | for (j = 0; j < (1 << log2_trafo_size); j += 4) { |
| 853 | 43373308 | int y_pu = (y0 + j) >> log2_min_pu_size; | |
| 854 | |||
| 855 |
2/2✓ Branch 0 taken 112431040 times.
✓ Branch 1 taken 43373308 times.
|
155804348 | for (i = 8; i < (1 << log2_trafo_size); i += 8) { |
| 856 | 112431040 | int xp_pu = (x0 + i - 1) >> log2_min_pu_size; | |
| 857 | 112431040 | int xq_pu = (x0 + i) >> log2_min_pu_size; | |
| 858 | 112431040 | const MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; | |
| 859 | 112431040 | const MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; | |
| 860 | |||
| 861 | 112431040 | bs = boundary_strength(s, curr, left, rpl); | |
| 862 | 112431040 | l->vertical_bs[((x0 + i) + (y0 + j) * l->bs_width) >> 2] = bs; | |
| 863 | } | ||
| 864 | } | ||
| 865 | } | ||
| 866 | 21201458 | } | |
| 867 | |||
| 868 | 9460 | void ff_hevc_tile_boundary_bs(HEVCLocalContext *lc, const HEVCLayerContext *l, | |
| 869 | const HEVCPPS *pps, int x0, int y0) | ||
| 870 | { | ||
| 871 | 9460 | const HEVCSPS *const sps = pps->sps; | |
| 872 | 9460 | const HEVCContext *s = lc->parent; | |
| 873 | 9460 | const MvField *tab_mvf = s->cur_frame->tab_mvf; | |
| 874 | 9460 | const int log2_min_pu_size = sps->log2_min_pu_size; | |
| 875 | 9460 | const int log2_min_tu_size = sps->log2_min_tb_size; | |
| 876 | 9460 | const int min_pu_width = sps->min_pu_width; | |
| 877 | 9460 | const int min_tu_width = sps->min_tb_width; | |
| 878 | 9460 | const int ctb_size = 1 << sps->log2_ctb_size; | |
| 879 | int i, bs; | ||
| 880 | |||
| 881 |
3/4✓ Branch 0 taken 6600 times.
✓ Branch 1 taken 2860 times.
✓ Branch 2 taken 6600 times.
✗ Branch 3 not taken.
|
9460 | if ((lc->boundary_flags & BOUNDARY_UPPER_TILE) && y0 > 0) { |
| 882 | 13200 | const RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ? | |
| 883 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6600 times.
|
6600 | ff_hevc_get_ref_list(s->cur_frame, x0, y0 - 1) : |
| 884 | 6600 | s->cur_frame->refPicList; | |
| 885 | 6600 | int yp_pu = (y0 - 1) >> log2_min_pu_size, yq_pu = y0 >> log2_min_pu_size; | |
| 886 | 6600 | int yp_tu = (y0 - 1) >> log2_min_tu_size, yq_tu = y0 >> log2_min_tu_size; | |
| 887 | 6600 | int len = FFMIN(ctb_size, sps->width - x0); | |
| 888 |
2/2✓ Branch 0 taken 105600 times.
✓ Branch 1 taken 6600 times.
|
112200 | for (i = 0; i < len; i += 4) { |
| 889 | 105600 | int x_pu = (x0 + i) >> log2_min_pu_size; | |
| 890 | 105600 | int x_tu = (x0 + i) >> log2_min_tu_size; | |
| 891 | 105600 | const MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; | |
| 892 | 105600 | const MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; | |
| 893 | 105600 | uint8_t top_cbf = l->cbf_luma[yp_tu * min_tu_width + x_tu]; | |
| 894 | 105600 | uint8_t curr_cbf = l->cbf_luma[yq_tu * min_tu_width + x_tu]; | |
| 895 |
4/4✓ Branch 0 taken 103250 times.
✓ Branch 1 taken 2350 times.
✓ Branch 2 taken 626 times.
✓ Branch 3 taken 102624 times.
|
105600 | if (curr->pred_flag == PF_INTRA || top->pred_flag == PF_INTRA) |
| 896 | 2976 | bs = 2; | |
| 897 |
4/4✓ Branch 0 taken 90026 times.
✓ Branch 1 taken 12598 times.
✓ Branch 2 taken 7657 times.
✓ Branch 3 taken 82369 times.
|
102624 | else if (curr_cbf || top_cbf) |
| 898 | 20255 | bs = 1; | |
| 899 | else | ||
| 900 | 82369 | bs = boundary_strength(s, curr, top, rpl_top); | |
| 901 | 105600 | l->horizontal_bs[((x0 + i) + y0 * l->bs_width) >> 2] = bs; | |
| 902 | } | ||
| 903 | } | ||
| 904 | |||
| 905 |
3/4✓ Branch 0 taken 3740 times.
✓ Branch 1 taken 5720 times.
✓ Branch 2 taken 3740 times.
✗ Branch 3 not taken.
|
9460 | if ((lc->boundary_flags & BOUNDARY_LEFT_TILE) && x0 > 0) { |
| 906 | 7480 | const RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ? | |
| 907 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3740 times.
|
3740 | ff_hevc_get_ref_list(s->cur_frame, x0 - 1, y0) : |
| 908 | 3740 | s->cur_frame->refPicList; | |
| 909 | 3740 | int xp_pu = (x0 - 1) >> log2_min_pu_size, xq_pu = x0 >> log2_min_pu_size; | |
| 910 | 3740 | int xp_tu = (x0 - 1) >> log2_min_tu_size, xq_tu = x0 >> log2_min_tu_size; | |
| 911 | 3740 | int len = FFMIN(ctb_size, sps->height - y0); | |
| 912 |
2/2✓ Branch 0 taken 59400 times.
✓ Branch 1 taken 3740 times.
|
63140 | for (i = 0; i < len; i += 4) { |
| 913 | 59400 | int y_pu = (y0 + i) >> log2_min_pu_size; | |
| 914 | 59400 | int y_tu = (y0 + i) >> log2_min_tu_size; | |
| 915 | 59400 | const MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; | |
| 916 | 59400 | const MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; | |
| 917 | 59400 | uint8_t left_cbf = l->cbf_luma[y_tu * min_tu_width + xp_tu]; | |
| 918 | 59400 | uint8_t curr_cbf = l->cbf_luma[y_tu * min_tu_width + xq_tu]; | |
| 919 |
4/4✓ Branch 0 taken 57806 times.
✓ Branch 1 taken 1594 times.
✓ Branch 2 taken 562 times.
✓ Branch 3 taken 57244 times.
|
59400 | if (curr->pred_flag == PF_INTRA || left->pred_flag == PF_INTRA) |
| 920 | 2156 | bs = 2; | |
| 921 |
4/4✓ Branch 0 taken 51176 times.
✓ Branch 1 taken 6068 times.
✓ Branch 2 taken 3740 times.
✓ Branch 3 taken 47436 times.
|
57244 | else if (curr_cbf || left_cbf) |
| 922 | 9808 | bs = 1; | |
| 923 | else | ||
| 924 | 47436 | bs = boundary_strength(s, curr, left, rpl_left); | |
| 925 | 59400 | l->vertical_bs[(x0 + (y0 + i) * l->bs_width) >> 2] = bs; | |
| 926 | } | ||
| 927 | } | ||
| 928 | 9460 | } | |
| 929 | |||
| 930 | #undef LUMA | ||
| 931 | #undef CB | ||
| 932 | #undef CR | ||
| 933 | |||
| 934 | 1993922 | void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCLayerContext *l, | |
| 935 | const HEVCPPS *pps, | ||
| 936 | int x, int y, int ctb_size) | ||
| 937 | { | ||
| 938 | 1993922 | const HEVCSPS *const sps = pps->sps; | |
| 939 | 1993922 | const HEVCContext *const s = lc->parent; | |
| 940 | 1993922 | int x_end = x >= sps->width - ctb_size; | |
| 941 | 1993922 | int skip = 0; | |
| 942 |
1/2✓ Branch 0 taken 1993922 times.
✗ Branch 1 not taken.
|
1993922 | if (s->avctx->skip_loop_filter >= AVDISCARD_ALL || |
| 943 |
5/6✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 1991372 times.
✓ Branch 2 taken 2040 times.
✓ Branch 3 taken 510 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2040 times.
|
1993922 | (s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && !IS_IDR(s)) || |
| 944 |
2/2✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1991372 times.
|
1991882 | (s->avctx->skip_loop_filter >= AVDISCARD_NONINTRA && |
| 945 |
1/2✓ Branch 0 taken 510 times.
✗ Branch 1 not taken.
|
510 | s->sh.slice_type != HEVC_SLICE_I) || |
| 946 |
2/2✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1991372 times.
|
1991882 | (s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && |
| 947 |
1/2✓ Branch 0 taken 510 times.
✗ Branch 1 not taken.
|
510 | s->sh.slice_type == HEVC_SLICE_B) || |
| 948 |
3/4✓ Branch 0 taken 510 times.
✓ Branch 1 taken 1991372 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 510 times.
|
1992392 | (s->avctx->skip_loop_filter >= AVDISCARD_NONREF && |
| 949 | 510 | ff_hevc_nal_is_nonref(s->nal_unit_type))) | |
| 950 | 2040 | skip = 1; | |
| 951 | |||
| 952 |
2/2✓ Branch 0 taken 1991882 times.
✓ Branch 1 taken 2040 times.
|
1993922 | if (!skip) |
| 953 | 1991882 | deblocking_filter_CTB(s, l, pps, sps, x, y); | |
| 954 |
4/4✓ Branch 0 taken 1726626 times.
✓ Branch 1 taken 267296 times.
✓ Branch 2 taken 1724586 times.
✓ Branch 3 taken 2040 times.
|
3718508 | if (sps->sao_enabled && !skip) { |
| 955 | 1724586 | int y_end = y >= sps->height - ctb_size; | |
| 956 |
4/4✓ Branch 0 taken 1601478 times.
✓ Branch 1 taken 123108 times.
✓ Branch 2 taken 1533100 times.
✓ Branch 3 taken 68378 times.
|
1724586 | if (y && x) |
| 957 | 1533100 | sao_filter_CTB(lc, l, s, pps, sps, x - ctb_size, y - ctb_size); | |
| 958 |
4/4✓ Branch 0 taken 1646636 times.
✓ Branch 1 taken 77950 times.
✓ Branch 2 taken 113507 times.
✓ Branch 3 taken 1533129 times.
|
1724586 | if (x && y_end) |
| 959 | 113507 | sao_filter_CTB(lc, l, s, pps, sps, x - ctb_size, y); | |
| 960 |
4/4✓ Branch 0 taken 1601478 times.
✓ Branch 1 taken 123108 times.
✓ Branch 2 taken 68377 times.
✓ Branch 3 taken 1533101 times.
|
1724586 | if (y && x_end) { |
| 961 | 68377 | sao_filter_CTB(lc, l, s, pps, sps, x, y - ctb_size); | |
| 962 |
2/2✓ Branch 0 taken 513 times.
✓ Branch 1 taken 67864 times.
|
68377 | if (s->avctx->active_thread_type & FF_THREAD_FRAME ) |
| 963 | 513 | ff_progress_frame_report(&s->cur_frame->tf, y); | |
| 964 | } | ||
| 965 |
4/4✓ Branch 0 taken 77949 times.
✓ Branch 1 taken 1646637 times.
✓ Branch 2 taken 9571 times.
✓ Branch 3 taken 68378 times.
|
1724586 | if (x_end && y_end) { |
| 966 | 9571 | sao_filter_CTB(lc, l, s, pps, sps, x , y); | |
| 967 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 9539 times.
|
9571 | if (s->avctx->active_thread_type & FF_THREAD_FRAME ) |
| 968 | 32 | ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size); | |
| 969 | } | ||
| 970 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 269336 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
269336 | } else if (s->avctx->active_thread_type & FF_THREAD_FRAME && x_end) |
| 971 | ✗ | ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size - 4); | |
| 972 | 1993922 | } | |
| 973 | |||
| 974 | 1993953 | void ff_hevc_hls_filters(HEVCLocalContext *lc, const HEVCLayerContext *l, | |
| 975 | const HEVCPPS *pps, | ||
| 976 | int x_ctb, int y_ctb, int ctb_size) | ||
| 977 | { | ||
| 978 | 1993953 | int x_end = x_ctb >= pps->sps->width - ctb_size; | |
| 979 | 1993953 | int y_end = y_ctb >= pps->sps->height - ctb_size; | |
| 980 |
4/4✓ Branch 0 taken 1852476 times.
✓ Branch 1 taken 141477 times.
✓ Branch 2 taken 1774308 times.
✓ Branch 3 taken 78168 times.
|
1993953 | if (y_ctb && x_ctb) |
| 981 | 1774308 | ff_hevc_hls_filter(lc, l, pps, x_ctb - ctb_size, y_ctb - ctb_size, ctb_size); | |
| 982 |
4/4✓ Branch 0 taken 1852476 times.
✓ Branch 1 taken 141477 times.
✓ Branch 2 taken 78167 times.
✓ Branch 3 taken 1774309 times.
|
1993953 | if (y_ctb && x_end) |
| 983 | 78167 | ff_hevc_hls_filter(lc, l, pps, x_ctb, y_ctb - ctb_size, ctb_size); | |
| 984 |
4/4✓ Branch 0 taken 1905310 times.
✓ Branch 1 taken 88643 times.
✓ Branch 2 taken 130973 times.
✓ Branch 3 taken 1774337 times.
|
1993953 | if (x_ctb && y_end) |
| 985 | 130973 | ff_hevc_hls_filter(lc, l, pps, x_ctb - ctb_size, y_ctb, ctb_size); | |
| 986 | 1993953 | } | |
| 987 |