summaryrefslogtreecommitdiffstats
path: root/third_party/aom/av1/common/txb_common.c
blob: c5b91e991c1531c784d669d3e060fdb12dc85dd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/*
 * Copyright (c) 2017, Alliance for Open Media. All rights reserved
 *
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */
#include "aom/aom_integer.h"
#include "av1/common/onyxc_int.h"
#include "av1/common/txb_common.h"

const int16_t av1_coeff_band_4x4[16] = { 0, 1, 2,  3,  4,  5,  6,  7,
                                         8, 9, 10, 11, 12, 13, 14, 15 };

const int16_t av1_coeff_band_8x8[64] = {
  0,  1,  2,  2,  3,  3,  4,  4,  5,  6,  2,  2,  3,  3,  4,  4,
  7,  7,  8,  8,  9,  9,  10, 10, 7,  7,  8,  8,  9,  9,  10, 10,
  11, 11, 12, 12, 13, 13, 14, 14, 11, 11, 12, 12, 13, 13, 14, 14,
  15, 15, 16, 16, 17, 17, 18, 18, 15, 15, 16, 16, 17, 17, 18, 18,
};

const int16_t av1_coeff_band_16x16[256] = {
  0,  1,  4,  4,  7,  7,  7,  7,  8,  8,  8,  8,  9,  9,  9,  9,  2,  3,  4,
  4,  7,  7,  7,  7,  8,  8,  8,  8,  9,  9,  9,  9,  5,  5,  6,  6,  7,  7,
  7,  7,  8,  8,  8,  8,  9,  9,  9,  9,  5,  5,  6,  6,  7,  7,  7,  7,  8,
  8,  8,  8,  9,  9,  9,  9,  10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12,
  13, 13, 13, 13, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13,
  13, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 10, 10,
  10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15,
  15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 14, 14, 14, 14, 15, 15, 15, 15,
  16, 16, 16, 16, 17, 17, 17, 17, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16,
  16, 17, 17, 17, 17, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17,
  17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 18,
  18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 18, 18, 18, 18,
  19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 18, 18, 18, 18, 19, 19, 19,
  19, 20, 20, 20, 20, 21, 21, 21, 21,
};

const int16_t av1_coeff_band_32x32[1024] = {
  0,  1,  4,  4,  7,  7,  7,  7,  10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11,
  11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 2,  3,  4,  4,  7,  7,
  7,  7,  10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 12,
  12, 12, 12, 12, 12, 12, 12, 5,  5,  6,  6,  7,  7,  7,  7,  10, 10, 10, 10,
  10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12,
  12, 5,  5,  6,  6,  7,  7,  7,  7,  10, 10, 10, 10, 10, 10, 10, 10, 11, 11,
  11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 8,  8,  8,  8,  9,
  9,  9,  9,  10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11,
  12, 12, 12, 12, 12, 12, 12, 12, 8,  8,  8,  8,  9,  9,  9,  9,  10, 10, 10,
  10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12,
  12, 12, 8,  8,  8,  8,  9,  9,  9,  9,  10, 10, 10, 10, 10, 10, 10, 10, 11,
  11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 8,  8,  8,  8,
  9,  9,  9,  9,  10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11,
  11, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14,
  14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16,
  16, 16, 16, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14,
  15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 13, 13, 13,
  13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15,
  15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 13, 13, 13, 13, 13, 13, 13, 13, 14,
  14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16,
  16, 16, 16, 16, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14,
  14, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 13, 13,
  13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15,
  15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 13, 13, 13, 13, 13, 13, 13, 13,
  14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16,
  16, 16, 16, 16, 16, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14,
  14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17,
  17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
  19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 17, 17, 17, 17, 17, 17, 17,
  17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20,
  20, 20, 20, 20, 20, 20, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18,
  18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20,
  17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19,
  19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 17, 17, 17, 17, 17, 17,
  17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20,
  20, 20, 20, 20, 20, 20, 20, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18,
  18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20,
  20, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19,
  19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 17, 17, 17, 17, 17,
  17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,
  20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22,
  22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24,
  24, 24, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23,
  23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 21, 21, 21, 21,
  21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23,
  23, 24, 24, 24, 24, 24, 24, 24, 24, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22,
  22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24,
  24, 24, 24, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
  23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 21, 21, 21,
  21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23,
  23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 21, 21, 21, 21, 21, 21, 21, 21, 22,
  22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24,
  24, 24, 24, 24, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22,
  22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24,
};

