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 /cmdutils.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 'cmdutils.c')
-rw-r--r-- | cmdutils.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cmdutils.c b/cmdutils.c index 49c6ad574e..681ed4244b 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -748,6 +748,36 @@ int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t reordered_pts, int6 return pts; } +FILE *get_preset_file(char *filename, size_t filename_size, + const char *preset_name, int is_path, const char *codec_name) +{ + FILE *f = NULL; + int i; + const char *base[3]= { getenv("FFMPEG_DATADIR"), + getenv("HOME"), + FFMPEG_DATADIR, + }; + + if (is_path) { + av_strlcpy(filename, preset_name, filename_size); + f = fopen(filename, "r"); + } else { + for (i = 0; i < 3 && !f; i++) { + if (!base[i]) + continue; + snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", preset_name); + f = fopen(filename, "r"); + if (!f && codec_name) { + snprintf(filename, filename_size, + "%s%s/%s-%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", codec_name, preset_name); + f = fopen(filename, "r"); + } + } + } + + return f; +} + #if CONFIG_AVFILTER static int ffsink_init(AVFilterContext *ctx, const char *args, void *opaque) |