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 #ifndef FFTOOLS_FFMPEG_H
20 #define FFTOOLS_FFMPEG_H
21
23
24 #include <stdint.h>
25 #include <stdio.h>
26 #include <signal.h>
27
29
32
34
36
46
48
50 #define VSYNC_PASSTHROUGH 0
53 #define VSYNC_VSCFR 0xfe
54 #define VSYNC_DROP 0xff
55
56 #define MAX_STREAMS 1024 /* arbitrary sanity check value */
57
65 };
66
73
79
80 /* select an input stream for an output stream */
82 int disabled;
/* 1 is this mapping is disabled by a negative map */
87 char *
linklabel;
/* name of an output link, for mapping lavfi outputs */
89
94
97
98 /* input/output options */
103
116
117 /* input options */
123
136
137 /* output options */
147
149
157
162
163 /* indexed by output file stream index */
166
234
241
243
244 // parameters configured for this input
246
249
253
255
258
264
265 /* temporary storage until stream maps are processed */
268
269 /* desired output stream properties */
275
276 // those are only set if no format is specified and the encoder gives us multiple options
281
285
288
294
298 int discard;
/* true if stream data should be discarded */
300 int decoding_needed;
/* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
301 #define DECODING_FOR_OST 1
302 #define DECODING_FOR_FILTER 2
303
308
309 int64_t
start;
/* time when read started */
310 /* predicted dts of the next packet read for this stream or (when there are
311 * several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
313 int64_t
dts;
///< dts of the last packet read for this stream (in AV_TIME_BASE units)
314
315 int64_t
next_pts;
///< synthetic pts for the next decode frame (in AV_TIME_BASE units)
316 int64_t
pts;
///< current pts of the decoded frame (in AV_TIME_BASE units)
318
320
321 int64_t
min_pts;
/* pts with the smallest value in a current stream */
322 int64_t
max_pts;
/* pts with the higher value in a current stream */
323
324 // when forcing constant input framerate through -r,
325 // this contains the pts that will be given to the next decoded frame
327
328 int64_t
nb_samples;
/* number of samples in the last decoded audio frame before looping */
329
336
338
340 struct { /* previous decoded subtitle and related variables */
345
353
355
356 /* decoded data from this stream goes into all those filters
357 * currently video and audio only */
360
362
363 /* hwaccel options */
368
369 /* hwaccel context */
377
378 /* stats */
379 // combined size of all the packets read
381 /* number of packets successfully read for this stream */
383 // number of frames/samples retrieved from the decoder
386
389
392
396 int eagain;
/* true if last read attempt returned EAGAIN */
397 int ist_index;
/* index of first stream in input_streams */
398 int loop;
/* set number of times input stream should be looped */
399 int64_t
duration;
/* actual duration of the longest stream in a file
400 at the moment when looping happens */
403
406 int64_t
start_time;
/* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
409 int nb_streams;
/* number of stream that ffmpeg is aware of; may be different
410 from ctx.nb_streams if new streams appear during av_read_frame() */
414
415 #if HAVE_THREADS
417 pthread_t thread;
/* thread reading from this file */
418 int non_blocking; /* reading packets from the thread should not block */
419 int joined; /* the thread has been joined */
420 int thread_queue_size; /* maximum number of queued packets */
421 #endif
423
431 };
432
433 #define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
434
436
441
444 int index;
/* stream index in the output file */
449 /* input pts and corresponding output pts
450 for A/V sync */
452 int64_t
sync_opts;
/* output frame counter, could be changed to some true timestamp */ // FIXME look at frame_number
453 /* pts of the first frame encoded for this stream, used for limiting
454 * recording time */
456 /* dts of the last packet sent to the muxer */
458 // the timebase of the packets sent to the muxer
461
464
473
475
476 /* video only */
483
485
486 /* forced key frames */
493
494 /* audio only */
497
500
503 char *
filters;
///< filtergraph associated to the -filter option
504 char *
filters_script;
///< filtergraph script associated to the -filter_script option
505
512 int unavailable;
/* true if the steram is unavailable (possibly temporarily) */
514
515 // init_output_stream() has been called for this stream
516 // The encoder and the bitstream filters have been initialized and the stream
517 // parameters are set in the AVStream.
519
521
526
528
529 /* stats */
530 // combined size of all the packets written
532 // number of packets send to the muxer
534 // number of frames/samples sent to the encoder
537
538 /* packet quality factor */
540
542
543 /* the packets are buffered here until the muxer is ready to be initialized */
545
546 /* packet picture type */
548
549 /* frame encode sum of squared error values */
552
556 int ost_index;
/* index of the first stream in output_streams */
557 int64_t
recording_time;
///< desired length of the resulting file in microseconds == AV_TIME_BASE units
558 int64_t
start_time;
///< start time in microseconds == AV_TIME_BASE units
560
562
565
570
575
578
581
585
608
612
614
618 #if CONFIG_QSV
620 #endif
622
623
626
629
631
634
636
639
647
649
651
653
657
661
664
666
667 #endif /* FFTOOLS_FFMPEG_H */
SpecifierOpt * passlogfiles
int64_t recording_time
desired length of the resulting file in microseconds == AV_TIME_BASE units
enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *avctx, AVCodec *codec, enum AVPixelFormat target)
This structure describes decoded (raw) audio or video data.
char * filters
filtergraph associated to the -filter option
SpecifierOpt * hwaccel_output_formats
HWDevice * filter_hw_device
OutputFile ** output_files
Main libavfilter public API header.
SpecifierOpt * copy_initial_nonkeyframes
int nb_chroma_intra_matrices
void choose_sample_fmt(AVStream *st, AVCodec *codec)
SpecifierOpt * reinit_filters
The bitstream filter state.
int max_muxing_queue_size
SpecifierOpt * sample_fmts
SpecifierOpt * guess_layout_max
void hw_device_free_all(void)
Convenience header that includes libavutil's core.
int cuvid_init(AVCodecContext *s)
FilterGraph ** filtergraphs
This struct describes the properties of an encoded stream.
float dts_error_threshold
int64_t start_time
start time in microseconds == AV_TIME_BASE units
SpecifierOpt * frame_pix_fmts
SpecifierOpt * chroma_intra_matrices
SpecifierOpt * intra_matrices
void remove_avoptions(AVDictionary **a, AVDictionary *b)
int copy_initial_nonkeyframes
AVDictionary * resample_opts
void reset_options(OptionsContext *o, int is_input)
SpecifierOpt * bitstream_filters
int init_complex_filtergraph(FilterGraph *fg)
int ist_in_filtergraph(FilterGraph *fg, InputStream *ist)
int filter_complex_nbthreads
SpecifierOpt * disposition
SpecifierOpt * enc_time_bases
Callback for checking whether to abort blocking functions.
libswresample public header
void check_filter_outputs(void)
int ffmpeg_parse_options(int argc, char **argv)
AudioChannelMap * audio_channel_maps
SpecifierOpt * codec_tags
SpecifierOpt * rc_overrides
int(* init)(AVCodecContext *s)
int hw_device_setup_for_encode(OutputStream *ost)
float frame_drop_threshold
AVRational frame_aspect_ratio
int nb_audio_channel_maps
SpecifierOpt * filter_scripts
int nb_hwaccel_output_formats
SpecifierOpt * audio_channels
uint64_t * channel_layouts
SpecifierOpt * time_bases
int metadata_chapters_manual
struct OutputStream * ost
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
SpecifierOpt * audio_sample_rate
int hw_device_setup_for_decode(InputStream *ist)
double forced_keyframes_expr_const_values[FKF_NB]
void opt_output_file(void *optctx, const char *filename)
int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
SpecifierOpt * dump_attachment
void assert_avoptions(AVDictionary *m)
SpecifierOpt * canvas_sizes
int qsv_init(AVCodecContext *s)
SpecifierOpt * metadata_map
int audio_channels_mapped
SpecifierOpt * copy_prior_start
SpecifierOpt * frame_aspect_ratios
SpecifierOpt * frame_sizes
HWDevice * hw_device_get_by_name(const char *name)
A linked-list of the inputs/outputs of the filter chain.
SpecifierOpt * frame_rates
struct InputStream * sync_ist
Libavcodec external API header.
AVFifoBuffer * muxing_queue
OutputStream ** output_streams
main external API structure.
int metadata_streams_manual
const char * attachment_filename
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
a very simple circular buffer FIFO implementation
SpecifierOpt * top_field_first
int configure_filtergraph(FilterGraph *fg)
Rational number (pair of numerator and denominator).
int metadata_global_manual
double rotate_override_value
int filtergraph_is_simple(FilterGraph *fg)
int frame_bits_per_raw_sample
char * filters_script
filtergraph script associated to the -filter_script option
SpecifierOpt * hwaccel_devices
float audio_drift_threshold
InputStream ** input_streams
AVIOContext * progress_avio
AVExpr * forced_keyframes_pexpr
const AVIOInterruptCB int_cb
A reference to a data buffer.
SpecifierOpt * max_muxing_queue_size
struct FilterGraph * graph
const OptionDef options[]
AVCodecParameters * ref_par
Utilties for rational number calculation.
SpecifierOpt * inter_matrices
const char *const forced_keyframes_const_names[]
SpecifierOpt * forced_key_frames
const char ** attachments
int nb_max_muxing_queue_size
AVBufferRef * hw_device_ctx
enum AVPixelFormat pix_fmt
SpecifierOpt * fix_sub_duration
SpecifierOpt * autorotate
int hwaccel_decode_init(AVCodecContext *avctx)
float dts_delta_threshold
int guess_input_channel_layout(InputStream *ist)
SpecifierOpt * max_frames
int nb_copy_initial_nonkeyframes
int hw_device_init_from_string(const char *arg, HWDevice **dev)
SpecifierOpt * codec_names
AVDictionary * encoder_opts
char * videotoolbox_pixfmt
int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
AVPixelFormat
Pixel format.
void sub2video_update(InputStream *ist, AVSubtitle *sub)
int nb_frame_aspect_ratios
int videotoolbox_init(AVCodecContext *s)
simple arithmetic expression evaluator