From 9b9e08badbfa61507a2b740d4a2bf33b6f3f32b1 Mon Sep 17 00:00:00 2001 From: deltaoscarmike <37912794+deltaoscarmike@users.noreply.github.com> Date: Sat, 17 Nov 2018 11:42:28 +0100 Subject: [PATCH] Build warnings cleanup --- configure.ac | 3 +- src/NativePresets/MstressJuppyDancer.cpp | 16 +-- src/NativePresets/RovastarDriftingChaos.cpp | 2 - src/libprojectM/HungarianMethod.hpp | 12 +- .../MilkdropPresetFactory/CustomShape.cpp | 8 +- .../MilkdropPresetFactory/CustomShape.hpp | 4 +- .../MilkdropPresetFactory/CustomWave.cpp | 68 +++++----- .../MilkdropPresetFactory/CustomWave.hpp | 2 +- .../MilkdropPresetFactory/Expr.hpp | 4 +- .../MilkdropPresetFactory/Func.cpp | 2 +- .../MilkdropPresetFactory/IdlePreset.cpp | 6 +- .../MilkdropPresetFactory/IdlePreset.hpp | 2 +- .../MilkdropPresetFactory/InitCond.cpp | 2 +- .../MilkdropPresetFactory/Makefile.am | 2 +- .../MilkdropPresetFactory/MilkdropPreset.cpp | 26 ++-- .../MilkdropPresetFactory.cpp | 6 +- .../MilkdropPresetFactory.hpp | 2 +- .../MilkdropPresetFactory/Param.cpp | 8 +- .../MilkdropPresetFactory/Parser.cpp | 39 +++--- .../MilkdropPresetFactory/Parser.hpp | 2 +- .../MilkdropPresetFactory/PresetFrameIO.cpp | 98 +++++++------- .../MilkdropPresetFactory/PresetFrameIO.hpp | 4 +- .../NativePresetFactory.cpp | 6 +- .../NativePresetFactory.hpp | 2 +- src/libprojectM/PCM.cpp | 6 +- src/libprojectM/PipelineMerger.cpp | 4 +- src/libprojectM/PresetChooser.hpp | 8 +- src/libprojectM/PresetFactory.hpp | 2 +- src/libprojectM/PresetFactoryManager.cpp | 4 +- src/libprojectM/PresetFactoryManager.hpp | 2 +- src/libprojectM/PresetLoader.cpp | 21 ++- src/libprojectM/PresetLoader.hpp | 4 +- src/libprojectM/RandomNumberGenerators.hpp | 3 +- src/libprojectM/Renderer/BeatDetect.cpp | 4 +- src/libprojectM/Renderer/MilkdropWaveform.cpp | 28 ++-- src/libprojectM/Renderer/PerPixelMesh.cpp | 16 +-- src/libprojectM/Renderer/PerPixelMesh.hpp | 6 +- src/libprojectM/Renderer/Pipeline.cpp | 9 +- src/libprojectM/Renderer/Pipeline.hpp | 5 +- .../Renderer/RenderItemMatcher.cpp | 6 +- .../Renderer/RenderItemMergeFunction.hpp | 2 +- src/libprojectM/Renderer/Renderable.cpp | 3 +- src/libprojectM/Renderer/Renderable.hpp | 2 +- src/libprojectM/Renderer/Renderer.cpp | 10 +- src/libprojectM/Renderer/Renderer.hpp | 2 +- src/libprojectM/Renderer/SOIL2/SOIL2.c | 6 +- src/libprojectM/Renderer/SOIL2/SOIL2.h | 13 +- src/libprojectM/Renderer/SOIL2/stb_image.h | 127 +++++++++++------- .../Renderer/SOIL2/stb_image_write.h | 20 +-- src/libprojectM/Renderer/SOIL2/stbi_DDS_c.h | 6 +- src/libprojectM/Renderer/ShaderEngine.cpp | 11 +- src/libprojectM/Renderer/Waveform.cpp | 4 +- src/libprojectM/Renderer/Waveform.hpp | 6 +- .../Renderer/hlslparser/src/CodeWriter.cpp | 2 + .../Renderer/hlslparser/src/Engine.cpp | 6 +- .../Renderer/hlslparser/src/Engine.h | 2 +- .../Renderer/hlslparser/src/GLSLGenerator.cpp | 8 +- .../Renderer/hlslparser/src/HLSLParser.cpp | 35 ++--- .../Renderer/hlslparser/src/HLSLParser.h | 2 +- .../Renderer/hlslparser/src/HLSLTokenizer.cpp | 2 +- .../Renderer/hlslparser/src/HLSLTree.cpp | 10 +- .../Renderer/hlslparser/src/HLSLTree.h | 2 +- src/libprojectM/libprojectM.pc.in | 4 +- src/libprojectM/projectM.cpp | 12 +- src/libprojectM/projectM.hpp | 6 +- src/projectM-sdl/Makefile.am | 1 + src/projectM-sdl/pmSDL.cpp | 19 ++- src/projectM-sdl/pmSDL.hpp | 2 +- src/projectM-sdl/projectM_SDL_main.cpp | 12 +- 69 files changed, 391 insertions(+), 400 deletions(-) diff --git a/configure.ac b/configure.ac index 622ad6551..2e504af59 100644 --- a/configure.ac +++ b/configure.ac @@ -160,7 +160,8 @@ AM_CONDITIONAL([ENABLE_QT], [test "$enable_qt" = yes]) AM_CONDITIONAL([ENABLE_EMSCRIPTEN], [test "$enable_emscripten" = yes]) -my_CFLAGS="-Wall -Wchar-subscripts -Wformat-security -Wmissing-declarations -Wpointer-arith -Wshadow -Wsign-compare -Wtype-limits " +my_CFLAGS="-Wall -Wchar-subscripts -Wformat-security -Wpointer-arith -Wshadow -Wsign-compare -Wtype-limits " +#my_CFLAGS+="-fsanitize=address -fno-omit-frame-pointer " my_CFLAGS+='-DDATADIR_PATH=\""$(pkgdatadir)"\" ' my_CFLAGS+='-I$(top_srcdir)/vendor ' AC_SUBST([my_CFLAGS]) diff --git a/src/NativePresets/MstressJuppyDancer.cpp b/src/NativePresets/MstressJuppyDancer.cpp index 967168593..cec0693be 100644 --- a/src/NativePresets/MstressJuppyDancer.cpp +++ b/src/NativePresets/MstressJuppyDancer.cpp @@ -156,8 +156,6 @@ class MstressJuppyDancer : public Pipeline public: Dancer dancer[10]; - float dx, dy, cx, cy, time; - float q1,meanmid,middiff,mi_prg,gam, bass; MstressJuppyDancer() : Pipeline() @@ -194,14 +192,14 @@ public: { float sx = -below(p.y,0.8)*.001; - float dx = .01*bass*(1-q1*2)*below(p.y,0.8); - float rot=rot+.051*below(p.y,0.8); - float cx=trunc(p.x*16)/16; - float cy=trunc(p.y*16)/16; + float dx = .01*bass*(1-q1*2)*below(p.y,0.8); + float rot= .051*below(p.y,0.8); + float cx=trunc(p.x*16)/16; + float cy=trunc(p.y*16)/16; - Transforms::Scale(p,context,sx,1,cx,cy); - Transforms::Rotate(p,context,rot,cx,cy); - Transforms::Transform(p,context,dx,0); + Transforms::Scale(p,context,sx,1,cx,cy); + Transforms::Rotate(p,context,rot,cx,cy); + Transforms::Transform(p,context,dx,0); return p; } diff --git a/src/NativePresets/RovastarDriftingChaos.cpp b/src/NativePresets/RovastarDriftingChaos.cpp index 2fad7b0f6..0dc830ea9 100644 --- a/src/NativePresets/RovastarDriftingChaos.cpp +++ b/src/NativePresets/RovastarDriftingChaos.cpp @@ -69,7 +69,6 @@ public: xamp = xamp + 0.5*(xamptarg-xamp); xdir = if_milk(above(abs(xpos),xamp),-sign(xpos),if_milk(below(abs(xspeed),0.1),2*above(xpos,0)-1,xdir)); - float xaccel = xdir*xamp - xpos - xspeed*0.055*below(abs(xpos),xamp); xspeed += xdir*xamp - xpos - xspeed*0.055*below(abs(xpos),xamp); xpos = xpos + 0.001*xspeed; dx = xpos*0.005; @@ -77,7 +76,6 @@ public: yamp += 0.5*(yamptarg-yamp); ydir = if_milk(above(abs(ypos),yamp),-sign(ypos),if_milk(below(abs(yspeed),0.1),2*above(ypos,0)-1,ydir)); - float yaccel = ydir*yamp - ypos - yspeed*0.055*below(abs(ypos),yamp); yspeed += ydir*yamp - ypos - yspeed*0.055*below(abs(ypos),yamp); ypos = ypos + 0.001*yspeed; diff --git a/src/libprojectM/HungarianMethod.hpp b/src/libprojectM/HungarianMethod.hpp index c92996be9..a6c19d344 100644 --- a/src/libprojectM/HungarianMethod.hpp +++ b/src/libprojectM/HungarianMethod.hpp @@ -28,15 +28,15 @@ void init_labels(const double cost[N][N]) { memset(lx, 0, sizeof(lx)); memset(ly, 0, sizeof(ly)); - for (int x = 0; x < n; x++) - for (int y = 0; y < n; y++) + for (unsigned int x = 0; x < n; x++) + for (unsigned int y = 0; y < n; y++) lx[x] = std::max(lx[x], cost[x][y]); } void augment(const double cost[N][N]) //main function of the algorithm { if (max_match == n) return; //check wether matching is already perfect - int x, y, root = 0; //just counters and root vertex + unsigned int x, y, root = 0; //just counters and root vertex int q[N], wr = 0, rd = 0; //q - queue for bfs, wr,rd - write and read //pos in queue memset(S, false, sizeof(S)); //init set S @@ -120,7 +120,7 @@ void augment(const double cost[N][N]) //main function of the algorithm void update_labels() { - int x, y; + unsigned int x, y; double delta = std::numeric_limits::max(); for (y = 0; y < n; y++) //calculate delta using slack if (!T[y]) @@ -140,7 +140,7 @@ void add_to_tree(int x, int prevx, const double cost[N][N]) { S[x] = true; //add x to S prev[x] = prevx; //we need this when augmenting - for (int y = 0; y < n; y++) //update slacks, because we add new vertex to S + for (unsigned int y = 0; y < n; y++) //update slacks, because we add new vertex to S if (lx[x] + ly[y] - cost[x][y] < slack[y]) { slack[y] = lx[x] + ly[y] - cost[x][y]; @@ -165,7 +165,7 @@ inline double operator()(const double cost[N][N], size_t logicalSize) memset(yx, -1, sizeof(yx)); init_labels(cost); //step 0 augment(cost); //steps 1-3 - for (int x = 0; x < n; x++) //forming answer there + for (unsigned int x = 0; x < n; x++) //forming answer there ret += cost[x][xy[x]]; return ret; } diff --git a/src/libprojectM/MilkdropPresetFactory/CustomShape.cpp b/src/libprojectM/MilkdropPresetFactory/CustomShape.cpp index 4d2c28306..2f1b423e3 100755 --- a/src/libprojectM/MilkdropPresetFactory/CustomShape.cpp +++ b/src/libprojectM/MilkdropPresetFactory/CustomShape.cpp @@ -40,14 +40,14 @@ CustomShape::CustomShape() : Shape() { CustomShape(0); -}; +} -CustomShape::CustomShape ( int id ) : Shape() +CustomShape::CustomShape ( int _id ) : Shape() { Param * param; - this->id = id; + this->id = _id; this->per_frame_count = 0; /* Start: Load custom shape parameters */ @@ -213,7 +213,7 @@ CustomShape::CustomShape ( int id ) : Shape() os << "q" << i; param = Param::new_param_float ( os.str().c_str(), P_FLAG_QVAR, &this->q[i], NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); - if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + if ( !ParamUtils::insert ( param, &this->param_tree ) ) { abort(); } diff --git a/src/libprojectM/MilkdropPresetFactory/CustomShape.hpp b/src/libprojectM/MilkdropPresetFactory/CustomShape.hpp index eb9a8e8c7..d4ea2e01b 100755 --- a/src/libprojectM/MilkdropPresetFactory/CustomShape.hpp +++ b/src/libprojectM/MilkdropPresetFactory/CustomShape.hpp @@ -76,9 +76,9 @@ public: /// Allocate a new custom shape, including param associations, per point equations, and initial values. /// \param id an integer id to associate with this custom wave. Future line parsing uses this as a reference key. - CustomShape( int id ); + CustomShape(int _id ); CustomShape(); - ~CustomShape(); + virtual ~CustomShape(); void loadUnspecInitConds(); void evalInitConds(); diff --git a/src/libprojectM/MilkdropPresetFactory/CustomWave.cpp b/src/libprojectM/MilkdropPresetFactory/CustomWave.cpp index c0cc8fbfd..f1febc608 100755 --- a/src/libprojectM/MilkdropPresetFactory/CustomWave.cpp +++ b/src/libprojectM/MilkdropPresetFactory/CustomWave.cpp @@ -74,7 +74,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, ¶m_tree) < 0) + if (!ParamUtils::insert(param, ¶m_tree)) { /// @bug make exception abort(); @@ -87,7 +87,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, ¶m_tree) < 0) + if (!ParamUtils::insert(param, ¶m_tree)) { ; /// @bug make exception @@ -102,7 +102,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; /// @bug make exception @@ -116,7 +116,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; /// @bug make exception @@ -130,7 +130,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; /// @bug make exception @@ -144,7 +144,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; @@ -162,7 +162,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; @@ -180,7 +180,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; /// @bug make exception @@ -197,7 +197,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { /// @bug make exception abort(); @@ -210,7 +210,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { /// @bug make exception abort(); @@ -224,7 +224,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; abort(); @@ -236,7 +236,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; abort(); @@ -248,7 +248,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; abort(); @@ -261,7 +261,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { abort(); } @@ -271,7 +271,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { abort(); } @@ -281,7 +281,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; abort(); @@ -293,7 +293,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; abort(); @@ -305,7 +305,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; abort(); @@ -317,7 +317,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; abort(); @@ -329,7 +329,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { abort(); } @@ -339,7 +339,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { abort(); @@ -350,7 +350,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { abort(); } @@ -359,7 +359,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { abort(); } @@ -369,7 +369,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { abort(); @@ -380,7 +380,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; abort(); @@ -392,7 +392,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), abort(); } - if (ParamUtils::insert(param, &this->param_tree) < 0) + if (!ParamUtils::insert(param, &this->param_tree)) { ; abort(); @@ -403,7 +403,7 @@ CustomWave::CustomWave(int _id) : Waveform(512), os << "q" << i; param = Param::new_param_float ( os.str().c_str(), P_FLAG_QVAR, &this->q[i], NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 ); - if ( ParamUtils::insert ( param, &this->param_tree ) < 0 ) + if ( !ParamUtils::insert ( param, &this->param_tree ) ) { abort(); } @@ -519,14 +519,14 @@ ColoredPoint CustomWave::PerPoint(ColoredPoint p, const WaveformContext context) for (std::vector::iterator pos = per_point_eqn_tree.begin(); pos != per_point_eqn_tree.end();++pos) (*pos)->evaluate(context.sample_int); - p.a = a_mesh[context.sample_int]; - p.r = r_mesh[context.sample_int]; - p.g = g_mesh[context.sample_int]; - p.b = b_mesh[context.sample_int]; - p.x = x_mesh[context.sample_int]; - p.y = y_mesh[context.sample_int]; + p.a = a_mesh[context.sample_int]; + p.r = r_mesh[context.sample_int]; + p.g = g_mesh[context.sample_int]; + p.b = b_mesh[context.sample_int]; + p.x = x_mesh[context.sample_int]; + p.y = y_mesh[context.sample_int]; - return p; + return p; } diff --git a/src/libprojectM/MilkdropPresetFactory/CustomWave.hpp b/src/libprojectM/MilkdropPresetFactory/CustomWave.hpp index f1df5aafa..bf8e01afa 100755 --- a/src/libprojectM/MilkdropPresetFactory/CustomWave.hpp +++ b/src/libprojectM/MilkdropPresetFactory/CustomWave.hpp @@ -56,7 +56,7 @@ public: CustomWave(int id); /** Destructor is necessary so we can free the per point matrices **/ - ~CustomWave(); + virtual ~CustomWave(); ColoredPoint PerPoint(ColoredPoint p, const WaveformContext context); diff --git a/src/libprojectM/MilkdropPresetFactory/Expr.hpp b/src/libprojectM/MilkdropPresetFactory/Expr.hpp index a1eb006d4..28abb062f 100755 --- a/src/libprojectM/MilkdropPresetFactory/Expr.hpp +++ b/src/libprojectM/MilkdropPresetFactory/Expr.hpp @@ -108,8 +108,8 @@ public: // NOTE: before optimize() left and right will always be TreeExpr Expr *left, *right; // these are for type-safe access in Parser.cpp - TreeExpr *&leftTree() { return *(TreeExpr **)&left; }; - TreeExpr *&rightTree() { return *(TreeExpr **)&right; }; + TreeExpr *leftTree() { return dynamic_cast(left); } + TreeExpr *rightTree() { return dynamic_cast(right); } ~TreeExpr(); diff --git a/src/libprojectM/MilkdropPresetFactory/Func.cpp b/src/libprojectM/MilkdropPresetFactory/Func.cpp index 71a9b293a..8c53a107f 100755 --- a/src/libprojectM/MilkdropPresetFactory/Func.cpp +++ b/src/libprojectM/MilkdropPresetFactory/Func.cpp @@ -31,7 +31,7 @@ #include Func::Func (const std::string & _name, float (*_func_ptr)(float*), int _num_args): - name(_name), func_ptr(_func_ptr), num_args(_num_args) {} + func_ptr(_func_ptr), name(_name), num_args(_num_args) {} /* Frees a function type, real complicated... */ Func::~Func() {} diff --git a/src/libprojectM/MilkdropPresetFactory/IdlePreset.cpp b/src/libprojectM/MilkdropPresetFactory/IdlePreset.cpp index 9507fb6c6..df6f0a94b 100644 --- a/src/libprojectM/MilkdropPresetFactory/IdlePreset.cpp +++ b/src/libprojectM/MilkdropPresetFactory/IdlePreset.cpp @@ -198,13 +198,13 @@ return out.str(); } -std::auto_ptr IdlePresets::allocate(const std::string & name, PresetOutputs & presetOutputs) +std::unique_ptr IdlePresets::allocate(const std::string & name, PresetOutputs & presetOutputs) { if (name == IDLE_PRESET_NAME) { std::istringstream in(presetText()); - return std::auto_ptr(new MilkdropPreset(in, IDLE_PRESET_NAME, presetOutputs)); + return std::unique_ptr(new MilkdropPreset(in, IDLE_PRESET_NAME, presetOutputs)); } else - return std::auto_ptr(0); + return std::unique_ptr(); } diff --git a/src/libprojectM/MilkdropPresetFactory/IdlePreset.hpp b/src/libprojectM/MilkdropPresetFactory/IdlePreset.hpp index 3231d4340..a3fd004be 100644 --- a/src/libprojectM/MilkdropPresetFactory/IdlePreset.hpp +++ b/src/libprojectM/MilkdropPresetFactory/IdlePreset.hpp @@ -12,7 +12,7 @@ class IdlePresets { public: /// Allocate a new idle preset instance /// \returns a newly allocated auto pointer of an idle preset instance - static std::auto_ptr allocate(const std::string & path, PresetOutputs & outputs); + static std::unique_ptr allocate(const std::string & path, PresetOutputs & outputs); private: static std::string presetText(); static const std::string IDLE_PRESET_NAME; diff --git a/src/libprojectM/MilkdropPresetFactory/InitCond.cpp b/src/libprojectM/MilkdropPresetFactory/InitCond.cpp index 2dae471f0..c43b91f35 100755 --- a/src/libprojectM/MilkdropPresetFactory/InitCond.cpp +++ b/src/libprojectM/MilkdropPresetFactory/InitCond.cpp @@ -138,7 +138,7 @@ void InitCond::init_cond_to_string() { return; /* Copy the string into the initial condition string buffer */ - strncpy(init_cond_string_buffer + init_cond_string_buffer_index, string, string_length); + memcpy(init_cond_string_buffer + init_cond_string_buffer_index, string, string_length + 1); /* Increment the string buffer, offset by one for the null terminator, which will be overwritten by the next call to this function */ diff --git a/src/libprojectM/MilkdropPresetFactory/Makefile.am b/src/libprojectM/MilkdropPresetFactory/Makefile.am index c67e2e0ee..c3a3aff09 100644 --- a/src/libprojectM/MilkdropPresetFactory/Makefile.am +++ b/src/libprojectM/MilkdropPresetFactory/Makefile.am @@ -14,7 +14,7 @@ CustomWave.hpp MilkdropPreset.hpp PerPointEqn.hpp\ Eval.hpp MilkdropPresetFactory.hpp PresetFrameIO.hpp\ Expr.hpp Param.hpp -: + libMilkdropPresetFactory_la_CPPFLAGS = ${my_CFLAGS} \ -include $(top_builddir)/config.h \ -I$(top_srcdir)/src/libprojectM diff --git a/src/libprojectM/MilkdropPresetFactory/MilkdropPreset.cpp b/src/libprojectM/MilkdropPresetFactory/MilkdropPreset.cpp index 494454cdb..8708bc875 100755 --- a/src/libprojectM/MilkdropPresetFactory/MilkdropPreset.cpp +++ b/src/libprojectM/MilkdropPresetFactory/MilkdropPreset.cpp @@ -56,9 +56,9 @@ MilkdropPreset::MilkdropPreset(std::istream & in, const std::string & presetName MilkdropPreset::MilkdropPreset(const std::string & absoluteFilePath, const std::string & presetName, PresetOutputs & presetOutputs): Preset(presetName), builtinParams(_presetInputs, presetOutputs), + _filename(parseFilename(absoluteFilePath)), _absoluteFilePath(absoluteFilePath), - _presetOutputs(presetOutputs), - _filename(parseFilename(absoluteFilePath)) + _presetOutputs(presetOutputs) { initialize(absoluteFilePath); @@ -172,15 +172,15 @@ void MilkdropPreset::evalCustomWavePerFrameEquations() for (PresetOutputs::cwave_container::iterator pos = customWaves.begin(); pos != customWaves.end(); ++pos) { - std::map & init_cond_tree = (*pos)->init_cond_tree; - for (std::map::iterator _pos = init_cond_tree.begin(); _pos != init_cond_tree.end(); ++_pos) + std::map & init_cond_tree2 = (*pos)->init_cond_tree; + for (std::map::iterator _pos = init_cond_tree2.begin(); _pos != init_cond_tree2.end(); ++_pos) { assert(_pos->second); _pos->second->evaluate(); } - std::vector & per_frame_eqn_tree = (*pos)->per_frame_eqn_tree; - for (std::vector::iterator _pos = per_frame_eqn_tree.begin(); _pos != per_frame_eqn_tree.end(); ++_pos) + std::vector & per_frame_eqn_tree2 = (*pos)->per_frame_eqn_tree; + for (std::vector::iterator _pos = per_frame_eqn_tree2.begin(); _pos != per_frame_eqn_tree2.end(); ++_pos) { (*_pos)->evaluate(); } @@ -194,15 +194,15 @@ void MilkdropPreset::evalCustomShapePerFrameEquations() for (PresetOutputs::cshape_container::iterator pos = customShapes.begin(); pos != customShapes.end(); ++pos) { - std::map & init_cond_tree = (*pos)->init_cond_tree; - for (std::map::iterator _pos = init_cond_tree.begin(); _pos != init_cond_tree.end(); ++_pos) + std::map & init_cond_tree2 = (*pos)->init_cond_tree; + for (std::map::iterator _pos = init_cond_tree2.begin(); _pos != init_cond_tree2.end(); ++_pos) { assert(_pos->second); _pos->second->evaluate(); } - std::vector & per_frame_eqn_tree = (*pos)->per_frame_eqn_tree; - for (std::vector::iterator _pos = per_frame_eqn_tree.begin(); _pos != per_frame_eqn_tree.end(); ++_pos) + std::vector & per_frame_eqn_tree2 = (*pos)->per_frame_eqn_tree; + for (std::vector::iterator _pos = per_frame_eqn_tree2.begin(); _pos != per_frame_eqn_tree2.end(); ++_pos) { (*_pos)->evaluate(); } @@ -284,8 +284,6 @@ void MilkdropPreset::Render(const BeatDetect &music, const PipelineContext &cont void MilkdropPreset::initialize(const std::string & pathname) { - int retval; - preloadInitialize(); if (MILKDROP_PRESET_DEBUG) @@ -474,7 +472,6 @@ void MilkdropPreset::evalPerPixelEqns() int MilkdropPreset::readIn(std::istream & fs) { - line_mode_t line_mode; presetOutputs().compositeShader.programSource.clear(); presetOutputs().warpShader.programSource.clear(); @@ -504,7 +501,6 @@ int MilkdropPreset::readIn(std::istream & fs) { { if (retval == PROJECTM_PARSE_ERROR) { - line_mode = UNSET_LINE_MODE; // std::cerr << "[Preset::readIn()] parse error in file \"" << this->absoluteFilePath() << "\"" << std::endl; } } @@ -541,6 +537,6 @@ int MilkdropPreset::loadPresetFile(const std::string & pathname) const std::string & MilkdropPreset::name() const { - return name().empty() ? filename() : name(); + return filename(); } diff --git a/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.cpp b/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.cpp index 7eb6abd70..8693c9a4b 100644 --- a/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.cpp +++ b/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.cpp @@ -204,7 +204,7 @@ PresetOutputs* MilkdropPresetFactory::createPresetOutputs(int gx, int gy) /* Q AND T VARIABLES START */ - for (int i = 0;iq[i] = 0; /* Q AND T VARIABLES END */ @@ -212,7 +212,7 @@ PresetOutputs* MilkdropPresetFactory::createPresetOutputs(int gx, int gy) } -std::auto_ptr MilkdropPresetFactory::allocate(const std::string & url, const std::string & name, const std::string & author) { +std::unique_ptr MilkdropPresetFactory::allocate(const std::string & url, const std::string & name, const std::string & author) { PresetOutputs *presetOutputs = _usePresetOutputs ? _presetOutputs : _presetOutputs2; @@ -223,5 +223,5 @@ std::auto_ptr MilkdropPresetFactory::allocate(const std::string & url, c if (PresetFactory::protocol(url, path) == PresetFactory::IDLE_PRESET_PROTOCOL) { return IdlePresets::allocate(path, *presetOutputs); } else - return std::auto_ptr(new MilkdropPreset(url, name, *presetOutputs)); + return std::unique_ptr(new MilkdropPreset(url, name, *presetOutputs)); } diff --git a/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.hpp b/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.hpp index 2a5a46afb..da0a6aeff 100644 --- a/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.hpp +++ b/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.hpp @@ -26,7 +26,7 @@ public: virtual ~MilkdropPresetFactory(); - std::auto_ptr allocate(const std::string & url, const std::string & name = std::string(), + std::unique_ptr allocate(const std::string & url, const std::string & name = std::string(), const std::string & author = std::string()); std::string supportedExtensions() const { return "milk prjm"; } diff --git a/src/libprojectM/MilkdropPresetFactory/Param.cpp b/src/libprojectM/MilkdropPresetFactory/Param.cpp index bb72a672a..9d7cec7cf 100755 --- a/src/libprojectM/MilkdropPresetFactory/Param.cpp +++ b/src/libprojectM/MilkdropPresetFactory/Param.cpp @@ -47,11 +47,11 @@ Param::Param( std::string _name, short int _type, short int _flags, void * _engi flags (_flags), matrix_flag (0), engine_val(_engine_val), - local_value(0.0), matrix (_matrix), default_init_val (_default_init_val), upper_bound (_upper_bound), - lower_bound (_lower_bound) + lower_bound (_lower_bound), + local_value(0.0) { } @@ -63,8 +63,8 @@ Param::Param(std::string _name) : type(P_TYPE_DOUBLE), flags(P_FLAG_USERDEF), matrix_flag(0), - local_value(0.0), - matrix(0) + matrix(0), + local_value(0.0) { engine_val = (float *)&local_value; diff --git a/src/libprojectM/MilkdropPresetFactory/Parser.cpp b/src/libprojectM/MilkdropPresetFactory/Parser.cpp index 4685a3a9b..90c63e4cb 100755 --- a/src/libprojectM/MilkdropPresetFactory/Parser.cpp +++ b/src/libprojectM/MilkdropPresetFactory/Parser.cpp @@ -60,7 +60,7 @@ int Parser::per_frame_eqn_count; int Parser::per_frame_init_eqn_count; int Parser::last_custom_wave_id; int Parser::last_custom_shape_id; -char Parser::last_eqn_type[MAX_TOKEN_SIZE]; +char Parser::last_eqn_type[MAX_TOKEN_SIZE+1]; int Parser::last_token_size; std::string Parser::lastLinePrefix(""); @@ -336,7 +336,7 @@ int Parser::parse_per_pixel_eqn(std::istream & fs, MilkdropPreset * preset, cha if (init_string != 0) { - strncpy(string, init_string, strlen(init_string)); + memcpy(string, init_string, strlen(init_string) + 1); } else { @@ -1255,11 +1255,11 @@ int Parser::parse_int(std::istream & fs, int * int_ptr) { case tMinus: sign = -1; - token = parseToken(fs, string); + parseToken(fs, string); break; case tPlus: sign = 1; - token = parseToken(fs, string); + parseToken(fs, string); break; default: sign = 1; @@ -1328,11 +1328,11 @@ int Parser::parse_float(std::istream & fs, float * float_ptr) { case tMinus: sign = -1; - token = parseToken(fs, string); + parseToken(fs, string); break; case tPlus: sign = 1; - token = parseToken(fs, string); + parseToken(fs, string); break; default: sign = 1; @@ -1501,7 +1501,7 @@ InitCond * Parser::parse_init_cond(std::istream & fs, char * name, MilkdropPres if (PARSE_DEBUG) printf("parsed_init_cond: parsing initial condition value... (LINE %d)\n", line_count); /* integer value (boolean is an integer in C) */ - if ( (param->type == P_TYPE_BOOL)) + if (param->type == P_TYPE_BOOL) { int bool_test; if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR) @@ -1512,7 +1512,7 @@ InitCond * Parser::parse_init_cond(std::istream & fs, char * name, MilkdropPres init_val.bool_val = bool_test; } - else if ((param->type == P_TYPE_INT)) + else if (param->type == P_TYPE_INT) { if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR) { @@ -1552,10 +1552,6 @@ InitCond * Parser::parse_init_cond(std::istream & fs, char * name, MilkdropPres void Parser::parse_string_block(std::istream & fs, std::string * out_string) { - - char name[MAX_TOKEN_SIZE]; - token_t token; - std::set skipList; skipList.insert('`'); readStringUntil(fs, out_string, false, skipList); @@ -1628,7 +1624,7 @@ InitCond * Parser::parse_per_frame_init_eqn(std::istream & fs, MilkdropPreset * init_val.bool_val = (bool)val; } - else if ((param->type == P_TYPE_INT)) + else if (param->type == P_TYPE_INT) { init_val.int_val = (int)val; } @@ -1688,7 +1684,6 @@ bool Parser::scanForComment(std::istream & fs) { void Parser::readStringUntil(std::istream & fs, std::string * out_buffer, bool wrapAround, const std::set & skipList) { - int string_line_buffer_index = 0; int c; /* Loop until a delimiter is found, or the maximum string size is found */ @@ -1746,7 +1741,6 @@ void Parser::readStringUntil(std::istream & fs, std::string * out_buffer, bool w if (!wrapsToNextLine(buffer.str())) { - wrapAround = false; int buf_size = (int)buffer.str().length(); // <= to also remove equal sign parsing from stream for (int k = 0; k <= buf_size; k++) { @@ -1822,7 +1816,7 @@ int Parser::parse_wavecode(char * token, std::istream & fs, MilkdropPreset * pr /* integer value (boolean is an integer in C) */ - if ((param->type == P_TYPE_BOOL)) + if (param->type == P_TYPE_BOOL) { int bool_test; if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR) @@ -1833,7 +1827,7 @@ int Parser::parse_wavecode(char * token, std::istream & fs, MilkdropPreset * pr } init_val.bool_val = bool_test; } - else if ((param->type == P_TYPE_INT)) + else if (param->type == P_TYPE_INT) { if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR) { @@ -1869,10 +1863,7 @@ int Parser::parse_wavecode(char * token, std::istream & fs, MilkdropPreset * pr return PROJECTM_FAILURE; } - std::pair::iterator, bool> inserteePair = - custom_wave->init_cond_tree.insert(std::make_pair(init_cond->param->name, init_cond)); - - // assert(inserteePair.second); + custom_wave->init_cond_tree.insert(std::make_pair(init_cond->param->name, init_cond)); line_mode = CUSTOM_WAVE_WAVECODE_LINE_MODE; @@ -1948,7 +1939,7 @@ int Parser::parse_shapecode(char * token, std::istream & fs, MilkdropPreset * p /* integer value (boolean is an integer in C) */ - if ((param->type == P_TYPE_BOOL)) + if (param->type == P_TYPE_BOOL) { int bool_test; if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR) @@ -1958,7 +1949,7 @@ int Parser::parse_shapecode(char * token, std::istream & fs, MilkdropPreset * p } init_val.bool_val = bool_test; } - else if ((param->type == P_TYPE_INT)) + else if (param->type == P_TYPE_INT) { if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR) { @@ -2313,7 +2304,7 @@ int Parser::parse_wave_helper(std::istream & fs, MilkdropPreset * preset, int /// HACK the parse_line code already parsed the per_pixel variable name. This handles that case /// Parser needs reworked. Don't have time for it. So this is the result. if (init_string) - strncpy(string, init_string, strlen(init_string)+1); + memcpy(string, init_string, strlen(init_string)+1); else { if (parseToken(fs, string) != tEq) diff --git a/src/libprojectM/MilkdropPresetFactory/Parser.hpp b/src/libprojectM/MilkdropPresetFactory/Parser.hpp index b52fede6d..1ce5d48fc 100755 --- a/src/libprojectM/MilkdropPresetFactory/Parser.hpp +++ b/src/libprojectM/MilkdropPresetFactory/Parser.hpp @@ -141,7 +141,7 @@ public: static int per_frame_init_eqn_count; static int last_custom_wave_id; static int last_custom_shape_id; - static char last_eqn_type[MAX_TOKEN_SIZE]; + static char last_eqn_type[MAX_TOKEN_SIZE+1]; static int last_token_size; static bool tokenWrapAroundEnabled; diff --git a/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.cpp b/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.cpp index 61aad0d7c..79d1ac37b 100644 --- a/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.cpp +++ b/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.cpp @@ -42,7 +42,7 @@ float **alloc_mesh(size_t gx, size_t gy) float **mesh = (float **)wipe_aligned_alloc(gx * sizeof(float *)); float *m = (float *)wipe_aligned_alloc(gx * gy * sizeof(float)); - for ( int x = 0; x < gx; x++ ) + for (unsigned int x = 0; x < gx; x++ ) mesh[x] = m + (gy * x); return mesh; } @@ -60,12 +60,12 @@ void copy_mesh(float **dst, float **src, int gx, int gy) } -void PresetInputs::Initialize ( int gx, int gy ) +void PresetInputs::Initialize ( int _gx, int _gy ) { int x, y; - this->gx = gx; - this->gy = gy; + this->gx = _gx; + this->gy = _gy; /// @bug no clue if this block belongs here @@ -93,7 +93,7 @@ void PresetInputs::Initialize ( int gx, int gy ) for ( y=0;yorigx[x][y]=x/ ( float ) ( gx-1 ); - this->origy[x][y]=- ( ( y/ ( float ) ( gy-1 ) )-1 ); + this->origy[x][y]= - ( ( y/ ( float ) ( gy-1 ) )-1 ); this->origrad[x][y]=hypot ( ( this->origx[x][y]-.5 ) *2, ( this->origy[x][y]-.5 ) *2 ) * .7071067; this->origtheta[x][y]=atan2 ( ( ( this->origy[x][y]-.5 ) *2 ), ( ( this->origx[x][y]-.5 ) *2 ) ); } @@ -203,17 +203,17 @@ void PresetOutputs::PerPixelMath_c(const PipelineContext &context) { for (int y = 0; y < gy; y++) { - const float orig_x = this->orig_x[x][y]; - const float orig_y = this->orig_y[x][y]; - const float warp_mesh = this->warp_mesh[x][y] * 0.0035f; + const float orig_x2 = this->orig_x[x][y]; + const float orig_y2 = this->orig_y[x][y]; + const float warp_mesh2 = this->warp_mesh[x][y] * 0.0035f; this->x_mesh[x][y] += - (warp_mesh * sinf(fWarpTime * 0.333f + fWarpScaleInv * (orig_x * f[0] - orig_y * f[3]))) + - (warp_mesh * cosf(fWarpTime * 0.753f - fWarpScaleInv * (orig_x * f[1] - orig_y * f[2]))); + (warp_mesh2 * sinf(fWarpTime * 0.333f + fWarpScaleInv * (orig_x2 * f[0] - orig_y2 * f[3]))) + + (warp_mesh2 * cosf(fWarpTime * 0.753f - fWarpScaleInv * (orig_x2 * f[1] - orig_y2 * f[2]))); this->y_mesh[x][y] += - (warp_mesh * cosf(fWarpTime * 0.375f - fWarpScaleInv * (orig_x * f[2] + orig_y * f[1]))) + - (warp_mesh * sinf(fWarpTime * 0.825f + fWarpScaleInv * (orig_x * f[0] + orig_y * f[3]))); + (warp_mesh2 * cosf(fWarpTime * 0.375f - fWarpScaleInv * (orig_x2 * f[2] + orig_y2 * f[1]))) + + (warp_mesh2 * sinf(fWarpTime * 0.825f + fWarpScaleInv * (orig_x2 * f[0] + orig_y2 * f[3]))); } } @@ -224,9 +224,9 @@ void PresetOutputs::PerPixelMath_c(const PipelineContext &context) const float u2 = this->x_mesh[x][y] - this->cx_mesh[x][y]; const float v2 = this->y_mesh[x][y] - this->cy_mesh[x][y]; - const float rot = this->rot_mesh[x][y]; - const float cos_rot = cosf(rot); - const float sin_rot = sinf(rot); + const float rot2 = this->rot_mesh[x][y]; + const float cos_rot = cosf(rot2); + const float sin_rot = sinf(rot2); this->x_mesh[x][y] = u2 * cos_rot - v2 * sin_rot + this->cx_mesh[x][y] - this->dx_mesh[x][y]; this->y_mesh[x][y] = u2 * sin_rot + v2 * cos_rot + this->cy_mesh[x][y] - this->dy_mesh[x][y]; @@ -301,46 +301,46 @@ void PresetOutputs::PerPixelMath_sse(const PipelineContext &context) _mm_load_ps(&this->rad_mesh[x][y]), _mm_set_ps1(2.0f)), _mm_set_ps1(1.0f)); - __m128 zoom_mesh = _mm_load_ps(&this->zoom_mesh[x][y]); - __m128 zoomexp_mesh = _mm_load_ps(&this->zoomexp_mesh[x][y]); - __m128 fZoom2 = _mm_pow(zoom_mesh, _mm_pow(zoomexp_mesh, rad_mesh_scaled)); + __m128 zoom_mesh2 = _mm_load_ps(&this->zoom_mesh[x][y]); + __m128 zoomexp_mesh2 = _mm_load_ps(&this->zoomexp_mesh[x][y]); + __m128 fZoom2 = _mm_pow(zoom_mesh2, _mm_pow(zoomexp_mesh2, rad_mesh_scaled)); // fZoom2Inv = 1.0f / fZoom2; __m128 fZoomInv = _mm_rcp_ps(fZoom2); // this->x_mesh[x][y] = this->orig_x[x][y] * 0.5f * fZoom2Inv + 0.5f; - __m128 x_mesh = + __m128 x_mesh2 = _mm_add_ps( _mm_mul_ps( _mm_load_ps(&this->orig_x[x][y]), _mm_mul_ps(fZoomInv,_mm_set_ps1(0.5f))), // CONSIDER: common sub-expression _mm_set_ps1(0.5f)); // this->x_mesh[x][y] = (this->x_mesh[x][y] - this->cx_mesh[x][y]) / this->sx_mesh[x][y] + this->cx_mesh[x][y]; - __m128 cx_mesh = _mm_load_ps(&this->cx_mesh[x][y]); - __m128 sx_mesh = _mm_load_ps(&this->sx_mesh[x][y]); + __m128 cx_mesh2 = _mm_load_ps(&this->cx_mesh[x][y]); + __m128 sx_mesh2 = _mm_load_ps(&this->sx_mesh[x][y]); _mm_store_ps(&this->x_mesh[x][y], _mm_add_ps( _mm_div_ps( - _mm_sub_ps(x_mesh,cx_mesh), - sx_mesh), - cx_mesh + _mm_sub_ps(x_mesh2,cx_mesh2), + sx_mesh2), + cx_mesh2 )); // this->y_mesh[x][y] = this->orig_y[x][y] * 0.5f * fZoom2Inv + 0.5f; - __m128 y_mesh = + __m128 y_mesh2 = _mm_add_ps( _mm_mul_ps( _mm_load_ps(&this->orig_y[x][y]), _mm_mul_ps(fZoomInv,_mm_set_ps1(0.5f))), _mm_set_ps1(0.5f)); // this->y_mesh[x][y] = (this->y_mesh[x][y] - this->cy_mesh[x][y]) / this->sy_mesh[x][y] + this->cy_mesh[x][y]; - __m128 cy_mesh = _mm_load_ps(&this->cy_mesh[x][y]); - __m128 sy_mesh = _mm_load_ps(&this->sy_mesh[x][y]); + __m128 cy_mesh2 = _mm_load_ps(&this->cy_mesh[x][y]); + __m128 sy_mesh2 = _mm_load_ps(&this->sy_mesh[x][y]); _mm_store_ps(&this->y_mesh[x][y], _mm_add_ps( _mm_div_ps( - _mm_sub_ps(y_mesh,cy_mesh), - sy_mesh), - cy_mesh + _mm_sub_ps(y_mesh2,cy_mesh2), + sy_mesh2), + cy_mesh2 )); } } @@ -362,9 +362,9 @@ void PresetOutputs::PerPixelMath_sse(const PipelineContext &context) //float orig_x = this->orig_x[x][y]; //float orig_y = this->orig_y[x][y]; //float warp_mesh = this->warp_mesh[x][y] * 0.0035f; - const __m128 orig_x = _mm_load_ps(&this->orig_x[x][y]); - const __m128 orig_y = _mm_load_ps(&this->orig_y[x][y]); - const __m128 warp_mesh = _mm_mul_ps(_mm_load_ps(&this->warp_mesh[x][y]), _mm_set_ps1(0.0035f)); + const __m128 orig_x2 = _mm_load_ps(&this->orig_x[x][y]); + const __m128 orig_y2 = _mm_load_ps(&this->orig_y[x][y]); + const __m128 warp_mesh2 = _mm_mul_ps(_mm_load_ps(&this->warp_mesh[x][y]), _mm_set_ps1(0.0035f)); // this->x_mesh[x][y] += // (warp_mesh * sinf(fWarpTime * 0.333f + fWarpScaleInv * (orig_x * f[0] - orig_y * f[3]))) + @@ -372,21 +372,21 @@ void PresetOutputs::PerPixelMath_sse(const PipelineContext &context) _mm_store_ps(&this->x_mesh[x][y], _mm_add_ps(_mm_load_ps(&this->x_mesh[x][y]), _mm_add_ps( - _mm_mul_ps(warp_mesh, _mm_sinf( + _mm_mul_ps(warp_mesh2, _mm_sinf( _mm_add_ps( _mm_set_ps1(fWarpTime*0.333f), _mm_mul_ps(_mm_set_ps1(fWarpScaleInv), _mm_sub_ps( - _mm_mul_ps(orig_x, _mm_set_ps1(f[0])), - _mm_mul_ps(orig_y, _mm_set_ps1(f[3])) + _mm_mul_ps(orig_x2, _mm_set_ps1(f[0])), + _mm_mul_ps(orig_y2, _mm_set_ps1(f[3])) ))))), - _mm_mul_ps(warp_mesh, _mm_cosf( + _mm_mul_ps(warp_mesh2, _mm_cosf( _mm_sub_ps( _mm_set_ps1(fWarpTime*0.753f), _mm_mul_ps(_mm_set_ps1(fWarpScaleInv), _mm_sub_ps( - _mm_mul_ps(orig_x, _mm_set_ps1(f[1])), - _mm_mul_ps(orig_y, _mm_set_ps1(f[2])) + _mm_mul_ps(orig_x2, _mm_set_ps1(f[1])), + _mm_mul_ps(orig_y2, _mm_set_ps1(f[2])) )))))))); // this->y_mesh[x][y] += @@ -395,21 +395,21 @@ void PresetOutputs::PerPixelMath_sse(const PipelineContext &context) _mm_store_ps(&this->y_mesh[x][y], _mm_add_ps(_mm_load_ps(&this->y_mesh[x][y]), _mm_add_ps( - _mm_mul_ps(warp_mesh, _mm_cosf( + _mm_mul_ps(warp_mesh2, _mm_cosf( _mm_sub_ps( _mm_set_ps1(fWarpTime*0.375f), _mm_mul_ps(_mm_set_ps1(fWarpScaleInv), _mm_add_ps( - _mm_mul_ps(orig_x, _mm_set_ps1(f[2])), - _mm_mul_ps(orig_y, _mm_set_ps1(f[1])) + _mm_mul_ps(orig_x2, _mm_set_ps1(f[2])), + _mm_mul_ps(orig_y2, _mm_set_ps1(f[1])) ))))), - _mm_mul_ps(warp_mesh, _mm_sinf( + _mm_mul_ps(warp_mesh2, _mm_sinf( _mm_add_ps( _mm_set_ps1(fWarpTime*0.825f), _mm_mul_ps(_mm_set_ps1(fWarpScaleInv), _mm_add_ps( - _mm_mul_ps(orig_x, _mm_set_ps1(f[0])), - _mm_mul_ps(orig_y, _mm_set_ps1(f[3])) + _mm_mul_ps(orig_x2, _mm_set_ps1(f[0])), + _mm_mul_ps(orig_y2, _mm_set_ps1(f[3])) )))))))); } } @@ -456,12 +456,12 @@ void PresetOutputs::PerPixelMath(const PipelineContext &context) } -void PresetOutputs::Initialize ( int gx, int gy ) +void PresetOutputs::Initialize ( int _gx, int _gy ) { - assert(gx > 0); + assert(_gx > 0); - this->gx = gx; - this->gy = gy; + this->gx = _gx; + this->gy = _gy; staticPerPixel = true; diff --git a/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.hpp b/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.hpp index 35f42d8e7..d9bc4ddf4 100644 --- a/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.hpp +++ b/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.hpp @@ -52,7 +52,7 @@ public: /// \param gx the width of the mesh /// \param gy the height of the mesh /// \note This must be called before reading values from this class - void Initialize(int gx, int gy); + void Initialize(int _gx, int _gy); /// Updates this preset inputs with the latest values from the /// the pipeline context and beat detection unit @@ -73,7 +73,7 @@ public: cwave_container customWaves; cshape_container customShapes; - void Initialize(int gx, int gy); + void Initialize(int _gx, int _gy); PresetOutputs(); ~PresetOutputs(); virtual void Render(const BeatDetect &music, const PipelineContext &context); diff --git a/src/libprojectM/NativePresetFactory/NativePresetFactory.cpp b/src/libprojectM/NativePresetFactory/NativePresetFactory.cpp index 529d82528..d39d0a05e 100644 --- a/src/libprojectM/NativePresetFactory/NativePresetFactory.cpp +++ b/src/libprojectM/NativePresetFactory/NativePresetFactory.cpp @@ -105,15 +105,15 @@ PresetLibrary * NativePresetFactory::loadLibrary(const std::string & url) { } -std::auto_ptr NativePresetFactory::allocate +std::unique_ptr NativePresetFactory::allocate (const std::string & url, const std::string & name, const std::string & author) { PresetLibrary * library; if ((library = loadLibrary(url)) == 0) - return std::auto_ptr(0); + return std::unique_ptr(); - return std::auto_ptr(new LibraryPreset + return std::unique_ptr(new LibraryPreset (library->createFunctor()(url.c_str()), library->destroyFunctor())); } diff --git a/src/libprojectM/NativePresetFactory/NativePresetFactory.hpp b/src/libprojectM/NativePresetFactory/NativePresetFactory.hpp index f8aa078ac..591f9bec0 100644 --- a/src/libprojectM/NativePresetFactory/NativePresetFactory.hpp +++ b/src/libprojectM/NativePresetFactory/NativePresetFactory.hpp @@ -26,7 +26,7 @@ public: virtual ~NativePresetFactory(); - virtual std::auto_ptr allocate(const std::string & url, const std::string & name = std::string(), + virtual std::unique_ptr allocate(const std::string & url, const std::string & name = std::string(), const std::string & author = std::string()); virtual std::string supportedExtensions() const { return "so dylib"; } diff --git a/src/libprojectM/PCM.cpp b/src/libprojectM/PCM.cpp index 41bff4502..fbe63619b 100755 --- a/src/libprojectM/PCM.cpp +++ b/src/libprojectM/PCM.cpp @@ -266,7 +266,7 @@ void PCM::addPCM8_512( const unsigned char PCMdata[2][512]) void PCM::getPCM(float *PCMdata, int samples, int channel, int freq, float smoothing, int derive) { - int i,index; + int index; index=start-1; @@ -274,7 +274,7 @@ void PCM::getPCM(float *PCMdata, int samples, int channel, int freq, float smoot PCMdata[0]=PCMd[channel][index]; - for(i=1;i allocate(); + std::unique_ptr allocate(); /// Set the chooser asocciated with this iterator void setChooser(const PresetChooser & chooser); @@ -71,7 +71,7 @@ public: /// \param presetInputs the preset inputs to associate with the preset upon construction /// \param presetOutputs the preset outputs to associate with the preset upon construction /// \returns an auto pointer of the newly allocated preset - std::auto_ptr directoryIndex(std::size_t index) const; + std::unique_ptr directoryIndex(std::size_t index) const; /// Gets the number of presets last believed to exist in the preset loader's filename collection /// \returns the number of presets in the collection @@ -145,7 +145,7 @@ inline bool PresetIterator::operator ==(const PresetIterator & presetPos) const return (*presetPos == **this); } -inline std::auto_ptr PresetIterator::allocate() { +inline std::unique_ptr PresetIterator::allocate() { return _presetChooser->directoryIndex(_currentIndex); } @@ -211,7 +211,7 @@ inline bool PresetChooser::empty() const { return _presetLoader->size() == 0; } -inline std::auto_ptr PresetChooser::directoryIndex(std::size_t index) const { +inline std::unique_ptr PresetChooser::directoryIndex(std::size_t index) const { return _presetLoader->loadPreset(index); } diff --git a/src/libprojectM/PresetFactory.hpp b/src/libprojectM/PresetFactory.hpp index e9c8a4cd0..07bb30b52 100644 --- a/src/libprojectM/PresetFactory.hpp +++ b/src/libprojectM/PresetFactory.hpp @@ -31,7 +31,7 @@ public: /// \param name the preset name /// \param author the preset author /// \returns a valid preset object - virtual std::auto_ptr allocate(const std::string & url, const std::string & name=std::string(), + virtual std::unique_ptr allocate(const std::string & url, const std::string & name=std::string(), const std::string & author=std::string()) = 0; /// Returns a space separated list of supported extensions diff --git a/src/libprojectM/PresetFactoryManager.cpp b/src/libprojectM/PresetFactoryManager.cpp index fbc87d680..c8baa2967 100644 --- a/src/libprojectM/PresetFactoryManager.cpp +++ b/src/libprojectM/PresetFactoryManager.cpp @@ -78,7 +78,7 @@ void PresetFactoryManager::registerFactory(const std::string & extensions, Prese -std::auto_ptr PresetFactoryManager::allocate(const std::string & url, const std::string & name) +std::unique_ptr PresetFactoryManager::allocate(const std::string & url, const std::string & name) { try { const std::string extension = parseExtension (url); @@ -91,7 +91,7 @@ std::auto_ptr PresetFactoryManager::allocate(const std::string & url, co } catch (...) { throw PresetFactoryException("uncaught preset factory exception"); } - return std::auto_ptr(); + return std::unique_ptr(); } PresetFactory & PresetFactoryManager::factory(const std::string & extension) { diff --git a/src/libprojectM/PresetFactoryManager.hpp b/src/libprojectM/PresetFactoryManager.hpp index 9fbcac43d..7a9867acb 100644 --- a/src/libprojectM/PresetFactoryManager.hpp +++ b/src/libprojectM/PresetFactoryManager.hpp @@ -48,7 +48,7 @@ class PresetFactoryManager { /// \param extension the file name extension to verify /// \returns true if a factory exists, false otherwise bool extensionHandled(const std::string & extension) const; - std::auto_ptr allocate(const std::string & url, const std::string & name); + std::unique_ptr allocate(const std::string & url, const std::string & name); private: int _gx, _gy; diff --git a/src/libprojectM/PresetLoader.cpp b/src/libprojectM/PresetLoader.cpp index 4006a2499..a685d22cb 100644 --- a/src/libprojectM/PresetLoader.cpp +++ b/src/libprojectM/PresetLoader.cpp @@ -84,8 +84,8 @@ void PresetLoader::rescan() while ( ( dir_entry = readdir ( _dir ) ) != NULL ) { - if (dir_entry->d_name == 0) - continue; + if (dir_entry->d_name[0] == 0) + continue; std::ostringstream out; // Convert char * to friendly string @@ -130,11 +130,10 @@ void PresetLoader::rescan() } -std::auto_ptr PresetLoader::loadPreset ( unsigned int index ) const +std::unique_ptr PresetLoader::loadPreset ( unsigned int index ) const { // Check that index isn't insane - assert ( index >= 0 ); assert ( index < _entries.size() ); return _presetFactoryManager.allocate ( _entries[index], _presetNames[index] ); @@ -142,7 +141,7 @@ std::auto_ptr PresetLoader::loadPreset ( unsigned int index ) const } -std::auto_ptr PresetLoader::loadPreset ( const std::string & url ) const +std::unique_ptr PresetLoader::loadPreset ( const std::string & url ) const { // std::cout << "Loading preset " << url << std::endl; @@ -155,7 +154,7 @@ std::auto_ptr PresetLoader::loadPreset ( const std::string & url ) cons } catch (...) { throw PresetFactoryException("preset factory exception of unknown cause"); } - return std::auto_ptr(); + return std::unique_ptr(); } void PresetLoader::handleDirectoryError() @@ -193,8 +192,6 @@ void PresetLoader::handleDirectoryError() void PresetLoader::setRating(unsigned int index, int rating, const PresetRatingType ratingType) { - assert ( index >=0 ); - const unsigned int ratingTypeIndex = static_cast(ratingType); assert (index < _ratings[ratingTypeIndex].size()); @@ -214,10 +211,10 @@ unsigned int PresetLoader::addPresetURL ( const std::string & url, const std::st assert(ratings.size() == TOTAL_RATING_TYPES); assert(ratings.size() == _ratings.size()); - for (int i = 0; i < _ratings.size(); i++) + for (unsigned int i = 0; i < _ratings.size(); i++) _ratings[i].push_back(ratings[i]); - for (int i = 0; i < ratings.size(); i++) + for (unsigned int i = 0; i < ratings.size(); i++) _ratingsSums[i] += ratings[i]; return _entries.size()-1; @@ -229,7 +226,7 @@ void PresetLoader::removePreset ( unsigned int index ) _entries.erase ( _entries.begin() + index ); _presetNames.erase ( _presetNames.begin() + index ); - for (int i = 0; i < _ratingsSums.size(); i++) { + for (unsigned int i = 0; i < _ratingsSums.size(); i++) { _ratingsSums[i] -= _ratings[i][index]; _ratings[i].erase ( _ratings[i].begin() + index ); } @@ -272,7 +269,7 @@ void PresetLoader::insertPresetURL ( unsigned int index, const std::string & url - for (int i = 0; i < _ratingsSums.size();i++) { + for (unsigned int i = 0; i < _ratingsSums.size();i++) { _ratingsSums[i] += _ratings[i][index]; _ratings[i].insert ( _ratings[i].begin() + index, ratings[i] ); } diff --git a/src/libprojectM/PresetLoader.hpp b/src/libprojectM/PresetLoader.hpp index 8acbc0a30..ecdfe20b8 100644 --- a/src/libprojectM/PresetLoader.hpp +++ b/src/libprojectM/PresetLoader.hpp @@ -40,8 +40,8 @@ class PresetLoader { /// Load a preset by specifying its unique identifier given when the preset url /// was added to this loader - std::auto_ptr loadPreset(unsigned int index) const; - std::auto_ptr loadPreset ( const std::string & url ) const; + std::unique_ptr loadPreset(unsigned int index) const; + std::unique_ptr loadPreset ( const std::string & url ) const; /// Add a preset to the loader's collection. /// \param url an url referencing the preset /// \param presetName a name for the preset diff --git a/src/libprojectM/RandomNumberGenerators.hpp b/src/libprojectM/RandomNumberGenerators.hpp index 862e43bba..ce6d5cbae 100644 --- a/src/libprojectM/RandomNumberGenerators.hpp +++ b/src/libprojectM/RandomNumberGenerators.hpp @@ -36,7 +36,7 @@ inline float uniform() inline float gaussian(float mean, float sigma) { - float x1, x2, w, y1, y2; + float x1, x2, w, y1; do { x1 = 2.0 * uniform() - 1.0; @@ -46,7 +46,6 @@ inline float gaussian(float mean, float sigma) w = sqrt( (-2.0 * log( w ) ) / w ); y1 = x1 * w; - y2 = x2 * w; float ret = y1*sigma + mean; diff --git a/src/libprojectM/Renderer/BeatDetect.cpp b/src/libprojectM/Renderer/BeatDetect.cpp index 3fca6f814..d987f207b 100755 --- a/src/libprojectM/Renderer/BeatDetect.cpp +++ b/src/libprojectM/Renderer/BeatDetect.cpp @@ -36,10 +36,10 @@ #include #include "BeatDetect.hpp" -BeatDetect::BeatDetect(PCM *pcm) { +BeatDetect::BeatDetect(PCM *_pcm) { int x,y; - this->pcm=pcm; + this->pcm=_pcm; this->vol_instant=0; this->vol_history=0; diff --git a/src/libprojectM/Renderer/MilkdropWaveform.cpp b/src/libprojectM/Renderer/MilkdropWaveform.cpp index 11f1a4d85..457cf5726 100644 --- a/src/libprojectM/Renderer/MilkdropWaveform.cpp +++ b/src/libprojectM/Renderer/MilkdropWaveform.cpp @@ -14,8 +14,9 @@ #include MilkdropWaveform::MilkdropWaveform(): RenderItem(), - x(0.5), y(0.5), r(1), g(0), b(0), a(1), mystery(0), mode(Line), scale(10), smoothing(0), rot(0), samples(0),modOpacityStart(0),modOpacityEnd(1), - modulateAlphaByVolume(false), maximizeColors(false), additive(false), dots(false), thick(false), loop(false) { + x(0.5), y(0.5), r(1), g(0), b(0), a(1), mystery(0), mode(Line), additive(false), dots(false), thick(false), + modulateAlphaByVolume(false), maximizeColors(false), scale(10), smoothing(0), + modOpacityStart(0), modOpacityEnd(1), rot(0), samples(0), loop(false) { Init(); } @@ -194,11 +195,7 @@ void MilkdropWaveform::MaximizeColors(RenderContext &context) void MilkdropWaveform::WaveformMath(RenderContext &context) { - int i; - - float r, theta; - - float offset; + float r2, theta; float wave_x_temp=0; float wave_y_temp=0; @@ -206,7 +203,6 @@ void MilkdropWaveform::WaveformMath(RenderContext &context) float cos_rot; float sin_rot; - offset=x-.5; float temp_y; two_waves = false; @@ -237,11 +233,11 @@ void MilkdropWaveform::WaveformMath(RenderContext &context) float value = context.beatDetect->pcm->pcmdataR[i]+context.beatDetect->pcm->pcmdataL[i]; value += offset * (i/(float)samples); - r=(0.5 + 0.4f*.12*value*scale + mystery)*.5; - theta=i*inv_nverts_minus_one*6.28f + context.time*0.2f; + r2=(0.5 + 0.4f*.12*value*scale + mystery)*.5; + theta=i*inv_nverts_minus_one*6.28f + context.time*0.2f; - wavearray[i][0]=(r*cos(theta)*(context.aspectCorrect? context.aspectRatio : 1.0)+x); - wavearray[i][1]=(r*sin(theta)+temp_y); + wavearray[i][0]=(r2*cos(theta)*(context.aspectCorrect? context.aspectRatio : 1.0)+x); + wavearray[i][1]=(r2*sin(theta)+temp_y); } } @@ -257,11 +253,11 @@ void MilkdropWaveform::WaveformMath(RenderContext &context) samples = 512-32; for ( int i=0;i<512-32;i++) { - theta=context.beatDetect->pcm->pcmdataL[i+32]*0.06*scale * 1.57 + context.time*2.3; - r=(0.53 + 0.43*context.beatDetect->pcm->pcmdataR[i]*0.12*scale+ mystery)*.5; + theta=context.beatDetect->pcm->pcmdataL[i+32]*0.06*scale * 1.57 + context.time*2.3; + r2=(0.53 + 0.43*context.beatDetect->pcm->pcmdataR[i]*0.12*scale+ mystery)*.5; - wavearray[i][0]=(r*cos(theta)*(context.aspectCorrect ? context.aspectRatio : 1.0)+x); - wavearray[i][1]=(r*sin(theta)+temp_y); + wavearray[i][0]=(r2*cos(theta)*(context.aspectCorrect ? context.aspectRatio : 1.0)+x); + wavearray[i][1]=(r2*sin(theta)+temp_y); } break; diff --git a/src/libprojectM/Renderer/PerPixelMesh.cpp b/src/libprojectM/Renderer/PerPixelMesh.cpp index c37813355..aecfd3435 100644 --- a/src/libprojectM/Renderer/PerPixelMesh.cpp +++ b/src/libprojectM/Renderer/PerPixelMesh.cpp @@ -4,10 +4,10 @@ #include "omptl/omptl" #include "omptl/omptl_algorithm" -PerPixelMesh::PerPixelMesh(int width, int height) : width(width), height(height), size (width * height), - p(width * height, PixelPoint(0,0)), - p_original(width * height, PixelPoint(0,0)), - identity(width * height, PerPixelContext(0,0,0,0,0,0)) +PerPixelMesh::PerPixelMesh(int _width, int _height) : width(_width), height(_height), size (_width * _height), + p(_width * _height, PixelPoint(0,0)), + p_original(_width * _height, PixelPoint(0,0)), + identity(_width * _height, PerPixelContext(0,0,0,0,0,0)) { for (int j=0;j p_original; std::vector identity; - PerPixelMesh(int width, int height); + PerPixelMesh(int _width, int _height); void Reset(); }; diff --git a/src/libprojectM/Renderer/Pipeline.cpp b/src/libprojectM/Renderer/Pipeline.cpp index 23780a3bf..adb70dc3f 100644 --- a/src/libprojectM/Renderer/Pipeline.cpp +++ b/src/libprojectM/Renderer/Pipeline.cpp @@ -11,14 +11,11 @@ Pipeline::Pipeline() : staticPerPixel(false),gx(0),gy(0),blur1n(1), blur2n(1), b blur1x(1), blur2x(1), blur3x(1), blur1ed(1){} -float **alloc_mesh(size_t gx, size_t gy); -float **free_mesh(float **mesh); - -void Pipeline::setStaticPerPixel(int gx, int gy) +void Pipeline::setStaticPerPixel(int _gx, int _gy) { staticPerPixel = true; - this->gx = gx; - this->gy = gy; + this->gx = _gx; + this->gy = _gy; this->x_mesh = alloc_mesh(gx, gy); this->y_mesh = alloc_mesh(gx, gy); diff --git a/src/libprojectM/Renderer/Pipeline.hpp b/src/libprojectM/Renderer/Pipeline.hpp index 0b336641c..807826129 100644 --- a/src/libprojectM/Renderer/Pipeline.hpp +++ b/src/libprojectM/Renderer/Pipeline.hpp @@ -50,9 +50,12 @@ public: std::vector compositeDrawables; Pipeline(); - void setStaticPerPixel(int gx, int gy); + void setStaticPerPixel(int _gx, int _gy); virtual ~Pipeline(); virtual PixelPoint PerPixel(PixelPoint p, const PerPixelContext context); }; +float **alloc_mesh(size_t gx, size_t gy); +float **free_mesh(float **mesh); + #endif diff --git a/src/libprojectM/Renderer/RenderItemMatcher.cpp b/src/libprojectM/Renderer/RenderItemMatcher.cpp index 612f118db..dca233284 100644 --- a/src/libprojectM/Renderer/RenderItemMatcher.cpp +++ b/src/libprojectM/Renderer/RenderItemMatcher.cpp @@ -1,8 +1,8 @@ #include "RenderItemMatcher.hpp" double RenderItemMatcher::computeMatching(const RenderItemList & lhs, const RenderItemList & rhs) const { - for (int i = 0; i < lhs.size();i++) { - int j; + for (unsigned int i = 0; i < lhs.size();i++) { + unsigned int j; for (j = 0; j < rhs.size();j++) _weights[i][j] = _distanceFunction(lhs[i], rhs[j]); for (; j < lhs.size();j++) @@ -20,7 +20,7 @@ double RenderItemMatcher::computeMatching(const RenderItemList & lhs, const Rend void RenderItemMatcher::setMatches (const RenderItemList & lhs_src, const RenderItemList & rhs_src) const { - for (int i = 0; i < lhs_src.size();i++) { + for (unsigned int i = 0; i < lhs_src.size();i++) { const int j = _hungarianMethod.matching(i); // hack diff --git a/src/libprojectM/Renderer/RenderItemMergeFunction.hpp b/src/libprojectM/Renderer/RenderItemMergeFunction.hpp index d07b035b8..846736576 100644 --- a/src/libprojectM/Renderer/RenderItemMergeFunction.hpp +++ b/src/libprojectM/Renderer/RenderItemMergeFunction.hpp @@ -120,7 +120,7 @@ protected: target.enabled = interpolate(lhs->enabled, rhs->enabled, ratio); target.masterAlpha = interpolate(lhs->masterAlpha, rhs->masterAlpha, ratio); - target.imageUrl = (ratio > 0.5) ? lhs->imageUrl : rhs->imageUrl, ratio; + target.imageUrl = (ratio > 0.5) ? lhs->imageUrl : rhs->imageUrl; return ret; } diff --git a/src/libprojectM/Renderer/Renderable.cpp b/src/libprojectM/Renderer/Renderable.cpp index 3ef1eebbf..29c0f0d25 100644 --- a/src/libprojectM/Renderer/Renderable.cpp +++ b/src/libprojectM/Renderer/Renderable.cpp @@ -83,7 +83,6 @@ void DarkenCenter::Draw(RenderContext &context) Shape::Shape():RenderItem() { - std::string imageUrl = ""; sides = 4; thickOutline = false; enabled = true; @@ -329,7 +328,7 @@ void MotionVectors::Draw(RenderContext &context) { for(int y=0;y<(int)y_num;y++) { - float lx, ly, lz; + float lx, ly; lx = x_offset+x*intervalx; ly = y_offset+y*intervaly; diff --git a/src/libprojectM/Renderer/Renderable.hpp b/src/libprojectM/Renderer/Renderable.hpp index fee9e82f0..799125dba 100644 --- a/src/libprojectM/Renderer/Renderable.hpp +++ b/src/libprojectM/Renderer/Renderable.hpp @@ -159,7 +159,7 @@ public: struct TypeIdPair { TypeIdPair(const std::type_info & info1, const std::type_info & info2): id1(info1.name()), id2(info2.name()) {} - TypeIdPair(const std::string & id1, const std::string & id2): id1(id1), id2(id2) {} + TypeIdPair(const std::string & _id1, const std::string & _id2): id1(_id1), id2(_id2) {} std::string id1; std::string id2; inline bool operator<(const TypeIdPair & rhs) const { diff --git a/src/libprojectM/Renderer/Renderer.cpp b/src/libprojectM/Renderer/Renderer.cpp index 5da27fcb6..615f649fd 100644 --- a/src/libprojectM/Renderer/Renderer.cpp +++ b/src/libprojectM/Renderer/Renderer.cpp @@ -21,8 +21,8 @@ class Preset; Renderer::Renderer(int width, int height, int gx, int gy, BeatDetect *_beatDetect, std::string _presetURL, std::string _titlefontURL, std::string _menufontURL, const std::string& datadir) : - title_fontURL(_titlefontURL), menu_fontURL(_menufontURL), presetURL(_presetURL), m_presetName("None"), vw(width), - vh(height), mesh(gx, gy), m_datadir(datadir) + mesh(gx, gy), m_presetName("None"), m_datadir(datadir), vw(width), vh(height), + title_fontURL(_titlefontURL), menu_fontURL(_menufontURL), presetURL(_presetURL) { this->totalframes = 1; this->noSwitch = false; @@ -729,7 +729,7 @@ void Renderer::draw_stats() #endif /** USE_FTGL */ } -void Renderer::draw_fps(float realfps) +void Renderer::draw_fps() { #ifdef USE_FTGL char bufferfps[20]; @@ -793,6 +793,10 @@ int Renderer::nearestPower2( int value ) { int x = value; int power = 0; + if ( x == 0 ) { + return 0; + } + while ( ( x & 0x01 ) != 1 ) { x >>= 1; } diff --git a/src/libprojectM/Renderer/Renderer.hpp b/src/libprojectM/Renderer/Renderer.hpp index 7d2c00e64..1e12e0adc 100644 --- a/src/libprojectM/Renderer/Renderer.hpp +++ b/src/libprojectM/Renderer/Renderer.hpp @@ -142,7 +142,7 @@ private: void rescale_per_pixel_matrices(); - void draw_fps( float realfps ); + void draw_fps(); void draw_stats(); void draw_help(); void draw_preset(); diff --git a/src/libprojectM/Renderer/SOIL2/SOIL2.c b/src/libprojectM/Renderer/SOIL2/SOIL2.c index 5aaec161b..64dbf27ad 100644 --- a/src/libprojectM/Renderer/SOIL2/SOIL2.c +++ b/src/libprojectM/Renderer/SOIL2/SOIL2.c @@ -495,7 +495,7 @@ unsigned int SOIL_load_OGL_texture_from_memory ( const unsigned char *const buffer, - int buffer_length, + unsigned int buffer_length, int force_channels, unsigned int reuse_texture_ID, unsigned int flags, @@ -1939,7 +1939,7 @@ const char* unsigned int SOIL_direct_load_DDS_from_memory( const unsigned char *const buffer, - int buffer_length, + unsigned int buffer_length, unsigned int reuse_texture_ID, int flags, int loading_as_cubemap ) @@ -2124,7 +2124,7 @@ unsigned int SOIL_direct_load_DDS_from_memory( /* do this for each face of the cubemap! */ for( cf_target = ogl_target_start; cf_target <= ogl_target_end; ++cf_target ) { - if( buffer_index + DDS_full_size <= (unsigned int)buffer_length ) + if( buffer_index + DDS_full_size <= buffer_length ) { unsigned int byte_offset = DDS_main_size; memcpy( (void*)DDS_data, (const void*)(&buffer[buffer_index]), DDS_full_size ); diff --git a/src/libprojectM/Renderer/SOIL2/SOIL2.h b/src/libprojectM/Renderer/SOIL2/SOIL2.h index 731997e29..ddaa1b10b 100755 --- a/src/libprojectM/Renderer/SOIL2/SOIL2.h +++ b/src/libprojectM/Renderer/SOIL2/SOIL2.h @@ -245,15 +245,14 @@ unsigned int **/ unsigned int SOIL_load_OGL_texture_from_memory - ( - const unsigned char *const buffer, - int buffer_length, - int force_channels, - unsigned int reuse_texture_ID, + (const unsigned char *const buffer, + unsigned int buffer_length, + int force_channels, + unsigned int reuse_texture_ID, unsigned int flags, int * width, int * height - ); + ); /** Loads 6 images from memory into an OpenGL cubemap texture. @@ -463,7 +462,7 @@ unsigned int SOIL_direct_load_DDS( /** Loads the DDS texture directly to the GPU memory ( if supported ) */ unsigned int SOIL_direct_load_DDS_from_memory( const unsigned char *const buffer, - int buffer_length, + unsigned int buffer_length, unsigned int reuse_texture_ID, int flags, int loading_as_cubemap ); diff --git a/src/libprojectM/Renderer/SOIL2/stb_image.h b/src/libprojectM/Renderer/SOIL2/stb_image.h index bfec1e5c5..a098542c7 100644 --- a/src/libprojectM/Renderer/SOIL2/stb_image.h +++ b/src/libprojectM/Renderer/SOIL2/stb_image.h @@ -1392,18 +1392,30 @@ static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int r // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (COMBO(img_n, req_comp)) { - CASE(1,2) dest[0]=src[0], dest[1]=255; break; - CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break; - CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break; - CASE(2,1) dest[0]=src[0]; break; - CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break; - CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break; - CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break; - CASE(3,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break; - CASE(3,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = 255; break; - CASE(4,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break; - CASE(4,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break; - CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break; + CASE(1,2) dest[0]=src[0], dest[1]=255; + break; + CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; + break; + CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; + break; + CASE(2,1) dest[0]=src[0]; + break; + CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; + break; + CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; + break; + CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; + break; + CASE(3,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); + break; + CASE(3,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = 255; + break; + CASE(4,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); + break; + CASE(4,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = src[3]; + break; + CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; + break; default: STBI_ASSERT(0); } #undef CASE @@ -3554,10 +3566,10 @@ static int stbi__zbuild_huffman(stbi__zhuffman *z, stbi_uc *sizelist, int num) z->size [c] = (stbi_uc ) s; z->value[c] = (stbi__uint16) i; if (s <= STBI__ZFAST_BITS) { - int k = stbi__bit_reverse(next_code[s],s); - while (k < (1 << STBI__ZFAST_BITS)) { - z->fast[k] = fastv; - k += (1 << s); + int k2 = stbi__bit_reverse(next_code[s],s); + while (k2 < (1 << STBI__ZFAST_BITS)) { + z->fast[k2] = fastv; + k2 += (1 << s); } } ++next_code[s]; @@ -4080,13 +4092,20 @@ static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 r for (k=0; k < nk; ++k) switch (filter) { // "none" filter turns into a memcpy here; make that explicit. - case STBI__F_none: memcpy(cur, raw, nk); break; - CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); break; - CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; - CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); break; - CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); break; - CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); break; - CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); break; + case STBI__F_none: memcpy(cur, raw, nk); + break; + CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); + break; + CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); + break; + CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); + break; + CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); + break; + CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); + break; + CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); + break; } #undef CASE raw += nk; @@ -4097,13 +4116,20 @@ static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 r for (i=x-1; i >= 1; --i, cur[img_n]=255,raw+=img_n,cur+=out_n,prior+=out_n) \ for (k=0; k < img_n; ++k) switch (filter) { - CASE(STBI__F_none) cur[k] = raw[k]; break; - CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-out_n]); break; - CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; - CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-out_n])>>1)); break; - CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-out_n],prior[k],prior[k-out_n])); break; - CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-out_n] >> 1)); break; - CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-out_n],0,0)); break; + CASE(STBI__F_none) cur[k] = raw[k]; + break; + CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-out_n]); + break; + CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); + break; + CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-out_n])>>1)); + break; + CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-out_n],prior[k],prior[k-out_n])); + break; + CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-out_n] >> 1)); + break; + CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-out_n],0,0)); + break; } #undef CASE } @@ -4163,20 +4189,20 @@ static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 r } if (img_n != out_n) { // insert alpha = 255 - stbi_uc *cur = a->out + stride*j; - int i; + stbi_uc *cur2 = a->out + stride*j; + int i2; if (img_n == 1) { - for (i=x-1; i >= 0; --i) { - cur[i*2+1] = 255; - cur[i*2+0] = cur[i]; + for (i2=x-1; i2 >= 0; --i2) { + cur2[i2*2+1] = 255; + cur2[i2*2+0] = cur2[i2]; } } else { STBI_ASSERT(img_n == 3); - for (i=x-1; i >= 0; --i) { - cur[i*4+3] = 255; - cur[i*4+2] = cur[i*3+2]; - cur[i*4+1] = cur[i*3+1]; - cur[i*4+0] = cur[i*3+0]; + for (i2=x-1; i2 >= 0; --i2) { + cur2[i2*4+3] = 255; + cur2[i2*4+2] = cur2[i2*3+2]; + cur2[i2*4+1] = cur2[i2*3+1]; + cur2[i2*4+0] = cur2[i2*3+0]; } } } @@ -4961,8 +4987,8 @@ static stbi_uc *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int if ( !tga_indexed && !tga_is_RLE) { for (i=0; i < tga_height; ++i) { - int y = tga_inverted ? tga_height -i - 1 : i; - stbi_uc *tga_row = tga_data + y*tga_width*tga_comp; + int y2 = tga_inverted ? tga_height -i - 1 : i; + stbi_uc *tga_row = tga_data + y2*tga_width*tga_comp; stbi__getn(s, tga_row, tga_width * tga_comp); } } else { @@ -5401,7 +5427,6 @@ static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *c if (count >= 128) { // Repeated stbi_uc value[4]; - int i; if (count==128) count = stbi__get16be(s); @@ -5643,22 +5668,22 @@ static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) bits |= (stbi__int32) stbi__get8(s) << valid_bits; valid_bits += 8; } else { - stbi__int32 code = bits & codemask; + stbi__int32 code2 = bits & codemask; bits >>= codesize; valid_bits -= codesize; // @OPTIMIZE: is there some way we can accelerate the non-clear path? - if (code == clear) { // clear code + if (code2 == clear) { // clear code codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; avail = clear + 2; oldcode = -1; first = 0; - } else if (code == clear + 1) { // end of stream code + } else if (code2 == clear + 1) { // end of stream code stbi__skip(s, len); while ((len = stbi__get8(s)) > 0) stbi__skip(s,len); return g->out; - } else if (code <= avail) { + } else if (code2 <= avail) { if (first) return stbi__errpuc("no clear code", "Corrupt GIF"); if (oldcode >= 0) { @@ -5666,18 +5691,18 @@ static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) if (avail > 4096) return stbi__errpuc("too many codes", "Corrupt GIF"); p->prefix = (stbi__int16) oldcode; p->first = g->codes[oldcode].first; - p->suffix = (code == avail) ? p->first : g->codes[code].first; - } else if (code == avail) + p->suffix = (code2 == avail) ? p->first : g->codes[code2].first; + } else if (code2 == avail) return stbi__errpuc("illegal code in raster", "Corrupt GIF"); - stbi__out_gif_code(g, (stbi__uint16) code); + stbi__out_gif_code(g, (stbi__uint16) code2); if ((avail & codemask) == 0 && avail <= 0x0FFF) { codesize++; codemask = (1 << codesize) - 1; } - oldcode = code; + oldcode = code2; } else { return stbi__errpuc("illegal code in raster", "Corrupt GIF"); } diff --git a/src/libprojectM/Renderer/SOIL2/stb_image_write.h b/src/libprojectM/Renderer/SOIL2/stb_image_write.h index 104897075..22de40b93 100644 --- a/src/libprojectM/Renderer/SOIL2/stb_image_write.h +++ b/src/libprojectM/Renderer/SOIL2/stb_image_write.h @@ -326,14 +326,14 @@ void stbiw__write_hdr_scanline(FILE *f, int width, int comp, unsigned char *scra /* RLE each component separately */ for (c=0; c < 4; c++) { - unsigned char *comp = &scratch[width*c]; + unsigned char *comp2 = &scratch[width*c]; x = 0; while (x < width) { // find first run r = x; while (r+2 < width) { - if (comp[r] == comp[r+1] && comp[r] == comp[r+2]) + if (comp2[r] == comp2[r+1] && comp2[r] == comp2[r+2]) break; ++r; } @@ -343,19 +343,19 @@ void stbiw__write_hdr_scanline(FILE *f, int width, int comp, unsigned char *scra while (x < r) { int len = r-x; if (len > 128) len = 128; - stbiw__write_dump_data(f, len, &comp[x]); + stbiw__write_dump_data(f, len, &comp2[x]); x += len; } // if there's a run, output it if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd // find next byte after run - while (r < width && comp[r] == comp[x]) + while (r < width && comp2[r] == comp2[x]) ++r; // output run up to r while (x < r) { int len = r-x; if (len > 127) len = 127; - stbiw__write_run_data(f, len, comp[x]); + stbiw__write_run_data(f, len, comp2[x]); x += len; } } @@ -550,12 +550,12 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l { // compute adler32 on input - unsigned int i=0, s1=1, s2=0, blocklen = data_len % 5552; - int j=0; - while (j < data_len) { - for (i=0; i < blocklen; ++i) s1 += data[j+i], s2 += s1; + unsigned int i2=0, s1=1, s2=0, blocklen = data_len % 5552; + int j2=0; + while (j2 < data_len) { + for (i2=0; i2 < blocklen; ++i2) s1 += data[j2+i2], s2 += s1; s1 %= 65521, s2 %= 65521; - j += blocklen; + j2 += blocklen; blocklen = 5552; } stbiw__sbpush(out, (unsigned char) (s2 >> 8)); diff --git a/src/libprojectM/Renderer/SOIL2/stbi_DDS_c.h b/src/libprojectM/Renderer/SOIL2/stbi_DDS_c.h index 5720c098a..82494aa2d 100755 --- a/src/libprojectM/Renderer/SOIL2/stbi_DDS_c.h +++ b/src/libprojectM/Renderer/SOIL2/stbi_DDS_c.h @@ -241,7 +241,8 @@ void stbi_decode_DXT_color_block( } static int stbi__dds_info( stbi__context *s, int *x, int *y, int *comp, int *iscompressed ) { - int flags,is_compressed,has_alpha; + unsigned int flags; + int is_compressed,has_alpha; DDS_header header={0}; if( sizeof( DDS_header ) != 128 ) @@ -342,7 +343,8 @@ static stbi_uc * stbi__dds_load(stbi__context *s, int *x, int *y, int *comp, int stbi_uc *dds_data = NULL; stbi_uc block[16*4]; stbi_uc compressed[8]; - int flags, DXT_family; + unsigned int flags; + int DXT_family; int has_alpha, has_mipmap; int is_compressed, cubemap_faces; int block_pitch, num_blocks; diff --git a/src/libprojectM/Renderer/ShaderEngine.cpp b/src/libprojectM/Renderer/ShaderEngine.cpp index a182720a8..644c86623 100644 --- a/src/libprojectM/Renderer/ShaderEngine.cpp +++ b/src/libprojectM/Renderer/ShaderEngine.cpp @@ -897,7 +897,7 @@ void ShaderEngine::SetupShaderVariables(GLuint program, const Pipeline &pipeline void ShaderEngine::SetupTextures(GLuint program, const Shader &shader) { - uint texNum = 0; + unsigned int texNum = 0; std::map texsizes; // Set samplers @@ -949,7 +949,7 @@ void ShaderEngine::SetupTextures(GLuint program, const Shader &shader) void ShaderEngine::RenderBlurTextures(const Pipeline &pipeline, const PipelineContext &pipelineContext) { - uint passes = 0; + unsigned int passes = 0; if (blur3_enabled) { passes = 6; } else if (blur2_enabled) { @@ -1017,7 +1017,7 @@ void ShaderEngine::RenderBlurTextures(const Pipeline &pipeline, const PipelineCo glBlendFunc(GL_ONE, GL_ZERO); glBindVertexArray(vaoBlur); - for (uint i=0; i class Array { public: - Array(Allocator * allocator) : allocator(allocator), buffer(NULL), size(0), capacity(0) {} + Array(Allocator * _allocator) : allocator(_allocator), buffer(NULL), size(0), capacity(0) {} void PushBack(const T & val) { ASSERT(&val < buffer || &val >= buffer+size); diff --git a/src/libprojectM/Renderer/hlslparser/src/GLSLGenerator.cpp b/src/libprojectM/Renderer/hlslparser/src/GLSLGenerator.cpp index 0afb03f8c..9a277185a 100755 --- a/src/libprojectM/Renderer/hlslparser/src/GLSLGenerator.cpp +++ b/src/libprojectM/Renderer/hlslparser/src/GLSLGenerator.cpp @@ -582,12 +582,12 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* HLSLUnaryExpression* unaryExpression = static_cast(expression); const char* op = "?"; bool pre = true; - const HLSLType* dstType = NULL; + const HLSLType* dstType2 = NULL; switch (unaryExpression->unaryOp) { case HLSLUnaryOp_Negative: op = "-"; break; case HLSLUnaryOp_Positive: op = "+"; break; - case HLSLUnaryOp_Not: op = "!"; dstType = &unaryExpression->expressionType; break; + case HLSLUnaryOp_Not: op = "!"; dstType2 = &unaryExpression->expressionType; break; case HLSLUnaryOp_PreIncrement: op = "++"; break; case HLSLUnaryOp_PreDecrement: op = "--"; break; case HLSLUnaryOp_PostIncrement: op = "++"; pre = false; break; @@ -598,11 +598,11 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* if (pre) { m_writer.Write("%s", op); - OutputExpression(unaryExpression->expression, dstType); + OutputExpression(unaryExpression->expression, dstType2); } else { - OutputExpression(unaryExpression->expression, dstType); + OutputExpression(unaryExpression->expression, dstType2); m_writer.Write("%s", op); } m_writer.Write(")"); diff --git a/src/libprojectM/Renderer/hlslparser/src/HLSLParser.cpp b/src/libprojectM/Renderer/hlslparser/src/HLSLParser.cpp index 00b185a63..ce85bad4f 100755 --- a/src/libprojectM/Renderer/hlslparser/src/HLSLParser.cpp +++ b/src/libprojectM/Renderer/hlslparser/src/HLSLParser.cpp @@ -339,6 +339,7 @@ static const EffectStateValue witnessStencilModeValues[] = { {NULL, 0} }; +/* not used static const EffectStateValue witnessFilterModeValues[] = { {"Point", 0}, {"Linear", 1}, @@ -354,6 +355,7 @@ static const EffectStateValue witnessWrapModeValues[] = { {"ClampToBorder", 2}, {NULL, 0} }; +*/ static const EffectState pipelineStates[] = { {"VertexShader", 0, NULL}, @@ -1534,7 +1536,7 @@ bool HLSLParser::ParseTopLevel(HLSLStatement*& statement) { // @@ Currently we support either a semantic or a register, but not both. if (AcceptIdentifier(declaration->semantic)) { - int k = 1; + // nothing } else if (!Expect(HLSLToken_Register) || !Expect('(') || !ExpectIdentifier(declaration->registerName) || !Expect(')')) { @@ -1913,20 +1915,20 @@ bool HLSLParser::ParseDeclaration(HLSLDeclaration*& declaration) } } - HLSLDeclaration * declaration = m_tree->AddNode(fileName, line); - declaration->type = type; - declaration->name = name; + HLSLDeclaration * declaration2 = m_tree->AddNode(fileName, line); + declaration2->type = type; + declaration2->name = name; - DeclareVariable( declaration->name, declaration->type ); + DeclareVariable( declaration2->name, declaration2->type ); // Handle option assignment of the declared variables(s). - if (!ParseDeclarationAssignment( declaration )) { + if (!ParseDeclarationAssignment( declaration2 )) { return false; } - if (firstDeclaration == NULL) firstDeclaration = declaration; - if (lastDeclaration != NULL) lastDeclaration->nextDeclaration = declaration; - lastDeclaration = declaration; + if (firstDeclaration == NULL) firstDeclaration = declaration2; + if (lastDeclaration != NULL) lastDeclaration->nextDeclaration = declaration2; + lastDeclaration = declaration2; } while(Accept(',')); @@ -2168,9 +2170,9 @@ bool HLSLParser::ParseBinaryExpression(int priority, HLSLExpression*& expression priority = 0; bool acceptBinaryOp = false; + HLSLBinaryOp binaryOp; while (1) { - HLSLBinaryOp binaryOp; if (acceptBinaryOp || AcceptBinaryOperator(priority, binaryOp)) { acceptBinaryOp = false; @@ -2507,11 +2509,11 @@ bool HLSLParser::ParseTerminalExpression(HLSLExpression*& expression, char& need done = true; // Post fix unary operator - HLSLUnaryOp unaryOp; - while (AcceptUnaryOperator(false, unaryOp)) + HLSLUnaryOp unaryOp2; + while (AcceptUnaryOperator(false, unaryOp2)) { HLSLUnaryExpression* unaryExpression = m_tree->AddNode(fileName, line); - unaryExpression->unaryOp = unaryOp; + unaryExpression->unaryOp = unaryOp2; unaryExpression->expression = expression; unaryExpression->expressionType = unaryExpression->expression->expressionType; expression = unaryExpression; @@ -3358,7 +3360,7 @@ bool HLSLParser::ParsePreprocessorDefine() // Macro with arguments if (Accept('(')) { - uint numArguments = 0; + unsigned int numArguments = 0; HLSLArgument* lastArgument = NULL; while (!Accept(')')) @@ -3998,8 +4000,8 @@ bool HLSLParser::AcceptType(bool allowVoid, HLSLType& type/*, bool acceptFlags*/ // Parse optional sampler type. if (Accept('<')) { - int token = m_tokenizer.GetToken(); - if (token == HLSLToken_Float || token == HLSLToken_Float1) + int token2 = m_tokenizer.GetToken(); + if (token2 == HLSLToken_Float || token2 == HLSLToken_Float1) { type.samplerType = HLSLBaseType_Float; } @@ -4244,7 +4246,6 @@ const HLSLFunction* HLSLParser::MatchFunctionCall(const HLSLFunctionCall* functi { const HLSLFunction* matchedFunction = NULL; - int numArguments = functionCall->numArguments; int numMatchedOverloads = 0; bool nameMatches = false; diff --git a/src/libprojectM/Renderer/hlslparser/src/HLSLParser.h b/src/libprojectM/Renderer/hlslparser/src/HLSLParser.h index 18adc87bb..6e7b3d802 100755 --- a/src/libprojectM/Renderer/hlslparser/src/HLSLParser.h +++ b/src/libprojectM/Renderer/hlslparser/src/HLSLParser.h @@ -143,7 +143,7 @@ private: HLSLTree* m_tree; bool m_allowUndeclaredIdentifiers = false; - bool m_disableSemanticValidation = false; + // not used bool m_disableSemanticValidation = false; }; } diff --git a/src/libprojectM/Renderer/hlslparser/src/HLSLTokenizer.cpp b/src/libprojectM/Renderer/hlslparser/src/HLSLTokenizer.cpp index fdecb9981..6580ac872 100755 --- a/src/libprojectM/Renderer/hlslparser/src/HLSLTokenizer.cpp +++ b/src/libprojectM/Renderer/hlslparser/src/HLSLTokenizer.cpp @@ -628,7 +628,7 @@ void HLSLTokenizer::Error(const char* format, ...) char buffer[1024]; va_list args; va_start(args, format); - int result = vsnprintf(buffer, sizeof(buffer) - 1, format, args); + vsnprintf(buffer, sizeof(buffer) - 1, format, args); va_end(args); Log_Error("%s(%d) : %s\n", m_fileName, m_lineNumber, buffer); diff --git a/src/libprojectM/Renderer/hlslparser/src/HLSLTree.cpp b/src/libprojectM/Renderer/hlslparser/src/HLSLTree.cpp index 9c8f98f21..2bb2fec8d 100755 --- a/src/libprojectM/Renderer/hlslparser/src/HLSLTree.cpp +++ b/src/libprojectM/Renderer/hlslparser/src/HLSLTree.cpp @@ -1168,7 +1168,7 @@ class MarkVisibleStatementsVisitor : public HLSLTreeVisitor { public: HLSLTree * tree; - MarkVisibleStatementsVisitor(HLSLTree * tree) : tree(tree) {} + MarkVisibleStatementsVisitor(HLSLTree * _tree) : tree(_tree) {} virtual void VisitFunction(HLSLFunction * node) { @@ -1581,10 +1581,10 @@ public: name = NULL; } - bool FindArgument(const char * name, HLSLFunction * function) + bool FindArgument(const char * _name, HLSLFunction * function) { this->found = false; - this->name = name; + this->name = _name; VisitStatements(function->statement); return found; } @@ -1929,9 +1929,7 @@ struct StatementList { declaration->name = m_tree->AddStringFormat("tmp%d", tmp_index++); declaration->type = expr->expressionType; declaration->assignment = expr; - - HLSLIdentifierExpression * ident = (HLSLIdentifierExpression *)expr; - + return declaration; } diff --git a/src/libprojectM/Renderer/hlslparser/src/HLSLTree.h b/src/libprojectM/Renderer/hlslparser/src/HLSLTree.h index 4400655af..dbd7121c2 100755 --- a/src/libprojectM/Renderer/hlslparser/src/HLSLTree.h +++ b/src/libprojectM/Renderer/hlslparser/src/HLSLTree.h @@ -586,7 +586,7 @@ struct HLSLMacro : public HLSLStatement } const char* name; HLSLArgument* argument; - int numArguments; + unsigned int numArguments; std::string value; HLSLMacro* macroAliased; }; diff --git a/src/libprojectM/libprojectM.pc.in b/src/libprojectM/libprojectM.pc.in index 84f6694e8..aaa5097d0 100644 --- a/src/libprojectM/libprojectM.pc.in +++ b/src/libprojectM/libprojectM.pc.in @@ -2,8 +2,8 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ -pkgdatadir=@datadir@/@PACKAGE_NAME@ -sysconfdir=@datadir@/@PACKAGE_NAME@ +pkgdatadir=@datarootdir@/@PACKAGE_NAME@ +sysconfdir=@datarootdir@/@PACKAGE_NAME@ Name: libprojectM Version: @PACKAGE_VERSION@ diff --git a/src/libprojectM/projectM.cpp b/src/libprojectM/projectM.cpp index c96452311..96e42a980 100755 --- a/src/libprojectM/projectM.cpp +++ b/src/libprojectM/projectM.cpp @@ -125,8 +125,8 @@ void projectM::projectM_resetTextures() projectM::projectM ( std::string config_file, int flags) : -beatDetect ( 0 ), renderer ( 0 ), _pcm(0), m_presetPos(0), m_flags(flags), _pipelineContext(new PipelineContext()), _pipelineContext2(new PipelineContext()), - timeKeeper(NULL), _matcher(NULL), _merger(NULL) +_pcm(0), beatDetect ( 0 ), renderer ( 0 ), _pipelineContext(new PipelineContext()), _pipelineContext2(new PipelineContext()), m_presetPos(0), + timeKeeper(NULL), m_flags(flags), _matcher(NULL), _merger(NULL) { readConfig(config_file); projectM_reset(); @@ -135,8 +135,8 @@ beatDetect ( 0 ), renderer ( 0 ), _pcm(0), m_presetPos(0), m_flags(flags), _pip } projectM::projectM(Settings settings, int flags): -beatDetect ( 0 ), renderer ( 0 ), _pcm(0), m_presetPos(0), m_flags(flags), _pipelineContext(new PipelineContext()), _pipelineContext2(new PipelineContext()), - timeKeeper(NULL), _matcher(NULL), _merger(NULL) +_pcm(0), beatDetect ( 0 ), renderer ( 0 ), _pipelineContext(new PipelineContext()), _pipelineContext2(new PipelineContext()), m_presetPos(0), + timeKeeper(NULL), m_flags(flags), _matcher(NULL), _merger(NULL) { readSettings(settings); projectM_reset(); @@ -428,7 +428,7 @@ static void *thread_callback(void *prjm) { if ( timeKeeper->IsSmoothing() && timeKeeper->SmoothRatio() > 1.0 ) { //printf("End Smooth\n"); - m_activePreset = m_activePreset2; + m_activePreset = std::move(m_activePreset2); timeKeeper->EndSmoothing(); } //printf("Normal\n"); @@ -795,7 +795,7 @@ void projectM::selectNext(const bool hardCut) { * @param targetPreset * @return a message indicating an error, empty otherwise. */ -std::string projectM::switchPreset(std::auto_ptr & targetPreset) { +std::string projectM::switchPreset(std::unique_ptr & targetPreset) { std::string result; diff --git a/src/libprojectM/projectM.hpp b/src/libprojectM/projectM.hpp index 014c45948..2f4924b44 100755 --- a/src/libprojectM/projectM.hpp +++ b/src/libprojectM/projectM.hpp @@ -326,10 +326,10 @@ private: PresetChooser * m_presetChooser; /// Currently loaded preset - std::auto_ptr m_activePreset; + std::unique_ptr m_activePreset; /// Destination preset when smooth preset switching - std::auto_ptr m_activePreset2; + std::unique_ptr m_activePreset2; TimeKeeper *timeKeeper; @@ -343,7 +343,7 @@ private: Pipeline* currentPipe; - std::string switchPreset(std::auto_ptr & targetPreset); + std::string switchPreset(std::unique_ptr & targetPreset); void switchPreset(const bool hardCut); diff --git a/src/projectM-sdl/Makefile.am b/src/projectM-sdl/Makefile.am index 90360a16c..fec2f43e6 100644 --- a/src/projectM-sdl/Makefile.am +++ b/src/projectM-sdl/Makefile.am @@ -9,5 +9,6 @@ ${SDL_CFLAGS} bin_PROGRAMS = projectMSDL projectMSDL_SOURCES = pmSDL.cpp projectM_SDL_main.cpp pmSDL.hpp projectMSDL_LDADD = ${SDL_LIBS} ../libprojectM/libprojectM.la +#projectMSDL_LDADD = -lasan ${SDL_LIBS} ../libprojectM/libprojectM.la projectMSDL_LDFLAGS = -static projectMSDL_PROGRAM = projectMSDL diff --git a/src/projectM-sdl/pmSDL.cpp b/src/projectM-sdl/pmSDL.cpp index 4e584d441..da31d34fd 100644 --- a/src/projectM-sdl/pmSDL.cpp +++ b/src/projectM-sdl/pmSDL.cpp @@ -30,12 +30,12 @@ void projectMSDL::audioInputCallbackS16(void *userdata, unsigned char *stream, i app->pcm()->addPCM16(pcm16); } -SDL_AudioDeviceID projectMSDL::selectAudioInput(int count) { +SDL_AudioDeviceID projectMSDL::selectAudioInput(int _count) { // ask the user which capture device to use // printf("Please select which audio input to use:\n"); printf("Detected devices:\n"); - for (int i = 0; i < count; i++) { - printf(" %i: 🎤%s\n", i, SDL_GetAudioDeviceName(i, true)); + for (int i = 0; i < _count; i++) { + printf(" %i: %s\n", i, SDL_GetAudioDeviceName(i, true)); } return 0; @@ -47,20 +47,20 @@ int projectMSDL::openAudioInput() { SDL_Log("Using audio driver: %s\n", driver_name); // get audio input device - int i, count = SDL_GetNumAudioDevices(true); // capture, please - if (count == 0) { + unsigned int i, count2 = SDL_GetNumAudioDevices(true); // capture, please + if (count2 == 0) { SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "No audio capture devices found"); SDL_Quit(); } - for (i = 0; i < count; i++) { + for (i = 0; i < count2; i++) { SDL_Log("Found audio capture device %d: %s", i, SDL_GetAudioDeviceName(i, true)); } SDL_AudioDeviceID selectedAudioDevice = 0; // device to open - if (count > 1) { + if (count2 > 1) { // need to choose which input device to use - selectedAudioDevice = selectAudioInput(count); - if (selectedAudioDevice > count) { + selectedAudioDevice = selectAudioInput(count2); + if (selectedAudioDevice > count2) { SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "No audio input device specified."); SDL_Quit(); } @@ -98,7 +98,6 @@ int projectMSDL::openAudioInput() { void projectMSDL::beginAudioCapture() { // allocate a buffer to store PCM data for feeding in - unsigned int maxSamples = audioChannelsCount * audioSampleCount; SDL_PauseAudioDevice(audioDeviceID, false); } diff --git a/src/projectM-sdl/pmSDL.hpp b/src/projectM-sdl/pmSDL.hpp index 9ac3166ad..b2d8e748a 100644 --- a/src/projectM-sdl/pmSDL.hpp +++ b/src/projectM-sdl/pmSDL.hpp @@ -68,7 +68,7 @@ private: static void audioInputCallbackS16(void *userdata, unsigned char *stream, int len); void keyHandler(SDL_Event *); - SDL_AudioDeviceID selectAudioInput(int count); + SDL_AudioDeviceID selectAudioInput(int _count); void renderTexture(); }; diff --git a/src/projectM-sdl/projectM_SDL_main.cpp b/src/projectM-sdl/projectM_SDL_main.cpp index f56061871..a7bb30cdf 100644 --- a/src/projectM-sdl/projectM_SDL_main.cpp +++ b/src/projectM-sdl/projectM_SDL_main.cpp @@ -76,18 +76,8 @@ int main(int argc, char *argv[]) { #endif int width = initialWindowBounds.w; int height = initialWindowBounds.h; - int renderIndex = 0; #ifdef USE_GLES - for(int i = 0; i < SDL_GetNumRenderDrivers(); i++) { - SDL_RendererInfo info; - if (SDL_GetRenderDriverInfo(i, &info) == 0) { - if (std::string(info.name) == "opengles2") { - renderIndex = i; - break; - } - } - } // use GLES 2.0 (this may need adjusting) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); @@ -160,7 +150,7 @@ int main(int argc, char *argv[]) { #if TEST_ALL_PRESETS uint buildErrors = 0; - for(int i = 0; i < app->getPlaylistSize(); i++) { + for(unsigned int i = 0; i < app->getPlaylistSize(); i++) { std::cout << i << "\t" << app->getPresetName(i) << std::endl; app->selectPreset(i); if (app->getErrorLoadingCurrentPreset()) {