summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2011-01-21 14:32:31 -0800
committerAndreas Huber <andih@google.com>2011-01-21 14:32:31 -0800
commit7fac331b39ca49ce49a67e425dcc031a3cb9e97f (patch)
treef38b5f0a2b0180deed38d27b9b91c26908785d6d
parentbc7f5b2e56107cfeaeeab13cf8979379e3c2f139 (diff)
downloadframeworks_av-7fac331b39ca49ce49a67e425dcc031a3cb9e97f.zip
frameworks_av-7fac331b39ca49ce49a67e425dcc031a3cb9e97f.tar.gz
frameworks_av-7fac331b39ca49ce49a67e425dcc031a3cb9e97f.tar.bz2
Properly rotate video that's marked as such and decoded to a surface.
Change-Id: I1e9144db3447e58c99aac3f47702ad471678789c related-to-bug: 3378148
-rw-r--r--include/media/stagefright/OMXCodec.h2
-rw-r--r--media/libstagefright/OMXCodec.cpp32
2 files changed, 34 insertions, 0 deletions
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index f8daa4f..3251c28 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -305,6 +305,8 @@ private:
void restorePatchedDataPointer(BufferInfo *info);
+ status_t applyRotation();
+
OMXCodec(const OMXCodec &);
OMXCodec &operator=(const OMXCodec &);
};
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index d842f65..94694a3 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -1680,6 +1680,33 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
return OK;
}
+status_t OMXCodec::applyRotation() {
+ sp<MetaData> meta = mSource->getFormat();
+
+ int32_t rotationDegrees;
+ if (!meta->findInt32(kKeyRotation, &rotationDegrees)) {
+ rotationDegrees = 0;
+ }
+
+ uint32_t transform;
+ switch (rotationDegrees) {
+ case 0: transform = 0; break;
+ case 90: transform = HAL_TRANSFORM_ROT_90; break;
+ case 180: transform = HAL_TRANSFORM_ROT_180; break;
+ case 270: transform = HAL_TRANSFORM_ROT_270; break;
+ default: transform = 0; break;
+ }
+
+ status_t err = OK;
+
+ if (transform) {
+ err = native_window_set_buffers_transform(
+ mNativeWindow.get(), transform);
+ }
+
+ return err;
+}
+
status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
// Get the number of buffers needed.
OMX_PARAM_PORTDEFINITIONTYPE def;
@@ -1713,6 +1740,11 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
return err;
}
+ err = applyRotation();
+ if (err != OK) {
+ return err;
+ }
+
// Set up the native window.
// XXX TODO: Get the gralloc usage flags from the OMX plugin!
err = native_window_set_usage(