Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / quicktime / minf.c
blob44386322931c6fd25e26e995ec6eb2e9eb148e7c
1 #include "funcprotos.h"
2 #include "quicktime.h"
6 void quicktime_minf_init(quicktime_minf_t *minf)
8 minf->is_video = minf->is_audio = 0;
9 quicktime_vmhd_init(&(minf->vmhd));
10 quicktime_smhd_init(&(minf->smhd));
11 quicktime_hdlr_init(&(minf->hdlr));
12 quicktime_dinf_init(&(minf->dinf));
13 quicktime_stbl_init(&(minf->stbl));
16 void quicktime_minf_init_video(quicktime_t *file,
17 quicktime_minf_t *minf,
18 int frame_w,
19 int frame_h,
20 int time_scale,
21 float frame_rate,
22 char *compressor)
24 minf->is_video = 1;
25 //printf("quicktime_minf_init_video 1\n");
26 quicktime_vmhd_init_video(file, &(minf->vmhd), frame_w, frame_h, frame_rate);
27 //printf("quicktime_minf_init_video 1 %d %f\n", time_scale, frame_rate);
28 quicktime_stbl_init_video(file, &(minf->stbl), frame_w, frame_h, time_scale, frame_rate, compressor);
29 //printf("quicktime_minf_init_video 2\n");
30 quicktime_hdlr_init_data(&(minf->hdlr));
31 //printf("quicktime_minf_init_video 1\n");
32 quicktime_dinf_init_all(&(minf->dinf));
33 //printf("quicktime_minf_init_video 2\n");
36 void quicktime_minf_init_audio(quicktime_t *file,
37 quicktime_minf_t *minf,
38 int channels,
39 int sample_rate,
40 int bits,
41 char *compressor)
43 minf->is_audio = 1;
44 /* smhd doesn't store anything worth initializing */
45 quicktime_stbl_init_audio(file,
46 &(minf->stbl),
47 channels,
48 sample_rate,
49 bits,
50 compressor);
51 quicktime_hdlr_init_data(&(minf->hdlr));
52 quicktime_dinf_init_all(&(minf->dinf));
55 void quicktime_minf_delete(quicktime_minf_t *minf)
57 quicktime_vmhd_delete(&(minf->vmhd));
58 quicktime_smhd_delete(&(minf->smhd));
59 quicktime_dinf_delete(&(minf->dinf));
60 quicktime_stbl_delete(&(minf->stbl));
61 quicktime_hdlr_delete(&(minf->hdlr));
64 void quicktime_minf_dump(quicktime_minf_t *minf)
66 printf(" media info\n");
67 printf(" is_audio %d\n", minf->is_audio);
68 printf(" is_video %d\n", minf->is_video);
69 if(minf->is_audio) quicktime_smhd_dump(&(minf->smhd));
70 if(minf->is_video) quicktime_vmhd_dump(&(minf->vmhd));
71 quicktime_hdlr_dump(&(minf->hdlr));
72 quicktime_dinf_dump(&(minf->dinf));
73 quicktime_stbl_dump(minf, &(minf->stbl));
76 int quicktime_read_minf(quicktime_t *file, quicktime_minf_t *minf, quicktime_atom_t *parent_atom)
78 quicktime_atom_t leaf_atom;
82 quicktime_atom_read_header(file, &leaf_atom);
83 //printf("quicktime_read_minf 1\n");
85 /* mandatory */
86 if(quicktime_atom_is(&leaf_atom, "vmhd"))
87 { minf->is_video = 1; quicktime_read_vmhd(file, &(minf->vmhd)); }
88 else
89 if(quicktime_atom_is(&leaf_atom, "smhd"))
90 { minf->is_audio = 1; quicktime_read_smhd(file, &(minf->smhd)); }
91 else
92 if(quicktime_atom_is(&leaf_atom, "hdlr"))
94 quicktime_read_hdlr(file, &(minf->hdlr));
95 /* Main Actor doesn't write component name */
96 quicktime_atom_skip(file, &leaf_atom);
98 else
99 if(quicktime_atom_is(&leaf_atom, "dinf"))
100 { quicktime_read_dinf(file, &(minf->dinf), &leaf_atom); }
101 else
102 if(quicktime_atom_is(&leaf_atom, "stbl"))
103 { quicktime_read_stbl(file, minf, &(minf->stbl), &leaf_atom); }
104 else
105 quicktime_atom_skip(file, &leaf_atom);
106 }while(quicktime_position(file) < parent_atom->end);
108 return 0;
111 void quicktime_write_minf(quicktime_t *file, quicktime_minf_t *minf)
113 quicktime_atom_t atom;
114 quicktime_atom_write_header(file, &atom, "minf");
116 if(minf->is_video) quicktime_write_vmhd(file, &(minf->vmhd));
117 if(minf->is_audio) quicktime_write_smhd(file, &(minf->smhd));
118 quicktime_write_hdlr(file, &(minf->hdlr));
119 quicktime_write_dinf(file, &(minf->dinf));
120 quicktime_write_stbl(file, minf, &(minf->stbl));
122 quicktime_atom_write_footer(file, &atom);