Coverage Report

Created: 2025-06-24 07:01

/src/ghostpdl/brotli/c/dec/bit_reader.h
Line
Count
Source (jump to first uncovered line)
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
/* Bit reading helpers */
8
9
#ifndef BROTLI_DEC_BIT_READER_H_
10
#define BROTLI_DEC_BIT_READER_H_
11
12
#include <string.h>  /* memcpy */
13
14
#include <brotli/types.h>
15
16
#include "../common/constants.h"
17
#include "../common/platform.h"
18
19
#if defined(__cplusplus) || defined(c_plusplus)
20
extern "C" {
21
#endif
22
23
0
#define BROTLI_SHORT_FILL_BIT_WINDOW_READ (sizeof(brotli_reg_t) >> 1)
24
25
/* 162 bits + 7 bytes */
26
0
#define BROTLI_FAST_INPUT_SLACK 28
27
28
BROTLI_INTERNAL extern const brotli_reg_t kBrotliBitMask[33];
29
30
0
static BROTLI_INLINE brotli_reg_t BitMask(brotli_reg_t n) {
31
0
  if (BROTLI_IS_CONSTANT(n) || BROTLI_HAS_UBFX) {
32
    /* Masking with this expression turns to a single
33
       "Unsigned Bit Field Extract" UBFX instruction on ARM. */
34
0
    return ~(~((brotli_reg_t)0) << n);
35
0
  } else {
36
0
    return kBrotliBitMask[n];
37
0
  }
38
0
}
Unexecuted instantiation: decode.c:BitMask
Unexecuted instantiation: state.c:BitMask
Unexecuted instantiation: bit_reader.c:BitMask
39
40
typedef struct {
41
  brotli_reg_t val_;       /* pre-fetched bits */
42
  brotli_reg_t bit_pos_;   /* current bit-reading position in val_ */
43
  const uint8_t* next_in;  /* the byte we're reading from */
44
  const uint8_t* guard_in; /* position from which "fast-path" is prohibited */
45
  const uint8_t* last_in;  /* == next_in + avail_in */
46
} BrotliBitReader;
47
48
typedef struct {
49
  brotli_reg_t val_;
50
  brotli_reg_t bit_pos_;
51
  const uint8_t* next_in;
52
  size_t avail_in;
53
} BrotliBitReaderState;
54
55
/* Initializes the BrotliBitReader fields. */
56
BROTLI_INTERNAL void BrotliInitBitReader(BrotliBitReader* br);
57
58
/* Ensures that accumulator is not empty.
59
   May consume up to sizeof(brotli_reg_t) - 1 bytes of input.
60
   Returns BROTLI_FALSE if data is required but there is no input available.
61
   For !BROTLI_UNALIGNED_READ_FAST this function also prepares bit reader for
62
   aligned reading. */
63
BROTLI_INTERNAL BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* br);
64
65
/* Fallback for BrotliSafeReadBits32. Extracted as noninlined method to unburden
66
   the main code-path. Never called for RFC brotli streams, required only for
67
   "large-window" mode and other extensions. */
68
BROTLI_INTERNAL BROTLI_NOINLINE BROTLI_BOOL BrotliSafeReadBits32Slow(
69
    BrotliBitReader* br, brotli_reg_t n_bits, brotli_reg_t* val);
