1 // Copyright 2023 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 //! This file contains a dummy backend whose only purpose is to let the decoder 6 //! run so we can test it in isolation. 7 8 use std::cell::RefCell; 9 use std::rc::Rc; 10 11 use crate::backend::dummy::decoder::Backend; 12 use crate::backend::dummy::decoder::Handle; 13 use crate::decoder::stateless::h265::H265; 14 use crate::decoder::stateless::NewStatelessDecoderError; 15 use crate::decoder::stateless::StatelessDecoder; 16 use crate::decoder::BlockingMode; 17 18 use crate::decoder::stateless::h265::StatelessH265DecoderBackend; 19 use crate::Resolution; 20 21 impl StatelessH265DecoderBackend for Backend { new_sequence( &mut self, _: &crate::codec::h265::parser::Sps, ) -> crate::decoder::stateless::StatelessBackendResult<()>22 fn new_sequence( 23 &mut self, 24 _: &crate::codec::h265::parser::Sps, 25 ) -> crate::decoder::stateless::StatelessBackendResult<()> { 26 Ok(()) 27 } 28 new_picture( &mut self, _: Resolution, _: u64, ) -> crate::decoder::stateless::NewPictureResult<Self::Picture>29 fn new_picture( 30 &mut self, 31 _: Resolution, 32 _: u64, 33 ) -> crate::decoder::stateless::NewPictureResult<Self::Picture> { 34 Ok(()) 35 } 36 begin_picture( &mut self, _: &mut Self::Picture, _: &crate::codec::h265::picture::PictureData, _: &crate::codec::h265::parser::Sps, _: &crate::codec::h265::parser::Pps, _: &crate::codec::h265::dpb::Dpb<Self::Handle>, _: &crate::decoder::stateless::h265::RefPicSet<Self::Handle>, _: &crate::codec::h265::parser::Slice, ) -> crate::decoder::stateless::StatelessBackendResult<()>37 fn begin_picture( 38 &mut self, 39 _: &mut Self::Picture, 40 _: &crate::codec::h265::picture::PictureData, 41 _: &crate::codec::h265::parser::Sps, 42 _: &crate::codec::h265::parser::Pps, 43 _: &crate::codec::h265::dpb::Dpb<Self::Handle>, 44 _: &crate::decoder::stateless::h265::RefPicSet<Self::Handle>, 45 _: &crate::codec::h265::parser::Slice, 46 ) -> crate::decoder::stateless::StatelessBackendResult<()> { 47 Ok(()) 48 } 49 decode_slice( &mut self, _: &mut Self::Picture, _: &crate::codec::h265::parser::Slice, _: &crate::codec::h265::parser::Sps, _: &crate::codec::h265::parser::Pps, _: &[Option<super::RefPicListEntry<Self::Handle>>; 16], _: &[Option<super::RefPicListEntry<Self::Handle>>; 16], ) -> crate::decoder::stateless::StatelessBackendResult<()>50 fn decode_slice( 51 &mut self, 52 _: &mut Self::Picture, 53 _: &crate::codec::h265::parser::Slice, 54 _: &crate::codec::h265::parser::Sps, 55 _: &crate::codec::h265::parser::Pps, 56 _: &[Option<super::RefPicListEntry<Self::Handle>>; 16], 57 _: &[Option<super::RefPicListEntry<Self::Handle>>; 16], 58 ) -> crate::decoder::stateless::StatelessBackendResult<()> { 59 Ok(()) 60 } 61 submit_picture( &mut self, _: Self::Picture, ) -> crate::decoder::stateless::StatelessBackendResult<Self::Handle>62 fn submit_picture( 63 &mut self, 64 _: Self::Picture, 65 ) -> crate::decoder::stateless::StatelessBackendResult<Self::Handle> { 66 Ok(Handle { handle: Rc::new(RefCell::new(Default::default())) }) 67 } 68 } 69 impl StatelessDecoder<H265, Backend> { 70 // Creates a new instance of the decoder using the dummy backend. new_dummy(blocking_mode: BlockingMode) -> Result<Self, NewStatelessDecoderError>71 pub fn new_dummy(blocking_mode: BlockingMode) -> Result<Self, NewStatelessDecoderError> { 72 Self::new(Backend::new(), blocking_mode) 73 } 74 } 75