7 /* atom handling routines */
8 int quicktime_atom_write_header(quicktime_t
*file
, quicktime_atom_t
*atom
, char *text
);
9 int quicktime_atom_write_header64(quicktime_t
*file
, quicktime_atom_t
*atom
, char *text
);
10 int64_t quicktime_byte_position(quicktime_t
*file
);
11 // Used internally to replace ftello values
12 int64_t quicktime_ftell(quicktime_t
*file
);
14 quicktime_trak_t
* quicktime_add_track(quicktime_t
*file
);
18 int quicktime_file_open(quicktime_t
*file
, char *path
, int rd
, int wr
);
19 int quicktime_file_close(quicktime_t
*file
);
20 int64_t quicktime_get_file_length(char *path
);
22 /* Initialize audio_map_t and video_map_t objects after loading headers */
23 /* Called by quicktime_read_info */
24 void quicktime_init_maps(quicktime_t
*file
);
26 int quicktime_read_char(quicktime_t
*file
);
27 float quicktime_read_fixed32(quicktime_t
*file
);
28 float quicktime_read_fixed16(quicktime_t
*file
);
29 int64_t quicktime_read_int64(quicktime_t
*file
);
30 int64_t quicktime_read_int64_le(quicktime_t
*file
);
31 unsigned long quicktime_read_uint32(quicktime_t
*file
);
32 long quicktime_read_int32(quicktime_t
*file
);
33 long quicktime_read_int32_le(quicktime_t
*file
);
34 long quicktime_read_int24(quicktime_t
*file
);
35 int64_t quicktime_position(quicktime_t
*file
);
36 int quicktime_set_position(quicktime_t
*file
, int64_t position
);
37 int quicktime_write_fixed32(quicktime_t
*file
, float number
);
38 int quicktime_write_char(quicktime_t
*file
, char x
);
39 int quicktime_write_int16(quicktime_t
*file
, int number
);
40 int quicktime_write_int16_le(quicktime_t
*file
, int number
);
41 int quicktime_write_int24(quicktime_t
*file
, long number
);
42 int quicktime_write_int32(quicktime_t
*file
, long value
);
43 int quicktime_write_int32_le(quicktime_t
*file
, long value
);
44 int quicktime_write_int64(quicktime_t
*file
, int64_t value
);
45 int quicktime_write_int64_le(quicktime_t
*file
, int64_t value
);
46 int quicktime_write_char32(quicktime_t
*file
, char *string
);
47 int quicktime_write_fixed16(quicktime_t
*file
, float number
);
49 /* Returns number of bytes written */
50 int quicktime_write_data(quicktime_t
*file
, char *data
, int size
);
51 int quicktime_match_32(char *input
, char *output
);
52 int quicktime_match_24(char *input
, char *output
);
53 void quicktime_write_pascal(quicktime_t
*file
, char *data
);
54 int quicktime_read_data(quicktime_t
*file
, char *data
, int64_t size
);
56 /* Most codecs don't specify the actual number of bits on disk in the stbl. */
57 /* Convert the samples to the number of bytes for reading depending on the codec. */
58 int64_t quicktime_samples_to_bytes(quicktime_trak_t
*track
, long samples
);
60 /* Convert Microsoft audio id to codec */
61 void quicktime_id_to_codec(char *result
, int id
);
63 int quicktime_find_vcodec(quicktime_video_map_t
*vtrack
);
64 int quicktime_find_acodec(quicktime_audio_map_t
*atrack
);
73 quicktime_scaletable_t
* quicktime_new_scaletable(int input_w
, int input_h
, int output_w
, int output_h
);
76 /* chunks always start on 1 */
77 /* samples start on 0 */
79 /* update the position pointers in all the tracks after a set_position */
80 int quicktime_update_positions(quicktime_t
*file
);
89 void quicktime_read_strh(quicktime_t
*file
, quicktime_atom_t
*parent_atom
);
90 void quicktime_write_strh(quicktime_t
*file
, int track
);
95 /* Create new strl object for reading or writing */
96 quicktime_strl_t
* quicktime_new_strl();
97 /* Initialize new strl object for writing */
98 void quicktime_init_strl(quicktime_t
*file
,
99 quicktime_audio_map_t
*atrack
,
100 quicktime_video_map_t
*vtrack
,
101 quicktime_trak_t
*trak
,
102 quicktime_strl_t
*strl
);
103 void quicktime_delete_strl(quicktime_strl_t
*strl
);
104 /* Read strl object */
105 void quicktime_read_strl(quicktime_t
*file
,
106 quicktime_strl_t
*strl
,
107 quicktime_atom_t
*parent_atom
);
110 void quicktime_delete_indx(quicktime_indx_t
*indx
);
111 void quicktime_init_indx(quicktime_t
*file
,
112 quicktime_indx_t
*indx
,
113 quicktime_strl_t
*strl
);
114 void quicktime_update_indx(quicktime_t
*file
,
115 quicktime_indx_t
*indx
,
117 void quicktime_finalize_indx(quicktime_t
*file
);
118 /* Called by quicktime_read_strl */
119 void quicktime_read_indx(quicktime_t
*file
,
120 quicktime_strl_t
*strl
,
121 quicktime_atom_t
*parent_atom
);
125 void quicktime_delete_hdrl(quicktime_t
*file
, quicktime_hdrl_t
*hdrl
);
126 void quicktime_read_hdrl(quicktime_t
*file
,
127 quicktime_hdrl_t
*hdrl
,
128 quicktime_atom_t
*parent_atom
);
129 void quicktime_init_hdrl(quicktime_t
*file
, quicktime_hdrl_t
*hdrl
);
130 void quicktime_finalize_hdrl(quicktime_t
*file
, quicktime_hdrl_t
*hdrl
);
138 /* Read movi and create objects */
139 void quicktime_delete_movi(quicktime_t
*file
, quicktime_movi_t
*movi
);
140 void quicktime_read_movi(quicktime_t
*file
,
141 quicktime_atom_t
*parent_atom
,
142 quicktime_movi_t
*movi
);
143 /* Write preliminary movi data and create objects */
144 void quicktime_init_movi(quicktime_t
*file
, quicktime_riff_t
*riff
);
145 void quicktime_finalize_movi(quicktime_t
*file
, quicktime_movi_t
*movi
);
152 void quicktime_delete_idx1(quicktime_idx1_t
*idx1
);
153 void quicktime_read_idx1(quicktime_t
*file
,
154 quicktime_riff_t
*riff
,
155 quicktime_atom_t
*parent_atom
);
156 void quicktime_write_idx1(quicktime_t
*file
,
157 quicktime_idx1_t
*idx1
);
158 /* Set the keyframe flag in the right IDX1 entry. new_keyframes starts on 0 */
159 /* Used by quicktime_insert_keyframe */
160 void quicktime_set_idx1_keyframe(quicktime_t
*file
,
161 quicktime_trak_t
*trak
,
163 /* Create new IDX1 entry. Used by quicktime_write_chunk_footer */
164 void quicktime_update_idx1table(quicktime_t
*file
,
165 quicktime_trak_t
*trak
,
172 void quicktime_read_odml(quicktime_t
*file
, quicktime_atom_t
*parent_atom
);
173 void quicktime_finalize_odml(quicktime_t
*file
, quicktime_hdrl_t
*hdrl
);
174 void quicktime_init_odml(quicktime_t
*file
, quicktime_hdrl_t
*hdrl
);
183 /* Create new riff and put on riff table */
184 quicktime_riff_t
* quicktime_new_riff(quicktime_t
*file
);
185 void quicktime_delete_riff(quicktime_t
*file
, quicktime_riff_t
*riff
);
186 void quicktime_read_riff(quicktime_t
*file
, quicktime_atom_t
*parent_atom
);
188 /* Write riff header and initialize structures */
189 /* Only the first riff has a hdrl object */
190 void quicktime_init_riff(quicktime_t
*file
);
191 void quicktime_finalize_riff(quicktime_t
*file
, quicktime_riff_t
*riff
);
194 /* Create ix object for writing only */
195 quicktime_ix_t
* quicktime_new_ix(quicktime_t
*file
,
196 quicktime_trak_t
*trak
,
197 quicktime_strl_t
*strl
);
198 void quicktime_delete_ix(quicktime_ix_t
*ix
);
199 void quicktime_update_ixtable(quicktime_t
*file
,
200 quicktime_trak_t
*trak
,
203 void quicktime_write_ix(quicktime_t
*file
,
206 /* Read entire ix atom from current position in file */
207 /* Called by quicktime_read_indx. */
208 void quicktime_read_ix(quicktime_t
*file
,
213 /* compression_id is for AVI reading */
214 int quicktime_trak_init_audio(quicktime_t
*file
,
215 quicktime_trak_t
*trak
,
220 int quicktime_trak_init_video(quicktime_t
*file
,
221 quicktime_trak_t
*trak
,
226 int quicktime_trak_delete(quicktime_trak_t
*trak
);
227 int quicktime_trak_dump(quicktime_trak_t
*trak
);
228 int quicktime_delete_trak(quicktime_moov_t
*moov
);
229 int quicktime_read_trak(quicktime_t
*file
, quicktime_trak_t
*trak
, quicktime_atom_t
*trak_atom
);
230 int quicktime_write_trak(quicktime_t
*file
, quicktime_trak_t
*trak
, long moov_time_scale
);
231 int64_t quicktime_track_end(quicktime_trak_t
*trak
);
234 /* the total number of samples in the track depending on the access mode */
235 long quicktime_track_samples(quicktime_t
*file
, quicktime_trak_t
*trak
);
238 /* queries for every atom */
239 /* the starting sample in the given chunk */
240 long quicktime_sample_of_chunk(quicktime_trak_t
*trak
, long chunk
);
243 /* the byte offset from mdat start of the chunk. Chunk is numbered from 1 */
244 int64_t quicktime_chunk_to_offset(quicktime_t
*file
, quicktime_trak_t
*trak
, long chunk
);
247 /* the chunk of any offset from mdat start */
248 long quicktime_offset_to_chunk(int64_t *chunk_offset
,
249 quicktime_trak_t
*trak
,
252 /* Bytes in the chunk. Chunk is numbered from 1 */
253 /* Only available in AVI. */
254 /* Reads the chunk header to get the size. */
255 /* Stores the chunk offset in chunk_offset. */
256 /* Returns the bytes in the chunk less the 8 byte header size */
257 int quicktime_chunk_bytes(quicktime_t
*file
,
258 int64_t *chunk_offset
,
260 quicktime_trak_t
*trak
);
263 /* total bytes between the two samples */
264 int64_t quicktime_sample_range_size(quicktime_trak_t
*trak
, long chunk_sample
, long sample
);
267 int quicktime_chunk_of_sample(int64_t *chunk_sample
,
269 quicktime_trak_t
*trak
,
274 /* converting between mdat offsets to samples */
275 int64_t quicktime_sample_to_offset(quicktime_t
*file
, quicktime_trak_t
*trak
, long sample
);
276 long quicktime_offset_to_sample(quicktime_trak_t
*trak
, int64_t offset
);
277 quicktime_trak_t
* quicktime_add_trak(quicktime_t
*file
);
280 void quicktime_write_chunk_header(quicktime_t
*file
,
281 quicktime_trak_t
*trak
,
282 quicktime_atom_t
*chunk
);
283 void quicktime_write_chunk_footer(quicktime_t
*file
,
284 quicktime_trak_t
*trak
,
286 quicktime_atom_t
*chunk
,
288 /* update all the tables after writing a buffer */
289 /* set sample_size to 0 if no sample size should be set */
291 * int quicktime_update_tables(quicktime_t *file,
292 * quicktime_trak_t *trak,
297 * int64_t sample_size);
299 void quicktime_update_stco(quicktime_stco_t
*stco
, long chunk
, int64_t offset
);
300 void quicktime_update_stsz(quicktime_stsz_t
*stsz
, long sample
, long sample_size
);
301 int quicktime_update_stsc(quicktime_stsc_t
*stsc
, long chunk
, long samples
);
302 int quicktime_trak_duration(quicktime_trak_t
*trak
, long *duration
, long *timescale
);
303 int quicktime_trak_fix_counts(quicktime_t
*file
, quicktime_trak_t
*trak
);
306 /* number of samples in the chunk */
307 long quicktime_chunk_samples(quicktime_trak_t
*trak
, long chunk
);
308 int quicktime_trak_shift_offsets(quicktime_trak_t
*trak
, int64_t offset
);
309 void quicktime_mhvd_init_video(quicktime_t
*file
,
310 quicktime_mvhd_t
*mvhd
,
314 void quicktime_stsd_init_video(quicktime_t
*file
,
315 quicktime_stsd_t
*stsd
,
320 void quicktime_stsd_init_audio(quicktime_t
*file
,
321 quicktime_stsd_t
*stsd
,
326 void quicktime_stts_init_video(quicktime_t
*file
,
327 quicktime_stts_t
*stts
,
330 void quicktime_stbl_init_video(quicktime_t
*file
,
331 quicktime_stbl_t
*stbl
,
337 void quicktime_stbl_init_audio(quicktime_t
*file
,
338 quicktime_stbl_t
*stbl
,
343 void quicktime_minf_init_video(quicktime_t
*file
,
344 quicktime_minf_t
*minf
,
350 void quicktime_mdhd_init_video(quicktime_t
*file
,
351 quicktime_mdhd_t
*mdhd
,
355 void quicktime_mdhd_init_audio(quicktime_mdhd_t
*mdhd
,
357 void quicktime_minf_init_audio(quicktime_t
*file
,
358 quicktime_minf_t
*minf
,
363 void quicktime_mdia_init_video(quicktime_t
*file
,
364 quicktime_mdia_t
*mdia
,
369 void quicktime_mdia_init_audio(quicktime_t
*file
,
370 quicktime_mdia_t
*mdia
,
375 void quicktime_tkhd_init_video(quicktime_t
*file
,
376 quicktime_tkhd_t
*tkhd
,
379 int quicktime_get_timescale(double frame_rate
);
381 unsigned long quicktime_current_time(void);