X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=effect_chain.cpp;h=aae2941f791ca86faf9ce16cea4912cd9c05fd1b;hb=fdad0932f08649e69e824ee73a787671a5bc93a5;hp=1d84e897add7d95eeeba77267f90dba631743744;hpb=367d5fc610b4111fbf036b0d32becee9118403b2;p=movit diff --git a/effect_chain.cpp b/effect_chain.cpp index 1d84e89..aae2941 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -414,6 +414,65 @@ void EffectChain::construct_glsl_programs(Node *output) std::reverse(phases.begin(), phases.end()); } +void EffectChain::output_dot(const char *filename) +{ + FILE *fp = fopen(filename, "w"); + if (fp == NULL) { + perror(filename); + exit(1); + } + + fprintf(fp, "digraph G {\n"); + for (unsigned i = 0; i < nodes.size(); ++i) { + fprintf(fp, " n%ld [label=\"%s\"];\n", (long)nodes[i], nodes[i]->effect->effect_type_id().c_str()); + for (unsigned j = 0; j < nodes[i]->outgoing_links.size(); ++j) { + std::vector labels; + + if (nodes[i]->outgoing_links[j]->effect->needs_texture_bounce()) { + labels.push_back("needs_bounce"); + } + if (nodes[i]->effect->changes_output_size()) { + labels.push_back("resize"); + } + + switch (nodes[i]->output_color_space) { + case COLORSPACE_REC_601_525: + labels.push_back("spc[rec601-525]"); + break; + case COLORSPACE_REC_601_625: + labels.push_back("spc[rec601-625]"); + break; + default: + break; + } + + switch (nodes[i]->output_gamma_curve) { + case GAMMA_sRGB: + labels.push_back("gamma[sRGB]"); + break; + case GAMMA_REC_601: // and GAMMA_REC_709 + labels.push_back("gamma[rec601/709]"); + break; + default: + break; + } + + if (labels.empty()) { + fprintf(fp, " n%ld -> n%ld;\n", (long)nodes[i], (long)nodes[i]->outgoing_links[j]); + } else { + std::string label = labels[0]; + for (unsigned k = 1; k < labels.size(); ++k) { + label += ", " + labels[k]; + } + fprintf(fp, " n%ld -> n%ld [label=\"%s\"];\n", (long)nodes[i], (long)nodes[i]->outgoing_links[j], label.c_str()); + } + } + } + fprintf(fp, "}\n"); + + fclose(fp); +} + void EffectChain::find_output_size(Phase *phase) { Node *output_node = phase->effects.back(); @@ -453,6 +512,8 @@ void EffectChain::find_output_size(Phase *phase) void EffectChain::finalize() { + output_dot("final.dot"); + // Find the output effect. This is, simply, one that has no outgoing links. // If there are multiple ones, the graph is malformed (we do not support // multiple outputs right now).