Skip to content

Commit

Permalink
fix movit transition with non-movit filter on input
Browse files Browse the repository at this point in the history
The chain fingerprint code did not handle the situation where one of its
inputs could change. In this case, it was a transition whose inputs were
not from the same chain: a non-movit filter interrupts it.
`filter_movit_convert.cpp:set_movit_parameters()` would fail to locate
the input, not set the pixel data, and return making rendering non-
deterministic.

https://forum.shotcut.org/t/text-simple-bug-with-gpu-efx-on/43892
  • Loading branch information
ddennedy committed May 6, 2024
1 parent fd4d9ad commit ef36d29
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.14)

project(MLT
VERSION 7.24.0
VERSION 7.25.0
DESCRIPTION "Multimedia Framework"
HOMEPAGE_URL "https://www.mltframework.org"
LANGUAGES C CXX
Expand Down
2 changes: 1 addition & 1 deletion src/framework/mlt_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define MLT_STRINGIZE(s) MLT_STRINGIZE2(s)

#define LIBMLT_VERSION_MAJOR 7
#define LIBMLT_VERSION_MINOR 24
#define LIBMLT_VERSION_MINOR 25
#define LIBMLT_VERSION_REVISION 0
#define LIBMLT_VERSION_INT \
((LIBMLT_VERSION_MAJOR << 16) + (LIBMLT_VERSION_MINOR << 8) + LIBMLT_VERSION_REVISION)
Expand Down
17 changes: 1 addition & 16 deletions src/modules/movit/filter_glsl_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* filter_glsl_manager.cpp
* Copyright (C) 2011-2012 Christophe Thommeret <hftom@free.fr>
* Copyright (C) 2013-2023 Dan Dennedy <dan@dennedy.org>
* Copyright (C) 2013-2024 Dan Dennedy <dan@dennedy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -19,7 +19,6 @@
*/

#include "filter_glsl_manager.h"
#include "mlt_flip_effect.h"
#include "mlt_movit_input.h"
#include <effect_chain.h>
#include <init.h>
Expand Down Expand Up @@ -265,20 +264,6 @@ void GlslManager::onClose(mlt_properties owner, GlslManager *filter, mlt_event_d
filter->cleanupContext();
}

void GlslManager::onServiceChanged(mlt_properties owner, mlt_service aservice)
{
Mlt::Service service(aservice);
service.lock();
service.set("movit chain", NULL, 0);
service.unlock();
}

void GlslManager::onPropertyChanged(mlt_properties owner, mlt_service service, const char *property)
{
if (property && std::string(property) == "disable")
onServiceChanged(owner, service);
}

extern "C" {

mlt_filter filter_glsl_manager_init(mlt_profile profile,
Expand Down
4 changes: 1 addition & 3 deletions src/modules/movit/filter_glsl_manager.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* filter_glsl_manager.h
* Copyright (C) 2013-2023 Dan Dennedy <dan@dennedy.org>
* Copyright (C) 2013-2024 Dan Dennedy <dan@dennedy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -141,8 +141,6 @@ class GlslManager : public Mlt::Filter

static void onInit(mlt_properties owner, GlslManager *filter, mlt_event_data);
static void onClose(mlt_properties owner, GlslManager *filter, mlt_event_data);
static void onServiceChanged(mlt_properties owner, mlt_service service);
static void onPropertyChanged(mlt_properties owner, mlt_service service, const char *property);
movit::ResourcePool *resource_pool;
Mlt::Deque texture_list;
Mlt::Deque syncs_to_delete;
Expand Down
31 changes: 19 additions & 12 deletions src/modules/movit/filter_movit_convert.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* filter_movit_convert.cpp
* Copyright (C) 2013-2023 Dan Dennedy <dan@dennedy.org>
* Copyright (C) 2013-2024 Dan Dennedy <dan@dennedy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -205,31 +205,38 @@ static void get_format_from_properties(mlt_properties properties,
ycbcr_format->cb_y_position = ycbcr_format->cr_y_position = 0.5f;
}

static void build_fingerprint(mlt_service service, mlt_frame frame, std::string *fingerprint)
static void build_fingerprint(GlslChain *chain,
mlt_service service,
mlt_frame frame,
std::string *fingerprint)
{
if (service == (mlt_service) -1) {
fingerprint->append("input");
mlt_producer producer = mlt_producer_cut_parent(mlt_frame_get_original_producer(frame));
if (producer && chain && chain->inputs[producer])
fingerprint->append(mlt_properties_get(MLT_PRODUCER_PROPERTIES(producer), "_unique_id"));
else
fingerprint->append("input");
return;
}

mlt_service input_a = GlslManager::get_effect_input(service, frame);
fingerprint->push_back('(');
build_fingerprint(input_a, frame, fingerprint);
build_fingerprint(chain, input_a, frame, fingerprint);
fingerprint->push_back(')');

mlt_frame frame_b;
mlt_service input_b;
GlslManager::get_effect_secondary_input(service, frame, &input_b, &frame_b);
if (input_b) {
fingerprint->push_back('(');
build_fingerprint(input_b, frame_b, fingerprint);
build_fingerprint(chain, input_b, frame_b, fingerprint);
fingerprint->push_back(')');
}

GlslManager::get_effect_third_input(service, frame, &input_b, &frame_b);
if (input_b) {
fingerprint->push_back('(');
build_fingerprint(input_b, frame_b, fingerprint);
build_fingerprint(chain, input_b, frame_b, fingerprint);
fingerprint->push_back(')');
}

Expand Down Expand Up @@ -321,15 +328,15 @@ static void finalize_movit_chain(mlt_service leaf_service, mlt_frame frame, mlt_
GlslChain *chain = GlslManager::get_chain(leaf_service);

std::string new_fingerprint;
build_fingerprint(leaf_service, frame, &new_fingerprint);
build_fingerprint(chain, leaf_service, frame, &new_fingerprint);

// Build the chain if needed.
if (!chain || new_fingerprint != chain->fingerprint) {
mlt_log_debug(leaf_service,
"=== CREATING NEW CHAIN (old chain=%p, leaf=%p, fingerprint=%s) ===\n",
chain,
leaf_service,
new_fingerprint.c_str());
mlt_log_info(leaf_service,
"=== CREATING NEW CHAIN (old chain=%p, leaf=%p, fingerprint=%s) ===\n",
chain,
leaf_service,
new_fingerprint.c_str());
mlt_profile profile = mlt_service_profile(leaf_service);
chain = new GlslChain;
chain->effect_chain = new EffectChain(profile->display_aspect_num,
Expand Down
1 change: 1 addition & 0 deletions src/modules/qt/filter_qtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ static int filter_get_image(mlt_frame frame,
mlt_properties filter_properties = get_filter_properties(filter, frame);
mlt_profile profile = mlt_service_profile(MLT_FILTER_SERVICE(filter));
mlt_position position = mlt_filter_get_position(filter, frame);
mlt_log_info(MLT_FILTER_SERVICE(filter), "get_image %p %d\n", filter, position);
mlt_position length = mlt_filter_get_length2(filter, frame);
bool isRichText = qstrlen(mlt_properties_get(filter_properties, "html")) > 0
|| qstrlen(mlt_properties_get(filter_properties, "resource")) > 0;
Expand Down

0 comments on commit ef36d29

Please sign in to comment.