70
71
static BROTLI_INLINE size_t
72
0
BrotliBitReaderGetAvailIn(BrotliBitReader* const br) {
73
0
  return (size_t)(br->last_in - br->next_in);
74
0
}
Unexecuted instantiation: decode.c:BrotliBitReaderGetAvailIn
Unexecuted instantiation: state.c:BrotliBitReaderGetAvailIn
Unexecuted instantiation: bit_reader.c:BrotliBitReaderGetAvailIn
75
76
static BROTLI_INLINE void BrotliBitReaderSaveState(
77
0
    BrotliBitReader* const from, BrotliBitReaderState* to) {
78
0
  to->val_ = from->val_;
79
0
  to->bit_pos_ = from->bit_pos_;
80
0
  to->next_in = from->next_in;
81
0
  to->avail_in = BrotliBitReaderGetAvailIn(from);
82
0
}
Unexecuted instantiation: decode.c:BrotliBitReaderSaveState
Unexecuted instantiation: state.c:BrotliBitReaderSaveState
Unexecuted instantiation: bit_reader.c:BrotliBitReaderSaveState
83
84
static BROTLI_INLINE void BrotliBitReaderSetInput(
85
0
    BrotliBitReader* const br, const uint8_t* next_in, size_t avail_in) {
86
0
  br->next_in = next_in;
87
0
  br->last_in = (avail_in == 0) ? next_in : (next_in + avail_in);
88
0
  if (avail_in + 1 > BROTLI_FAST_INPUT_SLACK) {
89
0
    br->guard_in = next_in + (avail_in + 1 - BROTLI_FAST_INPUT_SLACK);
90
0
  } else {
91
0
    br->guard_in = next_in;
92
0
  }
93
0
}
Unexecuted instantiation: decode.c:BrotliBitReaderSetInput
Unexecuted instantiation: state.c:BrotliBitReaderSetInput
Unexecuted instantiation: bit_reader.c:BrotliBitReaderSetInput
94
95
static BROTLI_INLINE void BrotliBitReaderRestoreState(
96
0
    BrotliBitReader* const to, BrotliBitReaderState* from) {
97
0
  to->val_ = from->val_;
98
0
  to->bit_pos_ = from->bit_pos_;
99
0
  to->next_in = from->next_in;
100
0
  BrotliBitReaderSetInput(to, from->next_in, from->avail_in);
101
0
}
Unexecuted instantiation: decode.c:BrotliBitReaderRestoreState
Unexecuted instantiation: state.c:BrotliBitReaderRestoreState
Unexecuted instantiation: bit_reader.c:BrotliBitReaderRestoreState
102
103
static BROTLI_INLINE brotli_reg_t BrotliGetAvailableBits(
104
0
    const BrotliBitReader* br) {
105
0
  return br->bit_pos_;
106
0
}
Unexecuted instantiation: decode.c:BrotliGetAvailableBits
Unexecuted instantiation: state.c:BrotliGetAvailableBits
Unexecuted instantiation: bit_reader.c:BrotliGetAvailableBits
107
108
/* Returns amount of unread bytes the bit reader still has buffered from the
109
   BrotliInput, including whole bytes in br->val_. Result is capped with
110
   maximal ring-buffer size (larger number won't be utilized anyway). */
111
0
static BROTLI_INLINE size_t BrotliGetRemainingBytes(BrotliBitReader* br) {
112
0
  static const size_t kCap = (size_t)1 << BROTLI_LARGE_MAX_WBITS;
113
0
  size_t avail_in = BrotliBitReaderGetAvailIn(br);
114
0
  if (avail_in > kCap) return kCap;
115
0
  return avail_in + (BrotliGetAvailableBits(br) >> 3);
116
0
}
Unexecuted instantiation: decode.c:BrotliGetRemainingBytes
Unexecuted instantiation: state.c:BrotliGetRemainingBytes
Unexecuted instantiation: bit_reader.c:BrotliGetRemainingBytes
117
118
/* Checks if there is at least |num| bytes left in the input ring-buffer
119
   (excluding the bits remaining in br->val_). */
120
static BROTLI_INLINE BROTLI_BOOL BrotliCheckInputAmount(
121
0
    BrotliBitReader* const br) {
122
0
  return TO_BROTLI_BOOL(br->next_in < br->guard_in);
123
0
}
Unexecuted instantiation: decode.c:BrotliCheckInputAmount
Unexecuted instantiation: state.c:BrotliCheckInputAmount
Unexecuted instantiation: bit_reader.c:BrotliCheckInputAmount
124
125
/* Load more bits into accumulator. */
126
static BROTLI_INLINE brotli_reg_t BrotliBitReaderLoadBits(brotli_reg_t val,
127
                                                          brotli_reg_t new_bits,
128
                                                          brotli_reg_t count,
129
0
                                                          brotli_reg_t offset) {
130
0
  BROTLI_DCHECK(
131
0
      !((val >> offset) & ~new_bits & ~(~((brotli_reg_t)0) << count)));
132
0
  (void)count;
133
0
  return val | (new_bits << offset);
134
0
}
Unexecuted instantiation: decode.c:BrotliBitReaderLoadBits
Unexecuted instantiation: state.c:BrotliBitReaderLoadBits
Unexecuted instantiation: bit_reader.c:BrotliBitReaderLoadBits
135
136
/* Guarantees that there are at least |n_bits| + 1 bits in accumulator.
137
   Precondition: accumulator contains at least 1 bit.
138
   |n_bits| should be in the range [1..24] for regular build. For portable
139
   non-64-bit little-endian build only 16 bits are safe to request. */
