Пример #1
0
FilterGraph *init_simple_filtergraph(InputStream *ist, OutputStream *ost)
{
    FilterGraph *fg = av_mallocz(sizeof(*fg));

    if (!fg)
        exit_program(1);
    fg->index = nb_filtergraphs;

    GROW_ARRAY(fg->outputs, fg->nb_outputs);
    if (!(fg->outputs[0] = av_mallocz(sizeof(*fg->outputs[0]))))
        exit_program(1);
    fg->outputs[0]->ost   = ost;
    fg->outputs[0]->graph = fg;

    ost->filter = fg->outputs[0];

    GROW_ARRAY(fg->inputs, fg->nb_inputs);
    if (!(fg->inputs[0] = av_mallocz(sizeof(*fg->inputs[0]))))
        exit_program(1);
    fg->inputs[0]->ist   = ist;
    fg->inputs[0]->graph = fg;

    GROW_ARRAY(ist->filters, ist->nb_filters);
    ist->filters[ist->nb_filters - 1] = fg->inputs[0];

    GROW_ARRAY(filtergraphs, nb_filtergraphs);
    filtergraphs[nb_filtergraphs - 1] = fg;

    return fg;
}
Пример #2
0
int main(int argc, char **argv)
{
    int ret;
    uint8_t *buffer = av_malloc(AVP_BUFFSIZE);

    if (!buffer)
        exit(1);

    register_exit(avprobe_cleanup);

    options = real_options;
    parse_loglevel(argc, argv, options);
    av_register_all();
    avformat_network_init();
    init_opts();
#if CONFIG_AVDEVICE
    avdevice_register_all();
#endif

    show_banner();

    octx.print_header = ini_print_header;
    octx.print_footer = ini_print_footer;

    octx.print_array_header = ini_print_array_header;
    octx.print_array_footer = ini_print_array_footer;
    octx.print_object_header = ini_print_object_header;

    octx.print_integer = ini_print_integer;
    octx.print_string = ini_print_string;

    parse_options(NULL, argc, argv, options, opt_input_file);

    if (!input_filename) {
        show_usage();
        fprintf(stderr, "You have to specify one input file.\n");
        fprintf(stderr,
                "Use -h to get full help or, even better, run 'man %s'.\n",
                program_name);
        exit_program(1);
    }

    probe_out = avio_alloc_context(buffer, AVP_BUFFSIZE, 1, NULL, NULL,
                                 probe_buf_write, NULL);
    if (!probe_out)
        exit_program(1);

    probe_header();
    ret = probe_file(input_filename);
    probe_footer();
    avio_flush(probe_out);
    av_freep(&probe_out);
    av_freep(&buffer);
    uninit_opts();
    avformat_network_deinit();

    return ret;
}
Пример #3
0
int menu()
{
    int user_choice;

    printf("1.Print Database\r\n");
    printf("2.Search Database\r\n");
    printf("3.Exit Database\r\n");

    while( scanf("%d",&user_choice) != 1)
    {
        fflush(stdin);
    }

    if(user_choice == 1) {
        print_database();
    }
    if(user_choice == 2) {
        search_database();
    }
    if(user_choice == 3) {
        exit_program();
    }
    else
    {
        printf("Please enter a proper value\r\n");
        menu();
    }

    return 0;
}
Пример #4
0
int opt_loglevel(const char *opt, const char *arg)
{
    const struct { const char *name; int level; } log_levels[] = {
        { "quiet"  , AV_LOG_QUIET   },
        { "panic"  , AV_LOG_PANIC   },
        { "fatal"  , AV_LOG_FATAL   },
        { "error"  , AV_LOG_ERROR   },
        { "warning", AV_LOG_WARNING },
        { "info"   , AV_LOG_INFO    },
        { "verbose", AV_LOG_VERBOSE },
        { "debug"  , AV_LOG_DEBUG   },
    };
    char *tail;
    int level;
    int i;

    for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
        if (!strcmp(log_levels[i].name, arg)) {
            av_log_set_level(log_levels[i].level);
            return 0;
        }
    }

    level = strtol(arg, &tail, 10);
    if (*tail) {
        av_log(NULL, AV_LOG_FATAL, "Invalid loglevel \"%s\". "
               "Possible levels are numbers or:\n", arg);
        for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
            av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name);
        exit_program(1);
    }
    av_log_set_level(level);
    return 0;
}
Пример #5
0
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
                   void (* parse_arg_function)(void *, const char*))
{
    const char *opt;
    int optindex, handleoptions = 1, ret;

    /* perform system-dependent conversions for arguments list */
    prepare_app_arguments(&argc, &argv);

    /* parse options */
    optindex = 1;
    while (optindex < argc) {
        opt = argv[optindex++];

        if (handleoptions && opt[0] == '-' && opt[1] != '\0') {
            if (opt[1] == '-' && opt[2] == '\0') {
                handleoptions = 0;
                continue;
            }
            opt++;

            if ((ret = parse_option(optctx, opt, argv[optindex], options)) < 0)
                exit_program(1);
            optindex += ret;
        } else {
            if (parse_arg_function)
                parse_arg_function(optctx, opt);
        }
    }
}
Пример #6
0
static char *choose_pix_fmts(OutputStream *ost)
{
    AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
    if (strict_dict)
        // used by choose_pixel_fmt() and below
        av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0);

     if (ost->keep_pix_fmt) {
        if (ost->filter)
            avfilter_graph_set_auto_convert(ost->filter->graph->graph,
                                            AVFILTER_AUTO_CONVERT_NONE);
        if (ost->enc_ctx->pix_fmt == AV_PIX_FMT_NONE)
            return NULL;
        return av_strdup(av_get_pix_fmt_name(ost->enc_ctx->pix_fmt));
    }
    if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
        return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)));
    } else if (ost->enc && ost->enc->pix_fmts) {
        const enum AVPixelFormat *p;
        AVIOContext *s = NULL;
        uint8_t *ret;
        int len;

        if (avio_open_dyn_buf(&s) < 0)
            exit_program(1);

        p = ost->enc->pix_fmts;
        if (ost->enc_ctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
            if (ost->enc_ctx->codec_id == AV_CODEC_ID_MJPEG) {
                p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE };
            } else if (ost->enc_ctx->codec_id == AV_CODEC_ID_LJPEG) {
                p = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P,
                                                    AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_BGRA, AV_PIX_FMT_NONE };
            }
