- Reestructuración de ficheros y directorios general

- merge v0.01 --> Añadido fileselector
- Añadidas fuentes de Gem y Pure Data
- pix2jpg incluído en Gem. Archivos de construcción de Gem modificados.
- Añadido fichero ompiling.txt con instrucciones de compilación
This commit is contained in:
Santi Noreña 2013-02-04 18:00:17 +01:00
parent c9adfd020b
commit e85d191b46
3100 changed files with 775434 additions and 3073 deletions

33
Gem/plugins/Makefile.am Normal file
View file

@ -0,0 +1,33 @@
AUTOMAKE_OPTIONS = foreign
AM_CPPFLAGS = -I$(top_srcdir)/src
SUBDIRS =
## image loading/saving plugins
SUBDIRS += imageMAGICK imageTIFF imageJPEG imageSGI imageQT
## film loading plugins
SUBDIRS += filmAVI filmAVIPLAY filmDS filmDarwin filmGMERLIN filmMPEG1 filmMPEG3 filmQT filmQT4L
if DISABLED
SUBDIRS += filmTEST
SUBDIRS += videoTEST
endif
## Pix output (continuous) plugins
SUBDIRS += recordQT recordQT4L recordV4L recordV4L2
## video capture plugins
SUBDIRS += videoDC1394 videoDS videoDV4L videoDarwin videoSGI videoUNICAP
SUBDIRS += videoV4L videoV4L2 videoVFW videoVLC
## proprietary video capture plugins
SUBDIRS += videoAVT videoHALCON videoPYLON
## asset loading plugins
SUBDIRS += modelOBJ modelASSIMP2
## filmTEST is not built by default, but we want to ship it
DIST_SUBDIRS = $(SUBDIRS) filmTEST videoTEST

View file

@ -0,0 +1,40 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
EXTRA_DIST =
EXTRA_DIST += win-vs2003/filmAVI.sln win-vs2003/filmAVI.vcproj
EXTRA_DIST += win-vs2008/filmAVI.sln win-vs2008/filmAVI.vcproj
pkglib_LTLIBRARIES=
if WINDOWS
pkglib_LTLIBRARIES += gem_filmAVI.la
endif
gem_filmAVI_la_CXXFLAGS =
gem_filmAVI_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_filmAVI_la_LDFLAGS += -no-undefined
endif
gem_filmAVI_la_LIBADD =
# RTE
gem_filmAVI_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_filmAVI_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_filmAVI_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_filmAVI_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_filmAVI_la @MOREFLAGS@
# Dependencies
## video-for-windows
gem_filmAVI_la_CXXFLAGS += @GEM_LIB_VFW32_CFLAGS@
gem_filmAVI_la_LIBADD += @GEM_LIB_VFW32_LIBS@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_filmAVI_la_SOURCES = filmAVI.cpp filmAVI.h

View file

@ -0,0 +1,313 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef _WIN32
#include "filmAVI.h"
#include "plugins/PluginFactory.h"
#include "Utils/Functions.h"
#include "Gem/Properties.h"
#include "Gem/RTE.h"
using namespace gem::plugins;
REGISTER_FILMFACTORY("AVI", filmAVI);
/////////////////////////////////////////////////////////
//
// filmAVI
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
filmAVI :: filmAVI(void) :
m_wantedFormat(GL_RGBA),
m_fps(-1.0),
m_numFrames(-1),
m_curFrame(-1),
m_nRawBuffSize(0),
m_RawBuffer(NULL),
m_format(GL_BGR_EXT),
m_reqFrame(0),
m_frame(NULL),
m_pbmihRaw(NULL),
m_pbmihDst(NULL),
m_hic(NULL),
m_getFrame(NULL),
m_streamVid(NULL)
{
AVIFileInit();
}
/////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
filmAVI :: ~filmAVI(void)
{
close();
AVIFileExit();
}
void filmAVI :: close(void)
{
if (m_streamVid){
AVIStreamRelease(m_streamVid);
m_streamVid = NULL;
}
if (m_pbmihRaw){
delete[] m_pbmihRaw;
m_pbmihRaw = NULL;
}
if (m_pbmihDst){
delete[] m_pbmihDst;
m_pbmihDst = NULL;
}
if (m_hic) {
ICDecompressEnd(m_hic);
ICClose(m_hic);
m_hic = NULL;
}
if (m_frame){
delete[]m_frame;
m_frame = NULL;
}
if (m_RawBuffer){
delete[] m_RawBuffer;
m_RawBuffer = NULL;
}
m_nRawBuffSize = 0;
}
/////////////////////////////////////////////////////////
// open the file
//
/////////////////////////////////////////////////////////
bool filmAVI :: open(const std::string filename, const gem::Properties&wantProps)
{
AVISTREAMINFO streaminfo;
long lSize = 0; // in bytes
double d;
if(wantProps.get("colorspace", d) && d>0)
m_wantedFormat=d;
if (AVIStreamOpenFromFile(&m_streamVid, filename.c_str(), streamtypeVIDEO, 0, OF_READ, NULL)) {
//error("filmAVI: Unable to open file: %s", filename.c_str());
goto unsupported;
}
if( AVIStreamInfo( m_streamVid, &streaminfo, sizeof(streaminfo)) ||
AVIStreamReadFormat(m_streamVid, AVIStreamStart(m_streamVid), NULL, &lSize)) {
//error("filmAVI: Unable to read file format: %s", filename.c_str());
goto unsupported;
}
m_pbmihRaw = (BITMAPINFOHEADER*) new char[lSize];
if(AVIStreamReadFormat(m_streamVid, AVIStreamStart(m_streamVid), m_pbmihRaw, &lSize)) {
//error("filmAVI: Unable to read file format: %s", filename.c_str());
goto unsupported;
}
if ((8 == m_pbmihRaw->biBitCount)
|| ((40 == m_pbmihRaw->biBitCount) && (mmioFOURCC('c','v','i','d') == m_pbmihRaw->biCompression))) {
// HACK: attempt to decompress 8 bit films or BW cinepak films to greyscale
m_pbmihDst = (BITMAPINFOHEADER*) new char[sizeof(BITMAPINFOHEADER) + 256*3];
//post("filmAVI: Loading as greyscale");
*m_pbmihDst = *m_pbmihRaw;
m_pbmihDst->biSize = sizeof(BITMAPINFOHEADER);
m_format = GL_LUMINANCE;
m_pbmihDst->biBitCount = 8;
m_pbmihDst->biClrUsed = 256;
m_pbmihDst->biClrImportant = 256;
char* pClrPtr = ((char*)m_pbmihDst) + sizeof(BITMAPINFOHEADER);
for (int i = 0; i < 256; i++){
*pClrPtr++ = i;
*pClrPtr++ = i;
*pClrPtr++ = i;
}
} else {
m_pbmihDst = (BITMAPINFOHEADER*) new char[sizeof(BITMAPINFOHEADER)];
*m_pbmihDst = *m_pbmihRaw;
m_format = GL_BGR_EXT;
m_pbmihDst->biBitCount = 24;
m_pbmihDst->biClrUsed = 0;
m_pbmihDst->biClrImportant = 0;
}
m_pbmihDst->biCompression = BI_RGB;
m_pbmihDst->biSizeImage = 0;
// Get the length of the movie
m_numFrames = streaminfo.dwLength - 1;
m_fps = (double)streaminfo.dwRate / streaminfo.dwScale;
m_image.image.xsize = streaminfo.rcFrame.right - streaminfo.rcFrame.left;
m_image.image.ysize = streaminfo.rcFrame.bottom - streaminfo.rcFrame.top;
m_image.image.setCsizeByFormat(m_wantedFormat);
m_image.image.reallocate();
if (!(m_hic = ICLocate(ICTYPE_VIDEO, 0, m_pbmihRaw, m_pbmihDst, ICMODE_DECOMPRESS))){
//error("filmAVI: Could not find decompressor: %s", filename.c_str());
goto unsupported;
}
if (m_format==GL_LUMINANCE){
if (ICERR_OK != ICDecompressSetPalette(m_hic, m_pbmihDst)){
error("filmAVI: Could not set palette: %s", filename.c_str());
}
}
if (ICERR_OK != ICDecompressBegin(m_hic, m_pbmihRaw, m_pbmihDst)){
//error("filmAVI: Could not begin decompression: %s", filename.c_str());
goto unsupported;
}
//if (!m_pbmihRaw->biSizeImage)
// m_pbmihRaw->biSizeImage = m_xsize * m_ysize * m_csize;
//m_nRawBuffSize = MIN(streaminfo.dwSuggestedBufferSize, m_pbmihRaw->biSizeImage);
m_nRawBuffSize = MAX(static_cast<int>(streaminfo.dwSuggestedBufferSize), static_cast<int>(m_pbmihRaw->biSizeImage));
if(!m_nRawBuffSize)m_nRawBuffSize = m_image.image.xsize * m_image.image.ysize * 3;
m_RawBuffer = new unsigned char[m_nRawBuffSize];
m_frame = new unsigned char[m_nRawBuffSize];
m_reqFrame = 0;
m_curFrame = -1;
return true;
unsupported:
close();
return false;
}
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
pixBlock* filmAVI :: getFrame(void){
BITMAPINFOHEADER* pbmih;
long lBytesWritten;
unsigned char*data=NULL;
if (m_reqFrame > m_numFrames)m_reqFrame=m_numFrames;
m_image.newimage=1;
m_image.image.upsidedown=false;
m_image.image.setCsizeByFormat(m_wantedFormat);
m_image.image.reallocate();
if (!AVIStreamRead(m_streamVid,
m_reqFrame, 1,
m_RawBuffer, m_nRawBuffSize,
&lBytesWritten, 0)){
m_pbmihRaw->biSize = lBytesWritten;
ICDecompress(m_hic, 0, m_pbmihRaw, m_RawBuffer, m_pbmihDst, m_frame);
data=m_frame;
} else data=(unsigned char *)AVIStreamGetFrame(m_getFrame, m_curFrame)+40;
if(!data)return 0;
switch(m_format){
case GL_LUMINANCE: m_image.image.fromGray(data); break;
default: m_image.image.fromBGR(data);
}
return &m_image;
}
film::errCode filmAVI :: changeImage(int imgNum, int trackNum){
if (imgNum<0)return film::FAILURE;
if (m_numFrames<0){
m_reqFrame = imgNum;
return film::SUCCESS;
}
if (imgNum>m_numFrames){
m_reqFrame=m_numFrames;
return film::FAILURE;
}
m_reqFrame = imgNum;
return film::SUCCESS;
}
///////////////////////////////
// Properties
bool filmAVI::enumProperties(gem::Properties&readable,
gem::Properties&writeable) {
readable.clear();
writeable.clear();
gem::any value;
value=0.;
readable.set("fps", value);
readable.set("frames", value);
readable.set("width", value);
readable.set("height", value);
writeable.set("colorspace", value);
return false;
}
void filmAVI::setProperties(gem::Properties&props) {
double d;
if(props.get("colorspace", d)) {
m_wantedFormat=d;
}
}
void filmAVI::getProperties(gem::Properties&props) {
std::vector<std::string> keys=props.keys();
gem::any value;
double d;
unsigned int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
props.erase(key);
if("fps"==key) {
d=m_fps;
value=d; props.set(key, value);
}
if("frames"==key) {
d=m_numFrames;
value=d; props.set(key, value);
}
if("width"==key) {
d=m_image.image.xsize;
value=d; props.set(key, value);
}
if("height"==key) {
d=m_image.image.ysize;
value=d; props.set(key, value);
}
}
}
#endif

View file

@ -0,0 +1,95 @@
/* -----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load an digital video (like AVI, Mpeg, Quicktime) into a pix block
(OS independant parent-class)
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) Günther Geiger. geiger@epy.co.at
Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__FILMAVI_FILMAVI_H_
#define _INCLUDE_GEMPLUGIN__FILMAVI_FILMAVI_H_
#include "plugins/film.h"
#include "Gem/Image.h"
#include <vfw.h>
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
filmAVI
film-loader class for AVI(windoze)
KEYWORDS
pix film movie
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT filmAVI : public film {
public:
//////////
// Constructor
filmAVI(void);
//////////
// Destructor
virtual ~filmAVI(void);
//////////
// open a movie up
virtual bool open(const std::string filename, const gem::Properties&);
//////////
// close the movie file
virtual void close(void);
//////////
// get the next frame
virtual pixBlock* getFrame(void);
//////////
// set the next frame to read;
virtual errCode changeImage(int imgNum, int trackNum=-1);
// can be used within a threaded context
virtual bool isThreadable(void) { return true; }
// Property handling
virtual bool enumProperties(gem::Properties&readable,gem::Properties&writeable);
virtual void setProperties(gem::Properties&props);
virtual void getProperties(gem::Properties&props);
protected:
GLenum m_wantedFormat; // format requested by the user
double m_fps; // the frame-rate
int m_numFrames; // number of frames in video
int m_curFrame;
pixBlock m_image; // output image
// the raw buffer for decoding...
int m_nRawBuffSize;
unsigned char* m_RawBuffer;
GLint m_format;
int m_reqFrame;
unsigned char* m_frame; /* this points to a buffer for decompression */
BITMAPINFOHEADER* m_pbmihRaw;
BITMAPINFOHEADER* m_pbmihDst;
HIC m_hic;
PGETFRAME m_getFrame; // the frame information
PAVISTREAM m_streamVid; // the stream itself
};};};
#endif // for header file

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filmAVI", "filmAVI.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="filmAVI"
ProjectGUID="{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
RootNamespace="gem"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib vfw32.lib pd.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib pd.lib vfw32.lib OLDNAMES.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\filmAVI.cpp">
</File>
<File
RelativePath="..\filmAVI.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filmAVI", "filmAVI.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="filmAVI"
ProjectGUID="{F2368753-AF77-43B7-BE96-1292EC104941}"
RootNamespace="gem"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\VFW.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="vfw32.lib"
AdditionalLibraryDirectories=""
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\filmAVI.cpp"
>
</File>
<File
RelativePath="..\filmAVI.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,34 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
pkglib_LTLIBRARIES=
if HAVE_LIB_AVIFILE
pkglib_LTLIBRARIES+= gem_filmAVIPLAY.la
endif
gem_filmAVIPLAY_la_CXXFLAGS =
gem_filmAVIPLAY_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_filmAVIPLAY_la_LDFLAGS += -no-undefined
endif
gem_filmAVIPLAY_la_LIBADD =
# RTE
gem_filmAVIPLAY_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_filmAVIPLAY_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_filmAVIPLAY_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_filmAVIPLAY_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_filmAVIPLAY_la @MOREFLAGS@
# Dependencies
gem_filmAVIPLAY_la_CXXFLAGS += @GEM_LIB_AVIFILE_CFLAGS@
gem_filmAVIPLAY_la_LIBADD += @GEM_LIB_AVIFILE_LIBS@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_filmAVIPLAY_la_SOURCES= filmAVIPLAY.cpp filmAVIPLAY.h

View file

@ -0,0 +1,215 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_LIBAVIPLAY
#include "filmAVIPLAY.h"
#include "plugins/PluginFactory.h"
#include "Gem/Properties.h"
using namespace gem::plugins;
REGISTER_FILMFACTORY("aviplay", filmAVIPLAY);
#include <unistd.h>
#include <time.h>
/////////////////////////////////////////////////////////
//
// filmAVIPLAY
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
filmAVIPLAY :: filmAVIPLAY(void) :
m_wantedFormat(GL_RGBA),
m_fps(-1.0),
m_numFrames(-1), m_numTracks(-1),
m_curFrame(-1), m_curTrack(-1),
m_readNext(false), m_newfilm(false),
m_avifile(NULL),
m_avistream(NULL),
m_aviimage(NULL),
m_rawdata(NULL),
m_rawlength(0)
{
}
/////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
filmAVIPLAY :: ~filmAVIPLAY(void)
{
close();
if(m_rawdata)delete[]m_rawdata;
}
void filmAVIPLAY :: close(void)
{
if (m_avistream)(*m_avistream).StopStreaming();
}
/////////////////////////////////////////////////////////
// open the file
//
/////////////////////////////////////////////////////////
bool filmAVIPLAY :: open(const std::string filename, const gem::Properties&wantProps)
{
double d;
if(wantProps.get("colorspace", d) && d>0) {
m_wantedFormat=d;
}
// how do we close the avifile ??? automagically ?
if (!(m_avifile = CreateIAviReadFile(filename.c_str())))goto unsupported;
while(!(*m_avifile).IsOpened()){
struct timeval sleep;
sleep.tv_sec=0;
sleep.tv_usec=500;/*500us*/
select(0,0,0,0,&sleep);
}
if (!(*m_avifile).IsValid())goto unsupported;
m_numTracks = (*m_avifile).VideoStreamCount();
if (m_numTracks<1)return false;
if (m_curTrack>=m_numTracks)m_curTrack = 0;
try {
m_avistream=(*m_avifile).GetStream(m_curTrack, avm::IStream::StreamType(1));
} catch (const char* string) {
m_avistream = 0;
}
if (!m_avistream)goto unsupported;
if ((*m_avistream).StartStreaming()==-1)goto unsupported;
m_numFrames = (*m_avistream).GetLength();
m_curFrame = -1;
if (1){
avm::StreamInfo *l_info = (*m_avistream).GetStreamInfo();
m_image.image.xsize = (*l_info).GetVideoWidth();
m_image.image.ysize = (*l_info).GetVideoHeight();
m_fps= (*l_info).GetFps();
}
m_image.image.setCsizeByFormat(m_wantedFormat);
if (!(m_image.image.xsize*m_image.image.ysize*m_image.image.csize))goto unsupported;
m_readNext=true;
m_newfilm = true;
return true;
goto unsupported;
unsupported:
close();
return false;
}
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
pixBlock* filmAVIPLAY :: getFrame(){
if (!m_avistream)return 0;
if (!m_readNext)return &m_image;
if(m_aviimage)(*m_aviimage).Release();
/* for MPEGs ReadFrame() will return 0 only when errors occur
* other formats return 0 all the time (and -1 on file end)
*/
m_aviimage = (*m_avistream).GetFrame(true); // this might crash sometimes...
if (m_aviimage){
int format = (*m_aviimage).Format();
m_rawdata=(*m_aviimage).Data();
m_image.image.setCsizeByFormat(m_wantedFormat);
switch(format){
case IMG_FMT_RGB24: m_image.image.fromRGB (m_rawdata); break;
case IMG_FMT_RGB32: m_image.image.fromRGBA(m_rawdata); break;
case IMG_FMT_BGR24: m_image.image.fromBGR (m_rawdata); break;
case IMG_FMT_BGR32: m_image.image.fromBGRA(m_rawdata); break;
case IMG_FMT_Y800 :
case IMG_FMT_Y8 : m_image.image.fromGray(m_rawdata); break;
case IMG_FMT_UYVY : m_image.image.fromUYVY(m_rawdata); break;
case IMG_FMT_YUY2 : m_image.image.fromYUY2(m_rawdata); break;
case IMG_FMT_YVYU : m_image.image.fromYVYU(m_rawdata); break;
case IMG_FMT_YV12 : m_image.image.fromYV12(m_rawdata); break;
case IMG_FMT_BGR16: // it seems like this was RGB16
default:
m_image.image.fromRGB16(m_rawdata); break;
}
m_image.newimage=1;
if (m_newfilm)m_image.newfilm=1; m_newfilm=false;
m_image.image.upsidedown=true;
m_readNext=false;
return &m_image;
}
return 0;
}
film::errCode filmAVIPLAY :: changeImage(int imgNum, int trackNum){
if (!m_avistream)return film::FAILURE;
m_avistream->Seek(imgNum);
m_readNext=true;
return film::SUCCESS;
}
///////////////////////////////
// Properties
bool filmAVIPLAY::enumProperties(gem::Properties&readable,
gem::Properties&writeable) {
readable.clear();
writeable.clear();
gem::any value;
value=0.;
readable.set("fps", value);
readable.set("frames", value);
readable.set("width", value);
readable.set("height", value);
return false;
}
void filmAVIPLAY::setProperties(gem::Properties&props) {
}
void filmAVIPLAY::getProperties(gem::Properties&props) {
std::vector<std::string> keys=props.keys();
gem::any value;
double d;
unsigned int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
props.erase(key);
if("fps"==key) {
d=m_fps;
value=d; props.set(key, value);
}
if("frames"==key && m_numFrames>=0) {
d=m_numFrames;
value=d; props.set(key, value);
}
if("tracks"==key && m_numTracks>=0) {
d=m_numTracks;
value=d; props.set(key, value);
}
if("width"==key) {
d=m_image.image.xsize;
value=d; props.set(key, value);
}
if("height"==key) {
d=m_image.image.ysize;
value=d; props.set(key, value);
}
}
}
#endif // AVIPLAY

View file

@ -0,0 +1,120 @@
/* -----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load an digital video (like AVI, Mpeg, Quicktime) into a pix block
(OS independant parent-class)
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) Günther Geiger. geiger@epy.co.at
Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__FILMAVIPLAY_FILMAVIPLAY_H_
#define _INCLUDE_GEMPLUGIN__FILMAVIPLAY_FILMAVIPLAY_H_
#include "plugins/film.h"
#include "Gem/Image.h"
#if defined (_WIN32) & defined (HAVE_LIBAVIPLAY)
// un windows there are other ways...
#undef HAVE_LIBAVIPLAY
#endif
#ifdef HAVE_LIBAVIPLAY
/* this used to be <avifile/avifile.h>
* but on my system it changed to <avifile-0.7/avifile.h>
* so we now find the correct path via "configure"
*/
// ugly hack, since avifile.h does weird things if HAVE_CONFIG_H is defined
# undef HAVE_CONFIG_H
# include "avifile.h"
# include "infotypes.h"
# include "image.h"
// some version checking...
# ifndef IMG_FMT_RGB24
# undef HAVE_LIBAVIPLAY
# endif // IMG_FMT_RGB24
#endif
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
filmAVIPLAY
film-loader class for AVIPLAY(linux)
KEYWORDS
pix film movie
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT filmAVIPLAY : public film {
public:
//////////
// Constructor
filmAVIPLAY(void);
//////////
// Destructor
~filmAVIPLAY(void);
#ifdef HAVE_LIBAVIPLAY
//////////
// open a movie up
virtual bool open(const std::string filename, const gem::Properties&);
//////////
// close the movie file
virtual void close(void);
//////////
// get the next frame
virtual pixBlock* getFrame(void);
//////////
// set the next frame to read;
virtual errCode changeImage(int imgNum, int trackNum=-1);
// can be used within a threaded context
virtual bool isThreadable(void) { return true; }
// Property handling
virtual bool enumProperties(gem::Properties&readable,gem::Properties&writeable);
virtual void setProperties(gem::Properties&props);
virtual void getProperties(gem::Properties&props);
protected:
GLenum m_wantedFormat; // format requested by the user
double m_fps; // the frame-rate
int m_numFrames, m_numTracks; // number of frames in video
int m_curFrame, m_curTrack;
pixBlock m_image; // output image
bool m_readNext; // indicates whether we should perform a seek/read
bool m_newfilm;
IAviReadFile *m_avifile;
IAviReadStream *m_avistream;
# ifdef AVM_BEGIN_NAMESPACE
avm::CImage *m_aviimage;
# else
CImage *m_aviimage;
# endif
#endif //AVIPLAY
unsigned char *m_rawdata;
long m_rawlength;
};};};
#endif // for header file

View file

@ -0,0 +1,38 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
EXTRA_DIST =
EXTRA_DIST += win-vs2003/filmDS.sln win-vs2003/filmDS.vcproj
EXTRA_DIST += win-vs2008/filmDS.sln win-vs2008/filmDS.vcproj
pkglib_LTLIBRARIES=
if WINDOWS
pkglib_LTLIBRARIES+= gem_filmDS.la
endif
gem_filmDS_la_CXXFLAGS =
gem_filmDS_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_filmDS_la_LDFLAGS += -no-undefined
endif
gem_filmDS_la_LIBADD =
# RTE
gem_filmDS_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_filmDS_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_filmDS_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_filmDS_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_filmDS_la @MOREFLAGS@
# Dependencies
# none
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_filmDS_la_SOURCES= filmDS.cpp filmDS.h

View file

