forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust382.4 MiBe18142dTahinli10 hours ago4543 commits

h263data.rs597 lines, 17.2 KiBHistoryRawDownload
1// Generated by crates/ec-mpeg4/gen_h263_tables.py from the text of ITU-T Rec. H.263 (01/2005)
2// (https://www.itu.int/rec/T-REC-H.263). Do not edit by hand.
3//
4// Every table in this file is transcribed from the Recommendation; the clause or table
5// number is given in each doc comment. A `[code, bits]` pair holds a variable length
6// code as its integer value and its length in bits (the sign bit of TCOEF / MVD
7// codes is not included).
8
9/// MCBPC for I pictures, code value by spec index (Table 7/H.263; index 8 is stuffing).
10pub const H263_INTRA_MCBPC_CODE: [u8; 9] = [1, 1, 2, 3, 1, 1, 2, 3, 1];
11
12/// MCBPC for I pictures, code length (Table 7/H.263).
13pub const H263_INTRA_MCBPC_BITS: [u8; 9] = [1, 3, 3, 3, 4, 6, 6, 6, 9];
14
15/// MCBPC for P pictures, code value. Slot = 4 * group + CBPC with group = INTRA + 2 * Q + 4 * four-vectors flags of the MB type (types 0, 3, 1, 4, 2 -> groups 0..4, type 5 -> group 6), slot 20 = stuffing, slots 21-23 unused (Table 8/H.263).
16pub const H263_INTER_MCBPC_CODE: [u8; 28] = [
17 1, 3, 2, 5, 3, 4, 3, 3, 3, 7, 6, 5, 4, 4, 3, 2, 2, 5, 4, 5, 1, 0, 0, 0, 2, 12, 14, 15,
18];
19
20/// MCBPC for P pictures, code length (Table 8/H.263); 0 marks an unused slot.
21pub const H263_INTER_MCBPC_BITS: [u8; 28] = [
22 1, 4, 4, 6, 5, 8, 8, 7, 3, 7, 7, 9, 6, 9, 9, 9, 3, 7, 7, 8, 9, 0, 0, 0, 11, 13, 13, 13,
23];
24
25/// CBPY, indexed by the INTRA pattern value (12,34) read as four bits (Table 12/H.263); the INTER code is that of the complemented pattern.
26pub const H263_CBPY_TAB: [[u8; 2]; 16] = [
27 [3, 4],
28 [5, 5],
29 [4, 5],
30 [9, 4],
31 [3, 5],
32 [7, 4],
33 [2, 6],
34 [11, 4],
35 [2, 5],
36 [3, 6],
37 [5, 4],
38 [10, 4],
39 [4, 4],
40 [8, 4],
41 [6, 4],
42 [3, 2],
43];
44
45/// MVD, indexed by the absolute vector difference in half samples 0..32 (Table 14/H.263); the sign bit follows the code, +-16 share one code.
46pub const MVTAB: [[u8; 2]; 33] = [
47 [1, 1],
48 [1, 2],
49 [1, 3],
50 [1, 4],
51 [3, 6],
52 [5, 7],
53 [4, 7],
54 [3, 7],
55 [11, 9],
56 [10, 9],
57 [9, 9],
58 [17, 10],
59 [16, 10],
60 [15, 10],
61 [14, 10],
62 [13, 10],
63 [12, 10],
64 [11, 10],
65 [10, 10],
66 [9, 10],
67 [8, 10],
68 [7, 10],
69 [6, 10],
70 [5, 10],
71 [4, 10],
72 [7, 11],
73 [6, 11],
74 [5, 11],
75 [4, 11],
76 [3, 11],
77 [2, 11],
78 [3, 12],
79 [2, 12],
80];
81
82/// TCOEF VLC without the sign bit, 102 (LAST, RUN, |LEVEL|) codes sorted by LAST, RUN, |LEVEL| followed by ESCAPE (Table 16/H.263).
83pub const INTER_VLC: [[u16; 2]; 103] = [
84 [2, 2],
85 [15, 4],
86 [21, 6],
87 [23, 7],
88 [31, 8],
89 [37, 9],
90 [36, 9],
91 [33, 10],
92 [32, 10],
93 [7, 11],
94 [6, 11],
95 [32, 11],
96 [6, 3],
97 [20, 6],
98 [30, 8],
99 [15, 10],
100 [33, 11],
101 [80, 12],
102 [14, 4],
103 [29, 8],
104 [14, 10],
105 [81, 12],
106 [13, 5],
107 [35, 9],
108 [13, 10],
109 [12, 5],
110 [34, 9],
111 [82, 12],
112 [11, 5],
113 [12, 10],
114 [83, 12],
115 [19, 6],
116 [11, 10],
117 [84, 12],
118 [18, 6],
119 [10, 10],
120 [17, 6],
121 [9, 10],
122 [16, 6],
123 [8, 10],
124 [22, 7],
125 [85, 12],
126 [21, 7],
127 [20, 7],
128 [28, 8],
129 [27, 8],
130 [33, 9],
131 [32, 9],
132 [31, 9],
133 [30, 9],
134 [29, 9],
135 [28, 9],
136 [27, 9],
137 [26, 9],
138 [34, 11],
139 [35, 11],
140 [86, 12],
141 [87, 12],
142 [7, 4],
143 [25, 9],
144 [5, 11],
145 [15, 6],
146 [4, 11],
147 [14, 6],
148 [13, 6],
149 [12, 6],
150 [19, 7],
151 [18, 7],
152 [17, 7],
153 [16, 7],
154 [26, 8],
155 [25, 8],
156 [24, 8],
157 [23, 8],
158 [22, 8],
159 [21, 8],
160 [20, 8],
161 [19, 8],
162 [24, 9],
163 [23, 9],
164 [22, 9],
165 [21, 9],
166 [20, 9],
167 [19, 9],
168 [18, 9],
169 [17, 9],
170 [7, 10],
171 [6, 10],
172 [5, 10],
173 [4, 10],
174 [36, 11],
175 [37, 11],
176 [38, 11],
177 [39, 11],
178 [88, 12],
179 [89, 12],
180 [90, 12],
181 [91, 12],
182 [92, 12],
183 [93, 12],
184 [94, 12],
185 [95, 12],
186 [3, 7],
187];
188
189/// |LEVEL| of the entries of INTER_VLC (Table 16/H.263).
190pub const INTER_LEVEL: [i8; 102] = [
191 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 1, 2, 3,
192 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 2,
193 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
194 1, 1, 1, 1, 1, 1, 1,
195];
196
197/// RUN of the entries of INTER_VLC (Table 16/H.263).
198pub const INTER_RUN: [i8; 102] = [
199 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6,
200 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
201 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
202 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
203];
204
205/// Zigzag scan: raster position (row * 8 + column) of each scan index (Figure 14/H.263).
206pub const ZIGZAG_DIRECT: [u8; 64] = [
207 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20,
208 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59,
209 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63,
210];
211
212/// Alternate-Horizontal scan (Figure I.2-a/H.263).
213pub const ALTERNATE_HORIZONTAL_SCAN: [u8; 64] = [
214 0, 1, 2, 3, 8, 9, 16, 17, 10, 11, 4, 5, 6, 7, 15, 14, 13, 12, 19, 18, 24, 25, 32, 33, 26, 27,
215 20, 21, 22, 23, 28, 29, 30, 31, 34, 35, 40, 41, 48, 49, 42, 43, 36, 37, 38, 39, 44, 45, 46, 47,
216 50, 51, 56, 57, 58, 59, 52, 53, 54, 55, 60, 61, 62, 63,
217];
218
219/// Alternate-Vertical scan (Figure I.2-b/H.263, as in H.262).
220pub const ALTERNATE_VERTICAL_SCAN: [u8; 64] = [
221 0, 8, 16, 24, 1, 9, 2, 10, 17, 25, 32, 40, 48, 56, 57, 49, 41, 33, 26, 18, 3, 11, 4, 12, 19,
222 27, 34, 42, 50, 58, 35, 43, 51, 59, 20, 28, 5, 13, 6, 14, 21, 29, 36, 44, 52, 60, 37, 45, 53,
223 61, 22, 30, 7, 15, 23, 31, 38, 46, 54, 62, 39, 47, 55, 63,
224];
225
226/// Source format dimensions by PTYPE source-format code 0-7 (width, height; Table 2/H.263 and 5.1.3); 0, 6 and 7 are not standard formats.
227pub const H263_FORMAT: [[u16; 2]; 8] = [
228 [0, 0],
229 [128, 96],
230 [176, 144],
231 [352, 288],
232 [704, 576],
233 [1408, 1152],
234 [0, 0],
235 [0, 0],
236];
237
238/// Pixel aspect ratio (width, height) by PAR code (Table 5/H.263); forbidden, reserved and extended codes give (0, 1).
239pub const H263_PIXEL_ASPECT: [[u8; 2]; 16] = [
240 [0, 1],
241 [1, 1],
242 [12, 11],
243 [10, 11],
244 [16, 11],
245 [40, 33],
246 [0, 1],
247 [0, 1],
248 [0, 1],
249 [0, 1],
250 [0, 1],
251 [0, 1],
252 [0, 1],
253 [0, 1],
254 [0, 1],
255 [0, 1],
256];
257
258// Number of entries (without ESCAPE) and number of LAST = 0 entries of the TCOEF tables.
259pub const H263_RL_INTER_N: usize = 102;
260pub const H263_RL_INTER_LAST: usize = 58;
261
262#[cfg(test)]
263mod spec_tests {
264 //! The rows below are the printed codes of the Recommendation; the tests rebuild
265 //! the packed tables from them and compare.
266 use super::*;
267
268 fn val(c: &str) -> (u32, u32) {
269 (u32::from_str_radix(c, 2).unwrap(), c.len() as u32)
270 }
271
272 /// (MB type, CBPC, code) of Table 7/H.263, indices 0-8.
273 const T7: [(&str, &str, &str); 9] = [
274 ("3", "00", "1"),
275 ("3", "01", "001"),
276 ("3", "10", "010"),
277 ("3", "11", "011"),
278 ("4", "00", "0001"),
279 ("4", "01", "000001"),
280 ("4", "10", "000010"),
281 ("4", "11", "000011"),
282 ("Stuffing", "-", "000000001"),
283 ];
284 /// (MB type, CBPC, code) of Table 8/H.263, indices 0-24.
285 const T8: [(&str, &str, &str); 25] = [
286 ("0", "00", "1"),
287 ("0", "01", "0011"),
288 ("0", "10", "0010"),
289 ("0", "11", "000101"),
290 ("1", "00", "011"),
291 ("1", "01", "0000111"),
292 ("1", "10", "0000110"),
293 ("1", "11", "000000101"),
294 ("2", "00", "010"),
295 ("2", "01", "0000101"),
296 ("2", "10", "0000100"),
297 ("2", "11", "00000101"),
298 ("3", "00", "00011"),
299 ("3", "01", "00000100"),
300 ("3", "10", "00000011"),
301 ("3", "11", "0000011"),
302 ("4", "00", "000100"),
303 ("4", "01", "000000100"),
304 ("4", "10", "000000011"),
305 ("4", "11", "000000010"),
306 ("Stuffing", "-", "000000001"),
307 ("5", "00", "00000000010"),
308 ("5", "01", "0000000001100"),
309 ("5", "10", "0000000001110"),
310 ("5", "11", "0000000001111"),
311 ];
312 /// Table 12/H.263 codes in index order (index = INTRA pattern).
313 const T12: [&str; 16] = [
314 "0011", "00101", "00100", "1001", "00011", "0111", "000010", "1011", "00010", "000011",
315 "0101", "1010", "0100", "1000", "0110", "11",
316 ];
317 /// Table 14/H.263 codes for positive vectors 0, 0.5, ... 15.5 without sign bit, and -16 last.
318 const T14: [&str; 33] = [
319 "1",
320 "01",
321 "001",
322 "0001",
323 "000011",
324 "0000101",
325 "0000100",
326 "0000011",
327 "000001011",
328 "000001010",
329 "000001001",
330 "0000010001",
331 "0000010000",
332 "0000001111",
333 "0000001110",
334 "0000001101",
335 "0000001100",
336 "0000001011",
337 "0000001010",
338 "0000001001",
339 "0000001000",
340 "0000000111",
341 "0000000110",
342 "0000000101",
343 "0000000100",
344 "00000000111",
345 "00000000110",
346 "00000000101",
347 "00000000100",
348 "00000000011",
349 "00000000010",
350 "000000000011",
351 "000000000010",
352 ];
353 /// Table 16/H.263 rows: (LAST, RUN, |LEVEL|, code without sign) by index; ESCAPE code below.
354 const T16: [(u8, i8, i8, &str); 102] = [
355 (0, 0, 1, "10"),
356 (0, 0, 2, "1111"),
357 (0, 0, 3, "010101"),
358 (0, 0, 4, "0010111"),
359 (0, 0, 5, "00011111"),
360 (0, 0, 6, "000100101"),
361 (0, 0, 7, "000100100"),
362 (0, 0, 8, "0000100001"),
363 (0, 0, 9, "0000100000"),
364 (0, 0, 10, "00000000111"),
365 (0, 0, 11, "00000000110"),
366 (0, 0, 12, "00000100000"),
367 (0, 1, 1, "110"),
368 (0, 1, 2, "010100"),
369 (0, 1, 3, "00011110"),
370 (0, 1, 4, "0000001111"),
371 (0, 1, 5, "00000100001"),
372 (0, 1, 6, "000001010000"),
373 (0, 2, 1, "1110"),
374 (0, 2, 2, "00011101"),
375 (0, 2, 3, "0000001110"),
376 (0, 2, 4, "000001010001"),
377 (0, 3, 1, "01101"),
378 (0, 3, 2, "000100011"),
379 (0, 3, 3, "0000001101"),
380 (0, 4, 1, "01100"),
381 (0, 4, 2, "000100010"),
382 (0, 4, 3, "000001010010"),
383 (0, 5, 1, "01011"),
384 (0, 5, 2, "0000001100"),
385 (0, 5, 3, "000001010011"),
386 (0, 6, 1, "010011"),
387 (0, 6, 2, "0000001011"),
388 (0, 6, 3, "000001010100"),
389 (0, 7, 1, "010010"),
390 (0, 7, 2, "0000001010"),
391 (0, 8, 1, "010001"),
392 (0, 8, 2, "0000001001"),
393 (0, 9, 1, "010000"),
394 (0, 9, 2, "0000001000"),
395 (0, 10, 1, "0010110"),
396 (0, 10, 2, "000001010101"),
397 (0, 11, 1, "0010101"),
398 (0, 12, 1, "0010100"),
399 (0, 13, 1, "00011100"),
400 (0, 14, 1, "00011011"),
401 (0, 15, 1, "000100001"),
402 (0, 16, 1, "000100000"),
403 (0, 17, 1, "000011111"),
404 (0, 18, 1, "000011110"),
405 (0, 19, 1, "000011101"),
406 (0, 20, 1, "000011100"),
407 (0, 21, 1, "000011011"),
408 (0, 22, 1, "000011010"),
409 (0, 23, 1, "00000100010"),
410 (0, 24, 1, "00000100011"),
411 (0, 25, 1, "000001010110"),
412 (0, 26, 1, "000001010111"),
413 (1, 0, 1, "0111"),
414 (1, 0, 2, "000011001"),
415 (1, 0, 3, "00000000101"),
416 (1, 1, 1, "001111"),
417 (1, 1, 2, "00000000100"),
418 (1, 2, 1, "001110"),
419 (1, 3, 1, "001101"),
420 (1, 4, 1, "001100"),
421 (1, 5, 1, "0010011"),
422 (1, 6, 1, "0010010"),
423 (1, 7, 1, "0010001"),
424 (1, 8, 1, "0010000"),
425 (1, 9, 1, "00011010"),
426 (1, 10, 1, "00011001"),
427 (1, 11, 1, "00011000"),
428 (1, 12, 1, "00010111"),
429 (1, 13, 1, "00010110"),
430 (1, 14, 1, "00010101"),
431 (1, 15, 1, "00010100"),
432 (1, 16, 1, "00010011"),
433 (1, 17, 1, "000011000"),
434 (1, 18, 1, "000010111"),
435 (1, 19, 1, "000010110"),
436 (1, 20, 1, "000010101"),
437 (1, 21, 1, "000010100"),
438 (1, 22, 1, "000010011"),
439 (1, 23, 1, "000010010"),
440 (1, 24, 1, "000010001"),
441 (1, 25, 1, "0000000111"),
442 (1, 26, 1, "0000000110"),
443 (1, 27, 1, "0000000101"),
444 (1, 28, 1, "0000000100"),
445 (1, 29, 1, "00000100100"),
446 (1, 30, 1, "00000100101"),
447 (1, 31, 1, "00000100110"),
448 (1, 32, 1, "00000100111"),
449 (1, 33, 1, "000001011000"),
450 (1, 34, 1, "000001011001"),
451 (1, 35, 1, "000001011010"),
452 (1, 36, 1, "000001011011"),
453 (1, 37, 1, "000001011100"),
454 (1, 38, 1, "000001011101"),
455 (1, 39, 1, "000001011110"),
456 (1, 40, 1, "000001011111"),
457 ];
458 const T16_ESC: &str = "0000011";
459 #[test]
460 fn mcbpc_matches_tables_7_and_8() {
461 for (i, r) in T7.iter().enumerate() {
462 let (c, n) = val(r.2);
463 assert_eq!(
464 (
465 H263_INTRA_MCBPC_CODE[i] as u32,
466 H263_INTRA_MCBPC_BITS[i] as u32
467 ),
468 (c, n)
469 );
470 }
471 for r in T8.iter() {
472 // group = flags of the MB type (INTRA 1, +Q 2, 4V 4); stuffing is group 5.
473 let group = match r.0 {
474 "Stuffing" => 5,
475 t => [0, 2, 4, 1, 3, 6][t.parse::<usize>().unwrap()],
476 };
477 let slot = 4 * group
478 + if r.0 == "Stuffing" {
479 0
480 } else {
481 usize::from_str_radix(r.1, 2).unwrap()
482 };
483 let (c, n) = val(r.2);
484 assert_eq!(
485 (
486 H263_INTER_MCBPC_CODE[slot] as u32,
487 H263_INTER_MCBPC_BITS[slot] as u32
488 ),
489 (c, n)
490 );
491 }
492 for &bits in &H263_INTER_MCBPC_BITS[21..24] {
493 assert_eq!(bits, 0);
494 }
495 }
496
497 #[test]
498 fn cbpy_and_mvd_match_tables_12_and_14() {
499 for (i, c) in T12.iter().enumerate() {
500 let (v, n) = val(c);
501 assert_eq!(
502 (H263_CBPY_TAB[i][0] as u32, H263_CBPY_TAB[i][1] as u32),
503 (v, n)
504 );
505 }
506 for (i, c) in T14.iter().enumerate() {
507 let (v, n) = val(c);
508 assert_eq!((MVTAB[i][0] as u32, MVTAB[i][1] as u32), (v, n));
509 }
510 }
511
512 fn check_rl(
513 rows: &[(u8, i8, i8, &str); 102],
514 vlc: &[[u16; 2]],
515 run: &[i8],
516 level: &[i8],
517 last: usize,
518 ) {
519 let mut sorted: Vec<_> = rows.to_vec();
520 sorted.sort_by_key(|r| (r.0, r.1, r.2));
521 assert_eq!(sorted.iter().filter(|r| r.0 == 0).count(), last);
522 for (i, r) in sorted.iter().enumerate() {
523 let (v, n) = val(r.3);
524 assert_eq!((vlc[i][0] as u32, vlc[i][1] as u32), (v, n), "entry {i}");
525 assert_eq!((run[i], level[i]), (r.1, r.2), "entry {i}");
526 }
527 let (v, n) = val(T16_ESC);
528 assert_eq!((vlc[102][0] as u32, vlc[102][1] as u32), (v, n));
529 }
530
531 #[test]
532 fn tcoef_matches_tables_16_and_i2() {
533 check_rl(
534 &T16,
535 &INTER_VLC,
536 &INTER_RUN,
537 &INTER_LEVEL,
538 H263_RL_INTER_LAST,
539 );
540 }
541
542 #[test]
543 fn small_tables_match_the_text() {
544 // Table 2 (formats) and Table 5 (PAR).
545 assert_eq!(H263_FORMAT[1], [128, 96]);
546 assert_eq!(H263_FORMAT[5], [1408, 1152]);
547 assert_eq!(
548 &H263_PIXEL_ASPECT[1..6],
549 &[[1, 1], [12, 11], [10, 11], [16, 11], [40, 33]]
550 );
551 }
552
553 #[test]
554 fn scans_match_figures() {
555 // Figure 14: first rows of the printed grid (scan positions, 1-based).
556 let fig14: [[u8; 8]; 8] = [
557 [1, 2, 6, 7, 15, 16, 28, 29],
558 [3, 5, 8, 14, 17, 27, 30, 43],
559 [4, 9, 13, 18, 26, 31, 42, 44],
560 [10, 12, 19, 25, 32, 41, 45, 54],
561 [11, 20, 24, 33, 40, 46, 53, 55],
562 [21, 23, 34, 39, 47, 52, 56, 61],
563 [22, 35, 38, 48, 51, 57, 60, 62],
564 [36, 37, 49, 50, 58, 59, 63, 64],
565 ];
566 for (i, &p) in ZIGZAG_DIRECT.iter().enumerate() {
567 assert_eq!(fig14[p as usize / 8][p as usize % 8] as usize, i + 1);
568 }
569 // Figure I.2-a and I.2-b.
570 let a: [[u8; 8]; 8] = [
571 [1, 2, 3, 4, 11, 12, 13, 14],
572 [5, 6, 9, 10, 18, 17, 16, 15],
573 [7, 8, 20, 19, 27, 28, 29, 30],
574 [21, 22, 25, 26, 31, 32, 33, 34],
575 [23, 24, 35, 36, 43, 44, 45, 46],
576 [37, 38, 41, 42, 47, 48, 49, 50],
577 [39, 40, 51, 52, 57, 58, 59, 60],
578 [53, 54, 55, 56, 61, 62, 63, 64],
579 ];
580 let b: [[u8; 8]; 8] = [
581 [1, 5, 7, 21, 23, 37, 39, 53],
582 [2, 6, 8, 22, 24, 38, 40, 54],
583 [3, 9, 20, 25, 35, 41, 51, 55],
584 [4, 10, 19, 26, 36, 42, 52, 56],
585 [11, 18, 27, 31, 43, 47, 57, 61],
586 [12, 17, 28, 32, 44, 48, 58, 62],
587 [13, 16, 29, 33, 45, 49, 59, 63],
588 [14, 15, 30, 34, 46, 50, 60, 64],
589 ];
590 for (i, &p) in ALTERNATE_HORIZONTAL_SCAN.iter().enumerate() {
591 assert_eq!(a[p as usize / 8][p as usize % 8] as usize, i + 1);
592 }
593 for (i, &p) in ALTERNATE_VERTICAL_SCAN.iter().enumerate() {
594 assert_eq!(b[p as usize / 8][p as usize % 8] as usize, i + 1);
595 }
596 }
597}