Coverage Report

Created: 2023-06-07 06:31

/src/aom/av1/common/txb_common.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2017, Alliance for Open Media. All rights reserved
3
 *
4
 * This source code is subject to the terms of the BSD 2 Clause License and
5
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6
 * was not distributed with this source code in the LICENSE file, you can
7
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8
 * Media Patent License 1.0 was not distributed with this source code in the
9
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10
 */
11
12
#ifndef AOM_AV1_COMMON_TXB_COMMON_H_
13
#define AOM_AV1_COMMON_TXB_COMMON_H_
14
15
#include "av1/common/av1_common_int.h"
16
17
extern const int16_t av1_eob_group_start[12];
18
extern const int16_t av1_eob_offset_bits[12];
19
20
extern const int8_t *av1_nz_map_ctx_offset[TX_SIZES_ALL];
21
22
typedef struct txb_ctx {
23
  int txb_skip_ctx;
24
  int dc_sign_ctx;
25
} TXB_CTX;
26
27
static const int base_level_count_to_index[13] = {
28
  0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
29
};
30
31
static const TX_CLASS tx_type_to_class[TX_TYPES] = {
32
  TX_CLASS_2D,     // DCT_DCT
33
  TX_CLASS_2D,     // ADST_DCT
34
  TX_CLASS_2D,     // DCT_ADST
35
  TX_CLASS_2D,     // ADST_ADST
36
  TX_CLASS_2D,     // FLIPADST_DCT
37
  TX_CLASS_2D,     // DCT_FLIPADST
38
  TX_CLASS_2D,     // FLIPADST_FLIPADST
39
  TX_CLASS_2D,     // ADST_FLIPADST
40
  TX_CLASS_2D,     // FLIPADST_ADST
41
  TX_CLASS_2D,     // IDTX
42
  TX_CLASS_VERT,   // V_DCT
43
  TX_CLASS_HORIZ,  // H_DCT
44
  TX_CLASS_VERT,   // V_ADST
45
  TX_CLASS_HORIZ,  // H_ADST
46
  TX_CLASS_VERT,   // V_FLIPADST
47
  TX_CLASS_HORIZ,  // H_FLIPADST
48
};
49
50
35.2M
static INLINE int get_txb_bhl(TX_SIZE tx_size) {
51
35.2M
  tx_size = av1_get_adjusted_tx_size(tx_size);
52
35.2M
  return tx_size_high_log2[tx_size];
53
35.2M
}
decodetxb.c:get_txb_bhl
Line
Count
Source
50
35.2M
static INLINE int get_txb_bhl(TX_SIZE tx_size) {
51
35.2M
  tx_size = av1_get_adjusted_tx_size(tx_size);
52
35.2M
  return tx_size_high_log2[tx_size];
53
35.2M
}
Unexecuted instantiation: entropy.c:get_txb_bhl
Unexecuted instantiation: entropymode.c:get_txb_bhl
Unexecuted instantiation: txb_common.c:get_txb_bhl
54
55
35.4M
static INLINE int get_txb_wide(TX_SIZE tx_size) {
56
35.4M
  tx_size = av1_get_adjusted_tx_size(tx_size);
57
35.4M
  return tx_size_wide[tx_size];
58
35.4M
}
decodetxb.c:get_txb_wide
Line
Count
Source
55
35.4M
static INLINE int get_txb_wide(TX_SIZE tx_size) {
56
35.4M
  tx_size = av1_get_adjusted_tx_size(tx_size);
57
35.4M
  return tx_size_wide[tx_size];
58
35.4M
}
Unexecuted instantiation: entropy.c:get_txb_wide
Unexecuted instantiation: entropymode.c:get_txb_wide
Unexecuted instantiation: txb_common.c:get_txb_wide
59
60
35.0M
static INLINE int get_txb_high(TX_SIZE tx_size) {
61
35.0M
  tx_size = av1_get_adjusted_tx_size(tx_size);
62
35.0M
  return tx_size_high[tx_size];
63
35.0M
}
decodetxb.c:get_txb_high
Line
Count
Source
60
35.0M
static INLINE int get_txb_high(TX_SIZE tx_size) {
61
35.0M
  tx_size = av1_get_adjusted_tx_size(tx_size);
62
35.0M
  return tx_size_high[tx_size];
63
35.0M
}
Unexecuted instantiation: entropy.c:get_txb_high
Unexecuted instantiation: entropymode.c:get_txb_high
Unexecuted instantiation: txb_common.c:get_txb_high
64
65
34.8M
static INLINE uint8_t *set_levels(uint8_t *const levels_buf, const int height) {
66
34.8M
  return levels_buf + TX_PAD_TOP * (height + TX_PAD_HOR);
67
34.8M
}
decodetxb.c:set_levels
Line
Count
Source
65
34.8M
static INLINE uint8_t *set_levels(uint8_t *const levels_buf, const int height) {
66
34.8M
  return levels_buf + TX_PAD_TOP * (height + TX_PAD_HOR);
67
34.8M
}
Unexecuted instantiation: entropy.c:set_levels
Unexecuted instantiation: entropymode.c:set_levels
Unexecuted instantiation: txb_common.c:set_levels
68
69
834M
static INLINE int get_padded_idx(const int idx, const int bhl) {
70
834M
  return idx + ((idx >> bhl) << TX_PAD_HOR_LOG2);
71
834M
}
decodetxb.c:get_padded_idx
Line
Count
Source
69
834M
static INLINE int get_padded_idx(const int idx, const int bhl) {
70
834M
  return idx + ((idx >> bhl) << TX_PAD_HOR_LOG2);
71
834M
}
Unexecuted instantiation: entropy.c:get_padded_idx
Unexecuted instantiation: entropymode.c:get_padded_idx
Unexecuted instantiation: txb_common.c:get_padded_idx
72
73
static INLINE int get_br_ctx_2d(const uint8_t *const levels,
74
                                const int c,  // raster order
75
14.7M
                                const int bhl) {
76
14.7M
  assert(c > 0);
77
0
  const int col = c >> bhl;
78
14.7M
  const int row = c - (col << bhl);
79
14.7M
  const int stride = (1 << bhl) + TX_PAD_HOR;
80
14.7M
  const int pos = col * stride + row;
81
14.7M
  int mag = AOMMIN(levels[pos + 1], MAX_BASE_BR_RANGE) +
82
14.7M
            AOMMIN(levels[pos + stride], MAX_BASE_BR_RANGE) +
83
14.7M
            AOMMIN(levels[pos + 1 + stride], MAX_BASE_BR_RANGE);
84
14.7M
  mag = AOMMIN((mag + 1) >> 1, 6);
85
  //((row | col) < 2) is equivalent to ((row < 2) && (col < 2))
86
14.7M
  if ((row | col) < 2) return mag + 7;
87
11.4M
  return mag + 14;
88
14.7M
}
decodetxb.c:get_br_ctx_2d
Line
Count
Source
75
14.7M
                                const int bhl) {
76
14.7M
  assert(c > 0);
77
0
  const int col = c >> bhl;
78
14.7M
  const int row = c - (col << bhl);
79
14.7M
  const int stride = (1 << bhl) + TX_PAD_HOR;
80
14.7M
  const int pos = col * stride + row;
81
14.7M
  int mag = AOMMIN(levels[pos + 1], MAX_BASE_BR_RANGE) +
82
14.7M
            AOMMIN(levels[pos + stride], MAX_BASE_BR_RANGE) +
83
14.7M
            AOMMIN(levels[pos + 1 + stride], MAX_BASE_BR_RANGE);
84
14.7M
  mag = AOMMIN((mag + 1) >> 1, 6);
85
  //((row | col) < 2) is equivalent to ((row < 2) && (col < 2))
86
14.7M
  if ((row | col) < 2) return mag + 7;
87
11.4M
  return mag + 14;
88
14.7M
}
Unexecuted instantiation: entropy.c:get_br_ctx_2d
Unexecuted instantiation: entropymode.c:get_br_ctx_2d
Unexecuted instantiation: txb_common.c:get_br_ctx_2d
89
90
static AOM_FORCE_INLINE int get_br_ctx_eob(const int c,  // raster order
91
                                           const int bhl,
92
647k
                                           const TX_CLASS tx_class) {
93
647k
  const int col = c >> bhl;
94
647k
  const int row = c - (col << bhl);
95
647k
  if (c == 0) return 0;
96
272k
  if ((tx_class == TX_CLASS_2D && row < 2 && col < 2) ||
97
272k
      (tx_class == TX_CLASS_HORIZ && col == 0) ||
98
272k
      (tx_class == TX_CLASS_VERT && row == 0))
99
23.2k
    return 7;
100
249k
  return 14;
101
272k
}
decodetxb.c:get_br_ctx_eob
Line
Count
Source
92
647k
                                           const TX_CLASS tx_class) {
93
647k
  const int col = c >> bhl;
94
647k
  const int row = c - (col << bhl);
95
647k
  if (c == 0) return 0;
96
272k
  if ((tx_class == TX_CLASS_2D && row < 2 && col < 2) ||
97
272k
      (tx_class == TX_CLASS_HORIZ && col == 0) ||
98
272k
      (tx_class == TX_CLASS_VERT && row == 0))
99
23.2k
    return 7;
100
249k
  return 14;
101
272k
}
Unexecuted instantiation: entropy.c:get_br_ctx_eob
Unexecuted instantiation: entropymode.c:get_br_ctx_eob
Unexecuted instantiation: txb_common.c:get_br_ctx_eob
102
103
static AOM_FORCE_INLINE int get_br_ctx(const uint8_t *const levels,
104
                                       const int c,  // raster order
105
5.17M
                                       const int bhl, const TX_CLASS tx_class) {
106
5.17M
  const int col = c >> bhl;
107
5.17M
  const int row = c - (col << bhl);
108
5.17M
  const int stride = (1 << bhl) + TX_PAD_HOR;
109
5.17M
  const int pos = col * stride + row;
110
5.17M
  int mag = levels[pos + 1];
111
5.17M
  mag += levels[pos + stride];
112
5.17M
  switch (tx_class) {
113
3.91M
    case TX_CLASS_2D:
114
3.91M
      mag += levels[pos + stride + 1];
115
3.91M
      mag = AOMMIN((mag + 1) >> 1, 6);
116
3.91M
      if (c == 0) return mag;
117
18.4E
      if ((row < 2) && (col < 2)) return mag + 7;
118
18.4E
      break;
119
18.4E
    case TX_CLASS_HORIZ:
120
724k
      mag += levels[pos + (stride << 1)];
121
724k
      mag = AOMMIN((mag + 1) >> 1, 6);
122
724k
      if (c == 0) return mag;
123
654k
      if (col == 0) return mag + 7;
124
353k
      break;
125
535k
    case TX_CLASS_VERT:
126
535k
      mag += levels[pos + 2];
127
535k
      mag = AOMMIN((mag + 1) >> 1, 6);
128
535k
      if (c == 0) return mag;
129
487k
      if (row == 0) return mag + 7;
130
275k
      break;
131
275k
    default: break;
132
5.17M
  }
133
134
628k
  return mag + 14;
135
5.17M
}
decodetxb.c:get_br_ctx
Line
Count
Source
105
5.17M
                                       const int bhl, const TX_CLASS tx_class) {
106
5.17M
  const int col = c >> bhl;
107
5.17M
  const int row = c - (col << bhl);
108
5.17M
  const int stride = (1 << bhl) + TX_PAD_HOR;
109
5.17M
  const int pos = col * stride + row;
110
5.17M
  int mag = levels[pos + 1];
111
5.17M
  mag += levels[pos + stride];
112
5.17M
  switch (tx_class) {
113
3.91M
    case TX_CLASS_2D:
114
3.91M
      mag += levels[pos + stride + 1];
115
3.91M
      mag = AOMMIN((mag + 1) >> 1, 6);
116
3.91M
      if (c == 0) return mag;
117
18.4E
      if ((row < 2) && (col < 2)) return mag + 7;
118
18.4E
      break;
119
18.4E
    case TX_CLASS_HORIZ:
120
724k
      mag += levels[pos + (stride << 1)];
121
724k
      mag = AOMMIN((mag + 1) >> 1, 6);
122
724k
      if (c == 0) return mag;
123
654k
      if (col == 0) return mag + 7;
124
353k
      break;
125
535k
    case TX_CLASS_VERT:
126
535k
      mag += levels[pos + 2];
127
535k
      mag = AOMMIN((mag + 1) >> 1, 6);
128
535k
      if (c == 0) return mag;
129
487k
      if (row == 0) return mag + 7;
130
275k
      break;
131
275k
    default: break;
132
5.17M
  }
133
134
628k
  return mag + 14;
135
5.17M
}
Unexecuted instantiation: entropy.c:get_br_ctx
Unexecuted instantiation: entropymode.c:get_br_ctx
Unexecuted instantiation: txb_common.c:get_br_ctx
136
137
static const uint8_t clip_max3[256] = {
138
  0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
139
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
140
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
141
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
142
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
143
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
144
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
145
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
146
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
147
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
148
};
149
150
static AOM_FORCE_INLINE int get_nz_mag(const uint8_t *const levels,
151
33.7M
                                       const int bhl, const TX_CLASS tx_class) {
152
33.7M
  int mag;
153
154
  // Note: AOMMIN(level, 3) is useless for decoder since level < 3.
155
33.7M
  mag = clip_max3[levels[(1 << bhl) + TX_PAD_HOR]];  // { 0, 1 }
156
33.7M
  mag += clip_max3[levels[1]];                       // { 1, 0 }
157
158
33.7M
  if (tx_class == TX_CLASS_2D) {
159
11.0M
    mag += clip_max3[levels[(1 << bhl) + TX_PAD_HOR + 1]];          // { 1, 1 }
160
11.0M
    mag += clip_max3[levels[(2 << bhl) + (2 << TX_PAD_HOR_LOG2)]];  // { 0, 2 }
161
11.0M
    mag += clip_max3[levels[2]];                                    // { 2, 0 }
162
22.7M
  } else if (tx_class == TX_CLASS_VERT) {
163
9.29M
    mag += clip_max3[levels[2]];  // { 2, 0 }
164
9.29M
    mag += clip_max3[levels[3]];  // { 3, 0 }
165
9.29M
    mag += clip_max3[levels[4]];  // { 4, 0 }
166
13.4M
  } else {
167
13.4M
    mag += clip_max3[levels[(2 << bhl) + (2 << TX_PAD_HOR_LOG2)]];  // { 0, 2 }
168
13.4M
    mag += clip_max3[levels[(3 << bhl) + (3 << TX_PAD_HOR_LOG2)]];  // { 0, 3 }
169
13.4M
    mag += clip_max3[levels[(4 << bhl) + (4 << TX_PAD_HOR_LOG2)]];  // { 0, 4 }
170
13.4M
  }
171
172
33.7M
  return mag;
173
33.7M
}
decodetxb.c:get_nz_mag
Line
Count
Source
151
33.7M
                                       const int bhl, const TX_CLASS tx_class) {
152
33.7M
  int mag;
153
154
  // Note: AOMMIN(level, 3) is useless for decoder since level < 3.
155
33.7M
  mag = clip_max3[levels[(1 << bhl) + TX_PAD_HOR]];  // { 0, 1 }
156
33.7M
  mag += clip_max3[levels[1]];                       // { 1, 0 }
157
158
33.7M
  if (tx_class == TX_CLASS_2D) {
159
11.0M
    mag += clip_max3[levels[(1 << bhl) + TX_PAD_HOR + 1]];          // { 1, 1 }
160
11.0M
    mag += clip_max3[levels[(2 << bhl) + (2 << TX_PAD_HOR_LOG2)]];  // { 0, 2 }
161
11.0M
    mag += clip_max3[levels[2]];                                    // { 2, 0 }
162
22.7M
  } else if (tx_class == TX_CLASS_VERT) {
163
9.29M
    mag += clip_max3[levels[2]];  // { 2, 0 }
164
9.29M
    mag += clip_max3[levels[3]];  // { 3, 0 }
165
9.29M
    mag += clip_max3[levels[4]];  // { 4, 0 }
166
13.4M
  } else {
167
13.4M
    mag += clip_max3[levels[(2 << bhl) + (2 << TX_PAD_HOR_LOG2)]];  // { 0, 2 }
168
13.4M
    mag += clip_max3[levels[(3 << bhl) + (3 << TX_PAD_HOR_LOG2)]];  // { 0, 3 }
169
13.4M
    mag += clip_max3[levels[(4 << bhl) + (4 << TX_PAD_HOR_LOG2)]];  // { 0, 4 }
170
13.4M
  }
171
172
33.7M
  return mag;
173
33.7M
}
Unexecuted instantiation: entropy.c:get_nz_mag
Unexecuted instantiation: entropymode.c:get_nz_mag
Unexecuted instantiation: txb_common.c:get_nz_mag
174
175
#define NZ_MAP_CTX_0 SIG_COEF_CONTEXTS_2D
176
#define NZ_MAP_CTX_5 (NZ_MAP_CTX_0 + 5)
177
#define NZ_MAP_CTX_10 (NZ_MAP_CTX_0 + 10)
178
179
static const int nz_map_ctx_offset_1d[32] = {
180
  NZ_MAP_CTX_0,  NZ_MAP_CTX_5,  NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10,
181
  NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10,
182
  NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10,
183
  NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10,
184
  NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10,
185
  NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10, NZ_MAP_CTX_10,
186
  NZ_MAP_CTX_10, NZ_MAP_CTX_10,
187
};
188
189
static AOM_FORCE_INLINE int get_nz_map_ctx_from_stats(
190
    const int stats,
191
    const int coeff_idx,  // raster order
192
33.7M
    const int bhl, const TX_SIZE tx_size, const TX_CLASS tx_class) {
193
  // tx_class == 0(TX_CLASS_2D)
194
33.7M
  if ((tx_class | coeff_idx) == 0) return 0;
195
22.7M
  int ctx = (stats + 1) >> 1;
196
22.7M
  ctx = AOMMIN(ctx, 4);
197
22.7M
  switch (tx_class) {
198
0
    case TX_CLASS_2D: {
199
      // This is the algorithm to generate av1_nz_map_ctx_offset[][]
200
      //   const int width = tx_size_wide[tx_size];
201
      //   const int height = tx_size_high[tx_size];
202
      //   if (width < height) {
203
      //     if (row < 2) return 11 + ctx;
204
      //   } else if (width > height) {
205
      //     if (col < 2) return 16 + ctx;
206
      //   }
207
      //   if (row + col < 2) return ctx + 1;
208
      //   if (row + col < 4) return 5 + ctx + 1;
209
      //   return 21 + ctx;
210
0
      return ctx + av1_nz_map_ctx_offset[tx_size][coeff_idx];
211
0
    }
212
13.4M
    case TX_CLASS_HORIZ: {
213
13.4M
      const int col = coeff_idx >> bhl;
214
13.4M
      return ctx + nz_map_ctx_offset_1d[col];
215
0
    }
216
9.29M
    case TX_CLASS_VERT: {
217
9.29M
      const int col = coeff_idx >> bhl;
218
9.29M
      const int row = coeff_idx - (col << bhl);
219
9.29M
      return ctx + nz_map_ctx_offset_1d[row];
220
0
    }
221
0
    default: break;
222
22.7M
  }
223
0
  return 0;
224
22.7M
}
decodetxb.c:get_nz_map_ctx_from_stats
Line
Count
Source
192
33.7M
    const int bhl, const TX_SIZE tx_size, const TX_CLASS tx_class) {
193
  // tx_class == 0(TX_CLASS_2D)
194
33.7M
  if ((tx_class | coeff_idx) == 0) return 0;
195
22.7M
  int ctx = (stats + 1) >> 1;
196
22.7M
  ctx = AOMMIN(ctx, 4);
197
22.7M
  switch (tx_class) {
198
0
    case TX_CLASS_2D: {
199
      // This is the algorithm to generate av1_nz_map_ctx_offset[][]
200
      //   const int width = tx_size_wide[tx_size];
201
      //   const int height = tx_size_high[tx_size];
202
      //   if (width < height) {
203
      //     if (row < 2) return 11 + ctx;
204
      //   } else if (width > height) {
205
      //     if (col < 2) return 16 + ctx;
206
      //   }
207
      //   if (row + col < 2) return ctx + 1;
208
      //   if (row + col < 4) return 5 + ctx + 1;
209
      //   return 21 + ctx;
210
0
      return ctx + av1_nz_map_ctx_offset[tx_size][coeff_idx];
211
0
    }
212
13.4M
    case TX_CLASS_HORIZ: {
213
13.4M
      const int col = coeff_idx >> bhl;
214
13.4M
      return ctx + nz_map_ctx_offset_1d[col];
215
0
    }
216
9.29M
    case TX_CLASS_VERT: {
217
9.29M
      const int col = coeff_idx >> bhl;
218
9.29M
      const int row = coeff_idx - (col << bhl);
219
9.29M
      return ctx + nz_map_ctx_offset_1d[row];
220
0
    }
221
0
    default: break;
222
22.7M
  }
223
0
  return 0;
224
22.7M
}
Unexecuted instantiation: entropy.c:get_nz_map_ctx_from_stats
Unexecuted instantiation: entropymode.c:get_nz_map_ctx_from_stats
Unexecuted instantiation: txb_common.c:get_nz_map_ctx_from_stats
225
226
typedef aom_cdf_prob (*base_cdf_arr)[CDF_SIZE(4)];
227
typedef aom_cdf_prob (*br_cdf_arr)[CDF_SIZE(BR_CDF_SIZE)];
228
229
20.9M
static INLINE int get_lower_levels_ctx_eob(int bhl, int width, int scan_idx) {
230
20.9M
  if (scan_idx == 0) return 0;
231
12.2M
  if (scan_idx <= (width << bhl) / 8) return 1;
232
6.63M
  if (scan_idx <= (width << bhl) / 4) return 2;
233
4.84M
  return 3;
234
6.63M
}
decodetxb.c:get_lower_levels_ctx_eob
Line
Count
Source
229
20.9M
static INLINE int get_lower_levels_ctx_eob(int bhl, int width, int scan_idx) {
230
20.9M
  if (scan_idx == 0) return 0;
231
12.2M
  if (scan_idx <= (width << bhl) / 8) return 1;
232
6.63M
  if (scan_idx <= (width << bhl) / 4) return 2;
233
4.84M
  return 3;
234
6.63M
}
Unexecuted instantiation: entropy.c:get_lower_levels_ctx_eob
Unexecuted instantiation: entropymode.c:get_lower_levels_ctx_eob
Unexecuted instantiation: txb_common.c:get_lower_levels_ctx_eob
235
236
static INLINE int get_lower_levels_ctx_2d(const uint8_t *levels, int coeff_idx,
237
232M
                                          int bhl, TX_SIZE tx_size) {
238
232M
  assert(coeff_idx > 0);
239
0
  int mag;
240
  // Note: AOMMIN(level, 3) is useless for decoder since level < 3.
241
232M
  levels = levels + get_padded_idx(coeff_idx, bhl);
242
232M
  mag = AOMMIN(levels[(1 << bhl) + TX_PAD_HOR], 3);               // { 0, 1 }
243
232M
  mag += AOMMIN(levels[1], 3);                                    // { 1, 0 }
244
232M
  mag += AOMMIN(levels[(1 << bhl) + TX_PAD_HOR + 1], 3);          // { 1, 1 }
245
232M
  mag += AOMMIN(levels[(2 << bhl) + (2 << TX_PAD_HOR_LOG2)], 3);  // { 0, 2 }
246
232M
  mag += AOMMIN(levels[2], 3);                                    // { 2, 0 }
247
248
232M
  const int ctx = AOMMIN((mag + 1) >> 1, 4);
249
232M
  return ctx + av1_nz_map_ctx_offset[tx_size][coeff_idx];
250
232M
}
decodetxb.c:get_lower_levels_ctx_2d
Line
Count
Source
237
232M
                                          int bhl, TX_SIZE tx_size) {
238
232M
  assert(coeff_idx > 0);
239
0
  int mag;
240
  // Note: AOMMIN(level, 3) is useless for decoder since level < 3.
241
232M
  levels = levels + get_padded_idx(coeff_idx, bhl);
242
232M
  mag = AOMMIN(levels[(1 << bhl) + TX_PAD_HOR], 3);               // { 0, 1 }
243
232M
  mag += AOMMIN(levels[1], 3);                                    // { 1, 0 }
244
232M
  mag += AOMMIN(levels[(1 << bhl) + TX_PAD_HOR + 1], 3);          // { 1, 1 }
245
232M
  mag += AOMMIN(levels[(2 << bhl) + (2 << TX_PAD_HOR_LOG2)], 3);  // { 0, 2 }
246
232M
  mag += AOMMIN(levels[2], 3);                                    // { 2, 0 }
247
248
232M
  const int ctx = AOMMIN((mag + 1) >> 1, 4);
249
232M
  return ctx + av1_nz_map_ctx_offset[tx_size][coeff_idx];
250
232M
}
Unexecuted instantiation: entropy.c:get_lower_levels_ctx_2d
Unexecuted instantiation: entropymode.c:get_lower_levels_ctx_2d
Unexecuted instantiation: txb_common.c:get_lower_levels_ctx_2d
251
static AOM_FORCE_INLINE int get_lower_levels_ctx(const uint8_t *levels,
252
                                                 int coeff_idx, int bhl,
253
                                                 TX_SIZE tx_size,
254
33.7M
                                                 TX_CLASS tx_class) {
255
33.7M
  const int stats =
256
33.7M
      get_nz_mag(levels + get_padded_idx(coeff_idx, bhl), bhl, tx_class);
257
33.7M
  return get_nz_map_ctx_from_stats(stats, coeff_idx, bhl, tx_size, tx_class);
258
33.7M
}
decodetxb.c:get_lower_levels_ctx
Line
Count
Source
254
33.7M
                                                 TX_CLASS tx_class) {
255
33.7M
  const int stats =
256
33.7M
      get_nz_mag(levels + get_padded_idx(coeff_idx, bhl), bhl, tx_class);
257
33.7M
  return get_nz_map_ctx_from_stats(stats, coeff_idx, bhl, tx_size, tx_class);
258
33.7M
}
Unexecuted instantiation: entropy.c:get_lower_levels_ctx
Unexecuted instantiation: entropymode.c:get_lower_levels_ctx
Unexecuted instantiation: txb_common.c:get_lower_levels_ctx
259
260
static INLINE int get_lower_levels_ctx_general(int is_last, int scan_idx,
261
                                               int bhl, int width,
262
                                               const uint8_t *levels,
263
                                               int coeff_idx, TX_SIZE tx_size,
264
0
                                               TX_CLASS tx_class) {
265
0
  if (is_last) {
266
0
    if (scan_idx == 0) return 0;
267
0
    if (scan_idx <= (width << bhl) >> 3) return 1;
268
0
    if (scan_idx <= (width << bhl) >> 2) return 2;
269
0
    return 3;
270
0
  }
271
0
  return get_lower_levels_ctx(levels, coeff_idx, bhl, tx_size, tx_class);
272
0
}
Unexecuted instantiation: decodetxb.c:get_lower_levels_ctx_general
Unexecuted instantiation: entropy.c:get_lower_levels_ctx_general
Unexecuted instantiation: entropymode.c:get_lower_levels_ctx_general
Unexecuted instantiation: txb_common.c:get_lower_levels_ctx_general
273
274
20.7M
static INLINE void set_dc_sign(int *cul_level, int dc_val) {
275
20.7M
  if (dc_val < 0)
276
5.30M
    *cul_level |= 1 << COEFF_CONTEXT_BITS;
277
15.4M
  else if (dc_val > 0)
278
12.0M
    *cul_level += 2 << COEFF_CONTEXT_BITS;
279
20.7M
}
decodetxb.c:set_dc_sign
Line
Count
Source
274
20.7M
static INLINE void set_dc_sign(int *cul_level, int dc_val) {
275
20.7M
  if (dc_val < 0)
276
5.30M
    *cul_level |= 1 << COEFF_CONTEXT_BITS;
277
15.4M
  else if (dc_val > 0)
278
12.0M
    *cul_level += 2 << COEFF_CONTEXT_BITS;
279
20.7M
}
Unexecuted instantiation: entropy.c:set_dc_sign
Unexecuted instantiation: entropymode.c:set_dc_sign
Unexecuted instantiation: txb_common.c:set_dc_sign
280
281
static void get_txb_ctx_general(const BLOCK_SIZE plane_bsize,
282
                                const TX_SIZE tx_size, const int plane,
283
                                const ENTROPY_CONTEXT *const a,
284
                                const ENTROPY_CONTEXT *const l,
285
15.1M
                                TXB_CTX *const txb_ctx) {
286
35.3M
#define MAX_TX_SIZE_UNIT 16
287
15.1M
  static const int8_t signs[3] = { 0, -1, 1 };
288
15.1M
  static const int8_t dc_sign_contexts[4 * MAX_TX_SIZE_UNIT + 1] = {
289
15.1M
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
290
15.1M
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
291
15.1M
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
292
15.1M
  };
293
15.1M
  const int txb_w_unit = tx_size_wide_unit[tx_size];
294
15.1M
  const int txb_h_unit = tx_size_high_unit[tx_size];
295
15.1M
  int dc_sign = 0;
296
15.1M
  int k = 0;
297
298
64.7M
  do {
299
64.7M
    const unsigned int sign = ((uint8_t)a[k]) >> COEFF_CONTEXT_BITS;
300
64.7M
    assert(sign <= 2);
301
0
    dc_sign += signs[sign];
302
64.7M
  } while (++k < txb_w_unit);
303
304
0
  k = 0;
305
41.6M
  do {
306
41.6M
    const unsigned int sign = ((uint8_t)l[k]) >> COEFF_CONTEXT_BITS;
307
41.6M
    assert(sign <= 2);
308
0
    dc_sign += signs[sign];
309
41.6M
  } while (++k < txb_h_unit);
310
311
15.1M
  txb_ctx->dc_sign_ctx = dc_sign_contexts[dc_sign + 2 * MAX_TX_SIZE_UNIT];
312
313
15.1M
  if (plane == 0) {
314
6.06M
    if (plane_bsize == txsize_to_bsize[tx_size]) {
315
5.43M
      txb_ctx->txb_skip_ctx = 0;
316
5.43M
    } else {
317
      // This is the algorithm to generate table skip_contexts[top][left].
318
      //    const int max = AOMMIN(top | left, 4);
319
      //    const int min = AOMMIN(AOMMIN(top, left), 4);
320
      //    if (!max)
321
      //      txb_skip_ctx = 1;
322
      //    else if (!min)
323
      //      txb_skip_ctx = 2 + (max > 3);
324
      //    else if (max <= 3)
325
      //      txb_skip_ctx = 4;
326
      //    else if (min <= 3)
327
      //      txb_skip_ctx = 5;
328
      //    else
329
      //      txb_skip_ctx = 6;
330
626k
      static const uint8_t skip_contexts[5][5] = { { 1, 2, 2, 2, 3 },
331
626k
                                                   { 2, 4, 4, 4, 5 },
332
626k
                                                   { 2, 4, 4, 4, 5 },
333
626k
                                                   { 2, 4, 4, 4, 5 },
334
626k
                                                   { 3, 5, 5, 5, 6 } };
335
      // For top and left, we only care about which of the following three
336
      // categories they belong to: { 0 }, { 1, 2, 3 }, or { 4, 5, ... }. The
337
      // spec calculates top and left with the Max() function. We can calculate
338
      // an approximate max with bitwise OR because the real max and the
339
      // approximate max belong to the same category.
340
626k
      int top = 0;
341
626k
      int left = 0;
342
343
626k
      k = 0;
344
5.05M
      do {
345
5.05M
        top |= a[k];
346
5.05M
      } while (++k < txb_w_unit);
347
626k
      top &= COEFF_CONTEXT_MASK;
348
626k
      top = AOMMIN(top, 4);
349
350
626k
      k = 0;
351
4.96M
      do {
352
4.96M
        left |= l[k];
353
4.96M
      } while (++k < txb_h_unit);
354
626k
      left &= COEFF_CONTEXT_MASK;
355
626k
      left = AOMMIN(left, 4);
356
357
626k
      txb_ctx->txb_skip_ctx = skip_contexts[top][left];
358
626k
    }
359
9.12M
  } else {
360
9.12M
    const int ctx_base = get_entropy_context(tx_size, a, l);
361
9.12M
    const int ctx_offset = (num_pels_log2_lookup[plane_bsize] >
362
9.12M
                            num_pels_log2_lookup[txsize_to_bsize[tx_size]])
363
9.12M
                               ? 10
364
9.12M
                               : 7;
365
9.12M
    txb_ctx->txb_skip_ctx = ctx_base + ctx_offset;
366
9.12M
  }
367
15.1M
}
decodetxb.c:get_txb_ctx_general
Line
Count
Source
285
15.1M
                                TXB_CTX *const txb_ctx) {
286
15.1M
#define MAX_TX_SIZE_UNIT 16
287
15.1M
  static const int8_t signs[3] = { 0, -1, 1 };
288
15.1M
  static const int8_t dc_sign_contexts[4 * MAX_TX_SIZE_UNIT + 1] = {
289
15.1M
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
290
15.1M
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
291
15.1M
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
292
15.1M
  };
293
15.1M
  const int txb_w_unit = tx_size_wide_unit[tx_size];
294
15.1M
  const int txb_h_unit = tx_size_high_unit[tx_size];
295
15.1M
  int dc_sign = 0;
296
15.1M
  int k = 0;
297
298
64.7M
  do {
299
64.7M
    const unsigned int sign = ((uint8_t)a[k]) >> COEFF_CONTEXT_BITS;
300
64.7M
    assert(sign <= 2);
301
0
    dc_sign += signs[sign];
302
64.7M
  } while (++k < txb_w_unit);
303
304
0
  k = 0;
305
41.6M
  do {
306
41.6M
    const unsigned int sign = ((uint8_t)l[k]) >> COEFF_CONTEXT_BITS;
307
41.6M
    assert(sign <= 2);
308
0
    dc_sign += signs[sign];
309
41.6M
  } while (++k < txb_h_unit);
310
311
15.1M
  txb_ctx->dc_sign_ctx = dc_sign_contexts[dc_sign + 2 * MAX_TX_SIZE_UNIT];
312
313
15.1M
  if (plane == 0) {
314
6.06M
    if (plane_bsize == txsize_to_bsize[tx_size]) {
315
5.43M
      txb_ctx->txb_skip_ctx = 0;
316
5.43M
    } else {
317
      // This is the algorithm to generate table skip_contexts[top][left].
318
      //    const int max = AOMMIN(top | left, 4);
319
      //    const int min = AOMMIN(AOMMIN(top, left), 4);
320
      //    if (!max)
321
      //      txb_skip_ctx = 1;
322
      //    else if (!min)
323
      //      txb_skip_ctx = 2 + (max > 3);
324
      //    else if (max <= 3)
325
      //      txb_skip_ctx = 4;
326
      //    else if (min <= 3)
327
      //      txb_skip_ctx = 5;
328
      //    else
329
      //      txb_skip_ctx = 6;
330
626k
      static const uint8_t skip_contexts[5][5] = { { 1, 2, 2, 2, 3 },
331
626k
                                                   { 2, 4, 4, 4, 5 },
332
626k
                                                   { 2, 4, 4, 4, 5 },
333
626k
                                                   { 2, 4, 4, 4, 5 },
334
626k
                                                   { 3, 5, 5, 5, 6 } };
335
      // For top and left, we only care about which of the following three
336
      // categories they belong to: { 0 }, { 1, 2, 3 }, or { 4, 5, ... }. The
337
      // spec calculates top and left with the Max() function. We can calculate
338
      // an approximate max with bitwise OR because the real max and the
339
      // approximate max belong to the same category.
340
626k
      int top = 0;
341
626k
      int left = 0;
342
343
626k
      k = 0;
344
5.05M
      do {
345
5.05M
        top |= a[k];
346
5.05M
      } while (++k < txb_w_unit);
347
626k
      top &= COEFF_CONTEXT_MASK;
348
626k
      top = AOMMIN(top, 4);
349
350
626k
      k = 0;
351
4.96M
      do {
352
4.96M
        left |= l[k];
353
4.96M
      } while (++k < txb_h_unit);
354
626k
      left &= COEFF_CONTEXT_MASK;
355
626k
      left = AOMMIN(left, 4);
356
357
626k
      txb_ctx->txb_skip_ctx = skip_contexts[top][left];
358
626k
    }
359
9.12M
  } else {
360
9.12M
    const int ctx_base = get_entropy_context(tx_size, a, l);
361
9.12M
    const int ctx_offset = (num_pels_log2_lookup[plane_bsize] >
362
9.12M
                            num_pels_log2_lookup[txsize_to_bsize[tx_size]])
363
9.12M
                               ? 10
364
9.12M
                               : 7;
365
9.12M
    txb_ctx->txb_skip_ctx = ctx_base + ctx_offset;
366
9.12M
  }
367
15.1M
}
Unexecuted instantiation: entropy.c:get_txb_ctx_general
Unexecuted instantiation: entropymode.c:get_txb_ctx_general
Unexecuted instantiation: txb_common.c:get_txb_ctx_general
368
369
#define SPECIALIZE_GET_TXB_CTX(w, h)                                          \
370
  static void get_txb_ctx_##w##x##h(                                          \
