On 2016-02-04 19:40, Paul B Mahol wrote: > +#define FN_ENTRY(name) {#name, script_ ## name} > +struct fn_entry { > + const char *name; > + int (*fn)(lua_State *L); > +}; > + > +static const struct fn_entry main_fns[] = { > + FN_ENTRY(log), > + FN_ENTRY(frame_count), > + FN_ENTRY(filter), > + {0} > +};
Consider using Lua's luaL_Reg type here. It already has the same fields as your struct. Whether it really matters I don't know. > +static int run_script(AVFilterContext *ctx) > +{ > + LuaScriptContext *s = ctx->priv; > + const char *dump; > + int ret, i; > + > + if (s->L) > + lua_close(s->L); > + > + s->L = luaL_newstate(); > + if (!s->L) > + return AVERROR(ENOMEM); > + > + avfilter_graph_free(&s->graph); > + memset(s->fctx, 0, sizeof(s->fctx)); > + s->nbf = 0; > + > + s->graph = avfilter_graph_alloc(); > + if (!s->graph) > + return AVERROR(ENOMEM); > + > + if (lua_cpcall(s->L, run_lua, ctx)) { lua_cpcall was removed in Lua 5.2 but you can replace this by just pushing the function and args on the stack and then calling it like any other function with lua_pcall. Overall I like this and see some potential in it. I know you have a few things to fix after speaking on IRC. I've already made a few changes but I won't do too many while you're still working on it, unless you ask for it of course. You can find my few changes here https://gitlab.com/J_Darnley/ffmpeg/commits/lua use as you see fit.
signature.asc
Description: OpenPGP digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel