mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-28 12:32:17 +02:00
avfilter/vf_paletteuse: don't constantly free and realloc internal frames
Reviewed-by: Clément Bœsch <u@pkh.me> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
f60fdbc960
commit
af05070ddf
@ -814,7 +814,7 @@ static void set_processing_window(enum diff_mode diff_mode,
|
|||||||
int width = cur_src->width;
|
int width = cur_src->width;
|
||||||
int height = cur_src->height;
|
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 y;
|
||||||
int x_end = cur_src->width - 1,
|
int x_end = cur_src->width - 1,
|
||||||
y_end = cur_src->height - 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,
|
set_processing_window(s->diff_mode, s->last_in, in,
|
||||||
s->last_out, out, &x, &y, &w, &h);
|
s->last_out, out, &x, &y, &w, &h);
|
||||||
av_frame_free(&s->last_in);
|
av_frame_unref(s->last_in);
|
||||||
av_frame_free(&s->last_out);
|
av_frame_unref(s->last_out);
|
||||||
s->last_in = av_frame_clone(in);
|
if (av_frame_ref(s->last_in, in) < 0 ||
|
||||||
s->last_out = av_frame_clone(out);
|
av_frame_ref(s->last_out, out) < 0 ||
|
||||||
if (!s->last_in || !s->last_out ||
|
|
||||||
av_frame_make_writable(s->last_in) < 0) {
|
av_frame_make_writable(s->last_in) < 0) {
|
||||||
av_frame_free(&in);
|
av_frame_free(&in);
|
||||||
av_frame_free(&out);
|
av_frame_free(&out);
|
||||||
@ -1086,6 +1085,14 @@ static av_cold int init(AVFilterContext *ctx)
|
|||||||
{
|
{
|
||||||
PaletteUseContext *s = ctx->priv;
|
PaletteUseContext *s = ctx->priv;
|
||||||
|
|
||||||
|
s->last_in = av_frame_alloc();
|
||||||
|
s->last_out = av_frame_alloc();
|
||||||
|
if (!s->last_in || !s->last_out) {
|
||||||
|
av_frame_free(&s->last_in);
|
||||||
|
av_frame_free(&s->last_out);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
s->set_frame = set_frame_lut[s->color_search_method][s->dither];
|
s->set_frame = set_frame_lut[s->color_search_method][s->dither];
|
||||||
|
|
||||||
if (s->dither == DITHERING_BAYER) {
|
if (s->dither == DITHERING_BAYER) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user