Commit 19973133 authored by stefano's avatar stefano

Add support in av_parse_color() to a "random" color name, which will

result in a randomly choosen random color, as it is with the
"bikeshed" color.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@18828 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent bf2e8cba
...@@ -217,7 +217,7 @@ static int color_table_compare(const void *lhs, const void *rhs) ...@@ -217,7 +217,7 @@ static int color_table_compare(const void *lhs, const void *rhs)
int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx) int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx)
{ {
if (!strcasecmp(color_string, "bikeshed")) { if (!strcasecmp(color_string, "random") || !strcasecmp(color_string, "bikeshed")) {
int rgba = ff_random_get_seed(); int rgba = ff_random_get_seed();
rgba_color[0] = rgba >> 24; rgba_color[0] = rgba >> 24;
rgba_color[1] = rgba >> 16; rgba_color[1] = rgba >> 16;
...@@ -304,6 +304,7 @@ int main(void) ...@@ -304,6 +304,7 @@ int main(void)
uint8_t rgba[4]; uint8_t rgba[4];
const char *color_names[] = { const char *color_names[] = {
"bikeshed", "bikeshed",
"RaNdOm",
"foo", "foo",
"red", "red",
"Red ", "Red ",
......
...@@ -45,6 +45,7 @@ char *av_get_token(const char **buf, const char *term); ...@@ -45,6 +45,7 @@ char *av_get_token(const char **buf, const char *term);
* *
* @param color_string a string specifying a color. It can be the name of * @param color_string a string specifying a color. It can be the name of
* a color (case insensitive match) or a 0xRRGGBB[AA] sequence. * a color (case insensitive match) or a 0xRRGGBB[AA] sequence.
* The string "random" will result in a random color.
* @return >= 0 in case of success, a negative value in case of * @return >= 0 in case of success, a negative value in case of
* failure (for example if color_string cannot be parsed). * failure (for example if color_string cannot be parsed).
*/ */
......
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