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

Unified Diff: media/gpu/dxva_video_decode_accelerator_win.cc

Issue 2081643003: Fix the frame freezing issue observed during a config change in the H.264 decoder on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 months 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
« no previous file with comments | « media/gpu/dxva_video_decode_accelerator_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/dxva_video_decode_accelerator_win.cc
diff --git a/media/gpu/dxva_video_decode_accelerator_win.cc b/media/gpu/dxva_video_decode_accelerator_win.cc
index 01ac4d322579dccd3d97728f162be5bf83d6d463..2fefcc7b63310ee1974d3c0e2d5b10437424b09c 100644
--- a/media/gpu/dxva_video_decode_accelerator_win.cc
+++ b/media/gpu/dxva_video_decode_accelerator_win.cc
@@ -590,6 +590,7 @@ DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator(
using_angle_device_(false),
enable_accelerated_vpx_decode_(
gpu_preferences.enable_accelerated_vpx_decode),
+ processing_config_changed_(false),
weak_this_factory_(this) {
weak_ptr_ = weak_this_factory_.GetWeakPtr();
memset(&input_stream_info_, 0, sizeof(input_stream_info_));
@@ -927,7 +928,7 @@ void DXVAVideoDecodeAccelerator::AssignPictureBuffers(
}
ProcessPendingSamples();
- if (pending_flush_) {
+ if (pending_flush_ || processing_config_changed_) {
decoder_thread_task_runner_->PostTask(
FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
base::Unretained(this)));
@@ -1020,7 +1021,7 @@ void DXVAVideoDecodeAccelerator::WaitForOutputBuffer(int32_t picture_buffer_id,
PLATFORM_FAILURE, );
ProcessPendingSamples();
- if (pending_flush_) {
+ if (pending_flush_ || processing_config_changed_) {
decoder_thread_task_runner_->PostTask(
FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
base::Unretained(this)));
@@ -1041,6 +1042,19 @@ void DXVAVideoDecodeAccelerator::Flush() {
pending_flush_ = true;
+ // If we receive a flush while processing a video stream config change, then
+ // we treat this as a regular flush, i.e we process queued decode packets,
+ // etc.
+ // We are resetting the processing_config_changed_ flag here which means that
+ // we won't be tearing down the decoder instance and recreating it to handle
+ // the changed configuration. The expectation here is that after the decoder
+ // is drained it should be able to handle a changed configuration.
+ // TODO(ananta)
+ // If a flush is sufficient to get the decoder to process video stream config
+ // changes correctly, then we don't need to tear down the decoder instance
+ // and recreate it. Check if this is indeed the case.
+ processing_config_changed_ = false;
+
decoder_thread_task_runner_->PostTask(
FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
base::Unretained(this)));
@@ -1843,7 +1857,7 @@ void DXVAVideoDecodeAccelerator::Invalidate() {
device_manager_.Release();
query_.Release();
}
-
+ sent_drain_message_ = false;
SetState(kUninitialized);
}
@@ -1919,6 +1933,8 @@ void DXVAVideoDecodeAccelerator::DecodePendingInputBuffers() {
TRACE_EVENT0("media",
"DXVAVideoDecodeAccelerator::DecodePendingInputBuffers");
DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
+ DCHECK(!processing_config_changed_);
+
State state = GetState();
RETURN_AND_NOTIFY_ON_FAILURE((state != kUninitialized),
"Invalid state: " << state, ILLEGAL_STATE, );
@@ -1946,7 +1962,9 @@ void DXVAVideoDecodeAccelerator::FlushInternal() {
// First drain the pending input because once the drain message is sent below,
// the decoder will ignore further input until it's drained.
- if (!pending_input_buffers_.empty()) {
+ // If we are processing a video configuration change, then we should just
+ // the drain the decoder.
+ if (!processing_config_changed_ && !pending_input_buffers_.empty()) {
decoder_thread_task_runner_->PostTask(
FROM_HERE,
base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers,
@@ -1974,11 +1992,18 @@ void DXVAVideoDecodeAccelerator::FlushInternal() {
if (OutputSamplesPresent())
return;
- SetState(kFlushing);
+ if (!processing_config_changed_) {
+ SetState(kFlushing);
- main_thread_task_runner_->PostTask(
- FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::NotifyFlushDone,
- weak_this_factory_.GetWeakPtr()));
+ main_thread_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::NotifyFlushDone,
+ weak_this_factory_.GetWeakPtr()));
+ } else {
+ processing_config_changed_ = false;
+ main_thread_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::ConfigChanged,
+ weak_this_factory_.GetWeakPtr(), config_));
+ }
SetState(kNormal);
}
@@ -2004,11 +2029,11 @@ void DXVAVideoDecodeAccelerator::DecodeInternal(
RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to check video stream config",
PLATFORM_FAILURE, );
+ processing_config_changed_ = config_changed;
+
if (config_changed) {
pending_input_buffers_.push_back(sample);
- main_thread_task_runner_->PostTask(
- FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::ConfigChanged,
- weak_this_factory_.GetWeakPtr(), config_));
+ FlushInternal();
return;
}
@@ -2250,7 +2275,7 @@ void DXVAVideoDecodeAccelerator::CopySurfaceComplete(
pending_output_samples_.pop_front();
}
- if (pending_flush_) {
+ if (pending_flush_ || processing_config_changed_) {
decoder_thread_task_runner_->PostTask(
FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
base::Unretained(this)));
@@ -2302,7 +2327,7 @@ void DXVAVideoDecodeAccelerator::BindPictureBufferToSample(
pending_output_samples_.pop_front();
}
- if (pending_flush_) {
+ if (pending_flush_ || processing_config_changed_) {
decoder_thread_task_runner_->PostTask(
FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal,
base::Unretained(this)));
« no previous file with comments | « media/gpu/dxva_video_decode_accelerator_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698