Fix share info initialization issue when enabling VPP/FRC

add a flag to indicate share_info initilization state

Bug: 18629797
BZ: 230329

Change-Id: Ifd452233049a26d00742f59e0af9f624295fbdcb
Signed-off-by: Jason Hu <jason.hu@intel.com>
diff --git a/src/android/psb_surface_gralloc.c b/src/android/psb_surface_gralloc.c
index 0d63d5e..ff7699b 100644
--- a/src/android/psb_surface_gralloc.c
+++ b/src/android/psb_surface_gralloc.c
@@ -43,6 +43,7 @@
 #define CONTEXT(id) ((object_context_p) object_heap_lookup( &driver_data->context_heap, id ))
 #define SURFACE(id)    ((object_surface_p) object_heap_lookup( &driver_data->surface_heap, id ))
 #define BUFFER(id)  ((object_buffer_p) object_heap_lookup( &driver_data->buffer_heap, id ))
+#define SHARE_INFO_INIT_VALUE   0x12345678
 
 static pthread_mutex_t gralloc_mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -381,15 +382,14 @@
                 (gfx_colorformat != HAL_PIXEL_FORMAT_YV12) &&
                 (format != VA_RT_FORMAT_RGB32)) {
 
-                unsigned int init_share_info = (unsigned int)external_buffers->reserved[2];
-                drv_debug_msg(VIDEO_DEBUG_GENERAL, "%s : Create graphic buffer initialized share info %d",__FUNCTION__, init_share_info);
+                unsigned int decoder_share_info = (unsigned int)external_buffers->reserved[2];
+                drv_debug_msg(VIDEO_DEBUG_GENERAL, "%s : Create graphic buffer initialized share info %d",__FUNCTION__, decoder_share_info);
                 obj_surface->share_info = (psb_surface_share_info_t *)vaddr[GRALLOC_SUB_BUFFER1];
 
-                if (init_share_info) {
+                if (obj_surface->share_info->initialized != SHARE_INFO_INIT_VALUE) {
                     memset(obj_surface->share_info, 0, sizeof(struct psb_surface_share_info_s));
                     // Set clear video the default output method as OUTPUT_FORCE_OVERLAY_FOR_SW_DECODE
                     // if the video can be decoded by HW, will reset the output method as 0 in psb_BeginPicture
-                    obj_surface->share_info->force_output_method = protected ? OUTPUT_FORCE_OVERLAY : OUTPUT_FORCE_OVERLAY_FOR_SW_DECODE;
 #ifdef PSBVIDEO_MSVDX_DEC_TILING
                     obj_surface->share_info->tiling = external_buffers->tiling;
 #endif
@@ -403,8 +403,11 @@
 
                     obj_surface->share_info->khandle = (uint32_t)(wsbmKBufHandle(wsbmKBuf(psb_surface->buf.drm_buf)));
 
-                    obj_surface->share_info->renderStatus = 0;
-                    obj_surface->share_info->used_by_widi = 0;
+                    obj_surface->share_info->initialized = SHARE_INFO_INIT_VALUE;
+                }
+
+                if (decoder_share_info) {
+                    obj_surface->share_info->force_output_method = protected ? OUTPUT_FORCE_OVERLAY : OUTPUT_FORCE_OVERLAY_FOR_SW_DECODE;
                     obj_surface->share_info->native_window = (void *)external_buffers->reserved[0];
 
                     attribute_tpi->reserved[1] = (unsigned long)obj_surface->share_info;
diff --git a/src/psb_drv_video.h b/src/psb_drv_video.h
index 66b7fe5..e036985 100755
--- a/src/psb_drv_video.h
+++ b/src/psb_drv_video.h
@@ -503,6 +503,7 @@
 
     unsigned int coded_width;
     unsigned int coded_height;
+    unsigned int initialized;
 };
 
 struct object_surface_s {
diff --git a/src/vsp_VPP.c b/src/vsp_VPP.c
index 05ef2b5..e597c89 100644
--- a/src/vsp_VPP.c
+++ b/src/vsp_VPP.c
@@ -689,25 +689,15 @@
 		/* copy the input share info to output */
 		output_share_info = cur_output_surf->share_info;
 		if (input_share_info != NULL && output_share_info != NULL) {
-			memcpy(output_share_info, input_share_info, sizeof(psb_surface_share_info_t));
-			output_share_info->metadata_rotate = 0;
-			output_share_info->surface_rotate = 0;
-			output_share_info->width_r = 0;
-			output_share_info->height_r = 0;
-			output_share_info->out_loop_khandle = 0;
-			output_share_info->out_loop_luma_stride = 0;
-			output_share_info->out_loop_chroma_u_stride = 0;
-			output_share_info->out_loop_chroma_v_stride = 0;
+            output_share_info->native_window = input_share_info->native_window;
+            output_share_info->force_output_method = input_share_info->force_output_method;
+            output_share_info->surface_protected = input_share_info->surface_protected;
+            output_share_info->bob_deinterlace = input_share_info->bob_deinterlace;
 
-			output_share_info->khandle = 0;
-
-			output_share_info->scaling_khandle = 0;
-			output_share_info->width_s = 0;
-			output_share_info->height_s = 0;
-			output_share_info->scaling_luma_stride = 0;
-			output_share_info->scaling_chroma_u_stride = 0;
-			output_share_info->scaling_chroma_v_stride = 0;
-
+            output_share_info->crop_width = input_share_info->crop_width;
+            output_share_info->crop_height = input_share_info->crop_height;
+            output_share_info->coded_width = input_share_info->coded_width;
+            output_share_info->coded_height = input_share_info->coded_height;
 			drv_debug_msg(VIDEO_DEBUG_GENERAL, "The input/output wxh %dx%d\n",input_share_info->width,input_share_info->height);
 		} else {
 			drv_debug_msg(VIDEO_DEBUG_WARNING, "The input/output share_info is NULL!!\n");