| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * VVC filters | ||
| 3 | * | ||
| 4 | * Copyright (C) 2021 Nuo Mi | ||
| 5 | * | ||
| 6 | * This file is part of FFmpeg. | ||
| 7 | * | ||
| 8 | * FFmpeg is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU Lesser General Public | ||
| 10 | * License as published by the Free Software Foundation; either | ||
| 11 | * version 2.1 of the License, or (at your option) any later version. | ||
| 12 | * | ||
| 13 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 | * Lesser General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU Lesser General Public | ||
| 19 | * License along with FFmpeg; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include "libavutil/frame.h" | ||
| 24 | #include "libavutil/imgutils.h" | ||
| 25 | |||
| 26 | #include "ctu.h" | ||
| 27 | #include "data.h" | ||
| 28 | #include "filter.h" | ||
| 29 | #include "refs.h" | ||
| 30 | |||
| 31 | #define LEFT 0 | ||
| 32 | #define TOP 1 | ||
| 33 | #define RIGHT 2 | ||
| 34 | #define BOTTOM 3 | ||
| 35 | #define MAX_EDGES 4 | ||
| 36 | |||
| 37 | #define DEFAULT_INTRA_TC_OFFSET 2 | ||
| 38 | |||
| 39 | #define POS(c_idx, x, y) \ | ||
| 40 | &fc->frame->data[c_idx][((y) >> fc->ps.sps->vshift[c_idx]) * fc->frame->linesize[c_idx] + \ | ||
| 41 | (((x) >> fc->ps.sps->hshift[c_idx]) << fc->ps.sps->pixel_shift)] | ||
| 42 | |||
| 43 | //Table 43 Derivation of threshold variables beta' and tc' from input Q | ||
| 44 | static const uint16_t tctable[66] = { | ||
| 45 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 46 | 0, 0, 3, 4, 4, 4, 4, 5, 5, 5, 5, 7, 7, 8, 9, 10, | ||
| 47 | 10, 11, 13, 14, 15, 17, 19, 21, 24, 25, 29, 33, 36, 41, 45, 51, | ||
| 48 | 57, 64, 71, 80, 89, 100, 112, 125, 141, 157, 177, 198, 222, 250, 280, 314, | ||
| 49 | 352, 395, | ||
| 50 | }; | ||
| 51 | |||
| 52 | //Table 43 Derivation of threshold variables beta' and tc' from input Q | ||
| 53 | static const uint8_t betatable[64] = { | ||
| 54 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 55 | 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, | ||
| 56 | 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, | ||
| 57 | 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, | ||
| 58 | }; | ||
| 59 | |||
| 60 | // One vertical and one horizontal virtual boundary in a CTU at most. The CTU will be divided into 4 subblocks. | ||
| 61 | #define MAX_VBBS 4 | ||
| 62 | |||
| 63 | 5153880 | static int get_virtual_boundary(const VVCFrameContext *fc, const int ctu_pos, const int vertical) | |
| 64 | { | ||
| 65 | 5153880 | const VVCSPS *sps = fc->ps.sps; | |
| 66 | 5153880 | const VVCPH *ph = &fc->ps.ph; | |
| 67 |
2/2✓ Branch 0 taken 2609008 times.
✓ Branch 1 taken 2544872 times.
|
5153880 | const uint16_t *vbs = vertical ? ph->vb_pos_x : ph->vb_pos_y; |
| 68 |
2/2✓ Branch 0 taken 2609008 times.
✓ Branch 1 taken 2544872 times.
|
5153880 | const uint8_t nb_vbs = vertical ? ph->num_ver_vbs : ph->num_hor_vbs; |
| 69 | 5153880 | const int pos = ctu_pos << sps->ctb_log2_size_y; | |
| 70 | |||
| 71 |
2/2✓ Branch 0 taken 329281 times.
✓ Branch 1 taken 4824599 times.
|
5153880 | if (sps->r->sps_virtual_boundaries_enabled_flag) { |
| 72 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 329281 times.
|
329281 | for (int i = 0; i < nb_vbs; i++) { |
| 73 | ✗ | const int o = vbs[i] - pos; | |
| 74 | ✗ | if (o >= 0 && o < sps->ctb_size_y) | |
| 75 | ✗ | return vbs[i]; | |
| 76 | } | ||
| 77 | } | ||
| 78 | 5153880 | return 0; | |
| 79 | } | ||
| 80 | |||
| 81 | 5064408 | static int is_virtual_boundary(const VVCFrameContext *fc, const int pos, const int vertical) | |
| 82 | { | ||
| 83 | 5064408 | return get_virtual_boundary(fc, pos >> fc->ps.sps->ctb_log2_size_y, vertical) == pos; | |
| 84 | } | ||
| 85 | |||
| 86 | 9640748 | static int get_qPc(const VVCFrameContext *fc, const int x0, const int y0, const int chroma) | |
| 87 | { | ||
| 88 | 9640748 | const int x = x0 >> MIN_TU_LOG2; | |
| 89 | 9640748 | const int y = y0 >> MIN_TU_LOG2; | |
| 90 | 9640748 | const int min_tu_width = fc->ps.pps->min_tu_width; | |
| 91 | 9640748 | return fc->tab.qp[chroma][x + y * min_tu_width]; | |
| 92 | } | ||
| 93 | |||
| 94 | 58771 | static void copy_ctb(uint8_t *dst, const uint8_t *src, const int width, const int height, | |
| 95 | const ptrdiff_t dst_stride, const ptrdiff_t src_stride) | ||
| 96 | { | ||
| 97 |
2/2✓ Branch 0 taken 5774084 times.
✓ Branch 1 taken 58771 times.
|
5832855 | for (int y = 0; y < height; y++) { |
| 98 | 5774084 | memcpy(dst, src, width); | |
| 99 | |||
| 100 | 5774084 | dst += dst_stride; | |
| 101 | 5774084 | src += src_stride; | |
| 102 | } | ||
| 103 | 58771 | } | |
| 104 | |||
| 105 | 31745 | static void copy_pixel(uint8_t *dst, const uint8_t *src, const int pixel_shift) | |
| 106 | { | ||
| 107 |
2/2✓ Branch 0 taken 29529 times.
✓ Branch 1 taken 2216 times.
|
31745 | if (pixel_shift) |
| 108 | 29529 | *(uint16_t *)dst = *(uint16_t *)src; | |
| 109 | else | ||
| 110 | 2216 | *dst = *src; | |
| 111 | 31745 | } | |
| 112 | |||
| 113 | 336687 | static void copy_vert(uint8_t *dst, const uint8_t *src, const int pixel_shift, const int height, | |
| 114 | const ptrdiff_t dst_stride, const ptrdiff_t src_stride) | ||
| 115 | { | ||
| 116 | int i; | ||
| 117 |
2/2✓ Branch 0 taken 8743 times.
✓ Branch 1 taken 327944 times.
|
336687 | if (pixel_shift == 0) { |
| 118 |
2/2✓ Branch 0 taken 370688 times.
✓ Branch 1 taken 8743 times.
|
379431 | for (i = 0; i < height; i++) { |
| 119 | 370688 | *dst = *src; | |
| 120 | 370688 | dst += dst_stride; | |
| 121 | 370688 | src += src_stride; | |
| 122 | } | ||
| 123 | } else { | ||
| 124 |
2/2✓ Branch 0 taken 31617656 times.
✓ Branch 1 taken 327944 times.
|
31945600 | for (i = 0; i < height; i++) { |
| 125 | 31617656 | *(uint16_t *)dst = *(uint16_t *)src; | |
| 126 | 31617656 | dst += dst_stride; | |
| 127 | 31617656 | src += src_stride; | |
| 128 | } | ||
| 129 | } | ||
| 130 | 336687 | } | |
| 131 | |||
| 132 | 317838 | static void copy_ctb_to_hv(VVCFrameContext *fc, const uint8_t *src, | |
| 133 | const ptrdiff_t src_stride, const int x, const int y, const int width, const int height, | ||
| 134 | const int c_idx, const int rx, const int ry, const int top) | ||
| 135 | { | ||
| 136 | 317838 | const int ps = fc->ps.sps->pixel_shift; | |
| 137 | 317838 | const int w = fc->ps.pps->width >> fc->ps.sps->hshift[c_idx]; | |
| 138 | 317838 | const int h = fc->ps.pps->height >> fc->ps.sps->vshift[c_idx]; | |
| 139 | |||
| 140 |
2/2✓ Branch 0 taken 158919 times.
✓ Branch 1 taken 158919 times.
|
317838 | if (top) { |
| 141 | /* top */ | ||
| 142 | 158919 | memcpy(fc->tab.sao_pixel_buffer_h[c_idx] + (((2 * ry) * w + x) << ps), | |
| 143 | 158919 | src, width << ps); | |
| 144 | } else { | ||
| 145 | /* bottom */ | ||
| 146 | 158919 | memcpy(fc->tab.sao_pixel_buffer_h[c_idx] + (((2 * ry + 1) * w + x) << ps), | |
| 147 | 158919 | src + src_stride * (height - 1), width << ps); | |
| 148 | |||
| 149 | /* copy vertical edges */ | ||
| 150 | 158919 | copy_vert(fc->tab.sao_pixel_buffer_v[c_idx] + (((2 * rx) * h + y) << ps), src, ps, height, 1 << ps, src_stride); | |
| 151 | 158919 | copy_vert(fc->tab.sao_pixel_buffer_v[c_idx] + (((2 * rx + 1) * h + y) << ps), src + ((width - 1) << ps), ps, height, 1 << ps, src_stride); | |
| 152 | } | ||
| 153 | 317838 | } | |
| 154 | |||
| 155 | 106650 | static void sao_copy_ctb_to_hv(VVCLocalContext *lc, const int rx, const int ry, const int top) | |
| 156 | { | ||
| 157 | 106650 | VVCFrameContext *fc = lc->fc; | |
| 158 | 106650 | const int ctb_size_y = fc->ps.sps->ctb_size_y; | |
| 159 | 106650 | const int x0 = rx << fc->ps.sps->ctb_log2_size_y; | |
| 160 | 106650 | const int y0 = ry << fc->ps.sps->ctb_log2_size_y; | |
| 161 | |||
| 162 |
4/4✓ Branch 0 taken 422376 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 317838 times.
✓ Branch 3 taken 106650 times.
|
424488 | for (int c_idx = 0; c_idx < (fc->ps.sps->r->sps_chroma_format_idc ? 3 : 1); c_idx++) { |
| 163 | 317838 | const int x = x0 >> fc->ps.sps->hshift[c_idx]; | |
| 164 | 317838 | const int y = y0 >> fc->ps.sps->vshift[c_idx]; | |
| 165 | 317838 | const ptrdiff_t src_stride = fc->frame->linesize[c_idx]; | |
| 166 | 317838 | const int ctb_size_h = ctb_size_y >> fc->ps.sps->hshift[c_idx]; | |
| 167 | 317838 | const int ctb_size_v = ctb_size_y >> fc->ps.sps->vshift[c_idx]; | |
| 168 | 317838 | const int width = FFMIN(ctb_size_h, (fc->ps.pps->width >> fc->ps.sps->hshift[c_idx]) - x); | |
| 169 | 317838 | const int height = FFMIN(ctb_size_v, (fc->ps.pps->height >> fc->ps.sps->vshift[c_idx]) - y); | |
| 170 | 317838 | const uint8_t *src = POS(c_idx, x0, y0); | |
| 171 | 317838 | copy_ctb_to_hv(fc, src, src_stride, x, y, width, height, c_idx, rx, ry, top); | |
| 172 | } | ||
| 173 | 106650 | } | |
| 174 | |||
| 175 | 53325 | void ff_vvc_sao_copy_ctb_to_hv(VVCLocalContext *lc, const int rx, const int ry, const int last_row) | |
| 176 | { | ||
| 177 |
2/2✓ Branch 0 taken 44892 times.
✓ Branch 1 taken 8433 times.
|
53325 | if (ry) |
| 178 | 44892 | sao_copy_ctb_to_hv(lc, rx, ry - 1, 0); | |
| 179 | |||
| 180 | 53325 | sao_copy_ctb_to_hv(lc, rx, ry, 1); | |
| 181 | |||
| 182 |
2/2✓ Branch 0 taken 8433 times.
✓ Branch 1 taken 44892 times.
|
53325 | if (last_row) |
| 183 | 8433 | sao_copy_ctb_to_hv(lc, rx, ry, 0); | |
| 184 | 53325 | } | |
| 185 | |||
| 186 | 330450 | static int sao_can_cross_slices(const VVCFrameContext *fc, const int rx, const int ry, const int dx, const int dy) | |
| 187 | { | ||
| 188 | 330450 | const uint8_t lfase = fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag; | |
| 189 | |||
| 190 |
4/4✓ Branch 0 taken 327330 times.
✓ Branch 1 taken 3120 times.
✓ Branch 2 taken 324598 times.
✓ Branch 3 taken 2732 times.
|
330450 | return lfase || CTB(fc->tab.slice_idx, rx, ry) == CTB(fc->tab.slice_idx, rx + dx, ry + dy); |
| 191 | } | ||
| 192 | |||
| 193 | 53325 | static void sao_get_edges(uint8_t vert_edge[2], uint8_t horiz_edge[2], uint8_t diag_edge[4], int *restore, | |
| 194 | const VVCLocalContext *lc, const int edges[4], const int rx, const int ry) | ||
| 195 | { | ||
| 196 | 53325 | const VVCFrameContext *fc = lc->fc; | |
| 197 | 53325 | const VVCSPS *sps = fc->ps.sps; | |
| 198 | 53325 | const H266RawSPS *rsps = sps->r; | |
| 199 | 53325 | const VVCPPS *pps = fc->ps.pps; | |
| 200 | 53325 | const int subpic_idx = lc->sc->sh.r->curr_subpic_idx; | |
| 201 | 53325 | const uint8_t lfase = fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag; | |
| 202 |
4/4✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 48244 times.
✓ Branch 2 taken 1662 times.
✓ Branch 3 taken 3419 times.
|
53325 | const uint8_t no_tile_filter = pps->r->num_tiles_in_pic > 1 && !pps->r->pps_loop_filter_across_tiles_enabled_flag; |
| 203 |
4/4✓ Branch 0 taken 2103 times.
✓ Branch 1 taken 51222 times.
✓ Branch 2 taken 1137 times.
✓ Branch 3 taken 966 times.
|
53325 | const uint8_t no_subpic_filter = rsps->sps_num_subpics_minus1 && !rsps->sps_loop_filter_across_subpic_enabled_flag[subpic_idx]; |
| 204 | 53325 | uint8_t lf_edge[] = { 0, 0, 0, 0 }; | |
| 205 | |||
| 206 |
8/8✓ Branch 0 taken 52188 times.
✓ Branch 1 taken 1137 times.
✓ Branch 2 taken 51636 times.
✓ Branch 3 taken 552 times.
✓ Branch 4 taken 3162 times.
✓ Branch 5 taken 48474 times.
✓ Branch 6 taken 184 times.
✓ Branch 7 taken 2978 times.
|
53325 | *restore = no_subpic_filter || no_tile_filter || !lfase || rsps->sps_virtual_boundaries_enabled_flag; |
| 207 | |||
| 208 |
2/2✓ Branch 0 taken 2978 times.
✓ Branch 1 taken 50347 times.
|
53325 | if (!*restore) |
| 209 | 2978 | return; | |
| 210 | |||
| 211 |
2/2✓ Branch 0 taken 45699 times.
✓ Branch 1 taken 4648 times.
|
50347 | if (!edges[LEFT]) { |
| 212 |
4/4✓ Branch 0 taken 1458 times.
✓ Branch 1 taken 44241 times.
✓ Branch 2 taken 612 times.
✓ Branch 3 taken 846 times.
|
45699 | lf_edge[LEFT] = no_tile_filter && pps->ctb_to_col_bd[rx] == rx; |
| 213 |
4/4✓ Branch 0 taken 1017 times.
✓ Branch 1 taken 44682 times.
✓ Branch 2 taken 309 times.
✓ Branch 3 taken 708 times.
|
45699 | lf_edge[LEFT] |= no_subpic_filter && rsps->sps_subpic_ctu_top_left_x[subpic_idx] == rx; |
| 214 | 45699 | lf_edge[LEFT] |= is_virtual_boundary(fc, rx << sps->ctb_log2_size_y, 1); | |
| 215 |
4/4✓ Branch 1 taken 45400 times.
✓ Branch 2 taken 299 times.
✓ Branch 3 taken 322 times.
✓ Branch 4 taken 45078 times.
|
45699 | vert_edge[0] = !sao_can_cross_slices(fc, rx, ry, -1, 0) || lf_edge[LEFT]; |
| 216 | } | ||
| 217 |
2/2✓ Branch 0 taken 45699 times.
✓ Branch 1 taken 4648 times.
|
50347 | if (!edges[RIGHT]) { |
| 218 |
4/4✓ Branch 0 taken 1458 times.
✓ Branch 1 taken 44241 times.
✓ Branch 2 taken 612 times.
✓ Branch 3 taken 846 times.
|
45699 | lf_edge[RIGHT] = no_tile_filter && pps->ctb_to_col_bd[rx] != pps->ctb_to_col_bd[rx + 1]; |
| 219 |
4/4✓ Branch 0 taken 996 times.
✓ Branch 1 taken 44703 times.
✓ Branch 2 taken 288 times.
✓ Branch 3 taken 708 times.
|
45699 | lf_edge[RIGHT] |= no_subpic_filter && rsps->sps_subpic_ctu_top_left_x[subpic_idx] + rsps->sps_subpic_width_minus1[subpic_idx] == rx; |
| 220 | 45699 | lf_edge[RIGHT] |= is_virtual_boundary(fc, (rx + 1) << sps->ctb_log2_size_y, 1); | |
| 221 |
4/4✓ Branch 1 taken 45400 times.
✓ Branch 2 taken 299 times.
✓ Branch 3 taken 318 times.
✓ Branch 4 taken 45082 times.
|
45699 | vert_edge[1] = !sao_can_cross_slices(fc, rx, ry, 1, 0) || lf_edge[RIGHT]; |
| 222 | } | ||
| 223 |
2/2✓ Branch 0 taken 42248 times.
✓ Branch 1 taken 8099 times.
|
50347 | if (!edges[TOP]) { |
| 224 |
4/4✓ Branch 0 taken 1356 times.
✓ Branch 1 taken 40892 times.
✓ Branch 2 taken 564 times.
✓ Branch 3 taken 792 times.
|
42248 | lf_edge[TOP] = no_tile_filter && pps->ctb_to_row_bd[ry] == ry; |
| 225 |
4/4✓ Branch 0 taken 852 times.
✓ Branch 1 taken 41396 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 630 times.
|
42248 | lf_edge[TOP] |= no_subpic_filter && rsps->sps_subpic_ctu_top_left_y[subpic_idx] == ry; |
| 226 | 42248 | lf_edge[TOP] |= is_virtual_boundary(fc, ry << sps->ctb_log2_size_y, 0); | |
| 227 |
4/4✓ Branch 1 taken 41895 times.
✓ Branch 2 taken 353 times.
✓ Branch 3 taken 282 times.
✓ Branch 4 taken 41613 times.
|
42248 | horiz_edge[0] = !sao_can_cross_slices(fc, rx, ry, 0, -1) || lf_edge[TOP]; |
| 228 | } | ||
| 229 |
2/2✓ Branch 0 taken 42248 times.
✓ Branch 1 taken 8099 times.
|
50347 | if (!edges[BOTTOM]) { |
| 230 |
4/4✓ Branch 0 taken 1356 times.
✓ Branch 1 taken 40892 times.
✓ Branch 2 taken 564 times.
✓ Branch 3 taken 792 times.
|
42248 | lf_edge[BOTTOM] = no_tile_filter && pps->ctb_to_row_bd[ry] != pps->ctb_to_row_bd[ry + 1]; |
| 231 |
4/4✓ Branch 0 taken 915 times.
✓ Branch 1 taken 41333 times.
✓ Branch 2 taken 285 times.
✓ Branch 3 taken 630 times.
|
42248 | lf_edge[BOTTOM] |= no_subpic_filter && rsps->sps_subpic_ctu_top_left_y[subpic_idx] + rsps->sps_subpic_height_minus1[subpic_idx] == ry; |
| 232 | 42248 | lf_edge[BOTTOM] |= is_virtual_boundary(fc, (ry + 1) << sps->ctb_log2_size_y, 0); | |
| 233 |
4/4✓ Branch 1 taken 41895 times.
✓ Branch 2 taken 353 times.
✓ Branch 3 taken 294 times.
✓ Branch 4 taken 41601 times.
|
42248 | horiz_edge[1] = !sao_can_cross_slices(fc, rx, ry, 0, 1) || lf_edge[BOTTOM]; |
| 234 | } | ||
| 235 | |||
| 236 |
4/4✓ Branch 0 taken 45699 times.
✓ Branch 1 taken 4648 times.
✓ Branch 2 taken 38639 times.
✓ Branch 3 taken 7060 times.
|
50347 | if (!edges[LEFT] && !edges[TOP]) |
| 237 |
6/6✓ Branch 1 taken 38282 times.
✓ Branch 2 taken 357 times.
✓ Branch 3 taken 38030 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 144 times.
✓ Branch 6 taken 37886 times.
|
38639 | diag_edge[0] = !sao_can_cross_slices(fc, rx, ry, -1, -1) || lf_edge[LEFT] || lf_edge[TOP]; |
| 238 | |||
| 239 |
4/4✓ Branch 0 taken 42248 times.
✓ Branch 1 taken 8099 times.
✓ Branch 2 taken 38639 times.
✓ Branch 3 taken 3609 times.
|
50347 | if (!edges[TOP] && !edges[RIGHT]) |
| 240 |
6/6✓ Branch 1 taken 38282 times.
✓ Branch 2 taken 357 times.
✓ Branch 3 taken 38030 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 144 times.
✓ Branch 6 taken 37886 times.
|
38639 | diag_edge[1] = !sao_can_cross_slices(fc, rx, ry, 1, -1) || lf_edge[RIGHT] || lf_edge[TOP]; |
| 241 | |||
| 242 |
4/4✓ Branch 0 taken 45699 times.
✓ Branch 1 taken 4648 times.
✓ Branch 2 taken 38639 times.
✓ Branch 3 taken 7060 times.
|
50347 | if (!edges[RIGHT] && !edges[BOTTOM]) |
| 243 |
6/6✓ Branch 1 taken 38282 times.
✓ Branch 2 taken 357 times.
✓ Branch 3 taken 38030 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 37878 times.
|
38639 | diag_edge[2] = !sao_can_cross_slices(fc, rx, ry, 1, 1) || lf_edge[RIGHT] || lf_edge[BOTTOM]; |
| 244 | |||
| 245 |
4/4✓ Branch 0 taken 45699 times.
✓ Branch 1 taken 4648 times.
✓ Branch 2 taken 38639 times.
✓ Branch 3 taken 7060 times.
|
50347 | if (!edges[LEFT] && !edges[BOTTOM]) |
| 246 |
6/6✓ Branch 1 taken 38282 times.
✓ Branch 2 taken 357 times.
✓ Branch 3 taken 38026 times.
✓ Branch 4 taken 256 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 37874 times.
|
38639 | diag_edge[3] = !sao_can_cross_slices(fc, rx, ry, -1, 1) || lf_edge[LEFT] || lf_edge[BOTTOM]; |
| 247 | } | ||
| 248 | |||
| 249 | 17276 | static void sao_copy_hor(uint8_t *dst, const ptrdiff_t dst_stride, | |
| 250 | const uint8_t *src, const ptrdiff_t src_stride, const int width, const int edges[4], const int ps) | ||
| 251 | { | ||
| 252 | 17276 | const int left = 1 - edges[LEFT]; | |
| 253 | 17276 | const int right = 1 - edges[RIGHT]; | |
| 254 | 17276 | int pos = 0; | |
| 255 | |||
| 256 | 17276 | src -= left << ps; | |
| 257 | 17276 | dst -= left << ps; | |
| 258 | |||
| 259 |
2/2✓ Branch 0 taken 15771 times.
✓ Branch 1 taken 1505 times.
|
17276 | if (left) { |
| 260 | 15771 | copy_pixel(dst, src, ps); | |
| 261 | 15771 | pos += (1 << ps); | |
| 262 | } | ||
| 263 | 17276 | memcpy(dst + pos, src + pos, width << ps); | |
| 264 |
2/2✓ Branch 0 taken 15974 times.
✓ Branch 1 taken 1302 times.
|
17276 | if (right) { |
| 265 | 15974 | pos += width << ps; | |
| 266 | 15974 | copy_pixel(dst + pos, src + pos, ps); | |
| 267 | } | ||
| 268 | 17276 | } | |
| 269 | |||
| 270 | 10370 | static void sao_extends_edges(uint8_t *dst, const ptrdiff_t dst_stride, | |
| 271 | const uint8_t *src, const ptrdiff_t src_stride, const int width, const int height, | ||
| 272 | const VVCFrameContext *fc, const int x0, const int y0, const int rx, const int ry, const int edges[4], const int c_idx) | ||
| 273 | { | ||
| 274 | 10370 | const uint8_t *sao_h = fc->tab.sao_pixel_buffer_h[c_idx]; | |
| 275 | 10370 | const uint8_t *sao_v = fc->tab.sao_pixel_buffer_v[c_idx]; | |
| 276 | 10370 | const int x = x0 >> fc->ps.sps->hshift[c_idx]; | |
| 277 | 10370 | const int y = y0 >> fc->ps.sps->vshift[c_idx]; | |
| 278 | 10370 | const int w = fc->ps.pps->width >> fc->ps.sps->hshift[c_idx]; | |
| 279 | 10370 | const int h = fc->ps.pps->height >> fc->ps.sps->vshift[c_idx]; | |
| 280 | 10370 | const int ps = fc->ps.sps->pixel_shift; | |
| 281 | |||
| 282 |
2/2✓ Branch 0 taken 8652 times.
✓ Branch 1 taken 1718 times.
|
10370 | if (!edges[TOP]) |
| 283 | 8652 | sao_copy_hor(dst - dst_stride, dst_stride, sao_h + (((2 * ry - 1) * w + x) << ps), src_stride, width, edges, ps); | |
| 284 | |||
| 285 |
2/2✓ Branch 0 taken 8624 times.
✓ Branch 1 taken 1746 times.
|
10370 | if (!edges[BOTTOM]) |
| 286 | 8624 | sao_copy_hor(dst + height * dst_stride, dst_stride, sao_h + (((2 * ry + 2) * w + x) << ps), src_stride, width, edges, ps); | |
| 287 | |||
| 288 |
2/2✓ Branch 0 taken 9384 times.
✓ Branch 1 taken 986 times.
|
10370 | if (!edges[LEFT]) |
| 289 | 9384 | copy_vert(dst - (1 << ps), sao_v + (((2 * rx - 1) * h + y) << ps), ps, height, dst_stride, 1 << ps); | |
| 290 | |||
| 291 |
2/2✓ Branch 0 taken 9465 times.
✓ Branch 1 taken 905 times.
|
10370 | if (!edges[RIGHT]) |
| 292 | 9465 | copy_vert(dst + (width << ps), sao_v + (((2 * rx + 2) * h + y) << ps), ps, height, dst_stride, 1 << ps); | |
| 293 | |||
| 294 | 10370 | copy_ctb(dst, src, width << ps, height, dst_stride, src_stride); | |
| 295 | 10370 | } | |
| 296 | |||
| 297 | ✗ | static void sao_restore_vb(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, | |
| 298 | const int width, const int height, const int vb_pos, const int ps, const int vertical) | ||
| 299 | { | ||
| 300 | ✗ | int w = 2; | |
| 301 | ✗ | int h = (vertical ? height : width); | |
| 302 | ✗ | int dx = vb_pos - 1; | |
| 303 | ✗ | int dy = 0; | |
| 304 | |||
| 305 | ✗ | if (!vertical) { | |
| 306 | ✗ | FFSWAP(int, w, h); | |
| 307 | ✗ | FFSWAP(int, dx, dy); | |
| 308 | } | ||
| 309 | ✗ | dst += dy * dst_stride +(dx << ps); | |
| 310 | ✗ | src += dy * src_stride +(dx << ps); | |
| 311 | |||
| 312 | ✗ | av_image_copy_plane(dst, dst_stride, src, src_stride, w << ps, h); | |
| 313 | ✗ | } | |
| 314 | |||
| 315 | 53325 | void ff_vvc_sao_filter(VVCLocalContext *lc, int x0, int y0) | |
| 316 | { | ||
| 317 | 53325 | VVCFrameContext *fc = lc->fc; | |
| 318 | 53325 | const VVCSPS *sps = fc->ps.sps; | |
| 319 | 53325 | const int rx = x0 >> sps->ctb_log2_size_y; | |
| 320 | 53325 | const int ry = y0 >> sps->ctb_log2_size_y; | |
| 321 | 53325 | const int edges[4] = { !rx, !ry, rx == fc->ps.pps->ctb_width - 1, ry == fc->ps.pps->ctb_height - 1 }; | |
| 322 | 53325 | const SAOParams *sao = &CTB(fc->tab.sao, rx, ry); | |
| 323 | // flags indicating unfilterable edges | ||
| 324 | 53325 | uint8_t vert_edge[] = { 0, 0 }; | |
| 325 | 53325 | uint8_t horiz_edge[] = { 0, 0 }; | |
| 326 | 53325 | uint8_t diag_edge[] = { 0, 0, 0, 0 }; | |
| 327 | 53325 | int restore, vb_x = 0, vb_y = 0;; | |
| 328 | |||
| 329 |
2/2✓ Branch 0 taken 1029 times.
✓ Branch 1 taken 52296 times.
|
53325 | if (sps->r->sps_virtual_boundaries_enabled_flag) { |
| 330 | 1029 | vb_x = get_virtual_boundary(fc, rx, 1); | |
| 331 | 1029 | vb_y = get_virtual_boundary(fc, ry, 0); | |
| 332 | } | ||
| 333 | |||
| 334 | 53325 | sao_get_edges(vert_edge, horiz_edge, diag_edge, &restore, lc, edges, rx, ry); | |
| 335 | |||
| 336 |
4/4✓ Branch 0 taken 211188 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 158919 times.
✓ Branch 3 taken 53325 times.
|
212244 | for (int c_idx = 0; c_idx < (sps->r->sps_chroma_format_idc ? 3 : 1); c_idx++) { |
| 337 | static const uint8_t sao_tab[16] = { 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8 }; | ||
| 338 | 158919 | const ptrdiff_t src_stride = fc->frame->linesize[c_idx]; | |
| 339 | 158919 | uint8_t *src = POS(c_idx, x0, y0); | |
| 340 | 158919 | const int hs = sps->hshift[c_idx]; | |
| 341 | 158919 | const int vs = sps->vshift[c_idx]; | |
| 342 | 158919 | const int ps = sps->pixel_shift; | |
| 343 | 158919 | const int width = FFMIN(sps->ctb_size_y, fc->ps.pps->width - x0) >> hs; | |
| 344 | 158919 | const int height = FFMIN(sps->ctb_size_y, fc->ps.pps->height - y0) >> vs; | |
| 345 | 158919 | const int tab = sao_tab[(FFALIGN(width, 8) >> 3) - 1]; | |
| 346 | 158919 | const int sao_eo_class = sao->eo_class[c_idx]; | |
| 347 | |||
| 348 |
3/3✓ Branch 0 taken 6152 times.
✓ Branch 1 taken 10370 times.
✓ Branch 2 taken 142397 times.
|
158919 | switch (sao->type_idx[c_idx]) { |
| 349 | 6152 | case SAO_BAND: | |
| 350 | 6152 | fc->vvcdsp.sao.band_filter[tab](src, src, src_stride, src_stride, | |
| 351 | 6152 | sao->offset_val[c_idx], sao->band_position[c_idx], width, height); | |
| 352 | 6152 | break; | |
| 353 | 10370 | case SAO_EDGE: | |
| 354 | { | ||
| 355 | 10370 | const ptrdiff_t dst_stride = 2 * MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE; | |
| 356 | 10370 | uint8_t *dst = lc->sao.buffer + dst_stride + AV_INPUT_BUFFER_PADDING_SIZE; | |
| 357 | |||
| 358 | 10370 | sao_extends_edges(dst, dst_stride, src, src_stride, width, height, fc, x0, y0, rx, ry, edges, c_idx); | |
| 359 | |||
| 360 | 10370 | fc->vvcdsp.sao.edge_filter[tab](src, dst, src_stride, sao->offset_val[c_idx], | |
| 361 | 10370 | sao->eo_class[c_idx], width, height); | |
| 362 | 10370 | fc->vvcdsp.sao.edge_restore[restore](src, dst, src_stride, dst_stride, | |
| 363 | sao, edges, width, height, c_idx, vert_edge, horiz_edge, diag_edge); | ||
| 364 | |||
| 365 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 10370 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
10370 | if (vb_x > x0 && sao_eo_class != SAO_EO_VERT) |
| 366 | ✗ | sao_restore_vb(src, src_stride, dst, dst_stride, width, height, (vb_x - x0) >> hs, ps, 1); | |
| 367 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 10370 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
10370 | if (vb_y > y0 && sao_eo_class != SAO_EO_HORIZ) |
| 368 | ✗ | sao_restore_vb(src, src_stride, dst, dst_stride, width, height, (vb_y - y0) >> vs, ps, 0); | |
| 369 | |||
| 370 | 10370 | break; | |
| 371 | } | ||
| 372 | } | ||
| 373 | } | ||
| 374 | 53325 | } | |
| 375 | |||
| 376 | #define TAB_BS(t, x, y) (t)[((y) >> MIN_TU_LOG2) * (fc->ps.pps->min_tu_width) + ((x) >> MIN_TU_LOG2)] | ||
| 377 | #define TAB_MAX_LEN(t, x, y) (t)[((y) >> MIN_TU_LOG2) * (fc->ps.pps->min_tu_width) + ((x) >> MIN_TU_LOG2)] | ||
| 378 | |||
| 379 | //8 samples a time | ||
| 380 | #define DEBLOCK_STEP 8 | ||
| 381 | #define LUMA_GRID 4 | ||
| 382 | #define CHROMA_GRID 8 | ||
| 383 | |||
| 384 | 11546862 | static int boundary_strength(const VVCLocalContext *lc, const MvField *curr, const MvField *neigh, | |
| 385 | const RefPicList *neigh_rpl) | ||
| 386 | { | ||
| 387 | 11546862 | RefPicList *rpl = lc->sc->rpl; | |
| 388 | |||
| 389 |
2/2✓ Branch 0 taken 12708 times.
✓ Branch 1 taken 11534154 times.
|
11546862 | if (curr->pred_flag == PF_PLT) |
| 390 | 12708 | return 0; | |
| 391 | |||
| 392 |
2/2✓ Branch 0 taken 154438 times.
✓ Branch 1 taken 11379716 times.
|
11534154 | if (curr->pred_flag == PF_IBC) |
| 393 |
4/4✓ Branch 0 taken 87234 times.
✓ Branch 1 taken 67204 times.
✓ Branch 2 taken 6750 times.
✓ Branch 3 taken 80484 times.
|
154438 | return FFABS(neigh->mv[0].x - curr->mv[0].x) >= 8 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 8; |
| 394 | |||
| 395 |
4/4✓ Branch 0 taken 5537520 times.
✓ Branch 1 taken 5842196 times.
✓ Branch 2 taken 5196699 times.
✓ Branch 3 taken 340821 times.
|
11379716 | if (curr->pred_flag == PF_BI && neigh->pred_flag == PF_BI) { |
| 396 | // same L0 and L1 | ||
| 397 |
2/2✓ Branch 0 taken 5114599 times.
✓ Branch 1 taken 82100 times.
|
5196699 | if (rpl[L0].refs[curr->ref_idx[L0]].poc == neigh_rpl[L0].refs[neigh->ref_idx[L0]].poc && |
| 398 |
2/2✓ Branch 0 taken 554793 times.
✓ Branch 1 taken 4559806 times.
|
5114599 | rpl[L0].refs[curr->ref_idx[L0]].poc == rpl[L1].refs[curr->ref_idx[L1]].poc && |
| 399 |
2/2✓ Branch 0 taken 551249 times.
✓ Branch 1 taken 3544 times.
|
554793 | neigh_rpl[L0].refs[neigh->ref_idx[L0]].poc == neigh_rpl[L1].refs[neigh->ref_idx[L1]].poc) { |
| 400 |
4/4✓ Branch 0 taken 503952 times.
✓ Branch 1 taken 47297 times.
✓ Branch 2 taken 478187 times.
✓ Branch 3 taken 25765 times.
|
551249 | if ((FFABS(neigh->mv[0].x - curr->mv[0].x) >= 8 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 8 || |
| 401 |
4/4✓ Branch 0 taken 474364 times.
✓ Branch 1 taken 3823 times.
✓ Branch 2 taken 3253 times.
✓ Branch 3 taken 471111 times.
|
478187 | FFABS(neigh->mv[1].x - curr->mv[1].x) >= 8 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 8) && |
| 402 |
4/4✓ Branch 0 taken 19736 times.
✓ Branch 1 taken 60402 times.
✓ Branch 2 taken 4909 times.
✓ Branch 3 taken 14827 times.
|
80138 | (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 8 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 8 || |
| 403 |
4/4✓ Branch 0 taken 2557 times.
✓ Branch 1 taken 2352 times.
✓ Branch 2 taken 2041 times.
✓ Branch 3 taken 516 times.
|
4909 | FFABS(neigh->mv[0].x - curr->mv[1].x) >= 8 || FFABS(neigh->mv[0].y - curr->mv[1].y) >= 8)) |
| 404 | 79622 | return 1; | |
| 405 | else | ||
| 406 | 471627 | return 0; | |
| 407 |
2/2✓ Branch 0 taken 4563350 times.
✓ Branch 1 taken 82100 times.
|
4645450 | } else if (neigh_rpl[L0].refs[neigh->ref_idx[L0]].poc == rpl[L0].refs[curr->ref_idx[L0]].poc && |
| 408 |
2/2✓ Branch 0 taken 4542978 times.
✓ Branch 1 taken 20372 times.
|
4563350 | neigh_rpl[L1].refs[neigh->ref_idx[L1]].poc == rpl[L1].refs[curr->ref_idx[L1]].poc) { |
| 409 |
4/4✓ Branch 0 taken 4003606 times.
✓ Branch 1 taken 539372 times.
✓ Branch 2 taken 3845931 times.
✓ Branch 3 taken 157675 times.
|
4542978 | if (FFABS(neigh->mv[0].x - curr->mv[0].x) >= 8 || FFABS(neigh->mv[0].y - curr->mv[0].y) >= 8 || |
| 410 |
4/4✓ Branch 0 taken 3811536 times.
✓ Branch 1 taken 34395 times.
✓ Branch 2 taken 21517 times.
✓ Branch 3 taken 3790019 times.
|
3845931 | FFABS(neigh->mv[1].x - curr->mv[1].x) >= 8 || FFABS(neigh->mv[1].y - curr->mv[1].y) >= 8) |
| 411 | 752959 | return 1; | |
| 412 | else | ||
| 413 | 3790019 | return 0; | |
| 414 |
2/2✓ Branch 0 taken 28007 times.
✓ Branch 1 taken 74465 times.
|
102472 | } else if (neigh_rpl[L1].refs[neigh->ref_idx[L1]].poc == rpl[L0].refs[curr->ref_idx[L0]].poc && |
| 415 |
2/2✓ Branch 0 taken 8707 times.
✓ Branch 1 taken 19300 times.
|
28007 | neigh_rpl[L0].refs[neigh->ref_idx[L0]].poc == rpl[L1].refs[curr->ref_idx[L1]].poc) { |
| 416 |
4/4✓ Branch 0 taken 2997 times.
✓ Branch 1 taken 5710 times.
✓ Branch 2 taken 1184 times.
✓ Branch 3 taken 1813 times.
|
8707 | if (FFABS(neigh->mv[1].x - curr->mv[0].x) >= 8 || FFABS(neigh->mv[1].y - curr->mv[0].y) >= 8 || |
| 417 |
4/4✓ Branch 0 taken 869 times.
✓ Branch 1 taken 315 times.
✓ Branch 2 taken 180 times.
✓ Branch 3 taken 689 times.
|
1184 | FFABS(neigh->mv[0].x - curr->mv[1].x) >= 8 || FFABS(neigh->mv[0].y - curr->mv[1].y) >= 8) |
| 418 | 8018 | return 1; | |
| 419 | else | ||
| 420 | 689 | return 0; | |
| 421 | } else { | ||
| 422 | 93765 | return 1; | |
| 423 | } | ||
| 424 |
4/4✓ Branch 0 taken 5842196 times.
✓ Branch 1 taken 340821 times.
✓ Branch 2 taken 5493980 times.
✓ Branch 3 taken 348216 times.
|
6183017 | } else if ((curr->pred_flag != PF_BI) && (neigh->pred_flag != PF_BI)){ // 1 MV |
| 425 | Mv A, B; | ||
| 426 | int ref_A, ref_B; | ||
| 427 | |||
| 428 |
2/2✓ Branch 0 taken 4252125 times.
✓ Branch 1 taken 1241855 times.
|
5493980 | if (curr->pred_flag & 1) { |
| 429 | 4252125 | A = curr->mv[0]; | |
| 430 | 4252125 | ref_A = rpl[L0].refs[curr->ref_idx[L0]].poc; | |
| 431 | } else { | ||
| 432 | 1241855 | A = curr->mv[1]; | |
| 433 | 1241855 | ref_A = rpl[L1].refs[curr->ref_idx[L1]].poc; | |
| 434 | } | ||
| 435 | |||
| 436 |
2/2✓ Branch 0 taken 4250602 times.
✓ Branch 1 taken 1243378 times.
|
5493980 | if (neigh->pred_flag & 1) { |
| 437 | 4250602 | B = neigh->mv[0]; | |
| 438 | 4250602 | ref_B = neigh_rpl[L0].refs[neigh->ref_idx[L0]].poc; | |
| 439 | } else { | ||
| 440 | 1243378 | B = neigh->mv[1]; | |
| 441 | 1243378 | ref_B = neigh_rpl[L1].refs[neigh->ref_idx[L1]].poc; | |
| 442 | } | ||
| 443 | |||
| 444 |
2/2✓ Branch 0 taken 5327791 times.
✓ Branch 1 taken 166189 times.
|
5493980 | if (ref_A == ref_B) { |
| 445 |
4/4✓ Branch 0 taken 4954988 times.
✓ Branch 1 taken 372803 times.
✓ Branch 2 taken 160926 times.
✓ Branch 3 taken 4794062 times.
|
5327791 | if (FFABS(A.x - B.x) >= 8 || FFABS(A.y - B.y) >= 8) |
| 446 | 533729 | return 1; | |
| 447 | else | ||
| 448 | 4794062 | return 0; | |
| 449 | } else | ||
| 450 | 166189 | return 1; | |
| 451 | } | ||
| 452 | |||
| 453 | 689037 | return 1; | |
| 454 | } | ||
| 455 | |||
| 456 | //part of 8.8.3.3 Derivation process of transform block boundary | ||
| 457 | 12496509 | static void derive_max_filter_length_luma(const VVCFrameContext *fc, const int qx, const int qy, | |
| 458 | const int size_q, const int has_subblock, const int vertical, uint8_t *max_len_p, uint8_t *max_len_q) | ||
| 459 | { | ||
| 460 |
2/2✓ Branch 0 taken 5995508 times.
✓ Branch 1 taken 6501001 times.
|
12496509 | const int px = vertical ? qx - 1 : qx; |
| 461 |
2/2✓ Branch 0 taken 6501001 times.
✓ Branch 1 taken 5995508 times.
|
12496509 | const int py = !vertical ? qy - 1 : qy; |
| 462 |
2/2✓ Branch 0 taken 5995508 times.
✓ Branch 1 taken 6501001 times.
|
12496509 | const uint8_t *tb_size = vertical ? fc->tab.tb_width[LUMA] : fc->tab.tb_height[LUMA]; |
| 463 | 12496509 | const int size_p = tb_size[(py >> MIN_TU_LOG2) * fc->ps.pps->min_tu_width + (px >> MIN_TU_LOG2)]; | |
| 464 | 12496509 | const int min_cb_log2 = fc->ps.sps->min_cb_log2_size_y; | |
| 465 | 12496509 | const int off_p = (py >> min_cb_log2) * fc->ps.pps->min_cb_width + (px >> min_cb_log2); | |
| 466 | |||
| 467 |
4/4✓ Branch 0 taken 10513742 times.
✓ Branch 1 taken 1982767 times.
✓ Branch 2 taken 895063 times.
✓ Branch 3 taken 9618679 times.
|
12496509 | if (size_p <= 4 || size_q <= 4) { |
| 468 | 2877830 | *max_len_p = *max_len_q = 1; | |
| 469 | } else { | ||
| 470 | 9618679 | *max_len_p = *max_len_q = 3; | |
| 471 |
2/2✓ Branch 0 taken 6311344 times.
✓ Branch 1 taken 3307335 times.
|
9618679 | if (size_p >= 32) |
| 472 | 6311344 | *max_len_p = 7; | |
| 473 |
2/2✓ Branch 0 taken 6137122 times.
✓ Branch 1 taken 3481557 times.
|
9618679 | if (size_q >= 32) |
| 474 | 6137122 | *max_len_q = 7; | |
| 475 | } | ||
| 476 |
2/2✓ Branch 0 taken 1397326 times.
✓ Branch 1 taken 11099183 times.
|
12496509 | if (has_subblock) |
| 477 | 1397326 | *max_len_q = FFMIN(5, *max_len_q); | |
| 478 |
4/4✓ Branch 0 taken 11230394 times.
✓ Branch 1 taken 1266115 times.
✓ Branch 2 taken 260568 times.
✓ Branch 3 taken 10969826 times.
|
12496509 | if (fc->tab.msf[off_p] || fc->tab.iaf[off_p]) |
| 479 | 1526683 | *max_len_p = FFMIN(5, *max_len_p); | |
| 480 | 12496509 | } | |
| 481 | |||
| 482 | 167228 | static void vvc_deblock_subblock_bs(const VVCLocalContext *lc, | |
| 483 | const int cb, int x0, int y0, int width, int height, const int vertical) | ||
| 484 | { | ||
| 485 | 167228 | const VVCFrameContext *fc = lc->fc; | |
| 486 | 167228 | const MvField *tab_mvf = fc->tab.mvf; | |
| 487 | 167228 | const RefPicList *rpl = lc->sc->rpl; | |
| 488 | 167228 | int stridea = fc->ps.pps->min_pu_width; | |
| 489 | 167228 | int strideb = 1; | |
| 490 | 167228 | const int log2_min_pu_size = MIN_PU_LOG2; | |
| 491 | |||
| 492 |
2/2✓ Branch 0 taken 84021 times.
✓ Branch 1 taken 83207 times.
|
167228 | if (!vertical) { |
| 493 | 84021 | FFSWAP(int, x0, y0); | |
| 494 | 84021 | FFSWAP(int, width, height); | |
| 495 | 84021 | FFSWAP(int, stridea, strideb); | |
| 496 | } | ||
| 497 | |||
| 498 | // bs for TU internal vertical PU boundaries | ||
| 499 |
2/2✓ Branch 0 taken 605893 times.
✓ Branch 1 taken 167228 times.
|
773121 | for (int i = 8 - ((x0 - cb) % 8); i < width; i += 8) { |
| 500 | 605893 | const int is_vb = is_virtual_boundary(fc, x0 + i, vertical); | |
| 501 | 605893 | const int xp_pu = (x0 + i - 1) >> log2_min_pu_size; | |
| 502 | 605893 | const int xq_pu = (x0 + i) >> log2_min_pu_size; | |
| 503 | |||
| 504 |
2/2✓ Branch 0 taken 6497682 times.
✓ Branch 1 taken 605893 times.
|
7103575 | for (int j = 0; j < height; j += 4) { |
| 505 | 6497682 | const int y_pu = (y0 + j) >> log2_min_pu_size; | |
| 506 | 6497682 | const MvField *mvf_p = &tab_mvf[y_pu * stridea + xp_pu * strideb]; | |
| 507 | 6497682 | const MvField *mvf_q = &tab_mvf[y_pu * stridea + xq_pu * strideb]; | |
| 508 |
1/2✓ Branch 0 taken 6497682 times.
✗ Branch 1 not taken.
|
6497682 | const int bs = is_vb ? 0 : boundary_strength(lc, mvf_q, mvf_p, rpl); |
| 509 | 6497682 | int x = x0 + i; | |
| 510 | 6497682 | int y = y0 + j; | |
| 511 | 6497682 | uint8_t max_len_p = 0, max_len_q = 0; | |
| 512 | |||
| 513 |
2/2✓ Branch 0 taken 3230782 times.
✓ Branch 1 taken 3266900 times.
|
6497682 | if (!vertical) |
| 514 | 3230782 | FFSWAP(int, x, y); | |
| 515 | |||
| 516 | 6497682 | TAB_BS(fc->tab.bs[vertical][LUMA], x, y) = bs; | |
| 517 | |||
| 518 |
4/4✓ Branch 0 taken 6496102 times.
✓ Branch 1 taken 1580 times.
✓ Branch 2 taken 1816 times.
✓ Branch 3 taken 6494286 times.
|
6497682 | if (i == 4 || i == width - 4) |
| 519 | 3396 | max_len_p = max_len_q = 1; | |
| 520 |
4/4✓ Branch 0 taken 5054010 times.
✓ Branch 1 taken 1440276 times.
✓ Branch 2 taken 1201958 times.
✓ Branch 3 taken 3852052 times.
|
6494286 | else if (i == 8 || i == width - 8) |
| 521 | 2642234 | max_len_p = max_len_q = 2; | |
| 522 | else | ||
| 523 | 3852052 | max_len_p = max_len_q = 3; | |
| 524 | |||
| 525 | 6497682 | TAB_MAX_LEN(fc->tab.max_len_p[vertical], x, y) = max_len_p; | |
| 526 | 6497682 | TAB_MAX_LEN(fc->tab.max_len_q[vertical], x, y) = max_len_q; | |
| 527 | } | ||
| 528 | } | ||
| 529 | 167228 | } | |
| 530 | |||
| 531 | 49062781 | static av_always_inline int deblock_bs(const VVCLocalContext *lc, | |
| 532 | const int x_p, const int y_p, const int x_q, const int y_q, const CodingUnit *cu, const TransformUnit *tu, | ||
| 533 | const RefPicList *rpl_p, const int c_idx, const int off_to_cb, const uint8_t has_sub_block) | ||
| 534 | { | ||
| 535 | 49062781 | const VVCFrameContext *fc = lc->fc; | |
| 536 | 49062781 | const MvField *tab_mvf = fc->tab.mvf; | |
| 537 | 49062781 | const int log2_min_pu_size = MIN_PU_LOG2; | |
| 538 | 49062781 | const int log2_min_tu_size = MIN_TU_LOG2; | |
| 539 | 49062781 | const int log2_min_cb_size = fc->ps.sps->min_cb_log2_size_y; | |
| 540 | 49062781 | const int min_pu_width = fc->ps.pps->min_pu_width; | |
| 541 | 49062781 | const int min_tu_width = fc->ps.pps->min_tu_width; | |
| 542 | 49062781 | const int min_cb_width = fc->ps.pps->min_cb_width; | |
| 543 | 49062781 | const int pu_p = (y_p >> log2_min_pu_size) * min_pu_width + (x_p >> log2_min_pu_size); | |
| 544 | 49062781 | const int pu_q = (y_q >> log2_min_pu_size) * min_pu_width + (x_q >> log2_min_pu_size); | |
| 545 | 49062781 | const MvField *mvf_p = &tab_mvf[pu_p]; | |
| 546 | 49062781 | const MvField *mvf_q = &tab_mvf[pu_q]; | |
| 547 | 49062781 | const uint8_t chroma = !!c_idx; | |
| 548 | 49062781 | const int tu_p = (y_p >> log2_min_tu_size) * min_tu_width + (x_p >> log2_min_tu_size); | |
| 549 | 49062781 | const int cb_p = (y_p >> log2_min_cb_size) * min_cb_width + (x_p >> log2_min_cb_size); | |
| 550 |
4/4✓ Branch 0 taken 121004 times.
✓ Branch 1 taken 48941777 times.
✓ Branch 2 taken 56629 times.
✓ Branch 3 taken 64375 times.
|
49062781 | const uint8_t pcmf = fc->tab.pcmf[chroma][cb_p] && cu->bdpcm_flag[chroma]; |
| 551 |
4/4✓ Branch 0 taken 37990666 times.
✓ Branch 1 taken 11072115 times.
✓ Branch 2 taken 1112033 times.
✓ Branch 3 taken 36878633 times.
|
49062781 | const uint8_t intra = fc->tab.cpm[chroma][cb_p] == MODE_INTRA || cu->pred_mode == MODE_INTRA; |
| 552 | 49062781 | const uint8_t same_mode = fc->tab.cpm[chroma][cb_p] == cu->pred_mode; | |
| 553 | |||
| 554 |
2/2✓ Branch 0 taken 56629 times.
✓ Branch 1 taken 49006152 times.
|
49062781 | if (pcmf) |
| 555 | 56629 | return 0; | |
| 556 | |||
| 557 |
6/6✓ Branch 0 taken 36878633 times.
✓ Branch 1 taken 12127519 times.
✓ Branch 2 taken 36491953 times.
✓ Branch 3 taken 386680 times.
✓ Branch 4 taken 302791 times.
✓ Branch 5 taken 36189162 times.
|
49006152 | if (intra || mvf_p->ciip_flag || mvf_q->ciip_flag) |
| 558 | 12816990 | return 2; | |
| 559 | |||
| 560 |
2/2✓ Branch 0 taken 28100568 times.
✓ Branch 1 taken 8088594 times.
|
36189162 | if (chroma) { |
| 561 | 55521158 | return fc->tab.tu_coded_flag[c_idx][tu_p] || | |
| 562 |
2/2✓ Branch 0 taken 27195060 times.
✓ Branch 1 taken 225530 times.
|
27420590 | fc->tab.tu_joint_cbcr_residual_flag[tu_p] || |
| 563 |
4/4✓ Branch 0 taken 27420590 times.
✓ Branch 1 taken 679978 times.
✓ Branch 2 taken 26925332 times.
✓ Branch 3 taken 269728 times.
|
82446490 | tu->coded_flag[c_idx] || |
| 564 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 26925332 times.
|
26925332 | tu->joint_cbcr_residual_flag; |
| 565 | } | ||
| 566 | |||
| 567 |
4/4✓ Branch 0 taken 7173315 times.
✓ Branch 1 taken 915279 times.
✓ Branch 2 taken 429696 times.
✓ Branch 3 taken 6743619 times.
|
8088594 | if (fc->tab.tu_coded_flag[LUMA][tu_p] || tu->coded_flag[LUMA]) |
| 568 | 1344975 | return 1; | |
| 569 | |||
| 570 |
6/6✓ Branch 0 taken 2012353 times.
✓ Branch 1 taken 4731266 times.
✓ Branch 2 taken 1998410 times.
✓ Branch 3 taken 13943 times.
✓ Branch 4 taken 1621280 times.
✓ Branch 5 taken 377130 times.
|
6743619 | if ((off_to_cb && ((off_to_cb % 8) || !has_sub_block))) |
| 571 | 1635223 | return 0; // inside a cu, not aligned to 8 or with no subblocks | |
| 572 | |||
| 573 |
2/2✓ Branch 0 taken 59216 times.
✓ Branch 1 taken 5049180 times.
|
5108396 | if (!same_mode) |
| 574 | 59216 | return 1; | |
| 575 | |||
| 576 | 5049180 | return boundary_strength(lc, mvf_q, mvf_p, rpl_p); | |
| 577 | } | ||
| 578 | |||
| 579 | 4867346 | static int deblock_is_boundary(const VVCLocalContext *lc, const int boundary, | |
| 580 | const int pos, const int rs, const int vertical) | ||
| 581 | { | ||
| 582 | 4867346 | const VVCFrameContext *fc = lc->fc; | |
| 583 | 4867346 | const H266RawSPS *rsps = fc->ps.sps->r; | |
| 584 | 4867346 | const H266RawPPS *rpps = fc->ps.pps->r; | |
| 585 | int flag; | ||
| 586 |
4/4✓ Branch 0 taken 4298170 times.
✓ Branch 1 taken 569176 times.
✓ Branch 2 taken 698099 times.
✓ Branch 3 taken 3600071 times.
|
4867346 | if (boundary && (pos % fc->ps.sps->ctb_size_y) == 0) { |
| 587 |
2/2✓ Branch 0 taken 377026 times.
✓ Branch 1 taken 321073 times.
|
698099 | flag = vertical ? BOUNDARY_LEFT_SLICE : BOUNDARY_UPPER_SLICE; |
| 588 |
2/2✓ Branch 0 taken 20714 times.
✓ Branch 1 taken 677385 times.
|
698099 | if (lc->boundary_flags & flag && |
| 589 |
2/2✓ Branch 0 taken 8259 times.
✓ Branch 1 taken 12455 times.
|
20714 | !rpps->pps_loop_filter_across_slices_enabled_flag) |
| 590 | 8259 | return 0; | |
| 591 | |||
| 592 |
2/2✓ Branch 0 taken 373036 times.
✓ Branch 1 taken 316804 times.
|
689840 | flag = vertical ? BOUNDARY_LEFT_TILE : BOUNDARY_UPPER_TILE; |
| 593 |
2/2✓ Branch 0 taken 30047 times.
✓ Branch 1 taken 659793 times.
|
689840 | if (lc->boundary_flags & flag && |
| 594 |
2/2✓ Branch 0 taken 9554 times.
✓ Branch 1 taken 20493 times.
|
30047 | !rpps->pps_loop_filter_across_tiles_enabled_flag) |
| 595 | 9554 | return 0; | |
| 596 | |||
| 597 |
2/2✓ Branch 0 taken 367107 times.
✓ Branch 1 taken 313179 times.
|
680286 | flag = vertical ? BOUNDARY_LEFT_SUBPIC : BOUNDARY_UPPER_SUBPIC; |
| 598 |
2/2✓ Branch 0 taken 363 times.
✓ Branch 1 taken 679923 times.
|
680286 | if (lc->boundary_flags & flag) { |
| 599 |
2/2✓ Branch 0 taken 313 times.
✓ Branch 1 taken 50 times.
|
363 | const int q_rs = rs - (vertical ? 1 : fc->ps.pps->ctb_width); |
| 600 | 363 | const SliceContext *q_slice = lc->fc->slices[lc->fc->tab.slice_idx[q_rs]]; | |
| 601 | |||
| 602 |
2/2✓ Branch 0 taken 253 times.
✓ Branch 1 taken 110 times.
|
363 | if (!rsps->sps_loop_filter_across_subpic_enabled_flag[q_slice->sh.r->curr_subpic_idx] || |
| 603 |
2/2✓ Branch 0 taken 50 times.
✓ Branch 1 taken 203 times.
|
253 | !rsps->sps_loop_filter_across_subpic_enabled_flag[lc->sc->sh.r->curr_subpic_idx]) |
| 604 | 160 | return 0; | |
| 605 | } | ||
| 606 | } | ||
| 607 | 4849373 | return boundary; | |
| 608 | } | ||
| 609 | |||
| 610 | 3024450 | static void vvc_deblock_bs_luma(const VVCLocalContext *lc, | |
| 611 | const int x0, const int y0, const int width, const int height, | ||
| 612 | const CodingUnit *cu, const TransformUnit *tu, int rs, const int vertical) | ||
| 613 | { | ||
| 614 | 3024450 | const VVCFrameContext *fc = lc->fc; | |
| 615 | 3024450 | const PredictionUnit *pu = &cu->pu; | |
| 616 | 3024450 | const int mask = LUMA_GRID - 1; | |
| 617 |
2/2✓ Branch 0 taken 1512225 times.
✓ Branch 1 taken 1512225 times.
|
3024450 | const int pos = vertical ? x0 : y0; |
| 618 |
2/2✓ Branch 0 taken 1512225 times.
✓ Branch 1 taken 1512225 times.
|
3024450 | const int cb = vertical ? cu->x0 : cu->y0; |
| 619 | 3024450 | const int is_intra = cu->pred_mode == MODE_INTRA; | |
| 620 |
2/2✓ Branch 0 taken 1512225 times.
✓ Branch 1 taken 1512225 times.
|
3024450 | const int cb_size = vertical ? cu->cb_width : cu->cb_height; |
| 621 |
8/8✓ Branch 0 taken 1453240 times.
✓ Branch 1 taken 1571210 times.
✓ Branch 2 taken 1287730 times.
✓ Branch 3 taken 165510 times.
✓ Branch 4 taken 29860 times.
✓ Branch 5 taken 1257870 times.
✓ Branch 6 taken 167228 times.
✓ Branch 7 taken 28142 times.
|
3024450 | const int has_sb = !is_intra && (pu->merge_subblock_flag || pu->inter_affine_flag) && cb_size > 8; |
| 622 | |||
| 623 |
6/6✓ Branch 0 taken 2966805 times.
✓ Branch 1 taken 57645 times.
✓ Branch 2 taken 2913067 times.
✓ Branch 3 taken 53738 times.
✓ Branch 5 taken 2902496 times.
✓ Branch 6 taken 121954 times.
|
3024450 | if (deblock_is_boundary(lc, pos > 0 && !(pos & mask), pos, rs, vertical)) { |
| 624 | 2902496 | const int is_vb = is_virtual_boundary(fc, pos, vertical); | |
| 625 |
2/2✓ Branch 0 taken 1468127 times.
✓ Branch 1 taken 1434369 times.
|
2902496 | const int size = vertical ? height : width; |
| 626 |
2/2✓ Branch 0 taken 1468127 times.
✓ Branch 1 taken 1434369 times.
|
2902496 | const int size_q = vertical ? width : height; |
| 627 | 2902496 | const int off = cb - pos; | |
| 628 |
2/2✓ Branch 0 taken 1468127 times.
✓ Branch 1 taken 1434369 times.
|
2902496 | const int flag = vertical ? BOUNDARY_LEFT_SLICE : BOUNDARY_UPPER_SLICE; |
| 629 | 2902496 | const RefPicList *rpl_p = | |
| 630 |
2/2✓ Branch 0 taken 73777 times.
✓ Branch 1 taken 2828719 times.
|
2902496 | (lc->boundary_flags & flag) ? ff_vvc_get_ref_list(fc, fc->ref, x0 - vertical, y0 - !vertical) : lc->sc->rpl; |
| 631 | |||
| 632 |
2/2✓ Branch 0 taken 12496509 times.
✓ Branch 1 taken 2902496 times.
|
15399005 | for (int i = 0; i < size; i += 4) { |
| 633 | 12496509 | const int x = x0 + i * !vertical; | |
| 634 | 12496509 | const int y = y0 + i * vertical; | |
| 635 | uint8_t max_len_p, max_len_q; | ||
| 636 |
1/2✓ Branch 0 taken 12496509 times.
✗ Branch 1 not taken.
|
12496509 | const int bs = is_vb ? 0 : deblock_bs(lc, x - vertical, y - !vertical, x, y, cu, tu, rpl_p, LUMA, off, has_sb); |
| 637 | |||
| 638 | 12496509 | TAB_BS(fc->tab.bs[vertical][LUMA], x, y) = bs; | |
| 639 | |||
| 640 | 12496509 | derive_max_filter_length_luma(fc, x, y, size_q, has_sb, vertical, &max_len_p, &max_len_q); | |
| 641 | 12496509 | TAB_MAX_LEN(fc->tab.max_len_p[vertical], x, y) = max_len_p; | |
| 642 | 12496509 | TAB_MAX_LEN(fc->tab.max_len_q[vertical], x, y) = max_len_q; | |
| 643 | } | ||
| 644 | } | ||
| 645 | |||
| 646 |
2/2✓ Branch 0 taken 167228 times.
✓ Branch 1 taken 2857222 times.
|
3024450 | if (has_sb) |
| 647 | 167228 | vvc_deblock_subblock_bs(lc, cb, x0, y0, width, height, vertical); | |
| 648 | 3024450 | } | |
| 649 | |||
| 650 | 1842896 | static void vvc_deblock_bs_chroma(const VVCLocalContext *lc, | |
| 651 | const int x0, const int y0, const int width, const int height, | ||
| 652 | const CodingUnit *cu, const TransformUnit *tu, const int rs, const int vertical) | ||
| 653 | { | ||
| 654 | 1842896 | const VVCFrameContext *fc = lc->fc; | |
| 655 |
2/2✓ Branch 0 taken 921448 times.
✓ Branch 1 taken 921448 times.
|
1842896 | const int shift = (vertical ? fc->ps.sps->hshift : fc->ps.sps->vshift)[CHROMA]; |
| 656 | 1842896 | const int mask = (CHROMA_GRID << shift) - 1; | |
| 657 |
2/2✓ Branch 0 taken 921448 times.
✓ Branch 1 taken 921448 times.
|
1842896 | const int pos = vertical ? x0 : y0; |
| 658 | |||
| 659 |
6/6✓ Branch 0 taken 1795695 times.
✓ Branch 1 taken 47201 times.
✓ Branch 2 taken 1385103 times.
✓ Branch 3 taken 410592 times.
✓ Branch 5 taken 1377701 times.
✓ Branch 6 taken 465195 times.
|
1842896 | if (deblock_is_boundary(lc, pos > 0 && !(pos & mask), pos, rs, vertical)) { |
| 660 | 1377701 | const int is_vb = is_virtual_boundary(fc, pos, vertical); | |
| 661 |
2/2✓ Branch 0 taken 691670 times.
✓ Branch 1 taken 686031 times.
|
1377701 | const int size = vertical ? height : width; |
| 662 | |||
| 663 |
2/2✓ Branch 0 taken 2755402 times.
✓ Branch 1 taken 1377701 times.
|
4133103 | for (int c_idx = CB; c_idx <= CR; c_idx++) { |
| 664 |
2/2✓ Branch 0 taken 36566272 times.
✓ Branch 1 taken 2755402 times.
|
39321674 | for (int i = 0; i < size; i += 2) { |
| 665 | 36566272 | const int x = x0 + i * !vertical; | |
| 666 | 36566272 | const int y = y0 + i * vertical; | |
| 667 |
1/2✓ Branch 0 taken 36566272 times.
✗ Branch 1 not taken.
|
36566272 | const int bs = is_vb ? 0 : deblock_bs(lc, x - vertical, y - !vertical, x, y, cu, tu, NULL, c_idx, 0, 0); |
| 668 | |||
| 669 | 36566272 | TAB_BS(fc->tab.bs[vertical][c_idx], x, y) = bs; | |
| 670 | } | ||
| 671 | } | ||
| 672 | } | ||
| 673 | 1842896 | } | |
| 674 | |||
| 675 | typedef void (*deblock_bs_fn)(const VVCLocalContext *lc, const int x0, const int y0, | ||
| 676 | const int width, const int height, const int rs, const int vertical); | ||
| 677 | |||
| 678 | 55061 | void ff_vvc_deblock_bs(VVCLocalContext *lc, const int rx, const int ry, const int rs) | |
| 679 | { | ||
| 680 | 55061 | const VVCFrameContext *fc = lc->fc; | |
| 681 | 55061 | const VVCSPS *sps = fc->ps.sps; | |
| 682 | 55061 | const int x0 = rx << sps->ctb_log2_size_y; | |
| 683 | 55061 | const int y0 = ry << sps->ctb_log2_size_y; | |
| 684 | |||
| 685 | 55061 | ff_vvc_decode_neighbour(lc, x0, y0, rx, ry, rs); | |
| 686 |
2/2✓ Branch 0 taken 1385221 times.
✓ Branch 1 taken 55061 times.
|
1440282 | for (const CodingUnit *cu = fc->tab.cus[rs]; cu; cu = cu->next) { |
| 687 |
2/2✓ Branch 0 taken 1705635 times.
✓ Branch 1 taken 1385221 times.
|
3090856 | for (const TransformUnit *tu = cu->tus.head; tu; tu = tu->next) { |
| 688 |
2/2✓ Branch 0 taken 3411270 times.
✓ Branch 1 taken 1705635 times.
|
5116905 | for (int vertical = 0; vertical <= 1; vertical++) { |
| 689 |
2/2✓ Branch 0 taken 3024450 times.
✓ Branch 1 taken 386820 times.
|
3411270 | if (tu->avail[LUMA]) |
| 690 | 3024450 | vvc_deblock_bs_luma(lc, tu->x0, tu->y0, tu->width, tu->height, cu, tu, rs, vertical); | |
| 691 |
2/2✓ Branch 0 taken 1842896 times.
✓ Branch 1 taken 1568374 times.
|
3411270 | if (tu->avail[CHROMA]) { |
| 692 |
3/4✓ Branch 0 taken 11834 times.
✓ Branch 1 taken 1831062 times.
✓ Branch 2 taken 11834 times.
✗ Branch 3 not taken.
|
1842896 | if (cu->isp_split_type != ISP_NO_SPLIT && cu->tree_type == SINGLE_TREE) |
| 693 | 11834 | vvc_deblock_bs_chroma(lc, cu->x0, cu->y0, cu->cb_width, cu->cb_height, cu, tu, rs, vertical); | |
| 694 | else | ||
| 695 | 1831062 | vvc_deblock_bs_chroma(lc, tu->x0, tu->y0, tu->width, tu->height, cu, tu, rs, vertical); | |
| 696 | } | ||
| 697 | } | ||
| 698 | } | ||
| 699 | } | ||
| 700 | 55061 | } | |
| 701 | |||
| 702 | //part of 8.8.3.3 Derivation process of transform block boundary | ||
| 703 | 8100340 | static void max_filter_length_luma(const VVCFrameContext *fc, const int qx, const int qy, | |
| 704 | const int vertical, uint8_t *max_len_p, uint8_t *max_len_q) | ||
| 705 | { | ||
| 706 | 8100340 | *max_len_p = TAB_MAX_LEN(fc->tab.max_len_p[vertical], qx, qy); | |
| 707 | 8100340 | *max_len_q = TAB_MAX_LEN(fc->tab.max_len_q[vertical], qx, qy); | |
| 708 | 8100340 | } | |
| 709 | |||
| 710 | //part of 8.8.3.3 Derivation process of transform block boundary | ||
| 711 | 4820374 | static void max_filter_length_chroma(const VVCFrameContext *fc, const int qx, const int qy, | |
| 712 | const int vertical, const int horizontal_ctu_edge, const int bs, uint8_t *max_len_p, uint8_t *max_len_q) | ||
| 713 | { | ||
| 714 |
2/2✓ Branch 0 taken 2309211 times.
✓ Branch 1 taken 2511163 times.
|
4820374 | const int px = vertical ? qx - 1 : qx; |
| 715 |
2/2✓ Branch 0 taken 2511163 times.
✓ Branch 1 taken 2309211 times.
|
4820374 | const int py = !vertical ? qy - 1 : qy; |
| 716 |
2/2✓ Branch 0 taken 2309211 times.
✓ Branch 1 taken 2511163 times.
|
4820374 | const uint8_t *tb_size = vertical ? fc->tab.tb_width[CHROMA] : fc->tab.tb_height[CHROMA]; |
| 717 | |||
| 718 | 4820374 | const int size_p = tb_size[(py >> MIN_TU_LOG2) * fc->ps.pps->min_tu_width + (px >> MIN_TU_LOG2)]; | |
| 719 | 4820374 | const int size_q = tb_size[(qy >> MIN_TU_LOG2) * fc->ps.pps->min_tu_width + (qx >> MIN_TU_LOG2)]; | |
| 720 |
4/4✓ Branch 0 taken 3904895 times.
✓ Branch 1 taken 915479 times.
✓ Branch 2 taken 3335563 times.
✓ Branch 3 taken 569332 times.
|
4820374 | if (size_p >= 8 && size_q >= 8) { |
| 721 | 3335563 | *max_len_p = *max_len_q = 3; | |
| 722 |
2/2✓ Branch 0 taken 395653 times.
✓ Branch 1 taken 2939910 times.
|
3335563 | if (horizontal_ctu_edge) |
| 723 | 395653 | *max_len_p = 1; | |
| 724 | } else { | ||
| 725 | //part of 8.8.3.6.4 Decision process for chroma block edges | ||
| 726 | 1484811 | *max_len_p = *max_len_q = (bs == 2); | |
| 727 | } | ||
| 728 | 4820374 | } | |
| 729 | |||
| 730 | 12920714 | static void max_filter_length(const VVCFrameContext *fc, const int qx, const int qy, | |
| 731 | const int c_idx, const int vertical, const int horizontal_ctu_edge, const int bs, uint8_t *max_len_p, uint8_t *max_len_q) | ||
| 732 | { | ||
| 733 |
2/2✓ Branch 0 taken 8100340 times.
✓ Branch 1 taken 4820374 times.
|
12920714 | if (!c_idx) |
| 734 | 8100340 | max_filter_length_luma(fc, qx, qy, vertical, max_len_p, max_len_q); | |
| 735 | else | ||
| 736 | 4820374 | max_filter_length_chroma(fc, qx, qy, vertical, horizontal_ctu_edge, bs, max_len_p, max_len_q); | |
| 737 | 12920714 | } | |
| 738 | |||
| 739 | #define TC_CALC(qp, bs) \ | ||
| 740 | tctable[av_clip((qp) + DEFAULT_INTRA_TC_OFFSET * ((bs) - 1) + \ | ||
| 741 | (tc_offset & -2), \ | ||
| 742 | 0, MAX_QP + DEFAULT_INTRA_TC_OFFSET)] | ||
| 743 | |||
| 744 | // part of 8.8.3.6.2 Decision process for luma block edges | ||
| 745 | 8100340 | static int get_qp_y(const VVCFrameContext *fc, const uint8_t *src, const int x, const int y, const int vertical) | |
| 746 | { | ||
| 747 | 8100340 | const VVCSPS *sps = fc->ps.sps; | |
| 748 | 8100340 | const int qp = (ff_vvc_get_qPy(fc, x - vertical, y - !vertical) + ff_vvc_get_qPy(fc, x, y) + 1) >> 1; | |
| 749 | 8100340 | int qp_offset = 0; | |
| 750 | int level; | ||
| 751 | |||
| 752 |
2/2✓ Branch 0 taken 7628461 times.
✓ Branch 1 taken 471879 times.
|
8100340 | if (!sps->r->sps_ladf_enabled_flag) |
| 753 | 7628461 | return qp; | |
| 754 | |||
| 755 | 471879 | level = fc->vvcdsp.lf.ladf_level[vertical](src, fc->frame->linesize[LUMA]); | |
| 756 | 471879 | qp_offset = sps->r->sps_ladf_lowest_interval_qp_offset; | |
| 757 |
4/4✓ Branch 0 taken 932712 times.
✓ Branch 1 taken 437994 times.
✓ Branch 2 taken 898827 times.
✓ Branch 3 taken 33885 times.
|
1370706 | for (int i = 0; i < sps->num_ladf_intervals - 1 && level > sps->ladf_interval_lower_bound[i + 1]; i++) |
| 758 | 898827 | qp_offset = sps->r->sps_ladf_qp_offset[i]; | |
| 759 | |||
| 760 | 471879 | return qp + qp_offset; | |
| 761 | } | ||
| 762 | |||
| 763 | // part of 8.8.3.6.2 Decision process for luma block edges | ||
| 764 | 4820374 | static int get_qp_c(const VVCFrameContext *fc, const int x, const int y, const int c_idx, const int vertical) | |
| 765 | { | ||
| 766 | 4820374 | const VVCSPS *sps = fc->ps.sps; | |
| 767 | 4820374 | return (get_qPc(fc, x - vertical, y - !vertical, c_idx) + get_qPc(fc, x, y, c_idx) - 2 * sps->qp_bd_offset + 1) >> 1; | |
| 768 | } | ||
| 769 | |||
| 770 | 12920714 | static int get_qp(const VVCFrameContext *fc, const uint8_t *src, const int x, const int y, const int c_idx, const int vertical) | |
| 771 | { | ||
| 772 |
2/2✓ Branch 0 taken 8100340 times.
✓ Branch 1 taken 4820374 times.
|
12920714 | if (!c_idx) |
| 773 | 8100340 | return get_qp_y(fc, src, x, y, vertical); | |
| 774 | 4820374 | return get_qp_c(fc, x, y, c_idx, vertical); | |
| 775 | } | ||
| 776 | |||
| 777 | 110122 | static void vvc_deblock(const VVCLocalContext *lc, int x0, int y0, const int rs, const int vertical) | |
| 778 | { | ||
| 779 | 110122 | VVCFrameContext *fc = lc->fc; | |
| 780 | 110122 | const VVCSPS *sps = fc->ps.sps; | |
| 781 |
2/2✓ Branch 0 taken 109066 times.
✓ Branch 1 taken 1056 times.
|
110122 | const int c_end = sps->r->sps_chroma_format_idc ? VVC_MAX_SAMPLE_ARRAYS : 1; |
| 782 | 110122 | const int ctb_size = fc->ps.sps->ctb_size_y; | |
| 783 | 110122 | const DBParams *params = fc->tab.deblock + rs; | |
| 784 | 110122 | int x_end = FFMIN(x0 + ctb_size, fc->ps.pps->width); | |
| 785 | 110122 | int y_end = FFMIN(y0 + ctb_size, fc->ps.pps->height); | |
| 786 | 110122 | const int log2_min_cb_size = fc->ps.sps->min_cb_log2_size_y; | |
| 787 | 110122 | const int min_cb_width = fc->ps.pps->min_cb_width; | |
| 788 | |||
| 789 |
2/2✓ Branch 0 taken 55061 times.
✓ Branch 1 taken 55061 times.
|
110122 | if (!vertical) { |
| 790 | 55061 | FFSWAP(int, x_end, y_end); | |
| 791 | 55061 | FFSWAP(int, x0, y0); | |
| 792 | } | ||
| 793 | |||
| 794 |
2/2✓ Branch 0 taken 328254 times.
✓ Branch 1 taken 110122 times.
|
438376 | for (int c_idx = 0; c_idx < c_end; c_idx++) { |
| 795 |
2/2✓ Branch 0 taken 164127 times.
✓ Branch 1 taken 164127 times.
|
328254 | const int hs = (vertical ? sps->hshift : sps->vshift)[c_idx]; |
| 796 |
2/2✓ Branch 0 taken 164127 times.
✓ Branch 1 taken 164127 times.
|
328254 | const int vs = (vertical ? sps->vshift : sps->hshift)[c_idx]; |
| 797 |
2/2✓ Branch 0 taken 218132 times.
✓ Branch 1 taken 110122 times.
|
328254 | const int grid = c_idx ? (CHROMA_GRID << hs) : LUMA_GRID; |
| 798 | 328254 | const int tc_offset = params->tc_offset[c_idx]; | |
| 799 | 328254 | const int beta_offset = params->beta_offset[c_idx]; | |
| 800 | 328254 | const int src_stride = fc->frame->linesize[c_idx]; | |
| 801 | |||
| 802 |
2/2✓ Branch 0 taken 3837191 times.
✓ Branch 1 taken 328254 times.
|
4165445 | for (int y = y0; y < y_end; y += (DEBLOCK_STEP << vs)) { |
| 803 |
4/4✓ Branch 0 taken 3387445 times.
✓ Branch 1 taken 449746 times.
✓ Branch 2 taken 74559994 times.
✓ Branch 3 taken 3837191 times.
|
78397185 | for (int x = x0 ? x0 : grid; x < x_end; x += grid) { |
| 804 |
4/4✓ Branch 0 taken 37220522 times.
✓ Branch 1 taken 37339472 times.
✓ Branch 2 taken 1654772 times.
✓ Branch 3 taken 35565750 times.
|
74559994 | const uint8_t horizontal_ctu_edge = !vertical && !(x % ctb_size); |
| 805 | 74559994 | int32_t bs[4], beta[4], tc[4] = { 0 }, all_zero_bs = 1; | |
| 806 | uint8_t max_len_p[4], max_len_q[4]; | ||
| 807 | 74559994 | uint8_t no_p[4] = { 0 }; | |
| 808 | 74559994 | uint8_t no_q[4] = { 0 }; | |
| 809 | |||
| 810 |
2/2✓ Branch 0 taken 164876912 times.
✓ Branch 1 taken 74559994 times.
|
239436906 | for (int i = 0; i < DEBLOCK_STEP >> (2 - vs); i++) { |
| 811 | 164876912 | int tx = x; | |
| 812 | 164876912 | int ty = y + (i << 2); | |
| 813 | 164876912 | const int end = ty >= y_end; | |
| 814 | |||
| 815 |
2/2✓ Branch 0 taken 82927796 times.
✓ Branch 1 taken 81949116 times.
|
164876912 | if (!vertical) |
| 816 | 82927796 | FFSWAP(int, tx, ty); | |
| 817 | |||
| 818 |
2/2✓ Branch 0 taken 164795444 times.
✓ Branch 1 taken 81468 times.
|
164876912 | bs[i] = end ? 0 : TAB_BS(fc->tab.bs[vertical][c_idx], tx, ty); |
| 819 |
2/2✓ Branch 0 taken 12920714 times.
✓ Branch 1 taken 151956198 times.
|
164876912 | if (bs[i]) { |
| 820 | 12920714 | const int qp = get_qp(fc, POS(c_idx, tx, ty), tx, ty, c_idx, vertical); | |
| 821 | 12920714 | beta[i] = betatable[av_clip(qp + beta_offset, 0, MAX_QP)]; | |
| 822 | 12920714 | tc[i] = TC_CALC(qp, bs[i]) ; | |
| 823 | 12920714 | max_filter_length(fc, tx, ty, c_idx, vertical, horizontal_ctu_edge, bs[i], &max_len_p[i], &max_len_q[i]); | |
| 824 | 12920714 | all_zero_bs = 0; | |
| 825 | |||
| 826 |
2/2✓ Branch 0 taken 1045440 times.
✓ Branch 1 taken 11875274 times.
|
12920714 | if (sps->r->sps_palette_enabled_flag) { |
| 827 | 1045440 | const int cu_q = (ty >> log2_min_cb_size) * min_cb_width + (tx >> log2_min_cb_size); | |
| 828 | 1045440 | const int cu_p = (ty - !vertical >> log2_min_cb_size) * min_cb_width + (tx - vertical >> log2_min_cb_size); | |
| 829 | 1045440 | no_q[i] = fc->tab.cpm[!!c_idx][cu_q] == MODE_PLT; | |
| 830 |
3/4✓ Branch 0 taken 1045440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54371 times.
✓ Branch 3 taken 991069 times.
|
1045440 | no_p[i] = cu_p >= 0 && fc->tab.cpm[!!c_idx][cu_p] == MODE_PLT; |
| 831 | } | ||
| 832 | } | ||
| 833 | } | ||
| 834 | |||
| 835 |
2/2✓ Branch 0 taken 5644448 times.
✓ Branch 1 taken 68915546 times.
|
74559994 | if (!all_zero_bs) { |
| 836 |
2/2✓ Branch 0 taken 2737576 times.
✓ Branch 1 taken 2906872 times.
|
5644448 | uint8_t *src = vertical ? POS(c_idx, x, y) : POS(c_idx, y, x); |
| 837 |
2/2✓ Branch 0 taken 4156732 times.
✓ Branch 1 taken 1487716 times.
|
5644448 | if (!c_idx) |
| 838 | 4156732 | fc->vvcdsp.lf.filter_luma[vertical](src, src_stride, beta, tc, no_p, no_q, max_len_p, max_len_q, horizontal_ctu_edge); | |
| 839 | else | ||
| 840 | 1487716 | fc->vvcdsp.lf.filter_chroma[vertical](src, src_stride, beta, tc, no_p, no_q, max_len_p, max_len_q, vs); | |
| 841 | } | ||
| 842 | } | ||
| 843 | } | ||
| 844 | } | ||
| 845 | 110122 | } | |
| 846 | |||
| 847 | 55061 | void ff_vvc_deblock_vertical(const VVCLocalContext *lc, const int x0, const int y0, const int rs) | |
| 848 | { | ||
| 849 | 55061 | vvc_deblock(lc, x0, y0, rs, 1); | |
| 850 | 55061 | } | |
| 851 | |||
| 852 | 55061 | void ff_vvc_deblock_horizontal(const VVCLocalContext *lc, const int x0, const int y0, const int rs) | |
| 853 | { | ||
| 854 | 55061 | vvc_deblock(lc, x0, y0, rs, 0); | |
| 855 | 55061 | } | |
| 856 | |||
| 857 | 683989 | static void alf_copy_border(uint8_t *dst, const uint8_t *src, | |
| 858 | const int pixel_shift, int width, const int height, const ptrdiff_t dst_stride, const ptrdiff_t src_stride) | ||
| 859 | { | ||
| 860 | 683989 | width <<= pixel_shift; | |
| 861 |
2/2✓ Branch 0 taken 35369581 times.
✓ Branch 1 taken 683989 times.
|
36053570 | for (int i = 0; i < height; i++) { |
| 862 | 35369581 | memcpy(dst, src, width); | |
| 863 | 35369581 | dst += dst_stride; | |
| 864 | 35369581 | src += src_stride; | |
| 865 | } | ||
| 866 | 683989 | } | |
| 867 | |||
| 868 | 10987 | static void alf_extend_vert(uint8_t *_dst, const uint8_t *_src, | |
| 869 | const int pixel_shift, const int width, const int height, ptrdiff_t stride) | ||
| 870 | { | ||
| 871 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10987 times.
|
10987 | if (pixel_shift == 0) { |
| 872 | ✗ | for (int i = 0; i < height; i++) { | |
| 873 | ✗ | memset(_dst, *_src, width); | |
| 874 | ✗ | _src += stride; | |
| 875 | ✗ | _dst += stride; | |
| 876 | } | ||
| 877 | } else { | ||
| 878 | 10987 | const uint16_t *src = (const uint16_t *)_src; | |
| 879 | 10987 | uint16_t *dst = (uint16_t *)_dst; | |
| 880 | 10987 | stride >>= pixel_shift; | |
| 881 | |||
| 882 |
2/2✓ Branch 0 taken 1080732 times.
✓ Branch 1 taken 10987 times.
|
1091719 | for (int i = 0; i < height; i++) { |
| 883 |
2/2✓ Branch 0 taken 2779080 times.
✓ Branch 1 taken 1080732 times.
|
3859812 | for (int j = 0; j < width; j++) |
| 884 | 2779080 | dst[j] = *src; | |
| 885 | 1080732 | src += stride; | |
| 886 | 1080732 | dst += stride; | |
| 887 | } | ||
| 888 | } | ||
| 889 | 10987 | } | |
| 890 | |||
| 891 | 49344 | static void alf_extend_horz(uint8_t *dst, const uint8_t *src, | |
| 892 | const int pixel_shift, int width, const int height, const ptrdiff_t stride) | ||
| 893 | { | ||
| 894 | 49344 | width <<= pixel_shift; | |
| 895 |
2/2✓ Branch 0 taken 121317 times.
✓ Branch 1 taken 49344 times.
|
170661 | for (int i = 0; i < height; i++) { |
| 896 | 121317 | memcpy(dst, src, width); | |
| 897 | 121317 | dst += stride; | |
| 898 | } | ||
| 899 | 49344 | } | |
| 900 | |||
| 901 | 130065 | static void alf_copy_ctb_to_hv(VVCFrameContext *fc, const uint8_t *src, const ptrdiff_t src_stride, | |
| 902 | const int x, const int y, const int width, const int height, const int rx, const int ry, const int c_idx) | ||
| 903 | { | ||
| 904 | 130065 | const int ps = fc->ps.sps->pixel_shift; | |
| 905 | 130065 | const int w = fc->ps.pps->width >> fc->ps.sps->hshift[c_idx]; | |
| 906 | 130065 | const int h = fc->ps.pps->height >> fc->ps.sps->vshift[c_idx]; | |
| 907 |
2/2✓ Branch 0 taken 43707 times.
✓ Branch 1 taken 86358 times.
|
130065 | const int border_pixels = (c_idx == 0) ? ALF_BORDER_LUMA : ALF_BORDER_CHROMA; |
| 908 | 130065 | const int offset_h[] = { 0, height - border_pixels }; | |
| 909 | 130065 | const int offset_v[] = { 0, width - border_pixels }; | |
| 910 | |||
| 911 | /* copy horizontal edges */ | ||
| 912 |
2/2✓ Branch 0 taken 260130 times.
✓ Branch 1 taken 130065 times.
|
390195 | for (int i = 0; i < FF_ARRAY_ELEMS(offset_h); i++) { |
| 913 | 260130 | alf_copy_border(fc->tab.alf_pixel_buffer_h[c_idx][i] + ((border_pixels * ry * w + x)<< ps), | |
| 914 | 260130 | src + offset_h[i] * src_stride, ps, width, border_pixels, w << ps, src_stride); | |
| 915 | } | ||
| 916 | /* copy vertical edges */ | ||
| 917 |
2/2✓ Branch 0 taken 260130 times.
✓ Branch 1 taken 130065 times.
|
390195 | for (int i = 0; i < FF_ARRAY_ELEMS(offset_v); i++) { |
| 918 | 260130 | alf_copy_border(fc->tab.alf_pixel_buffer_v[c_idx][i] + ((h * rx + y) * (border_pixels << ps)), | |
| 919 | 260130 | src + (offset_v[i] << ps), ps, border_pixels, height, border_pixels << ps, src_stride); | |
| 920 | } | ||
| 921 | 130065 | } | |
| 922 | |||
| 923 | 96802 | static void alf_fill_border_h(uint8_t *dst, const ptrdiff_t dst_stride, const uint8_t *src, const ptrdiff_t src_stride, | |
| 924 | const uint8_t *border, const int width, const int border_pixels, const int ps, const int edge) | ||
| 925 | { | ||
| 926 |
2/2✓ Branch 0 taken 18888 times.
✓ Branch 1 taken 77914 times.
|
96802 | if (edge) |
| 927 | 18888 | alf_extend_horz(dst, border, ps, width, border_pixels, dst_stride); | |
| 928 | else | ||
| 929 | 77914 | alf_copy_border(dst, src, ps, width, border_pixels, dst_stride, src_stride); | |
| 930 | 96802 | } | |
| 931 | |||
| 932 | 96802 | static void alf_fill_border_v(uint8_t *dst, const ptrdiff_t dst_stride, const uint8_t *src, | |
| 933 | const uint8_t *border, const int border_pixels, const int height, const int pixel_shift, const int *edges, const int edge) | ||
| 934 | { | ||
| 935 | 96802 | const ptrdiff_t src_stride = (border_pixels << pixel_shift); | |
| 936 | |||
| 937 |
2/2✓ Branch 0 taken 10987 times.
✓ Branch 1 taken 85815 times.
|
96802 | if (edge) { |
| 938 | 10987 | alf_extend_vert(dst, border, pixel_shift, border_pixels, height + 2 * border_pixels, dst_stride); | |
| 939 | 10987 | return; | |
| 940 | } | ||
| 941 | |||
| 942 | //left/right | ||
| 943 | 85815 | alf_copy_border(dst + dst_stride * border_pixels * edges[TOP], src + src_stride * border_pixels * edges[TOP], | |
| 944 | 85815 | pixel_shift, border_pixels, height + (!edges[TOP] + !edges[BOTTOM]) * border_pixels, dst_stride, src_stride); | |
| 945 | |||
| 946 | //top left/right | ||
| 947 |
2/2✓ Branch 0 taken 13876 times.
✓ Branch 1 taken 71939 times.
|
85815 | if (edges[TOP]) |
| 948 | 13876 | alf_extend_horz(dst, dst + dst_stride * border_pixels, pixel_shift, border_pixels, border_pixels, dst_stride); | |
| 949 | |||
| 950 | //bottom left/right | ||
| 951 |
2/2✓ Branch 0 taken 16580 times.
✓ Branch 1 taken 69235 times.
|
85815 | if (edges[BOTTOM]) { |
| 952 | 16580 | dst += dst_stride * (border_pixels + height); | |
| 953 | 16580 | alf_extend_horz(dst, dst - dst_stride, pixel_shift, border_pixels, border_pixels, dst_stride); | |
| 954 | } | ||
| 955 | } | ||
| 956 | |||
| 957 | 48401 | static void alf_prepare_buffer(VVCFrameContext *fc, uint8_t *_dst, const uint8_t *_src, const int x, const int y, | |
| 958 | const int rx, const int ry, const int width, const int height, const ptrdiff_t dst_stride, const ptrdiff_t src_stride, | ||
| 959 | const int c_idx, const int *edges) | ||
| 960 | { | ||
| 961 | 48401 | const int ps = fc->ps.sps->pixel_shift; | |
| 962 | 48401 | const int w = fc->ps.pps->width >> fc->ps.sps->hshift[c_idx]; | |
| 963 | 48401 | const int h = fc->ps.pps->height >> fc->ps.sps->vshift[c_idx]; | |
| 964 |
2/2✓ Branch 0 taken 21680 times.
✓ Branch 1 taken 26721 times.
|
48401 | const int border_pixels = c_idx == 0 ? ALF_BORDER_LUMA : ALF_BORDER_CHROMA; |
| 965 | uint8_t *dst, *src; | ||
| 966 | |||
| 967 | 48401 | copy_ctb(_dst, _src, width << ps, height, dst_stride, src_stride); | |
| 968 | |||
| 969 | //top | ||
| 970 | 48401 | src = fc->tab.alf_pixel_buffer_h[c_idx][1] + (((border_pixels * w) << ps) * (ry - 1) + (x << ps)); | |
| 971 | 48401 | dst = _dst - border_pixels * dst_stride; | |
| 972 | 48401 | alf_fill_border_h(dst, dst_stride, src, w << ps, _dst, width, border_pixels, ps, edges[TOP]); | |
| 973 | |||
| 974 | //bottom | ||
| 975 | 48401 | src = fc->tab.alf_pixel_buffer_h[c_idx][0] + (((border_pixels * w) << ps) * (ry + 1) + (x << ps)); | |
| 976 | 48401 | dst = _dst + height * dst_stride; | |
| 977 | 48401 | alf_fill_border_h(dst, dst_stride, src, w << ps, _dst + (height - 1) * dst_stride, width, border_pixels, ps, edges[BOTTOM]); | |
| 978 | |||
| 979 | |||
| 980 | //left | ||
| 981 | 48401 | src = fc->tab.alf_pixel_buffer_v[c_idx][1] + (h * (rx - 1) + y - border_pixels) * (border_pixels << ps); | |
| 982 | 48401 | dst = _dst - (border_pixels << ps) - border_pixels * dst_stride; | |
| 983 | 48401 | alf_fill_border_v(dst, dst_stride, src, dst + (border_pixels << ps), border_pixels, height, ps, edges, edges[LEFT]); | |
| 984 | |||
| 985 | //right | ||
| 986 | 48401 | src = fc->tab.alf_pixel_buffer_v[c_idx][0] + (h * (rx + 1) + y - border_pixels) * (border_pixels << ps); | |
| 987 | 48401 | dst = _dst + (width << ps) - border_pixels * dst_stride; | |
| 988 | 48401 | alf_fill_border_v(dst, dst_stride, src, dst - (1 << ps), border_pixels, height, ps, edges, edges[RIGHT]); | |
| 989 | 48401 | } | |
| 990 | |||
| 991 | 21045 | static void alf_get_coeff_and_clip(VVCLocalContext *lc, int16_t *coeff, int16_t *clip, | |
| 992 | const uint8_t *src, ptrdiff_t src_stride, int width, int height, int vb_pos, const ALFParams *alf) | ||
| 993 | { | ||
| 994 | 21045 | const VVCFrameContext *fc = lc->fc; | |
| 995 | 21045 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 996 | 21045 | uint8_t fixed_clip_set[ALF_NUM_FILTERS_LUMA][ALF_NUM_COEFF_LUMA] = { 0 }; | |
| 997 | const int16_t *coeff_set; | ||
| 998 | const uint8_t *clip_idx_set; | ||
| 999 | const uint8_t *class_to_filt; | ||
| 1000 | 21045 | const int size = width * height / ALF_BLOCK_SIZE / ALF_BLOCK_SIZE; | |
| 1001 | int class_idx[ALF_MAX_BLOCKS_IN_CTU]; | ||
| 1002 | int transpose_idx[ALF_MAX_BLOCKS_IN_CTU]; | ||
| 1003 | |||
| 1004 |
2/2✓ Branch 0 taken 2803 times.
✓ Branch 1 taken 18242 times.
|
21045 | if (alf->ctb_filt_set_idx_y < 16) { |
| 1005 | 2803 | coeff_set = &ff_vvc_alf_fix_filt_coeff[0][0]; | |
| 1006 | 2803 | clip_idx_set = &fixed_clip_set[0][0]; | |
| 1007 | 2803 | class_to_filt = ff_vvc_alf_class_to_filt_map[alf->ctb_filt_set_idx_y]; | |
| 1008 | } else { | ||
| 1009 | 18242 | const int id = rsh->sh_alf_aps_id_luma[alf->ctb_filt_set_idx_y - 16]; | |
| 1010 | 18242 | const VVCALF *aps = fc->ps.alf_list[id]; | |
| 1011 | 18242 | coeff_set = &aps->luma_coeff[0][0]; | |
| 1012 | 18242 | clip_idx_set = &aps->luma_clip_idx[0][0]; | |
| 1013 | 18242 | class_to_filt = ff_vvc_alf_aps_class_to_filt_map; | |
| 1014 | } | ||
| 1015 | 21045 | fc->vvcdsp.alf.classify(class_idx, transpose_idx, src, src_stride, width, height, | |
| 1016 | 21045 | vb_pos, lc->alf.gradient_tmp); | |
| 1017 | 21045 | fc->vvcdsp.alf.recon_coeff_and_clip(coeff, clip, class_idx, transpose_idx, size, | |
| 1018 | coeff_set, clip_idx_set, class_to_filt); | ||
| 1019 | 21045 | } | |
| 1020 | |||
| 1021 | 21045 | static void alf_filter_luma(VVCLocalContext *lc, uint8_t *dst, const uint8_t *src, | |
| 1022 | const ptrdiff_t dst_stride, const ptrdiff_t src_stride, const int x0, const int y0, | ||
| 1023 | const int width, const int height, const int _vb_pos, const ALFParams *alf) | ||
| 1024 | { | ||
| 1025 | 21045 | const VVCFrameContext *fc = lc->fc; | |
| 1026 | 21045 | int vb_pos = _vb_pos - y0; | |
| 1027 | 21045 | int16_t *coeff = lc->alf.coeff_tmp; | |
| 1028 | 21045 | int16_t *clip = lc->alf.clip_tmp; | |
| 1029 | |||
| 1030 | 21045 | alf_get_coeff_and_clip(lc, coeff, clip, src, src_stride, width, height, vb_pos, alf); | |
| 1031 | 21045 | fc->vvcdsp.alf.filter[LUMA](dst, dst_stride, src, src_stride, width, height, coeff, clip, vb_pos); | |
| 1032 | 21045 | } | |
| 1033 | |||
| 1034 | 160326 | static int alf_clip_from_idx(const VVCFrameContext *fc, const int idx) | |
| 1035 | { | ||
| 1036 | 160326 | const VVCSPS *sps = fc->ps.sps; | |
| 1037 | 160326 | const int offset[] = {0, 3, 5, 7}; | |
| 1038 | |||
| 1039 | 160326 | return 1 << (sps->bit_depth - offset[idx]); | |
| 1040 | } | ||
| 1041 | |||
| 1042 | 26721 | static void alf_filter_chroma(VVCLocalContext *lc, uint8_t *dst, const uint8_t *src, | |
| 1043 | const ptrdiff_t dst_stride, const ptrdiff_t src_stride, const int c_idx, | ||
| 1044 | const int width, const int height, const int vb_pos, const ALFParams *alf) | ||
| 1045 | { | ||
| 1046 | 26721 | VVCFrameContext *fc = lc->fc; | |
| 1047 | 26721 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 1048 | 26721 | const VVCALF *aps = fc->ps.alf_list[rsh->sh_alf_aps_id_chroma]; | |
| 1049 | 26721 | const int idx = alf->alf_ctb_filter_alt_idx[c_idx - 1]; | |
| 1050 | 26721 | const int16_t *coeff = aps->chroma_coeff[idx]; | |
| 1051 | int16_t clip[ALF_NUM_COEFF_CHROMA]; | ||
| 1052 | |||
| 1053 |
2/2✓ Branch 0 taken 160326 times.
✓ Branch 1 taken 26721 times.
|
187047 | for (int i = 0; i < ALF_NUM_COEFF_CHROMA; i++) |
| 1054 | 160326 | clip[i] = alf_clip_from_idx(fc, aps->chroma_clip_idx[idx][i]); | |
| 1055 | |||
| 1056 | 26721 | fc->vvcdsp.alf.filter[CHROMA](dst, dst_stride, src, src_stride, width, height, coeff, clip, vb_pos); | |
| 1057 | 26721 | } | |
| 1058 | |||
| 1059 | 10527 | static void alf_filter_cc(VVCLocalContext *lc, uint8_t *dst, const uint8_t *luma, | |
| 1060 | const ptrdiff_t dst_stride, const ptrdiff_t luma_stride, const int c_idx, | ||
| 1061 | const int width, const int height, const int hs, const int vs, const int vb_pos, const ALFParams *alf) | ||
| 1062 | { | ||
| 1063 | 10527 | const VVCFrameContext *fc = lc->fc; | |
| 1064 | 10527 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 1065 | 10527 | const int idx = c_idx - 1; | |
| 1066 |
2/2✓ Branch 0 taken 5379 times.
✓ Branch 1 taken 5148 times.
|
10527 | const int cc_aps_id = c_idx == CB ? rsh->sh_alf_cc_cb_aps_id : rsh->sh_alf_cc_cr_aps_id; |
| 1067 | 10527 | const VVCALF *aps = fc->ps.alf_list[cc_aps_id]; | |
| 1068 | |||
| 1069 |
1/2✓ Branch 0 taken 10527 times.
✗ Branch 1 not taken.
|
10527 | if (aps) { |
| 1070 | 10527 | const int16_t *coeff = aps->cc_coeff[idx][alf->ctb_cc_idc[idx] - 1]; | |
| 1071 | |||
| 1072 | 10527 | fc->vvcdsp.alf.filter_cc(dst, dst_stride, luma, luma_stride, width, height, hs, vs, coeff, vb_pos); | |
| 1073 | } | ||
| 1074 | 10527 | } | |
| 1075 | |||
| 1076 | 43707 | void ff_vvc_alf_copy_ctu_to_hv(VVCLocalContext* lc, const int x0, const int y0) | |
| 1077 | { | ||
| 1078 | 43707 | VVCFrameContext *fc = lc->fc; | |
| 1079 | 43707 | const int rx = x0 >> fc->ps.sps->ctb_log2_size_y; | |
| 1080 | 43707 | const int ry = y0 >> fc->ps.sps->ctb_log2_size_y; | |
| 1081 | 43707 | const int ctb_size_y = fc->ps.sps->ctb_size_y; | |
| 1082 |
2/2✓ Branch 0 taken 43179 times.
✓ Branch 1 taken 528 times.
|
43707 | const int c_end = fc->ps.sps->r->sps_chroma_format_idc ? VVC_MAX_SAMPLE_ARRAYS : 1; |
| 1083 | |||
| 1084 |
2/2✓ Branch 0 taken 130065 times.
✓ Branch 1 taken 43707 times.
|
173772 | for (int c_idx = 0; c_idx < c_end; c_idx++) { |
| 1085 | 130065 | const int hs = fc->ps.sps->hshift[c_idx]; | |
| 1086 | 130065 | const int vs = fc->ps.sps->vshift[c_idx]; | |
| 1087 | 130065 | const int x = x0 >> hs; | |
| 1088 | 130065 | const int y = y0 >> vs; | |
| 1089 | 130065 | const int width = FFMIN(fc->ps.pps->width - x0, ctb_size_y) >> hs; | |
| 1090 | 130065 | const int height = FFMIN(fc->ps.pps->height - y0, ctb_size_y) >> vs; | |
| 1091 | |||
| 1092 | 130065 | const int src_stride = fc->frame->linesize[c_idx]; | |
| 1093 | 130065 | uint8_t *src = POS(c_idx, x0, y0); | |
| 1094 | |||
| 1095 | 130065 | alf_copy_ctb_to_hv(fc, src, src_stride, x, y, width, height, rx, ry, c_idx); | |
| 1096 | } | ||
| 1097 | 43707 | } | |
| 1098 | |||
| 1099 | 43707 | static void alf_get_edges(const VVCLocalContext *lc, int edges[MAX_EDGES], const int rx, const int ry) | |
| 1100 | { | ||
| 1101 | 43707 | VVCFrameContext *fc = lc->fc; | |
| 1102 | 43707 | const VVCSPS *sps = fc->ps.sps; | |
| 1103 | 43707 | const VVCPPS *pps = fc->ps.pps; | |
| 1104 | 43707 | const int subpic_idx = lc->sc->sh.r->curr_subpic_idx; | |
| 1105 | |||
| 1106 | // we can't use |= instead of || in this function; |= is not a shortcut operator | ||
| 1107 | |||
| 1108 |
2/2✓ Branch 0 taken 40288 times.
✓ Branch 1 taken 3419 times.
|
43707 | if (!pps->r->pps_loop_filter_across_tiles_enabled_flag) { |
| 1109 |
4/4✓ Branch 0 taken 36418 times.
✓ Branch 1 taken 3870 times.
✓ Branch 2 taken 612 times.
✓ Branch 3 taken 35806 times.
|
40288 | edges[LEFT] = edges[LEFT] || (lc->boundary_flags & BOUNDARY_LEFT_TILE); |
| 1110 |
4/4✓ Branch 0 taken 33434 times.
✓ Branch 1 taken 6854 times.
✓ Branch 2 taken 564 times.
✓ Branch 3 taken 32870 times.
|
40288 | edges[TOP] = edges[TOP] || (lc->boundary_flags & BOUNDARY_UPPER_TILE); |
| 1111 |
4/4✓ Branch 0 taken 36418 times.
✓ Branch 1 taken 3870 times.
✓ Branch 2 taken 612 times.
✓ Branch 3 taken 35806 times.
|
40288 | edges[RIGHT] = edges[RIGHT] || pps->ctb_to_col_bd[rx] != pps->ctb_to_col_bd[rx + 1]; |
| 1112 |
4/4✓ Branch 0 taken 33434 times.
✓ Branch 1 taken 6854 times.
✓ Branch 2 taken 564 times.
✓ Branch 3 taken 32870 times.
|
40288 | edges[BOTTOM] = edges[BOTTOM] || pps->ctb_to_row_bd[ry] != pps->ctb_to_row_bd[ry + 1]; |
| 1113 | } | ||
| 1114 | |||
| 1115 |
2/2✓ Branch 0 taken 40239 times.
✓ Branch 1 taken 3468 times.
|
43707 | if (!pps->r->pps_loop_filter_across_slices_enabled_flag) { |
| 1116 |
4/4✓ Branch 0 taken 35890 times.
✓ Branch 1 taken 4349 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 35885 times.
|
40239 | edges[LEFT] = edges[LEFT] || (lc->boundary_flags & BOUNDARY_LEFT_SLICE); |
| 1117 |
4/4✓ Branch 0 taken 32954 times.
✓ Branch 1 taken 7285 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 32883 times.
|
40239 | edges[TOP] = edges[TOP] || (lc->boundary_flags & BOUNDARY_UPPER_SLICE); |
| 1118 |
4/4✓ Branch 0 taken 35890 times.
✓ Branch 1 taken 4349 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 35885 times.
|
40239 | edges[RIGHT] = edges[RIGHT] || CTB(fc->tab.slice_idx, rx, ry) != CTB(fc->tab.slice_idx, rx + 1, ry); |
| 1119 |
4/4✓ Branch 0 taken 32954 times.
✓ Branch 1 taken 7285 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 32883 times.
|
40239 | edges[BOTTOM] = edges[BOTTOM] || CTB(fc->tab.slice_idx, rx, ry) != CTB(fc->tab.slice_idx, rx, ry + 1); |
| 1120 | } | ||
| 1121 | |||
| 1122 |
2/2✓ Branch 0 taken 42741 times.
✓ Branch 1 taken 966 times.
|
43707 | if (!sps->r->sps_loop_filter_across_subpic_enabled_flag[subpic_idx]) { |
| 1123 |
4/4✓ Branch 0 taken 38352 times.
✓ Branch 1 taken 4389 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 38348 times.
|
42741 | edges[LEFT] = edges[LEFT] || (lc->boundary_flags & BOUNDARY_LEFT_SUBPIC); |
| 1124 |
3/4✓ Branch 0 taken 35226 times.
✓ Branch 1 taken 7515 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35226 times.
|
42741 | edges[TOP] = edges[TOP] || (lc->boundary_flags & BOUNDARY_UPPER_SUBPIC); |
| 1125 |
3/4✓ Branch 0 taken 38348 times.
✓ Branch 1 taken 4393 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38348 times.
|
42741 | edges[RIGHT] = edges[RIGHT] || fc->ps.sps->r->sps_subpic_ctu_top_left_x[subpic_idx] + fc->ps.sps->r->sps_subpic_width_minus1[subpic_idx] == rx; |
| 1126 |
4/4✓ Branch 0 taken 35238 times.
✓ Branch 1 taken 7503 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 35226 times.
|
42741 | edges[BOTTOM] = edges[BOTTOM] || fc->ps.sps->r->sps_subpic_ctu_top_left_y[subpic_idx] + fc->ps.sps->r->sps_subpic_height_minus1[subpic_idx] == ry; |
| 1127 | } | ||
| 1128 | |||
| 1129 |
2/2✓ Branch 0 taken 1029 times.
✓ Branch 1 taken 42678 times.
|
43707 | if (sps->r->sps_virtual_boundaries_enabled_flag) { |
| 1130 |
3/4✓ Branch 0 taken 621 times.
✓ Branch 1 taken 408 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 621 times.
|
1029 | edges[LEFT] = edges[LEFT] || is_virtual_boundary(fc, rx << sps->ctb_log2_size_y, 1); |
| 1131 |
3/4✓ Branch 0 taken 595 times.
✓ Branch 1 taken 434 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 595 times.
|
1029 | edges[TOP] = edges[TOP] || is_virtual_boundary(fc, ry << sps->ctb_log2_size_y, 0); |
| 1132 |
3/4✓ Branch 0 taken 625 times.
✓ Branch 1 taken 404 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 625 times.
|
1029 | edges[RIGHT] = edges[RIGHT] || is_virtual_boundary(fc, (rx + 1) << sps->ctb_log2_size_y, 1); |
| 1133 |
3/4✓ Branch 0 taken 583 times.
✓ Branch 1 taken 446 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 583 times.
|
1029 | edges[BOTTOM] = edges[BOTTOM] || is_virtual_boundary(fc, (ry + 1) << sps->ctb_log2_size_y, 0); |
| 1134 | } | ||
| 1135 | 43707 | } | |
| 1136 | |||
| 1137 | 43707 | static void alf_init_subblock(VVCRect *sb, int sb_edges[MAX_EDGES], const VVCRect *b, const int edges[MAX_EDGES]) | |
| 1138 | { | ||
| 1139 | 43707 | *sb = *b; | |
| 1140 | 43707 | memcpy(sb_edges, edges, sizeof(int) * MAX_EDGES); | |
| 1141 | 43707 | } | |
| 1142 | |||
| 1143 | 43707 | static void alf_get_subblock(VVCRect *sb, int edges[MAX_EDGES], const int bx, const int by, const int vb_pos[2], const int has_vb[2]) | |
| 1144 | { | ||
| 1145 | 43707 | int *pos[] = { &sb->l, &sb->t, &sb->r, &sb->b }; | |
| 1146 | |||
| 1147 |
2/2✓ Branch 0 taken 87414 times.
✓ Branch 1 taken 43707 times.
|
131121 | for (int vertical = 0; vertical <= 1; vertical++) { |
| 1148 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 87414 times.
|
87414 | if (has_vb[vertical]) { |
| 1149 | ✗ | const int c = vertical ? (bx ? LEFT : RIGHT) : (by ? TOP : BOTTOM); | |
| 1150 | ✗ | *pos[c] = vb_pos[vertical]; | |
| 1151 | ✗ | edges[c] = 1; | |
| 1152 | } | ||
| 1153 | } | ||
| 1154 | 43707 | } | |
| 1155 | |||
| 1156 | 43707 | static void alf_get_subblocks(const VVCLocalContext *lc, VVCRect sbs[MAX_VBBS], int sb_edges[MAX_VBBS][MAX_EDGES], int *nb_sbs, | |
| 1157 | const int x0, const int y0, const int rx, const int ry) | ||
| 1158 | { | ||
| 1159 | 43707 | VVCFrameContext *fc = lc->fc; | |
| 1160 | 43707 | const VVCSPS *sps = fc->ps.sps; | |
| 1161 | 43707 | const VVCPPS *pps = fc->ps.pps; | |
| 1162 | 43707 | const int ctu_size_y = sps->ctb_size_y; | |
| 1163 | 43707 | const int vb_pos[] = { get_virtual_boundary(fc, ry, 0), get_virtual_boundary(fc, rx, 1) }; | |
| 1164 | 43707 | const int has_vb[] = { vb_pos[0] > y0, vb_pos[1] > x0 }; | |
| 1165 | 43707 | const VVCRect b = { x0, y0, FFMIN(x0 + ctu_size_y, pps->width), FFMIN(y0 + ctu_size_y, pps->height) }; | |
| 1166 | 43707 | int edges[MAX_EDGES] = { !rx, !ry, rx == pps->ctb_width - 1, ry == pps->ctb_height - 1 }; | |
| 1167 | 43707 | int i = 0; | |
| 1168 | |||
| 1169 | 43707 | alf_get_edges(lc, edges, rx, ry); | |
| 1170 | |||
| 1171 |
2/2✓ Branch 0 taken 43707 times.
✓ Branch 1 taken 43707 times.
|
87414 | for (int by = 0; by <= has_vb[0]; by++) { |
| 1172 |
2/2✓ Branch 0 taken 43707 times.
✓ Branch 1 taken 43707 times.
|
87414 | for (int bx = 0; bx <= has_vb[1]; bx++, i++) { |
| 1173 | 43707 | alf_init_subblock(sbs + i, sb_edges[i], &b, edges); | |
| 1174 | 43707 | alf_get_subblock(sbs + i, sb_edges[i], bx, by, vb_pos, has_vb); | |
| 1175 | } | ||
| 1176 | } | ||
| 1177 | 43707 | *nb_sbs = i; | |
| 1178 | 43707 | } | |
| 1179 | |||
| 1180 | 43707 | void ff_vvc_alf_filter(VVCLocalContext *lc, const int x0, const int y0) | |
| 1181 | { | ||
| 1182 | 43707 | VVCFrameContext *fc = lc->fc; | |
| 1183 | 43707 | const VVCSPS *sps = fc->ps.sps; | |
| 1184 | 43707 | const int rx = x0 >> sps->ctb_log2_size_y; | |
| 1185 | 43707 | const int ry = y0 >> sps->ctb_log2_size_y; | |
| 1186 | 43707 | const int ps = sps->pixel_shift; | |
| 1187 | 43707 | const int padded_stride = EDGE_EMU_BUFFER_STRIDE << ps; | |
| 1188 | 43707 | const int padded_offset = padded_stride * ALF_PADDING_SIZE + (ALF_PADDING_SIZE << ps); | |
| 1189 |
2/2✓ Branch 0 taken 43179 times.
✓ Branch 1 taken 528 times.
|
43707 | const int c_end = sps->r->sps_chroma_format_idc ? VVC_MAX_SAMPLE_ARRAYS : 1; |
| 1190 | 43707 | const int has_chroma = !!sps->r->sps_chroma_format_idc; | |
| 1191 | 43707 | const int ctu_end = y0 + sps->ctb_size_y; | |
| 1192 | 43707 | const ALFParams *alf = &CTB(fc->tab.alf, rx, ry); | |
| 1193 | int sb_edges[MAX_VBBS][MAX_EDGES], nb_sbs; | ||
| 1194 | VVCRect sbs[MAX_VBBS]; | ||
| 1195 | |||
| 1196 | 43707 | alf_get_subblocks(lc, sbs, sb_edges, &nb_sbs, x0, y0, rx, ry); | |
| 1197 | |||
| 1198 |
2/2✓ Branch 0 taken 43707 times.
✓ Branch 1 taken 43707 times.
|
87414 | for (int i = 0; i < nb_sbs; i++) { |
| 1199 | 43707 | const VVCRect *sb = sbs + i; | |
| 1200 |
2/2✓ Branch 0 taken 130065 times.
✓ Branch 1 taken 43707 times.
|
173772 | for (int c_idx = 0; c_idx < c_end; c_idx++) { |
| 1201 | 130065 | const int hs = fc->ps.sps->hshift[c_idx]; | |
| 1202 | 130065 | const int vs = fc->ps.sps->vshift[c_idx]; | |
| 1203 | 130065 | const int x = sb->l >> hs; | |
| 1204 | 130065 | const int y = sb->t >> vs; | |
| 1205 | 130065 | const int width = (sb->r - sb->l) >> hs; | |
| 1206 | 130065 | const int height = (sb->b - sb->t) >> vs; | |
| 1207 | 130065 | const int src_stride = fc->frame->linesize[c_idx]; | |
| 1208 | 130065 | uint8_t *src = POS(c_idx, sb->l, sb->t); | |
| 1209 | uint8_t *padded; | ||
| 1210 | |||
| 1211 |
10/10✓ Branch 0 taken 82299 times.
✓ Branch 1 taken 47766 times.
✓ Branch 2 taken 22662 times.
✓ Branch 3 taken 59637 times.
✓ Branch 4 taken 22492 times.
✓ Branch 5 taken 170 times.
✓ Branch 6 taken 21956 times.
✓ Branch 7 taken 536 times.
✓ Branch 8 taken 99 times.
✓ Branch 9 taken 21857 times.
|
130065 | if (alf->ctb_flag[c_idx] || (!c_idx && has_chroma && (alf->ctb_cc_idc[0] || alf->ctb_cc_idc[1]))) { |
| 1212 |
2/2✓ Branch 0 taken 26721 times.
✓ Branch 1 taken 21680 times.
|
48401 | padded = (c_idx ? lc->alf.buffer_chroma : lc->alf.buffer_luma) + padded_offset; |
| 1213 | 48401 | alf_prepare_buffer(fc, padded, src, x, y, rx, ry, width, height, | |
| 1214 | 48401 | padded_stride, src_stride, c_idx, sb_edges[i]); | |
| 1215 | } | ||
| 1216 |
2/2✓ Branch 0 taken 47766 times.
✓ Branch 1 taken 82299 times.
|
130065 | if (alf->ctb_flag[c_idx]) { |
| 1217 |
2/2✓ Branch 0 taken 21045 times.
✓ Branch 1 taken 26721 times.
|
47766 | if (!c_idx) { |
| 1218 | 21045 | alf_filter_luma(lc, src, padded, src_stride, padded_stride, x, y, | |
| 1219 | width, height, ctu_end - ALF_VB_POS_ABOVE_LUMA, alf); | ||
| 1220 | } else { | ||
| 1221 | 26721 | alf_filter_chroma(lc, src, padded, src_stride, padded_stride, c_idx, | |
| 1222 | 26721 | width, height, ((ctu_end - sb->t) >> vs) - ALF_VB_POS_ABOVE_CHROMA, alf); | |
| 1223 | } | ||
| 1224 | } | ||
| 1225 |
4/4✓ Branch 0 taken 86358 times.
✓ Branch 1 taken 43707 times.
✓ Branch 2 taken 10527 times.
✓ Branch 3 taken 75831 times.
|
130065 | if (c_idx && alf->ctb_cc_idc[c_idx - 1]) { |
| 1226 | 10527 | padded = lc->alf.buffer_luma + padded_offset; | |
| 1227 | 10527 | alf_filter_cc(lc, src, padded, src_stride, padded_stride, c_idx, | |
| 1228 | 10527 | width, height, hs, vs, ctu_end - sb->t - ALF_VB_POS_ABOVE_LUMA, alf); | |
| 1229 | } | ||
| 1230 | } | ||
| 1231 | } | ||
| 1232 | 43707 | } | |
| 1233 | |||
| 1234 | |||
| 1235 | 55785 | void ff_vvc_lmcs_filter(const VVCLocalContext *lc, const int x, const int y) | |
| 1236 | { | ||
| 1237 | 55785 | const SliceContext *sc = lc->sc; | |
| 1238 | 55785 | const VVCFrameContext *fc = lc->fc; | |
| 1239 | 55785 | const int ctb_size = fc->ps.sps->ctb_size_y; | |
| 1240 | 55785 | const int width = FFMIN(fc->ps.pps->width - x, ctb_size); | |
| 1241 | 55785 | const int height = FFMIN(fc->ps.pps->height - y, ctb_size); | |
| 1242 | 55785 | uint8_t *data = POS(LUMA, x, y); | |
| 1243 |
2/2✓ Branch 0 taken 20525 times.
✓ Branch 1 taken 35260 times.
|
55785 | if (sc->sh.r->sh_lmcs_used_flag) |
| 1244 | 20525 | fc->vvcdsp.lmcs.filter(data, fc->frame->linesize[LUMA], width, height, &fc->ps.lmcs.inv_lut); | |
| 1245 | 55785 | } | |
| 1246 |