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

Unified Diff: media/gpu/android_video_decode_accelerator.cc

Issue 2000833003: Don't reset the codec state for a flush; this kills the frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix matrix and flush. Created 4 years, 7 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/android_video_decode_accelerator.h ('k') | media/gpu/avda_codec_image.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/android_video_decode_accelerator.cc
diff --git a/media/gpu/android_video_decode_accelerator.cc b/media/gpu/android_video_decode_accelerator.cc
index 50fe2ebca4ece288bff98a1135b8baa2d94a0966..6d549f08e5e8764be69169fb5a3967fdd11aad42 100644
--- a/media/gpu/android_video_decode_accelerator.cc
+++ b/media/gpu/android_video_decode_accelerator.cc
@@ -383,6 +383,7 @@ AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator(
error_sequence_token_(0),
defer_errors_(false),
deferred_initialization_pending_(false),
+ codec_needs_reset_(false),
weak_this_factory_(this) {}
AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() {
@@ -900,6 +901,11 @@ void AndroidVideoDecodeAccelerator::Decode(
const media::BitstreamBuffer& bitstream_buffer) {
DCHECK(thread_checker_.CalledOnValidThread());
+ // If we previously deferred a codec restart, take care of it now. This can
Tima Vaisburd 2016/05/24 19:06:26 Do you want to DCHECK that drain_type_ == DRAIN_TY
DaleCurtis 2016/05/24 23:53:14 Done.
+ // happen on older devices where configuration changes require a codec reset.
+ if (codec_needs_reset_)
+ ResetCodecState(base::Closure());
+
if (bitstream_buffer.id() >= 0 && bitstream_buffer.size() > 0) {
DecodeBuffer(bitstream_buffer);
return;
@@ -1179,6 +1185,17 @@ void AndroidVideoDecodeAccelerator::ResetCodecState(
const bool did_codec_error_happen = state_ == ERROR;
state_ = NO_ERROR;
+ // Don't reset the codec here if there's no error and we're only flushing;
+ // instead defer until the next decode call; this prevents us from unbacking
+ // frames that might be out for display at end of stream.
+ codec_needs_reset_ = false;
+ if (drain_type_ == DRAIN_FOR_FLUSH && !did_codec_error_happen) {
watk 2016/05/24 19:47:26 Can we do this even if there's no drain going on?
DaleCurtis 2016/05/24 23:53:14 We probably can, but doing so exposed a few issues
+ codec_needs_reset_ = true;
+ if (!done_cb.is_null())
+ done_cb.Run();
+ return;
+ }
+
// We might increment error_sequence_token here to cancel any delayed errors,
// but right now it's unclear that it's safe to do so. If we are in an error
// state because of a codec error, then it would be okay. Otherwise, it's
« no previous file with comments | « media/gpu/android_video_decode_accelerator.h ('k') | media/gpu/avda_codec_image.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698