Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
backward_references_hq.h
Go to the documentation of this file.
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_
11
12#include "../common/constants.h"
13#include "../common/context.h"
15#include "../common/platform.h"
16#include <brotli/types.h>
17#include "./command.h"
18#include "./hash.h"
19#include "./memory.h"
20#include "./quality.h"
21
22#if defined(__cplusplus) || defined(c_plusplus)
23extern "C" {
24#endif
25
27 size_t num_bytes,
28 size_t position, const uint8_t* ringbuffer, size_t ringbuffer_mask,
29 ContextLut literal_context_lut, const BrotliEncoderParams* params,
30 Hasher* hasher, int* dist_cache, size_t* last_insert_len,
31 Command* commands, size_t* num_commands, size_t* num_literals);
32
34 size_t num_bytes,
35 size_t position, const uint8_t* ringbuffer, size_t ringbuffer_mask,
36 ContextLut literal_context_lut, const BrotliEncoderParams* params,
37 Hasher* hasher, int* dist_cache, size_t* last_insert_len,
38 Command* commands, size_t* num_commands, size_t* num_literals);
39
40typedef struct ZopfliNode {
41 /* Best length to get up to this byte (not including this byte itself)
42 highest 7 bit is used to reconstruct the length code. */
43 uint32_t length;
44 /* Distance associated with the length. */
45 uint32_t distance;
46 /* Number of literal inserts before this copy; highest 5 bits contain
47 distance short code + 1 (or zero if no short code). */
49
50 /* This union holds information used by dynamic-programming. During forward
51 pass |cost| it used to store the goal function. When node is processed its
52 |cost| is invalidated in favor of |shortcut|. On path back-tracing pass
53 |next| is assigned the offset to next node on the path. */
54 union {
55 /* Smallest cost to get to this byte from the beginning, as found so far. */
56 float cost;
57 /* Offset to the next node on the path. Equals to command_length() of the
58 next node on the path. For last node equals to BROTLI_UINT32_MAX */
59 uint32_t next;
60 /* Node position that provides next distance for distance cache. */
61 uint32_t shortcut;
62 } u;
64
65BROTLI_INTERNAL void BrotliInitZopfliNodes(ZopfliNode* array, size_t length);
66
67/* Computes the shortest path of commands from position to at most
68 position + num_bytes.
69
70 On return, path->size() is the number of commands found and path[i] is the
71 length of the i-th command (copy length plus insert length).
72 Note that the sum of the lengths of all commands can be less than num_bytes.
73
74 On return, the nodes[0..num_bytes] array will have the following
75 "ZopfliNode array invariant":
76 For each i in [1..num_bytes], if nodes[i].cost < kInfinity, then
77 (1) nodes[i].copy_length() >= 2
78 (2) nodes[i].command_length() <= i and
79 (3) nodes[i - nodes[i].command_length()].cost < kInfinity */
81 MemoryManager* m, size_t num_bytes,
82 size_t position, const uint8_t* ringbuffer, size_t ringbuffer_mask,
83 ContextLut literal_context_lut, const BrotliEncoderParams* params,
84 const int* dist_cache, Hasher* hasher, ZopfliNode* nodes);
85
87 const size_t num_bytes, const size_t block_start, const ZopfliNode* nodes,
88 int* dist_cache, size_t* last_insert_len, const BrotliEncoderParams* params,
89 Command* commands, size_t* num_literals);
90
91#if defined(__cplusplus) || defined(c_plusplus)
92} /* extern "C" */
93#endif
94
95#endif /* BROTLI_ENC_BACKWARD_REFERENCES_HQ_H_ */
const uint8_t * ContextLut
Definition context.h:105
BROTLI_INTERNAL void BrotliCreateHqZopfliBackwardReferences(MemoryManager *m, size_t num_bytes, size_t position, const uint8_t *ringbuffer, size_t ringbuffer_mask, ContextLut literal_context_lut, const BrotliEncoderParams *params, Hasher *hasher, int *dist_cache, size_t *last_insert_len, Command *commands, size_t *num_commands, size_t *num_literals)
Definition backward_references_hq.c:739
BROTLI_INTERNAL void BrotliInitZopfliNodes(ZopfliNode *array, size_t length)
Definition backward_references_hq.c:42
BROTLI_INTERNAL void BrotliZopfliCreateCommands(const size_t num_bytes, const size_t block_start, const ZopfliNode *nodes, int *dist_cache, size_t *last_insert_len, const BrotliEncoderParams *params, Command *commands, size_t *num_literals)
Definition backward_references_hq.c:571
BROTLI_INTERNAL size_t BrotliZopfliComputeShortestPath(MemoryManager *m, size_t num_bytes, size_t position, const uint8_t *ringbuffer, size_t ringbuffer_mask, ContextLut literal_context_lut, const BrotliEncoderParams *params, const int *dist_cache, Hasher *hasher, ZopfliNode *nodes)
Definition backward_references_hq.c:657
struct ZopfliNode ZopfliNode
BROTLI_INTERNAL void BrotliCreateZopfliBackwardReferences(MemoryManager *m, size_t num_bytes, size_t position, const uint8_t *ringbuffer, size_t ringbuffer_mask, ContextLut literal_context_lut, const BrotliEncoderParams *params, Hasher *hasher, int *dist_cache, size_t *last_insert_len, Command *commands, size_t *num_commands, size_t *num_literals)
Definition backward_references_hq.c:722
Definition params.h:32
Definition command.h:107
Definition hash.h:381
Definition memory.h:26
Definition backward_references_hq.h:40
uint32_t dcode_insert_length
Definition backward_references_hq.h:48
union ZopfliNode::@10 u
uint32_t distance
Definition backward_references_hq.h:45
float cost
Definition backward_references_hq.h:56
uint32_t next
Definition backward_references_hq.h:59
uint32_t shortcut
Definition backward_references_hq.h:61
uint32_t length
Definition backward_references_hq.h:43
#define BROTLI_INTERNAL
Definition platform.h:173