Skip to content

Commit 341b358

Browse files
author
cclepper
committed
fixed looooong first frame bug. added detection for colorspace and image flipping.
git-svn-id: https://pd-gem.svn.sourceforge.net/svnroot/pd-gem/trunk/Gem@2099 49b2a0ca-c541-4d49-a7ef-d785e4371512
1 parent 64c7f9c commit 341b358

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

src/Pixes/recordQT.cpp

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# include <sys/types.h>
1010
# include <unistd.h>
1111
# include <fcntl.h>
12+
#include "m_pd.h"
1213
#endif
1314
#ifdef __WIN32__
1415
# define snprintf _snprintf
@@ -38,6 +39,8 @@ recordQT :: recordQT(int x, int y, int w, int h)
3839
{
3940
m_filename[0] = 0;
4041

42+
post("using recordQT");
43+
4144
# ifdef __WIN32__
4245
// Initialize QuickTime Media Layer
4346
OSErr err = noErr;
@@ -95,6 +98,9 @@ recordQT :: recordQT(int x, int y, int w, int h)
9598
m_dialog = 0;
9699
m_currentFrame = 0;
97100

101+
m_firstRun = 1;
102+
103+
m_ticks = 20;
98104

99105
// post("recordQT : anyCodec %d bestSpeedCodec %d bestFidelityCodec %d bestCompressionCodec %d",anyCodec,bestSpeedCodec,bestFidelityCodec,bestCompressionCodec);
100106
stdComponent = OpenDefaultComponent(StandardCompressionType,StandardCompressionSubType);
@@ -129,6 +135,7 @@ void recordQT :: setupQT() //this only needs to be done when codec info changes
129135
FSSpec theFSSpec;
130136
OSErr err = noErr;
131137
FSRef ref;
138+
OSType colorspace;
132139

133140
ComponentResult compErr = noErr;
134141

@@ -219,12 +226,25 @@ void recordQT :: setupQT() //this only needs to be done when codec info changes
219226
m_srcRect.bottom = m_height;
220227
m_srcRect.right = m_width;
221228

229+
230+
if (m_compressImage->format == GL_YUV422_GEM){
231+
m_rowBytes = m_width * 2;
232+
colorspace = k422YpCbCr8CodecType;
233+
post("recordQT: using YUV");
234+
}
235+
if (m_compressImage->format == GL_BGRA){
236+
colorspace = k32BGRAPixelFormat;// k32RGBAPixelFormat;
237+
m_rowBytes = m_width * 4;
238+
post("recordQT: using BGRA");
239+
}
240+
222241
#ifdef __APPLE__
223242
//give QT the length of each pixel row in bytes (2 for 4:2:2 YUV)
224-
m_rowBytes = m_width * 2;
243+
225244
//m_srcGWorld = NULL;//probably a memory leak
226245
err = QTNewGWorldFromPtr(&m_srcGWorld,
227-
k422YpCbCr8CodecType,
246+
colorspace,
247+
// k422YpCbCr8CodecType,
228248
//k32ARGBPixelFormat,
229249
&m_srcRect,
230250
NULL,
@@ -257,6 +277,21 @@ void recordQT :: setupQT() //this only needs to be done when codec info changes
257277

258278
SetMovieGWorld(m_movie,m_srcGWorld,GetGWorldDevice(m_srcGWorld));
259279

280+
#ifdef __APPLE__
281+
//there is a discrepency between what is really upside down and not.
282+
//since QT has flipped Y compared to GL it is upside down to GL but not to itself
283+
//so while the upsidedown flag is set for QT images sent to GL it is not correct for pix_ processing.
284+
//this is a hack on OSX since the native is YUV for pix_ and the only BGRA will usually be from pix_snap
285+
if (m_compressImage->upsidedown && m_compressImage->format == GL_BGRA) {
286+
MatrixRecord aMatrix;
287+
GetMovieMatrix(m_movie,&aMatrix);
288+
post("upside down");
289+
ScaleMatrix(&aMatrix,Long2Fix(1),Long2Fix(-1),0,0);
290+
SetMovieMatrix(m_movie,&aMatrix);
291+
}
292+
293+
#endif
294+
260295
#ifdef __WIN32__
261296
MatrixRecord aMatrix;
262297
GetMovieMatrix(m_movie,&aMatrix);
@@ -517,7 +552,7 @@ void recordQT :: compressFrame()
517552
compressedData,
518553
0,
519554
dataSize,
520-
20, //this should not be a fixed value but vary with framerate
555+
m_ticks, //this should not be a fixed value but vary with framerate
521556
(SampleDescriptionHandle)hImageDesc,
522557
1,
523558
syncFlag,

0 commit comments

Comments
 (0)