Browse code

ffprobe: add pixel format flags output

Adds output of pixel format flags to ffprobe -show_pixel_formats option.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Tobias Rapp authored on 2014/09/16 00:15:17
Showing 2 changed files
... ...
@@ -279,7 +279,22 @@
279 279
         </xsd:sequence>
280 280
     </xsd:complexType>
281 281
 
282
+    <xsd:complexType name="pixelFormatFlagsType">
283
+      <xsd:attribute name="big_endian" type="xsd:int" use="required"/>
284
+      <xsd:attribute name="palette"    type="xsd:int" use="required"/>
285
+      <xsd:attribute name="bitstream"  type="xsd:int" use="required"/>
286
+      <xsd:attribute name="hwaccel"    type="xsd:int" use="required"/>
287
+      <xsd:attribute name="planar"     type="xsd:int" use="required"/>
288
+      <xsd:attribute name="rgb"        type="xsd:int" use="required"/>
289
+      <xsd:attribute name="pseudopal"  type="xsd:int" use="required"/>
290
+      <xsd:attribute name="alpha"      type="xsd:int" use="required"/>
291
+    </xsd:complexType>
292
+
282 293
     <xsd:complexType name="pixelFormatType">
294
+      <xsd:sequence>
295
+        <xsd:element name="flags" type="ffprobe:pixelFormatFlagsType" minOccurs="0" maxOccurs="1"/>
296
+      </xsd:sequence>
297
+
283 298
       <xsd:attribute name="name"                type="xsd:string" use="required"/>
284 299
       <xsd:attribute name="nb_components"       type="xsd:int"    use="required"/>
285 300
       <xsd:attribute name="bits_per_pixel"      type="xsd:int"/>
... ...
@@ -67,6 +67,7 @@ static int do_show_data    = 0;
67 67
 static int do_show_program_version  = 0;
68 68
 static int do_show_library_versions = 0;
69 69
 static int do_show_pixel_formats = 0;
70
+static int do_show_pixel_format_flags = 0;
70 71
 
71 72
 static int do_show_chapter_tags = 0;
72 73
 static int do_show_format_tags = 0;
... ...
@@ -134,6 +135,7 @@ typedef enum {
134 134
     SECTION_ID_PACKETS,
135 135
     SECTION_ID_PACKETS_AND_FRAMES,
136 136
     SECTION_ID_PIXEL_FORMAT,
137
+    SECTION_ID_PIXEL_FORMAT_FLAGS,
137 138
     SECTION_ID_PIXEL_FORMATS,
138 139
     SECTION_ID_PROGRAM_STREAM_DISPOSITION,
139 140
     SECTION_ID_PROGRAM_STREAM_TAGS,
... ...
@@ -169,7 +171,8 @@ static struct section sections[] = {
169 169
     [SECTION_ID_PACKETS_AND_FRAMES] = { SECTION_ID_PACKETS_AND_FRAMES, "packets_and_frames", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET, -1} },
170 170
     [SECTION_ID_PACKET] =             { SECTION_ID_PACKET, "packet", 0, { -1 } },
171 171
     [SECTION_ID_PIXEL_FORMATS] =      { SECTION_ID_PIXEL_FORMATS, "pixel_formats", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PIXEL_FORMAT, -1 } },
172
-    [SECTION_ID_PIXEL_FORMAT] =       { SECTION_ID_PIXEL_FORMAT, "pixel_format", 0, { -1 } },
172
+    [SECTION_ID_PIXEL_FORMAT] =       { SECTION_ID_PIXEL_FORMAT, "pixel_format", 0, { SECTION_ID_PIXEL_FORMAT_FLAGS, -1 } },
173
+    [SECTION_ID_PIXEL_FORMAT_FLAGS] = { SECTION_ID_PIXEL_FORMAT_FLAGS, "flags", 0, { -1 }, .unique_name = "pixel_format_flags" },
173 174
     [SECTION_ID_PROGRAM_STREAM_DISPOSITION] = { SECTION_ID_PROGRAM_STREAM_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "program_stream_disposition" },
174 175
     [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" },
175 176
     [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)
2563 2563
     writer_print_section_footer(w);
2564 2564
 }
2565 2565
 
2566
+#define PRINT_PIX_FMT_FLAG(flagname, name)                                \
2567
+    do {                                                                  \
2568
+        print_int(name, !!(pixdesc->flags & AV_PIX_FMT_FLAG_##flagname)); \
2569
+    } while (0)
2570
+
2566 2571
 static void ffprobe_show_pixel_formats(WriterContext *w)
2567 2572
 {
2568 2573
     const AVPixFmtDescriptor *pixdesc = NULL;
... ...
@@ -2576,6 +2584,18 @@ static void ffprobe_show_pixel_formats(WriterContext *w)
2576 2576
         n = av_get_bits_per_pixel(pixdesc);
2577 2577
         if (n) print_int    ("bits_per_pixel", n);
2578 2578
         else   print_str_opt("bits_per_pixel", "N/A");
2579
+        if (do_show_pixel_format_flags) {
2580
+            writer_print_section_header(w, SECTION_ID_PIXEL_FORMAT_FLAGS);
2581
+            PRINT_PIX_FMT_FLAG(BE,        "big_endian");
2582
+            PRINT_PIX_FMT_FLAG(PAL,       "palette");
2583
+            PRINT_PIX_FMT_FLAG(BITSTREAM, "bitstream");
2584
+            PRINT_PIX_FMT_FLAG(HWACCEL,   "hwaccel");
2585
+            PRINT_PIX_FMT_FLAG(PLANAR,    "planar");
2586
+            PRINT_PIX_FMT_FLAG(RGB,       "rgb");
2587
+            PRINT_PIX_FMT_FLAG(PSEUDOPAL, "pseudopal");
2588
+            PRINT_PIX_FMT_FLAG(ALPHA,     "alpha");
2589
+            writer_print_section_footer(w);
2590
+        }
2579 2591
         writer_print_section_footer(w);
2580 2592
     }
2581 2593
     writer_print_section_footer(w);
... ...
@@ -3011,6 +3031,7 @@ int main(int argc, char **argv)
3011 3011
     SET_DO_SHOW(LIBRARY_VERSIONS, library_versions);
3012 3012
     SET_DO_SHOW(PACKETS, packets);
3013 3013
     SET_DO_SHOW(PIXEL_FORMATS, pixel_formats);
3014
+    SET_DO_SHOW(PIXEL_FORMAT_FLAGS, pixel_format_flags);
3014 3015
     SET_DO_SHOW(PROGRAM_VERSION, program_version);
3015 3016
     SET_DO_SHOW(PROGRAMS, programs);
3016 3017
     SET_DO_SHOW(STREAMS, streams);