Image: Use OpenImageIO for loading and saving a variety of image formats #105785

Merged
Jesse Yurkovich merged 9 commits from deadpin/blender:oiio-land-formats into main 2023-04-12 05:22:39 +02:00

This checkin will use OIIO to replace the image save/load code for BMP,
DDS, DPX, HDR, PNG, TGA, and TIFF.

This simplifies our build environment, reduces binary duplication,
removes large amounts of hard to maintain code, and fixes some bugs
along the way.

It should also help reduce rare differences between Blender and Cycles
which already uses OIIO for most situations. Or potentially makes them
easier to solve once discovered.

This is a continuation of the work for #101413


Test changes and bug fixes

Some test files (attached) are changed. Their summary is as follows:

  • Grayscale BMPs were saved out incorrectly in main and Windows refuses to display them. Now fixed.
  • Grayscale images in main, for all formats, were saved out incorrectly (only used the Red channel). Now fixed to use the luminance weights.
  • DPX files in all varieties were saved out incorrectly. I think; a second and third pair of eyes on this format would be welcome.

Example DPX changes:

template EXR save/load in main save/load through OIIO
exr-template.png RGB dpx-main-rgb.png dpx-oiio-rgb.png
exr-template.png RGBA dpx-main-rgba.png dpx-oiio-rgba.png

DDS code

I think the existing dds directory can be removed entirely instead of just being excluded like it is now. However, I'd like to keep it for a while longer and delete it during bcon2 of 3.6 if possible for ease of repros in the next few weeks.

The Remaining Formats

I'll continue to work towards a partial conversion of EXR, JPG, and WEBP but I can't commit to those for 3.6.
Thumbnail support for these 3 formats are what's stopping a full conversion.

JPEG 2000 support is lacking and that will take additional effort to solve if we want that format too.

This checkin will use OIIO to replace the image save/load code for BMP, DDS, DPX, HDR, PNG, TGA, and TIFF. This simplifies our build environment, reduces binary duplication, removes large amounts of hard to maintain code, and fixes some bugs along the way. It should also help reduce rare differences between Blender and Cycles which already uses OIIO for most situations. Or potentially makes them easier to solve once discovered. This is a continuation of the work for #101413 ---- #### Test changes and bug fixes Some test files (attached) are changed. Their summary is as follows: - Grayscale BMPs were saved out incorrectly in `main` and Windows refuses to display them. Now fixed. - Grayscale images in main, for all formats, were saved out incorrectly (only used the Red channel). Now fixed to use the luminance weights. - DPX files in all varieties were saved out incorrectly. I think; a second and third pair of eyes on this format would be welcome. Example DPX changes: | template EXR | | save/load in main | save/load through OIIO | | -- | -- | -- | -- | | ![exr-template.png](/attachments/4320a0c3-11ad-4672-8394-6d5a01059e7d) | RGB | ![dpx-main-rgb.png](/attachments/cab43838-66f0-46cc-96ab-e5778678627b) | ![dpx-oiio-rgb.png](/attachments/8f3c65ad-937d-4d95-98e9-2865a6067b53) | | ![exr-template.png](/attachments/4320a0c3-11ad-4672-8394-6d5a01059e7d) | RGBA | ![dpx-main-rgba.png](/attachments/4561ec61-4a2a-4f56-aa35-ac876e7de406) | ![dpx-oiio-rgba.png](/attachments/fcd7f7e0-09c2-441d-afb4-e74cad0bb901) | #### DDS code I think the existing dds directory can be removed entirely instead of just being excluded like it is now. However, I'd like to keep it for a while longer and delete it during bcon2 of 3.6 if possible for ease of repros in the next few weeks. #### The Remaining Formats I'll continue to work towards a partial conversion of EXR, JPG, and WEBP but I can't commit to those for 3.6. Thumbnail support for these 3 formats are what's stopping a full conversion. JPEG 2000 support is lacking and that will take additional effort to solve if we want that format too.
Jesse Yurkovich added 1 commit 2023-03-15 07:07:11 +01:00
d3db309266 Image: Use OpenImageIO for loading and saving a variety of image formats
This checkin will use OIIO to replace the image save/load code for BMP,
DDS, DPX, HDR, PNG, TGA, and TIFF.

This simplifies our build environment, reduces binary duplication,
removes large amounts of hard to maintain code, and fixes some bugs
along the way.

It should also help reduce rare differences between Blender and Cycles
which already uses OIIO for most situations. Or potentially makes them
easier to solve once discovered.

