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

Unified Diff: media/gpu/dxva_video_decode_accelerator_win.cc

Issue 2345123002: Attach color space information to hardware decoded NV12 video frames. (Closed)
Patch Set: compile fix Created 4 years, 3 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
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 5f730e80d3eb6b5b3283a39b97254d6afdef1398..19c1ddd1a3ee79b81bf96b15e54345fa8990f424 100644
--- a/media/gpu/dxva_video_decode_accelerator_win.cc
+++ b/media/gpu/dxva_video_decode_accelerator_win.cc
@@ -458,11 +458,21 @@ bool H264ConfigChangeDetector::DetectConfig(const uint8_t* stream,
return true;
}
+gfx::ColorSpace H264ConfigChangeDetector::current_color_space() const {
+ // TODO(hubbe): Is using last_sps_id_ correct here?
+ const H264SPS* sps = parser_->GetSPS(last_sps_id_);
+ if (sps)
+ return sps->GetColorSpace();
+ return gfx::ColorSpace();
+}
DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo(
int32_t buffer_id,
- IMFSample* sample)
- : input_buffer_id(buffer_id), picture_buffer_id(-1) {
+ IMFSample* sample,
+ const gfx::ColorSpace& color_space)
+ : input_buffer_id(buffer_id),
+ picture_buffer_id(-1),
+ color_space(color_space) {
output_sample.Attach(sample);
}
@@ -1594,7 +1604,7 @@ bool DXVAVideoDecodeAccelerator::GetStreamsInfoAndBufferReqs() {
return true;
}
-void DXVAVideoDecodeAccelerator::DoDecode() {
+void DXVAVideoDecodeAccelerator::DoDecode(const gfx::ColorSpace& color_space) {
jbauman 2016/09/23 00:55:25 Another idea would be to get the color space from
hubbe 2016/09/23 04:43:01 Not a bad idea, but MS enum doesn't seem to contai
TRACE_EVENT0("media", "DXVAVideoDecodeAccelerator::DoDecode");
DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
// This function is also called from FlushInternal in a loop which could
@@ -1606,7 +1616,6 @@ void DXVAVideoDecodeAccelerator::DoDecode() {
MFT_OUTPUT_DATA_BUFFER output_data_buffer = {0};
DWORD status = 0;
-
HRESULT hr = decoder_->ProcessOutput(0, // No flags
1, // # of out streams to pull from
&output_data_buffer, &status);
@@ -1628,7 +1637,7 @@ void DXVAVideoDecodeAccelerator::DoDecode() {
} else {
DVLOG(1) << "Received output format change from the decoder."
" Recursively invoking DoDecode";
- DoDecode();
+ DoDecode(color_space);
}
return;
} else if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) {
@@ -1647,12 +1656,14 @@ void DXVAVideoDecodeAccelerator::DoDecode() {
inputs_before_decode_ = 0;
- RETURN_AND_NOTIFY_ON_FAILURE(ProcessOutputSample(output_data_buffer.pSample),
- "Failed to process output sample.",
- PLATFORM_FAILURE, );
+ RETURN_AND_NOTIFY_ON_FAILURE(
+ ProcessOutputSample(output_data_buffer.pSample, color_space),
+ "Failed to process output sample.", PLATFORM_FAILURE, );
}
-bool DXVAVideoDecodeAccelerator::ProcessOutputSample(IMFSample* sample) {
+bool DXVAVideoDecodeAccelerator::ProcessOutputSample(
+ IMFSample* sample,
+ const gfx::ColorSpace& color_space) {
RETURN_ON_FAILURE(sample, "Decode succeeded with NULL output sample", false);
LONGLONG input_buffer_id = 0;
@@ -1664,7 +1675,7 @@ bool DXVAVideoDecodeAccelerator::ProcessOutputSample(IMFSample* sample) {
base::AutoLock lock(decoder_lock_);
DCHECK(pending_output_samples_.empty());
pending_output_samples_.push_back(
- PendingSampleInfo(input_buffer_id, sample));
+ PendingSampleInfo(input_buffer_id, sample, color_space));
}
if (pictures_requested_) {
@@ -1735,6 +1746,7 @@ void DXVAVideoDecodeAccelerator::ProcessPendingSamples() {
pending_sample->picture_buffer_id = index->second->id();
index->second->set_bound();
+ index->second->set_color_space(pending_sample->color_space);
if (share_nv12_textures_) {
main_thread_task_runner_->PostTask(
FROM_HERE,
@@ -1888,14 +1900,17 @@ void DXVAVideoDecodeAccelerator::RequestPictureBuffers(int width, int height) {
}
}
-void DXVAVideoDecodeAccelerator::NotifyPictureReady(int picture_buffer_id,
- int input_buffer_id) {
+void DXVAVideoDecodeAccelerator::NotifyPictureReady(
+ int picture_buffer_id,
+ int input_buffer_id,
+ const gfx::ColorSpace& color_space) {
DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
// This task could execute after the decoder has been torn down.
if (GetState() != kUninitialized && client_) {
// TODO(henryhsu): Use correct visible size instead of (0, 0). We can't use
// coded size here so use (0, 0) intentionally to have the client choose.
- Picture picture(picture_buffer_id, input_buffer_id, gfx::Rect(0, 0), false);
+ Picture picture(picture_buffer_id, input_buffer_id, gfx::Rect(0, 0),
+ color_space, false);
client_->PictureReady(picture);
}
}
@@ -1974,7 +1989,7 @@ void DXVAVideoDecodeAccelerator::FlushInternal() {
// Attempt to retrieve an output frame from the decoder. If we have one,
// return and proceed when the output frame is processed. If we don't have a
// frame then we are done.
- DoDecode();
+ DoDecode(config_change_detector_->current_color_space());
if (OutputSamplesPresent())
return;
@@ -2023,6 +2038,8 @@ void DXVAVideoDecodeAccelerator::DecodeInternal(
return;
}
+ gfx::ColorSpace color_space = config_change_detector_->current_color_space();
+
if (!inputs_before_decode_) {
TRACE_EVENT_ASYNC_BEGIN0("gpu", "DXVAVideoDecodeAccelerator.Decoding",
this);
@@ -2040,7 +2057,7 @@ void DXVAVideoDecodeAccelerator::DecodeInternal(
// process the input again. Failure in either of these steps is treated as a
// decoder failure.
if (hr == MF_E_NOTACCEPTING) {
- DoDecode();
+ DoDecode(color_space);
// If the DoDecode call resulted in an output frame then we should not
// process any more input until that frame is copied to the target surface.
if (!OutputSamplesPresent()) {
@@ -2072,7 +2089,7 @@ void DXVAVideoDecodeAccelerator::DecodeInternal(
RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to process input sample",
PLATFORM_FAILURE, );
- DoDecode();
+ DoDecode(color_space);
State state = GetState();
RETURN_AND_NOTIFY_ON_FAILURE(
@@ -2253,7 +2270,7 @@ void DXVAVideoDecodeAccelerator::CopySurfaceComplete(
RETURN_AND_NOTIFY_ON_FAILURE(result, "Failed to complete copying surface",
PLATFORM_FAILURE, );
- NotifyPictureReady(picture_buffer->id(), input_buffer_id);
+ NotifyPictureReady(picture_buffer->id(), input_buffer_id, gfx::ColorSpace());
{
base::AutoLock lock(decoder_lock_);
@@ -2305,7 +2322,8 @@ void DXVAVideoDecodeAccelerator::BindPictureBufferToSample(
RETURN_AND_NOTIFY_ON_FAILURE(result, "Failed to complete copying surface",
PLATFORM_FAILURE, );
- NotifyPictureReady(picture_buffer->id(), input_buffer_id);
+ NotifyPictureReady(picture_buffer->id(), input_buffer_id,
+ picture_buffer->color_space());
{
base::AutoLock lock(decoder_lock_);

Powered by Google App Engine
This is Rietveld 408576698