revert "perf(av1): the DPB shares one Arc per picture instead of copying it per slot"
Browse files at this commit173712b7297f57d0e00d9b795e0bd95308fa217dParent: bf707051 changed file +7 -14
- crates/ec-av1/src/stream.rs +7 -14
crates/ec-av1/src/stream.rsmodified+7 -14
| @@ -281,11 +281,7 @@ pub fn decode_stream_with( | |||
| 281 | // luma-only (chroma coincidentally shares this fixture's flat regions) | 281 | // luma-only (chroma coincidentally shares this fixture's flat regions) |
| 282 | // and small-magnitude (the two pictures mostly agree), which is exactly | 282 | // and small-magnitude (the two pictures mostly agree), which is exactly |
| 283 | // what made it look like a rounding bug rather than a wrong reference. | 283 | // what made it look like a rounding bug rather than a wrong reference. |
| 284 | - // lane-perf9: the DPB holds each picture behind an `Arc`, so a frame whose | 284 | + let mut ref_slots: [Option<Picture>; NUM_REF_FRAMES] = std::array::from_fn(|_| None); |
| 285 | - // `refresh_frame_flags` names several slots (a key frame names all eight) | ||
| 286 | - // stores eight pointers instead of eight ~25 MB 4K picture copies. | ||
| 287 | - let mut ref_slots: [Option<std::sync::Arc<Picture>>; NUM_REF_FRAMES] = | ||
| 288 | - std::array::from_fn(|_| None); | ||
| 289 | // lane-av1tmvp: each of the 8 reference slots' own saved temporal motion | 285 | // lane-av1tmvp: each of the 8 reference slots' own saved temporal motion |
| 290 | // field (spec 7.9's per-frame `MotionFieldMvs` storage, libaom | 286 | // field (spec 7.9's per-frame `MotionFieldMvs` storage, libaom |
| 291 | // `cur_frame->mvs`) plus the `OrderHint` the picture in that slot was | 287 | // `cur_frame->mvs`) plus the `OrderHint` the picture in that slot was |
| @@ -375,7 +371,7 @@ pub fn decode_stream_with( | |||
| 375 | bit_depth as u32, | 371 | bit_depth as u32, |
| 376 | ) | 372 | ) |
| 377 | } else { | 373 | } else { |
| 378 | - (*picture).clone() | 374 | + picture |
| 379 | }; | 375 | }; |
| 380 | sink(&output, pictures_decoded, true)?; | 376 | sink(&output, pictures_decoded, true)?; |
| 381 | pictures_shown += 1; | 377 | pictures_shown += 1; |
| @@ -855,7 +851,7 @@ pub fn decode_stream_with( | |||
| 855 | } else { | 851 | } else { |
| 856 | ref_slots | 852 | ref_slots |
| 857 | .get(header.ref_frame_idx[ref_frame - 1] as usize) | 853 | .get(header.ref_frame_idx[ref_frame - 1] as usize) |
| 858 | - .and_then(|slot| slot.as_deref()) | 854 | + .and_then(Option::as_ref) |
| 859 | } | 855 | } |
| 860 | }); | 856 | }); |
| 861 | // spec 7.9's own driver, `av1_setup_motion_field`: only run when | 857 | // spec 7.9's own driver, `av1_setup_motion_field`: only run when |
| @@ -927,9 +923,6 @@ pub fn decode_stream_with( | |||
| 927 | )?; | 923 | )?; |
| 928 | (picture, end_cdfs, motion_field) | 924 | (picture, end_cdfs, motion_field) |
| 929 | }; | 925 | }; |
| 930 | - // lane-perf9: one allocation per decoded frame, then every reference | ||
| 931 | - // slot this frame refreshes (and the sink) shares it. | ||
| 932 | - let picture = std::sync::Arc::new(picture); | ||
| 933 | // lane-lr r4: the Wiener/self-guided pixel filters are wired | 926 | // lane-lr r4: the Wiener/self-guided pixel filters are wired |
| 934 | // (`decode.rs::apply_loop_restoration`) -- no more refusal here, | 927 | // (`decode.rs::apply_loop_restoration`) -- no more refusal here, |
| 935 | // `uses_lr` frames now decode all the way to pixels. | 928 | // `uses_lr` frames now decode all the way to pixels. |
| @@ -1036,16 +1029,16 @@ pub fn decode_stream_with( | |||
| 1036 | let mc_identity = parser | 1029 | let mc_identity = parser |
| 1037 | .sequence_header() | 1030 | .sequence_header() |
| 1038 | .is_some_and(|seq| seq.color_config.matrix_coefficients == 0); | 1031 | .is_some_and(|seq| seq.color_config.matrix_coefficients == 0); |
| 1039 | - Some(crate::film_grain::apply_grain( | 1032 | + crate::film_grain::apply_grain( |
| 1040 | &picture, | 1033 | &picture, |
| 1041 | &header.film_grain, | 1034 | &header.film_grain, |
| 1042 | mc_identity, | 1035 | mc_identity, |
| 1043 | bit_depth as u32, | 1036 | bit_depth as u32, |
| 1044 | - )) | 1037 | + ) |
| 1045 | } else { | 1038 | } else { |
| 1046 | - None | 1039 | + picture |
| 1047 | }; | 1040 | }; |
| 1048 | - sink(output.as_ref().unwrap_or(&picture), pictures_decoded - 1, true)?; | 1041 | + sink(&output, pictures_decoded - 1, true)?; |
| 1049 | pictures_shown += 1; | 1042 | pictures_shown += 1; |
| 1050 | } else { | 1043 | } else { |
| 1051 | // Hidden (alt-ref/forward-key) frames never reach | 1044 | // Hidden (alt-ref/forward-key) frames never reach |