Skip to content

Commit

Permalink
Remove VLA from d90stairsteppingfix
Browse files Browse the repository at this point in the history
  • Loading branch information
jddurand authored and jaromil committed Dec 28, 2022
1 parent a4f417d commit 0e9ba7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/filter/d90stairsteppingfix/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
if(MSVC AND NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)
return() # MSVC cl doesn't support Variable Length Arrays (VLA), but clang-cl does
endif()

set (SOURCES d90stairsteppingfix.cpp)
set (TARGET d90stairsteppingfix)

Expand Down
7 changes: 5 additions & 2 deletions src/filter/d90stairsteppingfix/d90stairsteppingfix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class D90StairsteppingFix : public frei0r::filter
* and therefore get the number (line1+line2)/2, here 6.5.
* This positions will later be used for interpolation.
*/
float filled[newHeight];
float *filled = (float *) malloc(newHeight * sizeof(float));

int count = 0;
int index = 0;
Expand All @@ -160,7 +160,7 @@ class D90StairsteppingFix : public frei0r::filter
* Calculate scaling numbers to scale the full height matrix
* with the slice lines down to the original height (720p).
*/
float downScaling[height];
float *downScaling = (float *) malloc(height * sizeof(float));

float scaleFactor = (float) newHeight/height;
// printf("scale factor: %f\n", scaleFactor);
Expand All @@ -184,6 +184,9 @@ class D90StairsteppingFix : public frei0r::filter
m_mesh[i] = (1-offset)*filled[index] + offset*filled[index+1];
// printf("%f at %d with weights %f and %f\n", m_mesh[i], i, (1-offset)*downScaling[i], offset*downScaling[i+1]);
}

free(downScaling);
free(filled);

} else {
// Not a 720p file.
Expand Down

0 comments on commit 0e9ba7a

Please sign in to comment.