From 237cf3786ef7dea60818fc3bc464f72ed4b4d833 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Sat, 5 Sep 2015 18:25:31 +0200 Subject: [PATCH] lavu: Drop old deprecated AVOption API Deprecated in 2011/10 --- libavutil/opt.c | 122 -------------------------------------------- libavutil/opt.h | 56 -------------------- libavutil/version.h | 3 -- 3 files changed, 181 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 22e677576a..8d44e1f42a 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -41,13 +41,6 @@ #include -#if FF_API_OLD_AVOPTIONS -const AVOption *av_next_option(const void *obj, const AVOption *last) -{ - return av_opt_next(obj, last); -} -#endif - const AVOption *av_opt_next(const void *obj, const AVOption *last) { const AVClass *class; @@ -356,16 +349,6 @@ static int set_string_sample_fmt(void *obj, const AVOption *o, const char *val, AV_SAMPLE_FMT_NB, av_get_sample_fmt, "sample format"); } -#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) { int ret = 0; @@ -462,32 +445,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); @@ -627,47 +584,6 @@ int av_opt_set_channel_layout(void *obj, const char *name, int64_t cl, int searc 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, AV_OPT_SEARCH_CHILDREN); - 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_CONST: snprintf(buf, buf_len, "%f" , o->default_val.dbl);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_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags) { void *target_obj; @@ -782,44 +698,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; diff --git a/libavutil/opt.h b/libavutil/opt.h index 72e3a1cea9..9443bf3d6c 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -236,17 +236,6 @@ enum AVOptionType{ AV_OPT_TYPE_DURATION = MKBETAG('D','U','R',' '), AV_OPT_TYPE_COLOR = MKBETAG('C','O','L','R'), AV_OPT_TYPE_CHANNEL_LAYOUT = MKBETAG('C','H','L','A'), -#if FF_API_OLD_AVOPTIONS - FF_OPT_TYPE_FLAGS = 0, - FF_OPT_TYPE_INT, - FF_OPT_TYPE_INT64, - FF_OPT_TYPE_DOUBLE, - FF_OPT_TYPE_FLOAT, - FF_OPT_TYPE_STRING, - FF_OPT_TYPE_RATIONAL, - FF_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length - FF_OPT_TYPE_CONST=128, -#endif }; /** @@ -378,51 +367,6 @@ typedef struct AVOptionRanges { int nb_components; } AVOptionRanges; - -#if FF_API_OLD_AVOPTIONS -/** - * Set the field of obj with the given name to value. - * - * @param[in] obj A struct whose first element is a pointer to an - * AVClass. - * @param[in] name the name of the field to set - * @param[in] val The value to set. If the field is not of a string - * type, then the given string is parsed. - * SI postfixes and some named scalars are supported. - * If the field is of a numeric type, it has to be a numeric or named - * scalar. Behavior with more than one scalar and +- infix operators - * is undefined. - * If the field is of a flags type, it has to be a sequence of numeric - * scalars or named flags separated by '+' or '-'. Prefixing a flag - * with '+' causes it to be set without affecting the other flags; - * similarly, '-' unsets a flag. - * @param[out] o_out if non-NULL put here a pointer to the AVOption - * found - * @param alloc this parameter is currently ignored - * @return 0 if the value has been set, or an AVERROR code in case of - * error: - * AVERROR_OPTION_NOT_FOUND if no matching option exists - * AVERROR(ERANGE) if the value is out of range - * AVERROR(EINVAL) if the value is not valid - * @deprecated use av_opt_set() - */ -attribute_deprecated -int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out); - -attribute_deprecated const AVOption *av_set_double(void *obj, const char *name, double n); -attribute_deprecated const AVOption *av_set_q(void *obj, const char *name, AVRational n); -attribute_deprecated const AVOption *av_set_int(void *obj, const char *name, int64_t n); - -attribute_deprecated -double av_get_double(void *obj, const char *name, const AVOption **o_out); -attribute_deprecated -AVRational av_get_q(void *obj, const char *name, const AVOption **o_out); -attribute_deprecated -int64_t av_get_int(void *obj, const char *name, const AVOption **o_out); -attribute_deprecated const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len); -attribute_deprecated const AVOption *av_next_option(const void *obj, const AVOption *last); -#endif - /** * Show the obj options. * diff --git a/libavutil/version.h b/libavutil/version.h index 55f442002b..2f4d2efc73 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -84,9 +84,6 @@ * @{ */ -#ifndef FF_API_OLD_AVOPTIONS -#define FF_API_OLD_AVOPTIONS (LIBAVUTIL_VERSION_MAJOR < 55) -#endif #ifndef FF_API_VDPAU #define FF_API_VDPAU (LIBAVUTIL_VERSION_MAJOR < 56) #endif