summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
diff options
context:
space:
mode:
authorRonghua Wu <ronghuawu@google.com>2014-09-05 14:25:39 -0700
committerRonghua Wu <ronghuawu@google.com>2014-09-11 10:33:59 -0700
commita694dd0ce2caaf921f7bc894df87a5d52594b4eb (patch)
tree9ad4a1cbb711e3b2f81365e6163367c4cfb4b02b /media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
parent971873179cf202ad8aa1ddc4ec737795f1e03ce3 (diff)
downloadframeworks_av-a694dd0ce2caaf921f7bc894df87a5d52594b4eb.zip
frameworks_av-a694dd0ce2caaf921f7bc894df87a5d52594b4eb.tar.gz
frameworks_av-a694dd0ce2caaf921f7bc894df87a5d52594b4eb.tar.bz2
stagefright: add adaptive playback support to SoftMPEG decoder.
This covers both MPEG4 and H263 adaptive playback. Bug: 17326758 Change-Id: I80a67b7f3ceab05e792f0a459439a8274bd78e20
Diffstat (limited to 'media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp')
-rw-r--r--media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp50
1 files changed, 27 insertions, 23 deletions
diff --git a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
index 0d1ab71..5b2ab84 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
+++ b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
@@ -134,6 +134,12 @@ void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) {
}
uint8_t *bitstream = inHeader->pBuffer + inHeader->nOffset;
+ uint32_t *start_code = (uint32_t *)bitstream;
+ bool volHeader = *start_code == 0xB0010000;
+ if (volHeader) {
+ PVCleanUpVideoDecoder(mHandle);
+ mInitialized = false;
+ }
if (!mInitialized) {
uint8_t *vol_data[1];
@@ -141,7 +147,7 @@ void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) {
vol_data[0] = NULL;
- if (inHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG) {
+ if ((inHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG) || volHeader) {
vol_data[0] = bitstream;
vol_size = inHeader->nFilledLen;
}
@@ -169,21 +175,26 @@ void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) {
PVSetPostProcType((VideoDecControls *) mHandle, 0);
+ bool hasFrameData = false;
if (inHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG) {
inInfo->mOwnedByUs = false;
inQueue.erase(inQueue.begin());
inInfo = NULL;
notifyEmptyBufferDone(inHeader);
inHeader = NULL;
+ } else if (volHeader) {
+ hasFrameData = true;
}
mInitialized = true;
- if (mode == MPEG4_MODE && portSettingsChanged()) {
+ if (mode == MPEG4_MODE && handlePortSettingsChange()) {
return;
}
- continue;
+ if (!hasFrameData) {
+ continue;
+ }
}
if (!mFramesConfigured) {
@@ -223,7 +234,9 @@ void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) {
return;
}
- if (portSettingsChanged()) {
+ // H263 doesn't have VOL header, the frame size information is in short header, i.e. the
+ // decoder may detect size change after PVDecodeVideoFrame.
+ if (handlePortSettingsChange()) {
return;
}
@@ -269,7 +282,7 @@ void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) {
}
}
-bool SoftMPEG4::portSettingsChanged() {
+bool SoftMPEG4::handlePortSettingsChange() {
uint32_t disp_width, disp_height;
PVGetVideoDimensions(mHandle, (int32 *)&disp_width, (int32 *)&disp_height);
@@ -282,25 +295,20 @@ bool SoftMPEG4::portSettingsChanged() {
ALOGV("disp_width = %d, disp_height = %d, buf_width = %d, buf_height = %d",
disp_width, disp_height, buf_width, buf_height);
- if (mCropWidth != disp_width
- || mCropHeight != disp_height) {
+ bool cropChanged = false;
+ if (mCropWidth != disp_width || mCropHeight != disp_height) {
mCropLeft = 0;
mCropTop = 0;
mCropWidth = disp_width;
mCropHeight = disp_height;
-
- notify(OMX_EventPortSettingsChanged,
- 1,
- OMX_IndexConfigCommonOutputCrop,
- NULL);
+ cropChanged = true;
}
- if (buf_width != mWidth || buf_height != mHeight) {
- mWidth = buf_width;
- mHeight = buf_height;
-
- updatePortDefinitions();
-
+ bool portWillReset = false;
+ const bool fakeStride = true;
+ SoftVideoDecoderOMXComponent::handlePortSettingsChange(
+ &portWillReset, buf_width, buf_height, cropChanged, fakeStride);
+ if (portWillReset) {
if (mMode == MODE_H263) {
PVCleanUpVideoDecoder(mHandle);
@@ -318,13 +326,9 @@ bool SoftMPEG4::portSettingsChanged() {
}
mFramesConfigured = false;
-
- notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
- mOutputPortSettingsChange = AWAITING_DISABLED;
- return true;
}
- return false;
+ return portWillReset;
}
void SoftMPEG4::onPortFlushCompleted(OMX_U32 portIndex) {