return 0;
}
- #if LIBAVUTIL_VERSION_MAJOR < 53
+int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_flags)
+{
+ void *target_obj;
+ const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
+
+ if (!o || !target_obj)
+ return AVERROR_OPTION_NOT_FOUND;
+ if (o->type != AV_OPT_TYPE_IMAGE_SIZE) {
+ av_log(obj, AV_LOG_ERROR,
+ "The value set by option '%s' is not an image size.\n", o->name);
+ return AVERROR(EINVAL);
+ }
+ if (w<0 || h<0) {
+ av_log(obj, AV_LOG_ERROR,
+ "Invalid negative size value %dx%d for size '%s'\n", w, h, o->name);
+ return AVERROR(EINVAL);
+ }
+ *(int *)(((uint8_t *)target_obj) + o->offset) = w;
+ *(int *)(((uint8_t *)target_obj+sizeof(int)) + o->offset) = h;
+ return 0;
+}
+
+int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int search_flags)
+{
+ void *target_obj;
+ const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
+
+ if (!o || !target_obj)
+ return AVERROR_OPTION_NOT_FOUND;
+ if (o->type != AV_OPT_TYPE_VIDEO_RATE) {
+ av_log(obj, AV_LOG_ERROR,
+ "The value set by option '%s' is not a video rate.\n", o->name);
+ return AVERROR(EINVAL);
+ }
+ if (val.num <= 0 || val.den <= 0)
+ return AVERROR(EINVAL);
+ return set_number(obj, name, val.num, val.den, 1, search_flags);
+}
+
+static int set_format(void *obj, const char *name, int fmt, int search_flags,
+ enum AVOptionType type, const char *desc, int nb_fmts)
+{
+ void *target_obj;
+ const AVOption *o = av_opt_find2(obj, name, NULL, 0,
+ search_flags, &target_obj);
+ int min, max;
+ const AVClass *class = *(AVClass **)obj;
+
+ if (!o || !target_obj)
+ return AVERROR_OPTION_NOT_FOUND;
+ if (o->type != type) {
+ av_log(obj, AV_LOG_ERROR,
+ "The value set by option '%s' is not a %s format", name, desc);
+ return AVERROR(EINVAL);
+ }
+
++#if LIBAVUTIL_VERSION_MAJOR < 54
+ if (class->version && class->version < AV_VERSION_INT(52, 11, 100)) {
+ min = -1;
+ max = nb_fmts-1;
+ } else
+#endif
+ {
+ min = FFMIN(o->min, -1);
+ max = FFMAX(o->max, nb_fmts-1);
+ }
+ if (fmt < min || fmt > max) {
+ av_log(obj, AV_LOG_ERROR,
+ "Value %d for parameter '%s' out of %s format range [%d - %d]\n",
+ fmt, name, desc, min, max);
+ return AVERROR(ERANGE);
+ }
+ *(int *)(((uint8_t *)target_obj) + o->offset) = fmt;
+ return 0;
+}
+
+int av_opt_set_pixel_fmt(void *obj, const char *name, enum AVPixelFormat fmt, int search_flags)
+{
+ return set_format(obj, name, fmt, search_flags, AV_OPT_TYPE_PIXEL_FMT, "pixel", AV_PIX_FMT_NB);
+}
+
+int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags)
+{
+ return set_format(obj, name, fmt, search_flags, AV_OPT_TYPE_SAMPLE_FMT, "sample", AV_SAMPLE_FMT_NB);
+}
+
+int av_opt_set_channel_layout(void *obj, const char *name, int64_t cl, int search_flags)
+{
+ void *target_obj;
+ const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
+
+ if (!o || !target_obj)
+ return AVERROR_OPTION_NOT_FOUND;
+ if (o->type != AV_OPT_TYPE_CHANNEL_LAYOUT) {
+ av_log(obj, AV_LOG_ERROR,
+ "The value set by option '%s' is not a channel layout.\n", o->name);
+ return AVERROR(EINVAL);
+ }
+ *(int *)(((int64_t *)target_obj) + o->offset) = cl;
+ 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_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
{
void *dst, *target_obj;
case AV_OPT_TYPE_RATIONAL: {
AVRational val;
val = av_d2q(opt->default_val.dbl, INT_MAX);
- av_opt_set_q(s, opt->name, val, 0);
+ write_number(s, opt, dst, 1, val.den, val.num);
}
break;
+ case AV_OPT_TYPE_COLOR:
+ set_string_color(s, opt, opt->default_val.str, dst);
+ break;
case AV_OPT_TYPE_STRING:
- av_opt_set(s, opt->name, opt->default_val.str, 0);
+ set_string(s, opt, opt->default_val.str, dst);
+ break;
+ case AV_OPT_TYPE_IMAGE_SIZE:
+ set_string_image_size(s, opt, opt->default_val.str, dst);
+ break;
+ case AV_OPT_TYPE_VIDEO_RATE:
+ set_string_video_rate(s, opt, opt->default_val.str, dst);
+ break;
+ case AV_OPT_TYPE_PIXEL_FMT:
- #if LIBAVUTIL_VERSION_MAJOR < 53
++#if LIBAVUTIL_VERSION_MAJOR < 54
+ if (class->version && class->version < AV_VERSION_INT(52, 10, 100))
+ av_opt_set(s, opt->name, opt->default_val.str, 0);
+ else
+#endif
+ write_number(s, opt, dst, 1, 1, opt->default_val.i64);
+ break;
+ case AV_OPT_TYPE_SAMPLE_FMT:
- #if LIBAVUTIL_VERSION_MAJOR < 53
++#if LIBAVUTIL_VERSION_MAJOR < 54
+ if (class->version && class->version < AV_VERSION_INT(52, 10, 100))
+ av_opt_set(s, opt->name, opt->default_val.str, 0);
+ else
+#endif
+ write_number(s, opt, dst, 1, 1, opt->default_val.i64);
break;
case AV_OPT_TYPE_BINARY:
/* Cannot set default for binary */
* @{
*/
- #define LIBAVUTIL_VERSION_MAJOR 52
- #define LIBAVUTIL_VERSION_MINOR 58
-#define LIBAVUTIL_VERSION_MAJOR 53
-#define LIBAVUTIL_VERSION_MINOR 0
-#define LIBAVUTIL_VERSION_MICRO 0
++#define LIBAVUTIL_VERSION_MAJOR 53
++#define LIBAVUTIL_VERSION_MINOR 0
+#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
* @{
*/
- #define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 53)
+#ifndef FF_API_GET_BITS_PER_SAMPLE_FMT
- #define FF_API_FIND_OPT (LIBAVUTIL_VERSION_MAJOR < 53)
++#define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_FIND_OPT
- #define FF_API_OLD_AVOPTIONS (LIBAVUTIL_VERSION_MAJOR < 53)
++#define FF_API_FIND_OPT (LIBAVUTIL_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_OLD_AVOPTIONS
++#define FF_API_OLD_AVOPTIONS (LIBAVUTIL_VERSION_MAJOR < 54)
+#endif
#ifndef FF_API_PIX_FMT
- #define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 53)
+ #define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_CONTEXT_SIZE
- #define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 53)
+ #define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_PIX_FMT_DESC
- #define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 53)
+ #define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_AV_REVERSE
- #define FF_API_AV_REVERSE (LIBAVUTIL_VERSION_MAJOR < 53)
+ #define FF_API_AV_REVERSE (LIBAVUTIL_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_AUDIOCONVERT
- #define FF_API_AUDIOCONVERT (LIBAVUTIL_VERSION_MAJOR < 53)
+ #define FF_API_AUDIOCONVERT (LIBAVUTIL_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_CPU_FLAG_MMX2
- #define FF_API_CPU_FLAG_MMX2 (LIBAVUTIL_VERSION_MAJOR < 53)
+ #define FF_API_CPU_FLAG_MMX2 (LIBAVUTIL_VERSION_MAJOR < 54)
#endif
- #define FF_API_SAMPLES_UTILS_RETURN_ZERO (LIBAVUTIL_VERSION_MAJOR < 53)
+#ifndef FF_API_SAMPLES_UTILS_RETURN_ZERO
++#define FF_API_SAMPLES_UTILS_RETURN_ZERO (LIBAVUTIL_VERSION_MAJOR < 54)
+#endif
#ifndef FF_API_LLS_PRIVATE
- #define FF_API_LLS_PRIVATE (LIBAVUTIL_VERSION_MAJOR < 53)
+ #define FF_API_LLS_PRIVATE (LIBAVUTIL_VERSION_MAJOR < 54)
#endif
- #define FF_API_LLS1 (LIBAVUTIL_VERSION_MAJOR < 53)
+#ifndef FF_API_LLS1
++#define FF_API_LLS1 (LIBAVUTIL_VERSION_MAJOR < 54)
+#endif
#ifndef FF_API_AVFRAME_LAVC
- #define FF_API_AVFRAME_LAVC (LIBAVUTIL_VERSION_MAJOR < 53)
+ #define FF_API_AVFRAME_LAVC (LIBAVUTIL_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_VDPAU
- #define FF_API_VDPAU (LIBAVUTIL_VERSION_MAJOR < 53)
+ #define FF_API_VDPAU (LIBAVUTIL_VERSION_MAJOR < 54)
#endif
- #define FF_API_GET_CHANNEL_LAYOUT_COMPAT (LIBAVUTIL_VERSION_MAJOR < 53)
+#ifndef FF_API_GET_CHANNEL_LAYOUT_COMPAT
- #define FF_API_OLD_OPENCL (LIBAVUTIL_VERSION_MAJOR < 53)
++#define FF_API_GET_CHANNEL_LAYOUT_COMPAT (LIBAVUTIL_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_OLD_OPENCL
++#define FF_API_OLD_OPENCL (LIBAVUTIL_VERSION_MAJOR < 54)
+#endif
#ifndef FF_API_XVMC
- #define FF_API_XVMC (LIBAVUTIL_VERSION_MAJOR < 53)
+ #define FF_API_XVMC (LIBAVUTIL_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_INTFLOAT
- #define FF_API_INTFLOAT (LIBAVUTIL_VERSION_MAJOR < 53)
+ #define FF_API_INTFLOAT (LIBAVUTIL_VERSION_MAJOR < 54)
#endif
/**