#if LV_MAP_PROB
void av1_init_txb_probs(FRAME_CONTEXT *fc) {
  TX_SIZE tx_size;
  int plane, ctx, level;

  // Update probability models for transform block skip flag
  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
    for (ctx = 0; ctx < TXB_SKIP_CONTEXTS; ++ctx) {
      fc->txb_skip_cdf[tx_size][ctx][0] =
          AOM_ICDF(128 * (aom_cdf_prob)fc->txb_skip[tx_size][ctx]);
      fc->txb_skip_cdf[tx_size][ctx][1] = AOM_ICDF(32768);
      fc->txb_skip_cdf[tx_size][ctx][2] = 0;
    }
  }

  for (plane = 0; plane < PLANE_TYPES; ++plane) {
    for (ctx = 0; ctx < DC_SIGN_CONTEXTS; ++ctx) {
      fc->dc_sign_cdf[plane][ctx][0] =
          AOM_ICDF(128 * (aom_cdf_prob)fc->dc_sign[plane][ctx]);
      fc->dc_sign_cdf[plane][ctx][1] = AOM_ICDF(32768);
      fc->dc_sign_cdf[plane][ctx][2] = 0;
    }
  }

  // Update probability models for non-zero coefficient map and eob flag.
  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
    for (plane = 0; plane < PLANE_TYPES; ++plane) {
      for (level = 0; level < NUM_BASE_LEVELS; ++level) {
        for (ctx = 0; ctx < COEFF_BASE_CONTEXTS; ++ctx) {
          fc->coeff_base_cdf[tx_size][plane][level][ctx][0] = AOM_ICDF(
              128 * (aom_cdf_prob)fc->coeff_base[tx_size][plane][level][ctx]);
          fc->coeff_base_cdf[tx_size][plane][level][ctx][1] = AOM_ICDF(32768);
          fc->coeff_base_cdf[tx_size][plane][level][ctx][2] = 0;
        }
      }
    }
  }

  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
    for (plane = 0; plane < PLANE_TYPES; ++plane) {
      for (ctx = 0; ctx < SIG_COEF_CONTEXTS; ++ctx) {
        fc->nz_map_cdf[tx_size][plane][ctx][0] =
            AOM_ICDF(128 * (aom_cdf_prob)fc->nz_map[tx_size][plane][ctx]);
        fc->nz_map_cdf[tx_size][plane][ctx][1] = AOM_ICDF(32768);
        fc->nz_map_cdf[tx_size][plane][ctx][2] = 0;
      }

      for (ctx = 0; ctx < EOB_COEF_CONTEXTS; ++ctx) {
        fc->eob_flag_cdf[tx_size][plane][ctx][0] =
            AOM_ICDF(128 * (aom_cdf_prob)fc->eob_flag[tx_size][plane][ctx]);
        fc->eob_flag_cdf[tx_size][plane][ctx][1] = AOM_ICDF(32768);
        fc->eob_flag_cdf[tx_size][plane][ctx][2] = 0;
      }
    }
  }

  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
    for (plane = 0; plane < PLANE_TYPES; ++plane) {
      for (ctx = 0; ctx < LEVEL_CONTEXTS; ++ctx) {
        fc->coeff_lps_cdf[tx_size][plane][ctx][0] =
            AOM_ICDF(128 * (aom_cdf_prob)fc->coeff_lps[tx_size][plane][ctx]);
        fc->coeff_lps_cdf[tx_size][plane][ctx][1] = AOM_ICDF(32768);
        fc->coeff_lps_cdf[tx_size][plane][ctx][2] = 0;
      }
#if BR_NODE
      for (int br = 0; br < BASE_RANGE_SETS; ++br) {
        for (ctx = 0; ctx < LEVEL_CONTEXTS; ++ctx) {
          fc->coeff_br_cdf[tx_size][plane][br][ctx][0] = AOM_ICDF(
              128 * (aom_cdf_prob)fc->coeff_br[tx_size][plane][br][ctx]);
          fc->coeff_br_cdf[tx_size][plane][br][ctx][1] = AOM_ICDF(32768);
          fc->coeff_br_cdf[tx_size][plane][br][ctx][2] = 0;
        }
      }
#endif  // BR_NODE
    }
  }
