Commit 3a751eab authored by Paul B Mahol's avatar Paul B Mahol

lavu/opt: add AV_OPT_TYPE_COLOR

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 1ec578c0
...@@ -15,6 +15,9 @@ libavutil: 2012-10-22 ...@@ -15,6 +15,9 @@ libavutil: 2012-10-22
API changes, most recent first: API changes, most recent first:
2013-05-17 - xxxxxxx - lavu 52.33.100 - opt.h
Add AV_OPT_TYPE_COLOR value to AVOptionType enum.
2013-05-13 - xxxxxxx - lavu 52.31.100 - mem.h 2013-05-13 - xxxxxxx - lavu 52.31.100 - mem.h
Add av_dynarray2_add(). Add av_dynarray2_add().
......
...@@ -259,7 +259,7 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) ...@@ -259,7 +259,7 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
if (!val && (o->type != AV_OPT_TYPE_STRING && if (!val && (o->type != AV_OPT_TYPE_STRING &&
o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT && o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT &&
o->type != AV_OPT_TYPE_IMAGE_SIZE && o->type != AV_OPT_TYPE_VIDEO_RATE && o->type != AV_OPT_TYPE_IMAGE_SIZE && o->type != AV_OPT_TYPE_VIDEO_RATE &&
o->type != AV_OPT_TYPE_DURATION)) o->type != AV_OPT_TYPE_DURATION && o->type != AV_OPT_TYPE_COLOR))
return AVERROR(EINVAL); return AVERROR(EINVAL);
dst = ((uint8_t*)target_obj) + o->offset; dst = ((uint8_t*)target_obj) + o->offset;
...@@ -331,6 +331,16 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) ...@@ -331,6 +331,16 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", val); av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", val);
return ret; return ret;
} }
break;
case AV_OPT_TYPE_COLOR:
if (!val) {
return 0;
} else {
ret = av_parse_color(dst, val, -1, obj);
if (ret < 0)
av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as color\n", val);
return ret;
}
} }
av_log(obj, AV_LOG_ERROR, "Invalid option type.\n"); av_log(obj, AV_LOG_ERROR, "Invalid option type.\n");
...@@ -617,6 +627,9 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) ...@@ -617,6 +627,9 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
i64 / 3600000000, (int)((i64 / 60000000) % 60), i64 / 3600000000, (int)((i64 / 60000000) % 60),
(int)((i64 / 1000000) % 60), (int)(i64 % 1000000)); (int)((i64 / 1000000) % 60), (int)(i64 % 1000000));
break; break;
case AV_OPT_TYPE_COLOR:
ret = snprintf(buf, sizeof(buf), "0x%02x%02x%02x%02x", ((int *)dst)[0], ((int *)dst)[1], ((int *)dst)[2], ((int *)dst)[3]);
break;
default: default:
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
...@@ -886,6 +899,9 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, ...@@ -886,6 +899,9 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit,
case AV_OPT_TYPE_DURATION: case AV_OPT_TYPE_DURATION:
av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<duration>"); av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<duration>");
break; break;
case AV_OPT_TYPE_COLOR:
av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<color>");
break;
case AV_OPT_TYPE_CONST: case AV_OPT_TYPE_CONST:
default: default:
av_log(av_log_obj, AV_LOG_INFO, "%-12s ", ""); av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
...@@ -978,6 +994,7 @@ void av_opt_set_defaults2(void *s, int mask, int flags) ...@@ -978,6 +994,7 @@ void av_opt_set_defaults2(void *s, int mask, int flags)
av_opt_set_q(s, opt->name, val, 0); av_opt_set_q(s, opt->name, val, 0);
} }
break; break;
case AV_OPT_TYPE_COLOR:
case AV_OPT_TYPE_STRING: case AV_OPT_TYPE_STRING:
case AV_OPT_TYPE_IMAGE_SIZE: case AV_OPT_TYPE_IMAGE_SIZE:
case AV_OPT_TYPE_VIDEO_RATE: case AV_OPT_TYPE_VIDEO_RATE:
...@@ -1334,6 +1351,7 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch ...@@ -1334,6 +1351,7 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch
case AV_OPT_TYPE_FLOAT: case AV_OPT_TYPE_FLOAT:
case AV_OPT_TYPE_DOUBLE: case AV_OPT_TYPE_DOUBLE:
case AV_OPT_TYPE_DURATION: case AV_OPT_TYPE_DURATION:
case AV_OPT_TYPE_COLOR:
break; break;
case AV_OPT_TYPE_STRING: case AV_OPT_TYPE_STRING:
range->component_min = 0; range->component_min = 0;
...@@ -1400,6 +1418,7 @@ typedef struct TestContext ...@@ -1400,6 +1418,7 @@ typedef struct TestContext
enum AVPixelFormat pix_fmt; enum AVPixelFormat pix_fmt;
enum AVSampleFormat sample_fmt; enum AVSampleFormat sample_fmt;
int64_t duration; int64_t duration;
uint8_t color[4];
} TestContext; } TestContext;
#define OFFSET(x) offsetof(TestContext, x) #define OFFSET(x) offsetof(TestContext, x)
...@@ -1422,6 +1441,7 @@ static const AVOption test_options[]= { ...@@ -1422,6 +1441,7 @@ static const AVOption test_options[]= {
{"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64 = AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_NB-1}, {"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64 = AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_NB-1},
{"video_rate", "set videorate", OFFSET(video_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0 }, {"video_rate", "set videorate", OFFSET(video_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0 },
{"duration", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX}, {"duration", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX},
{"color", "set color", OFFSET(color), AV_OPT_TYPE_COLOR, {.str = "pink"}, 0, 0},
{NULL}, {NULL},
}; };
...@@ -1480,6 +1500,9 @@ int main(void) ...@@ -1480,6 +1500,9 @@ int main(void)
"duration=bogus", "duration=bogus",
"duration=123.45", "duration=123.45",
"duration=1\\:23\\:45.67", "duration=1\\:23\\:45.67",
"color=blue",
"color=0x223300",
"color=0x42FF07AA",
}; };
test_ctx.class = &test_class; test_ctx.class = &test_class;
......
...@@ -232,6 +232,7 @@ enum AVOptionType{ ...@@ -232,6 +232,7 @@ enum AVOptionType{
AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'), AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'),
AV_OPT_TYPE_VIDEO_RATE = MKBETAG('V','R','A','T'), ///< offset must point to AVRational AV_OPT_TYPE_VIDEO_RATE = MKBETAG('V','R','A','T'), ///< offset must point to AVRational
AV_OPT_TYPE_DURATION = MKBETAG('D','U','R',' '), AV_OPT_TYPE_DURATION = MKBETAG('D','U','R',' '),
AV_OPT_TYPE_COLOR = MKBETAG('C','O','L','R'),
#if FF_API_OLD_AVOPTIONS #if FF_API_OLD_AVOPTIONS
FF_OPT_TYPE_FLAGS = 0, FF_OPT_TYPE_FLAGS = 0,
FF_OPT_TYPE_INT, FF_OPT_TYPE_INT,
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
*/ */
#define LIBAVUTIL_VERSION_MAJOR 52 #define LIBAVUTIL_VERSION_MAJOR 52
#define LIBAVUTIL_VERSION_MINOR 32 #define LIBAVUTIL_VERSION_MINOR 33
#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment