FFmpeg
avformat_internal.h
Go to the documentation of this file.
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 {
35 
36  union {
37  // muxing only
38  struct {
39  /**
40  * Whether or not avformat_init_output has already been called
41  */
43 
44  /**
45  * Whether or not avformat_init_output fully initialized streams
46  */
48 
49 
50  /**
51  * Number of streams relevant for interleaving.
52  * Muxing only.
53  */
55 
56  /**
57  * The interleavement function in use. Always set.
58  */
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  */
76 
77  /**
78  * Sum of the size of packets in raw_packet_buffer, in bytes.
79  */
81 
82  /**
83  * Packets split by the parser get queued here.
84  */
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  */
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
106 
108 {
109  return (FormatContextInternal*)s;
110 }
111 
112 #define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48))
113 
115 {
116  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  */
133 
135 } FFStreamGroup;
136 
138 {
139  return (FFStreamGroup*)stg;
140 }
141 
143 {
144  return (const FFStreamGroup*)stg;
145 }
146 
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  */
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
AVCodec
AVCodec.
Definition: codec.h:187
is_relative
static av_always_inline int is_relative(int64_t ts)
Definition: avformat_internal.h:114
avpriv_register_devices
void avpriv_register_devices(const struct FFOutputFormat *const o[], const struct FFInputFormat *const i[])
int64_t
long long int64_t
Definition: coverity.c:34
FormatContextInternal::raw_packet_buffer
PacketList raw_packet_buffer
Raw packets from the demuxer, prior to parsing and decoding.
Definition: avformat_internal.h:75
PacketList
Definition: packet_internal.h:33
FormatContextInternal::metafree
int metafree
Contexts and child contexts do not contain a metadata option.
Definition: avformat_internal.h:90
FormatContextInternal
Definition: avformat_internal.h:33
ff_wrap_timestamp
int64_t ff_wrap_timestamp(const AVStream *st, int64_t timestamp)
Wrap a given time stamp, if there is an indication for an overflow.
Definition: demux.c:68
FormatContextInternal::streams_initialized
int streams_initialized
Whether or not avformat_init_output fully initialized streams.
Definition: avformat_internal.h:47
pkt
AVPacket * pkt
Definition: movenc.c:60
ff_find_decoder
const struct AVCodec * ff_find_decoder(AVFormatContext *s, const AVStream *st, enum AVCodecID codec_id)
Definition: avformat.c:894
s
#define s(width, name)
Definition: cbs_vp9.c:198
FFStreamGroup::fmtctx
AVFormatContext * fmtctx
Definition: avformat_internal.h:134
ff_is_intra_only
int ff_is_intra_only(enum AVCodecID id)
Definition: avformat.c:940
RELATIVE_TS_BASE
#define RELATIVE_TS_BASE
Definition: avformat_internal.h:112
codec_id
enum AVCodecID codec_id
Definition: vaapi_decode.c:410
FormatContextInternal::interleave_packet
int(* interleave_packet)(struct AVFormatContext *s, AVPacket *pkt, int flush, int has_packet)
The interleavement function in use.
Definition: avformat_internal.h:59
FFFormatContext
Definition: internal.h:64
AVFormatContext
Format I/O context.
Definition: avformat.h:1300
internal.h
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts.c:370
FFOutputFormat
Definition: mux.h:61
FormatContextInternal::fc
FFFormatContext fc
Definition: avformat_internal.h:34
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:49
FormatContextInternal::raw_packet_buffer_size
int raw_packet_buffer_size
Sum of the size of packets in raw_packet_buffer, in bytes.
Definition: avformat_internal.h:80
ffstreamgroup
static av_always_inline FFStreamGroup * ffstreamgroup(AVStreamGroup *stg)
Definition: avformat_internal.h:137
ff_free_stream
void ff_free_stream(AVStream **st)
Frees a stream without modifying the corresponding AVFormatContext.
Definition: avformat.c:45
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
ff_free_stream_group
void ff_free_stream_group(AVStreamGroup **pstg)
Frees a stream group without modifying the corresponding AVFormatContext.
Definition: avformat.c:84
av_always_inline
#define av_always_inline
Definition: attributes.h:49
FormatContextInternal::nb_interleaved_streams
int nb_interleaved_streams
Number of streams relevant for interleaving.
Definition: avformat_internal.h:54
ff_flush_packet_queue
void ff_flush_packet_queue(AVFormatContext *s)
Definition: avformat.c:138
AVStream
Stream structure.
Definition: avformat.h:748
avformat.h
FFStreamGroup::pub
AVStreamGroup pub
The public context.
Definition: avformat_internal.h:132
AVStreamGroup
Definition: avformat.h:1134
FormatContextInternal::chapter_ids_monotonic
int chapter_ids_monotonic
Set if chapter ids are strictly monotonic.
Definition: avformat_internal.h:95
ff_fc_internal
static av_always_inline FormatContextInternal * ff_fc_internal(AVFormatContext *s)
Definition: avformat_internal.h:107
AVPacket
This structure stores compressed data.
Definition: packet.h:516
FFInputFormat
Definition: demux.h:42
FFStreamGroup
Definition: avformat_internal.h:128
FormatContextInternal::parse_queue
PacketList parse_queue
Packets split by the parser get queued here.
Definition: avformat_internal.h:85
FormatContextInternal::initialized
int initialized
Whether or not avformat_init_output has already been called.
Definition: avformat_internal.h:42
cffstreamgroup
static const av_always_inline FFStreamGroup * cffstreamgroup(const AVStreamGroup *stg)
Definition: avformat_internal.h:142