371
      const BLOCK_SIZE plane_bsize, const int plane,                          \
372
      const ENTROPY_CONTEXT *const a, const ENTROPY_CONTEXT *const l,         \
373
20.1M
      TXB_CTX *const txb_ctx) {                                               \
374
20.1M
    static const int8_t signs[3] = { 0, -1, 1 };                              \
375
20.1M
    static const int8_t dc_sign_contexts[4 * MAX_TX_SIZE_UNIT + 1] = {        \
376
20.1M
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,       \
377
20.1M
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,       \
378
20.1M
      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2           \
379
20.1M
    };                                                                        \
380
20.1M
    const TX_SIZE tx_size = TX_##w##X##h;                                     \
381
20.1M
    const int txb_w_unit = tx_size_wide_unit[tx_size];                        \
382
20.1M
    const int txb_h_unit = tx_size_high_unit[tx_size];                        \
383
20.1M
    int dc_sign = 0;                                                          \
384
20.1M
    int k = 0;                                                                \
385
20.1M
                                                                              \
386
48.7M
    do {                                                                      \
387
48.7M
      const unsigned int sign = ((uint8_t)a[k]) >> COEFF_CONTEXT_BITS;        \
388
48.7M
      assert(sign <= 2);                                                      \
389
48.7M
      dc_sign += signs[sign];                                                 \
390
48.7M
    } while (++k < txb_w_unit);                                               \
391
20.1M
                                                                              \
392
20.1M
    k = 0;                                                                    \
393
48.7M
    do {                                                                      \
394
48.7M
      const unsigned int sign = ((uint8_t)l[k]) >> COEFF_CONTEXT_BITS;        \
395
48.7M
      assert(sign <= 2);                                                      \
396
48.7M
      dc_sign += signs[sign];                                                 \
397
48.7M
    } while (++k < txb_h_unit);                                               \
398
20.1M
                                                                              \
399
20.1M
    txb_ctx->dc_sign_ctx = dc_sign_contexts[dc_sign + 2 * MAX_TX_SIZE_UNIT];  \
400
20.1M
                                                                              \
401
20.1M
    if (plane == 0) {                                                         \
402
9.82M
      if (plane_bsize == txsize_to_bsize[tx_size]) {                          \
403
3.53M
        txb_ctx->txb_skip_ctx = 0;                                            \
404
6.28M
      } else {                                                                \
405
6.28M
        static const uint8_t skip_contexts[5][5] = { { 1, 2, 2, 2, 3 },       \
406
6.28M
                                                     { 2, 4, 4, 4, 5 },       \
407
6.28M
                                                     { 2, 4, 4, 4, 5 },       \
408
6.28M
                                                     { 2, 4, 4, 4, 5 },       \
409
6.28M
                                                     { 3, 5, 5, 5, 6 } };     \
410
6.28M
        int top = 0;                                                          \
411
6.28M
        int left = 0;                                                         \
412
6.28M
                                                                              \
413
6.28M
        k = 0;                                                                \
414
9.13M
        do {                                                                  \
415
9.13M
          top |= a[k];                                                        \
416
9.13M
        } while (++k < txb_w_unit);                                           \
417
6.28M
        top &= COEFF_CONTEXT_MASK;                                            \
418
6.28M
        top = AOMMIN(top, 4);                                                 \
419
6.28M
                                                                              \
420
6.28M
        k = 0;                                                                \
421
9.13M
        do {                                                                  \
422
9.13M
          left |= l[k];                                                       \
423
9.13M
        } while (++k < txb_h_unit);                                           \
424
6.28M
        left &= COEFF_CONTEXT_MASK;                                           \
425
6.28M
        left = AOMMIN(left, 4);                                               \
426
6.28M
                                                                              \
427
6.28M
        txb_ctx->txb_skip_ctx = skip_contexts[top][left];                     \
428
6.28M
      }                                                                       \
429
10.3M
    } else {                                                                  \
430
10.3M
      const int ctx_base = get_entropy_context(tx_size, a, l);                \
431
10.3M
      const int ctx_offset = (num_pels_log2_lookup[plane_bsize] >             \
432
10.3M
                              num_pels_log2_lookup[txsize_to_bsize[tx_size]]) \
433
10.3M
                                 ? 10                                         \
434
10.3M
                                 : 7;                                         \
435
10.3M
      txb_ctx->txb_skip_ctx = ctx_base + ctx_offset;                          \
436
10.3M
    }                                                                         \
437
20.1M
  }
