Crate dxfilter

Source
Expand description

§DxFilter

docs.rs Crates.io Crates.io

Scale and ColorConversion done with DirectX filters. You can also create your own filters with the provided api.

Crate contains various tools to make these features possible.

  • generate_shader! and compile_shader! macros to write shaders that compile at compile time
  • various built filters for converting and scaling from RGB to YUV or NV12
  • DxFilter interface for writing custom filters
  • utils like create_device_context , create_input_tex, create_output_tex for easier setup.
  • utils like AdapterFactory, Adapter, TextureReader imported from win_desktop_duplication.

For example usage, look at examples/rgb_to_nv12.rs

§Usage

// for more detailed example see examples/rgb_to_nv12.rs
fn main() {
    // {...}

    //                                    Texture    Texture    directx device
    let filter = ConvertARGBToNV12::new(&input_tex, &output_tex, &device).unwrap();
    //                directx device
    filter.apply_filter(&context).unwrap();

    // { ... }
}

§AvailableFilters

  • ARGB to AYUV
  • ARGB to NV12
  • ARGB or AYUV scale only
  • ARGB to YUV planar
  • ARGB to YUV420 planar
  • ARGB16 to Y410
  • ARGB16 to YUV444 10bit planar
  • ARGB16 to YUV420 10bit planar

Re-exports§

pub use error::DxResult as Result;

Modules§

color
contains color definitions and tools for converting color from one format to another
error
contains definition of various errors.
shader
Contains utils for creating Vertex and Pixel shaders from compiled shader byte code. you can easily use generate_shader! macro instead of these structs directly.
utils
various utilities for setup with directx. If you are using this in other applications, you should not need these methods. However, for simple applications, these will be helpful

Macros§

compile_shader
Compile directx shader at compile time and returns byte code. it uses D3DCompile2. any unexplained parameters are analogous to that function.
generate_shader
Compile DirectX shader at compile time and generates a function. The function takes an ID3D11Device4 instance to produce respective shader.

Structs§

ConvertARGBToAYUV
Filter for converting ARGBUNorm or ABGRUNorm into AYUV format. filter also scales automatically based on input and output textures.
ConvertARGBToNV12
Filter for converting ARGBUNorm or ABGRUNorm into NV12 format. filter also scales automatically based on input and output textures.
ConvertARGBToYUV444
Filter for converting ARGBUNorm or ABGRUNorm into YUV444 format. filter also scales automatically based on input and output textures.
ScaleARGBOrAYUV
Filter for simple scaling of ARGBUNorm or ABGRUNorm or AYUV formats.

Traits§

DxFilter
Interface for interacting with various filters. Interface is defined so that you could create Directx pipelines that involve multiple filters.