Coverage Report

Created: 2026-08-31 06:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/astc-encoder/Source/astcenc_symbolic_physical.cpp
Line
Count
Source
1
// SPDX-License-Identifier: Apache-2.0
2
// ----------------------------------------------------------------------------
3
// Copyright 2011-2026 Arm Limited
4
//
5
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
6
// use this file except in compliance with the License. You may obtain a copy
7
// of the License at:
8
//
9
//     http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
// License for the specific language governing permissions and limitations
15
// under the License.
16
// ----------------------------------------------------------------------------
17
18
/**
19
 * @brief Functions for converting between symbolic and physical encodings.
20
 */
21
22
#include "astcenc_internal.h"
23
24
#include <cassert>
25
26
/**
27
 * @brief Reverse bits in a byte.
28
 *
29
 * @param p   The value to reverse.
30
  *
31
 * @return The reversed result.
32
 */
33
static inline int bitrev8(int p)
34
76.8k
{
35
76.8k
  p = ((p & 0x0F) << 4) | ((p >> 4) & 0x0F);
36
76.8k
  p = ((p & 0x33) << 2) | ((p >> 2) & 0x33);
37
76.8k
  p = ((p & 0x55) << 1) | ((p >> 1) & 0x55);
38
76.8k
  return p;
39
76.8k
}
40
41
42
/**
43
 * @brief Read up to 8 bits at an arbitrary bit offset.
44
 *
45
 * The stored value is at most 8 bits, but can be stored at an offset of between 0 and 7 bits so may
46
 * span two separate bytes in memory.
47
 *
48
 * @param         bitcount    The number of bits to read.
49
 * @param         bitoffset   The bit offset to read from, between 0 and 7.
50
 * @param[in,out] ptr         The data pointer to read from.
51
 *
52
 * @return The read value.
53
 */
54
static inline int read_bits(
55
  int bitcount,
56
  int bitoffset,
57
  const uint8_t* ptr
58
21.3k
) {
59
21.3k
  int mask = (1 << bitcount) - 1;
60
21.3k
  ptr += bitoffset >> 3;
61
21.3k
  bitoffset &= 7;
62
21.3k
  int value = ptr[0] | (ptr[1] << 8);
63
21.3k
  value >>= bitoffset;
64
21.3k
  value &= mask;
65
21.3k
  return value;
66
21.3k
}
67
68
#if !defined(ASTCENC_DECOMPRESS_ONLY)
69
70
/**
71
 * @brief Write up to 8 bits at an arbitrary bit offset.
72
 *
73
 * The stored value is at most 8 bits, but can be stored at an offset of between 0 and 7 bits so
74
 * may span two separate bytes in memory.
75
 *
76
 * @param         value       The value to write.
77
 * @param         bitcount    The number of bits to write, starting from LSB.
78
 * @param         bitoffset   The bit offset to store at, between 0 and 7.
79
 * @param[in,out] ptr         The data pointer to write to.
80
 */
