]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '25a1ba814ad80056247fd357ec4c6911324a3f66'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 12 Feb 2014 13:41:24 +0000 (14:41 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 12 Feb 2014 13:41:24 +0000 (14:41 +0100)
* commit '25a1ba814ad80056247fd357ec4c6911324a3f66':
  log: Have function parameter names match between .c and .h file

Conflicts:
libavutil/log.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavutil/log.c
libavutil/log.h

diff --cc libavutil/log.c
index a7eb34c3d2512e376b5344241abd12b9ff3008da,3cc811bcccf8ef2cc0c637027638877b5df07e0a..38ce1e8fc84d38504e8d959832fccfb79dc69dfe
@@@ -159,91 -94,33 +159,91 @@@ const char *av_default_item_name(void *
      return (*(AVClass **) ptr)->class_name;
  }
  
 -void av_log_default_callback(void *avcl, int level, const char *fmt, va_list vl)
 +AVClassCategory av_default_get_category(void *ptr)
 +{
 +    return (*(AVClass **) ptr)->category;
 +}
 +
 +static void sanitize(uint8_t *line){
 +    while(*line){
 +        if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
 +            *line='?';
 +        line++;
 +    }
 +}
 +
 +static int get_category(void *ptr){
 +    AVClass *avc = *(AVClass **) ptr;
 +    if(    !avc
 +        || (avc->version&0xFF)<100
 +        ||  avc->version < (51 << 16 | 59 << 8)
 +        ||  avc->category >= AV_CLASS_CATEGORY_NB) return AV_CLASS_CATEGORY_NA + 16;
 +
 +    if(avc->get_category)
 +        return avc->get_category(ptr) + 16;
 +
 +    return avc->category + 16;
 +}
 +
- static void format_line(void *ptr, int level, const char *fmt, va_list vl,
++static void format_line(void *avcl, int level, const char *fmt, va_list vl,
 +                        AVBPrint part[3], int *print_prefix, int type[2])
  {
-     AVClass* avc = ptr ? *(AVClass **) ptr : NULL;
 -    static int print_prefix = 1;
 -    static int count;
 -    static char prev[1024];
 -    char line[1024];
 -    static int is_atty;
+     AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
 -    if (level > av_log_level)
 -        return;
 -    line[0] = 0;
 -    if (print_prefix && avc) {
 +    av_bprint_init(part+0, 0, 1);
 +    av_bprint_init(part+1, 0, 1);
 +    av_bprint_init(part+2, 0, 65536);
 +
 +    if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
 +    if (*print_prefix && avc) {
          if (avc->parent_log_context_offset) {
-             AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) +
+             AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +
                                     avc->parent_log_context_offset);
              if (parent && *parent) {
 -                snprintf(line, sizeof(line), "[%s @ %p] ",
 +                av_bprintf(part+0, "[%s @ %p] ",
                           (*parent)->item_name(parent), parent);
 +                if(type) type[0] = get_category(parent);
              }
          }
 -        snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ",
 +        av_bprintf(part+1, "[%s @ %p] ",
-                  avc->item_name(ptr), ptr);
-         if(type) type[1] = get_category(ptr);
+                  avc->item_name(avcl), avcl);
++        if(type) type[1] = get_category(avcl);
      }
  
 -    vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);
 +    av_vbprintf(part+2, fmt, vl);
  
 -    print_prefix = strlen(line) && line[strlen(line) - 1] == '\n';
 +    if(*part[0].str || *part[1].str || *part[2].str) {
 +        char lastc = part[2].len && part[2].len <= part[2].size ? part[2].str[part[2].len - 1] : 0;
 +        *print_prefix = lastc == '\n' || lastc == '\r';
 +    }
 +}
 +
 +void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
 +                        char *line, int line_size, int *print_prefix)
 +{
 +    AVBPrint part[3];
 +    format_line(ptr, level, fmt, vl, part, print_prefix, NULL);
 +    snprintf(line, line_size, "%s%s%s", part[0].str, part[1].str, part[2].str);
 +    av_bprint_finalize(part+2, NULL);
 +}
 +
 +void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
 +{
 +    static int print_prefix = 1;
 +    static int count;
 +    static char prev[LINE_SZ];
 +    AVBPrint part[3];
 +    char line[LINE_SZ];
 +    static int is_atty;
 +    int type[2];
 +
 +    if (level > av_log_level)
 +        return;
 +#if HAVE_PTHREADS
 +    pthread_mutex_lock(&mutex);
 +#endif
 +
 +    format_line(ptr, level, fmt, vl, part, &print_prefix, type);
 +    snprintf(line, sizeof(line), "%s%s%s", part[0].str, part[1].str, part[2].str);
  
  #if HAVE_ISATTY
      if (!is_atty)
diff --cc libavutil/log.h
Simple merge