mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
f_lavfi: support setting common filter options like "threads"
AVFilterContext instances support some additional AVOptions over the actual filter. This includes useful options like "threads". We didn't support setting those for the "direct" wrapper (--vf=yadif:threads=1 failed). Change this. It requires setting options on the AVFilterContext directly, except the code for positional parameters still needs to access the actual filter's AVOptions.
This commit is contained in:
@@ -313,7 +313,7 @@ void mp_avdict_print_unset(struct mp_log *log, int msgl, AVDictionary *dict)
|
||||
// to the name of the n-th parameter.
|
||||
static void resolve_positional_arg(void *avobj, char **name)
|
||||
{
|
||||
if (!*name || (*name)[0] != '@')
|
||||
if (!*name || (*name)[0] != '@' || !avobj)
|
||||
return;
|
||||
|
||||
char *end = NULL;
|
||||
@@ -344,12 +344,19 @@ static void resolve_positional_arg(void *avobj, char **name)
|
||||
// Options which fail to set (error or not found) are printed to log.
|
||||
// Returns: >=0 success, <0 failed to set an option
|
||||
int mp_set_avopts(struct mp_log *log, void *avobj, char **kv)
|
||||
{
|
||||
return mp_set_avopts_pos(log, avobj, avobj, kv);
|
||||
}
|
||||
|
||||
// Like mp_set_avopts(), but the posargs argument is used to resolve positional
|
||||
// arguments. If posargs==NULL, positional args are disabled.
|
||||
int mp_set_avopts_pos(struct mp_log *log, void *avobj, void *posargs, char **kv)
|
||||
{
|
||||
int success = 0;
|
||||
for (int n = 0; kv && kv[n * 2]; n++) {
|
||||
char *k = kv[n * 2 + 0];
|
||||
char *v = kv[n * 2 + 1];
|
||||
resolve_positional_arg(avobj, &k);
|
||||
resolve_positional_arg(posargs, &k);
|
||||
int r = av_opt_set(avobj, k, v, AV_OPT_SEARCH_CHILDREN);
|
||||
if (r == AVERROR_OPTION_NOT_FOUND) {
|
||||
mp_err(log, "AVOption '%s' not found.\n", k);
|
||||
|
||||
@@ -47,5 +47,6 @@ const char *mp_codec_from_av_codec_id(int codec_id);
|
||||
void mp_set_avdict(struct AVDictionary **dict, char **kv);
|
||||
void mp_avdict_print_unset(struct mp_log *log, int msgl, struct AVDictionary *d);
|
||||
int mp_set_avopts(struct mp_log *log, void *avobj, char **kv);
|
||||
int mp_set_avopts_pos(struct mp_log *log, void *avobj, void *posargs, char **kv);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user