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

colorconversion: add support for promoting < 8 bit planar to 8 bit planar #1080

Merged
merged 1 commit into from
Dec 26, 2023

Conversation

bradh
Copy link
Contributor

@bradh bradh commented Dec 25, 2023

This is a partial fix for color conversion from planar RGB with bit depth less than 8 bit into 8 bit. It extends an existing operation (Op_to_sdr_planes) to handle this case.

This is enough to get my uncompressed codec rework with heif-convert to generate JPEG. However it is not sufficient for PNG.

for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++) {
int in = p_in[y * stride_in + x];
p_out[y * stride_out + x] = (uint8_t) (in << shift); // TODO: I think no rounding here, but am not sure.
Copy link
Contributor

@farindk farindk Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usual technique is to use (in << shift) | (in >> (2*input_bits - 8). This puts the MSBs into the LSBs that were shifted in. The advantage is that full white (e.g. 0x3F in 6 bit) also gets mapped to (0xFF in 8 bits) instead of some grey.

@farindk farindk merged commit aa4cb58 into strukturag:develop-v1.18.0 Dec 26, 2023
2 checks passed
@farindk
Copy link
Contributor

farindk commented Dec 26, 2023

I have changed the convertion such that also inputs with <4 bits can be converted with the full output value range.

@bradh bradh deleted the rgb565 branch December 26, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants