compress_fragment_two_pass.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 two-pass processing: in the first pass we save
  7. the found backward matches and literal bytes into a buffer, and in the
  8. second pass we emit them into the bit stream using prefix codes built based
  9. on the actual command and literal byte histograms. */
  10. #ifndef BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_
  11. #define BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_
  12. #include "../common/types.h"
  13. #include "./memory.h"
  14. #include "./port.h"
  15. #if defined(__cplusplus) || defined(c_plusplus)
  16. extern "C" {
  17. #endif
  18. static const size_t kCompressFragmentTwoPassBlockSize = 1 << 17;
  19. /* Compresses "input" string to the "*storage" buffer as one or more complete
  20. meta-blocks, and updates the "*storage_ix" bit position.
  21. If "is_last" is 1, emits an additional empty last meta-block.
  22. REQUIRES: "input_size" is greater than zero, or "is_last" is 1.
  23. REQUIRES: "command_buf" and "literal_buf" point to at least
  24. kCompressFragmentTwoPassBlockSize long arrays.
  25. REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero.
  26. REQUIRES: "table_size" is a power of two */
  27. BROTLI_INTERNAL void BrotliCompressFragmentTwoPass(MemoryManager* m,
  28. const uint8_t* input,
  29. size_t input_size,
  30. int is_last,
  31. uint32_t* command_buf,
  32. uint8_t* literal_buf,
  33. int* table,
  34. size_t table_size,
  35. size_t* storage_ix,
  36. uint8_t* storage);
  37. #if defined(__cplusplus) || defined(c_plusplus)
  38. } /* extern "C" */
  39. #endif
  40. #endif /* BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ */