FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/avformat_internal.h
Date: 2025-04-25 22:50:00
Exec Total Coverage
Lines: 6 6 100.0%
Functions: 3 3 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 /*
20 * APIs internal to the generic avformat layer.
21 *
22 * MUST NOT be included by individual muxers or demuxers.
23 */
24
25 #ifndef AVFORMAT_AVFORMAT_INTERNAL_H
26 #define AVFORMAT_AVFORMAT_INTERNAL_H
27
28 #include <stdint.h>
29
30 #include "avformat.h"
31 #include "internal.h"
32
33 typedef struct FormatContextInternal {
34 FFFormatContext fc;
35
36 union {
37 // muxing only
38 struct {
39 /**
40 * Whether or not avformat_init_output has already been called
41 */
42 int initialized;
43
44 /**
45 * Whether or not avformat_init_output fully initialized streams
46 */
47 int streams_initialized;
48
49
50 /**
51 * Number of streams relevant for interleaving.
52 * Muxing only.
53 */
54 int nb_interleaved_streams;
55
56 /**
57 * The interleavement function in use. Always set.
58 */
59 int (*interleave_packet)(struct AVFormatContext *s, AVPacket *pkt,
60 int flush, int has_packet);
61
62 #if FF_API_COMPUTE_PKT_FIELDS2
63 int missing_ts_warning;
64 #endif
65 };
66
67 // demuxing only
68 struct {
69 /**
70 * Raw packets from the demuxer, prior to parsing and decoding.
71 * This buffer is used for buffering packets until the codec can
72 * be identified, as parsing cannot be done without knowing the
73 * codec.
74 */
75 PacketList raw_packet_buffer;
76
77 /**
78 * Sum of the size of packets in raw_packet_buffer, in bytes.
79 */
80 int raw_packet_buffer_size;
81
82 /**
83 * Packets split by the parser get queued here.
84 */
85 PacketList parse_queue;
86
87 /**
88 * Contexts and child contexts do not contain a metadata option
89 */
90 int metafree;
91
92 /**
93 * Set if chapter ids are strictly monotonic.
94 */
95 int chapter_ids_monotonic;
96 };
97 };
98 } FormatContextInternal;
99
100 6033736 static av_always_inline FormatContextInternal *ff_fc_internal(AVFormatContext *s)
101 {
102 6033736 return (FormatContextInternal*)s;
103 }
104
105 #define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48))
106
107 1671555 static av_always_inline int is_relative(int64_t ts)
108 {
109 1671555 return ts > (RELATIVE_TS_BASE - (1LL << 48));
110 }
111
112 /**
113 * Wrap a given time stamp, if there is an indication for an overflow
114 *
115 * @param st stream
116 * @param timestamp the time stamp to wrap
117 * @return resulting time stamp
118 */
119 int64_t ff_wrap_timestamp(const AVStream *st, int64_t timestamp);
120
121 typedef struct FFStreamGroup {
122 /**
123 * The public context.
124 */
125 AVStreamGroup pub;
126
127 AVFormatContext *fmtctx;
128 } FFStreamGroup;
129
130 static av_always_inline FFStreamGroup *ffstreamgroup(AVStreamGroup *stg)
131 {
132 return (FFStreamGroup*)stg;
133 }
134
135 389 static av_always_inline const FFStreamGroup *cffstreamgroup(const AVStreamGroup *stg)
136 {
137 389 return (const FFStreamGroup*)stg;
138 }
139
140 void ff_flush_packet_queue(AVFormatContext *s);
141
142 const struct AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st,
143 enum AVCodecID codec_id);
144
145 /**
146 * Frees a stream without modifying the corresponding AVFormatContext.
147 * Must only be called if the latter doesn't matter or if the stream
148 * is not yet attached to an AVFormatContext.
149 */
150 void ff_free_stream(AVStream **st);
151
152 /**
153 * Frees a stream group without modifying the corresponding AVFormatContext.
154 * Must only be called if the latter doesn't matter or if the stream
155 * is not yet attached to an AVFormatContext.
156 */
157 void ff_free_stream_group(AVStreamGroup **pstg);
158
159 int ff_is_intra_only(enum AVCodecID id);
160
161 struct FFOutputFormat;
162 struct FFInputFormat;
163 void avpriv_register_devices(const struct FFOutputFormat * const o[],
164 const struct FFInputFormat * const i[]);
165
166 #endif // AVFORMAT_AVFORMAT_INTERNAL_H
167