[go: nahoru, domu]

media/gpu: fix the vp9 decode when the stream starts with an Intra only frame

Current implementation allows only a keyframe as the first frame in the
stream. This patch relaxes the requiremnt a bit and legalize the decoding
when it starts with an Intra only frame. Also allows the resolution
change if there is no prior decoded frames and the current frame is an
intra only one.

BUG=889768

Change-Id: Ic3bdedc329072b473f057407101193ac7ba4dc09
Reviewed-on: https://chromium-review.googlesource.com/c/1341146
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611532}
diff --git a/media/gpu/vp9_decoder.cc b/media/gpu/vp9_decoder.cc
index 5b8e183..a16c6a9 100644
--- a/media/gpu/vp9_decoder.cc
+++ b/media/gpu/vp9_decoder.cc
@@ -92,7 +92,10 @@
       // Not kDecoding, so we need a resume point (a keyframe), as we are after
       // reset or at the beginning of the stream. Drop anything that is not
       // a keyframe in such case, and continue looking for a keyframe.
-      if (curr_frame_hdr_->IsKeyframe()) {
+      // Only exception is when the stream/sequence starts with an Intra only
+      // frame.
+      if (curr_frame_hdr_->IsKeyframe() ||
+          (curr_frame_hdr_->IsIntra() && pic_size_.IsEmpty())) {
         state_ = kDecoding;
       } else {
         curr_frame_hdr_.reset();
@@ -136,11 +139,14 @@
     if (new_pic_size != pic_size_) {
       DVLOG(1) << "New resolution: " << new_pic_size.ToString();
 
-      if (!curr_frame_hdr_->IsKeyframe()) {
+      if (!curr_frame_hdr_->IsKeyframe() &&
+          (curr_frame_hdr_->IsIntra() && pic_size_.IsEmpty())) {
         // TODO(posciak): This is doable, but requires a few modifications to
         // VDA implementations to allow multiple picture buffer sets in flight.
         // http://crbug.com/832264
-        DVLOG(1) << "Resolution change currently supported for keyframes only";
+        DVLOG(1) << "Resolution change currently supported for keyframes and "
+                    "sequence begins with Intra only when there is no prior "
+                    "frames in the context";
         if (++size_change_failure_counter_ > kVPxMaxNumOfSizeChangeFailures) {
           SetError();
           return kDecodeError;