aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg.h
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-10-13 12:24:43 +0200
committerAnton Khirnov <anton@khirnov.net>2022-10-18 13:57:42 +0200
commit18d6c07267994398f99b2241f577f8e7118af099 (patch)
treec0006fd2782de09562e79bf70aa5a17375309bef /fftools/ffmpeg.h
parent965bff37b6181b9db248a0deef7e2643d0ef9721 (diff)
downloadffmpeg-18d6c07267994398f99b2241f577f8e7118af099.tar.gz
fftools/ffmpeg_opt: move opening output files into a new file
ffmpeg_opt.c currently contains code for - parsing the options provided on the command line - opening and initializing input files based on these options - opening and initializing output files based on these options The code dealing with each of these is for the most part disjoint, so it makes sense to move them to separate files. Beyond reducing the quite considerable size of ffmpeg_opt.c, this will also allow exposing muxer internals (currently private to ffmpeg_mux.c) to the initialization code, thus removing the awkward separation currently in place.
Diffstat (limited to 'fftools/ffmpeg.h')
-rw-r--r--fftools/ffmpeg.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 5030f72fe5..f45b352bb0 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -686,6 +686,13 @@ extern HWDevice *filter_hw_device;
extern unsigned nb_output_dumped;
extern int main_return_code;
+extern int input_stream_potentially_available;
+extern int ignore_unknown_streams;
+extern int copy_unknown_streams;
+
+#if FFMPEG_OPT_PSNR
+extern int do_psnr;
+#endif
void term_init(void);
void term_exit(void);
@@ -695,6 +702,12 @@ void show_usage(void);
void remove_avoptions(AVDictionary **a, AVDictionary *b);
void assert_avoptions(AVDictionary *m);
+void assert_file_overwrite(const char *filename);
+char *read_file(const char *filename);
+AVDictionary *strip_specifiers(AVDictionary *dict);
+const AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder);
+int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global);
+
int configure_filtergraph(FilterGraph *fg);
void check_filter_outputs(void);
int filtergraph_is_simple(FilterGraph *fg);
@@ -729,6 +742,7 @@ int of_muxer_init(OutputFile *of, AVFormatContext *fc,
*/
int of_stream_init(OutputFile *of, OutputStream *ost);
int of_write_trailer(OutputFile *of);
+int of_open(OptionsContext *o, const char *filename);
void of_close(OutputFile **pof);
/*
@@ -761,4 +775,59 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt);
int init_input_threads(void);
void free_input_threads(void);
+#define SPECIFIER_OPT_FMT_str "%s"
+#define SPECIFIER_OPT_FMT_i "%i"
+#define SPECIFIER_OPT_FMT_i64 "%"PRId64
+#define SPECIFIER_OPT_FMT_ui64 "%"PRIu64
+#define SPECIFIER_OPT_FMT_f "%f"
+#define SPECIFIER_OPT_FMT_dbl "%lf"
+
+#define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\
+{\
+ char namestr[128] = "";\
+ const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\
+ for (i = 0; opt_name_##name[i]; i++)\
+ av_strlcatf(namestr, sizeof(namestr), "-%s%s", opt_name_##name[i], opt_name_##name[i+1] ? (opt_name_##name[i+2] ? ", " : " or ") : "");\
+ av_log(NULL, AV_LOG_WARNING, "Multiple %s options specified for stream %d, only the last option '-%s%s%s "SPECIFIER_OPT_FMT_##type"' will be used.\n",\
+ namestr, st->index, opt_name_##name[0], spec[0] ? ":" : "", spec, so->u.type);\
+}
+
+#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
+{\
+ int i, ret, matches = 0;\
+ SpecifierOpt *so;\
+ for (i = 0; i < o->nb_ ## name; i++) {\
+ char *spec = o->name[i].specifier;\
+ if ((ret = check_stream_specifier(fmtctx, st, spec)) > 0) {\
+ outvar = o->name[i].u.type;\
+ so = &o->name[i];\
+ matches++;\
+ } else if (ret < 0)\
+ exit_program(1);\
+ }\
+ if (matches > 1)\
+ WARN_MULTIPLE_OPT_USAGE(name, type, so, st);\
+}
+
+#define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\
+{\
+ int i;\
+ for (i = 0; i < o->nb_ ## name; i++) {\
+ char *spec = o->name[i].specifier;\
+ if (!strcmp(spec, mediatype))\
+ outvar = o->name[i].u.type;\
+ }\
+}
+
+extern const char * const opt_name_audio_channels[];
+extern const char * const opt_name_audio_ch_layouts[];
+extern const char * const opt_name_audio_sample_rate[];
+extern const char * const opt_name_codec_names[];
+extern const char * const opt_name_codec_tags[];
+extern const char * const opt_name_frame_rates[];
+extern const char * const opt_name_frame_sizes[];
+extern const char * const opt_name_frame_pix_fmts[];
+extern const char * const opt_name_sample_fmts[];
+extern const char * const opt_name_top_field_first[];
+
#endif /* FFTOOLS_FFMPEG_H */