FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/v210enc_init.h
Date: 2024-04-23 16:28:37
Exec Total Coverage
Lines: 25 25 100.0%
Functions: 3 3 100.0%
Branches: 4 4 100.0%

Line Branch Exec Source
1 /*
2 * V210 encoder DSP init
3 *
4 * Copyright (C) 2009 Michael Niedermayer <michaelni@gmx.at>
5 * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #ifndef AVCODEC_V210ENC_INIT_H
25 #define AVCODEC_V210ENC_INIT_H
26
27 #include <stddef.h>
28 #include <stdint.h>
29
30 #include "config.h"
31 #include "libavutil/attributes.h"
32 #include "libavutil/common.h"
33 #include "libavutil/intreadwrite.h"
34 #include "v210enc.h"
35
36 #define CLIP(v, depth) av_clip(v, 1<<(depth-8), ((1<<depth)-(1<<(depth-8))-1))
37 #define WRITE_PIXELS(a, b, c, depth) \
38 do { \
39 val = CLIP(*a++, depth) << (10-depth); \
40 val |= (CLIP(*b++, depth) << (20-depth)) | \
41 (CLIP(*c++, depth) << (30-depth)); \
42 AV_WL32(dst, val); \
43 dst += 4; \
44 } while (0)
45
46 45023 static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u,
47 const uint8_t *v, uint8_t *dst,
48 ptrdiff_t width)
49 {
50 uint32_t val;
51
52 /* unroll this to match the assembly */
53
2/2
✓ Branch 0 taken 1258783 times.
✓ Branch 1 taken 45023 times.
1303806 for (int i = 0; i < width - 11; i += 12) {
54 1258783 WRITE_PIXELS(u, y, v, 8);
55 1258783 WRITE_PIXELS(y, u, y, 8);
56 1258783 WRITE_PIXELS(v, y, u, 8);
57 1258783 WRITE_PIXELS(y, v, y, 8);
58 1258783 WRITE_PIXELS(u, y, v, 8);
59 1258783 WRITE_PIXELS(y, u, y, 8);
60 1258783 WRITE_PIXELS(v, y, u, 8);
61 1258783 WRITE_PIXELS(y, v, y, 8);
62 }
63 45023 }
64
65 45146 static void v210_planar_pack_10_c(const uint16_t *y, const uint16_t *u,
66 const uint16_t *v, uint8_t *dst,
67 ptrdiff_t width)
68 {
69 uint32_t val;
70
71
2/2
✓ Branch 0 taken 2524309 times.
✓ Branch 1 taken 45146 times.
2569455 for (int i = 0; i < width - 5; i += 6) {
72 2524309 WRITE_PIXELS(u, y, v, 10);
73 2524309 WRITE_PIXELS(y, u, y, 10);
74 2524309 WRITE_PIXELS(v, y, u, 10);
75 2524309 WRITE_PIXELS(y, v, y, 10);
76 }
77 45146 }
78
79 21 static av_cold av_unused void ff_v210enc_init(V210EncContext *s)
80 {
81 21 s->pack_line_8 = v210_planar_pack_8_c;
82 21 s->pack_line_10 = v210_planar_pack_10_c;
83 21 s->sample_factor_8 = 2;
84 21 s->sample_factor_10 = 1;
85
86 #if ARCH_X86
87 21 ff_v210enc_init_x86(s);
88 #endif
89 21 }
90
91 #endif /* AVCODEC_V210ENC_INIT_H */
92