Blender  V2.93
Classes | Typedefs | Functions | Variables
openexr_api.cpp File Reference
#include <algorithm>
#include <cerrno>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <set>
#include <stdexcept>
#include <string>
#include <Iex.h>
#include <ImathBox.h>
#include <ImfArray.h>
#include <ImfChannelList.h>
#include <ImfCompression.h>
#include <ImfCompressionAttribute.h>
#include <ImfIO.h>
#include <ImfInputFile.h>
#include <ImfOutputFile.h>
#include <ImfPixelType.h>
#include <ImfStandardAttributes.h>
#include <ImfStringAttribute.h>
#include <ImfVersion.h>
#include <half.h>
#include <ImfInputPart.h>
#include <ImfMultiPartInputFile.h>
#include <ImfMultiPartOutputFile.h>
#include <ImfMultiView.h>
#include <ImfOutputPart.h>
#include <ImfPartHelper.h>
#include <ImfPartType.h>
#include <ImfTiledOutputPart.h>
#include "DNA_scene_types.h"
#include <openexr_api.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math_color.h"
#include "BLI_threads.h"
#include "BKE_idprop.h"
#include "BKE_image.h"
#include "IMB_allocimbuf.h"
#include "IMB_colormanagement.h"
#include "IMB_colormanagement_intern.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_metadata.h"
#include "openexr_multi.h"

Go to the source code of this file.

Classes

class  IMemStream
 
class  IFileStream
 
class  OMemStream
 
class  OFileStream
 
struct  _RGBAZ
 
struct  ExrHandle
 
struct  ExrChannel
 
struct  ExrPass
 
struct  ExrLayer
 

Typedefs

using RGBAZ = _RGBAZ
 

Functions

static struct ExrPassimb_exr_get_pass (ListBase *lb, char *passname)
 
static bool exr_has_multiview (MultiPartInputFile &file)
 
static bool exr_has_multipart_file (MultiPartInputFile &file)
 
static bool exr_has_alpha (MultiPartInputFile &file)
 
static bool exr_has_zbuffer (MultiPartInputFile &file)
 
static void exr_printf (const char *__restrict fmt,...)
 
static void imb_exr_type_by_channels (ChannelList &channels, StringVector &views, bool *r_singlelayer, bool *r_multilayer, bool *r_multiview)
 
static half float_to_half_safe (const float value)
 
bool imb_is_a_openexr (const unsigned char *mem, const size_t size)
 
static void openexr_header_compression (Header *header, int compression)
 
static void openexr_header_metadata (Header *header, struct ImBuf *ibuf)
 
static void openexr_header_metadata_callback (void *data, const char *propname, char *prop, int UNUSED(len))
 
static bool imb_save_openexr_half (ImBuf *ibuf, const char *name, const int flags)
 
static bool imb_save_openexr_float (ImBuf *ibuf, const char *name, const int flags)
 
bool imb_save_openexr (struct ImBuf *ibuf, const char *name, int flags)
 
void * IMB_exr_get_handle (void)
 
void * IMB_exr_get_handle_name (const char *name)
 
void IMB_exr_add_view (void *handle, const char *name)
 
static int imb_exr_get_multiView_id (StringVector &views, const std::string &name)
 
static void imb_exr_get_views (MultiPartInputFile &file, StringVector &views)
 
static void imb_exr_insert_view_name (char *name_full, const char *passname, const char *viewname)
 
void IMB_exr_add_channel (void *handle, const char *layname, const char *passname, const char *viewname, int xstride, int ystride, float *rect, bool use_half_float)
 
int IMB_exr_begin_write (void *handle, const char *filename, int width, int height, int compress, const StampData *stamp)
 
void IMB_exrtile_begin_write (void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley)
 
int IMB_exr_begin_read (void *handle, const char *filename, int *width, int *height)
 
void IMB_exr_set_channel (void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect)
 
