diff --git a/src/filters/interframe.cpp b/src/filters/interframe.cpp index 407be592..c7e9d8ed 100644 --- a/src/filters/interframe.cpp +++ b/src/filters/interframe.cpp @@ -2,6 +2,8 @@ #include #include +#include "interframe.hpp" + #ifdef MMX extern "C" bool cpu_mmx; #endif @@ -16,7 +18,6 @@ static uint8_t *frm1 = NULL; static uint8_t *frm2 = NULL; static uint8_t *frm3 = NULL; -extern int RGB_LOW_BITS_MASK; extern uint32_t qRGB_COLOR_MASK[2]; static void Init() @@ -31,11 +32,12 @@ static void Init() void InterframeCleanup() { + //Hack to prevent double freeing *It looks like this is not being called in a thread safe manner) if(frm1) free(frm1); - if(frm2) + if(frm2 && (frm1 != frm2)) free(frm2); - if(frm3) + if(frm3 && (frm1 != frm3) && (frm2 != frm3)) free(frm3); frm1 = frm2 = frm3 = NULL; } diff --git a/src/filters/interframe.hpp b/src/filters/interframe.hpp new file mode 100644 index 00000000..66c2d2f4 --- /dev/null +++ b/src/filters/interframe.hpp @@ -0,0 +1,31 @@ +/// Interframe blending filters + +#ifndef INTERFRAME_HPP +#define INTERFRAME_HPP + +extern int RGB_LOW_BITS_MASK; + +static void Init(); + +// call ifc to ignore previous frame / when starting new +void InterframeCleanup(); + +// all 4 are MMX-accelerated if enabled +void SmartIB(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); +void SmartIB32(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); +void MotionBlurIB(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); +void MotionBlurIB32(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); + +#ifdef MMX +static void SmartIB_MMX(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); +static void SmartIB32_MMX(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); +static void MotionBlurIB_MMX(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); +static void MotionBlurIB32_MMX(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height); +#endif + +//Options for if start is 0 +void SmartIB(uint8_t *srcPtr, uint32_t srcPitch, int width, int height); +void SmartIB32(uint8_t *srcPtr, uint32_t srcPitch, int width, int height); +void MotionBlurIB(uint8_t *srcPtr, uint32_t srcPitch, int width, int height); +void MotionBlurIB32(uint8_t *srcPtr, uint32_t srcPitch, int width, int height); +#endif //INTERFRAME_HPP diff --git a/src/sdl/filters.cpp b/src/sdl/filters.cpp index dd858b26..f3d02499 100644 --- a/src/sdl/filters.cpp +++ b/src/sdl/filters.cpp @@ -22,6 +22,8 @@ #include "filters.h" +#include "../filters/interframe.hpp" + // // Screen filters // @@ -164,15 +166,6 @@ FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth) return func; } -// -// Interframe blending filters -// - -extern void SmartIB(uint8_t*, uint32_t, int, int); -extern void SmartIB32(uint8_t*, uint32_t, int, int); -extern void MotionBlurIB(uint8_t*, uint32_t, int, int); -extern void MotionBlurIB32(uint8_t*, uint32_t, int, int); - struct IFBFilterDesc { char name[30]; IFBFilterFunc func16; diff --git a/src/wx/filters.h b/src/wx/filters.h index 339412e7..0e313871 100644 --- a/src/wx/filters.h +++ b/src/wx/filters.h @@ -6,6 +6,9 @@ // most 16-bit filters require space in src rounded up to uint32_t // those that take delta take 1 src line of pixels, rounded up to uint32_t size // initial value appears to be all-0xff + +#include "../filters/interframe.hpp" + void Pixelate32(uint8_t* src, uint32_t spitch, uint8_t*, uint8_t* dst, uint32_t dstp, int w, int h); void Pixelate(uint8_t* src, uint32_t spitch, uint8_t* delta, uint8_t* dst, uint32_t dstp, int w, int h); // next 3*2 use Init_2xSaI(555|565) and do not take into account @@ -68,16 +71,4 @@ void xbrz4x32(uint8_t* src, uint32_t spitch, uint8_t*, uint8_t* dst, uint32_t ds void xbrz5x32(uint8_t* src, uint32_t spitch, uint8_t*, uint8_t* dst, uint32_t dstp, int w, int h); void xbrz6x32(uint8_t* src, uint32_t spitch, uint8_t*, uint8_t* dst, uint32_t dstp, int w, int h); -// call ifc to ignore previous frame / when starting new -void InterframeCleanup(); -// all 4 are MMX-accelerated if enabled -void SmartIB(uint8_t* src, uint32_t spitch, int width, int height); -void SmartIB32(uint8_t* src, uint32_t spitch, int width, int height); -void MotionBlurIB(uint8_t* src, uint32_t spitch, int width, int height); -void MotionBlurIB32(uint8_t* src, uint32_t spitch, int width, int height); -void SmartIB(uint8_t* src, uint32_t spitch, int width, int starty, int height); -void SmartIB32(uint8_t* src, uint32_t spitch, int width, int starty, int height); -void MotionBlurIB(uint8_t* src, uint32_t spitch, int width, int starty, int height); -void MotionBlurIB32(uint8_t* src, uint32_t spitch, int width, int starty, int height); - #endif /* FILTERS_H */