FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libswscale/utils.h
Date: 2024-10-27 21:33:06
Exec Total Coverage
Lines: 0 10 0.0%
Functions: 0 1 0.0%
Branches: 0 18 0.0%

Line Branch Exec Source
1 /*
2 * Copyright (C) 2024 Niklas Haas
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 #ifndef SWSCALE_UTILS_H
22 #define SWSCALE_UTILS_H
23
24 #include "libavutil/pixdesc.h"
25
26 #include "swscale.h"
27
28 enum {
29 FIELD_TOP, /* top/even rows, or progressive */
30 FIELD_BOTTOM, /* bottom/odd rows */
31 };
32
33 /* Subset of AVFrame parameters that uniquely determine pixel representation */
34 typedef struct SwsFormat {
35 int width, height;
36 int interlaced;
37 enum AVPixelFormat format;
38 enum AVColorRange range;
39 enum AVColorPrimaries prim;
40 enum AVColorTransferCharacteristic trc;
41 enum AVColorSpace csp;
42 enum AVChromaLocation loc;
43 const AVPixFmtDescriptor *desc; /* convenience */
44 } SwsFormat;
45
46 /**
47 * This function also sanitizes and strips the input data, removing irrelevant
48 * fields for certain formats.
49 */
50 SwsFormat ff_fmt_from_frame(const AVFrame *frame, int field);
51
52 static inline int ff_fmt_equal(const SwsFormat *fmt1, const SwsFormat *fmt2)
53 {
54 return fmt1->width == fmt2->width &&
55 fmt1->height == fmt2->height &&
56 fmt1->interlaced == fmt2->interlaced &&
57 fmt1->format == fmt2->format &&
58 fmt1->range == fmt2->range &&
59 fmt1->prim == fmt2->prim &&
60 fmt1->trc == fmt2->trc &&
61 fmt1->csp == fmt2->csp &&
62 fmt1->loc == fmt2->loc;
63 }
64
65 static inline int ff_fmt_align(enum AVPixelFormat fmt)
66 {
67 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
68 if (desc->flags & AV_PIX_FMT_FLAG_BAYER) {
69 return 2;
70 } else {
71 return 1 << desc->log2_chroma_h;
72 }
73 }
74
75 int ff_test_fmt(const SwsFormat *fmt, int output);
76
77 #endif /* SWSCALE_UTILS_H */
78