replaced depricated p2cstr with CopyPascalStringToC for OSX.
[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         SCCompressSequenceEnd(qcdx->theComponent);
365
366         UnlockPixels(qte->thePixMap);
367         if (qte->theGWorld)     DisposeGWorld (qte->theGWorld);
368         if (qte->ibuf) IMB_freeImBuf(qte->ibuf);
369
370
371
372 /************************************************************
373 *                                                           *
374 *    makeqtstring (char *string)                            *
375 *                                                           *
376 *    Function to generate output filename                   *
377 *                                                           *
378 *************************************************************/
379
380 void makeqtstring (char *string) {
381         char txt[64];
382
383         if (string==0) return;
384
385         strcpy(string, G.scene->r.pic);
386         BLI_convertstringcode(string, G.sce, G.scene->r.cfra);
387
388         RE_make_existing_file(string);
389
390         if (strcasecmp(string + strlen(string) - 4, ".mov")) {
391                 sprintf(txt, "%04d_%04d.mov", (G.scene->r.sfra) , (G.scene->r.efra) );
392                 strcat(string, txt);
393         }
394 }
395
396
397 /************************************************************
398 *                                                           *
399 *    start_qt(void)                                         *
400 *    append_qt(int frame)                                   *
401 *    end_qt(int frame)                                      *
402 *                                                           *
403 *    Quicktime Export functions for Blender's initrender.c  *
404 *                                                           *
405 ************************************************************/
406
407 void start_qt(void) {
408         OSErr err = noErr;
409
410         char name[2048];
411         char theFullPath[255];
412
413 #ifdef __APPLE__
414         int             myFile;
415         FSRef   myRef;
416 #endif
417
418         if(qte == NULL) qte = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport");
419         if(qcdx == NULL || have_qtcodec == FALSE) get_qtcodec_settings();
420         
421         if (G.afbreek != 1) {
422                 sframe = (G.scene->r.sfra);
423
424                 makeqtstring(name);
425                 sprintf(theFullPath, "%s", name);
426
427 #ifdef __APPLE__
428                 /* hack: create an empty file to make FSPathMakeRef() happy */
429                 myFile = open(theFullPath, O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRUSR|S_IWUSR);
430                 if (myFile < 0) {
431                         printf("error while creating file!\n");
432                         /* do something? */
433                 }
434                 close(myFile);
435                 err = FSPathMakeRef(theFullPath, &myRef, 0);
436                 CheckError(err, "FsPathMakeRef error");
437                 err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &qte->theSpec, NULL);
438                 CheckError(err, "FsGetCatalogInfoRef error");
439 #else
440                 CopyCStringToPascal(theFullPath, qte->qtfilename);
441                 err = FSMakeFSSpec(0, 0L, qte->qtfilename, &qte->theSpec);
442 #endif
443
444                 err = CreateMovieFile (&qte->theSpec, 
445                                                         kMyCreatorType,
446                                                         smCurrentScript, 
447                                                         createMovieFileDeleteCurFile | createMovieFileDontCreateResFile,
448                                                         &qte->resRefNum, 
449                                                         &qte->theMovie );
450                 CheckError(err, "CreateMovieFile error");
451
452                 printf("Created QuickTime movie: %s\n", name);
453
454                 check_renderbutton_framerate();
455
456                 QT_CreateMyVideoTrack();
457         }
458 }
459
460
461 void append_qt(int frame) {
462         QT_DoAddVideoSamplesToMedia(frame);
463 }
464
465 void end_qt(void) {
466         OSErr err = noErr;
467
468         short x,y,backx;
469         unsigned int *top,*bottom,temp;
470
471         if(qte->theMovie) {
472                 QT_EndCreateMyVideoTrack ();
473
474                 qte->resId = movieInDataForkResID;
475                 err = AddMovieResource (qte->theMovie, qte->resRefNum, &qte->resId, qte->qtfilename);
476                 CheckError(err, "AddMovieResource error");
477
478                 if (qte->resRefNum)     CloseMovieFile (qte->resRefNum);
479
480                 DisposeMovie (qte->theMovie);
481
482                 //flip back rendered data when done exporting quicktime
483
484                 x = R.rectx; y = R.recty; backx = x<<1;
485                 top = R.rectot; bottom = top + ((y-1) * x);     y >>= 1;
486
487                 for(;y>0;y--){
488                         for(x = R.rectx; x > 0; x--){
489                                 temp = *top;
490                                 *(top++) = *bottom;
491                                 *(bottom++) = temp;
492                         }
493                         bottom -= backx;
494                 }
495         }
496
497         if(qte) {
498                 MEM_freeN(qte);
499                 qte = NULL;
500         }
501 };
502
503
504 /************************************************************
505 *                                                           *
506 *    free_qtcodecdataExt(void)                              *
507 *                                                           *
508 *    Function to release codec memory, since it remains     *
509 *    resident after allocation.                             *
510 *                                                           *
511 *************************************************************/
512
513 void free_qtcodecdataExt(void) {
514         if(qcdx) {
515                 MEM_freeN(qcdx);
516                 qcdx = NULL;
517         }
518 }
519
520
521 /************************************************************
522 *                                                           *
523 *    check_renderbutton_framerate ( void )                  *
524 *                                                           *
525 *    To keep float framerates consistent between the codec  *
526 *    dialog and frs/sec button.                             *
527 *                                                           *
528 *************************************************************/
529
530 static void check_renderbutton_framerate(void) {
531         OSErr   err;    
532
533         err = SCGetInfo(qcdx->theComponent, scTemporalSettingsType,     &qcdx->gTemporalSettings);
534         CheckError(err, "SCGetInfo error");
535
536         if( (G.scene->r.frs_sec == 24 || G.scene->r.frs_sec == 30 || G.scene->r.frs_sec == 60) &&
537                 (qcdx->gTemporalSettings.frameRate == 1571553 ||
538                  qcdx->gTemporalSettings.frameRate == 1964113 ||
539                  qcdx->gTemporalSettings.frameRate == 3928227)) {;} else
540         qcdx->gTemporalSettings.frameRate = G.scene->r.frs_sec << 16;
541
542         err = SCSetInfo(qcdx->theComponent, scTemporalSettingsType,     &qcdx->gTemporalSettings);
543         CheckError( err, "SCSetInfo error" );
544
545         if(qcdx->gTemporalSettings.frameRate == 1571553) {                      // 23.98 fps
546                 qcdx->kVideoTimeScale = 2398;
547                 qcdx->duration = 100;
548         } else if (qcdx->gTemporalSettings.frameRate == 1964113) {      // 29.97 fps
549                 qcdx->kVideoTimeScale = 2997;
550                 qcdx->duration = 100;
551         } else if (qcdx->gTemporalSettings.frameRate == 3928227) {      // 59.94 fps
552                 qcdx->kVideoTimeScale = 5994;
553                 qcdx->duration = 100;
554         } else {
555                 qcdx->kVideoTimeScale = (qcdx->gTemporalSettings.frameRate >> 16) * 100;
556                 qcdx->duration = 100;
557         }
558 }
559 /********************************************************************
560 *                                                                   *
561 *    get_qtcodec_settings()                                         *
562 *                                                                   *
563 *    Displays Codec Dialog and retrieves Quicktime Codec settings.  *
564 *                                                                   *
565 ********************************************************************/
566
567 int get_qtcodec_settings(void) 
568 {
569         OSErr   err = noErr;
570 //      Component c = 0;
571 //      ComponentDescription cd;
572         CodecInfo ci;
573         char str[255];
574
575 //      cd.componentType = StandardCompressionType;
576 //      cd.componentSubType = StandardCompressionSubType;
577 //      cd.componentManufacturer = 0;
578 //      cd.componentFlags = 0;
579 //      cd.componentFlagsMask = 0;
580
581         if(qcdx == NULL) {
582                 qcdx = MEM_callocN(sizeof(QuicktimeCodecDataExt), "QuicktimeCodecDataExt");
583                 have_qtcodec = FALSE;
584         }
585
586         // configure the standard image compression dialog box
587
588         if (qcdx->theComponent == NULL) {
589                 qcdx->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);
590 //              c = FindNextComponent(c, &cd);
591 //              qcdx->theComponent = OpenComponent(c);
592
593 //              qcdx->gSpatialSettings.codecType = nil;     
594                 qcdx->gSpatialSettings.codec = anyCodec;         
595 //              qcdx->gSpatialSettings.depth;         
596                 qcdx->gSpatialSettings.spatialQuality = codecMaxQuality;
597
598                 qcdx->gTemporalSettings.temporalQuality = codecMaxQuality;
599 //              qcdx->gTemporalSettings.frameRate;      
600                 qcdx->gTemporalSettings.keyFrameRate = 25;   
601
602                 qcdx->aDataRateSetting.dataRate = 90 * 1024;          
603 //              qcdx->aDataRateSetting.frameDuration;     
604 //              qcdx->aDataRateSetting.minSpatialQuality; 
605 //              qcdx->aDataRateSetting.minTemporalQuality;
606
607
608                 err = SCSetInfo(qcdx->theComponent, scTemporalSettingsType,     &qcdx->gTemporalSettings);
609                 CheckError(err, "SCSetInfo1 error");
610                 err = SCSetInfo(qcdx->theComponent, scSpatialSettingsType,      &qcdx->gSpatialSettings);
611                 CheckError(err, "SCSetInfo2 error");
612                 err = SCSetInfo(qcdx->theComponent, scDataRateSettingsType,     &qcdx->aDataRateSetting);
613                 CheckError(err, "SCSetInfo3 error");
614         }
615
616         check_renderbutton_framerate();
617  
618         // put up the dialog box
619
620         err = SCRequestSequenceSettings(qcdx->theComponent);
621  
622         if (err == scUserCancelled) {
623                 G.afbreek = 1;
624                 return 0;
625         }
626
627         have_qtcodec = TRUE;
628
629         // get user selected data
630
631         SCGetInfo(qcdx->theComponent, scTemporalSettingsType,   &qcdx->gTemporalSettings);
632         SCGetInfo(qcdx->theComponent, scSpatialSettingsType,    &qcdx->gSpatialSettings);
633         SCGetInfo(qcdx->theComponent, scDataRateSettingsType,   &qcdx->aDataRateSetting);
634
635         GetCodecInfo (&ci, qcdx->gSpatialSettings.codecType, 0);
636         CopyPascalStringToC(ci.typeName, str);
637         sprintf(qtcdname,"Codec: %s", str);
638
639         // framerate jugglin'
640
641         if(qcdx->gTemporalSettings.frameRate == 1571553) {                      // 23.98 fps
642                 qcdx->kVideoTimeScale = 2398;
643                 qcdx->duration = 100;
644
645                 G.scene->r.frs_sec = 24;
646         } else if (qcdx->gTemporalSettings.frameRate == 1964113) {      // 29.97 fps
647                 qcdx->kVideoTimeScale = 2997;
648                 qcdx->duration = 100;
649
650                 G.scene->r.frs_sec = 30;
651         } else if (qcdx->gTemporalSettings.frameRate == 3928227) {      // 59.94 fps
652                 qcdx->kVideoTimeScale = 5994;
653                 qcdx->duration = 100;
654
655                 G.scene->r.frs_sec = 60;
656         } else {
657                 qcdx->kVideoTimeScale = 600;
658                 qcdx->duration = qcdx->kVideoTimeScale / (qcdx->gTemporalSettings.frameRate / 65536);
659
660                 G.scene->r.frs_sec = (qcdx->gTemporalSettings.frameRate / 65536);
661         }
662
663         return 1;
664 }
665
666 #endif /* _WIN32 || __APPLE__ */
667
668 #endif /* WITH_QUICKTIME */
669
670
671
672 #if 0
673
674 /************************************************************
675 *                                                           *
676 *    References for future codec handling                   *
677 *                                                           *
678 *************************************************************/
679
680 these are from mplayer sourcecode:
681
682 struct ComponentRecord {
683     long                            data[1];
684 };
685 typedef struct ComponentRecord          ComponentRecord;
686 typedef ComponentRecord *               Component;
687 typedef long OSErr;
688 typedef int OSType;
689 typedef long ComponentResult;
690 typedef long                            Fixed;
691
692
693 these are from quicktime:
694
695
696 typedef Component                       CodecComponent;
697 typedef OSType                          CodecType;
698 typedef unsigned short                  CodecFlags;
699 typedef unsigned long                   CodecQ;
700
701 typedef struct {
702    CodecType      codecType;        /* compressor type */
703    CodecComponent codec;            /* compressor */
704    short          depth;            /* pixel depth */
705    CodecQ         spatialQuality;   /* desired quality */
706 } SCSpatialSettings;
707
708 /* temporal options structure with the temporal settings request */
709 typedef struct {
710    CodecQ   temporalQuality;           /* desired quality */
711    Fixed    frameRate;                 /* frame rate */
712    long     keyFrameRate;              /* key frame rate */
713 } SCTemporalSettings;
714
715 /* data rate options with the data rate settings request */
716 typedef struct {
717    long     dataRate;               /* desired data rate */
718    long     frameDuration;          /* frame duration */
719    CodecQ   minSpatialQuality;      /* minimum value */
720    CodecQ   minTemporalQuality;     /* minimum value */
721 } SCDataRateSettings;
722
723
724 would look like this ???
725
726 typedef struct {
727    int                codecType;        /* compressor type */
728 //here is the prob
729    long                  *codec;            /* compressor */
730    short          depth;            /* pixel depth */
731    unsigned long  spatialQuality;   /* desired quality */
732 } SCSpatialSettings;
733
734 /* temporal options structure with the temporal settings request */
735 typedef struct {
736    unsigned long  temporalQuality;  /* desired quality */
737    long           frameRate;        /* frame rate */
738    long           keyFrameRate;     /* key frame rate */
739 } SCTemporalSettings;
740
741 /* data rate options with the data rate settings request */
742 typedef struct {
743    long           dataRate;               /* desired data rate */
744    long           frameDuration;          /* frame duration */
745    unsigned long  minSpatialQuality;      /* minimum value */
746    unsigned long  minTemporalQuality;     /* minimum value */
747 } SCDataRateSettings;
748
749
750 stuff to use quicktime Atoms (doesnt work) heh
751
752         long size;
753         Ptr     thePtr;
754         QTAtomContainer         myContainer = NULL;
755         QTAtom                          myAtom;
756 QTAtomContainer SettingsAtom;
757
758 atom -> component
759 SCSetSettingsFromAtomContainer(qcdx->theComponent, SettingsAtom);
760
761 component -> atom
762 SCGetSettingsAsAtomContainer(qcdx->theComponent, SettingsAtom);
763
764 QTCopyAtomDataToPtr(container, atom, 0, size, &targetPtr, &actualsize);
765 QTGetAtomDataPtr(container, atom, &size, &ptr);
766
767 kParentAtomIsContainer
768 #endif /* 0 */