decodetxb.c:get_txb_ctx_4x4
Line
Count
Source
373
9.85M
      TXB_CTX *const txb_ctx) {                                               \
374
9.85M
    static const int8_t signs[3] = { 0, -1, 1 };                              \
375
9.85M
    static const int8_t dc_sign_contexts[4 * MAX_TX_SIZE_UNIT + 1] = {        \
376
9.85M
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,       \
377
9.85M
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,       \
378
9.85M
      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2           \
379
9.85M
    };                                                                        \
380
9.85M
    const TX_SIZE tx_size = TX_##w##X##h;                                     \
381
9.85M
    const int txb_w_unit = tx_size_wide_unit[tx_size];                        \
382
9.85M
    const int txb_h_unit = tx_size_high_unit[tx_size];                        \
383
9.85M
    int dc_sign = 0;                                                          \
384
9.85M
    int k = 0;                                                                \
385
9.85M
                                                                              \
386
9.85M
    do {                                                                      \
387
9.85M
      const unsigned int sign = ((uint8_t)a[k]) >> COEFF_CONTEXT_BITS;        \
388
9.85M
      assert(sign <= 2);                                                      \
389
9.85M
      dc_sign += signs[sign];                                                 \
390
9.85M
    } while (++k < txb_w_unit);                                               \
391
9.85M
                                                                              \
392
9.85M
    k = 0;                                                                    \
393
9.85M
    do {                                                                      \
394
9.85M
      const unsigned int sign = ((uint8_t)l[k]) >> COEFF_CONTEXT_BITS;        \
395
9.85M
      assert(sign <= 2);                                                      \
396
9.85M
      dc_sign += signs[sign];                                                 \
397
9.85M
    } while (++k < txb_h_unit);                                               \
398
9.85M
                                                                              \
399
9.85M
    txb_ctx->dc_sign_ctx = dc_sign_contexts[dc_sign + 2 * MAX_TX_SIZE_UNIT];  \
400
9.85M
                                                                              \
401
9.85M
    if (plane == 0) {                                                         \
402
5.10M
      if (plane_bsize == txsize_to_bsize[tx_size]) {                          \
403
509k
        txb_ctx->txb_skip_ctx = 0;                                            \
404
4.59M
      } else {                                                                \
405
4.59M
        static const uint8_t skip_contexts[5][5] = { { 1, 2, 2, 2, 3 },       \
406
4.59M
                                                     { 2, 4, 4, 4, 5 },       \
407
4.59M
                                                     { 2, 4, 4, 4, 5 },       \
408
4.59M
                                                     { 2, 4, 4, 4, 5 },       \
409
4.59M
                                                     { 3, 5, 5, 5, 6 } };     \
410
4.59M
        int top = 0;                                                          \
411
4.59M
        int left = 0;                                                         \
412
4.59M
                                                                              \
413
4.59M
        k = 0;                                                                \
414
4.59M
        do {                                                                  \
415
4.59M
          top |= a[k];                                                        \
416
4.59M
        } while (++k < txb_w_unit);                                           \
417
4.59M
        top &= COEFF_CONTEXT_MASK;                                            \
418
4.59M
        top = AOMMIN(top, 4);                                                 \
419
4.59M
                                                                              \
420
4.59M
        k = 0;                                                                \
421
4.59M
        do {                                                                  \
422
4.59M
          left |= l[k];                                                       \
423
4.59M
        } while (++k < txb_h_unit);                                           \
424
4.59M
        left &= COEFF_CONTEXT_MASK;                                           \
425
4.59M
        left = AOMMIN(left, 4);                                               \
426
4.59M
                                                                              \
427
4.59M
        txb_ctx->txb_skip_ctx = skip_contexts[top][left];                     \
428
4.59M
      }                                                                       \
429
5.10M
    } else {                                                                  \
430
4.75M
      const int ctx_base = get_entropy_context(tx_size, a, l);                \
431
4.75M
      const int ctx_offset = (num_pels_log2_lookup[plane_bsize] >             \
432
4.75M
                              num_pels_log2_lookup[txsize_to_bsize[tx_size]]) \
433
4.75M
                                 ? 10                                         \
434
4.75M
                                 : 7;                                         \
435
4.75M
      txb_ctx->txb_skip_ctx = ctx_base + ctx_offset;                          \
436
4.75M
    }                                                                         \
437
9.85M
  }