#if CONFIG_CTX1D
  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
    for (plane = 0; plane < PLANE_TYPES; ++plane) {
      for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class) {
        fc->eob_mode_cdf[tx_size][plane][tx_class][0] = AOM_ICDF(
            128 * (aom_cdf_prob)fc->eob_mode[tx_size][plane][tx_class]);
        fc->eob_mode_cdf[tx_size][plane][tx_class][1] = AOM_ICDF(32768);
        fc->eob_mode_cdf[tx_size][plane][tx_class][2] = 0;
      }
    }
  }
  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
    for (plane = 0; plane < PLANE_TYPES; ++plane) {
      for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class) {
        for (ctx = 0; ctx < EMPTY_LINE_CONTEXTS; ++ctx) {
          fc->empty_line_cdf[tx_size][plane][tx_class][ctx][0] = AOM_ICDF(
              128 *
              (aom_cdf_prob)fc->empty_line[tx_size][plane][tx_class][ctx]);
          fc->empty_line_cdf[tx_size][plane][tx_class][ctx][1] =
              AOM_ICDF(32768);
          fc->empty_line_cdf[tx_size][plane][tx_class][ctx][2] = 0;
        }
      }
    }
  }
  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
    for (plane = 0; plane < PLANE_TYPES; ++plane) {
      for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class) {
        for (ctx = 0; ctx < HV_EOB_CONTEXTS; ++ctx) {
          fc->hv_eob_cdf[tx_size][plane][tx_class][ctx][0] = AOM_ICDF(
              128 * (aom_cdf_prob)fc->hv_eob[tx_size][plane][tx_class][ctx]);
          fc->hv_eob_cdf[tx_size][plane][tx_class][ctx][1] = AOM_ICDF(32768);
          fc->hv_eob_cdf[tx_size][plane][tx_class][ctx][2] = 0;
        }
      }
    }
  }
#endif  // CONFIG_CTX1D
}
#endif  // LV_MAP_PROB

