forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiB8c7bf80Tahinli3 months ago114 commits

dummy.rs75 lines, 2.3 KiBHistoryRawDownload
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
8use std::cell::RefCell;
9use std::rc::Rc;
10
11use crate::backend::dummy::decoder::Backend;
12use crate::backend::dummy::decoder::Handle;
13use crate::codec::h264::dpb::Dpb;
14use crate::codec::h264::dpb::DpbEntry;
15use crate::codec::h264::parser::Pps;
16use crate::codec::h264::parser::Slice;
17use crate::codec::h264::parser::SliceHeader;
18use crate::codec::h264::parser::Sps;
19use crate::codec::h264::picture::PictureData;
20use crate::decoder::stateless::h264::StatelessH264DecoderBackend;
21use crate::decoder::stateless::h264::H264;
22use crate::decoder::stateless::NewPictureResult;
23use crate::decoder::stateless::NewStatelessDecoderError;
24use crate::decoder::stateless::StatelessBackendResult;
25use crate::decoder::stateless::StatelessDecoder;
26use crate::decoder::BlockingMode;
27
28impl StatelessH264DecoderBackend for Backend {
29 fn new_sequence(&mut self, _: &Rc<Sps>) -> StatelessBackendResult<()> {
30 Ok(())
31 }
32
33 fn start_picture(
34 &mut self,
35 _: &mut Self::Picture,
36 _: &PictureData,
37 _: &Sps,
38 _: &Pps,
39 _: &Dpb<Self::Handle>,
40 _: &SliceHeader,
41 ) -> StatelessBackendResult<()> {
42 Ok(())
43 }
44
45 fn new_field_picture(&mut self, _: u64, _: &Self::Handle) -> NewPictureResult<()> {
46 Ok(())
47 }
48
49 fn decode_slice(
50 &mut self,
51 _: &mut Self::Picture,
52 _: &Slice,
53 _: &Sps,
54 _: &Pps,
55 _: &[&DpbEntry<Self::Handle>],
56 _: &[&DpbEntry<Self::Handle>],
57 ) -> StatelessBackendResult<()> {
58 Ok(())
59 }
60
61 fn submit_picture(&mut self, _: Self::Picture) -> StatelessBackendResult<Self::Handle> {
62 Ok(Handle { handle: Rc::new(RefCell::new(Default::default())) })
63 }
64
65 fn new_picture(&mut self, _: u64) -> NewPictureResult<()> {
66 Ok(())
67 }
68}
69
70impl StatelessDecoder<H264, Backend> {
71 // Creates a new instance of the decoder using the dummy backend.
72 pub fn new_dummy(blocking_mode: BlockingMode) -> Result<Self, NewStatelessDecoderError> {
73 Self::new(Backend::new(), blocking_mode)
74 }
75}