Commit b009862b authored by Can Wu's avatar Can Wu Committed by Rafaël Carré

introduce VLC_CLIP() macro to replace use pair of __MAX() and __MIN()

Signed-off-by: default avatarRafaël Carré <funman@videolan.org>
parent 5b3e912d
......@@ -579,6 +579,9 @@ VLC_API void vlc_release(gc_object_t *);
# define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
#endif
/* clip v in [min, max] */
#define VLC_CLIP(v, min, max) __MIN(__MAX((v), (min)), (max))
VLC_USED
static inline int64_t GCD ( int64_t a, int64_t b )
{
......
......@@ -459,7 +459,7 @@ int OpenEncoder( vlc_object_t *p_this )
if( p_sys->i_key_int > 0 )
p_context->gop_size = p_sys->i_key_int;
p_context->max_b_frames =
__MAX( __MIN( p_sys->i_b_frames, FF_MAX_B_FRAMES ), 0 );
VLC_CLIP( p_sys->i_b_frames, 0, FF_MAX_B_FRAMES );
p_context->b_frame_strategy = 0;
if( !p_context->max_b_frames &&
( p_enc->fmt_out.i_codec == VLC_CODEC_MPGV ||
......
......@@ -244,8 +244,7 @@ static int Control(demux_t *demux, int query, va_list args)
if (sys->duration < 0 || sys->is_realtime)
return VLC_EGENERIC;
int64_t time = va_arg(args, int64_t);
date_Set(&sys->pts, __MIN(__MAX(time - sys->pts_origin, 0),
sys->duration));
date_Set(&sys->pts, VLC_CLIP(time - sys->pts_origin, 0, sys->duration));
return VLC_SUCCESS;
}
case DEMUX_SET_NEXT_DEMUX_TIME: {
......
......@@ -252,7 +252,7 @@ static void FindLength( demux_t *p_demux )
/* Check end */
i_size = stream_Size( p_demux->s );
i_end = __MAX( 0, __MIN( 200000, i_size ) );
i_end = VLC_CLIP( i_size, 0, 200000 );
stream_Seek( p_demux->s, i_size - i_end );
i = 0;
......
......@@ -52,7 +52,7 @@
static int vlclua_volume_set( lua_State *L )
{
playlist_t *p_this = vlclua_get_playlist_internal( L );
int i_volume = __MAX(__MIN(luaL_checkint( L, 1 ), AOUT_VOLUME_MAX), 0);
int i_volume = VLC_CLIP( luaL_checkint( L, 1 ), 0, AOUT_VOLUME_MAX );
int i_ret = aout_VolumeSet( p_this, i_volume );
return vlclua_push_ret( L, i_ret );
}
......
......@@ -1215,7 +1215,7 @@ static int UpdateVolume( vlc_object_t *p_this )
/* Our volume is 0..255, RAOP is -144..0 (-144 off, -30..0 on) */
/* Limit range */
p_sys->i_volume = __MAX( 0, __MIN( p_sys->i_volume, 255 ) );
p_sys->i_volume = VLC_CLIP( p_sys->i_volume, 0, 255 );
if ( p_sys->i_volume == 0 )
d_volume = -144.0;
......
......@@ -2516,30 +2516,30 @@ static int Create( vlc_object_t *p_this )
psz_fontfamily = var_InheritString( p_filter, "freetype-font" );
p_sys->i_default_font_size = var_InheritInteger( p_filter, "freetype-fontsize" );
p_sys->i_font_opacity = var_InheritInteger( p_filter,"freetype-opacity" );
p_sys->i_font_opacity = __MAX( __MIN( p_sys->i_font_opacity, 255 ), 0 );
p_sys->i_font_opacity = VLC_CLIP( p_sys->i_font_opacity, 0, 255 );
p_sys->i_font_color = var_InheritInteger( p_filter, "freetype-color" );
p_sys->i_font_color = __MAX( __MIN( p_sys->i_font_color , 0xFFFFFF ), 0 );
p_sys->i_font_color = VLC_CLIP( p_sys->i_font_color, 0, 0xFFFFFF );
p_sys->b_font_bold = var_InheritBool( p_filter, "freetype-bold" );
p_sys->i_background_opacity = var_InheritInteger( p_filter,"freetype-background-opacity" );;
p_sys->i_background_opacity = __MAX( __MIN( p_sys->i_background_opacity, 255 ), 0 );
p_sys->i_background_opacity = VLC_CLIP( p_sys->i_background_opacity, 0, 255 );
p_sys->i_background_color = var_InheritInteger( p_filter, "freetype-background-color" );
p_sys->i_background_color = __MAX( __MIN( p_sys->i_background_color, 0xFFFFFF ), 0 );
p_sys->i_background_color = VLC_CLIP( p_sys->i_background_color, 0, 0xFFFFFF );
p_sys->f_outline_thickness = var_InheritInteger( p_filter, "freetype-outline-thickness" ) / 100.0;
p_sys->f_outline_thickness = __MAX( __MIN( p_sys->f_outline_thickness, 0.5 ), 0.0 );
p_sys->f_outline_thickness = VLC_CLIP( p_sys->f_outline_thickness, 0.0, 0.5 );
p_sys->i_outline_opacity = var_InheritInteger( p_filter, "freetype-outline-opacity" );
p_sys->i_outline_opacity = __MAX( __MIN( p_sys->i_outline_opacity, 255 ), 0 );
p_sys->i_outline_opacity = VLC_CLIP( p_sys->i_outline_opacity, 0, 255 );
p_sys->i_outline_color = var_InheritInteger( p_filter, "freetype-outline-color" );
p_sys->i_outline_color = __MAX( __MIN( p_sys->i_outline_color, 0xFFFFFF ), 0 );
p_sys->i_outline_color = VLC_CLIP( p_sys->i_outline_color, 0, 0xFFFFFF );
p_sys->i_shadow_opacity = var_InheritInteger( p_filter, "freetype-shadow-opacity" );
p_sys->i_shadow_opacity = __MAX( __MIN( p_sys->i_shadow_opacity, 255 ), 0 );
p_sys->i_shadow_opacity = VLC_CLIP( p_sys->i_shadow_opacity, 0, 255 );
p_sys->i_shadow_color = var_InheritInteger( p_filter, "freetype-shadow-color" );
p_sys->i_shadow_color = __MAX( __MIN( p_sys->i_shadow_color, 0xFFFFFF ), 0 );
p_sys->i_shadow_color = VLC_CLIP( p_sys->i_shadow_color, 0, 0xFFFFFF );
float f_shadow_angle = var_InheritFloat( p_filter, "freetype-shadow-angle" );
float f_shadow_distance = var_InheritFloat( p_filter, "freetype-shadow-distance" );
f_shadow_distance = __MAX( __MIN( f_shadow_distance, 1 ), 0 );
f_shadow_distance = VLC_CLIP( f_shadow_distance, 0, 1 );
p_sys->f_shadow_vector_x = f_shadow_distance * cos(2 * M_PI * f_shadow_angle / 360);
p_sys->f_shadow_vector_y = f_shadow_distance * sin(2 * M_PI * f_shadow_angle / 360);
......
......@@ -197,7 +197,7 @@ static int Create( vlc_object_t *p_this )
return VLC_ENOMEM;
p_sys->psz_font_name = var_CreateGetString( p_this, "quartztext-font" );
p_sys->i_font_opacity = 255;
p_sys->i_font_color = __MAX( __MIN( var_CreateGetInteger( p_this, "quartztext-color" ) , 0xFFFFFF ), 0 );
p_sys->i_font_color = VLC_CLIP( var_CreateGetInteger( p_this, "quartztext-color" ) , 0, 0xFFFFFF );
p_sys->i_font_size = GetFontSize( p_filter );
p_filter->pf_render_text = RenderText;
......@@ -330,9 +330,9 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
if( p_region_in->p_style )
{
i_font_color = __MAX( __MIN( p_region_in->p_style->i_font_color, 0xFFFFFF ), 0 );
i_font_alpha = __MAX( __MIN( p_region_in->p_style->i_font_alpha, 255 ), 0 );
i_font_size = __MAX( __MIN( p_region_in->p_style->i_font_size, 255 ), 0 );
i_font_color = VLC_CLIP( p_region_in->p_style->i_font_color, 0, 0xFFFFFF );
i_font_alpha = VLC_CLIP( p_region_in->p_style->i_font_alpha, 0, 255 );
i_font_size = VLC_CLIP( p_region_in->p_style->i_font_size, 0, 255 );
if( p_region_in->p_style->i_style_flags )
{
if( p_region_in->p_style->i_style_flags & STYLE_BOLD )
......
......@@ -166,11 +166,11 @@ static int Create( vlc_object_t *p_this )
var_Create( p_filter, "win32text-opacity",
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_filter, "win32text-opacity", &val );
p_sys->i_font_opacity = __MAX( __MIN( val.i_int, 255 ), 0 );
p_sys->i_font_opacity = VLC_CLIP( val.i_int, 0, 255 );
var_Create( p_filter, "win32text-color",
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_filter, "win32text-color", &val );
p_sys->i_font_color = __MAX( __MIN( val.i_int, 0xFFFFFF ), 0 );
p_sys->i_font_color = VLC_CLIP( val.i_int, 0, 0xFFFFFF );
p_sys->hfont = p_sys->hfont_bak = 0;
hdc = GetDC( NULL );
......@@ -335,9 +335,9 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
if( p_region_in->p_style )
{
i_font_color = __MAX( __MIN( p_region_in->p_style->i_font_color, 0xFFFFFF ), 0 );
i_font_alpha = __MAX( __MIN( p_region_in->p_style->i_font_alpha, 255 ), 0 );
i_font_size = __MAX( __MIN( p_region_in->p_style->i_font_size, 255 ), 0 );
i_font_color = VLC_CLIP( p_region_in->p_style->i_font_color, 0, 0xFFFFFF );
i_font_alpha = VLC_CLIP( p_region_in->p_style->i_font_alpha, 0, 255 );
i_font_size = VLC_CLIP( p_region_in->p_style->i_font_size, 0, 255 );
}
else
{
......
......@@ -238,7 +238,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
p_sys->i_pos_y = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-y" );
p_BarGraph->i_alpha = var_CreateGetIntegerCommand( p_filter,
"audiobargraph_v-transparency" );
p_BarGraph->i_alpha = __MAX( __MIN( p_BarGraph->i_alpha, 255 ), 0 );
p_BarGraph->i_alpha = VLC_CLIP( p_BarGraph->i_alpha, 0, 255 );
i_values = var_CreateGetStringCommand( p_filter, "audiobargraph_v-i_values" );
//p_BarGraph->nbChannels = 0;
//p_BarGraph->i_values = NULL;
......@@ -479,7 +479,7 @@ static int BarGraphCallback( vlc_object_t *p_this, char const *psz_var,
}
else if ( !strcmp( psz_var, "audiobargraph_v-transparency" ) )
{
p_BarGraph->i_alpha = __MAX( __MIN( newval.i_int, 255 ), 0 );
p_BarGraph->i_alpha = VLC_CLIP( newval.i_int, 0, 255 );
}
else if ( !strcmp( psz_var, "audiobargraph_v-i_values" ) )
{
......@@ -939,7 +939,7 @@ void parse_i_values( BarGraph_t *p_BarGraph, char *i_values)
p_BarGraph->nbChannels++;
p_BarGraph->i_values = xrealloc(p_BarGraph->i_values,
p_BarGraph->nbChannels*sizeof(int));
p_BarGraph->i_values[p_BarGraph->nbChannels-1] = __MAX( __MIN( atof(res)*p_BarGraph->scale, p_BarGraph->scale ), 0 );
p_BarGraph->i_values[p_BarGraph->nbChannels-1] = VLC_CLIP( atof(res)*p_BarGraph->scale, 0, p_BarGraph->scale );
res = strtok_r(NULL, delim, &tok);
}
......
......@@ -133,7 +133,7 @@ static int Create( vlc_object_t *p_this )
vlc_mutex_init( &p_sys->lock );
#define GET_VAR( name, min, max ) \
val = var_CreateGetIntegerCommand( p_filter, CFG_PREFIX #name ); \
p_sys->i_##name = __MIN( max, __MAX( min, val ) ); \
p_sys->i_##name = VLC_CLIP( val, min, max ); \
var_AddCallback( p_filter, CFG_PREFIX #name, BluescreenCallback, p_sys );
GET_VAR( u, 0x00, 0xff );
......@@ -267,13 +267,13 @@ static int BluescreenCallback( vlc_object_t *p_this, char const *psz_var,
vlc_mutex_lock( &p_sys->lock );
#define VAR_IS( a ) !strcmp( psz_var, CFG_PREFIX a )
if( VAR_IS( "u" ) )
p_sys->i_u = __MAX( 0, __MIN( 255, newval.i_int ) );
p_sys->i_u = VLC_CLIP( newval.i_int, 0, 255 );
else if( VAR_IS( "v" ) )
p_sys->i_v = __MAX( 0, __MIN( 255, newval.i_int ) );
p_sys->i_v = VLC_CLIP( newval.i_int, 0, 255 );
else if( VAR_IS( "ut" ) )
p_sys->i_ut = __MAX( 0, __MIN( 255, newval.i_int ) );
p_sys->i_ut = VLC_CLIP( newval.i_int, 0, 255 );
else if( VAR_IS( "vt" ) )
p_sys->i_vt = __MAX( 0, __MIN( 255, newval.i_int ) );
p_sys->i_vt = VLC_CLIP( newval.i_int, 0, 255 );
vlc_mutex_unlock( &p_sys->lock );
return VLC_SUCCESS;
......
......@@ -177,8 +177,8 @@ static picture_t *Filter(filter_t *filter, picture_t *src)
}
vlc_mutex_lock(&sys->lock);
float strength = __MIN(__MAX(sys->strength, STRENGTH_MIN), STRENGTH_MAX);
int radius = __MIN(__MAX((sys->radius + 1) & ~1, RADIUS_MIN), RADIUS_MAX);
float strength = VLC_CLIP(sys->strength, STRENGTH_MIN, STRENGTH_MAX);
int radius = VLC_CLIP((sys->radius + 1) & ~1, RADIUS_MIN, RADIUS_MAX);
vlc_mutex_unlock(&sys->lock);
const video_format_t *fmt = &filter->fmt_in.video;
......@@ -200,7 +200,7 @@ static picture_t *Filter(filter_t *filter, picture_t *src)
int h = fmt->i_height * chroma->p[i].h.num / chroma->p[i].h.den;
int r = (cfg->radius * chroma->p[i].w.num / chroma->p[i].w.den +
cfg->radius * chroma->p[i].h.num / chroma->p[i].h.den) / 2;
r = __MIN(__MAX((r + 1) & ~1, RADIUS_MIN), RADIUS_MAX);
r = VLC_CLIP((r + 1) & ~1, RADIUS_MIN, RADIUS_MAX);
if (__MIN(w, h) > 2 * r && cfg->buf) {
filter_plane(cfg, dstp->p_pixels, srcp->p_pixels,
w, h, dstp->i_pitch, srcp->i_pitch, r);
......
......@@ -258,7 +258,7 @@ static picture_t *Filter(filter_t *filter, picture_t *src)
}
vlc_mutex_lock(&sys->cfg.lock);
const double variance = __MIN(__MAX(sys->cfg.variance, VARIANCE_MIN), VARIANCE_MAX);
const double variance = VLC_CLIP(sys->cfg.variance, VARIANCE_MIN, VARIANCE_MAX);
vlc_mutex_unlock(&sys->cfg.lock);
const int scale = 256 * sqrt(variance);
......@@ -352,7 +352,7 @@ static int Generate(int16_t *bank, int h_min, int h_max, int v_min, int v_max)
vq = (int)( v * correction * 127 + 0.5);
else
vq = -(int)(-v * correction * 127 + 0.5);
bank[i * N + j] = __MIN(__MAX(vq, INT16_MIN), INT16_MAX);
bank[i * N + j] = VLC_CLIP(vq, INT16_MIN, INT16_MAX);
}
}
//mtime_t mul_duration = mdate() - tmul_0;
......@@ -397,8 +397,8 @@ static int Open(vlc_object_t *object)
int cutoff_low = BANK_SIZE - var_InheritInteger(filter, CFG_PREFIX "period-max");
int cutoff_high= BANK_SIZE - var_InheritInteger(filter, CFG_PREFIX "period-min");
cutoff_low = __MIN(__MAX(cutoff_low, 1), BANK_SIZE - 1);
cutoff_high = __MIN(__MAX(cutoff_high, 1), BANK_SIZE - 1);
cutoff_low = VLC_CLIP(cutoff_low, 1, BANK_SIZE - 1);
cutoff_high = VLC_CLIP(cutoff_high, 1, BANK_SIZE - 1);
if (Generate(sys->bank, cutoff_low, cutoff_high, cutoff_low, cutoff_high)) {
free(sys);
return VLC_EGENERIC;
......
......@@ -269,7 +269,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
msg_Warn( p_this, "no logo file specified" );
p_list->i_alpha = var_CreateGetIntegerCommand( p_filter, "logo-opacity");
p_list->i_alpha = __MAX( __MIN( p_list->i_alpha, 255 ), 0 );
p_list->i_alpha = VLC_CLIP( p_list->i_alpha, 0, 255 );
p_list->i_delay = var_CreateGetIntegerCommand( p_filter, "logo-delay" );
p_list->i_repeat = var_CreateGetIntegerCommand( p_filter, "logo-repeat" );
......@@ -529,9 +529,9 @@ static int Mouse( filter_t *p_filter, vlc_mouse_t *p_mouse,
{
int i_dx, i_dy;
vlc_mouse_GetMotion( &i_dx, &i_dy, p_old, p_new );
p_sys->i_pos_x = __MIN( __MAX( p_sys->i_pos_x + i_dx, 0 ),
p_sys->i_pos_x = VLC_CLIP( p_sys->i_pos_x + i_dx, 0,
p_filter->fmt_in.video.i_width - i_logo_w );
p_sys->i_pos_y = __MIN( __MAX( p_sys->i_pos_y + i_dy, 0 ),
p_sys->i_pos_y = VLC_CLIP( p_sys->i_pos_y + i_dy, 0,
p_filter->fmt_in.video.i_height - i_logo_h );
/* object under mouse has moved */
......@@ -585,7 +585,7 @@ static int LogoCallback( vlc_object_t *p_this, char const *psz_var,
}
else if ( !strcmp( psz_var, "logo-opacity" ) )
{
p_list->i_alpha = __MAX( __MIN( newval.i_int, 255 ), 0 );
p_list->i_alpha = VLC_CLIP( newval.i_int, 0, 255 );
}
else if ( !strcmp( psz_var, "logo-repeat" ) )
{
......
......@@ -356,9 +356,9 @@ static int Mouse( filter_t *p_filter, vlc_mouse_t *p_mouse, const vlc_mouse_t *p
const int v_w = p_fmt->i_width * ZOOM_FACTOR / p_sys->i_zoom;
const int v_h = p_fmt->i_height * ZOOM_FACTOR / p_sys->i_zoom;
p_sys->i_x = __MIN( __MAX( p_new->i_x * VIS_ZOOM - v_w/2, 0 ),
p_sys->i_x = VLC_CLIP( p_new->i_x * VIS_ZOOM - v_w/2, 0,
(int)p_fmt->i_width - v_w - 1);
p_sys->i_y = __MIN( __MAX( p_new->i_y * VIS_ZOOM - v_h/2, 0 ),
p_sys->i_y = VLC_CLIP( p_new->i_y * VIS_ZOOM - v_h/2, 0,
(int)p_fmt->i_height - v_h - 1);
b_grab = true;
......@@ -390,8 +390,8 @@ static int Mouse( filter_t *p_filter, vlc_mouse_t *p_mouse, const vlc_mouse_t *p
const int v_w = p_fmt->i_width * ZOOM_FACTOR / p_sys->i_zoom;
const int v_h = p_fmt->i_height * ZOOM_FACTOR / p_sys->i_zoom;
p_sys->i_x = __MAX( __MIN( p_sys->i_x, (int)p_fmt->i_width - v_w - 1 ), 0 );
p_sys->i_y = __MAX( __MIN( p_sys->i_y, (int)p_fmt->i_height - v_h - 1 ), 0 );
p_sys->i_x = VLC_CLIP( p_sys->i_x, 0, (int)p_fmt->i_width - v_w - 1 );
p_sys->i_y = VLC_CLIP( p_sys->i_y, 0, (int)p_fmt->i_height - v_h - 1 );
b_grab = true;
}
......
......@@ -299,7 +299,7 @@ static int CreateFilter( vlc_object_t *p_this )
#define GET_VAR( name, min, max ) \
i_command = var_CreateGetIntegerCommand( p_filter, CFG_PREFIX #name ); \
p_sys->i_##name = __MIN( max, __MAX( min, i_command ) ); \
p_sys->i_##name = VLC_CLIP( i_command, min, max ); \
var_AddCallback( p_filter, CFG_PREFIX #name, MosaicCallback, p_sys );
GET_VAR( width, 0, INT_MAX );
......@@ -738,7 +738,7 @@ static int MosaicCallback( vlc_object_t *p_this, char const *psz_var,
vlc_mutex_lock( &p_sys->lock );
msg_Dbg( p_this, "changing alpha from %d/255 to %d/255",
p_sys->i_alpha, (int)newval.i_int);
p_sys->i_alpha = __MIN( __MAX( newval.i_int, 0 ), 255 );
p_sys->i_alpha = VLC_CLIP( newval.i_int, 0, 255 );
vlc_mutex_unlock( &p_sys->lock );
}
else if( VAR_IS( "height" ) )
......@@ -777,7 +777,7 @@ static int MosaicCallback( vlc_object_t *p_this, char const *psz_var,
{
int i_old = 0, i_new = 0;
vlc_mutex_lock( &p_sys->lock );
newval.i_int = __MIN( __MAX( newval.i_int, 0 ), 10 );
newval.i_int = VLC_CLIP( newval.i_int, 0, 10 );
if( newval.i_int == 3 || newval.i_int == 7 )
newval.i_int = 5;
while( pi_align_values[i_old] != p_sys->i_align ) i_old++;
......
......@@ -215,7 +215,7 @@ static int MotionBlurCallback( vlc_object_t *p_this, char const *psz_var,
if( !strcmp( psz_var, FILTER_PREFIX "factor" ) )
{
vlc_spin_lock( &p_sys->lock );
p_sys->i_factor = __MIN( 127, __MAX( 1, newval.i_int ) );
p_sys->i_factor = VLC_CLIP( newval.i_int, 1, 127 );
vlc_spin_unlock( &p_sys->lock );
}
return VLC_SUCCESS;
......
......@@ -499,8 +499,8 @@ static int Open( vlc_object_t *p_this )
p_sys->a_0 = p_sys->bz_begin;
/* */
p_sys->i_col = __MAX( 1, __MIN( COL_MAX, p_sys->i_col ) );
p_sys->i_row = __MAX( 1, __MIN( ROW_MAX, p_sys->i_row ) );
p_sys->i_col = VLC_CLIP( COL_MAX, 1, p_sys->i_col );
p_sys->i_row = VLC_CLIP( ROW_MAX, 1, p_sys->i_row );
msg_Dbg( p_splitter, "opening a %i x %i wall",
p_sys->i_col, p_sys->i_row );
......
......@@ -236,7 +236,7 @@ static int SharpenCallback( vlc_object_t *p_this, char const *psz_var,
filter_sys_t *p_sys = (filter_sys_t *)p_data;
vlc_mutex_lock( &p_sys->lock );
init_precalc_table(p_sys, __MIN( 2., __MAX( 0., newval.f_float ) ));
init_precalc_table( p_sys, VLC_CLIP( newval.f_float, 0., 2. ) );
vlc_mutex_unlock( &p_sys->lock );
return VLC_SUCCESS;
}
......@@ -129,10 +129,10 @@ static int Open( vlc_object_t *p_this )
/* */
p_sys->i_col = var_CreateGetInteger( p_splitter, CFG_PREFIX "cols" );
p_sys->i_col = __MAX( 1, __MIN( COL_MAX, p_sys->i_col ) );
p_sys->i_col = VLC_CLIP( COL_MAX, 1, p_sys->i_col );
p_sys->i_row = var_CreateGetInteger( p_splitter, CFG_PREFIX "rows" );
p_sys->i_row = __MAX( 1, __MIN( ROW_MAX, p_sys->i_row ) );
p_sys->i_row = VLC_CLIP( ROW_MAX, 1, p_sys->i_row );
msg_Dbg( p_splitter, "opening a %i x %i wall",
p_sys->i_col, p_sys->i_row );
......
......@@ -738,7 +738,7 @@ static int AStreamReadBlock( stream_t *s, void *p_read, unsigned int i_read )
{
int i_current =
p_sys->block.p_current->i_buffer - p_sys->block.i_offset;
unsigned int i_copy = __MIN( (unsigned int)__MAX(i_current,0), i_read - i_data);
unsigned int i_copy = VLC_CLIP( (unsigned int)i_current, 0, i_read - i_data);
/* Copy data */
if( p_data )
......@@ -1312,9 +1312,9 @@ static int AStreamReadNoSeekStream( stream_t *s, void *p_read, unsigned int i_re
if( tk->i_end + i_data <= tk->i_start + p_sys->stream.i_offset + i_read )
{
const unsigned i_read_requested = __MAX( __MIN( i_read - i_data,
STREAM_READ_ATONCE * 10 ),
STREAM_READ_ATONCE / 2 );
const unsigned i_read_requested = VLC_CLIP( i_read - i_data,
STREAM_READ_ATONCE / 2,
STREAM_READ_ATONCE * 10 );
if( p_sys->stream.i_used < i_read_requested )
p_sys->stream.i_used = i_read_requested;
......
......@@ -992,28 +992,26 @@ void vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
}
const int right_max = osys->source.i_x_offset + osys->source.i_visible_width;
const int bottom_max = osys->source.i_y_offset + osys->source.i_visible_height;
#define __CLIP(v, a, b) __MAX(__MIN(v, b), a)
int left = __CLIP((int)osys->source.i_x_offset + osys->crop.left,
int left = VLC_CLIP((int)osys->source.i_x_offset + osys->crop.left,
0, right_max - 1);
int top = __CLIP((int)osys->source.i_y_offset + osys->crop.top,
int top = VLC_CLIP((int)osys->source.i_y_offset + osys->crop.top,
0, bottom_max - 1);
int right, bottom;
if (osys->crop.right <= 0)
right = (int)(osys->source.i_x_offset + osys->source.i_visible_width) + osys->crop.right;
else
right = (int)osys->source.i_x_offset + osys->crop.right;
right = __CLIP(right, left + 1, right_max);
right = VLC_CLIP(right, left + 1, right_max);
if (osys->crop.bottom <= 0)
bottom = (int)(osys->source.i_y_offset + osys->source.i_visible_height) + osys->crop.bottom;
else
bottom = (int)osys->source.i_y_offset + osys->crop.bottom;
bottom = __CLIP(bottom, top + 1, bottom_max);
bottom = VLC_CLIP(bottom, top + 1, bottom_max);
source.i_x_offset = left;
source.i_y_offset = top;
source.i_visible_width = right - left;
source.i_visible_height = bottom - top;
#undef __CLIP
video_format_Print(VLC_OBJECT(vd), "SOURCE ", &osys->source);
video_format_Print(VLC_OBJECT(vd), "CROPPED", &source);
if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_CROP, &source)) {
......
......@@ -175,7 +175,7 @@ void vout_InitInterlacingSupport(vout_thread_t *vout, bool is_interlaced)
/* */
var_Create(vout, "deinterlace", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT | VLC_VAR_HASCHOICE);
int deinterlace_state = var_GetInteger(vout, "deinterlace");
deinterlace_state = __MAX(__MIN(deinterlace_state, 1), -1);
deinterlace_state = VLC_CLIP(deinterlace_state, -1, 1);
text.psz_string = _("Deinterlace");
var_Change(vout, "deinterlace", VLC_VAR_SETTEXT, &text, NULL);
......
......@@ -71,7 +71,7 @@ static subpicture_region_t * vout_OSDEpgSlider(int x, int y,
picture_t *picture = region->p_picture;
ratio = __MIN(__MAX(ratio, 0), 1);
ratio = VLC_CLIP(ratio, 0, 1);
int filled_part_width = ratio * width;
for (int j = 0; j < height; j++) {
......
......@@ -293,7 +293,7 @@ static void OSDWidget(vout_thread_t *vout, int channel, int type, int position)
if (!var_InheritBool(vout, "osd"))
return;
if (type == OSD_HOR_SLIDER || type == OSD_VERT_SLIDER)
position = __MIN(__MAX(position, 0), 100);
position = VLC_CLIP(position, 0, 100);
subpicture_updater_sys_t *sys = malloc(sizeof(*sys));
if (!sys)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment