libmix: lower delay of output one decoded buffer

BZ: 146948

1) AVC: the original design will call endDecodingFrame for the previous frame
   when a new frame is detected; adjust the calling sequence for low delay mode;
2) VP8: enable low delay mode to allow one frame to be outputted at once.

Change-Id: Iac6a941a713d1ed43c21ccc35591f015ad237ab8
Signed-off-by: Dan Liang <dan.liang@intel.com>
diff --git a/videodecoder/VideoDecoderAVC.cpp b/videodecoder/VideoDecoderAVC.cpp
index 45e7e9d..957897b 100644
--- a/videodecoder/VideoDecoderAVC.cpp
+++ b/videodecoder/VideoDecoderAVC.cpp
@@ -164,16 +164,23 @@
 
     uint64_t lastPTS = mCurrentPTS;
     mCurrentPTS = buffer->timeStamp;
-
     //if (lastPTS != mCurrentPTS) {
     if (isNewFrame(data, lastPTS == mCurrentPTS)) {
+        if (mLowDelay) {
+            // start decoding a new frame
+            status = beginDecodingFrame(data);
+            CHECK_STATUS("beginDecodingFrame");
+        }
+
         // finish decoding the last frame
         status = endDecodingFrame(false);
         CHECK_STATUS("endDecodingFrame");
 
-        // start decoding a new frame
-        status = beginDecodingFrame(data);
-        CHECK_STATUS("beginDecodingFrame");
+        if (!mLowDelay) {
+            // start decoding a new frame
+            status = beginDecodingFrame(data);
+            CHECK_STATUS("beginDecodingFrame");
+        }
     } else {
         status = continueDecodingFrame(data);
         CHECK_STATUS("continueDecodingFrame");
diff --git a/videodecoder/VideoDecoderBase.h b/videodecoder/VideoDecoderBase.h
index b111bb3..5c620d0 100644
--- a/videodecoder/VideoDecoderBase.h
+++ b/videodecoder/VideoDecoderBase.h
@@ -105,6 +105,7 @@
     pthread_mutex_t mLock;
 
 protected:
+    bool mLowDelay; // when true, decoded frame is immediately output for rendering
     VideoFormatInfo mVideoFormatInfo;
     Display *mDisplay;
     VADisplay mVADisplay;
@@ -146,7 +147,6 @@
      };
 
 private:
-    bool mLowDelay; // when true, decoded frame is immediately output for rendering
     bool mRawOutput; // whether to output NV12 raw data
     bool mManageReference;  // this should stay true for VC1/MP4 decoder, and stay false for AVC decoder. AVC  handles reference frame using DPB
     OUTPUT_METHOD mOutputMethod;
diff --git a/videodecoder/VideoDecoderVP8.cpp b/videodecoder/VideoDecoderVP8.cpp
index 9bfd15b..f71099c 100644
--- a/videodecoder/VideoDecoderVP8.cpp
+++ b/videodecoder/VideoDecoderVP8.cpp
@@ -105,6 +105,7 @@
     status = VideoDecoderBase::parseBuffer(buffer->data, buffer->size, true, (void**)&data);
     CHECK_STATUS("VideoDecoderBase::parseBuffer");
 
+    enableLowDelayMode(true);
     status = startVA(data);
     return status;
 }