void av1_adapt_txb_probs(AV1_COMMON *cm, unsigned int count_sat,
                         unsigned int update_factor) {
  FRAME_CONTEXT *fc = cm->fc;
  const FRAME_CONTEXT *pre_fc = cm->pre_fc;
  const FRAME_COUNTS *counts = &cm->counts;
  TX_SIZE tx_size;
  int plane, ctx, level;

  // Update probability models for transform block skip flag
  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size)
    for (ctx = 0; ctx < TXB_SKIP_CONTEXTS; ++ctx)
      fc->txb_skip[tx_size][ctx] = mode_mv_merge_probs(
          pre_fc->txb_skip[tx_size][ctx], counts->txb_skip[tx_size][ctx]);

  for (plane = 0; plane < PLANE_TYPES; ++plane)
    for (ctx = 0; ctx < DC_SIGN_CONTEXTS; ++ctx)
      fc->dc_sign[plane][ctx] = mode_mv_merge_probs(
          pre_fc->dc_sign[plane][ctx], counts->dc_sign[plane][ctx]);

  // Update probability models for non-zero coefficient map and eob flag.
  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size)
    for (plane = 0; plane < PLANE_TYPES; ++plane)
      for (level = 0; level < NUM_BASE_LEVELS; ++level)
        for (ctx = 0; ctx < COEFF_BASE_CONTEXTS; ++ctx)
          fc->coeff_base[tx_size][plane][level][ctx] =
              merge_probs(pre_fc->coeff_base[tx_size][plane][level][ctx],
                          counts->coeff_base[tx_size][plane][level][ctx],
                          count_sat, update_factor);

  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
    for (plane = 0; plane < PLANE_TYPES; ++plane) {
      for (ctx = 0; ctx < SIG_COEF_CONTEXTS; ++ctx) {
        fc->nz_map[tx_size][plane][ctx] = merge_probs(
            pre_fc->nz_map[tx_size][plane][ctx],
            counts->nz_map[tx_size][plane][ctx], count_sat, update_factor);
      }

      for (ctx = 0; ctx < EOB_COEF_CONTEXTS; ++ctx) {
        fc->eob_flag[tx_size][plane][ctx] = merge_probs(
            pre_fc->eob_flag[tx_size][plane][ctx],
            counts->eob_flag[tx_size][plane][ctx], count_sat, update_factor);
      }
    }
  }

  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
    for (plane = 0; plane < PLANE_TYPES; ++plane) {
      for (ctx = 0; ctx < LEVEL_CONTEXTS; ++ctx) {
        fc->coeff_lps[tx_size][plane][ctx] = merge_probs(
            pre_fc->coeff_lps[tx_size][plane][ctx],
            counts->coeff_lps[tx_size][plane][ctx], count_sat, update_factor);
      }
#if BR_NODE
      for (int br = 0; br < BASE_RANGE_SETS; ++br) {
        for (ctx = 0; ctx < LEVEL_CONTEXTS; ++ctx) {
          fc->coeff_br[tx_size][plane][br][ctx] =
              merge_probs(pre_fc->coeff_br[tx_size][plane][br][ctx],
                          counts->coeff_br[tx_size][plane][br][ctx], count_sat,
                          update_factor);
        }
      }
#endif  // BR_NODE
    }
  }
#if CONFIG_CTX1D
  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
    for (plane = 0; plane < PLANE_TYPES; ++plane)
      for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class)
        fc->eob_mode[tx_size][plane][tx_class] =
            merge_probs(pre_fc->eob_mode[tx_size][plane][tx_class],
                        counts->eob_mode[tx_size][plane][tx_class], count_sat,
                        update_factor);
  }
  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
    for (plane = 0; plane < PLANE_TYPES; ++plane)
      for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class)
        for (ctx = 0; ctx < EMPTY_LINE_CONTEXTS; ++ctx)
          fc->empty_line[tx_size][plane][tx_class][ctx] =
              merge_probs(pre_fc->empty_line[tx_size][plane][tx_class][ctx],
                          counts->empty_line[tx_size][plane][tx_class][ctx],
                          count_sat, update_factor);
  }
  for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
    for (plane = 0; plane < PLANE_TYPES; ++plane)
      for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class)
        for (ctx = 0; ctx < HV_EOB_CONTEXTS; ++ctx)
          fc->hv_eob[tx_size][plane][tx_class][ctx] =
              merge_probs(pre_fc->hv_eob[tx_size][plane][tx_class][ctx],
                          counts->hv_eob[tx_size][plane][tx_class][ctx],
                          count_sat, update_factor);
  }
#endif
}

void av1_init_lv_map(AV1_COMMON *cm) {
  LV_MAP_CTX_TABLE *coeff_ctx_table = &cm->coeff_ctx_table;
  for (int row = 0; row < 2; ++row) {
    for (int col = 0; col < 2; ++col) {
      for (int sig_mag = 0; sig_mag < 2; ++sig_mag) {
        for (int count = 0; count < BASE_CONTEXT_POSITION_NUM + 1; ++count) {
          coeff_ctx_table->base_ctx_table[row][col][sig_mag][count] =
              get_base_ctx_from_count_mag(row, col, count, sig_mag);
        }
      }
    }
  }
}