The on-screen palette clamp only applies where the frame's mi dims are known
Browse files at this commitd84ad0071680f6c49d31b144b69805bc70fad734Parent: 4fcbac5- fix
- the on-screen palette clamp only applies where the frame's mi dims are known
1 changed file +11 -0
- crates/ec-av1/src/decode.rs +11 -0
crates/ec-av1/src/decode.rsmodified+11 -0
| @@ -8835,6 +8835,17 @@ fn palette_onscreen( | |||
| 8835 | fctx: &crate::decode::FrameCtx, | 8835 | fctx: &crate::decode::FrameCtx, |
| 8836 | ) -> (usize, usize) { | 8836 | ) -> (usize, usize) { |
| 8837 | let (mi_rows, mi_cols) = fctx.seg_mi_dims.with(|c| c.get()); | 8837 | let (mi_rows, mi_cols) = fctx.seg_mi_dims.with(|c| c.get()); |
| 8838 | + // corner-cut: no mi dims means this is not a real frame decode but the | ||
| 8839 | + // ENCODER's own in-process reconstruct (`FrameCtx::for_encoder`, where | ||
| 8840 | + // `set_segmentation` never runs), whose writer half | ||
| 8841 | + // (`tile::write_color_index_map`) is unclamped too -- the two mirror each | ||
| 8842 | + // other, and clamping only one of them read every map as 1x1. Ceiling: | ||
| 8843 | + // our encoder still writes a full map for a palette block cut by the | ||
| 8844 | + // frame edge, which a conformant decoder reads short. Upgrade path: clamp | ||
| 8845 | + // the writer, publish the mi dims on the encoder's ctx, drop this branch. | ||
| 8846 | + if mi_rows == 0 || mi_cols == 0 { | ||
| 8847 | + return (bw, bh); | ||
| 8848 | + } | ||
| 8838 | ( | 8849 | ( |
| 8839 | bw.min(mi_cols.saturating_sub(mi_c) * MI), | 8850 | bw.min(mi_cols.saturating_sub(mi_c) * MI), |
| 8840 | bh.min(mi_rows.saturating_sub(mi_r) * MI), | 8851 | bh.min(mi_rows.saturating_sub(mi_r) * MI), |