]> git.sesse.net Git - ffmpeg/blob - libavformat/dump.c
Merge commit 'e579d8b29cdb9b42c50a0fde277dfb047c1466ad'
[ffmpeg] / libavformat / dump.c
1 /*
2  * Various pretty-printing functions for use within FFmpeg
3  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 #include <stdio.h>
23 #include <stdint.h>
24
25 #include "libavutil/channel_layout.h"
26 #include "libavutil/display.h"
27 #include "libavutil/intreadwrite.h"
28 #include "libavutil/log.h"
29 #include "libavutil/mathematics.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/avstring.h"
32 #include "libavutil/replaygain.h"
33 #include "libavutil/stereo3d.h"
34
35 #include "avformat.h"
36
37 #define HEXDUMP_PRINT(...)                                                    \
38     do {                                                                      \
39         if (!f)                                                               \
40             av_log(avcl, level, __VA_ARGS__);                                 \
41         else                                                                  \
42             fprintf(f, __VA_ARGS__);                                          \
43     } while (0)
44
45 static void hex_dump_internal(void *avcl, FILE *f, int level,
46                               const uint8_t *buf, int size)
47 {
48     int len, i, j, c;
49
50     for (i = 0; i < size; i += 16) {
51         len = size - i;
52         if (len > 16)
53             len = 16;
54         HEXDUMP_PRINT("%08x ", i);
55         for (j = 0; j < 16; j++) {
56             if (j < len)
57                 HEXDUMP_PRINT(" %02x", buf[i + j]);
58             else
59                 HEXDUMP_PRINT("   ");
60         }
61         HEXDUMP_PRINT(" ");
62         for (j = 0; j < len; j++) {
63             c = buf[i + j];
64             if (c < ' ' || c > '~')
65                 c = '.';
66             HEXDUMP_PRINT("%c", c);
67         }
68         HEXDUMP_PRINT("\n");
69     }
70 }
71
72 void av_hex_dump(FILE *f, const uint8_t *buf, int size)
73 {
74     hex_dump_internal(NULL, f, 0, buf, size);
75 }
76
77 void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
78 {
79     hex_dump_internal(avcl, NULL, level, buf, size);
80 }
81
82 static void pkt_dump_internal(void *avcl, FILE *f, int level, const AVPacket *pkt,
83                               int dump_payload, AVRational time_base)
84 {
85     HEXDUMP_PRINT("stream #%d:\n", pkt->stream_index);
86     HEXDUMP_PRINT("  keyframe=%d\n", (pkt->flags & AV_PKT_FLAG_KEY) != 0);
87     HEXDUMP_PRINT("  duration=%0.3f\n", pkt->duration * av_q2d(time_base));
88     /* DTS is _always_ valid after av_read_frame() */
89     HEXDUMP_PRINT("  dts=");
90     if (pkt->dts == AV_NOPTS_VALUE)
91         HEXDUMP_PRINT("N/A");
92     else
93         HEXDUMP_PRINT("%0.3f", pkt->dts * av_q2d(time_base));
94     /* PTS may not be known if B-frames are present. */
95     HEXDUMP_PRINT("  pts=");
96     if (pkt->pts == AV_NOPTS_VALUE)
97         HEXDUMP_PRINT("N/A");
98     else
99         HEXDUMP_PRINT("%0.3f", pkt->pts * av_q2d(time_base));
100     HEXDUMP_PRINT("\n");
101     HEXDUMP_PRINT("  size=%d\n", pkt->size);
102     if (dump_payload)
103         av_hex_dump(f, pkt->data, pkt->size);
104 }
105
106 void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st)
107 {
108     pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base);
109 }
110
111 void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload,
112                       const AVStream *st)
113 {
114     pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base);
115 }
116
117
118 static void print_fps(double d, const char *postfix)
119 {
120     uint64_t v = lrintf(d * 100);
121     if (!v)
122         av_log(NULL, AV_LOG_INFO, "%1.4f %s", d, postfix);
123     else if (v % 100)
124         av_log(NULL, AV_LOG_INFO, "%3.2f %s", d, postfix);
125     else if (v % (100 * 1000))
126         av_log(NULL, AV_LOG_INFO, "%1.0f %s", d, postfix);
127     else
128         av_log(NULL, AV_LOG_INFO, "%1.0fk %s", d / 1000, postfix);
129 }
130
131 static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
132 {
133     if (m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0))) {
134         AVDictionaryEntry *tag = NULL;
135
136         av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
137         while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX)))
138             if (strcmp("language", tag->key)) {
139                 const char *p = tag->value;
140                 av_log(ctx, AV_LOG_INFO,
141                        "%s  %-16s: ", indent, tag->key);
142                 while (*p) {
143                     char tmp[256];
144                     size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
145                     av_strlcpy(tmp, p, FFMIN(sizeof(tmp), len+1));
146                     av_log(ctx, AV_LOG_INFO, "%s", tmp);
147                     p += len;
148                     if (*p == 0xd) av_log(ctx, AV_LOG_INFO, " ");
149                     if (*p == 0xa) av_log(ctx, AV_LOG_INFO, "\n%s  %-16s: ", indent, "");
150                     if (*p) p++;
151                 }
152                 av_log(ctx, AV_LOG_INFO, "\n");
153             }
154     }
155 }
156
157 /* param change side data*/
158 static void dump_paramchange(void *ctx, AVPacketSideData *sd)
159 {
160     int size = sd->size;
161     const uint8_t *data = sd->data;
162     uint32_t flags, channels, sample_rate, width, height;
163     uint64_t layout;
164
165     if (!data || sd->size < 4)
166         goto fail;
167
168     flags = AV_RL32(data);
169     data += 4;
170     size -= 4;
171
172     if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) {
173         if (size < 4)
174             goto fail;
175         channels = AV_RL32(data);
176         data += 4;
177         size -= 4;
178         av_log(ctx, AV_LOG_INFO, "channel count %"PRIu32", ", channels);
179     }
180     if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) {
181         if (size < 8)
182             goto fail;
183         layout = AV_RL64(data);
184         data += 8;
185         size -= 8;
186         av_log(ctx, AV_LOG_INFO,
187                "channel layout: %s, ", av_get_channel_name(layout));
188     }
189     if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
190         if (size < 4)
191             goto fail;
192         sample_rate = AV_RL32(data);
193         data += 4;
194         size -= 4;
195         av_log(ctx, AV_LOG_INFO, "sample_rate %"PRIu32", ", sample_rate);
196     }
197     if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) {
198         if (size < 8)
199             goto fail;
200         width = AV_RL32(data);
201         data += 4;
202         size -= 4;
203         height = AV_RL32(data);
204         data += 4;
205         size -= 4;
206         av_log(ctx, AV_LOG_INFO, "width %"PRIu32" height %"PRIu32, width, height);
207     }
208
209     return;
210 fail:
211     av_log(ctx, AV_LOG_INFO, "unknown param");
212 }
213
214 /* replaygain side data*/
215 static void print_gain(void *ctx, const char *str, int32_t gain)
216 {
217     av_log(ctx, AV_LOG_INFO, "%s - ", str);
218     if (gain == INT32_MIN)
219         av_log(ctx, AV_LOG_INFO, "unknown");
220     else
221         av_log(ctx, AV_LOG_INFO, "%f", gain / 100000.0f);
222     av_log(ctx, AV_LOG_INFO, ", ");
223 }
224
225 static void print_peak(void *ctx, const char *str, uint32_t peak)
226 {
227     av_log(ctx, AV_LOG_INFO, "%s - ", str);
228     if (!peak)
229         av_log(ctx, AV_LOG_INFO, "unknown");
230     else
231         av_log(ctx, AV_LOG_INFO, "%f", (float) peak / UINT32_MAX);
232     av_log(ctx, AV_LOG_INFO, ", ");
233 }
234
235 static void dump_replaygain(void *ctx, AVPacketSideData *sd)
236 {
237     AVReplayGain *rg;
238
239     if (sd->size < sizeof(*rg)) {
240         av_log(ctx, AV_LOG_INFO, "invalid data");
241         return;
242     }
243     rg = (AVReplayGain*)sd->data;
244
245     print_gain(ctx, "track gain", rg->track_gain);
246     print_peak(ctx, "track peak", rg->track_peak);
247     print_gain(ctx, "album gain", rg->album_gain);
248     print_peak(ctx, "album peak", rg->album_peak);
249 }
250
251 static void dump_stereo3d(void *ctx, AVPacketSideData *sd)
252 {
253     AVStereo3D *stereo;
254
255     if (sd->size < sizeof(*stereo)) {
256         av_log(ctx, AV_LOG_INFO, "invalid data");
257         return;
258     }
259
260     stereo = (AVStereo3D *)sd->data;
261
262     switch (stereo->type) {
263     case AV_STEREO3D_2D:
264         av_log(ctx, AV_LOG_INFO, "2D");
265         break;
266     case AV_STEREO3D_SIDEBYSIDE:
267         av_log(ctx, AV_LOG_INFO, "side by side");
268         break;
269     case AV_STEREO3D_TOPBOTTOM:
270         av_log(ctx, AV_LOG_INFO, "top and bottom");
271         break;
272     case AV_STEREO3D_FRAMESEQUENCE:
273         av_log(ctx, AV_LOG_INFO, "frame alternate");
274         break;
275     case AV_STEREO3D_CHECKERBOARD:
276         av_log(ctx, AV_LOG_INFO, "checkerboard");
277         break;
278     case AV_STEREO3D_LINES:
279         av_log(ctx, AV_LOG_INFO, "interleaved lines");
280         break;
281     case AV_STEREO3D_COLUMNS:
282         av_log(ctx, AV_LOG_INFO, "interleaved columns");
283         break;
284     case AV_STEREO3D_SIDEBYSIDE_QUINCUNX:
285         av_log(ctx, AV_LOG_INFO, "side by side (quincunx subsampling)");
286         break;
287     default:
288         av_log(ctx, AV_LOG_WARNING, "unknown");
289         break;
290     }
291
292     if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
293         av_log(ctx, AV_LOG_INFO, " (inverted)");
294 }
295
296 static void dump_audioservicetype(void *ctx, AVPacketSideData *sd)
297 {
298     enum AVAudioServiceType *ast = (enum AVAudioServiceType *)sd->data;
299
300     if (sd->size < sizeof(*ast)) {
301         av_log(ctx, AV_LOG_INFO, "invalid data");
302         return;
303     }
304
305     switch (*ast) {
306     case AV_AUDIO_SERVICE_TYPE_MAIN:
307         av_log(ctx, AV_LOG_INFO, "main");
308         break;
309     case AV_AUDIO_SERVICE_TYPE_EFFECTS:
310         av_log(ctx, AV_LOG_INFO, "effects");
311         break;
312     case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED:
313         av_log(ctx, AV_LOG_INFO, "visually impaired");
314         break;
315     case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED:
316         av_log(ctx, AV_LOG_INFO, "hearing impaired");
317         break;
318     case AV_AUDIO_SERVICE_TYPE_DIALOGUE:
319         av_log(ctx, AV_LOG_INFO, "dialogue");
320         break;
321     case AV_AUDIO_SERVICE_TYPE_COMMENTARY:
322         av_log(ctx, AV_LOG_INFO, "comentary");
323         break;
324     case AV_AUDIO_SERVICE_TYPE_EMERGENCY:
325         av_log(ctx, AV_LOG_INFO, "emergency");
326         break;
327     case AV_AUDIO_SERVICE_TYPE_VOICE_OVER:
328         av_log(ctx, AV_LOG_INFO, "voice over");
329         break;
330     case AV_AUDIO_SERVICE_TYPE_KARAOKE:
331         av_log(ctx, AV_LOG_INFO, "karaoke");
332         break;
333     default:
334         av_log(ctx, AV_LOG_WARNING, "unknown");
335         break;
336     }
337 }
338
339 static void dump_cpb(void *ctx, AVPacketSideData *sd)
340 {
341     AVCPBProperties *cpb = (AVCPBProperties *)sd->data;
342
343     if (sd->size < sizeof(*cpb)) {
344         av_log(ctx, AV_LOG_INFO, "invalid data");
345         return;
346     }
347
348     av_log(ctx, AV_LOG_INFO,
349            "bitrate max/min/avg: %d/%d/%d buffer size: %d vbv_delay: %"PRId64,
350            cpb->max_bitrate, cpb->min_bitrate, cpb->avg_bitrate,
351            cpb->buffer_size,
352            cpb->vbv_delay);
353 }
354
355 static void dump_sidedata(void *ctx, AVStream *st, const char *indent)
356 {
357     int i;
358
359     if (st->nb_side_data)
360         av_log(ctx, AV_LOG_INFO, "%sSide data:\n", indent);
361
362     for (i = 0; i < st->nb_side_data; i++) {
363         AVPacketSideData sd = st->side_data[i];
364         av_log(ctx, AV_LOG_INFO, "%s  ", indent);
365
366         switch (sd.type) {
367         case AV_PKT_DATA_PALETTE:
368             av_log(ctx, AV_LOG_INFO, "palette");
369             break;
370         case AV_PKT_DATA_NEW_EXTRADATA:
371             av_log(ctx, AV_LOG_INFO, "new extradata");
372             break;
373         case AV_PKT_DATA_PARAM_CHANGE:
374             av_log(ctx, AV_LOG_INFO, "paramchange: ");
375             dump_paramchange(ctx, &sd);
376             break;
377         case AV_PKT_DATA_H263_MB_INFO:
378             av_log(ctx, AV_LOG_INFO, "h263 macroblock info");
379             break;
380         case AV_PKT_DATA_REPLAYGAIN:
381             av_log(ctx, AV_LOG_INFO, "replaygain: ");
382             dump_replaygain(ctx, &sd);
383             break;
384         case AV_PKT_DATA_DISPLAYMATRIX:
385             av_log(ctx, AV_LOG_INFO, "displaymatrix: rotation of %.2f degrees",
386                    av_display_rotation_get((int32_t *)sd.data));
387             break;
388         case AV_PKT_DATA_STEREO3D:
389             av_log(ctx, AV_LOG_INFO, "stereo3d: ");
390             dump_stereo3d(ctx, &sd);
391             break;
392         case AV_PKT_DATA_AUDIO_SERVICE_TYPE:
393             av_log(ctx, AV_LOG_INFO, "audio service type: ");
394             dump_audioservicetype(ctx, &sd);
395             break;
396         case AV_PKT_DATA_QUALITY_STATS:
397             av_log(ctx, AV_LOG_INFO, "quality factor: %d, pict_type: %c", AV_RL32(sd.data), av_get_picture_type_char(sd.data[4]));
398             break;
399         case AV_PKT_DATA_CPB_PROPERTIES:
400             av_log(ctx, AV_LOG_INFO, "cpb: ");
401             dump_cpb(ctx, &sd);
402             break;
403         default:
404             av_log(ctx, AV_LOG_WARNING,
405                    "unknown side data type %d (%d bytes)", sd.type, sd.size);
406             break;
407         }
408
409         av_log(ctx, AV_LOG_INFO, "\n");
410     }
411 }
412
413 /* "user interface" functions */
414 static void dump_stream_format(AVFormatContext *ic, int i,
415                                int index, int is_output)
416 {
417     char buf[256];
418     int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
419     AVStream *st = ic->streams[i];
420     AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
421     char *separator = ic->dump_separator;
422     char **codec_separator = av_opt_ptr(st->codec->av_class, st->codec, "dump_separator");
423     int use_format_separator = !*codec_separator;
424
425     if (use_format_separator)
426         *codec_separator = av_strdup(separator);
427     avcodec_string(buf, sizeof(buf), st->codec, is_output);
428     if (use_format_separator)
429         av_freep(codec_separator);
430     av_log(NULL, AV_LOG_INFO, "    Stream #%d:%d", index, i);
431
432     /* the pid is an important information, so we display it */
433     /* XXX: add a generic system */
434     if (flags & AVFMT_SHOW_IDS)
435         av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id);
436     if (lang)
437         av_log(NULL, AV_LOG_INFO, "(%s)", lang->value);
438     av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->codec_info_nb_frames,
439            st->time_base.num, st->time_base.den);
440     av_log(NULL, AV_LOG_INFO, ": %s", buf);
441
442     if (st->sample_aspect_ratio.num && // default
443         av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) {
444         AVRational display_aspect_ratio;
445         av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
446                   st->codec->width  * (int64_t)st->sample_aspect_ratio.num,
447                   st->codec->height * (int64_t)st->sample_aspect_ratio.den,
448                   1024 * 1024);
449         av_log(NULL, AV_LOG_INFO, ", SAR %d:%d DAR %d:%d",
450                st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
451                display_aspect_ratio.num, display_aspect_ratio.den);
452     }
453
454     if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
455         int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
456         int tbr = st->r_frame_rate.den && st->r_frame_rate.num;
457         int tbn = st->time_base.den && st->time_base.num;
458         int tbc = st->codec->time_base.den && st->codec->time_base.num;
459
460         if (fps || tbr || tbn || tbc)
461             av_log(NULL, AV_LOG_INFO, "%s", separator);
462
463         if (fps)
464             print_fps(av_q2d(st->avg_frame_rate), tbr || tbn || tbc ? "fps, " : "fps");
465         if (tbr)
466             print_fps(av_q2d(st->r_frame_rate), tbn || tbc ? "tbr, " : "tbr");
467         if (tbn)
468             print_fps(1 / av_q2d(st->time_base), tbc ? "tbn, " : "tbn");
469         if (tbc)
470             print_fps(1 / av_q2d(st->codec->time_base), "tbc");
471     }
472
473     if (st->disposition & AV_DISPOSITION_DEFAULT)
474         av_log(NULL, AV_LOG_INFO, " (default)");
475     if (st->disposition & AV_DISPOSITION_DUB)
476         av_log(NULL, AV_LOG_INFO, " (dub)");
477     if (st->disposition & AV_DISPOSITION_ORIGINAL)
478         av_log(NULL, AV_LOG_INFO, " (original)");
479     if (st->disposition & AV_DISPOSITION_COMMENT)
480         av_log(NULL, AV_LOG_INFO, " (comment)");
481     if (st->disposition & AV_DISPOSITION_LYRICS)
482         av_log(NULL, AV_LOG_INFO, " (lyrics)");
483     if (st->disposition & AV_DISPOSITION_KARAOKE)
484         av_log(NULL, AV_LOG_INFO, " (karaoke)");
485     if (st->disposition & AV_DISPOSITION_FORCED)
486         av_log(NULL, AV_LOG_INFO, " (forced)");
487     if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
488         av_log(NULL, AV_LOG_INFO, " (hearing impaired)");
489     if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
490         av_log(NULL, AV_LOG_INFO, " (visual impaired)");
491     if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS)
492         av_log(NULL, AV_LOG_INFO, " (clean effects)");
493     av_log(NULL, AV_LOG_INFO, "\n");
494
495     dump_metadata(NULL, st->metadata, "    ");
496
497     dump_sidedata(NULL, st, "    ");
498 }
499
500 void av_dump_format(AVFormatContext *ic, int index,
501                     const char *url, int is_output)
502 {
503     int i;
504     uint8_t *printed = ic->nb_streams ? av_mallocz(ic->nb_streams) : NULL;
505     if (ic->nb_streams && !printed)
506         return;
507
508     av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n",
509            is_output ? "Output" : "Input",
510            index,
511            is_output ? ic->oformat->name : ic->iformat->name,
512            is_output ? "to" : "from", url);
513     dump_metadata(NULL, ic->metadata, "  ");
514
515     if (!is_output) {
516         av_log(NULL, AV_LOG_INFO, "  Duration: ");
517         if (ic->duration != AV_NOPTS_VALUE) {
518             int hours, mins, secs, us;
519             int64_t duration = ic->duration + (ic->duration <= INT64_MAX - 5000 ? 5000 : 0);
520             secs  = duration / AV_TIME_BASE;
521             us    = duration % AV_TIME_BASE;
522             mins  = secs / 60;
523             secs %= 60;
524             hours = mins / 60;
525             mins %= 60;
526             av_log(NULL, AV_LOG_INFO, "%02d:%02d:%02d.%02d", hours, mins, secs,
527                    (100 * us) / AV_TIME_BASE);
528         } else {
529             av_log(NULL, AV_LOG_INFO, "N/A");
530         }
531         if (ic->start_time != AV_NOPTS_VALUE) {
532             int secs, us;
533             av_log(NULL, AV_LOG_INFO, ", start: ");
534             secs = ic->start_time / AV_TIME_BASE;
535             us   = llabs(ic->start_time % AV_TIME_BASE);
536             av_log(NULL, AV_LOG_INFO, "%d.%06d",
537                    secs, (int) av_rescale(us, 1000000, AV_TIME_BASE));
538         }
539         av_log(NULL, AV_LOG_INFO, ", bitrate: ");
540         if (ic->bit_rate)
541             av_log(NULL, AV_LOG_INFO, "%"PRId64" kb/s", (int64_t)ic->bit_rate / 1000);
542         else
543             av_log(NULL, AV_LOG_INFO, "N/A");
544         av_log(NULL, AV_LOG_INFO, "\n");
545     }
546
547     for (i = 0; i < ic->nb_chapters; i++) {
548         AVChapter *ch = ic->chapters[i];
549         av_log(NULL, AV_LOG_INFO, "    Chapter #%d:%d: ", index, i);
550         av_log(NULL, AV_LOG_INFO,
551                "start %f, ", ch->start * av_q2d(ch->time_base));
552         av_log(NULL, AV_LOG_INFO,
553                "end %f\n", ch->end * av_q2d(ch->time_base));
554
555         dump_metadata(NULL, ch->metadata, "    ");
556     }
557
558     if (ic->nb_programs) {
559         int j, k, total = 0;
560         for (j = 0; j < ic->nb_programs; j++) {
561             AVDictionaryEntry *name = av_dict_get(ic->programs[j]->metadata,
562                                                   "name", NULL, 0);
563             av_log(NULL, AV_LOG_INFO, "  Program %d %s\n", ic->programs[j]->id,
564                    name ? name->value : "");
565             dump_metadata(NULL, ic->programs[j]->metadata, "    ");
566             for (k = 0; k < ic->programs[j]->nb_stream_indexes; k++) {
567                 dump_stream_format(ic, ic->programs[j]->stream_index[k],
568                                    index, is_output);
569                 printed[ic->programs[j]->stream_index[k]] = 1;
570             }
571             total += ic->programs[j]->nb_stream_indexes;
572         }
573         if (total < ic->nb_streams)
574             av_log(NULL, AV_LOG_INFO, "  No Program\n");
575     }
576
577     for (i = 0; i < ic->nb_streams; i++)
578         if (!printed[i])
579             dump_stream_format(ic, i, index, is_output);
580
581     av_free(printed);
582 }