MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / decompress_zlib

Function decompress_zlib

src/gpu/cl/ClKernelLibrary.cpp:126–161  ·  view source on GitHub ↗

Decompress a zlib compressed string * * @param[in] str ZLib compressed string * * @return The decompressed string if successful, otherwise false. */

Source from the content-addressed store, hash-verified

124 * @return The decompressed string if successful, otherwise false.
125 */
126std::string decompress_zlib(const std::string &str)
127{
128 // Create and initialize decompression stream
129 z_stream ds{};
130 if (inflateInit(&ds) != Z_OK)
131 {
132 return std::string();
133 }
134 ds.avail_in = str.size();
135 ds.next_in = (Bytef *)str.data();
136
137 // Roll-over the string using a buffer and decompress
138 int status = Z_OK;
139 char roll_buff[16384];
140 std::string inflated_str;
141 do
142 {
143 ds.avail_out = sizeof(roll_buff);
144 ds.next_out = reinterpret_cast<Bytef *>(roll_buff);
145
146 status = inflate(&ds, 0);
147 if (inflated_str.size() < ds.total_out)
148 {
149 inflated_str.append(roll_buff, ds.total_out - inflated_str.size());
150 }
151 } while (status == Z_OK);
152
153 // Finalize decompression stream
154 inflateEnd(&ds);
155 if (status != Z_STREAM_END)
156 {
157 return std::string();
158 }
159
160 return inflated_str;
161}
162} // namespace
163#endif /* ARM_COMPUTE_COMPRESSED_KERNELS */
164

Callers 1

programMethod · 0.85

Calls 3

appendMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected