History

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.

Originally committed as revision 18828 to svn://svn.ffmpeg.org/ffmpeg/trunk

Stefano Sabatini committed 17 years ago

Commit 3d3bd641 parent b69b6222 files · +3 −1Browse files

Unified · Split

2 files
  1. libavfilter/parseutils.c +2 −1
  2. libavfilter/parseutils.h +1 −0
libavfilter/parseutils.c+2−1
@@ -217,7 +217,7 @@ static int color_table_compare(const void *lhs, const void *rhs) · 216 unmodified lines
217 217
218int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx)218int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx)
219{219{
220 if (!strcasecmp(color_string, "bikeshed")) {220 if (!strcasecmp(color_string, "random") || !strcasecmp(color_string, "bikeshed")) {
221 int rgba = ff_random_get_seed();221 int rgba = ff_random_get_seed();
222 rgba_color[0] = rgba >> 24;222 rgba_color[0] = rgba >> 24;
223 rgba_color[1] = rgba >> 16;223 rgba_color[1] = rgba >> 16;
@@ -304,6 +304,7 @@ int main(void) · 80 unmodified lines
304 uint8_t rgba[4];304 uint8_t rgba[4];
305 const char *color_names[] = {305 const char *color_names[] = {
306 "bikeshed",306 "bikeshed",
307 "RaNdOm",
307 "foo",308 "foo",
308 "red",309 "red",
309 "Red ",310 "Red ",
libavfilter/parseutils.h+1−0
@@ -45,6 +45,7 @@ char *av_get_token(const char **buf, const char *term); · 44 unmodified lines
45 *45 *
46 * @param color_string a string specifying a color. It can be the name of46 * @param color_string a string specifying a color. It can be the name of
47 * a color (case insensitive match) or a 0xRRGGBB[AA] sequence.47 * a color (case insensitive match) or a 0xRRGGBB[AA] sequence.
48 * The string "random" will result in a random color.
48 * @return >= 0 in case of success, a negative value in case of49 * @return >= 0 in case of success, a negative value in case of
49 * failure (for example if color_string cannot be parsed).50 * failure (for example if color_string cannot be parsed).
50 */51 */

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