ffprobe: add pixel format flags output
authorTobias Rapp <t.rapp@noa-audio.com>
Mon, 15 Sep 2014 15:15:17 +0000 (17:15 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 7 Oct 2014 21:18:15 +0000 (23:18 +0200)
Adds output of pixel format flags to ffprobe -show_pixel_formats option.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
doc/ffprobe.xsd
ffprobe.c

index 598f651..e460e01 100644 (file)
         </xsd:sequence>
     </xsd:complexType>
 
+    <xsd:complexType name="pixelFormatFlagsType">
+      <xsd:attribute name="big_endian" type="xsd:int" use="required"/>
+      <xsd:attribute name="palette"    type="xsd:int" use="required"/>
+      <xsd:attribute name="bitstream"  type="xsd:int" use="required"/>
+      <xsd:attribute name="hwaccel"    type="xsd:int" use="required"/>
+      <xsd:attribute name="planar"     type="xsd:int" use="required"/>
+      <xsd:attribute name="rgb"        type="xsd:int" use="required"/>
+      <xsd:attribute name="pseudopal"  type="xsd:int" use="required"/>
+      <xsd:attribute name="alpha"      type="xsd:int" use="required"/>
+    </xsd:complexType>
+
     <xsd:complexType name="pixelFormatType">
+      <xsd:sequence>
+        <xsd:element name="flags" type="ffprobe:pixelFormatFlagsType" minOccurs="0" maxOccurs="1"/>
+      </xsd:sequence>
+
       <xsd:attribute name="name"                type="xsd:string" use="required"/>
       <xsd:attribute name="nb_components"       type="xsd:int"    use="required"/>
       <xsd:attribute name="bits_per_pixel"      type="xsd:int"/>
index 41667f1..c0f9b84 100644 (file)
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -67,6 +67,7 @@ static int do_show_data    = 0;
 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_chapter_tags = 0;
 static int do_show_format_tags = 0;
@@ -134,6 +135,7 @@ typedef enum {
     SECTION_ID_PACKETS,
     SECTION_ID_PACKETS_AND_FRAMES,
     SECTION_ID_PIXEL_FORMAT,
+    SECTION_ID_PIXEL_FORMAT_FLAGS,
     SECTION_ID_PIXEL_FORMATS,
     SECTION_ID_PROGRAM_STREAM_DISPOSITION,
     SECTION_ID_PROGRAM_STREAM_TAGS,
@@ -169,7 +171,8 @@ 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, { -1 } },
+    [SECTION_ID_PIXEL_FORMAT] =       { SECTION_ID_PIXEL_FORMAT, "pixel_format", 0, { SECTION_ID_PIXEL_FORMAT_FLAGS, -1 } },
+    [SECTION_ID_PIXEL_FORMAT_FLAGS] = { SECTION_ID_PIXEL_FORMAT_FLAGS, "flags", 0, { -1 }, .unique_name = "pixel_format_flags" },
     [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 } },
@@ -2563,6 +2566,11 @@ static void ffprobe_show_library_versions(WriterContext *w)
     writer_print_section_footer(w);
 }
 
+#define PRINT_PIX_FMT_FLAG(flagname, name)                                \
+    do {                                                                  \
+        print_int(name, !!(pixdesc->flags & AV_PIX_FMT_FLAG_##flagname)); \
+    } while (0)
+
 static void ffprobe_show_pixel_formats(WriterContext *w)
 {
     const AVPixFmtDescriptor *pixdesc = NULL;
@@ -2576,6 +2584,18 @@ static void ffprobe_show_pixel_formats(WriterContext *w)
         n = av_get_bits_per_pixel(pixdesc);
         if (n) print_int    ("bits_per_pixel", n);
         else   print_str_opt("bits_per_pixel", "N/A");
+        if (do_show_pixel_format_flags) {
+            writer_print_section_header(w, SECTION_ID_PIXEL_FORMAT_FLAGS);
+            PRINT_PIX_FMT_FLAG(BE,        "big_endian");
+            PRINT_PIX_FMT_FLAG(PAL,       "palette");
+            PRINT_PIX_FMT_FLAG(BITSTREAM, "bitstream");
+            PRINT_PIX_FMT_FLAG(HWACCEL,   "hwaccel");
+            PRINT_PIX_FMT_FLAG(PLANAR,    "planar");
+            PRINT_PIX_FMT_FLAG(RGB,       "rgb");
+            PRINT_PIX_FMT_FLAG(PSEUDOPAL, "pseudopal");
+            PRINT_PIX_FMT_FLAG(ALPHA,     "alpha");
+            writer_print_section_footer(w);
+        }
         writer_print_section_footer(w);
     }
     writer_print_section_footer(w);
@@ -3011,6 +3031,7 @@ int main(int argc, char **argv)
     SET_DO_SHOW(LIBRARY_VERSIONS, library_versions);
     SET_DO_SHOW(PACKETS, packets);
     SET_DO_SHOW(PIXEL_FORMATS, pixel_formats);
+    SET_DO_SHOW(PIXEL_FORMAT_FLAGS, pixel_format_flags);
     SET_DO_SHOW(PROGRAM_VERSION, program_version);
     SET_DO_SHOW(PROGRAMS, programs);
     SET_DO_SHOW(STREAMS, streams);