Refine VP8 encode middlerware to fix messy blocks issue.

BZ: 124706

Refine VP8 picture parameters;hardcode coded buffer size as 2M;
remove render slice parameters for VP8 encode.

Change-Id: If0d0c485f5382618cd53df3f757f0ab5b9f57002
Signed-off-by: Liu Bolun <bolun.liu@intel.com>
Signed-off-by: pingshix <pingx.shi@intel.com>
Reviewed-on: http://android.intel.com:8080/121814
Reviewed-by: cactus <cactus@intel.com>
Tested-by: cactus <cactus@intel.com>
diff --git a/videoencoder/VideoEncoderBase.cpp b/videoencoder/VideoEncoderBase.cpp
index f0d634e..2a84924 100644
--- a/videoencoder/VideoEncoderBase.cpp
+++ b/videoencoder/VideoEncoderBase.cpp
@@ -1347,21 +1347,36 @@
         return ENCODE_SUCCESS;
     }
 
-    // base on the rate control mode to calculate the defaule encoded buffer size
-    if (mComParams.rcMode == VA_RC_NONE) {
-        mCodedBufSize = (size * 400) / (16 * 16);
-        // set to value according to QP
-    } else {
-        mCodedBufSize = mComParams.rcParams.bitRate / 4;
+    // here, VP8 is different from AVC/H263
+    if(mComParams.profile == VAProfileVP8Version0_3) // for VP8 encode
+    {
+        // According to VIED suggestions, in CBR mode, coded buffer should be the size of 3 bytes per luma pixel
+        // in CBR_HRD mode, coded buffer size should be  5 * rc_buf_sz * rc_target_bitrate;
+        // now we just hardcode mCodedBufSize as 2M to walk round coded buffer size issue;
+        /*
+        if(mComParams.rcMode == VA_RC_CBR) // CBR_HRD mode
+            mCodedBufSize = 5 * mComParams.rcParams.bitRate * 6000;
+        else // CBR mode
+            mCodedBufSize = 3 * mComParams.resolution.width * mComParams.resolution.height;
+        */
+        mCodedBufSize = (2 * 1024 * 1024 + 31) & (~31);
     }
+    else // for AVC/H263/MPEG4 encode
+    {
+        // base on the rate control mode to calculate the defaule encoded buffer size
+        if (mComParams.rcMode == VA_RC_NONE) {
+             mCodedBufSize = (size * 400) / (16 * 16);
+             // set to value according to QP
+        } else {
+             mCodedBufSize = mComParams.rcParams.bitRate / 4;
+        }
 
-    mCodedBufSize =
-        max (mCodedBufSize , (size * 400) / (16 * 16));
+        mCodedBufSize = max (mCodedBufSize , (size * 400) / (16 * 16));
 
-    // in case got a very large user input bit rate value
-    mCodedBufSize =
-        min(mCodedBufSize, (size * 1.5 * 8));
-    mCodedBufSize =  (mCodedBufSize + 15) &(~15);
+        // in case got a very large user input bit rate value
+        mCodedBufSize = min(mCodedBufSize, (size * 1.5 * 8));
+        mCodedBufSize =  (mCodedBufSize + 15) &(~15);
+    }
 
     *maxSize = mCodedBufSize;
     return ENCODE_SUCCESS;
diff --git a/videoencoder/VideoEncoderVP8.cpp b/videoencoder/VideoEncoderVP8.cpp
index e8a05e1..10edc2b 100644
--- a/videoencoder/VideoEncoderVP8.cpp
+++ b/videoencoder/VideoEncoderVP8.cpp
@@ -40,7 +40,7 @@
 	mVideoConfigVP8.refresh_alternate_frame = 1;
 	mVideoConfigVP8.refresh_entropy_probs = 0;
 	mVideoConfigVP8.value = 0;
-	mVideoConfigVP8.sharpness_level = 0;
+	mVideoConfigVP8.sharpness_level = 2;
 
 	mComParams.profile = VAProfileVP8Version0_3;
 }
@@ -55,6 +55,7 @@
 
     LOG_V( "Begin\n");
 
+    memset(&(vp8SeqParam),0x00, sizeof(VAEncSequenceParameterBufferVP8));
     vp8SeqParam.frame_width = mComParams.resolution.width;
     vp8SeqParam.frame_height = mComParams.resolution.height;
     vp8SeqParam.error_resilient = mVideoParamsVP8.error_resilient;
@@ -85,6 +86,7 @@
     VAEncPictureParameterBufferVP8 vp8PicParam;
     LOG_V( "Begin\n");
 
+    memset(&(vp8PicParam),0x00, sizeof(VAEncPictureParameterBufferVP8));
     vp8PicParam.coded_buf = task->coded_buffer;
     vp8PicParam.pic_flags.value = 0;
     vp8PicParam.ref_flags.bits.force_kf = mVideoConfigVP8.force_kf; //0;