| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * VVC filters DSP | ||
| 3 | * | ||
| 4 | * Copyright (C) 2022 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 "libavcodec/h26x/h2656_sao_template.c" | ||
| 24 | |||
| 25 | 420000 | static void FUNC(lmcs_filter_luma)(uint8_t *_dst, ptrdiff_t dst_stride, const int width, const int height, const void *_lut) | |
| 26 | { | ||
| 27 | 420000 | const pixel *lut = _lut; | |
| 28 | 420000 | pixel *dst = (pixel*)_dst; | |
| 29 | 420000 | dst_stride /= sizeof(pixel); | |
| 30 | |||
| 31 |
2/2✓ Branch 0 taken 7355892 times.
✓ Branch 1 taken 210000 times.
|
15131784 | for (int y = 0; y < height; y++) { |
| 32 |
2/2✓ Branch 0 taken 572129632 times.
✓ Branch 1 taken 7355892 times.
|
1158971048 | for (int x = 0; x < width; x++) |
| 33 | 1144259264 | dst[x] = lut[dst[x]]; | |
| 34 | 14711784 | dst += dst_stride; | |
| 35 | } | ||
| 36 | 420000 | } | |
| 37 | |||
| 38 | 10161827328 | static av_always_inline int16_t FUNC(alf_clip)(pixel curr, pixel v0, pixel v1, int16_t clip) | |
| 39 | { | ||
| 40 | 10161827328 | return av_clip(v0 - curr, -clip, clip) + av_clip(v1 - curr, -clip, clip); | |
| 41 | } | ||
| 42 | |||
| 43 | 46198 | static void FUNC(alf_filter_luma)(uint8_t *_dst, ptrdiff_t dst_stride, const uint8_t *_src, ptrdiff_t src_stride, | |
| 44 | const int width, const int height, const int16_t *filter, const int16_t *clip, const int vb_pos) | ||
| 45 | { | ||
| 46 | 46198 | const pixel *src = (pixel *)_src; | |
| 47 | 46198 | const int shift = 7; | |
| 48 | 46198 | const int offset = 1 << ( shift - 1 ); | |
| 49 | 46198 | const int vb_above = vb_pos - 4; | |
| 50 | 46198 | const int vb_below = vb_pos + 3; | |
| 51 | |||
| 52 | 46198 | dst_stride /= sizeof(pixel); | |
| 53 | 46198 | src_stride /= sizeof(pixel); | |
| 54 | |||
| 55 |
2/2✓ Branch 0 taken 660118 times.
✓ Branch 1 taken 23099 times.
|
1366434 | for (int y = 0; y < height; y += ALF_BLOCK_SIZE) { |
| 56 |
2/2✓ Branch 0 taken 19910776 times.
✓ Branch 1 taken 660118 times.
|
41141788 | for (int x = 0; x < width; x += ALF_BLOCK_SIZE) { |
| 57 | 39821552 | const pixel *s0 = src + y * src_stride + x; | |
| 58 | 39821552 | const pixel *s1 = s0 + src_stride; | |
| 59 | 39821552 | const pixel *s2 = s0 - src_stride; | |
| 60 | 39821552 | const pixel *s3 = s1 + src_stride; | |
| 61 | 39821552 | const pixel *s4 = s2 - src_stride; | |
| 62 | 39821552 | const pixel *s5 = s3 + src_stride; | |
| 63 | 39821552 | const pixel *s6 = s4 - src_stride; | |
| 64 | |||
| 65 |
2/2✓ Branch 0 taken 79643104 times.
✓ Branch 1 taken 19910776 times.
|
199107760 | for (int i = 0; i < ALF_BLOCK_SIZE; i++) { |
| 66 | 159286208 | pixel *dst = (pixel *)_dst + (y + i) * dst_stride + x; | |
| 67 | |||
| 68 | 159286208 | const pixel *p0 = s0 + i * src_stride; | |
| 69 | 159286208 | const pixel *p1 = s1 + i * src_stride; | |
| 70 | 159286208 | const pixel *p2 = s2 + i * src_stride; | |
| 71 | 159286208 | const pixel *p3 = s3 + i * src_stride; | |
| 72 | 159286208 | const pixel *p4 = s4 + i * src_stride; | |
| 73 | 159286208 | const pixel *p5 = s5 + i * src_stride; | |
| 74 | 159286208 | const pixel *p6 = s6 + i * src_stride; | |
| 75 | |||
| 76 |
4/4✓ Branch 0 taken 77460256 times.
✓ Branch 1 taken 2182848 times.
✓ Branch 2 taken 545712 times.
✓ Branch 3 taken 76914544 times.
|
159286208 | const int is_near_vb_above = (y + i < vb_pos) && (y + i >= vb_pos - 1); |
| 77 |
4/4✓ Branch 0 taken 2182848 times.
✓ Branch 1 taken 77460256 times.
✓ Branch 2 taken 545712 times.
✓ Branch 3 taken 1637136 times.
|
159286208 | const int is_near_vb_below = (y + i >= vb_pos) && (y + i <= vb_pos); |
| 78 |
4/4✓ Branch 0 taken 79097392 times.
✓ Branch 1 taken 545712 times.
✓ Branch 2 taken 545712 times.
✓ Branch 3 taken 78551680 times.
|
159286208 | const int is_near_vb = is_near_vb_above || is_near_vb_below; |
| 79 | |||
| 80 |
4/4✓ Branch 0 taken 77460256 times.
✓ Branch 1 taken 2182848 times.
✓ Branch 2 taken 1637136 times.
✓ Branch 3 taken 75823120 times.
|
159286208 | if ((y + i < vb_pos) && ((y + i) > vb_above)) { |
| 81 |
2/2✓ Branch 0 taken 545712 times.
✓ Branch 1 taken 1091424 times.
|
3274272 | p1 = (y + i == vb_pos - 1) ? p0 : p1; |
| 82 |
2/2✓ Branch 0 taken 1091424 times.
✓ Branch 1 taken 545712 times.
|
3274272 | p3 = (y + i >= vb_pos - 2) ? p1 : p3; |
| 83 |
1/2✓ Branch 0 taken 1637136 times.
✗ Branch 1 not taken.
|
3274272 | p5 = (y + i >= vb_pos - 3) ? p3 : p5; |
| 84 | |||
| 85 |
2/2✓ Branch 0 taken 545712 times.
✓ Branch 1 taken 1091424 times.
|
3274272 | p2 = (y + i == vb_pos - 1) ? p0 : p2; |
| 86 |
2/2✓ Branch 0 taken 1091424 times.
✓ Branch 1 taken 545712 times.
|
3274272 | p4 = (y + i >= vb_pos - 2) ? p2 : p4; |
| 87 |
1/2✓ Branch 0 taken 1637136 times.
✗ Branch 1 not taken.
|
3274272 | p6 = (y + i >= vb_pos - 3) ? p4 : p6; |
| 88 |
4/4✓ Branch 0 taken 2182848 times.
✓ Branch 1 taken 75823120 times.
✓ Branch 2 taken 1637136 times.
✓ Branch 3 taken 545712 times.
|
156011936 | } else if ((y + i >= vb_pos) && ((y + i) < vb_below)) { |
| 89 |
2/2✓ Branch 0 taken 545712 times.
✓ Branch 1 taken 1091424 times.
|
3274272 | p2 = (y + i == vb_pos ) ? p0 : p2; |
| 90 |
2/2✓ Branch 0 taken 1091424 times.
✓ Branch 1 taken 545712 times.
|
3274272 | p4 = (y + i <= vb_pos + 1) ? p2 : p4; |
| 91 |
1/2✓ Branch 0 taken 1637136 times.
✗ Branch 1 not taken.
|
3274272 | p6 = (y + i <= vb_pos + 2) ? p4 : p6; |
| 92 | |||
| 93 |
2/2✓ Branch 0 taken 545712 times.
✓ Branch 1 taken 1091424 times.
|
3274272 | p1 = (y + i == vb_pos ) ? p0 : p1; |
| 94 |
2/2✓ Branch 0 taken 1091424 times.
✓ Branch 1 taken 545712 times.
|
3274272 | p3 = (y + i <= vb_pos + 1) ? p1 : p3; |
| 95 |
1/2✓ Branch 0 taken 1637136 times.
✗ Branch 1 not taken.
|
3274272 | p5 = (y + i <= vb_pos + 2) ? p3 : p5; |
| 96 | } | ||
| 97 | |||
| 98 |
2/2✓ Branch 0 taken 318572416 times.
✓ Branch 1 taken 79643104 times.
|
796431040 | for (int j = 0; j < ALF_BLOCK_SIZE; j++) { |
| 99 | 637144832 | int sum = 0; | |
| 100 | 637144832 | const pixel curr = *p0; | |
| 101 | |||
| 102 | 637144832 | sum += filter[0] * FUNC(alf_clip)(curr, p5[+0], p6[+0], clip[0]); | |
| 103 | 637144832 | sum += filter[1] * FUNC(alf_clip)(curr, p3[+1], p4[-1], clip[1]); | |
| 104 | 637144832 | sum += filter[2] * FUNC(alf_clip)(curr, p3[+0], p4[+0], clip[2]); | |
| 105 | 637144832 | sum += filter[3] * FUNC(alf_clip)(curr, p3[-1], p4[+1], clip[3]); | |
| 106 | 637144832 | sum += filter[4] * FUNC(alf_clip)(curr, p1[+2], p2[-2], clip[4]); | |
| 107 | 637144832 | sum += filter[5] * FUNC(alf_clip)(curr, p1[+1], p2[-1], clip[5]); | |
| 108 | 637144832 | sum += filter[6] * FUNC(alf_clip)(curr, p1[+0], p2[+0], clip[6]); | |
| 109 | 637144832 | sum += filter[7] * FUNC(alf_clip)(curr, p1[-1], p2[+1], clip[7]); | |
| 110 | 637144832 | sum += filter[8] * FUNC(alf_clip)(curr, p1[-2], p2[+2], clip[8]); | |
| 111 | 637144832 | sum += filter[9] * FUNC(alf_clip)(curr, p0[+3], p0[-3], clip[9]); | |
| 112 | 637144832 | sum += filter[10] * FUNC(alf_clip)(curr, p0[+2], p0[-2], clip[10]); | |
| 113 | 637144832 | sum += filter[11] * FUNC(alf_clip)(curr, p0[+1], p0[-1], clip[11]); | |
| 114 | |||
| 115 |
2/2✓ Branch 0 taken 314206720 times.
✓ Branch 1 taken 4365696 times.
|
637144832 | if (!is_near_vb) |
| 116 | 628413440 | sum = (sum + offset) >> shift; | |
| 117 | else | ||
| 118 | 8731392 | sum = (sum + (1 << ((shift + 3) - 1))) >> (shift + 3); | |
| 119 | 637144832 | sum += curr; | |
| 120 | 637144832 | dst[j] = CLIP(sum); | |
| 121 | |||
| 122 | 637144832 | p0++; | |
| 123 | 637144832 | p1++; | |
| 124 | 637144832 | p2++; | |
| 125 | 637144832 | p3++; | |
| 126 | 637144832 | p4++; | |
| 127 | 637144832 | p5++; | |
| 128 | 637144832 | p6++; | |
| 129 | } | ||
| 130 | } | ||
| 131 | 39821552 | filter += ALF_NUM_COEFF_LUMA; | |
| 132 | 39821552 | clip += ALF_NUM_COEFF_LUMA; | |
| 133 | } | ||
| 134 | } | ||
| 135 | 46198 | } | |
| 136 | |||
| 137 | 62786 | static void FUNC(alf_filter_chroma)(uint8_t* _dst, ptrdiff_t dst_stride, const uint8_t* _src, ptrdiff_t src_stride, | |
| 138 | const int width, const int height, const int16_t* filter, const int16_t* clip, const int vb_pos) | ||
| 139 | { | ||
| 140 | 62786 | const pixel *src = (pixel *)_src; | |
| 141 | 62786 | const int shift = 7; | |
| 142 | 62786 | const int offset = 1 << ( shift - 1 ); | |
| 143 | 62786 | const int vb_above = vb_pos - 2; | |
| 144 | 62786 | const int vb_below = vb_pos + 1; | |
| 145 | |||
| 146 | 62786 | dst_stride /= sizeof(pixel); | |
| 147 | 62786 | src_stride /= sizeof(pixel); | |
| 148 | |||
| 149 |
2/2✓ Branch 0 taken 595561 times.
✓ Branch 1 taken 31393 times.
|
1253908 | for (int y = 0; y < height; y += ALF_BLOCK_SIZE) { |
| 150 |
2/2✓ Branch 0 taken 13104632 times.
✓ Branch 1 taken 595561 times.
|
27400386 | for (int x = 0; x < width; x += ALF_BLOCK_SIZE) { |
| 151 | 26209264 | const pixel *s0 = src + y * src_stride + x; | |
| 152 | 26209264 | const pixel *s1 = s0 + src_stride; | |
| 153 | 26209264 | const pixel *s2 = s0 - src_stride; | |
| 154 | 26209264 | const pixel *s3 = s1 + src_stride; | |
| 155 | 26209264 | const pixel *s4 = s2 - src_stride; | |
| 156 | |||
| 157 |
2/2✓ Branch 0 taken 52418528 times.
✓ Branch 1 taken 13104632 times.
|
131046320 | for (int i = 0; i < ALF_BLOCK_SIZE; i++) { |
| 158 | 104837056 | pixel *dst = (pixel *)_dst + (y + i) * dst_stride + x; | |
| 159 | |||
| 160 | 104837056 | const pixel *p0 = s0 + i * src_stride; | |
| 161 | 104837056 | const pixel *p1 = s1 + i * src_stride; | |
| 162 | 104837056 | const pixel *p2 = s2 + i * src_stride; | |
| 163 | 104837056 | const pixel *p3 = s3 + i * src_stride; | |
| 164 | 104837056 | const pixel *p4 = s4 + i * src_stride; | |
| 165 | |||
| 166 |
4/4✓ Branch 0 taken 51439412 times.
✓ Branch 1 taken 979116 times.
✓ Branch 2 taken 489558 times.
✓ Branch 3 taken 50949854 times.
|
104837056 | const int is_near_vb_above = (y + i < vb_pos) && (y + i >= vb_pos - 1); |
| 167 |
4/4✓ Branch 0 taken 979116 times.
✓ Branch 1 taken 51439412 times.
✓ Branch 2 taken 489558 times.
✓ Branch 3 taken 489558 times.
|
104837056 | const int is_near_vb_below = (y + i >= vb_pos) && (y + i <= vb_pos); |
| 168 |
4/4✓ Branch 0 taken 51928970 times.
✓ Branch 1 taken 489558 times.
✓ Branch 2 taken 489558 times.
✓ Branch 3 taken 51439412 times.
|
104837056 | const int is_near_vb = is_near_vb_above || is_near_vb_below; |
| 169 | |||
| 170 |
4/4✓ Branch 0 taken 51439412 times.
✓ Branch 1 taken 979116 times.
✓ Branch 2 taken 979116 times.
✓ Branch 3 taken 50460296 times.
|
104837056 | if ((y + i < vb_pos) && ((y + i) >= vb_above)) { |
| 171 |
2/2✓ Branch 0 taken 489558 times.
✓ Branch 1 taken 489558 times.
|
1958232 | p1 = (y + i == vb_pos - 1) ? p0 : p1; |
| 172 |
1/2✓ Branch 0 taken 979116 times.
✗ Branch 1 not taken.
|
1958232 | p3 = (y + i >= vb_pos - 2) ? p1 : p3; |
| 173 | |||
| 174 |
2/2✓ Branch 0 taken 489558 times.
✓ Branch 1 taken 489558 times.
|
1958232 | p2 = (y + i == vb_pos - 1) ? p0 : p2; |
| 175 |
1/2✓ Branch 0 taken 979116 times.
✗ Branch 1 not taken.
|
1958232 | p4 = (y + i >= vb_pos - 2) ? p2 : p4; |
| 176 |
3/4✓ Branch 0 taken 979116 times.
✓ Branch 1 taken 50460296 times.
✓ Branch 2 taken 979116 times.
✗ Branch 3 not taken.
|
102878824 | } else if ((y + i >= vb_pos) && ((y + i) <= vb_below)) { |
| 177 |
2/2✓ Branch 0 taken 489558 times.
✓ Branch 1 taken 489558 times.
|
1958232 | p2 = (y + i == vb_pos ) ? p0 : p2; |
| 178 |
1/2✓ Branch 0 taken 979116 times.
✗ Branch 1 not taken.
|
1958232 | p4 = (y + i <= vb_pos + 1) ? p2 : p4; |
| 179 | |||
| 180 |
2/2✓ Branch 0 taken 489558 times.
✓ Branch 1 taken 489558 times.
|
1958232 | p1 = (y + i == vb_pos ) ? p0 : p1; |
| 181 |
1/2✓ Branch 0 taken 979116 times.
✗ Branch 1 not taken.
|
1958232 | p3 = (y + i <= vb_pos + 1) ? p1 : p3; |
| 182 | } | ||
| 183 | |||
| 184 |
2/2✓ Branch 0 taken 209674112 times.
✓ Branch 1 taken 52418528 times.
|
524185280 | for (int j = 0; j < ALF_BLOCK_SIZE; j++) { |
| 185 | 419348224 | int sum = 0; | |
| 186 | 419348224 | const pixel curr = *p0; | |
| 187 | |||
| 188 | 419348224 | sum += filter[0] * FUNC(alf_clip)(curr, p3[+0], p4[+0], clip[0]); | |
| 189 | 419348224 | sum += filter[1] * FUNC(alf_clip)(curr, p1[+1], p2[-1], clip[1]); | |
| 190 | 419348224 | sum += filter[2] * FUNC(alf_clip)(curr, p1[+0], p2[+0], clip[2]); | |
| 191 | 419348224 | sum += filter[3] * FUNC(alf_clip)(curr, p1[-1], p2[+1], clip[3]); | |
| 192 | 419348224 | sum += filter[4] * FUNC(alf_clip)(curr, p0[+2], p0[-2], clip[4]); | |
| 193 | 419348224 | sum += filter[5] * FUNC(alf_clip)(curr, p0[+1], p0[-1], clip[5]); | |
| 194 | |||
| 195 |
2/2✓ Branch 0 taken 205757648 times.
✓ Branch 1 taken 3916464 times.
|
419348224 | if (!is_near_vb) |
| 196 | 411515296 | sum = (sum + offset) >> shift; | |
| 197 | else | ||
| 198 | 7832928 | sum = (sum + (1 << ((shift + 3) - 1))) >> (shift + 3); | |
| 199 | 419348224 | sum += curr; | |
| 200 | 419348224 | dst[j] = CLIP(sum); | |
| 201 | |||
| 202 | 419348224 | p0++; | |
| 203 | 419348224 | p1++; | |
| 204 | 419348224 | p2++; | |
| 205 | 419348224 | p3++; | |
| 206 | 419348224 | p4++; | |
| 207 | } | ||
| 208 | } | ||
| 209 | } | ||
| 210 | } | ||
| 211 | 62786 | } | |
| 212 | |||
| 213 | 21054 | static void FUNC(alf_filter_cc)(uint8_t *_dst, ptrdiff_t dst_stride, const uint8_t *_luma, const ptrdiff_t luma_stride, | |
| 214 | const int width, const int height, const int hs, const int vs, const int16_t *filter, const int vb_pos) | ||
| 215 | { | ||
| 216 | 21054 | const ptrdiff_t stride = luma_stride / sizeof(pixel); | |
| 217 | |||
| 218 | 21054 | dst_stride /= sizeof(pixel); | |
| 219 | |||
| 220 |
2/2✓ Branch 0 taken 797668 times.
✓ Branch 1 taken 10527 times.
|
1616390 | for (int y = 0; y < height; y++) { |
| 221 |
2/2✓ Branch 0 taken 71027584 times.
✓ Branch 1 taken 797668 times.
|
143650504 | for (int x = 0; x < width; x++) { |
| 222 | 142055168 | int sum = 0; | |
| 223 | 142055168 | pixel *dst = (pixel *)_dst + y * dst_stride + x; | |
| 224 | 142055168 | const pixel *src = (pixel *)_luma + (y << vs) * stride + (x << hs); | |
| 225 | |||
| 226 | 142055168 | const pixel *s0 = src - stride; | |
| 227 | 142055168 | const pixel *s1 = src; | |
| 228 | 142055168 | const pixel *s2 = src + stride; | |
| 229 | 142055168 | const pixel *s3 = src + 2 * stride; | |
| 230 | |||
| 231 | 142055168 | const int pos = y << vs; | |
| 232 |
6/6✓ Branch 0 taken 41829376 times.
✓ Branch 1 taken 29198208 times.
✓ Branch 2 taken 41522688 times.
✓ Branch 3 taken 306688 times.
✓ Branch 4 taken 306688 times.
✓ Branch 5 taken 41216000 times.
|
142055168 | if (!vs && (pos == vb_pos || pos == vb_pos + 1)) |
| 233 | 1226752 | continue; | |
| 234 | |||
| 235 |
3/4✓ Branch 0 taken 69689712 times.
✓ Branch 1 taken 724496 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69689712 times.
|
140828416 | if (pos == (vb_pos - 2) || pos == (vb_pos + 1)) |
| 236 | 1448992 | s3 = s2; | |
| 237 |
4/4✓ Branch 0 taken 69383024 times.
✓ Branch 1 taken 306688 times.
✓ Branch 2 taken 417808 times.
✓ Branch 3 taken 68965216 times.
|
139379424 | else if (pos == (vb_pos - 1) || pos == vb_pos) |
| 238 | 1448992 | s3 = s2 = s0 = s1; | |
| 239 | |||
| 240 | |||
| 241 | 140828416 | sum += filter[0] * (*s0 - *src); | |
| 242 | 140828416 | sum += filter[1] * (*(s1 - 1) - *src); | |
| 243 | 140828416 | sum += filter[2] * (*(s1 + 1) - *src); | |
| 244 | 140828416 | sum += filter[3] * (*(s2 - 1) - *src); | |
| 245 | 140828416 | sum += filter[4] * (*s2 - *src); | |
| 246 | 140828416 | sum += filter[5] * (*(s2 + 1) - *src); | |
| 247 | 140828416 | sum += filter[6] * (*s3 - *src); | |
| 248 | 140828416 | sum = av_clip((sum + 64) >> 7, -(1 << (BIT_DEPTH - 1)), (1 << (BIT_DEPTH - 1)) - 1); | |
| 249 | 140828416 | sum += *dst; | |
| 250 | 140828416 | *dst = av_clip_pixel(sum); | |
| 251 | } | ||
| 252 | } | ||
| 253 | 21054 | } | |
| 254 | |||
| 255 | #define ALF_DIR_VERT 0 | ||
| 256 | #define ALF_DIR_HORZ 1 | ||
| 257 | #define ALF_DIR_DIGA0 2 | ||
| 258 | #define ALF_DIR_DIGA1 3 | ||
| 259 | |||
| 260 | 39821552 | static void FUNC(alf_get_idx)(int *class_idx, int *transpose_idx, const int *sum, const int ac) | |
| 261 | { | ||
| 262 | static const int arg_var[] = {0, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4 }; | ||
| 263 | |||
| 264 | int hv0, hv1, dir_hv, d0, d1, dir_d, hvd1, hvd0, sum_hv, dir1; | ||
| 265 | |||
| 266 | 39821552 | dir_hv = sum[ALF_DIR_VERT] <= sum[ALF_DIR_HORZ]; | |
| 267 | 39821552 | hv1 = FFMAX(sum[ALF_DIR_VERT], sum[ALF_DIR_HORZ]); | |
| 268 | 39821552 | hv0 = FFMIN(sum[ALF_DIR_VERT], sum[ALF_DIR_HORZ]); | |
| 269 | |||
| 270 | 39821552 | dir_d = sum[ALF_DIR_DIGA0] <= sum[ALF_DIR_DIGA1]; | |
| 271 | 39821552 | d1 = FFMAX(sum[ALF_DIR_DIGA0], sum[ALF_DIR_DIGA1]); | |
| 272 | 39821552 | d0 = FFMIN(sum[ALF_DIR_DIGA0], sum[ALF_DIR_DIGA1]); | |
| 273 | |||
| 274 | //promote to avoid overflow | ||
| 275 | 39821552 | dir1 = (uint64_t)d1 * hv0 <= (uint64_t)hv1 * d0; | |
| 276 |
2/2✓ Branch 0 taken 14834631 times.
✓ Branch 1 taken 5076145 times.
|
39821552 | hvd1 = dir1 ? hv1 : d1; |
| 277 |
2/2✓ Branch 0 taken 14834631 times.
✓ Branch 1 taken 5076145 times.
|
39821552 | hvd0 = dir1 ? hv0 : d0; |
| 278 | |||
| 279 | 39821552 | sum_hv = sum[ALF_DIR_HORZ] + sum[ALF_DIR_VERT]; | |
| 280 | 39821552 | *class_idx = arg_var[av_clip_uintp2(sum_hv * ac >> (BIT_DEPTH - 1), 4)]; | |
| 281 |
2/2✓ Branch 0 taken 4153084 times.
✓ Branch 1 taken 15757692 times.
|
39821552 | if (hvd1 * 2 > 9 * hvd0) |
| 282 | 8306168 | *class_idx += ((dir1 << 1) + 2) * 5; | |
| 283 |
2/2✓ Branch 0 taken 4929213 times.
✓ Branch 1 taken 10828479 times.
|
31515384 | else if (hvd1 > 2 * hvd0) |
| 284 | 9858426 | *class_idx += ((dir1 << 1) + 1) * 5; | |
| 285 | |||
| 286 | 39821552 | *transpose_idx = dir_d * 2 + dir_hv; | |
| 287 | 39821552 | } | |
| 288 | |||
| 289 | 46198 | static void FUNC(alf_classify)(int *class_idx, int *transpose_idx, | |
| 290 | const uint8_t *_src, const ptrdiff_t _src_stride, const int width, const int height, | ||
| 291 | const int vb_pos, int *gradient_tmp) | ||
| 292 | { | ||
| 293 | int *grad; | ||
| 294 | |||
| 295 | 46198 | const int h = height + ALF_GRADIENT_BORDER * 2; | |
| 296 | 46198 | const int w = width + ALF_GRADIENT_BORDER * 2; | |
| 297 | 46198 | const int size = (ALF_BLOCK_SIZE + ALF_GRADIENT_BORDER * 2) / ALF_GRADIENT_STEP; | |
| 298 | 46198 | const int gstride = (w / ALF_GRADIENT_STEP) * ALF_NUM_DIR; | |
| 299 | |||
| 300 | 46198 | const pixel *src = (const pixel *)_src; | |
| 301 | 46198 | const ptrdiff_t src_stride = _src_stride / sizeof(pixel); | |
| 302 | 46198 | src -= (ALF_GRADIENT_BORDER + 1) * src_stride + ALF_GRADIENT_BORDER; | |
| 303 | |||
| 304 | 46198 | grad = gradient_tmp; | |
| 305 |
2/2✓ Branch 0 taken 1366434 times.
✓ Branch 1 taken 23099 times.
|
2779066 | for (int y = 0; y < h; y += ALF_GRADIENT_STEP) { |
| 306 | 2732868 | const pixel *s0 = src + y * src_stride; | |
| 307 | 2732868 | const pixel *s1 = s0 + src_stride; | |
| 308 | 2732868 | const pixel *s2 = s1 + src_stride; | |
| 309 | 2732868 | const pixel *s3 = s2 + src_stride; | |
| 310 | |||
| 311 |
2/2✓ Branch 0 taken 18013 times.
✓ Branch 1 taken 1348421 times.
|
2732868 | if (y == vb_pos) //above |
| 312 | 36026 | s3 = s2; | |
| 313 |
2/2✓ Branch 0 taken 18013 times.
✓ Branch 1 taken 1330408 times.
|
2696842 | else if (y == vb_pos + ALF_GRADIENT_BORDER) |
| 314 | 36026 | s0 = s1; | |
| 315 | |||
| 316 |
2/2✓ Branch 0 taken 85110996 times.
✓ Branch 1 taken 1366434 times.
|
172954860 | for (int x = 0; x < w; x += ALF_GRADIENT_STEP) { |
| 317 | //two points a time | ||
| 318 | 170221992 | const pixel *a0 = s0 + x; | |
| 319 | 170221992 | const pixel *p0 = s1 + x; | |
| 320 | 170221992 | const pixel *b0 = s2 + x; | |
| 321 | 170221992 | const int val0 = (*p0) << 1; | |
| 322 | |||
| 323 | 170221992 | const pixel *a1 = s1 + x + 1; | |
| 324 | 170221992 | const pixel *p1 = s2 + x + 1; | |
| 325 | 170221992 | const pixel *b1 = s3 + x + 1; | |
| 326 | 170221992 | const int val1 = (*p1) << 1; | |
| 327 | |||
| 328 | 170221992 | grad[ALF_DIR_VERT] = FFABS(val0 - *a0 - *b0) + FFABS(val1 - *a1 - *b1); | |
| 329 | 170221992 | grad[ALF_DIR_HORZ] = FFABS(val0 - *(p0 - 1) - *(p0 + 1)) + FFABS(val1 - *(p1 - 1) - *(p1 + 1)); | |
| 330 | 170221992 | grad[ALF_DIR_DIGA0] = FFABS(val0 - *(a0 - 1) - *(b0 + 1)) + FFABS(val1 - *(a1 - 1) - *(b1 + 1)); | |
| 331 | 170221992 | grad[ALF_DIR_DIGA1] = FFABS(val0 - *(a0 + 1) - *(b0 - 1)) + FFABS(val1 - *(a1 + 1) - *(b1 - 1)); | |
| 332 | 170221992 | grad += ALF_NUM_DIR; | |
| 333 | } | ||
| 334 | } | ||
| 335 | |||
| 336 |
2/2✓ Branch 0 taken 660118 times.
✓ Branch 1 taken 23099 times.
|
1366434 | for (int y = 0; y < height ; y += ALF_BLOCK_SIZE ) { |
| 337 | 1320236 | int start = 0; | |
| 338 | 1320236 | int end = (ALF_BLOCK_SIZE + ALF_GRADIENT_BORDER * 2) / ALF_GRADIENT_STEP; | |
| 339 | 1320236 | int ac = 2; | |
| 340 |
2/2✓ Branch 0 taken 18013 times.
✓ Branch 1 taken 642105 times.
|
1320236 | if (y + ALF_BLOCK_SIZE == vb_pos) { |
| 341 | 36026 | end -= ALF_GRADIENT_BORDER / ALF_GRADIENT_STEP; | |
| 342 | 36026 | ac = 3; | |
| 343 |
2/2✓ Branch 0 taken 18013 times.
✓ Branch 1 taken 624092 times.
|
1284210 | } else if (y == vb_pos) { |
| 344 | 36026 | start += ALF_GRADIENT_BORDER / ALF_GRADIENT_STEP; | |
| 345 | 36026 | ac = 3; | |
| 346 | } | ||
| 347 |
2/2✓ Branch 0 taken 19910776 times.
✓ Branch 1 taken 660118 times.
|
41141788 | for (int x = 0; x < width; x += ALF_BLOCK_SIZE) { |
| 348 | 39821552 | const int xg = x / ALF_GRADIENT_STEP; | |
| 349 | 39821552 | const int yg = y / ALF_GRADIENT_STEP; | |
| 350 | 39821552 | int sum[ALF_NUM_DIR] = { 0 }; | |
| 351 | |||
| 352 | 39821552 | grad = gradient_tmp + (yg + start) * gstride + xg * ALF_NUM_DIR; | |
| 353 | //todo: optimize this loop | ||
| 354 |
2/2✓ Branch 0 taken 78552896 times.
✓ Branch 1 taken 19910776 times.
|
196927344 | for (int i = start; i < end; i++) { |
| 355 |
2/2✓ Branch 0 taken 314211584 times.
✓ Branch 1 taken 78552896 times.
|
785528960 | for (int j = 0; j < size; j++) { |
| 356 | 628423168 | sum[ALF_DIR_VERT] += grad[ALF_DIR_VERT]; | |
| 357 | 628423168 | sum[ALF_DIR_HORZ] += grad[ALF_DIR_HORZ]; | |
| 358 | 628423168 | sum[ALF_DIR_DIGA0] += grad[ALF_DIR_DIGA0]; | |
| 359 | 628423168 | sum[ALF_DIR_DIGA1] += grad[ALF_DIR_DIGA1]; | |
| 360 | 628423168 | grad += ALF_NUM_DIR; | |
| 361 | } | ||
| 362 | 157105792 | grad += gstride - size * ALF_NUM_DIR; | |
| 363 | } | ||
| 364 | 39821552 | FUNC(alf_get_idx)(class_idx, transpose_idx, sum, ac); | |
| 365 | |||
| 366 | 39821552 | class_idx++; | |
| 367 | 39821552 | transpose_idx++; | |
| 368 | } | ||
| 369 | } | ||
| 370 | |||
| 371 | 46198 | } | |
| 372 | |||
| 373 | 41590 | static void FUNC(alf_recon_coeff_and_clip)(int16_t *coeff, int16_t *clip, | |
| 374 | const int *class_idx, const int *transpose_idx, const int size, | ||
| 375 | const int16_t *coeff_set, const uint8_t *clip_idx_set, const uint8_t *class_to_filt) | ||
| 376 | { | ||
| 377 | const static int index[][ALF_NUM_COEFF_LUMA] = { | ||
| 378 | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, | ||
| 379 | { 9, 4, 10, 8, 1, 5, 11, 7, 3, 0, 2, 6 }, | ||
| 380 | { 0, 3, 2, 1, 8, 7, 6, 5, 4, 9, 10, 11 }, | ||
| 381 | { 9, 8, 10, 4, 3, 7, 11, 5, 1, 0, 2, 6 }, | ||
| 382 | }; | ||
| 383 | |||
| 384 | 41590 | const int16_t clip_set[] = { | |
| 385 | 1 << BIT_DEPTH, 1 << (BIT_DEPTH - 3), 1 << (BIT_DEPTH - 5), 1 << (BIT_DEPTH - 7) | ||
| 386 | }; | ||
| 387 | |||
| 388 |
2/2✓ Branch 0 taken 19244920 times.
✓ Branch 1 taken 20795 times.
|
38531430 | for (int i = 0; i < size; i++) { |
| 389 | 38489840 | const int16_t *src_coeff = coeff_set + class_to_filt[class_idx[i]] * ALF_NUM_COEFF_LUMA; | |
| 390 | 38489840 | const uint8_t *clip_idx = clip_idx_set + class_idx[i] * ALF_NUM_COEFF_LUMA; | |
| 391 | |||
| 392 |
2/2✓ Branch 0 taken 230939040 times.
✓ Branch 1 taken 19244920 times.
|
500367920 | for (int j = 0; j < ALF_NUM_COEFF_LUMA; j++) { |
| 393 | 461878080 | const int idx = index[transpose_idx[i]][j]; | |
| 394 | 461878080 | *coeff++ = src_coeff[idx]; | |
| 395 | 461878080 | *clip++ = clip_set[clip_idx[idx]]; | |
| 396 | } | ||
| 397 | } | ||
| 398 | 41590 | } | |
| 399 | |||
| 400 | #undef ALF_DIR_HORZ | ||
| 401 | #undef ALF_DIR_VERT | ||
| 402 | #undef ALF_DIR_DIGA0 | ||
| 403 | #undef ALF_DIR_DIGA1 | ||
| 404 | |||
| 405 | // line zero | ||
| 406 | #define P7 pix[-8 * xstride] | ||
| 407 | #define P6 pix[-7 * xstride] | ||
| 408 | #define P5 pix[-6 * xstride] | ||
| 409 | #define P4 pix[-5 * xstride] | ||
| 410 | #define P3 pix[-4 * xstride] | ||
| 411 | #define P2 pix[-3 * xstride] | ||
| 412 | #define P1 pix[-2 * xstride] | ||
| 413 | #define P0 pix[-1 * xstride] | ||
| 414 | #define Q0 pix[0 * xstride] | ||
| 415 | #define Q1 pix[1 * xstride] | ||
| 416 | #define Q2 pix[2 * xstride] | ||
| 417 | #define Q3 pix[3 * xstride] | ||
| 418 | #define Q4 pix[4 * xstride] | ||
| 419 | #define Q5 pix[5 * xstride] | ||
| 420 | #define Q6 pix[6 * xstride] | ||
| 421 | #define Q7 pix[7 * xstride] | ||
| 422 | #define P(x) pix[(-(x)-1) * xstride] | ||
| 423 | #define Q(x) pix[(x) * xstride] | ||
| 424 | |||
| 425 | // line three. used only for deblocking decision | ||
| 426 | #define TP7 pix[-8 * xstride + 3 * ystride] | ||
| 427 | #define TP6 pix[-7 * xstride + 3 * ystride] | ||
| 428 | #define TP5 pix[-6 * xstride + 3 * ystride] | ||
| 429 | #define TP4 pix[-5 * xstride + 3 * ystride] | ||
| 430 | #define TP3 pix[-4 * xstride + 3 * ystride] | ||
| 431 | #define TP2 pix[-3 * xstride + 3 * ystride] | ||
| 432 | #define TP1 pix[-2 * xstride + 3 * ystride] | ||
| 433 | #define TP0 pix[-1 * xstride + 3 * ystride] | ||
| 434 | #define TQ0 pix[0 * xstride + 3 * ystride] | ||
| 435 | #define TQ1 pix[1 * xstride + 3 * ystride] | ||
| 436 | #define TQ2 pix[2 * xstride + 3 * ystride] | ||
| 437 | #define TQ3 pix[3 * xstride + 3 * ystride] | ||
| 438 | #define TQ4 pix[4 * xstride + 3 * ystride] | ||
| 439 | #define TQ5 pix[5 * xstride + 3 * ystride] | ||
| 440 | #define TQ6 pix[6 * xstride + 3 * ystride] | ||
| 441 | #define TQ7 pix[7 * xstride + 3 * ystride] | ||
| 442 | #define TP(x) pix[(-(x)-1) * xstride + 3 * ystride] | ||
| 443 | #define TQ(x) pix[(x) * xstride + 3 * ystride] | ||
| 444 | |||
| 445 | #define FP3 pix[-4 * xstride + 1 * ystride] | ||
| 446 | #define FP2 pix[-3 * xstride + 1 * ystride] | ||
| 447 | #define FP1 pix[-2 * xstride + 1 * ystride] | ||
| 448 | #define FP0 pix[-1 * xstride + 1 * ystride] | ||
| 449 | #define FQ0 pix[0 * xstride + 1 * ystride] | ||
| 450 | #define FQ1 pix[1 * xstride + 1 * ystride] | ||
| 451 | #define FQ2 pix[2 * xstride + 1 * ystride] | ||
| 452 | #define FQ3 pix[3 * xstride + 1 * ystride] | ||
| 453 | |||
| 454 | #include "libavcodec/h26x/h2656_deblock_template.c" | ||
| 455 | |||
| 456 | 1754894 | static void FUNC(loop_filter_luma_large)(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, const int32_t tc, | |
| 457 | const uint8_t no_p, const uint8_t no_q, const uint8_t max_len_p, const uint8_t max_len_q) | ||
| 458 | { | ||
| 459 |
2/2✓ Branch 0 taken 3509788 times.
✓ Branch 1 taken 877447 times.
|
8774470 | for (int d = 0; d < 4; d++) { |
| 460 | 7019576 | const int p6 = P6; | |
| 461 | 7019576 | const int p5 = P5; | |
| 462 | 7019576 | const int p4 = P4; | |
| 463 | 7019576 | const int p3 = P3; | |
| 464 | 7019576 | const int p2 = P2; | |
| 465 | 7019576 | const int p1 = P1; | |
| 466 | 7019576 | const int p0 = P0; | |
| 467 | 7019576 | const int q0 = Q0; | |
| 468 | 7019576 | const int q1 = Q1; | |
| 469 | 7019576 | const int q2 = Q2; | |
| 470 | 7019576 | const int q3 = Q3; | |
| 471 | 7019576 | const int q4 = Q4; | |
| 472 | 7019576 | const int q5 = Q5; | |
| 473 | 7019576 | const int q6 = Q6; | |
| 474 | int m; | ||
| 475 |
4/4✓ Branch 0 taken 540184 times.
✓ Branch 1 taken 2969604 times.
✓ Branch 2 taken 323984 times.
✓ Branch 3 taken 216200 times.
|
7019576 | if (max_len_p == 5 && max_len_q == 5) |
| 476 | 647968 | m = (p4 + p3 + 2 * (p2 + p1 + p0 + q0 + q1 + q2) + q3 + q4 + 8) >> 4; | |
| 477 |
2/2✓ Branch 0 taken 1501248 times.
✓ Branch 1 taken 1684556 times.
|
6371608 | else if (max_len_p == max_len_q) |
| 478 | 3002496 | m = (p6 + p5 + p4 + p3 + p2 + p1 + 2 * (p0 + q0) + q1 + q2 + q3 + q4 + q5 + q6 + 8) >> 4; | |
| 479 |
2/2✓ Branch 0 taken 314888 times.
✓ Branch 1 taken 1369668 times.
|
3369112 | else if (max_len_p + max_len_q == 12) |
| 480 | 629776 | m = (p5 + p4 + p3 + p2 + 2 * (p1 + p0 + q0 + q1) + q2 + q3 + q4 + q5 + 8) >> 4; | |
| 481 |
2/2✓ Branch 0 taken 305916 times.
✓ Branch 1 taken 1063752 times.
|
2739336 | else if (max_len_p + max_len_q == 8) |
| 482 | 611832 | m = (p3 + p2 + p1 + p0 + q0 + q1 + q2 + q3 + 4) >> 3; | |
| 483 |
2/2✓ Branch 0 taken 759784 times.
✓ Branch 1 taken 303968 times.
|
2127504 | else if (max_len_q == 7) |
| 484 | 1519568 | m = (2 * (p2 + p1 + p0 + q0) + p0 + p1 + q1 + q2 + q3 + q4 + q5 + q6 + 8) >> 4; | |
| 485 | else | ||
| 486 | 607936 | m = (p6 + p5 + p4 + p3 + p2 + p1 + 2 * (q2 + q1 + q0 + p0) + q0 + q1 + 8) >> 4; | |
| 487 |
2/2✓ Branch 0 taken 3500924 times.
✓ Branch 1 taken 8864 times.
|
7019576 | if (!no_p) { |
| 488 | 7001848 | const int refp = (P(max_len_p) + P(max_len_p - 1) + 1) >> 1; | |
| 489 |
2/2✓ Branch 0 taken 999616 times.
✓ Branch 1 taken 2501308 times.
|
7001848 | if (max_len_p == 3) { |
| 490 | 1999232 | P0 = p0 + av_clip(((m * 53 + refp * 11 + 32) >> 6) - p0, -(tc * 6 >> 1), (tc * 6 >> 1)); | |
| 491 | 1999232 | P1 = p1 + av_clip(((m * 32 + refp * 32 + 32) >> 6) - p1, -(tc * 4 >> 1), (tc * 4 >> 1)); | |
| 492 | 1999232 | P2 = p2 + av_clip(((m * 11 + refp * 53 + 32) >> 6) - p2, -(tc * 2 >> 1), (tc * 2 >> 1)); | |
| 493 |
2/2✓ Branch 0 taken 540184 times.
✓ Branch 1 taken 1961124 times.
|
5002616 | } else if (max_len_p == 5) { |
| 494 | 1080368 | P0 = p0 + av_clip(((m * 58 + refp * 6 + 32) >> 6) - p0, -(tc * 6 >> 1), (tc * 6 >> 1)); | |
| 495 | 1080368 | P1 = p1 + av_clip(((m * 45 + refp * 19 + 32) >> 6) - p1, -(tc * 5 >> 1), (tc * 5 >> 1)); | |
| 496 | 1080368 | P2 = p2 + av_clip(((m * 32 + refp * 32 + 32) >> 6) - p2, -(tc * 4 >> 1), (tc * 4 >> 1)); | |
| 497 | 1080368 | P3 = p3 + av_clip(((m * 19 + refp * 45 + 32) >> 6) - p3, -(tc * 3 >> 1), (tc * 3 >> 1)); | |
| 498 | 1080368 | P4 = p4 + av_clip(((m * 6 + refp * 58 + 32) >> 6) - p4, -(tc * 2 >> 1), (tc * 2 >> 1)); | |
| 499 | } else { | ||
| 500 | 3922248 | P0 = p0 + av_clip(((m * 59 + refp * 5 + 32) >> 6) - p0, -(tc * 6 >> 1), (tc * 6 >> 1)); | |
| 501 | 3922248 | P1 = p1 + av_clip(((m * 50 + refp * 14 + 32) >> 6) - p1, -(tc * 5 >> 1), (tc * 5 >> 1)); | |
| 502 | 3922248 | P2 = p2 + av_clip(((m * 41 + refp * 23 + 32) >> 6) - p2, -(tc * 4 >> 1), (tc * 4 >> 1)); | |
| 503 | 3922248 | P3 = p3 + av_clip(((m * 32 + refp * 32 + 32) >> 6) - p3, -(tc * 3 >> 1), (tc * 3 >> 1)); | |
| 504 | 3922248 | P4 = p4 + av_clip(((m * 23 + refp * 41 + 32) >> 6) - p4, -(tc * 2 >> 1), (tc * 2 >> 1)); | |
| 505 | 3922248 | P5 = p5 + av_clip(((m * 14 + refp * 50 + 32) >> 6) - p5, -(tc * 1 >> 1), (tc * 1 >> 1)); | |
| 506 | 3922248 | P6 = p6 + av_clip(((m * 5 + refp * 59 + 32) >> 6) - p6, -(tc * 1 >> 1), (tc * 1 >> 1)); | |
| 507 | } | ||
| 508 | } | ||
| 509 |
2/2✓ Branch 0 taken 3503332 times.
✓ Branch 1 taken 6456 times.
|
7019576 | if (!no_q) { |
| 510 | 7006664 | const int refq = (Q(max_len_q) + Q(max_len_q - 1) + 1) >> 1; | |
| 511 |
2/2✓ Branch 0 taken 367108 times.
✓ Branch 1 taken 3136224 times.
|
7006664 | if (max_len_q == 3) { |
| 512 | 734216 | Q0 = q0 + av_clip(((m * 53 + refq * 11 + 32) >> 6) - q0, -(tc * 6 >> 1), (tc * 6 >> 1)); | |
| 513 | 734216 | Q1 = q1 + av_clip(((m * 32 + refq * 32 + 32) >> 6) - q1, -(tc * 4 >> 1), (tc * 4 >> 1)); | |
| 514 | 734216 | Q2 = q2 + av_clip(((m * 11 + refq * 53 + 32) >> 6) - q2, -(tc * 2 >> 1), (tc * 2 >> 1)); | |
| 515 |
2/2✓ Branch 0 taken 728588 times.
✓ Branch 1 taken 2407636 times.
|
6272448 | } else if (max_len_q == 5) { |
| 516 | 1457176 | Q0 = q0 + av_clip(((m * 58 + refq * 6 + 32) >> 6) - q0, -(tc * 6 >> 1), (tc * 6 >> 1)); | |
| 517 | 1457176 | Q1 = q1 + av_clip(((m * 45 + refq * 19 + 32) >> 6) - q1, -(tc * 5 >> 1), (tc * 5 >> 1)); | |
| 518 | 1457176 | Q2 = q2 + av_clip(((m * 32 + refq * 32 + 32) >> 6) - q2, -(tc * 4 >> 1), (tc * 4 >> 1)); | |
| 519 | 1457176 | Q3 = q3 + av_clip(((m * 19 + refq * 45 + 32) >> 6) - q3, -(tc * 3 >> 1), (tc * 3 >> 1)); | |
| 520 | 1457176 | Q4 = q4 + av_clip(((m * 6 + refq * 58 + 32) >> 6) - q4, -(tc * 2 >> 1), (tc * 2 >> 1)); | |
| 521 | } else { | ||
| 522 | 4815272 | Q0 = q0 + av_clip(((m * 59 + refq * 5 + 32) >> 6) - q0, -(tc * 6 >> 1), (tc * 6 >> 1)); | |
| 523 | 4815272 | Q1 = q1 + av_clip(((m * 50 + refq * 14 + 32) >> 6) - q1, -(tc * 5 >> 1), (tc * 5 >> 1)); | |
| 524 | 4815272 | Q2 = q2 + av_clip(((m * 41 + refq * 23 + 32) >> 6) - q2, -(tc * 4 >> 1), (tc * 4 >> 1)); | |
| 525 | 4815272 | Q3 = q3 + av_clip(((m * 32 + refq * 32 + 32) >> 6) - q3, -(tc * 3 >> 1), (tc * 3 >> 1)); | |
| 526 | 4815272 | Q4 = q4 + av_clip(((m * 23 + refq * 41 + 32) >> 6) - q4, -(tc * 2 >> 1), (tc * 2 >> 1)); | |
| 527 | 4815272 | Q5 = q5 + av_clip(((m * 14 + refq * 50 + 32) >> 6) - q5, -(tc * 1 >> 1), (tc * 1 >> 1)); | |
| 528 | 4815272 | Q6 = q6 + av_clip(((m * 5 + refq * 59 + 32) >> 6) - q6, -(tc * 1 >> 1), (tc * 1 >> 1)); | |
| 529 | } | ||
| 530 | |||
| 531 | } | ||
| 532 | 7019576 | pix += ystride; | |
| 533 | } | ||
| 534 | 1754894 | } | |
| 535 | |||
| 536 | 8164108 | static void FUNC(vvc_loop_filter_luma)(uint8_t* _pix, ptrdiff_t _xstride, ptrdiff_t _ystride, | |
| 537 | const int32_t *_beta, const int32_t *_tc, const uint8_t *_no_p, const uint8_t *_no_q, | ||
| 538 | const uint8_t *_max_len_p, const uint8_t *_max_len_q, const int hor_ctu_edge) | ||
| 539 | { | ||
| 540 | 8164108 | const ptrdiff_t xstride = _xstride / sizeof(pixel); | |
| 541 | 8164108 | const ptrdiff_t ystride = _ystride / sizeof(pixel); | |
| 542 | |||
| 543 |
2/2✓ Branch 0 taken 8164108 times.
✓ Branch 1 taken 4082054 times.
|
24492324 | for (int i = 0; i < 2; i++) { |
| 544 | #if BIT_DEPTH < 10 | ||
| 545 | 179908 | const int tc = (_tc[i] + (1 << (9 - BIT_DEPTH))) >> (10 - BIT_DEPTH); | |
| 546 | #else | ||
| 547 | 16148308 | const int tc = _tc[i] << (BIT_DEPTH - 10); | |
| 548 | #endif | ||
| 549 |
2/2✓ Branch 0 taken 7925491 times.
✓ Branch 1 taken 238617 times.
|
16328216 | if (tc) { |
| 550 | 15850982 | pixel* pix = (pixel*)_pix + i * 4 * ystride; | |
| 551 | 15850982 | const int dp0 = abs(P2 - 2 * P1 + P0); | |
| 552 | 15850982 | const int dq0 = abs(Q2 - 2 * Q1 + Q0); | |
| 553 | 15850982 | const int dp3 = abs(TP2 - 2 * TP1 + TP0); | |
| 554 | 15850982 | const int dq3 = abs(TQ2 - 2 * TQ1 + TQ0); | |
| 555 | 15850982 | const int d0 = dp0 + dq0; | |
| 556 | 15850982 | const int d3 = dp3 + dq3; | |
| 557 | 15850982 | const int tc25 = ((tc * 5 + 1) >> 1); | |
| 558 | |||
| 559 | 15850982 | const int no_p = _no_p[i]; | |
| 560 | 15850982 | const int no_q = _no_q[i]; | |
| 561 | |||
| 562 | 15850982 | int max_len_p = _max_len_p[i]; | |
| 563 | 15850982 | int max_len_q = _max_len_q[i]; | |
| 564 | |||
| 565 |
4/4✓ Branch 0 taken 2268621 times.
✓ Branch 1 taken 5656870 times.
✓ Branch 2 taken 1819421 times.
✓ Branch 3 taken 449200 times.
|
15850982 | const int large_p = (max_len_p > 3 && !hor_ctu_edge); |
| 566 | 15850982 | const int large_q = max_len_q > 3; | |
| 567 | |||
| 568 | 15850982 | const int beta = _beta[i] << BIT_DEPTH - 8; | |
| 569 | 15850982 | const int beta_3 = beta >> 3; | |
| 570 | 15850982 | const int beta_2 = beta >> 2; | |
| 571 | |||
| 572 |
4/4✓ Branch 0 taken 6106070 times.
✓ Branch 1 taken 1819421 times.
✓ Branch 2 taken 872905 times.
✓ Branch 3 taken 5233165 times.
|
15850982 | if (large_p || large_q) { |
| 573 |
2/2✓ Branch 0 taken 1819421 times.
✓ Branch 1 taken 872905 times.
|
5384652 | const int dp0l = large_p ? ((dp0 + abs(P5 - 2 * P4 + P3) + 1) >> 1) : dp0; |
| 574 |
2/2✓ Branch 0 taken 2247461 times.
✓ Branch 1 taken 444865 times.
|
5384652 | const int dq0l = large_q ? ((dq0 + abs(Q5 - 2 * Q4 + Q3) + 1) >> 1) : dq0; |
| 575 |
2/2✓ Branch 0 taken 1819421 times.
✓ Branch 1 taken 872905 times.
|
5384652 | const int dp3l = large_p ? ((dp3 + abs(TP5 - 2 * TP4 + TP3) + 1) >> 1) : dp3; |
| 576 |
2/2✓ Branch 0 taken 2247461 times.
✓ Branch 1 taken 444865 times.
|
5384652 | const int dq3l = large_q ? ((dq3 + abs(TQ5 - 2 * TQ4 + TQ3) + 1) >> 1) : dq3; |
| 577 | 5384652 | const int d0l = dp0l + dq0l; | |
| 578 | 5384652 | const int d3l = dp3l + dq3l; | |
| 579 | 5384652 | const int beta53 = beta * 3 >> 5; | |
| 580 | 5384652 | const int beta_4 = beta >> 4; | |
| 581 |
2/2✓ Branch 0 taken 1819421 times.
✓ Branch 1 taken 872905 times.
|
5384652 | max_len_p = large_p ? max_len_p : 3; |
| 582 |
2/2✓ Branch 0 taken 2247461 times.
✓ Branch 1 taken 444865 times.
|
5384652 | max_len_q = large_q ? max_len_q : 3; |
| 583 | |||
| 584 |
2/2✓ Branch 0 taken 2463787 times.
✓ Branch 1 taken 228539 times.
|
5384652 | if (d0l + d3l < beta) { |
| 585 |
2/2✓ Branch 0 taken 1361389 times.
✓ Branch 1 taken 1102398 times.
|
4927574 | const int sp0l = abs(P3 - P0) + (max_len_p == 7 ? abs(P7 - P6 - P5 + P4) : 0); |
| 586 |
2/2✓ Branch 0 taken 1667026 times.
✓ Branch 1 taken 796761 times.
|
4927574 | const int sq0l = abs(Q0 - Q3) + (max_len_q == 7 ? abs(Q4 - Q5 - Q6 + Q7) : 0); |
| 587 |
2/2✓ Branch 0 taken 1361389 times.
✓ Branch 1 taken 1102398 times.
|
4927574 | const int sp3l = abs(TP3 - TP0) + (max_len_p == 7 ? abs(TP7 - TP6 - TP5 + TP4) : 0); |
| 588 |
2/2✓ Branch 0 taken 1667026 times.
✓ Branch 1 taken 796761 times.
|
4927574 | const int sq3l = abs(TQ0 - TQ3) + (max_len_q == 7 ? abs(TQ4 - TQ5 - TQ6 + TQ7) : 0); |
| 589 |
2/2✓ Branch 0 taken 1675003 times.
✓ Branch 1 taken 788784 times.
|
4927574 | const int sp0 = large_p ? ((sp0l + abs(P3 - P(max_len_p)) + 1) >> 1) : sp0l; |
| 590 |
2/2✓ Branch 0 taken 1675003 times.
✓ Branch 1 taken 788784 times.
|
4927574 | const int sp3 = large_p ? ((sp3l + abs(TP3 - TP(max_len_p)) + 1) >> 1) : sp3l; |
| 591 |
2/2✓ Branch 0 taken 2073501 times.
✓ Branch 1 taken 390286 times.
|
4927574 | const int sq0 = large_q ? ((sq0l + abs(Q3 - Q(max_len_q)) + 1) >> 1) : sq0l; |
| 592 |
2/2✓ Branch 0 taken 2073501 times.
✓ Branch 1 taken 390286 times.
|
4927574 | const int sq3 = large_q ? ((sq3l + abs(TQ3 - TQ(max_len_q)) + 1) >> 1) : sq3l; |
| 593 |
4/4✓ Branch 0 taken 1074537 times.
✓ Branch 1 taken 1389250 times.
✓ Branch 2 taken 1071685 times.
✓ Branch 3 taken 2852 times.
|
4927574 | if (sp0 + sq0 < beta53 && abs(P0 - Q0) < tc25 && |
| 594 |
4/4✓ Branch 0 taken 957463 times.
✓ Branch 1 taken 114222 times.
✓ Branch 2 taken 956543 times.
✓ Branch 3 taken 920 times.
|
2143370 | sp3 + sq3 < beta53 && abs(TP0 - TQ0) < tc25 && |
| 595 |
4/4✓ Branch 0 taken 903504 times.
✓ Branch 1 taken 53039 times.
✓ Branch 2 taken 877447 times.
✓ Branch 3 taken 26057 times.
|
1913086 | (d0l << 1) < beta_4 && (d3l << 1) < beta_4) { |
| 596 | 1754894 | FUNC(loop_filter_luma_large)(pix, xstride, ystride, tc, no_p, no_q, max_len_p, max_len_q); | |
| 597 | 1754894 | continue; | |
| 598 | } | ||
| 599 | } | ||
| 600 | } | ||
| 601 |
2/2✓ Branch 0 taken 4983726 times.
✓ Branch 1 taken 2064318 times.
|
14096088 | if (d0 + d3 < beta) { |
| 602 |
3/4✓ Branch 0 taken 3496295 times.
✓ Branch 1 taken 1487431 times.
✓ Branch 2 taken 3496295 times.
✗ Branch 3 not taken.
|
9967452 | if (max_len_p > 2 && max_len_q > 2 && |
| 603 |
4/4✓ Branch 0 taken 1211437 times.
✓ Branch 1 taken 2284858 times.
✓ Branch 2 taken 1197174 times.
✓ Branch 3 taken 14263 times.
|
6992590 | abs(P3 - P0) + abs(Q3 - Q0) < beta_3 && abs(P0 - Q0) < tc25 && |
| 604 |
4/4✓ Branch 0 taken 922116 times.
✓ Branch 1 taken 275058 times.
✓ Branch 2 taken 918694 times.
✓ Branch 3 taken 3422 times.
|
2394348 | abs(TP3 - TP0) + abs(TQ3 - TQ0) < beta_3 && abs(TP0 - TQ0) < tc25 && |
| 605 |
4/4✓ Branch 0 taken 901581 times.
✓ Branch 1 taken 17113 times.
✓ Branch 2 taken 894405 times.
✓ Branch 3 taken 7176 times.
|
1837388 | (d0 << 1) < beta_2 && (d3 << 1) < beta_2) { |
| 606 | 1788810 | FUNC(loop_filter_luma_strong)(pix, xstride, ystride, tc, tc << 1, tc * 3, no_p, no_q); | |
| 607 | } else { | ||
| 608 | 8178642 | int nd_p = 1; | |
| 609 | 8178642 | int nd_q = 1; | |
| 610 |
3/4✓ Branch 0 taken 2769396 times.
✓ Branch 1 taken 1319925 times.
✓ Branch 2 taken 2769396 times.
✗ Branch 3 not taken.
|
8178642 | if (max_len_p > 1 && max_len_q > 1) { |
| 611 |
2/2✓ Branch 0 taken 2224731 times.
✓ Branch 1 taken 544665 times.
|
5538792 | if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3)) |
| 612 | 4449462 | nd_p = 2; | |
| 613 |
2/2✓ Branch 0 taken 2133765 times.
✓ Branch 1 taken 635631 times.
|
5538792 | if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3)) |
| 614 | 4267530 | nd_q = 2; | |
| 615 | } | ||
| 616 | 8178642 | FUNC(loop_filter_luma_weak)(pix, xstride, ystride, tc, beta, no_p, no_q, nd_p, nd_q); | |
| 617 | } | ||
| 618 | } | ||
| 619 | } | ||
| 620 | } | ||
| 621 | 8164108 | } | |
| 622 | |||
| 623 | 3397718 | static void FUNC(loop_filter_chroma_strong)(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, | |
| 624 | const int size, const int32_t tc, const uint8_t no_p, const uint8_t no_q) | ||
| 625 | { | ||
| 626 |
2/2✓ Branch 0 taken 3910556 times.
✓ Branch 1 taken 1698859 times.
|
11218830 | for (int d = 0; d < size; d++) { |
| 627 | 7821112 | const int p3 = P3; | |
| 628 | 7821112 | const int p2 = P2; | |
| 629 | 7821112 | const int p1 = P1; | |
| 630 | 7821112 | const int p0 = P0; | |
| 631 | 7821112 | const int q0 = Q0; | |
| 632 | 7821112 | const int q1 = Q1; | |
| 633 | 7821112 | const int q2 = Q2; | |
| 634 | 7821112 | const int q3 = Q3; | |
| 635 |
2/2✓ Branch 0 taken 3896624 times.
✓ Branch 1 taken 13932 times.
|
7821112 | if (!no_p) { |
| 636 | 7793248 | P0 = av_clip((p3 + p2 + p1 + 2 * p0 + q0 + q1 + q2 + 4) >> 3, p0 - tc, p0 + tc); | |
| 637 | 7793248 | P1 = av_clip((2 * p3 + p2 + 2 * p1 + p0 + q0 + q1 + 4) >> 3, p1 - tc, p1 + tc); | |
| 638 | 7793248 | P2 = av_clip((3 * p3 + 2 * p2 + p1 + p0 + q0 + 4) >> 3, p2 - tc, p2 + tc ); | |
| 639 | } | ||
| 640 |
2/2✓ Branch 0 taken 3901004 times.
✓ Branch 1 taken 9552 times.
|
7821112 | if (!no_q) { |
| 641 | 7802008 | Q0 = av_clip((p2 + p1 + p0 + 2 * q0 + q1 + q2 + q3 + 4) >> 3, q0 - tc, q0 + tc); | |
| 642 | 7802008 | Q1 = av_clip((p1 + p0 + q0 + 2 * q1 + q2 + 2 * q3 + 4) >> 3, q1 - tc, q1 + tc); | |
| 643 | 7802008 | Q2 = av_clip((p0 + q0 + q1 + 2 * q2 + 3 * q3 + 4) >> 3, q2 - tc, q2 + tc); | |
| 644 | } | ||
| 645 | 7821112 | pix += ystride; | |
| 646 | } | ||
| 647 | 3397718 | } | |
| 648 | |||
| 649 | 596624 | static void FUNC(loop_filter_chroma_strong_one_side)(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, | |
| 650 | const int size, const int32_t tc, const uint8_t no_p, const uint8_t no_q) | ||
| 651 | { | ||
| 652 |
2/2✓ Branch 0 taken 662024 times.
✓ Branch 1 taken 298312 times.
|
1920672 | for (int d = 0; d < size; d++) { |
| 653 | 1324048 | const int p1 = P1; | |
| 654 | 1324048 | const int p0 = P0; | |
| 655 | 1324048 | const int q0 = Q0; | |
| 656 | 1324048 | const int q1 = Q1; | |
| 657 | 1324048 | const int q2 = Q2; | |
| 658 | 1324048 | const int q3 = Q3; | |
| 659 |
2/2✓ Branch 0 taken 661048 times.
✓ Branch 1 taken 976 times.
|
1324048 | if (!no_p) { |
| 660 | 1322096 | P0 = av_clip((3 * p1 + 2 * p0 + q0 + q1 + q2 + 4) >> 3, p0 - tc, p0 + tc); | |
| 661 | } | ||
| 662 |
2/2✓ Branch 0 taken 660708 times.
✓ Branch 1 taken 1316 times.
|
1324048 | if (!no_q) { |
| 663 | 1321416 | Q0 = av_clip((2 * p1 + p0 + 2 * q0 + q1 + q2 + q3 + 4) >> 3, q0 - tc, q0 + tc); | |
| 664 | 1321416 | Q1 = av_clip((p1 + p0 + q0 + 2 * q1 + q2 + 2 * q3 + 4) >> 3, q1 - tc, q1 + tc); | |
| 665 | 1321416 | Q2 = av_clip((p0 + q0 + q1 + 2 * q2 + 3 * q3 + 4) >> 3, q2 - tc, q2 + tc); | |
| 666 | } | ||
| 667 | 1324048 | pix += ystride; | |
| 668 | } | ||
| 669 | 596624 | } | |
| 670 | |||
| 671 | 2845462 | static void FUNC(vvc_loop_filter_chroma)(uint8_t *_pix, const ptrdiff_t _xstride, const ptrdiff_t _ystride, | |
| 672 | const int32_t *_beta, const int32_t *_tc, const uint8_t *_no_p, const uint8_t *_no_q, | ||
| 673 | const uint8_t *_max_len_p, const uint8_t *_max_len_q, const int shift) | ||
| 674 | { | ||
| 675 | 2845462 | const ptrdiff_t xstride = _xstride / sizeof(pixel); | |
| 676 | 2845462 | const ptrdiff_t ystride = _ystride / sizeof(pixel); | |
| 677 |
2/2✓ Branch 0 taken 1006908 times.
✓ Branch 1 taken 415823 times.
|
2845462 | const int size = shift ? 2 : 4; |
| 678 | 2845462 | const int end = 8 / size; // 8 samples a loop | |
| 679 | |||
| 680 |
2/2✓ Branch 0 taken 4859278 times.
✓ Branch 1 taken 1422731 times.
|
12564018 | for (int i = 0; i < end; i++) { |
| 681 | #if BIT_DEPTH < 10 | ||
| 682 | 124656 | const int tc = (_tc[i] + (1 << (9 - BIT_DEPTH))) >> (10 - BIT_DEPTH); | |
| 683 | #else | ||
| 684 | 9593900 | const int tc = _tc[i] << (BIT_DEPTH - 10); | |
| 685 | #endif | ||
| 686 |
2/2✓ Branch 0 taken 4534158 times.
✓ Branch 1 taken 325120 times.
|
9718556 | if (tc) { |
| 687 | 9068316 | pixel *pix = (pixel *)_pix + i * size * ystride; | |
| 688 | 9068316 | const uint8_t no_p = _no_p[i]; | |
| 689 | 9068316 | const uint8_t no_q = _no_q[i]; | |
| 690 | |||
| 691 | 9068316 | const int beta = _beta[i] << (BIT_DEPTH - 8); | |
| 692 | 9068316 | const int beta_3 = beta >> 3; | |
| 693 | 9068316 | const int beta_2 = beta >> 2; | |
| 694 | |||
| 695 | 9068316 | const int tc25 = ((tc * 5 + 1) >> 1); | |
| 696 | |||
| 697 | 9068316 | uint8_t max_len_p = _max_len_p[i]; | |
| 698 | 9068316 | uint8_t max_len_q = _max_len_q[i]; | |
| 699 | |||
| 700 |
3/4✓ Branch 0 taken 4403742 times.
✓ Branch 1 taken 130416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4403742 times.
|
9068316 | if (!max_len_p || !max_len_q) |
| 701 | 260832 | continue; | |
| 702 | |||
| 703 |
2/2✓ Branch 0 taken 3150430 times.
✓ Branch 1 taken 1253312 times.
|
8807484 | if (max_len_q == 3){ |
| 704 |
2/2✓ Branch 0 taken 2533273 times.
✓ Branch 1 taken 617157 times.
|
6300860 | const int p1n = shift ? FP1 : TP1; |
| 705 |
4/4✓ Branch 0 taken 2772510 times.
✓ Branch 1 taken 377920 times.
✓ Branch 2 taken 2208801 times.
✓ Branch 3 taken 563709 times.
|
6300860 | const int p2n = max_len_p == 1 ? p1n : (shift ? FP2 : TP2); |
| 706 |
2/2✓ Branch 0 taken 2533273 times.
✓ Branch 1 taken 617157 times.
|
6300860 | const int p0n = shift ? FP0 : TP0; |
| 707 |
2/2✓ Branch 0 taken 2533273 times.
✓ Branch 1 taken 617157 times.
|
6300860 | const int q0n = shift ? FQ0 : TQ0; |
| 708 |
2/2✓ Branch 0 taken 2533273 times.
✓ Branch 1 taken 617157 times.
|
6300860 | const int q1n = shift ? FQ1 : TQ1; |
| 709 |
2/2✓ Branch 0 taken 2533273 times.
✓ Branch 1 taken 617157 times.
|
6300860 | const int q2n = shift ? FQ2 : TQ2; |
| 710 |
2/2✓ Branch 0 taken 377920 times.
✓ Branch 1 taken 2772510 times.
|
6300860 | const int p3 = max_len_p == 1 ? P1 : P3; |
| 711 |
2/2✓ Branch 0 taken 377920 times.
✓ Branch 1 taken 2772510 times.
|
6300860 | const int p2 = max_len_p == 1 ? P1 : P2; |
| 712 | 6300860 | const int p1 = P1; | |
| 713 | 6300860 | const int p0 = P0; | |
| 714 | 6300860 | const int dp0 = abs(p2 - 2 * p1 + p0); | |
| 715 | 6300860 | const int dq0 = abs(Q2 - 2 * Q1 + Q0); | |
| 716 | |||
| 717 | 6300860 | const int dp1 = abs(p2n - 2 * p1n + p0n); | |
| 718 | 6300860 | const int dq1 = abs(q2n - 2 * q1n + q0n); | |
| 719 | 6300860 | const int d0 = dp0 + dq0; | |
| 720 | 6300860 | const int d1 = dp1 + dq1; | |
| 721 | |||
| 722 |
2/2✓ Branch 0 taken 2842126 times.
✓ Branch 1 taken 308304 times.
|
6300860 | if (d0 + d1 < beta) { |
| 723 |
4/4✓ Branch 0 taken 2484716 times.
✓ Branch 1 taken 357410 times.
✓ Branch 2 taken 2053572 times.
✓ Branch 3 taken 431144 times.
|
5684252 | const int p3n = max_len_p == 1 ? p1n : (shift ? FP3 : TP3); |
| 724 |
2/2✓ Branch 0 taken 2363720 times.
✓ Branch 1 taken 478406 times.
|
5684252 | const int q3n = shift ? FQ3 : TQ3; |
| 725 |
4/4✓ Branch 0 taken 2525358 times.
✓ Branch 1 taken 316768 times.
✓ Branch 2 taken 2107228 times.
✓ Branch 3 taken 418130 times.
|
9898708 | const int dsam0 = (d0 << 1) < beta_2 && (abs(p3 - p0) + abs(Q0 - Q3) < beta_3) && |
| 726 |
2/2✓ Branch 0 taken 2079452 times.
✓ Branch 1 taken 27776 times.
|
4214456 | abs(p0 - Q0) < tc25; |
| 727 |
4/4✓ Branch 0 taken 2529227 times.
✓ Branch 1 taken 312899 times.
✓ Branch 2 taken 2111080 times.
✓ Branch 3 taken 418147 times.
|
9906412 | const int dsam1 = (d1 << 1) < beta_2 && (abs(p3n - p0n) + abs(q0n - q3n) < beta_3) && |
| 728 |
2/2✓ Branch 0 taken 2082815 times.
✓ Branch 1 taken 28265 times.
|
4222160 | abs(p0n - q0n) < tc25; |
| 729 |
4/4✓ Branch 0 taken 2079452 times.
✓ Branch 1 taken 762674 times.
✓ Branch 2 taken 82281 times.
✓ Branch 3 taken 1997171 times.
|
5684252 | if (!dsam0 || !dsam1) |
| 730 | 1689910 | max_len_p = max_len_q = 1; | |
| 731 | } else { | ||
| 732 | 616608 | max_len_p = max_len_q = 1; | |
| 733 | } | ||
| 734 | } | ||
| 735 | |||
| 736 |
3/4✓ Branch 0 taken 1698859 times.
✓ Branch 1 taken 2704883 times.
✓ Branch 2 taken 1698859 times.
✗ Branch 3 not taken.
|
8807484 | if (max_len_p == 3 && max_len_q == 3) |
| 737 | 3397718 | FUNC(loop_filter_chroma_strong)(pix, xstride, ystride, size, tc, no_p, no_q); | |
| 738 |
2/2✓ Branch 0 taken 298312 times.
✓ Branch 1 taken 2406571 times.
|
5409766 | else if (max_len_q == 3) |
| 739 | 596624 | FUNC(loop_filter_chroma_strong_one_side)(pix, xstride, ystride, size, tc, no_p, no_q); | |
| 740 | else | ||
| 741 | 4813142 | FUNC(loop_filter_chroma_weak)(pix, xstride, ystride, size, tc, no_p, no_q); | |
| 742 | } | ||
| 743 | } | ||
| 744 | 2845462 | } | |
| 745 | |||
| 746 | 1449156 | static void FUNC(vvc_h_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride, | |
| 747 | const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q, | ||
| 748 | const uint8_t *max_len_p, const uint8_t *max_len_q, int shift) | ||
| 749 | { | ||
| 750 | 1449156 | FUNC(vvc_loop_filter_chroma)(pix, stride, sizeof(pixel), beta, tc, | |
| 751 | no_p, no_q, max_len_p, max_len_q, shift); | ||
| 752 | 1449156 | } | |
| 753 | |||
| 754 | 1396306 | static void FUNC(vvc_v_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride, | |
| 755 | const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q, | ||
| 756 | const uint8_t *max_len_p, const uint8_t *max_len_q, int shift) | ||
| 757 | { | ||
| 758 | 1396306 | FUNC(vvc_loop_filter_chroma)(pix, sizeof(pixel), stride, beta, tc, | |
| 759 | no_p, no_q, max_len_p, max_len_q, shift); | ||
| 760 | 1396306 | } | |
| 761 | |||
| 762 | 4232790 | static void FUNC(vvc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride, | |
| 763 | const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q, | ||
| 764 | const uint8_t *max_len_p, const uint8_t *max_len_q, const int hor_ctu_edge) | ||
| 765 | { | ||
| 766 | 4232790 | FUNC(vvc_loop_filter_luma)(pix, stride, sizeof(pixel), beta, tc, | |
| 767 | no_p, no_q, max_len_p, max_len_q, hor_ctu_edge); | ||
| 768 | 4232790 | } | |
| 769 | |||
| 770 | 3931318 | static void FUNC(vvc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride, | |
| 771 | const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q, | ||
| 772 | const uint8_t *max_len_p, const uint8_t *max_len_q, const int hor_ctu_edge) | ||
| 773 | { | ||
| 774 | 3931318 | FUNC(vvc_loop_filter_luma)(pix, sizeof(pixel), stride, beta, tc, | |
| 775 | no_p, no_q, max_len_p, max_len_q, hor_ctu_edge); | ||
| 776 | 3931318 | } | |
| 777 | |||
| 778 | 943758 | static int FUNC(vvc_loop_ladf_level)(const uint8_t *_pix, const ptrdiff_t _xstride, const ptrdiff_t _ystride) | |
| 779 | { | ||
| 780 | 943758 | const pixel *pix = (pixel *)_pix; | |
| 781 | 943758 | const ptrdiff_t xstride = _xstride / sizeof(pixel); | |
| 782 | 943758 | const ptrdiff_t ystride = _ystride / sizeof(pixel); | |
| 783 | 943758 | return (P0 + TP0 + Q0 + TQ0) >> 2; | |
| 784 | } | ||
| 785 | |||
| 786 | 477242 | static int FUNC(vvc_h_loop_ladf_level)(const uint8_t *pix, ptrdiff_t stride) | |
| 787 | { | ||
| 788 | 477242 | return FUNC(vvc_loop_ladf_level)(pix, stride, sizeof(pixel)); | |
| 789 | } | ||
| 790 | |||
| 791 | 466516 | static int FUNC(vvc_v_loop_ladf_level)(const uint8_t *pix, ptrdiff_t stride) | |
| 792 | { | ||
| 793 | 466516 | return FUNC(vvc_loop_ladf_level)(pix, sizeof(pixel), stride); | |
| 794 | } | ||
| 795 | |||
| 796 | #undef P7 | ||
| 797 | #undef P6 | ||
| 798 | #undef P5 | ||
| 799 | #undef P4 | ||
| 800 | #undef P3 | ||
| 801 | #undef P2 | ||
| 802 | #undef P1 | ||
| 803 | #undef P0 | ||
| 804 | #undef Q0 | ||
| 805 | #undef Q1 | ||
| 806 | #undef Q2 | ||
| 807 | #undef Q3 | ||
| 808 | #undef Q4 | ||
| 809 | #undef Q5 | ||
| 810 | #undef Q6 | ||
| 811 | #undef Q7 | ||
| 812 | |||
| 813 | #undef TP7 | ||
| 814 | #undef TP6 | ||
| 815 | #undef TP5 | ||
| 816 | #undef TP4 | ||
| 817 | #undef TP3 | ||
| 818 | #undef TP2 | ||
| 819 | #undef TP1 | ||
| 820 | #undef TP0 | ||
| 821 | #undef TQ0 | ||
| 822 | #undef TQ1 | ||
| 823 | #undef TQ2 | ||
| 824 | #undef TQ3 | ||
| 825 | #undef TQ4 | ||
| 826 | #undef TQ5 | ||
| 827 | #undef TQ6 | ||
| 828 | #undef TQ7 | ||
| 829 | |||
| 830 | 3084 | static void FUNC(ff_vvc_lmcs_dsp_init)(VVCLMCSDSPContext *const lmcs) | |
| 831 | { | ||
| 832 | 3084 | lmcs->filter = FUNC(lmcs_filter_luma); | |
| 833 | 3084 | } | |
| 834 | |||
| 835 | 3084 | static void FUNC(ff_vvc_lf_dsp_init)(VVCLFDSPContext *const lf) | |
| 836 | { | ||
| 837 | 3084 | lf->ladf_level[0] = FUNC(vvc_h_loop_ladf_level); | |
| 838 | 3084 | lf->ladf_level[1] = FUNC(vvc_v_loop_ladf_level); | |
| 839 | 3084 | lf->filter_luma[0] = FUNC(vvc_h_loop_filter_luma); | |
| 840 | 3084 | lf->filter_luma[1] = FUNC(vvc_v_loop_filter_luma); | |
| 841 | 3084 | lf->filter_chroma[0] = FUNC(vvc_h_loop_filter_chroma); | |
| 842 | 3084 | lf->filter_chroma[1] = FUNC(vvc_v_loop_filter_chroma); | |
| 843 | 3084 | } | |
| 844 | |||
| 845 | 3084 | static void FUNC(ff_vvc_sao_dsp_init)(VVCSAODSPContext *const sao) | |
| 846 | { | ||
| 847 |
2/2✓ Branch 0 taken 13878 times.
✓ Branch 1 taken 1542 times.
|
30840 | for (int i = 0; i < FF_ARRAY_ELEMS(sao->band_filter); i++) |
| 848 | 27756 | sao->band_filter[i] = FUNC(sao_band_filter); | |
| 849 |
2/2✓ Branch 0 taken 13878 times.
✓ Branch 1 taken 1542 times.
|
30840 | for (int i = 0; i < FF_ARRAY_ELEMS(sao->edge_filter); i++) |
| 850 | 27756 | sao->edge_filter[i] = FUNC(sao_edge_filter); | |
| 851 | 3084 | sao->edge_restore[0] = FUNC(sao_edge_restore_0); | |
| 852 | 3084 | sao->edge_restore[1] = FUNC(sao_edge_restore_1); | |
| 853 | 3084 | } | |
| 854 | |||
| 855 | 3084 | static void FUNC(ff_vvc_alf_dsp_init)(VVCALFDSPContext *const alf) | |
| 856 | { | ||
| 857 | 3084 | alf->filter[LUMA] = FUNC(alf_filter_luma); | |
| 858 | 3084 | alf->filter[CHROMA] = FUNC(alf_filter_chroma); | |
| 859 | 3084 | alf->filter_cc = FUNC(alf_filter_cc); | |
| 860 | 3084 | alf->classify = FUNC(alf_classify); | |
| 861 | 3084 | alf->recon_coeff_and_clip = FUNC(alf_recon_coeff_and_clip); | |
| 862 | 3084 | } | |
| 863 |