]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/log.c
avoptions: Support getting flag values using av_get_int
[ffmpeg] / libavutil / log.c
index cfeb21cd5a666096af6856dc2b86abdb7f680b6c..fd5e2cbbe2853c04eabe2274b2635ef0578486f8 100644 (file)
@@ -2,20 +2,20 @@
  * log functions
  * Copyright (c) 2003 Michel Bardiaux
  *
- * This file is part of Libav.
+ * This file is part of FFmpeg.
  *
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
@@ -79,6 +79,14 @@ const char* av_default_item_name(void* ptr){
     return (*(AVClass**)ptr)->class_name;
 }
 
+static void sanitize(uint8_t *line){
+    while(*line){
+        if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
+            *line='?';
+        line++;
+    }
+}
+
 void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
 {
     static int print_prefix=1;
@@ -103,13 +111,13 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
 
     vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);
 
-    print_prefix= line[strlen(line)-1] == '\n';
+    print_prefix = strlen(line) && line[strlen(line)-1] == '\n';
 
 #if HAVE_ISATTY
     if(!is_atty) is_atty= isatty(2) ? 1 : -1;
 #endif
 
-    if(print_prefix && (flags & AV_LOG_SKIP_REPEATED) && !strncmp(line, prev, sizeof line)){
+    if(print_prefix && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev)){
         count++;
         if(is_atty==1)
             fprintf(stderr, "    Last message repeated %d times\r", count);
@@ -119,8 +127,9 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
         fprintf(stderr, "    Last message repeated %d times\n", count);
         count=0;
     }
+    strcpy(prev, line);
+    sanitize(line);
     colored_fputs(av_clip(level>>3, 0, 6), line);
-    strncpy(prev, line, sizeof line);
 }
 
 static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;