]> git.sesse.net Git - movit/blob - blur_effect.h
Allow changing pitch on YCbCrInput as we go.
[movit] / blur_effect.h
1 #ifndef _BLUR_EFFECT_H
2 #define _BLUR_EFFECT_H 1
3
4 // A separable 2D blur implemented by a combination of mipmap filtering
5 // and convolution (essentially giving a convolution with a piecewise linear
6 // approximation to the true impulse response).
7 //
8 // Works in two passes; first horizontal, then vertical (BlurEffect,
9 // which is what the user is intended to use, instantiates two copies of
10 // SingleBlurPassEffect behind the scenes).
11
12 #include "effect.h"
13
14 class SingleBlurPassEffect;
15
16 class BlurEffect : public Effect {
17 public:
18         BlurEffect();
19
20         // We want this for the same reason as ResizeEffect; we could end up scaling
21         // down quite a lot.
22         virtual bool needs_texture_bounce() const { return true; }
23         virtual bool needs_mipmaps() const { return true; }
24         virtual bool needs_srgb_primaries() const { return false; }
25
26         virtual std::string output_fragment_shader() {
27                 assert(false);
28         }
29         virtual void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) {
30                 assert(false);
31         }
32
33         virtual void add_self_to_effect_chain(EffectChain *chain, const std::vector<Effect *> &input);
34         virtual bool set_float(const std::string &key, float value);
35         
36 private:
37         void update_radius();
38         
39         float radius;
40         SingleBlurPassEffect *hpass, *vpass;
41 };
42
43 class SingleBlurPassEffect : public Effect {
44 public:
45         SingleBlurPassEffect();
46         std::string output_fragment_shader();
47
48         virtual bool needs_texture_bounce() const { return true; }
49         virtual bool needs_mipmaps() const { return true; }
50         virtual bool needs_srgb_primaries() const { return false; }
51
52         virtual bool changes_output_size() const { return true; }
53
54         virtual void get_output_size(unsigned *width, unsigned *height) const {
55                 *width = this->width;
56                 *height = this->height;
57         }
58
59         void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num);
60         void clear_gl_state();
61         
62         enum Direction { HORIZONTAL = 0, VERTICAL = 1 };
63
64 private:
65         float radius;
66         Direction direction;
67         int width, height;
68 };
69
70 #endif // !defined(_BLUR_EFFECT_H)