blob: 5a16806669f03a5398bdaee274e1be66f3acf148 [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <zircon/types.h>
namespace chunked_compression {
// CompressionParams describes the configuration for compression.
struct CompressionParams {
// Validates the configured parameters.
bool IsValid() const;
// Returns the minimum size that a buffer must be to hold the result of compressing |len| bytes,
// given the configured parameters.
size_t ComputeOutputSizeLimit(size_t len) const;
// How aggressively to compress.
// MinCompressionLevel() <= compression_level <= MaxCompressionLevel()
int compression_level = DefaultCompressionLevel();
// Size of chunks. Will be rounded up to a multiple of 4096 bytes.
// MinChunkSize() <= chunk_size <= MaxChunkSize()
size_t chunk_size = MinChunkSize();
// Whether to include a per-frame checksum.
// Each frame is independently validated with its checksum when decompressed.
bool frame_checksum = false;
static int DefaultCompressionLevel();
static int MinCompressionLevel();
static int MaxCompressionLevel();
// Estimates a good chunk size for the given input size.
// |len| is the data input size.
// |target_size| is the frame size to target. A frame size greater than or equal to this
// will be returned (greater when the data is too large to support the target size.)
static size_t ChunkSizeForInputSize(size_t len, size_t target_size);
static size_t MinChunkSize();
} // namespace chunked_compression