FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/colorspacedsp_yuv2yuv_template.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 38 38 100.0%
Functions: 27 27 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/avassert.h"
22
23 #undef opixel
24 #define opixel pixel
25
26 #undef ipixel
27 #if IN_BIT_DEPTH == 8
28 #define ipixel uint8_t
29 #else
30 #define ipixel uint16_t
31 #endif
32
33 #undef fn
34 #undef fn2
35 #undef fn3
36 #define fn3(a,b,c,d) a##_##d##p##b##to##c##_c
37 #define fn2(a,b,c,d) fn3(a,b,c,d)
38 #define fn(a) fn2(a, IN_BIT_DEPTH, OUT_BIT_DEPTH, ss)
39
40 162 static void fn(yuv2yuv)(uint8_t *_dst[3], const ptrdiff_t dst_stride[3],
41 uint8_t *_src[3], const ptrdiff_t src_stride[3],
42 int w, int h, const int16_t c[3][3][8],
43 const int16_t yuv_offset[2][8])
44 {
45 162 opixel **dst = (opixel **) _dst;
46 162 ipixel **src = (ipixel **) _src;
47 162 const ipixel *src0 = src[0], *src1 = src[1], *src2 = src[2];
48 162 opixel *dst0 = dst[0], *dst1 = dst[1], *dst2 = dst[2];
49 int y, x;
50 162 const int sh = 14 + IN_BIT_DEPTH - OUT_BIT_DEPTH;
51 162 const int rnd = 1 << (sh - 1);
52 162 int y_off_in = yuv_offset[0][0];
53 162 int y_off_out = yuv_offset[1][0] << sh;
54 162 const int uv_off_in = 128 << (IN_BIT_DEPTH - 8);
55 162 const int uv_off_out = rnd + (128 << (OUT_BIT_DEPTH - 8 + sh));
56 162 int cyy = c[0][0][0], cyu = c[0][1][0], cyv = c[0][2][0];
57 162 int cuu = c[1][1][0], cuv = c[1][2][0], cvu = c[2][1][0], cvv = c[2][2][0];
58
59 av_assert2(c[1][0][0] == 0);
60 av_assert2(c[2][0][0] == 0);
61 162 w = AV_CEIL_RSHIFT(w, SS_W);
62 162 h = AV_CEIL_RSHIFT(h, SS_H);
63
2/2
✓ Branch 0 taken 4320 times.
✓ Branch 1 taken 81 times.
8802 for (y = 0; y < h; y++) {
64
2/2
✓ Branch 0 taken 193536 times.
✓ Branch 1 taken 4320 times.
395712 for (x = 0; x < w; x++) {
65 387072 int y00 = src0[x << SS_W] - y_off_in;
66 #if SS_W == 1
67 165888 int y01 = src0[2 * x + 1] - y_off_in;
68 #if SS_H == 1
69 55296 int y10 = src0[src_stride[0] / sizeof(ipixel) + 2 * x] - y_off_in;
70 55296 int y11 = src0[src_stride[0] / sizeof(ipixel) + 2 * x + 1] - y_off_in;
71 #endif
72 #endif
73 387072 int u = src1[x] - uv_off_in, v = src2[x] - uv_off_in;
74 387072 int uv_val = cyu * u + cyv * v + rnd + y_off_out;
75
76 387072 dst0[x << SS_W] = av_clip_pixel((cyy * y00 + uv_val) >> sh);
77 #if SS_W == 1
78 165888 dst0[x * 2 + 1] = av_clip_pixel((cyy * y01 + uv_val) >> sh);
79 #if SS_H == 1
80 55296 dst0[x * 2 + 0 + dst_stride[0] / sizeof(opixel)] =
81 55296 av_clip_pixel((cyy * y10 + uv_val) >> sh);
82 55296 dst0[x * 2 + 1 + dst_stride[0] / sizeof(opixel)] =
83 55296 av_clip_pixel((cyy * y11 + uv_val) >> sh);
84 #endif
85 #endif
86
87 387072 dst1[x] = av_clip_pixel((u * cuu + v * cuv + uv_off_out) >> sh);
88 387072 dst2[x] = av_clip_pixel((u * cvu + v * cvv + uv_off_out) >> sh);
89 }
90
91 8640 dst0 += (dst_stride[0] * (1 << SS_H)) / sizeof(opixel);
92 8640 dst1 += dst_stride[1] / sizeof(opixel);
93 8640 dst2 += dst_stride[2] / sizeof(opixel);
94 8640 src0 += (src_stride[0] * (1 << SS_H)) / sizeof(ipixel);
95 8640 src1 += src_stride[1] / sizeof(ipixel);
96 8640 src2 += src_stride[2] / sizeof(ipixel);
97 }
98 162 }
99