From 2e424d50ca819087686617aafaa2b008b3fa29f7 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 2 Aug 2022 13:01:03 +0200 Subject: [PATCH] replaced instances of color_out with color_printf + reindent vidcap/file help ("where" keyword) --- src/alsa_common.h | 2 +- src/audio/capture/alsa.c | 14 ++++----- src/audio/capture/portaudio.c | 6 ++-- src/audio/playback/alsa.c | 17 ++++++----- src/audio/playback/portaudio.cpp | 3 +- src/capture_filter.cpp | 3 +- src/capture_filter/change_pixfmt.c | 2 +- src/capture_filter/disrupt.c | 2 +- src/capture_filter/matrix.c | 2 +- src/capture_filter/none.c | 3 +- src/capture_filter/split.c | 2 +- src/export.c | 2 +- src/ndi_common.h | 6 ++-- src/playback.c | 12 +++----- src/utils/color_out.h | 11 ++++--- src/utils/nat.c | 11 +++---- src/video_capture/DirectShowGrabber.cpp | 3 +- src/video_capture/file.c | 38 +++++++++++-------------- src/video_capture/screen_win.c | 3 +- src/video_capture/v4l2.c | 26 +++++++---------- src/video_capture/ximea.c | 11 ++++--- src/video_display.c | 7 +++-- src/video_display/ndi.c | 9 ++---- src/video_display/v4l2.c | 8 ++---- src/vo_postprocess.c | 2 +- 25 files changed, 89 insertions(+), 116 deletions(-) diff --git a/src/alsa_common.h b/src/alsa_common.h index 71add3908..efadee12e 100644 --- a/src/alsa_common.h +++ b/src/alsa_common.h @@ -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); } diff --git a/src/audio/capture/alsa.c b/src/audio/capture/alsa.c index de478ea7c..54a0806fc 100644 --- a/src/audio/capture/alsa.c +++ b/src/audio/capture/alsa.c @@ -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:\n"); - color_out(COLOR_OUT_BOLD, "\t-s alsa::opts=\n"); - color_out(COLOR_OUT_BOLD, "\t-s alsa:opts=\n\n"); - color_out(COLOR_OUT_BOLD, "\t"); - printf(" can be in format key1=value1:key2=value2, options are:\n"); - color_out(COLOR_OUT_BOLD, "\t\tframes="); - 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:\n" TERM_RESET); + color_printf(TERM_BOLD "\t-s alsa::opts=\n" TERM_RESET); + color_printf(TERM_BOLD "\t-s alsa:opts=\n\n" TERM_RESET); + color_printf(TERM_BOLD "\t" TERM_RESET " can be in format key1=value1:key2=value2, options are:\n"); + color_printf(TERM_BOLD "\t\tframes=" TERM_RESET " number of audio frames captured at a moment\n"); printf("\nAvailable ALSA capture devices\n"); audio_cap_alsa_help(NULL); diff --git a/src/audio/capture/portaudio.c b/src/audio/capture/portaudio.c index d282cb834..cf7c5a1a0 100644 --- a/src/audio/capture/portaudio.c +++ b/src/audio/capture/portaudio.c @@ -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, "[:[:latency=]]\n\n"); - color_out(COLOR_OUT_BOLD, "\t"); - 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 "[:[:latency=]]\n\n" TERM_RESET); + color_printf(TERM_BOLD "\t" TERM_RESET "\tsuggested latency in sec (experimental, use in case of problems)\n"); printf("\nAvailable PortAudio capture devices:\n"); audio_cap_portaudio_help(NULL); diff --git a/src/audio/playback/alsa.c b/src/audio/playback/alsa.c index b42649934..1b00efae4 100644 --- a/src/audio/playback/alsa.c +++ b/src/audio/playback/alsa.c @@ -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, "[:] --param alsa-playback-api={thread|async|sync}[,alsa-playback-buffer=[-]][,audio-buffer-len=]\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=[-]\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=\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 "[:] --param alsa-playback-api={thread|async|sync}[,alsa-playback-buffer=[-]][,audio-buffer-len=]\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=[-]\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=\n" TERM_RESET); + color_printf("\t\tlength of UG internal ALSA buffer (in milliseconds)\n"); printf("\n"); printf("Available ALSA playback devices:\n"); diff --git a/src/audio/playback/portaudio.cpp b/src/audio/playback/portaudio.cpp index ba9e4a743..81a9d11bb 100644 --- a/src/audio/playback/portaudio.cpp +++ b/src/audio/playback/portaudio.cpp @@ -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, "[:]\n\n"); + color_printf(TERM_BOLD TERM_FG_RED "\t-r poraudio" TERM_FG_RESET "[:]\n\n" TERM_RESET); printf("Available PortAudio playback devices:\n"); audio_play_portaudio_help(NULL); return &audio_init_state_ok; diff --git a/src/capture_filter.cpp b/src/capture_filter.cpp index 200635ab8..6002a7a5a 100644 --- a/src/capture_filter.cpp +++ b/src/capture_filter.cpp @@ -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 [:opts][,[:opts][,[:]]]"); - printf(" -t \n\n"); + color_printf(TERM_BOLD "\t--capture-filter [:opts][,[:opts][,[:]]]" TERM_RESET " -t \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) { diff --git a/src/capture_filter/change_pixfmt.c b/src/capture_filter/change_pixfmt.c index f07f9e2f1..f28eb2ae3 100644 --- a/src/capture_filter/change_pixfmt.c +++ b/src/capture_filter/change_pixfmt.c @@ -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:\n"); + color_printf(TERM_FG_RED "\t--capture-filter change_pixfmt:\n" TERM_FG_RESET); return 1; } diff --git a/src/capture_filter/disrupt.c b/src/capture_filter/disrupt.c index 91876708e..df2546b4b 100644 --- a/src/capture_filter/disrupt.c +++ b/src/capture_filter/disrupt.c @@ -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; } diff --git a/src/capture_filter/matrix.c b/src/capture_filter/matrix.c index ba95d5bdb..e229a7509 100644 --- a/src/capture_filter/matrix.c +++ b/src/capture_filter/matrix.c @@ -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"); diff --git a/src/capture_filter/none.c b/src/capture_filter/none.c index 412484950..3adf0c1ac 100644 --- a/src/capture_filter/none.c +++ b/src/capture_filter/none.c @@ -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; } diff --git a/src/capture_filter/split.c b/src/capture_filter/split.c index a94675aac..b9c77661f 100644 --- a/src/capture_filter/split.c +++ b/src/capture_filter/split.c @@ -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) diff --git a/src/export.c b/src/export.c index b7d9d2d81..f9b1d1a82 100644 --- a/src/export.c +++ b/src/export.c @@ -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; diff --git a/src/ndi_common.h b/src/ndi_common.h index ba5f22196..8ef8b7cda 100644 --- a/src/ndi_common.h +++ b/src/ndi_common.h @@ -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 diff --git a/src/playback.c b/src/playback.c index 79033a4eb..4f34af898 100644 --- a/src/playback.c +++ b/src/playback.c @@ -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 [||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 [||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) { diff --git a/src/utils/color_out.h b/src/utils/color_out.h index 3ee04487f..e24d1f375 100644 --- a/src/utils/color_out.h +++ b/src/utils/color_out.h @@ -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" { diff --git a/src/utils/nat.c b/src/utils/nat.c index 86b40c474..db10436f6 100644 --- a/src/utils/nat.c +++ b/src/utils/nat.c @@ -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; } diff --git a/src/video_capture/DirectShowGrabber.cpp b/src/video_capture/DirectShowGrabber.cpp index 7192a5bd9..48ace026c 100644 --- a/src/video_capture/DirectShowGrabber.cpp +++ b/src/video_capture/DirectShowGrabber.cpp @@ -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); diff --git a/src/video_capture/file.c b/src/video_capture/file.c index cab9e4622..8a933ec1e 100644 --- a/src/video_capture/file.c +++ b/src/video_capture/file.c @@ -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:"); - color_out(COLOR_OUT_BOLD, "[:loop][:nodecode][:codec=]"); + color_printf("Usage:\n"); + color_printf(TERM_BOLD TERM_FG_RED "\t-t file:" TERM_FG_RESET "[:loop][:nodecode][:codec=]%s\n" TERM_RESET, + full ? "[:opportunistic_audio][:queue=][:threads=[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=][:threads=[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"); } } diff --git a/src/video_capture/screen_win.c b/src/video_capture/screen_win.c index cba716eba..8f818fcae 100644 --- a/src/video_capture/screen_win.c +++ b/src/video_capture/screen_win.c @@ -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=][:height=][:fps=]\n"); + color_printf(TERM_BOLD TERM_FG_RED "\t-t screen" TERM_FG_RESET "[:width=][:height=][:fps=]\n" TERM_RESET); } static struct vidcap_type * vidcap_screen_win_probe(bool verbose, void (**deleter)(void *)) diff --git a/src/video_capture/v4l2.c b/src/video_capture/v4l2.c index e290056e6..ba37909ce 100644 --- a/src/video_capture/v4l2.c +++ b/src/video_capture/v4l2.c @@ -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=]"); - color_out(COLOR_OUT_BOLD, "[:codec=][:size=x][:tpf=|:fps=][:buffers=][:convert=][:permissive] | -t v4l2:[short]help\n"); + color_printf(TERM_BOLD TERM_FG_RED "\t-t v4l2[:device=]" TERM_FG_RESET + "[:codec=][:size=x][:tpf=|:fps=][:buffers=][:convert=][:permissive] | -t v4l2:[short]help\n" TERM_RESET); printf("where\n"); - color_out(COLOR_OUT_BOLD, " -"); printf("\tuse device to grab from (default: first usable)\n"); - color_out(COLOR_OUT_BOLD, "\t"); printf(" - time per frame in format /\n"); - color_out(COLOR_OUT_BOLD, "\t"); printf(" - number of capture buffers to be used (default: %d)\n", DEFAULT_BUF_COUNT); - color_out(COLOR_OUT_BOLD, "\t"); printf(" or "); color_out(COLOR_OUT_BOLD, ""); printf(" should be given as a single integer or a fraction\n"); - color_out(COLOR_OUT_BOLD, "\t"); printf(" - SW conversion, eg. to RGB (useful eg. to convert captured MJPG from USB 2.0 webcam to uncompressed),\n" + color_printf(TERM_BOLD " -" TERM_RESET "\tuse device to grab from (default: first usable)\n"); + color_printf(TERM_BOLD "\t" TERM_RESET " - time per frame in format /\n"); + color_printf(TERM_BOLD "\t" TERM_RESET " - number of capture buffers to be used (default: %d)\n", DEFAULT_BUF_COUNT); + color_printf(TERM_BOLD "\t" TERM_RESET " or " TERM_BOLD "" TERM_RESET " should be given as a single integer or a fraction\n"); + color_printf(TERM_BOLD "\t" 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)); diff --git a/src/video_capture/ximea.c b/src/video_capture/ximea.c index 8dccab333..2ca37413f 100644 --- a/src/video_capture/ximea.c +++ b/src/video_capture/ximea.c @@ -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=][:exposure=]\n"); + color_printf("XIMEA usage:\n"); + color_printf(TERM_BOLD TERM_FG_RED, "\t-t ximea" TERM_FG_RESET "[:device=][:exposure=]\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); } diff --git a/src/video_display.c b/src/video_display.c index 883bef81f..98dd08c34 100644 --- a/src/video_display.c +++ b/src/video_display.c @@ -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; diff --git a/src/video_display/ndi.c b/src/video_display/ndi.c index be564a9e7..29accf3a7 100644 --- a/src/video_display/ndi.c +++ b/src/video_display/ndi.c @@ -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=][:audio_level=]\n"); + color_printf(TERM_BOLD TERM_FG_RED "\t-d ndi" TERM_FG_RESET "[:help][:name=][:audio_level=]\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); } /** diff --git a/src/video_display/v4l2.c b/src/video_display/v4l2.c index bbddff455..e15715ef5 100644 --- a/src/video_display/v4l2.c +++ b/src/video_display/v4l2.c @@ -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=] | -d v4l2:help\n"); + color_printf(TERM_BOLD TERM_FG_RED "\t-d v4l2" TERM_FG_RESET "[:device=] | -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); } diff --git a/src/vo_postprocess.c b/src/vo_postprocess.c index 5f0ab096d..6a4b80d74 100644 --- a/src/vo_postprocess.c +++ b/src/vo_postprocess.c @@ -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 [:] | help\n"); + color_printf(TERM_BOLD "\t-p [:] | help\n" TERM_RESET); printf("\n"); printf("Possible postprocess modules:\n"); list_modules(LIBRARY_CLASS_VIDEO_POSTPROCESS, VO_PP_ABI_VERSION, full);