MCPcopy Create free account
hub / github.com/IENT/YUView / goToNextFrame

Method goToNextFrame

YUViewLib/src/ui/PlaybackController.cpp:519–569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519void PlaybackController::goToNextFrame(const int nextFrameIndex)
520{
521 this->waitingForItem[0] =
522 this->currentItem[0]->isLoading() || this->currentItem[0]->isLoadingDoubleBuffer();
523 this->waitingForItem[1] =
524 this->splitViewPrimary->isSplitting() && this->currentItem[1] &&
525 (this->currentItem[1]->isLoading() || this->currentItem[1]->isLoadingDoubleBuffer());
526 if (this->waitingForItem[0] || this->waitingForItem[1])
527 {
528 // The double buffer of the current item or the second item is still loading. Playback is not
529 // fast enough. We must wait until the next frame was loaded (in both items) successfully
530 // until we can display it. We must pause the timer until this happens.
531 this->timer.stop();
532 this->playbackMode = PlaybackMode::Stalled;
533 this->playbackWasStalled = true;
534 DEBUG_PLAYBACK("PlaybackController::goToNextFrame playback stalled");
535 return;
536 }
537
538 DEBUG_PLAYBACK("PlaybackController::goToNextFrame next frame %d", nextFrameIndex);
539 this->setCurrentFrameAndUpdate(nextFrameIndex);
540
541 if (this->countdownForFPSUpdate.tickAndGetIsExpired())
542 {
543 const auto msecsSinceLastUpdate = this->fpsUpdateStopWatch.getMsSinceCreation();
544
545 // Print the frames per second as float with one digit after the decimal dot.
546 const auto actualFramesPerSec = (static_cast<double>(this->countdownForFPSUpdate.getTicks()) /
547 (msecsSinceLastUpdate / 1000.0));
548 if (actualFramesPerSec > 0)
549 this->ui.fpsLabel->setText(QString::number(actualFramesPerSec, 'f', 1));
550 if (this->playbackWasStalled)
551 this->ui.fpsLabel->setStyleSheet("QLabel { background-color: yellow }");
552 else
553 this->ui.fpsLabel->setStyleSheet("");
554 this->playbackWasStalled = false;
555
556 this->fpsUpdateStopWatch = StopWatch();
557 }
558
559 // Check if the time interval changed (the user changed the rate of the item)
560 if (this->anyItemIndexedByFrame())
561 {
562 const auto frameRate = this->getCurrentItemsFrameRate();
563
564 const auto newtimerInterval =
565 std::chrono::duration_cast<std::chrono::milliseconds>(1000ms / frameRate);
566 if (this->timerInterval != newtimerInterval)
567 this->startOrUpdateTimer();
568 }
569}
570
571void PlaybackController::enableControls(bool enable)
572{

Callers 1

timerEventMethod · 0.95

Calls 12

anyItemIndexedByFrameMethod · 0.95
startOrUpdateTimerMethod · 0.95
StopWatchClass · 0.85
isSplittingMethod · 0.80
tickAndGetIsExpiredMethod · 0.80
getMsSinceCreationMethod · 0.80
getTicksMethod · 0.80
setTextMethod · 0.80
isLoadingMethod · 0.45
isLoadingDoubleBufferMethod · 0.45

Tested by

no test coverage detected