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

Side by Side Diff: media/filters/decoder_stream.cc

Issue 490033002: Don't try to decode more than one EOS at a time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/filters/decoder_stream.h" 5 #include "media/filters/decoder_stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 const SetDecryptorReadyCB& set_decryptor_ready_cb) 45 const SetDecryptorReadyCB& set_decryptor_ready_cb)
46 : task_runner_(task_runner), 46 : task_runner_(task_runner),
47 state_(STATE_UNINITIALIZED), 47 state_(STATE_UNINITIALIZED),
48 stream_(NULL), 48 stream_(NULL),
49 low_delay_(false), 49 low_delay_(false),
50 decoder_selector_( 50 decoder_selector_(
51 new DecoderSelector<StreamType>(task_runner, 51 new DecoderSelector<StreamType>(task_runner,
52 decoders.Pass(), 52 decoders.Pass(),
53 set_decryptor_ready_cb)), 53 set_decryptor_ready_cb)),
54 active_splice_(false), 54 active_splice_(false),
55 decoding_eos_(false),
55 pending_decode_requests_(0), 56 pending_decode_requests_(0),
56 weak_factory_(this) {} 57 weak_factory_(this) {}
57 58
58 template <DemuxerStream::Type StreamType> 59 template <DemuxerStream::Type StreamType>
59 DecoderStream<StreamType>::~DecoderStream() { 60 DecoderStream<StreamType>::~DecoderStream() {
60 FUNCTION_DVLOG(2); 61 FUNCTION_DVLOG(2);
61 DCHECK(task_runner_->BelongsToCurrentThread()); 62 DCHECK(task_runner_->BelongsToCurrentThread());
62 63
63 decoder_selector_.reset(); 64 decoder_selector_.reset();
64 65
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 201
201 template <DemuxerStream::Type StreamType> 202 template <DemuxerStream::Type StreamType>
202 bool DecoderStream<StreamType>::CanDecodeMore() const { 203 bool DecoderStream<StreamType>::CanDecodeMore() const {
203 DCHECK(task_runner_->BelongsToCurrentThread()); 204 DCHECK(task_runner_->BelongsToCurrentThread());
204 205
205 // Limit total number of outputs stored in |ready_outputs_| and being decoded. 206 // Limit total number of outputs stored in |ready_outputs_| and being decoded.
206 // It only makes sense to saturate decoder completely when output queue is 207 // It only makes sense to saturate decoder completely when output queue is
207 // empty. 208 // empty.
208 int num_decodes = 209 int num_decodes =
209 static_cast<int>(ready_outputs_.size()) + pending_decode_requests_; 210 static_cast<int>(ready_outputs_.size()) + pending_decode_requests_;
210 return num_decodes < GetMaxDecodeRequests(); 211 return !decoding_eos_ && num_decodes < GetMaxDecodeRequests();
211 } 212 }
212 213
213 template <DemuxerStream::Type StreamType> 214 template <DemuxerStream::Type StreamType>
214 void DecoderStream<StreamType>::OnDecoderSelected( 215 void DecoderStream<StreamType>::OnDecoderSelected(
215 scoped_ptr<Decoder> selected_decoder, 216 scoped_ptr<Decoder> selected_decoder,
216 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream) { 217 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream) {
217 FUNCTION_DVLOG(2); 218 FUNCTION_DVLOG(2);
218 DCHECK(task_runner_->BelongsToCurrentThread()); 219 DCHECK(task_runner_->BelongsToCurrentThread());
219 DCHECK_EQ(state_, STATE_INITIALIZING) << state_; 220 DCHECK_EQ(state_, STATE_INITIALIZING) << state_;
220 DCHECK(!init_cb_.is_null()); 221 DCHECK(!init_cb_.is_null());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 259
259 int buffer_size = buffer->end_of_stream() ? 0 : buffer->data_size(); 260 int buffer_size = buffer->end_of_stream() ? 0 : buffer->data_size();
260 261
261 TRACE_EVENT_ASYNC_BEGIN0("media", GetTraceString<StreamType>(), this); 262 TRACE_EVENT_ASYNC_BEGIN0("media", GetTraceString<StreamType>(), this);
262 ++pending_decode_requests_; 263 ++pending_decode_requests_;
263 decoder_->Decode(buffer, 264 decoder_->Decode(buffer,
264 base::Bind(&DecoderStream<StreamType>::OnDecodeDone, 265 base::Bind(&DecoderStream<StreamType>::OnDecodeDone,
265 weak_factory_.GetWeakPtr(), 266 weak_factory_.GetWeakPtr(),
266 buffer_size, 267 buffer_size,
267 buffer->end_of_stream())); 268 buffer->end_of_stream()));
269
270 if (buffer->end_of_stream())
271 decoding_eos_ = true;
268 } 272 }
269 273
270 template <DemuxerStream::Type StreamType> 274 template <DemuxerStream::Type StreamType>
271 void DecoderStream<StreamType>::FlushDecoder() { 275 void DecoderStream<StreamType>::FlushDecoder() {
272 Decode(DecoderBuffer::CreateEOSBuffer()); 276 Decode(DecoderBuffer::CreateEOSBuffer());
273 } 277 }
274 278
275 template <DemuxerStream::Type StreamType> 279 template <DemuxerStream::Type StreamType>
276 void DecoderStream<StreamType>::OnDecodeDone(int buffer_size, 280 void DecoderStream<StreamType>::OnDecodeDone(int buffer_size,
277 bool end_of_stream, 281 bool end_of_stream,
xhwang 2014/08/21 16:37:07 Since we have "decoding_eos_", this parameter seem
sandersd (OOO until July 31) 2014/08/23 00:49:15 Since there can be multiple pending decodes, I don
xhwang 2014/08/27 22:32:51 Got it. Thanks for the clarification.
278 typename Decoder::Status status) { 282 typename Decoder::Status status) {
279 FUNCTION_DVLOG(2) << status; 283 FUNCTION_DVLOG(2) << status;
280 DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER || 284 DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER ||
281 state_ == STATE_PENDING_DEMUXER_READ || state_ == STATE_ERROR) 285 state_ == STATE_PENDING_DEMUXER_READ || state_ == STATE_ERROR)
282 << state_; 286 << state_;
283 DCHECK_GT(pending_decode_requests_, 0); 287 DCHECK_GT(pending_decode_requests_, 0);
284 288
285 --pending_decode_requests_; 289 --pending_decode_requests_;
286 290
287 TRACE_EVENT_ASYNC_END0("media", GetTraceString<StreamType>(), this); 291 TRACE_EVENT_ASYNC_END0("media", GetTraceString<StreamType>(), this);
288 292
293 if (end_of_stream)
294 decoding_eos_ = false;
295
289 if (state_ == STATE_ERROR) { 296 if (state_ == STATE_ERROR) {
290 DCHECK(read_cb_.is_null()); 297 DCHECK(read_cb_.is_null());
291 return; 298 return;
292 } 299 }
293 300
294 // Drop decoding result if Reset() was called during decoding. 301 // Drop decoding result if Reset() was called during decoding.
295 // The resetting process will be handled when the decoder is reset. 302 // The resetting process will be handled when the decoder is reset.
296 if (!reset_cb_.is_null()) 303 if (!reset_cb_.is_null())
297 return; 304 return;
298 305
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 538 }
532 539
533 // The resetting process will be continued in OnDecoderReinitialized(). 540 // The resetting process will be continued in OnDecoderReinitialized().
534 ReinitializeDecoder(); 541 ReinitializeDecoder();
535 } 542 }
536 543
537 template class DecoderStream<DemuxerStream::VIDEO>; 544 template class DecoderStream<DemuxerStream::VIDEO>;
538 template class DecoderStream<DemuxerStream::AUDIO>; 545 template class DecoderStream<DemuxerStream::AUDIO>;
539 546
540 } // namespace media 547 } // namespace media
OLDNEW
« media/filters/decoder_stream.h ('K') | « media/filters/decoder_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698