81
static inline void write_bits(
82
  int value,
83
  int bitcount,
84
  int bitoffset,
85
  uint8_t* ptr
86
9.84k
) {
87
9.84k
  int mask = (1 << bitcount) - 1;
88
9.84k
  value &= mask;
89
9.84k
  ptr += bitoffset >> 3;
90
9.84k
  bitoffset &= 7;
91
9.84k
  value <<= bitoffset;
92
9.84k
  mask <<= bitoffset;
93
9.84k
  mask = ~mask;
94
95
9.84k
  ptr[0] &= mask;
96
9.84k
  ptr[0] |= value;
97
9.84k
  ptr[1] &= mask >> 8;
98
9.84k
  ptr[1] |= value >> 8;
99
9.84k
}
100
101
/* See header for documentation. */
102
void symbolic_to_physical(
103
  const block_size_descriptor& bsd,
104
  const symbolic_compressed_block& scb,
105
  uint8_t pcb[16]
106
2.17k
) {
107
2.17k
  assert(scb.block_type != SYM_BTYPE_ERROR);
108
109
  // Constant color block using UNORM16 colors
110
2.17k
  if (scb.block_type == SYM_BTYPE_CONST_U16)
111
150
  {
112
    // There is currently no attempt to coalesce larger void-extents
113
150
    static const uint8_t cbytes[8] { 0xFC, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
114
1.35k
    for (unsigned int i = 0; i < 8; i++)
115
1.20k
    {
116
1.20k
      pcb[i] = cbytes[i];
117
1.20k
    }
118
119
750
    for (unsigned int i = 0; i < BLOCK_MAX_COMPONENTS; i++)
120
600
    {
121
600
      pcb[2 * i + 8] = scb.constant_color[i] & 0xFF;
122
600
      pcb[2 * i + 9] = (scb.constant_color[i] >> 8) & 0xFF;
123
600
    }
124
125
150
    return;
126
150
  }
127
128
  // Constant color block using FP16 colors
129
2.02k
  if (scb.block_type == SYM_BTYPE_CONST_F16)
130
6
  {
131
    // There is currently no attempt to coalesce larger void-extents
132
6
    static const uint8_t cbytes[8]  { 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
133
54
    for (unsigned int i = 0; i < 8; i++)
134
48
    {
135
48
      pcb[i] = cbytes[i];
136
48
    }
137
138
30
    for (unsigned int i = 0; i < BLOCK_MAX_COMPONENTS; i++)
139
24
    {
140
24
      pcb[2 * i + 8] = scb.constant_color[i] & 0xFF;
141
24
      pcb[2 * i + 9] = (scb.constant_color[i] >> 8) & 0xFF;
142
24
    }
143
144
6
    return;
145
6
  }
146
147
2.02k
  unsigned int partition_count = scb.partition_count;
148
149
  // Compress the weights.
150
  // They are encoded as an ordinary integer-sequence, then bit-reversed
151
2.02k
  uint8_t weightbuf[16] { 0 };
152
153
2.02k
  const auto& bm = bsd.get_block_mode(scb.block_mode);
154
2.02k
  const auto& di = bsd.get_decimation_info(bm.decimation_mode);
155
2.02k
  int weight_count = di.weight_count;
156
2.02k
  quant_method weight_quant_method = bm.get_weight_quant_mode();
157
2.02k
  float weight_quant_levels = static_cast<float>(get_quant_level(weight_quant_method));
158
2.02k
  int is_dual_plane = bm.is_dual_plane;
159
160
2.02k
  const auto& qat = quant_and_xfer_tables[weight_quant_method];
161
162
2.02k
  int real_weight_count = is_dual_plane ? 2 * weight_count : weight_count;
163
164
2.02k
  int bits_for_weights = get_ise_sequence_bitcount(real_weight_count, weight_quant_method);
165
166
2.02k
  uint8_t weights[64];
167
2.02k
  if (is_dual_plane)
168
592
  {
169
10.2k
    for (int i = 0; i < weight_count; i++)
170
9.68k
    {
171
9.68k
      float uqw = static_cast<float>(scb.weights[i]);
172
9.68k
      float qw = (uqw / 64.0f) * (weight_quant_levels - 1.0f);
173
9.68k
      int qwi = static_cast<int>(qw + 0.5f);
174
9.68k
      weights[2 * i] = qat.scramble_map[qwi];
175
176
9.68k
      uqw = static_cast<float>(scb.weights[i + WEIGHTS_PLANE2_OFFSET]);
177
9.68k
      qw = (uqw / 64.0f) * (weight_quant_levels - 1.0f);
178
9.68k
      qwi = static_cast<int>(qw + 0.5f);
179
9.68k
      weights[2 * i + 1] = qat.scramble_map[qwi];
180
9.68k
    }
181
592
  }
182
1.43k
  else
183
1.43k
  {
184
33.9k
    for (int i = 0; i < weight_count; i++)
185
32.5k
    {
186
32.5k
      float uqw = static_cast<float>(scb.weights[i]);
187
32.5k
      float qw = (uqw / 64.0f) * (weight_quant_levels - 1.0f);
188
32.5k
      int qwi = static_cast<int>(qw + 0.5f);
189
32.5k
      weights[i] = qat.scramble_map[qwi];
190
32.5k
    }
191
1.43k
  }
192
193
2.02k
  encode_ise(weight_quant_method, real_weight_count, weights, weightbuf, 0);
194
195
34.3k
  for (int i = 0; i < 16; i++)
196
32.3k
  {
197
32.3k
    pcb[i] = static_cast<uint8_t>(bitrev8(weightbuf[15 - i]));
198
32.3k
  }
199
200
2.02k
  write_bits(scb.block_mode, 11, 0, pcb);
201
2.02k
  write_bits(partition_count - 1, 2, 11, pcb);
202
203
2.02k
  int below_weights_pos = 128 - bits_for_weights;
204
205
  // Encode partition index and color endpoint types for blocks with 2+ partitions
206
2.02k
  if (partition_count > 1)
207
1.15k
  {
208
1.15k
    write_bits(scb.partition_index, 6, 13, pcb);
209
1.15k
    write_bits(scb.partition_index >> 6, PARTITION_INDEX_BITS - 6, 19, pcb);
210
211
1.15k
    if (scb.color_formats_matched)
212
276
    {
213
276
      write_bits(scb.color_formats[0] << 2, 6, 13 + PARTITION_INDEX_BITS, pcb);
214
276
    }
215
878
    else
216
878
    {
217
      // Check endpoint types for each partition to determine the lowest class present
218
878
      int low_class = 4;
219
220
3.17k
      for (unsigned int i = 0; i < partition_count; i++)
221
2.29k
      {
222
2.29k
        int class_of_format = scb.color_formats[i] >> 2;
223
2.29k
        low_class = astc::min(class_of_format, low_class);
224
2.29k
      }
225
226
878
      if (low_class == 3)
227
211
      {
228
211
        low_class = 2;
229
211
      }
230
231
878
      int encoded_type = low_class + 1;
232
878
      int bitpos = 2;
233
234
3.17k
      for (unsigned int i = 0; i < partition_count; i++)
235
2.29k
      {
236
2.29k
        int classbit_of_format = (scb.color_formats[i] >> 2) - low_class;
237
2.29k
        encoded_type |= classbit_of_format << bitpos;
238
2.29k
        bitpos++;
239
2.29k
      }
240
241
3.17k
      for (unsigned int i = 0; i < partition_count; i++)
242
2.29k
      {
243
2.29k
        int lowbits_of_format = scb.color_formats[i] & 3;
244
2.29k
        encoded_type |= lowbits_of_format << bitpos;
245
2.29k
        bitpos += 2;
246
2.29k
      }
247
248
878
      int encoded_type_lowpart = encoded_type & 0x3F;
249
878
      int encoded_type_highpart = encoded_type >> 6;
250
878
      int encoded_type_highpart_size = (3 * partition_count) - 4;
251
878
      int encoded_type_highpart_pos = 128 - bits_for_weights - encoded_type_highpart_size;
252
878
      write_bits(encoded_type_lowpart, 6, 13 + PARTITION_INDEX_BITS, pcb);
253
878
      write_bits(encoded_type_highpart, encoded_type_highpart_size, encoded_type_highpart_pos, pcb);
254
878
      below_weights_pos -= encoded_type_highpart_size;
255
878
    }
256
1.15k
  }
257
868
  else
258
868
  {
259
868
    write_bits(scb.color_formats[0], 4, 13, pcb);
260
868
  }
261
262
  // In dual-plane mode, encode the color component of the second plane of weights
263
2.02k
  if (is_dual_plane)
264
592
  {
265
592
    write_bits(scb.plane2_component, 2, below_weights_pos - 2, pcb);
266
592
  }
267
268
  // Encode the color components
269
2.02k
  uint8_t values_to_encode[32];
270
2.02k
  int valuecount_to_encode = 0;
271
272
2.02k
  const uint8_t* pack_table = color_uquant_to_scrambled_pquant_tables[scb.quant_mode - QUANT_6];
273
6.01k
  for (unsigned int i = 0; i < scb.partition_count; i++)
274
3.98k
  {
275
3.98k
    int vals = 2 * (scb.color_formats[i] >> 2) + 2;
276
3.98k
    assert(vals <= 8);
277
24.5k
    for (int j = 0; j < vals; j++)
278
20.5k
    {
279
20.5k
      values_to_encode[j + valuecount_to_encode] = pack_table[scb.color_values[i][j]];
280
20.5k
    }
281
3.98k
    valuecount_to_encode += vals;
282
3.98k
  }
283
284
2.02k
  encode_ise(scb.get_color_quant_mode(), valuecount_to_encode, values_to_encode, pcb,
285
2.02k
             scb.partition_count == 1 ? 17 : 19 + PARTITION_INDEX_BITS);
286
2.02k
}
287
288
#endif
289
290
/* See header for documentation. */
291
void physical_to_symbolic(
292
  const block_size_descriptor& bsd,
293
  const uint8_t pcb[16],
294
  symbolic_compressed_block& scb
295
4.33k
) {
296
4.33k
  uint8_t bswapped[16];
297
298
4.33k
  scb.block_type = SYM_BTYPE_NONCONST;
299
300
  // Extract header fields
301
4.33k
  int block_mode = read_bits(11, 0, pcb);
302
4.33k
  if ((block_mode & 0x1FF) == 0x1FC)
303
925
  {
304
    // Constant color block
305
306
    // Check what format the data has
307
925
    if (block_mode & 0x200)
308
557
    {
309
557
      scb.block_type = SYM_BTYPE_CONST_F16;
310
557
    }
311
368
    else
312
368
    {
313
368
      scb.block_type = SYM_BTYPE_CONST_U16;
314
368
    }
315
316
925
    scb.partition_count = 0;
317
4.62k
    for (int i = 0; i < 4; i++)
318
3.70k
    {
319
3.70k
      scb.constant_color[i] = pcb[2 * i + 8] | (pcb[2 * i + 9] << 8);
320
3.70k
    }
321
322
    // Additionally, check that the void-extent
323
925
    if (bsd.dim_z == 1)
324
819
    {
325
      // 2D void-extent
326
819
      int rsvbits = read_bits(2, 10, pcb);
327
819
      if (rsvbits != 3)
328
49
      {
329
49
        scb.block_type = SYM_BTYPE_ERROR;
330
49
        return;
331
49
      }
332
333
      // Low values span 3 bytes so need two read_bits calls
334
770
      int vx_low_s = read_bits(8, 12, pcb) | (read_bits(5, 12 + 8, pcb) << 8);
335
770
      int vx_high_s = read_bits(13, 25, pcb);
336
770
      int vx_low_t = read_bits(8, 38, pcb) | (read_bits(5, 38 + 8, pcb) << 8);
337
770
      int vx_high_t = read_bits(13, 51, pcb);
338
339
770
      int all_ones = vx_low_s == 0x1FFF && vx_high_s == 0x1FFF &&
340
179
                     vx_low_t == 0x1FFF && vx_high_t == 0x1FFF;
341
342
770
      if ((vx_low_s >= vx_high_s || vx_low_t >= vx_high_t) && !all_ones)
343
358
      {
344
358
        scb.block_type = SYM_BTYPE_ERROR;
345
358
        return;
346
358
      }
347
770
    }
348
106
    else
349
106
    {
350
      // 3D void-extent
351
106
      int vx_low_s = read_bits(9, 10, pcb);
352
106
      int vx_high_s = read_bits(9, 19, pcb);
353
106
      int vx_low_t = read_bits(9, 28, pcb);
354
106
      int vx_high_t = read_bits(9, 37, pcb);
355
106
      int vx_low_r = read_bits(9, 46, pcb);
356
106
      int vx_high_r = read_bits(9, 55, pcb);
357
358
106
      int all_ones = vx_low_s == 0x1FF && vx_high_s == 0x1FF &&
359
56
                     vx_low_t == 0x1FF && vx_high_t == 0x1FF &&
360
25
                     vx_low_r == 0x1FF && vx_high_r == 0x1FF;
361
362
106
      if ((vx_low_s >= vx_high_s || vx_low_t >= vx_high_t || vx_low_r >= vx_high_r) && !all_ones)
363
102
      {
364
102
        scb.block_type = SYM_BTYPE_ERROR;
365
102
        return;
366
102
      }
367
106
    }
368
369
416
    return;
370
925
  }
371
372
3.41k
  unsigned int packed_index = bsd.block_mode_packed_index[block_mode];
373
3.41k
  if (packed_index == BLOCK_BAD_BLOCK_MODE)
374
629
  {
375
629
    scb.block_type = SYM_BTYPE_ERROR;
376
629
    return;
377
629
  }
378
379
2.78k
  const auto& bm = bsd.get_block_mode(block_mode);
380
2.78k
  const auto& di = bsd.get_decimation_info(bm.decimation_mode);
381
382
2.78k
  int weight_count = di.weight_count;
383
2.78k
  promise(weight_count > 0);
384
385
2.78k
  quant_method weight_quant_method = static_cast<quant_method>(bm.quant_mode);
386
2.78k
  int is_dual_plane = bm.is_dual_plane;
387
388
2.78k
  int real_weight_count = is_dual_plane ? 2 * weight_count : weight_count;
389
390
2.78k
  int partition_count = read_bits(2, 11, pcb) + 1;
391
2.78k
  promise(partition_count > 0);
392
393
2.78k
  scb.block_mode = static_cast<uint16_t>(block_mode);
394
2.78k
  scb.partition_count = static_cast<uint8_t>(partition_count);
395
396
47.3k
  for (int i = 0; i < 16; i++)
397
44.5k
  {
398
44.5k
    bswapped[i] = static_cast<uint8_t>(bitrev8(pcb[15 - i]));
399
44.5k
  }
400
401
2.78k
  int bits_for_weights = get_ise_sequence_bitcount(real_weight_count, weight_quant_method);
402
403
2.78k
  int below_weights_pos = 128 - bits_for_weights;
404
405
2.78k
  uint8_t indices[64];
406
2.78k
  const auto& qat = quant_and_xfer_tables[weight_quant_method];
407
408
2.78k
  decode_ise(weight_quant_method, real_weight_count, bswapped, indices, 0);
409
410
2.78k
  if (is_dual_plane)
411
855
  {
412
12.9k
    for (int i = 0; i < weight_count; i++)
413
12.0k
    {
414
12.0k
      scb.weights[i] = qat.unscramble_and_unquant_map[indices[2 * i]];
415
12.0k
      scb.weights[i + WEIGHTS_PLANE2_OFFSET] = qat.unscramble_and_unquant_map[indices[2 * i + 1]];
416
12.0k
    }
417
855
  }
418
1.92k
  else
419
1.92k
  {
420
37.9k
    for (int i = 0; i < weight_count; i++)
421
36.0k
    {
422
36.0k
      scb.weights[i] = qat.unscramble_and_unquant_map[indices[i]];
423
36.0k
    }
424
1.92k
  }
425
426
2.78k
  if (is_dual_plane && partition_count == 4)
427
86
  {
428
86
    scb.block_type = SYM_BTYPE_ERROR;
429
86
    return;
430
86
  }
431
432
2.69k
  scb.color_formats_matched = 0;
433
434
  // Determine the format of each endpoint pair
435
2.69k
  int color_formats[BLOCK_MAX_PARTITIONS];
436
2.69k
  int encoded_type_highpart_size = 0;
437
2.69k
  if (partition_count == 1)
438
296
  {
439
296
    color_formats[0] = read_bits(4, 13, pcb);
440
296
    scb.partition_index = 0;
441
296
  }
442
2.40k
  else
443
2.40k
  {
444
2.40k
    encoded_type_highpart_size = (3 * partition_count) - 4;
445
2.40k
    below_weights_pos -= encoded_type_highpart_size;
446
2.40k
    int encoded_type = read_bits(6, 13 + PARTITION_INDEX_BITS, pcb) |
447
2.40k
                      (read_bits(encoded_type_highpart_size, below_weights_pos, pcb) << 6);
448
2.40k
    int baseclass = encoded_type & 0x3;
449
2.40k
    if (baseclass == 0)
450
1.48k
    {
451
6.31k
      for (int i = 0; i < partition_count; i++)
452
4.83k
      {
453
4.83k
        color_formats[i] = (encoded_type >> 2) & 0xF;
454
4.83k
      }
455
456
1.48k
      below_weights_pos += encoded_type_highpart_size;
457
1.48k
      scb.color_formats_matched = 1;
458
1.48k
      encoded_type_highpart_size = 0;
459
1.48k
    }
460
922
    else
461
922
    {
462
922
      int bitpos = 2;
463
922
      baseclass--;
464
465
3.33k
      for (int i = 0; i < partition_count; i++)
466
2.41k
      {
467
2.41k
        color_formats[i] = (((encoded_type >> bitpos) & 1) + baseclass) << 2;
468
2.41k
        bitpos++;
469
2.41k
      }
470
471
3.33k
      for (int i = 0; i < partition_count; i++)
472
2.41k
      {
473
2.41k
        color_formats[i] |= (encoded_type >> bitpos) & 3;
474
2.41k
        bitpos += 2;
475
2.41k
      }
476
922
    }
477
2.40k
    scb.partition_index = static_cast<uint16_t>(read_bits(10, 13, pcb));
478
479
    // Reject blocks selecting a partitioning that is not present in this
480
    // block size descriptor. A SELF_DECOMPRESS_ONLY context drops the
481
    // partitionings its compressor never emits, so a texture compressed
482
    // with a different context can reference an inactive entry. This is an
483
    // API contract break from the application, and should not happen in
484
    // valid usage.
485
2.40k
    if (bsd.partitioning_packed_index[partition_count - 2][scb.partition_index] == BLOCK_BAD_PARTITIONING)
486
0
    {
487
0
      scb.block_type = SYM_BTYPE_ERROR;
488
0
      return;
489
0
    }
490
2.40k
  }
491
492
10.2k
  for (int i = 0; i < partition_count; i++)
493
7.54k
  {
494
7.54k
    scb.color_formats[i] = static_cast<uint8_t>(color_formats[i]);
495
7.54k
  }
496
497
  // Determine number of color endpoint integers
498
2.69k
  int color_integer_count = 0;
499
10.2k
  for (int i = 0; i < partition_count; i++)
500
7.54k
  {
501
7.54k
    int endpoint_class = color_formats[i] >> 2;
502
7.54k
    color_integer_count += (endpoint_class + 1) * 2;
503
7.54k
  }
504
505
2.69k
  if (color_integer_count > 18)
506
96
  {
507
96
    scb.block_type = SYM_BTYPE_ERROR;
508
96
    return;
509
96
  }
510
511
  // Determine the color endpoint format to use
512
2.60k
  static const int color_bits_arr[5] { -1, 115 - 4, 113 - 4 - PARTITION_INDEX_BITS, 113 - 4 - PARTITION_INDEX_BITS, 113 - 4 - PARTITION_INDEX_BITS };
513
2.60k
  int color_bits = color_bits_arr[partition_count] - bits_for_weights - encoded_type_highpart_size;
514
2.60k
  if (is_dual_plane)
515
764
  {
516
764
    color_bits -= 2;
517
764
  }
518
519
2.60k
  if (color_bits < 0)
520
69
  {
521
69
    color_bits = 0;
522
69
  }
523
524
2.60k
  int color_quant_level = quant_mode_table[color_integer_count >> 1][color_bits];
525
2.60k
  if (color_quant_level < QUANT_6)
526
126
  {
527
126
    scb.block_type = SYM_BTYPE_ERROR;
528
126
    return;
529
126
  }
530
531
  // Unpack the integer color values and assign to endpoints
532
2.47k
  scb.quant_mode = static_cast<quant_method>(color_quant_level);
533
534
2.47k
  uint8_t values_to_decode[32];
535
2.47k
  decode_ise(static_cast<quant_method>(color_quant_level), color_integer_count, pcb,
536
2.47k
             values_to_decode, (partition_count == 1 ? 17 : 19 + PARTITION_INDEX_BITS));
537
538
2.47k
  int valuecount_to_decode = 0;
539
2.47k
  const uint8_t* unpack_table = color_scrambled_pquant_to_uquant_tables[scb.quant_mode - QUANT_6];
540
9.29k
  for (int i = 0; i < partition_count; i++)
541
6.81k
  {
542
6.81k
    int vals = 2 * (color_formats[i] >> 2) + 2;
543
39.9k
    for (int j = 0; j < vals; j++)
544
33.1k
    {
545
33.1k
      scb.color_values[i][j] = unpack_table[values_to_decode[j + valuecount_to_decode]];
546
33.1k
    }
547
6.81k
    valuecount_to_decode += vals;
548
6.81k
  }
549
550
  // Fetch component for second-plane in the case of dual plane of weights.
551
2.47k
  scb.plane2_component = -1;
552
2.47k
  if (is_dual_plane)
553
682
  {
554
682
    scb.plane2_component = static_cast<int8_t>(read_bits(2, below_weights_pos - 2, pcb));
555
682
  }
556
2.47k
}