Hopefully enhance readability.
Stefano Sabatini authored on 2013/05/20 06:32:02... | ... |
@@ -42,24 +42,26 @@ typedef struct { |
42 | 42 |
int is_rgb; |
43 | 43 |
} GEQContext; |
44 | 44 |
|
45 |
+enum { Y = 0, U, V, A, G, B, R }; |
|
46 |
+ |
|
45 | 47 |
#define OFFSET(x) offsetof(GEQContext, x) |
46 | 48 |
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM |
47 | 49 |
|
48 | 50 |
static const AVOption geq_options[] = { |
49 |
- { "lum_expr", "set luminance expression", OFFSET(expr_str[0]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
50 |
- { "lum", "set luminance expression", OFFSET(expr_str[0]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
51 |
- { "cb_expr", "set chroma blue expression", OFFSET(expr_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
52 |
- { "cb", "set chroma blue expression", OFFSET(expr_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
53 |
- { "cr_expr", "set chroma red expression", OFFSET(expr_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
54 |
- { "cr", "set chroma red expression", OFFSET(expr_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
55 |
- { "alpha_expr", "set alpha expression", OFFSET(expr_str[3]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
56 |
- { "a", "set alpha expression", OFFSET(expr_str[3]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
57 |
- { "red_expr", "set red expression", OFFSET(expr_str[6]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
58 |
- { "r", "set red expression", OFFSET(expr_str[6]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
59 |
- { "green_expr", "set green expression", OFFSET(expr_str[4]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
60 |
- { "g", "set green expression", OFFSET(expr_str[4]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
61 |
- { "blue_expr", "set blue expression", OFFSET(expr_str[5]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
62 |
- { "b", "set blue expression", OFFSET(expr_str[5]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
51 |
+ { "lum_expr", "set luminance expression", OFFSET(expr_str[Y]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
52 |
+ { "lum", "set luminance expression", OFFSET(expr_str[Y]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
53 |
+ { "cb_expr", "set chroma blue expression", OFFSET(expr_str[U]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
54 |
+ { "cb", "set chroma blue expression", OFFSET(expr_str[U]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
55 |
+ { "cr_expr", "set chroma red expression", OFFSET(expr_str[V]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
56 |
+ { "cr", "set chroma red expression", OFFSET(expr_str[V]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
57 |
+ { "alpha_expr", "set alpha expression", OFFSET(expr_str[A]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
58 |
+ { "a", "set alpha expression", OFFSET(expr_str[A]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
59 |
+ { "red_expr", "set red expression", OFFSET(expr_str[R]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
60 |
+ { "r", "set red expression", OFFSET(expr_str[R]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
61 |
+ { "green_expr", "set green expression", OFFSET(expr_str[G]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
62 |
+ { "g", "set green expression", OFFSET(expr_str[G]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
63 |
+ { "blue_expr", "set blue expression", OFFSET(expr_str[B]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
64 |
+ { "b", "set blue expression", OFFSET(expr_str[B]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, |
|
63 | 65 |
{NULL}, |
64 | 66 |
}; |
65 | 67 |
|
... | ... |
@@ -103,42 +105,42 @@ static av_cold int geq_init(AVFilterContext *ctx) |
103 | 103 |
GEQContext *geq = ctx->priv; |
104 | 104 |
int plane, ret = 0; |
105 | 105 |
|
106 |
- if (!geq->expr_str[0] && !geq->expr_str[4] && !geq->expr_str[5] && !geq->expr_str[6]) { |
|
106 |
+ if (!geq->expr_str[Y] && !geq->expr_str[G] && !geq->expr_str[B] && !geq->expr_str[R]) { |
|
107 | 107 |
av_log(ctx, AV_LOG_ERROR, "A luminance or RGB expression is mandatory\n"); |
108 | 108 |
ret = AVERROR(EINVAL); |
109 | 109 |
goto end; |
110 | 110 |
} |
111 |
- geq->is_rgb = !geq->expr_str[0]; |
|
111 |
+ geq->is_rgb = !geq->expr_str[Y]; |
|
112 | 112 |
|
113 |
- if ((geq->expr_str[0] || geq->expr_str[1] || geq->expr_str[2]) && (geq->expr_str[4] || geq->expr_str[5] || geq->expr_str[6])) { |
|
113 |
+ if ((geq->expr_str[Y] || geq->expr_str[U] || geq->expr_str[V]) && (geq->expr_str[G] || geq->expr_str[B] || geq->expr_str[R])) { |
|
114 | 114 |
av_log(ctx, AV_LOG_ERROR, "Either YCbCr or RGB but not both must be specified\n"); |
115 | 115 |
ret = AVERROR(EINVAL); |
116 | 116 |
goto end; |
117 | 117 |
} |
118 | 118 |
|
119 |
- if (!geq->expr_str[1] && !geq->expr_str[2]) { |
|
119 |
+ if (!geq->expr_str[U] && !geq->expr_str[V]) { |
|
120 | 120 |
/* No chroma at all: fallback on luma */ |
121 |
- geq->expr_str[1] = av_strdup(geq->expr_str[0]); |
|
122 |
- geq->expr_str[2] = av_strdup(geq->expr_str[0]); |
|
121 |
+ geq->expr_str[U] = av_strdup(geq->expr_str[Y]); |
|
122 |
+ geq->expr_str[V] = av_strdup(geq->expr_str[Y]); |
|
123 | 123 |
} else { |
124 | 124 |
/* One chroma unspecified, fallback on the other */ |
125 |
- if (!geq->expr_str[1]) geq->expr_str[1] = av_strdup(geq->expr_str[2]); |
|
126 |
- if (!geq->expr_str[2]) geq->expr_str[2] = av_strdup(geq->expr_str[1]); |
|
125 |
+ if (!geq->expr_str[U]) geq->expr_str[U] = av_strdup(geq->expr_str[V]); |
|
126 |
+ if (!geq->expr_str[V]) geq->expr_str[V] = av_strdup(geq->expr_str[U]); |
|
127 | 127 |
} |
128 | 128 |
|
129 |
- if (!geq->expr_str[3]) |
|
130 |
- geq->expr_str[3] = av_strdup("255"); |
|
131 |
- if (!geq->expr_str[4]) |
|
132 |
- geq->expr_str[4] = av_strdup("g(X,Y)"); |
|
133 |
- if (!geq->expr_str[5]) |
|
134 |
- geq->expr_str[5] = av_strdup("b(X,Y)"); |
|
135 |
- if (!geq->expr_str[6]) |
|
136 |
- geq->expr_str[6] = av_strdup("r(X,Y)"); |
|
129 |
+ if (!geq->expr_str[A]) |
|
130 |
+ geq->expr_str[A] = av_strdup("255"); |
|
131 |
+ if (!geq->expr_str[G]) |
|
132 |
+ geq->expr_str[G] = av_strdup("g(X,Y)"); |
|
133 |
+ if (!geq->expr_str[B]) |
|
134 |
+ geq->expr_str[B] = av_strdup("b(X,Y)"); |
|
135 |
+ if (!geq->expr_str[R]) |
|
136 |
+ geq->expr_str[R] = av_strdup("r(X,Y)"); |
|
137 | 137 |
|
138 | 138 |
if (geq->is_rgb ? |
139 |
- (!geq->expr_str[4] || !geq->expr_str[5] || !geq->expr_str[6]) |
|
139 |
+ (!geq->expr_str[G] || !geq->expr_str[B] || !geq->expr_str[R]) |
|
140 | 140 |
: |
141 |
- (!geq->expr_str[1] || !geq->expr_str[2] || !geq->expr_str[3])) { |
|
141 |
+ (!geq->expr_str[U] || !geq->expr_str[V] || !geq->expr_str[A])) { |
|
142 | 142 |
ret = AVERROR(ENOMEM); |
143 | 143 |
goto end; |
144 | 144 |
} |