[FFmpeg-cvslog] ffprobe: simplify/fix logic for the -show_format_entry option
Stefano Sabatini
git at videolan.org
Mon May 14 13:01:36 CEST 2012
ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Wed May 9 00:43:58 2012 +0200| [6cd06bd22c9ba2bcbe165d5e6e09334b7386dc2f] | committer: Stefano Sabatini
ffprobe: simplify/fix logic for the -show_format_entry option
Do not skip chapter header/footer printing, which breaks the parsing for
most writers.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6cd06bd22c9ba2bcbe165d5e6e09334b7386dc2f
---
ffprobe.c | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/ffprobe.c b/ffprobe.c
index 8145437..fb37d08 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -178,6 +178,8 @@ struct WriterContext {
unsigned int nb_item; ///< number of the item printed in the given section, starting at 0
unsigned int nb_section; ///< number of the section printed in the given section sequence, starting at 0
unsigned int nb_chapter; ///< number of the chapter, starting at 0
+
+ int is_fmt_chapter; ///< tells if the current chapter is "format", required by the print_format_entry option
};
static const char *writer_get_name(void *p)
@@ -252,6 +254,8 @@ static inline void writer_print_chapter_header(WriterContext *wctx,
if (wctx->writer->print_chapter_header)
wctx->writer->print_chapter_header(wctx, chapter);
wctx->nb_section = 0;
+
+ wctx->is_fmt_chapter = !strcmp(chapter, "format");
}
static inline void writer_print_chapter_footer(WriterContext *wctx,
@@ -265,27 +269,23 @@ static inline void writer_print_chapter_footer(WriterContext *wctx,
static inline void writer_print_section_header(WriterContext *wctx,
const char *section)
{
- if (!fmt_entries_to_show || (section && av_dict_get(fmt_entries_to_show, section, NULL, 0))) {
- if (wctx->writer->print_section_header)
- wctx->writer->print_section_header(wctx, section);
- wctx->nb_item = 0;
- }
+ if (wctx->writer->print_section_header)
+ wctx->writer->print_section_header(wctx, section);
+ wctx->nb_item = 0;
}
static inline void writer_print_section_footer(WriterContext *wctx,
const char *section)
{
- if (!fmt_entries_to_show || (section && av_dict_get(fmt_entries_to_show, section, NULL, 0))) {
- if (wctx->writer->print_section_footer)
- wctx->writer->print_section_footer(wctx, section);
- wctx->nb_section++;
- }
+ if (wctx->writer->print_section_footer)
+ wctx->writer->print_section_footer(wctx, section);
+ wctx->nb_section++;
}
static inline void writer_print_integer(WriterContext *wctx,
const char *key, long long int val)
{
- if (!fmt_entries_to_show || (key && av_dict_get(fmt_entries_to_show, key, NULL, 0))) {
+ if (!wctx->is_fmt_chapter || !fmt_entries_to_show || av_dict_get(fmt_entries_to_show, key, NULL, 0)) {
wctx->writer->print_integer(wctx, key, val);
wctx->nb_item++;
}
@@ -296,7 +296,7 @@ static inline void writer_print_string(WriterContext *wctx,
{
if (opt && !(wctx->writer->flags & WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS))
return;
- if (!fmt_entries_to_show || (key && av_dict_get(fmt_entries_to_show, key, NULL, 0))) {
+ if (!wctx->is_fmt_chapter || !fmt_entries_to_show || av_dict_get(fmt_entries_to_show, key, NULL, 0)) {
wctx->writer->print_string(wctx, key, val);
wctx->nb_item++;
}
@@ -307,7 +307,7 @@ static void writer_print_time(WriterContext *wctx, const char *key,
{
char buf[128];
- if (!fmt_entries_to_show || (key && av_dict_get(fmt_entries_to_show, key, NULL, 0))) {
+ if (!wctx->is_fmt_chapter || !fmt_entries_to_show || av_dict_get(fmt_entries_to_show, key, NULL, 0)) {
if (ts == AV_NOPTS_VALUE) {
writer_print_string(wctx, key, "N/A", 1);
} else {
More information about the ffmpeg-cvslog
mailing list