devices/virtio/video/
vda.rs1use crate::virtio::video::error::VideoError;
8use crate::virtio::video::format::Profile;
9
10impl From<libvda::Error> for VideoError {
12 fn from(error: libvda::Error) -> Self {
13 VideoError::BackendFailure(error.into())
14 }
15}
16
17macro_rules! impl_libvda_conversion {
18 ( $( ( $x:ident, $y:ident ) ),* ) => {
19 pub fn from_libvda_profile(p: libvda::Profile) -> Option<Self> {
20 match p {
21 $(libvda::Profile::$x => Some(Self::$y),)*
22 _ => None
23 }
24 }
25
26 #[cfg(feature = "video-encoder")]
27 pub fn to_libvda_profile(self) -> Option<libvda::Profile> {
28 match self {
29 $(Self::$y => Some(libvda::Profile::$x),)*
30 _ => None
31 }
32 }
33 }
34}
35
36impl Profile {
37 impl_libvda_conversion!(
38 (H264ProfileBaseline, H264Baseline),
39 (H264ProfileMain, H264Main),
40 (H264ProfileExtended, H264Extended),
41 (H264ProfileHigh, H264High),
42 (H264ProfileHigh10Profile, H264High10),
43 (H264ProfileHigh422Profile, H264High422),
44 (
45 H264ProfileHigh444PredictiveProfile,
46 H264High444PredictiveProfile
47 ),
48 (H264ProfileScalableBaseline, H264ScalableBaseline),
49 (H264ProfileScalableHigh, H264ScalableHigh),
50 (H264ProfileStereoHigh, H264StereoHigh),
51 (H264ProfileMultiviewHigh, H264MultiviewHigh),
52 (HevcProfileMain, HevcMain),
53 (HevcProfileMain10, HevcMain10),
54 (HevcProfileMainStillPicture, HevcMainStillPicture),
55 (VP8, VP8Profile0),
56 (VP9Profile0, VP9Profile0),
57 (VP9Profile1, VP9Profile1),
58 (VP9Profile2, VP9Profile2),
59 (VP9Profile3, VP9Profile3)
60 );
61}