void blur_channels_node_t::blur_channel( int ch, const Imath::Box2i& area, const boost::gil::gray32f_view_t& tmp, const Imath::V2f& radius, int iters, blur_border_mode border) { if( border != border_black) { int hradius = std::ceil( radius.x); int vradius = std::ceil( radius.y); int border_x0 = std::min( area.min.x - defined().min.x, hradius); int border_y0 = std::min( area.min.y - defined().min.y, vradius); int border_x1 = std::min( defined().max.x - area.max.x, hradius); int border_y1 = std::min( defined().max.y - area.max.y, vradius); Imath::Box2i box( area); box.min.x -= border_x0; box.min.y -= border_y0; box.max.x += border_x1; box.max.y += border_y1; if( border == border_repeat) boost::gil::repeat_border_pixels( boost::gil::nth_channel_view( subimage_view( box), ch), border_x0, border_y0, border_x1, border_y1); else boost::gil::reflect_border_pixels( boost::gil::nth_channel_view( subimage_view( box), ch), border_x0, border_y0, border_x1, border_y1); } image::box_blur_channel( boost::gil::nth_channel_view( const_image_view(), ch), tmp, boost::gil::nth_channel_view( image_view(), ch), radius.x, radius.y, iters); }
/* * process_attribute: skip attributes in __attribute__((...)). * * r) target type */ static void process_attribute(int target) { int brace = 0; int c; /* * Skip '...' in __attribute__((...)) * but pick up symbols in it. */ while ((c = nexttoken("()", cpp_reserved_word)) != EOF) { if (c == '(') brace++; else if (c == ')') brace--; else if (c == SYMBOL) { if (target == REF) { if (defined(token)) PUT(token, lineno, sp); } else if (target == SYM) { if (!defined(token)) PUT(token, lineno, sp); } } if (brace == 0) break; } }
/* * condition_macro: * * i) cc token * i) target current target */ static void condition_macro(int cc, int target) { cur = &pifstack[piflevel]; if (cc == SHARP_IFDEF || cc == SHARP_IFNDEF || cc == SHARP_IF) { DBG_PRINT(piflevel, "#if"); if (++piflevel >= MAXPIFSTACK) die("#if pifstack over flow. [%s]", curfile); ++cur; cur->start = level; cur->end = -1; cur->if0only = 0; if (peekc(0) == '0') cur->if0only = 1; else if ((cc = nexttoken(NULL, cpp_reserved_word)) == SYMBOL && !strcmp(token, "notdef")) cur->if0only = 1; else pushbacktoken(); } else if (cc == SHARP_ELIF || cc == SHARP_ELSE) { DBG_PRINT(piflevel - 1, "#else"); if (cur->end == -1) cur->end = level; else if (cur->end != level && wflag) warning("uneven level. [+%d %s]", lineno, curfile); level = cur->start; cur->if0only = 0; } else if (cc == SHARP_ENDIF) { int minus = 0; --piflevel; if (piflevel < 0) { minus = 1; piflevel = 0; } DBG_PRINT(piflevel, "#endif"); if (minus) { if (wflag) warning("#if block unmatched. reseted. [+%d %s]", lineno, curfile); } else { if (cur->if0only) level = cur->start; else if (cur->end != -1) { if (cur->end != level && wflag) warning("uneven level. [+%d %s]", lineno, curfile); level = cur->end; } } } while ((cc = nexttoken(NULL, cpp_reserved_word)) != EOF && cc != '\n') { if (cc == SYMBOL && strcmp(token, "defined") != 0) { if (target == REF) { if (defined(token)) PUT(token, lineno, sp); } else if (target == SYM) { if (!defined(token)) PUT(token, lineno, sp); } } } }
void SymmetricFunction::validate() const { POMAGMA_INFO("Validating SymmetricFunction"); m_lines.validate(); POMAGMA_DEBUG("validating line-value consistency"); for (size_t i = 1; i <= item_dim(); ++i) for (size_t j = i; j <= item_dim(); ++j) { auto val_iter = m_values.find(assert_sorted_pair(i, j)); if (not(support().contains(i) and support().contains(j))) { POMAGMA_ASSERT(val_iter == m_values.end(), "found unsupported lhs, rhs: " << i << ',' << j); } else if (val_iter != m_values.end()) { POMAGMA_ASSERT(defined(i, j), "found undefined value: " << i << ',' << j); Ob val = val_iter->second; POMAGMA_ASSERT(val, "found zero value: " << i << ',' << j); POMAGMA_ASSERT(support().contains(val), "found unsupported value: " << i << ',' << j); } else { POMAGMA_ASSERT(not defined(i, j), "found defined null value: " << i << ',' << j); } } }
void keyer3d_node_t::do_process( const render::context_t& context) { image_node_t *in0 = input_as<image_node_t>( 0); float gtol = get_value<float>( param( "gtol")); float gsoft = get_value<float>( param( "gsoft")); keyer().set_tol_soft_factors( gtol, gsoft); if( !input(1)) { Imath::Box2i area( Imath::intersect( defined(), in0->defined())); if( area.isEmpty()) return; boost::gil::tbb_transform_pixels( in0->const_subimage_view( area), subimage_view( area), key3d_fun( keyer())); } else { image_node_t *in1 = input_as<image_node_t>( 1); Imath::Box2i area( Imath::intersect( Imath::intersect( defined(), in0->defined()), in1->defined())); if( area.isEmpty()) return; boost::gil::tbb_transform2_pixels( in0->const_subimage_view( area), in1->const_subimage_view( area), subimage_view( area), key3d_fun( keyer())); } }
void flip_node_t::do_process( const render::context_t& context) { if( defined().isEmpty()) return; calc_transform_matrix(); image::affine_warp_nearest( input_as<image_node_t>()->defined(), input_as<image_node_t>()->const_image_view(), defined(), image_view(), xform_, inv_xform_); }
void blur_node_t::do_process( const render::render_context_t& context) { Imath::Box2i area( intersect( input()->defined(), defined())); if( area.isEmpty()) return; boost::gil::copy_pixels( input()->const_subimage_view( area), subimage_view( area)); int bmode = get_value<int>( param( "border")); if( bmode != border_black) { int border_x0 = area.min.x - defined().min.x; int border_y0 = area.min.y - defined().min.y; int border_x1 = defined().max.x - area.max.x; int border_y1 = defined().max.y - area.max.y; if( bmode == border_repeat) boost::gil::repeat_border_pixels( image_view(), border_x0, border_y0, border_x1, border_y1); else boost::gil::reflect_border_pixels( image_view(), border_x0, border_y0, border_x1, border_y1); } int channels = get_value<int>( param( "channels")); Imath::V2f radius = get_value<Imath::V2f>( param( "radius")); int iters = get_value<int>( param( "iters")); radius.x /= context.subsample; radius.y /= context.subsample; switch( channels) { case channels_rgba: image::box_blur_rgba( const_image_view(), image_view(), radius.x, radius.y, iters); break; case channels_rgb: { image::box_blur_rgba( const_image_view(), image_view(), radius.x, radius.y, iters); boost::gil::fill_pixels( boost::gil::nth_channel_view( image_view(), 3), boost::gil::gray32f_pixel_t( 0)); boost::gil::copy_pixels( boost::gil::nth_channel_view( input()->const_subimage_view( area), 3), boost::gil::nth_channel_view( subimage_view( area), 3)); } break; case channels_alpha: { image::box_blur_channel( boost::gil::nth_channel_view( const_image_view(), 3), boost::gil::nth_channel_view( image_view(), 3), radius.x, radius.y, iters); } break; } }
static void exfill(void (*fill) (PLINT, PLFLT *, PLFLT *), PLINT (*defined) (PLFLT, PLFLT), int n, PLFLT *x, PLFLT *y) { if (defined == NULL) (*fill) (n, x, y); else { PLFLT xx[16]; PLFLT yy[16]; PLFLT xb, yb; PLINT count = 0; PLINT is_inside = defined (x[n-1], y[n-1]); PLINT i; for (i = 0; i < n; i++) { if (defined(x[i], y[i])) { if (!is_inside) { if (i > 0) bisect (defined, 10, x[i], y[i], x[i-1], y[i-1], &xb, &yb); else bisect (defined, 10, x[i], y[i], x[n-1], y[n-1], &xb, &yb); xx[count] = xb; yy[count++] = yb; } xx[count] = x[i]; yy[count++] = y[i]; is_inside = 1; } else { if (is_inside) { if (i > 0) bisect (defined, 10, x[i-1], y[i-1], x[i], y[i], &xb, &yb); else bisect (defined, 10, x[n-1], y[n-1], x[i], y[i], &xb, &yb); xx[count] = xb; yy[count++] = yb; is_inside = 0; } } } if (count) (*fill) (count, xx, yy); } }
/* * Initializes the timer, and resets the timer count to 0. Sets up the ISRs * linked with timer0. */ void timer_init(){ //Set up the timer to run at F_CPU / 256, in normal mode (we reset TCNT0 in the ISR) TCCR0A = 0x0; TCCR0B |= _BV(CS02); //Every _timer_micro_divisor clock ticks is one microsecond. _timer_micro_divisor = F_CPU / 1000000; //Set compare value to be F_CPU / 1000 -- fire interrupt every millisecond OCR0A = F_CPU / 256 / 1000; //Enable compare interrupt #if defined(__AVR_ATtiny13__) || \ defined(__AVR_ATtiny24__) || \ defined(__AVR_ATtiny44__) || \ defined(__AVR_ATtiny84__) || \ defined(__AVR_ATtiny25__) || \ defined(__AVR_ATtiny45__) || \ defined(__AVR_ATtiny85__) TIMSK = _BV(OCIE0A); #elif defined(__AVR_ATmega48__) || \ defined(__AVR_ATmega48P__) || \ defined(__AVR_ATmega168__) || \ defined(__AVR_ATmega328__) || \ defined(__AVR_ATmega328P__) || \ defined(__AVR_ATmega324P__) || \ defined(__AVR_ATmega644__) || \ defined(__AVR_ATmega644P__) || \ defined(__AVR_ATmega644PA__) || \ defined(__AVR_ATmega1284P__) defined(__AVR_ATmega32U2__) || \ defined(__AVR_ATmega16U4__) || \ defined(__AVR_ATmega32U4__) TIMSK0 = _BV(OCIE0A); #endif //Reset count variables _timer_millis = 0; //Enable interrupts if the NO_INTERRUPT_ENABLE define is not set. If it is, you need to call sei() elsewhere. #ifndef NO_INTERRUPT_ENABLE sei(); #endif }
void Buffer::set_min(int m0, int m1, int m2, int m3) { user_assert(defined()) << "Buffer is undefined\n"; contents.ptr->buf.min[0] = m0; contents.ptr->buf.min[1] = m1; contents.ptr->buf.min[2] = m2; contents.ptr->buf.min[3] = m3; }
void colorx_node_t::do_process( const render::context_t& context) { if( !expr_.get() || !expr_->isValid()) { image::make_color_bars( image_view()); return; } Imath::Box2i area( Imath::intersect( input_as<image_node_t>()->defined(), defined())); if( area.isEmpty()) return; if( expr_->isThreadSafe()) // multi-threaded { tbb::parallel_for( tbb::blocked_range<int>( 0, area.size().y + 1), boost::bind( &colorx_node_t::do_expression, this, _1, area, boost::cref( context)), tbb::auto_partitioner()); } else { tbb::blocked_range<int> range( 0, area.size().y + 1); do_expression( range, area, context); } }
void MaskedIcon::load_big(unsigned id, unsigned big_id, bool center) { if (Layout::ScaleEnabled()) { if (big_id > 0) bitmap.load(big_id); else bitmap.load_stretch(id, Layout::FastScale(1)); } else bitmap.load(id); assert(defined()); size = bitmap.get_size(); /* left half is mask, right half is icon */ size.cx /= 2; if (center) { origin.x = size.cx / 2; origin.y = size.cy / 2; } else { origin.x = 0; origin.y = 0; } }
virtual void print() { if (defined()) cout << name << ":" << values[ value() -1] << '\n'; else cout << name << ":Undefined\n"; };
bool LoopLevel::match(const LoopLevel &other) const { internal_assert(defined()); return (contents->func_name == other.contents->func_name && (contents->var_name == other.contents->var_name || Internal::ends_with(contents->var_name, "." + other.contents->var_name) || Internal::ends_with(other.contents->var_name, "." + contents->var_name))); }
static void gen_conf(Entry * head, FILE * fp, int verbose_output) { Entry *entry; char buf[8192]; Line *def = NULL; for (entry = head; entry != NULL; entry = entry->next) { Line *line; if (!strcmp(entry->name, "comment")) (void) 0; else if (verbose_output) { fprintf(fp, "# TAG: %s", entry->name); if (entry->comment) fprintf(fp, "\t%s\n", entry->comment); else fprintf(fp, "\n"); } if (verbose_output) { if (!defined(entry->ifdef)) { fprintf(fp, "# Note: This option is only available if Squid is rebuilt with the\n"); fprintf(fp, "# %s option\n#\n", available_if(entry->ifdef)); } for (line = entry->doc; line != NULL; line = line->next) { fprintf(fp, "#%s\n", line->data); } } if (entry->default_value && strcmp(entry->default_value, "none") != 0) { snprintf(buf, sizeof(buf), "%s %s", entry->name, entry->default_value); lineAdd(&def, buf); } if (entry->default_if_none) { for (line = entry->default_if_none; line; line = line->next) { snprintf(buf, sizeof(buf), "%s %s", entry->name, line->data); lineAdd(&def, buf); } } if (!def && entry->doc && strcmp(entry->name, "comment") != 0) lineAdd(&def, "none"); if (verbose_output && def && (entry->doc || entry->nocomment)) { fprintf(fp, "#\n#Default:\n"); while (def != NULL) { line = def; def = line->next; fprintf(fp, "# %s\n", line->data); xfree(line->data); xfree(line); } } if (verbose_output && entry->nocomment) fprintf(fp, "#\n"); for (line = entry->nocomment; line != NULL; line = line->next) { fprintf(fp, "%s\n", line->data); } if (verbose_output && entry->doc != NULL) { fprintf(fp, "\n"); } } }
void exposure_node_t::do_process( const image::const_image_view_t& src, const image::image_view_t& dst, const render::render_context_t& context) { image::const_image_view_t src_view; image::image_view_t dst_view; Imath::Box2i area; if( input(1)) { boost::gil::copy_pixels( src, dst); area = intersect( input(1)->defined(), defined()); if( area.isEmpty()) return; src_view = input(0)->const_subimage_view( area); dst_view = subimage_view( area); } else { src_view = src; dst_view = dst; } boost::gil::tbb_transform_pixels( src_view, dst_view, exposure_fun( get_value<float>( param( "exp")))); if( input(1)) image::key_mix( src_view, dst_view, boost::gil::nth_channel_view( input(1)->const_subimage_view( area), 3), dst_view); }
void smart_blur_node_t::do_process( const render::context_t& context) { Imath::Box2i area( ImathExt::intersect( input_as<image_node_t>()->defined(), defined())); if( area.isEmpty()) return; Imath::V2f stddev = get_value<Imath::V2f>( param( "stddev")); stddev = adjust_blur_size( stddev, context.subsample); copy_src_image( 0, area, ( blur_border_mode) get_value<int>( param( "border"))); blur_channels_mode channels = ( blur_channels_mode) get_value<int>( param( "channels")); switch( channels) { case channels_rgba: { image::buffer_t tmp( const_image_view().height(), const_image_view().width(), 4); image::smart_blur_rgba( const_image_view(), tmp.rgba_view(), image_view(), stddev.x, stddev.y, get_value<float>( param( "theresh"))); } break; case channels_rgb: { image::buffer_t tmp( const_image_view().height(), const_image_view().width(), 4); image::smart_blur_rgba( const_image_view(), tmp.rgba_view(), image_view(), stddev.x, stddev.y, get_value<float>( param( "theresh"))); boost::gil::fill_pixels( boost::gil::nth_channel_view( image_view(), 3), boost::gil::gray32f_pixel_t( 0)); boost::gil::copy_pixels( boost::gil::nth_channel_view( input_as<image_node_t>()->const_subimage_view( area), 3), boost::gil::nth_channel_view( subimage_view( area), 3)); } break; } }
void MaskedIcon::draw(Canvas &canvas, int x, int y) const { assert(defined()); #ifdef ENABLE_OPENGL if (size.cx == 0) /* hack: do the postponed layout calcuation now */ const_cast<MaskedIcon *>(this)->CalculateLayout((bool)size.cy); GLTexture &texture = *bitmap.native(); GLEnable scope(GL_TEXTURE_2D); texture.bind(); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); GLLogicOp logic_op(GL_OR); texture.draw(x - origin.x, y - origin.y, size.cx, size.cy, 0, 0, size.cx, size.cy); logic_op.set(GL_AND); texture.draw(x - origin.x, y - origin.y, size.cx, size.cy, size.cx, 0, size.cx, size.cy); #else canvas.copy_or(x - origin.x, y - origin.y, size.cx, size.cy, bitmap, 0, 0); canvas.copy_and(x - origin.x, y - origin.y, size.cx, size.cy, bitmap, size.cx, 0); #endif }
/** * Check if this thread is the current thread. */ bool inside() const { #ifdef HAVE_POSIX return defined() && pthread_equal(pthread_self(), handle); #else return GetCurrentThread() == handle; #endif }
DenseSet Router::find_defined() const { POMAGMA_INFO("Finding defined obs"); DenseSet defined(m_carrier.item_dim()); DenseSet undefined(m_carrier.item_dim()); undefined = m_carrier.support(); bool changed = true; while (changed) { changed = false; POMAGMA_DEBUG("accumulating route probabilities"); undefined -= defined; for (auto iter = undefined.iter(); iter.ok(); iter.next()) { Ob ob = *iter; if (defines(defined, ob)) { defined.insert(ob); changed = true; break; } } } return defined; }
void lens_distort_node_t::do_process( const render::context_t& context) { image_node_t *in = input_as<image_node_t>(); switch( get_value<int>( param( "model"))) { case syntheyes_model: { float k = get_value<float>( param( "synth_k")); float k3 = get_value<float>( param( "synth_k3")); if( get_value<int>( param( "mode")) == undistort) { if( k3 == 0) { camera::syntheyes_quadratic_undistort dist( k, in->format(), in->aspect_ratio()); if( get_value<int>( param( "filter")) == bilinear) image::warp_bilinear( in->defined(), in->const_image_view(), defined(), image_view(), dist, false, false); else image::warp_bicubic( in->defined(), in->const_image_view(), defined(), image_view(), dist, false, false); } else { camera::syntheyes_undistort dist( k, k3, in->format(), in->aspect_ratio()); if( get_value<int>( param( "filter")) == bilinear) image::warp_bilinear( in->defined(), in->const_image_view(), defined(), image_view(), dist, false, false); else image::warp_bicubic( in->defined(), in->const_image_view(), defined(), image_view(), dist, false, false); } } else { if( k3 == 0) { camera::syntheyes_quadratic_redistort dist( k, in->format(), in->aspect_ratio()); if( get_value<int>( param( "filter")) == bilinear) image::warp_bilinear( in->defined(), in->const_image_view(), defined(), image_view(), dist, false, false); else image::warp_bicubic( in->defined(), in->const_image_view(), defined(), image_view(), dist, false, false); } else { camera::syntheyes_redistort dist( k, k3, in->format(), in->aspect_ratio()); if( get_value<int>( param( "filter")) == bilinear) image::warp_bilinear( in->defined(), in->const_image_view(), defined(), image_view(), dist, false, false); else image::warp_bicubic( in->defined(), in->const_image_view(), defined(), image_view(), dist, false, false); } } } break; }; }
int ImageBase::stride(int dim) const { user_assert(defined()) << "stride of undefined Image\n"; user_assert(dim >= 0 && dim < dims) << "Requested stride of dimension " << dim << " in " << dims << "-dimensional Image \"" << buffer.name() << "\".\n"; return buffer.stride(dim); }
void HubSettings::merge(const HubSettings& sub) { for(uint8_t i = 0; i < StringCount; ++i) { if(defined(sub.strings[i])) { strings[i] = sub.strings[i]; } } for(uint8_t i = 0; i < BoolCount; ++i) { if(defined(sub.bools[i])) { bools[i] = sub.bools[i]; } } for(uint8_t i = 0; i < IntCount; ++i) { if(defined(sub.ints[i])) { ints[i] = sub.ints[i]; } } }
void HubSettings::save(SimpleXML& xml) const { for(uint8_t i = 0; i < StringCount; ++i) { if(defined(strings[i])) { xml.addChildAttrib(stringNames[i], strings[i]); } } for(uint8_t i = 0; i < BoolCount; ++i) { if(defined(bools[i])) { xml.addChildAttrib(boolNames[i], toIntXml(bools[i])); } } for(uint8_t i = 0; i < IntCount; ++i) { if(defined(ints[i])) { xml.addChildAttrib(intNames[i], ints[i]); } } }
void Font::reset() { assert(!defined() || IsScreenInitialized()); delete textUtilObject; textUtilObject = NULL; }
void set_matte_node_t::do_process( const render::context_t& context) { if( defined().isEmpty()) return; boost::gil::tbb_transform_pixels( input_as<image_node_t>( 0)->const_subimage_view( defined()), image_view(), copy_rgb_and_clear_alpha()); Imath::Box2i area = ImathExt::intersect( defined(), input_as<image_node_t>( 1)->defined()); if( !area.isEmpty()) boost::gil::tbb_copy_pixels( boost::gil::nth_channel_view( input_as<image_node_t>( 1)->const_subimage_view( area), 3), boost::gil::nth_channel_view( subimage_view( area), 3)); if( get_value<bool>( param( "premultiply"))) image::premultiply( image_view(), image_view()); }
const PixelSize Bitmap::get_size() const { assert(defined()); const PixelSize size = { width, height }; return size; }
IArrayBox& iMultiFab::operator[] (int K) { BL_ASSERT(defined(K)); IArrayBox& fab = this->FabArray<IArrayBox>::get(K); return fab; }
void Pen::reset() { assert(!defined() || IsScreenInitialized()); #ifndef NDEBUG width = 0; #endif }
void expand_node_t::do_process( const render::context_t& context) { Imath::Box2i area = ImathExt::intersect( input_as<image_node_t>()->defined(), defined()); if( area.isEmpty()) return; boost::gil::copy_pixels( input_as<image_node_t>()->const_subimage_view( area), subimage_view( area)); }