本文整理匯總了C++中int_max函數的典型用法代碼示例。如果您正苦於以下問題:C++ int_max函數的具體用法?C++ int_max怎麽用?C++ int_max使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了int_max函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: opj_image_comp_header_update
/**
* Updates the components characteristics of the image from the coding parameters.
*
* @param p_image_header the image header to update.
* @param p_cp the coding parameters from which to update the image.
*/
void opj_image_comp_header_update(opj_image_t * p_image_header, const struct opj_cp_v2 * p_cp)
{
OPJ_UINT32 i, l_width, l_height;
OPJ_INT32 l_x0, l_y0, l_x1, l_y1;
OPJ_INT32 l_comp_x0, l_comp_y0, l_comp_x1, l_comp_y1;
opj_image_comp_t* l_img_comp = NULL;
l_x0 = int_max(p_cp->tx0 , p_image_header->x0);
l_y0 = int_max(p_cp->ty0 , p_image_header->y0);
l_x1 = int_min(p_cp->tx0 + p_cp->tw * p_cp->tdx, p_image_header->x1);
l_y1 = int_min(p_cp->ty0 + p_cp->th * p_cp->tdy, p_image_header->y1);
l_img_comp = p_image_header->comps;
for (i = 0; i < p_image_header->numcomps; ++i) {
l_comp_x0 = int_ceildiv(l_x0, l_img_comp->dx);
l_comp_y0 = int_ceildiv(l_y0, l_img_comp->dy);
l_comp_x1 = int_ceildiv(l_x1, l_img_comp->dx);
l_comp_y1 = int_ceildiv(l_y1, l_img_comp->dy);
l_width = int_ceildivpow2(l_comp_x1 - l_comp_x0, l_img_comp->factor);
l_height = int_ceildivpow2(l_comp_y1 - l_comp_y0, l_img_comp->factor);
l_img_comp->w = l_width;
l_img_comp->h = l_height;
l_img_comp->x0 = l_comp_x0/*l_x0*/;
l_img_comp->y0 = l_comp_y0/*l_y0*/;
++l_img_comp;
}
}
示例2: pow
void j2kTierOne::tierOneInitContext()
{
//初始化ZC上下文,有9個
for(int bandno=0; bandno<4; bandno++)
{
for(int ctx=0; ctx<256; ++ctx)
{
zcContextNo[(bandno<<8)|ctx]=initCtxZC(ctx,bandno);
}
}
//初始化SC上下文,有5個
for(int ctx=0; ctx<256; ctx++)
{
scContextNo[ctx]=initCtxSC(ctx<<4);//左移為移出低位4位
}
//初始化MR中的上下文,有3個
for(int i=0; i<2; i++)
{
for(int ctx=0; ctx<2048; ++ctx)
{
int j=(i<<11)+ctx;//(1<<11)為作標記準備
if(i)
maContextNo[ctx+(i<<11)]=initCtxMAG(T1_REFINE|ctx);//添加 refine標記
else
maContextNo[ctx+(i<<11)]=initCtxMAG(ctx);
}
}
for(int ctx=0; ctx<256; ++ctx)
spbNo[ctx]=initSPB(ctx<<4);//騰出低4位
double t,u,v;
for(int i=0; i<(1<<T1_NMSEDEC_BITS); i++)
{
t=i/pow(2.0,T1_NMSEDEC_FRACBITS);
u=t;
v=t-1.5;
double sig=(floor((u * u - v * v) * pow(2.0, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2.0, T1_NMSEDEC_FRACBITS) * 8192.0);
nmSeDecSig[i]=int_max(0,(int)sig );
sig=(floor((u * u) * pow(2.0, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2.0, T1_NMSEDEC_FRACBITS) * 8192.0);
nmSeDecSig0[i]=int_max(0, (int)sig );
u=t-1.0;
if(i&(1<<T1_NMSEDEC_BITS-1))
{
v=t-1.5;
} else
{
v=t-0.5;
}
nmSeDecRef[i]=int_max(0, (int) (floor((u * u - v * v) * pow(2.0, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2.0, T1_NMSEDEC_FRACBITS) * 8192.0));
nmSeDecRef0[i]=int_max(0,(int) (floor((u * u) * pow(2.0, T1_NMSEDEC_FRACBITS) +0.5) / pow(2.0, T1_NMSEDEC_FRACBITS) * 8192.0));
}
}
示例3: debug_cookie_parser
static inline void
debug_cookie_parser(struct cookie_str *cstr, unsigned char *pos, int ws, int eq)
{
int namelen = int_max(cstr->nam_end - cstr->str, 0);
int valuelen = int_max(cstr->val_end - cstr->val_start, 0);
printf("[%.*s] :: (%.*s) :: %d,%d [%s] %d\n",
namelen, cstr->str,
valuelen, cstr->val_start,
ws, eq, pos, cstr->nam_end - cstr->str);
}
示例4: do_op_left
static int
do_op_left(struct form_state *fs, struct line_info *line, int current, int utf8)
{
int old_state;
int new_state;
unsigned char *new_value;
if (!utf8) {
fs->state = int_max(fs->state - 1, 0);
return 0;
}
if (fs->state_cell) {
fs->state = fs->state_cell;
fs->state_cell = 0;
return 0;
}
old_state = fs->state;
new_value = utf8_prevchar(fs->value + fs->state, 1, fs->value);
new_state = new_value - fs->value;
if (old_state != new_state) {
if (old_state == line[current].start && line[current].split_prev)
fs->state_cell = new_state;
else
fs->state = new_state;
}
return 0;
}
示例5: test_fx_float_limits_zero
void test_fx_float_limits_zero(ostream& out)
{
cerr << "****************** limits fx_float_zero\n";
sc_fxval zero_min("-0"); SHOW(zero_min);
sc_fxval zero_plus("+0"); SHOW(zero_plus);
sc_fxval zero(0); SHOW(zero);
sc_fxval nan("NaN"); SHOW(nan);
sc_fxval inf_plus("+Inf"); SHOW(inf_plus);
sc_fxval inf_min("-Inf"); SHOW(inf_min);
sc_fxval inf("Inf"); SHOW(inf);
sc_fxval long_max(LONG_MAX); SHOW(long_max);
sc_fxval long_min(LONG_MIN); SHOW(long_min);
sc_fxval int_max(INT_MAX); SHOW(int_max);
sc_fxval int_min(INT_MIN); SHOW(int_min);
sc_fxval uint_max(UINT_MAX); SHOW(uint_max);
sc_fxval ulong_max(ULONG_MAX); SHOW(ulong_max);
sc_fxval double_min(DBL_MIN); SHOW(double_min);
sc_fxval double_max(DBL_MAX); SHOW(double_max);
sc_fxval float_min(FLT_MIN); SHOW(float_min);
sc_fxval float_max(FLT_MAX); SHOW(float_max);
sc_fxval res;
SHOW_EXPS(zero_min);
SHOW_EXPS(zero_plus);
SHOW_EXPS(zero);
}
示例6: do_op_end
static int
do_op_end(struct form_state *fs, struct line_info *line, int current, int utf8)
{
if (current == -1) {
fs->state = strlen(fs->value);
return 0;
}
if (!utf8) {
int wrap = line[current + 1].start == line[current].end;
/* Don't jump to next line when wrapping. */
fs->state = int_max(0, line[current].end - wrap);
return 0;
}
current -= !!fs->state_cell;
fs->state = line[current].end;
if (line[current].split_next) {
unsigned char *new_value;
new_value = utf8_prevchar(fs->value + fs->state, 1, fs->value);
fs->state_cell = new_value - fs->value;
} else {
fs->state_cell = 0;
}
return 0;
}
示例7: test_fx_fixed_limits_double
void test_fx_fixed_limits_double(ostream& out)
{
out << "****************** limits fx_fixed<8, 5>_double\n";
sc_fixed<8, 5> zero_min("-0"); SHOW(zero_min);
sc_fixed<8, 5> zero_plus("+0"); SHOW(zero_plus);
sc_fixed<8, 5> zero(0); SHOW(zero);
sc_fixed<8, 5> long_max(LONG_MAX); SHOW(long_max);
sc_fixed<8, 5> long_min(LONG_MIN); SHOW(long_min);
sc_fixed<8, 5> int_max(INT_MAX); SHOW(int_max);
sc_fixed<8, 5> int_min(INT_MIN); SHOW(int_min);
sc_fixed<8, 5> uint_max(UINT_MAX); SHOW(uint_max);
sc_fixed<8, 5> ulong_max(ULONG_MAX); SHOW(ulong_max);
sc_fixed<8, 5> double_min(DBL_MIN); SHOW(double_min);
sc_fixed<8, 5> double_max(DBL_MAX); SHOW(double_max);
sc_fixed<8, 5> float_min(FLT_MIN); SHOW(float_min);
sc_fixed<8, 5> float_max(FLT_MAX); SHOW(float_max);
// sc_fixed<8, 5> res;
// SHOW_EXPS(double_min);
// SHOW_EXPS(double_max);
// SHOW_EXPS(float_min);
// SHOW_EXPS(float_max);
}
示例8: get_joystick_direction
void EightDirections::update(float dt)
{
if (max_speed == 0)
return;
bool on = false;
int dir = get_joystick_direction(1);
if (dir == 8)
dir = instance->direction;
else {
on = true;
dir *= 4;
instance->set_direction(dir, false);
}
double mul = instance->frame->timer_mul;
double change;
if (on)
change = get_accelerator(acceleration);
else
change = -get_accelerator(deceleration);
set_speed(int_max(0, int_min(speed + change * mul, max_speed)));
if (speed == 0)
return;
double add_x, add_y;
get_dir(instance->direction, add_x, add_y);
double m = get_pixels(speed) * mul;
move(add_x * m, add_y * m);
last_move = m;
}
示例9: test_fx_fix_limits_long
void test_fx_fix_limits_long(ostream& out)
{
out << "****************** limits fx_fix_long\n";
sc_fix zero_min("-0"); SHOW(zero_min);
sc_fix zero_plus("+0"); SHOW(zero_plus);
sc_fix zero(0); SHOW(zero);
sc_fix long_max(LONG_MAX); SHOW(long_max);
sc_fix long_min(LONG_MIN); SHOW(long_min);
sc_fix int_max(INT_MAX); SHOW(int_max);
sc_fix int_min(INT_MIN); SHOW(int_min);
sc_fix uint_max(UINT_MAX); SHOW(uint_max);
sc_fix ulong_max(ULONG_MAX); SHOW(ulong_max);
sc_fix double_min(DBL_MIN); SHOW(double_min);
sc_fix double_max(DBL_MAX); SHOW(double_max);
sc_fix float_min(FLT_MIN); SHOW(float_min);
sc_fix float_max(FLT_MAX); SHOW(float_max);
// sc_fix res;
// SHOW_EXPS(long_max);
// SHOW_EXPS(long_min);
// SHOW_EXPS(int_max);
// SHOW_EXPS(int_min);
// SHOW_EXPS(uint_max);
// SHOW_EXPS(ulong_max);
}
示例10: zero
/*
PRE: size of actual_dist is same as size of hypothesized_dist.
Any entry in which hypothesized_dist has a value of
zero must have an actual_dist value of zero (i.e.
forall i, hy_dist[i]==0 => ac_dist[i] == 0
Given two distributions represented as histograms
(actual_dist and hypothesized_dist), how much evidence is there that they are
from the same distribution?
Note that these things must be counts. Each element of actual_dist must
be an integer. Each element of hypothesized_dist may be non-integer
because we're talking expected counts there.
The prob returned by this function answers that question
using a standard chi-squared test. If it is low (e.g. < 0.05), then it is
unlikely that they are the same.
The "dof" parameter is the mysterious "Degrees Of Freedom" that haunts
any use of the word "Chi".
If it is possible for any entry in the dist
to take any value, then set dof==size.
If the sum of values is constrained to a certain value
then set dof==size-1.
If there are more constraints than that, then subtract
more from size.
*/
double chi_squared_prob(dyv *actual_dist,dyv *hypothesized_dist,int dof)
{
double result = -1.0;
double min_hyp_dist = dyv_min(hypothesized_dist);
if ( min_hyp_dist < 0.0 )
my_error("chi_squared_prob: -ve count in hypothesized_dist");
else if ( min_hyp_dist > 0.0 )
result = chi_squared_prob_helper(actual_dist,hypothesized_dist,dof);
else
{
dyv *copy_ad = mk_dyv(0);
dyv *copy_hd = mk_dyv(0);
int i;
for ( i = 0 ; i < dyv_size(actual_dist) ; i++ )
{
if ( dyv_ref(hypothesized_dist,i) > 0.0 )
{
add_to_dyv(copy_ad,dyv_ref(actual_dist,i));
add_to_dyv(copy_hd,dyv_ref(hypothesized_dist,i));
dof -= 1;
}
else if ( dyv_ref(actual_dist,i) > 0.0 )
my_error("chi_squared_prob: actual_dist value must be zero if hyp dist value is zero");
}
dof = int_max(2,dof);
result = chi_squared_prob_helper(copy_ad,copy_hd,dof);
free_dyv(copy_ad);
free_dyv(copy_hd);
}
return result;
}
示例11: int_max
void Active::force_frame(int value)
{
if (loop_count == 0)
return;
int frame_count = direction_data->frame_count;
forced_frame = int_max(0, int_min(value, frame_count - 1));
update_frame();
}
示例12: gpm_mouse_in
static void
gpm_mouse_in(struct gpm_mouse_spec *gms)
{
Gpm_Event gev;
struct term_event ev;
struct term_event_mouse mouse;
if (Gpm_GetEvent(&gev) <= 0) {
clear_handlers(gms->h);
return;
}
mouse.x = int_max(gev.x - 1, 0);
mouse.y = int_max(gev.y - 1, 0);
if (gev.buttons & GPM_B_LEFT)
mouse.button = B_LEFT;
else if (gev.buttons & GPM_B_MIDDLE)
mouse.button = B_MIDDLE;
else if (gev.buttons & GPM_B_RIGHT)
mouse.button = B_RIGHT;
else
return;
if (gev.type & GPM_DOWN)
mouse.button |= B_DOWN;
else if (gev.type & GPM_UP)
mouse.button |= B_UP;
else if (gev.type & GPM_DRAG)
mouse.button |= B_DRAG;
else
return;
set_mouse_term_event(&ev, mouse.x, mouse.y, mouse.button);
gms->fn(gms->data, (char *) &ev, sizeof(ev));
}
示例13: get_dir
void BallMovement::update()
{
if (stop_speed != 0 || speed == 0) {
instance->set_animation(STOPPED);
return;
} else
instance->set_animation(WALKING);
double add_x, add_y;
get_dir(instance->direction, add_x, add_y);
double m = get_pixels(speed) * instance->frame->timer_mul;
if (speed > 100 && has_back_col) {
double move_x = add_x * m;
double move_y = add_y * m;
int steps = 4;
move_x /= steps;
move_y /= steps;
old_x = instance->x;
old_y = instance->y;
clear_collisions();
for (int i = 0; i < steps; ++i) {
this->add_x += move_x;
this->add_y += move_y;
double xx = floor(this->add_x);
double yy = floor(this->add_y);
this->add_x -= xx;
this->add_y -= yy;
instance->set_position(instance->x + xx,
instance->y + yy);
if (instance->overlaps_background())
break;
}
} else {
move(add_x * m, add_y * m);
}
if (deceleration != 0)
speed_change -= get_accelerator(deceleration)
* instance->frame->timer_mul;
int change = (int)speed_change;
speed_change -= change;
speed = int_max(0, speed + change);
}
示例14: t2_decode_packets
int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile) {
unsigned char *c = src;
opj_pi_iterator_t *pi;
int pino, e = 0;
int n = 0,i;
opj_volume_t *volume = t2->volume;
opj_cp_t *cp = t2->cp;
/* create a packet iterator */
pi = pi_create(volume, cp, tileno);
if(!pi) {
/* TODO: throw an error */
return -999;
}
for (pino = 0; pino <= cp->tcps[tileno].numpocs; pino++) {
while (pi_next(&pi[pino])) {
if ((cp->layer==0) || (cp->layer>=((pi[pino].layno)+1))) {
e = t2_decode_packet(t2, c, src + len - c, tile, &cp->tcps[tileno], &pi[pino]);
} else {
e = 0;
}
/* progression in resolution */
for (i = 0; i < 3; i++){
volume->comps[pi[pino].compno].resno_decoded[i] = (e > 0) ? int_max(pi[pino].resno, volume->comps[pi[pino].compno].resno_decoded[i]) : volume->comps[pi[pino].compno].resno_decoded[i];
}
n++;
if (e == -999) { /* ADD */
break;
} else {
opj_event_msg(t2->cinfo, EVT_INFO, " t2_decode_packet: %d bytes decoded\n",e);
c += e;
}
}
}
/* don't forget to release pi */
pi_destroy(pi, cp, tileno);
if (e == -999) {
return e;
}
return (c - src);
}
示例15: t2_decode_packets
int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile) {
unsigned char *c = src;
opj_pi_iterator_t *pi;
int pino, e = 0;
int n = 0;
opj_image_t *image = t2->image;
opj_cp_t *cp = t2->cp;
/* create a packet iterator */
pi = pi_create(image, cp, tileno);
if(!pi) {
/* TODO: throw an error */
return -999;
}
for (pino = 0; pino <= cp->tcps[tileno].numpocs; pino++) {
while (pi_next(&pi[pino])) {
if ((cp->layer==0) || (cp->layer>=((pi[pino].layno)+1))) {
e = t2_decode_packet(t2, c, src + len - c, tile, &cp->tcps[tileno], &pi[pino]);
} else {
e = 0;
}
/* progression in resolution */
image->comps[pi[pino].compno].resno_decoded =
(e > 0) ?
int_max(pi[pino].resno, image->comps[pi[pino].compno].resno_decoded)
: image->comps[pi[pino].compno].resno_decoded;
n++;
if (e == -999) { /* ADD */
break;
} else {
c += e;
}
}
}
/* don't forget to release pi */
pi_destroy(pi, cp, tileno);
if (e == -999) {
return e;
}
return (c - src);
}