-
Notifications
You must be signed in to change notification settings - Fork 259
/
Copy pathmod.rs
61 lines (54 loc) · 1.7 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) 2001-2016, Alliance for Open Media. All rights reserved
// Copyright (c) 2017-2021, The rav1e contributors. All rights reserved
//
// This source code is subject to the terms of the BSD 2 Clause License and
// the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
// was not distributed with this source code in the LICENSE file, you can
// obtain it at www.aomedia.org/license/software. If the Alliance for Open
// Media Patent License 1.0 was not distributed with this source code in the
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.
use rav1e::prelude::*;
use std::io;
pub mod y4m;
pub trait FrameBuilder<T: Pixel> {
fn new_frame(&self) -> Frame<T>;
}
pub trait Decoder: Send {
fn get_video_details(&self) -> VideoDetails;
fn read_frame<T: Pixel, F: FrameBuilder<T>>(
&mut self, ctx: &F, cfg: &VideoDetails,
) -> Result<Frame<T>, DecodeError>;
}
#[derive(Debug)]
#[allow(clippy::upper_case_acronyms)]
pub enum DecodeError {
EOF,
BadInput,
UnknownColorspace,
ParseError,
IoError(io::Error),
MemoryLimitExceeded,
}
#[derive(Debug, Clone, Copy)]
pub struct VideoDetails {
pub width: usize,
pub height: usize,
pub sample_aspect_ratio: Rational,
pub bit_depth: usize,
pub chroma_sampling: ChromaSampling,
pub chroma_sample_position: ChromaSamplePosition,
pub time_base: Rational,
}
impl Default for VideoDetails {
fn default() -> Self {
VideoDetails {
width: 640,
height: 480,
sample_aspect_ratio: Rational { num: 1, den: 1 },
bit_depth: 8,
chroma_sampling: ChromaSampling::Cs420,
chroma_sample_position: ChromaSamplePosition::Unknown,
time_base: Rational { num: 30, den: 1 },
}
}
}