Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / quicktime / tkhd.c
blob42ccfcb9da8cbd687686289272d25f16306ffd5f
1 #include "funcprotos.h"
2 #include "quicktime.h"
5 int quicktime_tkhd_init(quicktime_tkhd_t *tkhd)
7 int i;
8 tkhd->version = 0;
9 tkhd->flags = 15;
10 tkhd->creation_time = quicktime_current_time();
11 tkhd->modification_time = quicktime_current_time();
12 tkhd->track_id;
13 tkhd->reserved1 = 0;
14 tkhd->duration = 0; /* need to set this when closing */
15 for(i = 0; i < 8; i++) tkhd->reserved2[i] = 0;
16 tkhd->layer = 0;
17 tkhd->alternate_group = 0;
18 tkhd->volume = 0.996094;
19 tkhd->reserved3 = 0;
20 quicktime_matrix_init(&(tkhd->matrix));
21 tkhd->track_width = 0;
22 tkhd->track_height = 0;
23 return 0;
26 int quicktime_tkhd_delete(quicktime_tkhd_t *tkhd)
28 return 0;
31 void quicktime_tkhd_dump(quicktime_tkhd_t *tkhd)
33 printf(" track header\n");
34 printf(" version %d\n", tkhd->version);
35 printf(" flags %ld\n", tkhd->flags);
36 printf(" creation_time %u\n", tkhd->creation_time);
37 printf(" modification_time %u\n", tkhd->modification_time);
38 printf(" track_id %d\n", tkhd->track_id);
39 printf(" reserved1 %ld\n", tkhd->reserved1);
40 printf(" duration %ld\n", tkhd->duration);
41 quicktime_print_chars(" reserved2 ", tkhd->reserved2, 8);
42 printf(" layer %d\n", tkhd->layer);
43 printf(" alternate_group %d\n", tkhd->alternate_group);
44 printf(" volume %f\n", tkhd->volume);
45 printf(" reserved3 %d\n", tkhd->reserved3);
46 quicktime_matrix_dump(&(tkhd->matrix));
47 printf(" track_width %f\n", tkhd->track_width);
48 printf(" track_height %f\n", tkhd->track_height);
51 void quicktime_read_tkhd(quicktime_t *file, quicktime_tkhd_t *tkhd)
53 //printf("quicktime_read_tkhd 1 %llx\n", quicktime_position(file));
54 tkhd->version = quicktime_read_char(file);
55 tkhd->flags = quicktime_read_int24(file);
56 tkhd->creation_time = quicktime_read_int32(file);
57 tkhd->modification_time = quicktime_read_int32(file);
58 tkhd->track_id = quicktime_read_int32(file);
59 tkhd->reserved1 = quicktime_read_int32(file);
60 tkhd->duration = quicktime_read_int32(file);
61 quicktime_read_data(file, tkhd->reserved2, 8);
62 tkhd->layer = quicktime_read_int16(file);
63 tkhd->alternate_group = quicktime_read_int16(file);
64 //printf("quicktime_read_tkhd 1 %llx\n", quicktime_position(file));
65 tkhd->volume = quicktime_read_fixed16(file);
66 //printf("quicktime_read_tkhd 2\n");
67 tkhd->reserved3 = quicktime_read_int16(file);
68 quicktime_read_matrix(file, &(tkhd->matrix));
69 tkhd->track_width = quicktime_read_fixed32(file);
70 tkhd->track_height = quicktime_read_fixed32(file);
73 void quicktime_write_tkhd(quicktime_t *file, quicktime_tkhd_t *tkhd)
75 quicktime_atom_t atom;
76 quicktime_atom_write_header(file, &atom, "tkhd");
77 quicktime_write_char(file, tkhd->version);
78 quicktime_write_int24(file, tkhd->flags);
79 quicktime_write_int32(file, tkhd->creation_time);
80 quicktime_write_int32(file, tkhd->modification_time);
81 quicktime_write_int32(file, tkhd->track_id);
82 quicktime_write_int32(file, tkhd->reserved1);
83 quicktime_write_int32(file, tkhd->duration);
84 quicktime_write_data(file, tkhd->reserved2, 8);
85 quicktime_write_int16(file, tkhd->layer);
86 quicktime_write_int16(file, tkhd->alternate_group);
87 quicktime_write_fixed16(file, tkhd->volume);
88 quicktime_write_int16(file, tkhd->reserved3);
89 quicktime_write_matrix(file, &(tkhd->matrix));
90 quicktime_write_fixed32(file, tkhd->track_width);
91 quicktime_write_fixed32(file, tkhd->track_height);
92 quicktime_atom_write_footer(file, &atom);
96 void quicktime_tkhd_init_video(quicktime_t *file,
97 quicktime_tkhd_t *tkhd,
98 int frame_w,
99 int frame_h)
101 tkhd->track_width = frame_w;
102 tkhd->track_height = frame_h;
103 tkhd->volume = 0;