stss.c
上传用户:luping1608
上传日期:2007-01-06
资源大小:38k
文件大小:1k
源码类别:

多媒体

开发平台:

Unix_Linux

  1. #include "quicktime.h"
  2. int quicktime_stss_init(quicktime_stss_t *stss)
  3. {
  4. stss->version = 0;
  5. stss->flags = 0;
  6. stss->total_entries = 0;
  7. }
  8. int quicktime_stss_delete(quicktime_stss_t *stss)
  9. {
  10. if(stss->total_entries) free(stss->table);
  11. stss->total_entries = 0;
  12. }
  13. int quicktime_stss_dump(quicktime_stss_t *stss)
  14. {
  15. int i;
  16. printf("     sync samplen");
  17. printf("      version %dn", stss->version);
  18. printf("      flags %dn", stss->flags);
  19. printf("      total_entries %dn", stss->total_entries);
  20. for(i = 0; i < stss->total_entries; i++)
  21. {
  22. printf("       sample %dn", stss->table[i].sample);
  23. }
  24. }
  25. int quicktime_read_stss(quicktime_t *file, quicktime_stss_t *stss)
  26. {
  27. int i;
  28. stss->version = quicktime_read_char(file);
  29. stss->flags = quicktime_read_int24(file);
  30. stss->total_entries = quicktime_read_int32(file);
  31. stss->table = (quicktime_stss_table_t*)malloc(sizeof(quicktime_stss_table_t) * stss->total_entries);
  32. for(i = 0; i < stss->total_entries; i++)
  33. {
  34. stss->table[i].sample = quicktime_read_int32(file);
  35. }
  36. }
  37. int quicktime_write_stss(quicktime_t *file, quicktime_stss_t *stss)
  38. {
  39. int i;
  40. quicktime_atom_t atom;
  41. if(stss->total_entries)
  42. {
  43. quicktime_atom_write_header(file, &atom, "stss");
  44. quicktime_write_char(file, stss->version);
  45. quicktime_write_int24(file, stss->flags);
  46. quicktime_write_int32(file, stss->total_entries);
  47. for(i = 0; i < stss->total_entries; i++)
  48. {
  49. quicktime_write_int32(file, stss->table[i].sample);
  50. }
  51. quicktime_atom_write_footer(file, &atom);
  52. }
  53. }