U4: ec-vp9 drop the decode_syntax syntax-only walk: pixels flag, frames_seen, decode_index, syntax_blocks, last_frame_blocks, InterWalk block count and frame index, and the unused inter token walk
Browse files at this commit4288c9226a2226993213ec447d5fb0781f45d1cdParent: 4f6b18f1 changed file +48 -226
- crates/ec-vp9/src/decode.rs +48 -226
crates/ec-vp9/src/decode.rsmodified+48 -226
| @@ -199,13 +199,6 @@ pub struct Decoder { | |||
| 199 | last: LastFrameFacts, | 199 | last: LastFrameFacts, |
| 200 | /// Live only while an inter frame is being parsed. | 200 | /// Live only while an inter frame is being parsed. |
| 201 | iw: Option<InterWalk>, | 201 | iw: Option<InterWalk>, |
| 202 | - /// Frames parsed by `decode_syntax` (the dump's frame index). | ||
| 203 | - frames_seen: usize, | ||
| 204 | - /// Frames decoded by `decode` (the dumps' `frame=` field for this path; | ||
| 205 | - /// `decode_syntax` counts the same way in `frames_seen`). | ||
| 206 | - decode_index: usize, | ||
| 207 | - /// Mode-info blocks parsed in the most recent inter frame (0 otherwise). | ||
| 208 | - syntax_blocks: usize, | ||
| 209 | /// `twd->extend_and_predict_buf`: the per-prediction bordered reference | 202 | /// `twd->extend_and_predict_buf`: the per-prediction bordered reference |
| 210 | /// window built when a block's read leaves the reference frame. | 203 | /// window built when a block's read leaves the reference frame. |
| 211 | mc_scratch: Vec<Sample>, | 204 | mc_scratch: Vec<Sample>, |
| @@ -263,9 +256,6 @@ struct InterWalk { | |||
| 263 | prev_seg: Vec<u8>, | 256 | prev_seg: Vec<u8>, |
| 264 | prev_mvs: Vec<crate::inter::MvRef>, | 257 | prev_mvs: Vec<crate::inter::MvRef>, |
| 265 | tile_col_end: usize, | 258 | tile_col_end: usize, |
| 266 | - frame_index: usize, | ||
| 267 | - /// Mode-info blocks parsed in this frame (the harness's count gate). | ||
| 268 | - blocks: usize, | ||
| 269 | } | 259 | } |
| 270 | 260 | ||
| 271 | impl Decoder { | 261 | impl Decoder { |
| @@ -285,21 +275,12 @@ impl Decoder { | |||
| 285 | prev_seg: Vec::new(), | 275 | prev_seg: Vec::new(), |
| 286 | last: LastFrameFacts::default(), | 276 | last: LastFrameFacts::default(), |
| 287 | iw: None, | 277 | iw: None, |
| 288 | - frames_seen: 0, | ||
| 289 | - decode_index: 0, | ||
| 290 | - syntax_blocks: 0, | ||
| 291 | mc_scratch: Vec::new(), | 278 | mc_scratch: Vec::new(), |
| 292 | mc_temp: vec![0; 64 * 135 + 64 * 64], | 279 | mc_temp: vec![0; 64 * 135 + 64 * 64], |
| 293 | threads: default_threads(), | 280 | threads: default_threads(), |
| 294 | } | 281 | } |
| 295 | } | 282 | } |
| 296 | 283 | ||
| 297 | - /// Mode-info blocks the most recent inter frame parsed; `0` for a keyframe | ||
| 298 | - /// or before any frame. The syntax harness pins this number. | ||
| 299 | - pub fn last_frame_blocks(&self) -> usize { | ||
| 300 | - self.syntax_blocks | ||
| 301 | - } | ||
| 302 | - | ||
| 303 | /// Decode one frame (or one superframe chunk); returns the picture | 284 | /// Decode one frame (or one superframe chunk); returns the picture |
| 304 | /// when a frame is for display. Hidden frames still update state. | 285 | /// when a frame is for display. Hidden frames still update state. |
| 305 | pub fn decode(&mut self, frame: &[u8]) -> Result<Option<Picture>> { | 286 | pub fn decode(&mut self, frame: &[u8]) -> Result<Option<Picture>> { |
| @@ -322,17 +303,13 @@ impl Decoder { | |||
| 322 | }; | 303 | }; |
| 323 | } | 304 | } |
| 324 | validate(&hdr)?; | 305 | validate(&hdr)?; |
| 325 | - // One index per decoded frame (the dumps' `frame=` field), so this | ||
| 326 | - // path and `decode_syntax` label the same frame the same way. | ||
| 327 | - let index = self.decode_index; | ||
| 328 | - self.decode_index += 1; | ||
| 329 | if hdr.frame_type == FrameType::Key { | 306 | if hdr.frame_type == FrameType::Key { |
| 330 | return self.decode_key_frame(&hdr, frame); | 307 | return self.decode_key_frame(&hdr, frame); |
| 331 | } | 308 | } |
| 332 | if hdr.intra_only { | 309 | if hdr.intra_only { |
| 333 | return self.decode_intra_only_frame(&hdr, frame); | 310 | return self.decode_intra_only_frame(&hdr, frame); |
| 334 | } | 311 | } |
| 335 | - self.decode_inter_frame(&hdr, frame, index, true) | 312 | + self.decode_inter_frame(&hdr, frame) |
| 336 | } | 313 | } |
| 337 | 314 | ||
| 338 | /// Decode one key frame through to pixels and refresh every slot. | 315 | /// Decode one key frame through to pixels and refresh every slot. |
| @@ -448,48 +425,10 @@ impl Decoder { | |||
| 448 | Ok(if hdr.show_frame { Some(pic) } else { None }) | 425 | Ok(if hdr.show_frame { Some(pic) } else { None }) |
| 449 | } | 426 | } |
| 450 | 427 | ||
| 451 | - /// Parse one frame's syntax: keyframes decode through to pixels, inter | 428 | + /// Inter-frame decode: compressed header, the tile walk (mode info, MVs, |
| 452 | - /// frames are parsed (headers, mode info, MVs) with no reconstruction and | 429 | + /// tokens, prediction, residual and the loop filter), then the reference |
| 453 | - /// no picture. `decode` still refuses inter frames. | 430 | + /// refresh. |
| 454 | - pub fn decode_syntax(&mut self, frame: &[u8]) -> Result<()> { | 431 | + fn decode_inter_frame(&mut self, hdr: &FrameHeader, frame: &[u8]) -> Result<Option<Picture>> { |
| 455 | - for sub in superframe::split(frame)? { | ||
| 456 | - let index = self.frames_seen; | ||
| 457 | - self.frames_seen += 1; | ||
| 458 | - let hdr = self.parser.parse_frame(sub)?; | ||
| 459 | - if hdr.show_existing_frame { | ||
| 460 | - continue; | ||
| 461 | - } | ||
| 462 | - validate(&hdr)?; | ||
| 463 | - if hdr.frame_type == FrameType::Key { | ||
| 464 | - // Propagate: a corrupt keyframe leaves a half-updated frame | ||
| 465 | - // context, prev-frame MV field and reference slots behind, so | ||
| 466 | - // any inter-frame dump after it would be meaningless evidence. | ||
| 467 | - self.decode_key_frame(&hdr, sub)?; | ||
| 468 | - } else if hdr.intra_only { | ||
| 469 | - // Same body as a keyframe, but an inter frame that refreshes | ||
| 470 | - // only the slots it names. | ||
| 471 | - self.decode_intra_only_frame(&hdr, sub)?; | ||
| 472 | - } else { | ||
| 473 | - self.decode_inter_frame(&hdr, sub, index, false)?; | ||
| 474 | - } | ||
| 475 | - } | ||
| 476 | - Ok(()) | ||
| 477 | - } | ||
| 478 | - | ||
| 479 | - /// Inter-frame decode: compressed header, the tile walk (mode info, MVs | ||
| 480 | - /// and tokens always; prediction, residual and the loop filter when | ||
| 481 | - /// `pixels`), then the reference refresh. | ||
| 482 | - /// | ||
| 483 | - /// `pixels == false` is the syntax-only walk the instrumented harnesses | ||
| 484 | - /// drive: tokens keep the entropy stream aligned, no pixel is touched and | ||
| 485 | - /// the reference slots are left alone. | ||
| 486 | - fn decode_inter_frame( | ||
| 487 | - &mut self, | ||
| 488 | - hdr: &FrameHeader, | ||
| 489 | - frame: &[u8], | ||
| 490 | - index: usize, | ||
| 491 | - pixels: bool, | ||
| 492 | - ) -> Result<Option<Picture>> { | ||
| 493 | let ss_x = hdr.subsampling_x as usize; | 432 | let ss_x = hdr.subsampling_x as usize; |
| 494 | let ss_y = hdr.subsampling_y as usize; | 433 | let ss_y = hdr.subsampling_y as usize; |
| 495 | // Frame-context bookkeeping (spec 6.2 / libvpx `vp9_decode_frame`): | 434 | // Frame-context bookkeeping (spec 6.2 / libvpx `vp9_decode_frame`): |
| @@ -508,24 +447,23 @@ impl Decoder { | |||
| 508 | // format here (`vp9_decodeframe.c:1620-1627`); a reference whose coded | 447 | // format here (`vp9_decodeframe.c:1620-1627`); a reference whose coded |
| 509 | // size differs from this frame's is SCALED during prediction | 448 | // size differs from this frame's is SCALED during prediction |
| 510 | // (`vp9_setup_scale_factors_for_frame` per reference), not refused. | 449 | // (`vp9_setup_scale_factors_for_frame` per reference), not refused. |
| 511 | - if pixels { | 450 | + for (i, name) in ["last", "golden", "altref"].iter().enumerate() { |
| 512 | - for (i, name) in ["last", "golden", "altref"].iter().enumerate() { | 451 | + let slot = hdr.ref_frame_idx[i] as usize; |
| 513 | - let slot = hdr.ref_frame_idx[i] as usize; | 452 | + if slot >= self.refs.len() || hdr.ref_frame_idx[i] >= 8 { |
| 514 | - if slot >= self.refs.len() || hdr.ref_frame_idx[i] >= 8 { | 453 | + return Err(corrupt("vp9 inter names a reference slot past the DPB")); |
| 515 | - return Err(corrupt("vp9 inter names a reference slot past the DPB")); | 454 | + } |
| 516 | - } | 455 | + if self.refs[slot].is_none() { |
| 517 | - if self.refs[slot].is_none() { | 456 | + return Err(Error::corrupt(format!( |
| 518 | - return Err(Error::corrupt(format!( | 457 | + "vp9 inter reference `{name}` names empty slot {slot}" |
| 519 | - "vp9 inter reference `{name}` names empty slot {slot}" | 458 | + ))); |
| 520 | - ))); | ||
| 521 | - } | ||
| 522 | } | 459 | } |
| 523 | - let width = hdr.width as usize; | ||
| 524 | - let height = hdr.height as usize; | ||
| 525 | - let aw = width.div_ceil(64) * 64; | ||
| 526 | - let ah = height.div_ceil(64) * 64; | ||
| 527 | - self.planes = Some(self.frame_planes(aw, ah, hdr.bit_depth, ss_x, ss_y)); | ||
| 528 | } | 460 | } |
| 461 | + let width = hdr.width as usize; | ||
| 462 | + let height = hdr.height as usize; | ||
| 463 | + let aw = width.div_ceil(64) * 64; | ||
| 464 | + let ah = height.div_ceil(64) * 64; | ||
| 465 | + self.planes = Some(self.frame_planes(aw, ah, hdr.bit_depth, ss_x, ss_y)); | ||
| 466 | + | ||
| 529 | 467 | ||
| 530 | let hdr_start = hdr.uncompressed_header_size as usize; | 468 | let hdr_start = hdr.uncompressed_header_size as usize; |
| 531 | let ch = read_compressed_header( | 469 | let ch = read_compressed_header( |
| @@ -578,8 +516,6 @@ impl Decoder { | |||
| 578 | prev_seg: std::mem::take(&mut self.prev_seg), | 516 | prev_seg: std::mem::take(&mut self.prev_seg), |
| 579 | prev_mvs: std::mem::take(&mut self.prev_mvs), | 517 | prev_mvs: std::mem::take(&mut self.prev_mvs), |
| 580 | tile_col_end: mi_cols, | 518 | tile_col_end: mi_cols, |
| 581 | - frame_index: index, | ||
| 582 | - blocks: 0, | ||
| 583 | }); | 519 | }); |
| 584 | 520 | ||
| 585 | let data: &[u8] = frame | 521 | let data: &[u8] = frame |
| @@ -589,7 +525,6 @@ impl Decoder { | |||
| 589 | let job = TileJob { | 525 | let job = TileJob { |
| 590 | hdr, | 526 | hdr, |
| 591 | tx_mode: ch.tx_mode, | 527 | tx_mode: ch.tx_mode, |
| 592 | - pixels, | ||
| 593 | level_of_seg: [[0u8; 2]; 8], | 528 | level_of_seg: [[0u8; 2]; 8], |
| 594 | tiles: &tiles, | 529 | tiles: &tiles, |
| 595 | }; | 530 | }; |
| @@ -620,9 +555,6 @@ impl Decoder { | |||
| 620 | adapt_mv_probs(&mut self.ctx, &pre, &counts, hdr.allow_high_precision_mv); | 555 | adapt_mv_probs(&mut self.ctx, &pre, &counts, hdr.allow_high_precision_mv); |
| 621 | } | 556 | } |
| 622 | 557 | ||
| 623 | - // The walk state is consumed below, so the block count the harness pins | ||
| 624 | - // has to be captured first. | ||
| 625 | - self.syntax_blocks = self.iw.as_ref().map_or(0, |w| w.blocks); | ||
| 626 | let w = self.iw.take().expect("inter walk state"); | 558 | let w = self.iw.take().expect("inter walk state"); |
| 627 | self.prev_mvs = w.mvs; | 559 | self.prev_mvs = w.mvs; |
| 628 | if hdr.segmentation.enabled { | 560 | if hdr.segmentation.enabled { |
| @@ -641,10 +573,6 @@ impl Decoder { | |||
| 641 | self.frame_ctxs[hdr.frame_context_idx as usize] = self.ctx.as_ref().clone(); | 573 | self.frame_ctxs[hdr.frame_context_idx as usize] = self.ctx.as_ref().clone(); |
| 642 | } | 574 | } |
| 643 | 575 | ||
| 644 | - if !pixels { | ||
| 645 | - return Ok(None); | ||
| 646 | - } | ||
| 647 | - | ||
| 648 | // Loop filter post-pass: same extents as the keyframe path, but the | 576 | // Loop filter post-pass: same extents as the keyframe path, but the |
| 649 | // per-cell level comes from the block's own reference and mode class | 577 | // per-cell level comes from the block's own reference and mode class |
| 650 | // (`get_filter_level`, vp9_loopfilter.c:249). | 578 | // (`get_filter_level`, vp9_loopfilter.c:249). |
| @@ -752,7 +680,6 @@ impl Decoder { | |||
| 752 | &mut w.seg_map, counts, | 680 | &mut w.seg_map, counts, |
| 753 | ); | 681 | ); |
| 754 | if let Ok(info) = &info { | 682 | if let Ok(info) = &info { |
| 755 | - w.blocks += 1; | ||
| 756 | for dy in 0..y_mis { | 683 | for dy in 0..y_mis { |
| 757 | for dx in 0..x_mis { | 684 | for dx in 0..x_mis { |
| 758 | let i = (row + dy) * mi.mi_cols + col + dx; | 685 | let i = (row + dy) * mi.mi_cols + col + dx; |
| @@ -768,82 +695,6 @@ impl Decoder { | |||
| 768 | info | 695 | info |
| 769 | } | 696 | } |
| 770 | 697 | ||
| 771 | - /// Tokens for one inter block: same entropy walk as the keyframe path, | ||
| 772 | - /// but no prediction and no residual add. `is_inter` selects the | ||
| 773 | - /// coefficient-probability ref axis. | ||
| 774 | - #[allow(clippy::too_many_arguments)] | ||
| 775 | - fn decode_inter_block_tokens( | ||
| 776 | - &mut self, | ||
| 777 | - r: &mut crate::bool::BoolDecoder, | ||
| 778 | - mi: &MiState, | ||
| 779 | - ectx: &mut [PlaneContexts; 3], | ||
| 780 | - hdr: &FrameHeader, | ||
| 781 | - info: &MiInfo, | ||
| 782 | - row: usize, | ||
| 783 | - col: usize, | ||
| 784 | - sb_type: usize, | ||
| 785 | - bw: usize, | ||
| 786 | - bh: usize, | ||
| 787 | - counts: &mut crate::adapt::Counts, | ||
| 788 | - ) -> Result<usize> { | ||
| 789 | - let (ss_x, ss_y) = plane_ss(hdr, 1); | ||
| 790 | - let n4w = [ | ||
| 791 | - plane_n4_w(bw, 0), | ||
| 792 | - plane_n4_w(bw, ss_x), | ||
| 793 | - plane_n4_w(bw, ss_x), | ||
| 794 | - ]; | ||
| 795 | - let n4h = [ | ||
| 796 | - plane_n4_h(bh, 0), | ||
| 797 | - plane_n4_h(bh, ss_y), | ||
| 798 | - plane_n4_h(bh, ss_y), | ||
| 799 | - ]; | ||
| 800 | - if info.skip { | ||
| 801 | - // dec_reset_skip_context | ||
| 802 | - reset_skip_context(ectx, row, col, sb_type, n4w, n4h, ss_x, ss_y); | ||
| 803 | - return Ok(0); | ||
| 804 | - } | ||
| 805 | - let mb_to_right = ((mi.mi_cols as isize - bw as isize - col as isize) * 64) as i32; | ||
| 806 | - let mb_to_bottom = ((mi.mi_rows as isize - bh as isize - row as isize) * 64) as i32; | ||
| 807 | - let mut eobtotal = 0usize; | ||
| 808 | - for plane in 0..3usize { | ||
| 809 | - let (ss_x, ss_y) = plane_ss(hdr, plane); | ||
| 810 | - let tx_size = if plane == 0 { | ||
| 811 | - info.tx_size | ||
| 812 | - } else { | ||
| 813 | - get_uv_tx_size(info.tx_size, sb_type, ss_x, ss_y) | ||
| 814 | - }; | ||
| 815 | - let step = 1usize << tx_size; | ||
| 816 | - let max_blocks_wide = | ||
| 817 | - (n4w[plane] as i32 + (mb_to_right.min(0) >> (5 + ss_x))).max(0) as usize; | ||
| 818 | - let max_blocks_high = | ||
| 819 | - (n4h[plane] as i32 + (mb_to_bottom.min(0) >> (5 + ss_y))).max(0) as usize; | ||
| 820 | - for brow in (0..max_blocks_high).step_by(step) { | ||
| 821 | - for bcol in (0..max_blocks_wide).step_by(step) { | ||
| 822 | - eobtotal += decode_inter_tx_tokens( | ||
| 823 | - r, | ||
| 824 | - ectx, | ||
| 825 | - hdr, | ||
| 826 | - info, | ||
| 827 | - &self.ctx, | ||
| 828 | - plane, | ||
| 829 | - row, | ||
| 830 | - col, | ||
| 831 | - brow, | ||
| 832 | - bcol, | ||
| 833 | - tx_size, | ||
| 834 | - sb_type, | ||
| 835 | - bw, | ||
| 836 | - bh, | ||
| 837 | - mb_to_right, | ||
| 838 | - mb_to_bottom, counts, | ||
| 839 | - ) | ||
| 840 | - .eob; | ||
| 841 | - } | ||
| 842 | - } | ||
| 843 | - } | ||
| 844 | - Ok(eobtotal) | ||
| 845 | - } | ||
| 846 | - | ||
| 847 | /// `decode_block`'s inter arm with pixels (`vp9_decodeframe.c:990-1044`): | 698 | /// `decode_block`'s inter arm with pixels (`vp9_decodeframe.c:990-1044`): |
| 848 | /// `dec_build_inter_predictors_sb` for the whole block, then | 699 | /// `dec_build_inter_predictors_sb` for the whole block, then |
| 849 | /// `reconstruct_inter_block` per transform block. Intra blocks inside an | 700 | /// `reconstruct_inter_block` per transform block. Intra blocks inside an |
| @@ -1114,7 +965,6 @@ impl Decoder { | |||
| 1114 | let job = TileJob { | 965 | let job = TileJob { |
| 1115 | hdr, | 966 | hdr, |
| 1116 | tx_mode, | 967 | tx_mode, |
| 1117 | - pixels: true, | ||
| 1118 | level_of_seg, | 968 | level_of_seg, |
| 1119 | tiles: &tiles, | 969 | tiles: &tiles, |
| 1120 | }; | 970 | }; |
| @@ -1177,10 +1027,6 @@ impl Decoder { | |||
| 1177 | n4: usize, | 1027 | n4: usize, |
| 1178 | tile_col_start: usize, | 1028 | tile_col_start: usize, |
| 1179 | tx_mode: u8, | 1029 | tx_mode: u8, |
| 1180 | - // Whether this walk reconstructs pixels. Consulted by the inter | ||
| 1181 | - // branch only: a keyframe always reconstructs its intra blocks, and | ||
| 1182 | - // the syntax-only inter walk parses tokens without predicting. | ||
| 1183 | - pixels: bool, | ||
| 1184 | counts: &mut crate::adapt::Counts, | 1030 | counts: &mut crate::adapt::Counts, |
| 1185 | ) -> Result<()> { | 1031 | ) -> Result<()> { |
| 1186 | if row >= mi.mi_rows || col >= mi.mi_cols { | 1032 | if row >= mi.mi_rows || col >= mi.mi_cols { |
| @@ -1228,7 +1074,7 @@ impl Decoder { | |||
| 1228 | 1, | 1074 | 1, |
| 1229 | tile_col_start, | 1075 | tile_col_start, |
| 1230 | tx_mode, | 1076 | tx_mode, |
| 1231 | - pixels, counts, | 1077 | + counts, |
| 1232 | )?; | 1078 | )?; |
| 1233 | } else { | 1079 | } else { |
| 1234 | match partition { | 1080 | match partition { |
| @@ -1246,7 +1092,7 @@ impl Decoder { | |||
| 1246 | n4, | 1092 | n4, |
| 1247 | tile_col_start, | 1093 | tile_col_start, |
| 1248 | tx_mode, | 1094 | tx_mode, |
| 1249 | - pixels, counts, | 1095 | + counts, |
| 1250 | )?, | 1096 | )?, |
| 1251 | 1 => { | 1097 | 1 => { |
| 1252 | self.decode_block( | 1098 | self.decode_block( |
| @@ -1263,7 +1109,7 @@ impl Decoder { | |||
| 1263 | n8, | 1109 | n8, |
| 1264 | tile_col_start, | 1110 | tile_col_start, |
| 1265 | tx_mode, | 1111 | tx_mode, |
| 1266 | - pixels, counts, | 1112 | + counts, |
| 1267 | )?; | 1113 | )?; |
| 1268 | if has_rows { | 1114 | if has_rows { |
| 1269 | self.decode_block( | 1115 | self.decode_block( |
| @@ -1280,7 +1126,7 @@ impl Decoder { | |||
| 1280 | n8, | 1126 | n8, |
| 1281 | tile_col_start, | 1127 | tile_col_start, |
| 1282 | tx_mode, | 1128 | tx_mode, |
| 1283 | - pixels, counts, | 1129 | + counts, |
| 1284 | )?; | 1130 | )?; |
| 1285 | } | 1131 | } |
| 1286 | } | 1132 | } |
| @@ -1299,7 +1145,7 @@ impl Decoder { | |||
| 1299 | n4, | 1145 | n4, |
| 1300 | tile_col_start, | 1146 | tile_col_start, |
| 1301 | tx_mode, | 1147 | tx_mode, |
| 1302 | - pixels, counts, | 1148 | + counts, |
| 1303 | )?; | 1149 | )?; |
| 1304 | if has_cols { | 1150 | if has_cols { |
| 1305 | self.decode_block( | 1151 | self.decode_block( |
| @@ -1316,7 +1162,7 @@ impl Decoder { | |||
| 1316 | n4, | 1162 | n4, |
| 1317 | tile_col_start, | 1163 | tile_col_start, |
| 1318 | tx_mode, | 1164 | tx_mode, |
| 1319 | - pixels, counts, | 1165 | + counts, |
| 1320 | )?; | 1166 | )?; |
| 1321 | } | 1167 | } |
| 1322 | } | 1168 | } |
| @@ -1339,7 +1185,7 @@ impl Decoder { | |||
| 1339 | n8, | 1185 | n8, |
| 1340 | tile_col_start, | 1186 | tile_col_start, |
| 1341 | tx_mode, | 1187 | tx_mode, |
| 1342 | - pixels, counts, | 1188 | + counts, |
| 1343 | )?; | 1189 | )?; |
| 1344 | } | 1190 | } |
| 1345 | } | 1191 | } |
| @@ -1368,7 +1214,6 @@ impl Decoder { | |||
| 1368 | bhl: usize, | 1214 | bhl: usize, |
| 1369 | tile_col_start: usize, | 1215 | tile_col_start: usize, |
| 1370 | tx_mode: u8, | 1216 | tx_mode: u8, |
| 1371 | - pixels: bool, | ||
| 1372 | counts: &mut crate::adapt::Counts, | 1217 | counts: &mut crate::adapt::Counts, |
| 1373 | ) -> Result<()> { | 1218 | ) -> Result<()> { |
| 1374 | let bw = 1 << (bwl - 1); | 1219 | let bw = 1 << (bwl - 1); |
| @@ -1421,39 +1266,27 @@ impl Decoder { | |||
| 1421 | )? | 1266 | )? |
| 1422 | }; | 1267 | }; |
| 1423 | if !intra_frame { | 1268 | if !intra_frame { |
| 1424 | - if pixels { | 1269 | + // Full inter decode: prediction, tokens, residual. The |
| 1425 | - // Full inter decode: prediction, tokens, residual. The | 1270 | + // per-cell loop-filter level is the block's own reference and |
| 1426 | - // per-cell loop-filter level is the block's own reference and | 1271 | + // mode class (`get_filter_level`), so the grids are written |
| 1427 | - // mode class (`get_filter_level`), so the grids are written | 1272 | + // inside the reconstruction rather than from `level_of_seg`. |
| 1428 | - // inside the reconstruction rather than from `level_of_seg`. | 1273 | + let became_skip = self.reconstruct_inter_pixels( |
| 1429 | - let became_skip = self.reconstruct_inter_pixels( | 1274 | + r, |
| 1430 | - r, | 1275 | + ectx, |
| 1431 | - ectx, | 1276 | + grids, |
| 1432 | - grids, | 1277 | + hdr, |
| 1433 | - hdr, | 1278 | + &info, |
| 1434 | - &info, | 1279 | + row, |
| 1435 | - row, | 1280 | + col, |
| 1436 | - col, | 1281 | + sb_type, |
| 1437 | - sb_type, | 1282 | + bw, |
| 1438 | - bw, | 1283 | + bh, |
| 1439 | - bh, | 1284 | + mi, |
| 1440 | - mi, | 1285 | + tile_col_start, |
| 1441 | - tile_col_start, counts, | 1286 | + counts, |
| 1442 | - )?; | 1287 | + )?; |
| 1443 | - if became_skip { | 1288 | + if became_skip { |
| 1444 | - info.skip = true; | 1289 | + info.skip = true; |
| 1445 | - } | ||
| 1446 | - } else { | ||
| 1447 | - // Inter syntax only: tokens keep the entropy stream aligned, | ||
| 1448 | - // the block lands in the mode grid, and no pixel is touched. | ||
| 1449 | - let eobtotal = | ||
| 1450 | - self.decode_inter_block_tokens(r, mi, ectx, hdr, &info, row, col, sb_type, bw, bh, counts)?; | ||
| 1451 | - // libvpx decode_block: an inter block of 8x8 or larger with no | ||
| 1452 | - // coefficients becomes skip (`mi->skip = 1`), which the skip | ||
| 1453 | - // and tx contexts of later blocks then read. | ||
| 1454 | - if sb_type >= 3 && !info.skip && eobtotal == 0 { | ||
| 1455 | - info.skip = true; | ||
| 1456 | - } | ||
| 1457 | } | 1290 | } |
| 1458 | for dy in 0..y_mis { | 1291 | for dy in 0..y_mis { |
| 1459 | for dx in 0..x_mis { | 1292 | for dx in 0..x_mis { |
| @@ -2121,8 +1954,6 @@ fn interp_filter_of(hdr: &FrameHeader) -> u8 { | |||
| 2121 | struct TileJob<'a> { | 1954 | struct TileJob<'a> { |
| 2122 | hdr: &'a FrameHeader, | 1955 | hdr: &'a FrameHeader, |
| 2123 | tx_mode: u8, | 1956 | tx_mode: u8, |
| 2124 | - /// Whether the walk reconstructs pixels (see `decode_partition`). | ||
| 2125 | - pixels: bool, | ||
| 2126 | /// Loop-filter level per segment (keyframes; inter walks pass zeros). | 1957 | /// Loop-filter level per segment (keyframes; inter walks pass zeros). |
| 2127 | level_of_seg: [[u8; 2]; 8], | 1958 | level_of_seg: [[u8; 2]; 8], |
| 2128 | /// Tile payloads in bitstream order: `tiles[tile_row * tile_cols + tile_col]`. | 1959 | /// Tile payloads in bitstream order: `tiles[tile_row * tile_cols + tile_col]`. |
| @@ -2304,9 +2135,6 @@ impl Decoder { | |||
| 2304 | copy_plane_cols(dst, src, lo, hi, hi == mi_cols); | 2135 | copy_plane_cols(dst, src, lo, hi, hi == mi_cols); |
| 2305 | } | 2136 | } |
| 2306 | } | 2137 | } |
| 2307 | - if let (Some(dst), Some(src)) = (self.iw.as_mut(), wk.iw.as_ref()) { | ||
| 2308 | - dst.blocks += src.blocks; | ||
| 2309 | - } | ||
| 2310 | if let Some(p) = wk.planes.take() { | 2138 | if let Some(p) = wk.planes.take() { |
| 2311 | self.recycle_planes(p); | 2139 | self.recycle_planes(p); |
| 2312 | } | 2140 | } |
| @@ -2370,7 +2198,6 @@ impl Decoder { | |||
| 2370 | 4, | 2198 | 4, |
| 2371 | col_lo, | 2199 | col_lo, |
| 2372 | job.tx_mode, | 2200 | job.tx_mode, |
| 2373 | - job.pixels, | ||
| 2374 | counts, | 2201 | counts, |
| 2375 | )?; | 2202 | )?; |
| 2376 | } | 2203 | } |
| @@ -2407,12 +2234,7 @@ impl Decoder { | |||
| 2407 | prev_seg: w.prev_seg.clone(), | 2234 | prev_seg: w.prev_seg.clone(), |
| 2408 | prev_mvs: w.prev_mvs.clone(), | 2235 | prev_mvs: w.prev_mvs.clone(), |
| 2409 | tile_col_end: w.tile_col_end, | 2236 | tile_col_end: w.tile_col_end, |
| 2410 | - frame_index: w.frame_index, | ||
| 2411 | - blocks: 0, | ||
| 2412 | }), | 2237 | }), |
| 2413 | - frames_seen: self.frames_seen, | ||
| 2414 | - decode_index: self.decode_index, | ||
| 2415 | - syntax_blocks: 0, | ||
| 2416 | mc_scratch: Vec::new(), | 2238 | mc_scratch: Vec::new(), |
| 2417 | mc_temp: vec![0; 64 * 135 + 64 * 64], | 2239 | mc_temp: vec![0; 64 * 135 + 64 * 64], |
| 2418 | threads: 1, | 2240 | threads: 1, |