codecs: fix MPEG2 decoder resolution change
Bug: 28679582
Change-Id: Icd9d4af6552820e6d0ee1a2f7915258613a4901b
(cherry picked from commit 903bac1de1b0763c227464bac46bc5111eba9609)
diff --git a/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.cpp b/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.cpp
index 8283ab5..27f860e 100644
--- a/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.cpp
+++ b/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.cpp
@@ -74,7 +74,8 @@
mIvColorFormat(IV_YUV_420P),
mNewWidth(mWidth),
mNewHeight(mHeight),
- mChangingResolution(false) {
+ mChangingResolution(false),
+ mStride(mWidth) {
initPorts(kNumBuffers, INPUT_BUF_SIZE, kNumBuffers, CODEC_MIME_TYPE);
// If input dump is enabled, then open create an empty file
@@ -202,6 +203,8 @@
/* Set number of cores/threads to be used by the codec */
setNumCores();
+ mStride = 0;
+
return OK;
}
@@ -384,7 +387,8 @@
resetPlugin();
/* Set the run time (dynamic) parameters */
- setParams(displayStride);
+ mStride = outputBufferWidth();
+ setParams(mStride);
/* Set number of cores/threads to be used by the codec */
setNumCores();
@@ -548,6 +552,12 @@
List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex);
List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);
+ if (outputBufferWidth() != mStride) {
+ /* Set the run-time (dynamic) parameters */
+ mStride = outputBufferWidth();
+ setParams(mStride);
+ }
+
/* If input EOS is seen and decoder is not in flush mode,
* set the decoder in flush mode.
* There can be a case where EOS is sent along with last picture data
@@ -686,6 +696,8 @@
mChangingResolution = false;
resetDecoder();
resetPlugin();
+ mStride = outputBufferWidth();
+ setParams(mStride);
continue;
}
diff --git a/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.h b/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.h
index f48b70b..025e9a0 100644
--- a/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.h
+++ b/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.h
@@ -106,6 +106,7 @@
bool mChangingResolution;
bool mFlushNeeded;
bool mWaitForI;
+ size_t mStride;
status_t initDecoder();
status_t deInitDecoder();