return ret;
}
- av_log(ctx, AV_LOG_INFO,
+ av_log(ctx, AV_LOG_VERBOSE,
"idx:%d name:'%s' type:%s explanation:'%s' ",
i, info.name,
info.type == F0R_PARAM_BOOL ? "bool" :
info.explanation);
#ifdef DEBUG
- av_log(ctx, AV_LOG_INFO, "value:");
+ av_log(ctx, AV_LOG_DEBUG, "value:");
switch (info.type) {
void *v;
double d;
case F0R_PARAM_BOOL:
v = &d;
frei0r->get_param_value(frei0r->instance, v, i);
- av_log(ctx, AV_LOG_INFO, "%s", d >= 0.5 && d <= 1.0 ? "y" : "n");
+ av_log(ctx, AV_LOG_DEBUG, "%s", d >= 0.5 && d <= 1.0 ? "y" : "n");
break;
case F0R_PARAM_DOUBLE:
v = &d;
frei0r->get_param_value(frei0r->instance, v, i);
- av_log(ctx, AV_LOG_INFO, "%f", d);
+ av_log(ctx, AV_LOG_DEBUG, "%f", d);
break;
case F0R_PARAM_COLOR:
v = &col;
frei0r->get_param_value(frei0r->instance, v, i);
- av_log(ctx, AV_LOG_INFO, "%f/%f/%f", col.r, col.g, col.b);
+ av_log(ctx, AV_LOG_DEBUG, "%f/%f/%f", col.r, col.g, col.b);
break;
case F0R_PARAM_POSITION:
v = &pos;
frei0r->get_param_value(frei0r->instance, v, i);
- av_log(ctx, AV_LOG_INFO, "%lf/%lf", pos.x, pos.y);
+ av_log(ctx, AV_LOG_DEBUG, "%lf/%lf", pos.x, pos.y);
break;
default: /* F0R_PARAM_STRING */
v = s;
frei0r->get_param_value(frei0r->instance, v, i);
- av_log(ctx, AV_LOG_INFO, "'%s'\n", s);
+ av_log(ctx, AV_LOG_DEBUG, "'%s'\n", s);
break;
}
#endif
- av_log(ctx, AV_LOG_INFO, "\n");
+ av_log(ctx, AV_LOG_VERBOSE, "\n");
}
return 0;
return AVERROR(EINVAL);
}
- av_log(ctx, AV_LOG_INFO,
+ av_log(ctx, AV_LOG_VERBOSE,
"name:%s author:'%s' explanation:'%s' color_model:%s "
"frei0r_version:%d version:%d.%d num_params:%d\n",
pi->name, pi->author, pi->explanation,
return 0;
}
-static av_cold int filter_init(AVFilterContext *ctx, const char *args, void *opaque)
+static av_cold int filter_init(AVFilterContext *ctx, const char *args)
{
Frei0rContext *frei0r = ctx->priv;
char dl_name[1024], c;
return 0;
}
-static void null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { }
+static int null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+{
+ return 0;
+}
-static void end_frame(AVFilterLink *inlink)
+static int end_frame(AVFilterLink *inlink)
{
Frei0rContext *frei0r = inlink->dst->priv;
AVFilterLink *outlink = inlink->dst->outputs[0];
AVFilterBufferRef *inpicref = inlink->cur_buf;
AVFilterBufferRef *outpicref = outlink->out_buf;
+ int ret;
frei0r->update(frei0r->instance, inpicref->pts * av_q2d(inlink->time_base) * 1000,
(const uint32_t *)inpicref->data[0],
(uint32_t *)outpicref->data[0]);
- avfilter_unref_buffer(inpicref);
- ff_draw_slice(outlink, 0, outlink->h, 1);
- ff_end_frame(outlink);
- avfilter_unref_buffer(outpicref);
+ if ((ret = ff_draw_slice(outlink, 0, outlink->h, 1)) ||
+ (ret = ff_end_frame(outlink)) < 0)
+ return ret;
+ return 0;
}
AVFilter avfilter_vf_frei0r = {
.priv_size = sizeof(Frei0rContext),
- .inputs = (const AVFilterPad[]) {{ .name = "default",
- .type = AVMEDIA_TYPE_VIDEO,
- .draw_slice = null_draw_slice,
- .config_props = config_input_props,
- .end_frame = end_frame,
- .min_perms = AV_PERM_READ },
- { .name = NULL}},
-
- .outputs = (const AVFilterPad[]) {{ .name = "default",
- .type = AVMEDIA_TYPE_VIDEO, },
- { .name = NULL}},
+ .inputs = (const AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .draw_slice = null_draw_slice,
+ .config_props = config_input_props,
+ .end_frame = end_frame,
+ .min_perms = AV_PERM_READ },
+ { .name = NULL}},
+
+ .outputs = (const AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO, },
+ { .name = NULL}},
};
-static av_cold int source_init(AVFilterContext *ctx, const char *args, void *opaque)
+static av_cold int source_init(AVFilterContext *ctx, const char *args)
{
Frei0rContext *frei0r = ctx->priv;
char dl_name[1024], c;
{
Frei0rContext *frei0r = outlink->src->priv;
AVFilterBufferRef *picref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
+ AVFilterBufferRef *buf_out;
+ int ret;
+
+ if (!picref)
+ return AVERROR(ENOMEM);
+
picref->video->sample_aspect_ratio = (AVRational) {1, 1};
picref->pts = frei0r->pts++;
picref->pos = -1;
- ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0));
+ buf_out = avfilter_ref_buffer(picref, ~0);
+ if (!buf_out) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
+ ret = ff_start_frame(outlink, buf_out);
+ if (ret < 0)
+ goto fail;
+
frei0r->update(frei0r->instance, av_rescale_q(picref->pts, frei0r->time_base, (AVRational){1,1000}),
NULL, (uint32_t *)picref->data[0]);
- ff_draw_slice(outlink, 0, outlink->h, 1);
- ff_end_frame(outlink);
+ ret = ff_draw_slice(outlink, 0, outlink->h, 1);
+ if (ret < 0)
+ goto fail;
+
+ ret = ff_end_frame(outlink);
+
+fail:
avfilter_unref_buffer(picref);
- return 0;
+ return ret;
}
AVFilter avfilter_vsrc_frei0r_src = {
.inputs = (const AVFilterPad[]) {{ .name = NULL}},
- .outputs = (const AVFilterPad[]) {{ .name = "default",
- .type = AVMEDIA_TYPE_VIDEO,
- .request_frame = source_request_frame,
- .config_props = source_config_props },
- { .name = NULL}},
+ .outputs = (const AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .request_frame = source_request_frame,
+ .config_props = source_config_props },
+ { .name = NULL}},
};