summaryrefslogtreecommitdiffstats
path: root/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
diff options
context:
space:
mode:
authorDharmaray Kundargi <dharmaray@google.com>2011-01-19 19:09:27 -0800
committerDharmaray Kundargi <dharmaray@google.com>2011-01-20 00:13:18 -0800
commit35cb2de64cb6482a08f446e80733e7d344a0dcac (patch)
treed26fe0bca0cbebec23c854caefe3b7d81e2f74c8 /libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
parentbf3270869c4734e6b628d0a0dbd46015f622ea4a (diff)
downloadframeworks_av-35cb2de64cb6482a08f446e80733e7d344a0dcac.zip
frameworks_av-35cb2de64cb6482a08f446e80733e7d344a0dcac.tar.gz
frameworks_av-35cb2de64cb6482a08f446e80733e7d344a0dcac.tar.bz2
Change preview player code also.
Adapt to 32 bit aligned decoder buffers Change-Id: I631f7e60b8e424af496f45d0e5e292bf9e8a9dde
Diffstat (limited to 'libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp')
-rwxr-xr-xlibvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp55
1 files changed, 47 insertions, 8 deletions
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
index b362197..208a04e 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
@@ -721,6 +721,8 @@ M4OSA_ERR VideoEditorVideoDecoder_configureFromMetadata(M4OSA_Context pContext,
int32_t width = 0;
int32_t height = 0;
int32_t frameSize = 0;
+ int32_t vWidth, vHeight;
+ int32_t cropLeft, cropTop, cropRight, cropBottom;
VIDEOEDITOR_CHECK(M4OSA_NULL != pContext, M4ERR_PARAMETER);
VIDEOEDITOR_CHECK(M4OSA_NULL != meta, M4ERR_PARAMETER);
@@ -729,10 +731,29 @@ M4OSA_ERR VideoEditorVideoDecoder_configureFromMetadata(M4OSA_Context pContext,
pDecShellContext = (VideoEditorVideoDecoder_Context*)pContext;
- // Get the parameters
- success = meta->findInt32(kKeyWidth, &width);
- success &= meta->findInt32(kKeyHeight, &height);
+ success = meta->findInt32(kKeyWidth, &vWidth);
VIDEOEDITOR_CHECK(TRUE == success, M4ERR_PARAMETER);
+ success = meta->findInt32(kKeyHeight, &vHeight);
+ VIDEOEDITOR_CHECK(TRUE == success, M4ERR_PARAMETER);
+
+ pDecShellContext->mGivenWidth = vWidth;
+ pDecShellContext->mGivenHeight = vHeight;
+
+ if (!meta->findRect(
+ kKeyCropRect, &cropLeft, &cropTop, &cropRight, &cropBottom)) {
+
+ cropLeft = cropTop = 0;
+ cropRight = vWidth - 1;
+ cropBottom = vHeight - 1;
+
+ LOGI("got dimensions only %d x %d", width, height);
+ } else {
+ LOGI("got crop rect %d, %d, %d, %d",
+ cropLeft, cropTop, cropRight, cropBottom);
+ }
+
+ width = cropRight - cropLeft + 1;
+ height = cropBottom - cropTop + 1;
LOGV("VideoDecoder_configureFromMetadata : W=%d H=%d", width, height);
VIDEOEDITOR_CHECK((0 != width) && (0 != height), M4ERR_PARAMETER);
@@ -763,7 +784,8 @@ M4OSA_ERR VideoEditorVideoDecoder_configureFromMetadata(M4OSA_Context pContext,
MAX_DEC_BUFFERS, (M4OSA_Char*)"VIDEOEDITOR_DecodedBufferPool");
VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
err = VIDEOEDITOR_BUFFER_initPoolBuffers(pDecShellContext->m_pDecBufferPool,
- frameSize + width * 2);
+ frameSize + pDecShellContext->mGivenWidth * 2);
+
VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
cleanUp:
@@ -876,6 +898,7 @@ M4OSA_ERR VideoEditorVideoDecoder_create(M4OSA_Context *pContext,
pDecShellContext->mNbOutputFrames = 0;
pDecShellContext->mFirstOutputCts = -1;
pDecShellContext->mLastOutputCts = -1;
+ pDecShellContext->m_pDecBufferPool = M4OSA_NULL;
/**
* StageFright graph building
@@ -1197,11 +1220,27 @@ M4OSA_ERR VideoEditorVideoDecoder_decode(M4OSA_Context context,
break;
}
case OMX_COLOR_FormatYUV420Planar:
- M4OSA_memcpy((M4OSA_MemAddr8)tmpDecBuffer->pData,
- (M4OSA_MemAddr8) pDecoderBuffer->data() +
- pDecoderBuffer->range_offset(),
- (M4OSA_UInt32)pDecoderBuffer->range_length());
+ {
+ int32_t width = pDecShellContext->m_pVideoStreamhandler->m_videoWidth;
+ int32_t height = pDecShellContext->m_pVideoStreamhandler->m_videoHeight;
+ int32_t yPlaneSize = width * height;
+ int32_t uvPlaneSize = width * height / 4;
+ int32_t offsetSrc = 0;
+
+ M4OSA_MemAddr8 pTmpBuff = (M4OSA_MemAddr8)pDecoderBuffer->data() + pDecoderBuffer->range_offset();
+
+ M4OSA_memcpy((M4OSA_MemAddr8)tmpDecBuffer->pData, pTmpBuff, yPlaneSize);
+
+ offsetSrc += pDecShellContext->mGivenWidth * pDecShellContext->mGivenHeight;
+ M4OSA_memcpy((M4OSA_MemAddr8)tmpDecBuffer->pData + yPlaneSize,
+ pTmpBuff + offsetSrc, uvPlaneSize);
+
+ offsetSrc += (pDecShellContext->mGivenWidth >> 1) * (pDecShellContext->mGivenHeight >> 1);
+ M4OSA_memcpy((M4OSA_MemAddr8)tmpDecBuffer->pData + yPlaneSize + uvPlaneSize,
+ pTmpBuff + offsetSrc, uvPlaneSize);
+
break;
+ }
default:
LOGV("VideoDecoder_decode: unexpected color format 0x%X",
pDecShellContext->decOuputColorFormat);