mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
avutil/log: merge calls that set ansi color and print the string
about 1/3 or so faster Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
22ef9cb46d
commit
2c21e2ee4c
@ -75,9 +75,6 @@ static const uint8_t color[16 + AV_CLASS_CATEGORY_NB] = {
|
|||||||
|
|
||||||
static int16_t background, attr_orig;
|
static int16_t background, attr_orig;
|
||||||
static HANDLE con;
|
static HANDLE con;
|
||||||
#define set_color(x) SetConsoleTextAttribute(con, background | color[x])
|
|
||||||
#define set_256color set_color
|
|
||||||
#define reset_color() SetConsoleTextAttribute(con, attr_orig)
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static const uint32_t color[16 + AV_CLASS_CATEGORY_NB] = {
|
static const uint32_t color[16 + AV_CLASS_CATEGORY_NB] = {
|
||||||
@ -101,9 +98,6 @@ static const uint32_t color[16 + AV_CLASS_CATEGORY_NB] = {
|
|||||||
[16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 147 << 8 | 0x14,
|
[16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 147 << 8 | 0x14,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define set_color(x) fprintf(stderr, "\033[%d;3%dm", (color[x] >> 4) & 15, color[x] & 15)
|
|
||||||
#define set_256color(x) fprintf(stderr, "\033[48;5;%dm\033[38;5;%dm", (color[x] >> 16) & 0xff, (color[x] >> 8) & 0xff)
|
|
||||||
#define reset_color() fprintf(stderr, "\033[0m")
|
|
||||||
#endif
|
#endif
|
||||||
static int use_color = -1;
|
static int use_color = -1;
|
||||||
|
|
||||||
@ -132,14 +126,29 @@ static void colored_fputs(int level, const char *str)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_color == 1) {
|
#if HAVE_SETCONSOLETEXTATTRIBUTE
|
||||||
set_color(level);
|
if (use_color)
|
||||||
} else if (use_color == 256)
|
SetConsoleTextAttribute(con, background | color[level]);
|
||||||
set_256color(level);
|
|
||||||
fputs(str, stderr);
|
fputs(str, stderr);
|
||||||
if (use_color) {
|
if (use_color)
|
||||||
reset_color();
|
SetConsoleTextAttribute(con, attr_orig);
|
||||||
}
|
#else
|
||||||
|
if (use_color == 1) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"\033[%d;3%dm%s\033[0m",
|
||||||
|
(color[level] >> 4) & 15,
|
||||||
|
color[level] & 15,
|
||||||
|
str);
|
||||||
|
} else if (use_color == 256) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"\033[48;5;%dm\033[38;5;%dm%s\033[0m",
|
||||||
|
(color[level] >> 16) & 0xff,
|
||||||
|
(color[level] >> 8) & 0xff,
|
||||||
|
str);
|
||||||
|
} else
|
||||||
|
fputs(str, stderr);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *av_default_item_name(void *ptr)
|
const char *av_default_item_name(void *ptr)
|
||||||
|
Loading…
Reference in New Issue
Block a user