Calculate crop in MW according to setting width / height

BZ: 95362

uniform CTP/MERR to set crop info in MW

Change-Id: Ia7dcc233d587018661d8629069b76d6d3e063355
Signed-off-by: Zhao Liang <leo.zhao@intel.com>
Reviewed-on: http://android.intel.com:8080/98558
Reviewed-by: Shi, PingX <pingx.shi@intel.com>
Reviewed-by: cactus <cactus@intel.com>
Tested-by: Shi, PingX <pingx.shi@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
diff --git a/videoencoder/VideoEncoderAVC.cpp b/videoencoder/VideoEncoderAVC.cpp
index ae0293b..0f4d84b 100644
--- a/videoencoder/VideoEncoderAVC.cpp
+++ b/videoencoder/VideoEncoderAVC.cpp
@@ -856,8 +856,22 @@
         avcSeqParams.frame_crop_right_offset = mVideoParamsAVC.crop.RightOffset;
         avcSeqParams.frame_crop_top_offset = mVideoParamsAVC.crop.TopOffset;
         avcSeqParams.frame_crop_bottom_offset = mVideoParamsAVC.crop.BottomOffset;
-    } else
+    } else {
         avcSeqParams.frame_cropping_flag = false;
+
+        if (mComParams.resolution.width & 0xf) {
+            avcSeqParams.frame_cropping_flag = true;
+            uint32_t AWidth = (mComParams.resolution.width + 0xf) & (~0xf);
+            avcSeqParams.frame_crop_right_offset = ( AWidth - mComParams.resolution.width ) / 2;
+        }
+
+        if (mComParams.resolution.height & 0xf) {
+            avcSeqParams.frame_cropping_flag = true;
+            uint32_t AHeight = (mComParams.resolution.height + 0xf) & (~0xf);
+            avcSeqParams.frame_crop_bottom_offset = ( AHeight - mComParams.resolution.height ) / 2;
+        }
+    }
+
     if(avcSeqParams.vui_parameters_present_flag && (mVideoParamsAVC.SAR.SarWidth || mVideoParamsAVC.SAR.SarHeight)) {
         avcSeqParams.vui_fields.bits.aspect_ratio_info_present_flag = true;
         avcSeqParams.aspect_ratio_idc = 0xff /* Extended_SAR */;