summarylogtreecommitdiffstats
path: root/fixes.patch
blob: fd0b93c3417a9f17f88136fbccbf92576f5c55ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e4be369..6c57cfa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,9 +8,9 @@ include("macro.cmake")
 set(CMAKE_CXX_STANDARD 11)
 
 # Define dependencies
-link_halide()
 link_libtiff()
 
+find_package(Halide REQUIRED)
 find_package(ZLIB REQUIRED)
 find_package(PNG REQUIRED)
 find_package(JPEG REQUIRED)
@@ -27,36 +27,28 @@ set(header_files
     src/dngwriter.h
     src/LibRaw2DngConverter.h)
 
-include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${HALIDE_DISTRIB_DIR}/include ${HALIDE_DISTRIB_DIR}/tools ${RAW2DNG_INCLUDE_DIRS})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${RAW2DNG_INCLUDE_DIRS})
 include_directories(${CMAKE_BINARY_DIR}/genfiles)
 
 set(HALIDE_TARGET "")
 set(HALIDE_TARGET_FEATURES "")
-halide_library(hdrplus_pipeline
-    SRCS src/hdrplus_pipeline_generator.cpp src/align.cpp src/merge.cpp src/finish.cpp src/util.cpp
-    # GENERATOR_DEPS  # We don't have any yet
-    GENERATOR_NAME hdrplus_pipeline
-    # GENERATOR_ARGS  # We don't have any yet
-    FUNCTION_NAME hdrplus_pipeline
-    # HALIDE_TARGET ${HALIDE_TARGET}  # TODO: add option with custom HALIDE_TARGET
-    # HALIDE_TARGET_FEATURES ${HALIDE_TARGET_FEATURES}  # TODO: add option with custom HALIDE_TARGET
-    # EXTRA_OUTPUTS "stmt;html;schedule") # uncomment for extra output
+add_executable(hdrplus_pipeline_generator
+    src/hdrplus_pipeline_generator.cpp src/align.cpp src/merge.cpp src/finish.cpp src/util.cpp
 )
+target_link_libraries(hdrplus_pipeline_generator Halide::Generator)
+add_halide_library(hdrplus_pipeline FROM hdrplus_pipeline_generator)
 
-halide_library(align_and_merge
-    SRCS src/align_and_merge_generator.cpp src/align.cpp src/merge.cpp src/util.cpp
-    GENERATOR_NAME align_and_merge
-    FUNCTION_NAME align_and_merge
-    # HALIDE_TARGET ${HALIDE_TARGET}  # TODO: add option with custom HALIDE_TARGET
-    # HALIDE_TARGET_FEATURES ${HALIDE_TARGET_FEATURES}  # TODO: add option with custom HALIDE_TARGET
-    # EXTRA_OUTPUTS "stmt;html;schedule") # uncomment for extra output
+add_executable(align_and_merge_generator
+    src/align_and_merge_generator.cpp src/align.cpp src/merge.cpp src/util.cpp
 )
+target_link_libraries(align_and_merge_generator Halide::Generator)
+add_halide_library(align_and_merge FROM align_and_merge_generator)
 
 
 add_executable(hdrplus bin/HDRPlus.cpp ${src_files})
 add_dependencies(hdrplus hdrplus_pipeline)
-target_link_libraries(hdrplus hdrplus_pipeline Halide png ${LIBRAW_LIBRARY} ${TIFF_LIBRARIES} ${TIFFXX_LIBRARY})
+target_link_libraries(hdrplus hdrplus_pipeline Halide::Halide png ${LIBRAW_LIBRARY} ${TIFF_LIBRARIES} ${TIFFXX_LIBRARY})
 
 add_executable(stack_frames bin/stack_frames.cpp ${src_files})
 add_dependencies(stack_frames align_and_merge)
-target_link_libraries(stack_frames Halide align_and_merge ${LIBRAW_LIBRARY} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${TIFFXX_LIBRARY})
+target_link_libraries(stack_frames Halide::Halide align_and_merge ${LIBRAW_LIBRARY} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${TIFFXX_LIBRARY})
diff --git a/bin/HDRPlus.cpp b/bin/HDRPlus.cpp
index f2b8683..2a5be35 100644
--- a/bin/HDRPlus.cpp
+++ b/bin/HDRPlus.cpp
@@ -8,7 +8,7 @@
 #include <include/stb_image_write.h>
 
 #include <src/Burst.h>
-#include <hdrplus_pipeline/hdrplus_pipeline.h>
+#include "hdrplus_pipeline.h"
 
 /*
  * HDRPlus Class -- Houses file I/O, defines pipeline attributes and calls
diff --git a/bin/stack_frames.cpp b/bin/stack_frames.cpp
index 666c56f..b9d570e 100644
--- a/bin/stack_frames.cpp
+++ b/bin/stack_frames.cpp
@@ -7,7 +7,7 @@
 
 #include <src/Burst.h>
 
-#include <align_and_merge/align_and_merge.h>
+#include "align_and_merge.h"
 
 Halide::Runtime::Buffer<uint16_t> align_and_merge(Halide::Runtime::Buffer<uint16_t> burst) {
     if (burst.channels() < 2) {
diff --git a/macro.cmake b/macro.cmake
index 0c5c2bb..ece5e2e 100644
--- a/macro.cmake
+++ b/macro.cmake
@@ -1,16 +1,5 @@
 cmake_minimum_required(VERSION 3.10)
 
-macro(link_halide)
-    if("${HALIDE_DISTRIB_DIR}" STREQUAL " ")
-        message(FATAL_ERROR "Specify HALIDE_DISTRIB_DIR variable in the cmake options.")
-    endif()
-    find_package(Threads) # fix dynamic linking for halide
-    set(HALIDE_DISTRIB_USE_STATIC_LIBRARY OFF)
-    include(${HALIDE_DISTRIB_DIR}/halide.cmake)
-    include_directories(${HALIDE_DISTRIB_DIR}/include ${HALIDE_DISTRIB_DIR}/tools)
-    link_directories(${HALIDE_DISTRIB_DIR}/lib ${HALIDE_DISTRIB_DIR}/bin)
-endmacro()
-
 macro(link_libtiff)
     # Link as follows:
     # target_link_libraries(TARGET ${TIFF_LIBRARIES})
diff --git a/src/util.cpp b/src/util.cpp
index 9c984f0..a31f1bc 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -3,6 +3,7 @@
 #include "Halide.h"
 #include <vector>
 #include <algorithm>
+#include <sstream>
 
 using namespace Halide;
 using namespace Halide::ConciseCasts;
@@ -37,7 +38,7 @@ Func box_down2(Func input, std::string name) {
 Func gauss_down4(Func input, std::string name) {
 
     Func output(name);
-    Buffer<uint32_t> k(5, 5, "gauss_down4_kernel");
+    Buffer<uint32_t> k(5, 5, "gauss_down4_kernel_" + name);
     k.translate({-2, -2});
 
     Var x, y, n;
@@ -115,7 +116,10 @@ Func gauss_7x7(Func input, std::string name) {
 
     // gaussian kernel
 
-    Buffer<float> k(7, "gauss_7x7_kernel");
+    static int i = 0;
+    std::ostringstream buffer_name;
+    buffer_name << "gauss_7x7_kernel_" << name << ++i;
+    Buffer<float> k(7, buffer_name.str());
     k.translate({-3});
 
     Var x;