X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=effect_chain.cpp;h=cb7c52caa6cbd831642c1960e8bf701aca277684;hp=dd7a652804b4fc119019545fcd45744999a7ffd3;hb=a616ded3842994840ce0cfa365d259f602493779;hpb=5e05605a85a15944b95d7000745446756cdcbfa8 diff --git a/effect_chain.cpp b/effect_chain.cpp index dd7a652..cb7c52c 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -51,10 +51,7 @@ EffectChain::~EffectChain() Input *EffectChain::add_input(Input *input) { inputs.push_back(input); - - Node *node = add_node(input); - node->output_color_space = input->get_color_space(); - node->output_gamma_curve = input->get_gamma_curve(); + add_node(input); return input; } @@ -648,6 +645,21 @@ void EffectChain::topological_sort_visit_node(Node *node, std::set *visi sorted_list->push_back(node); } +void EffectChain::find_color_spaces_for_inputs() +{ + for (unsigned i = 0; i < nodes.size(); ++i) { + Node *node = nodes[i]; + if (node->disabled) { + continue; + } + if (node->incoming_links.size() == 0) { + Input *input = static_cast(node->effect); + node->output_color_space = input->get_color_space(); + node->output_gamma_curve = input->get_gamma_curve(); + } + } +} + // Propagate gamma and color space information as far as we can in the graph. // The rules are simple: Anything where all the inputs agree, get that as // output as well. Anything else keeps having *_INVALID. @@ -992,9 +1004,12 @@ void EffectChain::finalize() } output_dot("step1-rewritten.dot"); - propagate_gamma_and_color_space(); + find_color_spaces_for_inputs(); output_dot("step2-propagated.dot"); + propagate_gamma_and_color_space(); + output_dot("step3-propagated.dot"); + fix_internal_color_spaces(); fix_output_color_space(); output_dot("step4-output-colorspacefix.dot");