@ -0,0 +1,896 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef _MSC_VER
# define snprintf _snprintf
#endif
#if defined(_WIN32) && defined(HAVE_DIRECTSHOW)
#ifndef HAVE_DXTRANS_H
// http://jaewon.mine.nu/jaewon/2009/06/17/a-workaround-for-a-missing-file-dxtrans-h-in-directx-sdk/
# pragma include_alias( "dxtrans.h", "qedit.h" )
# define __IDxtCompositor_INTERFACE_DEFINED__
# define __IDxtAlphaSetter_INTERFACE_DEFINED__
# define __IDxtJpeg_INTERFACE_DEFINED__
# define __IDxtKey_INTERFACE_DEFINED__
#endif
#include "filmDS.h"
#include "plugins/PluginFactory.h"
#include "Gem/RTE.h"
#include "Gem/Properties.h"
#include "Gem/Exception.h"
using namespace gem::plugins;
REGISTER_FILMFACTORY("DirectShow", filmDS);
#include <atlbase.h>
#include <atlconv.h>
#include <streams.h>
#include <dvdmedia.h>
#define REGISTER_FILTERGRAPH 1
#include <strsafe.h>
HRESULT filmGetPin(IBaseFilter *pFilter, PIN_DIRECTION PinDir, IPin **ppPin);
HRESULT filmConnectFilters(IGraphBuilder *pGraph, IBaseFilter *pFirst, IBaseFilter *pSecond);
HRESULT filmAddGraphToRot(IUnknown *pUnkGraph, DWORD *pdwRegister) ;
void filmRemoveGraphFromRot(DWORD pdwRegister);
/////////////////////////////////////////////////////////
//
// filmDS
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
static void throwCtorError(const char*format, HRESULT RetVal) {
char errstring[MAXPDSTRING];
snprintf(errstring, MAXPDSTRING-1, format, RetVal);
errstring[MAXPDSTRING-1]=0;
throw(GemException(errstring));
}
filmDS :: filmDS(void) :
m_numFrames(-1),
m_reqFrame(1),
m_frame(NULL),
m_xsize(0), m_ysize(0), m_csize(0),
m_auto(0.f),
VideoFilter(NULL),
SampleFilter(NULL),
NullFilter(NULL),
SampleGrabber(NULL),
FilterGraph(NULL),
MediaControl(NULL),
MediaSeeking(NULL),
MediaPosition(NULL),
m_Duration(0),
m_LastFrame(0)
{
HRESULT RetVal;
CoInitialize(NULL);
// Create the base object of a filter graph
RetVal = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&FilterGraph);
if (RetVal != S_OK || NULL == FilterGraph)
{
throwCtorError("Unable to create FilterGraph interface %d", RetVal);
return;
}
// Get the IMediaControl interface for Run, Stop, Pause and keeps control states
RetVal = FilterGraph->QueryInterface(IID_IMediaControl, (void **)&MediaControl);
if (RetVal != S_OK || NULL == MediaControl)
{
throwCtorError("Unable to create MediaControl interface %d", RetVal);
return;
}
// Get the IMediaSeeking interface for rewinding video at loop point
// and set time format to frames
RetVal = FilterGraph->QueryInterface(IID_IMediaSeeking, (void **)&MediaSeeking);
if (RetVal != S_OK || NULL == MediaSeeking)
{
throwCtorError("Unable to create MediaSeeking interface %d", RetVal);
return;
}
// Get the IMediaPosition interface for getting the current position of the clip
RetVal = FilterGraph->QueryInterface(IID_IMediaPosition, (void **)&MediaPosition);
if (RetVal != S_OK || NULL == MediaPosition)
{
throwCtorError("Unable to create MediaPosition interface %d", RetVal);
return;
}
}
////////////////////////////////////////////////////////
// Destructor
//
////////////////////////////////////////////////////////
filmDS :: ~filmDS()
{
close();
// Release IMediaControl interface
if (MediaControl != NULL)
{
MediaControl->Release();
MediaControl = NULL;
}
// Release IMediaSeeking interface
if (MediaSeeking != NULL)
{
MediaSeeking->Release();
MediaSeeking = NULL;
}
// Release IMediaPosition interface
if (MediaPosition != NULL)
{
MediaPosition->Release();
MediaPosition = NULL;
}
// Release base FilterGraph
if (FilterGraph != NULL)
{
FilterGraph->Release();
FilterGraph = NULL;
}
// Release COM
CoUninitialize();
}
void filmDS :: close(void)
{
// Stop the video. Filters cannot be remove until video is stopped
if (MediaControl != NULL)
{
MediaControl->Stop();
}
// Release ISampleGrabber interface
if (SampleGrabber != NULL)
{
SampleGrabber->Release();
SampleGrabber = NULL;
}
// Remove and release SampleFilter (IBaseFilter) interface
if (SampleFilter != NULL)
{
FilterGraph->RemoveFilter(SampleFilter);
SampleFilter->Release();
SampleFilter = NULL;
}
// Remove and release VideoFilter (IBaseFilter) interface
if (VideoFilter != NULL)
{
FilterGraph->RemoveFilter(VideoFilter);
VideoFilter->Release();
VideoFilter = NULL;
}
// Remove and release NullFilter (IBaseFilter) interface
if (NullFilter != NULL)
{
FilterGraph->RemoveFilter(NullFilter);
NullFilter->Release();
NullFilter = NULL;
}
// Delete the graphics buffer
if (m_frame != NULL)
{
delete [] m_frame;
m_frame = NULL;
}
#ifdef REGISTER_FILTERGRAPH
if (m_GraphRegister)
{
HRESULT hr;
filmRemoveGraphFromRot(m_GraphRegister);
m_GraphRegister = 0;
}
#endif
}
/////////////////////////////////////////////////////////
// open the file
//
/////////////////////////////////////////////////////////
bool filmDS :: open(const std::string filename, const gem::Properties&wantProps)
{
WCHAR WideFileName[MAXPDSTRING];
HRESULT RetVal;
AM_MEDIA_TYPE MediaType;
BOOL bFrameTime = TRUE;
GUID Guid;
verbose(1, "Trying DirectShow");
// Convert c-string to Wide string.
memset(&WideFileName, 0, MAXPDSTRING * 2);
if (0 == MultiByteToWideChar(CP_ACP, 0, filename.c_str(), filename.length(), WideFileName,
MAXPDSTRING))
{
error("filmDS: Unable to load %s", filename.c_str());
return false;
}
// Add a file source filter to the filter graph.
RetVal = FilterGraph->AddSourceFilter(WideFileName, L"SOURCE", &VideoFilter);
if (RetVal != S_OK || NULL == VideoFilter)
{
error("filmDS: Unable to render %s", filename.c_str());
return false;
}
// Create an instance of the sample grabber filter. The filter allows frames to be
// buffered from a video source.
RetVal = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER,
IID_IBaseFilter, (void**)&SampleFilter);
if (RetVal != S_OK || NULL == SampleFilter)
{
error("Unable to create SampleFilter interface %d", RetVal);
return false;
}
// Add sample grabber filter to the filter graph.
RetVal = FilterGraph->AddFilter(SampleFilter, L"Sample Grabber");
if (RetVal != S_OK)
{
error("Unable to add SampleFilter %d", RetVal);
return false;
}
// Find an interface to the SampleGrabber from the SampleGrabber filter. The
// SampleGrabber allows frames to be grabbed from the filter. SetBufferSamples(TRUE)
// tells the SampleGrabber to buffer the frames. SetOneShot(FALSE) tells the
// SampleGrabber to continuously grab frames. has GetCurrentBuffer() method
RetVal = SampleFilter->QueryInterface(IID_ISampleGrabber, (void **)&SampleGrabber);
if (RetVal != S_OK || NULL == SampleGrabber)
{
error("Unable to create SampleGrabber interface %d", RetVal);
return false;
}
// Set the media type that the SampleGrabber wants.
// MEDIATYPE_Video selects only video and not interleaved audio and video
// MEDIASUBTYPE_RGB24 is the colorspace and format to deliver frames
// MediaType.formattype is GUID_NULLsince it is handled later to get file info
memset(&MediaType, 0, sizeof(AM_MEDIA_TYPE));
MediaType.majortype = MEDIATYPE_Video;
MediaType.subtype = MEDIASUBTYPE_RGB32;
//MediaType.subtype = MEDIASUBTYPE_RGB24;
//MediaType.subtype = MEDIASUBTYPE_UYVY;
MediaType.formattype = GUID_NULL;
RetVal = SampleGrabber->SetMediaType(&MediaType);
// Set the SampleGrabber to return continuous frames
RetVal = SampleGrabber->SetOneShot(FALSE);
if (RetVal != S_OK)
{
error("Unable to setup sample grabber %d", RetVal);
return false;
}
// Set the SampleGrabber to copy the data to a buffer. This only set to FALSE when a
// callback is used.
RetVal = SampleGrabber->SetBufferSamples(TRUE);
if (RetVal != S_OK)
{
error("Unable to setup sample grabber %d", RetVal);
return false;
}
// Create the Null Renderer interface. The Null Renderer is used to disable rendering of a
// video stream to a window.
RetVal = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER,
IID_IBaseFilter, (void**)&NullFilter);
if (RetVal != S_OK || NULL == NullFilter)
{
error("Unable to create NullFilter interface %d", RetVal);
return false;
}
// Add the Null Renderer filter to the FilterGraph
RetVal = FilterGraph->AddFilter(NullFilter, L"NullRenderer");
if (RetVal != S_OK)
{
error("Unable to add NullFilter %d", RetVal);
return false;
}
// DS filter chain is FileSource -> SampleGrabber -> NullRenderer
// DS can put any neeeded filters in the chain for format or colorspace conversion
// decompression or other transforms
// Connect the SampleFilter to the VideoFilter
RetVal = filmConnectFilters(FilterGraph, VideoFilter, SampleFilter);
if (RetVal != S_OK)
{
error("Unable to connect filters %d", RetVal);
return false;
}
// Connect the NullFilter to the SampleFilter
RetVal = filmConnectFilters(FilterGraph, SampleFilter, NullFilter);
if (RetVal != S_OK)
{
error("Unable to connect filters %d", RetVal);
return false;
}
// Set the time format to frames
Guid = TIME_FORMAT_FRAME;
RetVal = MediaSeeking->SetTimeFormat(&Guid);
if (RetVal != S_OK)
{
// If frame time format not available, default to 100 nanosecond increments.
bFrameTime = FALSE;
Guid = TIME_FORMAT_MEDIA_TIME;
RetVal = MediaSeeking->SetTimeFormat(&Guid);
if (RetVal != S_OK)
{
error("Unable to set video time format %d", RetVal);
return false;
}
}
// Get the duration of the video. Format will be in previously set time format. This is
// compatible with the value returned from GetCurrentPosition
RetVal = MediaSeeking->GetDuration(&m_Duration);
if (RetVal != S_OK)
{
error("Unable to get video duration %d", RetVal);
return false;
}
// Set the number of frames based on the time format used.
if (TRUE == bFrameTime)
{
m_numFrames = m_Duration;
}
else
{
LONGLONG OutFormat;
GUID OutGuid;
OutGuid = TIME_FORMAT_FRAME;
Guid = TIME_FORMAT_MEDIA_TIME;
//converts from 100 nanosecond format to number of frames
MediaSeeking->ConvertTimeFormat(&OutFormat, &OutGuid, m_Duration, &Guid);
m_numFrames = OutFormat;
}
// Get the format of the connected media.
RetVal = SampleGrabber->GetConnectedMediaType(&MediaType);
if (RetVal != S_OK)
{
error("Unable to get media type %d", RetVal);
return false;
}
// The SampleGrabber will only return video of the the 'FORMAT_VideoInfo' type.
if (FORMAT_VideoInfo == MediaType.formattype && MediaType.pbFormat != NULL)
{
// Format returned is specific to the formattype.
VIDEOINFOHEADER *VideoInfo = (VIDEOINFOHEADER *)MediaType.pbFormat;
// Get size of the image from the BitmapInfoHeader returned in the VIDEOINFOHEADER.
m_xsize = VideoInfo->bmiHeader.biWidth;
m_ysize = VideoInfo->bmiHeader.biHeight;
//m_csize = 3;
m_csize = 4;
}
else
{
error("Invalid media type returned %s", filename.c_str());
return false;
}
// Allocate video buffer if valid sizes returned.
if (m_xsize > 0 && m_ysize > 0 && m_csize > 0)
{
if (m_frame != NULL)
{
delete [] m_frame;
}
m_frame = new BYTE[m_xsize * m_ysize * m_csize];
if (NULL == m_frame)
{
error("Unable to allocate memory for the video buffer %s", filename.c_str());
return false;
}
}
// Release the MediaType.pbFormat data
FreeMediaType(MediaType);
IBaseFilter *DVFilter;
// If DV video is used, set the quality to 720 x 480.
RetVal = FilterGraph->FindFilterByName(L"DV Video Decoder", &DVFilter);
if (S_OK == RetVal && DVFilter != NULL)
{
IIPDVDec *IPDVDec;
// Find the IIPDVDec interface
RetVal = DVFilter->QueryInterface(IID_IIPDVDec, (void **)&IPDVDec);
if (S_OK == RetVal && IPDVDec != NULL)
{
// Set the property to DVRESOLUTION_FULL
IPDVDec->put_IPDisplay(DVRESOLUTION_FULL);
// Release the interface
IPDVDec->Release();
}
// Release the interface
DVFilter->Release();
}
// Setup the pixBlock data based on the media type.
// this is a guess at the fast past for pixels on Windows
m_image.image.xsize = m_xsize;
m_image.image.ysize = m_ysize;
m_image.image.csize = m_csize;
if (m_csize == 3) m_image.image.format = GL_BGR_EXT;
if (m_csize == 4) m_image.image.format = GL_BGRA;
m_image.image.type = GL_UNSIGNED_BYTE;
// Start the video stream
RetVal = MediaControl->Run();
if (RetVal != S_OK && RetVal != S_FALSE)
{
error("Unable to start video %d", RetVal);
return false;
}
// Wait for the video to begin playing.
while (TRUE)
{
OAFilterState FilterState;
// Get the state and ensure it's not in an intermediate state
RetVal = MediaControl->GetState(0, &FilterState);
if (RetVal != S_OK && RetVal != VFW_S_STATE_INTERMEDIATE)
{
error("Unable to run video %d", RetVal);
return false;
}
// Ensure the video is running
else if (RetVal == S_OK && State_Running == FilterState)
{
break;
}
}
// Sets the tex coords
// prepareTexture();
// Set the last frame to -1 so it will show the first frame.
m_LastFrame = -1;
// m_haveMovie = TRUE;
#ifdef REGISTER_FILTERGRAPH
if (FAILED(RetVal = filmAddGraphToRot(FilterGraph, &m_GraphRegister))){
error("filmDS: failed to register filter graph with ROT! hr=0x%X", RetVal);
m_GraphRegister = 0;
}
#endif
return true;
}
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
pixBlock* filmDS :: getFrame(){
long frameSize = m_ysize * m_xsize * m_csize;
HRESULT RetVal;
OAFilterState State;
// LONGLONG CurrentPosition;
// LONGLONG Current = 0;
// Initially set the image as unchanged
m_image.newimage = FALSE;
// If the MediaControl interface is unavailable return.
if (NULL == MediaControl)
{
return 0;
}
// Ensure the video is running
RetVal = MediaControl->GetState(0, &State);
if (m_auto > 0.f){
//if the video is paused then start it running again
if (State != State_Running)
{
RetVal = MediaControl->Run();
RetVal = MediaControl->GetState(0, &State);
}
//set the rate of the clip
RetVal = MediaSeeking->SetRate(m_auto);
if (SampleGrabber != NULL && State == State_Running)
{
// Get the current position of the video
if (MediaSeeking != NULL)
{
LONGLONG CurrentPosition;
RetVal = MediaSeeking->GetCurrentPosition(&CurrentPosition);
if (S_OK == RetVal)
{
// If the current position is >= the duration, reset the position to the
// beginning
if (CurrentPosition >= m_Duration)
{
LONGLONG Current = 0;
// Set the start position to 0, do not change the end position.
RetVal = MediaSeeking->SetPositions(&Current,
AM_SEEKING_AbsolutePositioning | AM_SEEKING_NoFlush,
NULL, AM_SEEKING_NoPositioning);
m_image.newimage = TRUE;
}
// Indicate the the image has changed.
else if (CurrentPosition > m_LastFrame)
{
m_image.newimage = TRUE;
}
}
}
// If the video image has changed, copy it to the pixBlock buffer.
if (TRUE == m_image.newimage)
{
RetVal = SampleGrabber->GetCurrentBuffer(&frameSize, (long *)m_frame);
if (RetVal != S_OK)
{
m_image.image.data = NULL;
}
else
{
m_image.image.data = m_frame;
//m_image.image.fromBGR(m_frame);
}
}
}
}else{
LONGLONG frameSeek;
frameSeek = (LONGLONG) m_reqFrame;
if (State == State_Running) RetVal = MediaControl->Pause();
//check if the playback is 'Paused' and don't keep asking for the same frame
if (m_reqFrame == m_LastFrame)
{
m_image.newimage = FALSE;
return &m_image;
}
RetVal = MediaSeeking->SetPositions(&frameSeek,
AM_SEEKING_AbsolutePositioning,
NULL, AM_SEEKING_NoPositioning);
if (RetVal != S_OK)
{
post("filmDS: SetPositions failed");
}
RetVal = SampleGrabber->GetCurrentBuffer(&frameSize, (long *)m_frame);
if (RetVal != S_OK)
{
m_image.image.data = NULL;
post("filmDS: GetCurrentBuffer failed");
}
else
{
m_image.image.data = m_frame;
m_image.newimage = TRUE;
//m_image.image.fromBGR(m_frame);
m_LastFrame = m_reqFrame;
}
}
return &m_image;
}
film::errCode filmDS :: changeImage(int imgNum, int trackNum){
m_reqFrame = imgNum;
if (m_reqFrame > m_Duration) return film::FAILURE;
return film::SUCCESS;
}
///////////////////////////////
// Properties
bool filmDS::enumProperties(gem::Properties&readable, gem::Properties&writeable) {
readable.clear();
writeable.clear();
gem::any value;
value=0.;
readable.set("frames", value);
readable.set("width", value);
readable.set("height", value);
return false;
}
void filmDS::setProperties(gem::Properties&props) {
std::vector<std::string> keys=props.keys();
gem::any value;
double d;
unsigned int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
if("auto"==key) {
if(props.get(key, d)) {
m_auto=d;
}
}
}
}
void filmDS::getProperties(gem::Properties&props) {
std::vector<std::string> keys=props.keys();
gem::any value;
double d;
unsigned int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
props.erase(key);
if("frames"==key) {
d=m_numFrames;
value=d; props.set(key, value);
}
if("width"==key) {
d=m_image.image.xsize;
value=d; props.set(key, value);
}
if("height"==key) {
d=m_image.image.ysize;
value=d; props.set(key, value);
}
}
}
HRESULT filmGetPin(IBaseFilter *pFilter, PIN_DIRECTION PinDir, IPin **ppPin)
{
IEnumPins *pEnum;
IPin *pPin;
// Enumerate the pins on the filter
pFilter->EnumPins(&pEnum);
if (NULL == pEnum)
{
return E_FAIL;
}
// Get the next pin. Needs to be called initially to get the first pin.
while (pEnum->Next(1, &pPin, 0) == S_OK)
{
PIN_DIRECTION PinDirThis;
// Get the direction of a pin
pPin->QueryDirection(&PinDirThis);
// Check if pin is the same type of pin requested. Will only return the first pin
// of a certain direction.
if (PinDir == PinDirThis)
{
// Release the interface
pEnum->Release();
// Return the pin, since it's the same direction as requested.
*ppPin = pPin;
return S_OK;
}
// Release the pin, since it's not the correct direction.
pPin->Release();
}
// Release the interface
pEnum->Release();
return E_FAIL;
}
HRESULT filmConnectFilters(IGraphBuilder *pGraph, IBaseFilter *pFirst, IBaseFilter *pSecond)
{
IPin *pOut = NULL;
IPin *pIn = NULL;
// Find the first output pin on the first filter
HRESULT RetVal = filmGetPin(pFirst, PINDIR_OUTPUT, &pOut);
if (RetVal != S_OK)
{
return RetVal;
}
if (NULL == pOut)
{
return E_FAIL;
}
// Find the first input pin on the second filter
RetVal = filmGetPin(pSecond, PINDIR_INPUT, &pIn);
if (RetVal != S_OK)
{
return RetVal;
}
if (NULL == pIn)
{
return E_FAIL;
}
if (RetVal != S_OK)
{
pOut->Release();
return E_FAIL;
}
// Attempt to connect the two pins.
RetVal = pGraph->Connect(pOut, pIn);
// A filter having audio and video will return a VFW_S_PARTIAL_RENDER when attempting
// to connect to a filter only having video (ie. the SampleGrabber filter)
if (VFW_S_PARTIAL_RENDER == RetVal)
{
return S_OK;
}
// Release the pins
pIn->Release();
pOut->Release();
return RetVal;
}
HRESULT filmAddGraphToRot(IUnknown *pUnkGraph, DWORD *pdwRegister)
{
IMoniker * pMoniker;
IRunningObjectTable *pROT;
if (FAILED(GetRunningObjectTable(0, &pROT)))
{
return E_FAIL;
}
WCHAR wsz[128];
StringCchPrintfW(wsz, 128, L"FilterGraph %08x pid %08x", (DWORD_PTR)pUnkGraph,
GetCurrentProcessId());
HRESULT hr = CreateItemMoniker(L"!", wsz, &pMoniker);
if (SUCCEEDED(hr))
{
hr = pROT->Register(0, pUnkGraph, pMoniker, pdwRegister);
pMoniker->Release();
}
pROT->Release();
return hr;
}
void filmRemoveGraphFromRot(DWORD pdwRegister)
{
IRunningObjectTable *pROT;
if (SUCCEEDED(GetRunningObjectTable(0, &pROT)))
{
pROT->Revoke(pdwRegister);
pROT->Release();
}
}
#endif

104
Gem/plugins/filmDS/filmDS.h Normal file
View file

@ -0,0 +1,104 @@
/* -----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load an digital video (like AVI, Mpeg, Quicktime) into a pix block
(OS independant parent-class)
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) Günther Geiger. geiger@epy.co.at
Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__FILMDS_FILMDS_H_
#define _INCLUDE_GEMPLUGIN__FILMDS_FILMDS_H_
#include "plugins/film.h"
#include "Gem/Image.h"
#include <dshow.h>
#include <qedit.h>
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
filmDS
film-loader class for AVI(windoze)
KEYWORDS
pix film movie
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT filmDS : public film {
public:
//////////
// Constructor
filmDS(void);
//////////
// Destructor
virtual ~filmDS(void);
//////////
// open a movie up
virtual bool open(const std::string filename, const gem::Properties&);
//////////
// close the movie file
virtual void close(void);
//////////
// get the next frame
virtual pixBlock* getFrame(void);
//////////
// set the next frame to read;
virtual errCode changeImage(int imgNum, int trackNum=-1);
// can be used within a threaded context
virtual bool isThreadable(void) { return true; }
// Property handling
virtual bool enumProperties(gem::Properties&readable,gem::Properties&writeable);
virtual void setProperties(gem::Properties&props);
virtual void getProperties(gem::Properties&props);
protected:
int m_numFrames; // number of frames in video
pixBlock m_image; // output image
int m_reqFrame;
unsigned char* m_frame; /* this points to a buffer for decompression */
int m_xsize;
int m_ysize;
int m_csize;
double m_auto;
private:
IBaseFilter *VideoFilter; // Base Filter for video
IBaseFilter *SampleFilter; // Sample filter
IBaseFilter *NullFilter; // Null render base Filter for video
ISampleGrabber *SampleGrabber; // Sample grabber
IGraphBuilder *FilterGraph; // Filter Graph for movie playback
IMediaControl *MediaControl; // MediaControl interface
IMediaSeeking *MediaSeeking; // MediaSeeking interface
IMediaPosition *MediaPosition; // MediaPosition interface
LONGLONG m_Duration; // Duration of video
LONGLONG m_LastFrame; // Last frame
unsigned long m_GraphRegister;
};}; };
#endif // for header file

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filmDS", "filmDS.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="filmDS"
ProjectGUID="{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
RootNamespace="gem"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="0"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;;&quot;C:\DXSDK\samples\C++\DirectShow\BaseClasses&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN;HAVE_DIRECTSHOW"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib pd.lib ddraw.lib atls.lib strmiids.lib strmbase.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;;&quot;C:\DXSDK\samples\C++\DirectShow\BaseClasses\Release&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib pd.lib vfw32.lib OLDNAMES.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\filmDS.cpp">
</File>
<File
RelativePath="..\filmDS.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filmDS", "filmDS.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,171 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="filmDS"
ProjectGUID="{6EA41ED7-ECCD-4A9A-BED0-E8E4B4BD77EB}"
RootNamespace="gem"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops;..\..\..\build\win-vs2008\DirectShow.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\filmDS.cpp"
>
</File>
<File
RelativePath="..\filmDS.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,35 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
pkglib_LTLIBRARIES=
if MACOSX
pkglib_LTLIBRARIES+= gem_filmDarwin.la
endif
gem_filmDarwin_la_CXXFLAGS =
gem_filmDarwin_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_filmDarwin_la_LDFLAGS += -no-undefined
endif
gem_filmDarwin_la_LIBADD =
# RTE
gem_filmDarwin_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_filmDarwin_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_filmDarwin_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_filmDarwin_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_filmDarwin_la @MOREFLAGS@
# Dependencies
gem_filmDarwin_la_CXXFLAGS += @GEM_FRAMEWORK_QUICKTIME@ @GEM_FRAMEWORK_CARBON@
gem_filmDarwin_la_LIBADD += @GEM_FRAMEWORK_QUICKTIME@ @GEM_FRAMEWORK_CARBON@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_filmDarwin_la_SOURCES= filmDarwin.cpp filmDarwin.h

View file

@ -0,0 +1,358 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// Copyright (c) 2002 James Tittle & Chris Clepper
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "filmDarwin.h"
#ifdef HAVE_CARBONQUICKTIME
#include "plugins/PluginFactory.h"
#include "Gem/RTE.h"
#include "Gem/Properties.h"
using namespace gem::plugins;
REGISTER_FILMFACTORY("Darwin", filmDarwin);
/////////////////////////////////////////////////////////
//
// filmDarwin
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
filmDarwin :: filmDarwin(void) :
m_wantedFormat(GL_YUV422_GEM),
m_auto(false),
m_numFrames(-1), m_numTracks(-1),
m_curFrame(-1), m_lastFrame(-1),
m_movie(NULL),
m_srcGWorld(NULL),
m_movieTime(0),
m_movieTrack(0),
m_movieMedia(0),
m_timeScale(0),
m_durationf(0.),
m_fps(1.)
{}
////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
filmDarwin :: ~filmDarwin(void)
{
close();
}
void filmDarwin :: close(void)
{
if(m_srcGWorld){
::DisposeMovie(m_movie);
::DisposeGWorld(m_srcGWorld);
m_srcGWorld = NULL;
}
}
/////////////////////////////////////////////////////////
// open the file
//
/////////////////////////////////////////////////////////
bool filmDarwin :: open(const std::string filename, const gem::Properties&wantProps)
{
double d;
if(wantProps.get("colorspace", d) && d>0) {
m_wantedFormat=d;
}
FSSpec theFSSpec;
OSErr err = noErr;
FSRef ref;
Rect m_srcRect;
long m_rowBytes;
OSType whichMediaType = VisualMediaCharacteristic;
short flags = nextTimeMediaSample + nextTimeEdgeOK;
short refnum = 0;
OSType pixelformat=0;
long hints;
Track movieTrack;
Media trackMedia;
if(filename.empty()) {
goto unsupported;
} else {
err = ::FSPathMakeRef((const UInt8*)filename.c_str(), &ref, NULL);
err = ::FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL);
if (err) {
//error("filmDarwin: Unable to find file: %s", filename.c_str());
goto unsupported;
}
}
err = ::OpenMovieFile(&theFSSpec, &refnum, fsRdPerm);
if (err) {
//error("filmDarwin: Couldn't open the movie file: %#s (%d)", theFSSpec.name, err);
if (refnum) ::CloseMovieFile(refnum);
goto unsupported;
}
::NewMovieFromFile(&m_movie, refnum, NULL, NULL, newMovieActive, NULL);
if (refnum) ::CloseMovieFile(refnum);
// m_curFrame = -1;
if(m_curFrame==-1)m_curFrame=-2;
m_lastFrame=-1;
m_numTracks = (int)GetMovieTrackCount(m_movie);
verbose(1, "filmDarwin: m_numTracks = %d",(int)m_numTracks);
// Get the length of the movie
long movieDur, movieScale;
movieDur = (long)GetMovieDuration(m_movie);
movieScale = (long)GetMovieTimeScale(m_movie);
verbose(1, "Movie duration = %d timescale = %d timebase = %d",movieDur, movieScale, (long)GetMovieTimeBase(m_movie));
movieTrack = GetMovieIndTrackType(m_movie,
1,
VideoMediaType,
movieTrackMediaType); //get first video track
trackMedia = GetTrackMedia(movieTrack);
m_numFrames= GetMediaSampleCount(trackMedia);
if(m_numFrames>0) {
m_durationf = static_cast<double>(movieDur)/static_cast<double>(m_numFrames);
m_fps=static_cast<double>(m_numFrames)*static_cast<double>(movieScale)/static_cast<double>(movieDur);
} else {
m_numFrames=-1;
m_fps=30.f;
m_durationf=static_cast<double>(movieScale)/m_fps;
}
verbose(1, "numFrames= %d...%f", (int)m_numFrames, (float)m_durationf);
// Get the bounds for the movie
::GetMovieBox(m_movie, &m_srcRect);
OffsetRect(&m_srcRect, -m_srcRect.left, -m_srcRect.top);
SetMovieBox(m_movie, &m_srcRect);
m_image.image.xsize = m_srcRect.right - m_srcRect.left;
m_image.image.ysize = m_srcRect.bottom - m_srcRect.top;
verbose(1, "rect rt:%d lt:%d", m_srcRect.right, m_srcRect.left);
verbose(1, "rect top:%d bottom:%d", m_srcRect.top, m_srcRect.bottom);
verbose(1, "movie size x:%d y:%d", m_image.image.xsize, m_image.image.ysize);
switch(m_wantedFormat) {
case 0: // if no other format is requested, use YUV
case GL_YCBCR_422_APPLE:
m_image.image.format = m_wantedFormat;
hints |= hintsHighQuality | hintsDeinterlaceFields;
pixelformat=k422YpCbCr8CodecType;
break;
default:
m_image.image.format = GL_BGRA_EXT;
hints |= hintsHighQuality;
pixelformat=k32ARGBPixelFormat;
break;
}
m_image.image.setCsizeByFormat();
m_image.image.data = new unsigned char [m_image.image.xsize*m_image.image.ysize*m_image.image.csize];
m_rowBytes = m_image.image.xsize * m_image.image.csize;
SetMoviePlayHints(m_movie, hints, hints);
err = QTNewGWorldFromPtr( &m_srcGWorld,
pixelformat,
&m_srcRect,
NULL,
NULL,
0,
m_image.image.data,
m_rowBytes);
if (err) {
//error("filmDarwin: Couldn't make QTNewGWorldFromPtr %d", err);
goto unsupported;
}
m_movieTime = 0;
// *** set the graphics world for displaying the movie ***
::SetMovieGWorld(m_movie, m_srcGWorld, GetGWorldDevice(m_srcGWorld));
::MoviesTask(m_movie, 0); // *** this does the actual drawing into the GWorld ***
return true;
unsupported:
return false;
}
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
pixBlock* filmDarwin :: getFrame(void){
CGrafPtr savedPort;
GDHandle savedDevice;
Rect m_srcRect;
PixMapHandle m_pixMap;
::GetGWorld(&savedPort, &savedDevice);
::SetGWorld(m_srcGWorld, NULL);
::GetMovieBox(m_movie, &m_srcRect);
m_pixMap = ::GetGWorldPixMap(m_srcGWorld);
// get the next frame of the source movie
short flags = nextTimeStep;
OSType whichMediaType = VisualMediaCharacteristic;
TimeValue duration;
/* check whether we reached the end of the clip */
if (IsMovieDone(m_movie)) {
GoToBeginningOfMovie(m_movie);
return NULL;
}
if(m_numFrames<0) {
/* the opened media doesn't support seeking
* so we return the next frame, if a new frame was requested
* and the last frame if no new frame was requested
*/
m_movieTime = GetMovieTime(m_movie, NULL);
if(m_curFrame<0 && m_lastFrame<0) {
m_curFrame=0;
}
/* if we have a valid curFrame (>=0) and curFrame progresses (curFrame!=lastFrame), get the next image
* always get the image, if lastFrame<0
*/
if(m_curFrame!=m_lastFrame) {
m_image.newimage=1;
SetMovieRate(m_movie,X2Fix(1.0));
} else {
m_image.newimage=0;
SetMovieRate(m_movie,X2Fix(0.0));
}
MoviesTask(m_movie, 0); // *** this does the actual drawing into the GWorld ***
m_lastFrame=m_curFrame;
return &m_image;
}
//check for last frame to loop the clip
if (m_curFrame >= m_numFrames){
return NULL;
m_curFrame = 0;
m_movieTime = 0;
}
m_movieTime = static_cast<long>(static_cast<double>(m_curFrame) * m_durationf);
m_movieTime-=9; //total hack!! subtract an arbitrary amount and have nextinterestingtime find the exact place
//check for -1
if (m_movieTime < 0) m_movieTime = 0;
// if this is the first frame, include the frame we are currently on
if (m_curFrame == 0) flags |= nextTimeEdgeOK;
// if (m_auto) {
if (1) {
::GetMovieNextInterestingTime(m_movie,
flags,
1,
&whichMediaType,
m_movieTime,
0,
&m_movieTime,
// NULL);
&duration);
flags = 0;
flags = nextTimeStep;
// m_curFrame++;
}
// set the time for the frame and give time to the movie toolbox
SetMovieTimeValue(m_movie, m_movieTime);
MoviesTask(m_movie, 0); // *** this does the actual drawing into the GWorld ***
m_image.newimage=(m_lastFrame != m_curFrame);
m_lastFrame=m_curFrame;
return &m_image;
}
film::errCode filmDarwin :: changeImage(int imgNum, int trackNum){
m_curFrame=imgNum;
// return 0;
return film::SUCCESS;
}
///////////////////////////////
// Properties
bool filmDarwin::enumProperties(gem::Properties&readable,
gem::Properties&writeable) {
readable.clear();
writeable.clear();
gem::any value;
value=0.;
readable.set("frames", value);
readable.set("tracks", value);
readable.set("width", value);
readable.set("height", value);
readable.set("fps", value);
writeable.set("auto", value);
return false;
}
void filmDarwin::setProperties(gem::Properties&props) {
double d;
if(props.get("auto", d)) {
m_auto=(d>=0.5);
}
}
void filmDarwin::getProperties(gem::Properties&props) {
std::vector<std::string> keys=props.keys();
gem::any value;
double d;
unsigned int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
props.erase(key);
if("frames"==key) {
d=m_numFrames;
value=d; props.set(key, value);
}
if("tracks"==key) {
d=m_numTracks;
value=d; props.set(key, value);
}
if("width"==key) {
d=m_image.image.xsize;
value=d; props.set(key, value);
}
if("height"==key) {
d=m_image.image.ysize;
value=d; props.set(key, value);
}
if("fps"==key) {
d=m_fps;
value=d; props.set(key, value);
}
}
}
#endif /* CARBONQUICKTIME */

