avformat/vqf: fix memory leak in add_metadata()
[ffmpeg.git] / fftools / ffmpeg.h
blob9439be0f41abe43f12a332aae32cc87a6586945b
1 /*
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
19 #ifndef FFTOOLS_FFMPEG_H
20 #define FFTOOLS_FFMPEG_H
22 #include "config.h"
24 #include <stdatomic.h>
25 #include <stdint.h>
26 #include <stdio.h>
27 #include <signal.h>
29 #include "cmdutils.h"
30 #include "ffmpeg_sched.h"
31 #include "sync_queue.h"
33 #include "libavformat/avformat.h"
34 #include "libavformat/avio.h"
36 #include "libavcodec/avcodec.h"
37 #include "libavcodec/bsf.h"
39 #include "libavfilter/avfilter.h"
41 #include "libavutil/avutil.h"
42 #include "libavutil/dict.h"
43 #include "libavutil/eval.h"
44 #include "libavutil/fifo.h"
45 #include "libavutil/hwcontext.h"
46 #include "libavutil/pixfmt.h"
47 #include "libavutil/rational.h"
48 #include "libavutil/thread.h"
49 #include "libavutil/threadmessage.h"
51 #include "libswresample/swresample.h"
53 // deprecated features
54 #define FFMPEG_OPT_QPHIST 1
55 #define FFMPEG_OPT_ADRIFT_THRESHOLD 1
56 #define FFMPEG_OPT_ENC_TIME_BASE_NUM 1
57 #define FFMPEG_OPT_TOP 1
58 #define FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP 1
59 #define FFMPEG_OPT_VSYNC_DROP 1
60 #define FFMPEG_OPT_VSYNC 1
61 #define FFMPEG_OPT_FILTER_SCRIPT 1
63 #define FFMPEG_ERROR_RATE_EXCEEDED FFERRTAG('E', 'R', 'E', 'D')
65 enum VideoSyncMethod {
66 VSYNC_AUTO = -1,
67 VSYNC_PASSTHROUGH,
68 VSYNC_CFR,
69 VSYNC_VFR,
70 VSYNC_VSCFR,
71 #if FFMPEG_OPT_VSYNC_DROP
72 VSYNC_DROP,
73 #endif
76 enum EncTimeBase {
77 ENC_TIME_BASE_DEMUX = -1,
78 ENC_TIME_BASE_FILTER = -2,
81 enum HWAccelID {
82 HWACCEL_NONE = 0,
83 HWACCEL_AUTO,
84 HWACCEL_GENERIC,
87 enum FrameOpaque {
88 FRAME_OPAQUE_SUB_HEARTBEAT = 1,
89 FRAME_OPAQUE_EOF,
90 FRAME_OPAQUE_SEND_COMMAND,
93 enum PacketOpaque {
94 PKT_OPAQUE_SUB_HEARTBEAT = 1,
95 PKT_OPAQUE_FIX_SUB_DURATION,
98 enum LatencyProbe {
99 LATENCY_PROBE_DEMUX,
100 LATENCY_PROBE_DEC_PRE,
101 LATENCY_PROBE_DEC_POST,
102 LATENCY_PROBE_FILTER_PRE,
103 LATENCY_PROBE_FILTER_POST,
104 LATENCY_PROBE_ENC_PRE,
105 LATENCY_PROBE_ENC_POST,
106 LATENCY_PROBE_NB,
109 typedef struct HWDevice {
110 const char *name;
111 enum AVHWDeviceType type;
112 AVBufferRef *device_ref;
113 } HWDevice;
115 enum ViewSpecifierType {
116 // no specifier given
117 VIEW_SPECIFIER_TYPE_NONE = 0,
118 // val is view index
119 VIEW_SPECIFIER_TYPE_IDX,
120 // val is view ID
121 VIEW_SPECIFIER_TYPE_ID,
122 // specify view by its position, val is AV_STEREO3D_VIEW_LEFT/RIGHT
123 VIEW_SPECIFIER_TYPE_POS,
124 // use all views, val is ignored
125 VIEW_SPECIFIER_TYPE_ALL,
128 typedef struct ViewSpecifier {
129 enum ViewSpecifierType type;
130 unsigned val;
131 } ViewSpecifier;
133 /* select an input stream for an output stream */
134 typedef struct StreamMap {
135 int disabled; /* 1 is this mapping is disabled by a negative map */
136 int file_index;
137 int stream_index;
138 char *linklabel; /* name of an output link, for mapping lavfi outputs */
140 ViewSpecifier vs;
141 } StreamMap;
143 typedef struct OptionsContext {
144 OptionGroup *g;
146 /* input/output options */
147 int64_t start_time;
148 int64_t start_time_eof;
149 int seek_timestamp;
150 const char *format;
152 SpecifierOptList codec_names;
153 SpecifierOptList audio_ch_layouts;
154 SpecifierOptList audio_channels;
155 SpecifierOptList audio_sample_rate;
156 SpecifierOptList frame_rates;
157 SpecifierOptList max_frame_rates;
158 SpecifierOptList frame_sizes;
159 SpecifierOptList frame_pix_fmts;
161 /* input options */
162 int64_t input_ts_offset;
163 int loop;
164 int rate_emu;
165 float readrate;
166 double readrate_initial_burst;
167 int accurate_seek;
168 int thread_queue_size;
169 int input_sync_ref;
170 int find_stream_info;
172 SpecifierOptList ts_scale;
173 SpecifierOptList dump_attachment;
174 SpecifierOptList hwaccels;
175 SpecifierOptList hwaccel_devices;
176 SpecifierOptList hwaccel_output_formats;
177 SpecifierOptList autorotate;
178 SpecifierOptList apply_cropping;
180 /* output options */
181 StreamMap *stream_maps;
182 int nb_stream_maps;
183 const char **attachments;
184 int nb_attachments;
186 int chapters_input_file;
188 int64_t recording_time;
189 int64_t stop_time;
190 int64_t limit_filesize;
191 float mux_preload;
192 float mux_max_delay;
193 float shortest_buf_duration;
194 int shortest;
195 int bitexact;
197 int video_disable;
198 int audio_disable;
199 int subtitle_disable;
200 int data_disable;
202 // keys are stream indices
203 AVDictionary *streamid;
205 SpecifierOptList metadata;
206 SpecifierOptList max_frames;
207 SpecifierOptList bitstream_filters;
208 SpecifierOptList codec_tags;
209 SpecifierOptList sample_fmts;
210 SpecifierOptList qscale;
211 SpecifierOptList forced_key_frames;
212 SpecifierOptList fps_mode;
213 SpecifierOptList force_fps;
214 SpecifierOptList frame_aspect_ratios;
215 SpecifierOptList display_rotations;
216 SpecifierOptList display_hflips;
217 SpecifierOptList display_vflips;
218 SpecifierOptList rc_overrides;
219 SpecifierOptList intra_matrices;
220 SpecifierOptList inter_matrices;
221 SpecifierOptList chroma_intra_matrices;
222 #if FFMPEG_OPT_TOP
223 SpecifierOptList top_field_first;
224 #endif
225 SpecifierOptList metadata_map;
226 SpecifierOptList presets;
227 SpecifierOptList copy_initial_nonkeyframes;
228 SpecifierOptList copy_prior_start;
229 SpecifierOptList filters;
230 #if FFMPEG_OPT_FILTER_SCRIPT
231 SpecifierOptList filter_scripts;
232 #endif
233 SpecifierOptList reinit_filters;
234 SpecifierOptList fix_sub_duration;
235 SpecifierOptList fix_sub_duration_heartbeat;
236 SpecifierOptList canvas_sizes;
237 SpecifierOptList pass;
238 SpecifierOptList passlogfiles;
239 SpecifierOptList max_muxing_queue_size;
240 SpecifierOptList muxing_queue_data_threshold;
241 SpecifierOptList guess_layout_max;
242 SpecifierOptList apad;
243 SpecifierOptList discard;
244 SpecifierOptList disposition;
245 SpecifierOptList program;
246 SpecifierOptList stream_groups;
247 SpecifierOptList time_bases;
248 SpecifierOptList enc_time_bases;
249 SpecifierOptList autoscale;
250 SpecifierOptList bits_per_raw_sample;
251 SpecifierOptList enc_stats_pre;
252 SpecifierOptList enc_stats_post;
253 SpecifierOptList mux_stats;
254 SpecifierOptList enc_stats_pre_fmt;
255 SpecifierOptList enc_stats_post_fmt;
256 SpecifierOptList mux_stats_fmt;
257 } OptionsContext;
259 enum IFilterFlags {
260 IFILTER_FLAG_AUTOROTATE = (1 << 0),
261 IFILTER_FLAG_REINIT = (1 << 1),
262 IFILTER_FLAG_CFR = (1 << 2),
263 IFILTER_FLAG_CROP = (1 << 3),
266 typedef struct InputFilterOptions {
267 int64_t trim_start_us;
268 int64_t trim_end_us;
270 uint8_t *name;
272 /* When IFILTER_FLAG_CFR is set, the stream is guaranteed to be CFR with
273 * this framerate.
275 * Otherwise, this is an estimate that should not be relied upon to be
276 * accurate */
277 AVRational framerate;
279 unsigned crop_top;
280 unsigned crop_bottom;
281 unsigned crop_left;
282 unsigned crop_right;
284 int sub2video_width;
285 int sub2video_height;
287 // a combination of IFILTER_FLAG_*
288 unsigned flags;
290 AVFrame *fallback;
291 } InputFilterOptions;
293 enum OFilterFlags {
294 OFILTER_FLAG_DISABLE_CONVERT = (1 << 0),
295 // produce 24-bit audio
296 OFILTER_FLAG_AUDIO_24BIT = (1 << 1),
297 OFILTER_FLAG_AUTOSCALE = (1 << 2),
300 typedef struct OutputFilterOptions {
301 // Caller-provided name for this output
302 char *name;
304 // Codec used for encoding, may be NULL
305 const AVCodec *enc;
307 int64_t trim_start_us;
308 int64_t trim_duration_us;
309 int64_t ts_offset;
311 /* Desired output timebase.
312 * Numerator can be one of EncTimeBase values, or 0 when no preference.
314 AVRational output_tb;
316 AVDictionary *sws_opts;
317 AVDictionary *swr_opts;
319 const char *nb_threads;
321 // A combination of OFilterFlags.
322 unsigned flags;
324 int format;
325 int width;
326 int height;
327 enum AVColorSpace color_space;
328 enum AVColorRange color_range;
330 enum VideoSyncMethod vsync_method;
331 AVRational frame_rate;
332 AVRational max_frame_rate;
334 int sample_rate;
335 AVChannelLayout ch_layout;
337 const int *formats;
338 const int *sample_rates;
339 const AVChannelLayout *ch_layouts;
340 const AVRational *frame_rates;
341 const enum AVColorSpace *color_spaces;
342 const enum AVColorRange *color_ranges;
344 // for simple filtergraphs only, view specifier passed
345 // along to the decoder
346 const ViewSpecifier *vs;
347 } OutputFilterOptions;
349 typedef struct InputFilter {
350 struct FilterGraph *graph;
351 uint8_t *name;
352 } InputFilter;
354 typedef struct OutputFilter {
355 const AVClass *class;
357 struct FilterGraph *graph;
358 uint8_t *name;
360 /* for filters that are not yet bound to an output stream,
361 * this stores the output linklabel, if any */
362 int bound;
363 uint8_t *linklabel;
365 char *apad;
367 enum AVMediaType type;
369 atomic_uint_least64_t nb_frames_dup;
370 atomic_uint_least64_t nb_frames_drop;
371 } OutputFilter;
373 typedef struct FilterGraph {
374 const AVClass *class;
375 int index;
377 InputFilter **inputs;
378 int nb_inputs;
379 OutputFilter **outputs;
380 int nb_outputs;
381 } FilterGraph;
383 enum DecoderFlags {
384 DECODER_FLAG_FIX_SUB_DURATION = (1 << 0),
385 // input timestamps are unreliable (guessed by demuxer)
386 DECODER_FLAG_TS_UNRELIABLE = (1 << 1),
387 // decoder should override timestamps by fixed framerate
388 // from DecoderOpts.framerate
389 DECODER_FLAG_FRAMERATE_FORCED = (1 << 2),
390 #if FFMPEG_OPT_TOP
391 DECODER_FLAG_TOP_FIELD_FIRST = (1 << 3),
392 #endif
393 DECODER_FLAG_SEND_END_TS = (1 << 4),
394 // force bitexact decoding
395 DECODER_FLAG_BITEXACT = (1 << 5),
398 typedef struct DecoderOpts {
399 int flags;
401 char *name;
402 void *log_parent;
404 const AVCodec *codec;
405 const AVCodecParameters *par;
407 /* hwaccel options */
408 enum HWAccelID hwaccel_id;
409 enum AVHWDeviceType hwaccel_device_type;
410 char *hwaccel_device;
411 enum AVPixelFormat hwaccel_output_format;
413 AVRational time_base;
415 // Either forced (when DECODER_FLAG_FRAMERATE_FORCED is set) or
416 // estimated (otherwise) video framerate.
417 AVRational framerate;
418 } DecoderOpts;
420 typedef struct Decoder {
421 const AVClass *class;
423 enum AVMediaType type;
425 const uint8_t *subtitle_header;
426 int subtitle_header_size;
428 // number of frames/samples retrieved from the decoder
429 uint64_t frames_decoded;
430 uint64_t samples_decoded;
431 uint64_t decode_errors;
432 } Decoder;
434 typedef struct InputStream {
435 const AVClass *class;
437 /* parent source */
438 struct InputFile *file;
440 int index;
442 AVStream *st;
443 int user_set_discard;
446 * Codec parameters - to be used by the decoding/streamcopy code.
447 * st->codecpar should not be accessed, because it may be modified
448 * concurrently by the demuxing thread.
450 AVCodecParameters *par;
451 Decoder *decoder;
452 const AVCodec *dec;
454 /* framerate forced with -r */
455 AVRational framerate;
456 #if FFMPEG_OPT_TOP
457 int top_field_first;
458 #endif
460 int fix_sub_duration;
462 /* decoded data from this stream goes into all those filters
463 * currently video and audio only */
464 InputFilter **filters;
465 int nb_filters;
466 } InputStream;
468 typedef struct InputFile {
469 const AVClass *class;
471 int index;
473 AVFormatContext *ctx;
474 int64_t input_ts_offset;
475 int input_sync_ref;
477 * Effective format start time based on enabled streams.
479 int64_t start_time_effective;
480 int64_t ts_offset;
481 /* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
482 int64_t start_time;
484 /* streams that ffmpeg is aware of;
485 * there may be extra streams in ctx that are not mapped to an InputStream
486 * if new streams appear dynamically during demuxing */
487 InputStream **streams;
488 int nb_streams;
489 } InputFile;
491 enum forced_keyframes_const {
492 FKF_N,
493 FKF_N_FORCED,
494 FKF_PREV_FORCED_N,
495 FKF_PREV_FORCED_T,
496 FKF_T,
497 FKF_NB
500 #define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
501 #define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 << 1)
503 enum EncStatsType {
504 ENC_STATS_LITERAL = 0,
505 ENC_STATS_FILE_IDX,
506 ENC_STATS_STREAM_IDX,
507 ENC_STATS_FRAME_NUM,
508 ENC_STATS_FRAME_NUM_IN,
509 ENC_STATS_TIMEBASE,
510 ENC_STATS_TIMEBASE_IN,
511 ENC_STATS_PTS,
512 ENC_STATS_PTS_TIME,
513 ENC_STATS_PTS_IN,
514 ENC_STATS_PTS_TIME_IN,
515 ENC_STATS_DTS,
516 ENC_STATS_DTS_TIME,
517 ENC_STATS_SAMPLE_NUM,
518 ENC_STATS_NB_SAMPLES,
519 ENC_STATS_PKT_SIZE,
520 ENC_STATS_BITRATE,
521 ENC_STATS_AVG_BITRATE,
522 ENC_STATS_KEYFRAME,
525 typedef struct EncStatsComponent {
526 enum EncStatsType type;
528 uint8_t *str;
529 size_t str_len;
530 } EncStatsComponent;
532 typedef struct EncStats {
533 EncStatsComponent *components;
534 int nb_components;
536 AVIOContext *io;
538 pthread_mutex_t lock;
539 int lock_initialized;
540 } EncStats;
542 enum {
543 KF_FORCE_SOURCE = 1,
544 #if FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP
545 KF_FORCE_SOURCE_NO_DROP = 2,
546 #endif
549 typedef struct KeyframeForceCtx {
550 int type;
552 int64_t ref_pts;
554 // timestamps of the forced keyframes, in AV_TIME_BASE_Q
555 int64_t *pts;
556 int nb_pts;
557 int index;
559 AVExpr *pexpr;
560 double expr_const_values[FKF_NB];
562 int dropped_keyframe;
563 } KeyframeForceCtx;
565 typedef struct Encoder {
566 const AVClass *class;
568 AVCodecContext *enc_ctx;
570 // number of frames/samples sent to the encoder
571 uint64_t frames_encoded;
572 uint64_t samples_encoded;
573 } Encoder;
575 enum CroppingType {
576 CROP_DISABLED = 0,
577 CROP_ALL,
578 CROP_CODEC,
579 CROP_CONTAINER,
582 typedef struct OutputStream {
583 const AVClass *class;
585 enum AVMediaType type;
587 /* parent muxer */
588 struct OutputFile *file;
590 int index; /* stream index in the output file */
592 /* input stream that is the source for this output stream;
593 * may be NULL for streams with no well-defined source, e.g.
594 * attachments or outputs from complex filtergraphs */
595 InputStream *ist;
597 AVStream *st; /* stream in the output file */
599 Encoder *enc;
601 /* video only */
602 #if FFMPEG_OPT_TOP
603 int top_field_first;
604 #endif
605 int bitexact;
606 int bits_per_raw_sample;
608 AVRational frame_aspect_ratio;
610 KeyframeForceCtx kf;
612 const char *logfile_prefix;
613 FILE *logfile;
615 // simple filtergraph feeding this stream, if any
616 FilterGraph *fg_simple;
617 OutputFilter *filter;
619 char *attachment_filename;
621 /* stats */
622 // number of packets send to the muxer
623 atomic_uint_least64_t packets_written;
625 /* packet quality factor */
626 atomic_int quality;
628 EncStats enc_stats_pre;
629 EncStats enc_stats_post;
632 * bool on whether this stream should be utilized for splitting
633 * subtitles utilizing fix_sub_duration at random access points.
635 unsigned int fix_sub_duration_heartbeat;
636 } OutputStream;
638 typedef struct OutputFile {
639 const AVClass *class;
641 int index;
643 const char *url;
645 OutputStream **streams;
646 int nb_streams;
648 int64_t recording_time; ///< desired length of the resulting file in microseconds == AV_TIME_BASE units
649 int64_t start_time; ///< start time in microseconds == AV_TIME_BASE units
651 int bitexact;
652 } OutputFile;
654 // optionally attached as opaque_ref to decoded AVFrames
655 typedef struct FrameData {
656 // demuxer-estimated dts in AV_TIME_BASE_Q,
657 // to be used when real dts is missing
658 int64_t dts_est;
660 // properties that come from the decoder
661 struct {
662 uint64_t frame_num;
664 int64_t pts;
665 AVRational tb;
666 } dec;
668 AVRational frame_rate_filter;
670 int bits_per_raw_sample;
672 int64_t wallclock[LATENCY_PROBE_NB];
674 AVCodecParameters *par_enc;
675 } FrameData;
677 extern InputFile **input_files;
678 extern int nb_input_files;
680 extern OutputFile **output_files;
681 extern int nb_output_files;
683 // complex filtergraphs
684 extern FilterGraph **filtergraphs;
685 extern int nb_filtergraphs;
687 // standalone decoders (not tied to demuxed streams)
688 extern Decoder **decoders;
689 extern int nb_decoders;
691 extern char *vstats_filename;
693 extern float dts_delta_threshold;
694 extern float dts_error_threshold;
696 extern enum VideoSyncMethod video_sync_method;
697 extern float frame_drop_threshold;
698 extern int do_benchmark;
699 extern int do_benchmark_all;
700 extern int do_hex_dump;
701 extern int do_pkt_dump;
702 extern int copy_ts;
703 extern int start_at_zero;
704 extern int copy_tb;
705 extern int debug_ts;
706 extern int exit_on_error;
707 extern int abort_on_flags;
708 extern int print_stats;
709 extern int64_t stats_period;
710 extern int stdin_interaction;
711 extern AVIOContext *progress_avio;
712 extern float max_error_rate;
714 extern char *filter_nbthreads;
715 extern int filter_complex_nbthreads;
716 extern int vstats_version;
717 extern int auto_conversion_filters;
719 extern const AVIOInterruptCB int_cb;
721 extern const OptionDef options[];
722 extern HWDevice *filter_hw_device;
724 extern atomic_uint nb_output_dumped;
726 extern int ignore_unknown_streams;
727 extern int copy_unknown_streams;
729 extern int recast_media;
731 extern FILE *vstats_file;
733 void term_init(void);
734 void term_exit(void);
736 void show_usage(void);
738 int check_avoptions_used(const AVDictionary *opts, const AVDictionary *opts_used,
739 void *logctx, int decode);
741 int assert_file_overwrite(const char *filename);
742 int find_codec(void *logctx, const char *name,
743 enum AVMediaType type, int encoder, const AVCodec **codec);
744 int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global);
746 int filtergraph_is_simple(const FilterGraph *fg);
747 int fg_create_simple(FilterGraph **pfg,
748 InputStream *ist,
749 char *graph_desc,
750 Scheduler *sch, unsigned sched_idx_enc,
751 const OutputFilterOptions *opts);
752 int fg_finalise_bindings(void);
755 * Get our axiliary frame data attached to the frame, allocating it
756 * if needed.
758 FrameData *frame_data(AVFrame *frame);
760 const FrameData *frame_data_c(AVFrame *frame);
762 FrameData *packet_data (AVPacket *pkt);
763 const FrameData *packet_data_c(AVPacket *pkt);
765 int ofilter_bind_enc(OutputFilter *ofilter,
766 unsigned sched_idx_enc,
767 const OutputFilterOptions *opts);
770 * Create a new filtergraph in the global filtergraph list.
772 * @param graph_desc Graph description; an av_malloc()ed string, filtergraph
773 * takes ownership of it.
775 int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch);
777 void fg_free(FilterGraph **pfg);
779 void fg_send_command(FilterGraph *fg, double time, const char *target,
780 const char *command, const char *arg, int all_filters);
782 int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch);
784 void enc_stats_write(OutputStream *ost, EncStats *es,
785 const AVFrame *frame, const AVPacket *pkt,
786 uint64_t frame_num);
788 HWDevice *hw_device_get_by_name(const char *name);
789 HWDevice *hw_device_get_by_type(enum AVHWDeviceType type);
790 int hw_device_init_from_string(const char *arg, HWDevice **dev);
791 int hw_device_init_from_type(enum AVHWDeviceType type,
792 const char *device,
793 HWDevice **dev_out);
794 void hw_device_free_all(void);
797 * Get a hardware device to be used with this filtergraph.
798 * The returned reference is owned by the callee, the caller
799 * must ref it explicitly for long-term use.
801 AVBufferRef *hw_device_for_filter(void);
804 * Create a standalone decoder.
806 int dec_create(const OptionsContext *o, const char *arg, Scheduler *sch);
809 * @param dec_opts Dictionary filled with decoder options. Its ownership
810 * is transferred to the decoder.
811 * @param param_out If non-NULL, media properties after opening the decoder
812 * are written here.
814 * @retval ">=0" non-negative scheduler index on success
815 * @retval "<0" an error code on failure
817 int dec_init(Decoder **pdec, Scheduler *sch,
818 AVDictionary **dec_opts, const DecoderOpts *o,
819 AVFrame *param_out);
820 void dec_free(Decoder **pdec);
823 * Called by filters to connect decoder's output to given filtergraph input.
825 * @param opts filtergraph input options, to be filled by this function
827 int dec_filter_add(Decoder *dec, InputFilter *ifilter, InputFilterOptions *opts,
828 const ViewSpecifier *vs, SchedulerNode *src);
831 * For multiview video, request output of the view(s) determined by vs.
832 * May be called multiple times.
834 * If this function is never called, only the base view is output. If it is
835 * called at least once, only the views requested are output.
837 * @param src scheduler node from which the frames corresponding vs
838 * will originate
840 int dec_request_view(Decoder *dec, const ViewSpecifier *vs,
841 SchedulerNode *src);
843 int enc_alloc(Encoder **penc, const AVCodec *codec,
844 Scheduler *sch, unsigned sch_idx, void *log_parent);
845 void enc_free(Encoder **penc);
847 int enc_open(void *opaque, const AVFrame *frame);
849 int enc_loopback(Encoder *enc);
852 * Initialize muxing state for the given stream, should be called
853 * after the codec/streamcopy setup has been done.
855 * Open the muxer once all the streams have been initialized.
857 int of_stream_init(OutputFile *of, OutputStream *ost,
858 const AVCodecContext *enc_ctx);
859 int of_write_trailer(OutputFile *of);
860 int of_open(const OptionsContext *o, const char *filename, Scheduler *sch);
861 void of_free(OutputFile **pof);
863 void of_enc_stats_close(void);
865 int64_t of_filesize(OutputFile *of);
867 int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch);
868 void ifile_close(InputFile **f);
870 int ist_use(InputStream *ist, int decoding_needed,
871 const ViewSpecifier *vs, SchedulerNode *src);
872 int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
873 const ViewSpecifier *vs, InputFilterOptions *opts,
874 SchedulerNode *src);
877 * Find an unused input stream of given type.
879 InputStream *ist_find_unused(enum AVMediaType type);
881 /* iterate over all input streams in all input files;
882 * pass NULL to start iteration */
883 InputStream *ist_iter(InputStream *prev);
885 /* iterate over all output streams in all output files;
886 * pass NULL to start iteration */
887 OutputStream *ost_iter(OutputStream *prev);
889 void update_benchmark(const char *fmt, ...);
891 const char *opt_match_per_type_str(const SpecifierOptList *sol,
892 char mediatype);
893 void opt_match_per_stream_str(void *logctx, const SpecifierOptList *sol,
894 AVFormatContext *fc, AVStream *st, const char **out);
895 void opt_match_per_stream_int(void *logctx, const SpecifierOptList *sol,
896 AVFormatContext *fc, AVStream *st, int *out);
897 void opt_match_per_stream_int64(void *logctx, const SpecifierOptList *sol,
898 AVFormatContext *fc, AVStream *st, int64_t *out);
899 void opt_match_per_stream_dbl(void *logctx, const SpecifierOptList *sol,
900 AVFormatContext *fc, AVStream *st, double *out);
902 int view_specifier_parse(const char **pspec, ViewSpecifier *vs);
904 int muxer_thread(void *arg);
905 int encoder_thread(void *arg);
907 #endif /* FFTOOLS_FFMPEG_H */