release-request-767e2998-9243-43e0-b656-1acb30ac5115-for-git_oc-release-4124637 snap-temp-L74200000076595014

Change-Id: Ic761eb5365f2f567a440a3178e6e6b3055ef03aa
diff --git a/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.cpp b/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.cpp
index d358ce4..6e70ded 100644
--- a/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.cpp
+++ b/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.cpp
@@ -77,13 +77,6 @@
     // If input dump is enabled, then open create an empty file
     GENERATE_FILE_NAMES();
     CREATE_DUMP_FILE(mInFile);
-
-    if (OK != initDecoder()) {
-        ALOGE("Failed to initialize decoder");
-        notify(OMX_EventError, OMX_ErrorUnsupportedSetting, 0, NULL);
-        mSignalledError = true;
-        return;
-    }
 }
 
 SoftMPEG2::~SoftMPEG2() {
@@ -454,8 +447,6 @@
     if (OK != ret) {
         ALOGE("Failed to initialize decoder");
         deInitDecoder();
-        notify(OMX_EventError, OMX_ErrorUnsupportedSetting, 0, NULL);
-        mSignalledError = true;
         return ret;
     }
     mSignalledError = false;
@@ -604,6 +595,15 @@
         return;
     }
 
+    if (NULL == mCodecCtx) {
+        if (OK != initDecoder()) {
+            ALOGE("Failed to initialize decoder");
+            notify(OMX_EventError, OMX_ErrorUnsupportedSetting, 0, NULL);
+            mSignalledError = true;
+            return;
+        }
+    }
+
     List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex);
     List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);
 
@@ -658,9 +658,6 @@
 
             if (OK != reInitDecoder()) {
                 ALOGE("Failed to reinitialize decoder");
-                notify(OMX_EventError, OMX_ErrorUnsupportedSetting, 0, NULL);
-                mSignalledError = true;
-                return;
             }
             return;
         }
@@ -736,8 +733,6 @@
 
                 if (OK != reInitDecoder()) {
                     ALOGE("Failed to reinitialize decoder");
-                    notify(OMX_EventError, OMX_ErrorUnsupportedSetting, 0, NULL);
-                    mSignalledError = true;
                     return;
                 }