| 39 | |
| 40 | #ifdef PDAL_HAVE_ZLIB |
| 41 | void BpfCompressor::startBlock() |
| 42 | { |
| 43 | // Initialize the stream. |
| 44 | m_strm.zalloc = Z_NULL; |
| 45 | m_strm.zfree = Z_NULL; |
| 46 | m_strm.opaque = Z_NULL; |
| 47 | if (deflateInit(&m_strm, Z_DEFAULT_COMPRESSION) != Z_OK) |
| 48 | throw error("Could not initialize BPF compressor."); |
| 49 | |
| 50 | m_rawSize = 0; |
| 51 | m_compressedSize = 0; |
| 52 | uint32_t rawSize = 0; |
| 53 | uint32_t compressedSize = 0; |
| 54 | |
| 55 | // Initiailize the streambuf with the backing buffer. |
| 56 | m_charbuf.initialize(m_inbuf.data(), m_inbuf.size()); |
| 57 | |
| 58 | // Note our position so that we can rewind here. |
| 59 | m_blockStart.mark(); |
| 60 | m_out << rawSize << compressedSize; |
| 61 | |
| 62 | // Make a new stream from our charbuf and push it so that future writes |
| 63 | // to our stream go to the backing vector. |
| 64 | m_out.pushStream(new std::ostream(&m_charbuf)); |
| 65 | } |
| 66 | |
| 67 | |
| 68 | void BpfCompressor::compress() |
no test coverage detected