Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping ColorSpace value into ColorModel #29

Open
gibix opened this issue Aug 10, 2019 · 1 comment
Open

Mapping ColorSpace value into ColorModel #29

gibix opened this issue Aug 10, 2019 · 1 comment
Labels

Comments

@gibix
Copy link
Contributor

gibix commented Aug 10, 2019

I'm looking for a solution for mapping values from matroska::elements::Video::colour_space into av_data::pixel::ColorModel as part of #9. The value are written in FourCC as described here.

Here is a first draft of the solution

const RAW: u32 = fourcc(b'r', b'a', b'w', b' ');

const fn fourcc(a: u8, b: u8, c: u8, d: u8) -> u32 {
    (d as u32) | (c as u32) << 8 | (b as u32) << 16 | (a as u32) << 24
}

// parse fourCC value into pixel::ColorModel
// TODO: assumed Big Endian
fn colour_space_to_color_model(colour_space: &[u8]) -> Option<ColorModel> {
    let mut fourcc_val: u32 = 0;

    for c in colour_space {
        let b = *c as u8;

        fourcc_val = (fourcc_val << 8) | b as u32
    }

    match fourcc_val {
        RAW => Some(ColorModel::Trichromatic(TrichromaticEncodingSystem::RGB)),
        _ => None
    }
}
  1. There is no offocial list of the formats supported in the ColorSpace field Colour Space values ietf-wg-cellar/matroska-specification#337
  2. I'm not sure how to match all values from fourcc's yuv into av_data::pixel::TrichromaticEncodingSystem
@gibix gibix added the question label Aug 10, 2019
@lu-zero
Copy link
Member

lu-zero commented Aug 11, 2019

Ideally you can expose the fourcc as a struct FourCC(u32). and have the mapping as an esternal trait to move from and to the color model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants