Re: [FFmpeg-devel] [PATCH] avfilter/vf_paletteuse: don't constantly free and realloc internal frames
On 1/17/2019 12:51 PM, Clément Bœsch wrote: > On Tue, Jan 15, 2019 at 01:14:34AM -0300, James Almer wrote: >> Signed-off-by: James Almer >> --- >> libavfilter/vf_paletteuse.c | 16 ++-- >> 1 file changed, 10 insertions(+), 6 deletions(-) >> >> diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c >> index 5966f10685..289c663e8e 100644 >> --- a/libavfilter/vf_paletteuse.c >> +++ b/libavfilter/vf_paletteuse.c >> @@ -814,7 +814,7 @@ static void set_processing_window(enum diff_mode >> diff_mode, >> int width = cur_src->width; >> int height = cur_src->height; >> >> -if (prv_src && diff_mode == DIFF_MODE_RECTANGLE) { >> +if (prv_src->data[0] && diff_mode == DIFF_MODE_RECTANGLE) { >> int y; >> int x_end = cur_src->width - 1, >> y_end = cur_src->height - 1; >> @@ -911,11 +911,10 @@ static int apply_palette(AVFilterLink *inlink, AVFrame >> *in, AVFrame **outf) >> >> set_processing_window(s->diff_mode, s->last_in, in, >>s->last_out, out, , , , ); >> -av_frame_free(>last_in); >> -av_frame_free(>last_out); >> -s->last_in = av_frame_clone(in); >> -s->last_out = av_frame_clone(out); >> -if (!s->last_in || !s->last_out || >> +av_frame_unref(s->last_in); >> +av_frame_unref(s->last_out); >> +if (av_frame_ref(s->last_in, in) < 0 || >> +av_frame_ref(s->last_out, out) < 0 || >> av_frame_make_writable(s->last_in) < 0) { >> av_frame_free(); >> av_frame_free(); >> @@ -1086,6 +1085,11 @@ static av_cold int init(AVFilterContext *ctx) >> { >> PaletteUseContext *s = ctx->priv; >> >> +s->last_in = av_frame_alloc(); >> +s->last_out = av_frame_alloc(); >> +if (!s->last_in || !s->last_out) >> +return AVERROR(ENOMEM); >> + >> s->set_frame = set_frame_lut[s->color_search_method][s->dither]; >> >> if (s->dither == DITHERING_BAYER) { > > LGTM, thanks Pushed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter/vf_paletteuse: don't constantly free and realloc internal frames
On Tue, Jan 15, 2019 at 01:14:34AM -0300, James Almer wrote: > Signed-off-by: James Almer > --- > libavfilter/vf_paletteuse.c | 16 ++-- > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c > index 5966f10685..289c663e8e 100644 > --- a/libavfilter/vf_paletteuse.c > +++ b/libavfilter/vf_paletteuse.c > @@ -814,7 +814,7 @@ static void set_processing_window(enum diff_mode > diff_mode, > int width = cur_src->width; > int height = cur_src->height; > > -if (prv_src && diff_mode == DIFF_MODE_RECTANGLE) { > +if (prv_src->data[0] && diff_mode == DIFF_MODE_RECTANGLE) { > int y; > int x_end = cur_src->width - 1, > y_end = cur_src->height - 1; > @@ -911,11 +911,10 @@ static int apply_palette(AVFilterLink *inlink, AVFrame > *in, AVFrame **outf) > > set_processing_window(s->diff_mode, s->last_in, in, >s->last_out, out, , , , ); > -av_frame_free(>last_in); > -av_frame_free(>last_out); > -s->last_in = av_frame_clone(in); > -s->last_out = av_frame_clone(out); > -if (!s->last_in || !s->last_out || > +av_frame_unref(s->last_in); > +av_frame_unref(s->last_out); > +if (av_frame_ref(s->last_in, in) < 0 || > +av_frame_ref(s->last_out, out) < 0 || > av_frame_make_writable(s->last_in) < 0) { > av_frame_free(); > av_frame_free(); > @@ -1086,6 +1085,11 @@ static av_cold int init(AVFilterContext *ctx) > { > PaletteUseContext *s = ctx->priv; > > +s->last_in = av_frame_alloc(); > +s->last_out = av_frame_alloc(); > +if (!s->last_in || !s->last_out) > +return AVERROR(ENOMEM); > + > s->set_frame = set_frame_lut[s->color_search_method][s->dither]; > > if (s->dither == DITHERING_BAYER) { LGTM, thanks -- Clément B. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avfilter/vf_paletteuse: don't constantly free and realloc internal frames
Signed-off-by: James Almer --- libavfilter/vf_paletteuse.c | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c index 5966f10685..289c663e8e 100644 --- a/libavfilter/vf_paletteuse.c +++ b/libavfilter/vf_paletteuse.c @@ -814,7 +814,7 @@ static void set_processing_window(enum diff_mode diff_mode, int width = cur_src->width; int height = cur_src->height; -if (prv_src && diff_mode == DIFF_MODE_RECTANGLE) { +if (prv_src->data[0] && diff_mode == DIFF_MODE_RECTANGLE) { int y; int x_end = cur_src->width - 1, y_end = cur_src->height - 1; @@ -911,11 +911,10 @@ static int apply_palette(AVFilterLink *inlink, AVFrame *in, AVFrame **outf) set_processing_window(s->diff_mode, s->last_in, in, s->last_out, out, , , , ); -av_frame_free(>last_in); -av_frame_free(>last_out); -s->last_in = av_frame_clone(in); -s->last_out = av_frame_clone(out); -if (!s->last_in || !s->last_out || +av_frame_unref(s->last_in); +av_frame_unref(s->last_out); +if (av_frame_ref(s->last_in, in) < 0 || +av_frame_ref(s->last_out, out) < 0 || av_frame_make_writable(s->last_in) < 0) { av_frame_free(); av_frame_free(); @@ -1086,6 +1085,11 @@ static av_cold int init(AVFilterContext *ctx) { PaletteUseContext *s = ctx->priv; +s->last_in = av_frame_alloc(); +s->last_out = av_frame_alloc(); +if (!s->last_in || !s->last_out) +return AVERROR(ENOMEM); + s->set_frame = set_frame_lut[s->color_search_method][s->dither]; if (s->dither == DITHERING_BAYER) { -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel