UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
macros.h File Reference
#include <cctype>
Include dependency graph for macros.h:

Go to the source code of this file.

Macros

#define __NL__
 
#define ARR_COUNT(arr)
 
#define CLAMP(x, low, high)
 
#define DIV_ROUNDED_UP(value, div)
 
#define EXTERN_C   extern "C"
 
#define IF_NOT_NULL_ELSE(val, default_val)
 
#define IF_NOT_UNDEF_ELSE(val, default_val)
 
#define IS_FCC(val)
 
#define IS_KEY_PREFIX(tok, key)
 expands to true value if <k> from tok in format <k>=<v> is prefix of key
 
#define IS_PREFIX(tok, key)
 similar as above, but also key without a value is accepted (value optional)
 
#define MAX(a, b)
 
#define MERGE(a, b)
 
#define MIN(a, b)
 
#define OPTIMIZED_FOR   for
 
#define snprintf_ch(str, ...)
 shortcut for snprintf(var, sizeof var...), var must be a char array
 
#define STARTS_WITH(str, token)
 
#define STRINGIFY(A)
 
#define SWAP(a, b)
 
#define SWAP_PTR(a, b)
 
#define to_fourcc(a, b, c, d)
 Creates FourCC word.
 
#define TOSTRING(A)
 
#define UG_ASSERT(cond)
 unconditional alternative to assert that is not affected by NDEBUG macro
 
#define UG_ASSERT_NO_FATAL(cond)
 
#define UNDEF   -1
 

Enumerations

enum  { MAX_CPU_CORES = 256 , SHORT_STR = 128 , STR_LEN = 2048 }
 the following limits are used mostly for static array allocations More...
 

Detailed Description

Author
Martin Pulec pulec.nosp@m.@ces.nosp@m.net.c.nosp@m.z

Definition in file macros.h.

Macro Definition Documentation

◆ __NL__

#define __NL__

Definition at line 121 of file macros.h.

◆ ARR_COUNT

#define ARR_COUNT ( arr)
Value:
(sizeof (arr) / sizeof (arr)[0])

Definition at line 60 of file macros.h.

Referenced by image_pattern_strips::fill().

◆ CLAMP

#define CLAMP ( x,
low,
high )
Value:
(((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))

Definition at line 67 of file macros.h.

Referenced by filter(), get_sine_signal(), vc_copylineRGBtoGrayscale_SSE(), vc_copylineUYVYtoRGBA(), vidcap_file_parse_fmt(), and yuv444p_to_rgb().

◆ DIV_ROUNDED_UP

#define DIV_ROUNDED_UP ( value,
div )
Value:
((((value) % (div)) != 0) ? ((value) / (div) + 1) : ((value) / (div)))

Definition at line 55 of file macros.h.

◆ EXTERN_C

#define EXTERN_C   extern "C"

Definition at line 71 of file macros.h.

◆ IF_NOT_NULL_ELSE

#define IF_NOT_NULL_ELSE ( val,
default_val )

◆ IF_NOT_UNDEF_ELSE

#define IF_NOT_UNDEF_ELSE ( val,
default_val )
Value:
((val) != UNDEF ? (val) : (default_val))
#define UNDEF
Definition macros.h:52

Definition at line 53 of file macros.h.

◆ IS_FCC

#define IS_FCC ( val)
Value:
(isprint((val) >> 24U & 0xFFU) && isprint((val) >> 16U & 0xFFU) && isprint((val) >> 8U & 0xFFU) && isprint((val) & 0xFFU))

Definition at line 116 of file macros.h.

Referenced by get_osstatus_str().

◆ IS_KEY_PREFIX

#define IS_KEY_PREFIX ( tok,
key )
Value:
(strchr((tok), '=') != 0 && \
strncmp(key, tok, strchr((tok), '=') - (tok)) == 0)
const char * key
Definition cineform.cpp:125

expands to true value if <k> from tok in format <k>=<v> is prefix of key

Definition at line 138 of file macros.h.

138#define IS_KEY_PREFIX(tok, key) \
139 (strchr((tok), '=') != 0 && \
140 strncmp(key, tok, strchr((tok), '=') - (tok)) == 0)

Referenced by delay_init(), display_decklink_init(), display_sdl2_init(), j2k_compress_init(), parse_audio_codec_params(), parse_audio_format(), image_pattern_strips::parse_fmt(), parse_fmt(), parse_fmt(), parse_fmt(), parse_fmt(), parse_fmt(), parse_fmt(), parse_option(), process_args(), settings_init(), vidcap_decklink_init(), vidcap_file_parse_fmt(), vidcap_screen_win_process_params(), vidcap_testcard2_init(), and vidcap_testcard_init().

◆ IS_PREFIX

#define IS_PREFIX ( tok,
key )
Value:
(IS_KEY_PREFIX(tok, key) || strncmp(tok, key, strlen(tok)) == 0)
#define IS_KEY_PREFIX(tok, key)
expands to true value if <k> from tok in format <k>=<v> is prefix of key
Definition macros.h:138

similar as above, but also key without a value is accepted (value optional)

Definition at line 142 of file macros.h.

142#define IS_PREFIX(tok, key) \
143 (IS_KEY_PREFIX(tok, key) || strncmp(tok, key, strlen(tok)) == 0)

Referenced by display_sdl2_init(), parse_fmt(), and settings_init().

◆ MAX

◆ MERGE

#define MERGE ( a,
b )
Value:
a##b

Definition at line 47 of file macros.h.

◆ MIN

◆ OPTIMIZED_FOR

#define OPTIMIZED_FOR   for

Definition at line 127 of file macros.h.

Referenced by ayuv64_to_uyvy(), ayuv64_to_v210(), ayuv64_to_y416(), convert_BGRA_RGBA(), convert_P216_Y216(), gbrap_to_rgb_rgba(), gbrp_to_rgb(), gbrp_to_rgba(), gbrpXXle_to_r10k(), gbrpXXle_to_r12l(), gbrpXXle_to_rg48(), gbrpXXle_to_rgb(), gbrpXXle_to_rgba(), i420_8_to_uyvy(), ndi_disp_convert_Y216_to_P216(), ndi_disp_convert_Y416_to_PA16(), nv12_to_rgb(), nv12_to_uyvy(), nv12_to_uyvy(), p010le_to_uyvy(), p010le_to_v210(), r10k_to_gbrpXXle(), r10k_to_yuv42Xp10le(), r10k_to_yuv444pXXle(), r12l_to_gbrpXXle(), r12l_to_yuv444pXXle(), rg48_to_gbrp12le(), rg48_to_yuv444pXXle(), rgb_rgba_to_gbrp(), rgb_to_yuv444p(), upload_texture(), uyvy_to_nv12(), uyvy_to_vuya(), uyvy_to_yuv420p(), uyvy_to_yuv422p(), uyvy_to_yuv444p(), v210_to_p010le(), v210_to_xv30(), v210_to_y210(), v210_to_yuv420p10le(), v210_to_yuv422p10le(), v210_to_yuv444p10le(), v210_to_yuv444p16le(), vc_copylineDVS10(), vc_copylineDVS10toV210(), vc_copyliner10ktoRGB(), vc_copyliner10ktoY416(), vc_copylineR12AtoR12L(), vc_copylineR12L(), vc_copylineR12LtoR10k(), vc_copylineR12LtoR12A(), vc_copylineR12LtoRG48(), vc_copylineR12LtoRGB(), vc_copylineR12LtoUYVY(), vc_copylineR12LtoY416(), vc_copylineRG48toR10k(), vc_copylineRG48toR12L(), vc_copylineRG48toRGB(), vc_copylineRG48toRGBA(), vc_copylineRG48toV210(), vc_copylineRG48toY216(), vc_copylineRG48toY416(), vc_copylineRGB(), vc_copylineRGB_AtoR12L(), vc_copylineRGBAtoRG48(), vc_copylineRGBAtoRGBwithShift(), vc_copylineRGBtoGrayscale_SSE(), vc_copylineRGBtoRG48(), vc_copylineRGBtoRGBA(), vc_copylineUYVYtoGrayscale(), vc_copylineUYVYtoRGBA(), vc_copylineV210toRG48(), vc_copylineV210toRGB(), vc_copylineV210toY216(), vc_copylineV210toY416(), vc_copylineY216toV210(), vc_copylineY416toR10k(), vc_copylineY416toR12L(), vc_copylineY416toRG48(), vc_copylineY416toRGB(), vc_copylineY416toRGBA(), vc_copylineY416toV210(), vc_copylineYUYV(), vuya_to_uyvy(), vuyax_to_y416(), y216_to_yuv422pXXle(), y216_to_yuv444p16le(), y416_to_xv30(), yuv420p10le_to_uyvy(), yuv420p10le_to_v210(), yuv420p_to_uyvy(), yuv420p_to_v210(), yuv422p10le_to_v210(), yuv422p_to_uyvy(), yuv422p_to_v210(), yuv444p10le_to_rgb(), yuv444p16le_to_uyvy(), yuv444p1Xle_to_uyvy(), yuv444p1Xle_to_v210(), yuv444p1Xle_to_y416(), yuv444p_to_rgb(), yuv444p_to_uyvy(), yuv444p_to_v210(), yuv444pXXle_to_r10k(), yuv444pXXle_to_r12l(), yuv444pXXle_to_rg48(), yuv8p_to_rgb(), and yuvp10le_to_rgb().

