X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=effect_chain.cpp;h=9aaa74829041028090079ed8d511abe8e4edd2dd;hp=f6266d741e63c0308ea841952a6ec23816f30406;hb=c59abdb997a1d1d703ac5dd71513dea03628a53e;hpb=3702fd5c7d6121bab0ff5726804e6591038406b3 diff --git a/effect_chain.cpp b/effect_chain.cpp index f6266d7..9aaa748 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -666,10 +666,49 @@ void EffectChain::find_output_size(Phase *phase) return; } + // If all effects have the same size, use that. unsigned output_width = 0, output_height = 0; + bool all_inputs_same_size = true; - // If not, look at the input phases and textures. - // We select the largest one (by fit into the current aspect). + for (unsigned i = 0; i < phase->inputs.size(); ++i) { + Node *input = phase->inputs[i]; + assert(input->phase->output_width != 0); + assert(input->phase->output_height != 0); + if (output_width == 0 && output_height == 0) { + output_width = input->phase->output_width; + output_height = input->phase->output_height; + } else if (output_width != input->phase->output_width || + output_height != input->phase->output_height) { + all_inputs_same_size = false; + } + } + for (unsigned i = 0; i < phase->effects.size(); ++i) { + Effect *effect = phase->effects[i]->effect; + if (effect->num_inputs() != 0) { + continue; + } + + Input *input = static_cast(effect); + if (output_width == 0 && output_height == 0) { + output_width = input->get_width(); + output_height = input->get_height(); + } else if (output_width != input->get_width() || + output_height != input->get_height()) { + all_inputs_same_size = false; + } + } + + if (all_inputs_same_size) { + assert(output_width != 0); + assert(output_height != 0); + phase->output_width = output_width; + phase->output_height = output_height; + return; + } + + // If not, fit all the inputs into the current aspect, and select the largest one. + output_width = 0; + output_height = 0; for (unsigned i = 0; i < phase->inputs.size(); ++i) { Node *input = phase->inputs[i]; assert(input->phase->output_width != 0);