Skip to content

Conversation

@brechtvl
Copy link
Contributor

Description

Many codecs don't provide bits_per_raw_sample. The bit depth of the luma channel is the closest equivalent to a single bit depth then, while the chroma channels may be subsampled.

Tested on basically all the video files on my computer, they all give a non-zero bit depth that looks correct now.

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable. (Check if there is no
    need to update the documentation, for example if this is a bug fix that
    doesn't change the API.)
  • I have ensured that the change is tested somewhere in the testsuite
    (adding new test cases if necessary).
  • If I added or modified a C++ API call, I have also amended the
    corresponding Python bindings (and if altering ImageBufAlgo functions, also
    exposed the new functionality as oiiotool options).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format before submitting, I definitely will look at the CI
    test that runs clang-format and fix anything that it highlights as being
    nonconforming.

Many codecs don't provide bits_per_raw_sample. The bit depth of the
luma channel is the closest equivalent to a single bit depth then,
while the chroma channels may be subsampled.

Tested on basically all the video files on my computer, they all give
a non-zero bit depth now.

Signed-off-by: Brecht Van Lommel <[email protected]>
@lgritz
Copy link
Collaborator

lgritz commented Sep 15, 2025

In case it changes how you want to do this: It is not necessary to set "oiio:BitsPerSample" unless it differs from what is implied by ImageSpec.format. For example, if the standard type you are returning is uint16, but you want to say, "I'm conveying this data via 16 bit ints, and of course 65535 is interpreted as 1.0, but just you know, in the file, it was stored only 10 bits," then you set "oiio:BitsPerSample" to 10.

@brechtvl
Copy link
Contributor Author

brechtvl commented Sep 15, 2025

In my tests this changes a bunch of cases from 0 bits to 8, 10 or 12 bits. So I think it is useful.

I could not set it if it matches the format, but other file formats seem to set it unconditionally.

@lgritz
Copy link
Collaborator

lgritz commented Sep 15, 2025

I could not set it if it matches the format, but other file formats seem to set it unconditionally.

If that's what all the others are doing, I think it's fine.

Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

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

LGTM

@lgritz lgritz merged commit b9e3a99 into AcademySoftwareFoundation:main Sep 15, 2025
31 checks passed
zachlewis pushed a commit to zachlewis/OpenImageIO that referenced this pull request Sep 16, 2025
…dation#4885)

Many codecs don't provide `bits_per_raw_sample`. The bit depth of the
luma channel is the closest equivalent to a single bit depth then, while
the chroma channels may be subsampled.

Tested on basically all the video files on my computer, they all give a
non-zero bit depth that looks correct now.

Signed-off-by: Brecht Van Lommel <[email protected]>
Signed-off-by: Zach Lewis <[email protected]>
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Sep 16, 2025
…dation#4885)

Many codecs don't provide `bits_per_raw_sample`. The bit depth of the
luma channel is the closest equivalent to a single bit depth then, while
the chroma channels may be subsampled.

Tested on basically all the video files on my computer, they all give a
non-zero bit depth that looks correct now.

Signed-off-by: Brecht Van Lommel <[email protected]>
@lgritz lgritz added the file formats Image file formats, ImageInput, ImageOutput label Oct 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

file formats Image file formats, ImageInput, ImageOutput

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants