mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-25 01:00:01 +00:00
Allocate the xBRZ buffer only when actually used.
This way if scaling is off, we don't have to worry about potentially eating more RAM on any platform.
This commit is contained in:
parent
3c9150231d
commit
10049e62a8
@ -530,6 +530,10 @@ TextureScaler::TextureScaler() {
|
||||
initBicubicWeights();
|
||||
}
|
||||
|
||||
TextureScaler::~TextureScaler() {
|
||||
xbrz::shutdown();
|
||||
}
|
||||
|
||||
bool TextureScaler::IsEmptyOrFlat(u32* data, int pixels, GLenum fmt) {
|
||||
int pixelsPerWord = (fmt == GL_UNSIGNED_BYTE) ? 1 : 2;
|
||||
u32 ref = data[0];
|
||||
|
@ -27,6 +27,7 @@
|
||||
class TextureScaler {
|
||||
public:
|
||||
TextureScaler();
|
||||
~TextureScaler();
|
||||
|
||||
void Scale(u32* &data, GLenum &dstfmt, int &width, int &height, int factor);
|
||||
|
||||
|
@ -438,7 +438,8 @@ public:
|
||||
|
||||
private:
|
||||
std::vector<float> buffer; //consumes 64 MB memory; using double is 2% faster, but takes 128 MB
|
||||
} distYCbCrBuffer;
|
||||
};
|
||||
DistYCbCrBuffer *distYCbCrBuffer = nullptr;
|
||||
|
||||
|
||||
inline
|
||||
@ -1122,7 +1123,7 @@ struct ColorDistanceRGB
|
||||
{
|
||||
static double dist(uint32_t pix1, uint32_t pix2, double luminanceWeight)
|
||||
{
|
||||
return distYCbCrBuffer.dist(pix1, pix2);
|
||||
return distYCbCrBuffer->dist(pix1, pix2);
|
||||
|
||||
//if (pix1 == pix2) //about 4% perf boost
|
||||
// return 0;
|
||||
@ -1144,7 +1145,7 @@ struct ColorDistanceARGB
|
||||
3. if a1 = 1, distance should be: 255 * (1 - a2) + a2 * distYCbCr()
|
||||
*/
|
||||
|
||||
return std::min(a1, a2) * distYCbCrBuffer.dist(pix1, pix2) + 255 * abs(a1 - a2);
|
||||
return std::min(a1, a2) * distYCbCrBuffer->dist(pix1, pix2) + 255 * abs(a1 - a2);
|
||||
|
||||
//if (pix1 == pix2)
|
||||
// return 0;
|
||||
@ -1156,6 +1157,9 @@ struct ColorDistanceARGB
|
||||
|
||||
void xbrz::scale(size_t factor, const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, ColorFormat colFmt, const xbrz::ScalerCfg& cfg, int yFirst, int yLast)
|
||||
{
|
||||
if (distYCbCrBuffer == nullptr)
|
||||
distYCbCrBuffer = new DistYCbCrBuffer();
|
||||
|
||||
switch (colFmt)
|
||||
{
|
||||
case ColorFormat::ARGB:
|
||||
@ -1187,6 +1191,13 @@ void xbrz::scale(size_t factor, const uint32_t* src, uint32_t* trg, int srcWidth
|
||||
}
|
||||
|
||||
|
||||
void xbrz::shutdown()
|
||||
{
|
||||
delete distYCbCrBuffer;
|
||||
distYCbCrBuffer = nullptr;
|
||||
}
|
||||
|
||||
|
||||
bool xbrz::equalColorTest(uint32_t col1, uint32_t col2, ColorFormat colFmt, double luminanceWeight, double equalColorTolerance)
|
||||
{
|
||||
switch (colFmt)
|
||||
|
@ -67,6 +67,8 @@ void scale(size_t factor, //valid range: 2 - 5
|
||||
const ScalerCfg& cfg = ScalerCfg(),
|
||||
int yFirst = 0, int yLast = std::numeric_limits<int>::max()); //slice of source image
|
||||
|
||||
void shutdown();
|
||||
|
||||
void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight,
|
||||
uint32_t* trg, int trgWidth, int trgHeight);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user