void DXSampleWidget::update() { // Get time since last frame m_frameTime = m_timer->restart(); // Use this when disabling vsync // qDebug() << m_timer->nsecsElapsed(); // Calculate frames per second ++m_frames; m_elapsedTime += m_frameTime; if (m_elapsedTime >= 1000) { emit fps(m_frames); m_frames = 0; m_elapsedTime = 0; } // Rotate the model? if (m_animating) { static float rotation = 0.0f; rotation += 0.001f * m_frameTime; if (rotation >= 2 * (float)D3DX_PI) rotation -= 2 * (float)D3DX_PI; m_model->setRotation(m_model->getRotation().x, rotation, m_model->getRotation().z); } // Render the scene render(); }
void display (void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the color buffer and the depth buffer glLoadIdentity(); //gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); gluLookAt (xpos, ypos, xpos, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); //camera position, x,y,z, looking at x,y,z, Up Positions of the camera camera(); fps(); player_position(); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(3, GL_FLOAT, 0, quad); glColorPointer(3, GL_FLOAT, 0, colors); glPushMatrix(); glTranslatef(0.0f, 0.0f, -5.0f); glDrawArrays(GL_QUADS, 0, 4); glPopMatrix(); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glFlush(); glutSwapBuffers(); //swap the buffers angle++; //increase the angle }
void main() { unsigned char *data; allocDoubleBuffer_vbe(); sys_VBEstart(); SCREEN =sys_giveSCREEN(); allocDoubleBuffer_vbe(); memset(SCREEN, 10, 1024*768*4); OSMesaContext gl_ctx = OSMesaCreateContext(OSMESA_BGRA, NULL); if(!OSMesaMakeCurrent(gl_ctx, DOUBLEBUFFER_vbe, GL_UNSIGNED_BYTE, 1024,768)) sys_reboot(); OSMesaPixelStore(OSMESA_Y_UP, 0); reshape(1024,768); init(); int i; for(i = 0; i < 20000; i++) { angle += 6; draw(); SwapBuffers_vbe(); } fps(); }
/* * Draw info strings on screen, like FPS */ void CLGLWindowDrawInfo(void) { if(CLGLWindow::showInfo == true){ std::stringstream fps(std::stringstream::in | std::stringstream::out); std::stringstream simTime(std::stringstream::in | std::stringstream::out); static std::stringstream pause(std::stringstream::in | std::stringstream::out); static std::stringstream kernel(std::stringstream::in | std::stringstream::out); pause.seekp(std::ios::beg); kernel.seekp(std::ios::beg); // Draw FPS fps << "FPS: " << CLGLWindow::fps; CLGLWindowDrawString(fps.str().c_str(), 1, CLGLWindow::window_height-CLGLWindow::fontSize, CLGLWindow::stringColor, CLGLWindow::font); // Draw How many particles are beeing simulated and if it is paused if(CLGLWindow::play == ON){ pause << "Simulating " << CLGLWindow::NumParticles << " Particles"; CLGLWindowDrawString(pause.str().c_str(), 1, 33, CLGLWindow::stringColor, CLGLWindow::font); } else{ CLGLWindowDrawString("Paused", 1, 33, CLGLWindow::stringColor, CLGLWindow::font); } // Draw Current Kernel in Use kernel << "Kernel: Gravity with Runge Kutta " << CLGLSim::curKernel << std::endl; CLGLWindowDrawString(kernel.str().c_str(), 1, 7, CLGLWindow::stringColor, CLGLWindow::font); } }
astra_status_t device_stream<TFrameWrapper>::on_open() { if (is_open()) return astra_status_t::ASTRA_STATUS_SUCCESS; LOG_INFO("orbbec.mocks.device_stream", "creating mock stream of type: %d", description().type()); LOG_INFO("orbbec.mocks.device_stream", "created mock stream of type: %d", description().type()); LOG_INFO("orbbec.mocks.device_stream", "stream type %d supports modes:", description().type()); for(auto it = deviceStream_->modes_begin(); it != deviceStream_->modes_end(); ++it) { auto mode = *it; LOG_INFO("orbbec.mocks.device_stream", "mode: %ux%ux%u@%u pf:%u", mode.width(), mode.height(), mode.bytesPerPixel(), mode.fps(), mode.pixelFormat()); } set_mode(deviceStream_->active_mode()); return astra_status_t::ASTRA_STATUS_SUCCESS; }
inline std::ostream& FpsCounter::print(std::ostream& os) { os << std::fixed << std::setprecision(2); os << fps() << " fps."; os << std::scientific; return os; }
void Window::timer(int state) { fps(); CALL(OnFrame); for (set<Window *>::iterator it = windows.begin(); it != windows.end(); ++it) (*it)->resized = false; glutTimerFunc((int) (1000 / GameSpeed), Window::timer, 0); }
Window::Window() : mDisplayMode(DEFAULT_BUF), mASAP(false), mVSync(true) { implCtor(); // must call first! dimensions(Dim(800,600)); fps(40); append(inputEventHandler()); append(windowEventHandler()); }
int64_t FFmpegInput::time_stamp(int pos) const { int64_t timestamp = static_cast<int64_t>((static_cast<double> (pos) / fps()) * AV_TIME_BASE); if (static_cast<int64_t> (m_format_context->start_time) != AV_NOPTS_VALUE) { timestamp += m_format_context->start_time; } return timestamp; }
int64_t FFmpegInput::time_stamp(int frame) const { int64_t timestamp = static_cast<int64_t>((static_cast<double> (frame) / (fps() * av_q2d(m_format_context->streams[m_video_stream]->time_base))) ); if (static_cast<int64_t>(m_format_context->start_time) != int64_t(AV_NOPTS_VALUE)) { timestamp += static_cast<int64_t>(static_cast<double> (m_format_context->start_time)*AV_TIME_BASE/av_q2d(m_format_context->streams[m_video_stream]->time_base)); } return timestamp; }
void FFmpegInput::read_frame(int frame) { if (m_last_decoded_pos + 1 != frame ) { seek (frame); } AVPacket pkt; int finished = 0; int ret = 0; while ((ret = av_read_frame (m_format_context, &pkt)) == 0 || m_codec_cap_delay ) { if (pkt.stream_index == m_video_stream) { if (ret < 0 && m_codec_cap_delay) { pkt.data = NULL; pkt.size = 0; } avcodec_decode_video2 (m_codec_context, m_frame, &finished, &pkt); double pts = 0; if (static_cast<int64_t>(m_frame->pkt_pts) != int64_t(AV_NOPTS_VALUE)) { pts = av_q2d (m_format_context->streams[m_video_stream]->time_base) * m_frame->pkt_pts; } int current_frame = int((pts-m_start_time) * fps() + 0.5f); //??? //current_frame = m_frame->display_picture_number; m_last_search_pos = current_frame; if( current_frame == frame && finished) { avpicture_fill ( reinterpret_cast<AVPicture*>(m_rgb_frame), &m_rgb_buffer[0], AV_PIX_FMT_RGB24, m_codec_context->width, m_codec_context->height ); sws_scale ( m_sws_rgb_context, static_cast<uint8_t const * const *> (m_frame->data), m_frame->linesize, 0, m_codec_context->height, m_rgb_frame->data, m_rgb_frame->linesize ); m_last_decoded_pos = current_frame; av_free_packet (&pkt); break; } } av_free_packet (&pkt); } m_read_frame = true; }
int main( int argc, char* args[] ){ StopWatch fps(0.2); SDL_Event event; SDL_Rect camera = { 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT }; //Initialize if( init() == false ) { std::cerr<<"Init fail"<<std::endl; return 1; } //Load the files if( load_files() == false ){ std::cerr<<"Load file fail"<<std::endl; return 1; } //Continuous key press // if(SDL_EnableKeyRepeat(200,200)<0) return 1; MenuScreen * menu_screen = new MenuScreen(); ScreenController * screen_controller = new ScreenController(menu_screen); //While the user hasn't quit fps.start(); while( QUIT == false ){ while( SDL_PollEvent( &event )){ if( event.type == SDL_QUIT )QUIT = true; } if (fps.is_timeup()) { screen_controller->handle_input(event); screen_controller->animate(); fps.start(); } screen_controller->show(camera, menuSheet, screen); //Update the screen if( SDL_Flip( screen ) == -1 ){ return 1; } } //Clean up delete screen_controller; clean_up(); return 0; }
void RendererSettings::accept() { if ( width() <= 0 || height() <= 0 || outputFileName().isEmpty() == true || fps() <= .0f ) { QMessageBox::warning( this, "Invalid parameters", "Please enter valid rendering parameters" ); } else QDialog::accept(); }
TEST_F( VideoTracks, FetchTracks ) { auto f = std::static_pointer_cast<Media>( ml->addMedia( "file.avi" ) ); f->addVideoTrack( "H264", 1920, 1080, 3000, 100, 5678, 16, 10, "l1", "d1" ); f->addVideoTrack( "VP80", 640, 480, 3000, 100, 9876, 16, 9, "l2", "d2" ); // Testing fetch from initially created instance: auto ts = f->videoTracks()->all(); ASSERT_EQ( ts.size(), 2u ); auto t2 = ts[0]; ASSERT_EQ( t2->codec(), "H264" ); ASSERT_EQ( t2->width(), 1920u ); ASSERT_EQ( t2->height(), 1080u ); ASSERT_EQ( t2->fps(), 30.0f ); ASSERT_EQ( t2->fpsNum(), 3000u ); ASSERT_EQ( t2->fpsDen(), 100u ); ASSERT_EQ( t2->bitrate(), 5678u ); ASSERT_EQ( t2->sarNum(), 16u ); ASSERT_EQ( t2->sarDen(), 10u ); ASSERT_EQ( t2->language(), "l1" ); ASSERT_EQ( t2->description(), "d1" ); // Reload from DB Reload(); auto m = ml->media( f->id() ); ASSERT_NE( nullptr, m ); ts = m->videoTracks()->all(); ASSERT_EQ( ts.size(), 2u ); t2 = ts[0]; ASSERT_EQ( t2->codec(), "H264" ); ASSERT_EQ( t2->width(), 1920u ); ASSERT_EQ( t2->height(), 1080u ); ASSERT_EQ( t2->fps(), 30.0f ); ASSERT_EQ( t2->fpsNum(), 3000u ); ASSERT_EQ( t2->fpsDen(), 100u ); ASSERT_EQ( t2->bitrate(), 5678u ); ASSERT_EQ( t2->language(), "l1" ); ASSERT_EQ( t2->description(), "d1" ); }
//senquack - some conversion to fixed point //void drawRPanel() { // int y; // int ml; // if ( left >= 0 ) { // drawString(lStr, 40+480, 280, 18, 1, 200, 200, 222); // drawLetter(left, 40+480, 420, 18, 1, 230, 180, 150); // switch ( mode ) { // case NORMAL_MODE: // drawString(bStr, 90+480, 280, 18, 1, 200, 200, 222); // drawLetter(bomb, 90+480, 420, 18, 1, 230, 180, 150); // break; // case PSY_MODE: // ml = ship.grzCnt/40; // drawBox(550, 460, 50, 8, 120, 120, 120); // drawBox(500+ml, 460, ml, 8, 210, 210, 240); // break; // case GW_MODE: // ml = (ship.rfMtr-ship.rfMtrDec)/40; // drawBox(550, 460, 50, 8, 120, 120, 120); // drawBox(500+ml, 460, ml, 8, 210, 240, 210); // if ( ml >= 50 ) { // drawString(okStr, 540, 460, 10, 0, 230, 240, 230); // } // break; // } // } // y = 24; // drawString(stageStr, 124+480, y, 24, 1, 200, 200, 222); // y += 24*1.7f*2; // drawLetter(38, 124+480, y, 24, 1, 200, 200, 222); // y += 24*1.7f; // drawNumRight(scene+1, 124+480, y, 24, 200, 200, 222); //} void drawRPanel() { int y; int ml; // Show FPS if (settings.show_fps) { drawString(fpsStr, 10, 430, 10, 0, 200, 200, 200); drawNumHoriz(fps(), 10, 460, 10, 200, 200, 200); } if ( left >= 0 ) { drawString(lStr, 40+480, 280, 18, 1, 200, 200, 222); drawLetter(left, 40+480, 420, 18, 1, 230, 180, 150); switch ( mode ) { case NORMAL_MODE: drawString(bStr, 90+480, 280, 18, 1, 200, 200, 222); drawLetter(bomb, 90+480, 420, 18, 1, 230, 180, 150); break; case PSY_MODE: ml = ship.grzCnt/40; #ifdef FIXEDMATH drawBox(INT2FNUM(550), INT2FNUM(460), INT2FNUM(50), INT2FNUM(8), 120, 120, 120); drawBox(INT2FNUM(500+ml), INT2FNUM(460), INT2FNUM(ml), INT2FNUM(8), 210, 210, 240); #else drawBox(550, 460, 50, 8, 120, 120, 120); drawBox(500+ml, 460, ml, 8, 210, 210, 240); #endif //FIXEDMATH break; case GW_MODE: ml = (ship.rfMtr-ship.rfMtrDec)/40; #ifdef FIXEDMATH drawBox(INT2FNUM(550), INT2FNUM(460), INT2FNUM(50), INT2FNUM(8), 120, 120, 120); drawBox(INT2FNUM(500+ml), INT2FNUM(460), INT2FNUM(ml), INT2FNUM(8), 210, 240, 210); #else drawBox(550, 460, 50, 8, 120, 120, 120); drawBox(500+ml, 460, ml, 8, 210, 240, 210); #endif //FIXEDMATH if ( ml >= 50 ) { drawString(okStr, 540, 460, 10, 0, 230, 240, 230); } break; } } y = 24; drawString(stageStr, 124+480, y, 24, 1, 200, 200, 222); y += 24*1.7f*2; drawLetter(38, 124+480, y, 24, 1, 200, 200, 222); y += 24*1.7f; drawNumRight(scene+1, 124+480, y, 24, 200, 200, 222); }
AVRational Codec::GetSupportedFrameRate(const AVRational& frame_rate) const { AVRational fps(frame_rate); while (get()->id == CODEC_ID_MPEG4 && fps.num > (1<<16)-1) { fps.num /= 2; fps.den /= 2; } if (!get()->supported_framerates) return fps; return get()->supported_framerates[av_find_nearest_q_idx(fps, get()->supported_framerates)]; }
void Player::suspend(bool suspend) { if(_state==PLAYSTATE_STOPPED) return; if(suspend) { stateBeforeSuspend = _state; _state = PLAYSTATE_SUSPENDED; timer.stop(); } else if(_state == PLAYSTATE_SUSPENDED /*&& suspend==false */) { _state = stateBeforeSuspend; timer.start((int)(1.0/fps()*1000.0)); } }
int GLFWView::run() { map->start(); while (!glfwWindowShouldClose(window)) { if (map->needsSwap()) { glfwSwapBuffers(window); map->swapped(); fps(); } glfwWaitEvents(); } map->stop(); return 0; }
void TimeControls::initUI() { auto playback = mEditor->playback(); SignalBlocker b( mLoopStartSpinBox ); mLoopStartSpinBox->setValue( playback->markInFrame() ); SignalBlocker b2( mLoopEndSpinBox ); mLoopEndSpinBox->setValue( playback->markOutFrame() ); mPlaybackRangeCheckBox->setChecked( false ); mLoopStartSpinBox->setEnabled( false ); mLoopEndSpinBox->setEnabled( false ); SignalBlocker b3( mFpsBox ); mFpsBox->setValue( playback->fps() ); }
void MainWindow::checkLoadedSettings(){ QAction *action; action = resolutionGroup_->checkedAction(); if(action) action->setChecked(false); QList<QAction*> resolutionListActions = resolutionGroup_->actions(); foreach(QAction *action, resolutionListActions){ if(action->property("width").toInt() == width() && action->property("height").toInt() == height()){ action->setChecked(true); break; } } action = fpsGroup_->checkedAction(); if(action) action->setChecked(false); QList<QAction*> fpsListActions = fpsGroup_->actions(); foreach(QAction *action, fpsListActions){ if(action->property("fps").toInt() == fps()){ action->setChecked(true); break; } } action = orientationGroup_->checkedAction(); if(action) action->setChecked(false); QList<QAction*> orientationListActions = orientationGroup_->actions(); foreach(QAction *action, orientationListActions){ if(static_cast<Orientation>(action->property("orientation").toInt()) == orientation()){ action->setChecked(true); break; } } ui.actionDraw_Infos->setChecked(drawInfos()); ui.actionAlways_on_Top->setChecked(alwaysOnTop()); ui.actionAuto_Scale->setChecked(autoScale()); }
void DesktopCaptureElement::readFrame() { QScreen *screen = QGuiApplication::screens()[this->m_curScreenNumber]; AkFrac fps(30000, 1001); AkVideoCaps caps; caps.isValid() = true; caps.format() = AkVideoCaps::Format_rgb24; caps.bpp() = AkVideoCaps::bitsPerPixel(caps.format()); caps.width() = screen->size().width(); caps.height() = screen->size().height(); caps.fps() = fps; QPixmap frame = screen->grabWindow(QApplication::desktop()->winId()); QImage frameImg= frame.toImage().convertToFormat(QImage::Format_RGB888); AkPacket packet = AkUtils::imageToPacket(frameImg, caps.toCaps()); if (!packet) return; qint64 pts = qint64(QTime::currentTime().msecsSinceStartOfDay() * fps.value() / 1e3); packet.setPts(pts); packet.setTimeBase(fps.invert()); packet.setIndex(0); packet.setId(this->m_id); if (!this->m_threadedRead) { emit this->oStream(packet); return; } if (!this->m_threadStatus.isRunning()) { this->m_curPacket = packet; this->m_threadStatus = QtConcurrent::run(&this->m_threadPool, this->sendPacket, this, this->m_curPacket); } }
Window& Window::displayMode(DisplayMode v){ if(created()){ const Cursor cursor_ = cursor(); const bool cursorHide_ = cursorHide(); const Dim dim_ = dimensions(); const bool fullScreen_ = fullScreen(); const double fps_ = fps(); const std::string& title_ = title(); destroy(); create(dim_, title_, fps_, v); cursor(cursor_); cursorHide(cursorHide_); fullScreen(fullScreen_); } else{ mDisplayMode = v; } return *this; }
AkCaps CaptureDShow::capsFromMediaType(const AM_MEDIA_TYPE *mediaType) const { if (!mediaType) return AkCaps(); VIDEOINFOHEADER *videoInfoHeader = reinterpret_cast<VIDEOINFOHEADER *>(mediaType->pbFormat); QString fourcc = guidToStr->value(mediaType->subtype); if (fourcc.isEmpty()) return AkCaps(); AkCaps videoCaps; videoCaps.setMimeType("video/unknown"); videoCaps.setProperty("fourcc", fourcc); videoCaps.setProperty("width", int(videoInfoHeader->bmiHeader.biWidth)); videoCaps.setProperty("height", int(videoInfoHeader->bmiHeader.biHeight)); AkFrac fps(TIME_BASE, videoInfoHeader->AvgTimePerFrame); videoCaps.setProperty("fps", fps.toString()); return videoCaps; }
void Player::PlayOrPause() { //From pause to play if(_state==PLAYSTATE_STOPPED) { if(playFrame()==loopOut) setPlaybackFrame(loopIn); _state = PLAYSTATE_PLAYING; ui->playButton->setIcon(pauseIcon); timer.start((int)(1.0/fps()*1000.0)); emit playbackStarted(); } else //pause the playback { timer.stop(); _state = PLAYSTATE_STOPPED; ui->playButton->setIcon(playIcon); emit playbackPaused(); } }
//SV-XXX: rearranged initialisation order to shut up gcc4 Grabber::Grabber() : vstart_(0), vstop_(0), hstart_(0), hstop_(0), threshold_(48), framebase_(0), frame_(0), crvec_(0), ref_(0), inw_(0), inh_(0), outw_(0), outh_(0), target_(0), tx_(0), rover_(0), running_(0), status_(0), delta_(0.) { bps(128); fps(1); /*XXX*/ idle_low_ = 2; idle_high_ = 2; /* CCIR 601 */ ymin_ = 16; ymax_ = 235; contrast_ = 1.0; for (int i = 0; i < 256; ++i) ynorm_[i] = i; }
void gameloop() { while(1) { fps(); count++; monstermove(); monstermake(); bulletmove(); attackcheck(); keycheck(); draw(); Console_Flip(); gamewait(); if(endcheck() == 1) { Print("clear!\n", 10, 5); Print("game end...", 10, 6); _getch(); Console_Close(); exit(0); } } }
void run() { running = true; Timer framet; Accumulator fps(1.0), input(1.0 / 30.0), render(1.0 / 60.0); while (running) { framet.update(); double dt = framet.delta(); fps.add(dt); input.add(dt); render.add(dt); if (fps.ready()) { printf("%i\n", (int) (1.f / dt)); fps.reset(); } if (render.ready()) { render.reset(); } if (input.ready()) { input.reset(); } ++ticks; } }
MmeGrabber::MmeGrabber() { /* fprintf(stderr, "vic: Called MmeGrabber constructor\n"); */ mmeMaster = this; /*XXX defer videoOpen until start? */ if (videoGetNumDevs() <= 0 || videoOpen(&handle_, 0, VIDEO_IN) != DV_ERR_OK) { valid_ = 0; fprintf(stderr,"vic : Failed to open video device\n"); return; } port_=1; standard_=VIDEO_STANDARD_NTSC; valid_ = 1; running_ = 0; wantgrab_ = 0; buffers_ = 1; fps(5); init(); }
bool VaapiEncoderH264::ensureCodedBufferSize() { AutoLock locker(m_paramLock); uint32_t mbSize; FUNC_ENTER(); if (m_maxCodedbufSize) return true; if (!width() || !height()) { return false; } m_mbWidth = (width() + 15) / 16; m_mbHeight = (height() + 15)/ 16; //FIXME: m_numSlices = 1; mbSize = m_mbWidth * m_mbHeight; if (m_numSlices > (mbSize + 1) / 2) m_numSlices = (mbSize + 1) / 2; ASSERT (m_numSlices); /* As spec A.3.1, max coded buffer size should be: * 384 *( Max( PicSizeInMbs, fR * MaxMBPS ) + MaxMBPS / fps ) รท MinCR * The max level we support now is 5.1*/ m_maxCodedbufSize = 384 * (MAX(mbSize, LEVEL51_MAX_MBPS / H264_FRAME_FR) + LEVEL51_MAX_MBPS / fps()) / H264_MIN_CR; DEBUG("m_maxCodedbufSize: %u", m_maxCodedbufSize); return true; }
void HUD::draw(const Player& plyr, const ppogl::Vec2i& resolution) { m_resolution = resolution; gl::PushMatrix(); { gl::MatrixMode(GL_PROJECTION); gl::LoadIdentity(); gl::Ortho(0.0, m_resolution.x(), 0.0, m_resolution.y(), -1.0, 1.0); gl::MatrixMode(GL_MODELVIEW); gl::LoadIdentity(); gl::Translate(0.0, 0.0, -1.0); set_gl_options( TEXFONT ); for(int i=0; i<m_numElements; i++){ switch(m_element[i].type){ case 0: text(i); break; case 1: if(GameConfig::displayFPS){ fps(i); } break; case 2: herring(i,plyr.herring); break; case 3: image(i); break; case 4: time(i); break; case 5: { ppogl::Vec3d vel = plyr.vel; speed(i,vel.normalize()* M_PER_SEC_TO_KM_PER_H); } break; case 6: { ppogl::Vec3d vel = plyr.vel; gauge(i,vel.normalize()* M_PER_SEC_TO_KM_PER_H,plyr.control.jump_amt); } break; case 7: bar(i,plyr.control.jump_amt); break; case 8: { ppogl::Vec3d vel = plyr.vel; bar(i,vel.normalize()* M_PER_SEC_TO_KM_PER_H/135); } break; case 9: if(GameConfig::displayCoursePercentage){ coursePercentage(i, plyr); } break; case 10: if(GameConfig::displayCoursePercentage){ bar(i,plyr.getCoursePercentage()/100); } break; case 11: if(GameConfig::displayCoursePercentage){ image(i); } break; case 12: if(GameConfig::displayFPS){ image(i); } break; } } } gl::PopMatrix(); }