Пример #1
0
int quicktime_set_video_position(quicktime_t *file, int64_t frame, int track)
{
	int64_t offset, chunk_sample, chunk;
	quicktime_trak_t *trak;
	if(track >= file->total_vtracks)
	{
		fprintf(stderr, 
			"quicktime_set_video_position: frame=%lld track=%d >= file->total_vtracks %d\n", 
			frame,
			track,
			file->total_vtracks);
		track = file->total_vtracks - 1;
	}

	if(track < file->total_vtracks && track >= 0)
	{
		trak = file->vtracks[track].track;
		file->vtracks[track].current_position = frame;
		quicktime_chunk_of_sample(&chunk_sample, &chunk, trak, frame);
		file->vtracks[track].current_chunk = chunk;
		offset = quicktime_sample_to_offset(file, trak, frame);
		quicktime_set_position(file, offset);
	}
	return 0;
}
Пример #2
0
long quicktime_read_audio(quicktime_t *file,
	char *audio_buffer, long samples, int track)
{
	quicktime_audio_map_t *track_map = &file->atracks[track];
	quicktime_trak_t *trak = track_map->track;
	int64_t position, chunk, chunk_sample;
	long ret, bytes, chunk_offset, chunk_len;
	int result = 0;

	position = file->atracks[track].current_position;
	quicktime_chunk_of_sample(&chunk_sample, &chunk, trak, position);
	ret = 0;

	while( samples > 0 ) {
		int64_t offset = quicktime_sample_to_offset(file, trak, position);
		quicktime_set_position(file, offset);
		chunk_offset = position - chunk_sample;
		chunk_len = quicktime_chunk_samples(trak, chunk) - chunk_offset;
		if( chunk_len > samples ) chunk_len = samples;
		else ++chunk;
		chunk_sample = (position += chunk_len);
		bytes = quicktime_samples_to_bytes(trak, chunk_len);
		result = !quicktime_read_data(file, &audio_buffer[ret], bytes);
		if( result ) break;
		ret += bytes;
		samples -= chunk_len;
	}
//printf("quicktime_read_audio 5\n");

	track_map->current_position = position;
	track_map->current_chunk = chunk;
	return !result ? ret : 0;
}
Пример #3
0
int quicktime_set_video_position(quicktime_t *file, long frame, int track)
{
	long offset, chunk_sample, chunk;
	quicktime_trak_t *trak;

	if(file->total_vtracks)
	{
		trak = file->vtracks[track].track;
		file->vtracks[track].current_position = frame;
		quicktime_chunk_of_sample(&chunk_sample, &chunk, trak, frame);
		file->vtracks[track].current_chunk = chunk;
		offset = quicktime_sample_to_offset(trak, frame);
		quicktime_set_position(file, offset);
		/*quicktime_update_positions(file); */
	}
	return 0;
}
Пример #4
0
int quicktime_set_audio_position(quicktime_t *file, int64_t sample, int track)
{
	int64_t offset, chunk_sample, chunk;
	quicktime_trak_t *trak;

	if(track < file->total_atracks)
	{
		trak = file->atracks[track].track;
		file->atracks[track].current_position = sample;
		quicktime_chunk_of_sample(&chunk_sample, &chunk, trak, sample);
		file->atracks[track].current_chunk = chunk;
		offset = quicktime_sample_to_offset(file, trak, sample);
		quicktime_set_position(file, offset);
	}
	else
		fprintf(stderr, "quicktime_set_audio_position: track >= file->total_atracks\n");

	return 0;
}