Image: Add OIIO support APIs #105519
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#105519
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "deadpin/blender:oiio-support"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This adds a new set of APIs supporting the loading and saving of image
formats through OIIO. It makes use of the recent IOProxy work in OIIO
to align with the existing Blender image loading/saving machinery.
The support code here has been prototyped to work with ~7 of our image
formats so far[1]. It includes centralized handling of
IB_test
,IB_mem
, andIB_metadata
flags, which the existing code did nothandle consistently or at all depending on the format.[2]
The PSD format (
format_psd.cc
) is included here since the priorlocation of the code has been restructured away. It serves as an example
of how the loading code typically flows for all the other formats.[3]
This continues the work for #101413
[1] The BMP,DDS,HDR,PNG,TIFF,and TARGA formats will be sent for review after this
[2] There is a small change in OpenEXR that is a result of the better metadata handling. If a loaded image has its "compression" metadata set, and the user then re-saves the image as OpenEXR, the API call to add this piece of metadata to the OpenEXR stream will fail. We simply do not transfer this attribute now; it's already been set for the image anyhow.
[3] Incidentally this will address #70495 for "free"
@ -0,0 +37,4 @@
size_t pwrite(const void *buf, size_t size, int64_t offset) override
{
std::lock_guard<std::mutex> lock(mutex_);
A mutex lock here seems risky for performance, do we know that it only writes in large chunks and the overhead is not too bad?
@ -0,0 +42,4 @@
/* If buffer is too small increase it. */
size_t end = offset + size;
while (end > ibuf_->encodedbuffersize) {
imb_enlargeencodedbufferImBuf(ibuf_);
I'm not sure this is working correctly.
imb_enlargeencodedbufferImBuf
seems to assume that the data to memcpy as the buffer is enlarged isencodedsize
bytes from the start of the buffer. But this looks like it can write anywhere in the full buffer?@ -0,0 +220,4 @@
ibuf->flags |= (spec.extra_attribs.empty()) ? 0 : IB_metadata;
for (const auto &attrib : spec.extra_attribs) {
IMB_metadata_set_field(ibuf->metadata, attrib.name().c_str(), attrib.get_string().c_str());
I'm a bit unsure about the performance implications of this. I vaguely remember some file formats having really big metadata, which may not be efficient to convert to a string.
Though I'm not really sure now where I saw that, maybe it's fine to ignore for now.
@ -0,0 +10,4 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
using uchar = unsigned char;
Use
BLI_sys_types.h
instead., otherwise might conflict if both are included.@ -0,0 +15,4 @@
/**
* Parameters and settings used while reading image formats.
*/
struct ReadContext {
These structs should have either a prefix or be in a namespace, the names are too generic.
@ -68,9 +68,6 @@ const char *imb_ext_image[] = {
};
const char *imb_ext_image_filepath_only[] = {
I guess this variable can be removed entirely now.
@ -0,0 +37,4 @@
return size;
}
size_t pwrite(const void *buf, size_t size, int64_t offset) override
I clarified with Larry over at OIIO and we can drop the mutex. I was using their internal IOProxies as an example of how to build ours but it turns out we'd only need the mutex if our code was calling
pwrite
concurrently with OIIO. Performance was within noise for me, as the lock is uncontended in our case, but it can be removed entirely.@ -0,0 +42,4 @@
/* If buffer is too small increase it. */
size_t end = offset + size;
while (end > ibuf_->encodedbuffersize) {
if (!imb_enlargeencodedbufferImBuf(ibuf_)) {
Good eye. It happened to work because of how OIIO calls into this (effectively in order) but a general caller of pwrite would indeed be problematic. Should be fixed now.
@blender-bot build
@blender-bot build