Пример #7
0
bool exit_program(){
  switch(ask_question_char("\nÄr du säker på att du vill avsluta?\n[J]a eller [N]ej _")){
  case 'J': return false; break;
  case 'N': return true; break;
  default:  return exit_program();
  }
}
Пример #8
0
void caught_signal(int sig)
{
	fprintf(stderr, "Caught signal %d\n", sig);
	fprintf(stderr, "Total packet=%u]\n", count);
	
	exit_program(0);
}
Пример #9
0
int menu()
{
	int user_choice;
	
	printf("1.Print Database\r\n");
	printf("2.Add part to database\r\n");
	printf("3.Remove part from database\r\n");
	printf("4.Search Database\r\n");
	printf("5.Exit Database\r\n");
	
	while( scanf("%d%*c",&user_choice) != 1)
	{
		fflush(stdin);
	}
	
	if(user_choice == 1){ print_database(); }
	if(user_choice == 2){ add_parts_to_database();}
	if(user_choice == 3){ remove_parts_from_database();}
	if(user_choice == 4){ search_database();}
	if(user_choice == 5){ exit_program();}
	else
	{
		printf("Please enter a proper value\r\n");
		menu();
	}
	
	return 0;
}
Пример #10
0
static int exec_5()
{//WB stage
	  int ins = stage_context[4].ins;
	  u32_t type=-1;
	  if(ins>=0)
	  {
		    assert(stage_context[4].decoded!=NULL);
		    type=stage_context[4].decoded->type;
		    if(type==8)
		    {//halt. terminate the program!
				exit_program();
				assert(0);//no return!!!!
		    }
		    if(ins_pro[type]==0 || ins_pro[type]==2 ||( ins_pro[type]==3 && stage_context[4].decoded->type!=10) )
		    {
				regs[stage_context[4].decoded->dest]=stage_context[4].decoded->result;
				reg_valid_bits[stage_context[4].decoded->dest] = 1;
		    }
		    free_ins_buffer(ins);
		    free(stage_context[4].decoded);
		    stage_context[4].ins=-1;
		    stage_context[4].decoded=NULL;
	  }
	  return 0;
}
Пример #11
0
void check_usage(int argc, char** argv)
{
	if (argc < 4)
	{
		fprintf(stderr, "Usage: log_to_file mode dst src\n");
		exit_program(1);
	}
}
void check_usage(int argc, char** argv)
{
	if (argc != 2)
	{
		fprintf(stderr, "Usage: parse_log <trace_file>\n");
		exit_program(1);
	}
}
Пример #13
0
void check_usage(int argc, char** argv)
{
	if (argc != 2)
	{
		fprintf(stderr, "Usage: %s <output_file>\n", argv[0]);
		exit_program(1);
	}
}
Пример #14
0
void *grow_array(void *array, int elem_size, int *size, int new_size)
{
    if (new_size >= INT_MAX / elem_size) {
        av_log(NULL, AV_LOG_ERROR, "Array too big.\n");
        exit_program(1);
    }
    if (*size < new_size) {
        uint8_t *tmp = av_realloc(array, new_size*elem_size);
        if (!tmp) {
            av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n");
            exit_program(1);
        }
        memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
        *size = new_size;
        return tmp;
    }
    return array;
}
Пример #15
0
static char *choose_pix_fmts(OutputStream *ost)
{
    AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
    if(strict_dict)
        // used by choose_pixel_fmt() and below
    {
        av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0);
    }
    
    if(ost->keep_pix_fmt)
    {
        if(ost->filter)
            avfilter_graph_set_auto_convert(ost->filter->graph->graph,
                                            AVFILTER_AUTO_CONVERT_NONE);
        if(ost->enc_ctx->pix_fmt == AV_PIX_FMT_NONE)
        {
            return NULL;
        }
        return av_strdup(av_get_pix_fmt_name(ost->enc_ctx->pix_fmt));
    }
    if(ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE)
    {
        return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)));
    }
    else if(ost->enc && ost->enc->pix_fmts)
    {
        const enum AVPixelFormat *p;
        AVIOContext *s = NULL;
        uint8_t *ret;
        int len;
        
        if(avio_open_dyn_buf(&s) < 0)
        {
            exit_program(1);
        }
        
        p = ost->enc->pix_fmts;
        if(ost->enc_ctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL)
        {
            p = get_compliance_unofficial_pix_fmts(ost->enc_ctx->codec_id, p);
        }
        
        for(; *p != AV_PIX_FMT_NONE; p++)
        {
            const char *name = av_get_pix_fmt_name(*p);
            avio_printf(s, "%s|", name);
        }
        len = avio_close_dyn_buf(s, &ret);
        ret[len - 1] = 0;
        return ret;
    }
    else
    {
        return NULL;
    }
}
Пример #16
0
int main()
{
  goods_t *myShelf = create_shelf(100);
  goods_t *previousshelf = create_shelf(100);
  int loop = 1; 
 
 
  while (loop)
    {
      menu();
      char option = read_char();
      switch(option)
	{

	case 'A':
	  {
	    get_old_shelf(previousshelf, myShelf);
	    add_to_shelf_IO(myShelf);
	    break;
	  }

	case 'R':
	  {
	    get_old_shelf(previousshelf, myShelf);
	    char remove = 'r';
	    show_page_IO(myShelf, remove);
	    break;
	  }

	case 'E':
	  {
	    char edit = 'e';
	    show_page_IO(myShelf, edit);
	    break;
	  }
	case 'U':
	  undo_action(previousshelf, myShelf);
	  printf("\n\tYou have undone your latest action");
	  break;
	  
	case 'L':
	  {
	    char list = 'l';
	    show_page_IO(myShelf, list);  
	    break;
	  }  
	case 'x':
	  exit_program();
	  break;
	default:
	  printf("\n\nInvalid input _");
	  break;
	}
    }
  return 0;
}
Пример #17
0
FILE* open_file(char* filename, char* spec)
{
	FILE* fp = fopen(filename, spec);
	if (!fp)
	{
		perror("fopen");
		exit_program(1);
	}
	return fp;
}
Пример #18
0
int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
{
    int64_t us;
    if (av_parse_time(&us, timestr, is_duration) < 0) {
        av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n",
               is_duration ? "duration" : "date", context, timestr);
        exit_program(1);
    }
    return us;
}
Пример #19
0
void check_version(int ver)
{
    if (ver == version())
        return;
    PRINT("FATAL ERROR:");
    PRINT("You have wrong version of bootstrapper!");
    PRINT("Actual version: " << ver);
    PRINT("Your version: " << version());
    PRINT("Please, run BootstrapUpdater.exe to update the bootstrapper.");
    exit_program(1);
}
int main(int argc, char** argv)
{
	/* Local variables */
	unsigned char buf[BUF_SIZE];
	unsigned short l, l2;
	FILE* in;

	/* Make sure usage is correct */
	check_usage(argc, argv);

	/* Open and check log file */
	in = open_file(argv[1], "r");

	/* Read the next entry size */
	fread(&l2, 1, sizeof(unsigned short), in);
	l = ntohs(l2);
	while (!feof(in)) {
		/* Sanity-check the entry size */
		if (l == 0) {
			fprintf(stderr, "Error: got entry size=0\n");
			exit_program(-1);
		} else if (l > BUF_SIZE) {
			fprintf(stderr,
				"Error: got entry size %u > BUF_SIZE=%u\n",
				l, BUF_SIZE);
			exit_program(-2);
		}

		/* Read in the entry */
		fread(buf, l, sizeof(*buf), in);

		printf("Entry size=%d, code=0x%X\n", l, buf[0]);

		/* Read the next entry size */
		fread(&l2, 1, sizeof(unsigned short), in);
		l = ntohs(l2);
	}

	exit_program(0);
	return 0;
}
Пример #21
0
static void opt_input_file(void *optctx, const char *arg)
{
    if (input_filename) {
        fprintf(stderr,
                "Argument '%s' provided as input filename, but '%s' was already specified.\n",
                arg, input_filename);
        exit_program(1);
    }
    if (!strcmp(arg, "-"))
        arg = "pipe:";
    input_filename = arg;
}
Пример #22
0
void create_window(void) {
SDL_SysWMinfo info;
int xres, yres;

	get_display_res(&xres, &yres);

	screen_width = xres * 0.6f;
	screen_height = screen_width * 0.4f;

	SDK_window_hints(SDL_NOFRAME);

	if (SDK_create_window(screen_width, screen_height, 0, "mpflow") < 0) {
		fprintf(stderr, "error: failed to create window\n");
		exit_program(1);
	}
/*
	put window in center of the screen
*/
	SDL_VERSION(&info.version);

	if (SDL_GetWMInfo(&info) > 0 && info.subsystem == SDL_SYSWM_X11) {
/*
	This code gets the current video mode by reading the size of the desktop root window
	The trouble is that it needs a window to be able to do that

		Window root_window, child_window;
		int a, b, c, d;
		unsigned int u;
		XWindowAttributes attrs;

		info.info.x11.lock_func();

		XQueryPointer(info.info.x11.display, info.info.x11.window, &root_window, &child_window, &a, &b, &c, &d, &u);
		XGetWindowAttributes(info.info.x11.display, root_window, &attrs);

		info.info.x11.unlock_func();
		printf("TD root window size [%d, %d]\n", attrs.width, attrs.height);
*/
/* center window on screen */
		window_x = (xres - screen_width) / 2;
		window_y = (yres - screen_height) / 2;

		info.info.x11.lock_func();

		XMoveWindow(info.info.x11.display, info.info.x11.wmwindow, window_x, window_y);
		XMapRaised(info.info.x11.display, info.info.x11.wmwindow);

		info.info.x11.unlock_func();
	} else
		window_x = window_y = 0;
}
Пример #23
0
void db_autofill(db_t *db, int items){
  const char *names[] = {"Bullar", "Citron", "Deg", "Fisk", "Gurka", "Ingefära", "Jordnötter",
			 "Kaffe", "Lingon", "Mjölk", "Nudlar", "Päron", "Smör", "Tomat", NULL};
  int names_s = -1;
  while(names[++names_s]);
  const char desc[] = "Blah blah ";
  int names_usage[sizeof(names)/sizeof(char)];
  const int amounts[] = {100, 200, 300, 400, 1337};
  const int price_divider = 20;
  int c;
  for(c=0; c<names_s; c++){
    names_usage[c] = 1;
  }

  for(c=0; c<items; c++){
    ware_t ware;
    strcpy(ware.name, names[c%names_s]);
    strcpy(ware.description, desc);
    strcat(ware.description, names[c%names_s]);
    ware.amount=amounts[c%(sizeof(amounts)/sizeof(int))];
    ware.price=(amounts[c%(sizeof(amounts)/sizeof(int))]/price_divider);
    ware.storage_location=(storage_location_t){.character=*names[c%names_s],
	                                       .number=names_usage[c%names_s]++};
    db_insert_mute(db, ware);
  }
}

int main(int argc, char *argv[]){
  bool running = true;
  char input;
  ware_t wares[1024];
  db_t db = {.current_index=0, .max_index=sizeof(wares)/sizeof(ware_t), .wares=wares, .copy_index=-1};

  db_autofill(&db, 10);

  while(running){     
    input = ask_question_char("\nVälkommen till lagerhantering 1.0\n=================================\n[L]ägga till en vara\n[T]a bort en vara\n[R]edigera en vara\nÅn[g]ra senaste ändringen\nLista [h]ela varukatalogen\n[A]vsluta\n\nVad vill du göra idag? _");

    switch(input){
    case 'L': add_goods(&db); break;
    case 'T': remove_goods(&db); break;
    case 'R': edit_goods(&db); break;
    case 'G': undo_goods(&db); break;
    case 'H': list_goods(&db); break;
    case 'A': running = exit_program(); break;
    default:  puts("Okänt kommando.");
    }
  }
  return 0;
}
Пример #24
0
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
{
    av_freep(&ofilter->name);
    DESCRIBE_FILTER_LINK(ofilter, out, 0);

    if (!ofilter->ost) {
        av_log(NULL, AV_LOG_FATAL, "Filter %s has a unconnected output\n", ofilter->name);
        exit_program(1);
    }

    switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) {
    case AVMEDIA_TYPE_VIDEO: return configure_output_video_filter(fg, ofilter, out);
    case AVMEDIA_TYPE_AUDIO: return configure_output_audio_filter(fg, ofilter, out);
    default: av_assert0(0);
    }
}
Пример #25
0
int init_complex_filtergraph(FilterGraph *fg)
{
    AVFilterInOut *inputs, *outputs, *cur;
    AVFilterGraph *graph;
    int ret = 0;
    
    /* this graph is only used for determining the kinds of inputs
     * and outputs we have, and is discarded on exit from this function */
    graph = avfilter_graph_alloc();
    if(!graph)
    {
        return AVERROR(ENOMEM);
    }
    
    ret = avfilter_graph_parse2(graph, fg->graph_desc, &inputs, &outputs);
    if(ret < 0)
    {
        goto fail;
    }
    
    for(cur = inputs; cur; cur = cur->next)
    {
        init_input_filter(fg, cur);
    }
    
    for(cur = outputs; cur;)
    {
        GROW_ARRAY(fg->outputs, fg->nb_outputs);
        fg->outputs[fg->nb_outputs - 1] = av_mallocz(sizeof(*fg->outputs[0]));
        if(!fg->outputs[fg->nb_outputs - 1])
        {
            exit_program(1);
        }
        
        fg->outputs[fg->nb_outputs - 1]->graph   = fg;
        fg->outputs[fg->nb_outputs - 1]->out_tmp = cur;
        fg->outputs[fg->nb_outputs - 1]->type    = avfilter_pad_get_type(cur->filter_ctx->output_pads,
                cur->pad_idx);
        cur = cur->next;
        fg->outputs[fg->nb_outputs - 1]->out_tmp->next = NULL;
    }
    
fail:
    avfilter_inout_free(&inputs);
    avfilter_graph_free(&graph);
    return ret;
}
Пример #26
0
int main(int argc, char *argv[]) {
	printf("mpflow - Copyright (C) 2009 Walter de Jong <*****@*****.**>\n");
	get_options(argc, argv);

	if (lock_program() == -1) {
		printf("another instance of mpflow is already running\n");
		return 1;
	}
	init_mpd();

/* init app */
	SDK_init();

	create_window();
	set_app_icon();

	init_gl();
	draw_startup();			/* only a border */

/* note that the order of init_() functions here is important (!) */
	init_textures();
	init_text();
	init_covers();
	init_events();

	init_widget_covers();
	init_widget_about();
	init_widget_aboutbutton();
	init_widget_titlebar();

	main_widget = &w_titlebar;
	prepare_widgets();
	draw();

	for(;;) {
		SDK_handle_events();
		move_covers();

		if (!moving)
			SDL_WaitEvent(NULL);
		else
			SDK_sleep(FRAME_DELAY);
	}
	exit_program(0);
	return 0;
}
Пример #27
0
/* we've gotten a message from the other side saying that he's sent the
 * last of the file being transfered.  close the local file descriptor.
 */
