From b1565131e7ff04c9c1db1c0c478f96b5ae31d793 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Sun, 24 Nov 2024 20:19:58 +0100 Subject: [PATCH] Remove two dependencies (#28) * Remove thiserror dependency * Remove paste dependency * Update MSRV lockfile --- Cargo.lock.MSRV | 166 ++++++++++++++----------------------- Cargo.toml | 2 - src/errors.rs | 38 ++++++--- src/yuv.rs | 21 +++-- src/yuv_rgb/transfer.rs | 62 +++++++------- yuvxyb-math/src/lib.rs | 2 +- yuvxyb-math/src/mul_add.rs | 2 +- 7 files changed, 136 insertions(+), 157 deletions(-) diff --git a/Cargo.lock.MSRV b/Cargo.lock.MSRV index dde4b6a..8b10e8b 100644 --- a/Cargo.lock.MSRV +++ b/Cargo.lock.MSRV @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "adler2" version = "2.0.0" @@ -37,28 +31,27 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "av-data" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75b98a3525d00f920df9a2d44cc99b9cc5b7dc70d7fbb612cd755270dbe6552" +checksum = "fca67ba5d317924c02180c576157afd54babe48a76ebc66ce6d34bb8ba08308e" dependencies = [ "byte-slice-cast", "bytes", "num-derive", "num-rational", "num-traits", - "thiserror", ] [[package]] @@ -81,9 +74,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.18.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" [[package]] name = "byteorder" @@ -99,9 +92,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "bytes" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "cast" @@ -144,18 +137,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstyle", "clap_lex", @@ -163,9 +156,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "crc32fast" @@ -224,21 +217,21 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "fdeflate" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" +checksum = "07c6f4c64c1d33a3111c4466f7365ebdcc37c5bd1ea0d62aae2e3d722aacbedb" dependencies = [ "simd-adler32", ] [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", + "miniz_oxide", ] [[package]] @@ -270,9 +263,9 @@ checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "image" -version = "0.25.2" +version = "0.25.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99314c8a2152b8ddb211f924cdae532d8c5e4c8bb54728e12fff1b0cd5963a10" +checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b" dependencies = [ "bytemuck", "byteorder-lite", @@ -313,15 +306,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "log" @@ -335,16 +328,6 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" -[[package]] -name = "miniz_oxide" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", - "simd-adler32", -] - [[package]] name = "miniz_oxide" version = "0.8.0" @@ -352,6 +335,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ "adler2", + "simd-adler32", ] [[package]] @@ -406,9 +390,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oorandom" @@ -416,23 +400,17 @@ version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - [[package]] name = "png" -version = "0.17.13" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" +checksum = "52f9d46a34a05a6a57566bc2bfae066ef07585a6e3fa30fbbdff5936380623f0" dependencies = [ "bitflags", "crc32fast", "fdeflate", "flate2", - "miniz_oxide 0.7.4", + "miniz_oxide", ] [[package]] @@ -446,9 +424,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "307e3004becf10f5a6e0d59d20f3cd28231b0e0827a96cd3e0ce6d14bc1e4bb3" dependencies = [ "unicode-ident", ] @@ -494,9 +472,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -506,9 +484,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -517,9 +495,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "ryu" @@ -538,18 +516,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.210" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", @@ -558,9 +536,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -576,35 +554,15 @@ checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] name = "syn" -version = "2.0.77" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "thiserror" -version = "1.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "tinytemplate" version = "1.2.1" @@ -617,9 +575,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "v_frame" @@ -650,9 +608,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -661,9 +619,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", @@ -676,9 +634,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -686,9 +644,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", @@ -699,9 +657,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "winapi-util" @@ -804,9 +762,7 @@ dependencies = [ "interpolate_name", "log", "num-traits", - "paste", "rand", - "thiserror", "v_frame", "yuvxyb-math", ] diff --git a/Cargo.toml b/Cargo.toml index e8391fb..004f1cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,8 +21,6 @@ yuvxyb-math = { version = "0.1.0", path = "yuvxyb-math" } av-data = "0.4.2" log = "0.4.17" num-traits = "0.2.15" -paste = "1.0.9" -thiserror = "1.0.40" v_frame = "0.3.8" [dev-dependencies] diff --git a/src/errors.rs b/src/errors.rs index 551910d..a9e7821 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,26 +1,35 @@ -use thiserror::Error; +use std::fmt; /// Error type for when converting data from one color space to another fails. /// /// Note that some conversions are infallible. These conversions will be /// implemented in the [`From`] trait. Check the type's documentation /// to see which conversions are implemented. -#[derive(Debug, Error, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ConversionError { - #[error("Cannot convert between YUV and RGB using these matrix coefficients.")] UnsupportedMatrixCoefficients, - #[error("No matrix coefficients were specified.")] UnspecifiedMatrixCoefficients, - #[error("Cannot convert between YUV and RGB using these primaries.")] UnsupportedColorPrimaries, - #[error("No primaries were specified.")] UnspecifiedColorPrimaries, - #[error("Cannot convert between YUV and RGB using this transfer function.")] UnsupportedTransferCharacteristic, - #[error("No transfer function was specified.")] UnspecifiedTransferCharacteristic, } +impl std::error::Error for ConversionError {} + +impl fmt::Display for ConversionError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::UnsupportedMatrixCoefficients => write!(f, "Cannot convert between YUV and RGB using these matrix coefficients."), + Self::UnspecifiedMatrixCoefficients => write!(f, "No matrix coefficients were specified."), + Self::UnsupportedColorPrimaries => write!(f, "Cannot convert between YUV and RGB using these primaries."), + Self::UnspecifiedColorPrimaries => write!(f, "No primaries were specified."), + Self::UnsupportedTransferCharacteristic => write!(f, "Cannot convert between YUV and RGB using this transfer function."), + Self::UnspecifiedTransferCharacteristic => write!(f, "No transfer function was specified."), + } + } +} + /// Error type for when creating one of the colorspace structs fails. /// /// Note that the [`Yuv`] struct uses a separate Error type, [`YuvError`]. @@ -39,11 +48,20 @@ pub enum ConversionError { /// /// [`Yuv`]: crate::yuv::Yuv /// [`YuvError`]: crate::yuv::YuvError -#[derive(Debug, Error, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum CreationError { /// There is a mismatch between the supplied data and the supplied resolution. /// /// Generally, data.len() should be equal to width * height. - #[error("Data length does not match the specified dimensions.")] ResolutionMismatch, } + +impl std::error::Error for CreationError {} + +impl fmt::Display for CreationError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::ResolutionMismatch => write!(f, "Data length does not match the specified dimensions."), + } + } +} diff --git a/src/yuv.rs b/src/yuv.rs index fea6256..27c946a 100644 --- a/src/yuv.rs +++ b/src/yuv.rs @@ -1,7 +1,7 @@ +use std::fmt; use std::mem::size_of; use av_data::pixel::{ColorPrimaries, MatrixCoefficients, TransferCharacteristic}; -use thiserror::Error; use v_frame::{frame::Frame, plane::Plane, prelude::Pixel}; use crate::{yuv_rgb::rgb_to_yuv, ConversionError, LinearRgb, Rgb, Xyb}; @@ -36,11 +36,10 @@ pub struct YuvConfig { } /// Error type for when creating a [`Yuv`] struct goes wrong. -#[derive(Debug, Error, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum YuvError { /// The configured subsampling does not match /// the actual subsampling in the frame data. - #[error("Configured subsampling does not match subsampling of frame data.")] SubsamplingMismatch, /// The width of the luminance plane is not @@ -48,7 +47,6 @@ pub enum YuvError { /// /// For example, for 4:2:0 chroma subsampling, the width /// of the luminance plane must be divisible by 2. - #[error("The frame width does not support the configured subsampling.")] InvalidLumaWidth, /// The height of the luminance plane is not @@ -56,7 +54,6 @@ pub enum YuvError { /// /// For example, for 4:2:0 chroma subsampling, the height /// of the luminance plane must be divisible by 2. - #[error("The frame height does not support the configured subsampling.")] InvalidLumaHeight, /// The supplied data contains values which are outside @@ -65,10 +62,22 @@ pub enum YuvError { /// This error can not occur for bit depths of 8 and 16, /// as the valid range of values matches the available /// range in the underlying data type exactly. - #[error("Data contains values which are not valid for the configured bit depth.")] InvalidData, } +impl std::error::Error for YuvError {} + +impl fmt::Display for YuvError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::SubsamplingMismatch => write!(f, "Configured subsampling does not match subsampling of frame data."), + Self::InvalidLumaWidth => write!(f, "The frame width does not support the configured subsampling."), + Self::InvalidLumaHeight => write!(f, "The frame height does not support the configured subsampling."), + Self::InvalidData => write!(f, "Data contains values which are not valid for the configured bit depth."), + } + } +} + impl Yuv { /// Create a new [`Yuv`] with the given data and configuration. /// diff --git a/src/yuv_rgb/transfer.rs b/src/yuv_rgb/transfer.rs index de79724..49144be 100644 --- a/src/yuv_rgb/transfer.rs +++ b/src/yuv_rgb/transfer.rs @@ -56,43 +56,41 @@ impl TransferFunction for TransferCharacteristic { } macro_rules! image_transfer_fn { - ($name:ident) => { - paste::item! { - fn [](mut input: Vec<[f32; 3]>) -> Vec<[f32; 3]> { - // SAFETY: Referencing preallocated memory (input) - let input_flat = unsafe { - from_raw_parts_mut(input.as_mut_ptr().cast::(), input.len() * 3) - }; - - for val in input_flat { - *val = $name(*val); - } - - input + ($image_name:ident, $name:ident) => { + fn $image_name(mut input: Vec<[f32; 3]>) -> Vec<[f32; 3]> { + // SAFETY: Referencing preallocated memory (input) + let input_flat = unsafe { + from_raw_parts_mut(input.as_mut_ptr().cast::(), input.len() * 3) + }; + + for val in input_flat { + *val = $name(*val); } + + input } }; } -image_transfer_fn!(log100_inverse_oetf); -image_transfer_fn!(log316_inverse_oetf); -image_transfer_fn!(rec_1886_eotf); -image_transfer_fn!(rec_470m_oetf); -image_transfer_fn!(rec_470bg_oetf); -image_transfer_fn!(xvycc_eotf); -image_transfer_fn!(srgb_eotf); -image_transfer_fn!(st_2084_inverse_oetf); -image_transfer_fn!(arib_b67_inverse_oetf); - -image_transfer_fn!(log100_oetf); -image_transfer_fn!(log316_oetf); -image_transfer_fn!(rec_1886_inverse_eotf); -image_transfer_fn!(rec_470m_inverse_oetf); -image_transfer_fn!(rec_470bg_inverse_oetf); -image_transfer_fn!(xvycc_inverse_eotf); -image_transfer_fn!(srgb_inverse_eotf); -image_transfer_fn!(st_2084_oetf); -image_transfer_fn!(arib_b67_oetf); +image_transfer_fn!(image_log100_inverse_oetf, log100_inverse_oetf); +image_transfer_fn!(image_log316_inverse_oetf, log316_inverse_oetf); +image_transfer_fn!(image_rec_1886_eotf, rec_1886_eotf); +image_transfer_fn!(image_rec_470m_oetf, rec_470m_oetf); +image_transfer_fn!(image_rec_470bg_oetf, rec_470bg_oetf); +image_transfer_fn!(image_xvycc_eotf, xvycc_eotf); +image_transfer_fn!(image_srgb_eotf, srgb_eotf); +image_transfer_fn!(image_st_2084_inverse_oetf, st_2084_inverse_oetf); +image_transfer_fn!(image_arib_b67_inverse_oetf, arib_b67_inverse_oetf); + +image_transfer_fn!(image_log100_oetf, log100_oetf); +image_transfer_fn!(image_log316_oetf, log316_oetf); +image_transfer_fn!(image_rec_1886_inverse_eotf, rec_1886_inverse_eotf); +image_transfer_fn!(image_rec_470m_inverse_oetf, rec_470m_inverse_oetf); +image_transfer_fn!(image_rec_470bg_inverse_oetf, rec_470bg_inverse_oetf); +image_transfer_fn!(image_xvycc_inverse_eotf, xvycc_inverse_eotf); +image_transfer_fn!(image_srgb_inverse_eotf, srgb_inverse_eotf); +image_transfer_fn!(image_st_2084_oetf, st_2084_oetf); +image_transfer_fn!(image_arib_b67_oetf, arib_b67_oetf); const REC709_ALPHA: f32 = 1.099_296_8; const REC709_BETA: f32 = 0.018_053_97; diff --git a/yuvxyb-math/src/lib.rs b/yuvxyb-math/src/lib.rs index 67a68b3..fc80956 100644 --- a/yuvxyb-math/src/lib.rs +++ b/yuvxyb-math/src/lib.rs @@ -40,4 +40,4 @@ mod pow_exp; pub use cbrtf::cbrtf; pub use matrix::{ColVector, Matrix, RowVector}; pub use mul_add::multiply_add; -pub use pow_exp::{expf, powf}; \ No newline at end of file +pub use pow_exp::{expf, powf}; diff --git a/yuvxyb-math/src/mul_add.rs b/yuvxyb-math/src/mul_add.rs index ae7e799..1543ba2 100644 --- a/yuvxyb-math/src/mul_add.rs +++ b/yuvxyb-math/src/mul_add.rs @@ -8,4 +8,4 @@ pub fn multiply_add(a: f32, b: f32, c: f32) -> f32 { } else { a * b + c } -} \ No newline at end of file +}