You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
lavfi: add a preinit callback to filters.
It is necessary for filters with child objects, to set the class and default options values.
This commit is contained in:
@@ -692,6 +692,7 @@ static int default_execute(AVFilterContext *ctx, avfilter_action_func *func, voi
|
|||||||
AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
|
AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
|
||||||
{
|
{
|
||||||
AVFilterContext *ret;
|
AVFilterContext *ret;
|
||||||
|
int preinited = 0;
|
||||||
|
|
||||||
if (!filter)
|
if (!filter)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -708,6 +709,11 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
|
|||||||
if (!ret->priv)
|
if (!ret->priv)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
if (filter->preinit) {
|
||||||
|
if (filter->preinit(ret) < 0)
|
||||||
|
goto err;
|
||||||
|
preinited = 1;
|
||||||
|
}
|
||||||
|
|
||||||
av_opt_set_defaults(ret);
|
av_opt_set_defaults(ret);
|
||||||
if (filter->priv_class) {
|
if (filter->priv_class) {
|
||||||
@@ -745,6 +751,8 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
if (preinited)
|
||||||
|
filter->uninit(ret);
|
||||||
av_freep(&ret->inputs);
|
av_freep(&ret->inputs);
|
||||||
av_freep(&ret->input_pads);
|
av_freep(&ret->input_pads);
|
||||||
ret->nb_inputs = 0;
|
ret->nb_inputs = 0;
|
||||||
|
@@ -194,6 +194,21 @@ typedef struct AVFilter {
|
|||||||
*****************************************************************
|
*****************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter pre-initialization function
|
||||||
|
*
|
||||||
|
* This callback will be called immediately after the filter context is
|
||||||
|
* allocated, to allow allocating and initing sub-objects.
|
||||||
|
*
|
||||||
|
* If this callback is not NULL, the uninit callback will be called on
|
||||||
|
* allocation failure.
|
||||||
|
*
|
||||||
|
* @return 0 on success,
|
||||||
|
* AVERROR code on failure (but the code will be
|
||||||
|
* dropped and treated as ENOMEM by the calling code)
|
||||||
|
*/
|
||||||
|
int (*preinit)(AVFilterContext *ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter initialization function.
|
* Filter initialization function.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user