DO NOT MERGE - Fix for bug 5255159 Cannot play exported movie from Movie Studio

Ensure video encoder is not created and destroyed for every clip.

Change-Id: I9ce4db9312af801570dd51f4b075f262e27e3952
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_Edit.c b/libvideoeditor/vss/src/M4VSS3GPP_Edit.c
index b764fef..d9330f5 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_Edit.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_Edit.c
@@ -2971,21 +2971,6 @@
         {
             /* if not a transition then reset previous video state */
             pC->Vstate = M4VSS3GPP_kEditVideoState_READ_WRITE;
-
-            if( pC->bIsMMS == M4OSA_FALSE ) /* RC */
-            {
-                /* There may be an encoder to destroy */
-                err = M4VSS3GPP_intDestroyVideoEncoder(pC);
-
-                if( M4NO_ERROR != err )
-                {
-                    M4OSA_TRACE1_1(
-                        "M4VSS3GPP_intSwitchToNextClip:\
-                        M4VSS3GPP_editDestroyVideoEncoder() returns 0x%x!",
-                        err);
-                    return err;
-                }
-            }
         }
     }
     /* The flags are set to false at the beginning of every clip */
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_EditVideo.c b/libvideoeditor/vss/src/M4VSS3GPP_EditVideo.c
index 1667155..b5e79e9 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_EditVideo.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_EditVideo.c
@@ -884,15 +884,17 @@
         && pC->bIsMMS == M4OSA_FALSE )
     {
         /**
-        * Create the encoder */
-        err = M4VSS3GPP_intCreateVideoEncoder(pC);
+        * Create the encoder, if not created already*/
+        if (pC->ewc.encoderState == M4VSS3GPP_kNoEncoder) {
+            err = M4VSS3GPP_intCreateVideoEncoder(pC);
 
-        if( M4NO_ERROR != err )
-        {
-            M4OSA_TRACE1_1(
-                "M4VSS3GPP_intCheckVideoMode: M4VSS3GPP_intCreateVideoEncoder returns 0x%x!",
-                err);
-            return err;
+            if( M4NO_ERROR != err )
+            {
+                M4OSA_TRACE1_1(
+                    "M4VSS3GPP_intCheckVideoMode: M4VSS3GPP_intCreateVideoEncoder \
+                     returns 0x%x!", err);
+                return err;
+            }
         }
     }
     else if( pC->bIsMMS == M4OSA_TRUE && pC->ewc.pEncContext == M4OSA_NULL )