home *** CD-ROM | disk | FTP | other *** search
/ Geek 6 / Geek-006.iso / linux / video / xmovie-1.5.3.tar.gz / xmovie-1.5.3.tar / xmovie-1.5.3 / quicktime / tkhd.c < prev    next >
C/C++ Source or Header  |  2000-11-29  |  3KB  |  101 lines

  1. #include "quicktime.h"
  2.  
  3.  
  4. int quicktime_tkhd_init(quicktime_tkhd_t *tkhd)
  5. {
  6.     int i;
  7.     tkhd->version = 0;
  8.     tkhd->flags = 15;
  9.     tkhd->creation_time = quicktime_current_time();
  10.     tkhd->modification_time = quicktime_current_time();
  11.     tkhd->track_id;
  12.     tkhd->reserved1 = 0;
  13.     tkhd->duration = 0;      /* need to set this when closing */
  14.     for(i = 0; i < 8; i++) tkhd->reserved2[i] = 0;
  15.     tkhd->layer = 0;
  16.     tkhd->alternate_group = 0;
  17.     tkhd->volume = 0.996094;
  18.     tkhd->reserved3 = 0;
  19.     quicktime_matrix_init(&(tkhd->matrix));
  20.     tkhd->track_width = 0;
  21.     tkhd->track_height = 0;
  22.     return 0;
  23. }
  24.  
  25. int quicktime_tkhd_delete(quicktime_tkhd_t *tkhd)
  26. {
  27.     return 0;
  28. }
  29.  
  30. void quicktime_tkhd_dump(quicktime_tkhd_t *tkhd)
  31. {
  32.     printf("  track header\n");
  33.     printf("   version %d\n", tkhd->version);
  34.     printf("   flags %ld\n", tkhd->flags);
  35.     printf("   creation_time %u\n", tkhd->creation_time);
  36.     printf("   modification_time %u\n", tkhd->modification_time);
  37.     printf("   track_id %d\n", tkhd->track_id);
  38.     printf("   reserved1 %ld\n", tkhd->reserved1);
  39.     printf("   duration %ld\n", tkhd->duration);
  40.     quicktime_print_chars("   reserved2 ", tkhd->reserved2, 8);
  41.     printf("   layer %d\n", tkhd->layer);
  42.     printf("   alternate_group %d\n", tkhd->alternate_group);
  43.     printf("   volume %f\n", tkhd->volume);
  44.     printf("   reserved3 %d\n", tkhd->reserved3);
  45.     quicktime_matrix_dump(&(tkhd->matrix));
  46.     printf("   track_width %f\n", tkhd->track_width);
  47.     printf("   track_height %f\n", tkhd->track_height);
  48. }
  49.  
  50. void quicktime_read_tkhd(quicktime_t *file, quicktime_tkhd_t *tkhd)
  51. {
  52.     tkhd->version = quicktime_read_char(file);
  53.     tkhd->flags = quicktime_read_int24(file);
  54.     tkhd->creation_time = quicktime_read_int32(file);
  55.     tkhd->modification_time = quicktime_read_int32(file);
  56.     tkhd->track_id = quicktime_read_int32(file);
  57.     tkhd->reserved1 = quicktime_read_int32(file);
  58.     tkhd->duration = quicktime_read_int32(file);
  59.     quicktime_read_data(file, tkhd->reserved2, 8);
  60.     tkhd->layer = quicktime_read_int16(file);
  61.     tkhd->alternate_group = quicktime_read_int16(file);
  62.     tkhd->volume = quicktime_read_fixed16(file);
  63.     tkhd->reserved3 = quicktime_read_int16(file);
  64.     quicktime_read_matrix(file, &(tkhd->matrix));
  65.     tkhd->track_width = quicktime_read_fixed32(file);
  66.     tkhd->track_height = quicktime_read_fixed32(file);
  67. }
  68.  
  69. void quicktime_write_tkhd(quicktime_t *file, quicktime_tkhd_t *tkhd)
  70. {
  71.     quicktime_atom_t atom;
  72.     quicktime_atom_write_header(file, &atom, "tkhd");
  73.     quicktime_write_char(file, tkhd->version);
  74.     quicktime_write_int24(file, tkhd->flags);
  75.     quicktime_write_int32(file, tkhd->creation_time);
  76.     quicktime_write_int32(file, tkhd->modification_time);
  77.     quicktime_write_int32(file, tkhd->track_id);
  78.     quicktime_write_int32(file, tkhd->reserved1);
  79.     quicktime_write_int32(file, tkhd->duration);
  80.     quicktime_write_data(file, tkhd->reserved2, 8);
  81.     quicktime_write_int16(file, tkhd->layer);
  82.     quicktime_write_int16(file, tkhd->alternate_group);
  83.     quicktime_write_fixed16(file, tkhd->volume);
  84.     quicktime_write_int16(file, tkhd->reserved3);
  85.     quicktime_write_matrix(file, &(tkhd->matrix));
  86.      quicktime_write_fixed32(file, tkhd->track_width);
  87.      quicktime_write_fixed32(file, tkhd->track_height);
  88.     quicktime_atom_write_footer(file, &atom);
  89. }
  90.  
  91.  
  92. void quicktime_tkhd_init_video(quicktime_t *file, 
  93.                                 quicktime_tkhd_t *tkhd, 
  94.                                 int frame_w, 
  95.                                 int frame_h)
  96. {
  97.     tkhd->track_width = frame_w;
  98.     tkhd->track_height = frame_h;
  99.     tkhd->volume = 0;
  100. }
  101.