Mercurial > libavcodec.hg
comparison utils.c @ 1598:932d306bf1dc libavcodec
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
author | michael |
---|---|
date | Mon, 03 Nov 2003 13:26:22 +0000 |
parents | de5e2acd0f80 |
children | bb0fa675533f |
comparison
equal
deleted
inserted
replaced
1597:4c9165372ab3 | 1598:932d306bf1dc |
---|---|
1 /* | 1 /* |
2 * utils for libavcodec | 2 * utils for libavcodec |
3 * Copyright (c) 2001 Fabrice Bellard. | 3 * Copyright (c) 2001 Fabrice Bellard. |
4 * Copyright (c) 2003 Michel Bardiaux for the av_log API | |
4 * | 5 * |
5 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Lesser General Public | 7 * modify it under the terms of the GNU Lesser General Public |
7 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
23 */ | 24 */ |
24 | 25 |
25 #include "avcodec.h" | 26 #include "avcodec.h" |
26 #include "dsputil.h" | 27 #include "dsputil.h" |
27 #include "mpegvideo.h" | 28 #include "mpegvideo.h" |
29 #include <stdarg.h> | |
28 | 30 |
29 void *av_mallocz(unsigned int size) | 31 void *av_mallocz(unsigned int size) |
30 { | 32 { |
31 void *ptr; | 33 void *ptr; |
32 | 34 |
764 | 766 |
765 l += (h%c)<<32; | 767 l += (h%c)<<32; |
766 | 768 |
767 return ((h/c)<<32) + l/c; | 769 return ((h/c)<<32) + l/c; |
768 } | 770 } |
771 | |
772 /* av_log API */ | |
773 | |
774 #ifdef AV_LOG_TRAP_PRINTF | |
775 #undef stderr | |
776 #undef fprintf | |
777 #endif | |
778 | |
779 static int av_log_level = AV_LOG_DEBUG; | |
780 | |
781 static void av_log_default_callback(AVCodecContext* avctx, int level, const char* fmt, va_list vl) | |
782 { | |
783 if(level>av_log_level) | |
784 return; | |
785 if(avctx) | |
786 fprintf(stderr, "[%s @ %p]", avctx->codec->name, avctx); | |
787 vfprintf(stderr, fmt, vl); | |
788 } | |
789 | |
790 static void (*av_log_callback)(AVCodecContext*, int, const char*, va_list) = av_log_default_callback; | |
791 | |
792 void av_log(AVCodecContext* avctx, int level, const char *fmt, ...) | |
793 { | |
794 va_list vl; | |
795 va_start(vl, fmt); | |
796 av_vlog(avctx, level, fmt, vl); | |
797 va_end(vl); | |
798 } | |
799 | |
800 void av_vlog(AVCodecContext* avctx, int level, const char *fmt, va_list vl) | |
801 { | |
802 av_log_callback(avctx, level, fmt, vl); | |
803 } | |
804 | |
805 int av_log_get_level(void) | |
806 { | |
807 return av_log_level; | |
808 } | |
809 | |
810 void av_log_set_level(int level) | |
811 { | |
812 av_log_level = level; | |
813 } | |
814 | |
815 void av_log_set_callback(void (*callback)(AVCodecContext*, int, const char*, va_list)) | |
816 { | |
817 av_log_callback = callback; | |
818 } | |
819 |