decodetxb.c:get_txb_ctx_8x8
Line
Count
Source
373
5.18M
      TXB_CTX *const txb_ctx) {                                               \
374
5.18M
    static const int8_t signs[3] = { 0, -1, 1 };                              \
375
5.18M
    static const int8_t dc_sign_contexts[4 * MAX_TX_SIZE_UNIT + 1] = {        \
376
5.18M
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,       \
377
5.18M
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,       \
378
5.18M
      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2           \
379
5.18M
    };                                                                        \
380
5.18M
    const TX_SIZE tx_size = TX_##w##X##h;                                     \
381
5.18M
    const int txb_w_unit = tx_size_wide_unit[tx_size];                        \
382
5.18M
    const int txb_h_unit = tx_size_high_unit[tx_size];                        \
383
5.18M
    int dc_sign = 0;                                                          \
384
5.18M
    int k = 0;                                                                \
385
5.18M
                                                                              \
386
10.3M
    do {                                                                      \
387
10.3M
      const unsigned int sign = ((uint8_t)a[k]) >> COEFF_CONTEXT_BITS;        \
388
10.3M
      assert(sign <= 2);                                                      \
389
10.3M
      dc_sign += signs[sign];                                                 \
390
10.3M
    } while (++k < txb_w_unit);                                               \
391
5.18M
                                                                              \
392
5.18M
    k = 0;                                                                    \
393
10.3M
    do {                                                                      \
394
10.3M
      const unsigned int sign = ((uint8_t)l[k]) >> COEFF_CONTEXT_BITS;        \
395
10.3M
      assert(sign <= 2);                                                      \
396
10.3M
      dc_sign += signs[sign];                                                 \
397
10.3M
    } while (++k < txb_h_unit);                                               \
398
5.18M
                                                                              \
399
5.18M
    txb_ctx->dc_sign_ctx = dc_sign_contexts[dc_sign + 2 * MAX_TX_SIZE_UNIT];  \
400
5.18M
                                                                              \
401
5.18M
    if (plane == 0) {                                                         \
402
2.57M
      if (plane_bsize == txsize_to_bsize[tx_size]) {                          \
403
1.27M
        txb_ctx->txb_skip_ctx = 0;                                            \
404
1.29M
      } else {                                                                \
405
1.29M
        static const uint8_t skip_contexts[5][5] = { { 1, 2, 2, 2, 3 },       \
406
1.29M
                                                     { 2, 4, 4, 4, 5 },       \
407
1.29M
                                                     { 2, 4, 4, 4, 5 },       \
408
1.29M
                                                     { 2, 4, 4, 4, 5 },       \
409
1.29M
                                                     { 3, 5, 5, 5, 6 } };     \
410
1.29M
        int top = 0;                                                          \
411
1.29M
        int left = 0;                                                         \
412
1.29M
                                                                              \
413
1.29M
        k = 0;                                                                \
414
2.59M
        do {                                                                  \
415
2.59M
          top |= a[k];                                                        \
416
2.59M
        } while (++k < txb_w_unit);                                           \
417
1.29M
        top &= COEFF_CONTEXT_MASK;                                            \
418
1.29M
        top = AOMMIN(top, 4);                                                 \
419
1.29M
                                                                              \
420
1.29M
        k = 0;                                                                \
421
2.59M
        do {                                                                  \
422
2.59M
          left |= l[k];                                                       \
423
2.59M
        } while (++k < txb_h_unit);                                           \
424
1.29M
        left &= COEFF_CONTEXT_MASK;                                           \
425
1.29M
        left = AOMMIN(left, 4);                                               \
426
1.29M
                                                                              \
427
1.29M
        txb_ctx->txb_skip_ctx = skip_contexts[top][left];                     \
428
1.29M
      }                                                                       \
429
2.60M
    } else {                                                                  \
430
2.60M
      const int ctx_base = get_entropy_context(tx_size, a, l);                \
431
2.60M
      const int ctx_offset = (num_pels_log2_lookup[plane_bsize] >             \
432
2.60M
                              num_pels_log2_lookup[txsize_to_bsize[tx_size]]) \
433
2.60M
                                 ? 10                                         \
434
2.60M
                                 : 7;                                         \
435
2.60M
      txb_ctx->txb_skip_ctx = ctx_base + ctx_offset;                          \
436
2.60M
    }                                                                         \
437
5.18M
  }
