Coverage Report

Created: 2025-08-26 06:43

/src/libwebp/src/enc/backward_references_enc.h
Line
Count
Source
1
// Copyright 2012 Google Inc. All Rights Reserved.
2
//
3
// Use of this source code is governed by a BSD-style license
4
// that can be found in the COPYING file in the root of the source
5
// tree. An additional intellectual property rights grant can be found
6
// in the file PATENTS. All contributing project authors may
7
// be found in the AUTHORS file in the root of the source tree.
8
// -----------------------------------------------------------------------------
9
//
10
// Author: Jyrki Alakuijala (jyrki@google.com)
11
//
12
13
#ifndef WEBP_ENC_BACKWARD_REFERENCES_ENC_H_
14
#define WEBP_ENC_BACKWARD_REFERENCES_ENC_H_
15
16
#include <assert.h>
17
#include <stdlib.h>
18
19
#include "src/webp/encode.h"
20
#include "src/webp/format_constants.h"
21
#include "src/webp/types.h"
22
23
#ifdef __cplusplus
24
extern "C" {
25
#endif
26
27
// The maximum allowed limit is 11.
28
480k
#define MAX_COLOR_CACHE_BITS 10
29
30
// -----------------------------------------------------------------------------
31
// PixOrCopy
32
33
enum Mode { kLiteral, kCacheIdx, kCopy, kNone };
34
35
typedef struct {
36
  // mode as uint8_t to make the memory layout to be exactly 8 bytes.
37
  uint8_t mode;
38
  uint16_t len;
39
  uint32_t argb_or_distance;
40
} PixOrCopy;
41
42
static WEBP_INLINE PixOrCopy PixOrCopyCreateCopy(uint32_t distance,
43
19.3M
                                                 uint16_t len) {
44
19.3M
  PixOrCopy retval;
45
19.3M
  retval.mode = kCopy;
46
19.3M
  retval.argb_or_distance = distance;
47
19.3M
  retval.len = len;
48
19.3M
  return retval;
49
19.3M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyCreateCopy
Unexecuted instantiation: alpha_enc.c:PixOrCopyCreateCopy
Unexecuted instantiation: vp8l_enc.c:PixOrCopyCreateCopy
Unexecuted instantiation: lossless_enc.c:PixOrCopyCreateCopy
backward_references_enc.c:PixOrCopyCreateCopy
Line
Count
Source
43
16.2M
                                                 uint16_t len) {
44
16.2M
  PixOrCopy retval;
45
16.2M
  retval.mode = kCopy;
46
16.2M
  retval.argb_or_distance = distance;
47
16.2M
  retval.len = len;
48
16.2M
  return retval;
49
16.2M
}
Unexecuted instantiation: histogram_enc.c:PixOrCopyCreateCopy
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyCreateCopy
Unexecuted instantiation: predictor_enc.c:PixOrCopyCreateCopy
backward_references_cost_enc.c:PixOrCopyCreateCopy
Line
Count
Source
43
3.07M
                                                 uint16_t len) {
44
3.07M
  PixOrCopy retval;
45
3.07M
  retval.mode = kCopy;
46
3.07M
  retval.argb_or_distance = distance;
47
3.07M
  retval.len = len;
48
3.07M
  return retval;
49
3.07M
}
50
51
78.1M
static WEBP_INLINE PixOrCopy PixOrCopyCreateCacheIdx(int idx) {
52
78.1M
  PixOrCopy retval;
53
78.1M
  assert(idx >= 0);
54
78.1M
  assert(idx < (1 << MAX_COLOR_CACHE_BITS));
55
78.1M
  retval.mode = kCacheIdx;
56
78.1M
  retval.argb_or_distance = idx;
57
78.1M
  retval.len = 1;
58
78.1M
  return retval;
59
78.1M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyCreateCacheIdx
Unexecuted instantiation: alpha_enc.c:PixOrCopyCreateCacheIdx
Unexecuted instantiation: vp8l_enc.c:PixOrCopyCreateCacheIdx
Unexecuted instantiation: lossless_enc.c:PixOrCopyCreateCacheIdx
backward_references_enc.c:PixOrCopyCreateCacheIdx
Line
Count
Source
51
66.4M
static WEBP_INLINE PixOrCopy PixOrCopyCreateCacheIdx(int idx) {
52
66.4M
  PixOrCopy retval;
53
66.4M
  assert(idx >= 0);
54
66.4M
  assert(idx < (1 << MAX_COLOR_CACHE_BITS));
55
66.4M
  retval.mode = kCacheIdx;
56
66.4M
  retval.argb_or_distance = idx;
57
66.4M
  retval.len = 1;
58
66.4M
  return retval;
59
66.4M
}
Unexecuted instantiation: histogram_enc.c:PixOrCopyCreateCacheIdx
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyCreateCacheIdx
Unexecuted instantiation: predictor_enc.c:PixOrCopyCreateCacheIdx
backward_references_cost_enc.c:PixOrCopyCreateCacheIdx
Line
Count
Source
51
11.7M
static WEBP_INLINE PixOrCopy PixOrCopyCreateCacheIdx(int idx) {
52
11.7M
  PixOrCopy retval;
53
11.7M
  assert(idx >= 0);
54
11.7M
  assert(idx < (1 << MAX_COLOR_CACHE_BITS));
55
11.7M
  retval.mode = kCacheIdx;
56
11.7M
  retval.argb_or_distance = idx;
57
11.7M
  retval.len = 1;
58
11.7M
  return retval;
59
11.7M
}
60
61
277M
static WEBP_INLINE PixOrCopy PixOrCopyCreateLiteral(uint32_t argb) {
62
277M
  PixOrCopy retval;
63
277M
  retval.mode = kLiteral;
64
277M
  retval.argb_or_distance = argb;
65
277M
  retval.len = 1;
66
277M
  return retval;
67
277M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyCreateLiteral
Unexecuted instantiation: alpha_enc.c:PixOrCopyCreateLiteral
Unexecuted instantiation: vp8l_enc.c:PixOrCopyCreateLiteral
Unexecuted instantiation: lossless_enc.c:PixOrCopyCreateLiteral
backward_references_enc.c:PixOrCopyCreateLiteral
Line
Count
Source
61
237M
static WEBP_INLINE PixOrCopy PixOrCopyCreateLiteral(uint32_t argb) {
62
237M
  PixOrCopy retval;
63
237M
  retval.mode = kLiteral;
64
237M
  retval.argb_or_distance = argb;
65
237M
  retval.len = 1;
66
237M
  return retval;
67
237M
}
Unexecuted instantiation: histogram_enc.c:PixOrCopyCreateLiteral
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyCreateLiteral
Unexecuted instantiation: predictor_enc.c:PixOrCopyCreateLiteral
backward_references_cost_enc.c:PixOrCopyCreateLiteral
Line
Count
Source
61
39.5M
static WEBP_INLINE PixOrCopy PixOrCopyCreateLiteral(uint32_t argb) {
62
39.5M
  PixOrCopy retval;
63
39.5M
  retval.mode = kLiteral;
64
39.5M
  retval.argb_or_distance = argb;
65
39.5M
  retval.len = 1;
66
39.5M
  return retval;
67
39.5M
}
68
69
950M
static WEBP_INLINE int PixOrCopyIsLiteral(const PixOrCopy* const p) {
70
950M
  return (p->mode == kLiteral);
71
950M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyIsLiteral
Unexecuted instantiation: alpha_enc.c:PixOrCopyIsLiteral
vp8l_enc.c:PixOrCopyIsLiteral
Line
Count
Source
69
147M
static WEBP_INLINE int PixOrCopyIsLiteral(const PixOrCopy* const p) {
70
147M
  return (p->mode == kLiteral);
71
147M
}
Unexecuted instantiation: lossless_enc.c:PixOrCopyIsLiteral
backward_references_enc.c:PixOrCopyIsLiteral
Line
Count
Source
69
289M
static WEBP_INLINE int PixOrCopyIsLiteral(const PixOrCopy* const p) {
70
289M
  return (p->mode == kLiteral);
71
289M
}
histogram_enc.c:PixOrCopyIsLiteral
Line
Count
Source
69
513M
static WEBP_INLINE int PixOrCopyIsLiteral(const PixOrCopy* const p) {
70
513M
  return (p->mode == kLiteral);
71
513M
}
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyIsLiteral
Unexecuted instantiation: predictor_enc.c:PixOrCopyIsLiteral
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyIsLiteral
72
73
205M
static WEBP_INLINE int PixOrCopyIsCacheIdx(const PixOrCopy* const p) {
74
205M
  return (p->mode == kCacheIdx);
75
205M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyIsCacheIdx
Unexecuted instantiation: alpha_enc.c:PixOrCopyIsCacheIdx
vp8l_enc.c:PixOrCopyIsCacheIdx
Line
Count
Source
73
47.6M
static WEBP_INLINE int PixOrCopyIsCacheIdx(const PixOrCopy* const p) {
74
47.6M
  return (p->mode == kCacheIdx);
75
47.6M
}
Unexecuted instantiation: lossless_enc.c:PixOrCopyIsCacheIdx
Unexecuted instantiation: backward_references_enc.c:PixOrCopyIsCacheIdx
histogram_enc.c:PixOrCopyIsCacheIdx
Line
Count
Source
73
157M
static WEBP_INLINE int PixOrCopyIsCacheIdx(const PixOrCopy* const p) {
74
157M
  return (p->mode == kCacheIdx);
75
157M
}
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyIsCacheIdx
Unexecuted instantiation: predictor_enc.c:PixOrCopyIsCacheIdx
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyIsCacheIdx
76
77
147M
static WEBP_INLINE int PixOrCopyIsCopy(const PixOrCopy* const p) {
78
147M
  return (p->mode == kCopy);
79
147M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyIsCopy
Unexecuted instantiation: alpha_enc.c:PixOrCopyIsCopy
Unexecuted instantiation: vp8l_enc.c:PixOrCopyIsCopy
Unexecuted instantiation: lossless_enc.c:PixOrCopyIsCopy
backward_references_enc.c:PixOrCopyIsCopy
Line
Count
Source
77
147M
static WEBP_INLINE int PixOrCopyIsCopy(const PixOrCopy* const p) {
78
147M
  return (p->mode == kCopy);
79
147M
}
Unexecuted instantiation: histogram_enc.c:PixOrCopyIsCopy
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyIsCopy
Unexecuted instantiation: predictor_enc.c:PixOrCopyIsCopy
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyIsCopy
80
81
static WEBP_INLINE uint32_t PixOrCopyLiteral(const PixOrCopy* const p,
82
1.82G
                                             int component) {
83
1.82G
  assert(p->mode == kLiteral);
84
1.82G
  return (p->argb_or_distance >> (component * 8)) & 0xff;
85
1.82G
}
Unexecuted instantiation: webp_enc.c:PixOrCopyLiteral
Unexecuted instantiation: alpha_enc.c:PixOrCopyLiteral
vp8l_enc.c:PixOrCopyLiteral
Line
Count
Source
82
397M
                                             int component) {
83
397M
  assert(p->mode == kLiteral);
84
397M
  return (p->argb_or_distance >> (component * 8)) & 0xff;
85
397M
}
Unexecuted instantiation: lossless_enc.c:PixOrCopyLiteral
Unexecuted instantiation: backward_references_enc.c:PixOrCopyLiteral
histogram_enc.c:PixOrCopyLiteral
Line
Count
Source
82
1.42G
                                             int component) {
83
1.42G
  assert(p->mode == kLiteral);
84
1.42G
  return (p->argb_or_distance >> (component * 8)) & 0xff;
85
1.42G
}
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyLiteral
Unexecuted instantiation: predictor_enc.c:PixOrCopyLiteral
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyLiteral
86
87
330M
static WEBP_INLINE uint32_t PixOrCopyLength(const PixOrCopy* const p) {
88
330M
  return p->len;
89
330M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyLength
Unexecuted instantiation: alpha_enc.c:PixOrCopyLength
vp8l_enc.c:PixOrCopyLength
Line
Count
Source
87
147M
static WEBP_INLINE uint32_t PixOrCopyLength(const PixOrCopy* const p) {
88
147M
  return p->len;
89
147M
}
Unexecuted instantiation: lossless_enc.c:PixOrCopyLength
backward_references_enc.c:PixOrCopyLength
Line
Count
Source
87
11.3M
static WEBP_INLINE uint32_t PixOrCopyLength(const PixOrCopy* const p) {
88
11.3M
  return p->len;
89
11.3M
}
histogram_enc.c:PixOrCopyLength
Line
Count
Source
87
172M
static WEBP_INLINE uint32_t PixOrCopyLength(const PixOrCopy* const p) {
88
172M
  return p->len;
89
172M
}
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyLength
Unexecuted instantiation: predictor_enc.c:PixOrCopyLength
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyLength
90
91
166M
static WEBP_INLINE uint32_t PixOrCopyCacheIdx(const PixOrCopy* const p) {
92
166M
  assert(p->mode == kCacheIdx);
93
166M
  assert(p->argb_or_distance < (1U << MAX_COLOR_CACHE_BITS));
94
166M
  return p->argb_or_distance;
95
166M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyCacheIdx
Unexecuted instantiation: alpha_enc.c:PixOrCopyCacheIdx
vp8l_enc.c:PixOrCopyCacheIdx
Line
Count
Source
91
39.4M
static WEBP_INLINE uint32_t PixOrCopyCacheIdx(const PixOrCopy* const p) {
92
39.4M
  assert(p->mode == kCacheIdx);
93
39.4M
  assert(p->argb_or_distance < (1U << MAX_COLOR_CACHE_BITS));
94
39.4M
  return p->argb_or_distance;
95
39.4M
}
Unexecuted instantiation: lossless_enc.c:PixOrCopyCacheIdx
Unexecuted instantiation: backward_references_enc.c:PixOrCopyCacheIdx
histogram_enc.c:PixOrCopyCacheIdx
Line
Count
Source
91
127M
static WEBP_INLINE uint32_t PixOrCopyCacheIdx(const PixOrCopy* const p) {
92
127M
  assert(p->mode == kCacheIdx);
93
127M
  assert(p->argb_or_distance < (1U << MAX_COLOR_CACHE_BITS));
94
127M
  return p->argb_or_distance;
95
127M
}
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyCacheIdx
Unexecuted instantiation: predictor_enc.c:PixOrCopyCacheIdx
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyCacheIdx
96
97
38.7M
static WEBP_INLINE uint32_t PixOrCopyDistance(const PixOrCopy* const p) {
98
38.7M
  assert(p->mode == kCopy);
99
38.7M
  return p->argb_or_distance;
100
38.7M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyDistance
Unexecuted instantiation: alpha_enc.c:PixOrCopyDistance
vp8l_enc.c:PixOrCopyDistance
Line
Count
Source
97
8.27M
static WEBP_INLINE uint32_t PixOrCopyDistance(const PixOrCopy* const p) {
98
8.27M
  assert(p->mode == kCopy);
99
8.27M
  return p->argb_or_distance;
100
8.27M
}
Unexecuted instantiation: lossless_enc.c:PixOrCopyDistance
Unexecuted instantiation: backward_references_enc.c:PixOrCopyDistance
histogram_enc.c:PixOrCopyDistance
Line
Count
Source
97
30.4M
static WEBP_INLINE uint32_t PixOrCopyDistance(const PixOrCopy* const p) {
98
30.4M
  assert(p->mode == kCopy);
99
30.4M
  return p->argb_or_distance;
100
30.4M
}
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyDistance
Unexecuted instantiation: predictor_enc.c:PixOrCopyDistance
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyDistance
101
102
// -----------------------------------------------------------------------------
103
// VP8LHashChain
104
105
286M
#define HASH_BITS 18
106
511k
#define HASH_SIZE (1 << HASH_BITS)
107
108
// If you change this, you need MAX_LENGTH_BITS + WINDOW_SIZE_BITS <= 32 as it
109
// is used in VP8LHashChain.
110
2.20G
#define MAX_LENGTH_BITS 12
111
485k
#define WINDOW_SIZE_BITS 20
112
// We want the max value to be attainable and stored in MAX_LENGTH_BITS bits.
113
1.18G
#define MAX_LENGTH ((1 << MAX_LENGTH_BITS) - 1)
114
#if MAX_LENGTH_BITS + WINDOW_SIZE_BITS > 32
115
#error "MAX_LENGTH_BITS + WINDOW_SIZE_BITS > 32"
116
#endif
117
118
typedef struct VP8LHashChain VP8LHashChain;
119
struct VP8LHashChain {
120
  // The 20 most significant bits contain the offset at which the best match
121
  // is found. These 20 bits are the limit defined by GetWindowSizeForHashChain
122
  // (through WINDOW_SIZE = 1<<20).
123
  // The lower 12 bits contain the length of the match. The 12 bit limit is
124
  // defined in MaxFindCopyLength with MAX_LENGTH=4096.
125
  uint32_t* offset_length;
126
  // This is the maximum size of the hash_chain that can be constructed.
127
  // Typically this is the pixel count (width x height) for a given image.
128
  int size;
129
};
130
131
// Must be called first, to set size.
132
int VP8LHashChainInit(VP8LHashChain* const p, int size);
133
// Pre-compute the best matches for argb. pic and percent are for progress.
134
int VP8LHashChainFill(VP8LHashChain* const p, int quality,
135
                      const uint32_t* const argb, int xsize, int ysize,
136
                      int low_effort, const WebPPicture* const pic,
137
                      int percent_range, int* const percent);
138
void VP8LHashChainClear(VP8LHashChain* const p);  // release memory
139
140
static WEBP_INLINE int VP8LHashChainFindOffset(const VP8LHashChain* const p,
141
302M
                                               const int base_position) {
142
302M
  return p->offset_length[base_position] >> MAX_LENGTH_BITS;
143
302M
}
Unexecuted instantiation: webp_enc.c:VP8LHashChainFindOffset
Unexecuted instantiation: alpha_enc.c:VP8LHashChainFindOffset
Unexecuted instantiation: vp8l_enc.c:VP8LHashChainFindOffset
Unexecuted instantiation: lossless_enc.c:VP8LHashChainFindOffset
backward_references_enc.c:VP8LHashChainFindOffset
Line
Count
Source
141
124M
                                               const int base_position) {
142
124M
  return p->offset_length[base_position] >> MAX_LENGTH_BITS;
143
124M
}
Unexecuted instantiation: histogram_enc.c:VP8LHashChainFindOffset
Unexecuted instantiation: near_lossless_enc.c:VP8LHashChainFindOffset
Unexecuted instantiation: predictor_enc.c:VP8LHashChainFindOffset
backward_references_cost_enc.c:VP8LHashChainFindOffset
Line
Count
Source
141
177M
                                               const int base_position) {
142
177M
  return p->offset_length[base_position] >> MAX_LENGTH_BITS;
143
177M
}
144
145
static WEBP_INLINE int VP8LHashChainFindLength(const VP8LHashChain* const p,
146
597M
                                               const int base_position) {
147
597M
  return p->offset_length[base_position] & ((1U << MAX_LENGTH_BITS) - 1);
148
597M
}
Unexecuted instantiation: webp_enc.c:VP8LHashChainFindLength
Unexecuted instantiation: alpha_enc.c:VP8LHashChainFindLength
Unexecuted instantiation: vp8l_enc.c:VP8LHashChainFindLength
Unexecuted instantiation: lossless_enc.c:VP8LHashChainFindLength
backward_references_enc.c:VP8LHashChainFindLength
Line
Count
Source
146
422M
                                               const int base_position) {
147
422M
  return p->offset_length[base_position] & ((1U << MAX_LENGTH_BITS) - 1);
148
422M
}
Unexecuted instantiation: histogram_enc.c:VP8LHashChainFindLength
Unexecuted instantiation: near_lossless_enc.c:VP8LHashChainFindLength
Unexecuted instantiation: predictor_enc.c:VP8LHashChainFindLength
backward_references_cost_enc.c:VP8LHashChainFindLength
Line
Count
Source
146
174M
                                               const int base_position) {
147
174M
  return p->offset_length[base_position] & ((1U << MAX_LENGTH_BITS) - 1);
148
174M
}
149
150
static WEBP_INLINE void VP8LHashChainFindCopy(const VP8LHashChain* const p,
151
                                              int base_position,
152
                                              int* const offset_ptr,
153
295M
                                              int* const length_ptr) {
154
295M
  *offset_ptr = VP8LHashChainFindOffset(p, base_position);
155
295M
  *length_ptr = VP8LHashChainFindLength(p, base_position);
156
295M
}
Unexecuted instantiation: webp_enc.c:VP8LHashChainFindCopy
Unexecuted instantiation: alpha_enc.c:VP8LHashChainFindCopy
Unexecuted instantiation: vp8l_enc.c:VP8LHashChainFindCopy
Unexecuted instantiation: lossless_enc.c:VP8LHashChainFindCopy
backward_references_enc.c:VP8LHashChainFindCopy
Line
Count
Source
153
120M
                                              int* const length_ptr) {
154
120M
  *offset_ptr = VP8LHashChainFindOffset(p, base_position);
155
120M
  *length_ptr = VP8LHashChainFindLength(p, base_position);
156
120M
}
Unexecuted instantiation: histogram_enc.c:VP8LHashChainFindCopy
Unexecuted instantiation: near_lossless_enc.c:VP8LHashChainFindCopy
Unexecuted instantiation: predictor_enc.c:VP8LHashChainFindCopy
backward_references_cost_enc.c:VP8LHashChainFindCopy
Line
Count
Source
153
174M
                                              int* const length_ptr) {
154
174M
  *offset_ptr = VP8LHashChainFindOffset(p, base_position);
155
174M
  *length_ptr = VP8LHashChainFindLength(p, base_position);
156
174M
}
157
158
// -----------------------------------------------------------------------------
159
// VP8LBackwardRefs (block-based backward-references storage)
160
161
// maximum number of reference blocks the image will be segmented into
162
52.9k
#define MAX_REFS_BLOCK_PER_IMAGE 16
163
164
typedef struct PixOrCopyBlock PixOrCopyBlock;  // forward declaration
165
typedef struct VP8LBackwardRefs VP8LBackwardRefs;
166
167
// Container for blocks chain
168
struct VP8LBackwardRefs {
169
  int block_size;               // common block-size
170
  int error;                    // set to true if some memory error occurred
171
  PixOrCopyBlock* refs;         // list of currently used blocks
172
  PixOrCopyBlock** tail;        // for list recycling
173
  PixOrCopyBlock* free_blocks;  // free-list
174
  PixOrCopyBlock* last_block;   // used for adding new refs (internal)
175
};
176
177
// Initialize the object. 'block_size' is the common block size to store
178
// references (typically, width * height / MAX_REFS_BLOCK_PER_IMAGE).
179
void VP8LBackwardRefsInit(VP8LBackwardRefs* const refs, int block_size);
180
// Release memory for backward references.
181
void VP8LBackwardRefsClear(VP8LBackwardRefs* const refs);
182
183
// Cursor for iterating on references content
184
typedef struct {
185
  // public:
186
  PixOrCopy* cur_pos;  // current position
187
  // private:
188
  PixOrCopyBlock* cur_block;  // current block in the refs list
189
  const PixOrCopy* last_pos;  // sentinel for switching to next block
190
} VP8LRefsCursor;
191
192
// Returns a cursor positioned at the beginning of the references list.
193
VP8LRefsCursor VP8LRefsCursorInit(const VP8LBackwardRefs* const refs);
194
// Returns true if cursor is pointing at a valid position.
195
1.10G
static WEBP_INLINE int VP8LRefsCursorOk(const VP8LRefsCursor* const c) {
196
1.10G
  return (c->cur_pos != NULL);
197
1.10G
}
Unexecuted instantiation: webp_enc.c:VP8LRefsCursorOk
Unexecuted instantiation: alpha_enc.c:VP8LRefsCursorOk
vp8l_enc.c:VP8LRefsCursorOk
Line
Count
Source
195
147M
static WEBP_INLINE int VP8LRefsCursorOk(const VP8LRefsCursor* const c) {
196
147M
  return (c->cur_pos != NULL);
197
147M
}
Unexecuted instantiation: lossless_enc.c:VP8LRefsCursorOk
backward_references_enc.c:VP8LRefsCursorOk
Line
Count
Source
195
437M
static WEBP_INLINE int VP8LRefsCursorOk(const VP8LRefsCursor* const c) {
196
437M
  return (c->cur_pos != NULL);
197
437M
}
histogram_enc.c:VP8LRefsCursorOk
Line
Count
Source
195
515M
static WEBP_INLINE int VP8LRefsCursorOk(const VP8LRefsCursor* const c) {
196
515M
  return (c->cur_pos != NULL);
197
515M
}
Unexecuted instantiation: near_lossless_enc.c:VP8LRefsCursorOk
Unexecuted instantiation: predictor_enc.c:VP8LRefsCursorOk
Unexecuted instantiation: backward_references_cost_enc.c:VP8LRefsCursorOk
198
// Move to next block of references. Internal, not to be called directly.
199
void VP8LRefsCursorNextBlock(VP8LRefsCursor* const c);
200
// Move to next position, or NULL. Should not be called if !VP8LRefsCursorOk().
201
1.09G
static WEBP_INLINE void VP8LRefsCursorNext(VP8LRefsCursor* const c) {
202
1.09G
  assert(c != NULL);
203
1.09G
  assert(VP8LRefsCursorOk(c));
204
1.09G
  if (++c->cur_pos == c->last_pos) VP8LRefsCursorNextBlock(c);
205
1.09G
}
Unexecuted instantiation: webp_enc.c:VP8LRefsCursorNext
Unexecuted instantiation: alpha_enc.c:VP8LRefsCursorNext
vp8l_enc.c:VP8LRefsCursorNext
Line
Count
Source
201
147M
static WEBP_INLINE void VP8LRefsCursorNext(VP8LRefsCursor* const c) {
202
147M
  assert(c != NULL);
203
147M
  assert(VP8LRefsCursorOk(c));
204
147M
  if (++c->cur_pos == c->last_pos) VP8LRefsCursorNextBlock(c);
205
147M
}
Unexecuted instantiation: lossless_enc.c:VP8LRefsCursorNext
backward_references_enc.c:VP8LRefsCursorNext
Line
Count
Source
201
436M
static WEBP_INLINE void VP8LRefsCursorNext(VP8LRefsCursor* const c) {
202
436M
  assert(c != NULL);
203
436M
  assert(VP8LRefsCursorOk(c));
204
436M
  if (++c->cur_pos == c->last_pos) VP8LRefsCursorNextBlock(c);
205
436M
}
histogram_enc.c:VP8LRefsCursorNext
Line
Count
Source
201
513M
static WEBP_INLINE void VP8LRefsCursorNext(VP8LRefsCursor* const c) {
202
513M
  assert(c != NULL);
203
513M
  assert(VP8LRefsCursorOk(c));
204
513M
  if (++c->cur_pos == c->last_pos) VP8LRefsCursorNextBlock(c);
205
513M
}
Unexecuted instantiation: near_lossless_enc.c:VP8LRefsCursorNext
Unexecuted instantiation: predictor_enc.c:VP8LRefsCursorNext
Unexecuted instantiation: backward_references_cost_enc.c:VP8LRefsCursorNext
206
207
// -----------------------------------------------------------------------------
208
// Main entry points
209
210
enum VP8LLZ77Type { kLZ77Standard = 1, kLZ77RLE = 2, kLZ77Box = 4 };
211
212
// Evaluates best possible backward references for specified quality.
213
// The input cache_bits to 'VP8LGetBackwardReferences' sets the maximum cache
214
// bits to use (passing 0 implies disabling the local color cache).
215
// The optimal cache bits is evaluated and set for the *cache_bits_best
216
// parameter with the matching refs_best.
217
// If do_no_cache == 0, refs is an array of 2 values and the best
218
// VP8LBackwardRefs is put in the first element.
219
// If do_no_cache != 0, refs is an array of 3 values and the best
220
// VP8LBackwardRefs is put in the first element, the best value with no-cache in
221
// the second element.
222
// In both cases, the last element is used as temporary internally.
223
// pic and percent are for progress.
224
// Returns false in case of error (stored in pic->error_code).
225
int VP8LGetBackwardReferences(
226
    int width, int height, const uint32_t* const argb, int quality,
227
    int low_effort, int lz77_types_to_try, int cache_bits_max, int do_no_cache,
228
    const VP8LHashChain* const hash_chain, VP8LBackwardRefs* const refs,
229
    int* const cache_bits_best, const WebPPicture* const pic, int percent_range,
230
    int* const percent);
231
232
#ifdef __cplusplus
233
}
234
#endif
235
236
#endif  // WEBP_ENC_BACKWARD_REFERENCES_ENC_H_