applied AkhIL's cinelerra-cv surround patch
[cinelerra_cv/ct.git] / quicktime / mdia.c
blob68205adf71cc73832200d7f6264b699af385e005
1 #include "funcprotos.h"
2 #include "quicktime.h"
5 void quicktime_mdia_init(quicktime_mdia_t *mdia)
7 quicktime_mdhd_init(&(mdia->mdhd));
8 quicktime_hdlr_init(&(mdia->hdlr));
9 quicktime_minf_init(&(mdia->minf));
12 void quicktime_mdia_init_video(quicktime_t *file,
13 quicktime_mdia_t *mdia,
14 int frame_w,
15 int frame_h,
16 float frame_rate,
17 char *compressor)
19 //printf("quicktime_mdia_init_video 1\n");
20 quicktime_mdhd_init_video(file, &(mdia->mdhd), frame_w, frame_h, frame_rate);
21 //printf("quicktime_mdia_init_video 1 %d %f\n", mdia->mdhd.time_scale, frame_rate);
22 quicktime_minf_init_video(file, &(mdia->minf), frame_w, frame_h, mdia->mdhd.time_scale, frame_rate, compressor);
23 //printf("quicktime_mdia_init_video 1\n");
24 quicktime_hdlr_init_video(&(mdia->hdlr));
25 //printf("quicktime_mdia_init_video 2\n");
28 void quicktime_mdia_init_audio(quicktime_t *file,
29 quicktime_mdia_t *mdia,
30 int channels,
31 int sample_rate,
32 int bits,
33 char *compressor)
35 quicktime_mdhd_init_audio(&(mdia->mdhd),
36 sample_rate);
37 quicktime_minf_init_audio(file,
38 &(mdia->minf),
39 channels,
40 sample_rate,
41 bits,
42 compressor);
43 quicktime_hdlr_init_audio(&(mdia->hdlr));
46 void quicktime_mdia_delete(quicktime_mdia_t *mdia)
48 quicktime_mdhd_delete(&(mdia->mdhd));
49 quicktime_hdlr_delete(&(mdia->hdlr));
50 quicktime_minf_delete(&(mdia->minf));
53 void quicktime_mdia_dump(quicktime_mdia_t *mdia)
55 printf(" media\n");
56 quicktime_mdhd_dump(&(mdia->mdhd));
57 quicktime_hdlr_dump(&(mdia->hdlr));
58 quicktime_minf_dump(&(mdia->minf));
61 int quicktime_read_mdia(quicktime_t *file, quicktime_mdia_t *mdia, quicktime_atom_t *trak_atom)
63 quicktime_atom_t leaf_atom;
67 quicktime_atom_read_header(file, &leaf_atom);
68 //printf("quicktime_read_mdia %llx\n", quicktime_position(file));
70 /* mandatory */
71 if(quicktime_atom_is(&leaf_atom, "mdhd"))
72 { quicktime_read_mdhd(file, &(mdia->mdhd)); }
73 else
74 if(quicktime_atom_is(&leaf_atom, "hdlr"))
76 quicktime_read_hdlr(file, &(mdia->hdlr));
77 /* Main Actor doesn't write component name */
78 quicktime_atom_skip(file, &leaf_atom);
80 else
81 if(quicktime_atom_is(&leaf_atom, "minf"))
82 { quicktime_read_minf(file, &(mdia->minf), &leaf_atom); }
83 else
84 quicktime_atom_skip(file, &leaf_atom);
85 }while(quicktime_position(file) < trak_atom->end);
87 return 0;
90 void quicktime_write_mdia(quicktime_t *file, quicktime_mdia_t *mdia)
92 quicktime_atom_t atom;
93 quicktime_atom_write_header(file, &atom, "mdia");
95 quicktime_write_mdhd(file, &(mdia->mdhd));
96 quicktime_write_hdlr(file, &(mdia->hdlr));
97 quicktime_write_minf(file, &(mdia->minf));
99 quicktime_atom_write_footer(file, &atom);