FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/avformat_internal.h
Date: 2024-11-20 23:03:26
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
99 #if FF_API_LAVF_SHORTEST
100 /**
101 * Timestamp of the end of the shortest stream.
102 */
103 int64_t shortest_end;
104 #endif
105 } FormatContextInternal;
106
107 5983778 static av_always_inline FormatContextInternal *ff_fc_internal(AVFormatContext *s)
108 {
109 5983778 return (FormatContextInternal*)s;
110 }
111
112 #define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48))
113
114 1661546 static av_always_inline int is_relative(int64_t ts)
115 {
116 1661546 return ts > (RELATIVE_TS_BASE - (1LL << 48));
117 }
118
119 /**
120 * Wrap a given time stamp, if there is an indication for an overflow
121 *
122 * @param st stream
123 * @param timestamp the time stamp to wrap
124 * @return resulting time stamp
125 */
126 int64_t ff_wrap_timestamp(const AVStream *st, int64_t timestamp);
127
128 typedef struct FFStreamGroup {
129 /**
130 * The public context.
131 */
132 AVStreamGroup pub;
133
134 AVFormatContext *fmtctx;
135 } FFStreamGroup;
136
137 static av_always_inline FFStreamGroup *ffstreamgroup(AVStreamGroup *stg)
138 {
139 return (FFStreamGroup*)stg;
140 }
141
142 330 static av_always_inline const FFStreamGroup *cffstreamgroup(const AVStreamGroup *stg)
143 {
144 330 return (const FFStreamGroup*)stg;
145 }
146
147 void ff_flush_packet_queue(AVFormatContext *s);
148
149 const struct AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st,
150 enum AVCodecID codec_id);
151
152 /**
153 * Frees a stream 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(AVStream **st);
158
159 /**
160 * Frees a stream group without modifying the corresponding AVFormatContext.
161 * Must only be called if the latter doesn't matter or if the stream
162 * is not yet attached to an AVFormatContext.
163 */
164 void ff_free_stream_group(AVStreamGroup **pstg);
165
166 int ff_is_intra_only(enum AVCodecID id);
167
168 struct FFOutputFormat;
169 struct FFInputFormat;
170 void avpriv_register_devices(const struct FFOutputFormat * const o[],
171 const struct FFInputFormat * const i[]);
172
173 #endif // AVFORMAT_AVFORMAT_INTERNAL_H
174