forge
Explore
Log in

Don't you dare go Hollow

Thread allow_screen_content_tools/allow_intrabc through decode_key_frame_tile[_with_cdfs]

Browse files at this commit

818f85da227aec31eb5e64453ca299270590ffe5Ahmet Kaan GümüşParent: b46f7d8
  • feat
    • thread allow_screen_content_tools/allow_intrabc through decode_key_frame_tile[_with_cdfs]
    • narrow whole-frame refusal to non-key frames
Show full message
feat(av1): thread allow_screen_content_tools/allow_intrabc through decode_key_frame_tile[_with_cdfs]; narrow whole-frame refusal to non-key frames

decode_block/decode_leaf8/read_intra_mode already consumed palette/intrabc
syntax on key frames (prior builder). This wires the two bools the rest of
the way: through decode_key_frame_tile_with_cdfs and the public
decode_key_frame_tile wrapper, stream.rs's real production call
(header.allow_screen_content_tools/allow_intrabc), and the 7 test call
sites (false, false -- none of those fixtures use screen content tools).

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