stss.c
上传用户:luping1608
上传日期:2007-01-06
资源大小:38k
文件大小:1k
- #include "quicktime.h"
- int quicktime_stss_init(quicktime_stss_t *stss)
- {
- stss->version = 0;
- stss->flags = 0;
- stss->total_entries = 0;
- }
- int quicktime_stss_delete(quicktime_stss_t *stss)
- {
- if(stss->total_entries) free(stss->table);
- stss->total_entries = 0;
- }
- int quicktime_stss_dump(quicktime_stss_t *stss)
- {
- int i;
- printf(" sync samplen");
- printf(" version %dn", stss->version);
- printf(" flags %dn", stss->flags);
- printf(" total_entries %dn", stss->total_entries);
- for(i = 0; i < stss->total_entries; i++)
- {
- printf(" sample %dn", stss->table[i].sample);
- }
- }
- int quicktime_read_stss(quicktime_t *file, quicktime_stss_t *stss)
- {
- int i;
- stss->version = quicktime_read_char(file);
- stss->flags = quicktime_read_int24(file);
- stss->total_entries = quicktime_read_int32(file);
-
- stss->table = (quicktime_stss_table_t*)malloc(sizeof(quicktime_stss_table_t) * stss->total_entries);
- for(i = 0; i < stss->total_entries; i++)
- {
- stss->table[i].sample = quicktime_read_int32(file);
- }
- }
- int quicktime_write_stss(quicktime_t *file, quicktime_stss_t *stss)
- {
- int i;
- quicktime_atom_t atom;
- if(stss->total_entries)
- {
- quicktime_atom_write_header(file, &atom, "stss");
- quicktime_write_char(file, stss->version);
- quicktime_write_int24(file, stss->flags);
- quicktime_write_int32(file, stss->total_entries);
- for(i = 0; i < stss->total_entries; i++)
- {
- quicktime_write_int32(file, stss->table[i].sample);
- }
- quicktime_atom_write_footer(file, &atom);
- }
- }