void quicktime_read_hdlr(quicktime_t *file, quicktime_hdlr_t *hdlr) { hdlr->version = quicktime_read_char(file); hdlr->flags = quicktime_read_int24(file); quicktime_read_char32(file, hdlr->component_type); quicktime_read_char32(file, hdlr->component_subtype); hdlr->component_manufacturer = quicktime_read_int32(file); hdlr->component_flags = quicktime_read_int32(file); hdlr->component_flag_mask = quicktime_read_int32(file); quicktime_read_pascal(file, hdlr->component_name); }
int quicktime_read_hdlr(quicktime_t *file, quicktime_hdlr_t *hdlr) { hdlr->version = quicktime_read_char(file); hdlr->flags = quicktime_read_int24(file); quicktime_read_char32(file, hdlr->component_type); quicktime_read_char32(file, hdlr->component_subtype); hdlr->component_manufacturer = quicktime_read_int32(file); hdlr->component_flags = quicktime_read_int32(file); hdlr->component_flag_mask = quicktime_read_int32(file); if (file->use_mp4) { // TBD read null terminated string } else { quicktime_read_pascal(file, hdlr->component_name); } }
void quicktime_read_dref_table(quicktime_t *file, quicktime_dref_table_t *table) { table->size = quicktime_read_int32(file); quicktime_read_char32(file, table->type); table->version = quicktime_read_char(file); table->flags = quicktime_read_int24(file); if(table->data_reference) free(table->data_reference); table->data_reference = malloc(table->size); if(table->size > 12) quicktime_read_data(file, table->data_reference, table->size - 12); table->data_reference[table->size - 12] = 0; }
void quicktime_read_indx(quicktime_t *file, quicktime_strl_t *strl, quicktime_atom_t *parent_atom) { quicktime_indx_t *indx = &strl->indx; quicktime_indxtable_t *indx_table; quicktime_ix_t *ix; int i; int64_t offset; indx->longs_per_entry = quicktime_read_int16_le(file); indx->index_subtype = quicktime_read_char(file); indx->index_type = quicktime_read_char(file); indx->table_size = quicktime_read_int32_le(file); quicktime_read_char32(file, indx->chunk_id); quicktime_read_int32_le(file); quicktime_read_int32_le(file); quicktime_read_int32_le(file); // file->is_odml = 1; //printf("quicktime_read_indx 1\n"); /* Read indx entries */ indx->table = calloc(indx->table_size, sizeof(quicktime_indxtable_t)); for(i = 0; i < indx->table_size; i++) { indx_table = &indx->table[i]; indx_table->index_offset = quicktime_read_int64_le(file); indx_table->index_size = quicktime_read_int32_le(file); indx_table->duration = quicktime_read_int32_le(file); offset = quicktime_position(file); indx_table->ix = calloc(indx->table_size, sizeof(quicktime_ix_t*)); /* Now read the partial index */ ix = indx_table->ix = calloc(1, sizeof(quicktime_ix_t)); quicktime_set_position(file, indx_table->index_offset); quicktime_read_ix(file, ix); quicktime_set_position(file, offset); } //printf("quicktime_read_indx 100\n"); }
int quicktime_read_info(quicktime_t *file) { int result = 0, found_moov = 0; int i, j, k, m, channel, trak_channel, track; long start_position = quicktime_position(file); quicktime_atom_t leaf_atom; quicktime_trak_t *trak; char avi_test[4]; /* Check for Microsoft AVI */ quicktime_read_char32(file, avi_test); if(quicktime_match_32(avi_test, "RIFF")) { quicktime_read_char32(file, avi_test); quicktime_read_char32(file, avi_test); if(quicktime_match_32(avi_test, "AVI ")) file->use_avi = 1; } quicktime_set_position(file, 0); do { result = quicktime_atom_read_header(file, &leaf_atom); if(!result) { if(quicktime_atom_is(&leaf_atom, "mdat")) { quicktime_read_mdat(file, &(file->mdat), &leaf_atom); } else if(quicktime_atom_is(&leaf_atom, "moov")) { quicktime_read_moov(file, &(file->moov), &leaf_atom); found_moov = 1; } else { quicktime_atom_skip(file, &leaf_atom); } } }while(!result && quicktime_position(file) < file->total_length); /* go back to the original position */ quicktime_set_position(file, start_position); if(found_moov) { /* get tables for all the different tracks */ file->total_atracks = quicktime_audio_tracks(file); file->atracks = (quicktime_audio_map_t*)calloc(1, sizeof(quicktime_audio_map_t) * file->total_atracks); for(i = 0, track = 0; i < file->total_atracks; i++) { while(!file->moov.trak[track]->mdia.minf.is_audio) track++; quicktime_init_audio_map(&(file->atracks[i]), file->moov.trak[track]); } file->total_vtracks = quicktime_video_tracks(file); file->vtracks = (quicktime_video_map_t*)calloc(1, sizeof(quicktime_video_map_t) * file->total_vtracks); for(track = 0, i = 0; i < file->total_vtracks; i++) { while(!file->moov.trak[track]->mdia.minf.is_video) track++; quicktime_init_video_map(&(file->vtracks[i]), file->moov.trak[track]); } /* for all tracks */ for (track = 0; track < file->moov.total_tracks; track++) { /* check if it's a hint track */ if (!file->moov.trak[track]->mdia.minf.is_hint) { continue; } /* it is, so for each reference */ for (j = 0; j < file->moov.trak[track]->tref.hint.numTracks; j++) { /* get the reference track id */ long refTrackId = file->moov.trak[track]->tref.hint.trackIds[j]; /* check each audio track */ for(k = 0; k < file->total_atracks; k++) { if (file->atracks[k].track->tkhd.track_id == refTrackId) { int m = file->atracks[k].totalHintTracks++; file->atracks[k].hintTracks[m] = file->moov.trak[track]; file->atracks[k].hintPositions[m] = 0; file->moov.trak[track]->tref.hint.traks[j] = file->atracks[k].track; file->total_hint_tracks++; break; } } /* check each video track */ for(k = 0; k < file->total_vtracks; k++) { if (file->vtracks[k].track->tkhd.track_id == refTrackId) { int m = file->vtracks[k].totalHintTracks++; file->vtracks[k].hintTracks[m] = file->moov.trak[track]; file->vtracks[k].hintPositions[m] = 0; file->moov.trak[track]->tref.hint.traks[j] = file->vtracks[k].track; file->total_hint_tracks++; break; } } } } } if(found_moov) return 0; else return 1; }