Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Unified Diff: content/common/gpu/media/vt_video_decode_accelerator.cc

Issue 742233002: Implement |pic_order_cnt| computation for VTVideoDecode accelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vt_reorder
Patch Set: Address comments (other than unittesting). Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/media/vt_video_decode_accelerator.cc
diff --git a/content/common/gpu/media/vt_video_decode_accelerator.cc b/content/common/gpu/media/vt_video_decode_accelerator.cc
index 50f1c5b2818e0e2f36f41d69aacb436b776acdf3..8618d142ade5c46b0e0ddb50100fe44bc7f67283 100644
--- a/content/common/gpu/media/vt_video_decode_accelerator.cc
+++ b/content/common/gpu/media/vt_video_decode_accelerator.cc
@@ -38,8 +38,9 @@ static const int kNALUHeaderLength = 4;
// requirements are low, as we don't need the textures to be backed by storage.
static const int kNumPictureBuffers = media::limits::kMaxVideoFrames + 1;
-// TODO(sandersd): Use the configured reorder window instead.
-static const int kMinReorderQueueSize = 4;
+// Maximum number of frames to queue for reordering before we stop asking for
+// more. (NotifyEndOfBitstreamBuffer() is called when frames are moved into the
+// reorder queue.)
static const int kMaxReorderQueueSize = 16;
// Route decoded frame callbacks back into the VTVideoDecodeAccelerator.
@@ -63,7 +64,7 @@ VTVideoDecodeAccelerator::Task::~Task() {
}
VTVideoDecodeAccelerator::Frame::Frame(int32_t bitstream_id)
- : bitstream_id(bitstream_id), pic_order_cnt(0) {
+ : bitstream_id(bitstream_id), pic_order_cnt(0), reorder_window(0) {
}
VTVideoDecodeAccelerator::Frame::~Frame() {
@@ -74,8 +75,10 @@ bool VTVideoDecodeAccelerator::FrameOrder::operator()(
const linked_ptr<Frame>& rhs) const {
if (lhs->pic_order_cnt != rhs->pic_order_cnt)
return lhs->pic_order_cnt > rhs->pic_order_cnt;
- // If the pic_order is the same, fallback on using the bitstream order.
- // TODO(sandersd): Assign a sequence number in Decode().
+ // If |pic_order_cnt| is the same, fall back on using the bitstream order.
+ // TODO(sandersd): Assign a sequence number in Decode() and use that instead.
+ // TODO(sandersd): Using the sequence number, ensure that frames older than
+ // |kMaxReorderQueueSize| are ordered first, regardless of |pic_order_cnt|.
return lhs->bitstream_id > rhs->bitstream_id;
}
@@ -318,8 +321,8 @@ void VTVideoDecodeAccelerator::DecodeTask(
return;
case media::H264NALU::kNonIDRSlice:
- // TODO(sandersd): Check that there has been an SPS or IDR slice since
- // the last reset.
+ // TODO(sandersd): Check that there has been an IDR slice since the
+ // last reset.
case media::H264NALU::kIDRSlice:
{
// TODO(sandersd): Make sure this only happens once per frame.
@@ -333,8 +336,8 @@ void VTVideoDecodeAccelerator::DecodeTask(
return;
}
- // TODO(sandersd): Keep a cache of recent SPS/PPS units instead of
- // only the most recent ones.
+ // TODO(sandersd): Maintain a cache of configurations and reconfigure
+ // only when a slice references a new config.
DCHECK_EQ(slice_hdr.pic_parameter_set_id, last_pps_id_);
const media::H264PPS* pps =
parser_.GetPPS(slice_hdr.pic_parameter_set_id);
@@ -352,9 +355,16 @@ void VTVideoDecodeAccelerator::DecodeTask(
return;
}
- // TODO(sandersd): Compute pic_order_cnt.
- DCHECK(!slice_hdr.field_pic_flag);
- frame->pic_order_cnt = 0;
+ if (!poc_.ComputePicOrderCnt(sps, slice_hdr, &frame->pic_order_cnt)) {
+ NotifyError(UNREADABLE_INPUT);
+ return;
+ }
+
+ if (sps->vui_parameters_present_flag &&
+ sps->bitstream_restriction_flag) {
+ frame->reorder_window = std::min(sps->max_num_reorder_frames,
+ kMaxReorderQueueSize - 1);
+ }
}
default:
nalus.push_back(nalu);
@@ -618,6 +628,12 @@ bool VTVideoDecodeAccelerator::ProcessTaskQueue() {
case TASK_RESET:
DCHECK_EQ(task.type, pending_flush_tasks_.front());
if (reorder_queue_.size() == 0) {
+ last_sps_id_ = -1;
+ last_pps_id_ = -1;
+ last_sps_.clear();
+ last_spsext_.clear();
+ last_pps_.clear();
+ poc_.Reset();
pending_flush_tasks_.pop();
client_->NotifyResetDone();
task_queue_.pop();
@@ -645,7 +661,9 @@ bool VTVideoDecodeAccelerator::ProcessReorderQueue() {
bool flushing = !task_queue_.empty() &&
(task_queue_.front().type != TASK_FRAME ||
task_queue_.front().frame->pic_order_cnt == 0);
- if (flushing || reorder_queue_.size() >= kMinReorderQueueSize) {
+
+ int32_t reorder_window = reorder_queue_.top()->reorder_window;
+ if (flushing || (int32_t)reorder_queue_.size() > reorder_window) {
DaleCurtis 2014/11/21 21:42:05 static_cast, and you're forcing size_t into int32_
sandersd (OOO until July 31) 2014/11/21 23:33:16 Done. I did it the previous way because there is
if (ProcessFrame(*reorder_queue_.top())) {
reorder_queue_.pop();
return true;

Powered by Google App Engine
This is Rietveld 408576698