Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)

Bug: 166295507
Merged-In: I69a69f0bd988eedd220f8aaab9932e871fe8a2c0
Change-Id: I32a7ca28f66d8350a9a1bebe88d5aa7481a4ce0b
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..ecf8b8e
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,2 @@
+[Hook Scripts]
+mainline_hook = ${REPO_ROOT}/frameworks/av/tools/mainline_hook_project.sh
diff --git a/common/armv8/impeg2_format_conv.s b/common/armv8/impeg2_format_conv.s
index ec76e29..44afcab 100644
--- a/common/armv8/impeg2_format_conv.s
+++ b/common/armv8/impeg2_format_conv.s
@@ -136,6 +136,7 @@
     ldr             w14, [sp, #112]     //// Load convert_uv_only
 
     cmp             w14, #1
+    mov             x9,  x5
     beq             yuv420sp_uv_chroma
     ///* Do the preprocessing before the main loops start */
     //// Load the parameters from stack
@@ -195,7 +196,7 @@
     sub             x8, x8, x6          //// Destination increment
 
     lsr             x6, x6, #1
-    lsr             x5, x5, #1
+    lsr             x5, x9, #1
 yuv420sp_uv_row_loop_uv:
     mov             x16, x6
 
@@ -312,6 +313,7 @@
     ldr             w14, [sp, #112]     //// Load convert_uv_only
 
     cmp             w14, #1
+    mov             x9,  x5
     beq             yuv420sp_vu_chroma
 
     ///* Do the preprocessing before the main loops start */
@@ -373,7 +375,7 @@
     sub             x8, x8, x6          //// Destination increment
 
     lsr             x6, x6, #1
-    lsr             x5, x5, #1
+    lsr             x5, x9, #1
 yuv420sp_vu_row_loop_uv:
     mov             x16, x6
 
diff --git a/decoder/impeg2d_pic_proc.c b/decoder/impeg2d_pic_proc.c
index 4689f95..ac29f9b 100644
--- a/decoder/impeg2d_pic_proc.c
+++ b/decoder/impeg2d_pic_proc.c
@@ -121,7 +121,7 @@
         if(1 == ps_dec->u4_share_disp_buf)
             convert_uv_only = 1;
 
-        if(pu1_src_y == pu1_dst_y)
+        if(ps_src_pic->pu1_y == ps_disp_frm_buf->pv_y_buf)
             convert_uv_only = 1;
 
         if(ps_dec->i4_chromaFormat == IV_YUV_420SP_UV)
diff --git a/test/decoder/main.c b/test/decoder/main.c
index 0a249ac..51f2c44 100644
--- a/test/decoder/main.c
+++ b/test/decoder/main.c
@@ -3112,8 +3112,8 @@
         {
             ithread_join(s_app_ctx.display_thread_handle, NULL);
         }
-        free(s_app_ctx.display_thread_handle);
     }
+    free(s_app_ctx.display_thread_handle);
 
     {
         iv_retrieve_mem_rec_ip_t s_retrieve_dec_ip;