Commit e13a191a authored by IOhannes m zmölnig's avatar IOhannes m zmölnig
Browse files

removed long deprecated objects

parent 976a12d9
#N canvas 306 199 651 488 10;
#X obj 14 204 gemhead;
#X msg 221 66 open 0;
#X msg 221 41 enumerate;
#X msg 221 92 close;
#X obj 14 401 pix_texture;
#X obj 14 431 rectangle 4 3;
#X obj 220 18 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X msg 224 158 dialog format;
#X msg 224 182 dialog crossbar;
#X msg 224 205 dialog source;
#X msg 224 228 dialog display;
#X msg 224 265 dv res full;
#X msg 224 288 dv res half;
#X msg 225 311 dv res quarter;
#X msg 224 335 dv res dc;
#X text 309 13 enable/disable;
#X text 308 40 list available devices;
#X text 310 67 open device N;
#X text 311 96 close the device;
#X text 354 158 display format dialog;
#X text 356 133 display all configuration dialogs;
#X text 354 182 display crossbar dialog;
#X text 355 208 display source dialog;
#X text 355 231 display display dialog;
#X text 356 267 (DV only) set decode res to full;
#X text 356 288 (DV only) set decode res to half;
#X text 356 310 (DV only) set decode res to quarter;
#X text 355 335 (DV only) set decode res to dc;
#X text 12 -13 pix_videoDS;
#X text 127 -13 Live video capture using DirectShow (Windows only)
;
#X msg 224 132 dialog;
#X obj 21 116 gemwin;
#X msg 21 35 create;
#X obj 123 66 tgl 30 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1
;
#X msg 37 68 destroy;
#X msg 225 393 colorspace \$1;
#X symbolatom 225 373 6 0 0 0 - - -;
#X text 283 372 RGBA|YUV|Grey;
#X obj 14 371 pix_video;
#X connect 0 0 38 0;
#X connect 1 0 38 0;
#X connect 2 0 38 0;
#X connect 3 0 38 0;
#X connect 4 0 5 0;
#X connect 6 0 38 0;
#X connect 7 0 38 0;
#X connect 8 0 38 0;
#X connect 9 0 38 0;
#X connect 10 0 38 0;
#X connect 11 0 38 0;
#X connect 12 0 38 0;
#X connect 13 0 38 0;
#X connect 14 0 38 0;
#X connect 30 0 38 0;
#X connect 32 0 31 0;
#X connect 33 0 31 0;
#X connect 34 0 31 0;
#X connect 35 0 38 0;
#X connect 36 0 35 0;
#X connect 38 0 4 0;
......@@ -234,26 +234,5 @@ libPixes_la_SOURCES= \
pix_zoom.cpp \
pix_zoom.h
# deprecated stuff
EXTRA_DIST = \
pix_filmOS.cpp \
pix_filmOS.h \
pix_filmDarwin.cpp \
pix_filmDarwin.h \
pix_movieOS.cpp \
pix_movieOS.h \
pix_movieDarwin.cpp \
pix_movieDarwin.h \
pix_movieDS.cpp \
pix_movieDS.h \
pix_videoDarwin.cpp \
pix_videoDarwin.h \
pix_videoOS.cpp \
pix_videoOS.h \
pix_recordQT.cpp \
pix_recordQT.h
CHECKUNUSED_IGNORE=$(EXTRA_DIST)
////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// tigital@mac.com
//
// Implementation file
//
// Copyright (c) 1997-1999 Mark Danks.
// 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.
//
/////////////////////////////////////////////////////////
#include "Gem/GemConfig.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
#if !defined HAVE_CARBONQUICKTIME && defined GEM_FILMBACKEND && GEM_FILMBACKEND == GEM_FILMBACKEND_Darwin
# undef GEM_FILMBACKEND
#endif
#if defined GEM_FILMBACKEND && GEM_FILMBACKEND == GEM_FILMBACKEND_Darwin
#define HELPSYMBOL "pix_film"
#include "pix_filmDarwin.h"
CPPEXTERN_NEW_WITH_ONE_ARG(pix_filmDarwin, t_symbol *, A_DEFSYM);
/////////////////////////////////////////////////////////
//
// pix_filmDarwin
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
pix_filmDarwin :: pix_filmDarwin(t_symbol *filename) :
pix_filmOS(filename),
m_srcGWorld(NULL),
m_hiquality(1),
m_play(0),
m_rate(1.0),
prevTime(0), curTime(0),
m_Task(0),
m_volume(0.f),
m_movie(NULL)
{
m_colorspace = GEM_YUV;
// make sure that there are some characters
if (filename && filename->s_name && filename->s_name[0]) {
openMess(filename);
}
}
////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
pix_filmDarwin :: ~pix_filmDarwin()
{
closeMess();
deleteBuffer();
outlet_free(m_outNumFrames);
outlet_free(m_outEnd);
}
void pix_filmDarwin :: closeMess(void)
{
switch (m_haveMovie) {
case GEM_MOVIE_MOV:
case GEM_MOVIE_AVI:
case GEM_MOVIE_MPG:
::DisposeMovie(m_movie);
::DisposeGWorld(m_srcGWorld);
m_srcGWorld = NULL;
m_haveMovie = GEM_MOVIE_NONE;
break;
case GEM_MOVIE_NONE:
default:
break;
}
}
/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
void pix_filmDarwin :: realOpen(char *filename)
{
FSSpec theFSSpec;
OSErr err = noErr;
FSRef ref;
Track movieTrack, audioTrack;
Media trackMedia;
long sampleCount;
long m_rowBytes;
MatrixRecord matrix;
if (!filename[0]) {
error("no filename passed");
} else {
UInt8*filename8=reinterpret_cast<UInt8*>(filename);
err = ::FSPathMakeRef(filename8, &ref, NULL);
err = ::FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, &theFSSpec,
NULL);
if (err) {
error("unable to find file: %s", filename);
return;
}
m_haveMovie = GEM_MOVIE_MOV;
}
short refnum = 0;
err = ::OpenMovieFile(&theFSSpec, &refnum, fsRdPerm);
if (err) {
error("couldn't open the movie file: %#s (%d)", theFSSpec.name, err);
if (refnum) {
::CloseMovieFile(refnum);
}
return;
}
::NewMovieFromFile(&m_movie, refnum, NULL, NULL, newMovieActive, NULL);
if (refnum) {
::CloseMovieFile(refnum);
}
m_reqFrame = 0;
m_curFrame = -1;
m_numTracks = static_cast<int>(GetMovieTrackCount(m_movie));
movieTrack = GetMovieIndTrackType(m_movie,1,VideoMediaType,
movieTrackMediaType); //get first video track
trackMedia = GetTrackMedia(movieTrack);
sampleCount = GetMediaSampleCount(trackMedia);
m_numFrames = sampleCount;
audioTrack = GetMovieIndTrackType(m_movie,1,SoundMediaType,
movieTrackMediaType);
SetTrackEnabled(audioTrack, FALSE);
// Get the length of the movie
movieDur = static_cast<long>(GetMovieDuration(m_movie));
movieScale = static_cast<long>(GetMovieTimeScale(m_movie));
durationf = static_cast<double>(movieDur)/static_cast<double>(m_numFrames);
// 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_xsize = m_srcRect.right - m_srcRect.left;
m_ysize = m_srcRect.bottom - m_srcRect.top;
//long index;
//special code for trapping HD formats which have pixel dimensions which are different from what QT reports
//this is undocumented anywhere by Apple - thanks to Marc Van Olmen for helping sort this out
ImageDescriptionHandle desc = NULL;
desc = reinterpret_cast<ImageDescriptionHandle>(NewHandle(0));
GetMediaSampleDescription(trackMedia,1,
reinterpret_cast<SampleDescriptionHandle>(desc));
# ifdef kDVCPROHD720pCodecType
//DVCPRO720p
if ((*desc)->cType == kDVCPROHD720pCodecType) {
post("kDVCPROHD720pCodecType");
m_xsize = 960;
SetRect( &m_srcRect, 0, 0, m_xsize, m_ysize );
SetMovieBox(m_movie, &m_srcRect);
ScaleMatrix(&matrix,FloatToFixed(0.75),FloatToFixed(1.),FloatToFixed(1.),
FloatToFixed(1.));
SetMovieMatrix(m_movie,&matrix);
}
//DVCPRO 1080i60
if ((*desc)->cType == kDVCPROHD1080i60CodecType) {
post("kDVCPROHD1080i60CodecType");
m_hiquality = 0;
m_xsize = 1280;
SetRect( &m_srcRect, 0, 0, m_xsize, m_ysize );
ScaleMatrix(&matrix,FloatToFixed(2.f/3.f),FloatToFixed(1.),
FloatToFixed(1.),FloatToFixed(1.));
SetMovieBox(m_movie, &m_srcRect);
SetMovieMatrix(m_movie,&matrix);
}
# endif
//DVCPRO 1080i
//HDV
//post("image description width %d heigh %d hRes %d vRes %d",(*desc)->width,(*desc)->height,Fix2Long((*desc)->hRes),Fix2Long((*desc)->vRes));
// We will use a YUV GWorld/Texture to get the fastest performance
// 16 bits per pixel for 4:2:2
// RowBytes should be a multiple of 32 for GL_STORAGE_SHARED_APPLE to work
// This means movie width for 16bits need to be a multiple of 16
// (and for rgba/32bits width needs to be a multiple of 32)
// we pad out to that. The texture coords ensure we do not use the extra bytes.
int bpp;
if (m_colorspace == GEM_RGBA) {
bpp = 32;
} else {
bpp = 16;
}
UInt32 thePadOffset = m_xsize % bpp;
if( thePadOffset != 0 ) {
m_xsize += (bpp - thePadOffset);
SetRect( &m_srcRect, 0, 0, m_xsize, m_ysize );
}
if (m_colorspace == GEM_RGBA) {
m_format = GEM_RGBA;
createBuffer();
prepareTexture();
m_rowBytes = m_xsize * 4;
if (m_hiquality) {
SetMoviePlayHints(m_movie, hintsHighQuality, hintsHighQuality);
}
err = QTNewGWorldFromPtr( &m_srcGWorld,
k32ARGBPixelFormat, // gives noErr
&m_srcRect,
NULL,
NULL,
0,
m_pixBlock.image.data,
m_rowBytes);
} else {
m_format=GEM_YUV;
createBuffer();
// prepareTexture();
m_rowBytes = m_xsize * 2;
if (m_hiquality) {
SetMoviePlayHints(m_movie, hintsHighQuality | hintsDeinterlaceFields,
hintsHighQuality | hintsDeinterlaceFields);
}
err = QTNewGWorldFromPtr( &m_srcGWorld,
k422YpCbCr8CodecType,
&m_srcRect,
NULL,
NULL,
0,
m_pixBlock.image.data,
m_rowBytes);
}
if (err) {
error("couldn't make QTNewGWorldFromPtr %d", err);
m_haveMovie = 0;
return;
}
/* movies task method */
m_movieTime = GetMovieTime(m_movie,nil);
playRate = GetMoviePreferredRate(m_movie);
// *** set the graphics world for displaying the movie ***
::SetMovieGWorld(m_movie, m_srcGWorld, GetGWorldDevice(m_srcGWorld));
if (m_auto) {
SetMovieRate(m_movie,X2Fix(1.0));
m_play = 1;
} else {
SetMovieRate(m_movie,X2Fix(0.0));
}
SetMovieVolume(m_movie,FloatToFixed(m_volume));
::MoviesTask(m_movie,
0); // *** this does the actual drawing into the GWorld ***
curTime = GetMovieTime(m_movie,NULL);
prevTime = 0;
newImage = 1;
}
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
void pix_filmDarwin :: getFrame()
{
short flags = nextTimeStep;
OSType whichMediaType = VisualMediaCharacteristic;
if (!m_haveMovie) {
return;
}
m_Task = 0;
if (m_curFrame >= m_numFrames) {
m_curFrame = 0;
}
// ***********************************
//
//what follows is some of the worst hack work i've ever done to get QT to 'work'
//
//the problem is that QT is very good a playing media if it manages everything itself internally.
//however, that doesn't fit well with GEM because GEM has it's own internal tasking callbacks, so
//in order to get the two to play nice, a bunch of ugly, shit code has to be done. below is a way to
//track the internal state of QT MoviesTask() and figure out which frame it is currently processing.
//this avoids the frame being processed twice by the GEM render chain by managing the newImage flag
//
//note all of the crap to check for the direction of the playback and loop points.
//
// THERE MUST BE A BETTER WAY!!!!!!!!!!!!!!
//
// ************************************
if (m_auto) {
//play the startmovie() way
if (!m_play) {
SetMovieRate(m_movie,X2Fix(m_rate));
m_play = 1;
newImage = 0;
return;
// post("curTime %d prevTime %d",curTime,prevTime);
// SetMovieVolume(m_movie, kFullVolume);
}
if (m_rate > 0.f) {
if (IsMovieDone(m_movie)) {
outlet_bang(m_outEnd);
GoToBeginningOfMovie(m_movie);
prevTime = 0;
flags |= nextTimeEdgeOK;
m_reqFrame = 0;
}
m_Task = 1;
MoviesTask(m_movie,
0); // *** this does the actual drawing into the GWorld ***
curTime = GetMovieTime(m_movie,NULL);
//check to see if the current position is past our next frame
if (prevTime < curTime) {
//if (prevTime != curTime){
newImage = 1;
prevTime = curTime;
//find next frame bounds using GetMovieNextIntertestingTime()
GetMovieNextInterestingTime(m_movie,
flags,
1,
&whichMediaType,
curTime,
0,
&prevTime,
// NULL,
nil);
} else {
//if it's still the same frame then don't process
newImage = 0;
}
} else {
if (GetMovieTime(m_movie,nil) <= 0) {
GoToEndOfMovie(m_movie);
prevTime = GetMovieTime(m_movie,NULL);
curTime = prevTime;
// get the frame prior to the last frame
GetMovieNextInterestingTime(m_movie,
flags,
1,
&whichMediaType,
prevTime,
-1,
&prevTime,
NULL);
} else {
m_Task = 1;
MoviesTask(m_movie,
0); // *** this does the actual drawing into the GWorld ***
curTime = GetMovieTime(m_movie,NULL);
if (prevTime >= curTime) {
newImage = 1;
prevTime = curTime;
//find next frame bounds using GetMovieNextIntertestingTime()
GetMovieNextInterestingTime(m_movie,
flags,
1,
&whichMediaType,
prevTime,
-1,
&prevTime,
NULL);
} else {
newImage = 0;
}
}
}
if (m_newFilm) {
newImage = 1;
MoviesTask(m_movie,
0); // *** this does the actual drawing into the GWorld ***
// curTime = GetMovieTime(m_movie,NULL);
}
} else {
//play the manual way
if (m_play) {
SetMovieRate(m_movie,X2Fix(0.0));
m_play = 0; //turn off play
newImage = 0;
m_movieTime = GetMovieTime(m_movie,NULL);
// SetMovieVolume(m_movie, kNoVolume);
return; //not sure about this
} else {
m_movieTime = m_reqFrame * duration;
m_movieTime = static_cast<long>(static_cast<double>(m_reqFrame) *
durationf);
m_movieTime-=9; //total hack!! subtract an arbitrary amount and have nextinterestingtime find the exact place
::GetMovieNextInterestingTime( m_movie,
flags,
1,
&whichMediaType,
m_movieTime,
0,
&m_movieTime,
NULL);
}
SetMovieTimeValue(m_movie, m_movieTime);
m_Task = 1;
newImage = 1;
MoviesTask(m_movie, 0);
curTime = GetMovieTime(m_movie,NULL);
}
//I suppose if you roll your own YUV->ARGB it would go here?
}
void pix_filmDarwin :: postrender(GemState *state)
{
}
void pix_filmDarwin :: startRendering()
{
//bit of a hack related to stopRendering()
if (m_auto && m_haveMovie) {
SetMovieVolume(m_movie, static_cast<short>(m_volume * 255.f));
}
}
void pix_filmDarwin :: stopRendering()
{
//bit of a hack to keep the sound from playing after rendering stops
if (m_auto && m_haveMovie) {
SetMovieVolume(m_movie, kNoVolume);
}
}
void pix_filmDarwin :: LoadRam()
{
TimeValue length;
OSErr err;
if (m_haveMovie) {
m_movieTime = 0;
length = GetMovieDuration(m_movie);
err = LoadMovieIntoRam(m_movie,m_movieTime,length,keepInRam);
if (err) {
error("LoadMovieIntoRam failed miserably");
}
} else {
error("no movie to load into RAM!");
}
}
void pix_filmDarwin :: MovRate(float rate)
{
m_rate = static_cast<float>(rate);
if (m_auto && m_haveMovie) {
SetMovieRate(m_movie,X2Fix(static_cast<double>(m_rate)));
}
}
void pix_filmDarwin :: MovVolume(float volume)
{
m_volume = static_cast<float>(volume);
if (m_auto && m_haveMovie) {
SetMovieVolume(m_movie,static_cast<short>(m_volume * 255.f));
}
}
void pix_filmDarwin :: doDebug()
{
post("---------- pix_filmDarwin doDebug start----------");
post("m_numTracks = %d",m_numTracks);
post("Movie duration = %d timescale = %d timebase = %d", movieDur,