Now leave Interframe filter creation/selection to a factory class

This commit is contained in:
Arthur Moore 2015-03-10 23:47:20 -04:00
parent 77d26474b4
commit 8a052006ce
4 changed files with 27 additions and 23 deletions

View File

@ -13,13 +13,6 @@
// Function pointer type for a filter function
typedef void(*FilterFunc)(u8*, u32, u8*, u8*, u32, int, int);
//WX
enum ifbfunc {
// this order must match order of option enum and selector widget
IFB_NONE, IFB_SMART, IFB_MOTION_BLUR
};
typedef std::pair<FilterFunc,FilterFunc> filterpair;
typedef std::pair<std::string,filterpair> namedfilter;

View File

@ -60,7 +60,7 @@ void SmartIB::run(u8 *srcPtr, unsigned int num_threads,unsigned int thread_numbe
u32 colorMask = 0xfefefe;
for (int i = 0; i < width*band_height; i++)
for (unsigned int i = 0; i < width*band_height; i++)
{
u32 color = src0[i];
src0[i] =
@ -117,7 +117,7 @@ void MotionBlurIB::run(u8 *srcPtr, unsigned int num_threads,unsigned int thread_
u32 colorMask = 0xfefefe;
for (int i = 0; i < width*band_height; i++)
for (unsigned int i = 0; i < width*band_height; i++)
{
u32 color = src0[i];
src0[i] = (((color & colorMask) >> 1) +

View File

@ -67,7 +67,31 @@ public:
void run(u8 *srcPtr, unsigned int num_threads=1,unsigned int thread_number=0);
};
//WX
enum ifbfunc {
// this order must match order of option enum and selector widget
IFB_NONE, IFB_SMART, IFB_MOTION_BLUR
};
///Use this to select/create the filter to use
class interframe_factory
{
public:
static interframe_filter * createIFB(ifbfunc filter_select)
{
switch(filter_select) {
case IFB_SMART:
return new SmartIB();
break;
case IFB_MOTION_BLUR:
return new MotionBlurIB();
break;
default:
return new interframe_filter();
break;
}
}
};
#endif //NEW_INTERFRAME_HPP

View File

@ -986,20 +986,7 @@ DrawingPanel::DrawingPanel(int _width, int _height) :
myFilter = new filter(std::string(gopts.filter.mb_str(wxConvUTF8)));
if(gopts.ifb != IFB_NONE) {
switch(gopts.ifb) {
case IFB_SMART:
iFilter = new SmartIB();
break;
case IFB_MOTION_BLUR:
iFilter = new MotionBlurIB();
break;
}
}
else
{
iFilter = new interframe_filter();
}
iFilter = interframe_factory::createIFB((ifbfunc)gopts.ifb);
scale = myFilter->getScale();
myFilter->setWidth(width);