Blender  V2.93
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 (uchar *lbuf, uchar *rlebuf, int z, int cnt)
 
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 (uint *lptr, int xsize, int ysize, int zsize, const char *name, int *zptr)
 
bool imb_saveiris (struct ImBuf *ibuf, const char *filepath, int flags)
 

Macro Definition Documentation

◆ BINTLUM

#define BINTLUM   (21)

Definition at line 62 of file iris.c.

◆ BPP

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

Definition at line 79 of file iris.c.

◆ BPPMASK

#define BPPMASK   0x00ff

Definition at line 74 of file iris.c.

◆ CHANOFFSET

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

Definition at line 71 of file iris.c.

◆ DIRTY_FLAG_ENCODING

#define DIRTY_FLAG_ENCODING   (1 << 1)

Definition at line 105 of file iris.c.

◆ DIRTY_FLAG_EOF

#define DIRTY_FLAG_EOF   (1 << 0)

Definition at line 104 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)

◆ 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 61 of file iris.c.

◆ GS

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

Definition at line 241 of file iris.c.

◆ GSS

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

Definition at line 244 of file iris.c.

◆ HEADER_SIZE

#define HEADER_SIZE   512

Definition at line 56 of file iris.c.

◆ ILUM

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

Definition at line 64 of file iris.c.

◆ IMAGIC

#define IMAGIC   0732

Definition at line 39 of file iris.c.

◆ ISRLE

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

Definition at line 77 of file iris.c.

◆ ITYPE_RLE

#define ITYPE_RLE   0x0100

Definition at line 76 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:104

◆ 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 91 of file iris.c.

◆ MFILE_SEEK

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

Definition at line 97 of file iris.c.

◆ MFILE_STEP

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

Definition at line 92 of file iris.c.

◆ OFFSET_B

#define OFFSET_B   2

Definition at line 68 of file iris.c.

◆ OFFSET_G

#define OFFSET_G   1

Definition at line 67 of file iris.c.

◆ OFFSET_R

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

Definition at line 66 of file iris.c.

◆ RINTLUM

#define RINTLUM   (79)

Definition at line 60 of file iris.c.

◆ RLE

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

Definition at line 80 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 ( uchar lbuf,
uchar rlebuf,
int  z,
int  cnt 
)
static

Definition at line 917 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 141 of file iris.c.

References MFILE_DATA, and MFILE_STEP.

Referenced by readtab().

◆ getshort()

static ushort getshort ( MFileOffset inf)
static

Definition at line 131 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 246 of file iris.c.

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

Referenced by imb_loadiris().

◆ imb_loadiris()

struct ImBuf* imb_loadiris ( const uchar 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 611 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 620 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 907 of file iris.c.

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

Referenced by output_iris().

◆ output_iris()

static bool output_iris ( uint lptr,
int  xsize,
int  ysize,
int  zsize,
const char *  name,
int *  zptr 
)
static

Copy an array of ints to an iris image file. Each int represents one pixel. xsize and ysize specify the dimensions of the pixel array. zsize specifies what kind of image file to write out. if zsize is 1, the luminance of the pixels are calculated, and a single channel black and white image is saved. If zsize is 3, an RGB image file is saved. If zsize is 4, an RGBA image file is saved.

Added: zbuf write

Definition at line 815 of file iris.c.

References BLI_fopen(), CHANOFFSET, compressrow(), IMAGE::dim, HEADER_SIZE, IMAGIC, IMAGE::imagic, len, lumrow(), IMAGE::max, MEM_freeN, MEM_mallocN, IMAGE::min, ImBuf::name, pos, RLE, IMAGE::type, writeheader(), writetab(), IMAGE::xsize, y, IMAGE::ysize, z, and IMAGE::zsize.

Referenced by imb_saveiris().

◆ putlong()

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

Definition at line 160 of file iris.c.

Referenced by writeheader(), and writetab().

◆ putshort()

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

Definition at line 151 of file iris.c.

Referenced by writeheader().

◆ readheader()

static void readheader ( MFileOffset inf,
IMAGE image 
)
static

Definition at line 171 of file iris.c.

References IMAGE::dim, getshort(), IMAGE::imagic, IMAGE::type, IMAGE::xsize, IMAGE::ysize, and IMAGE::zsize.

Referenced by imb_loadiris().

◆ readtab()

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

Definition at line 211 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 219 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

◆ writetab()

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

Definition at line 200 of file iris.c.

References len, putlong(), and r.

Referenced by output_iris().