View file

@ -0,0 +1,101 @@
/* -----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load a digital video (like AVI, Mpeg, Quicktime) into a pix block
(OS independant parent-class)
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) Günther Geiger. geiger@epy.co.at
Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__FILMDARWIN_FILMDARWIN_H_
#define _INCLUDE_GEMPLUGIN__FILMDARWIN_FILMDARWIN_H_
#if defined __APPLE__ && !defined __x86_64__
// with OSX10.6, apple has removed loads of Carbon functionality (in 64bit mode)
// LATER make this a real check in configure
# define HAVE_CARBONQUICKTIME
#endif
#ifdef HAVE_CARBONQUICKTIME
#include "plugins/film.h"
#include "Gem/Image.h"
# include <Carbon/Carbon.h>
# include <QuickTime/QuickTime.h>
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
filmDarwin
film-loader class for MacOS-X (Darwin)
KEYWORDS
pix film movie
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT filmDarwin : public film {
public:
//////////
// Constructor
filmDarwin(void);
//////////
// Destructor
virtual ~filmDarwin(void);
//////////
// open a movie up
virtual bool open(const std::string filename, const gem::Properties&);
//////////
// close the movie file
virtual void close(void);
//////////
// get the next frame
virtual pixBlock* getFrame(void);
//////////
// set the next frame to read;
virtual errCode changeImage(int imgNum, int trackNum=-1);
// cannot be used within a threaded context
virtual bool isThreadable(void) { return false; }
// Property handling
virtual bool enumProperties(gem::Properties&readable,gem::Properties&writeable);
virtual void setProperties(gem::Properties&props);
virtual void getProperties(gem::Properties&props);
protected:
GLenum m_wantedFormat; // format requested by the user
bool m_auto; // automatic progression
int m_numFrames, m_numTracks; // number of frames in video
int m_curFrame, m_lastFrame;
pixBlock m_image; // output image
Movie m_movie;
GWorldPtr m_srcGWorld;
TimeValue m_movieTime;
Track m_movieTrack;
Media m_movieMedia;
TimeValue m_timeScale;
double m_durationf;
double m_fps;
};};};
#endif //HAVE_CARBONQUICKTIME
#endif // for header file

View file

@ -0,0 +1,35 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
pkglib_LTLIBRARIES=
if HAVE_LIB_GMERLIN_AVDEC
pkglib_LTLIBRARIES+= gem_filmGMERLIN.la
endif
gem_filmGMERLIN_la_CXXFLAGS =
gem_filmGMERLIN_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_filmGMERLIN_la_LDFLAGS += -no-undefined
endif
gem_filmGMERLIN_la_LIBADD =
# RTE
gem_filmGMERLIN_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_filmGMERLIN_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_filmGMERLIN_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_filmGMERLIN_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_filmGMERLIN_la @MOREFLAGS@
# Dependencies
gem_filmGMERLIN_la_CXXFLAGS += @GEM_LIB_GMERLIN_AVDEC_CFLAGS@
gem_filmGMERLIN_la_LIBADD += @GEM_LIB_GMERLIN_AVDEC_LIBS@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_filmGMERLIN_la_SOURCES= filmGMERLIN.cpp filmGMERLIN.h

View file

@ -0,0 +1,436 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_LIBGMERLIN_AVDEC
# define HAVE_GMERLIN
#endif
#ifdef HAVE_GMERLIN
#include "filmGMERLIN.h"
#include "plugins/PluginFactory.h"
#include "Gem/RTE.h"
#include "Gem/Properties.h"
//#define GEM_FILMGMERLIN_TRACKSWITCH 1
using namespace gem::plugins;
REGISTER_FILMFACTORY("gmerlin", filmGMERLIN);
/////////////////////////////////////////////////////////
//
// filmGMERLIN
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
filmGMERLIN :: filmGMERLIN(void) :
m_numFrames(-1), m_numTracks(-1),
m_file(NULL),
m_opt(NULL),
m_track(0), m_stream(0),
m_gframe(NULL),
m_finalframe(NULL),
m_gconverter(NULL),
m_fps(0.), m_fps_num(1), m_fps_denum(1),
m_next_timestamp(0),
#ifdef USE_FRAMETABLE
m_frametable(NULL),
#endif
m_doConvert(false)
{
m_gconverter=gavl_video_converter_create ();
}
////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
filmGMERLIN :: ~filmGMERLIN(void)
{
close();
if(m_gconverter)gavl_video_converter_destroy(m_gconverter);m_gconverter=NULL;
}
void filmGMERLIN :: close(void)
{
if(m_file)bgav_close(m_file);m_file=NULL;
#ifdef USE_FRAMETABLE
if(m_frametable)gavl_frame_table_destroy(m_frametable); m_frametable=NULL;
#endif
/* LATER: free frame buffers */
}
/////////////////////////////////////////////////////////
// logging
//
/////////////////////////////////////////////////////////
void filmGMERLIN::log(bgav_log_level_t level, const char *log_domain, const char *message)
{
switch(level) {
case BGAV_LOG_DEBUG:
verbose(2, "[pix_film:%s] %s", log_domain, message);
break;
case BGAV_LOG_INFO:
verbose(1, "[pix_film:%s] %s", log_domain, message);
break;
case BGAV_LOG_WARNING:
post("[pix_film:%s] %s", log_domain, message);
break;
case BGAV_LOG_ERROR:
error("[pix_film:%s!] %s", log_domain, message);
break;
default:break;
}
}
void filmGMERLIN::log_callback (void *data, bgav_log_level_t level, const char *log_domain, const char *message)
{
((filmGMERLIN*)(data))->log(level, log_domain, message);
}
bool filmGMERLIN :: isThreadable(void) {
if(m_numFrames<0)
return false;
return true;
}
/////////////////////////////////////////////////////////
// really open the file !
//
/////////////////////////////////////////////////////////
bool filmGMERLIN :: open(const std::string sfilename, const gem::Properties&wantProps)
{
close();
m_track=0;
m_file = bgav_create();
if(!m_file) return false;
m_opt = bgav_get_options(m_file);
if(!m_opt) return false;
/*
bgav_options_set_connect_timeout(m_opt, connect_timeout);
bgav_options_set_read_timeout(m_opt, read_timeout);
bgav_options_set_network_bandwidth(m_opt, network_bandwidth);
*/
bgav_options_set_seek_subtitles(m_opt, 0);
bgav_options_set_sample_accurate(m_opt, 1);
bgav_options_set_log_callback(m_opt,
log_callback,
this);
const char*filename=sfilename.c_str();
if(!strncmp(filename, "vcd://", 6))
{
if(!bgav_open_vcd(m_file, filename + 5))
{
//error("Could not open VCD Device %s", filename + 5);
return false;
}
}
else if(!strncmp(filename, "dvd://", 6))
{
if(!bgav_open_dvd(m_file, filename + 5))
{
//error("Could not open DVD Device %s", filename + 5);
return false;
}
}
else if(!strncmp(filename, "dvb://", 6))
{
if(!bgav_open_dvb(m_file, filename + 6))
{
//error("Could not open DVB Device %s", filename + 6);
return false;
}
}
else {
if(!bgav_open(m_file, filename)) {
//error("Could not open file %s", filename);
close();
return false;
}
}
if(bgav_is_redirector(m_file))
{
int i=0;
int num_urls=bgav_redirector_get_num_urls(m_file);
post("Found redirector:");
for(i = 0; i < num_urls; i++)
{
post("#%d: '%s' -> %s", i, bgav_redirector_get_name(m_file, i), bgav_redirector_get_url(m_file, i));
}
for(i = 0; i < num_urls; i++) {
filename=(char*)bgav_redirector_get_url(m_file, i);
close();
if (open(filename, wantProps)) {
return true;
}
}
/* couldn't open a redirected stream */
return false;
}
/*
* ok, we have been able to open the "file"
* now get some information from it...
*/
m_numTracks = bgav_num_tracks(m_file);
// LATER: check whether this track has a video-stream...
int numvstreams=bgav_num_video_streams (m_file, m_track);
if(numvstreams) {
bgav_select_track(m_file, m_track);
} else {
post("track %d does not contain a video-stream: skipping");
}
bgav_set_video_stream(m_file, m_stream, BGAV_STREAM_DECODE);
if(!bgav_start(m_file)) {
close();
return false;
}
m_next_timestamp=bgav_video_start_time(m_file, m_track);
gavl_video_format_t*gformat = (gavl_video_format_t*)bgav_get_video_format (m_file, m_stream);
m_gframe = gavl_video_frame_create_nopad(gformat);
gavl_video_format_t finalformat[1];
finalformat->frame_width = gformat->frame_width;
finalformat->frame_height = gformat->frame_height;
finalformat->image_width = gformat->image_width;
finalformat->image_height = gformat->image_height;
finalformat->pixel_width = gformat->pixel_width;
finalformat->pixel_height = gformat->pixel_height;
finalformat->frame_duration = gformat->frame_duration;
finalformat->timescale = gformat->timescale;
#ifdef __APPLE__
/* GAVL_UYVY definitely works on PowerPC
* m.e.grimm also reported that he had to use UYVY,
* i assume he is on x86_64;
* so make it the default for now
*/
finalformat->pixelformat=GAVL_UYVY;
/* don't know what this is exactly: */
//finalformat->pixelformat=GAVL_YUY2;
#else
finalformat->pixelformat=GAVL_RGBA_32;
#endif
m_finalframe = gavl_video_frame_create_nopad(finalformat);
m_doConvert= (gavl_video_converter_init (m_gconverter, gformat, finalformat)>0);
m_image.image.xsize=gformat->frame_width;
m_image.image.ysize=gformat->frame_height;
#ifdef __APPLE__
m_image.image.setCsizeByFormat(GL_YUV422_GEM);
#else
m_image.image.setCsizeByFormat(GL_RGBA);
#endif
m_image.image.notowned=true;
m_image.image.upsidedown=true;
m_image.newfilm=true;
if(gformat->frame_duration) {
m_fps = gformat->timescale / gformat->frame_duration;
} else {
m_fps = gformat->timescale;
}
m_fps_num=gformat->timescale;
m_fps_denum=gformat->frame_duration;
m_numFrames=-1;
#ifdef USE_FRAMETABLE
m_frametable=bgav_get_frame_table(m_file, m_track);
if(m_frametable)
m_numFrames=gavl_frame_table_num_frames (m_frametable);
#endif
gavl_time_t dur=bgav_get_duration (m_file, m_track);
if(m_numFrames<0)
if(dur!=GAVL_TIME_UNDEFINED)
m_numFrames = gavl_time_to_frames(m_fps_num,
m_fps_denum,
dur);
return true;
}
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
pixBlock* filmGMERLIN :: getFrame(void){
if(!m_file)return NULL;
bgav_read_video(m_file, m_gframe, m_stream);
if(m_doConvert) {
gavl_video_convert (m_gconverter, m_gframe, m_finalframe);
m_image.image.data=m_finalframe->planes[0];
} else {
m_image.image.data=m_gframe->planes[0];
}
m_image.newimage=true;
m_image.image.upsidedown=true;
m_next_timestamp=m_gframe->timestamp+m_gframe->duration;
return &m_image;
}
/////////////////////////////////////////////////////////
// changeFrame
//
/////////////////////////////////////////////////////////
film::errCode filmGMERLIN :: changeImage(int imgNum, int trackNum){
if(trackNum<0) {
/* just automatically proceed to the next frame: this might speed up things for linear decoding */
return film::SUCCESS;
}
if(!m_file)return film::FAILURE;
#if GEM_FILMGMERLIN_TRACKSWITCH
// LATER implement track-switching
// this really shares a lot of code with open() so it should go into a separate function
if(trackNum) {
if(m_numTracks>trackNum || trackNum<0) {
post("selected invalid track %d of %d", trackNum, m_numTracks);
} else {
int numvstreams=bgav_num_video_streams (m_file, m_track);
post("track %d contains %d video streams", m_track, numvstreams);
if(numvstreams) {
bgav_select_track(m_file, m_track);
#ifdef USE_FRAMETABLE
if(m_frametable) {
gavl_frame_table_destroy(m_frametable);
m_frametable=bgav_get_frame_table(m_file, m_track);
}
#endif
} else {
post("track %d does not contain a video-stream: skipping");
}
}
}
#endif /* GEM_FILMGMERLIN_TRACKSWITCH */
if(imgNum>=m_numFrames || imgNum<0)return film::FAILURE;
if(bgav_can_seek(m_file)) {
if(0) {
#ifdef USE_FRAMETABLE
} else if(m_frametable) {
// no assumptions about fixed framerate
int64_t seekpos = gavl_frame_table_frame_to_time(m_frametable, imgNum, NULL);
bgav_seek_video(m_file, m_track, seekpos);
return film::SUCCESS;
#endif
} else {
// assuming fixed framerate
/*
Plaum: "Relying on a constant framerate is not good."
m_fps_denum and m_fps_num are set only once!
*/
int64_t seekposOrg = imgNum*m_fps_denum;
int64_t seekpos = seekposOrg;
#if 0
// LATER: set a minimum frame offset
// keep in mind that m_fps_denum could be 1!
// so it's better to calculate the difference in milliseconds and compare
int64_t diff=m_next_timestamp-seekpos;
# define TIMESTAMP_OFFSET_MAX 5
if(diff<TIMESTAMP_OFFSET_MAX && diff>(TIMESTAMP_OFFSET_MAX * -1)) {
// hey we are already there...
return film::SUCCESS;
}
#endif
bgav_seek_scaled(m_file, &seekpos, m_fps_num);
if(seekposOrg == seekpos)
return film::SUCCESS;
/* never mind: always return success... */
return film::SUCCESS;
}
}
return film::FAILURE;
}
///////////////////////////////
// Properties
bool filmGMERLIN::enumProperties(gem::Properties&readable,
gem::Properties&writeable) {
readable.clear();
writeable.clear();
gem::any value;
value=0.;
readable.set("fps", value);
readable.set("frames", value);
readable.set("width", value);
readable.set("height", value);
return false;
}
void filmGMERLIN::setProperties(gem::Properties&props) {
}
void filmGMERLIN::getProperties(gem::Properties&props) {
std::vector<std::string> keys=props.keys();
gem::any value;
double d;
unsigned int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
props.erase(key);
if("fps"==key) {
d=m_fps;
value=d; props.set(key, value);
}
if("frames"==key && m_numFrames>=0) {
d=m_numFrames;
value=d; props.set(key, value);
}
if("tracks"==key && m_numTracks>=0) {
d=m_numTracks;
value=d; props.set(key, value);
}
if("width"==key) {
d=m_image.image.xsize;
value=d; props.set(key, value);
}
if("height"==key) {
d=m_image.image.ysize;
value=d; props.set(key, value);
}
}
}
#endif // GMERLIN

View file

@ -0,0 +1,117 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load a digital video (quicktime4linux) for linux
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) Günther Geiger. geiger@epy.co.at
Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__FILMGMERLIN_FILMGMERLIN_H_
#define _INCLUDE_GEMPLUGIN__FILMGMERLIN_FILMGMERLIN_H_
#include "plugins/film.h"
#include "Gem/Image.h"
#include <stdio.h>
# ifdef __cplusplus
extern "C" {
# endif
# include <gmerlin/avdec.h>
# include <gmerlin/bgav_version.h>
# if BGAV_BUILD >= BGAV_MAKE_BUILD(1,0,2)
# define USE_FRAMETABLE
# else
# undef USE_FRAMETABLE
# endif
# ifdef __cplusplus
}
# endif
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
filmGMERLIN
Loads in a film
KEYWORDS
pix
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT filmGMERLIN : public film {
public:
//////////
// Constructor
filmGMERLIN(void);
//////////
// Destructor
virtual ~filmGMERLIN(void);
//////////
// open a movie up
virtual bool open(const std::string filename, const gem::Properties&);
//////////
// close the movie file
virtual void close(void);
//////////
// get the next frame
virtual pixBlock* getFrame(void);
//////////
// set the next frame to read;
virtual errCode changeImage(int imgNum, int trackNum = -1);
virtual bool isThreadable(void);
// Property handling
virtual bool enumProperties(gem::Properties&readable,gem::Properties&writeable);
virtual void setProperties(gem::Properties&props);
virtual void getProperties(gem::Properties&props);
//-----------------------------------
// GROUP: Movie data
//-----------------------------------
protected:
pixBlock m_image; // output image
int m_numFrames, m_numTracks; // number of frames in video
bgav_t* m_file;
bgav_options_t * m_opt;
int m_track, m_stream;
gavl_video_frame_t*m_gframe,*m_finalframe;
gavl_video_converter_t*m_gconverter;
double m_fps; // the frame-rate
int m_fps_num, m_fps_denum;
int64_t m_next_timestamp;
#ifdef USE_FRAMETABLE
gavl_frame_table_t *m_frametable;
#endif
// whether we need to convert the image before using it in Gem
bool m_doConvert;
virtual void log(bgav_log_level_t level, const char *log_domain, const char *message);
private:
static void log_callback(void *data, bgav_log_level_t level, const char *log_domain, const char *message);
};};};
#endif // for header file

View file

@ -0,0 +1,35 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
pkglib_LTLIBRARIES=
if HAVE_LIB_MPEG
pkglib_LTLIBRARIES+= gem_filmMPEG1.la
endif
gem_filmMPEG1_la_CXXFLAGS =
gem_filmMPEG1_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_filmMPEG1_la_LDFLAGS += -no-undefined
endif
gem_filmMPEG1_la_LIBADD =
# RTE
gem_filmMPEG1_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_filmMPEG1_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_filmMPEG1_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_filmMPEG1_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_filmMPEG1_la @MOREFLAGS@
# Dependencies
gem_filmMPEG1_la_CXXFLAGS += @GEM_LIB_MPEG_CFLAGS@
gem_filmMPEG1_la_LIBADD += @GEM_LIB_MPEG_LIBS@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_filmMPEG1_la_SOURCES = filmMPEG1.cpp filmMPEG1.h

View file

@ -0,0 +1,217 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "filmMPEG1.h"
#include "plugins/PluginFactory.h"
#include "Gem/Properties.h"
using namespace gem::plugins;
#ifdef HAVE_LIBMPEG
REGISTER_FILMFACTORY("MPEG1", filmMPEG1);
/////////////////////////////////////////////////////////
//
// filmMPEG1
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
filmMPEG1 :: filmMPEG1(void) :
m_wantedFormat(GL_RGBA),
m_fps(-1.0),
m_curFrame(-1),
m_newfilm(false),
m_streamfile(NULL),
m_reachedEnd(false),
m_data(NULL),
m_length(0)
{}
/////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
filmMPEG1 :: ~filmMPEG1()
{
close();
if(m_data)delete[]m_data;
}
void filmMPEG1 :: close(void)
{
if (m_streamfile)fclose(m_streamfile);
m_streamfile=0;
}
/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
bool filmMPEG1 :: open(const std::string filename, int format)
{
if (format>0)m_wantedFormat=format;
if (!(m_streamfile = fopen (filename.c_str(), "rb")))return false;
int wantedFormat= (m_wantedFormat)?m_wantedFormat:GL_RGBA;
switch (wantedFormat){
case GL_LUMINANCE:
SetMPEGOption (MPEG_DITHER, GRAY_DITHER);
break;
default:
wantedFormat=GL_RGBA;
case GL_YCBCR_422_GEM:
case GL_RGBA:
SetMPEGOption (MPEG_DITHER, FULL_COLOR_DITHER);
}
if (OpenMPEG (m_streamfile, &m_streamVid)) { /* let's hope it's MPEG */
m_curFrame = 0;
// Unfortunately there is no way to get the length of an MPEG-Stream
m_fps = (double)m_streamVid.PictureRate; // ??
m_image.image.xsize = m_streamVid.Width;
m_image.image.ysize = m_streamVid.Height;
if (!(m_image.image.xsize*m_image.image.ysize))goto unsupported;
m_image.image.setCsizeByFormat(wantedFormat);
m_image.image.reallocate();
int length=m_image.image.xsize*m_image.image.ysize;
length*=((m_image.image.format==GL_LUMINANCE)?1:4)+4;
if(m_length<length){
if (m_data)delete[]m_data;
m_length=length;
m_data=new unsigned char[m_length];
}
m_reachedEnd=false;
m_newfilm = true;
return true;
}
goto unsupported;
unsupported:
close();
return false;
}
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
pixBlock* filmMPEG1 :: getFrame(){
if (m_reachedEnd){
m_curFrame=-1;
return 0;
}
if (!m_readNext){
return &m_image;
}
m_image.image.upsidedown=true;
m_readNext = false;
int length=m_image.image.xsize*m_image.image.ysize;
length*=((m_image.image.format==GL_LUMINANCE)?1:4)+4;
if(m_length<length){
if (m_data)delete[]m_data;
m_length=length;
m_data=new unsigned char[m_length];
}
if (m_reachedEnd=!GetMPEGFrame ((char*)(m_data))){
if(m_image.image.format==GL_YCBCR_422_GEM){
m_image.image.fromRGBA(m_data);
} else m_image.image.data=m_data;
m_curFrame=-1;
return &m_image;// was 0; but then we have one non-textured frame in auto-mode
} else {
if(m_image.image.format==GL_YCBCR_422_GEM){
m_image.image.fromRGBA(m_data);
} else m_image.image.data=m_data;
if(m_newfilm)m_image.newfilm=1; m_newfilm=false;
m_image.newimage=1;
return &m_image;
}
return 0;
}
film::errCode filmMPEG1 :: changeImage(int imgNum, int trackNum){
if (m_reachedEnd&&imgNum>0)return film::FAILURE;
m_readNext = true;
if (imgNum==0){
if (!RewindMPEG(m_streamfile, &m_streamVid))return film::FAILURE;
m_curFrame=0;
m_reachedEnd=false;
}
return film::DONTKNOW;
}
///////////////////////////////
// Properties
bool filmMPEG1::enumProperties(gem::Properties&readable,
gem::Properties&writeable) {
readable.clear();
writeable.clear();
gem::any value;
value=0.;
readable.set("fps", value);
readable.set("width", value);
readable.set("height", value);
writeable.set("colorspace", value);
return false;
}
void filmMPEG1::setProperties(gem::Properties&props) {
double d;
if(props.get("colorspace", d)) {
m_wantedFormat=(GLenum)d;
}
}
void filmMPEG1::getProperties(gem::Properties&props) {
std::vector<std::string> keys=props.keys();
gem::any value;
double d;
unsigned int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
props.erase(key);
if("fps"==key) {
d=m_fps;
value=d; props.set(key, value);
}
if("width"==key) {
d=m_image.image.xsize;
value=d; props.set(key, value);
}
if("height"==key) {
d=m_image.image.ysize;
value=d; props.set(key, value);
}
}
}
#endif

View file

@ -0,0 +1,89 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load an digital video (like AVI, Mpeg, Quicktime) into a pix block (Linux)
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) Günther Geiger. geiger@epy.co.at
Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__FILMMPEG1_FILMMPEG1_H_
#define _INCLUDE_GEMPLUGIN__FILMMPEG1_FILMMPEG1_H_
#include "plugins/film.h"
#include "Gem/Image.h"
#include <stdio.h>
#include <mpeg.h>
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
filmMPEG1
Loads in a film
KEYWORDS
pix
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT filmMPEG1 : public film {
public:
//////////
// Constructor
filmMPEG1(void);
//////////
// Destructor
virtual ~filmMPEG1(void);
//////////
// open a movie up
virtual bool open(const std::string filename, const gem::Properties&);
//////////
// close the movie file
virtual void close(void);
//////////
// get the next frame
virtual pixBlock* getFrame(void);
//////////
// set the next frame to read;
virtual errCode changeImage(int imgNum, int trackNum = -1);
// can be used within a threaded context
virtual bool isThreadable(void) { return true; }
// Property handling
virtual bool enumProperties(gem::Properties&readable,gem::Properties&writeable);
virtual void setProperties(gem::Properties&props);
virtual void getProperties(gem::Properties&props);
//-----------------------------------
// GROUP: Movie data
//-----------------------------------
protected:
GLenum m_wantedFormat; // format requested by the user
double m_fps; // the frame-rate
int m_curFrame;
pixBlock m_image; // output image
bool m_newfilm;
FILE *m_streamfile;
ImageDesc m_streamVid;
bool m_reachedEnd;
unsigned char*m_data;
int m_length;
};};};
#endif // for header file

View file

@ -0,0 +1,35 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
pkglib_LTLIBRARIES=
if HAVE_LIB_LIBMPEG3
pkglib_LTLIBRARIES+= gem_filmMPEG3.la
endif
gem_filmMPEG3_la_CXXFLAGS =
gem_filmMPEG3_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_filmMPEG3_la_LDFLAGS += -no-undefined
endif
gem_filmMPEG3_la_LIBADD =
# RTE
gem_filmMPEG3_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_filmMPEG3_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_filmMPEG3_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_filmMPEG3_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_filmMPEG3_la @MOREFLAGS@
# Dependencies
gem_filmMPEG3_la_CXXFLAGS += @GEM_LIB_LIBMPEG3_CFLAGS@
gem_filmMPEG3_la_LIBADD += @GEM_LIB_LIBMPEG3_LIBS@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_filmMPEG3_la_SOURCES= filmMPEG3.cpp filmMPEG3.h

View file

