FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/colorspacedsp.c
Date: 2024-04-16 15:12:51
Exec Total Coverage
Lines: 31 31 100.0%
Functions: 2 2 100.0%
Branches: 4 4 100.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2016 Ronald S. Bultje <rsbultje@gmail.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "libavutil/common.h"
22 #include "colorspacedsp.h"
23
24 /*
25 * SS_W/H stands for "subsampling_w/h"
26 * it's analogous to AVPixFmtDescriptor->log2_chroma_w/h.
27 */
28 #define SS_W 0
29 #define SS_H 0
30
31 #define BIT_DEPTH 8
32 #include "colorspacedsp_template.c"
33
34 #undef BIT_DEPTH
35 #define BIT_DEPTH 10
36 #include "colorspacedsp_template.c"
37
38 #undef BIT_DEPTH
39 #define BIT_DEPTH 12
40 #include "colorspacedsp_template.c"
41
42 #undef SS_W
43 #undef SS_H
44
45 #define SS_W 1
46 #define SS_H 0
47
48 #undef BIT_DEPTH
49 #define BIT_DEPTH 8
50 #include "colorspacedsp_template.c"
51
52 #undef BIT_DEPTH
53 #define BIT_DEPTH 10
54 #include "colorspacedsp_template.c"
55
56 #undef BIT_DEPTH
57 #define BIT_DEPTH 12
58 #include "colorspacedsp_template.c"
59
60 #undef SS_W
61 #undef SS_H
62
63 #define SS_W 1
64 #define SS_H 1
65
66 #undef BIT_DEPTH
67 #define BIT_DEPTH 8
68 #include "colorspacedsp_template.c"
69
70 #undef BIT_DEPTH
71 #define BIT_DEPTH 10
72 #include "colorspacedsp_template.c"
73
74 #undef BIT_DEPTH
75 #define BIT_DEPTH 12
76 #include "colorspacedsp_template.c"
77
78 3 static void multiply3x3_c(int16_t *buf[3], ptrdiff_t stride,
79 int w, int h, const int16_t m[3][3][8])
80 {
81 int y, x;
82 3 int16_t *buf0 = buf[0], *buf1 = buf[1], *buf2 = buf[2];
83
84
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 3 times.
195 for (y = 0; y < h; y++) {
85
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 192 times.
12480 for (x = 0; x < w; x++) {
86 12288 int v0 = buf0[x], v1 = buf1[x], v2 = buf2[x];
87
88 12288 buf0[x] = av_clip_int16((m[0][0][0] * v0 + m[0][1][0] * v1 +
89 12288 m[0][2][0] * v2 + 8192) >> 14);
90 12288 buf1[x] = av_clip_int16((m[1][0][0] * v0 + m[1][1][0] * v1 +
91 12288 m[1][2][0] * v2 + 8192) >> 14);
92 12288 buf2[x] = av_clip_int16((m[2][0][0] * v0 + m[2][1][0] * v1 +
93 12288 m[2][2][0] * v2 + 8192) >> 14);
94 }
95
96 192 buf0 += stride;
97 192 buf1 += stride;
98 192 buf2 += stride;
99 }
100 3 }
101
102 52 void ff_colorspacedsp_init(ColorSpaceDSPContext *dsp)
103 {
104 #define init_yuv2rgb_fn(bit) \
105 dsp->yuv2rgb[BPP_##bit][SS_444] = yuv2rgb_444p##bit##_c; \
106 dsp->yuv2rgb[BPP_##bit][SS_422] = yuv2rgb_422p##bit##_c; \
107 dsp->yuv2rgb[BPP_##bit][SS_420] = yuv2rgb_420p##bit##_c
108
109 52 init_yuv2rgb_fn( 8);
110 52 init_yuv2rgb_fn(10);
111 52 init_yuv2rgb_fn(12);
112
113 #define init_rgb2yuv_fn(bit) \
114 dsp->rgb2yuv[BPP_##bit][SS_444] = rgb2yuv_444p##bit##_c; \
115 dsp->rgb2yuv[BPP_##bit][SS_422] = rgb2yuv_422p##bit##_c; \
116 dsp->rgb2yuv[BPP_##bit][SS_420] = rgb2yuv_420p##bit##_c
117
118 52 init_rgb2yuv_fn( 8);
119 52 init_rgb2yuv_fn(10);
120 52 init_rgb2yuv_fn(12);
121
122 #define init_rgb2yuv_fsb_fn(bit) \
123 dsp->rgb2yuv_fsb[BPP_##bit][SS_444] = rgb2yuv_fsb_444p##bit##_c; \
124 dsp->rgb2yuv_fsb[BPP_##bit][SS_422] = rgb2yuv_fsb_422p##bit##_c; \
125 dsp->rgb2yuv_fsb[BPP_##bit][SS_420] = rgb2yuv_fsb_420p##bit##_c
126
127 52 init_rgb2yuv_fsb_fn( 8);
128 52 init_rgb2yuv_fsb_fn(10);
129 52 init_rgb2yuv_fsb_fn(12);
130
131 #define init_yuv2yuv_fn(idx1, bit1, bit2) \
132 dsp->yuv2yuv[idx1][BPP_##bit2][SS_444] = yuv2yuv_444p##bit1##to##bit2##_c; \
133 dsp->yuv2yuv[idx1][BPP_##bit2][SS_422] = yuv2yuv_422p##bit1##to##bit2##_c; \
134 dsp->yuv2yuv[idx1][BPP_##bit2][SS_420] = yuv2yuv_420p##bit1##to##bit2##_c
135 #define init_yuv2yuv_fns(bit1) \
136 init_yuv2yuv_fn(BPP_##bit1, bit1, 8); \
137 init_yuv2yuv_fn(BPP_##bit1, bit1, 10); \
138 init_yuv2yuv_fn(BPP_##bit1, bit1, 12)
139
140 52 init_yuv2yuv_fns( 8);
141 52 init_yuv2yuv_fns(10);
142 52 init_yuv2yuv_fns(12);
143
144 52 dsp->multiply3x3 = multiply3x3_c;
145
146 #if ARCH_X86
147 52 ff_colorspacedsp_x86_init(dsp);
148 #endif
149 52 }
150