Skip to content

core: Add custom bit depth field#352

Open
feliwir wants to merge 1 commit intoetemesi254:devfrom
feliwir:custom-bitdepth
Open

core: Add custom bit depth field#352
feliwir wants to merge 1 commit intoetemesi254:devfrom
feliwir:custom-bitdepth

Conversation

@feliwir
Copy link

@feliwir feliwir commented Feb 9, 2026

This change allows specifying custom bit depths as specified in #351
By itself this change allows to encode 10bit & 12bit PPMs which is a requirement for testing changes proposed in #349

E.g. i can save the decoded 10bit & 12bit JPEG files now (PR will arrive after this one):
image

@etemesi254
Copy link
Owner

This has to be approached with care, the depth is important in other places especially in the imageprocs function, so will spend some few days checking that it works.

But appreciate the effort in starting it.

@feliwir
Copy link
Author

feliwir commented Feb 9, 2026

I choose this approach to stay API compatible. I'd prefer not having an enum at all, but i think that would be a breaking change.

@feliwir feliwir mentioned this pull request Feb 9, 2026
2 tasks
@etemesi254
Copy link
Owner

how would you represent different depths? disregarding apis?

@feliwir
Copy link
Author

feliwir commented Feb 10, 2026

Well, the bit depth would just be an integer (u8) without an enum in my opinion. Because an amount of bits is always a variable number and there might be anything really from 0-32. Maybe we have 64bits depths in the future :)

Currently the API limits us to three possible presets (8, 16, 32). Additionally it also mixes in the scalar type (float or integer). This is not directly related to the bit depth in my opinion

@etemesi254
Copy link
Owner

And what datatype would represent them?

Because at the end of the day you need to tie it to a number a computer can manipulate.

@feliwir
Copy link
Author

feliwir commented Feb 10, 2026

I totally agree that a datatype needs to be selected. However the current API is misleading, because there are also 8 & 16bit floats, and there are also 32-bit integers.
So in my imagination there should be a way to select the data type (signed integer, unsigned integer or float) and a function to select the bitdepth (a arbitary number). In case of an unsupported / invalid combination the encoder should notify the user by returning an error

@etemesi254
Copy link
Owner

ignore the encoding for now

how would you perform operations ?

a simple operation is like increasing exposure so its usually 'clamp(num*exposure_value,MAX_SIZE,VAL)'

depth of 'f32' represents floating type images which are between 0-1 generally not MIN_FLOAT-MAX_FLOAT

@feliwir
Copy link
Author

feliwir commented Feb 11, 2026

I know that float image data is usually between 0-1. I am not sure how that is related to the API change proposal though

@etemesi254
Copy link
Owner

It is unrelated, just trying to pick your brain on what a better design would be, maybe one day could add it.

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