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

Side by Side Diff: content/common/gpu/media/dxva_video_decode_accelerator.cc

Issue 540043003: Don't dismiss picture buffers on rez change until they are available (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move disposal to task Created 6 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 unified diff | Download patch
« no previous file with comments | « content/common/gpu/media/dxva_video_decode_accelerator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" 5 #include "content/common/gpu/media/dxva_video_decode_accelerator.h"
6 6
7 #if !defined(OS_WIN) 7 #if !defined(OS_WIN)
8 #error This file should only be built on Windows. 8 #error This file should only be built on Windows.
9 #endif // !defined(OS_WIN) 9 #endif // !defined(OS_WIN)
10 10
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 int32 picture_buffer_id) { 555 int32 picture_buffer_id) {
556 DCHECK(CalledOnValidThread()); 556 DCHECK(CalledOnValidThread());
557 557
558 RETURN_AND_NOTIFY_ON_FAILURE((state_ != kUninitialized), 558 RETURN_AND_NOTIFY_ON_FAILURE((state_ != kUninitialized),
559 "Invalid state: " << state_, ILLEGAL_STATE,); 559 "Invalid state: " << state_, ILLEGAL_STATE,);
560 560
561 if (output_picture_buffers_.empty()) 561 if (output_picture_buffers_.empty())
562 return; 562 return;
563 563
564 OutputBuffers::iterator it = output_picture_buffers_.find(picture_buffer_id); 564 OutputBuffers::iterator it = output_picture_buffers_.find(picture_buffer_id);
565 RETURN_AND_NOTIFY_ON_FAILURE(it != output_picture_buffers_.end(), 565 // If we didn't find the picture id in the |output_picture_buffers_| map we
566 "Invalid picture id: " << picture_buffer_id, INVALID_ARGUMENT,); 566 // try the |stale_output_picture_buffers_| map, as this may have been an
567 // output picture buffer from before a resolution change, that at resolution
568 // change time had yet to be displayed. The client is calling us back to tell
569 // us that we can now recycle this picture buffer, so if we were waiting to
570 // dispose of it we now can.
571 if (it == output_picture_buffers_.end()) {
572 it = stale_output_picture_buffers_.find(picture_buffer_id);
573 RETURN_AND_NOTIFY_ON_FAILURE(it != stale_output_picture_buffers_.end(),
574 "Invalid picture id: " << picture_buffer_id, INVALID_ARGUMENT,);
575 base::MessageLoop::current()->PostTask(FROM_HERE,
576 base::Bind(&DXVAVideoDecodeAccelerator::DeferredDismissStaleBuffer,
577 weak_this_factory_.GetWeakPtr(), picture_buffer_id));
578 return;
579 }
567 580
568 it->second->ReusePictureBuffer(); 581 it->second->ReusePictureBuffer();
569 ProcessPendingSamples(); 582 ProcessPendingSamples();
570 583
571 if (state_ == kFlushing && pending_output_samples_.empty()) 584 if (state_ == kFlushing && pending_output_samples_.empty())
572 FlushInternal(); 585 FlushInternal();
573 } 586 }
574 587
575 void DXVAVideoDecodeAccelerator::Flush() { 588 void DXVAVideoDecodeAccelerator::Flush() {
576 DCHECK(CalledOnValidThread()); 589 DCHECK(CalledOnValidThread());
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 } 1004 }
992 } 1005 }
993 1006
994 void DXVAVideoDecodeAccelerator::Invalidate() { 1007 void DXVAVideoDecodeAccelerator::Invalidate() {
995 if (state_ == kUninitialized) 1008 if (state_ == kUninitialized)
996 return; 1009 return;
997 weak_this_factory_.InvalidateWeakPtrs(); 1010 weak_this_factory_.InvalidateWeakPtrs();
998 output_picture_buffers_.clear(); 1011 output_picture_buffers_.clear();
999 pending_output_samples_.clear(); 1012 pending_output_samples_.clear();
1000 pending_input_buffers_.clear(); 1013 pending_input_buffers_.clear();
1001 decoder_.Release(); 1014 decoder_.Release();
ananta 2014/09/04 22:42:52 Please clear the stale_output_picture_buffers_ mem
luken 2014/09/04 22:49:15 Done.
1002 MFShutdown(); 1015 MFShutdown();
1003 state_ = kUninitialized; 1016 state_ = kUninitialized;
1004 } 1017 }
1005 1018
1006 void DXVAVideoDecodeAccelerator::NotifyInputBufferRead(int input_buffer_id) { 1019 void DXVAVideoDecodeAccelerator::NotifyInputBufferRead(int input_buffer_id) {
1007 if (client_) 1020 if (client_)
1008 client_->NotifyEndOfBitstreamBuffer(input_buffer_id); 1021 client_->NotifyEndOfBitstreamBuffer(input_buffer_id);
1009 } 1022 }
1010 1023
1011 void DXVAVideoDecodeAccelerator::NotifyFlushDone() { 1024 void DXVAVideoDecodeAccelerator::NotifyFlushDone() {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 base::Bind(&DXVAVideoDecodeAccelerator::NotifyInputBufferRead, 1178 base::Bind(&DXVAVideoDecodeAccelerator::NotifyInputBufferRead,
1166 weak_this_factory_.GetWeakPtr(), 1179 weak_this_factory_.GetWeakPtr(),
1167 input_buffer_id)); 1180 input_buffer_id));
1168 } 1181 }
1169 1182
1170 void DXVAVideoDecodeAccelerator::HandleResolutionChanged(int width, 1183 void DXVAVideoDecodeAccelerator::HandleResolutionChanged(int width,
1171 int height) { 1184 int height) {
1172 base::MessageLoop::current()->PostTask( 1185 base::MessageLoop::current()->PostTask(
1173 FROM_HERE, 1186 FROM_HERE,
1174 base::Bind(&DXVAVideoDecodeAccelerator::DismissStaleBuffers, 1187 base::Bind(&DXVAVideoDecodeAccelerator::DismissStaleBuffers,
1175 weak_this_factory_.GetWeakPtr(), 1188 weak_this_factory_.GetWeakPtr()));
1176 output_picture_buffers_));
1177 1189
1178 base::MessageLoop::current()->PostTask( 1190 base::MessageLoop::current()->PostTask(
1179 FROM_HERE, 1191 FROM_HERE,
1180 base::Bind(&DXVAVideoDecodeAccelerator::RequestPictureBuffers, 1192 base::Bind(&DXVAVideoDecodeAccelerator::RequestPictureBuffers,
1181 weak_this_factory_.GetWeakPtr(), 1193 weak_this_factory_.GetWeakPtr(),
1182 width, 1194 width,
1183 height)); 1195 height));
1196 }
1197
1198 void DXVAVideoDecodeAccelerator::DismissStaleBuffers() {
1199 OutputBuffers::iterator index;
1200
1201 for (index = output_picture_buffers_.begin();
1202 index != output_picture_buffers_.end();
1203 ++index) {
1204 if (index->second->available()) {
1205 DVLOG(1) << "Dismissing picture id: " << index->second->id();
1206 client_->DismissPictureBuffer(index->second->id());
1207 } else {
1208 // Move to |stale_output_picture_buffers_| for deferred deletion.
1209 stale_output_picture_buffers_.insert(
1210 std::make_pair(index->first, index->second));
1211 }
1212 }
1184 1213
1185 output_picture_buffers_.clear(); 1214 output_picture_buffers_.clear();
1186 } 1215 }
1187 1216
1188 void DXVAVideoDecodeAccelerator::DismissStaleBuffers( 1217 void DXVAVideoDecodeAccelerator::DeferredDismissStaleBuffer(
1189 const OutputBuffers& picture_buffers) { 1218 int32 picture_buffer_id) {
1190 OutputBuffers::const_iterator index; 1219 OutputBuffers::iterator it = stale_output_picture_buffers_.find(
1191 1220 picture_buffer_id);
1192 for (index = picture_buffers.begin(); 1221 DCHECK(it != stale_output_picture_buffers_.end());
1193 index != picture_buffers.end(); 1222 DVLOG(1) << "Dismissing picture id: " << it->second->id();
1194 ++index) { 1223 client_->DismissPictureBuffer(it->second->id());
1195 DVLOG(1) << "Dismissing picture id: " << index->second->id(); 1224 stale_output_picture_buffers_.erase(it);
1196 client_->DismissPictureBuffer(index->second->id());
1197 }
1198 } 1225 }
1199 1226
1200 } // namespace content 1227 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/dxva_video_decode_accelerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698