Skip to content

Add framerate control to sherlock265 #310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
use namespace
  • Loading branch information
EdenGottlieb committed Dec 16, 2021
commit 9e7e6670df823801352b5d5ca4b86e30a7d06021
8 changes: 5 additions & 3 deletions sherlock265/VideoDecoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ using namespace videogfx;
#include <thread>

using namespace std;
using namespace std::chrono;

VideoDecoder::VideoDecoder()
: mFH(NULL),
Expand Down Expand Up @@ -133,7 +134,7 @@ void VideoDecoder::decoder_loop()
img = de265_peek_next_picture(ctx);
while (img==NULL)
{
auto start = std::chrono::system_clock::now();
auto start = system_clock::now();
mutex.unlock();
int more=1;
de265_error err = de265_decode(ctx, &more);
Expand All @@ -142,8 +143,9 @@ void VideoDecoder::decoder_loop()
if (more && err == DE265_OK) {
// try again to get picture

std::chrono::duration<double> decode_time = std::chrono::system_clock::now() - start;
std::chrono::duration<double> sleep_for_time = std::chrono::milliseconds(33) - decode_time;
duration<double> decode_time = system_clock::now() - start;
duration<double> sleep_for_time = milliseconds(33) - decode_time;

std::this_thread::sleep_for(sleep_for_time);

img = de265_peek_next_picture(ctx);
Expand Down