| 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 "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 | 25201468 | 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 12600734 times.
✓ Branch 1 taken 12600734 times.
|
25201468 | if (c_idx == 1) |
| 57 | 12600734 | offset = pps->cb_qp_offset; | |
| 58 | else | ||
| 59 | 12600734 | offset = pps->cr_qp_offset; | |
| 60 | |||
| 61 | 25201468 | qp_i = av_clip(qp_y + offset, 0, 57); | |
| 62 |
2/2✓ Branch 0 taken 21721740 times.
✓ Branch 1 taken 3479728 times.
|
25201468 | if (sps->chroma_format_idc == 1) { |
| 63 |
2/2✓ Branch 0 taken 4436065 times.
✓ Branch 1 taken 17285675 times.
|
21721740 | if (qp_i < 30) |
| 64 | 4436065 | qp = qp_i; | |
| 65 |
2/2✓ Branch 0 taken 226539 times.
✓ Branch 1 taken 17059136 times.
|
17285675 | else if (qp_i > 43) |
| 66 | 226539 | qp = qp_i - 6; | |
| 67 | else | ||
| 68 | 17059136 | qp = qp_c[qp_i - 30]; | |
| 69 | } else { | ||
| 70 | 3479728 | qp = av_clip(qp_i, 0, 51); | |
| 71 | } | ||
| 72 | |||
| 73 | 25201468 | idxt = av_clip(qp + DEFAULT_INTRA_TC_OFFSET + tc_offset, 0, 53); | |
| 74 | 25201468 | return tctable[idxt]; | |
| 75 | } | ||
| 76 | |||
| 77 | 1554832 | 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 | 1554832 | int ctb_size_mask = (1 << sps->log2_ctb_size) - 1; | |
| 83 | 1554832 | int MinCuQpDeltaSizeMask = (1 << (sps->log2_ctb_size - | |
| 84 | 1554832 | pps->diff_cu_qp_delta_depth)) - 1; | |
| 85 | 1554832 | int xQgBase = xBase - (xBase & MinCuQpDeltaSizeMask); | |
| 86 | 1554832 | int yQgBase = yBase - (yBase & MinCuQpDeltaSizeMask); | |
| 87 | 1554832 | int min_cb_width = sps->min_cb_width; | |
| 88 | 1554832 | int x_cb = xQgBase >> sps->log2_min_cb_size; | |
| 89 | 1554832 | int y_cb = yQgBase >> sps->log2_min_cb_size; | |
| 90 |
2/2✓ Branch 0 taken 1014178 times.
✓ Branch 1 taken 540654 times.
|
2569010 | int availableA = (xBase & ctb_size_mask) && |
| 91 |
2/2✓ Branch 0 taken 867145 times.
✓ Branch 1 taken 147033 times.
|
1014178 | (xQgBase & ctb_size_mask); |
| 92 |
2/2✓ Branch 0 taken 996081 times.
✓ Branch 1 taken 558751 times.
|
2550913 | int availableB = (yBase & ctb_size_mask) && |
| 93 |
2/2✓ Branch 0 taken 865555 times.
✓ Branch 1 taken 130526 times.
|
996081 | (yQgBase & ctb_size_mask); |
| 94 | int qPy_pred, qPy_a, qPy_b; | ||
| 95 | |||
| 96 | // qPy_pred | ||
| 97 |
5/6✓ Branch 0 taken 1461827 times.
✓ Branch 1 taken 93005 times.
✓ Branch 2 taken 20190 times.
✓ Branch 3 taken 1441637 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20190 times.
|
1554832 | if (lc->first_qp_group || (!xQgBase && !yQgBase)) { |
| 98 | 93005 | lc->first_qp_group = !lc->tu.is_cu_qp_delta_coded; | |
| 99 | 93005 | qPy_pred = s->sh.slice_qp; | |
| 100 | } else { | ||
| 101 | 1461827 | qPy_pred = lc->qPy_pred; | |
| 102 | } | ||
| 103 | |||
| 104 | // qPy_a | ||
| 105 |
2/2✓ Branch 0 taken 687687 times.
✓ Branch 1 taken 867145 times.
|
1554832 | if (availableA == 0) |
| 106 | 687687 | qPy_a = qPy_pred; | |
| 107 | else | ||
| 108 | 867145 | qPy_a = l->qp_y_tab[(x_cb - 1) + y_cb * min_cb_width]; | |
| 109 | |||
| 110 | // qPy_b | ||
| 111 |
2/2✓ Branch 0 taken 689277 times.
✓ Branch 1 taken 865555 times.
|
1554832 | if (availableB == 0) |
| 112 | 689277 | qPy_b = qPy_pred; | |
| 113 | else | ||
| 114 | 865555 | 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 | 1554832 | return (qPy_a + qPy_b + 1) >> 1; | |
| 120 | } | ||
| 121 | |||
| 122 | 1554832 | 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 | 1554832 | const HEVCSPS *const sps = pps->sps; | |
| 127 | 1554832 | const HEVCContext *const s = lc->parent; | |
| 128 | 1554832 | int qp_y = get_qPy_pred(lc, s, l, pps, sps, xBase, yBase, log2_cb_size); | |
| 129 | |||
| 130 |
2/2✓ Branch 0 taken 391504 times.
✓ Branch 1 taken 1163328 times.
|
1554832 | if (lc->tu.cu_qp_delta != 0) { |
| 131 | 391504 | int off = sps->qp_bd_offset; | |
| 132 |
1/2✓ Branch 0 taken 391504 times.
✗ Branch 1 not taken.
|
391504 | lc->qp_y = FFUMOD(qp_y + lc->tu.cu_qp_delta + 52 + 2 * off, |
| 133 | 391504 | 52 + off) - off; | |
| 134 | } else | ||
| 135 | 1163328 | lc->qp_y = qp_y; | |
| 136 | 1554832 | } | |
| 137 | |||
| 138 | 129538850 | static int get_qPy(const HEVCSPS *sps, const int8_t *qp_y_tab, int xC, int yC) | |
| 139 | { | ||
| 140 | 129538850 | int log2_min_cb_size = sps->log2_min_cb_size; | |
| 141 | 129538850 | int x = xC >> log2_min_cb_size; | |
| 142 | 129538850 | int y = yC >> log2_min_cb_size; | |
| 143 | 129538850 | return qp_y_tab[x + y * sps->min_cb_width]; | |
| 144 | } | ||
| 145 | |||
| 146 | 429576 | 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 64682 times.
✓ Branch 1 taken 364894 times.
|
429576 | if (((intptr_t)dst | (intptr_t)src | stride_dst | stride_src) & 15) { |
| 152 |
2/2✓ Branch 0 taken 2831264 times.
✓ Branch 1 taken 64682 times.
|
2895946 | for (i = 0; i < height; i++) { |
| 153 |
2/2✓ Branch 0 taken 19652048 times.
✓ Branch 1 taken 2831264 times.
|
22483312 | for (j = 0; j < width - 7; j+=8) |
| 154 | 19652048 | AV_COPY64U(dst+j, src+j); | |
| 155 | 2831264 | dst += stride_dst; | |
| 156 | 2831264 | src += stride_src; | |
| 157 | } | ||
| 158 |
2/2✓ Branch 0 taken 64482 times.
✓ Branch 1 taken 200 times.
|
64682 | if (width&7) { |
| 159 | 64482 | dst += ((width>>3)<<3) - stride_dst * height; | |
| 160 | 64482 | src += ((width>>3)<<3) - stride_src * height; | |
| 161 | 64482 | width &= 7; | |
| 162 |
2/2✓ Branch 0 taken 2829664 times.
✓ Branch 1 taken 64482 times.
|
2894146 | for (i = 0; i < height; i++) { |
| 163 |
2/2✓ Branch 0 taken 6107224 times.
✓ Branch 1 taken 2829664 times.
|
8936888 | for (j = 0; j < width; j++) |
| 164 | 6107224 | dst[j] = src[j]; | |
| 165 | 2829664 | dst += stride_dst; | |
| 166 | 2829664 | src += stride_src; | |
| 167 | } | ||
| 168 | } | ||
| 169 | } else { | ||
| 170 |
2/2✓ Branch 0 taken 19236552 times.
✓ Branch 1 taken 364894 times.
|
19601446 | for (i = 0; i < height; i++) { |
| 171 |
2/2✓ Branch 0 taken 96858808 times.
✓ Branch 1 taken 19236552 times.
|
116095360 | for (j = 0; j < width; j+=16) |
| 172 | 96858808 | AV_COPY128(dst+j, src+j); | |
| 173 | 19236552 | dst += stride_dst; | |
| 174 | 19236552 | src += stride_src; | |
| 175 | } | ||
| 176 | } | ||
| 177 | 429576 | } | |
| 178 | |||
| 179 | 1519129 | static void copy_pixel(uint8_t *dst, const uint8_t *src, int pixel_shift) | |
| 180 | { | ||
| 181 |
2/2✓ Branch 0 taken 230630 times.
✓ Branch 1 taken 1288499 times.
|
1519129 | if (pixel_shift) |
| 182 | 230630 | *(uint16_t *)dst = *(uint16_t *)src; | |
| 183 | else | ||
| 184 | 1288499 | *dst = *src; | |
| 185 | 1519129 | } | |
| 186 | |||
| 187 | 1436080 | 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 1248406 times.
✓ Branch 1 taken 187674 times.
|
1436080 | if (pixel_shift == 0) { |
| 193 |
2/2✓ Branch 0 taken 59595376 times.
✓ Branch 1 taken 1248406 times.
|
60843782 | for (i = 0; i < height; i++) { |
| 194 | 59595376 | *dst = *src; | |
| 195 | 59595376 | dst += stride_dst; | |
| 196 | 59595376 | src += stride_src; | |
| 197 | } | ||
| 198 | } else { | ||
| 199 |
2/2✓ Branch 0 taken 11491952 times.
✓ Branch 1 taken 187674 times.
|
11679626 | for (i = 0; i < height; i++) { |
| 200 | 11491952 | *(uint16_t *)dst = *(uint16_t *)src; | |
| 201 | 11491952 | dst += stride_dst; | |
| 202 | 11491952 | src += stride_src; | |
| 203 | } | ||
| 204 | } | ||
| 205 | 1436080 | } | |
| 206 | |||
| 207 | 544921 | 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 | 544921 | int sh = sps->pixel_shift; | |
| 213 | 544921 | int w = sps->width >> sps->hshift[c_idx]; | |
| 214 | 544921 | int h = sps->height >> sps->vshift[c_idx]; | |
| 215 | |||
| 216 | /* copy horizontal edges */ | ||
| 217 | 544921 | memcpy(l->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb) * w + x) << sh), | |
| 218 | 544921 | src, width << sh); | |
| 219 | 544921 | memcpy(l->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 1) * w + x) << sh), | |
| 220 | 544921 | src + stride_src * (height - 1), width << sh); | |
| 221 | |||
| 222 | /* copy vertical edges */ | ||
| 223 | 544921 | copy_vert(l->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb) * h + y) << sh), src, sh, height, 1 << sh, stride_src); | |
| 224 | |||
| 225 | 544921 | 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 | 544921 | } | |
| 227 | |||
| 228 | 429576 | 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 425287 times.
✓ Branch 1 taken 4289 times.
|
429576 | if (pps->transquant_bypass_enable_flag || |
| 235 |
3/4✓ Branch 0 taken 104 times.
✓ Branch 1 taken 425183 times.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
|
425287 | (sps->pcm_loop_filter_disabled && sps->pcm_enabled)) { |
| 236 | int x, y; | ||
| 237 | 4393 | int min_pu_size = 1 << sps->log2_min_pu_size; | |
| 238 | 4393 | int hshift = sps->hshift[c_idx]; | |
| 239 | 4393 | int vshift = sps->vshift[c_idx]; | |
| 240 | 4393 | int x_min = ((x0 ) >> sps->log2_min_pu_size); | |
| 241 | 4393 | int y_min = ((y0 ) >> sps->log2_min_pu_size); | |
| 242 | 4393 | int x_max = ((x0 + width ) >> sps->log2_min_pu_size); | |
| 243 | 4393 | int y_max = ((y0 + height) >> sps->log2_min_pu_size); | |
| 244 | 4393 | int len = (min_pu_size >> hshift) << sps->pixel_shift; | |
| 245 |
2/2✓ Branch 0 taken 49472 times.
✓ Branch 1 taken 4393 times.
|
53865 | for (y = y_min; y < y_max; y++) { |
| 246 |
2/2✓ Branch 0 taken 632704 times.
✓ Branch 1 taken 49472 times.
|
682176 | for (x = x_min; x < x_max; x++) { |
| 247 |
2/2✓ Branch 0 taken 264 times.
✓ Branch 1 taken 632440 times.
|
632704 | if (l->is_pcm[y * sps->min_pu_width + x]) { |
| 248 | int n; | ||
| 249 | 264 | uint8_t *src = src1 + | |
| 250 | 264 | (((y << sps->log2_min_pu_size) - y0) >> vshift) * stride_src + | |
| 251 | 264 | ((((x << sps->log2_min_pu_size) - x0) >> hshift) << sps->pixel_shift); | |
| 252 | 264 | const uint8_t *dst = dst1 + | |
| 253 | 264 | (((y << sps->log2_min_pu_size) - y0) >> vshift) * stride_dst + | |
| 254 | 264 | ((((x << sps->log2_min_pu_size) - x0) >> hshift) << sps->pixel_shift); | |
| 255 | |||
| 256 |
2/2✓ Branch 0 taken 704 times.
✓ Branch 1 taken 264 times.
|
968 | for (n = 0; n < (min_pu_size >> vshift); n++) { |
| 257 | 704 | memcpy(src, dst, len); | |
| 258 | 704 | src += stride_src; | |
| 259 | 704 | dst += stride_dst; | |
| 260 | } | ||
| 261 | } | ||
| 262 | } | ||
| 263 | } | ||
| 264 | } | ||
| 265 | 429576 | } | |
| 266 | |||
| 267 | #define CTB(tab, x, y) ((tab)[(y) * sps->ctb_width + (x)]) | ||
| 268 | |||
| 269 | 1381567 | 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 | 1381567 | int x_ctb = x >> sps->log2_ctb_size; | |
| 278 | 1381567 | int y_ctb = y >> sps->log2_ctb_size; | |
| 279 | 1381567 | int ctb_addr_rs = y_ctb * sps->ctb_width + x_ctb; | |
| 280 | 1381567 | int ctb_addr_ts = pps->ctb_addr_rs_to_ts[ctb_addr_rs]; | |
| 281 | 1381567 | SAOParams *sao = &CTB(l->sao, x_ctb, y_ctb); | |
| 282 | // flags indicating unfilterable edges | ||
| 283 | 1381567 | uint8_t vert_edge[] = { 0, 0 }; | |
| 284 | 1381567 | uint8_t horiz_edge[] = { 0, 0 }; | |
| 285 | 1381567 | uint8_t diag_edge[] = { 0, 0, 0, 0 }; | |
| 286 | 1381567 | uint8_t lfase = CTB(l->filter_slice_edges, x_ctb, y_ctb); | |
| 287 |
2/2✓ Branch 0 taken 173880 times.
✓ Branch 1 taken 1207687 times.
|
1555447 | uint8_t no_tile_filter = pps->tiles_enabled_flag && |
| 288 |
2/2✓ Branch 0 taken 16664 times.
✓ Branch 1 taken 157216 times.
|
173880 | !pps->loop_filter_across_tiles_enabled_flag; |
| 289 |
4/4✓ Branch 0 taken 1364903 times.
✓ Branch 1 taken 16664 times.
✓ Branch 2 taken 116440 times.
✓ Branch 3 taken 1248463 times.
|
1381567 | uint8_t restore = no_tile_filter || !lfase; |
| 290 | 1381567 | uint8_t left_tile_edge = 0; | |
| 291 | 1381567 | uint8_t right_tile_edge = 0; | |
| 292 | 1381567 | uint8_t up_tile_edge = 0; | |
| 293 | 1381567 | uint8_t bottom_tile_edge = 0; | |
| 294 | |||
| 295 | 1381567 | edges[0] = x_ctb == 0; | |
| 296 | 1381567 | edges[1] = y_ctb == 0; | |
| 297 | 1381567 | edges[2] = x_ctb == sps->ctb_width - 1; | |
| 298 | 1381567 | edges[3] = y_ctb == sps->ctb_height - 1; | |
| 299 | |||
| 300 |
2/2✓ Branch 0 taken 133104 times.
✓ Branch 1 taken 1248463 times.
|
1381567 | if (restore) { |
| 301 |
2/2✓ Branch 0 taken 127633 times.
✓ Branch 1 taken 5471 times.
|
133104 | if (!edges[0]) { |
| 302 |
4/4✓ Branch 0 taken 16242 times.
✓ Branch 1 taken 111391 times.
✓ Branch 2 taken 836 times.
✓ Branch 3 taken 15406 times.
|
127633 | 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 111391 times.
✓ Branch 1 taken 16242 times.
✓ Branch 2 taken 111184 times.
✓ Branch 3 taken 207 times.
✓ Branch 4 taken 836 times.
✓ Branch 5 taken 126590 times.
|
127633 | 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 127634 times.
✓ Branch 1 taken 5470 times.
|
133104 | if (!edges[2]) { |
| 306 |
4/4✓ Branch 0 taken 16242 times.
✓ Branch 1 taken 111392 times.
✓ Branch 2 taken 836 times.
✓ Branch 3 taken 15406 times.
|
127634 | 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 111392 times.
✓ Branch 1 taken 16242 times.
✓ Branch 2 taken 111185 times.
✓ Branch 3 taken 207 times.
✓ Branch 4 taken 836 times.
✓ Branch 5 taken 126591 times.
|
127634 | 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 123620 times.
✓ Branch 1 taken 9484 times.
|
133104 | if (!edges[1]) { |
| 310 |
4/4✓ Branch 0 taken 15931 times.
✓ Branch 1 taken 107689 times.
✓ Branch 2 taken 1440 times.
✓ Branch 3 taken 14491 times.
|
123620 | 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 107689 times.
✓ Branch 1 taken 15931 times.
✓ Branch 2 taken 106249 times.
✓ Branch 3 taken 1440 times.
✓ Branch 4 taken 1440 times.
✓ Branch 5 taken 120740 times.
|
123620 | 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 123650 times.
✓ Branch 1 taken 9454 times.
|
133104 | if (!edges[3]) { |
| 314 |
4/4✓ Branch 0 taken 15931 times.
✓ Branch 1 taken 107719 times.
✓ Branch 2 taken 1440 times.
✓ Branch 3 taken 14491 times.
|
123650 | 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 107719 times.
✓ Branch 1 taken 15931 times.
✓ Branch 2 taken 106279 times.
✓ Branch 3 taken 1440 times.
✓ Branch 4 taken 1440 times.
✓ Branch 5 taken 120770 times.
|
123650 | 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 127633 times.
✓ Branch 1 taken 5471 times.
✓ Branch 2 taken 118893 times.
✓ Branch 3 taken 8740 times.
|
133104 | if (!edges[0] && !edges[1]) { |
| 318 |
8/8✓ Branch 0 taken 103365 times.
✓ Branch 1 taken 15528 times.
✓ Branch 2 taken 101781 times.
✓ Branch 3 taken 1584 times.
✓ Branch 4 taken 116510 times.
✓ Branch 5 taken 799 times.
✓ Branch 6 taken 1332 times.
✓ Branch 7 taken 115178 times.
|
118893 | 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 123620 times.
✓ Branch 1 taken 9484 times.
✓ Branch 2 taken 118894 times.
✓ Branch 3 taken 4726 times.
|
133104 | if (!edges[1] && !edges[2]) { |
| 321 |
8/8✓ Branch 0 taken 103366 times.
✓ Branch 1 taken 15528 times.
✓ Branch 2 taken 101782 times.
✓ Branch 3 taken 1584 times.
✓ Branch 4 taken 116511 times.
✓ Branch 5 taken 799 times.
✓ Branch 6 taken 1332 times.
✓ Branch 7 taken 115179 times.
|
118894 | 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 127634 times.
✓ Branch 1 taken 5470 times.
✓ Branch 2 taken 118923 times.
✓ Branch 3 taken 8711 times.
|
133104 | if (!edges[2] && !edges[3]) { |
| 324 |
8/8✓ Branch 0 taken 103395 times.
✓ Branch 1 taken 15528 times.
✓ Branch 2 taken 101811 times.
✓ Branch 3 taken 1584 times.
✓ Branch 4 taken 116540 times.
✓ Branch 5 taken 799 times.
✓ Branch 6 taken 1332 times.
✓ Branch 7 taken 115208 times.
|
118923 | 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 127633 times.
✓ Branch 1 taken 5471 times.
✓ Branch 2 taken 118922 times.
✓ Branch 3 taken 8711 times.
|
133104 | if (!edges[0] && !edges[3]) { |
| 327 |
8/8✓ Branch 0 taken 103394 times.
✓ Branch 1 taken 15528 times.
✓ Branch 2 taken 101810 times.
✓ Branch 3 taken 1584 times.
✓ Branch 4 taken 116539 times.
✓ Branch 5 taken 799 times.
✓ Branch 6 taken 1332 times.
✓ Branch 7 taken 115207 times.
|
118922 | 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 5526076 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 4144605 times.
✓ Branch 3 taken 1381567 times.
|
5526172 | for (c_idx = 0; c_idx < (sps->chroma_format_idc ? 3 : 1); c_idx++) { |
| 332 | 4144605 | int x0 = x >> sps->hshift[c_idx]; | |
| 333 | 4144605 | int y0 = y >> sps->vshift[c_idx]; | |
| 334 | 4144605 | ptrdiff_t stride_src = s->cur_frame->f->linesize[c_idx]; | |
| 335 | 4144605 | int ctb_size_h = (1 << (sps->log2_ctb_size)) >> sps->hshift[c_idx]; | |
| 336 | 4144605 | int ctb_size_v = (1 << (sps->log2_ctb_size)) >> sps->vshift[c_idx]; | |
| 337 | 4144605 | int width = FFMIN(ctb_size_h, (sps->width >> sps->hshift[c_idx]) - x0); | |
| 338 | 4144605 | int height = FFMIN(ctb_size_v, (sps->height >> sps->vshift[c_idx]) - y0); | |
| 339 | 4144605 | int tab = sao_tab[(FFALIGN(width, 8) >> 3) - 1]; | |
| 340 | 4144605 | 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 116114 times.
✓ Branch 1 taken 428807 times.
✓ Branch 2 taken 3599684 times.
|
4144605 | switch (sao->type_idx[c_idx]) { |
| 345 | 116114 | case SAO_BAND: | |
| 346 | 116114 | 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 115353 times.
✓ Branch 1 taken 761 times.
|
116114 | if (pps->transquant_bypass_enable_flag || |
| 349 |
3/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 115345 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
115353 | (sps->pcm_loop_filter_disabled && sps->pcm_enabled)) { |
| 350 | 769 | dst = lc->edge_emu_buffer; | |
| 351 | 769 | stride_dst = 2*MAX_PB_SIZE; | |
| 352 | 769 | copy_CTB(dst, src, width << sps->pixel_shift, height, stride_dst, stride_src); | |
| 353 | 769 | s->hevcdsp.sao_band_filter[tab](src, dst, stride_src, stride_dst, | |
| 354 | 769 | sao->offset_val[c_idx], sao->band_position[c_idx], | |
| 355 | width, height); | ||
| 356 | 769 | restore_tqb_pixels(l, pps, sps, src, dst, stride_src, stride_dst, | |
| 357 | x, y, width, height, c_idx); | ||
| 358 | } else { | ||
| 359 | 115345 | s->hevcdsp.sao_band_filter[tab](src, src, stride_src, stride_src, | |
| 360 | 115345 | sao->offset_val[c_idx], sao->band_position[c_idx], | |
| 361 | width, height); | ||
| 362 | } | ||
| 363 | 116114 | sao->type_idx[c_idx] = SAO_APPLIED; | |
| 364 | 116114 | break; | |
| 365 | 428807 | case SAO_EDGE: | |
| 366 | { | ||
| 367 | 428807 | int w = sps->width >> sps->hshift[c_idx]; | |
| 368 | 428807 | int h = sps->height >> sps->vshift[c_idx]; | |
| 369 | 428807 | int left_edge = edges[0]; | |
| 370 | 428807 | int top_edge = edges[1]; | |
| 371 | 428807 | int right_edge = edges[2]; | |
| 372 | 428807 | int bottom_edge = edges[3]; | |
| 373 | 428807 | int sh = sps->pixel_shift; | |
| 374 | int left_pixels, right_pixels; | ||
| 375 | |||
| 376 | 428807 | stride_dst = 2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE; | |
| 377 | 428807 | dst = lc->edge_emu_buffer + stride_dst + AV_INPUT_BUFFER_PADDING_SIZE; | |
| 378 | |||
| 379 |
2/2✓ Branch 0 taken 401409 times.
✓ Branch 1 taken 27398 times.
|
428807 | if (!top_edge) { |
| 380 | 401409 | int left = 1 - left_edge; | |
| 381 | 401409 | int right = 1 - right_edge; | |
| 382 | const uint8_t *src1[2]; | ||
| 383 | uint8_t *dst1; | ||
| 384 | int src_idx, pos; | ||
| 385 | |||
| 386 | 401409 | dst1 = dst - stride_dst - (left << sh); | |
| 387 | 401409 | src1[0] = src - stride_src - (left << sh); | |
| 388 | 401409 | src1[1] = l->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb - 1) * w + x0 - left) << sh); | |
| 389 | 401409 | pos = 0; | |
| 390 |
2/2✓ Branch 0 taken 383036 times.
✓ Branch 1 taken 18373 times.
|
401409 | if (left) { |
| 391 | 383036 | src_idx = (CTB(l->sao, x_ctb-1, y_ctb-1).type_idx[c_idx] == | |
| 392 | SAO_APPLIED); | ||
| 393 | 383036 | copy_pixel(dst1, src1[src_idx], sh); | |
| 394 | 383036 | pos += (1 << sh); | |
| 395 | } | ||
| 396 | 401409 | src_idx = (CTB(l->sao, x_ctb, y_ctb-1).type_idx[c_idx] == | |
| 397 | SAO_APPLIED); | ||
| 398 | 401409 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); | |
| 399 |
2/2✓ Branch 0 taken 382143 times.
✓ Branch 1 taken 19266 times.
|
401409 | if (right) { |
| 400 | 382143 | pos += width << sh; | |
| 401 | 382143 | src_idx = (CTB(l->sao, x_ctb+1, y_ctb-1).type_idx[c_idx] == | |
| 402 | SAO_APPLIED); | ||
| 403 | 382143 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); | |
| 404 | } | ||
| 405 | } | ||
| 406 |
2/2✓ Branch 0 taken 395275 times.
✓ Branch 1 taken 33532 times.
|
428807 | if (!bottom_edge) { |
| 407 | 395275 | int left = 1 - left_edge; | |
| 408 | 395275 | int right = 1 - right_edge; | |
| 409 | const uint8_t *src1[2]; | ||
| 410 | uint8_t *dst1; | ||
| 411 | int src_idx, pos; | ||
| 412 | |||
| 413 | 395275 | dst1 = dst + height * stride_dst - (left << sh); | |
| 414 | 395275 | src1[0] = src + height * stride_src - (left << sh); | |
| 415 | 395275 | src1[1] = l->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 2) * w + x0 - left) << sh); | |
| 416 | 395275 | pos = 0; | |
| 417 |
2/2✓ Branch 0 taken 377577 times.
✓ Branch 1 taken 17698 times.
|
395275 | if (left) { |
| 418 | 377577 | src_idx = (CTB(l->sao, x_ctb-1, y_ctb+1).type_idx[c_idx] == | |
| 419 | SAO_APPLIED); | ||
| 420 | 377577 | copy_pixel(dst1, src1[src_idx], sh); | |
| 421 | 377577 | pos += (1 << sh); | |
| 422 | } | ||
| 423 | 395275 | src_idx = (CTB(l->sao, x_ctb, y_ctb+1).type_idx[c_idx] == | |
| 424 | SAO_APPLIED); | ||
| 425 | 395275 | memcpy(dst1 + pos, src1[src_idx] + pos, width << sh); | |
| 426 |
2/2✓ Branch 0 taken 376373 times.
✓ Branch 1 taken 18902 times.
|
395275 | if (right) { |
| 427 | 376373 | pos += width << sh; | |
| 428 | 376373 | src_idx = (CTB(l->sao, x_ctb+1, y_ctb+1).type_idx[c_idx] == | |
| 429 | SAO_APPLIED); | ||
| 430 | 376373 | copy_pixel(dst1 + pos, src1[src_idx] + pos, sh); | |
| 431 | } | ||
| 432 | } | ||
| 433 | 428807 | left_pixels = 0; | |
| 434 |
2/2✓ Branch 0 taken 408354 times.
✓ Branch 1 taken 20453 times.
|
428807 | if (!left_edge) { |
| 435 |
2/2✓ Branch 0 taken 346238 times.
✓ Branch 1 taken 62116 times.
|
408354 | if (CTB(l->sao, x_ctb-1, y_ctb).type_idx[c_idx] == SAO_APPLIED) { |
| 436 | 346238 | copy_vert(dst - (1 << sh), | |
| 437 | 346238 | l->sao_pixel_buffer_v[c_idx] + (((2 * x_ctb - 1) * h + y0) << sh), | |
| 438 | 346238 | sh, height, stride_dst, 1 << sh); | |
| 439 | } else { | ||
| 440 | 62116 | left_pixels = 1; | |
| 441 | } | ||
| 442 | } | ||
| 443 | 428807 | right_pixels = 0; | |
| 444 |
2/2✓ Branch 0 taken 407340 times.
✓ Branch 1 taken 21467 times.
|
428807 | if (!right_edge) { |
| 445 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 407340 times.
|
407340 | 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 | 407340 | right_pixels = 1; | |
| 451 | } | ||
| 452 | } | ||
| 453 | |||
| 454 | 428807 | copy_CTB(dst - (left_pixels << sh), | |
| 455 | 428807 | src - (left_pixels << sh), | |
| 456 | 428807 | (width + left_pixels + right_pixels) << sh, | |
| 457 | height, stride_dst, stride_src); | ||
| 458 | |||
| 459 | 428807 | copy_CTB_to_hv(l, sps, src, stride_src, x0, y0, width, height, c_idx, | |
| 460 | x_ctb, y_ctb); | ||
| 461 | 428807 | s->hevcdsp.sao_edge_filter[tab](src, dst, stride_src, sao->offset_val[c_idx], | |
| 462 | sao->eo_class[c_idx], width, height); | ||
| 463 | 428807 | 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 | 428807 | restore_tqb_pixels(l, pps, sps, src, dst, stride_src, stride_dst, | |
| 472 | x, y, width, height, c_idx); | ||
| 473 | 428807 | sao->type_idx[c_idx] = SAO_APPLIED; | |
| 474 | 428807 | break; | |
| 475 | } | ||
| 476 | } | ||
| 477 | } | ||
| 478 | 1381567 | } | |
| 479 | |||
| 480 | 2188560 | static int get_pcm(const HEVCSPS *sps, const uint8_t *is_pcm, int x, int y) | |
| 481 | { | ||
| 482 | 2188560 | int log2_min_pu_size = sps->log2_min_pu_size; | |
| 483 | int x_pu, y_pu; | ||
| 484 | |||
| 485 |
2/4✓ Branch 0 taken 2188560 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2188560 times.
|
2188560 | if (x < 0 || y < 0) |
| 486 | ✗ | return 2; | |
| 487 | |||
| 488 | 2188560 | x_pu = x >> log2_min_pu_size; | |
| 489 | 2188560 | y_pu = y >> log2_min_pu_size; | |
| 490 | |||
| 491 |
3/4✓ Branch 0 taken 2188560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1408 times.
✓ Branch 3 taken 2187152 times.
|
2188560 | if (x_pu >= sps->min_pu_width || y_pu >= sps->min_pu_height) |
| 492 | 1408 | return 2; | |
| 493 | 2187152 | 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 | 1612988 | 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 | 1612988 | uint8_t **data = s->cur_frame->f->data; | |
| 506 | 1612988 | 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 | 1612988 | uint8_t no_p[2] = { 0 }; | |
| 513 | 1612988 | uint8_t no_q[2] = { 0 }; | |
| 514 | |||
| 515 | 1612988 | int log2_ctb_size = sps->log2_ctb_size; | |
| 516 | int x_end, x_end2, y_end; | ||
| 517 | 1612988 | int ctb_size = 1 << log2_ctb_size; | |
| 518 | 1612988 | int ctb = (x0 >> log2_ctb_size) + | |
| 519 | 1612988 | (y0 >> log2_ctb_size) * sps->ctb_width; | |
| 520 | 1612988 | int cur_tc_offset = l->deblock[ctb].tc_offset; | |
| 521 | 1612988 | int cur_beta_offset = l->deblock[ctb].beta_offset; | |
| 522 | int left_tc_offset, left_beta_offset; | ||
| 523 | int tc_offset, beta_offset; | ||
| 524 | 3313357 | int pcmf = (sps->pcm_enabled && | |
| 525 |
4/4✓ Branch 0 taken 87381 times.
✓ Branch 1 taken 1525607 times.
✓ Branch 2 taken 87325 times.
✓ Branch 3 taken 56 times.
|
3225920 | sps->pcm_loop_filter_disabled) || |
| 526 |
2/2✓ Branch 0 taken 4850 times.
✓ Branch 1 taken 1608082 times.
|
1612932 | pps->transquant_bypass_enable_flag; |
| 527 | |||
| 528 |
2/2✓ Branch 0 taken 1530575 times.
✓ Branch 1 taken 82413 times.
|
1612988 | if (x0) { |
| 529 | 1530575 | left_tc_offset = l->deblock[ctb - 1].tc_offset; | |
| 530 | 1530575 | left_beta_offset = l->deblock[ctb - 1].beta_offset; | |
| 531 | } else { | ||
| 532 | 82413 | left_tc_offset = 0; | |
| 533 | 82413 | left_beta_offset = 0; | |
| 534 | } | ||
| 535 | |||
| 536 | 1612988 | x_end = x0 + ctb_size; | |
| 537 |
2/2✓ Branch 0 taken 25456 times.
✓ Branch 1 taken 1587532 times.
|
1612988 | if (x_end > sps->width) |
| 538 | 25456 | x_end = sps->width; | |
| 539 | 1612988 | y_end = y0 + ctb_size; | |
| 540 |
2/2✓ Branch 0 taken 99162 times.
✓ Branch 1 taken 1513826 times.
|
1612988 | if (y_end > sps->height) |
| 541 | 99162 | y_end = sps->height; | |
| 542 | |||
| 543 | 1612988 | tc_offset = cur_tc_offset; | |
| 544 | 1612988 | beta_offset = cur_beta_offset; | |
| 545 | |||
| 546 | 1612988 | x_end2 = x_end; | |
| 547 |
2/2✓ Branch 0 taken 1530576 times.
✓ Branch 1 taken 82412 times.
|
1612988 | if (x_end2 != sps->width) |
| 548 | 1530576 | x_end2 -= 8; | |
| 549 |
2/2✓ Branch 0 taken 11417040 times.
✓ Branch 1 taken 1612988 times.
|
13030028 | for (y = y0; y < y_end; y += 8) { |
| 550 | // vertical filtering luma | ||
| 551 |
4/4✓ Branch 0 taken 10820786 times.
✓ Branch 1 taken 596254 times.
✓ Branch 2 taken 85998222 times.
✓ Branch 3 taken 11417040 times.
|
97415262 | for (x = x0 ? x0 : 8; x < x_end; x += 8) { |
| 552 | 85998222 | const int bs0 = l->vertical_bs[(x + y * l->bs_width) >> 2]; | |
| 553 | 85998222 | const int bs1 = l->vertical_bs[(x + (y + 4) * l->bs_width) >> 2]; | |
| 554 |
4/4✓ Branch 0 taken 66626766 times.
✓ Branch 1 taken 19371456 times.
✓ Branch 2 taken 92684 times.
✓ Branch 3 taken 66534082 times.
|
85998222 | if (bs0 || bs1) { |
| 555 | 19464140 | const int qp = (get_qPy(sps, l->qp_y_tab, x - 1, y) + | |
| 556 | 19464140 | get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1; | |
| 557 | |||
| 558 | 19464140 | beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)]; | |
| 559 | |||
| 560 |
2/2✓ Branch 0 taken 19371456 times.
✓ Branch 1 taken 92684 times.
|
19464140 | tc[0] = bs0 ? TC_CALC(qp, bs0) : 0; |
| 561 |
2/2✓ Branch 0 taken 19364695 times.
✓ Branch 1 taken 99445 times.
|
19464140 | tc[1] = bs1 ? TC_CALC(qp, bs1) : 0; |
| 562 | 19464140 | src = &data[LUMA][y * linesize[LUMA] + (x << sps->pixel_shift)]; | |
| 563 |
2/2✓ Branch 0 taken 199191 times.
✓ Branch 1 taken 19264949 times.
|
19464140 | if (pcmf) { |
| 564 | 199191 | no_p[0] = get_pcm(sps, l->is_pcm, x - 1, y); | |
| 565 | 199191 | no_p[1] = get_pcm(sps, l->is_pcm, x - 1, y + 4); | |
| 566 | 199191 | no_q[0] = get_pcm(sps, l->is_pcm, x, y); | |
| 567 | 199191 | no_q[1] = get_pcm(sps, l->is_pcm, x, y + 4); | |
| 568 | 199191 | s->hevcdsp.hevc_v_loop_filter_luma_c(src, linesize[LUMA], | |
| 569 | beta, tc, no_p, no_q); | ||
| 570 | } else | ||
| 571 | 19264949 | 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 132451 times.
✓ Branch 1 taken 11284589 times.
|
11417040 | if(!y) |
| 577 | 132451 | continue; | |
| 578 | |||
| 579 | // horizontal filtering luma | ||
| 580 |
4/4✓ Branch 0 taken 10698629 times.
✓ Branch 1 taken 585960 times.
✓ Branch 2 taken 85627699 times.
✓ Branch 3 taken 11284589 times.
|
96912288 | for (x = x0 ? x0 - 8 : 0; x < x_end2; x += 8) { |
| 581 | 85627699 | const int bs0 = l->horizontal_bs[( x + y * l->bs_width) >> 2]; | |
| 582 | 85627699 | const int bs1 = l->horizontal_bs[((x + 4) + y * l->bs_width) >> 2]; | |
| 583 |
4/4✓ Branch 0 taken 65921066 times.
✓ Branch 1 taken 19706633 times.
✓ Branch 2 taken 110330 times.
✓ Branch 3 taken 65810736 times.
|
85627699 | if (bs0 || bs1) { |
| 584 | 19816963 | const int qp = (get_qPy(sps, l->qp_y_tab, x, y - 1) + | |
| 585 | 19816963 | get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1; | |
| 586 | |||
| 587 |
2/2✓ Branch 0 taken 17304789 times.
✓ Branch 1 taken 2512174 times.
|
19816963 | tc_offset = x >= x0 ? cur_tc_offset : left_tc_offset; |
| 588 |
2/2✓ Branch 0 taken 17304789 times.
✓ Branch 1 taken 2512174 times.
|
19816963 | beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset; |
| 589 | |||
| 590 | 19816963 | beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)]; | |
| 591 |
2/2✓ Branch 0 taken 19706633 times.
✓ Branch 1 taken 110330 times.
|
19816963 | tc[0] = bs0 ? TC_CALC(qp, bs0) : 0; |
| 592 |
2/2✓ Branch 0 taken 19691601 times.
✓ Branch 1 taken 125362 times.
|
19816963 | tc[1] = bs1 ? TC_CALC(qp, bs1) : 0; |
| 593 | 19816963 | src = &data[LUMA][y * linesize[LUMA] + (x << sps->pixel_shift)]; | |
| 594 |
2/2✓ Branch 0 taken 200589 times.
✓ Branch 1 taken 19616374 times.
|
19816963 | if (pcmf) { |
| 595 | 200589 | no_p[0] = get_pcm(sps, l->is_pcm, x, y - 1); | |
| 596 | 200589 | no_p[1] = get_pcm(sps, l->is_pcm, x + 4, y - 1); | |
| 597 | 200589 | no_q[0] = get_pcm(sps, l->is_pcm, x, y); | |
| 598 | 200589 | no_q[1] = get_pcm(sps, l->is_pcm, x + 4, y); | |
| 599 | 200589 | s->hevcdsp.hevc_h_loop_filter_luma_c(src, linesize[LUMA], | |
| 600 | beta, tc, no_p, no_q); | ||
| 601 | } else | ||
| 602 | 19616374 | 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 1612940 times.
✓ Branch 1 taken 48 times.
|
1612988 | if (sps->chroma_format_idc) { |
| 609 |
2/2✓ Branch 0 taken 3225880 times.
✓ Branch 1 taken 1612940 times.
|
4838820 | for (chroma = 1; chroma <= 2; chroma++) { |
| 610 | 3225880 | int h = 1 << sps->hshift[chroma]; | |
| 611 | 3225880 | int v = 1 << sps->vshift[chroma]; | |
| 612 | |||
| 613 | // vertical filtering chroma | ||
| 614 |
2/2✓ Branch 0 taken 11890838 times.
✓ Branch 1 taken 3225880 times.
|
15116718 | for (y = y0; y < y_end; y += (8 * v)) { |
| 615 |
4/4✓ Branch 0 taken 609552 times.
✓ Branch 1 taken 11281286 times.
✓ Branch 2 taken 45349298 times.
✓ Branch 3 taken 11890838 times.
|
57240136 | for (x = x0 ? x0 : 8 * h; x < x_end; x += (8 * h)) { |
| 616 | 45349298 | const int bs0 = l->vertical_bs[(x + y * l->bs_width) >> 2]; | |
| 617 | 45349298 | const int bs1 = l->vertical_bs[(x + (y + (4 * v)) * l->bs_width) >> 2]; | |
| 618 | |||
| 619 |
4/4✓ Branch 0 taken 38892480 times.
✓ Branch 1 taken 6456818 times.
✓ Branch 2 taken 141074 times.
✓ Branch 3 taken 38751406 times.
|
45349298 | if ((bs0 == 2) || (bs1 == 2)) { |
| 620 | 6597892 | const int qp0 = (get_qPy(sps, l->qp_y_tab, x - 1, y) + | |
| 621 | 6597892 | get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1; | |
| 622 | 6597892 | const int qp1 = (get_qPy(sps, l->qp_y_tab, x - 1, y + (4 * v)) + | |
| 623 | 6597892 | get_qPy(sps, l->qp_y_tab, x, y + (4 * v)) + 1) >> 1; | |
| 624 | |||
| 625 |
2/2✓ Branch 0 taken 6456818 times.
✓ Branch 1 taken 141074 times.
|
6597892 | c_tc[0] = (bs0 == 2) ? chroma_tc(pps, sps, qp0, chroma, tc_offset) : 0; |
| 626 |
2/2✓ Branch 0 taken 6452112 times.
✓ Branch 1 taken 145780 times.
|
6597892 | c_tc[1] = (bs1 == 2) ? chroma_tc(pps, sps, qp1, chroma, tc_offset) : 0; |
| 627 | 6597892 | src = &data[chroma][(y >> sps->vshift[chroma]) * linesize[chroma] + ((x >> sps->hshift[chroma]) << sps->pixel_shift)]; | |
| 628 |
2/2✓ Branch 0 taken 74312 times.
✓ Branch 1 taken 6523580 times.
|
6597892 | if (pcmf) { |
| 629 | 74312 | no_p[0] = get_pcm(sps, l->is_pcm, x - 1, y); | |
| 630 | 74312 | no_p[1] = get_pcm(sps, l->is_pcm, x - 1, y + (4 * v)); | |
| 631 | 74312 | no_q[0] = get_pcm(sps, l->is_pcm, x, y); | |
| 632 | 74312 | no_q[1] = get_pcm(sps, l->is_pcm, x, y + (4 * v)); | |
| 633 | 74312 | s->hevcdsp.hevc_v_loop_filter_chroma_c(src, linesize[chroma], | |
| 634 | c_tc, no_p, no_q); | ||
| 635 | } else | ||
| 636 | 6523580 | 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 264878 times.
✓ Branch 1 taken 11625960 times.
|
11890838 | if(!y) |
| 642 | 264878 | continue; | |
| 643 | |||
| 644 | // horizontal filtering chroma | ||
| 645 |
2/2✓ Branch 0 taken 11036992 times.
✓ Branch 1 taken 588968 times.
|
11625960 | tc_offset = x0 ? left_tc_offset : cur_tc_offset; |
| 646 | 11625960 | x_end2 = x_end; | |
| 647 |
2/2✓ Branch 0 taken 11037000 times.
✓ Branch 1 taken 588960 times.
|
11625960 | if (x_end != sps->width) |
| 648 | 11037000 | x_end2 = x_end - 8 * h; | |
| 649 |
4/4✓ Branch 0 taken 11036992 times.
✓ Branch 1 taken 588968 times.
✓ Branch 2 taken 44985486 times.
✓ Branch 3 taken 11625960 times.
|
56611446 | for (x = x0 ? x0 - 8 * h : 0; x < x_end2; x += (8 * h)) { |
| 650 | 44985486 | const int bs0 = l->horizontal_bs[( x + y * l->bs_width) >> 2]; | |
| 651 | 44985486 | const int bs1 = l->horizontal_bs[((x + 4 * h) + y * l->bs_width) >> 2]; | |
| 652 |
4/4✓ Branch 0 taken 38838792 times.
✓ Branch 1 taken 6146694 times.
✓ Branch 2 taken 147314 times.
✓ Branch 3 taken 38691478 times.
|
44985486 | if ((bs0 == 2) || (bs1 == 2)) { |
| 653 | 6146694 | const int qp0 = bs0 == 2 ? (get_qPy(sps, l->qp_y_tab, x, y - 1) + | |
| 654 |
2/2✓ Branch 0 taken 6146694 times.
✓ Branch 1 taken 147314 times.
|
12440702 | get_qPy(sps, l->qp_y_tab, x, y) + 1) >> 1 : 0; |
| 655 | 6145844 | const int qp1 = bs1 == 2 ? (get_qPy(sps, l->qp_y_tab, x + (4 * h), y - 1) + | |
| 656 |
2/2✓ Branch 0 taken 6145844 times.
✓ Branch 1 taken 148164 times.
|
12439852 | get_qPy(sps, l->qp_y_tab, x + (4 * h), y) + 1) >> 1 : 0; |
| 657 | |||
| 658 |
2/2✓ Branch 0 taken 6146694 times.
✓ Branch 1 taken 147314 times.
|
6294008 | c_tc[0] = bs0 == 2 ? chroma_tc(pps, sps, qp0, chroma, tc_offset) : 0; |
| 659 |
2/2✓ Branch 0 taken 6145844 times.
✓ Branch 1 taken 148164 times.
|
6294008 | c_tc[1] = bs1 == 2 ? chroma_tc(pps, sps, qp1, chroma, cur_tc_offset) : 0; |
| 660 | 6294008 | src = &data[chroma][(y >> sps->vshift[1]) * linesize[chroma] + ((x >> sps->hshift[1]) << sps->pixel_shift)]; | |
| 661 |
2/2✓ Branch 0 taken 73048 times.
✓ Branch 1 taken 6220960 times.
|
6294008 | if (pcmf) { |
| 662 | 73048 | no_p[0] = get_pcm(sps, l->is_pcm, x, y - 1); | |
| 663 | 73048 | no_p[1] = get_pcm(sps, l->is_pcm, x + (4 * h), y - 1); | |
| 664 | 73048 | no_q[0] = get_pcm(sps, l->is_pcm, x, y); | |
| 665 | 73048 | no_q[1] = get_pcm(sps, l->is_pcm, x + (4 * h), y); | |
| 666 | 73048 | s->hevcdsp.hevc_h_loop_filter_chroma_c(src, linesize[chroma], | |
| 667 | c_tc, no_p, no_q); | ||
| 668 | } else | ||
| 669 | 6220960 | s->hevcdsp.hevc_h_loop_filter_chroma(src, linesize[chroma], | |
| 670 | c_tc, no_p, no_q); | ||
| 671 | } | ||
| 672 | } | ||
| 673 | } | ||
| 674 | } | ||
| 675 | } | ||
| 676 | 1612988 | } | |
| 677 | |||
| 678 | 253319862 | 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 160973577 times.
✓ Branch 1 taken 92346285 times.
✓ Branch 2 taken 156383882 times.
✓ Branch 3 taken 4589695 times.
|
253319862 | if (curr->pred_flag == PF_BI && neigh->pred_flag == PF_BI) { |
| 682 | // same L0 and L1 | ||
| 683 |
2/2✓ Branch 0 taken 154590633 times.
✓ Branch 1 taken 1793249 times.
|
156383882 | 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 134827092 times.
|
154590633 | 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 134975068 times.
✓ Branch 1 taken 1793249 times.
|
136768317 | } 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 134367348 times.
✓ Branch 1 taken 607720 times.
|
134975068 | neigh_refPicList[1].list[neigh->ref_idx[1]] == s->cur_frame->refPicList[1].list[curr->ref_idx[1]]) { |
| 695 |
4/4✓ Branch 0 taken 130530794 times.
✓ Branch 1 taken 3836554 times.
✓ Branch 2 taken 129618196 times.
✓ Branch 3 taken 912598 times.
|
134367348 | 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 129111719 times.
✓ Branch 1 taken 506477 times.
✓ Branch 2 taken 162604 times.
✓ Branch 3 taken 128949115 times.
|
129618196 | FFABS(neigh->mv[1].x - curr->mv[1].x) >= 4 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 4) |
| 697 | 5418233 | return 1; | |
| 698 | else | ||
| 699 | 128949115 | return 0; | |
| 700 |
2/2✓ Branch 0 taken 741301 times.
✓ Branch 1 taken 1659668 times.
|
2400969 | } 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 | 2239856 | return 1; | |
| 709 | } | ||
| 710 |
4/4✓ Branch 0 taken 92346285 times.
✓ Branch 1 taken 4589695 times.
✓ Branch 2 taken 87767947 times.
✓ Branch 3 taken 4578338 times.
|
96935980 | } 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 74832082 times.
✓ Branch 1 taken 12935865 times.
|
87767947 | if (curr->pred_flag & 1) { |
| 715 | 74832082 | A = curr->mv[0]; | |
| 716 | 74832082 | ref_A = s->cur_frame->refPicList[0].list[curr->ref_idx[0]]; | |
| 717 | } else { | ||
| 718 | 12935865 | A = curr->mv[1]; | |
| 719 | 12935865 | ref_A = s->cur_frame->refPicList[1].list[curr->ref_idx[1]]; | |
| 720 | } | ||
| 721 | |||
| 722 |
2/2✓ Branch 0 taken 74848117 times.
✓ Branch 1 taken 12919830 times.
|
87767947 | if (neigh->pred_flag & 1) { |
| 723 | 74848117 | B = neigh->mv[0]; | |
| 724 | 74848117 | ref_B = neigh_refPicList[0].list[neigh->ref_idx[0]]; | |
| 725 | } else { | ||
| 726 | 12919830 | B = neigh->mv[1]; | |
| 727 | 12919830 | ref_B = neigh_refPicList[1].list[neigh->ref_idx[1]]; | |
| 728 | } | ||
| 729 | |||
| 730 |
2/2✓ Branch 0 taken 83979536 times.
✓ Branch 1 taken 3788411 times.
|
87767947 | if (ref_A == ref_B) { |
| 731 |
4/4✓ Branch 0 taken 81878175 times.
✓ Branch 1 taken 2101361 times.
✓ Branch 2 taken 683204 times.
✓ Branch 3 taken 81194971 times.
|
83979536 | if (FFABS(A.x - B.x) >= 4 || FFABS(A.y - B.y) >= 4) |
| 732 | 2784565 | return 1; | |
| 733 | else | ||
| 734 | 81194971 | return 0; | |
| 735 | } else | ||
| 736 | 3788411 | return 1; | |
| 737 | } | ||
| 738 | |||
| 739 | 9168033 | return 1; | |
| 740 | } | ||
| 741 | |||
| 742 | 21584945 | 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 | 21584945 | const HEVCSPS *const sps = pps->sps; | |
| 747 | 21584945 | const HEVCContext *s = lc->parent; | |
| 748 | 21584945 | const MvField *tab_mvf = s->cur_frame->tab_mvf; | |
| 749 | 21584945 | int log2_min_pu_size = sps->log2_min_pu_size; | |
| 750 | 21584945 | int log2_min_tu_size = sps->log2_min_tb_size; | |
| 751 | 21584945 | int min_pu_width = sps->min_pu_width; | |
| 752 | 21584945 | int min_tu_width = sps->min_tb_width; | |
| 753 | 21584945 | int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width + | |
| 754 | 21584945 | (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 21265916 times.
✓ Branch 1 taken 319029 times.
✓ Branch 2 taken 16761146 times.
✓ Branch 3 taken 4504770 times.
|
21584945 | boundary_upper = y0 > 0 && !(y0 & 7); |
| 759 |
2/2✓ Branch 0 taken 16761146 times.
✓ Branch 1 taken 4823799 times.
|
21584945 | if (boundary_upper && |
| 760 |
2/2✓ Branch 0 taken 2219673 times.
✓ Branch 1 taken 14541473 times.
|
16761146 | ((!s->sh.slice_loop_filter_across_slices_enabled_flag && |
| 761 |
2/2✓ Branch 0 taken 511181 times.
✓ Branch 1 taken 1708492 times.
|
2219673 | lc->boundary_flags & BOUNDARY_UPPER_SLICE && |
| 762 |
2/2✓ Branch 0 taken 449547 times.
✓ Branch 1 taken 61634 times.
|
511181 | (y0 % (1 << sps->log2_ctb_size)) == 0) || |
| 763 |
2/2✓ Branch 0 taken 429711 times.
✓ Branch 1 taken 16269801 times.
|
16699512 | (!pps->loop_filter_across_tiles_enabled_flag && |
| 764 |
2/2✓ Branch 0 taken 114253 times.
✓ Branch 1 taken 315458 times.
|
429711 | lc->boundary_flags & BOUNDARY_UPPER_TILE && |
| 765 |
2/2✓ Branch 0 taken 19889 times.
✓ Branch 1 taken 94364 times.
|
114253 | (y0 % (1 << sps->log2_ctb_size)) == 0))) |
| 766 | 81523 | boundary_upper = 0; | |
| 767 | |||
| 768 |
2/2✓ Branch 0 taken 16679623 times.
✓ Branch 1 taken 4905322 times.
|
21584945 | if (boundary_upper) { |
| 769 | 33359246 | const RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ? | |
| 770 |
2/2✓ Branch 0 taken 2136569 times.
✓ Branch 1 taken 14543054 times.
|
16679623 | ff_hevc_get_ref_list(s->cur_frame, x0, y0 - 1) : |
| 771 | 14543054 | s->cur_frame->refPicList; | |
| 772 | 16679623 | int yp_pu = (y0 - 1) >> log2_min_pu_size; | |
| 773 | 16679623 | int yq_pu = y0 >> log2_min_pu_size; | |
| 774 | 16679623 | int yp_tu = (y0 - 1) >> log2_min_tu_size; | |
| 775 | 16679623 | int yq_tu = y0 >> log2_min_tu_size; | |
| 776 | |||
| 777 |
2/2✓ Branch 0 taken 52956546 times.
✓ Branch 1 taken 16679623 times.
|
69636169 | for (i = 0; i < (1 << log2_trafo_size); i += 4) { |
| 778 | 52956546 | int x_pu = (x0 + i) >> log2_min_pu_size; | |
| 779 | 52956546 | int x_tu = (x0 + i) >> log2_min_tu_size; | |
| 780 | 52956546 | const MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; | |
| 781 | 52956546 | const MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; | |
| 782 | 52956546 | uint8_t top_cbf_luma = l->cbf_luma[yp_tu * min_tu_width + x_tu]; | |
| 783 | 52956546 | uint8_t curr_cbf_luma = l->cbf_luma[yq_tu * min_tu_width + x_tu]; | |
| 784 | |||
| 785 |
4/4✓ Branch 0 taken 38174058 times.
✓ Branch 1 taken 14782488 times.
✓ Branch 2 taken 1354250 times.
✓ Branch 3 taken 36819808 times.
|
52956546 | if (curr->pred_flag == PF_INTRA || top->pred_flag == PF_INTRA) |
| 786 | 16136738 | bs = 2; | |
| 787 |
4/4✓ Branch 0 taken 28922409 times.
✓ Branch 1 taken 7897399 times.
✓ Branch 2 taken 3000704 times.
✓ Branch 3 taken 25921705 times.
|
36819808 | else if (curr_cbf_luma || top_cbf_luma) |
| 788 | 10898103 | bs = 1; | |
| 789 | else | ||
| 790 | 25921705 | bs = boundary_strength(s, curr, top, rpl_top); | |
| 791 | 52956546 | 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 21365477 times.
✓ Branch 1 taken 219468 times.
✓ Branch 2 taken 16860707 times.
✓ Branch 3 taken 4504770 times.
|
21584945 | boundary_left = x0 > 0 && !(x0 & 7); |
| 797 |
2/2✓ Branch 0 taken 16860707 times.
✓ Branch 1 taken 4724238 times.
|
21584945 | if (boundary_left && |
| 798 |
2/2✓ Branch 0 taken 2241758 times.
✓ Branch 1 taken 14618949 times.
|
16860707 | ((!s->sh.slice_loop_filter_across_slices_enabled_flag && |
| 799 |
2/2✓ Branch 0 taken 69038 times.
✓ Branch 1 taken 2172720 times.
|
2241758 | lc->boundary_flags & BOUNDARY_LEFT_SLICE && |
| 800 |
2/2✓ Branch 0 taken 60387 times.
✓ Branch 1 taken 8651 times.
|
69038 | (x0 % (1 << sps->log2_ctb_size)) == 0) || |
| 801 |
2/2✓ Branch 0 taken 441443 times.
✓ Branch 1 taken 16410613 times.
|
16852056 | (!pps->loop_filter_across_tiles_enabled_flag && |
| 802 |
2/2✓ Branch 0 taken 59900 times.
✓ Branch 1 taken 381543 times.
|
441443 | lc->boundary_flags & BOUNDARY_LEFT_TILE && |
| 803 |
2/2✓ Branch 0 taken 13608 times.
✓ Branch 1 taken 46292 times.
|
59900 | (x0 % (1 << sps->log2_ctb_size)) == 0))) |
| 804 | 22259 | boundary_left = 0; | |
| 805 | |||
| 806 |
2/2✓ Branch 0 taken 16838448 times.
✓ Branch 1 taken 4746497 times.
|
21584945 | if (boundary_left) { |
| 807 | 33676896 | const RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ? | |
| 808 |
2/2✓ Branch 0 taken 250133 times.
✓ Branch 1 taken 16588315 times.
|
16838448 | ff_hevc_get_ref_list(s->cur_frame, x0 - 1, y0) : |
| 809 | 16588315 | s->cur_frame->refPicList; | |
| 810 | 16838448 | int xp_pu = (x0 - 1) >> log2_min_pu_size; | |
| 811 | 16838448 | int xq_pu = x0 >> log2_min_pu_size; | |
| 812 | 16838448 | int xp_tu = (x0 - 1) >> log2_min_tu_size; | |
| 813 | 16838448 | int xq_tu = x0 >> log2_min_tu_size; | |
| 814 | |||
| 815 |
2/2✓ Branch 0 taken 53972730 times.
✓ Branch 1 taken 16838448 times.
|
70811178 | for (i = 0; i < (1 << log2_trafo_size); i += 4) { |
| 816 | 53972730 | int y_pu = (y0 + i) >> log2_min_pu_size; | |
| 817 | 53972730 | int y_tu = (y0 + i) >> log2_min_tu_size; | |
| 818 | 53972730 | const MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; | |
| 819 | 53972730 | const MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; | |
| 820 | 53972730 | uint8_t left_cbf_luma = l->cbf_luma[y_tu * min_tu_width + xp_tu]; | |
| 821 | 53972730 | uint8_t curr_cbf_luma = l->cbf_luma[y_tu * min_tu_width + xq_tu]; | |
| 822 | |||
| 823 |
4/4✓ Branch 0 taken 39102998 times.
✓ Branch 1 taken 14869732 times.
✓ Branch 2 taken 1501810 times.
✓ Branch 3 taken 37601188 times.
|
53972730 | if (curr->pred_flag == PF_INTRA || left->pred_flag == PF_INTRA) |
| 824 | 16371542 | bs = 2; | |
| 825 |
4/4✓ Branch 0 taken 29656684 times.
✓ Branch 1 taken 7944504 times.
✓ Branch 2 taken 3050047 times.
✓ Branch 3 taken 26606637 times.
|
37601188 | else if (curr_cbf_luma || left_cbf_luma) |
| 826 | 10994551 | bs = 1; | |
| 827 | else | ||
| 828 | 26606637 | bs = boundary_strength(s, curr, left, rpl_left); | |
| 829 | 53972730 | l->vertical_bs[(x0 + (y0 + i) * l->bs_width) >> 2] = bs; | |
| 830 | } | ||
| 831 | } | ||
| 832 | |||
| 833 |
4/4✓ Branch 0 taken 11151628 times.
✓ Branch 1 taken 10433317 times.
✓ Branch 2 taken 7891998 times.
✓ Branch 3 taken 3259630 times.
|
21584945 | if (log2_trafo_size > log2_min_pu_size && !is_intra) { |
| 834 | 7891998 | const RefPicList *rpl = s->cur_frame->refPicList; | |
| 835 | |||
| 836 | // bs for TU internal horizontal PU boundaries | ||
| 837 |
2/2✓ Branch 0 taken 10585411 times.
✓ Branch 1 taken 7891998 times.
|
18477409 | for (j = 8; j < (1 << log2_trafo_size); j += 8) { |
| 838 | 10585411 | int yp_pu = (y0 + j - 1) >> log2_min_pu_size; | |
| 839 | 10585411 | int yq_pu = (y0 + j) >> log2_min_pu_size; | |
| 840 | |||
| 841 |
2/2✓ Branch 0 taken 100395760 times.
✓ Branch 1 taken 10585411 times.
|
110981171 | for (i = 0; i < (1 << log2_trafo_size); i += 4) { |
| 842 | 100395760 | int x_pu = (x0 + i) >> log2_min_pu_size; | |
| 843 | 100395760 | const MvField *top = &tab_mvf[yp_pu * min_pu_width + x_pu]; | |
| 844 | 100395760 | const MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu]; | |
| 845 | |||
| 846 | 100395760 | bs = boundary_strength(s, curr, top, rpl); | |
| 847 | 100395760 | 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 36954818 times.
✓ Branch 1 taken 7891998 times.
|
44846816 | for (j = 0; j < (1 << log2_trafo_size); j += 4) { |
| 853 | 36954818 | int y_pu = (y0 + j) >> log2_min_pu_size; | |
| 854 | |||
| 855 |
2/2✓ Branch 0 taken 100395760 times.
✓ Branch 1 taken 36954818 times.
|
137350578 | for (i = 8; i < (1 << log2_trafo_size); i += 8) { |
| 856 | 100395760 | int xp_pu = (x0 + i - 1) >> log2_min_pu_size; | |
| 857 | 100395760 | int xq_pu = (x0 + i) >> log2_min_pu_size; | |
| 858 | 100395760 | const MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu]; | |
| 859 | 100395760 | const MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu]; | |
| 860 | |||
| 861 | 100395760 | bs = boundary_strength(s, curr, left, rpl); | |
| 862 | 100395760 | l->vertical_bs[((x0 + i) + (y0 + j) * l->bs_width) >> 2] = bs; | |
| 863 | } | ||
| 864 | } | ||
| 865 | } | ||
| 866 | 21584945 | } | |
| 867 | |||
| 868 | #undef LUMA | ||
| 869 | #undef CB | ||
| 870 | #undef CR | ||
| 871 | |||
| 872 | 1615028 | void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCLayerContext *l, | |
| 873 | const HEVCPPS *pps, | ||
| 874 | int x, int y, int ctb_size) | ||
| 875 | { | ||
| 876 | 1615028 | const HEVCSPS *const sps = pps->sps; | |
| 877 | 1615028 | const HEVCContext *const s = lc->parent; | |
| 878 | 1615028 | int x_end = x >= sps->width - ctb_size; | |
| 879 | 1615028 | int skip = 0; | |
| 880 |
1/2✓ Branch 0 taken 1615028 times.
✗ Branch 1 not taken.
|
1615028 | if (s->avctx->skip_loop_filter >= AVDISCARD_ALL || |
| 881 |
5/6✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 1611968 times.
✓ Branch 2 taken 2040 times.
✓ Branch 3 taken 1020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2040 times.
|
1615028 | (s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && !IS_IDR(s)) || |
| 882 |
2/2✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 1611968 times.
|
1612988 | (s->avctx->skip_loop_filter >= AVDISCARD_NONINTRA && |
| 883 |
1/2✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
|
1020 | s->sh.slice_type != HEVC_SLICE_I) || |
| 884 |
2/2✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 1611968 times.
|
1612988 | (s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && |
| 885 |
1/2✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
|
1020 | s->sh.slice_type == HEVC_SLICE_B) || |
| 886 |
3/4✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 1611968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1020 times.
|
1614008 | (s->avctx->skip_loop_filter >= AVDISCARD_NONREF && |
| 887 | 1020 | ff_hevc_nal_is_nonref(s->nal_unit_type))) | |
| 888 | 2040 | skip = 1; | |
| 889 | |||
| 890 |
2/2✓ Branch 0 taken 1612988 times.
✓ Branch 1 taken 2040 times.
|
1615028 | if (!skip) |
| 891 | 1612988 | deblocking_filter_CTB(s, l, pps, sps, x, y); | |
| 892 |
4/4✓ Branch 0 taken 1383638 times.
✓ Branch 1 taken 231390 times.
✓ Branch 2 taken 1381598 times.
✓ Branch 3 taken 2040 times.
|
2996626 | if (sps->sao_enabled && !skip) { |
| 893 | 1381598 | int y_end = y >= sps->height - ctb_size; | |
| 894 |
4/4✓ Branch 0 taken 1264744 times.
✓ Branch 1 taken 116854 times.
✓ Branch 2 taken 1200940 times.
✓ Branch 3 taken 63804 times.
|
1381598 | if (y && x) |
| 895 | 1200940 | sao_filter_CTB(lc, l, s, pps, sps, x - ctb_size, y - ctb_size); | |
| 896 |
4/4✓ Branch 0 taken 1308302 times.
✓ Branch 1 taken 73296 times.
✓ Branch 2 taken 107333 times.
✓ Branch 3 taken 1200969 times.
|
1381598 | if (x && y_end) |
| 897 | 107333 | sao_filter_CTB(lc, l, s, pps, sps, x - ctb_size, y); | |
| 898 |
4/4✓ Branch 0 taken 1264744 times.
✓ Branch 1 taken 116854 times.
✓ Branch 2 taken 63803 times.
✓ Branch 3 taken 1200941 times.
|
1381598 | if (y && x_end) { |
| 899 | 63803 | sao_filter_CTB(lc, l, s, pps, sps, x, y - ctb_size); | |
| 900 |
2/2✓ Branch 0 taken 513 times.
✓ Branch 1 taken 63290 times.
|
63803 | if (s->avctx->active_thread_type & FF_THREAD_FRAME ) |
| 901 | 513 | ff_progress_frame_report(&s->cur_frame->tf, y); | |
| 902 | } | ||
| 903 |
4/4✓ Branch 0 taken 73295 times.
✓ Branch 1 taken 1308303 times.
✓ Branch 2 taken 9491 times.
✓ Branch 3 taken 63804 times.
|
1381598 | if (x_end && y_end) { |
| 904 | 9491 | sao_filter_CTB(lc, l, s, pps, sps, x , y); | |
| 905 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 9459 times.
|
9491 | if (s->avctx->active_thread_type & FF_THREAD_FRAME ) |
| 906 | 32 | ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size); | |
| 907 | } | ||
| 908 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 233430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
233430 | } else if (s->avctx->active_thread_type & FF_THREAD_FRAME && x_end) |
| 909 | ✗ | ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size - 4); | |
| 910 | 1615028 | } | |
| 911 | |||
| 912 | 1615059 | void ff_hevc_hls_filters(HEVCLocalContext *lc, const HEVCLayerContext *l, | |
| 913 | const HEVCPPS *pps, | ||
| 914 | int x_ctb, int y_ctb, int ctb_size) | ||
| 915 | { | ||
| 916 | 1615059 | int x_end = x_ctb >= pps->sps->width - ctb_size; | |
| 917 | 1615059 | int y_end = y_ctb >= pps->sps->height - ctb_size; | |
| 918 |
4/4✓ Branch 0 taken 1482488 times.
✓ Branch 1 taken 132571 times.
✓ Branch 2 taken 1410304 times.
✓ Branch 3 taken 72184 times.
|
1615059 | if (y_ctb && x_ctb) |
| 919 | 1410304 | ff_hevc_hls_filter(lc, l, pps, x_ctb - ctb_size, y_ctb - ctb_size, ctb_size); | |
| 920 |
4/4✓ Branch 0 taken 1482488 times.
✓ Branch 1 taken 132571 times.
✓ Branch 2 taken 72183 times.
✓ Branch 3 taken 1410305 times.
|
1615059 | if (y_ctb && x_end) |
| 921 | 72183 | ff_hevc_hls_filter(lc, l, pps, x_ctb, y_ctb - ctb_size, ctb_size); | |
| 922 |
4/4✓ Branch 0 taken 1532577 times.
✓ Branch 1 taken 82482 times.
✓ Branch 2 taken 122244 times.
✓ Branch 3 taken 1410333 times.
|
1615059 | if (x_ctb && y_end) |
| 923 | 122244 | ff_hevc_hls_filter(lc, l, pps, x_ctb - ctb_size, y_ctb, ctb_size); | |
| 924 | 1615059 | } | |
| 925 |