140
static BROTLI_INLINE void BrotliFillBitWindow(
141
0
    BrotliBitReader* const br, brotli_reg_t n_bits) {
142
0
#if (BROTLI_64_BITS)
143
0
  if (BROTLI_UNALIGNED_READ_FAST && BROTLI_IS_CONSTANT(n_bits) &&
144
0
      (n_bits <= 8)) {
145
0
    brotli_reg_t bit_pos = br->bit_pos_;
146
0
    if (bit_pos <= 8) {
147
0
      br->val_ = BrotliBitReaderLoadBits(br->val_,
148
0
          BROTLI_UNALIGNED_LOAD64LE(br->next_in), 56, bit_pos);
149
0
      br->bit_pos_ = bit_pos + 56;
150
0
      br->next_in += 7;
151
0
    }
152
0
  } else if (BROTLI_UNALIGNED_READ_FAST && BROTLI_IS_CONSTANT(n_bits) &&
153
0
             (n_bits <= 16)) {
154
0
    brotli_reg_t bit_pos = br->bit_pos_;
155
0
    if (bit_pos <= 16) {
156
0
      br->val_ = BrotliBitReaderLoadBits(br->val_,
157
0
          BROTLI_UNALIGNED_LOAD64LE(br->next_in), 48, bit_pos);
158
0
      br->bit_pos_ = bit_pos + 48;
159
0
      br->next_in += 6;
160
0
    }
161
0
  } else {
162
0
    brotli_reg_t bit_pos = br->bit_pos_;
163
0
    if (bit_pos <= 32) {
164
0
      br->val_ = BrotliBitReaderLoadBits(br->val_,
165
0
          (uint64_t)BROTLI_UNALIGNED_LOAD32LE(br->next_in), 32, bit_pos);
166
0
      br->bit_pos_ = bit_pos + 32;
167
0
      br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ;
168
0
    }
169
0
  }
170
#else
171
  if (BROTLI_UNALIGNED_READ_FAST && BROTLI_IS_CONSTANT(n_bits) &&
172
      (n_bits <= 8)) {
173
    brotli_reg_t bit_pos = br->bit_pos_;
174
    if (bit_pos <= 8) {
175
      br->val_ = BrotliBitReaderLoadBits(br->val_,
176
          BROTLI_UNALIGNED_LOAD32LE(br->next_in), 24, bit_pos);
177
      br->bit_pos_ = bit_pos + 24;
178
      br->next_in += 3;
179
    }
180
  } else {
181
    brotli_reg_t bit_pos = br->bit_pos_;
182
    if (bit_pos <= 16) {
183
      br->val_ = BrotliBitReaderLoadBits(br->val_,
184
          (uint32_t)BROTLI_UNALIGNED_LOAD16LE(br->next_in), 16, bit_pos);
185
      br->bit_pos_ = bit_pos + 16;
186
      br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ;
187
    }
188
  }
189
#endif
190
0
}
Unexecuted instantiation: decode.c:BrotliFillBitWindow
Unexecuted instantiation: state.c:BrotliFillBitWindow
Unexecuted instantiation: bit_reader.c:BrotliFillBitWindow
191
192
/* Mostly like BrotliFillBitWindow, but guarantees only 16 bits and reads no
193
   more than BROTLI_SHORT_FILL_BIT_WINDOW_READ bytes of input. */
