Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  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_sidedata(void *ctx, AVStream *st, const char *indent)
  340. {
  341.     int i;
  342.  
  343.     if (st->nb_side_data)
  344.         av_log(ctx, AV_LOG_INFO, "%sSide data:\n", indent);
  345.  
  346.     for (i = 0; i < st->nb_side_data; i++) {
  347.         AVPacketSideData sd = st->side_data[i];
  348.         av_log(ctx, AV_LOG_INFO, "%s  ", indent);
  349.  
  350.         switch (sd.type) {
  351.         case AV_PKT_DATA_PALETTE:
  352.             av_log(ctx, AV_LOG_INFO, "palette");
  353.             break;
  354.         case AV_PKT_DATA_NEW_EXTRADATA:
  355.             av_log(ctx, AV_LOG_INFO, "new extradata");
  356.             break;
  357.         case AV_PKT_DATA_PARAM_CHANGE:
  358.             av_log(ctx, AV_LOG_INFO, "paramchange: ");
  359.             dump_paramchange(ctx, &sd);
  360.             break;
  361.         case AV_PKT_DATA_H263_MB_INFO:
  362.             av_log(ctx, AV_LOG_INFO, "h263 macroblock info");
  363.             break;
  364.         case AV_PKT_DATA_REPLAYGAIN:
  365.             av_log(ctx, AV_LOG_INFO, "replaygain: ");
  366.             dump_replaygain(ctx, &sd);
  367.             break;
  368.         case AV_PKT_DATA_DISPLAYMATRIX:
  369.             av_log(ctx, AV_LOG_INFO, "displaymatrix: rotation of %.2f degrees",
  370.                    av_display_rotation_get((int32_t *)sd.data));
  371.             break;
  372.         case AV_PKT_DATA_STEREO3D:
  373.             av_log(ctx, AV_LOG_INFO, "stereo3d: ");
  374.             dump_stereo3d(ctx, &sd);
  375.             break;
  376.         case AV_PKT_DATA_AUDIO_SERVICE_TYPE:
  377.             av_log(ctx, AV_LOG_INFO, "audio service type: ");
  378.             dump_audioservicetype(ctx, &sd);
  379.             break;
  380.         case AV_PKT_DATA_QUALITY_STATS:
  381.             av_log(ctx, AV_LOG_INFO, "quality factor: %d, pict_type: %c", AV_RL32(sd.data), av_get_picture_type_char(sd.data[4]));
  382.             break;
  383.         default:
  384.             av_log(ctx, AV_LOG_WARNING,
  385.                    "unknown side data type %d (%d bytes)", sd.type, sd.size);
  386.             break;
  387.         }
  388.  
  389.         av_log(ctx, AV_LOG_INFO, "\n");
  390.     }
  391. }
  392.  
  393. /* "user interface" functions */
  394. static void dump_stream_format(AVFormatContext *ic, int i,
  395.                                int index, int is_output)
  396. {
  397.     char buf[256];
  398.     int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
  399.     AVStream *st = ic->streams[i];
  400.     AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
  401.     char *separator = ic->dump_separator;
  402.     char **codec_separator = av_opt_ptr(st->codec->av_class, st->codec, "dump_separator");
  403.     int use_format_separator = !*codec_separator;
  404.  
  405.     if (use_format_separator)
  406.         *codec_separator = av_strdup(separator);
  407.     avcodec_string(buf, sizeof(buf), st->codec, is_output);
  408.     if (use_format_separator)
  409.         av_freep(codec_separator);
  410.     av_log(NULL, AV_LOG_INFO, "    Stream #%d:%d", index, i);
  411.  
  412.     /* the pid is an important information, so we display it */
  413.     /* XXX: add a generic system */
  414.     if (flags & AVFMT_SHOW_IDS)
  415.         av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id);
  416.     if (lang)
  417.         av_log(NULL, AV_LOG_INFO, "(%s)", lang->value);
  418.     av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->codec_info_nb_frames,
  419.            st->time_base.num, st->time_base.den);
  420.     av_log(NULL, AV_LOG_INFO, ": %s", buf);
  421.  
  422.     if (st->sample_aspect_ratio.num && // default
  423.         av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) {
  424.         AVRational display_aspect_ratio;
  425.         av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
  426.                   st->codec->width  * (int64_t)st->sample_aspect_ratio.num,
  427.                   st->codec->height * (int64_t)st->sample_aspect_ratio.den,
  428.                   1024 * 1024);
  429.         av_log(NULL, AV_LOG_INFO, ", SAR %d:%d DAR %d:%d",
  430.                st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
  431.                display_aspect_ratio.num, display_aspect_ratio.den);
  432.     }
  433.  
  434.     if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
  435.         int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
  436.         int tbr = st->r_frame_rate.den && st->r_frame_rate.num;
  437.         int tbn = st->time_base.den && st->time_base.num;
  438.         int tbc = st->codec->time_base.den && st->codec->time_base.num;
  439.  
  440.         if (fps || tbr || tbn || tbc)
  441.             av_log(NULL, AV_LOG_INFO, "%s", separator);
  442.  
  443.         if (fps)
  444.             print_fps(av_q2d(st->avg_frame_rate), tbr || tbn || tbc ? "fps, " : "fps");
  445.         if (tbr)
  446.             print_fps(av_q2d(st->r_frame_rate), tbn || tbc ? "tbr, " : "tbr");
  447.         if (tbn)
  448.             print_fps(1 / av_q2d(st->time_base), tbc ? "tbn, " : "tbn");
  449.         if (tbc)
  450.             print_fps(1 / av_q2d(st->codec->time_base), "tbc");
  451.     }
  452.  
  453.     if (st->disposition & AV_DISPOSITION_DEFAULT)
  454.         av_log(NULL, AV_LOG_INFO, " (default)");
  455.     if (st->disposition & AV_DISPOSITION_DUB)
  456.         av_log(NULL, AV_LOG_INFO, " (dub)");
  457.     if (st->disposition & AV_DISPOSITION_ORIGINAL)
  458.         av_log(NULL, AV_LOG_INFO, " (original)");
  459.     if (st->disposition & AV_DISPOSITION_COMMENT)
  460.         av_log(NULL, AV_LOG_INFO, " (comment)");
  461.     if (st->disposition & AV_DISPOSITION_LYRICS)
  462.         av_log(NULL, AV_LOG_INFO, " (lyrics)");
  463.     if (st->disposition & AV_DISPOSITION_KARAOKE)
  464.         av_log(NULL, AV_LOG_INFO, " (karaoke)");
  465.     if (st->disposition & AV_DISPOSITION_FORCED)
  466.         av_log(NULL, AV_LOG_INFO, " (forced)");
  467.     if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
  468.         av_log(NULL, AV_LOG_INFO, " (hearing impaired)");
  469.     if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
  470.         av_log(NULL, AV_LOG_INFO, " (visual impaired)");
  471.     if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS)
  472.         av_log(NULL, AV_LOG_INFO, " (clean effects)");
  473.     av_log(NULL, AV_LOG_INFO, "\n");
  474.  
  475.     dump_metadata(NULL, st->metadata, "    ");
  476.  
  477.     dump_sidedata(NULL, st, "    ");
  478. }
  479.  
  480. void av_dump_format(AVFormatContext *ic, int index,
  481.                     const char *url, int is_output)
  482. {
  483.     int i;
  484.     uint8_t *printed = ic->nb_streams ? av_mallocz(ic->nb_streams) : NULL;
  485.     if (ic->nb_streams && !printed)
  486.         return;
  487.  
  488.     av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n",
  489.            is_output ? "Output" : "Input",
  490.            index,
  491.            is_output ? ic->oformat->name : ic->iformat->name,
  492.            is_output ? "to" : "from", url);
  493.     dump_metadata(NULL, ic->metadata, "  ");
  494.  
  495.     if (!is_output) {
  496.         av_log(NULL, AV_LOG_INFO, "  Duration: ");
  497.         if (ic->duration != AV_NOPTS_VALUE) {
  498.             int hours, mins, secs, us;
  499.             int64_t duration = ic->duration + (ic->duration <= INT64_MAX - 5000 ? 5000 : 0);
  500.             secs  = duration / AV_TIME_BASE;
  501.             us    = duration % AV_TIME_BASE;
  502.             mins  = secs / 60;
  503.             secs %= 60;
  504.             hours = mins / 60;
  505.             mins %= 60;
  506.             av_log(NULL, AV_LOG_INFO, "%02d:%02d:%02d.%02d", hours, mins, secs,
  507.                    (100 * us) / AV_TIME_BASE);
  508.         } else {
  509.             av_log(NULL, AV_LOG_INFO, "N/A");
  510.         }
  511.         if (ic->start_time != AV_NOPTS_VALUE) {
  512.             int secs, us;
  513.             av_log(NULL, AV_LOG_INFO, ", start: ");
  514.             secs = ic->start_time / AV_TIME_BASE;
  515.             us   = llabs(ic->start_time % AV_TIME_BASE);
  516.             av_log(NULL, AV_LOG_INFO, "%d.%06d",
  517.                    secs, (int) av_rescale(us, 1000000, AV_TIME_BASE));
  518.         }
  519.         av_log(NULL, AV_LOG_INFO, ", bitrate: ");
  520.         if (ic->bit_rate)
  521.             av_log(NULL, AV_LOG_INFO, "%d kb/s", ic->bit_rate / 1000);
  522.         else
  523.             av_log(NULL, AV_LOG_INFO, "N/A");
  524.         av_log(NULL, AV_LOG_INFO, "\n");
  525.     }
  526.  
  527.     for (i = 0; i < ic->nb_chapters; i++) {
  528.         AVChapter *ch = ic->chapters[i];
  529.         av_log(NULL, AV_LOG_INFO, "    Chapter #%d:%d: ", index, i);
  530.         av_log(NULL, AV_LOG_INFO,
  531.                "start %f, ", ch->start * av_q2d(ch->time_base));
  532.         av_log(NULL, AV_LOG_INFO,
  533.                "end %f\n", ch->end * av_q2d(ch->time_base));
  534.  
  535.         dump_metadata(NULL, ch->metadata, "    ");
  536.     }
  537.  
  538.     if (ic->nb_programs) {
  539.         int j, k, total = 0;
  540.         for (j = 0; j < ic->nb_programs; j++) {
  541.             AVDictionaryEntry *name = av_dict_get(ic->programs[j]->metadata,
  542.                                                   "name", NULL, 0);
  543.             av_log(NULL, AV_LOG_INFO, "  Program %d %s\n", ic->programs[j]->id,
  544.                    name ? name->value : "");
  545.             dump_metadata(NULL, ic->programs[j]->metadata, "    ");
  546.             for (k = 0; k < ic->programs[j]->nb_stream_indexes; k++) {
  547.                 dump_stream_format(ic, ic->programs[j]->stream_index[k],
  548.                                    index, is_output);
  549.                 printed[ic->programs[j]->stream_index[k]] = 1;
  550.             }
  551.             total += ic->programs[j]->nb_stream_indexes;
  552.         }
  553.         if (total < ic->nb_streams)
  554.             av_log(NULL, AV_LOG_INFO, "  No Program\n");
  555.     }
  556.  
  557.     for (i = 0; i < ic->nb_streams; i++)
  558.         if (!printed[i])
  559.             dump_stream_format(ic, i, index, is_output);
  560.  
  561.     av_free(printed);
  562. }
  563.