void ffmpegWidget::updateImage(FFBuffer *newbuf) {
    // calculate fps
    int elapsed = this->lastFrameTime->elapsed();
    // limit framerate in fallback mode
    if (this->rawbuf && newbuf && this->xv_format < 0 && elapsed < 100) {
        this->limited = QString(" (limited)");
        if (newbuf) newbuf->release();
        return;
    }
    this->lastFrameTime->start();
    this->ticksum -= this->ticklist[tickindex];             /* subtract value falling off */
    this->ticksum += elapsed;                               /* add new value */
    this->ticklist[this->tickindex] = elapsed;              /* save new value so it can be subtracted later */
    if (++this->tickindex == MAXTICKS) this->tickindex=0;   /* inc buffer index */
    _fps = 1000.0  * MAXTICKS / this->ticksum;
    emit fpsChanged(_fps);
    emit fpsChanged(QString("%1%2").arg(_fps, 0, 'f', 1).arg(this->limited));
    this->limited = QString("");

    // store the buffer
    if (this->rawbuf) this->rawbuf->release();    
    this->rawbuf = newbuf;
    
    // if blank then just do an update
    if (newbuf == NULL) {
        // release any full frame we might have
        if (this->fullbuf) this->fullbuf->release();        
        this->fullbuf = NULL;
        // update the screen to blank it
        update();
        return;
    }    
    
    // make the frame the right format
    makeFullFrame();            

    // if width and height changes then make sure we zoom onto it
    if (this->fullbuf && (_imW != this->fullbuf->width || _imH != this->fullbuf->height)) {
        _imW = this->fullbuf->width;
        emit imWChanged(_imW);
        _imH = this->fullbuf->height;
        emit imHChanged(_imH);
        /* Zoom so it fills the viewport */
        disableUpdates = true;
        setZoom(0);
        /* Update the maximum gridx and gridy values */
        _maxGx = _imW - 1;
        emit maxGxChanged(_maxGx);
        _maxGy = _imH - 1;
        emit maxGyChanged(_maxGy);
        /* Update scale factors */
        this->updateScalefactor();
        this->disableUpdates = false;
    } 
    
    // repaint the screen
    update();
}
void QuasiGame::setFps(const int &fps)
{
    if (m_fps != fps) {
        m_fps = fps;

        emit fpsChanged();
    }
}
void PlaybackManager::setFps( int fps )
{
    if ( mFps != fps )
    {
        mFps = fps;
        emit fpsChanged( mFps );
    }
}
void MjpegStreamerClient::updateFramerate()
{
    m_fps = m_frameCount;
    m_frameCount = 0;
    emit fpsChanged(m_fps);

#ifdef QT_DEBUG
    qDebug() << "fps: " << m_fps;
#endif
}
// draw the data received over serial
void RenderArea::drawData(unsigned char* data) {
    for (int x = 0; x < Settings::bufferSize; x++) {
        dots[x] = QPoint(x,data[x]*Settings::heightConstant);
    }
    update();

    // recalculate fps
    emit fpsChanged(frames/(time.elapsed()/1000.0));
    if (!(frames % 100)) {
        time.start();
        frames = 0;
    }
    frames ++;
}
    void BasicRenderer::calculateFPS()
    {
	    static int frameCount = 0;
	    static float elapsedTime = 0.0f;

	    ++frameCount;

	    // compute averages over one second period
        if((m_timer.totalTime() - elapsedTime) >= 1.0f)
	    {
		    float fps = static_cast<float>(frameCount);
		    float millisecsPerFrame = 1000.0f / fps;
		    emit fpsChanged(fps, millisecsPerFrame);

		    frameCount = 0;
		    elapsedTime += 1.0f;
	    }
    }
