int quicktime_read_smhd(quicktime_t *file, quicktime_smhd_t *smhd) { smhd->version = quicktime_read_char(file); smhd->flags = quicktime_read_int24(file); smhd->balance = quicktime_read_int16(file); smhd->reserved = quicktime_read_int16(file); }
void quicktime_read_vmhd(quicktime_t *file, quicktime_vmhd_t *vmhd) { int i; vmhd->version = quicktime_read_char(file); vmhd->flags = quicktime_read_int24(file); vmhd->graphics_mode = quicktime_read_int16(file); for(i = 0; i < 3; i++) vmhd->opcolor[i] = quicktime_read_int16(file); }
void 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_read_hmhd(quicktime_t *file, quicktime_hmhd_t *hmhd) { hmhd->version = quicktime_read_char(file); hmhd->flags = quicktime_read_int24(file); hmhd->maxPDUsize = quicktime_read_int16(file); hmhd->avgPDUsize = quicktime_read_int16(file); hmhd->maxbitrate = quicktime_read_int32(file); hmhd->avgbitrate = quicktime_read_int32(file); hmhd->slidingavgbitrate = quicktime_read_int32(file); return 0; }
int quicktime_read_tkhd(quicktime_t *file, quicktime_tkhd_t *tkhd) { tkhd->version = quicktime_read_char(file); tkhd->flags = quicktime_read_int24(file); tkhd->creation_time = quicktime_read_int32(file); tkhd->modification_time = quicktime_read_int32(file); tkhd->track_id = quicktime_read_int32(file); tkhd->reserved1 = quicktime_read_int32(file); tkhd->duration = quicktime_read_int32(file); quicktime_read_data(file, tkhd->reserved2, 8); tkhd->layer = quicktime_read_int16(file); tkhd->alternate_group = quicktime_read_int16(file); tkhd->volume = quicktime_read_fixed16(file); tkhd->reserved3 = quicktime_read_int16(file); quicktime_read_matrix(file, &(tkhd->matrix)); tkhd->track_width = quicktime_read_fixed32(file); tkhd->track_height = quicktime_read_fixed32(file); }
void quicktime_read_stsd_table(quicktime_t *file, quicktime_minf_t *minf, quicktime_stsd_table_t *table) { quicktime_atom_t leaf_atom; quicktime_atom_read_header(file, &leaf_atom); table->format[0] = leaf_atom.type[0]; table->format[1] = leaf_atom.type[1]; table->format[2] = leaf_atom.type[2]; table->format[3] = leaf_atom.type[3]; quicktime_read_data(file, table->reserved, 6); table->data_reference = quicktime_read_int16(file); if(minf->is_audio) quicktime_read_stsd_audio(file, table, &leaf_atom); if(minf->is_video) quicktime_read_stsd_video(file, table, &leaf_atom); }
void quicktime_read_stsd_audio(quicktime_t *file, quicktime_stsd_table_t *table, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; table->version = quicktime_read_int16(file); table->revision = quicktime_read_int16(file); quicktime_read_data(file, table->vendor, 4); table->channels = quicktime_read_int16(file); table->sample_size = quicktime_read_int16(file); table->compression_id = quicktime_read_int16(file); table->packet_size = quicktime_read_int16(file); table->sample_rate = quicktime_read_fixed32(file); // Kluge for fixed32 limitation if(table->sample_rate + 65536 == 96000 || table->sample_rate + 65536 == 88200) table->sample_rate += 65536; // Version 1 fields if(table->version > 0) { table->samples_per_packet = quicktime_read_int32(file); table->bytes_per_packet = quicktime_read_int32(file); table->bytes_per_frame = quicktime_read_int32(file); table->bytes_per_sample = quicktime_read_int32(file); // Skip another 20 bytes if(table->version == 2) { quicktime_set_position(file, quicktime_position(file) + 0x14); } while(quicktime_position(file) < parent_atom->end) { quicktime_atom_read_header(file, &leaf_atom); if(quicktime_atom_is(&leaf_atom, "wave")) { read_wave(file, table, &leaf_atom); } else { quicktime_atom_skip(file, &leaf_atom); } } } // FFMPEG says the esds sometimes contains a sample rate that overrides // the sample table. quicktime_esds_samplerate(table, &table->esds); }
int quicktime_read_ctab(quicktime_t *file, quicktime_ctab_t *ctab) { int i; ctab->seed = quicktime_read_int32(file); ctab->flags = quicktime_read_int16(file); ctab->size = quicktime_read_int16(file) + 1; ctab->alpha = malloc(sizeof(int16_t) * ctab->size); ctab->red = malloc(sizeof(int16_t) * ctab->size); ctab->green = malloc(sizeof(int16_t) * ctab->size); ctab->blue = malloc(sizeof(int16_t) * ctab->size); for(i = 0; i < ctab->size; i++) { ctab->alpha[i] = quicktime_read_int16(file); ctab->red[i] = quicktime_read_int16(file); ctab->green[i] = quicktime_read_int16(file); ctab->blue[i] = quicktime_read_int16(file); } return 0; }
void quicktime_read_stsd_video(quicktime_t *file, quicktime_stsd_table_t *table, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; int len; table->version = quicktime_read_int16(file); table->revision = quicktime_read_int16(file); quicktime_read_data(file, table->vendor, 4); table->temporal_quality = quicktime_read_int32(file); table->spatial_quality = quicktime_read_int32(file); table->width = quicktime_read_int16(file); table->height = quicktime_read_int16(file); table->dpi_horizontal = quicktime_read_fixed32(file); table->dpi_vertical = quicktime_read_fixed32(file); table->data_size = quicktime_read_int32(file); table->frames_per_sample = quicktime_read_int16(file); len = quicktime_read_char(file); quicktime_read_data(file, table->compressor_name, 31); table->depth = quicktime_read_int16(file); table->ctab_id = quicktime_read_int16(file); /* The data needed for SVQ3 codec and maybe some others ? */ struct ImageDescription *id; int stsd_size,fourcc,c,d; stsd_size = parent_atom->end - parent_atom->start; table->extradata_size = stsd_size - 4; id = (struct ImageDescription *) malloc(table->extradata_size); // we do not include size table->extradata = (char *) id; memcpy(id->cType, table->format, 4); // Fourcc id->version = table->version; id->revisionLevel = table->revision; memcpy(id->vendor, table->vendor, 4); // I think mplayer screws up on this one, it turns bytes around! :) id->temporalQuality = table->temporal_quality; id->spatialQuality = table->spatial_quality; id->width = table->width; id->height = table->height; id->hRes = table->dpi_horizontal; id->vRes = table->dpi_vertical; id->dataSize = table->data_size; id->frameCount = table->frames_per_sample; id->name[0] = len; memcpy(&(id->name[1]), table->compressor_name, 31); id->depth = table->depth; id->clutID = table->ctab_id; if (quicktime_position(file) < parent_atom->end) { int position = quicktime_position(file); // remember position int datalen = parent_atom->end - position; quicktime_read_data(file, ((char*)&id->clutID)+2, datalen); quicktime_set_position(file, position); // return to previous position so parsing can go on } while(quicktime_position(file) < parent_atom->end) { quicktime_atom_read_header(file, &leaf_atom); /* * printf("quicktime_read_stsd_video 1 %llx %llx %llx %s\n", * leaf_atom.start, leaf_atom.end, quicktime_position(file), * leaf_atom.type); */ if(quicktime_atom_is(&leaf_atom, "esds")) { quicktime_read_esds(file, &leaf_atom, &table->esds); } else if(quicktime_atom_is(&leaf_atom, "avcC")) { quicktime_read_avcc(file, &leaf_atom, &table->avcc); } else if(quicktime_atom_is(&leaf_atom, "ctab")) { quicktime_read_ctab(file, &(table->ctab)); } else if(quicktime_atom_is(&leaf_atom, "gama")) { table->gamma = quicktime_read_fixed32(file); } else if(quicktime_atom_is(&leaf_atom, "fiel")) { table->fields = quicktime_read_char(file); table->field_dominance = quicktime_read_char(file); } else quicktime_atom_skip(file, &leaf_atom); /* if(quicktime_atom_is(&leaf_atom, "mjqt")) */ /* { */ /* quicktime_read_mjqt(file, &(table->mjqt)); */ /* } */ /* else */ /* if(quicktime_atom_is(&leaf_atom, "mjht")) */ /* { */ /* quicktime_read_mjht(file, &(table->mjht)); */ /* } */ /* else */ } //printf("quicktime_read_stsd_video 2\n"); }
void quicktime_read_stsd_video(quicktime_t *file, quicktime_stsd_table_t *table, quicktime_atom_t *parent_atom) { quicktime_atom_t leaf_atom; int len; table->version = quicktime_read_int16(file); table->revision = quicktime_read_int16(file); quicktime_read_data(file, table->vendor, 4); table->temporal_quality = quicktime_read_int32(file); table->spatial_quality = quicktime_read_int32(file); table->width = quicktime_read_int16(file); table->height = quicktime_read_int16(file); table->dpi_horizontal = quicktime_read_fixed32(file); table->dpi_vertical = quicktime_read_fixed32(file); table->data_size = quicktime_read_int32(file); table->frames_per_sample = quicktime_read_int16(file); len = quicktime_read_char(file); quicktime_read_data(file, table->compressor_name, 31); table->depth = quicktime_read_int16(file); table->ctab_id = quicktime_read_int16(file); while(quicktime_position(file) < parent_atom->end) { quicktime_atom_read_header(file, &leaf_atom); /* * printf("quicktime_read_stsd_video 1 %llx %llx %llx %s\n", * leaf_atom.start, leaf_atom.end, quicktime_position(file), * leaf_atom.type); */ if(quicktime_atom_is(&leaf_atom, "esds")) { quicktime_read_esds(file, &leaf_atom, &table->esds); } else if(quicktime_atom_is(&leaf_atom, "avcC")) { quicktime_read_avcc(file, &leaf_atom, &table->avcc); } else if(quicktime_atom_is(&leaf_atom, "ctab")) { quicktime_read_ctab(file, &(table->ctab)); } else if(quicktime_atom_is(&leaf_atom, "gama")) { table->gamma = quicktime_read_fixed32(file); } else if(quicktime_atom_is(&leaf_atom, "fiel")) { table->fields = quicktime_read_char(file); table->field_dominance = quicktime_read_char(file); } else quicktime_atom_skip(file, &leaf_atom); /* if(quicktime_atom_is(&leaf_atom, "mjqt")) */ /* { */ /* quicktime_read_mjqt(file, &(table->mjqt)); */ /* } */ /* else */ /* if(quicktime_atom_is(&leaf_atom, "mjht")) */ /* { */ /* quicktime_read_mjht(file, &(table->mjht)); */ /* } */ /* else */ } //printf("quicktime_read_stsd_video 2\n"); }