components.h
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:41k
源码类别:

midi

开发平台:

Unix_Linux

  1. // Basic types:
  2. typedef char *                          Ptr;
  3. typedef Ptr *                           Handle;
  4. typedef int32_t                         Size;
  5. typedef unsigned char                   Boolean;
  6. typedef unsigned char                   Str31[32];
  7. typedef int32_t                         Fixed;
  8. typedef int32_t OSErr;
  9. typedef int OSType;
  10. typedef int32_t ComponentResult;
  11. typedef unsigned char                   UInt8;
  12. typedef signed char                     SInt8;
  13. typedef unsigned short                  UInt16;
  14. typedef signed short                    SInt16;
  15. typedef uint32_t                        UInt32;
  16. typedef int32_t                         SInt32;
  17. #define FOUR_CHAR_CODE(a,b,c,d)       ((uint32_t)(a)<<24 | (uint32_t)(b)<<16 | (uint32_t)(c)<<8 | (uint32_t)(d)) /* otherwise compiler will complain about values with high bit set */
  18. // codec private shit:
  19. typedef void *GlobalsPtr;
  20. typedef void **Globals;
  21. //==================== COMPONENTS ===========================
  22. struct __attribute__((__packed__)) ComponentParameters {
  23.     UInt8                           flags;                      /* call modifiers: sync/async, deferred, immed, etc */
  24.     UInt8                           paramSize;                  /* size in bytes of actual parameters passed to this call */
  25.     short                           what;                       /* routine selector, negative for Component management calls */
  26.     int32_t                         params[1];                  /* actual parameters for the indicated routine */
  27. };
  28. typedef struct ComponentParameters      ComponentParameters;
  29. struct __attribute__((__packed__)) ComponentDescription {
  30.     OSType                          componentType;              /* A unique 4-byte code indentifying the command set */
  31.     OSType                          componentSubType;           /* Particular flavor of this instance */
  32.     OSType                          componentManufacturer;      /* Vendor indentification */
  33.     uint32_t                        componentFlags;             /* 8 each for Component,Type,SubType,Manuf/revision */
  34.     uint32_t                        componentFlagsMask;         /* Mask for specifying which flags to consider in search, zero during registration */
  35. };
  36. typedef struct ComponentDescription     ComponentDescription;
  37. struct __attribute__((__packed__)) ResourceSpec {
  38.     OSType                          resType;                    /* 4-byte code    */
  39.     short                           resID;                      /*         */
  40. };
  41. typedef struct ResourceSpec             ResourceSpec;
  42. struct __attribute__((__packed__)) ComponentResource {
  43.     ComponentDescription            cd;                         /* Registration parameters */
  44.     ResourceSpec                    component;                  /* resource where Component code is found */
  45.     ResourceSpec                    componentName;              /* name string resource */
  46.     ResourceSpec                    componentInfo;              /* info string resource */
  47.     ResourceSpec                    componentIcon;              /* icon resource */
  48. };
  49. typedef struct ComponentResource        ComponentResource;
  50. typedef ComponentResource *             ComponentResourcePtr;
  51. typedef ComponentResourcePtr *          ComponentResourceHandle;
  52. struct __attribute__((__packed__)) ComponentRecord {
  53.     int32_t                            data[1];
  54. };
  55. typedef struct ComponentRecord          ComponentRecord;
  56. typedef ComponentRecord *               Component;
  57. struct __attribute__((__packed__)) ComponentInstanceRecord {
  58.     int32_t                            data[1];
  59. };
  60. typedef struct ComponentInstanceRecord  ComponentInstanceRecord;
  61. typedef ComponentInstanceRecord *       ComponentInstance;
  62. // ========================= QUICKDRAW =========================
  63. struct __attribute__((__packed__)) Rect {
  64.     short                           top;
  65.     short                           left;
  66.     short                           bottom;
  67.     short                           right;
  68. };
  69. typedef struct Rect                     Rect;
  70. typedef Rect *                          RectPtr;
  71. struct __attribute__((__packed__)) RGBColor {
  72.     unsigned short                  red;                        /*magnitude of red component*/
  73.     unsigned short                  green;                      /*magnitude of green component*/
  74.     unsigned short                  blue;                       /*magnitude of blue component*/
  75. };
  76. typedef struct RGBColor                 RGBColor;
  77. typedef RGBColor *                      RGBColorPtr;
  78. typedef RGBColorPtr *                   RGBColorHdl;
  79. struct __attribute__((__packed__)) ColorSpec {
  80.     short                           value;                      /*index or other value*/
  81.     RGBColor                        rgb;                        /*true color*/
  82. };
  83. typedef struct ColorSpec                ColorSpec;
  84. typedef ColorSpec *                     ColorSpecPtr;
  85. typedef ColorSpec                       CSpecArray[1];
  86. struct __attribute__((__packed__)) ColorTable {
  87.     int32_t                         ctSeed;                     /*unique identifier for table*/
  88.     short                           ctFlags;                    /*high bit: 0 = PixMap; 1 = device*/
  89.     short                           ctSize;                     /*number of entries in CTTable*/
  90.     CSpecArray                      ctTable;                    /*array [0..0] of ColorSpec*/
  91. };
  92. typedef struct ColorTable               ColorTable;
  93. typedef ColorTable *                    CTabPtr;
  94. typedef CTabPtr *                       CTabHandle;
  95. struct __attribute__((__packed__)) MatrixRecord {
  96.     Fixed                           matrix[3][3];
  97. };
  98. typedef struct MatrixRecord             MatrixRecord;
  99. typedef MatrixRecord *                  MatrixRecordPtr;
  100. typedef int32_t                         ImageSequence;
  101. typedef OSType                          CodecType;
  102. typedef unsigned short                  CodecFlags;
  103. typedef uint32_t                        CodecQ;
  104. struct __attribute__((__packed__)) ImageDescription {
  105.     int32_t                         idSize;                     /* total size of ImageDescription including extra data ( CLUTs and other per sequence data ) */
  106.     CodecType                       cType;                      /* what kind of codec compressed this data */
  107.     int32_t                         resvd1;                     /* reserved for Apple use */
  108.     short                           resvd2;                     /* reserved for Apple use */
  109.     short                           dataRefIndex;               /* set to zero  */
  110.     short                           version;                    /* which version is this data */
  111.     short                           revisionLevel;              /* what version of that codec did this */
  112.     int32_t                         vendor;                     /* whose  codec compressed this data */
  113.     CodecQ                          temporalQuality;            /* what was the temporal quality factor  */
  114.     CodecQ                          spatialQuality;             /* what was the spatial quality factor */
  115.     short                           width;                      /* how many pixels wide is this data */
  116.     short                           height;                     /* how many pixels high is this data */
  117.     Fixed                           hRes;                       /* horizontal resolution */
  118.     Fixed                           vRes;                       /* vertical resolution */
  119.     int32_t                         dataSize;                   /* if known, the size of data for this image descriptor */
  120.     short                           frameCount;                 /* number of frames this description applies to */
  121.     Str31                           name;                       /* name of codec ( in case not installed )  */
  122.     short                           depth;                      /* what depth is this data (1-32) or ( 33-40 grayscale ) */
  123.     short                           clutID;                     /* clut id or if 0 clut follows  or -1 if no clut */
  124. };
  125. typedef struct ImageDescription         ImageDescription;
  126. typedef ImageDescription *              ImageDescriptionPtr;
  127. typedef ImageDescriptionPtr *           ImageDescriptionHandle;
  128. /* values for PixMap.pixelFormat*/
  129. enum {
  130.     k16LE555PixelFormat         = FOUR_CHAR_CODE('L','5','5','5'),       /* 16 bit LE rgb 555 (PC)*/
  131.     k16LE5551PixelFormat        = FOUR_CHAR_CODE('5','5','5','1'),       /* 16 bit LE rgb 5551*/
  132.     k16BE565PixelFormat         = FOUR_CHAR_CODE('B','5','6','5'),       /* 16 bit BE rgb 565*/
  133.     k16LE565PixelFormat         = FOUR_CHAR_CODE('L','5','6','5'),       /* 16 bit LE rgb 565*/
  134.     k24BGRPixelFormat           = FOUR_CHAR_CODE('2','4','B','G'),       /* 24 bit bgr */
  135.     k32BGRAPixelFormat          = FOUR_CHAR_CODE('B','G','R','A'),       /* 32 bit bgra    (Matrox)*/
  136.     k32ABGRPixelFormat          = FOUR_CHAR_CODE('A','B','G','R'),       /* 32 bit abgr    */
  137.     k32RGBAPixelFormat          = FOUR_CHAR_CODE('R','G','B','A'),       /* 32 bit rgba    */
  138.     kYUVSPixelFormat            = FOUR_CHAR_CODE('y','u','v','s'),       /* YUV 4:2:2 byte ordering 16-unsigned = 'YUY2'*/
  139.     kYUVUPixelFormat            = FOUR_CHAR_CODE('y','u','v','u'),       /* YUV 4:2:2 byte ordering 16-signed*/
  140.     kYVU9PixelFormat            = FOUR_CHAR_CODE('Y','V','U','9'),       /* YVU9 Planar    9*/
  141.     kYUV411PixelFormat          = FOUR_CHAR_CODE('Y','4','1','1'),       /* YUV 4:1:1 Interleaved  16*/
  142.     kYVYU422PixelFormat         = FOUR_CHAR_CODE('Y','V','Y','U'),       /* YVYU 4:2:2 byte ordering   16*/
  143.     kUYVY422PixelFormat         = FOUR_CHAR_CODE('U','Y','V','Y'),       /* UYVY 4:2:2 byte ordering   16*/
  144.     kYUV211PixelFormat          = FOUR_CHAR_CODE('Y','2','1','1'),       /* YUV 2:1:1 Packed   8*/
  145.     k2vuyPixelFormat            = FOUR_CHAR_CODE('2','v','u','y')        /* UYVY 4:2:2 byte ordering   16*/
  146. };
  147. struct __attribute__((__packed__)) PixMapExtension {
  148.     int32_t                         extSize;                    /*size of struct, duh!*/
  149.     uint32_t                        pmBits;                     /*pixmap attributes bitfield*/
  150.     void *                          pmGD;                       /*this is a GDHandle*/
  151.     int32_t                         pmSeed;
  152.     Fixed                           gammaLevel;                 /*pixmap gammalevel*/
  153.     Fixed                           requestedGammaLevel;
  154.     uint32_t                        reserved2;
  155.     int32_t                         longRowBytes;               /*used when rowBytes > 16382*/
  156.     uint32_t                        signature;
  157.     Handle                          baseAddrHandle;
  158. };
  159. typedef struct PixMapExtension          PixMapExtension;
  160. typedef PixMapExtension *               PixMapExtPtr;
  161. typedef PixMapExtPtr *                  PixMapExtHandle;
  162. struct __attribute__((__packed__)) PixMap {
  163.     Ptr                             baseAddr;                   /*pointer to pixels*/
  164.     short                           rowBytes;                   /*offset to next line*/
  165.     Rect                            bounds;                     /*encloses bitmap*/
  166.     short                           pmVersion;                  /*pixMap version number*/
  167.     short                           packType;                   /*defines packing format*/
  168.     int32_t                         packSize;                   /*length of pixel data*/
  169.     Fixed                           hRes;                       /*horiz. resolution (ppi)*/
  170.     Fixed                           vRes;                       /*vert. resolution (ppi)*/
  171.     short                           pixelType;                  /*defines pixel type*/
  172.     short                           pixelSize;                  /*# bits in pixel*/
  173.     short                           cmpCount;                   /*# components in pixel*/
  174.     short                           cmpSize;                    /*# bits per component*/
  175.     OSType                          pixelFormat;                /*fourCharCode representation*/
  176.     CTabHandle                      pmTable;                    /*color map for this pixMap*/
  177.     PixMapExtHandle                 pmExt;                      /*Handle to pixMap extension*/
  178. };
  179. typedef struct PixMap                   PixMap;
  180. typedef PixMap *                        PixMapPtr;
  181. typedef PixMapPtr *                     PixMapHandle;
  182. struct __attribute__((__packed__)) BitMap {
  183.     Ptr                             baseAddr;
  184.     short                           rowBytes;
  185.     Rect                            bounds;
  186. };
  187. typedef struct BitMap                   BitMap;
  188. typedef BitMap *                        BitMapPtr;
  189. typedef BitMapPtr *                     BitMapHandle;
  190. typedef struct OpaqueRgnHandle*         RgnHandle;
  191. struct Pattern {
  192.     UInt8                           pat[8];
  193. };
  194. typedef struct Pattern                  Pattern;
  195. typedef unsigned char                   Style;
  196. typedef Style                           StyleField;
  197. struct __attribute__((__packed__)) Point {
  198.     short                           v;
  199.     short                           h;
  200. };
  201. typedef struct Point                    Point;
  202. struct __attribute__((__packed__)) GrafPort {
  203.     short                           device;
  204.     BitMap                          portBits;
  205.     Rect                            portRect;
  206.     RgnHandle                       visRgn;
  207.     RgnHandle                       clipRgn;
  208.     Pattern                         bkPat;
  209.     Pattern                         fillPat;
  210.     Point                           pnLoc;
  211.     Point                           pnSize;
  212.     short                           pnMode;
  213.     Pattern                         pnPat;
  214.     short                           pnVis;
  215.     short                           txFont;
  216.     StyleField                      txFace;                     /*StyleField occupies 16-bits, but only first 8-bits are used*/
  217.     UInt8                           txFlags;                    /* QuickTime uses second 8 bits of StyleField for txFlags */
  218.     short                           txMode;
  219.     short                           txSize;
  220.     Fixed                           spExtra;
  221.     int32_t                         fgColor;
  222.     int32_t                         bkColor;
  223.     short                           colrBit;
  224.     short                           patStretch;
  225.     Handle                          picSave;
  226.     Handle                          rgnSave;
  227.     Handle                          polySave;
  228.     /*QDProcsPtr*/void*                      grafProcs;
  229. };
  230. typedef struct GrafPort                 GrafPort;
  231. typedef GrafPort *GWorldPtr;
  232. typedef GWorldPtr *GWorldHandle;
  233. #define anyCodec                ((CodecComponent)0)
  234. enum {
  235.                                                                 /* transfer modes */
  236.     srcCopy                     = 0,                            /*the 16 transfer modes*/
  237.     srcOr                       = 1,
  238.     srcXor                      = 2,
  239.     srcBic                      = 3,
  240.     notSrcCopy                  = 4,
  241.     notSrcOr                    = 5,
  242.     notSrcXor                   = 6,
  243.     notSrcBic                   = 7,
  244.     patCopy                     = 8,
  245.     patOr                       = 9,
  246.     patXor                      = 10,
  247.     patBic                      = 11,
  248.     notPatCopy                  = 12,
  249.     notPatOr                    = 13,
  250.     notPatXor                   = 14,
  251.     notPatBic                   = 15,                           /* Special Text Transfer Mode */
  252.     grayishTextOr               = 49,
  253.     hilitetransfermode          = 50,
  254.     hilite                      = 50,                           /* Arithmetic transfer modes */
  255.     blend                       = 32,
  256.     addPin                      = 33,
  257.     addOver                     = 34,
  258.     subPin                      = 35,
  259.     addMax                      = 37,
  260.     adMax                       = 37,
  261.     subOver                     = 38,
  262.     adMin                       = 39,
  263.     ditherCopy                  = 64,                           /* Transparent mode constant */
  264.     transparent                 = 36
  265. };
  266. typedef uint32_t                   GWorldFlags;
  267. // ============================== CODECS ===========================
  268. typedef Component                       CompressorComponent;
  269. typedef Component                       DecompressorComponent;
  270. typedef Component                       CodecComponent;
  271. enum {
  272.     codecLosslessQuality        = 0x00000400,
  273.     codecMaxQuality             = 0x000003FF,
  274.     codecMinQuality             = 0x00000000,
  275.     codecLowQuality             = 0x00000100,
  276.     codecNormalQuality          = 0x00000200,
  277.     codecHighQuality            = 0x00000300
  278. };
  279. // callbacks:
  280. typedef void* ImageCodecDrawBandCompleteUPP;
  281. typedef int64_t ICMProgressProcRecord;
  282. typedef int64_t ICMCompletionProcRecord;
  283. typedef ICMCompletionProcRecord* ICMCompletionProcRecordPtr;
  284. typedef int64_t ICMDataProcRecord;
  285. typedef void* ICMFrameTimePtr;
  286. typedef void* CDSequenceDataSourcePtr;
  287. typedef void* ICMFrameTimeInfoPtr;
  288. // graphics port
  289. typedef struct OpaqueGrafPtr*           GrafPtr;
  290. typedef GrafPtr                         CGrafPtr;
  291. /*  codec capabilities flags    */
  292. enum {
  293.     codecCanScale               = 1L << 0, // 1
  294.     codecCanMask                = 1L << 1, // 2
  295.     codecCanMatte               = 1L << 2, // 4
  296.     codecCanTransform           = 1L << 3, // 8
  297.     codecCanTransferMode        = 1L << 4, // 10
  298.     codecCanCopyPrev            = 1L << 5, // 20
  299.     codecCanSpool               = 1L << 6, // 40
  300.     codecCanClipVertical        = 1L << 7, // 80
  301.     codecCanClipRectangular     = 1L << 8, // 100
  302.     codecCanRemapColor          = 1L << 9, // 200
  303.     codecCanFastDither          = 1L << 10, // 400
  304.     codecCanSrcExtract          = 1L << 11, // 800
  305.     codecCanCopyPrevComp        = 1L << 12, // 1000
  306.     codecCanAsync               = 1L << 13, // 2000
  307.     codecCanMakeMask            = 1L << 14, // 4000
  308.     codecCanShift               = 1L << 15, // 8000
  309.     codecCanAsyncWhen           = 1L << 16, // 10000
  310.     codecCanShieldCursor        = 1L << 17, // 20000
  311.     codecCanManagePrevBuffer    = 1L << 18, // 40000
  312.     codecHasVolatileBuffer      = 1L << 19,     // 80000                /* codec requires redraw after window movement */
  313.     codecWantsRegionMask        = 1L << 20, // 100000
  314.     codecImageBufferIsOnScreen  = 1L << 21,     // 200000                /* old def of codec using overlay surface, = ( codecIsDirectToScreenOnly | codecUsesOverlaySurface | codecImageBufferIsOverlaySurface | codecSrcMustBeImageBuffer ) */
  315.     codecWantsDestinationPixels = 1L << 22,     // 400000
  316.     codecWantsSpecialScaling    = 1L << 23,     // 800000
  317.     codecHandlesInputs          = 1L << 24, // 1000000
  318.     codecCanDoIndirectSurface   = 1L << 25,                     /* codec can handle indirect surface (GDI) */
  319.     codecIsSequenceSensitive    = 1L << 26,
  320.     codecRequiresOffscreen      = 1L << 27,
  321.     codecRequiresMaskBits       = 1L << 28,
  322.     codecCanRemapResolution     = 1L << 29,
  323.     codecIsDirectToScreenOnly   = 1L << 30,                     /* codec can only decompress data to the screen */
  324.     codecCanLockSurface         = 1L << 31                      /* codec can lock destination surface, icm doesn't lock for you */
  325. };
  326. /*  codec capabilities flags2   */
  327. enum {
  328.     codecUsesOverlaySurface     = 1L << 0,                      /* codec uses overlay surface */
  329.     codecImageBufferIsOverlaySurface = 1L << 1,                 /* codec image buffer is overlay surface, the bits in the buffer are on the screen */
  330.     codecSrcMustBeImageBuffer   = 1L << 2,                      /* codec can only source data from an image buffer */
  331.     codecImageBufferIsInAGPMemory = 1L << 4,                    /* codec image buffer is in AGP space, byte writes are OK */
  332.     codecImageBufferIsInPCIMemory = 1L << 5                     /* codec image buffer is across a PCI bus; byte writes are bad */
  333. };
  334. /*  codec condition flags   */
  335. // FFD =  13 = 8+4+1
  336. enum {
  337.     codecConditionFirstBand     = 1L << 0, // 1
  338.     codecConditionLastBand      = 1L << 1, // 2
  339.     codecConditionFirstFrame    = 1L << 2, // 4
  340.     codecConditionNewDepth      = 1L << 3, // 8
  341.     codecConditionNewTransform  = 1L << 4, // 10
  342.     codecConditionNewSrcRect    = 1L << 5, // 20
  343.     codecConditionNewMask       = 1L << 6, // 40
  344.     codecConditionNewMatte      = 1L << 7, // 80
  345.     codecConditionNewTransferMode = 1L << 8, // 100
  346.     codecConditionNewClut       = 1L << 9, // 200
  347.     codecConditionNewAccuracy   = 1L << 10, // 400
  348.     codecConditionNewDestination = 1L << 11, // 800
  349.     codecConditionFirstScreen   = 1L << 12, // 1000
  350.     codecConditionDoCursor      = 1L << 13, // 2000
  351.     codecConditionCatchUpDiff   = 1L << 14, // 4000
  352.     codecConditionMaskMayBeChanged = 1L << 15, // 8000
  353.     codecConditionToBuffer      = 1L << 16, // 10000
  354.     codecConditionCodecChangedMask = 1L << 31 // 20000
  355. };
  356. struct __attribute__((__packed__)) CodecCapabilities {
  357.     int32_t                         flags;
  358.     short                           wantedPixelSize;
  359.     short                           extendWidth;
  360.     short                           extendHeight;
  361.     short                           bandMin;
  362.     short                           bandInc;
  363.     short                           pad;
  364.     uint32_t                        time;
  365.     int32_t                         flags2;                     /* field new in QuickTime 4.0 */
  366. };
  367. typedef struct CodecCapabilities        CodecCapabilities;
  368. struct __attribute__((__packed__)) CodecDecompressParams {
  369.     ImageSequence                   sequenceID;                 /* predecompress,banddecompress */
  370.     ImageDescriptionHandle          imageDescription;           /* predecompress,banddecompress */
  371.     Ptr                             data;
  372.     int32_t                         bufferSize;
  373.     int32_t                         frameNumber;
  374.     int32_t                         startLine;
  375.     int32_t                         stopLine;
  376.     int32_t                         conditionFlags;
  377.     CodecFlags                      callerFlags; // short
  378.     CodecCapabilities *             capabilities;               /* predecompress,banddecompress */
  379.     ICMProgressProcRecord           progressProcRecord;
  380.     ICMCompletionProcRecord         completionProcRecord;
  381.     ICMDataProcRecord               dataProcRecord;
  382.     CGrafPtr                        port;                       /* predecompress,banddecompress */
  383.     PixMap                          dstPixMap;                  /* predecompress,banddecompress */
  384.     BitMapPtr                       maskBits;
  385.     PixMapPtr                       mattePixMap;
  386.     Rect                            srcRect;                    /* predecompress,banddecompress */
  387.     MatrixRecord *                  matrix;                     /* predecompress,banddecompress */
  388.     CodecQ                          accuracy;                   /* predecompress,banddecompress */
  389.     short                           transferMode;               /* predecompress,banddecompress */
  390.     ICMFrameTimePtr                 frameTime;                  /* banddecompress */
  391.     int32_t                         reserved[1];
  392.                                                                 /* The following fields only exist for QuickTime 2.0 and greater */
  393.     SInt8                           matrixFlags;                /* high bit set if 2x resize */
  394.     SInt8                           matrixType;
  395.     Rect                            dstRect;                    /* only valid for simple transforms */
  396.                                                                 /* The following fields only exist for QuickTime 2.1 and greater */
  397.     UInt16                          majorSourceChangeSeed;
  398.     UInt16                          minorSourceChangeSeed;
  399.     CDSequenceDataSourcePtr         sourceData;
  400.     RgnHandle                       maskRegion;
  401.                                                                 /* The following fields only exist for QuickTime 2.5 and greater */
  402.     OSType **                       wantedDestinationPixelTypes; /* Handle to 0-terminated list of OSTypes */
  403.     int32_t                         screenFloodMethod;
  404.     int32_t                         screenFloodValue;
  405.     short                           preferredOffscreenPixelSize;
  406.                                                                 /* The following fields only exist for QuickTime 3.0 and greater */
  407.     ICMFrameTimeInfoPtr             syncFrameTime;              /* banddecompress */
  408.     Boolean                         needUpdateOnTimeChange;     /* banddecompress */
  409.     Boolean                         enableBlackLining;
  410.     Boolean                         needUpdateOnSourceChange;   /* band decompress */
  411.     Boolean                         pad;
  412.     int32_t                         unused;
  413.     CGrafPtr                        finalDestinationPort;
  414.     int32_t                         requestedBufferWidth;       /* must set codecWantsSpecialScaling to indicate this field is valid*/
  415.     int32_t                         requestedBufferHeight;      /* must set codecWantsSpecialScaling to indicate this field is valid*/
  416.                                                                 /* The following fields only exist for QuickTime 4.0 and greater */
  417.     Rect                            displayableAreaOfRequestedBuffer; /* set in predecompress*/
  418.     Boolean                         requestedSingleField;
  419.     Boolean                         needUpdateOnNextIdle;
  420.     Boolean                         pad2[2];
  421.     Fixed                           bufferGammaLevel;
  422.                                                                 /* The following fields only exist for QuickTime 5.0 and greater */
  423.     UInt32                          taskWeight;                 /* preferred weight for MP tasks implementing this operation*/
  424.     OSType                          taskName;                   /* preferred name (type) for MP tasks implementing this operation*/
  425. };
  426. typedef struct CodecDecompressParams    CodecDecompressParams;
  427. struct __attribute__((__packed__)) ImageSubCodecDecompressCapabilities {
  428.     int32_t                         recordSize;                 /* sizeof(ImageSubCodecDecompressCapabilities)*/
  429.     int32_t                         decompressRecordSize;       /* size of your codec's decompress record*/
  430.     Boolean                         canAsync;                   /* default true*/
  431.     UInt8                           pad0;
  432.                                                                 /* The following fields only exist for QuickTime 4.0 and greater */
  433.     UInt16                          suggestedQueueSize;
  434.     Boolean                         canProvideTrigger;
  435.                                                                 /* The following fields only exist for QuickTime 5.0 and greater */
  436.     Boolean                         subCodecFlushesScreen;      /* only used on Mac OS X*/
  437.     Boolean                         subCodecCallsDrawBandComplete;
  438.     UInt8                           pad2[1];
  439.                                                                 /* The following fields only exist for QuickTime 5.1 and greater */
  440.     Boolean                         isChildCodec;               /* set by base codec before calling Initialize*/
  441.     UInt8                           pad3[3];
  442. };
  443. typedef struct ImageSubCodecDecompressCapabilities ImageSubCodecDecompressCapabilities;
  444. struct __attribute__((__packed__)) ImageSubCodecDecompressRecord {
  445.     Ptr                             baseAddr;
  446.     int32_t                         rowBytes;
  447.     Ptr                             codecData;
  448.     ICMProgressProcRecord           progressProcRecord;
  449.     ICMDataProcRecord               dataProcRecord;
  450.     void *                          userDecompressRecord;       /* pointer to codec-specific per-band data*/
  451.     UInt8                           frameType;
  452.     Boolean                         inhibitMP;                  /* set this in BeginBand to tell the base decompressor not to call DrawBand from an MP task for this frame.  (Only has any effect for MP-capable subcodecs.  New in QuickTime 5.0.)*/
  453.     UInt8                           pad[2];
  454.     int32_t                         priv[2];
  455.                                                                 /* The following fields only exist for QuickTime 5.0 and greater */
  456.     ImageCodecDrawBandCompleteUPP   drawBandCompleteUPP;        /* only used if subcodec set subCodecCallsDrawBandComplete; if drawBandCompleteUPP is non-nil, codec must call it when a frame is finished, but may return from DrawBand before the frame is finished. */
  457.     void *                          drawBandCompleteRefCon;     /* Note: do not call drawBandCompleteUPP directly from a hardware interrupt; instead, use DTInstall to run a function at deferred task time, and call drawBandCompleteUPP from that. */
  458. };
  459. typedef struct ImageSubCodecDecompressRecord ImageSubCodecDecompressRecord;
  460. /* These are the bits that are set in the Component flags, and also in the codecInfo struct. */
  461. enum {
  462.     codecInfoDoes1              = (1L << 0),                    /* codec can work with 1-bit pixels */
  463.     codecInfoDoes2              = (1L << 1),                    /* codec can work with 2-bit pixels */
  464.     codecInfoDoes4              = (1L << 2),                    /* codec can work with 4-bit pixels */
  465.     codecInfoDoes8              = (1L << 3),                    /* codec can work with 8-bit pixels */
  466.     codecInfoDoes16             = (1L << 4),                    /* codec can work with 16-bit pixels */
  467.     codecInfoDoes32             = (1L << 5),                    /* codec can work with 32-bit pixels */
  468.     codecInfoDoesDither         = (1L << 6),                    /* codec can do ditherMode */
  469.     codecInfoDoesStretch        = (1L << 7),                    /* codec can stretch to arbitrary sizes */
  470.     codecInfoDoesShrink         = (1L << 8),                    /* codec can shrink to arbitrary sizes */
  471.     codecInfoDoesMask           = (1L << 9),                    /* codec can mask to clipping regions */
  472.     codecInfoDoesTemporal       = (1L << 10),                   /* codec can handle temporal redundancy */
  473.     codecInfoDoesDouble         = (1L << 11),                   /* codec can stretch to double size exactly */
  474.     codecInfoDoesQuad           = (1L << 12),                   /* codec can stretch to quadruple size exactly */
  475.     codecInfoDoesHalf           = (1L << 13),                   /* codec can shrink to half size */
  476.     codecInfoDoesQuarter        = (1L << 14),                   /* codec can shrink to quarter size */
  477.     codecInfoDoesRotate         = (1L << 15),                   /* codec can rotate on decompress */
  478.     codecInfoDoesHorizFlip      = (1L << 16),                   /* codec can flip horizontally on decompress */
  479.     codecInfoDoesVertFlip       = (1L << 17),                   /* codec can flip vertically on decompress */
  480.     codecInfoHasEffectParameterList = (1L << 18),               /* codec implements get effects parameter list call, once was codecInfoDoesSkew */
  481.     codecInfoDoesBlend          = (1L << 19),                   /* codec can blend on decompress */
  482.     codecInfoDoesWarp           = (1L << 20),                   /* codec can warp arbitrarily on decompress */
  483.     codecInfoDoesRecompress     = (1L << 21),                   /* codec can recompress image without accumulating errors */
  484.     codecInfoDoesSpool          = (1L << 22),                   /* codec can spool image data */
  485.     codecInfoDoesRateConstrain  = (1L << 23)                    /* codec can data rate constrain */
  486. };
  487. enum {
  488.     codecInfoDepth1             = (1L << 0),                    /* compressed data at 1 bpp depth available */
  489.     codecInfoDepth2             = (1L << 1),                    /* compressed data at 2 bpp depth available */
  490.     codecInfoDepth4             = (1L << 2),                    /* compressed data at 4 bpp depth available */
  491.     codecInfoDepth8             = (1L << 3),                    /* compressed data at 8 bpp depth available */
  492.     codecInfoDepth16            = (1L << 4),                    /* compressed data at 16 bpp depth available */
  493.     codecInfoDepth32            = (1L << 5),                    /* compressed data at 32 bpp depth available */
  494.     codecInfoDepth24            = (1L << 6),                    /* compressed data at 24 bpp depth available */
  495.     codecInfoDepth33            = (1L << 7),                    /* compressed data at 1 bpp monochrome depth  available */
  496.     codecInfoDepth34            = (1L << 8),                    /* compressed data at 2 bpp grayscale depth available */
  497.     codecInfoDepth36            = (1L << 9),                    /* compressed data at 4 bpp grayscale depth available */
  498.     codecInfoDepth40            = (1L << 10),                   /* compressed data at 8 bpp grayscale depth available */
  499.     codecInfoStoresClut         = (1L << 11),                   /* compressed data can have custom cluts */
  500.     codecInfoDoesLossless       = (1L << 12),                   /* compressed data can be stored in lossless format */
  501.     codecInfoSequenceSensitive  = (1L << 13)                    /* compressed data is sensitive to out of sequence decoding */
  502. };
  503. struct __attribute__((__packed__)) CodecInfo {
  504.     Str31                           typeName;                   /* name of the codec type i.e.: 'Apple Image Compression' */
  505.     short                           version;                    /* version of the codec data that this codec knows about */
  506.     short                           revisionLevel;              /* revision level of this codec i.e: 0x00010001 (1.0.1) */
  507.     int32_t                         vendor;                     /* Maker of this codec i.e: 'appl' */
  508.     int32_t                         decompressFlags;            /* codecInfo flags for decompression capabilities */
  509.     int32_t                         compressFlags;              /* codecInfo flags for compression capabilities */
  510.     int32_t                         formatFlags;                /* codecInfo flags for compression format details */
  511.     UInt8                           compressionAccuracy;        /* measure (1-255) of accuracy of this codec for compress (0 if unknown) */
  512.     UInt8                           decompressionAccuracy;      /* measure (1-255) of accuracy of this codec for decompress (0 if unknown) */
  513.     unsigned short                  compressionSpeed;           /* ( millisecs for compressing 320x240 on base mac II) (0 if unknown)  */
  514.     unsigned short                  decompressionSpeed;         /* ( millisecs for decompressing 320x240 on mac II)(0 if unknown)  */
  515.     UInt8                           compressionLevel;           /* measure (1-255) of compression level of this codec (0 if unknown)  */
  516.     UInt8                           resvd;                      /* pad */
  517.     short                           minimumHeight;              /* minimum height of image (block size) */
  518.     short                           minimumWidth;               /* minimum width of image (block size) */
  519.     short                           decompressPipelineLatency;  /* in milliseconds ( for asynchronous codecs ) */
  520.     short                           compressPipelineLatency;    /* in milliseconds ( for asynchronous codecs ) */
  521.     int32_t                         privateData;
  522. };
  523. typedef struct CodecInfo                CodecInfo;
  524. enum {
  525.     codecFlagUseImageBuffer     = (1L << 0),                    /* decompress*/
  526.     codecFlagUseScreenBuffer    = (1L << 1),                    /* decompress*/
  527.     codecFlagUpdatePrevious     = (1L << 2),                    /* compress*/
  528.     codecFlagNoScreenUpdate     = (1L << 3),                    /* decompress*/
  529.     codecFlagWasCompressed      = (1L << 4),                    /* compress*/
  530.     codecFlagDontOffscreen      = (1L << 5),                    /* decompress*/
  531.     codecFlagUpdatePreviousComp = (1L << 6),                    /* compress*/
  532.     codecFlagForceKeyFrame      = (1L << 7),                    /* compress*/
  533.     codecFlagOnlyScreenUpdate   = (1L << 8),                    /* decompress*/
  534.     codecFlagLiveGrab           = (1L << 9),                    /* compress*/
  535.     codecFlagDiffFrame          = (1L << 9),                    /* decompress*/
  536.     codecFlagDontUseNewImageBuffer = (1L << 10),                /* decompress*/
  537.     codecFlagInterlaceUpdate    = (1L << 11),                   /* decompress*/
  538.     codecFlagCatchUpDiff        = (1L << 12),                   /* decompress*/
  539.     codecFlagSupportDisable     = (1L << 13),                   /* decompress*/
  540.     codecFlagReenable           = (1L << 14)                    /* decompress*/
  541. };
  542. static inline void dump_ImageDescription(void* xxx){
  543.     ImageDescription* id=(ImageDescription*)xxx;
  544.     unsigned char* x;
  545.     int i;
  546.     for(i=0;i<id->idSize;i++){
  547. printf(" %02X",((unsigned char*)id)[i]);
  548. if((i%16)==15) printf("n");
  549.     }
  550.     printf("n");
  551.     printf("=============== ImageDescription at %p ==================n",xxx);
  552.     printf("idSize=0x%X  fourcc=0x%08Xn",id->idSize,id->cType);
  553.     printf("ver=%d rev=%d vendor=0x%08Xn",id->version,id->revisionLevel,id->vendor);
  554.     printf("tempQ=%d spatQ=%d  dim: %d x %d  dpi: %d x %d  depth: %dn",
  555. id->temporalQuality,id->spatialQuality,
  556. id->width, id->height,
  557. id->hRes, id->vRes,
  558. id->depth);
  559.     printf("dataSize=%d frameCount=%d clutID=%dn",id->dataSize, id->frameCount, id->clutID);
  560.     printf("name='%.*s'n",((char*)(&id->name))[0],((char*)(&id->name))+1);
  561.     x=((char*)(&id->clutID))+2;
  562.     if(id->idSize>sizeof(ImageDescription)){
  563. printf("%02X %02X %02X %02X | %02X %02X %02X %02X | %02X %02X %02X %02X | %02X %02X %02X %02Xn",
  564. x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9],x[10],x[11],x[12],x[13],x[14],x[15]);
  565.     }
  566.     printf("=========================================================n");
  567. }
  568. static inline void dump_Rect(char* title,Rect *r){
  569.     printf("%s: %d;%d - %d;%dn",title,
  570.         (int)r->top,(int)r->left,(int)r->bottom,(int)r->right);
  571. }
  572. static inline void dump_MatrixRecord(char* title, MatrixRecord *m){
  573.     printf("%s: [%d %d %d][%d %d %d][%d %d %d]n",title,
  574. m->matrix[0][0],m->matrix[0][1],m->matrix[0][2],
  575. m->matrix[1][0],m->matrix[1][1],m->matrix[1][2],
  576. m->matrix[2][0],m->matrix[2][1],m->matrix[2][2]);
  577. }
  578. static inline void dump_PixMap(void* xxx){
  579.     PixMap *p=xxx;
  580.     printf("=============== PixMap at %p ==================n",xxx);
  581.     printf("base=%p  stride=%dn",p->baseAddr, p->rowBytes);
  582.     dump_Rect("bounds",&p->bounds);
  583.     printf("pmVersion=0x%X packType=0x%Xn packSize=0x%Xn",
  584. p->pmVersion,p->packType, p->packSize);
  585.     printf("hRes=0x%X vRes=0x%X pixelType=0x%X pixelSize=0x%Xn",
  586. p->hRes,p->vRes,p->pixelType,p->pixelSize);
  587.     printf("cmpCount=0x%X cmpSize=0x%X pixelFormat=0x%Xn",
  588. p->cmpCount,p->cmpSize,p->pixelFormat);
  589.     printf("pmTable=%p pmExt=%pn",p->pmTable,p->pmExt);
  590.     printf("=========================================================n");
  591. }
  592. static inline void dump_CodecCapabilities(void* xxx){
  593.     CodecCapabilities* cc=xxx;
  594.     if(!xxx) return;
  595.     printf("=============== CodecCapabilities at %p =================n",xxx);
  596.     printf("flags=0x%X  flags2=0x%Xn",cc->flags,cc->flags2);
  597.     printf("wantedPixelSize=%d extendWidth=%d extendHeight=%d band=%d+%dn",
  598. cc->wantedPixelSize,cc->extendWidth,cc->extendHeight,
  599. cc->bandMin,cc->bandInc);
  600.     printf("pad=0x%X  time=0x%Xn",cc->pad,cc->time);
  601.     printf("=========================================================n");
  602. }
  603. static inline void dump_CodecDecompressParams(void* xxx){
  604.     CodecDecompressParams* cd=xxx;
  605.     ImageDescription **idh;
  606.     int i;
  607.     if(!xxx) return;
  608.     printf("=============== CodecDecompressParams at %p ==================n",xxx);
  609.     printf("sequenceID=%dn",cd->sequenceID);
  610.     idh=cd->imageDescription;
  611.     if(idh && idh[0]) dump_ImageDescription(idh[0]);
  612.     
  613.     for(i=0;i<sizeof(CodecDecompressParams);i++){
  614. printf(" %02X",((unsigned char*)cd)[i]);
  615. if((i%16)==15) printf("n");
  616.     }
  617.     printf("n");
  618.     
  619.     printf("data=%p  size=%dn",cd->data,cd->bufferSize);
  620.     printf("frameno=%d  lines: %d .. %d   condflags=0x%X  callerflags=0x%Xn",
  621. cd->frameNumber, cd->startLine, cd->stopLine, cd->conditionFlags,cd->callerFlags);
  622. //    printf("maskBits=%p mattePixMap=%pn",
  623. // cd->maskBits,cd->mattePixMap);
  624.     dump_PixMap(&cd->dstPixMap);
  625. //    if(cd->mattePixMap) dump_PixMap(cd->mattePixMap);
  626.     if(cd->matrix) dump_MatrixRecord("matrix",cd->matrix);
  627.     if(cd->capabilities) dump_CodecCapabilities(cd->capabilities);
  628.     printf("accuracy=%d  transferMode=%d  matrixFlags=0x%X matrixType=%dn",
  629. (int)cd->accuracy, (int)cd->transferMode, (int)cd->matrixFlags, (int)cd->matrixType);
  630.     printf("srcrect: %d;%d - %d;%dn",cd->srcRect.top,cd->srcRect.left,cd->srcRect.bottom,cd->srcRect.right);
  631.     printf("dstrect: %d;%d - %d;%dn",cd->dstRect.top,cd->dstRect.left,cd->dstRect.bottom,cd->dstRect.right);
  632.     printf("wantedDestinationPixelTypes=%pn",cd->wantedDestinationPixelTypes);
  633.     if(cd->wantedDestinationPixelTypes){
  634. unsigned int* p=cd->wantedDestinationPixelTypes;
  635. while(p[0]){
  636.     printf("  0x%08X %.4sn",p[0],&p[0]);
  637.     ++p;
  638. }
  639.     }
  640.     printf("screenFloodMethod=%d value=%d  preferredOffscreenPixelSize=%dn",
  641. cd->screenFloodMethod, cd->screenFloodValue, cd->preferredOffscreenPixelSize);
  642.     printf("callbacks: progress=%p compl=%p data=%p ftime=%p srcdata=%p sync=%pn",
  643.      cd->progressProcRecord, cd->completionProcRecord,
  644.      cd->dataProcRecord, cd->frameTime, cd->sourceData, cd->syncFrameTime);
  645. //    printf("n");
  646.     printf("=========================================================n");
  647. }