1 #include "funcprotos.h"
5 void quicktime_stsd_init(quicktime_stsd_t
*stsd
)
9 stsd
->total_entries
= 0;
12 void quicktime_stsd_init_table(quicktime_stsd_t
*stsd
)
14 if(!stsd
->total_entries
)
16 stsd
->total_entries
= 1;
17 stsd
->table
= (quicktime_stsd_table_t
*)calloc(1, sizeof(quicktime_stsd_table_t
) * stsd
->total_entries
);
18 quicktime_stsd_table_init(&(stsd
->table
[0]));
22 void quicktime_stsd_init_video(quicktime_t
*file
,
23 quicktime_stsd_t
*stsd
,
29 quicktime_stsd_table_t
*table
;
30 quicktime_stsd_init_table(stsd
);
31 //printf("quicktime_stsd_init_video 1\n");
32 table
= &(stsd
->table
[0]);
33 //printf("quicktime_stsd_init_video 1\n");
35 quicktime_copy_char32(table
->format
, compression
);
36 //printf("quicktime_stsd_init_video 1\n");
37 table
->width
= frame_w
;
38 //printf("quicktime_stsd_init_video 1\n");
39 table
->height
= frame_h
;
40 //printf("quicktime_stsd_init_video 1\n");
41 table
->frames_per_sample
= 1;
42 //printf("quicktime_stsd_init_video 1\n");
44 //printf("quicktime_stsd_init_video 1\n");
45 table
->ctab_id
= 65535;
46 //printf("quicktime_stsd_init_video 2\n");
49 void quicktime_stsd_init_audio(quicktime_t
*file
,
50 quicktime_stsd_t
*stsd
,
56 quicktime_stsd_table_t
*table
;
57 quicktime_stsd_init_table(stsd
);
58 table
= &(stsd
->table
[0]);
60 quicktime_copy_char32(table
->format
, compressor
);
61 table
->channels
= channels
;
62 table
->sample_size
= bits
;
63 table
->sample_rate
= sample_rate
;
66 void quicktime_stsd_delete(quicktime_stsd_t
*stsd
)
69 if(stsd
->total_entries
)
71 for(i
= 0; i
< stsd
->total_entries
; i
++)
72 quicktime_stsd_table_delete(&(stsd
->table
[i
]));
76 stsd
->total_entries
= 0;
79 void quicktime_stsd_dump(void *minf_ptr
, quicktime_stsd_t
*stsd
)
82 printf(" sample description\n");
83 printf(" version %d\n", stsd
->version
);
84 printf(" flags %d\n", stsd
->flags
);
85 printf(" total_entries %d\n", stsd
->total_entries
);
87 for(i
= 0; i
< stsd
->total_entries
; i
++)
89 quicktime_stsd_table_dump(minf_ptr
, &(stsd
->table
[i
]));
93 void quicktime_read_stsd(quicktime_t
*file
, quicktime_minf_t
*minf
, quicktime_stsd_t
*stsd
)
96 quicktime_atom_t leaf_atom
;
98 stsd
->version
= quicktime_read_char(file
);
99 stsd
->flags
= quicktime_read_int24(file
);
100 stsd
->total_entries
= quicktime_read_int32(file
);
101 stsd
->table
= (quicktime_stsd_table_t
*)calloc(1, sizeof(quicktime_stsd_table_t
) * stsd
->total_entries
);
102 for(i
= 0; i
< stsd
->total_entries
; i
++)
104 quicktime_stsd_table_init(&(stsd
->table
[i
]));
105 // quicktime_read_stsd_table(file, minf, &(stsd->table[i]));
106 quicktime_read_stsd_table(file
, minf
, &(stsd
->table
[0]));
110 void quicktime_write_stsd(quicktime_t
*file
, quicktime_minf_t
*minf
, quicktime_stsd_t
*stsd
)
112 quicktime_atom_t atom
;
114 quicktime_atom_write_header(file
, &atom
, "stsd");
116 quicktime_write_char(file
, stsd
->version
);
117 quicktime_write_int24(file
, stsd
->flags
);
118 quicktime_write_int32(file
, stsd
->total_entries
);
119 for(i
= 0; i
< stsd
->total_entries
; i
++)
121 quicktime_write_stsd_table(file
, minf
, stsd
->table
);
124 quicktime_atom_write_footer(file
, &atom
);