|
|
|
@ -34,28 +34,6 @@ |
|
|
|
|
#include "log.h" |
|
|
|
|
#include "mathematics.h" |
|
|
|
|
|
|
|
|
|
#if FF_API_FIND_OPT |
|
|
|
|
//FIXME order them and do a bin search
|
|
|
|
|
const AVOption *av_find_opt(void *v, const char *name, const char *unit, int mask, int flags) |
|
|
|
|
{ |
|
|
|
|
AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass
|
|
|
|
|
const AVOption *o= c->option; |
|
|
|
|
|
|
|
|
|
for (; o && o->name; o++) { |
|
|
|
|
if (!strcmp(o->name, name) && (!unit || (o->unit && !strcmp(o->unit, unit))) && (o->flags & mask) == flags) |
|
|
|
|
return o; |
|
|
|
|
} |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#if FF_API_OLD_AVOPTIONS |
|
|
|
|
const AVOption *av_next_option(void *obj, const AVOption *last) |
|
|
|
|
{ |
|
|
|
|
return av_opt_next(obj, last); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
const AVOption *av_opt_next(void *obj, const AVOption *last) |
|
|
|
|
{ |
|
|
|
|
AVClass *class = *(AVClass**)obj; |
|
|
|
@ -221,16 +199,6 @@ static int set_string_number(void *obj, const AVOption *o, const char *val, void |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if FF_API_OLD_AVOPTIONS |
|
|
|
|
int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out) |
|
|
|
|
{ |
|
|
|
|
const AVOption *o = av_opt_find(obj, name, NULL, 0, 0); |
|
|
|
|
if (o_out) |
|
|
|
|
*o_out = o; |
|
|
|
|
return av_opt_set(obj, name, val, 0); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
int av_opt_set(void *obj, const char *name, const char *val, int search_flags) |
|
|
|
|
{ |
|
|
|
|
void *dst, *target_obj; |
|
|
|
@ -284,32 +252,6 @@ static int set_number(void *obj, const char *name, double num, int den, int64_t |
|
|
|
|
return write_number(obj, o, dst, num, den, intnum); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if FF_API_OLD_AVOPTIONS |
|
|
|
|
const AVOption *av_set_double(void *obj, const char *name, double n) |
|
|
|
|
{ |
|
|
|
|
const AVOption *o = av_opt_find(obj, name, NULL, 0, 0); |
|
|
|
|
if (set_number(obj, name, n, 1, 1, 0) < 0) |
|
|
|
|
return NULL; |
|
|
|
|
return o; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const AVOption *av_set_q(void *obj, const char *name, AVRational n) |
|
|
|
|
{ |
|
|
|
|
const AVOption *o = av_opt_find(obj, name, NULL, 0, 0); |
|
|
|
|
if (set_number(obj, name, n.num, n.den, 1, 0) < 0) |
|
|
|
|
return NULL; |
|
|
|
|
return o; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const AVOption *av_set_int(void *obj, const char *name, int64_t n) |
|
|
|
|
{ |
|
|
|
|
const AVOption *o = av_opt_find(obj, name, NULL, 0, 0); |
|
|
|
|
if (set_number(obj, name, 1, 1, n, 0) < 0) |
|
|
|
|
return NULL; |
|
|
|
|
return o; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags) |
|
|
|
|
{ |
|
|
|
|
return set_number(obj, name, 1, 1, val, search_flags); |
|
|
|
@ -354,46 +296,6 @@ int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if FF_API_OLD_AVOPTIONS |
|
|
|
|
/**
|
|
|
|
|
* |
|
|
|
|
* @param buf a buffer which is used for returning non string values as strings, can be NULL |
|
|
|
|
* @param buf_len allocated length in bytes of buf |
|
|
|
|
*/ |
|
|
|
|
const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len) |
|
|
|
|
{ |
|
|
|
|
const AVOption *o = av_opt_find(obj, name, NULL, 0, 0); |
|
|
|
|
void *dst; |
|
|
|
|
uint8_t *bin; |
|
|
|
|
int len, i; |
|
|
|
|
if (!o) |
|
|
|
|
return NULL; |
|
|
|
|
if (o->type != AV_OPT_TYPE_STRING && (!buf || !buf_len)) |
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
dst= ((uint8_t*)obj) + o->offset; |
|
|
|
|
if (o_out) *o_out= o; |
|
|
|
|
|
|
|
|
|
switch (o->type) { |
|
|
|
|
case AV_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break; |
|
|
|
|
case AV_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break; |
|
|
|
|
case AV_OPT_TYPE_INT64: snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break; |
|
|
|
|
case AV_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break; |
|
|
|
|
case AV_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break; |
|
|
|
|
case AV_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break; |
|
|
|
|
case AV_OPT_TYPE_STRING: return *(void**)dst; |
|
|
|
|
case AV_OPT_TYPE_BINARY: |
|
|
|
|
len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *)); |
|
|
|
|
if (len >= (buf_len + 1)/2) return NULL; |
|
|
|
|
bin = *(uint8_t**)dst; |
|
|
|
|
for (i = 0; i < len; i++) snprintf(buf + i*2, 3, "%02X", bin[i]); |
|
|
|
|
break; |
|
|
|
|
default: return NULL; |
|
|
|
|
} |
|
|
|
|
return buf; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) |
|
|
|
|
{ |
|
|
|
|
void *dst, *target_obj; |
|
|
|
@ -459,44 +361,6 @@ error: |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if FF_API_OLD_AVOPTIONS |
|
|
|
|
double av_get_double(void *obj, const char *name, const AVOption **o_out) |
|
|
|
|
{ |
|
|
|
|
int64_t intnum=1; |
|
|
|
|
double num=1; |
|
|
|
|
int den=1; |
|
|
|
|
|
|
|
|
|
if (get_number(obj, name, o_out, &num, &den, &intnum, 0) < 0) |
|
|
|
|
return NAN; |
|
|
|
|
return num*intnum/den; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
AVRational av_get_q(void *obj, const char *name, const AVOption **o_out) |
|
|
|
|
{ |
|
|
|
|
int64_t intnum=1; |
|
|
|
|
double num=1; |
|
|
|
|
int den=1; |
|
|
|
|
|
|
|
|
|
if (get_number(obj, name, o_out, &num, &den, &intnum, 0) < 0) |
|
|
|
|
return (AVRational){0, 0}; |
|
|
|
|
if (num == 1.0 && (int)intnum == intnum) |
|
|
|
|
return (AVRational){intnum, den}; |
|
|
|
|
else |
|
|
|
|
return av_d2q(num*intnum/den, 1<<24); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int64_t av_get_int(void *obj, const char *name, const AVOption **o_out) |
|
|
|
|
{ |
|
|
|
|
int64_t intnum=1; |
|
|
|
|
double num=1; |
|
|
|
|
int den=1; |
|
|
|
|
|
|
|
|
|
if (get_number(obj, name, o_out, &num, &den, &intnum, 0) < 0) |
|
|
|
|
return -1; |
|
|
|
|
return num*intnum/den; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val) |
|
|
|
|
{ |
|
|
|
|
int64_t intnum = 1; |
|
|
|
@ -633,19 +497,8 @@ int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags) |
|
|
|
|
|
|
|
|
|
void av_opt_set_defaults(void *s) |
|
|
|
|
{ |
|
|
|
|
#if FF_API_OLD_AVOPTIONS |
|
|
|
|
av_opt_set_defaults2(s, 0, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void av_opt_set_defaults2(void *s, int mask, int flags) |
|
|
|
|
{ |
|
|
|
|
#endif |
|
|
|
|
const AVOption *opt = NULL; |
|
|
|
|
while ((opt = av_opt_next(s, opt)) != NULL) { |
|
|
|
|
#if FF_API_OLD_AVOPTIONS |
|
|
|
|
if ((opt->flags & mask) != flags) |
|
|
|
|
continue; |
|
|
|
|
#endif |
|
|
|
|
switch (opt->type) { |
|
|
|
|
case AV_OPT_TYPE_CONST: |
|
|
|
|
/* Nothing to be done here */ |
|
|
|
|