mdhd.c
上传用户:luping1608
上传日期:2007-01-06
资源大小:38k
文件大小:2k
- #include "quicktime.h"
- int quicktime_mdhd_init(quicktime_mdhd_t *mdhd)
- {
- mdhd->version = 0;
- mdhd->flags = 0;
- mdhd->creation_time = quicktime_current_time();
- mdhd->modification_time = quicktime_current_time();
- mdhd->time_scale = 0;
- mdhd->duration = 0;
- mdhd->language = 0;
- mdhd->quality = 0;
- }
- int quicktime_mdhd_init_video(quicktime_t *file,
- quicktime_mdhd_t *mdhd,
- int frame_w,
- int frame_h,
- float frame_rate)
- {
- mdhd->time_scale = quicktime_get_timescale(frame_rate);
- mdhd->duration = 0; // set this when closing
- }
- int quicktime_mdhd_init_audio(quicktime_t *file,
- quicktime_mdhd_t *mdhd,
- int channels,
- int sample_rate,
- int bits,
- char *compressor)
- {
- mdhd->time_scale = sample_rate;
- mdhd->duration = 0; // set this when closing
- }
- quicktime_mdhd_delete(quicktime_mdhd_t *mdhd)
- {
- }
- int quicktime_read_mdhd(quicktime_t *file, quicktime_mdhd_t *mdhd)
- {
- mdhd->version = quicktime_read_char(file);
- mdhd->flags = quicktime_read_int24(file);
- mdhd->creation_time = quicktime_read_int32(file);
- mdhd->modification_time = quicktime_read_int32(file);
- mdhd->time_scale = quicktime_read_int32(file);
- mdhd->duration = quicktime_read_int32(file);
- mdhd->language = quicktime_read_int16(file);
- mdhd->quality = quicktime_read_int16(file);
- }
- int quicktime_mdhd_dump(quicktime_mdhd_t *mdhd)
- {
- printf(" media headern");
- printf(" version %dn", mdhd->version);
- printf(" flags %dn", mdhd->flags);
- printf(" creation_time %un", mdhd->creation_time);
- printf(" modification_time %un", mdhd->modification_time);
- printf(" time_scale %dn", mdhd->time_scale);
- printf(" duration %dn", mdhd->duration);
- printf(" language %dn", mdhd->language);
- printf(" quality %dn", mdhd->quality);
- }
- int quicktime_write_mdhd(quicktime_t *file, quicktime_mdhd_t *mdhd)
- {
- quicktime_atom_t atom;
- quicktime_atom_write_header(file, &atom, "mdhd");
- quicktime_write_char(file, mdhd->version);
- quicktime_write_int24(file, mdhd->flags);
- quicktime_write_int32(file, mdhd->creation_time);
- quicktime_write_int32(file, mdhd->modification_time);
- quicktime_write_int32(file, mdhd->time_scale);
- quicktime_write_int32(file, mdhd->duration);
- quicktime_write_int16(file, mdhd->language);
- quicktime_write_int16(file, mdhd->quality);
- quicktime_atom_write_footer(file, &atom);
- }