### Grain Table File Format Example Source: https://docs.rs/av1-grain/latest/av1_grain/fn.parse_grain_table.html?search=std%3A%3Avec Illustrates the ASCII file format for the grain table. It shows the structure for defining film grain segments, including parameters like start time, end time, apply grain flag, random seed, and dynamic grain. It also details the format for array parameters such as AR coefficients and scaling points. ```text filmgrn1 E p ... sY ... sCb ... sCr ... cY .... cCb .... cCr .... E ... ``` -------------------------------- ### Manipulate ArrayVec Elements Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html Examples of adding, inserting, and removing elements from an ArrayVec, including safe and fallible methods. ```rust use arrayvec::ArrayVec; let mut array = ArrayVec::<_, 2>::new(); // Safe push array.push(1); // Fallible push let result = array.try_push(2); assert!(result.is_ok()); // Insertion array.insert(0, 3); // Truncation array.truncate(1); ``` -------------------------------- ### Get Remaining Capacity of ArrayVec in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=u32+-%3E+bool Demonstrates how to find the remaining capacity of an `ArrayVec` using the `remaining_capacity()` method in Rust. This indicates how many more elements can be added. ```rust use arrayvec::ArrayVec; let mut array = ArrayVec::from([1, 2, 3]); array.pop(); assert_eq!(array.remaining_capacity(), 1); ``` -------------------------------- ### Get Capacity of ArrayVec in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=u32+-%3E+bool Shows how to retrieve the total capacity of an `ArrayVec` using the `capacity()` method in Rust. This returns the maximum number of elements it can hold. ```rust use arrayvec::ArrayVec; let array = ArrayVec::from([1, 2, 3]); assert_eq!(array.capacity(), 3); ``` -------------------------------- ### Generate photon noise parameters in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/fn.generate_photon_noise_params.html?search= The generate_photon_noise_params function creates a GrainTableSegment based on a specified time range and noise generation arguments. It is designed for AV1 video grain synthesis, requiring a start and end time along with a NoiseGenArgs configuration object. ```rust pub fn generate_photon_noise_params( start_time: u64, end_time: u64, args: NoiseGenArgs, ) -> GrainTableSegment ``` -------------------------------- ### Create and Manage ArrayVec Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html Demonstrates how to instantiate an ArrayVec using standard or constant constructors and how to check its capacity and length. ```rust use arrayvec::ArrayVec; // Standard creation let mut array = ArrayVec::<_, 16>::new(); array.push(1); // Constant creation static ARRAY: ArrayVec = ArrayVec::new_const(); // Capacity and length checks assert_eq!(array.len(), 1); assert_eq!(array.capacity(), 16); ``` -------------------------------- ### Get Length of ArrayVec in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=u32+-%3E+bool Illustrates how to get the current number of elements in an `ArrayVec` using the `len()` method in Rust. This method returns a `usize` representing the count. ```rust use arrayvec::ArrayVec; let mut array = ArrayVec::from([1, 2, 3]); array.pop(); assert_eq!(array.len(), 2); ``` -------------------------------- ### Initialize ArrayVec Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to create new instances of ArrayVec using standard and constant constructors. ```rust use arrayvec::ArrayVec; // Standard initialization let mut array = ArrayVec::<_, 16>::new(); array.push(1); // Constant initialization static ARRAY: ArrayVec = ArrayVec::new_const(); ``` -------------------------------- ### take Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html Returns the ArrayVec, replacing the original with a new empty ArrayVec. ```APIDOC ## POST /take ### Description Returns the `ArrayVec`, replacing the original with a new empty `ArrayVec`. ### Method POST ### Endpoint `/take` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "No request body needed for take" } ``` ### Response #### Success Response (200) - **taken_arrayvec** (ArrayVec) - The original ArrayVec, now empty. #### Response Example ```json { "example": "An ArrayVec containing the original elements" } ``` ``` -------------------------------- ### Get Length of ArrayVec in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=std%3A%3Avec Shows how to retrieve the current number of elements in an ArrayVec using the `len()` method. This is a constant-time operation. ```rust use arrayvec::ArrayVec; let mut array = ArrayVec::from([1, 2, 3]); array.pop(); assert_eq!(array.len(), 2); ``` -------------------------------- ### clone_to_uninit Source: https://docs.rs/av1-grain/latest/av1_grain/struct.GrainTableSegment.html?search= Performs copy-assignment from self to dest. This is a nightly-only experimental API. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description Performs copy-assignment from `self` to `dest`. ### Method `unsafe fn` ### Endpoint N/A (This is a function signature, not an API endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response (200) N/A (This is a function that modifies memory in place) #### Response Example N/A ``` -------------------------------- ### Get Remaining Capacity of ArrayVec in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=std%3A%3Avec Demonstrates using `remaining_capacity()` to find out how many more elements can be added to an ArrayVec before it is full. This is calculated as `capacity() - len()`. ```rust use arrayvec::ArrayVec; let mut array = ArrayVec::from([1, 2, 3]); array.pop(); assert_eq!(array.remaining_capacity(), 1); ``` -------------------------------- ### Rust: Unsafe fn clone_to_uninit API Source: https://docs.rs/av1-grain/latest/av1_grain/struct.GrainTableSegment.html?search= This is a nightly-only experimental API. It performs copy-assignment from `self` to `dest`, which must be a mutable pointer to uninitialized memory. Use with caution. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### ArrayVec Trait Implementations Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Details on the various trait implementations for ArrayVec, including AsRef, AsMut, Borrow, BorrowMut, Clone, Debug, Default, Deref, DerefMut, Drop, Extend, From, FromIterator, Hash, IntoIterator, and Ord. ```APIDOC ## Trait: AsMut<[T]> ### Description Provides a mutable reference to the underlying slice. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/impl/AsMut ### Parameters None ### Response #### Success Response (200) - **slice** (*&mut [T]*) - A mutable slice of the vector's elements. ## Trait: AsRef<[T]> ### Description Provides an immutable reference to the underlying slice. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/impl/AsRef ### Parameters None ### Response #### Success Response (200) - **slice** (*&[T]*) - An immutable slice of the vector's elements. ## Trait: Borrow<[T]> ### Description Immutably borrows the underlying slice. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/impl/Borrow ### Parameters None ### Response #### Success Response (200) - **slice** (*&[T]*) - An immutable slice of the vector's elements. ## Trait: BorrowMut<[T]> ### Description Mutably borrows the underlying slice. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/impl/BorrowMut ### Parameters None ### Response #### Success Response (200) - **slice** (*&mut [T]*) - A mutable slice of the vector's elements. ## Trait: Clone ### Description Clones the ArrayVec. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/impl/Clone ### Parameters #### Request Body - **rhs** (*&ArrayVec*) - The ArrayVec to clone from. ### Response #### Success Response (200) - **cloned_arrayvec** (*ArrayVec*) - A new ArrayVec that is a clone of the original. ## Trait: Debug ### Description Formats the ArrayVec for debugging. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/impl/Debug ### Parameters None ### Response #### Success Response (200) - **formatted_string** (*String*) - A string representation of the ArrayVec for debugging. ## Trait: Default ### Description Creates an empty ArrayVec. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/impl/Default ### Parameters None ### Response #### Success Response (200) - **default_arrayvec** (*ArrayVec*) - An empty ArrayVec. ## Trait: Deref ### Description Dereferences the ArrayVec to get a slice. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/impl/Deref ### Parameters None ### Response #### Success Response (200) - **target_slice** (*&[T]*) - The underlying slice. ## Trait: DerefMut ### Description Mutably dereferences the ArrayVec to get a mutable slice. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/impl/DerefMut ### Parameters None ### Response #### Success Response (200) - **target_slice** (*&mut [T]*) - The mutable underlying slice. ## Trait: Drop ### Description Executes the destructor for the ArrayVec. ### Method DELETE ### Endpoint /websites/rs_av1-grain_av1_grain/impl/Drop ### Parameters None ### Response #### Success Response (200) - **status** (*String*) - Indicates that the destructor has been executed. ## Trait: Extend ### Description Extends the ArrayVec with elements from an iterator. Panics if extending exceeds capacity. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/impl/Extend ### Parameters #### Request Body - **iter** (*I*) - An iterator providing elements of type T. ### Response #### Success Response (200) - **status** (*String*) - Indicates successful extension. ## Trait: From<[T; CAP]> ### Description Creates an ArrayVec from a fixed-size array. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/impl/From ### Parameters #### Request Body - **array** (*[T; CAP]*) - The fixed-size array to convert. ### Response #### Success Response (200) - **arrayvec** (*ArrayVec*) - The created ArrayVec. ## Trait: FromIterator ### Description Creates an ArrayVec from an iterator. Panics if the iterator yields more elements than the capacity. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/impl/FromIterator ### Parameters #### Request Body - **iter** (*I*) - An iterator providing elements of type T. ### Response #### Success Response (200) - **arrayvec** (*ArrayVec*) - The created ArrayVec. ## Trait: Hash ### Description Hashes the contents of the ArrayVec. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/impl/Hash ### Parameters None ### Response #### Success Response (200) - **hash_value** (*u64*) - The computed hash value. ## Trait: IntoIterator ### Description Consumes the ArrayVec and returns an iterator over its elements. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/impl/IntoIterator ### Parameters None ### Response #### Success Response (200) - **iterator** (*IntoIter*) - An iterator that yields elements by value. ## Trait: Ord ### Description Compares two ArrayVec instances. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/impl/Ord ### Parameters #### Query Parameters - **other** (*&ArrayVec*) - The other ArrayVec to compare against. ### Response #### Success Response (200) - **ordering** (*Ordering*) - The comparison result (Less, Equal, Greater). ``` -------------------------------- ### Generic Implementations for Any Type in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/struct.NoiseGenArgs.html Demonstrates blanket implementations for generic types, including Any, Borrow, BorrowMut, CloneToUninit, From, Into, ToOwned, TryFrom, and TryInto. These are common trait implementations provided by the Rust standard library. ```rust impl Any for T where T: 'static + ?Sized impl Borrow for T where T: ?Sized impl BorrowMut for T where T: ?Sized impl CloneToUninit for T where T: Clone impl From for T impl Into for T where U: From impl ToOwned for T where T: Clone impl TryFrom for T where U: Into impl TryInto for T where U: TryFrom ``` -------------------------------- ### Get Slice View of ArrayVec Contents in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=u32+-%3E+bool Returns an immutable slice (`&[T]`) containing all the elements currently in the ArrayVec. This provides read-only access to the vector's contents. ```rust pub fn as_slice(&self) -> &[T] ``` -------------------------------- ### Get Slice View of ArrayVec Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=std%3A%3Avec Returns an immutable slice (`&[T]`) containing all the elements currently in the ArrayVec. This provides read-only access to the vector's contents without copying. ```rust use arrayvec::ArrayVec; let array = ArrayVec::from([1, 2, 3]); let slice = array.as_slice(); assert_eq!(slice, &[1, 2, 3]); ``` -------------------------------- ### av1_grain Crate Overview Source: https://docs.rs/av1-grain/latest/av1_grain/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This section provides an overview of the av1_grain crate, including re-exports, structs, enums, constants, and functions. ```APIDOC ## Crate av1_grain ### Re-exports `pub use v_frame;` ### Structs * **DiffGenerator** * (No description provided) * **GrainTableSegment** * Specifies parameters for enabling decoder-side grain synthesis for a segment of video from `start_time` to `end_time`. * **NoiseGenArgs** * Settings and video data defining how to generate the film grain params. ### Enums * **TransferFunction** * (No description provided) ### Constants * **DEFAULT_GRAIN_SEED** * A randomly generated u16 to be used as a starting random seed for grain synthesis. The idea behind using a constant random seed is so that encodes are deterministic and reproducible. * **NUM_UV_COEFFS** * The max number of coefficients per chroma plane for grain synthesis. * **NUM_UV_POINTS** * The max number of scaling points per chroma plane for grain synthesis. * **NUM_Y_COEFFS** * The max number of luma coefficients for grain synthesis. * **NUM_Y_POINTS** * The max number of luma scaling points for grain synthesis. ### Functions * **generate_photon_noise_params** * Generates a set of photon noise parameters for a segment of video given a set of `args`. * **parse_grain_table** * This file has the implementation details of the grain table. * **write_grain_table** * Write a set of generated film grain params to a table file, using the standard film grain table format supported by aomenc, rav1e, and svt-av1. ### Type Aliases * **ScalingPoints** * (No description provided) ``` -------------------------------- ### Get Mutable Slice from ArrayVec (Rust) Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides a mutable slice containing all elements of the ArrayVec. This allows for in-place modification of the vector's contents. ```rust pub fn as_mut_slice(&mut self) -> &mut [T] ``` -------------------------------- ### Finalize DiffGenerator and Get Segments in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/struct.DiffGenerator.html The `finish` method consumes the DiffGenerator and returns a vector of GrainTableSegment. This signifies the completion of frame processing and the generation of the final output. ```rust pub fn finish(self) -> Vec ``` -------------------------------- ### AV1 Grain Synthesis API Reference Source: https://docs.rs/av1-grain/latest/av1_grain/all.html?search=std%3A%3Avec This section provides a detailed reference for the AV1 Grain Synthesis API, covering its various components. ```APIDOC ## AV1 Grain Synthesis API Reference ### Description This API provides functionalities for generating and manipulating grain synthesis parameters for AV1 video encoding. ### Structs #### DiffGenerator Represents a difference generator for grain synthesis. #### GrainTableSegment Represents a segment within a grain table. #### NoiseGenArgs Arguments for noise generation. ### Enums #### TransferFunction Defines transfer functions used in grain synthesis. ### Functions #### generate_photon_noise_params Generates photon noise parameters. - **Method**: Any (likely internal or utility) - **Description**: Computes and returns parameters necessary for photon noise generation. #### parse_grain_table Parses a grain table. - **Method**: Any (likely internal or utility) - **Description**: Reads and interprets data from a grain table. #### write_grain_table Writes a grain table. - **Method**: Any (likely internal or utility) - **Description**: Serializes and writes grain table data. ### Type Aliases #### ScalingPoints An alias for a type representing scaling points. ### Constants #### DEFAULT_GRAIN_SEED Default seed value for grain generation. #### NUM_UV_COEFFS Number of coefficients for UV channels. #### NUM_UV_POINTS Number of points for UV channels. #### NUM_Y_COEFFS Number of coefficients for Y channel. #### NUM_Y_POINTS Number of points for Y channel. ``` -------------------------------- ### Define Grain Table Segment Source: https://docs.rs/av1-grain/latest/av1_grain/index.html The GrainTableSegment struct specifies parameters for enabling decoder-side grain synthesis for a specific video segment defined by start and end times. ```rust pub struct GrainTableSegment { pub start_time: u64, pub end_time: u64, // Additional parameters for grain synthesis } ``` -------------------------------- ### Manage ArrayVec Capacity and State Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods to inspect the current state of the collection, including length, capacity, and fullness checks. ```rust use arrayvec::ArrayVec; let mut array = ArrayVec::from([1, 2, 3]); assert_eq!(array.len(), 3); assert_eq!(array.capacity(), 3); assert!(array.is_full()); assert_eq!(array.remaining_capacity(), 0); ``` -------------------------------- ### POST /try_from Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=u32+-%3E+bool Converts a slice into an ArrayVec, returning an error if the slice exceeds the collection capacity. ```APIDOC ## POST /try_from ### Description Attempts to create an ArrayVec from a provided slice. If the slice length is greater than the capacity (CAP), it returns a CapacityError. ### Method POST ### Parameters #### Request Body - **slice** (&[T]) - Required - The source slice to convert. ### Request Example { "slice": [1, 2, 3] } ### Response #### Success Response (200) - **ArrayVec** (Object) - The populated ArrayVec instance. #### Error Response (400) - **Error** (CapacityError) - Returned if the slice is too large for the ArrayVec capacity. ``` -------------------------------- ### Define DEFAULT_GRAIN_SEED Constant in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/constant.DEFAULT_GRAIN_SEED.html?search=u32+-%3E+bool Defines a constant `DEFAULT_GRAIN_SEED` of type u16, used as a starting random seed for grain synthesis. This constant ensures deterministic and reproducible encodes. ```rust pub const DEFAULT_GRAIN_SEED: u16 = 10956; ``` -------------------------------- ### Get Capacity of ArrayVec in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=std%3A%3Avec Illustrates retrieving the total capacity of an ArrayVec using the `capacity()` method. This indicates the maximum number of elements the vector can hold without reallocating (though ArrayVec does not reallocate). ```rust use arrayvec::ArrayVec; let array = ArrayVec::from([1, 2, 3]); assert_eq!(array.capacity(), 3); ``` -------------------------------- ### Iterating over ArrayVec Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=u32+-%3E+bool Shows how to consume an ArrayVec to create an iterator, allowing for element-wise processing of the collection. ```rust use arrayvec::ArrayVec; for elt in ArrayVec::from([1, 2, 3]) { // Process element } ``` -------------------------------- ### ArrayVec Trait Implementations Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html Details on various trait implementations for ArrayVec, including AsRef, AsMut, Borrow, BorrowMut, Clone, Debug, Default, Deref, DerefMut, Drop, Extend, From, FromIterator, Hash, IntoIterator, and Ord. ```APIDOC ## Trait: AsMut<[T]> for ArrayVec ### Description Provides a mutable reference to the underlying slice of the ArrayVec. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/as_mut ### Parameters None ### Request Example None ### Response #### Success Response (200) - **slice** (*&mut [T]*) - A mutable slice of the ArrayVec's elements. #### Response Example ```json { "slice": "[mutable slice data]" } ``` ## Trait: AsRef<[T]> for ArrayVec ### Description Provides an immutable reference to the underlying slice of the ArrayVec. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/as_ref ### Parameters None ### Request Example None ### Response #### Success Response (200) - **slice** (*&[T]*) - An immutable slice of the ArrayVec's elements. #### Response Example ```json { "slice": "[immutable slice data]" } ``` ## Trait: Borrow<[T]> for ArrayVec ### Description Immutably borrows the ArrayVec as a slice. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/borrow ### Parameters None ### Request Example None ### Response #### Success Response (200) - **slice** (*&[T]*) - An immutable slice of the ArrayVec's elements. #### Response Example ```json { "slice": "[immutable slice data]" } ``` ## Trait: BorrowMut<[T]> for ArrayVec ### Description Mutably borrows the ArrayVec as a slice. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/borrow_mut ### Parameters None ### Request Example None ### Response #### Success Response (200) - **slice** (*&mut [T]*) - A mutable slice of the ArrayVec's elements. #### Response Example ```json { "slice": "[mutable slice data]" } ``` ## Trait: Clone for ArrayVec ### Description Clones the ArrayVec. Requires the element type `T` to implement `Clone`. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/clone ### Parameters #### Request Body - **source** (*ArrayVec*) - The ArrayVec to clone. ### Request Example ```json { "source": "[ArrayVec data]" } ``` ### Response #### Success Response (200) - **cloned_arrayvec** (*ArrayVec*) - A new, cloned ArrayVec. #### Response Example ```json { "cloned_arrayvec": "[cloned ArrayVec data]" } ``` ## Trait: Debug for ArrayVec ### Description Formats the ArrayVec for debugging. Requires the element type `T` to implement `Debug`. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/fmt ### Parameters None ### Request Example None ### Response #### Success Response (200) - **formatted_string** (*String*) - A string representation of the ArrayVec for debugging. #### Response Example ```json { "formatted_string": "ArrayVec([element1, element2, ...])" } ``` ## Trait: Default for ArrayVec ### Description Creates an empty ArrayVec. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/default ### Parameters None ### Request Example None ### Response #### Success Response (200) - **default_arrayvec** (*ArrayVec*) - An empty ArrayVec. #### Response Example ```json { "default_arrayvec": [] } ``` ## Trait: Deref for ArrayVec ### Description Dereferences the ArrayVec into a slice `[T]`. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/deref ### Parameters None ### Request Example None ### Response #### Success Response (200) - **target_slice** (*[T]*) - The dereferenced slice. #### Response Example ```json { "target_slice": "[slice data]" } ``` ## Trait: DerefMut for ArrayVec ### Description Mutably dereferences the ArrayVec into a mutable slice `[T]`. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/deref_mut ### Parameters None ### Request Example None ### Response #### Success Response (200) - **target_slice** (*&mut [T]*) - The mutably dereferenced slice. #### Response Example ```json { "target_slice": "[mutable slice data]" } ``` ## Trait: Drop for ArrayVec ### Description Executes the destructor for the ArrayVec type. This operation does not have a direct API endpoint as it's managed by the language runtime. ### Method N/A ### Endpoint N/A ### Parameters None ### Request Example None ### Response None ## Trait: Extend for ArrayVec ### Description Extends the ArrayVec with elements from an iterator. Panics if extending exceeds capacity. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/extend ### Parameters #### Request Body - **iterator** (*I where I: IntoIterator*) - An iterator providing elements to extend the ArrayVec. ### Request Example ```json { "iterator": "[iterator data]" } ``` ### Response #### Success Response (200) - **updated_arrayvec** (*ArrayVec*) - The ArrayVec after extension. #### Response Example ```json { "updated_arrayvec": "[updated ArrayVec data]" } ``` ## Trait: From<[T; CAP]> for ArrayVec ### Description Creates an ArrayVec from a fixed-size array. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/from_array ### Parameters #### Request Body - **array** (*[T; CAP]*) - The fixed-size array to convert. ### Request Example ```json { "array": [1, 2, 3] } ``` ### Response #### Success Response (200) - **created_arrayvec** (*ArrayVec*) - The ArrayVec created from the array. #### Response Example ```json { "created_arrayvec": [1, 2, 3] } ``` ## Trait: FromIterator for ArrayVec ### Description Creates an ArrayVec from an iterator. Panics if the iterator yields more elements than the capacity. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/from_iter ### Parameters #### Request Body - **iter** (*I where I: IntoIterator*) - An iterator providing elements to create the ArrayVec. ### Request Example ```json { "iter": "[iterator data]" } ``` ### Response #### Success Response (200) - **created_arrayvec** (*ArrayVec*) - The ArrayVec created from the iterator. #### Response Example ```json { "created_arrayvec": "[ArrayVec data]" } ``` ## Trait: Hash for ArrayVec ### Description Hashes the ArrayVec. Requires the element type `T` to implement `Hash`. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/hash ### Parameters None ### Request Example None ### Response #### Success Response (200) - **hash_value** (*u64*) - The computed hash value. #### Response Example ```json { "hash_value": 1234567890 } ``` ## Trait: IntoIterator for ArrayVec ### Description Consumes the ArrayVec and returns an iterator over its elements. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/into_iter ### Parameters #### Request Body - **arrayvec** (*ArrayVec*) - The ArrayVec to consume. ### Request Example ```json { "arrayvec": "[ArrayVec data]" } ``` ### Response #### Success Response (200) - **iterator** (*IntoIter*) - An iterator over the elements of the ArrayVec. #### Response Example ```json { "iterator": "[iterator data]" } ``` ## Trait: Ord for ArrayVec ### Description Compares two ArrayVecs. Requires the element type `T` to implement `Ord`. ### Method POST ### Endpoint /websites/rs_av1-grain_av1_grain/cmp ### Parameters #### Request Body - **self** (*ArrayVec*) - The first ArrayVec. - **other** (*ArrayVec*) - The second ArrayVec. ### Request Example ```json { "self": "[ArrayVec 1 data]", "other": "[ArrayVec 2 data]" } ``` ### Response #### Success Response (200) - **ordering** (*Ordering*) - The result of the comparison (Less, Equal, Greater). #### Response Example ```json { "ordering": "Equal" } ``` ``` -------------------------------- ### Get Raw Pointer to ArrayVec Buffer (Rust) Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns a constant raw pointer to the ArrayVec's underlying buffer. This is useful for low-level memory operations or interfacing with C code. ```rust pub fn as_ptr(&self) -> *const T ``` -------------------------------- ### Get Mutable Raw Pointer to ArrayVec Buffer (Rust) Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns a mutable raw pointer to the ArrayVec's underlying buffer. This enables direct memory manipulation, but requires careful handling to maintain memory safety. ```rust pub fn as_mut_ptr(&mut self) -> *mut T ``` -------------------------------- ### Generic Implementations for DiffGenerator (Rust) Source: https://docs.rs/av1-grain/latest/av1_grain/struct.DiffGenerator.html?search=u32+-%3E+bool Showcases various blanket implementations for the DiffGenerator struct, including Auto Traits like Freeze, Send, Sync, Unpin, and UnwindSafe, as well as Blanket Implementations for traits like Any, Borrow, From, Into, TryFrom, and TryInto. ```rust impl Freeze for DiffGenerator impl RefUnwindSafe for DiffGenerator impl Send for DiffGenerator impl Sync for DiffGenerator impl Unpin for DiffGenerator impl UnsafeUnpin for DiffGenerator impl UnwindSafe for DiffGenerator impl Any for T where T: 'static + ?Sized, fn type_id(&self) -> TypeId impl Borrow for T where T: ?Sized, fn borrow(&self) -> &T impl BorrowMut for T where T: ?Sized, fn borrow_mut(&mut self) -> &mut T impl From for T fn from(t: T) -> T impl where U: From, fn into(self) -> U impl where U: Into, type Error = Infallible fn try_from(value: U) -> Result>::Error> impl where U: TryFrom, type Error = >::Error fn try_into(self) -> Result>::Error> ``` -------------------------------- ### Initialize DiffGenerator in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/struct.DiffGenerator.html Provides a constructor for the DiffGenerator struct. It takes frame rate, source bit depth, and denoised bit depth as arguments to initialize the generator. ```rust pub fn new( fps: Rational64, source_bit_depth: usize, denoised_bit_depth: usize, ) -> Self ``` -------------------------------- ### DiffGenerator API Source: https://docs.rs/av1-grain/latest/av1_grain/struct.DiffGenerator.html?search=u32+-%3E+bool Documentation for the DiffGenerator struct, including its constructor, methods for processing and finalizing frames, and associated error handling. ```APIDOC ## Struct DiffGenerator ### Description Represents a generator for calculating grain table segments. ### Source ```rust pub struct DiffGenerator { /* private fields */ } ``` ## Implementations ### impl DiffGenerator #### pub fn new(fps: Rational64, source_bit_depth: usize, denoised_bit_depth: usize) -> Self ##### Description Creates a new `DiffGenerator` instance. ##### Parameters * `fps` (Rational64) - Frames per second. * `source_bit_depth` (usize) - Bit depth of the source. * `denoised_bit_depth` (usize) - Bit depth of the denoised output. #### pub fn diff_frame(&mut self, source: &Frame, denoised: &Frame) -> Result<()> ##### Description Processes the next frame and adds the results to the state of this `DiffGenerator`. ##### Parameters * `source` (&Frame) - The source frame. * `denoised` (&Frame) - The denoised frame. ##### Errors * If the frames do not have the same resolution. * If the frames do not have the same chroma subsampling. #### pub fn finish(self) -> Vec ##### Description Finalize the state of this `DiffGenerator` and return the resulting grain table segments. ### Auto Trait Implementations * `Freeze` for `DiffGenerator` * `RefUnwindSafe` for `DiffGenerator` * `Send` for `DiffGenerator` * `Sync` for `DiffGenerator` * `Unpin` for `DiffGenerator` * `UnsafeUnpin` for `DiffGenerator` * `UnwindSafe` for `DiffGenerator` ### Blanket Implementations * `impl Any for T` where `T: 'static + ?Sized` * `fn type_id(&self) -> TypeId` * `impl Borrow for T` where `T: ?Sized` * `fn borrow(&self) -> &T` * `impl BorrowMut for T` where `T: ?Sized` * `fn borrow_mut(&mut self) -> &mut T` * `impl From for T` * `fn from(t: T) -> T` * `impl Into for T` where `U: From` * `fn into(self) -> U` * `impl TryFrom for T` where `U: Into` * `type Error = Infallible` * `fn try_from(value: U) -> Result>::Error>` * `impl TryInto for T` where `U: TryFrom` * `type Error = >::Error` * `fn try_into(self) -> Result>::Error>` ``` -------------------------------- ### CloneToUninit Trait Source: https://docs.rs/av1-grain/latest/av1_grain/struct.GrainTableSegment.html Provides an experimental nightly-only API for performing copy-assignment from a source to an uninitialized memory destination. ```APIDOC ## UNSAFE fn clone_to_uninit ### Description Performs copy-assignment from `self` to a raw pointer destination. This is a nightly-only experimental API. ### Method UNSAFE FUNCTION ### Parameters #### Path Parameters - **self** (&T) - Required - The source object to clone. - **dest** (*mut u8) - Required - The raw pointer to uninitialized memory. ### Response - **Success** - Memory at `dest` is initialized with the clone of `self`. ``` -------------------------------- ### POST /noise-generation/args Source: https://docs.rs/av1-grain/latest/av1_grain/struct.NoiseGenArgs.html?search=std%3A%3Avec Defines the configuration parameters for generating film grain noise in AV1 video processing. ```APIDOC ## POST /noise-generation/args ### Description Configures the parameters for film grain synthesis, including input dimensions, ISO sensitivity, and color range handling. ### Method POST ### Endpoint /noise-generation/args ### Parameters #### Request Body - **iso_setting** (u32) - Required - The ISO sensitivity setting for grain generation. - **width** (u32) - Required - The width of the video frame. - **height** (u32) - Required - The height of the video frame. - **transfer_function** (TransferFunction) - Required - The transfer function applied to the video data. - **full_range** (bool) - Required - Specifies if the input is full range (true) or limited range (false). - **chroma_grain** (bool) - Required - Enables or disables grain generation for chroma channels. - **random_seed** (Option) - Optional - A seed value for the random number generator used in grain synthesis. ### Request Example { "iso_setting": 100, "width": 1920, "height": 1080, "transfer_function": "srgb", "full_range": true, "chroma_grain": true, "random_seed": 42 } ### Response #### Success Response (200) - **status** (string) - Confirmation of configuration acceptance. #### Response Example { "status": "success" } ``` -------------------------------- ### Rust: Implement CloneToUninit for T Source: https://docs.rs/av1-grain/latest/av1_grain/struct.GrainTableSegment.html Provides a nightly-only experimental API for performing copy-assignment from self to a mutable pointer destination. This is useful for low-level memory manipulation where direct assignment is required. ```rust impl CloneToUninit for T where T: Clone, { unsafe fn clone_to_uninit(&self, dest: *mut u8) // ... implementation details ... } ``` -------------------------------- ### ArrayVec Core Methods Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides access to the underlying data of the ArrayVec as mutable or immutable slices, or raw pointers. ```APIDOC ## GET /websites/rs_av1-grain_av1_grain/as_mut_slice ### Description Returns a mutable slice containing all elements of the vector. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/as_mut_slice ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **slice** (*&mut [T]*) - A mutable slice of the vector's elements. #### Response Example ```json { "slice": "mutable_slice_representation" } ``` ## GET /websites/rs_av1-grain_av1_grain/as_ptr ### Description Returns a raw pointer to the vector's buffer. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/as_ptr ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **pointer** (**const T*) - A raw pointer to the vector's buffer. #### Response Example ```json { "pointer": "raw_pointer_representation" } ``` ## GET /websites/rs_av1-grain_av1_grain/as_mut_ptr ### Description Returns a raw mutable pointer to the vector's buffer. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/as_mut_ptr ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **pointer** (**mut T*) - A raw mutable pointer to the vector's buffer. #### Response Example ```json { "pointer": "raw_mutable_pointer_representation" } ``` ``` -------------------------------- ### Convert slice to ArrayVec using TryFrom Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to safely convert a slice into an ArrayVec using the TryFrom trait. This operation returns an error if the slice length exceeds the capacity of the ArrayVec. ```rust use arrayvec::ArrayVec; use std::convert::TryInto as _; let array: ArrayVec<_, 4> = (&[1, 2, 3] as &[_]).try_into().unwrap(); assert_eq!(array.len(), 3); assert_eq!(array.capacity(), 4); ``` -------------------------------- ### ArrayVec Min and Clamp Methods (Rust) Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=std%3A%3Avec Provides utility functions for ArrayVec. The `min` function returns the smaller of two values, while `clamp` restricts a value to be within a specified minimum and maximum range. ```rust fn min(self, other: Self) -> Self where Self: Sized; fn clamp(self, min: Self, max: Self) -> Self where Self: Sized; ``` -------------------------------- ### Create New Empty ArrayVec in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=std%3A%3Avec Demonstrates creating a new, empty ArrayVec with a specified capacity. The `new()` function is used for runtime initialization, and elements can be pushed until the capacity is reached. ```rust use arrayvec::ArrayVec; let mut array = ArrayVec::<_, 16>::new(); array.push(1); array.push(2); assert_eq!(&array[..], &[1, 2]); assert_eq!(array.capacity(), 16); ``` -------------------------------- ### Type Conversion Traits (From/Into/TryFrom/TryInto) Source: https://docs.rs/av1-grain/latest/av1_grain/struct.GrainTableSegment.html Standard traits for converting between types, including fallible and infallible conversion patterns. ```APIDOC ## fn from / fn into / fn try_from / fn try_into ### Description Standard library traits for type conversion. `From`/`Into` handle infallible conversions, while `TryFrom`/`TryInto` handle fallible conversions. ### Parameters - **value** (T/U) - Required - The input value to convert. ### Response - **From/Into** - Returns the converted type U. - **TryFrom/TryInto** - Returns Result where Error is Infallible. ``` -------------------------------- ### Rust: Implement TryInto Trait for Fallible Conversion Source: https://docs.rs/av1-grain/latest/av1_grain/struct.GrainTableSegment.html?search= Explains the `TryInto for T` trait, the reciprocal of `TryFrom for U`. The `try_into(self) -> Result>::Error>` method attempts the conversion, returning a `Result`. ```rust impl TryInto for T where U: TryFrom, { type Error = >::Error; fn try_into(self) -> Result { U::try_from(self) } } ``` -------------------------------- ### Implement Blanket CloneToUninit Trait for Clone Types in Rust Source: https://docs.rs/av1-grain/latest/av1_grain/enum.TransferFunction.html?search=u32+-%3E+bool Shows the nightly-only experimental blanket implementation of `CloneToUninit` for types that implement `Clone`. This is an unsafe operation for copying data to uninitialized memory. ```rust impl CloneToUninit for T where T: Clone, { unsafe fn clone_to_uninit(&self, dest: *mut u8) } ``` -------------------------------- ### ArrayVec Core Methods Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html Provides access to the underlying data of the ArrayVec as mutable or immutable slices, or raw pointers. ```APIDOC ## GET /websites/rs_av1-grain_av1_grain/as_mut_slice ### Description Returns a mutable slice containing all elements of the vector. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/as_mut_slice ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **slice** (*&mut [T]*) - A mutable slice of the vector's elements. #### Response Example ```json { "slice": "[mutable slice data]" } ``` ## GET /websites/rs_av1-grain_av1_grain/as_ptr ### Description Returns a raw pointer to the vector’s buffer. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/as_ptr ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **pointer** (**const T*) - A raw pointer to the vector's buffer. #### Response Example ```json { "pointer": "0x..." } ``` ## GET /websites/rs_av1-grain_av1_grain/as_mut_ptr ### Description Returns a raw mutable pointer to the vector’s buffer. ### Method GET ### Endpoint /websites/rs_av1-grain_av1_grain/as_mut_ptr ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **pointer** (**mut T*) - A raw mutable pointer to the vector's buffer. #### Response Example ```json { "pointer": "0x..." } ``` ``` -------------------------------- ### Take ownership of ArrayVec Source: https://docs.rs/av1-grain/latest/av1_grain/type.ScalingPoints.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Replaces the current ArrayVec with an empty one and returns the original instance. ```rust use arrayvec::ArrayVec; let mut v = ArrayVec::from([0, 1, 2, 3]); assert_eq!([0, 1, 2, 3], v.take().into_inner().unwrap()); assert!(v.is_empty()); ```