mirror of https://github.com/mpv-player/mpv
m_option: drop support for -del for list options
5f74ed5828
deprecated this many years ago.
The utility is questionable at best given that -remove exists and is
more natural to use. Free up some code and drop it.
This commit is contained in:
parent
d72c86f95c
commit
b56e63e2a9
|
@ -109,6 +109,7 @@ Interface changes
|
||||||
- rename `--play-dir` to `--play-direction`
|
- rename `--play-dir` to `--play-direction`
|
||||||
- `--js-memory-report` is now used for enabling memory reporting for javascript
|
- `--js-memory-report` is now used for enabling memory reporting for javascript
|
||||||
scripts
|
scripts
|
||||||
|
- drop support for `-del` syntax for list options
|
||||||
--- mpv 0.36.0 ---
|
--- mpv 0.36.0 ---
|
||||||
- add `--target-contrast`
|
- add `--target-contrast`
|
||||||
- Target luminance value is now also applied when ICC profile is used.
|
- Target luminance value is now also applied when ICC profile is used.
|
||||||
|
|
|
@ -20,7 +20,7 @@ syntax is:
|
||||||
workaround deprecated mpv filters.
|
workaround deprecated mpv filters.
|
||||||
|
|
||||||
See ``--vf`` group of options for info on how ``--af-add``, ``--af-pre``,
|
See ``--vf`` group of options for info on how ``--af-add``, ``--af-pre``,
|
||||||
``--af-del``, ``--af-clr``, and possibly others work.
|
``--af-clr``, and possibly others work.
|
||||||
|
|
||||||
Available filters are:
|
Available filters are:
|
||||||
|
|
||||||
|
|
|
@ -539,7 +539,6 @@ Suffix Meaning
|
||||||
-pre Prepend 1 or more items (same syntax as -set)
|
-pre Prepend 1 or more items (same syntax as -set)
|
||||||
-clr Clear the option (remove all items)
|
-clr Clear the option (remove all items)
|
||||||
-remove Delete item if present (does not interpret escapes)
|
-remove Delete item if present (does not interpret escapes)
|
||||||
-del Delete 1 or more items by integer index (deprecated)
|
|
||||||
-toggle Append an item, or remove if if it already exists (no escapes)
|
-toggle Append an item, or remove if if it already exists (no escapes)
|
||||||
============= ===============================================
|
============= ===============================================
|
||||||
|
|
||||||
|
@ -590,7 +589,6 @@ Suffix Meaning
|
||||||
-pre Prepend 1 or more filters (same syntax as -set)
|
-pre Prepend 1 or more filters (same syntax as -set)
|
||||||
-clr Clear the option (remove all filters)
|
-clr Clear the option (remove all filters)
|
||||||
-remove Delete filter if present
|
-remove Delete filter if present
|
||||||
-del Delete 1 or more filters by integer index or filter label (deprecated)
|
|
||||||
-toggle Append a filter, or remove if if it already exists
|
-toggle Append a filter, or remove if if it already exists
|
||||||
-help Pseudo operation that prints a help text to the terminal
|
-help Pseudo operation that prints a help text to the terminal
|
||||||
============= ===============================================
|
============= ===============================================
|
||||||
|
|
|
@ -1119,9 +1119,9 @@ Video
|
||||||
``--vf=<filter1[=parameter1:parameter2:...],filter2,...>``
|
``--vf=<filter1[=parameter1:parameter2:...],filter2,...>``
|
||||||
Specify a list of video filters to apply to the video stream. See
|
Specify a list of video filters to apply to the video stream. See
|
||||||
`VIDEO FILTERS`_ for details and descriptions of the available filters.
|
`VIDEO FILTERS`_ for details and descriptions of the available filters.
|
||||||
The option variants ``--vf-add``, ``--vf-pre``, ``--vf-del`` and
|
The option variants ``--vf-add``, ``--vf-pre``, and ``--vf-clr`` exist
|
||||||
``--vf-clr`` exist to modify a previously specified list, but you
|
to modify a previously specified list, but you should not need these for
|
||||||
should not need these for typical use.
|
typical use.
|
||||||
|
|
||||||
``--untimed``
|
``--untimed``
|
||||||
Do not sleep when outputting video frames. Useful for benchmarks when used
|
Do not sleep when outputting video frames. Useful for benchmarks when used
|
||||||
|
@ -1936,9 +1936,9 @@ Audio
|
||||||
``--af=<filter1[=parameter1:parameter2:...],filter2,...>``
|
``--af=<filter1[=parameter1:parameter2:...],filter2,...>``
|
||||||
Specify a list of audio filters to apply to the audio stream. See
|
Specify a list of audio filters to apply to the audio stream. See
|
||||||
`AUDIO FILTERS`_ for details and descriptions of the available filters.
|
`AUDIO FILTERS`_ for details and descriptions of the available filters.
|
||||||
The option variants ``--af-add``, ``--af-pre``, ``--af-del`` and
|
The option variants ``--af-add``, ``--af-pre``, and ``--af-clr`` exist
|
||||||
``--af-clr`` exist to modify a previously specified list, but you
|
to modify a previously specified list, but you should not need these for
|
||||||
should not need these for typical use.
|
typical use.
|
||||||
|
|
||||||
``--audio-spdif=<codecs>``
|
``--audio-spdif=<codecs>``
|
||||||
List of codecs for which compressed audio passthrough should be used. This
|
List of codecs for which compressed audio passthrough should be used. This
|
||||||
|
|
|
@ -108,11 +108,6 @@ filter list.
|
||||||
from the list if it was present. Matching of filters works as described in
|
from the list if it was present. Matching of filters works as described in
|
||||||
``--vf-remove``.
|
``--vf-remove``.
|
||||||
|
|
||||||
``--vf-del=filter``
|
|
||||||
Sort of like ``--vf-remove``, but also accepts an index number. Index
|
|
||||||
numbers start at 0, negative numbers address the end of the list (-1 is the
|
|
||||||
last). Deprecated.
|
|
||||||
|
|
||||||
``--vf-clr``
|
``--vf-clr``
|
||||||
Completely empties the filter list.
|
Completely empties the filter list.
|
||||||
|
|
||||||
|
|
|
@ -1297,11 +1297,10 @@ const m_option_type_t m_option_type_string = {
|
||||||
#define OP_NONE 0
|
#define OP_NONE 0
|
||||||
#define OP_ADD 1
|
#define OP_ADD 1
|
||||||
#define OP_PRE 2
|
#define OP_PRE 2
|
||||||
#define OP_DEL 3
|
#define OP_CLR 3
|
||||||
#define OP_CLR 4
|
#define OP_TOGGLE 4
|
||||||
#define OP_TOGGLE 5
|
#define OP_APPEND 5
|
||||||
#define OP_APPEND 6
|
#define OP_REMOVE 6
|
||||||
#define OP_REMOVE 7
|
|
||||||
|
|
||||||
static void free_str_list(void *dst)
|
static void free_str_list(void *dst)
|
||||||
{
|
{
|
||||||
|
@ -1343,55 +1342,6 @@ static int str_list_add(char **add, int n, void *dst, int pre)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int str_list_del(struct mp_log *log, char **del, int n, void *dst)
|
|
||||||
{
|
|
||||||
char **lst, *ep;
|
|
||||||
int i, ln, s;
|
|
||||||
long idx;
|
|
||||||
|
|
||||||
lst = VAL(dst);
|
|
||||||
|
|
||||||
for (ln = 0; lst && lst[ln]; ln++)
|
|
||||||
/**/;
|
|
||||||
s = ln;
|
|
||||||
|
|
||||||
for (i = 0; del[i] != NULL; i++) {
|
|
||||||
idx = strtol(del[i], &ep, 0);
|
|
||||||
if (*ep) {
|
|
||||||
mp_err(log, "Invalid index: %s\n", del[i]);
|
|
||||||
talloc_free(del[i]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
talloc_free(del[i]);
|
|
||||||
if (idx < 0 || idx >= ln) {
|
|
||||||
mp_err(log, "Index %ld is out of range.\n", idx);
|
|
||||||
continue;
|
|
||||||
} else if (!lst[idx])
|
|
||||||
continue;
|
|
||||||
talloc_free(lst[idx]);
|
|
||||||
lst[idx] = NULL;
|
|
||||||
s--;
|
|
||||||
}
|
|
||||||
talloc_free(del);
|
|
||||||
|
|
||||||
if (s == 0) {
|
|
||||||
talloc_free(lst);
|
|
||||||
VAL(dst) = NULL;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't bother shrinking the list allocation
|
|
||||||
for (i = 0, n = 0; i < ln; i++) {
|
|
||||||
if (!lst[i])
|
|
||||||
continue;
|
|
||||||
lst[n] = lst[i];
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
lst[s] = NULL;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct bstr get_nextsep(struct bstr *ptr, char sep, bool modify)
|
static struct bstr get_nextsep(struct bstr *ptr, char sep, bool modify)
|
||||||
{
|
{
|
||||||
struct bstr str = *ptr;
|
struct bstr str = *ptr;
|
||||||
|
@ -1438,11 +1388,6 @@ static int parse_str_list_impl(struct mp_log *log, const m_option_t *opt,
|
||||||
multi = false;
|
multi = false;
|
||||||
} else if (bstr_endswith0(name, "-pre")) {
|
} else if (bstr_endswith0(name, "-pre")) {
|
||||||
op = OP_PRE;
|
op = OP_PRE;
|
||||||
} else if (bstr_endswith0(name, "-del")) {
|
|
||||||
op = OP_DEL;
|
|
||||||
mp_warn(log, "Option %.*s: -del is deprecated! "
|
|
||||||
"Use -remove (removes by content instead of by index).\n",
|
|
||||||
BSTR_P(name));
|
|
||||||
} else if (bstr_endswith0(name, "-clr")) {
|
} else if (bstr_endswith0(name, "-clr")) {
|
||||||
op = OP_CLR;
|
op = OP_CLR;
|
||||||
} else if (bstr_endswith0(name, "-set")) {
|
} else if (bstr_endswith0(name, "-set")) {
|
||||||
|
@ -1530,8 +1475,6 @@ static int parse_str_list_impl(struct mp_log *log, const m_option_t *opt,
|
||||||
return str_list_add(res, n, dst, 0);
|
return str_list_add(res, n, dst, 0);
|
||||||
case OP_PRE:
|
case OP_PRE:
|
||||||
return str_list_add(res, n, dst, 1);
|
return str_list_add(res, n, dst, 1);
|
||||||
case OP_DEL:
|
|
||||||
return str_list_del(log, res, n, dst);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VAL(dst))
|
if (VAL(dst))
|
||||||
|
@ -3337,8 +3280,7 @@ done: ;
|
||||||
// Parse a single entry for -vf-del (return 0 if not applicable)
|
// Parse a single entry for -vf-del (return 0 if not applicable)
|
||||||
// mark_del is bounded by the number of items in dst
|
// mark_del is bounded by the number of items in dst
|
||||||
static int parse_obj_settings_del(struct mp_log *log, struct bstr opt_name,
|
static int parse_obj_settings_del(struct mp_log *log, struct bstr opt_name,
|
||||||
struct bstr *param, int op,
|
struct bstr *param, void *dst, bool *mark_del)
|
||||||
void *dst, bool *mark_del)
|
|
||||||
{
|
{
|
||||||
bstr s = *param;
|
bstr s = *param;
|
||||||
if (bstr_eatstart0(&s, "@")) {
|
if (bstr_eatstart0(&s, "@")) {
|
||||||
|
@ -3364,30 +3306,7 @@ static int parse_obj_settings_del(struct mp_log *log, struct bstr opt_name,
|
||||||
*param = s;
|
*param = s;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op == OP_REMOVE)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bstr rest;
|
|
||||||
long long id = bstrtoll(s, &rest, 0);
|
|
||||||
if (rest.len == s.len)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (dst) {
|
|
||||||
int num = obj_settings_list_num_items(VAL(dst));
|
|
||||||
if (id < 0)
|
|
||||||
id = num + id;
|
|
||||||
|
|
||||||
if (id >= 0 && id < num) {
|
|
||||||
mark_del[id] = true;
|
|
||||||
} else {
|
|
||||||
mp_warn(log, "Option %.*s: Index %lld is out of range.\n",
|
|
||||||
BSTR_P(opt_name), id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*param = rest;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
|
static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
|
||||||
|
@ -3409,11 +3328,6 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
|
||||||
op = OP_NONE;
|
op = OP_NONE;
|
||||||
} else if (bstr_endswith0(name, "-pre")) {
|
} else if (bstr_endswith0(name, "-pre")) {
|
||||||
op = OP_PRE;
|
op = OP_PRE;
|
||||||
} else if (bstr_endswith0(name, "-del")) {
|
|
||||||
op = OP_DEL;
|
|
||||||
mp_warn(log, "Option %.*s: -del is deprecated! "
|
|
||||||
"Use -remove (removes by content instead of by index).\n",
|
|
||||||
BSTR_P(name));
|
|
||||||
} else if (bstr_endswith0(name, "-remove")) {
|
} else if (bstr_endswith0(name, "-remove")) {
|
||||||
op = OP_REMOVE;
|
op = OP_REMOVE;
|
||||||
} else if (bstr_endswith0(name, "-clr")) {
|
} else if (bstr_endswith0(name, "-clr")) {
|
||||||
|
@ -3477,7 +3391,7 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
|
||||||
if (dst)
|
if (dst)
|
||||||
free_obj_settings_list(dst);
|
free_obj_settings_list(dst);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (op == OP_DEL || op == OP_REMOVE) {
|
} else if (op == OP_REMOVE) {
|
||||||
mark_del = talloc_zero_array(NULL, bool, num_items + 1);
|
mark_del = talloc_zero_array(NULL, bool, num_items + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3486,8 +3400,8 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
|
||||||
|
|
||||||
while (param.len > 0) {
|
while (param.len > 0) {
|
||||||
int r = 0;
|
int r = 0;
|
||||||
if (op == OP_DEL || op == OP_REMOVE)
|
if (op == OP_REMOVE)
|
||||||
r = parse_obj_settings_del(log, name, ¶m, op, dst, mark_del);
|
r = parse_obj_settings_del(log, name, ¶m, dst, mark_del);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
r = parse_obj_settings(log, name, op, ¶m, ol, dst ? &res : NULL);
|
r = parse_obj_settings(log, name, op, ¶m, ol, dst ? &res : NULL);
|
||||||
}
|
}
|
||||||
|
@ -3574,20 +3488,16 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
talloc_free(res);
|
talloc_free(res);
|
||||||
} else if (op == OP_DEL || op == OP_REMOVE) {
|
} else if (op == OP_REMOVE) {
|
||||||
for (int n = num_items - 1; n >= 0; n--) {
|
for (int n = num_items - 1; n >= 0; n--) {
|
||||||
if (mark_del[n])
|
if (mark_del[n])
|
||||||
obj_settings_list_del_at(&list, n);
|
obj_settings_list_del_at(&list, n);
|
||||||
}
|
}
|
||||||
for (int n = 0; res && res[n].name; n++) {
|
for (int n = 0; res && res[n].name; n++) {
|
||||||
int found = obj_settings_find_by_content(list, &res[n]);
|
int found = obj_settings_find_by_content(list, &res[n]);
|
||||||
if (found < 0) {
|
if (found >= 0)
|
||||||
if (op == OP_DEL)
|
|
||||||
mp_warn(log, "Option %.*s: Item not found\n", BSTR_P(name));
|
|
||||||
} else {
|
|
||||||
obj_settings_list_del_at(&list, found);
|
obj_settings_list_del_at(&list, found);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
free_obj_settings_list(&res);
|
free_obj_settings_list(&res);
|
||||||
} else {
|
} else {
|
||||||
assert(op == OP_NONE);
|
assert(op == OP_NONE);
|
||||||
|
|
Loading…
Reference in New Issue