floatIMB_exr_channel_rect (void *handle, const char *layname, const char *passname, const char *viewname)
 
void IMB_exr_clear_channels (void *handle)
 
void IMB_exr_write_channels (void *handle)
 
void IMB_exrtile_write_channels (void *handle, int partx, int party, int level, const char *viewname, bool empty)
 
void IMB_exr_read_channels (void *handle)
 
void IMB_exr_multilayer_convert (void *handle, void *base, void *(*addview)(void *base, const char *str), void *(*addlayer)(void *base, const char *str), void(*addpass)(void *base, void *lay, const char *str, float *rect, int totchan, const char *chan_id, const char *view))
 
void IMB_exr_close (void *handle)
 
static int imb_exr_split_token (const char *str, const char *end, const char **token)
 
static int imb_exr_split_channel_name (ExrChannel *echan, char *layname, char *passname)
 
static ExrLayerimb_exr_get_layer (ListBase *lb, char *layname)
 
static ExrHandleimb_exr_begin_read_mem (IStream &file_stream, MultiPartInputFile &file, int width, int height)
 
static void exr_printf (const char *fmt,...)
 
static void exr_print_filecontents (MultiPartInputFile &file)
 
static const char * exr_rgba_channelname (MultiPartInputFile &file, const char *chan)
 
static int exr_has_rgb (MultiPartInputFile &file, const char *rgb_channels[3])
 
static bool exr_has_luma (MultiPartInputFile &file)
 
static bool exr_has_chroma (MultiPartInputFile &file)
 
static bool exr_is_half_float (MultiPartInputFile &file)
 
static bool imb_exr_is_multilayer_file (MultiPartInputFile &file)
 
static bool imb_exr_is_multi (MultiPartInputFile &file)
 
bool IMB_exr_has_multilayer (void *handle)
 
