diff --git a/src/filters/new_interframe.cpp b/src/filters/new_interframe.cpp index ff54d70b..2f09309b 100644 --- a/src/filters/new_interframe.cpp +++ b/src/filters/new_interframe.cpp @@ -9,25 +9,13 @@ #include "new_interframe.hpp" -void interframe_filter::setWidth(unsigned int _width) +SmartIB::SmartIB(unsigned int _width,unsigned int _height): interframe_filter(_width,_height) { - width = _width; - - //32 bit filter, so 4 bytes per pixel - // The +1 is for a 1 pixel border that the emulator spits out - horiz_bytes = (width+1) * 4; - //Unfortunately, the filter keeps the border on the scaled output, but DOES NOT scale it -// horiz_bytes_out = width * 4 * myScale + 4; - -} - -SmartIB::SmartIB() -{ - frm1 = (u32 *)calloc(322*242,4); + frm1 = (u32 *)calloc(_width*_height,4); // 1 frame ago - frm2 = (u32 *)calloc(322*242,4); + frm2 = (u32 *)calloc(_width*_height,4); // 2 frames ago - frm3 = (u32 *)calloc(322*242,4); + frm3 = (u32 *)calloc(_width*_height,4); // 3 frames ago } @@ -80,10 +68,10 @@ void SmartIB::run(u32 *srcPtr, unsigned int num_threads,unsigned int thread_numb } -MotionBlurIB::MotionBlurIB() +MotionBlurIB::MotionBlurIB(unsigned int _width,unsigned int _height): interframe_filter(_width,_height) { - frm1 = (u32 *)calloc(322*242,4); - // 1 frame ago + //Buffer to hold last frame + frm1 = (u32 *)calloc(_width*_height,4); } MotionBlurIB::~MotionBlurIB() diff --git a/src/filters/new_interframe.hpp b/src/filters/new_interframe.hpp index e74d6180..6dffb2b0 100644 --- a/src/filters/new_interframe.hpp +++ b/src/filters/new_interframe.hpp @@ -13,24 +13,20 @@ private: unsigned int width; ///The filter's height unsigned int height; + ///The internal scale +// int myScale; ///Don't need to calculate these every time (based off width) - unsigned int horiz_bytes; +// unsigned int horiz_bytes; // unsigned int horiz_bytes_out; //Children need this pre-calculated data, but it's NOT public -protected: - unsigned int get_horiz_bytes() {return horiz_bytes;} +// protected: +// unsigned int get_horiz_bytes() {return horiz_bytes;} // unsigned int get_horiz_bytes_out() {return horiz_bytes_out;} public: - interframe_filter(): width(0) {} + interframe_filter(unsigned int _width=0,unsigned int _height=0): width(_width),height(_height) {} virtual std::string getName() {return "Dummy Filter";} virtual int getScale() {return 0;} - ///Set the number of pixels per horizontal row - ///Always use this after initialization if using the new run function. - void setWidth(unsigned int _width); unsigned int getWidth() {return width;} - ///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(u32 *srcPtr, unsigned int num_threads=1,unsigned int thread_number=0) {} @@ -48,8 +44,9 @@ private: u32 *frm1; u32 *frm2; u32 *frm3; -public: SmartIB(); +public: + SmartIB(unsigned int _width,unsigned int _height); ~SmartIB(); std::string getName() {return "SmartIB";} void run(u32 *srcPtr, unsigned int num_threads=1,unsigned int thread_number=0); @@ -60,8 +57,10 @@ class MotionBlurIB : public interframe_filter { private: u32 *frm1; -public: + //Must enter width and height at filter initialization MotionBlurIB(); +public: + MotionBlurIB(unsigned int _width,unsigned int _height); ~MotionBlurIB(); std::string getName() {return "MotionBlurIB";} void run(u32 *srcPtr, unsigned int num_threads=1,unsigned int thread_number=0); @@ -78,14 +77,14 @@ enum ifbfunc { class interframe_factory { public: - static interframe_filter * createIFB(ifbfunc filter_select) + static interframe_filter * createIFB(ifbfunc filter_select,unsigned int width,unsigned int height) { switch(filter_select) { case IFB_SMART: - return new SmartIB(); + return new SmartIB(width,height); break; case IFB_MOTION_BLUR: - return new MotionBlurIB(); + return new MotionBlurIB(width,height); break; default: return new interframe_filter(); diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index d6f8ed3b..32091a62 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -1070,12 +1070,10 @@ DrawingPanel::DrawingPanel(int _width, int _height) : myFilter = new filter(std::string(gopts.filter.mb_str(wxConvUTF8))); - iFilter = interframe_factory::createIFB((ifbfunc)gopts.ifb); + iFilter = interframe_factory::createIFB((ifbfunc)gopts.ifb,width,height); scale = myFilter->getScale(); myFilter->setWidth(width); - iFilter->setWidth(width); - iFilter->setHeight(height); //Do a quick run to initialize the filter //\TODO: Fix the filters so this is no longer needed