Skip to content

Commit

Permalink
Add vsync option to nosync0r filter
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatherly committed Jan 21, 2025
1 parent 8bf0322 commit 646f718
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/filter/nosync0r/nosync0r.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,38 @@ class nosync0r : public frei0r::filter
{
hsync = 0.0;
register_param(hsync,"HSync","the hsync offset");
vsync = 0.0;
register_param(vsync,"VSync","the vsync offset");
}

virtual void update(double time,
uint32_t* out,
const uint32_t* in)
{
unsigned int
first_line=static_cast<unsigned int>(height*std::fmod(std::fabs(hsync),1.0));
if (hsync == 0.0 && vsync == 0.0) {
std::copy(in, in+width*height, out);
} else if (vsync == 0.0) {
unsigned int
first_line=static_cast<unsigned int>(height*std::fmod(std::fabs(hsync),1.0));

std::copy(in+width*first_line, in+width*height, out);
std::copy(in, in+width*first_line, out+width*(height-first_line));
std::copy(in+width*first_line, in+width*height, out);
std::copy(in, in+width*first_line, out+width*(height-first_line));
} else {
unsigned int hoffset=static_cast<unsigned int>(height*std::fmod(std::fabs(hsync),1.0));
unsigned int voffset=static_cast<unsigned int>(width*std::fmod(std::fabs(vsync),1.0));
for (unsigned int src_line = 0; src_line < height; src_line++) {
unsigned int dst_line = (src_line + hoffset) % height;
const uint32_t* src_pix = in + (width * src_line);
uint32_t* dst_pix = out + (width * dst_line);
std::copy(src_pix, src_pix + width - voffset, dst_pix + voffset);
std::copy(src_pix + width - voffset, src_pix + width, dst_pix);
}
}
}

private:
double hsync;
double vsync;
};


Expand Down

0 comments on commit 646f718

Please sign in to comment.