4 /* ================================= structures */
6 /* Version used internally. You need to query it with the C functions */
7 #define QUICKTIME_MAJOR 2
8 #define QUICKTIME_MINOR 0
9 #define QUICKTIME_RELEASE 0
12 #define HEADER_LENGTH 8
13 #define MAXTRACKS 1024
15 /* Crazy Mich R. Soft constants */
16 #define AVI_HASINDEX 0x00000010 // Index at end of file?
17 #define AVI_MUSTUSEINDEX 0x00000020
18 #define AVI_ISINTERLEAVED 0x00000100
19 #define AVI_TRUSTCKTYPE 0x00000800 // Use CKType to find key frames?
20 #define AVI_WASCAPTUREFILE 0x00010000
21 #define AVI_COPYRIGHTED 0x00020000
22 #define AVIF_WASCAPTUREFILE 0x00010000
23 #define AVI_KEYFRAME 0x10
24 #define AVI_INDEX_OF_CHUNKS 0x01
25 #define AVI_INDEX_OF_INDEXES 0x00
27 #define AVI_FRAME_RATE_BASE 10000
28 #define MAX_RIFFS 0x100
37 #define FTELL ftello64
38 #define FSEEK fseeko64
41 // ffmpeg requires global variable initialization
42 // These are defined in mpeg4.c
43 extern int ffmpeg_initialized
;
44 extern pthread_mutex_t ffmpeg_lock
;
48 /* for AVI it's the end of the 8 byte header in the file */
49 /* for Quicktime it's the start of the 8 byte header in the file */
51 int64_t end
; /* byte endpoint in file */
52 int64_t size
; /* byte size for writing */
53 int use_64
; /* Use 64 bit header */
54 unsigned char type
[4];
67 unsigned long creation_time
;
68 unsigned long modification_time
;
77 quicktime_matrix_t matrix
;
96 /* ===================== sample table ======================== // */
100 /* sample description */
104 int motion_jpeg_quantization_table
;
110 int motion_jpeg_huffman_table
;
120 /* common to audio and video */
125 /* video description */
126 long temporal_quality
;
127 long spatial_quality
;
130 float dpi_horizontal
;
133 int frames_per_sample
;
134 char compressor_name
[32];
137 quicktime_ctab_t ctab
;
141 /* 0 - unknown 1 - top first 2 - bottom first */
143 quicktime_mjqt_t mjqt
;
144 quicktime_mjht_t mjht
;
146 /* audio description */
152 } quicktime_stsd_table_t
;
160 quicktime_stsd_table_t
*table
;
168 long sample_duration
;
169 } quicktime_stts_table_t
;
176 quicktime_stts_table_t
*table
;
184 } quicktime_stss_table_t
;
191 long entries_allocated
;
192 quicktime_stss_table_t
*table
;
196 /* sample to chunk */
202 } quicktime_stsc_table_t
;
210 long entries_allocated
;
211 quicktime_stsc_table_t
*table
;
219 } quicktime_stsz_table_t
;
228 long entries_allocated
; /* used by the library for allocating a table */
229 quicktime_stsz_table_t
*table
;
237 } quicktime_stco_table_t
;
245 long entries_allocated
; /* used by the library for allocating a table */
246 quicktime_stco_table_t
*table
;
255 quicktime_stsd_t stsd
;
256 quicktime_stts_t stts
;
257 quicktime_stss_t stss
;
258 quicktime_stsc_t stsc
;
259 quicktime_stsz_t stsz
;
260 quicktime_stco_t stco
;
271 char *data_reference
;
272 } quicktime_dref_table_t
;
279 quicktime_dref_table_t
*table
;
282 /* data information */
286 quicktime_dref_t dref
;
289 /* video media header */
300 /* sound media header */
310 /* handler reference */
316 char component_type
[4];
317 char component_subtype
[4];
318 long component_manufacturer
;
319 long component_flags
;
320 long component_flag_mask
;
321 char component_name
[256];
324 /* media information */
330 quicktime_vmhd_t vmhd
;
331 quicktime_smhd_t smhd
;
332 quicktime_stbl_t stbl
;
333 quicktime_hdlr_t hdlr
;
334 quicktime_dinf_t dinf
;
344 unsigned long creation_time
;
345 unsigned long modification_time
;
357 quicktime_mdhd_t mdhd
;
358 quicktime_minf_t minf
;
359 quicktime_hdlr_t hdlr
;
368 } quicktime_elst_table_t
;
376 quicktime_elst_table_t
*table
;
381 quicktime_elst_t elst
;
389 quicktime_tkhd_t tkhd
;
390 quicktime_mdia_t mdia
;
391 quicktime_edts_t edts
;
399 unsigned long creation_time
;
400 unsigned long modification_time
;
403 float preferred_rate
;
404 float preferred_volume
;
406 quicktime_matrix_t matrix
;
408 long preview_duration
;
411 long selection_duration
;
431 quicktime_mvhd_t mvhd
;
432 quicktime_trak_t
*trak
[MAXTRACKS
];
433 quicktime_udta_t udta
;
434 quicktime_ctab_t ctab
;
439 quicktime_atom_t atom
;
444 /* Offset of end of 8 byte chunk header relative to ix->base_offset */
446 /* size of data without 8 byte header */
448 } quicktime_ixtable_t
;
452 quicktime_atom_t atom
;
453 quicktime_ixtable_t
*table
;
455 int table_allocation
;
458 /* ixtable relative_offset is relative to this */
462 /* corresponding chunk id */
469 quicktime_atom_t atom
;
472 /* For writing only, there are multiple movi objects with multiple ix tables. */
473 /* This is not used for reading. Instead an ix_t object in indx_t is used. */
474 quicktime_ix_t
*ix
[MAXTRACKS
];
479 /* Start of start of corresponding ix## header */
480 int64_t index_offset
;
481 /* Size not including 8 byte header */
483 /* duration in "ticks" */
486 /* Partial index for reading only. */
488 } quicktime_indxtable_t
;
492 quicktime_atom_t atom
;
496 /* corresponding chunk id: 00wb, 00dc */
499 /* Number of partial indexes here */
501 int table_allocation
;
502 quicktime_indxtable_t
*table
;
507 quicktime_atom_t atom
;
508 /* Super index for reading */
509 quicktime_indx_t indx
;
510 /* AVI needs header placeholders before anything else is written */
511 int64_t length_offset
;
512 int64_t samples_per_chunk_offset
;
513 int64_t sample_size_offset
;
514 /* Start of indx header for later writing */
516 /* Size of JUNK without 8 byte header which is to be replaced by indx */
517 int64_t padding_size
;
518 /* Tag for writer with NULL termination: 00wb, 00dc Not available in reader.*/
520 /* Flags for reader. Not available in writer. */
523 /* Notify reader the super indexes are valid */
529 quicktime_atom_t atom
;
530 int64_t frames_offset
;
531 int64_t bitrate_offset
;
532 /* Offsets to be written during file closure */
533 int64_t total_frames_offset
;
535 /* AVI equivalent for each trak. Use file->moov.total_tracks */
536 /* Need it for super indexes during reading. */
537 quicktime_strl_t
*strl
[MAXTRACKS
];
544 /* Start of 8 byte chunk header relative to start of the 'movi' string */
546 /* Size of chunk less the 8 byte header */
548 } quicktime_idx1table_t
;
552 quicktime_atom_t atom
;
553 quicktime_idx1table_t
*table
;
555 int table_allocation
;
560 quicktime_atom_t atom
;
561 quicktime_movi_t movi
;
562 quicktime_hdrl_t hdrl
;
565 quicktime_idx1_t idx1
;
566 /* Notify reader the idx1 table is valid */
571 /* table of pointers to every track */
574 quicktime_trak_t
*track
; /* real quicktime track corresponding to this table */
575 int channels
; /* number of audio channels in the track */
576 long current_position
; /* current sample in output file */
577 long current_chunk
; /* current chunk in output file */
580 } quicktime_audio_map_t
;
584 quicktime_trak_t
*track
;
585 long current_position
; /* current frame in output file */
586 long current_chunk
; /* current chunk in output file */
589 } quicktime_video_map_t
;
591 /* file descriptor passed to all routines */
595 int64_t total_length
;
596 quicktime_mdat_t mdat
;
597 quicktime_moov_t moov
;
613 quicktime_riff_t
*riff
[MAX_RIFFS
];
620 /* for begining and ending frame writes where the user wants to write the */
621 /* file descriptor directly */
625 /* Current position of virtual file descriptor */
626 int64_t file_position
;
628 /* Work around a bug in glibc where ftello returns only 32 bits by maintaining */
629 /* our own position */
630 int64_t ftell_position
;
632 /* Read ahead buffer */
633 int64_t preload_size
; /* Enables preload when nonzero. */
634 char *preload_buffer
;
635 int64_t preload_start
; /* Start of preload_buffer in file */
636 int64_t preload_end
; /* End of preload buffer in file */
637 int64_t preload_ptr
; /* Offset of preload_start in preload_buffer */
639 /* Write ahead buffer */
640 /* Amount of data in presave buffer */
641 int64_t presave_size
;
642 /* Next presave byte's position in file */
643 int64_t presave_position
;
644 char *presave_buffer
;
645 /* Presave doesn't matter a whole lot, so its size is fixed */
646 #define QUICKTIME_PRESAVE 0x100000
649 /* mapping of audio channels to movie tracks */
650 /* one audio map entry exists for each channel */
652 quicktime_audio_map_t
*atracks
;
654 /* mapping of video tracks to movie tracks */
656 quicktime_video_map_t
*vtracks
;
658 /* Number of processors at our disposal */
661 /* Parameters for frame currently being decoded */
663 int in_x
, in_y
, in_w
, in_h
, out_w
, out_h
;
664 int color_model
, row_span
;
668 /* Structure created in track_map to describe the codec */
671 int (*delete_vcodec
)(quicktime_video_map_t
*vtrack
);
672 int (*delete_acodec
)(quicktime_audio_map_t
*atrack
);
673 /* Decode a single frame */
674 int (*decode_video
)(quicktime_t
*file
,
675 unsigned char **row_pointers
,
677 /* Encode a single frame */
678 int (*encode_video
)(quicktime_t
*file
,
679 unsigned char **row_pointers
,
681 /* Decode a certain number of samples */
682 int (*decode_audio
)(quicktime_t
*file
,
688 /* Encode a chunk of audio */
689 int (*encode_audio
)(quicktime_t
*file
,
694 int (*reads_colormodel
)(quicktime_t
*file
,
697 int (*writes_colormodel
)(quicktime_t
*file
,
701 int (*set_parameter
)(quicktime_t
*file
,
705 void (*flush
)(quicktime_t
*file
,
708 /* AVI codec ID for audio. AVI codec ID's are based on WAV files, by the way. */
711 /* Pointer to static character code for identifying the codec. */
714 /* English title of codec. Optional. */
717 /* English description of codec. Optional. */
720 /* Proprietary data for the codec to allocate and delete. */
726 /* Structure tabulated in plugin.c to search the codecs */
729 void (*init_vcodec
)(quicktime_video_map_t
*);
730 void (*init_acodec
)(quicktime_audio_map_t
*);
731 } quicktime_codectable_t
;