Coverage Report

Created: 2026-05-16 07:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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
10.4k
#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
13.9M
                                                 uint16_t len) {
44
13.9M
  PixOrCopy retval;
45
13.9M
  retval.mode = kCopy;
46
13.9M
  retval.argb_or_distance = distance;
47
13.9M
  retval.len = len;
48
13.9M
  return retval;
49
13.9M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyCreateCopy
Unexecuted instantiation: vp8l_enc.c:PixOrCopyCreateCopy
Unexecuted instantiation: lossless_enc.c:PixOrCopyCreateCopy
backward_references_enc.c:PixOrCopyCreateCopy
Line
Count
Source
43
9.23M
                                                 uint16_t len) {
44
9.23M
  PixOrCopy retval;
45
9.23M
  retval.mode = kCopy;
46
9.23M
  retval.argb_or_distance = distance;
47
9.23M
  retval.len = len;
48
9.23M
  return retval;
49
9.23M
}
Unexecuted instantiation: histogram_enc.c:PixOrCopyCreateCopy
backward_references_cost_enc.c:PixOrCopyCreateCopy
Line
Count
Source
43
4.76M
                                                 uint16_t len) {
44
4.76M
  PixOrCopy retval;
45
4.76M
  retval.mode = kCopy;
46
4.76M
  retval.argb_or_distance = distance;
47
4.76M
  retval.len = len;
48
4.76M
  return retval;
49
4.76M
}
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyCreateCopy
Unexecuted instantiation: predictor_enc.c:PixOrCopyCreateCopy
Unexecuted instantiation: alpha_enc.c:PixOrCopyCreateCopy
50
51
52.0M
static WEBP_INLINE PixOrCopy PixOrCopyCreateCacheIdx(int idx) {
52
52.0M
  PixOrCopy retval;
53
52.0M
  assert(idx >= 0);
54
52.0M
  assert(idx < (1 << MAX_COLOR_CACHE_BITS));
55
52.0M
  retval.mode = kCacheIdx;
56
52.0M
  retval.argb_or_distance = idx;
57
52.0M
  retval.len = 1;
58
52.0M
  return retval;
59
52.0M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyCreateCacheIdx
Unexecuted instantiation: vp8l_enc.c:PixOrCopyCreateCacheIdx
Unexecuted instantiation: lossless_enc.c:PixOrCopyCreateCacheIdx
backward_references_enc.c:PixOrCopyCreateCacheIdx
Line
Count
Source
51
47.2M
static WEBP_INLINE PixOrCopy PixOrCopyCreateCacheIdx(int idx) {
52
47.2M
  PixOrCopy retval;
53
47.2M
  assert(idx >= 0);
54
  assert(idx < (1 << MAX_COLOR_CACHE_BITS));
55
47.2M
  retval.mode = kCacheIdx;
56
47.2M
  retval.argb_or_distance = idx;
57
47.2M
  retval.len = 1;
58
47.2M
  return retval;
59
47.2M
}
Unexecuted instantiation: histogram_enc.c:PixOrCopyCreateCacheIdx
backward_references_cost_enc.c:PixOrCopyCreateCacheIdx
Line
Count
Source
51
4.78M
static WEBP_INLINE PixOrCopy PixOrCopyCreateCacheIdx(int idx) {
52
4.78M
  PixOrCopy retval;
53
4.78M
  assert(idx >= 0);
54
  assert(idx < (1 << MAX_COLOR_CACHE_BITS));
55
4.78M
  retval.mode = kCacheIdx;
56
4.78M
  retval.argb_or_distance = idx;
57
4.78M
  retval.len = 1;
58
4.78M
  return retval;
59
4.78M
}
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyCreateCacheIdx
Unexecuted instantiation: predictor_enc.c:PixOrCopyCreateCacheIdx
Unexecuted instantiation: alpha_enc.c:PixOrCopyCreateCacheIdx
60
61
357M
static WEBP_INLINE PixOrCopy PixOrCopyCreateLiteral(uint32_t argb) {
62
357M
  PixOrCopy retval;
63
357M
  retval.mode = kLiteral;
64
357M
  retval.argb_or_distance = argb;
65
357M
  retval.len = 1;
66
357M
  return retval;
67
357M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyCreateLiteral
Unexecuted instantiation: vp8l_enc.c:PixOrCopyCreateLiteral
Unexecuted instantiation: lossless_enc.c:PixOrCopyCreateLiteral
backward_references_enc.c:PixOrCopyCreateLiteral
Line
Count
Source
61
274M
static WEBP_INLINE PixOrCopy PixOrCopyCreateLiteral(uint32_t argb) {
62
274M
  PixOrCopy retval;
63
274M
  retval.mode = kLiteral;
64
274M
  retval.argb_or_distance = argb;
65
274M
  retval.len = 1;
66
274M
  return retval;
67
274M
}
Unexecuted instantiation: histogram_enc.c:PixOrCopyCreateLiteral
backward_references_cost_enc.c:PixOrCopyCreateLiteral
Line
Count
Source
61
83.6M
static WEBP_INLINE PixOrCopy PixOrCopyCreateLiteral(uint32_t argb) {
62
83.6M
  PixOrCopy retval;
63
83.6M
  retval.mode = kLiteral;
64
83.6M
  retval.argb_or_distance = argb;
65
83.6M
  retval.len = 1;
66
83.6M
  return retval;
67
83.6M
}
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyCreateLiteral
Unexecuted instantiation: predictor_enc.c:PixOrCopyCreateLiteral
Unexecuted instantiation: alpha_enc.c:PixOrCopyCreateLiteral
68
69
1.11G
static WEBP_INLINE int PixOrCopyIsLiteral(const PixOrCopy* const p) {
70
1.11G
  return (p->mode == kLiteral);
71
1.11G
}
Unexecuted instantiation: webp_enc.c:PixOrCopyIsLiteral
vp8l_enc.c:PixOrCopyIsLiteral
Line
Count
Source
69
95.1M
static WEBP_INLINE int PixOrCopyIsLiteral(const PixOrCopy* const p) {
70
95.1M
  return (p->mode == kLiteral);
71
95.1M
}
Unexecuted instantiation: lossless_enc.c:PixOrCopyIsLiteral
backward_references_enc.c:PixOrCopyIsLiteral
Line
Count
Source
69
459M
static WEBP_INLINE int PixOrCopyIsLiteral(const PixOrCopy* const p) {
70
459M
  return (p->mode == kLiteral);
71
459M
}
histogram_enc.c:PixOrCopyIsLiteral
Line
Count
Source
69
564M
static WEBP_INLINE int PixOrCopyIsLiteral(const PixOrCopy* const p) {
70
564M
  return (p->mode == kLiteral);
71
564M
}
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyIsLiteral
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyIsLiteral
Unexecuted instantiation: predictor_enc.c:PixOrCopyIsLiteral
Unexecuted instantiation: alpha_enc.c:PixOrCopyIsLiteral
72
73
98.0M
static WEBP_INLINE int PixOrCopyIsCacheIdx(const PixOrCopy* const p) {
74
98.0M
  return (p->mode == kCacheIdx);
75
98.0M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyIsCacheIdx
vp8l_enc.c:PixOrCopyIsCacheIdx
Line
Count
Source
73
11.0M
static WEBP_INLINE int PixOrCopyIsCacheIdx(const PixOrCopy* const p) {
74
11.0M
  return (p->mode == kCacheIdx);
75
11.0M
}
Unexecuted instantiation: lossless_enc.c:PixOrCopyIsCacheIdx
Unexecuted instantiation: backward_references_enc.c:PixOrCopyIsCacheIdx
histogram_enc.c:PixOrCopyIsCacheIdx
Line
Count
Source
73
86.9M
static WEBP_INLINE int PixOrCopyIsCacheIdx(const PixOrCopy* const p) {
74
86.9M
  return (p->mode == kCacheIdx);
75
86.9M
}
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyIsCacheIdx
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyIsCacheIdx
Unexecuted instantiation: predictor_enc.c:PixOrCopyIsCacheIdx
Unexecuted instantiation: alpha_enc.c:PixOrCopyIsCacheIdx
76
77
95.1M
static WEBP_INLINE int PixOrCopyIsCopy(const PixOrCopy* const p) {
78
95.1M
  return (p->mode == kCopy);
79
95.1M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyIsCopy
Unexecuted instantiation: vp8l_enc.c:PixOrCopyIsCopy
Unexecuted instantiation: lossless_enc.c:PixOrCopyIsCopy
backward_references_enc.c:PixOrCopyIsCopy
Line
Count
Source
77
95.1M
static WEBP_INLINE int PixOrCopyIsCopy(const PixOrCopy* const p) {
78
95.1M
  return (p->mode == kCopy);
79
95.1M
}
Unexecuted instantiation: histogram_enc.c:PixOrCopyIsCopy
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyIsCopy
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyIsCopy
Unexecuted instantiation: predictor_enc.c:PixOrCopyIsCopy
Unexecuted instantiation: alpha_enc.c:PixOrCopyIsCopy
80
81
static WEBP_INLINE uint32_t PixOrCopyLiteral(const PixOrCopy* const p,
82
2.24G
                                             int component) {
83
2.24G
  assert(p->mode == kLiteral);
84
2.24G
  return (p->argb_or_distance >> (component * 8)) & 0xff;
85
2.24G
}
Unexecuted instantiation: webp_enc.c:PixOrCopyLiteral
vp8l_enc.c:PixOrCopyLiteral
Line
Count
Source
82
336M
                                             int component) {
83
  assert(p->mode == kLiteral);
84
336M
  return (p->argb_or_distance >> (component * 8)) & 0xff;
85
336M
}
Unexecuted instantiation: lossless_enc.c:PixOrCopyLiteral
Unexecuted instantiation: backward_references_enc.c:PixOrCopyLiteral
histogram_enc.c:PixOrCopyLiteral
Line
Count
Source
82
1.91G
                                             int component) {
83
  assert(p->mode == kLiteral);
84
1.91G
  return (p->argb_or_distance >> (component * 8)) & 0xff;
85
1.91G
}
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyLiteral
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyLiteral
Unexecuted instantiation: predictor_enc.c:PixOrCopyLiteral
Unexecuted instantiation: alpha_enc.c:PixOrCopyLiteral
86
87
224M
static WEBP_INLINE uint32_t PixOrCopyLength(const PixOrCopy* const p) {
88
224M
  return p->len;
89
224M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyLength
vp8l_enc.c:PixOrCopyLength
Line
Count
Source
87
95.1M
static WEBP_INLINE uint32_t PixOrCopyLength(const PixOrCopy* const p) {
88
95.1M
  return p->len;
89
95.1M
}
Unexecuted instantiation: lossless_enc.c:PixOrCopyLength
backward_references_enc.c:PixOrCopyLength
Line
Count
Source
87
9.13M
static WEBP_INLINE uint32_t PixOrCopyLength(const PixOrCopy* const p) {
88
9.13M
  return p->len;
89
9.13M
}
histogram_enc.c:PixOrCopyLength
Line
Count
Source
87
120M
static WEBP_INLINE uint32_t PixOrCopyLength(const PixOrCopy* const p) {
88
120M
  return p->len;
89
120M
}
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyLength
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyLength
Unexecuted instantiation: predictor_enc.c:PixOrCopyLength
Unexecuted instantiation: alpha_enc.c:PixOrCopyLength
90
91
67.7M
static WEBP_INLINE uint32_t PixOrCopyCacheIdx(const PixOrCopy* const p) {
92
67.7M
  assert(p->mode == kCacheIdx);
93
67.7M
  assert(p->argb_or_distance < (1U << MAX_COLOR_CACHE_BITS));
94
67.7M
  return p->argb_or_distance;
95
67.7M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyCacheIdx
vp8l_enc.c:PixOrCopyCacheIdx
Line
Count
Source
91
5.84M
static WEBP_INLINE uint32_t PixOrCopyCacheIdx(const PixOrCopy* const p) {
92
5.84M
  assert(p->mode == kCacheIdx);
93
  assert(p->argb_or_distance < (1U << MAX_COLOR_CACHE_BITS));
94
5.84M
  return p->argb_or_distance;
95
5.84M
}
Unexecuted instantiation: lossless_enc.c:PixOrCopyCacheIdx
Unexecuted instantiation: backward_references_enc.c:PixOrCopyCacheIdx
histogram_enc.c:PixOrCopyCacheIdx
Line
Count
Source
91
61.9M
static WEBP_INLINE uint32_t PixOrCopyCacheIdx(const PixOrCopy* const p) {
92
61.9M
  assert(p->mode == kCacheIdx);
93
  assert(p->argb_or_distance < (1U << MAX_COLOR_CACHE_BITS));
94
61.9M
  return p->argb_or_distance;
95
61.9M
}
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyCacheIdx
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyCacheIdx
Unexecuted instantiation: predictor_enc.c:PixOrCopyCacheIdx
Unexecuted instantiation: alpha_enc.c:PixOrCopyCacheIdx
96
97
30.2M
static WEBP_INLINE uint32_t PixOrCopyDistance(const PixOrCopy* const p) {
98
30.2M
  assert(p->mode == kCopy);
99
30.2M
  return p->argb_or_distance;
100
30.2M
}
Unexecuted instantiation: webp_enc.c:PixOrCopyDistance
vp8l_enc.c:PixOrCopyDistance
Line
Count
Source
97
5.24M
static WEBP_INLINE uint32_t PixOrCopyDistance(const PixOrCopy* const p) {
98
  assert(p->mode == kCopy);
99
5.24M
  return p->argb_or_distance;
100
5.24M
}
Unexecuted instantiation: lossless_enc.c:PixOrCopyDistance
Unexecuted instantiation: backward_references_enc.c:PixOrCopyDistance
histogram_enc.c:PixOrCopyDistance
Line
Count
Source
97
25.0M
static WEBP_INLINE uint32_t PixOrCopyDistance(const PixOrCopy* const p) {
98
  assert(p->mode == kCopy);
99
25.0M
  return p->argb_or_distance;
100
25.0M
}
Unexecuted instantiation: backward_references_cost_enc.c:PixOrCopyDistance
Unexecuted instantiation: near_lossless_enc.c:PixOrCopyDistance
Unexecuted instantiation: predictor_enc.c:PixOrCopyDistance
Unexecuted instantiation: alpha_enc.c:PixOrCopyDistance
101
102
// -----------------------------------------------------------------------------
103
// VP8LHashChain
104
105
689M
#define HASH_BITS 18
106
10.7k
#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
7.48G
#define MAX_LENGTH_BITS 12
111
8.71k
#define WINDOW_SIZE_BITS 20
112
// We want the max value to be attainable and stored in MAX_LENGTH_BITS bits.
113
4.47G
#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
1.03G
                                               const int base_position) {
142
1.03G
  return p->offset_length[base_position] >> MAX_LENGTH_BITS;
143
1.03G
}
Unexecuted instantiation: webp_enc.c:VP8LHashChainFindOffset
Unexecuted instantiation: vp8l_enc.c:VP8LHashChainFindOffset
Unexecuted instantiation: lossless_enc.c:VP8LHashChainFindOffset
backward_references_enc.c:VP8LHashChainFindOffset
Line
Count
Source
141
164M
                                               const int base_position) {
142
164M
  return p->offset_length[base_position] >> MAX_LENGTH_BITS;
143
164M
}
Unexecuted instantiation: histogram_enc.c:VP8LHashChainFindOffset
backward_references_cost_enc.c:VP8LHashChainFindOffset
Line
Count
Source
141
866M
                                               const int base_position) {
142
866M
  return p->offset_length[base_position] >> MAX_LENGTH_BITS;
143
866M
}
Unexecuted instantiation: near_lossless_enc.c:VP8LHashChainFindOffset
Unexecuted instantiation: predictor_enc.c:VP8LHashChainFindOffset
Unexecuted instantiation: alpha_enc.c:VP8LHashChainFindOffset
144
145
static WEBP_INLINE int VP8LHashChainFindLength(const VP8LHashChain* const p,
146
2.09G
                                               const int base_position) {
147
2.09G
  return p->offset_length[base_position] & ((1U << MAX_LENGTH_BITS) - 1);
148
2.09G
}
Unexecuted instantiation: webp_enc.c:VP8LHashChainFindLength
Unexecuted instantiation: vp8l_enc.c:VP8LHashChainFindLength
Unexecuted instantiation: lossless_enc.c:VP8LHashChainFindLength
backward_references_enc.c:VP8LHashChainFindLength
Line
Count
Source
146
1.22G
                                               const int base_position) {
147
1.22G
  return p->offset_length[base_position] & ((1U << MAX_LENGTH_BITS) - 1);
148
1.22G
}
Unexecuted instantiation: histogram_enc.c:VP8LHashChainFindLength
backward_references_cost_enc.c:VP8LHashChainFindLength
Line
Count
Source
146
861M
                                               const int base_position) {
147
861M
  return p->offset_length[base_position] & ((1U << MAX_LENGTH_BITS) - 1);
148
861M
}
Unexecuted instantiation: near_lossless_enc.c:VP8LHashChainFindLength
Unexecuted instantiation: predictor_enc.c:VP8LHashChainFindLength
Unexecuted instantiation: alpha_enc.c:VP8LHashChainFindLength
149
150
static WEBP_INLINE void VP8LHashChainFindCopy(const VP8LHashChain* const p,
151
                                              int base_position,
152
                                              int* const offset_ptr,
153
955M
                                              int* const length_ptr) {
154
955M
  *offset_ptr = VP8LHashChainFindOffset(p, base_position);
155
955M
  *length_ptr = VP8LHashChainFindLength(p, base_position);
156
955M
}
Unexecuted instantiation: webp_enc.c:VP8LHashChainFindCopy
Unexecuted instantiation: vp8l_enc.c:VP8LHashChainFindCopy
Unexecuted instantiation: lossless_enc.c:VP8LHashChainFindCopy
backward_references_enc.c:VP8LHashChainFindCopy
Line
Count
Source
153
94.0M
                                              int* const length_ptr) {
154
94.0M
  *offset_ptr = VP8LHashChainFindOffset(p, base_position);
155
94.0M
  *length_ptr = VP8LHashChainFindLength(p, base_position);
156
94.0M
}
Unexecuted instantiation: histogram_enc.c:VP8LHashChainFindCopy
backward_references_cost_enc.c:VP8LHashChainFindCopy
Line
Count
Source
153
861M
                                              int* const length_ptr) {
154
861M
  *offset_ptr = VP8LHashChainFindOffset(p, base_position);
155
861M
  *length_ptr = VP8LHashChainFindLength(p, base_position);
156
861M
}
Unexecuted instantiation: near_lossless_enc.c:VP8LHashChainFindCopy
Unexecuted instantiation: predictor_enc.c:VP8LHashChainFindCopy
Unexecuted instantiation: alpha_enc.c:VP8LHashChainFindCopy
157
158
// -----------------------------------------------------------------------------
159
// VP8LBackwardRefs (block-based backward-references storage)
160
161
// maximum number of reference blocks the image will be segmented into
162
2.77k
#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.21G
static WEBP_INLINE int VP8LRefsCursorOk(const VP8LRefsCursor* const c) {
196
1.21G
  return (c->cur_pos != NULL);
197
1.21G
}
Unexecuted instantiation: webp_enc.c:VP8LRefsCursorOk
vp8l_enc.c:VP8LRefsCursorOk
Line
Count
Source
195
95.1M
static WEBP_INLINE int VP8LRefsCursorOk(const VP8LRefsCursor* const c) {
196
  return (c->cur_pos != NULL);
197
95.1M
}
Unexecuted instantiation: lossless_enc.c:VP8LRefsCursorOk
backward_references_enc.c:VP8LRefsCursorOk
Line
Count
Source
195
554M
static WEBP_INLINE int VP8LRefsCursorOk(const VP8LRefsCursor* const c) {
196
  return (c->cur_pos != NULL);
197
554M
}
histogram_enc.c:VP8LRefsCursorOk
Line
Count
Source
195
564M
static WEBP_INLINE int VP8LRefsCursorOk(const VP8LRefsCursor* const c) {
196
  return (c->cur_pos != NULL);
197
564M
}
Unexecuted instantiation: backward_references_cost_enc.c:VP8LRefsCursorOk
Unexecuted instantiation: near_lossless_enc.c:VP8LRefsCursorOk
Unexecuted instantiation: predictor_enc.c:VP8LRefsCursorOk
Unexecuted instantiation: alpha_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.21G
static WEBP_INLINE void VP8LRefsCursorNext(VP8LRefsCursor* const c) {
202
1.21G
  assert(c != NULL);
203
1.21G
  assert(VP8LRefsCursorOk(c));
204
1.21G
  if (++c->cur_pos == c->last_pos) VP8LRefsCursorNextBlock(c);
205
1.21G
}
Unexecuted instantiation: webp_enc.c:VP8LRefsCursorNext
vp8l_enc.c:VP8LRefsCursorNext
Line
Count
Source
201
95.1M
static WEBP_INLINE void VP8LRefsCursorNext(VP8LRefsCursor* const c) {
202
95.1M
  assert(c != NULL);
203
95.1M
  assert(VP8LRefsCursorOk(c));
204
95.1M
  if (++c->cur_pos == c->last_pos) VP8LRefsCursorNextBlock(c);
205
95.1M
}
Unexecuted instantiation: lossless_enc.c:VP8LRefsCursorNext
backward_references_enc.c:VP8LRefsCursorNext
Line
Count
Source
201
554M
static WEBP_INLINE void VP8LRefsCursorNext(VP8LRefsCursor* const c) {
202
554M
  assert(c != NULL);
203
554M
  assert(VP8LRefsCursorOk(c));
204
554M
  if (++c->cur_pos == c->last_pos) VP8LRefsCursorNextBlock(c);
205
554M
}
histogram_enc.c:VP8LRefsCursorNext
Line
Count
Source
201
564M
static WEBP_INLINE void VP8LRefsCursorNext(VP8LRefsCursor* const c) {
202
564M
  assert(c != NULL);
203
564M
  assert(VP8LRefsCursorOk(c));
204
564M
  if (++c->cur_pos == c->last_pos) VP8LRefsCursorNextBlock(c);
205
564M
}
Unexecuted instantiation: backward_references_cost_enc.c:VP8LRefsCursorNext
Unexecuted instantiation: near_lossless_enc.c:VP8LRefsCursorNext
Unexecuted instantiation: predictor_enc.c:VP8LRefsCursorNext
Unexecuted instantiation: alpha_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_