194
0
static BROTLI_INLINE void BrotliFillBitWindow16(BrotliBitReader* const br) {
195
0
  BrotliFillBitWindow(br, 17);
196
0
}
Unexecuted instantiation: decode.c:BrotliFillBitWindow16
Unexecuted instantiation: state.c:BrotliFillBitWindow16
Unexecuted instantiation: bit_reader.c:BrotliFillBitWindow16
197
198
/* Tries to pull one byte of input to accumulator.
199
   Returns BROTLI_FALSE if there is no input available. */
200
0
static BROTLI_INLINE BROTLI_BOOL BrotliPullByte(BrotliBitReader* const br) {
201
0
  if (br->next_in == br->last_in) {
202
0
    return BROTLI_FALSE;
203
0
  }
204
0
  br->val_ = BrotliBitReaderLoadBits(br->val_,
205
0
      (brotli_reg_t)*br->next_in, 8, br->bit_pos_);
206
0
  br->bit_pos_ += 8;
207
0
  ++br->next_in;
208
0
  return BROTLI_TRUE;
209
0
}
Unexecuted instantiation: decode.c:BrotliPullByte
Unexecuted instantiation: state.c:BrotliPullByte
Unexecuted instantiation: bit_reader.c:BrotliPullByte
210
211
/* Returns currently available bits.
212
   The number of valid bits could be calculated by BrotliGetAvailableBits. */
213
static BROTLI_INLINE brotli_reg_t BrotliGetBitsUnmasked(
214
0
    BrotliBitReader* const br) {
215
0
  return br->val_;
216
0
}
Unexecuted instantiation: decode.c:BrotliGetBitsUnmasked
Unexecuted instantiation: state.c:BrotliGetBitsUnmasked
Unexecuted instantiation: bit_reader.c:BrotliGetBitsUnmasked
217
218
/* Like BrotliGetBits, but does not mask the result.
219
   The result contains at least 16 valid bits. */
220
static BROTLI_INLINE brotli_reg_t BrotliGet16BitsUnmasked(
221
0
    BrotliBitReader* const br) {
222
0
  BrotliFillBitWindow(br, 16);
223
0
  return (brotli_reg_t)BrotliGetBitsUnmasked(br);
224
0
}
Unexecuted instantiation: decode.c:BrotliGet16BitsUnmasked
Unexecuted instantiation: state.c:BrotliGet16BitsUnmasked
Unexecuted instantiation: bit_reader.c:BrotliGet16BitsUnmasked
225
226
/* Returns the specified number of bits from |br| without advancing bit
227
   position. */
228
static BROTLI_INLINE brotli_reg_t BrotliGetBits(
229
0
    BrotliBitReader* const br, brotli_reg_t n_bits) {
230
0
  BrotliFillBitWindow(br, n_bits);
231
0
  return BrotliGetBitsUnmasked(br) & BitMask(n_bits);
232
0
}
Unexecuted instantiation: decode.c:BrotliGetBits
Unexecuted instantiation: state.c:BrotliGetBits
Unexecuted instantiation: bit_reader.c:BrotliGetBits
233
234
/* Tries to peek the specified amount of bits. Returns BROTLI_FALSE, if there
235
   is not enough input. */
236
static BROTLI_INLINE BROTLI_BOOL BrotliSafeGetBits(
237
0
    BrotliBitReader* const br, brotli_reg_t n_bits, brotli_reg_t* val) {
238
0
  while (BrotliGetAvailableBits(br) < n_bits) {
239
0
    if (!BrotliPullByte(br)) {
240
0
      return BROTLI_FALSE;
241
0
    }
242
0
  }
243
0
  *val = BrotliGetBitsUnmasked(br) & BitMask(n_bits);
244
0
  return BROTLI_TRUE;
245
0
}
Unexecuted instantiation: decode.c:BrotliSafeGetBits
Unexecuted instantiation: state.c:BrotliSafeGetBits
Unexecuted instantiation: bit_reader.c:BrotliSafeGetBits
246
247
/* Advances the bit pos by |n_bits|. */
248
static BROTLI_INLINE void BrotliDropBits(
249
0
    BrotliBitReader* const br, brotli_reg_t n_bits) {
250
0
  br->bit_pos_ -= n_bits;
251
0
  br->val_ >>= n_bits;
252
0
}
Unexecuted instantiation: decode.c:BrotliDropBits
Unexecuted instantiation: state.c:BrotliDropBits
Unexecuted instantiation: bit_reader.c:BrotliDropBits
253
254
/* Make sure that there are no spectre bits in accumulator.
255
   This is important for the cases when some bytes are skipped
256
   (i.e. never placed into accumulator). */
