+void set_context_opts(void *ctx, void *opts_ctx, int flags)
+{
+ int i;
+ for(i=0; i<opt_name_count; i++){
+ char buf[256];
+ const AVOption *opt;
+ const char *str= av_get_string(opts_ctx, opt_names[i], &opt, buf, sizeof(buf));
+ /* if an option with name opt_names[i] is present in opts_ctx then str is non-NULL */
+ if(str && ((opt->flags & flags) == flags))
+ av_set_string3(ctx, opt_names[i], str, 1, NULL);
+ }
+}
+
+void print_error(const char *filename, int err)
+{
+ char errbuf[128];
+ const char *errbuf_ptr = errbuf;
+
+ if (av_strerror(err, errbuf, sizeof(errbuf)) < 0)
+ errbuf_ptr = strerror(AVUNERROR(err));
+ fprintf(stderr, "%s: %s\n", filename, errbuf_ptr);
+}
+
+#define PRINT_LIB_VERSION(outstream,libname,LIBNAME,indent) \
+ if (CONFIG_##LIBNAME) { \
+ unsigned int version = libname##_version(); \
+ fprintf(outstream, "%slib%-10s %2d.%2d.%2d / %2d.%2d.%2d\n", \
+ indent? " " : "", #libname, \
+ LIB##LIBNAME##_VERSION_MAJOR, \
+ LIB##LIBNAME##_VERSION_MINOR, \
+ LIB##LIBNAME##_VERSION_MICRO, \
+ version >> 16, version >> 8 & 0xff, version & 0xff); \
+ }
+
+static void print_all_lib_versions(FILE* outstream, int indent)
+{
+ PRINT_LIB_VERSION(outstream, avutil, AVUTIL, indent);
+ PRINT_LIB_VERSION(outstream, avcodec, AVCODEC, indent);
+ PRINT_LIB_VERSION(outstream, avformat, AVFORMAT, indent);
+ PRINT_LIB_VERSION(outstream, avdevice, AVDEVICE, indent);
+ PRINT_LIB_VERSION(outstream, avfilter, AVFILTER, indent);
+ PRINT_LIB_VERSION(outstream, swscale, SWSCALE, indent);
+ PRINT_LIB_VERSION(outstream, postproc, POSTPROC, indent);
+}
+
+static void maybe_print_config(const char *lib, const char *cfg)
+{
+ static int warned_cfg;
+
+ if (strcmp(FFMPEG_CONFIGURATION, cfg)) {
+ if (!warned_cfg) {
+ fprintf(stderr, " WARNING: library configuration mismatch\n");
+ warned_cfg = 1;
+ }
+ fprintf(stderr, " %-11s configuration: %s\n", lib, cfg);
+ }
+}
+
+#define PRINT_LIB_CONFIG(lib, tag, cfg) do { \
+ if (CONFIG_##lib) \
+ maybe_print_config(tag, cfg); \
+ } while (0)
+
+void show_banner(void)
+{
+ fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d the FFmpeg developers\n",
+ program_name, program_birth_year, this_year);
+ fprintf(stderr, " built on %s %s with %s %s\n",
+ __DATE__, __TIME__, CC_TYPE, CC_VERSION);
+ fprintf(stderr, " configuration: " FFMPEG_CONFIGURATION "\n");
+ PRINT_LIB_CONFIG(AVUTIL, "libavutil", avutil_configuration());
+ PRINT_LIB_CONFIG(AVCODEC, "libavcodec", avcodec_configuration());
+ PRINT_LIB_CONFIG(AVFORMAT, "libavformat", avformat_configuration());
+ PRINT_LIB_CONFIG(AVDEVICE, "libavdevice", avdevice_configuration());
+ PRINT_LIB_CONFIG(AVFILTER, "libavfilter", avfilter_configuration());
+ PRINT_LIB_CONFIG(SWSCALE, "libswscale", swscale_configuration());
+ PRINT_LIB_CONFIG(POSTPROC, "libpostproc", postproc_configuration());
+ print_all_lib_versions(stderr, 1);
+}
+
+void show_version(void) {