History

avfilter/vf_zoompan: parse zoom,x and y expression during initialization

Fixes #6127.

Paul B Mahol committed 9 years ago

Commit bf39f7e1 parent 2ce43271 file · +22 −12Browse files

Unified · Split

libavfilter/vf_zoompan.c+22−12
@@ -81,6 +81,9 @@ typedef struct ZPcontext { · 80 unmodified lines
8181 char *x_expr_str;
8282 char *y_expr_str;
8383 char *duration_expr_str;
84+
85+ AVExpr *zoom_expr, *x_expr, *y_expr;
86+
8487 int w, h;
8588 double x, y;
8689 double prev_zoom;
@@ -123,6 +126,7 @@ static int config_output(AVFilterLink *outlink) · 36 unmodified lines
123126 {
124127 AVFilterContext *ctx = outlink->src;
125128 ZPContext *s = ctx->priv;
129+ int ret;
126130
127131 outlink->w = s->w;
128132 outlink->h = s->h;
@@ -130,6 +134,18 @@ static int config_output(AVFilterLink *outlink) · 1 unmodified line
130134 outlink->frame_rate = s->framerate;
131135 s->desc = av_pix_fmt_desc_get(outlink->format);
132136
137+ ret = av_expr_parse(&s->zoom_expr, s->zoom_expr_str, var_names, NULL, NULL, NULL, NULL, 0, ctx);
138+ if (ret < 0)
139+ return ret;
140+
141+ ret = av_expr_parse(&s->x_expr, s->x_expr_str, var_names, NULL, NULL, NULL, NULL, 0, ctx);
142+ if (ret < 0)
143+ return ret;
144+
145+ ret = av_expr_parse(&s->y_expr, s->y_expr_str, var_names, NULL, NULL, NULL, NULL, 0, ctx);
146+ if (ret < 0)
147+ return ret;
148+
133149 return 0;
134150 }
135151
@@ -151,28 +167,22 @@ static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double *var_va · 15 unmodified lines
151167 var_values[VAR_TIME] = pts * av_q2d(outlink->time_base);
152168 var_values[VAR_FRAME] = i;
153169 var_values[VAR_ON] = outlink->frame_count_in + 1;
154− if ((ret = av_expr_parse_and_eval(zoom, s->zoom_expr_str,
155− var_names, var_values,
156− NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
157− return ret;
170+
171+ *zoom = av_expr_eval(s->zoom_expr, var_values, NULL);
158172
159173 *zoom = av_clipd(*zoom, 1, 10);
160174 var_values[VAR_ZOOM] = *zoom;
161175 w = in->width * (1.0 / *zoom);
162176 h = in->height * (1.0 / *zoom);
163177
164− if ((ret = av_expr_parse_and_eval(dx, s->x_expr_str,
165− var_names, var_values,
166− NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
167− return ret;
178+ *dx = av_expr_eval(s->x_expr, var_values, NULL);
179+
168180 x = *dx = av_clipd(*dx, 0, FFMAX(in->width - w, 0));
169181 var_values[VAR_X] = *dx;
170182 x &= ~((1 << s->desc->log2_chroma_w) - 1);
171183
172− if ((ret = av_expr_parse_and_eval(dy, s->y_expr_str,
173− var_names, var_values,
174− NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
175− return ret;
184+ *dy = av_expr_eval(s->y_expr, var_values, NULL);
185+
176186 y = *dy = av_clipd(*dy, 0, FFMAX(in->height - h, 0));
177187 var_values[VAR_Y] = *dy;
178188 y &= ~((1 << s->desc->log2_chroma_h) - 1);

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