make ref/rec surfaces stride/height aligned with 16 to avoid bad performance.
BZ: 52316
It is found that if ref/rec surfaces stride/height not aligned with 16,
the SyncSurface will become very slow, about 1 sec per time. so make all aligned.
Change-Id: Ia17c19b30890b0025d8809dcb53f60e229f3460e
Signed-off-by: Zhao Liang <leo.zhao@intel.com>
Reviewed-on: http://android.intel.com:8080/62236
Reviewed-by: Ding, Haitao <haitao.ding@intel.com>
Tested-by: Ding, Haitao <haitao.ding@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
diff --git a/videoencoder/VideoEncoderBase.cpp b/videoencoder/VideoEncoderBase.cpp
index 72b4778..417aab0 100644
--- a/videoencoder/VideoEncoderBase.cpp
+++ b/videoencoder/VideoEncoderBase.cpp
@@ -124,6 +124,8 @@
VASurfaceID surfaces[2];
int32_t index = -1;
SurfaceMap *map = mSrcSurfaceMapList;
+ uint32_t stride_aligned = 0;
+ uint32_t height_aligned = 0;
VAConfigAttrib vaAttrib[2];
uint32_t maxSize = 0;
@@ -166,17 +168,20 @@
VASurfaceAttributeTPI attribute_tpi;
- attribute_tpi.size = mComParams.resolution.width * mComParams.resolution.height * 3 / 2;
- attribute_tpi.luma_stride = mComParams.resolution.width;
- attribute_tpi.chroma_u_stride = mComParams.resolution.width;
- attribute_tpi.chroma_v_stride = mComParams.resolution.width;
+ stride_aligned = ((mComParams.resolution.width + 15) / 16 ) * 16;
+ height_aligned = ((mComParams.resolution.height + 15) / 16 ) * 16;
+
+ attribute_tpi.size = stride_aligned * height_aligned * 3 / 2;
+ attribute_tpi.luma_stride = stride_aligned;
+ attribute_tpi.chroma_u_stride = stride_aligned;
+ attribute_tpi.chroma_v_stride = stride_aligned;
attribute_tpi.luma_offset = 0;
- attribute_tpi.chroma_u_offset = mComParams.resolution.width * mComParams.resolution.height;
- attribute_tpi.chroma_v_offset = mComParams.resolution.width * mComParams.resolution.height;
+ attribute_tpi.chroma_u_offset = stride_aligned * height_aligned;
+ attribute_tpi.chroma_v_offset = stride_aligned * height_aligned;
attribute_tpi.pixel_format = VA_FOURCC_NV12;
attribute_tpi.type = VAExternalMemoryNULL;
- vaCreateSurfacesWithAttribute(mVADisplay, mComParams.resolution.width, mComParams.resolution.height,
+ vaCreateSurfacesWithAttribute(mVADisplay, stride_aligned, height_aligned,
VA_RT_FORMAT_YUV420, 2, surfaces, &attribute_tpi);
CHECK_VA_STATUS_RETURN("vaCreateSurfacesWithAttribute");