private.h
上传用户:luping1608
上传日期:2007-01-06
资源大小:38k
文件大小:7k
源码类别:

多媒体

开发平台:

Unix_Linux

  1. #ifndef PRIVATE_H
  2. #define PRIVATE_H
  3. // ================================= structures
  4. #define HEADER_LENGTH 8
  5. #define MAXTRACKS 1024
  6. #include "codecs.h"
  7. typedef struct
  8. {
  9. float values[9];
  10. } quicktime_matrix_t;
  11. typedef struct
  12. {
  13. int version;
  14. long flags;
  15. unsigned long creation_time;
  16. unsigned long modification_time;
  17. int track_id;
  18. long reserved1;
  19. long duration;
  20. char reserved2[8];
  21. int layer;
  22. int alternate_group;
  23. float volume;
  24. long reserved3;
  25. quicktime_matrix_t matrix;
  26. float track_width;
  27. float track_height;
  28. } quicktime_tkhd_t;
  29. typedef struct
  30. {
  31. long seed;
  32. long flags;
  33. long size;
  34. short int *alpha;
  35. short int *red;
  36. short int *green;
  37. short int *blue;
  38. } quicktime_ctab_t;
  39. // ===================== sample table ======================== //
  40. // sample description
  41. typedef struct
  42. {
  43. int motion_jpeg_quantization_table;
  44. } quicktime_mjqt_t;
  45. typedef struct
  46. {
  47. int motion_jpeg_huffman_table;
  48. } quicktime_mjht_t;
  49. typedef struct
  50. {
  51. char format[4];
  52. char reserved[6];
  53. int data_reference;
  54. // common to audio and video
  55. int version;
  56. int revision;
  57. char vendor[4];
  58. // video description
  59. long temporal_quality;
  60. long spatial_quality;
  61. int width;
  62. int height;
  63. float dpi_horizontal;
  64. float dpi_vertical;
  65. long data_size;
  66. int frames_per_sample;
  67. char compressor_name[32];
  68. int depth;
  69. int ctab_id;
  70. quicktime_ctab_t ctab;
  71. float gamma;
  72. int fields;
  73. quicktime_mjqt_t mjqt;
  74. quicktime_mjht_t mjht;
  75. // audio description
  76. int channels;
  77. int sample_size;
  78. int compression_id;
  79. int packet_size;
  80. float sample_rate;
  81. } quicktime_stsd_table_t;
  82. typedef struct
  83. {
  84. int version;
  85. long flags;
  86. long total_entries;
  87. quicktime_stsd_table_t *table;
  88. } quicktime_stsd_t;
  89. // time to sample
  90. typedef struct
  91. {
  92. long sample_count;
  93. long sample_duration;
  94. } quicktime_stts_table_t;
  95. typedef struct
  96. {
  97. int version;
  98. long flags;
  99. long total_entries;
  100. quicktime_stts_table_t *table;
  101. } quicktime_stts_t;
  102. // sync sample
  103. typedef struct
  104. {
  105. long sample;
  106. } quicktime_stss_table_t;
  107. typedef struct
  108. {
  109. int version;
  110. long flags;
  111. long total_entries;
  112. quicktime_stss_table_t *table;
  113. } quicktime_stss_t;
  114. // sample to chunk
  115. typedef struct
  116. {
  117. long chunk;
  118. long samples;
  119. long id;
  120. } quicktime_stsc_table_t;
  121. typedef struct
  122. {
  123. int version;
  124. long flags;
  125. long total_entries;
  126. long entries_allocated;
  127. quicktime_stsc_table_t *table;
  128. } quicktime_stsc_t;
  129. // sample size
  130. typedef struct
  131. {
  132. long size;
  133. } quicktime_stsz_table_t;
  134. typedef struct
  135. {
  136. int version;
  137. long flags;
  138. long sample_size;
  139. long total_entries;
  140. long entries_allocated;    // used by the library for allocating a table
  141. quicktime_stsz_table_t *table;
  142. } quicktime_stsz_t;
  143. // chunk offset
  144. typedef struct
  145. {
  146. long offset;
  147. } quicktime_stco_table_t;
  148. typedef struct
  149. {
  150. int version;
  151. long flags;
  152. long total_entries;
  153. long entries_allocated;    // used by the library for allocating a table
  154. quicktime_stco_table_t *table;
  155. } quicktime_stco_t;
  156. // sample table
  157. typedef struct
  158. {
  159. int version;
  160. long flags;
  161. quicktime_stsd_t stsd;
  162. quicktime_stts_t stts;
  163. quicktime_stss_t stss;
  164. quicktime_stsc_t stsc;
  165. quicktime_stsz_t stsz;
  166. quicktime_stco_t stco;
  167. } quicktime_stbl_t;
  168. // data reference
  169. typedef struct
  170. {
  171. long size;
  172. char type[4];
  173. int version;
  174. long flags;
  175. char *data_reference;
  176. } quicktime_dref_table_t;
  177. typedef struct
  178. {
  179. int version;
  180. long flags;
  181. long total_entries;
  182. quicktime_dref_table_t *table;
  183. } quicktime_dref_t;
  184. // data information
  185. typedef struct
  186. {
  187. quicktime_dref_t dref;
  188. } quicktime_dinf_t;
  189. // video media header
  190. typedef struct
  191. {
  192. int version;
  193. long flags;
  194. int graphics_mode;
  195. int opcolor[3];
  196. } quicktime_vmhd_t;
  197. // sound media header
  198. typedef struct
  199. {
  200. int version;
  201. long flags;
  202. int balance;
  203. int reserved;
  204. } quicktime_smhd_t;
  205. // handler reference
  206. typedef struct
  207. {
  208. int version;
  209. long flags;
  210. char component_type[4];
  211. char component_subtype[4];
  212. long component_manufacturer;
  213. long component_flags;
  214. long component_flag_mask;
  215. char component_name[256];
  216. } quicktime_hdlr_t;
  217. // media information
  218. typedef struct
  219. {
  220. int is_video;
  221. int is_audio;
  222. quicktime_vmhd_t vmhd;
  223. quicktime_smhd_t smhd;
  224. quicktime_stbl_t stbl;
  225. quicktime_hdlr_t hdlr;
  226. quicktime_dinf_t dinf;
  227. } quicktime_minf_t;
  228. // media header
  229. typedef struct
  230. {
  231. int version;
  232. long flags;
  233. unsigned long creation_time;
  234. unsigned long modification_time;
  235. long time_scale;
  236. long duration;
  237. int language;
  238. int quality;
  239. } quicktime_mdhd_t;
  240. // media
  241. typedef struct
  242. {
  243. quicktime_mdhd_t mdhd;
  244. quicktime_minf_t minf;
  245. quicktime_hdlr_t hdlr;
  246. } quicktime_mdia_t;
  247. // edit list
  248. typedef struct
  249. {
  250. long duration;
  251. long time;
  252. float rate;
  253. } quicktime_elst_table_t;
  254. typedef struct
  255. {
  256. int version;
  257. long flags;
  258. long total_entries;
  259. quicktime_elst_table_t *table;
  260. } quicktime_elst_t;
  261. typedef struct
  262. {
  263. quicktime_elst_t elst;
  264. } quicktime_edts_t;
  265. typedef struct
  266. {
  267. quicktime_tkhd_t tkhd;
  268. quicktime_mdia_t mdia;
  269. quicktime_edts_t edts;
  270. } quicktime_trak_t;
  271. typedef struct
  272. {
  273. int version;
  274. long flags;
  275. unsigned long creation_time;
  276. unsigned long modification_time;
  277. long time_scale;
  278. long duration;
  279. float preferred_rate;
  280. float preferred_volume;
  281. char reserved[10];
  282. quicktime_matrix_t matrix;
  283. long preview_time;
  284. long preview_duration;
  285. long poster_time;
  286. long selection_time;
  287. long selection_duration;
  288. long current_time;
  289. long next_track_id;
  290. } quicktime_mvhd_t;
  291. typedef struct
  292. {
  293. int total_tracks;
  294. quicktime_mvhd_t mvhd;
  295. quicktime_trak_t *trak[MAXTRACKS];
  296. quicktime_ctab_t ctab;
  297. } quicktime_moov_t;
  298. typedef struct
  299. {
  300. long start;
  301. long size;
  302. } quicktime_mdat_t;
  303. typedef struct
  304. {
  305. long start;      // byte start in file
  306. long end;        // byte endpoint in file
  307. long size;       // byte size for writing
  308. char type[4];
  309. } quicktime_atom_t;
  310. // table of pointers to every track
  311. typedef struct
  312. {
  313. quicktime_trak_t *track; // real quicktime track corresponding to this table
  314. int channels;            // number of audio channels in the track
  315. long current_position;   // current sample in output file
  316. long current_chunk;      // current chunk in output file
  317. quicktime_codecs_t codecs;
  318. } quicktime_audio_map_t;
  319. typedef struct
  320. {
  321. quicktime_trak_t *track;
  322. long current_position;
  323. long current_chunk;
  324. // Array of pointers to frames of raw data when caching frames.
  325. unsigned char **frame_cache;
  326. long frames_cached;
  327. quicktime_codecs_t codecs;
  328. } quicktime_video_map_t;
  329. // file descriptor passed to all routines
  330. typedef struct
  331. {
  332. FILE *stream;
  333. long total_length;
  334. quicktime_mdat_t mdat;
  335. quicktime_moov_t moov;
  336. int rd;
  337. int wr;
  338. // mapping of audio channels to movie tracks
  339. // one audio map entry exists for each channel
  340. int total_atracks;
  341. quicktime_audio_map_t *atracks;
  342. // mapping of video tracks to movie tracks
  343. int total_vtracks;
  344. quicktime_video_map_t *vtracks;
  345. // for begining and ending frame writes where the user wants to write the 
  346. // file descriptor directly
  347. long offset;
  348. } quicktime_t;
  349. #endif