mirror of
https://github.com/libretro/gambatte-libretro.git
synced 2024-11-27 01:40:23 +00:00
refactoring.
git-svn-id: https://gambatte.svn.sourceforge.net/svnroot/gambatte@256 9dfb2916-2d38-0410-aef4-c5fe6c9ffc24
This commit is contained in:
parent
3233abfabc
commit
644441168c
@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Sindre Aam<EFBFBD>s *
|
||||
* Copyright (C) 2008 by Sindre Aamås *
|
||||
* aamas@stud.ntnu.no *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@ -28,14 +28,12 @@ class Array : Uncopyable {
|
||||
std::size_t sz;
|
||||
|
||||
public:
|
||||
Array(const std::size_t size = 0) : a(size ? new T[size] : 0), sz(size) {}
|
||||
explicit Array(const std::size_t size = 0) : a(size ? new T[size] : 0), sz(size) {}
|
||||
~Array() { delete []a; }
|
||||
void reset(const std::size_t size = 0) { delete []a; a = size ? new T[size] : 0; sz = size; }
|
||||
std::size_t size() const { return sz; }
|
||||
T * get() { return a; }
|
||||
const T * get() const { return a; }
|
||||
operator T*() { return a; }
|
||||
operator const T*() const { return a; }
|
||||
T * get() const { return a; }
|
||||
operator T*() const { return a; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -23,13 +23,14 @@
|
||||
#include "subresampler.h"
|
||||
#include "makesinckernel.h"
|
||||
#include "cic4.h"
|
||||
#include "array.h"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
template<unsigned channels, unsigned phases>
|
||||
class BlackmanSinc : public SubResampler {
|
||||
PolyPhaseConvoluter<channels, phases> convoluters[channels];
|
||||
short *kernel;
|
||||
Array<short> kernel;
|
||||
|
||||
static double blackmanWin(const long i, const long M) {
|
||||
static const double PI = 3.14159265358979323846;
|
||||
@ -64,16 +65,15 @@ public:
|
||||
|
||||
BlackmanSinc(unsigned div, unsigned phaseLen, double fc) { init(div, phaseLen, fc); }
|
||||
BlackmanSinc(unsigned div, RollOff ro) { init(div, ro.taps, ro.fc); }
|
||||
~BlackmanSinc() { delete[] kernel; }
|
||||
std::size_t resample(short *out, const short *in, std::size_t inlen);
|
||||
void adjustDiv(unsigned div);
|
||||
unsigned mul() const { return MUL; }
|
||||
unsigned div() const { return convoluters[0].div(); }
|
||||
};
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
void BlackmanSinc<channels, phases>::init(const unsigned div, const unsigned phaseLen, const double fc) {
|
||||
kernel = new short[phaseLen * phases];
|
||||
kernel.reset(phaseLen * phases);
|
||||
|
||||
makeSincKernel(kernel, phases, phaseLen, fc, blackmanWin);
|
||||
|
||||
@ -81,7 +81,7 @@ void BlackmanSinc<channels, phases>::init(const unsigned div, const unsigned pha
|
||||
convoluters[i].reset(kernel, phaseLen, div);
|
||||
}
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
std::size_t BlackmanSinc<channels, phases>::resample(short *const out, const short *const in, const std::size_t inlen) {
|
||||
std::size_t samplesOut;
|
||||
|
||||
@ -91,7 +91,7 @@ std::size_t BlackmanSinc<channels, phases>::resample(short *const out, const sho
|
||||
return samplesOut;
|
||||
}
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
void BlackmanSinc<channels, phases>::adjustDiv(const unsigned div) {
|
||||
for (unsigned i = 0; i < channels; ++i)
|
||||
convoluters[i].adjustDiv(div);
|
||||
|
@ -38,6 +38,11 @@ float ChainResampler::get3ChainCost(const float ratio, const float rollOff, cons
|
||||
return ratio1 * ratio / ((ratio1 - 1) * 2) + ratio2 * ratio1 / ((ratio2 - 1) * 2) + ratio2 / rollOff;
|
||||
}
|
||||
|
||||
ChainResampler::ChainResampler()
|
||||
: bigSinc(0), buffer2(0), periodSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
std::size_t ChainResampler::reallocateBuffer() {
|
||||
std::size_t bufSz[2] = { 0, 0 };
|
||||
std::size_t inSz = periodSize;
|
||||
@ -55,12 +60,10 @@ std::size_t ChainResampler::reallocateBuffer() {
|
||||
if (inSz >= bufSz[i&1])
|
||||
bufSz[i&1] = 0;
|
||||
|
||||
if (bufferSize < bufSz[0] + bufSz[1]) {
|
||||
delete[] buffer;
|
||||
buffer = (bufferSize = bufSz[0] + bufSz[1]) ? new short[bufferSize * channels] : NULL;
|
||||
}
|
||||
if (buffer.size() < (bufSz[0] + bufSz[1]) * channels)
|
||||
buffer.reset((bufSz[0] + bufSz[1]) * channels);
|
||||
|
||||
buffer2 = bufSz[1] ? buffer + bufSz[0] * channels : NULL;
|
||||
buffer2 = bufSz[1] ? buffer + bufSz[0] * channels : 0;
|
||||
|
||||
return (maxOut_ = inSz);
|
||||
}
|
||||
@ -93,7 +96,7 @@ std::size_t ChainResampler::resample(short *const out, const short *const in, st
|
||||
short *const buf2 = buffer2 ? buffer2 : out;
|
||||
|
||||
const short *inbuf = in;
|
||||
short *outbuf = NULL;
|
||||
short *outbuf = 0;
|
||||
|
||||
for (list_t::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
outbuf = ++list_t::iterator(it) == list.end() ? out : (inbuf == buf ? buf2 : buf);
|
||||
@ -105,11 +108,10 @@ std::size_t ChainResampler::resample(short *const out, const short *const in, st
|
||||
}
|
||||
|
||||
void ChainResampler::uninit() {
|
||||
delete[] buffer;
|
||||
buffer2 = buffer = NULL;
|
||||
bufferSize = 0;
|
||||
buffer2 = 0;
|
||||
buffer.reset();
|
||||
periodSize = 0;
|
||||
bigSinc = NULL;
|
||||
bigSinc = 0;
|
||||
|
||||
for (list_t::iterator it = list.begin(); it != list.end(); ++it)
|
||||
delete *it;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <list>
|
||||
#include "array.h"
|
||||
#include "subresampler.h"
|
||||
#include "../resampler.h"
|
||||
#include "upsampler.h"
|
||||
@ -33,9 +34,8 @@ class ChainResampler : public Resampler {
|
||||
|
||||
list_t list;
|
||||
SubResampler *bigSinc;
|
||||
short *buffer;
|
||||
Array<short> buffer;
|
||||
short *buffer2;
|
||||
std::size_t bufferSize;
|
||||
std::size_t periodSize;
|
||||
std::size_t maxOut_;
|
||||
|
||||
@ -56,14 +56,14 @@ class ChainResampler : public Resampler {
|
||||
template<template<unsigned,unsigned> class Sinc>
|
||||
std::size_t downinit(long inRate, long outRate, std::size_t periodSize);
|
||||
|
||||
std::size_t reallocateBuffer();
|
||||
|
||||
template<template<unsigned,unsigned> class Sinc>
|
||||
std::size_t upinit(long inRate, long outRate, std::size_t periodSize);
|
||||
|
||||
std::size_t reallocateBuffer();
|
||||
|
||||
public:
|
||||
enum { channels = 2 };
|
||||
ChainResampler() : bigSinc(NULL), buffer(NULL), buffer2(NULL), bufferSize(0), periodSize(0) {}
|
||||
ChainResampler();
|
||||
~ChainResampler() { uninit(); }
|
||||
|
||||
void adjustRate(long inRate, long outRate);
|
||||
|
@ -35,7 +35,7 @@ class Cic2Core {
|
||||
// unsigned bufpos;
|
||||
|
||||
public:
|
||||
Cic2Core(const unsigned div = 2) {
|
||||
explicit Cic2Core(const unsigned div = 2) {
|
||||
reset(div);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public:
|
||||
void reset(unsigned div);
|
||||
};
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
void Cic2Core<channels>::reset(const unsigned div) {
|
||||
sum2 = sum1 = 0;
|
||||
prev2 = prev1 = 0;
|
||||
@ -53,7 +53,7 @@ void Cic2Core<channels>::reset(const unsigned div) {
|
||||
// bufpos = div - 1;
|
||||
}
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
std::size_t Cic2Core<channels>::filter(short *out, const short *const in, std::size_t inlen) {
|
||||
// const std::size_t produced = (inlen + div_ - (bufpos + 1)) / div_;
|
||||
const std::size_t produced = (inlen + div_ - nextdivn) / div_;
|
||||
@ -173,19 +173,19 @@ class Cic2 : public SubResampler {
|
||||
|
||||
public:
|
||||
enum { MAX_DIV = 64 };
|
||||
Cic2(unsigned div);
|
||||
explicit Cic2(unsigned div);
|
||||
std::size_t resample(short *out, const short *in, std::size_t inlen);
|
||||
unsigned mul() const { return 1; }
|
||||
unsigned div() const { return cics[0].div(); }
|
||||
};
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
Cic2<channels>::Cic2(const unsigned div) {
|
||||
for (unsigned i = 0; i < channels; ++i)
|
||||
cics[i].reset(div);
|
||||
}
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
std::size_t Cic2<channels>::resample(short *const out, const short *const in, const std::size_t inlen) {
|
||||
std::size_t samplesOut;
|
||||
|
||||
|
@ -37,7 +37,7 @@ class Cic3Core {
|
||||
// unsigned bufpos;
|
||||
|
||||
public:
|
||||
Cic3Core(const unsigned div = 1) {
|
||||
explicit Cic3Core(const unsigned div = 1) {
|
||||
reset(div);
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public:
|
||||
void reset(unsigned div);
|
||||
};
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
void Cic3Core<channels>::reset(const unsigned div) {
|
||||
sum3 = sum2 = sum1 = 0;
|
||||
prev3 = prev2 = prev1 = 0;
|
||||
@ -55,7 +55,7 @@ void Cic3Core<channels>::reset(const unsigned div) {
|
||||
// bufpos = div - 1;
|
||||
}
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
std::size_t Cic3Core<channels>::filter(short *out, const short *const in, std::size_t inlen) {
|
||||
// const std::size_t produced = (inlen + div_ - (bufpos + 1)) / div_;
|
||||
const std::size_t produced = (inlen + div_ - nextdivn) / div_;
|
||||
@ -210,7 +210,7 @@ public:
|
||||
void reset(unsigned div);
|
||||
};
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
void Cic3EvenOddCore<channels>::reset(const unsigned div) {
|
||||
sum3 = sum2 = sum1 = 0;
|
||||
prev3 = prev2 = prev1 = 0;
|
||||
@ -218,7 +218,7 @@ void Cic3EvenOddCore<channels>::reset(const unsigned div) {
|
||||
nextdivn = div;
|
||||
}
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
void Cic3EvenOddCore<channels>::filterEven(short *out, const short *s, std::size_t n) {
|
||||
const int mul = getMul(div_);
|
||||
unsigned long sm1 = sum1;
|
||||
@ -255,7 +255,7 @@ void Cic3EvenOddCore<channels>::filterEven(short *out, const short *s, std::size
|
||||
sum3 = sm3;
|
||||
}
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
void Cic3EvenOddCore<channels>::filterOdd(short *out, const short *s, std::size_t n) {
|
||||
const int mul = getMul(div_);
|
||||
unsigned long sm1 = sum1;
|
||||
@ -297,7 +297,7 @@ void Cic3EvenOddCore<channels>::filterOdd(short *out, const short *s, std::size_
|
||||
sum3 = sm3;
|
||||
}
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
std::size_t Cic3EvenOddCore<channels>::filter(short *out, const short *const in, std::size_t inlen) {
|
||||
short *const outStart = out;
|
||||
const short *s = in;
|
||||
@ -357,19 +357,19 @@ class Cic3 : public SubResampler {
|
||||
|
||||
public:
|
||||
enum { MAX_DIV = 23 };
|
||||
Cic3(unsigned div);
|
||||
explicit Cic3(unsigned div);
|
||||
std::size_t resample(short *out, const short *in, std::size_t inlen);
|
||||
unsigned mul() const { return 1; }
|
||||
unsigned div() const { return cics[0].div(); }
|
||||
};
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
Cic3<channels>::Cic3(const unsigned div) {
|
||||
for (unsigned i = 0; i < channels; ++i)
|
||||
cics[i].reset(div);
|
||||
}
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
std::size_t Cic3<channels>::resample(short *const out, const short *const in, const std::size_t inlen) {
|
||||
std::size_t samplesOut;
|
||||
|
||||
|
@ -39,7 +39,7 @@ class Cic4Core {
|
||||
unsigned bufpos;
|
||||
|
||||
public:
|
||||
Cic4Core(const unsigned div = 1) {
|
||||
explicit Cic4Core(const unsigned div = 1) {
|
||||
reset(div);
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ public:
|
||||
void reset(unsigned div);
|
||||
};
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
void Cic4Core<channels>::reset(const unsigned div) {
|
||||
sum4 = sum3 = sum2 = sum1 = 0;
|
||||
prev4 = prev3 = prev2 = prev1 = 0;
|
||||
@ -57,7 +57,7 @@ void Cic4Core<channels>::reset(const unsigned div) {
|
||||
bufpos = div - 1;
|
||||
}
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
std::size_t Cic4Core<channels>::filter(short *out, const short *const in, std::size_t inlen) {
|
||||
const std::size_t produced = (inlen + div_ - (bufpos + 1)) / div_;
|
||||
// const std::size_t produced = (inlen + div_ - nextdivn) / div_;
|
||||
@ -212,19 +212,19 @@ class Cic4 : public SubResampler {
|
||||
|
||||
public:
|
||||
enum { MAX_DIV = 13 };
|
||||
Cic4(unsigned div);
|
||||
explicit Cic4(unsigned div);
|
||||
std::size_t resample(short *out, const short *in, std::size_t inlen);
|
||||
unsigned mul() const { return 1; }
|
||||
unsigned div() const { return cics[0].div(); }
|
||||
};
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
Cic4<channels>::Cic4(const unsigned div) {
|
||||
for (unsigned i = 0; i < channels; ++i)
|
||||
cics[i].reset(div);
|
||||
}
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
std::size_t Cic4<channels>::resample(short *const out, const short *const in, const std::size_t inlen) {
|
||||
std::size_t samplesOut;
|
||||
|
||||
|
@ -21,39 +21,36 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include "array.h"
|
||||
#include "rshift16_round.h"
|
||||
|
||||
template<unsigned channels, unsigned phases>
|
||||
class PolyPhaseConvoluter {
|
||||
const short *kernel;
|
||||
short *prevbuf;
|
||||
Array<short> prevbuf;
|
||||
|
||||
unsigned phaseLen;
|
||||
unsigned div_;
|
||||
unsigned x_;
|
||||
|
||||
public:
|
||||
PolyPhaseConvoluter() : kernel(NULL), prevbuf(NULL), phaseLen(0), div_(0), x_(0) {}
|
||||
PolyPhaseConvoluter() : kernel(0), div_(0), x_(0) {}
|
||||
PolyPhaseConvoluter(const short *kernel, unsigned phaseLen, unsigned div) { reset(kernel, phaseLen, div); }
|
||||
~PolyPhaseConvoluter() { delete[] prevbuf; }
|
||||
void reset(const short *kernel, unsigned phaseLen, unsigned div);
|
||||
std::size_t filter(short *out, const short *in, std::size_t inlen);
|
||||
void adjustDiv(const unsigned div) { this->div_ = div; }
|
||||
unsigned div() const { return div_; }
|
||||
};
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
void PolyPhaseConvoluter<channels, phases>::reset(const short *const kernel, const unsigned phaseLen, const unsigned div) {
|
||||
this->kernel = kernel;
|
||||
this->phaseLen = phaseLen;
|
||||
this->div_ = div;
|
||||
x_ = 0;
|
||||
delete[] prevbuf;
|
||||
prevbuf = new short[phaseLen];
|
||||
std::fill(prevbuf, prevbuf + phaseLen, 0);
|
||||
prevbuf.reset(phaseLen);
|
||||
std::fill(prevbuf.get(), prevbuf.get() + phaseLen, 0);
|
||||
}
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
std::size_t PolyPhaseConvoluter<channels, phases>::filter(short *out, const short *const in, std::size_t inlen) {
|
||||
if (!kernel || !inlen)
|
||||
return 0;
|
||||
@ -86,6 +83,7 @@ std::size_t PolyPhaseConvoluter<channels, phases>::filter(short *out, const shor
|
||||
} while (--n);
|
||||
}*/
|
||||
|
||||
const std::size_t phaseLen = prevbuf.size();
|
||||
const std::size_t M = phaseLen * phases - 1;
|
||||
inlen *= phases;
|
||||
std::size_t x = x_;
|
||||
|
@ -23,13 +23,14 @@
|
||||
#include "subresampler.h"
|
||||
#include "makesinckernel.h"
|
||||
#include "cic3.h"
|
||||
#include "array.h"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
template<unsigned channels, unsigned phases>
|
||||
class HammingSinc : public SubResampler {
|
||||
PolyPhaseConvoluter<channels, phases> convoluters[channels];
|
||||
short *kernel;
|
||||
Array<short> kernel;
|
||||
|
||||
static double hammingWin(const long i, const long M) {
|
||||
static const double PI = 3.14159265358979323846;
|
||||
@ -64,16 +65,15 @@ public:
|
||||
|
||||
HammingSinc(unsigned div, unsigned phaseLen, double fc) { init(div, phaseLen, fc); }
|
||||
HammingSinc(unsigned div, RollOff ro) { init(div, ro.taps, ro.fc); }
|
||||
~HammingSinc() { delete[] kernel; }
|
||||
std::size_t resample(short *out, const short *in, std::size_t inlen);
|
||||
void adjustDiv(unsigned div);
|
||||
unsigned mul() const { return MUL; }
|
||||
unsigned div() const { return convoluters[0].div(); }
|
||||
};
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
void HammingSinc<channels, phases>::init(const unsigned div, const unsigned phaseLen, const double fc) {
|
||||
kernel = new short[phaseLen * phases];
|
||||
kernel.reset(phaseLen * phases);
|
||||
|
||||
makeSincKernel(kernel, phases, phaseLen, fc, hammingWin);
|
||||
|
||||
@ -81,7 +81,7 @@ void HammingSinc<channels, phases>::init(const unsigned div, const unsigned phas
|
||||
convoluters[i].reset(kernel, phaseLen, div);
|
||||
}
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
std::size_t HammingSinc<channels, phases>::resample(short *const out, const short *const in, const std::size_t inlen) {
|
||||
std::size_t samplesOut;
|
||||
|
||||
@ -91,7 +91,7 @@ std::size_t HammingSinc<channels, phases>::resample(short *const out, const shor
|
||||
return samplesOut;
|
||||
}
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
void HammingSinc<channels, phases>::adjustDiv(const unsigned div) {
|
||||
for (unsigned i = 0; i < channels; ++i)
|
||||
convoluters[i].adjustDiv(div);
|
||||
|
@ -24,13 +24,14 @@
|
||||
#include "makesinckernel.h"
|
||||
#include "i0.h"
|
||||
#include "cic3.h"
|
||||
#include "array.h"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
template<unsigned channels, unsigned phases>
|
||||
class Kaiser50Sinc : public SubResampler {
|
||||
PolyPhaseConvoluter<channels, phases> convoluters[channels];
|
||||
short *kernel;
|
||||
Array<short> kernel;
|
||||
|
||||
static double kaiserWin(const long n, const long M) {
|
||||
static const double beta = 4.62;
|
||||
@ -71,16 +72,15 @@ public:
|
||||
|
||||
Kaiser50Sinc(unsigned div, unsigned phaseLen, double fc) { init(div, phaseLen, fc); }
|
||||
Kaiser50Sinc(unsigned div, RollOff ro) { init(div, ro.taps, ro.fc); }
|
||||
~Kaiser50Sinc() { delete[] kernel; }
|
||||
std::size_t resample(short *out, const short *in, std::size_t inlen);
|
||||
void adjustDiv(unsigned div);
|
||||
unsigned mul() const { return MUL; }
|
||||
unsigned div() const { return convoluters[0].div(); }
|
||||
};
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
void Kaiser50Sinc<channels, phases>::init(const unsigned div, const unsigned phaseLen, const double fc) {
|
||||
kernel = new short[phaseLen * phases];
|
||||
kernel.reset(phaseLen * phases);
|
||||
|
||||
makeSincKernel(kernel, phases, phaseLen, fc, kaiserWin);
|
||||
|
||||
@ -88,7 +88,7 @@ void Kaiser50Sinc<channels, phases>::init(const unsigned div, const unsigned pha
|
||||
convoluters[i].reset(kernel, phaseLen, div);
|
||||
}
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
std::size_t Kaiser50Sinc<channels, phases>::resample(short *const out, const short *const in, const std::size_t inlen) {
|
||||
std::size_t samplesOut;
|
||||
|
||||
@ -98,7 +98,7 @@ std::size_t Kaiser50Sinc<channels, phases>::resample(short *const out, const sho
|
||||
return samplesOut;
|
||||
}
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
void Kaiser50Sinc<channels, phases>::adjustDiv(const unsigned div) {
|
||||
for (unsigned i = 0; i < channels; ++i)
|
||||
convoluters[i].adjustDiv(div);
|
||||
|
@ -24,13 +24,14 @@
|
||||
#include "makesinckernel.h"
|
||||
#include "i0.h"
|
||||
#include "cic4.h"
|
||||
#include "array.h"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
template<unsigned channels, unsigned phases>
|
||||
class Kaiser70Sinc : public SubResampler {
|
||||
PolyPhaseConvoluter<channels, phases> convoluters[channels];
|
||||
short *kernel;
|
||||
Array<short> kernel;
|
||||
|
||||
static double kaiserWin(const long n, const long M) {
|
||||
static const double beta = 6.9;
|
||||
@ -71,16 +72,15 @@ public:
|
||||
|
||||
Kaiser70Sinc(unsigned div, unsigned phaseLen, double fc) { init(div, phaseLen, fc); }
|
||||
Kaiser70Sinc(unsigned div, RollOff ro) { init(div, ro.taps, ro.fc); }
|
||||
~Kaiser70Sinc() { delete[] kernel; }
|
||||
std::size_t resample(short *out, const short *in, std::size_t inlen);
|
||||
void adjustDiv(unsigned div);
|
||||
unsigned mul() const { return MUL; }
|
||||
unsigned div() const { return convoluters[0].div(); }
|
||||
};
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
void Kaiser70Sinc<channels, phases>::init(const unsigned div, const unsigned phaseLen, const double fc) {
|
||||
kernel = new short[phaseLen * phases];
|
||||
kernel.reset(phaseLen * phases);
|
||||
|
||||
makeSincKernel(kernel, phases, phaseLen, fc, kaiserWin);
|
||||
|
||||
@ -88,7 +88,7 @@ void Kaiser70Sinc<channels, phases>::init(const unsigned div, const unsigned pha
|
||||
convoluters[i].reset(kernel, phaseLen, div);
|
||||
}
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
std::size_t Kaiser70Sinc<channels, phases>::resample(short *const out, const short *const in, const std::size_t inlen) {
|
||||
std::size_t samplesOut;
|
||||
|
||||
@ -98,7 +98,7 @@ std::size_t Kaiser70Sinc<channels, phases>::resample(short *const out, const sho
|
||||
return samplesOut;
|
||||
}
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
void Kaiser70Sinc<channels, phases>::adjustDiv(const unsigned div) {
|
||||
for (unsigned i = 0; i < channels; ++i)
|
||||
convoluters[i].adjustDiv(div);
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
std::size_t resample(short *out, const short *in, std::size_t inlen);
|
||||
};
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
void LinintCore<channels>::init(const long inRate, const long outRate) {
|
||||
adjustRate(inRate, outRate);
|
||||
pos_ = (ratio >> 16) + 1;
|
||||
@ -48,7 +48,7 @@ void LinintCore<channels>::init(const long inRate, const long outRate) {
|
||||
prevSample_ = 0;
|
||||
}
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
std::size_t LinintCore<channels>::resample(short *const out, const short *const in, const std::size_t inlen) {
|
||||
std::size_t opos = 0;
|
||||
std::size_t pos = pos_;
|
||||
@ -101,7 +101,7 @@ public:
|
||||
std::size_t resample(short *out, const short *in, std::size_t inlen);
|
||||
};
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
Linint<channels>::Linint(const long inRate, const long outRate) {
|
||||
setRate(inRate, outRate);
|
||||
|
||||
@ -109,7 +109,7 @@ Linint<channels>::Linint(const long inRate, const long outRate) {
|
||||
cores[i].init(inRate, outRate);
|
||||
}
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
void Linint<channels>::adjustRate(const long inRate, const long outRate) {
|
||||
setRate(inRate, outRate);
|
||||
|
||||
@ -117,7 +117,7 @@ void Linint<channels>::adjustRate(const long inRate, const long outRate) {
|
||||
cores[i].adjustRate(inRate, outRate);
|
||||
}
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
std::size_t Linint<channels>::resample(short *const out, const short *const in, const std::size_t inlen) {
|
||||
std::size_t outlen = 0;
|
||||
|
||||
|
@ -17,13 +17,14 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "makesinckernel.h"
|
||||
#include "array.h"
|
||||
|
||||
void makeSincKernel(short *const kernel, const unsigned phases, const unsigned phaseLen, double fc, double (*win)(long m, long M)) {
|
||||
static const double PI = 3.14159265358979323846;
|
||||
fc /= phases;
|
||||
|
||||
/*{
|
||||
double *const dkernel = new double[phaseLen * phases];
|
||||
const Array<double> dkernel(phaseLen * phases);
|
||||
const long M = static_cast<long>(phaseLen) * phases - 1;
|
||||
|
||||
for (long i = 0; i < M + 1; ++i) {
|
||||
@ -61,15 +62,13 @@ void makeSincKernel(short *const kernel, const unsigned phases, const unsigned p
|
||||
|
||||
for (long i = 0; i < M + 1; ++i)
|
||||
kernel[i] = std::floor(dkernel[i] * gain + 0.5);
|
||||
|
||||
delete[] dkernel;
|
||||
}*/
|
||||
|
||||
// The following is equivalent to the more readable version above
|
||||
|
||||
const long M = static_cast<long>(phaseLen) * phases - 1;
|
||||
|
||||
double *const dkernel = new double[M / 2 + 1];
|
||||
const Array<double> dkernel(M / 2 + 1);
|
||||
|
||||
{
|
||||
double *dk = dkernel;
|
||||
@ -140,6 +139,4 @@ void makeSincKernel(short *const kernel, const unsigned phases, const unsigned p
|
||||
for (long i = ph; i < M / 2 + 1; i += phases)
|
||||
*km-- = *k++ = std::floor(*dk++ * gain + 0.5);
|
||||
}
|
||||
|
||||
delete[] dkernel;
|
||||
}
|
||||
|
@ -23,13 +23,14 @@
|
||||
#include "subresampler.h"
|
||||
#include "makesinckernel.h"
|
||||
#include "cic2.h"
|
||||
#include "array.h"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
template<unsigned channels, unsigned phases>
|
||||
class RectSinc : public SubResampler {
|
||||
PolyPhaseConvoluter<channels, phases> convoluters[channels];
|
||||
short *kernel;
|
||||
Array<short> kernel;
|
||||
|
||||
static double rectWin(const long /*i*/, const long /*M*/) {
|
||||
return 1;
|
||||
@ -63,16 +64,15 @@ public:
|
||||
|
||||
RectSinc(unsigned div, unsigned phaseLen, double fc) { init(div, phaseLen, fc); }
|
||||
RectSinc(unsigned div, RollOff ro) { init(div, ro.taps, ro.fc); }
|
||||
~RectSinc() { delete[] kernel; }
|
||||
std::size_t resample(short *out, const short *in, std::size_t inlen);
|
||||
void adjustDiv(unsigned div);
|
||||
unsigned mul() const { return MUL; }
|
||||
unsigned div() const { return convoluters[0].div(); }
|
||||
};
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
void RectSinc<channels, phases>::init(const unsigned div, const unsigned phaseLen, const double fc) {
|
||||
kernel = new short[phaseLen * phases];
|
||||
kernel.reset(phaseLen * phases);
|
||||
|
||||
makeSincKernel(kernel, phases, phaseLen, fc, rectWin);
|
||||
|
||||
@ -80,7 +80,7 @@ void RectSinc<channels, phases>::init(const unsigned div, const unsigned phaseLe
|
||||
convoluters[i].reset(kernel, phaseLen, div);
|
||||
}
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
std::size_t RectSinc<channels, phases>::resample(short *const out, const short *const in, const std::size_t inlen) {
|
||||
std::size_t samplesOut;
|
||||
|
||||
@ -90,7 +90,7 @@ std::size_t RectSinc<channels, phases>::resample(short *const out, const short *
|
||||
return samplesOut;
|
||||
}
|
||||
|
||||
template<const unsigned channels, const unsigned phases>
|
||||
template<unsigned channels, unsigned phases>
|
||||
void RectSinc<channels, phases>::adjustDiv(const unsigned div) {
|
||||
for (unsigned i = 0; i < channels; ++i)
|
||||
convoluters[i].adjustDiv(div);
|
||||
|
@ -39,12 +39,12 @@ struct ChainSincInfo {
|
||||
};
|
||||
|
||||
const ResamplerInfo ResamplerInfo::resamplers[] = {
|
||||
{ "2-tap linear interpolation", LinintInfo::create },
|
||||
{ "Rectangular windowed sinc (~20 dB SNR)", ChainSincInfo<RectSinc>::create },
|
||||
{ "Fast", LinintInfo::create },
|
||||
{ "High quality (CIC + sinc chain)", ChainSincInfo<RectSinc>::create },
|
||||
// { "Hamming windowed sinc (~50 dB SNR)", ChainSincInfo<HammingSinc>::create },
|
||||
// { "Blackman windowed sinc (~70 dB SNR)", ChainSincInfo<BlackmanSinc>::create },
|
||||
{ "Kaiser windowed sinc (~50 dB SNR)", ChainSincInfo<Kaiser50Sinc>::create },
|
||||
{ "Kaiser windowed sinc (~70 dB SNR)", ChainSincInfo<Kaiser70Sinc>::create }
|
||||
{ "Very high quality (CIC + sinc chain)", ChainSincInfo<Kaiser50Sinc>::create },
|
||||
{ "Highest quality (CIC + sinc chain)", ChainSincInfo<Kaiser70Sinc>::create }
|
||||
};
|
||||
|
||||
const unsigned ResamplerInfo::num_ = sizeof(ResamplerInfo::resamplers) / sizeof(ResamplerInfo);
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
unsigned div() const { return 1; }
|
||||
};
|
||||
|
||||
template<const unsigned channels>
|
||||
template<unsigned channels>
|
||||
std::size_t Upsampler<channels>::resample(short *out, const short *in, std::size_t inlen) {
|
||||
if (inlen) {
|
||||
std::memset(out, 0, inlen * mul_ * sizeof(short) * channels);
|
||||
|
@ -18,7 +18,8 @@
|
||||
***************************************************************************/
|
||||
#include "rgb32conv.h"
|
||||
#include "videolink.h"
|
||||
#include <int.h>
|
||||
#include "array.h"
|
||||
#include "gbint.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace {
|
||||
@ -36,7 +37,7 @@ class Rgb32ToUyvy {
|
||||
public:
|
||||
Rgb32ToUyvy();
|
||||
void operator()(const gambatte::uint_least32_t *s, gambatte::uint_least32_t *d,
|
||||
unsigned w, unsigned h, unsigned srcPitch, unsigned dstPitch);
|
||||
unsigned w, unsigned h, int srcPitch, int dstPitch);
|
||||
};
|
||||
|
||||
Rgb32ToUyvy::Rgb32ToUyvy() {
|
||||
@ -48,7 +49,9 @@ Rgb32ToUyvy::Rgb32ToUyvy() {
|
||||
std::fill(cache, cache + cache_size, c);
|
||||
}
|
||||
|
||||
void Rgb32ToUyvy::operator()(const gambatte::uint_least32_t *s, gambatte::uint_least32_t *d, const unsigned w, unsigned h, const unsigned s_pitch, const unsigned d_pitch) {
|
||||
void Rgb32ToUyvy::operator()(const gambatte::uint_least32_t *s,
|
||||
gambatte::uint_least32_t *d, const unsigned w, unsigned h, const int s_pitch, const int d_pitch)
|
||||
{
|
||||
while (h--) {
|
||||
unsigned n = w >> 1;
|
||||
|
||||
@ -80,13 +83,13 @@ void Rgb32ToUyvy::operator()(const gambatte::uint_least32_t *s, gambatte::uint_l
|
||||
d += 2;
|
||||
} while (--n);
|
||||
|
||||
s += s_pitch - w;
|
||||
d += d_pitch - w;
|
||||
s += s_pitch - static_cast<int>(w);
|
||||
d += d_pitch - static_cast<int>(w);
|
||||
}
|
||||
}
|
||||
|
||||
static void rgb32ToRgb16(const gambatte::uint_least32_t *s, gambatte::uint_least16_t *d,
|
||||
const unsigned w, unsigned h, const unsigned srcPitch, const unsigned dstPitch)
|
||||
const unsigned w, unsigned h, const int srcPitch, const int dstPitch)
|
||||
{
|
||||
do {
|
||||
unsigned n = w;
|
||||
@ -96,41 +99,51 @@ static void rgb32ToRgb16(const gambatte::uint_least32_t *s, gambatte::uint_least
|
||||
++s;
|
||||
} while (--n);
|
||||
|
||||
s += srcPitch - w;
|
||||
d += dstPitch - w;
|
||||
s += srcPitch - static_cast<int>(w);
|
||||
d += dstPitch - static_cast<int>(w);
|
||||
} while (--h);
|
||||
}
|
||||
|
||||
class Rgb32ToUyvyLink : public VideoLink {
|
||||
const Array<gambatte::uint_least32_t> inbuf_;
|
||||
Rgb32ToUyvy rgb32ToUyvy;
|
||||
const unsigned width_;
|
||||
const unsigned height_;
|
||||
|
||||
public:
|
||||
Rgb32ToUyvyLink(unsigned width, unsigned height) :
|
||||
VideoLink(new gambatte::uint_least32_t[width * height], width),
|
||||
width_(width), height_(height) {}
|
||||
~Rgb32ToUyvyLink() { delete[] static_cast<gambatte::uint_least32_t*>(inBuf()); }
|
||||
Rgb32ToUyvyLink(unsigned width, unsigned height)
|
||||
: inbuf_(static_cast<std::size_t>(width) * height),
|
||||
width_(width),
|
||||
height_(height)
|
||||
{
|
||||
}
|
||||
|
||||
void draw(void *dst, unsigned dstpitch) {
|
||||
rgb32ToUyvy(static_cast<gambatte::uint_least32_t*>(inBuf()),
|
||||
static_cast<gambatte::uint_least32_t*>(dst), width_, height_, inPitch(), dstpitch);
|
||||
virtual void* inBuf() const { return inbuf_; }
|
||||
virtual int inPitch() const { return width_; }
|
||||
|
||||
virtual void draw(void *dst, int dstpitch) {
|
||||
rgb32ToUyvy(inbuf_, static_cast<gambatte::uint_least32_t*>(dst), width_, height_, inPitch(), dstpitch);
|
||||
}
|
||||
};
|
||||
|
||||
class Rgb32ToRgb16Link : public VideoLink {
|
||||
const Array<gambatte::uint_least32_t> inbuf_;
|
||||
const unsigned width_;
|
||||
const unsigned height_;
|
||||
|
||||
public:
|
||||
Rgb32ToRgb16Link(unsigned width, unsigned height) :
|
||||
VideoLink(new gambatte::uint_least32_t[width * height], width),
|
||||
width_(width), height_(height) {}
|
||||
~Rgb32ToRgb16Link() { delete[] static_cast<gambatte::uint_least32_t*>(inBuf()); }
|
||||
Rgb32ToRgb16Link(unsigned width, unsigned height)
|
||||
: inbuf_(static_cast<std::size_t>(width) * height),
|
||||
width_(width),
|
||||
height_(height)
|
||||
{
|
||||
}
|
||||
|
||||
void draw(void *dst, unsigned dstpitch) {
|
||||
rgb32ToRgb16(static_cast<gambatte::uint_least32_t*>(inBuf()),
|
||||
static_cast<gambatte::uint_least16_t*>(dst), width_, height_, inPitch(), dstpitch);
|
||||
virtual void* inBuf() const { return inbuf_; }
|
||||
virtual int inPitch() const { return width_; }
|
||||
|
||||
virtual void draw(void *dst, int dstpitch) {
|
||||
rgb32ToRgb16(inbuf_, static_cast<gambatte::uint_least16_t*>(dst), width_, height_, inPitch(), dstpitch);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ static const VfilterInfo vfinfos[] = {
|
||||
VFINFO("MaxSt's hq3x", MaxStHq3x)
|
||||
};
|
||||
|
||||
unsigned VfilterInfo::numVfilters() {
|
||||
return (sizeof(vfinfos) / sizeof(VfilterInfo));
|
||||
std::size_t VfilterInfo::numVfilters() {
|
||||
return sizeof(vfinfos) / sizeof(vfinfos[0]);
|
||||
}
|
||||
|
||||
const VfilterInfo& VfilterInfo::get(unsigned n) {
|
||||
const VfilterInfo& VfilterInfo::get(std::size_t n) {
|
||||
return vfinfos[n];
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef VFILTERINFO_H
|
||||
#define VFILTERINFO_H
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
class VideoLink;
|
||||
|
||||
struct VfilterInfo {
|
||||
@ -30,8 +32,8 @@ struct VfilterInfo {
|
||||
unsigned outHeight;
|
||||
VideoLink* (*create)();
|
||||
|
||||
static const VfilterInfo& get(unsigned n);
|
||||
static unsigned numVfilters();
|
||||
static const VfilterInfo& get(std::size_t n);
|
||||
static std::size_t numVfilters();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -17,18 +17,13 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "catrom2x.h"
|
||||
#include <cstring>
|
||||
#include <int.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace {
|
||||
enum { WIDTH = VfilterInfo::IN_WIDTH };
|
||||
enum { HEIGHT = VfilterInfo::IN_HEIGHT };
|
||||
enum { PITCH = WIDTH + 3 };
|
||||
|
||||
static inline gambatte::uint_least32_t* buffer(const Catrom2x *c2x) {
|
||||
return static_cast<gambatte::uint_least32_t*>(c2x->inBuf()) - (PITCH + 1);
|
||||
}
|
||||
|
||||
struct Colorsum {
|
||||
gambatte::uint_least32_t r, g, b;
|
||||
};
|
||||
@ -99,7 +94,7 @@ static void merge_columns(gambatte::uint_least32_t *dest, const Colorsum *sums)
|
||||
}
|
||||
}
|
||||
|
||||
static void filter(gambatte::uint_least32_t *dline, const unsigned pitch, const gambatte::uint_least32_t *sline) {
|
||||
static void filter(gambatte::uint_least32_t *dline, const int pitch, const gambatte::uint_least32_t *sline) {
|
||||
Colorsum sums[PITCH];
|
||||
|
||||
for (unsigned h = HEIGHT; h--;) {
|
||||
@ -165,14 +160,20 @@ static void filter(gambatte::uint_least32_t *dline, const unsigned pitch, const
|
||||
}
|
||||
}
|
||||
|
||||
Catrom2x::Catrom2x() : VideoLink((new gambatte::uint_least32_t[(HEIGHT + 3UL) * PITCH]) + (PITCH + 1), PITCH) {
|
||||
std::memset(buffer(this), 0, (HEIGHT + 3UL) * PITCH * sizeof(gambatte::uint_least32_t));
|
||||
Catrom2x::Catrom2x()
|
||||
: buffer_((HEIGHT + 3UL) * PITCH)
|
||||
{
|
||||
std::fill_n(buffer_.get(), buffer_.size(), 0);
|
||||
}
|
||||
|
||||
Catrom2x::~Catrom2x() {
|
||||
delete[] buffer(this);
|
||||
void* Catrom2x::inBuf() const {
|
||||
return buffer_ + PITCH + 1;
|
||||
}
|
||||
|
||||
void Catrom2x::draw(void *const dbuffer, const unsigned pitch) {
|
||||
::filter(static_cast<gambatte::uint_least32_t*>(dbuffer), pitch, buffer(this) + PITCH);
|
||||
int Catrom2x::inPitch() const {
|
||||
return PITCH;
|
||||
}
|
||||
|
||||
void Catrom2x::draw(void *const dbuffer, const int pitch) {
|
||||
::filter(static_cast<gambatte::uint_least32_t*>(dbuffer), pitch, buffer_ + PITCH);
|
||||
}
|
||||
|
@ -21,15 +21,19 @@
|
||||
|
||||
#include "../videolink.h"
|
||||
#include "../vfilterinfo.h"
|
||||
#include "array.h"
|
||||
#include "gbint.h"
|
||||
|
||||
class Catrom2x : public VideoLink {
|
||||
const Array<gambatte::uint_least32_t> buffer_;
|
||||
public:
|
||||
enum { OUT_WIDTH = VfilterInfo::IN_WIDTH * 2 };
|
||||
enum { OUT_HEIGHT = VfilterInfo::IN_HEIGHT * 2 };
|
||||
|
||||
Catrom2x();
|
||||
~Catrom2x();
|
||||
void draw(void *dst, unsigned dstpitch);
|
||||
virtual void* inBuf() const;
|
||||
virtual int inPitch() const;
|
||||
virtual void draw(void *dst, int dstpitch);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -17,18 +17,13 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "catrom3x.h"
|
||||
#include <cstring>
|
||||
#include <int.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace {
|
||||
enum { WIDTH = VfilterInfo::IN_WIDTH };
|
||||
enum { HEIGHT = VfilterInfo::IN_HEIGHT };
|
||||
enum { PITCH = WIDTH + 3 };
|
||||
|
||||
static inline gambatte::uint_least32_t* buffer(const Catrom3x *c3x) {
|
||||
return static_cast<gambatte::uint_least32_t*>(c3x->inBuf()) - (PITCH + 1);
|
||||
}
|
||||
|
||||
struct Colorsum {
|
||||
gambatte::uint_least32_t r, g, b;
|
||||
};
|
||||
@ -226,7 +221,7 @@ static void merge_columns(gambatte::uint_least32_t *dest, const Colorsum *sums)
|
||||
}
|
||||
}
|
||||
|
||||
static void filter(gambatte::uint_least32_t *dline, const unsigned pitch, const gambatte::uint_least32_t *sline) {
|
||||
static void filter(gambatte::uint_least32_t *dline, const int pitch, const gambatte::uint_least32_t *sline) {
|
||||
Colorsum sums[PITCH];
|
||||
|
||||
for (unsigned h = HEIGHT; h--;) {
|
||||
@ -331,14 +326,20 @@ static void filter(gambatte::uint_least32_t *dline, const unsigned pitch, const
|
||||
}
|
||||
}
|
||||
|
||||
Catrom3x::Catrom3x() : VideoLink((new gambatte::uint_least32_t[(HEIGHT + 3UL) * PITCH]) + (PITCH + 1), PITCH) {
|
||||
std::memset(buffer(this), 0, (HEIGHT + 3UL) * PITCH * sizeof(gambatte::uint_least32_t));
|
||||
Catrom3x::Catrom3x()
|
||||
: buffer_((HEIGHT + 3UL) * PITCH)
|
||||
{
|
||||
std::fill_n(buffer_.get(), buffer_.size(), 0);
|
||||
}
|
||||
|
||||
Catrom3x::~Catrom3x() {
|
||||
delete[] buffer(this);
|
||||
void* Catrom3x::inBuf() const {
|
||||
return buffer_ + PITCH + 1;
|
||||
}
|
||||
|
||||
void Catrom3x::draw(void *const dbuffer, const unsigned pitch) {
|
||||
::filter(static_cast<gambatte::uint_least32_t*>(dbuffer), pitch, buffer(this) + PITCH);
|
||||
int Catrom3x::inPitch() const {
|
||||
return PITCH;
|
||||
}
|
||||
|
||||
void Catrom3x::draw(void *const dbuffer, const int pitch) {
|
||||
::filter(static_cast<gambatte::uint_least32_t*>(dbuffer), pitch, buffer_ + PITCH);
|
||||
}
|
||||
|
@ -21,15 +21,19 @@
|
||||
|
||||
#include "../videolink.h"
|
||||
#include "../vfilterinfo.h"
|
||||
#include "array.h"
|
||||
#include "gbint.h"
|
||||
|
||||
class Catrom3x : public VideoLink {
|
||||
const Array<gambatte::uint_least32_t> buffer_;
|
||||
public:
|
||||
enum { OUT_WIDTH = VfilterInfo::IN_WIDTH * 3 };
|
||||
enum { OUT_HEIGHT = VfilterInfo::IN_HEIGHT * 3 };
|
||||
|
||||
Catrom3x();
|
||||
~Catrom3x();
|
||||
void draw(void *dst, unsigned dstpitch);
|
||||
virtual void* inBuf() const;
|
||||
virtual int inPitch() const;
|
||||
virtual void draw(void *dst, int dstpitch);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Sindre Aam<EFBFBD>s *
|
||||
* Copyright (C) 2007 by Sindre Aamås *
|
||||
* aamas@stud.ntnu.no *
|
||||
* *
|
||||
* Copyright (C) 1999 Derek Liauw Kie Fa (Kreed) *
|
||||
@ -19,8 +19,7 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "kreed2xsai.h"
|
||||
#include <cstring>
|
||||
#include <int.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace {
|
||||
|
||||
@ -71,8 +70,7 @@ static inline unsigned long qInterpolate(const unsigned long a, const unsigned l
|
||||
}
|
||||
|
||||
template<unsigned srcPitch, unsigned width, unsigned height>
|
||||
static void filter(gambatte::uint_least32_t *dstPtr, const unsigned dstPitch,
|
||||
const gambatte::uint_least32_t *srcPtr)
|
||||
static void filter(gambatte::uint_least32_t *dstPtr, const int dstPitch, const gambatte::uint_least32_t *srcPtr)
|
||||
{
|
||||
unsigned h = height;
|
||||
|
||||
@ -215,20 +213,22 @@ enum { PITCH = WIDTH + 3 };
|
||||
enum { BUF_SIZE = (HEIGHT + 3) * PITCH };
|
||||
enum { BUF_OFFSET = PITCH + 1 };
|
||||
|
||||
static inline gambatte::uint_least32_t* buffer(const Kreed2xSaI *c2x) {
|
||||
return static_cast<gambatte::uint_least32_t*>(c2x->inBuf()) - BUF_OFFSET;
|
||||
}
|
||||
|
||||
Kreed2xSaI::Kreed2xSaI()
|
||||
: buffer_(BUF_SIZE)
|
||||
{
|
||||
std::fill_n(buffer_.get(), buffer_.size(), 0);
|
||||
}
|
||||
|
||||
Kreed2xSaI::Kreed2xSaI() : VideoLink(new gambatte::uint_least32_t[BUF_SIZE] + BUF_OFFSET, PITCH) {
|
||||
std::memset(buffer(this), 0, BUF_SIZE * sizeof(gambatte::uint_least32_t));
|
||||
void* Kreed2xSaI::inBuf() const {
|
||||
return buffer_ + BUF_OFFSET;
|
||||
}
|
||||
|
||||
Kreed2xSaI::~Kreed2xSaI() {
|
||||
delete[] buffer(this);
|
||||
int Kreed2xSaI::inPitch() const {
|
||||
return PITCH;
|
||||
}
|
||||
|
||||
void Kreed2xSaI::draw(void *const dbuffer, const unsigned pitch) {
|
||||
::filter<PITCH, WIDTH, HEIGHT>(static_cast<gambatte::uint_least32_t*>(dbuffer), pitch, buffer(this) + BUF_OFFSET);
|
||||
void Kreed2xSaI::draw(void *const dbuffer, const int pitch) {
|
||||
::filter<PITCH, WIDTH, HEIGHT>(static_cast<gambatte::uint_least32_t*>(dbuffer), pitch, buffer_ + BUF_OFFSET);
|
||||
}
|
||||
|
@ -21,15 +21,19 @@
|
||||
|
||||
#include "../videolink.h"
|
||||
#include "../vfilterinfo.h"
|
||||
#include "array.h"
|
||||
#include "gbint.h"
|
||||
|
||||
class Kreed2xSaI : public VideoLink {
|
||||
const Array<gambatte::uint_least32_t> buffer_;
|
||||
public:
|
||||
enum { OUT_WIDTH = VfilterInfo::IN_WIDTH * 2 };
|
||||
enum { OUT_HEIGHT = VfilterInfo::IN_HEIGHT * 2 };
|
||||
|
||||
Kreed2xSaI();
|
||||
~Kreed2xSaI();
|
||||
void draw(void *dst, unsigned dstpitch);
|
||||
virtual void* inBuf() const;
|
||||
virtual int inPitch() const;
|
||||
virtual void draw(void *dst, int dstpitch);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -20,8 +20,6 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "maxsthq2x.h"
|
||||
#include <int.h>
|
||||
#include <cstring>
|
||||
|
||||
static /*inline*/ unsigned long Interp1(const unsigned long c1, const unsigned long c2) {
|
||||
const unsigned long lowbits = ((c1 & 0x030303) * 3 + (c2 & 0x030303)) & 0x030303;
|
||||
@ -48,13 +46,13 @@ static /*inline*/ unsigned long Interp7(const unsigned long c1, const unsigned l
|
||||
}
|
||||
|
||||
static /*inline*/ unsigned long Interp9(unsigned long c1, const unsigned long c2, const unsigned long c3) {
|
||||
const unsigned lowbits = ((c1 * 2 & 0x070707) + ((c2 & 0x070707) + (c3 & 0x070707)) * 3) & 0x070707;
|
||||
const unsigned long lowbits = ((c1 * 2 & 0x070707) + ((c2 & 0x070707) + (c3 & 0x070707)) * 3) & 0x070707;
|
||||
|
||||
return (c1 * 2 + (c2 + c3) * 3 - lowbits) >> 3;
|
||||
}
|
||||
|
||||
static /*inline*/ unsigned long Interp10(const unsigned long c1, const unsigned long c2, const unsigned long c3) {
|
||||
const unsigned lowbits = ((c1 & 0x0F0F0F) * 14 + (c2 & 0x0F0F0F) + (c3 & 0x0F0F0F)) & 0x0F0F0F;
|
||||
const unsigned long lowbits = ((c1 & 0x0F0F0F) * 14 + (c2 & 0x0F0F0F) + (c3 & 0x0F0F0F)) & 0x0F0F0F;
|
||||
|
||||
return (c1 * 14 + c2 + c3 - lowbits) >> 4;
|
||||
}
|
||||
@ -119,8 +117,7 @@ static /*inline*/ bool Diff(const unsigned long w1, const unsigned long w2) {
|
||||
}
|
||||
|
||||
template<unsigned Xres, unsigned Yres>
|
||||
static void filter(gambatte::uint_least32_t *pOut, const unsigned dstPitch,
|
||||
const gambatte::uint_least32_t *pIn)
|
||||
static void filter(gambatte::uint_least32_t *pOut, const int dstPitch, const gambatte::uint_least32_t *pIn)
|
||||
{
|
||||
unsigned long w[10];
|
||||
|
||||
@ -2836,20 +2833,23 @@ static void filter(gambatte::uint_least32_t *pOut, const unsigned dstPitch,
|
||||
++pIn;
|
||||
pOut += 2;
|
||||
}
|
||||
pOut += dstPitch * 2 - Xres * 2;
|
||||
pOut += dstPitch * 2 - static_cast<int>(Xres * 2);
|
||||
}
|
||||
}
|
||||
|
||||
static inline gambatte::uint_least32_t* buffer(const MaxStHq2x *hq2x) {
|
||||
return static_cast<gambatte::uint_least32_t*>(hq2x->inBuf());
|
||||
MaxStHq2x::MaxStHq2x()
|
||||
: buffer_(VfilterInfo::IN_HEIGHT * VfilterInfo::IN_WIDTH)
|
||||
{
|
||||
}
|
||||
|
||||
MaxStHq2x::MaxStHq2x() : VideoLink(new gambatte::uint_least32_t[VfilterInfo::IN_HEIGHT * VfilterInfo::IN_WIDTH], VfilterInfo::IN_WIDTH) {}
|
||||
|
||||
MaxStHq2x::~MaxStHq2x() {
|
||||
delete[] buffer(this);
|
||||
void* MaxStHq2x::inBuf() const {
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
void MaxStHq2x::draw(void *const dbuffer, const unsigned pitch) {
|
||||
::filter<VfilterInfo::IN_WIDTH, VfilterInfo::IN_HEIGHT>(static_cast<gambatte::uint_least32_t*>(dbuffer), pitch, buffer(this));
|
||||
int MaxStHq2x::inPitch() const {
|
||||
return VfilterInfo::IN_WIDTH;
|
||||
}
|
||||
|
||||
void MaxStHq2x::draw(void *const dbuffer, const int pitch) {
|
||||
::filter<VfilterInfo::IN_WIDTH, VfilterInfo::IN_HEIGHT>(static_cast<gambatte::uint_least32_t*>(dbuffer), pitch, buffer_);
|
||||
}
|
||||
|
@ -21,15 +21,19 @@
|
||||
|
||||
#include "../videolink.h"
|
||||
#include "../vfilterinfo.h"
|
||||
#include "array.h"
|
||||
#include "gbint.h"
|
||||
|
||||
class MaxStHq2x : public VideoLink {
|
||||
const Array<gambatte::uint_least32_t> buffer_;
|
||||
public:
|
||||
enum { OUT_WIDTH = VfilterInfo::IN_WIDTH * 2 };
|
||||
enum { OUT_HEIGHT = VfilterInfo::IN_HEIGHT * 2 };
|
||||
|
||||
MaxStHq2x();
|
||||
~MaxStHq2x();
|
||||
void draw(void *dst, unsigned dstpitch);
|
||||
virtual void* inBuf() const;
|
||||
virtual int inPitch() const;
|
||||
virtual void draw(void *dst, int dstpitch);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -20,8 +20,6 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "maxsthq3x.h"
|
||||
#include <int.h>
|
||||
#include <cstring>
|
||||
|
||||
static /*inline*/ unsigned long Interp1(const unsigned long c1, const unsigned long c2) {
|
||||
const unsigned long lowbits = ((c1 & 0x030303) * 3 + (c2 & 0x030303)) & 0x030303;
|
||||
@ -116,8 +114,7 @@ static /*inline*/ bool Diff(const unsigned long w1, const unsigned long w2) {
|
||||
}
|
||||
|
||||
template<unsigned Xres, unsigned Yres>
|
||||
static void filter(gambatte::uint_least32_t *pOut, const unsigned dstPitch,
|
||||
const gambatte::uint_least32_t *pIn)
|
||||
static void filter(gambatte::uint_least32_t *pOut, const int dstPitch, const gambatte::uint_least32_t *pIn)
|
||||
{
|
||||
unsigned long w[10];
|
||||
|
||||
@ -3806,20 +3803,23 @@ static void filter(gambatte::uint_least32_t *pOut, const unsigned dstPitch,
|
||||
++pIn;
|
||||
pOut += 3;
|
||||
}
|
||||
pOut += dstPitch * 3 - Xres * 3;
|
||||
pOut += dstPitch * 3 - static_cast<int>(Xres * 3);
|
||||
}
|
||||
}
|
||||
|
||||
static inline gambatte::uint_least32_t* buffer(const MaxStHq3x *hq3x) {
|
||||
return static_cast<gambatte::uint_least32_t*>(hq3x->inBuf());
|
||||
MaxStHq3x::MaxStHq3x()
|
||||
: buffer_(VfilterInfo::IN_HEIGHT * VfilterInfo::IN_WIDTH)
|
||||
{
|
||||
}
|
||||
|
||||
MaxStHq3x::MaxStHq3x() : VideoLink(new gambatte::uint_least32_t[VfilterInfo::IN_HEIGHT * VfilterInfo::IN_WIDTH], VfilterInfo::IN_WIDTH) {}
|
||||
|
||||
MaxStHq3x::~MaxStHq3x() {
|
||||
delete[] buffer(this);
|
||||
void* MaxStHq3x::inBuf() const {
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
void MaxStHq3x::draw(void *const dbuffer, const unsigned pitch) {
|
||||
::filter<VfilterInfo::IN_WIDTH, VfilterInfo::IN_HEIGHT>(static_cast<gambatte::uint_least32_t*>(dbuffer), pitch, buffer(this));
|
||||
int MaxStHq3x::inPitch() const {
|
||||
return VfilterInfo::IN_WIDTH;
|
||||
}
|
||||
|
||||
void MaxStHq3x::draw(void *const dbuffer, const int pitch) {
|
||||
::filter<VfilterInfo::IN_WIDTH, VfilterInfo::IN_HEIGHT>(static_cast<gambatte::uint_least32_t*>(dbuffer), pitch, buffer_);
|
||||
}
|
||||
|
@ -21,15 +21,19 @@
|
||||
|
||||
#include "../videolink.h"
|
||||
#include "../vfilterinfo.h"
|
||||
#include "array.h"
|
||||
#include "gbint.h"
|
||||
|
||||
class MaxStHq3x : public VideoLink {
|
||||
const Array<gambatte::uint_least32_t> buffer_;
|
||||
public:
|
||||
enum { OUT_WIDTH = VfilterInfo::IN_WIDTH * 3 };
|
||||
enum { OUT_HEIGHT = VfilterInfo::IN_HEIGHT * 3 };
|
||||
|
||||
MaxStHq3x();
|
||||
~MaxStHq3x();
|
||||
void draw(void *dst, unsigned dstpitch);
|
||||
virtual void* inBuf() const;
|
||||
virtual int inPitch() const;
|
||||
virtual void draw(void *dst, int dstpitch);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -20,15 +20,11 @@
|
||||
#define VIDEOLINK_H
|
||||
|
||||
class VideoLink {
|
||||
void *const inbuf;
|
||||
const unsigned inpitch;
|
||||
protected:
|
||||
VideoLink(void *inbuf, unsigned inpitch) : inbuf(inbuf), inpitch(inpitch) {}
|
||||
public:
|
||||
void* inBuf() const { return inbuf; }
|
||||
unsigned inPitch() const { return inpitch; }
|
||||
virtual ~VideoLink() {}
|
||||
virtual void draw(void *dst, unsigned dstpitch) = 0;
|
||||
virtual void* inBuf() const = 0;
|
||||
virtual int inPitch() const = 0;
|
||||
virtual void draw(void *dst, int dstpitch) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -41,6 +41,7 @@ dpadLeftLast(false) {
|
||||
std::fill(inputState, inputState + 8, false);
|
||||
}
|
||||
|
||||
namespace {
|
||||
static const InputDialog::Button constructButtonInfo(InputDialog::Button::Action *action, const char *label,
|
||||
const char *category, int defaultKey = Qt::Key_unknown, int defaultAltKey = Qt::Key_unknown) {
|
||||
InputDialog::Button b = { label: label, category: category, defaultKey: defaultKey,
|
||||
@ -65,6 +66,7 @@ struct GbDirAct : InputDialog::Button::Action {
|
||||
};
|
||||
|
||||
enum { A_BUT, B_BUT, SELECT_BUT, START_BUT, RIGHT_BUT, LEFT_BUT, UP_BUT, DOWN_BUT };
|
||||
}
|
||||
|
||||
InputDialog* GambatteSource::createInputDialog() {
|
||||
std::vector<InputDialog::Button> v;
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define BLITTERWRAPPER_H
|
||||
|
||||
#include "sdlblitter.h"
|
||||
#include "int.h"
|
||||
#include "gbint.h"
|
||||
#include "videolink/videolink.h"
|
||||
#include <memory>
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define GAMBATTE_H
|
||||
|
||||
#include "inputgetter.h"
|
||||
#include "int.h"
|
||||
#include "gbint.h"
|
||||
#include <string>
|
||||
|
||||
namespace gambatte {
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef BITMAP_FONT_H
|
||||
#define BITMAP_FONT_H
|
||||
|
||||
#include "int.h"
|
||||
#include "gbint.h"
|
||||
|
||||
namespace bitmapfont {
|
||||
enum Char {
|
||||
|
@ -19,7 +19,6 @@
|
||||
#ifndef CPU_H
|
||||
#define CPU_H
|
||||
|
||||
#include "int.h"
|
||||
#include "memory.h"
|
||||
|
||||
namespace gambatte {
|
||||
|
@ -25,17 +25,17 @@
|
||||
|
||||
namespace gambatte {
|
||||
|
||||
Memory::Memory(const Interrupter &interrupter_in) :
|
||||
vrambank(vram),
|
||||
getInput(0),
|
||||
divLastUpdate(0),
|
||||
lastOamDmaUpdate(DISABLED_TIME),
|
||||
display(ioamhram, vram, VideoInterruptRequester(&intreq)),
|
||||
interrupter(interrupter_in),
|
||||
dmaSource(0),
|
||||
dmaDestination(0),
|
||||
oamDmaPos(0xFE),
|
||||
blanklcd(false)
|
||||
Memory::Memory(const Interrupter &interrupter_in)
|
||||
: vrambank(vram),
|
||||
getInput(0),
|
||||
divLastUpdate(0),
|
||||
lastOamDmaUpdate(DISABLED_TIME),
|
||||
display(ioamhram, vram, VideoInterruptRequester(&intreq)),
|
||||
interrupter(interrupter_in),
|
||||
dmaSource(0),
|
||||
dmaDestination(0),
|
||||
oamDmaPos(0xFE),
|
||||
blanklcd(false)
|
||||
{
|
||||
intreq.setEventTime<BLIT>(144*456ul);
|
||||
intreq.setEventTime<END>(0);
|
||||
@ -758,7 +758,7 @@ void Memory::nontrivial_ff_write(const unsigned P, unsigned data, const unsigned
|
||||
if (data & 0x80) {
|
||||
intreq.setEventTime<BLIT>(display.nextMode1IrqTime() + (blanklcd ? 0 : 70224 << isDoubleSpeed()));
|
||||
} else {
|
||||
ioamhram[0x141] |= lyc; //Mr. Do! needs conicidence flag preserved.
|
||||
ioamhram[0x141] |= lyc;
|
||||
intreq.setEventTime<BLIT>(cycleCounter + (456 * 4 << isDoubleSpeed()));
|
||||
|
||||
if (hdmaEnabled)
|
||||
|
@ -20,7 +20,6 @@
|
||||
#define MEMORY_H
|
||||
|
||||
#include "mem/cartridge.h"
|
||||
#include "int.h"
|
||||
#include "video.h"
|
||||
#include "sound.h"
|
||||
#include "interrupter.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef OSD_ELEMENT_H
|
||||
#define OSD_ELEMENT_H
|
||||
|
||||
#include "int.h"
|
||||
#include "gbint.h"
|
||||
|
||||
namespace gambatte {
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#ifndef SOUND_H
|
||||
#define SOUND_H
|
||||
|
||||
#include "int.h"
|
||||
#include "sound/channel1.h"
|
||||
#include "sound/channel2.h"
|
||||
#include "sound/channel3.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef SOUND_CHANNEL1_H
|
||||
#define SOUND_CHANNEL1_H
|
||||
|
||||
#include "int.h"
|
||||
#include "gbint.h"
|
||||
#include "master_disabler.h"
|
||||
#include "length_counter.h"
|
||||
#include "duty_unit.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef SOUND_CHANNEL2_H
|
||||
#define SOUND_CHANNEL2_H
|
||||
|
||||
#include "int.h"
|
||||
#include "gbint.h"
|
||||
#include "length_counter.h"
|
||||
#include "duty_unit.h"
|
||||
#include "envelope_unit.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef SOUND_CHANNEL3_H
|
||||
#define SOUND_CHANNEL3_H
|
||||
|
||||
#include "int.h"
|
||||
#include "gbint.h"
|
||||
#include "master_disabler.h"
|
||||
#include "length_counter.h"
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef SOUND_CHANNEL4_H
|
||||
#define SOUND_CHANNEL4_H
|
||||
|
||||
#include "int.h"
|
||||
#include "gbint.h"
|
||||
#include "master_disabler.h"
|
||||
#include "length_counter.h"
|
||||
#include "envelope_unit.h"
|
||||
|
@ -437,7 +437,7 @@ bool StateSaver::loadState(SaveState &state, const std::string &filename) {
|
||||
file.ignore();
|
||||
file.ignore(get24(file));
|
||||
|
||||
Array<char> labelbuf(list.maxLabelsize());
|
||||
const Array<char> labelbuf(list.maxLabelsize());
|
||||
const Saver labelbufSaver = { label: labelbuf, save: 0, load: 0, labelsize: list.maxLabelsize() };
|
||||
|
||||
SaverList::const_iterator done = list.begin();
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef STATESAVER_H
|
||||
#define STATESAVER_H
|
||||
|
||||
#include "int.h"
|
||||
#include "gbint.h"
|
||||
#include <string>
|
||||
|
||||
namespace gambatte {
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "video/ly_counter.h"
|
||||
#include "video/sprite_mapper.h"
|
||||
#include "int.h"
|
||||
#include "gbint.h"
|
||||
|
||||
namespace gambatte {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user