Merge commit '41e86146e7240f9d42e8cdb86a94bb3eb2bbe15f'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 8 Oct 2014 23:03:55 +0000 (01:03 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 8 Oct 2014 23:26:34 +0000 (01:26 +0200)
* commit '41e86146e7240f9d42e8cdb86a94bb3eb2bbe15f':
  dump: print detailed color space information

full color triplets are only printed if they are not all equal, otherwise
they are printed as before

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/utils.c

@@@ -2984,34 -1914,37 +2984,49 @@@ void avcodec_string(char *buf, int buf_
  
      switch (enc->codec_type) {
      case AVMEDIA_TYPE_VIDEO:
 -        snprintf(buf, buf_size,
 -                 "Video: %s%s",
 -                 codec_name, enc->mb_decision ? " (hq)" : "");
 -        if (profile)
 -            snprintf(buf + strlen(buf), buf_size - strlen(buf),
 -                     " (%s)", profile);
 +        if (enc->pix_fmt != AV_PIX_FMT_NONE) {
 +            char detail[256] = "(";
-             const char *colorspace_name;
  
 -        av_strlcat(buf, "\n      ", buf_size);
 -        snprintf(buf + strlen(buf), buf_size - strlen(buf),
 +            av_strlcat(buf, separator, buf_size);
 +
 +            snprintf(buf + strlen(buf), buf_size - strlen(buf),
                   "%s", enc->pix_fmt == AV_PIX_FMT_NONE ? "none" :
                       av_get_pix_fmt_name(enc->pix_fmt));
-                 av_strlcatf(detail, sizeof(detail),
-                             enc->color_range == AVCOL_RANGE_MPEG ? "tv, ": "pc, ");
 +            if (enc->bits_per_raw_sample &&
 +                enc->bits_per_raw_sample <= av_pix_fmt_desc_get(enc->pix_fmt)->comp[0].depth_minus1)
 +                av_strlcatf(detail, sizeof(detail), "%d bpc, ", enc->bits_per_raw_sample);
 +            if (enc->color_range != AVCOL_RANGE_UNSPECIFIED)
-             colorspace_name = av_get_colorspace_name(enc->colorspace);
-             if (colorspace_name)
-                 av_strlcatf(detail, sizeof(detail), "%s, ", colorspace_name);
++                av_strlcatf(detail, sizeof(detail), "%s, ",
++                            av_color_range_name(enc->color_range));
++
++            if (enc->colorspace != AVCOL_SPC_UNSPECIFIED ||
++                enc->color_primaries != AVCOL_PRI_UNSPECIFIED ||
++                enc->color_trc != AVCOL_TRC_UNSPECIFIED) {
++                if (enc->colorspace != enc->color_primaries ||
++                    enc->colorspace != enc->color_trc) {
++                    new_line = 1;
++                    av_strlcatf(detail, sizeof(detail), "%s/%s/%s, ",
++                                av_color_space_name(enc->colorspace),
++                                av_color_primaries_name(enc->color_primaries),
++                                av_color_transfer_name(enc->color_trc));
++                } else
++                    av_strlcatf(detail, sizeof(detail), "%s, ",
++                                av_get_colorspace_name(enc->colorspace));
++            }
 +
++            if (av_log_get_level() >= AV_LOG_DEBUG &&
++                enc->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED)
++                av_strlcatf(detail, sizeof(detail), "%s, ",
++                            av_chroma_location_name(enc->chroma_sample_location));
  
 -        if (enc->color_range != AVCOL_RANGE_UNSPECIFIED)
 -            snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %s",
 -                     av_color_range_name(enc->color_range));
 -        if (enc->colorspace != AVCOL_SPC_UNSPECIFIED ||
 -            enc->color_primaries != AVCOL_PRI_UNSPECIFIED ||
 -            enc->color_trc != AVCOL_TRC_UNSPECIFIED) {
 -            new_line = 1;
 -            snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %s/%s/%s",
 -                     av_color_space_name(enc->colorspace),
 -                     av_color_primaries_name(enc->color_primaries),
 -                     av_color_transfer_name(enc->color_trc));
 -        }
 -        if (av_log_get_level() >= AV_LOG_DEBUG &&
 -            enc->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED)
 -            snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %s",
 -                     av_chroma_location_name(enc->chroma_sample_location));
 +            if (strlen(detail) > 1) {
 +                detail[strlen(detail) - 2] = 0;
 +                av_strlcatf(buf, buf_size, "%s)", detail);
 +            }
 +        }
  
          if (enc->width) {
--            av_strlcat(buf, new_line ? "\n      " : ", ", buf_size);
++            av_strlcat(buf, new_line ? separator : ", ", buf_size);
  
              snprintf(buf + strlen(buf), buf_size - strlen(buf),
                       "%dx%d",