Skip to content

panic when converting to YUV420 to RGB #2

@mfreeborn

Description

@mfreeborn

I have a raw buffer of bytes which is a YUV420 format frame from a camera, which I am trying to convert to RGB (well, ultimately to a JPEG).

My code, however, panics when I try to do the conversion, looking something like this:

let frame_data: Vec<u8> = ...; // a 1920x1080 resolution YUV420 frame, 3110400 bytes long
let view = Image::<Yuv<u8>, _>::from_buf(&frame_data, 1920, 1080).unwrap();
let mut rgb_buf = Image::<Rgb<u8>, _>::new(0, 0, 0u8);
view.convert(&mut rgb_buf); 

And then I get a really long panic message:

thread '<unnamed>' panicked at 'range end index 3116160 out of range for slice of length 3110400', /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/ffimage-0.9.0/src/packed/convert/rayon.rs:86:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'range end index 3306240 out of range for slice of length 3110400', /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/ffimage-0.9.0/src/packed/convert/rayon.rs:86:27
... repeated absolutely loads of times with an incrementing "range end index"

Is YUV420 conversion supported?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions