]> git.sesse.net Git - movit/blobdiff - effect_chain.cpp
Add edge information about odd things, such as bounces, resizes and non-standard...
[movit] / effect_chain.cpp
index 1d84e897add7d95eeeba77267f90dba631743744..63fcdac68fc8f1a019f179cb664fee243641feb8 100644 (file)
@@ -414,6 +414,68 @@ 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<std::string> 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_709:
+                               labels.push_back("spc[rec709]");
+                               break;
+                       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 +515,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).