decodetxb.c:get_txb_ctx_16x16
Line
Count
Source
373
3.09M
      TXB_CTX *const txb_ctx) {                                               \
374
3.09M
    static const int8_t signs[3] = { 0, -1, 1 };                              \
375
3.09M
    static const int8_t dc_sign_contexts[4 * MAX_TX_SIZE_UNIT + 1] = {        \
376
3.09M
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,       \
377
3.09M
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,       \
378
3.09M
      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2           \
379
3.09M
    };                                                                        \
380
3.09M
    const TX_SIZE tx_size = TX_##w##X##h;                                     \
381
3.09M
    const int txb_w_unit = tx_size_wide_unit[tx_size];                        \
382
3.09M
    const int txb_h_unit = tx_size_high_unit[tx_size];                        \
383
3.09M
    int dc_sign = 0;                                                          \
384
3.09M
    int k = 0;                                                                \
385
3.09M
                                                                              \
386
12.3M
    do {                                                                      \
387
12.3M
      const unsigned int sign = ((uint8_t)a[k]) >> COEFF_CONTEXT_BITS;        \
388
12.3M
      assert(sign <= 2);                                                      \
389
12.3M
      dc_sign += signs[sign];                                                 \
390
12.3M
    } while (++k < txb_w_unit);                                               \
391
3.09M
                                                                              \
392
3.09M
    k = 0;                                                                    \
393
12.3M
    do {                                                                      \
394
12.3M
      const unsigned int sign = ((uint8_t)l[k]) >> COEFF_CONTEXT_BITS;        \
395
12.3M
      assert(sign <= 2);                                                      \
396
12.3M
      dc_sign += signs[sign];                                                 \
397
12.3M
    } while (++k < txb_h_unit);                                               \
398
3.09M
                                                                              \
399
3.09M
    txb_ctx->dc_sign_ctx = dc_sign_contexts[dc_sign + 2 * MAX_TX_SIZE_UNIT];  \
400
3.09M
                                                                              \
401
3.09M
    if (plane == 0) {                                                         \
402
1.36M
      if (plane_bsize == txsize_to_bsize[tx_size]) {                          \
403
1.05M
        txb_ctx->txb_skip_ctx = 0;                                            \
404
1.05M
      } else {                                                                \
405
308k
        static const uint8_t skip_contexts[5][5] = { { 1, 2, 2, 2, 3 },       \
406
308k
                                                     { 2, 4, 4, 4, 5 },       \
407
308k
                                                     { 2, 4, 4, 4, 5 },       \
408
308k
                                                     { 2, 4, 4, 4, 5 },       \
409
308k
                                                     { 3, 5, 5, 5, 6 } };     \
410
308k
        int top = 0;                                                          \
411
308k
        int left = 0;                                                         \
412
308k
                                                                              \
413
308k
        k = 0;                                                                \
414
1.23M
        do {                                                                  \
415
1.23M
          top |= a[k];                                                        \
416
1.23M
        } while (++k < txb_w_unit);                                           \
417
308k
        top &= COEFF_CONTEXT_MASK;                                            \
418
308k
        top = AOMMIN(top, 4);                                                 \
419
308k
                                                                              \
420
308k
        k = 0;                                                                \
421
1.23M
        do {                                                                  \
422
1.23M
          left |= l[k];                                                       \
423
1.23M
        } while (++k < txb_h_unit);                                           \
424
308k
        left &= COEFF_CONTEXT_MASK;                                           \
425
308k
        left = AOMMIN(left, 4);                                               \
426
308k
                                                                              \
427
308k
        txb_ctx->txb_skip_ctx = skip_contexts[top][left];                     \
428
308k
      }                                                                       \
429
1.73M
    } else {                                                                  \
430
1.73M
      const int ctx_base = get_entropy_context(tx_size, a, l);                \
431
1.73M
      const int ctx_offset = (num_pels_log2_lookup[plane_bsize] >             \
432
1.73M
                              num_pels_log2_lookup[txsize_to_bsize[tx_size]]) \
433
1.73M
                                 ? 10                                         \
434
1.73M
                                 : 7;                                         \
435
1.73M
      txb_ctx->txb_skip_ctx = ctx_base + ctx_offset;                          \
436
1.73M
    }                                                                         \
437
3.09M
  }
