| 1 | /* Copyright 2013 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | Distributed under MIT license. |
| 4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
| 5 | */ |
| 6 | |
| 7 | /* Function to find backward reference copies. */ |
| 8 | |
| 9 | #ifndef BROTLI_ENC_BACKWARD_REFERENCES_HQ_H_ |
| 10 | #define BROTLI_ENC_BACKWARD_REFERENCES_HQ_H_cxx . . $ `c/enc/backward_references_hq.h:10:9`! |
| 11 | |
| 12 | #include "../common/context.h"cxx . . $ `<file>/c/common/context.h`/ |
| 13 | #include "../common/platform.h"cxx . . $ `<file>/c/common/platform.h`/ |
| 14 | #include "command.h"cxx . . $ `<file>/c/enc/command.h`/ |
| 15 | #include "hash.h"cxx . . $ `<file>/c/enc/hash.h`/ |
| 16 | #include "memory.h"cxx . . $ `<file>/c/enc/memory.h`/ |
| 17 | #include "params.h"cxx . . $ `<file>/c/enc/params.h`/ |
| 18 | |
| 19 | #if defined(__cplusplus) || defined(c_plusplus) |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
| 23 | BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! void BrotliCreateZopfliBackwardReferencescxx . . $ BrotliCreateZopfliBackwardReferences(77af74dfdc9f4df3).(MemoryManagercxx . . $ MemoryManager#* m, |
| 24 | size_tcxx . . $ size_t# num_bytes, |
| 25 | size_tcxx . . $ size_t# position, const uint8_tcxx . . $ uint8_t#* ringbuffer, size_tcxx . . $ size_t# ringbuffer_mask, |
| 26 | ContextLutcxx . . $ ContextLut# literal_context_lut, const BrotliEncoderParamscxx . . $ BrotliEncoderParams#* params, |
| 27 | Hashercxx . . $ Hasher#* hasher, int* dist_cache, size_tcxx . . $ size_t#* last_insert_len, |
| 28 | Commandcxx . . $ Command#* commands, size_tcxx . . $ size_t#* num_commands, size_tcxx . . $ size_t#* num_literals); |
| 29 | |
| 30 | BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! void BrotliCreateHqZopfliBackwardReferencescxx . . $ BrotliCreateHqZopfliBackwardReferences(77af74dfdc9f4df3).(MemoryManagercxx . . $ MemoryManager#* m, |
| 31 | size_tcxx . . $ size_t# num_bytes, |
| 32 | size_tcxx . . $ size_t# position, const uint8_tcxx . . $ uint8_t#* ringbuffer, size_tcxx . . $ size_t# ringbuffer_mask, |
| 33 | ContextLutcxx . . $ ContextLut# literal_context_lut, const BrotliEncoderParamscxx . . $ BrotliEncoderParams#* params, |
| 34 | Hashercxx . . $ Hasher#* hasher, int* dist_cache, size_tcxx . . $ size_t#* last_insert_len, |
| 35 | Commandcxx . . $ Command#* commands, size_tcxx . . $ size_t#* num_commands, size_tcxx . . $ size_t#* num_literals); |
| 36 | |
| 37 | typedef struct ZopfliNodecxx . . $ ZopfliNode# { |
| 38 | /* Best length to get up to this byte (not including this byte itself) |
| 39 | highest 7 bit is used to reconstruct the length code. */ |
| 40 | uint32_tcxx . . $ uint32_t# lengthcxx . . $ ZopfliNode#length.; |
| 41 | /* Distance associated with the length. */ |
| 42 | uint32_tcxx . . $ uint32_t# distancecxx . . $ ZopfliNode#distance.; |
| 43 | /* Number of literal inserts before this copy; highest 5 bits contain |
| 44 | distance short code + 1 (or zero if no short code). */ |
| 45 | uint32_tcxx . . $ uint32_t# dcode_insert_lengthcxx . . $ ZopfliNode#dcode_insert_length.; |
| 46 | |
| 47 | /* This union holds information used by dynamic-programming. During forward |
| 48 | pass |cost| it used to store the goal function. When node is processed its |
| 49 | |cost| is invalidated in favor of |shortcut|. On path back-tracing pass |
| 50 | |next| is assigned the offset to next node on the path. */ |
| 51 | unioncxx . . $ ZopfliNode#$anonymous_type_0# { |
| 52 | /* Smallest cost to get to this byte from the beginning, as found so far. */ |
| 53 | float costcxx . . $ ZopfliNode#$anonymous_type_0#cost.; |
| 54 | /* Offset to the next node on the path. Equals to command_length() of the |
| 55 | next node on the path. For last node equals to BROTLI_UINT32_MAX */ |
| 56 | uint32_tcxx . . $ uint32_t# nextcxx . . $ ZopfliNode#$anonymous_type_0#next.; |
| 57 | /* Node position that provides next distance for distance cache. */ |
| 58 | uint32_tcxx . . $ uint32_t# shortcutcxx . . $ ZopfliNode#$anonymous_type_0#shortcut.; |
| 59 | } ucxx . . $ ZopfliNode#u.; |
| 60 | } ZopfliNodecxx . . $ ZopfliNode#; |
| 61 | |
| 62 | BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! void BrotliInitZopfliNodescxx . . $ BrotliInitZopfliNodes(8999d8ffe0627287).(ZopfliNodecxx . . $ ZopfliNode#* array, size_tcxx . . $ size_t# length); |
| 63 | |
| 64 | /* Computes the shortest path of commands from position to at most |
| 65 | position + num_bytes. |
| 66 | |
| 67 | On return, path->size() is the number of commands found and path[i] is the |
| 68 | length of the i-th command (copy length plus insert length). |
| 69 | Note that the sum of the lengths of all commands can be less than num_bytes. |
| 70 | |
| 71 | On return, the nodes[0..num_bytes] array will have the following |
| 72 | "ZopfliNode array invariant": |
| 73 | For each i in [1..num_bytes], if nodes[i].cost < kInfinity, then |
| 74 | (1) nodes[i].copy_length() >= 2 |
| 75 | (2) nodes[i].command_length() <= i and |
| 76 | (3) nodes[i - nodes[i].command_length()].cost < kInfinity */ |
| 77 | BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! size_tcxx . . $ size_t# BrotliZopfliComputeShortestPathcxx . . $ BrotliZopfliComputeShortestPath(7f1f18aaf03fb24d).( |
| 78 | MemoryManagercxx . . $ MemoryManager#* m, size_tcxx . . $ size_t# num_bytes, |
| 79 | size_tcxx . . $ size_t# position, const uint8_tcxx . . $ uint8_t#* ringbuffer, size_tcxx . . $ size_t# ringbuffer_mask, |
| 80 | ContextLutcxx . . $ ContextLut# literal_context_lut, const BrotliEncoderParamscxx . . $ BrotliEncoderParams#* params, |
| 81 | const int* dist_cache, Hashercxx . . $ Hasher#* hasher, ZopfliNodecxx . . $ ZopfliNode#* nodes); |
| 82 | |
| 83 | BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! void BrotliZopfliCreateCommandscxx . . $ BrotliZopfliCreateCommands(426b03b768448b1b).( |
| 84 | const size_tcxx . . $ size_t# num_bytes, const size_tcxx . . $ size_t# block_start, const ZopfliNodecxx . . $ ZopfliNode#* nodes, |
| 85 | int* dist_cache, size_tcxx . . $ size_t#* last_insert_len, const BrotliEncoderParamscxx . . $ BrotliEncoderParams#* params, |
| 86 | Commandcxx . . $ Command#* commands, size_tcxx . . $ size_t#* num_literals); |
| 87 | |
| 88 | #if defined(__cplusplus) || defined(c_plusplus) |
| 89 | } /* extern "C" */ |
| 90 | #endif |
| 91 | |
| 92 | #endif /* BROTLI_ENC_BACKWARD_REFERENCES_HQ_H_ */ |