257
0
static BROTLI_INLINE void BrotliBitReaderNormalize(BrotliBitReader* br) {
258
  /* Actually, it is enough to normalize when br->bit_pos_ == 0 */
259
0
  if (br->bit_pos_ < (sizeof(brotli_reg_t) << 3u)) {
260
0
    br->val_ &= (((brotli_reg_t)1) << br->bit_pos_) - 1;
261
0
  }
262
0
}
Unexecuted instantiation: decode.c:BrotliBitReaderNormalize
Unexecuted instantiation: state.c:BrotliBitReaderNormalize
Unexecuted instantiation: bit_reader.c:BrotliBitReaderNormalize
263
264
0
static BROTLI_INLINE void BrotliBitReaderUnload(BrotliBitReader* br) {
265
0
  brotli_reg_t unused_bytes = BrotliGetAvailableBits(br) >> 3;
266
0
  brotli_reg_t unused_bits = unused_bytes << 3;
267
0
  br->next_in =
268
0
      (unused_bytes == 0) ? br->next_in : (br->next_in - unused_bytes);
269
0
  br->bit_pos_ -= unused_bits;
270
0
  BrotliBitReaderNormalize(br);
271
0
}
Unexecuted instantiation: decode.c:BrotliBitReaderUnload
Unexecuted instantiation: state.c:BrotliBitReaderUnload
Unexecuted instantiation: bit_reader.c:BrotliBitReaderUnload
272
273
/* Reads the specified number of bits from |br| and advances the bit pos.
274
   Precondition: accumulator MUST contain at least |n_bits|. */
275
static BROTLI_INLINE void BrotliTakeBits(BrotliBitReader* const br,
276
                                         brotli_reg_t n_bits,
277
0
                                         brotli_reg_t* val) {
278
0
  *val = BrotliGetBitsUnmasked(br) & BitMask(n_bits);
279
0
  BROTLI_LOG(("[BrotliTakeBits]  %d %d %d val: %6x\n",
280
0
              (int)BrotliBitReaderGetAvailIn(br), (int)br->bit_pos_,
281
0
              (int)n_bits, (int)*val));
282
0
  BrotliDropBits(br, n_bits);
283
0
}
Unexecuted instantiation: decode.c:BrotliTakeBits
Unexecuted instantiation: state.c:BrotliTakeBits
Unexecuted instantiation: bit_reader.c:BrotliTakeBits
284
285
/* Reads the specified number of bits from |br| and advances the bit pos.
286
   Assumes that there is enough input to perform BrotliFillBitWindow.
287
   Up to 24 bits are allowed to be requested from this method. */
288
static BROTLI_INLINE brotli_reg_t BrotliReadBits24(
289
0
    BrotliBitReader* const br, brotli_reg_t n_bits) {
290
0
  BROTLI_DCHECK(n_bits <= 24);
291
0
  if (BROTLI_64_BITS || (n_bits <= 16)) {
292
0
    brotli_reg_t val;
293
0
    BrotliFillBitWindow(br, n_bits);
294
0
    BrotliTakeBits(br, n_bits, &val);
295
0
    return val;
296
0
  } else {
297
0
    brotli_reg_t low_val;
298
0
    brotli_reg_t high_val;
299
0
    BrotliFillBitWindow(br, 16);
300
0
    BrotliTakeBits(br, 16, &low_val);
301
0
    BrotliFillBitWindow(br, 8);
302
0
    BrotliTakeBits(br, n_bits - 16, &high_val);
303
0
    return low_val | (high_val << 16);
304
0
  }
305
0
}
Unexecuted instantiation: decode.c:BrotliReadBits24
Unexecuted instantiation: state.c:BrotliReadBits24
Unexecuted instantiation: bit_reader.c:BrotliReadBits24
306
307
/* Same as BrotliReadBits24, but allows reading up to 32 bits. */
308
static BROTLI_INLINE brotli_reg_t BrotliReadBits32(
309
0
    BrotliBitReader* const br, brotli_reg_t n_bits) {
310
0
  BROTLI_DCHECK(n_bits <= 32);
311
0
  if (BROTLI_64_BITS || (n_bits <= 16)) {
312
0
    brotli_reg_t val;
313
0
    BrotliFillBitWindow(br, n_bits);
314
0
    BrotliTakeBits(br, n_bits, &val);
315
0
    return val;
316
0
  } else {
317
0
    brotli_reg_t low_val;
318
0
    brotli_reg_t high_val;
319
0
    BrotliFillBitWindow(br, 16);
320
0
    BrotliTakeBits(br, 16, &low_val);
321
0
    BrotliFillBitWindow(br, 16);
322
0
    BrotliTakeBits(br, n_bits - 16, &high_val);
323
0
    return low_val | (high_val << 16);
324
0
  }
325
0
}
Unexecuted instantiation: decode.c:BrotliReadBits32
Unexecuted instantiation: state.c:BrotliReadBits32
Unexecuted instantiation: bit_reader.c:BrotliReadBits32
326
327
/* Tries to read the specified amount of bits. Returns BROTLI_FALSE, if there
328
   is not enough input. |n_bits| MUST be positive.
329
   Up to 24 bits are allowed to be requested from this method. */
330
static BROTLI_INLINE BROTLI_BOOL BrotliSafeReadBits(
331
0
    BrotliBitReader* const br, brotli_reg_t n_bits, brotli_reg_t* val) {
332
0
  BROTLI_DCHECK(n_bits <= 24);
333
0
  while (BrotliGetAvailableBits(br) < n_bits) {
334
0
    if (!BrotliPullByte(br)) {
335
0
      return BROTLI_FALSE;
336
0
    }
337
0
  }
338
0
  BrotliTakeBits(br, n_bits, val);
339
0
  return BROTLI_TRUE;
340
0
}
Unexecuted instantiation: decode.c:BrotliSafeReadBits
Unexecuted instantiation: state.c:BrotliSafeReadBits
Unexecuted instantiation: bit_reader.c:BrotliSafeReadBits
341
342
/* Same as BrotliSafeReadBits, but allows reading up to 32 bits. */
343
static BROTLI_INLINE BROTLI_BOOL BrotliSafeReadBits32(
344
0
    BrotliBitReader* const br, brotli_reg_t n_bits, brotli_reg_t* val) {
345
0
  BROTLI_DCHECK(n_bits <= 32);
346
0
  if (BROTLI_64_BITS || (n_bits <= 24)) {
347
0
    while (BrotliGetAvailableBits(br) < n_bits) {
348
0
      if (!BrotliPullByte(br)) {
349
0
        return BROTLI_FALSE;
350
0
      }
351
0
    }
352
0
    BrotliTakeBits(br, n_bits, val);
353
0
    return BROTLI_TRUE;
354
0
  } else {
355
0
    return BrotliSafeReadBits32Slow(br, n_bits, val);
356
0
  }
357
0
}
Unexecuted instantiation: decode.c:BrotliSafeReadBits32
Unexecuted instantiation: state.c:BrotliSafeReadBits32
Unexecuted instantiation: bit_reader.c:BrotliSafeReadBits32
358
359
/* Advances the bit reader position to the next byte boundary and verifies
360
   that any skipped bits are set to zero. */