@ -0,0 +1,253 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_LIBMPEG3
#include "filmMPEG3.h"
#include "plugins/PluginFactory.h"
#include "Gem/Properties.h"
#include "Gem/RTE.h"
using namespace gem::plugins;
REGISTER_FILMFACTORY("MPEG3", filmMPEG3);
/* take care of API changes */
#ifdef MPEG3_MAJOR
# if MPEG3_MINOR > 6
# define FILMMPEG3_OPEN17
# endif
#endif /* MPEG3 version defines */
/////////////////////////////////////////////////////////
//
// filmMPEG3
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
filmMPEG3 :: filmMPEG3(void) :
m_wantedFormat(GL_RGBA),
m_fps(-1.0),
m_numFrames(-1), m_numTracks(-1),
m_readNext(false),
m_newfilm(false),
mpeg_file(NULL)
{ }
/////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
filmMPEG3 :: ~filmMPEG3(void)
{
close();
}
void filmMPEG3 :: close(void)
{
if(mpeg_file)mpeg3_close(mpeg_file);
mpeg_file=NULL;
}
/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
bool filmMPEG3 :: open(const std::string filename, const gem::Properties&wantProps)
{
char*cfilename=const_cast<char*>(filename.c_str());
if (mpeg3_check_sig(cfilename)){/* ok, this is mpeg(3) */
#ifdef FILMMPEG3_OPEN17
// new API with more sophisticated error-feedback
mpeg_file= mpeg3_open(cfilename, 0);
#else
// old API
mpeg_file= mpeg3_open(cfilename);
#endif
if(!mpeg_file) {
//error("filmMPEG3: this file %s does not seem to hold any video data", filename.c_str());
goto unsupported;
}
if (!mpeg3_has_video(mpeg_file)){
error("filmMPEG3: this file %s does not seem to hold any video data", filename.c_str());
goto unsupported;
}
m_numTracks = mpeg3_total_vstreams(mpeg_file);
if(m_curTrack>=m_numTracks || m_curTrack<0)
m_curTrack=0;
m_numFrames = mpeg3_video_frames(mpeg_file, m_curTrack);
m_fps = mpeg3_frame_rate(mpeg_file, m_curTrack);
m_image.image.xsize=mpeg3_video_width(mpeg_file, m_curTrack);
m_image.image.ysize=mpeg3_video_height(mpeg_file, m_curTrack);
if (!m_image.image.xsize*m_image.image.ysize)goto unsupported;
double d;
if(wantProps.get("colorspace", d)) {
m_image.image.setCsizeByFormat((int)d);
m_wantedFormat=m_image.image.format;
}
m_image.image.reallocate();
changeImage(0,-1);
m_newfilm=true;
return true;
}
goto unsupported;
unsupported:
close();
return false;
}
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
pixBlock* filmMPEG3 :: getFrame(void) {
if (!m_readNext){
return &m_image;
}
m_readNext = false;
int i;
int wantedFormat=m_wantedFormat;
char*u=NULL,*y=NULL,*v=NULL;
m_image.image.setCsizeByFormat(wantedFormat);
int datasize=m_image.image.xsize*m_image.image.ysize*m_image.image.csize;
m_image.image.reallocate(datasize+4);
if(m_wantedFormat==GL_RGBA){
// the mpeg3-YUV2RGB decoder works better than ours
unsigned char **rows = new unsigned char* [m_image.image.ysize];
unsigned char **dummy=rows;
i=m_image.image.ysize;
while(i--)*dummy++=m_image.image.data+(i*m_image.image.xsize*m_image.image.csize);
if (mpeg3_read_frame(mpeg_file, rows,
0, 0,
m_image.image.xsize, m_image.image.ysize,
m_image.image.xsize, m_image.image.ysize,
MPEG3_RGBA8888,
0)) {
error("filmMPEG3:: could not read frame ! %d", m_curFrame);
return 0;
}
// unfortunately the ALPHA is set to 0!
i = m_image.image.xsize*m_image.image.ysize;
unsigned char*aptr=m_image.image.data;
while(i--){
aptr[chAlpha]=255;
aptr+=4;
}
m_image.image.upsidedown=false;
delete[]rows;
} else {
// unfortunately this is upside down.
if(mpeg3_read_yuvframe_ptr(mpeg_file,&y,&u,&v,0)){
error("filmMPEG3:: could not read yuv-frame ! %d", m_curFrame);
return 0;
}
m_image.image.fromYV12((unsigned char*)y, (unsigned char*)u, (unsigned char*)v);
m_image.image.upsidedown=true;
}
if(m_newfilm)m_image.newfilm=1; m_newfilm=false;
m_image.newimage=1;
return &m_image;
}
film::errCode filmMPEG3 :: changeImage(int imgNum, int trackNum){
m_readNext = true;
if (imgNum ==-1) imgNum=m_curFrame;
if (m_numFrames>1 && imgNum>=m_numFrames)return film::FAILURE;
if (trackNum==-1||trackNum>m_numTracks)trackNum=m_curTrack;
int test;
if ((test=mpeg3_set_frame(mpeg_file, imgNum, trackNum))) {
}
m_curFrame=imgNum;
m_curTrack=trackNum;
return film::SUCCESS;
m_readNext=false;
return film::FAILURE;
}
///////////////////////////////
// Properties
bool filmMPEG3::enumProperties(gem::Properties&readable,
gem::Properties&writeable) {
readable.clear();
writeable.clear();
gem::any value;
value=0.;
readable.set("fps", value);
readable.set("frames", value);
readable.set("tracks", value);
readable.set("width", value);
readable.set("height", value);
writeable.set("colorspace", value);
return false;
}
void filmMPEG3::setProperties(gem::Properties&props) {
double d;
if(props.get("colorspace", d)) {
m_wantedFormat=d;
}
}
void filmMPEG3::getProperties(gem::Properties&props) {
std::vector<std::string> keys=props.keys();
gem::any value;
double d;
unsigned int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
props.erase(key);
if("fps"==key) {
d=m_fps;
value=d; props.set(key, value);
}
if("frames"==key) {
d=m_numFrames;
value=d; props.set(key, value);
}
if("tracks"==key) {
d=m_numTracks;
value=d; props.set(key, value);
}
if("width"==key) {
d=m_image.image.xsize;
value=d; props.set(key, value);
}
if("height"==key) {
d=m_image.image.ysize;
value=d; props.set(key, value);
}
}
}
#endif

View file

@ -0,0 +1,90 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load an digital video (like AVI, Mpeg, Quicktime) into a pix block (Linux)
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) Günther Geiger. geiger@epy.co.at
Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__FILMMPEG3_FILMMPEG3_H_
#define _INCLUDE_GEMPLUGIN__FILMMPEG3_FILMMPEG3_H_
#include "plugins/film.h"
#include "Gem/Image.h"
#include <stdio.h>
#ifdef HAVE_LIBMPEG3
#include <libmpeg3.h>
#endif // MPEG3
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
filmMPEG3
Loads in a film
KEYWORDS
pix
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT filmMPEG3 : public film {
public:
//////////
// Constructor
filmMPEG3(void);
//////////
// Destructor
virtual ~filmMPEG3(void);
#ifdef HAVE_LIBMPEG3
//////////
// open a movie up
virtual bool open(const std::string filename, const gem::Properties&);
//////////
// close the movie file
virtual void close(void);
//////////
// get the next frame
virtual pixBlock* getFrame(void);
//////////
// set the next frame to read;
virtual errCode changeImage(int imgNum, int trackNum = -1);
// cannot be used within a threaded context
virtual bool isThreadable(void) { return false; }
// Property handling
virtual bool enumProperties(gem::Properties&readable,gem::Properties&writeable);
virtual void setProperties(gem::Properties&props);
virtual void getProperties(gem::Properties&props);
//-----------------------------------
// GROUP: Movie data
//-----------------------------------
protected:
GLenum m_wantedFormat; // format requested by the user
double m_fps; // the frame-rate
int m_numFrames, m_numTracks; // number of frames in video
int m_curFrame, m_curTrack;
pixBlock m_image; // output image
bool m_readNext;
bool m_newfilm;
mpeg3_t *mpeg_file;
#endif
};};};
#endif // for header file

View file

@ -0,0 +1,39 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
EXTRA_DIST =
EXTRA_DIST += win-vs2003/filmQT.sln win-vs2003/filmQT.vcproj
EXTRA_DIST += win-vs2008/filmQT.sln win-vs2008/filmQT.vcproj
pkglib_LTLIBRARIES=
if HAVE_FRAMEWORK_QUICKTIME
pkglib_LTLIBRARIES+= gem_filmQT.la
endif
gem_filmQT_la_CXXFLAGS =
gem_filmQT_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_filmQT_la_LDFLAGS += -no-undefined
endif
gem_filmQT_la_LIBADD =
# RTE
gem_filmQT_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_filmQT_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_filmQT_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_filmQT_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_filmQT_la @MOREFLAGS@
# Dependencies
gem_filmQT_la_CXXFLAGS += @GEM_FRAMEWORK_QUICKTIME@
gem_filmQT_la_LIBADD += @GEM_FRAMEWORK_QUICKTIME@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_filmQT_la_SOURCES= filmQT.cpp filmQT.h

View file

@ -0,0 +1,419 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// tigital@mac.com
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) 2002 James Tittle & Chris Clepper
// Copyright (c) 2003-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if defined __APPLE__
# if !defined __x86_64__
// with OSX10.6, apple has removed loads of Carbon functionality (in 64bit mode)
// LATER make this a real check in configure
# define HAVE_CARBONQUICKTIME
# elif defined HAVE_QUICKTIME
# undef HAVE_QUICKTIME
# endif
#endif
#ifdef HAVE_QUICKTIME
#include "filmQT.h"
#include "plugins/PluginFactory.h"
#include "Gem/Properties.h"
#include "Gem/RTE.h"
#include "Gem/Exception.h"
using namespace gem::plugins;
REGISTER_FILMFACTORY("QuickTime", filmQT);
# ifdef __APPLE__
# define FILMQT_DEFAULT_PIXELFORMAT GL_YCBCR_422_APPLE
static bool filmQT_initQT(void) { return true; }
static bool filmQT_deinitQT(void) { return true; }
# else /* !__APPLE__ */
/* TextUtils.h is from QTdev */
# include "TextUtils.h"
# define OffsetRect MacOffsetRect
# define FILMQT_DEFAULT_PIXELFORMAT GL_RGBA
static bool filmQT_initQT(void) {
// Initialize QuickTime Media Layer
OSErr err = noErr;
if ((err = InitializeQTML(0))) {
error("filmQT: Could not initialize quicktime: error %d\n", err);
return false;
}
// Initialize QuickTime
if (err = EnterMovies()) {
error("filmQT: Could not initialize quicktime: error %d\n", err);
return false;
}
return true;
}
static bool filmQT_deinitQT(void) {
// Deinitialize QuickTime Media Layer
ExitMovies();
// Deinitialize QuickTime Media Layer
TerminateQTML();
return true;
}
# endif /* w32 */
/////////////////////////////////////////////////////////
//
// filmQT
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
filmQT :: filmQT(void) :
m_wantedFormat(FILMQT_DEFAULT_PIXELFORMAT),
m_fps(-1.),
m_numFrames(-1), m_numTracks(-1),
m_curFrame(-1), m_curTrack(-1),
m_readNext(false),
m_auto(0.f),
m_movie(NULL),
m_srcGWorld(NULL),
m_movieTime(0),
m_movieTrack(0),
m_timeScale(1),
m_frameDuration(0),
m_bInit(false)
{
if(!filmQT_initQT()) {
throw(GemException("unable to initialize QuickTime"));
}
m_image.image.setCsizeByFormat(m_wantedFormat);
m_bInit = true;
}
/////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
filmQT :: ~filmQT(void)
{
close();
/* should we check whether "m_bInit" is true? */
filmQT_deinitQT();
}
void filmQT :: close(void)
{
if (!m_bInit){
return;
}
DisposeMovie(m_movie);
//in QT Bizzaro World GWorlds dispose themselves! And leak about 4k per call
// ::DisposeGWorld(m_srcGWorld);
// m_srcGWorld = NULL;
}
bool filmQT :: open(const std::string filename, const gem::Properties&wantProps) {
FSSpec theFSSpec;
OSErr err = noErr;
Rect m_srcRect;
long m_rowBytes;
short refnum = 0;
long movieDur, movieTimeScale;
OSType whichMediaType;
short flags = 0;
double d;
OSType pixelformat=0;
long hints=0;
if (filename.empty())return false;
if (!m_bInit){
error("filmQT: object not correctly initialized\n");
return false;
}
// Clean up any open files: closeMess();
Str255 pstrFilename;
CopyCStringToPascal(filename.c_str(), pstrFilename); // Convert to Pascal string
err = FSMakeFSSpec (0, 0L, pstrFilename, &theFSSpec); // Make specification record
#ifdef __APPLE__
if (err != noErr) {
FSRef ref;
err = ::FSPathMakeRef((const UInt8*)filename.c_str(), &ref, NULL);
err = ::FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL);
}
#endif
if (err != noErr) {
error("filmQT: Unable to find file: %s (%d)", filename.c_str(), err);
//goto unsupported;
}
err = ::OpenMovieFile(&theFSSpec, &refnum, fsRdPerm);
if (err) {
error("filmQT: Couldn't open the movie file: %s (%d)", filename.c_str(), err);
if (refnum) ::CloseMovieFile(refnum);
goto unsupported;
}
err = ::NewMovieFromFile(&m_movie, refnum, NULL, NULL, newMovieActive, NULL);
if (err) {
error("filmQT: Couldn't make a movie from file: %s (%d)", filename.c_str(), err);
if (refnum) ::CloseMovieFile(refnum);
m_movie=NULL;
goto unsupported;
}
if (refnum) ::CloseMovieFile(refnum);
m_curFrame = -1;
m_numTracks = static_cast<int>(GetMovieTrackCount(m_movie));
// Get the length of the movie
movieDur = static_cast<long>(GetMovieDuration(m_movie));
movieTimeScale = static_cast<long>(GetMovieTimeScale(m_movie));
whichMediaType = VisualMediaCharacteristic;
// shouldn't the flags be OR'ed instead of ADDed ? (jmz)
flags = nextTimeMediaSample | nextTimeEdgeOK;
m_frameDuration=0;
GetMovieNextInterestingTime( m_movie, flags,
static_cast<TimeValue>(1),
&whichMediaType, 0,
static_cast<Fixed>(1<<16), NULL, &m_frameDuration);
if(movieDur<=0)
m_numFrames=-1;
else
m_numFrames = movieDur/m_frameDuration;
if(m_frameDuration>=movieDur) {
m_fps=30.f;
//m_frameDuration=(float)movieTimeScale/m_fps;
m_frameDuration=0;
m_numFrames=-1;
} else {
m_fps = (float)movieTimeScale/(float)m_frameDuration;
}
// Get the bounds for the movie
::GetMovieBox(m_movie, &m_srcRect);
// OffsetRect(&m_srcRect, -m_srcRect.left, -m_srcRect.top);
SetMovieBox(m_movie, &m_srcRect);
m_image.image.xsize = m_srcRect.right - m_srcRect.left;
m_image.image.ysize = m_srcRect.bottom - m_srcRect.top;
switch(m_wantedFormat) {
default: // if no other format is requested, use YUV
case GL_YCBCR_422_APPLE:
post("YUV");
m_image.image.format = m_wantedFormat;
hints |= hintsHighQuality | hintsDeinterlaceFields;
pixelformat=k422YpCbCr8CodecType;
break;
case GL_BGRA_EXT:
post("BGRA");
m_image.image.format = GL_BGRA_EXT;
hints |= hintsHighQuality;
pixelformat=k32ARGBPixelFormat;
break;
case GL_RGBA:
post("RGBA");
m_image.image.format = GL_RGBA;
hints |= hintsHighQuality;
pixelformat=k32RGBAPixelFormat;
break;
}
m_image.image.setCsizeByFormat();
m_image.image.allocate();
m_rowBytes = m_image.image.xsize * m_image.image.csize;
SetMoviePlayHints(m_movie, hints, hints);
err = SetMovieAudioMute(m_movie, true, 0);
if(noErr!=err) {
error("filmQT: unable to mute movie...");
}
err = QTNewGWorldFromPtr( &m_srcGWorld,
pixelformat,
&m_srcRect,
NULL,
NULL,
0,
m_image.image.data,
m_rowBytes);
if (err) {
error("filmQT: Couldn't make QTNewGWorldFromPtr %d", err);
goto unsupported;
}
// *** set the graphics world for displaying the movie ***
::SetMovieGWorld(m_movie, m_srcGWorld, GetGWorldDevice(m_srcGWorld));
if(GetMoviesError()){
close();
goto unsupported;
}
if(m_frameDuration)
SetMovieRate(m_movie,X2Fix(m_auto));
else if (m_auto == 0.f)
SetMovieRate(m_movie,X2Fix(1.f));
::MoviesTask(m_movie, 0); // *** this does the actual drawing into the GWorld ***
m_readNext=true;
return true;
unsupported:
return false;
}
/////////////////////////////////////////////////////////
// getFrame
//
/////////////////////////////////////////////////////////
pixBlock* filmQT :: getFrame(void)
{
CGrafPtr savedPort;
GDHandle savedDevice;
Rect m_srcRect;
::GetGWorld(&savedPort, &savedDevice);
::SetGWorld(m_srcGWorld, NULL);
::GetMovieBox(m_movie, &m_srcRect);
// set the time for the frame and give time to the movie toolbox
if(m_frameDuration>0)
SetMovieTimeValue(m_movie, m_movieTime);
MoviesTask(m_movie, 0); // *** this does the actual drawing into the GWorld ***
m_image.newimage = m_readNext;
m_image.image.upsidedown=true;
SetMovieRate(m_movie,X2Fix(m_auto));
m_readNext=(m_auto!=0.f);
return &m_image;
}
film::errCode filmQT :: changeImage(int imgNum, int trackNum){
m_readNext = false;
if (imgNum ==-1) imgNum=m_curFrame;
if (m_numFrames>1 && imgNum>=m_numFrames){
m_movieTime=0;
return film::FAILURE;
}
if (trackNum==-1||trackNum>m_numTracks)trackNum=m_curTrack;
m_readNext=true;
if(imgNum!=m_curFrame && m_frameDuration<1)
SetMovieRate(m_movie,X2Fix(1.0));
m_curFrame = imgNum;
/* i have moved the "auto"-thing into [pix_film].
* this is good because the decoder-class need not care about auto-play anylonger
* this is bad, because we might do it more sophisticated in the decoder-class
*/
m_movieTime = static_cast<long>(m_curFrame * m_frameDuration);
return film::SUCCESS;
}
///////////////////////////////
// Properties
bool filmQT::enumProperties(gem::Properties&readable,
gem::Properties&writeable) {
readable.clear();
writeable.clear();
gem::any value;
value=0.;
readable.set("fps", value);
readable.set("frames", value);
readable.set("tracks", value);
readable.set("width", value);
readable.set("height", value);
return false;
}
void filmQT::setProperties(gem::Properties&props) {
}
void filmQT::getProperties(gem::Properties&props) {
std::vector<std::string> keys=props.keys();
gem::any value;
double d;
unsigned int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
props.erase(key);
if("fps"==key) {
d=m_fps;
value=d; props.set(key, value);
}
if("frames"==key && m_numFrames>=0) {
d=m_numFrames;
value=d; props.set(key, value);
}
if("tracks"==key && m_numTracks>=0) {
d=m_numTracks;
value=d; props.set(key, value);
}
if("width"==key) {
d=m_image.image.xsize;
value=d; props.set(key, value);
}
if("height"==key) {
d=m_image.image.ysize;
value=d; props.set(key, value);
}
}
}
#ifdef LOADRAM
//////////
// load film into RAM
void filmQT :: LoadRam(void){
TimeValue length;
OSErr err;
if (m_haveMovie){
m_movieTime = 0;
length = GetMovieDuration(m_movie);
err =LoadMovieIntoRam(m_movie,m_movieTime,length,keepInRam);
if (err) {
post("filmQT: LoadMovieIntoRam failed miserably");
}
}else{
post("filmQT: no movie to load into RAM!");
}
}
#endif // LoadRAM
#endif // HAVE_QT

View file

@ -0,0 +1,98 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load an digital video (like AVI, Mpeg, Quicktime) into a pix block (Windus/Apple)
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) 2002 James Tittle. tigital@mac.com
Copyright (c) 2011 IOhannes m zmölnig. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__FILMQT_FILMQT_H_
#define _INCLUDE_GEMPLUGIN__FILMQT_FILMQT_H_
#include "plugins/film.h"
#include "Gem/Image.h"
#ifdef HAVE_CARBONQUICKTIME
# include <Carbon/Carbon.h>
# include <QuickTime/QuickTime.h>
#else defined _WIN32
# include <QTML.h>
# include <Movies.h>
#endif
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
filmQT
Loads in a film
KEYWORDS
pix
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT filmQT : public film
{
public:
//////////
// Constructor
filmQT(void);
//////////
// Destructor
virtual ~filmQT(void);
//////////
// open a movie up
virtual bool open(const std::string filename, const gem::Properties&);
//////////
// close the movie file
virtual void close(void);
//////////
// get the next frame
virtual pixBlock* getFrame(void);
//////////
// set the next frame to read;
virtual errCode changeImage(int imgNum, int trackNum = -1);
// cannot be used within a threaded context
virtual bool isThreadable(void) { return false; }
// Property handling
virtual bool enumProperties(gem::Properties&readable,gem::Properties&writeable);
virtual void setProperties(gem::Properties&props);
virtual void getProperties(gem::Properties&props);
protected:
GLenum m_wantedFormat; // the requested pixel format (in GL)
double m_fps; // the frame-rate
int m_numFrames, m_numTracks; // number of frames in video
int m_curFrame, m_curTrack;
pixBlock m_image; // output image
bool m_readNext;
float m_auto;
//-----------------------------------
// GROUP: Movie data
//-----------------------------------
Movie m_movie;
GWorldPtr m_srcGWorld;
TimeValue m_movieTime;
Track m_movieTrack;
TimeValue m_timeScale;
TimeValue m_frameDuration;
// managed to initialize our Quicktime-Decoder
bool m_bInit;
};};};
#endif // for header file

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filmQT", "filmQT.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="filmQT"
ProjectGUID="{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
RootNamespace="gem"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;;&quot;$(ProgramFiles)\QuickTime SDK\CIncludes&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN;HAVE_QUICKTIME"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib QTMLClient.lib pd.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;;&quot;$(ProgramFiles)\QuickTime SDK\Libraries&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib pd.lib vfw32.lib OLDNAMES.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\filmQT.cpp">
</File>
<File
RelativePath="..\filmQT.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filmQT", "filmQT.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,171 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="filmQT"
ProjectGUID="{92E57A6D-B582-46F0-B02D-E0F29A594143}"
RootNamespace="gem"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\QuickTime.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\filmQT.cpp"
>
</File>
<File
RelativePath="..\filmQT.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,39 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
pkglib_LTLIBRARIES=
if HAVE_LIB_LIBQUICKTIME
pkglib_LTLIBRARIES+= gem_filmQT4L.la
endif
if HAVE_LIB_LQT
pkglib_LTLIBRARIES+= gem_filmQT4L.la
endif
gem_filmQT4L_la_CXXFLAGS =
gem_filmQT4L_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_filmQT4L_la_LDFLAGS += -no-undefined
endif
gem_filmQT4L_la_LIBADD =
# RTE
gem_filmQT4L_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_filmQT4L_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_filmQT4L_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_filmQT4L_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_filmQT4L_la @MOREFLAGS@
# Dependencies
gem_filmQT4L_la_CXXFLAGS += @GEM_LIB_LIBQUICKTIME_CFLAGS@ @GEM_LIB_LQT_CFLAGS@
gem_filmQT4L_la_LIBADD += @GEM_LIB_LIBQUICKTIME_LIBS@ @GEM_LIB_LQT_LIBS@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_filmQT4L_la_SOURCES= filmQT4L.cpp filmQT4L.h

View file

@ -0,0 +1,246 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_LIBQUICKTIME
#include "filmQT4L.h"
#include "plugins/PluginFactory.h"
#include "Gem/Properties.h"
#include "Gem/RTE.h"
using namespace gem::plugins;
#include <colormodels.h>
REGISTER_FILMFACTORY("quicktime4linux", filmQT4L);
/////////////////////////////////////////////////////////
//
// filmQT4L
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
filmQT4L :: filmQT4L(void) :
m_wantedFormat(GL_RGBA),
m_fps(-1.0),
m_numFrames(-1), m_numTracks(-1),
m_curFrame(-1), m_curTrack(0),
m_newfilm(false),
m_quickfile(NULL),
m_qtformat(0),
m_lastFrame(0)
{
}
/////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
filmQT4L :: ~filmQT4L()
{
close();
}
void filmQT4L :: close(void)
{
if(m_quickfile)quicktime_close(m_quickfile);
m_quickfile=0;
}
/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
bool filmQT4L :: open(const std::string filename, const gem::Properties&wantProps)
{
int wantedFormat=GL_RGBA;
double d;
unsigned int format=0;
if(wantProps.get("format", d)) {
format=d;
}
switch(format){
default:
break;
case GL_RGBA:
case GL_YCBCR_422_GEM:
case GL_LUMINANCE:
m_wantedFormat=format;
break;
}
char*cfilename=const_cast<char*>(filename.c_str());
if (quicktime_check_sig(cfilename)){ /* ok, this is quicktime */
if (!(m_quickfile = quicktime_open(filename.c_str(), 1, 0))){
// post("filmQT4L: Unable to open file: %s", filename.c_str());
return false;
}
m_curFrame = -1;
// Get the number of tracks
m_numTracks = quicktime_video_tracks(m_quickfile);
// Get the length of the movie (on track current track)
m_numFrames = quicktime_video_length(m_quickfile, m_curTrack) - 1;
// Get the frame-rate
m_fps = quicktime_frame_rate(m_quickfile, m_curTrack);
// Get the video dimensions
m_image.image.xsize = quicktime_video_width (m_quickfile, m_curTrack);
m_image.image.ysize = quicktime_video_height(m_quickfile, m_curTrack);
if (!quicktime_supported_video(m_quickfile, m_curTrack)){
// char *codec = quicktime_video_compressor(m_quickfile, m_curTrack);
// post("filmQT4L: unsupported CODEC '%s'!", codec);
quicktime_close(m_quickfile);
m_quickfile=0;
return false;
}
m_image.image.setCsizeByFormat(wantedFormat);
m_image.image.reallocate();
m_qtimage.xsize=m_image.image.xsize;
m_qtimage.ysize=m_image.image.ysize;
#ifdef __APPLE__
m_qtimage.setCsizeByFormat(GL_BGR);
#else
m_qtimage.setCsizeByFormat(GL_RGB);
#endif
m_qtimage.reallocate();
m_newfilm = true;
return true;
}
goto unsupported;
unsupported:
close();
return false;
}
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
pixBlock* filmQT4L :: getFrame(){
int i=m_image.image.ysize;
if (m_lastFrame==m_curFrame &&
m_image.image.format==m_wantedFormat)
{
m_image.newimage=0;
return &m_image;
}
m_image.image.setCsizeByFormat(m_wantedFormat);
m_image.image.reallocate();
pixBlock* pimage = 0;
unsigned char **rows = new unsigned char*[m_image.image.ysize];
while(i--)rows[i]=m_qtimage.data+m_qtimage.xsize*m_qtimage.csize*(m_qtimage.ysize-i-1);
m_lastFrame=m_curFrame;
if (quicktime_decode_video(m_quickfile, rows, m_curTrack)) {
post("filmQT4L:: couldn't decode video !");
}else {
m_image.image.convertFrom(&m_qtimage);
m_image.newimage=1; m_image.image.upsidedown=false;
pimage = &m_image;
if(m_newfilm)m_image.newfilm=1;
m_newfilm=false;
}
delete[] rows;
return pimage;
}
film::errCode filmQT4L :: changeImage(int imgNum, int trackNum){
if(imgNum>m_numFrames || imgNum<0)return film::FAILURE;
if (imgNum>0)m_curFrame=imgNum;
if(trackNum>0)m_curTrack=trackNum;
int i=-1;
#ifdef HAVE_QUICKTIME_SEEK_VIDEO
lqt_seek_video (m_quickfile, m_curTrack, m_curFrame, m_curTrack);
#else
if ((i=quicktime_set_video_position(m_quickfile, m_curFrame, m_curTrack))){ }
#endif
return film::SUCCESS;
}
///////////////////////////////
// Properties
bool filmQT4L::enumProperties(gem::Properties&readable,
gem::Properties&writeable) {
readable.clear();
writeable.clear();
gem::any value;
value=0.;
readable.set("fps", value);
readable.set("frames", value);
readable.set("tracks", value);
readable.set("width", value);
readable.set("height", value);
writeable.set("colorspace", value);
return false;
}
void filmQT4L::setProperties(gem::Properties&props) {
double d;
if(props.get("colorspace", d)) {
m_wantedFormat=d;
}
}
void filmQT4L::getProperties(gem::Properties&props) {
std::vector<std::string> keys=props.keys();
gem::any value;
double d;
unsigned int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
props.erase(key);
if("fps"==key) {
d=m_fps;
value=d; props.set(key, value);
}
if("frames"==key) {
d=m_numFrames;
value=d; props.set(key, value);
}
if("tracks"==key) {
d=m_numTracks;
value=d; props.set(key, value);
}
if("width"==key) {
d=m_image.image.xsize;
value=d; props.set(key, value);
}
if("height"==key) {
d=m_image.image.ysize;
value=d; props.set(key, value);
}
}
}
#endif // QT4L

View file

