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(
35393539 loop_filter: &LoopFilterParams,
35403540 tx_select: bool,
35413541 reduced_tx_set: bool,
3542+ allow_screen_content_tools: bool,
3543+ allow_intrabc: bool,
35423544 ) -> Result<Picture> {
35433545 decode_key_frame_tile_with_cdfs(
35443546 data,
@@ -3554,6 +3556,8 @@ pub fn decode_key_frame_tile(
35543556 None,
35553557 tx_select,
35563558 reduced_tx_set,
3559+ allow_screen_content_tools,
3560+ allow_intrabc,
35573561 )
35583562 .map(|(picture, _)| picture)
35593563 }
@@ -3580,6 +3584,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
35803584 initial_cdfs: Option<Cdfs>,
35813585 tx_select: bool,
35823586 reduced_tx_set: bool,
3587+ allow_screen_content_tools: bool,
3588+ allow_intrabc: bool,
35833589 ) -> Result<(Picture, Cdfs)> {
35843590 if mi_cols == 0 || mi_rows == 0 {
35853591 return Err(unsupported("a frame with no mode-info grid"));
@@ -9388,6 +9394,8 @@ mod tests {
93889394 &LoopFilterParams::default(),
93899395 false,
93909396 true,
9397+ false,
9398+ false,
93919399 )
93929400 .is_err()
93939401 );
@@ -9430,6 +9438,8 @@ mod tests {
94309438 &LoopFilterParams::default(),
94319439 false,
94329440 true,
9441+ false,
9442+ false,
94339443 )
94349444 .unwrap();
94359445 assert_eq!(decoded.width, w, "{w}x{h}: decoded width");
@@ -9513,6 +9523,8 @@ mod tests {
95139523 &LoopFilterParams::default(),
95149524 false,
95159525 true,
9526+ false,
9527+ false,
95169528 )
95179529 .unwrap();
95189530 assert!(
@@ -9698,6 +9710,8 @@ mod tests {
96989710 &LoopFilterParams::default(),
96999711 false,
97009712 true,
9713+ false,
9714+ false,
97019715 )
97029716 .unwrap();
97039717 assert_eq!(ours.y, ffmpeg_decoded.y, "{width}x{height}: luma vs ffmpeg");
@@ -9770,6 +9784,8 @@ mod tests {
97709784 &LoopFilterParams::default(),
97719785 false,
97729786 true,
9787+ false,
9788+ false,
97739789 )
97749790 .unwrap();
97759791 assert_eq!(
@@ -10073,6 +10089,8 @@ mod tests {
1007310089 &LoopFilterParams::default(),
1007410090 false,
1007510091 true,
10092+ false,
10093+ false,
1007610094 )
1007710095 .unwrap();
1007810096 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>> {
166166 // (spec 5.11.10/5.11.11, one symbol group per superblock). Refuse
167167 // before desyncing rather than silently miscode, the same pattern as
168168 // 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 {
170175 return Err(Error::unsupported(
171176 "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)",
173178 ));
174179 }
175180 if header.delta.q_present || header.delta.lf_present {
@@ -313,6 +318,8 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
313318 initial_cdfs,
314319 header.tx_mode == TxMode::Select,
315320 header.reduced_tx_set,
321+ header.allow_screen_content_tools,
322+ header.allow_intrabc,
316323 )?;
317324 // A key frame codes no inter blocks -- its own saved motion
318325 // field has no cells set, matching libaom's own "intra frame
@@ -535,6 +542,8 @@ mod tests {
535542 false,
536543 // Our own encoder always writes `reduced_tx_set: true`.
537544 true,
545+ false,
546+ false,
538547 )
539548 .unwrap();
540549 let via_stream = decode_stream(&encoded.stream).unwrap();