diff --git a/src/codec/vp9/parser.rs b/src/codec/vp9/parser.rs index a19bd73e..78071490 100644 --- a/src/codec/vp9/parser.rs +++ b/src/codec/vp9/parser.rs @@ -314,9 +314,9 @@ struct FrameSize { height: u32, } -pub struct Frame> { - /// The abstraction for the raw memory for this frame. - bitstream: T, +pub struct Frame<'a> { + /// The bitstream data for this frame. + bitstream: &'a [u8], /// The frame header. pub header: Header, /// The offset into T @@ -325,8 +325,8 @@ pub struct Frame> { size: usize, } -impl> Frame { - pub fn new(bitstream: T, header: Header, offset: usize, size: usize) -> Self { +impl<'a> Frame<'a> { + pub fn new(bitstream: &'a [u8], header: Header, offset: usize, size: usize) -> Self { Self { bitstream, header, @@ -336,9 +336,9 @@ impl> Frame { } } -impl> AsRef<[u8]> for Frame { +impl<'a> AsRef<[u8]> for Frame<'a> { fn as_ref(&self) -> &[u8] { - let data = self.bitstream.as_ref(); + let data = self.bitstream; &data[self.offset..self.offset + self.size] } } @@ -1090,13 +1090,13 @@ impl Parser { } /// Parse a single VP9 frame. - pub fn parse_frame>( + pub fn parse_frame<'a>( &mut self, - bitstream: T, + bitstream: &'a [u8], offset: usize, size: usize, - ) -> anyhow::Result> { - let header = self.parse_frame_header(&bitstream, offset)?; + ) -> anyhow::Result> { + let header = self.parse_frame_header(bitstream, offset)?; Ok(Frame { header, @@ -1108,10 +1108,10 @@ impl Parser { /// Parses VP9 frames from the data in `resource`. This can result in more than one frame if the /// data passed in contains a VP9 superframe. - pub fn parse_chunk + Copy>( + pub fn parse_chunk<'a>( &mut self, - resource: T, - ) -> anyhow::Result>> { + resource: &'a [u8], + ) -> anyhow::Result>> { let superframe_hdr = Parser::parse_superframe_hdr(resource)?; let mut offset = 0; diff --git a/src/decoder/stateless/vp9.rs b/src/decoder/stateless/vp9.rs index 1bb126c6..dc72144c 100644 --- a/src/decoder/stateless/vp9.rs +++ b/src/decoder/stateless/vp9.rs @@ -139,7 +139,7 @@ where } /// Handle a single frame. - fn handle_frame(&mut self, frame: &Frame<&[u8]>, timestamp: u64) -> Result<(), DecodeError> { + fn handle_frame(&mut self, frame: &Frame, timestamp: u64) -> Result<(), DecodeError> { let decoded_handle = if frame.header.show_existing_frame { // Frame to be shown. Unwrapping must produce a Picture, because the // spec mandates frame_to_show_map_idx references a valid entry in diff --git a/src/decoder/stateless/vp9/vaapi.rs b/src/decoder/stateless/vp9/vaapi.rs index 20c4e940..1fcc30cc 100644 --- a/src/decoder/stateless/vp9/vaapi.rs +++ b/src/decoder/stateless/vp9/vaapi.rs @@ -486,7 +486,7 @@ mod tests { // FRAME 0 let packet = ivf_iter.next().unwrap(); - let mut frames = parser.parse_chunk(&packet).unwrap(); + let mut frames = parser.parse_chunk(packet).unwrap(); assert_eq!(frames.len(), 1); let frame = frames.remove(0); @@ -556,7 +556,7 @@ mod tests { // FRAME 1 let packet = ivf_iter.next().unwrap(); - let mut frames = parser.parse_chunk(&packet).unwrap(); + let mut frames = parser.parse_chunk(packet).unwrap(); assert_eq!(frames.len(), 2); let frame = frames.remove(0); assert_eq!(frame.as_ref().len(), 2390);