@ -0,0 +1,92 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load a digital video (quicktime4linux) for linux
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) Günther Geiger. geiger@epy.co.at
Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__FILMQT4L_FILMQT4L_H_
#define _INCLUDE_GEMPLUGIN__FILMQT4L_FILMQT4L_H_
#include "plugins/film.h"
#include "Gem/Image.h"
#include <stdio.h>
#include <quicktime.h>
#include <colormodels.h>
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
filmQT4L1
Loads in a film
KEYWORDS
pix
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT filmQT4L : public film {
public:
//////////
// Constructor
filmQT4L(void);
//////////
// Destructor
virtual ~filmQT4L(void);
//////////
// open a movie up
virtual bool open(const std::string filename, const gem::Properties&);
//////////
// close the movie file
virtual void close(void);
//////////
// get the next frame
virtual pixBlock* getFrame(void);
//////////
// set the next frame to read;
virtual errCode changeImage(int imgNum, int trackNum = -1);
// can be used within a threaded context
virtual bool isThreadable(void) { return true; }
// Property handling
virtual bool enumProperties(gem::Properties&readable,gem::Properties&writeable);
virtual void setProperties(gem::Properties&props);
virtual void getProperties(gem::Properties&props);
//-----------------------------------
// GROUP: Movie data
//-----------------------------------
protected:
GLenum m_wantedFormat; // format requested by the user
double m_fps; // the frame-rate
int m_numFrames, m_numTracks; // number of frames in video
int m_curFrame, m_curTrack;
pixBlock m_image; // output image
bool m_newfilm;
quicktime_t *m_quickfile;
int m_qtformat;
imageStruct m_qtimage;
int m_lastFrame;
};};};
#endif // for header file

View file

@ -0,0 +1,32 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
pkglib_LTLIBRARIES= gem_filmTEST.la
gem_filmTEST_la_CXXFLAGS =
gem_filmTEST_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_filmTEST_la_LDFLAGS += -no-undefined
endif
gem_filmTEST_la_LIBADD =
# RTE
gem_filmTEST_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_filmTEST_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_filmTEST_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_filmTEST_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_filmTEST_la @MOREFLAGS@
# Dependencies
gem_filmTEST_la_CXXFLAGS +=
gem_filmTEST_la_LIBADD +=
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_filmTEST_la_SOURCES= filmTEST.cpp filmTEST.h

View file

@ -0,0 +1,121 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include "filmTEST.h"
#include "plugins/PluginFactory.h"
#include "Gem/RTE.h"
#include "Gem/Properties.h"
using namespace gem::plugins;
REGISTER_FILMFACTORY("test", filmTEST);
/////////////////////////////////////////////////////////
//
// filmTEST
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
filmTEST :: filmTEST(void)
{
m_image.image.setCsizeByFormat(GL_RGBA);
m_image.image.xsize=320;
m_image.image.ysize=240;
m_image.image.reallocate();
}
/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
bool filmTEST :: open(const std::string filename, const gem::Properties&wantProps)
{
m_numFrames=100;
m_fps=20;
changeImage(0,0);
return true;
}
void filmTEST::close(void) {}
bool filmTEST::isThreadable(void) {return true;}
void filmTEST::setProperties(gem::Properties&props) {
}
void filmTEST::getProperties(gem::Properties&props) {
std::vector<std::string> keys=props.keys();
unsigned int i=0;
for(i=0; i<keys.size(); i++) {
std::string key=keys[i];
props.erase(key);
#define SETPROP(k, v) } else if(k == key) { double d=(double)v; props.set(key, v)
if(""==key) {
SETPROP("fps", m_fps);
SETPROP("frames", m_numFrames);
SETPROP("width", m_image.image.xsize);
SETPROP("height", m_image.image.ysize);
}
}
}
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
pixBlock* filmTEST :: getFrame(){
return &m_image;
}
film::errCode filmTEST :: changeImage(int imgNum, int trackNum){
unsigned char*data=m_image.image.data;
unsigned int size=m_image.image.xsize*m_image.image.ysize*m_image.image.csize;
unsigned char value=(unsigned char)imgNum;
while(size-->0) {
*data++=value;
value++;
}
m_image.newimage=true;
return film::SUCCESS;
}
bool filmTEST::enumProperties(gem::Properties&readprops, gem::Properties&writeprops) {
readprops.clear();
writeprops.clear();
double d=0;
readprops.set("width", d);
readprops.set("height", d);
readprops.set("fps", d);
readprops.set("frames", d);
return true;
}

View file

@ -0,0 +1,69 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load an digital video (like AVI, Mpeg, Quicktime) into a pix block (Linux)
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) Günther Geiger. geiger@epy.co.at
Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__FILMTEST_FILMTEST_H_
#define _INCLUDE_GEMPLUGIN__FILMTEST_FILMTEST_H_
#include "plugins/film.h"
#include "Gem/Image.h"
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
filmTEST
Loads in a film
KEYWORDS
pix
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT filmTEST : public film {
public:
//////////
// Constructor
filmTEST(void);
//////////
// open a movie up
virtual bool open(const std::string filename, const gem::Properties&);
virtual void close(void);
//////////
// get the next frame
virtual pixBlock* getFrame(void);
//////////
// set the next frame to read;
virtual errCode changeImage(int imgNum, int trackNum = -1);
virtual bool enumProperties(gem::Properties&readprops, gem::Properties&writeprops);
virtual void getProperties(gem::Properties&props);
virtual void setProperties(gem::Properties&props);
virtual bool isThreadable(void);
//-----------------------------------
pixBlock m_image;
double m_fps;
unsigned int m_numFrames;
};};};
#endif // for header file

View file

@ -0,0 +1,40 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
EXTRA_DIST =
EXTRA_DIST += win-vs2003/imageJPEG.sln win-vs2003/imageJPEG.vcproj
EXTRA_DIST += win-vs2008/imageJPEG.sln win-vs2008/imageJPEG.vcproj
EXTRA_DIST += win-vs2008/JPEG.vsprops
pkglib_LTLIBRARIES=
if HAVE_LIB_JPEG
pkglib_LTLIBRARIES+= gem_imageJPEG.la
endif
gem_imageJPEG_la_CXXFLAGS =
gem_imageJPEG_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_imageJPEG_la_LDFLAGS += -no-undefined
endif
gem_imageJPEG_la_LIBADD =
# RTE
gem_imageJPEG_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_imageJPEG_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_imageJPEG_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_imageJPEG_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_imageJPEG_la @MOREFLAGS@
# Dependencies
gem_imageJPEG_la_CXXFLAGS += @GEM_LIB_JPEG_CFLAGS@
gem_imageJPEG_la_LIBADD += @GEM_LIB_JPEG_LIBS@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_imageJPEG_la_SOURCES= imageJPEG.cpp imageJPEG.h

View file

@ -0,0 +1,324 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_LIBJPEG
#include <string.h>
#include "imageJPEG.h"
#include "plugins/PluginFactory.h"
#include "Gem/RTE.h"
extern "C"
{
# ifdef _WIN32
# undef FAR
# endif
# undef EXTERN
#if (defined _WIN32) && (defined __MINGW32__)
# define HAVE_BOOLEAN
#endif
# include "jpeglib.h"
#include <setjmp.h>
}
using namespace gem::plugins;
REGISTER_IMAGELOADERFACTORY("jpeg", imageJPEG);
REGISTER_IMAGESAVERFACTORY("jpeg", imageJPEG);
/////////////////////////////////////////////////////////
//
// imageJPEG
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
/***************************************************************************
*
* We have to do some funky error handling to keep the jpeg library
* from exiting on us.
*
***************************************************************************/
/*****************************
*
* Here is the error handler
*
*****************************/
struct my_error_mgr
{
struct jpeg_error_mgr pub; // "public" fields
jmp_buf setjmp_buffer; // for return to caller
};
typedef struct my_error_mgr * my_error_ptr;
/*
* Here's the routine that will replace the standard error_exit method:
*/
METHODDEF(void) my_error_exit (j_common_ptr cinfo)
{
// cinfo->err really points to a my_error_mgr struct, so coerce pointer
my_error_ptr myerr = reinterpret_cast<my_error_ptr> (cinfo->err);
// Always display the message.
// We could postpone this until after returning, if we chose.
// (*cinfo->err->output_message) (cinfo);
// Return control to the setjmp point
longjmp(myerr->setjmp_buffer, 1);
}
imageJPEG :: imageJPEG(void)
{
//post("imageJPEG");
}
imageJPEG :: ~imageJPEG(void)
{
//post("~imageJPEG");
}
/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
bool imageJPEG :: load(std::string filename, imageStruct&result, gem::Properties&props)
{
// open up the file
FILE * infile;
::verbose(2, "reading '%s' with libJPEG", filename.c_str());
if ((infile = fopen(filename.c_str(), "rb")) == NULL) {
//verbose(2, "GemImageLoad(JPEG): Unable to open image file: %s", filename.c_str());
return(false);
}
// create the jpeg structures
jpeg_decompress_struct cinfo;
my_error_mgr jerr;
// We set up the normal JPEG error routines, then override error_exit
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = my_error_exit;
// Establish the setjmp return context for my_error_exit to use.
if ( setjmp(jerr.setjmp_buffer) ) {
// If we get here, the JPEG code has signaled an error.
// We need to clean up the JPEG object, close the input file, and return.
jpeg_destroy_decompress(&cinfo);
fclose(infile);
return(false);
}
// create the decompression structure
jpeg_create_decompress(&cinfo);
// associate the decompress struct with the file
jpeg_stdio_src(&cinfo, infile);
// read in the file info
jpeg_read_header(&cinfo, TRUE);
// do we have an RGB image?
if (cinfo.jpeg_color_space == JCS_RGB) {
result.setCsizeByFormat(GL_RGBA);
} else if (cinfo.jpeg_color_space == JCS_GRAYSCALE) {
// do we have a gray8 image?
result.setCsizeByFormat(GL_LUMINANCE);
} else {
// something else, so decompress as RGB
result.setCsizeByFormat(GL_RGBA);
cinfo.out_color_space = JCS_RGB;
}
// start the decompression
jpeg_start_decompress(&cinfo);
int xSize = cinfo.output_width;
int ySize = cinfo.output_height;
int cSize = result.csize;
result.upsidedown=true;
result.xsize = xSize;
result.ysize = ySize;
result.reallocate();
// cycle through the scan lines
unsigned char *srcLine = new unsigned char[xSize * cSize];
unsigned char *dstLine = result.data;
int yStride = xSize * cSize;
int lines = ySize;
int pixes = xSize;
// do RGBA/RGB data
if (cSize == 4) {
while (lines--) {
unsigned char *src = srcLine;
unsigned char *dst = dstLine;
jpeg_read_scanlines(&cinfo, &src, 1);
pixes = xSize;
while (pixes--) {
dst[chRed] = src[0];
dst[chGreen] = src[1];
dst[chBlue] = src[2];
dst[chAlpha] = 255;
dst += 4;
src += 3;
}
dstLine += yStride;
}
} else {
// do grayscale data
while (lines--) {
unsigned char *src = srcLine;
unsigned char *dst = dstLine;
jpeg_read_scanlines(&cinfo, &src, 1);
pixes = xSize;
while (pixes--) {
*dst++ = *src++;
}
dstLine += yStride;
}
}
// finish the decompression
jpeg_finish_decompress(&cinfo);
// cleanup
jpeg_destroy_decompress(&cinfo);
fclose(infile);
delete [] srcLine;
return true;
}
bool imageJPEG::save(const imageStruct&constimage, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
struct jpeg_compress_struct cinfo;
/* More stuff */
FILE * outfile=NULL; /* target file */
JSAMPROW row_pointer; /* pointer to JSAMPLE row[s] */
int row_stride; /* physical row width in image buffer */
// We set up the normal JPEG error routines, then override error_exit
my_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = my_error_exit;
// Establish the setjmp return context for my_error_exit to use.
if ( setjmp(jerr.setjmp_buffer) ) {
// If we get here, the JPEG code has signaled an error.
// We need to clean up the JPEG object, close the input file, and return.
jpeg_destroy_compress(&cinfo);
if(outfile)
fclose(outfile);
return(false);
}
double fquality=100;
props.get("quality", fquality);
int quality=fquality;
if(GL_YUV422_GEM==constimage.format) {
error("don't know how to write YUV-images with libJPEG");
return false;
}
/* Now we can initialize the JPEG compression object. */
jpeg_create_compress(&cinfo);
if ((outfile = fopen(filename.c_str(), "wb")) == NULL) {
error("can't open %s\n", filename.c_str());
return (false);
}
jpeg_stdio_dest(&cinfo, outfile);
imageStruct image;
constimage.convertTo(&image, GL_RGB);
// image.fixUpDown();
JSAMPLE *image_buffer = image.data;
cinfo.image_width = image.xsize; /* image width and height, in pixels */
cinfo.image_height = image.ysize;
cinfo.input_components = 3; /* # of color components per pixel */
cinfo.in_color_space = JCS_RGB; /* colorspace of input image */
jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */);
jpeg_start_compress(&cinfo, TRUE);
row_stride = image.xsize * image.csize; /* JSAMPLEs per row in image_buffer */
while (cinfo.next_scanline < cinfo.image_height) {
/* jpeg_write_scanlines expects an array of pointers to scanlines.
* Here the array is only one element long, but you could pass
* more than one scanline at a time if that's more convenient.
*/
int rowindex=cinfo.next_scanline;
if(!image.upsidedown)
rowindex=(cinfo.image_height-cinfo.next_scanline-1);
row_pointer = & image_buffer[rowindex * row_stride];
if(jpeg_write_scanlines(&cinfo, &row_pointer, 1) < 0){
error("GEM: could not write line %d to image %s", cinfo.next_scanline, filename.c_str());
jpeg_finish_compress(&cinfo);
fclose(outfile);
jpeg_destroy_compress(&cinfo);
return(false);
}
}
jpeg_finish_compress(&cinfo);
fclose(outfile);
jpeg_destroy_compress(&cinfo);
return true;
}
float imageJPEG::estimateSave(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
float result=0.;
if(mimetype == "image/jpeg")// || mimetype == "image/pjpeg")
result += 100.;
// LATER check some properties....
if(gem::Properties::UNSET != props.type("quality"))
result += 1.;
return result;
}
void imageJPEG::getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props) {
mimetypes.clear();
props.clear();
mimetypes.push_back("image/jpeg");
mimetypes.push_back("image/pjpeg");
gem::any value;
value=100.f;
props.set("quality", value);
}
#endif

View file

@ -0,0 +1,62 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load a picture (using libjpeg)
Copyright (c) 2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__IMAGEJPEG_IMAGEJPEG_H_
#define _INCLUDE_GEMPLUGIN__IMAGEJPEG_IMAGEJPEG_H_
#include "plugins/imageloader.h"
#include "plugins/imagesaver.h"
#include <stdio.h>
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
imageJPEG
Loads in a picture
KEYWORDS
pix
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT imageJPEG : public gem::plugins::imageloader, public gem::plugins::imagesaver {
public:
//////////
// Constructor
imageJPEG(void);
virtual ~imageJPEG(void);
//////////
// read an image
virtual bool load(std::string filename, imageStruct&result, gem::Properties&props);
//////////
// write an image
virtual bool save(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props);
//////////
// estimate, how well we could save this image
virtual float estimateSave(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props);
////////
// get writing capabilities of this backend (informative)
virtual void getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props);
////////
// can be used from threaded contexts
virtual bool isThreadable(void) {return true;}
};
};};
#endif // for header file

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imageJPEG", "imageJPEG.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="imageJPEG"
ProjectGUID="{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
RootNamespace="gem"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;;&quot;$(ProjectDir)\..\..\..\..\GemLibs\Jpeg&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN;HAVE_LIBJPEG"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib libjpeg.lib pd.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;;&quot;$(ProjectDir)\..\..\..\..\GemLibs\Jpeg&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="OLDNAMES.lib Gem.lib pd.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\imageJPEG.cpp">
</File>
<File
RelativePath="..\imageJPEG.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="JPEG"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="$(ProjectDir)\..\..\..\..\GemLibs\Jpeg"
PreprocessorDefinitions="HAVE_LIBJPEG"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libjpeg.lib"
AdditionalLibraryDirectories="$(ProjectDir)\..\..\..\..\GemLibs\Jpeg"
/>
</VisualStudioPropertySheet>

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imageJPEG", "imageJPEG.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,171 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="imageJPEG"
ProjectGUID="{94CA04E7-CCF9-4733-A1BD-F3283C21288A}"
RootNamespace="gem"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops;.\JPEG.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\imageJPEG.cpp"
>
</File>
<File
RelativePath="..\imageJPEG.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,181 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
/* this implements ImageMagick loading/saving using MagickCore */
#include "imageMAGICK.h"
#include "Gem/RTE.h"
#ifdef _MSC_VER
# if !defined(_W64)
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
# define _W64 __w64
# else
# define _W64
# endif
# endif
# ifdef _WIN64
typedef __int64 ssize_t;
# else
typedef _w64 int ssize_t;
# endif
#endif
#include <magick/MagickCore.h>
using namespace gem::plugins;
namespace {
static bool showException(ExceptionInfo*exception, const std::string&prefix=std::string()) {
if(!exception)return true;
if (exception->severity == UndefinedException)
return false;
bool iswarning=exception->severity < ErrorException;
std::string message=prefix;
message+="[";
message+= SetClientName(0);
message+="]";
if(!iswarning)
message+"!";
message+=": ";
if ( exception->reason != 0 ) {
message += std::string(exception->reason);
}
if ( exception->description != 0 )
message += " (" + std::string(exception->description) + ")";
if(iswarning) {
verbose(1, "%s", message.c_str());
} else {
verbose(1, "%s", message.c_str());
}
return (!iswarning);
}
}
/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
bool imageMAGICK :: load(std::string filename, imageStruct&result, gem::Properties&props)
{
bool success=false;
::verbose(2, "reading '%s' with ImageMagick", filename.c_str());
ExceptionInfo*exception=AcquireExceptionInfo();
ImageInfo*image_info=CloneImageInfo((ImageInfo *) NULL);
CopyMagickString(image_info->filename,filename.c_str(), MaxTextExtent);
Image*image=ReadImage(image_info,exception);
if(showException(exception, "magick reading problem"))
goto cleanup;
if (image == (Image *) NULL)
goto cleanup;
result.xsize=static_cast<GLint>(image->columns);
result.ysize=static_cast<GLint>(image->rows);
result.setCsizeByFormat(GL_RGBA);
result.reallocate();
result.upsidedown=true;
ExportImagePixels(image, 0, 0, result.xsize, result.ysize,
"RGBA",
CharPixel,
reinterpret_cast<void*>(result.data),
exception);
if(showException(exception, "magick decoding problem"))
goto cleanup;
success=true;
cleanup:
if(image_info)
image_info=DestroyImageInfo(image_info);
if(exception)
exception=DestroyExceptionInfo(exception);
return success;
}
bool imageMAGICK::save(const imageStruct&image, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
error("GEM::imageMAGICK::save (MagickCore) seems to be broken! we are trying to fix it");
imageStruct*img=const_cast<imageStruct*>(&image);
imageStruct*pImage=img;
bool result=false;
ImageInfo*image_info=CloneImageInfo((ImageInfo *) NULL);
Image*finalImage=NULL;
CopyMagickString(image_info->filename,filename.c_str(), MaxTextExtent);
std::string cs;
switch(img->format) {
case GL_LUMINANCE:
cs="K";
break;
case GL_RGBA:
cs="RGBA";
break;
default:
pImage=new imageStruct();
pImage->convertFrom(img, GL_RGB);
case GL_RGB:
cs="RGB";
break;
case GL_BGRA_EXT:
cs="BGRA";
break;
}
ExceptionInfo*exception=AcquireExceptionInfo();
Image *mimage = ConstituteImage(pImage->xsize,pImage->ysize,
cs.c_str(), CharPixel,
pImage->data,exception);
if(showException(exception, "magick conversion problem"))
goto cleanup;
finalImage=(pImage->upsidedown)?mimage:FlipImage( mimage, exception );
if(showException(exception, "magick flipping problem"))
goto cleanup;
finalImage->depth=8;
//options->depth = 8;
double quality;
if(props.get("quality", quality)) {
finalImage->quality=quality;
//options->quality = quality;
}
WriteImage(image_info,finalImage);
if(showException(&finalImage->exception, "magick writing problem"))
goto cleanup;
result=true;
cleanup:
if(finalImage!=mimage)
finalImage=DestroyImage(finalImage);
mimage=DestroyImage(mimage);
exception=DestroyExceptionInfo(exception);
image_info=DestroyImageInfo(image_info);
return result;
}

View file

@ -0,0 +1,122 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
/* this implements ImageMagick loading/saving using Magick++ */
#include "imageMAGICK.h"
#include "Gem/RTE.h"
#include <Magick++.h>
using namespace gem::plugins;
namespace MagickCore {};
using namespace MagickCore;
namespace MagickLib {};
using namespace MagickLib;
/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
bool imageMAGICK :: load(std::string filename, imageStruct&result, gem::Properties&props)
{
Magick::Image image;
try {
::verbose(2, "reading '%s' with ImageMagick", filename.c_str());
// Read a file into image object
try {
image.read( filename );
} catch (Magick::Warning e) {
verbose(1, "magick loading problem: %s", e.what());
}
result.xsize=static_cast<GLint>(image.columns());
result.ysize=static_cast<GLint>(image.rows());
result.setCsizeByFormat(GL_RGBA);
result.reallocate();
result.upsidedown=true;
try {
image.write(0,0,result.xsize,result.ysize,
"RGBA",
Magick::CharPixel,
reinterpret_cast<void*>(result.data));
} catch (Magick::Warning e) {
verbose(1, "magick decoding problem: %s", e.what());
}
}catch( Magick::Exception e ) {
verbose(1, "magick loading image failed with: %s", e.what());
return false;
}
return true;
}
bool imageMAGICK::save(const imageStruct&image, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
imageStruct*img=const_cast<imageStruct*>(&image);
imageStruct*pImage=img;
std::string cs;
switch(img->format) {
case GL_LUMINANCE:
cs="K";
break;
case GL_RGBA:
cs="RGBA";
break;
default:
pImage=new imageStruct();
pImage->convertFrom(img, GL_RGB);
case GL_RGB:
cs="RGB";
break;
case GL_BGRA_EXT:
cs="BGRA";
break;
}
try{
Magick::Image mimage(pImage->xsize, pImage->ysize, cs, Magick::CharPixel, pImage->data);
// since openGL is upside down
if(!pImage->upsidedown) {
mimage.flip();
}
// 8 bits per channel are enough!
// LATER make this dependent on the image->type
mimage.depth(8);
double quality;
if(props.get("quality", quality)) {
mimage.quality(quality);
}
try {
// finally convert and export
mimage.write(filename);
} catch (Magick::Warning e) {
verbose(1, "magick saving problem: %s", e.what());
}
} catch (Magick::Exception e){
error("%s", e.what());
if(pImage!=&image)delete pImage; pImage=NULL;
return false;
} catch (...) {
error("imageMAGICK:: uncaught exception!");
return false;
}
if(pImage!=&image)delete pImage; pImage=NULL;
return true;
}

View file

@ -0,0 +1,59 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
EXTRA_DIST =
EXTRA_DIST += win-vs2003/imageMAGICK.sln win-vs2003/imageMAGICK.vcproj
EXTRA_DIST += win-vs2008/imageMAGICK.sln win-vs2008/imageMAGICK.vcproj
EXTRA_DIST += win-vs2008/ImageMagick_Release.vsprops win-vs2008/ImageMagick.vsprops
pkglib_LTLIBRARIES=
if HAVE_LIB_IMAGEMAGICK__
pkglib_LTLIBRARIES+= gem_imageMAGICK.la
else
if HAVE_LIB_MAGICKCORE
pkglib_LTLIBRARIES+= gem_imageMAGICK.la
endif
endif
gem_imageMAGICK_la_CXXFLAGS =
gem_imageMAGICK_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_imageMAGICK_la_LDFLAGS += -no-undefined
endif
gem_imageMAGICK_la_LIBADD =
# RTE
gem_imageMAGICK_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_imageMAGICK_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_imageMAGICK_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_imageMAGICK_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_imageMAGICK_la @MOREFLAGS@
# Dependencies
if HAVE_LIB_IMAGEMAGICK__
gem_imageMAGICK_la_CXXFLAGS += @GEM_LIB_IMAGEMAGICK___CFLAGS@
gem_imageMAGICK_la_LIBADD += @GEM_LIB_IMAGEMAGICK___LIBS@
else
if HAVE_LIB_MAGICKCORE
gem_imageMAGICK_la_CXXFLAGS += @GEM_LIB_MAGICKCORE_CFLAGS@
gem_imageMAGICK_la_LIBADD += @GEM_LIB_MAGICKCORE_LIBS@
endif
endif
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_imageMAGICK_la_SOURCES = imageMAGICK.cpp imageMAGICK.h
if HAVE_LIB_IMAGEMAGICK__
gem_imageMAGICK_la_SOURCES+= MagickPlusPlus.cpp
else
if HAVE_LIB_MAGICKCORE
gem_imageMAGICK_la_SOURCES+= MagickCore.cpp
endif
endif

View file

@ -0,0 +1,142 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_LIBMAGICK
#include <string.h>
#include "imageMAGICK.h"
#include "plugins/PluginFactory.h"
#include "Gem/RTE.h"
#ifdef _MSC_VER
# if !defined(_W64)
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
# define _W64 __w64
# else
# define _W64
# endif
# endif
# ifdef _WIN64
typedef __int64 ssize_t;
# else
typedef _w64 int ssize_t;
# endif
#endif
#include <magick/MagickCore.h>
// hmm, the GetMimeList() function has changed!
// ImageMagick-6.6.2-0: **GetMimeList(const char *,unsigned long *,ExceptionInfo *),
// ImageMagick-6.6.2-1: **GetMimeList(const char *,size_t *,ExceptionInfo *),
// theoretically, "unsigned long" and "size_t" are pretty much the same
// but in practice the compiler will complain bitterly
// set let's do some magick...
#ifndef MagickLibInterface
# define MagickLibInterface 0
#endif
#ifndef MagickLibVersion
# define MagickLibVersion 0
#endif
// this won't catch ImageMagick>=6.6.2-0, but what can I do?
// ubuntu/natty ships with 6.6.2-6!
// another workaround: compile with "-fpermissive"
#if (MagickLibInterface > 3) || (MagickLibVersion >= 0x662)
# define mimelistlength_t size_t
#else
# define mimelistlength_t unsigned long
#endif
using namespace gem::plugins;
namespace MagickCore {};
using namespace MagickCore;
namespace MagickLib {};
using namespace MagickLib;
REGISTER_IMAGELOADERFACTORY("magick", imageMAGICK);
REGISTER_IMAGESAVERFACTORY("magick", imageMAGICK);
/////////////////////////////////////////////////////////
//
// imageMAGICK
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
imageMAGICK :: imageMAGICK(void)
{
if(!IsMagickInstantiated())
MagickCoreGenesis(NULL,MagickTrue);
//post("imageMAGICK");
char**mimelist;
mimelistlength_t length;
ExceptionInfo exception;
GetExceptionInfo(&exception);
mimelist=GetMimeList("image/*", &length, &exception);
unsigned int i;
for(i=0; i<length; i++) {
m_mimetypes.push_back(mimelist[i]);
}
}
imageMAGICK :: ~imageMAGICK(void)
{
//post("~imageMAGICK");
}
float imageMAGICK::estimateSave(const imageStruct&image, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
float result=0.5; // slightly preference for MAGICK
unsigned int i;
for(i=0; i<m_mimetypes.size(); i++) {
if(mimetype==m_mimetypes[i]) {
result+=100.;
break;
}
}
if(gem::Properties::UNSET != props.type("quality"))
result += 1.;
return result;
}
void imageMAGICK::getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props) {
mimetypes.clear();
props.clear();
mimetypes = m_mimetypes;
gem::any value;
value=100.f;
props.set("quality", value);
}
#endif

View file

