/* main.c */

int double_display = 0,gray = 0;

extern buf_size;
extern double y_scale,c_scale,c_offset;

write_2(a)
char *a;
{
	write(2,a,strlen(a));
}

main(argc,argv)
char **argv;
{
	int i,j;

	get_rid_of_root();
	for (i=1; i<argc; i++)
		if (*argv[i] == '-') {
			if (strcmp(argv[i],"--") == 0) {
				i++;
				break;
			}
			else if (strncmp(argv[i],"-b",2) == 0) {
				j = argv[i+1] ? atoi(argv[i+1]) : 0;
				if (j > buf_size)
					buf_size = j;
				i++;
			}
			else if (strncmp(argv[i],"-c",2) == 0) {
				if (argv[i+1]) {
					sscanf(argv[i+1],"%lf,%lf,%lf",&y_scale,&c_scale,&c_offset);
					i++;
				}
			}
			else if (strncmp(argv[i],"-g",2) == 0)
				gray = 1;
			else if (strncmp(argv[i],"-2",2) == 0)
				double_display = 1;
			else {
				write_2("bad switch\n");
				_exit(1);
			}
		}
		else
			break;
	if (i < argc) {
		close(0);
		if (open(argv[i],0)) {
			write_2("open failed\n");
			_exit(1);
		}
	}
	init_decoders();
	init_util();
	init_recon();
	init_video();
	while (!parse_stream())
		;
	eexit();
}
