History

lavu/opt: add AV_OPT_TYPE_COLOR

Paul B Mahol committed 13 years ago

Commit 3a751ea1 parent 1ec578c4 files · +29 −2Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/opt.c +24 −1
  3. libavutil/opt.h +1 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2012-10-22 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2013-05-17 - xxxxxxx - lavu 52.33.100 - opt.h
19+ Add AV_OPT_TYPE_COLOR value to AVOptionType enum.
20+
1821 2013-05-13 - xxxxxxx - lavu 52.31.100 - mem.h
1922 Add av_dynarray2_add().
2023
libavutil/opt.c+24−1
@@ -259,7 +259,7 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) · 258 unmodified lines
259259 if (!val && (o->type != AV_OPT_TYPE_STRING &&
260260 o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT &&
261261 o->type != AV_OPT_TYPE_IMAGE_SIZE && o->type != AV_OPT_TYPE_VIDEO_RATE &&
262− o->type != AV_OPT_TYPE_DURATION))
262+ o->type != AV_OPT_TYPE_DURATION && o->type != AV_OPT_TYPE_COLOR))
263263 return AVERROR(EINVAL);
264264
265265 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) · 65 unmodified lines
331331 av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", val);
332332 return ret;
333333 }
334+ break;
335+ case AV_OPT_TYPE_COLOR:
336+ if (!val) {
337+ return 0;
338+ } else {
339+ ret = av_parse_color(dst, val, -1, obj);
340+ if (ret < 0)
341+ av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as color\n", val);
342+ return ret;
343+ }
334344 }
335345
336346 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) · 280 unmodified lines
617627 i64 / 3600000000, (int)((i64 / 60000000) % 60),
618628 (int)((i64 / 1000000) % 60), (int)(i64 % 1000000));
619629 break;
630+ case AV_OPT_TYPE_COLOR:
631+ ret = snprintf(buf, sizeof(buf), "0x%02x%02x%02x%02x", ((int *)dst)[0], ((int *)dst)[1], ((int *)dst)[2], ((int *)dst)[3]);
632+ break;
620633 default:
621634 return AVERROR(EINVAL);
622635 }
@@ -886,6 +899,9 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, · 263 unmodified lines
886899 case AV_OPT_TYPE_DURATION:
887900 av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<duration>");
888901 break;
902+ case AV_OPT_TYPE_COLOR:
903+ av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<color>");
904+ break;
889905 case AV_OPT_TYPE_CONST:
890906 default:
891907 av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
@@ -978,6 +994,7 @@ void av_opt_set_defaults2(void *s, int mask, int flags) · 86 unmodified lines
978994 av_opt_set_q(s, opt->name, val, 0);
979995 }
980996 break;
997+ case AV_OPT_TYPE_COLOR:
981998 case AV_OPT_TYPE_STRING:
982999 case AV_OPT_TYPE_IMAGE_SIZE:
9831000 case AV_OPT_TYPE_VIDEO_RATE:
@@ -1334,6 +1351,7 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch · 350 unmodified lines
13341351 case AV_OPT_TYPE_FLOAT:
13351352 case AV_OPT_TYPE_DOUBLE:
13361353 case AV_OPT_TYPE_DURATION:
1354+ case AV_OPT_TYPE_COLOR:
13371355 break;
13381356 case AV_OPT_TYPE_STRING:
13391357 range->component_min = 0;
@@ -1400,6 +1418,7 @@ typedef struct TestContext · 60 unmodified lines
14001418 enum AVPixelFormat pix_fmt;
14011419 enum AVSampleFormat sample_fmt;
14021420 int64_t duration;
1421+ uint8_t color[4];
14031422 } TestContext;
14041423
14051424 #define OFFSET(x) offsetof(TestContext, x)
@@ -1422,6 +1441,7 @@ static const AVOption test_options[]= { · 16 unmodified lines
14221441 {"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64 = AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_NB-1},
14231442 {"video_rate", "set videorate", OFFSET(video_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0 },
14241443 {"duration", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX},
1444+{"color", "set color", OFFSET(color), AV_OPT_TYPE_COLOR, {.str = "pink"}, 0, 0},
14251445 {NULL},
14261446 };
14271447
@@ -1480,6 +1500,9 @@ int main(void) · 52 unmodified lines
14801500 "duration=bogus",
14811501 "duration=123.45",
14821502 "duration=1\\:23\\:45.67",
1503+ "color=blue",
1504+ "color=0x223300",
1505+ "color=0x42FF07AA",
14831506 };
14841507
14851508 test_ctx.class = &test_class;
libavutil/opt.h+1−0
@@ -232,6 +232,7 @@ enum AVOptionType{ · 231 unmodified lines
232232 AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'),
233233 AV_OPT_TYPE_VIDEO_RATE = MKBETAG('V','R','A','T'), ///< offset must point to AVRational
234234 AV_OPT_TYPE_DURATION = MKBETAG('D','U','R',' '),
235+ AV_OPT_TYPE_COLOR = MKBETAG('C','O','L','R'),
235236 #if FF_API_OLD_AVOPTIONS
236237 FF_OPT_TYPE_FLAGS = 0,
237238 FF_OPT_TYPE_INT,
libavutil/version.h+1−1
@@ -75,7 +75,7 @@ · 74 unmodified lines
7575 */
7676
7777 #define LIBAVUTIL_VERSION_MAJOR 52
78−#define LIBAVUTIL_VERSION_MINOR 32
78+#define LIBAVUTIL_VERSION_MINOR 33
7979 #define LIBAVUTIL_VERSION_MICRO 100
8080
8181 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t