diff options
| author | 2011-03-18 12:19:43 -0700 | |
|---|---|---|
| committer | 2011-03-18 13:43:45 -0700 | |
| commit | 7e91d91a4fe8ea62c07040d224615e4f823fccfb (patch) | |
| tree | 838e186800b96239c61e38db3a1959a48abf75d0 | |
| parent | 6ed6f6d82d7b9f8d82f3ab3a9f718a0e59ffa476 (diff) | |
Handle display dimension scaling event due to SAR embedded in AVC videos
bug - 3379293
Change-Id: I03cb548e61d31bc0a2fb40916d207aaf840fafce
| -rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 11 | ||||
| -rw-r--r-- | media/libstagefright/OMXCodec.cpp | 41 |
2 files changed, 49 insertions, 3 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 7a00d7ac7eda..35bc0b82cebe 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -876,6 +876,17 @@ void AwesomePlayer::notifyVideoSize_l() { cropLeft, cropTop, cropRight, cropBottom); } + int32_t displayWidth; + if (meta->findInt32(kKeyDisplayWidth, &displayWidth)) { + LOGV("Display width changed (%d=>%d)", mDisplayWidth, displayWidth); + mDisplayWidth = displayWidth; + } + int32_t displayHeight; + if (meta->findInt32(kKeyDisplayHeight, &displayHeight)) { + LOGV("Display height changed (%d=>%d)", mDisplayHeight, displayHeight); + mDisplayHeight = displayHeight; + } + int32_t usableWidth = cropRight - cropLeft + 1; int32_t usableHeight = cropBottom - cropTop + 1; if (mDisplayWidth != 0) { diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index 3e26a95bb37d..a6a34b363092 100644 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -2215,13 +2215,15 @@ void OMXCodec::onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) { if (data2 == 0 || data2 == OMX_IndexParamPortDefinition) { onPortSettingsChanged(data1); - } else if (data1 == kPortIndexOutput - && data2 == OMX_IndexConfigCommonOutputCrop) { + } else if (data1 == kPortIndexOutput && + (data2 == OMX_IndexConfigCommonOutputCrop || + data2 == OMX_IndexConfigCommonScale)) { sp<MetaData> oldOutputFormat = mOutputFormat; initOutputFormat(mSource->getFormat()); - if (formatHasNotablyChanged(oldOutputFormat, mOutputFormat)) { + if (data2 == OMX_IndexConfigCommonOutputCrop && + formatHasNotablyChanged(oldOutputFormat, mOutputFormat)) { mOutputPortSettingsHaveChanged = true; if (mNativeWindow != NULL) { @@ -2240,6 +2242,39 @@ void OMXCodec::onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) { // already invalid, we'll know soon enough. native_window_set_crop(mNativeWindow.get(), &crop); } + } else if (data2 == OMX_IndexConfigCommonScale) { + OMX_CONFIG_SCALEFACTORTYPE scale; + InitOMXParams(&scale); + scale.nPortIndex = kPortIndexOutput; + + // Change display dimension only when necessary. + if (OK == mOMX->getConfig( + mNode, + OMX_IndexConfigCommonScale, + &scale, sizeof(scale))) { + int32_t left, top, right, bottom; + CHECK(mOutputFormat->findRect(kKeyCropRect, + &left, &top, + &right, &bottom)); + + // The scale is in 16.16 format. + // scale 1.0 = 0x010000. When there is no + // need to change the display, skip it. + LOGV("Get OMX_IndexConfigScale: 0x%lx/0x%lx", + scale.xWidth, scale.xHeight); + + if (scale.xWidth != 0x010000) { + mOutputFormat->setInt32(kKeyDisplayWidth, + ((right - left + 1) * scale.xWidth) >> 16); + mOutputPortSettingsHaveChanged = true; + } + + if (scale.xHeight != 0x010000) { + mOutputFormat->setInt32(kKeyDisplayHeight, + ((bottom - top + 1) * scale.xHeight) >> 16); + mOutputPortSettingsHaveChanged = true; + } + } } } break; |