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

多媒体

开发平台:

Unix_Linux

  1. #include "quicktime.h"
  2. int quicktime_stbl_init(quicktime_stbl_t *stbl)
  3. {
  4. stbl->version = 0;
  5. stbl->flags = 0;
  6. quicktime_stsd_init(&(stbl->stsd));
  7. quicktime_stts_init(&(stbl->stts));
  8. quicktime_stss_init(&(stbl->stss));
  9. quicktime_stsc_init(&(stbl->stsc));
  10. quicktime_stsz_init(&(stbl->stsz));
  11. quicktime_stco_init(&(stbl->stco));
  12. }
  13. int quicktime_stbl_init_video(quicktime_t *file, 
  14. quicktime_stbl_t *stbl, 
  15. int frame_w,
  16. int frame_h, 
  17. float frame_rate,
  18. char *compressor)
  19. {
  20. quicktime_stsd_init_video(file, &(stbl->stsd), frame_w, frame_h, frame_rate, compressor);
  21. quicktime_stts_init_video(file, &(stbl->stts), frame_rate);
  22. quicktime_stsc_init_video(file, &(stbl->stsc));
  23. quicktime_stsz_init_video(file, &(stbl->stsz));
  24. quicktime_stco_init_common(file, &(stbl->stco));
  25. }
  26. int quicktime_stbl_init_audio(quicktime_t *file, 
  27. quicktime_stbl_t *stbl, 
  28. int channels, 
  29. int sample_rate, 
  30. int bits, 
  31. char *compressor)
  32. {
  33. quicktime_stsd_init_audio(file, &(stbl->stsd), channels, sample_rate, bits, compressor);
  34. quicktime_stts_init_audio(file, &(stbl->stts), sample_rate);
  35. quicktime_stsc_init_audio(file, &(stbl->stsc), sample_rate);
  36. quicktime_stsz_init_audio(file, &(stbl->stsz), channels, bits);
  37. quicktime_stco_init_common(file, &(stbl->stco));
  38. }
  39. int quicktime_stbl_delete(quicktime_stbl_t *stbl)
  40. {
  41. quicktime_stsd_delete(&(stbl->stsd));
  42. quicktime_stts_delete(&(stbl->stts));
  43. quicktime_stss_delete(&(stbl->stss));
  44. quicktime_stsc_delete(&(stbl->stsc));
  45. quicktime_stsz_delete(&(stbl->stsz));
  46. quicktime_stco_delete(&(stbl->stco));
  47. }
  48. int quicktime_stbl_dump(void *minf_ptr, quicktime_stbl_t *stbl)
  49. {
  50. printf("    sample tablen");
  51. quicktime_stsd_dump(minf_ptr, &(stbl->stsd));
  52. quicktime_stts_dump(&(stbl->stts));
  53. quicktime_stss_dump(&(stbl->stss));
  54. quicktime_stsc_dump(&(stbl->stsc));
  55. quicktime_stsz_dump(&(stbl->stsz));
  56. quicktime_stco_dump(&(stbl->stco));
  57. }
  58. int quicktime_read_stbl(quicktime_t *file, quicktime_minf_t *minf, quicktime_stbl_t *stbl, quicktime_atom_t *parent_atom)
  59. {
  60. quicktime_atom_t leaf_atom;
  61. do
  62. {
  63. quicktime_atom_read_header(file->stream, &leaf_atom);
  64. // mandatory
  65. if(quicktime_atom_is(&leaf_atom, "stsd"))
  66. quicktime_read_stsd(file, minf, &(stbl->stsd)); 
  67. quicktime_atom_skip(file, &leaf_atom);
  68. }
  69. else
  70. if(quicktime_atom_is(&leaf_atom, "stts"))
  71. { quicktime_read_stts(file, &(stbl->stts)); }
  72. else
  73. if(quicktime_atom_is(&leaf_atom, "stss"))
  74. { quicktime_read_stss(file, &(stbl->stss)); }
  75. else
  76. if(quicktime_atom_is(&leaf_atom, "stsc"))
  77. { quicktime_read_stsc(file, &(stbl->stsc)); }
  78. else
  79. if(quicktime_atom_is(&leaf_atom, "stsz"))
  80. { quicktime_read_stsz(file, &(stbl->stsz)); }
  81. else
  82. if(quicktime_atom_is(&leaf_atom, "stco"))
  83. { quicktime_read_stco(file, &(stbl->stco)); }
  84. else
  85. quicktime_atom_skip(file, &leaf_atom);
  86. }while(quicktime_position(file) < parent_atom->end);
  87. return 0;
  88. }
  89. int quicktime_write_stbl(quicktime_t *file, quicktime_minf_t *minf, quicktime_stbl_t *stbl)
  90. {
  91. quicktime_atom_t atom;
  92. quicktime_atom_write_header(file, &atom, "stbl");
  93. quicktime_write_stsd(file, minf, &(stbl->stsd));
  94. quicktime_write_stts(file, &(stbl->stts));
  95. quicktime_write_stss(file, &(stbl->stss));
  96. quicktime_write_stsc(file, &(stbl->stsc));
  97. quicktime_write_stsz(file, &(stbl->stsz));
  98. quicktime_write_stco(file, &(stbl->stco));
  99. quicktime_atom_write_footer(file, &atom);
  100. }