◆ snprintf_ch

#define snprintf_ch ( str,
... )
Value:
snprintf(str, sizeof str, __VA_ARGS__)

shortcut for snprintf(var, sizeof var...), var must be a char array

Definition at line 101 of file macros.h.

Referenced by audio_cap_wasapi_probe(), bug_msg(), configure_with(), openssl_decrypt_init(), openssl_encrypt_init(), image_pattern_strips::parse_fmt(), parse_options_internal(), and sdp_add_video().

◆ STARTS_WITH

#define STARTS_WITH ( str,
token )
Value:
!strncmp(str, token, strlen(token))

Definition at line 102 of file macros.h.

Referenced by get_video_desc_from_string().

◆ STRINGIFY

#define STRINGIFY ( A)
Value:
#A

Definition at line 48 of file macros.h.

◆ SWAP

#define SWAP ( a,
b )
Value:
do { b ^= a; a ^= b; b ^= a; } while (0)

Definition at line 57 of file macros.h.

Referenced by udp_init_if().

◆ SWAP_PTR

#define SWAP_PTR ( a,
b )
Value:
do { void *tmp = (a); (a) = (b); (b) = tmp; } while(0)

Definition at line 58 of file macros.h.

Referenced by decode_frame().

◆ to_fourcc

#define to_fourcc ( a,
b,
c,
d )
Value:
(((uint32_t)(a)) | ((uint32_t)(b)<<8U) | ((uint32_t)(c)<<16U) | ((uint32_t)(d)<<24U))

Creates FourCC word.

The main idea of FourCC is that it can be anytime read by human (by hexa editor, gdb, tcpdump). Therefore, this is stored as a big endian even on little-endian architectures - first byte of FourCC is in the memory on the lowest address.

Definition at line 114 of file macros.h.

Referenced by audio_tx_send_chan(), configure_with(), create_jpeg_frame(), decode_audio_frame(), decode_video_frame(), parse_quant_tables(), parse_video_hdr(), print_dropped(), probe_internal(), validate_std_audio(), and vidcap_ndi_grab().

◆ TOSTRING

#define TOSTRING ( A)
Value:
#define STRINGIFY(A)
Definition macros.h:48

Definition at line 49 of file macros.h.

Referenced by audio_cap_testcard_init(), display_dummy_init(), show_help(), and show_help().

◆ UG_ASSERT

#define UG_ASSERT ( cond)
Value:
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
if (!(cond)) { \
fprintf(stderr, \
"%s:%d: %s: Assertion `" #cond "' failed.\n", \
__FILE__, __LINE__, __func__); \
abort(); \
} \
} while (0)

unconditional alternative to assert that is not affected by NDEBUG macro

Definition at line 78 of file macros.h.

78#define UG_ASSERT(cond) \
79 do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
80 if (!(cond)) { \
81 fprintf(stderr, \
82 "%s:%d: %s: Assertion `" #cond "' failed.\n", \
83 __FILE__, __LINE__, __func__); \
84 abort(); \
85 } \
86 } while (0)

Referenced by audio_cap_sdl_mixer_init(), display_gl_get_property(), get_audio_conn_flag_name(), and fec::pt_from_fec_type().

◆ UG_ASSERT_NO_FATAL

#define UG_ASSERT_NO_FATAL ( cond)
Value:
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
if (!(cond)) { \
fprintf(stderr, \
"%s:%d: %s: Assertion `" #cond "' failed.\n", \
__FILE__, __LINE__, __func__); \
handle_error(EXIT_FAILURE); \
} \
} while (0)

soft version of UG_ASSERT_SOFT - only exit if user requested exit on failures

Definition at line 90 of file macros.h.

90#define UG_ASSERT_NO_FATAL(cond) \
91 do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
92 if (!(cond)) { \
93 fprintf(stderr, \
94 "%s:%d: %s: Assertion `" #cond "' failed.\n", \
95 __FILE__, __LINE__, __func__); \
96 handle_error(EXIT_FAILURE); \
97 } \
98 } while (0)

Referenced by show_help().

◆ UNDEF

#define UNDEF   -1

Definition at line 52 of file macros.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

the following limits are used mostly for static array allocations

Enumerator
MAX_CPU_CORES 

maximal expected CPU core count

SHORT_STR 
STR_LEN 

"standard" string length placeholder

Definition at line 131 of file macros.h.

131 {
132 MAX_CPU_CORES = 256,
133 SHORT_STR = 128,
134 STR_LEN = 2048,
135};
@ MAX_CPU_CORES
maximal expected CPU core count
Definition macros.h:132
@ SHORT_STR
Definition macros.h:133
@ STR_LEN
"standard" string length placeholder
Definition macros.h:134