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

多媒体

开发平台:

Unix_Linux

  1. #include "quicktime.h"
  2. int quicktime_elst_table_init(quicktime_elst_table_t *table)
  3. {
  4. table->duration = 0;
  5. table->time = 0;
  6. table->rate = 1;
  7. }
  8. int quicktime_elst_table_delete(quicktime_elst_table_t *table)
  9. {
  10. }
  11. int quicktime_read_elst_table(quicktime_t *file, quicktime_elst_table_t *table)
  12. {
  13. table->duration = quicktime_read_int32(file);
  14. table->time = quicktime_read_int32(file);
  15. table->rate = quicktime_read_fixed32(file);
  16. }
  17. int quicktime_write_elst_table(quicktime_t *file, quicktime_elst_table_t *table, long duration)
  18. {
  19. table->duration = duration;
  20. quicktime_write_int32(file, table->duration);
  21. quicktime_write_int32(file, table->time);
  22. quicktime_write_fixed32(file, table->rate);
  23. }
  24. int quicktime_elst_table_dump(quicktime_elst_table_t *table)
  25. {
  26. printf("    edit list tablen");
  27. printf("     duration %ldn", table->duration);
  28. printf("     time %ldn", table->time);
  29. printf("     rate %fn", table->rate);
  30. }
  31. int quicktime_elst_init(quicktime_elst_t *elst)
  32. {
  33. elst->version = 0;
  34. elst->flags = 0;
  35. elst->total_entries = 0;
  36. elst->table = 0;
  37. }
  38. int quicktime_elst_init_all(quicktime_elst_t *elst)
  39. {
  40. if(!elst->total_entries)
  41. {
  42. elst->total_entries = 1;
  43. elst->table = (quicktime_elst_table_t*)malloc(sizeof(quicktime_elst_table_t) * elst->total_entries);
  44. quicktime_elst_table_init(&(elst->table[0]));
  45. }
  46. }
  47. int quicktime_elst_delete(quicktime_elst_t *elst)
  48. {
  49. int i;
  50. if(elst->total_entries)
  51. {
  52. for(i = 0; i < elst->total_entries; i++)
  53. quicktime_elst_table_delete(&(elst->table[i]));
  54. free(elst->table);
  55. }
  56. elst->total_entries = 0;
  57. }
  58. int quicktime_elst_dump(quicktime_elst_t *elst)
  59. {
  60. int i;
  61. printf("   edit list (elst)n");
  62. printf("    version %dn", elst->version);
  63. printf("    flags %dn", elst->flags);
  64. printf("    total_entries %dn", elst->total_entries);
  65. for(i = 0; i < elst->total_entries; i++)
  66. {
  67. quicktime_elst_table_dump(&(elst->table[i]));
  68. }
  69. }
  70. int quicktime_read_elst(quicktime_t *file, quicktime_elst_t *elst)
  71. {
  72. int i;
  73. quicktime_atom_t leaf_atom;
  74. elst->version = quicktime_read_char(file);
  75. elst->flags = quicktime_read_int24(file);
  76. elst->total_entries = quicktime_read_int32(file);
  77. elst->table = (quicktime_elst_table_t*)malloc(sizeof(quicktime_elst_table_t) * elst->total_entries);
  78. for(i = 0; i < elst->total_entries; i++)
  79. {
  80. quicktime_elst_table_init(&(elst->table[i]));
  81. quicktime_read_elst_table(file, &(elst->table[i]));
  82. }
  83. }
  84. int quicktime_write_elst(quicktime_t *file, quicktime_elst_t *elst, long duration)
  85. {
  86. quicktime_atom_t atom;
  87. int i;
  88. quicktime_atom_write_header(file, &atom, "elst");
  89. quicktime_write_char(file, elst->version);
  90. quicktime_write_int24(file, elst->flags);
  91. quicktime_write_int32(file, elst->total_entries);
  92. for(i = 0; i < elst->total_entries; i++)
  93. {
  94. quicktime_write_elst_table(file, elst->table, duration);
  95. }
  96. quicktime_atom_write_footer(file, &atom);
  97. }