mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2026-01-23 23:21:06 +01:00
lavu/opt: add flag to return NULL when applicable in av_opt_get
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
f36baeebc5
commit
0562f95902
3 changed files with 21 additions and 3 deletions
|
|
@ -666,12 +666,20 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
|
|||
case AV_OPT_TYPE_RATIONAL: ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
|
||||
case AV_OPT_TYPE_CONST: ret = snprintf(buf, sizeof(buf), "%f" , o->default_val.dbl);break;
|
||||
case AV_OPT_TYPE_STRING:
|
||||
if (*(uint8_t**)dst)
|
||||
if (*(uint8_t**)dst) {
|
||||
*out_val = av_strdup(*(uint8_t**)dst);
|
||||
else
|
||||
} else if (search_flags & AV_OPT_ALLOW_NULL) {
|
||||
*out_val = NULL;
|
||||
return 0;
|
||||
} else {
|
||||
*out_val = av_strdup("");
|
||||
}
|
||||
return *out_val ? 0 : AVERROR(ENOMEM);
|
||||
case AV_OPT_TYPE_BINARY:
|
||||
if (!*(uint8_t**)dst && (search_flags & AV_OPT_ALLOW_NULL)) {
|
||||
*out_val = NULL;
|
||||
return 0;
|
||||
}
|
||||
len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));
|
||||
if ((uint64_t)len*2 + 1 > INT_MAX)
|
||||
return AVERROR(EINVAL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue