Inter var-tx (TxMode::Select) read + per-TU residual
Browse files at this commitf66f359057272bb8896eee8fd935f7856f0c52aaParent: d47ed65- feat
- inter var-tx (TxMode::Select) read + per-TU residual
- blanket inter refusal lifted
18 changed files +3869 -2536
- crates/ec-av1/src/cdf.rs +15 -20
- crates/ec-av1/src/decode.rs +2747 -2254
- crates/ec-av1/src/encode.rs +52 -13
- crates/ec-av1/src/encoder.rs +8 -2
- crates/ec-av1/src/gate_coverage.rs +28 -9
- crates/ec-av1/src/intra.rs +10 -3
- crates/ec-av1/src/lib.rs +1 -1
- crates/ec-av1/src/mc.rs +6 -3
- crates/ec-av1/src/motion.rs +8 -1
- crates/ec-av1/src/mvstack.rs +118 -16
- crates/ec-av1/src/quant.rs +9 -1
- crates/ec-av1/src/refusal_inventory.rs +18 -5
- crates/ec-av1/src/restoration.rs +130 -48
- crates/ec-av1/src/stream.rs +655 -135
- crates/ec-av1/src/superres.rs +11 -3
- crates/ec-av1/src/transform.rs +7 -5
- crates/ec-av1/src/warp.rs +23 -8
- crates/ec-av1/src/wedge.rs +23 -9
crates/ec-av1/src/cdf.rsmodified+15 -20
| @@ -277,21 +277,16 @@ pub const EOB_PT_512_LUMA_Q3: [u16; 11] = [ | |||
| 277 | /// coded positions -- what a true 16x8/8x16 rectangular transform has | 277 | /// coded positions -- what a true 16x8/8x16 rectangular transform has |
| 278 | /// (`txsize_log2_minus4` = 3), distinct from [`EOB_PT_256_CHROMA`]'s | 278 | /// (`txsize_log2_minus4` = 3), distinct from [`EOB_PT_256_CHROMA`]'s |
| 279 | /// 256-position group a *square* 16x16 reads. | 279 | /// 256-position group a *square* 16x16 reads. |
| 280 | -pub const EOB_PT_128_CHROMA: [u16; 9] = [ | 280 | +pub const EOB_PT_128_CHROMA: [u16; 9] = [13627, 16246, 20173, 24429, 27948, 30415, 31863, 32768, 0]; |
| 281 | - 13627, 16246, 20173, 24429, 27948, 30415, 31863, 32768, 0, | ||
| 282 | -]; | ||
| 283 | /// [`EOB_PT_128_CHROMA`], q-context 0. | 281 | /// [`EOB_PT_128_CHROMA`], q-context 0. |
| 284 | -pub const EOB_PT_128_CHROMA_Q0: [u16; 9] = [ | 282 | +pub const EOB_PT_128_CHROMA_Q0: [u16; 9] = |
| 285 | - 5245, 7456, 12880, 15852, 20033, 23932, 27608, 32768, 0, | 283 | + [5245, 7456, 12880, 15852, 20033, 23932, 27608, 32768, 0]; |
| 286 | -]; | ||
| 287 | /// [`EOB_PT_128_CHROMA`], q-context 1. | 284 | /// [`EOB_PT_128_CHROMA`], q-context 1. |
| 288 | -pub const EOB_PT_128_CHROMA_Q1: [u16; 9] = [ | 285 | +pub const EOB_PT_128_CHROMA_Q1: [u16; 9] = |
| 289 | - 8045, 11200, 15497, 19595, 23948, 27408, 30938, 32768, 0, | 286 | + [8045, 11200, 15497, 19595, 23948, 27408, 30938, 32768, 0]; |
| 290 | -]; | ||
| 291 | /// [`EOB_PT_128_CHROMA`], q-context 3. | 287 | /// [`EOB_PT_128_CHROMA`], q-context 3. |
| 292 | -pub const EOB_PT_128_CHROMA_Q3: [u16; 9] = [ | 288 | +pub const EOB_PT_128_CHROMA_Q3: [u16; 9] = |
| 293 | - 24313, 26062, 28385, 30107, 31217, 31898, 32345, 32768, 0, | 289 | + [24313, 26062, 28385, 30107, 31217, 31898, 32345, 32768, 0]; |
| 294 | -]; | ||
| 295 | 290 | ||
| 296 | /// `av1_default_eob_multi512_cdfs[*][1][*]` (`token_cdfs.h:874-901`, | 291 | /// `av1_default_eob_multi512_cdfs[*][1][*]` (`token_cdfs.h:874-901`, |
| 297 | /// lane-sbpart): the end-of-block group of a CHROMA transform with 512 coded | 292 | /// lane-sbpart): the end-of-block group of a CHROMA transform with 512 coded |
| @@ -1656,20 +1651,20 @@ pub const WEDGE_IDX: [[u16; 17]; 22] = [ | |||
| 1656 | 29629, 32768, 0, | 1651 | 29629, 32768, 0, |
| 1657 | ], | 1652 | ], |
| 1658 | [ | 1653 | [ |
| 1659 | - 2779, 3738, 4683, 7213, 7775, 8017, 8655, 14357, 17939, 21332, 24520, 27470, 29456, | 1654 | + 2779, 3738, 4683, 7213, 7775, 8017, 8655, 14357, 17939, 21332, 24520, 27470, 29456, 30529, |
| 1660 | - 30529, 31656, 32768, 0, | 1655 | + 31656, 32768, 0, |
| 1661 | ], | 1656 | ], |
| 1662 | [ | 1657 | [ |
| 1663 | 1684, 3625, 5675, 7108, 9302, 11274, 14429, 17144, 19163, 20961, 22884, 24471, 26719, | 1658 | 1684, 3625, 5675, 7108, 9302, 11274, 14429, 17144, 19163, 20961, 22884, 24471, 26719, |
| 1664 | 28714, 30877, 32768, 0, | 1659 | 28714, 30877, 32768, 0, |
| 1665 | ], | 1660 | ], |
| 1666 | [ | 1661 | [ |
| 1667 | - 1142, 3491, 6277, 7314, 8089, 8355, 9023, 13624, 15369, 16730, 18114, 19313, 22521, | 1662 | + 1142, 3491, 6277, 7314, 8089, 8355, 9023, 13624, 15369, 16730, 18114, 19313, 22521, 26012, |
| 1668 | - 26012, 29550, 32768, 0, | 1663 | + 29550, 32768, 0, |
| 1669 | ], | 1664 | ], |
| 1670 | [ | 1665 | [ |
| 1671 | - 2742, 4195, 5727, 8035, 8980, 9336, 10146, 14124, 17270, 20533, 23434, 25972, 27944, | 1666 | + 2742, 4195, 5727, 8035, 8980, 9336, 10146, 14124, 17270, 20533, 23434, 25972, 27944, 29570, |
| 1672 | - 29570, 31416, 32768, 0, | 1667 | + 31416, 32768, 0, |
| 1673 | ], | 1668 | ], |
| 1674 | [ | 1669 | [ |
| 1675 | 1727, 3948, 6101, 7796, 9841, 12344, 15766, 18944, 20638, 22038, 23963, 25311, 26988, | 1670 | 1727, 3948, 6101, 7796, 9841, 12344, 15766, 18944, 20638, 22038, 23963, 25311, 26988, |
| @@ -1712,8 +1707,8 @@ pub const WEDGE_IDX: [[u16; 17]; 22] = [ | |||
| 1712 | 30911, 32768, 0, | 1707 | 30911, 32768, 0, |
| 1713 | ], | 1708 | ], |
| 1714 | [ | 1709 | [ |
| 1715 | - 1135, 1322, 1493, 2635, 2696, 2737, 2770, 21016, 22935, 25057, 27251, 29173, 30089, | 1710 | + 1135, 1322, 1493, 2635, 2696, 2737, 2770, 21016, 22935, 25057, 27251, 29173, 30089, 30960, |
| 1716 | - 30960, 31933, 32768, 0, | 1711 | + 31933, 32768, 0, |
| 1717 | ], | 1712 | ], |
| 1718 | [ | 1713 | [ |
| 1719 | 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528, 24576, 26624, | 1714 | 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528, 24576, 26624, |
crates/ec-av1/src/decode.rsmodified+2747 -2254
Diff too large; view file
| @@ -21,9 +21,7 @@ | |||
| 21 | //! too). Anything outside that refuses with [`Error::unsupported`] rather than | 21 | //! too). Anything outside that refuses with [`Error::unsupported`] rather than |
| 22 | //! silently miscoding. | 22 | //! silently miscoding. |
| 23 | 23 | ||
| 24 | -use ec_av1_syntax::{ | 24 | +use ec_av1_syntax::{CdefParams, DeltaParams, LoopFilterParams, LoopRestorationParams, TileInfo}; |
| 25 | - CdefParams, DeltaParams, LoopFilterParams, LoopRestorationParams, TileInfo, | ||
| 26 | -}; | ||
| 27 | use ec_core::{Error, Result}; | 25 | use ec_core::{Error, Result}; |
| 28 | 26 | ||
| 29 | use crate::cdf; | 27 | use crate::cdf; |
| @@ -199,7 +197,14 @@ fn plane_q_delta(plane_idx: usize) -> (i32, i32) { | |||
| 199 | /// top-left leaf is the only block that can ever land there), or when that | 197 | /// top-left leaf is the only block that can ever land there), or when that |
| 200 | /// leaf both *is* the whole superblock and is `skip` (the one case libaom | 198 | /// leaf both *is* the whole superblock and is `skip` (the one case libaom |
| 201 | /// itself skips the read, state carrying over unchanged). | 199 | /// itself skips the read, state carrying over unchanged). |
| 202 | -fn maybe_read_delta_q(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_c: usize, is_whole_sb: bool, skip: bool) { | 200 | +fn maybe_read_delta_q( |
| 201 | + dec: &mut SymbolDecoder, | ||
| 202 | + cdfs: &mut Cdfs, | ||
| 203 | + mi_r: usize, | ||
| 204 | + mi_c: usize, | ||
| 205 | + is_whole_sb: bool, | ||
| 206 | + skip: bool, | ||
| 207 | +) { | ||
| 203 | if !DELTA_Q_PRESENT.with(|c| c.get()) { | 208 | if !DELTA_Q_PRESENT.with(|c| c.get()) { |
| 204 | return; | 209 | return; |
| 205 | } | 210 | } |
| @@ -254,7 +259,14 @@ pub(crate) fn delta_lf_hits() -> usize { | |||
| 254 | /// [`maybe_read_delta_q`] (spec order `delta_q -> delta_lf`), looped over | 259 | /// [`maybe_read_delta_q`] (spec order `delta_q -> delta_lf`), looped over |
| 255 | /// `FRAME_LF_COUNT = 4` planes/directions when `delta_lf_multi` is set, or | 260 | /// `FRAME_LF_COUNT = 4` planes/directions when `delta_lf_multi` is set, or |
| 256 | /// read once into index 0 otherwise. | 261 | /// read once into index 0 otherwise. |
| 257 | -fn maybe_read_delta_lf(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_c: usize, is_whole_sb: bool, skip: bool) { | 262 | +fn maybe_read_delta_lf( |
| 263 | + dec: &mut SymbolDecoder, | ||
| 264 | + cdfs: &mut Cdfs, | ||
| 265 | + mi_r: usize, | ||
| 266 | + mi_c: usize, | ||
| 267 | + is_whole_sb: bool, | ||
| 268 | + skip: bool, | ||
| 269 | +) { | ||
| 258 | if !DELTA_LF_PRESENT.with(|c| c.get()) { | 270 | if !DELTA_LF_PRESENT.with(|c| c.get()) { |
| 259 | return; | 271 | return; |
| 260 | } | 272 | } |
| @@ -370,8 +382,7 @@ thread_local! { | |||
| 370 | /// lane-comppin r4: decode-order picture counter for `EC_AV1_PREFILT_DUMP`, | 382 | /// lane-comppin r4: decode-order picture counter for `EC_AV1_PREFILT_DUMP`, |
| 371 | /// mirroring stream.rs's `pictures_decoded` so the two dumps index | 383 | /// mirroring stream.rs's `pictures_decoded` so the two dumps index |
| 372 | /// identically against aomdec's own `ec_frame_idx` in decodeframe.c. | 384 | /// identically against aomdec's own `ec_frame_idx` in decodeframe.c. |
| 373 | -static PREFILT_PICTURE_IDX: std::sync::atomic::AtomicUsize = | 385 | +static PREFILT_PICTURE_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); |
| 374 | - std::sync::atomic::AtomicUsize::new(0); | ||
| 375 | 386 | ||
| 376 | /// Current value of [`DEBLOCK_HITS`]. | 387 | /// Current value of [`DEBLOCK_HITS`]. |
| 377 | pub(crate) fn deblock_hits() -> usize { | 388 | pub(crate) fn deblock_hits() -> usize { |
| @@ -1186,33 +1197,33 @@ fn br_ctx(grid: &[i32], side: usize, row: usize, col: usize, class: TxClass) -> | |||
| 1186 | /// against the real table). Not the square zigzag formula generalized to | 1197 | /// against the real table). Not the square zigzag formula generalized to |
| 1187 | /// unequal `w`/`h` -- checked and that does NOT reproduce this table. | 1198 | /// unequal `w`/`h` -- checked and that does NOT reproduce this table. |
| 1188 | const SCAN_32X16: [u16; 512] = [ | 1199 | const SCAN_32X16: [u16; 512] = [ |
| 1189 | - 0, 32, 1, 64, 33, 2, 96, 65, 34, 3, 128, 97, 66, 35, 4, 160, 129, 98, 67, 36, 5, 192, 161, | 1200 | + 0, 32, 1, 64, 33, 2, 96, 65, 34, 3, 128, 97, 66, 35, 4, 160, 129, 98, 67, 36, 5, 192, 161, 130, |
| 1190 | - 130, 99, 68, 37, 6, 224, 193, 162, 131, 100, 69, 38, 7, 256, 225, 194, 163, 132, 101, 70, 39, | 1201 | + 99, 68, 37, 6, 224, 193, 162, 131, 100, 69, 38, 7, 256, 225, 194, 163, 132, 101, 70, 39, 8, |
| 1191 | - 8, 288, 257, 226, 195, 164, 133, 102, 71, 40, 9, 320, 289, 258, 227, 196, 165, 134, 103, 72, | 1202 | + 288, 257, 226, 195, 164, 133, 102, 71, 40, 9, 320, 289, 258, 227, 196, 165, 134, 103, 72, 41, |
| 1192 | - 41, 10, 352, 321, 290, 259, 228, 197, 166, 135, 104, 73, 42, 11, 384, 353, 322, 291, 260, 229, | 1203 | + 10, 352, 321, 290, 259, 228, 197, 166, 135, 104, 73, 42, 11, 384, 353, 322, 291, 260, 229, 198, |
| 1193 | - 198, 167, 136, 105, 74, 43, 12, 416, 385, 354, 323, 292, 261, 230, 199, 168, 137, 106, 75, 44, | 1204 | + 167, 136, 105, 74, 43, 12, 416, 385, 354, 323, 292, 261, 230, 199, 168, 137, 106, 75, 44, 13, |
| 1194 | - 13, 448, 417, 386, 355, 324, 293, 262, 231, 200, 169, 138, 107, 76, 45, 14, 480, 449, 418, | 1205 | + 448, 417, 386, 355, 324, 293, 262, 231, 200, 169, 138, 107, 76, 45, 14, 480, 449, 418, 387, |
| 1195 | - 387, 356, 325, 294, 263, 232, 201, 170, 139, 108, 77, 46, 15, 481, 450, 419, 388, 357, 326, | 1206 | + 356, 325, 294, 263, 232, 201, 170, 139, 108, 77, 46, 15, 481, 450, 419, 388, 357, 326, 295, |
| 1196 | - 295, 264, 233, 202, 171, 140, 109, 78, 47, 16, 482, 451, 420, 389, 358, 327, 296, 265, 234, | 1207 | + 264, 233, 202, 171, 140, 109, 78, 47, 16, 482, 451, 420, 389, 358, 327, 296, 265, 234, 203, |
| 1197 | - 203, 172, 141, 110, 79, 48, 17, 483, 452, 421, 390, 359, 328, 297, 266, 235, 204, 173, 142, | 1208 | + 172, 141, 110, 79, 48, 17, 483, 452, 421, 390, 359, 328, 297, 266, 235, 204, 173, 142, 111, 80, |
| 1198 | - 111, 80, 49, 18, 484, 453, 422, 391, 360, 329, 298, 267, 236, 205, 174, 143, 112, 81, 50, 19, | 1209 | + 49, 18, 484, 453, 422, 391, 360, 329, 298, 267, 236, 205, 174, 143, 112, 81, 50, 19, 485, 454, |
| 1199 | - 485, 454, 423, 392, 361, 330, 299, 268, 237, 206, 175, 144, 113, 82, 51, 20, 486, 455, 424, | 1210 | + 423, 392, 361, 330, 299, 268, 237, 206, 175, 144, 113, 82, 51, 20, 486, 455, 424, 393, 362, |
| 1200 | - 393, 362, 331, 300, 269, 238, 207, 176, 145, 114, 83, 52, 21, 487, 456, 425, 394, 363, 332, | 1211 | + 331, 300, 269, 238, 207, 176, 145, 114, 83, 52, 21, 487, 456, 425, 394, 363, 332, 301, 270, |
| 1201 | - 301, 270, 239, 208, 177, 146, 115, 84, 53, 22, 488, 457, 426, 395, 364, 333, 302, 271, 240, | 1212 | + 239, 208, 177, 146, 115, 84, 53, 22, 488, 457, 426, 395, 364, 333, 302, 271, 240, 209, 178, |
| 1202 | - 209, 178, 147, 116, 85, 54, 23, 489, 458, 427, 396, 365, 334, 303, 272, 241, 210, 179, 148, | 1213 | + 147, 116, 85, 54, 23, 489, 458, 427, 396, 365, 334, 303, 272, 241, 210, 179, 148, 117, 86, 55, |
| 1203 | - 117, 86, 55, 24, 490, 459, 428, 397, 366, 335, 304, 273, 242, 211, 180, 149, 118, 87, 56, 25, | 1214 | + 24, 490, 459, 428, 397, 366, 335, 304, 273, 242, 211, 180, 149, 118, 87, 56, 25, 491, 460, 429, |
| 1204 | - 491, 460, 429, 398, 367, 336, 305, 274, 243, 212, 181, 150, 119, 88, 57, 26, 492, 461, 430, | 1215 | + 398, 367, 336, 305, 274, 243, 212, 181, 150, 119, 88, 57, 26, 492, 461, 430, 399, 368, 337, |
| 1205 | - 399, 368, 337, 306, 275, 244, 213, 182, 151, 120, 89, 58, 27, 493, 462, 431, 400, 369, 338, | 1216 | + 306, 275, 244, 213, 182, 151, 120, 89, 58, 27, 493, 462, 431, 400, 369, 338, 307, 276, 245, |
| 1206 | - 307, 276, 245, 214, 183, 152, 121, 90, 59, 28, 494, 463, 432, 401, 370, 339, 308, 277, 246, | 1217 | + 214, 183, 152, 121, 90, 59, 28, 494, 463, 432, 401, 370, 339, 308, 277, 246, 215, 184, 153, |
| 1207 | - 215, 184, 153, 122, 91, 60, 29, 495, 464, 433, 402, 371, 340, 309, 278, 247, 216, 185, 154, | 1218 | + 122, 91, 60, 29, 495, 464, 433, 402, 371, 340, 309, 278, 247, 216, 185, 154, 123, 92, 61, 30, |
| 1208 | - 123, 92, 61, 30, 496, 465, 434, 403, 372, 341, 310, 279, 248, 217, 186, 155, 124, 93, 62, 31, | 1219 | + 496, 465, 434, 403, 372, 341, 310, 279, 248, 217, 186, 155, 124, 93, 62, 31, 497, 466, 435, |
| 1209 | - 497, 466, 435, 404, 373, 342, 311, 280, 249, 218, 187, 156, 125, 94, 63, 498, 467, 436, 405, | 1220 | + 404, 373, 342, 311, 280, 249, 218, 187, 156, 125, 94, 63, 498, 467, 436, 405, 374, 343, 312, |
| 1210 | - 374, 343, 312, 281, 250, 219, 188, 157, 126, 95, 499, 468, 437, 406, 375, 344, 313, 282, 251, | 1221 | + 281, 250, 219, 188, 157, 126, 95, 499, 468, 437, 406, 375, 344, 313, 282, 251, 220, 189, 158, |
| 1211 | - 220, 189, 158, 127, 500, 469, 438, 407, 376, 345, 314, 283, 252, 221, 190, 159, 501, 470, 439, | 1222 | + 127, 500, 469, 438, 407, 376, 345, 314, 283, 252, 221, 190, 159, 501, 470, 439, 408, 377, 346, |
| 1212 | - 408, 377, 346, 315, 284, 253, 222, 191, 502, 471, 440, 409, 378, 347, 316, 285, 254, 223, 503, | 1223 | + 315, 284, 253, 222, 191, 502, 471, 440, 409, 378, 347, 316, 285, 254, 223, 503, 472, 441, 410, |
| 1213 | - 472, 441, 410, 379, 348, 317, 286, 255, 504, 473, 442, 411, 380, 349, 318, 287, 505, 474, 443, | 1224 | + 379, 348, 317, 286, 255, 504, 473, 442, 411, 380, 349, 318, 287, 505, 474, 443, 412, 381, 350, |
| 1214 | - 412, 381, 350, 319, 506, 475, 444, 413, 382, 351, 507, 476, 445, 414, 383, 508, 477, 446, 415, | 1225 | + 319, 506, 475, 444, 413, 382, 351, 507, 476, 445, 414, 383, 508, 477, 446, 415, 509, 478, 447, |
| 1215 | - 509, 478, 447, 510, 479, 511, | 1226 | + 510, 479, 511, |
| 1216 | ]; | 1227 | ]; |
| 1217 | 1228 | ||
| 1218 | /// `Default_Scan_16x32`, this decoder's own row-major transcription (see | 1229 | /// `Default_Scan_16x32`, this decoder's own row-major transcription (see |
| @@ -1316,7 +1327,11 @@ fn br_ctx_rect(grid: &[i32], w: usize, h: usize, row: usize, col: usize) -> usiz | |||
| 1316 | if row == 0 && col == 0 { | 1327 | if row == 0 && col == 0 { |
| 1317 | return mag; | 1328 | return mag; |
| 1318 | } | 1329 | } |
| 1319 | - if row < 2 && col < 2 { mag + 7 } else { mag + 14 } | 1330 | + if row < 2 && col < 2 { |
| 1331 | + mag + 7 | ||
| 1332 | + } else { | ||
| 1333 | + mag + 14 | ||
| 1334 | + } | ||
| 1320 | } | 1335 | } |
| 1321 | 1336 | ||
| 1322 | fn dc_vote(dc: Option<bool>) -> i32 { | 1337 | fn dc_vote(dc: Option<bool>) -> i32 { |
| @@ -1472,7 +1487,9 @@ fn read_coeffs( | |||
| 1472 | if std::env::var_os("EC_AV1_TELL").is_some() { | 1487 | if std::env::var_os("EC_AV1_TELL").is_some() { |
| 1473 | eprintln!( | 1488 | eprintln!( |
| 1474 | "TELL label=post_txb_skip ctx={skip_ctx} all_zero={} tell={} range={}", | 1489 | "TELL label=post_txb_skip ctx={skip_ctx} all_zero={} tell={} range={}", |
| 1475 | - all_zero as u8, dec.debug_bitpos(), dec.debug_state().0 | 1490 | + all_zero as u8, |
| 1491 | + dec.debug_bitpos(), | ||
| 1492 | + dec.debug_state().0 | ||
| 1476 | ); | 1493 | ); |
| 1477 | } | 1494 | } |
| 1478 | if trace { | 1495 | if trace { |
| @@ -1611,7 +1628,10 @@ fn read_coeffs( | |||
| 1611 | }; | 1628 | }; |
| 1612 | if ec_trace_coeff { | 1629 | if ec_trace_coeff { |
| 1613 | let (rng, _) = dec.debug_state(); | 1630 | let (rng, _) = dec.debug_state(); |
| 1614 | - eprintln!("EC_COEFF_STEP tag=sign c={c} sign={} rng={rng}", negative as i32); | 1631 | + eprintln!( |
| 1632 | + "EC_COEFF_STEP tag=sign c={c} sign={} rng={rng}", | ||
| 1633 | + negative as i32 | ||
| 1634 | + ); | ||
| 1615 | } | 1635 | } |
| 1616 | let level = if level.abs_diff(0) as i32 > MAX_BR_LEVEL { | 1636 | let level = if level.abs_diff(0) as i32 > MAX_BR_LEVEL { |
| 1617 | let g = read_golomb(dec)?; | 1637 | let g = read_golomb(dec)?; |
| @@ -1796,10 +1816,10 @@ struct Neighbours { | |||
| 1796 | /// 4x4 mi granularity: the transform *width* (above) / *height* (left) in | 1816 | /// 4x4 mi granularity: the transform *width* (above) / *height* (left) in |
| 1797 | /// pixels last written over each unit by `set_txfm_ctxs`/ | 1817 | /// pixels last written over each unit by `set_txfm_ctxs`/ |
| 1798 | /// `txfm_partition_update`, which is what an inter block's `txfm_split` | 1818 | /// `txfm_partition_update`, which is what an inter block's `txfm_split` |
| 1799 | - /// symbol reads its context from (lane-txselect, spec 5.11.17). Zero | 1819 | + /// symbol reads its context from (lane-txselect, spec 5.11.17). |
| 1800 | - /// (libaom's own tile-start value) until a block writes one; a fresh | 1820 | + /// [`TXFM_CTX_INIT`] until a block writes one; a fresh full-height `left` |
| 1801 | - /// full-height `left` array is exactly libaom's per-superblock-row reset, | 1821 | + /// array is exactly libaom's per-superblock-row reset, since each mi row |
| 1802 | - /// since each mi row is only ever visited inside one superblock row. | 1822 | + /// is only ever visited inside one superblock row. |
| 1803 | above_txfm: Vec<u8>, | 1823 | above_txfm: Vec<u8>, |
| 1804 | left_txfm: Vec<u8>, | 1824 | left_txfm: Vec<u8>, |
| 1805 | /// Whether the block above/left of this column/row coded `skip_mode` | 1825 | /// Whether the block above/left of this column/row coded `skip_mode` |
| @@ -1924,8 +1944,8 @@ impl Neighbours { | |||
| 1924 | left_side_mi: vec![SB; rows * (SUB / MI)], | 1944 | left_side_mi: vec![SB; rows * (SUB / MI)], |
| 1925 | above_skip: vec![false; cols], | 1945 | above_skip: vec![false; cols], |
| 1926 | left_skip: vec![false; rows], | 1946 | left_skip: vec![false; rows], |
| 1927 | - above_txfm: vec![0u8; cols * (SUB / MI)], | 1947 | + above_txfm: vec![TXFM_CTX_INIT; cols * (SUB / MI)], |
| 1928 | - left_txfm: vec![0u8; rows * (SUB / MI)], | 1948 | + left_txfm: vec![TXFM_CTX_INIT; rows * (SUB / MI)], |
| 1929 | above_skip_mode: vec![false; cols], | 1949 | above_skip_mode: vec![false; cols], |
| 1930 | left_skip_mode: vec![false; rows], | 1950 | left_skip_mode: vec![false; rows], |
| 1931 | above_inter: vec![false; cols], | 1951 | above_inter: vec![false; cols], |
| @@ -2064,7 +2084,13 @@ impl Neighbours { | |||
| 2064 | /// As [`Self::record_palette_y`], for a just-decoded block's own chroma | 2084 | /// As [`Self::record_palette_y`], for a just-decoded block's own chroma |
| 2065 | /// (U-channel) palette size/colours -- `size == 0` clears stale state the | 2085 | /// (U-channel) palette size/colours -- `size == 0` clears stale state the |
| 2066 | /// same way (lane-palette2 r1). | 2086 | /// same way (lane-palette2 r1). |
| 2067 | - fn record_palette_uv(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) { | 2087 | + fn record_palette_uv( |
| 2088 | + &mut self, | ||
| 2089 | + at: (usize, usize), | ||
| 2090 | + side: usize, | ||
| 2091 | + size: usize, | ||
| 2092 | + colors: [u16; 8], | ||
| 2093 | + ) { | ||
| 2068 | let (r, c) = at; | 2094 | let (r, c) = at; |
| 2069 | for cell in 0..side / SUB { | 2095 | for cell in 0..side / SUB { |
| 2070 | self.above_palette_uv_size[c + cell] = size; | 2096 | self.above_palette_uv_size[c + cell] = size; |
| @@ -2085,7 +2111,10 @@ impl Neighbours { | |||
| 2085 | let (r, c) = at; | 2111 | let (r, c) = at; |
| 2086 | let above_ok = r % 4 != 0; | 2112 | let above_ok = r % 4 != 0; |
| 2087 | let (above_n, above_colors) = if above_ok && self.above_palette_uv_size[c] > 0 { | 2113 | let (above_n, above_colors) = if above_ok && self.above_palette_uv_size[c] > 0 { |
| 2088 | - (self.above_palette_uv_size[c], self.above_palette_uv_colors[c]) | 2114 | + ( |
| 2115 | + self.above_palette_uv_size[c], | ||
| 2116 | + self.above_palette_uv_colors[c], | ||
| 2117 | + ) | ||
| 2089 | } else { | 2118 | } else { |
| 2090 | (0, [0u16; 8]) | 2119 | (0, [0u16; 8]) |
| 2091 | }; | 2120 | }; |
| @@ -2419,7 +2448,12 @@ impl Neighbours { | |||
| 2419 | 2448 | ||
| 2420 | /// [`Self::around_rect`] taking the block's position directly in 4x4 | 2449 | /// [`Self::around_rect`] taking the block's position directly in 4x4 |
| 2421 | /// mode-info units, mirroring [`Self::around_mi`]. | 2450 | /// mode-info units, mirroring [`Self::around_mi`]. |
| 2422 | - fn around_mi_rect(&self, (mi_r, mi_c): (usize, usize), w: usize, h: usize) -> [(bool, bool, i32); 3] { | 2451 | + fn around_mi_rect( |
| 2452 | + &self, | ||
| 2453 | + (mi_r, mi_c): (usize, usize), | ||
| 2454 | + w: usize, | ||
| 2455 | + h: usize, | ||
| 2456 | + ) -> [(bool, bool, i32); 3] { | ||
| 2423 | let (w_mi, h_mi) = (w / MI, h / MI); | 2457 | let (w_mi, h_mi) = (w / MI, h / MI); |
| 2424 | std::array::from_fn(|plane| { | 2458 | std::array::from_fn(|plane| { |
| 2425 | let mut above_coded = false; | 2459 | let mut above_coded = false; |
| @@ -2518,13 +2552,7 @@ impl Neighbours { | |||
| 2518 | 2552 | ||
| 2519 | /// [`Self::record_mi`] with independent above (`w`)/left (`h`) extents, | 2553 | /// [`Self::record_mi`] with independent above (`w`)/left (`h`) extents, |
| 2520 | /// in pixels (lane-partitions r1, mirroring [`Self::record_rect`]). | 2554 | /// in pixels (lane-partitions r1, mirroring [`Self::record_rect`]). |
| 2521 | - fn record_mi_rect( | 2555 | + fn record_mi_rect(&mut self, at_mi: (usize, usize), w: usize, h: usize, grids: &[Vec<i32>; 3]) { |
| 2522 | - &mut self, | ||
| 2523 | - at_mi: (usize, usize), | ||
| 2524 | - w: usize, | ||
| 2525 | - h: usize, | ||
| 2526 | - grids: &[Vec<i32>; 3], | ||
| 2527 | - ) { | ||
| 2528 | let (mi_r, mi_c) = at_mi; | 2556 | let (mi_r, mi_c) = at_mi; |
| 2529 | let states: [Neighbour; 3] = std::array::from_fn(|plane| neighbour_state(&grids[plane])); | 2557 | let states: [Neighbour; 3] = std::array::from_fn(|plane| neighbour_state(&grids[plane])); |
| 2530 | let (w_mi, h_mi) = (w / MI, h / MI); | 2558 | let (w_mi, h_mi) = (w / MI, h / MI); |
| @@ -2720,7 +2748,11 @@ struct PaletteUv { | |||
| 2720 | /// `get_unsigned_bits`, which is the same formula): smallest `n` with | 2748 | /// `get_unsigned_bits`, which is the same formula): smallest `n` with |
| 2721 | /// `2^n >= x`, `0` for `x <= 1`. | 2749 | /// `2^n >= x`, `0` for `x <= 1`. |
| 2722 | fn ceil_log2(x: u32) -> u32 { | 2750 | fn ceil_log2(x: u32) -> u32 { |
| 2723 | - if x < 2 { 0 } else { 32 - (x - 1).leading_zeros() } | 2751 | + if x < 2 { |
| 2752 | + 0 | ||
| 2753 | + } else { | ||
| 2754 | + 32 - (x - 1).leading_zeros() | ||
| 2755 | + } | ||
| 2724 | } | 2756 | } |
| 2725 | 2757 | ||
| 2726 | /// `av1_read_uniform` (decoder.h:425): a uniform `0..n` value coded as | 2758 | /// `av1_read_uniform` (decoder.h:425): a uniform `0..n` value coded as |
| @@ -2807,7 +2839,11 @@ fn read_palette_colors_y(dec: &mut SymbolDecoder, n: usize, cache: &[u16]) -> [u | |||
| 2807 | /// side by side). V never uses a cache: a leading bit picks either `n` raw | 2839 | /// side by side). V never uses a cache: a leading bit picks either `n` raw |
| 2808 | /// literals, or a first raw value plus `n-1` signed deltas that wrap mod 256 | 2840 | /// literals, or a first raw value plus `n-1` signed deltas that wrap mod 256 |
| 2809 | /// rather than clamp. | 2841 | /// rather than clamp. |
| 2810 | -fn read_palette_colors_uv(dec: &mut SymbolDecoder, n: usize, cache: &[u16]) -> ([u16; 8], [u16; 8]) { | 2842 | +fn read_palette_colors_uv( |
| 2843 | + dec: &mut SymbolDecoder, | ||
| 2844 | + n: usize, | ||
| 2845 | + cache: &[u16], | ||
| 2846 | +) -> ([u16; 8], [u16; 8]) { | ||
| 2811 | let mut cached = Vec::with_capacity(n); | 2847 | let mut cached = Vec::with_capacity(n); |
| 2812 | for &c in cache { | 2848 | for &c in cache { |
| 2813 | if cached.len() >= n { | 2849 | if cached.len() >= n { |
| @@ -2887,13 +2923,21 @@ fn palette_color_index_context( | |||
| 2887 | col: usize, | 2923 | col: usize, |
| 2888 | n: usize, | 2924 | n: usize, |
| 2889 | ) -> (usize, [u8; 8]) { | 2925 | ) -> (usize, [u8; 8]) { |
| 2890 | - let left = if col >= 1 { Some(map[row * side + col - 1]) } else { None }; | 2926 | + let left = if col >= 1 { |
| 2927 | + Some(map[row * side + col - 1]) | ||
| 2928 | + } else { | ||
| 2929 | + None | ||
| 2930 | + }; | ||
| 2891 | let up_left = if col >= 1 && row >= 1 { | 2931 | let up_left = if col >= 1 && row >= 1 { |
| 2892 | Some(map[(row - 1) * side + col - 1]) | 2932 | Some(map[(row - 1) * side + col - 1]) |
| 2893 | } else { | 2933 | } else { |
| 2894 | None | 2934 | None |
| 2895 | }; | 2935 | }; |
| 2896 | - let up = if row >= 1 { Some(map[(row - 1) * side + col]) } else { None }; | 2936 | + let up = if row >= 1 { |
| 2937 | + Some(map[(row - 1) * side + col]) | ||
| 2938 | + } else { | ||
| 2939 | + None | ||
| 2940 | + }; | ||
| 2897 | let mut scores = [0i32; 8]; | 2941 | let mut scores = [0i32; 8]; |
| 2898 | for (neighbour, weight) in [(left, 2), (up_left, 1), (up, 2)] { | 2942 | for (neighbour, weight) in [(left, 2), (up_left, 1), (up, 2)] { |
| 2899 | if let Some(v) = neighbour { | 2943 | if let Some(v) = neighbour { |
| @@ -3366,128 +3410,135 @@ fn decode_block_rect( | |||
| 3366 | // --enable-tx-size-search=0 the encoder writes no such symbol, so the | 3410 | // --enable-tx-size-search=0 the encoder writes no such symbol, so the |
| 3367 | // decoder consumed one that was never there. | 3411 | // decoder consumed one that was never there. |
| 3368 | { | 3412 | { |
| 3369 | - let around = neighbours.around_rect(at, bw, bh); | 3413 | + let around = neighbours.around_rect(at, bw, bh); |
| 3370 | - let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, mode); | 3414 | + let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, mode); |
| 3371 | - let (luma_levels, luma_tx_type) = read_coeffs_rect( | 3415 | + let (luma_levels, luma_tx_type) = read_coeffs_rect( |
| 3372 | - dec, | 3416 | + dec, |
| 3373 | - &mut luma_coding, | 3417 | + &mut luma_coding, |
| 3374 | - luma_scan, | 3418 | + luma_scan, |
| 3375 | - bw, | 3419 | + bw, |
| 3376 | - bh, | 3420 | + bh, |
| 3377 | - 0, | 3421 | + 0, |
| 3378 | - dc_sign_ctx(around[0].2), | 3422 | + dc_sign_ctx(around[0].2), |
| 3379 | - TxType::DctDct, | 3423 | + TxType::DctDct, |
| 3380 | - )?; | 3424 | + )?; |
| 3381 | - if std::env::var_os("EC_AV1_TRACE").is_some() { | 3425 | + if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 3382 | - let (rng, _) = dec.debug_state(); | 3426 | + let (rng, _) = dec.debug_state(); |
| 3383 | - eprintln!("TRACE_RECT_COEFF plane=0 mi_row={mi_r} mi_col={mi_c} rng={rng}"); | 3427 | + eprintln!("TRACE_RECT_COEFF plane=0 mi_row={mi_r} mi_col={mi_c} rng={rng}"); |
| 3384 | - } | 3428 | + } |
| 3385 | - let luma_residual = dequant_and_inverse_typed_wh( | 3429 | + let luma_residual = dequant_and_inverse_typed_wh( |
| 3386 | - &luma_levels, | 3430 | + &luma_levels, |
| 3387 | - bw, | 3431 | + bw, |
| 3388 | - bh, | 3432 | + bh, |
| 3389 | - crate::decode::bit_depth(), | 3433 | + crate::decode::bit_depth(), |
| 3390 | - CURRENT_Q_IDX.with(|c| c.get()), | 3434 | + CURRENT_Q_IDX.with(|c| c.get()), |
| 3391 | - plane_q_delta(0).0, | 3435 | + plane_q_delta(0).0, |
| 3392 | - plane_q_delta(0).1, | 3436 | + plane_q_delta(0).1, |
| 3393 | - luma_tx_type, | 3437 | + luma_tx_type, |
| 3394 | - ); | 3438 | + ); |
| 3395 | - y.reconstruct_rect( | 3439 | + y.reconstruct_rect( |
| 3396 | - px, | 3440 | + px, |
| 3397 | - py, | 3441 | + py, |
| 3398 | - bw, | 3442 | + bw, |
| 3399 | - bh, | 3443 | + bh, |
| 3400 | - mode, | 3444 | + mode, |
| 3401 | - angle_delta_y, | 3445 | + angle_delta_y, |
| 3402 | - reach, | 3446 | + reach, |
| 3403 | - &luma_residual, | 3447 | + &luma_residual, |
| 3404 | - None, | 3448 | + None, |
| 3405 | - filter_intra, | 3449 | + filter_intra, |
| 3406 | - smooth_neighbor, | 3450 | + smooth_neighbor, |
| 3407 | - ); | 3451 | + ); |
| 3408 | - let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | 3452 | + let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); |
| 3409 | - let u_default_tx = default_intra_tx_type(uv_predict_mode as u8); | 3453 | + let u_default_tx = default_intra_tx_type(uv_predict_mode as u8); |
| 3410 | - let u_skip_ctx = usize::from(around[1].0) + usize::from(around[1].1); | 3454 | + let u_skip_ctx = usize::from(around[1].0) + usize::from(around[1].1); |
| 3411 | - let mut u_coding = cdfs.txb(TxbSet::ChromaRect16x8, uv_predict_mode); | 3455 | + let mut u_coding = cdfs.txb(TxbSet::ChromaRect16x8, uv_predict_mode); |
| 3412 | - let (u_levels, u_tx_type) = read_coeffs_rect( | 3456 | + let (u_levels, u_tx_type) = read_coeffs_rect( |
| 3413 | - dec, | 3457 | + dec, |
| 3414 | - &mut u_coding, | 3458 | + &mut u_coding, |
| 3415 | - chroma_scan, | 3459 | + chroma_scan, |
| 3416 | - chroma_w, | 3460 | + chroma_w, |
| 3417 | - chroma_h, | 3461 | + chroma_h, |
| 3418 | - u_skip_ctx, | 3462 | + u_skip_ctx, |
| 3419 | - dc_sign_ctx(around[1].2), | 3463 | + dc_sign_ctx(around[1].2), |
| 3420 | - u_default_tx, | 3464 | + u_default_tx, |
| 3421 | - )?; | 3465 | + )?; |
| 3422 | - if std::env::var_os("EC_AV1_TRACE").is_some() { | 3466 | + if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 3423 | - let (rng, _) = dec.debug_state(); | 3467 | + let (rng, _) = dec.debug_state(); |
| 3424 | - eprintln!("TRACE_RECT_COEFF plane=1 mi_row={mi_r} mi_col={mi_c} rng={rng}"); | 3468 | + eprintln!("TRACE_RECT_COEFF plane=1 mi_row={mi_r} mi_col={mi_c} rng={rng}"); |
| 3425 | - } | 3469 | + } |
| 3426 | - let u_residual = dequant_and_inverse_typed_wh( | 3470 | + let u_residual = dequant_and_inverse_typed_wh( |
| 3427 | - &u_levels, | 3471 | + &u_levels, |
| 3428 | - chroma_w, | 3472 | + chroma_w, |
| 3429 | - chroma_h, | 3473 | + chroma_h, |
| 3430 | - crate::decode::bit_depth(), | 3474 | + crate::decode::bit_depth(), |
| 3431 | - CURRENT_Q_IDX.with(|c| c.get()), | 3475 | + CURRENT_Q_IDX.with(|c| c.get()), |
| 3432 | - plane_q_delta(1).0, | 3476 | + plane_q_delta(1).0, |
| 3433 | - plane_q_delta(1).1, | 3477 | + plane_q_delta(1).1, |
| 3434 | - u_tx_type, | 3478 | + u_tx_type, |
| 3435 | - ); | 3479 | + ); |
| 3436 | - u.reconstruct_rect( | 3480 | + u.reconstruct_rect( |
| 3437 | - cpx, | 3481 | + cpx, |
| 3438 | - cpy, | 3482 | + cpy, |
| 3439 | - chroma_w, | 3483 | + chroma_w, |
| 3440 | - chroma_h, | 3484 | + chroma_h, |
| 3441 | - uv_predict_mode, | 3485 | + uv_predict_mode, |
| 3442 | - angle_delta_uv, | 3486 | + angle_delta_uv, |
| 3443 | - reach, | 3487 | + reach, |
| 3444 | - &u_residual, | 3488 | + &u_residual, |
| 3445 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | 3489 | + alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), |
| 3446 | - None, | 3490 | + None, |
| 3447 | - smooth_neighbor_uv, | 3491 | + smooth_neighbor_uv, |
| 3448 | - ); | 3492 | + ); |
| 3449 | - let v_default_tx = default_intra_tx_type(uv_predict_mode as u8); | 3493 | + let v_default_tx = default_intra_tx_type(uv_predict_mode as u8); |
| 3450 | - let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1); | 3494 | + let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1); |
| 3451 | - let mut v_coding = cdfs.txb(TxbSet::ChromaRect16x8, uv_predict_mode); | 3495 | + let mut v_coding = cdfs.txb(TxbSet::ChromaRect16x8, uv_predict_mode); |
| 3452 | - let (v_levels, v_tx_type) = read_coeffs_rect( | 3496 | + let (v_levels, v_tx_type) = read_coeffs_rect( |
| 3453 | - dec, | 3497 | + dec, |
| 3454 | - &mut v_coding, | 3498 | + &mut v_coding, |
| 3455 | - chroma_scan, | 3499 | + chroma_scan, |
| 3456 | - chroma_w, | 3500 | + chroma_w, |
| 3457 | - chroma_h, | 3501 | + chroma_h, |
| 3458 | - v_skip_ctx, | 3502 | + v_skip_ctx, |
| 3459 | - dc_sign_ctx(around[2].2), | 3503 | + dc_sign_ctx(around[2].2), |
| 3460 | - v_default_tx, | 3504 | + v_default_tx, |
| 3461 | - )?; | 3505 | + )?; |
| 3462 | - if std::env::var_os("EC_AV1_TRACE").is_some() { | 3506 | + if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 3463 | - let (rng, _) = dec.debug_state(); | 3507 | + let (rng, _) = dec.debug_state(); |
| 3464 | - eprintln!("TRACE_RECT_COEFF plane=2 mi_row={mi_r} mi_col={mi_c} rng={rng}"); | 3508 | + eprintln!("TRACE_RECT_COEFF plane=2 mi_row={mi_r} mi_col={mi_c} rng={rng}"); |
| 3465 | - } | 3509 | + } |
| 3466 | - let v_residual = dequant_and_inverse_typed_wh( | 3510 | + let v_residual = dequant_and_inverse_typed_wh( |
| 3467 | - &v_levels, | 3511 | + &v_levels, |
| 3468 | - chroma_w, | 3512 | + chroma_w, |
| 3469 | - chroma_h, | 3513 | + chroma_h, |
| 3470 | - crate::decode::bit_depth(), | 3514 | + crate::decode::bit_depth(), |
| 3471 | - CURRENT_Q_IDX.with(|c| c.get()), | 3515 | + CURRENT_Q_IDX.with(|c| c.get()), |
| 3472 | - plane_q_delta(2).0, | 3516 | + plane_q_delta(2).0, |
| 3473 | - plane_q_delta(2).1, | 3517 | + plane_q_delta(2).1, |
| 3474 | - v_tx_type, | 3518 | + v_tx_type, |
| 3475 | - ); | 3519 | + ); |
| 3476 | - v.reconstruct_rect( | 3520 | + v.reconstruct_rect( |
| 3477 | - cpx, | 3521 | + cpx, |
| 3478 | - cpy, | 3522 | + cpy, |
| 3479 | - chroma_w, | 3523 | + chroma_w, |
| 3480 | - chroma_h, | 3524 | + chroma_h, |
| 3481 | - uv_predict_mode, | 3525 | + uv_predict_mode, |
| 3482 | - angle_delta_uv, | 3526 | + angle_delta_uv, |
| 3483 | - reach, | 3527 | + reach, |
| 3484 | - &v_residual, | 3528 | + &v_residual, |
| 3485 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | 3529 | + alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), |
| 3486 | - None, | 3530 | + None, |
| 3487 | - smooth_neighbor_uv, | 3531 | + smooth_neighbor_uv, |
| 3488 | - ); | 3532 | + ); |
| 3489 | - neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[luma_levels, u_levels, v_levels]); | 3533 | + neighbours.record_rect( |
| 3490 | - RECT_COEFF_HITS.with(|c| c.set(c.get() + 1)); | 3534 | + at, |
| 3535 | + bw, | ||
| 3536 | + bh, | ||
| 3537 | + mode, | ||
| 3538 | + uv_predict_mode, | ||
| 3539 | + &[luma_levels, u_levels, v_levels], | ||
| 3540 | + ); | ||
| 3541 | + RECT_COEFF_HITS.with(|c| c.set(c.get() + 1)); | ||
| 3491 | } | 3542 | } |
| 3492 | } | 3543 | } |
| 3493 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); | 3544 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); |
| @@ -3546,8 +3597,7 @@ fn decode_leaf_rect( | |||
| 3546 | left_mode = pmode; | 3597 | left_mode = pmode; |
| 3547 | } | 3598 | } |
| 3548 | } | 3599 | } |
| 3549 | - let smooth_neighbor = | 3600 | + let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 3550 | - is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | ||
| 3551 | if smooth_neighbor { | 3601 | if smooth_neighbor { |
| 3552 | SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | 3602 | SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); |
| 3553 | } | 3603 | } |
| @@ -3571,7 +3621,11 @@ fn decode_leaf_rect( | |||
| 3571 | "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", | 3621 | "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", |
| 3572 | )); | 3622 | )); |
| 3573 | } | 3623 | } |
| 3574 | - let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; | 3624 | + let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 3625 | + DC_PRED | ||
| 3626 | + } else { | ||
| 3627 | + uv_mode | ||
| 3628 | + }; | ||
| 3575 | let depth = if tx_select { | 3629 | let depth = if tx_select { |
| 3576 | let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh); | 3630 | let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh); |
| 3577 | dec.symbol(&mut cdfs.tx_size_cat2[ctx]) | 3631 | dec.symbol(&mut cdfs.tx_size_cat2[ctx]) |
| @@ -3862,7 +3916,9 @@ fn decode_block_rect64( | |||
| 3862 | ); | 3916 | ); |
| 3863 | if std::env::var_os("EC_SBPART_DUMP64").is_some() { | 3917 | if std::env::var_os("EC_SBPART_DUMP64").is_some() { |
| 3864 | let leftcol: Vec<u16> = if px > 0 { | 3918 | let leftcol: Vec<u16> = if px > 0 { |
| 3865 | - (py..py + bh).map(|row| y.data[row * y.width + px - 1]).collect() | 3919 | + (py..py + bh) |
| 3920 | + .map(|row| y.data[row * y.width + px - 1]) | ||
| 3921 | + .collect() | ||
| 3866 | } else { | 3922 | } else { |
| 3867 | vec![] | 3923 | vec![] |
| 3868 | }; | 3924 | }; |
| @@ -3986,7 +4042,14 @@ fn decode_block_rect64( | |||
| 3986 | None, | 4042 | None, |
| 3987 | smooth_neighbor_uv, | 4043 | smooth_neighbor_uv, |
| 3988 | ); | 4044 | ); |
| 3989 | - neighbours.record_rect(at, bw, bh, mode, uv_predict_mode, &[luma_levels, u_levels, v_levels]); | 4045 | + neighbours.record_rect( |
| 4046 | + at, | ||
| 4047 | + bw, | ||
| 4048 | + bh, | ||
| 4049 | + mode, | ||
| 4050 | + uv_predict_mode, | ||
| 4051 | + &[luma_levels, u_levels, v_levels], | ||
| 4052 | + ); | ||
| 3990 | RECT_COEFF_HITS.with(|c| c.set(c.get() + 1)); | 4053 | RECT_COEFF_HITS.with(|c| c.set(c.get() + 1)); |
| 3991 | } | 4054 | } |
| 3992 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); | 4055 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); |
| @@ -4179,9 +4242,7 @@ fn read_intra_mode( | |||
| 4179 | // `decode_color_index_map` call). | 4242 | // `decode_color_index_map` call). |
| 4180 | let mut palette_y_pending: Option<(usize, [u16; 8])> = None; | 4243 | let mut palette_y_pending: Option<(usize, [u16; 8])> = None; |
| 4181 | let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; | 4244 | let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None; |
| 4182 | - if allow_screen_content_tools | 4245 | + if allow_screen_content_tools && let Some(bsize_ctx) = palette_bsize_ctx(side) { |
| 4183 | - && let Some(bsize_ctx) = palette_bsize_ctx(side) | ||
| 4184 | - { | ||
| 4185 | let (mode_ctx, cache) = palette.unwrap_or((0, &[])); | 4246 | let (mode_ctx, cache) = palette.unwrap_or((0, &[])); |
| 4186 | if mode == DC_PRED { | 4247 | if mode == DC_PRED { |
| 4187 | if trace { | 4248 | if trace { |
| @@ -4195,7 +4256,10 @@ fn read_intra_mode( | |||
| 4195 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][mode_ctx]) != 0; | 4256 | mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][mode_ctx]) != 0; |
| 4196 | if mode == DC_PRED && trace { | 4257 | if mode == DC_PRED && trace { |
| 4197 | let (rng, _) = dec.debug_state(); | 4258 | let (rng, _) = dec.debug_state(); |
| 4198 | - eprintln!("TRACE palette_y_mode value={} rng={rng}", use_palette_y as i32); | 4259 | + eprintln!( |
| 4260 | + "TRACE palette_y_mode value={} rng={rng}", | ||
| 4261 | + use_palette_y as i32 | ||
| 4262 | + ); | ||
| 4199 | } | 4263 | } |
| 4200 | if use_palette_y { | 4264 | if use_palette_y { |
| 4201 | if palette.is_none() { | 4265 | if palette.is_none() { |
| @@ -4266,7 +4330,11 @@ fn read_intra_mode( | |||
| 4266 | if trace { | 4330 | if trace { |
| 4267 | eprintln!("TRACE palette_y size={n} colors={:?}", &colors[..n]); | 4331 | eprintln!("TRACE palette_y size={n} colors={:?}", &colors[..n]); |
| 4268 | } | 4332 | } |
| 4269 | - PaletteY { size: n, colors, map } | 4333 | + PaletteY { |
| 4334 | + size: n, | ||
| 4335 | + colors, | ||
| 4336 | + map, | ||
| 4337 | + } | ||
| 4270 | }); | 4338 | }); |
| 4271 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { | 4339 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { |
| 4272 | let map = decode_color_index_map(dec, cdfs, n, side / 2, true); | 4340 | let map = decode_color_index_map(dec, cdfs, n, side / 2, true); |
| @@ -4278,7 +4346,12 @@ fn read_intra_mode( | |||
| 4278 | &v_colors[..n] | 4346 | &v_colors[..n] |
| 4279 | ); | 4347 | ); |
| 4280 | } | 4348 | } |
| 4281 | - PaletteUv { size: n, u_colors, v_colors, map } | 4349 | + PaletteUv { |
| 4350 | + size: n, | ||
| 4351 | + u_colors, | ||
| 4352 | + v_colors, | ||
| 4353 | + map, | ||
| 4354 | + } | ||
| 4282 | }); | 4355 | }); |
| 4283 | Ok(( | 4356 | Ok(( |
| 4284 | skip, | 4357 | skip, |
| @@ -4728,7 +4801,15 @@ fn read_plane( | |||
| 4728 | full | 4801 | full |
| 4729 | }; | 4802 | }; |
| 4730 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx); | 4803 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx); |
| 4731 | - let residual = dequant_and_inverse_typed(&levels, side, bit_depth(), CURRENT_Q_IDX.with(|c| c.get()), dc_delta, ac_delta, tx_type); | 4804 | + let residual = dequant_and_inverse_typed( |
| 4805 | + &levels, | ||
| 4806 | + side, | ||
| 4807 | + bit_depth(), | ||
| 4808 | + CURRENT_Q_IDX.with(|c| c.get()), | ||
| 4809 | + dc_delta, | ||
| 4810 | + ac_delta, | ||
| 4811 | + tx_type, | ||
| 4812 | + ); | ||
| 4732 | if std::env::var_os("EC_AV1_TRACE").is_some() { | 4813 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 4733 | eprintln!( | 4814 | eprintln!( |
| 4734 | "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={levels:?} residual={residual:?}", | 4815 | "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={levels:?} residual={residual:?}", |
| @@ -4795,23 +4876,32 @@ fn decode_block( | |||
| 4795 | let (px, py) = (c * SUB, r * SUB); | 4876 | let (px, py) = (c * SUB, r * SUB); |
| 4796 | let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache(at); | 4877 | let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache(at); |
| 4797 | let palette_uv_cache = neighbours.palette_uv_cache(at); | 4878 | let palette_uv_cache = neighbours.palette_uv_cache(at); |
| 4798 | - let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) = | 4879 | + let ( |
| 4799 | - read_intra_mode( | 4880 | + skip, |
| 4800 | - dec, | 4881 | + mode, |
| 4801 | - cdfs, | 4882 | + angle_delta_y, |
| 4802 | - neighbours.above_mode[c], | 4883 | + uv_mode, |
| 4803 | - neighbours.left_mode[r], | 4884 | + angle_delta_uv, |
| 4804 | - cfl, | 4885 | + alpha, |
| 4805 | - side, | 4886 | + filter_intra, |
| 4806 | - enable_filter_intra, | 4887 | + palette_y, |
| 4807 | - neighbours.skip_txfm_ctx(r * (SUB / MI), c * (SUB / MI)), | 4888 | + palette_uv, |
| 4808 | - allow_screen_content_tools, | 4889 | + ) = read_intra_mode( |
| 4809 | - allow_intrabc, | 4890 | + dec, |
| 4810 | - Some((palette_ctx, &palette_cache)), | 4891 | + cdfs, |
| 4811 | - &palette_uv_cache, | 4892 | + neighbours.above_mode[c], |
| 4812 | - r * (SUB / MI), | 4893 | + neighbours.left_mode[r], |
| 4813 | - c * (SUB / MI), | 4894 | + cfl, |
| 4814 | - )?; | 4895 | + side, |
| 4896 | + enable_filter_intra, | ||
| 4897 | + neighbours.skip_txfm_ctx(r * (SUB / MI), c * (SUB / MI)), | ||
| 4898 | + allow_screen_content_tools, | ||
| 4899 | + allow_intrabc, | ||
| 4900 | + Some((palette_ctx, &palette_cache)), | ||
| 4901 | + &palette_uv_cache, | ||
| 4902 | + r * (SUB / MI), | ||
| 4903 | + c * (SUB / MI), | ||
| 4904 | + )?; | ||
| 4815 | // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED` | 4905 | // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED` |
| 4816 | // (13) predicts as `DC_PRED` with the [`cfl_scaled`] nudge carrying the | 4906 | // (13) predicts as `DC_PRED` with the [`cfl_scaled`] nudge carrying the |
| 4817 | // actual chroma-from-luma correlation, same as this decoder always did. | 4907 | // actual chroma-from-luma correlation, same as this decoder always did. |
| @@ -4869,11 +4959,7 @@ fn decode_block( | |||
| 4869 | "a palette block with a split luma transform (round 1)", | 4959 | "a palette block with a split luma transform (round 1)", |
| 4870 | )); | 4960 | )); |
| 4871 | } | 4961 | } |
| 4872 | - let buf: Vec<u16> = py | 4962 | + let buf: Vec<u16> = py.map.iter().map(|&idx| py.colors[idx as usize]).collect(); |
| 4873 | - .map | ||
| 4874 | - .iter() | ||
| 4875 | - .map(|&idx| py.colors[idx as usize]) | ||
| 4876 | - .collect(); | ||
| 4877 | PALETTE_PRED.with(|c| *c.borrow_mut() = Some(buf)); | 4963 | PALETTE_PRED.with(|c| *c.borrow_mut() = Some(buf)); |
| 4878 | } | 4964 | } |
| 4879 | // A UV-palette block's own chroma prediction override (lane-palette2 r1), | 4965 | // A UV-palette block's own chroma prediction override (lane-palette2 r1), |
| @@ -4883,8 +4969,14 @@ fn decode_block( | |||
| 4883 | // either of these run. | 4969 | // either of these run. |
| 4884 | let palette_uv_bufs: Option<(Vec<u16>, Vec<u16>)> = palette_uv.as_ref().map(|puv| { | 4970 | let palette_uv_bufs: Option<(Vec<u16>, Vec<u16>)> = palette_uv.as_ref().map(|puv| { |
| 4885 | ( | 4971 | ( |
| 4886 | - puv.map.iter().map(|&idx| puv.u_colors[idx as usize]).collect(), | 4972 | + puv.map |
| 4887 | - puv.map.iter().map(|&idx| puv.v_colors[idx as usize]).collect(), | 4973 | + .iter() |
| 4974 | + .map(|&idx| puv.u_colors[idx as usize]) | ||
| 4975 | + .collect(), | ||
| 4976 | + puv.map | ||
| 4977 | + .iter() | ||
| 4978 | + .map(|&idx| puv.v_colors[idx as usize]) | ||
| 4979 | + .collect(), | ||
| 4888 | ) | 4980 | ) |
| 4889 | }); | 4981 | }); |
| 4890 | if skip { | 4982 | if skip { |
| @@ -4936,7 +5028,13 @@ fn decode_block( | |||
| 4936 | let luma_grid = vec![0i32; side * side]; | 5028 | let luma_grid = vec![0i32; side * side]; |
| 4937 | let u_grid = vec![0i32; chroma_side * chroma_side]; | 5029 | let u_grid = vec![0i32; chroma_side * chroma_side]; |
| 4938 | let v_grid = vec![0i32; chroma_side * chroma_side]; | 5030 | let v_grid = vec![0i32; chroma_side * chroma_side]; |
| 4939 | - neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]); | 5031 | + neighbours.record( |
| 5032 | + at, | ||
| 5033 | + side, | ||
| 5034 | + mode, | ||
| 5035 | + uv_predict_mode, | ||
| 5036 | + &[luma_grid, u_grid, v_grid], | ||
| 5037 | + ); | ||
| 4940 | } else if !tx_select || logical_tx == side { | 5038 | } else if !tx_select || logical_tx == side { |
| 4941 | // A single luma transform unit -- the old path, unchanged (including | 5039 | // A single luma transform unit -- the old path, unchanged (including |
| 4942 | // the 64x64 corner case, `logical_tx == side == 64` with | 5040 | // the 64x64 corner case, `logical_tx == side == 64` with |
| @@ -5021,7 +5119,13 @@ fn decode_block( | |||
| 5021 | None, | 5119 | None, |
| 5022 | smooth_neighbor_uv, | 5120 | smooth_neighbor_uv, |
| 5023 | )?; | 5121 | )?; |
| 5024 | - neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]); | 5122 | + neighbours.record( |
| 5123 | + at, | ||
| 5124 | + side, | ||
| 5125 | + mode, | ||
| 5126 | + uv_predict_mode, | ||
| 5127 | + &[luma_grid, u_grid, v_grid], | ||
| 5128 | + ); | ||
| 5025 | } else { | 5129 | } else { |
| 5026 | // Several luma transform units, raster order (spec | 5130 | // Several luma transform units, raster order (spec |
| 5027 | // `transform_block`'s loop): the block's resolved transform is | 5131 | // `transform_block`'s loop): the block's resolved transform is |
| @@ -5202,23 +5306,32 @@ fn decode_leaf8( | |||
| 5202 | // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec | 5306 | // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec |
| 5203 | // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other | 5307 | // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other |
| 5204 | // `decode_block` caller at 16x16 and up. | 5308 | // `decode_block` caller at 16x16 and up. |
| 5205 | - let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, _palette_y, _palette_uv) = | 5309 | + let ( |
| 5206 | - read_intra_mode( | 5310 | + skip, |
| 5207 | - dec, | 5311 | + mode, |
| 5208 | - cdfs, | 5312 | + angle_delta_y, |
| 5209 | - above_mode, | 5313 | + uv_mode, |
| 5210 | - left_mode, | 5314 | + angle_delta_uv, |
| 5211 | - true, | 5315 | + alpha, |
| 5212 | - 8, | 5316 | + filter_intra, |
| 5213 | - enable_filter_intra, | 5317 | + _palette_y, |
| 5214 | - neighbours.skip_txfm_ctx(leaf_mi.0, leaf_mi.1), | 5318 | + _palette_uv, |
| 5215 | - allow_screen_content_tools, | 5319 | + ) = read_intra_mode( |
| 5216 | - allow_intrabc, | 5320 | + dec, |
| 5217 | - None, | 5321 | + cdfs, |
| 5218 | - &[], | 5322 | + above_mode, |
| 5219 | - leaf_mi.0, | 5323 | + left_mode, |
| 5220 | - leaf_mi.1, | 5324 | + true, |
| 5221 | - )?; | 5325 | + 8, |
| 5326 | + enable_filter_intra, | ||
| 5327 | + neighbours.skip_txfm_ctx(leaf_mi.0, leaf_mi.1), | ||
| 5328 | + allow_screen_content_tools, | ||
| 5329 | + allow_intrabc, | ||
| 5330 | + None, | ||
| 5331 | + &[], | ||
| 5332 | + leaf_mi.0, | ||
| 5333 | + leaf_mi.1, | ||
| 5334 | + )?; | ||
| 5222 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { | 5335 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 5223 | DC_PRED | 5336 | DC_PRED |
| 5224 | } else { | 5337 | } else { |
| @@ -5764,18 +5877,10 @@ fn read_tx_size( | |||
| 5764 | ) -> usize { | 5877 | ) -> usize { |
| 5765 | let ctx = tx_size_context(n, at_mi, side); | 5878 | let ctx = tx_size_context(n, at_mi, side); |
| 5766 | let depth = match side { | 5879 | let depth = match side { |
| 5767 | - 8 => { | 5880 | + 8 => dec.symbol(&mut cdfs.tx_size_cat0[ctx]), |
| 5768 | - dec.symbol(&mut cdfs.tx_size_cat0[ctx]) | 5881 | + 16 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]), |
| 5769 | - } | 5882 | + 32 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]), |
| 5770 | - 16 => { | 5883 | + 64 => dec.symbol(&mut cdfs.tx_size_cat3[ctx]), |
| 5771 | - dec.symbol(&mut cdfs.tx_size_cat1[ctx]) | ||
| 5772 | - } | ||
| 5773 | - 32 => { | ||
| 5774 | - dec.symbol(&mut cdfs.tx_size_cat2[ctx]) | ||
| 5775 | - } | ||
| 5776 | - 64 => { | ||
| 5777 | - dec.symbol(&mut cdfs.tx_size_cat3[ctx]) | ||
| 5778 | - } | ||
| 5779 | _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64"), | 5884 | _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64"), |
| 5780 | }; | 5885 | }; |
| 5781 | if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { | 5886 | if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { |
| @@ -5852,6 +5957,14 @@ fn set_txfm_ctxs( | |||
| 5852 | } | 5957 | } |
| 5853 | } | 5958 | } |
| 5854 | 5959 | ||
| 5960 | +/// The value libaom initialises both transform contexts to -- NOT zero: | ||
| 5961 | +/// `av1_zero_above_context` memsets the txfm row to | ||
| 5962 | +/// `tx_size_wide[TX_SIZES_LARGEST]` and `av1_zero_left_context` does the same | ||
| 5963 | +/// with `tx_size_high[TX_SIZES_LARGEST]` (`av1_common_int.h`), i.e. 64 | ||
| 5964 | +/// pixels, so an unwritten neighbour reads as the *widest* possible | ||
| 5965 | +/// transform, not the narrowest. | ||
| 5966 | +const TXFM_CTX_INIT: u8 = 64; | ||
| 5967 | + | ||
| 5855 | /// libaom's `MAX_VARTX_DEPTH`: an inter block's transform tree halves at most | 5968 | /// libaom's `MAX_VARTX_DEPTH`: an inter block's transform tree halves at most |
| 5856 | /// twice below its own largest transform. | 5969 | /// twice below its own largest transform. |
| 5857 | const MAX_VARTX_DEPTH: usize = 2; | 5970 | const MAX_VARTX_DEPTH: usize = 2; |
| @@ -5985,6 +6098,14 @@ fn read_block_tx_size( | |||
| 5985 | } | 6098 | } |
| 5986 | } | 6099 | } |
| 5987 | let single = leaves.len() == 1 && leaves[0].2 == side; | 6100 | let single = leaves.len() == 1 && leaves[0].2 == side; |
| 6101 | + if !single && leaves.iter().any(|leaf| leaf.2 > 32) { | ||
| 6102 | + // Only a block wider than a superblock's own 64x64 max transform | ||
| 6103 | + // reaches here; this crate has no 64-point *inter* coefficient | ||
| 6104 | + // table set ([`inter_txbset_for`] stops at 32). | ||
| 6105 | + return Err(unsupported( | ||
| 6106 | + "an inter var-tx tree with a leaf transform larger than 32x32", | ||
| 6107 | + )); | ||
| 6108 | + } | ||
| 5988 | let resolved = leaves.last().map_or(side, |l| l.2); | 6109 | let resolved = leaves.last().map_or(side, |l| l.2); |
| 5989 | return Ok((resolved, (!single).then_some(leaves))); | 6110 | return Ok((resolved, (!single).then_some(leaves))); |
| 5990 | } | 6111 | } |
| @@ -6008,6 +6129,94 @@ fn read_block_tx_size( | |||
| 6008 | Ok((tx, None)) | 6129 | Ok((tx, None)) |
| 6009 | } | 6130 | } |
| 6010 | 6131 | ||
| 6132 | +/// One 8x8 inter leaf's luma residual (lane-txselect): either the whole-8x8 | ||
| 6133 | +/// transform, or -- when [`read_block_tx_size`]'s var-tx tree took the single | ||
| 6134 | +/// split a `BLOCK_8X8` can take (`split`) -- the four 4x4 transform units in | ||
| 6135 | +/// raster order, each reading its own coefficient context off the units | ||
| 6136 | +/// already decoded before it. Returns the block's luma grid (all-zero in the | ||
| 6137 | +/// split case, whose reconstruction has already happened unit by unit) and | ||
| 6138 | +/// the `tx_type` chroma inherits: `av1_get_tx_type`'s colocated luma lookup, | ||
| 6139 | +/// which for a split block lands on the top-left unit. | ||
| 6140 | +#[allow(clippy::too_many_arguments)] | ||
| 6141 | +fn read_inter_luma8( | ||
| 6142 | + dec: &mut SymbolDecoder, | ||
| 6143 | + cdfs: &mut Cdfs, | ||
| 6144 | + neighbours: &mut Neighbours, | ||
| 6145 | + leaf_mi: (usize, usize), | ||
| 6146 | + y: &mut PlaneBuf, | ||
| 6147 | + px: usize, | ||
| 6148 | + py: usize, | ||
| 6149 | + pred_y: &[u16], | ||
| 6150 | + mode_for_tx: usize, | ||
| 6151 | + base_q_idx: u8, | ||
| 6152 | + scan8: &[u16], | ||
| 6153 | + scan4: &[u16], | ||
| 6154 | + reduced_tx_set: bool, | ||
| 6155 | + split: bool, | ||
| 6156 | +) -> Result<(Vec<i32>, TxType)> { | ||
| 6157 | + if !split { | ||
| 6158 | + return read_inter_plane( | ||
| 6159 | + dec, | ||
| 6160 | + cdfs, | ||
| 6161 | + if reduced_tx_set { | ||
| 6162 | + TxbSet::Luma8Inter | ||
| 6163 | + } else { | ||
| 6164 | + TxbSet::Luma8InterSet1 | ||
| 6165 | + }, | ||
| 6166 | + scan8, | ||
| 6167 | + 0, | ||
| 6168 | + neighbours.around_mi(leaf_mi, 8)[0], | ||
| 6169 | + mode_for_tx, | ||
| 6170 | + y, | ||
| 6171 | + px, | ||
| 6172 | + py, | ||
| 6173 | + 8, | ||
| 6174 | + base_q_idx, | ||
| 6175 | + pred_y, | ||
| 6176 | + None, | ||
| 6177 | + None, | ||
| 6178 | + ); | ||
| 6179 | + } | ||
| 6180 | + let mut first = TxType::DctDct; | ||
| 6181 | + for tu_row in 0..2 { | ||
| 6182 | + for tu_col in 0..2 { | ||
| 6183 | + let tu_mi = (leaf_mi.0 + tu_row, leaf_mi.1 + tu_col); | ||
| 6184 | + let mut tu_pred = Vec::with_capacity(16); | ||
| 6185 | + for rr in 0..4 { | ||
| 6186 | + let start = (tu_row * 4 + rr) * 8 + tu_col * 4; | ||
| 6187 | + tu_pred.extend_from_slice(&pred_y[start..start + 4]); | ||
| 6188 | + } | ||
| 6189 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); | ||
| 6190 | + let (tu_grid, tu_tx_type) = read_inter_plane( | ||
| 6191 | + dec, | ||
| 6192 | + cdfs, | ||
| 6193 | + if reduced_tx_set { | ||
| 6194 | + TxbSet::Luma4Inter | ||
| 6195 | + } else { | ||
| 6196 | + TxbSet::Luma4InterSet1 | ||
| 6197 | + }, | ||
| 6198 | + scan4, | ||
| 6199 | + 0, | ||
| 6200 | + neighbours.around_mi(tu_mi, 4)[0], | ||
| 6201 | + mode_for_tx, | ||
| 6202 | + y, | ||
| 6203 | + px + tu_col * 4, | ||
| 6204 | + py + tu_row * 4, | ||
| 6205 | + 4, | ||
| 6206 | + base_q_idx, | ||
| 6207 | + &tu_pred, | ||
| 6208 | + None, | ||
| 6209 | + Some(tu_skip_ctx), | ||
| 6210 | + )?; | ||
| 6211 | + if tu_row == 0 && tu_col == 0 { | ||
| 6212 | + first = tu_tx_type; | ||
| 6213 | + } | ||
| 6214 | + neighbours.record_mi_luma(tu_mi, 4, &tu_grid); | ||
| 6215 | + } | ||
| 6216 | + } | ||
| 6217 | + Ok((vec![0i32; 64], first)) | ||
| 6218 | +} | ||
| 6219 | + | ||
| 6011 | /// The [`TxbSet`] one leaf of an inter block's var-tx tree reads its | 6220 | /// The [`TxbSet`] one leaf of an inter block's var-tx tree reads its |
| 6012 | /// coefficient tables from -- the inter counterpart of [`txbset_for`]. | 6221 | /// coefficient tables from -- the inter counterpart of [`txbset_for`]. |
| 6013 | fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet { | 6222 | fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet { |
| @@ -6082,7 +6291,13 @@ fn unit_log2(px: u32) -> i32 { | |||
| 6082 | /// the flat `mode_deltas[1]` this used before was a `LAST_FRAME`-reachable | 6291 | /// the flat `mode_deltas[1]` this used before was a `LAST_FRAME`-reachable |
| 6083 | /// wrong delta on every `GLOBALMV` block, masked while any `GOLDEN_FRAME` | 6292 | /// wrong delta on every `GLOBALMV` block, masked while any `GOLDEN_FRAME` |
| 6084 | /// block anywhere aborted the whole stream's decode before comparison). | 6293 | /// block anywhere aborted the whole stream's decode before comparison). |
| 6085 | -fn lf_level(lf: &LoopFilterParams, plane_idx: usize, dir: usize, ref_frame: i8, delta_lf: i32) -> i32 { | 6294 | +fn lf_level( |
| 6295 | + lf: &LoopFilterParams, | ||
| 6296 | + plane_idx: usize, | ||
| 6297 | + dir: usize, | ||
| 6298 | + ref_frame: i8, | ||
| 6299 | + delta_lf: i32, | ||
| 6300 | +) -> i32 { | ||
| 6086 | let base = i32::from(if plane_idx == 0 { | 6301 | let base = i32::from(if plane_idx == 0 { |
| 6087 | lf.level[dir] | 6302 | lf.level[dir] |
| 6088 | } else if plane_idx == 1 { | 6303 | } else if plane_idx == 1 { |
| @@ -6147,7 +6362,8 @@ fn edge_params( | |||
| 6147 | let pv_ref = n.ref_grid[pv_mi_r * n.skip_grid_cols_mi + pv_mi_c]; | 6362 | let pv_ref = n.ref_grid[pv_mi_r * n.skip_grid_cols_mi + pv_mi_c]; |
| 6148 | let delta_idx = if plane_idx == 0 { dir } else { plane_idx + 1 }; | 6363 | let delta_idx = if plane_idx == 0 { dir } else { plane_idx + 1 }; |
| 6149 | let cur_delta_lf = i32::from(n.delta_lf_grid[mi_r * n.skip_grid_cols_mi + mi_c][delta_idx]); | 6364 | let cur_delta_lf = i32::from(n.delta_lf_grid[mi_r * n.skip_grid_cols_mi + mi_c][delta_idx]); |
| 6150 | - let pv_delta_lf = i32::from(n.delta_lf_grid[pv_mi_r * n.skip_grid_cols_mi + pv_mi_c][delta_idx]); | 6365 | + let pv_delta_lf = |
| 6366 | + i32::from(n.delta_lf_grid[pv_mi_r * n.skip_grid_cols_mi + pv_mi_c][delta_idx]); | ||
| 6151 | 6367 | ||
| 6152 | let cur_level = lf_level(lf, plane_idx, dir, cur_ref, cur_delta_lf); | 6368 | let cur_level = lf_level(lf, plane_idx, dir, cur_ref, cur_delta_lf); |
| 6153 | let pv_level = lf_level(lf, plane_idx, dir, pv_ref, pv_delta_lf); | 6369 | let pv_level = lf_level(lf, plane_idx, dir, pv_ref, pv_delta_lf); |
| @@ -6510,9 +6726,7 @@ fn deblock_plane( | |||
| 6510 | let mut y0 = 4usize; | 6726 | let mut y0 = 4usize; |
| 6511 | while y0 < th { | 6727 | while y0 < th { |
| 6512 | if let Some((len, level)) = edge_params(lf, n, plane_idx, 1, chroma, x0, y0) { | 6728 | if let Some((len, level)) = edge_params(lf, n, plane_idx, 1, chroma, x0, y0) { |
| 6513 | - if std::env::var_os("EC_AV1_DEBLOCK_TRACE").is_some() | 6729 | + if std::env::var_os("EC_AV1_DEBLOCK_TRACE").is_some() && plane_idx == 0 && x0 == 44 |
| 6514 | - && plane_idx == 0 | ||
| 6515 | - && x0 == 44 | ||
| 6516 | { | 6730 | { |
| 6517 | eprintln!( | 6731 | eprintln!( |
| 6518 | "HEDGE x0={x0} y0={y0} len={len} level={level} sharpness={}", | 6732 | "HEDGE x0={x0} y0={y0} len={len} level={level} sharpness={}", |
| @@ -6563,10 +6777,7 @@ fn apply_cdef( | |||
| 6563 | return 0; | 6777 | return 0; |
| 6564 | } | 6778 | } |
| 6565 | let (sb_r, sb_c) = (mi_r / SB_MI as usize, mi_c / SB_MI as usize); | 6779 | let (sb_r, sb_c) = (mi_r / SB_MI as usize, mi_c / SB_MI as usize); |
| 6566 | - idx_grid | 6780 | + idx_grid.get(sb_r * sb_cols + sb_c).copied().unwrap_or(0) as usize |
| 6567 | - .get(sb_r * sb_cols + sb_c) | ||
| 6568 | - .copied() | ||
| 6569 | - .unwrap_or(0) as usize | ||
| 6570 | }; | 6781 | }; |
| 6571 | let src_y = y.data.clone(); | 6782 | let src_y = y.data.clone(); |
| 6572 | let src_u = u.data.clone(); | 6783 | let src_u = u.data.clone(); |
| @@ -6937,8 +7148,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 6937 | // last entry) is not, so the upper bound needs `div_ceil` the same | 7148 | // last entry) is not, so the upper bound needs `div_ceil` the same |
| 6938 | // way the whole-frame `sb_rows`/`sb_cols` above does, to keep the | 7149 | // way the whole-frame `sb_rows`/`sb_cols` above does, to keep the |
| 6939 | // trailing partial superblock row/column in scope. | 7150 | // trailing partial superblock row/column in scope. |
| 6940 | - let (sb_r0, sb_r1) = ((mi_row0 / SB_MI).min(sb_rows), mi_row1.div_ceil(SB_MI).min(sb_rows)); | 7151 | + let (sb_r0, sb_r1) = ( |
| 6941 | - let (sb_c0, sb_c1) = ((mi_col0 / SB_MI).min(sb_cols), mi_col1.div_ceil(SB_MI).min(sb_cols)); | 7152 | + (mi_row0 / SB_MI).min(sb_rows), |
| 7153 | + mi_row1.div_ceil(SB_MI).min(sb_rows), | ||
| 7154 | + ); | ||
| 7155 | + let (sb_c0, sb_c1) = ( | ||
| 7156 | + (mi_col0 / SB_MI).min(sb_cols), | ||
| 7157 | + mi_col1.div_ceil(SB_MI).min(sb_cols), | ||
| 7158 | + ); | ||
| 6942 | 7159 | ||
| 6943 | let mut cdfs = base_cdfs.clone(); | 7160 | let mut cdfs = base_cdfs.clone(); |
| 6944 | // spec `decode_tile`: `CurrentQIndex` resets to the frame's own | 7161 | // spec `decode_tile`: `CurrentQIndex` resets to the frame's own |
| @@ -6975,186 +7192,495 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 6975 | ); | 7192 | ); |
| 6976 | TILE_HITS.with(|c| c.set(c.get() + 1)); | 7193 | TILE_HITS.with(|c| c.set(c.get() + 1)); |
| 6977 | 7194 | ||
| 6978 | - for sb_r in sb_r0..sb_r1 { | 7195 | + for sb_r in sb_r0..sb_r1 { |
| 6979 | - neighbours.start_row(); | 7196 | + neighbours.start_row(); |
| 6980 | - for sb_c in sb_c0..sb_c1 { | 7197 | + for sb_c in sb_c0..sb_c1 { |
| 6981 | - crate::restoration::read_lr( | 7198 | + crate::restoration::read_lr( |
| 6982 | - &mut dec, | 7199 | + &mut dec, |
| 6983 | - &mut cdfs, | 7200 | + &mut cdfs, |
| 6984 | - lr, | 7201 | + lr, |
| 6985 | - &mut lr_grid, | 7202 | + &mut lr_grid, |
| 6986 | - &mut lr_reference, | 7203 | + &mut lr_reference, |
| 6987 | - sb_r * SB_MI, | 7204 | + sb_r * SB_MI, |
| 6988 | - sb_c * SB_MI, | 7205 | + sb_c * SB_MI, |
| 6989 | - SB_MI, | 7206 | + SB_MI, |
| 6990 | - ); | 7207 | + ); |
| 6991 | - CDEF_TRANSMITTED.with(|c| c.set(false)); | 7208 | + CDEF_TRANSMITTED.with(|c| c.set(false)); |
| 6992 | - let at = (sb_r as usize * 4, sb_c as usize * 4); | 7209 | + let at = (sb_r as usize * 4, sb_c as usize * 4); |
| 6993 | - let ctx = neighbours.partition_ctx(at, SB); | 7210 | + let ctx = neighbours.partition_ctx(at, SB); |
| 6994 | - let (has_cols, has_rows) = ( | 7211 | + let (has_cols, has_rows) = ( |
| 6995 | - sb_c * SB_MI + SB_MI / 2 < mi_cols, | 7212 | + sb_c * SB_MI + SB_MI / 2 < mi_cols, |
| 6996 | - sb_r * SB_MI + SB_MI / 2 < mi_rows, | 7213 | + sb_r * SB_MI + SB_MI / 2 < mi_rows, |
| 6997 | - ); | 7214 | + ); |
| 6998 | - // Recomputed at this superblock's own half (spec | 7215 | + // Recomputed at this superblock's own half (spec |
| 6999 | - // `decode_partition`): a full alphabet symbol when both halves are | 7216 | + // `decode_partition`): a full alphabet symbol when both halves are |
| 7000 | - // inside the true frame, a single gathered bit when just one is | 7217 | + // inside the true frame, a single gathered bit when just one is |
| 7001 | - // (the superblock cannot be left whole, so this is forced split), | 7218 | + // (the superblock cannot be left whole, so this is forced split), |
| 7002 | - // and nothing at all (SPLIT inferred, no bits) when neither is — | 7219 | + // and nothing at all (SPLIT inferred, no bits) when neither is — |
| 7003 | - // mirroring [`crate::tile::sb_coeff_key_frame_tile`]'s own | 7220 | + // mirroring [`crate::tile::sb_coeff_key_frame_tile`]'s own |
| 7004 | - // three-way write exactly. | 7221 | + // three-way write exactly. |
| 7005 | - let part = if has_cols && has_rows { | 7222 | + let part = if has_cols && has_rows { |
| 7006 | - let p = dec.symbol(&mut cdfs.partition_w64[ctx]); | 7223 | + let p = dec.symbol(&mut cdfs.partition_w64[ctx]); |
| 7007 | - if std::env::var_os("EC_AV1_TRACE").is_some() { | 7224 | + if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 7008 | - eprintln!("TRACE partition_w64 ctx={ctx} value={p}"); | 7225 | + eprintln!("TRACE partition_w64 ctx={ctx} value={p}"); |
| 7009 | - } | ||
| 7010 | - p | ||
| 7011 | - } else { | ||
| 7012 | - match (has_cols, has_rows) { | ||
| 7013 | - (true, false) => { | ||
| 7014 | - dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)); | ||
| 7015 | - } | ||
| 7016 | - (false, true) => { | ||
| 7017 | - dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)); | ||
| 7018 | } | 7226 | } |
| 7019 | - _ => {} | 7227 | + p |
| 7020 | - } | 7228 | + } else { |
| 7021 | - PARTITION_SPLIT | 7229 | + match (has_cols, has_rows) { |
| 7022 | - }; | 7230 | + (true, false) => { |
| 7023 | - match part { | 7231 | + dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)); |
| 7024 | - PARTITION_NONE => { | ||
| 7025 | - decode_block( | ||
| 7026 | - &mut dec, | ||
| 7027 | - &mut cdfs, | ||
| 7028 | - &mut neighbours, | ||
| 7029 | - at, | ||
| 7030 | - SB, | ||
| 7031 | - TxbSet::Luma64, | ||
| 7032 | - TxbSet::Chroma32, | ||
| 7033 | - TX32, | ||
| 7034 | - TX32, | ||
| 7035 | - (&scan32, &scan32), | ||
| 7036 | - false, | ||
| 7037 | - &mut y, | ||
| 7038 | - &mut u, | ||
| 7039 | - &mut v, | ||
| 7040 | - base_q_idx, | ||
| 7041 | - enable_filter_intra, | ||
| 7042 | - allow_screen_content_tools, | ||
| 7043 | - allow_intrabc, | ||
| 7044 | - &scan32, | ||
| 7045 | - &scan16, | ||
| 7046 | - &scan8, | ||
| 7047 | - &scan4, | ||
| 7048 | - tx_select, | ||
| 7049 | - reduced_tx_set, | ||
| 7050 | - )?; | ||
| 7051 | - } | ||
| 7052 | - PARTITION_SPLIT => { | ||
| 7053 | - for q in 0..4 { | ||
| 7054 | - let (r32, c32) = (sb_r * 2 + q / 2, sb_c * 2 + q % 2); | ||
| 7055 | - if r32 >= rows32 || c32 >= cols32 { | ||
| 7056 | - continue; | ||
| 7057 | } | 7232 | } |
| 7058 | - let at32 = (r32 as usize * 2, c32 as usize * 2); | 7233 | + (false, true) => { |
| 7059 | - let ctx32 = neighbours.partition_ctx(at32, BLOCK); | 7234 | + dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)); |
| 7060 | - let (has_cols32, has_rows32) = ( | 7235 | + } |
| 7061 | - has_half(c32 * BLOCK_MI, BLOCK_MI, mi_cols), | 7236 | + _ => {} |
| 7062 | - has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows), | 7237 | + } |
| 7063 | - ); | 7238 | + PARTITION_SPLIT |
| 7064 | - let part32 = if has_cols32 && has_rows32 { | 7239 | + }; |
| 7065 | - let p = dec.symbol(&mut cdfs.partition_w32[ctx32]); | 7240 | + match part { |
| 7066 | - if std::env::var_os("EC_AV1_TRACE").is_some() { | 7241 | + PARTITION_NONE => { |
| 7067 | - let (rng, _) = dec.debug_state(); | 7242 | + decode_block( |
| 7068 | - eprintln!( | 7243 | + &mut dec, |
| 7069 | - "TRACE partition_w32 mi=({},{}) ctx={ctx32} value={p} rng={rng}", | 7244 | + &mut cdfs, |
| 7070 | - r32 * BLOCK_MI, | 7245 | + &mut neighbours, |
| 7071 | - c32 * BLOCK_MI | 7246 | + at, |
| 7072 | - ); | 7247 | + SB, |
| 7248 | + TxbSet::Luma64, | ||
| 7249 | + TxbSet::Chroma32, | ||
| 7250 | + TX32, | ||
| 7251 | + TX32, | ||
| 7252 | + (&scan32, &scan32), | ||
| 7253 | + false, | ||
| 7254 | + &mut y, | ||
| 7255 | + &mut u, | ||
| 7256 | + &mut v, | ||
| 7257 | + base_q_idx, | ||
| 7258 | + enable_filter_intra, | ||
| 7259 | + allow_screen_content_tools, | ||
| 7260 | + allow_intrabc, | ||
| 7261 | + &scan32, | ||
| 7262 | + &scan16, | ||
| 7263 | + &scan8, | ||
| 7264 | + &scan4, | ||
| 7265 | + tx_select, | ||
| 7266 | + reduced_tx_set, | ||
| 7267 | + )?; | ||
| 7268 | + } | ||
| 7269 | + PARTITION_SPLIT => { | ||
| 7270 | + for q in 0..4 { | ||
| 7271 | + let (r32, c32) = (sb_r * 2 + q / 2, sb_c * 2 + q % 2); | ||
| 7272 | + if r32 >= rows32 || c32 >= cols32 { | ||
| 7273 | + continue; | ||
| 7073 | } | 7274 | } |
| 7074 | - p | 7275 | + let at32 = (r32 as usize * 2, c32 as usize * 2); |
| 7075 | - } else { | 7276 | + let ctx32 = neighbours.partition_ctx(at32, BLOCK); |
| 7076 | - match (has_cols32, has_rows32) { | 7277 | + let (has_cols32, has_rows32) = ( |
| 7077 | - (true, false) => { | 7278 | + has_half(c32 * BLOCK_MI, BLOCK_MI, mi_cols), |
| 7078 | - dec.symbol_fixed(&gather( | 7279 | + has_half(r32 * BLOCK_MI, BLOCK_MI, mi_rows), |
| 7079 | - &cdfs.partition_w32[ctx32], | 7280 | + ); |
| 7080 | - VERT_ALIKE, | 7281 | + let part32 = if has_cols32 && has_rows32 { |
| 7081 | - )); | 7282 | + let p = dec.symbol(&mut cdfs.partition_w32[ctx32]); |
| 7082 | - } | 7283 | + if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 7083 | - (false, true) => { | 7284 | + let (rng, _) = dec.debug_state(); |
| 7084 | - dec.symbol_fixed(&gather( | 7285 | + eprintln!( |
| 7085 | - &cdfs.partition_w32[ctx32], | 7286 | + "TRACE partition_w32 mi=({},{}) ctx={ctx32} value={p} rng={rng}", |
| 7086 | - HORZ_ALIKE, | 7287 | + r32 * BLOCK_MI, |
| 7087 | - )); | 7288 | + c32 * BLOCK_MI |
| 7289 | + ); | ||
| 7088 | } | 7290 | } |
| 7089 | - _ => {} | 7291 | + p |
| 7090 | - } | 7292 | + } else { |
| 7091 | - PARTITION_SPLIT | 7293 | + match (has_cols32, has_rows32) { |
| 7092 | - }; | 7294 | + (true, false) => { |
| 7093 | - match part32 { | 7295 | + dec.symbol_fixed(&gather( |
| 7094 | - PARTITION_NONE => { | 7296 | + &cdfs.partition_w32[ctx32], |
| 7095 | - decode_block( | 7297 | + VERT_ALIKE, |
| 7096 | - &mut dec, | 7298 | + )); |
| 7097 | - &mut cdfs, | ||
| 7098 | - &mut neighbours, | ||
| 7099 | - at32, | ||
| 7100 | - BLOCK, | ||
| 7101 | - TxbSet::Luma32, | ||
| 7102 | - TxbSet::Chroma16, | ||
| 7103 | - TX32, | ||
| 7104 | - TX16, | ||
| 7105 | - (&scan32, &scan16), | ||
| 7106 | - true, | ||
| 7107 | - &mut y, | ||
| 7108 | - &mut u, | ||
| 7109 | - &mut v, | ||
| 7110 | - base_q_idx, | ||
| 7111 | - enable_filter_intra, | ||
| 7112 | - allow_screen_content_tools, | ||
| 7113 | - allow_intrabc, | ||
| 7114 | - &scan32, | ||
| 7115 | - &scan16, | ||
| 7116 | - &scan8, | ||
| 7117 | - &scan4, | ||
| 7118 | - tx_select, | ||
| 7119 | - reduced_tx_set, | ||
| 7120 | - )?; | ||
| 7121 | - } | ||
| 7122 | - PARTITION_SPLIT => { | ||
| 7123 | - for sub in 0..4 { | ||
| 7124 | - let (sr, sc) = | ||
| 7125 | - (r32 as usize * 2 + sub / 2, c32 as usize * 2 + sub % 2); | ||
| 7126 | - if (sr as u32) * SUB_MI >= mi_rows | ||
| 7127 | - || (sc as u32) * SUB_MI >= mi_cols | ||
| 7128 | - { | ||
| 7129 | - continue; | ||
| 7130 | } | 7299 | } |
| 7131 | - let (has_cols16, has_rows16) = ( | 7300 | + (false, true) => { |
| 7132 | - has_half(sc as u32 * SUB_MI, SUB_MI, mi_cols), | 7301 | + dec.symbol_fixed(&gather( |
| 7133 | - has_half(sr as u32 * SUB_MI, SUB_MI, mi_rows), | 7302 | + &cdfs.partition_w32[ctx32], |
| 7134 | - ); | 7303 | + HORZ_ALIKE, |
| 7135 | - let at16 = (sr, sc); | 7304 | + )); |
| 7136 | - let ctx16 = neighbours.partition_ctx(at16, SUB); | 7305 | + } |
| 7137 | - if has_cols16 && has_rows16 { | 7306 | + _ => {} |
| 7138 | - let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]); | 7307 | + } |
| 7139 | - if std::env::var_os("EC_AV1_TRACE").is_some() { | 7308 | + PARTITION_SPLIT |
| 7140 | - eprintln!( | 7309 | + }; |
| 7141 | - "TRACE partition_w16 mi=({},{}) ctx={ctx16} value={part16}", | 7310 | + match part32 { |
| 7142 | - at16.0, at16.1 | 7311 | + PARTITION_NONE => { |
| 7143 | - ); | 7312 | + decode_block( |
| 7313 | + &mut dec, | ||
| 7314 | + &mut cdfs, | ||
| 7315 | + &mut neighbours, | ||
| 7316 | + at32, | ||
| 7317 | + BLOCK, | ||
| 7318 | + TxbSet::Luma32, | ||
| 7319 | + TxbSet::Chroma16, | ||
| 7320 | + TX32, | ||
| 7321 | + TX16, | ||
| 7322 | + (&scan32, &scan16), | ||
| 7323 | + true, | ||
| 7324 | + &mut y, | ||
| 7325 | + &mut u, | ||
| 7326 | + &mut v, | ||
| 7327 | + base_q_idx, | ||
| 7328 | + enable_filter_intra, | ||
| 7329 | + allow_screen_content_tools, | ||
| 7330 | + allow_intrabc, | ||
| 7331 | + &scan32, | ||
| 7332 | + &scan16, | ||
| 7333 | + &scan8, | ||
| 7334 | + &scan4, | ||
| 7335 | + tx_select, | ||
| 7336 | + reduced_tx_set, | ||
| 7337 | + )?; | ||
| 7338 | + } | ||
| 7339 | + PARTITION_SPLIT => { | ||
| 7340 | + for sub in 0..4 { | ||
| 7341 | + let (sr, sc) = ( | ||
| 7342 | + r32 as usize * 2 + sub / 2, | ||
| 7343 | + c32 as usize * 2 + sub % 2, | ||
| 7344 | + ); | ||
| 7345 | + if (sr as u32) * SUB_MI >= mi_rows | ||
| 7346 | + || (sc as u32) * SUB_MI >= mi_cols | ||
| 7347 | + { | ||
| 7348 | + continue; | ||
| 7349 | + } | ||
| 7350 | + let (has_cols16, has_rows16) = ( | ||
| 7351 | + has_half(sc as u32 * SUB_MI, SUB_MI, mi_cols), | ||
| 7352 | + has_half(sr as u32 * SUB_MI, SUB_MI, mi_rows), | ||
| 7353 | + ); | ||
| 7354 | + let at16 = (sr, sc); | ||
| 7355 | + let ctx16 = neighbours.partition_ctx(at16, SUB); | ||
| 7356 | + if has_cols16 && has_rows16 { | ||
| 7357 | + let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]); | ||
| 7358 | + if std::env::var_os("EC_AV1_TRACE").is_some() { | ||
| 7359 | + eprintln!( | ||
| 7360 | + "TRACE partition_w16 mi=({},{}) ctx={ctx16} value={part16}", | ||
| 7361 | + at16.0, at16.1 | ||
| 7362 | + ); | ||
| 7363 | + } | ||
| 7364 | + if part16 == PARTITION_NONE { | ||
| 7365 | + decode_block( | ||
| 7366 | + &mut dec, | ||
| 7367 | + &mut cdfs, | ||
| 7368 | + &mut neighbours, | ||
| 7369 | + at16, | ||
| 7370 | + SUB, | ||
| 7371 | + TxbSet::Luma16, | ||
| 7372 | + TxbSet::Chroma8, | ||
| 7373 | + TX16, | ||
| 7374 | + TX8, | ||
| 7375 | + (&scan16, &scan8), | ||
| 7376 | + true, | ||
| 7377 | + &mut y, | ||
| 7378 | + &mut u, | ||
| 7379 | + &mut v, | ||
| 7380 | + base_q_idx, | ||
| 7381 | + enable_filter_intra, | ||
| 7382 | + allow_screen_content_tools, | ||
| 7383 | + allow_intrabc, | ||
| 7384 | + &scan32, | ||
| 7385 | + &scan16, | ||
| 7386 | + &scan8, | ||
| 7387 | + &scan4, | ||
| 7388 | + tx_select, | ||
| 7389 | + reduced_tx_set, | ||
| 7390 | + )?; | ||
| 7391 | + continue; | ||
| 7392 | + } | ||
| 7393 | + if part16 == PARTITION_VERT_B { | ||
| 7394 | + VERT_B_INTRA_HITS.with(|c| c.set(c.get() + 1)); | ||
| 7395 | + // Left rect: 8x16, real | ||
| 7396 | + // `decode_block_rect`, sat at the | ||
| 7397 | + // 16x16 parent's own origin (no | ||
| 7398 | + // fractional-SUB-grid pixel | ||
| 7399 | + // offset needed -- the plain | ||
| 7400 | + // HORZ/VERT arms this lane's | ||
| 7401 | + // charter named DO need one, | ||
| 7402 | + // since their second half is | ||
| 7403 | + // offset by half the parent; | ||
| 7404 | + // unported, see decode_block_rect's | ||
| 7405 | + // own doc comment). | ||
| 7406 | + decode_block_rect( | ||
| 7407 | + &mut dec, | ||
| 7408 | + &mut cdfs, | ||
| 7409 | + &mut neighbours, | ||
| 7410 | + at16, | ||
| 7411 | + 8, | ||
| 7412 | + 16, | ||
| 7413 | + &mut y, | ||
| 7414 | + &mut u, | ||
| 7415 | + &mut v, | ||
| 7416 | + enable_filter_intra, | ||
| 7417 | + allow_screen_content_tools, | ||
| 7418 | + base_q_idx, | ||
| 7419 | + tx_select, | ||
| 7420 | + )?; | ||
| 7421 | + // Two 8x8 squares stacked on the | ||
| 7422 | + // right, chained through | ||
| 7423 | + // `prev_leaf` exactly like the | ||
| 7424 | + // real (non-straddle) SPLIT path | ||
| 7425 | + // below: the bottom leaf's ABOVE | ||
| 7426 | + // context is the top leaf, not | ||
| 7427 | + // the coarse SUB-grid array (a | ||
| 7428 | + // real block never sat there). | ||
| 7429 | + let (mi_row0, mi_col0) = | ||
| 7430 | + (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | ||
| 7431 | + let top_right = | ||
| 7432 | + (mi_row0 as usize, mi_col0 as usize + 2); | ||
| 7433 | + let bot_right = | ||
| 7434 | + (mi_row0 as usize + 2, mi_col0 as usize + 2); | ||
| 7435 | + let mode_tr = decode_leaf8( | ||
| 7436 | + &mut dec, | ||
| 7437 | + &mut cdfs, | ||
| 7438 | + &mut neighbours, | ||
| 7439 | + at16, | ||
| 7440 | + top_right, | ||
| 7441 | + (&scan8, &scan4), | ||
| 7442 | + None, | ||
| 7443 | + &mut y, | ||
| 7444 | + &mut u, | ||
| 7445 | + &mut v, | ||
| 7446 | + base_q_idx, | ||
| 7447 | + enable_filter_intra, | ||
| 7448 | + allow_screen_content_tools, | ||
| 7449 | + allow_intrabc, | ||
| 7450 | + tx_select, | ||
| 7451 | + reduced_tx_set, | ||
| 7452 | + )?; | ||
| 7453 | + let mode_br = decode_leaf8( | ||
| 7454 | + &mut dec, | ||
| 7455 | + &mut cdfs, | ||
| 7456 | + &mut neighbours, | ||
| 7457 | + at16, | ||
| 7458 | + bot_right, | ||
| 7459 | + (&scan8, &scan4), | ||
| 7460 | + Some((top_right, mode_tr)), | ||
| 7461 | + &mut y, | ||
| 7462 | + &mut u, | ||
| 7463 | + &mut v, | ||
| 7464 | + base_q_idx, | ||
| 7465 | + enable_filter_intra, | ||
| 7466 | + allow_screen_content_tools, | ||
| 7467 | + allow_intrabc, | ||
| 7468 | + tx_select, | ||
| 7469 | + reduced_tx_set, | ||
| 7470 | + )?; | ||
| 7471 | + // `record()`'s above_mode/left_mode | ||
| 7472 | + // write is a no-op at an 8x8 | ||
| 7473 | + // leaf's own side (same gap the | ||
| 7474 | + // real-SPLIT path above patches): | ||
| 7475 | + // force it from the last-decoded | ||
| 7476 | + // (bottom-right) leaf. | ||
| 7477 | + neighbours.above_mode[sc] = mode_br; | ||
| 7478 | + neighbours.left_mode[sr] = mode_br; | ||
| 7479 | + continue; | ||
| 7480 | + } | ||
| 7481 | + if part16 == PARTITION_HORZ { | ||
| 7482 | + HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); | ||
| 7483 | + let (mi_row0, mi_col0) = | ||
| 7484 | + (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | ||
| 7485 | + let top = (mi_row0 as usize, mi_col0 as usize); | ||
| 7486 | + let bot = (mi_row0 as usize + 2, mi_col0 as usize); | ||
| 7487 | + let mode_top = decode_leaf_rect( | ||
| 7488 | + &mut dec, | ||
| 7489 | + &mut cdfs, | ||
| 7490 | + &mut neighbours, | ||
| 7491 | + at16, | ||
| 7492 | + top, | ||
| 7493 | + 16, | ||
| 7494 | + 8, | ||
| 7495 | + None, | ||
| 7496 | + &mut y, | ||
| 7497 | + &mut u, | ||
| 7498 | + &mut v, | ||
| 7499 | + enable_filter_intra, | ||
| 7500 | + allow_screen_content_tools, | ||
| 7501 | + base_q_idx, | ||
| 7502 | + tx_select, | ||
| 7503 | + )?; | ||
| 7504 | + let mode_bot = decode_leaf_rect( | ||
| 7505 | + &mut dec, | ||
| 7506 | + &mut cdfs, | ||
| 7507 | + &mut neighbours, | ||
| 7508 | + at16, | ||
| 7509 | + bot, | ||
| 7510 | + 16, | ||
| 7511 | + 8, | ||
| 7512 | + Some((top, mode_top)), | ||
| 7513 | + &mut y, | ||
| 7514 | + &mut u, | ||
| 7515 | + &mut v, | ||
| 7516 | + enable_filter_intra, | ||
| 7517 | + allow_screen_content_tools, | ||
| 7518 | + base_q_idx, | ||
| 7519 | + tx_select, | ||
| 7520 | + )?; | ||
| 7521 | + neighbours.above_mode[sc] = mode_bot; | ||
| 7522 | + neighbours.left_mode[sr] = mode_bot; | ||
| 7523 | + continue; | ||
| 7524 | + } | ||
| 7525 | + if part16 == PARTITION_VERT { | ||
| 7526 | + HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); | ||
| 7527 | + let (mi_row0, mi_col0) = | ||
| 7528 | + (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | ||
| 7529 | + let left = (mi_row0 as usize, mi_col0 as usize); | ||
| 7530 | + let right = | ||
| 7531 | + (mi_row0 as usize, mi_col0 as usize + 2); | ||
| 7532 | + let mode_left = decode_leaf_rect( | ||
| 7533 | + &mut dec, | ||
| 7534 | + &mut cdfs, | ||
| 7535 | + &mut neighbours, | ||
| 7536 | + at16, | ||
| 7537 | + left, | ||
| 7538 | + 8, | ||
| 7539 | + 16, | ||
| 7540 | + None, | ||
| 7541 | + &mut y, | ||
| 7542 | + &mut u, | ||
| 7543 | + &mut v, | ||
| 7544 | + enable_filter_intra, | ||
| 7545 | + allow_screen_content_tools, | ||
| 7546 | + base_q_idx, | ||
| 7547 | + tx_select, | ||
| 7548 | + )?; | ||
| 7549 | + let mode_right = decode_leaf_rect( | ||
| 7550 | + &mut dec, | ||
| 7551 | + &mut cdfs, | ||
| 7552 | + &mut neighbours, | ||
| 7553 | + at16, | ||
| 7554 | + right, | ||
| 7555 | + 8, | ||
| 7556 | + 16, | ||
| 7557 | + Some((left, mode_left)), | ||
| 7558 | + &mut y, | ||
| 7559 | + &mut u, | ||
| 7560 | + &mut v, | ||
| 7561 | + enable_filter_intra, | ||
| 7562 | + allow_screen_content_tools, | ||
| 7563 | + base_q_idx, | ||
| 7564 | + tx_select, | ||
| 7565 | + )?; | ||
| 7566 | + neighbours.above_mode[sc] = mode_right; | ||
| 7567 | + neighbours.left_mode[sr] = mode_right; | ||
| 7568 | + continue; | ||
| 7569 | + } | ||
| 7570 | + if part16 != PARTITION_SPLIT { | ||
| 7571 | + return Err(unsupported( | ||
| 7572 | + "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)", | ||
| 7573 | + )); | ||
| 7574 | + } | ||
| 7575 | + // A real (non-straddle) SPLIT of a | ||
| 7576 | + // whole 16x16 into four 8x8 leaves -- | ||
| 7577 | + // the same recursion the straddle | ||
| 7578 | + // path below already runs when the | ||
| 7579 | + // true frame edge forces it, just | ||
| 7580 | + // over all four positions instead of | ||
| 7581 | + // the one or two the edge leaves. | ||
| 7582 | + let (mi_row0, mi_col0) = | ||
| 7583 | + (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | ||
| 7584 | + let mut prev_leaf: Option<((usize, usize), usize)> = | ||
| 7585 | + None; | ||
| 7586 | + for i in 0..4 { | ||
| 7587 | + let (mr, mc) = | ||
| 7588 | + (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2); | ||
| 7589 | + let leaf_mi = (mr as usize, mc as usize); | ||
| 7590 | + let leaf_ctx = | ||
| 7591 | + neighbours.partition_ctx_mi(leaf_mi, 8); | ||
| 7592 | + let part8 = | ||
| 7593 | + dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); | ||
| 7594 | + if std::env::var_os("EC_AV1_TRACE").is_some() { | ||
| 7595 | + eprintln!( | ||
| 7596 | + "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}" | ||
| 7597 | + ); | ||
| 7598 | + } | ||
| 7599 | + if part8 != PARTITION_NONE { | ||
| 7600 | + return Err(unsupported( | ||
| 7601 | + "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", | ||
| 7602 | + )); | ||
| 7603 | + } | ||
| 7604 | + let leaf_mode = decode_leaf8( | ||
| 7605 | + &mut dec, | ||
| 7606 | + &mut cdfs, | ||
| 7607 | + &mut neighbours, | ||
| 7608 | + at16, | ||
| 7609 | + leaf_mi, | ||
| 7610 | + (&scan8, &scan4), | ||
| 7611 | + prev_leaf, | ||
| 7612 | + &mut y, | ||
| 7613 | + &mut u, | ||
| 7614 | + &mut v, | ||
| 7615 | + base_q_idx, | ||
| 7616 | + enable_filter_intra, | ||
| 7617 | + allow_screen_content_tools, | ||
| 7618 | + allow_intrabc, | ||
| 7619 | + tx_select, | ||
| 7620 | + reduced_tx_set, | ||
| 7621 | + )?; | ||
| 7622 | + prev_leaf = Some((leaf_mi, leaf_mode)); | ||
| 7623 | + } | ||
| 7624 | + if let Some((_, mode)) = prev_leaf { | ||
| 7625 | + neighbours.above_mode[sc] = mode; | ||
| 7626 | + neighbours.left_mode[sr] = mode; | ||
| 7627 | + } | ||
| 7628 | + continue; | ||
| 7629 | + } | ||
| 7630 | + // The true edge falls inside this 16x16 | ||
| 7631 | + // leaf itself (mod-32==8 target sizes, | ||
| 7632 | + // lane-av1-rect): one axis only -- an 8x8 | ||
| 7633 | + // leaf never itself straddles, so the | ||
| 7634 | + // block splits cleanly along whichever | ||
| 7635 | + // axis is short. | ||
| 7636 | + if !has_cols16 && !has_rows16 { | ||
| 7637 | + return Err(unsupported( | ||
| 7638 | + "a 16x16 block whose true edge cuts through both \ | ||
| 7639 | + axes needs a rectangular transform this decoder \ | ||
| 7640 | + does not code yet", | ||
| 7641 | + )); | ||
| 7642 | + } | ||
| 7643 | + if has_cols16 { | ||
| 7644 | + dec.symbol_fixed(&gather( | ||
| 7645 | + &cdfs.partition_w16[ctx16], | ||
| 7646 | + VERT_ALIKE, | ||
| 7647 | + )); | ||
| 7648 | + } else { | ||
| 7649 | + dec.symbol_fixed(&gather( | ||
| 7650 | + &cdfs.partition_w16[ctx16], | ||
| 7651 | + HORZ_ALIKE, | ||
| 7652 | + )); | ||
| 7144 | } | 7653 | } |
| 7145 | - if part16 == PARTITION_NONE { | 7654 | + let (mi_row0, mi_col0) = |
| 7146 | - decode_block( | 7655 | + (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 7656 | + let leaf_positions: Vec<(u32, u32)> = (0..4) | ||
| 7657 | + .map(|i| (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2)) | ||
| 7658 | + .filter(|&(mr, mc)| mr < mi_rows && mc < mi_cols) | ||
| 7659 | + .collect(); | ||
| 7660 | + let mut prev_leaf: Option<((usize, usize), usize)> = None; | ||
| 7661 | + for (mr, mc) in leaf_positions { | ||
| 7662 | + let leaf_mi = (mr as usize, mc as usize); | ||
| 7663 | + let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); | ||
| 7664 | + let part8 = | ||
| 7665 | + dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); | ||
| 7666 | + if std::env::var_os("EC_AV1_TRACE").is_some() { | ||
| 7667 | + eprintln!( | ||
| 7668 | + "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}" | ||
| 7669 | + ); | ||
| 7670 | + } | ||
| 7671 | + if part8 != PARTITION_NONE { | ||
| 7672 | + return Err(unsupported( | ||
| 7673 | + "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", | ||
| 7674 | + )); | ||
| 7675 | + } | ||
| 7676 | + let leaf_mode = decode_leaf8( | ||
| 7147 | &mut dec, | 7677 | &mut dec, |
| 7148 | &mut cdfs, | 7678 | &mut cdfs, |
| 7149 | &mut neighbours, | 7679 | &mut neighbours, |
| 7150 | at16, | 7680 | at16, |
| 7151 | - SUB, | 7681 | + leaf_mi, |
| 7152 | - TxbSet::Luma16, | 7682 | + (&scan8, &scan4), |
| 7153 | - TxbSet::Chroma8, | 7683 | + prev_leaf, |
| 7154 | - TX16, | ||
| 7155 | - TX8, | ||
| 7156 | - (&scan16, &scan8), | ||
| 7157 | - true, | ||
| 7158 | &mut y, | 7684 | &mut y, |
| 7159 | &mut u, | 7685 | &mut u, |
| 7160 | &mut v, | 7686 | &mut v, |
| @@ -7162,499 +7688,192 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 7162 | enable_filter_intra, | 7688 | enable_filter_intra, |
| 7163 | allow_screen_content_tools, | 7689 | allow_screen_content_tools, |
| 7164 | allow_intrabc, | 7690 | allow_intrabc, |
| 7165 | - &scan32, | ||
| 7166 | - &scan16, | ||
| 7167 | - &scan8, | ||
| 7168 | - &scan4, | ||
| 7169 | tx_select, | 7691 | tx_select, |
| 7170 | reduced_tx_set, | 7692 | reduced_tx_set, |
| 7171 | )?; | 7693 | )?; |
| 7172 | - continue; | 7694 | + prev_leaf = Some((leaf_mi, leaf_mode)); |
| 7173 | - } | ||
| 7174 | - if part16 == PARTITION_VERT_B { | ||
| 7175 | - VERT_B_INTRA_HITS.with(|c| c.set(c.get() + 1)); | ||
| 7176 | - // Left rect: 8x16, real | ||
| 7177 | - // `decode_block_rect`, sat at the | ||
| 7178 | - // 16x16 parent's own origin (no | ||
| 7179 | - // fractional-SUB-grid pixel | ||
| 7180 | - // offset needed -- the plain | ||
| 7181 | - // HORZ/VERT arms this lane's | ||
| 7182 | - // charter named DO need one, | ||
| 7183 | - // since their second half is | ||
| 7184 | - // offset by half the parent; | ||
| 7185 | - // unported, see decode_block_rect's | ||
| 7186 | - // own doc comment). | ||
| 7187 | - decode_block_rect( | ||
| 7188 | - &mut dec, | ||
| 7189 | - &mut cdfs, | ||
| 7190 | - &mut neighbours, | ||
| 7191 | - at16, | ||
| 7192 | - 8, | ||
| 7193 | - 16, | ||
| 7194 | - &mut y, | ||
| 7195 | - &mut u, | ||
| 7196 | - &mut v, | ||
| 7197 | - enable_filter_intra, | ||
| 7198 | - allow_screen_content_tools, | ||
| 7199 | - base_q_idx, | ||
| 7200 | - tx_select, | ||
| 7201 | - )?; | ||
| 7202 | - // Two 8x8 squares stacked on the | ||
| 7203 | - // right, chained through | ||
| 7204 | - // `prev_leaf` exactly like the | ||
| 7205 | - // real (non-straddle) SPLIT path | ||
| 7206 | - // below: the bottom leaf's ABOVE | ||
| 7207 | - // context is the top leaf, not | ||
| 7208 | - // the coarse SUB-grid array (a | ||
| 7209 | - // real block never sat there). | ||
| 7210 | - let (mi_row0, mi_col0) = | ||
| 7211 | - (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | ||
| 7212 | - let top_right = | ||
| 7213 | - (mi_row0 as usize, mi_col0 as usize + 2); | ||
| 7214 | - let bot_right = | ||
| 7215 | - (mi_row0 as usize + 2, mi_col0 as usize + 2); | ||
| 7216 | - let mode_tr = decode_leaf8( | ||
| 7217 | - &mut dec, | ||
| 7218 | - &mut cdfs, | ||
| 7219 | - &mut neighbours, | ||
| 7220 | - at16, | ||
| 7221 | - top_right, | ||
| 7222 | - (&scan8, &scan4), | ||
| 7223 | - None, | ||
| 7224 | - &mut y, | ||
| 7225 | - &mut u, | ||
| 7226 | - &mut v, | ||
| 7227 | - base_q_idx, | ||
| 7228 | - enable_filter_intra, | ||
| 7229 | - allow_screen_content_tools, | ||
| 7230 | - allow_intrabc, | ||
| 7231 | - tx_select, | ||
| 7232 | - reduced_tx_set, | ||
| 7233 | - )?; | ||
| 7234 | - let mode_br = decode_leaf8( | ||
| 7235 | - &mut dec, | ||
| 7236 | - &mut cdfs, | ||
| 7237 | - &mut neighbours, | ||
| 7238 | - at16, | ||
| 7239 | - bot_right, | ||
| 7240 | - (&scan8, &scan4), | ||
| 7241 | - Some((top_right, mode_tr)), | ||
| 7242 | - &mut y, | ||
| 7243 | - &mut u, | ||
| 7244 | - &mut v, | ||
| 7245 | - base_q_idx, | ||
| 7246 | - enable_filter_intra, | ||
| 7247 | - allow_screen_content_tools, | ||
| 7248 | - allow_intrabc, | ||
| 7249 | - tx_select, | ||
| 7250 | - reduced_tx_set, | ||
| 7251 | - )?; | ||
| 7252 | - // `record()`'s above_mode/left_mode | ||
| 7253 | - // write is a no-op at an 8x8 | ||
| 7254 | - // leaf's own side (same gap the | ||
| 7255 | - // real-SPLIT path above patches): | ||
| 7256 | - // force it from the last-decoded | ||
| 7257 | - // (bottom-right) leaf. | ||
| 7258 | - neighbours.above_mode[sc] = mode_br; | ||
| 7259 | - neighbours.left_mode[sr] = mode_br; | ||
| 7260 | - continue; | ||
| 7261 | - } | ||
| 7262 | - if part16 == PARTITION_HORZ { | ||
| 7263 | - HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); | ||
| 7264 | - let (mi_row0, mi_col0) = ( | ||
| 7265 | - sr as u32 * SUB_MI, | ||
| 7266 | - sc as u32 * SUB_MI, | ||
| 7267 | - ); | ||
| 7268 | - let top = (mi_row0 as usize, mi_col0 as usize); | ||
| 7269 | - let bot = (mi_row0 as usize + 2, mi_col0 as usize); | ||
| 7270 | - let mode_top = decode_leaf_rect( | ||
| 7271 | - &mut dec, | ||
| 7272 | - &mut cdfs, | ||
| 7273 | - &mut neighbours, | ||
| 7274 | - at16, | ||
| 7275 | - top, | ||
| 7276 | - 16, | ||
| 7277 | - 8, | ||
| 7278 | - None, | ||
| 7279 | - &mut y, | ||
| 7280 | - &mut u, | ||
| 7281 | - &mut v, | ||
| 7282 | - enable_filter_intra, | ||
| 7283 | - allow_screen_content_tools, | ||
| 7284 | - base_q_idx, | ||
| 7285 | - tx_select, | ||
| 7286 | - )?; | ||
| 7287 | - let mode_bot = decode_leaf_rect( | ||
| 7288 | - &mut dec, | ||
| 7289 | - &mut cdfs, | ||
| 7290 | - &mut neighbours, | ||
| 7291 | - at16, | ||
| 7292 | - bot, | ||
| 7293 | - 16, | ||
| 7294 | - 8, | ||
| 7295 | - Some((top, mode_top)), | ||
| 7296 | - &mut y, | ||
| 7297 | - &mut u, | ||
| 7298 | - &mut v, | ||
| 7299 | - enable_filter_intra, | ||
| 7300 | - allow_screen_content_tools, | ||
| 7301 | - base_q_idx, | ||
| 7302 | - tx_select, | ||
| 7303 | - )?; | ||
| 7304 | - neighbours.above_mode[sc] = mode_bot; | ||
| 7305 | - neighbours.left_mode[sr] = mode_bot; | ||
| 7306 | - continue; | ||
| 7307 | - } | ||
| 7308 | - if part16 == PARTITION_VERT { | ||
| 7309 | - HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1)); | ||
| 7310 | - let (mi_row0, mi_col0) = ( | ||
| 7311 | - sr as u32 * SUB_MI, | ||
| 7312 | - sc as u32 * SUB_MI, | ||
| 7313 | - ); | ||
| 7314 | - let left = (mi_row0 as usize, mi_col0 as usize); | ||
| 7315 | - let right = (mi_row0 as usize, mi_col0 as usize + 2); | ||
| 7316 | - let mode_left = decode_leaf_rect( | ||
| 7317 | - &mut dec, | ||
| 7318 | - &mut cdfs, | ||
| 7319 | - &mut neighbours, | ||
| 7320 | - at16, | ||
| 7321 | - left, | ||
| 7322 | - 8, | ||
| 7323 | - 16, | ||
| 7324 | - None, | ||
| 7325 | - &mut y, | ||
| 7326 | - &mut u, | ||
| 7327 | - &mut v, | ||
| 7328 | - enable_filter_intra, | ||
| 7329 | - allow_screen_content_tools, | ||
| 7330 | - base_q_idx, | ||
| 7331 | - tx_select, | ||
| 7332 | - )?; | ||
| 7333 | - let mode_right = decode_leaf_rect( | ||
| 7334 | - &mut dec, | ||
| 7335 | - &mut cdfs, | ||
| 7336 | - &mut neighbours, | ||
| 7337 | - at16, | ||
| 7338 | - right, | ||
| 7339 | - 8, | ||
| 7340 | - 16, | ||
| 7341 | - Some((left, mode_left)), | ||
| 7342 | - &mut y, | ||
| 7343 | - &mut u, | ||
| 7344 | - &mut v, | ||
| 7345 | - enable_filter_intra, | ||
| 7346 | - allow_screen_content_tools, | ||
| 7347 | - base_q_idx, | ||
| 7348 | - tx_select, | ||
| 7349 | - )?; | ||
| 7350 | - neighbours.above_mode[sc] = mode_right; | ||
| 7351 | - neighbours.left_mode[sr] = mode_right; | ||
| 7352 | - continue; | ||
| 7353 | - } | ||
| 7354 | - if part16 != PARTITION_SPLIT { | ||
| 7355 | - return Err(unsupported( | ||
| 7356 | - "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)", | ||
| 7357 | - )); | ||
| 7358 | - } | ||
| 7359 | - // A real (non-straddle) SPLIT of a | ||
| 7360 | - // whole 16x16 into four 8x8 leaves -- | ||
| 7361 | - // the same recursion the straddle | ||
| 7362 | - // path below already runs when the | ||
| 7363 | - // true frame edge forces it, just | ||
| 7364 | - // over all four positions instead of | ||
| 7365 | - // the one or two the edge leaves. | ||
| 7366 | - let (mi_row0, mi_col0) = | ||
| 7367 | - (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | ||
| 7368 | - let mut prev_leaf: Option<((usize, usize), usize)> = None; | ||
| 7369 | - for i in 0..4 { | ||
| 7370 | - let (mr, mc) = | ||
| 7371 | - (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2); | ||
| 7372 | - let leaf_mi = (mr as usize, mc as usize); | ||
| 7373 | - let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); | ||
| 7374 | - let part8 = | ||
| 7375 | - dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); | ||
| 7376 | - if std::env::var_os("EC_AV1_TRACE").is_some() { | ||
| 7377 | - eprintln!( | ||
| 7378 | - "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}" | ||
| 7379 | - ); | ||
| 7380 | - } | ||
| 7381 | - if part8 != PARTITION_NONE { | ||
| 7382 | - return Err(unsupported( | ||
| 7383 | - "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", | ||
| 7384 | - )); | ||
| 7385 | - } | ||
| 7386 | - let leaf_mode = decode_leaf8( | ||
| 7387 | - &mut dec, | ||
| 7388 | - &mut cdfs, | ||
| 7389 | - &mut neighbours, | ||
| 7390 | - at16, | ||
| 7391 | - leaf_mi, | ||
| 7392 | - (&scan8, &scan4), | ||
| 7393 | - prev_leaf, | ||
| 7394 | - &mut y, | ||
| 7395 | - &mut u, | ||
| 7396 | - &mut v, | ||
| 7397 | - base_q_idx, | ||
| 7398 | - enable_filter_intra, | ||
| 7399 | - allow_screen_content_tools, | ||
| 7400 | - allow_intrabc, | ||
| 7401 | - tx_select, | ||
| 7402 | - reduced_tx_set, | ||
| 7403 | - )?; | ||
| 7404 | - prev_leaf = Some((leaf_mi, leaf_mode)); | ||
| 7405 | } | 7695 | } |
| 7696 | + // `record()`'s `above_mode`/`left_mode` | ||
| 7697 | + // write is a no-op at an 8x8 leaf's own | ||
| 7698 | + // side, so force the write once the whole | ||
| 7699 | + // 16x16 slot's leaves are done, from the | ||
| 7700 | + // last leaf (mirrors the writer's r15 | ||
| 7701 | + // fix). | ||
| 7406 | if let Some((_, mode)) = prev_leaf { | 7702 | if let Some((_, mode)) = prev_leaf { |
| 7407 | neighbours.above_mode[sc] = mode; | 7703 | neighbours.above_mode[sc] = mode; |
| 7408 | neighbours.left_mode[sr] = mode; | 7704 | neighbours.left_mode[sr] = mode; |
| 7409 | } | 7705 | } |
| 7410 | - continue; | ||
| 7411 | - } | ||
| 7412 | - // The true edge falls inside this 16x16 | ||
| 7413 | - // leaf itself (mod-32==8 target sizes, | ||
| 7414 | - // lane-av1-rect): one axis only -- an 8x8 | ||
| 7415 | - // leaf never itself straddles, so the | ||
| 7416 | - // block splits cleanly along whichever | ||
| 7417 | - // axis is short. | ||
| 7418 | - if !has_cols16 && !has_rows16 { | ||
| 7419 | - return Err(unsupported( | ||
| 7420 | - "a 16x16 block whose true edge cuts through both \ | ||
| 7421 | - axes needs a rectangular transform this decoder \ | ||
| 7422 | - does not code yet", | ||
| 7423 | - )); | ||
| 7424 | - } | ||
| 7425 | - if has_cols16 { | ||
| 7426 | - dec.symbol_fixed(&gather( | ||
| 7427 | - &cdfs.partition_w16[ctx16], | ||
| 7428 | - VERT_ALIKE, | ||
| 7429 | - )); | ||
| 7430 | - } else { | ||
| 7431 | - dec.symbol_fixed(&gather( | ||
| 7432 | - &cdfs.partition_w16[ctx16], | ||
| 7433 | - HORZ_ALIKE, | ||
| 7434 | - )); | ||
| 7435 | - } | ||
| 7436 | - let (mi_row0, mi_col0) = | ||
| 7437 | - (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | ||
| 7438 | - let leaf_positions: Vec<(u32, u32)> = (0..4) | ||
| 7439 | - .map(|i| (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2)) | ||
| 7440 | - .filter(|&(mr, mc)| mr < mi_rows && mc < mi_cols) | ||
| 7441 | - .collect(); | ||
| 7442 | - let mut prev_leaf: Option<((usize, usize), usize)> = None; | ||
| 7443 | - for (mr, mc) in leaf_positions { | ||
| 7444 | - let leaf_mi = (mr as usize, mc as usize); | ||
| 7445 | - let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); | ||
| 7446 | - let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); | ||
| 7447 | - if std::env::var_os("EC_AV1_TRACE").is_some() { | ||
| 7448 | - eprintln!( | ||
| 7449 | - "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}" | ||
| 7450 | - ); | ||
| 7451 | - } | ||
| 7452 | - if part8 != PARTITION_NONE { | ||
| 7453 | - return Err(unsupported( | ||
| 7454 | - "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", | ||
| 7455 | - )); | ||
| 7456 | - } | ||
| 7457 | - let leaf_mode = decode_leaf8( | ||
| 7458 | - &mut dec, | ||
| 7459 | - &mut cdfs, | ||
| 7460 | - &mut neighbours, | ||
| 7461 | - at16, | ||
| 7462 | - leaf_mi, | ||
| 7463 | - (&scan8, &scan4), | ||
| 7464 | - prev_leaf, | ||
| 7465 | - &mut y, | ||
| 7466 | - &mut u, | ||
| 7467 | - &mut v, | ||
| 7468 | - base_q_idx, | ||
| 7469 | - enable_filter_intra, | ||
| 7470 | - allow_screen_content_tools, | ||
| 7471 | - allow_intrabc, | ||
| 7472 | - tx_select, | ||
| 7473 | - reduced_tx_set, | ||
| 7474 | - )?; | ||
| 7475 | - prev_leaf = Some((leaf_mi, leaf_mode)); | ||
| 7476 | - } | ||
| 7477 | - // `record()`'s `above_mode`/`left_mode` | ||
| 7478 | - // write is a no-op at an 8x8 leaf's own | ||
| 7479 | - // side, so force the write once the whole | ||
| 7480 | - // 16x16 slot's leaves are done, from the | ||
| 7481 | - // last leaf (mirrors the writer's r15 | ||
| 7482 | - // fix). | ||
| 7483 | - if let Some((_, mode)) = prev_leaf { | ||
| 7484 | - neighbours.above_mode[sc] = mode; | ||
| 7485 | - neighbours.left_mode[sr] = mode; | ||
| 7486 | } | 7706 | } |
| 7487 | } | 7707 | } |
| 7488 | - } | ||
| 7489 | - PARTITION_HORZ => { | ||
| 7490 | - // lane-intradisp r1: two true 32x16 strips. | ||
| 7491 | - decode_block_rect( | ||
| 7492 | - &mut dec, | ||
| 7493 | - &mut cdfs, | ||
| 7494 | - &mut neighbours, | ||
| 7495 | - at32, | ||
| 7496 | - 32, | ||
| 7497 | - 16, | ||
| 7498 | - &mut y, | ||
| 7499 | - &mut u, | ||
| 7500 | - &mut v, | ||
| 7501 | - enable_filter_intra, | ||
crates/ec-av1/src/encode.rsmodified+52 -13
| @@ -1098,7 +1098,10 @@ impl Reach { | |||
| 1098 | return false; | 1098 | return false; |
| 1099 | } | 1099 | } |
| 1100 | let table = HAS_TOP_RIGHT_RECT[usize::from(bw == 16)]; | 1100 | let table = HAS_TOP_RIGHT_RECT[usize::from(bw == 16)]; |
| 1101 | - Self::bit(table, (row * Self::table_stride(bw) + col) % (table.len() * 8)) | 1101 | + Self::bit( |
| 1102 | + table, | ||
| 1103 | + (row * Self::table_stride(bw) + col) % (table.len() * 8), | ||
| 1104 | + ) | ||
| 1102 | } | 1105 | } |
| 1103 | 1106 | ||
| 1104 | fn bottom_left_rect(bw: usize, bh: usize, x: usize, y: usize) -> bool { | 1107 | fn bottom_left_rect(bw: usize, bh: usize, x: usize, y: usize) -> bool { |
| @@ -1110,7 +1113,10 @@ impl Reach { | |||
| 1110 | return false; | 1113 | return false; |
| 1111 | } | 1114 | } |
| 1112 | let table = HAS_BOTTOM_LEFT_RECT[usize::from(bw == 16)]; | 1115 | let table = HAS_BOTTOM_LEFT_RECT[usize::from(bw == 16)]; |
| 1113 | - Self::bit(table, (row * Self::table_stride(bw) + col) % (table.len() * 8)) | 1116 | + Self::bit( |
| 1117 | + table, | ||
| 1118 | + (row * Self::table_stride(bw) + col) % (table.len() * 8), | ||
| 1119 | + ) | ||
| 1114 | } | 1120 | } |
| 1115 | 1121 | ||
| 1116 | /// Neither, which is all a mode that reads no further than its own edges | 1122 | /// Neither, which is all a mode that reads no further than its own edges |
| @@ -3105,8 +3111,14 @@ mod tests { | |||
| 3105 | width, | 3111 | width, |
| 3106 | height, | 3112 | height, |
| 3107 | y: out.stdout[..luma].iter().map(|&v| u16::from(v)).collect(), | 3113 | y: out.stdout[..luma].iter().map(|&v| u16::from(v)).collect(), |
| 3108 | - u: out.stdout[luma..luma + chroma].iter().map(|&v| u16::from(v)).collect(), | 3114 | + u: out.stdout[luma..luma + chroma] |
| 3109 | - v: out.stdout[luma + chroma..].iter().map(|&v| u16::from(v)).collect(), | 3115 | + .iter() |
| 3116 | + .map(|&v| u16::from(v)) | ||
| 3117 | + .collect(), | ||
| 3118 | + v: out.stdout[luma + chroma..] | ||
| 3119 | + .iter() | ||
| 3120 | + .map(|&v| u16::from(v)) | ||
| 3121 | + .collect(), | ||
| 3110 | } | 3122 | } |
| 3111 | } | 3123 | } |
| 3112 | 3124 | ||
| @@ -3676,8 +3688,14 @@ mod tests { | |||
| 3676 | width, | 3688 | width, |
| 3677 | height, | 3689 | height, |
| 3678 | y: out.stdout[..luma].iter().map(|&v| u16::from(v)).collect(), | 3690 | y: out.stdout[..luma].iter().map(|&v| u16::from(v)).collect(), |
| 3679 | - u: out.stdout[luma..luma + chroma].iter().map(|&v| u16::from(v)).collect(), | 3691 | + u: out.stdout[luma..luma + chroma] |
| 3680 | - v: out.stdout[luma + chroma..].iter().map(|&v| u16::from(v)).collect(), | 3692 | + .iter() |
| 3693 | + .map(|&v| u16::from(v)) | ||
| 3694 | + .collect(), | ||
| 3695 | + v: out.stdout[luma + chroma..] | ||
| 3696 | + .iter() | ||
| 3697 | + .map(|&v| u16::from(v)) | ||
| 3698 | + .collect(), | ||
| 3681 | } | 3699 | } |
| 3682 | } | 3700 | } |
| 3683 | 3701 | ||
| @@ -4409,9 +4427,18 @@ mod tests { | |||
| 4409 | Picture { | 4427 | Picture { |
| 4410 | width, | 4428 | width, |
| 4411 | height, | 4429 | height, |
| 4412 | - y: out.stdout[base..base + luma].iter().map(|&v| u16::from(v)).collect(), | 4430 | + y: out.stdout[base..base + luma] |
| 4413 | - u: out.stdout[base + luma..base + luma + chroma].iter().map(|&v| u16::from(v)).collect(), | 4431 | + .iter() |
| 4414 | - v: out.stdout[base + luma + chroma..base + frame_bytes].iter().map(|&v| u16::from(v)).collect(), | 4432 | + .map(|&v| u16::from(v)) |
| 4433 | + .collect(), | ||
| 4434 | + u: out.stdout[base + luma..base + luma + chroma] | ||
| 4435 | + .iter() | ||
| 4436 | + .map(|&v| u16::from(v)) | ||
| 4437 | + .collect(), | ||
| 4438 | + v: out.stdout[base + luma + chroma..base + frame_bytes] | ||
| 4439 | + .iter() | ||
| 4440 | + .map(|&v| u16::from(v)) | ||
| 4441 | + .collect(), | ||
| 4415 | } | 4442 | } |
| 4416 | }) | 4443 | }) |
| 4417 | .collect() | 4444 | .collect() |
| @@ -4751,8 +4778,14 @@ mod tests { | |||
| 4751 | width, | 4778 | width, |
| 4752 | height, | 4779 | height, |
| 4753 | y: bytes[..luma].iter().map(|&v| u16::from(v)).collect(), | 4780 | y: bytes[..luma].iter().map(|&v| u16::from(v)).collect(), |
| 4754 | - u: bytes[luma..luma + chroma].iter().map(|&v| u16::from(v)).collect(), | 4781 | + u: bytes[luma..luma + chroma] |
| 4755 | - v: bytes[luma + chroma..].iter().map(|&v| u16::from(v)).collect(), | 4782 | + .iter() |
| 4783 | + .map(|&v| u16::from(v)) | ||
| 4784 | + .collect(), | ||
| 4785 | + v: bytes[luma + chroma..] | ||
| 4786 | + .iter() | ||
| 4787 | + .map(|&v| u16::from(v)) | ||
| 4788 | + .collect(), | ||
| 4756 | } | 4789 | } |
| 4757 | }) | 4790 | }) |
| 4758 | } | 4791 | } |
| @@ -4878,8 +4911,14 @@ mod tests { | |||
| 4878 | width, | 4911 | width, |
| 4879 | height, | 4912 | height, |
| 4880 | y: bytes[..luma].iter().map(|&v| u16::from(v)).collect(), | 4913 | y: bytes[..luma].iter().map(|&v| u16::from(v)).collect(), |
| 4881 | - u: bytes[luma..luma + chroma].iter().map(|&v| u16::from(v)).collect(), | 4914 | + u: bytes[luma..luma + chroma] |
| 4882 | - v: bytes[luma + chroma..].iter().map(|&v| u16::from(v)).collect(), | 4915 | + .iter() |
| 4916 | + .map(|&v| u16::from(v)) | ||
| 4917 | + .collect(), | ||
| 4918 | + v: bytes[luma + chroma..] | ||
| 4919 | + .iter() | ||
| 4920 | + .map(|&v| u16::from(v)) | ||
| 4921 | + .collect(), | ||
| 4883 | } | 4922 | } |
| 4884 | }) | 4923 | }) |
| 4885 | .collect() | 4924 | .collect() |
crates/ec-av1/src/encoder.rsmodified+8 -2
| @@ -680,8 +680,14 @@ mod tests { | |||
| 680 | width, | 680 | width, |
| 681 | height, | 681 | height, |
| 682 | y: bytes[..luma].iter().map(|&v| u16::from(v)).collect(), | 682 | y: bytes[..luma].iter().map(|&v| u16::from(v)).collect(), |
| 683 | - u: bytes[luma..luma + chroma].iter().map(|&v| u16::from(v)).collect(), | 683 | + u: bytes[luma..luma + chroma] |
| 684 | - v: bytes[luma + chroma..].iter().map(|&v| u16::from(v)).collect(), | 684 | + .iter() |
| 685 | + .map(|&v| u16::from(v)) | ||
| 686 | + .collect(), | ||
| 687 | + v: bytes[luma + chroma..] | ||
| 688 | + .iter() | ||
| 689 | + .map(|&v| u16::from(v)) | ||
| 690 | + .collect(), | ||
| 685 | } | 691 | } |
| 686 | }) | 692 | }) |
| 687 | .collect(), | 693 | .collect(), |
crates/ec-av1/src/gate_coverage.rsmodified+28 -9
| @@ -32,9 +32,10 @@ | |||
| 32 | /// Each entry is `(flag, why)`. Removing an entry is how a lane records that | 32 | /// Each entry is `(flag, why)`. Removing an entry is how a lane records that |
| 33 | /// its tool is now covered by a real stream. | 33 | /// its tool is now covered by a real stream. |
| 34 | #[cfg(test)] | 34 | #[cfg(test)] |
| 35 | -const NEVER_EXERCISED: &[(&str, &str)] = &[ | 35 | +const NEVER_EXERCISED: &[(&str, &str)] = &[( |
| 36 | - ("enable-intrabc", "intra block copy syntax is consumed but no block is reconstructed from it"), | 36 | + "enable-intrabc", |
| 37 | -]; | 37 | + "intra block copy syntax is consumed but no block is reconstructed from it", |
| 38 | +)]; | ||
| 38 | 39 | ||
| 39 | #[cfg(test)] | 40 | #[cfg(test)] |
| 40 | mod tests { | 41 | mod tests { |
| @@ -51,7 +52,11 @@ mod tests { | |||
| 51 | .split("\n #[") | 52 | .split("\n #[") |
| 52 | .filter(|body| body.contains("\"--passes=1\"")) | 53 | .filter(|body| body.contains("\"--passes=1\"")) |
| 53 | .collect(); | 54 | .collect(); |
| 54 | - assert!(gates.len() >= 20, "expected the real-aomenc gates, found {}", gates.len()); | 55 | + assert!( |
| 56 | + gates.len() >= 20, | ||
| 57 | + "expected the real-aomenc gates, found {}", | ||
| 58 | + gates.len() | ||
| 59 | + ); | ||
| 55 | 60 | ||
| 56 | let mut per_tool: BTreeMap<String, (usize, usize, usize)> = BTreeMap::new(); | 61 | let mut per_tool: BTreeMap<String, (usize, usize, usize)> = BTreeMap::new(); |
| 57 | let mut names: BTreeSet<String> = BTreeSet::new(); | 62 | let mut names: BTreeSet<String> = BTreeSet::new(); |
| @@ -61,8 +66,12 @@ mod tests { | |||
| 61 | for (i, _) in gate.match_indices("\"--enable-") { | 66 | for (i, _) in gate.match_indices("\"--enable-") { |
| 62 | let rest = &gate[i + 3..]; | 67 | let rest = &gate[i + 3..]; |
| 63 | let Some(end) = rest.find('"') else { continue }; | 68 | let Some(end) = rest.find('"') else { continue }; |
| 64 | - let Some((flag, value)) = rest[..end].split_once('=') else { continue }; | 69 | + let Some((flag, value)) = rest[..end].split_once('=') else { |
| 65 | - let Some(value) = value.chars().next() else { continue }; | 70 | + continue; |
| 71 | + }; | ||
| 72 | + let Some(value) = value.chars().next() else { | ||
| 73 | + continue; | ||
| 74 | + }; | ||
| 66 | names.insert(flag.to_owned()); | 75 | names.insert(flag.to_owned()); |
| 67 | here.insert(flag.to_owned(), value); | 76 | here.insert(flag.to_owned(), value); |
| 68 | } | 77 | } |
| @@ -120,10 +129,20 @@ mod tests { | |||
| 120 | #[test] | 129 | #[test] |
| 121 | fn tool_settings_reads_whole_flags() { | 130 | fn tool_settings_reads_whole_flags() { |
| 122 | let (gate_count, per_tool) = tool_settings(); | 131 | let (gate_count, per_tool) = tool_settings(); |
| 123 | - assert!(per_tool.contains_key("enable-cdef"), "expected --enable-cdef among the gate flags"); | 132 | + assert!( |
| 133 | + per_tool.contains_key("enable-cdef"), | ||
| 134 | + "expected --enable-cdef among the gate flags" | ||
| 135 | + ); | ||
| 124 | for (name, &(off, on, defaulted)) in &per_tool { | 136 | for (name, &(off, on, defaulted)) in &per_tool { |
| 125 | - assert!(!name.is_empty() && !name.contains(['"', '=']), "malformed flag {name:?}"); | 137 | + assert!( |
| 126 | - assert_eq!(off + on + defaulted, gate_count, "{name} counts do not cover every gate"); | 138 | + !name.is_empty() && !name.contains(['"', '=']), |
| 139 | + "malformed flag {name:?}" | ||
| 140 | + ); | ||
| 141 | + assert_eq!( | ||
| 142 | + off + on + defaulted, | ||
| 143 | + gate_count, | ||
| 144 | + "{name} counts do not cover every gate" | ||
| 145 | + ); | ||
| 127 | } | 146 | } |
| 128 | } | 147 | } |
| 129 | } | 148 | } |
crates/ec-av1/src/intra.rsmodified+10 -3
| @@ -768,7 +768,8 @@ pub fn predict_filter_intra( | |||
| 768 | for k in 0..8 { | 768 | for k in 0..8 { |
| 769 | let (r_off, c_off) = (k >> 2, k & 3); | 769 | let (r_off, c_off) = (k >> 2, k & 3); |
| 770 | let pr: i32 = taps[k].iter().zip(&p).map(|(t, s)| t * s).sum(); | 770 | let pr: i32 = taps[k].iter().zip(&p).map(|(t, s)| t * s).sum(); |
| 771 | - let value = round2(pr, FILTER_INTRA_SCALE_BITS).clamp(0, crate::decode::sample_max()); | 771 | + let value = |
| 772 | + round2(pr, FILTER_INTRA_SCALE_BITS).clamp(0, crate::decode::sample_max()); | ||
| 772 | let idx = (r + r_off) * (side + 1) + c + c_off; | 773 | let idx = (r + r_off) * (side + 1) + c + c_off; |
| 773 | buffer[idx] = value; | 774 | buffer[idx] = value; |
| 774 | } | 775 | } |
| @@ -908,7 +909,11 @@ mod tests { | |||
| 908 | let left = fill(reach, 2); | 909 | let left = fill(reach, 2); |
| 909 | let corner = ((bw * 3 + bh * 5) % 256) as u16; | 910 | let corner = ((bw * 3 + bh * 5) % 256) as u16; |
| 910 | 911 | ||
| 911 | - for (name, mode) in [("DC", DC_PRED), ("SMOOTH", SMOOTH_PRED), ("PAETH", PAETH_PRED)] { | 912 | + for (name, mode) in [ |
| 913 | + ("DC", DC_PRED), | ||
| 914 | + ("SMOOTH", SMOOTH_PRED), | ||
| 915 | + ("PAETH", PAETH_PRED), | ||
| 916 | + ] { | ||
| 912 | let mut dst = vec![0u16; bw * bh]; | 917 | let mut dst = vec![0u16; bw * bh]; |
| 913 | predict( | 918 | predict( |
| 914 | mode, | 919 | mode, |
| @@ -953,7 +958,9 @@ mod tests { | |||
| 953 | let got = checksum(&dst); | 958 | let got = checksum(&dst); |
| 954 | let key = ("DR", bw, bh, angle, i32::from(ef), i32::from(sn)); | 959 | let key = ("DR", bw, bh, angle, i32::from(ef), i32::from(sn)); |
| 955 | let want = *expected.get(&key).unwrap_or_else(|| { | 960 | let want = *expected.get(&key).unwrap_or_else(|| { |
| 956 | - panic!("missing DR {bw}x{bh} angle={angle} ef={ef} sn={sn} in the C dump") | 961 | + panic!( |
| 962 | + "missing DR {bw}x{bh} angle={angle} ef={ef} sn={sn} in the C dump" | ||
| 963 | + ) | ||
| 957 | }); | 964 | }); |
| 958 | assert_eq!( | 965 | assert_eq!( |
| 959 | got, want, | 966 | got, want, |
crates/ec-av1/src/lib.rsmodified+1 -1
| @@ -33,8 +33,8 @@ pub mod quant; | |||
| 33 | mod refusal_inventory; | 33 | mod refusal_inventory; |
| 34 | mod restoration; | 34 | mod restoration; |
| 35 | pub mod sequence; | 35 | pub mod sequence; |
| 36 | -mod superres; | ||
| 37 | pub mod stream; | 36 | pub mod stream; |
| 37 | +mod superres; | ||
| 38 | pub mod tile; | 38 | pub mod tile; |
| 39 | pub mod transform; | 39 | pub mod transform; |
| 40 | mod warp; | 40 | mod warp; |
crates/ec-av1/src/mc.rsmodified+6 -3
| @@ -403,7 +403,8 @@ pub fn predict_with_filters( | |||
| 403 | for (t, &tap) in v_filter.iter().enumerate() { | 403 | for (t, &tap) in v_filter.iter().enumerate() { |
| 404 | sum += tap * intermediate[(row + t) * block_w + col]; | 404 | sum += tap * intermediate[(row + t) * block_w + col]; |
| 405 | } | 405 | } |
| 406 | - dst[row * block_w + col] = round2(sum, INTER_ROUND_1).clamp(0, crate::decode::sample_max()) as u16; | 406 | + dst[row * block_w + col] = |
| 407 | + round2(sum, INTER_ROUND_1).clamp(0, crate::decode::sample_max()) as u16; | ||
| 407 | } | 408 | } |
| 408 | } | 409 | } |
| 409 | 410 | ||
| @@ -656,7 +657,8 @@ pub fn combine_compound( | |||
| 656 | assert_eq!(dst.len(), pred0.len(), "the destination is the block"); | 657 | assert_eq!(dst.len(), pred0.len(), "the destination is the block"); |
| 657 | for i in 0..dst.len() { | 658 | for i in 0..dst.len() { |
| 658 | let sum = pred0[i] * fwd_weight + pred1[i] * bck_weight; | 659 | let sum = pred0[i] * fwd_weight + pred1[i] * bck_weight; |
| 659 | - dst[i] = round2(sum, INTER_POST_ROUND + DIST_PRECISION_BITS).clamp(0, crate::decode::sample_max()) as u16; | 660 | + dst[i] = round2(sum, INTER_POST_ROUND + DIST_PRECISION_BITS) |
| 661 | + .clamp(0, crate::decode::sample_max()) as u16; | ||
| 660 | } | 662 | } |
| 661 | } | 663 | } |
| 662 | 664 | ||
| @@ -719,7 +721,8 @@ pub fn blend_masked_compound( | |||
| 719 | i32::from(mask[i * mask_stride + j]) | 721 | i32::from(mask[i * mask_stride + j]) |
| 720 | }; | 722 | }; |
| 721 | let res = (m * pred0[i * w + j] + (64 - m) * pred1[i * w + j]) >> 6; | 723 | let res = (m * pred0[i * w + j] + (64 - m) * pred1[i * w + j]) >> 6; |
| 722 | - dst[i * w + j] = round2(res, INTER_POST_ROUND).clamp(0, crate::decode::sample_max()) as u16; | 724 | + dst[i * w + j] = |
| 725 | + round2(res, INTER_POST_ROUND).clamp(0, crate::decode::sample_max()) as u16; | ||
| 723 | } | 726 | } |
| 724 | } | 727 | } |
| 725 | } | 728 | } |
crates/ec-av1/src/motion.rsmodified+8 -1
| @@ -273,7 +273,14 @@ fn search_traced_from_step( | |||
| 273 | let x_q4 = (block_x as i32) * 16 + mv.1 * Q4_PER_Q3; | 273 | let x_q4 = (block_x as i32) * 16 + mv.1 * Q4_PER_Q3; |
| 274 | let y_q4 = (block_y as i32) * 16 + mv.0 * Q4_PER_Q3; | 274 | let y_q4 = (block_y as i32) * 16 + mv.0 * Q4_PER_Q3; |
| 275 | predict( | 275 | predict( |
| 276 | - &reference16, stride, ref_width, ref_height, x_q4, y_q4, block_w, block_h, | 276 | + &reference16, |
| 277 | + stride, | ||
| 278 | + ref_width, | ||
| 279 | + ref_height, | ||
| 280 | + x_q4, | ||
| 281 | + y_q4, | ||
| 282 | + block_w, | ||
| 283 | + block_h, | ||
| 277 | &mut dst16, | 284 | &mut dst16, |
| 278 | ); | 285 | ); |
| 279 | let sad: f64 = source | 286 | let sad: f64 = source |
crates/ec-av1/src/mvstack.rsmodified+118 -16
| @@ -1235,8 +1235,16 @@ fn scan_row_compound( | |||
| 1235 | found = true; | 1235 | found = true; |
| 1236 | add_compound_candidate( | 1236 | add_compound_candidate( |
| 1237 | candidates, | 1237 | candidates, |
| 1238 | - if info.is_global_mv0 { gm_mv(gm, ref_frame.0) } else { info.mv }, | 1238 | + if info.is_global_mv0 { |
| 1239 | - if info.is_global_mv1 { gm_mv(gm, ref_frame.1) } else { info.mv1.unwrap_or((0, 0)) }, | 1239 | + gm_mv(gm, ref_frame.0) |
| 1240 | + } else { | ||
| 1241 | + info.mv | ||
| 1242 | + }, | ||
| 1243 | + if info.is_global_mv1 { | ||
| 1244 | + gm_mv(gm, ref_frame.1) | ||
| 1245 | + } else { | ||
| 1246 | + info.mv1.unwrap_or((0, 0)) | ||
| 1247 | + }, | ||
| 1240 | len as u32 * weight, | 1248 | len as u32 * weight, |
| 1241 | ); | 1249 | ); |
| 1242 | *newmv_count += u32::from(info.is_new_mv); | 1250 | *newmv_count += u32::from(info.is_new_mv); |
| @@ -1292,8 +1300,16 @@ fn scan_col_compound( | |||
| 1292 | found = true; | 1300 | found = true; |
| 1293 | add_compound_candidate( | 1301 | add_compound_candidate( |
| 1294 | candidates, | 1302 | candidates, |
| 1295 | - if info.is_global_mv0 { gm_mv(gm, ref_frame.0) } else { info.mv }, | 1303 | + if info.is_global_mv0 { |
| 1296 | - if info.is_global_mv1 { gm_mv(gm, ref_frame.1) } else { info.mv1.unwrap_or((0, 0)) }, | 1304 | + gm_mv(gm, ref_frame.0) |
| 1305 | + } else { | ||
| 1306 | + info.mv | ||
| 1307 | + }, | ||
| 1308 | + if info.is_global_mv1 { | ||
| 1309 | + gm_mv(gm, ref_frame.1) | ||
| 1310 | + } else { | ||
| 1311 | + info.mv1.unwrap_or((0, 0)) | ||
| 1312 | + }, | ||
| 1297 | len as u32 * weight, | 1313 | len as u32 * weight, |
| 1298 | ); | 1314 | ); |
| 1299 | *newmv_count += u32::from(info.is_new_mv); | 1315 | *newmv_count += u32::from(info.is_new_mv); |
| @@ -1326,8 +1342,16 @@ fn scan_top_right_compound( | |||
| 1326 | { | 1342 | { |
| 1327 | add_compound_candidate( | 1343 | add_compound_candidate( |
| 1328 | candidates, | 1344 | candidates, |
| 1329 | - if info.is_global_mv0 { gm_mv(gm, ref_frame.0) } else { info.mv }, | 1345 | + if info.is_global_mv0 { |
| 1330 | - if info.is_global_mv1 { gm_mv(gm, ref_frame.1) } else { info.mv1.unwrap_or((0, 0)) }, | 1346 | + gm_mv(gm, ref_frame.0) |
| 1347 | + } else { | ||
| 1348 | + info.mv | ||
| 1349 | + }, | ||
| 1350 | + if info.is_global_mv1 { | ||
| 1351 | + gm_mv(gm, ref_frame.1) | ||
| 1352 | + } else { | ||
| 1353 | + info.mv1.unwrap_or((0, 0)) | ||
| 1354 | + }, | ||
| 1331 | CORNER_WEIGHT, | 1355 | CORNER_WEIGHT, |
| 1332 | ); | 1356 | ); |
| 1333 | *newmv_count += u32::from(info.is_new_mv); | 1357 | *newmv_count += u32::from(info.is_new_mv); |
| @@ -1356,8 +1380,16 @@ fn scan_corner_compound( | |||
| 1356 | { | 1380 | { |
| 1357 | add_compound_candidate( | 1381 | add_compound_candidate( |
| 1358 | candidates, | 1382 | candidates, |
| 1359 | - if info.is_global_mv0 { gm_mv(gm, ref_frame.0) } else { info.mv }, | 1383 | + if info.is_global_mv0 { |
| 1360 | - if info.is_global_mv1 { gm_mv(gm, ref_frame.1) } else { info.mv1.unwrap_or((0, 0)) }, | 1384 | + gm_mv(gm, ref_frame.0) |
| 1385 | + } else { | ||
| 1386 | + info.mv | ||
| 1387 | + }, | ||
| 1388 | + if info.is_global_mv1 { | ||
| 1389 | + gm_mv(gm, ref_frame.1) | ||
| 1390 | + } else { | ||
| 1391 | + info.mv1.unwrap_or((0, 0)) | ||
| 1392 | + }, | ||
| 1361 | CORNER_WEIGHT, | 1393 | CORNER_WEIGHT, |
| 1362 | ); | 1394 | ); |
| 1363 | *newmv_count += u32::from(info.is_new_mv); | 1395 | *newmv_count += u32::from(info.is_new_mv); |
| @@ -1876,8 +1908,16 @@ fn ref_ctx( | |||
| 1876 | b_set: &[i8], | 1908 | b_set: &[i8], |
| 1877 | ) -> usize { | 1909 | ) -> usize { |
| 1878 | let refs = [above0, above1, left0, left1]; | 1910 | let refs = [above0, above1, left0, left1]; |
| 1879 | - let a = refs.into_iter().flatten().filter(|r| a_set.contains(r)).count(); | 1911 | + let a = refs |
| 1880 | - let b = refs.into_iter().flatten().filter(|r| b_set.contains(r)).count(); | 1912 | + .into_iter() |
| 1913 | + .flatten() | ||
| 1914 | + .filter(|r| a_set.contains(r)) | ||
| 1915 | + .count(); | ||
| 1916 | + let b = refs | ||
| 1917 | + .into_iter() | ||
| 1918 | + .flatten() | ||
| 1919 | + .filter(|r| b_set.contains(r)) | ||
| 1920 | + .count(); | ||
| 1881 | match a.cmp(&b) { | 1921 | match a.cmp(&b) { |
| 1882 | std::cmp::Ordering::Less => 0, | 1922 | std::cmp::Ordering::Less => 0, |
| 1883 | std::cmp::Ordering::Equal => 1, | 1923 | std::cmp::Ordering::Equal => 1, |
| @@ -1953,7 +1993,14 @@ pub(crate) fn single_ref_p5_ctx( | |||
| 1953 | left0: Option<i8>, | 1993 | left0: Option<i8>, |
| 1954 | left1: Option<i8>, | 1994 | left1: Option<i8>, |
| 1955 | ) -> usize { | 1995 | ) -> usize { |
| 1956 | - ref_ctx(above0, above1, left0, left1, &[LAST3_FRAME], &[GOLDEN_FRAME]) | 1996 | + ref_ctx( |
| 1997 | + above0, | ||
| 1998 | + above1, | ||
| 1999 | + left0, | ||
| 2000 | + left1, | ||
| 2001 | + &[LAST3_FRAME], | ||
| 2002 | + &[GOLDEN_FRAME], | ||
| 2003 | + ) | ||
| 1957 | } | 2004 | } |
| 1958 | 2005 | ||
| 1959 | /// `av1_get_pred_context_single_ref_p6` | 2006 | /// `av1_get_pred_context_single_ref_p6` |
| @@ -1964,7 +2011,14 @@ pub(crate) fn single_ref_p6_ctx( | |||
| 1964 | left0: Option<i8>, | 2011 | left0: Option<i8>, |
| 1965 | left1: Option<i8>, | 2012 | left1: Option<i8>, |
| 1966 | ) -> usize { | 2013 | ) -> usize { |
| 1967 | - ref_ctx(above0, above1, left0, left1, &[BWDREF_FRAME], &[ALTREF2_FRAME]) | 2014 | + ref_ctx( |
| 2015 | + above0, | ||
| 2016 | + above1, | ||
| 2017 | + left0, | ||
| 2018 | + left1, | ||
| 2019 | + &[BWDREF_FRAME], | ||
| 2020 | + &[ALTREF2_FRAME], | ||
| 2021 | + ) | ||
| 1968 | } | 2022 | } |
| 1969 | 2023 | ||
| 1970 | /// `av1_get_pred_context_uni_comp_ref_p1`: `LAST2` vs. `LAST3`/`GOLDEN`, | 2024 | /// `av1_get_pred_context_uni_comp_ref_p1`: `LAST2` vs. `LAST3`/`GOLDEN`, |
| @@ -2658,7 +2712,19 @@ mod tests { | |||
| 2658 | let (mv0, mv1) = ((2, 2), (-6, 3)); | 2712 | let (mv0, mv1) = ((2, 2), (-6, 3)); |
| 2659 | grid.set(2, 1, comp_inter(mv0, mv1)); | 2713 | grid.set(2, 1, comp_inter(mv0, mv1)); |
| 2660 | 2714 | ||
| 2661 | - let stack = find_mv_stack_compound(&grid, 2, 2, 2, 2, COMP_PAIR, 8, 8, &NO_SIGN_BIAS, &NO_GM_MV, None); | 2715 | + let stack = find_mv_stack_compound( |
| 2716 | + &grid, | ||
| 2717 | + 2, | ||
| 2718 | + 2, | ||
| 2719 | + 2, | ||
| 2720 | + 2, | ||
| 2721 | + COMP_PAIR, | ||
| 2722 | + 8, | ||
| 2723 | + 8, | ||
| 2724 | + &NO_SIGN_BIAS, | ||
| 2725 | + &NO_GM_MV, | ||
| 2726 | + None, | ||
| 2727 | + ); | ||
| 2662 | 2728 | ||
| 2663 | // The exact-pair immediate scan lands one boosted entry; the | 2729 | // The exact-pair immediate scan lands one boosted entry; the |
| 2664 | // compound extension pass (short stack, len < MAX_MV_REF_CANDIDATES) | 2730 | // compound extension pass (short stack, len < MAX_MV_REF_CANDIDATES) |
| @@ -2682,7 +2748,19 @@ mod tests { | |||
| 2682 | grid.set(2, 1, comp_inter(mv0, mv1)); | 2748 | grid.set(2, 1, comp_inter(mv0, mv1)); |
| 2683 | grid.set(3, 1, comp_inter(mv0, mv1)); | 2749 | grid.set(3, 1, comp_inter(mv0, mv1)); |
| 2684 | 2750 | ||
| 2685 | - let stack = find_mv_stack_compound(&grid, 2, 2, 2, 2, COMP_PAIR, 8, 8, &NO_SIGN_BIAS, &NO_GM_MV, None); | 2751 | + let stack = find_mv_stack_compound( |
| 2752 | + &grid, | ||
| 2753 | + 2, | ||
| 2754 | + 2, | ||
| 2755 | + 2, | ||
| 2756 | + 2, | ||
| 2757 | + COMP_PAIR, | ||
| 2758 | + 8, | ||
| 2759 | + 8, | ||
| 2760 | + &NO_SIGN_BIAS, | ||
| 2761 | + &NO_GM_MV, | ||
| 2762 | + None, | ||
| 2763 | + ); | ||
| 2686 | 2764 | ||
| 2687 | // Exact libaom `is_dup` port: with exactly one entry already in the | 2765 | // Exact libaom `is_dup` port: with exactly one entry already in the |
| 2688 | // stack (the four identical-pair neighbours deduped by the | 2766 | // stack (the four identical-pair neighbours deduped by the |
| @@ -2714,7 +2792,19 @@ mod tests { | |||
| 2714 | grid.set(4, 2, comp_inter(left.0, left.1)); | 2792 | grid.set(4, 2, comp_inter(left.0, left.1)); |
| 2715 | grid.set(5, 2, comp_inter(left.0, left.1)); | 2793 | grid.set(5, 2, comp_inter(left.0, left.1)); |
| 2716 | 2794 | ||
| 2717 | - let stack = find_mv_stack_compound(&grid, 3, 3, 2, 3, COMP_PAIR, 8, 8, &NO_SIGN_BIAS, &NO_GM_MV, None); | 2795 | + let stack = find_mv_stack_compound( |
| 2796 | + &grid, | ||
| 2797 | + 3, | ||
| 2798 | + 3, | ||
| 2799 | + 2, | ||
| 2800 | + 3, | ||
| 2801 | + COMP_PAIR, | ||
| 2802 | + 8, | ||
| 2803 | + 8, | ||
| 2804 | + &NO_SIGN_BIAS, | ||
| 2805 | + &NO_GM_MV, | ||
| 2806 | + None, | ||
| 2807 | + ); | ||
| 2718 | 2808 | ||
| 2719 | assert_eq!(stack.entries.len(), 2); | 2809 | assert_eq!(stack.entries.len(), 2); |
| 2720 | assert_eq!(stack.entries[0].mv0, left.0); | 2810 | assert_eq!(stack.entries[0].mv0, left.0); |
| @@ -2803,7 +2893,19 @@ mod tests { | |||
| 2803 | }, | 2893 | }, |
| 2804 | ); | 2894 | ); |
| 2805 | 2895 | ||
| 2806 | - let stack = find_mv_stack_compound(&grid, 2, 2, 2, 2, COMP_PAIR, 8, 8, &NO_SIGN_BIAS, &NO_GM_MV, None); | 2896 | + let stack = find_mv_stack_compound( |
| 2897 | + &grid, | ||
| 2898 | + 2, | ||
| 2899 | + 2, | ||
| 2900 | + 2, | ||
| 2901 | + 2, | ||
| 2902 | + COMP_PAIR, | ||
| 2903 | + 8, | ||
| 2904 | + 8, | ||
| 2905 | + &NO_SIGN_BIAS, | ||
| 2906 | + &NO_GM_MV, | ||
| 2907 | + None, | ||
| 2908 | + ); | ||
| 2807 | 2909 | ||
| 2808 | // The combine step (libaom's real "Handle compound reference frame | 2910 | // The combine step (libaom's real "Handle compound reference frame |
| 2809 | // extension") zips each side's ref_id-then-ref_diff lists | 2911 | // extension") zips each side's ref_id-then-ref_diff lists |
crates/ec-av1/src/quant.rsmodified+9 -1
| @@ -225,7 +225,15 @@ pub fn dequant(levels: &[i32], side: usize, bit_depth: u8, q_idx: i32) -> Vec<i3 | |||
| 225 | /// [`dequant`] widened to `(w, h)` (lane-recttx), threading the same | 225 | /// [`dequant`] widened to `(w, h)` (lane-recttx), threading the same |
| 226 | /// [`QuantDeltas`]-shaped `dc_delta`/`ac_delta` pair as [`dequant_coeff_wh`]. | 226 | /// [`QuantDeltas`]-shaped `dc_delta`/`ac_delta` pair as [`dequant_coeff_wh`]. |
| 227 | #[allow(clippy::too_many_arguments)] | 227 | #[allow(clippy::too_many_arguments)] |
| 228 | -pub fn dequant_wh(levels: &[i32], w: usize, h: usize, bit_depth: u8, q_idx: i32, dc_delta: i32, ac_delta: i32) -> Vec<i32> { | 228 | +pub fn dequant_wh( |
| 229 | + levels: &[i32], | ||
| 230 | + w: usize, | ||
| 231 | + h: usize, | ||
| 232 | + bit_depth: u8, | ||
| 233 | + q_idx: i32, | ||
| 234 | + dc_delta: i32, | ||
| 235 | + ac_delta: i32, | ||
| 236 | +) -> Vec<i32> { | ||
| 229 | levels | 237 | levels |
| 230 | .iter() | 238 | .iter() |
| 231 | .enumerate() | 239 | .enumerate() |
crates/ec-av1/src/refusal_inventory.rsmodified+18 -5
| @@ -64,7 +64,8 @@ const REFUSALS: &[&str] = &[ | |||
| 64 | "a reference picture whose height does not match this frame's own true size", | 64 | "a reference picture whose height does not match this frame's own true size", |
| 65 | "a show_existing_frame header naming an empty reference slot", | 65 | "a show_existing_frame header naming an empty reference slot", |
| 66 | "an 8x8 leaf that coded WARPED_CAUSAL (motion_mode == 2): av1_find_projection/the affine warp filter are not ported, only motion_mode_allowed's alphabet choice is", | 66 | "an 8x8 leaf that coded WARPED_CAUSAL (motion_mode == 2): av1_find_projection/the affine warp filter are not ported, only motion_mode_allowed's alphabet choice is", |
| 67 | - "an inter frame using TxMode::Select (this decoder's inter path never reads a tx_depth symbol, so it desyncs after the first block's mode)", | 67 | + "an inter var-tx tree with a leaf transform larger than 32x32", |
| 68 | + "an intra block in an inter frame whose tx_depth splits its luma transform (round 1)", | ||
| 68 | "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)", | 69 | "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)", |
| 69 | "an inter frame with no key frame before it", | 70 | "an inter frame with no key frame before it", |
| 70 | "an inter SB-level partition type other than SPLIT (this decoder's inter tile path only recurses a superblock as SPLIT)", | 71 | "an inter SB-level partition type other than SPLIT (this decoder's inter tile path only recurses a superblock as SPLIT)", |
| @@ -178,7 +179,11 @@ mod tests { | |||
| 178 | .chain(REFUSALS) | 179 | .chain(REFUSALS) |
| 179 | .map(|&s| s.to_owned()) | 180 | .map(|&s| s.to_owned()) |
| 180 | .collect(); | 181 | .collect(); |
| 181 | - assert!(found.len() >= 30, "the refusal scan found only {} reasons -- it is broken, not the decoder", found.len()); | 182 | + assert!( |
| 183 | + found.len() >= 30, | ||
| 184 | + "the refusal scan found only {} reasons -- it is broken, not the decoder", | ||
| 185 | + found.len() | ||
| 186 | + ); | ||
| 182 | 187 | ||
| 183 | let added: Vec<&String> = found.difference(&listed).collect(); | 188 | let added: Vec<&String> = found.difference(&listed).collect(); |
| 184 | assert!( | 189 | assert!( |
| @@ -224,9 +229,14 @@ mod tests { | |||
| 224 | let mut found: BTreeSet<String> = BTreeSet::new(); | 229 | let mut found: BTreeSet<String> = BTreeSet::new(); |
| 225 | for (i, _) in src.match_indices("\"SKIP ") { | 230 | for (i, _) in src.match_indices("\"SKIP ") { |
| 226 | let rest = &src[i + "\"SKIP ".len()..]; | 231 | let rest = &src[i + "\"SKIP ".len()..]; |
| 227 | - let Some(colon) = rest.find(':') else { continue }; | 232 | + let Some(colon) = rest.find(':') else { |
| 233 | + continue; | ||
| 234 | + }; | ||
| 228 | let name = &rest[..colon]; | 235 | let name = &rest[..colon]; |
| 229 | - if !name.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') { | 236 | + if !name |
| 237 | + .chars() | ||
| 238 | + .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') | ||
| 239 | + { | ||
| 230 | continue; | 240 | continue; |
| 231 | } | 241 | } |
| 232 | // The tail of the message says what was skipped. Only "{e}" -- the | 242 | // The tail of the message says what was skipped. Only "{e}" -- the |
| @@ -239,7 +249,10 @@ mod tests { | |||
| 239 | } | 249 | } |
| 240 | } | 250 | } |
| 241 | let listed: BTreeSet<&str> = GATES_THAT_SKIP_ON_A_DECODE_ERROR.iter().copied().collect(); | 251 | let listed: BTreeSet<&str> = GATES_THAT_SKIP_ON_A_DECODE_ERROR.iter().copied().collect(); |
| 242 | - let added: Vec<&String> = found.iter().filter(|n| !listed.contains(n.as_str())).collect(); | 252 | + let added: Vec<&String> = found |
| 253 | + .iter() | ||
| 254 | + .filter(|n| !listed.contains(n.as_str())) | ||
| 255 | + .collect(); | ||
| 243 | assert!( | 256 | assert!( |
| 244 | added.is_empty(), | 257 | added.is_empty(), |
| 245 | "these gates turn a decode error into a printed SKIP and are not declared: \ | 258 | "these gates turn a decode error into a printed SKIP and are not declared: \ |
crates/ec-av1/src/restoration.rsmodified+130 -48
| @@ -62,7 +62,12 @@ fn inverse_recenter(r: u32, v: u32) -> u32 { | |||
| 62 | /// `aom_read_primitive_refsubexpfin` (`inv_recenter_finite_nonneg` composed | 62 | /// `aom_read_primitive_refsubexpfin` (`inv_recenter_finite_nonneg` composed |
| 63 | /// with `read_primitive_subexpfin`): a value in `[0, n)` recentred around | 63 | /// with `read_primitive_subexpfin`): a value in `[0, n)` recentred around |
| 64 | /// `reference`. | 64 | /// `reference`. |
| 65 | -fn decode_unsigned_subexp_with_ref_msac(dec: &mut SymbolDecoder, n: u32, k: u32, reference: u32) -> u32 { | 65 | +fn decode_unsigned_subexp_with_ref_msac( |
| 66 | + dec: &mut SymbolDecoder, | ||
| 67 | + n: u32, | ||
| 68 | + k: u32, | ||
| 69 | + reference: u32, | ||
| 70 | +) -> u32 { | ||
| 66 | let v = decode_subexp_msac(dec, n, k); | 71 | let v = decode_subexp_msac(dec, n, k); |
| 67 | if (reference << 1) <= n { | 72 | if (reference << 1) <= n { |
| 68 | inverse_recenter(reference, v) | 73 | inverse_recenter(reference, v) |
| @@ -73,7 +78,13 @@ fn decode_unsigned_subexp_with_ref_msac(dec: &mut SymbolDecoder, n: u32, k: u32, | |||
| 73 | 78 | ||
| 74 | /// Signed wrapper, matching the way `read_wiener_filter`/`read_sgrproj_filter` | 79 | /// Signed wrapper, matching the way `read_wiener_filter`/`read_sgrproj_filter` |
| 75 | /// call `aom_read_primitive_refsubexpfin(rb, max-min+1, k, ref-min)+min`. | 80 | /// call `aom_read_primitive_refsubexpfin(rb, max-min+1, k, ref-min)+min`. |
| 76 | -fn decode_signed_subexp_with_ref_msac(dec: &mut SymbolDecoder, low: i32, high: i32, k: u32, reference: i32) -> i32 { | 81 | +fn decode_signed_subexp_with_ref_msac( |
| 82 | + dec: &mut SymbolDecoder, | ||
| 83 | + low: i32, | ||
| 84 | + high: i32, | ||
| 85 | + k: u32, | ||
| 86 | + reference: i32, | ||
| 87 | +) -> i32 { | ||
| 77 | let n = (high - low) as u32; | 88 | let n = (high - low) as u32; |
| 78 | let r = (reference - low).clamp(0, n as i32) as u32; | 89 | let r = (reference - low).clamp(0, n as i32) as u32; |
| 79 | decode_unsigned_subexp_with_ref_msac(dec, n, k, r) as i32 + low | 90 | decode_unsigned_subexp_with_ref_msac(dec, n, k, r) as i32 + low |
| @@ -138,7 +149,11 @@ fn read_wiener_direction(dec: &mut SymbolDecoder, chroma: bool, reference: &[i32 | |||
| 138 | 149 | ||
| 139 | /// `read_wiener_filter` (decodeframe.c ~1595): both directions, updating | 150 | /// `read_wiener_filter` (decodeframe.c ~1595): both directions, updating |
| 140 | /// `reference` in place (the running per-plane, per-tile reference state). | 151 | /// `reference` in place (the running per-plane, per-tile reference state). |
| 141 | -fn read_wiener_filter(dec: &mut SymbolDecoder, chroma: bool, reference: &mut WienerInfo) -> WienerInfo { | 152 | +fn read_wiener_filter( |
| 153 | + dec: &mut SymbolDecoder, | ||
| 154 | + chroma: bool, | ||
| 155 | + reference: &mut WienerInfo, | ||
| 156 | +) -> WienerInfo { | ||
| 142 | let vfilter = read_wiener_direction(dec, chroma, &reference.vfilter); | 157 | let vfilter = read_wiener_direction(dec, chroma, &reference.vfilter); |
| 143 | let hfilter = read_wiener_direction(dec, chroma, &reference.hfilter); | 158 | let hfilter = read_wiener_direction(dec, chroma, &reference.hfilter); |
| 144 | let info = WienerInfo { vfilter, hfilter }; | 159 | let info = WienerInfo { vfilter, hfilter }; |
| @@ -539,7 +554,9 @@ fn apply_wiener_stripe( | |||
| 539 | for (t, &tap) in info.hfilter.iter().enumerate() { | 554 | for (t, &tap) in info.hfilter.iter().enumerate() { |
| 540 | let x = col - 3 + t as i64; | 555 | let x = col - 3 + t as i64; |
| 541 | sum += tap as i64 | 556 | sum += tap as i64 |
| 542 | - * lr_sample(cdef, deblocked, stride, plane_w, plane_h, v_start, v_end, row, x) as i64; | 557 | + * lr_sample( |
| 558 | + cdef, deblocked, stride, plane_w, plane_h, v_start, v_end, row, x, | ||
| 559 | + ) as i64; | ||
| 543 | } | 560 | } |
| 544 | // `WIENER_CLAMP_LIMIT(round0=3, bd=8) - 1`. | 561 | // `WIENER_CLAMP_LIMIT(round0=3, bd=8) - 1`. |
| 545 | inter[r * w + c] = round2(sum, 3).clamp(0, 8191) as i32; | 562 | inter[r * w + c] = round2(sum, 3).clamp(0, 8191) as i32; |
| @@ -551,7 +568,8 @@ fn apply_wiener_stripe( | |||
| 551 | for (t, &tap) in info.vfilter.iter().enumerate() { | 568 | for (t, &tap) in info.vfilter.iter().enumerate() { |
| 552 | sum += tap as i64 * inter[(r + t) * w + c] as i64; | 569 | sum += tap as i64 * inter[(r + t) * w + c] as i64; |
| 553 | } | 570 | } |
| 554 | - out[(v_start + r) * stride + h_start + c] = round2(sum, 11).clamp(0, crate::decode::sample_max() as i64) as u16; | 571 | + out[(v_start + r) * stride + h_start + c] = |
| 572 | + round2(sum, 11).clamp(0, crate::decode::sample_max() as i64) as u16; | ||
| 555 | } | 573 | } |
| 556 | } | 574 | } |
| 557 | } | 575 | } |
| @@ -568,31 +586,27 @@ fn apply_wiener_stripe( | |||
| 568 | // `~/.cache/aom-oracle/src/av1/common/restoration.c` to rule out any other | 586 | // `~/.cache/aom-oracle/src/av1/common/restoration.c` to rule out any other |
| 569 | // transcription slip. | 587 | // transcription slip. |
| 570 | const SGR_X_BY_XPLUS1: [i32; 256] = [ | 588 | const SGR_X_BY_XPLUS1: [i32; 256] = [ |
| 571 | - 1, 128, 171, 192, 205, 213, 219, 224, 228, 230, 233, 235, 236, 238, 239, | 589 | + 1, 128, 171, 192, 205, 213, 219, 224, 228, 230, 233, 235, 236, 238, 239, 240, 241, 242, 243, |
| 572 | - 240, 241, 242, 243, 243, 244, 244, 245, 245, 246, 246, 247, 247, 247, 247, | 590 | + 243, 244, 244, 245, 245, 246, 246, 247, 247, 247, 247, 248, 248, 248, 248, 249, 249, 249, 249, |
| 573 | - 248, 248, 248, 248, 249, 249, 249, 249, 249, 250, 250, 250, 250, 250, 250, | 591 | + 249, 250, 250, 250, 250, 250, 250, 250, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 252, |
| 574 | - 250, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 252, 252, 252, 252, | 592 | + 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 253, 253, 253, |
| 575 | - 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 253, 253, | 593 | + 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, |
| 576 | - 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, | 594 | + 253, 253, 253, 253, 253, 253, 253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, |
| 577 | - 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 254, 254, 254, | 595 | + 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, |
| 578 | - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, | 596 | + 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, |
| 579 | - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, | 597 | + 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 255, |
| 580 | - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, | 598 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 581 | - 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, | 599 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 582 | - 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | 600 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 583 | - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | 601 | + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
| 584 | - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | 602 | + 255, 255, 255, 255, 255, 255, 255, 255, 256, |
| 585 | - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
| 586 | - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
| 587 | - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | ||
| 588 | - 256, | ||
| 589 | ]; | 603 | ]; |
| 590 | 604 | ||
| 591 | /// `av1_one_by_x` (`restoration.c`): `round(4096/n)` for `n` in `1..=25` | 605 | /// `av1_one_by_x` (`restoration.c`): `round(4096/n)` for `n` in `1..=25` |
| 592 | /// (`MAX_NELEM`, `(2*MAX_RADIUS+1)^2`), indexed `[n-1]`. | 606 | /// (`MAX_NELEM`, `(2*MAX_RADIUS+1)^2`), indexed `[n-1]`. |
| 593 | const SGR_ONE_BY_X: [i32; 25] = [ | 607 | const SGR_ONE_BY_X: [i32; 25] = [ |
| 594 | - 4096, 2048, 1365, 1024, 819, 683, 585, 512, 455, 410, 372, 341, 315, 293, 273, 256, 241, 228, 216, 205, 195, 186, | 608 | + 4096, 2048, 1365, 1024, 819, 683, 585, 512, 455, 410, 372, 341, 315, 293, 273, 256, 241, 228, |
| 595 | - 178, 171, 164, | 609 | + 216, 205, 195, 186, 178, 171, 164, |
| 596 | ]; | 610 | ]; |
| 597 | 611 | ||
| 598 | const SGRPROJ_MTABLE_BITS: u32 = 20; | 612 | const SGRPROJ_MTABLE_BITS: u32 = 20; |
| @@ -640,8 +654,9 @@ fn compute_ab( | |||
| 640 | let row = v_start as i64 + i + dr as i64; | 654 | let row = v_start as i64 + i + dr as i64; |
| 641 | for dc in -r..=r { | 655 | for dc in -r..=r { |
| 642 | let col = h_start as i64 + j + dc as i64; | 656 | let col = h_start as i64 + j + dc as i64; |
| 643 | - let px = | 657 | + let px = lr_sample( |
| 644 | - lr_sample(cdef, deblocked, stride, plane_w, plane_h, v_start, v_end, row, col) as i64; | 658 | + cdef, deblocked, stride, plane_w, plane_h, v_start, v_end, row, col, |
| 659 | + ) as i64; | ||
| 645 | a += px * px; | 660 | a += px * px; |
| 646 | b += px; | 661 | b += px; |
| 647 | } | 662 | } |
| @@ -697,8 +712,16 @@ fn apply_sgrproj_stripe( | |||
| 697 | let gw = w + 2; | 712 | let gw = w + 2; |
| 698 | let idx = |gi: i64, gj: i64| -> usize { (gi + 1) as usize * gw + (gj + 1) as usize }; | 713 | let idx = |gi: i64, gj: i64| -> usize { (gi + 1) as usize * gw + (gj + 1) as usize }; |
| 699 | 714 | ||
| 700 | - let ab0 = (r0 > 0).then(|| compute_ab(cdef, deblocked, stride, plane_w, plane_h, h_start, v_start, v_end, w, h, r0, s0)); | 715 | + let ab0 = (r0 > 0).then(|| { |
| 701 | - let ab1 = (r1 > 0).then(|| compute_ab(cdef, deblocked, stride, plane_w, plane_h, h_start, v_start, v_end, w, h, r1, s1)); | 716 | + compute_ab( |
| 717 | + cdef, deblocked, stride, plane_w, plane_h, h_start, v_start, v_end, w, h, r0, s0, | ||
| 718 | + ) | ||
| 719 | + }); | ||
| 720 | + let ab1 = (r1 > 0).then(|| { | ||
| 721 | + compute_ab( | ||
| 722 | + cdef, deblocked, stride, plane_w, plane_h, h_start, v_start, v_end, w, h, r1, s1, | ||
| 723 | + ) | ||
| 724 | + }); | ||
| 702 | 725 | ||
| 703 | // r8: call-unique debug dump -- r6's coordinate-only gate (`v_start==60`) | 726 | // r8: call-unique debug dump -- r6's coordinate-only gate (`v_start==60`) |
| 704 | // matched several unrelated calls across the gate's attempt sweep, so its | 727 | // matched several unrelated calls across the gate's attempt sweep, so its |
| @@ -711,7 +734,9 @@ fn apply_sgrproj_stripe( | |||
| 711 | let bytes: Vec<i32> = (59..=61) | 734 | let bytes: Vec<i32> = (59..=61) |
| 712 | .flat_map(|row| { | 735 | .flat_map(|row| { |
| 713 | (5..=7).map(move |col| { | 736 | (5..=7).map(move |col| { |
| 714 | - lr_sample(cdef, deblocked, stride, plane_w, plane_h, v_start, v_end, row, col) | 737 | + lr_sample( |
| 738 | + cdef, deblocked, stride, plane_w, plane_h, v_start, v_end, row, col, | ||
| 739 | + ) | ||
| 715 | }) | 740 | }) |
| 716 | }) | 741 | }) |
| 717 | .collect(); | 742 | .collect(); |
| @@ -788,7 +813,8 @@ fn apply_sgrproj_stripe( | |||
| 788 | let (a_ur, b_ur) = ab[idx(i - 1, j + 1)]; | 813 | let (a_ur, b_ur) = ab[idx(i - 1, j + 1)]; |
| 789 | let (a_dl, b_dl) = ab[idx(i + 1, j - 1)]; | 814 | let (a_dl, b_dl) = ab[idx(i + 1, j - 1)]; |
| 790 | let (a_dr, b_dr) = ab[idx(i + 1, j + 1)]; | 815 | let (a_dr, b_dr) = ab[idx(i + 1, j + 1)]; |
| 791 | - let a = (a_c + a_u + a_d + a_l + a_r) as i64 * 4 + (a_ul + a_ur + a_dl + a_dr) as i64 * 3; | 816 | + let a = (a_c + a_u + a_d + a_l + a_r) as i64 * 4 |
| 817 | + + (a_ul + a_ur + a_dl + a_dr) as i64 * 3; | ||
| 792 | let b = (b_c + b_u + b_d + b_l + b_r) * 4 + (b_ul + b_ur + b_dl + b_dr) * 3; | 818 | let b = (b_c + b_u + b_d + b_l + b_r) * 4 + (b_ul + b_ur + b_dl + b_dr) * 3; |
| 793 | let flt1 = round2(a * dgd + b, SGRPROJ_SGR_BITS + 5 - SGRPROJ_RST_BITS); | 819 | let flt1 = round2(a * dgd + b, SGRPROJ_SGR_BITS + 5 - SGRPROJ_RST_BITS); |
| 794 | v += xq[1] as i64 * (flt1 - u); | 820 | v += xq[1] as i64 * (flt1 - u); |
| @@ -801,13 +827,20 @@ fn apply_sgrproj_stripe( | |||
| 801 | "EC_LR_CALL_DUMP combine: c={:?} u_tap(row60)={:?} d={:?} l={:?} r={:?} \ | 827 | "EC_LR_CALL_DUMP combine: c={:?} u_tap(row60)={:?} d={:?} l={:?} r={:?} \ |
| 802 | ul={:?} ur={:?} dl={:?} dr={:?} dense a={a} b={b} dgd={dgd} \ | 828 | ul={:?} ur={:?} dl={:?} dr={:?} dense a={a} b={b} dgd={dgd} \ |
| 803 | u={u} flt1={flt1} xq={xq:?} v_before_final_round={v}", | 829 | u={u} flt1={flt1} xq={xq:?} v_before_final_round={v}", |
| 804 | - ab[idx(i, j)], ab[idx(i - 1, j)], ab[idx(i + 1, j)], ab[idx(i, j - 1)], | 830 | + ab[idx(i, j)], |
| 805 | - ab[idx(i, j + 1)], ab[idx(i - 1, j - 1)], ab[idx(i - 1, j + 1)], | 831 | + ab[idx(i - 1, j)], |
| 806 | - ab[idx(i + 1, j - 1)], ab[idx(i + 1, j + 1)] | 832 | + ab[idx(i + 1, j)], |
| 833 | + ab[idx(i, j - 1)], | ||
| 834 | + ab[idx(i, j + 1)], | ||
| 835 | + ab[idx(i - 1, j - 1)], | ||
| 836 | + ab[idx(i - 1, j + 1)], | ||
| 837 | + ab[idx(i + 1, j - 1)], | ||
| 838 | + ab[idx(i + 1, j + 1)] | ||
| 807 | ); | 839 | ); |
| 808 | } | 840 | } |
| 809 | } | 841 | } |
| 810 | - let out_v = round2(v, SGRPROJ_PRJ_BITS as u32 + SGRPROJ_RST_BITS).clamp(0, crate::decode::sample_max() as i64) as u16; | 842 | + let out_v = round2(v, SGRPROJ_PRJ_BITS as u32 + SGRPROJ_RST_BITS) |
| 843 | + .clamp(0, crate::decode::sample_max() as i64) as u16; | ||
| 811 | out[(v_start as i64 + i) as usize * stride + (h_start as i64 + j) as usize] = out_v; | 844 | out[(v_start as i64 + i) as usize * stride + (h_start as i64 + j) as usize] = out_v; |
| 812 | } | 845 | } |
| 813 | } | 846 | } |
| @@ -847,10 +880,30 @@ fn filter_restoration_unit( | |||
| 847 | let stripe_v_end = stripe_v_start + h; | 880 | let stripe_v_end = stripe_v_start + h; |
| 848 | match filter { | 881 | match filter { |
| 849 | UnitFilter::Wiener(info) => apply_wiener_stripe( | 882 | UnitFilter::Wiener(info) => apply_wiener_stripe( |
| 850 | - out, cdef, deblocked, stride, plane_w, plane_h, h_start, h_end, stripe_v_start, stripe_v_end, &info, | 883 | + out, |
| 884 | + cdef, | ||
| 885 | + deblocked, | ||
| 886 | + stride, | ||
| 887 | + plane_w, | ||
| 888 | + plane_h, | ||
| 889 | + h_start, | ||
| 890 | + h_end, | ||
| 891 | + stripe_v_start, | ||
| 892 | + stripe_v_end, | ||
| 893 | + &info, | ||
| 851 | ), | 894 | ), |
| 852 | UnitFilter::Sgrproj(info) => apply_sgrproj_stripe( | 895 | UnitFilter::Sgrproj(info) => apply_sgrproj_stripe( |
| 853 | - out, cdef, deblocked, stride, plane_w, plane_h, h_start, h_end, stripe_v_start, stripe_v_end, &info, | 896 | + out, |
| 897 | + cdef, | ||
| 898 | + deblocked, | ||
| 899 | + stride, | ||
| 900 | + plane_w, | ||
| 901 | + plane_h, | ||
| 902 | + h_start, | ||
| 903 | + h_end, | ||
| 904 | + stripe_v_start, | ||
| 905 | + stripe_v_end, | ||
| 906 | + &info, | ||
| 854 | ), | 907 | ), |
| 855 | UnitFilter::None => {} | 908 | UnitFilter::None => {} |
| 856 | } | 909 | } |
| @@ -893,7 +946,11 @@ pub(crate) fn apply_loop_restoration_plane( | |||
| 893 | let mut rrow = 0usize; | 946 | let mut rrow = 0usize; |
| 894 | while y0 < plane_h as u32 { | 947 | while y0 < plane_h as u32 { |
| 895 | let remaining_h = plane_h as u32 - y0; | 948 | let remaining_h = plane_h as u32 - y0; |
| 896 | - let uh = if remaining_h < ext_size { remaining_h } else { unit_size }; | 949 | + let uh = if remaining_h < ext_size { |
| 950 | + remaining_h | ||
| 951 | + } else { | ||
| 952 | + unit_size | ||
| 953 | + }; | ||
| 897 | let v_start = (y0 as i64 - voffset as i64).max(0) as u32; | 954 | let v_start = (y0 as i64 - voffset as i64).max(0) as u32; |
| 898 | let mut v_end = y0 + uh; | 955 | let mut v_end = y0 + uh; |
| 899 | if v_end < plane_h as u32 { | 956 | if v_end < plane_h as u32 { |
| @@ -904,7 +961,11 @@ pub(crate) fn apply_loop_restoration_plane( | |||
| 904 | let mut rcol = 0usize; | 961 | let mut rcol = 0usize; |
| 905 | while x0 < plane_w as u32 { | 962 | while x0 < plane_w as u32 { |
| 906 | let remaining_w = plane_w as u32 - x0; | 963 | let remaining_w = plane_w as u32 - x0; |
| 907 | - let uw = if remaining_w < ext_size { remaining_w } else { unit_size }; | 964 | + let uw = if remaining_w < ext_size { |
| 965 | + remaining_w | ||
| 966 | + } else { | ||
| 967 | + unit_size | ||
| 968 | + }; | ||
| 908 | let filter = grid.get(plane, rrow, rcol); | 969 | let filter = grid.get(plane, rrow, rcol); |
| 909 | if filter != UnitFilter::None { | 970 | if filter != UnitFilter::None { |
| 910 | filter_restoration_unit( | 971 | filter_restoration_unit( |
| @@ -928,7 +989,10 @@ pub(crate) fn apply_loop_restoration_plane( | |||
| 928 | y0 += uh; | 989 | y0 += uh; |
| 929 | rrow += 1; | 990 | rrow += 1; |
| 930 | } | 991 | } |
| 931 | - debug_assert_eq!(rrow, grid.vert_units[plane], "RU row walk must match RestorationGrid::new's count_units"); | 992 | + debug_assert_eq!( |
| 993 | + rrow, grid.vert_units[plane], | ||
| 994 | + "RU row walk must match RestorationGrid::new's count_units" | ||
| 995 | + ); | ||
| 932 | out | 996 | out |
| 933 | } | 997 | } |
| 934 | 998 | ||
| @@ -985,7 +1049,13 @@ mod tests { | |||
| 985 | } | 1049 | } |
| 986 | } | 1050 | } |
| 987 | 1051 | ||
| 988 | - fn write_unsigned_subexp_with_ref(enc: &mut SymbolEncoder, n: u32, k: u32, reference: u32, v: u32) { | 1052 | + fn write_unsigned_subexp_with_ref( |
| 1053 | + enc: &mut SymbolEncoder, | ||
| 1054 | + n: u32, | ||
| 1055 | + k: u32, | ||
| 1056 | + reference: u32, | ||
| 1057 | + v: u32, | ||
| 1058 | + ) { | ||
| 989 | let r = reference.clamp(0, n.saturating_sub(1)); | 1059 | let r = reference.clamp(0, n.saturating_sub(1)); |
| 990 | let coded = if (r << 1) <= n { | 1060 | let coded = if (r << 1) <= n { |
| 991 | recenter(r, v) | 1061 | recenter(r, v) |
| @@ -1001,7 +1071,15 @@ mod tests { | |||
| 1001 | /// `SGRPROJ_PRJ_MAX-MIN+1`. | 1071 | /// `SGRPROJ_PRJ_MAX-MIN+1`. |
| 1002 | #[test] | 1072 | #[test] |
| 1003 | fn subexp_roundtrips_every_value() { | 1073 | fn subexp_roundtrips_every_value() { |
| 1004 | - for &(num_syms, k) in &[(16u32, 1u32), (32, 2), (64, 3), (96, 4), (128, 4), (3, 1), (1, 3)] { | 1074 | + for &(num_syms, k) in &[ |
| 1075 | + (16u32, 1u32), | ||
| 1076 | + (32, 2), | ||
| 1077 | + (64, 3), | ||
| 1078 | + (96, 4), | ||
| 1079 | + (128, 4), | ||
| 1080 | + (3, 1), | ||
| 1081 | + (1, 3), | ||
| 1082 | + ] { | ||
| 1005 | for v in 0..num_syms { | 1083 | for v in 0..num_syms { |
| 1006 | let mut enc = SymbolEncoder::new(); | 1084 | let mut enc = SymbolEncoder::new(); |
| 1007 | write_subexp(&mut enc, num_syms, k, v); | 1085 | write_subexp(&mut enc, num_syms, k, v); |
| @@ -1039,10 +1117,10 @@ mod tests { | |||
| 1039 | #[test] | 1117 | #[test] |
| 1040 | fn signed_subexp_with_ref_roundtrips() { | 1118 | fn signed_subexp_with_ref_roundtrips() { |
| 1041 | let cases: [(i32, i32, u32); 4] = [ | 1119 | let cases: [(i32, i32, u32); 4] = [ |
| 1042 | - (-5, 11, 1), // Wiener tap0 | 1120 | + (-5, 11, 1), // Wiener tap0 |
| 1043 | - (-23, 9, 2), // Wiener tap1 | 1121 | + (-23, 9, 2), // Wiener tap1 |
| 1044 | - (-17, 47, 3), // Wiener tap2 | 1122 | + (-17, 47, 3), // Wiener tap2 |
| 1045 | - (-96, 32, 4), // SGR xqd0 | 1123 | + (-96, 32, 4), // SGR xqd0 |
| 1046 | ]; | 1124 | ]; |
| 1047 | for (low, high, k) in cases { | 1125 | for (low, high, k) in cases { |
| 1048 | let n = (high - low) as u32; | 1126 | let n = (high - low) as u32; |
| @@ -1054,8 +1132,12 @@ mod tests { | |||
| 1054 | write_unsigned_subexp_with_ref(&mut enc, n, k, r, coded_v); | 1132 | write_unsigned_subexp_with_ref(&mut enc, n, k, r, coded_v); |
| 1055 | let payload = enc.finish(); | 1133 | let payload = enc.finish(); |
| 1056 | let mut dec = SymbolDecoder::new(&payload); | 1134 | let mut dec = SymbolDecoder::new(&payload); |
| 1057 | - let got = decode_signed_subexp_with_ref_msac(&mut dec, low, high, k, reference_v); | 1135 | + let got = |
| 1058 | - assert_eq!(got, v, "low={low} high={high} k={k} reference={reference_v} v={v}"); | 1136 | + decode_signed_subexp_with_ref_msac(&mut dec, low, high, k, reference_v); |
| 1137 | + assert_eq!( | ||
| 1138 | + got, v, | ||
| 1139 | + "low={low} high={high} k={k} reference={reference_v} v={v}" | ||
| 1140 | + ); | ||
| 1059 | } | 1141 | } |
| 1060 | } | 1142 | } |
| 1061 | } | 1143 | } |
crates/ec-av1/src/stream.rsmodified+655 -135
| @@ -195,24 +195,13 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 195 | // now read (`maybe_read_cdef_idx` in decode.rs) and threaded into | 195 | // now read (`maybe_read_cdef_idx` in decode.rs) and threaded into |
| 196 | // [`crate::decode::apply_cdef`]'s per-superblock strength lookup, so | 196 | // [`crate::decode::apply_cdef`]'s per-superblock strength lookup, so |
| 197 | // a `cdef_bits > 0` stream no longer needs this refusal. | 197 | // a `cdef_bits > 0` stream no longer needs this refusal. |
| 198 | - // An intra frame's `decode_key_frame_tile*` now reads `tx_depth` | 198 | + // Both frame types now read their transform size under |
| 199 | - // under `TxMode::Select` (lane-av1txsel, spec 5.11.16): the key-frame | 199 | + // `TxMode::Select`: an intra frame's `decode_key_frame_tile*` reads |
| 200 | - // decode path threads `tx_select` through `decode_block`/ | 200 | + // `tx_depth` (lane-av1txsel, spec 5.11.16), and an inter frame's |
| 201 | - // `decode_leaf8`, and refuses on its own (a named `unsupported`, not | 201 | + // `decode_inter_block`/`decode_inter_block8` read the recursive |
| 202 | - // a silent desync) the one case it still cannot code -- a resolved | 202 | + // `txfm_split` var-tx tree (lane-txselect, spec 5.11.17) -- so the |
| 203 | - // 4x4 luma transform, which has no coefficient tables here. This | 203 | + // blanket inter-frame refusal that used to stand here is gone. What |
| 204 | - // refusal is narrowed to what genuinely still has no reader at all: | 204 | + // remains refused is named at its own site in `read_block_tx_size`. |
| 205 | - // `decode_inter_frame`'s inter path never threads `tx_select` | ||
| 206 | - // through its own block loop, so an inter frame under | ||
| 207 | - // `TxMode::Select` still desyncs the same way the comment above used | ||
| 208 | - // to describe for every frame -- lane-av1real r3's | ||
| 209 | - // luma-near-flat-vs-ffmpeg-gradient bug. | ||
| 210 | - if header.tx_mode == TxMode::Select && header.frame_type != FrameType::Key { | ||
| 211 | - return Err(Error::unsupported( | ||
| 212 | - "AV1 decode_stream", | ||
| 213 | - "an inter frame using TxMode::Select (this decoder's inter path never reads a tx_depth symbol, so it desyncs after the first block's mode)", | ||
| 214 | - )); | ||
| 215 | - } | ||
| 216 | // lane-av1real r11's blindness-audit sweep (`read_intra_frame_mode_info`, | 205 | // lane-av1real r11's blindness-audit sweep (`read_intra_frame_mode_info`, |
| 217 | // libaom decodemv.c): three more per-block/per-SB symbols this crate | 206 | // libaom decodemv.c): three more per-block/per-SB symbols this crate |
| 218 | // never reads at all, each gated by a header field this decoder | 207 | // never reads at all, each gated by a header field this decoder |
| @@ -615,6 +604,7 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 615 | header.skip_mode_present, | 604 | header.skip_mode_present, |
| 616 | header.skip_mode_frame, | 605 | header.skip_mode_frame, |
| 617 | header.reduced_tx_set, | 606 | header.reduced_tx_set, |
| 607 | + header.tx_mode == TxMode::Select, | ||
| 618 | header.is_motion_mode_switchable, | 608 | header.is_motion_mode_switchable, |
| 619 | header.allow_warped_motion, | 609 | header.allow_warped_motion, |
| 620 | header.allow_screen_content_tools, | 610 | header.allow_screen_content_tools, |
| @@ -931,9 +921,18 @@ mod tests { | |||
| 931 | Pic { | 921 | Pic { |
| 932 | width, | 922 | width, |
| 933 | height, | 923 | height, |
| 934 | - y: out.stdout[base..base + luma].iter().map(|&v| u16::from(v)).collect(), | 924 | + y: out.stdout[base..base + luma] |
| 935 | - u: out.stdout[base + luma..base + luma + chroma].iter().map(|&v| u16::from(v)).collect(), | 925 | + .iter() |
| 936 | - v: out.stdout[base + luma + chroma..base + frame_bytes].iter().map(|&v| u16::from(v)).collect(), | 926 | + .map(|&v| u16::from(v)) |
| 927 | + .collect(), | ||
| 928 | + u: out.stdout[base + luma..base + luma + chroma] | ||
| 929 | + .iter() | ||
| 930 | + .map(|&v| u16::from(v)) | ||
| 931 | + .collect(), | ||
| 932 | + v: out.stdout[base + luma + chroma..base + frame_bytes] | ||
| 933 | + .iter() | ||
| 934 | + .map(|&v| u16::from(v)) | ||
| 935 | + .collect(), | ||
| 937 | } | 936 | } |
| 938 | }) | 937 | }) |
| 939 | .collect() | 938 | .collect() |
| @@ -952,8 +951,17 @@ mod tests { | |||
| 952 | ) -> Vec<Pic> { | 951 | ) -> Vec<Pic> { |
| 953 | let mut child = Command::new("ffmpeg") | 952 | let mut child = Command::new("ffmpeg") |
| 954 | .args([ | 953 | .args([ |
| 955 | - "-v", "error", "-f", "obu", "-i", "-", "-f", "rawvideo", "-pix_fmt", | 954 | + "-v", |
| 956 | - "yuv420p10le", "-", | 955 | + "error", |
| 956 | + "-f", | ||
| 957 | + "obu", | ||
| 958 | + "-i", | ||
| 959 | + "-", | ||
| 960 | + "-f", | ||
| 961 | + "rawvideo", | ||
| 962 | + "-pix_fmt", | ||
| 963 | + "yuv420p10le", | ||
| 964 | + "-", | ||
| 957 | ]) | 965 | ]) |
| 958 | .stdin(Stdio::piped()) | 966 | .stdin(Stdio::piped()) |
| 959 | .stdout(Stdio::piped()) | 967 | .stdout(Stdio::piped()) |
| @@ -1195,7 +1203,9 @@ mod tests { | |||
| 1195 | hash_color(seed, 2), | 1203 | hash_color(seed, 2), |
| 1196 | hash_color(seed, 3), | 1204 | hash_color(seed, 3), |
| 1197 | ); | 1205 | ); |
| 1198 | - format!("gradients=size={width}x{height}:c0={c0}:c1={c1}:c2={c2}:c3={c3}:seed={seed}:{tail}") | 1206 | + format!( |
| 1207 | + "gradients=size={width}x{height}:c0={c0}:c1={c1}:c2={c2}:c3={c3}:seed={seed}:{tail}" | ||
| 1208 | + ) | ||
| 1199 | } | 1209 | } |
| 1200 | 1210 | ||
| 1201 | /// The determinism guard: same seed twice must byte-match ffmpeg's own | 1211 | /// The determinism guard: same seed twice must byte-match ffmpeg's own |
| @@ -1210,7 +1220,16 @@ mod tests { | |||
| 1210 | fn render_hash(lavfi: &str) -> Vec<u8> { | 1220 | fn render_hash(lavfi: &str) -> Vec<u8> { |
| 1211 | let out = Command::new("ffmpeg") | 1221 | let out = Command::new("ffmpeg") |
| 1212 | .args([ | 1222 | .args([ |
| 1213 | - "-v", "error", "-f", "lavfi", "-i", lavfi, "-frames:v", "1", "-f", "rawvideo", | 1223 | + "-v", |
| 1224 | + "error", | ||
| 1225 | + "-f", | ||
| 1226 | + "lavfi", | ||
| 1227 | + "-i", | ||
| 1228 | + lavfi, | ||
| 1229 | + "-frames:v", | ||
| 1230 | + "1", | ||
| 1231 | + "-f", | ||
| 1232 | + "rawvideo", | ||
| 1214 | "-", | 1233 | "-", |
| 1215 | ]) | 1234 | ]) |
| 1216 | .stdin(Stdio::null()) | 1235 | .stdin(Stdio::null()) |
| @@ -2333,6 +2352,215 @@ mod tests { | |||
| 2333 | ); | 2352 | ); |
| 2334 | } | 2353 | } |
| 2335 | 2354 | ||
| 2355 | + /// lane-txselect's decisive gate: a real aomenc INTER sequence WITHOUT | ||
| 2356 | + /// `--enable-tx-size-search=0`, the flag every other inter recipe in this | ||
| 2357 | + /// file pins off precisely to keep the stream on `TxMode::Largest`. | ||
| 2358 | + /// Dropped, aomenc takes its own default (`TX_MODE_SELECT` -- which is | ||
| 2359 | + /// what both of the user's real films use), and an inter block's | ||
| 2360 | + /// transform size is then the recursive `txfm_split` tree of spec | ||
| 2361 | + /// 5.11.17 rather than one whole-block transform. A stream that decoded | ||
| 2362 | + /// pixel-exact while every `txfm_split` symbol resolved to "no split" | ||
| 2363 | + /// would prove nothing (it is `TxMode::Largest` by another name), so this | ||
| 2364 | + /// gate hard-asserts BOTH counters: at least one `txfm_split` symbol read | ||
| 2365 | + /// AND at least one split actually taken. Exhausting every attempt is a | ||
| 2366 | + /// FAILURE, not a SKIP -- an unfired gate is a vacuous gate. | ||
| 2367 | + #[test] | ||
| 2368 | + fn a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact() { | ||
| 2369 | + if !have_ffmpeg() { | ||
| 2370 | + eprintln!( | ||
| 2371 | + "SKIP a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact: no ffmpeg" | ||
| 2372 | + ); | ||
| 2373 | + return; | ||
| 2374 | + } | ||
| 2375 | + if !have_aomenc() { | ||
| 2376 | + eprintln!( | ||
| 2377 | + "SKIP a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact: no aomenc at {}", | ||
| 2378 | + aomenc_path().display() | ||
| 2379 | + ); | ||
| 2380 | + return; | ||
| 2381 | + } | ||
| 2382 | + let (width, height, frame_count) = (64usize, 64usize, 4usize); | ||
| 2383 | + let mut refusals = Vec::new(); | ||
| 2384 | + for attempt in 0..40u32 { | ||
| 2385 | + let seed = 42 + attempt; | ||
| 2386 | + // Detail is what makes aomenc's RD prefer a split transform; a | ||
| 2387 | + // flat gradient resolves every `txfm_split` to 0. `mandelbrot`'s | ||
| 2388 | + // fractal boundary is the same source the sibling intra tx-select | ||
| 2389 | + // gate uses, at a different `start_scale` per attempt. | ||
| 2390 | + let source = format!( | ||
| 2391 | + "mandelbrot=size=64x64:start_scale={}:rate=25", | ||
| 2392 | + 5.0 - f64::from(attempt) * 0.06 | ||
| 2393 | + ); | ||
| 2394 | + let y4m = Command::new("ffmpeg") | ||
| 2395 | + .args([ | ||
| 2396 | + "-v", | ||
| 2397 | + "error", | ||
| 2398 | + "-f", | ||
| 2399 | + "lavfi", | ||
| 2400 | + "-i", | ||
| 2401 | + &source, | ||
| 2402 | + // Desaturated chroma: `uv_mode` stays DC_PRED, so the | ||
| 2403 | + // still-refused directional-chroma gap never fires and | ||
| 2404 | + // luma detail alone drives the transform split. | ||
| 2405 | + "-vf", | ||
| 2406 | + "hue=s=0", | ||
| 2407 | + "-pix_fmt", | ||
| 2408 | + "yuv420p", | ||
| 2409 | + "-t", | ||
| 2410 | + "0.16", | ||
| 2411 | + "-f", | ||
| 2412 | + "yuv4mpegpipe", | ||
| 2413 | + "-", | ||
| 2414 | + ]) | ||
| 2415 | + .stdin(Stdio::null()) | ||
| 2416 | + .stdout(Stdio::piped()) | ||
| 2417 | + .stderr(Stdio::piped()) | ||
| 2418 | + .output() | ||
| 2419 | + .expect("ffmpeg failed to run"); | ||
| 2420 | + assert!( | ||
| 2421 | + y4m.status.success(), | ||
| 2422 | + "ffmpeg fixture: {}", | ||
| 2423 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 2424 | + ); | ||
| 2425 | + let mut child = Command::new(aomenc_path()) | ||
| 2426 | + .args([ | ||
| 2427 | + "--codec=av1", | ||
| 2428 | + "--passes=1", | ||
| 2429 | + "--end-usage=q", | ||
| 2430 | + "--cq-level=55", | ||
| 2431 | + "--cpu-used=0", | ||
| 2432 | + "--lag-in-frames=0", | ||
| 2433 | + "--auto-alt-ref=0", | ||
| 2434 | + "--kf-max-dist=1000", | ||
| 2435 | + "--threads=1", | ||
| 2436 | + "--row-mt=0", | ||
| 2437 | + "--enable-order-hint=0", | ||
| 2438 | + "--enable-warped-motion=0", | ||
| 2439 | + "--enable-obmc=0", | ||
| 2440 | + "--enable-masked-comp=0", | ||
| 2441 | + "--enable-interintra-comp=0", | ||
| 2442 | + "--enable-dist-wtd-comp=0", | ||
| 2443 | + "--enable-diff-wtd-comp=0", | ||
| 2444 | + "--enable-onesided-comp=0", | ||
| 2445 | + "--enable-interintra-wedge=0", | ||
| 2446 | + "--enable-smooth-interintra=0", | ||
| 2447 | + "--enable-rect-partitions=0", | ||
| 2448 | + "--enable-ab-partitions=0", | ||
| 2449 | + "--enable-1to4-partitions=0", | ||
| 2450 | + "--enable-filter-intra=0", | ||
| 2451 | + "--enable-smooth-intra=0", | ||
| 2452 | + "--enable-paeth-intra=0", | ||
| 2453 | + "--enable-directional-intra=0", | ||
| 2454 | + "--enable-angle-delta=0", | ||
| 2455 | + // DELIBERATELY ABSENT: --enable-tx-size-search=0. | ||
| 2456 | + "--enable-cdef=0", | ||
| 2457 | + "--enable-restoration=0", | ||
| 2458 | + "--max-partition-size=32", | ||
| 2459 | + // Sub-16 inter partitions are a separate named refusal | ||
| 2460 | + // (this decoder codes no inter block below 16x16 through | ||
| 2461 | + // the square path this gate drives), and detailed content | ||
| 2462 | + // makes aomenc's RD reach for them on nearly every seed. | ||
| 2463 | + "--min-partition-size=16", | ||
| 2464 | + "--enable-palette=0", | ||
| 2465 | + "--enable-intrabc=0", | ||
| 2466 | + "--enable-cfl-intra=0", | ||
| 2467 | + "--enable-ref-frame-mvs=0", | ||
| 2468 | + "--obu", | ||
| 2469 | + "-o", | ||
| 2470 | + "-", | ||
| 2471 | + "-", | ||
| 2472 | + ]) | ||
| 2473 | + .stdin(Stdio::piped()) | ||
| 2474 | + .stdout(Stdio::piped()) | ||
| 2475 | + .stderr(Stdio::piped()) | ||
| 2476 | + .spawn() | ||
| 2477 | + .expect("aomenc failed to start"); | ||
| 2478 | + child | ||
| 2479 | + .stdin | ||
| 2480 | + .take() | ||
| 2481 | + .expect("aomenc stdin") | ||
| 2482 | + .write_all(&y4m.stdout) | ||
| 2483 | + .expect("writing y4m to aomenc"); | ||
| 2484 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 2485 | + assert!( | ||
| 2486 | + out.status.success(), | ||
| 2487 | + "aomenc refused the fixture: {}", | ||
| 2488 | + String::from_utf8_lossy(&out.stderr) | ||
| 2489 | + ); | ||
| 2490 | + let stream = out.stdout; | ||
| 2491 | + let (reads_before, hits_before) = | ||
| 2492 | + (decode::txfm_split_reads(), decode::txfm_split_hits()); | ||
| 2493 | + let frames = match decode_stream(&stream) { | ||
| 2494 | + Ok(frames) => frames, | ||
| 2495 | + Err(e) => { | ||
| 2496 | + let msg = e.to_string(); | ||
| 2497 | + assert!( | ||
| 2498 | + msg.contains("unsupported"), | ||
| 2499 | + "tx-select inter decode failed outright (seed {seed}): {msg}" | ||
| 2500 | + ); | ||
| 2501 | + refusals.push(format!("seed {seed}: {msg}")); | ||
| 2502 | + continue; | ||
| 2503 | + } | ||
| 2504 | + }; | ||
| 2505 | + let (reads, hits) = ( | ||
| 2506 | + decode::txfm_split_reads() - reads_before, | ||
| 2507 | + decode::txfm_split_hits() - hits_before, | ||
| 2508 | + ); | ||
| 2509 | + if hits == 0 { | ||
| 2510 | + refusals.push(format!( | ||
| 2511 | + "seed {seed}: decoded, but no block took a txfm_split ({reads} symbols read)" | ||
| 2512 | + )); | ||
| 2513 | + continue; | ||
| 2514 | + } | ||
| 2515 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); | ||
| 2516 | + assert_eq!(frames.len(), frame_count); | ||
| 2517 | + eprintln!("txselect gate seed={seed}: txfm_split reads={reads} splits taken={hits}"); | ||
| 2518 | + // Name the first differing sample before the assert fires: a | ||
| 2519 | + // 64x64 plane's `assert_eq!` output is 4096 numbers, useless for | ||
| 2520 | + // locating a desync. | ||
| 2521 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 2522 | + for (plane, (g, w)) in [ | ||
| 2523 | + ("Y", (&got.y, &want.y)), | ||
| 2524 | + ("U", (&got.u, &want.u)), | ||
| 2525 | + ("V", (&got.v, &want.v)), | ||
| 2526 | + ] { | ||
| 2527 | + let stride = if plane == "Y" { width } else { width / 2 }; | ||
| 2528 | + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | ||
| 2529 | + eprintln!( | ||
| 2530 | + "txselect gate seed={seed}: frame {i} {plane} first diff at \ | ||
| 2531 | + ({}, {}) got {} want {} ({} samples differ)", | ||
| 2532 | + at % stride, | ||
| 2533 | + at / stride, | ||
| 2534 | + g[at], | ||
| 2535 | + w[at], | ||
| 2536 | + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | ||
| 2537 | + ); | ||
| 2538 | + let coords: Vec<String> = g | ||
| 2539 | + .iter() | ||
| 2540 | + .zip(w.iter()) | ||
| 2541 | + .enumerate() | ||
| 2542 | + .filter(|(_, (a, b))| a != b) | ||
| 2543 | + .take(12) | ||
| 2544 | + .map(|(k, (a, b))| format!("({},{})={a}/{b}", k % stride, k / stride)) | ||
| 2545 | + .collect(); | ||
| 2546 | + eprintln!("txselect gate seed={seed}: frame {i} {plane} diffs {coords:?}"); | ||
| 2547 | + } | ||
| 2548 | + } | ||
| 2549 | + } | ||
| 2550 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 2551 | + assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed})"); | ||
| 2552 | + assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})"); | ||
| 2553 | + assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed})"); | ||
| 2554 | + } | ||
| 2555 | + return; | ||
| 2556 | + } | ||
| 2557 | + panic!( | ||
| 2558 | + "a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact never observed a \ | ||
| 2559 | + taken txfm_split:\n{}", | ||
| 2560 | + refusals.join("\n") | ||
| 2561 | + ); | ||
| 2562 | + } | ||
| 2563 | + | ||
| 2336 | /// lane-chroma r2 stage 1: a real aomenc key frame with | 2564 | /// lane-chroma r2 stage 1: a real aomenc key frame with |
| 2337 | /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`) | 2565 | /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`) |
| 2338 | /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still- | 2566 | /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still- |
| @@ -2506,8 +2734,19 @@ mod tests { | |||
| 2506 | ); | 2734 | ); |
| 2507 | let y4m = Command::new("ffmpeg") | 2735 | let y4m = Command::new("ffmpeg") |
| 2508 | .args([ | 2736 | .args([ |
| 2509 | - "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-t", | 2737 | + "-v", |
| 2510 | - "0.04", "-f", "yuv4mpegpipe", "-", | 2738 | + "error", |
| 2739 | + "-f", | ||
| 2740 | + "lavfi", | ||
| 2741 | + "-i", | ||
| 2742 | + &source, | ||
| 2743 | + "-pix_fmt", | ||
| 2744 | + "yuv420p", | ||
| 2745 | + "-t", | ||
| 2746 | + "0.04", | ||
| 2747 | + "-f", | ||
| 2748 | + "yuv4mpegpipe", | ||
| 2749 | + "-", | ||
| 2511 | ]) | 2750 | ]) |
| 2512 | .stdin(Stdio::null()) | 2751 | .stdin(Stdio::null()) |
| 2513 | .stdout(Stdio::piped()) | 2752 | .stdout(Stdio::piped()) |
| @@ -2779,13 +3018,7 @@ mod tests { | |||
| 2779 | let y4m = Command::new("ffmpeg") | 3018 | let y4m = Command::new("ffmpeg") |
| 2780 | .args(["-v", "error", "-f", "lavfi", "-i"]) | 3019 | .args(["-v", "error", "-f", "lavfi", "-i"]) |
| 2781 | .arg(&source) | 3020 | .arg(&source) |
| 2782 | - .args([ | 3021 | + .args(["-pix_fmt", "yuv420p", "-f", "yuv4mpegpipe", "-"]) |
| 2783 | - "-pix_fmt", | ||
| 2784 | - "yuv420p", | ||
| 2785 | - "-f", | ||
| 2786 | - "yuv4mpegpipe", | ||
| 2787 | - "-", | ||
| 2788 | - ]) | ||
| 2789 | .stdin(Stdio::null()) | 3022 | .stdin(Stdio::null()) |
| 2790 | .stdout(Stdio::piped()) | 3023 | .stdout(Stdio::piped()) |
| 2791 | .stderr(Stdio::piped()) | 3024 | .stderr(Stdio::piped()) |
| @@ -2893,7 +3126,10 @@ mod tests { | |||
| 2893 | if !ok { | 3126 | if !ok { |
| 2894 | let pin = std::env::temp_dir().join("ec-av1-deblocking-gate-fail.obu"); | 3127 | let pin = std::env::temp_dir().join("ec-av1-deblocking-gate-fail.obu"); |
| 2895 | let _ = std::fs::write(&pin, &stream); | 3128 | let _ = std::fs::write(&pin, &stream); |
| 2896 | - panic!("frame {i} mismatch vs ffmpeg -- stream pinned at {}", pin.display()); | 3129 | + panic!( |
| 3130 | + "frame {i} mismatch vs ffmpeg -- stream pinned at {}", | ||
| 3131 | + pin.display() | ||
| 3132 | + ); | ||
| 2897 | } | 3133 | } |
| 2898 | } | 3134 | } |
| 2899 | } | 3135 | } |
| @@ -3828,32 +4064,41 @@ mod tests { | |||
| 3828 | .zip(&ffmpeg_frames) | 4064 | .zip(&ffmpeg_frames) |
| 3829 | .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | 4065 | .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); |
| 3830 | if mismatched { | 4066 | if mismatched { |
| 3831 | - let pin = std::env::temp_dir().join("ec-av1-reference-select-gate-fail.obu"); | 4067 | + let pin = |
| 4068 | + std::env::temp_dir().join("ec-av1-reference-select-gate-fail.obu"); | ||
| 3832 | let _ = std::fs::write(&pin, &stream); | 4069 | let _ = std::fs::write(&pin, &stream); |
| 3833 | if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { | 4070 | if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { |
| 3834 | std::fs::write(&path, &stream).expect("writing pinned stream"); | 4071 | std::fs::write(&path, &stream).expect("writing pinned stream"); |
| 3835 | - eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | 4072 | + eprintln!( |
| 4073 | + "EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}" | ||
| 4074 | + ); | ||
| 3836 | } | 4075 | } |
| 3837 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 4076 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 3838 | assert_eq!( | 4077 | assert_eq!( |
| 3839 | - got.y, want.y, | 4078 | + got.y, |
| 4079 | + want.y, | ||
| 3840 | "{NAME} frame {i} luma vs ffmpeg (seed {seed}) -- stream pinned at {}", | 4080 | "{NAME} frame {i} luma vs ffmpeg (seed {seed}) -- stream pinned at {}", |
| 3841 | pin.display() | 4081 | pin.display() |
| 3842 | ); | 4082 | ); |
| 3843 | assert_eq!( | 4083 | assert_eq!( |
| 3844 | - got.u, want.u, | 4084 | + got.u, |
| 4085 | + want.u, | ||
| 3845 | "{NAME} frame {i} U vs ffmpeg (seed {seed}) -- stream pinned at {}", | 4086 | "{NAME} frame {i} U vs ffmpeg (seed {seed}) -- stream pinned at {}", |
| 3846 | pin.display() | 4087 | pin.display() |
| 3847 | ); | 4088 | ); |
| 3848 | assert_eq!( | 4089 | assert_eq!( |
| 3849 | - got.v, want.v, | 4090 | + got.v, |
| 4091 | + want.v, | ||
| 3850 | "{NAME} frame {i} V vs ffmpeg (seed {seed}) -- stream pinned at {}", | 4092 | "{NAME} frame {i} V vs ffmpeg (seed {seed}) -- stream pinned at {}", |
| 3851 | pin.display() | 4093 | pin.display() |
| 3852 | ); | 4094 | ); |
| 3853 | } | 4095 | } |
| 3854 | } else { | 4096 | } else { |
| 3855 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 4097 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 3856 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 4098 | + assert_eq!( |
| 4099 | + got.y, want.y, | ||
| 4100 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 4101 | + ); | ||
| 3857 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 4102 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 3858 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 4103 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 3859 | } | 4104 | } |
| @@ -4024,17 +4269,20 @@ mod tests { | |||
| 4024 | } | 4269 | } |
| 4025 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 4270 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 4026 | assert_eq!( | 4271 | assert_eq!( |
| 4027 | - got.y, want.y, | 4272 | + got.y, |
| 4273 | + want.y, | ||
| 4028 | "{NAME} frame {i} luma vs ffmpeg (seed {seed}) -- stream pinned at {}", | 4274 | "{NAME} frame {i} luma vs ffmpeg (seed {seed}) -- stream pinned at {}", |
| 4029 | pin.display() | 4275 | pin.display() |
| 4030 | ); | 4276 | ); |
| 4031 | assert_eq!( | 4277 | assert_eq!( |
| 4032 | - got.u, want.u, | 4278 | + got.u, |
| 4279 | + want.u, | ||
| 4033 | "{NAME} frame {i} U vs ffmpeg (seed {seed}) -- stream pinned at {}", | 4280 | "{NAME} frame {i} U vs ffmpeg (seed {seed}) -- stream pinned at {}", |
| 4034 | pin.display() | 4281 | pin.display() |
| 4035 | ); | 4282 | ); |
| 4036 | assert_eq!( | 4283 | assert_eq!( |
| 4037 | - got.v, want.v, | 4284 | + got.v, |
| 4285 | + want.v, | ||
| 4038 | "{NAME} frame {i} V vs ffmpeg (seed {seed}) -- stream pinned at {}", | 4286 | "{NAME} frame {i} V vs ffmpeg (seed {seed}) -- stream pinned at {}", |
| 4039 | pin.display() | 4287 | pin.display() |
| 4040 | ); | 4288 | ); |
| @@ -4198,7 +4446,10 @@ mod tests { | |||
| 4198 | } | 4446 | } |
| 4199 | } | 4447 | } |
| 4200 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 4448 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 4201 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 4449 | + assert_eq!( |
| 4450 | + got.y, want.y, | ||
| 4451 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 4452 | + ); | ||
| 4202 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 4453 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 4203 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 4454 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 4204 | } | 4455 | } |
| @@ -4389,7 +4640,10 @@ mod tests { | |||
| 4389 | } | 4640 | } |
| 4390 | } | 4641 | } |
| 4391 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 4642 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 4392 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 4643 | + assert_eq!( |
| 4644 | + got.y, want.y, | ||
| 4645 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 4646 | + ); | ||
| 4393 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 4647 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 4394 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 4648 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 4395 | } | 4649 | } |
| @@ -4555,7 +4809,10 @@ mod tests { | |||
| 4555 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | 4809 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); |
| 4556 | } | 4810 | } |
| 4557 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 4811 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 4558 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 4812 | + assert_eq!( |
| 4813 | + got.y, want.y, | ||
| 4814 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 4815 | + ); | ||
| 4559 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 4816 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 4560 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 4817 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 4561 | } | 4818 | } |
| @@ -4679,8 +4936,7 @@ mod tests { | |||
| 4679 | if let Ok(path) = std::env::var("EC_SUPERRES_STREAM_DUMP") { | 4936 | if let Ok(path) = std::env::var("EC_SUPERRES_STREAM_DUMP") { |
| 4680 | std::fs::write(path, &stream).expect("dump stream"); | 4937 | std::fs::write(path, &stream).expect("dump stream"); |
| 4681 | } | 4938 | } |
| 4682 | - let frames = | 4939 | + let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME} refused: {e}")); |
| 4683 | - decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME} refused: {e}")); | ||
| 4684 | assert_eq!(frames.len(), frame_count); | 4940 | assert_eq!(frames.len(), frame_count); |
| 4685 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); | 4941 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); |
| 4686 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 4942 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| @@ -4825,8 +5081,7 @@ mod tests { | |||
| 4825 | if let Ok(path) = std::env::var("EC_SUPERRES_INTER_STREAM_DUMP") { | 5081 | if let Ok(path) = std::env::var("EC_SUPERRES_INTER_STREAM_DUMP") { |
| 4826 | std::fs::write(&path, &stream).expect("dump stream"); | 5082 | std::fs::write(&path, &stream).expect("dump stream"); |
| 4827 | } | 5083 | } |
| 4828 | - let frames = | 5084 | + let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME} refused: {e}")); |
| 4829 | - decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME} refused: {e}")); | ||
| 4830 | assert_eq!(frames.len(), frame_count); | 5085 | assert_eq!(frames.len(), frame_count); |
| 4831 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); | 5086 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); |
| 4832 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 5087 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| @@ -5004,7 +5259,10 @@ mod tests { | |||
| 5004 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | 5259 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); |
| 5005 | } | 5260 | } |
| 5006 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 5261 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 5007 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 5262 | + assert_eq!( |
| 5263 | + got.y, want.y, | ||
| 5264 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 5265 | + ); | ||
| 5008 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 5266 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 5009 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 5267 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 5010 | } | 5268 | } |
| @@ -5184,7 +5442,10 @@ mod tests { | |||
| 5184 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | 5442 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); |
| 5185 | } | 5443 | } |
| 5186 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 5444 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 5187 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 5445 | + assert_eq!( |
| 5446 | + got.y, want.y, | ||
| 5447 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 5448 | + ); | ||
| 5188 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 5449 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 5189 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 5450 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 5190 | } | 5451 | } |
| @@ -5505,7 +5766,10 @@ mod tests { | |||
| 5505 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | 5766 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); |
| 5506 | } | 5767 | } |
| 5507 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 5768 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 5508 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 5769 | + assert_eq!( |
| 5770 | + got.y, want.y, | ||
| 5771 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 5772 | + ); | ||
| 5509 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 5773 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 5510 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 5774 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 5511 | } | 5775 | } |
| @@ -5706,7 +5970,10 @@ mod tests { | |||
| 5706 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); | 5970 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); |
| 5707 | assert_eq!(frames.len(), frame_count); | 5971 | assert_eq!(frames.len(), frame_count); |
| 5708 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 5972 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 5709 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 5973 | + assert_eq!( |
| 5974 | + got.y, want.y, | ||
| 5975 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 5976 | + ); | ||
| 5710 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 5977 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 5711 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 5978 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 5712 | } | 5979 | } |
| @@ -5912,7 +6179,10 @@ mod tests { | |||
| 5912 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | 6179 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); |
| 5913 | } | 6180 | } |
| 5914 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 6181 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 5915 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 6182 | + assert_eq!( |
| 6183 | + got.y, want.y, | ||
| 6184 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 6185 | + ); | ||
| 5916 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 6186 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 5917 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 6187 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 5918 | } | 6188 | } |
| @@ -5953,7 +6223,6 @@ mod tests { | |||
| 5953 | ); | 6223 | ); |
| 5954 | } | 6224 | } |
| 5955 | 6225 | ||
| 5956 | - | ||
| 5957 | /// lane-lr r3: proves stage 1/2's exit criterion -- a real | 6226 | /// lane-lr r3: proves stage 1/2's exit criterion -- a real |
| 5958 | /// `--enable-restoration=1` aomenc stream must survive the whole | 6227 | /// `--enable-restoration=1` aomenc stream must survive the whole |
| 5959 | /// partition walk (every symbol read entropy-exact) and land on the | 6228 | /// partition walk (every symbol read entropy-exact) and land on the |
| @@ -6082,9 +6351,18 @@ mod tests { | |||
| 6082 | ); | 6351 | ); |
| 6083 | } | 6352 | } |
| 6084 | for (i, (pic, refpic)) in pics.iter().zip(reference.iter()).enumerate() { | 6353 | for (i, (pic, refpic)) in pics.iter().zip(reference.iter()).enumerate() { |
| 6085 | - assert_eq!(pic.y, refpic.y, "{NAME}: luma mismatch (seed {seed} frame {i})"); | 6354 | + assert_eq!( |
| 6086 | - assert_eq!(pic.u, refpic.u, "{NAME}: U mismatch (seed {seed} frame {i})"); | 6355 | + pic.y, refpic.y, |
| 6087 | - assert_eq!(pic.v, refpic.v, "{NAME}: V mismatch (seed {seed} frame {i})"); | 6356 | + "{NAME}: luma mismatch (seed {seed} frame {i})" |
| 6357 | + ); | ||
| 6358 | + assert_eq!( | ||
| 6359 | + pic.u, refpic.u, | ||
| 6360 | + "{NAME}: U mismatch (seed {seed} frame {i})" | ||
| 6361 | + ); | ||
| 6362 | + assert_eq!( | ||
| 6363 | + pic.v, refpic.v, | ||
| 6364 | + "{NAME}: V mismatch (seed {seed} frame {i})" | ||
| 6365 | + ); | ||
| 6088 | } | 6366 | } |
| 6089 | lr_refusals += 1; // reused below as "attempts that actually exercised LR pixels" | 6367 | lr_refusals += 1; // reused below as "attempts that actually exercised LR pixels" |
| 6090 | } | 6368 | } |
| @@ -6344,7 +6622,10 @@ mod tests { | |||
| 6344 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | 6622 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); |
| 6345 | } | 6623 | } |
| 6346 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 6624 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 6347 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 6625 | + assert_eq!( |
| 6626 | + got.y, want.y, | ||
| 6627 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 6628 | + ); | ||
| 6348 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 6629 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 6349 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 6630 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 6350 | } | 6631 | } |
| @@ -6373,8 +6654,16 @@ mod tests { | |||
| 6373 | eprintln!("SKIP: no ffmpeg/aomenc"); | 6654 | eprintln!("SKIP: no ffmpeg/aomenc"); |
| 6374 | return; | 6655 | return; |
| 6375 | } | 6656 | } |
| 6376 | - let sizes: &[(usize, usize)] = | 6657 | + let sizes: &[(usize, usize)] = &[ |
| 6377 | - &[(8, 8), (16, 16), (32, 32), (16, 32), (32, 16), (64, 64), (48, 48), (24, 24)]; | 6658 | + (8, 8), |
| 6659 | + (16, 16), | ||
| 6660 | + (32, 32), | ||
| 6661 | + (16, 32), | ||
| 6662 | + (32, 16), | ||
| 6663 | + (64, 64), | ||
| 6664 | + (48, 48), | ||
| 6665 | + (24, 24), | ||
| 6666 | + ]; | ||
| 6378 | for &(width, height) in sizes { | 6667 | for &(width, height) in sizes { |
| 6379 | let mut ok = 0u32; | 6668 | let mut ok = 0u32; |
| 6380 | let mut bad = 0u32; | 6669 | let mut bad = 0u32; |
| @@ -6389,26 +6678,53 @@ mod tests { | |||
| 6389 | ); | 6678 | ); |
| 6390 | let y4m = Command::new("ffmpeg") | 6679 | let y4m = Command::new("ffmpeg") |
| 6391 | .args([ | 6680 | .args([ |
| 6392 | - "-v", "error", "-f", "lavfi", "-i", &source, "-t", "0.04", "-pix_fmt", | 6681 | + "-v", |
| 6393 | - "yuv420p", "-f", "yuv4mpegpipe", "-", | 6682 | + "error", |
| 6683 | + "-f", | ||
| 6684 | + "lavfi", | ||
| 6685 | + "-i", | ||
| 6686 | + &source, | ||
| 6687 | + "-t", | ||
| 6688 | + "0.04", | ||
| 6689 | + "-pix_fmt", | ||
| 6690 | + "yuv420p", | ||
| 6691 | + "-f", | ||
| 6692 | + "yuv4mpegpipe", | ||
| 6693 | + "-", | ||
| 6394 | ]) | 6694 | ]) |
| 6395 | .stdin(Stdio::null()) | 6695 | .stdin(Stdio::null()) |
| 6396 | .stdout(Stdio::piped()) | 6696 | .stdout(Stdio::piped()) |
| 6397 | .stderr(Stdio::piped()) | 6697 | .stderr(Stdio::piped()) |
| 6398 | .output() | 6698 | .output() |
| 6399 | .expect("ffmpeg failed to run"); | 6699 | .expect("ffmpeg failed to run"); |
| 6400 | - assert!(y4m.status.success(), "ffmpeg fixture: {}", String::from_utf8_lossy(&y4m.stderr)); | 6700 | + assert!( |
| 6701 | + y4m.status.success(), | ||
| 6702 | + "ffmpeg fixture: {}", | ||
| 6703 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 6704 | + ); | ||
| 6401 | let max_part = width.max(height).min(64).next_power_of_two(); | 6705 | let max_part = width.max(height).min(64).next_power_of_two(); |
| 6402 | let min_part = width.min(height).next_power_of_two().max(8).min(max_part); | 6706 | let min_part = width.min(height).next_power_of_two().max(8).min(max_part); |
| 6403 | let max_part_arg = format!("--max-partition-size={max_part}"); | 6707 | let max_part_arg = format!("--max-partition-size={max_part}"); |
| 6404 | let min_part_arg = format!("--min-partition-size={min_part}"); | 6708 | let min_part_arg = format!("--min-partition-size={min_part}"); |
| 6405 | let args: Vec<&str> = vec![ | 6709 | let args: Vec<&str> = vec![ |
| 6406 | - "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32", | 6710 | + "--codec=av1", |
| 6407 | - "--cpu-used=4", "--kf-max-dist=0", "--limit=1", "--threads=1", | 6711 | + "--passes=1", |
| 6408 | - "--row-mt=0", "--enable-rect-partitions=0", "--enable-ab-partitions=0", | 6712 | + "--end-usage=q", |
| 6713 | + "--cq-level=32", | ||
| 6714 | + "--cpu-used=4", | ||
| 6715 | + "--kf-max-dist=0", | ||
| 6716 | + "--limit=1", | ||
| 6717 | + "--threads=1", | ||
| 6718 | + "--row-mt=0", | ||
| 6719 | + "--enable-rect-partitions=0", | ||
| 6720 | + "--enable-ab-partitions=0", | ||
| 6409 | "--enable-1to4-partitions=0", | 6721 | "--enable-1to4-partitions=0", |
| 6410 | - &max_part_arg, &min_part_arg, | 6722 | + &max_part_arg, |
| 6411 | - "--obu", "-o", "-", "-", | 6723 | + &min_part_arg, |
| 6724 | + "--obu", | ||
| 6725 | + "-o", | ||
| 6726 | + "-", | ||
| 6727 | + "-", | ||
| 6412 | ]; | 6728 | ]; |
| 6413 | let mut child = Command::new(aomenc_path()) | 6729 | let mut child = Command::new(aomenc_path()) |
| 6414 | .args(&args) | 6730 | .args(&args) |
| @@ -6417,9 +6733,18 @@ mod tests { | |||
| 6417 | .stderr(Stdio::piped()) | 6733 | .stderr(Stdio::piped()) |
| 6418 | .spawn() | 6734 | .spawn() |
| 6419 | .expect("aomenc failed to start"); | 6735 | .expect("aomenc failed to start"); |
| 6420 | - child.stdin.take().expect("aomenc stdin").write_all(&y4m.stdout).expect("write y4m"); | 6736 | + child |
| 6737 | + .stdin | ||
| 6738 | + .take() | ||
| 6739 | + .expect("aomenc stdin") | ||
| 6740 | + .write_all(&y4m.stdout) | ||
| 6741 | + .expect("write y4m"); | ||
| 6421 | let out = child.wait_with_output().expect("aomenc failed to run"); | 6742 | let out = child.wait_with_output().expect("aomenc failed to run"); |
| 6422 | - assert!(out.status.success(), "aomenc refused: {}", String::from_utf8_lossy(&out.stderr)); | 6743 | + assert!( |
| 6744 | + out.status.success(), | ||
| 6745 | + "aomenc refused: {}", | ||
| 6746 | + String::from_utf8_lossy(&out.stderr) | ||
| 6747 | + ); | ||
| 6423 | let stream = out.stdout; | 6748 | let stream = out.stdout; |
| 6424 | let frames = match decode_stream(&stream) { | 6749 | let frames = match decode_stream(&stream) { |
| 6425 | Err(e) => { | 6750 | Err(e) => { |
| @@ -6486,8 +6811,19 @@ mod tests { | |||
| 6486 | ); | 6811 | ); |
| 6487 | let y4m = Command::new("ffmpeg") | 6812 | let y4m = Command::new("ffmpeg") |
| 6488 | .args([ | 6813 | .args([ |
| 6489 | - "-v", "error", "-f", "lavfi", "-i", &source, "-t", "0.04", "-pix_fmt", "yuv420p", | 6814 | + "-v", |
| 6490 | - "-f", "yuv4mpegpipe", "-", | 6815 | + "error", |
| 6816 | + "-f", | ||
| 6817 | + "lavfi", | ||
| 6818 | + "-i", | ||
| 6819 | + &source, | ||
| 6820 | + "-t", | ||
| 6821 | + "0.04", | ||
| 6822 | + "-pix_fmt", | ||
| 6823 | + "yuv420p", | ||
| 6824 | + "-f", | ||
| 6825 | + "yuv4mpegpipe", | ||
| 6826 | + "-", | ||
| 6491 | ]) | 6827 | ]) |
| 6492 | .stdin(Stdio::null()) | 6828 | .stdin(Stdio::null()) |
| 6493 | .stdout(Stdio::piped()) | 6829 | .stdout(Stdio::piped()) |
| @@ -6496,12 +6832,25 @@ mod tests { | |||
| 6496 | .expect("ffmpeg failed to run"); | 6832 | .expect("ffmpeg failed to run"); |
| 6497 | assert!(y4m.status.success()); | 6833 | assert!(y4m.status.success()); |
| 6498 | let args: Vec<&str> = vec![ | 6834 | let args: Vec<&str> = vec![ |
| 6499 | - "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32", "--cpu-used=4", | 6835 | + "--codec=av1", |
| 6500 | - "--kf-max-dist=0", "--limit=1", "--threads=1", "--row-mt=0", | 6836 | + "--passes=1", |
| 6501 | - "--enable-rect-partitions=0", "--enable-ab-partitions=0", | 6837 | + "--end-usage=q", |
| 6502 | - "--enable-1to4-partitions=0", "--max-partition-size=32", "--min-partition-size=32", | 6838 | + "--cq-level=32", |
| 6839 | + "--cpu-used=4", | ||
| 6840 | + "--kf-max-dist=0", | ||
| 6841 | + "--limit=1", | ||
| 6842 | + "--threads=1", | ||
| 6843 | + "--row-mt=0", | ||
| 6844 | + "--enable-rect-partitions=0", | ||
| 6845 | + "--enable-ab-partitions=0", | ||
| 6846 | + "--enable-1to4-partitions=0", | ||
| 6847 | + "--max-partition-size=32", | ||
| 6848 | + "--min-partition-size=32", | ||
| 6503 | "--enable-filter-intra=0", | 6849 | "--enable-filter-intra=0", |
| 6504 | - "--obu", "-o", "-", "-", | 6850 | + "--obu", |
| 6851 | + "-o", | ||
| 6852 | + "-", | ||
| 6853 | + "-", | ||
| 6505 | ]; | 6854 | ]; |
| 6506 | let mut child = Command::new(aomenc_path()) | 6855 | let mut child = Command::new(aomenc_path()) |
| 6507 | .args(&args) | 6856 | .args(&args) |
| @@ -6589,9 +6938,9 @@ mod tests { | |||
| 6589 | // below it, blending the wrong OBMC prediction there. | 6938 | // below it, blending the wrong OBMC prediction there. |
| 6590 | "rect-flake-3", | 6939 | "rect-flake-3", |
| 6591 | ] | 6940 | ] |
| 6592 | - .iter() | 6941 | + .iter() |
| 6593 | - .map(|n| format!("{fixtures}/{n}.obu")) | 6942 | + .map(|n| format!("{fixtures}/{n}.obu")) |
| 6594 | - .collect(), | 6943 | + .collect(), |
| 6595 | }; | 6944 | }; |
| 6596 | for path in paths { | 6945 | for path in paths { |
| 6597 | eprintln!("pin: {path}"); | 6946 | eprintln!("pin: {path}"); |
| @@ -7590,9 +7939,18 @@ mod tests { | |||
| 7590 | ); | 7939 | ); |
| 7591 | 7940 | ||
| 7592 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | 7941 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); |
| 7593 | - assert_eq!(picture.y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | 7942 | + assert_eq!( |
| 7594 | - assert_eq!(picture.u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | 7943 | + picture.y, ffmpeg_frames[0].y, |
| 7595 | - assert_eq!(picture.v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | 7944 | + "{NAME}: luma vs ffmpeg (seed {seed})" |
| 7945 | + ); | ||
| 7946 | + assert_eq!( | ||
| 7947 | + picture.u, ffmpeg_frames[0].u, | ||
| 7948 | + "{NAME}: U vs ffmpeg (seed {seed})" | ||
| 7949 | + ); | ||
| 7950 | + assert_eq!( | ||
| 7951 | + picture.v, ffmpeg_frames[0].v, | ||
| 7952 | + "{NAME}: V vs ffmpeg (seed {seed})" | ||
| 7953 | + ); | ||
| 7596 | matched += 1; | 7954 | matched += 1; |
| 7597 | } | 7955 | } |
| 7598 | assert!( | 7956 | assert!( |
| @@ -7804,9 +8162,18 @@ mod tests { | |||
| 7804 | ); | 8162 | ); |
| 7805 | 8163 | ||
| 7806 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | 8164 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); |
| 7807 | - assert_eq!(picture.y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | 8165 | + assert_eq!( |
| 7808 | - assert_eq!(picture.u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | 8166 | + picture.y, ffmpeg_frames[0].y, |
| 7809 | - assert_eq!(picture.v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | 8167 | + "{NAME}: luma vs ffmpeg (seed {seed})" |
| 8168 | + ); | ||
| 8169 | + assert_eq!( | ||
| 8170 | + picture.u, ffmpeg_frames[0].u, | ||
| 8171 | + "{NAME}: U vs ffmpeg (seed {seed})" | ||
| 8172 | + ); | ||
| 8173 | + assert_eq!( | ||
| 8174 | + picture.v, ffmpeg_frames[0].v, | ||
| 8175 | + "{NAME}: V vs ffmpeg (seed {seed})" | ||
| 8176 | + ); | ||
| 7810 | matched += 1; | 8177 | matched += 1; |
| 7811 | } | 8178 | } |
| 7812 | assert!( | 8179 | assert!( |
| @@ -7843,8 +8210,17 @@ mod tests { | |||
| 7843 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | 8210 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); |
| 7844 | let y4m = Command::new("ffmpeg") | 8211 | let y4m = Command::new("ffmpeg") |
| 7845 | .args([ | 8212 | .args([ |
| 7846 | - "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | 8213 | + "-v", |
| 7847 | - "yuv4mpegpipe", "-", | 8214 | + "error", |
| 8215 | + "-f", | ||
| 8216 | + "lavfi", | ||
| 8217 | + "-i", | ||
| 8218 | + &source, | ||
| 8219 | + "-pix_fmt", | ||
| 8220 | + "yuv420p", | ||
| 8221 | + "-f", | ||
| 8222 | + "yuv4mpegpipe", | ||
| 8223 | + "-", | ||
| 7848 | ]) | 8224 | ]) |
| 7849 | .stdin(Stdio::null()) | 8225 | .stdin(Stdio::null()) |
| 7850 | .stdout(Stdio::piped()) | 8226 | .stdout(Stdio::piped()) |
| @@ -7930,12 +8306,25 @@ mod tests { | |||
| 7930 | "{NAME}: tile_hits delta was {hits}, expected >1 -- both tile rows must actually \ | 8306 | "{NAME}: tile_hits delta was {hits}, expected >1 -- both tile rows must actually \ |
| 7931 | decode, not just tile 0 (seed {seed})" | 8307 | decode, not just tile 0 (seed {seed})" |
| 7932 | ); | 8308 | ); |
| 7933 | - assert_eq!(pictures.len(), 1, "{NAME}: expected exactly 1 picture (seed {seed})"); | 8309 | + assert_eq!( |
| 8310 | + pictures.len(), | ||
| 8311 | + 1, | ||
| 8312 | + "{NAME}: expected exactly 1 picture (seed {seed})" | ||
| 8313 | + ); | ||
| 7934 | 8314 | ||
| 7935 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | 8315 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); |
| 7936 | - assert_eq!(pictures[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | 8316 | + assert_eq!( |
| 7937 | - assert_eq!(pictures[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | 8317 | + pictures[0].y, ffmpeg_frames[0].y, |
| 7938 | - assert_eq!(pictures[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | 8318 | + "{NAME}: luma vs ffmpeg (seed {seed})" |
| 8319 | + ); | ||
| 8320 | + assert_eq!( | ||
| 8321 | + pictures[0].u, ffmpeg_frames[0].u, | ||
| 8322 | + "{NAME}: U vs ffmpeg (seed {seed})" | ||
| 8323 | + ); | ||
| 8324 | + assert_eq!( | ||
| 8325 | + pictures[0].v, ffmpeg_frames[0].v, | ||
| 8326 | + "{NAME}: V vs ffmpeg (seed {seed})" | ||
| 8327 | + ); | ||
| 7939 | matched += 1; | 8328 | matched += 1; |
| 7940 | } | 8329 | } |
| 7941 | assert!( | 8330 | assert!( |
| @@ -7976,8 +8365,17 @@ mod tests { | |||
| 7976 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | 8365 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); |
| 7977 | let y4m = Command::new("ffmpeg") | 8366 | let y4m = Command::new("ffmpeg") |
| 7978 | .args([ | 8367 | .args([ |
| 7979 | - "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | 8368 | + "-v", |
| 7980 | - "yuv4mpegpipe", "-", | 8369 | + "error", |
| 8370 | + "-f", | ||
| 8371 | + "lavfi", | ||
| 8372 | + "-i", | ||
| 8373 | + &source, | ||
| 8374 | + "-pix_fmt", | ||
| 8375 | + "yuv420p", | ||
| 8376 | + "-f", | ||
| 8377 | + "yuv4mpegpipe", | ||
| 8378 | + "-", | ||
| 7981 | ]) | 8379 | ]) |
| 7982 | .stdin(Stdio::null()) | 8380 | .stdin(Stdio::null()) |
| 7983 | .stdout(Stdio::piped()) | 8381 | .stdout(Stdio::piped()) |
| @@ -8126,9 +8524,18 @@ mod tests { | |||
| 8126 | ); | 8524 | ); |
| 8127 | 8525 | ||
| 8128 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | 8526 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); |
| 8129 | - assert_eq!(picture.y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | 8527 | + assert_eq!( |
| 8130 | - assert_eq!(picture.u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | 8528 | + picture.y, ffmpeg_frames[0].y, |
| 8131 | - assert_eq!(picture.v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | 8529 | + "{NAME}: luma vs ffmpeg (seed {seed})" |
| 8530 | + ); | ||
| 8531 | + assert_eq!( | ||
| 8532 | + picture.u, ffmpeg_frames[0].u, | ||
| 8533 | + "{NAME}: U vs ffmpeg (seed {seed})" | ||
| 8534 | + ); | ||
| 8535 | + assert_eq!( | ||
| 8536 | + picture.v, ffmpeg_frames[0].v, | ||
| 8537 | + "{NAME}: V vs ffmpeg (seed {seed})" | ||
| 8538 | + ); | ||
| 8132 | matched += 1; | 8539 | matched += 1; |
| 8133 | } | 8540 | } |
| 8134 | assert!( | 8541 | assert!( |
| @@ -8178,8 +8585,17 @@ mod tests { | |||
| 8178 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | 8585 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); |
| 8179 | let y4m = Command::new("ffmpeg") | 8586 | let y4m = Command::new("ffmpeg") |
| 8180 | .args([ | 8587 | .args([ |
| 8181 | - "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | 8588 | + "-v", |
| 8182 | - "yuv4mpegpipe", "-", | 8589 | + "error", |
| 8590 | + "-f", | ||
| 8591 | + "lavfi", | ||
| 8592 | + "-i", | ||
| 8593 | + &source, | ||
| 8594 | + "-pix_fmt", | ||
| 8595 | + "yuv420p", | ||
| 8596 | + "-f", | ||
| 8597 | + "yuv4mpegpipe", | ||
| 8598 | + "-", | ||
| 8183 | ]) | 8599 | ]) |
| 8184 | .stdin(Stdio::null()) | 8600 | .stdin(Stdio::null()) |
| 8185 | .stdout(Stdio::piped()) | 8601 | .stdout(Stdio::piped()) |
| @@ -8283,12 +8699,25 @@ mod tests { | |||
| 8283 | "{NAME}: tile_hits delta was {hits}, expected >2 -- all four tile rows must \ | 8699 | "{NAME}: tile_hits delta was {hits}, expected >2 -- all four tile rows must \ |
| 8284 | actually decode, not just a subset (seed {seed})" | 8700 | actually decode, not just a subset (seed {seed})" |
| 8285 | ); | 8701 | ); |
| 8286 | - assert_eq!(pictures.len(), 1, "{NAME}: expected exactly 1 picture (seed {seed})"); | 8702 | + assert_eq!( |
| 8703 | + pictures.len(), | ||
| 8704 | + 1, | ||
| 8705 | + "{NAME}: expected exactly 1 picture (seed {seed})" | ||
| 8706 | + ); | ||
| 8287 | 8707 | ||
| 8288 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | 8708 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); |
| 8289 | - assert_eq!(pictures[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | 8709 | + assert_eq!( |
| 8290 | - assert_eq!(pictures[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | 8710 | + pictures[0].y, ffmpeg_frames[0].y, |
| 8291 | - assert_eq!(pictures[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | 8711 | + "{NAME}: luma vs ffmpeg (seed {seed})" |
| 8712 | + ); | ||
| 8713 | + assert_eq!( | ||
| 8714 | + pictures[0].u, ffmpeg_frames[0].u, | ||
| 8715 | + "{NAME}: U vs ffmpeg (seed {seed})" | ||
| 8716 | + ); | ||
| 8717 | + assert_eq!( | ||
| 8718 | + pictures[0].v, ffmpeg_frames[0].v, | ||
| 8719 | + "{NAME}: V vs ffmpeg (seed {seed})" | ||
| 8720 | + ); | ||
| 8292 | matched += 1; | 8721 | matched += 1; |
| 8293 | } | 8722 | } |
| 8294 | assert!( | 8723 | assert!( |
| @@ -8320,7 +8749,8 @@ mod tests { | |||
| 8320 | /// comment used to describe are gone from `decode_stream`. | 8749 | /// comment used to describe are gone from `decode_stream`. |
| 8321 | #[test] | 8750 | #[test] |
| 8322 | fn a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream() { | 8751 | fn a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream() { |
| 8323 | - const NAME: &str = "a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream"; | 8752 | + const NAME: &str = |
| 8753 | + "a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream"; | ||
| 8324 | if !have_ffmpeg() { | 8754 | if !have_ffmpeg() { |
| 8325 | eprintln!("SKIP {NAME}: no ffmpeg"); | 8755 | eprintln!("SKIP {NAME}: no ffmpeg"); |
| 8326 | return; | 8756 | return; |
| @@ -8337,8 +8767,17 @@ mod tests { | |||
| 8337 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | 8767 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); |
| 8338 | let y4m = Command::new("ffmpeg") | 8768 | let y4m = Command::new("ffmpeg") |
| 8339 | .args([ | 8769 | .args([ |
| 8340 | - "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | 8770 | + "-v", |
| 8341 | - "yuv4mpegpipe", "-", | 8771 | + "error", |
| 8772 | + "-f", | ||
| 8773 | + "lavfi", | ||
| 8774 | + "-i", | ||
| 8775 | + &source, | ||
| 8776 | + "-pix_fmt", | ||
| 8777 | + "yuv420p", | ||
| 8778 | + "-f", | ||
| 8779 | + "yuv4mpegpipe", | ||
| 8780 | + "-", | ||
| 8342 | ]) | 8781 | ]) |
| 8343 | .stdin(Stdio::null()) | 8782 | .stdin(Stdio::null()) |
| 8344 | .stdout(Stdio::piped()) | 8783 | .stdout(Stdio::piped()) |
| @@ -8425,12 +8864,25 @@ mod tests { | |||
| 8425 | "{NAME}: tile_hits delta was {hits}, expected >1 -- both tiles must actually \ | 8864 | "{NAME}: tile_hits delta was {hits}, expected >1 -- both tiles must actually \ |
| 8426 | decode, not just tile 0 (seed {seed})" | 8865 | decode, not just tile 0 (seed {seed})" |
| 8427 | ); | 8866 | ); |
| 8428 | - assert_eq!(pictures.len(), 1, "{NAME}: expected exactly 1 picture (seed {seed})"); | 8867 | + assert_eq!( |
| 8868 | + pictures.len(), | ||
| 8869 | + 1, | ||
| 8870 | + "{NAME}: expected exactly 1 picture (seed {seed})" | ||
| 8871 | + ); | ||
| 8429 | 8872 | ||
| 8430 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | 8873 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); |
| 8431 | - assert_eq!(pictures[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | 8874 | + assert_eq!( |
| 8432 | - assert_eq!(pictures[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | 8875 | + pictures[0].y, ffmpeg_frames[0].y, |
| 8433 | - assert_eq!(pictures[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | 8876 | + "{NAME}: luma vs ffmpeg (seed {seed})" |
| 8877 | + ); | ||
| 8878 | + assert_eq!( | ||
| 8879 | + pictures[0].u, ffmpeg_frames[0].u, | ||
| 8880 | + "{NAME}: U vs ffmpeg (seed {seed})" | ||
| 8881 | + ); | ||
| 8882 | + assert_eq!( | ||
| 8883 | + pictures[0].v, ffmpeg_frames[0].v, | ||
| 8884 | + "{NAME}: V vs ffmpeg (seed {seed})" | ||
| 8885 | + ); | ||
| 8434 | matched += 1; | 8886 | matched += 1; |
| 8435 | } | 8887 | } |
| 8436 | assert!( | 8888 | assert!( |
| @@ -8615,7 +9067,10 @@ mod tests { | |||
| 8615 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | 9067 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); |
| 8616 | } | 9068 | } |
| 8617 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 9069 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 8618 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 9070 | + assert_eq!( |
| 9071 | + got.y, want.y, | ||
| 9072 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 9073 | + ); | ||
| 8619 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 9074 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 8620 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 9075 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 8621 | } | 9076 | } |
| @@ -8681,8 +9136,17 @@ mod tests { | |||
| 8681 | let source = gradients_source(seed, width, height, "duration=0.08:rate=25"); | 9136 | let source = gradients_source(seed, width, height, "duration=0.08:rate=25"); |
| 8682 | let y4m = Command::new("ffmpeg") | 9137 | let y4m = Command::new("ffmpeg") |
| 8683 | .args([ | 9138 | .args([ |
| 8684 | - "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | 9139 | + "-v", |
| 8685 | - "yuv4mpegpipe", "-", | 9140 | + "error", |
| 9141 | + "-f", | ||
| 9142 | + "lavfi", | ||
| 9143 | + "-i", | ||
| 9144 | + &source, | ||
| 9145 | + "-pix_fmt", | ||
| 9146 | + "yuv420p", | ||
| 9147 | + "-f", | ||
| 9148 | + "yuv4mpegpipe", | ||
| 9149 | + "-", | ||
| 8686 | ]) | 9150 | ]) |
| 8687 | .stdin(Stdio::null()) | 9151 | .stdin(Stdio::null()) |
| 8688 | .stdout(Stdio::piped()) | 9152 | .stdout(Stdio::piped()) |
| @@ -8806,11 +9270,18 @@ mod tests { | |||
| 8806 | "{NAME}: tile_hits delta was {hits}, expected > {frames} -- both tiles of both \ | 9270 | "{NAME}: tile_hits delta was {hits}, expected > {frames} -- both tiles of both \ |
| 8807 | frames must actually decode (seed {seed})" | 9271 | frames must actually decode (seed {seed})" |
| 8808 | ); | 9272 | ); |
| 8809 | - assert_eq!(pictures.len(), frames, "{NAME}: expected {frames} pictures (seed {seed})"); | 9273 | + assert_eq!( |
| 9274 | + pictures.len(), | ||
| 9275 | + frames, | ||
| 9276 | + "{NAME}: expected {frames} pictures (seed {seed})" | ||
| 9277 | + ); | ||
| 8810 | 9278 | ||
| 8811 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frames); | 9279 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frames); |
| 8812 | for (i, (got, want)) in pictures.iter().zip(&ffmpeg_frames).enumerate() { | 9280 | for (i, (got, want)) in pictures.iter().zip(&ffmpeg_frames).enumerate() { |
| 8813 | - assert_eq!(got.y, want.y, "{NAME}: seed {seed} frame {i} luma vs ffmpeg"); | 9281 | + assert_eq!( |
| 9282 | + got.y, want.y, | ||
| 9283 | + "{NAME}: seed {seed} frame {i} luma vs ffmpeg" | ||
| 9284 | + ); | ||
| 8814 | assert_eq!(got.u, want.u, "{NAME}: seed {seed} frame {i} U vs ffmpeg"); | 9285 | assert_eq!(got.u, want.u, "{NAME}: seed {seed} frame {i} U vs ffmpeg"); |
| 8815 | assert_eq!(got.v, want.v, "{NAME}: seed {seed} frame {i} V vs ffmpeg"); | 9286 | assert_eq!(got.v, want.v, "{NAME}: seed {seed} frame {i} V vs ffmpeg"); |
| 8816 | } | 9287 | } |
| @@ -8862,8 +9333,17 @@ mod tests { | |||
| 8862 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | 9333 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); |
| 8863 | let y4m = Command::new("ffmpeg") | 9334 | let y4m = Command::new("ffmpeg") |
| 8864 | .args([ | 9335 | .args([ |
| 8865 | - "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | 9336 | + "-v", |
| 8866 | - "yuv4mpegpipe", "-", | 9337 | + "error", |
| 9338 | + "-f", | ||
| 9339 | + "lavfi", | ||
| 9340 | + "-i", | ||
| 9341 | + &source, | ||
| 9342 | + "-pix_fmt", | ||
| 9343 | + "yuv420p", | ||
| 9344 | + "-f", | ||
| 9345 | + "yuv4mpegpipe", | ||
| 9346 | + "-", | ||
| 8867 | ]) | 9347 | ]) |
| 8868 | .stdin(Stdio::null()) | 9348 | .stdin(Stdio::null()) |
| 8869 | .stdout(Stdio::piped()) | 9349 | .stdout(Stdio::piped()) |
| @@ -8964,12 +9444,25 @@ mod tests { | |||
| 8964 | hits > 0, | 9444 | hits > 0, |
| 8965 | "{NAME}: tile_hits delta was {hits}, expected >0 (seed {seed})" | 9445 | "{NAME}: tile_hits delta was {hits}, expected >0 (seed {seed})" |
| 8966 | ); | 9446 | ); |
| 8967 | - assert_eq!(pictures.len(), 1, "{NAME}: expected exactly 1 picture (seed {seed})"); | 9447 | + assert_eq!( |
| 9448 | + pictures.len(), | ||
| 9449 | + 1, | ||
| 9450 | + "{NAME}: expected exactly 1 picture (seed {seed})" | ||
| 9451 | + ); | ||
| 8968 | 9452 | ||
| 8969 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | 9453 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); |
| 8970 | - assert_eq!(pictures[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | 9454 | + assert_eq!( |
| 8971 | - assert_eq!(pictures[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | 9455 | + pictures[0].y, ffmpeg_frames[0].y, |
| 8972 | - assert_eq!(pictures[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | 9456 | + "{NAME}: luma vs ffmpeg (seed {seed})" |
| 9457 | + ); | ||
| 9458 | + assert_eq!( | ||
| 9459 | + pictures[0].u, ffmpeg_frames[0].u, | ||
| 9460 | + "{NAME}: U vs ffmpeg (seed {seed})" | ||
| 9461 | + ); | ||
| 9462 | + assert_eq!( | ||
| 9463 | + pictures[0].v, ffmpeg_frames[0].v, | ||
| 9464 | + "{NAME}: V vs ffmpeg (seed {seed})" | ||
| 9465 | + ); | ||
| 8973 | matched += 1; | 9466 | matched += 1; |
| 8974 | } | 9467 | } |
| 8975 | assert!( | 9468 | assert!( |
| @@ -9032,8 +9525,17 @@ mod tests { | |||
| 9032 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | 9525 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); |
| 9033 | let y4m = Command::new("ffmpeg") | 9526 | let y4m = Command::new("ffmpeg") |
| 9034 | .args([ | 9527 | .args([ |
| 9035 | - "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | 9528 | + "-v", |
| 9036 | - "yuv4mpegpipe", "-", | 9529 | + "error", |
| 9530 | + "-f", | ||
| 9531 | + "lavfi", | ||
| 9532 | + "-i", | ||
| 9533 | + &source, | ||
| 9534 | + "-pix_fmt", | ||
| 9535 | + "yuv420p", | ||
| 9536 | + "-f", | ||
| 9537 | + "yuv4mpegpipe", | ||
| 9538 | + "-", | ||
| 9037 | ]) | 9539 | ]) |
| 9038 | .stdin(Stdio::null()) | 9540 | .stdin(Stdio::null()) |
| 9039 | .stdout(Stdio::piped()) | 9541 | .stdout(Stdio::piped()) |
| @@ -9145,12 +9647,25 @@ mod tests { | |||
| 9145 | hits > 0, | 9647 | hits > 0, |
| 9146 | "{NAME}: tile_hits delta was {hits}, expected >0 (seed {seed})" | 9648 | "{NAME}: tile_hits delta was {hits}, expected >0 (seed {seed})" |
| 9147 | ); | 9649 | ); |
| 9148 | - assert_eq!(pictures.len(), 1, "{NAME}: expected exactly 1 picture (seed {seed})"); | 9650 | + assert_eq!( |
| 9651 | + pictures.len(), | ||
| 9652 | + 1, | ||
| 9653 | + "{NAME}: expected exactly 1 picture (seed {seed})" | ||
| 9654 | + ); | ||
| 9149 | 9655 | ||
| 9150 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | 9656 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); |
| 9151 | - assert_eq!(pictures[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | 9657 | + assert_eq!( |
| 9152 | - assert_eq!(pictures[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | 9658 | + pictures[0].y, ffmpeg_frames[0].y, |
| 9153 | - assert_eq!(pictures[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | 9659 | + "{NAME}: luma vs ffmpeg (seed {seed})" |
| 9660 | + ); | ||
| 9661 | + assert_eq!( | ||
| 9662 | + pictures[0].u, ffmpeg_frames[0].u, | ||
| 9663 | + "{NAME}: U vs ffmpeg (seed {seed})" | ||
| 9664 | + ); | ||
| 9665 | + assert_eq!( | ||
| 9666 | + pictures[0].v, ffmpeg_frames[0].v, | ||
| 9667 | + "{NAME}: V vs ffmpeg (seed {seed})" | ||
| 9668 | + ); | ||
| 9154 | matched += 1; | 9669 | matched += 1; |
| 9155 | } | 9670 | } |
| 9156 | assert!( | 9671 | assert!( |
| @@ -9311,7 +9826,10 @@ mod tests { | |||
| 9311 | } | 9826 | } |
| 9312 | } | 9827 | } |
| 9313 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 9828 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 9314 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 9829 | + assert_eq!( |
| 9830 | + got.y, want.y, | ||
| 9831 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 9832 | + ); | ||
| 9315 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 9833 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 9316 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 9834 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 9317 | } | 9835 | } |
| @@ -9353,9 +9871,8 @@ mod tests { | |||
| 9353 | #[test] | 9871 | #[test] |
| 9354 | #[ignore = "drift never observed this round -- see lanes/rect64q-r1.report.md"] | 9872 | #[ignore = "drift never observed this round -- see lanes/rect64q-r1.report.md"] |
| 9355 | fn a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_and_delta_q_decodes_pixel_exact() | 9873 | fn a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_and_delta_q_decodes_pixel_exact() |
| 9356 | - { | 9874 | + { |
| 9357 | - const NAME: &str = | 9875 | + const NAME: &str = "a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_and_delta_q_decodes_pixel_exact"; |
| 9358 | - "a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_and_delta_q_decodes_pixel_exact"; | ||
| 9359 | let _gate_lock = lock_gate_counters(); | 9876 | let _gate_lock = lock_gate_counters(); |
| 9360 | if !have_ffmpeg() { | 9877 | if !have_ffmpeg() { |
| 9361 | eprintln!("SKIP {NAME}: no ffmpeg"); | 9878 | eprintln!("SKIP {NAME}: no ffmpeg"); |
| @@ -9472,7 +9989,10 @@ mod tests { | |||
| 9472 | } | 9989 | } |
| 9473 | } | 9990 | } |
| 9474 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 9991 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 9475 | - assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | 9992 | + assert_eq!( |
| 9993 | + got.y, want.y, | ||
| 9994 | + "{NAME} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 9995 | + ); | ||
| 9476 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | 9996 | assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); |
| 9477 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | 9997 | assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); |
| 9478 | } | 9998 | } |
crates/ec-av1/src/superres.rsmodified+11 -3
| @@ -114,7 +114,10 @@ pub(crate) fn upscale_row(row: &[u8], real_right_margin: &[u8], out_width: usize | |||
| 114 | padded[pad..pad + in_width].copy_from_slice(row); | 114 | padded[pad..pad + in_width].copy_from_slice(row); |
| 115 | let real_n = real_right_margin.len().min(pad); | 115 | let real_n = real_right_margin.len().min(pad); |
| 116 | padded[pad + in_width..pad + in_width + real_n].copy_from_slice(&real_right_margin[..real_n]); | 116 | padded[pad + in_width..pad + in_width + real_n].copy_from_slice(&real_right_margin[..real_n]); |
| 117 | - let replicate_from = real_right_margin.last().copied().unwrap_or(row[in_width - 1]); | 117 | + let replicate_from = real_right_margin |
| 118 | + .last() | ||
| 119 | + .copied() | ||
| 120 | + .unwrap_or(row[in_width - 1]); | ||
| 118 | padded[pad + in_width + real_n..].fill(replicate_from); | 121 | padded[pad + in_width + real_n..].fill(replicate_from); |
| 119 | 122 | ||
| 120 | // `av1_convolve_horiz_rs_c` is called with `input - 1` and itself | 123 | // `av1_convolve_horiz_rs_c` is called with `input - 1` and itself |
| @@ -262,7 +265,9 @@ mod tests { | |||
| 262 | upscale_row(&row, &[], 16, &mut out); | 265 | upscale_row(&row, &[], 16, &mut out); |
| 263 | assert_eq!( | 266 | assert_eq!( |
| 264 | out, | 267 | out, |
| 265 | - [9, 12, 17, 23, 28, 32, 37, 43, 48, 53, 58, 62, 67, 73, 78, 81] | 268 | + [ |
| 269 | + 9, 12, 17, 23, 28, 32, 37, 43, 48, 53, 58, 62, 67, 73, 78, 81 | ||
| 270 | + ] | ||
| 266 | ); | 271 | ); |
| 267 | } | 272 | } |
| 268 | 273 | ||
| @@ -295,6 +300,9 @@ mod tests { | |||
| 295 | let real_margin = [140u8]; | 300 | let real_margin = [140u8]; |
| 296 | let mut out = [0u8; 64]; | 301 | let mut out = [0u8; 64]; |
| 297 | upscale_row(&row, &real_margin, 64, &mut out); | 302 | upscale_row(&row, &real_margin, 64, &mut out); |
| 298 | - assert_eq!(out[62], 141, "column 62 must match libaom, not the old replicate-padded 140"); | 303 | + assert_eq!( |
| 304 | + out[62], 141, | ||
| 305 | + "column 62 must match libaom, not the old replicate-padded 140" | ||
| 306 | + ); | ||
| 299 | } | 307 | } |
| 300 | } | 308 | } |
crates/ec-av1/src/transform.rsmodified+7 -5
| @@ -839,12 +839,12 @@ pub fn inverse_transform_2d_typed_wh( | |||
| 839 | let mut t = [0i32; 64]; | 839 | let mut t = [0i32; 64]; |
| 840 | for i in 0..h { | 840 | for i in 0..h { |
| 841 | for j in 0..w { | 841 | for j in 0..w { |
| 842 | - let c = if i < 32 && j < 32 { dequant[i * w + j] } else { 0 }; | 842 | + let c = if i < 32 && j < 32 { |
| 843 | - t[j] = if rect_scale { | 843 | + dequant[i * w + j] |
| 844 | - round2(c * 2896, 12) | ||
| 845 | } else { | 844 | } else { |
| 846 | - c | 845 | + 0 |
| 847 | }; | 846 | }; |
| 847 | + t[j] = if rect_scale { round2(c * 2896, 12) } else { c }; | ||
| 848 | } | 848 | } |
| 849 | inverse_1d(&mut t, log2w, row_clamp, row_kind); | 849 | inverse_1d(&mut t, log2w, row_clamp, row_kind); |
| 850 | for j in 0..w { | 850 | for j in 0..w { |
| @@ -898,7 +898,9 @@ pub fn dequant_and_inverse_typed( | |||
| 898 | ac_delta: i32, | 898 | ac_delta: i32, |
| 899 | tx_type: TxType, | 899 | tx_type: TxType, |
| 900 | ) -> Vec<i32> { | 900 | ) -> Vec<i32> { |
| 901 | - dequant_and_inverse_typed_wh(levels, side, side, bit_depth, q_idx, dc_delta, ac_delta, tx_type) | 901 | + dequant_and_inverse_typed_wh( |
| 902 | + levels, side, side, bit_depth, q_idx, dc_delta, ac_delta, tx_type, | ||
| 903 | + ) | ||
| 902 | } | 904 | } |
| 903 | 905 | ||
| 904 | /// [`dequant_and_inverse_typed`] widened to `(w, h)` (lane-recttx). `dc_delta`/ | 906 | /// [`dequant_and_inverse_typed`] widened to `(w, h)` (lane-recttx). `dc_delta`/ |
crates/ec-av1/src/warp.rsmodified+23 -8
| @@ -326,12 +326,20 @@ fn get_shear_params(wmmat: [i32; 6]) -> Option<(i16, i16, i16, i16)> { | |||
| 326 | return None; | 326 | return None; |
| 327 | } | 327 | } |
| 328 | let mat = wmmat.map(|v| v as i64); | 328 | let mat = wmmat.map(|v| v as i64); |
| 329 | - let mut alpha = clamp(mat[2] - (1 << WARPEDMODEL_PREC_BITS), i16::MIN as i64, i16::MAX as i64); | 329 | + let mut alpha = clamp( |
| 330 | + mat[2] - (1 << WARPEDMODEL_PREC_BITS), | ||
| 331 | + i16::MIN as i64, | ||
| 332 | + i16::MAX as i64, | ||
| 333 | + ); | ||
| 330 | let beta = clamp(mat[3], i16::MIN as i64, i16::MAX as i64); | 334 | let beta = clamp(mat[3], i16::MIN as i64, i16::MAX as i64); |
| 331 | let (y_mag, shift) = resolve_divisor_32(mat[2].unsigned_abs() as u32); | 335 | let (y_mag, shift) = resolve_divisor_32(mat[2].unsigned_abs() as u32); |
| 332 | let y = if mat[2] < 0 { -y_mag } else { y_mag }; | 336 | let y = if mat[2] < 0 { -y_mag } else { y_mag }; |
| 333 | let v = (mat[4] * (1 << WARPEDMODEL_PREC_BITS)) * y; | 337 | let v = (mat[4] * (1 << WARPEDMODEL_PREC_BITS)) * y; |
| 334 | - let mut gamma = clamp(round2_signed(v, shift as u32), i16::MIN as i64, i16::MAX as i64); | 338 | + let mut gamma = clamp( |
| 339 | + round2_signed(v, shift as u32), | ||
| 340 | + i16::MIN as i64, | ||
| 341 | + i16::MAX as i64, | ||
| 342 | + ); | ||
| 335 | let v = (mat[3] * mat[4]) * y; | 343 | let v = (mat[3] * mat[4]) * y; |
| 336 | let mut delta = clamp( | 344 | let mut delta = clamp( |
| 337 | mat[5] - round2_signed(v, shift as u32) - (1 << WARPEDMODEL_PREC_BITS), | 345 | mat[5] - round2_signed(v, shift as u32) - (1 << WARPEDMODEL_PREC_BITS), |
| @@ -412,7 +420,13 @@ pub fn find_projection( | |||
| 412 | /// translational fallback in that rare case. | 420 | /// translational fallback in that rare case. |
| 413 | pub fn global_warp_params(wmmat: [i32; 6]) -> Option<WarpParams> { | 421 | pub fn global_warp_params(wmmat: [i32; 6]) -> Option<WarpParams> { |
| 414 | let (alpha, beta, gamma, delta) = get_shear_params(wmmat)?; | 422 | let (alpha, beta, gamma, delta) = get_shear_params(wmmat)?; |
| 415 | - Some(WarpParams { wmmat, alpha, beta, gamma, delta }) | 423 | + Some(WarpParams { |
| 424 | + wmmat, | ||
| 425 | + alpha, | ||
| 426 | + beta, | ||
| 427 | + gamma, | ||
| 428 | + delta, | ||
| 429 | + }) | ||
| 416 | } | 430 | } |
| 417 | 431 | ||
| 418 | fn clip_pixel(v: i32) -> u16 { | 432 | fn clip_pixel(v: i32) -> u16 { |
| @@ -480,8 +494,8 @@ pub fn warp_affine( | |||
| 480 | let mut sx = sx4 + beta * (k as i64 + 4); | 494 | let mut sx = sx4 + beta * (k as i64 + 4); |
| 481 | for l in -4..4i32 { | 495 | for l in -4..4i32 { |
| 482 | let ix = ix4 + l - 3; | 496 | let ix = ix4 + l - 3; |
| 483 | - let offs = | 497 | + let offs = (round2(sx, WARPEDDIFF_PREC_BITS) as i32 + WARPEDPIXEL_PREC_SHIFTS) |
| 484 | - (round2(sx, WARPEDDIFF_PREC_BITS) as i32 + WARPEDPIXEL_PREC_SHIFTS) as usize; | 498 | + as usize; |
| 485 | let coeffs = &AV1_WARPED_FILTER[offs]; | 499 | let coeffs = &AV1_WARPED_FILTER[offs]; |
| 486 | let mut sum: i32 = 1 << offset_bits_horiz; | 500 | let mut sum: i32 = 1 << offset_bits_horiz; |
| 487 | for (m, &c) in coeffs.iter().enumerate() { | 501 | for (m, &c) in coeffs.iter().enumerate() { |
| @@ -501,12 +515,13 @@ pub fn warp_affine( | |||
| 501 | let l_hi = (4i32).min(p_col + p_width - j - 4); | 515 | let l_hi = (4i32).min(p_col + p_width - j - 4); |
| 502 | let mut l = -4i32; | 516 | let mut l = -4i32; |
| 503 | while l < l_hi { | 517 | while l < l_hi { |
| 504 | - let offs = | 518 | + let offs = (round2(sy, WARPEDDIFF_PREC_BITS) as i32 + WARPEDPIXEL_PREC_SHIFTS) |
| 505 | - (round2(sy, WARPEDDIFF_PREC_BITS) as i32 + WARPEDPIXEL_PREC_SHIFTS) as usize; | 519 | + as usize; |
| 506 | let coeffs = &AV1_WARPED_FILTER[offs]; | 520 | let coeffs = &AV1_WARPED_FILTER[offs]; |
| 507 | let mut sum: i32 = 1 << offset_bits_vert; | 521 | let mut sum: i32 = 1 << offset_bits_vert; |
| 508 | for m in 0..8i32 { | 522 | for m in 0..8i32 { |
| 509 | - sum += tmp[(k + m + 4) as usize][(l + 4) as usize] * coeffs[m as usize] as i32; | 523 | + sum += |
| 524 | + tmp[(k + m + 4) as usize][(l + 4) as usize] * coeffs[m as usize] as i32; | ||
| 510 | } | 525 | } |
| 511 | sum = round2(sum as i64, reduce_bits_vert as u32) as i32; | 526 | sum = round2(sum as i64, reduce_bits_vert as u32) as i32; |
| 512 | let out_row = (i - p_row + k + 4) as usize; | 527 | let out_row = (i - p_row + k + 4) as usize; |
crates/ec-av1/src/wedge.rsmodified+23 -9
| @@ -33,18 +33,18 @@ const N_DIR: usize = 6; | |||
| 33 | 33 | ||
| 34 | const WEDGE_MASTER_OBLIQUE_ODD: [u8; MASK_MASTER_SIZE] = [ | 34 | const WEDGE_MASTER_OBLIQUE_ODD: [u8; MASK_MASTER_SIZE] = [ |
| 35 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 6, | 35 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 6, |
| 36 | - 18, 37, 53, 60, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | 36 | + 18, 37, 53, 60, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, |
| 37 | - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | 37 | + 64, 64, 64, 64, 64, 64, 64, 64, 64, |
| 38 | ]; | 38 | ]; |
| 39 | const WEDGE_MASTER_OBLIQUE_EVEN: [u8; MASK_MASTER_SIZE] = [ | 39 | const WEDGE_MASTER_OBLIQUE_EVEN: [u8; MASK_MASTER_SIZE] = [ |
| 40 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 11, | 40 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 11, |
| 41 | - 27, 46, 58, 62, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | 41 | + 27, 46, 58, 62, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, |
| 42 | - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | 42 | + 64, 64, 64, 64, 64, 64, 64, 64, 64, |
| 43 | ]; | 43 | ]; |
| 44 | const WEDGE_MASTER_VERTICAL: [u8; MASK_MASTER_SIZE] = [ | 44 | const WEDGE_MASTER_VERTICAL: [u8; MASK_MASTER_SIZE] = [ |
| 45 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 7, | 45 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 7, |
| 46 | - 21, 43, 57, 62, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | 46 | + 21, 43, 57, 62, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, |
| 47 | - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | 47 | + 64, 64, 64, 64, 64, 64, 64, 64, 64, |
| 48 | ]; | 48 | ]; |
| 49 | 49 | ||
| 50 | /// `wedge_codebook_16_heqw` (reconinter.c) -- (direction, x_offset, y_offset). | 50 | /// `wedge_codebook_16_heqw` (reconinter.c) -- (direction, x_offset, y_offset). |
| @@ -149,7 +149,13 @@ fn init_wedge_master_masks() -> MasterMasks { | |||
| 149 | /// `get_wedge_mask_inplace` (reconinter.c): the `bw x bh` window of the | 149 | /// `get_wedge_mask_inplace` (reconinter.c): the `bw x bh` window of the |
| 150 | /// master plane for this `(wedge_index, neg, bw, bh)`, still in | 150 | /// master plane for this `(wedge_index, neg, bw, bh)`, still in |
| 151 | /// `MASK_MASTER_SIZE`-stride coordinates (caller extracts the window). | 151 | /// `MASK_MASTER_SIZE`-stride coordinates (caller extracts the window). |
| 152 | -fn wedge_window(master: &MasterMasks, wedge_index: usize, neg: usize, bw: usize, bh: usize) -> (usize, usize, usize) { | 152 | +fn wedge_window( |
| 153 | + master: &MasterMasks, | ||
| 154 | + wedge_index: usize, | ||
| 155 | + neg: usize, | ||
| 156 | + bw: usize, | ||
| 157 | + bh: usize, | ||
| 158 | +) -> (usize, usize, usize) { | ||
| 153 | let (dir, xo, yo) = HEQW[wedge_index]; | 159 | let (dir, xo, yo) = HEQW[wedge_index]; |
| 154 | let wsignflip = SIGNFLIP[wedge_index] as usize; | 160 | let wsignflip = SIGNFLIP[wedge_index] as usize; |
| 155 | let woff = (xo as usize * bw) >> 3; | 161 | let woff = (xo as usize * bw) >> 3; |
| @@ -157,7 +163,11 @@ fn wedge_window(master: &MasterMasks, wedge_index: usize, neg: usize, bw: usize, | |||
| 157 | let _ = &master.obl[neg ^ wsignflip][dir as usize]; | 163 | let _ = &master.obl[neg ^ wsignflip][dir as usize]; |
| 158 | let row0 = MASK_MASTER_SIZE / 2 - hoff; | 164 | let row0 = MASK_MASTER_SIZE / 2 - hoff; |
| 159 | let col0 = MASK_MASTER_SIZE / 2 - woff; | 165 | let col0 = MASK_MASTER_SIZE / 2 - woff; |
| 160 | - (neg ^ wsignflip, dir as usize, row0 * MASK_MASTER_SIZE + col0) | 166 | + ( |
| 167 | + neg ^ wsignflip, | ||
| 168 | + dir as usize, | ||
| 169 | + row0 * MASK_MASTER_SIZE + col0, | ||
| 170 | + ) | ||
| 161 | } | 171 | } |
| 162 | 172 | ||
| 163 | /// Per-`(sign, wedge_index)` `bw x bh` mask, contiguous stride `bw`. | 173 | /// Per-`(sign, wedge_index)` `bw x bh` mask, contiguous stride `bw`. |
| @@ -282,6 +292,10 @@ mod tests { | |||
| 282 | } | 292 | } |
| 283 | } | 293 | } |
| 284 | } | 294 | } |
| 285 | - assert_eq!(checked, 3 * 2 * MAX_WEDGE_TYPES, "checked every (bsize,sign,index) triple"); | 295 | + assert_eq!( |
| 296 | + checked, | ||
| 297 | + 3 * 2 * MAX_WEDGE_TYPES, | ||
| 298 | + "checked every (bsize,sign,index) triple" | ||
| 299 | + ); | ||
| 286 | } | 300 | } |
| 287 | } | 301 | } |