@ -0,0 +1,67 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load a picture (using ImageMagick)
Copyright (c) 2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__IMAGEMAGICK_IMAGEMAGICK_H_
#define _INCLUDE_GEMPLUGIN__IMAGEMAGICK_IMAGEMAGICK_H_
#include "plugins/imageloader.h"
#include "plugins/imagesaver.h"
#include <stdio.h>
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
imageMAGICK
Loads in a picture
KEYWORDS
pix
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT imageMAGICK : public gem::plugins::imageloader, public gem::plugins::imagesaver {
public:
//////////
// Constructor
imageMAGICK(void);
virtual ~imageMAGICK(void);
//////////
// read an image
virtual bool load(std::string filename, imageStruct&result, gem::Properties&props);
//////////
// write an image
virtual bool save(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props);
//////////
// estimate, how well we could save this image
virtual float estimateSave(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props);
////////
// get writing capabilities of this backend (informative)
virtual void getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props);
////////
// can be used from threaded contexts
virtual bool isThreadable(void) {return true;}
private:
std::vector<std::string>m_mimetypes;
};
};};
#endif // for header file

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imageMAGICK", "imageMAGICK.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="imageMAGICK"
ProjectGUID="{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
RootNamespace="gem"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;;&quot;$(IMAGEMAGICK)&quot;;&quot;$(IMAGEMAGICK)\magick&quot;;&quot;$(IMAGEMAGICK)\Magick++\lib&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN;HAVE_LIBMAGICKPLUSPLUS"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib pd.lib CORE_RL_bzlib_.lib CORE_RL_coders_.lib CORE_RL_filters_.lib CORE_RL_jbig_.lib CORE_RL_jp2_.lib CORE_RL_jpeg_.lib CORE_RL_lcms_.lib CORE_RL_libxml_.lib CORE_RL_magick_.lib CORE_RL_Magick++_.lib CORE_RL_png_.lib CORE_RL_tiff_.lib CORE_RL_ttf_.lib CORE_RL_wand_.lib CORE_RL_xlib_.lib CORE_RL_zlib_.lib CORE_RL_wmf_.lib winmm.lib wsock32.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;;&quot;$(IMAGEMAGICK)\VisualMagick\lib\&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="OLDNAMES.lib Gem.lib pd.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\imageMAGICK.cpp">
</File>
<File
RelativePath="..\imageMAGICK.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="ImageMagick"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(IMAGEMAGICK)&quot;;&quot;$(IMAGEMAGICK)\magick&quot;;&quot;$(IMAGEMAGICK)\Magick++\lib&quot;"
PreprocessorDefinitions="HAVE_LIBMAGICKPLUSPLUS;HAVE_LIBMAGICK"
/>
<Tool
Name="VCLinkerTool"
AdditionalLibraryDirectories="$(IMAGEMAGICK)\VisualMagick\lib\"
/>
</VisualStudioPropertySheet>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="ImageMagick - Release"
InheritedPropertySheets=".\ImageMagick.vsprops"
>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="CORE_RL_magick_.lib CORE_RL_bzlib_.lib CORE_RL_coders_.lib CORE_RL_filters_.lib CORE_RL_jbig_.lib CORE_RL_jp2_.lib CORE_RL_jpeg_.lib CORE_RL_lcms_.lib CORE_RL_libxml_.lib CORE_RL_png_.lib CORE_RL_tiff_.lib CORE_RL_ttf_.lib CORE_RL_wand_.lib CORE_RL_xlib_.lib CORE_RL_zlib_.lib CORE_RL_wmf_.lib"
/>
</VisualStudioPropertySheet>

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imageMAGICK", "imageMAGICK.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="imageMAGICK"
ProjectGUID="{9E650453-D08D-416F-AE68-F8EDE6E92892}"
RootNamespace="gem"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops;.\ImageMagick_Release.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="winmm.lib wsock32.lib"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\imageMAGICK.cpp"
>
</File>
<File
RelativePath="..\imageMAGICK.h"
>
</File>
<File
RelativePath="..\MagickCore.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,39 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
EXTRA_DIST =
EXTRA_DIST += win-vs2003/imageQT.sln win-vs2003/imageQT.vcproj
EXTRA_DIST += win-vs2008/imageQT.sln win-vs2008/imageQT.vcproj
pkglib_LTLIBRARIES=
if HAVE_FRAMEWORK_QUICKTIME
pkglib_LTLIBRARIES+= gem_imageQT.la
endif
gem_imageQT_la_CXXFLAGS =
gem_imageQT_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_imageQT_la_LDFLAGS += -no-undefined
endif
gem_imageQT_la_LIBADD =
# RTE
gem_imageQT_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_imageQT_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_imageQT_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_imageQT_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_imageQT_la @MOREFLAGS@
# Dependencies
gem_imageQT_la_CXXFLAGS += @GEM_FRAMEWORK_QUICKTIME@
gem_imageQT_la_LIBADD += @GEM_FRAMEWORK_QUICKTIME@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_imageQT_la_SOURCES= imageQT.cpp imageQT.h

View file

@ -0,0 +1,551 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if defined __APPLE__
# if !defined __x86_64__
// with OSX10.6, apple has removed loads of Carbon functionality (in 64bit mode)
// LATER make this a real check in configure
# define HAVE_CARBONQUICKTIME
# elif defined HAVE_QUICKTIME
# undef HAVE_QUICKTIME
# endif
#endif
#ifdef HAVE_QUICKTIME
# ifdef HAVE_CARBONQUICKTIME
//
# elif defined _WIN32
//
# else
# undef HAVE_QUICKTIME
# endif
#endif
#ifdef HAVE_QUICKTIME
# include "Gem/RTE.h"
# include "imageQT.h"
#include "plugins/PluginFactory.h"
# ifdef HAVE_CARBONQUICKTIME
# include <Carbon/Carbon.h>
# include <QuickTime/QuickTime.h>
# include <QuickTime/ImageCompression.h>
# define IMAGEQT_RGBA_PIXELFORMAT k32ARGBPixelFormat
# elif defined _WIN32
# include <QTML.h>
# include <Movies.h>
# include <QuickTimeComponents.h>
# include "Gem/Exception.h"
# define OffsetRect MacOffsetRect
# define IMAGEQT_RGBA_PIXELFORMAT k32RGBAPixelFormat
# endif
#ifdef _MSC_VER /* This is only for Microsoft's compiler, not cygwin, e.g. */
# define snprintf _snprintf
# define vsnprintf _vsnprintf
#endif
#define QT_MAX_FILENAMELENGTH 256
#include <stdio.h>
# include <map>
//# include <string.h>
//# include <fcntl.h>
using namespace gem::plugins;
REGISTER_IMAGELOADERFACTORY("QT", imageQT);
REGISTER_IMAGESAVERFACTORY("QT", imageQT);
#if defined __APPLE__
static OSStatus
FSPathMakeFSSpec(
const UInt8 *path,
FSSpec *spec)
{
OSStatus result;
FSRef ref;
Boolean *isDirectory=NULL;
/* check parameters */
require_action(NULL != spec, BadParameter, result = paramErr);
/* convert the POSIX path to an FSRef */
result = FSPathMakeRef(path, &ref, isDirectory);
require_noerr(result, FSPathMakeRef);
/* and then convert the FSRef to an FSSpec */
result = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, spec, NULL);
require_noerr(result, FSGetCatalogInfo);
FSGetCatalogInfo:
FSPathMakeRef:
BadParameter:
return ( result );
}
#elif defined _WIN32
static OSStatus
FSPathMakeFSSpec(
const UInt8 *path,
FSSpec *spec)
{
char filename[QT_MAX_FILENAMELENGTH];
UInt8*filename8=reinterpret_cast<UInt8*>(filename);
FILE*fil=NULL;
snprintf(filename, QT_MAX_FILENAMELENGTH, "%s", path);
c2pstr(filename);
OSErr err=FSMakeFSSpec (0, 0L, filename8, spec);
if (err != noErr && err != -37){
error("GEM: recordQT: error %d in FSMakeFSSpec()", err);
} else {
err = noErr;
}
return err;
}
#endif
// MemAlloc
// Simple memory allocation wrapper
static void* MemAlloc(unsigned long memsize)
{
if(memsize <= 0)
return NULL;
else
return (malloc(memsize));
}
static unsigned char* CStringToPString(char *string)
{
unsigned char *newString = (unsigned char*)MemAlloc(strlen(string) + 1);
size_t i = 0;
for(i = 0; i < strlen(string); i++)
newString[i+1] = string[i];
newString[0] = i;
return newString;
}
static void InvertGLImage( unsigned char *imageData, unsigned char * outData, long imageSize, long rowBytes )
{
long i, j;
// This is not an optimized routine!
// FIXXME use a flip function in GemPixUtils for this
// Copy rows into tmp buffer one at a time, reversing their order
for (i = 0, j = imageSize - rowBytes; i < imageSize; i += rowBytes, j -= rowBytes) {
memcpy( &outData[j], &imageData[i], static_cast<size_t>(rowBytes) );
}
}
static std::map<std::string, OSType> s_mime2type;
static bool mime2type(const std::string&mimetype, OSType&filetype) {
static bool done=false;
if(!done) {
done=true;
//s_mime2type["image/"]=kQTFileTypeAIFF;
//s_mime2type["image/"]=kQTFileTypeAIFC;
//s_mime2type["image/"]=kQTFileTypeDVC;
//s_mime2type["image/"]=kQTFileTypeMIDI;
s_mime2type["image/pict"]=kQTFileTypePicture;//-
//s_mime2type["image/"]=kQTFileTypeMovie;
//s_mime2type["image/"]=kQTFileTypeText;
//s_mime2type["image/"]=kQTFileTypeWave;
//s_mime2type["image/"]=kQTFileTypeSystemSevenSound;
//s_mime2type["image/"]=kQTFileTypeMuLaw;
//s_mime2type["image/"]=kQTFileTypeAVI;
//s_mime2type["image/"]=kQTFileTypeSoundDesignerII;
//s_mime2type["image/"]=kQTFileTypeAudioCDTrack;
//s_mime2type["image/pict"]=kQTFileTypePICS;
s_mime2type["image/gif"]=kQTFileTypeGIF;//-
s_mime2type["image/png"]=kQTFileTypePNG;//-
s_mime2type["image/tiff"]=kQTFileTypeTIFF;//-
s_mime2type["image/psd"]=kQTFileTypePhotoShop;//-
s_mime2type["image/sgi"]=kQTFileTypeSGIImage;//-
s_mime2type["image/bmp"]=kQTFileTypeBMP;//-
s_mime2type["image/jpeg"]=kQTFileTypeJPEG;//-
// s_mime2type["image/"]=kQTFileTypeJFIF;
s_mime2type["image/mac"]=kQTFileTypeMacPaint;//-
s_mime2type["image/targa"]=kQTFileTypeTargaImage;//-
// s_mime2type["image/"]=kQTFileTypeQuickDrawGXPicture;
s_mime2type["image/x-quicktime"]=kQTFileTypeQuickTimeImage;//-
//s_mime2type["image/"]=kQTFileType3DMF;
//s_mime2type["image/"]=kQTFileTypeFLC;
//s_mime2type["image/"]=kQTFileTypeFlash;
//s_mime2type["image/"]=kQTFileTypeFlashPix;
//s_mime2type["image/"]=kQTFileTypeMP4;
//s_mime2type["image/"]=kQTFileTypePDF;
//s_mime2type["image/"]=kQTFileType3GPP;
//s_mime2type["image/"]=kQTFileTypeAMR;
//s_mime2type["image/"]=kQTFileTypeSDV;
//s_mime2type["image/"]=kQTFileType3GP2;
//s_mime2type["image/"]=kQTFileTypeAMC;
s_mime2type["image/jp2"]=kQTFileTypeJPEG2000;//-
}
std::map<std::string, OSType>::iterator it = s_mime2type.find(mimetype);
if(s_mime2type.end() != it) {
filetype=it->second;
return true;
}
return false;
}
/////////////////////////////////////////////////////////
//
// imageQT
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
imageQT :: imageQT(void)
{
static bool firsttime=true;
if(firsttime) {
#ifdef _WIN32
// Initialize QuickTime Media Layer
OSErr err = noErr;
if ((err = InitializeQTML(0))) {
throw(GemException("unable to initialize QuickTime"));
}
// start QuickTime
if (err = EnterMovies()) {
throw(GemException("unable to initialize QuickTime/Movies"));
}
verbose(1, "imageQT: QT init done");
#endif // WINDOWS
firsttime=false;
}
//post("imageQT");
}
imageQT :: ~imageQT(void)
{
//post("~imageQT");
}
/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
static bool QuickTimeImage2mem(GraphicsImportComponent inImporter, imageStruct&result)
{
Rect r;
if (::GraphicsImportGetNaturalBounds(inImporter, &r)) return NULL; //get an image size
::OffsetRect(&r, -r.left, -r.top);
if (::GraphicsImportSetBoundsRect(inImporter, &r)) return NULL;
ImageDescriptionHandle imageDescH = NULL;
if (::GraphicsImportGetImageDescription(inImporter, &imageDescH)) return NULL;
result.xsize = (*imageDescH)->width;
result.ysize = (*imageDescH)->height;
result.upsidedown = true;
OSType pixelformat = 0;
/* afaik, there is no 8bit grayscale format....
* and even if it was, k8GrayPixelFormat would not be a define...
*/
#ifdef k8GrayPixelFormat
/* from the docs on "depth": what depth is this data (1-32) or ( 33-40 grayscale ) */
if ((*imageDescH)->depth <= 32) {
result.setCsizeByFormat(GL_RGBA_GEM);
pixelformat = IMAGEQT_RGBA_PIXELFORMAT;
} else {
result.setCsizeByFormat(GL_LUMINANCE);
pixelformat = k8GrayPixelFormat;
}
#else
result.setCsizeByFormat(GL_RGBA_GEM);
pixelformat = IMAGEQT_RGBA_PIXELFORMAT;
#endif
::DisposeHandle(reinterpret_cast<Handle>(imageDescH));
imageDescH = NULL;
result.reallocate();
#ifdef __DEBUG__
post("QuickTimeImage2mem() : allocate %d bytes", result.xsize*result.ysize*result.csize);
#endif
if (result.data == NULL) {
error("Can't allocate memory for an image.");
return false;
}
GWorldPtr gw = NULL;
OSErr err = QTNewGWorldFromPtr(&gw,
/* taken from pix_filmDarwin */
pixelformat, // gives noErr
&r, NULL, NULL, 0,
// keepLocal,
//useDistantHdwrMem,
result.data,
static_cast<long>(result.xsize * result.csize));
if (err) {
error("Can't create QTNewWorld");
}
::GraphicsImportSetGWorld(inImporter, gw, NULL);
::GraphicsImportDraw(inImporter);
::DisposeGWorld(gw); //dispose the offscreen
gw = NULL;
return true;
}
bool imageQT :: load(std::string filename, imageStruct&result, gem::Properties&props)
{
OSErr err;
GraphicsImportComponent importer = NULL;
::verbose(2, "reading '%s' with QuickTime", filename.c_str());
std::string myfilename=filename;
// does the file even exist?
if (!filename.empty()) {
FSSpec spec;
err = ::FSPathMakeFSSpec( reinterpret_cast<const UInt8*>(myfilename.c_str()), &spec);
if (err) {
error("GemImageLoad: Unable to find file: %s", filename.c_str());
error("parID : %d", spec.parID);
return false;
}
err = ::GetGraphicsImporterForFile(&spec, &importer);
if (err) {
error("GemImageLoad: Unable to import image '%s'", filename.c_str());
return false;
}
}
bool ret = QuickTimeImage2mem(importer, result);
::CloseComponent(importer);
return ret;
}
static bool touch(std::string filename) {
#ifdef __APPLE__
int fd;
fd = open(filename.c_str(), O_CREAT | O_RDWR, 0600);
if (fd < 0)
return false;
write(fd, " ", 1);
close(fd);
return true;
#elif defined _WIN32
FILE*outfile=fopen(filename.c_str(), "");
if(NULL==outfile)
return false;
fclose(outfile);
return true;
#endif
return false;
}
bool imageQT::save(const imageStruct&constimage, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
OSErr err=noErr;
ComponentResult cErr = 0;
GWorldPtr img = NULL;
GraphicsExportComponent geComp = NULL;
Rect r;
FSSpec spec;
OSType osFileType=kQTFileTypeTIFF;
mime2type(mimetype, osFileType);
std::string myfilename=filename.c_str();
const UInt8*filename8=reinterpret_cast<const UInt8*>(myfilename.c_str());
#if defined __APPLE__
FSRef ref;
err = ::FSPathMakeRef(filename8, &ref, NULL );
if (err == fnfErr) {
// if the file does not yet exist, then let's create the file
touch(myfilename);
err = FSPathMakeRef(filename8, &ref, NULL);
}
if (err != noErr) {
verbose(1, "ERROR: %d in FSPathMakeRef()", err);
}
err = ::FSGetCatalogInfo(&ref, kFSCatInfoNodeFlags, NULL, NULL, &spec, NULL);
if (err != noErr) {
verbose(1, "ERROR: %d in FSGetCatalogInfo()", err);
}
err = FSMakeFSSpec(spec.vRefNum, spec.parID, filename8, &spec); //this always gives an error -37 ???
#elif defined _WIN32
touch(myfilename);
err = FSMakeFSSpec (0, 0L, filename8, &spec);
#endif
if (err != noErr && err != -37){
verbose(1, "GEM: imageQT: error %d in FSMakeFSSpec()", err);
}
err = OpenADefaultComponent(GraphicsExporterComponentType, osFileType, &geComp);
if (err != noErr) {
error("ERROR: %d in OpenADefaultComponent()", err);
return false; // FIXME:
}
r.top = 0;
r.left = 0;
r.bottom = constimage.ysize;
r.right = constimage.xsize;
imageStruct rgbaimg;
rgbaimg.convertFrom(&constimage, GL_RGBA_GEM);
unsigned char *data = NULL;
if(!rgbaimg.upsidedown) { // the image is openGL-oriented, not quicktime-oriented! flip it!
int rowBytes = rgbaimg.xsize * rgbaimg.csize;
int imageSize = rgbaimg.ysize * rowBytes;
data = new unsigned char[imageSize];
InvertGLImage(rgbaimg.data, data, imageSize, rowBytes);
}
err = QTNewGWorldFromPtr(&img,
IMAGEQT_RGBA_PIXELFORMAT, //k32RGBAPixelFormat,
&r, NULL, NULL, 0,
(data?data:rgbaimg.data),
static_cast<long>(rgbaimg.xsize * rgbaimg.csize));
// is this the right place to free the "data" buffer (if used)?
// i don't know, whether quicktime still needs the buffer...
if (err != noErr) {
error("ERROR: %d in QTNewGWorldFromPtr()", err);
if(data)delete[]data;
return false; // FIXME:
}
// Set the input GWorld for the exporter
cErr = GraphicsExportSetInputGWorld(geComp, img);
if (cErr != noErr) {
error("ERROR: %d in GraphicsExportSetInputGWorld()", cErr);
if(data)delete[]data;
return false; // FIXME:
}
// Set the output file to our FSSpec
cErr = GraphicsExportSetOutputFile(geComp, &spec);
if (cErr != noErr) {
error("ERROR: %i in GraphicsExportSetOutputFile()", cErr);
if(data)delete[]data;
return false; // FIXME:
}
// Set the compression quality (needed for JPEG, not necessarily for other formats)
/*
codecMinQuality
codecLowQuality
codecNormalQuality
codecHighQuality
codecMaxQuality
codecLosslessQuality
*/
CodecQ quality=codecHighQuality;
double d=0.;
if(props.get("quality", d)) {
// <0 = minqality
// >=100 = lossless
if(d<0.)d=0.;
else if(d>100.)d=100.;
CodecQ maxQ=codecLosslessQuality;
double maxQ_d=(double)maxQ;
double quality_d=maxQ_d * d / 100.; // 0..maxQ
quality=(CodecQ)quality_d;
}
cErr = GraphicsExportSetCompressionQuality(geComp, quality);
// Export it
cErr = GraphicsExportDoExport(geComp, NULL);
if (cErr != noErr) {
error("ERROR: %i in GraphicsExportDoExport()", cErr);
if(data)delete[]data;
return false; // FIXME:
}
// finally, close the component
if (geComp != NULL)
CloseComponent(geComp);
if(data)delete[]data;
return true;
}
float imageQT::estimateSave(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
float result=0.;
OSType filetype; // just a dummy
if(mime2type(mimetype, filetype))
result+=100.;
// LATER check some properties....
if(gem::Properties::UNSET != props.type("quality"))
result += 1.;
return result;
}
void imageQT::getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props) {
mimetypes.clear();
props.clear();
std::map<std::string, OSType>::iterator it;
for(it = s_mime2type.begin(); it!=s_mime2type.end(); ++it) {
mimetypes.push_back(it->first);
}
gem::any value;
value=100.f;
props.set("quality", value);
}
#endif /* have_quicktime */

View file

@ -0,0 +1,63 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load a picture (using QuickTime)
Copyright (c) 2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__IMAGEQT_IMAGEQT_H_
#define _INCLUDE_GEMPLUGIN__IMAGEQT_IMAGEQT_H_
#include "plugins/imageloader.h"
#include "plugins/imagesaver.h"
#include <stdio.h>
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
imageQT
Loads in a picture
KEYWORDS
pix
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT imageQT : public gem::plugins::imageloader, public gem::plugins::imagesaver {
public:
//////////
// Constructor
imageQT(void);
virtual ~imageQT(void);
//////////
// read an image
virtual bool load(std::string filename, imageStruct&result, gem::Properties&props);
//////////
// write an image
virtual bool save(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props);
//////////
// estimate, how well we could save this image
virtual float estimateSave(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props);
////////
// get writing capabilities of this backend (informative)
virtual void getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props);
////////
// QuickTime cannot be used from threaded contexts
virtual bool isThreadable(void) {return false;}
};
};};
#endif // for header file

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imageQT", "imageQT.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="imageQT"
ProjectGUID="{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
RootNamespace="gem"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;;&quot;$(ProgramFiles)\QuickTime SDK\CIncludes&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN;HAVE_QUICKTIME"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib QTMLClient.lib pd.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;;&quot;$(ProgramFiles)\QuickTime SDK\Libraries&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib pd.lib vfw32.lib OLDNAMES.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\imageQT.cpp">
</File>
<File
RelativePath="..\imageQT.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imageQT", "imageQT.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,171 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="imageQT"
ProjectGUID="{7AD29AEA-D4FD-4E87-B8C8-2C4CEAD24523}"
RootNamespace="gem"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\QuickTime.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\imageQT.cpp"
>
</File>
<File
RelativePath="..\imageQT.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,34 @@
GEM - Graphics Environment for Multimedia
Copyright © 1997-2000 Mark Danks
Copyright © Günter Geiger
Copyright © 2001-2011 IOhannes m zmölnig,
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
In the official GEM distribution, the GNU General Public License is
in the file GnuGPL.LICENSE
---------------------------------------------------------
OTHER COPYRIGHT NOTICES
---------------------------------------------------------
fstimage:
Masayuki Matsumoto
sgi image loader.
matumot[AT]dst.nk-exa.co.jp
Copyright (C) 1995 Masayuki Mastumoto
Modified so that it doesn't exit on error.
Added support for reading grayscale, rgb, and rgba images
Mark Danks - 1998

View file

@ -0,0 +1,35 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
EXTRA_DIST =
EXTRA_DIST += win-vs2003/imageSGI.sln win-vs2003/imageSGI.vcproj
EXTRA_DIST += win-vs2008/imageSGI.sln win-vs2008/imageSGI.vcproj
pkglib_LTLIBRARIES= gem_imageSGI.la
gem_imageSGI_la_CXXFLAGS =
gem_imageSGI_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_imageSGI_la_LDFLAGS += -no-undefined
endif
gem_imageSGI_la_LIBADD =
# RTE
gem_imageSGI_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_imageSGI_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_imageSGI_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_imageSGI_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_imageSGI_la @MOREFLAGS@
# Dependencies
## none
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_imageSGI_la_SOURCES= imageSGI.cpp imageSGI.h sgiimage.cpp sgiimage.h

View file

@ -0,0 +1,139 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include "imageSGI.h"
#include "Gem/RTE.h"
#include "sgiimage.h"
#include "plugins/PluginFactory.h"
using namespace gem::plugins;
REGISTER_IMAGELOADERFACTORY("SGI", imageSGI);
/////////////////////////////////////////////////////////
//
// imageSGI
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
imageSGI :: imageSGI(void)
{
//post("imageSGI");
}
imageSGI :: ~imageSGI(void)
{
//post("~imageSGI");
}
/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
bool imageSGI :: load(std::string filename, imageStruct&result, gem::Properties&props)
{
int32 xsize, ysize, csize;
if (!sizeofimage(filename.c_str(), &xsize, &ysize, &csize) )
return(NULL);
::verbose(2, "reading '%s' with SGI", filename.c_str());
result.xsize=xsize;
result.ysize=ysize;
if (csize == 4 || csize == 3) {
result.setCsizeByFormat(GL_RGBA);
} else if (csize == 1) {
result.setCsizeByFormat(GL_LUMINANCE);
} else {
//error("GemImageLoad(SGI): unknown color components in SGI file: %s", filename.c_str());
return(false);
}
result.reallocate();
unsigned int32 *readData = longimagedata((char *)filename.c_str());
if (!readData) {
//error("GemImageLoad: error reading SGI image file: %s", filename.c_str());
return false;
}
unsigned char *src = reinterpret_cast<unsigned char*>(readData);
unsigned char *dst = &(result.data[0]);
const int yStride = result.xsize * result.csize;
// do RGBA data
if (csize == 4) {
while (ysize--) {
unsigned char *pixels = dst;
int count = xsize;
while(count--) {
pixels[chRed] = src[0];
pixels[chGreen] = src[1];
pixels[chBlue] = src[2];
pixels[chAlpha] = src[3];
pixels += 4;
src += 4;
}
dst += yStride;
}
}
else if (csize == 3) {
// do RGB data
while (ysize--) {
unsigned char *pixels = dst;
int count = xsize;
while(count--) {
pixels[chRed] = src[0];
pixels[chGreen] = src[1];
pixels[chBlue] = src[2];
pixels[chAlpha] = 255;;
pixels += 4;
src += 4;
}
dst += yStride;
}
} else {
// do grayscale
while (ysize--) {
unsigned char *pixels = dst;
int count = xsize;
while(count--) {
pixels[0] = src[0];
pixels++;
src += 4;
}
dst += yStride;
}
}
free(readData);
return true;
}
bool imageSGI::save(const imageStruct&image, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
return false;
}
float imageSGI::estimateSave(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
return 0.;
}

View file

@ -0,0 +1,59 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load an SGI picture
Copyright (c) 2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__IMAGESGI_IMAGESGI_H_
#define _INCLUDE_GEMPLUGIN__IMAGESGI_IMAGESGI_H_
#include "plugins/imageloader.h"
#include <stdio.h>
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
imageSGI
Loads in a picture
KEYWORDS
pix
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT imageSGI : public gem::plugins::imageloader {
public:
//////////
// Constructor
imageSGI(void);
virtual ~imageSGI(void);
//////////
// read an image
virtual bool load(std::string filename, imageStruct&result, gem::Properties&props);
//////////
// write an image
virtual bool save(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props);
//////////
// estimate, how well we could save this image
virtual float estimateSave(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props);
// this is always threadable
virtual bool isThreadable(void) { return true; }
};
};};
#endif // for header file

View file

