int main(int argc __attribute__((unused)), char *argv[]) { /* init allegro library */ ALLEGRO_TIMER *timer = NULL; al_init(); /* prepare random number generator */ srand(time(NULL)); /* activate all engine subsystems using the startup macro */ resetCollisionTable(); STARTUP(videoInit()) STARTUP(init_datafile(argv)) STARTUP(al_install_keyboard()) STARTUP(al_install_joystick()) STARTUP(fontInit()) STARTUP(setupSound()) timer = al_create_timer(1.0 / 60); al_start_timer(timer); initMediaLib(); initBuffers(); /* prepare game */ startGame(); /* begin game loop */ while(!state.terminate) { runState(timer); } /* finish, return control to os */ al_destroy_timer(timer); shutdownState(); shutdownGame(); videoKill(); shutdownSound(); al_uninstall_system(); PHYSFS_deinit(); /* no problems, exit false */ return EXIT_SUCCESS; }
int main(void) { DisableDog(); CPUinit(); EALLOW; outputEnable(); LCDinit(); LCDclear(); initADC(); DAC_init(); // SRAMwrite(0); // SRAMaddress = 0x260000; //shouldn't need SRAM here fft_init(); initBuffers(); timerINIT(ISRvalue, samplingRate); while(1){ if(sampleBufferFull){ fft.InBuf = &sampleBuffer[0]; int i; for(i = 0;i<FFT_SIZE;i++){ outBuffer[i] = 0; } for(i=0;i<FFT_SIZE/2;i++){ MagBuffer[i] = 0; } RFFT_f32(&fft); //fft.MagBuf = &sampleBuffer[0]; RFFT_f32_mag(&fft); sampleBufferFull = 0; EINT; } else{ //do nothing } } return 0; }
void PointCloudViewer::init() { glEnable(GL_POINT_SMOOTH); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); glEnable(GL_BLEND); glPointSize(3); glLineWidth(10); setMouseTracking(true); texid = bindTexture(QImage(rgbImg->ptr(), rgbImg->cols, rgbImg->rows, QImage::Format_RGB888), GL_TEXTURE_2D, GL_RGB, QGLContext::LinearFilteringBindOption); initBackground(); initLights(); initBuffers(); restoreStateFromFile(); setAnimationPeriod(10); startAnimation(); }
//initiate the turtle with the center at (x, y), orientation of turtle_angle void turtleInit(float x, float y, float angle) { float temp = 0; //angle for(int i = 0; i < turtle_points-3; ++i) { turtle[i].x = r*cos(temp*torad)+x; turtle[i].y = r*sin(temp*torad)+y; temp += 30; } turtle[turtle_points-3].x = r*cos(angle*torad)+x; turtle[turtle_points-3].y = r*sin(angle*torad)+y; turtle[turtle_points-2] = point2(r2*cos(angle*torad)+x, r2*sin(angle*torad)+y); turtle_angle = angle; turtle[turtle_brush] = point2(x, y); initBuffers(); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(turtle), turtle); }
void Worker::run() { try { registerSignalHandler(); initBuffers(); if(workType == QueueWorkType_DIRECT) workLoopDirectWork(); else workLoopAnyWork(); log.log(4, "Component stopped."); } catch(std::exception& e) { PThread::getCurrentThreadApp()->handleComponentException(e); } }
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnInitDialog( wxInitDialogEvent& event ) { m_skipCopyFromPanel = false; wxListItem columnLabel; columnLabel.SetImage( -1 ); columnLabel.SetText( _( "Name" ) ); fieldListCtrl->InsertColumn( COLUMN_FIELD_NAME, columnLabel ); columnLabel.SetText( _( "Value" ) ); fieldListCtrl->InsertColumn( COLUMN_TEXT, columnLabel ); m_staticTextUnitSize->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) ); m_staticTextUnitPosX->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) ); m_staticTextUnitPosY->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) ); initBuffers(); copySelectedFieldToPanel(); stdDialogButtonSizerOK->SetDefault(); }
int USBGrabber::open(const char* aDevPath, size_t *aWidth, size_t *aHeight, uint32_t *aFormat) { if (mFd != 0) { error("Device already opened"); return 0; } // Open capture device mFd = v4l2_open(aDevPath, O_RDWR | O_NONBLOCK, 0); if (mFd < 0) { error("Cannot open capturer device\n"); return 0; } if (!validateCaptureDevice()) return 0; if (!initCaptureFormat()) return 0; if (!setCaptureFormat(aWidth, aHeight, aFormat)) return 0; if (!getCaptureInfo()) return 0; if (!initBuffers()) return 0; if (!startStreaming()) return 0; return 1; }
int TSecurityChannelStream::attach(ISecurityChannel& aChannel) { if(isAttached()) detach(); if(!aChannel.isEstablished()) { __L_BAD(m_pLog, "Security session is not established!"); return -5; } int nResult = getStreamSizes(aChannel); if(nResult) { __L_BADH(m_pLog, "Error in getStreamSizes", nResult); return nResult; } nResult = initBuffers(); if(nResult) { __L_BADH(m_pLog, "Error in initBuffers", nResult); return nResult; } m_pSocketStream = ISocketStream::create(); nResult = m_pSocketStream->attach( *aChannel.getAttachedSocket()); if(nResult) { __L_BADH(m_pLog, "Cannot attach socket", nResult); return nResult; } m_pSecurityChannel = &aChannel; return 0; }
DLVHEX_NAMESPACE_BEGIN ProcessBuf::ProcessBuf() : std::streambuf(), #ifndef WIN32 process(-1), #endif bufsize(256) { #ifndef WIN32 // ignore SIGPIPE struct sigaction sa; sa.sa_handler = SIG_IGN; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); if (::sigaction(SIGPIPE, &sa, 0)) { ::perror("sigaction"); ::exit(1); } #endif initBuffers(); // don't call virtual methods in the ctor }
void AdaptiveManifoldFilterN::filter(InputArray src, OutputArray dst, InputArray joint) { CV_Assert(sigma_s_ >= 1 && (sigma_r_ > 0 && sigma_r_ <= 1)); num_pca_iterations_ = std::max(1, num_pca_iterations_); initBuffers(src, joint); curTreeHeight = tree_height_ <= 0 ? computeManifoldTreeHeight(sigma_s_, sigma_r_) : tree_height_; sigma_r_over_sqrt_2 = (float) (sigma_r_ / sqrt(2.0)); const double seedCoef = jointCn[0].at<float>(srcSize.height/2, srcSize.width/2); const uint64 baseCoef = numeric_limits<uint64>::max() / 0xFFFF; rnd.state = static_cast<int64>(baseCoef*seedCoef); Mat1b cluster0(srcSize, 0xFF); vector<Mat> eta0(jointCnNum); for (int i = 0; i < jointCnNum; i++) h_filter(jointCn[i], eta0[i], (float)sigma_s_); buildManifoldsAndPerformFiltering(eta0, cluster0, 1); gatherResult(src, dst); }
void EngineFilterButterworth8Band::setFrequencyCorners(double freqCorner1, double freqCorner2) { m_coef[0]= 1 * fid_design_coef(m_coef + 1, 16, "BpBu8", m_sampleRate, freqCorner1, freqCorner2, 0); initBuffers(); }
//============================================================================== void ResourceGroupImpl::init(const ResourceGroupInitInfo& init) { U resourcesCount = 0; U dynCount = 0; // Init textures & samplers m_textureNamesCount = 0; m_allSamplersZero = true; for(U i = 0; i < init.m_textures.getSize(); ++i) { if(init.m_textures[i].m_texture.isCreated()) { m_textureNames[i] = init.m_textures[i].m_texture->getImplementation().getGlName(); m_textureNamesCount = i + 1; ++resourcesCount; } else { m_textureNames[i] = 0; } if(init.m_textures[i].m_sampler.isCreated()) { m_samplerNames[i] = init.m_textures[i].m_sampler->getImplementation().getGlName(); m_allSamplersZero = false; ++resourcesCount; } else { m_samplerNames[i] = 0; } } // Init shader buffers initBuffers( init.m_uniformBuffers, m_ubos, m_ubosCount, resourcesCount, dynCount); initBuffers( init.m_storageBuffers, m_ssbos, m_ssbosCount, resourcesCount, dynCount); initBuffers(init.m_atomicBuffers, m_atomics, m_atomicsCount, resourcesCount, dynCount); // Init vert buffers m_vertBindingsCount = 0; for(U i = 0; i < init.m_vertexBuffers.getSize(); ++i) { const BufferBinding& binding = init.m_vertexBuffers[i]; if(binding.m_buffer.isCreated()) { ANKI_ASSERT(!binding.m_dynamic); m_vertBuffNames[i] = binding.m_buffer->getImplementation().getGlName(); m_vertBuffOffsets[i] = binding.m_offset; ++m_vertBindingsCount; ++resourcesCount; } else if(binding.m_dynamic) { ++dynCount; const GlState& state = getManager() .getImplementation() .getRenderingThread() .getState(); m_vertBuffNames[i] = state.m_dynamicMemoryManager.getGlName(BufferUsage::VERTEX); m_vertBuffOffsets[i] = MAX_U32; ++m_vertBindingsCount; m_hasDynamicVertexBuff = true; } else { m_vertBuffNames[i] = 0; m_vertBuffOffsets[i] = 0; } } // Init index buffer if(init.m_indexBuffer.m_buffer.isCreated()) { const BufferImpl& buff = init.m_indexBuffer.m_buffer->getImplementation(); ANKI_ASSERT(init.m_indexSize == 2 || init.m_indexSize == 4); m_indexBuffName = buff.getGlName(); m_indexSize = init.m_indexSize; ++resourcesCount; } ANKI_ASSERT((resourcesCount > 0 || dynCount > 0) && "Resource group empty"); // Hold references initResourceReferences(init, resourcesCount); }
void setFactor(int f) {_factor = f; _nbVertex = (int)pow(2, f) + 1; initTerrain(); initBuffers();}
int main(int argc, char *argv[]) { #ifdef ON_DEMAND int junk = 0; #endif #ifdef MODULE int new_sock; #endif /* return status of MPI functions */ MPI_Status status; /* number of pixels of the image */ int dim = 0; /* dimensions of the image */ int width, height; /* image count */ int num_image = 0, num_worker; /* time variables */ struct timeval tv1, tv2; /* fits of Gaussian */ double fit[DIM_FIT]; /* image representing Gaussian fit */ unsigned char *image = NULL; /* indexes */ int i = 0; /* Gauss matrix and vector have contiguous space in memory */ double *data = (double *) malloc(sizeof(double) * DIM_FIT * (DIM_FIT + 1)); gsl_matrix_view matrice = gsl_matrix_view_array(data, DIM_FIT, DIM_FIT); gsl_vector_view vettore = gsl_vector_view_array(data + (DIM_FIT * DIM_FIT), DIM_FIT); /********************************************************************* INIT *********************************************************************/ srand(time(NULL)); /* in order to recover from an error */ gsl_set_error_handler_off(); /* Initialize of MPI */ MPI_Init(&argc, &argv); /* check the input parameters */ if (argc != 3) { fprintf(stderr, "Invalid number of parameters\n"); MPI_Abort(MPI_COMM_WORLD, MPI_ERR_ARG); } /* Every process takes the own rank */ MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); /* Total number of processes */ MPI_Comm_size(MPI_COMM_WORLD, &p); /* check for the number of processes */ if (p <= PS) { fprintf(stderr, "Number of process not valid\n"); MPI_Abort(MPI_COMM_WORLD, MPI_ERR_OP); } /* number of workers */ num_worker = p - PS; /* first image is used to estimate gaussian parameters */ if (my_rank == EMITTER) { #ifdef DEBUG printf("Emitter with rank %d\n", my_rank); #endif #ifdef MODULE new_sock = Connect(); if (Read(new_sock, &width, sizeof(int)) < 0) error("Error reading the integers"); if (Read(new_sock, &height, sizeof(int)) < 0) error("Error reading the integers"); dim = width * height; image = (unsigned char *) malloc(dim); /* read from the socket */ if (Read(new_sock, image, dim) < 0) error("Error reading from socket"); #else /* an image representing the gaussian is created and returned as a unsigned char matrix */ width = atoi(argv[1]); height = atoi(argv[2]); image = createImage(width, height); #endif /* parameters of the gaussian are estimated */ initialization(image, width, height, fit); } /* broadcast data of the image */ MPI_Bcast(&width, 1, MPI_INT, EMITTER, MPI_COMM_WORLD); MPI_Bcast(&height, 1, MPI_INT, EMITTER, MPI_COMM_WORLD); MPI_Bcast(&fit, DIM_FIT, MPI_DOUBLE, EMITTER, MPI_COMM_WORLD); /* dimension of the image */ dim = width * height; /********************************************************************* EMITTER *********************************************************************/ if (my_rank == EMITTER) { for (i = 0; i < STREAMLENGTH; i++) { #ifdef DEBUG printf("Emitter sends image %d\n", i); #endif /* send to the workers the first images */ if (i < num_worker) { /* first image is sent to worker */ MPI_Send(image, dim, MPI_UNSIGNED_CHAR, i + PS, IMAGE, MPI_COMM_WORLD); } else { #ifdef ON_DEMAND /* ON_DEMAND */ /* receive the request */ MPI_Recv(&junk, 1, MPI_INT, MPI_ANY_SOURCE, REQUEST, MPI_COMM_WORLD, &status); /* send the image */ MPI_Send(image, dim, MPI_UNSIGNED_CHAR, status.MPI_SOURCE, IMAGE, MPI_COMM_WORLD); #else /* NOT ON_DEMAND */ MPI_Send(image, dim, MPI_UNSIGNED_CHAR, i % num_worker + PS, IMAGE, MPI_COMM_WORLD); #endif } #ifdef MODULE if (i < STREAMLENGTH - 1) { /* read from the socket */ if (Read(new_sock, image, dim) < 0) error("Error reading from socket"); } #endif } /* send the termination message */ for (i = PS; i < p; i++) MPI_Send(NULL, 0, MPI_INT, i, TERMINATION, MPI_COMM_WORLD); /********************************************************************* COLLECTOR *********************************************************************/ } else if (my_rank == COLLECTOR) { #ifdef DEBUG printf("Collector with rank %d\n", my_rank); #endif /* take the time */ gettimeofday(&tv1, NULL); i = 0; while (i < num_worker) { MPI_Recv(fit, DIM_FIT, MPI_DOUBLE, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); if (status.MPI_TAG == TERMINATION) { #ifdef DEBUG printf("Worker %d has ended\n", status.MPI_SOURCE); #endif i++; } else { num_image++; #ifdef DEBUG /* PRINTOUT OF THE CURRENT RESULT */ printf ("Image %d from worker %d: %f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n", num_image, status.MPI_SOURCE, fit[PAR_A], fit[PAR_X], fit[PAR_Y], fit[PAR_SX], fit[PAR_SY], fit[PAR_a], fit[PAR_b], fit[PAR_c]); #endif } } /* take the time */ gettimeofday(&tv2, NULL); /* print parallelism degree, data size and the completion time */ printf("%d\t%d\t%ld\n", p, dim, (tv2.tv_sec - tv1.tv_sec) * 1000000 + tv2.tv_usec - tv1.tv_usec); /********************************************************************* WORKER *********************************************************************/ } else { #ifdef DEBUG printf("Worker with rank %d\n", my_rank); #endif /* calculate number of pixels and initialize buffers for the fit */ dim = width * height; initBuffers(dim); image = (unsigned char *) malloc(dim); while (TRUE) { #ifdef ON_DEMAND /* send the request */ MPI_Send(&dim, 1, MPI_INT, EMITTER, REQUEST, MPI_COMM_WORLD); #endif /* blocking test of incoming message */ MPI_Probe(EMITTER, MPI_ANY_TAG, MPI_COMM_WORLD, &status); /* workers ends if receives termination message */ if (status.MPI_TAG == TERMINATION) { #ifdef DEBUG printf("Worker %d ends after %d images\n", my_rank, num_image); #endif /* last result is sent to the collector with a different TAG */ MPI_Send(fit, DIM_FIT, MPI_DOUBLE, COLLECTOR, TERMINATION, MPI_COMM_WORLD); freeBuffers(); break; } /* receive the image from the emitter */ MPI_Recv(image, dim, MPI_UNSIGNED_CHAR, EMITTER, IMAGE, MPI_COMM_WORLD, &status); /* calculation of the Gauss matrix and vector */ procedure(image, width, height, fit, matrice, vettore, 0); /* solve the system and adjust the fit vector */ postProcedure(matrice, vettore, fit); /* send the result to the collector */ MPI_Send(fit, DIM_FIT, MPI_DOUBLE, COLLECTOR, RESULTS, MPI_COMM_WORLD); } } /* Finalize of MPI */ MPI_Finalize(); return 0; }
void CUniCaptureThread::run() { emit setIsRunning( true ); init(); delayTime = 10; // initial delay time frameCounter = 0; frameTimer.start(); while( !*stopThread ) { if ( *readyToProcess == true ) { // Check resolution changes QRect screenGeometry = scr->geometry(); int nScreenWidth = screenGeometry.width(); int nScreenHeight = screenGeometry.height(); if ( nScreenWidth != ScreenWidth || nScreenHeight != ScreenHeight ) { ScreenWidth = nScreenWidth; ScreenHeight = nScreenHeight; cleanupBuffers(); initBuffers(); } // Creating and filling regions data CRegions * regions = new CRegions( settings->getHorizontalSegmentWidth( ScreenWidth ), settings->getHorizontalHeight( ScreenHeight ), settings->getVerticalWidth( ScreenWidth ), settings->getVerticalSegmentHeight( ScreenHeight ) ); // Horizontals // Top for ( unsigned short x = 0; x < settings->LEDnumH; x++ ) { QImage im = scr->grabWindow( desktopID, x * regions->hWidth, 0, regions->hWidth, regions->hHeight ).toImage(); unsigned char * bufH_tmp = new unsigned char[ bufHSize ]; memcpy( bufH_tmp, im.bits(), bufHSize ); regions->regionHTop.push_back( bufH_tmp ); } // Bottom for ( unsigned short x = 0; x < settings->LEDnumH; x++ ) { QImage im = scr->grabWindow( desktopID, x * regions->hWidth, ScreenHeight - regions->hHeight, regions->hWidth, regions->hHeight ).toImage(); unsigned char * bufH_tmp = new unsigned char[ bufHSize ]; memcpy( bufH_tmp, im.bits(), bufHSize ); regions->regionHBottom.push_back( bufH_tmp ); } // Verticals // Left for ( int x = 0; x < settings->LEDnumV; x++ ) { QImage im = scr->grabWindow( desktopID, 0, x * regions->vHeight, regions->vWidth, regions->vHeight ).toImage(); unsigned char * bufV_tmp = new unsigned char[ bufVSize ]; memcpy( bufV_tmp, im.bits(), bufVSize ); regions->regionVLeft.push_back( bufV_tmp ); } // Right for ( int x = 0; x < settings->LEDnumV; x++ ) { QImage im = scr->grabWindow( desktopID, ScreenWidth - regions->vWidth, x * regions->vHeight, regions->vWidth, regions->vHeight ).toImage(); unsigned char * bufV_tmp = new unsigned char[ bufVSize ]; memcpy( bufV_tmp, im.bits(), bufVSize ); regions->regionVRight.push_back( bufV_tmp ); } *readyToProcess = false; emit onImageCaptured( regions ); ++frameCounter; updateDelayTime(); } usleep( delayTime ); } cleanup(); emit setIsRunning( false ); //*stopThread = true; }
int main(int argc, char *argv[]) { /* pixels per worker */ int ppw = 0; /* number of workers */ int num_worker; /* pixels of the entire image */ int dim; /* dimension of the entire image */ int width,height; /* time variables */ struct timeval tv1, tv2; /* Dimension of the partitioned image */ int dimx = 0, dimy = 0; /* fit of the Gaussian */ double fit[DIM_FIT]; /* image representing Gaussian fit */ unsigned char *image = NULL; #ifdef PADDED /* buffer for the padded image */ unsigned char *padded = NULL; #endif #ifdef MODULE /* socket for the camera */ int new_sock; #endif /* local partition of the image*/ unsigned char *partition; /* size of reduce buffer */ int buffer_size = DIM_FIT * (DIM_FIT + 1); /* indexes */ int i = 0; /* buffer for fit procedure */ double *data = (double *) malloc( sizeof(double) * buffer_size ); gsl_matrix_view matrice = gsl_matrix_view_array(data, DIM_FIT, DIM_FIT); gsl_vector_view vettore = gsl_vector_view_array(data + (DIM_FIT * DIM_FIT), DIM_FIT); /* output buffer of reduce */ double *ret = (double *) malloc( sizeof(double) * buffer_size ); gsl_matrix_view r_matrice = gsl_matrix_view_array(ret, DIM_FIT, DIM_FIT); gsl_vector_view r_vettore = gsl_vector_view_array(ret + (DIM_FIT * DIM_FIT), DIM_FIT); /********************************************************************* INIT *********************************************************************/ srand(time(NULL)); /* in order to recover from an error */ gsl_set_error_handler_off(); /* Initialize of MPI */ MPI_Init(&argc, &argv); /* Check the input parameters */ if (argc != 3) { fprintf(stderr, "Invalid number of parameters: %d\n",argc); MPI_Abort(MPI_COMM_WORLD,MPI_ERR_ARG); } /* Every process takes their own rank */ MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); /* Total number of processes */ MPI_Comm_size(MPI_COMM_WORLD, &p); /* Number of workers */ num_worker = p - PS; if (my_rank == EMITTER) { #if DEBUG printf("Emitter with rank %d\n", my_rank); #endif #ifdef MODULE new_sock = Connect(); if (Read(new_sock, &width, sizeof(int)) < 0) error("Error reading the integers"); if (Read(new_sock, &height, sizeof(int)) < 0) error("Error reading the integers"); dim = width * height; image = (unsigned char *) malloc (dim); /* read from the socket */ if (Read(new_sock, image, dim) < 0) error("Error reading from socket"); #else /* an image representing the gaussian is created and returned as a unsigned char matrix */ width = atoi(argv[1]); height = atoi(argv[2]); /* y dimension of the image is adjusted (if needed) */ while (height % num_worker != 0) height++; /* image is created */ image = createImage(width, height); #endif /* parameters of the gaussian are estimated */ initialization(image, width, height,fit); #if DEBUG printf("Emitter survived init\n"); #endif } /* broadcast data of the image */ MPI_Bcast(&width,1,MPI_INT,EMITTER,MPI_COMM_WORLD); MPI_Bcast(&height,1,MPI_INT,EMITTER,MPI_COMM_WORLD); MPI_Bcast(&fit,DIM_FIT,MPI_DOUBLE,EMITTER,MPI_COMM_WORLD); /* dimension of the local partition are determined and relative buffers are initialized */ dim = width * height; dimx = width; dimy = height / num_worker; ppw = dimx * dimy; partition = (unsigned char *) malloc(sizeof(unsigned char) * ppw); initBuffers(ppw); /* if I am the emitter I take the time */ if (my_rank == EMITTER) gettimeofday(&tv1, NULL); #ifdef PADDED if (my_rank == EMITTER){ padded =(unsigned char*) malloc(sizeof(unsigned char) * ppw * p); for (i=0; i < dim; i++){ padded[i + ppw] = image[i]; } for(i=0;i<DIM_FIT * (DIM_FIT + 1);i++){ ret[i] = 0; } free(image); image = padded; } #endif /********************************************************************* LOOP on ELEMENTS *********************************************************************/ for (i = 0; i < STREAMLENGTH; i++) { /* the emitter executes the scatter */ MPI_Scatter(image, ppw, MPI_UNSIGNED_CHAR, partition, ppw, MPI_UNSIGNED_CHAR, EMITTER, MPI_COMM_WORLD); /* execute the procedure over my partition */ if(my_rank >= PS){ procedure(partition, dimx, dimy , fit, matrice, vettore, dimy*(my_rank-PS)); } /* execute the reduce of matrix and vector */ MPI_Reduce(data, ret, buffer_size , MPI_DOUBLE, MPI_SUM, EMITTER, MPI_COMM_WORLD); if (my_rank == EMITTER) { /* adjust fit results */ postProcedure(r_matrice,r_vettore,fit); } /* broadcast of the result */ MPI_Bcast(fit, DIM_FIT, MPI_DOUBLE, EMITTER, MPI_COMM_WORLD); #ifdef DEBUG if (my_rank == EMITTER) { printf("Image %d: %f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n", i, fit[PAR_A], fit[PAR_X], fit[PAR_Y], fit[PAR_SX], fit[PAR_SY], fit[PAR_a], fit[PAR_b], fit[PAR_c]); } #endif #ifdef MODULE if (my_rank == EMITTER && i < STREAMLENGTH - 1) { /* new image is stored in buffer image of the emitter*/ #ifdef PADDED if (Read(new_sock, image + ppw, dim) < 0) error("Error reading from socket"); #else if (Read(new_sock, image, dim) < 0) error("Error reading from socket"); #endif } #endif } if (my_rank == EMITTER) { gettimeofday(&tv2, NULL); /* print the parallelism degree, data size and the completion time */ printf("%d\t%d\t%ld\n", p, dim, (tv2.tv_sec - tv1.tv_sec) * 1000000 + tv2.tv_usec - tv1.tv_usec); } freeBuffers(); /* Finalize of MPI */ MPI_Finalize(); return 0; }
PointSpritesGeometry::PointSpritesGeometry() { m_program =0; m_type =GL_POINTS; initBuffers(); }
bool graphics::line_batcher::create() { return initShaders() && initBuffers(); }
BufferRecorderNode::BufferRecorderNode( size_t numFrames, const Format &format ) : SampleRecorderNode( format ), mLastOverrun( 0 ) { initBuffers( numFrames ); }
BufferRecorderNode::BufferRecorderNode( const Format &format ) : SampleRecorderNode( format ), mLastOverrun( 0 ) { initBuffers( DEFAULT_RECORD_BUFFER_FRAMES ); }
void EngineFilterButterworth8High::setFrequencyCorners(double freqCorner1) { m_coef[0] = 1 * fid_design_coef(m_coef + 1, 8, "HpBu8", m_sampleRate, freqCorner1, 0, 0); initBuffers(); }
void Skybox::reload() { initBuffers(); }
void init(void) { // modified to include IdxBufObj also 26 Jan initBuffers(); initShaders(); initRendering(); }
void init(void) { initBuffers(); initShaders(); initRendering(); }
void GLFramebuffer::initBuffers(int w, int h) { initBuffers(w, h, GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER); }
DrawMesh::DrawMesh( Mesh* m, char* texturePath, ID3D11Device* device ) { _mesh = m; initBuffers( device ); }
int main(int argc, char** argv) { char *outfilename = "outfile"; int reclength= -1; // reclength in secs char c; ///////////////////////////////////////////////////// // CHECKING AND INTERPRETING COMMAND LINE SWITCHES ///////////////////////////////////////////////////// printf("\n*********************************************************************\n"); printf("\n FFV1rec based on nuppelrec by Roman Hochleitner"); printf("\n version "_VERSION_"\n"); printf("\n*********************************************************************\n"); quiet = 0; avcodec_init(); avcodec_register_all(); recordaudio = 1; memset(&ainfo,0,sizeof(ainfo)); ainfo.frequency=44100; tzone.tz_minuteswest=-60; // whatever tzone.tz_dsttime=0; now.tv_sec=0; // reset now.tv_usec=0; // reset parseRcFile(); while ((c=getopt(argc,argv,"d:b:M:q:l:c:C:S:W:H:t:NTV:A:a:srf:pnb:x:y:zQ2")) != -1) { switch(c) { case '2': do_split=1;break; case 'b': ainfo.frequency=atoi(optarg);break; case 'q': info.quality = atoi(optarg); break; case 'd': if(!(info.keydist = atoi(optarg))) info.keydist=1; break; case 'M': info.me = atoi(optarg); break; case 'S': info.channel = atoi(optarg); break; case 'W': info.width = atoi(optarg); break; case 'H': info.height = atoi(optarg); break; case 't': drec = atof(optarg); break; case 'x': videomegs = atoi(optarg); break; case 'C': if(!FFV1_selectByName(optarg)) { printf("\n cannot find this codec\n"); exit(0); };break; case 'y': audiomegs = atoi(optarg); break; case 'p': info.ntsc = 0; break; case 'n': info.ntsc = 1; break; case 's': info.ntsc = 0; info.secam=1; break; case 'f': info.frequency = atof(optarg); break; case 'z': recordaudio = 0;printf("\n Audio disabled\n"); break; case 'A': audiodevice = optarg; break; case 'V': videodevice = optarg; break; case 'Q': quiet = 1; break; case 'h': usage(); break; default: usage(); } } if (optind==argc) usage(); else outfilename=argv[optind]; if (drec != -1.0) { reclength = (int)(drec*60); } if(info.width==0) { info.width=352; } if(info.height==0) { if(info.ntsc) info.height=240; else info.height=288; } ///////////////////////////////////////////// // CALCULATE BUFFER SIZES ///////////////////////////////////////////// video_buffer_size=(info.height*info.width*3)>>1 ; if (videomegs == -1) { if (info.width>=480 || info.height>288) { videomegs = 64; //drRocket -> helps megs for big ones } else { videomegs = 14; // normally we don't need more than that } } video_buffer_count = (videomegs*1024*1024)/video_buffer_size; // we have to detect audio_buffer_size, too before initshm() // or we crash horribly later, if no audio is recorded we // don't change the value of 16384 if (recordaudio) { if (!audioDevPreinit(audiodevice,&ainfo)) { fprintf(stderr,"error: could not detect audio blocksize, audio recording disabled\n"); recordaudio = 0; } } if (audiomegs==-1) audiomegs=2; if (ainfo.bufferSize!=0) audio_buffer_count = (audiomegs*1000*1000)/ainfo.bufferSize; else audio_buffer_count = 1; fprintf(stderr, "we are using %dx%ldB video (frame-) buffers and\n %dx%ldB audio blocks\n audio fq=%ld\n", video_buffer_count, video_buffer_size, audio_buffer_count, ainfo.bufferSize, ainfo.frequency ); initBuffers(); ///////////////////////////////////////////// // NOW START WRITER/ENCODER PROCESS ///////////////////////////////////////////// writeInit(&info); PTHR *wr; wr=(PTHR *)&write_process; pthread_create(&pid_write,0,wr,outfilename); /////////////////////////// // now save the start time gettimeofday(&stm, &tzone); // #ifndef TESTINPUT ///////////////////////////////////////////// // NOW START AUDIO RECORDER ///////////////////////////////////////////// if (recordaudio) { printf("Initializing audio...\n"); if(! initAudioDev(audiodevice,&ainfo)) { fprintf(stderr, "cannot initialize audio!\n"); exit(-1); } PTHR *aud; aud=(PTHR *)&captureAudioDev; pthread_create(&pid_audio,0,aud,NULL); } else { printf("No audio.\n"); } // #endif ///////////////////////////////////////////// // NOW START VIDEO RECORDER ///////////////////////////////////////////// // only root can do this if (getuid()==0) nice(-10); if( !initVideoDev(videodevice, &info )) { printf(" Cannot init video input\n"); exit(0); } captureVideoDev(); return 0; }
DrawMesh::DrawMesh( std::vector<vec3> v, std::vector<vec3> n, std::vector<vec3> u, Face f, char* texFile, ID3D11Device* device ) { _mesh = new Mesh( v, n, u, f ); initBuffers( device ); }
void CGDISimpleThread::run() { emit setIsRunning( true ); init(); delayTime = 10; // initial delay time frameCounter = 0; frameTimer.start(); while( !*stopThread ) { if ( *readyToProcess == true ) { // Check for resolution changes int nScreenWidth = GetSystemMetrics(SM_CXSCREEN); int nScreenHeight = GetSystemMetrics(SM_CYSCREEN); if ( nScreenWidth != ScreenWidth || nScreenHeight != ScreenHeight ) { ScreenWidth = nScreenWidth; ScreenHeight = nScreenHeight; cleanupBuffers(); initBuffers(); } // Creating and filling regions data CRegions * regions = new CRegions( settings->getHorizontalSegmentWidth( ScreenWidth ), settings->getHorizontalHeight( ScreenHeight ), settings->getVerticalWidth( ScreenWidth ), settings->getVerticalSegmentHeight( ScreenHeight ) ); // Horizontals SelectObject( hCaptureDC, hCaptureBitmapH ); // Top for ( unsigned short x = 0; x < settings->LEDnumH; x++ ) { BitBlt( hCaptureDC, 0, 0, regions->hWidth, regions->hHeight, hDesktopDC, x * regions->hWidth, 0, SRCCOPY|CAPTUREBLT ); GetBitmapBits( hCaptureBitmapH, bufHSize, bufH ); unsigned char * bufH_tmp = new unsigned char[ bufHSize ]; memcpy( bufH_tmp, bufH, bufHSize ); regions->regionHTop.push_back( bufH_tmp ); } // Bottom for ( unsigned short x = 0; x < settings->LEDnumH; x++ ) { BitBlt( hCaptureDC, 0, 0, regions->hWidth, regions->hHeight, hDesktopDC, x * regions->hWidth, ScreenHeight - regions->hHeight, SRCCOPY|CAPTUREBLT ); GetBitmapBits( hCaptureBitmapH, bufHSize, bufH ); unsigned char * bufH_tmp = new unsigned char[ bufHSize ]; memcpy( bufH_tmp, bufH, bufHSize ); regions->regionHBottom.push_back( bufH_tmp ); } // Verticals SelectObject(hCaptureDC,hCaptureBitmapV); // Left for ( int x = 0; x < settings->LEDnumV; x++ ) { BitBlt( hCaptureDC, 0, 0, regions->vWidth, regions->vHeight, hDesktopDC, 0, x * regions->vHeight, SRCCOPY|CAPTUREBLT ); GetBitmapBits( hCaptureBitmapV, bufVSize, bufV ); unsigned char * bufV_tmp = new unsigned char[ bufVSize ]; memcpy( bufV_tmp, bufV, bufVSize ); regions->regionVLeft.push_back( bufV_tmp ); } // Right for ( int x = 0; x < settings->LEDnumV; x++ ) { BitBlt( hCaptureDC, 0, 0, regions->vWidth, regions->vHeight, hDesktopDC, ScreenWidth - regions->vWidth, x * regions->vHeight, SRCCOPY|CAPTUREBLT ); GetBitmapBits( hCaptureBitmapV, bufVSize, bufV ); unsigned char * bufV_tmp = new unsigned char[ bufVSize ]; memcpy( bufV_tmp, bufV, bufVSize ); regions->regionVRight.push_back( bufV_tmp ); } *readyToProcess = false; emit onImageCaptured( regions ); ++frameCounter; updateDelayTime(); } usleep( delayTime ); } cleanup(); emit setIsRunning( false ); //*stopThread = true; }