VideoRenderer::VideoRenderer(QQuickItem *parent)
    : HighQualityTextureItem(parent)
    , d(new Data(this))
{
    d->letterbox = new LetterboxItem(this);
    const QQmlProperty property(d->letterbox, u"anchors.centerIn"_q);
    property.write(QVariant::fromValue(this));
    setZ(-1);
    setAcceptHoverEvents(true);
    setAcceptedMouseButtons(Qt::AllButtons);
    setFlag(ItemAcceptsDrops, true);
    connect(&d->sizeChecker, &QTimer::timeout, [=] () { d->updateOsdSize(); });
    d->sizeChecker.setInterval(300);

    d->measure.setTimer([=]() {
        if (_Change(d->fps, d->measure.get()))
            emit fpsChanged(d->fps);
    }, 100000);
}
// set fps to 0 if we've waited 1.5 times the time we should for a frame
void ffmpegWidget::calcFps() {
    if (this->lastFrameTime->elapsed() > 1500.0 / _fps) {
        emit fpsChanged(QString("0.0"));
    }
}
Exemple #9
0
void Configure::slotFpsChanged(int fps) {
    emit fpsChanged(fps);
}
Exemple #10
0
void ScreenProvider::updateFps()
{
    emit fpsChanged(framebufferinfo_.fps);
    emit frameTime(framebufferinfo_.frametime);
}
void DebugMetricsMonitor::updateFps() {
    emit fpsChanged();
    // TODO: Decide if we want to log FPS details here
}
Exemple #12
0
void
Timer::waitUntilNextFrameIsDue ()
{
    if (playState != ePlayStateRunning) {
        //
        // If we are not running, reset all timing state
        // variables and return without waiting.
        //

        gettimeofday (&_lastFrameTime, 0);
        _timingError = 0;
        _lastFpsFrameTime = _lastFrameTime;
        _framesSinceLastFpsFrame = 0;

        return;
    }


    double spf;
    {
        QMutexLocker l(_mutex);
        spf = _spf;
    }
    //
    // If less than _spf seconds have passed since the last frame
    // was displayed, sleep until exactly _spf seconds have gone by.
    //
    timeval now;
    gettimeofday (&now, 0);

    double timeSinceLastFrame =  now.tv_sec  - _lastFrameTime.tv_sec +
                                (now.tv_usec - _lastFrameTime.tv_usec) * 1e-6f;
    if (timeSinceLastFrame < 0) {
        timeSinceLastFrame = 0;
    }
    double timeToSleep = spf - timeSinceLastFrame - _timingError;

    #ifdef _WIN32

    if (timeToSleep > 0) {
        Sleep ( int (timeToSleep * 1000.0f) );
    }

    #else

    if (timeToSleep > 0) {
        timespec ts;
        ts.tv_sec = (time_t) timeToSleep;
        ts.tv_nsec = (long) ( (timeToSleep - ts.tv_sec) * 1e9f );
        nanosleep (&ts, 0);
    }

    #endif

    //
    // If we slept, it is possible that we woke up a little too early
    // or a little too late.  Keep track of the difference between
    // now and the exact time when we wanted to wake up; next time
    // we'll try sleep that much longer or shorter.  This should
    // keep our average frame rate close to one fame every _spf seconds.
    //

    gettimeofday (&now, 0);

    timeSinceLastFrame =  now.tv_sec  - _lastFrameTime.tv_sec +
                         (now.tv_usec - _lastFrameTime.tv_usec) * 1e-6f;

    _timingError += timeSinceLastFrame - spf;

    if (_timingError < -2 * spf) {
        _timingError = -2 * spf;
    }

    if (_timingError >  2 * spf) {
        _timingError =  2 * spf;
    }

    _lastFrameTime = now;

    //
    // Calculate our actual frame rate, averaged over several frames.
    //

    double t =  now.tv_sec  - _lastFpsFrameTime.tv_sec +
               (now.tv_usec - _lastFpsFrameTime.tv_usec) * 1e-6f;

    if (t > NATRON_FPS_REFRESH_RATE_SECONDS) {
        double actualFrameRate = _framesSinceLastFpsFrame / t;
        double curActualFrameRate;
        double desiredFrameRate;
        {
            QMutexLocker l(_mutex);
            if (actualFrameRate != _actualFrameRate) {
                _actualFrameRate = actualFrameRate;
            }
            desiredFrameRate = 1.f / _spf;
            curActualFrameRate = _actualFrameRate;
        }
        Q_EMIT fpsChanged(curActualFrameRate, desiredFrameRate);

        _framesSinceLastFpsFrame = 0;
    }


    if (_framesSinceLastFpsFrame == 0) {
        _lastFpsFrameTime = now;
    }

    _framesSinceLastFpsFrame += 1;
} // waitUntilNextFrameIsDue