decodetxb.c:get_txb_ctx_32x32
Line
Count
Source
373
2.01M
      TXB_CTX *const txb_ctx) {                                               \
374
2.01M
    static const int8_t signs[3] = { 0, -1, 1 };                              \
375
2.01M
    static const int8_t dc_sign_contexts[4 * MAX_TX_SIZE_UNIT + 1] = {        \
376
2.01M
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,       \
377
2.01M
      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,       \
378
2.01M
      2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2           \
379
2.01M
    };                                                                        \
380
2.01M
    const TX_SIZE tx_size = TX_##w##X##h;                                     \
381
2.01M
    const int txb_w_unit = tx_size_wide_unit[tx_size];                        \
382
2.01M
    const int txb_h_unit = tx_size_high_unit[tx_size];                        \
383
2.01M
    int dc_sign = 0;                                                          \
384
2.01M
    int k = 0;                                                                \
385
2.01M
                                                                              \
386
16.1M
    do {                                                                      \
387
16.1M
      const unsigned int sign = ((uint8_t)a[k]) >> COEFF_CONTEXT_BITS;        \
388
16.1M
      assert(sign <= 2);                                                      \
389
16.1M
      dc_sign += signs[sign];                                                 \
390
16.1M
    } while (++k < txb_w_unit);                                               \
391
2.01M
                                                                              \
392
2.01M
    k = 0;                                                                    \
393
16.1M
    do {                                                                      \
394
16.1M
      const unsigned int sign = ((uint8_t)l[k]) >> COEFF_CONTEXT_BITS;        \
395
16.1M
      assert(sign <= 2);                                                      \
396
16.1M
      dc_sign += signs[sign];                                                 \
397
16.1M
    } while (++k < txb_h_unit);                                               \
398
2.01M
                                                                              \
399
2.01M
    txb_ctx->dc_sign_ctx = dc_sign_contexts[dc_sign + 2 * MAX_TX_SIZE_UNIT];  \
400
2.01M
                                                                              \
401
2.01M
    if (plane == 0) {                                                         \
402
783k
      if (plane_bsize == txsize_to_bsize[tx_size]) {                          \
403
694k
        txb_ctx->txb_skip_ctx = 0;                                            \
404
694k
      } else {                                                                \
405
88.8k
        static const uint8_t skip_contexts[5][5] = { { 1, 2, 2, 2, 3 },       \
406
88.8k
                                                     { 2, 4, 4, 4, 5 },       \
407
88.8k
                                                     { 2, 4, 4, 4, 5 },       \
408
88.8k
                                                     { 2, 4, 4, 4, 5 },       \
409
88.8k
                                                     { 3, 5, 5, 5, 6 } };     \
410
88.8k
        int top = 0;                                                          \
411
88.8k
        int left = 0;                                                         \
412
88.8k
                                                                              \
413
88.8k
        k = 0;                                                                \
414
710k
        do {                                                                  \
415
710k
          top |= a[k];                                                        \
416
710k
        } while (++k < txb_w_unit);                                           \
417
88.8k
        top &= COEFF_CONTEXT_MASK;                                            \
418
88.8k
        top = AOMMIN(top, 4);                                                 \
419
88.8k
                                                                              \
420
88.8k
        k = 0;                                                                \
421
710k
        do {                                                                  \
422
710k
          left |= l[k];                                                       \
423
710k
        } while (++k < txb_h_unit);                                           \
424
88.8k
        left &= COEFF_CONTEXT_MASK;                                           \
425
88.8k
        left = AOMMIN(left, 4);                                               \
426
88.8k
                                                                              \
427
88.8k
        txb_ctx->txb_skip_ctx = skip_contexts[top][left];                     \
428
88.8k
      }                                                                       \
429
1.23M
    } else {                                                                  \
430
1.23M
      const int ctx_base = get_entropy_context(tx_size, a, l);                \
431
1.23M
      const int ctx_offset = (num_pels_log2_lookup[plane_bsize] >             \
432
1.23M
                              num_pels_log2_lookup[txsize_to_bsize[tx_size]]) \
433
1.23M
                                 ? 10                                         \
434
1.23M
                                 : 7;                                         \
435
1.23M
      txb_ctx->txb_skip_ctx = ctx_base + ctx_offset;                          \
436
1.23M
    }                                                                         \
437
2.01M
  }
