am 4061c9aa: Merge "Fix the presentation video resolution when it is different from the actual image resolution of the video." into honeycomb

* commit '4061c9aa6d77bd7ad3b43d898b3e55fd62f57f18':
  Fix the presentation video resolution when it is different from the actual image resolution of the video.
This commit is contained in:
James Dong
2011-01-19 10:06:23 -08:00
committed by Android Git Automerger
4 changed files with 33 additions and 4 deletions

View File

@@ -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',

View File

@@ -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(

View File

@@ -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;
}

View File

@@ -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;