Reference planes borrow the DPB picture instead of copying it
Browse files at this commitc42b240352977b878bbc6cf578f5b2c6ab4891f4Parent: 16ae97f- perf
- reference planes borrow the DPB picture instead of copying it
1 changed file +168 -169
- crates/ec-av1/src/decode.rs +168 -169
crates/ec-av1/src/decode.rsmodified+168 -169
| @@ -7247,7 +7247,7 @@ fn tx_size_context_rect( | |||
| 7247 | } | 7247 | } |
| 7248 | 7248 | ||
| 7249 | /// [`cfl_ac_q3`] for a true `bw`x`bh` rect strip (lane-intradisp r1). | 7249 | /// [`cfl_ac_q3`] for a true `bw`x`bh` rect strip (lane-intradisp r1). |
| 7250 | -fn cfl_ac_q3_rect(y: &PlaneBuf, px: usize, py: usize, bw: usize, bh: usize) -> Vec<i32> { | 7250 | +fn cfl_ac_q3_rect(y: &PlaneBuf<'_>, px: usize, py: usize, bw: usize, bh: usize) -> Vec<i32> { |
| 7251 | let (cw, ch) = (bw / 2, bh / 2); | 7251 | let (cw, ch) = (bw / 2, bh / 2); |
| 7252 | let mut ac = vec![0i32; cw * ch]; | 7252 | let mut ac = vec![0i32; cw * ch]; |
| 7253 | let mut sum = 0i32; | 7253 | let mut sum = 0i32; |
| @@ -7351,9 +7351,9 @@ fn decode_rect_split( | |||
| 7351 | tx_w: usize, | 7351 | tx_w: usize, |
| 7352 | tx_h: usize, | 7352 | tx_h: usize, |
| 7353 | m: &RectStripModes, | 7353 | m: &RectStripModes, |
| 7354 | - y: &mut PlaneBuf, | 7354 | + y: &mut PlaneBuf<'static>, |
| 7355 | - u: &mut PlaneBuf, | 7355 | + u: &mut PlaneBuf<'static>, |
| 7356 | - v: &mut PlaneBuf, | 7356 | + v: &mut PlaneBuf<'static>, |
| 7357 | base_q_idx: u8, | 7357 | base_q_idx: u8, |
| 7358 | reduced_tx_set: bool, fctx: &crate::decode::FrameCtx, | 7358 | reduced_tx_set: bool, fctx: &crate::decode::FrameCtx, |
| 7359 | ) -> Result<()> { | 7359 | ) -> Result<()> { |
| @@ -7980,9 +7980,9 @@ fn decode_intra_rect_in_inter( | |||
| 7980 | // `(PARTITION_HORZ_4, is_chroma_reference)` when this strip is one of the | 7980 | // `(PARTITION_HORZ_4, is_chroma_reference)` when this strip is one of the |
| 7981 | // four 16x4 / 4x16 strips of a 16x16-level 1:4 partition (lane-intra16x4). | 7981 | // four 16x4 / 4x16 strips of a 16x16-level 1:4 partition (lane-intra16x4). |
| 7982 | strip16: Option<(bool, bool)>, | 7982 | strip16: Option<(bool, bool)>, |
| 7983 | - y: &mut PlaneBuf, | 7983 | + y: &mut PlaneBuf<'static>, |
| 7984 | - u: &mut PlaneBuf, | 7984 | + u: &mut PlaneBuf<'static>, |
| 7985 | - v: &mut PlaneBuf, | 7985 | + v: &mut PlaneBuf<'static>, |
| 7986 | base_q_idx: u8, fctx: &crate::decode::FrameCtx, | 7986 | base_q_idx: u8, fctx: &crate::decode::FrameCtx, |
| 7987 | ) -> Result<()> { | 7987 | ) -> Result<()> { |
| 7988 | // `at` is in MI units (the inter path's own unit since lane-inter4); | 7988 | // `at` is in MI units (the inter path's own unit since lane-inter4); |
| @@ -8533,9 +8533,9 @@ fn decode_block_rect( | |||
| 8533 | at: (usize, usize), | 8533 | at: (usize, usize), |
| 8534 | bw: usize, | 8534 | bw: usize, |
| 8535 | bh: usize, | 8535 | bh: usize, |
| 8536 | - y: &mut PlaneBuf, | 8536 | + y: &mut PlaneBuf<'static>, |
| 8537 | - u: &mut PlaneBuf, | 8537 | + u: &mut PlaneBuf<'static>, |
| 8538 | - v: &mut PlaneBuf, | 8538 | + v: &mut PlaneBuf<'static>, |
| 8539 | enable_filter_intra: bool, | 8539 | enable_filter_intra: bool, |
| 8540 | allow_screen_content_tools: bool, | 8540 | allow_screen_content_tools: bool, |
| 8541 | base_q_idx: u8, | 8541 | base_q_idx: u8, |
| @@ -8989,9 +8989,9 @@ fn decode_leaf_rect( | |||
| 8989 | bw: usize, | 8989 | bw: usize, |
| 8990 | bh: usize, | 8990 | bh: usize, |
| 8991 | prev_leaf: Option<((usize, usize), usize)>, | 8991 | prev_leaf: Option<((usize, usize), usize)>, |
| 8992 | - y: &mut PlaneBuf, | 8992 | + y: &mut PlaneBuf<'static>, |
| 8993 | - u: &mut PlaneBuf, | 8993 | + u: &mut PlaneBuf<'static>, |
| 8994 | - v: &mut PlaneBuf, | 8994 | + v: &mut PlaneBuf<'static>, |
| 8995 | enable_filter_intra: bool, | 8995 | enable_filter_intra: bool, |
| 8996 | allow_screen_content_tools: bool, | 8996 | allow_screen_content_tools: bool, |
| 8997 | base_q_idx: u8, | 8997 | base_q_idx: u8, |
| @@ -9329,9 +9329,9 @@ fn decode_block_rect4( | |||
| 9329 | bw: usize, | 9329 | bw: usize, |
| 9330 | bh: usize, | 9330 | bh: usize, |
| 9331 | prev_strip: Option<((usize, usize), usize)>, | 9331 | prev_strip: Option<((usize, usize), usize)>, |
| 9332 | - y: &mut PlaneBuf, | 9332 | + y: &mut PlaneBuf<'static>, |
| 9333 | - u: &mut PlaneBuf, | 9333 | + u: &mut PlaneBuf<'static>, |
| 9334 | - v: &mut PlaneBuf, | 9334 | + v: &mut PlaneBuf<'static>, |
| 9335 | enable_filter_intra: bool, | 9335 | enable_filter_intra: bool, |
| 9336 | allow_screen_content_tools: bool, | 9336 | allow_screen_content_tools: bool, |
| 9337 | base_q_idx: u8, | 9337 | base_q_idx: u8, |
| @@ -9798,9 +9798,9 @@ fn decode_rect4_16( | |||
| 9798 | neighbours: &mut Neighbours, | 9798 | neighbours: &mut Neighbours, |
| 9799 | at16: (usize, usize), | 9799 | at16: (usize, usize), |
| 9800 | horz: bool, | 9800 | horz: bool, |
| 9801 | - y: &mut PlaneBuf, | 9801 | + y: &mut PlaneBuf<'static>, |
| 9802 | - u: &mut PlaneBuf, | 9802 | + u: &mut PlaneBuf<'static>, |
| 9803 | - v: &mut PlaneBuf, | 9803 | + v: &mut PlaneBuf<'static>, |
| 9804 | enable_filter_intra: bool, | 9804 | enable_filter_intra: bool, |
| 9805 | allow_screen_content_tools: bool, | 9805 | allow_screen_content_tools: bool, |
| 9806 | base_q_idx: u8, | 9806 | base_q_idx: u8, |
| @@ -9874,9 +9874,9 @@ fn decode_rect4_16_strip( | |||
| 9874 | horz: bool, | 9874 | horz: bool, |
| 9875 | has_chroma: bool, | 9875 | has_chroma: bool, |
| 9876 | prev: Option<((usize, usize), usize)>, | 9876 | prev: Option<((usize, usize), usize)>, |
| 9877 | - y: &mut PlaneBuf, | 9877 | + y: &mut PlaneBuf<'static>, |
| 9878 | - u: &mut PlaneBuf, | 9878 | + u: &mut PlaneBuf<'static>, |
| 9879 | - v: &mut PlaneBuf, | 9879 | + v: &mut PlaneBuf<'static>, |
| 9880 | enable_filter_intra: bool, | 9880 | enable_filter_intra: bool, |
| 9881 | allow_screen_content_tools: bool, | 9881 | allow_screen_content_tools: bool, |
| 9882 | base_q_idx: u8, | 9882 | base_q_idx: u8, |
| @@ -10376,9 +10376,9 @@ fn decode_block_rect64( | |||
| 10376 | at: (usize, usize), | 10376 | at: (usize, usize), |
| 10377 | bw: usize, | 10377 | bw: usize, |
| 10378 | bh: usize, | 10378 | bh: usize, |
| 10379 | - y: &mut PlaneBuf, | 10379 | + y: &mut PlaneBuf<'static>, |
| 10380 | - u: &mut PlaneBuf, | 10380 | + u: &mut PlaneBuf<'static>, |
| 10381 | - v: &mut PlaneBuf, | 10381 | + v: &mut PlaneBuf<'static>, |
| 10382 | enable_filter_intra: bool, | 10382 | enable_filter_intra: bool, |
| 10383 | allow_screen_content_tools: bool, | 10383 | allow_screen_content_tools: bool, |
| 10384 | base_q_idx: u8, | 10384 | base_q_idx: u8, |
| @@ -11296,7 +11296,7 @@ fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) { | |||
| 11296 | /// 4:2:0 to Q3 (`(a+b+c+d) << 1`, each 2x2 group), then block-average | 11296 | /// 4:2:0 to Q3 (`(a+b+c+d) << 1`, each 2x2 group), then block-average |
| 11297 | /// subtracted (`round_offset = num_pel/2`, right-shifted by `log2(num_pel)`) | 11297 | /// subtracted (`round_offset = num_pel/2`, right-shifted by `log2(num_pel)`) |
| 11298 | /// to give the AC values [`cfl_scaled`] scales by alpha. | 11298 | /// to give the AC values [`cfl_scaled`] scales by alpha. |
| 11299 | -fn cfl_ac_q3(y: &PlaneBuf, px: usize, py: usize, side: usize) -> Vec<i32> { | 11299 | +fn cfl_ac_q3(y: &PlaneBuf<'_>, px: usize, py: usize, side: usize) -> Vec<i32> { |
| 11300 | let cside = side / 2; | 11300 | let cside = side / 2; |
| 11301 | let mut ac = vec![0i32; cside * cside]; | 11301 | let mut ac = vec![0i32; cside * cside]; |
| 11302 | let mut sum = 0i32; | 11302 | let mut sum = 0i32; |
| @@ -11349,7 +11349,7 @@ fn stage_dump_idx() -> usize { | |||
| 11349 | PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst).saturating_sub(1) | 11349 | PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst).saturating_sub(1) |
| 11350 | } | 11350 | } |
| 11351 | 11351 | ||
| 11352 | -fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { | 11352 | +fn dump_stage16(var: &str, y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>, fw: usize, fh: usize) { |
| 11353 | use std::io::Write; | 11353 | use std::io::Write; |
| 11354 | // lane-sbrect10 r2 / lane-cdef r1 (one shared helper): index the dump by | 11354 | // lane-sbrect10 r2 / lane-cdef r1 (one shared helper): index the dump by |
| 11355 | // decode-order picture like EC_AV1_PREFILT_DUMP already does -- a fixed | 11355 | // decode-order picture like EC_AV1_PREFILT_DUMP already does -- a fixed |
| @@ -11385,7 +11385,7 @@ fn dump_stage_idx(var: &str) -> usize { | |||
| 11385 | i | 11385 | i |
| 11386 | } | 11386 | } |
| 11387 | 11387 | ||
| 11388 | -fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { | 11388 | +fn dump_stage(var: &str, y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { |
| 11389 | use std::io::Write; | 11389 | use std::io::Write; |
| 11390 | if let Ok(path) = crate::envflags::var(var) | 11390 | if let Ok(path) = crate::envflags::var(var) |
| 11391 | && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) | 11391 | && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) |
| @@ -11398,8 +11398,8 @@ fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { | |||
| 11398 | } | 11398 | } |
| 11399 | 11399 | ||
| 11400 | #[derive(Clone)] | 11400 | #[derive(Clone)] |
| 11401 | -struct PlaneBuf { | 11401 | +struct PlaneBuf<'a> { |
| 11402 | - data: Vec<u16>, | 11402 | + data: std::borrow::Cow<'a, [u16]>, |
| 11403 | width: usize, | 11403 | width: usize, |
| 11404 | height: usize, | 11404 | height: usize, |
| 11405 | /// The frame's true, decodable extent in this plane's own units — past | 11405 | /// The frame's true, decodable extent in this plane's own units — past |
| @@ -11432,9 +11432,9 @@ struct PlaneBuf { | |||
| 11432 | /// (lane-av1refs: the same "empty slot" case `GOLDEN_FRAME` already | 11432 | /// (lane-av1refs: the same "empty slot" case `GOLDEN_FRAME` already |
| 11433 | /// refused by name, now generic across `LAST2`/`LAST3`/`GOLDEN`/`BWDREF`/ | 11433 | /// refused by name, now generic across `LAST2`/`LAST3`/`GOLDEN`/`BWDREF`/ |
| 11434 | /// `ALTREF2`/`ALTREF`). | 11434 | /// `ALTREF2`/`ALTREF`). |
| 11435 | -type RefSlots<'a> = [Option<(&'a PlaneBuf, &'a PlaneBuf, &'a PlaneBuf)>; 8]; | 11435 | +type RefSlots<'a> = [Option<(&'a PlaneBuf<'a>, &'a PlaneBuf<'a>, &'a PlaneBuf<'a>)>; 8]; |
| 11436 | 11436 | ||
| 11437 | -impl PlaneBuf { | 11437 | +impl PlaneBuf<'_> { |
| 11438 | /// Sets this plane's own tile pixel origin ([`Self::tile_x0`]/ | 11438 | /// Sets this plane's own tile pixel origin ([`Self::tile_x0`]/ |
| 11439 | /// [`Self::tile_y0`]) before that tile's own superblock walk. `x0`/`y0` | 11439 | /// [`Self::tile_y0`]) before that tile's own superblock walk. `x0`/`y0` |
| 11440 | /// are already in this plane's own units (luma pixels for `y`, chroma | 11440 | /// are already in this plane's own units (luma pixels for `y`, chroma |
| @@ -11616,7 +11616,7 @@ impl PlaneBuf { | |||
| 11616 | base = (base + cfl_scaled(alpha_q3, ac_q3[idx])).clamp(0, sample_max(fctx)); | 11616 | base = (base + cfl_scaled(alpha_q3, ac_q3[idx])).clamp(0, sample_max(fctx)); |
| 11617 | } | 11617 | } |
| 11618 | let sample = (base + residual[idx]).clamp(0, sample_max(fctx)) as u16; | 11618 | let sample = (base + residual[idx]).clamp(0, sample_max(fctx)) as u16; |
| 11619 | - self.data[(y + row) * self.width + x + col] = sample; | 11619 | + self.data.to_mut()[(y + row) * self.width + x + col] = sample; |
| 11620 | } | 11620 | } |
| 11621 | } | 11621 | } |
| 11622 | } | 11622 | } |
| @@ -11723,7 +11723,7 @@ impl PlaneBuf { | |||
| 11723 | base = (base + cfl_scaled(alpha_q3, ac_q3[idx])).clamp(0, sample_max(fctx)); | 11723 | base = (base + cfl_scaled(alpha_q3, ac_q3[idx])).clamp(0, sample_max(fctx)); |
| 11724 | } | 11724 | } |
| 11725 | let sample = (base + residual[idx]).clamp(0, sample_max(fctx)) as u16; | 11725 | let sample = (base + residual[idx]).clamp(0, sample_max(fctx)) as u16; |
| 11726 | - self.data[(y + row) * self.width + x + col] = sample; | 11726 | + self.data.to_mut()[(y + row) * self.width + x + col] = sample; |
| 11727 | } | 11727 | } |
| 11728 | } | 11728 | } |
| 11729 | } | 11729 | } |
| @@ -11746,7 +11746,7 @@ fn read_plane( | |||
| 11746 | predict_mode: usize, | 11746 | predict_mode: usize, |
| 11747 | angle_delta: i32, | 11747 | angle_delta: i32, |
| 11748 | reach: Reach, | 11748 | reach: Reach, |
| 11749 | - plane: &mut PlaneBuf, | 11749 | + plane: &mut PlaneBuf<'static>, |
| 11750 | x: usize, | 11750 | x: usize, |
| 11751 | y: usize, | 11751 | y: usize, |
| 11752 | side: usize, | 11752 | side: usize, |
| @@ -11886,9 +11886,9 @@ fn decode_block( | |||
| 11886 | chroma_tx: usize, | 11886 | chroma_tx: usize, |
| 11887 | scans: (&[u16], &[u16]), | 11887 | scans: (&[u16], &[u16]), |
| 11888 | cfl: bool, | 11888 | cfl: bool, |
| 11889 | - y: &mut PlaneBuf, | 11889 | + y: &mut PlaneBuf<'static>, |
| 11890 | - u: &mut PlaneBuf, | 11890 | + u: &mut PlaneBuf<'static>, |
| 11891 | - v: &mut PlaneBuf, | 11891 | + v: &mut PlaneBuf<'static>, |
| 11892 | base_q_idx: u8, | 11892 | base_q_idx: u8, |
| 11893 | enable_filter_intra: bool, | 11893 | enable_filter_intra: bool, |
| 11894 | allow_screen_content_tools: bool, | 11894 | allow_screen_content_tools: bool, |
| @@ -12631,9 +12631,9 @@ fn decode_block_128rect( | |||
| 12631 | at: (usize, usize), | 12631 | at: (usize, usize), |
| 12632 | bw: usize, | 12632 | bw: usize, |
| 12633 | bh: usize, | 12633 | bh: usize, |
| 12634 | - y: &mut PlaneBuf, | 12634 | + y: &mut PlaneBuf<'static>, |
| 12635 | - u: &mut PlaneBuf, | 12635 | + u: &mut PlaneBuf<'static>, |
| 12636 | - v: &mut PlaneBuf, | 12636 | + v: &mut PlaneBuf<'static>, |
| 12637 | base_q_idx: u8, | 12637 | base_q_idx: u8, |
| 12638 | enable_filter_intra: bool, | 12638 | enable_filter_intra: bool, |
| 12639 | allow_screen_content_tools: bool, | 12639 | allow_screen_content_tools: bool, |
| @@ -12952,9 +12952,9 @@ fn decode_leaf8( | |||
| 12952 | leaf_mi: (usize, usize), | 12952 | leaf_mi: (usize, usize), |
| 12953 | scans: (&[u16], &[u16]), | 12953 | scans: (&[u16], &[u16]), |
| 12954 | prev_leaf: Option<((usize, usize), usize)>, | 12954 | prev_leaf: Option<((usize, usize), usize)>, |
| 12955 | - y: &mut PlaneBuf, | 12955 | + y: &mut PlaneBuf<'static>, |
| 12956 | - u: &mut PlaneBuf, | 12956 | + u: &mut PlaneBuf<'static>, |
| 12957 | - v: &mut PlaneBuf, | 12957 | + v: &mut PlaneBuf<'static>, |
| 12958 | base_q_idx: u8, | 12958 | base_q_idx: u8, |
| 12959 | enable_filter_intra: bool, | 12959 | enable_filter_intra: bool, |
| 12960 | allow_screen_content_tools: bool, | 12960 | allow_screen_content_tools: bool, |
| @@ -13669,9 +13669,9 @@ fn decode_leaf_split4( | |||
| 13669 | leaf_mi: (usize, usize), | 13669 | leaf_mi: (usize, usize), |
| 13670 | scan4: &[u16], | 13670 | scan4: &[u16], |
| 13671 | prev_leaf: Option<((usize, usize), usize)>, | 13671 | prev_leaf: Option<((usize, usize), usize)>, |
| 13672 | - y: &mut PlaneBuf, | 13672 | + y: &mut PlaneBuf<'static>, |
| 13673 | - u: &mut PlaneBuf, | 13673 | + u: &mut PlaneBuf<'static>, |
| 13674 | - v: &mut PlaneBuf, | 13674 | + v: &mut PlaneBuf<'static>, |
| 13675 | base_q_idx: u8, | 13675 | base_q_idx: u8, |
| 13676 | enable_filter_intra: bool, | 13676 | enable_filter_intra: bool, |
| 13677 | allow_intrabc: bool, | 13677 | allow_intrabc: bool, |
| @@ -13889,9 +13889,9 @@ fn decode_leaf_rect8( | |||
| 13889 | leaf_mi: (usize, usize), | 13889 | leaf_mi: (usize, usize), |
| 13890 | vert: bool, | 13890 | vert: bool, |
| 13891 | scan4: &[u16], | 13891 | scan4: &[u16], |
| 13892 | - y: &mut PlaneBuf, | 13892 | + y: &mut PlaneBuf<'static>, |
| 13893 | - u: &mut PlaneBuf, | 13893 | + u: &mut PlaneBuf<'static>, |
| 13894 | - v: &mut PlaneBuf, | 13894 | + v: &mut PlaneBuf<'static>, |
| 13895 | base_q_idx: u8, | 13895 | base_q_idx: u8, |
| 13896 | enable_filter_intra: bool, | 13896 | enable_filter_intra: bool, |
| 13897 | allow_intrabc: bool, | 13897 | allow_intrabc: bool, |
| @@ -14398,7 +14398,7 @@ fn cdef_adjust_strength(strength: i32, var: i32) -> i32 { | |||
| 14398 | #[allow(unsafe_code)] | 14398 | #[allow(unsafe_code)] |
| 14399 | fn cdef_filter_block( | 14399 | fn cdef_filter_block( |
| 14400 | src: &[i32], | 14400 | src: &[i32], |
| 14401 | - dst: &mut PlaneBuf, | 14401 | + dst: &mut PlaneBuf<'static>, |
| 14402 | ox: usize, | 14402 | ox: usize, |
| 14403 | oy: usize, | 14403 | oy: usize, |
| 14404 | bw: usize, | 14404 | bw: usize, |
| @@ -14422,7 +14422,7 @@ fn cdef_filter_block( | |||
| 14422 | unsafe { | 14422 | unsafe { |
| 14423 | cdef_simd::filter_block_avx2( | 14423 | cdef_simd::filter_block_avx2( |
| 14424 | src, | 14424 | src, |
| 14425 | - &mut dst.data, | 14425 | + dst.data.to_mut(), |
| 14426 | stride, | 14426 | stride, |
| 14427 | ox, | 14427 | ox, |
| 14428 | oy, | 14428 | oy, |
| @@ -14443,7 +14443,7 @@ fn cdef_filter_block( | |||
| 14443 | } | 14443 | } |
| 14444 | cdef_filter_block_scalar( | 14444 | cdef_filter_block_scalar( |
| 14445 | src, | 14445 | src, |
| 14446 | - &mut dst.data, | 14446 | + dst.data.to_mut(), |
| 14447 | stride, | 14447 | stride, |
| 14448 | ox, | 14448 | ox, |
| 14449 | oy, | 14449 | oy, |
| @@ -14773,9 +14773,9 @@ mod cdef_simd { | |||
| 14773 | /// Ported from libaom's `av1/common/av1_loopfilter.c` (edge/level decision) | 14773 | /// Ported from libaom's `av1/common/av1_loopfilter.c` (edge/level decision) |
| 14774 | /// and `aom_dsp/loopfilter.c` (the `aom_lpf_*` pixel kernels). | 14774 | /// and `aom_dsp/loopfilter.c` (the `aom_lpf_*` pixel kernels). |
| 14775 | fn apply_deblock( | 14775 | fn apply_deblock( |
| 14776 | - y: &mut PlaneBuf, | 14776 | + y: &mut PlaneBuf<'static>, |
| 14777 | - u: &mut PlaneBuf, | 14777 | + u: &mut PlaneBuf<'static>, |
| 14778 | - v: &mut PlaneBuf, | 14778 | + v: &mut PlaneBuf<'static>, |
| 14779 | lf: &LoopFilterParams, | 14779 | lf: &LoopFilterParams, |
| 14780 | n: &Neighbours, | 14780 | n: &Neighbours, |
| 14781 | frame_width: usize, | 14781 | frame_width: usize, |
| @@ -15960,7 +15960,7 @@ fn read_inter_plane_rect( | |||
| 15960 | plane_idx: usize, | 15960 | plane_idx: usize, |
| 15961 | around: (bool, bool, i32), | 15961 | around: (bool, bool, i32), |
| 15962 | tx_mode: usize, | 15962 | tx_mode: usize, |
| 15963 | - plane: &mut PlaneBuf, | 15963 | + plane: &mut PlaneBuf<'static>, |
| 15964 | x: usize, | 15964 | x: usize, |
| 15965 | y: usize, | 15965 | y: usize, |
| 15966 | prediction: &[u16], | 15966 | prediction: &[u16], |
| @@ -16080,7 +16080,7 @@ fn read_inter_luma8( | |||
| 16080 | cdfs: &mut Cdfs, | 16080 | cdfs: &mut Cdfs, |
| 16081 | neighbours: &mut Neighbours, | 16081 | neighbours: &mut Neighbours, |
| 16082 | leaf_mi: (usize, usize), | 16082 | leaf_mi: (usize, usize), |
| 16083 | - y: &mut PlaneBuf, | 16083 | + y: &mut PlaneBuf<'static>, |
| 16084 | px: usize, | 16084 | px: usize, |
| 16085 | py: usize, | 16085 | py: usize, |
| 16086 | pred_y: &[u16], | 16086 | pred_y: &[u16], |
| @@ -17125,7 +17125,7 @@ fn filter_edge16( | |||
| 17125 | /// One plane's worth of spec 7.14: every vertical edge across the plane, | 17125 | /// One plane's worth of spec 7.14: every vertical edge across the plane, |
| 17126 | /// then every horizontal edge (the order the spec and libaom both use). | 17126 | /// then every horizontal edge (the order the spec and libaom both use). |
| 17127 | fn deblock_plane( | 17127 | fn deblock_plane( |
| 17128 | - plane: &mut PlaneBuf, | 17128 | + plane: &mut PlaneBuf<'static>, |
| 17129 | plane_idx: usize, | 17129 | plane_idx: usize, |
| 17130 | lf: &LoopFilterParams, | 17130 | lf: &LoopFilterParams, |
| 17131 | n: &Neighbours, | 17131 | n: &Neighbours, |
| @@ -17185,7 +17185,7 @@ fn deblock_plane( | |||
| 17185 | if let Some((len, level)) = ps[0] { | 17185 | if let Some((len, level)) = ps[0] { |
| 17186 | if ps.iter().all(|p| *p == ps[0]) | 17186 | if ps.iter().all(|p| *p == ps[0]) |
| 17187 | && filter_edge16( | 17187 | && filter_edge16( |
| 17188 | - &mut plane.data, | 17188 | + plane.data.to_mut(), |
| 17189 | y0 * stride + x0, | 17189 | y0 * stride + x0, |
| 17190 | stride, | 17190 | stride, |
| 17191 | true, | 17191 | true, |
| @@ -17201,7 +17201,7 @@ fn deblock_plane( | |||
| 17201 | for (k, p) in ps.iter().enumerate() { | 17201 | for (k, p) in ps.iter().enumerate() { |
| 17202 | if let Some((len, level)) = *p { | 17202 | if let Some((len, level)) = *p { |
| 17203 | filter_edge( | 17203 | filter_edge( |
| 17204 | - &mut plane.data, | 17204 | + plane.data.to_mut(), |
| 17205 | (y0 + 4 * k) * stride + x0, | 17205 | (y0 + 4 * k) * stride + x0, |
| 17206 | stride as isize, | 17206 | stride as isize, |
| 17207 | 1, | 17207 | 1, |
| @@ -17219,7 +17219,7 @@ fn deblock_plane( | |||
| 17219 | eprintln!("VEDGE x0={x0} y0={y0} len={len} level={level}"); | 17219 | eprintln!("VEDGE x0={x0} y0={y0} len={len} level={level}"); |
| 17220 | } | 17220 | } |
| 17221 | filter_edge( | 17221 | filter_edge( |
| 17222 | - &mut plane.data, | 17222 | + plane.data.to_mut(), |
| 17223 | y0 * stride + x0, | 17223 | y0 * stride + x0, |
| 17224 | stride as isize, | 17224 | stride as isize, |
| 17225 | 1, | 17225 | 1, |
| @@ -17242,7 +17242,7 @@ fn deblock_plane( | |||
| 17242 | if let Some((len, level)) = ps[0] { | 17242 | if let Some((len, level)) = ps[0] { |
| 17243 | if ps.iter().all(|p| *p == ps[0]) | 17243 | if ps.iter().all(|p| *p == ps[0]) |
| 17244 | && filter_edge16( | 17244 | && filter_edge16( |
| 17245 | - &mut plane.data, | 17245 | + plane.data.to_mut(), |
| 17246 | y0 * stride + x0, | 17246 | y0 * stride + x0, |
| 17247 | stride, | 17247 | stride, |
| 17248 | false, | 17248 | false, |
| @@ -17258,7 +17258,7 @@ fn deblock_plane( | |||
| 17258 | for (k, p) in ps.iter().enumerate() { | 17258 | for (k, p) in ps.iter().enumerate() { |
| 17259 | if let Some((len, level)) = *p { | 17259 | if let Some((len, level)) = *p { |
| 17260 | filter_edge( | 17260 | filter_edge( |
| 17261 | - &mut plane.data, | 17261 | + plane.data.to_mut(), |
| 17262 | y0 * stride + x0 + 4 * k, | 17262 | y0 * stride + x0 + 4 * k, |
| 17263 | 1, | 17263 | 1, |
| 17264 | stride as isize, | 17264 | stride as isize, |
| @@ -17282,7 +17282,7 @@ fn deblock_plane( | |||
| 17282 | ); | 17282 | ); |
| 17283 | } | 17283 | } |
| 17284 | filter_edge( | 17284 | filter_edge( |
| 17285 | - &mut plane.data, | 17285 | + plane.data.to_mut(), |
| 17286 | y0 * stride + x0, | 17286 | y0 * stride + x0, |
| 17287 | 1, | 17287 | 1, |
| 17288 | stride as isize, | 17288 | stride as isize, |
| @@ -17325,8 +17325,8 @@ fn scratch_empty() -> Vec<u16> { | |||
| 17325 | 17325 | ||
| 17326 | /// A plane's post-deblock snapshot, its samples taken from the pool (every | 17326 | /// A plane's post-deblock snapshot, its samples taken from the pool (every |
| 17327 | /// other field is `usize`). | 17327 | /// other field is `usize`). |
| 17328 | -fn plane_snapshot(p: &PlaneBuf) -> PlaneBuf { | 17328 | +fn plane_snapshot(p: &PlaneBuf<'_>) -> PlaneBuf<'static> { |
| 17329 | - PlaneBuf { data: scratch_from(&p.data), ..*p } | 17329 | + PlaneBuf { data: std::borrow::Cow::Owned(scratch_from(&p.data)), ..*p } |
| 17330 | } | 17330 | } |
| 17331 | 17331 | ||
| 17332 | /// Hands a buffer back to the pool; the capacity is what is worth keeping. | 17332 | /// Hands a buffer back to the pool; the capacity is what is worth keeping. |
| @@ -17335,9 +17335,9 @@ fn scratch_return(v: Vec<u16>) { | |||
| 17335 | } | 17335 | } |
| 17336 | 17336 | ||
| 17337 | fn apply_cdef( | 17337 | fn apply_cdef( |
| 17338 | - y: &mut PlaneBuf, | 17338 | + y: &mut PlaneBuf<'static>, |
| 17339 | - u: &mut PlaneBuf, | 17339 | + u: &mut PlaneBuf<'static>, |
| 17340 | - v: &mut PlaneBuf, | 17340 | + v: &mut PlaneBuf<'static>, |
| 17341 | cdef: &CdefParams, | 17341 | cdef: &CdefParams, |
| 17342 | skip_grid: &Neighbours, | 17342 | skip_grid: &Neighbours, |
| 17343 | // This frame header's own CROPPED luma size, for the straddling-unit | 17343 | // This frame header's own CROPPED luma size, for the straddling-unit |
| @@ -17557,12 +17557,12 @@ fn apply_cdef( | |||
| 17557 | /// CDEF-filtered plane, per `restoration.rs`'s own `lr_sample` doc comment. | 17557 | /// CDEF-filtered plane, per `restoration.rs`'s own `lr_sample` doc comment. |
| 17558 | #[allow(clippy::too_many_arguments)] | 17558 | #[allow(clippy::too_many_arguments)] |
| 17559 | fn apply_loop_restoration( | 17559 | fn apply_loop_restoration( |
| 17560 | - y: &mut PlaneBuf, | 17560 | + y: &mut PlaneBuf<'static>, |
| 17561 | - u: &mut PlaneBuf, | 17561 | + u: &mut PlaneBuf<'static>, |
| 17562 | - v: &mut PlaneBuf, | 17562 | + v: &mut PlaneBuf<'static>, |
| 17563 | - deblocked_y: &PlaneBuf, | 17563 | + deblocked_y: &PlaneBuf<'_>, |
| 17564 | - deblocked_u: &PlaneBuf, | 17564 | + deblocked_u: &PlaneBuf<'_>, |
| 17565 | - deblocked_v: &PlaneBuf, | 17565 | + deblocked_v: &PlaneBuf<'_>, |
| 17566 | lr: &LoopRestorationParams, | 17566 | lr: &LoopRestorationParams, |
| 17567 | grid: &crate::restoration::RestorationGrid, | 17567 | grid: &crate::restoration::RestorationGrid, |
| 17568 | // lane-golomb r8: this frame header's own (cropped) luma size. Loop | 17568 | // lane-golomb r8: this frame header's own (cropped) luma size. Loop |
| @@ -17597,8 +17597,7 @@ fn apply_loop_restoration( | |||
| 17597 | 0, | 17597 | 0, |
| 17598 | &mut out, fctx, | 17598 | &mut out, fctx, |
| 17599 | ); | 17599 | ); |
| 17600 | - std::mem::swap(&mut y.data, &mut out); | 17600 | + scratch_return(std::mem::replace(&mut y.data, std::borrow::Cow::Owned(out)).into_owned()); |
| 17601 | - scratch_return(out); | ||
| 17602 | let mut out = scratch_empty(); | 17601 | let mut out = scratch_empty(); |
| 17603 | crate::restoration::apply_loop_restoration_plane( | 17602 | crate::restoration::apply_loop_restoration_plane( |
| 17604 | &u.data, | 17603 | &u.data, |
| @@ -17613,8 +17612,7 @@ fn apply_loop_restoration( | |||
| 17613 | 1, | 17612 | 1, |
| 17614 | &mut out, fctx, | 17613 | &mut out, fctx, |
| 17615 | ); | 17614 | ); |
| 17616 | - std::mem::swap(&mut u.data, &mut out); | 17615 | + scratch_return(std::mem::replace(&mut u.data, std::borrow::Cow::Owned(out)).into_owned()); |
| 17617 | - scratch_return(out); | ||
| 17618 | let mut out = scratch_empty(); | 17616 | let mut out = scratch_empty(); |
| 17619 | crate::restoration::apply_loop_restoration_plane( | 17617 | crate::restoration::apply_loop_restoration_plane( |
| 17620 | &v.data, | 17618 | &v.data, |
| @@ -17629,8 +17627,7 @@ fn apply_loop_restoration( | |||
| 17629 | 2, | 17627 | 2, |
| 17630 | &mut out, fctx, | 17628 | &mut out, fctx, |
| 17631 | ); | 17629 | ); |
| 17632 | - std::mem::swap(&mut v.data, &mut out); | 17630 | + scratch_return(std::mem::replace(&mut v.data, std::borrow::Cow::Owned(out)).into_owned()); |
| 17633 | - scratch_return(out); | ||
| 17634 | } | 17631 | } |
| 17635 | 17632 | ||
| 17636 | /// Decodes the payload [`crate::tile::sb_coeff_key_frame_tile`] writes, | 17633 | /// Decodes the payload [`crate::tile::sb_coeff_key_frame_tile`] writes, |
| @@ -17995,7 +17992,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 17995 | let (width, height) = (cols32 as usize * BLOCK, rows32 as usize * BLOCK); | 17992 | let (width, height) = (cols32 as usize * BLOCK, rows32 as usize * BLOCK); |
| 17996 | 17993 | ||
| 17997 | let mut y = PlaneBuf { | 17994 | let mut y = PlaneBuf { |
| 17998 | - data: vec![0u16; width * height], | 17995 | + data: std::borrow::Cow::Owned(vec![0u16; width * height]), |
| 17999 | width, | 17996 | width, |
| 18000 | height, | 17997 | height, |
| 18001 | true_width, | 17998 | true_width, |
| @@ -18006,7 +18003,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 18006 | tile_y1: height, | 18003 | tile_y1: height, |
| 18007 | }; | 18004 | }; |
| 18008 | let mut u = PlaneBuf { | 18005 | let mut u = PlaneBuf { |
| 18009 | - data: vec![0u16; width * height / 4], | 18006 | + data: std::borrow::Cow::Owned(vec![0u16; width * height / 4]), |
| 18010 | width: width / 2, | 18007 | width: width / 2, |
| 18011 | height: height / 2, | 18008 | height: height / 2, |
| 18012 | true_width: true_width / 2, | 18009 | true_width: true_width / 2, |
| @@ -18017,7 +18014,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 18017 | tile_y1: height / 2, | 18014 | tile_y1: height / 2, |
| 18018 | }; | 18015 | }; |
| 18019 | let mut v = PlaneBuf { | 18016 | let mut v = PlaneBuf { |
| 18020 | - data: vec![0u16; width * height / 4], | 18017 | + data: std::borrow::Cow::Owned(vec![0u16; width * height / 4]), |
| 18021 | width: width / 2, | 18018 | width: width / 2, |
| 18022 | height: height / 2, | 18019 | height: height / 2, |
| 18023 | true_width: true_width / 2, | 18020 | true_width: true_width / 2, |
| @@ -19893,7 +19890,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 19893 | use std::io::Write; | 19890 | use std::io::Write; |
| 19894 | let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | 19891 | let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); |
| 19895 | if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) { | 19892 | if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) { |
| 19896 | - let narrow = |p: &PlaneBuf| -> Vec<u8> { p.data.iter().map(|&s| s as u8).collect() }; | 19893 | + let narrow = |p: &PlaneBuf<'_>| -> Vec<u8> { p.data.iter().map(|&s| s as u8).collect() }; |
| 19897 | let _ = f.write_all(&narrow(&y)); | 19894 | let _ = f.write_all(&narrow(&y)); |
| 19898 | let _ = f.write_all(&narrow(&u)); | 19895 | let _ = f.write_all(&narrow(&u)); |
| 19899 | let _ = f.write_all(&narrow(&v)); | 19896 | let _ = f.write_all(&narrow(&v)); |
| @@ -19905,7 +19902,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 19905 | use std::io::Write; | 19902 | use std::io::Write; |
| 19906 | static IDX2: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | 19903 | static IDX2: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); |
| 19907 | let idx = IDX2.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | 19904 | let idx = IDX2.fetch_add(1, std::sync::atomic::Ordering::SeqCst); |
| 19908 | - let crop_wide = |plane: &PlaneBuf| -> Vec<u8> { | 19905 | + let crop_wide = |plane: &PlaneBuf<'_>| -> Vec<u8> { |
| 19909 | let mut out = Vec::with_capacity(plane.true_width * plane.true_height); | 19906 | let mut out = Vec::with_capacity(plane.true_width * plane.true_height); |
| 19910 | for row in 0..plane.true_height { | 19907 | for row in 0..plane.true_height { |
| 19911 | out.extend(plane.data[row * plane.width..][..plane.true_width].iter().map(|&s| s as u8)); | 19908 | out.extend(plane.data[row * plane.width..][..plane.true_width].iter().map(|&s| s as u8)); |
| @@ -19967,10 +19964,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 19967 | if let Some((upscaled_w, _)) = superres(fctx) { | 19964 | if let Some((upscaled_w, _)) = superres(fctx) { |
| 19968 | let bd = u32::from(bit_depth(fctx)); | 19965 | let bd = u32::from(bit_depth(fctx)); |
| 19969 | let (uw, fw, fh) = (upscaled_w as usize, frame_width as usize, frame_height as usize); | 19966 | let (uw, fw, fh) = (upscaled_w as usize, frame_width as usize, frame_height as usize); |
| 19970 | - let up = |p: &PlaneBuf, in_w: usize, in_h: usize, out_w: usize| PlaneBuf { | 19967 | + let up = |p: &PlaneBuf<'_>, in_w: usize, in_h: usize, out_w: usize| PlaneBuf { |
| 19971 | - data: crate::superres::upscale_plane_strided( | 19968 | + data: std::borrow::Cow::Owned(crate::superres::upscale_plane_strided( |
| 19972 | &p.data, p.width, in_w, in_h, p.true_width, out_w, bd, | 19969 | &p.data, p.width, in_w, in_h, p.true_width, out_w, bd, |
| 19973 | - ), | 19970 | + )), |
| 19974 | width: out_w, | 19971 | width: out_w, |
| 19975 | height: in_h, | 19972 | height: in_h, |
| 19976 | true_width: out_w, | 19973 | true_width: out_w, |
| @@ -19997,9 +19994,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 19997 | ); | 19994 | ); |
| 19998 | } | 19995 | } |
| 19999 | if let Some((db_y, db_u, db_v)) = deblocked { | 19996 | if let Some((db_y, db_u, db_v)) = deblocked { |
| 20000 | - scratch_return(db_y.data); | 19997 | + scratch_return(db_y.data.into_owned()); |
| 20001 | - scratch_return(db_u.data); | 19998 | + scratch_return(db_u.data.into_owned()); |
| 20002 | - scratch_return(db_v.data); | 19999 | + scratch_return(db_v.data.into_owned()); |
| 20003 | } | 20000 | } |
| 20004 | 20001 | ||
| 20005 | let (fw, fh) = (lr_w, frame_height as usize); | 20002 | let (fw, fh) = (lr_w, frame_height as usize); |
| @@ -20017,14 +20014,14 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 20017 | Picture { | 20014 | Picture { |
| 20018 | width, | 20015 | width, |
| 20019 | height, | 20016 | height, |
| 20020 | - y: y.data, | 20017 | + y: y.data.into_owned(), |
| 20021 | - u: u.data, | 20018 | + u: u.data.into_owned(), |
| 20022 | - v: v.data, | 20019 | + v: v.data.into_owned(), |
| 20023 | }, | 20020 | }, |
| 20024 | result_cdfs, | 20021 | result_cdfs, |
| 20025 | )); | 20022 | )); |
| 20026 | } | 20023 | } |
| 20027 | - let crop = |plane: &PlaneBuf, w: usize, h: usize| -> Vec<u16> { | 20024 | + let crop = |plane: &PlaneBuf<'_>, w: usize, h: usize| -> Vec<u16> { |
| 20028 | let mut out = Vec::with_capacity(w * h); | 20025 | let mut out = Vec::with_capacity(w * h); |
| 20029 | for row in 0..h { | 20026 | for row in 0..h { |
| 20030 | out.extend(plane.data[row * plane.width..][..w].iter().copied()); | 20027 | out.extend(plane.data[row * plane.width..][..w].iter().copied()); |
| @@ -20346,7 +20343,7 @@ fn mv_to_q4(pos: usize, mv_component: i32, luma: bool) -> i32 { | |||
| 20346 | (pos as i32) * 16 + mv_component * if luma { 2 } else { 1 } | 20343 | (pos as i32) * 16 + mv_component * if luma { 2 } else { 1 } |
| 20347 | } | 20344 | } |
| 20348 | 20345 | ||
| 20349 | -impl PlaneBuf { | 20346 | +impl PlaneBuf<'_> { |
| 20350 | /// Adds `residual` onto an already-computed `prediction` (motion | 20347 | /// Adds `residual` onto an already-computed `prediction` (motion |
| 20351 | /// compensation's output, rather than [`predict`]'s intra one), writing | 20348 | /// compensation's output, rather than [`predict`]'s intra one), writing |
| 20352 | /// the clamped reconstruction into the plane at `(x, y)` -- the inter | 20349 | /// the clamped reconstruction into the plane at `(x, y)` -- the inter |
| @@ -20396,7 +20393,7 @@ impl PlaneBuf { | |||
| 20396 | let dst = (y + row) * self.width + x; | 20393 | let dst = (y + row) * self.width + x; |
| 20397 | let pred = &prediction[src..src + w]; | 20394 | let pred = &prediction[src..src + w]; |
| 20398 | let res = &residual[src..src + w]; | 20395 | let res = &residual[src..src + w]; |
| 20399 | - let out = &mut self.data[dst..dst + w]; | 20396 | + let out = &mut self.data.to_mut()[dst..dst + w]; |
| 20400 | for ((o, &p), &r) in out.iter_mut().zip(pred).zip(res) { | 20397 | for ((o, &p), &r) in out.iter_mut().zip(pred).zip(res) { |
| 20401 | *o = (i32::from(p) + r).clamp(0, max) as u16; | 20398 | *o = (i32::from(p) + r).clamp(0, max) as u16; |
| 20402 | } | 20399 | } |
| @@ -20418,7 +20415,7 @@ fn read_inter_plane( | |||
| 20418 | plane_idx: usize, | 20415 | plane_idx: usize, |
| 20419 | around: (bool, bool, i32), | 20416 | around: (bool, bool, i32), |
| 20420 | tx_mode: usize, | 20417 | tx_mode: usize, |
| 20421 | - plane: &mut PlaneBuf, | 20418 | + plane: &mut PlaneBuf<'static>, |
| 20422 | x: usize, | 20419 | x: usize, |
| 20423 | y: usize, | 20420 | y: usize, |
| 20424 | side: usize, | 20421 | side: usize, |
| @@ -20557,11 +20554,11 @@ fn read_single_ref( | |||
| 20557 | /// the compound path can call it twice (lane-av1comp). | 20554 | /// the compound path can call it twice (lane-av1comp). |
| 20558 | fn ref_planes<'a>( | 20555 | fn ref_planes<'a>( |
| 20559 | ref_frame: i8, | 20556 | ref_frame: i8, |
| 20560 | - ref_y: &'a PlaneBuf, | 20557 | + ref_y: &'a PlaneBuf<'a>, |
| 20561 | - ref_u: &'a PlaneBuf, | 20558 | + ref_u: &'a PlaneBuf<'a>, |
| 20562 | - ref_v: &'a PlaneBuf, | 20559 | + ref_v: &'a PlaneBuf<'a>, |
| 20563 | other_refs: &'a RefSlots, | 20560 | other_refs: &'a RefSlots, |
| 20564 | -) -> Result<(&'a PlaneBuf, &'a PlaneBuf, &'a PlaneBuf)> { | 20561 | +) -> Result<(&'a PlaneBuf<'a>, &'a PlaneBuf<'a>, &'a PlaneBuf<'a>)> { |
| 20565 | if ref_frame == LAST_FRAME { | 20562 | if ref_frame == LAST_FRAME { |
| 20566 | Ok((ref_y, ref_u, ref_v)) | 20563 | Ok((ref_y, ref_u, ref_v)) |
| 20567 | } else { | 20564 | } else { |
| @@ -20999,7 +20996,7 @@ nb_newmv={} cell_size={:?} cell_inter={:?} cell_ref={:?} sb_row_off={} sb_col_of | |||
| 20999 | /// under `av1_setup_build_prediction_by_{above,left}_pred`). | 20996 | /// under `av1_setup_build_prediction_by_{above,left}_pred`). |
| 21000 | #[allow(clippy::too_many_arguments)] | 20997 | #[allow(clippy::too_many_arguments)] |
| 21001 | fn obmc_neighbour_pred( | 20998 | fn obmc_neighbour_pred( |
| 21002 | - refplane: &PlaneBuf, | 20999 | + refplane: &PlaneBuf<'_>, |
| 21003 | x: usize, | 21000 | x: usize, |
| 21004 | y: usize, | 21001 | y: usize, |
| 21005 | mv: (i32, i32), | 21002 | mv: (i32, i32), |
| @@ -21072,7 +21069,7 @@ const II_WEIGHTS_1D: [u8; 128] = [ | |||
| 21072 | /// lane-wii r2: `wedge == Some(..)` replaces the mode mask with the wedge | 21069 | /// lane-wii r2: `wedge == Some(..)` replaces the mode mask with the wedge |
| 21073 | /// codebook mask (fixed sign 0; luma stride, 2x2 box-averaged for chroma). | 21070 | /// codebook mask (fixed sign 0; luma stride, 2x2 box-averaged for chroma). |
| 21074 | fn interintra_blend( | 21071 | fn interintra_blend( |
| 21075 | - plane: &PlaneBuf, | 21072 | + plane: &PlaneBuf<'_>, |
| 21076 | x: usize, | 21073 | x: usize, |
| 21077 | y: usize, | 21074 | y: usize, |
| 21078 | bw: usize, | 21075 | bw: usize, |
| @@ -21275,9 +21272,9 @@ fn obmc_blend( | |||
| 21275 | py: usize, | 21272 | py: usize, |
| 21276 | cpx: usize, | 21273 | cpx: usize, |
| 21277 | cpy: usize, | 21274 | cpy: usize, |
| 21278 | - ref_y: &PlaneBuf, | 21275 | + ref_y: &PlaneBuf<'_>, |
| 21279 | - ref_u: &PlaneBuf, | 21276 | + ref_u: &PlaneBuf<'_>, |
| 21280 | - ref_v: &PlaneBuf, | 21277 | + ref_v: &PlaneBuf<'_>, |
| 21281 | other_refs: &RefSlots, | 21278 | other_refs: &RefSlots, |
| 21282 | interp_fixed: Option<mc::InterpFilterKind>, | 21279 | interp_fixed: Option<mc::InterpFilterKind>, |
| 21283 | // lane-scaledref r1: this frame's own coded luma width -- each OBMC | 21280 | // lane-scaledref r1: this frame's own coded luma width -- each OBMC |
| @@ -21849,12 +21846,12 @@ fn decode_inter_block( | |||
| 21849 | side: usize, | 21846 | side: usize, |
| 21850 | mi_cols: u32, | 21847 | mi_cols: u32, |
| 21851 | mi_rows: u32, | 21848 | mi_rows: u32, |
| 21852 | - y: &mut PlaneBuf, | 21849 | + y: &mut PlaneBuf<'static>, |
| 21853 | - u: &mut PlaneBuf, | 21850 | + u: &mut PlaneBuf<'static>, |
| 21854 | - v: &mut PlaneBuf, | 21851 | + v: &mut PlaneBuf<'static>, |
| 21855 | - ref_y: &PlaneBuf, | 21852 | + ref_y: &PlaneBuf<'_>, |
| 21856 | - ref_u: &PlaneBuf, | 21853 | + ref_u: &PlaneBuf<'_>, |
| 21857 | - ref_v: &PlaneBuf, | 21854 | + ref_v: &PlaneBuf<'_>, |
| 21858 | // lane-av1refs: every non-`LAST_FRAME` reference this frame header's own | 21855 | // lane-av1refs: every non-`LAST_FRAME` reference this frame header's own |
| 21859 | // `ref_frame_idx` names a live DPB slot for, indexed `[ref_frame]` | 21856 | // `ref_frame_idx` names a live DPB slot for, indexed `[ref_frame]` |
| 21860 | // (`LAST2_FRAME`=2 .. `ALTREF_FRAME`=7; index 0/1 unused, `LAST_FRAME` | 21857 | // (`LAST2_FRAME`=2 .. `ALTREF_FRAME`=7; index 0/1 unused, `LAST_FRAME` |
| @@ -25046,7 +25043,7 @@ fn decode_inter_block( | |||
| 25046 | ); | 25043 | ); |
| 25047 | let cu_scan = default_scan(cu_tx); | 25044 | let cu_scan = default_scan(cu_tx); |
| 25048 | for plane_idx in 1..3 { | 25045 | for plane_idx in 1..3 { |
| 25049 | - let buf: &mut PlaneBuf = if plane_idx == 1 { &mut *u } else { &mut *v }; | 25046 | + let buf: &mut PlaneBuf<'static> = if plane_idx == 1 { &mut *u } else { &mut *v }; |
| 25050 | let cu_grid = if skip { | 25047 | let cu_grid = if skip { |
| 25051 | buf.reconstruct( | 25048 | buf.reconstruct( |
| 25052 | cu_x, | 25049 | cu_x, |
| @@ -25544,12 +25541,12 @@ fn decode_inter_sub8_split4( | |||
| 25544 | group_mi: (usize, usize), | 25541 | group_mi: (usize, usize), |
| 25545 | mi_cols: u32, | 25542 | mi_cols: u32, |
| 25546 | mi_rows: u32, | 25543 | mi_rows: u32, |
| 25547 | - y: &mut PlaneBuf, | 25544 | + y: &mut PlaneBuf<'static>, |
| 25548 | - u: &mut PlaneBuf, | 25545 | + u: &mut PlaneBuf<'static>, |
| 25549 | - v: &mut PlaneBuf, | 25546 | + v: &mut PlaneBuf<'static>, |
| 25550 | - ref_y: &PlaneBuf, | 25547 | + ref_y: &PlaneBuf<'_>, |
| 25551 | - ref_u: &PlaneBuf, | 25548 | + ref_u: &PlaneBuf<'_>, |
| 25552 | - ref_v: &PlaneBuf, | 25549 | + ref_v: &PlaneBuf<'_>, |
| 25553 | other_refs: &RefSlots, | 25550 | other_refs: &RefSlots, |
| 25554 | sign_bias_table: &SignBiasTable, | 25551 | sign_bias_table: &SignBiasTable, |
| 25555 | global_motion: &[ec_av1_syntax::WarpParams; 7], | 25552 | global_motion: &[ec_av1_syntax::WarpParams; 7], |
| @@ -26055,9 +26052,9 @@ fn decode_intra_sub8_leaf( | |||
| 26055 | has_chroma: bool, | 26052 | has_chroma: bool, |
| 26056 | skip: bool, | 26053 | skip: bool, |
| 26057 | scan4: &[u16], | 26054 | scan4: &[u16], |
| 26058 | - y: &mut PlaneBuf, | 26055 | + y: &mut PlaneBuf<'static>, |
| 26059 | - u: &mut PlaneBuf, | 26056 | + u: &mut PlaneBuf<'static>, |
| 26060 | - v: &mut PlaneBuf, | 26057 | + v: &mut PlaneBuf<'static>, |
| 26061 | base_q_idx: u8, | 26058 | base_q_idx: u8, |
| 26062 | enable_filter_intra: bool, | 26059 | enable_filter_intra: bool, |
| 26063 | tx_select: bool, | 26060 | tx_select: bool, |
| @@ -26501,12 +26498,12 @@ fn decode_inter_sub8_rect2( | |||
| 26501 | vert: bool, | 26498 | vert: bool, |
| 26502 | mi_cols: u32, | 26499 | mi_cols: u32, |
| 26503 | mi_rows: u32, | 26500 | mi_rows: u32, |
| 26504 | - y: &mut PlaneBuf, | 26501 | + y: &mut PlaneBuf<'static>, |
| 26505 | - u: &mut PlaneBuf, | 26502 | + u: &mut PlaneBuf<'static>, |
| 26506 | - v: &mut PlaneBuf, | 26503 | + v: &mut PlaneBuf<'static>, |
| 26507 | - ref_y: &PlaneBuf, | 26504 | + ref_y: &PlaneBuf<'_>, |
| 26508 | - ref_u: &PlaneBuf, | 26505 | + ref_u: &PlaneBuf<'_>, |
| 26509 | - ref_v: &PlaneBuf, | 26506 | + ref_v: &PlaneBuf<'_>, |
| 26510 | other_refs: &RefSlots, | 26507 | other_refs: &RefSlots, |
| 26511 | sign_bias_table: &SignBiasTable, | 26508 | sign_bias_table: &SignBiasTable, |
| 26512 | global_motion: &[ec_av1_syntax::WarpParams; 7], | 26509 | global_motion: &[ec_av1_syntax::WarpParams; 7], |
| @@ -27108,12 +27105,12 @@ fn decode_inter_block8( | |||
| 27108 | mi_rows: u32, | 27105 | mi_rows: u32, |
| 27109 | outer_at: (usize, usize), | 27106 | outer_at: (usize, usize), |
| 27110 | leaf_mi: (usize, usize), | 27107 | leaf_mi: (usize, usize), |
| 27111 | - y: &mut PlaneBuf, | 27108 | + y: &mut PlaneBuf<'static>, |
| 27112 | - u: &mut PlaneBuf, | 27109 | + u: &mut PlaneBuf<'static>, |
| 27113 | - v: &mut PlaneBuf, | 27110 | + v: &mut PlaneBuf<'static>, |
| 27114 | - ref_y: &PlaneBuf, | 27111 | + ref_y: &PlaneBuf<'_>, |
| 27115 | - ref_u: &PlaneBuf, | 27112 | + ref_u: &PlaneBuf<'_>, |
| 27116 | - ref_v: &PlaneBuf, | 27113 | + ref_v: &PlaneBuf<'_>, |
| 27117 | other_refs: &RefSlots, | 27114 | other_refs: &RefSlots, |
| 27118 | base_q_idx: u8, | 27115 | base_q_idx: u8, |
| 27119 | scan8: &[u16], | 27116 | scan8: &[u16], |
| @@ -29339,7 +29336,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 29339 | let (width, height) = (cols as usize * BLOCK, rows as usize * BLOCK); | 29336 | let (width, height) = (cols as usize * BLOCK, rows as usize * BLOCK); |
| 29340 | 29337 | ||
| 29341 | let ref_y = PlaneBuf { | 29338 | let ref_y = PlaneBuf { |
| 29342 | - data: reference.y.iter().map(|&s| s as u16).collect(), | 29339 | + data: std::borrow::Cow::Borrowed(&reference.y), |
| 29343 | width: reference.width, | 29340 | width: reference.width, |
| 29344 | height: reference.height, | 29341 | height: reference.height, |
| 29345 | true_width: reference.width, | 29342 | true_width: reference.width, |
| @@ -29350,7 +29347,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 29350 | tile_y1: reference.height, | 29347 | tile_y1: reference.height, |
| 29351 | }; | 29348 | }; |
| 29352 | let ref_u = PlaneBuf { | 29349 | let ref_u = PlaneBuf { |
| 29353 | - data: reference.u.iter().map(|&s| s as u16).collect(), | 29350 | + data: std::borrow::Cow::Borrowed(&reference.u), |
| 29354 | width: reference.width / 2, | 29351 | width: reference.width / 2, |
| 29355 | height: reference.height / 2, | 29352 | height: reference.height / 2, |
| 29356 | true_width: reference.width / 2, | 29353 | true_width: reference.width / 2, |
| @@ -29361,7 +29358,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 29361 | tile_y1: reference.height / 2, | 29358 | tile_y1: reference.height / 2, |
| 29362 | }; | 29359 | }; |
| 29363 | let ref_v = PlaneBuf { | 29360 | let ref_v = PlaneBuf { |
| 29364 | - data: reference.v.iter().map(|&s| s as u16).collect(), | 29361 | + data: std::borrow::Cow::Borrowed(&reference.v), |
| 29365 | width: reference.width / 2, | 29362 | width: reference.width / 2, |
| 29366 | height: reference.height / 2, | 29363 | height: reference.height / 2, |
| 29367 | true_width: reference.width / 2, | 29364 | true_width: reference.width / 2, |
| @@ -29378,13 +29375,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 29378 | // block it is decoding selects an index that is still `None` here | 29375 | // block it is decoding selects an index that is still `None` here |
| 29379 | // (spec 7.9 requires every *active* reference be a compatible size; | 29376 | // (spec 7.9 requires every *active* reference be a compatible size; |
| 29380 | // an inactive one this frame never selects is simply left `None`). | 29377 | // an inactive one this frame never selects is simply left `None`). |
| 29381 | - let owned_refs: [Option<(PlaneBuf, PlaneBuf, PlaneBuf)>; 8] = std::array::from_fn(|i| { | 29378 | + let owned_refs: [Option<(PlaneBuf<'_>, PlaneBuf<'_>, PlaneBuf<'_>)>; 8] = std::array::from_fn(|i| { |
| 29382 | other_refs[i] | 29379 | other_refs[i] |
| 29383 | .filter(|g| g.width == reference.width && g.height == reference.height) | 29380 | .filter(|g| g.width == reference.width && g.height == reference.height) |
| 29384 | .map(|g| { | 29381 | .map(|g| { |
| 29385 | ( | 29382 | ( |
| 29386 | PlaneBuf { | 29383 | PlaneBuf { |
| 29387 | - data: g.y.iter().map(|&s| s as u16).collect(), | 29384 | + data: std::borrow::Cow::Borrowed(&g.y), |
| 29388 | width: g.width, | 29385 | width: g.width, |
| 29389 | height: g.height, | 29386 | height: g.height, |
| 29390 | true_width: g.width, | 29387 | true_width: g.width, |
| @@ -29395,7 +29392,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 29395 | tile_y1: g.height, | 29392 | tile_y1: g.height, |
| 29396 | }, | 29393 | }, |
| 29397 | PlaneBuf { | 29394 | PlaneBuf { |
| 29398 | - data: g.u.iter().map(|&s| s as u16).collect(), | 29395 | + data: std::borrow::Cow::Borrowed(&g.u), |
| 29399 | width: g.width / 2, | 29396 | width: g.width / 2, |
| 29400 | height: g.height / 2, | 29397 | height: g.height / 2, |
| 29401 | true_width: g.width / 2, | 29398 | true_width: g.width / 2, |
| @@ -29406,7 +29403,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 29406 | tile_y1: g.height / 2, | 29403 | tile_y1: g.height / 2, |
| 29407 | }, | 29404 | }, |
| 29408 | PlaneBuf { | 29405 | PlaneBuf { |
| 29409 | - data: g.v.iter().map(|&s| s as u16).collect(), | 29406 | + data: std::borrow::Cow::Borrowed(&g.v), |
| 29410 | width: g.width / 2, | 29407 | width: g.width / 2, |
| 29411 | height: g.height / 2, | 29408 | height: g.height / 2, |
| 29412 | true_width: g.width / 2, | 29409 | true_width: g.width / 2, |
| @@ -29423,7 +29420,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 29423 | std::array::from_fn(|i| owned_refs[i].as_ref().map(|(a, b, c)| (a, b, c))); | 29420 | std::array::from_fn(|i| owned_refs[i].as_ref().map(|(a, b, c)| (a, b, c))); |
| 29424 | 29421 | ||
| 29425 | let mut y = PlaneBuf { | 29422 | let mut y = PlaneBuf { |
| 29426 | - data: vec![0u16; width * height], | 29423 | + data: std::borrow::Cow::Owned(vec![0u16; width * height]), |
| 29427 | width, | 29424 | width, |
| 29428 | height, | 29425 | height, |
| 29429 | true_width, | 29426 | true_width, |
| @@ -29434,7 +29431,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 29434 | tile_y1: height, | 29431 | tile_y1: height, |
| 29435 | }; | 29432 | }; |
| 29436 | let mut u = PlaneBuf { | 29433 | let mut u = PlaneBuf { |
| 29437 | - data: vec![0u16; width * height / 4], | 29434 | + data: std::borrow::Cow::Owned(vec![0u16; width * height / 4]), |
| 29438 | width: width / 2, | 29435 | width: width / 2, |
| 29439 | height: height / 2, | 29436 | height: height / 2, |
| 29440 | true_width: true_width / 2, | 29437 | true_width: true_width / 2, |
| @@ -29445,7 +29442,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 29445 | tile_y1: height / 2, | 29442 | tile_y1: height / 2, |
| 29446 | }; | 29443 | }; |
| 29447 | let mut v = PlaneBuf { | 29444 | let mut v = PlaneBuf { |
| 29448 | - data: vec![0u16; width * height / 4], | 29445 | + data: std::borrow::Cow::Owned(vec![0u16; width * height / 4]), |
| 29449 | width: width / 2, | 29446 | width: width / 2, |
| 29450 | height: height / 2, | 29447 | height: height / 2, |
| 29451 | true_width: true_width / 2, | 29448 | true_width: true_width / 2, |
| @@ -31949,7 +31946,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 31949 | use std::io::Write; | 31946 | use std::io::Write; |
| 31950 | let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | 31947 | let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); |
| 31951 | if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) { | 31948 | if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) { |
| 31952 | - let narrow = |p: &PlaneBuf| -> Vec<u8> { p.data.iter().map(|&s| s as u8).collect() }; | 31949 | + let narrow = |p: &PlaneBuf<'_>| -> Vec<u8> { p.data.iter().map(|&s| s as u8).collect() }; |
| 31953 | let _ = f.write_all(&narrow(&y)); | 31950 | let _ = f.write_all(&narrow(&y)); |
| 31954 | let _ = f.write_all(&narrow(&u)); | 31951 | let _ = f.write_all(&narrow(&u)); |
| 31955 | let _ = f.write_all(&narrow(&v)); | 31952 | let _ = f.write_all(&narrow(&v)); |
| @@ -32006,10 +32003,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 32006 | if let Some((upscaled_w, _)) = superres(fctx) { | 32003 | if let Some((upscaled_w, _)) = superres(fctx) { |
| 32007 | let bd = u32::from(bit_depth(fctx)); | 32004 | let bd = u32::from(bit_depth(fctx)); |
| 32008 | let (uw, fw, fh) = (upscaled_w as usize, frame_width as usize, frame_height as usize); | 32005 | let (uw, fw, fh) = (upscaled_w as usize, frame_width as usize, frame_height as usize); |
| 32009 | - let up = |p: &PlaneBuf, in_w: usize, in_h: usize, out_w: usize| PlaneBuf { | 32006 | + let up = |p: &PlaneBuf<'_>, in_w: usize, in_h: usize, out_w: usize| PlaneBuf { |
| 32010 | - data: crate::superres::upscale_plane_strided( | 32007 | + data: std::borrow::Cow::Owned(crate::superres::upscale_plane_strided( |
| 32011 | &p.data, p.width, in_w, in_h, p.true_width, out_w, bd, | 32008 | &p.data, p.width, in_w, in_h, p.true_width, out_w, bd, |
| 32012 | - ), | 32009 | + )), |
| 32013 | width: out_w, | 32010 | width: out_w, |
| 32014 | height: in_h, | 32011 | height: in_h, |
| 32015 | true_width: out_w, | 32012 | true_width: out_w, |
| @@ -32036,9 +32033,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 32036 | ); | 32033 | ); |
| 32037 | } | 32034 | } |
| 32038 | if let Some((db_y, db_u, db_v)) = deblocked { | 32035 | if let Some((db_y, db_u, db_v)) = deblocked { |
| 32039 | - scratch_return(db_y.data); | 32036 | + scratch_return(db_y.data.into_owned()); |
| 32040 | - scratch_return(db_u.data); | 32037 | + scratch_return(db_u.data.into_owned()); |
| 32041 | - scratch_return(db_v.data); | 32038 | + scratch_return(db_v.data.into_owned()); |
| 32042 | } | 32039 | } |
| 32043 | 32040 | ||
| 32044 | let motion_field = build_motion_field( | 32041 | let motion_field = build_motion_field( |
| @@ -32065,15 +32062,15 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 32065 | Picture { | 32062 | Picture { |
| 32066 | width, | 32063 | width, |
| 32067 | height, | 32064 | height, |
| 32068 | - y: y.data, | 32065 | + y: y.data.into_owned(), |
| 32069 | - u: u.data, | 32066 | + u: u.data.into_owned(), |
| 32070 | - v: v.data, | 32067 | + v: v.data.into_owned(), |
| 32071 | }, | 32068 | }, |
| 32072 | result_cdfs, | 32069 | result_cdfs, |
| 32073 | motion_field, | 32070 | motion_field, |
| 32074 | )); | 32071 | )); |
| 32075 | } | 32072 | } |
| 32076 | - let crop = |plane: &PlaneBuf, w: usize, h: usize| -> Vec<u16> { | 32073 | + let crop = |plane: &PlaneBuf<'_>, w: usize, h: usize| -> Vec<u16> { |
| 32077 | let mut out = Vec::with_capacity(w * h); | 32074 | let mut out = Vec::with_capacity(w * h); |
| 32078 | for row in 0..h { | 32075 | for row in 0..h { |
| 32079 | out.extend(plane.data[row * plane.width..][..w].iter().copied()); | 32076 | out.extend(plane.data[row * plane.width..][..w].iter().copied()); |
| @@ -32748,7 +32745,7 @@ mod tests { | |||
| 32748 | const REFUSAL: &str = | 32745 | const REFUSAL: &str = |
| 32749 | "a reference frame selected with no picture at this frame's own ref_frame_idx slot"; | 32746 | "a reference frame selected with no picture at this frame's own ref_frame_idx slot"; |
| 32750 | let plane = PlaneBuf { | 32747 | let plane = PlaneBuf { |
| 32751 | - data: vec![0u16; 16], | 32748 | + data: std::borrow::Cow::Owned(vec![0u16; 16]), |
| 32752 | width: 4, | 32749 | width: 4, |
| 32753 | height: 4, | 32750 | height: 4, |
| 32754 | true_width: 4, | 32751 | true_width: 4, |
| @@ -33470,12 +33467,14 @@ mod tests { | |||
| 33470 | let (width, height) = (64usize, 64usize); | 33467 | let (width, height) = (64usize, 64usize); |
| 33471 | let ref_pattern: Vec<u16> = (0..width * height).map(|i| (i % 251) as u16).collect(); | 33468 | let ref_pattern: Vec<u16> = (0..width * height).map(|i| (i % 251) as u16).collect(); |
| 33472 | let ref_plane = |scale: usize| PlaneBuf { | 33469 | let ref_plane = |scale: usize| PlaneBuf { |
| 33473 | - data: ref_pattern | 33470 | + data: std::borrow::Cow::Owned( |
| 33474 | - .iter() | 33471 | + ref_pattern |
| 33475 | - .step_by(scale.max(1)) | 33472 | + .iter() |
| 33476 | - .take((width / scale) * (height / scale)) | 33473 | + .step_by(scale.max(1)) |
| 33477 | - .copied() | 33474 | + .take((width / scale) * (height / scale)) |
| 33478 | - .collect(), | 33475 | + .copied() |
| 33476 | + .collect(), | ||
| 33477 | + ), | ||
| 33479 | width: width / scale, | 33478 | width: width / scale, |
| 33480 | height: height / scale, | 33479 | height: height / scale, |
| 33481 | true_width: width / scale, | 33480 | true_width: width / scale, |
| @@ -33486,7 +33485,7 @@ mod tests { | |||
| 33486 | tile_y1: height / scale, | 33485 | tile_y1: height / scale, |
| 33487 | }; | 33486 | }; |
| 33488 | let ref_y = PlaneBuf { | 33487 | let ref_y = PlaneBuf { |
| 33489 | - data: ref_pattern.clone(), | 33488 | + data: std::borrow::Cow::Owned(ref_pattern.clone()), |
| 33490 | width, | 33489 | width, |
| 33491 | height, | 33490 | height, |
| 33492 | true_width: width, | 33491 | true_width: width, |
| @@ -33500,7 +33499,7 @@ mod tests { | |||
| 33500 | let ref_v = ref_plane(2); | 33499 | let ref_v = ref_plane(2); |
| 33501 | 33500 | ||
| 33502 | let mut y = PlaneBuf { | 33501 | let mut y = PlaneBuf { |
| 33503 | - data: vec![0u16; width * height], | 33502 | + data: std::borrow::Cow::Owned(vec![0u16; width * height]), |
| 33504 | width, | 33503 | width, |
| 33505 | height, | 33504 | height, |
| 33506 | true_width: width, | 33505 | true_width: width, |
| @@ -33511,7 +33510,7 @@ mod tests { | |||
| 33511 | tile_y1: height, | 33510 | tile_y1: height, |
| 33512 | }; | 33511 | }; |
| 33513 | let mut u = PlaneBuf { | 33512 | let mut u = PlaneBuf { |
| 33514 | - data: vec![0u16; (width / 2) * (height / 2)], | 33513 | + data: std::borrow::Cow::Owned(vec![0u16; (width / 2) * (height / 2)]), |
| 33515 | width: width / 2, | 33514 | width: width / 2, |
| 33516 | height: height / 2, | 33515 | height: height / 2, |
| 33517 | true_width: width / 2, | 33516 | true_width: width / 2, |
| @@ -33522,7 +33521,7 @@ mod tests { | |||
| 33522 | tile_y1: height / 2, | 33521 | tile_y1: height / 2, |
| 33523 | }; | 33522 | }; |
| 33524 | let mut v = PlaneBuf { | 33523 | let mut v = PlaneBuf { |
| 33525 | - data: vec![0u16; (width / 2) * (height / 2)], | 33524 | + data: std::borrow::Cow::Owned(vec![0u16; (width / 2) * (height / 2)]), |
| 33526 | width: width / 2, | 33525 | width: width / 2, |
| 33527 | height: height / 2, | 33526 | height: height / 2, |
| 33528 | true_width: width / 2, | 33527 | true_width: width / 2, |