53#if HAVE_VALGRIND_VALGRIND_H && CONFIG_VALGRIND_BACKTRACE
54#include <valgrind/valgrind.h>
56#define BACKTRACE_LOGLEVEL AV_LOG_ERROR
63#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
94static int16_t background, attr_orig;
129#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
130static void win_console_puts(
const char *str)
132 const uint8_t *q = str;
136 uint16_t *buf =
line;
140 while (*q && nb_chars <
LINE_SZ - 1) {
144 GET_UTF8(ch, *q ? *q++ : 0, ch = 0xfffd;
goto continue_on_invalid;)
149 WriteConsoleW(con,
line, nb_chars, &written,
NULL);
156 char *term = getenv(
"TERM");
158#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
159 CONSOLE_SCREEN_BUFFER_INFO con_info;
161 con = GetStdHandle(STD_ERROR_HANDLE);
162 if (con != INVALID_HANDLE_VALUE && !GetConsoleMode(con, &
dummy))
163 con = INVALID_HANDLE_VALUE;
164 if (con != INVALID_HANDLE_VALUE) {
165 GetConsoleScreenBufferInfo(con, &con_info);
166 attr_orig = con_info.wAttributes;
167 background = attr_orig & 0xF0;
171 if (getenv(
"AV_LOG_FORCE_NOCOLOR")) {
173 }
else if (getenv(
"AV_LOG_FORCE_COLOR")) {
176#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
177 use_color = (con != INVALID_HANDLE_VALUE);
185 if (getenv(
"AV_LOG_FORCE_256COLOR") || term && strstr(term,
"256color"))
191 if (local_use_color == 1) {
193 "\033[%"PRIu32
";3%"PRIu32
"m%s\033[0m",
199 "\033[48;5;%"PRIu32
"m\033[38;5;%dm%s\033[0m",
203 }
else if (local_use_color == 256) {
205 "\033[48;5;%"PRIu32
"m\033[38;5;%"PRIu32
"m%s\033[0m",
225#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
226 if (con != INVALID_HANDLE_VALUE) {
228 SetConsoleTextAttribute(con, background | win_color[
level]);
229 win_console_puts(str);
231 SetConsoleTextAttribute(con, attr_orig);
243 return (*(
AVClass **) ptr)->class_name;
248 return (*(
AVClass **) ptr)->category;
263 || avc->
version < (51 << 16 | 59 << 8)
305 struct tm *ptm, tmbuf;
307 const int64_t time_ms = time_us / 1000;
308 const time_t time_s = time_ms / 1000;
309 const int millisec = time_ms - (time_s * 1000);
321 AVBPrint part[5],
int *print_prefix,
int type[2])
332 if (*print_prefix && avc) {
336 if (parent && *parent) {
355 if(*part[0].str || *part[1].str || *part[2].str || *part[3].str) {
356 char lastc = part[3].len && part[3].len <= part[3].size ? part[3].str[part[3].len - 1] : 0;
357 *print_prefix = lastc ==
'\n' || lastc ==
'\r';
362 char *
line,
int line_size,
int *print_prefix)
368 char *
line,
int line_size,
int *print_prefix)
374 ret =
snprintf(
line, line_size,
"%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
381 static int print_prefix = 1;
391 tint =
level & 0xff00;
400 snprintf(
line,
sizeof(
line),
"%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
404 is_atty = isatty(2) ? 1 : -1;
411 fprintf(stderr,
" Last message repeated %d times\r", count);
415 fprintf(stderr,
" Last message repeated %d times\n", count);
431#if CONFIG_VALGRIND_BACKTRACE
432 if (
level <= BACKTRACE_LOGLEVEL)
433 VALGRIND_PRINTF_BACKTRACE(
"%s",
"");
450void av_log_once(
void* avcl,
int initial_level,
int subsequent_level,
int *
state,
const char *fmt, ...)
454 av_vlog(avcl, *
state ? subsequent_level : initial_level, fmt, vl);
462 void (*
log_callback)(
void*, int,
const char*, va_list) =
464 if (avc && avc->
version >= (50 << 16 | 15 << 8 | 2) &&
497 va_list argument_list)
501 "version to the newest one from Git. If the problem still "
502 "occurs, it means that your file has a feature which has not "
503 "been implemented.\n");
506 "of this file to https://streams.videolan.org/upload/ "
507 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n");
512 va_list argument_list;
514 va_start(argument_list, msg);
516 va_end(argument_list);
521 va_list argument_list;
523 va_start(argument_list, msg);
525 va_end(argument_list);
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_AUTOMATIC
#define flags(name, subs,...)
common internal and external API header
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
#define PUT_UTF16(val, tmp, PUT_16BIT)
Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
static void callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, enum dshowDeviceType devtype)
#define atomic_load_explicit(object, order)
#define atomic_store_explicit(object, desired, order)
intptr_t atomic_uintptr_t
static struct @346255127015250356166251341105367306144006377143 state
static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm)
Append a formatted date and time to a print buffer.
void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg)
Append a formatted string to a print buffer.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
#define AV_LOG_QUIET
Print no output.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_LOG_PRINT_DATETIME
Include system date and time in log output.
int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix)
Format a line of log the same way as the default callback.
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
#define AV_LOG_PRINT_TIME
Include system time in log output.
const char * av_default_item_name(void *ptr)
Return the context name.
void av_log_set_level(int level)
Set the log level.
void av_log_default_callback(void *ptr, int level, const char *fmt, va_list vl)
Default logging callback.
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level.
#define AV_LOG_SKIP_REPEATED
Skip repeated messages, this requires the user app to use av_log() instead of (f)printf as the 2 woul...
AVClassCategory av_default_get_category(void *ptr)
int av_log_get_flags(void)
#define AV_LOG_PRINT_LEVEL
Include the log severity in messages originating from codecs.
int av_log_get_level(void)
Get the current log level.
void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix)
Format a line of log the same way as the default callback.
void av_log_set_flags(int arg)
common internal API header
#define AV_MUTEX_INITIALIZER
static int ff_mutex_unlock(AVMutex *mutex)
static int ff_mutex_lock(AVMutex *mutex)
static void check_color_terminal(void)
static void colored_fputs(int level, int tint, const char *str)
static int get_category(void *ptr)
static void missing_feature_sample(int sample, void *avc, const char *msg, va_list argument_list)
static atomic_int av_log_level
void av_log_once(void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
static const char * get_level_str(int level)
static void ansi_fputs(int level, int tint, const char *str, int local_use_color)
static atomic_int av_log_flags
static void format_date_now(AVBPrint *bp_time, int include_date)
void avpriv_report_missing_feature(void *avc, const char *msg,...)
static atomic_uintptr_t av_log_callback
static void format_line(void *avcl, int level, const char *fmt, va_list vl, AVBPrint part[5], int *print_prefix, int type[2])
static void sanitize(uint8_t *line)
@ AV_CLASS_CATEGORY_INPUT
@ AV_CLASS_CATEGORY_MUXER
@ AV_CLASS_CATEGORY_SWSCALER
@ AV_CLASS_CATEGORY_BITSTREAM_FILTER
@ AV_CLASS_CATEGORY_DEVICE_OUTPUT
@ AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT
@ AV_CLASS_CATEGORY_NB
not part of ABI/API
@ AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT
@ AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT
@ AV_CLASS_CATEGORY_FILTER
@ AV_CLASS_CATEGORY_DEMUXER
@ AV_CLASS_CATEGORY_OUTPUT
@ AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT
@ AV_CLASS_CATEGORY_DEVICE_INPUT
@ AV_CLASS_CATEGORY_SWRESAMPLER
@ AV_CLASS_CATEGORY_ENCODER
@ AV_CLASS_CATEGORY_DECODER
@ AV_CLASS_CATEGORY_HWDEVICE
Describe the class of an AVClass context structure.
AVClassCategory(* get_category)(void *ctx)
Callback to return the instance category.
AVClassCategory category
Category used for visualization (like color).
int version
LIBAVUTIL_VERSION with which this structure was created.
int parent_log_context_offset
Offset in the structure where a pointer to the parent context for logging is stored.
const char *(* item_name)(void *ctx)
A pointer to a function which returns the name of a context instance ctx associated with the class.
int log_level_offset_offset
Offset in the structure where the log level offset is stored.
#define avpriv_request_sample(...)
int64_t av_gettime(void)
Get the current time in microseconds.