From Stephan Huber, "attached you'll find the latest versions of the QTKit + the AVFoundation-plugin, some changes to osgPresentation and a small enhancement für ImageIO.
I fixed some bugs and did some more tests with both of the video-plugins. I integrated CoreVideo with osgPresentation, ImageStream has a new virtual method called createSuitableTexture which returns NULL for default implementations. Specialized implementations like the QTKit-plugin return a CoreVideo-texture. I refactored the code in SlideShowConstructor::createTexturedQuad to use a texture returned from ImageStream::createSuitableTexture. I did not use osgDB::readObjectFile to get the texture-object, as a lot of image-related code in SlideShowConstructor had to be refactored to use a texture. My changes are minimal and should not break existing code. There's one minor issue with CoreVideo in general: As the implementation is asynchronous, there might be no texture available, when first showing the video the first frame. I am a bit unsure how to tackle this problem, any input on this is appreciated. Back to the AVFoundation-plugin: the current implementation does not support CoreVideo as the QTKit-plugin supports it. There's no way to get decoded frames from AVFoundation stored on the GPU, which is kind of sad. I added some support for CoreVideo to transfer decoded frames back to the GPU, but in my testings the performance was worse than using the normal approach using glTexSubImage. This is why I disabled CoreVideo for AVFoundation. You can still request a CoreVideoTexture via readObjectFile, though. "
This commit is contained in:
@@ -138,9 +138,9 @@ void OSXCoreVideoTexture::apply(osg::State& state) const {
|
||||
else
|
||||
_adapter = new OSXCoreVideoAdapter(state, _image.get());
|
||||
}
|
||||
|
||||
_adapter->getFrame();
|
||||
_textureTarget = _adapter->getTextureTarget();
|
||||
|
||||
glBindTexture(_textureTarget, _adapter->getTextureName());
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,10 @@ public:
|
||||
return _waitForFirstFrame || getNeedsDispatching();
|
||||
}
|
||||
|
||||
static void initializeQTKit();
|
||||
|
||||
virtual osg::Texture* createSuitableTexture();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void applyLoopingMode();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "OSXQTKitVideo.h"
|
||||
#include "OSXCoreVideoAdapter.h"
|
||||
#include "OSXCoreVideoTexture.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -88,12 +89,37 @@ struct OSXQTKitVideo::Data {
|
||||
};
|
||||
|
||||
|
||||
void OSXQTKitVideo::initializeQTKit()
|
||||
{
|
||||
static bool inited(false);
|
||||
if (!inited)
|
||||
{
|
||||
inited = true;
|
||||
// force initialization of QTKit on the main-thread!
|
||||
if (![NSThread isMainThread]) {
|
||||
dispatch_apply(1, dispatch_get_main_queue(), ^(size_t n) {
|
||||
EnterMovies();
|
||||
QTMovie* movie = [QTMovie movie];
|
||||
// release missing by intent, gets released by the block!
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
EnterMovies();
|
||||
QTMovie* movie = [QTMovie movie];
|
||||
[movie release];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OSXQTKitVideo::OSXQTKitVideo()
|
||||
: osgVideo::VideoImageStream()
|
||||
, _rate(0.0)
|
||||
, _coreVideoAdapter(NULL)
|
||||
{
|
||||
initializeQTKit();
|
||||
|
||||
_status = INVALID;
|
||||
_data = new Data();
|
||||
_data->notificationHandler = [[NotificationHandler alloc] init];
|
||||
@@ -211,9 +237,9 @@ void OSXQTKitVideo::open(const std::string& file_name)
|
||||
|
||||
applyLoopingMode();
|
||||
|
||||
_waitForFirstFrame = true;
|
||||
_waitForFirstFrame = true;
|
||||
requestNewFrame(true);
|
||||
|
||||
_fileName = file_name;
|
||||
_status = (valid) ? PAUSED : INVALID;
|
||||
}
|
||||
|
||||
@@ -367,4 +393,9 @@ void OSXQTKitVideo::decodeFrame(bool force)
|
||||
dirty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
osg::Texture* OSXQTKitVideo::createSuitableTexture()
|
||||
{
|
||||
return new OSXCoreVideoTexture(this);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class ReaderWriterQTKit : public osgDB::ReaderWriter
|
||||
|
||||
supportsOption("disableCoreVideo", "disable the usage of coreVideo when using readObjectFile, returns an ImageStream instead");
|
||||
supportsOption("disableMultiThreadedFrameDispatching", "disable the usage of the multithreade VideoFrameDispatcher to decode video frames");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,9 @@ class ReaderWriterQTKit : public osgDB::ReaderWriter
|
||||
fileName = osgDB::findDataFile( fileName, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
static OpenThreads::Mutex mutex;
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
|
||||
|
||||
OSG_INFO<<"ReaderWriterQTKit::readImage "<< fileName<< std::endl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user