Palette colour-index CDF tables + 4-site wiring
Browse files at this commit28f95f60da07242bb7cfe90b49481de5149258b5Parent: eb2d621- feat
- palette colour-index CDF tables + 4-site wiring
2 changed files +123 -0
- crates/ec-av1/src/cdf.rs +113 -0
- crates/ec-av1/src/cdf_state.rs +10 -0
crates/ec-av1/src/cdf.rsmodified+113 -0
| @@ -416,6 +416,119 @@ pub const PALETTE_Y_MODE: [[[u16; 3]; 3]; 7] = [ | ||
| 416 | 416 | /// this block's own luma palette was used -- always 0 here, see |
| 417 | 417 | /// [`PALETTE_Y_MODE`]'s doc). |
| 418 | 418 | pub const PALETTE_UV_MODE: [[u16; 3]; 2] = [[32461, 32768, 0], [21488, 32768, 0]]; |
| 419 | +/// `default_palette_y_color_index_cdf` (entropymode.c): the per-pixel colour | |
| 420 | +/// index symbol for a palette-Y block, indexed `[n-2][color_ctx]` where `n` | |
| 421 | +/// is the block's palette size (2..=8, `PALETTE_SIZES`) and `color_ctx` is | |
| 422 | +/// `av1_get_palette_color_index_context`'s 0..=4 output | |
| 423 | +/// (`PALETTE_COLOR_INDEX_CONTEXTS`). Each row is transcribed straight from | |
| 424 | +/// its `AOM_CDFn` macro (`n-1` raw probs, then `32768, 0`) and zero-padded | |
| 425 | +/// out to width 9 (the `n=8` row's real length); the call site slices | |
| 426 | +/// `[..=n]`, which only ever touches the real prefix, so the trailing zero | |
| 427 | +/// padding on shorter rows is never read. | |
| 428 | +pub const PALETTE_Y_COLOR_INDEX: [[[u16; 9]; 5]; 7] = [ | |
| 429 | + [ | |
| 430 | + [28710, 32768, 0, 0, 0, 0, 0, 0, 0], | |
| 431 | + [16384, 32768, 0, 0, 0, 0, 0, 0, 0], | |
| 432 | + [10553, 32768, 0, 0, 0, 0, 0, 0, 0], | |
| 433 | + [27036, 32768, 0, 0, 0, 0, 0, 0, 0], | |
| 434 | + [31603, 32768, 0, 0, 0, 0, 0, 0, 0], | |
| 435 | + ], | |
| 436 | + [ | |
| 437 | + [27877, 30490, 32768, 0, 0, 0, 0, 0, 0], | |
| 438 | + [11532, 25697, 32768, 0, 0, 0, 0, 0, 0], | |
| 439 | + [6544, 30234, 32768, 0, 0, 0, 0, 0, 0], | |
| 440 | + [23018, 28072, 32768, 0, 0, 0, 0, 0, 0], | |
| 441 | + [31915, 32385, 32768, 0, 0, 0, 0, 0, 0], | |
| 442 | + ], | |
| 443 | + [ | |
| 444 | + [25572, 28046, 30045, 32768, 0, 0, 0, 0, 0], | |
| 445 | + [9478, 21590, 27256, 32768, 0, 0, 0, 0, 0], | |
| 446 | + [7248, 26837, 29824, 32768, 0, 0, 0, 0, 0], | |
| 447 | + [19167, 24486, 28349, 32768, 0, 0, 0, 0, 0], | |
| 448 | + [31400, 31825, 32250, 32768, 0, 0, 0, 0, 0], | |
| 449 | + ], | |
| 450 | + [ | |
| 451 | + [24779, 26955, 28576, 30282, 32768, 0, 0, 0, 0], | |
| 452 | + [8669, 20364, 24073, 28093, 32768, 0, 0, 0, 0], | |
| 453 | + [4255, 27565, 29377, 31067, 32768, 0, 0, 0, 0], | |
| 454 | + [19864, 23674, 26716, 29530, 32768, 0, 0, 0, 0], | |
| 455 | + [31646, 31893, 32147, 32426, 32768, 0, 0, 0, 0], | |
| 456 | + ], | |
| 457 | + [ | |
| 458 | + [23132, 25407, 26970, 28435, 30073, 32768, 0, 0, 0], | |
| 459 | + [7443, 17242, 20717, 24762, 27982, 32768, 0, 0, 0], | |
| 460 | + [6300, 24862, 26944, 28784, 30671, 32768, 0, 0, 0], | |
| 461 | + [18916, 22895, 25267, 27435, 29652, 32768, 0, 0, 0], | |
| 462 | + [31270, 31550, 31808, 32059, 32353, 32768, 0, 0, 0], | |
| 463 | + ], | |
| 464 | + [ | |
| 465 | + [23105, 25199, 26464, 27684, 28931, 30318, 32768, 0, 0], | |
| 466 | + [6950, 15447, 18952, 22681, 25567, 28563, 32768, 0, 0], | |
| 467 | + [7560, 23474, 25490, 27203, 28921, 30708, 32768, 0, 0], | |
| 468 | + [18544, 22373, 24457, 26195, 28119, 30045, 32768, 0, 0], | |
| 469 | + [31198, 31451, 31670, 31882, 32123, 32391, 32768, 0, 0], | |
| 470 | + ], | |
| 471 | + [ | |
| 472 | + [21689, 23883, 25163, 26352, 27506, 28827, 30195, 32768, 0], | |
| 473 | + [6892, 15385, 17840, 21606, 24287, 26753, 29204, 32768, 0], | |
| 474 | + [5651, 23182, 25042, 26518, 27982, 29392, 30900, 32768, 0], | |
| 475 | + [19349, 22578, 24418, 25994, 27524, 29031, 30448, 32768, 0], | |
| 476 | + [31028, 31270, 31504, 31705, 31927, 32153, 32392, 32768, 0], | |
| 477 | + ], | |
| 478 | +]; | |
| 479 | +/// `default_palette_uv_color_index_cdf` (entropymode.c): as | |
| 480 | +/// [`PALETTE_Y_COLOR_INDEX`], for the chroma colour-index map. | |
| 481 | +pub const PALETTE_UV_COLOR_INDEX: [[[u16; 9]; 5]; 7] = [ | |
| 482 | + [ | |
| 483 | + [29089, 32768, 0, 0, 0, 0, 0, 0, 0], | |
| 484 | + [16384, 32768, 0, 0, 0, 0, 0, 0, 0], | |
| 485 | + [8713, 32768, 0, 0, 0, 0, 0, 0, 0], | |
| 486 | + [29257, 32768, 0, 0, 0, 0, 0, 0, 0], | |
| 487 | + [31610, 32768, 0, 0, 0, 0, 0, 0, 0], | |
| 488 | + ], | |
| 489 | + [ | |
| 490 | + [25257, 29145, 32768, 0, 0, 0, 0, 0, 0], | |
| 491 | + [12287, 27293, 32768, 0, 0, 0, 0, 0, 0], | |
| 492 | + [7033, 27960, 32768, 0, 0, 0, 0, 0, 0], | |
| 493 | + [20145, 25405, 32768, 0, 0, 0, 0, 0, 0], | |
| 494 | + [30608, 31639, 32768, 0, 0, 0, 0, 0, 0], | |
| 495 | + ], | |
| 496 | + [ | |
| 497 | + [24210, 27175, 29903, 32768, 0, 0, 0, 0, 0], | |
| 498 | + [9888, 22386, 27214, 32768, 0, 0, 0, 0, 0], | |
| 499 | + [5901, 26053, 29293, 32768, 0, 0, 0, 0, 0], | |
| 500 | + [18318, 22152, 28333, 32768, 0, 0, 0, 0, 0], | |
| 501 | + [30459, 31136, 31926, 32768, 0, 0, 0, 0, 0], | |
| 502 | + ], | |
| 503 | + [ | |
| 504 | + [22980, 25479, 27781, 29986, 32768, 0, 0, 0, 0], | |
| 505 | + [8413, 21408, 24859, 28874, 32768, 0, 0, 0, 0], | |
| 506 | + [2257, 29449, 30594, 31598, 32768, 0, 0, 0, 0], | |
| 507 | + [19189, 21202, 25915, 28620, 32768, 0, 0, 0, 0], | |
| 508 | + [31844, 32044, 32281, 32518, 32768, 0, 0, 0, 0], | |
| 509 | + ], | |
| 510 | + [ | |
| 511 | + [22217, 24567, 26637, 28683, 30548, 32768, 0, 0, 0], | |
| 512 | + [7307, 16406, 19636, 24632, 28424, 32768, 0, 0, 0], | |
| 513 | + [4441, 25064, 26879, 28942, 30919, 32768, 0, 0, 0], | |
| 514 | + [17210, 20528, 23319, 26750, 29582, 32768, 0, 0, 0], | |
| 515 | + [30674, 30953, 31396, 31735, 32207, 32768, 0, 0, 0], | |
| 516 | + ], | |
| 517 | + [ | |
| 518 | + [21239, 23168, 25044, 26962, 28705, 30506, 32768, 0, 0], | |
| 519 | + [6545, 15012, 18004, 21817, 25503, 28701, 32768, 0, 0], | |
| 520 | + [3448, 26295, 27437, 28704, 30126, 31442, 32768, 0, 0], | |
| 521 | + [15889, 18323, 21704, 24698, 26976, 29690, 32768, 0, 0], | |
| 522 | + [30988, 31204, 31479, 31734, 31983, 32325, 32768, 0, 0], | |
| 523 | + ], | |
| 524 | + [ | |
| 525 | + [21442, 23288, 24758, 26246, 27649, 28980, 30563, 32768, 0], | |
| 526 | + [5863, 14933, 17552, 20668, 23683, 26411, 29273, 32768, 0], | |
| 527 | + [3415, 25810, 26877, 27990, 29223, 30394, 31618, 32768, 0], | |
| 528 | + [17965, 20084, 22232, 23974, 26274, 28402, 30390, 32768, 0], | |
| 529 | + [31190, 31329, 31516, 31679, 31825, 32026, 32322, 32768, 0], | |
| 530 | + ], | |
| 531 | +]; | |
| 419 | 532 | /// `default_intrabc_cdf` (entropymode.c): the `use_intrabc` flag on an |
| 420 | 533 | /// intra frame with `allow_intrabc` set. |
| 421 | 534 | pub const INTRABC: [u16; 3] = [30531, 32768, 0]; |
crates/ec-av1/src/cdf_state.rsmodified+10 -0
| @@ -431,6 +431,12 @@ pub(crate) struct Cdfs { | ||
| 431 | 431 | pub palette_uv_mode: [[u16; 3]; 2], |
| 432 | 432 | /// A chroma palette block's own size -- see [`cdf::PALETTE_UV_SIZE`]. |
| 433 | 433 | pub palette_uv_size: [[u16; 8]; 7], |
| 434 | + /// A palette-Y block's per-pixel colour-index symbol -- see | |
| 435 | + /// [`cdf::PALETTE_Y_COLOR_INDEX`]. | |
| 436 | + pub palette_y_color_index: [[[u16; 9]; 5]; 7], | |
| 437 | + /// A palette-UV block's per-pixel colour-index symbol -- see | |
| 438 | + /// [`cdf::PALETTE_UV_COLOR_INDEX`]. | |
| 439 | + pub palette_uv_color_index: [[[u16; 9]; 5]; 7], | |
| 434 | 440 | /// The `use_intrabc` flag -- see [`cdf::INTRABC`]. |
| 435 | 441 | pub intrabc: [u16; 3], |
| 436 | 442 | } |
| @@ -653,6 +659,8 @@ impl Cdfs { | ||
| 653 | 659 | reset2(&mut self.palette_y_size); |
| 654 | 660 | reset2(&mut self.palette_uv_mode); |
| 655 | 661 | reset2(&mut self.palette_uv_size); |
| 662 | + reset3(&mut self.palette_y_color_index); | |
| 663 | + reset3(&mut self.palette_uv_color_index); | |
| 656 | 664 | reset1(&mut self.intrabc); |
| 657 | 665 | } |
| 658 | 666 | |
| @@ -1113,6 +1121,8 @@ impl Cdfs { | ||
| 1113 | 1121 | palette_y_size: cdf::PALETTE_Y_SIZE, |
| 1114 | 1122 | palette_uv_mode: cdf::PALETTE_UV_MODE, |
| 1115 | 1123 | palette_uv_size: cdf::PALETTE_UV_SIZE, |
| 1124 | + palette_y_color_index: cdf::PALETTE_Y_COLOR_INDEX, | |
| 1125 | + palette_uv_color_index: cdf::PALETTE_UV_COLOR_INDEX, | |
| 1116 | 1126 | intrabc: cdf::INTRABC, |
| 1117 | 1127 | } |
| 1118 | 1128 | } |