MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / CopyDataToBuffer

Method CopyDataToBuffer

lib/mdflib/mdflib/src/dz4block.cpp:115–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115uint64_t Dz4Block::CopyDataToBuffer(std::streambuf& from_file,
116 std::vector<uint8_t> &dest,
117 uint64_t &buffer_index) const {
118 if (data_position_ == 0 || orig_data_length_ == 0 || data_length_ == 0) {
119 return 0;
120 }
121
122 SetFilePosition(from_file, data_position_);
123
124 uint64_t count = 0;
125 switch (static_cast<Dz4ZipType>(type_)) {
126 case Dz4ZipType::Deflate: {
127 ByteArray temp(static_cast<size_t>(data_length_), 0);
128 from_file.sgetn( reinterpret_cast<char*>(temp.data()),
129 static_cast<std::streamsize>(temp.size()) );
130 ByteArray out(static_cast<size_t>(orig_data_length_), 0);
131 Inflate(temp, out);
132 count = orig_data_length_;
133 memcpy(dest.data() + buffer_index, out.data(), static_cast<size_t>(count) );
134 buffer_index += count;
135 break;
136 }
137
138 case Dz4ZipType::TransposeAndDeflate: {
139 ByteArray temp(static_cast<size_t>(data_length_), 0);
140 from_file.sgetn(reinterpret_cast<char*>(temp.data()),
141 static_cast<std::streamsize>(temp.size()) );
142 ByteArray out(static_cast<size_t>( orig_data_length_ ), 0);
143 Inflate(temp, out);
144 InvTranspose(out, parameter_);
145
146 count = orig_data_length_;
147 memcpy(dest.data() + buffer_index, out.data(), static_cast<size_t>(count) );
148 buffer_index += count;
149 break;
150 }
151
152 default:
153 break;
154 }
155 return count;
156}
157
158bool Dz4Block::Data(const std::vector<uint8_t> &uncompressed_data) {
159 bool compress = true;

Callers 4

GetNextByteMethod · 0.45
CopyDataToBufferFunction · 0.45
ReadSignalDataMethod · 0.45
ReadDataMethod · 0.45

Calls 5

SetFilePositionFunction · 0.85
InflateFunction · 0.85
InvTransposeFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected