FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vvc/dsp_template.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 48 48 100.0%
Functions: 9 15 60.0%
Branches: 22 22 100.0%

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 1755752 static void FUNC(add_residual)(uint8_t *_dst, const int *res,
33 const int w, const int h, const ptrdiff_t _stride)
34 {
35 1755752 pixel *dst = (pixel *)_dst;
36
37 1755752 const int stride = _stride / sizeof(pixel);
38
39
2/2
✓ Branch 0 taken 9186046 times.
✓ Branch 1 taken 877876 times.
20127844 for (int y = 0; y < h; y++) {
40
2/2
✓ Branch 0 taken 158259568 times.
✓ Branch 1 taken 9186046 times.
334891228 for (int x = 0; x < w; x++) {
41 316519136 dst[x] = av_clip_pixel(dst[x] + *res);
42 316519136 res++;
43 }
44 18372092 dst += stride;
45 }
46 1755752 }
47
48 37340 static void FUNC(add_residual_joint)(uint8_t *_dst, const int *res,
49 const int w, const int h, const ptrdiff_t _stride, const int c_sign, const int shift)
50 {
51 37340 pixel *dst = (pixel *)_dst;
52
53 37340 const int stride = _stride / sizeof(pixel);
54
55
2/2
✓ Branch 0 taken 183832 times.
✓ Branch 1 taken 18670 times.
405004 for (int y = 0; y < h; y++) {
56
2/2
✓ Branch 0 taken 3021744 times.
✓ Branch 1 taken 183832 times.
6411152 for (int x = 0; x < w; x++) {
57 6043488 const int r = ((*res) * c_sign) >> shift;
58 6043488 dst[x] = av_clip_pixel(dst[x] + r);
59 6043488 res++;
60 }
61 367664 dst += stride;
62 }
63 37340 }
64
65 29314 static void FUNC(pred_residual_joint)(int *buf, const int w, const int h,
66 const int c_sign, const int shift)
67 {
68
2/2
✓ Branch 0 taken 124218 times.
✓ Branch 1 taken 14657 times.
277750 for (int y = 0; y < h; y++) {
69
2/2
✓ Branch 0 taken 1373264 times.
✓ Branch 1 taken 124218 times.
2994964 for (int x = 0; x < w; x++) {
70 2746528 *buf = ((*buf) * c_sign) >> shift;
71 2746528 buf++;
72 }
73 }
74 29314 }
75
76 20 static void FUNC(transform_bdpcm)(int *coeffs, const int width, const int height,
77 const int vertical, const int log2_transform_range)
78 {
79 int x, y;
80
81
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
20 if (vertical) {
82 8 coeffs += width;
83
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 4 times.
56 for (y = 0; y < height - 1; y++) {
84
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 24 times.
312 for (x = 0; x < width; x++)
85 264 coeffs[x] = av_clip_intp2(coeffs[x] + coeffs[x - width], log2_transform_range);
86 48 coeffs += width;
87 }
88 } else {
89
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 6 times.
84 for (y = 0; y < height; y++) {
90
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 36 times.
352 for (x = 1; x < width; x++)
91 280 coeffs[x] = av_clip_intp2(coeffs[x] + coeffs[x - 1], log2_transform_range);
92 72 coeffs += width;
93 }
94 }
95 20 }
96
97 2600 static void FUNC(ff_vvc_itx_dsp_init)(VVCItxDSPContext *const itx)
98 {
99 #define VVC_ITX(TYPE, type, s) \
100 itx->itx[VVC_##TYPE][VVC_##TX_SIZE_##s] = ff_vvc_inv_##type##_##s; \
101
102 #define VVC_ITX_COMMON(TYPE, type) \
103 VVC_ITX(TYPE, type, 4); \
104 VVC_ITX(TYPE, type, 8); \
105 VVC_ITX(TYPE, type, 16); \
106 VVC_ITX(TYPE, type, 32);
107
108 2600 itx->add_residual = FUNC(add_residual);
109 2600 itx->add_residual_joint = FUNC(add_residual_joint);
110 2600 itx->pred_residual_joint = FUNC(pred_residual_joint);
111 2600 itx->transform_bdpcm = FUNC(transform_bdpcm);
112 2600 VVC_ITX(DCT2, dct2, 2)
113 2600 VVC_ITX(DCT2, dct2, 64)
114 2600 VVC_ITX_COMMON(DCT2, dct2)
115 2600 VVC_ITX_COMMON(DCT8, dct8)
116 2600 VVC_ITX_COMMON(DST7, dst7)
117
118 #undef VVC_ITX
119 #undef VVC_ITX_COMMON
120 2600 }
121