avfilter/framesync: allocate FFFrameSyncIn internally
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
@ -42,9 +42,13 @@ static int process_frame(FFFrameSync *fs)
|
|||||||
|
|
||||||
int ff_dualinput_init(AVFilterContext *ctx, FFDualInputContext *s)
|
int ff_dualinput_init(AVFilterContext *ctx, FFDualInputContext *s)
|
||||||
{
|
{
|
||||||
FFFrameSyncIn *in = s->fs.in;
|
FFFrameSyncIn *in;
|
||||||
|
int ret;
|
||||||
|
|
||||||
ff_framesync_init(&s->fs, ctx, 2);
|
if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
in = s->fs.in;
|
||||||
s->fs.opaque = s;
|
s->fs.opaque = s;
|
||||||
s->fs.on_event = process_frame;
|
s->fs.on_event = process_frame;
|
||||||
in[0].time_base = ctx->inputs[0]->time_base;
|
in[0].time_base = ctx->inputs[0]->time_base;
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FFFrameSync fs;
|
FFFrameSync fs;
|
||||||
FFFrameSyncIn second_input; /* must be immediately after fs */
|
|
||||||
|
|
||||||
AVFrame *(*process)(AVFilterContext *ctx, AVFrame *main, const AVFrame *second);
|
AVFrame *(*process)(AVFilterContext *ctx, AVFrame *main, const AVFrame *second);
|
||||||
int shortest; ///< terminate stream when the second input terminates
|
int shortest; ///< terminate stream when the second input terminates
|
||||||
|
@ -46,11 +46,16 @@ enum {
|
|||||||
STATE_EOF,
|
STATE_EOF,
|
||||||
};
|
};
|
||||||
|
|
||||||
void ff_framesync_init(FFFrameSync *fs, void *parent, unsigned nb_in)
|
int ff_framesync_init(FFFrameSync *fs, void *parent, unsigned nb_in)
|
||||||
{
|
{
|
||||||
fs->class = &framesync_class;
|
fs->class = &framesync_class;
|
||||||
fs->parent = parent;
|
fs->parent = parent;
|
||||||
fs->nb_in = nb_in;
|
fs->nb_in = nb_in;
|
||||||
|
|
||||||
|
fs->in = av_calloc(nb_in, sizeof(*fs->in));
|
||||||
|
if (!fs->in)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void framesync_sync_level_update(FFFrameSync *fs)
|
static void framesync_sync_level_update(FFFrameSync *fs)
|
||||||
@ -267,6 +272,8 @@ void ff_framesync_uninit(FFFrameSync *fs)
|
|||||||
av_frame_free(&fs->in[i].frame_next);
|
av_frame_free(&fs->in[i].frame_next);
|
||||||
ff_bufqueue_discard_all(&fs->in[i].queue);
|
ff_bufqueue_discard_all(&fs->in[i].queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
av_freep(&fs->in);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_framesync_process_frame(FFFrameSync *fs, unsigned all)
|
int ff_framesync_process_frame(FFFrameSync *fs, unsigned all)
|
||||||
|
@ -201,9 +201,9 @@ typedef struct FFFrameSync {
|
|||||||
uint8_t eof;
|
uint8_t eof;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of inputs; all inputs must be in consecutive memory
|
* Pointer to array of inputs.
|
||||||
*/
|
*/
|
||||||
FFFrameSyncIn in[1]; /* must be the last field */
|
FFFrameSyncIn *in;
|
||||||
|
|
||||||
} FFFrameSync;
|
} FFFrameSync;
|
||||||
|
|
||||||
@ -215,8 +215,9 @@ typedef struct FFFrameSync {
|
|||||||
* @param fs frame sync structure to initialize
|
* @param fs frame sync structure to initialize
|
||||||
* @param parent parent object, used for logging
|
* @param parent parent object, used for logging
|
||||||
* @param nb_in number of inputs
|
* @param nb_in number of inputs
|
||||||
|
* @return >= 0 for success or a negative error code
|
||||||
*/
|
*/
|
||||||
void ff_framesync_init(FFFrameSync *fs, void *parent, unsigned nb_in);
|
int ff_framesync_init(FFFrameSync *fs, void *parent, unsigned nb_in);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure a frame sync structure.
|
* Configure a frame sync structure.
|
||||||
|
@ -46,7 +46,6 @@ typedef struct MergePlanesContext {
|
|||||||
const AVPixFmtDescriptor *outdesc;
|
const AVPixFmtDescriptor *outdesc;
|
||||||
|
|
||||||
FFFrameSync fs;
|
FFFrameSync fs;
|
||||||
FFFrameSyncIn fsin[3]; /* must be immediately after fs */
|
|
||||||
} MergePlanesContext;
|
} MergePlanesContext;
|
||||||
|
|
||||||
#define OFFSET(x) offsetof(MergePlanesContext, x)
|
#define OFFSET(x) offsetof(MergePlanesContext, x)
|
||||||
@ -174,9 +173,11 @@ static int config_output(AVFilterLink *outlink)
|
|||||||
MergePlanesContext *s = ctx->priv;
|
MergePlanesContext *s = ctx->priv;
|
||||||
InputParam inputsp[4];
|
InputParam inputsp[4];
|
||||||
FFFrameSyncIn *in;
|
FFFrameSyncIn *in;
|
||||||
int i;
|
int i, ret;
|
||||||
|
|
||||||
|
if ((ret = ff_framesync_init(&s->fs, ctx, s->nb_inputs)) < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
ff_framesync_init(&s->fs, ctx, s->nb_inputs);
|
|
||||||
in = s->fs.in;
|
in = s->fs.in;
|
||||||
s->fs.opaque = s;
|
s->fs.opaque = s;
|
||||||
s->fs.on_event = process_frame;
|
s->fs.on_event = process_frame;
|
||||||
|
Reference in New Issue
Block a user