]> git.sesse.net Git - movit/blobdiff - deconvolution_sharpen_effect.cpp
Stop using BGR, BGRA and grayscale formats.
[movit] / deconvolution_sharpen_effect.cpp
index 260266403852a2beb22232e29924d4c25a873b2d..c4ad5cd2cd699b65c223d505dc0fd88932b4e3e1 100644 (file)
@@ -4,7 +4,7 @@
 
 #include <Eigen/Dense>
 #include <Eigen/Cholesky>
-#include <GL/glew.h>
+#include <epoxy/gl.h>
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
 #include <new>
 
 #include "deconvolution_sharpen_effect.h"
+#include "effect_util.h"
 #include "util.h"
 
 using namespace Eigen;
+using namespace std;
+
+namespace movit {
 
 DeconvolutionSharpenEffect::DeconvolutionSharpenEffect()
        : R(5),
@@ -36,7 +40,7 @@ DeconvolutionSharpenEffect::DeconvolutionSharpenEffect()
        register_float("noise", &noise);
 }
 
-std::string DeconvolutionSharpenEffect::output_fragment_shader()
+string DeconvolutionSharpenEffect::output_fragment_shader()
 {
        char buf[256];
        sprintf(buf, "#define R %u\n", R);
@@ -169,10 +173,10 @@ MatrixXf convolve(const MatrixXf &a, const MatrixXf &b)
                        int xa_max = xr;
 
                        // Now fit to the first demand.
-                       ya_min = std::max<int>(ya_min, 0);
-                       ya_max = std::min<int>(ya_max, a.rows() - 1);
-                       xa_min = std::max<int>(xa_min, 0);
-                       xa_max = std::min<int>(xa_max, a.cols() - 1);
+                       ya_min = max<int>(ya_min, 0);
+                       ya_max = min<int>(ya_max, a.rows() - 1);
+                       xa_min = max<int>(xa_min, 0);
+                       xa_max = min<int>(xa_max, a.cols() - 1);
 
                        assert(ya_max >= ya_min);
                        assert(xa_max >= xa_min);
@@ -219,10 +223,10 @@ MatrixXf central_convolve(const MatrixXf &a, const MatrixXf &b)
                        int xa_max = xr;
 
                        // Now fit to the first demand.
-                       ya_min = std::max<int>(ya_min, 0);
-                       ya_max = std::min<int>(ya_max, a.rows() - 1);
-                       xa_min = std::max<int>(xa_min, 0);
-                       xa_max = std::min<int>(xa_max, a.cols() - 1);
+                       ya_min = max<int>(ya_min, 0);
+                       ya_max = min<int>(ya_max, a.rows() - 1);
+                       xa_min = max<int>(xa_min, 0);
+                       xa_max = min<int>(xa_max, a.cols() - 1);
 
                        assert(ya_max >= ya_min);
                        assert(xa_max >= xa_min);
@@ -239,16 +243,6 @@ MatrixXf central_convolve(const MatrixXf &a, const MatrixXf &b)
        return result;
 }
 
-void print_matrix(const MatrixXf &m)
-{
-       for (int y = 0; y < m.rows(); ++y) {
-               for (int x = 0; x < m.cols(); ++x) {
-                       printf("%7.4f ", m(x, y));
-               }
-               printf("\n");
-       }
-}
-
 }  // namespace
 
 void DeconvolutionSharpenEffect::update_deconvolution_kernel()
@@ -309,7 +303,7 @@ void DeconvolutionSharpenEffect::update_deconvolution_kernel()
        MatrixXf r_uu(8 * R + 1, 8 * R + 1);
        for (int y = -4 * R; y <= 4 * R; ++y) { 
                for (int x = -4 * R; x <= 4 * R; ++x) {
-                       r_uu(x + 4 * R, y + 4 * R) = pow(correlation, hypot(x, y));
+                       r_uu(x + 4 * R, y + 4 * R) = pow(double(correlation), hypot(x, y));
                }
        }
 
@@ -426,7 +420,7 @@ void DeconvolutionSharpenEffect::update_deconvolution_kernel()
        last_noise = noise;
 }
 
-void DeconvolutionSharpenEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num)
+void DeconvolutionSharpenEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num)
 {
        Effect::set_gl_state(glsl_program_num, prefix, sampler_num);
 
@@ -452,3 +446,5 @@ void DeconvolutionSharpenEffect::set_gl_state(GLuint glsl_program_num, const std
 
        set_uniform_vec4_array(glsl_program_num, prefix, "samples", samples, (R + 1) * (R + 1));
 }
+
+}  // namespace movit