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

多媒体

开发平台:

Unix_Linux

  1. #include "quicktime.h"
  2. int quicktime_mvhd_init(quicktime_mvhd_t *mvhd)
  3. {
  4. int i;
  5. mvhd->version = 0;
  6. mvhd->flags = 0;
  7. mvhd->creation_time = quicktime_current_time();
  8. mvhd->modification_time = quicktime_current_time();
  9. mvhd->time_scale = 600;
  10. mvhd->duration = 0;
  11. mvhd->preferred_rate = 1.0;
  12. mvhd->preferred_volume = 0.996094;
  13. for(i = 0; i < 10; i++) mvhd->reserved[i] = 0;
  14. quicktime_matrix_init(&(mvhd->matrix));
  15. mvhd->preview_time = 0;
  16. mvhd->preview_duration = 0;
  17. mvhd->poster_time = 0;
  18. mvhd->selection_time = 0;
  19. mvhd->selection_duration = 0;
  20. mvhd->current_time = 0;
  21. mvhd->next_track_id = 1;
  22. return 0;
  23. }
  24. int quicktime_mvhd_delete(quicktime_mvhd_t *mvhd)
  25. {
  26. return 0;
  27. }
  28. int quicktime_mvhd_dump(quicktime_mvhd_t *mvhd)
  29. {
  30. printf(" movie headern");
  31. printf("  version %dn", mvhd->version);
  32. printf("  flags %ldn", mvhd->flags);
  33. printf("  creation_time %un", mvhd->creation_time);
  34. printf("  modification_time %un", mvhd->modification_time);
  35. printf("  time_scale %ldn", mvhd->time_scale);
  36. printf("  duration %ldn", mvhd->duration);
  37. printf("  preferred_rate %fn", mvhd->preferred_rate);
  38. printf("  preferred_volume %fn", mvhd->preferred_volume);
  39. quicktime_print_chars("  reserved ", mvhd->reserved, 10);
  40. quicktime_matrix_dump(&(mvhd->matrix));
  41. printf("  preview_time %ldn", mvhd->preview_time);
  42. printf("  preview_duration %ldn", mvhd->preview_duration);
  43. printf("  poster_time %ldn", mvhd->poster_time);
  44. printf("  selection_time %ldn", mvhd->selection_time);
  45. printf("  selection_duration %ldn", mvhd->selection_duration);
  46. printf("  current_time %ldn", mvhd->current_time);
  47. printf("  next_track_id %ldn", mvhd->next_track_id);
  48. }
  49. int quicktime_read_mvhd(quicktime_t *file, quicktime_mvhd_t *mvhd)
  50. {
  51. mvhd->version = quicktime_read_char(file);
  52. mvhd->flags = quicktime_read_int24(file);
  53. mvhd->creation_time = quicktime_read_int32(file);
  54. mvhd->modification_time = quicktime_read_int32(file);
  55. mvhd->time_scale = quicktime_read_int32(file);
  56. mvhd->duration = quicktime_read_int32(file);
  57. mvhd->preferred_rate = quicktime_read_fixed32(file);
  58. mvhd->preferred_volume = quicktime_read_fixed16(file);
  59. quicktime_read_data(file, mvhd->reserved, 10);
  60. quicktime_read_matrix(file, &(mvhd->matrix));
  61. mvhd->preview_time = quicktime_read_int32(file);
  62. mvhd->preview_duration = quicktime_read_int32(file);
  63. mvhd->poster_time = quicktime_read_int32(file);
  64. mvhd->selection_time = quicktime_read_int32(file);
  65. mvhd->selection_duration = quicktime_read_int32(file);
  66. mvhd->current_time = quicktime_read_int32(file);
  67. mvhd->next_track_id = quicktime_read_int32(file);
  68. }
  69. int quicktime_mhvd_init_video(quicktime_t *file, quicktime_mvhd_t *mvhd, float frame_rate)
  70. {
  71. mvhd->time_scale = quicktime_get_timescale(frame_rate);
  72. }
  73. int quicktime_write_mvhd(quicktime_t *file, quicktime_mvhd_t *mvhd)
  74. {
  75. quicktime_atom_t atom;
  76. quicktime_atom_write_header(file, &atom, "mvhd");
  77. quicktime_write_char(file, mvhd->version);
  78. quicktime_write_int24(file, mvhd->flags);
  79. quicktime_write_int32(file, mvhd->creation_time);
  80. quicktime_write_int32(file, mvhd->modification_time);
  81. quicktime_write_int32(file, mvhd->time_scale);
  82. quicktime_write_int32(file, mvhd->duration);
  83. quicktime_write_fixed32(file, mvhd->preferred_rate);
  84. quicktime_write_fixed16(file, mvhd->preferred_volume);
  85. quicktime_write_data(file, mvhd->reserved, 10);
  86. quicktime_write_matrix(file, &(mvhd->matrix));
  87. quicktime_write_int32(file, mvhd->preview_time);
  88. quicktime_write_int32(file, mvhd->preview_duration);
  89. quicktime_write_int32(file, mvhd->poster_time);
  90. quicktime_write_int32(file, mvhd->selection_time);
  91. quicktime_write_int32(file, mvhd->selection_duration);
  92. quicktime_write_int32(file, mvhd->current_time);
  93. quicktime_write_int32(file, mvhd->next_track_id);
  94. quicktime_atom_write_footer(file, &atom);
  95. }