static int opt_preset(const char *opt, const char *arg)

{

    FILE *f=NULL;

    char filename[1000], tmp[1000], tmp2[1000], line[1000];

    int i;

    const char *base[3]= { getenv("HOME"),

                           "/usr/local/share",

                           "/usr/share",

                         };



    for(i=!base[0]; i<3 && !f; i++){

        snprintf(filename, sizeof(filename), "%s/%sffmpeg/%s.ffpreset", base[i], i ? "" : ".", arg);

        f= fopen(filename, "r");

        if(!f){

            char *codec_name= *opt == 'v' ? video_codec_name :

                              *opt == 'a' ? audio_codec_name :

                                            subtitle_codec_name;

            snprintf(filename, sizeof(filename), "%s/%sffmpeg/%s-%s.ffpreset", base[i],  i ? "" : ".", codec_name, arg);

            f= fopen(filename, "r");

        }

    }

    if(!f && ((arg[0]=='.' && arg[1]=='/') || arg[0]=='/' ||

              is_dos_path(arg))){

        snprintf(filename, sizeof(filename), arg);

        f= fopen(filename, "r");

    }



    if(!f){

        fprintf(stderr, "File for preset '%s' not found\n", arg);

        av_exit(1);

    }



    while(!feof(f)){

        int e= fscanf(f, "%999[^\n]\n", line) - 1;

        if(line[0] == '#' && !e)

            continue;

        e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2;

        if(e){

            fprintf(stderr, "%s: Preset file invalid\n", filename);

            av_exit(1);

        }

        if(!strcmp(tmp, "acodec")){

            opt_audio_codec(tmp2);

        }else if(!strcmp(tmp, "vcodec")){

            opt_video_codec(tmp2);

        }else if(!strcmp(tmp, "scodec")){

            opt_subtitle_codec(tmp2);

        }else if(opt_default(tmp, tmp2) < 0){

            fprintf(stderr, "%s: Invalid option or argument: %s=%s\n", filename, tmp, tmp2);

            av_exit(1);

        }

    }



    fclose(f);



    return 0;

}

static int opt_preset(const char *opt, const char *arg)

{

    FILE *f=NULL;

    char filename[1000], tmp[1000], tmp2[1000], line[1000];

    int i;

    const char *base[3]= { getenv("HOME"),

                           "/usr/local/share",

                           "/usr/share",

                         };



    for(i=!base[0]; i<3 && !f; i++){

        snprintf(filename, sizeof(filename), "%s/%sffmpeg/%s.ffpreset", base[i], i ? "" : ".", arg);

        f= fopen(filename, "r");

        if(!f){

            char *codec_name= *opt == 'v' ? video_codec_name :

                              *opt == 'a' ? audio_codec_name :

                                            subtitle_codec_name;

            snprintf(filename, sizeof(filename), "%s/%sffmpeg/%s-%s.ffpreset", base[i],  i ? "" : ".", codec_name, arg);

            f= fopen(filename, "r");

        }

    }

    if(!f && ((arg[0]=='.' && arg[1]=='/') || arg[0]=='/' ||

              is_dos_path(arg))){

        snprintf(filename, sizeof(filename), arg);

        f= fopen(filename, "r");

    }



    if(!f){

        fprintf(stderr, "File for preset '%s' not found\n", arg);

        av_exit(1);

    }



    while(!feof(f)){

        int e= fscanf(f, "%999[^\n]\n", line) - 1;

        if(line[0] == '#' && !e)

            continue;

        e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2;

        if(e){

            fprintf(stderr, "%s: Preset file invalid\n", filename);

            av_exit(1);

        }

        if(!strcmp(tmp, "acodec")){

            opt_audio_codec(tmp2);

        }else if(!strcmp(tmp, "vcodec")){

            opt_video_codec(tmp2);

        }else if(!strcmp(tmp, "scodec")){

            opt_subtitle_codec(tmp2);

        }else if(opt_default(tmp, tmp2) < 0){

            fprintf(stderr, "%s: Invalid option or argument: %s=%s\n", filename, tmp, tmp2);

            av_exit(1);

        }

    }



    fclose(f);



    return 0;

}

static int FUNC_0(const char *VAR_0, const char *VAR_1)

