@@ -1124,7 +1124,7 @@ class BinarySaver : public ion::BuildingBlock<BinarySaver<T, D>> {
11241124 BuildingBlockParam<std::string> output_directory_ptr{ " output_directory" , " ." };
11251125 BuildingBlockParam<std::string> prefix_ptr{" prefix" , " raw-" };
11261126
1127- Input<Halide::Func> input_images {" input" , Halide::type_of<T>(), D};
1127+ Input<Halide::Func> input_image {" input" , Halide::type_of<T>(), D};
11281128 Input<Halide::Func> input_deviceinfo{ " input_deviceinfo" , Halide::type_of<uint8_t >(), 1 };
11291129 Input<Halide::Func> frame_count{ " frame_count" , Halide::type_of<uint32_t >(), 1 };
11301130 Input<int32_t > width{ " width" };
@@ -1155,7 +1155,7 @@ class BinarySaver : public ion::BuildingBlock<BinarySaver<T, D>> {
11551155 Buffer<uint8_t > id_buf = this ->get_id ();
11561156
11571157 Func image;
1158- image (_) = input_images (_);
1158+ image (_) = input_image (_);
11591159 image.compute_root ();
11601160
11611161 Func deviceinfo;
@@ -1223,47 +1223,68 @@ class BinaryGenDCSaver : public ion::BuildingBlock<BinaryGenDCSaver> {
12231223 }
12241224};
12251225
1226- class BinaryLoader : public ion ::BuildingBlock<BinaryLoader> {
1226+ template <typename T>
1227+ class BinaryLoader : public ion ::BuildingBlock<BinaryLoader<T>> {
12271228public:
1228- BuildingBlockParam<std::string> output_directory_ptr{ " output_directory_ptr" , " " };
1229- Input<int32_t > width{ " width" , 0 };
1230- Input<int32_t > height{ " height" , 0 };
1231- Output<Halide::Func> output0{ " output0" , UInt (16 ), 2 };
1232- Output<Halide::Func> output1{ " output1" , UInt (16 ), 2 };
1233- Output<Halide::Func> finished{ " finished" , UInt (1 ), 1 };
1234- Output<Halide::Func> bin_idx{ " bin_idx" , UInt (32 ), 1 };
1229+ BuildingBlockParam<std::string> output_directory_ptr{" output_directory" , " " };
1230+ BuildingBlockParam<std::string> prefix_ptr{" prefix" , " raw-" };
1231+ Input<int32_t >width{" width" };
1232+ Input<int32_t > height{" height" };
1233+ Output<Halide::Func> output{" output" , type_of<T>(), 2 };
1234+ Output<Halide::Func> finished{" finished" , Halide::UInt (1 ), 1 };
1235+ Output<Halide::Func> bin_idx{" bin_idx" , Halide::UInt (32 ), 1 };
1236+ Output<Halide::Func> frame_count{" frame_count" , Halide::UInt (32 ), 1 };
12351237
12361238 void generate () {
12371239 using namespace Halide ;
1240+ Func binaryloader;
12381241
1239- std::string session_id = sole::uuid4 ().str ();
1240- Buffer<uint8_t > session_id_buf (static_cast <int >(session_id.size () + 1 ));
1241- session_id_buf.fill (0 );
1242- std::memcpy (session_id_buf.data (), session_id.c_str (), session_id.size ());
1242+ {
1243+ Buffer<uint8_t > id_buf = this ->get_id ();
1244+ const std::string output_directory (output_directory_ptr);
1245+ Halide::Buffer<uint8_t > output_directory_buf (static_cast <int >(output_directory.size () + 1 ));
1246+ output_directory_buf.fill (0 );
1247+ std::memcpy (output_directory_buf.data (), output_directory.c_str (), output_directory.size ());
12431248
1244- const std::string output_directory (output_directory_ptr );
1245- Halide::Buffer<uint8_t > output_directory_buf (static_cast <int >(output_directory .size () + 1 ));
1246- output_directory_buf .fill (0 );
1247- std::memcpy (output_directory_buf .data (), output_directory .c_str (), output_directory .size ());
1249+ const std::string prefix (prefix_ptr );
1250+ Halide::Buffer<uint8_t > prefix_buf (static_cast <int >(prefix .size () + 1 ));
1251+ prefix_buf .fill (0 );
1252+ std::memcpy (prefix_buf .data (), prefix .c_str (), prefix .size ());
12481253
1249- std::vector<ExternFuncArgument> params = { session_id_buf, width, height, output_directory_buf };
1250- Func binaryloader;
1251- binaryloader.define_extern (" binaryloader" , params, { UInt (16 ), UInt (16 ) }, 2 );
1252- binaryloader.compute_root ();
1253- output0 (_) = binaryloader (_)[0 ];
1254- output1 (_) = binaryloader (_)[1 ];
1254+ std::vector<ExternFuncArgument> params = {id_buf, width, height, output_directory_buf ,prefix_buf};
12551255
1256+ binaryloader.define_extern (" binaryloader" , params, type_of<T>(), 2 );
1257+ binaryloader.compute_root ();
1258+ output (_) = binaryloader (_);
1259+ }
12561260
12571261 Func binaryloader_finished;
1258- binaryloader_finished.define_extern (" binaryloader_finished" ,
1259- { binaryloader, session_id_buf, width, height, output_directory_buf },
1260- { type_of<bool >(), UInt (32 )}, 1 );
1261- binaryloader_finished.compute_root ();
1262- finished (_) = binaryloader_finished (_)[0 ];
1263- bin_idx (_) = binaryloader_finished (_)[1 ];
1262+ {
1263+ Buffer<uint8_t > id_buf = this ->get_id ();
1264+ const std::string prefix (prefix_ptr);
1265+ Halide::Buffer<uint8_t > prefix_buf (static_cast <int >(prefix.size () + 1 ));
1266+ prefix_buf.fill (0 );
1267+ std::memcpy (prefix_buf.data (), prefix.c_str (), prefix.size ());
1268+
1269+ const std::string output_directory (output_directory_ptr);
1270+ Halide::Buffer<uint8_t > output_directory_buf (static_cast <int >(output_directory.size () + 1 ));
1271+ output_directory_buf.fill (0 );
1272+ std::memcpy (output_directory_buf.data (), output_directory.c_str (), output_directory.size ());
1273+ binaryloader_finished.define_extern (" binaryloader_finished" ,
1274+ {binaryloader, id_buf, width, height, output_directory_buf, prefix_buf},
1275+ {UInt (1 ), UInt (32 ),UInt (32 )}, 1 );
1276+ binaryloader_finished.compute_root ();
1277+ finished (_) = binaryloader_finished (_)[0 ];
1278+ bin_idx (_) = binaryloader_finished (_)[1 ];
1279+ frame_count (_) = binaryloader_finished (_)[2 ];
1280+ }
1281+ this ->register_disposer (" reader_dispose" );
12641282 }
12651283};
12661284
1285+ using BinaryLoader_U8x2 = BinaryLoader<uint8_t >;
1286+ using BinaryLoader_U16x2 = BinaryLoader<uint16_t >;
1287+
12671288} // namespace image_io
12681289} // namespace bb
12691290} // namespace ion
@@ -1306,7 +1327,9 @@ ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::BinarySaver_U8x3, image_io_binary
13061327ION_REGISTER_BUILDING_BLOCK (ion::bb::image_io::BinarySaver_U8x2, image_io_binarysaver_u8x2);
13071328ION_REGISTER_BUILDING_BLOCK (ion::bb::image_io::BinarySaver_U16x2, image_io_binarysaver_u16x2);
13081329
1309- ION_REGISTER_BUILDING_BLOCK (ion::bb::image_io::BinaryLoader, image_io_binaryloader);
1330+ ION_REGISTER_BUILDING_BLOCK (ion::bb::image_io::BinaryLoader_U16x2, image_io_binaryloader);
1331+ ION_REGISTER_BUILDING_BLOCK (ion::bb::image_io::BinaryLoader_U8x2, image_io_binaryloader_u8x2);
1332+ ION_REGISTER_BUILDING_BLOCK (ion::bb::image_io::BinaryLoader_U16x2, image_io_binaryloader_u16x2);
13101333
13111334ION_REGISTER_BUILDING_BLOCK (ion::bb::image_io::BinaryGenDCSaver, image_io_binary_gendc_saver);
13121335
0 commit comments