compress_fragment.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Copyright 2015 Google Inc. All Rights Reserved.
  2. Distributed under MIT license.
  3. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
  4. */
  5. /* Function for fast encoding of an input fragment, independently from the input
  6. history. This function uses one-pass processing: when we find a backward
  7. match, we immediately emit the corresponding command and literal codes to
  8. the bit stream. */
  9. #ifndef BROTLI_ENC_COMPRESS_FRAGMENT_H_
  10. #define BROTLI_ENC_COMPRESS_FRAGMENT_H_
  11. #include "../common/types.h"
  12. #include "./memory.h"
  13. #include "./port.h"
  14. #if defined(__cplusplus) || defined(c_plusplus)
  15. extern "C" {
  16. #endif
  17. /* Compresses "input" string to the "*storage" buffer as one or more complete
  18. meta-blocks, and updates the "*storage_ix" bit position.
  19. If "is_last" is 1, emits an additional empty last meta-block.
  20. "cmd_depth" and "cmd_bits" contain the command and distance prefix codes
  21. (see comment in encode.h) used for the encoding of this input fragment.
  22. If "is_last" is 0, they are updated to reflect the statistics
  23. of this input fragment, to be used for the encoding of the next fragment.
  24. "*cmd_code_numbits" is the number of bits of the compressed representation
  25. of the command and distance prefix codes, and "cmd_code" is an array of
  26. at least "(*cmd_code_numbits + 7) >> 3" size that contains the compressed
  27. command and distance prefix codes. If "is_last" is 0, these are also
  28. updated to represent the updated "cmd_depth" and "cmd_bits".
  29. REQUIRES: "input_size" is greater than zero, or "is_last" is 1.
  30. REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero.
  31. REQUIRES: "table_size" is a power of two */
  32. BROTLI_INTERNAL void BrotliCompressFragmentFast(MemoryManager* m,
  33. const uint8_t* input,
  34. size_t input_size,
  35. int is_last,
  36. int* table, size_t table_size,
  37. uint8_t cmd_depth[128],
  38. uint16_t cmd_bits[128],
  39. size_t* cmd_code_numbits,
  40. uint8_t* cmd_code,
  41. size_t* storage_ix,
  42. uint8_t* storage);
  43. #if defined(__cplusplus) || defined(c_plusplus)
  44. } /* extern "C" */
  45. #endif
  46. #endif /* BROTLI_ENC_COMPRESS_FRAGMENT_H_ */