]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_frei0r.c
x86inc: Improve FMA instruction handling
[ffmpeg] / libavfilter / vf_frei0r.c
index 7e79b28f8f2c13428e353f49b43ac60b8fcc613f..04f74bcc7193157881c20ddd06a1444d54c39ffc 100644 (file)
@@ -81,7 +81,7 @@ static void *load_sym(AVFilterContext *ctx, const char *sym_name)
     Frei0rContext *s = ctx->priv;
     void *sym = dlsym(s->dl_handle, sym_name);
     if (!sym)
-        av_log(ctx, AV_LOG_ERROR, "Could not find symbol '%s' in loaded module\n", sym_name);
+        av_log(ctx, AV_LOG_ERROR, "Could not find symbol '%s' in loaded module.\n", sym_name);
     return sym;
 }
 
@@ -129,7 +129,7 @@ static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, cha
     return 0;
 
 fail:
-    av_log(ctx, AV_LOG_ERROR, "Invalid value '%s' for parameter '%s'\n",
+    av_log(ctx, AV_LOG_ERROR, "Invalid value '%s' for parameter '%s'.\n",
            param, info.name);
     return AVERROR(EINVAL);
 }
@@ -149,7 +149,8 @@ static int set_params(AVFilterContext *ctx, const char *params)
         if (*params) {
             if (!(param = av_get_token(&params, "|")))
                 return AVERROR(ENOMEM);
-            params++;               /* skip ':' */
+            if (*params)
+                params++;               /* skip ':' */
             ret = set_param(ctx, info, i, param);
             av_free(param);
             if (ret < 0)
@@ -198,11 +199,11 @@ static int set_params(AVFilterContext *ctx, const char *params)
         default: /* F0R_PARAM_STRING */
             v = s;
             s->get_param_value(s->instance, v, i);
-            av_log(ctx, AV_LOG_DEBUG, "'%s'\n", s);
+            av_log(ctx, AV_LOG_DEBUG, "'%s'", s);
             break;
         }
 #endif
-        av_log(ctx, AV_LOG_VERBOSE, "\n");
+        av_log(ctx, AV_LOG_VERBOSE, ".\n");
     }
 
     return 0;
@@ -213,7 +214,7 @@ static void *load_path(AVFilterContext *ctx, const char *prefix, const char *nam
     char path[1024];
 
     snprintf(path, sizeof(path), "%s%s%s", prefix, name, SLIBSUF);
-    av_log(ctx, AV_LOG_DEBUG, "Looking for frei0r effect in '%s'\n", path);
+    av_log(ctx, AV_LOG_DEBUG, "Looking for frei0r effect in '%s'.\n", path);
     return dlopen(path, RTLD_NOW|RTLD_LOCAL);
 }
 
@@ -232,12 +233,18 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
     }
 
     /* see: http://piksel.org/frei0r/1.2/spec/1.2/spec/group__pluglocations.html */
-    if ((path = av_strdup(getenv("FREI0R_PATH")))) {
-        char *p, *ptr = NULL;
-        for (p = path; p = strtok_r(p, ":", &ptr); p = NULL)
-            if (s->dl_handle = load_path(ctx, p, dl_name))
-                break;
-        av_free(path);
+    if (path = getenv("FREI0R_PATH")) {
+        while(*path) {
+            char *ptr = av_get_token((const char **)&path, ":");
+            if (!ptr)
+                return AVERROR(ENOMEM);
+            s->dl_handle = load_path(ctx, ptr, dl_name);
+            av_freep(&ptr);
+            if (s->dl_handle)
+                break;              /* found */
+            if (*path)
+                path++;             /* skip ':' */
+        }
     }
     if (!s->dl_handle && (path = getenv("HOME"))) {
         char prefix[1024];
@@ -249,7 +256,7 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
     if (!s->dl_handle)
         s->dl_handle = load_path(ctx, "/usr/lib/frei0r-1/", dl_name);
     if (!s->dl_handle) {
-        av_log(ctx, AV_LOG_ERROR, "Could not find module '%s'\n", dl_name);
+        av_log(ctx, AV_LOG_ERROR, "Could not find module '%s'.\n", dl_name);
         return AVERROR(EINVAL);
     }
 
@@ -265,7 +272,7 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
         return AVERROR(EINVAL);
 
     if (f0r_init() < 0) {
-        av_log(ctx, AV_LOG_ERROR, "Could not init the frei0r module");
+        av_log(ctx, AV_LOG_ERROR, "Could not init the frei0r module.\n");
         return AVERROR(EINVAL);
     }
 
@@ -273,7 +280,7 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
     pi = &s->plugin_info;
     if (pi->plugin_type != type) {
         av_log(ctx, AV_LOG_ERROR,
-               "Invalid type '%s' for the plugin\n",
+               "Invalid type '%s' for this plugin\n",
                pi->plugin_type == F0R_PLUGIN_TYPE_FILTER ? "filter" :
                pi->plugin_type == F0R_PLUGIN_TYPE_SOURCE ? "source" :
                pi->plugin_type == F0R_PLUGIN_TYPE_MIXER2 ? "mixer2" :
@@ -320,7 +327,7 @@ static int config_input_props(AVFilterLink *inlink)
     if (s->destruct && s->instance)
         s->destruct(s->instance);
     if (!(s->instance = s->construct(inlink->w, inlink->h))) {
-        av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance");
+        av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance.\n");
         return AVERROR(EINVAL);
     }
 
@@ -405,7 +412,7 @@ static const AVFilterPad avfilter_vf_frei0r_outputs[] = {
     { NULL }
 };
 
-AVFilter avfilter_vf_frei0r = {
+AVFilter ff_vf_frei0r = {
     .name      = "frei0r",
     .description = NULL_IF_CONFIG_SMALL("Apply a frei0r effect."),
 
@@ -427,13 +434,13 @@ static av_cold int source_init(AVFilterContext *ctx)
     AVRational frame_rate_q;
 
     if (av_parse_video_size(&s->w, &s->h, s->size) < 0) {
-        av_log(ctx, AV_LOG_ERROR, "Invalid frame size: '%s'\n", s->size);
+        av_log(ctx, AV_LOG_ERROR, "Invalid frame size: '%s'.\n", s->size);
         return AVERROR(EINVAL);
     }
 
     if (av_parse_video_rate(&frame_rate_q, s->framerate) < 0 ||
         frame_rate_q.den <= 0 || frame_rate_q.num <= 0) {
-        av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", s->framerate);
+        av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'.\n", s->framerate);
         return AVERROR(EINVAL);
     }
     s->time_base.num = frame_rate_q.den;
@@ -452,11 +459,16 @@ static int source_config_props(AVFilterLink *outlink)
     outlink->w = s->w;
     outlink->h = s->h;
     outlink->time_base = s->time_base;
+    outlink->frame_rate = av_inv_q(s->time_base);
 
     if (s->destruct && s->instance)
         s->destruct(s->instance);
     if (!(s->instance = s->construct(outlink->w, outlink->h))) {
-        av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance");
+        av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance.\n");
+        return AVERROR(EINVAL);
+    }
+    if (!s->params) {
+        av_log(ctx, AV_LOG_ERROR, "frei0r filter parameters not set.\n");
         return AVERROR(EINVAL);
     }
 
@@ -505,7 +517,7 @@ static const AVFilterPad avfilter_vsrc_frei0r_src_outputs[] = {
     { NULL }
 };
 
-AVFilter avfilter_vsrc_frei0r_src = {
+AVFilter ff_vsrc_frei0r_src = {
     .name        = "frei0r_src",
     .description = NULL_IF_CONFIG_SMALL("Generate a frei0r source."),