|
9 | 9 | # include <sys/types.h>
|
10 | 10 | # include <unistd.h>
|
11 | 11 | # include <fcntl.h>
|
| 12 | +#include "m_pd.h" |
12 | 13 | #endif
|
13 | 14 | #ifdef __WIN32__
|
14 | 15 | # define snprintf _snprintf
|
@@ -38,6 +39,8 @@ recordQT :: recordQT(int x, int y, int w, int h)
|
38 | 39 | {
|
39 | 40 | m_filename[0] = 0;
|
40 | 41 |
|
| 42 | +post("using recordQT"); |
| 43 | + |
41 | 44 | # ifdef __WIN32__
|
42 | 45 | // Initialize QuickTime Media Layer
|
43 | 46 | OSErr err = noErr;
|
@@ -95,6 +98,9 @@ recordQT :: recordQT(int x, int y, int w, int h)
|
95 | 98 | m_dialog = 0;
|
96 | 99 | m_currentFrame = 0;
|
97 | 100 |
|
| 101 | + m_firstRun = 1; |
| 102 | + |
| 103 | + m_ticks = 20; |
98 | 104 |
|
99 | 105 | // post("recordQT : anyCodec %d bestSpeedCodec %d bestFidelityCodec %d bestCompressionCodec %d",anyCodec,bestSpeedCodec,bestFidelityCodec,bestCompressionCodec);
|
100 | 106 | stdComponent = OpenDefaultComponent(StandardCompressionType,StandardCompressionSubType);
|
@@ -129,6 +135,7 @@ void recordQT :: setupQT() //this only needs to be done when codec info changes
|
129 | 135 | FSSpec theFSSpec;
|
130 | 136 | OSErr err = noErr;
|
131 | 137 | FSRef ref;
|
| 138 | + OSType colorspace; |
132 | 139 |
|
133 | 140 | ComponentResult compErr = noErr;
|
134 | 141 |
|
@@ -219,12 +226,25 @@ void recordQT :: setupQT() //this only needs to be done when codec info changes
|
219 | 226 | m_srcRect.bottom = m_height;
|
220 | 227 | m_srcRect.right = m_width;
|
221 | 228 |
|
| 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 | + |
222 | 241 | #ifdef __APPLE__
|
223 | 242 | //give QT the length of each pixel row in bytes (2 for 4:2:2 YUV)
|
224 |
| - m_rowBytes = m_width * 2; |
| 243 | + |
225 | 244 | //m_srcGWorld = NULL;//probably a memory leak
|
226 | 245 | err = QTNewGWorldFromPtr(&m_srcGWorld,
|
227 |
| - k422YpCbCr8CodecType, |
| 246 | + colorspace, |
| 247 | + // k422YpCbCr8CodecType, |
228 | 248 | //k32ARGBPixelFormat,
|
229 | 249 | &m_srcRect,
|
230 | 250 | NULL,
|
@@ -257,6 +277,21 @@ void recordQT :: setupQT() //this only needs to be done when codec info changes
|
257 | 277 |
|
258 | 278 | SetMovieGWorld(m_movie,m_srcGWorld,GetGWorldDevice(m_srcGWorld));
|
259 | 279 |
|
| 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 | + |
260 | 295 | #ifdef __WIN32__
|
261 | 296 | MatrixRecord aMatrix;
|
262 | 297 | GetMovieMatrix(m_movie,&aMatrix);
|
@@ -517,7 +552,7 @@ void recordQT :: compressFrame()
|
517 | 552 | compressedData,
|
518 | 553 | 0,
|
519 | 554 | 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 |
521 | 556 | (SampleDescriptionHandle)hImageDesc,
|
522 | 557 | 1,
|
523 | 558 | syncFlag,
|
|
0 commit comments