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