Browse code

ffprobe: support printing AVStream and AVPacket side data

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

Michael Niedermayer authored on 2015/05/03 07:40:50
Showing 2 changed files
... ...
@@ -48,6 +48,11 @@
48 48
     </xsd:complexType>
49 49
 
50 50
     <xsd:complexType name="packetType">
51
+      <xsd:sequence>
52
+        <xsd:element name="tag" type="ffprobe:tagType" minOccurs="0" maxOccurs="unbounded"/>
53
+        <xsd:element name="side_data_list" type="ffprobe:packetSideDataListType"   minOccurs="0" maxOccurs="1" />
54
+      </xsd:sequence>
55
+
51 56
       <xsd:attribute name="codec_type"    type="xsd:string" use="required" />
52 57
       <xsd:attribute name="stream_index"  type="xsd:int" use="required" />
53 58
       <xsd:attribute name="pts"           type="xsd:long"  />
... ...
@@ -65,6 +70,16 @@
65 65
       <xsd:attribute name="data_hash"     type="xsd:string" />
66 66
     </xsd:complexType>
67 67
 
68
+    <xsd:complexType name="packetSideDataListType">
69
+        <xsd:sequence>
70
+            <xsd:element name="side_data" type="ffprobe:packetSideDataType" minOccurs="1" maxOccurs="unbounded"/>
71
+        </xsd:sequence>
72
+    </xsd:complexType>
73
+    <xsd:complexType name="packetSideDataType">
74
+        <xsd:attribute name="side_data_type"              type="xsd:string"/>
75
+        <xsd:attribute name="side_data_size"              type="xsd:int"   />
76
+    </xsd:complexType>
77
+
68 78
     <xsd:complexType name="frameType">
69 79
       <xsd:sequence>
70 80
             <xsd:element name="tag" type="ffprobe:tagType" minOccurs="0" maxOccurs="unbounded"/>
... ...
@@ -156,6 +171,10 @@
156 156
         <xsd:element name="disposition" type="ffprobe:streamDispositionType" minOccurs="0" maxOccurs="1"/>
157 157
         <xsd:element name="tag" type="ffprobe:tagType" minOccurs="0" maxOccurs="unbounded"/>
158 158
       </xsd:sequence>
159
+      <xsd:sequence>
160
+        <xsd:element name="tag" type="ffprobe:tagType" minOccurs="0" maxOccurs="unbounded"/>
161
+        <xsd:element name="side_data_list" type="ffprobe:packetSideDataListType"   minOccurs="0" maxOccurs="1" />
162
+      </xsd:sequence>
159 163
 
160 164
       <xsd:attribute name="index"            type="xsd:int" use="required"/>
161 165
       <xsd:attribute name="codec_name"       type="xsd:string" />
... ...
@@ -137,6 +137,8 @@ typedef enum {
137 137
     SECTION_ID_PACKET,
138 138
     SECTION_ID_PACKETS,
139 139
     SECTION_ID_PACKETS_AND_FRAMES,
140
+    SECTION_ID_PACKET_SIDE_DATA_LIST,
141
+    SECTION_ID_PACKET_SIDE_DATA,
140 142
     SECTION_ID_PIXEL_FORMAT,
141 143
     SECTION_ID_PIXEL_FORMAT_FLAGS,
142 144
     SECTION_ID_PIXEL_FORMAT_COMPONENT,
... ...
@@ -155,6 +157,8 @@ typedef enum {
155 155
     SECTION_ID_STREAM_DISPOSITION,
156 156
     SECTION_ID_STREAMS,
157 157
     SECTION_ID_STREAM_TAGS,
158
+    SECTION_ID_STREAM_SIDE_DATA_LIST,
159
+    SECTION_ID_STREAM_SIDE_DATA,
158 160
     SECTION_ID_SUBTITLE,
159 161
 } SectionID;
160 162
 
... ...
@@ -174,7 +178,9 @@ static struct section sections[] = {
174 174
     [SECTION_ID_LIBRARY_VERSION] =    { SECTION_ID_LIBRARY_VERSION, "library_version", 0, { -1 } },
175 175
     [SECTION_ID_PACKETS] =            { SECTION_ID_PACKETS, "packets", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET, -1} },
176 176
     [SECTION_ID_PACKETS_AND_FRAMES] = { SECTION_ID_PACKETS_AND_FRAMES, "packets_and_frames", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET, -1} },
177
-    [SECTION_ID_PACKET] =             { SECTION_ID_PACKET, "packet", 0, { -1 } },
177
+    [SECTION_ID_PACKET] =             { SECTION_ID_PACKET, "packet", 0, { SECTION_ID_PACKET_SIDE_DATA_LIST, -1 } },
178
+    [SECTION_ID_PACKET_SIDE_DATA_LIST] ={ SECTION_ID_PACKET_SIDE_DATA_LIST, "side_data_list", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET_SIDE_DATA, -1 } },
179
+    [SECTION_ID_PACKET_SIDE_DATA] =     { SECTION_ID_PACKET_SIDE_DATA, "side_data", 0, { -1 } },
178 180
     [SECTION_ID_PIXEL_FORMATS] =      { SECTION_ID_PIXEL_FORMATS, "pixel_formats", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PIXEL_FORMAT, -1 } },
179 181
     [SECTION_ID_PIXEL_FORMAT] =       { SECTION_ID_PIXEL_FORMAT, "pixel_format", 0, { SECTION_ID_PIXEL_FORMAT_FLAGS, SECTION_ID_PIXEL_FORMAT_COMPONENTS, -1 } },
180 182
     [SECTION_ID_PIXEL_FORMAT_FLAGS] = { SECTION_ID_PIXEL_FORMAT_FLAGS, "flags", 0, { -1 }, .unique_name = "pixel_format_flags" },
... ...
@@ -193,9 +199,11 @@ static struct section sections[] = {
193 193
                                           SECTION_ID_PACKETS, SECTION_ID_ERROR, SECTION_ID_PROGRAM_VERSION, SECTION_ID_LIBRARY_VERSIONS,
194 194
                                           SECTION_ID_PIXEL_FORMATS, -1} },
195 195
     [SECTION_ID_STREAMS] =            { SECTION_ID_STREAMS, "streams", SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM, -1 } },
196
-    [SECTION_ID_STREAM] =             { SECTION_ID_STREAM, "stream", 0, { SECTION_ID_STREAM_DISPOSITION, SECTION_ID_STREAM_TAGS, -1 } },
196
+    [SECTION_ID_STREAM] =             { SECTION_ID_STREAM, "stream", 0, { SECTION_ID_STREAM_DISPOSITION, SECTION_ID_STREAM_TAGS, SECTION_ID_STREAM_SIDE_DATA_LIST, -1 } },
197 197
     [SECTION_ID_STREAM_DISPOSITION] = { SECTION_ID_STREAM_DISPOSITION, "disposition", 0, { -1 }, .unique_name = "stream_disposition" },
198 198
     [SECTION_ID_STREAM_TAGS] =        { SECTION_ID_STREAM_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "stream_tags" },
199
+    [SECTION_ID_STREAM_SIDE_DATA_LIST] ={ SECTION_ID_STREAM_SIDE_DATA_LIST, "side_data_list", SECTION_FLAG_IS_ARRAY, { SECTION_ID_STREAM_SIDE_DATA, -1 } },
200
+    [SECTION_ID_STREAM_SIDE_DATA] =     { SECTION_ID_STREAM_SIDE_DATA, "side_data", 0, { -1 } },
199 201
     [SECTION_ID_SUBTITLE] =           { SECTION_ID_SUBTITLE, "subtitle", 0, { -1 } },
200 202
 };
201 203
 
... ...
@@ -1751,6 +1759,25 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk
1751 1751
     if (pkt->pos != -1) print_fmt    ("pos", "%"PRId64, pkt->pos);
1752 1752
     else                print_str_opt("pos", "N/A");
1753 1753
     print_fmt("flags", "%c",      pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_');
1754
+
1755
+    if (pkt->side_data_elems) {
1756
+        int i;
1757
+        writer_print_section_header(w, SECTION_ID_PACKET_SIDE_DATA_LIST);
1758
+        for (i = 0; i < pkt->side_data_elems; i++) {
1759
+            AVPacketSideData *sd = &pkt->side_data[i];
1760
+            const char *name;
1761
+            writer_print_section_header(w, SECTION_ID_PACKET_SIDE_DATA);
1762
+            print_str("side_data_type", "unknown");
1763
+            print_int("side_data_size", sd->size);
1764
+            if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
1765
+                writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
1766
+                print_int("rotation", av_display_rotation_get((int32_t *)sd->data));
1767
+            }
1768
+            writer_print_section_footer(w);
1769
+        }
1770
+        writer_print_section_footer(w);
1771
+    }
1772
+
1754 1773
     if (do_show_data)
1755 1774
         writer_print_data(w, "data", pkt->data, pkt->size);
1756 1775
     writer_print_data_hash(w, "data_hash", pkt->data, pkt->size);
... ...
@@ -2274,6 +2301,24 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
2274 2274
     if (do_show_stream_tags)
2275 2275
         ret = show_tags(w, stream->metadata, in_program ? SECTION_ID_PROGRAM_STREAM_TAGS : SECTION_ID_STREAM_TAGS);
2276 2276
 
2277
+    if (stream->nb_side_data) {
2278
+        int i;
2279
+        writer_print_section_header(w, SECTION_ID_STREAM_SIDE_DATA_LIST);
2280
+        for (i = 0; i < stream->nb_side_data; i++) {
2281
+            AVPacketSideData *sd = &stream->side_data[i];
2282
+            const char *name;
2283
+            writer_print_section_header(w, SECTION_ID_STREAM_SIDE_DATA);
2284
+            print_str("side_data_type", "unknown");
2285
+            print_int("side_data_size", sd->size);
2286
+            if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
2287
+                writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
2288
+                print_int("rotation", av_display_rotation_get((int32_t *)sd->data));
2289
+            }
2290
+            writer_print_section_footer(w);
2291
+        }
2292
+        writer_print_section_footer(w);
2293
+    }
2294
+
2277 2295
     writer_print_section_footer(w);
2278 2296
     av_bprint_finalize(&pbuf, NULL);
2279 2297
     fflush(stdout);