diff --git a/CMakeLists.txt b/CMakeLists.txt index 616e314c..99cf4f05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,10 +37,6 @@ if (WITH_CUDA) find_package(CUDA REQUIRED) endif() - - - - # # Version # @@ -77,23 +73,11 @@ else() target_link_libraries(ion-core PUBLIC Halide::Halide Halide::Runtime) endif() - -# -# SSL support to download image from url -# -if(OPENSSL_FOUND) - if (UNIX) - target_link_libraries(ion-core PUBLIC ssl crypto) - target_compile_definitions(ion-core PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT) - endif() -endif() - # # ion-bb # add_subdirectory(src/bb) - # # Test # @@ -208,5 +192,4 @@ else () set(CPACK_GENERATOR "ZIP") endif () set(CPACK_PACKAGE_VERSION ${ION_KIT_VERSION}) -include(CPack) - +include(CPack) \ No newline at end of file diff --git a/src/bb/base/rt.h b/src/bb/base/rt.h index 3dc8bf50..a057f3b3 100644 --- a/src/bb/base/rt.h +++ b/src/bb/base/rt.h @@ -41,20 +41,14 @@ namespace bb { namespace base { std::tuple parse_url(const std::string &url) { - - const std::string https_prefix = "https://"; - const std::string http_prefix = "http://"; - - auto prefix_length = url.rfind( https_prefix, 0) == 0 ? https_prefix.size() : - url.rfind( http_prefix, 0) == 0 ? http_prefix.size() : -1; - - if (prefix_length == -1){ + auto protocol_end_pos = url.find("://"); + if (protocol_end_pos == std::string::npos) { return std::tuple("", ""); } - auto path_name_pos = url.find("/", prefix_length); - auto host_name = url.substr(prefix_length, path_name_pos-prefix_length); + auto host_name_pos = protocol_end_pos + 3; + auto path_name_pos = url.find("/", host_name_pos); + auto host_name = url.substr(0, path_name_pos); auto path_name = url.substr(path_name_pos); - return std::tuple(host_name, path_name); } @@ -139,12 +133,8 @@ extern "C" ION_EXPORT int ion_bb_base_buffer_loader(halide_buffer_t *url_buf, in } } } else { -#ifdef CPPHTTPLIB_OPENSSL_SUPPORT - httplib::SSLClient cli(host_name.c_str()); -#else - httplib::Client cli(host_name.c_str()); -#endif + httplib::Client cli(host_name.c_str()); cli.set_follow_location(true); auto res = cli.Get(path_name.c_str()); if (res && res->status == 200 && res->body.size() == size) { diff --git a/src/bb/image-io/rt_common.h b/src/bb/image-io/rt_common.h index f30fba3a..664a61e4 100644 --- a/src/bb/image-io/rt_common.h +++ b/src/bb/image-io/rt_common.h @@ -140,21 +140,14 @@ namespace ion { }; std::tuple parse_url(const std::string &url) { - - const std::string https_prefix = "https://"; - const std::string http_prefix = "http://"; - - auto prefix_length = url.rfind( https_prefix, 0) == 0 ? https_prefix.size() : - url.rfind( http_prefix, 0) == 0 ? http_prefix.size() : -1; - - if (prefix_length == -1){ + auto protocol_end_pos = url.find("://"); + if (protocol_end_pos == std::string::npos) { return std::tuple("", ""); } - - auto path_name_pos = url.find("/", prefix_length); - auto host_name = url.substr(prefix_length, path_name_pos-prefix_length); + auto host_name_pos = protocol_end_pos + 3; + auto path_name_pos = url.find("/", host_name_pos); + auto host_name = url.substr(0, path_name_pos); auto path_name = url.substr(path_name_pos); - return std::tuple(host_name, path_name); } @@ -176,13 +169,8 @@ namespace ion { img_loaded = true; } } else { -//for https url, httplib::Client throw exception (what(): 'https' scheme is not supported.). need SSL support instead -#ifdef CPPHTTPLIB_OPENSSL_SUPPORT - httplib::SSLClient cli(host_name.c_str()); -#else - httplib::Client cli(host_name.c_str()); -#endif - +// Without CPPHTTPLIB_OPENSSL_SUPPORT pre-defined, httplib::Client throw exception (what(): 'https' scheme is not supported.). + httplib::Client cli(host_name.c_str()); cli.set_follow_location(true); auto res = cli.Get(path_name.c_str()); @@ -220,13 +208,7 @@ namespace ion { std::ifstream ifs(url, std::ios::binary); ifs.read(reinterpret_cast(data.data()), data.size()); } else { - -#ifdef CPPHTTPLIB_OPENSSL_SUPPORT - httplib::SSLClient cli(host_name.c_str()); -#else httplib::Client cli(host_name.c_str()); -#endif - cli.set_follow_location(true); auto res = cli.Get(path_name.c_str()); if (res && res->status == 200) { diff --git a/src/builder.cc b/src/builder.cc index d55d297e..6a3d2e15 100644 --- a/src/builder.cc +++ b/src/builder.cc @@ -315,6 +315,9 @@ Halide::Pipeline Builder::build(const ion::PortMap& pm, std::vectorbuild_input(j,f)); else{ // access to Port[index] + if (index>=fs.size()){ + throw std::runtime_error("Port index out of range: " + in->name()); + } args.push_back(bb->build_input(j, fs[index])); } @@ -348,20 +351,6 @@ Halide::Pipeline Builder::build(const ion::PortMap& pm, std::vectorpush_back(kv.second[i]); } -// if (index!=-1){ -// auto fs = bbs[node_id]->get_outputs(port_key); -// output_funcs.push_back(fs[index]); -// outputs->push_back(kv.second[0]); -// }else{ -// auto fs = bbs[node_id]->get_outputs(port_key); -// if (fs.size() != kv.second.size()) { -// throw std::runtime_error("Invalid size of array : " + node_id + ", " + port_key); -// } -// for (size_t i=0; ipush_back(kv.second[i]); -// } -// } } else { auto f = bbs[node_id]->get_outputs(port_key).front(); if (1 != kv.second.size()) { diff --git a/test/port-access.cc b/test/port-access.cc index f5e1e1e6..18b979f4 100644 --- a/test/port-access.cc +++ b/test/port-access.cc @@ -26,9 +26,8 @@ void display_image_float(Halide::Buffer buffer, std::string filename) { cv::Mat img_float(height, width, CV_32F, buffer.data()); img_float.convertTo(img_out, CV_8U, 255); } - -// cv::imshow( "Display window: " + filename, img_out); - cv::imwrite("./saved.png", img_out); + cv::imshow( "Display window: " + filename, img_out); +// cv::imwrite("./saved.png", img_out); }