VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Decompressor.h
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <memory>
20#include <vector>
21
22#include <vrs/ForwardDefinitions.h>
23#include <vrs/VrsExport.h>
24
25namespace vrs {
26
35class VRS_API Decompressor {
36 public:
39
40 void setCompressionType(CompressionType compressionType);
41 CompressionType getCompressionType() const {
42 return compressionType_;
43 }
44
45 size_t getRecommendedInputBufferSize() const;
46
50 int decompress(void* destination, uint32_t destinationSize, uint32_t& outReadSize);
51
57 void* allocateCompressedDataBuffer(size_t requestSize);
58
63 return readSize_ - decodedSize_;
64 }
65
85 int initFrame(FileHandler& file, size_t& outFrameSize, size_t& inOutMaxReadSize);
92 int readFrame(FileHandler& file, void* dst, size_t frameSize, size_t& inOutMaxReadSize);
93
95 void reset();
96
97 private:
98 const void* getCompressedData() const {
99 return compressedBuffer_.data() + decodedSize_;
100 }
101 size_t getCompressedDataSize() const {
102 return readSize_ - decodedSize_;
103 }
104
105 class Lz4Decompressor;
106 std::unique_ptr<Lz4Decompressor> lz4Context_;
107 class ZstdDecompressor;
108 std::unique_ptr<ZstdDecompressor> zstdContext_;
109 std::vector<uint8_t> compressedBuffer_;
110 CompressionType compressionType_{};
111 size_t readSize_ = {};
112 size_t decodedSize_ = {};
113 size_t lastResult_ = {};
114};
115
116} // namespace vrs
Decompressor helper class, to decompresses data at a target location.
Definition Decompressor.h:35
size_t getRemainingCompressedDataBufferSize() const
Definition Decompressor.h:62
Class to abstract VRS file system operations, to enable support for alternate storage methods,...
Definition FileHandler.h:75
Definition Compressor.cpp:113
CompressionType
Type of compression. Used in VRS record headers, so never modify the values.
Definition Record.h:38