/rust/registry/src/index.crates.io-6f17d22bba15001f/v_frame-0.3.9/src/frame.rs
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) 2018-2020, The rav1e contributors. All rights reserved |
2 | | // |
3 | | // This source code is subject to the terms of the BSD 2 Clause License and |
4 | | // the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
5 | | // was not distributed with this source code in the LICENSE file, you can |
6 | | // obtain it at www.aomedia.org/license/software. If the Alliance for Open |
7 | | // Media Patent License 1.0 was not distributed with this source code in the |
8 | | // PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
9 | | |
10 | | use crate::math::*; |
11 | | use crate::pixel::*; |
12 | | use crate::plane::*; |
13 | | |
14 | | #[cfg(feature = "serialize")] |
15 | | use serde::{Deserialize, Serialize}; |
16 | | |
17 | | /// Represents a raw video frame |
18 | | #[derive(Debug, Clone, Eq, PartialEq)] |
19 | | #[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))] |
20 | | pub struct Frame<T: Pixel> { |
21 | | /// Planes constituting the frame. |
22 | | pub planes: [Plane<T>; 3], |
23 | | } |
24 | | |
25 | | impl<T: Pixel> Frame<T> { |
26 | | /// Creates a new frame with the given parameters. |
27 | | /// |
28 | | /// Allocates data for the planes. |
29 | 0 | pub fn new_with_padding( |
30 | 0 | width: usize, |
31 | 0 | height: usize, |
32 | 0 | chroma_sampling: ChromaSampling, |
33 | 0 | luma_padding: usize, |
34 | 0 | ) -> Self { |
35 | 0 | let luma_width = width.align_power_of_two(3); |
36 | 0 | let luma_height = height.align_power_of_two(3); |
37 | 0 |
|
38 | 0 | let (chroma_decimation_x, chroma_decimation_y) = |
39 | 0 | chroma_sampling.get_decimation().unwrap_or((0, 0)); |
40 | 0 | let (chroma_width, chroma_height) = |
41 | 0 | chroma_sampling.get_chroma_dimensions(luma_width, luma_height); |
42 | 0 | let chroma_padding_x = luma_padding >> chroma_decimation_x; |
43 | 0 | let chroma_padding_y = luma_padding >> chroma_decimation_y; |
44 | 0 |
|
45 | 0 | Frame { |
46 | 0 | planes: [ |
47 | 0 | Plane::new(luma_width, luma_height, 0, 0, luma_padding, luma_padding), |
48 | 0 | Plane::new( |
49 | 0 | chroma_width, |
50 | 0 | chroma_height, |
51 | 0 | chroma_decimation_x, |
52 | 0 | chroma_decimation_y, |
53 | 0 | chroma_padding_x, |
54 | 0 | chroma_padding_y, |
55 | 0 | ), |
56 | 0 | Plane::new( |
57 | 0 | chroma_width, |
58 | 0 | chroma_height, |
59 | 0 | chroma_decimation_x, |
60 | 0 | chroma_decimation_y, |
61 | 0 | chroma_padding_x, |
62 | 0 | chroma_padding_y, |
63 | 0 | ), |
64 | 0 | ], |
65 | 0 | } |
66 | 0 | } Unexecuted instantiation: <v_frame::frame::Frame<u16>>::new_with_padding Unexecuted instantiation: <v_frame::frame::Frame<u8>>::new_with_padding Unexecuted instantiation: <v_frame::frame::Frame<_>>::new_with_padding |
67 | | } |