]> git.sesse.net Git - movit/blob - complex_modulate_effect.cpp
Add a deinterlacer based on YADIF.
[movit] / complex_modulate_effect.cpp
1 #include <epoxy/gl.h>
2
3 #include "complex_modulate_effect.h"
4 #include "effect_chain.h"
5 #include "effect_util.h"
6 #include "util.h"
7
8 using namespace std;
9
10 namespace movit {
11
12 ComplexModulateEffect::ComplexModulateEffect()
13         : num_repeats_x(1), num_repeats_y(1)
14 {
15         register_int("num_repeats_x", &num_repeats_x);
16         register_int("num_repeats_y", &num_repeats_y);
17         register_vec2("num_repeats", uniform_num_repeats);
18 }
19
20 string ComplexModulateEffect::output_fragment_shader()
21 {
22         return read_file("complex_modulate_effect.frag");
23 }
24
25 void ComplexModulateEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num)
26 {
27         Effect::set_gl_state(glsl_program_num, prefix, sampler_num);
28
29         uniform_num_repeats[0] = float(num_repeats_x);
30         uniform_num_repeats[1] = float(num_repeats_y);
31
32         // Set the secondary input to repeat (and nearest while we're at it).
33         Node *self = chain->find_node_for_effect(this);
34         glActiveTexture(chain->get_input_sampler(self, 1));
35         check_error();
36         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
37         check_error();
38         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
39         check_error();
40         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
41         check_error();
42         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
43         check_error();
44 }
45
46 void ComplexModulateEffect::inform_input_size(unsigned input_num, unsigned width, unsigned height)
47 {
48         if (input_num == 0) {
49                 primary_input_width = width;
50                 primary_input_height = height;
51         }
52 }
53
54 void ComplexModulateEffect::get_output_size(unsigned *width, unsigned *height,
55                                             unsigned *virtual_width, unsigned *virtual_height) const
56 {
57         *width = *virtual_width = primary_input_width;
58         *height = *virtual_height = primary_input_height;
59 }
60
61 }  // namespace movit