1 // Copyright 2022 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::decoders::vp8::backends::StatelessDecoderBackend; 12 use crate::decoders::vp8::decoder::Decoder; 13 use crate::decoders::vp8::parser::Header; 14 use crate::decoders::vp8::parser::MbLfAdjustments; 15 use crate::decoders::vp8::parser::Segmentation; 16 use crate::decoders::BlockingMode; 17 use crate::utils::dummy::*; 18 19 impl StatelessDecoderBackend for Backend { new_sequence(&mut self, _: &crate::decoders::vp8::parser::Header) -> super::Result<()>20 fn new_sequence(&mut self, _: &crate::decoders::vp8::parser::Header) -> super::Result<()> { 21 Ok(()) 22 } 23 submit_picture( &mut self, _: &Header, _: Option<&Self::Handle>, _: Option<&Self::Handle>, _: Option<&Self::Handle>, _: &[u8], _: &Segmentation, _: &MbLfAdjustments, _: u64, _: BlockingMode, ) -> super::Result<Self::Handle>24 fn submit_picture( 25 &mut self, 26 _: &Header, 27 _: Option<&Self::Handle>, 28 _: Option<&Self::Handle>, 29 _: Option<&Self::Handle>, 30 _: &[u8], 31 _: &Segmentation, 32 _: &MbLfAdjustments, 33 _: u64, 34 _: BlockingMode, 35 ) -> super::Result<Self::Handle> { 36 Ok(Handle { 37 handle: Rc::new(RefCell::new(BackendHandle)), 38 }) 39 } 40 41 #[cfg(test)] get_test_params(&self) -> &dyn std::any::Any42 fn get_test_params(&self) -> &dyn std::any::Any { 43 // There are no test parameters for the dummy backend. 44 unimplemented!() 45 } 46 } 47 48 impl Decoder<Handle> { 49 // Creates a new instance of the decoder using the dummy backend. new_dummy(blocking_mode: BlockingMode) -> anyhow::Result<Self>50 pub fn new_dummy(blocking_mode: BlockingMode) -> anyhow::Result<Self> { 51 Self::new(Box::new(Backend::new()), blocking_mode) 52 } 53 } 54