libavfilter/vf_colorkey.cui
typedef struct ColorkeyContext { const AVClass *class; /* color offsets rgba */ int co[4]; uint8_t colorkey_rgba[4]; float similarity; float blend; } ColorkeyContext; #define OFFSET(x) offsetof(ColorkeyContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM static const AVOption colorkey_options[] = { { "color", "set the colorkey key color", OFFSET(colorkey_rgba), AV_OPT_TYPE_COLOR, { .str = "black" }, CHAR_MIN, CHAR_MAX, FLAGS }, { "similarity", "set the colorkey similarity value", OFFSET(similarity), AV_OPT_TYPE_FLOAT, { .dbl = 0.01 }, 0.01, 1.0, FLAGS }, { "blend", "set the colorkey key blend value", OFFSET(blend), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, 0.0, 1.0, FLAGS }, { NULL } }; AVFILTER_DEFINE_CLASS(colorkey); AVFilter ff_vf_colorkey = { .name = "colorkey", .description = NULL_IF_CONFIG_SMALL("Turns a certain color into transparency. Operates on RGB colors."), .priv_size = sizeof(ColorkeyContext), .priv_class = &colorkey_class, .query_formats = query_formats, .inputs = colorkey_inputs, .outputs = colorkey_outputs, .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, };
libavutil/parseutils.curl
typedef struct ColorEntry { const char *name; ///< a string representing the name of the color uint8_t rgb_color[3]; ///< RGB values for the color } ColorEntry; static const ColorEntry color_table[] = { { "AliceBlue", { 0xF0, 0xF8, 0xFF } }, { "AntiqueWhite", { 0xFA, 0xEB, 0xD7 } }, { "Aqua", { 0x00, 0xFF, 0xFF } }, { "Aquamarine", { 0x7F, 0xFF, 0xD4 } }, { "Azure", { 0xF0, 0xFF, 0xFF } }, { "Beige", { 0xF5, 0xF5, 0xDC } }, { "Bisque", { 0xFF, 0xE4, 0xC4 } }, { "Black", { 0x00, 0x00, 0x00 } }, { "BlanchedAlmond", { 0xFF, 0xEB, 0xCD } }, { "Blue", { 0x00, 0x00, 0xFF } }, { "BlueViolet", { 0x8A, 0x2B, 0xE2 } }, { "Brown", { 0xA5, 0x2A, 0x2A } }, { "BurlyWood", { 0xDE, 0xB8, 0x87 } }, { "CadetBlue", { 0x5F, 0x9E, 0xA0 } }, { "Chartreuse", { 0x7F, 0xFF, 0x00 } }, { "Chocolate", { 0xD2, 0x69, 0x1E } }, { "Coral", { 0xFF, 0x7F, 0x50 } }, { "CornflowerBlue", { 0x64, 0x95, 0xED } }, { "Cornsilk", { 0xFF, 0xF8, 0xDC } }, { "Crimson", { 0xDC, 0x14, 0x3C } }, { "Cyan", { 0x00, 0xFF, 0xFF } }, { "DarkBlue", { 0x00, 0x00, 0x8B } }, { "DarkCyan", { 0x00, 0x8B, 0x8B } }, { "DarkGoldenRod", { 0xB8, 0x86, 0x0B } }, { "DarkGray", { 0xA9, 0xA9, 0xA9 } }, { "DarkGreen", { 0x00, 0x64, 0x00 } }, { "DarkKhaki", { 0xBD, 0xB7, 0x6B } }, { "DarkMagenta", { 0x8B, 0x00, 0x8B } }, { "DarkOliveGreen", { 0x55, 0x6B, 0x2F } }, { "Darkorange", { 0xFF, 0x8C, 0x00 } }, { "DarkOrchid", { 0x99, 0x32, 0xCC } }, { "DarkRed", { 0x8B, 0x00, 0x00 } }, { "DarkSalmon", { 0xE9, 0x96, 0x7A } }, { "DarkSeaGreen", { 0x8F, 0xBC, 0x8F } }, { "DarkSlateBlue", { 0x48, 0x3D, 0x8B } }, { "DarkSlateGray", { 0x2F, 0x4F, 0x4F } }, { "DarkTurquoise", { 0x00, 0xCE, 0xD1 } }, { "DarkViolet", { 0x94, 0x00, 0xD3 } }, { "DeepPink", { 0xFF, 0x14, 0x93 } }, { "DeepSkyBlue", { 0x00, 0xBF, 0xFF } }, { "DimGray", { 0x69, 0x69, 0x69 } }, { "DodgerBlue", { 0x1E, 0x90, 0xFF } }, { "FireBrick", { 0xB2, 0x22, 0x22 } }, { "FloralWhite", { 0xFF, 0xFA, 0xF0 } }, { "ForestGreen", { 0x22, 0x8B, 0x22 } }, { "Fuchsia", { 0xFF, 0x00, 0xFF } }, { "Gainsboro", { 0xDC, 0xDC, 0xDC } }, { "GhostWhite", { 0xF8, 0xF8, 0xFF } }, { "Gold", { 0xFF, 0xD7, 0x00 } }, { "GoldenRod", { 0xDA, 0xA5, 0x20 } }, { "Gray", { 0x80, 0x80, 0x80 } }, { "Green", { 0x00, 0x80, 0x00 } }, { "GreenYellow", { 0xAD, 0xFF, 0x2F } }, { "HoneyDew", { 0xF0, 0xFF, 0xF0 } }, { "HotPink", { 0xFF, 0x69, 0xB4 } }, { "IndianRed", { 0xCD, 0x5C, 0x5C } }, { "Indigo", { 0x4B, 0x00, 0x82 } }, { "Ivory", { 0xFF, 0xFF, 0xF0 } }, { "Khaki", { 0xF0, 0xE6, 0x8C } }, { "Lavender", { 0xE6, 0xE6, 0xFA } }, { "LavenderBlush", { 0xFF, 0xF0, 0xF5 } }, { "LawnGreen", { 0x7C, 0xFC, 0x00 } }, { "LemonChiffon", { 0xFF, 0xFA, 0xCD } }, { "LightBlue", { 0xAD, 0xD8, 0xE6 } }, { "LightCoral", { 0xF0, 0x80, 0x80 } }, { "LightCyan", { 0xE0, 0xFF, 0xFF } }, { "LightGoldenRodYellow", { 0xFA, 0xFA, 0xD2 } }, { "LightGreen", { 0x90, 0xEE, 0x90 } }, { "LightGrey", { 0xD3, 0xD3, 0xD3 } }, { "LightPink", { 0xFF, 0xB6, 0xC1 } }, { "LightSalmon", { 0xFF, 0xA0, 0x7A } }, { "LightSeaGreen", { 0x20, 0xB2, 0xAA } }, { "LightSkyBlue", { 0x87, 0xCE, 0xFA } }, { "LightSlateGray", { 0x77, 0x88, 0x99 } }, { "LightSteelBlue", { 0xB0, 0xC4, 0xDE } }, { "LightYellow", { 0xFF, 0xFF, 0xE0 } }, { "Lime", { 0x00, 0xFF, 0x00 } }, { "LimeGreen", { 0x32, 0xCD, 0x32 } }, { "Linen", { 0xFA, 0xF0, 0xE6 } }, { "Magenta", { 0xFF, 0x00, 0xFF } }, { "Maroon", { 0x80, 0x00, 0x00 } }, { "MediumAquaMarine", { 0x66, 0xCD, 0xAA } }, { "MediumBlue", { 0x00, 0x00, 0xCD } }, { "MediumOrchid", { 0xBA, 0x55, 0xD3 } }, { "MediumPurple", { 0x93, 0x70, 0xD8 } }, { "MediumSeaGreen", { 0x3C, 0xB3, 0x71 } }, { "MediumSlateBlue", { 0x7B, 0x68, 0xEE } }, { "MediumSpringGreen", { 0x00, 0xFA, 0x9A } }, { "MediumTurquoise", { 0x48, 0xD1, 0xCC } }, { "MediumVioletRed", { 0xC7, 0x15, 0x85 } }, { "MidnightBlue", { 0x19, 0x19, 0x70 } }, { "MintCream", { 0xF5, 0xFF, 0xFA } }, { "MistyRose", { 0xFF, 0xE4, 0xE1 } }, { "Moccasin", { 0xFF, 0xE4, 0xB5 } }, { "NavajoWhite", { 0xFF, 0xDE, 0xAD } }, { "Navy", { 0x00, 0x00, 0x80 } }, { "OldLace", { 0xFD, 0xF5, 0xE6 } }, { "Olive", { 0x80, 0x80, 0x00 } }, { "OliveDrab", { 0x6B, 0x8E, 0x23 } }, { "Orange", { 0xFF, 0xA5, 0x00 } }, { "OrangeRed", { 0xFF, 0x45, 0x00 } }, { "Orchid", { 0xDA, 0x70, 0xD6 } }, { "PaleGoldenRod", { 0xEE, 0xE8, 0xAA } }, { "PaleGreen", { 0x98, 0xFB, 0x98 } }, { "PaleTurquoise", { 0xAF, 0xEE, 0xEE } }, { "PaleVioletRed", { 0xD8, 0x70, 0x93 } }, { "PapayaWhip", { 0xFF, 0xEF, 0xD5 } }, { "PeachPuff", { 0xFF, 0xDA, 0xB9 } }, { "Peru", { 0xCD, 0x85, 0x3F } }, { "Pink", { 0xFF, 0xC0, 0xCB } }, { "Plum", { 0xDD, 0xA0, 0xDD } }, { "PowderBlue", { 0xB0, 0xE0, 0xE6 } }, { "Purple", { 0x80, 0x00, 0x80 } }, { "Red", { 0xFF, 0x00, 0x00 } }, { "RosyBrown", { 0xBC, 0x8F, 0x8F } }, { "RoyalBlue", { 0x41, 0x69, 0xE1 } }, { "SaddleBrown", { 0x8B, 0x45, 0x13 } }, { "Salmon", { 0xFA, 0x80, 0x72 } }, { "SandyBrown", { 0xF4, 0xA4, 0x60 } }, { "SeaGreen", { 0x2E, 0x8B, 0x57 } }, { "SeaShell", { 0xFF, 0xF5, 0xEE } }, { "Sienna", { 0xA0, 0x52, 0x2D } }, { "Silver", { 0xC0, 0xC0, 0xC0 } }, { "SkyBlue", { 0x87, 0xCE, 0xEB } }, { "SlateBlue", { 0x6A, 0x5A, 0xCD } }, { "SlateGray", { 0x70, 0x80, 0x90 } }, { "Snow", { 0xFF, 0xFA, 0xFA } }, { "SpringGreen", { 0x00, 0xFF, 0x7F } }, { "SteelBlue", { 0x46, 0x82, 0xB4 } }, { "Tan", { 0xD2, 0xB4, 0x8C } }, { "Teal", { 0x00, 0x80, 0x80 } }, { "Thistle", { 0xD8, 0xBF, 0xD8 } }, { "Tomato", { 0xFF, 0x63, 0x47 } }, { "Turquoise", { 0x40, 0xE0, 0xD0 } }, { "Violet", { 0xEE, 0x82, 0xEE } }, { "Wheat", { 0xF5, 0xDE, 0xB3 } }, { "White", { 0xFF, 0xFF, 0xFF } }, { "WhiteSmoke", { 0xF5, 0xF5, 0xF5 } }, { "Yellow", { 0xFF, 0xFF, 0x00 } }, { "YellowGreen", { 0x9A, 0xCD, 0x32 } }, };
其中AVOption在libavutil/opt.h定義spa
enum AVOptionType{ AV_OPT_TYPE_FLAGS, AV_OPT_TYPE_INT, AV_OPT_TYPE_INT64, AV_OPT_TYPE_DOUBLE, AV_OPT_TYPE_FLOAT, AV_OPT_TYPE_STRING, AV_OPT_TYPE_RATIONAL, AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length AV_OPT_TYPE_DICT, AV_OPT_TYPE_CONST = 128, AV_OPT_TYPE_IMAGE_SIZE = MKBETAG('S','I','Z','E'), ///< offset must point to two consecutive integers AV_OPT_TYPE_PIXEL_FMT = MKBETAG('P','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_DURATION = MKBETAG('D','U','R',' '), AV_OPT_TYPE_COLOR = MKBETAG('C','O','L','R'), AV_OPT_TYPE_CHANNEL_LAYOUT = MKBETAG('C','H','L','A'), AV_OPT_TYPE_BOOL = MKBETAG('B','O','O','L'), }; /** * AVOption */ typedef struct AVOption { const char *name; /** * short English help text * @todo What about other languages? */ const char *help; /** * The offset relative to the context structure where the option * value is stored. It should be 0 for named constants. */ int offset; enum AVOptionType type; /** * the default value for scalar options */ union { int64_t i64; double dbl; const char *str; /* TODO those are unused now */ AVRational q; } default_val; double min; ///< minimum valid value for the option double max; ///< maximum valid value for the option int flags; #define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding #define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding #if FF_API_OPT_TYPE_METADATA #define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ... #endif #define AV_OPT_FLAG_AUDIO_PARAM 8 #define AV_OPT_FLAG_VIDEO_PARAM 16 #define AV_OPT_FLAG_SUBTITLE_PARAM 32 /** * The option is inteded for exporting values to the caller. */ #define AV_OPT_FLAG_EXPORT 64 /** * The option may not be set through the AVOptions API, only read. * This flag only makes sense when AV_OPT_FLAG_EXPORT is also set. */ #define AV_OPT_FLAG_READONLY 128 #define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering //FIXME think about enc-audio, ... style flags /** * The logical unit to which the option belongs. Non-constant * options and corresponding named constants share the same * unit. May be NULL. */ const char *unit; } AVOption;
因此經過名稱能夠找到對應的十六進制數字。scala