Skip to content

Commit

Permalink
fix #837 high memory with frei0r plugins that allocate
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Nov 1, 2022
1 parent 640266b commit b18f280
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/modules/frei0r/frei0r_helper.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* frei0r_helper.c -- frei0r helper
* Copyright (c) 2008 Marco Gittler <[email protected]>
* Copyright (C) 2009-2020 Meltytech, LLC
* Copyright (C) 2009-2022 Meltytech, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -78,6 +78,20 @@ static int f0r_update2_slice( int id, int index, int count, void *context )
return 0;
}

static void destruct_ctor(mlt_properties prop)
{
void (*f0r_destruct) (f0r_instance_t instance) = mlt_properties_get_data(prop, "f0r_destruct", NULL);
for (int i = 0; i < mlt_properties_count(prop); i++) {
if (strstr(mlt_properties_get_name(prop, i), "ctor-")) {
void *inst = mlt_properties_get_data(prop, mlt_properties_get_name(prop, i), NULL);
if (inst) {
f0r_destruct((f0r_instance_t) inst);
mlt_properties_clear(prop, mlt_properties_get_name(prop, i));
}
}
}
}

int process_frei0r_item( mlt_service service, mlt_position position, double time,
int length, mlt_frame frame, uint8_t **image, int *width, int *height )
{
Expand Down Expand Up @@ -136,6 +150,7 @@ int process_frei0r_item( mlt_service service, mlt_position position, double time

f0r_instance_t inst = mlt_properties_get_data(prop, ctorname, NULL);
if (!inst) {
destruct_ctor(prop);
inst = f0r_construct(*width, slice_height);
mlt_properties_set_data(prop, ctorname, inst, 0, NULL, NULL);
}
Expand Down

0 comments on commit b18f280

Please sign in to comment.