2 * This file is part of FFmpeg.
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.
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.
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
20 * APIs internal to the generic avformat layer.
22 * MUST NOT be included by individual muxers or demuxers.
25 #ifndef AVFORMAT_AVFORMAT_INTERNAL_H
26 #define AVFORMAT_AVFORMAT_INTERNAL_H
33 typedef struct FormatContextInternal
{
40 * Whether or not avformat_init_output has already been called
45 * Whether or not avformat_init_output fully initialized streams
47 int streams_initialized
;
51 * Number of streams relevant for interleaving.
54 int nb_interleaved_streams
;
57 * The interleavement function in use. Always set.
59 int (*interleave_packet
)(struct AVFormatContext
*s
, AVPacket
*pkt
,
60 int flush
, int has_packet
);
62 #if FF_API_COMPUTE_PKT_FIELDS2
63 int missing_ts_warning
;
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
75 PacketList raw_packet_buffer
;
78 * Sum of the size of packets in raw_packet_buffer, in bytes.
80 int raw_packet_buffer_size
;
83 * Packets split by the parser get queued here.
85 PacketList parse_queue
;
88 * Contexts and child contexts do not contain a metadata option
93 * Set if chapter ids are strictly monotonic.
95 int chapter_ids_monotonic
;
98 } FormatContextInternal
;
100 static av_always_inline FormatContextInternal
*ff_fc_internal(AVFormatContext
*s
)
102 return (FormatContextInternal
*)s
;
105 #define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48))
107 static av_always_inline
int is_relative(int64_t ts
)
109 return ts
> (RELATIVE_TS_BASE
- (1LL << 48));
113 * Wrap a given time stamp, if there is an indication for an overflow
116 * @param timestamp the time stamp to wrap
117 * @return resulting time stamp
119 int64_t ff_wrap_timestamp(const AVStream
*st
, int64_t timestamp
);
121 typedef struct FFStreamGroup
{
123 * The public context.
127 AVFormatContext
*fmtctx
;
130 static av_always_inline FFStreamGroup
*ffstreamgroup(AVStreamGroup
*stg
)
132 return (FFStreamGroup
*)stg
;
135 static av_always_inline
const FFStreamGroup
*cffstreamgroup(const AVStreamGroup
*stg
)
137 return (const FFStreamGroup
*)stg
;
140 void ff_flush_packet_queue(AVFormatContext
*s
);
142 const struct AVCodec
*ff_find_decoder(AVFormatContext
*s
, const AVStream
*st
,
143 enum AVCodecID codec_id
);
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.
150 void ff_free_stream(AVStream
**st
);
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.
157 void ff_free_stream_group(AVStreamGroup
**pstg
);
159 int ff_is_intra_only(enum AVCodecID id
);
161 struct FFOutputFormat
;
162 struct FFInputFormat
;
163 void avpriv_register_devices(const struct FFOutputFormat
* const o
[],
164 const struct FFInputFormat
* const i
[]);
166 #endif // AVFORMAT_AVFORMAT_INTERNAL_H