Commit 5faff383 authored by Henrik Gramner's avatar Henrik Gramner Committed by Henrik Gramner
Browse files

Eliminate 1D scan tables

parent 989057fb
......@@ -444,32 +444,34 @@ static int decode_coefs(Dav1dTileContext *const t,
// base tokens
uint16_t (*const eob_cdf)[4] = ts->cdf.coef.eob_base_tok[t_dim->ctx][chroma];
uint16_t (*const hi_cdf)[4] = ts->cdf.coef.br_tok[imin(t_dim->ctx, 3)][chroma];
const uint16_t *const scan = dav1d_scans[tx][tx_class];
unsigned rc, dc_tok;
if (eob) {
uint16_t (*const lo_cdf)[4] = ts->cdf.coef.base_tok[t_dim->ctx][chroma];
uint8_t *const levels = t->scratch.levels; // bits 0-5: tok, 6-7: lo_tok
const int sw = imin(t_dim->w, 8), sh = imin(t_dim->h, 8);
const unsigned shift = 2 + imin(t_dim->lh, 3), mask = 4 * sh - 1;
/* eob */
rc = scan[eob];
unsigned x = rc >> shift, y = rc & mask;
unsigned ctx = 1 + (eob > sw * sh * 2) + (eob > sw * sh * 4);
int eob_tok = dav1d_msac_decode_symbol_adapt4(&ts->msac, eob_cdf[ctx], 2);
int tok = eob_tok + 1;
int level_tok = tok * 0x41;
unsigned mag;
if (dbg)
printf("Post-lo_tok[%d][%d][%d][%d=%d=%d]: r=%d\n",
t_dim->ctx, chroma, ctx, eob, rc, tok, ts->msac.rng);
#define DECODE_COEFS_CLASS(tx_class) \
unsigned x, y; \
if (tx_class == TX_CLASS_2D) \
rc = scan[eob], x = rc >> shift, y = rc & mask; \
else if (tx_class == TX_CLASS_H) \
/* Transposing reduces the stride and padding requirements */ \
x = eob & mask, y = eob >> shift, rc = eob; \
else /* tx_class == TX_CLASS_V */ \
x = eob & mask, y = eob >> shift, rc = (x << shift2) | y; \
if (dbg) \
printf("Post-lo_tok[%d][%d][%d][%d=%d=%d]: r=%d\n", \
t_dim->ctx, chroma, ctx, eob, rc, tok, ts->msac.rng); \
if (eob_tok == 2) { \
ctx = (tx_class == TX_CLASS_2D ? (x | y) > 1 : \
tx_class == TX_CLASS_H ? x != 0 : y != 0) ? 14 : 7; \
ctx = (tx_class == TX_CLASS_2D ? (x | y) > 1 : y != 0) ? 14 : 7; \
tok = dav1d_msac_decode_hi_tok(&ts->msac, hi_cdf[ctx]); \
level_tok = tok + (3 << 6); \
if (dbg) \
......@@ -478,17 +480,15 @@ static int decode_coefs(Dav1dTileContext *const t,
ts->msac.rng); \
} \
cf[rc] = tok << 11; \
if (tx_class == TX_CLASS_H) \
/* Transposing reduces the stride and padding requirements */ \
levels[y * stride + x] = (uint8_t) level_tok; \
else \
levels[x * stride + y] = (uint8_t) level_tok; \
levels[x * stride + y] = (uint8_t) level_tok; \
for (int i = eob - 1; i > 0; i--) { /* ac */ \
unsigned rc_i; \
if (tx_class == TX_CLASS_H) \
rc_i = i, x = rc_i & mask, y = rc_i >> shift; \
else \
if (tx_class == TX_CLASS_2D) \
rc_i = scan[i], x = rc_i >> shift, y = rc_i & mask; \
else if (tx_class == TX_CLASS_H) \
x = i & mask, y = i >> shift, rc_i = i; \
else /* tx_class == TX_CLASS_V */ \
x = i & mask, y = i >> shift, rc_i = (x << shift2) | y; \
assert(x < 32 && y < 32); \
uint8_t *const level = levels + x * stride + y; \
ctx = get_lo_ctx(level, tx_class, &mag, lo_ctx_offsets, x, y, stride); \
......@@ -540,27 +540,33 @@ static int decode_coefs(Dav1dTileContext *const t,
} \
break
const uint8_t (*lo_ctx_offsets)[5];
const uint16_t *scan;
switch (tx_class) {
case TX_CLASS_2D: {
const unsigned nonsquare_tx = tx >= RTX_4X8;
const uint8_t (*const lo_ctx_offsets)[5] =
dav1d_lo_ctx_offsets[nonsquare_tx + (tx & nonsquare_tx)];
lo_ctx_offsets = dav1d_lo_ctx_offsets[nonsquare_tx + (tx & nonsquare_tx)];
scan = dav1d_scans[tx];
const ptrdiff_t stride = 4 * sh;
const unsigned shift = t_dim->lh < 4 ? t_dim->lh + 2 : 5, shift2 = 0;
const unsigned mask = 4 * sh - 1;
memset(levels, 0, stride * (4 * sw + 2));
DECODE_COEFS_CLASS(TX_CLASS_2D);
}
case TX_CLASS_H: {
#define lo_ctx_offsets NULL
const ptrdiff_t stride = 16;
const unsigned shift = t_dim->lh + 2, shift2 = 0;
const unsigned mask = 4 * sh - 1;
memset(levels, 0, stride * (4 * sh + 2));
DECODE_COEFS_CLASS(TX_CLASS_H);
}
case TX_CLASS_V: {
const ptrdiff_t stride = 16;
const unsigned shift = t_dim->lw + 2, shift2 = t_dim->lh + 2;
const unsigned mask = 4 * sw - 1;
memset(levels, 0, stride * (4 * sw + 2));
DECODE_COEFS_CLASS(TX_CLASS_V);
}
#undef lo_ctx_offsets
#undef DECODE_COEFS_CLASS
default: assert(0);
}
......
......@@ -30,19 +30,14 @@
#include "common/attributes.h"
#include "src/scan.h"
static const uint16_t ALIGN(av1_default_scan_4x4[], 32) = {
static const uint16_t ALIGN(scan_4x4[], 32) = {
0, 4, 1, 2,
5, 8, 12, 9,
6, 3, 7, 10,
13, 14, 11, 15,
};
static const uint16_t ALIGN(av1_mrow_scan_4x4[], 32) = {
0, 4, 8, 12,
1, 5, 9, 13,
2, 6, 10, 14,
3, 7, 11, 15,
};
static const uint16_t ALIGN(av1_default_scan_4x8[], 32) = {
static const uint16_t ALIGN(scan_4x8[], 32) = {
0, 8, 1, 16,
9, 2, 24, 17,
10, 3, 25, 18,
......@@ -52,17 +47,8 @@ static const uint16_t ALIGN(av1_default_scan_4x8[], 32) = {
14, 7, 29, 22,
15, 30, 23, 31,
};
static const uint16_t ALIGN(av1_mrow_scan_4x8[], 32) = {
0, 8, 16, 24,
1, 9, 17, 25,
2, 10, 18, 26,
3, 11, 19, 27,
4, 12, 20, 28,
5, 13, 21, 29,
6, 14, 22, 30,
7, 15, 23, 31,
};
static const uint16_t ALIGN(av1_default_scan_4x16[], 32) = {
static const uint16_t ALIGN(scan_4x16[], 32) = {
0, 16, 1, 32,
17, 2, 48, 33,
18, 3, 49, 34,
......@@ -80,37 +66,15 @@ static const uint16_t ALIGN(av1_default_scan_4x16[], 32) = {
30, 15, 61, 46,
31, 62, 47, 63,
};
static const uint16_t ALIGN(av1_mrow_scan_4x16[], 32) = {
0, 16, 32, 48,
1, 17, 33, 49,
2, 18, 34, 50,
3, 19, 35, 51,
4, 20, 36, 52,
5, 21, 37, 53,
6, 22, 38, 54,
7, 23, 39, 55,
8, 24, 40, 56,
9, 25, 41, 57,
10, 26, 42, 58,
11, 27, 43, 59,
12, 28, 44, 60,
13, 29, 45, 61,
14, 30, 46, 62,
15, 31, 47, 63,
};
static const uint16_t ALIGN(av1_default_scan_8x4[], 32) = {
static const uint16_t ALIGN(scan_8x4[], 32) = {
0, 1, 4, 2, 5, 8, 3, 6,
9, 12, 7, 10, 13, 16, 11, 14,
17, 20, 15, 18, 21, 24, 19, 22,
25, 28, 23, 26, 29, 27, 30, 31,
};
static const uint16_t ALIGN(av1_mrow_scan_8x4[], 32) = {
0, 4, 8, 12, 16, 20, 24, 28,
1, 5, 9, 13, 17, 21, 25, 29,
2, 6, 10, 14, 18, 22, 26, 30,
3, 7, 11, 15, 19, 23, 27, 31,
};
static const uint16_t ALIGN(av1_default_scan_8x8[], 32) = {
static const uint16_t ALIGN(scan_8x8[], 32) = {
0, 8, 1, 2, 9, 16, 24, 17,
10, 3, 4, 11, 18, 25, 32, 40,
33, 26, 19, 12, 5, 6, 13, 20,
......@@ -120,17 +84,8 @@ static const uint16_t ALIGN(av1_default_scan_8x8[], 32) = {
23, 31, 38, 45, 52, 59, 60, 53,
46, 39, 47, 54, 61, 62, 55, 63,
};
static const uint16_t ALIGN(av1_mrow_scan_8x8[], 32) = {
0, 8, 16, 24, 32, 40, 48, 56,
1, 9, 17, 25, 33, 41, 49, 57,
2, 10, 18, 26, 34, 42, 50, 58,
3, 11, 19, 27, 35, 43, 51, 59,
4, 12, 20, 28, 36, 44, 52, 60,
5, 13, 21, 29, 37, 45, 53, 61,
6, 14, 22, 30, 38, 46, 54, 62,
7, 15, 23, 31, 39, 47, 55, 63,
};
static const uint16_t ALIGN(av1_default_scan_8x16[], 32) = {
static const uint16_t ALIGN(scan_8x16[], 32) = {
0, 16, 1, 32, 17, 2, 48, 33,
18, 3, 64, 49, 34, 19, 4, 80,
65, 50, 35, 20, 5, 96, 81, 66,
......@@ -148,25 +103,8 @@ static const uint16_t ALIGN(av1_default_scan_8x16[], 32) = {
47, 123, 108, 93, 78, 63, 124, 109,
94, 79, 125, 110, 95, 126, 111, 127,
};
static const uint16_t ALIGN(av1_mrow_scan_8x16[], 32) = {
0, 16, 32, 48, 64, 80, 96, 112,
1, 17, 33, 49, 65, 81, 97, 113,
2, 18, 34, 50, 66, 82, 98, 114,
3, 19, 35, 51, 67, 83, 99, 115,
4, 20, 36, 52, 68, 84, 100, 116,
5, 21, 37, 53, 69, 85, 101, 117,
6, 22, 38, 54, 70, 86, 102, 118,
7, 23, 39, 55, 71, 87, 103, 119,
8, 24, 40, 56, 72, 88, 104, 120,
9, 25, 41, 57, 73, 89, 105, 121,
10, 26, 42, 58, 74, 90, 106, 122,
11, 27, 43, 59, 75, 91, 107, 123,
12, 28, 44, 60, 76, 92, 108, 124,
13, 29, 45, 61, 77, 93, 109, 125,
14, 30, 46, 62, 78, 94, 110, 126,
15, 31, 47, 63, 79, 95, 111, 127,
};
static const uint16_t ALIGN(av1_default_scan_8x32[], 32) = {
static const uint16_t ALIGN(scan_8x32[], 32) = {
0, 32, 1, 64, 33, 2, 96, 65,
34, 3, 128, 97, 66, 35, 4, 160,
129, 98, 67, 36, 5, 192, 161, 130,
......@@ -200,19 +138,15 @@ static const uint16_t ALIGN(av1_default_scan_8x32[], 32) = {
95, 251, 220, 189, 158, 127, 252, 221,
190, 159, 253, 222, 191, 254, 223, 255,
};
static const uint16_t ALIGN(av1_default_scan_16x4[], 32) = {
static const uint16_t ALIGN(scan_16x4[], 32) = {
0, 1, 4, 2, 5, 8, 3, 6, 9, 12, 7, 10, 13, 16, 11, 14,
17, 20, 15, 18, 21, 24, 19, 22, 25, 28, 23, 26, 29, 32, 27, 30,
33, 36, 31, 34, 37, 40, 35, 38, 41, 44, 39, 42, 45, 48, 43, 46,
49, 52, 47, 50, 53, 56, 51, 54, 57, 60, 55, 58, 61, 59, 62, 63,
};
static const uint16_t ALIGN(av1_mrow_scan_16x4[], 32) = {
0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60,
1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61,
2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62,
3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63,
};
static const uint16_t ALIGN(av1_default_scan_16x8[], 32) = {
static const uint16_t ALIGN(scan_16x8[], 32) = {
0, 1, 8, 2, 9, 16, 3, 10, 17, 24, 4, 11, 18, 25, 32, 5,
12, 19, 26, 33, 40, 6, 13, 20, 27, 34, 41, 48, 7, 14, 21, 28,
35, 42, 49, 56, 15, 22, 29, 36, 43, 50, 57, 64, 23, 30, 37, 44,
......@@ -222,17 +156,8 @@ static const uint16_t ALIGN(av1_default_scan_16x8[], 32) = {
99, 106, 113, 120, 79, 86, 93, 100, 107, 114, 121, 87, 94, 101, 108, 115,
122, 95, 102, 109, 116, 123, 103, 110, 117, 124, 111, 118, 125, 119, 126, 127,
};
static const uint16_t ALIGN(av1_mrow_scan_16x8[], 32) = {
0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120,
1, 9, 17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97, 105, 113, 121,
2, 10, 18, 26, 34, 42, 50, 58, 66, 74, 82, 90, 98, 106, 114, 122,
3, 11, 19, 27, 35, 43, 51, 59, 67, 75, 83, 91, 99, 107, 115, 123,
4, 12, 20, 28, 36, 44, 52, 60, 68, 76, 84, 92, 100, 108, 116, 124,
5, 13, 21, 29, 37, 45, 53, 61, 69, 77, 85, 93, 101, 109, 117, 125,
6, 14, 22, 30, 38, 46, 54, 62, 70, 78, 86, 94, 102, 110, 118, 126,
7, 15, 23, 31, 39, 47, 55, 63, 71, 79, 87, 95, 103, 111, 119, 127,
};
static const uint16_t ALIGN(av1_default_scan_16x16[], 32) = {
static const uint16_t ALIGN(scan_16x16[], 32) = {
0, 16, 1, 2, 17, 32, 48, 33, 18, 3, 4, 19, 34, 49, 64, 80,
65, 50, 35, 20, 5, 6, 21, 36, 51, 66, 81, 96, 112, 97, 82, 67,
52, 37, 22, 7, 8, 23, 38, 53, 68, 83, 98, 113, 128, 144, 129, 114,
......@@ -250,43 +175,8 @@ static const uint16_t ALIGN(av1_default_scan_16x16[], 32) = {
188, 173, 158, 143, 159, 174, 189, 204, 219, 234, 249, 250, 235, 220, 205, 190,
175, 191, 206, 221, 236, 251, 252, 237, 222, 207, 223, 238, 253, 254, 239, 255,
};
static const uint16_t ALIGN(av1_mrow_scan_16x16[], 32) = {
0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240,
1, 17, 33, 49, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241,
2, 18, 34, 50, 66, 82, 98, 114, 130, 146, 162, 178, 194, 210, 226, 242,
3, 19, 35, 51, 67, 83, 99, 115, 131, 147, 163, 179, 195, 211, 227, 243,
4, 20, 36, 52, 68, 84, 100, 116, 132, 148, 164, 180, 196, 212, 228, 244,
5, 21, 37, 53, 69, 85, 101, 117, 133, 149, 165, 181, 197, 213, 229, 245,
6, 22, 38, 54, 70, 86, 102, 118, 134, 150, 166, 182, 198, 214, 230, 246,
7, 23, 39, 55, 71, 87, 103, 119, 135, 151, 167, 183, 199, 215, 231, 247,
8, 24, 40, 56, 72, 88, 104, 120, 136, 152, 168, 184, 200, 216, 232, 248,
9, 25, 41, 57, 73, 89, 105, 121, 137, 153, 169, 185, 201, 217, 233, 249,
10, 26, 42, 58, 74, 90, 106, 122, 138, 154, 170, 186, 202, 218, 234, 250,
11, 27, 43, 59, 75, 91, 107, 123, 139, 155, 171, 187, 203, 219, 235, 251,
12, 28, 44, 60, 76, 92, 108, 124, 140, 156, 172, 188, 204, 220, 236, 252,
13, 29, 45, 61, 77, 93, 109, 125, 141, 157, 173, 189, 205, 221, 237, 253,
14, 30, 46, 62, 78, 94, 110, 126, 142, 158, 174, 190, 206, 222, 238, 254,
15, 31, 47, 63, 79, 95, 111, 127, 143, 159, 175, 191, 207, 223, 239, 255,
};
static const uint16_t ALIGN(av1_mcol_scan_16x16[], 32) = {
0, 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,
};
static const uint16_t ALIGN(av1_default_scan_16x32[], 32) = {
static const uint16_t ALIGN(scan_16x32[], 32) = {
0, 32, 1, 64, 33, 2, 96, 65, 34, 3, 128, 97, 66, 35, 4, 160,
129, 98, 67, 36, 5, 192, 161, 130, 99, 68, 37, 6, 224, 193, 162, 131,
100, 69, 38, 7, 256, 225, 194, 163, 132, 101, 70, 39, 8, 288, 257, 226,
......@@ -320,7 +210,8 @@ static const uint16_t ALIGN(av1_default_scan_16x32[], 32) = {
380, 349, 318, 287, 505, 474, 443, 412, 381, 350, 319, 506, 475, 444, 413, 382,
351, 507, 476, 445, 414, 383, 508, 477, 446, 415, 509, 478, 447, 510, 479, 511,
};
static const uint16_t ALIGN(av1_default_scan_32x8[], 32) = {
static const uint16_t ALIGN(scan_32x8[], 32) = {
0, 1, 8, 2, 9, 16, 3, 10, 17, 24, 4, 11, 18, 25, 32, 5, 12, 19, 26, 33, 40, 6, 13, 20, 27, 34, 41, 48, 7, 14, 21, 28,
35, 42, 49, 56, 15, 22, 29, 36, 43, 50, 57, 64, 23, 30, 37, 44, 51, 58, 65, 72, 31, 38, 45, 52, 59, 66, 73, 80, 39, 46, 53, 60,
67, 74, 81, 88, 47, 54, 61, 68, 75, 82, 89, 96, 55, 62, 69, 76, 83, 90, 97, 104, 63, 70, 77, 84, 91, 98, 105, 112, 71, 78, 85, 92,
......@@ -330,7 +221,8 @@ static const uint16_t ALIGN(av1_default_scan_32x8[], 32) = {
195, 202, 209, 216, 175, 182, 189, 196, 203, 210, 217, 224, 183, 190, 197, 204, 211, 218, 225, 232, 191, 198, 205, 212, 219, 226, 233, 240, 199, 206, 213, 220,
227, 234, 241, 248, 207, 214, 221, 228, 235, 242, 249, 215, 222, 229, 236, 243, 250, 223, 230, 237, 244, 251, 231, 238, 245, 252, 239, 246, 253, 247, 254, 255,
};
static const uint16_t ALIGN(av1_default_scan_32x16[], 32) = {
static const uint16_t ALIGN(scan_32x16[], 32) = {
0, 1, 16, 2, 17, 32, 3, 18, 33, 48, 4, 19, 34, 49, 64, 5, 20, 35, 50, 65, 80, 6, 21, 36, 51, 66, 81, 96, 7, 22, 37, 52,
67, 82, 97, 112, 8, 23, 38, 53, 68, 83, 98, 113, 128, 9, 24, 39, 54, 69, 84, 99, 114, 129, 144, 10, 25, 40, 55, 70, 85, 100, 115, 130,
145, 160, 11, 26, 41, 56, 71, 86, 101, 116, 131, 146, 161, 176, 12, 27, 42, 57, 72, 87, 102, 117, 132, 147, 162, 177, 192, 13, 28, 43, 58, 73,
......@@ -348,7 +240,8 @@ static const uint16_t ALIGN(av1_default_scan_32x16[], 32) = {
381, 396, 411, 426, 441, 456, 471, 486, 501, 367, 382, 397, 412, 427, 442, 457, 472, 487, 502, 383, 398, 413, 428, 443, 458, 473, 488, 503, 399, 414, 429, 444,
459, 474, 489, 504, 415, 430, 445, 460, 475, 490, 505, 431, 446, 461, 476, 491, 506, 447, 462, 477, 492, 507, 463, 478, 493, 508, 479, 494, 509, 495, 510, 511,
};
static const uint16_t ALIGN(av1_default_scan_32x32[], 32) = {
static const uint16_t ALIGN(scan_32x32[], 32) = {
0, 32, 1, 2, 33, 64, 96, 65, 34, 3, 4, 35, 66, 97, 128, 160, 129, 98, 67, 36, 5, 6, 37, 68, 99, 130, 161, 192, 224, 193, 162, 131,
100, 69, 38, 7, 8, 39, 70, 101, 132, 163, 194, 225, 256, 288, 257, 226, 195, 164, 133, 102, 71, 40, 9, 10, 41, 72, 103, 134, 165, 196, 227, 258,
289, 320, 352, 321, 290, 259, 228, 197, 166, 135, 104, 73, 42, 11, 12, 43, 74, 105, 136, 167, 198, 229, 260, 291, 322, 353, 384, 416, 385, 354, 323, 292,
......@@ -383,62 +276,24 @@ static const uint16_t ALIGN(av1_default_scan_32x32[], 32) = {
892, 861, 830, 799, 831, 862, 893, 924, 955, 986, 1017, 1018, 987, 956, 925, 894, 863, 895, 926, 957, 988, 1019, 1020, 989, 958, 927, 959, 990, 1021, 1022, 991, 1023,
};
const uint16_t *const dav1d_scans[N_RECT_TX_SIZES][3] = {
[TX_4X4] = {
[TX_CLASS_2D] = av1_default_scan_4x4,
[TX_CLASS_V] = av1_mrow_scan_4x4,
[TX_CLASS_H] = av1_mcol_scan_16x16,
}, [TX_8X8] = {
[TX_CLASS_2D] = av1_default_scan_8x8,
[TX_CLASS_V] = av1_mrow_scan_8x8,
[TX_CLASS_H] = av1_mcol_scan_16x16,
}, [TX_16X16] = {
[TX_CLASS_2D] = av1_default_scan_16x16,
[TX_CLASS_V] = av1_mrow_scan_16x16,
[TX_CLASS_H] = av1_mcol_scan_16x16,
}, [TX_32X32] = {
[TX_CLASS_2D] = av1_default_scan_32x32,
}, [TX_64X64] = {
[TX_CLASS_2D] = av1_default_scan_32x32,
}, [RTX_4X8] = {
[TX_CLASS_2D] = av1_default_scan_4x8,
[TX_CLASS_V] = av1_mrow_scan_4x8,
[TX_CLASS_H] = av1_mcol_scan_16x16,
}, [RTX_8X4] = {
[TX_CLASS_2D] = av1_default_scan_8x4,
[TX_CLASS_V] = av1_mrow_scan_8x4,
[TX_CLASS_H] = av1_mcol_scan_16x16,
}, [RTX_8X16] = {
[TX_CLASS_2D] = av1_default_scan_8x16,
[TX_CLASS_V] = av1_mrow_scan_8x16,
[TX_CLASS_H] = av1_mcol_scan_16x16,
}, [RTX_16X8] = {
[TX_CLASS_2D] = av1_default_scan_16x8,
[TX_CLASS_V] = av1_mrow_scan_16x8,
[TX_CLASS_H] = av1_mcol_scan_16x16,
}, [RTX_16X32] = {
[TX_CLASS_2D] = av1_default_scan_16x32,
}, [RTX_32X16] = {
[TX_CLASS_2D] = av1_default_scan_32x16,
}, [RTX_32X64] = {
[TX_CLASS_2D] = av1_default_scan_32x32,
}, [RTX_64X32] = {
[TX_CLASS_2D] = av1_default_scan_32x32,
}, [RTX_4X16] = {
[TX_CLASS_2D] = av1_default_scan_4x16,
[TX_CLASS_V] = av1_mrow_scan_4x16,
[TX_CLASS_H] = av1_mcol_scan_16x16,
}, [RTX_16X4] = {
[TX_CLASS_2D] = av1_default_scan_16x4,
[TX_CLASS_V] = av1_mrow_scan_16x4,
[TX_CLASS_H] = av1_mcol_scan_16x16,
}, [RTX_8X32] = {
[TX_CLASS_2D] = av1_default_scan_8x32,
}, [RTX_32X8] = {
[TX_CLASS_2D] = av1_default_scan_32x8,
}, [RTX_16X64] = {
[TX_CLASS_2D] = av1_default_scan_16x32,
}, [RTX_64X16] = {
[TX_CLASS_2D] = av1_default_scan_32x16,
},
const uint16_t *const dav1d_scans[N_RECT_TX_SIZES] = {
[ TX_4X4 ] = scan_4x4,
[ TX_8X8 ] = scan_8x8,
[ TX_16X16] = scan_16x16,
[ TX_32X32] = scan_32x32,
[ TX_64X64] = scan_32x32,
[RTX_4X8 ] = scan_4x8,
[RTX_8X4 ] = scan_8x4,
[RTX_8X16 ] = scan_8x16,
[RTX_16X8 ] = scan_16x8,
[RTX_16X32] = scan_16x32,
[RTX_32X16] = scan_32x16,
[RTX_32X64] = scan_32x32,
[RTX_64X32] = scan_32x32,
[RTX_4X16 ] = scan_4x16,
[RTX_16X4 ] = scan_16x4,
[RTX_8X32 ] = scan_8x32,
[RTX_32X8 ] = scan_32x8,
[RTX_16X64] = scan_16x32,
[RTX_64X16] = scan_32x16,
};
......@@ -32,6 +32,6 @@
#include "src/levels.h"
extern const uint16_t *const dav1d_scans[N_RECT_TX_SIZES][3];
extern const uint16_t *const dav1d_scans[N_RECT_TX_SIZES];
#endif /* DAV1D_SRC_SCAN_H */
......@@ -138,14 +138,21 @@ static int copy_subcoefs(coef *coeff,
* dimensions are non-zero. This leads to braching to specific optimized
* simd versions (e.g. dc-only) so that we get full asm coverage in this
* test */
const uint16_t *const scan = dav1d_scans[tx][dav1d_tx_type_class[txtp]];
const enum TxClass tx_class = dav1d_tx_type_class[txtp];
const uint16_t *const scan = dav1d_scans[tx];
const int sub_high = subsh > 0 ? subsh * 8 - 1 : 0;
const int sub_low = subsh > 1 ? sub_high - 8 : 0;
int n, eob;
for (n = 0, eob = 0; n < sw * sh; n++) {
const int rc = scan[n];
const int rcx = rc % sh, rcy = rc / sh;
int rc, rcx, rcy;
if (tx_class == TX_CLASS_2D)
rc = scan[n], rcx = rc % sh, rcy = rc / sh;
else if (tx_class == TX_CLASS_H)
rcx = n % sh, rcy = n / sh, rc = n;
else /* tx_class == TX_CLASS_V */
rcx = n / sw, rcy = n % sw, rc = rcy * sh + rcx;
/* Pick a random eob within this sub-itx */
if (rcx > sub_high || rcy > sub_high) {
......@@ -156,8 +163,18 @@ static int copy_subcoefs(coef *coeff,
if (eob)
eob += rnd() % (n - eob - 1);
for (n = eob + 1; n < sw * sh; n++)
coeff[scan[n]] = 0;
if (tx_class == TX_CLASS_2D)
for (n = eob + 1; n < sw * sh; n++)
coeff[scan[n]] = 0;
else if (tx_class == TX_CLASS_H)
for (n = eob + 1; n < sw * sh; n++)
coeff[n] = 0;
else /* tx_class == TX_CLASS_V */ {
for (int rcx = eob / sw, rcy = eob % sw; rcx < sh; rcx++, rcy = -1)
while (++rcy < sw)
coeff[rcy * sh + rcx] = 0;
n = sw * sh;
}
for (; n < 32 * 32; n++)
coeff[n] = rnd();
return eob;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment