Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/image.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Collobert <ronan@collobert.com>2015-10-16 22:11:14 +0300
committerRonan Collobert <ronan@collobert.com>2015-10-16 22:11:14 +0300
commit13a5af643c2c686a1cc6f8c89e7094bfa4c7a62d (patch)
treed872ef918c2a0eeec3b3b678d1134de7e38b7fdc
parenta708cd156dc6105d60a7b8c508a510d3e4e3d137 (diff)
fix a bunch of warnings when compiling with -Wallfixwarnings
-rw-r--r--CMakeLists.txt29
-rwxr-xr-xgeneric/image.c15
2 files changed, 34 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 007a949..80abb16 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,35 @@ FIND_PACKAGE(Torch REQUIRED)
FIND_PACKAGE(JPEG QUIET)
FIND_PACKAGE(PNG QUIET)
+# OpenMP support?
+SET(WITH_OPENMP ON CACHE BOOL "OpenMP support if available?")
+IF (APPLE AND CMAKE_COMPILER_IS_GNUCC)
+ EXEC_PROGRAM (uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
+ STRING (REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
+ MESSAGE (STATUS "MAC OS Darwin Version: ${DARWIN_VERSION}")
+ IF (DARWIN_VERSION GREATER 9)
+ SET(APPLE_OPENMP_SUCKS 1)
+ ENDIF (DARWIN_VERSION GREATER 9)
+ EXECUTE_PROCESS (COMMAND ${CMAKE_C_COMPILER} -dumpversion
+ OUTPUT_VARIABLE GCC_VERSION)
+ IF (APPLE_OPENMP_SUCKS AND GCC_VERSION VERSION_LESS 4.6.2)
+ MESSAGE(STATUS "Warning: Disabling OpenMP (unstable with this version of GCC)")
+ MESSAGE(STATUS " Install GCC >= 4.6.2 or change your OS to enable OpenMP")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas")
+ SET(WITH_OPENMP OFF CACHE BOOL "OpenMP support if available?" FORCE)
+ ENDIF ()
+ENDIF ()
+
+IF (WITH_OPENMP)
+ FIND_PACKAGE(OpenMP)
+ IF(OPENMP_FOUND)
+ MESSAGE(STATUS "Compiling with OpenMP support")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
+ ENDIF(OPENMP_FOUND)
+ENDIF (WITH_OPENMP)
+
SET(src ppm.c)
ADD_TORCH_PACKAGE(ppm "${src}" "${luasrc}" "Image Processing")
TARGET_LINK_LIBRARIES(ppm luaT TH)
diff --git a/generic/image.c b/generic/image.c
index 51d256c..89ba31f 100755
--- a/generic/image.c
+++ b/generic/image.c
@@ -1478,8 +1478,6 @@ int image_(Main_vflip)(lua_State *L) {
int width = dst->size[2];
int height = dst->size[1];
- int src_width = src->size[2];
- int src_height = src->size[1];
int channels = dst->size[0];
long *is = src->stride;
long *os = dst->stride;
@@ -1527,8 +1525,6 @@ int image_(Main_hflip)(lua_State *L) {
int width = dst->size[2];
int height = dst->size[1];
- int src_width = src->size[2];
- int src_height = src->size[1];
int channels = dst->size[0];
long *is = src->stride;
long *os = dst->stride;
@@ -1574,11 +1570,11 @@ int image_(Main_flip)(lua_State *L) {
THTensor *src = luaT_checkudata(L, 2, torch_Tensor);
long flip_dim = luaL_checklong(L, 3);
- if (dst->nDimension != src->nDimension) {
- luaL_error(L, "image.flip: src and dst nDimension does not match");
+ if ((dst->nDimension != 5) || (src->nDimension != 5)) {
+ luaL_error(L, "image.flip: expected 5 dimensions for src and dst");
}
- if (flip_dim < 1 || flip_dim > dst->nDimension) {
+ if (flip_dim < 1 || flip_dim > dst->nDimension || flip_dim > 5) {
luaL_error(L, "image.flip: flip_dim out of bounds");
}
flip_dim--; // Make it zero indexed
@@ -1595,7 +1591,6 @@ int image_(Main_flip)(lua_State *L) {
long size2 = dst->size[2];
long size3 = dst->size[3];
long size4 = dst->size[4];
- long size_flip = dst->size[flip_dim];
if (src->size[0] != size0 || src->size[1] != size1 ||
src->size[2] != size2 || src->size[3] != size3 ||
@@ -1606,7 +1601,7 @@ int image_(Main_flip)(lua_State *L) {
long *is = src->stride;
long *os = dst->stride;
- long x, y, z, d, t, isrc, idst;
+ long x, y, z, d, t, isrc, idst = 0;
for (t = 0; t < size0; t++) {
for (d = 0; d < size1; d++) {
for (z = 0; z < size2; z++) {
@@ -1714,7 +1709,7 @@ int image_(Main_warp)(lua_State *L) {
real *flow_data = THTensor_(data)(flowfield);
// resample
- long k,x,y,jj,v,u,i,j;
+ long k,x,y,v,u,i,j;
for (y=0; y<height; y++) {
for (x=0; x<width; x++) {
// subpixel position: