Blender  V3.3
Classes | Macros | Typedefs | Functions
iris.c File Reference
#include <string.h>
#include "BLI_fileops.h"
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"
#include "IMB_filetype.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "imbuf.h"
#include "IMB_colormanagement.h"
#include "IMB_colormanagement_intern.h"

Go to the source code of this file.

Classes

struct  IMAGE
 
struct  MFileOffset
 

Macros

#define IMAGIC   0732
 
#define HEADER_SIZE   512
 
#define RINTLUM   (79)
 
#define GINTLUM   (156)
 
#define BINTLUM   (21)
 
#define ILUM(r, g, b)   ((int)(RINTLUM * (r) + GINTLUM * (g) + BINTLUM * (b)) >> 8)
 
#define OFFSET_R   0 /* this is byte order dependent */
 
#define OFFSET_G   1
 
#define OFFSET_B   2
 
#define CHANOFFSET(z)   (3 - (z)) /* this is byte order dependent */
 
#define BPPMASK   0x00ff
 
#define ITYPE_RLE   0x0100
 
#define ISRLE(type)   (((type)&0xff00) == ITYPE_RLE)
 
#define BPP(type)   ((type)&BPPMASK)
 
#define RLE(bpp)   (ITYPE_RLE | (bpp))
 
#define MFILE_DATA(inf)   ((void)0, ((inf)->_file_data + (inf)->_file_offset))
 
#define MFILE_STEP(inf, step)
 
#define MFILE_SEEK(inf, pos)
 
#define DIRTY_FLAG_EOF   (1 << 0)
 
#define DIRTY_FLAG_ENCODING   (1 << 1)
 
#define GS(x)   (((uchar *)(x))[0] << 8 | ((uchar *)(x))[1])
 
#define GSS(x)   (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0])
 
#define MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(p)
 
#define MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(p)
 
#define EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next)
 
#define EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next)
 
#define EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next)
 
#define EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next)
 

Typedefs

typedef struct MFileOffset MFileOffset
 

Functions

 BLI_STATIC_ASSERT (sizeof(IMAGE)==HEADER_SIZE, "Invalid header size")
 
static void readheader (MFileOffset *inf, IMAGE *image)
 
static int writeheader (FILE *outf, IMAGE *image)
 
static ushort getshort (MFileOffset *inf)
 
static uint getlong (MFileOffset *mofs)
 
static void putshort (FILE *outf, ushort val)
 
static int putlong (FILE *outf, uint val)
 
static int writetab (FILE *outf, uint *tab, int len)
 
static void readtab (MFileOffset *inf, uint *tab, int len)
 
static int expandrow (uchar *optr, const uchar *optr_end, const uchar *iptr, const uchar *iptr_end, int z)
 
static int expandrow2 (float *optr, const float *optr_end, const uchar *iptr, const uchar *iptr_end, int z)
 
static void interleaverow (uchar *lptr, const uchar *cptr, int z, int n)
 
static void interleaverow2 (float *lptr, const uchar *cptr, int z, int n)
 
static int compressrow (const uchar *lbuf, uchar *rlebuf, int z, int row_len)
 
static void lumrow (const uchar *rgbptr, uchar *lumptr, int n)
 
static void test_endian_zbuf (struct ImBuf *ibuf)
 
bool imb_is_a_iris (const uchar *mem, size_t size)
 
