diff --git a/src/filters/new_interframe.cpp b/src/filters/new_interframe.cpp index 857a7957..d8ee856f 100644 --- a/src/filters/new_interframe.cpp +++ b/src/filters/new_interframe.cpp @@ -21,15 +21,6 @@ void interframe_filter::setWidth(unsigned int _width) } -void interframe_filter::run(u8 *srcPtr, int starty, int height) -{ - if(!getWidth()) - { - throw std::runtime_error("ERROR: Filter width not set"); - } - this->run(srcPtr, get_horiz_bytes(), getWidth(), starty, height); -} - SmartIB::SmartIB() { frm1 = (u8 *)calloc(322*242,4); @@ -53,27 +44,22 @@ SmartIB::~SmartIB() frm1 = frm2 = frm3 = NULL; } -void SmartIB::run(u8 *srcPtr, u32 srcPitch, int width, int starty, int height) +void SmartIB::run(u8 *srcPtr, int starty, int height) { - setWidth(width); - //Make sure the math was correct - if( (srcPitch != get_horiz_bytes()) ) - { - throw std::runtime_error("ERROR: Filter programmer is an idiot, and messed up an important calculation!"); - } + //Actual width needs to take into account the +1 border + unsigned int width = getWidth() +1; - u32 *src0 = (u32 *)srcPtr + starty * srcPitch / 4; - u32 *src1 = (u32 *)frm1 + starty * srcPitch / 4; - u32 *src2 = (u32 *)frm2 + starty * srcPitch / 4; - u32 *src3 = (u32 *)frm3 + starty * srcPitch / 4; + u32 *src0 = (u32 *)srcPtr + starty * width; + u32 *src1 = (u32 *)frm1 + starty * width; + u32 *src2 = (u32 *)frm2 + starty * width; + u32 *src3 = (u32 *)frm3 + starty * width; u32 colorMask = 0xfefefe; - int sPitch = srcPitch >> 2; int pos = 0; for (int j = 0; j < height; j++) - for (int i = 0; i < sPitch; i++) { + for (int i = 0; i < width; i++) { u32 color = src0[pos]; src0[pos] = (src1[pos] != src2[pos]) && @@ -116,25 +102,20 @@ MotionBlurIB::~MotionBlurIB() frm1 = frm2 = frm3 = NULL; } -void MotionBlurIB::run(u8 *srcPtr, u32 srcPitch, int width, int starty, int height) +void MotionBlurIB::run(u8 *srcPtr, int starty, int height) { - setWidth(width); - //Make sure the math was correct - if( (srcPitch != get_horiz_bytes()) ) - { - throw std::runtime_error("ERROR: Filter programmer is an idiot, and messed up an important calculation!"); - } + //Actual width needs to take into account the +1 border + unsigned int width = getWidth() +1; - u32 *src0 = (u32 *)srcPtr + starty * srcPitch / 4; - u32 *src1 = (u32 *)frm1 + starty * srcPitch / 4; + u32 *src0 = (u32 *)srcPtr + starty * width; + u32 *src1 = (u32 *)frm1 + starty * width; u32 colorMask = 0xfefefe; - int sPitch = srcPitch >> 2; int pos = 0; for (int j = 0; j < height; j++) - for (int i = 0; i < sPitch; i++) { + for (int i = 0; i < width; i++) { u32 color = src0[pos]; src0[pos] = (((color & colorMask) >> 1) + ((src1[pos] & colorMask) >> 1)); diff --git a/src/filters/new_interframe.hpp b/src/filters/new_interframe.hpp index 06c313b5..d1f3b0b6 100644 --- a/src/filters/new_interframe.hpp +++ b/src/filters/new_interframe.hpp @@ -11,6 +11,8 @@ class interframe_filter private: ///The filter's width unsigned int width; + ///The filter's height + unsigned int height; ///Don't need to calculate these every time (based off width) unsigned int horiz_bytes; // unsigned int horiz_bytes_out; @@ -26,10 +28,12 @@ public: ///Always use this after initialization if using the new run function. void setWidth(unsigned int _width); unsigned int getWidth() {return width;} - ///DEPRECATED Original Interframe function - virtual void run(u8 *srcPtr, u32 srcPitch, int width, int starty, int height) {} + ///Set the number of horizontal rows in the image + ///Always use this after initialization if using the new run function. + void setHeight(unsigned int _height){height=_height;} + unsigned int getHeight() {return height;} ///New smarter Interframe function - virtual void run(u8 *srcPtr, int starty, int height); + virtual void run(u8 *srcPtr, int starty, int height) {} }; @@ -47,7 +51,7 @@ public: SmartIB(); ~SmartIB(); std::string getName() {return "SmartIB";} - void run(u8 *srcPtr, u32 srcPitch, int width, int starty, int height); + void run(u8 *srcPtr, int starty, int height); }; class MotionBlurIB : public interframe_filter @@ -60,7 +64,7 @@ public: MotionBlurIB(); ~MotionBlurIB(); std::string getName() {return "MotionBlurIB";} - void run(u8 *srcPtr, u32 srcPitch, int width, int starty, int height); + void run(u8 *srcPtr, int starty, int height); }; diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index 303b4c59..7e9e5b2d 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -1004,6 +1004,7 @@ DrawingPanel::DrawingPanel(int _width, int _height) : scale = myFilter->getScale(); myFilter->setWidth(width); iFilter->setWidth(width); + iFilter->setHeight(height); std::cerr << "width: " << width << " Height: " << height << std::endl; #define out_16 (systemColorDepth == 16)