Exemple #1
0
static bool read_avi(void *file, int frame, bitmap_yuy16 &bitmap, INT16 *lsound, INT16 *rsound, int &samples)
{
	avi_file *avifile = reinterpret_cast<avi_file *>(file);

	// read the frame
	avi_error avierr = avi_read_video_frame(avifile, frame, bitmap);
	if (avierr != AVIERR_NONE)
		return FALSE;

	// read the samples
	const avi_movie_info *aviinfo = avi_get_movie_info(avifile);
	UINT32 firstsample = (UINT64(aviinfo->audio_samplerate) * UINT64(frame) * UINT64(aviinfo->video_sampletime) + aviinfo->video_timescale - 1) / UINT64(aviinfo->video_timescale);
	UINT32 lastsample = (UINT64(aviinfo->audio_samplerate) * UINT64(frame + 1) * UINT64(aviinfo->video_sampletime) + aviinfo->video_timescale - 1) / UINT64(aviinfo->video_timescale);
	avierr = avi_read_sound_samples(avifile, 0, firstsample, lastsample - firstsample, lsound);
	avierr = avi_read_sound_samples(avifile, 1, firstsample, lastsample - firstsample, rsound);
	if (avierr != AVIERR_NONE)
		return false;
	samples = lastsample - firstsample;
	return true;
}
Exemple #2
0
static int read_avi(void *file, int frame, bitmap_yuy16 &bitmap, INT16 *lsound, INT16 *rsound, int *samples)
{
	const avi_movie_info *aviinfo = avi_get_movie_info((avi_file *)file);
	UINT32 firstsample = ((UINT64)aviinfo->audio_samplerate * (UINT64)frame * (UINT64)aviinfo->video_sampletime + aviinfo->video_timescale - 1) / (UINT64)aviinfo->video_timescale;
	UINT32 lastsample = ((UINT64)aviinfo->audio_samplerate * (UINT64)(frame + 1) * (UINT64)aviinfo->video_sampletime + aviinfo->video_timescale - 1) / (UINT64)aviinfo->video_timescale;
	avi_error avierr;

	/* read the frame */
	avierr = avi_read_video_frame((avi_file *)file, frame, bitmap);
	if (avierr != AVIERR_NONE)
		return FALSE;

	/* read the samples */
	avierr = avi_read_sound_samples((avi_file *)file, 0, firstsample, lastsample - firstsample, lsound);
	avierr = avi_read_sound_samples((avi_file *)file, 1, firstsample, lastsample - firstsample, rsound);
	if (avierr != AVIERR_NONE)
		return FALSE;
	*samples = lastsample - firstsample;
	return TRUE;
}