replaced instances of color_out with color_printf

+ reindent vidcap/file help ("where" keyword)
This commit is contained in:
Martin Pulec
2022-08-02 13:01:03 +02:00
parent d1fbb7cb34
commit 2e424d50ca
25 changed files with 89 additions and 116 deletions

View File

@@ -120,7 +120,7 @@ static inline void audio_alsa_help(void)
strcpy(available_devices[0].name, "default ALSA device (same as \"alsa:default\")");
for(int i = 0; i < count; i++){
const char * const id = available_devices[i].dev;
color_out(COLOR_OUT_BOLD, "\talsa%s", id);
color_printf(TERM_FG_RED "\talsa%s" TERM_FG_RESET, id);
for (int j = 0; j < 30 - (int) strlen(id); ++j) putchar(' ');
printf(": %s\n", available_devices[i].name);
}

View File

@@ -105,14 +105,12 @@ static void * audio_cap_alsa_init(const char *cfg)
{
if(cfg && strcmp(cfg, "help") == 0) {
printf("Usage\n");
color_out(COLOR_OUT_BOLD | COLOR_OUT_RED, "\t-s alsa\n");
color_out(COLOR_OUT_BOLD, "\t-s alsa:<device>\n");
color_out(COLOR_OUT_BOLD, "\t-s alsa:<device>:opts=<opts>\n");
color_out(COLOR_OUT_BOLD, "\t-s alsa:opts=<opts>\n\n");
color_out(COLOR_OUT_BOLD, "\t<opts>");
printf(" can be in format key1=value1:key2=value2, options are:\n");
color_out(COLOR_OUT_BOLD, "\t\tframes=<frames>");
printf(" number of audio frames captured at a moment\n");
color_printf(TERM_BOLD TERM_FG_RED "\t-s alsa\n" TERM_RESET);
color_printf(TERM_BOLD "\t-s alsa:<device>\n" TERM_RESET);
color_printf(TERM_BOLD "\t-s alsa:<device>:opts=<opts>\n" TERM_RESET);
color_printf(TERM_BOLD "\t-s alsa:opts=<opts>\n\n" TERM_RESET);
color_printf(TERM_BOLD "\t<opts>" TERM_RESET " can be in format key1=value1:key2=value2, options are:\n");
color_printf(TERM_BOLD "\t\tframes=<frames>" TERM_RESET " number of audio frames captured at a moment\n");
printf("\nAvailable ALSA capture devices\n");
audio_cap_alsa_help(NULL);

View File

@@ -138,10 +138,8 @@ static void * audio_cap_portaudio_init(const char *cfg)
if(cfg && strcmp(cfg, "help") == 0) {
printf("Portaudio options:\n");
color_out(COLOR_OUT_BOLD | COLOR_OUT_RED, "\t-s portaudio");
color_out(COLOR_OUT_BOLD, "[:<index>[:latency=<l>]]\n\n");
color_out(COLOR_OUT_BOLD, "\t<l>");
printf("\tsuggested latency in sec (experimental, use in case of problems)\n");
color_printf(TERM_BOLD TERM_FG_RED "\t-s portaudio" TERM_FG_RESET "[:<index>[:latency=<l>]]\n\n" TERM_RESET);
color_printf(TERM_BOLD "\t<l>" TERM_RESET "\tsuggested latency in sec (experimental, use in case of problems)\n");
printf("\nAvailable PortAudio capture devices:\n");
audio_cap_portaudio_help(NULL);

View File

@@ -830,15 +830,14 @@ static void * audio_play_alsa_init(const char *cfg)
if(cfg && strlen(cfg) > 0) {
if(strcmp(cfg, "help") == 0) {
printf("Usage\n");
color_out(COLOR_OUT_BOLD | COLOR_OUT_RED, "\t-r alsa");
color_out(COLOR_OUT_BOLD, "[:<device>] --param alsa-playback-api={thread|async|sync}[,alsa-playback-buffer=[<us>-]<us>][,audio-buffer-len=<ablen>]\n");
color_out(0u, "where\n");
color_out(COLOR_OUT_BOLD, "\talsa-playback-api={thread|async|sync}\n");
color_out(0, "\t\tuse selected API ('thread' is default)\n");
color_out(COLOR_OUT_BOLD, "\talsa-playback-buffer=[<us>-]<us>\n");
color_out(0, "\t\tset buffer max and optionally max (thread and async API only)\n");
color_out(COLOR_OUT_BOLD, "\taudio-buffer-len=<ablen>\n");
color_out(0, "\t\tlength of UG internal ALSA buffer (in milliseconds)\n");
color_printf(TERM_BOLD TERM_FG_RED "\t-r alsa" TERM_FG_RESET "[:<device>] --param alsa-playback-api={thread|async|sync}[,alsa-playback-buffer=[<us>-]<us>][,audio-buffer-len=<ablen>]\n" TERM_RESET);
color_printf("where\n");
color_printf(TERM_BOLD "\talsa-playback-api={thread|async|sync}\n" TERM_RESET);
color_printf("\t\tuse selected API ('thread' is default)\n");
color_printf(TERM_BOLD "\talsa-playback-buffer=[<us>-]<us>\n" TERM_RESET);
color_printf("\t\tset buffer max and optionally max (thread and async API only)\n");
color_printf(TERM_BOLD "\taudio-buffer-len=<ablen>\n" TERM_RESET);
color_printf("\t\tlength of UG internal ALSA buffer (in milliseconds)\n");
printf("\n");
printf("Available ALSA playback devices:\n");

View File

@@ -154,8 +154,7 @@ static void * audio_play_portaudio_init(const char *cfg)
if(cfg) {
if(strcmp(cfg, "help") == 0) {
printf("PortAudio playback usage:\n");
color_out(COLOR_OUT_BOLD | COLOR_OUT_RED, "\t-r poraudio");
color_out(COLOR_OUT_BOLD, "[:<index>]\n\n");
color_printf(TERM_BOLD TERM_FG_RED "\t-r poraudio" TERM_FG_RESET "[:<index>]\n\n" TERM_RESET);
printf("Available PortAudio playback devices:\n");
audio_play_portaudio_help(NULL);
return &audio_init_state_ok;

View File

@@ -103,8 +103,7 @@ int capture_filter_init(struct module *parent, const char *cfg, struct capture_f
{
if (cfg && (strcasecmp(cfg, "help") == 0 || strcasecmp(cfg, "fullhelp") == 0)) {
printf("Usage:\n");
color_out(COLOR_OUT_BOLD, "\t--capture-filter <filter1>[:opts][,<filter2>[:opts][,<filter3>[:<opts>]]]");
printf(" -t <capture>\n\n");
color_printf(TERM_BOLD "\t--capture-filter <filter1>[:opts][,<filter2>[:opts][,<filter3>[:<opts>]]]" TERM_RESET " -t <capture>\n\n");
printf("Available capture filters:\n");
list_modules(LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION, strcasecmp(cfg, "fullhelp") == 0);
if (strcasecmp(cfg, "fullhelp") != 0) {

View File

@@ -63,7 +63,7 @@ static int init(struct module *parent, const char *cfg, void **state)
if (strlen(cfg) == 0 || strcmp(cfg, "help") == 0) {
printf("Performs pixel format change transformation.\n\n"
"usage:\n");
color_out(COLOR_OUT_BOLD, "\t--capture-filter change_pixfmt:<name>\n");
color_printf(TERM_FG_RED "\t--capture-filter change_pixfmt:<name>\n" TERM_FG_RESET);
return 1;
}

View File

@@ -91,7 +91,7 @@ static int init(struct module *parent, const char *cfg, void **state)
}
} else {
usage();
color_out(COLOR_OUT_RED, MOD_NAME "Currently only supported filter is jitter\n");
color_printf(TERM_FG_RED MOD_NAME "Currently only supported filter is jitter\n" TERM_FG_RESET);
free(s);
return -1;
}

View File

@@ -64,7 +64,7 @@ static int init(struct module *parent, const char *cfg, void **state)
if (strlen(cfg) == 0 || strcmp(cfg, "help") == 0) {
printf("Performs matrix transformation on input pixels.\n\n"
"usage:\n");
color_out(COLOR_OUT_BOLD, "\t--capture-filter matrix:a:b:c:d:e:f:g:h:i[:no-bounds-check]\n");
color_printf(TERM_BOLD "\t--capture-filter matrix:a:b:c:d:e:f:g:h:i[:no-bounds-check]\n" TERM_RESET);
printf("where numbers a-i are members of 3x3 transformation matrix [a b c; d e f; g h i], decimals.\n"
"Coefficients are applied at unpacked pixels (eg. on Y Cb and Cr channels of UYVY). Result is marked as RGB.\n"
"Currently only RGB and UYVY is supported on input. No additional color transformation is performed.\n");

View File

@@ -62,8 +62,7 @@ static int init(struct module *parent, const char *cfg, void **state)
UNUSED(state);
if (strlen(cfg) > 0) {
color_out(COLOR_OUT_RED | COLOR_OUT_BOLD, "none");
color_out(0, " capture filter - dummy (noop) filter, no options\n");
color_printf(TERM_BOLD TERM_FG_RED "none" TERM_FG_RESET " capture filter - dummy (noop) filter, no options\n" TERM_RESET);
return strcmp(cfg, "help") == 0 ? 1 : -1;
}

View File

@@ -65,7 +65,7 @@ struct state_split {
static void usage() {
printf("Splits frame to XxY tiles:\n\n");
printf("split usage:\n");
color_out(COLOR_OUT_BOLD, "\tsplit:x:y\n\n");
color_printf(TERM_BOLD "\tsplit:x:y\n\n" TERM_RESET);
}
static int init(struct module *parent, const char *cfg, void **state)

View File

@@ -271,7 +271,7 @@ static bool create_dir(struct exporter *s)
}
if (s->dir) {
color_out(COLOR_OUT_BOLD | COLOR_OUT_YELLOW, "Using export directory: %s\n", s->dir);
color_printf(TERM_BOLD TERM_FG_YELLOW "Using export directory: %s\n" TERM_RESET, s->dir);
return true;
} else {
return false;

View File

@@ -49,7 +49,7 @@
#include "compat/dlfunc.h"
#include "config_common.h" // MAX
#include "debug.h"
#include "utils/color_out.h" // MERGE, TOSTRING
#include "utils/color_out.h"
#include "utils/macros.h" // MERGE, TOSTRING
#define NDILIB_DEFAULT_PATH "/usr/local/lib"
@@ -161,8 +161,8 @@ static void close_ndi_library(LIB_HANDLE hNDILib) {
}
#define NDI_PRINT_COPYRIGHT \
color_out(COLOR_OUT_BOLD | COLOR_OUT_BLUE, u8"This application uses NDI® available from http://ndi.tv/\n" \
u8"NDI® is a registered trademark of NewTek, Inc.\n\n"); int not_defined_function
color_printf(TERM_BOLD TERM_FG_BLUE u8"This application uses NDI® available from http://ndi.tv/\n" \
u8"NDI® is a registered trademark of NewTek, Inc.\n\n" TERM_RESET); int not_defined_function
#endif // defined NDI_COMMON_H_1A76D048_695C_4247_A24A_583C29010FC4

View File

@@ -53,14 +53,10 @@
#define MOD_NAME "[playback] "
static void playback_usage(void) {
color_out(0, "Usage:\n");
color_out(COLOR_OUT_RED | COLOR_OUT_BOLD, "\t--playback [<file>|<dir>|help]");
color_out(COLOR_OUT_BOLD, "[:loop]\n\n");
color_out(0, "Use ");
color_out(COLOR_OUT_BOLD, "-t file:help");
color_out(0, " or ");
color_out(COLOR_OUT_BOLD, "-t import:help");
color_out(0, " to see further specific configuration options.\n\n");
color_printf("Usage:\n");
color_printf(TERM_BOLD TERM_FG_RED "\t--playback [<file>|<dir>|help]" TERM_FG_RESET "[:loop]\n\n" TERM_RESET);
color_printf("Use ");
color_printf(TERM_BOLD "-t file:help" TERM_RESET " or " TERM_BOLD "-t import:help" TERM_RESET " to see further specific configuration options.\n\n");
}
int playback_set_device(char *device_string, size_t buf_len, const char *optarg) {

View File

@@ -82,10 +82,13 @@
#define COLOR_OUT_BRIGHT_GRAY (68u<<4u)
#define COLOR_OUT_BG_SHIFT (COLOR_OUT_FG_SHIFT+COLOR_BITS)
#define TERM_RESET "\e[0m"
#define TERM_BOLD "\e[1m"
#define TERM_FG_RED "\e[31m"
#define TERM_FG_RESET "\e[39m"
#define TERM_RESET "\e[0m"
#define TERM_BOLD "\e[1m"
#define TERM_FG_RED "\e[31m"
#define TERM_FG_YELLOW "\e[33m"
#define TERM_FG_BLUE "\e[34m"
#define TERM_FG_MAGENTA "\e[34m"
#define TERM_FG_RESET "\e[39m"
#ifdef __cplusplus
extern "C" {

View File

@@ -501,17 +501,14 @@ struct ug_nat_traverse *start_nat_traverse(const char *config, const char *remot
if (strcmp(config, "help") == 0) {
printf("Usage:\n");
color_out(COLOR_OUT_BOLD | COLOR_OUT_RED, "\t-N");
color_out(COLOR_OUT_BOLD, "[protocol[:renewal-interval]]\n");
color_printf(TERM_BOLD TERM_FG_RED "\t-N" TERM_FG_RESET "[protocol[:renewal-interval]]\n" TERM_RESET);
printf("where:\n");
color_out(COLOR_OUT_BOLD, "\tprotocol");
printf(" - one of:");
color_printf(TERM_BOLD "\tprotocol" TERM_RESET " - one of:");
for (int i = UG_NAT_TRAVERSE_FIRST; i <= UG_NAT_TRAVERSE_LAST; ++i) {
color_out(COLOR_OUT_BOLD, " %s", nat_traverse_info[i].name_short);
color_printf(TERM_BOLD " %s" TERM_RESET, nat_traverse_info[i].name_short);
}
printf("\n");
color_out(COLOR_OUT_BOLD, "\trenewal-interval");
printf(" - mapping renew interval (in seconds, min: %d)\n", PREALLOCATE_S + 1);
color_printf(TERM_BOLD "\trenewal-interval" TERM_RESET " - mapping renew interval (in seconds, min: %d)\n", PREALLOCATE_S + 1);
return NULL;
}

View File

@@ -391,8 +391,7 @@ static void show_help(struct vidcap_dshow_state *s) {
// Ignore the device
continue;
}
printf("Device %d: ", n);
color_out(COLOR_OUT_BOLD, "%ls\n", var.bstrVal);
color_printf("Device %d: " TERM_BOLD "%ls\n" TERM_RESET, n, var.bstrVal);
// clean up structures
VariantClear(&var);

View File

@@ -128,29 +128,25 @@ struct vidcap_state_lavf_decoder {
};
static void vidcap_file_show_help(bool full) {
color_out(0, "Usage:\n");
color_out(COLOR_OUT_BOLD | COLOR_OUT_RED, "\t-t file:<name>");
color_out(COLOR_OUT_BOLD, "[:loop][:nodecode][:codec=<c>]");
color_printf("Usage:\n");
color_printf(TERM_BOLD TERM_FG_RED "\t-t file:<name>" TERM_FG_RESET "[:loop][:nodecode][:codec=<c>]%s\n" TERM_RESET,
full ? "[:opportunistic_audio][:queue=<len>][:threads=<n>[FS]]" : "");
color_printf("where\n");
color_printf(TERM_BOLD "\tloop\n" TERM_RESET);
color_printf("\t\tloop the playback\n");
color_printf(TERM_BOLD "\tnodecode\n" TERM_RESET);
color_printf("\t\tdon't decompress the video (may not work because required data for correct decompess are in container or UG doesn't recognize the codec)\n");
color_printf(TERM_BOLD "\tcodec\n" TERM_RESET);
color_printf("\t\tcodec to decode to\n");
if (full) {
color_out(COLOR_OUT_BOLD, "[:opportunistic_audio][:queue=<len>][:threads=<n>[FS]]");
}
color_out(0, "\n");
color_out(0, "\t\twhere\n");
color_out(COLOR_OUT_BOLD, "\tloop\n");
color_out(0, "\t\tloop the playback\n");
color_out(COLOR_OUT_BOLD, "\tnodecode\n");
color_out(0, "\t\tdon't decompress the video (may not work because required data for correct decompess are in container or UG doesn't recognize the codec)\n");
color_out(COLOR_OUT_BOLD, "\tcodec\n");
color_out(0, "\t\tcodec to decode to\n");
if (full) {
color_out(COLOR_OUT_BOLD, "\topportunistic_audio\n");
color_out(0, "\t\tgrab audio if not present but do not fail if not\n");
color_out(COLOR_OUT_BOLD, "\tqueue\n");
color_out(0, "\t\tmax queue len (default: %d), increasing may help if video stutters\n", FILE_DEFAULT_QUEUE_LEN);
color_out(COLOR_OUT_BOLD, "\tthreads\n");
color_out(0, "\t\tnumber of threads (0 is default), 'S' and/or 'F' to use slice/frame threads, use at least one flag\n");
color_printf(TERM_BOLD "\topportunistic_audio\n" TERM_RESET);
color_printf("\t\tgrab audio if not present but do not fail if not\n");
color_printf(TERM_BOLD "\tqueue\n" TERM_RESET);
color_printf("\t\tmax queue len (default: %d), increasing may help if video stutters\n", FILE_DEFAULT_QUEUE_LEN);
color_printf(TERM_BOLD "\tthreads\n" TERM_RESET);
color_printf("\t\tnumber of threads (0 is default), 'S' and/or 'F' to use slice/frame threads, use at least one flag\n");
} else {
color_out(0, "\n(use \":fullhelp\" to see all available options)\n");
color_printf("\n(use \":fullhelp\" to see all available options)\n");
}
}

View File

@@ -75,8 +75,7 @@ static void show_help()
{
printf("Screen capture\n");
printf("Usage\n");
color_out(COLOR_OUT_BOLD | COLOR_OUT_RED, "\t-t screen");
color_out(COLOR_OUT_BOLD, "[:width=<w>][:height=<h>][:fps=<f>]\n");
color_printf(TERM_BOLD TERM_FG_RED "\t-t screen" TERM_FG_RESET "[:width=<w>][:height=<h>][:fps=<f>]\n" TERM_RESET);
}
static struct vidcap_type * vidcap_screen_win_probe(bool verbose, void (**deleter)(void *))

View File

@@ -200,23 +200,23 @@ static void show_help(_Bool full)
{
printf("V4L2 capture\n");
printf("Usage\n");
color_out(COLOR_OUT_RED | COLOR_OUT_BOLD, "\t-t v4l2[:device=<dev>]");
color_out(COLOR_OUT_BOLD, "[:codec=<pixel_fmt>][:size=<width>x<height>][:tpf=<tpf>|:fps=<fps>][:buffers=<bufcnt>][:convert=<conv>][:permissive] | -t v4l2:[short]help\n");
color_printf(TERM_BOLD TERM_FG_RED "\t-t v4l2[:device=<dev>]" TERM_FG_RESET
"[:codec=<pixel_fmt>][:size=<width>x<height>][:tpf=<tpf>|:fps=<fps>][:buffers=<bufcnt>][:convert=<conv>][:permissive] | -t v4l2:[short]help\n" TERM_RESET);
printf("where\n");
color_out(COLOR_OUT_BOLD, "<dev> -"); printf("\tuse device to grab from (default: first usable)\n");
color_out(COLOR_OUT_BOLD, "\t<tpf>"); printf(" - time per frame in format <numerator>/<denominator>\n");
color_out(COLOR_OUT_BOLD, "\t<bufcnt>"); printf(" - number of capture buffers to be used (default: %d)\n", DEFAULT_BUF_COUNT);
color_out(COLOR_OUT_BOLD, "\t<tpf>"); printf(" or "); color_out(COLOR_OUT_BOLD, "<fps>"); printf(" should be given as a single integer or a fraction\n");
color_out(COLOR_OUT_BOLD, "\t<conv>"); printf(" - SW conversion, eg. to RGB (useful eg. to convert captured MJPG from USB 2.0 webcam to uncompressed),\n"
color_printf(TERM_BOLD "<dev> -" TERM_RESET "\tuse device to grab from (default: first usable)\n");
color_printf(TERM_BOLD "\t<tpf>" TERM_RESET " - time per frame in format <numerator>/<denominator>\n");
color_printf(TERM_BOLD "\t<bufcnt>" TERM_RESET " - number of capture buffers to be used (default: %d)\n", DEFAULT_BUF_COUNT);
color_printf(TERM_BOLD "\t<tpf>" TERM_RESET " or " TERM_BOLD "<fps>" TERM_RESET " should be given as a single integer or a fraction\n");
color_printf(TERM_BOLD "\t<conv>" TERM_RESET " - SW conversion, eg. to RGB (useful eg. to convert captured MJPG from USB 2.0 webcam to uncompressed),\n"
"\t codecs available to convert to:");
#ifdef HAVE_LIBV4LCONVERT
for (unsigned int i = 0; i < sizeof v4l2_ug_map / sizeof v4l2_ug_map[0]; ++i) {
if (v4lconvert_supported_dst_format(v4l2_ug_map[i].v4l2_fcc)) {
color_out(COLOR_OUT_BOLD, " %s", get_codec_name(v4l2_ug_map[i].ug_codec));
color_printf(TERM_BOLD " %s" TERM_RESET, get_codec_name(v4l2_ug_map[i].ug_codec));
}
}
#else
color_out(COLOR_OUT_RED, " v4lconvert support not compiled in!");
color_printf(TERM_FG_RED " v4lconvert support not compiled in!" TERM_RESET);
#endif
printf("\n");
printf("\t\tpermissive - do not fail if configuration values (size, FPS) are adjusted by driver and not set exactly\n");
@@ -247,10 +247,7 @@ static void show_help(_Bool full)
goto next_device;
}
printf("\t%sDevice ", (i == 0 ? "(*) " : " "));
color_out(COLOR_OUT_BOLD,"%s ", name);
printf("%s, %s)%s\n", capab.card, capab.bus_info, full ? ":" : "");
color_printf("\t%sDevice " TERM_BOLD "%s " TERM_RESET"%s (%s)%s\n", (i == 0 ? "(*) " : " "), name, capab.card, capab.bus_info, full ? ":" : "");
struct v4l2_fmtdesc format;
memset(&format, 0, sizeof(format));
@@ -273,8 +270,7 @@ static void show_help(_Bool full)
printf(" ");
}
printf("Pixel format ");
color_out(COLOR_OUT_BOLD, "%4.4s", (const char *) &format.pixelformat);
printf(" (%s). Available frame sizes:\n", format.description);
color_printf(TERM_BOLD "%4.4s" TERM_RESET " (%s). Available frame sizes:\n", (const char *) &format.pixelformat, format.description);
struct v4l2_frmsizeenum size;
memset(&size, 0, sizeof(size));

View File

@@ -156,9 +156,8 @@ static void vidcap_ximea_close_lib(struct ximea_functions *f)
static void vidcap_ximea_show_help() {
color_out(0, "XIMEA usage:\n");
color_out(COLOR_OUT_RED | COLOR_OUT_BOLD, "\t-t ximea");
color_out(COLOR_OUT_BOLD, "[:device=<d>][:exposure=<time_us>]\n");
color_printf("XIMEA usage:\n");
color_printf(TERM_BOLD TERM_FG_RED, "\t-t ximea" TERM_FG_RESET "[:device=<d>][:exposure=<time_us>]\n" TERM_RESET);
printf("\n");
printf("Available devices:\n");
@@ -182,11 +181,11 @@ static void vidcap_ximea_show_help() {
for (DWORD i = 0; i < count; ++i) {
char name[256];
color_out(COLOR_OUT_BOLD, "\t%d) ", (int) i);
color_printf(TERM_BOLD "\t%d) " TERM_RESET, (int) i);
if (funcs.xiGetDeviceInfoString(i, XI_PRM_DEVICE_NAME, name, sizeof name) == XI_OK) {
color_out(0, "%s", name);
color_printf("%s", name);
}
color_out(0, "\n");
color_printf("\n");
}
vidcap_ximea_close_lib(&funcs);
}

View File

@@ -400,9 +400,10 @@ int display_put_frame(struct display *d, struct video_frame *frame, int flags)
long long seconds_ns = t - d->t0;
if (seconds_ns > 5 * NS_IN_SEC) {
if (log_level >= LOG_LEVEL_INFO) {
color_out(COLOR_OUT_BOLD | COLOR_OUT_MAGENTA, "[%s]", d->display_name);
color_out(0, " %d frames in %g seconds = ", d->frames, (double) seconds_ns / NS_IN_SEC);
color_out(COLOR_OUT_BOLD, "%g FPS\n", (double) d->frames * NS_IN_SEC / seconds_ns);
color_printf(TERM_BOLD TERM_FG_MAGENTA "[%s]" TERM_RESET " %d frames in %g seconds = " TERM_BOLD "%g FPS\n",
d->display_name,
d->frames, (double) seconds_ns / NS_IN_SEC,
(double) d->frames * NS_IN_SEC / seconds_ns);
}
d->frames = 0;
d->t0 = t;

View File

@@ -138,13 +138,10 @@ static int display_ndi_reconfigure(void *state, struct video_desc desc)
static void usage()
{
printf("Usage:\n");
color_out(COLOR_OUT_BOLD | COLOR_OUT_RED, "\t-d ndi");
color_out(COLOR_OUT_BOLD, "[:help][:name=<n>][:audio_level=<x>]\n");
color_printf(TERM_BOLD TERM_FG_RED "\t-d ndi" TERM_FG_RESET "[:help][:name=<n>][:audio_level=<x>]\n" TERM_RESET);
printf("\twhere\n");
color_out(COLOR_OUT_BOLD, "\t\tname\n");
printf("\t\t\tthe name of the server\n");
color_out(COLOR_OUT_BOLD, "\t\taudio_level\n");
printf("\t\t\taudio headroom above reference level (in dB, or mic/line, default %d)\n", DEFAULT_AUDIO_LEVEL);
color_printf(TERM_BOLD "\t\tname\n" TERM_RESET "\t\t\tthe name of the server\n");
color_printf(TERM_BOLD "\t\taudio_level\n" TERM_RESET "\t\t\taudio headroom above reference level (in dB, or mic/line, default %d)\n", DEFAULT_AUDIO_LEVEL);
}
/**

View File

@@ -109,8 +109,7 @@ next_device:
static void usage() {
printf("Usage:\n");
color_out(COLOR_OUT_BOLD|COLOR_OUT_RED, "\t-d v4l2");
color_out(COLOR_OUT_BOLD, "[:device=<path>] | -d v4l2:help\n");
color_printf(TERM_BOLD TERM_FG_RED "\t-d v4l2" TERM_FG_RESET "[:device=<path>] | -d v4l2:help\n" TERM_RESET);
printf("\n");
printf("Available devices:\n");
int count = 0;
@@ -118,15 +117,14 @@ static void usage() {
void (*deleter)(void *) = free;
display_v4l2_probe(&devices, &count, &deleter);
if (count == 0) {
color_out(COLOR_OUT_RED, "\tNo V4L2 output devices available!\n");
color_printf(TERM_FG_RED "\tNo V4L2 output devices available!\n" TERM_FG_RESET);
}
for (int i = 0; i < count; ++i) {
const char *dev_path = strchr(devices[i].dev, '=');
if (strchr(dev_path, '=') != 0) {
dev_path = strchr(dev_path, '=') + 1;
} // else bogus, ":device=" should be stripped
printf("\t%s: ", dev_path);
color_out(COLOR_OUT_BOLD, "%s\n", devices[i].name);
color_printf("\t%s: " TERM_BOLD "%s\n" TERM_RESET, dev_path, devices[i].name);
}
deleter(devices);
}

View File

@@ -68,7 +68,7 @@ struct vo_postprocess_state {
void show_vo_postprocess_help(bool full)
{
printf("Usage:\n");
color_out(COLOR_OUT_BOLD, "\t-p <postprocess_module>[:<args>] | help\n");
color_printf(TERM_BOLD "\t-p <postprocess_module>[:<args>] | help\n" TERM_RESET);
printf("\n");
printf("Possible postprocess modules:\n");
list_modules(LIBRARY_CLASS_VIDEO_POSTPROCESS, VO_PP_ABI_VERSION, full);