Thread allow_screen_content_tools/allow_intrabc through decode_key_frame_tile[_with_cdfs]
Browse files at this commit818f85da227aec31eb5e64453ca299270590ffe5Parent: b46f7d8- feat
- thread allow_screen_content_tools/allow_intrabc through decode_key_frame_tile[_with_cdfs]
- narrow whole-frame refusal to non-key frames
2 changed files +29 -2
- crates/ec-av1/src/decode.rs +18 -0
- crates/ec-av1/src/stream.rs +11 -2
crates/ec-av1/src/decode.rsmodified+18 -0
| @@ -3539,6 +3539,8 @@ pub fn decode_key_frame_tile( | ||
| 3539 | 3539 | loop_filter: &LoopFilterParams, |
| 3540 | 3540 | tx_select: bool, |
| 3541 | 3541 | reduced_tx_set: bool, |
| 3542 | + allow_screen_content_tools: bool, | |
| 3543 | + allow_intrabc: bool, | |
| 3542 | 3544 | ) -> Result<Picture> { |
| 3543 | 3545 | decode_key_frame_tile_with_cdfs( |
| 3544 | 3546 | data, |
| @@ -3554,6 +3556,8 @@ pub fn decode_key_frame_tile( | ||
| 3554 | 3556 | None, |
| 3555 | 3557 | tx_select, |
| 3556 | 3558 | reduced_tx_set, |
| 3559 | + allow_screen_content_tools, | |
| 3560 | + allow_intrabc, | |
| 3557 | 3561 | ) |
| 3558 | 3562 | .map(|(picture, _)| picture) |
| 3559 | 3563 | } |
| @@ -3580,6 +3584,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 3580 | 3584 | initial_cdfs: Option<Cdfs>, |
| 3581 | 3585 | tx_select: bool, |
| 3582 | 3586 | reduced_tx_set: bool, |
| 3587 | + allow_screen_content_tools: bool, | |
| 3588 | + allow_intrabc: bool, | |
| 3583 | 3589 | ) -> Result<(Picture, Cdfs)> { |
| 3584 | 3590 | if mi_cols == 0 || mi_rows == 0 { |
| 3585 | 3591 | return Err(unsupported("a frame with no mode-info grid")); |
| @@ -9388,6 +9394,8 @@ mod tests { | ||
| 9388 | 9394 | &LoopFilterParams::default(), |
| 9389 | 9395 | false, |
| 9390 | 9396 | true, |
| 9397 | + false, | |
| 9398 | + false, | |
| 9391 | 9399 | ) |
| 9392 | 9400 | .is_err() |
| 9393 | 9401 | ); |
| @@ -9430,6 +9438,8 @@ mod tests { | ||
| 9430 | 9438 | &LoopFilterParams::default(), |
| 9431 | 9439 | false, |
| 9432 | 9440 | true, |
| 9441 | + false, | |
| 9442 | + false, | |
| 9433 | 9443 | ) |
| 9434 | 9444 | .unwrap(); |
| 9435 | 9445 | assert_eq!(decoded.width, w, "{w}x{h}: decoded width"); |
| @@ -9513,6 +9523,8 @@ mod tests { | ||
| 9513 | 9523 | &LoopFilterParams::default(), |
| 9514 | 9524 | false, |
| 9515 | 9525 | true, |
| 9526 | + false, | |
| 9527 | + false, | |
| 9516 | 9528 | ) |
| 9517 | 9529 | .unwrap(); |
| 9518 | 9530 | assert!( |
| @@ -9698,6 +9710,8 @@ mod tests { | ||
| 9698 | 9710 | &LoopFilterParams::default(), |
| 9699 | 9711 | false, |
| 9700 | 9712 | true, |
| 9713 | + false, | |
| 9714 | + false, | |
| 9701 | 9715 | ) |
| 9702 | 9716 | .unwrap(); |
| 9703 | 9717 | assert_eq!(ours.y, ffmpeg_decoded.y, "{width}x{height}: luma vs ffmpeg"); |
| @@ -9770,6 +9784,8 @@ mod tests { | ||
| 9770 | 9784 | &LoopFilterParams::default(), |
| 9771 | 9785 | false, |
| 9772 | 9786 | true, |
| 9787 | + false, | |
| 9788 | + false, | |
| 9773 | 9789 | ) |
| 9774 | 9790 | .unwrap(); |
| 9775 | 9791 | assert_eq!( |
| @@ -10073,6 +10089,8 @@ mod tests { | ||
| 10073 | 10089 | &LoopFilterParams::default(), |
| 10074 | 10090 | false, |
| 10075 | 10091 | true, |
| 10092 | + false, | |
| 10093 | + false, | |
| 10076 | 10094 | ) |
| 10077 | 10095 | .unwrap(); |
| 10078 | 10096 | assert_eq!(reference.y, ffmpeg_frames[0].y, "frame 0 luma vs ffmpeg"); |
crates/ec-av1/src/stream.rsmodified+11 -2
| @@ -166,10 +166,15 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 166 | 166 | // (spec 5.11.10/5.11.11, one symbol group per superblock). Refuse |
| 167 | 167 | // before desyncing rather than silently miscode, the same pattern as |
| 168 | 168 | // the CDEF/TxMode::Select refusals above. |
| 169 | - if header.allow_screen_content_tools { | |
| 169 | + // Key frames now consume (not reconstruct) palette/intrabc syntax | |
| 170 | + // via read_intra_mode, so the arithmetic decoder stays in sync; | |
| 171 | + // decode_inter_block/decode_inter_block8's intra-sub-block branches | |
| 172 | + // still have no such wiring, so a non-key frame with the bit set | |
| 173 | + // still desyncs and must refuse. | |
| 174 | + if header.frame_type != FrameType::Key && header.allow_screen_content_tools { | |
| 170 | 175 | return Err(Error::unsupported( |
| 171 | 176 | "AV1 decode_stream", |
| 172 | - "a frame with allow_screen_content_tools set (this decoder never reads intrabc/palette_mode_info)", | |
| 177 | + "a non-key frame with allow_screen_content_tools set (this decoder's inter path never reads intrabc/palette_mode_info)", | |
| 173 | 178 | )); |
| 174 | 179 | } |
| 175 | 180 | if header.delta.q_present || header.delta.lf_present { |
| @@ -313,6 +318,8 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 313 | 318 | initial_cdfs, |
| 314 | 319 | header.tx_mode == TxMode::Select, |
| 315 | 320 | header.reduced_tx_set, |
| 321 | + header.allow_screen_content_tools, | |
| 322 | + header.allow_intrabc, | |
| 316 | 323 | )?; |
| 317 | 324 | // A key frame codes no inter blocks -- its own saved motion |
| 318 | 325 | // field has no cells set, matching libaom's own "intra frame |
| @@ -535,6 +542,8 @@ mod tests { | ||
| 535 | 542 | false, |
| 536 | 543 | // Our own encoder always writes `reduced_tx_set: true`. |
| 537 | 544 | true, |
| 545 | + false, | |
| 546 | + false, | |
| 538 | 547 | ) |
| 539 | 548 | .unwrap(); |
| 540 | 549 | let via_stream = decode_stream(&encoded.stream).unwrap(); |