Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/framework/mlt_producer.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ double mlt_producer_get_fps(mlt_producer self)

int mlt_producer_set_in_and_out(mlt_producer self, mlt_position in, mlt_position out)
{

if (self == NULL) {
return 1;
}
if (self->set_in_and_out) {
return self->set_in_and_out(self, in, out);
}
Expand Down
9 changes: 5 additions & 4 deletions src/modules/avformat/filter_avcolour_space.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,11 @@ static mlt_frame filter_process(mlt_filter filter, mlt_frame frame)
// The producer may still change it during get_image.
// This way we do not have to modify each producer to set a valid colorspace.
mlt_properties properties = MLT_FRAME_PROPERTIES(frame);
if (mlt_properties_get_int(properties, "colorspace") <= 0)
mlt_properties_set_int(properties,
"colorspace",
mlt_service_profile(MLT_FILTER_SERVICE(filter))->colorspace);
if (mlt_properties_get_int(properties, "colorspace") <= 0) {
mlt_profile profile = mlt_service_profile(MLT_FILTER_SERVICE(filter));
int colorspace = profile ? profile->colorspace : mlt_colorspace_bt601;
mlt_properties_set_int(properties, "colorspace", colorspace);
}

if (!frame->convert_image)
frame->convert_image = convert_image;
Expand Down
31 changes: 24 additions & 7 deletions src/modules/core/producer_colour.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,21 @@ static int producer_get_image(mlt_frame frame,
// Choose suitable out values if nothing specific requested
if (*format == mlt_image_none || *format == mlt_image_movit)
*format = mlt_image_rgba;
if (*width <= 0)
*width = mlt_service_profile(MLT_PRODUCER_SERVICE(producer))->width;
if (*height <= 0)
*height = mlt_service_profile(MLT_PRODUCER_SERVICE(producer))->height;
if (*width <= 0 || *height <= 0) {
mlt_profile profile = mlt_service_profile(MLT_PRODUCER_SERVICE(producer));
if (profile) {
if (*width <= 0)
*width = profile->width;
if (*height <= 0)
*height = profile->height;
} else {
if (*width <= 0)
*width = 16;
if (*height <= 0)
*height = 16;
}
}


// Choose default image format if specific request is unsupported
if (*format != mlt_image_yuv420p && *format != mlt_image_yuv422 && *format != mlt_image_rgb
Expand Down Expand Up @@ -259,10 +270,16 @@ static int producer_get_frame(mlt_producer producer, mlt_frame_ptr frame, int in
// Set producer-specific frame properties
mlt_properties_set_int(properties, "progressive", 1);
mlt_profile profile = mlt_service_profile(MLT_PRODUCER_SERVICE(producer));
mlt_properties_set_double(properties, "aspect_ratio", mlt_profile_sar(profile));
mlt_properties_set_int(properties, "meta.media.width", profile->width);
mlt_properties_set_int(properties, "meta.media.height", profile->height);
double sar = profile ? mlt_profile_sar(profile) : 1.0;
int pw = profile ? profile->width : 16;
int ph = profile ? profile->height : 16;
mlt_properties_set_double(properties, "aspect_ratio", sar);
mlt_properties_set_int(properties, "meta.media.width", pw);
mlt_properties_set_int(properties, "meta.media.height", ph);




// colour is an alias for resource
if (mlt_properties_get(producer_props, "colour") != NULL)
mlt_properties_set(producer_props,
Expand Down
17 changes: 17 additions & 0 deletions src/modules/gdk/producer_pango.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ static int parse_style(char *style)
}

static PangoFT2FontMap *fontmap = NULL;
static int pango_instance_count = 0;

static void on_fontmap_reload();
mlt_producer producer_pango_init(const char *filename)
Expand All @@ -198,6 +199,7 @@ mlt_producer producer_pango_init(const char *filename)
pthread_mutex_lock(&pango_mutex);
if (fontmap == NULL)
fontmap = (PangoFT2FontMap *) pango_ft2_font_map_new();
pango_instance_count++;
pthread_mutex_unlock(&pango_mutex);

producer->get_frame = producer_get_frame;
Expand Down Expand Up @@ -807,6 +809,21 @@ static void producer_close(mlt_producer parent)
free(self->text);
free(self->font);
free(self->family);

// If this is the last instance, shutdown Pango/Fontconfig resources to avoid leaks in short-lived processes
pthread_mutex_lock(&pango_mutex);
if (pango_instance_count > 0)
pango_instance_count--;
if (pango_instance_count == 0 && fontmap) {
pango_fc_font_map_shutdown(PANGO_FC_FONT_MAP(fontmap));
g_object_unref(fontmap);
fontmap = NULL;
FcFini();
}
pthread_mutex_unlock(&pango_mutex);



parent->close = NULL;
mlt_producer_close(parent);
free(self);
Expand Down
10 changes: 5 additions & 5 deletions src/modules/movit/filter_movit_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,11 +759,11 @@ static mlt_frame process(mlt_filter filter, mlt_frame frame)
// The producer may still change it during get_image.
// This way we do not have to modify each producer to set a valid colorspace.
mlt_properties properties = MLT_FRAME_PROPERTIES(frame);
if (mlt_properties_get_int(properties, "colorspace") <= 0)
mlt_properties_set_int(properties,
"colorspace",
mlt_service_profile(MLT_FILTER_SERVICE(filter))->colorspace);

if (mlt_properties_get_int(properties, "colorspace") <= 0) {
mlt_profile profile = mlt_service_profile(MLT_FILTER_SERVICE(filter));
int colorspace = profile ? profile->colorspace : mlt_colorspace_bt601;
mlt_properties_set_int(properties, "colorspace", colorspace);
}
frame->convert_image = convert_image;

mlt_filter cpu_csc = (mlt_filter) mlt_properties_get_data(MLT_FILTER_PROPERTIES(filter),
Expand Down
21 changes: 20 additions & 1 deletion src/modules/xml/producer_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,9 +753,12 @@ static void on_end_link(deserialise_context context, const xmlChar *name)
mlt_log_error(NULL, "[producer_xml] Invalid top of stack on link close\n");
}

if (service) {
if (service && type == mlt_dummy_producer_type) {
mlt_service_close(service);
free(service);
} else if (service && type != mlt_dummy_producer_type) {
// Not our dummy wrapper; restore stack to avoid freeing real services.
context_push_service(context, service, type);
}
}

Expand All @@ -781,6 +784,22 @@ static void on_end_producer(deserialise_context context, const xmlChar *name)
mlt_service service = context_pop_service(context, &type);
mlt_properties properties = MLT_SERVICE_PROPERTIES(service);

// If the top of stack is a real producer (due to earlier push), consume it,
// then consume and destroy the dummy wrapper underneath.
if (service != NULL && type == mlt_producer_type) {
enum service_type dummy_type = mlt_invalid_type;
mlt_service dummy = context_pop_service(context, &dummy_type);
if (dummy && dummy_type == mlt_dummy_producer_type) {
mlt_service_close(dummy);
free(dummy);
} else if (dummy) {
// Unexpected non-dummy beneath a producer; restore it.
context_push_service(context, dummy, dummy_type);
}
// Producer end tag consumed; do not push producer back.
return;
}

if (service != NULL && type == mlt_dummy_producer_type) {
mlt_service producer = NULL;

Expand Down