diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-11-04 23:07:04 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-11-04 23:07:04 +0000 |
commit | 6e872935db95638edd73093d299608076eed7d9c (patch) | |
tree | db3c35521bf0c3fc267c88d07c37a55dfaf35646 /ffmpeg.c | |
parent | 58b4e5407d05164f1874ffb32612237253411093 (diff) | |
download | ffmpeg-6e872935db95638edd73093d299608076eed7d9c.tar.gz |
Implement get_preset_file() in cmdutils.h and use it to factorize code
from ffmpeg.c and ffserver.c.
Originally committed as revision 25679 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffmpeg.c')
-rw-r--r-- | ffmpeg.c | 29 |
1 files changed, 4 insertions, 25 deletions
@@ -4030,32 +4030,11 @@ 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("FFMPEG_DATADIR"), - getenv("HOME"), - FFMPEG_DATADIR, - }; - - if (*opt != 'f') { - for(i=0; i<3 && !f; i++){ - if(!base[i]) - continue; - snprintf(filename, sizeof(filename), "%s%s/%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", 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%s/%s-%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", codec_name, arg); - f= fopen(filename, "r"); - } - } - } else { - av_strlcpy(filename, arg, sizeof(filename)); - f= fopen(filename, "r"); - } + char *codec_name = *opt == 'v' ? video_codec_name : + *opt == 'a' ? audio_codec_name : + subtitle_codec_name; - if(!f){ + if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', codec_name))) { fprintf(stderr, "File for preset '%s' not found\n", arg); ffmpeg_exit(1); } |