libmix: update actual buffer count for AVC

BZ: 184168

If there is a B frame to be output, which should be
excluded in the caculating of buffer count. Otherwize,
the buffer count is not enough then ANR happens.

Change-Id: Ie3d76d5c7f1cbcb73054b68881e07939847fd9f3
Signed-off-by: Tianmi Chen <tianmi.chen@intel.com>
diff --git a/videodecoder/VideoDecoderAVC.cpp b/videodecoder/VideoDecoderAVC.cpp
index faec181..b5a4a6b 100644
--- a/videodecoder/VideoDecoderAVC.cpp
+++ b/videodecoder/VideoDecoderAVC.cpp
@@ -772,7 +772,9 @@
         }
     }
 
-    int diff = data->codec_data->num_ref_frames + 1 - mOutputWindowSize;
+    int DPBSize = getDPBSize(data);
+    // considering there is a B frame to be output, which needs to be exclued in output queue
+    int diff = DPBSize - (mOutputWindowSize - 1);
 
     if (mConfigBuffer.flag & WANT_SURFACE_PROTECTION) {
         mVideoFormatInfo.actualBufferNeeded = mConfigBuffer.surfaceNumber;
@@ -780,7 +782,7 @@
         // The number of actual buffer needed is
         // outputQueue + nativewindow_owned + (diff > 0 ? diff : 1) + widi_need_max + 1(available buffer)
         // while outputQueue = DPB < 8? DPB :8
-        // and diff = Reference + 1 - ouputQueue
+        // and diff = DBPSize - (outputQ - 1)
         mVideoFormatInfo.actualBufferNeeded = mOutputWindowSize + NW_CONSUMED /* Owned by native window */
                                               + (diff > 0 ? diff : 1)
 #ifndef USE_GEN_HW