[FFmpeg-devel] [PATCH 1/2] avfilter/framesync: allocate FFFrameSyncIn internally
Paul B Mahol
onemda at gmail.com
Mon Oct 7 13:02:40 CEST 2013
On 10/7/13, Stefano Sabatini <stefasab at gmail.com> wrote:
> On date Saturday 2013-10-05 20:19:23 +0000, Paul B Mahol encoded:
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>> libavfilter/dualinput.c | 8 ++++++--
>> libavfilter/dualinput.h | 1 -
>> libavfilter/framesync.c | 9 ++++++++-
>> libavfilter/framesync.h | 7 ++++---
>> 4 files changed, 18 insertions(+), 7 deletions(-)
>>
>> diff --git a/libavfilter/dualinput.c b/libavfilter/dualinput.c
>> index 97e15cb..5e6432a 100644
>> --- a/libavfilter/dualinput.c
>> +++ b/libavfilter/dualinput.c
>> @@ -42,9 +42,13 @@ static int process_frame(FFFrameSync *fs)
>>
>> 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.on_event = process_frame;
>> in[0].time_base = ctx->inputs[0]->time_base;
>> diff --git a/libavfilter/dualinput.h b/libavfilter/dualinput.h
>> index 0ec0ea7..5ff23e6 100644
>> --- a/libavfilter/dualinput.h
>> +++ b/libavfilter/dualinput.h
>> @@ -31,7 +31,6 @@
>>
>> typedef struct {
>> FFFrameSync fs;
>> - FFFrameSyncIn second_input; /* must be immediately after fs */
>>
>> AVFrame *(*process)(AVFilterContext *ctx, AVFrame *main, const
>> AVFrame *second);
>> int shortest; ///< terminate stream when the second
>> input terminates
>> diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c
>> index 12db50c..bdac40b 100644
>> --- a/libavfilter/framesync.c
>> +++ b/libavfilter/framesync.c
>> @@ -46,11 +46,16 @@ enum {
>> 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->parent = parent;
>> 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)
>> @@ -267,6 +272,8 @@ void ff_framesync_uninit(FFFrameSync *fs)
>> av_frame_free(&fs->in[i].frame_next);
>> ff_bufqueue_discard_all(&fs->in[i].queue);
>> }
>> +
>> + av_freep(&fs->in);
>> }
>>
>> int ff_framesync_process_frame(FFFrameSync *fs, unsigned all)
>> diff --git a/libavfilter/framesync.h b/libavfilter/framesync.h
>> index 2072781..7ba99d5 100644
>> --- a/libavfilter/framesync.h
>> +++ b/libavfilter/framesync.h
>> @@ -201,9 +201,9 @@ typedef struct FFFrameSync {
>> 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;
>>
>> @@ -215,8 +215,9 @@ typedef struct FFFrameSync {
>> * @param fs frame sync structure to initialize
>> * @param parent parent object, used for logging
>> * @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);
>
> Don't you need to update other users as well?
What other users?
The one and only user, dualinput, have been updated.
>
> LGTM if tested otherwise.
> --
> FFmpeg = Freak & Faithful Murdering Proud Extroverse Gorilla
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list