Mercurial > libavformat.hg
comparison avformat.h @ 3948:134f8658e2d9 libavformat
spelling/wording/grammar
author | diego |
---|---|
date | Sat, 27 Sep 2008 19:51:53 +0000 |
parents | a324a7aa8a5b |
children | 8d94741841b2 |
comparison
equal
deleted
inserted
replaced
3947:a324a7aa8a5b | 3948:134f8658e2d9 |
---|---|
48 | 48 |
49 /* packet functions */ | 49 /* packet functions */ |
50 | 50 |
51 typedef struct AVPacket { | 51 typedef struct AVPacket { |
52 /** | 52 /** |
53 * Presentation time stamp in time_base units. | 53 * Presentation timestamp in time_base units. |
54 * This is the time at which the decompressed packet will be presented | 54 * This is the time at which the decompressed packet will be presented |
55 * to the user. | 55 * to the user. |
56 * Can be AV_NOPTS_VALUE if it is not stored in the file. | 56 * Can be AV_NOPTS_VALUE if it is not stored in the file. |
57 * pts MUST be larger or equal to dts as presentation can not happen before | 57 * pts MUST be larger or equal to dts as presentation cannot happen before |
58 * decompression, unless one wants to view hex dumps. Some formats misuse | 58 * decompression, unless one wants to view hex dumps. Some formats misuse |
59 * the terms dts and pts/cts to mean something different, these timestamps | 59 * the terms dts and pts/cts to mean something different, these timestamps |
60 * must be converted to true pts/dts before they are stored in AVPacket. | 60 * must be converted to true pts/dts before they are stored in AVPacket. |
61 */ | 61 */ |
62 int64_t pts; | 62 int64_t pts; |
63 /** | 63 /** |
64 * Decompression time stamp in time_base units. | 64 * Decompression timestamp in time_base units. |
65 * This is the time at which the packet is decompressed. | 65 * This is the time at which the packet is decompressed. |
66 * Can be AV_NOPTS_VALUE if it is not stored in the file. | 66 * Can be AV_NOPTS_VALUE if it is not stored in the file. |
67 */ | 67 */ |
68 int64_t dts; | 68 int64_t dts; |
69 uint8_t *data; | 69 uint8_t *data; |
78 void (*destruct)(struct AVPacket *); | 78 void (*destruct)(struct AVPacket *); |
79 void *priv; | 79 void *priv; |
80 int64_t pos; ///< byte position in stream, -1 if unknown | 80 int64_t pos; ///< byte position in stream, -1 if unknown |
81 | 81 |
82 /** | 82 /** |
83 * This is the time difference in stream timebase units from the pts of this | 83 * Time difference in stream time base units from the pts of this |
84 * packet to the point at which the output from the decoder has converged | 84 * packet to the point at which the output from the decoder has converged |
85 * independent from the availability | 85 * independent from the availability of previous frames. That is, the |
86 * of previous frames (that is the frames are virtually identical no matter | 86 * frames are virtually identical no matter if decoding started from |
87 * if decoding started from the very first frame or from this keyframe). | 87 * the very first frame or from this keyframe. |
88 * is AV_NOPTS_VALUE if unknown. | 88 * Is AV_NOPTS_VALUE if unknown. |
89 * This field is not the display duration of the current packet. | 89 * This field is not the display duration of the current packet. |
90 * | 90 * |
91 * The purpose of this field is to allow seeking in streams that have no | 91 * The purpose of this field is to allow seeking in streams that have no |
92 * keyframes in the conventional sense. It corresponds to the | 92 * keyframes in the conventional sense. It corresponds to the |
93 * recovery point SEI in H.264 and match_time_delta in nut. It also is | 93 * recovery point SEI in H.264 and match_time_delta in NUT. It is also |
94 * essential for some types of subtitle streams to ensure that all | 94 * essential for some types of subtitle streams to ensure that all |
95 * subtitles are correctly displayed after seeking. | 95 * subtitles are correctly displayed after seeking. |
96 */ | 96 */ |
97 int64_t convergence_duration; | 97 int64_t convergence_duration; |
98 } AVPacket; | 98 } AVPacket; |
104 * Default packet destructor. | 104 * Default packet destructor. |
105 */ | 105 */ |
106 void av_destruct_packet(AVPacket *pkt); | 106 void av_destruct_packet(AVPacket *pkt); |
107 | 107 |
108 /** | 108 /** |
109 * Initialize optional fields of a packet to default values. | 109 * Initialize optional fields of a packet with default values. |
110 * | 110 * |
111 * @param pkt packet | 111 * @param pkt packet |
112 */ | 112 */ |
113 void av_init_packet(AVPacket *pkt); | 113 void av_init_packet(AVPacket *pkt); |
114 | 114 |
115 /** | 115 /** |
116 * Allocate the payload of a packet and initialize its fields to default values. | 116 * Allocate the payload of a packet and initialize its fields with |
117 * default values. | |
117 * | 118 * |
118 * @param pkt packet | 119 * @param pkt packet |
119 * @param size wanted payload size | 120 * @param size wanted payload size |
120 * @return 0 if OK. AVERROR_xxx otherwise. | 121 * @return 0 if OK, AVERROR_xxx otherwise |
121 */ | 122 */ |
122 int av_new_packet(AVPacket *pkt, int size); | 123 int av_new_packet(AVPacket *pkt, int size); |
123 | 124 |
124 /** | 125 /** |
125 * Allocate and read the payload of a packet and initialize its fields to default values. | 126 * Allocate and read the payload of a packet and initialize its fields with |
127 * default values. | |
126 * | 128 * |
127 * @param pkt packet | 129 * @param pkt packet |
128 * @param size wanted payload size | 130 * @param size desired payload size |
129 * @return >0 (read size) if OK. AVERROR_xxx otherwise. | 131 * @return >0 (read size) if OK, AVERROR_xxx otherwise |
130 */ | 132 */ |
131 int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size); | 133 int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size); |
132 | 134 |
133 /** | 135 /** |
134 * @warning This is a hack - the packet memory allocation stuff is broken. The | 136 * @warning This is a hack - the packet memory allocation stuff is broken. The |
135 * packet is allocated if it was not really allocated | 137 * packet is allocated if it was not really allocated. |
136 */ | 138 */ |
137 int av_dup_packet(AVPacket *pkt); | 139 int av_dup_packet(AVPacket *pkt); |
138 | 140 |
139 /** | 141 /** |
140 * Free a packet | 142 * Free a packet. |
141 * | 143 * |
142 * @param pkt packet to free | 144 * @param pkt packet to free |
143 */ | 145 */ |
144 static inline void av_free_packet(AVPacket *pkt) | 146 static inline void av_free_packet(AVPacket *pkt) |
145 { | 147 { |
150 | 152 |
151 /*************************************************/ | 153 /*************************************************/ |
152 /* fractional numbers for exact pts handling */ | 154 /* fractional numbers for exact pts handling */ |
153 | 155 |
154 /** | 156 /** |
155 * the exact value of the fractional number is: 'val + num / den'. | 157 * The exact value of the fractional number is: 'val + num / den'. |
156 * num is assumed to be such as 0 <= num < den | 158 * num is assumed to be 0 <= num < den. |
157 * @deprecated Use AVRational instead | 159 * @deprecated Use AVRational instead. |
158 */ | 160 */ |
159 typedef struct AVFrac { | 161 typedef struct AVFrac { |
160 int64_t val, num, den; | 162 int64_t val, num, den; |
161 } AVFrac attribute_deprecated; | 163 } AVFrac attribute_deprecated; |
162 | 164 |
165 | 167 |
166 struct AVCodecTag; | 168 struct AVCodecTag; |
167 | 169 |
168 struct AVFormatContext; | 170 struct AVFormatContext; |
169 | 171 |
170 /** this structure contains the data a format has to probe a file */ | 172 /** This structure contains the data a format has to probe a file. */ |
171 typedef struct AVProbeData { | 173 typedef struct AVProbeData { |
172 const char *filename; | 174 const char *filename; |
173 unsigned char *buf; | 175 unsigned char *buf; |
174 int buf_size; | 176 int buf_size; |
175 } AVProbeData; | 177 } AVProbeData; |
176 | 178 |
177 #define AVPROBE_SCORE_MAX 100 ///< max score, half of that is used for file extension based detection | 179 #define AVPROBE_SCORE_MAX 100 ///< Maximum score, half of that is used for file-extension-based detection. |
178 #define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer | 180 #define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer |
179 | 181 |
180 typedef struct AVFormatParameters { | 182 typedef struct AVFormatParameters { |
181 AVRational time_base; | 183 AVRational time_base; |
182 int sample_rate; | 184 int sample_rate; |
183 int channels; | 185 int channels; |
184 int width; | 186 int width; |
185 int height; | 187 int height; |
186 enum PixelFormat pix_fmt; | 188 enum PixelFormat pix_fmt; |
187 int channel; /**< used to select dv channel */ | 189 int channel; /**< Used to select DV channel. */ |
188 const char *standard; /**< tv standard, NTSC, PAL, SECAM */ | 190 const char *standard; /**< TV standard, NTSC, PAL, SECAM */ |
189 unsigned int mpeg2ts_raw:1; /**< force raw MPEG2 transport stream output, if possible */ | 191 unsigned int mpeg2ts_raw:1; /**< Force raw MPEG-2 transport stream output, if possible. */ |
190 unsigned int mpeg2ts_compute_pcr:1; /**< compute exact PCR for each transport | 192 unsigned int mpeg2ts_compute_pcr:1; /**< Compute exact PCR for each transport |
191 stream packet (only meaningful if | 193 stream packet (only meaningful if |
192 mpeg2ts_raw is TRUE) */ | 194 mpeg2ts_raw is TRUE). */ |
193 unsigned int initial_pause:1; /**< do not begin to play the stream | 195 unsigned int initial_pause:1; /**< Do not begin to play the stream |
194 immediately (RTSP only) */ | 196 immediately (RTSP only). */ |
195 unsigned int prealloced_context:1; | 197 unsigned int prealloced_context:1; |
196 #if LIBAVFORMAT_VERSION_INT < (53<<16) | 198 #if LIBAVFORMAT_VERSION_INT < (53<<16) |
197 enum CodecID video_codec_id; | 199 enum CodecID video_codec_id; |
198 enum CodecID audio_codec_id; | 200 enum CodecID audio_codec_id; |
199 #endif | 201 #endif |
200 } AVFormatParameters; | 202 } AVFormatParameters; |
201 | 203 |
202 //! demuxer will use url_fopen, no opened file should be provided by the caller | 204 //! Demuxer will use url_fopen, no opened file should be provided by the caller. |
203 #define AVFMT_NOFILE 0x0001 | 205 #define AVFMT_NOFILE 0x0001 |
204 #define AVFMT_NEEDNUMBER 0x0002 /**< needs '%d' in filename */ | 206 #define AVFMT_NEEDNUMBER 0x0002 /**< Needs '%d' in filename. */ |
205 #define AVFMT_SHOW_IDS 0x0008 /**< show format stream IDs numbers */ | 207 #define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */ |
206 #define AVFMT_RAWPICTURE 0x0020 /**< format wants AVPicture structure for | 208 #define AVFMT_RAWPICTURE 0x0020 /**< Format wants AVPicture structure for |
207 raw picture data */ | 209 raw picture data. */ |
208 #define AVFMT_GLOBALHEADER 0x0040 /**< format wants global header */ | 210 #define AVFMT_GLOBALHEADER 0x0040 /**< Format wants global header. */ |
209 #define AVFMT_NOTIMESTAMPS 0x0080 /**< format does not need / have any timestamps */ | 211 #define AVFMT_NOTIMESTAMPS 0x0080 /**< Format does not need / have any timestamps. */ |
210 #define AVFMT_GENERIC_INDEX 0x0100 /**< use generic index building code */ | 212 #define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */ |
211 #define AVFMT_TS_DISCONT 0x0200 /**< format allows timestamo discontinuities */ | 213 #define AVFMT_TS_DISCONT 0x0200 /**< Format allows timestamp discontinuities. */ |
212 | 214 |
213 typedef struct AVOutputFormat { | 215 typedef struct AVOutputFormat { |
214 const char *name; | 216 const char *name; |
215 /** | 217 /** |
216 * Descriptive name for the format, meant to be more human-readable | 218 * Descriptive name for the format, meant to be more human-readable |
217 * than \p name. You \e should use the NULL_IF_CONFIG_SMALL() macro | 219 * than \p name. You \e should use the NULL_IF_CONFIG_SMALL() macro |
218 * to define it. | 220 * to define it. |
219 */ | 221 */ |
220 const char *long_name; | 222 const char *long_name; |
221 const char *mime_type; | 223 const char *mime_type; |
222 const char *extensions; /**< comma separated filename extensions */ | 224 const char *extensions; /**< comma-separated filename extensions */ |
223 /** size of private data so that it can be allocated in the wrapper */ | 225 /** Size of private data so that it can be allocated in the wrapper. */ |
224 int priv_data_size; | 226 int priv_data_size; |
225 /* output support */ | 227 /* output support */ |
226 enum CodecID audio_codec; /**< default audio codec */ | 228 enum CodecID audio_codec; /**< default audio codec */ |
227 enum CodecID video_codec; /**< default video codec */ | 229 enum CodecID video_codec; /**< default video codec */ |
228 int (*write_header)(struct AVFormatContext *); | 230 int (*write_header)(struct AVFormatContext *); |
229 int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); | 231 int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); |
230 int (*write_trailer)(struct AVFormatContext *); | 232 int (*write_trailer)(struct AVFormatContext *); |
231 /** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */ | 233 /** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */ |
232 int flags; | 234 int flags; |
233 /** currently only used to set pixel format if not YUV420P */ | 235 /** Currently only used to set pixel format if not YUV420P. */ |
234 int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *); | 236 int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *); |
235 int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush); | 237 int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush); |
236 | 238 |
237 /** | 239 /** |
238 * list of supported codec_id-codec_tag pairs, ordered by "better choice first" | 240 * list of supported codec_id-codec_tag pairs, ordered by "better choice first" |
252 * Descriptive name for the format, meant to be more human-readable | 254 * Descriptive name for the format, meant to be more human-readable |
253 * than \p name. You \e should use the NULL_IF_CONFIG_SMALL() macro | 255 * than \p name. You \e should use the NULL_IF_CONFIG_SMALL() macro |
254 * to define it. | 256 * to define it. |
255 */ | 257 */ |
256 const char *long_name; | 258 const char *long_name; |
257 /** size of private data so that it can be allocated in the wrapper */ | 259 /** Size of private data so that it can be allocated in the wrapper. */ |
258 int priv_data_size; | 260 int priv_data_size; |
259 /** | 261 /** |
260 * Tell if a given file has a chance of being parsed by this format. | 262 * Tell if a given file has a chance of being parsed by this format. |
261 * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes | 263 * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes |
262 * big so you do not have to check for that unless you need more. | 264 * big so you do not have to check for that unless you need more. |
263 */ | 265 */ |
264 int (*read_probe)(AVProbeData *); | 266 int (*read_probe)(AVProbeData *); |
265 /** read the format header and initialize the AVFormatContext | 267 /** Read the format header and initialize the AVFormatContext |
266 structure. Return 0 if OK. 'ap' if non NULL contains | 268 structure. Return 0 if OK. 'ap' if non-NULL contains |
267 additional paramters. Only used in raw format right | 269 additional parameters. Only used in raw format right |
268 now. 'av_new_stream' should be called to create new streams. */ | 270 now. 'av_new_stream' should be called to create new streams. */ |
269 int (*read_header)(struct AVFormatContext *, | 271 int (*read_header)(struct AVFormatContext *, |
270 AVFormatParameters *ap); | 272 AVFormatParameters *ap); |
271 /** read one packet and put it in 'pkt'. pts and flags are also | 273 /** Read one packet and put it in 'pkt'. pts and flags are also |
272 set. 'av_new_stream' can be called only if the flag | 274 set. 'av_new_stream' can be called only if the flag |
273 AVFMTCTX_NOHEADER is used. */ | 275 AVFMTCTX_NOHEADER is used. */ |
274 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); | 276 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); |
275 /** close the stream. The AVFormatContext and AVStreams are not | 277 /** Close the stream. The AVFormatContext and AVStreams are not |
276 freed by this function */ | 278 freed by this function */ |
277 int (*read_close)(struct AVFormatContext *); | 279 int (*read_close)(struct AVFormatContext *); |
278 /** | 280 /** |
279 * seek to a given timestamp relative to the frames in | 281 * Seek to a given timestamp relative to the frames in |
280 * stream component stream_index | 282 * stream component stream_index. |
281 * @param stream_index must not be -1 | 283 * @param stream_index must not be -1 |
282 * @param flags selects which direction should be preferred if no exact | 284 * @param flags selects which direction should be preferred if no exact |
283 * match is available | 285 * match is available |
284 * @return >= 0 on success (but not necessarily the new offset) | 286 * @return >= 0 on success (but not necessarily the new offset) |
285 */ | 287 */ |
286 int (*read_seek)(struct AVFormatContext *, | 288 int (*read_seek)(struct AVFormatContext *, |
287 int stream_index, int64_t timestamp, int flags); | 289 int stream_index, int64_t timestamp, int flags); |
288 /** | 290 /** |
289 * gets the next timestamp in stream[stream_index].time_base units. | 291 * Gets the next timestamp in stream[stream_index].time_base units. |
290 * @return the timestamp or AV_NOPTS_VALUE if an error occurred | 292 * @return the timestamp or AV_NOPTS_VALUE if an error occurred |
291 */ | 293 */ |
292 int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index, | 294 int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index, |
293 int64_t *pos, int64_t pos_limit); | 295 int64_t *pos, int64_t pos_limit); |
294 /** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */ | 296 /** Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER. */ |
295 int flags; | 297 int flags; |
296 /** if extensions are defined, then no probe is done. You should | 298 /** If extensions are defined, then no probe is done. You should |
297 usually not use extension format guessing because it is not | 299 usually not use extension format guessing because it is not |
298 reliable enough */ | 300 reliable enough */ |
299 const char *extensions; | 301 const char *extensions; |
300 /** general purpose read only value that the format can use */ | 302 /** General purpose read-only value that the format can use. */ |
301 int value; | 303 int value; |
302 | 304 |
303 /** start/resume playing - only meaningful if using a network based format | 305 /** Start/resume playing - only meaningful if using a network-based format |
304 (RTSP) */ | 306 (RTSP). */ |
305 int (*read_play)(struct AVFormatContext *); | 307 int (*read_play)(struct AVFormatContext *); |
306 | 308 |
307 /** pause playing - only meaningful if using a network based format | 309 /** Pause playing - only meaningful if using a network-based format |
308 (RTSP) */ | 310 (RTSP). */ |
309 int (*read_pause)(struct AVFormatContext *); | 311 int (*read_pause)(struct AVFormatContext *); |
310 | 312 |
311 const struct AVCodecTag * const *codec_tag; | 313 const struct AVCodecTag * const *codec_tag; |
312 | 314 |
313 /* private fields */ | 315 /* private fields */ |
315 } AVInputFormat; | 317 } AVInputFormat; |
316 | 318 |
317 enum AVStreamParseType { | 319 enum AVStreamParseType { |
318 AVSTREAM_PARSE_NONE, | 320 AVSTREAM_PARSE_NONE, |
319 AVSTREAM_PARSE_FULL, /**< full parsing and repack */ | 321 AVSTREAM_PARSE_FULL, /**< full parsing and repack */ |
320 AVSTREAM_PARSE_HEADERS, /**< only parse headers, don't repack */ | 322 AVSTREAM_PARSE_HEADERS, /**< Only parse headers, do not repack. */ |
321 AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on packet boundary */ | 323 AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on packet boundary */ |
322 }; | 324 }; |
323 | 325 |
324 typedef struct AVIndexEntry { | 326 typedef struct AVIndexEntry { |
325 int64_t pos; | 327 int64_t pos; |
326 int64_t timestamp; | 328 int64_t timestamp; |
327 #define AVINDEX_KEYFRAME 0x0001 | 329 #define AVINDEX_KEYFRAME 0x0001 |
328 int flags:2; | 330 int flags:2; |
329 int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs 32 byte due to possible 8byte align). | 331 int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs. 32 bytes due to possible 8-byte alignment). |
330 int min_distance; /**< min distance between this and the previous keyframe, used to avoid unneeded searching */ | 332 int min_distance; /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */ |
331 } AVIndexEntry; | 333 } AVIndexEntry; |
332 | 334 |
333 #define AV_DISPOSITION_DEFAULT 0x0001 | 335 #define AV_DISPOSITION_DEFAULT 0x0001 |
334 #define AV_DISPOSITION_DUB 0x0002 | 336 #define AV_DISPOSITION_DUB 0x0002 |
335 #define AV_DISPOSITION_ORIGINAL 0x0004 | 337 #define AV_DISPOSITION_ORIGINAL 0x0004 |
344 * version bump. | 346 * version bump. |
345 * sizeof(AVStream) must not be used outside libav*. | 347 * sizeof(AVStream) must not be used outside libav*. |
346 */ | 348 */ |
347 typedef struct AVStream { | 349 typedef struct AVStream { |
348 int index; /**< stream index in AVFormatContext */ | 350 int index; /**< stream index in AVFormatContext */ |
349 int id; /**< format specific stream id */ | 351 int id; /**< format-specific stream ID */ |
350 AVCodecContext *codec; /**< codec context */ | 352 AVCodecContext *codec; /**< codec context */ |
351 /** | 353 /** |
352 * Real base frame rate of the stream. | 354 * Real base frame rate of the stream. |
353 * This is the lowest frame rate with which all timestamps can be | 355 * This is the lowest frame rate with which all timestamps can be |
354 * represented accurately (it is the least common multiple of all | 356 * represented accurately (it is the least common multiple of all |
355 * frame rates in the stream), Note, this value is just a guess! | 357 * frame rates in the stream). Note, this value is just a guess! |
356 * For example if the timebase is 1/90000 and all frames have either | 358 * For example if the time base is 1/90000 and all frames have either |
357 * approximately 3600 or 1800 timer ticks then r_frame_rate will be 50/1. | 359 * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1. |
358 */ | 360 */ |
359 AVRational r_frame_rate; | 361 AVRational r_frame_rate; |
360 void *priv_data; | 362 void *priv_data; |
361 | 363 |
362 /* internal data used in av_find_stream_info() */ | 364 /* internal data used in av_find_stream_info() */ |
363 int64_t first_dts; | 365 int64_t first_dts; |
364 /** encoding: PTS generation when outputing stream */ | 366 /** encoding: pts generation when outputting stream */ |
365 struct AVFrac pts; | 367 struct AVFrac pts; |
366 | 368 |
367 /** | 369 /** |
368 * This is the fundamental unit of time (in seconds) in terms | 370 * This is the fundamental unit of time (in seconds) in terms |
369 * of which frame timestamps are represented. For fixed-fps content, | 371 * of which frame timestamps are represented. For fixed-fps content, |
370 * timebase should be 1/frame rate and timestamp increments should be | 372 * time base should be 1/frame rate and timestamp increments should be 1. |
371 * identically 1. | |
372 */ | 373 */ |
373 AVRational time_base; | 374 AVRational time_base; |
374 int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ | 375 int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ |
375 /* ffmpeg.c private use */ | 376 /* ffmpeg.c private use */ |
376 int stream_copy; /**< if set, just copy stream */ | 377 int stream_copy; /**< If set, just copy stream. */ |
377 enum AVDiscard discard; ///< selects which packets can be discarded at will and do not need to be demuxed | 378 enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed. |
378 //FIXME move stuff to a flags field? | 379 //FIXME move stuff to a flags field? |
379 /** quality, as it has been removed from AVCodecContext and put in AVVideoFrame | 380 /** Quality, as it has been removed from AVCodecContext and put in AVVideoFrame. |
380 * MN: dunno if that is the right place for it */ | 381 * MN: dunno if that is the right place for it */ |
381 float quality; | 382 float quality; |
382 /** | 383 /** |
383 * Decoding: pts of the first frame of the stream, in stream time base. | 384 * Decoding: pts of the first frame of the stream, in stream time base. |
384 * Only set this if you are absolutely 100% sure that the value you set | 385 * Only set this if you are absolutely 100% sure that the value you set |
389 */ | 390 */ |
390 int64_t start_time; | 391 int64_t start_time; |
391 /** | 392 /** |
392 * Decoding: duration of the stream, in stream time base. | 393 * Decoding: duration of the stream, in stream time base. |
393 * If a source file does not specify a duration, but does specify | 394 * If a source file does not specify a duration, but does specify |
394 * a bitrate, this value will be estimates from bit rate and file size. | 395 * a bitrate, this value will be estimated from bitrate and file size. |
395 */ | 396 */ |
396 int64_t duration; | 397 int64_t duration; |
397 | 398 |
398 char language[4]; /** ISO 639 3-letter language code (empty string if undefined) */ | 399 char language[4]; /** ISO 639 3-letter language code (empty string if undefined) */ |
399 | 400 |
403 | 404 |
404 int64_t cur_dts; | 405 int64_t cur_dts; |
405 int last_IP_duration; | 406 int last_IP_duration; |
406 int64_t last_IP_pts; | 407 int64_t last_IP_pts; |
407 /* av_seek_frame() support */ | 408 /* av_seek_frame() support */ |
408 AVIndexEntry *index_entries; /**< only used if the format does not | 409 AVIndexEntry *index_entries; /**< Only used if the format does not |
409 support seeking natively */ | 410 support seeking natively. */ |
410 int nb_index_entries; | 411 int nb_index_entries; |
411 unsigned int index_entries_allocated_size; | 412 unsigned int index_entries_allocated_size; |
412 | 413 |
413 int64_t nb_frames; ///< number of frames in this stream if known or 0 | 414 int64_t nb_frames; ///< number of frames in this stream if known or 0 |
414 | 415 |
416 int64_t unused[4+1]; | 417 int64_t unused[4+1]; |
417 #endif | 418 #endif |
418 | 419 |
419 char *filename; /**< source filename of the stream */ | 420 char *filename; /**< source filename of the stream */ |
420 | 421 |
421 int disposition; /**< AV_DISPOSITION_* bitfield */ | 422 int disposition; /**< AV_DISPOSITION_* bit field */ |
422 | 423 |
423 AVProbeData probe_data; | 424 AVProbeData probe_data; |
424 #define MAX_REORDER_DELAY 16 | 425 #define MAX_REORDER_DELAY 16 |
425 int64_t pts_buffer[MAX_REORDER_DELAY+1]; | 426 int64_t pts_buffer[MAX_REORDER_DELAY+1]; |
426 | 427 |
440 * version bump. | 441 * version bump. |
441 * sizeof(AVProgram) must not be used outside libav*. | 442 * sizeof(AVProgram) must not be used outside libav*. |
442 */ | 443 */ |
443 typedef struct AVProgram { | 444 typedef struct AVProgram { |
444 int id; | 445 int id; |
445 char *provider_name; ///< Network name for DVB streams | 446 char *provider_name; ///< network name for DVB streams |
446 char *name; ///< Service name for DVB streams | 447 char *name; ///< service name for DVB streams |
447 int flags; | 448 int flags; |
448 enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller | 449 enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller |
449 unsigned int *stream_index; | 450 unsigned int *stream_index; |
450 unsigned int nb_stream_indexes; | 451 unsigned int nb_stream_indexes; |
451 } AVProgram; | 452 } AVProgram; |
452 | 453 |
453 #define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present | 454 #define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present |
454 (streams are added dynamically) */ | 455 (streams are added dynamically) */ |
455 | 456 |
456 typedef struct AVChapter { | 457 typedef struct AVChapter { |
457 int id; ///< Unique id to identify the chapter | 458 int id; ///< unique ID to identify the chapter |
458 AVRational time_base; ///< Timebase in which the start/end timestamps are specified | 459 AVRational time_base; ///< time base in which the start/end timestamps are specified |
459 int64_t start, end; ///< chapter start/end time in time_base units | 460 int64_t start, end; ///< chapter start/end time in time_base units |
460 char *title; ///< chapter title | 461 char *title; ///< chapter title |
461 } AVChapter; | 462 } AVChapter; |
462 | 463 |
463 #define MAX_STREAMS 20 | 464 #define MAX_STREAMS 20 |
464 | 465 |
465 /** | 466 /** |
466 * format I/O context. | 467 * Format I/O context. |
467 * New fields can be added to the end with minor version bumps. | 468 * New fields can be added to the end with minor version bumps. |
468 * Removal, reordering and changes to existing fields require a major | 469 * Removal, reordering and changes to existing fields require a major |
469 * version bump. | 470 * version bump. |
470 * sizeof(AVFormatContext) must not be used outside libav*. | 471 * sizeof(AVFormatContext) must not be used outside libav*. |
471 */ | 472 */ |
472 typedef struct AVFormatContext { | 473 typedef struct AVFormatContext { |
473 const AVClass *av_class; /**< set by av_alloc_format_context */ | 474 const AVClass *av_class; /**< Set by av_alloc_format_context. */ |
474 /* can only be iformat or oformat, not both at the same time */ | 475 /* Can only be iformat or oformat, not both at the same time. */ |
475 struct AVInputFormat *iformat; | 476 struct AVInputFormat *iformat; |
476 struct AVOutputFormat *oformat; | 477 struct AVOutputFormat *oformat; |
477 void *priv_data; | 478 void *priv_data; |
478 ByteIOContext *pb; | 479 ByteIOContext *pb; |
479 unsigned int nb_streams; | 480 unsigned int nb_streams; |
488 char album[512]; | 489 char album[512]; |
489 int year; /**< ID3 year, 0 if none */ | 490 int year; /**< ID3 year, 0 if none */ |
490 int track; /**< track number, 0 if none */ | 491 int track; /**< track number, 0 if none */ |
491 char genre[32]; /**< ID3 genre */ | 492 char genre[32]; /**< ID3 genre */ |
492 | 493 |
493 int ctx_flags; /**< format specific flags, see AVFMTCTX_xx */ | 494 int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */ |
494 /* private data for pts handling (do not modify directly) */ | 495 /* private data for pts handling (do not modify directly). */ |
495 /** This buffer is only needed when packets were already buffered but | 496 /** This buffer is only needed when packets were already buffered but |
496 not decoded, for example to get the codec parameters in mpeg | 497 not decoded, for example to get the codec parameters in MPEG |
497 streams */ | 498 streams. */ |
498 struct AVPacketList *packet_buffer; | 499 struct AVPacketList *packet_buffer; |
499 | 500 |
500 /** decoding: position of the first frame of the component, in | 501 /** Decoding: position of the first frame of the component, in |
501 AV_TIME_BASE fractional seconds. NEVER set this value directly: | 502 AV_TIME_BASE fractional seconds. NEVER set this value directly: |
502 it is deduced from the AVStream values. */ | 503 It is deduced from the AVStream values. */ |
503 int64_t start_time; | 504 int64_t start_time; |
504 /** decoding: duration of the stream, in AV_TIME_BASE fractional | 505 /** Decoding: duration of the stream, in AV_TIME_BASE fractional |
505 seconds. NEVER set this value directly: it is deduced from the | 506 seconds. NEVER set this value directly: it is deduced from the |
506 AVStream values. */ | 507 AVStream values. */ |
507 int64_t duration; | 508 int64_t duration; |
508 /** decoding: total file size. 0 if unknown */ | 509 /** decoding: total file size, 0 if unknown */ |
509 int64_t file_size; | 510 int64_t file_size; |
510 /** decoding: total stream bitrate in bit/s, 0 if not | 511 /** Decoding: total stream bitrate in bit/s, 0 if not |
511 available. Never set it directly if the file_size and the | 512 available. Never set it directly if the file_size and the |
512 duration are known as ffmpeg can compute it automatically. */ | 513 duration are known as ffmpeg can compute it automatically. */ |
513 int bit_rate; | 514 int bit_rate; |
514 | 515 |
515 /* av_read_frame() support */ | 516 /* av_read_frame() support */ |
531 #define AVFMT_INFINITEOUTPUTLOOP 0 | 532 #define AVFMT_INFINITEOUTPUTLOOP 0 |
532 /** number of times to loop output in formats that support it */ | 533 /** number of times to loop output in formats that support it */ |
533 int loop_output; | 534 int loop_output; |
534 | 535 |
535 int flags; | 536 int flags; |
536 #define AVFMT_FLAG_GENPTS 0x0001 ///< generate pts if missing even if it requires parsing future frames | 537 #define AVFMT_FLAG_GENPTS 0x0001 ///< Generate pts if missing even if it requires parsing future frames. |
537 #define AVFMT_FLAG_IGNIDX 0x0002 ///< ignore index | 538 #define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index. |
538 #define AVFMT_FLAG_NONBLOCK 0x0004 ///< do not block when reading packets from input | 539 #define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input. |
539 | 540 |
540 int loop_input; | 541 int loop_input; |
541 /** decoding: size of data to probe; encoding unused */ | 542 /** Decoding: size of data to probe; encoding: unused. */ |
542 unsigned int probesize; | 543 unsigned int probesize; |
543 | 544 |
544 /** | 545 /** |
545 * maximum duration in AV_TIME_BASE units over which the input should be analyzed in av_find_stream_info() | 546 * Maximum time (in AV_TIME_BASE units) during which the input should |
547 * be analyzed in av_find_stream_info(). | |
546 */ | 548 */ |
547 int max_analyze_duration; | 549 int max_analyze_duration; |
548 | 550 |
549 const uint8_t *key; | 551 const uint8_t *key; |
550 int keylen; | 552 int keylen; |
552 unsigned int nb_programs; | 554 unsigned int nb_programs; |
553 AVProgram **programs; | 555 AVProgram **programs; |
554 | 556 |
555 /** | 557 /** |
556 * Forced video codec_id. | 558 * Forced video codec_id. |
557 * demuxing: set by user | 559 * Demuxing: Set by user. |
558 */ | 560 */ |
559 enum CodecID video_codec_id; | 561 enum CodecID video_codec_id; |
560 /** | 562 /** |
561 * Forced audio codec_id. | 563 * Forced audio codec_id. |
562 * demuxing: set by user | 564 * Demuxing: Set by user. |
563 */ | 565 */ |
564 enum CodecID audio_codec_id; | 566 enum CodecID audio_codec_id; |
565 /** | 567 /** |
566 * Forced subtitle codec_id. | 568 * Forced subtitle codec_id. |
567 * demuxing: set by user | 569 * Demuxing: Set by user. |
568 */ | 570 */ |
569 enum CodecID subtitle_codec_id; | 571 enum CodecID subtitle_codec_id; |
570 | 572 |
571 /** | 573 /** |
572 * Maximum amount of memory in bytes to use per stream for the index. | 574 * Maximum amount of memory in bytes to use per stream for the index. |
573 * If the needed index exceeds this size entries will be discarded as | 575 * If the needed index exceeds this size, entries will be discarded as |
574 * needed to maintain a smaller size. This can lead to slower or less | 576 * needed to maintain a smaller size. This can lead to slower or less |
575 * accurate seeking (depends on demuxer). | 577 * accurate seeking (depends on demuxer). |
576 * Demuxers for which a full in memory index is mandatory will ignore | 578 * Demuxers for which a full in-memory index is mandatory will ignore |
577 * this. | 579 * this. |
578 * muxing : unused | 580 * muxing : unused |
579 * demuxing: set by user | 581 * demuxing: set by user |
580 */ | 582 */ |
581 unsigned int max_index_size; | 583 unsigned int max_index_size; |
582 | 584 |
583 /** | 585 /** |
584 * Maximum amount of memory in bytes to use for buffering frames | 586 * Maximum amount of memory in bytes to use for buffering frames |
585 * obtained from real-time capture devices. | 587 * obtained from realtime capture devices. |
586 */ | 588 */ |
587 unsigned int max_picture_buffer; | 589 unsigned int max_picture_buffer; |
588 | 590 |
589 unsigned int nb_chapters; | 591 unsigned int nb_chapters; |
590 AVChapter **chapters; | 592 AVChapter **chapters; |
591 | 593 |
592 /** | 594 /** |
593 * Flags to enable debuging. | 595 * Flags to enable debugging. |
594 */ | 596 */ |
595 int debug; | 597 int debug; |
596 #define FF_FDEBUG_TS 0x0001 | 598 #define FF_FDEBUG_TS 0x0001 |
597 | 599 |
598 /** | 600 /** |
599 * raw packets from the demuxer, prior to parsing and decoding. | 601 * Raw packets from the demuxer, prior to parsing and decoding. |
600 * This buffer is used for buffering packets until the codec can | 602 * This buffer is used for buffering packets until the codec can |
601 * be identified, as parsing cannot be done without knowing the | 603 * be identified, as parsing cannot be done without knowing the |
602 * codec. | 604 * codec. |
603 */ | 605 */ |
604 struct AVPacketList *raw_packet_buffer; | 606 struct AVPacketList *raw_packet_buffer; |
632 const char *filename, const char *mime_type); | 634 const char *filename, const char *mime_type); |
633 AVOutputFormat *guess_format(const char *short_name, | 635 AVOutputFormat *guess_format(const char *short_name, |
634 const char *filename, const char *mime_type); | 636 const char *filename, const char *mime_type); |
635 | 637 |
636 /** | 638 /** |
637 * Guesses the codec id based upon muxer and filename. | 639 * Guesses the codec ID based upon muxer and filename. |
638 */ | 640 */ |
639 enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, | 641 enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, |
640 const char *filename, const char *mime_type, enum CodecType type); | 642 const char *filename, const char *mime_type, enum CodecType type); |
641 | 643 |
642 /** | 644 /** |
667 /** | 669 /** |
668 * Send a nice dump of a packet to the specified file stream. | 670 * Send a nice dump of a packet to the specified file stream. |
669 * | 671 * |
670 * @param f The file stream pointer where the dump should be sent to. | 672 * @param f The file stream pointer where the dump should be sent to. |
671 * @param pkt packet to dump | 673 * @param pkt packet to dump |
672 * @param dump_payload true if the payload must be displayed too | 674 * @param dump_payload True if the payload must be displayed, too. |
673 */ | 675 */ |
674 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); | 676 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); |
675 | 677 |
676 /** | 678 /** |
677 * Send a nice dump of a packet to the log. | 679 * Send a nice dump of a packet to the log. |
679 * @param avcl A pointer to an arbitrary struct of which the first field is a | 681 * @param avcl A pointer to an arbitrary struct of which the first field is a |
680 * pointer to an AVClass struct. | 682 * pointer to an AVClass struct. |
681 * @param level The importance level of the message, lower values signifying | 683 * @param level The importance level of the message, lower values signifying |
682 * higher importance. | 684 * higher importance. |
683 * @param pkt packet to dump | 685 * @param pkt packet to dump |
684 * @param dump_payload true if the payload must be displayed too | 686 * @param dump_payload True if the payload must be displayed, too. |
685 */ | 687 */ |
686 void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload); | 688 void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload); |
687 | 689 |
688 void av_register_all(void); | 690 void av_register_all(void); |
689 | 691 |
692 unsigned int av_codec_get_tag(const struct AVCodecTag **tags, enum CodecID id); | 694 unsigned int av_codec_get_tag(const struct AVCodecTag **tags, enum CodecID id); |
693 | 695 |
694 /* media file input */ | 696 /* media file input */ |
695 | 697 |
696 /** | 698 /** |
697 * finds AVInputFormat based on input format's short name. | 699 * Finds AVInputFormat based on the short name of the input format. |
698 */ | 700 */ |
699 AVInputFormat *av_find_input_format(const char *short_name); | 701 AVInputFormat *av_find_input_format(const char *short_name); |
700 | 702 |
701 /** | 703 /** |
702 * Guess file format. | 704 * Guess file format. |
703 * | 705 * |
704 * @param is_opened whether the file is already opened, determines whether | 706 * @param is_opened Whether the file is already opened; determines whether |
705 * demuxers with or without AVFMT_NOFILE are probed | 707 * demuxers with or without AVFMT_NOFILE are probed. |
706 */ | 708 */ |
707 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); | 709 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); |
708 | 710 |
709 /** | 711 /** |
710 * Allocates all the structures needed to read an input stream. | 712 * Allocates all the structures needed to read an input stream. |
716 | 718 |
717 /** | 719 /** |
718 * Open a media file as input. The codecs are not opened. Only the file | 720 * Open a media file as input. The codecs are not opened. Only the file |
719 * header (if present) is read. | 721 * header (if present) is read. |
720 * | 722 * |
721 * @param ic_ptr the opened media file handle is put here | 723 * @param ic_ptr The opened media file handle is put here. |
722 * @param filename filename to open. | 724 * @param filename filename to open |
723 * @param fmt if non NULL, force the file format to use | 725 * @param fmt If non-NULL, force the file format to use. |
724 * @param buf_size optional buffer size (zero if default is OK) | 726 * @param buf_size optional buffer size (zero if default is OK) |
725 * @param ap additional parameters needed when opening the file (NULL if default) | 727 * @param ap Additional parameters needed when opening the file (NULL if default). |
726 * @return 0 if OK. AVERROR_xxx otherwise. | 728 * @return 0 if OK, AVERROR_xxx otherwise |
727 */ | 729 */ |
728 int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, | 730 int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, |
729 AVInputFormat *fmt, | 731 AVInputFormat *fmt, |
730 int buf_size, | 732 int buf_size, |
731 AVFormatParameters *ap); | 733 AVFormatParameters *ap); |
737 AVFormatContext *av_alloc_format_context(void); | 739 AVFormatContext *av_alloc_format_context(void); |
738 | 740 |
739 /** | 741 /** |
740 * Read packets of a media file to get stream information. This | 742 * Read packets of a media file to get stream information. This |
741 * is useful for file formats with no headers such as MPEG. This | 743 * is useful for file formats with no headers such as MPEG. This |
742 * function also computes the real frame rate in case of mpeg2 repeat | 744 * function also computes the real frame rate in case of MPEG-2 repeat |
743 * frame mode. | 745 * frame mode. |
744 * The logical file position is not changed by this function; | 746 * The logical file position is not changed by this function; |
745 * examined packets may be buffered for later processing. | 747 * examined packets may be buffered for later processing. |
746 * | 748 * |
747 * @param ic media file handle | 749 * @param ic media file handle |
748 * @return >=0 if OK. AVERROR_xxx if error. | 750 * @return >=0 if OK, AVERROR_xxx on error |
749 * @todo Let user decide somehow what information is needed so we do not waste time getting stuff the user does not need. | 751 * @todo Let the user decide somehow what information is needed so that |
752 * we do not waste time getting stuff the user does not need. | |
750 */ | 753 */ |
751 int av_find_stream_info(AVFormatContext *ic); | 754 int av_find_stream_info(AVFormatContext *ic); |
752 | 755 |
753 /** | 756 /** |
754 * Read a transport packet from a media file. | 757 * Read a transport packet from a media file. |
756 * This function is obsolete and should never be used. | 759 * This function is obsolete and should never be used. |
757 * Use av_read_frame() instead. | 760 * Use av_read_frame() instead. |
758 * | 761 * |
759 * @param s media file handle | 762 * @param s media file handle |
760 * @param pkt is filled | 763 * @param pkt is filled |
761 * @return 0 if OK. AVERROR_xxx if error. | 764 * @return 0 if OK, AVERROR_xxx on error |
762 */ | 765 */ |
763 int av_read_packet(AVFormatContext *s, AVPacket *pkt); | 766 int av_read_packet(AVFormatContext *s, AVPacket *pkt); |
764 | 767 |
765 /** | 768 /** |
766 * Return the next frame of a stream. | 769 * Return the next frame of a stream. |
773 * data). If the audio frames have a variable size (e.g. MPEG audio), | 776 * data). If the audio frames have a variable size (e.g. MPEG audio), |
774 * then it contains one frame. | 777 * then it contains one frame. |
775 * | 778 * |
776 * pkt->pts, pkt->dts and pkt->duration are always set to correct | 779 * pkt->pts, pkt->dts and pkt->duration are always set to correct |
777 * values in AVStream.timebase units (and guessed if the format cannot | 780 * values in AVStream.timebase units (and guessed if the format cannot |
778 * provided them). pkt->pts can be AV_NOPTS_VALUE if the video format | 781 * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format |
779 * has B frames, so it is better to rely on pkt->dts if you do not | 782 * has B-frames, so it is better to rely on pkt->dts if you do not |
780 * decompress the payload. | 783 * decompress the payload. |
781 * | 784 * |
782 * @return 0 if OK, < 0 if error or end of file. | 785 * @return 0 if OK, < 0 on error or end of file |
783 */ | 786 */ |
784 int av_read_frame(AVFormatContext *s, AVPacket *pkt); | 787 int av_read_frame(AVFormatContext *s, AVPacket *pkt); |
785 | 788 |
786 /** | 789 /** |
787 * Seek to the key frame at timestamp. | 790 * Seek to the key frame at timestamp. |
788 * 'timestamp' in 'stream_index'. | 791 * 'timestamp' in 'stream_index'. |
789 * @param stream_index If stream_index is (-1), a default | 792 * @param stream_index If stream_index is (-1), a default |
790 * stream is selected, and timestamp is automatically converted | 793 * stream is selected, and timestamp is automatically converted |
791 * from AV_TIME_BASE units to the stream specific time_base. | 794 * from AV_TIME_BASE units to the stream specific time_base. |
792 * @param timestamp timestamp in AVStream.time_base units | 795 * @param timestamp Timestamp in AVStream.time_base units |
793 * or if there is no stream specified then in AV_TIME_BASE units | 796 * or, if no stream is specified, in AV_TIME_BASE units. |
794 * @param flags flags which select direction and seeking mode | 797 * @param flags flags which select direction and seeking mode |
795 * @return >= 0 on success | 798 * @return >= 0 on success |
796 */ | 799 */ |
797 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags); | 800 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags); |
798 | 801 |
799 /** | 802 /** |
800 * start playing a network based stream (e.g. RTSP stream) at the | 803 * Start playing a network based stream (e.g. RTSP stream) at the |
801 * current position | 804 * current position. |
802 */ | 805 */ |
803 int av_read_play(AVFormatContext *s); | 806 int av_read_play(AVFormatContext *s); |
804 | 807 |
805 /** | 808 /** |
806 * Pause a network based stream (e.g. RTSP stream). | 809 * Pause a network based stream (e.g. RTSP stream). |
828 * Can only be called in the read_header() function. If the flag | 831 * Can only be called in the read_header() function. If the flag |
829 * AVFMTCTX_NOHEADER is in the format context, then new streams | 832 * AVFMTCTX_NOHEADER is in the format context, then new streams |
830 * can be added in read_packet too. | 833 * can be added in read_packet too. |
831 * | 834 * |
832 * @param s media file handle | 835 * @param s media file handle |
833 * @param id file format dependent stream id | 836 * @param id file-format-dependent stream ID |
834 */ | 837 */ |
835 AVStream *av_new_stream(AVFormatContext *s, int id); | 838 AVStream *av_new_stream(AVFormatContext *s, int id); |
836 AVProgram *av_new_program(AVFormatContext *s, int id); | 839 AVProgram *av_new_program(AVFormatContext *s, int id); |
837 | 840 |
838 /** | 841 /** |
839 * Add a new chapter. | 842 * Add a new chapter. |
840 * This function is NOT part of the public API | 843 * This function is NOT part of the public API |
841 * and should be ONLY used by demuxers. | 844 * and should ONLY be used by demuxers. |
842 * | 845 * |
843 * @param s media file handle | 846 * @param s media file handle |
844 * @param id unique id for this chapter | 847 * @param id unique ID for this chapter |
845 * @param start chapter start time in time_base units | 848 * @param start chapter start time in time_base units |
846 * @param end chapter end time in time_base units | 849 * @param end chapter end time in time_base units |
847 * @param title chapter title | 850 * @param title chapter title |
848 * | 851 * |
849 * @return AVChapter or NULL if error. | 852 * @return AVChapter or NULL on error |
850 */ | 853 */ |
851 AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title); | 854 AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title); |
852 | 855 |
853 /** | 856 /** |
854 * Set the pts for a given stream. | 857 * Set the pts for a given stream. |
862 void av_set_pts_info(AVStream *s, int pts_wrap_bits, | 865 void av_set_pts_info(AVStream *s, int pts_wrap_bits, |
863 int pts_num, int pts_den); | 866 int pts_num, int pts_den); |
864 | 867 |
865 #define AVSEEK_FLAG_BACKWARD 1 ///< seek backward | 868 #define AVSEEK_FLAG_BACKWARD 1 ///< seek backward |
866 #define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes | 869 #define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes |
867 #define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non keyframes | 870 #define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes |
868 | 871 |
869 int av_find_default_stream_index(AVFormatContext *s); | 872 int av_find_default_stream_index(AVFormatContext *s); |
870 | 873 |
871 /** | 874 /** |
872 * Gets the index for a specific timestamp. | 875 * Gets the index for a specific timestamp. |
873 * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond to | 876 * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond |
874 * the timestamp which is <= the requested one, if backward is 0 | 877 * to the timestamp which is <= the requested one, if backward |
875 * then it will be >= | 878 * is 0, then it will be >= |
876 * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise | 879 * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise |
877 * @return < 0 if no such timestamp could be found | 880 * @return < 0 if no such timestamp could be found |
878 */ | 881 */ |
879 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags); | 882 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags); |
880 | 883 |
886 * by demuxers. | 889 * by demuxers. |
887 */ | 890 */ |
888 void ff_reduce_index(AVFormatContext *s, int stream_index); | 891 void ff_reduce_index(AVFormatContext *s, int stream_index); |
889 | 892 |
890 /** | 893 /** |
891 * Add a index entry into a sorted list updateing if it is already there. | 894 * Add an index entry into a sorted list. Update the entry if the list |
892 * | 895 * already contains it. |
893 * @param timestamp timestamp in the timebase of the given stream | 896 * |
897 * @param timestamp timestamp in the time base of the given stream | |
894 */ | 898 */ |
895 int av_add_index_entry(AVStream *st, | 899 int av_add_index_entry(AVStream *st, |
896 int64_t pos, int64_t timestamp, int size, int distance, int flags); | 900 int64_t pos, int64_t timestamp, int size, int distance, int flags); |
897 | 901 |
898 /** | 902 /** |
902 * @param stream_index stream number | 906 * @param stream_index stream number |
903 */ | 907 */ |
904 int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags); | 908 int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags); |
905 | 909 |
906 /** | 910 /** |
907 * Updates cur_dts of all streams based on given timestamp and AVStream. | 911 * Updates cur_dts of all streams based on the given timestamp and AVStream. |
908 * | 912 * |
909 * Stream ref_st unchanged, others set cur_dts in their native timebase | 913 * Stream ref_st unchanged, others set cur_dts in their native time base. |
910 * only needed for timestamp wrapping or if (dts not set and pts!=dts). | 914 * Only needed for timestamp wrapping or if (dts not set and pts!=dts). |
911 * @param timestamp new dts expressed in time_base of param ref_st | 915 * @param timestamp new dts expressed in time_base of param ref_st |
912 * @param ref_st reference stream giving time_base of param timestamp | 916 * @param ref_st reference stream giving time_base of param timestamp |
913 */ | 917 */ |
914 void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); | 918 void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); |
915 | 919 |
927 /** | 931 /** |
928 * Allocate the stream private data and write the stream header to an | 932 * Allocate the stream private data and write the stream header to an |
929 * output media file. | 933 * output media file. |
930 * | 934 * |
931 * @param s media file handle | 935 * @param s media file handle |
932 * @return 0 if OK. AVERROR_xxx if error. | 936 * @return 0 if OK, AVERROR_xxx on error |
933 */ | 937 */ |
934 int av_write_header(AVFormatContext *s); | 938 int av_write_header(AVFormatContext *s); |
935 | 939 |
936 /** | 940 /** |
937 * Write a packet to an output media file. | 941 * Write a packet to an output media file. |
938 * | 942 * |
939 * The packet shall contain one audio or video frame. | 943 * The packet shall contain one audio or video frame. |
940 * The packet must be correctly interleaved according to the container specification, | 944 * The packet must be correctly interleaved according to the container specification, |
941 * if not then av_interleaved_write_frame must be used | 945 * if not then av_interleaved_write_frame must be used. |
942 * | 946 * |
943 * @param s media file handle | 947 * @param s media file handle |
944 * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ... | 948 * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ... |
945 * @return < 0 if error, = 0 if OK, 1 if end of stream wanted. | 949 * @return < 0 on error, = 0 if OK, 1 if end of stream wanted |
946 */ | 950 */ |
947 int av_write_frame(AVFormatContext *s, AVPacket *pkt); | 951 int av_write_frame(AVFormatContext *s, AVPacket *pkt); |
948 | 952 |
949 /** | 953 /** |
950 * Writes a packet to an output media file ensuring correct interleaving. | 954 * Writes a packet to an output media file ensuring correct interleaving. |
956 * of memory to interleave with this, so it is preferable to interleave at the | 960 * of memory to interleave with this, so it is preferable to interleave at the |
957 * demuxer level. | 961 * demuxer level. |
958 * | 962 * |
959 * @param s media file handle | 963 * @param s media file handle |
960 * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ... | 964 * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ... |
961 * @return < 0 if error, = 0 if OK, 1 if end of stream wanted. | 965 * @return < 0 on error, = 0 if OK, 1 if end of stream wanted |
962 */ | 966 */ |
963 int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); | 967 int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); |
964 | 968 |
965 /** | 969 /** |
966 * Interleave a packet per DTS in an output media file. | 970 * Interleave a packet per dts in an output media file. |
967 * | 971 * |
968 * Packets with pkt->destruct == av_destruct_packet will be freed inside this function, | 972 * Packets with pkt->destruct == av_destruct_packet will be freed inside this function, |
969 * so they cannot be used after it, note calling av_free_packet() on them is still safe. | 973 * so they cannot be used after it, note calling av_free_packet() on them is still safe. |
970 * | 974 * |
971 * @param s media file handle | 975 * @param s media file handle |
983 * free the file private data. | 987 * free the file private data. |
984 * | 988 * |
985 * May only be called after a successful call to av_write_header. | 989 * May only be called after a successful call to av_write_header. |
986 * | 990 * |
987 * @param s media file handle | 991 * @param s media file handle |
988 * @return 0 if OK. AVERROR_xxx if error. | 992 * @return 0 if OK, AVERROR_xxx on error |
989 */ | 993 */ |
990 int av_write_trailer(AVFormatContext *s); | 994 int av_write_trailer(AVFormatContext *s); |
991 | 995 |
992 void dump_format(AVFormatContext *ic, | 996 void dump_format(AVFormatContext *ic, |
993 int index, | 997 int index, |
994 const char *url, | 998 const char *url, |
995 int is_output); | 999 int is_output); |
996 | 1000 |
997 /** | 1001 /** |
998 * parses width and height out of string str. | 1002 * Parses width and height out of string str. |
999 * @deprecated Use av_parse_video_frame_size instead. | 1003 * @deprecated Use av_parse_video_frame_size instead. |
1000 */ | 1004 */ |
1001 attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr, const char *str); | 1005 attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr, const char *str); |
1002 | 1006 |
1003 /** | 1007 /** |
1011 * @param datestr String representing a date or a duration. | 1015 * @param datestr String representing a date or a duration. |
1012 * - If a date the syntax is: | 1016 * - If a date the syntax is: |
1013 * @code | 1017 * @code |
1014 * [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]} | 1018 * [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]} |
1015 * @endcode | 1019 * @endcode |
1016 * Time is localtime unless Z is appended, in which case it is | 1020 * Time is local time unless Z is appended, in which case it is |
1017 * interpreted as UTC. | 1021 * interpreted as UTC. |
1018 * If the year-month-day part isn't specified it takes the current | 1022 * If the year-month-day part is not specified it takes the current |
1019 * year-month-day. | 1023 * year-month-day. |
1020 * Returns the number of microseconds since 1st of January, 1970 up to | 1024 * Returns the number of microseconds since 1st of January, 1970 up to |
1021 * the time of the parsed date or INT64_MIN if \p datestr cannot be | 1025 * the time of the parsed date or INT64_MIN if \p datestr cannot be |
1022 * successfully parsed. | 1026 * successfully parsed. |
1023 * - If a duration the syntax is: | 1027 * - If a duration the syntax is: |
1035 int64_t parse_date(const char *datestr, int duration); | 1039 int64_t parse_date(const char *datestr, int duration); |
1036 | 1040 |
1037 /** Gets the current time in microseconds. */ | 1041 /** Gets the current time in microseconds. */ |
1038 int64_t av_gettime(void); | 1042 int64_t av_gettime(void); |
1039 | 1043 |
1040 /* ffm specific for ffserver */ | 1044 /* ffm-specific for ffserver */ |
1041 #define FFM_PACKET_SIZE 4096 | 1045 #define FFM_PACKET_SIZE 4096 |
1042 offset_t ffm_read_write_index(int fd); | 1046 offset_t ffm_read_write_index(int fd); |
1043 void ffm_write_write_index(int fd, offset_t pos); | 1047 void ffm_write_write_index(int fd, offset_t pos); |
1044 void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size); | 1048 void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size); |
1045 | 1049 |
1051 */ | 1055 */ |
1052 int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info); | 1056 int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info); |
1053 | 1057 |
1054 /** | 1058 /** |
1055 * Returns in 'buf' the path with '%d' replaced by number. | 1059 * Returns in 'buf' the path with '%d' replaced by number. |
1056 | 1060 * |
1057 * Also handles the '%0nd' format where 'n' is the total number | 1061 * Also handles the '%0nd' format where 'n' is the total number |
1058 * of digits and '%%'. | 1062 * of digits and '%%'. |
1059 * | 1063 * |
1060 * @param buf destination buffer | 1064 * @param buf destination buffer |
1061 * @param buf_size destination buffer size | 1065 * @param buf_size destination buffer size |
1062 * @param path numbered sequence string | 1066 * @param path numbered sequence string |
1063 * @param number frame number | 1067 * @param number frame number |
1064 * @return 0 if OK, -1 if format error. | 1068 * @return 0 if OK, -1 on format error |
1065 */ | 1069 */ |
1066 int av_get_frame_filename(char *buf, int buf_size, | 1070 int av_get_frame_filename(char *buf, int buf_size, |
1067 const char *path, int number); | 1071 const char *path, int number); |
1068 | 1072 |
1069 /** | 1073 /** |
1070 * Check whether filename actually is a numbered sequence generator. | 1074 * Check whether filename actually is a numbered sequence generator. |
1071 * | 1075 * |
1072 * @param filename possible numbered sequence string | 1076 * @param filename possible numbered sequence string |
1073 * @return 1 if a valid numbered sequence string, 0 otherwise. | 1077 * @return 1 if a valid numbered sequence string, 0 otherwise |
1074 */ | 1078 */ |
1075 int av_filename_number_test(const char *filename); | 1079 int av_filename_number_test(const char *filename); |
1076 | 1080 |
1077 /** | 1081 /** |
1078 * Generate an SDP for an RTP session. | 1082 * Generate an SDP for an RTP session. |
1079 * | 1083 * |
1080 * @param ac array of AVFormatContexts describing the RTP streams. If the | 1084 * @param ac array of AVFormatContexts describing the RTP streams. If the |
1081 * array is composed by only one context, such context can contain | 1085 * array is composed by only one context, such context can contain |
1082 * multiple AVStreams (one AVStream per RTP stream). Otherwise, | 1086 * multiple AVStreams (one AVStream per RTP stream). Otherwise, |
1083 * all the contexts in the array (an AVCodecContext per RTP stream) | 1087 * all the contexts in the array (an AVCodecContext per RTP stream) |
1084 * must contain only one AVStream | 1088 * must contain only one AVStream. |
1085 * @param n_files number of AVCodecContexts contained in ac | 1089 * @param n_files number of AVCodecContexts contained in ac |
1086 * @param buff buffer where the SDP will be stored (must be allocated by | 1090 * @param buff buffer where the SDP will be stored (must be allocated by |
1087 * the caller | 1091 * the caller) |
1088 * @param size the size of the buffer | 1092 * @param size the size of the buffer |
1089 * @return 0 if OK. AVERROR_xxx if error. | 1093 * @return 0 if OK, AVERROR_xxx on error |
1090 */ | 1094 */ |
1091 int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size); | 1095 int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size); |
1092 | 1096 |
1093 #ifdef HAVE_AV_CONFIG_H | 1097 #ifdef HAVE_AV_CONFIG_H |
1094 | 1098 |