void HDRImage3f::getHDRImage1f (HDRImage1f* out, FuncF3toF* func, uint2 append) { uint2 sizeAvailable = out->getSize (); uint2 sizeAppend = out->getAppendSize (); if (sizeAvailable != getSize() || sizeAppend != append) out->setSize (sizeAvailable, sizeAppend); uint2 sizeTotal = out->getTotalSize (); out->setMult (m_mult); for (uint y = 0; y < sizeAvailable.y; y++) { float* r = getRedBuffer (uint2(0,y)); float* g = getGreenBuffer (uint2(0,y)); float* b = getBlueBuffer (uint2(0,y)); float* a = out->getBuffer (uint2(0,y)); for (uint x = 0; x < sizeAvailable.x; x++) { *a = (*func) (float3(*r, *g, *b)); a++; r++; g++; b++; } } }
int f_packing(ARG0) { unsigned char *p; unsigned int pack; if (mode >= 0) { p = sec[5]; pack = code_table_5_0(sec); if (mode >= 0) { sprintf(inv_out,"packing="); inv_out += strlen(inv_out); if (pack <= sizeof (packing_msg) / sizeof (p)) { sprintf(inv_out,"%s", packing_msg[pack]); } else if (pack == 40 || pack == 40000) { sprintf(inv_out,"JPEG2000"); } else if (pack == 41 || pack == 40010) { sprintf(inv_out,"PNG"); } else if (pack == 50) { sprintf(inv_out,"Simple,Spherical Harmonic"); } else if (pack == 51) { sprintf(inv_out,"Complex,Spherical Harmonic"); } else if (pack == 255) { sprintf(inv_out,"missing"); } else { sprintf(inv_out,"unknown packing"); } inv_out += strlen(inv_out); } if (mode > 0) { if (pack == 0) { sprintf(inv_out," val=(%lg+i)*2^%d*10^%d, i=0..%d (#bits=%d)", ieee2flt(p+11), int2(p+15), -int2(p+17), (1 << p[19])-1, p[19]); } if (pack == 50) { sprintf(inv_out," val=(%lg+i)*2^%d*10^%d, i=0..%d (#bits=%d) global_mean=%lg", ieee2flt(p+11), int2(p+15), -int2(p+17), (1 << p[19])-1, p[19], ieee2flt(p+20)); } if (pack == 51) { sprintf(inv_out," val=(%lg+i)*2^%d*10^%d, i=0..%d (#bits=%d)", ieee2flt(p+11), int2(p+15), -int2(p+17), (1 << p[19])-1, p[19]); inv_out += strlen(inv_out); sprintf(inv_out," P-Laplacian scaling factor*10^-6=%d",int4(p+20)); inv_out += strlen(inv_out); sprintf(inv_out," Js=%d Ks=%d Ms=%d Ts=%d", uint2(p+24), uint2(p+26), uint2(p+28), int4(p+30)); inv_out += strlen(inv_out); sprintf(inv_out," code_table_5.7=%d", (int) p[34]); /* sprintf(inv_out," mean?=%lg", ieee2flt(sec[7]+5)); */ } } } return 0; }
SDL_Surface* HDRImage3f::getSDLSurface (float multCoef, SDL_Surface* surface, uint2 surfaceSize) { uint2 size = uint2::getMin (getSize(), surfaceSize); if (surface != NULL) { if ((surface->w != size.x) || (surface->h != size.y) || (surface->format->BitsPerPixel != 32)) { SDL_FreeSurface (surface); surface = NULL; } } if (! surface) { surface = SDL_CreateRGBSurface(SDL_SWSURFACE, size.x, size.y, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000); } float* inr (m_red); float* ing (m_green); float* inb (m_blue); SDL_LockSurface (surface); uint* outpix = (uint*) surface->pixels; multCoef *= 256.0; //uint2 size = getSize(); for (uint y = 0; y < size.y; y++) { inr = getRedBuffer (uint2(0, y)); ing = getGreenBuffer (uint2(0, y)); inb = getBlueBuffer (uint2(0, y)); outpix = (uint*) ((uchar*) surface->pixels + surface->pitch*y); for (uint x = 0; x < size.x; x++) { uchar ucr = toUchar (*inr, multCoef); uchar ucg = toUchar (*ing, multCoef); uchar ucb = toUchar (*inb, multCoef); uchar uca = 0; *outpix = ucr << 0 | ucg << 8 | ucb << 16 | uca << 24; inr++; ing++; inb++; outpix++; } //inr += m_appendSize.x; //ing += m_appendSize.x; //inb += m_appendSize.x; } SDL_UnlockSurface (surface); return surface; }
bool HDRImage3f::loadFromHDRFile (cchar* pathname, uint2 appendMult, uint2 appendAdd) { HDRLoaderResult res; bool bres = HDRLoader::load (pathname, res); if (false == bres) return false; uint2 available = uint2 (res.width, res.height); uint2 append = available*appendMult + appendAdd; setSize (available, append); uint countReals = m_totalSize.getArea(); m_red = ::fftwf_alloc_real (countReals); m_green = ::fftwf_alloc_real (countReals); m_blue = ::fftwf_alloc_real (countReals); for (uint y = 0; y < getSize().y; y++) for (uint x = 0; x < getSize().x; x++) { uint offsetSrc = x + y*res.width; uint offsetDst = getOffset (x, y); m_red[offsetDst] = res.cols [offsetSrc*3]; m_green[offsetDst] = res.cols [offsetSrc*3+1]; m_blue[offsetDst] = res.cols [offsetSrc*3+2]; } clearAppendArea (); return true; }
/* * HEADER:400:Sec5:inv:0:Sec 5 values (Data representation section) */ int f_Sec5(ARG0) { if (mode >= 0) { sprintf(inv_out,"Sec5 len=%d #defined data points=%d Data Repr. Template=5.%d", uint4(&(sec[5][0])), uint4(&(sec[5][5])), uint2(&(sec[5][9]))); } return 0; }
namespace configuration { uint2 client_dimensions = uint2(1680, 900); bool client_windowed = false; int v_sync = 1; uint2 virtual_dimensions = client_dimensions; bool fxaa = true; }
int code_table_4_233(unsigned char **sec) { unsigned char *p; int i; p = code_table_4_233_location(sec); if (p == NULL) return -1; i = uint2(p); return i; }
void HDRImage3f::getSubImage (PtrHDRImage3f& outimg, uint2 size, float2 reloffsetMin, float2 reloffsetMax) { if (! outimg.get()) outimg = PtrHDRImage3f (new HDRImage3f); outimg->setSize (size); outimg->setMult (getMult()); float2 step = (getSize().get<float>() * (float2(1.0f,1.0f) - reloffsetMin- reloffsetMax)/ size.get<float>()) ; HDRImage3f midresult (uint2(outimg->getSize().x, getSize().y)); { float3* in = new float3[getSize().x]; float3* out = new float3[outimg->getSize().x]; for (uint y = 0; y < getSize().y; y++) { for (uint x = 0; x < getSize().x; x++) in[x] = getPixel (uint2(x,y)); if (step.x < 1.0f) remapLanczosFilter (in, getSize().x, out, size.x, float2(reloffsetMin.x, reloffsetMax.x)); else remapAverage (in, getSize().x, out, size.x, float2(reloffsetMin.x, reloffsetMax.x)); for (uint x = 0; x < size.x; x++) midresult.setPixel (uint2(x,y), out[x]); } delete [] (out); delete [] (in); } { float3* in = new float3[getSize().y]; float3* out = new float3[outimg->getSize().y]; for (uint x = 0; x < size.x; x++) { for (uint y = 0; y < getSize().y; y++) in[y] = midresult.getPixel (uint2(x,y)); if (step.y < 1.0f) remapLanczosFilter (in, getSize().y, out, size.y, float2(reloffsetMin.y, reloffsetMax.y)); else remapAverage (in, getSize().y, out, size.y, float2(reloffsetMin.y, reloffsetMax.y)); for (uint y = 0; y < size.y; y++) outimg->setPixel (uint2(x,y), out[y]); } delete [] (out); delete [] (in); } }
void HDRImage3c::rfftplanUpdate () { uint2 total = getTotalSize()-uint2(0,2); m_rfftplanR = fftwf_plan_dft_c2r_2d (total.y, total.x, m_red, m_hdriRFFT->getRedBuffer(), FFTW_MEASURE); m_rfftplanG = fftwf_plan_dft_c2r_2d (total.y, total.x, m_green, m_hdriRFFT->getGreenBuffer(), FFTW_MEASURE); m_rfftplanB = fftwf_plan_dft_c2r_2d (total.y, total.x, m_blue, m_hdriRFFT->getBlueBuffer(), FFTW_MEASURE); }
bool filter(Image_buffer<rendering::Color4c>& destination, const Image_buffer<rendering::Color4c>& source) const { if (destination.format() != source.format() || destination.dimensions() != source.dimensions()) { return false; } // const __m128 m4x255f = _mm_set_ps1(255.f); for (uint32_t y = 0; y < source.dimensions().y; ++y) { for (uint32_t x = 0; x < source.dimensions().x; ++x) { const rendering::Color4c& source_color = source.get(uint2(x, y)); /* __m128i mi = _mm_set_epi32(source_color.b, source_color.g, source_color.r, 0); __m128 ma = _mm_cvtepi32_ps(mi); __m128 mb = _mm_set_ps1(factor_); __m128 m_mul = _mm_mul_ps(ma, mb); __m128 m_min =_mm_min_ps(m_mul, m4x255f); mi = _mm_cvtps_epi32(m_min); rendering::Color4c modulated(mi.m128i_i32[3], mi.m128i_i32[2], mi.m128i_i32[1], 255); */ rendering::Color4c modulated((unsigned char)(std::min(factor_ * float(source_color.r), 255.f)), (unsigned char)(std::min(factor_ * float(source_color.g), 255.f)), (unsigned char)(std::min(factor_ * float(source_color.b), 255.f)), 255); destination.set(uint2(x, y), modulated); } } return true; }
boost::shared_ptr<HDRImage3f> HDRImage3c::computeRFFT () { if (! m_hdriRFFT.get()) m_hdriRFFT = boost::shared_ptr<HDRImage3f> (new HDRImage3f); uint2 size = (getSize()-uint2(0,1))*uint2(1,2); uint2 append = (getTotalSize()-uint2(0,1))*uint2(1,2)-size; if (size != m_hdriRFFT->getSize() || append != m_hdriRFFT->getAppendSize()) m_hdriRFFT->setSize (size, append); if (m_rfftplanNeedUpdate) { rfftplanUpdate (); m_rfftplanNeedUpdate = false; } m_hdriRFFT->setMult (getMult()/m_hdriRFFT->getTotalSize().getArea()); fftwf_execute (m_rfftplanR); fftwf_execute (m_rfftplanG); fftwf_execute (m_rfftplanB); return m_hdriRFFT; }
bool filter(Image_buffer<rendering::Color4>& destination, const Image_buffer<rendering::Color4>& source) const { if (destination.format() != source.format() || destination.dimensions() != source.dimensions()) { return false; } for (uint32_t y = 0; y < source.dimensions().y; ++y) { for (uint32_t x = 0; x < source.dimensions().x; ++x) { const rendering::Color4& source_color = source.get(uint2(x, y)); rendering::Color4 modulated(factor_ * source_color.r, factor_ * source_color.g, factor_ * source_color.b, 1.f); destination.set(uint2(x, y), modulated); } } return true; }
void copyHDRImage (HDRImage1f* hdriDst, HDRImage1f* hdriSrc, uint2 dstOrg, uint2 srcOrg, uint2 size) { uint offminx = -std::min<int>(dstOrg.x, std::min<int>(srcOrg.x,0)); uint offmaxx = size.x-std::min<uint>(hdriDst->getSize().x-dstOrg.x, std::min<uint> (hdriSrc->getSize().x-srcOrg.x, size.x)); uint sizex = size.x - offminx - offmaxx; uint sx = srcOrg.x + offminx; uint dx = dstOrg.x + offminx; uint sizeofLine = sizex*sizeof(float); for (uint y = 0; y < size.y; y++) { uint dy = dstOrg.y + y; uint sy = srcOrg.y + y; if (dy < 0 || dy >= hdriDst->getSize().y) continue; if (sy < 0 || sy >= hdriSrc->getSize().y) continue; memcpy (hdriDst->getBuffer (uint2(dx, dy)), hdriSrc->getBuffer (uint2 (sx, sy)), sizeofLine); } }
int code_table_4_230(unsigned char **sec) { int val, i; val = GB2_ProdDefTemplateNo(sec); switch (val) { case 40: case 41: case 42: case 43: i = uint2(sec[4]+11); break; default: i = -1; break; } return i; }
GpuFftCS4::GpuFftCS4(uint32_t width, uint32_t height, bool forward) : width_(width), height_(height), forward_(forward) { RenderFactory& rf = Context::Instance().RenderFactoryInstance(); src_ = rf.MakeVertexBuffer(BU_Dynamic, EAH_GPU_Read | EAH_GPU_Unordered | EAH_GPU_Structured, nullptr, EF_GR32F); src_->Resize(3 * width * height * sizeof(float) * 2); dst_ = rf.MakeVertexBuffer(BU_Dynamic, EAH_GPU_Read | EAH_GPU_Unordered | EAH_GPU_Structured, nullptr, EF_GR32F); dst_->Resize(3 * width * height * sizeof(float) * 2); tmp_buffer_ = rf.MakeVertexBuffer(BU_Dynamic, EAH_GPU_Read | EAH_GPU_Unordered | EAH_GPU_Structured, nullptr, EF_GR32F); tmp_buffer_->Resize(3 * width * height * sizeof(float) * 2); quad_layout_ = rf.MakeRenderLayout(); quad_layout_->TopologyType(RenderLayout::TT_TriangleStrip); float2 xyzs[] = { float2(-1, +1), float2(+1, +1), float2(-1, -1), float2(+1, -1) }; ElementInitData init_data; init_data.row_pitch = sizeof(xyzs); init_data.slice_pitch = 0; init_data.data = xyzs; GraphicsBufferPtr quad_vb = rf.MakeVertexBuffer(BU_Static, EAH_GPU_Read | EAH_Immutable, &init_data); quad_layout_->BindVertexStream(quad_vb, std::make_tuple(vertex_element(VEU_Position, 0, EF_GR32F))); tex_fb_ = rf.MakeFrameBuffer(); effect_ = SyncLoadRenderEffect("FFT.fxml"); buf2tex_tech_ = effect_->TechniqueByName("Buf2Tex"); radix008a_tech_ = effect_->TechniqueByName("FFTRadix008A4"); radix008a_first_tech_ = effect_->TechniqueByName("FFTRadix008AFirst4"); radix008a_final_tech_ = effect_->TechniqueByName("FFTRadix008AFinal4"); real_tex_ep_ = effect_->ParameterByName("real_tex"); imag_tex_ep_ = effect_->ParameterByName("imag_tex"); *(effect_->ParameterByName("input_buf")) = dst_; *(effect_->ParameterByName("tex_width_height")) = uint2(width, height); uint32_t n = width * height; *(effect_->ParameterByName("addr_offset")) = uint3(0 * n, 1 * n, 2 * n); *(effect_->ParameterByName("forward")) = static_cast<int32_t>(forward_); *(effect_->ParameterByName("scale")) = 1.0f / (width_ * height_); }
int CALLBACK MyFontFamProc(ENUMLOGFONTA FAR* lpelf, NEWTEXTMETRICA FAR* lpntm, int FontType, LPARAM lParam) { switch (lParam) { case FQ_NAMES: epptr->concatcstring(lpelf->elfLogFont.lfFaceName, EC_RETURN, nfonts++ == 0); break; case FQ_SIZES: if (!(FontType & TRUETYPE_FONTTYPE)) { //if not true-type font uint2 size = uint2((((lpelf->elfLogFont.lfHeight * 72) / SCREEN_WIDTH_FOR_FONT_USE) * 8 / 7)); uint2 i; for (i = 0; i < nfonts; i++) if (sizes[i] == size) return True; //return to callback function again MCU_realloc((char **)&sizes, nfonts, nfonts + 1, sizeof(uint2)); sizes[nfonts] = size; epptr->concatuint(size, EC_RETURN, nfonts++ == 0); break; } else { //if true-type font, size is always 0. epptr->concatuint(0, EC_RETURN, nfonts++ == 0); return False; //stop right here. no more callback function } case FQ_STYLES: { if (!(FontType & TRUETYPE_FONTTYPE)) { //not true-type font epptr->setstaticcstring("plain\nbold\nitalic\nbold-italic"); return False; //stop right here, do not continue looping through callback } char *style = (char *)lpelf->elfStyle; if (strequal(style, "Regular")) epptr->concatcstring("plain", EC_RETURN, nfonts++ == 0); else if (strequal(style, "Bold Italic")) epptr->concatcstring("bold-italic", EC_RETURN, nfonts++ == 0); else epptr->concatcstring((char*)lpelf->elfStyle, EC_RETURN, nfonts++ == 0); break; } default: break; } return True; }
void MCStack::setgeom() { if (MCnoui || !opened) return; // MW-2009-09-25: Ensure things are the right size when doing // remote dialog/menu windows. if (window == DNULL) { state &= ~CS_NEED_RESIZE; // MW-2011-08-18: [[ Redraw ]] Update to use redraw. MCRedrawLockScreen(); resize(rect . width, rect . height); MCRedrawUnlockScreen(); mode_setgeom(); return; } uint32_t wstyle, exstyle; getstyle(wstyle, exstyle); RECT newrect = getwrect(rect, wstyle, exstyle); RECT wrect; GetWindowRect((HWND)window->handle.window, &wrect); LONG cx = newrect.right - newrect.left; LONG cy = newrect.bottom - newrect.top; state &= ~CS_NEED_RESIZE; if (wrect.right - wrect.left != cx || wrect.bottom - wrect.top != cy || newrect.left != wrect.left || newrect.top != wrect.top) { state |= CS_NO_CONFIG; MoveWindow((HWND)window->handle.window, newrect.left, newrect.top, cx, cy, True); if (wrect.right - wrect.left != cx || wrect.bottom - wrect.top != cy) resize(uint2(wrect.right - wrect.left), uint2(wrect.bottom - wrect.top)); state &= ~CS_NO_CONFIG; } }
bool HDRImage3f::loadFromFile (cchar* pathname, uint2 appendMult, uint2 appendAdd) { if ((strlen(pathname)>4) && !(strcmp (".hdr", pathname+strlen(pathname)-4))) return loadFromHDRFile (pathname, appendMult, appendAdd); SDL_Surface* surf = IMG_Load (pathname); if (surf == NULL) return false; assert (surf->format->BitsPerPixel == 24 || surf->format->BitsPerPixel == 32); uint2 available = uint2 (surf->w, surf->h); uint2 append = available - available*appendMult + appendAdd; setSize (available, append); uint countReals = m_totalSize.getArea(); m_red = ::fftwf_alloc_real (countReals); m_green = ::fftwf_alloc_real (countReals); m_blue = ::fftwf_alloc_real (countReals); SDL_LockSurface (surf); uint width = surf->w; uint* outpix = (uint*) surf->pixels; uint2 size = getSize(); float* r = m_red; float* g = m_green; float* b = m_blue; uchar* inpix = ((uchar*)surf->pixels); uint offX = surf->format->BitsPerPixel / 8; for (uint y = 0; y < size.y; y++) { for (uint x = 0; x < size.x; x++) { uint offsetSrc = offX*x + y*surf->pitch; *r = ((float) inpix[offsetSrc+0])/256; *g = ((float) inpix[offsetSrc+1])/256; *b = ((float) inpix[offsetSrc+2])/256; r++; g++; b++; } r += m_appendSize.x; g += m_appendSize.x; b += m_appendSize.x; } SDL_UnlockSurface (surf); SDL_FreeSurface (surf); return true; }
void copyHDRImage (HDRImage3c* hdriDst, HDRImage1f* hdriSrc) { assert (hdriDst->getTotalSize () == hdriSrc->getTotalSize()/uint2(1,2)); uint2 size = hdriDst->getTotalSize (); { float* dst = (float*) hdriDst->getRedBuffer (); float* src = (float*) hdriSrc->getBuffer (); for (uint y = 0; y < size.y; y++) for (uint x = 0; x < size.x; x++) for (uint i = 0; i < 2; i++) { *dst = *src; dst++; src++; } } { float* dst = (float*) hdriDst->getGreenBuffer (); float* src = (float*) hdriSrc->getBuffer (); for (uint y = 0; y < size.y; y++) for (uint x = 0; x < size.x; x++) for (uint i = 0; i < 2; i++) { *dst = *src; dst++; src++; } } { float* dst = (float*) hdriDst->getBlueBuffer (); float* src = (float*) hdriSrc->getBuffer (); for (uint y = 0; y < size.y; y++) for (uint x = 0; x < size.x; x++) for (uint i = 0; i < 2; i++) { *dst = *src; dst++; src++; } } }
int f_hybrid(ARG0) { int pdtsize, n, secsize, k; if (mode >= 0) { pdtsize = prod_def_temp_size(sec); // size of PDT with no extra vert coordinates secsize = GB2_Sec4_size(sec); // size of PDT + vert coordinatese + extras n = uint2(&(sec[4][5])); // number of vert coordinate values if (n % 2 != 0) fatal_error_i("vertical coordinate parameters should be in pairs, n=%d", n); if (n == 0) return 0; if (pdtsize + 4*n > secsize) fatal_error("not enough space allocated for vertical coordinate data",""); sprintf(inv_out,"Hybrid levels=%d", n/2); inv_out += strlen(inv_out); for (k = 1; k <= n/2; k++) { sprintf(inv_out," %d=(%9.6f,%9.6f)", k, (double) ieee2flt(sec[4]+pdtsize+k*8-8), (double) ieee2flt(sec[4]+pdtsize+k*8-4)); inv_out += strlen(inv_out); } } return 0; }
GpuFftCS5::GpuFftCS5(uint32_t width, uint32_t height, bool forward) : width_(width), height_(height), forward_(forward) { RenderFactory& rf = Context::Instance().RenderFactoryInstance(); tmp_real_tex_[0] = rf.MakeTexture2D(width, height, 1, 1, EF_ABGR32F, 1, 0, EAH_GPU_Read | EAH_GPU_Unordered, nullptr); tmp_imag_tex_[0] = rf.MakeTexture2D(width, height, 1, 1, EF_ABGR32F, 1, 0, EAH_GPU_Read | EAH_GPU_Unordered, nullptr); tmp_real_tex_[1] = rf.MakeTexture2D(width, height, 1, 1, EF_ABGR32F, 1, 0, EAH_GPU_Read | EAH_GPU_Unordered, nullptr); tmp_imag_tex_[1] = rf.MakeTexture2D(width, height, 1, 1, EF_ABGR32F, 1, 0, EAH_GPU_Read | EAH_GPU_Unordered, nullptr); effect_ = SyncLoadRenderEffect("FFT.fxml"); radix008a_tech_ = effect_->TechniqueByName("FFTRadix008A5"); radix008a_final_x_tech_ = effect_->TechniqueByName("FFTRadix008AFinalX5"); radix008a_final_y_tech_ = effect_->TechniqueByName("FFTRadix008AFinalY5"); *(effect_->ParameterByName("tex_width_height")) = uint2(width - 1, height - 1); *(effect_->ParameterByName("forward")) = static_cast<int32_t>(forward_); *(effect_->ParameterByName("scale")) = 1.0f / (width_ * height_); }
#include "Image/Filter/To_BGRA.hpp" #include "Image_storage/Image_writer.hpp" #include "Math/Vector.inl" #include <QFileDialog> #include <QColorDialog> #include <QPixmap> #include <QProgressBar> #include <QMessageBox> QImage to_QImage(const Image_buffer<rendering::Color4c>& source); const std::string Main_window::s_settings_file_name = "settings.txt"; const uint2 Main_window::s_thumbnail_dimensions = uint2(192, 192); Main_window::Main_window(QWidget *parent) : QMainWindow(parent), ui(new Ui::Main_window), thumbnail_provider_(image_provider_, s_thumbnail_dimensions) { ui->setupUi(this); settings_.load(s_settings_file_name); ui->material_name_line_edit_->setText("Material_name"); ui->color_image_controls_->init(3, rendering::Color3(0.75f, 0.75f, 0.75f), true, &thumbnail_provider_); ui->opacity_image_controls_->init(1, rendering::Color3(1.f, 1.f, 1.f), true, &thumbnail_provider_); ui->emissive_image_controls_->init(1, rendering::Color3(0.f, 0.f, 0.f), true, &thumbnail_provider_);
/* * HEADER:400:JMA:inv:0:inventory for JMA locally defined PDT */ int f_JMA(ARG0) { int pdt, i, nr; int center; if (mode < 0) return 0; center = GB2_Center(sec); if (center != JMA1 && center != JMA2) return 0; pdt = GB2_ProdDefTemplateNo(sec); if (pdt < 50000) return 0; if (pdt == 51022) { sprintf(inv_out,"site=%c%c%c%c", sec[4][24], sec[4][25], sec[4][26], sec[4][27]); inv_out += strlen(inv_out); if (mode >= 1) { sprintf(inv_out,":site_id#=%u", uint2(sec[4]+28)); inv_out += strlen(inv_out); sprintf(inv_out,":site_lon=%lf:site_lat=%lf:site_elev=%.1lfm",int4(sec[4]+18)*1e-6, int4(sec[4]+14)*1e-6,int2(sec[4]+22)*0.1) ; inv_out += strlen(inv_out); sprintf(inv_out,":mag_dec=%.2fdeg", int2(sec[4]+30)*0.001); inv_out += strlen(inv_out); sprintf(inv_out,":freq=%ukHz", uint4(sec[4]+32)); inv_out += strlen(inv_out); sprintf(inv_out,":pol=%d:opn_mode=%d:reflec=%d", (int) sec[4][36], (int) sec[4][37], (int) sec[4][38]); inv_out += strlen(inv_out); sprintf(inv_out,":qc=%d:cluster_filter=%d", (int) sec[4][39], (int) sec[4][40]); inv_out += strlen(inv_out); sprintf(inv_out,":angle_elev_constant=%.2f", int2(sec[4]+41)*0.01); inv_out += strlen(inv_out); } nr = GB2_Sec4_size(sec); nr = (nr % 4) ? -1 : (nr - 60) / 4; if (mode >= 1) { sprintf(inv_out,":Ntheta=%d", nr); inv_out += strlen(inv_out); i = uint_n(sec[4]+55, 3); if (i != 0xffffff) { sprintf(inv_out,":bin_size=%dm", i); inv_out += strlen(inv_out); } if ((sec[4][58] != 255) || (sec[4][59] != 255)) { sprintf(inv_out,":d_theta=%.1lfdeg", int2(sec[4]+58)*0.1); inv_out += strlen(inv_out); } } if (mode < 2) { sprintf(inv_out,":ele(1)=%.2fdeg", int2(sec[4]+60)*0.01); inv_out += strlen(inv_out); sprintf(inv_out,":ele(%d)=%.2fdeg", nr/2,int2(sec[4]+60+((nr-1)/2)*4)*0.01); inv_out += strlen(inv_out); } if (mode >= 2) { sprintf(inv_out,"\n:elevation angle(1..Ntheta)="); inv_out += strlen(inv_out); for (i = 0; i < nr; i++) { sprintf(inv_out,"%.2f ", int2(sec[4]+60+i*4)*0.01); inv_out += strlen(inv_out); } sprintf(inv_out,"\n:pulse repetion freq(1..Ntheta)="); inv_out += strlen(inv_out); for (i = 0; i < nr; i++) { sprintf(inv_out,"%.2f ", int2(sec[4]+62+i*4)*0.01); inv_out += strlen(inv_out); } } } return 0; }
void GpuFftCS5::Execute(TexturePtr const & out_real, TexturePtr const & out_imag, TexturePtr const & in_real, TexturePtr const & in_imag) { RenderFactory& rf = Context::Instance().RenderFactoryInstance(); RenderEngine& re = rf.RenderEngineInstance(); FrameBufferPtr old_fb = re.CurFrameBuffer(); re.BindFrameBuffer(FrameBufferPtr()); int index = 0; // X direction { uint32_t istride = width_ / 8; float phase_base = -PI2 / width_; *(effect_->ParameterByName("ostride2")) = uint2(width_ / 8, 0); *(effect_->ParameterByName("iscale2")) = uint2(8, 1); *(effect_->ParameterByName("istride2")) = uint4(istride, 0, istride - 1, static_cast<uint32_t>(-1)); *(effect_->ParameterByName("phase_base2")) = phase_base; this->Radix008A(tmp_real_tex_[index], tmp_imag_tex_[index], in_real, in_imag, width_ / 8, height_, 1 == istride, false); index = !index; uint32_t t = width_; while (t > 8) { istride /= 8; phase_base *= 8; *(effect_->ParameterByName("istride2")) = uint4(istride, 0, istride - 1, static_cast<uint32_t>(-1)); *(effect_->ParameterByName("phase_base2")) = phase_base; this->Radix008A(tmp_real_tex_[index], tmp_imag_tex_[index], tmp_real_tex_[!index], tmp_imag_tex_[!index], width_ / 8, height_, 1 == istride, false); index = !index; t /= 8; } } // Y direction { uint32_t istride = height_ / 8; float phase_base = -PI2 / height_; *(effect_->ParameterByName("ostride2")) = uint2(0, height_ / 8); *(effect_->ParameterByName("iscale2")) = uint2(1, 8); *(effect_->ParameterByName("istride2")) = uint4(0, istride, static_cast<uint32_t>(-1), istride - 1); *(effect_->ParameterByName("phase_base2")) = phase_base; if (1 == istride) { this->Radix008A(out_real, out_imag, tmp_real_tex_[!index], tmp_imag_tex_[!index], width_, height_ / 8, false, 1 == istride); } else { this->Radix008A(tmp_real_tex_[index], tmp_imag_tex_[index], tmp_real_tex_[!index], tmp_imag_tex_[!index], width_, height_ / 8, false, 1 == istride); } index = !index; uint32_t t = height_; while (t > 8) { istride /= 8; phase_base *= 8; *(effect_->ParameterByName("istride2")) = uint4(0, istride, static_cast<uint32_t>(-1), istride - 1); *(effect_->ParameterByName("phase_base2")) = phase_base; if (1 == istride) { this->Radix008A(out_real, out_imag, tmp_real_tex_[!index], tmp_imag_tex_[!index], width_, height_ / 8, false, 1 == istride); } else { this->Radix008A(tmp_real_tex_[index], tmp_imag_tex_[index], tmp_real_tex_[!index], tmp_imag_tex_[!index], width_, height_ / 8, false, 1 == istride); } index = !index; t /= 8; } } re.BindFrameBuffer(old_fb); }
void GpuFftCS4::Execute(TexturePtr const & out_real, TexturePtr const & out_imag, TexturePtr const & in_real, TexturePtr const & in_imag) { RenderFactory& rf = Context::Instance().RenderFactoryInstance(); RenderEngine& re = rf.RenderEngineInstance(); tex_fb_->Attach(FrameBuffer::ATT_Color0, rf.Make2DRenderView(*out_real, 0, 1, 0)); tex_fb_->Attach(FrameBuffer::ATT_Color1, rf.Make2DRenderView(*out_imag, 0, 1, 0)); FrameBufferPtr old_fb = re.CurFrameBuffer(); re.BindFrameBuffer(FrameBufferPtr()); *real_tex_ep_ = in_real; *imag_tex_ep_ = in_imag; uint32_t const thread_count = 3 * (width_ * height_) / 8; uint32_t ostride = width_ * height_ / 8; uint32_t istride = ostride; uint32_t istride3 = height_ / 8; uint32_t pstride = width_; float phase_base = -PI2 / (width_ * height_); *(effect_->ParameterByName("thread_count")) = thread_count; // X direction *(effect_->ParameterByName("ostride")) = ostride; *(effect_->ParameterByName("pstride")) = pstride; *(effect_->ParameterByName("istride")) = istride; *(effect_->ParameterByName("istride3")) = uint2(0, istride3); *(effect_->ParameterByName("phase_base")) = phase_base; this->Radix008A(tmp_buffer_, src_, thread_count, istride, true); GraphicsBufferPtr buf[2] = { dst_, tmp_buffer_ }; int index = 0; uint32_t t = width_; while (t > 8) { istride /= 8; istride3 /= 8; phase_base *= 8.0f; *(effect_->ParameterByName("istride")) = istride; *(effect_->ParameterByName("istride3")) = uint2(0, istride3); *(effect_->ParameterByName("phase_base")) = phase_base; this->Radix008A(buf[index], buf[!index], thread_count, istride, false); index = !index; t /= 8; } // Y direction ostride = height_ / 8; pstride = 1; *(effect_->ParameterByName("ostride")) = ostride; *(effect_->ParameterByName("pstride")) = pstride; istride /= 8; istride3 /= 8; phase_base *= 8.0f; *(effect_->ParameterByName("istride")) = istride; *(effect_->ParameterByName("istride3")) = uint2(istride3, 0); *(effect_->ParameterByName("phase_base")) = phase_base; this->Radix008A(buf[index], buf[!index], thread_count, istride, false); index = !index; t = height_; while (t > 8) { istride /= 8; istride3 /= 8; phase_base *= 8.0f; *(effect_->ParameterByName("istride")) = istride; *(effect_->ParameterByName("istride3")) = uint2(istride3, 0); *(effect_->ParameterByName("phase_base")) = phase_base; this->Radix008A(buf[index], buf[!index], thread_count, istride, false); index = !index; t /= 8; } re.BindFrameBuffer(tex_fb_); re.Render(*buf2tex_tech_, *quad_layout_); re.BindFrameBuffer(old_fb); }
void drive_operation() { // Uint64 tests CQLValue a1(Uint64(10)); CQLValue a2(Uint64(15)); CQLValue a3(Uint64(25)); CQLValue a4(Uint64(30)); CQLValue a5(Uint64(150)); PEGASUS_TEST_ASSERT(a1 != a2); PEGASUS_TEST_ASSERT(a5 == a5); PEGASUS_TEST_ASSERT(a1 < a2); PEGASUS_TEST_ASSERT(a2 >= a1); PEGASUS_TEST_ASSERT(a1 <= a2); PEGASUS_TEST_ASSERT(a2 > a1); // Sint64 tests CQLValue b1(Sint64(10)); CQLValue b2(Sint64(15)); CQLValue b3(Sint64(25)); CQLValue b4(Sint64(30)); CQLValue b5(Sint64(150)); PEGASUS_TEST_ASSERT(b1 != b2); PEGASUS_TEST_ASSERT(b5 == b5); PEGASUS_TEST_ASSERT(b1 < b2); PEGASUS_TEST_ASSERT(b2 >= b1); PEGASUS_TEST_ASSERT(b1 <= b2); PEGASUS_TEST_ASSERT(b2 > b1); // Real64 tests CQLValue c1(Real64(10.00)); CQLValue c2(Real64(15.00)); CQLValue c3(Real64(25.00)); CQLValue c4(Real64(30.00)); CQLValue c5(Real64(150.00)); PEGASUS_TEST_ASSERT(c1 != c2); PEGASUS_TEST_ASSERT(c5 == c5); PEGASUS_TEST_ASSERT(c1 < c2); PEGASUS_TEST_ASSERT(c2 >= c1); PEGASUS_TEST_ASSERT(c1 <= c2); PEGASUS_TEST_ASSERT(c2 > c1); // Misc PEGASUS_TEST_ASSERT(a1 == b1); PEGASUS_TEST_ASSERT(a1 == c1); PEGASUS_TEST_ASSERT(b1 == a1); PEGASUS_TEST_ASSERT(b1 == c1); PEGASUS_TEST_ASSERT(c1 == a1); PEGASUS_TEST_ASSERT(c1 == b1); PEGASUS_TEST_ASSERT(a2 != b1); PEGASUS_TEST_ASSERT(a2 != c1); PEGASUS_TEST_ASSERT(b2 != a1); PEGASUS_TEST_ASSERT(b2 != c1); PEGASUS_TEST_ASSERT(c2 != a1); PEGASUS_TEST_ASSERT(c2 != b1); PEGASUS_TEST_ASSERT(a2 >= b1); PEGASUS_TEST_ASSERT(a2 >= c1); PEGASUS_TEST_ASSERT(b2 >= a1); PEGASUS_TEST_ASSERT(b2 >= c1); PEGASUS_TEST_ASSERT(c2 >= a1); PEGASUS_TEST_ASSERT(c2 >= b1); PEGASUS_TEST_ASSERT(a2 <= b3); PEGASUS_TEST_ASSERT(a2 <= c3); PEGASUS_TEST_ASSERT(b2 <= a3); PEGASUS_TEST_ASSERT(b2 <= c3); PEGASUS_TEST_ASSERT(c2 <= a3); PEGASUS_TEST_ASSERT(c2 <= b3); PEGASUS_TEST_ASSERT(a2 > b1); PEGASUS_TEST_ASSERT(a2 > c1); PEGASUS_TEST_ASSERT(b2 > a1); PEGASUS_TEST_ASSERT(b2 > c1); PEGASUS_TEST_ASSERT(c2 > a1); PEGASUS_TEST_ASSERT(c2 > b1); PEGASUS_TEST_ASSERT(a2 < b3); PEGASUS_TEST_ASSERT(a2 < c3); PEGASUS_TEST_ASSERT(b2 < a3); PEGASUS_TEST_ASSERT(b2 < c3); PEGASUS_TEST_ASSERT(c2 < a3); PEGASUS_TEST_ASSERT(c2 < b3); //Overflow testing CQLValue real1(Real64(0.00000001)); CQLValue sint1(Sint64(-1)); CQLValue uint1(Sint64(1)); CQLValue uint2(Uint64(0)); PEGASUS_TEST_ASSERT(uint1 > sint1); PEGASUS_TEST_ASSERT(real1 > sint1); PEGASUS_TEST_ASSERT(uint2 > sint1); PEGASUS_TEST_ASSERT(real1 > uint2); CQLValue real2(Real64(25.00000000000001)); CQLValue real3(Real64(24.99999999999999)); CQLValue sint2(Sint64(25)); CQLValue uint3(Uint64(25)); PEGASUS_TEST_ASSERT(real2 > real3); PEGASUS_TEST_ASSERT(real2 > sint2); PEGASUS_TEST_ASSERT(real2 > uint3); PEGASUS_TEST_ASSERT(real3 < sint2); PEGASUS_TEST_ASSERT(real3 < uint3); // String tests CQLValue d1(String("HELLO")); CQLValue d2(String("HEL")); CQLValue d3(String("LO")); CQLValue d4(String("AHELLO")); CQLValue d5(String("ZHELLO")); PEGASUS_TEST_ASSERT(d1 == d2 + d3); PEGASUS_TEST_ASSERT(d1 != d2 + d4); PEGASUS_TEST_ASSERT(d1 <= d5); PEGASUS_TEST_ASSERT(d1 < d5); PEGASUS_TEST_ASSERT(d1 >= d4); PEGASUS_TEST_ASSERT(d1 > d4); String str1("0x10"); String str2("10"); String str3("10B"); String str4("10.10"); CQLValue e1( str1, CQLValue::Hex); CQLValue e2( str2, CQLValue::Decimal); CQLValue e3( str3, CQLValue::Binary); CQLValue e4( str4, CQLValue::Real); CQLValue e5(Uint64(16)); CQLValue e6(Uint64(10)); CQLValue e7(Uint64(2)); CQLValue e8(Real64(10.10)); PEGASUS_TEST_ASSERT(e1 == e5); PEGASUS_TEST_ASSERT(e2 == e6); PEGASUS_TEST_ASSERT(e3 == e7); PEGASUS_TEST_ASSERT(e4 == e8); Array<Uint64> array1; array1.append(1); array1.append(2); array1.append(3); array1.append(4); array1.append(5); array1.append(6); array1.append(7); array1.append(8); array1.append(9); array1.append(10); Array<Sint64> array2; array2.append(1); array2.append(2); array2.append(3); array2.append(4); array2.append(5); array2.append(6); array2.append(7); array2.append(8); array2.append(9); array2.append(10); array2.append(3); Array<Real64> array3; array3.append(1.00); array3.append(2.00); array3.append(3.00); array3.append(9.00); array3.append(10.00); array3.append(3.00); array3.append(4.00); array3.append(5.00); array3.append(6.00); array3.append(7.00); array3.append(8.00); Array<Uint64> array4; array4.append(1); array4.append(23); array4.append(3); array4.append(4); array4.append(5); array4.append(6); array4.append(7); array4.append(88); array4.append(9); array4.append(10); Array<Sint64> array5; array5.append(-1); array5.append(2); array5.append(3); array5.append(4); array5.append(5); array5.append(-6); array5.append(7); array5.append(8); array5.append(9); array5.append(10); array5.append(-3); Array<Real64> array6; array6.append(1.23); array6.append(2.00); array6.append(3.00); array6.append(9.00); array6.append(10.00); array6.append(3.00); array6.append(4.14); array6.append(5.00); array6.append(6.00); array6.append(7.00); array6.append(8.00); CIMValue cv1(array1); CIMValue cv2(array2); CIMValue cv3(array3); CIMValue cv4(array4); CIMValue cv5(array5); CIMValue cv6(array6); CQLValue vr1(cv1); CQLValue vr2(cv1); CQLValue vr3(cv2); CQLValue vr4(cv3); CQLValue vr5(cv4); CQLValue vr6(cv5); CQLValue vr7(cv6); PEGASUS_TEST_ASSERT(vr1 == vr2); PEGASUS_TEST_ASSERT(vr1 == vr3); PEGASUS_TEST_ASSERT(vr1 == vr4); PEGASUS_TEST_ASSERT(vr4 == vr3); PEGASUS_TEST_ASSERT(vr1 != vr5); PEGASUS_TEST_ASSERT(vr3 != vr6); PEGASUS_TEST_ASSERT(vr4 != vr7); const CIMName _cimName(String("CIM_OperatingSystem")); CIMInstance _i1(_cimName); CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules"))); CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p4(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i1.addProperty(_p1); _i1.addProperty(_p2); _i1.addProperty(_p3); _i1.addProperty(_p4); CIMInstance _i2(_cimName); CIMProperty _p5(CIMName("Description"), CIMValue(String("Dave Rules Everything"))); CIMProperty _p6(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p7(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p8(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i2.addProperty(_p5); _i2.addProperty(_p6); _i2.addProperty(_p7); _i2.addProperty(_p8); CQLValue cql1(_i1); CQLValue cql2(_i1); CQLValue cql3(_i2); CQLValue cql4(_i2); //PEGASUS_TEST_ASSERT(cql1 == cql1); return; }
T &pixel(float2 uv) { uint2 coords = uint2(uv * float2(size)); return pixel<T>(coords); }
T &pixel(int2 coords) { return pixel<T>(uint2(max(int2(0), coords))); }
uint2 unnormalized(float2 uv) const { return uint2(uv * float2(size)); }
AppInputTest (string testName, int countRenders = 1): UnitTest (testName), m_sof(new SharedObjectsFactory(uint2(1024,768))) { //m_countRenders = countRenders; }