@ -0,0 +1,697 @@
/*
* fastimg -
* Faster reading and writing of image files.
*
* This code should work on machines with any byte order.
*
* Could someone make this run real fast using multiple processors
* or how about using memory mapped files to speed it up?
*
* Paul Haeberli - 1991
*/
/*
* porting to Windows NT
* Masayuki Mastumoto - 1995
*/
/*
* Modified so that it doesn't exit on error.
* Added support for reading grayscale, rgb, and rgba images
* Mark Danks - 1998
*/
// FIXXME: use C++ memory allocators
#include <stdlib.h>
#include "sgiimage.h"
#ifndef _WIN32
# include <unistd.h>
#endif // for !win32
#include <string.h>
#include <stdio.h>
#include "Gem/RTE.h"
//#include "m_pd.h"
/*
* from image.h
*
*/
typedef struct {
unsigned short imagic; /* stuff saved on disk . . */
unsigned short type;
unsigned short dim;
unsigned short xsize;
unsigned short ysize;
unsigned short zsize;
unsigned int32 min;
unsigned int32 max;
unsigned int32 wastebytes;
char name[80];
unsigned int32 colormap;
int32 file; /* stuff used in core only */
unsigned short flags;
short dorev;
short x;
short y;
short z;
short cnt;
unsigned short *ptr;
unsigned short *base;
unsigned short *tmpbuf;
unsigned int32 offset;
unsigned int32 rleend; /* for rle images */
unsigned int32 *rowstart; /* for rle images */
int32 *rowsize; /* for rle images */
} IMAGE;
#define IMAGIC 0732
#define TYPEMASK 0xff00
#define BPPMASK 0x00ff
#define ITYPE_VERBATIM 0x0000
#define ITYPE_RLE 0x0100
#define ISRLE(type) (((type) & 0xff00) == ITYPE_RLE)
#define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM)
#define BPP(type) ((type) & BPPMASK)
#define RLE(bpp) (ITYPE_RLE | (bpp))
#define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp))
/*
* end of image.h stuff
*
*/
#define RINTLUM (79)
#define GINTLUM (156)
#define BINTLUM (21)
#define ILUM(r,g,b) (static_cast<int>(RINTLUM*(r)+GINTLUM*(g)+BINTLUM*(b))>>8)
#define OFFSET_R 3 /* this is byte order dependent */
#define OFFSET_G 2
#define OFFSET_B 1
#define OFFSET_A 0
#define CHANOFFSET(z) (3-(z)) /* this is byte order dependent */
static void expandrow(unsigned char *optr, unsigned char *iptr, int32 z);
static void setalpha(unsigned char *lptr, int32 n);
static void copybw(int32 *lptr, int32 n);
static void lumrow(unsigned char *rgbptr, unsigned char *lumptr, int32 n);
static int compressrow(unsigned char *lbuf, unsigned char *rlebuf, int32 z, int32 cnt);
static void interleaverow(unsigned char *lptr, unsigned char *cptr, int32 z, int32 n);
#define TAGLEN (5)
/*
* addlongimgtag -
* this is used to extract image data from core dumps.
*
*/
unsigned int32 *
getLongImage(const char *textureFile, int32 *xsize, int32 *ysize, int32 *csize)
{
sizeofimage(textureFile, xsize, ysize, csize);
return longimagedata(textureFile);
}
void addlongimgtag(unsigned int32 *dptr, int32 xsize, int32 ysize)
{
dptr = dptr+(xsize*ysize);
dptr[0] = 0x12345678;
dptr[1] = 0x59493333;
dptr[2] = 0x69434222;
dptr[3] = xsize;
dptr[4] = ysize;
}
/*
* byte order independent read/write of shorts and longs.
*
*/
static unsigned short getshort(FILE *inf)
{
unsigned char buf[2];
size_t count=fread(buf,2,1,inf);
if(count<1){error("error reading file"); return 0;}
return (buf[0]<<8)+(buf[1]<<0);
}
static unsigned int32 getlong(FILE *inf)
{
unsigned char buf[4];
size_t count = fread(buf,4,1,inf);
if(count<1){error("error reading file"); return 0;}
return (buf[0]<<24)+(buf[1]<<16)+(buf[2]<<8)+(buf[3]<<0);
}
static void putshort(FILE *outf, unsigned short val)
{
unsigned char buf[2];
buf[0] = (val>>8);
buf[1] = (val>>0);
fwrite(buf,2,1,outf);
}
static int putlong(FILE *outf, unsigned int32 val)
{
unsigned char buf[4];
buf[0] = static_cast<unsigned char>(val>>24);
buf[1] = static_cast<unsigned char>(val>>16);
buf[2] = static_cast<unsigned char>(val>>8);
buf[3] = static_cast<unsigned char>(val>>0);
return fwrite(buf,4,1,outf);
}
static void readheader(FILE *inf, IMAGE *image)
{
memset(image, 0, sizeof(IMAGE));
image->imagic = getshort(inf);
image->type = getshort(inf);
image->dim = getshort(inf);
image->xsize = getshort(inf);
image->ysize = getshort(inf);
image->zsize = getshort(inf);
}
static int writeheader(FILE *outf, IMAGE *image)
{
IMAGE t;
memset(&t, 0, sizeof(IMAGE));
fwrite(&t,sizeof(IMAGE),1,outf);
fseek(outf,0,SEEK_SET);
putshort(outf,image->imagic);
putshort(outf,image->type);
putshort(outf,image->dim);
putshort(outf,image->xsize);
putshort(outf,image->ysize);
putshort(outf,image->zsize);
putlong(outf,image->min);
putlong(outf,image->max);
putlong(outf,0);
return fwrite("no name",8,1,outf);
}
static int writetab(FILE *outf, unsigned int32 *tab, int32 len)
{
int r=0;
while(len) {
r = putlong(outf,*tab++);
len -= 4;
}
return r;
}
static void readtab(FILE *inf, unsigned int32 *tab, int32 len)
{
while(len) {
*tab++ = getlong(inf);
len -= 4;
}
}
/*
* sizeofimage -
* return the xsize and ysize of an iris image file.
*
*/
int sizeofimage(const char *name, int32 *xsize, int32 *ysize, int32 *csize)
{
IMAGE image;
FILE *inf;
inf = fopen(name,"rb");
if(!inf)
{
return(0);
}
readheader(inf,&image);
if(image.imagic != IMAGIC)
{
fclose(inf);
return(0);
}
*xsize = image.xsize;
*ysize = image.ysize;
*csize = image.zsize;
fclose(inf);
return(1);
}
/*
* longimagedata -
* read in a B/W RGB or RGBA iris image file and return a
* pointer to an array of longs.
*
*/
unsigned int32 *longimagedata(const char *name)
{
unsigned int32 *base, *lptr;
unsigned char *rledat, *verdat;
unsigned int32 *starttab, *lengthtab;
FILE *inf;
IMAGE *image;
int y, z, tablen;
int xsize, ysize, zsize;
int bpp, rle, badorder;
unsigned int rlebuflen;
unsigned int cur;
inf = fopen(name,"rb");
if(!inf)
{
return(NULL);
}
image = (IMAGE *)malloc(sizeof(IMAGE));
readheader(inf,image);
if(image->imagic != IMAGIC)
{
fclose(inf);
return(NULL);
}
rle = ISRLE(image->type);
bpp = BPP(image->type);
if(bpp != 1 )
{
printf("longimagedata: image must have 1 byte per pix chan\n");
fclose(inf);
return(NULL);
}
xsize = image->xsize;
ysize = image->ysize;
zsize = image->zsize;
if(rle)
{
tablen = ysize*zsize*sizeof(int32);
starttab = (unsigned int32 *)malloc(tablen);
lengthtab = (unsigned int32 *)malloc(tablen);
rlebuflen = static_cast<int32>(1.05*xsize+10);
rledat = (unsigned char *)malloc(rlebuflen);
fseek(inf,512,SEEK_SET);
readtab(inf,starttab,tablen);
readtab(inf,lengthtab,tablen);
/* check data order */
cur = 0;
badorder = 0;
for(y=0; y<ysize; y++)
{
for(z=0; z<zsize; z++)
{
if(starttab[y+z*ysize]<cur)
{
badorder = 1;
break;
}
cur = starttab[y+z*ysize];
}
if(badorder)
break;
}
fseek(inf,512+2*tablen,SEEK_SET);
cur = 512+2*tablen;
base = (unsigned int32 *)
malloc((xsize*ysize+TAGLEN)*sizeof(int32));
addlongimgtag(base,xsize,ysize);
if(badorder)
{
for(z=0; z<zsize; z++)
{
lptr = base;
for(y=0; y<ysize; y++)
{
if(cur != starttab[y+z*ysize])
{
fseek(inf,starttab[y+z*ysize],SEEK_SET);
cur = starttab[y+z*ysize];
}
if(lengthtab[y+z*ysize]>rlebuflen)
{
printf("longimagedata: rlebuf(%d) is too small - bad poop : %d\n",rlebuflen, lengthtab[y+z*ysize]);
return(NULL);
}
size_t count=fread(rledat,lengthtab[y+z*ysize],1,inf);
if(count<1){error("error reading file"); return 0;}
cur += lengthtab[y+z*ysize];
#ifdef IRISGL
expandrow((unsigned char *)lptr,(unsigned char *)rledat,3-z);
#else
expandrow((unsigned char *)lptr,(unsigned char *)rledat,z);
#endif
lptr += xsize;
}
}
}
else
{
lptr = base;
for(y=0; y<ysize; y++)
{
for(z=0; z<zsize; z++)
{
if(cur != starttab[y+z*ysize])
{
fseek(inf,starttab[y+z*ysize],SEEK_SET);
cur = starttab[y+z*ysize];
}
size_t count=fread(rledat,lengthtab[y+z*ysize],1,inf);
if(count<1){error("error reading file"); return 0;}
cur += lengthtab[y+z*ysize];
#ifdef IRISGL
expandrow((unsigned char *)lptr,(unsigned char *)rledat,3-z);
#else
expandrow((unsigned char *)lptr,(unsigned char *)rledat,z);
#endif
}
lptr += xsize;
}
}
if(zsize == 3)
setalpha((unsigned char *)base,xsize*ysize);
else if(zsize<3)
copybw((int32 *)base,xsize*ysize);
fclose(inf);
free(starttab);
free(lengthtab);
free(rledat);
free(image);
return base;
}
else
{
base = (unsigned int32 *)
malloc((xsize*ysize+TAGLEN)*sizeof(int32));
addlongimgtag(base,xsize,ysize);
verdat = (unsigned char *)malloc(xsize);
fseek(inf,512,SEEK_SET);
for(z=0; z<zsize; z++)
{
lptr = base;
for(y=0; y<ysize; y++)
{
size_t count = fread(verdat,xsize,1,inf);
if(count<1){error("error reading file"); return 0;}
#ifdef IRISGL
interleaverow((unsigned char *)lptr,verdat,3-z,xsize);
#else
interleaverow((unsigned char *)lptr,verdat,z,xsize);
#endif
lptr += xsize;
}
}
if(zsize == 3)
setalpha((unsigned char *)base,xsize*ysize);
else if(zsize<3)
copybw((int32 *)base,xsize*ysize);
fclose(inf);
free(verdat);
free(image);
return base;
}
}
/* static utility functions for longimagedata */
static void interleaverow(unsigned char *lptr, unsigned char *cptr, int32 z, int32 n)
{
lptr += z;
while(n--) {
*lptr = *cptr++;
lptr += 4;
}
}
static void copybw(int32 *lptr, int32 n)
{
while(n>=8) {
lptr[0] = 0xff000000+(0x010101*(lptr[0]&0xff));
lptr[1] = 0xff000000+(0x010101*(lptr[1]&0xff));
lptr[2] = 0xff000000+(0x010101*(lptr[2]&0xff));
lptr[3] = 0xff000000+(0x010101*(lptr[3]&0xff));
lptr[4] = 0xff000000+(0x010101*(lptr[4]&0xff));
lptr[5] = 0xff000000+(0x010101*(lptr[5]&0xff));
lptr[6] = 0xff000000+(0x010101*(lptr[6]&0xff));
lptr[7] = 0xff000000+(0x010101*(lptr[7]&0xff));
lptr += 8;
n-=8;
}
while(n--) {
*lptr = 0xff000000+(0x010101*(*lptr&0xff));
lptr++;
}
}
static void setalpha(unsigned char *lptr, int32 n)
{
#ifndef IRISGL
lptr +=3;
#endif
while(n>=8) {
lptr[0*4] = 0xff;
lptr[1*4] = 0xff;
lptr[2*4] = 0xff;
lptr[3*4] = 0xff;
lptr[4*4] = 0xff;
lptr[5*4] = 0xff;
lptr[6*4] = 0xff;
lptr[7*4] = 0xff;
lptr += 4*8;
n -= 8;
}
while(n--) {
*lptr = 0xff;
lptr += 4;
}
}
static void expandrow(unsigned char *optr, unsigned char *iptr, int32 z)
{
unsigned char pixel, count;
optr += z;
while(1) {
pixel = *iptr++;
if ( !(count = (pixel & 0x7f)) )
return;
if(pixel & 0x80) {
while(count>=8) {
optr[0*4] = iptr[0];
optr[1*4] = iptr[1];
optr[2*4] = iptr[2];
optr[3*4] = iptr[3];
optr[4*4] = iptr[4];
optr[5*4] = iptr[5];
optr[6*4] = iptr[6];
optr[7*4] = iptr[7];
optr += 8*4;
iptr += 8;
count -= 8;
}
while(count--) {
*optr = *iptr++;
optr+=4;
}
} else {
pixel = *iptr++;
while(count>=8) {
optr[0*4] = pixel;
optr[1*4] = pixel;
optr[2*4] = pixel;
optr[3*4] = pixel;
optr[4*4] = pixel;
optr[5*4] = pixel;
optr[6*4] = pixel;
optr[7*4] = pixel;
optr += 8*4;
count -= 8;
}
while(count--) {
*optr = pixel;
optr+=4;
}
}
}
}
/*
* longstoimage -
* copy an array of longs to an iris image file. Each long
* represents one pixel. xsize and ysize specify the dimensions of
* the pixel array. zsize specifies what kind of image file to
* write out. if zsize is 1, the luminance of the pixels are
* calculated, and a sinlge channel black and white image is saved.
* If zsize is 3, an RGB image file is saved. If zsize is 4, an
* RGBA image file is saved.
*
*/
int longstoimage(unsigned int32 *lptr, int32 xsize, int32 ysize, int32 zsize, const char *name)
{
FILE *outf;
IMAGE *image;
int tablen, y, z, pos, len;
int32 *starttab, *lengthtab;
unsigned char *rlebuf;
unsigned int32 *lumbuf;
int rlebuflen, goodwrite;
goodwrite = 1;
outf = fopen(name,"wb");
if(!outf) {
printf("longstoimage: can't open output file\n");
return 0;
}
tablen = ysize*zsize*sizeof(int32);
image = (IMAGE *)malloc(sizeof(IMAGE));
starttab = (int32 *)malloc(tablen);
lengthtab = (int32 *)malloc(tablen);
rlebuflen = static_cast<int32>(1.05*xsize+10);
rlebuf = (unsigned char *)malloc(rlebuflen);
lumbuf = (unsigned int32 *)malloc(xsize*sizeof(int32));
memset(image,0,sizeof(IMAGE));
image->imagic = IMAGIC;
image->type = RLE(1);
if(zsize>1)
image->dim = 3;
else
image->dim = 2;
image->xsize = static_cast<unsigned short>(xsize);
image->ysize = static_cast<unsigned short>(ysize);
image->zsize = static_cast<unsigned short>(zsize);
image->min = 0;
image->max = 255;
goodwrite *= writeheader(outf,image);
fseek(outf,512+2*tablen,SEEK_SET);
pos = 512+2*tablen;
for(y=0; y<ysize; y++) {
for(z=0; z<zsize; z++) {
if(zsize == 1) {
lumrow((unsigned char *)lptr,(unsigned char *)lumbuf,xsize);
#ifdef IRISGL
len = compressrow((unsigned char *)lumbuf,rlebuf,CHANOFFSET(z),xsize);
#else
len = compressrow((unsigned char *)lumbuf,rlebuf,CHANOFFSET(3-z),xsize);
#endif
} else {
#ifdef IRISGL
len = compressrow((unsigned char *)lptr,rlebuf,CHANOFFSET(z),xsize);
#else
len = compressrow((unsigned char *)lptr,rlebuf,CHANOFFSET(3-z),xsize);
#endif
}
if(len>rlebuflen) {
printf("longstoimage: rlebuf is too small - bad poop\n");
goodwrite=0;
goto longstoimage_close;
}
goodwrite *= fwrite(rlebuf,len,1,outf);
starttab[y+z*ysize] = pos;
lengthtab[y+z*ysize] = len;
pos += len;
}
lptr += xsize;
}
fseek(outf,512,SEEK_SET);
goodwrite *= writetab(outf,(unsigned int32 *)starttab,tablen);
goodwrite *= writetab(outf,(unsigned int32 *)lengthtab,tablen);
longstoimage_close:
free(image);
free(starttab);
free(lengthtab);
free(rlebuf);
free(lumbuf);
fclose(outf);
if(goodwrite)
return 1;
else {
printf("longstoimage: not enough space for image!!\n");
return 0;
}
}
/* static utility functions for longstoimage */
static void lumrow(unsigned char *rgbptr, unsigned char *lumptr, int32 n)
{
lumptr += CHANOFFSET(0);
while(n--) {
*lumptr = ILUM(rgbptr[OFFSET_R],rgbptr[OFFSET_G],rgbptr[OFFSET_B]);
lumptr += 4;
rgbptr += 4;
}
}
static int compressrow(unsigned char *lbuf, unsigned char *rlebuf, int32 z, int32 cnt)
{
unsigned char *iptr, *ibufend, *sptr, *optr;
short todo, cc;
int32 count;
lbuf += z;
iptr = lbuf;
ibufend = iptr+cnt*4;
optr = rlebuf;
while(iptr<ibufend) {
sptr = iptr;
iptr += 8;
while((iptr<ibufend)&& ((iptr[-8]!=iptr[-4])||(iptr[-4]!=iptr[0])))
iptr+=4;
iptr -= 8;
count = (iptr-sptr)/4;
while(count) {
todo = static_cast<short>((count > 126) ? 126 : count);
count -= todo;
*optr++ = 0x80|todo;
while(todo>8) {
optr[0] = sptr[0*4];
optr[1] = sptr[1*4];
optr[2] = sptr[2*4];
optr[3] = sptr[3*4];
optr[4] = sptr[4*4];
optr[5] = sptr[5*4];
optr[6] = sptr[6*4];
optr[7] = sptr[7*4];
optr += 8;
sptr += 8*4;
todo -= 8;
}
while(todo--) {
*optr++ = *sptr;
sptr += 4;
}
}
sptr = iptr;
cc = *iptr;
iptr += 4;
while( (iptr<ibufend) && (*iptr == cc) )
iptr += 4;
count = (iptr-sptr)/4;
while(count) {
todo = static_cast<short>(count>126 ? 126:count);
count -= todo;
*optr++ = static_cast<unsigned char>(todo);
*optr++ = static_cast<unsigned char>(cc);
}
}
*optr++ = 0;
return optr - rlebuf;
}

View file

@ -0,0 +1,23 @@
/*
* porting to Windows NT
* Masayuki Mastumoto - 1995
*/
/*
* Modified so that it doesn't exit on error.
* Added support for reading grayscale, rgb, and rgba images
* Mark Danks - 1998
*/
#ifndef __SGIIMAGE_H__
#define __SGIIMAGE_H__
#define int32 int
extern unsigned int32 *getLongImage(const char *textureFile, int32 *xsize, int32 *ysize, int32 *csize);
extern int longstoimage(unsigned int32 *lptr, int32 xsize, int32 ysize, int32 zsize, const char *name);
extern unsigned int32 *longimagedata(const char *name);
extern int sizeofimage(const char *name, int32 *xsize, int32 *ysize, int32 *csize);
#endif /* __SGIIMAGE_H__ */

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imageSGI", "imageSGI.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="imageSGI"
ProjectGUID="{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
RootNamespace="gem"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib pd.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="OLDNAMES.lib Gem.lib pd.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\imageSGI.cpp">
</File>
<File
RelativePath="..\imageSGI.h">
</File>
<File
RelativePath="..\sgiimage.cpp">
</File>
<File
RelativePath="..\sgiimage.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imageSGI", "imageSGI.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,179 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="imageSGI"
ProjectGUID="{4755C755-FB54-41CF-BECE-EC63B14F6151}"
RootNamespace="gem"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\imageSGI.cpp"
>
</File>
<File
RelativePath="..\imageSGI.h"
>
</File>
<File
RelativePath="..\sgiimage.cpp"
>
</File>
<File
RelativePath="..\sgiimage.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,41 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
EXTRA_DIST =
EXTRA_DIST += win-vs2003/imageTIFF.sln win-vs2003/imageTIFF.vcproj
EXTRA_DIST += win-vs2008/imageTIFF.sln win-vs2008/imageTIFF.vcproj
EXTRA_DIST += win-vs2008/TIFF.vsprops
pkglib_LTLIBRARIES=
if HAVE_LIB_TIFF
pkglib_LTLIBRARIES+= gem_imageTIFF.la
endif
gem_imageTIFF_la_CXXFLAGS =
gem_imageTIFF_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_imageTIFF_la_LDFLAGS += -no-undefined
endif
gem_imageTIFF_la_LIBADD =
# RTE
gem_imageTIFF_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_imageTIFF_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_imageTIFF_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_imageTIFF_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_imageTIFF_la @MOREFLAGS@
# Dependencies
gem_imageTIFF_la_CXXFLAGS += @GEM_LIB_TIFF_CFLAGS@
gem_imageTIFF_la_LIBADD += @GEM_LIB_TIFF_LIBS@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_imageTIFF_la_SOURCES= imageTIFF.cpp imageTIFF.h

View file

@ -0,0 +1,375 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// Copyright (c) Günther Geiger.
// Copyright (c) 2001-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_LIBTIFF
extern "C"
{
# include "tiffio.h"
}
#include <string.h>
#include "imageTIFF.h"
#include "plugins/PluginFactory.h"
#include "Gem/RTE.h"
using namespace gem::plugins;
REGISTER_IMAGELOADERFACTORY("tiff", imageTIFF);
REGISTER_IMAGESAVERFACTORY("tiff", imageTIFF);
#ifdef _MSC_VER
# define vsnprintf _vsnprintf
#endif
namespace {
static void imageTIFF_verbosehandler(const int verbosity, const char*module, const char*fmt, va_list ap) {
std::string result=module;
result+=": ";
char buf[MAXPDSTRING];
vsnprintf(buf, MAXPDSTRING, fmt, ap);
buf[MAXPDSTRING-1]=0;
result+=buf;
verbose(verbosity, "%s", result.c_str());
}
static void imageTIFF_errorhandler(const char*module, const char*fmt, va_list ap) {
imageTIFF_verbosehandler(2, module, fmt, ap);
}
static void imageTIFF_warnhandler(const char*module, const char*fmt, va_list ap) {
imageTIFF_verbosehandler(3, module, fmt, ap);
}
};
/////////////////////////////////////////////////////////
//
// imageTIFF
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
imageTIFF :: imageTIFF(void)
{
//post("imageTIFF");
bool firsttime=true;
if(firsttime) {
TIFFSetErrorHandler(imageTIFF_errorhandler);
TIFFSetWarningHandler(imageTIFF_warnhandler);
}
firsttime=false;
}
imageTIFF :: ~imageTIFF(void)
{
//post("~imageTIFF");
}
/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
bool imageTIFF :: load(std::string filename, imageStruct&result, gem::Properties&props)
{
::verbose(2, "reading '%s' with libTIFF", filename.c_str());
TIFF *tif = TIFFOpen(filename.c_str(), "r");
if (tif == NULL) {
return(NULL);
}
uint32 width, height;
short bits, samps;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bits);
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samps);
int npixels = width * height;
result.xsize=width;
result.ysize=height;
result.upsidedown=true;
result.type=GL_UNSIGNED_BYTE; //?
bool knownFormat = false;
// Is it a gray8 image?
if (bits == 8 && samps == 1)
{
result.setCsizeByFormat(GL_LUMINANCE);
knownFormat = true;
}
// Is it an RGB image?
else if (bits == 8 && samps == 3)
{
result.setCsizeByFormat(GL_RGBA);
knownFormat = true;
}
// Is it an RGBA image?
else if (bits == 8 && samps == 4)
{
result.setCsizeByFormat(GL_RGBA);
knownFormat = true;
}
// can we handle the raw data?
if (knownFormat) {
unsigned char *buf = new unsigned char [TIFFScanlineSize(tif)];
if (buf == NULL) {
error("GemImageLoad(TIFF): can't allocate memory for scanline buffer: %s", filename.c_str());
TIFFClose(tif);
return(false);
}
result.reallocate();
unsigned char *dstLine = result.data;
int yStride = result.xsize * result.csize;
for (uint32 row = 0; row < height; row++)
{
unsigned char *pixels = dstLine;
if (TIFFReadScanline(tif, buf, row, 0) < 0) {
error("GemImageLoad(TIFF): bad image data read on line: %d: %s", row, filename.c_str());
TIFFClose(tif);
return false;
}
unsigned char *inp = buf;
if (samps == 1) {
for (uint32 i = 0; i < width; i++) {
*pixels++ = *inp++; // Gray8
}
}
else if (samps == 3) {
for (uint32 i = 0; i < width; i++) {
pixels[chRed] = inp[0]; // Red
pixels[chGreen] = inp[1]; // Green
pixels[chBlue] = inp[2]; // Blue
pixels[chAlpha] = 255; // Alpha
pixels += 4;
inp += 3;
}
} else {
for (uint32 i = 0; i < width; i++) {
pixels[chRed] = inp[0]; // Red
pixels[chGreen] = inp[1]; // Green
pixels[chBlue] = inp[2]; // Blue
pixels[chAlpha] = inp[3]; // Alpha
pixels += 4;
inp += 4;
}
}
dstLine += yStride;
}
delete [] buf;
}
// nope, so use the automatic conversion
else {
char emsg[1024];
TIFFRGBAImage img;
if (TIFFRGBAImageBegin(&img, tif, 0, emsg) == 0) {
//error("GemImageLoad(TIFF): Error reading in image file: %s : %s", filename, emsg);
TIFFClose(tif);
return(false);
}
uint32*raster = reinterpret_cast<uint32*>(_TIFFmalloc(npixels * sizeof(uint32)));
if (raster == NULL) {
error("GemImageLoad(TIFF): Unable to allocate memory for image: %s", filename.c_str());
TIFFClose(tif);
return(false);
}
if (TIFFRGBAImageGet(&img, raster, width, height) == 0) {
//error("GemImageLoad(TIFF): Error getting image data in file: %s, %s", filename, emsg);
_TIFFfree(raster);
TIFFClose(tif);
return(false);
}
TIFFRGBAImageEnd(&img);
result.setCsizeByFormat(GL_RGBA);
result.reallocate();
unsigned char *dstLine = result.data;
int yStride = result.xsize * result.csize;
// transfer everything over
int k = 0;
for (uint32 i = 0; i < height; i++) {
unsigned char *pixels = dstLine;
for (uint32 j = 0; j < width; j++) {
pixels[chRed] = static_cast<unsigned char>(TIFFGetR(raster[k])); // Red
pixels[chGreen] = static_cast<unsigned char>(TIFFGetG(raster[k])); // Green
pixels[chBlue] = static_cast<unsigned char>(TIFFGetB(raster[k])); // Blue
pixels[chAlpha] = static_cast<unsigned char>(TIFFGetA(raster[k])); // Alpha
k++;
pixels += 4;
}
dstLine += yStride;
}
_TIFFfree(raster);
}
double value_d;
short value_i16;
char value_s[MAXPDSTRING];
if(TIFFGetField(tif, TIFFTAG_XRESOLUTION, &value_d)) props.set("xresolution", value_d);
if(TIFFGetField(tif, TIFFTAG_YRESOLUTION, &value_d)) props.set("yresolution", value_d);
if(TIFFGetField(tif, TIFFTAG_XRESOLUTION, &value_d)) props.set("xresolution", value_d);
if(TIFFGetField(tif, TIFFTAG_RESOLUTIONUNIT, &value_i16)) {
std::string resunit;
switch(value_i16) {
case RESUNIT_INCH:
resunit="inch";
break;
case RESUNIT_CENTIMETER:
resunit="centimeter";
break;
default:
resunit="none";
break;
}
props.set("resolutionunit", resunit);
}
if(TIFFGetField(tif, TIFFTAG_SOFTWARE, &value_s)) props.set("software", std::string(value_s));
if(TIFFGetField(tif, TIFFTAG_ARTIST, &value_s)) props.set("artist", std::string(value_s));
if(TIFFGetField(tif, TIFFTAG_HOSTCOMPUTER, &value_s)) props.set("hostcomputer", std::string(value_s));
TIFFClose(tif);
return true;
}
bool imageTIFF::save(const imageStruct&constimage, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
TIFF *tif = NULL;
if(GL_YUV422_GEM==constimage.format) {
error("don't know how to write YUV-images with libTIFF");
return false;
}
tif=TIFFOpen(filename.c_str(), "w");
if (tif == NULL) {
return false;
}
imageStruct image; constimage.copy2Image(&image);
image.fixUpDown();
uint32 width=image.xsize, height = image.ysize;
short bits=8, samps=image.csize;
int npixels = width * height;
//int planar_conf = PLANARCONFIG_CONTIG;
std::string software = "PD/GEM";
std::string artist;
std::string hostcomputer;
double xresolution = 72., yresolution=72.;
short resunit = RESUNIT_INCH;
props.get("xresolution", xresolution);
props.get("yresolution", yresolution);
std::string resunit_s;
if(props.get("resolutionunit", resunit_s)) {
if(("inch"==resunit_s) || ("english"==resunit_s) || ("imperial"==resunit_s))
resunit=RESUNIT_INCH;
else if(("centimeter"==resunit_s) || ("metric"==resunit_s))
resunit=RESUNIT_CENTIMETER;
else
resunit=RESUNIT_NONE;
}
props.get("software", software);
props.get("artist", artist);
props.get("hostcomputer", hostcomputer);
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bits);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, samps);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, 1);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField(tif, TIFFTAG_XRESOLUTION, xresolution); // RATIONAL
TIFFSetField(tif, TIFFTAG_YRESOLUTION, yresolution); // RATIONAL
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, resunit);
if(!software.empty())
TIFFSetField(tif, TIFFTAG_SOFTWARE, software.c_str());
if(!artist.empty())
TIFFSetField(tif, TIFFTAG_ARTIST, artist.c_str());
if(!hostcomputer.empty())
TIFFSetField(tif, TIFFTAG_HOSTCOMPUTER, hostcomputer.c_str());
int yStride = image.xsize * image.csize;
unsigned char *srcLine = &(image.data[npixels * image.csize]);
srcLine -= yStride;
for (uint32 row = 0; row < height; row++) {
unsigned char *buf = srcLine;
if (TIFFWriteScanline(tif, buf, row, 0) < 0)
{
error("GEM: could not write line %d to image %s", row, filename.c_str());
TIFFClose(tif);
delete [] buf;
return(false);
}
srcLine -= yStride;
}
TIFFClose(tif);
return true;
}
float imageTIFF::estimateSave(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props) {
float result=0;
if(mimetype == "image/tiff" || mimetype == "image/x-tiff")
result += 100;
if(gem::Properties::UNSET != props.type("xresolution"))result+=1.;
if(gem::Properties::UNSET != props.type("yresolution"))result+=1.;
if(gem::Properties::UNSET != props.type("resolutionunit"))result+=1.;
if(gem::Properties::UNSET != props.type("software"))result+=1.;
if(gem::Properties::UNSET != props.type("artist"))result+=1.;
if(gem::Properties::UNSET != props.type("hostcomputer"))result+=1.;
return result;
}
void imageTIFF::getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props) {
mimetypes.clear();
props.clear();
mimetypes.push_back("image/tiff");
mimetypes.push_back("image/x-tiff");
gem::any value;
value=72.f;
props.set("xresolution", value);
props.set("yresolution", value);
value=std::string("inch");
props.set("resolutionunit", value);
value=std::string("PD/GEM");
props.set("software", value);
value=std::string("");
props.set("artist", value);
props.set("hostcomputer", value);
}
#endif

