From 7d327d62426206bd89fc2e0b996faa5be867c0a2 Mon Sep 17 00:00:00 2001 From: Tobias Rapp Date: Mon, 15 Sep 2014 17:15:42 +0200 Subject: [PATCH] ffprobe: add pixel format component bit depth output Adds output of bit depth per pixel format component to ffprobe -show_pixel_formats option. Signed-off-by: Michael Niedermayer --- doc/ffprobe.xsd | 12 ++++++++++++ ffprobe.c | 20 ++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd index e460e01f42..bf17186d32 100644 --- a/doc/ffprobe.xsd +++ b/doc/ffprobe.xsd @@ -290,9 +290,21 @@ + + + + + + + + + + + + diff --git a/ffprobe.c b/ffprobe.c index c0f9b84dfb..b6df74b1b5 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -68,6 +68,7 @@ static int do_show_program_version = 0; static int do_show_library_versions = 0; static int do_show_pixel_formats = 0; static int do_show_pixel_format_flags = 0; +static int do_show_pixel_format_components = 0; static int do_show_chapter_tags = 0; static int do_show_format_tags = 0; @@ -136,6 +137,8 @@ typedef enum { SECTION_ID_PACKETS_AND_FRAMES, SECTION_ID_PIXEL_FORMAT, SECTION_ID_PIXEL_FORMAT_FLAGS, + SECTION_ID_PIXEL_FORMAT_COMPONENT, + SECTION_ID_PIXEL_FORMAT_COMPONENTS, SECTION_ID_PIXEL_FORMATS, SECTION_ID_PROGRAM_STREAM_DISPOSITION, SECTION_ID_PROGRAM_STREAM_TAGS, @@ -171,8 +174,10 @@ static struct section sections[] = { [SECTION_ID_PACKETS_AND_FRAMES] = { SECTION_ID_PACKETS_AND_FRAMES, "packets_and_frames", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET, -1} }, [SECTION_ID_PACKET] = { SECTION_ID_PACKET, "packet", 0, { -1 } }, [SECTION_ID_PIXEL_FORMATS] = { SECTION_ID_PIXEL_FORMATS, "pixel_formats", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PIXEL_FORMAT, -1 } }, - [SECTION_ID_PIXEL_FORMAT] = { SECTION_ID_PIXEL_FORMAT, "pixel_format", 0, { SECTION_ID_PIXEL_FORMAT_FLAGS, -1 } }, + [SECTION_ID_PIXEL_FORMAT] = { SECTION_ID_PIXEL_FORMAT, "pixel_format", 0, { SECTION_ID_PIXEL_FORMAT_FLAGS, SECTION_ID_PIXEL_FORMAT_COMPONENTS, -1 } }, [SECTION_ID_PIXEL_FORMAT_FLAGS] = { SECTION_ID_PIXEL_FORMAT_FLAGS, "flags", 0, { -1 }, .unique_name = "pixel_format_flags" }, + [SECTION_ID_PIXEL_FORMAT_COMPONENTS] = { SECTION_ID_PIXEL_FORMAT_COMPONENTS, "components", SECTION_FLAG_IS_ARRAY, {SECTION_ID_PIXEL_FORMAT_COMPONENT, -1 }, .unique_name = "pixel_format_components" }, + [SECTION_ID_PIXEL_FORMAT_COMPONENT] = { SECTION_ID_PIXEL_FORMAT_COMPONENT, "component", 0, { -1 } }, [SECTION_ID_PROGRAM_STREAM_DISPOSITION] = { SECTION_ID_PROGRAM_STREAM_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "program_stream_disposition" }, [SECTION_ID_PROGRAM_STREAM_TAGS] = { SECTION_ID_PROGRAM_STREAM_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "program_stream_tags" }, [SECTION_ID_PROGRAM] = { SECTION_ID_PROGRAM, "program", 0, { SECTION_ID_PROGRAM_TAGS, SECTION_ID_PROGRAM_STREAMS, -1 } }, @@ -2574,7 +2579,7 @@ static void ffprobe_show_library_versions(WriterContext *w) static void ffprobe_show_pixel_formats(WriterContext *w) { const AVPixFmtDescriptor *pixdesc = NULL; - int n; + int i, n; writer_print_section_header(w, SECTION_ID_PIXEL_FORMATS); while (pixdesc = av_pix_fmt_desc_next(pixdesc)) { @@ -2596,6 +2601,16 @@ static void ffprobe_show_pixel_formats(WriterContext *w) PRINT_PIX_FMT_FLAG(ALPHA, "alpha"); writer_print_section_footer(w); } + if (do_show_pixel_format_components && (pixdesc->nb_components > 0)) { + writer_print_section_header(w, SECTION_ID_PIXEL_FORMAT_COMPONENTS); + for (i = 0; i < pixdesc->nb_components; i++) { + writer_print_section_header(w, SECTION_ID_PIXEL_FORMAT_COMPONENT); + print_int("index", i + 1); + print_int("bit_depth", pixdesc->comp[i].depth_minus1 + 1); + writer_print_section_footer(w); + } + writer_print_section_footer(w); + } writer_print_section_footer(w); } writer_print_section_footer(w); @@ -3032,6 +3047,7 @@ int main(int argc, char **argv) SET_DO_SHOW(PACKETS, packets); SET_DO_SHOW(PIXEL_FORMATS, pixel_formats); SET_DO_SHOW(PIXEL_FORMAT_FLAGS, pixel_format_flags); + SET_DO_SHOW(PIXEL_FORMAT_COMPONENTS, pixel_format_components); SET_DO_SHOW(PROGRAM_VERSION, program_version); SET_DO_SHOW(PROGRAMS, programs); SET_DO_SHOW(STREAMS, streams);