#define WHITESPACES " \n\t"
+/**
+ * Link two filters together.
+ *
+ * @see avfilter_link()
+ */
static int link_filter(AVFilterContext *src, int srcpad,
AVFilterContext *dst, int dstpad,
AVClass *log_ctx)
{
- if (avfilter_link(src, srcpad, dst, dstpad)) {
+ int ret;
+ if ((ret = avfilter_link(src, srcpad, dst, dstpad))) {
av_log(log_ctx, AV_LOG_ERROR,
- "cannot create the link %s:%d -> %s:%d\n",
+ "Cannot create the link %s:%d -> %s:%d\n",
src->filter->name, srcpad, dst->filter->name, dstpad);
- return -1;
+ return ret;
}
return 0;
}
/**
- * Parse "[linkname]"
- * @param name a pointer (that need to be free'd after use) to the name between
- * parenthesis
+ * Parse the name of a link, which has the format "[linkname]".
+ *
+ * @return a pointer (that need to be freed after use) to the name
+ * between parenthesis
*/
static char *parse_link_name(const char **buf, AVClass *log_ctx)
{
return name;
}
+/**
+ * Create an instance of a filter, initialize and insert it in the
+ * filtergraph in *ctx.
+ *
+ * @param ctx the filtergraph context
+ * @param index an index which is supposed to be unique for each filter instance added to the filtergraph
+ * @param filt_name the name of the filter to create
+ * @param args the arguments provided to the filter during its initialization
+ * @param log_ctx the log context to use
+ * @return a filter context in case of successful creation and configuration, NULL otherwise.
+ */
static AVFilterContext *create_filter(AVFilterGraph *ctx, int index,
const char *filt_name, const char *args,
AVClass *log_ctx)
if (!filt) {
av_log(log_ctx, AV_LOG_ERROR,
- "no such filter: '%s'\n", filt_name);
+ "No such filter: '%s'\n", filt_name);
return NULL;
}
- filt_ctx = avfilter_open(filt, inst_name);
+ avfilter_open(&filt_ctx, filt, inst_name);
if (!filt_ctx) {
av_log(log_ctx, AV_LOG_ERROR,
- "error creating filter '%s'\n", filt_name);
+ "Error creating filter '%s'\n", filt_name);
return NULL;
}
if (avfilter_init_filter(filt_ctx, args, NULL)) {
av_log(log_ctx, AV_LOG_ERROR,
- "error initializing filter '%s' with args '%s'\n", filt_name, args);
+ "Error initializing filter '%s' with args '%s'\n", filt_name, args);
return NULL;
}