Index: vf_overlay.c
===================================================================
--- vf_overlay.c	(revision 5425)
+++ vf_overlay.c	(working copy)
@@ -25,22 +25,37 @@
 #include "libavcodec/eval.h"
 #include "libavutil/avstring.h"
 
-static const char *var_names[] = {
+static const char *const_names[]={
+    "PI",
+    "N",         ///< frame number (starting at zero)
     "mainW",    ///< width of the main video
     "mainH",    ///< height of the main video
     "overlayW", ///< width of the overlay video
-    "overlayH", ///< height of the overlay video
+    "overlayH",
     NULL
 };
 
+enum PosOfValue {
+    POV_PI,
+    POV_N,
+    POV_MAIN_W,
+    POV_MAIN_H,
+    POV_OVERLAY_W,
+    POV_OVERLAY_H,
+    POV_NULL
+};
+
 enum var_name {
     MAIN_W,
     MAIN_H,
     OVERLAY_W,
     OVERLAY_H,
+    N,
     VARS_NB
 };
 
+
+
 typedef struct {
     int x, y;                   //< position of subpicture
 
@@ -49,23 +64,45 @@
      *  pics[x][0]    are previously outputted images.
      *  pics[x][1]    are queued, yet unused frames for each input. */
     AVFilterPicRef *pics[2][2];
-
+    double const_values[POV_NULL+1]; 
     int bpp;                    //< bytes per pixel
     int hsub, vsub;             //< chroma subsampling
-
+     AVEvalExpr *expr_x;
+     AVEvalExpr *expr_y;
     char x_expr[256], y_expr[256];
 } OverlayContext;
 
 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
 {
     OverlayContext *over = ctx->priv;
+    const char *error;
+    char  x_e[255];
+    char  y_e[255];
 
     av_strlcpy(over->x_expr, "0", sizeof(over->x_expr));
     av_strlcpy(over->y_expr, "0", sizeof(over->y_expr));
+  
+    x_e[0] = NULL;
+    y_e[0] = NULL;
+     
+    sscanf(args, "%255[^:]:%255[^:]", x_e, y_e);
+    over->expr_x = ff_parse(x_e, const_names, NULL, NULL, NULL, NULL, &error);
+    
+    if (!over->expr_x)
+        av_log(ctx, AV_LOG_ERROR,
+            "init() cannot parse expresion '%s' due to %s\n", x_e, error);
+    
+    over->expr_y = ff_parse(y_e, const_names, NULL, NULL, NULL, NULL, &error);
+    
+    if (!over->expr_y)
+        av_log(ctx, AV_LOG_ERROR,
+            "init() cannot parse expresion '%s' due to %s\n", y_e, error);
+    
+    over->const_values[POV_PI] = M_PI;
+    over->const_values[POV_N] = 0;
+    over->const_values[POV_NULL] = 0.0;
+    
 
-    if (args)
-        sscanf(args, "%255[^:]:%255[^:]", over->x_expr, over->y_expr);
-
     return 0;
 }
 
@@ -112,33 +149,21 @@
 
 static int config_input_overlay(AVFilterLink *link)
 {
+    OverlayContext  *over = link->dst->priv;
     AVFilterContext *ctx  = link->dst;
-    OverlayContext  *over = link->dst->priv;
-    const char *error = NULL, *expr;
-    double var_values[VARS_NB];
-
-    /* Finish the configuration by evaluating the expressions
-       now when both inputs are configured. */
-    var_values[MAIN_W]    = ctx->inputs[0]->w;
-    var_values[MAIN_H]    = ctx->inputs[0]->h;
-    var_values[OVERLAY_W] = ctx->inputs[1]->w;
-    var_values[OVERLAY_H] = ctx->inputs[1]->h;
-
-    over->x = ff_eval2((expr = over->x_expr), var_values, var_names,
-                       NULL, NULL, NULL, NULL, NULL, &error);
-    if (error)
-        goto fail;
-    over->y = ff_eval2((expr = over->y_expr), var_values, var_names,
-                       NULL, NULL, NULL, NULL, NULL, &error);
-    if (error)
-        goto fail;
-
+  
+    over->const_values[POV_MAIN_W]    = ctx->inputs[0]->w;
+    over->const_values[POV_MAIN_H]    = ctx->inputs[0]->h;
+    over->const_values[POV_OVERLAY_W] = ctx->inputs[1]->w;
+    over->const_values[POV_OVERLAY_H] = ctx->inputs[1]->h;
+  
+    over->x = (int) ff_parse_eval(over->expr_x, over->const_values, over);
+    
+    over->y = (int) ff_parse_eval(over->expr_y, over->const_values, over);
+  
+    av_log(NULL, AV_LOG_INFO, "x:%d y:%d\n", over->x, over->y);
+    
     return 0;
-
-fail:
-    av_log(NULL, AV_LOG_ERROR,
-           "Error when evaluating the expression '%s': %s\n", expr, error);
-    return -1;
 }
 
 static void shift_input(OverlayContext *over, int idx)
@@ -162,6 +187,7 @@
         /* No previous unused frame, take this one into use directly */
         over->pics[link->dstpad][0] = picref;
     }
+    
 }
 
 static void end_frame(AVFilterLink *link)
@@ -207,9 +233,11 @@
 {
     AVFilterPicRef *pic;
     OverlayContext *over = link->src->priv;
+    AVFilterContext *ctx  = link->dst;
     int idx;
     int x, y, w, h;
 
+
     if (!over->pics[0][0] || !over->pics[1][0]) {
         /* No frame output yet, we need one frame from each input */
         if (!over->pics[0][0] && avfilter_request_frame(link->src->inputs[0]))
@@ -255,23 +283,35 @@
         copy_image(pic, 0, 0, over->pics[0][0], link->w, link->h,
                    over->bpp, over->hsub, over->vsub);
     }
+    
+    
+    over->x = (uint64_t)ff_parse_eval(over->expr_x, over->const_values, over);
+    
+    over->y = (uint64_t) ff_parse_eval(over->expr_y, over->const_values, over);
+   
+    
     x = FFMIN(over->x, link->w-1);
     y = FFMIN(over->y, link->h-1);
+    
+    
     w = FFMIN(link->w-x, over->pics[1][0]->w);
     h = FFMIN(link->h-y, over->pics[1][0]->h);
+    
+
     if(over->pics[1][0])
         copy_image(pic, x, y, over->pics[1][0], w, h,
                    over->bpp, over->hsub, over->vsub);
 
+    
     /* we give the output frame the higher of the two current pts values */
     pic->pts = FFMAX(over->pics[0][0]->pts, over->pics[1][0]->pts);
 
+    over->const_values[POV_N ] += 1;
     /* and send it to the next filter */
     avfilter_start_frame(link, avfilter_ref_pic(pic, ~0));
     avfilter_draw_slice (link, 0, pic->h);
     avfilter_end_frame  (link);
     avfilter_unref_pic(pic);
-
     return 0;
 }
 
