Exemple #1
0
static void *open_avi(const char *filename, movie_info *info)
{
	const avi_movie_info *aviinfo;
	avi_error avierr;
	avi_file *avi;

	/* open the file */
	avierr = avi_open(filename, &avi);
	if (avierr != AVIERR_NONE)
	{
		fprintf(stderr, "Error opening AVI file: %s\n", avi_error_string(avierr));
		return NULL;
	}

	/* extract movie info */
	aviinfo = avi_get_movie_info(avi);
	info->framerate = (double)aviinfo->video_timescale / (double)aviinfo->video_sampletime;
	info->numframes = aviinfo->video_numsamples;
	info->width = aviinfo->video_width;
	info->height = aviinfo->video_height;
	info->samplerate = aviinfo->audio_samplerate;
	info->channels = aviinfo->audio_channels;

	return avi;
}
Exemple #2
0
bool DRV_AviBegin(const char* fname)
{
	DRV_AviEnd();

	BITMAPINFOHEADER bi;
	memset(&bi, 0, sizeof(bi));
	bi.biSize = 0x28;    
	bi.biPlanes = 1;
	bi.biBitCount = 24;
	bi.biWidth = 256;
	bi.biHeight = 384;
	bi.biSizeImage = 3 * 256 * 384;

	WAVEFORMATEX wf;
	wf.cbSize = sizeof(WAVEFORMATEX);
	wf.nAvgBytesPerSec = 44100 * 4;
	wf.nBlockAlign = 4;
	wf.nChannels = 2;
	wf.nSamplesPerSec = 44100;
	wf.wBitsPerSample = 16;
	wf.wFormatTag = WAVE_FORMAT_PCM;
	

	saved_avi_ext[0]='\0';

	//mbg 8/10/08 - decide whether there will be sound in this movie
	//if this is a new movie..
	/*if(!avi_file) {
		if(FSettings.SndRate)
			use_sound = true;
		else use_sound = false;
	}*/

	//mbg 8/10/08 - if there is no sound in this movie, then dont open the audio stream
	WAVEFORMATEX* pwf = &wf;
	//if(!use_sound)
	//	pwf = 0;


	if(!avi_open(fname, &bi, pwf))
	{
		saved_avi_fname[0]='\0';
		return 0;
	}

	// Don't display at file splits
	if(!avi_segnum)
		EMU_PrintMessage("AVI recording started.");

	strncpy(saved_cur_avi_fnameandext,fname,MAX_PATH);
	strncpy(saved_avi_fname,fname,MAX_PATH);
	char* dot = strrchr(saved_avi_fname, '.');
	if(dot && dot > strrchr(saved_avi_fname, '/') && dot > strrchr(saved_avi_fname, '\\'))
	{
		strcpy(saved_avi_ext,dot);
		dot[0]='\0';
	}
	return 1;
}
Exemple #3
0
int FCEUI_AviBegin(const char* fname)
{
	FCEUI_AviEnd();

	struct VideoSystemInfo vsi;
	BITMAPINFOHEADER bi;
	int is_pal;

	is_pal=FCEUI_GetCurrentVidSystem(&vsi.start_scanline, &vsi.end_scanline);
	vsi.fps = FCEUI_GetDesiredFPS();//is_pal ? 50 : 60;
	vsi.end_scanline++;

	memset(&bi, 0, sizeof(bi));
	bi.biSize = sizeof(BITMAPINFOHEADER);    
	bi.biPlanes = 1;
	bi.biBitCount = 24;
	bi.biWidth = VIDEO_WIDTH;
	bi.biHeight = vsi.end_scanline-vsi.start_scanline;
	bi.biSizeImage = 3 * bi.biWidth * bi.biHeight;

	//mbg 6/27/08 -- this was originally labeled as hacky..
	WAVEFORMATEX wf;
	wf.cbSize = sizeof(WAVEFORMATEX);
	wf.nAvgBytesPerSec = soundrate * 2;
	wf.nBlockAlign = 2;
	wf.nChannels = 1;
	wf.nSamplesPerSec = soundrate;
	wf.wBitsPerSample = 16;
	wf.wFormatTag = WAVE_FORMAT_PCM;
	

	saved_avi_ext[0]='\0';

	//mbg 8/10/08 - decide whether there will be sound in this movie
	//if this is a new movie..
	if(!avi_file) {
		if(FSettings.SndRate)
			use_sound = true;
		else use_sound = false;
	}

	//mbg 8/10/08 - if there is no sound in this movie, then dont open the audio stream
	WAVEFORMATEX* pwf = &wf;
	if(!use_sound)
		pwf = 0;


	if(!avi_open(fname, &bi, pwf, &vsi))
	{
		saved_avi_fname[0]='\0';
		return 0;
	}

	// Don't display at file splits
	if(!avi_segnum)
		FCEU_DispMessage("AVI recording started.",0);

	strncpy(saved_cur_avi_fnameandext,fname,MAX_PATH);
	strncpy(saved_avi_fname,fname,MAX_PATH);
	char* dot = strrchr(saved_avi_fname, '.');
	if(dot && dot > strrchr(saved_avi_fname, '/') && dot > strrchr(saved_avi_fname, '\\'))
	{
		strcpy(saved_avi_ext,dot);
		dot[0]='\0';
	}
	return 1;
}
Exemple #4
0
static int generate_from_avi(const char *aviname)
{
	UINT32 line12 = 0, line13 = 0, line14 = 0, framenum = 0, chapternum = 0;
	const avi_movie_info *info;
	bitmap_t *bitmap;
	avi_error avierr;
	avi_file *avi;
	int white = 0;
	int frame;

	/* open the file */
	avierr = avi_open(aviname, &avi);
	if (avierr != AVIERR_NONE)
	{
		fprintf(stderr, "Error opening AVI file: %s\n", avi_error_string(avierr));
		return 1;
	}

	/* extract movie info */
	info = avi_get_movie_info(avi);
	fprintf(stderr, "%dx%d - %d frames total\n", info->video_width, info->video_height, info->video_numsamples);
	if (info->video_height != 39)
	{
		fprintf(stderr, "Unknown VANC capture format: expected 39 rows\n");
		return 1;
	}

	/* allocate a bitmap to hold it */
	bitmap = bitmap_alloc(info->video_width, info->video_height, BITMAP_FORMAT_YUY16);
	if (bitmap == NULL)
	{
		fprintf(stderr, "Out of memory allocating %dx%d bitmap\n", info->video_width, info->video_height);
		return 1;
	}

	/* loop over frames */
	for (frame = 0; frame < info->video_numsamples; frame++)
	{
		int field;
		UINT8 bits[24];

		/* read the frame */
		avierr = avi_read_video_frame_yuy16(avi, frame, bitmap);
		if (avierr != AVIERR_NONE)
		{
			fprintf(stderr, "Error reading AVI frame %d: %s\n", frame, avi_error_string(avierr));
			break;
		}

		/* loop over two fields */
		for (field = 0; field < 2; field++)
		{
			int prevwhite = white;
			int i;

			/* line 7 contains the white flag */
			white = 0;
			if (*BITMAP_ADDR16(bitmap, 20 * field + 7, bitmap->width / 2) > 0x8000)
				white = 1;

			/* output metadata for *previous* field */
			if (frame > 0 || field > 0)
			{
				int flags = 0;

				if (!prevwhite) flags |= 0x01;
				if (!white) flags |= 0x02;
				output_meta(flags, prevwhite, line12, line13, line14, framenum, chapternum);
			}

			/* line 12 contains stop code and other interesting bits */
			line12 = 0;
			if (parse_line(bitmap, 20 * field + 12, 24, bits) == 24)
				for (i = 0; i < 24; i++)
					line12 = (line12 << 1) | bits[i];

			/* line 13 and 14 contain frame/chapter/lead in/out encodings */
			line13 = 0;
			if (parse_line(bitmap, 20 * field + 13, 24, bits) == 24)
				for (i = 0; i < 24; i++)
					line13 = (line13 << 1) | bits[i];

			line14 = 0;
			if (parse_line(bitmap, 20 * field + 14, 24, bits) == 24)
				for (i = 0; i < 24; i++)
					line14 = (line14 << 1) | bits[i];

			/* the two lines must match */
//          if (line13 != 0 && line14 != 0 && line13 != line14)
//              line13 = line14 = 0;

			/* is this a frame number? */
			if ((line13 & 0xf00000) == 0xf00000)
				framenum = line13 & 0x7ffff;
			if ((line13 & 0xf00fff) == 0x800ddd)
				chapternum = (line13 >> 12) & 0x7f;
		}
	}

	/* output metadata for *previous* field */
	{
		int flags = 0;

		if (!white) flags |= 0x01;
		output_meta(flags, white, line12, line13, line14, framenum, chapternum);
	}

	bitmap_free(bitmap);
	return 0;
}