[PORT FROM ICS] Support dynamic resolution change for omx working in raw data mode.

BZ: 40303

Support dynamic resolution change for omx working in raw data mode.

Change-Id: I7d7e501f960e6bcb07cd9dd5b864233d04db90e6
Signed-off-by: fxiao4X <fengx.xiao@intel.com>
Signed-off-by: hding3 <haitao.ding@intel.com>
Reviewed-on: http://android.intel.com:8080/59881
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
diff --git a/videodecoder/VideoDecoderAVC.cpp b/videodecoder/VideoDecoderAVC.cpp
index 243ca80..2ef67c3 100644
--- a/videodecoder/VideoDecoderAVC.cpp
+++ b/videodecoder/VideoDecoderAVC.cpp
@@ -657,36 +657,14 @@
 }
 
 Decode_Status VideoDecoderAVC::handleNewSequence(vbp_data_h264 *data) {
-    int width = mVideoFormatInfo.width;
-    int height = mVideoFormatInfo.height;
-
     updateFormatInfo(data);
     if (mSizeChanged == false) {
         return DECODE_SUCCESS;
-    } else if (mConfigBuffer.flag & USE_NATIVE_GRAPHIC_BUFFER){
+    } else {
         mSizeChanged = false;
         flushSurfaceBuffers();
         return DECODE_FORMAT_CHANGE;
     }
-
-    if (mVideoFormatInfo.width > mVideoFormatInfo.surfaceWidth ||
-        mVideoFormatInfo.height > mVideoFormatInfo.surfaceHeight) {
-        ETRACE("New video size %d x %d exceeds surface size %d x %d.",
-                mVideoFormatInfo.width, mVideoFormatInfo.height,
-                mVideoFormatInfo.surfaceWidth, mVideoFormatInfo.surfaceHeight);
-        return DECODE_NEED_RESTART;
-    }
-
-    if (width == mVideoFormatInfo.width &&
-        height == mVideoFormatInfo.height) {
-        ITRACE("New video sequence with the same resolution.");
-        mSizeChanged = false;
-    } else {
-        WTRACE("Video size changed from %d x %d to %d x %d.", width, height,
-                mVideoFormatInfo.width, mVideoFormatInfo.height);
-        flushSurfaceBuffers();
-    }
-    return DECODE_SUCCESS;
 }
 
 bool VideoDecoderAVC::isNewFrame(vbp_data_h264 *data, bool equalPTS) {
diff --git a/videodecoder/VideoDecoderBase.cpp b/videodecoder/VideoDecoderBase.cpp
index 69912da..c89b9b7 100644
--- a/videodecoder/VideoDecoderBase.cpp
+++ b/videodecoder/VideoDecoderBase.cpp
@@ -141,8 +141,10 @@
 
     mVideoFormatInfo.width = buffer->width;
     mVideoFormatInfo.height = buffer->height;
-    mVideoFormatInfo.surfaceWidth = buffer->graphicBufferWidth;
-    mVideoFormatInfo.surfaceHeight = buffer->graphicBufferHeight;
+    if (buffer->flag & USE_NATIVE_GRAPHIC_BUFFER) {
+        mVideoFormatInfo.surfaceWidth = buffer->graphicBufferWidth;
+        mVideoFormatInfo.surfaceHeight = buffer->graphicBufferHeight;
+    }
     mLowDelay = buffer->flag & WANT_LOW_DELAY;
     mRawOutput = buffer->flag & WANT_RAW_OUTPUT;
     mSignalBufferSize = 0;
@@ -704,6 +706,7 @@
             }
         }
     }
+
     // TODO: validate profile
     if (numSurface == 0) {
         return DECODE_FAIL;
diff --git a/videodecoder/VideoDecoderMPEG4.cpp b/videodecoder/VideoDecoderMPEG4.cpp
index 5499fbb..2ec6123 100644
--- a/videodecoder/VideoDecoderMPEG4.cpp
+++ b/videodecoder/VideoDecoderMPEG4.cpp
@@ -103,6 +103,7 @@
     CHECK_STATUS("decodeFrame");
     if (mSizeChanged) {
         mSizeChanged = false;
+        flushSurfaceBuffers();
         return DECODE_FORMAT_CHANGE;
     }