Unexecuted instantiation: entropy.c:get_txb_ctx_4x4
Unexecuted instantiation: entropy.c:get_txb_ctx_8x8
Unexecuted instantiation: entropy.c:get_txb_ctx_16x16
Unexecuted instantiation: entropy.c:get_txb_ctx_32x32
Unexecuted instantiation: entropymode.c:get_txb_ctx_4x4
Unexecuted instantiation: entropymode.c:get_txb_ctx_8x8
Unexecuted instantiation: entropymode.c:get_txb_ctx_16x16
Unexecuted instantiation: entropymode.c:get_txb_ctx_32x32
Unexecuted instantiation: txb_common.c:get_txb_ctx_4x4
Unexecuted instantiation: txb_common.c:get_txb_ctx_8x8
Unexecuted instantiation: txb_common.c:get_txb_ctx_16x16
Unexecuted instantiation: txb_common.c:get_txb_ctx_32x32
438
439
SPECIALIZE_GET_TXB_CTX(4, 4)
440
SPECIALIZE_GET_TXB_CTX(8, 8)
441
SPECIALIZE_GET_TXB_CTX(16, 16)
442
SPECIALIZE_GET_TXB_CTX(32, 32)
443
444
// Wrapper for get_txb_ctx that calls the specialized version of get_txb_ctc_*
445
// so that the compiler can compile away the while loops.
446
static INLINE void get_txb_ctx(const BLOCK_SIZE plane_bsize,
447
                               const TX_SIZE tx_size, const int plane,
448
                               const ENTROPY_CONTEXT *const a,
449
                               const ENTROPY_CONTEXT *const l,
450
35.3M
                               TXB_CTX *const txb_ctx) {
451
35.3M
  switch (tx_size) {
452
9.86M
    case TX_4X4: get_txb_ctx_4x4(plane_bsize, plane, a, l, txb_ctx); break;
453
5.18M
    case TX_8X8: get_txb_ctx_8x8(plane_bsize, plane, a, l, txb_ctx); break;
454
3.09M
    case TX_16X16: get_txb_ctx_16x16(plane_bsize, plane, a, l, txb_ctx); break;
455
2.01M
    case TX_32X32: get_txb_ctx_32x32(plane_bsize, plane, a, l, txb_ctx); break;
456
15.1M
    default:
457
15.1M
      get_txb_ctx_general(plane_bsize, tx_size, plane, a, l, txb_ctx);
458
15.1M
      break;
459
35.3M
  }
460
35.3M
}
decodetxb.c:get_txb_ctx
Line
Count
Source
450
35.3M
                               TXB_CTX *const txb_ctx) {
451
35.3M
  switch (tx_size) {
452
9.86M
    case TX_4X4: get_txb_ctx_4x4(plane_bsize, plane, a, l, txb_ctx); break;
453
5.18M
    case TX_8X8: get_txb_ctx_8x8(plane_bsize, plane, a, l, txb_ctx); break;
454
3.09M
    case TX_16X16: get_txb_ctx_16x16(plane_bsize, plane, a, l, txb_ctx); break;
455
2.01M
    case TX_32X32: get_txb_ctx_32x32(plane_bsize, plane, a, l, txb_ctx); break;
456
15.1M
    default:
457
15.1M
      get_txb_ctx_general(plane_bsize, tx_size, plane, a, l, txb_ctx);
458
15.1M
      break;
459
35.3M
  }
460
35.3M
}
Unexecuted instantiation: entropy.c:get_txb_ctx
Unexecuted instantiation: entropymode.c:get_txb_ctx
Unexecuted instantiation: txb_common.c:get_txb_ctx
461
#undef MAX_TX_SIZE_UNIT
462
463
#endif  // AOM_AV1_COMMON_TXB_COMMON_H_