Interframe filters can now handle image buffers of any size

This commit is contained in:
Arthur Moore 2015-03-12 21:38:41 -04:00
parent ec041ec6ee
commit 27e95b3f99
3 changed files with 22 additions and 37 deletions

View File

@ -9,25 +9,13 @@
#include "new_interframe.hpp" #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; frm1 = (u32 *)calloc(_width*_height,4);
//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);
// 1 frame ago // 1 frame ago
frm2 = (u32 *)calloc(322*242,4); frm2 = (u32 *)calloc(_width*_height,4);
// 2 frames ago // 2 frames ago
frm3 = (u32 *)calloc(322*242,4); frm3 = (u32 *)calloc(_width*_height,4);
// 3 frames ago // 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); //Buffer to hold last frame
// 1 frame ago frm1 = (u32 *)calloc(_width*_height,4);
} }
MotionBlurIB::~MotionBlurIB() MotionBlurIB::~MotionBlurIB()

View File

@ -13,24 +13,20 @@ private:
unsigned int width; unsigned int width;
///The filter's height ///The filter's height
unsigned int height; unsigned int height;
///The internal scale
// int myScale;
///Don't need to calculate these every time (based off width) ///Don't need to calculate these every time (based off width)
unsigned int horiz_bytes; // unsigned int horiz_bytes;
// unsigned int horiz_bytes_out; // unsigned int horiz_bytes_out;
//Children need this pre-calculated data, but it's NOT public //Children need this pre-calculated data, but it's NOT public
protected: // protected:
unsigned int get_horiz_bytes() {return horiz_bytes;} // unsigned int get_horiz_bytes() {return horiz_bytes;}
// unsigned int get_horiz_bytes_out() {return horiz_bytes_out;} // unsigned int get_horiz_bytes_out() {return horiz_bytes_out;}
public: 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 std::string getName() {return "Dummy Filter";}
virtual int getScale() {return 0;} 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;} 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;} unsigned int getHeight() {return height;}
///New smarter Interframe function ///New smarter Interframe function
virtual void run(u32 *srcPtr, unsigned int num_threads=1,unsigned int thread_number=0) {} virtual void run(u32 *srcPtr, unsigned int num_threads=1,unsigned int thread_number=0) {}
@ -48,8 +44,9 @@ private:
u32 *frm1; u32 *frm1;
u32 *frm2; u32 *frm2;
u32 *frm3; u32 *frm3;
public:
SmartIB(); SmartIB();
public:
SmartIB(unsigned int _width,unsigned int _height);
~SmartIB(); ~SmartIB();
std::string getName() {return "SmartIB";} std::string getName() {return "SmartIB";}
void run(u32 *srcPtr, unsigned int num_threads=1,unsigned int thread_number=0); void run(u32 *srcPtr, unsigned int num_threads=1,unsigned int thread_number=0);
@ -60,8 +57,10 @@ class MotionBlurIB : public interframe_filter
{ {
private: private:
u32 *frm1; u32 *frm1;
public: //Must enter width and height at filter initialization
MotionBlurIB(); MotionBlurIB();
public:
MotionBlurIB(unsigned int _width,unsigned int _height);
~MotionBlurIB(); ~MotionBlurIB();
std::string getName() {return "MotionBlurIB";} std::string getName() {return "MotionBlurIB";}
void run(u32 *srcPtr, unsigned int num_threads=1,unsigned int thread_number=0); void run(u32 *srcPtr, unsigned int num_threads=1,unsigned int thread_number=0);
@ -78,14 +77,14 @@ enum ifbfunc {
class interframe_factory class interframe_factory
{ {
public: public:
static interframe_filter * createIFB(ifbfunc filter_select) static interframe_filter * createIFB(ifbfunc filter_select,unsigned int width,unsigned int height)
{ {
switch(filter_select) { switch(filter_select) {
case IFB_SMART: case IFB_SMART:
return new SmartIB(); return new SmartIB(width,height);
break; break;
case IFB_MOTION_BLUR: case IFB_MOTION_BLUR:
return new MotionBlurIB(); return new MotionBlurIB(width,height);
break; break;
default: default:
return new interframe_filter(); return new interframe_filter();

View File

@ -1070,12 +1070,10 @@ DrawingPanel::DrawingPanel(int _width, int _height) :
myFilter = new filter(std::string(gopts.filter.mb_str(wxConvUTF8))); 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(); scale = myFilter->getScale();
myFilter->setWidth(width); myFilter->setWidth(width);
iFilter->setWidth(width);
iFilter->setHeight(height);
//Do a quick run to initialize the filter //Do a quick run to initialize the filter
//\TODO: Fix the filters so this is no longer needed //\TODO: Fix the filters so this is no longer needed