361
0
static BROTLI_INLINE BROTLI_BOOL BrotliJumpToByteBoundary(BrotliBitReader* br) {
362
0
  brotli_reg_t pad_bits_count = BrotliGetAvailableBits(br) & 0x7;
363
0
  brotli_reg_t pad_bits = 0;
364
0
  if (pad_bits_count != 0) {
365
0
    BrotliTakeBits(br, pad_bits_count, &pad_bits);
366
0
  }
367
0
  BrotliBitReaderNormalize(br);
368
0
  return TO_BROTLI_BOOL(pad_bits == 0);
369
0
}
Unexecuted instantiation: decode.c:BrotliJumpToByteBoundary
Unexecuted instantiation: state.c:BrotliJumpToByteBoundary
Unexecuted instantiation: bit_reader.c:BrotliJumpToByteBoundary
370
371
0
static BROTLI_INLINE void BrotliDropBytes(BrotliBitReader* br, size_t num) {
372
  /* Check detour is legal: accumulator must to be empty. */
373
0
  BROTLI_DCHECK(br->bit_pos_ == 0);
374
0
  BROTLI_DCHECK(br->val_ == 0);
375
0
  br->next_in += num;
376
0
}
Unexecuted instantiation: decode.c:BrotliDropBytes
Unexecuted instantiation: state.c:BrotliDropBytes
Unexecuted instantiation: bit_reader.c:BrotliDropBytes
377
378
/* Copies remaining input bytes stored in the bit reader to the output. Value
379
   |num| may not be larger than BrotliGetRemainingBytes. The bit reader must be
380
   warmed up again after this. */
381
static BROTLI_INLINE void BrotliCopyBytes(uint8_t* dest,
382
0
                                          BrotliBitReader* br, size_t num) {
383
0
  while (BrotliGetAvailableBits(br) >= 8 && num > 0) {
384
0
    *dest = (uint8_t)BrotliGetBitsUnmasked(br);
385
0
    BrotliDropBits(br, 8);
386
0
    ++dest;
387
0
    --num;
388
0
  }
389
0
  BrotliBitReaderNormalize(br);
390
0
  if (num > 0) {
391
0
    memcpy(dest, br->next_in, num);
392
0
    BrotliDropBytes(br, num);
393
0
  }
394
0
}
Unexecuted instantiation: decode.c:BrotliCopyBytes
Unexecuted instantiation: state.c:BrotliCopyBytes
Unexecuted instantiation: bit_reader.c:BrotliCopyBytes
395
396
0
BROTLI_UNUSED_FUNCTION void BrotliBitReaderSuppressUnusedFunctions(void) {
397
0
  BROTLI_UNUSED(&BrotliBitReaderSuppressUnusedFunctions);
398
0
399
0
  BROTLI_UNUSED(&BrotliBitReaderGetAvailIn);
400
0
  BROTLI_UNUSED(&BrotliBitReaderLoadBits);
401
0
  BROTLI_UNUSED(&BrotliBitReaderRestoreState);
402
0
  BROTLI_UNUSED(&BrotliBitReaderSaveState);
403
0
  BROTLI_UNUSED(&BrotliBitReaderSetInput);
404
0
  BROTLI_UNUSED(&BrotliBitReaderUnload);
405
0
  BROTLI_UNUSED(&BrotliCheckInputAmount);
406
0
  BROTLI_UNUSED(&BrotliCopyBytes);
407
0
  BROTLI_UNUSED(&BrotliFillBitWindow16);
408
0
  BROTLI_UNUSED(&BrotliGet16BitsUnmasked);
409
0
  BROTLI_UNUSED(&BrotliGetBits);
410
0
  BROTLI_UNUSED(&BrotliGetRemainingBytes);
411
0
  BROTLI_UNUSED(&BrotliJumpToByteBoundary);
412
0
  BROTLI_UNUSED(&BrotliReadBits24);
413
0
  BROTLI_UNUSED(&BrotliReadBits32);
414
0
  BROTLI_UNUSED(&BrotliSafeGetBits);
415
0
  BROTLI_UNUSED(&BrotliSafeReadBits);
416
0
  BROTLI_UNUSED(&BrotliSafeReadBits32);
417
0
}
Unexecuted instantiation: decode.c:BrotliBitReaderSuppressUnusedFunctions
Unexecuted instantiation: state.c:BrotliBitReaderSuppressUnusedFunctions
Unexecuted instantiation: bit_reader.c:BrotliBitReaderSuppressUnusedFunctions
418
419
#if defined(__cplusplus) || defined(c_plusplus)
420
}  /* extern "C" */
421
#endif
422
423
#endif  /* BROTLI_DEC_BIT_READER_H_ */