| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * HEVC video decoder | ||
| 3 | * | ||
| 4 | * Copyright (C) 2012 - 2013 Guillaume Martres | ||
| 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/get_bits.h" | ||
| 24 | #include "hevcdec.h" | ||
| 25 | |||
| 26 | #include "libavcodec/bit_depth_template.c" | ||
| 27 | #include "dsp.h" | ||
| 28 | #include "libavcodec/h26x/h2656_sao_template.c" | ||
| 29 | #include "libavcodec/h26x/h2656_inter_template.c" | ||
| 30 | |||
| 31 | 74598 | static void FUNC(put_pcm)(uint8_t *_dst, ptrdiff_t stride, int width, int height, | |
| 32 | GetBitContext *gb, int pcm_bit_depth) | ||
| 33 | { | ||
| 34 | int x, y; | ||
| 35 | 74598 | pixel *dst = (pixel *)_dst; | |
| 36 | |||
| 37 | 74598 | stride /= sizeof(pixel); | |
| 38 | |||
| 39 |
2/2✓ Branch 0 taken 327424 times.
✓ Branch 1 taken 37299 times.
|
729446 | for (y = 0; y < height; y++) { |
| 40 |
2/2✓ Branch 0 taken 4382080 times.
✓ Branch 1 taken 327424 times.
|
9419008 | for (x = 0; x < width; x++) |
| 41 | 8764160 | dst[x] = get_bits(gb, pcm_bit_depth) << (BIT_DEPTH - pcm_bit_depth); | |
| 42 | 654848 | dst += stride; | |
| 43 | } | ||
| 44 | 74598 | } | |
| 45 | |||
| 46 | 32562878 | static av_always_inline void FUNC(add_residual)(uint8_t *restrict dst8, const int16_t *restrict res, | |
| 47 | ptrdiff_t stride, int size) | ||
| 48 | { | ||
| 49 | int x, y; | ||
| 50 | |||
| 51 |
2/2✓ Branch 0 taken 132583516 times.
✓ Branch 1 taken 16281439 times.
|
297729910 | for (y = 0; y < size; y++) { |
| 52 | 265167032 | pixel *restrict dst = (pixel *)dst8; | |
| 53 |
2/2✓ Branch 0 taken 1843659856 times.
✓ Branch 1 taken 132583516 times.
|
3952486744 | for (x = 0; x < size; x++) { |
| 54 | 3687319712 | dst[x] = av_clip_pixel(dst[x] + *res); | |
| 55 | 3687319712 | res++; | |
| 56 | } | ||
| 57 | 265167032 | dst8 += stride; | |
| 58 | } | ||
| 59 | 32562878 | } | |
| 60 | |||
| 61 | 17752290 | static void FUNC(add_residual4x4)(uint8_t *_dst, const int16_t *res, | |
| 62 | ptrdiff_t stride) | ||
| 63 | { | ||
| 64 | 17752290 | FUNC(add_residual)(_dst, res, stride, 4); | |
| 65 | 17752290 | } | |
| 66 | |||
| 67 | 8680866 | static void FUNC(add_residual8x8)(uint8_t *_dst, const int16_t *res, | |
| 68 | ptrdiff_t stride) | ||
| 69 | { | ||
| 70 | 8680866 | FUNC(add_residual)(_dst, res, stride, 8); | |
| 71 | 8680866 | } | |
| 72 | |||
| 73 | 4465010 | static void FUNC(add_residual16x16)(uint8_t *_dst, const int16_t *res, | |
| 74 | ptrdiff_t stride) | ||
| 75 | { | ||
| 76 | 4465010 | FUNC(add_residual)(_dst, res, stride, 16); | |
| 77 | 4465010 | } | |
| 78 | |||
| 79 | 1664712 | static void FUNC(add_residual32x32)(uint8_t *_dst, const int16_t *res, | |
| 80 | ptrdiff_t stride) | ||
| 81 | { | ||
| 82 | 1664712 | FUNC(add_residual)(_dst, res, stride, 32); | |
| 83 | 1664712 | } | |
| 84 | |||
| 85 | 54126 | static void FUNC(transform_rdpcm)(int16_t *_coeffs, int16_t log2_size, int mode) | |
| 86 | { | ||
| 87 | 54126 | int16_t *coeffs = (int16_t *) _coeffs; | |
| 88 | int x, y; | ||
| 89 | 54126 | int size = 1 << log2_size; | |
| 90 | |||
| 91 |
2/2✓ Branch 0 taken 9989 times.
✓ Branch 1 taken 17074 times.
|
54126 | if (mode) { |
| 92 | 19978 | coeffs += size; | |
| 93 |
2/2✓ Branch 0 taken 56315 times.
✓ Branch 1 taken 9989 times.
|
132608 | for (y = 0; y < size - 1; y++) { |
| 94 |
2/2✓ Branch 0 taken 523168 times.
✓ Branch 1 taken 56315 times.
|
1158966 | for (x = 0; x < size; x++) |
| 95 | 1046336 | coeffs[x] += coeffs[x - size]; | |
| 96 | 112630 | coeffs += size; | |
| 97 | } | ||
| 98 | } else { | ||
| 99 |
2/2✓ Branch 0 taken 124352 times.
✓ Branch 1 taken 17074 times.
|
282852 | for (y = 0; y < size; y++) { |
| 100 |
2/2✓ Branch 0 taken 1049312 times.
✓ Branch 1 taken 124352 times.
|
2347328 | for (x = 1; x < size; x++) |
| 101 | 2098624 | coeffs[x] += coeffs[x - 1]; | |
| 102 | 248704 | coeffs += size; | |
| 103 | } | ||
| 104 | } | ||
| 105 | 54126 | } | |
| 106 | |||
| 107 | /** | ||
| 108 | * HEVC transform dequantization (ITU-T H.265 8.6.3) | ||
| 109 | * | ||
| 110 | * @param coeffs transform coefficient buffer (in-place) | ||
| 111 | * @param log2_size log2 of transform block size, range: 2..5 (4x4 to 32x32) | ||
| 112 | * This value comes from recursive split_transform_flag parsing | ||
| 113 | * in the bitstream, bounded by log2_min_tb_size (min 2) and | ||
| 114 | * log2_max_trafo_size (max 5) from SPS. | ||
| 115 | * | ||
| 116 | * Formula: shift = 15 - BIT_DEPTH - log2_size | ||
| 117 | * | ||
| 118 | * bit_depth | 4x4 (2) | 8x8 (3) | 16x16 (4) | 32x32 (5) | ||
| 119 | * ----------+---------+---------+-----------+---------- | ||
| 120 | * 8-bit | 5 | 4 | 3 | 2 (shift right) | ||
| 121 | * 10-bit | 3 | 2 | 1 | 0 (shift right / no-op) | ||
| 122 | * 12-bit | 1 | 0 | -1 | -2 (shift right / no-op / shift left) | ||
| 123 | * | ||
| 124 | * When shift == 0, output equals input (identity transform), so we skip | ||
| 125 | * the loop entirely for better performance. | ||
| 126 | */ | ||
| 127 | 888684 | static void FUNC(dequant)(int16_t *coeffs, int16_t log2_size) | |
| 128 | { | ||
| 129 | 888684 | int shift = 15 - BIT_DEPTH - log2_size; | |
| 130 | int x, y; | ||
| 131 | 888684 | int size = 1 << log2_size; | |
| 132 | |||
| 133 |
2/2✓ Branch 0 taken 145127 times.
✓ Branch 1 taken 9298 times.
|
308850 | if (BIT_DEPTH <= 9 || shift > 0) { |
| 134 | 870088 | int offset = 1 << (shift - 1); | |
| 135 |
2/2✓ Branch 0 taken 1814112 times.
✓ Branch 1 taken 435044 times.
|
4498312 | for (y = 0; y < size; y++) { |
| 136 |
2/2✓ Branch 0 taken 8284544 times.
✓ Branch 1 taken 1814112 times.
|
20197312 | for (x = 0; x < size; x++) { |
| 137 | 16569088 | *coeffs = (*coeffs + offset) >> shift; | |
| 138 | 16569088 | coeffs++; | |
| 139 | } | ||
| 140 | } | ||
| 141 |
2/2✓ Branch 0 taken 82 times.
✓ Branch 1 taken 9213 times.
|
18590 | } else if (BIT_DEPTH > 10 && shift < 0) { |
| 142 |
2/2✓ Branch 0 taken 1456 times.
✓ Branch 1 taken 82 times.
|
3076 | for (y = 0; y < size; y++) { |
| 143 |
2/2✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 1456 times.
|
58720 | for (x = 0; x < size; x++) { |
| 144 | 55808 | *coeffs = *(uint16_t*)coeffs << -shift; | |
| 145 | 55808 | coeffs++; | |
| 146 | } | ||
| 147 | } | ||
| 148 | } | ||
| 149 | /* shift == 0: no operation needed (identity transform) */ | ||
| 150 | 888684 | } | |
| 151 | |||
| 152 | #define SET(dst, x) (dst) = (x) | ||
| 153 | #define SCALE(dst, x) (dst) = av_clip_int16(((x) + add) >> shift) | ||
| 154 | |||
| 155 | #define TR_4x4_LUMA(dst, src, step, assign) \ | ||
| 156 | do { \ | ||
| 157 | int c0 = src[0 * step] + src[2 * step]; \ | ||
| 158 | int c1 = src[2 * step] + src[3 * step]; \ | ||
| 159 | int c2 = src[0 * step] - src[3 * step]; \ | ||
| 160 | int c3 = 74 * src[1 * step]; \ | ||
| 161 | \ | ||
| 162 | assign(dst[2 * step], 74 * (src[0 * step] - \ | ||
| 163 | src[2 * step] + \ | ||
| 164 | src[3 * step])); \ | ||
| 165 | assign(dst[0 * step], 29 * c0 + 55 * c1 + c3); \ | ||
| 166 | assign(dst[1 * step], 55 * c2 - 29 * c1 + c3); \ | ||
| 167 | assign(dst[3 * step], 55 * c0 + 29 * c2 - c3); \ | ||
| 168 | } while (0) | ||
| 169 | |||
| 170 | 7848038 | static void FUNC(transform_4x4_luma)(int16_t *coeffs) | |
| 171 | { | ||
| 172 | int i; | ||
| 173 | 7848038 | int shift = 7; | |
| 174 | 7848038 | int add = 1 << (shift - 1); | |
| 175 | 7848038 | int16_t *src = coeffs; | |
| 176 | |||
| 177 |
2/2✓ Branch 0 taken 15696076 times.
✓ Branch 1 taken 3924019 times.
|
39240190 | for (i = 0; i < 4; i++) { |
| 178 | 31392152 | TR_4x4_LUMA(src, src, 4, SCALE); | |
| 179 | 31392152 | src++; | |
| 180 | } | ||
| 181 | |||
| 182 | 7848038 | shift = 20 - BIT_DEPTH; | |
| 183 | 7848038 | add = 1 << (shift - 1); | |
| 184 |
2/2✓ Branch 0 taken 15696076 times.
✓ Branch 1 taken 3924019 times.
|
39240190 | for (i = 0; i < 4; i++) { |
| 185 | 31392152 | TR_4x4_LUMA(coeffs, coeffs, 1, SCALE); | |
| 186 | 31392152 | coeffs += 4; | |
| 187 | } | ||
| 188 | 7848038 | } | |
| 189 | |||
| 190 | #undef TR_4x4_LUMA | ||
| 191 | |||
| 192 | #define TR_4(dst, src, dstep, sstep, assign, end) \ | ||
| 193 | do { \ | ||
| 194 | const int e0 = 64 * src[0 * sstep] + 64 * src[2 * sstep]; \ | ||
| 195 | const int e1 = 64 * src[0 * sstep] - 64 * src[2 * sstep]; \ | ||
| 196 | const int o0 = 83 * src[1 * sstep] + 36 * src[3 * sstep]; \ | ||
| 197 | const int o1 = 36 * src[1 * sstep] - 83 * src[3 * sstep]; \ | ||
| 198 | \ | ||
| 199 | assign(dst[0 * dstep], e0 + o0); \ | ||
| 200 | assign(dst[1 * dstep], e1 + o1); \ | ||
| 201 | assign(dst[2 * dstep], e1 - o1); \ | ||
| 202 | assign(dst[3 * dstep], e0 - o0); \ | ||
| 203 | } while (0) | ||
| 204 | |||
| 205 | #define TR_8(dst, src, dstep, sstep, assign, end) \ | ||
| 206 | do { \ | ||
| 207 | int i, j; \ | ||
| 208 | int e_8[4]; \ | ||
| 209 | int o_8[4] = { 0 }; \ | ||
| 210 | for (i = 0; i < 4; i++) \ | ||
| 211 | for (j = 1; j < end; j += 2) \ | ||
| 212 | o_8[i] += transform[4 * j][i] * src[j * sstep]; \ | ||
| 213 | TR_4(e_8, src, 1, 2 * sstep, SET, 4); \ | ||
| 214 | \ | ||
| 215 | for (i = 0; i < 4; i++) { \ | ||
| 216 | assign(dst[i * dstep], e_8[i] + o_8[i]); \ | ||
| 217 | assign(dst[(7 - i) * dstep], e_8[i] - o_8[i]); \ | ||
| 218 | } \ | ||
| 219 | } while (0) | ||
| 220 | |||
| 221 | #define TR_16(dst, src, dstep, sstep, assign, end) \ | ||
| 222 | do { \ | ||
| 223 | int i, j; \ | ||
| 224 | int e_16[8]; \ | ||
| 225 | int o_16[8] = { 0 }; \ | ||
| 226 | for (i = 0; i < 8; i++) \ | ||
| 227 | for (j = 1; j < end; j += 2) \ | ||
| 228 | o_16[i] += transform[2 * j][i] * src[j * sstep]; \ | ||
| 229 | TR_8(e_16, src, 1, 2 * sstep, SET, 8); \ | ||
| 230 | \ | ||
| 231 | for (i = 0; i < 8; i++) { \ | ||
| 232 | assign(dst[i * dstep], e_16[i] + o_16[i]); \ | ||
| 233 | assign(dst[(15 - i) * dstep], e_16[i] - o_16[i]); \ | ||
| 234 | } \ | ||
| 235 | } while (0) | ||
| 236 | |||
| 237 | #define TR_32(dst, src, dstep, sstep, assign, end) \ | ||
| 238 | do { \ | ||
| 239 | int i, j; \ | ||
| 240 | int e_32[16]; \ | ||
| 241 | int o_32[16] = { 0 }; \ | ||
| 242 | for (i = 0; i < 16; i++) \ | ||
| 243 | for (j = 1; j < end; j += 2) \ | ||
| 244 | o_32[i] += transform[j][i] * src[j * sstep]; \ | ||
| 245 | TR_16(e_32, src, 1, 2 * sstep, SET, end / 2); \ | ||
| 246 | \ | ||
| 247 | for (i = 0; i < 16; i++) { \ | ||
| 248 | assign(dst[i * dstep], e_32[i] + o_32[i]); \ | ||
| 249 | assign(dst[(31 - i) * dstep], e_32[i] - o_32[i]); \ | ||
| 250 | } \ | ||
| 251 | } while (0) | ||
| 252 | |||
| 253 | #define IDCT_VAR4(H) \ | ||
| 254 | int limit2 = FFMIN(col_limit + 4, H) | ||
| 255 | #define IDCT_VAR8(H) \ | ||
| 256 | int limit = FFMIN(col_limit, H); \ | ||
| 257 | int limit2 = FFMIN(col_limit + 4, H) | ||
| 258 | #define IDCT_VAR16(H) IDCT_VAR8(H) | ||
| 259 | #define IDCT_VAR32(H) IDCT_VAR8(H) | ||
| 260 | |||
| 261 | #define IDCT(H) \ | ||
| 262 | static void FUNC(idct_ ## H ## x ## H )(int16_t *coeffs, \ | ||
| 263 | int col_limit) \ | ||
| 264 | { \ | ||
| 265 | int i; \ | ||
| 266 | int shift = 7; \ | ||
| 267 | int add = 1 << (shift - 1); \ | ||
| 268 | int16_t *src = coeffs; \ | ||
| 269 | IDCT_VAR ## H(H); \ | ||
| 270 | \ | ||
| 271 | for (i = 0; i < H; i++) { \ | ||
| 272 | TR_ ## H(src, src, H, H, SCALE, limit2); \ | ||
| 273 | if (limit2 < H && i%4 == 0 && !!i) \ | ||
| 274 | limit2 -= 4; \ | ||
| 275 | src++; \ | ||
| 276 | } \ | ||
| 277 | \ | ||
| 278 | shift = 20 - BIT_DEPTH; \ | ||
| 279 | add = 1 << (shift - 1); \ | ||
| 280 | for (i = 0; i < H; i++) { \ | ||
| 281 | TR_ ## H(coeffs, coeffs, 1, 1, SCALE, limit); \ | ||
| 282 | coeffs += H; \ | ||
| 283 | } \ | ||
| 284 | } | ||
| 285 | |||
| 286 | #define IDCT_DC(H) \ | ||
| 287 | static void FUNC(idct_ ## H ## x ## H ## _dc)(int16_t *coeffs) \ | ||
| 288 | { \ | ||
| 289 | int i, j; \ | ||
| 290 | int shift = 14 - BIT_DEPTH; \ | ||
| 291 | int add = 1 << (shift - 1); \ | ||
| 292 | int coeff = (((coeffs[0] + 1) >> 1) + add) >> shift; \ | ||
| 293 | \ | ||
| 294 | for (j = 0; j < H; j++) { \ | ||
| 295 | for (i = 0; i < H; i++) { \ | ||
| 296 | coeffs[i + j * H] = coeff; \ | ||
| 297 | } \ | ||
| 298 | } \ | ||
| 299 | } | ||
| 300 | |||
| 301 |
5/10✗ Branch 0 not taken.
✓ Branch 1 taken 11077072 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 11077072 times.
✓ Branch 7 taken 2769268 times.
✓ Branch 8 taken 11077072 times.
✓ Branch 9 taken 2769268 times.
|
49846824 | IDCT( 4) |
| 302 |
17/22✓ Branch 0 taken 423891456 times.
✓ Branch 1 taken 105972864 times.
✓ Branch 2 taken 105972864 times.
✓ Branch 3 taken 26493216 times.
✓ Branch 4 taken 105972864 times.
✓ Branch 5 taken 26493216 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 26493216 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 26493216 times.
✓ Branch 13 taken 3311652 times.
✓ Branch 14 taken 298021248 times.
✓ Branch 15 taken 105972864 times.
✓ Branch 16 taken 105972864 times.
✓ Branch 17 taken 26493216 times.
✓ Branch 18 taken 105972864 times.
✓ Branch 19 taken 26493216 times.
✓ Branch 20 taken 26493216 times.
✓ Branch 21 taken 3311652 times.
|
2404204488 | IDCT( 8) |
| 303 |
34/34✓ Branch 0 taken 856514784 times.
✓ Branch 1 taken 226580992 times.
✓ Branch 2 taken 226580992 times.
✓ Branch 3 taken 28322624 times.
✓ Branch 4 taken 453161984 times.
✓ Branch 5 taken 113290496 times.
✓ Branch 6 taken 113290496 times.
✓ Branch 7 taken 28322624 times.
✓ Branch 8 taken 113290496 times.
✓ Branch 9 taken 28322624 times.
✓ Branch 10 taken 226580992 times.
✓ Branch 11 taken 28322624 times.
✓ Branch 12 taken 21065408 times.
✓ Branch 13 taken 7257216 times.
✓ Branch 14 taken 5266352 times.
✓ Branch 15 taken 15799056 times.
✓ Branch 16 taken 3949764 times.
✓ Branch 17 taken 1316588 times.
✓ Branch 18 taken 28322624 times.
✓ Branch 19 taken 1770164 times.
✓ Branch 20 taken 900286208 times.
✓ Branch 21 taken 226580992 times.
✓ Branch 22 taken 226580992 times.
✓ Branch 23 taken 28322624 times.
✓ Branch 24 taken 453161984 times.
✓ Branch 25 taken 113290496 times.
✓ Branch 26 taken 113290496 times.
✓ Branch 27 taken 28322624 times.
✓ Branch 28 taken 113290496 times.
✓ Branch 29 taken 28322624 times.
✓ Branch 30 taken 226580992 times.
✓ Branch 31 taken 28322624 times.
✓ Branch 32 taken 28322624 times.
✓ Branch 33 taken 1770164 times.
|
8162052648 | IDCT(16) |
| 304 |
46/46✓ Branch 0 taken 1341233360 times.
✓ Branch 1 taken 351694336 times.
✓ Branch 2 taken 351694336 times.
✓ Branch 3 taken 21980896 times.
✓ Branch 4 taken 326216208 times.
✓ Branch 5 taken 175847168 times.
✓ Branch 6 taken 175847168 times.
✓ Branch 7 taken 21980896 times.
✓ Branch 8 taken 351694336 times.
✓ Branch 9 taken 87923584 times.
✓ Branch 10 taken 87923584 times.
✓ Branch 11 taken 21980896 times.
✓ Branch 12 taken 87923584 times.
✓ Branch 13 taken 21980896 times.
✓ Branch 14 taken 175847168 times.
✓ Branch 15 taken 21980896 times.
✓ Branch 16 taken 351694336 times.
✓ Branch 17 taken 21980896 times.
✓ Branch 18 taken 19542944 times.
✓ Branch 19 taken 2437952 times.
✓ Branch 20 taken 4885736 times.
✓ Branch 21 taken 14657208 times.
✓ Branch 22 taken 4275019 times.
✓ Branch 23 taken 610717 times.
✓ Branch 24 taken 21980896 times.
✓ Branch 25 taken 686903 times.
✓ Branch 26 taken 2030906880 times.
✓ Branch 27 taken 351694336 times.
✓ Branch 28 taken 351694336 times.
✓ Branch 29 taken 21980896 times.
✓ Branch 30 taken 495420416 times.
✓ Branch 31 taken 175847168 times.
✓ Branch 32 taken 175847168 times.
✓ Branch 33 taken 21980896 times.
✓ Branch 34 taken 351694336 times.
✓ Branch 35 taken 87923584 times.
✓ Branch 36 taken 87923584 times.
✓ Branch 37 taken 21980896 times.
✓ Branch 38 taken 87923584 times.
✓ Branch 39 taken 21980896 times.
✓ Branch 40 taken 175847168 times.
✓ Branch 41 taken 21980896 times.
✓ Branch 42 taken 351694336 times.
✓ Branch 43 taken 21980896 times.
✓ Branch 44 taken 21980896 times.
✓ Branch 45 taken 686903 times.
|
14807349166 | IDCT(32) |
| 305 | |||
| 306 |
4/4✓ Branch 0 taken 19511264 times.
✓ Branch 1 taken 4877816 times.
✓ Branch 2 taken 4877816 times.
✓ Branch 3 taken 1219454 times.
|
51217068 | IDCT_DC( 4) |
| 307 |
4/4✓ Branch 0 taken 61023360 times.
✓ Branch 1 taken 7627920 times.
✓ Branch 2 taken 7627920 times.
✓ Branch 3 taken 953490 times.
|
139209540 | IDCT_DC( 8) |
| 308 |
4/4✓ Branch 0 taken 114278400 times.
✓ Branch 1 taken 7142400 times.
✓ Branch 2 taken 7142400 times.
✓ Branch 3 taken 446400 times.
|
243734400 | IDCT_DC(16) |
| 309 |
4/4✓ Branch 0 taken 146153472 times.
✓ Branch 1 taken 4567296 times.
✓ Branch 2 taken 4567296 times.
✓ Branch 3 taken 142728 times.
|
301726992 | IDCT_DC(32) |
| 310 | |||
| 311 | #undef TR_4 | ||
| 312 | #undef TR_8 | ||
| 313 | #undef TR_16 | ||
| 314 | #undef TR_32 | ||
| 315 | |||
| 316 | #undef SET | ||
| 317 | #undef SCALE | ||
| 318 | |||
| 319 | //////////////////////////////////////////////////////////////////////////////// | ||
| 320 | // | ||
| 321 | //////////////////////////////////////////////////////////////////////////////// | ||
| 322 | #define ff_hevc_pel_filters ff_hevc_qpel_filters | ||
| 323 | #define DECL_HV_FILTER(f) \ | ||
| 324 | const int8_t *hf = ff_hevc_ ## f ## _filters[mx]; \ | ||
| 325 | const int8_t *vf = ff_hevc_ ## f ## _filters[my]; | ||
| 326 | |||
| 327 | #define FW_PUT(p, f, t) \ | ||
| 328 | static void FUNC(put_hevc_## f)(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, int height, \ | ||
| 329 | intptr_t mx, intptr_t my, int width) \ | ||
| 330 | { \ | ||
| 331 | DECL_HV_FILTER(p) \ | ||
| 332 | FUNC(put_ ## t)(dst, src, srcstride, height, hf, vf, width); \ | ||
| 333 | } | ||
| 334 | |||
| 335 | #define FW_PUT_UNI(p, f, t) \ | ||
| 336 | static void FUNC(put_hevc_ ## f)(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \ | ||
| 337 | ptrdiff_t srcstride, int height, intptr_t mx, intptr_t my, int width) \ | ||
| 338 | { \ | ||
| 339 | DECL_HV_FILTER(p) \ | ||
| 340 | FUNC(put_ ## t)(dst, dststride, src, srcstride, height, hf, vf, width); \ | ||
| 341 | } | ||
| 342 | |||
| 343 | #define FW_PUT_UNI_W(p, f, t) \ | ||
| 344 | static void FUNC(put_hevc_ ## f)(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \ | ||
| 345 | ptrdiff_t srcstride,int height, int denom, int wx, int ox, \ | ||
| 346 | intptr_t mx, intptr_t my, int width) \ | ||
| 347 | { \ | ||
| 348 | DECL_HV_FILTER(p) \ | ||
| 349 | FUNC(put_ ## t)(dst, dststride, src, srcstride, height, denom, wx, ox, hf, vf, width); \ | ||
| 350 | } | ||
| 351 | |||
| 352 | #define FW_PUT_FUNCS(f, t, dir) \ | ||
| 353 | FW_PUT(f, f ## _ ## dir, t ## _ ## dir) \ | ||
| 354 | FW_PUT_UNI(f, f ## _uni_ ## dir, uni_ ## t ## _ ## dir) \ | ||
| 355 | FW_PUT_UNI_W(f, f ## _uni_w_ ## dir, uni_## t ## _w_ ## dir) | ||
| 356 | |||
| 357 | 5017088 | FW_PUT(pel, pel_pixels, pixels) | |
| 358 | 6980388 | FW_PUT_UNI(pel, pel_uni_pixels, uni_pixels) | |
| 359 | 170270 | FW_PUT_UNI_W(pel, pel_uni_w_pixels, uni_w_pixels) | |
| 360 | |||
| 361 | 3450226 | FW_PUT_FUNCS(qpel, luma, h ) | |
| 362 | 2977958 | FW_PUT_FUNCS(qpel, luma, v ) | |
| 363 | 9270514 | FW_PUT_FUNCS(qpel, luma, hv ) | |
| 364 | 5510444 | FW_PUT_FUNCS(epel, chroma, h ) | |
| 365 | 4388320 | FW_PUT_FUNCS(epel, chroma, v ) | |
| 366 | 24025592 | FW_PUT_FUNCS(epel, chroma, hv ) | |
| 367 | |||
| 368 | 5462332 | static void FUNC(put_hevc_pel_bi_pixels)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, | |
| 369 | const int16_t *src2, | ||
| 370 | int height, intptr_t mx, intptr_t my, int width) | ||
| 371 | { | ||
| 372 | int x, y; | ||
| 373 | 5462332 | const pixel *src = (const pixel *)_src; | |
| 374 | 5462332 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 375 | 5462332 | pixel *dst = (pixel *)_dst; | |
| 376 | 5462332 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 377 | |||
| 378 | 5462332 | int shift = 14 + 1 - BIT_DEPTH; | |
| 379 | #if BIT_DEPTH < 14 | ||
| 380 | 5462332 | int offset = 1 << (shift - 1); | |
| 381 | #else | ||
| 382 | int offset = 0; | ||
| 383 | #endif | ||
| 384 | |||
| 385 |
2/2✓ Branch 0 taken 41306864 times.
✓ Branch 1 taken 2731166 times.
|
88076060 | for (y = 0; y < height; y++) { |
| 386 |
2/2✓ Branch 0 taken 1067768520 times.
✓ Branch 1 taken 41306864 times.
|
2218150768 | for (x = 0; x < width; x++) |
| 387 | 2135537040 | dst[x] = av_clip_pixel(((src[x] << (14 - BIT_DEPTH)) + src2[x] + offset) >> shift); | |
| 388 | 82613728 | src += srcstride; | |
| 389 | 82613728 | dst += dststride; | |
| 390 | 82613728 | src2 += MAX_PB_SIZE; | |
| 391 | } | ||
| 392 | 5462332 | } | |
| 393 | |||
| 394 | 84070 | static void FUNC(put_hevc_pel_bi_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, | |
| 395 | const int16_t *src2, | ||
| 396 | int height, int denom, int wx0, int wx1, | ||
| 397 | int ox, intptr_t mx, intptr_t my, int width) | ||
| 398 | { | ||
| 399 | int x, y; | ||
| 400 | 84070 | const pixel *src = (const pixel *)_src; | |
| 401 | 84070 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 402 | 84070 | pixel *dst = (pixel *)_dst; | |
| 403 | 84070 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 404 | |||
| 405 | 84070 | int shift = 14 + 1 - BIT_DEPTH; | |
| 406 | 84070 | int log2Wd = denom + shift - 1; | |
| 407 | |||
| 408 | 84070 | ox = ox * (1 << (BIT_DEPTH - 8)) + 1; | |
| 409 |
2/2✓ Branch 0 taken 913548 times.
✓ Branch 1 taken 42035 times.
|
1911166 | for (y = 0; y < height; y++) { |
| 410 |
2/2✓ Branch 0 taken 29554400 times.
✓ Branch 1 taken 913548 times.
|
60935896 | for (x = 0; x < width; x++) { |
| 411 | 59108800 | dst[x] = av_clip_pixel(( (src[x] << (14 - BIT_DEPTH)) * wx1 + src2[x] * wx0 + ox * (1 << log2Wd)) >> (log2Wd + 1)); | |
| 412 | } | ||
| 413 | 1827096 | src += srcstride; | |
| 414 | 1827096 | dst += dststride; | |
| 415 | 1827096 | src2 += MAX_PB_SIZE; | |
| 416 | } | ||
| 417 | 84070 | } | |
| 418 | |||
| 419 | //////////////////////////////////////////////////////////////////////////////// | ||
| 420 | // | ||
| 421 | //////////////////////////////////////////////////////////////////////////////// | ||
| 422 | #define QPEL_FILTER(src, stride) \ | ||
| 423 | (filter[0] * src[x - 3 * stride] + \ | ||
| 424 | filter[1] * src[x - 2 * stride] + \ | ||
| 425 | filter[2] * src[x - stride] + \ | ||
| 426 | filter[3] * src[x ] + \ | ||
| 427 | filter[4] * src[x + stride] + \ | ||
| 428 | filter[5] * src[x + 2 * stride] + \ | ||
| 429 | filter[6] * src[x + 3 * stride] + \ | ||
| 430 | filter[7] * src[x + 4 * stride]) | ||
| 431 | |||
| 432 | 1362426 | static void FUNC(put_hevc_qpel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, | |
| 433 | const int16_t *src2, | ||
| 434 | int height, intptr_t mx, intptr_t my, int width) | ||
| 435 | { | ||
| 436 | int x, y; | ||
| 437 | 1362426 | const pixel *src = (const pixel*)_src; | |
| 438 | 1362426 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 439 | 1362426 | pixel *dst = (pixel *)_dst; | |
| 440 | 1362426 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 441 | |||
| 442 | 1362426 | const int8_t *filter = ff_hevc_qpel_filters[mx]; | |
| 443 | |||
| 444 | 1362426 | int shift = 14 + 1 - BIT_DEPTH; | |
| 445 | #if BIT_DEPTH < 14 | ||
| 446 | 1362426 | int offset = 1 << (shift - 1); | |
| 447 | #else | ||
| 448 | int offset = 0; | ||
| 449 | #endif | ||
| 450 | |||
| 451 |
2/2✓ Branch 0 taken 15145566 times.
✓ Branch 1 taken 681213 times.
|
31653558 | for (y = 0; y < height; y++) { |
| 452 |
2/2✓ Branch 0 taken 513252956 times.
✓ Branch 1 taken 15145566 times.
|
1056797044 | for (x = 0; x < width; x++) |
| 453 | 1026505912 | dst[x] = av_clip_pixel(((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift); | |
| 454 | 30291132 | src += srcstride; | |
| 455 | 30291132 | dst += dststride; | |
| 456 | 30291132 | src2 += MAX_PB_SIZE; | |
| 457 | } | ||
| 458 | 1362426 | } | |
| 459 | |||
| 460 | 1073412 | static void FUNC(put_hevc_qpel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride, | |
| 461 | const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, | ||
| 462 | int height, intptr_t mx, intptr_t my, int width) | ||
| 463 | { | ||
| 464 | int x, y; | ||
| 465 | 1073412 | const pixel *src = (const pixel*)_src; | |
| 466 | 1073412 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 467 | 1073412 | pixel *dst = (pixel *)_dst; | |
| 468 | 1073412 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 469 | |||
| 470 | 1073412 | const int8_t *filter = ff_hevc_qpel_filters[my]; | |
| 471 | |||
| 472 | 1073412 | int shift = 14 + 1 - BIT_DEPTH; | |
| 473 | #if BIT_DEPTH < 14 | ||
| 474 | 1073412 | int offset = 1 << (shift - 1); | |
| 475 | #else | ||
| 476 | int offset = 0; | ||
| 477 | #endif | ||
| 478 | |||
| 479 |
2/2✓ Branch 0 taken 11565878 times.
✓ Branch 1 taken 536706 times.
|
24205168 | for (y = 0; y < height; y++) { |
| 480 |
2/2✓ Branch 0 taken 377825756 times.
✓ Branch 1 taken 11565878 times.
|
778783268 | for (x = 0; x < width; x++) |
| 481 | 755651512 | dst[x] = av_clip_pixel(((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift); | |
| 482 | 23131756 | src += srcstride; | |
| 483 | 23131756 | dst += dststride; | |
| 484 | 23131756 | src2 += MAX_PB_SIZE; | |
| 485 | } | ||
| 486 | 1073412 | } | |
| 487 | |||
| 488 | 3364696 | static void FUNC(put_hevc_qpel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride, | |
| 489 | const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, | ||
| 490 | int height, intptr_t mx, intptr_t my, int width) | ||
| 491 | { | ||
| 492 | int x, y; | ||
| 493 | const int8_t *filter; | ||
| 494 | 3364696 | const pixel *src = (const pixel*)_src; | |
| 495 | 3364696 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 496 | 3364696 | pixel *dst = (pixel *)_dst; | |
| 497 | 3364696 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 498 | int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE]; | ||
| 499 | 3364696 | int16_t *tmp = tmp_array; | |
| 500 | 3364696 | int shift = 14 + 1 - BIT_DEPTH; | |
| 501 | #if BIT_DEPTH < 14 | ||
| 502 | 3364696 | int offset = 1 << (shift - 1); | |
| 503 | #else | ||
| 504 | int offset = 0; | ||
| 505 | #endif | ||
| 506 | |||
| 507 | 3364696 | src -= QPEL_EXTRA_BEFORE * srcstride; | |
| 508 | 3364696 | filter = ff_hevc_qpel_filters[mx]; | |
| 509 |
2/2✓ Branch 0 taken 48026278 times.
✓ Branch 1 taken 1682348 times.
|
99417252 | for (y = 0; y < height + QPEL_EXTRA; y++) { |
| 510 |
2/2✓ Branch 0 taken 1424993862 times.
✓ Branch 1 taken 48026278 times.
|
2946040280 | for (x = 0; x < width; x++) |
| 511 | 2849987724 | tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8); | |
| 512 | 96052556 | src += srcstride; | |
| 513 | 96052556 | tmp += MAX_PB_SIZE; | |
| 514 | } | ||
| 515 | |||
| 516 | 3364696 | tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE; | |
| 517 | 3364696 | filter = ff_hevc_qpel_filters[my]; | |
| 518 | |||
| 519 |
2/2✓ Branch 0 taken 36249842 times.
✓ Branch 1 taken 1682348 times.
|
75864380 | for (y = 0; y < height; y++) { |
| 520 |
2/2✓ Branch 0 taken 1174296604 times.
✓ Branch 1 taken 36249842 times.
|
2421092892 | for (x = 0; x < width; x++) |
| 521 | 2348593208 | dst[x] = av_clip_pixel(((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) + src2[x] + offset) >> shift); | |
| 522 | 72499684 | tmp += MAX_PB_SIZE; | |
| 523 | 72499684 | dst += dststride; | |
| 524 | 72499684 | src2 += MAX_PB_SIZE; | |
| 525 | } | ||
| 526 | 3364696 | } | |
| 527 | |||
| 528 | 25262 | static void FUNC(put_hevc_qpel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride, | |
| 529 | const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, | ||
| 530 | int height, int denom, int wx0, int wx1, | ||
| 531 | int ox, intptr_t mx, intptr_t my, int width) | ||
| 532 | { | ||
| 533 | int x, y; | ||
| 534 | 25262 | const pixel *src = (const pixel*)_src; | |
| 535 | 25262 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 536 | 25262 | pixel *dst = (pixel *)_dst; | |
| 537 | 25262 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 538 | |||
| 539 | 25262 | const int8_t *filter = ff_hevc_qpel_filters[mx]; | |
| 540 | |||
| 541 | 25262 | int shift = 14 + 1 - BIT_DEPTH; | |
| 542 | 25262 | int log2Wd = denom + shift - 1; | |
| 543 | |||
| 544 | 25262 | ox = ox * (1 << (BIT_DEPTH - 8)) + 1; | |
| 545 |
2/2✓ Branch 0 taken 326376 times.
✓ Branch 1 taken 12631 times.
|
678014 | for (y = 0; y < height; y++) { |
| 546 |
2/2✓ Branch 0 taken 12110160 times.
✓ Branch 1 taken 326376 times.
|
24873072 | for (x = 0; x < width; x++) |
| 547 | 24220320 | dst[x] = av_clip_pixel(((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 + | |
| 548 | ox * (1 << log2Wd)) >> (log2Wd + 1)); | ||
| 549 | 652752 | src += srcstride; | |
| 550 | 652752 | dst += dststride; | |
| 551 | 652752 | src2 += MAX_PB_SIZE; | |
| 552 | } | ||
| 553 | 25262 | } | |
| 554 | |||
| 555 | 20560 | static void FUNC(put_hevc_qpel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, | |
| 556 | const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, | ||
| 557 | int height, int denom, int wx0, int wx1, | ||
| 558 | int ox, intptr_t mx, intptr_t my, int width) | ||
| 559 | { | ||
| 560 | int x, y; | ||
| 561 | 20560 | const pixel *src = (const pixel*)_src; | |
| 562 | 20560 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 563 | 20560 | pixel *dst = (pixel *)_dst; | |
| 564 | 20560 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 565 | |||
| 566 | 20560 | const int8_t *filter = ff_hevc_qpel_filters[my]; | |
| 567 | |||
| 568 | 20560 | int shift = 14 + 1 - BIT_DEPTH; | |
| 569 | 20560 | int log2Wd = denom + shift - 1; | |
| 570 | |||
| 571 | 20560 | ox = ox * (1 << (BIT_DEPTH - 8)) + 1; | |
| 572 |
2/2✓ Branch 0 taken 241540 times.
✓ Branch 1 taken 10280 times.
|
503640 | for (y = 0; y < height; y++) { |
| 573 |
2/2✓ Branch 0 taken 8232272 times.
✓ Branch 1 taken 241540 times.
|
16947624 | for (x = 0; x < width; x++) |
| 574 | 16464544 | dst[x] = av_clip_pixel(((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 + | |
| 575 | ox * (1 << log2Wd)) >> (log2Wd + 1)); | ||
| 576 | 483080 | src += srcstride; | |
| 577 | 483080 | dst += dststride; | |
| 578 | 483080 | src2 += MAX_PB_SIZE; | |
| 579 | } | ||
| 580 | 20560 | } | |
| 581 | |||
| 582 | 70814 | static void FUNC(put_hevc_qpel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, | |
| 583 | const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, | ||
| 584 | int height, int denom, int wx0, int wx1, | ||
| 585 | int ox, intptr_t mx, intptr_t my, int width) | ||
| 586 | { | ||
| 587 | int x, y; | ||
| 588 | const int8_t *filter; | ||
| 589 | 70814 | const pixel *src = (const pixel*)_src; | |
| 590 | 70814 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 591 | 70814 | pixel *dst = (pixel *)_dst; | |
| 592 | 70814 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 593 | int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE]; | ||
| 594 | 70814 | int16_t *tmp = tmp_array; | |
| 595 | 70814 | int shift = 14 + 1 - BIT_DEPTH; | |
| 596 | 70814 | int log2Wd = denom + shift - 1; | |
| 597 | |||
| 598 | 70814 | src -= QPEL_EXTRA_BEFORE * srcstride; | |
| 599 | 70814 | filter = ff_hevc_qpel_filters[mx]; | |
| 600 |
2/2✓ Branch 0 taken 1128105 times.
✓ Branch 1 taken 35407 times.
|
2327024 | for (y = 0; y < height + QPEL_EXTRA; y++) { |
| 601 |
2/2✓ Branch 0 taken 36871784 times.
✓ Branch 1 taken 1128105 times.
|
75999778 | for (x = 0; x < width; x++) |
| 602 | 73743568 | tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8); | |
| 603 | 2256210 | src += srcstride; | |
| 604 | 2256210 | tmp += MAX_PB_SIZE; | |
| 605 | } | ||
| 606 | |||
| 607 | 70814 | tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE; | |
| 608 | 70814 | filter = ff_hevc_qpel_filters[my]; | |
| 609 | |||
| 610 | 70814 | ox = ox * (1 << (BIT_DEPTH - 8)) + 1; | |
| 611 |
2/2✓ Branch 0 taken 880256 times.
✓ Branch 1 taken 35407 times.
|
1831326 | for (y = 0; y < height; y++) { |
| 612 |
2/2✓ Branch 0 taken 30916688 times.
✓ Branch 1 taken 880256 times.
|
63593888 | for (x = 0; x < width; x++) |
| 613 | 61833376 | dst[x] = av_clip_pixel(((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx1 + src2[x] * wx0 + | |
| 614 | ox * (1 << log2Wd)) >> (log2Wd + 1)); | ||
| 615 | 1760512 | tmp += MAX_PB_SIZE; | |
| 616 | 1760512 | dst += dststride; | |
| 617 | 1760512 | src2 += MAX_PB_SIZE; | |
| 618 | } | ||
| 619 | 70814 | } | |
| 620 | |||
| 621 | //////////////////////////////////////////////////////////////////////////////// | ||
| 622 | // | ||
| 623 | //////////////////////////////////////////////////////////////////////////////// | ||
| 624 | #define EPEL_FILTER(src, stride) \ | ||
| 625 | (filter[0] * src[x - stride] + \ | ||
| 626 | filter[1] * src[x] + \ | ||
| 627 | filter[2] * src[x + stride] + \ | ||
| 628 | filter[3] * src[x + 2 * stride]) | ||
| 629 | |||
| 630 | 2166052 | static void FUNC(put_hevc_epel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride, | |
| 631 | const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, | ||
| 632 | int height, intptr_t mx, intptr_t my, int width) | ||
| 633 | { | ||
| 634 | int x, y; | ||
| 635 | 2166052 | const pixel *src = (const pixel *)_src; | |
| 636 | 2166052 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 637 | 2166052 | pixel *dst = (pixel *)_dst; | |
| 638 | 2166052 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 639 | 2166052 | const int8_t *filter = ff_hevc_epel_filters[mx]; | |
| 640 | 2166052 | int shift = 14 + 1 - BIT_DEPTH; | |
| 641 | #if BIT_DEPTH < 14 | ||
| 642 | 2166052 | int offset = 1 << (shift - 1); | |
| 643 | #else | ||
| 644 | int offset = 0; | ||
| 645 | #endif | ||
| 646 | |||
| 647 |
2/2✓ Branch 0 taken 12793552 times.
✓ Branch 1 taken 1083026 times.
|
27753156 | for (y = 0; y < height; y++) { |
| 648 |
2/2✓ Branch 0 taken 217368712 times.
✓ Branch 1 taken 12793552 times.
|
460324528 | for (x = 0; x < width; x++) { |
| 649 | 434737424 | dst[x] = av_clip_pixel(((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift); | |
| 650 | } | ||
| 651 | 25587104 | dst += dststride; | |
| 652 | 25587104 | src += srcstride; | |
| 653 | 25587104 | src2 += MAX_PB_SIZE; | |
| 654 | } | ||
| 655 | 2166052 | } | |
| 656 | |||
| 657 | 1506488 | static void FUNC(put_hevc_epel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride, | |
| 658 | const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, | ||
| 659 | int height, intptr_t mx, intptr_t my, int width) | ||
| 660 | { | ||
| 661 | int x, y; | ||
| 662 | 1506488 | const pixel *src = (const pixel *)_src; | |
| 663 | 1506488 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 664 | 1506488 | const int8_t *filter = ff_hevc_epel_filters[my]; | |
| 665 | 1506488 | pixel *dst = (pixel *)_dst; | |
| 666 | 1506488 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 667 | 1506488 | int shift = 14 + 1 - BIT_DEPTH; | |
| 668 | #if BIT_DEPTH < 14 | ||
| 669 | 1506488 | int offset = 1 << (shift - 1); | |
| 670 | #else | ||
| 671 | int offset = 0; | ||
| 672 | #endif | ||
| 673 | |||
| 674 |
2/2✓ Branch 0 taken 9088776 times.
✓ Branch 1 taken 753244 times.
|
19684040 | for (y = 0; y < height; y++) { |
| 675 |
2/2✓ Branch 0 taken 149399880 times.
✓ Branch 1 taken 9088776 times.
|
316977312 | for (x = 0; x < width; x++) |
| 676 | 298799760 | dst[x] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift); | |
| 677 | 18177552 | dst += dststride; | |
| 678 | 18177552 | src += srcstride; | |
| 679 | 18177552 | src2 += MAX_PB_SIZE; | |
| 680 | } | ||
| 681 | 1506488 | } | |
| 682 | |||
| 683 | 8559712 | static void FUNC(put_hevc_epel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride, | |
| 684 | const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, | ||
| 685 | int height, intptr_t mx, intptr_t my, int width) | ||
| 686 | { | ||
| 687 | int x, y; | ||
| 688 | 8559712 | const pixel *src = (const pixel *)_src; | |
| 689 | 8559712 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 690 | 8559712 | pixel *dst = (pixel *)_dst; | |
| 691 | 8559712 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 692 | 8559712 | const int8_t *filter = ff_hevc_epel_filters[mx]; | |
| 693 | int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE]; | ||
| 694 | 8559712 | int16_t *tmp = tmp_array; | |
| 695 | 8559712 | int shift = 14 + 1 - BIT_DEPTH; | |
| 696 | #if BIT_DEPTH < 14 | ||
| 697 | 8559712 | int offset = 1 << (shift - 1); | |
| 698 | #else | ||
| 699 | int offset = 0; | ||
| 700 | #endif | ||
| 701 | |||
| 702 | 8559712 | src -= EPEL_EXTRA_BEFORE * srcstride; | |
| 703 | |||
| 704 |
2/2✓ Branch 0 taken 61898060 times.
✓ Branch 1 taken 4279856 times.
|
132355832 | for (y = 0; y < height + EPEL_EXTRA; y++) { |
| 705 |
2/2✓ Branch 0 taken 920788640 times.
✓ Branch 1 taken 61898060 times.
|
1965373400 | for (x = 0; x < width; x++) |
| 706 | 1841577280 | tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8); | |
| 707 | 123796120 | src += srcstride; | |
| 708 | 123796120 | tmp += MAX_PB_SIZE; | |
| 709 | } | ||
| 710 | |||
| 711 | 8559712 | tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE; | |
| 712 | 8559712 | filter = ff_hevc_epel_filters[my]; | |
| 713 | |||
| 714 |
2/2✓ Branch 0 taken 49058492 times.
✓ Branch 1 taken 4279856 times.
|
106676696 | for (y = 0; y < height; y++) { |
| 715 |
2/2✓ Branch 0 taken 783245672 times.
✓ Branch 1 taken 49058492 times.
|
1664608328 | for (x = 0; x < width; x++) |
| 716 | 1566491344 | dst[x] = av_clip_pixel(((EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) + src2[x] + offset) >> shift); | |
| 717 | 98116984 | tmp += MAX_PB_SIZE; | |
| 718 | 98116984 | dst += dststride; | |
| 719 | 98116984 | src2 += MAX_PB_SIZE; | |
| 720 | } | ||
| 721 | 8559712 | } | |
| 722 | |||
| 723 | 38276 | static void FUNC(put_hevc_epel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride, | |
| 724 | const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, | ||
| 725 | int height, int denom, int wx0, int wx1, | ||
| 726 | int ox, intptr_t mx, intptr_t my, int width) | ||
| 727 | { | ||
| 728 | int x, y; | ||
| 729 | 38276 | const pixel *src = (const pixel *)_src; | |
| 730 | 38276 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 731 | 38276 | pixel *dst = (pixel *)_dst; | |
| 732 | 38276 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 733 | 38276 | const int8_t *filter = ff_hevc_epel_filters[mx]; | |
| 734 | 38276 | int shift = 14 + 1 - BIT_DEPTH; | |
| 735 | 38276 | int log2Wd = denom + shift - 1; | |
| 736 | |||
| 737 | 38276 | ox = ox * (1 << (BIT_DEPTH - 8)) + 1; | |
| 738 |
2/2✓ Branch 0 taken 281780 times.
✓ Branch 1 taken 19138 times.
|
601836 | for (y = 0; y < height; y++) { |
| 739 |
2/2✓ Branch 0 taken 6354784 times.
✓ Branch 1 taken 281780 times.
|
13273128 | for (x = 0; x < width; x++) |
| 740 | 12709568 | dst[x] = av_clip_pixel(((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 + | |
| 741 | ox * (1 << log2Wd)) >> (log2Wd + 1)); | ||
| 742 | 563560 | src += srcstride; | |
| 743 | 563560 | dst += dststride; | |
| 744 | 563560 | src2 += MAX_PB_SIZE; | |
| 745 | } | ||
| 746 | 38276 | } | |
| 747 | |||
| 748 | 25028 | static void FUNC(put_hevc_epel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, | |
| 749 | const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, | ||
| 750 | int height, int denom, int wx0, int wx1, | ||
| 751 | int ox, intptr_t mx, intptr_t my, int width) | ||
| 752 | { | ||
| 753 | int x, y; | ||
| 754 | 25028 | const pixel *src = (const pixel *)_src; | |
| 755 | 25028 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 756 | 25028 | const int8_t *filter = ff_hevc_epel_filters[my]; | |
| 757 | 25028 | pixel *dst = (pixel *)_dst; | |
| 758 | 25028 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 759 | 25028 | int shift = 14 + 1 - BIT_DEPTH; | |
| 760 | 25028 | int log2Wd = denom + shift - 1; | |
| 761 | |||
| 762 | 25028 | ox = ox * (1 << (BIT_DEPTH - 8)) + 1; | |
| 763 |
2/2✓ Branch 0 taken 173064 times.
✓ Branch 1 taken 12514 times.
|
371156 | for (y = 0; y < height; y++) { |
| 764 |
2/2✓ Branch 0 taken 3990848 times.
✓ Branch 1 taken 173064 times.
|
8327824 | for (x = 0; x < width; x++) |
| 765 | 7981696 | dst[x] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 + | |
| 766 | ox * (1 << log2Wd)) >> (log2Wd + 1)); | ||
| 767 | 346128 | src += srcstride; | |
| 768 | 346128 | dst += dststride; | |
| 769 | 346128 | src2 += MAX_PB_SIZE; | |
| 770 | } | ||
| 771 | 25028 | } | |
| 772 | |||
| 773 | 166712 | static void FUNC(put_hevc_epel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, | |
| 774 | const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, | ||
| 775 | int height, int denom, int wx0, int wx1, | ||
| 776 | int ox, intptr_t mx, intptr_t my, int width) | ||
| 777 | { | ||
| 778 | int x, y; | ||
| 779 | 166712 | const pixel *src = (const pixel *)_src; | |
| 780 | 166712 | ptrdiff_t srcstride = _srcstride / sizeof(pixel); | |
| 781 | 166712 | pixel *dst = (pixel *)_dst; | |
| 782 | 166712 | ptrdiff_t dststride = _dststride / sizeof(pixel); | |
| 783 | 166712 | const int8_t *filter = ff_hevc_epel_filters[mx]; | |
| 784 | int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE]; | ||
| 785 | 166712 | int16_t *tmp = tmp_array; | |
| 786 | 166712 | int shift = 14 + 1 - BIT_DEPTH; | |
| 787 | 166712 | int log2Wd = denom + shift - 1; | |
| 788 | |||
| 789 | 166712 | src -= EPEL_EXTRA_BEFORE * srcstride; | |
| 790 | |||
| 791 |
2/2✓ Branch 0 taken 1286192 times.
✓ Branch 1 taken 83356 times.
|
2739096 | for (y = 0; y < height + EPEL_EXTRA; y++) { |
| 792 |
2/2✓ Branch 0 taken 21663936 times.
✓ Branch 1 taken 1286192 times.
|
45900256 | for (x = 0; x < width; x++) |
| 793 | 43327872 | tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8); | |
| 794 | 2572384 | src += srcstride; | |
| 795 | 2572384 | tmp += MAX_PB_SIZE; | |
| 796 | } | ||
| 797 | |||
| 798 | 166712 | tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE; | |
| 799 | 166712 | filter = ff_hevc_epel_filters[my]; | |
| 800 | |||
| 801 | 166712 | ox = ox * (1 << (BIT_DEPTH - 8)) + 1; | |
| 802 |
2/2✓ Branch 0 taken 1036124 times.
✓ Branch 1 taken 83356 times.
|
2238960 | for (y = 0; y < height; y++) { |
| 803 |
2/2✓ Branch 0 taken 18669504 times.
✓ Branch 1 taken 1036124 times.
|
39411256 | for (x = 0; x < width; x++) |
| 804 | 37339008 | dst[x] = av_clip_pixel(((EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx1 + src2[x] * wx0 + | |
| 805 | ox * (1 << log2Wd)) >> (log2Wd + 1)); | ||
| 806 | 2072248 | tmp += MAX_PB_SIZE; | |
| 807 | 2072248 | dst += dststride; | |
| 808 | 2072248 | src2 += MAX_PB_SIZE; | |
| 809 | } | ||
| 810 | 166712 | } | |
| 811 | |||
| 812 | // line zero | ||
| 813 | #define P3 pix[-4 * xstride] | ||
| 814 | #define P2 pix[-3 * xstride] | ||
| 815 | #define P1 pix[-2 * xstride] | ||
| 816 | #define P0 pix[-1 * xstride] | ||
| 817 | #define Q0 pix[0 * xstride] | ||
| 818 | #define Q1 pix[1 * xstride] | ||
| 819 | #define Q2 pix[2 * xstride] | ||
| 820 | #define Q3 pix[3 * xstride] | ||
| 821 | |||
| 822 | // line three. used only for deblocking decision | ||
| 823 | #define TP3 pix[-4 * xstride + 3 * ystride] | ||
| 824 | #define TP2 pix[-3 * xstride + 3 * ystride] | ||
| 825 | #define TP1 pix[-2 * xstride + 3 * ystride] | ||
| 826 | #define TP0 pix[-1 * xstride + 3 * ystride] | ||
| 827 | #define TQ0 pix[0 * xstride + 3 * ystride] | ||
| 828 | #define TQ1 pix[1 * xstride + 3 * ystride] | ||
| 829 | #define TQ2 pix[2 * xstride + 3 * ystride] | ||
| 830 | #define TQ3 pix[3 * xstride + 3 * ystride] | ||
| 831 | |||
| 832 | #include "libavcodec/h26x/h2656_deblock_template.c" | ||
| 833 | |||
| 834 | 85846092 | static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix, | |
| 835 | ptrdiff_t _xstride, ptrdiff_t _ystride, | ||
| 836 | int beta, const int *_tc, | ||
| 837 | const uint8_t *_no_p, const uint8_t *_no_q) | ||
| 838 | { | ||
| 839 | 85846092 | ptrdiff_t xstride = _xstride / sizeof(pixel); | |
| 840 | 85846092 | ptrdiff_t ystride = _ystride / sizeof(pixel); | |
| 841 | |||
| 842 | 85846092 | beta <<= BIT_DEPTH - 8; | |
| 843 | |||
| 844 |
2/2✓ Branch 0 taken 85846092 times.
✓ Branch 1 taken 42923046 times.
|
257538276 | for (int j = 0; j < 2; j++) { |
| 845 | 171692184 | pixel* pix = (pixel*)_pix + j * 4 * ystride; | |
| 846 | 171692184 | const int dp0 = abs(P2 - 2 * P1 + P0); | |
| 847 | 171692184 | const int dq0 = abs(Q2 - 2 * Q1 + Q0); | |
| 848 | 171692184 | const int dp3 = abs(TP2 - 2 * TP1 + TP0); | |
| 849 | 171692184 | const int dq3 = abs(TQ2 - 2 * TQ1 + TQ0); | |
| 850 | 171692184 | const int d0 = dp0 + dq0; | |
| 851 | 171692184 | const int d3 = dp3 + dq3; | |
| 852 | 171692184 | const int tc = _tc[j] << (BIT_DEPTH - 8); | |
| 853 | 171692184 | const int no_p = _no_p[j]; | |
| 854 | 171692184 | const int no_q = _no_q[j]; | |
| 855 | |||
| 856 |
2/2✓ Branch 0 taken 64658415 times.
✓ Branch 1 taken 21187677 times.
|
171692184 | if (d0 + d3 < beta) { |
| 857 | 129316830 | const int beta_3 = beta >> 3; | |
| 858 | 129316830 | const int beta_2 = beta >> 2; | |
| 859 | 129316830 | const int tc25 = ((tc * 5 + 1) >> 1); | |
| 860 | |||
| 861 |
4/4✓ Branch 0 taken 19484030 times.
✓ Branch 1 taken 45174385 times.
✓ Branch 2 taken 18985571 times.
✓ Branch 3 taken 498459 times.
|
129316830 | if (abs(P3 - P0) + abs(Q3 - Q0) < beta_3 && abs(P0 - Q0) < tc25 && |
| 862 |
4/4✓ Branch 0 taken 14320080 times.
✓ Branch 1 taken 4665491 times.
✓ Branch 2 taken 14215997 times.
✓ Branch 3 taken 104083 times.
|
37971142 | abs(TP3 - TP0) + abs(TQ3 - TQ0) < beta_3 && abs(TP0 - TQ0) < tc25 && |
| 863 |
4/4✓ Branch 0 taken 13718390 times.
✓ Branch 1 taken 497607 times.
✓ Branch 2 taken 13406555 times.
✓ Branch 3 taken 311835 times.
|
55245104 | (d0 << 1) < beta_2 && (d3 << 1) < beta_2) { |
| 864 | 26813110 | const int tc2 = tc << 1; | |
| 865 | 26813110 | FUNC(loop_filter_luma_strong)(pix, xstride, ystride, tc2, tc2, tc2, no_p, no_q); | |
| 866 | } else { | ||
| 867 | 102503720 | int nd_p = 1; | |
| 868 | 102503720 | int nd_q = 1; | |
| 869 |
2/2✓ Branch 0 taken 35785105 times.
✓ Branch 1 taken 15466755 times.
|
102503720 | if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3)) |
| 870 | 71570210 | nd_p = 2; | |
| 871 |
2/2✓ Branch 0 taken 34909366 times.
✓ Branch 1 taken 16342494 times.
|
102503720 | if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3)) |
| 872 | 69818732 | nd_q = 2; | |
| 873 | 102503720 | FUNC(loop_filter_luma_weak)(pix, xstride, ystride, tc, beta, no_p, no_q, nd_p, nd_q); | |
| 874 | } | ||
| 875 | } | ||
| 876 | } | ||
| 877 | 85846092 | } | |
| 878 | |||
| 879 | 26199108 | static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride, | |
| 880 | ptrdiff_t _ystride, const int *_tc, | ||
| 881 | const uint8_t *_no_p, const uint8_t *_no_q) | ||
| 882 | { | ||
| 883 | int no_p, no_q; | ||
| 884 | 26199108 | ptrdiff_t xstride = _xstride / sizeof(pixel); | |
| 885 | 26199108 | ptrdiff_t ystride = _ystride / sizeof(pixel); | |
| 886 | 26199108 | const int size = 4; | |
| 887 | |||
| 888 |
2/2✓ Branch 0 taken 26199108 times.
✓ Branch 1 taken 13099554 times.
|
78597324 | for (int j = 0; j < 2; j++) { |
| 889 | 52398216 | pixel *pix = (pixel *)_pix + j * size * ystride; | |
| 890 | 52398216 | const int tc = _tc[j] << (BIT_DEPTH - 8); | |
| 891 |
2/2✓ Branch 0 taken 23572431 times.
✓ Branch 1 taken 2626677 times.
|
52398216 | if (tc > 0) { |
| 892 | 47144862 | no_p = _no_p[j]; | |
| 893 | 47144862 | no_q = _no_q[j]; | |
| 894 | |||
| 895 | 47144862 | FUNC(loop_filter_chroma_weak)(pix, xstride, ystride, size, tc, no_p, no_q); | |
| 896 | } | ||
| 897 | } | ||
| 898 | 26199108 | } | |
| 899 | |||
| 900 | 12803726 | static void FUNC(hevc_h_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride, | |
| 901 | const int32_t *tc, const uint8_t *no_p, | ||
| 902 | const uint8_t *no_q) | ||
| 903 | { | ||
| 904 | 12803726 | FUNC(hevc_loop_filter_chroma)(pix, stride, sizeof(pixel), tc, no_p, no_q); | |
| 905 | 12803726 | } | |
| 906 | |||
| 907 | 13395382 | static void FUNC(hevc_v_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride, | |
| 908 | const int32_t *tc, const uint8_t *no_p, | ||
| 909 | const uint8_t *no_q) | ||
| 910 | { | ||
| 911 | 13395382 | FUNC(hevc_loop_filter_chroma)(pix, sizeof(pixel), stride, tc, no_p, no_q); | |
| 912 | 13395382 | } | |
| 913 | |||
| 914 | 43280626 | static void FUNC(hevc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride, | |
| 915 | int beta, const int32_t *tc, const uint8_t *no_p, | ||
| 916 | const uint8_t *no_q) | ||
| 917 | { | ||
| 918 | 43280626 | FUNC(hevc_loop_filter_luma)(pix, stride, sizeof(pixel), | |
| 919 | beta, tc, no_p, no_q); | ||
| 920 | 43280626 | } | |
| 921 | |||
| 922 | 42565466 | static void FUNC(hevc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride, | |
| 923 | int beta, const int32_t *tc, const uint8_t *no_p, | ||
| 924 | const uint8_t *no_q) | ||
| 925 | { | ||
| 926 | 42565466 | FUNC(hevc_loop_filter_luma)(pix, sizeof(pixel), stride, | |
| 927 | beta, tc, no_p, no_q); | ||
| 928 | 42565466 | } | |
| 929 | |||
| 930 | #undef P3 | ||
| 931 | #undef P2 | ||
| 932 | #undef P1 | ||
| 933 | #undef P0 | ||
| 934 | #undef Q0 | ||
| 935 | #undef Q1 | ||
| 936 | #undef Q2 | ||
| 937 | #undef Q3 | ||
| 938 | |||
| 939 | #undef TP3 | ||
| 940 | #undef TP2 | ||
| 941 | #undef TP1 | ||
| 942 | #undef TP0 | ||
| 943 | #undef TQ0 | ||
| 944 | #undef TQ1 | ||
| 945 | #undef TQ2 | ||
| 946 | #undef TQ3 | ||
| 947 |