126fa459cSmrg/* Copyright 2015 Google Inc. All Rights Reserved. 226fa459cSmrg 326fa459cSmrg Distributed under MIT license. 426fa459cSmrg See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 526fa459cSmrg*/ 626fa459cSmrg 726fa459cSmrg/* Function for fast encoding of an input fragment, independently from the input 826fa459cSmrg history. This function uses one-pass processing: when we find a backward 926fa459cSmrg match, we immediately emit the corresponding command and literal codes to 1026fa459cSmrg the bit stream. */ 1126fa459cSmrg 1226fa459cSmrg#ifndef BROTLI_ENC_COMPRESS_FRAGMENT_H_ 1326fa459cSmrg#define BROTLI_ENC_COMPRESS_FRAGMENT_H_ 1426fa459cSmrg 1526fa459cSmrg#include "../common/platform.h" 1626fa459cSmrg#include <brotli/types.h> 1726fa459cSmrg#include "./memory.h" 1826fa459cSmrg 1926fa459cSmrg#if defined(__cplusplus) || defined(c_plusplus) 2026fa459cSmrgextern "C" { 2126fa459cSmrg#endif 2226fa459cSmrg 2326fa459cSmrg/* Compresses "input" string to the "*storage" buffer as one or more complete 2426fa459cSmrg meta-blocks, and updates the "*storage_ix" bit position. 2526fa459cSmrg 2626fa459cSmrg If "is_last" is 1, emits an additional empty last meta-block. 2726fa459cSmrg 2826fa459cSmrg "cmd_depth" and "cmd_bits" contain the command and distance prefix codes 2926fa459cSmrg (see comment in encode.h) used for the encoding of this input fragment. 3026fa459cSmrg If "is_last" is 0, they are updated to reflect the statistics 3126fa459cSmrg of this input fragment, to be used for the encoding of the next fragment. 3226fa459cSmrg 3326fa459cSmrg "*cmd_code_numbits" is the number of bits of the compressed representation 3426fa459cSmrg of the command and distance prefix codes, and "cmd_code" is an array of 3526fa459cSmrg at least "(*cmd_code_numbits + 7) >> 3" size that contains the compressed 3626fa459cSmrg command and distance prefix codes. If "is_last" is 0, these are also 3726fa459cSmrg updated to represent the updated "cmd_depth" and "cmd_bits". 3826fa459cSmrg 3926fa459cSmrg REQUIRES: "input_size" is greater than zero, or "is_last" is 1. 4026fa459cSmrg REQUIRES: "input_size" is less or equal to maximal metablock size (1 << 24). 4126fa459cSmrg REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero. 4226fa459cSmrg REQUIRES: "table_size" is an odd (9, 11, 13, 15) power of two 4326fa459cSmrg OUTPUT: maximal copy distance <= |input_size| 4426fa459cSmrg OUTPUT: maximal copy distance <= BROTLI_MAX_BACKWARD_LIMIT(18) */ 4526fa459cSmrgBROTLI_INTERNAL void BrotliCompressFragmentFast(MemoryManager* m, 4626fa459cSmrg const uint8_t* input, 4726fa459cSmrg size_t input_size, 4826fa459cSmrg BROTLI_BOOL is_last, 4926fa459cSmrg int* table, size_t table_size, 5026fa459cSmrg uint8_t cmd_depth[128], 5126fa459cSmrg uint16_t cmd_bits[128], 5226fa459cSmrg size_t* cmd_code_numbits, 5326fa459cSmrg uint8_t* cmd_code, 5426fa459cSmrg size_t* storage_ix, 5526fa459cSmrg uint8_t* storage); 5626fa459cSmrg 5726fa459cSmrg#if defined(__cplusplus) || defined(c_plusplus) 5826fa459cSmrg} /* extern "C" */ 5926fa459cSmrg#endif 6026fa459cSmrg 6126fa459cSmrg#endif /* BROTLI_ENC_COMPRESS_FRAGMENT_H_ */ 62