r609: Make it compile with xorg
[cinelerra_cv/mob.git] / quicktime / stss.c
blob799e3077b604ea5601c8aff5f61f9a7f271adbd8
1 #include "funcprotos.h"
2 #include "quicktime.h"
6 void quicktime_stss_init(quicktime_stss_t *stss)
8 stss->version = 0;
9 stss->flags = 0;
10 stss->total_entries = 0;
11 stss->entries_allocated = 2;
12 stss->table = (quicktime_stss_table_t*)calloc(1, sizeof(quicktime_stss_table_t) * stss->entries_allocated);
15 void quicktime_stss_delete(quicktime_stss_t *stss)
17 if(stss->entries_allocated) free(stss->table);
18 stss->total_entries = 0;
19 stss->entries_allocated = 0;
20 stss->table = 0;
23 void quicktime_stss_dump(quicktime_stss_t *stss)
25 int i;
26 printf(" sync sample\n");
27 printf(" version %d\n", stss->version);
28 printf(" flags %d\n", stss->flags);
29 printf(" total_entries %d\n", stss->total_entries);
30 for(i = 0; i < stss->total_entries; i++)
32 printf(" sample %x\n", stss->table[i].sample);
36 void quicktime_read_stss(quicktime_t *file, quicktime_stss_t *stss)
38 int i;
39 stss->version = quicktime_read_char(file);
40 stss->flags = quicktime_read_int24(file);
41 stss->total_entries = quicktime_read_int32(file);
43 if(stss->entries_allocated < stss->total_entries)
45 stss->entries_allocated = stss->total_entries;
46 stss->table = (quicktime_stss_table_t*)realloc(stss->table, sizeof(quicktime_stss_table_t) * stss->entries_allocated);
49 for(i = 0; i < stss->total_entries; i++)
51 stss->table[i].sample = quicktime_read_int32(file);
56 void quicktime_write_stss(quicktime_t *file, quicktime_stss_t *stss)
58 int i;
59 quicktime_atom_t atom;
61 if(stss->total_entries)
63 quicktime_atom_write_header(file, &atom, "stss");
65 quicktime_write_char(file, stss->version);
66 quicktime_write_int24(file, stss->flags);
67 quicktime_write_int32(file, stss->total_entries);
68 for(i = 0; i < stss->total_entries; i++)
70 quicktime_write_int32(file, stss->table[i].sample);
73 quicktime_atom_write_footer(file, &atom);