{

    FILE *f=NULL;

    char VAR_2[1000], VAR_3[1000], VAR_4[1000], VAR_5[1000];

    int VAR_6;

    const char *VAR_7[3]= { getenv("HOME"),

                           "/usr/local/share",

                           "/usr/share",

                         };



    for(VAR_6=!VAR_7[0]; VAR_6<3 && !f; VAR_6++){

        snprintf(VAR_2, sizeof(VAR_2), "%s/%sffmpeg/%s.ffpreset", VAR_7[VAR_6], VAR_6 ? "" : ".", VAR_1);

        f= fopen(VAR_2, "r");

        if(!f){

            char *codec_name= *VAR_0 == 'v' ? video_codec_name :

                              *VAR_0 == 'a' ? audio_codec_name :

                                            subtitle_codec_name;

            snprintf(VAR_2, sizeof(VAR_2), "%s/%sffmpeg/%s-%s.ffpreset", VAR_7[VAR_6],  VAR_6 ? "" : ".", codec_name, VAR_1);

            f= fopen(VAR_2, "r");

        }

    }

    if(!f && ((VAR_1[0]=='.' && VAR_1[1]=='/') || VAR_1[0]=='/' ||

              is_dos_path(VAR_1))){

        snprintf(VAR_2, sizeof(VAR_2), VAR_1);

        f= fopen(VAR_2, "r");

    }



    if(!f){

        fprintf(stderr, "File for preset '%s' not found\n", VAR_1);

        av_exit(1);

    }



    while(!feof(f)){

        int VAR_8= fscanf(f, "%999[^\n]\n", VAR_5) - 1;

        if(VAR_5[0] == '#' && !VAR_8)

            continue;

        VAR_8|= sscanf(VAR_5, "%999[^=]=%999[^\n]\n", VAR_3, VAR_4) - 2;

        if(VAR_8){

            fprintf(stderr, "%s: Preset file invalid\n", VAR_2);

            av_exit(1);

        }

        if(!strcmp(VAR_3, "acodec")){

            opt_audio_codec(VAR_4);

        }else if(!strcmp(VAR_3, "vcodec")){

            opt_video_codec(VAR_4);

        }else if(!strcmp(VAR_3, "scodec")){

            opt_subtitle_codec(VAR_4);

        }else if(opt_default(VAR_3, VAR_4) < 0){

            fprintf(stderr, "%s: Invalid option or argument: %s=%s\n", VAR_2, VAR_3, VAR_4);

            av_exit(1);

        }

    }



    fclose(f);



    return 0;

}

static int FUNC_0(const char *VAR_0, const char *VAR_1)
{ FILE *f=NULL; char VAR_2[1000], VAR_3[1000], VAR_4[1000], VAR_5[1000]; int VAR_6; const char *VAR_7[3]= { getenv("HOME"), "/usr/local/share",
"/usr/share",
}; for(VAR_6=!VAR_7[0]; VAR_6<3 && !f; VAR_6++){ snprintf(VAR_2, sizeof(VAR_2), "%s/%sffmpeg/%s.ffpreset", VAR_7[VAR_6], VAR_6 ? "" : ".", VAR_1); f= fopen(VAR_2, "r"); if(!f){ char *codec_name= *VAR_0 == 'v' ? video_codec_name :
*VAR_0 == 'a' ? audio_codec_name :
subtitle_codec_name; snprintf(VAR_2, sizeof(VAR_2), "%s/%sffmpeg/%s-%s.ffpreset", VAR_7[VAR_6],  VAR_6 ? "" : ".", codec_name, VAR_1); f= fopen(VAR_2, "r"); } } if(!f && ((VAR_1[0]=='.' && VAR_1[1]=='/') || VAR_1[0]=='/' ||
is_dos_path(VAR_1))){ snprintf(VAR_2, sizeof(VAR_2), VAR_1); f= fopen(VAR_2, "r"); } if(!f){ fprintf(stderr, "File for preset '%s' not found\n", VAR_1); av_exit(1); } while(!feof(f)){ int VAR_8= fscanf(f, "%999[^\n]\n", VAR_5) - 1; if(VAR_5[0] == '#' && !VAR_8)
continue; VAR_8|= sscanf(VAR_5, "%999[^=]=%999[^\n]\n", VAR_3, VAR_4) - 2; if(VAR_8){ fprintf(stderr, "%s: Preset file invalid\n", VAR_2); av_exit(1); } if(!strcmp(VAR_3, "acodec")){ opt_audio_codec(VAR_4); }else if(!strcmp(VAR_3, "vcodec")){ opt_video_codec(VAR_4); }else if(!strcmp(VAR_3, "scodec")){ opt_subtitle_codec(VAR_4); }else if(opt_default(VAR_3, VAR_4) < 0){ fprintf(stderr, "%s: Invalid option or argument: %s=%s\n", VAR_2, VAR_3, VAR_4); av_exit(1); } } fclose(f); return 0; }