29734ae13da85f37c16d6b9860397a047fcd20c1
[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;
143
144 } QuicktimeExport;
145
146 typedef struct _QuicktimeCodecDataExt {
147
148         ComponentInstance       theComponent;
149         SCTemporalSettings  gTemporalSettings;
150         SCSpatialSettings   gSpatialSettings;
151         SCDataRateSettings  aDataRateSetting;
152         TimeValue                       duration;
153         long                            kVideoTimeScale;
154
155 } QuicktimeCodecDataExt;
156
157 struct _QuicktimeExport *qte;
158 struct _QuicktimeCodecDataExt *qcdx;
159
160 /************************************************************
161 *                                                           *
162 *    VARIABLES                                              *
163 *                                                           *
164 *************************************************************/
165
166 #define kMyCreatorType  FOUR_CHAR_CODE('TVOD')
167 #define kPixelDepth     32      /* use 32-bit depth */
168 #define kTrackStart             0
169 #define kMediaStart             0
170
171 static int sframe;
172
173 int             have_qtcodec;
174 char    qtcdname[64];
175
176 /************************************************************
177 *                                                           *
178 *    CheckError(OSErr err, char *msg)                       *
179 *                                                           *
180 *    prints errors in console, doesnt interrupt Blender     *
181 *                                                           *
182 *************************************************************/
183
184 void CheckError(OSErr err, char *msg)
185 {
186         if(err != noErr) printf("%s: %d\n", msg, err);
187 }
188
189
190 /************************************************************
191 *                                                           *
192 *    QT_CreateMyVideoTrack()                                *
193 *    QT_EndCreateMyVideoTrack()                             *
194 *                                                           *
195 *    Creates/finishes a video track for the QuickTime movie *
196 *                                                           *
197 *************************************************************/
198
199 static void QT_CreateMyVideoTrack(void)
200 {
201         OSErr err = noErr;
202         Rect trackFrame;
203
204         trackFrame.top = 0;
205         trackFrame.left = 0;
206         trackFrame.bottom = R.recty;
207         trackFrame.right = R.rectx;
208         
209         qte->theTrack = NewMovieTrack (qte->theMovie, 
210                                                         FixRatio(trackFrame.right,1),
211                                                         FixRatio(trackFrame.bottom,1), 
212                                                         kNoVolume);
213         CheckError( GetMoviesError(), "NewMovieTrack error" );
214
215         qte->theMedia = NewTrackMedia (qte->theTrack,
216                                                         VideoMediaType,
217                                                         qcdx->kVideoTimeScale,
218                                                         nil,
219                                                         0);
220         CheckError( GetMoviesError(), "NewTrackMedia error" );
221
222         err = BeginMediaEdits (qte->theMedia);
223         CheckError( err, "BeginMediaEdits error" );
224
225         QT_StartAddVideoSamplesToMedia (&trackFrame);
226
227
228
229 static void QT_EndCreateMyVideoTrack(void)
230 {
231         OSErr err = noErr;
232
233         QT_EndAddVideoSamplesToMedia ();
234
235         err = EndMediaEdits (qte->theMedia);
236         CheckError( err, "EndMediaEdits error" );
237
238         err = InsertMediaIntoTrack (qte->theTrack,
239                                                                 kTrackStart,/* track start time */
240                                                                 kMediaStart,/* media start time */
241                                                                 GetMediaDuration (qte->theMedia),
242                                                                 fixed1);
243         CheckError( err, "InsertMediaIntoTrack error" );
244
245
246
247 /************************************************************
248 *                                                           *
249 *    QT_StartAddVideoSamplesToMedia()                       *
250 *    QT_DoAddVideoSamplesToMedia()                          *
251 *    QT_EndAddVideoSamplesToMedia()                         *
252 *                                                           *
253 *    Creates video samples for the media in a track         *
254 *                                                           *
255 *************************************************************/
256
257 static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame)
258 {
259         OSErr err = noErr;
260
261         qte->ibuf = IMB_allocImBuf (R.rectx, R.recty, 32, IB_rect, 0);
262
263         err = NewGWorldFromPtr( &qte->theGWorld,
264                                                         k32ARGBPixelFormat,
265                                                         trackFrame,
266                                                         NULL, NULL, 0,
267                                                         (unsigned char *)qte->ibuf->rect,
268                                                         R.rectx * 4 );
269         CheckError (err, "NewGWorldFromPtr error");
270
271         qte->thePixMap = GetGWorldPixMap(qte->theGWorld);
272         LockPixels(qte->thePixMap);
273
274         SCDefaultPixMapSettings (qcdx->theComponent, qte->thePixMap, true);
275
276         SCSetInfo(qcdx->theComponent, scTemporalSettingsType,   &qcdx->gTemporalSettings);
277         SCSetInfo(qcdx->theComponent, scSpatialSettingsType,    &qcdx->gSpatialSettings);
278         SCSetInfo(qcdx->theComponent, scDataRateSettingsType,   &qcdx->aDataRateSetting);
279
280         err = SCCompressSequenceBegin(qcdx->theComponent, qte->thePixMap, NULL, &qte->anImageDescription); 
281         CheckError (err, "SCCompressSequenceBegin error" );
282 }
283
284
285 static void QT_DoAddVideoSamplesToMedia (int frame)
286 {
287         OSErr   err = noErr;
288         Rect    imageRect;
289
290         register int            index;
291         register int            boxsize;
292         register uint32_t       *readPos;
293         register uint32_t       *changePos;
294         Ptr                                     myPtr;
295
296         short   syncFlag;
297         long    dataSize;
298         Handle  compressedData;
299
300 // flip rendered data for quicktime
301 // NOTE: we flip the original renderdata !
302         short x,y,backx;
303         unsigned int *top,*bottom,temp;
304
305         x = R.rectx; y = R.recty; backx = x<<1;
306         top = R.rectot; bottom = top + ((y-1) * x);     y >>= 1;
307
308         for(;y>0;y--){
309                 for(x = R.rectx; x > 0; x--){
310                         temp = *top;
311                         *(top++) = *bottom;
312                         *(bottom++) = temp;
313                 }
314                 bottom -= backx;
315         }
316
317 //get pointers to parse bitmapdata
318         myPtr = GetPixBaseAddr(qte->thePixMap);
319         imageRect = (**qte->thePixMap).bounds;
320
321         boxsize = R.rectx * R.recty;
322         readPos = (uint32_t *) R.rectot;
323         changePos = (uint32_t *) myPtr;
324
325 #ifdef __APPLE__
326 // Swap alpha byte to the end, so ARGB become RGBA; note this is big endian-centric.
327         for( index = 0; index < boxsize; index++, changePos++, readPos++ )
328                 *( changePos ) = ( ( *readPos & 0xFFFFFFFF ) >> 8 ) |
329                          ( ( *readPos << 24 ) & 0xFF );
330 #endif
331
332 #ifdef _WIN32
333 // poked around a little... this seems to work for windows, dunno if it's legal
334         for( index = 0; index < boxsize; index++, changePos++, readPos++ )
335                 *( changePos ) = ( ( *readPos & 0xFFFFFFFF ) << 8 ) |
336                                                  ( ( *readPos >> 24 ) & 0xFF ); // & ( ( *readPos << 8 ) & 0xFF );
337 #endif
338
339         err = SCCompressSequenceFrame(qcdx->theComponent,
340                 qte->thePixMap,
341                 &imageRect,
342                 &compressedData,
343                 &dataSize,
344                 &syncFlag);
345         CheckError(err, "SCCompressSequenceFrame error");
346
347         err = AddMediaSample(qte->theMedia,
348                 compressedData,
349                 0,
350                 dataSize,
351                 qcdx->duration,
352                 (SampleDescriptionHandle)qte->anImageDescription,
353                 1,
354                 syncFlag,
355                 NULL);
356         CheckError(err, "AddMediaSample error");
357
358         printf ("added frame %3d (frame %3d in movie): ", frame, frame-sframe);
359 }
360
361
362 static void QT_EndAddVideoSamplesToMedia (void)
363 {
364         
365         SCCompressSequenceEnd(qcdx->theComponent);
366
367         UnlockPixels(qte->thePixMap);
368         if (qte->theGWorld)     DisposeGWorld (qte->theGWorld);
369         if (qte->ibuf) IMB_freeImBuf(qte->ibuf);
370
371
372
373 /************************************************************
374 *                                                           *
375 *    makeqtstring (char *string)                            *
376 *                                                           *
377 *    Function to generate output filename                   *
378 *                                                           *
379 *************************************************************/
380
381 void makeqtstring (char *string) {
382         char txt[64];
383
384         if (string==0) return;
385
386         strcpy(string, G.scene->r.pic);
387         BLI_convertstringcode(string, G.sce, G.scene->r.cfra);
388
389         RE_make_existing_file(string);
390
391         if (strcasecmp(string + strlen(string) - 4, ".mov")) {
392                 sprintf(txt, "%04d_%04d.mov", (G.scene->r.sfra) , (G.scene->r.efra) );
393                 strcat(string, txt);
394         }
395 }
396
397
398 /************************************************************
399 *                                                           *
400 *    start_qt(void)                                         *
401 *    append_qt(int frame)                                   *
402 *    end_qt(int frame)                                      *
403 *                                                           *
404 *    Quicktime Export functions for Blender's initrender.c  *
405 *                                                           *
406 ************************************************************/
407
408 void start_qt(void) {
409         OSErr err = noErr;
410
411         char name[2048];
412         char theFullPath[255];
413
414 #ifdef __APPLE__
415         int             myFile;
416         FSRef   myRef;
417 #endif
418
419         if(qte == NULL) qte = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport");
420         if(qcdx == NULL || have_qtcodec == FALSE) get_qtcodec_settings();
421         
422         if (G.afbreek != 1) {
423                 sframe = (G.scene->r.sfra);
424
425                 makeqtstring(name);
426                 sprintf(theFullPath, "%s", name);
427
428 #ifdef __APPLE__
429                 /* hack: create an empty file to make FSPathMakeRef() happy */
430                 myFile = open(theFullPath, O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRUSR|S_IWUSR);
431                 if (myFile < 0) {
432                         printf("error while creating file!\n");
433                         /* do something? */
434                 }
435                 close(myFile);
436                 err = FSPathMakeRef(theFullPath, &myRef, 0);
437                 CheckError(err, "FsPathMakeRef error");
438                 err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &qte->theSpec, NULL);
439                 CheckError(err, "FsGetCatalogInfoRef error");
440 #else
441                 CopyCStringToPascal(theFullPath, qte->qtfilename);
442                 err = FSMakeFSSpec(0, 0L, qte->qtfilename, &qte->theSpec);
443 #endif
444
445                 err = CreateMovieFile (&qte->theSpec, 
446                                                         kMyCreatorType,
447                                                         smCurrentScript, 
448                                                         createMovieFileDeleteCurFile | createMovieFileDontCreateResFile,
449                                                         &qte->resRefNum, 
450                                                         &qte->theMovie );
451                 CheckError(err, "CreateMovieFile error");
452
453                 printf("Created QuickTime movie: %s\n", name);
454
455                 check_renderbutton_framerate();
456
457                 QT_CreateMyVideoTrack();
458         }
459 }
460
461
462 void append_qt(int frame) {
463         QT_DoAddVideoSamplesToMedia(frame);
464 }
465
466 void end_qt(void) {
467         OSErr err = noErr;
468
469         short x,y,backx;
470         unsigned int *top,*bottom,temp;
471
472         if(qte->theMovie) {
473                 QT_EndCreateMyVideoTrack ();
474
475                 qte->resId = movieInDataForkResID;
476                 err = AddMovieResource (qte->theMovie, qte->resRefNum, &qte->resId, qte->qtfilename);
477                 CheckError(err, "AddMovieResource error");
478
479                 if (qte->resRefNum)     CloseMovieFile (qte->resRefNum);
480
481                 DisposeMovie (qte->theMovie);
482
483                 //flip back rendered data when done exporting quicktime
484
485                 x = R.rectx; y = R.recty; backx = x<<1;
486                 top = R.rectot; bottom = top + ((y-1) * x);     y >>= 1;
487
488                 for(;y>0;y--){
489                         for(x = R.rectx; x > 0; x--){
490                                 temp = *top;
491                                 *(top++) = *bottom;
492                                 *(bottom++) = temp;
493                         }
494                         bottom -= backx;
495                 }
496         }
497
498         if(qte) {
499                 MEM_freeN(qte);
500                 qte = NULL;
501         }
502 };
503
504
505 /************************************************************
506 *                                                           *
507 *    free_qtcodecdataExt(void)                              *
508 *                                                           *
509 *    Function to release codec memory, since it remains     *
510 *    resident after allocation.                             *
511 *                                                           *
512 *************************************************************/
513
514 void free_qtcodecdataExt(void) {
515         if(qcdx) {
516                 MEM_freeN(qcdx);
517                 qcdx = NULL;
518         }
519 }
520
521
522 /************************************************************
523 *                                                           *
524 *    check_renderbutton_framerate ( void )                  *
525 *                                                           *
526 *    To keep float framerates consistent between the codec  *
527 *    dialog and frs/sec button.                             *
528 *                                                           *
529 *************************************************************/
530
531 static void check_renderbutton_framerate(void) {
532         OSErr   err;    
533
534         err = SCGetInfo(qcdx->theComponent, scTemporalSettingsType,     &qcdx->gTemporalSettings);
535         CheckError(err, "SCGetInfo error");
536
537         if( (G.scene->r.frs_sec == 24 || G.scene->r.frs_sec == 30 || G.scene->r.frs_sec == 60) &&
538                 (qcdx->gTemporalSettings.frameRate == 1571553 ||
539                  qcdx->gTemporalSettings.frameRate == 1964113 ||
540                  qcdx->gTemporalSettings.frameRate == 3928227)) {;} else
541         qcdx->gTemporalSettings.frameRate = G.scene->r.frs_sec << 16;
542
543         err = SCSetInfo(qcdx->theComponent, scTemporalSettingsType,     &qcdx->gTemporalSettings);
544         CheckError( err, "SCSetInfo error" );
545
546         if(qcdx->gTemporalSettings.frameRate == 1571553) {                      // 23.98 fps
547                 qcdx->kVideoTimeScale = 2398;
548                 qcdx->duration = 100;
549         } else if (qcdx->gTemporalSettings.frameRate == 1964113) {      // 29.97 fps
550                 qcdx->kVideoTimeScale = 2997;
551                 qcdx->duration = 100;
552         } else if (qcdx->gTemporalSettings.frameRate == 3928227) {      // 59.94 fps
553                 qcdx->kVideoTimeScale = 5994;
554                 qcdx->duration = 100;
555         } else {
556                 qcdx->kVideoTimeScale = (qcdx->gTemporalSettings.frameRate >> 16) * 100;
557                 qcdx->duration = 100;
558         }
559 }
560 /********************************************************************
561 *                                                                   *
562 *    get_qtcodec_settings()                                         *
563 *                                                                   *
564 *    Displays Codec Dialog and retrieves Quicktime Codec settings.  *
565 *                                                                   *
566 ********************************************************************/
567
568 int get_qtcodec_settings(void) 
569 {
570         OSErr   err = noErr;
571         Component c = 0;
572         ComponentDescription cd;
573         CodecInfo ci;
574
575         cd.componentType = StandardCompressionType;
576         cd.componentSubType = StandardCompressionSubType;
577         cd.componentManufacturer = 0;
578         cd.componentFlags = 0;
579         cd.componentFlagsMask = 0;
580
581
582         if(qcdx == NULL) {
583                 qcdx = MEM_callocN(sizeof(QuicktimeCodecDataExt), "QuicktimeCodecDataExt");
584                 have_qtcodec = FALSE;
585         }
586
587         // configure the standard image compression dialog box
588
589         if (qcdx->theComponent == NULL) {
590 //              qcdx->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);
591                 c = FindNextComponent(c, &cd);
592                 qcdx->theComponent = OpenComponent(c);
593
594 //              qcdx->gSpatialSettings.codecType = nil;     
595                 qcdx->gSpatialSettings.codec = anyCodec;         
596 //              qcdx->gSpatialSettings.depth;         
597                 qcdx->gSpatialSettings.spatialQuality = codecMaxQuality;
598
599                 qcdx->gTemporalSettings.temporalQuality = codecMaxQuality;
600 //              qcdx->gTemporalSettings.frameRate;      
601                 qcdx->gTemporalSettings.keyFrameRate = 25;   
602
603                 qcdx->aDataRateSetting.dataRate = 90 * 1024;          
604 //              qcdx->aDataRateSetting.frameDuration;     
605 //              qcdx->aDataRateSetting.minSpatialQuality; 
606 //              qcdx->aDataRateSetting.minTemporalQuality;
607
608
609                 err = SCSetInfo(qcdx->theComponent, scTemporalSettingsType,     &qcdx->gTemporalSettings);
610                 CheckError(err, "SCSetInfo1 error");
611                 err = SCSetInfo(qcdx->theComponent, scSpatialSettingsType,      &qcdx->gSpatialSettings);
612                 CheckError(err, "SCSetInfo2 error");
613                 err = SCSetInfo(qcdx->theComponent, scDataRateSettingsType,     &qcdx->aDataRateSetting);
614                 CheckError(err, "SCSetInfo3 error");
615         }
616
617         check_renderbutton_framerate();
618  
619         // put up the dialog box
620
621         err = SCRequestSequenceSettings(qcdx->theComponent);
622
623  
624    if (err == scUserCancelled) {
625                 G.afbreek = 1;
626                 return 0;
627         }
628
629         have_qtcodec = TRUE;
630
631         // get user selected data
632
633         SCGetInfo(qcdx->theComponent, scTemporalSettingsType,   &qcdx->gTemporalSettings);
634         SCGetInfo(qcdx->theComponent, scSpatialSettingsType,    &qcdx->gSpatialSettings);
635         SCGetInfo(qcdx->theComponent, scDataRateSettingsType,   &qcdx->aDataRateSetting);
636
637         GetCodecInfo (&ci, qcdx->gSpatialSettings.codecType, 0);
638         sprintf(qtcdname,"Codec: %s", p2cstr(ci.typeName));
639
640         // framerate jugglin'
641
642         if(qcdx->gTemporalSettings.frameRate == 1571553) {                      // 23.98 fps
643                 qcdx->kVideoTimeScale = 2398;
644                 qcdx->duration = 100;
645
646                 G.scene->r.frs_sec = 24;
647         } else if (qcdx->gTemporalSettings.frameRate == 1964113) {      // 29.97 fps
648                 qcdx->kVideoTimeScale = 2997;
649                 qcdx->duration = 100;
650
651                 G.scene->r.frs_sec = 30;
652         } else if (qcdx->gTemporalSettings.frameRate == 3928227) {      // 59.94 fps
653                 qcdx->kVideoTimeScale = 5994;
654                 qcdx->duration = 100;
655
656                 G.scene->r.frs_sec = 60;
657         } else {
658                 qcdx->kVideoTimeScale = 600;
659                 qcdx->duration = qcdx->kVideoTimeScale / (qcdx->gTemporalSettings.frameRate / 65536);
660
661                 G.scene->r.frs_sec = (qcdx->gTemporalSettings.frameRate / 65536);
662         }
663
664         return 1;
665 }
666
667 #endif /* _WIN32 || __APPLE__ */
668
669 #endif /* WITH_QUICKTIME */
670
671
672
673 #if 0
674
675 /************************************************************
676 *                                                           *
677 *    References for future codec handling                   *
678 *                                                           *
679 *************************************************************/
680
681 these are from mplayer sourcecode:
682
683 struct ComponentRecord {
684     long                            data[1];
685 };
686 typedef struct ComponentRecord          ComponentRecord;
687 typedef ComponentRecord *               Component;
688 typedef long OSErr;
689 typedef int OSType;
690 typedef long ComponentResult;
691 typedef long                            Fixed;
692
693
694 these are from quicktime:
695
696
697 typedef Component                       CodecComponent;
698 typedef OSType                          CodecType;
699 typedef unsigned short                  CodecFlags;
700 typedef unsigned long                   CodecQ;
701
702 typedef struct {
703    CodecType      codecType;        /* compressor type */
704    CodecComponent codec;            /* compressor */
705    short          depth;            /* pixel depth */
706    CodecQ         spatialQuality;   /* desired quality */
707 } SCSpatialSettings;
708
709 /* temporal options structure with the temporal settings request */
710 typedef struct {
711    CodecQ   temporalQuality;           /* desired quality */
712    Fixed    frameRate;                 /* frame rate */
713    long     keyFrameRate;              /* key frame rate */
714 } SCTemporalSettings;
715
716 /* data rate options with the data rate settings request */
717 typedef struct {
718    long     dataRate;               /* desired data rate */
719    long     frameDuration;          /* frame duration */
720    CodecQ   minSpatialQuality;      /* minimum value */
721    CodecQ   minTemporalQuality;     /* minimum value */
722 } SCDataRateSettings;
723
724
725 would look like this ???
726
727 typedef struct {
728    int                codecType;        /* compressor type */
729 //here is the prob
730    long                  *codec;            /* compressor */
731    short          depth;            /* pixel depth */
732    unsigned long  spatialQuality;   /* desired quality */
733 } SCSpatialSettings;
734
735 /* temporal options structure with the temporal settings request */
736 typedef struct {
737    unsigned long  temporalQuality;  /* desired quality */
738    long           frameRate;        /* frame rate */
739    long           keyFrameRate;     /* key frame rate */
740 } SCTemporalSettings;
741
742 /* data rate options with the data rate settings request */
743 typedef struct {
744    long           dataRate;               /* desired data rate */
745    long           frameDuration;          /* frame duration */
746    unsigned long  minSpatialQuality;      /* minimum value */
747    unsigned long  minTemporalQuality;     /* minimum value */
748 } SCDataRateSettings;
749
750
751 stuff to use quicktime Atoms (doesnt work) heh
752
753         long size;
754         Ptr     thePtr;
755         QTAtomContainer         myContainer = NULL;
756         QTAtom                          myAtom;
757 QTAtomContainer SettingsAtom;
758
759 atom -> component
760 SCSetSettingsFromAtomContainer(qcdx->theComponent, SettingsAtom);
761
762 component -> atom
763 SCGetSettingsAsAtomContainer(qcdx->theComponent, SettingsAtom);
764
765 QTCopyAtomDataToPtr(container, atom, 0, size, &targetPtr, &actualsize);
766 QTGetAtomDataPtr(container, atom, &size, &ptr);
767
768 kParentAtomIsContainer
769 #endif /* 0 */