Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
google
GitHub Repository: google/crosvm
Path: blob/main/devices/src/virtio/video/decoder/capability.rs
5394 views
1
// Copyright 2020 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
//! Capablities of the virtio video decoder device.
6
7
use std::collections::BTreeMap;
8
9
use crate::virtio::video::control::*;
10
use crate::virtio::video::format::*;
11
12
#[derive(Clone)]
13
pub struct Capability {
14
in_fmts: Vec<FormatDesc>,
15
out_fmts: Vec<FormatDesc>,
16
17
// Stores supporterd profiles and levels for each format.
18
profiles: BTreeMap<Format, Vec<Profile>>,
19
levels: BTreeMap<Format, Vec<Level>>,
20
}
21
22
impl Capability {
23
// Make this method pub(super) so backends can create capabilities.
24
pub(super) fn new(
25
in_fmts: Vec<FormatDesc>,
26
out_fmts: Vec<FormatDesc>,
27
profiles: BTreeMap<Format, Vec<Profile>>,
28
levels: BTreeMap<Format, Vec<Level>>,
29
) -> Self {
30
Self {
31
in_fmts,
32
out_fmts,
33
profiles,
34
levels,
35
}
36
}
37
38
pub fn input_formats(&self) -> &Vec<FormatDesc> {
39
&self.in_fmts
40
}
41
42
pub fn output_formats(&self) -> &Vec<FormatDesc> {
43
&self.out_fmts
44
}
45
46
pub fn query_control(&self, t: &QueryCtrlType) -> Option<QueryCtrlResponse> {
47
use QueryCtrlType::*;
48
match *t {
49
Profile(fmt) => {
50
let profiles = self.profiles.get(&fmt)?;
51
Some(QueryCtrlResponse::Profile(profiles.to_vec()))
52
}
53
Level(fmt) => {
54
let levels = self.levels.get(&fmt)?;
55
Some(QueryCtrlResponse::Level(levels.to_vec()))
56
}
57
}
58
}
59
}
60
61