xBRZ 1.3 filter update by chrono, zenju

https://sourceforge.net/projects/xbrz/


git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1290 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
skidau 2015-04-03 22:19:46 +00:00
parent 3d20c6cf97
commit c279a8e88d
4 changed files with 402 additions and 468 deletions

View File

@ -1,6 +1,6 @@
// **************************************************************************** // ****************************************************************************
// * This file is part of the HqMAME project. It is distributed under * // * This file is part of the HqMAME project. It is distributed under *
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * // * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 *
// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved *
// * * // * *
// * Additionally and as a special exception, the author gives permission * // * Additionally and as a special exception, the author gives permission *

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
// **************************************************************************** // ****************************************************************************
// * This file is part of the HqMAME project. It is distributed under * // * This file is part of the HqMAME project. It is distributed under *
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * // * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 *
// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved *
// * * // * *
// * Additionally and as a special exception, the author gives permission * // * Additionally and as a special exception, the author gives permission *
@ -30,26 +30,34 @@ namespace xbrz
using a modified approach of xBR: using a modified approach of xBR:
http://board.byuu.org/viewtopic.php?f=10&t=2248 http://board.byuu.org/viewtopic.php?f=10&t=2248
- new rule set preserving small image features - new rule set preserving small image features
- highly optimized for performance
- support alpha channel
- support multithreading - support multithreading
- support 64 bit architectures - support 64-bit architectures
- support processing image slices - support processing image slices
*/ */
enum ColorFormat //from high bits -> low bits, 8 bit per channel
{
ARGB, //including alpha channel, BGRA byte order on little-endian machines
RGB, //8 bit for each red, green, blue, upper 8 bits unused
};
/* /*
-> map source (srcWidth * srcHeight) to target (scale * width x scale * height) image, optionally processing a half-open slice of rows [yFirst, yLast) only -> map source (srcWidth * srcHeight) to target (scale * width x scale * height) image, optionally processing a half-open slice of rows [yFirst, yLast) only
-> color format: ARGB (BGRA byte order), alpha channel unused
-> support for source/target pitch in bytes! -> support for source/target pitch in bytes!
-> if your emulator changes only a few image slices during each cycle (e.g. DOSBox) then there's no need to run xBRZ on the complete image: -> if your emulator changes only a few image slices during each cycle (e.g. DOSBox) then there's no need to run xBRZ on the complete image:
Just make sure you enlarge the source image slice by 2 rows on top and 2 on bottom (this is the additional range the xBRZ algorithm is using during analysis) Just make sure you enlarge the source image slice by 2 rows on top and 2 on bottom (this is the additional range the xBRZ algorithm is using during analysis)
Caveat: If there are multiple changed slices, make sure they do not overlap after adding these additional rows in order to avoid a memory race condition Caveat: If there are multiple changed slices, make sure they do not overlap after adding these additional rows in order to avoid a memory race condition
in the target image data if you are using multiple threads for processing each enlarged slice! in the target image data if you are using multiple threads for processing each enlarged slice!
THREAD-SAFETY: - parts of the same image may be scaled by multiple threads as long as the [yFirst, yLast) ranges do not overlap! THREAD-SAFETY: - parts of the same image may be scaled by multiple threads as long as the [yFirst, yLast) ranges do not overlap!
- there is a minor inefficiency for the first row of a slice, so avoid processing single rows only - there is a minor inefficiency for the first row of a slice, so avoid processing single rows only; suggestion: process 6 rows at least
*/ */
void scale(size_t factor, //valid range: 2 - 5 void scale(size_t factor, //valid range: 2 - 5
const uint32_t* src, int srcWidth, int srcHeight, int srcPitch, const uint32_t* src, int srcWidth, int srcHeight, int srcPitch,
uint32_t* trg, int trgPitch, uint32_t* trg, int trgPitch,
ColorFormat colFmt,
const ScalerCfg& cfg = ScalerCfg(), const ScalerCfg& cfg = ScalerCfg(),
int yFirst = 0, int yLast = std::numeric_limits<int>::max()); //slice of source image int yFirst = 0, int yLast = std::numeric_limits<int>::max()); //slice of source image
@ -66,7 +74,7 @@ void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, int
SliceType st, int yFirst, int yLast); SliceType st, int yFirst, int yLast);
//parameter tuning //parameter tuning
bool equalColorTest(uint32_t col1, uint32_t col2, double luminanceWeight, double equalColorTolerance); bool equalColorTest(uint32_t col1, uint32_t col2, ColorFormat colFmt, double luminanceWeight, double equalColorTolerance);

View File

@ -1,23 +1,23 @@
#include "../System.h" #include "../System.h"
#include "xBRZ/xbrz.h" #include "xBRZ/xbrz.h"
void xbrz2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height) void xbrz2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height)
{ {
xbrz::scale(2, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch); xbrz::scale(2, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB);
} }
void xbrz3x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height) void xbrz3x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height)
{ {
xbrz::scale(3, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch); xbrz::scale(3, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB);
} }
void xbrz4x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height) void xbrz4x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height)
{ {
xbrz::scale(4, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch); xbrz::scale(4, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB);
} }
void xbrz5x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height) void xbrz5x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height)
{ {
xbrz::scale(5, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch); xbrz::scale(5, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB);
} }