struct ImBufimb_loadiris (const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
 
static bool output_iris (const char *filepath, const uint *lptr, const int *zptr, const int xsize, const int ysize, const int zsize)
 
bool imb_saveiris (struct ImBuf *ibuf, const char *filepath, int flags)
 

Macro Definition Documentation

◆ BINTLUM

#define BINTLUM   (21)

Definition at line 46 of file iris.c.

◆ BPP

#define BPP (   type)    ((type)&BPPMASK)

Definition at line 63 of file iris.c.

◆ BPPMASK

#define BPPMASK   0x00ff

Definition at line 58 of file iris.c.

◆ CHANOFFSET

#define CHANOFFSET (   z)    (3 - (z)) /* this is byte order dependent */

Definition at line 55 of file iris.c.

◆ DIRTY_FLAG_ENCODING

#define DIRTY_FLAG_ENCODING   (1 << 1)

Definition at line 89 of file iris.c.

◆ DIRTY_FLAG_EOF

#define DIRTY_FLAG_EOF   (1 << 0)

Definition at line 88 of file iris.c.

◆ EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL [1/2]

#define EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL (   iptr_next)
Value:
if (UNLIKELY(iptr_next > iptr_end)) { \
goto fail; \
} \
((void)0)
#define UNLIKELY(x)
SyclQueue void void size_t num_bytes void

◆ EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL [2/2]

#define EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL (   iptr_next)
Value:
if (UNLIKELY(iptr_next > iptr_end)) { \
goto fail; \
} \
((void)0)

◆ EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL [1/2]

#define EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL (   optr_next)
Value:
if (UNLIKELY(optr_next > optr_end)) { \
goto fail; \
} \
((void)0)

◆ EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL [2/2]

#define EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL (   optr_next)
Value:
if (UNLIKELY(optr_next > optr_end)) { \
goto fail; \
} \
((void)0)

◆ GINTLUM

#define GINTLUM   (156)

Definition at line 45 of file iris.c.

◆ GS

#define GS (   x)    (((uchar *)(x))[0] << 8 | ((uchar *)(x))[1])

Definition at line 225 of file iris.c.

◆ GSS

#define GSS (   x)    (((uchar *)(x))[1] << 8 | ((uchar *)(x))[0])

Definition at line 228 of file iris.c.

◆ HEADER_SIZE

#define HEADER_SIZE   512

Definition at line 40 of file iris.c.

◆ ILUM

#define ILUM (   r,
  g,
 
)    ((int)(RINTLUM * (r) + GINTLUM * (g) + BINTLUM * (b)) >> 8)

Definition at line 48 of file iris.c.

◆ IMAGIC

#define IMAGIC   0732

Definition at line 23 of file iris.c.

◆ ISRLE

#define ISRLE (   type)    (((type)&0xff00) == ITYPE_RLE)

Definition at line 61 of file iris.c.

◆ ITYPE_RLE

#define ITYPE_RLE   0x0100

Definition at line 60 of file iris.c.

◆ MFILE_CAPACITY_AT_PTR_OK_OR_FAIL [1/2]

#define MFILE_CAPACITY_AT_PTR_OK_OR_FAIL (   p)
Value:
if (UNLIKELY((p) > mem_end)) { \
dirty_flag |= DIRTY_FLAG_EOF; \
goto fail_rle; \
} \
((void)0)
#define DIRTY_FLAG_EOF
Definition: iris.c:88

◆ MFILE_CAPACITY_AT_PTR_OK_OR_FAIL [2/2]

#define MFILE_CAPACITY_AT_PTR_OK_OR_FAIL (   p)
Value:
if (UNLIKELY((p) > mem_end)) { \
dirty_flag |= DIRTY_FLAG_EOF; \
goto fail_uncompressed; \
} \
((void)0)

◆ MFILE_DATA

#define MFILE_DATA (   inf)    ((void)0, ((inf)->_file_data + (inf)->_file_offset))

Definition at line 75 of file iris.c.

◆ MFILE_SEEK

#define MFILE_SEEK (   inf,
  pos 
)
Value:
{ \
(inf)->_file_offset = pos; \
} \
((void)0)
uint pos

Definition at line 81 of file iris.c.

◆ MFILE_STEP

#define MFILE_STEP (   inf,
  step 
)
Value:
{ \
(inf)->_file_offset += step; \
} \
((void)0)

Definition at line 76 of file iris.c.

◆ OFFSET_B

#define OFFSET_B   2

Definition at line 52 of file iris.c.

◆ OFFSET_G

#define OFFSET_G   1

Definition at line 51 of file iris.c.

◆ OFFSET_R

#define OFFSET_R   0 /* this is byte order dependent */

Definition at line 50 of file iris.c.

◆ RINTLUM

#define RINTLUM   (79)

Definition at line 44 of file iris.c.

◆ RLE

#define RLE (   bpp)    (ITYPE_RLE | (bpp))

Definition at line 64 of file iris.c.

Typedef Documentation

◆ MFileOffset

typedef struct MFileOffset MFileOffset

Function Documentation

◆ BLI_STATIC_ASSERT()

