Debian Codegraph @

src/filter/nosync0r/nosync0r.cpp

raw symbols SCIP
1 #include "frei0r.hpp"
2
3 #include <algorithm>
4 #include <cmath>
5
6 class nosync0r : public frei0r::filter
7 {
8 public:
9 nosync0r(unsigned int width, unsigned int height)
10 {
11 hsync = 0.0;
12 register_param(hsync,"HSync","the hsync offset");
13 vsync = 0.0;
14 register_param(vsync,"VSync","the vsync offset");
15 }
16
17 virtual void update(double time,
18 uint32_t* out,
19 const uint32_t* in)
20 {
21 if (hsync == 0.0 && vsync == 0.0) {
22 std::copy(in, in+width*height, out);
23 } else if (vsync == 0.0) {
24 unsigned int
25 first_line=static_cast<unsigned int>(height*std::fmod(std::fabs(hsync),1.0));
26
27 std::copy(in+width*first_line, in+width*height, out);
28 std::copy(in, in+width*first_line, out+width*(height-first_line));
29 } else {
30 unsigned int hoffset=static_cast<unsigned int>(height*std::fmod(std::fabs(hsync),1.0));
31 unsigned int voffset=static_cast<unsigned int>(width*std::fmod(std::fabs(vsync),1.0));
32 for (unsigned int src_line = 0; src_line < height; src_line++) {
33 unsigned int dst_line = (src_line + hoffset) % height;
34 const uint32_t* src_pix = in + (width * src_line);
35 uint32_t* dst_pix = out + (width * dst_line);
36 std::copy(src_pix, src_pix + width - voffset, dst_pix + voffset);
37 std::copy(src_pix + width - voffset, src_pix + width, dst_pix);
38 }
39 }
40 }
41
42 private:
43 double hsync;
44 double vsync;
45 };
46
47
48 frei0r::construct<nosync0r> plugin("nosync0r",
49 "broken tv",
50 "Martin Bayer",
51 0,2);
52