From 44002e77d2cea0767d381dc4dc9e6812c8965288 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 22 Jan 2013 16:53:50 +0000 Subject: [PATCH] From Alessandro Terenzi, "I've modified the avfoundation plugin to copy the preferredTransform matrix into the UserData property of the corresponding imagestream: by doing so, we can realize if the video should be transformed when applied as a texture (this should be the case, for instance, when we record a movie using an iOS device with any orientation different than 'landscape left')." --- .../avfoundation/OSXAVFoundationVideo.mm | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/osgPlugins/avfoundation/OSXAVFoundationVideo.mm b/src/osgPlugins/avfoundation/OSXAVFoundationVideo.mm index c7aed2782..ce26d0ddb 100644 --- a/src/osgPlugins/avfoundation/OSXAVFoundationVideo.mm +++ b/src/osgPlugins/avfoundation/OSXAVFoundationVideo.mm @@ -1,6 +1,7 @@ #include "OSXAVFoundationVideo.h" -#include +#include +#include #include #include @@ -16,6 +17,7 @@ #include "OSXAVFoundationCoreVideoTexture.h" + namespace { static NSString* toNSString(const std::string& str) @@ -353,8 +355,27 @@ void OSXAVFoundationVideo::open(const std::string& filename) AVAssetTrack* track = [tracks objectAtIndex:i]; size = track.naturalSize; _framerate = track.nominalFrameRate; + + CGAffineTransform txf = [track preferredTransform]; + + osg::Matrixf mat; + mat.makeIdentity(); + + if(!CGAffineTransformIsIdentity(txf)) + { + // user should take this into account and transform accordingly... + mat(0,0) = txf.a; + mat(1,0) = txf.c; + mat(3,0) = txf.tx; + + mat(0,1) = txf.b; + mat(1,1) = txf.d; + mat(3,1) = txf.ty; + } + + this->setUserValue("preferredTransform", mat); } - + _s = size.width; _t = size.height; _r = 1;