diff options
-rw-r--r-- | include/media/stagefright/MetaData.h | 6 | ||||
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 22 | ||||
-rw-r--r-- | media/libstagefright/MPEG4Extractor.cpp | 6 | ||||
-rw-r--r-- | media/libstagefright/include/AwesomePlayer.h | 3 |
4 files changed, 33 insertions, 4 deletions
diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h index 5170a2c..18fd90e 100644 --- a/include/media/stagefright/MetaData.h +++ b/include/media/stagefright/MetaData.h @@ -30,8 +30,10 @@ namespace android { // The following keys map to int32_t data unless indicated otherwise. enum { kKeyMIMEType = 'mime', // cstring - kKeyWidth = 'widt', // int32_t - kKeyHeight = 'heig', // int32_t + kKeyWidth = 'widt', // int32_t, image pixel + kKeyHeight = 'heig', // int32_t, image pixel + kKeyDisplayWidth = 'dWid', // int32_t, display/presentation + kKeyDisplayHeight = 'dHgt', // int32_t, display/presentation // a rectangle, if absent assumed to be (0, 0, width - 1, height - 1) kKeyCropRect = 'crop', diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 49d05ed..58c4a2e 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -165,6 +165,8 @@ AwesomePlayer::AwesomePlayer() mTimeSource(NULL), mVideoRendererIsPreview(false), mAudioPlayer(NULL), + mDisplayWidth(0), + mDisplayHeight(0), mFlags(0), mExtractorFlags(0), mVideoBuffer(NULL), @@ -329,6 +331,18 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) { if (!haveVideo && !strncasecmp(mime, "video/", 6)) { setVideoSource(extractor->getTrack(i)); haveVideo = true; + + // Set the presentation/display size + int32_t displayWidth, displayHeight; + bool success = meta->findInt32(kKeyDisplayWidth, &displayWidth); + if (success) { + success = meta->findInt32(kKeyDisplayHeight, &displayHeight); + } + if (success) { + mDisplayWidth = displayWidth; + mDisplayHeight = displayHeight; + } + } else if (!haveAudio && !strncasecmp(mime, "audio/", 6)) { setAudioSource(extractor->getTrack(i)); haveAudio = true; @@ -370,6 +384,8 @@ void AwesomePlayer::reset() { void AwesomePlayer::reset_l() { LOGI("reset_l"); + mDisplayWidth = 0; + mDisplayHeight = 0; if (mDecryptHandle != NULL) { mDrmManagerClient->setPlaybackStatus(mDecryptHandle, @@ -862,6 +878,12 @@ void AwesomePlayer::notifyVideoSize_l() { int32_t usableWidth = cropRight - cropLeft + 1; int32_t usableHeight = cropBottom - cropTop + 1; + if (mDisplayWidth != 0) { + usableWidth = mDisplayWidth; + } + if (mDisplayHeight != 0) { + usableHeight = mDisplayHeight; + } int32_t rotationDegrees; if (!mVideoTrack->getFormat()->findInt32( diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index bafa243..aca701d 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -1321,10 +1321,12 @@ status_t MPEG4Extractor::parseTrackHeader( mLastTrack->meta->setInt32(kKeyRotation, rotationDegrees); } -#if 0 + // Handle presentation display size, which could be different + // from the image size indicated by kKeyWidth and kKeyHeight. uint32_t width = U32_AT(&buffer[dynSize + 52]); uint32_t height = U32_AT(&buffer[dynSize + 56]); -#endif + mLastTrack->meta->setInt32(kKeyDisplayWidth, width >> 16); + mLastTrack->meta->setInt32(kKeyDisplayHeight, height >> 16); return OK; } diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h index fe00856..41ef181 100644 --- a/media/libstagefright/include/AwesomePlayer.h +++ b/media/libstagefright/include/AwesomePlayer.h @@ -150,6 +150,9 @@ private: AudioPlayer *mAudioPlayer; int64_t mDurationUs; + int32_t mDisplayWidth; + int32_t mDisplayHeight; + uint32_t mFlags; uint32_t mExtractorFlags; uint32_t mSinceLastDropped; |