Skip to content

Commit

Permalink
Report timestamp for when decoding completed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Themaister committed Oct 28, 2023
1 parent 4258ff3 commit 144dc1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions video/ffmpeg_decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ struct VideoDecoder::Impl
uint64_t lock_order = 0;

double pts = 0.0;
double done_ts = 0.0;
ImageState state = ImageState::Idle;
};
std::vector<DecodedImage> video_queue;
Expand Down Expand Up @@ -1660,6 +1661,7 @@ void VideoDecoder::Impl::process_video_frame_in_task(unsigned frame, AVFrame *av
// Can now acquire.
std::lock_guard<std::mutex> holder{lock};
img.state = ImageState::Ready;
img.done_ts = double(Util::get_current_time_nsecs()) * 1e-9;
cond.notify_all();
}

Expand Down Expand Up @@ -2051,6 +2053,7 @@ int VideoDecoder::Impl::try_acquire_video_frame(VideoFrame &frame)
frame.view = &video_queue[index].rgb_image->get_view();
frame.index = index;
frame.pts = video_queue[index].pts;
frame.done_ts = video_queue[index].done_ts;

// Progress.
cond.notify_one();
Expand Down Expand Up @@ -2104,6 +2107,7 @@ bool VideoDecoder::Impl::acquire_video_frame(VideoFrame &frame, int timeout_ms)
frame.view = &video_queue[index].rgb_image->get_view();
frame.index = index;
frame.pts = video_queue[index].pts;
frame.done_ts = video_queue[index].done_ts;

// Progress.
acquire_blocking = false;
Expand Down Expand Up @@ -2312,6 +2316,7 @@ void VideoDecoder::Impl::flush_codecs()
img.lock_order = 0;
img.state = ImageState::Idle;
img.pts = 0.0;
img.done_ts = 0.0;
}

if (video.av_ctx)
Expand Down
1 change: 1 addition & 0 deletions video/ffmpeg_decode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct VideoFrame
Vulkan::Semaphore sem;
unsigned index = 0;
double pts = 0.0;
double done_ts = 0.0;
};

class DemuxerIOInterface
Expand Down

0 comments on commit 144dc1d

Please sign in to comment.