| 2555 | } |
| 2556 | |
| 2557 | static int probe_file(AVTextFormatContext *tfc, const char *filename, |
| 2558 | const char *print_filename) |
| 2559 | { |
| 2560 | InputFile ifile = { 0 }; |
| 2561 | int ret, i; |
| 2562 | int section_id; |
| 2563 | |
| 2564 | do_analyze_frames = do_analyze_frames && do_show_streams; |
| 2565 | do_read_frames = do_show_frames || do_count_frames || do_analyze_frames; |
| 2566 | do_read_packets = do_show_packets || do_count_packets; |
| 2567 | |
| 2568 | ret = open_input_file(&ifile, filename, print_filename); |
| 2569 | if (ret < 0) |
| 2570 | goto end; |
| 2571 | |
| 2572 | #define CHECK_END if (ret < 0) goto end |
| 2573 | |
| 2574 | nb_streams = ifile.fmt_ctx->nb_streams; |
| 2575 | REALLOCZ_ARRAY_STREAM(nb_streams_frames,0,ifile.fmt_ctx->nb_streams); |
| 2576 | REALLOCZ_ARRAY_STREAM(nb_streams_packets,0,ifile.fmt_ctx->nb_streams); |
| 2577 | REALLOCZ_ARRAY_STREAM(selected_streams,0,ifile.fmt_ctx->nb_streams); |
| 2578 | REALLOCZ_ARRAY_STREAM(streams_with_closed_captions,0,ifile.fmt_ctx->nb_streams); |
| 2579 | REALLOCZ_ARRAY_STREAM(streams_with_film_grain,0,ifile.fmt_ctx->nb_streams); |
| 2580 | |
| 2581 | for (i = 0; i < ifile.fmt_ctx->nb_streams; i++) { |
| 2582 | if (stream_specifier) { |
| 2583 | ret = avformat_match_stream_specifier(ifile.fmt_ctx, |
| 2584 | ifile.fmt_ctx->streams[i], |
| 2585 | stream_specifier); |
| 2586 | CHECK_END; |
| 2587 | else |
| 2588 | selected_streams[i] = ret; |
| 2589 | ret = 0; |
| 2590 | } else { |
| 2591 | selected_streams[i] = 1; |
| 2592 | } |
| 2593 | if (!selected_streams[i]) |
| 2594 | ifile.fmt_ctx->streams[i]->discard = AVDISCARD_ALL; |
| 2595 | } |
| 2596 | |
| 2597 | if (do_read_frames || do_read_packets) { |
| 2598 | if (do_show_frames && do_show_packets && |
| 2599 | tfc->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_MIXED_ARRAY_CONTENT) |
| 2600 | section_id = SECTION_ID_PACKETS_AND_FRAMES; |
| 2601 | else if (do_show_packets && !do_show_frames) |
| 2602 | section_id = SECTION_ID_PACKETS; |
| 2603 | else // (!do_show_packets && do_show_frames) |
| 2604 | section_id = SECTION_ID_FRAMES; |
| 2605 | if (do_show_frames || do_show_packets) |
| 2606 | avtext_print_section_header(tfc, NULL, section_id); |
| 2607 | ret = read_packets(tfc, &ifile); |
| 2608 | if (do_show_frames || do_show_packets) |
| 2609 | avtext_print_section_footer(tfc); |
| 2610 | CHECK_END; |
| 2611 | } |
| 2612 | |
| 2613 | if (do_show_programs) { |
| 2614 | ret = show_programs(tfc, &ifile); |
no test coverage detected