]> git.sesse.net Git - nageru/blobdiff - flow_main.cpp
Allow symlinked frame files. Useful for testing.
[nageru] / flow_main.cpp
index d8cf4773f59e6c07d2b5b6a031b2b5103d7e7ff3..dc82d229ca8b121bcb92496b7a7114ac8b06a1a6 100644 (file)
@@ -1,6 +1,8 @@
 #define NO_SDL_GLEXT 1
 
-#include <epoxy/gl.h>
+#include "flow.h"
+#include "gpu_timers.h"
+#include "util.h"
 
 #include <SDL2/SDL.h>
 #include <SDL2/SDL_error.h>
 #include <SDL2/SDL_keyboard.h>
 #include <SDL2/SDL_mouse.h>
 #include <SDL2/SDL_video.h>
-
-#include <assert.h>
-#include <getopt.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "flow.h"
-#include "gpu_timers.h"
-#include "util.h"
-
 #include <algorithm>
+#include <assert.h>
 #include <deque>
-#include <memory>
+#include <epoxy/gl.h>
+#include <getopt.h>
 #include <map>
+#include <memory>
 #include <stack>
+#include <stdio.h>
+#include <unistd.h>
 #include <vector>
 
 #define BUFFER_OFFSET(i) ((char *)nullptr + (i))
@@ -264,15 +261,15 @@ void compute_flow_only(int argc, char **argv, int optind)
        glCreateTextures(GL_TEXTURE_2D_ARRAY, 1, &tex_gray);
        glTextureStorage3D(tex_gray, levels, GL_R8, width1, height1, 2);
 
-       GrayscaleConversion gray;
-       gray.exec(image_tex, tex_gray, width1, height1, /*num_layers=*/2);
-       glGenerateTextureMipmap(tex_gray);
-
        OperatingPoint op = operating_point3;
        if (!enable_variational_refinement) {
                op.variational_refinement = false;
        }
-       DISComputeFlow compute_flow(width1, height1, op);
+
+       DISComputeFlow compute_flow(width1, height1, op);  // Must be initialized before gray.
+       GrayscaleConversion gray;
+       gray.exec(image_tex, tex_gray, width1, height1, /*num_layers=*/2);
+       glGenerateTextureMipmap(tex_gray);
 
        if (enable_warmup) {
                in_warmup = true;
@@ -379,7 +376,7 @@ void interpolate_image(int argc, char **argv, int optind)
        }
        DISComputeFlow compute_flow(width1, height1, op);
        GrayscaleConversion gray;
-       Interpolate interpolate(width1, height1, op);
+       Interpolate interpolate(op, /*split_ycbcr_output=*/false);
 
        GLuint tex_gray;
        glCreateTextures(GL_TEXTURE_2D_ARRAY, 1, &tex_gray);
@@ -391,7 +388,7 @@ void interpolate_image(int argc, char **argv, int optind)
                in_warmup = true;
                for (int i = 0; i < 10; ++i) {
                        GLuint bidirectional_flow_tex = compute_flow.exec(tex_gray, DISComputeFlow::FORWARD_AND_BACKWARD, DISComputeFlow::DO_NOT_RESIZE_FLOW);
-                       GLuint interpolated_tex = interpolate.exec(image_tex, tex_gray, bidirectional_flow_tex, width1, height1, 0.5f);
+                       GLuint interpolated_tex = interpolate.exec(image_tex, tex_gray, bidirectional_flow_tex, width1, height1, 0.5f).first;
                        compute_flow.release_texture(bidirectional_flow_tex);
                        interpolate.release_texture(interpolated_tex);
                }
@@ -405,7 +402,7 @@ void interpolate_image(int argc, char **argv, int optind)
                snprintf(ppm_filename, sizeof(ppm_filename), "interp%04d.ppm", frameno);
 
                float alpha = frameno / 60.0f;
-               GLuint interpolated_tex = interpolate.exec(image_tex, tex_gray, bidirectional_flow_tex, width1, height1, alpha);
+               GLuint interpolated_tex = interpolate.exec(image_tex, tex_gray, bidirectional_flow_tex, width1, height1, alpha).first;
 
                schedule_read<RGBAType>(interpolated_tex, width1, height1, filename0, filename1, "", ppm_filename);
                interpolate.release_texture(interpolated_tex);
@@ -418,7 +415,7 @@ void interpolate_image(int argc, char **argv, int optind)
 
 int main(int argc, char **argv)
 {
-        static const option long_options[] = {
+       static const option long_options[] = {
                { "smoothness-relative-weight", required_argument, 0, 's' },  // alpha.
                { "intensity-relative-weight", required_argument, 0, 'i' },  // delta.
                { "gradient-relative-weight", required_argument, 0, 'g' },  // gamma.