----

Some test files (attached) are changed. Their summary is as follows:
 - Grayscale BMPs were saved out incorrectly in `main` and Windows refuses to display them. Now fixed.
 - Grayscale PNGs in 16bit format, coming from 32bit float buffers, were saved out incorrectly in `main`. Now fixed.
 - DPX files in all varieties were saved out incorrectly. I think; a second and third pair of eyes on this format would be welcome.

Example DPX changes:
| template EXR | #chan | save/load in main | save/load through OIIO |
| -- | -- | -- | -- |
|  |  |  |  |
|  |  |  |  |

A reminder about the remaining formats:
I'll continue to work towards a partial conversion of EXR, JPG, and WEBP but I can't commit to those for 3.6.
Thumbnail support for these 3 formats are what's stopping a full conversion.

JPEG 2000 support is lacking and that will take additional effort to solve if we want that format too.
Jesse Yurkovich added 1 commit 2023-03-15 23:47:53 +01:00
buildbot/vexp-code-patch-coordinator Build done. Details
bf24d6b2ee
Build fixes for linux/mac
Jesse Yurkovich changed title from WIP: Image: Use OpenImageIO for loading and saving a variety of image formats to Image: Use OpenImageIO for loading and saving a variety of image formats 2023-03-16 00:03:33 +01:00
Jesse Yurkovich added this to the Core project 2023-03-16 00:03:42 +01:00
Member

Grayscale PNGs in 16bit format, coming from 32bit float buffers, were saved out incorrectly in main. Now fixed.

It always helps to show the change, when something changes. =)

I had to track down the current SVN_imbuf_io to see that you switched it from taking the Rec 709 luma weights for RGB to BW conversion in main, to taking just the red channel as the BW input.

> Grayscale PNGs in 16bit format, coming from 32bit float buffers, were saved out incorrectly in main. Now fixed. It always helps to show the change, when something changes. =) I had to track down the current SVN_imbuf_io to see that you switched it from taking the Rec 709 luma weights for RGB to BW conversion in main, to taking just the red channel as the BW input.
Brecht Van Lommel requested review from Brecht Van Lommel 2023-03-17 11:20:01 +01:00

I had to track down the current SVN_imbuf_io to see that you switched it from taking the Rec 709 luma weights for RGB to BW conversion in main, to taking just the red channel as the BW input.

That seems wrong, BW is supposed to convert RGB to grayscale rather than using just 1 channel.

> I had to track down the current SVN_imbuf_io to see that you switched it from taking the Rec 709 luma weights for RGB to BW conversion in main, to taking just the red channel as the BW input. That seems wrong, BW is supposed to convert RGB to grayscale rather than using just 1 channel.

From the description I understand that there are expected differences in file saving, but from the tests it seems there are also differences in file loading?

cycles_displacement_cpu (Failed)
cycles_reports_cpu (Failed)
cycles_shader_cpu (Failed)
bf_imbuf_save (Failed)
bf_imbuf_load (Failed)
From the description I understand that there are expected differences in file saving, but from the tests it seems there are also differences in file loading? ``` cycles_displacement_cpu (Failed) cycles_reports_cpu (Failed) cycles_shader_cpu (Failed) bf_imbuf_save (Failed) bf_imbuf_load (Failed) ```
Brecht Van Lommel requested changes 2023-03-20 18:12:24 +01:00
Brecht Van Lommel left a comment
Owner

I didn't spot mistakes in the code, but marking request changes for the BW saving and failing tests.

I didn't spot mistakes in the code, but marking request changes for the BW saving and failing tests.
Author
Member

I think the Cycles test failures are because the PR branch here is behind main a bit and those tests were recently updated in SVN. I'll merge main after figuring out the PNG issue below.

As for the PNG issue, here is what they look like. For "main", is the "16 bit from 32 bit" case broken? Or is it correct and all the others are actually the broken ones?

