Commit eacec32f authored by Chih-Yu Huang's avatar Chih-Yu Huang Committed by Commit Bot

media/gpu: Set timestamp at VaapiVD and V4L2SVD correctly.

Originally we assume that VD::CreateSurface() will be called after
AVD::SetStream() is called, and the returned surface is used for the
current bitstream buffer. However, the description of AVD doesn't
guarantee this fact.

This CL changes to set the timestamp that is mapped from bitstream id
passed from SurfaceReady(). This timestamp is actually reliable value.

BUG=b:140842667
TEST=run video_decode_accelerator_tests on Kevin and Eve

Change-Id: I255870c6220a4bd771e1f23b54c309fe8ca42246
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1810452Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699204}
parent b8ae575b
...@@ -45,7 +45,8 @@ class MEDIA_GPU_EXPORT DmabufVideoFramePool { ...@@ -45,7 +45,8 @@ class MEDIA_GPU_EXPORT DmabufVideoFramePool {
const gfx::Size& natural_size) = 0; const gfx::Size& natural_size) = 0;
// Returns a frame from the pool with the parameters assigned by // Returns a frame from the pool with the parameters assigned by
// SetFrameFormat(). Returns nullptr if the pool is exhausted. // SetFrameFormat() and zero timestamp. Returns nullptr if the pool is
// exhausted.
virtual scoped_refptr<VideoFrame> GetFrame() = 0; virtual scoped_refptr<VideoFrame> GetFrame() = 0;
// Checks whether the pool is exhausted. This happens when the pool reached // Checks whether the pool is exhausted. This happens when the pool reached
......
...@@ -818,7 +818,6 @@ scoped_refptr<V4L2DecodeSurface> V4L2SliceVideoDecoder::CreateSurface() { ...@@ -818,7 +818,6 @@ scoped_refptr<V4L2DecodeSurface> V4L2SliceVideoDecoder::CreateSurface() {
base::BindOnce(&V4L2SliceVideoDecoder::PumpDecodeTask, weak_this_))); base::BindOnce(&V4L2SliceVideoDecoder::PumpDecodeTask, weak_this_)));
return nullptr; return nullptr;
} }
frame->set_timestamp(current_decode_request_->buffer->timestamp());
// Request V4L2 input and output buffers. // Request V4L2 input and output buffers.
V4L2WritableBufferRef input_buf = input_queue_->GetFreeBuffer(); V4L2WritableBufferRef input_buf = input_queue_->GetFreeBuffer();
...@@ -1101,6 +1100,11 @@ void V4L2SliceVideoDecoder::RunOutputCB(scoped_refptr<VideoFrame> frame, ...@@ -1101,6 +1100,11 @@ void V4L2SliceVideoDecoder::RunOutputCB(scoped_refptr<VideoFrame> frame,
DCHECK_CALLED_ON_VALID_SEQUENCE(decoder_sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(decoder_sequence_checker_);
DVLOGF(4) << "timestamp: " << timestamp; DVLOGF(4) << "timestamp: " << timestamp;
// |frame| haven't been set timestamp before, we could set the timestamp
// directly without wrapping.
if (frame->timestamp().is_zero())
frame->set_timestamp(timestamp);
// We need to update one or more attributes of the frame. Since we can't // We need to update one or more attributes of the frame. Since we can't
// modify the attributes of the frame directly, we wrap the frame into a new // modify the attributes of the frame directly, we wrap the frame into a new
// frame with updated attributes. The old frame is bound to a destruction // frame with updated attributes. The old frame is bound to a destruction
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/time/time.h"
#include "media/base/video_decoder.h" #include "media/base/video_decoder.h"
#include "media/base/video_frame_layout.h" #include "media/base/video_frame_layout.h"
#include "media/base/video_types.h" #include "media/base/video_types.h"
......
...@@ -404,8 +404,6 @@ scoped_refptr<VASurface> VaapiVideoDecoder::CreateSurface() { ...@@ -404,8 +404,6 @@ scoped_refptr<VASurface> VaapiVideoDecoder::CreateSurface() {
return nullptr; return nullptr;
} }
frame->set_timestamp(current_decode_task_->buffer_->timestamp());
// Create VASurface from the native pixmap. // Create VASurface from the native pixmap.
scoped_refptr<VASurface> va_surface = scoped_refptr<VASurface> va_surface =
vaapi_wrapper_->CreateVASurfaceForVideoFrame(frame.get()); vaapi_wrapper_->CreateVASurfaceForVideoFrame(frame.get());
...@@ -473,6 +471,11 @@ void VaapiVideoDecoder::OutputFrameTask(scoped_refptr<VideoFrame> video_frame, ...@@ -473,6 +471,11 @@ void VaapiVideoDecoder::OutputFrameTask(scoped_refptr<VideoFrame> video_frame,
DCHECK(video_frame); DCHECK(video_frame);
DVLOGF(4); DVLOGF(4);
// |video_frame| haven't been set timestamp before, we could set the timestamp
// directly without wrapping.
if (video_frame->timestamp().is_zero())
video_frame->set_timestamp(timestamp);
// We need to update one or more attributes of the frame. Since we can't // We need to update one or more attributes of the frame. Since we can't
// modify the attributes of the frame directly, we wrap the frame into a new // modify the attributes of the frame directly, we wrap the frame into a new
// frame with updated attributes. The old frame is bound to a destruction // frame with updated attributes. The old frame is bound to a destruction
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/time/time.h"
#include "media/base/video_codecs.h" #include "media/base/video_codecs.h"
#include "media/base/video_decoder.h" #include "media/base/video_decoder.h"
#include "media/base/video_frame_layout.h" #include "media/base/video_frame_layout.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment