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 4
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 // Utility functions for vbr audio. This is accessed through quicktime_audio_map_t.
51 // End of the output buffer in the file in samples
53 // Number of samples in output buffer before end
55 // Position in output buffer of buffer_end
57 // Output buffer, linear for each channel.
58 double **output_buffer
;
59 // Copy of channel count for deletion
61 // Input buffer for temporary compressed data
64 unsigned char *input_buffer
;
65 // Entry in sample size table of next frame of audio to read
66 int sample_size_entry
;
67 // Next sample/frame to read
75 /* for AVI it's the end of the 8 byte header in the file */
76 /* for Quicktime it's the start of the 8 byte header in the file */
78 int64_t end
; /* byte endpoint in file */
79 int64_t size
; /* byte size for writing */
80 int use_64
; /* Use 64 bit header */
81 unsigned char type
[4];
94 unsigned long creation_time
;
95 unsigned long modification_time
;
104 quicktime_matrix_t matrix
;
123 /* ===================== sample table ======================== // */
127 /* sample description */
131 int motion_jpeg_quantization_table
;
137 int motion_jpeg_huffman_table
;
147 /* common to audio and video */
152 /* video description */
153 long temporal_quality
;
154 long spatial_quality
;
157 float dpi_horizontal
;
160 int frames_per_sample
;
161 char compressor_name
[32];
164 quicktime_ctab_t ctab
;
168 /* 0 - unknown 1 - top first 2 - bottom first */
170 quicktime_mjqt_t mjqt
;
171 quicktime_mjht_t mjht
;
173 /* audio description */
180 int mpeg4_header_size
;
182 /* Version 1 of audio description */
183 int samples_per_packet
;
184 int bytes_per_packet
;
186 int bytes_per_sample
;
187 } quicktime_stsd_table_t
;
195 quicktime_stsd_table_t
*table
;
203 long sample_duration
;
204 } quicktime_stts_table_t
;
211 quicktime_stts_table_t
*table
;
219 } quicktime_stss_table_t
;
226 long entries_allocated
;
227 quicktime_stss_table_t
*table
;
231 /* sample to chunk */
237 } quicktime_stsc_table_t
;
245 long entries_allocated
;
246 quicktime_stsc_table_t
*table
;
254 } quicktime_stsz_table_t
;
263 long entries_allocated
; /* used by the library for allocating a table */
264 quicktime_stsz_table_t
*table
;
272 } quicktime_stco_table_t
;
280 long entries_allocated
; /* used by the library for allocating a table */
281 quicktime_stco_table_t
*table
;
290 quicktime_stsd_t stsd
;
291 quicktime_stts_t stts
;
292 quicktime_stss_t stss
;
293 quicktime_stsc_t stsc
;
294 quicktime_stsz_t stsz
;
295 quicktime_stco_t stco
;
306 char *data_reference
;
307 } quicktime_dref_table_t
;
314 quicktime_dref_table_t
*table
;
317 /* data information */
321 quicktime_dref_t dref
;
324 /* video media header */
335 /* sound media header */
345 /* handler reference */
351 char component_type
[4];
352 char component_subtype
[4];
353 long component_manufacturer
;
354 long component_flags
;
355 long component_flag_mask
;
356 char component_name
[256];
359 /* media information */
365 quicktime_vmhd_t vmhd
;
366 quicktime_smhd_t smhd
;
367 quicktime_stbl_t stbl
;
368 quicktime_hdlr_t hdlr
;
369 quicktime_dinf_t dinf
;
379 unsigned long creation_time
;
380 unsigned long modification_time
;
392 quicktime_mdhd_t mdhd
;
393 quicktime_minf_t minf
;
394 quicktime_hdlr_t hdlr
;
403 } quicktime_elst_table_t
;
411 quicktime_elst_table_t
*table
;
416 quicktime_elst_t elst
;
424 quicktime_tkhd_t tkhd
;
425 quicktime_mdia_t mdia
;
426 quicktime_edts_t edts
;
434 unsigned long creation_time
;
435 unsigned long modification_time
;
438 float preferred_rate
;
439 float preferred_volume
;
441 quicktime_matrix_t matrix
;
443 long preview_duration
;
446 long selection_duration
;
466 quicktime_mvhd_t mvhd
;
467 quicktime_trak_t
*trak
[MAXTRACKS
];
468 quicktime_udta_t udta
;
469 quicktime_ctab_t ctab
;
474 quicktime_atom_t atom
;
479 /* Offset of end of 8 byte chunk header relative to ix->base_offset */
481 /* size of data without 8 byte header */
483 } quicktime_ixtable_t
;
487 quicktime_atom_t atom
;
488 quicktime_ixtable_t
*table
;
490 int table_allocation
;
493 /* ixtable relative_offset is relative to this */
497 /* corresponding chunk id */
504 quicktime_atom_t atom
;
507 /* For writing only, there are multiple movi objects with multiple ix tables. */
508 /* This is not used for reading. Instead an ix_t object in indx_t is used. */
509 quicktime_ix_t
*ix
[MAXTRACKS
];
514 /* Start of start of corresponding ix## header */
515 int64_t index_offset
;
516 /* Size not including 8 byte header */
518 /* duration in "ticks" */
521 /* Partial index for reading only. */
523 } quicktime_indxtable_t
;
527 quicktime_atom_t atom
;
531 /* corresponding chunk id: 00wb, 00dc */
534 /* Number of partial indexes here */
536 int table_allocation
;
537 quicktime_indxtable_t
*table
;
542 quicktime_atom_t atom
;
543 /* Super index for reading */
544 quicktime_indx_t indx
;
545 /* AVI needs header placeholders before anything else is written */
546 int64_t length_offset
;
547 int64_t samples_per_chunk_offset
;
548 int64_t sample_size_offset
;
549 /* Start of indx header for later writing */
551 /* Size of JUNK without 8 byte header which is to be replaced by indx */
552 int64_t padding_size
;
553 /* Tag for writer with NULL termination: 00wb, 00dc Not available in reader.*/
555 /* Flags for reader. Not available in writer. */
558 /* Notify reader the super indexes are valid */
564 quicktime_atom_t atom
;
565 int64_t frames_offset
;
566 int64_t bitrate_offset
;
567 /* Offsets to be written during file closure */
568 int64_t total_frames_offset
;
570 /* AVI equivalent for each trak. Use file->moov.total_tracks */
571 /* Need it for super indexes during reading. */
572 quicktime_strl_t
*strl
[MAXTRACKS
];
579 /* Start of 8 byte chunk header relative to start of the 'movi' string */
581 /* Size of chunk less the 8 byte header */
583 } quicktime_idx1table_t
;
587 quicktime_atom_t atom
;
588 quicktime_idx1table_t
*table
;
590 int table_allocation
;
595 quicktime_atom_t atom
;
596 quicktime_movi_t movi
;
597 quicktime_hdrl_t hdrl
;
600 quicktime_idx1_t idx1
;
601 /* Notify reader the idx1 table is valid */
606 /* table of pointers to every track */
609 quicktime_trak_t
*track
; /* real quicktime track corresponding to this table */
610 int channels
; /* number of audio channels in the track */
611 long current_position
; /* current sample in output file */
612 long current_chunk
; /* current chunk in output file */
613 quicktime_vbr_t vbr
; /* Stores for vbr codecs */
616 } quicktime_audio_map_t
;
620 quicktime_trak_t
*track
;
621 long current_position
; /* current frame in output file */
622 long current_chunk
; /* current chunk in output file */
625 } quicktime_video_map_t
;
627 /* file descriptor passed to all routines */
631 int64_t total_length
;
632 quicktime_mdat_t mdat
;
633 quicktime_moov_t moov
;
637 /* If the moov atom is compressed */
639 unsigned char *moov_data
;
641 * Temporary storage of compressed sizes. If the file length is shorter than the
642 * uncompressed sizes, it won't work.
646 int64_t old_preload_size
;
647 char *old_preload_buffer
;
648 int64_t old_preload_start
;
649 int64_t old_preload_end
;
650 int64_t old_preload_ptr
;
662 quicktime_riff_t
*riff
[MAX_RIFFS
];
669 /* for begining and ending frame writes where the user wants to write the */
670 /* file descriptor directly */
674 /* Current position of virtual file descriptor */
675 int64_t file_position
;
677 /* Work around a bug in glibc where ftello returns only 32 bits by maintaining */
678 /* our own position */
679 int64_t ftell_position
;
681 /* Read ahead buffer */
682 int64_t preload_size
; /* Enables preload when nonzero. */
683 char *preload_buffer
;
684 int64_t preload_start
; /* Start of preload_buffer in file */
685 int64_t preload_end
; /* End of preload buffer in file */
686 int64_t preload_ptr
; /* Offset of preload_start in preload_buffer */
688 /* Write ahead buffer */
689 /* Amount of data in presave buffer */
690 int64_t presave_size
;
691 /* Next presave byte's position in file */
692 int64_t presave_position
;
693 char *presave_buffer
;
694 /* Presave doesn't matter a whole lot, so its size is fixed */
695 #define QUICKTIME_PRESAVE 0x100000
698 /* mapping of audio channels to movie tracks */
699 /* one audio map entry exists for each channel */
701 quicktime_audio_map_t
*atracks
;
703 /* mapping of video tracks to movie tracks */
705 quicktime_video_map_t
*vtracks
;
707 /* Number of processors at our disposal */
710 /* Parameters for frame currently being decoded */
712 int in_x
, in_y
, in_w
, in_h
, out_w
, out_h
;
713 int color_model
, row_span
;
715 /* Adjustable timecode frame number */
716 int64_t current_frame
;
724 /* Structure created in track_map to describe the codec */
727 int (*delete_vcodec
)(quicktime_video_map_t
*vtrack
);
728 int (*delete_acodec
)(quicktime_audio_map_t
*atrack
);
729 /* Decode a single frame */
730 int (*decode_video
)(quicktime_t
*file
,
731 unsigned char **row_pointers
,
733 /* Encode a single frame */
734 int (*encode_video
)(quicktime_t
*file
,
735 unsigned char **row_pointers
,
737 /* Decode a certain number of samples */
738 int (*decode_audio
)(quicktime_t
*file
,
744 /* Encode a chunk of audio */
745 int (*encode_audio
)(quicktime_t
*file
,
750 int (*reads_colormodel
)(quicktime_t
*file
,
753 int (*writes_colormodel
)(quicktime_t
*file
,
757 int (*set_parameter
)(quicktime_t
*file
,
761 void (*flush
)(quicktime_t
*file
,
764 /* AVI codec ID for audio. AVI codec ID's are based on WAV files, by the way. */
767 /* Pointer to static character code for identifying the codec. */
770 /* English title of codec. Optional. */
773 /* English description of codec. Optional. */
776 /* Proprietary data for the codec to allocate and delete. */
782 /* Structure tabulated in plugin.c to search the codecs */
785 void (*init_vcodec
)(quicktime_video_map_t
*);
786 void (*init_acodec
)(quicktime_audio_map_t
*);
787 } quicktime_codectable_t
;