bw 8 bit from 8 bit bw 8 bit from 32 bit bw 16 bit from 8 bit bw 16 bit from 32 bit
main png-bw-08-15__from__rgba08.png png-bw-08-15__from__rgba32.png png-bw-16-25__from__rgba08.png png-bw-16-25__from__rgba32.png
oiio same same same oiio-png-bw-16-25__from__rgba32.png
I think the Cycles test failures are because the PR branch here is behind main a bit and those tests were recently updated in SVN. I'll merge main after figuring out the PNG issue below. As for the PNG issue, here is what they look like. For "main", is the "16 bit from 32 bit" case broken? Or is it correct and all the others are actually the broken ones? | | bw 8 bit from 8 bit | bw 8 bit from 32 bit | bw 16 bit from 8 bit | bw 16 bit from 32 bit | | - | - | - | - | - | | main | ![png-bw-08-15__from__rgba08.png](/attachments/410614c4-8b83-4ad3-a5c0-577de6da7052) | ![png-bw-08-15__from__rgba32.png](/attachments/fac475d8-efe6-4d23-bead-9ad610ed810e) | ![png-bw-16-25__from__rgba08.png](/attachments/3cd57a3f-ef77-49f2-8fc6-c26106de7941) | ![png-bw-16-25__from__rgba32.png](/attachments/b960e5f6-3443-40e0-a4a9-cc2a7950aa6d) | | oiio | same | same | same | ![oiio-png-bw-16-25__from__rgba32.png](/attachments/27e99d0b-4166-40d5-a76c-9ab71fd93c5a) |

As for the PNG issue, here is what they look like. For "main", is the "16 bit from 32 bit" case broken? Or is it correct and all the others are actually the broken ones?

It seems to be all the others. Those match viewing just the R channel in the image editor, which is not what is expected.

> As for the PNG issue, here is what they look like. For "main", is the "16 bit from 32 bit" case broken? Or is it correct and all the others are actually the broken ones? It seems to be all the others. Those match viewing just the R channel in the image editor, which is not what is expected.
Jesse Yurkovich added 3 commits 2023-03-21 19:23:17 +01:00
Author
Member

Alright, latest update is using the luminance values for all grayscale images now. This fixes BMP,PNG,TGA, and TIFF which were all using just 1-channel.

This will fix #103728 and probably several others. JPG format remains "broken" and would require a separate fixup.

Alright, latest update is using the luminance values for all grayscale images now. This fixes BMP,PNG,TGA, and TIFF which were all using just 1-channel. This will fix #103728 and probably several others. JPG format remains "broken" and would require a separate fixup.
Jesse Yurkovich added 2 commits 2023-03-24 08:06:36 +01:00
Author
Member

I'll be away on travel with little to no internet until April 10th. I'll respond to any further feedback once I'm back but there's no additional known items outstanding on the patch I think.

I'll be away on travel with little to no internet until April 10th. I'll respond to any further feedback once I'm back but there's no additional known items outstanding on the patch I think.
Brecht Van Lommel requested review from Brecht Van Lommel 2023-03-24 21:09:16 +01:00

@blender-bot build

@blender-bot build
Brecht Van Lommel approved these changes 2023-03-27 13:41:22 +02:00
Jesse Yurkovich added 2 commits 2023-04-11 23:05:39 +02:00
Jesse Yurkovich merged commit aa3bdfd76a into main 2023-04-12 05:22:39 +02:00
Jesse Yurkovich deleted branch oiio-land-formats 2023-04-12 05:22:40 +02:00
Member

@deadpin https://builder.blender.org/admin/#/builders/31/builds/9466

294/319 Test #317: bf_imbuf_save ........................................................***Failed    6.00 sec
 
[ RUN      ] bmp-bw__from__rgba08.bmp
 Save result is different from reference image
[  FAILED  ] bmp-bw__from__rgba08.bmp
[ RUN      ] bmp-rgb__from__rgba08.bmp
[       OK ] bmp-rgb__from__rgba08.bmp
[ RUN      ] bmp-bw__from__rgba32.bmp
 Save result is different from reference image
[  FAILED  ] bmp-bw__from__rgba32.bmp
@deadpin https://builder.blender.org/admin/#/builders/31/builds/9466 ``` 294/319 Test #317: bf_imbuf_save ........................................................***Failed 6.00 sec [ RUN ] bmp-bw__from__rgba08.bmp Save result is different from reference image [ FAILED ] bmp-bw__from__rgba08.bmp [ RUN ] bmp-rgb__from__rgba08.bmp [ OK ] bmp-rgb__from__rgba08.bmp [ RUN ] bmp-bw__from__rgba32.bmp Save result is different from reference image [ FAILED ] bmp-bw__from__rgba32.bmp ```
Author
Member

@ankitm should be fixed now with 1771ded381

@ankitm should be fixed now with 1771ded381125409a578ca57093f79219fe5cf79
Bastien Montagne removed this from the Core project 2023-07-03 12:47:40 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#105785
No description provided.