diff --git a/core-buffer/include/FastH5Writer.hpp b/core-buffer/include/FastH5Writer.hpp index 7b572fb..6db76f2 100644 --- a/core-buffer/include/FastH5Writer.hpp +++ b/core-buffer/include/FastH5Writer.hpp @@ -1,15 +1,28 @@ #ifndef FASTH5WRITER_HPP #define FASTH5WRITER_HPP +#include #include template class FastH5Writer { + + const uint16_t CHUNKING_FACTOR = 1; + + const size_t n_frames_per_file_; + const uint16_t y_frame_size_; + const uint16_t x_frame_size_; + + std::string current_output_file_; + H5::DataSet current_image_dataset_; + + void create_image_dataset(); + public: FastH5Writer( - const uint16_t n_frames_per_file, - const std::vector& frame_size - ); + const size_t n_frames_per_file, + const uint16_t y_frame_size, + const uint16_t x_frame_size); template void add_metadata(const std::string& metadata_name); diff --git a/core-buffer/src/FastH5Writer.cpp b/core-buffer/src/FastH5Writer.cpp new file mode 100644 index 0000000..0ffe01a --- /dev/null +++ b/core-buffer/src/FastH5Writer.cpp @@ -0,0 +1,43 @@ +#include "FastH5Writer.hpp" +#include + +template<> +FastH5Writer::FastH5Writer( + const size_t n_frames_per_file, + const uint16_t y_frame_size, + const uint16_t x_frame_size) : + n_frames_per_file_(n_frames_per_file), + y_frame_size_(y_frame_size), + x_frame_size_(y_frame_size) +{ +// // Each element in uint16_t has 2 bytes. +// size_t n_bytes = 2 * y_frame_size * x_frame_size; + auto file = H5::H5File(target_filename.c_str(), H5F_ACC_TRUNC); + + + + + create_dataset("image", frame_size, n_frames_per_file, "uint16"); +} + +template +void FastH5Writer::create_image_dataset() +{ + hsize_t dataset_dimension[3] = + {n_frames_per_file_, y_frame_size_, x_frame_size_}; + hsize_t max_dataset_dimension[3] = + {n_frames_per_file_, y_frame_size_, x_frame_size_}; + H5::DataSpace dataspace( + 3, dataset_dimension, max_dataset_dimension); + + hsize_t dataset_chunking[3] = + {CHUNKING_FACTOR, y_frame_size_, x_frame_size_}; + H5::DSetCreatPropList dataset_properties; + dataset_properties.setChunk(3, dataset_chunking); + + H5::AtomType dataset_data_type(H5::PredType::NATIVE_UINT16); + dataset_data_type.setOrder(H5T_ORDER_LE); + + current_image_dataset_ = current_output_file_.createDataSet( + "image", dataset_data_type, dataspace, dataset_properties); +} \ No newline at end of file