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

[fix] raw: fix channel layout #4516

Merged

Conversation

antond-weta
Copy link
Contributor

Description

The function libraw_filter_to_str() converts the imgdata.idata.filters field to human readable form, by mapping a few hardcoded values. I found the issue by converting images with disabled demosaicing, which writes the Bayer pattern into the ImageBuf metadata. The Panasonic GX9 didn't have any pattern recognised; The Canon R5 was incorrectly recognised as GMCY.

The imgdata.idata.filters actually contains a sequence of 2-bit values, where each represents an index in a 4-character long string imgdata.idata.cdesc. I have modified the code to extract the channels from imgdata.idata.cdesc as expected.

I have also disabled the normalisation code, which I believe was incorrect, and never executed due to the issue above.

Tests

The current tests pass, however, I'll start a discussion on the piece of code I have concerns with.

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.

Signed-off-by: Anton Dukhovnikov <[email protected]>
case 0x49494949: return "GBGR";
case 0x94949494: return "RGBG";
default: break;
char result[5] = { 0 };
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't actually know... does this for sure fill the whole array with 0's? Is that part of the C++ standard, and not relying on any particular compiler?

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 pending one minor comment I made asking for clarification about the array initialization.

Signed-off-by: Anton Dukhovnikov <[email protected]>
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 de51ee6 into AcademySoftwareFoundation:main Nov 6, 2024
28 checks passed
@lgritz lgritz added the file formats Image file formats, ImageInput, ImageOutput label Nov 6, 2024
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Nov 10, 2024
The function libraw_filter_to_str() converts the `imgdata.idata.filters`
field to human readable form, by mapping a few hardcoded values. I found
the issue by converting images with disabled demosaicing, which writes
the Bayer pattern into the ImageBuf metadata. The Panasonic GX9 didn't
have any pattern recognised; The Canon R5 was incorrectly recognised as
GMCY.

The `imgdata.idata.filters` actually contains a sequence of 2-bit
values, where each represents an index in a 4-character long string
`imgdata.idata.cdesc`. I have modified the code to extract the channels
from `imgdata.idata.cdesc` as expected.

I have also disabled the normalisation code, which I believe was
incorrect, and never executed due to the issue above.

The current tests pass, however, I'll start a discussion on the piece of
code I have concerns with.

---------

Signed-off-by: Anton Dukhovnikov <[email protected]>
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Nov 10, 2024
The function libraw_filter_to_str() converts the `imgdata.idata.filters`
field to human readable form, by mapping a few hardcoded values. I found
the issue by converting images with disabled demosaicing, which writes
the Bayer pattern into the ImageBuf metadata. The Panasonic GX9 didn't
have any pattern recognised; The Canon R5 was incorrectly recognised as
GMCY.

The `imgdata.idata.filters` actually contains a sequence of 2-bit
values, where each represents an index in a 4-character long string
`imgdata.idata.cdesc`. I have modified the code to extract the channels
from `imgdata.idata.cdesc` as expected.

I have also disabled the normalisation code, which I believe was
incorrect, and never executed due to the issue above.

The current tests pass, however, I'll start a discussion on the piece of
code I have concerns with.

---------

Signed-off-by: Anton Dukhovnikov <[email protected]>
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Nov 13, 2024
The function libraw_filter_to_str() converts the `imgdata.idata.filters`
field to human readable form, by mapping a few hardcoded values. I found
the issue by converting images with disabled demosaicing, which writes
the Bayer pattern into the ImageBuf metadata. The Panasonic GX9 didn't
have any pattern recognised; The Canon R5 was incorrectly recognised as
GMCY.

The `imgdata.idata.filters` actually contains a sequence of 2-bit
values, where each represents an index in a 4-character long string
`imgdata.idata.cdesc`. I have modified the code to extract the channels
from `imgdata.idata.cdesc` as expected.

I have also disabled the normalisation code, which I believe was
incorrect, and never executed due to the issue above.

The current tests pass, however, I'll start a discussion on the piece of
code I have concerns with.

---------

Signed-off-by: Anton Dukhovnikov <[email protected]>
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Nov 21, 2024
The function libraw_filter_to_str() converts the `imgdata.idata.filters`
field to human readable form, by mapping a few hardcoded values. I found
the issue by converting images with disabled demosaicing, which writes
the Bayer pattern into the ImageBuf metadata. The Panasonic GX9 didn't
have any pattern recognised; The Canon R5 was incorrectly recognised as
GMCY.

The `imgdata.idata.filters` actually contains a sequence of 2-bit
values, where each represents an index in a 4-character long string
`imgdata.idata.cdesc`. I have modified the code to extract the channels
from `imgdata.idata.cdesc` as expected.

I have also disabled the normalisation code, which I believe was
incorrect, and never executed due to the issue above.

The current tests pass, however, I'll start a discussion on the piece of
code I have concerns with.

---------

Signed-off-by: Anton Dukhovnikov <[email protected]>
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