mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-05-28 07:29:14 +00:00
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
This commit is contained in:
parent
58b4e5407d
commit
6e872935db
4 changed files with 58 additions and 45 deletions
30
cmdutils.c
30
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue