1 /*******************************************************************************
2  lqt_funcprotos.h
3 
4  libquicktime - A library for reading and writing quicktime/avi/mp4 files.
5  http://libquicktime.sourceforge.net
6 
7  Copyright (C) 2002 Heroine Virtual Ltd.
8  Copyright (C) 2002-2011 Members of the libquicktime project.
9 
10  This library is free software; you can redistribute it and/or modify it under
11  the terms of the GNU Lesser General Public License as published by the Free
12  Software Foundation; either version 2.1 of the License, or (at your option)
13  any later version.
14 
15  This library is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
18  details.
19 
20  You should have received a copy of the GNU Lesser General Public License along
21  with this library; if not, write to the Free Software Foundation, Inc., 51
22  Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 *******************************************************************************/
24 #include <config.h>
25 #include <quicktime/lqt.h>
26 #include <quicktime/qtprivate.h>
27 
28 #ifdef HAVE_GCC_VISIBILITY
29 #define LQT_EXTERN __attribute__ ((visibility("default")))
30 #else
31 #define LQT_EXTERN extern
32 #endif
33 
34 /* Some macros */
35 
36 #define IS_QUICKTIME(type) (type & (LQT_FILE_QT_OLD | LQT_FILE_QT))
37 #define IS_MP4(type) (type & (LQT_FILE_MP4 | LQT_FILE_M4A | LQT_FILE_3GP))
38 #define IS_AVI(type) (type & (LQT_FILE_AVI | LQT_FILE_AVI_ODML))
39 
40 /* atom.c */
41 
42 int quicktime_atom_read_header(quicktime_t *file, quicktime_atom_t *atom);
43 int quicktime_atom_write_header64(quicktime_t *file, quicktime_atom_t *atom, char *text);
44 int quicktime_atom_write_header(quicktime_t *file, quicktime_atom_t *atom, char *text);
45 void quicktime_atom_write_footer(quicktime_t *file, quicktime_atom_t *atom);
46 int quicktime_atom_is(quicktime_atom_t *atom, char *type);
47 int quicktime_atom_skip(quicktime_t *file, quicktime_atom_t *atom);
48 
49 /* audio.c */
50 
51 void lqt_convert_audio_encode(quicktime_t * file, int16_t ** in_int, float ** in_float,
52                               void * out, int num_channels, int num_samples,
53                               lqt_sample_format_t stream_format);
54 
55 void lqt_convert_audio_decode(quicktime_t * file, void * in, int16_t ** out_int,
56                               float ** out_float, int num_channels, int num_samples,
57                               lqt_sample_format_t stream_format);
58 
59 
60 /* avi_avih.c */
61 
62 void quicktime_read_avih(quicktime_t *file,
63                          quicktime_avih_t *avih,
64                          quicktime_atom_t *parent_atom);
65 
66 void quicktime_write_avih(quicktime_t *file,
67                           quicktime_avih_t *avih);
68 
69 void quicktime_avih_dump(quicktime_avih_t *avih);
70 
71 void quicktime_avih_init(quicktime_avih_t *avih, quicktime_t * file);
72 
73 /* avi_guid.c */
74 
75 void quicktime_GUID_dump(quicktime_GUID_t * g);
76 int  quicktime_GUID_equal(const quicktime_GUID_t * g1, const quicktime_GUID_t * g2);
77 void quicktime_GUID_read(quicktime_t * file, quicktime_GUID_t * guid);
78 void quicktime_GUID_write(quicktime_t * file, quicktime_GUID_t * guid);
79 
80 /* avi_hdrl.c */
81 
82 void quicktime_read_hdrl(quicktime_t *file,
83                          quicktime_hdrl_t *hdrl,
84                          quicktime_atom_t *parent_atom);
85 
86 void quicktime_write_hdrl(quicktime_t *file);
87 
88 void quicktime_finalize_hdrl(quicktime_t *file, quicktime_hdrl_t *hdrl);
89 void quicktime_delete_hdrl(quicktime_t *file, quicktime_hdrl_t *hdrl);
90 void quicktime_init_hdrl(quicktime_t *file, quicktime_hdrl_t *hdrl);
91 
92 /* avi_idx1.c */
93 
94 void quicktime_read_idx1(quicktime_t *file,
95                          quicktime_riff_t *riff,
96                          quicktime_atom_t *parent_atom);
97 
98 void quicktime_delete_idx1(quicktime_idx1_t *idx1);
99 
100 void quicktime_write_idx1(quicktime_t *file,
101                           quicktime_idx1_t *idx1);
102 void quicktime_set_idx1_keyframe(quicktime_t *file,
103                                  quicktime_trak_t *trak,
104                                  int new_keyframe);
105 
106 void quicktime_update_idx1table(quicktime_t *file,
107                                 quicktime_trak_t *trak,
108                                 int offset,
109                                 int size);
110 
111 void quicktime_idx1_dump(quicktime_idx1_t *idx1);
112 
113 
114 /* avi_indx.c */
115 
116 void quicktime_finalize_indx(quicktime_t *file, quicktime_indx_t *indx);
117 
118 void quicktime_delete_indx(quicktime_indx_t *indx);
119 void quicktime_init_indx(quicktime_t *file,
120                          quicktime_indx_t *indx,
121                          quicktime_strl_t *strl);
122 
123 void quicktime_read_indx(quicktime_t *file,
124                          quicktime_strl_t *strl,
125                          quicktime_atom_t *parent_atom);
126 
127 void quicktime_indx_dump(quicktime_indx_t *);
128 
129 
130 void quicktime_indx_init_riff(quicktime_t *file, quicktime_trak_t * trak);
131 void quicktime_indx_finalize_riff(quicktime_t *file, quicktime_trak_t * trak);
132 
133 void quicktime_set_indx_keyframe(quicktime_t *file, quicktime_trak_t * trak,
134                                  long frame);
135 
136 /* avi_info.c */
137 
138 void quicktime_read_riffinfo(quicktime_t *file,
139                              quicktime_riffinfo_t *info,
140                              quicktime_atom_t *parent_atom);
141 
142 void quicktime_write_riffinfo(quicktime_t *file,
143                               quicktime_riffinfo_t *info);
144 
145 void quicktime_riffinfo_2_udta(quicktime_riffinfo_t * riffinfo,
146                                quicktime_udta_t * udta);
147 void quicktime_udta_2_riffinfo(quicktime_udta_t * udta,
148                                quicktime_riffinfo_t * riffinfo);
149 void quicktime_delete_riffinfo(quicktime_riffinfo_t * riffinfo);
150 void quicktime_init_riffinfo(quicktime_riffinfo_t * riffinfo);
151 
152 
153 /* avi_ix.c */
154 
155 quicktime_ix_t* quicktime_new_ix(quicktime_t *file,
156                                  quicktime_trak_t *trak,
157                                  quicktime_strl_t *strl);
158 void quicktime_delete_ix(quicktime_ix_t *ix);
159 void quicktime_update_ixtable(quicktime_t *file,
160                               quicktime_trak_t *trak,
161                               int64_t offset,
162                               int size);
163 void quicktime_write_ix(quicktime_t *file, quicktime_trak_t *trak);
164 
165 void quicktime_read_ix(quicktime_t *file,
166                        quicktime_ix_t *ix);
167 
168 void quicktime_ix_dump(quicktime_ix_t *ix);
169 
170 
171 
172 /* avi_movi.c */
173 
174 void quicktime_read_movi(quicktime_t *file,
175                          quicktime_atom_t *parent_atom,
176                          quicktime_movi_t *movi);
177 void quicktime_write_movi(quicktime_t *file);
178 void quicktime_delete_movi(quicktime_t *file, quicktime_movi_t *movi);
179 void quicktime_init_movi(quicktime_t *file, quicktime_riff_t *riff);
180 void quicktime_finalize_movi(quicktime_t *file, quicktime_movi_t *movi);
181 
182 /* avi_odml.c */
183 
184 void quicktime_finalize_odml(quicktime_t *file, quicktime_hdrl_t *hdrl);
185 void quicktime_init_odml(quicktime_t *file, quicktime_hdrl_t *hdrl);
186 
187 /* avi_riff.c */
188 
189 void quicktime_read_riff(quicktime_t *file, quicktime_atom_t *parent_atom);
190 void quicktime_delete_riff(quicktime_t *file, quicktime_riff_t *riff);
191 int quicktime_import_avi(quicktime_t *file);
192 void quicktime_init_riff(quicktime_t *file);
193 void quicktime_finalize_riff(quicktime_t *file, quicktime_riff_t *riff);
194 quicktime_riff_t* quicktime_new_riff(quicktime_t *file);
195 
196 void quicktime_riff_dump(quicktime_riff_t * riff);
197 
198 /* avi_strf.c */
199 
200 void quicktime_read_strf_audio(quicktime_t *file,
201                                quicktime_strf_t *strf,
202                                quicktime_atom_t *parent_atom);
203 
204 void quicktime_write_strf_audio(quicktime_t *file,
205                                 quicktime_strf_t *strf);
206 
207 void quicktime_strf_dump_audio(quicktime_strf_t *strf);
208 
209 void quicktime_read_strf_video(quicktime_t *file,
210                                quicktime_strf_t *strf,
211                                quicktime_atom_t *parent_atom);
212 
213 void quicktime_write_strf_video(quicktime_t *file,
214                                 quicktime_strf_t *strf);
215 
216 void quicktime_strf_dump_video(quicktime_strf_t *strf);
217 
218 void quicktime_strf_set_video_extradata(quicktime_strf_t *strf, const uint8_t * data, int len);
219 void quicktime_strf_delete_video(quicktime_strf_t *strf);
220 
221 LQT_EXTERN void quicktime_strf_set_audio_extradata(quicktime_strf_t *strf, const uint8_t * data, int len);
222 void quicktime_strf_delete_audio(quicktime_strf_t *strf);
223 
224 
225 
226 /* avi_strh.c */
227 
228 void quicktime_read_strh(quicktime_t *file,
229                          quicktime_strh_t *strh,
230                          quicktime_atom_t *parent_atom);
231 
232 void quicktime_write_strh(quicktime_t *file,
233                           quicktime_strh_t *strh);
234 
235 void quicktime_strh_dump(quicktime_strh_t *strh);
236 
237 
238 /* avi_strl.c */
239 
240 void quicktime_delete_strl(quicktime_strl_t *strl);
241 quicktime_strl_t* quicktime_new_strl();
242 
243 void quicktime_read_strl(quicktime_t *file,
244                          quicktime_strl_t *strl,
245                          quicktime_atom_t *parent_atom);
246 
247 void quicktime_strl_dump(quicktime_strl_t *strl);
248 
249 /* Convert an strl to a trak */
250 void quicktime_strl_2_qt(quicktime_t *file,
251                          quicktime_strl_t *strl);
252 
253 
254 void quicktime_init_strl(quicktime_t *file,
255                          quicktime_audio_map_t *atrack,
256                          quicktime_video_map_t *vtrack,
257                          quicktime_trak_t *trak,
258                          quicktime_strl_t *strl);
259 
260 void
261 quicktime_finalize_strl(quicktime_t *file, quicktime_trak_t * trak,
262                         quicktime_strl_t *strl);
263 
264 
265 
266 /* chan.c */
267 
268 void quicktime_chan_init(quicktime_chan_t *chan);
269 void quicktime_chan_delete(quicktime_chan_t *chan);
270 void quicktime_chan_dump(quicktime_chan_t *chan);
271 void quicktime_read_chan(quicktime_t *file, quicktime_chan_t *chan);
272 void quicktime_write_chan(quicktime_t *file, quicktime_chan_t *chan);
273 
274 /* Update an atrack from a chan atom */
275 void quicktime_get_chan(quicktime_audio_map_t * atrack);
276 
277 /* Set the chan atom of an atrack */
278 LQT_EXTERN void quicktime_set_chan(quicktime_audio_map_t * atrack);
279 
280 /* clap.c */
281 
282 void quicktime_clap_init(quicktime_clap_t *clap);
283 void quicktime_clap_delete(quicktime_clap_t *clap);
284 void quicktime_clap_dump(quicktime_clap_t *clap);
285 void quicktime_read_clap(quicktime_t *file, quicktime_clap_t *clap);
286 void quicktime_write_clap(quicktime_t *file, quicktime_clap_t *clap);
287 
288 // ******************************** Permutation *******************************
289 
290 #define PERMUTATION_ARGS \
291 	unsigned char **output_rows,  \
292 	unsigned char **input_rows, \
293 	int in_x,  \
294 	int in_y,  \
295 	int in_w,  \
296 	int in_h, \
297 	int out_w,  \
298 	int out_h, \
299 	int in_colormodel,  \
300 	int out_colormodel, \
301 	int in_rowspan, \
302 	int out_rowspan, \
303 	int in_rowspan_uv, \
304 	int out_rowspan_uv, \
305 	int scale, \
306 	int out_pixelsize, \
307 	int in_pixelsize, \
308 	int *row_table, \
309 	int *column_table
310 
311 
312 
313 /* cmodel_default.c */
314 
315 void cmodel_yuv420p(PERMUTATION_ARGS);
316 void cmodel_yuv422p(PERMUTATION_ARGS);
317 void cmodel_yuv411p(PERMUTATION_ARGS);
318 void cmodel_yuv444p(PERMUTATION_ARGS);
319 void cmodel_yuv422(PERMUTATION_ARGS);
320 void cmodel_default(PERMUTATION_ARGS);
321 
322 /* colr.c */
323 
324 void quicktime_colr_init(quicktime_colr_t *colr);
325 void quicktime_colr_delete(quicktime_colr_t *colr);
326 void quicktime_colr_dump(quicktime_colr_t *colr);
327 void quicktime_read_colr(quicktime_t *file, quicktime_colr_t *colr);
328 void quicktime_write_colr(quicktime_t *file, quicktime_colr_t *colr);
329 
330 /* ctab.c */
331 
332 int quicktime_ctab_init(quicktime_ctab_t *ctab);
333 int quicktime_ctab_delete(quicktime_ctab_t *ctab);
334 void quicktime_ctab_dump(quicktime_ctab_t *ctab);
335 int quicktime_read_ctab(quicktime_t *file, quicktime_ctab_t *ctab);
336 void quicktime_default_ctab(quicktime_ctab_t *ctab, int depth);
337 
338 /* ctts.c */
339 
340 void quicktime_ctts_init(quicktime_ctts_t *ctts);
341 void quicktime_ctts_delete(quicktime_ctts_t *ctts);
342 void quicktime_ctts_dump(quicktime_ctts_t *ctts);
343 void quicktime_read_ctts(quicktime_t *file, quicktime_ctts_t *ctts);
344 void quicktime_write_ctts(quicktime_t *file, quicktime_ctts_t *ctts);
345 void quicktime_update_ctts(quicktime_ctts_t *ctts, long sample, long duration);
346 void quicktime_compress_ctts(quicktime_ctts_t *ctts);
347 void quicktime_fix_ctts(quicktime_ctts_t *ctts);
348 
349 /* dinf.c */
350 
351 void quicktime_dinf_init(quicktime_dinf_t *dinf);
352 void quicktime_dinf_delete(quicktime_dinf_t *dinf);
353 void quicktime_dinf_init_all(quicktime_dinf_t *dinf, lqt_file_type_t type);
354 void quicktime_dinf_dump(quicktime_dinf_t *dinf);
355 void quicktime_read_dinf(quicktime_t *file, quicktime_dinf_t *dinf, quicktime_atom_t *dinf_atom);
356 void quicktime_write_dinf(quicktime_t *file, quicktime_dinf_t *dinf);
357 
358 /* dref.c */
359 
360 void quicktime_dref_table_init(quicktime_dref_table_t *table, lqt_file_type_t type);
361 void quicktime_dref_table_delete(quicktime_dref_table_t *table);
362 void quicktime_read_dref_table(quicktime_t *file, quicktime_dref_table_t *table);
363 void quicktime_write_dref_table(quicktime_t *file, quicktime_dref_table_t *table);
364 void quicktime_dref_table_dump(quicktime_dref_table_t *table);
365 void quicktime_dref_init(quicktime_dref_t *dref);
366 void quicktime_dref_init_all(quicktime_dref_t *dref, lqt_file_type_t type);
367 void quicktime_dref_delete(quicktime_dref_t *dref);
368 void quicktime_dref_dump(quicktime_dref_t *dref);
369 void quicktime_read_dref(quicktime_t *file, quicktime_dref_t *dref);
370 void quicktime_write_dref(quicktime_t *file, quicktime_dref_t *dref);
371 
372 /* edts.c */
373 
374 void quicktime_edts_init(quicktime_edts_t *edts);
375 void quicktime_edts_delete(quicktime_edts_t *edts);
376 void quicktime_edts_init_table(quicktime_edts_t *edts);
377 void quicktime_read_edts(quicktime_t *file, quicktime_edts_t *edts, quicktime_atom_t *edts_atom);
378 void quicktime_edts_dump(quicktime_edts_t *edts);
379 void quicktime_write_edts(quicktime_t *file, quicktime_edts_t *edts);
380 
381 /* enda.c */
382 
383 void quicktime_read_enda(quicktime_t *file, quicktime_enda_t *enda,
384                          quicktime_atom_t *enda_atom);
385 void quicktime_write_enda(quicktime_t *file, quicktime_enda_t *enda);
386 void quicktime_enda_dump(quicktime_enda_t *enda);
387 
388 LQT_EXTERN void quicktime_set_enda(quicktime_stsd_table_t *table, int little_endian);
389 
390 /* Returns TRUE if little endian */
391 LQT_EXTERN int quicktime_get_enda(quicktime_stsd_table_t *table);
392 
393 /* elst.c */
394 
395 void quicktime_elst_table_init(quicktime_elst_table_t *table);
396 void quicktime_elst_table_delete(quicktime_elst_table_t *table);
397 void quicktime_read_elst_table(quicktime_t *file, quicktime_elst_table_t *table);
398 void quicktime_write_elst_table(quicktime_t *file, quicktime_elst_table_t *table);
399 void quicktime_elst_table_dump(quicktime_elst_table_t *table);
400 void quicktime_elst_init(quicktime_elst_t *elst);
401 void quicktime_elst_init_all(quicktime_elst_t *elst);
402 void quicktime_elst_delete(quicktime_elst_t *elst);
403 void quicktime_elst_dump(quicktime_elst_t *elst);
404 void quicktime_read_elst(quicktime_t *file, quicktime_elst_t *elst);
405 void quicktime_write_elst(quicktime_t *file, quicktime_elst_t *elst);
406 void quicktime_elst_fix_counts(quicktime_elst_t *elst,
407                                int moov_scale, quicktime_trak_t * trak, int timescale);
408 int64_t quicktime_elst_get_pts_offset(quicktime_elst_t *elst,
409                                       int moov_scale, int timescale);
410 
411 
412 /* esds.c */
413 
414 void quicktime_read_esds(quicktime_t * file, quicktime_esds_t * esds);
415 void quicktime_write_esds(quicktime_t * file, quicktime_esds_t * esds);
416 void quicktime_esds_dump(quicktime_esds_t * esds);
417 void quicktime_esds_delete(quicktime_esds_t * esds);
418 
419 int quicktime_write_mp4_descr_length(quicktime_t *file,
420                                      int length, int compact);
421 int quicktime_read_mp4_descr_length(quicktime_t * file);
422 
423 /* Set up an esds atom for encoding. Arguments are  decoderConfig
424    and decoderConfigLen. The esds atom will be returned so the
425    other parameters can be set by the encoder */
426 
427 LQT_EXTERN quicktime_esds_t * quicktime_set_esds(quicktime_trak_t * trak,
428                                                  const uint8_t * decoderConfig,
429                                                  int decoderConfigLen);
430 
431 /* fiel.c */
432 
433 void quicktime_fiel_init(quicktime_fiel_t *fiel);
434 void quicktime_fiel_delete(quicktime_fiel_t *fiel);
435 void quicktime_fiel_dump(quicktime_fiel_t *fiel);
436 void quicktime_read_fiel(quicktime_t *file, quicktime_fiel_t *fiel);
437 void quicktime_write_fiel(quicktime_t *file, quicktime_fiel_t *fiel);
438 
439 
440 /* frma.c */
441 
442 void quicktime_read_frma(quicktime_t *file, quicktime_frma_t *frma,
443                          quicktime_atom_t *frma_atom);
444 
445 void quicktime_write_frma(quicktime_t *file, quicktime_frma_t *frma);
446 void quicktime_frma_dump(quicktime_frma_t *frma);
447 LQT_EXTERN void quicktime_set_frma(quicktime_trak_t * trak, char * codec);
448 
449 /* ftab.c */
450 
451 int quicktime_ftab_init(quicktime_ftab_t *ftab, int font_id, const char * font_name);
452 int quicktime_ftab_delete(quicktime_ftab_t *ftab);
453 void quicktime_ftab_dump(quicktime_ftab_t *ftab);
454 int quicktime_read_ftab(quicktime_t *file, quicktime_ftab_t *ftab);
455 void quicktime_write_ftab(quicktime_t *file, quicktime_ftab_t *ftab);
456 
457 
458 /* ftyp.c */
459 
460 
461 void quicktime_ftyp_init(quicktime_ftyp_t * ftyp, lqt_file_type_t type);
462 
463 lqt_file_type_t quicktime_ftyp_get_file_type(quicktime_ftyp_t * ftyp);
464 
465 void quicktime_read_ftyp(quicktime_t *file, quicktime_ftyp_t *ftyp,
466                          quicktime_atom_t *parent_atom);
467 void quicktime_write_ftyp(quicktime_t *file, quicktime_ftyp_t *ftyp);
468 void quicktime_ftyp_dump(quicktime_ftyp_t *ftyp);
469 void quicktime_ftyp_delete(quicktime_ftyp_t *ftyp);
470 
471 /* gama.c */
472 
473 void quicktime_gama_init(quicktime_gama_t *gama);
474 void quicktime_gama_delete(quicktime_gama_t *gama);
475 void quicktime_gama_dump(quicktime_gama_t *gama);
476 void quicktime_read_gama(quicktime_t *file, quicktime_gama_t *gama);
477 void quicktime_write_gama(quicktime_t *file, quicktime_gama_t *gama);
478 
479 
480 /* gmhd.c */
481 
482 void quicktime_gmhd_init(quicktime_gmhd_t *gmhd);
483 void quicktime_gmhd_delete(quicktime_gmhd_t *gmhd);
484 void quicktime_gmhd_dump(quicktime_gmhd_t *gmhd);
485 void quicktime_read_gmhd(quicktime_t *file, quicktime_gmhd_t *gmhd, quicktime_atom_t *parent_atom);
486 void quicktime_write_gmhd(quicktime_t *file, quicktime_gmhd_t *gmhd);
487 void quicktime_gmhd_init_timecode(quicktime_gmhd_t *gmhd);
488 
489 
490 /* gmhd_text.c */
491 
492 void quicktime_gmhd_text_init(quicktime_gmhd_text_t *gmhd);
493 void quicktime_gmhd_text_delete(quicktime_gmhd_text_t *gmhd);
494 void quicktime_gmhd_text_dump(quicktime_gmhd_text_t *gmhd);
495 void quicktime_read_gmhd_text(quicktime_t *file,
496                               quicktime_gmhd_text_t *gmhd,
497                               quicktime_atom_t *parent_atom);
498 void quicktime_write_gmhd_text(quicktime_t *file,
499                                quicktime_gmhd_text_t *gmhd);
500 
501 
502 /* gmin.c */
503 
504 void quicktime_gmin_init(quicktime_gmin_t *gmin);
505 void quicktime_gmin_delete(quicktime_gmin_t *gmin);
506 void quicktime_gmin_dump(quicktime_gmin_t *gmin);
507 void quicktime_read_gmin(quicktime_t *file, quicktime_gmin_t *gmin);
508 void quicktime_write_gmin(quicktime_t *file, quicktime_gmin_t *gmin);
509 
510 /* hdlr.c */
511 
512 void quicktime_hdlr_init(quicktime_hdlr_t *hdlr);
513 void quicktime_hdlr_init_video(quicktime_hdlr_t *hdlr);
514 void quicktime_hdlr_init_panorama(quicktime_hdlr_t *hdlr);
515 int quicktime_hdlr_init_qtvr(quicktime_hdlr_t *hdlr, int track_type);
516 void quicktime_hdlr_init_audio(quicktime_hdlr_t *hdlr);
517 void quicktime_hdlr_init_data(quicktime_hdlr_t *hdlr);
518 void quicktime_hdlr_init_text(quicktime_hdlr_t *hdlr);
519 void quicktime_hdlr_init_tx3g(quicktime_hdlr_t *hdlr);
520 void quicktime_hdlr_init_timecode(quicktime_hdlr_t *hdlr);
521 
522 
523 void quicktime_hdlr_init_udta(quicktime_hdlr_t *hdlr);
524 void quicktime_hdlr_delete(quicktime_hdlr_t *hdlr);
525 void quicktime_hdlr_dump(quicktime_hdlr_t *hdlr);
526 void quicktime_read_hdlr(quicktime_t *file, quicktime_hdlr_t *hdlr, quicktime_atom_t * parent_atom);
527 void quicktime_write_hdlr(quicktime_t *file, quicktime_hdlr_t *hdlr);
528 
529 /* imgp.c */
530 
531 int quicktime_imgp_init(quicktime_imgp_t *imgp);
532 int quicktime_imgp_delete(quicktime_imgp_t *imgp);
533 void quicktime_imgp_dump(quicktime_imgp_t *imgp);
534 int quicktime_read_imgp(quicktime_t *file, quicktime_imgp_t *imgp, quicktime_qtatom_t *imgp_atom);
535 void quicktime_write_imgp(quicktime_t *file, quicktime_imgp_t *imgp);
536 
537 /* impn.c */
538 
539 int quicktime_impn_init(quicktime_impn_t *impn);
540 int quicktime_impn_delete(quicktime_impn_t *impn);
541 void quicktime_impn_dump(quicktime_impn_t *impn);
542 int quicktime_read_impn(quicktime_t *file, quicktime_impn_t *impn, quicktime_qtatom_t *impn_atom);
543 void quicktime_write_impn(quicktime_t *file, quicktime_impn_t *impn);
544 
545 /* iods.c */
546 
547 void quicktime_iods_init(quicktime_iods_t * iods);
548 void quicktime_iods_add_track(quicktime_iods_t * iods, quicktime_trak_t * trak);
549 void quicktime_read_iods(quicktime_t *file, quicktime_iods_t * iods);
550 void quicktime_write_iods(quicktime_t *file, quicktime_moov_t * moov);
551 void quicktime_iods_dump(quicktime_iods_t * iods);
552 void quicktime_iods_delete(quicktime_iods_t * iods);
553 
554 /* language.c */
555 
556 const char * lqt_get_charset(int mac_code, lqt_file_type_t file_type);
557 
558 /* Macintosh charsets are not supported everywhere, but some are pretty
559    close to other ones */
560 const char * lqt_get_charset_fallback(int mac_code, lqt_file_type_t file_type);
561 
562 /* log.c */
563 
564 LQT_EXTERN void lqt_log(quicktime_t * file, lqt_log_level_t level,
565              const char * domain, const char * format, ...)
566   __attribute__ ((format (printf, 4, 5)));
567 
568 LQT_EXTERN void lqt_logs(quicktime_t * file, lqt_log_level_t level,
569               const char * domain, const char * str);
570 
571 /* For dumping strings */
572 void lqt_dump(const char * format, ...)  __attribute__ ((format (printf, 1, 2)));
573 
574 /* lqt_codecinfo.c */
575 
576 lqt_codec_info_t * lqt_codec_info_copy_single(const lqt_codec_info_t * info);
577 void lqt_codec_info_destroy_single(lqt_codec_info_t * info);
578 
579 /* matrix.c */
580 
581 void quicktime_matrix_init(quicktime_matrix_t *matrix);
582 void quicktime_matrix_delete(quicktime_matrix_t *matrix);
583 void quicktime_read_matrix(quicktime_t *file, quicktime_matrix_t *matrix);
584 void quicktime_matrix_dump(quicktime_matrix_t *matrix);
585 void quicktime_write_matrix(quicktime_t *file, quicktime_matrix_t *matrix);
586 
587 /* mdat.c */
588 
589 void quicktime_mdat_delete(quicktime_mdat_t *mdat);
590 void quicktime_read_mdat(quicktime_t *file, quicktime_mdat_t *mdat, quicktime_atom_t *parent_atom);
591 
592 /* mdhd.c */
593 
594 void quicktime_mdhd_init(quicktime_mdhd_t *mdhd);
595 void quicktime_mdhd_delete(quicktime_mdhd_t *mdhd);
596 
597 void quicktime_mdhd_dump(quicktime_mdhd_t *mdhd);
598 
599 void quicktime_read_mdhd(quicktime_t *file, quicktime_mdhd_t *mdhd);
600 void quicktime_write_mdhd(quicktime_t *file, quicktime_mdhd_t *mdhd);
601 
602 void quicktime_mdhd_init_audio(quicktime_t *file,
603                                quicktime_mdhd_t *mdhd,
604                                int sample_rate);
605 
606 void quicktime_mdhd_init_video(quicktime_t *file,
607                                quicktime_mdhd_t *mdhd,
608                                int timescale);
609 
610 void quicktime_mdhd_init_text(quicktime_t *file,
611                               quicktime_mdhd_t *mdhd,
612                               int timescale);
613 
614 /* mdia.c */
615 
616 void quicktime_mdia_init(quicktime_mdia_t *mdia);
617 void quicktime_mdia_delete(quicktime_mdia_t *mdia);
618 void quicktime_mdia_dump(quicktime_mdia_t *mdia);
619 int quicktime_read_mdia(quicktime_t *file, quicktime_trak_t *trak,
620                         quicktime_mdia_t *mdia, quicktime_atom_t *trak_atom);
621 void quicktime_write_mdia(quicktime_t *file, quicktime_mdia_t *mdia);
622 
623 void quicktime_mdia_init_audio(quicktime_t *file,
624                                quicktime_mdia_t *mdia,
625                                int channels,
626                                int sample_rate,
627                                int bits,
628                                char *compressor);
629 
630 void quicktime_mdia_init_video(quicktime_t *file,
631                                quicktime_mdia_t *mdia,
632                                int frame_w,
633                                int frame_h,
634                                int frame_duration,
635                                int timescale,
636                                char *compressor);
637 
638 void quicktime_mdia_init_panorama(quicktime_t *file,
639 				  quicktime_mdia_t *mdia,
640 				  int width,
641 				  int height,
642 				  int frame_duration,
643 				  int timescale);
644 
645 void quicktime_mdia_init_qtvr(quicktime_t *file,
646 				  quicktime_mdia_t *mdia,
647 				  int track_type,
648 				  int frame_duration,
649 				  int timescale);
650 
651 void quicktime_mdia_init_text(quicktime_t * file,
652                               quicktime_mdia_t * mdia,
653                               int timescale);
654 
655 void quicktime_mdia_init_tx3g(quicktime_t * file,
656                               quicktime_mdia_t * mdia,
657                               int timescale);
658 
659 void quicktime_mdia_init_timecode(quicktime_t *file,
660                                   quicktime_mdia_t *mdia,
661                                   int time_scale,
662                                   int frame_duration,
663                                   int num_frames,
664                                   uint32_t flags);
665 
666 
667 /* minf.c */
668 
669 void quicktime_minf_init(quicktime_minf_t *minf);
670 
671 void quicktime_minf_dump(quicktime_minf_t *minf);
672 int quicktime_read_minf(quicktime_t *file, quicktime_trak_t *trak,
673                         quicktime_minf_t *minf, quicktime_atom_t *parent_atom);
674 void quicktime_write_minf(quicktime_t *file, quicktime_minf_t *minf);
675 void quicktime_minf_delete(quicktime_minf_t *minf);
676 
677 void quicktime_minf_init_video(quicktime_t *file,
678                                quicktime_minf_t *minf,
679                                int frame_w,
680                                int frame_h,
681                                int frame_duration,
682                                int time_scale,
683                                char *compressor);
684 
685 void quicktime_minf_init_audio(quicktime_t *file,
686                                quicktime_minf_t *minf,
687                                int channels,
688                                int sample_rate,
689                                int bits,
690                                char *compressor);
691 
692 void quicktime_minf_init_panorama(quicktime_t *file,
693 				  quicktime_minf_t *minf,
694 				  int width,
695 				  int height,
696 				  int frame_duration);
697 
698 void quicktime_minf_init_qtvr(quicktime_t *file,
699 				  quicktime_minf_t *minf,
700 				  int frame_type,
701 				  int frame_duration);
702 
703 void quicktime_minf_init_text(quicktime_t *file,
704                               quicktime_minf_t *minf);
705 
706 void quicktime_minf_init_tx3g(quicktime_t *file,
707                               quicktime_minf_t *minf);
708 
709 void quicktime_minf_init_timecode(quicktime_t *file,
710                                   quicktime_minf_t *minf,
711                                   int time_scale,
712                                   int frame_duration,
713                                   int num_frames,
714                                   uint32_t flags);
715 
716 /* moov.c */
717 
718 int quicktime_moov_init(quicktime_moov_t *moov);
719 int quicktime_moov_delete(quicktime_moov_t *moov);
720 void quicktime_moov_dump(quicktime_moov_t *moov);
721 int quicktime_read_moov(quicktime_t *file, quicktime_moov_t *moov, quicktime_atom_t *parent_atom);
722 void quicktime_finalize_moov(quicktime_t *file, quicktime_moov_t *moov);
723 void quicktime_write_moov(quicktime_t *file, quicktime_moov_t *moov);
724 void quicktime_update_durations(quicktime_moov_t *moov);
725 int quicktime_shift_offsets(quicktime_moov_t *moov, int64_t offset);
726 
727 /* mvhd.c */
728 
729 int quicktime_mvhd_init(quicktime_mvhd_t *mvhd);
730 int quicktime_mvhd_delete(quicktime_mvhd_t *mvhd);
731 void quicktime_mvhd_dump(quicktime_mvhd_t *mvhd);
732 void quicktime_read_mvhd(quicktime_t *file, quicktime_mvhd_t *mvhd, quicktime_atom_t *parent_atom);
733 void quicktime_mhvd_init_video(quicktime_t *file, quicktime_mvhd_t *mvhd, int time_scale);
734 void quicktime_write_mvhd(quicktime_t *file, quicktime_mvhd_t *mvhd);
735 
736 /* navg.c */
737 
738 int quicktime_navg_init(quicktime_navg_t *navg);
739 int quicktime_navg_delete(quicktime_navg_t *navg);
740 void quicktime_navg_dump(quicktime_navg_t *navg);
741 int quicktime_read_navg(quicktime_t *file, quicktime_navg_t *navg, quicktime_atom_t *navg_atom);
742 void quicktime_write_navg(quicktime_t *file, quicktime_navg_t *navg);
743 
744 /* ndhd */
745 
746 int quicktime_ndhd_init(quicktime_ndhd_t *ndhd);
747 int quicktime_ndhd_delete(quicktime_ndhd_t *ndhd);
748 void quicktime_ndhd_dump(quicktime_ndhd_t *ndhd);
749 int quicktime_read_ndhd(quicktime_t *file, quicktime_ndhd_t *ndhd);
750 void quicktime_write_ndhd(quicktime_t *file, quicktime_ndhd_t *ndhd);
751 
752 /* nloc.c */
753 
754 int quicktime_nloc_init(quicktime_nloc_t *nloc);
755 int quicktime_nloc_delete(quicktime_nloc_t *nloc);
756 void quicktime_nloc_dump(quicktime_nloc_t *nloc);
757 int quicktime_read_nloc(quicktime_t *file, quicktime_nloc_t *nloc, quicktime_qtatom_t *nloc_atom);
758 void quicktime_write_nloc(quicktime_t *file, quicktime_nloc_t *nloc);
759 
760 /* nmhd.c */
761 
762 int quicktime_nmhd_init(quicktime_nmhd_t *nmhd);
763 int quicktime_nmhd_delete(quicktime_nmhd_t *nmhd);
764 void quicktime_nmhd_dump(quicktime_nmhd_t *nmhd);
765 int quicktime_read_nmhd(quicktime_t *file, quicktime_nmhd_t *nmhd);
766 void quicktime_write_nmhd(quicktime_t *file, quicktime_nmhd_t *nmhd);
767 
768 
769 /* obji.c */
770 
771 int quicktime_obji_init(quicktime_obji_t *obji);
772 int quicktime_obji_delete(quicktime_obji_t *obji);
773 void quicktime_obji_dump(quicktime_obji_t *obji);
774 int quicktime_read_obji(quicktime_t *file, quicktime_obji_t *obji);
775 void quicktime_write_obji(quicktime_t *file, quicktime_obji_t *obji);
776 
777 /* pano.c */
778 
779 int quicktime_pano_init(quicktime_pano_t *pano);
780 int quicktime_pano_delete(quicktime_pano_t *pano);
781 void quicktime_pano_dump(quicktime_pano_t *pano);
782 int quicktime_read_pano(quicktime_t *file, quicktime_pano_t *navg, quicktime_atom_t *pano_atom);
783 void quicktime_write_pano(quicktime_t *file, quicktime_pano_t *pano);
784 
785 /* pasp.c */
786 
787 void quicktime_pasp_init(quicktime_pasp_t *pasp);
788 void quicktime_pasp_delete(quicktime_pasp_t *pasp);
789 void quicktime_pasp_dump(quicktime_pasp_t *pasp);
790 void quicktime_read_pasp(quicktime_t *file, quicktime_pasp_t *pasp);
791 void quicktime_write_pasp(quicktime_t *file, quicktime_pasp_t *pasp);
792 
793 /* pdat.c */
794 
795 int quicktime_pdat_init(quicktime_pdat_t *pdat);
796 int quicktime_pdat_delete(quicktime_pdat_t *pdat);
797 void quicktime_pdat_dump(quicktime_pdat_t *pdat);
798 int quicktime_read_pdat(quicktime_t *file, quicktime_pdat_t *pdat);
799 void quicktime_write_pdat(quicktime_t *file, quicktime_pdat_t *pdat);
800 
801 /* pHdr */
802 
803 int quicktime_pHdr_init(quicktime_pHdr_t *pHdr);
804 int quicktime_pHdr_init(quicktime_pHdr_t *pHdr);
805 int quicktime_pHdr_delete(quicktime_pHdr_t *pHdr);
806 void quicktime_pHdr_dump(quicktime_pHdr_t *pHdr);
807 
808 int quicktime_read_pHdr(quicktime_t *file,
809                         quicktime_pHdr_t *pHdr,
810                         quicktime_atom_t *pHdr_atom);
811 
812 void quicktime_write_pHdr(quicktime_t *file,
813                           quicktime_pHdr_t *pHdr);
814 
815 /* qtatom.c */
816 
817 int quicktime_qtatom_read_header(quicktime_t *file, quicktime_qtatom_t *atom);
818 int quicktime_qtatom_write_header(quicktime_t *file, quicktime_qtatom_t *atom, char *text, long ID);
819 void quicktime_qtatom_write_footer(quicktime_t *file, quicktime_qtatom_t *atom);
820 int quicktime_qtatom_is(quicktime_qtatom_t *atom, char *type);
821 int quicktime_qtatom_skip(quicktime_t *file, quicktime_qtatom_t *atom);
822 void quicktime_qtatom_read_container_header(quicktime_t *file);
823 void quicktime_qtatom_write_container_header(quicktime_t *file);
824 
825 /* qtvr.c */
826 
827 int quicktime_qtvr_init(quicktime_qtvr_t *qtvr);
828 int quicktime_qtvr_delete(quicktime_qtvr_t *qtvr);
829 void quicktime_qtvr_dump(quicktime_qtvr_t *qtvr);
830 int quicktime_read_qtvr(quicktime_t *file, quicktime_qtvr_t *qtvr, quicktime_atom_t *qtvr_atom);
831 void quicktime_write_qtvr(quicktime_t *file, quicktime_qtvr_t *qtvr);
832 
833 /* smhd.c */
834 
835 void quicktime_smhd_init(quicktime_smhd_t *smhd);
836 void quicktime_smhd_delete(quicktime_smhd_t *smhd);
837 void quicktime_smhd_dump(quicktime_smhd_t *smhd);
838 void quicktime_read_smhd(quicktime_t *file, quicktime_smhd_t *smhd);
839 void quicktime_write_smhd(quicktime_t *file, quicktime_smhd_t *smhd);
840 
841 /* stbl.c */
842 
843 void quicktime_stbl_init(quicktime_stbl_t *stbl);
844 void quicktime_stbl_delete(quicktime_stbl_t *stbl);
845 void quicktime_stbl_dump(void *minf_ptr, quicktime_stbl_t *stbl);
846 int quicktime_read_stbl(quicktime_t *file, quicktime_minf_t *minf,
847                         quicktime_stbl_t *stbl, quicktime_atom_t *parent_atom);
848 
849 void quicktime_write_stbl(quicktime_t *file, quicktime_minf_t *minf,
850                           quicktime_stbl_t *stbl);
851 
852 void quicktime_stbl_init_video(quicktime_t *file,
853                                quicktime_stbl_t *stbl,
854                                int frame_w,
855                                int frame_h,
856                                int frame_duration,
857                                int time_scale,
858                                char *compressor);
859 
860 void quicktime_stbl_init_audio(quicktime_t *file,
861                                quicktime_stbl_t *stbl,
862                                int channels,
863                                int sample_rate,
864                                int bits,
865                                char *compressor);
866 
867 void quicktime_stbl_init_panorama(quicktime_t *file,
868 				  quicktime_stbl_t *stbl,
869 				  int width,
870 				  int height,
871 				  int frame_duration);
872 
873 void quicktime_stbl_init_qtvr(quicktime_t *file,
874 				  quicktime_stbl_t *stbl,
875 				  int track_type,
876 				  int frame_duration);
877 
878 void quicktime_stbl_init_text(quicktime_t *file,
879                               quicktime_stbl_t *stbl);
880 
881 void quicktime_stbl_init_tx3g(quicktime_t *file,
882                               quicktime_stbl_t *stbl);
883 
884 void quicktime_stbl_init_timecode(quicktime_t *file,
885                                   quicktime_stbl_t *stbl,
886                                   int time_scale,
887                                   int frame_duration,
888                                   int num_frames,
889                                   uint32_t flags);
890 
891 /* stco.c */
892 
893 void quicktime_stco_init(quicktime_stco_t *stco);
894 void quicktime_stco_delete(quicktime_stco_t *stco);
895 void quicktime_stco_init_common(quicktime_t *file, quicktime_stco_t *stco);
896 void quicktime_stco_dump(quicktime_stco_t *stco);
897 void quicktime_read_stco(quicktime_t *file, quicktime_stco_t *stco);
898 void quicktime_read_stco64(quicktime_t *file, quicktime_stco_t *stco);
899 void quicktime_write_stco(quicktime_t *file, quicktime_stco_t *stco);
900 void quicktime_update_stco(quicktime_stco_t *stco, long chunk, int64_t offset);
901 
902 /* stsc.c */
903 
904 void quicktime_stsc_init(quicktime_stsc_t *stsc);
905 void quicktime_stsc_init_table(quicktime_t *file, quicktime_stsc_t *stsc);
906 void quicktime_stsc_init_video(quicktime_t *file, quicktime_stsc_t *stsc);
907 void quicktime_stsc_init_audio(quicktime_t *file, quicktime_stsc_t *stsc, int sample_rate);
908 void quicktime_stsc_delete(quicktime_stsc_t *stsc);
909 void quicktime_stsc_dump(quicktime_stsc_t *stsc);
910 void quicktime_read_stsc(quicktime_t *file, quicktime_stsc_t *stsc);
911 void quicktime_write_stsc(quicktime_t *file, quicktime_stsc_t *stsc);
912 int quicktime_update_stsc(quicktime_stsc_t *stsc, long chunk, long samples);
913 void quicktime_compress_stsc(quicktime_stsc_t *stsc);
914 
915 /* stsd.c */
916 
917 void quicktime_stsd_init(quicktime_stsd_t *stsd);
918 void quicktime_stsd_init_table(quicktime_stsd_t *stsd);
919 void quicktime_stsd_delete(quicktime_stsd_t *stsd);
920 void quicktime_stsd_dump(void *minf_ptr, quicktime_stsd_t *stsd);
921 void quicktime_read_stsd(quicktime_t *file, quicktime_stsd_t *stsd);
922 void quicktime_write_stsd(quicktime_t *file, quicktime_minf_t *minf, quicktime_stsd_t *stsd);
923 
924 /* This function is called by the decoder after the complete minf atom is read (i.e. if we know
925    for sure, what kind of stream it is. */
926 
927 void quicktime_finalize_stsd(quicktime_t * file, quicktime_trak_t * trak, quicktime_stsd_t * stsd);
928 
929 
930 void quicktime_stsd_set_video_codec(quicktime_stsd_t *stsd,
931                                     char * compression);
932 
933 void quicktime_stsd_set_audio_codec(quicktime_stsd_t *stsd,
934                                     char * compression);
935 
936 void quicktime_stsd_init_video(quicktime_t *file,
937                                quicktime_stsd_t *stsd,
938                                int frame_w,
939                                int frame_h,
940                                char *compression);
941 
942 void quicktime_stsd_init_audio(quicktime_t *file,
943                                quicktime_stsd_t *stsd,
944                                int channels,
945                                int sample_rate,
946                                int bits,
947                                char *compressor);
948 
949 void quicktime_stsd_init_panorama(quicktime_t *file,
950 				  quicktime_stsd_t *stsd,
951 				  int width,
952 				  int height);
953 
954 int quicktime_stsd_init_qtvr(quicktime_t *file,
955                               quicktime_stsd_t *stsd,
956                               int track_type);
957 
958 void quicktime_stsd_init_text(quicktime_t *file,
959                               quicktime_stsd_t *stsd);
960 
961 void quicktime_stsd_init_tx3g(quicktime_t *file,
962                               quicktime_stsd_t *stsd);
963 
964 void quicktime_stsd_init_timecode(quicktime_t *file,
965 				  quicktime_stsd_t *stsd,
966 				  int timescale,
967 				  int frameduration,
968 				  int numframes, uint32_t flags);
969 
970 /* stsdtable.c */
971 
972 
973 void quicktime_read_stsd_audio(quicktime_t *file, quicktime_stsd_table_t *table,
974                                quicktime_atom_t *parent_atom);
975 void quicktime_write_stsd_audio(quicktime_t *file, quicktime_stsd_table_t *table);
976 void quicktime_read_stsd_video(quicktime_t *file, quicktime_stsd_table_t *table,
977                                quicktime_atom_t *parent_atom);
978 
979 LQT_EXTERN void quicktime_set_stsd_audio_v1(quicktime_stsd_table_t *table,
980                                  uint32_t samples_per_packet,
981                                  uint32_t bytes_per_packet,
982                                  uint32_t bytes_per_frame,
983                                  uint32_t bytes_per_sample);
984 
985 LQT_EXTERN void
986 quicktime_set_stsd_audio_v2(quicktime_stsd_table_t *table,
987                             uint32_t formatSpecificFlags,
988                             uint32_t constBytesPerAudioPacket,
989                             uint32_t constLPCMFramesPerAudioPacket);
990 
991 void quicktime_write_stsd_video(quicktime_t *file, quicktime_stsd_table_t *table);
992 void quicktime_read_stsd_table(quicktime_t *file, quicktime_minf_t *minf, quicktime_stsd_table_t *table);
993 
994 void quicktime_read_stsd_table_raw(quicktime_t *file, quicktime_stsd_table_t *table);
995 
996 void quicktime_stsd_table_init(quicktime_stsd_table_t *table);
997 
998 void quicktime_stsd_table_delete(quicktime_stsd_table_t *table);
999 void quicktime_stsd_video_dump(quicktime_stsd_table_t *table);
1000 void quicktime_stsd_audio_dump(quicktime_stsd_table_t *table);
1001 void quicktime_stsd_table_dump(void *minf_ptr, quicktime_stsd_table_t *table);
1002 void quicktime_write_stsd_table(quicktime_t *file, quicktime_minf_t *minf, quicktime_stsd_table_t *table);
1003 
1004 LQT_EXTERN uint8_t * quicktime_stsd_get_user_atom(quicktime_trak_t * trak, char * name, uint32_t * len);
1005 LQT_EXTERN void quicktime_stsd_set_user_atom(quicktime_trak_t * trak, char * name,
1006                                   uint8_t * data, uint32_t len);
1007 
1008 
1009 
1010 /* stss.c */
1011 
1012 void quicktime_stss_init(quicktime_stss_t *stss);
1013 void quicktime_stss_delete(quicktime_stss_t *stss);
1014 void quicktime_stss_dump(quicktime_stss_t *stss);
1015 void quicktime_read_stss(quicktime_t *file, quicktime_stss_t *stss);
1016 void quicktime_write_stss(quicktime_t *file, quicktime_stss_t *stss);
1017 
1018 /* stsz.c */
1019 
1020 void quicktime_stsz_init(quicktime_stsz_t *stsz);
1021 void quicktime_stsz_init_video(quicktime_t *file, quicktime_stsz_t *stsz);
1022 void quicktime_stsz_init_audio(quicktime_t *file,
1023                                quicktime_stsz_t *stsz,
1024                                int channels,
1025                                int bits,
1026                                char *compressor);
1027 void quicktime_stsz_delete(quicktime_stsz_t *stsz);
1028 void quicktime_stsz_dump(quicktime_stsz_t *stsz);
1029 void quicktime_read_stsz(quicktime_t *file, quicktime_stsz_t *stsz);
1030 void quicktime_write_stsz(quicktime_t *file, quicktime_stsz_t *stsz);
1031 void quicktime_update_stsz(quicktime_stsz_t *stsz,
1032                            long sample,
1033                            long sample_size);
1034 void quicktime_stsz_init_timecode(quicktime_stsz_t *stsz);
1035 
1036 /* stts.c */
1037 
1038 void quicktime_stts_init(quicktime_stts_t *stts);
1039 void quicktime_stts_init_table(quicktime_stts_t *stts);
1040 void quicktime_stts_init_video(quicktime_t *file, quicktime_stts_t *stts, int frame_duration);
1041 void quicktime_stts_init_audio(quicktime_t *file, quicktime_stts_t *stts, int sample_rate);
1042 void quicktime_stts_init_timecode(quicktime_t *file, quicktime_stts_t *stts);
1043 void quicktime_stts_init_qtvr(quicktime_t *file,
1044                               quicktime_stts_t *stts, int frame_duration);
1045 
1046 
1047 void quicktime_stts_delete(quicktime_stts_t *stts);
1048 void quicktime_stts_dump(quicktime_stts_t *stts);
1049 void quicktime_read_stts(quicktime_t *file, quicktime_stts_t *stts);
1050 void quicktime_write_stts(quicktime_t *file, quicktime_stts_t *stts);
1051 LQT_EXTERN void quicktime_update_stts(quicktime_stts_t *stts, long sample, long duration);
1052 /* The following function kicks out redundant entries */
1053 void quicktime_compress_stts(quicktime_stts_t *stts);
1054 
1055 void quicktime_stts_init_panorama(quicktime_t *file, quicktime_stts_t *stts, int frame_duration);
1056 
1057 
1058 int64_t quicktime_time_to_sample(quicktime_stts_t *stts, int64_t * time,
1059                                  int64_t * stts_index, int64_t * stts_count);
1060 
1061 int64_t quicktime_sample_to_time(quicktime_stts_t *stts, int64_t sample,
1062                                  int64_t * stts_index, int64_t * stts_count);
1063 
1064 
1065 
1066 /* texttrack.c */
1067 
1068 void lqt_init_text_map(quicktime_t * file,
1069                        quicktime_text_map_t * map, quicktime_trak_t * trak,
1070                        int encode);
1071 
1072 void lqt_delete_text_map(quicktime_t * file,
1073                          quicktime_text_map_t * map);
1074 
1075 /* tkhd.c */
1076 
1077 int quicktime_tkhd_init(quicktime_tkhd_t *tkhd, lqt_file_type_t type);
1078 int quicktime_tkhd_delete(quicktime_tkhd_t *tkhd);
1079 void quicktime_tkhd_dump(quicktime_tkhd_t *tkhd);
1080 void quicktime_read_tkhd(quicktime_t *file, quicktime_tkhd_t *tkhd);
1081 void quicktime_write_tkhd(quicktime_t *file, quicktime_tkhd_t *tkhd);
1082 void quicktime_tkhd_init_video(quicktime_t *file, quicktime_tkhd_t *tkhd,
1083                                int frame_w, int frame_h);
1084 
1085 void quicktime_tkhd_init_timecode(quicktime_t *file,
1086                                   quicktime_tkhd_t *tkhd,
1087                                   int frame_w,
1088                                   int frame_h);
1089 
1090 
1091 /* trak.c */
1092 
1093 int quicktime_trak_init(quicktime_trak_t *trak, lqt_file_type_t type);
1094 int quicktime_trak_init_video(quicktime_t *file,
1095                               quicktime_trak_t *trak,
1096                               int frame_w,
1097                               int frame_h,
1098                               int frame_duration,
1099                               int time_scale,
1100                               char *compressor);
1101 
1102 int quicktime_trak_init_audio(quicktime_t *file,
1103                               quicktime_trak_t *trak,
1104                               int channels,
1105                               int sample_rate,
1106                               int bits,
1107                               char *compressor);
1108 
1109 int quicktime_trak_init_qtvr(quicktime_t *file,
1110 				 quicktime_trak_t *trak,
1111 				 int track_type,
1112 				 int width,
1113 				 int height,
1114 				 int timescale,
1115 				 int frame_duration);
1116 
1117 int quicktime_trak_init_text(quicktime_t * file, quicktime_trak_t * trak,
1118                              int timescale);
1119 
1120 int quicktime_trak_init_tx3g(quicktime_t * file, quicktime_trak_t * trak,
1121                              int timescale);
1122 
1123 int quicktime_trak_init_timecode(quicktime_t *file,
1124                                  quicktime_trak_t *trak,
1125                                  int time_scale,
1126                                  int frame_duration,
1127                                  int num_frames,
1128                                  int frame_w,
1129                                  int frame_h,
1130                                  uint32_t flags);
1131 
1132 int quicktime_trak_init_panorama(quicktime_t *file,
1133 				 quicktime_trak_t *trak,
1134 				 int width,
1135 				 int height,
1136 				 int timescale,
1137 				 int frame_duration);
1138 
1139 int quicktime_trak_delete(quicktime_trak_t *trak);
1140 int quicktime_trak_dump(quicktime_trak_t *trak);
1141 quicktime_trak_t* quicktime_add_trak(quicktime_t *file);
1142 int quicktime_delete_trak(quicktime_moov_t *moov);
1143 int quicktime_read_trak(quicktime_t *file, quicktime_trak_t *trak, quicktime_atom_t *trak_atom);
1144 int quicktime_write_trak(quicktime_t *file, quicktime_trak_t *trak);
1145 int64_t quicktime_track_samples(quicktime_t *file, quicktime_trak_t *trak);
1146 long quicktime_sample_of_chunk(quicktime_trak_t *trak, long chunk);
1147 
1148 /* translation.c */
1149 
1150 LQT_EXTERN void lqt_translation_init();
1151 
1152 
1153 /* useratoms.c */
1154 
1155 LQT_EXTERN uint8_t *
1156 quicktime_user_atoms_get_atom(quicktime_user_atoms_t * u,
1157                               char * name, uint32_t * len);
1158 
1159 LQT_EXTERN void quicktime_user_atoms_add_atom(quicktime_user_atoms_t * u,
1160                                               char * name, uint8_t * data,
1161                                               uint32_t len);
1162 
1163 void quicktime_user_atoms_read_atom(quicktime_t * file,
1164                                     quicktime_user_atoms_t * u,
1165                                     quicktime_atom_t * leaf_atom);
1166 
1167 void quicktime_user_atoms_delete(quicktime_user_atoms_t * u);
1168 
1169 void quicktime_write_user_atoms(quicktime_t * file,
1170                                 quicktime_user_atoms_t * u);
1171 void quicktime_user_atoms_dump(quicktime_user_atoms_t * u);
1172 
1173 
1174 
1175 
1176 
1177 
1178 /* For AVI */
1179 int quicktime_avg_chunk_samples(quicktime_t *file, quicktime_trak_t *trak);
1180 
1181 /* For seeking in CBR audio files: Get the chunk index for a specified sample.
1182    On return, chunk_sample will contain the first sample of the returned chunk */
1183 
1184 LQT_EXTERN int quicktime_chunk_of_sample(int64_t *chunk_sample,
1185                                          int64_t *chunk,
1186                                          quicktime_trak_t *trak,
1187                                          int64_t sample);
1188 
1189 int64_t quicktime_chunk_to_offset(quicktime_t *file, quicktime_trak_t *trak, long chunk);
1190 
1191 
1192 int64_t quicktime_sample_range_size(quicktime_trak_t *trak,
1193                                     long chunk_sample,
1194                                     long sample);
1195 int64_t quicktime_sample_to_offset(quicktime_t *file, quicktime_trak_t *trak, long sample);
1196 
1197 LQT_EXTERN void quicktime_write_chunk_header(quicktime_t *file,
1198                                              quicktime_trak_t *trak);
1199 
1200 LQT_EXTERN void quicktime_write_chunk_footer(quicktime_t *file,
1201                                              quicktime_trak_t *trak);
1202 
1203 int quicktime_trak_duration(quicktime_trak_t *trak,
1204                             int64_t *duration,
1205                             int *timescale);
1206 
1207 int quicktime_trak_fix_counts(quicktime_t *file, quicktime_trak_t *trak,
1208                               int moov_time_scale);
1209 LQT_EXTERN long quicktime_chunk_samples(quicktime_trak_t *trak, long chunk);
1210 int quicktime_trak_shift_offsets(quicktime_trak_t *trak, int64_t offset);
1211 
1212 
1213 /* tcmi.c */
1214 
1215 void quicktime_read_tcmi(quicktime_t *file, quicktime_tcmi_t *tcmi);
1216 void quicktime_write_tcmi(quicktime_t *file, quicktime_tcmi_t *tcmi);
1217 void quicktime_tcmi_dump(quicktime_tcmi_t *tcmi);
1218 void quicktime_tcmi_delete(quicktime_tcmi_t *tcmi);
1219 void quicktime_tcmi_init(quicktime_tcmi_t *tcmi);
1220 
1221 /* timecode.c */
1222 
1223 void lqt_flush_timecode(quicktime_t * file, int track, int64_t time,
1224                         int force);
1225 
1226 
1227 /* tmcd.c */
1228 
1229 void quicktime_tmcd_dump(quicktime_tmcd_t *tmcd);
1230 void quicktime_tmcd_init(quicktime_tmcd_t *tmcd);
1231 void quicktime_tmcd_delete(quicktime_tmcd_t *tmcd);
1232 void quicktime_read_tmcd(quicktime_t *file, quicktime_tmcd_t *tmcd,
1233                          quicktime_atom_t *parent_atom);
1234 void quicktime_write_tmcd(quicktime_t *file, quicktime_tmcd_t *tmcd);
1235 
1236 
1237 /* tref.c */
1238 
1239 int quicktime_tref_init(quicktime_tref_t *tref);
1240 int quicktime_tref_delete(quicktime_tref_t *tref);
1241 void quicktime_tref_dump(quicktime_tref_t *tref);
1242 int quicktime_read_tref(quicktime_t *file, quicktime_tref_t *tref,
1243                         quicktime_atom_t *tref_atom);
1244 void quicktime_write_tref(quicktime_t *file, quicktime_tref_t *tref);
1245 int quicktime_tref_init_qtvr(quicktime_tref_t *tref, int track_type);
1246 int quicktime_tref_init_chap(quicktime_tref_t * tref, int track_id);
1247 int quicktime_tref_init_tmcd(quicktime_tref_t * tref, int track_id);
1248 
1249 
1250 /* udta.c */
1251 
1252 int quicktime_udta_init(quicktime_udta_t *udta);
1253 int quicktime_udta_delete(quicktime_udta_t *udta);
1254 void quicktime_udta_dump(quicktime_udta_t *udta);
1255 int quicktime_read_udta(quicktime_t *file, quicktime_udta_t *udta, quicktime_atom_t *udta_atom);
1256 void quicktime_write_udta(quicktime_t *file, quicktime_udta_t *udta);
1257 int quicktime_set_udta_string(char **string, int *size, char *new_string);
1258 int quicktime_read_udta_string(quicktime_t *file,
1259                                char **string,
1260                                int *size, int ilst);
1261 
1262 int
1263 quicktime_write_udta_string(quicktime_t *file, const char * string,
1264                             int ilst, lqt_charset_converter_t ** cnv);
1265 
1266 /* vmhd.c */
1267 
1268 void quicktime_vmhd_init(quicktime_vmhd_t *vmhd);
1269 void quicktime_vmhd_init_video(quicktime_t *file,
1270                                quicktime_vmhd_t *vmhd,
1271                                int frame_w,
1272                                int frame_h,
1273                                int frame_duration,
1274                                int timescale);
1275 
1276 void quicktime_vmhd_delete(quicktime_vmhd_t *vmhd);
1277 void quicktime_vmhd_dump(quicktime_vmhd_t *vmhd);
1278 void quicktime_read_vmhd(quicktime_t *file, quicktime_vmhd_t *vmhd);
1279 void quicktime_write_vmhd(quicktime_t *file, quicktime_vmhd_t *vmhd);
1280 
1281 /* vrni.c */
1282 
1283 int quicktime_vrni_init(quicktime_vrni_t *vrni);
1284 int quicktime_vrni_delete(quicktime_vrni_t *vrni);
1285 void quicktime_vrni_dump(quicktime_vrni_t *vrni);
1286 int quicktime_read_vrni(quicktime_t *file, quicktime_vrni_t *vrni, quicktime_qtatom_t *vrni_atom);
1287 void quicktime_write_vrni(quicktime_t *file, quicktime_vrni_t *vrni);
1288 
1289 /* vrnp.c */
1290 
1291 int quicktime_vrnp_init(quicktime_vrnp_t *vrnp);
1292 int quicktime_vrnp_delete(quicktime_vrnp_t *vrnp);
1293 void quicktime_vrnp_dump(quicktime_vrnp_t *vrnp);
1294 int quicktime_read_vrnp(quicktime_t *file, quicktime_vrnp_t *vrnp, quicktime_qtatom_t *vrnp_atom);
1295 void quicktime_write_vrnp(quicktime_t *file, quicktime_vrnp_t *vrnp);
1296 
1297 /* vrsc.c */
1298 
1299 int quicktime_vrsc_init(quicktime_vrsc_t *vrsc);
1300 int quicktime_vrsc_delete(quicktime_vrsc_t *vrsc);
1301 void quicktime_vrsc_dump(quicktime_vrsc_t *vrsc);
1302 int quicktime_read_vrsc(quicktime_t *file, quicktime_vrsc_t *vrsc, quicktime_qtatom_t *vrsc_atom);
1303 void quicktime_write_vrsc(quicktime_t *file, quicktime_vrsc_t *vrsc);
1304 
1305 /* wave.c */
1306 
1307 void quicktime_read_wave(quicktime_t *file, quicktime_wave_t *wave,
1308                          quicktime_atom_t *wave_atom);
1309 
1310 void quicktime_write_wave(quicktime_t *file, quicktime_wave_t *wave);
1311 void quicktime_wave_dump(quicktime_wave_t *wave);
1312 void quicktime_wave_delete(quicktime_wave_t *wave);
1313 
1314 LQT_EXTERN uint8_t * quicktime_wave_get_user_atom(quicktime_trak_t * trak, char * name, uint32_t * len);
1315 LQT_EXTERN void quicktime_wave_set_user_atom(quicktime_trak_t * trak, char * name, uint8_t * data,  uint32_t len);
1316 
1317 
1318 
1319 /* util.c */
1320 
1321 /* Disk I/O */
1322 int64_t quicktime_get_file_length(const char *path);
1323 int quicktime_file_open(quicktime_t *file, const char *path, int rd, int wr);
1324 int quicktime_file_close(quicktime_t *file);
1325 int64_t quicktime_ftell(quicktime_t *file);
1326 int quicktime_fseek(quicktime_t *file, int64_t offset);
1327 LQT_EXTERN int quicktime_read_data(quicktime_t *file, uint8_t *data, int64_t size);
1328 LQT_EXTERN int quicktime_write_data(quicktime_t *file, const uint8_t *data, int size);
1329 int64_t quicktime_byte_position(quicktime_t *file);
1330 void quicktime_read_pascal(quicktime_t *file, char *data);
1331 void quicktime_write_pascal(quicktime_t *file, char *data);
1332 float quicktime_read_fixed32(quicktime_t *file);
1333 int quicktime_write_fixed32(quicktime_t *file, float number);
1334 
1335 float quicktime_read_float32(quicktime_t *file);
1336 double quicktime_read_double64(quicktime_t *file);
1337 
1338 int quicktime_write_float32(quicktime_t *file, float value);
1339 int quicktime_write_double64(quicktime_t *file, double value);
1340 
1341 int quicktime_write_int64(quicktime_t *file, int64_t value);
1342 int quicktime_write_int64_le(quicktime_t *file, int64_t value);
1343 int quicktime_write_int32(quicktime_t *file, long value);
1344 int quicktime_write_int32_le(quicktime_t *file, long value);
1345 int quicktime_write_char32(quicktime_t *file, char *string);
1346 float quicktime_read_fixed16(quicktime_t *file);
1347 int quicktime_write_fixed16(quicktime_t *file, float number);
1348 unsigned long quicktime_read_uint32(quicktime_t *file);
1349 long quicktime_read_int32(quicktime_t *file);
1350 long quicktime_read_int32_le(quicktime_t *file);
1351 int64_t quicktime_read_int64(quicktime_t *file);
1352 int64_t quicktime_read_int64_le(quicktime_t *file);
1353 long quicktime_read_int24(quicktime_t *file);
1354 int quicktime_write_int24(quicktime_t *file, long number);
1355 int quicktime_read_int16(quicktime_t *file);
1356 int quicktime_read_int16_le(quicktime_t *file);
1357 int quicktime_write_int16(quicktime_t *file, int number);
1358 int quicktime_write_int16_le(quicktime_t *file, int number);
1359 int quicktime_read_char(quicktime_t *file);
1360 int quicktime_write_char(quicktime_t *file, char x);
1361 void quicktime_read_char32(quicktime_t *file, char *string);
1362 int64_t quicktime_position(quicktime_t *file);
1363 int quicktime_set_position(quicktime_t *file, int64_t position);
1364 void quicktime_copy_char32(char *output, char *input);
1365 void quicktime_print_chars(char *desc, uint8_t *input, int len);
1366 unsigned long quicktime_current_time(void);
1367 LQT_EXTERN int quicktime_match_32(void *input, void *output);
1368 int quicktime_match_24(char *input, char *output);
1369 
1370 LQT_EXTERN void lqt_hexdump(uint8_t * data, int len, int linebreak);
1371 void lqt_hexdump_stdout(uint8_t * data, int len, int linebreak);
1372 
1373 void lqt_dump_time(uint64_t t);
1374 
1375 /* lqt_quicktime.c */
1376 
1377 int quicktime_init(quicktime_t *file);
1378 quicktime_trak_t* quicktime_add_track(quicktime_t *);
1379 int quicktime_get_timescale(double frame_rate);
1380 
1381 int quicktime_init_audio_map(quicktime_t * file,
1382                              quicktime_audio_map_t *atrack,
1383                              int encode, lqt_codec_info_t * info);
1384 
1385 int quicktime_delete_audio_map(quicktime_audio_map_t *atrack);
1386 
1387 
1388 int quicktime_init_video_map(quicktime_video_map_t *vtrack,
1389                              int encode, lqt_codec_info_t * info);
1390 
1391 int quicktime_delete_video_map(quicktime_video_map_t *vtrack);
1392 
1393 
1394 void quicktime_init_maps(quicktime_t * file);
1395 void lqt_update_frame_position(quicktime_video_map_t * track);
1396 
1397 LQT_EXTERN void lqt_init_vbr_audio(quicktime_t * file, int track);
1398 
1399 LQT_EXTERN int lqt_chunk_of_sample_vbr(int64_t *chunk_sample,
1400                                        int64_t *chunk,
1401                                        quicktime_trak_t *trak,
1402                                        int64_t sample);
1403 
1404 LQT_EXTERN void lqt_set_audio_bitrate(quicktime_t * file, int track, int bitrate);
1405 
1406 
1407 int lqt_add_audio_track_internal(quicktime_t *file,
1408                                  int channels, long sample_rate, int bits,
1409                                  lqt_codec_info_t * codec_info,
1410                                  const lqt_compression_info_t * ci);
1411 
1412 int lqt_add_video_track_internal(quicktime_t *file,
1413                                  int frame_w, int frame_h,
1414                                  int frame_duration, int timescale,
1415                                  lqt_codec_info_t * info,
1416                                  const lqt_compression_info_t * ci);
1417 
1418 
1419 int lqt_is_keyframe(quicktime_t *file, int track, int frame);
1420 
1421 
1422 /* Read all the information about the file. */
1423 /* Requires a MOOV atom be present in the file. */
1424 /* If no MOOV atom exists return 1 else return 0. */
1425 int quicktime_read_info(quicktime_t *file);
1426 
1427 void lqt_start_encoding(quicktime_t *file);
1428 
1429 /*
1430  *  Set the default codec parameters from the registry
1431  *  Works for reading and writing
1432  */
1433 
1434 void lqt_set_default_video_parameters(quicktime_t * file, int track);
1435 void lqt_set_default_audio_parameters(quicktime_t * file, int track);
1436 
1437 /* Before and after writing subsequent frames, we must call
1438    quicktime_write_chunk_[header|footer] */
1439 
1440 LQT_EXTERN void lqt_start_audio_vbr_frame(quicktime_t * file, int track);
1441 LQT_EXTERN void lqt_finish_audio_vbr_frame(quicktime_t * file, int track, int num_samples);
1442 
1443 /*
1444  *  Convenience function: Returns an array of chunk sizes
1445  *  for a track. This is expecially useful for compressing audio
1446  *  codecs since the chunk size cannot quickly be determined from
1447  *  the tables.
1448  *  Call this function in the constructor of the codec and free()
1449  *  the returned array, when it's no longer needed
1450  */
1451 
1452 int64_t * lqt_get_chunk_sizes(quicktime_t * file, quicktime_trak_t *trak);
1453 
1454 /* lqt_codecs.c */
1455 
1456 int quicktime_init_vcodec(quicktime_video_map_t *vtrack, int encode,
1457                           lqt_codec_info_t * info);
1458 int quicktime_init_acodec(quicktime_audio_map_t *atrack, int encode,
1459                           lqt_codec_info_t * info);
1460 
1461 int quicktime_delete_codec(quicktime_codec_t *codec);
1462 int quicktime_codecs_flush(quicktime_t *file);
1463 
1464 LQT_EXTERN void lqt_write_frame_header(quicktime_t * file, int track,
1465                                        int pic_num1, int64_t pic_pts, int keyframe);
1466 
1467 LQT_EXTERN void lqt_write_frame_footer(quicktime_t * file, int track);
1468 
1469 void lqt_video_build_timestamp_tables(quicktime_t * file, int track);
1470 
1471 
1472 LQT_EXTERN void lqt_video_append_timestamp(quicktime_t * file, int track,
1473                                            int64_t time, int duration);
1474 
1475 quicktime_codec_t * quicktime_load_codec(lqt_codec_info_t * info,
1476                                          quicktime_audio_map_t * amap,
1477                                          quicktime_video_map_t * vmap);
1478 
1479 
1480 /* workarounds.c */
1481 
1482 int64_t quicktime_add3(int64_t a, int64_t b, int64_t c);
1483