static void end_receiving_file(message_t *buf)
{
    if (!receiving) {
        fprintf(stderr, "end_receiving_file:  "
                "got transfer_end_msg while not receiving.\n");
        return;
    }

    close(fd);
    receiving = 0;
    fprintf(stderr, "end_receiving_file..\n");

    if (!server) {
        exit_program(0);
    }

    state = state_nominal;
}
Пример #28
0
static int input_about(int key) {
	switch(key) {
		case SDK_ESC:
			exit_program(0);
			return 1;

		case SDK_ENTER:
		case SDK_SPACE:
			main_widget = &w_covers;
			main_widget->prepare();
			draw();
			return 1;

		default:
			;
	}
	return 0;
}
Пример #29
0
int		ft_key_hook(int keycode, t_env *env)
{
	if (keycode == ESC)
		exit_program(keycode, 0);
	else if (keycode == MINUS || keycode == PLUS)
		handle_size(keycode, env);
	else if (keycode == LEFT || keycode == RIGHT
			|| keycode == UP || keycode == DOWN)
		handle_pos(keycode, env);
	else if (keycode == SLASH || keycode == STAR)
		handle_spike(keycode, env);
	else if (keycode == KEY_C)
	{
		env->ui = !env->ui ? 1 : 0;
		expose_hook(env);
	}
	return (0);
}
Пример #30
0
double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
{
    char *tail;
    const char *error;
    double d = av_strtod(numstr, &tail);
    if (*tail)
        error= "Expected number for %s but found: %s\n";
    else if (d < min || d > max)
        error= "The value for %s was %s which is not within %f - %f\n";
    else if(type == OPT_INT64 && (int64_t)d != d)
        error= "Expected int64 for %s but found %s\n";
    else if (type == OPT_INT && (int)d != d)
        error= "Expected int for %s but found %s\n";
    else
        return d;
    av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max);
    exit_program(1);
    return 0;
}