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
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182013-05-17 - xxxxxxx - lavu 52.33.100 - opt.h
19 Add AV_OPT_TYPE_COLOR value to AVOptionType enum.
20
182013-05-13 - xxxxxxx - lavu 52.31.100 - mem.h212013-05-13 - xxxxxxx - lavu 52.31.100 - mem.h
19 Add av_dynarray2_add().22 Add av_dynarray2_add().
20 23
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
259 if (!val && (o->type != AV_OPT_TYPE_STRING &&259 if (!val && (o->type != AV_OPT_TYPE_STRING &&
260 o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT &&260 o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT &&
261 o->type != AV_OPT_TYPE_IMAGE_SIZE && o->type != AV_OPT_TYPE_VIDEO_RATE &&261 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))
263 return AVERROR(EINVAL);263 return AVERROR(EINVAL);
264 264
265 dst = ((uint8_t*)target_obj) + o->offset;265 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
331 av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", val);331 av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", val);
332 return ret;332 return ret;
333 }333 }
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 }
334 }344 }
335 345
336 av_log(obj, AV_LOG_ERROR, "Invalid option type.\n");346 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
617 i64 / 3600000000, (int)((i64 / 60000000) % 60),627 i64 / 3600000000, (int)((i64 / 60000000) % 60),
618 (int)((i64 / 1000000) % 60), (int)(i64 % 1000000));628 (int)((i64 / 1000000) % 60), (int)(i64 % 1000000));
619 break;629 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;
620 default:633 default:
621 return AVERROR(EINVAL);634 return AVERROR(EINVAL);
622 }635 }
@@ -886,6 +899,9 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, · 263 unmodified lines
886 case AV_OPT_TYPE_DURATION:899 case AV_OPT_TYPE_DURATION:
887 av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<duration>");900 av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<duration>");
888 break;901 break;
902 case AV_OPT_TYPE_COLOR:
903 av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<color>");
904 break;
889 case AV_OPT_TYPE_CONST:905 case AV_OPT_TYPE_CONST:
890 default:906 default:
891 av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");907 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
978 av_opt_set_q(s, opt->name, val, 0);994 av_opt_set_q(s, opt->name, val, 0);
979 }995 }
980 break;996 break;
997 case AV_OPT_TYPE_COLOR:
981 case AV_OPT_TYPE_STRING:998 case AV_OPT_TYPE_STRING:
982 case AV_OPT_TYPE_IMAGE_SIZE:999 case AV_OPT_TYPE_IMAGE_SIZE:
983 case AV_OPT_TYPE_VIDEO_RATE:1000 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
1334 case AV_OPT_TYPE_FLOAT:1351 case AV_OPT_TYPE_FLOAT:
1335 case AV_OPT_TYPE_DOUBLE:1352 case AV_OPT_TYPE_DOUBLE:
1336 case AV_OPT_TYPE_DURATION:1353 case AV_OPT_TYPE_DURATION:
1354 case AV_OPT_TYPE_COLOR:
1337 break;1355 break;
1338 case AV_OPT_TYPE_STRING:1356 case AV_OPT_TYPE_STRING:
1339 range->component_min = 0;1357 range->component_min = 0;
@@ -1400,6 +1418,7 @@ typedef struct TestContext · 60 unmodified lines
1400 enum AVPixelFormat pix_fmt;1418 enum AVPixelFormat pix_fmt;
1401 enum AVSampleFormat sample_fmt;1419 enum AVSampleFormat sample_fmt;
1402 int64_t duration;1420 int64_t duration;
1421 uint8_t color[4];
1403} TestContext;1422} TestContext;
1404 1423
1405#define OFFSET(x) offsetof(TestContext, x)1424#define OFFSET(x) offsetof(TestContext, x)
@@ -1422,6 +1441,7 @@ static const AVOption test_options[]= { · 16 unmodified lines
1422{"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64 = AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_NB-1},1441{"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64 = AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_NB-1},
1423{"video_rate", "set videorate", OFFSET(video_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0 },1442{"video_rate", "set videorate", OFFSET(video_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0 },
1424{"duration", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX},1443{"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},
1425{NULL},1445{NULL},
1426};1446};
1427 1447
@@ -1480,6 +1500,9 @@ int main(void) · 52 unmodified lines
1480 "duration=bogus",1500 "duration=bogus",
1481 "duration=123.45",1501 "duration=123.45",
1482 "duration=1\\:23\\:45.67",1502 "duration=1\\:23\\:45.67",
1503 "color=blue",
1504 "color=0x223300",
1505 "color=0x42FF07AA",
1483 };1506 };
1484 1507
1485 test_ctx.class = &test_class;1508 test_ctx.class = &test_class;
libavutil/opt.h+1−0
@@ -232,6 +232,7 @@ enum AVOptionType{ · 231 unmodified lines
232 AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'),232 AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'),
233 AV_OPT_TYPE_VIDEO_RATE = MKBETAG('V','R','A','T'), ///< offset must point to AVRational233 AV_OPT_TYPE_VIDEO_RATE = MKBETAG('V','R','A','T'), ///< offset must point to AVRational
234 AV_OPT_TYPE_DURATION = MKBETAG('D','U','R',' '),234 AV_OPT_TYPE_DURATION = MKBETAG('D','U','R',' '),
235 AV_OPT_TYPE_COLOR = MKBETAG('C','O','L','R'),
235#if FF_API_OLD_AVOPTIONS236#if FF_API_OLD_AVOPTIONS
236 FF_OPT_TYPE_FLAGS = 0,237 FF_OPT_TYPE_FLAGS = 0,
237 FF_OPT_TYPE_INT,238 FF_OPT_TYPE_INT,
libavutil/version.h+1−1
@@ -75,7 +75,7 @@ · 74 unmodified lines
75 */75 */
76 76
77#define LIBAVUTIL_VERSION_MAJOR 5277#define LIBAVUTIL_VERSION_MAJOR 52
78#define LIBAVUTIL_VERSION_MINOR 3278#define LIBAVUTIL_VERSION_MINOR 33
79#define LIBAVUTIL_VERSION_MICRO 10079#define LIBAVUTIL_VERSION_MICRO 100
80 80
81#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \81#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