../../../ffmpeg/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
85 / 147
57.8%
Branches:
24 / 54
44.4%
Functions:
9 / 15
60.0%

libavcodec/vvc/dsp_template.c
Line Branch Exec Source
1 /*
2 * VVC transform and residual DSP
3 *
4 * Copyright (C) 2021 Nuo Mi
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22 #include "libavutil/frame.h"
23 #include "libavcodec/bit_depth_template.c"
24
25 #include "dec.h"
26 #include "data.h"
27
28 #include "inter_template.c"
29 #include "intra_template.c"
30 #include "filter_template.c"
31
32 1294034 static void FUNC(add_residual)(uint8_t *_dst, const int *res,
33 const int w, const int h, const ptrdiff_t _stride)
34 {
35 1294034 pixel *dst = (pixel *)_dst;
36
37 1294034 const int stride = _stride / sizeof(pixel);
38
39
4/6
add_residual_10:
✓ Branch 7 → 3 taken 12958552 times.
✓ Branch 7 → 8 taken 1260818 times.
add_residual_12:
✗ Branch 7 → 3 not taken.
✗ Branch 7 → 8 not taken.
add_residual_8:
✓ Branch 7 → 3 taken 243874 times.
✓ Branch 7 → 8 taken 33216 times.
14496460 for (int y = 0; y < h; y++) {
40
4/6
add_residual_10:
✓ Branch 5 → 4 taken 211067148 times.
✓ Branch 5 → 6 taken 12958552 times.
add_residual_12:
✗ Branch 5 → 4 not taken.
✗ Branch 5 → 6 not taken.
add_residual_8:
✓ Branch 5 → 4 taken 2422608 times.
✓ Branch 5 → 6 taken 243874 times.
226692182 for (int x = 0; x < w; x++) {
41 213489756 dst[x] = av_clip_pixel(dst[x] + *res);
42 213489756 res++;
43 }
44 13202426 dst += stride;
45 }
46 1294034 }
47
48 54924 static void FUNC(pred_residual_joint)(int *dst, const int *src, const int w, const int h,
49 const int c_sign, const int shift)
50 {
51 54924 const int size = w * h;
52
4/6
pred_residual_joint_10:
✓ Branch 4 → 3 taken 6848632 times.
✓ Branch 4 → 5 taken 54682 times.
pred_residual_joint_12:
✗ Branch 4 → 3 not taken.
✗ Branch 4 → 5 not taken.
pred_residual_joint_8:
✓ Branch 4 → 3 taken 21472 times.
✓ Branch 4 → 5 taken 242 times.
6925028 for (int i = 0; i < size; i++)
53 6870104 dst[i] = (src[i] * c_sign) >> shift;
54 54924 }
55
56 3683 static void FUNC(transform_bdpcm)(int *coeffs, const int width, const int height,
57 const int vertical, const int log2_transform_range)
58 {
59 int x, y;
60
61
2/6
transform_bdpcm_10:
✓ Branch 2 → 3 taken 2422 times.
✓ Branch 2 → 9 taken 1261 times.
transform_bdpcm_12:
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 9 not taken.
transform_bdpcm_8:
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 9 not taken.
3683 if (vertical) {
62 2422 coeffs += width;
63
2/6
transform_bdpcm_10:
✓ Branch 8 → 4 taken 22634 times.
✓ Branch 8 → 15 taken 2422 times.
transform_bdpcm_12:
✗ Branch 8 → 4 not taken.
✗ Branch 8 → 15 not taken.
transform_bdpcm_8:
✗ Branch 8 → 4 not taken.
✗ Branch 8 → 15 not taken.
25056 for (y = 0; y < height - 1; y++) {
64
2/6
transform_bdpcm_10:
✓ Branch 6 → 5 taken 220652 times.
✓ Branch 6 → 7 taken 22634 times.
transform_bdpcm_12:
✗ Branch 6 → 5 not taken.
✗ Branch 6 → 7 not taken.
transform_bdpcm_8:
✗ Branch 6 → 5 not taken.
✗ Branch 6 → 7 not taken.
243286 for (x = 0; x < width; x++)
65 220652 coeffs[x] = av_clip_intp2(coeffs[x] + coeffs[x - width], log2_transform_range);
66 22634 coeffs += width;
67 }
68 } else {
69
2/6
transform_bdpcm_10:
✓ Branch 14 → 10 taken 10364 times.
✓ Branch 14 → 15 taken 1261 times.
transform_bdpcm_12:
✗ Branch 14 → 10 not taken.
✗ Branch 14 → 15 not taken.
transform_bdpcm_8:
✗ Branch 14 → 10 not taken.
✗ Branch 14 → 15 not taken.
11625 for (y = 0; y < height; y++) {
70
2/6
transform_bdpcm_10:
✓ Branch 12 → 11 taken 80292 times.
✓ Branch 12 → 13 taken 10364 times.
transform_bdpcm_12:
✗ Branch 12 → 11 not taken.
✗ Branch 12 → 13 not taken.
transform_bdpcm_8:
✗ Branch 12 → 11 not taken.
✗ Branch 12 → 13 not taken.
90656 for (x = 1; x < width; x++)
71 80292 coeffs[x] = av_clip_intp2(coeffs[x] + coeffs[x - 1], log2_transform_range);
72 10364 coeffs += width;
73 }
74 }
75 3683 }
76
77 // 8.7.4.6 Residual modification process for blocks using colour space conversion
78 15154 static void FUNC(adaptive_color_transform)(int *y, int *u, int *v, const int width, const int height)
79 {
80 15154 const int size = width * height;
81 15154 const int bits = BIT_DEPTH + 1;
82
83
2/6
adaptive_color_transform_10:
✓ Branch 4 → 3 taken 3064832 times.
✓ Branch 4 → 5 taken 15154 times.
adaptive_color_transform_12:
✗ Branch 4 → 3 not taken.
✗ Branch 4 → 5 not taken.
adaptive_color_transform_8:
✗ Branch 4 → 3 not taken.
✗ Branch 4 → 5 not taken.
3079986 for (int i = 0; i < size; i++) {
84 3064832 const int y0 = av_clip_intp2(y[i], bits);
85 3064832 const int cg = av_clip_intp2(u[i], bits);
86 3064832 const int co = av_clip_intp2(v[i], bits);
87 3064832 const int t = y0 - (cg >> 1);
88
89 3064832 y[i] = cg + t;
90 3064832 u[i] = t - (co >> 1);
91 3064832 v[i] = co + u[i];
92 }
93 15154 }
94
95 2939 static void FUNC(ff_vvc_itx_dsp_init)(VVCItxDSPContext *const itx)
96 {
97 #define VVC_ITX(TYPE, type, s) \
98 itx->itx[VVC_##TYPE][VVC_##TX_SIZE_##s] = ff_vvc_inv_##type##_##s; \
99
100 #define VVC_ITX_COMMON(TYPE, type) \
101 VVC_ITX(TYPE, type, 4); \
102 VVC_ITX(TYPE, type, 8); \
103 VVC_ITX(TYPE, type, 16); \
104 VVC_ITX(TYPE, type, 32);
105
106 2939 itx->add_residual = FUNC(add_residual);
107 2939 itx->pred_residual_joint = FUNC(pred_residual_joint);
108 2939 itx->transform_bdpcm = FUNC(transform_bdpcm);
109 2939 VVC_ITX(DCT2, dct2, 2)
110 2939 VVC_ITX(DCT2, dct2, 64)
111 2939 VVC_ITX_COMMON(DCT2, dct2)
112 2939 VVC_ITX_COMMON(DCT8, dct8)
113 2939 VVC_ITX_COMMON(DST7, dst7)
114
115 2939 itx->adaptive_color_transform = FUNC(adaptive_color_transform);
116
117 #undef VVC_ITX
118 #undef VVC_ITX_COMMON
119 2939 }
120