00001 #include "funcprotos.h"
00002 #include "quicktime.h"
00003
00004
00005 int quicktime_tkhd_init(quicktime_tkhd_t *tkhd)
00006 {
00007 int i;
00008 tkhd->version = 0;
00009 tkhd->flags = 15;
00010 tkhd->creation_time = quicktime_current_time();
00011 tkhd->modification_time = quicktime_current_time();
00012 tkhd->track_id;
00013 tkhd->reserved1 = 0;
00014 tkhd->duration = 0;
00015 for(i = 0; i < 8; i++) tkhd->reserved2[i] = 0;
00016 tkhd->layer = 0;
00017 tkhd->alternate_group = 0;
00018 tkhd->volume = 0.996094;
00019 tkhd->reserved3 = 0;
00020 quicktime_matrix_init(&(tkhd->matrix));
00021 tkhd->track_width = 0;
00022 tkhd->track_height = 0;
00023 return 0;
00024 }
00025
00026 int quicktime_tkhd_delete(quicktime_tkhd_t *tkhd)
00027 {
00028 return 0;
00029 }
00030
00031 void quicktime_tkhd_dump(quicktime_tkhd_t *tkhd)
00032 {
00033 printf(" track header\n");
00034 printf(" version %d\n", tkhd->version);
00035 printf(" flags %ld\n", tkhd->flags);
00036 printf(" creation_time %u\n", tkhd->creation_time);
00037 printf(" modification_time %u\n", tkhd->modification_time);
00038 printf(" track_id %d\n", tkhd->track_id);
00039 printf(" reserved1 %ld\n", tkhd->reserved1);
00040 printf(" duration %ld\n", tkhd->duration);
00041 quicktime_print_chars(" reserved2 ", tkhd->reserved2, 8);
00042 printf(" layer %d\n", tkhd->layer);
00043 printf(" alternate_group %d\n", tkhd->alternate_group);
00044 printf(" volume %f\n", tkhd->volume);
00045 printf(" reserved3 %d\n", tkhd->reserved3);
00046 quicktime_matrix_dump(&(tkhd->matrix));
00047 printf(" track_width %f\n", tkhd->track_width);
00048 printf(" track_height %f\n", tkhd->track_height);
00049 }
00050
00051 void quicktime_read_tkhd(quicktime_t *file, quicktime_tkhd_t *tkhd)
00052 {
00053
00054 tkhd->version = quicktime_read_char(file);
00055 tkhd->flags = quicktime_read_int24(file);
00056 tkhd->creation_time = quicktime_read_int32(file);
00057 tkhd->modification_time = quicktime_read_int32(file);
00058 tkhd->track_id = quicktime_read_int32(file);
00059 tkhd->reserved1 = quicktime_read_int32(file);
00060 tkhd->duration = quicktime_read_int32(file);
00061 quicktime_read_data(file, tkhd->reserved2, 8);
00062 tkhd->layer = quicktime_read_int16(file);
00063 tkhd->alternate_group = quicktime_read_int16(file);
00064
00065 tkhd->volume = quicktime_read_fixed16(file);
00066
00067 tkhd->reserved3 = quicktime_read_int16(file);
00068 quicktime_read_matrix(file, &(tkhd->matrix));
00069 tkhd->track_width = quicktime_read_fixed32(file);
00070 tkhd->track_height = quicktime_read_fixed32(file);
00071 }
00072
00073 void quicktime_write_tkhd(quicktime_t *file, quicktime_tkhd_t *tkhd)
00074 {
00075 quicktime_atom_t atom;
00076 quicktime_atom_write_header(file, &atom, "tkhd");
00077 quicktime_write_char(file, tkhd->version);
00078 quicktime_write_int24(file, tkhd->flags);
00079 quicktime_write_int32(file, tkhd->creation_time);
00080 quicktime_write_int32(file, tkhd->modification_time);
00081 quicktime_write_int32(file, tkhd->track_id);
00082 quicktime_write_int32(file, tkhd->reserved1);
00083 quicktime_write_int32(file, tkhd->duration);
00084 quicktime_write_data(file, tkhd->reserved2, 8);
00085 quicktime_write_int16(file, tkhd->layer);
00086 quicktime_write_int16(file, tkhd->alternate_group);
00087 quicktime_write_fixed16(file, tkhd->volume);
00088 quicktime_write_int16(file, tkhd->reserved3);
00089 quicktime_write_matrix(file, &(tkhd->matrix));
00090 quicktime_write_fixed32(file, tkhd->track_width);
00091 quicktime_write_fixed32(file, tkhd->track_height);
00092 quicktime_atom_write_footer(file, &atom);
00093 }
00094
00095
00096 void quicktime_tkhd_init_video(quicktime_t *file,
00097 quicktime_tkhd_t *tkhd,
00098 int frame_w,
00099 int frame_h)
00100 {
00101 tkhd->track_width = frame_w;
00102 tkhd->track_height = frame_h;
00103 tkhd->volume = 0;
00104 }