diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2012-01-01 17:18:18 +0100 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2012-01-07 11:02:13 +0100 |
commit | fa7d1c39fd5edfa09e210ebce4b40fc872eb6abd (patch) | |
tree | 7ebcce0e90badfe6ae3ed40ff3dcb0c0aff69bed /ffprobe.c | |
parent | e869d08cbceee27f08e77eb54eef93740f5df00b (diff) | |
download | ffmpeg-fa7d1c39fd5edfa09e210ebce4b40fc872eb6abd.tar.gz |
ffprobe: move writer context registration and initialization in main()
Simplify pending changes, as the writer context will be used in the
main() routine.
Diffstat (limited to 'ffprobe.c')
-rw-r--r-- | ffprobe.c | 62 |
1 files changed, 30 insertions, 32 deletions
@@ -1392,31 +1392,10 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename) } \ } while (0) -static int probe_file(const char *filename) +static int probe_file(WriterContext *wctx, const char *filename) { AVFormatContext *fmt_ctx; int ret; - const Writer *w; - char *buf; - char *w_name = NULL, *w_args = NULL; - WriterContext *wctx; - - writer_register_all(); - - if (!print_format) - print_format = av_strdup("default"); - w_name = av_strtok(print_format, "=", &buf); - w_args = buf; - - w = writer_get_by_name(w_name); - if (!w) { - av_log(NULL, AV_LOG_ERROR, "Unknown output format with name '%s'\n", w_name); - ret = AVERROR(EINVAL); - goto end; - } - - if ((ret = writer_open(&wctx, w, w_args, NULL)) < 0) - goto end; writer_print_header(wctx); ret = open_input_file(&fmt_ctx, filename); @@ -1429,10 +1408,6 @@ static int probe_file(const char *filename) show_error(wctx, ret); } writer_print_footer(wctx); - writer_close(&wctx); - -end: - av_freep(&print_format); return ret; } @@ -1513,6 +1488,10 @@ static const OptionDef options[] = { int main(int argc, char **argv) { + const Writer *w; + WriterContext *wctx; + char *buf; + char *w_name = NULL, *w_args = NULL; int ret; parse_loglevel(argc, argv, options); @@ -1526,15 +1505,34 @@ int main(int argc, char **argv) show_banner(argc, argv, options); parse_options(NULL, argc, argv, options, opt_input_file); - if (!input_filename) { - show_usage(); - av_log(NULL, AV_LOG_ERROR, "You have to specify one input file.\n"); - av_log(NULL, AV_LOG_ERROR, "Use -h to get full help or, even better, run 'man %s'.\n", program_name); - exit(1); + writer_register_all(); + + if (!print_format) + print_format = av_strdup("default"); + w_name = av_strtok(print_format, "=", &buf); + w_args = buf; + + w = writer_get_by_name(w_name); + if (!w) { + av_log(NULL, AV_LOG_ERROR, "Unknown output format with name '%s'\n", w_name); + ret = AVERROR(EINVAL); + goto end; } - ret = probe_file(input_filename); + if ((ret = writer_open(&wctx, w, w_args, NULL)) >= 0) { + if (!input_filename) { + show_usage(); + av_log(NULL, AV_LOG_ERROR, "You have to specify one input file.\n"); + av_log(NULL, AV_LOG_ERROR, "Use -h to get full help or, even better, run 'man %s'.\n", program_name); + ret = AVERROR(EINVAL); + } else + ret = probe_file(wctx, input_filename); + + writer_close(&wctx); + } +end: + av_freep(&print_format); avformat_network_deinit(); return ret; |