aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2010-11-04 23:07:04 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2010-11-04 23:07:04 +0000
commit6e872935db95638edd73093d299608076eed7d9c (patch)
treedb3c35521bf0c3fc267c88d07c37a55dfaf35646 /ffmpeg.c
parent58b4e5407d05164f1874ffb32612237253411093 (diff)
downloadffmpeg-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.c29
1 files changed, 4 insertions, 25 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 46121c0a5a..8b1878b0a1 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -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);
}