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')."

This commit is contained in:
Robert Osfield 2013-01-22 16:53:50 +00:00
parent 128eeb9b30
commit 44002e77d2

View File

@ -1,6 +1,7 @@
#include "OSXAVFoundationVideo.h"
#include <osgdB/FileNameUtils>
#include <osgDB/FileNameUtils>
#include <osg/ValueObject>
#include <iostream>
#include <deque>
@ -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;