summaryrefslogtreecommitdiffstats
path: root/media/libmediaplayerservice
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-12-03 15:20:40 -0800
committerAndreas Huber <andih@google.com>2012-12-05 10:34:34 -0800
commite9810fae2ca6620337b75a787786cc0ea52adecd (patch)
treef848298646fb0163e6911ad8622adcc12a8eba3f /media/libmediaplayerservice
parent07dfb08e935fdfe9f73f452cf27e3e2b052eda4f (diff)
downloadframeworks_av-e9810fae2ca6620337b75a787786cc0ea52adecd.zip
frameworks_av-e9810fae2ca6620337b75a787786cc0ea52adecd.tar.gz
frameworks_av-e9810fae2ca6620337b75a787786cc0ea52adecd.tar.bz2
Respect sample aspect ratio in NuPlayer.
related-to-bug: 7569402 Change-Id: I302de95d83b180bd2dc72ddd0c69a665dbce2527
Diffstat (limited to 'media/libmediaplayerservice')
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.cpp41
1 files changed, 31 insertions, 10 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index f363568..746055c 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -448,7 +448,8 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
} else if (what == ACodec::kWhatOutputFormatChanged) {
if (audio) {
int32_t numChannels;
- CHECK(codecRequest->findInt32("channel-count", &numChannels));
+ CHECK(codecRequest->findInt32(
+ "channel-count", &numChannels));
int32_t sampleRate;
CHECK(codecRequest->findInt32("sample-rate", &sampleRate));
@@ -460,13 +461,15 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
audio_output_flags_t flags;
int64_t durationUs;
- // FIXME: we should handle the case where the video decoder is created after
- // we receive the format change indication. Current code will just make that
- // we select deep buffer with video which should not be a problem as it should
+ // FIXME: we should handle the case where the video decoder
+ // is created after we receive the format change indication.
+ // Current code will just make that we select deep buffer
+ // with video which should not be a problem as it should
// not prevent from keeping A/V sync.
if (mVideoDecoder == NULL &&
mSource->getDuration(&durationUs) == OK &&
- durationUs > AUDIO_SINK_MIN_DEEP_BUFFER_DURATION_US) {
+ durationUs
+ > AUDIO_SINK_MIN_DEEP_BUFFER_DURATION_US) {
flags = AUDIO_OUTPUT_FLAG_DEEP_BUFFER;
} else {
flags = AUDIO_OUTPUT_FLAG_NONE;
@@ -502,17 +505,35 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
"crop",
&cropLeft, &cropTop, &cropRight, &cropBottom));
+ int32_t displayWidth = cropRight - cropLeft + 1;
+ int32_t displayHeight = cropBottom - cropTop + 1;
+
ALOGV("Video output format changed to %d x %d "
"(crop: %d x %d @ (%d, %d))",
width, height,
- (cropRight - cropLeft + 1),
- (cropBottom - cropTop + 1),
+ displayWidth,
+ displayHeight,
cropLeft, cropTop);
+ sp<AMessage> videoInputFormat =
+ mSource->getFormat(false /* audio */);
+
+ // Take into account sample aspect ratio if necessary:
+ int32_t sarWidth, sarHeight;
+ if (videoInputFormat->findInt32("sar-width", &sarWidth)
+ && videoInputFormat->findInt32(
+ "sar-height", &sarHeight)) {
+ ALOGV("Sample aspect ratio %d : %d",
+ sarWidth, sarHeight);
+
+ displayWidth = (displayWidth * sarWidth) / sarHeight;
+
+ ALOGV("display dimensions %d x %d",
+ displayWidth, displayHeight);
+ }
+
notifyListener(
- MEDIA_SET_VIDEO_SIZE,
- cropRight - cropLeft + 1,
- cropBottom - cropTop + 1);
+ MEDIA_SET_VIDEO_SIZE, displayWidth, displayHeight);
}
} else if (what == ACodec::kWhatShutdownCompleted) {
ALOGV("%s shutdown completed", audio ? "audio" : "video");