Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Oct 18, 2024
1 parent 06be72b commit 444435c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ fn main() {
&mut rgba,
width as usize,
height as usize,
yuvs::YuvRange::TV,
yuvs::YuvRange::Tv,
yuvs::YuvStandardMatrix::Bt601,
).unwrap();
let end_time = Instant::now().sub(start_time);
Expand Down
6 changes: 6 additions & 0 deletions yuvs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "yuvs"
version = "0.1.0"
edition = "2021"

[dependencies]
42 changes: 42 additions & 0 deletions yuvs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) Radzivon Bartoshyk, 10/2024. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#![forbid(unsafe_code)]

mod yuv400;
mod yuv420;
mod yuv422;
mod yuv444;
mod yuv_support;

pub use yuv400::yuv400_to_rgb;
pub use yuv420::yuv420_to_rgb;
pub use yuv422::yuv422_to_rgb;
pub use yuv444::yuv444_to_rgb;
pub use yuv_support::*;
8 changes: 4 additions & 4 deletions yuvs/src/yuv_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ pub fn get_forward_transform(
/// Declares YUV range TV (limited) or Full
pub enum YuvRange {
/// Limited range Y ∈ [16 << (depth - 8), 16 << (depth - 8) + 224 << (depth - 8)], UV ∈ [-1 << (depth - 1), -1 << (depth - 1) + 1 << (depth - 1)]
TV,
Tv,
/// Full range Y ∈ [0, 2^bit_depth - 1], UV ∈ [-1 << (depth - 1), -1 << (depth - 1) + 2^bit_depth - 1]
Full,
Pc,
}

#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
Expand All @@ -164,14 +164,14 @@ pub struct YuvChromaRange {

pub const fn get_yuv_range(depth: u32, range: YuvRange) -> YuvChromaRange {
match range {
YuvRange::TV => YuvChromaRange {
YuvRange::Tv => YuvChromaRange {
bias_y: 16 << (depth - 8),
bias_uv: 1 << (depth - 1),
range_y: 219 << (depth - 8),
range_uv: 224 << (depth - 8),
range,
},
YuvRange::Full => YuvChromaRange {
YuvRange::Pc => YuvChromaRange {
bias_y: 0,
bias_uv: 1 << (depth - 1),
range_uv: (1 << depth) - 1,
Expand Down

0 comments on commit 444435c

Please sign in to comment.