home *** CD-ROM | disk | FTP | other *** search
/ Geek 6 / Geek-006.iso / linux / video / xmovie-1.5.3.tar.gz / xmovie-1.5.3.tar / xmovie-1.5.3 / quicktime / private.h < prev    next >
C/C++ Source or Header  |  2000-11-29  |  9KB  |  550 lines

  1. #ifndef PRIVATE_H
  2. #define PRIVATE_H
  3.  
  4. /* ================================= structures */
  5.  
  6. #define HEADER_LENGTH 8
  7. #define MAXTRACKS 1024
  8.  
  9. #include "codecs.h"
  10. #include "sizes.h"
  11.  
  12. typedef struct
  13. {
  14.     float values[9];
  15. } quicktime_matrix_t;
  16.  
  17.  
  18. typedef struct
  19. {
  20.     int version;
  21.     long flags;
  22.     unsigned long creation_time;
  23.     unsigned long modification_time;
  24.     int track_id;
  25.     long reserved1;
  26.     long duration;
  27.     char reserved2[8];
  28.     int layer;
  29.     int alternate_group;
  30.     float volume;
  31.     long reserved3;
  32.     quicktime_matrix_t matrix;
  33.     float track_width;
  34.     float track_height;
  35. } quicktime_tkhd_t;
  36.  
  37.  
  38. typedef struct
  39. {
  40.     long seed;
  41.     long flags;
  42.     long size;
  43.     short int *alpha;
  44.     short int *red;
  45.     short int *green;
  46.     short int *blue;
  47. } quicktime_ctab_t;
  48.  
  49.  
  50.  
  51. /* ===================== sample table ======================== // */
  52.  
  53.  
  54.  
  55. /* sample description */
  56.  
  57. typedef struct
  58. {
  59.     int motion_jpeg_quantization_table;
  60. } quicktime_mjqt_t;
  61.  
  62.  
  63. typedef struct
  64. {
  65.     int motion_jpeg_huffman_table;
  66. } quicktime_mjht_t;
  67.  
  68.  
  69. typedef struct
  70. {
  71.     char format[4];
  72.     char reserved[6];
  73.     int data_reference;
  74.  
  75. /* common to audio and video */
  76.     int version;
  77.     int revision;
  78.     char vendor[4];
  79.  
  80. /* video description */
  81.     long temporal_quality;
  82.     long spatial_quality;
  83.     int width;
  84.     int height;
  85.     float dpi_horizontal;
  86.     float dpi_vertical;
  87.     long data_size;
  88.     int frames_per_sample;
  89.     char compressor_name[32];
  90.     int depth;
  91.     int ctab_id;
  92.     quicktime_ctab_t ctab;
  93.     float gamma;
  94.     int fields;    /* 0, 1, or 2 */
  95.     int field_dominance;   /* 0 - unknown     1 - top first     2 - bottom first */
  96.     quicktime_mjqt_t mjqt;
  97.     quicktime_mjht_t mjht;
  98.  
  99. /* audio description */
  100.     int channels;
  101.     int sample_size;
  102.     int compression_id;
  103.     int packet_size;
  104.     float sample_rate;
  105. } quicktime_stsd_table_t;
  106.  
  107.  
  108. typedef struct
  109. {
  110.     int version;
  111.     long flags;
  112.     long total_entries;
  113.     quicktime_stsd_table_t *table;
  114. } quicktime_stsd_t;
  115.  
  116.  
  117. /* time to sample */
  118. typedef struct
  119. {
  120.     long sample_count;
  121.     long sample_duration;
  122. } quicktime_stts_table_t;
  123.  
  124. typedef struct
  125. {
  126.     int version;
  127.     long flags;
  128.     long total_entries;
  129.     quicktime_stts_table_t *table;
  130. } quicktime_stts_t;
  131.  
  132.  
  133. /* sync sample */
  134. typedef struct
  135. {
  136.     long sample;
  137. } quicktime_stss_table_t;
  138.  
  139. typedef struct
  140. {
  141.     int version;
  142.     long flags;
  143.     long total_entries;
  144.     quicktime_stss_table_t *table;
  145. } quicktime_stss_t;
  146.  
  147.  
  148. /* sample to chunk */
  149. typedef struct
  150. {
  151.     long chunk;
  152.     long samples;
  153.     long id;
  154. } quicktime_stsc_table_t;
  155.  
  156. typedef struct
  157. {
  158.     int version;
  159.     long flags;
  160.     long total_entries;
  161.     
  162.     long entries_allocated;
  163.     quicktime_stsc_table_t *table;
  164. } quicktime_stsc_t;
  165.  
  166.  
  167. /* sample size */
  168. typedef struct
  169. {
  170.     long size;
  171. } quicktime_stsz_table_t;
  172.  
  173. typedef struct
  174. {
  175.     int version;
  176.     long flags;
  177.     long sample_size;
  178.     long total_entries;
  179.  
  180.     long entries_allocated;    /* used by the library for allocating a table */
  181.     quicktime_stsz_table_t *table;
  182. } quicktime_stsz_t;
  183.  
  184.  
  185. /* chunk offset */
  186. typedef struct
  187. {
  188.     long offset;
  189. } quicktime_stco_table_t;
  190.  
  191. typedef struct
  192. {
  193.     int version;
  194.     long flags;
  195.     long total_entries;
  196.     
  197.     long entries_allocated;    /* used by the library for allocating a table */
  198.     quicktime_stco_table_t *table;
  199. } quicktime_stco_t;
  200.  
  201.  
  202. /* sample table */
  203. typedef struct
  204. {
  205.     int version;
  206.     long flags;
  207.     quicktime_stsd_t stsd;
  208.     quicktime_stts_t stts;
  209.     quicktime_stss_t stss;
  210.     quicktime_stsc_t stsc;
  211.     quicktime_stsz_t stsz;
  212.     quicktime_stco_t stco;
  213. } quicktime_stbl_t;
  214.  
  215. /* data reference */
  216.  
  217. typedef struct
  218. {
  219.     long size;
  220.     char type[4];
  221.     int version;
  222.     long flags;
  223.     char *data_reference;
  224. } quicktime_dref_table_t;
  225.  
  226. typedef struct
  227. {
  228.     int version;
  229.     long flags;
  230.     long total_entries;
  231.     quicktime_dref_table_t *table;
  232. } quicktime_dref_t;
  233.  
  234. /* data information */
  235.  
  236. typedef struct
  237. {
  238.     quicktime_dref_t dref;
  239. } quicktime_dinf_t;
  240.  
  241. /* video media header */
  242.  
  243. typedef struct
  244. {
  245.     int version;
  246.     long flags;
  247.     int graphics_mode;
  248.     int opcolor[3];
  249. } quicktime_vmhd_t;
  250.  
  251.  
  252. /* sound media header */
  253.  
  254. typedef struct
  255. {
  256.     int version;
  257.     long flags;
  258.     int balance;
  259.     int reserved;
  260. } quicktime_smhd_t;
  261.  
  262. /* handler reference */
  263.  
  264. typedef struct
  265. {
  266.     int version;
  267.     long flags;
  268.     char component_type[4];
  269.     char component_subtype[4];
  270.     long component_manufacturer;
  271.     long component_flags;
  272.     long component_flag_mask;
  273.     char component_name[256];
  274. } quicktime_hdlr_t;
  275.  
  276. /* media information */
  277.  
  278. typedef struct
  279. {
  280.     int is_video;
  281.     int is_audio;
  282.     quicktime_vmhd_t vmhd;
  283.     quicktime_smhd_t smhd;
  284.     quicktime_stbl_t stbl;
  285.     quicktime_hdlr_t hdlr;
  286.     quicktime_dinf_t dinf;
  287. } quicktime_minf_t;
  288.  
  289.  
  290. /* media header */
  291.  
  292. typedef struct
  293. {
  294.     int version;
  295.     long flags;
  296.     unsigned long creation_time;
  297.     unsigned long modification_time;
  298.     long time_scale;
  299.     long duration;
  300.     int language;
  301.     int quality;
  302. } quicktime_mdhd_t;
  303.  
  304.  
  305. /* media */
  306.  
  307. typedef struct
  308. {
  309.     quicktime_mdhd_t mdhd;
  310.     quicktime_minf_t minf;
  311.     quicktime_hdlr_t hdlr;
  312. } quicktime_mdia_t;
  313.  
  314. /* edit list */
  315. typedef struct
  316. {
  317.     long duration;
  318.     long time;
  319.     float rate;
  320. } quicktime_elst_table_t;
  321.  
  322. typedef struct
  323. {
  324.     int version;
  325.     long flags;
  326.     long total_entries;
  327.  
  328.     quicktime_elst_table_t *table;
  329. } quicktime_elst_t;
  330.  
  331. typedef struct
  332. {
  333.     quicktime_elst_t elst;
  334. } quicktime_edts_t;
  335.  
  336.  
  337. typedef struct
  338. {
  339.     quicktime_tkhd_t tkhd;
  340.     quicktime_mdia_t mdia;
  341.     quicktime_edts_t edts;
  342. } quicktime_trak_t;
  343.  
  344.  
  345. typedef struct
  346. {
  347.     int version;
  348.     long flags;
  349.     unsigned long creation_time;
  350.     unsigned long modification_time;
  351.     long time_scale;
  352.     long duration;
  353.     float preferred_rate;
  354.     float preferred_volume;
  355.     char reserved[10];
  356.     quicktime_matrix_t matrix;
  357.     long preview_time;
  358.     long preview_duration;
  359.     long poster_time;
  360.     long selection_time;
  361.     long selection_duration;
  362.     long current_time;
  363.     long next_track_id;
  364. } quicktime_mvhd_t;
  365.  
  366. typedef struct
  367. {
  368.     char *copyright;
  369.     int copyright_len;
  370.     char *name;
  371.     int name_len;
  372.     char *info;
  373.     int info_len;
  374. } quicktime_udta_t;
  375.  
  376.  
  377. typedef struct
  378. {
  379.     int total_tracks;
  380.  
  381.     quicktime_mvhd_t mvhd;
  382.     quicktime_trak_t *trak[MAXTRACKS];
  383.     quicktime_udta_t udta;
  384.     quicktime_ctab_t ctab;
  385. } quicktime_moov_t;
  386.  
  387. typedef struct
  388. {
  389.     long start;
  390.     long size;
  391. } quicktime_mdat_t;
  392.  
  393.  
  394. typedef struct
  395. {
  396.     long start;      /* byte start in file */
  397.     long end;        /* byte endpoint in file */
  398.     long size;       /* byte size for writing */
  399.     char type[4];
  400. } quicktime_atom_t;
  401.  
  402. /* table of pointers to every track */
  403. typedef struct
  404. {
  405.     quicktime_trak_t *track; /* real quicktime track corresponding to this table */
  406.     int channels;            /* number of audio channels in the track */
  407.     long current_position;   /* current sample in output file */
  408.     long current_chunk;      /* current chunk in output file */
  409.  
  410.     void *codec;
  411. } quicktime_audio_map_t;
  412.  
  413. typedef struct
  414. {
  415.     quicktime_trak_t *track;
  416.     long current_position;
  417.     long current_chunk;
  418.  
  419. /* Array of pointers to frames of raw data when caching frames. */
  420. //    unsigned char **frame_cache;
  421. //    long frames_cached;
  422.  
  423.     void *codec;
  424. } quicktime_video_map_t;
  425.  
  426. /* file descriptor passed to all routines */
  427.  
  428. typedef struct
  429. {
  430.     FILE *stream;
  431.     long total_length;
  432.     quicktime_mdat_t mdat;
  433.     quicktime_moov_t moov;
  434.     int rd;
  435.     int wr;
  436.     int use_avi;
  437.  
  438. /* mapping of audio channels to movie tracks */
  439. /* one audio map entry exists for each channel */
  440.     int total_atracks;
  441.     quicktime_audio_map_t *atracks;
  442.  
  443. /* mapping of video tracks to movie tracks */
  444.     int total_vtracks;
  445.     quicktime_video_map_t *vtracks;
  446.  
  447. /* for begining and ending frame writes where the user wants to write the  */
  448. /* file descriptor directly */
  449.     long offset;
  450.  
  451. /* Number of processors at our disposal */
  452.     int cpus;
  453.  
  454. /* I/O */
  455.     long file_position;      /* Current position of file descriptor */
  456.  
  457. /* Read ahead buffer */
  458.     long preload_size;      /* Enables preload when nonzero. */
  459.     char *preload_buffer;
  460.     long preload_start;     /* Start of preload_buffer in file */
  461.     long preload_end;       /* End of preload buffer in file */
  462.     long preload_ptr;       /* Offset of preload_start in preload_buffer */
  463.  
  464. /* Parameters for frame currently being decoded */
  465.     int do_scaling;
  466.     int in_x, in_y, in_w, in_h, out_w, out_h;
  467.     int color_model;
  468. } quicktime_t;
  469.  
  470. typedef struct
  471. {
  472.     int (*delete_vcodec)(quicktime_video_map_t *vtrack);
  473.     int (*delete_acodec)(quicktime_audio_map_t *atrack);
  474.     int (*decode_video)(quicktime_t *file, 
  475.                 unsigned char **row_pointers, 
  476.                 int track);
  477.     int (*encode_video)(quicktime_t *file, 
  478.                 unsigned char **row_pointers, 
  479.                 int track);
  480.     int (*decode_audio)(quicktime_t *file, 
  481.                 QUICKTIME_INT16 *output_i, 
  482.                 float *output_f, 
  483.                 long samples, 
  484.                 int track,
  485.                 int channel);
  486.     int (*encode_audio)(quicktime_t *file, 
  487.                 QUICKTIME_INT16 **input_i, 
  488.                 float **input_f, 
  489.                 int track, 
  490.                 long samples);
  491.     int (*reads_colormodel)(quicktime_t *file, 
  492.         int colormodel, 
  493.         int track);
  494.     int (*writes_colormodel)(quicktime_t *file, 
  495.         int colormodel, 
  496.         int track);
  497.  
  498.     void *priv;
  499. } quicktime_codec_t;
  500.  
  501.  
  502. typedef struct 
  503. {
  504.   quicktime_codec_t codec;
  505.   char fourcc[5];
  506.  
  507.   void(*init)(quicktime_video_map_t *);
  508.  
  509.   int(*decode)(quicktime_t *file,
  510.            int track,
  511.            unsigned long inputsize,
  512.            unsigned char *input,
  513.            unsigned char *output);
  514.  
  515.   int(*encode)(quicktime_t *file,
  516.            int track,
  517.            unsigned char *input,
  518.            unsigned char *output);
  519.   
  520.   int(*delete_codec)(quicktime_video_map_t *vtrack);
  521.  
  522. } quicktime_extern_video_t;
  523.  
  524.  
  525.  
  526.  
  527. typedef struct 
  528. {
  529.   quicktime_codec_t codec;
  530.   char fourcc[5];
  531.  
  532.   void(*init)(quicktime_audio_map_t *);
  533.  
  534.   int(*decode)(quicktime_t *file,
  535.            int track,
  536.            unsigned long inputsize,
  537.            unsigned char *input,
  538.            unsigned char *output);
  539.  
  540.   int(*encode)(quicktime_t *file,
  541.            int track,
  542.            unsigned char *input,
  543.            unsigned char *output);
  544.   
  545.   int(*delete_codec)(quicktime_audio_map_t *atrack);
  546. } quicktime_extern_audio_t;
  547.  
  548.  
  549. #endif
  550.