struct ImBufimb_load_openexr (const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
 
void imb_initopenexr (void)
 
void imb_exitopenexr (void)
 

Variables

static ListBase exrhandles = {nullptr, nullptr}
 

Typedef Documentation

◆ RGBAZ

using RGBAZ = _RGBAZ

Definition at line 321 of file openexr_api.cpp.

Function Documentation

◆ exr_has_alpha()

static bool exr_has_alpha ( MultiPartInputFile &  file)
static

Definition at line 1769 of file openexr_api.cpp.

References file.

Referenced by imb_load_openexr().

◆ exr_has_chroma()

static bool exr_has_chroma ( MultiPartInputFile &  file)
static

Definition at line 1756 of file openexr_api.cpp.

References file.

Referenced by imb_load_openexr().

◆ exr_has_luma()

static bool exr_has_luma ( MultiPartInputFile &  file)
static

Definition at line 1747 of file openexr_api.cpp.

References file.

Referenced by imb_load_openexr().

◆ exr_has_multipart_file()

static bool exr_has_multipart_file ( MultiPartInputFile &  file)
static

Definition at line 1866 of file openexr_api.cpp.

References file.

Referenced by imb_exr_get_views(), and imb_exr_is_multi().

◆ exr_has_multiview()

static bool exr_has_multiview ( MultiPartInputFile &  file)
static

Definition at line 1855 of file openexr_api.cpp.

References file.

Referenced by imb_exr_get_views(), and imb_exr_is_multi().

◆ exr_has_rgb()

static int exr_has_rgb ( MultiPartInputFile &  file,
const char *  rgb_channels[3] 
)
static

Definition at line 1726 of file openexr_api.cpp.

References file.

Referenced by imb_load_openexr().

◆ exr_has_zbuffer()

static bool exr_has_zbuffer ( MultiPartInputFile &  file)
static

Definition at line 1763 of file openexr_api.cpp.

References file.

Referenced by imb_load_openexr().

◆ exr_is_half_float()

static bool exr_is_half_float ( MultiPartInputFile &  file)
static

Definition at line 1775 of file openexr_api.cpp.

References file, and HALF.

Referenced by imb_load_openexr().

◆ exr_print_filecontents()

static void exr_print_filecontents ( MultiPartInputFile &  file)
static

Definition at line 1679 of file openexr_api.cpp.

References file, and view.

Referenced by imb_load_openexr().

◆ exr_printf() [1/2]

static void exr_printf ( const char *__restrict  fmt,
  ... 
)
static

◆ exr_printf() [2/2]

static void exr_printf ( const char *  fmt,
  ... 
)
static

Definition at line 1665 of file openexr_api.cpp.

References output.

◆ exr_rgba_channelname()

static const char* exr_rgba_channelname ( MultiPartInputFile &  file,
const char *  chan 
)
static

Definition at line 1709 of file openexr_api.cpp.

References BLI_strcasecmp(), file, len, and str.

Referenced by imb_load_openexr().

◆ float_to_half_safe()

static half float_to_half_safe ( const float  value)
static

Definition at line 323 of file openexr_api.cpp.

References clamp_f().

Referenced by IMB_exr_write_channels(), and imb_save_openexr_half().

◆ imb_exitopenexr()

void imb_exitopenexr ( void  )

Definition at line 2102 of file openexr_api.cpp.

◆ IMB_exr_add_channel()

void IMB_exr_add_channel ( void *  handle,
const char *  layname,
const char *  passname,
const char *  viewname,
int  xstride,
int  ystride,
float rect,
bool  use_half_float 
)

◆ IMB_exr_add_view()

void IMB_exr_add_view ( void *  handle,
const char *  name 
)

◆ IMB_exr_begin_read()

int IMB_exr_begin_read ( void *  handle,
const char *  filename,
int *  width,
int *  height 
)

◆ imb_exr_begin_read_mem()

static ExrHandle* imb_exr_begin_read_mem ( IStream &  file_stream,
MultiPartInputFile &  file,
int  width,
int  height 
)
static

◆ IMB_exr_begin_write()

int IMB_exr_begin_write ( void *  handle,
const char *  filename,
int  width,
int  height,
int  compress,
const StampData stamp 
)

◆ IMB_exr_channel_rect()

float* IMB_exr_channel_rect ( void *  handle,
const char *  layname,
const char *  passname,
const char *  viewname 
)

◆ IMB_exr_clear_channels()

void IMB_exr_clear_channels ( void *  handle)

◆ IMB_exr_close()

void IMB_exr_close ( void *  handle)

◆ IMB_exr_get_handle()

void* IMB_exr_get_handle ( void  )

◆ IMB_exr_get_handle_name()

void* IMB_exr_get_handle_name ( const char *  name)

◆ imb_exr_get_layer()

static ExrLayer* imb_exr_get_layer ( ListBase lb,
char *  layname 
)
static

◆ imb_exr_get_multiView_id()

static int imb_exr_get_multiView_id ( StringVector &  views,
const std::string &  name 
)
static

◆ imb_exr_get_pass()

static ExrPass * imb_exr_get_pass ( ListBase lb,
char *  passname 
)
static

◆ imb_exr_get_views()

static void imb_exr_get_views ( MultiPartInputFile &  file,
StringVector &  views 
)
static

◆ IMB_exr_has_multilayer()

bool IMB_exr_has_multilayer ( void *  handle)

Definition at line 1891 of file openexr_api.cpp.

References data, and imb_exr_is_multi().

Referenced by load_image_single(), and load_sequence_single().

◆ imb_exr_insert_view_name()

static void imb_exr_insert_view_name ( char *  name_full,
const char *  passname,
const char *  viewname 
)
static

◆ imb_exr_is_multi()

static bool imb_exr_is_multi ( MultiPartInputFile &  file)
static

◆ imb_exr_is_multilayer_file()

static bool imb_exr_is_multilayer_file ( MultiPartInputFile &  file)
static

Definition at line 1787 of file openexr_api.cpp.

References file.

Referenced by imb_exr_is_multi().

◆ IMB_exr_multilayer_convert()

void IMB_exr_multilayer_convert ( void *  handle,
void *  base,
void *(*)(void *base, const char *str addview,
void *(*)(void *base, const char *str addlayer,
void(*)(void *base, void *lay, const char *str, float *rect, int totchan, const char *chan_id, const char *view addpass 
)

◆ IMB_exr_read_channels()

void IMB_exr_read_channels ( void *  handle)

◆ IMB_exr_set_channel()

void IMB_exr_set_channel ( void *  handle,
const char *  layname,
const char *  passname,
int  xstride,
int  ystride,
float rect 
)

◆ imb_exr_split_channel_name()

static int imb_exr_split_channel_name ( ExrChannel echan,
char *  layname,
char *  passname 
)
static

◆ imb_exr_split_token()

static int imb_exr_split_token ( const char *  str,
const char *  end,
const char **  token 
)
static

Definition at line 1378 of file openexr_api.cpp.

References BLI_str_partition_ex(), and str.

Referenced by imb_exr_split_channel_name().

◆ imb_exr_type_by_channels()

static void imb_exr_type_by_channels ( ChannelList &  channels,
StringVector &  views,
bool *  r_singlelayer,
bool *  r_multilayer,
bool *  r_multiview 
)
static

Definition at line 1799 of file openexr_api.cpp.

References BLI_assert, imb_exr_get_multiView_id(), and pos.

Referenced by IMB_exr_begin_write().

◆ IMB_exr_write_channels()

void IMB_exr_write_channels ( void *  handle)

◆ IMB_exrtile_begin_write()

void IMB_exrtile_begin_write ( void *  handle,
const char *  filename,
int  mipmap,
int  width,
int  height,
int  tilex,
int  tiley 
)

◆ IMB_exrtile_write_channels()

void IMB_exrtile_write_channels ( void *  handle,
int  partx,
int  party,
int  level,
const char *  viewname,
bool  empty 
)

◆ imb_initopenexr()

void imb_initopenexr ( void  )

Definition at line 2095 of file openexr_api.cpp.

References BLI_system_thread_count().

◆ imb_is_a_openexr()

bool imb_is_a_openexr ( const unsigned char *  mem,
const size_t  size 
)

Test presence of OpenEXR file.

Parameters
mempointer to loaded OpenEXR bitstream

Definition at line 334 of file openexr_api.cpp.

References size().

Referenced by imb_load_openexr().

◆ imb_load_openexr()

struct ImBuf* imb_load_openexr ( const unsigned char *  mem,
size_t  size,
int  flags,
char  colorspace[IM_MAX_SPACE] 
)

◆ imb_save_openexr()

bool imb_save_openexr ( struct ImBuf ibuf,
const char *  name,
int  flags 
)

◆ imb_save_openexr_float()

static bool imb_save_openexr_float ( ImBuf ibuf,
const char *  name,
const int  flags 
)
static

◆ imb_save_openexr_half()

static bool imb_save_openexr_half ( ImBuf ibuf,
const char *  name,
const int  flags 
)
static

◆ openexr_header_compression()

static void openexr_header_compression ( Header header,
int  compression 
)
static

◆ openexr_header_metadata()

static void openexr_header_metadata ( Header header,
struct ImBuf ibuf 
)
static

◆ openexr_header_metadata_callback()

static void openexr_header_metadata_callback ( void *  data,
const char *  propname,
char *  prop,
int   UNUSEDlen 
)
static

Definition at line 402 of file openexr_api.cpp.

References data.

Referenced by IMB_exr_begin_write().

Variable Documentation

◆ exrhandles

ListBase exrhandles = {nullptr, nullptr}
static

Definition at line 622 of file openexr_api.cpp.

Referenced by IMB_exr_close(), IMB_exr_get_handle(), and IMB_exr_get_handle_name().