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

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_zoompan.c+22−12
@@ -81,6 +81,9 @@ typedef struct ZPcontext { · 80 unmodified lines
81 char *x_expr_str;81 char *x_expr_str;
82 char *y_expr_str;82 char *y_expr_str;
83 char *duration_expr_str;83 char *duration_expr_str;
84
85 AVExpr *zoom_expr, *x_expr, *y_expr;
86
84 int w, h;87 int w, h;
85 double x, y;88 double x, y;
86 double prev_zoom;89 double prev_zoom;
@@ -123,6 +126,7 @@ static int config_output(AVFilterLink *outlink) · 36 unmodified lines
123{126{
124 AVFilterContext *ctx = outlink->src;127 AVFilterContext *ctx = outlink->src;
125 ZPContext *s = ctx->priv;128 ZPContext *s = ctx->priv;
129 int ret;
126 130
127 outlink->w = s->w;131 outlink->w = s->w;
128 outlink->h = s->h;132 outlink->h = s->h;
@@ -130,6 +134,18 @@ static int config_output(AVFilterLink *outlink) · 1 unmodified line
130 outlink->frame_rate = s->framerate;134 outlink->frame_rate = s->framerate;
131 s->desc = av_pix_fmt_desc_get(outlink->format);135 s->desc = av_pix_fmt_desc_get(outlink->format);
132 136
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
133 return 0;149 return 0;
134}150}
135 151
@@ -151,28 +167,22 @@ static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double *var_va · 15 unmodified lines
151 var_values[VAR_TIME] = pts * av_q2d(outlink->time_base);167 var_values[VAR_TIME] = pts * av_q2d(outlink->time_base);
152 var_values[VAR_FRAME] = i;168 var_values[VAR_FRAME] = i;
153 var_values[VAR_ON] = outlink->frame_count_in + 1;169 var_values[VAR_ON] = outlink->frame_count_in + 1;
154 if ((ret = av_expr_parse_and_eval(zoom, s->zoom_expr_str,170
155 var_names, var_values,171 *zoom = av_expr_eval(s->zoom_expr, var_values, NULL);
156 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
157 return ret;
158 172
159 *zoom = av_clipd(*zoom, 1, 10);173 *zoom = av_clipd(*zoom, 1, 10);
160 var_values[VAR_ZOOM] = *zoom;174 var_values[VAR_ZOOM] = *zoom;
161 w = in->width * (1.0 / *zoom);175 w = in->width * (1.0 / *zoom);
162 h = in->height * (1.0 / *zoom);176 h = in->height * (1.0 / *zoom);
163 177
164 if ((ret = av_expr_parse_and_eval(dx, s->x_expr_str,178 *dx = av_expr_eval(s->x_expr, var_values, NULL);
165 var_names, var_values,179
166 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
167 return ret;
168 x = *dx = av_clipd(*dx, 0, FFMAX(in->width - w, 0));180 x = *dx = av_clipd(*dx, 0, FFMAX(in->width - w, 0));
169 var_values[VAR_X] = *dx;181 var_values[VAR_X] = *dx;
170 x &= ~((1 << s->desc->log2_chroma_w) - 1);182 x &= ~((1 << s->desc->log2_chroma_w) - 1);
171 183
172 if ((ret = av_expr_parse_and_eval(dy, s->y_expr_str,184 *dy = av_expr_eval(s->y_expr, var_values, NULL);
173 var_names, var_values,185
174 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
175 return ret;
176 y = *dy = av_clipd(*dy, 0, FFMAX(in->height - h, 0));186 y = *dy = av_clipd(*dy, 0, FFMAX(in->height - h, 0));
177 var_values[VAR_Y] = *dy;187 var_values[VAR_Y] = *dy;
178 y &= ~((1 << s->desc->log2_chroma_h) - 1);188 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