X-Git-Url: https://git.nihav.org/?p=nihav.git;a=blobdiff_plain;f=nihav-codec-support%2Fsrc%2Fdata%2Fmod.rs;h=eba029939a3a46643dea1fd3a650a7eccf1f3927;hp=35a89736b72075a71e6d4305b9bc667e6795f401;hb=379524159c95f1c3639976ccf35f9d47cd9732ac;hpb=b4d5b8515e75383b4fc59ea2813c90c615d59a96 diff --git a/nihav-codec-support/src/data/mod.rs b/nihav-codec-support/src/data/mod.rs index 35a8973..eba0299 100644 --- a/nihav-codec-support/src/data/mod.rs +++ b/nihav-codec-support/src/data/mod.rs @@ -5,7 +5,7 @@ /// In the decoding process of many codecs there is a need to store some previously decoded information and only immediate top neighbours are used. /// This can be done by storing either the full information for the whole frame or just the top line and move information for last decoded row to the top every time when row decoding is done. /// `GenericCache` implements the second approach. -/// +/// /// # Examples /// /// Create a cache for one line and use top pixel for prediction: @@ -44,17 +44,17 @@ impl GenericCache { stride, height, xpos: 0, - data: Vec::with_capacity((height + 1) * stride), + data: Vec::with_capacity((height + 1) * stride + 1), default, }; ret.reset(); ret } /// Reports the total amount of elements stored. - pub fn full_size(&self) -> usize { self.stride * (self.height + 1) } + pub fn full_size(&self) -> usize { self.stride * (self.height + 1) + 1 } /// Resets the cache state. pub fn reset(&mut self) { - self.data.truncate(0); + self.data.clear(); let size = self.full_size(); self.data.resize(size, self.default); self.xpos = self.stride + 1;