Fix Issue Crash during Export Issue 3414805 , and Preview smoothning for 720p Clips

Change-Id: I5a90fc350a33c1eca9b4ec682b68b80913578341
diff --git a/libvideoeditor/lvpp/PreviewPlayer.cpp b/libvideoeditor/lvpp/PreviewPlayer.cpp
index 49f50cb..59e9bce 100644
--- a/libvideoeditor/lvpp/PreviewPlayer.cpp
+++ b/libvideoeditor/lvpp/PreviewPlayer.cpp
@@ -858,16 +858,15 @@
 
             mVideoBuffer->release();
             mVideoBuffer = NULL;
-
-            postVideoEvent_l();
+            postVideoEvent_l(0);
             return;
         }
 
-        if (latenessUs < -10000) {
-            // We're more than 10ms early.
-            LOGV("We're more than 10ms early, lateness %lld", latenessUs);
+        if (latenessUs < -25000) {
+            // We're more than 25ms early.
+            LOGV("We're more than 25ms early, lateness %lld", latenessUs);
 
-            postVideoEvent_l(10000);
+            postVideoEvent_l(25000);
             return;
         }
     }
@@ -1018,7 +1017,7 @@
     }
     else {
         if(!mIsVideoSourceJpg) {
-            postVideoEvent_l();
+            postVideoEvent_l(0);
         }
         else {
             postVideoEvent_l(33000);
diff --git a/libvideoeditor/lvpp/PreviewRenderer.cpp b/libvideoeditor/lvpp/PreviewRenderer.cpp
index 0f43043..c2b6fa9 100755
--- a/libvideoeditor/lvpp/PreviewRenderer.cpp
+++ b/libvideoeditor/lvpp/PreviewRenderer.cpp
@@ -78,7 +78,7 @@
             GRALLOC_USAGE_SW_READ_NEVER | GRALLOC_USAGE_SW_WRITE_OFTEN

             | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP));

 

-    CHECK_EQ(0, native_window_set_buffer_count(mSurface.get(), 2));

+    CHECK_EQ(0, native_window_set_buffer_count(mSurface.get(), 3));

 

     // Width must be multiple of 32???

     CHECK_EQ(0, native_window_set_buffers_geometry(

diff --git a/libvideoeditor/lvpp/VideoEditorTools.cpp b/libvideoeditor/lvpp/VideoEditorTools.cpp
index 73362ad..35ca1c3 100755
--- a/libvideoeditor/lvpp/VideoEditorTools.cpp
+++ b/libvideoeditor/lvpp/VideoEditorTools.cpp
@@ -1948,7 +1948,7 @@
             pPlaneTemp = pPlaneOut;

         }

 

-                 /**

+        /**

          * Call AIR functions */

         err = M4AIR_create(&m_air_context, M4AIR_kYUV420P);

         if(err != M4NO_ERROR)

@@ -2511,21 +2511,24 @@
                 /**< No flip on X abscissa */

                 if(M4OSA_FALSE == pC->m_bFlipX)

                 {

+                     M4OSA_UInt32 loc_height = pOut[i].u_height;

+                     M4OSA_UInt32 loc_width = pOut[i].u_width;

+                     M4OSA_UInt32 loc_stride = pIn[i].u_stride;

                     /**< Loop on each row */

-                    for(j=0;j<pOut[i].u_height;j++)

+                    for (j=0; j<loc_height; j++)

                     {

                         /**< Copy one whole line */

-                        M4OSA_memcpy((M4OSA_MemAddr8)pu8_data_out, (M4OSA_MemAddr8)pu8_data_in, pOut[i].u_width);

+                        memcpy((M4OSA_MemAddr8)pu8_data_out, (M4OSA_MemAddr8)pu8_data_in, loc_width);

 

                         /**< Update pointers */

                         pu8_data_out += pOut[i].u_stride;

                         if(M4OSA_FALSE == pC->m_bFlipY)

                         {

-                            pu8_data_in += pIn[i].u_stride;

+                            pu8_data_in += loc_stride;

                         }

                         else

                         {

-                            pu8_data_in -= pIn[i].u_stride;

+                            pu8_data_in -= loc_stride;

                         }

                     }

                 }