/vanilla-iced

Iced YUV shader

Primary LanguageRustMIT LicenseMIT

Vanilla Iced

iced_baby_vip

Custom shader for rendering YUV / YCbCr data using Iced.

Check out the examples to see it in action!

Usage

fn view(&self) -> Element<Message> {
    // Get some YUV
    let yuv = vanilla_iced::Yuv {
        format: Format::I420, // yuv format
        data: vec![..] // raw yuv data
    };

    // Render it
    iced::widget::shader(vanilla_iced::Program::new(yuv)).into()
}

fn update(&mut self, message: Message) -> iced::Command<Message> {
    match message {
        Message::GotSomeNewYuv(frame) => {
            // Update a shader program in your app state with new YUV data
            self.program.update_frame(frame);
        }
    }
}

Goals

  • Render I420
  • Render Y444
  • Support other common 4:2:0 YUV formats by conversion to I420
    • NV12
  • Support other common 4:4:4 YUV formats by conversion to Y444

Motivations

Typically the output from decoding compressed video formats is YUV frames. While YUV can be converted to RGBA on the CPU for rendering with Iced's Image widget, doing so is not particularly efficient. This project seeks to move YUV conversion to the GPU using a dedicated shader, supporting the development of video players and other multimedia applications with Iced.