From: Steinar H. Gunderson Date: Tue, 1 Sep 2015 23:02:38 +0000 (+0200) Subject: Propagate size correctly across effects that change output size. X-Git-Tag: 1.2.0~32 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=4a35c01ed5407a3d9b9616f9d13e77970ee003ef;ds=sidebyside Propagate size correctly across effects that change output size. When propagating size information between effects in a phase, we'd forget to check if the effect wanted to change size and use that information instead of our own heuristics. Fix that. This is currently a no-op, since right now we always break a phase when an effect changes output size, but there are very real situations where we'd be fine with not doing so, so this patch paves the way for that. --- diff --git a/effect_chain.cpp b/effect_chain.cpp index d33cdae..870da81 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -623,7 +623,8 @@ void EffectChain::inform_input_sizes(Phase *phase) // Now propagate from the inputs towards the end, and inform as we go. // The rules are simple: // - // 1. Don't touch effects that already have given sizes (ie., inputs). + // 1. Don't touch effects that already have given sizes (ie., inputs + // or effects that change the output size). // 2. If all of your inputs have the same size, that will be your output size. // 3. Otherwise, your output size is 0x0. for (unsigned i = 0; i < phase->effects.size(); ++i) { @@ -645,8 +646,16 @@ void EffectChain::inform_input_sizes(Phase *phase) this_output_height = 0; } } - node->output_width = this_output_width; - node->output_height = this_output_height; + if (node->effect->changes_output_size()) { + // We cannot call get_output_size() before we've done inform_input_size() + // on all inputs. + unsigned real_width_ignored, real_height_ignored; + node->effect->get_output_size(&real_width_ignored, &real_height_ignored, + &node->output_width, &node->output_height); + } else { + node->output_width = this_output_width; + node->output_height = this_output_height; + } } }