View file

@ -0,0 +1,65 @@
/*-----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load a picture (using libtiff)
Copyright (c) 2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE_GEMPLUGIN__IMAGETIFF_IMAGETIFF_H_
#define _INCLUDE_GEMPLUGIN__IMAGETIFF_IMAGETIFF_H_
#include "plugins/imageloader.h"
#include "plugins/imagesaver.h"
#include <stdio.h>
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
imageTIFF
Loads in a picture
KEYWORDS
pix
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT imageTIFF : public gem::plugins::imageloader, public gem::plugins::imagesaver {
public:
//////////
// Constructor
imageTIFF(void);
virtual ~imageTIFF(void);
//////////
// read an image
virtual bool load(std::string filename, imageStruct&result, gem::Properties&props);
//////////
// write an image
virtual bool save(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props);
//////////
// estimate, how well we could save this image
virtual float estimateSave(const imageStruct&img, const std::string&filename, const std::string&mimetype, const gem::Properties&props);
////////
// get writing capabilities of this backend (informative)
virtual void getWriteCapabilities(std::vector<std::string>&mimetypes, gem::Properties&props);
////////
// can be used from threaded contexts
virtual bool isThreadable(void) {return true;}
};
};};
#endif // for header file

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imageTIFF", "imageTIFF.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="imageTIFF"
ProjectGUID="{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
RootNamespace="gem"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;;&quot;$(ProjectDir)\..\..\..\..\GemLibs\tiff\libtiff&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN;HAVE_LIBTIFF"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib libtiff.lib pd.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;;&quot;$(ProjectDir)\..\..\..\..\GemLibs\tiff&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="OLDNAMES.lib Gem.lib pd.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\imageTIFF.cpp">
</File>
<File
RelativePath="..\imageTIFF.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="TIFF"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="$(ProjectDir)\..\..\..\..\GemLibs\tiff\libtiff"
PreprocessorDefinitions="HAVE_LIBTIFF"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libtiff.lib"
AdditionalLibraryDirectories="$(ProjectDir)\..\..\..\..\GemLibs\tiff"
/>
</VisualStudioPropertySheet>

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imageTIFF", "imageTIFF.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,171 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="imageTIFF"
ProjectGUID="{6D5697D9-964B-43B0-B5F8-5779E5EF7FCC}"
RootNamespace="gem"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops;.\TIFF.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\imageTIFF.cpp"
>
</File>
<File
RelativePath="..\imageTIFF.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,43 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
EXTRA_DIST =
EXTRA_DIST += win-vs2003/modelASSIMP2.sln win-vs2003/modelASSIMP2.vcproj
EXTRA_DIST += win-vs2008/modelASSIMP2.sln win-vs2008/modelASSIMP2.vcproj
EXTRA_DIST += win-vs2008/ASSIMP2.vsprops
pkglib_LTLIBRARIES=
if HAVE_LIB_ASSIMP
pkglib_LTLIBRARIES += gem_modelASSIMP2.la
endif
gem_modelASSIMP2_la_CXXFLAGS =
gem_modelASSIMP2_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_modelASSIMP2_la_LDFLAGS += -no-undefined
endif
gem_modelASSIMP2_la_LIBADD =
# RTE
gem_modelASSIMP2_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_modelASSIMP2_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_modelASSIMP2_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_modelASSIMP2_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_modelASSIMP2_la @MOREFLAGS@
# Dependencies
gem_modelASSIMP2_la_CXXFLAGS += @PKG_ASSIMP_CFLAGS@ @GL_CFLAGS@
gem_modelASSIMP2_la_LIBADD += @PKG_ASSIMP_LIBS@ @GL_LIBS@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_modelASSIMP2_la_SOURCES= \
modelASSIMP2.cpp \
modelASSIMP2.h

View file

@ -0,0 +1,32 @@
read a model using ASSIMPv2 (http://assimp.sf.net)
--------------------------------------------------
TODO
====
animation:
-> http://nolimitsdesigns.com/game-design/open-asset-import-library-animation-loader/
extract texture files
compilation hints
=================
w32-mingw
---------
on w32/MinGW, configure will most likely not find your installation of the assimp-sdk.
this is what i use approximately to enable assimp support when building Gem with MinGW
(the code is bash-script, change appropriately if you use another shell; the leading '$'
is to indicate newlines - don't copy them)
also make sure that ASSIMP_PATH does not contain any spaces!
$ ASSIMP_PATH=/home/zmoelnig/src/assimp--2.0.863-sdk
$ ASSIMP_CFLAGS=-I${ASSIMP_PATH}/include
$ ASSIMP_LIBS=-L${ASSIMP_PATH}/bin/assimp_release-dll_win32 -Xlinker -l:Assimp32.dll
$ ./configure PKG_ASSIMP_CFLAGS="${ASSIMP_CFLAGS}" PKG_ASSIMP_LIBS="${ASSIMP_LIBS}"
it's a good idea to put the "Assimp32.dll" besides your gem_modelASSIMP.dll

View file

@ -0,0 +1,419 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 2001-2012 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if (defined HAVE_LIBASSIMP2) && (defined HAVE_ASSIMP_H)
#include "modelASSIMP2.h"
#include "plugins/PluginFactory.h"
#include "Gem/RTE.h"
#include "Gem/Exception.h"
#include "Gem/Properties.h"
#include "Utils/Functions.h"
#include <string>
#include <math.h>
using namespace gem::plugins;
REGISTER_MODELLOADERFACTORY("ASSIMP2", modelASSIMP2);
namespace {
#define aisgl_min(x,y) (x<y?x:y)
#define aisgl_max(x,y) (y>x?y:x)
// ----------------------------------------------------------------------------
static void get_bounding_box_for_node (const struct aiScene*scene, const struct aiNode* nd,
struct aiVector3D* min,
struct aiVector3D* max,
struct aiMatrix4x4* trafo
){
struct aiMatrix4x4 prev;
unsigned int n = 0, t;
prev = *trafo;
aiMultiplyMatrix4(trafo,&nd->mTransformation);
for (; n < nd->mNumMeshes; ++n) {
const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
for (t = 0; t < mesh->mNumVertices; ++t) {
struct aiVector3D tmp = mesh->mVertices[t];
aiTransformVecByMatrix4(&tmp,trafo);
min->x = aisgl_min(min->x,tmp.x);
min->y = aisgl_min(min->y,tmp.y);
min->z = aisgl_min(min->z,tmp.z);
max->x = aisgl_max(max->x,tmp.x);
max->y = aisgl_max(max->y,tmp.y);
max->z = aisgl_max(max->z,tmp.z);
}
}
for (n = 0; n < nd->mNumChildren; ++n) {
get_bounding_box_for_node(scene, nd->mChildren[n],min,max,trafo);
}
*trafo = prev;
}
// ----------------------------------------------------------------------------
static void get_bounding_box (const struct aiScene*scene, struct aiVector3D* min, struct aiVector3D* max)
{
struct aiMatrix4x4 trafo;
aiIdentityMatrix4(&trafo);
min->x = min->y = min->z = 1e10f;
max->x = max->y = max->z = -1e10f;
get_bounding_box_for_node(scene, scene->mRootNode,min,max,&trafo);
}
// ----------------------------------------------------------------------------
static void color4_to_float4(const struct aiColor4D *c, float f[4])
{
f[0] = c->r;
f[1] = c->g;
f[2] = c->b;
f[3] = c->a;
}
// ----------------------------------------------------------------------------
static void set_float4(float f[4], float a, float b, float c, float d)
{
f[0] = a;
f[1] = b;
f[2] = c;
f[3] = d;
}
// ----------------------------------------------------------------------------
static void apply_material(const struct aiMaterial *mtl)
{
float c[4];
GLenum fill_mode;
int ret1, ret2;
struct aiColor4D diffuse;
struct aiColor4D specular;
struct aiColor4D ambient;
struct aiColor4D emission;
float shininess, strength;
int two_sided;
int wireframe;
unsigned int max;
set_float4(c, 0.8f, 0.8f, 0.8f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, &diffuse))
color4_to_float4(&diffuse, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, c);
//post("diffuse: %g\t%g\t%g\t%g", c[0], c[1], c[2], c[3]);
set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_SPECULAR, &specular))
color4_to_float4(&specular, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, c);
//post("specular: %g\t%g\t%g\t%g", c[0], c[1], c[2], c[3]);
set_float4(c, 0.2f, 0.2f, 0.2f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_AMBIENT, &ambient))
color4_to_float4(&ambient, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, c);
//post("ambient: %g\t%g\t%g\t%g", c[0], c[1], c[2], c[3]);
set_float4(c, 0.0f, 0.0f, 0.0f, 1.0f);
if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_EMISSIVE, &emission))
color4_to_float4(&emission, c);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, c);
// post("emission: %g\t%g\t%g\t%g", c[0], c[1], c[2], c[3]);
max = 1;
ret1 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS, &shininess, &max);
max = 1;
ret2 = aiGetMaterialFloatArray(mtl, AI_MATKEY_SHININESS_STRENGTH, &strength, &max);
if((ret1 == AI_SUCCESS) && (ret2 == AI_SUCCESS)) {
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess * strength);
//post("shininess: %gx%g=%g\t%g", shininess, strength, shininess*strength);
}
else {
/* JMZ: in modelOBJ the default shininess is 65 */
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0f);
set_float4(c, 0.0f, 0.0f, 0.0f, 0.0f);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, c);
}
max = 1;
if(AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_ENABLE_WIREFRAME, &wireframe, &max)) {
fill_mode = wireframe ? GL_LINE : GL_FILL;
} else {
fill_mode = GL_FILL;
}
glPolygonMode(GL_FRONT_AND_BACK, fill_mode);
max = 1;
if((AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_TWOSIDED, &two_sided, &max)) && two_sided) {
glEnable(GL_CULL_FACE);
} else {
glDisable(GL_CULL_FACE);
}
}
// ----------------------------------------------------------------------------
// Can't send color down as a pointer to aiColor4D because AI colors are ABGR.
static void Color4f(const struct aiColor4D *color)
{
glColor4f(color->r, color->g, color->b, color->a);
}
// ----------------------------------------------------------------------------
static void recursive_render (const struct aiScene*scene, const struct aiScene *sc, const struct aiNode* nd, const bool use_material)
{
int i;
unsigned int n = 0, t;
struct aiMatrix4x4 m = nd->mTransformation;
// update transform
aiTransposeMatrix4(&m);
glPushMatrix();
glMultMatrixf((float*)&m);
// draw all meshes assigned to this node
for (; n < nd->mNumMeshes; ++n) {
const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
if(use_material)
apply_material(sc->mMaterials[mesh->mMaterialIndex]);
#if 0 /* handled globally */
if(mesh->mNormals == NULL) {
glDisable(GL_LIGHTING);
} else {
glEnable(GL_LIGHTING);
}
#endif
#if 0
if(mesh->mColors[0] != NULL) {
glEnable(GL_COLOR_MATERIAL);
} else {
glDisable(GL_COLOR_MATERIAL);
}
#endif
for (t = 0; t < mesh->mNumFaces; ++t) {
const struct aiFace* face = &mesh->mFaces[t];
GLenum face_mode;
switch(face->mNumIndices) {
case 1: face_mode = GL_POINTS; break;
case 2: face_mode = GL_LINES; break;
case 3: face_mode = GL_TRIANGLES; break;
default: face_mode = GL_POLYGON; break;
}
glBegin(face_mode);
for(i = 0; i < face->mNumIndices; i++) {
int index = face->mIndices[i];
if(use_material && mesh->mColors[0] != NULL)
Color4f(&mesh->mColors[0][index]);
if(mesh->mNormals != NULL)
glNormal3fv(&mesh->mNormals[index].x);
if(mesh->HasTextureCoords(0))
glTexCoord2f(mesh->mTextureCoords[0][index].x, mesh->mTextureCoords[0][index].y);
glVertex3fv(&mesh->mVertices[index].x);
}
glEnd();
}
}
// draw all children
for (n = 0; n < nd->mNumChildren; ++n) {
recursive_render(scene, sc, nd->mChildren[n], use_material);
}
glPopMatrix();
}
};
modelASSIMP2 :: modelASSIMP2(void) :
m_rebuild(true),
m_scene(NULL), m_dispList(0),
m_scale(1.f),
m_useMaterial(false)
{
}
modelASSIMP2 ::~modelASSIMP2(void) {
destroy();
}
bool modelASSIMP2 :: open(const std::string&name, const gem::Properties&requestprops) {
destroy();
m_scene = aiImportFile(name.c_str(), aiProcessPreset_TargetRealtime_Quality);
if(!m_scene)return false;
get_bounding_box(m_scene, &m_min,&m_max);
m_center.x=(m_min.x+m_max.x)/2.f;
m_center.y=(m_min.y+m_max.y)/2.f;
m_center.z=(m_min.z+m_max.z)/2.f;
/* default is to rescale the object */
float tmp;
tmp = m_max.x-m_min.x;
tmp = aisgl_max(m_max.y - m_min.y,tmp);
tmp = aisgl_max(m_max.z - m_min.z,tmp);
m_scale = 2.f / tmp;
m_offset.x=-m_center.x;
m_offset.y=-m_center.y;
m_offset.z=-m_center.z;
gem::Properties props=requestprops;
setProperties(props);
m_rebuild=true;
return true;
}
bool modelASSIMP2 :: render(void) {
if(m_rebuild || 0==m_dispList)
compile();
if(m_dispList) {
glPushMatrix();
// scale the model
glScalef(m_scale, m_scale, m_scale);
// center the model
glTranslatef( m_offset.x, m_offset.y, m_offset.z );
glCallList(m_dispList);
glPopMatrix();
}
return (!m_dispList);
}
void modelASSIMP2 :: close(void) {
destroy();
}
bool modelASSIMP2 :: enumProperties(gem::Properties&readable,
gem::Properties&writeable) {
readable.clear();
writeable.clear();
return false;
}
void modelASSIMP2 :: setProperties(gem::Properties&props) {
double d;
#if 0
std::vector<std::string>keys=props.keys();
unsigned int i;
for(i=0; i<keys.size(); i++) {
post("key[%d]=%s ... %d", i, keys[i].c_str(), props.type(keys[i]));
}
#endif
if(props.get("rescale", d)) {
bool b=(bool)d;
if(b) {
float tmp;
tmp = m_max.x-m_min.x;
tmp = aisgl_max(m_max.y - m_min.y,tmp);
tmp = aisgl_max(m_max.z - m_min.z,tmp);
m_scale = 2.f / tmp;
m_offset.x=-m_center.x;
m_offset.y=-m_center.y;
m_offset.z=-m_center.z;
} else {
m_scale=1.;
m_offset.x=m_offset.y=m_offset.z=0.f;
}
}
if(props.get("usematerials", d)) {
bool useMaterial=d;
if(useMaterial!=m_useMaterial)
m_rebuild=true;
m_useMaterial=useMaterial;
}
}
void modelASSIMP2 :: getProperties(gem::Properties&props) {
}
bool modelASSIMP2 :: compile(void) {
if(!m_scene) return false;
if(!(GLEW_VERSION_1_1)) {
// verbose(1, "cannot build display-list now...do you have a window?");
return false;
}
if (m_dispList) {
glDeleteLists(m_dispList, 1);
m_dispList=0;
}
m_dispList=glGenLists(1);
if(m_dispList) {
GLboolean useColorMaterial=GL_FALSE;
glGetBooleanv(GL_COLOR_MATERIAL, &useColorMaterial);
glNewList(m_dispList, GL_COMPILE);
glDisable(GL_COLOR_MATERIAL);
// now begin at the root node of the imported data and traverse
// the scenegraph by multiplying subsequent local transforms
// together on GL's matrix stack.
recursive_render(m_scene, m_scene, m_scene->mRootNode, m_useMaterial);
if(useColorMaterial)
glEnable(GL_COLOR_MATERIAL);
glEndList();
}
bool res = (0 != m_dispList);
if(res) m_rebuild=false;
return res;
}
void modelASSIMP2 :: destroy(void) {
/* LATER: check valid contexts (remove glDelete from here) */
if (m_dispList) {
// destroy display list
glDeleteLists(m_dispList, 1);
m_dispList = 0;
}
if(m_scene)
aiReleaseImport(m_scene);
m_scene=NULL;
}
#endif

View file

@ -0,0 +1,78 @@
/* -----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load an asset (like .obj oder .dxf)
Copyright (c) 2001-2012 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE__GEMPLUGIN__MODELASSIMP2_MODELASSIMP2_H_
#define _INCLUDE__GEMPLUGIN__MODELASSIMP2_MODELASSIMP2_H_
#include "plugins/modelloader.h"
#include "assimp.h"
#include "aiPostProcess.h"
#include "aiScene.h"
#include "Gem/GemGL.h"
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
modelASSIMP2
loads an Alias WaveFront .obj file as an asset
KEYWORDS
asset model
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT modelASSIMP2 : public gem::plugins::modelloader {
public:
/////////
// ctor/dtor
modelASSIMP2(void);
virtual ~modelASSIMP2(void);
virtual bool isThreadable(void) { return true; }
//////////
// open/close an asset
virtual bool open(const std::string&, const gem::Properties&);
virtual void close(void);
//////////
// render the asset
virtual bool render(void);
virtual bool compile(void);
//////////
// property handling
virtual bool enumProperties(gem::Properties&, gem::Properties&);
virtual void setProperties(gem::Properties&);
virtual void getProperties(gem::Properties&);
protected:
virtual void destroy(void);
bool m_rebuild;
const aiScene *m_scene;
GLint m_dispList;
float m_scale;
struct aiVector3D m_offset;
struct aiVector3D m_min, m_max, m_center;
bool m_useMaterial;
};
};}; // namespace gem::plugins
#endif // for header file

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modelASSIMP2", "modelASSIMP2.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="modelASSIMP2"
ProjectGUID="{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
RootNamespace="gem"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;;&quot;$(ProjectDir)\..\..\..\GemLibs\assimp--2.0.863\include&quot;"
PreprocessorDefinitions="HAVE_LIBASSIMP2;HAVE_ASSIMP_H;NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="Gem.lib Assimp32.lib pd.lib opengl32.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;;&quot;$(ProjectDir)\..\..\..\GemLibs\assimp--2.0.863\lib&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
OutputDirectory="$(SolutionDir)"
IntermediateDirectory="$(ProjectDir)/$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\src&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\src&quot;;&quot;$(ProgramFiles)\pd\src&quot;"
PreprocessorDefinitions="NT;WIN32;_WINDOWS;__WIN32__;_LANGUAGE_C_PLUS_PLUS;WIN32_LEAN_AND_MEAN"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="0"
DefaultCharIsUnsigned="FALSE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="OLDNAMES.lib Gem.lib pd.lib"
OutputFile="$(OutDir)/gem_$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)&quot;;&quot;$(ProjectDir)\..\..\build\win-vs2003&quot;;&quot;$(ProjectDir)\..\..\..\..\pd\bin&quot;;&quot;$(ProgramFiles)\pd\bin&quot;"
ProgramDatabaseFile="$(ProjectDir)/$(ProjectName).pdb"
ImportLibrary="$(ProjectDir)/$(TargetName).lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\modelASSIMP2.cpp">
</File>
<File
RelativePath="..\modelASSIMP2.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="ASSIMP2"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="$(ProjectDir)\..\..\..\..\assimp--2.0.863-sdk\include"
PreprocessorDefinitions="HAVE_LIBASSIMP;HAVE_ASSIMP_H"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="assimp.lib"
AdditionalLibraryDirectories="$(ProjectDir)\..\..\..\..\assimp--2.0.863-sdk\lib\assimp_release-dll_win32"
/>
</VisualStudioPropertySheet>

View file

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modelASSIMP2", "modelASSIMP2.vcproj", "{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Release = Release
ReleaseDummy = ReleaseDummy
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.ActiveCfg = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.Release.Build.0 = Release|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.ActiveCfg = ReleaseDummy|Win32
{FF21A158-2BDE-483F-85C3-80C9DF0A0ABC}.ReleaseDummy.Build.0 = ReleaseDummy|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,172 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="modelASSIMP2"
ProjectGUID="{32A8EA41-EC6E-4F4D-9A82-8B2175F549A2}"
RootNamespace="gem"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops;.\ASSIMP2.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="opengl32.lib"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="ReleaseDummy|Win32"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\..\..\build\win-vs2008\plugin.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\./gem.tlb"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\modelASSIMP2.cpp"
>
</File>
<File
RelativePath="..\modelASSIMP2.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,42 @@
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CPPFLAGS = -I$(top_srcdir)/src @GEM_EXTERNAL_CPPFLAGS@
EXTRA_DIST =
EXTRA_DIST += win-vs2003/modelOBJ.sln win-vs2003/modelOBJ.vcproj
EXTRA_DIST += win-vs2008/modelOBJ.sln win-vs2008/modelOBJ.vcproj
pkglib_LTLIBRARIES= gem_modelOBJ.la
gem_modelOBJ_la_CXXFLAGS =
gem_modelOBJ_la_LDFLAGS = -module -avoid-version -shared
if WINDOWS
gem_modelOBJ_la_LDFLAGS += -no-undefined
endif
gem_modelOBJ_la_LIBADD =
# RTE
gem_modelOBJ_la_CXXFLAGS += @GEM_RTE_CFLAGS@ @GEM_ARCH_CXXFLAGS@
gem_modelOBJ_la_LDFLAGS += @GEM_RTE_LIBS@ @GEM_ARCH_LDFLAGS@
# flags for building Gem externals
gem_modelOBJ_la_CXXFLAGS += @GEM_EXTERNAL_CFLAGS@
gem_modelOBJ_la_LIBADD += -L$(top_builddir) @GEM_EXTERNAL_LIBS@
# gem_modelOBJ_la @MOREFLAGS@
# Dependencies
gem_modelOBJ_la_CXXFLAGS += @GL_CFLAGS@
gem_modelOBJ_la_LIBADD += @GL_LIBS@
# convenience symlinks
include $(srcdir)/../symlink_ltlib.mk
### SOURCES
gem_modelOBJ_la_SOURCES= \
modelOBJ.cpp \
modelOBJ.h \
model_loader.cpp \
model_loader.h

View file

@ -0,0 +1,193 @@
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// zmoelnig@iem.kug.ac.at
//
// Implementation file
//
// Copyright (c) 2001-2012 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////
#include "modelOBJ.h"
#include "plugins/PluginFactory.h"
#include "Gem/RTE.h"
#include "Gem/Exception.h"
#include "Gem/Properties.h"
#include <string>
using namespace gem::plugins;
REGISTER_MODELLOADERFACTORY("OBJ", modelOBJ);
modelOBJ :: modelOBJ(void) :
m_model(NULL), m_dispList(0),
m_material(0),
m_flags(GLM_SMOOTH | GLM_TEXTURE),
m_group(0),
m_rebuild(false),
m_currentH(1.f), m_currentW(1.f),
m_textype(GLM_TEX_DEFAULT),
m_reverse(false)
{
}
modelOBJ ::~modelOBJ(void) {
destroy();
}
bool modelOBJ :: open(const std::string&name, const gem::Properties&requestprops) {
destroy();
#if 0
std::vector<std::string>keys=requestprops.keys();
unsigned int i;
for(i=0; i<keys.size(); i++) {
post("key[%d]=%s", i, keys[i].c_str());
}
#endif
m_model = glmReadOBJ(name.c_str());
if (!m_model){
return false;
}
m_reverse=false;
double d=1;
requestprops.get("rescale", d);
if(d)glmUnitize(m_model);
glmFacetNormals (m_model);
gem::Properties props=requestprops;
if(gem::Properties::UNSET==requestprops.type("smooth")) {
props.set("smooth", 0.5);
}
setProperties(props);
glmTexture(m_model, m_textype, 1,1);
m_rebuild=true;
return true;
}
bool modelOBJ :: render(void) {
if(m_rebuild) {
glmTexture(m_model, m_textype, 1,1);
compile();
}
if(m_dispList)
glCallList(m_dispList);
return (0!=m_dispList);
}
void modelOBJ :: close(void) {
destroy();
}
bool modelOBJ :: enumProperties(gem::Properties&readable,
gem::Properties&writeable) {
readable.clear();
writeable.clear();
return false;
}
void modelOBJ :: setProperties(gem::Properties&props) {
double d;
if(props.get("smooth", d)) {
if(d<0.)d=0.;
if(d>1.)d=1.;
if(m_model)
glmVertexNormals(m_model, d*180.);
m_rebuild=true;
}
if(props.get("texwidth", d)) {
if(d!=m_currentW)
m_rebuild=true;
m_currentW=d;
}
if(props.get("texheight", d)) {
if(d!=m_currentH)
m_rebuild=true;
m_currentH=d;
}
if(props.get("usematerials", d)) {
int flags=GLM_SMOOTH | GLM_TEXTURE;
if(d)
flags |= GLM_MATERIAL;
if(flags!=m_flags)
m_rebuild=true;
m_flags=flags;
}
std::string s;
if(props.get("textype", s)) {
if("UV"==s)
m_textype= GLM_TEX_UV;
else if("linear"==s)
m_textype= GLM_TEX_LINEAR;
else if("spheremap"==s)
m_textype= GLM_TEX_SPHEREMAP;
m_rebuild=true;
}
if(props.get("group", d)) {
m_group=d;
m_rebuild=true;
}
if(props.get("reverse", d)) {
// LATER:move this to compile()
bool reverse=d;
if((reverse!=m_reverse) && m_model) {
glmReverseWinding(m_model);
m_rebuild=true;
}
m_reverse=reverse;
}
}
void modelOBJ :: getProperties(gem::Properties&props) {
props.clear();
}
bool modelOBJ :: compile(void) {
if(!m_model) return false;
if(!(GLEW_VERSION_1_1)) {
// verbose(1, "cannot build display-list now...do you have a window?");
return false;
}
if (m_dispList) {
glDeleteLists(m_dispList, 1);
m_dispList=0;
}
if (!m_group){
m_dispList = glmList(m_model, m_flags);
} else {
m_dispList = glmListGroup(m_model, m_flags, m_group);
}
bool res = (0 != m_dispList);
if(res) m_rebuild=false;
return res;
}
void modelOBJ :: destroy(void) {
/* LATER: check valid contexts (remove glDelete from here) */
if (m_dispList) {
// destroy display list
glDeleteLists(m_dispList, 1);
m_dispList = 0;
}
if(m_model) {
glmDelete(m_model);
m_model=NULL;
}
}

View file

@ -0,0 +1,73 @@
/* -----------------------------------------------------------------
GEM - Graphics Environment for Multimedia
Load an asset (like .obj oder .dxf)
Copyright (c) 2001-2012 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
-----------------------------------------------------------------*/
#ifndef _INCLUDE__GEMPLUGIN__MODELOBJ_MODELOBJ_H_
#define _INCLUDE__GEMPLUGIN__MODELOBJ_MODELOBJ_H_
#include "plugins/modelloader.h"
#include "model_loader.h"
/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
modelOBJ
loads an Alias WaveFront .obj file as an asset
KEYWORDS
asset model
-----------------------------------------------------------------*/
namespace gem { namespace plugins {
class GEM_EXPORT modelOBJ : public gem::plugins::modelloader {
public:
/////////
// ctor/dtor
modelOBJ(void);
virtual ~modelOBJ(void);
virtual bool isThreadable(void) { return true; }
//////////
// open/close an asset
virtual bool open(const std::string&, const gem::Properties&);
virtual void close(void);
//////////
// render the asset
virtual bool render(void);
virtual bool compile(void);
//////////
// property handling
virtual bool enumProperties(gem::Properties&, gem::Properties&);
virtual void setProperties(gem::Properties&);
virtual void getProperties(gem::Properties&);
protected:
virtual void destroy(void);
bool m_rebuild;
GLMmodel *m_model;
GLint m_dispList;
int m_material;
int m_flags;
int m_group;
float m_currentH, m_currentW;
glmtexture_t m_textype;
bool m_reverse;
};
};}; // namespace gem::plugins
#endif // for header file

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more