From d61e3eec24fecd418da070db0ea27c46d2f74362 Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Tue, 3 Oct 2023 11:21:40 +0900 Subject: [PATCH] codec/h26x: remove generic parameter for data The data member does not need to be owned - it can simply be borrowed as a slice. Change that type to remove a generic argument (and introduce a lifetime), which simplifies the code a bit. --- examples/ccdec.rs | 4 +-- src/codec/h264/nalu.rs | 35 ++++++++++------------ src/codec/h264/parser.rs | 22 +++++++------- src/codec/h264/picture.rs | 2 +- src/codec/h265/parser.rs | 46 +++++++++++++---------------- src/codec/h265/picture.rs | 2 +- src/decoder/stateless/h264.rs | 14 ++++----- src/decoder/stateless/h264/dummy.rs | 2 +- src/decoder/stateless/h264/vaapi.rs | 4 +-- src/decoder/stateless/h265.rs | 18 +++++------ src/decoder/stateless/h265/dummy.rs | 4 +-- src/decoder/stateless/h265/vaapi.rs | 8 ++--- src/utils.rs | 4 +-- 13 files changed, 75 insertions(+), 90 deletions(-) diff --git a/examples/ccdec.rs b/examples/ccdec.rs index 89860219..e6120b9e 100644 --- a/examples/ccdec.rs +++ b/examples/ccdec.rs @@ -338,7 +338,7 @@ fn main() { let display = libva::Display::open().expect("failed to open libva display"); let (mut decoder, frame_iter) = match args.input_format { EncodedFormat::H264 => { - let frame_iter = Box::new(NalIterator::>::new(&input).map(Cow::Borrowed)) + let frame_iter = Box::new(NalIterator::::new(&input).map(Cow::Borrowed)) as Box>>; let decoder = Box::new(StatelessDecoder::::new_vaapi( @@ -369,7 +369,7 @@ fn main() { (decoder, frame_iter) } EncodedFormat::H265 => { - let frame_iter = Box::new(NalIterator::>::new(&input).map(Cow::Borrowed)) + let frame_iter = Box::new(NalIterator::::new(&input).map(Cow::Borrowed)) as Box>>; let decoder = Box::new(StatelessDecoder::::new_vaapi( diff --git a/src/codec/h264/nalu.rs b/src/codec/h264/nalu.rs index 7920a04c..a00ed7b8 100644 --- a/src/codec/h264/nalu.rs +++ b/src/codec/h264/nalu.rs @@ -18,29 +18,28 @@ pub trait Header: Sized { } #[derive(Debug)] -pub struct Nalu { +pub struct Nalu<'a, U> { header: U, /// The mapping that backs this NALU. Possibly shared with the other NALUs /// in the Access Unit. - data: T, + data: &'a [u8], size: usize, offset: usize, sc_offset: usize, } -impl Nalu +impl<'a, U> Nalu<'a, U> where - T: AsRef<[u8]> + Clone, U: Debug + Header, { /// Find the next Annex B encoded NAL unit. - pub fn next(cursor: &mut Cursor) -> anyhow::Result> { + pub fn next(cursor: &mut Cursor<&'a [u8]>) -> anyhow::Result> { let bitstream = cursor.clone().into_inner(); let pos = usize::try_from(cursor.position())?; // Find the start code for this NALU - let current_nalu_offset = match Nalu::::find_start_code(cursor, pos) { + let current_nalu_offset = match Nalu::<'a, U>::find_start_code(cursor, pos) { Some(offset) => offset, None => return Err(anyhow!("No NAL found")), }; @@ -49,7 +48,7 @@ where // If the preceding byte is 00, then we actually have a four byte SC, // i.e. 00 00 00 01 Where the first 00 is the "zero_byte()" - if start_code_offset > 0 && cursor.get_ref().as_ref()[start_code_offset - 1] == 00 { + if start_code_offset > 0 && cursor.get_ref()[start_code_offset - 1] == 00 { start_code_offset -= 1; } @@ -62,14 +61,12 @@ where let hdr = U::parse(cursor)?; // Find the start of the subsequent NALU. - let mut next_nalu_offset = match Nalu::::find_start_code(cursor, nalu_offset) { + let mut next_nalu_offset = match Nalu::<'a, U>::find_start_code(cursor, nalu_offset) { Some(offset) => offset, None => cursor.chunk().len(), // Whatever data is left must be part of the current NALU }; - while next_nalu_offset > 0 - && cursor.get_ref().as_ref()[nalu_offset + next_nalu_offset - 1] == 00 - { + while next_nalu_offset > 0 && cursor.get_ref()[nalu_offset + next_nalu_offset - 1] == 00 { // Discard trailing_zero_8bits next_nalu_offset -= 1; } @@ -91,14 +88,13 @@ where } } -impl Nalu +impl<'a, U> Nalu<'a, U> where - T: AsRef<[u8]>, U: Debug, { - fn find_start_code(data: &mut Cursor, offset: usize) -> Option { + fn find_start_code(data: &mut Cursor<&'a [u8]>, offset: usize) -> Option { // discard all zeroes until the start code pattern is found - data.get_ref().as_ref()[offset..] + data.get_ref()[offset..] .windows(3) .position(|window| window == [0x00, 0x00, 0x01]) } @@ -109,8 +105,8 @@ where } /// Get a reference to the nalu's data. - pub fn data(&self) -> &T { - &self.data + pub fn data(&self) -> &'a [u8] { + self.data } /// Get a reference to the nalu's size. @@ -129,9 +125,8 @@ where } } -impl, U> AsRef<[u8]> for Nalu { +impl<'a, U> AsRef<[u8]> for Nalu<'a, U> { fn as_ref(&self) -> &[u8] { - let data = self.data.as_ref(); - &data[self.offset..self.offset + self.size] + &self.data[self.offset..self.offset + self.size] } } diff --git a/src/codec/h264/parser.rs b/src/codec/h264/parser.rs index 2b8a9ebc..d0d3944f 100644 --- a/src/codec/h264/parser.rs +++ b/src/codec/h264/parser.rs @@ -19,7 +19,7 @@ use crate::codec::h264::nalu::Header; use crate::codec::h264::nalu_reader::NaluReader; use crate::codec::h264::picture::Field; -pub type Nalu = nalu::Nalu; +pub type Nalu<'a> = nalu::Nalu<'a, NaluHeader>; const DEFAULT_4X4_INTRA: [u8; 16] = [ 6, 13, 13, 20, 20, 20, 28, 28, 28, 28, 32, 32, 32, 37, 37, 42, @@ -409,21 +409,21 @@ impl SliceHeader { /// A H264 slice. An integer number of macroblocks or macroblock pairs ordered /// consecutively in the raster scan within a particular slice group -pub struct Slice { +pub struct Slice<'a> { /// The slice header. header: SliceHeader, /// The NAL unit backing this slice. - nalu: Nalu, + nalu: Nalu<'a>, } -impl Slice { +impl<'a> Slice<'a> { /// Get a reference to the slice's header. pub fn header(&self) -> &SliceHeader { &self.header } /// Get a reference to the slice's nalu. - pub fn nalu(&self) -> &Nalu { + pub fn nalu(&self) -> &Nalu<'a> { &self.nalu } } @@ -1787,7 +1787,7 @@ impl Parser { /// Parse a SPS and add it to the list of active SPSes. /// /// Returns a reference to the new SPS. - pub fn parse_sps>(&mut self, nalu: &Nalu) -> anyhow::Result<&Rc> { + pub fn parse_sps(&mut self, nalu: &Nalu) -> anyhow::Result<&Rc> { if !matches!(nalu.header().type_, NaluType::Sps) { return Err(anyhow!( "Invalid NALU type, expected {:?}, got {:?}", @@ -1956,7 +1956,7 @@ impl Parser { Ok(self.get_sps(key).unwrap()) } - pub fn parse_pps>(&mut self, nalu: &Nalu) -> anyhow::Result<&Pps> { + pub fn parse_pps(&mut self, nalu: &Nalu) -> anyhow::Result<&Pps> { if !matches!(nalu.header().type_, NaluType::Pps) { return Err(anyhow!( "Invalid NALU type, expected {:?}, got {:?}", @@ -2215,9 +2215,9 @@ impl Parser { Ok(()) } - fn parse_dec_ref_pic_marking>( + fn parse_dec_ref_pic_marking( r: &mut NaluReader, - nalu: &Nalu, + nalu: &Nalu, header: &mut SliceHeader, ) -> anyhow::Result<()> { let rpm = &mut header.dec_ref_pic_marking; @@ -2263,7 +2263,7 @@ impl Parser { Ok(()) } - pub fn parse_slice_header>(&self, nalu: Nalu) -> anyhow::Result> { + pub fn parse_slice_header<'a>(&self, nalu: Nalu<'a>) -> anyhow::Result> { if !matches!( nalu.header().type_, NaluType::Slice @@ -2838,7 +2838,7 @@ mod tests { 0x00, 0x00, 0x01, 0x07, 0x00, 0x00, 0x0a, 0xfb, 0xb0, 0x32, 0xc0, 0xca, 0x80, ]; - let mut cursor = Cursor::new(invalid_sps); + let mut cursor = Cursor::new(invalid_sps.as_ref()); let mut parser = Parser::default(); while let Ok(nalu) = Nalu::next(&mut cursor) { diff --git a/src/codec/h264/picture.rs b/src/codec/h264/picture.rs index 3f47d833..de6d6062 100644 --- a/src/codec/h264/picture.rs +++ b/src/codec/h264/picture.rs @@ -114,7 +114,7 @@ impl PictureData { } } - pub fn new_from_slice(slice: &Slice<&[u8]>, sps: &Sps, timestamp: u64) -> Self { + pub fn new_from_slice(slice: &Slice, sps: &Sps, timestamp: u64) -> Self { let hdr = slice.header(); let nalu_hdr = slice.nalu().header(); diff --git a/src/codec/h265/parser.rs b/src/codec/h265/parser.rs index c0739f81..68caf9e3 100644 --- a/src/codec/h265/parser.rs +++ b/src/codec/h265/parser.rs @@ -220,7 +220,7 @@ impl Header for NaluHeader { } } -pub type Nalu = nalu::Nalu; +pub type Nalu<'a> = nalu::Nalu<'a, NaluHeader>; /// H265 levels as defined by table A.8. /// `general_level_idc` and `sub_layer_level_idc[ OpTid ]` shall be set equal to a @@ -2970,21 +2970,21 @@ impl Default for SliceHeader { /// A H265 slice. An integer number of macroblocks or macroblock pairs ordered /// consecutively in the raster scan within a particular slice group -pub struct Slice { +pub struct Slice<'a> { /// The slice header. header: SliceHeader, /// The NAL unit backing this slice. - nalu: Nalu, + nalu: Nalu<'a>, } -impl Slice { +impl<'a> Slice<'a> { /// Get a reference to the slice's header. pub fn header(&self) -> &SliceHeader { &self.header } /// Get a reference to the slice's nalu. - pub fn nalu(&self) -> &Nalu { + pub fn nalu(&self) -> &Nalu { &self.nalu } @@ -3666,7 +3666,7 @@ pub struct Parser { impl Parser { /// Parse a VPS NALU. - pub fn parse_vps>(&mut self, nalu: &Nalu) -> anyhow::Result<&Vps> { + pub fn parse_vps(&mut self, nalu: &Nalu) -> anyhow::Result<&Vps> { if !matches!(nalu.header().type_, NaluType::VpsNut) { return Err(anyhow!( "Invalid NALU type, expected {:?}, got {:?}", @@ -4535,7 +4535,7 @@ impl Parser { } /// Parse a SPS NALU. - pub fn parse_sps>(&mut self, nalu: &Nalu) -> anyhow::Result<&Sps> { + pub fn parse_sps(&mut self, nalu: &Nalu) -> anyhow::Result<&Sps> { if !matches!(nalu.header().type_, NaluType::SpsNut) { return Err(anyhow!( "Invalid NALU type, expected {:?}, got {:?}", @@ -4832,7 +4832,7 @@ impl Parser { } /// Parse a PPS NALU. - pub fn parse_pps>(&mut self, nalu: &Nalu) -> anyhow::Result<&Pps> { + pub fn parse_pps(&mut self, nalu: &Nalu) -> anyhow::Result<&Pps> { if !matches!(nalu.header().type_, NaluType::PpsNut) { return Err(anyhow!( "Invalid NALU type, expected {:?}, got {:?}", @@ -5155,10 +5155,7 @@ impl Parser { } /// Parses a slice header from a slice NALU. - pub fn parse_slice_header>( - &mut self, - nalu: Nalu, - ) -> anyhow::Result> { + pub fn parse_slice_header<'a>(&mut self, nalu: Nalu<'a>) -> anyhow::Result> { if !matches!( nalu.header().type_, NaluType::TrailN @@ -5611,10 +5608,7 @@ mod tests { const STREAM_TEST_25_FPS_SLICE_1: &[u8] = include_bytes!("test_data/test-25fps-h265-slice-data-1.bin"); - fn dispatch_parse_call( - parser: &mut Parser, - nalu: Nalu<&[u8], NaluHeader>, - ) -> anyhow::Result<()> { + fn dispatch_parse_call(parser: &mut Parser, nalu: Nalu) -> anyhow::Result<()> { match nalu.header().type_ { NaluType::TrailN | NaluType::TrailR @@ -5652,9 +5646,9 @@ mod tests { bitstream: &[u8], nalu_type: NaluType, mut nskip: i32, - ) -> Option> { + ) -> Option> { let mut cursor = Cursor::new(bitstream); - while let Ok(nalu) = Nalu::<_, NaluHeader>::next(&mut cursor) { + while let Ok(nalu) = Nalu::::next(&mut cursor) { if nalu.header().type_ == nalu_type { if nskip == 0 { return Some(nalu); @@ -5672,7 +5666,7 @@ mod tests { fn parse_nalus_from_stream_file() { let mut cursor = Cursor::new(STREAM_BEAR); let mut num_nalus = 0; - while Nalu::<_, NaluHeader>::next(&mut cursor).is_ok() { + while Nalu::::next(&mut cursor).is_ok() { num_nalus += 1; } @@ -5680,7 +5674,7 @@ mod tests { let mut cursor = Cursor::new(STREAM_BBB); let mut num_nalus = 0; - while Nalu::<_, NaluHeader>::next(&mut cursor).is_ok() { + while Nalu::::next(&mut cursor).is_ok() { num_nalus += 1; } @@ -5688,7 +5682,7 @@ mod tests { let mut cursor = Cursor::new(STREAM_TEST25FPS); let mut num_nalus = 0; - while Nalu::<_, NaluHeader>::next(&mut cursor).is_ok() { + while Nalu::::next(&mut cursor).is_ok() { num_nalus += 1; } @@ -5702,21 +5696,21 @@ mod tests { let mut cursor = Cursor::new(STREAM_BBB); let mut parser = Parser::default(); - while let Ok(nalu) = Nalu::<_, NaluHeader>::next(&mut cursor) { + while let Ok(nalu) = Nalu::::next(&mut cursor) { dispatch_parse_call(&mut parser, nalu).unwrap(); } let mut cursor = Cursor::new(STREAM_BEAR); let mut parser = Parser::default(); - while let Ok(nalu) = Nalu::<_, NaluHeader>::next(&mut cursor) { + while let Ok(nalu) = Nalu::::next(&mut cursor) { dispatch_parse_call(&mut parser, nalu).unwrap(); } let mut cursor = Cursor::new(STREAM_TEST25FPS); let mut parser = Parser::default(); - while let Ok(nalu) = Nalu::<_, NaluHeader>::next(&mut cursor) { + while let Ok(nalu) = Nalu::::next(&mut cursor) { dispatch_parse_call(&mut parser, nalu).unwrap(); } } @@ -5727,7 +5721,7 @@ mod tests { let mut cursor = Cursor::new(STREAM_BEAR); let mut parser = Parser::default(); - let vps_nalu = Nalu::<_, NaluHeader>::next(&mut cursor).unwrap(); + let vps_nalu = Nalu::::next(&mut cursor).unwrap(); let vps = parser.parse_vps(&vps_nalu).unwrap(); assert!(vps.base_layer_internal_flag); @@ -5924,7 +5918,7 @@ mod tests { let mut cursor = Cursor::new(STREAM_TEST25FPS); let mut parser = Parser::default(); - let vps_nalu = Nalu::<_, NaluHeader>::next(&mut cursor).unwrap(); + let vps_nalu = Nalu::::next(&mut cursor).unwrap(); let vps = parser.parse_vps(&vps_nalu).unwrap(); assert!(vps.base_layer_internal_flag); assert!(vps.base_layer_available_flag); diff --git a/src/codec/h265/picture.rs b/src/codec/h265/picture.rs index 84be0026..4903d6dd 100644 --- a/src/codec/h265/picture.rs +++ b/src/codec/h265/picture.rs @@ -47,7 +47,7 @@ impl PictureData { /// This will also call the picture order count process (clause 8.3.1) to /// correctly initialize the POC values. pub fn new_from_slice( - slice: &Slice<&[u8]>, + slice: &Slice, pps: &Pps, first_picture_in_bitstream: bool, first_picture_after_eos: bool, diff --git a/src/decoder/stateless/h264.rs b/src/decoder/stateless/h264.rs index b731f9dc..0865b4c9 100644 --- a/src/decoder/stateless/h264.rs +++ b/src/decoder/stateless/h264.rs @@ -106,7 +106,7 @@ pub trait StatelessH264DecoderBackend: StatelessDecoderBackend> { fn decode_slice( &mut self, picture: &mut Self::Picture, - slice: &Slice<&[u8]>, + slice: &Slice, sps: &Sps, pps: &Pps, dpb: &Dpb, @@ -546,7 +546,7 @@ where #[allow(clippy::type_complexity)] fn find_first_field( &self, - slice: &Slice>, + slice: &Slice, ) -> anyhow::Result>, B::Handle)>> { let mut prev_field = None; @@ -1422,7 +1422,7 @@ where /// Init the current picture being decoded. fn init_current_pic( &mut self, - slice: &Slice<&[u8]>, + slice: &Slice, first_field: Option<&Rc>>, timestamp: u64, ) -> anyhow::Result { @@ -1472,7 +1472,7 @@ where fn begin_picture( &mut self, timestamp: u64, - slice: &Slice<&[u8]>, + slice: &Slice, ) -> Result, DecodeError> { let nalu_hdr = slice.nalu().header(); @@ -1779,7 +1779,7 @@ where fn handle_slice( &mut self, cur_pic: &mut CurrentPicState, - slice: &Slice<&[u8]>, + slice: &Slice, ) -> anyhow::Result<()> { // A slice can technically refer to another PPS. let pps = self @@ -1824,7 +1824,7 @@ where Ok(handle) } - fn process_nalu(&mut self, timestamp: u64, nalu: Nalu<&[u8]>) -> Result<(), DecodeError> { + fn process_nalu(&mut self, timestamp: u64, nalu: Nalu) -> Result<(), DecodeError> { match nalu.header().nalu_type() { NaluType::Sps => { self.codec.parser.parse_sps(&nalu)?; @@ -1981,7 +1981,7 @@ pub mod tests { |d, s, f| { simple_playback_loop( d, - NalIterator::>::new(s), + NalIterator::::new(s), f, &mut simple_playback_loop_owned_frames, DecodedFormat::NV12, diff --git a/src/decoder/stateless/h264/dummy.rs b/src/decoder/stateless/h264/dummy.rs index aa78ab28..6470ca3c 100644 --- a/src/decoder/stateless/h264/dummy.rs +++ b/src/decoder/stateless/h264/dummy.rs @@ -51,7 +51,7 @@ impl StatelessH264DecoderBackend for Backend { fn decode_slice( &mut self, _: &mut Self::Picture, - _: &Slice<&[u8]>, + _: &Slice, _: &Sps, _: &Pps, _: &Dpb, diff --git a/src/decoder/stateless/h264/vaapi.rs b/src/decoder/stateless/h264/vaapi.rs index bf86ecbe..ac0ed9cf 100644 --- a/src/decoder/stateless/h264/vaapi.rs +++ b/src/decoder/stateless/h264/vaapi.rs @@ -499,7 +499,7 @@ impl StatelessH264DecoderBackend for Vaapi fn decode_slice( &mut self, picture: &mut Self::Picture, - slice: &Slice<&[u8]>, + slice: &Slice, sps: &Sps, pps: &Pps, _: &Dpb, @@ -612,7 +612,7 @@ mod tests { |d, s, f| { simple_playback_loop( d, - NalIterator::>::new(s), + NalIterator::::new(s), f, &mut simple_playback_loop_owned_frames, output_format, diff --git a/src/decoder/stateless/h265.rs b/src/decoder/stateless/h265.rs index 591ee875..a0c860ff 100644 --- a/src/decoder/stateless/h265.rs +++ b/src/decoder/stateless/h265.rs @@ -122,7 +122,7 @@ pub trait StatelessH265DecoderBackend: StatelessDecoderBackend { pps: &Pps, dpb: &Dpb, rps: &RefPicSet, - slice: &Slice<&[u8]>, + slice: &Slice, ) -> StatelessBackendResult<()>; /// Called to dispatch a decode operation to the backend. @@ -130,7 +130,7 @@ pub trait StatelessH265DecoderBackend: StatelessDecoderBackend { fn decode_slice( &mut self, picture: &mut Self::Picture, - slice: &Slice<&[u8]>, + slice: &Slice, sps: &Sps, pps: &Pps, dpb: &Dpb, @@ -392,7 +392,7 @@ where } // See 8.3.2. - fn decode_rps(&mut self, slice: &Slice<&[u8]>, cur_pic: &PictureData) -> anyhow::Result<()> { + fn decode_rps(&mut self, slice: &Slice, cur_pic: &PictureData) -> anyhow::Result<()> { let hdr = slice.header(); if cur_pic.nalu_type.is_irap() && cur_pic.no_rasl_output_flag { @@ -916,7 +916,7 @@ where fn begin_picture( &mut self, timestamp: u64, - slice: &Slice<&[u8]>, + slice: &Slice, ) -> Result>, DecodeError> { if self.backend.frame_pool().num_free_frames() == 0 { return Err(DecodeError::NotEnoughOutputBuffers(1)); @@ -1010,11 +1010,7 @@ where } /// Handle a slice. Called once per slice NALU. - fn handle_slice( - &mut self, - pic: &mut CurrentPicState, - slice: &Slice<&[u8]>, - ) -> anyhow::Result<()> { + fn handle_slice(&mut self, pic: &mut CurrentPicState, slice: &Slice) -> anyhow::Result<()> { // A dependent slice may refer to a previous SPS which // is not the one currently in use. self.update_current_set_ids(slice.header().pic_parameter_set_id())?; @@ -1125,7 +1121,7 @@ where Ok(()) } - fn process_nalu(&mut self, timestamp: u64, nalu: Nalu<&[u8]>) -> Result<(), DecodeError> { + fn process_nalu(&mut self, timestamp: u64, nalu: Nalu) -> Result<(), DecodeError> { log::debug!( "Processing NALU {:?}, length is {}", nalu.header().nalu_type(), @@ -1346,7 +1342,7 @@ pub mod tests { |d, s, f| { simple_playback_loop( d, - NalIterator::>::new(s), + NalIterator::::new(s), f, &mut simple_playback_loop_owned_frames, DecodedFormat::NV12, diff --git a/src/decoder/stateless/h265/dummy.rs b/src/decoder/stateless/h265/dummy.rs index 3188953d..44a8f55f 100644 --- a/src/decoder/stateless/h265/dummy.rs +++ b/src/decoder/stateless/h265/dummy.rs @@ -40,7 +40,7 @@ impl StatelessH265DecoderBackend for Backend { _: &crate::codec::h265::parser::Pps, _: &crate::codec::h265::dpb::Dpb, _: &crate::decoder::stateless::h265::RefPicSet, - _: &crate::codec::h265::parser::Slice<&[u8]>, + _: &crate::codec::h265::parser::Slice, ) -> crate::decoder::stateless::StatelessBackendResult<()> { Ok(()) } @@ -48,7 +48,7 @@ impl StatelessH265DecoderBackend for Backend { fn decode_slice( &mut self, _: &mut Self::Picture, - _: &crate::codec::h265::parser::Slice<&[u8]>, + _: &crate::codec::h265::parser::Slice, _: &crate::codec::h265::parser::Sps, _: &crate::codec::h265::parser::Pps, _: &crate::codec::h265::dpb::Dpb, diff --git a/src/decoder/stateless/h265/vaapi.rs b/src/decoder/stateless/h265/vaapi.rs index 74b0e153..5917e019 100644 --- a/src/decoder/stateless/h265/vaapi.rs +++ b/src/decoder/stateless/h265/vaapi.rs @@ -384,7 +384,7 @@ impl VaapiBackend { } fn build_pic_param( - _: &Slice>, + _: &Slice, current_picture: &PictureData, current_surface_id: libva::VASurfaceID, dpb: &Dpb>, @@ -625,7 +625,7 @@ impl StatelessH265DecoderBackend pps: &Pps, dpb: &Dpb, rps: &RefPicSet, - slice: &Slice<&[u8]>, + slice: &Slice, ) -> crate::decoder::stateless::StatelessBackendResult<()> { let metadata = self.metadata_state.get_parsed()?; let context = &metadata.context; @@ -677,7 +677,7 @@ impl StatelessH265DecoderBackend fn decode_slice( &mut self, picture: &mut Self::Picture, - slice: &Slice<&[u8]>, + slice: &Slice, sps: &Sps, _: &Pps, _: &Dpb, @@ -885,7 +885,7 @@ mod tests { |d, s, f| { simple_playback_loop( d, - NalIterator::>::new(s), + NalIterator::::new(s), f, &mut simple_playback_loop_owned_frames, output_format, diff --git a/src/utils.rs b/src/utils.rs index 765ac850..01ab408e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -78,7 +78,7 @@ impl<'a, Nalu> NalIterator<'a, Nalu> { } } -impl<'a> Iterator for NalIterator<'a, H264Nalu<&[u8]>> { +impl<'a> Iterator for NalIterator<'a, H264Nalu<'a>> { type Item = &'a [u8]; fn next(&mut self) -> Option { @@ -92,7 +92,7 @@ impl<'a> Iterator for NalIterator<'a, H264Nalu<&[u8]>> { } } -impl<'a> Iterator for NalIterator<'a, H265Nalu<&[u8]>> { +impl<'a> Iterator for NalIterator<'a, H265Nalu<'a>> { type Item = &'a [u8]; fn next(&mut self) -> Option {