BLI_STATIC_ASSERT ( sizeof(IMAGE = =HEADER_SIZE,
"Invalid header size  
)

◆ compressrow()

static int compressrow ( const uchar lbuf,
uchar rlebuf,
int  z,
int  row_len 
)
static

Definition at line 900 of file iris.c.

References count, and z.

Referenced by output_iris().

◆ expandrow()

static int expandrow ( uchar optr,
const uchar optr_end,
const uchar iptr,
const uchar iptr_end,
int  z 
)
static

◆ expandrow2()

static int expandrow2 ( float optr,
const float optr_end,
const uchar iptr,
const uchar iptr_end,
int  z 
)
static

◆ getlong()

static uint getlong ( MFileOffset mofs)
static

Definition at line 125 of file iris.c.

References MFILE_DATA, and MFILE_STEP.

Referenced by readtab().

◆ getshort()

static ushort getshort ( MFileOffset inf)
static

Definition at line 115 of file iris.c.

References MFILE_DATA, and MFILE_STEP.

Referenced by readheader().

◆ imb_is_a_iris()

bool imb_is_a_iris ( const uchar mem,
size_t  size 
)

Definition at line 230 of file iris.c.

References GS, GSS, IMAGIC, and size().

Referenced by imb_loadiris().

◆ imb_loadiris()

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

◆ imb_saveiris()

bool imb_saveiris ( struct ImBuf ibuf,
const char *  filepath,
int  flags 
)

◆ interleaverow()

static void interleaverow ( uchar lptr,
const uchar cptr,
int  z,
int  n 
)
static

Definition at line 589 of file iris.c.

References z.

Referenced by imb_loadiris().

◆ interleaverow2()

static void interleaverow2 ( float lptr,
const uchar cptr,
int  z,
int  n 
)
static

Definition at line 598 of file iris.c.

References z.

Referenced by imb_loadiris().

◆ lumrow()

static void lumrow ( const uchar rgbptr,
uchar lumptr,
int  n 
)
static

Definition at line 890 of file iris.c.

References CHANOFFSET, ILUM, OFFSET_B, OFFSET_G, and OFFSET_R.

Referenced by output_iris().

◆ output_iris()

static bool output_iris ( const char *  filepath,
const uint lptr,
const int *  zptr,
const int  xsize,
const int  ysize,
const int  zsize 
)
static
Parameters
filepathThe file path to write to.
lptran array of integers to an iris image file (each int represents one pixel).
zptrdepth-buffer (optional, may be NULL).
xsizewith width of the pixel-array.
ysizeheight of the pixel-array.
zsizespecifies what kind of image file to write out.
  • 1: the luminance of the pixels are calculated, and a single channel black and white image is saved.
  • 3: an RGB image file is saved.
  • 4: an RGBA image file is saved.
  • 8: an RGBA image and a Z-buffer (non-null zptr).

Definition at line 794 of file iris.c.

References BLI_assert_msg, BLI_fopen(), CHANOFFSET, compressrow(), HEADER_SIZE, image(), IMAGIC, len, lumrow(), MEM_freeN, MEM_mallocN, pos, RLE, writeheader(), writetab(), y, and z.

Referenced by imb_saveiris().

◆ putlong()

static int putlong ( FILE *  outf,
uint  val 
)
static

Definition at line 144 of file iris.c.

Referenced by writeheader(), and writetab().

◆ putshort()

static void putshort ( FILE *  outf,
ushort  val 
)
static

Definition at line 135 of file iris.c.

Referenced by writeheader().

◆ readheader()

static void readheader ( MFileOffset inf,
IMAGE image 
)
static

Definition at line 155 of file iris.c.

References getshort(), and image().

Referenced by imb_loadiris().

◆ readtab()

static void readtab ( MFileOffset inf,
uint tab,
int  len 
)
static

Definition at line 195 of file iris.c.

References getlong(), and len.

Referenced by imb_loadiris().

◆ test_endian_zbuf()

static void test_endian_zbuf ( struct ImBuf ibuf)
static

Definition at line 203 of file iris.c.

References BIG_LONG, len, NULL, ImBuf::x, ImBuf::y, and ImBuf::zbuf.

Referenced by imb_loadiris(), and imb_saveiris().

◆ writeheader()

static int writeheader ( FILE *  outf,
IMAGE image 
)
static

Definition at line 166 of file iris.c.

References image(), putlong(), putshort(), and t.

Referenced by output_iris().

◆ writetab()

static int writetab ( FILE *  outf,
uint tab,
int  len 
)
static

Definition at line 184 of file iris.c.

References len, putlong(), and r.

Referenced by output_iris().