0bcc51db84aa244fb4826d36de3719a0d772f622
[blender.git] / source / blender / quicktime / apple / quicktime_export.c
1 /**
2  * $Id$
3  *
4  * quicktime_export.c
5  *
6  * Code to create QuickTime Movies with Blender
7  *
8  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version. The Blender
13  * Foundation also sells licenses for use in proprietary software under
14  * the Blender License.  See http://www.blender.org/BL/ for information
15  * about this.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software Foundation,
24  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  *
26  *
27  * The Original Code is written by Rob Haarsma (phase)
28  *
29  * Contributor(s): Stefan Gartner (sgefant)
30  *
31  * ***** END GPL/BL DUAL LICENSE BLOCK *****
32  */
33 /*      
34 TODO:
35
36 -  fix saving of compressionsettings
37
38 This should be fixed because:
39
40 - currently only one quicktime codec is used for all scenes
41 - this single codecsetting gets only initialised from the codec dialog
42
43 - the codecsettings have to get stored in the blendfile for background
44   rendering. blender -b crashes when it wants to popup the qt codec dialog
45   to retrieve a valid codec.
46 (quicktime isnt initialised yet when blender -b requests a rendering codec)
47
48 Some references to store the codec settings are placed at the end of this file.
49
50 DONE:
51
52 *  structurize file & compression data
53
54 *  fix 23.98, 29.97, 59.94 framerates
55 *  fix framerate button
56 *  fix mac compatibility
57
58 *  fix fallthrough to codecselector  // buttons.c
59 *  fix playback qt movie             // playanim.c
60 *  fix setting fps thru blenderbutton as well as codec dialog
61
62 */
63
64 #ifdef WITH_QUICKTIME
65
66 #if defined(_WIN32) || defined(__APPLE__)
67
68 /************************************************************
69 *                                                           *
70 *    INCLUDE FILES                                          *
71 *                                                           *
72 *************************************************************/
73
74 #include "BKE_global.h"
75 #include "BKE_scene.h"
76 #include "BLI_blenlib.h"
77 #include "BLO_sys_types.h"
78 #include "IMB_imbuf.h"
79 #include "IMB_imbuf_types.h"
80 #include "MEM_guardedalloc.h"
81 #include "render.h"
82
83 #include "quicktime_export.h"
84
85 #ifdef _WIN32
86 #include <FixMath.h>
87 #include <QTML.h>
88 #include <TextUtils.h> 
89 #include <Movies.h>
90 #include <QuicktimeComponents.h>
91 #include <MoviesFormat.h>
92 #endif /* _WIN32 */
93
94 #ifdef __APPLE__
95 #undef NDEBUG
96 #include <QuickTime/Movies.h>
97 #include <QuickTime/QuicktimeComponents.h>
98 #include <fcntl.h> /* open() */
99 #include <unistd.h> /* close() */
100 #include <sys/stat.h> /* file permissions */
101 #endif /* __APPLE__ */
102
103
104 /************************************************************
105 *                                                           *
106 *    FUNCTION PROTOTYPES                                    *
107 *                                                           *
108 *************************************************************/
109
110 static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame);
111 static void QT_DoAddVideoSamplesToMedia (int frame);
112 static void QT_EndAddVideoSamplesToMedia (void);
113 static void QT_CreateMyVideoTrack (void);
114 static void QT_EndCreateMyVideoTrack (void);
115
116 static void check_renderbutton_framerate(void);
117
118 /************************************************************
119 *                                                           *
120 *    STRUCTS                                                *
121 *                                                           *
122 *************************************************************/
123
124 typedef struct _QuicktimeExport {
125
126         FSSpec          theSpec;
127         short           resRefNum;
128         short           resId;
129         short           movieResId;
130         Str255          qtfilename;
131
132         Media           theMedia;
133         Movie           theMovie;
134         Track           theTrack;
135
136         GWorldPtr       theGWorld;
137         PixMapHandle    thePixMap;
138
139         ImageDescription        **anImageDescription;
140         ImageSequence           anImageSequence;
141
142         ImBuf           *ibuf;  //for Qtime's Gworld
143         ImBuf           *ibuf2; //copy of renderdata, to be Y-flipped
144
145 } QuicktimeExport;
146
147 typedef struct _QuicktimeCodecDataExt {
148
149         ComponentInstance       theComponent;
150         SCTemporalSettings  gTemporalSettings;
151         SCSpatialSettings   gSpatialSettings;
152         SCDataRateSettings  aDataRateSetting;
153         TimeValue                       duration;
154         long                            kVideoTimeScale;
155
156 } QuicktimeCodecDataExt;
157
158 struct _QuicktimeExport *qte;
159 struct _QuicktimeCodecDataExt *qcdx;
160
161 /************************************************************
162 *                                                           *
163 *    VARIABLES                                              *
164 *                                                           *
165 *************************************************************/
166
167 #define kMyCreatorType  FOUR_CHAR_CODE('TVOD')
168 #define kPixelDepth     32      /* use 32-bit depth */
169 #define kTrackStart             0
170 #define kMediaStart             0
171
172 static int sframe;
173
174 int             have_qtcodec;
175 char    qtcdname[64];
176
177 /************************************************************
178 *                                                           *
179 *    CheckError(OSErr err, char *msg)                       *
180 *                                                           *
181 *    prints errors in console, doesnt interrupt Blender     *
182 *                                                           *
183 *************************************************************/
184
185 void CheckError(OSErr err, char *msg)
186 {
187         if(err != noErr) printf("%s: %d\n", msg, err);
188 }
189
190
191 /************************************************************
192 *                                                           *
193 *    QT_CreateMyVideoTrack()                                *
194 *    QT_EndCreateMyVideoTrack()                             *
195 *                                                           *
196 *    Creates/finishes a video track for the QuickTime movie *
197 *                                                           *
198 *************************************************************/
199
200 static void QT_CreateMyVideoTrack(void)
201 {
202         OSErr err = noErr;
203         Rect trackFrame;
204
205         trackFrame.top = 0;
206         trackFrame.left = 0;
207         trackFrame.bottom = R.recty;
208         trackFrame.right = R.rectx;
209         
210         qte->theTrack = NewMovieTrack (qte->theMovie, 
211                                                         FixRatio(trackFrame.right,1),
212                                                         FixRatio(trackFrame.bottom,1), 
213                                                         kNoVolume);
214         CheckError( GetMoviesError(), "NewMovieTrack error" );
215
216         qte->theMedia = NewTrackMedia (qte->theTrack,
217                                                         VideoMediaType,
218                                                         qcdx->kVideoTimeScale,
219                                                         nil,
220                                                         0);
221         CheckError( GetMoviesError(), "NewTrackMedia error" );
222
223         err = BeginMediaEdits (qte->theMedia);
224         CheckError( err, "BeginMediaEdits error" );
225
226         QT_StartAddVideoSamplesToMedia (&trackFrame);
227
228
229
230 static void QT_EndCreateMyVideoTrack(void)
231 {
232         OSErr err = noErr;
233
234         QT_EndAddVideoSamplesToMedia ();
235
236         err = EndMediaEdits (qte->theMedia);
237         CheckError( err, "EndMediaEdits error" );
238
239         err = InsertMediaIntoTrack (qte->theTrack,
240                                                                 kTrackStart,/* track start time */
241                                                                 kMediaStart,/* media start time */
242                                                                 GetMediaDuration (qte->theMedia),
243                                                                 fixed1);
244         CheckError( err, "InsertMediaIntoTrack error" );
245
246
247
248 /************************************************************
249 *                                                           *
250 *    QT_StartAddVideoSamplesToMedia()                       *
251 *    QT_DoAddVideoSamplesToMedia()                          *
252 *    QT_EndAddVideoSamplesToMedia()                         *
253 *                                                           *
254 *    Creates video samples for the media in a track         *
255 *                                                           *
256 *************************************************************/
257
258 static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame)
259 {
260         OSErr err = noErr;
261
262         qte->ibuf = IMB_allocImBuf (R.rectx, R.recty, 32, IB_rect, 0);
263         qte->ibuf2 = IMB_allocImBuf (R.rectx, R.recty, 32, IB_rect, 0);
264
265         err = NewGWorldFromPtr( &qte->theGWorld,
266                                                         k32ARGBPixelFormat,
267                                                         trackFrame,
268                                                         NULL, NULL, 0,
269                                                         (unsigned char *)qte->ibuf->rect,
270                                                         R.rectx * 4 );
271         CheckError (err, "NewGWorldFromPtr error");
272
273         qte->thePixMap = GetGWorldPixMap(qte->theGWorld);
274         LockPixels(qte->thePixMap);
275
276         SCDefaultPixMapSettings (qcdx->theComponent, qte->thePixMap, true);
277
278         SCSetInfo(qcdx->theComponent, scTemporalSettingsType,   &qcdx->gTemporalSettings);
279         SCSetInfo(qcdx->theComponent, scSpatialSettingsType,    &qcdx->gSpatialSettings);
280         SCSetInfo(qcdx->theComponent, scDataRateSettingsType,   &qcdx->aDataRateSetting);
281
282         err = SCCompressSequenceBegin(qcdx->theComponent, qte->thePixMap, NULL, &qte->anImageDescription); 
283         CheckError (err, "SCCompressSequenceBegin error" );
284 }
285
286
287 static void QT_DoAddVideoSamplesToMedia (int frame)
288 {
289         OSErr   err = noErr;
290         Rect    imageRect;
291
292         register int            index;
293         register int            boxsize;
294         register uint32_t       *readPos;
295         register uint32_t       *changePos;
296         Ptr                                     myPtr;
297
298         short   syncFlag;
299         long    dataSize;
300         Handle  compressedData;
301
302 // copy and flip the renderdata
303         if(qte->ibuf2) {
304                 memcpy(qte->ibuf2->rect, R.rectot, 4*R.rectx*R.recty);
305                 IMB_flipy(qte->ibuf2);
306         }
307
308 //get pointers to parse bitmapdata
309         myPtr = GetPixBaseAddr(qte->thePixMap);
310         imageRect = (**qte->thePixMap).bounds;
311
312         boxsize = R.rectx * R.recty;
313         readPos = (uint32_t *) qte->ibuf2->rect;
314         changePos = (uint32_t *) myPtr;
315
316 #ifdef __APPLE__
317 // Swap alpha byte to the end, so ARGB become RGBA; note this is big endian-centric.
318         for( index = 0; index < boxsize; index++, changePos++, readPos++ )
319                 *( changePos ) = ( ( *readPos & 0xFFFFFFFF ) >> 8 ) |
320                          ( ( *readPos << 24 ) & 0xFF );
321 #endif
322
323 #ifdef _WIN32
324 // poked around a little... this seems to work for windows, dunno if it's legal
325         for( index = 0; index < boxsize; index++, changePos++, readPos++ )
326                 *( changePos ) = ( ( *readPos & 0xFFFFFFFF ) << 8 ) |
327                                                  ( ( *readPos >> 24 ) & 0xFF ); // & ( ( *readPos << 8 ) & 0xFF );
328 #endif
329
330         err = SCCompressSequenceFrame(qcdx->theComponent,
331                 qte->thePixMap,
332                 &imageRect,
333                 &compressedData,
334                 &dataSize,
335                 &syncFlag);
336         CheckError(err, "SCCompressSequenceFrame error");
337
338         err = AddMediaSample(qte->theMedia,
339                 compressedData,
340                 0,
341                 dataSize,
342                 qcdx->duration,
343                 (SampleDescriptionHandle)qte->anImageDescription,
344                 1,
345                 syncFlag,
346                 NULL);
347         CheckError(err, "AddMediaSample error");
348
349         printf ("added frame %3d (frame %3d in movie): ", frame, frame-sframe);
350 }
351
352
353 static void QT_EndAddVideoSamplesToMedia (void)
354 {
355         SCCompressSequenceEnd(qcdx->theComponent);
356
357         UnlockPixels(qte->thePixMap);
358         if (qte->theGWorld)     DisposeGWorld (qte->theGWorld);
359         if (qte->ibuf) IMB_freeImBuf(qte->ibuf);
360         if (qte->ibuf2) {
361                 IMB_freeImBuf(qte->ibuf2);
362         }
363
364
365
366 /************************************************************
367 *                                                           *
368 *    makeqtstring (char *string)                            *
369 *                                                           *
370 *    Function to generate output filename                   *
371 *                                                           *
372 *************************************************************/
373
374 void makeqtstring (char *string) {
375         char txt[64];
376
377         if (string==0) return;
378
379         strcpy(string, G.scene->r.pic);
380         BLI_convertstringcode(string, G.sce, G.scene->r.cfra);
381
382         RE_make_existing_file(string);
383
384         if (strcasecmp(string + strlen(string) - 4, ".mov")) {
385                 sprintf(txt, "%04d_%04d.mov", (G.scene->r.sfra) , (G.scene->r.efra) );
386                 strcat(string, txt);
387         }
388 }
389
390
391 /************************************************************
392 *                                                           *
393 *    start_qt(void)                                         *
394 *    append_qt(int frame)                                   *
395 *    end_qt(int frame)                                      *
396 *                                                           *
397 *    Quicktime Export functions for Blender's initrender.c  *
398 *                                                           *
399 ************************************************************/
400
401 void start_qt(void) {
402         OSErr err = noErr;
403
404         char name[2048];
405         char theFullPath[255];
406
407 #ifdef __APPLE__
408         int             myFile;
409         FSRef   myRef;
410 #endif
411
412         if(qte == NULL) qte = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport");
413         if(qcdx == NULL || have_qtcodec == FALSE) get_qtcodec_settings();
414         
415         if (G.afbreek != 1) {
416                 sframe = (G.scene->r.sfra);
417
418                 makeqtstring(name);
419                 sprintf(theFullPath, "%s", name);
420
421 #ifdef __APPLE__
422                 /* hack: create an empty file to make FSPathMakeRef() happy */
423                 myFile = open(theFullPath, O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRUSR|S_IWUSR);
424                 if (myFile < 0) {
425                         printf("error while creating file!\n");
426                         /* do something? */
427                 }
428                 close(myFile);
429                 err = FSPathMakeRef(theFullPath, &myRef, 0);
430                 CheckError(err, "FsPathMakeRef error");
431                 err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &qte->theSpec, NULL);
432                 CheckError(err, "FsGetCatalogInfoRef error");
433 #else
434                 CopyCStringToPascal(theFullPath, qte->qtfilename);
435                 err = FSMakeFSSpec(0, 0L, qte->qtfilename, &qte->theSpec);
436 #endif
437
438                 err = CreateMovieFile (&qte->theSpec, 
439                                                         kMyCreatorType,
440                                                         smCurrentScript, 
441                                                         createMovieFileDeleteCurFile | createMovieFileDontCreateResFile,
442                                                         &qte->resRefNum, 
443                                                         &qte->theMovie );
444                 CheckError(err, "CreateMovieFile error");
445
446                 printf("Created QuickTime movie: %s\n", name);
447
448                 check_renderbutton_framerate();
449
450                 QT_CreateMyVideoTrack();
451         }
452 }
453
454
455 void append_qt(int frame) {
456         QT_DoAddVideoSamplesToMedia(frame);
457 }
458
459 void end_qt(void) {
460         OSErr err = noErr;
461
462         if(qte->theMovie) {
463                 QT_EndCreateMyVideoTrack ();
464
465                 qte->resId = movieInDataForkResID;
466                 err = AddMovieResource (qte->theMovie, qte->resRefNum, &qte->resId, qte->qtfilename);
467                 CheckError(err, "AddMovieResource error");
468
469                 if (qte->resRefNum)     CloseMovieFile (qte->resRefNum);
470
471                 DisposeMovie (qte->theMovie);
472         }
473
474         if(qte) {
475                 MEM_freeN(qte);
476                 qte = NULL;
477         }
478 };
479
480
481 /************************************************************
482 *                                                           *
483 *    free_qtcodecdataExt(void)                              *
484 *                                                           *
485 *    Function to release codec memory, since it remains     *
486 *    resident after allocation.                             *
487 *                                                           *
488 *************************************************************/
489
490 void free_qtcodecdataExt(void) {
491         if(qcdx) {
492                 MEM_freeN(qcdx);
493                 qcdx = NULL;
494         }
495 }
496
497
498 /************************************************************
499 *                                                           *
500 *    check_renderbutton_framerate ( void )                  *
501 *                                                           *
502 *    To keep float framerates consistent between the codec  *
503 *    dialog and frs/sec button.                             *
504 *                                                           *
505 *************************************************************/
506
507 static void check_renderbutton_framerate(void) {
508         OSErr   err;    
509
510         err = SCGetInfo(qcdx->theComponent, scTemporalSettingsType,     &qcdx->gTemporalSettings);
511         CheckError(err, "SCGetInfo error");
512
513         if( (G.scene->r.frs_sec == 24 || G.scene->r.frs_sec == 30 || G.scene->r.frs_sec == 60) &&
514                 (qcdx->gTemporalSettings.frameRate == 1571553 ||
515                  qcdx->gTemporalSettings.frameRate == 1964113 ||
516                  qcdx->gTemporalSettings.frameRate == 3928227)) {;} else
517         qcdx->gTemporalSettings.frameRate = G.scene->r.frs_sec << 16;
518
519         err = SCSetInfo(qcdx->theComponent, scTemporalSettingsType,     &qcdx->gTemporalSettings);
520         CheckError( err, "SCSetInfo error" );
521
522         if(qcdx->gTemporalSettings.frameRate == 1571553) {                      // 23.98 fps
523                 qcdx->kVideoTimeScale = 2398;
524                 qcdx->duration = 100;
525         } else if (qcdx->gTemporalSettings.frameRate == 1964113) {      // 29.97 fps
526                 qcdx->kVideoTimeScale = 2997;
527                 qcdx->duration = 100;
528         } else if (qcdx->gTemporalSettings.frameRate == 3928227) {      // 59.94 fps
529                 qcdx->kVideoTimeScale = 5994;
530                 qcdx->duration = 100;
531         } else {
532                 qcdx->kVideoTimeScale = (qcdx->gTemporalSettings.frameRate >> 16) * 100;
533                 qcdx->duration = 100;
534         }
535 }
536 /********************************************************************
537 *                                                                   *
538 *    get_qtcodec_settings()                                         *
539 *                                                                   *
540 *    Displays Codec Dialog and retrieves Quicktime Codec settings.  *
541 *                                                                   *
542 ********************************************************************/
543
544 int get_qtcodec_settings(void) 
545 {
546         OSErr   err = noErr;
547 //      Component c = 0;
548 //      ComponentDescription cd;
549         CodecInfo ci;
550         char str[255];
551
552 //      cd.componentType = StandardCompressionType;
553 //      cd.componentSubType = StandardCompressionSubType;
554 //      cd.componentManufacturer = 0;
555 //      cd.componentFlags = 0;
556 //      cd.componentFlagsMask = 0;
557
558         if(qcdx == NULL) {
559                 qcdx = MEM_callocN(sizeof(QuicktimeCodecDataExt), "QuicktimeCodecDataExt");
560                 have_qtcodec = FALSE;
561         }
562
563         // configure the standard image compression dialog box
564
565         if (qcdx->theComponent == NULL) {
566                 qcdx->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);
567 //              c = FindNextComponent(c, &cd);
568 //              qcdx->theComponent = OpenComponent(c);
569
570 //              qcdx->gSpatialSettings.codecType = nil;     
571                 qcdx->gSpatialSettings.codec = anyCodec;         
572 //              qcdx->gSpatialSettings.depth;         
573                 qcdx->gSpatialSettings.spatialQuality = codecMaxQuality;
574
575                 qcdx->gTemporalSettings.temporalQuality = codecMaxQuality;
576 //              qcdx->gTemporalSettings.frameRate;      
577                 qcdx->gTemporalSettings.keyFrameRate = 25;   
578
579                 qcdx->aDataRateSetting.dataRate = 90 * 1024;          
580 //              qcdx->aDataRateSetting.frameDuration;     
581 //              qcdx->aDataRateSetting.minSpatialQuality; 
582 //              qcdx->aDataRateSetting.minTemporalQuality;
583
584
585                 err = SCSetInfo(qcdx->theComponent, scTemporalSettingsType,     &qcdx->gTemporalSettings);
586                 CheckError(err, "SCSetInfo1 error");
587                 err = SCSetInfo(qcdx->theComponent, scSpatialSettingsType,      &qcdx->gSpatialSettings);
588                 CheckError(err, "SCSetInfo2 error");
589                 err = SCSetInfo(qcdx->theComponent, scDataRateSettingsType,     &qcdx->aDataRateSetting);
590                 CheckError(err, "SCSetInfo3 error");
591         }
592
593         check_renderbutton_framerate();
594  
595         // put up the dialog box
596
597         err = SCRequestSequenceSettings(qcdx->theComponent);
598  
599         if (err == scUserCancelled) {
600                 G.afbreek = 1;
601                 return 0;
602         }
603
604         have_qtcodec = TRUE;
605
606         // get user selected data
607
608         SCGetInfo(qcdx->theComponent, scTemporalSettingsType,   &qcdx->gTemporalSettings);
609         SCGetInfo(qcdx->theComponent, scSpatialSettingsType,    &qcdx->gSpatialSettings);
610         SCGetInfo(qcdx->theComponent, scDataRateSettingsType,   &qcdx->aDataRateSetting);
611
612         GetCodecInfo (&ci, qcdx->gSpatialSettings.codecType, 0);
613         CopyPascalStringToC(ci.typeName, str);
614         sprintf(qtcdname,"Codec: %s", str);
615
616         // framerate jugglin'
617
618         if(qcdx->gTemporalSettings.frameRate == 1571553) {                      // 23.98 fps
619                 qcdx->kVideoTimeScale = 2398;
620                 qcdx->duration = 100;
621
622                 G.scene->r.frs_sec = 24;
623         } else if (qcdx->gTemporalSettings.frameRate == 1964113) {      // 29.97 fps
624                 qcdx->kVideoTimeScale = 2997;
625                 qcdx->duration = 100;
626
627                 G.scene->r.frs_sec = 30;
628         } else if (qcdx->gTemporalSettings.frameRate == 3928227) {      // 59.94 fps
629                 qcdx->kVideoTimeScale = 5994;
630                 qcdx->duration = 100;
631
632                 G.scene->r.frs_sec = 60;
633         } else {
634                 qcdx->kVideoTimeScale = 600;
635                 qcdx->duration = qcdx->kVideoTimeScale / (qcdx->gTemporalSettings.frameRate / 65536);
636
637                 G.scene->r.frs_sec = (qcdx->gTemporalSettings.frameRate / 65536);
638         }
639
640         return 1;
641 }
642
643 #endif /* _WIN32 || __APPLE__ */
644
645 #endif /* WITH_QUICKTIME */
646
647
648
649 #if 0
650
651 /************************************************************
652 *                                                           *
653 *    References for future codec handling                   *
654 *                                                           *
655 *************************************************************/
656
657 these are from mplayer sourcecode:
658
659 struct ComponentRecord {
660     long                            data[1];
661 };
662 typedef struct ComponentRecord          ComponentRecord;
663 typedef ComponentRecord *               Component;
664 typedef long OSErr;
665 typedef int OSType;
666 typedef long ComponentResult;
667 typedef long                            Fixed;
668
669
670 these are from quicktime:
671
672
673 typedef Component                       CodecComponent;
674 typedef OSType                          CodecType;
675 typedef unsigned short                  CodecFlags;
676 typedef unsigned long                   CodecQ;
677
678 typedef struct {
679    CodecType      codecType;        /* compressor type */
680    CodecComponent codec;            /* compressor */
681    short          depth;            /* pixel depth */
682    CodecQ         spatialQuality;   /* desired quality */
683 } SCSpatialSettings;
684
685 /* temporal options structure with the temporal settings request */
686 typedef struct {
687    CodecQ   temporalQuality;           /* desired quality */
688    Fixed    frameRate;                 /* frame rate */
689    long     keyFrameRate;              /* key frame rate */
690 } SCTemporalSettings;
691
692 /* data rate options with the data rate settings request */
693 typedef struct {
694    long     dataRate;               /* desired data rate */
695    long     frameDuration;          /* frame duration */
696    CodecQ   minSpatialQuality;      /* minimum value */
697    CodecQ   minTemporalQuality;     /* minimum value */
698 } SCDataRateSettings;
699
700
701 would look like this ???
702
703 typedef struct {
704    int                codecType;        /* compressor type */
705 //here is the prob
706    long                  *codec;            /* compressor */
707    short          depth;            /* pixel depth */
708    unsigned long  spatialQuality;   /* desired quality */
709 } SCSpatialSettings;
710
711 /* temporal options structure with the temporal settings request */
712 typedef struct {
713    unsigned long  temporalQuality;  /* desired quality */
714    long           frameRate;        /* frame rate */
715    long           keyFrameRate;     /* key frame rate */
716 } SCTemporalSettings;
717
718 /* data rate options with the data rate settings request */
719 typedef struct {
720    long           dataRate;               /* desired data rate */
721    long           frameDuration;          /* frame duration */
722    unsigned long  minSpatialQuality;      /* minimum value */
723    unsigned long  minTemporalQuality;     /* minimum value */
724 } SCDataRateSettings;
725
726
727 stuff to use quicktime Atoms (doesnt work) heh
728
729         long size;
730         Ptr     thePtr;
731         QTAtomContainer         myContainer = NULL;
732         QTAtom                          myAtom;
733 QTAtomContainer SettingsAtom;
734
735 atom -> component
736 SCSetSettingsFromAtomContainer(qcdx->theComponent, SettingsAtom);
737
738 component -> atom
739 SCGetSettingsAsAtomContainer(qcdx->theComponent, SettingsAtom);
740
741 QTCopyAtomDataToPtr(container, atom, 0, size, &targetPtr, &actualsize);
742 QTGetAtomDataPtr(container, atom, &size, &ptr);
743
744 kParentAtomIsContainer
745 #endif /* 0 */