Skip to content

Commit

Permalink
c++17 strict conformance
Browse files Browse the repository at this point in the history
  • Loading branch information
pinterf committed Mar 23, 2020
1 parent 016494f commit c95dac2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 57 deletions.
44 changes: 22 additions & 22 deletions dfttest/MersenneTwister.h
Expand Up @@ -213,7 +213,7 @@ inline MTRand::uint32 MTRand::randInt()
if (left == 0) reload();
--left;

register uint32 s1;
uint32 s1;
s1 = *pNext++;
s1 ^= (s1 >> 11);
s1 ^= (s1 << 7) & 0x9d2c5680UL;
Expand Down Expand Up @@ -258,9 +258,9 @@ inline void MTRand::seed(uint32* const bigSeed, const uint32 seedLength)
// in each element are discarded.
// Just call seed() if you want to get array from /dev/urandom
initialize(19650218UL);
register int i = 1;
register uint32 j = 0;
register int k = (N > seedLength ? N : seedLength);
int i = 1;
uint32 j = 0;
int k = (N > seedLength ? N : seedLength);
for (; k; --k)
{
state[i] =
Expand Down Expand Up @@ -295,9 +295,9 @@ inline void MTRand::seed()
if (urandom)
{
uint32 bigSeed[N];
register uint32* s = bigSeed;
register int i = N;
register bool success = true;
uint32* s = bigSeed;
int i = N;
bool success = true;
while (success && i--)
success = (fread(s++, sizeof(uint32), 1, urandom) != 0);
fclose(urandom);
Expand All @@ -315,9 +315,9 @@ inline void MTRand::initialize(const uint32 seed)
// See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
// In previous versions, most significant bits (MSBs) of the seed affect
// only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto.
register uint32* s = state;
register uint32* r = state;
register int i = 1;
uint32* s = state;
uint32* r = state;
int i = 1;
*s++ = seed & 0xffffffffUL;
for (; i < N; ++i)
{
Expand All @@ -331,8 +331,8 @@ inline void MTRand::reload()
{
// Generate N new values in state
// Made clearer and faster by Matthew Bellew (matthew.bellew@home.com)
register uint32* p = state;
register int i;
uint32* p = state;
int i;
for (i = N - M; i--; ++p)
*p = twist(p[M], p[0], p[1]);
for (i = M; --i; ++p)
Expand Down Expand Up @@ -371,19 +371,19 @@ inline MTRand::uint32 MTRand::hash(time_t t, clock_t c)

inline void MTRand::save(uint32* saveArray) const
{
register uint32* sa = saveArray;
register const uint32* s = state;
register int i = N;
uint32* sa = saveArray;
const uint32* s = state;
int i = N;
for (; i--; *sa++ = *s++) {}
*sa = left;
}


inline void MTRand::load(uint32* const loadArray)
{
register uint32* s = state;
register uint32* la = loadArray;
register int i = N;
uint32* s = state;
uint32* la = loadArray;
int i = N;
for (; i--; *s++ = *la++) {}
left = *la;
pNext = &state[N - left];
Expand All @@ -392,17 +392,17 @@ inline void MTRand::load(uint32* const loadArray)

inline std::ostream& operator<<(std::ostream& os, const MTRand& mtrand)
{
register const MTRand::uint32* s = mtrand.state;
register int i = mtrand.N;
const MTRand::uint32* s = mtrand.state;
int i = mtrand.N;
for (; i--; os << *s++ << "\t") {}
return os << mtrand.left;
}


inline std::istream& operator>>(std::istream& is, MTRand& mtrand)
{
register MTRand::uint32* s = mtrand.state;
register int i = mtrand.N;
MTRand::uint32* s = mtrand.state;
int i = mtrand.N;
for (; i--; is >> *s++) {}
is >> mtrand.left;
mtrand.pNext = &mtrand.state[mtrand.N - mtrand.left];
Expand Down
4 changes: 2 additions & 2 deletions dfttest/PlanarFrame.h
Expand Up @@ -68,7 +68,7 @@ class PlanarFrame
int width, int height);
void conv444toRGB24(uint8_t* py, uint8_t* pu, uint8_t* pv, uint8_t* dst, int pitch1Y, int pitch1UV, int pitch2,
int width, int height);
void PlanarFrame::AddLsb(unsigned char* dstp, int dst_pitch, const unsigned char* srcp,
void AddLsb(unsigned char* dstp, int dst_pitch, const unsigned char* srcp,
int src_pitch, int row_size, int height);

static int get_row_size_safe(const PVideoFrame& frame, const VideoInfo& viInfo, int plane_id);
Expand Down Expand Up @@ -99,7 +99,7 @@ class PlanarFrame
int GetPitch(uint8_t plane);
int getCPUFlags(void) { return cpu; }
inline void BitBlt(uint8_t* dstp, int dst_pitch, const uint8_t* srcp, int src_pitch, int row_size, int height);
PlanarFrame& PlanarFrame::operator=(PlanarFrame& ob2);
PlanarFrame& operator=(PlanarFrame& ob2);
void convYUY2to422(const uint8_t* src, uint8_t* py, uint8_t* pu, uint8_t* pv, int pitch1, int pitch2Y, int pitch2UV,
int width, int height);
void convRGB24to444(const uint8_t* src, uint8_t* py, uint8_t* pu, uint8_t* pv, int pitch1, int pitch2Y, int pitch2UV,
Expand Down
13 changes: 8 additions & 5 deletions dfttest/dfttest.cpp
Expand Up @@ -564,7 +564,8 @@ void intcast_SSE2_8(const float* p, unsigned char* dst, const int src_height,

PVideoFrame dfttest::GetFrame_S(int n, IScriptEnvironment* env)
{
nlf->pf->copyFrom(child->GetFrame(mapn(n), env), vi_src);
PVideoFrame src = child->GetFrame(mapn(n), env);
nlf->pf->copyFrom(src, vi_src);
copyPad(nlf->pf, nlf->ppf, env);
for (int b = 0; b < 3; ++b)
{
Expand Down Expand Up @@ -608,7 +609,8 @@ PVideoFrame dfttest::GetFrame_T(int n, IScriptEnvironment* env)
nlFrame* nl = fc->frames[fc->getCachePos(i - n + pos)];
if (nl->fnum != i)
{
nl->pf->copyFrom(child->GetFrame(mapn(i), env), vi_src);
PVideoFrame src = child->GetFrame(mapn(i), env);
nl->pf->copyFrom(src, vi_src);
copyPad(nl->pf, nl->ppf, env);
nl->setFNum(i);
}
Expand Down Expand Up @@ -671,7 +673,8 @@ PVideoFrame dfttest::GetFrame_T(int n, IScriptEnvironment* env)
nlFrame* nl = fc->frames[fc->getCachePos(i - z)];
if (nl->fnum != i)
{
nl->pf->copyFrom(child->GetFrame(mapn(i), env), vi_src);
PVideoFrame src = child->GetFrame(mapn(i), env);
nl->pf->copyFrom(src, vi_src);
copyPad(nl->pf, nl->ppf, env);
nl->setFNum(i);
}
Expand Down Expand Up @@ -1398,9 +1401,9 @@ dfttest::dfttest(PClip _child, bool _Y, bool _U, bool _V, int _ftype, float _sig
PlanarFrame* padPF = new PlanarFrame();
padPF->createPlanar(noyl * lsb_in_hmul, noyc * lsb_in_hmul, noxl, noxc, false, false, 1, 8); // DJATOM: line updated with hardcoded defaults. Now it works with 8-bit frame using updated PlanarFrame
if (tbsize > 1)
fc = new nlCache(tbsize, padPF, (VideoInfo)vi_src);
fc = new nlCache(tbsize, padPF, vi_src);
else
nlf = new nlFrame(padPF, (VideoInfo)vi_src);
nlf = new nlFrame(padPF, vi_src);
const int ebcount = (tbsize > 1 && tmode == 1) ? tbsize : 1;
ebuff = (float**)calloc(ebcount * 3, sizeof(float*));
for (int q = 0; q < ebcount; ++q)
Expand Down
56 changes: 28 additions & 28 deletions dfttest/dfttest.h
Expand Up @@ -125,22 +125,22 @@ class nlFrame
public:
int fnum;
PlanarFrame* pf, * ppf;
nlFrame::nlFrame();
nlFrame::nlFrame(PlanarFrame* tp, VideoInfo& vi);
nlFrame::~nlFrame();
void nlFrame::setFNum(int i);
nlFrame();
nlFrame(PlanarFrame* tp, VideoInfo& vi);
~nlFrame();
void setFNum(int i);
};

class nlCache
{
public:
nlFrame** frames;
int start_pos, size;
nlCache::nlCache();
nlCache::nlCache(int _size, PlanarFrame* tp, VideoInfo& vi);
nlCache::~nlCache();
void nlCache::resetCacheStart(int first, int last);
int nlCache::getCachePos(int n);
nlCache();
nlCache(int _size, PlanarFrame* tp, VideoInfo& vi);
~nlCache();
void resetCacheStart(int first, int last);
int getCachePos(int n);
};

struct PS_INFO {
Expand Down Expand Up @@ -199,36 +199,36 @@ class dfttest : public GenericVideoFilter
HANDLE* thds;
CRITICAL_SECTION csect;
const char* sfile, * sfile2, * pminfile, * pmaxfile;
VideoInfo vi_src;
VideoInfo vi_byte;
VideoInfo vi_src;
VideoInfo vi_byte;
fftwf_destroy_plan_proc fftwf_destroy_plan;
fftwf_plan_dft_r2c_3d_proc fftwf_plan_dft_r2c_3d;
fftwf_plan_dft_c2r_3d_proc fftwf_plan_dft_c2r_3d;
fftwf_plan_dft_r2c_2d_proc fftwf_plan_dft_r2c_2d;
fftwf_plan_dft_c2r_2d_proc fftwf_plan_dft_c2r_2d;
fftwf_execute_dft_r2c_proc fftwf_execute_dft_r2c;
fftwf_execute_dft_c2r_proc fftwf_execute_dft_c2r;
int dfttest::mapn(int n);
void dfttest::copyPad(PlanarFrame* src, PlanarFrame* dst, IScriptEnvironment* env);
PVideoFrame dfttest::GetFrame_S(int n, IScriptEnvironment* env);
PVideoFrame dfttest::GetFrame_T(int n, IScriptEnvironment* env);
PVideoFrame dfttest::build_output_frame(IScriptEnvironment* env);
void dfttest::bypass_plane(PlanarFrame& frame, int plane);
void dfttest::conv_result_plane_to_int(int width, int height, int b, int ebuff_index, IScriptEnvironment* env);
void dfttest::merge_msb_lsb();
void dfttest::processTemporalBlock(int pos);
void dfttest::loadFile(float* dest, const char* src, const float wscale,
int mapn(int n);
void copyPad(PlanarFrame* src, PlanarFrame* dst, IScriptEnvironment* env);
PVideoFrame GetFrame_S(int n, IScriptEnvironment* env);
PVideoFrame GetFrame_T(int n, IScriptEnvironment* env);
PVideoFrame build_output_frame(IScriptEnvironment* env);
void bypass_plane(PlanarFrame& frame, int plane);
void conv_result_plane_to_int(int width, int height, int b, int ebuff_index, IScriptEnvironment* env);
void merge_msb_lsb();
void processTemporalBlock(int pos);
void loadFile(float* dest, const char* src, const float wscale,
IScriptEnvironment* env);
void dfttest::getNoiseSpectrum(const char* fname, const char* nstring,
void getNoiseSpectrum(const char* fname, const char* nstring,
float* dest, const float wscale, IScriptEnvironment* env);
void dfttest::sigmaFromString(float* dest, const char* sstring, const char* ssx,
void sigmaFromString(float* dest, const char* sstring, const char* ssx,
const char* ssy, const char* sst, const float wscale, IScriptEnvironment* env);
void dfttest::outputSigmaFile(const char* fname, const float* s, const float scale,
void outputSigmaFile(const char* fname, const float* s, const float scale,
const bool zmean2);

public:
PVideoFrame __stdcall dfttest::GetFrame(int n, IScriptEnvironment* env);
dfttest::dfttest(PClip _child, bool _Y, bool _U, bool _V, int _ftype,
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override;
dfttest(PClip _child, bool _Y, bool _U, bool _V, int _ftype,
float _sigma, float _sigma2, float _pmin, float _pmax, int _sbsize,
int _smode, int _sosize, int _tbsize, int _tmode, int _tosize,
int _swin, int _twin, double _sbeta, double _tbeta, bool _zmean,
Expand All @@ -238,8 +238,8 @@ class dfttest : public GenericVideoFilter
const char* _ssy, const char* _sst, const int _dither,
bool _lsb_in_flag, bool _lsb_out_flag, bool _quiet_flag,
IScriptEnvironment* env);
dfttest::~dfttest();
int __stdcall dfttest::SetCacheHints(int cachehints, int frame_range)
~dfttest();
int __stdcall SetCacheHints(int cachehints, int frame_range)
{
switch (cachehints)
{
Expand Down

0 comments on commit c95dac2

Please sign in to comment.