Cleanup: use u-prefixed integer types (for brevity)
This commit is contained in:
parent
75f9b691e2
commit
4d69b6f525
@ -258,7 +258,7 @@ bool addzbufImBuf(ImBuf *ibuf)
|
|||||||
|
|
||||||
IMB_freezbufImBuf(ibuf);
|
IMB_freezbufImBuf(ibuf);
|
||||||
|
|
||||||
if ((ibuf->zbuf = imb_alloc_pixels(ibuf->x, ibuf->y, 1, sizeof(unsigned int), __func__))) {
|
if ((ibuf->zbuf = imb_alloc_pixels(ibuf->x, ibuf->y, 1, sizeof(uint), __func__))) {
|
||||||
ibuf->mall |= IB_zbuf;
|
ibuf->mall |= IB_zbuf;
|
||||||
ibuf->flags |= IB_zbuf;
|
ibuf->flags |= IB_zbuf;
|
||||||
return true;
|
return true;
|
||||||
@ -309,7 +309,7 @@ bool imb_addencodedbufferImBuf(ImBuf *ibuf)
|
|||||||
|
|
||||||
bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
|
bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
|
||||||
{
|
{
|
||||||
unsigned int newsize, encodedsize;
|
uint newsize, encodedsize;
|
||||||
void *newbuffer;
|
void *newbuffer;
|
||||||
|
|
||||||
if (ibuf == NULL) {
|
if (ibuf == NULL) {
|
||||||
@ -351,8 +351,7 @@ bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *imb_alloc_pixels(
|
void *imb_alloc_pixels(uint x, uint y, uint channels, size_t typesize, const char *name)
|
||||||
unsigned int x, unsigned int y, unsigned int channels, size_t typesize, const char *name)
|
|
||||||
{
|
{
|
||||||
/* Protect against buffer overflow vulnerabilities from files specifying
|
/* Protect against buffer overflow vulnerabilities from files specifying
|
||||||
* a width and height that overflow and alloc too little memory. */
|
* a width and height that overflow and alloc too little memory. */
|
||||||
@ -364,7 +363,7 @@ void *imb_alloc_pixels(
|
|||||||
return MEM_callocN(size, name);
|
return MEM_callocN(size, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool imb_addrectfloatImBuf(ImBuf *ibuf, const unsigned int channels)
|
bool imb_addrectfloatImBuf(ImBuf *ibuf, const uint channels)
|
||||||
{
|
{
|
||||||
if (ibuf == NULL) {
|
if (ibuf == NULL) {
|
||||||
return false;
|
return false;
|
||||||
@ -399,7 +398,7 @@ bool imb_addrectImBuf(ImBuf *ibuf)
|
|||||||
}
|
}
|
||||||
ibuf->rect = NULL;
|
ibuf->rect = NULL;
|
||||||
|
|
||||||
if ((ibuf->rect = imb_alloc_pixels(ibuf->x, ibuf->y, 4, sizeof(unsigned char), __func__))) {
|
if ((ibuf->rect = imb_alloc_pixels(ibuf->x, ibuf->y, 4, sizeof(uchar), __func__))) {
|
||||||
ibuf->mall |= IB_rect;
|
ibuf->mall |= IB_rect;
|
||||||
ibuf->flags |= IB_rect;
|
ibuf->flags |= IB_rect;
|
||||||
if (ibuf->planes > 32) {
|
if (ibuf->planes > 32) {
|
||||||
@ -412,8 +411,7 @@ bool imb_addrectImBuf(ImBuf *ibuf)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ImBuf *IMB_allocFromBufferOwn(
|
struct ImBuf *IMB_allocFromBufferOwn(uint *rect, float *rectf, uint w, uint h, uint channels)
|
||||||
unsigned int *rect, float *rectf, unsigned int w, unsigned int h, unsigned int channels)
|
|
||||||
{
|
{
|
||||||
ImBuf *ibuf = NULL;
|
ImBuf *ibuf = NULL;
|
||||||
|
|
||||||
@ -444,11 +442,8 @@ struct ImBuf *IMB_allocFromBufferOwn(
|
|||||||
return ibuf;
|
return ibuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect,
|
struct ImBuf *IMB_allocFromBuffer(
|
||||||
const float *rectf,
|
const uint *rect, const float *rectf, uint w, uint h, uint channels)
|
||||||
unsigned int w,
|
|
||||||
unsigned int h,
|
|
||||||
unsigned int channels)
|
|
||||||
{
|
{
|
||||||
ImBuf *ibuf = NULL;
|
ImBuf *ibuf = NULL;
|
||||||
|
|
||||||
@ -488,8 +483,7 @@ bool imb_addtilesImBuf(ImBuf *ibuf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ibuf->tiles) {
|
if (!ibuf->tiles) {
|
||||||
if ((ibuf->tiles = MEM_callocN(sizeof(unsigned int *) * ibuf->xtiles * ibuf->ytiles,
|
if ((ibuf->tiles = MEM_callocN(sizeof(uint *) * ibuf->xtiles * ibuf->ytiles, "imb_tiles"))) {
|
||||||
"imb_tiles"))) {
|
|
||||||
ibuf->mall |= IB_tiles;
|
ibuf->mall |= IB_tiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -497,7 +491,7 @@ bool imb_addtilesImBuf(ImBuf *ibuf)
|
|||||||
return (ibuf->tiles != NULL);
|
return (ibuf->tiles != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int flags)
|
ImBuf *IMB_allocImBuf(uint x, uint y, uchar planes, uint flags)
|
||||||
{
|
{
|
||||||
ImBuf *ibuf;
|
ImBuf *ibuf;
|
||||||
|
|
||||||
@ -513,8 +507,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int
|
|||||||
return ibuf;
|
return ibuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IMB_initImBuf(
|
bool IMB_initImBuf(struct ImBuf *ibuf, uint x, uint y, uchar planes, uint flags)
|
||||||
struct ImBuf *ibuf, unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
|
|
||||||
{
|
{
|
||||||
memset(ibuf, 0, sizeof(ImBuf));
|
memset(ibuf, 0, sizeof(ImBuf));
|
||||||
|
|
||||||
@ -678,7 +671,7 @@ size_t IMB_get_size_in_memory(ImBuf *ibuf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ibuf->tiles) {
|
if (ibuf->tiles) {
|
||||||
size += sizeof(unsigned int) * ibuf->ytiles * ibuf->xtiles;
|
size += sizeof(uint) * ibuf->ytiles * ibuf->xtiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
@ -97,9 +97,9 @@ static void free_anim_movie(struct anim *UNUSED(anim))
|
|||||||
# define PATHSEPARATOR '/'
|
# define PATHSEPARATOR '/'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int an_stringdec(const char *string, char *head, char *tail, unsigned short *numlen)
|
static int an_stringdec(const char *string, char *head, char *tail, ushort *numlen)
|
||||||
{
|
{
|
||||||
unsigned short len, nume, nums = 0;
|
ushort len, nume, nums = 0;
|
||||||
short i;
|
short i;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
@ -139,8 +139,7 @@ static int an_stringdec(const char *string, char *head, char *tail, unsigned sho
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void an_stringenc(
|
static void an_stringenc(char *string, const char *head, const char *tail, ushort numlen, int pic)
|
||||||
char *string, const char *head, const char *tail, unsigned short numlen, int pic)
|
|
||||||
{
|
{
|
||||||
BLI_path_sequence_encode(string, head, tail, numlen, pic);
|
BLI_path_sequence_encode(string, head, tail, numlen, pic);
|
||||||
}
|
}
|
||||||
@ -454,7 +453,7 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position)
|
|||||||
lpbi = AVIStreamGetFrame(anim->pgf, position + AVIStreamStart(anim->pavi[anim->firstvideo]));
|
lpbi = AVIStreamGetFrame(anim->pgf, position + AVIStreamStart(anim->pavi[anim->firstvideo]));
|
||||||
if (lpbi) {
|
if (lpbi) {
|
||||||
ibuf = IMB_ibImageFromMemory(
|
ibuf = IMB_ibImageFromMemory(
|
||||||
(const unsigned char *)lpbi, 100, IB_rect, anim->colorspace, "<avi_fetchibuf>");
|
(const uchar *)lpbi, 100, IB_rect, anim->colorspace, "<avi_fetchibuf>");
|
||||||
/* Oh brother... */
|
/* Oh brother... */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1568,7 +1567,7 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim,
|
|||||||
{
|
{
|
||||||
struct ImBuf *ibuf = NULL;
|
struct ImBuf *ibuf = NULL;
|
||||||
char head[256], tail[256];
|
char head[256], tail[256];
|
||||||
unsigned short digits;
|
ushort digits;
|
||||||
int pic;
|
int pic;
|
||||||
int filter_y;
|
int filter_y;
|
||||||
if (anim == NULL) {
|
if (anim == NULL) {
|
||||||
|
@ -81,11 +81,11 @@ static ImGlobalTileCache GLOBAL_CACHE;
|
|||||||
/** \name Hash Functions
|
/** \name Hash Functions
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static unsigned int imb_global_tile_hash(const void *gtile_p)
|
static uint imb_global_tile_hash(const void *gtile_p)
|
||||||
{
|
{
|
||||||
const ImGlobalTile *gtile = gtile_p;
|
const ImGlobalTile *gtile = gtile_p;
|
||||||
|
|
||||||
return ((unsigned int)(intptr_t)gtile->ibuf) * 769 + gtile->tx * 53 + gtile->ty * 97;
|
return ((uint)(intptr_t)gtile->ibuf) * 769 + gtile->tx * 53 + gtile->ty * 97;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool imb_global_tile_cmp(const void *a_p, const void *b_p)
|
static bool imb_global_tile_cmp(const void *a_p, const void *b_p)
|
||||||
@ -96,11 +96,11 @@ static bool imb_global_tile_cmp(const void *a_p, const void *b_p)
|
|||||||
return ((a->ibuf != b->ibuf) || (a->tx != b->tx) || (a->ty != b->ty));
|
return ((a->ibuf != b->ibuf) || (a->tx != b->tx) || (a->ty != b->ty));
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int imb_thread_tile_hash(const void *ttile_p)
|
static uint imb_thread_tile_hash(const void *ttile_p)
|
||||||
{
|
{
|
||||||
const ImThreadTile *ttile = ttile_p;
|
const ImThreadTile *ttile = ttile_p;
|
||||||
|
|
||||||
return ((unsigned int)(intptr_t)ttile->ibuf) * 769 + ttile->tx * 53 + ttile->ty * 97;
|
return ((uint)(intptr_t)ttile->ibuf) * 769 + ttile->tx * 53 + ttile->ty * 97;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool imb_thread_tile_cmp(const void *a_p, const void *b_p)
|
static bool imb_thread_tile_cmp(const void *a_p, const void *b_p)
|
||||||
@ -121,9 +121,9 @@ static void imb_global_cache_tile_load(ImGlobalTile *gtile)
|
|||||||
{
|
{
|
||||||
ImBuf *ibuf = gtile->ibuf;
|
ImBuf *ibuf = gtile->ibuf;
|
||||||
int toffs = ibuf->xtiles * gtile->ty + gtile->tx;
|
int toffs = ibuf->xtiles * gtile->ty + gtile->tx;
|
||||||
unsigned int *rect;
|
uint *rect;
|
||||||
|
|
||||||
rect = MEM_callocN(sizeof(unsigned int) * ibuf->tilex * ibuf->tiley, "imb_tile");
|
rect = MEM_callocN(sizeof(uint) * ibuf->tilex * ibuf->tiley, "imb_tile");
|
||||||
imb_loadtile(ibuf, gtile->tx, gtile->ty, rect);
|
imb_loadtile(ibuf, gtile->tx, gtile->ty, rect);
|
||||||
ibuf->tiles[toffs] = rect;
|
ibuf->tiles[toffs] = rect;
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ static void imb_global_cache_tile_unload(ImGlobalTile *gtile)
|
|||||||
MEM_freeN(ibuf->tiles[toffs]);
|
MEM_freeN(ibuf->tiles[toffs]);
|
||||||
ibuf->tiles[toffs] = NULL;
|
ibuf->tiles[toffs] = NULL;
|
||||||
|
|
||||||
GLOBAL_CACHE.totmem -= sizeof(unsigned int) * ibuf->tilex * ibuf->tiley;
|
GLOBAL_CACHE.totmem -= sizeof(uint) * ibuf->tilex * ibuf->tiley;
|
||||||
}
|
}
|
||||||
|
|
||||||
void imb_tile_cache_tile_free(ImBuf *ibuf, int tx, int ty)
|
void imb_tile_cache_tile_free(ImBuf *ibuf, int tx, int ty)
|
||||||
@ -343,7 +343,7 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf,
|
|||||||
BLI_addhead(&GLOBAL_CACHE.tiles, gtile);
|
BLI_addhead(&GLOBAL_CACHE.tiles, gtile);
|
||||||
|
|
||||||
/* mark as being loaded and unlock to allow other threads to load too */
|
/* mark as being loaded and unlock to allow other threads to load too */
|
||||||
GLOBAL_CACHE.totmem += sizeof(unsigned int) * ibuf->tilex * ibuf->tiley;
|
GLOBAL_CACHE.totmem += sizeof(uint) * ibuf->tilex * ibuf->tiley;
|
||||||
|
|
||||||
BLI_mutex_unlock(&GLOBAL_CACHE.mutex);
|
BLI_mutex_unlock(&GLOBAL_CACHE.mutex);
|
||||||
|
|
||||||
@ -363,10 +363,7 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf,
|
|||||||
/** \name Per-Thread Cache
|
/** \name Per-Thread Cache
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache,
|
static uint *imb_thread_cache_get_tile(ImThreadTileCache *cache, ImBuf *ibuf, int tx, int ty)
|
||||||
ImBuf *ibuf,
|
|
||||||
int tx,
|
|
||||||
int ty)
|
|
||||||
{
|
{
|
||||||
ImThreadTile *ttile, lookuptile;
|
ImThreadTile *ttile, lookuptile;
|
||||||
ImGlobalTile *gtile, *replacetile;
|
ImGlobalTile *gtile, *replacetile;
|
||||||
@ -418,7 +415,7 @@ static unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache,
|
|||||||
return ibuf->tiles[toffs];
|
return ibuf->tiles[toffs];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int *IMB_gettile(ImBuf *ibuf, int tx, int ty, int thread)
|
uint *IMB_gettile(ImBuf *ibuf, int tx, int ty, int thread)
|
||||||
{
|
{
|
||||||
return imb_thread_cache_get_tile(&GLOBAL_CACHE.thread_cache[thread + 1], ibuf, tx, ty);
|
return imb_thread_cache_get_tile(&GLOBAL_CACHE.thread_cache[thread + 1], ibuf, tx, ty);
|
||||||
}
|
}
|
||||||
@ -427,7 +424,7 @@ void IMB_tiles_to_rect(ImBuf *ibuf)
|
|||||||
{
|
{
|
||||||
ImBuf *mipbuf;
|
ImBuf *mipbuf;
|
||||||
ImGlobalTile *gtile;
|
ImGlobalTile *gtile;
|
||||||
unsigned int *to, *from;
|
uint *to, *from;
|
||||||
int a, tx, ty, y, w, h;
|
int a, tx, ty, y, w, h;
|
||||||
|
|
||||||
for (a = 0; a < ibuf->miptot; a++) {
|
for (a = 0; a < ibuf->miptot; a++) {
|
||||||
@ -435,8 +432,7 @@ void IMB_tiles_to_rect(ImBuf *ibuf)
|
|||||||
|
|
||||||
/* don't call imb_addrectImBuf, it frees all mipmaps */
|
/* don't call imb_addrectImBuf, it frees all mipmaps */
|
||||||
if (!mipbuf->rect) {
|
if (!mipbuf->rect) {
|
||||||
if ((mipbuf->rect = MEM_callocN(ibuf->x * ibuf->y * sizeof(unsigned int),
|
if ((mipbuf->rect = MEM_callocN(ibuf->x * ibuf->y * sizeof(uint), "imb_addrectImBuf"))) {
|
||||||
"imb_addrectImBuf"))) {
|
|
||||||
mipbuf->mall |= IB_rect;
|
mipbuf->mall |= IB_rect;
|
||||||
mipbuf->flags |= IB_rect;
|
mipbuf->flags |= IB_rect;
|
||||||
}
|
}
|
||||||
@ -460,7 +456,7 @@ void IMB_tiles_to_rect(ImBuf *ibuf)
|
|||||||
h = (ty == mipbuf->ytiles - 1) ? mipbuf->y - ty * mipbuf->tiley : mipbuf->tiley;
|
h = (ty == mipbuf->ytiles - 1) ? mipbuf->y - ty * mipbuf->tiley : mipbuf->tiley;
|
||||||
|
|
||||||
for (y = 0; y < h; y++) {
|
for (y = 0; y < h; y++) {
|
||||||
memcpy(to, from, sizeof(unsigned int) * w);
|
memcpy(to, from, sizeof(uint) * w);
|
||||||
from += mipbuf->tilex;
|
from += mipbuf->tilex;
|
||||||
to += mipbuf->x;
|
to += mipbuf->x;
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@
|
|||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
static struct ImBuf *imb_load_dpx_cineon(const unsigned char *mem,
|
static struct ImBuf *imb_load_dpx_cineon(
|
||||||
size_t size,
|
const uchar *mem, size_t size, int use_cineon, int flags, char colorspace[IM_MAX_SPACE])
|
||||||
int use_cineon,
|
|
||||||
int flags,
|
|
||||||
char colorspace[IM_MAX_SPACE])
|
|
||||||
{
|
{
|
||||||
ImBuf *ibuf;
|
ImBuf *ibuf;
|
||||||
LogImageFile *image;
|
LogImageFile *image;
|
||||||
@ -74,7 +71,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filepath, int use_cineon
|
|||||||
LogImageFile *logImage;
|
LogImageFile *logImage;
|
||||||
float *fbuf;
|
float *fbuf;
|
||||||
float *fbuf_ptr;
|
float *fbuf_ptr;
|
||||||
unsigned char *rect_ptr;
|
uchar *rect_ptr;
|
||||||
int x, y, depth, bitspersample, rvalue;
|
int x, y, depth, bitspersample, rvalue;
|
||||||
|
|
||||||
if (flags & IB_mem) {
|
if (flags & IB_mem) {
|
||||||
@ -153,7 +150,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filepath, int use_cineon
|
|||||||
for (y = 0; y < ibuf->y; y++) {
|
for (y = 0; y < ibuf->y; y++) {
|
||||||
for (x = 0; x < ibuf->x; x++) {
|
for (x = 0; x < ibuf->x; x++) {
|
||||||
fbuf_ptr = fbuf + 4 * ((ibuf->y - y - 1) * ibuf->x + x);
|
fbuf_ptr = fbuf + 4 * ((ibuf->y - y - 1) * ibuf->x + x);
|
||||||
rect_ptr = (unsigned char *)ibuf->rect + 4 * (y * ibuf->x + x);
|
rect_ptr = (uchar *)ibuf->rect + 4 * (y * ibuf->x + x);
|
||||||
fbuf_ptr[0] = (float)rect_ptr[0] / 255.0f;
|
fbuf_ptr[0] = (float)rect_ptr[0] / 255.0f;
|
||||||
fbuf_ptr[1] = (float)rect_ptr[1] / 255.0f;
|
fbuf_ptr[1] = (float)rect_ptr[1] / 255.0f;
|
||||||
fbuf_ptr[2] = (float)rect_ptr[2] / 255.0f;
|
fbuf_ptr[2] = (float)rect_ptr[2] / 255.0f;
|
||||||
@ -173,15 +170,12 @@ bool imb_save_cineon(struct ImBuf *buf, const char *filepath, int flags)
|
|||||||
return imb_save_dpx_cineon(buf, filepath, 1, flags);
|
return imb_save_dpx_cineon(buf, filepath, 1, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool imb_is_a_cineon(const unsigned char *buf, size_t size)
|
bool imb_is_a_cineon(const uchar *buf, size_t size)
|
||||||
{
|
{
|
||||||
return logImageIsCineon(buf, size);
|
return logImageIsCineon(buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImBuf *imb_load_cineon(const unsigned char *mem,
|
ImBuf *imb_load_cineon(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
|
||||||
size_t size,
|
|
||||||
int flags,
|
|
||||||
char colorspace[IM_MAX_SPACE])
|
|
||||||
{
|
{
|
||||||
if (!imb_is_a_cineon(mem, size)) {
|
if (!imb_is_a_cineon(mem, size)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -194,15 +188,12 @@ bool imb_save_dpx(struct ImBuf *buf, const char *filepath, int flags)
|
|||||||
return imb_save_dpx_cineon(buf, filepath, 0, flags);
|
return imb_save_dpx_cineon(buf, filepath, 0, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool imb_is_a_dpx(const unsigned char *buf, size_t size)
|
bool imb_is_a_dpx(const uchar *buf, size_t size)
|
||||||
{
|
{
|
||||||
return logImageIsDpx(buf, size);
|
return logImageIsDpx(buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImBuf *imb_load_dpx(const unsigned char *mem,
|
ImBuf *imb_load_dpx(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
|
||||||
size_t size,
|
|
||||||
int flags,
|
|
||||||
char colorspace[IM_MAX_SPACE])
|
|
||||||
{
|
{
|
||||||
if (!imb_is_a_dpx(mem, size)) {
|
if (!imb_is_a_dpx(mem, size)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -121,13 +121,13 @@ static void fillCineonMainHeader(LogImageFile *cineon,
|
|||||||
/* we leave it blank */
|
/* we leave it blank */
|
||||||
}
|
}
|
||||||
|
|
||||||
LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize)
|
LogImageFile *cineonOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize)
|
||||||
{
|
{
|
||||||
CineonMainHeader header;
|
CineonMainHeader header;
|
||||||
LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
|
LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
|
||||||
const char *filepath = (const char *)byteStuff;
|
const char *filepath = (const char *)byteStuff;
|
||||||
int i;
|
int i;
|
||||||
unsigned int dataOffset;
|
uint dataOffset;
|
||||||
|
|
||||||
if (cineon == NULL) {
|
if (cineon == NULL) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
@ -158,8 +158,8 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
|
|||||||
cineon->memBufferSize = 0;
|
cineon->memBufferSize = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cineon->memBuffer = (unsigned char *)byteStuff;
|
cineon->memBuffer = (uchar *)byteStuff;
|
||||||
cineon->memCursor = (unsigned char *)byteStuff;
|
cineon->memCursor = (uchar *)byteStuff;
|
||||||
cineon->memBufferSize = bufferSize;
|
cineon->memBufferSize = bufferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
|
|||||||
else {
|
else {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("Cineon: Bad magic number %lu in \"%s\".\n",
|
printf("Cineon: Bad magic number %lu in \"%s\".\n",
|
||||||
(unsigned long)header.fileHeader.magic_num,
|
(ulong)header.fileHeader.magic_num,
|
||||||
byteStuff);
|
byteStuff);
|
||||||
}
|
}
|
||||||
logImageClose(cineon);
|
logImageClose(cineon);
|
||||||
@ -296,7 +296,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32) {
|
if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32) {
|
||||||
cineon->element[i].refHighData = (unsigned int)cineon->element[i].maxValue;
|
cineon->element[i].refHighData = (uint)cineon->element[i].maxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cineon->element[i].refLowQuantity == CINEON_UNDEFINED_R32 ||
|
if (cineon->element[i].refLowQuantity == CINEON_UNDEFINED_R32 ||
|
||||||
@ -353,7 +353,7 @@ LogImageFile *cineonCreate(
|
|||||||
{
|
{
|
||||||
CineonMainHeader header;
|
CineonMainHeader header;
|
||||||
const char *shortFilename = NULL;
|
const char *shortFilename = NULL;
|
||||||
/* unsigned char pad[6044]; */
|
/* uchar pad[6044]; */
|
||||||
|
|
||||||
LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
|
LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
|
||||||
if (cineon == NULL) {
|
if (cineon == NULL) {
|
||||||
|
@ -38,10 +38,10 @@ typedef struct {
|
|||||||
} CineonFileHeader;
|
} CineonFileHeader;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned char descriptor1;
|
uchar descriptor1;
|
||||||
unsigned char descriptor2;
|
uchar descriptor2;
|
||||||
unsigned char bits_per_sample;
|
uchar bits_per_sample;
|
||||||
unsigned char filler;
|
uchar filler;
|
||||||
unsigned int pixels_per_line;
|
unsigned int pixels_per_line;
|
||||||
unsigned int lines_per_image;
|
unsigned int lines_per_image;
|
||||||
unsigned int ref_low_data;
|
unsigned int ref_low_data;
|
||||||
@ -51,8 +51,8 @@ typedef struct {
|
|||||||
} CineonElementHeader;
|
} CineonElementHeader;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned char orientation;
|
uchar orientation;
|
||||||
unsigned char elements_per_image;
|
uchar elements_per_image;
|
||||||
unsigned short filler;
|
unsigned short filler;
|
||||||
CineonElementHeader element[8];
|
CineonElementHeader element[8];
|
||||||
float white_point_x;
|
float white_point_x;
|
||||||
@ -65,10 +65,10 @@ typedef struct {
|
|||||||
float blue_primary_y;
|
float blue_primary_y;
|
||||||
char label[200];
|
char label[200];
|
||||||
char reserved[28];
|
char reserved[28];
|
||||||
unsigned char interleave;
|
uchar interleave;
|
||||||
unsigned char packing;
|
uchar packing;
|
||||||
unsigned char data_sign;
|
uchar data_sign;
|
||||||
unsigned char sense;
|
uchar sense;
|
||||||
unsigned int line_padding;
|
unsigned int line_padding;
|
||||||
unsigned int element_padding;
|
unsigned int element_padding;
|
||||||
char reserved2[20];
|
char reserved2[20];
|
||||||
@ -90,10 +90,10 @@ typedef struct {
|
|||||||
} CineonOriginationHeader;
|
} CineonOriginationHeader;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned char film_code;
|
uchar film_code;
|
||||||
unsigned char film_type;
|
uchar film_type;
|
||||||
unsigned char edge_code_perforation_offset;
|
uchar edge_code_perforation_offset;
|
||||||
unsigned char filler;
|
uchar filler;
|
||||||
unsigned int prefix;
|
unsigned int prefix;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
char format[32];
|
char format[32];
|
||||||
@ -112,7 +112,7 @@ typedef struct {
|
|||||||
} CineonMainHeader;
|
} CineonMainHeader;
|
||||||
|
|
||||||
void cineonSetVerbose(int);
|
void cineonSetVerbose(int);
|
||||||
LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize);
|
LogImageFile *cineonOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize);
|
||||||
LogImageFile *cineonCreate(
|
LogImageFile *cineonCreate(
|
||||||
const char *filepath, int width, int height, int bitsPerSample, const char *creator);
|
const char *filepath, int width, int height, int bitsPerSample, const char *creator);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ static void fillDpxMainHeader(LogImageFile *dpx,
|
|||||||
header->televisionHeader.integration_times = swap_float(DPX_UNDEFINED_R32, dpx->isMSB);
|
header->televisionHeader.integration_times = swap_float(DPX_UNDEFINED_R32, dpx->isMSB);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize)
|
LogImageFile *dpxOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize)
|
||||||
{
|
{
|
||||||
DpxMainHeader header;
|
DpxMainHeader header;
|
||||||
LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
|
LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
|
||||||
@ -155,8 +155,8 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
|
|||||||
dpx->memBufferSize = 0;
|
dpx->memBufferSize = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dpx->memBuffer = (unsigned char *)byteStuff;
|
dpx->memBuffer = (uchar *)byteStuff;
|
||||||
dpx->memCursor = (unsigned char *)byteStuff;
|
dpx->memCursor = (uchar *)byteStuff;
|
||||||
dpx->memBufferSize = bufferSize;
|
dpx->memBufferSize = bufferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dpx->element[i].refHighData == DPX_UNDEFINED_U32) {
|
if (dpx->element[i].refHighData == DPX_UNDEFINED_U32) {
|
||||||
dpx->element[i].refHighData = (unsigned int)dpx->element[i].maxValue;
|
dpx->element[i].refHighData = (uint)dpx->element[i].maxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_DPX_UNDEFINED_R32(dpx->element[i].refLowQuantity)) {
|
if (IS_DPX_UNDEFINED_R32(dpx->element[i].refLowQuantity)) {
|
||||||
@ -418,7 +418,7 @@ LogImageFile *dpxCreate(const char *filepath,
|
|||||||
{
|
{
|
||||||
DpxMainHeader header;
|
DpxMainHeader header;
|
||||||
const char *shortFilename = NULL;
|
const char *shortFilename = NULL;
|
||||||
unsigned char pad[6044];
|
uchar pad[6044];
|
||||||
|
|
||||||
LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
|
LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
|
||||||
if (dpx == NULL) {
|
if (dpx == NULL) {
|
||||||
|
@ -81,29 +81,29 @@ void logImageSetVerbose(int verbosity)
|
|||||||
* IO stuff
|
* IO stuff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int logImageIsDpx(const void *buffer, const unsigned int size)
|
int logImageIsDpx(const void *buffer, const uint size)
|
||||||
{
|
{
|
||||||
unsigned int magicNum;
|
uint magicNum;
|
||||||
if (size < sizeof(magicNum)) {
|
if (size < sizeof(magicNum)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
magicNum = *(unsigned int *)buffer;
|
magicNum = *(uint *)buffer;
|
||||||
return (magicNum == DPX_FILE_MAGIC || magicNum == swap_uint(DPX_FILE_MAGIC, 1));
|
return (magicNum == DPX_FILE_MAGIC || magicNum == swap_uint(DPX_FILE_MAGIC, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
int logImageIsCineon(const void *buffer, const unsigned int size)
|
int logImageIsCineon(const void *buffer, const uint size)
|
||||||
{
|
{
|
||||||
unsigned int magicNum;
|
uint magicNum;
|
||||||
if (size < sizeof(magicNum)) {
|
if (size < sizeof(magicNum)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
magicNum = *(unsigned int *)buffer;
|
magicNum = *(uint *)buffer;
|
||||||
return (magicNum == CINEON_FILE_MAGIC || magicNum == swap_uint(CINEON_FILE_MAGIC, 1));
|
return (magicNum == CINEON_FILE_MAGIC || magicNum == swap_uint(CINEON_FILE_MAGIC, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
LogImageFile *logImageOpenFromFile(const char *filepath, int cineon)
|
LogImageFile *logImageOpenFromFile(const char *filepath, int cineon)
|
||||||
{
|
{
|
||||||
unsigned int magicNum;
|
uint magicNum;
|
||||||
FILE *f = BLI_fopen(filepath, "rb");
|
FILE *f = BLI_fopen(filepath, "rb");
|
||||||
|
|
||||||
(void)cineon;
|
(void)cineon;
|
||||||
@ -120,16 +120,16 @@ LogImageFile *logImageOpenFromFile(const char *filepath, int cineon)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if (logImageIsDpx(&magicNum, sizeof(magicNum))) {
|
if (logImageIsDpx(&magicNum, sizeof(magicNum))) {
|
||||||
return dpxOpen((const unsigned char *)filepath, 0, 0);
|
return dpxOpen((const uchar *)filepath, 0, 0);
|
||||||
}
|
}
|
||||||
if (logImageIsCineon(&magicNum, sizeof(magicNum))) {
|
if (logImageIsCineon(&magicNum, sizeof(magicNum))) {
|
||||||
return cineonOpen((const unsigned char *)filepath, 0, 0);
|
return cineonOpen((const uchar *)filepath, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size)
|
LogImageFile *logImageOpenFromMemory(const uchar *buffer, uint size)
|
||||||
{
|
{
|
||||||
if (logImageIsDpx(buffer, size)) {
|
if (logImageIsDpx(buffer, size)) {
|
||||||
return dpxOpen(buffer, 1, size);
|
return dpxOpen(buffer, 1, size);
|
||||||
@ -276,9 +276,9 @@ int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
|
|||||||
static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement, float *data)
|
static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement, float *data)
|
||||||
{
|
{
|
||||||
size_t rowLength = getRowLength(logImage->width, logElement);
|
size_t rowLength = getRowLength(logImage->width, logElement);
|
||||||
unsigned char *row;
|
uchar *row;
|
||||||
|
|
||||||
row = (unsigned char *)MEM_mallocN(rowLength, __func__);
|
row = (uchar *)MEM_mallocN(rowLength, __func__);
|
||||||
if (row == NULL) {
|
if (row == NULL) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("DPX/Cineon: Cannot allocate row.\n");
|
printf("DPX/Cineon: Cannot allocate row.\n");
|
||||||
@ -289,7 +289,7 @@ static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement,
|
|||||||
|
|
||||||
for (size_t y = 0; y < logImage->height; y++) {
|
for (size_t y = 0; y < logImage->height; y++) {
|
||||||
for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
|
for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
|
||||||
row[x] = (unsigned char)float_uint(data[y * logImage->width * logImage->depth + x], 255);
|
row[x] = (uchar)float_uint(data[y * logImage->width * logImage->depth + x], 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logimage_fwrite(row, rowLength, 1, logImage) == 0) {
|
if (logimage_fwrite(row, rowLength, 1, logImage) == 0) {
|
||||||
@ -307,10 +307,10 @@ static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement,
|
|||||||
static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement, float *data)
|
static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement, float *data)
|
||||||
{
|
{
|
||||||
size_t rowLength = getRowLength(logImage->width, logElement);
|
size_t rowLength = getRowLength(logImage->width, logElement);
|
||||||
unsigned int pixel, index;
|
uint pixel, index;
|
||||||
unsigned int *row;
|
uint *row;
|
||||||
|
|
||||||
row = (unsigned int *)MEM_mallocN(rowLength, __func__);
|
row = (uint *)MEM_mallocN(rowLength, __func__);
|
||||||
if (row == NULL) {
|
if (row == NULL) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("DPX/Cineon: Cannot allocate row.\n");
|
printf("DPX/Cineon: Cannot allocate row.\n");
|
||||||
@ -324,8 +324,7 @@ static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement,
|
|||||||
pixel = 0;
|
pixel = 0;
|
||||||
|
|
||||||
for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
|
for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
|
||||||
pixel |= (unsigned int)float_uint(data[y * logImage->width * logImage->depth + x], 1023)
|
pixel |= (uint)float_uint(data[y * logImage->width * logImage->depth + x], 1023) << offset;
|
||||||
<< offset;
|
|
||||||
offset -= 10;
|
offset -= 10;
|
||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
row[index] = swap_uint(pixel, logImage->isMSB);
|
row[index] = swap_uint(pixel, logImage->isMSB);
|
||||||
@ -353,9 +352,9 @@ static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement,
|
|||||||
static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement, float *data)
|
static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement, float *data)
|
||||||
{
|
{
|
||||||
size_t rowLength = getRowLength(logImage->width, logElement);
|
size_t rowLength = getRowLength(logImage->width, logElement);
|
||||||
unsigned short *row;
|
ushort *row;
|
||||||
|
|
||||||
row = (unsigned short *)MEM_mallocN(rowLength, __func__);
|
row = (ushort *)MEM_mallocN(rowLength, __func__);
|
||||||
if (row == NULL) {
|
if (row == NULL) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("DPX/Cineon: Cannot allocate row.\n");
|
printf("DPX/Cineon: Cannot allocate row.\n");
|
||||||
@ -366,7 +365,7 @@ static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement,
|
|||||||
for (size_t y = 0; y < logImage->height; y++) {
|
for (size_t y = 0; y < logImage->height; y++) {
|
||||||
for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
|
for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
|
||||||
row[x] = swap_ushort(
|
row[x] = swap_ushort(
|
||||||
((unsigned short)float_uint(data[y * logImage->width * logImage->depth + x], 4095)) << 4,
|
((ushort)float_uint(data[y * logImage->width * logImage->depth + x], 4095)) << 4,
|
||||||
logImage->isMSB);
|
logImage->isMSB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,9 +384,9 @@ static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement,
|
|||||||
static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement, float *data)
|
static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement, float *data)
|
||||||
{
|
{
|
||||||
size_t rowLength = getRowLength(logImage->width, logElement);
|
size_t rowLength = getRowLength(logImage->width, logElement);
|
||||||
unsigned short *row;
|
ushort *row;
|
||||||
|
|
||||||
row = (unsigned short *)MEM_mallocN(rowLength, __func__);
|
row = (ushort *)MEM_mallocN(rowLength, __func__);
|
||||||
if (row == NULL) {
|
if (row == NULL) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("DPX/Cineon: Cannot allocate row.\n");
|
printf("DPX/Cineon: Cannot allocate row.\n");
|
||||||
@ -398,7 +397,7 @@ static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement,
|
|||||||
for (size_t y = 0; y < logImage->height; y++) {
|
for (size_t y = 0; y < logImage->height; y++) {
|
||||||
for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
|
for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
|
||||||
row[x] = swap_ushort(
|
row[x] = swap_ushort(
|
||||||
(unsigned short)float_uint(data[y * logImage->width * logImage->depth + x], 65535),
|
(ushort)float_uint(data[y * logImage->width * logImage->depth + x], 65535),
|
||||||
logImage->isMSB);
|
logImage->isMSB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,11 +424,11 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
|
|||||||
float *elementData[8];
|
float *elementData[8];
|
||||||
float *elementData_ptr[8];
|
float *elementData_ptr[8];
|
||||||
float *mergedData;
|
float *mergedData;
|
||||||
unsigned int sampleIndex;
|
uint sampleIndex;
|
||||||
LogImageElement mergedElement;
|
LogImageElement mergedElement;
|
||||||
|
|
||||||
/* Determine the depth of the picture and if there's a separate alpha element.
|
/* Determine the depth of the picture and if there's a separate alpha element.
|
||||||
* If the element is supported, load it into an unsigned ints array. */
|
* If the element is supported, load it into an uints array. */
|
||||||
memset(&elementData, 0, 8 * sizeof(float *));
|
memset(&elementData, 0, 8 * sizeof(float *));
|
||||||
hasAlpha = 0;
|
hasAlpha = 0;
|
||||||
|
|
||||||
@ -695,7 +694,7 @@ static int logImageElementGetData(LogImageFile *logImage, LogImageElement logEle
|
|||||||
|
|
||||||
static int logImageElementGetData1(LogImageFile *logImage, LogImageElement logElement, float *data)
|
static int logImageElementGetData1(LogImageFile *logImage, LogImageElement logElement, float *data)
|
||||||
{
|
{
|
||||||
unsigned int pixel;
|
uint pixel;
|
||||||
|
|
||||||
/* seek at the right place */
|
/* seek at the right place */
|
||||||
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
|
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
|
||||||
@ -727,7 +726,7 @@ static int logImageElementGetData1(LogImageFile *logImage, LogImageElement logEl
|
|||||||
static int logImageElementGetData8(LogImageFile *logImage, LogImageElement logElement, float *data)
|
static int logImageElementGetData8(LogImageFile *logImage, LogImageElement logElement, float *data)
|
||||||
{
|
{
|
||||||
size_t rowLength = getRowLength(logImage->width, logElement);
|
size_t rowLength = getRowLength(logImage->width, logElement);
|
||||||
unsigned char pixel;
|
uchar pixel;
|
||||||
|
|
||||||
/* extract required pixels */
|
/* extract required pixels */
|
||||||
for (size_t y = 0; y < logImage->height; y++) {
|
for (size_t y = 0; y < logImage->height; y++) {
|
||||||
@ -756,7 +755,7 @@ static int logImageElementGetData10(LogImageFile *logImage,
|
|||||||
LogImageElement logElement,
|
LogImageElement logElement,
|
||||||
float *data)
|
float *data)
|
||||||
{
|
{
|
||||||
unsigned int pixel;
|
uint pixel;
|
||||||
|
|
||||||
/* seek to data */
|
/* seek to data */
|
||||||
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
|
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
|
||||||
@ -829,15 +828,14 @@ static int logImageElementGetData10Packed(LogImageFile *logImage,
|
|||||||
float *data)
|
float *data)
|
||||||
{
|
{
|
||||||
size_t rowLength = getRowLength(logImage->width, logElement);
|
size_t rowLength = getRowLength(logImage->width, logElement);
|
||||||
unsigned int pixel, oldPixel;
|
uint pixel, oldPixel;
|
||||||
|
|
||||||
/* converting bytes to pixels */
|
/* converting bytes to pixels */
|
||||||
for (size_t y = 0; y < logImage->height; y++) {
|
for (size_t y = 0; y < logImage->height; y++) {
|
||||||
/* seek to data */
|
/* seek to data */
|
||||||
if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) {
|
if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("DPX/Cineon: Couldn't seek at %u\n",
|
printf("DPX/Cineon: Couldn't seek at %u\n", (uint)(y * rowLength + logElement.dataOffset));
|
||||||
(unsigned int)(y * rowLength + logElement.dataOffset));
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -884,9 +882,9 @@ static int logImageElementGetData12(LogImageFile *logImage,
|
|||||||
LogImageElement logElement,
|
LogImageElement logElement,
|
||||||
float *data)
|
float *data)
|
||||||
{
|
{
|
||||||
unsigned int sampleIndex;
|
uint sampleIndex;
|
||||||
unsigned int numSamples = logImage->width * logImage->height * logElement.depth;
|
uint numSamples = logImage->width * logImage->height * logElement.depth;
|
||||||
unsigned short pixel;
|
ushort pixel;
|
||||||
|
|
||||||
/* seek to data */
|
/* seek to data */
|
||||||
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
|
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
|
||||||
@ -923,15 +921,14 @@ static int logImageElementGetData12Packed(LogImageFile *logImage,
|
|||||||
float *data)
|
float *data)
|
||||||
{
|
{
|
||||||
size_t rowLength = getRowLength(logImage->width, logElement);
|
size_t rowLength = getRowLength(logImage->width, logElement);
|
||||||
unsigned int pixel, oldPixel;
|
uint pixel, oldPixel;
|
||||||
|
|
||||||
/* converting bytes to pixels */
|
/* converting bytes to pixels */
|
||||||
for (size_t y = 0; y < logImage->height; y++) {
|
for (size_t y = 0; y < logImage->height; y++) {
|
||||||
/* seek to data */
|
/* seek to data */
|
||||||
if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) {
|
if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("DPX/Cineon: Couldn't seek at %u\n",
|
printf("DPX/Cineon: Couldn't seek at %u\n", (uint)(y * rowLength + logElement.dataOffset));
|
||||||
(unsigned int)(y * rowLength + logElement.dataOffset));
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -978,9 +975,9 @@ static int logImageElementGetData16(LogImageFile *logImage,
|
|||||||
LogImageElement logElement,
|
LogImageElement logElement,
|
||||||
float *data)
|
float *data)
|
||||||
{
|
{
|
||||||
unsigned int numSamples = logImage->width * logImage->height * logElement.depth;
|
uint numSamples = logImage->width * logImage->height * logElement.depth;
|
||||||
unsigned int sampleIndex;
|
uint sampleIndex;
|
||||||
unsigned short pixel;
|
ushort pixel;
|
||||||
|
|
||||||
/* seek to data */
|
/* seek to data */
|
||||||
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
|
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
|
||||||
@ -1076,8 +1073,8 @@ static float *getLinToLogLut(LogImageFile *logImage, LogImageElement logElement)
|
|||||||
{
|
{
|
||||||
float *lut;
|
float *lut;
|
||||||
float gain, negativeFilmGamma, offset, step;
|
float gain, negativeFilmGamma, offset, step;
|
||||||
unsigned int lutsize = (unsigned int)(logElement.maxValue + 1);
|
uint lutsize = (uint)(logElement.maxValue + 1);
|
||||||
unsigned int i;
|
uint i;
|
||||||
|
|
||||||
lut = MEM_mallocN(sizeof(float) * lutsize, "getLinToLogLut");
|
lut = MEM_mallocN(sizeof(float) * lutsize, "getLinToLogLut");
|
||||||
|
|
||||||
@ -1104,8 +1101,8 @@ static float *getLogToLinLut(LogImageFile *logImage, LogImageElement logElement)
|
|||||||
float *lut;
|
float *lut;
|
||||||
float breakPoint, gain, kneeGain, kneeOffset, negativeFilmGamma, offset, step, softClip;
|
float breakPoint, gain, kneeGain, kneeOffset, negativeFilmGamma, offset, step, softClip;
|
||||||
/* float filmGamma; unused */
|
/* float filmGamma; unused */
|
||||||
unsigned int lutsize = (unsigned int)(logElement.maxValue + 1);
|
uint lutsize = (uint)(logElement.maxValue + 1);
|
||||||
unsigned int i;
|
uint i;
|
||||||
|
|
||||||
lut = MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut");
|
lut = MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut");
|
||||||
|
|
||||||
@ -1154,8 +1151,8 @@ static float *getLogToLinLut(LogImageFile *logImage, LogImageElement logElement)
|
|||||||
static float *getLinToSrgbLut(LogImageElement logElement)
|
static float *getLinToSrgbLut(LogImageElement logElement)
|
||||||
{
|
{
|
||||||
float col, *lut;
|
float col, *lut;
|
||||||
unsigned int lutsize = (unsigned int)(logElement.maxValue + 1);
|
uint lutsize = (uint)(logElement.maxValue + 1);
|
||||||
unsigned int i;
|
uint i;
|
||||||
|
|
||||||
lut = MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut");
|
lut = MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut");
|
||||||
|
|
||||||
@ -1175,8 +1172,8 @@ static float *getLinToSrgbLut(LogImageElement logElement)
|
|||||||
static float *getSrgbToLinLut(LogImageElement logElement)
|
static float *getSrgbToLinLut(LogImageElement logElement)
|
||||||
{
|
{
|
||||||
float col, *lut;
|
float col, *lut;
|
||||||
unsigned int lutsize = (unsigned int)(logElement.maxValue + 1);
|
uint lutsize = (uint)(logElement.maxValue + 1);
|
||||||
unsigned int i;
|
uint i;
|
||||||
|
|
||||||
lut = MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut");
|
lut = MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut");
|
||||||
|
|
||||||
@ -1199,7 +1196,7 @@ static int convertRGBA_RGB(float *src,
|
|||||||
LogImageElement logElement,
|
LogImageElement logElement,
|
||||||
int elementIsSource)
|
int elementIsSource)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint i;
|
||||||
float *src_ptr = src;
|
float *src_ptr = src;
|
||||||
float *dst_ptr = dst;
|
float *dst_ptr = dst;
|
||||||
|
|
||||||
@ -1254,7 +1251,7 @@ static int convertRGB_RGBA(float *src,
|
|||||||
LogImageElement logElement,
|
LogImageElement logElement,
|
||||||
int elementIsSource)
|
int elementIsSource)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint i;
|
||||||
float *src_ptr = src;
|
float *src_ptr = src;
|
||||||
float *dst_ptr = dst;
|
float *dst_ptr = dst;
|
||||||
|
|
||||||
@ -1309,7 +1306,7 @@ static int convertRGBA_RGBA(float *src,
|
|||||||
LogImageElement logElement,
|
LogImageElement logElement,
|
||||||
int elementIsSource)
|
int elementIsSource)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint i;
|
||||||
float *src_ptr = src;
|
float *src_ptr = src;
|
||||||
float *dst_ptr = dst;
|
float *dst_ptr = dst;
|
||||||
|
|
||||||
@ -1354,7 +1351,7 @@ static int convertABGR_RGBA(float *src,
|
|||||||
LogImageElement logElement,
|
LogImageElement logElement,
|
||||||
int elementIsSource)
|
int elementIsSource)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint i;
|
||||||
float *src_ptr = src;
|
float *src_ptr = src;
|
||||||
float *dst_ptr = dst;
|
float *dst_ptr = dst;
|
||||||
|
|
||||||
@ -1407,7 +1404,7 @@ static int convertCbYCr_RGBA(float *src,
|
|||||||
LogImageFile *logImage,
|
LogImageFile *logImage,
|
||||||
LogImageElement logElement)
|
LogImageElement logElement)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint i;
|
||||||
float conversionMatrix[9], refLowData, y, cb, cr;
|
float conversionMatrix[9], refLowData, y, cb, cr;
|
||||||
float *src_ptr = src;
|
float *src_ptr = src;
|
||||||
float *dst_ptr = dst;
|
float *dst_ptr = dst;
|
||||||
@ -1439,7 +1436,7 @@ static int convertCbYCrA_RGBA(float *src,
|
|||||||
LogImageFile *logImage,
|
LogImageFile *logImage,
|
||||||
LogImageElement logElement)
|
LogImageElement logElement)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint i;
|
||||||
float conversionMatrix[9], refLowData, y, cb, cr, a;
|
float conversionMatrix[9], refLowData, y, cb, cr, a;
|
||||||
float *src_ptr = src;
|
float *src_ptr = src;
|
||||||
float *dst_ptr = dst;
|
float *dst_ptr = dst;
|
||||||
@ -1472,7 +1469,7 @@ static int convertCbYCrY_RGBA(float *src,
|
|||||||
LogImageFile *logImage,
|
LogImageFile *logImage,
|
||||||
LogImageElement logElement)
|
LogImageElement logElement)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint i;
|
||||||
float conversionMatrix[9], refLowData, y1, y2, cb, cr;
|
float conversionMatrix[9], refLowData, y1, y2, cb, cr;
|
||||||
float *src_ptr = src;
|
float *src_ptr = src;
|
||||||
float *dst_ptr = dst;
|
float *dst_ptr = dst;
|
||||||
@ -1524,7 +1521,7 @@ static int convertCbYACrYA_RGBA(float *src,
|
|||||||
LogImageFile *logImage,
|
LogImageFile *logImage,
|
||||||
LogImageElement logElement)
|
LogImageElement logElement)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint i;
|
||||||
float conversionMatrix[9], refLowData, y1, y2, cb, cr, a1, a2;
|
float conversionMatrix[9], refLowData, y1, y2, cb, cr, a1, a2;
|
||||||
float *src_ptr = src;
|
float *src_ptr = src;
|
||||||
float *dst_ptr = dst;
|
float *dst_ptr = dst;
|
||||||
@ -1578,7 +1575,7 @@ static int convertLuminance_RGBA(float *src,
|
|||||||
LogImageFile *logImage,
|
LogImageFile *logImage,
|
||||||
LogImageElement logElement)
|
LogImageElement logElement)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint i;
|
||||||
float conversionMatrix[9], value, refLowData;
|
float conversionMatrix[9], value, refLowData;
|
||||||
float *src_ptr = src;
|
float *src_ptr = src;
|
||||||
float *dst_ptr = dst;
|
float *dst_ptr = dst;
|
||||||
@ -1604,7 +1601,7 @@ static int convertYA_RGBA(float *src,
|
|||||||
LogImageFile *logImage,
|
LogImageFile *logImage,
|
||||||
LogImageElement logElement)
|
LogImageElement logElement)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint i;
|
||||||
float conversionMatrix[9], value, refLowData;
|
float conversionMatrix[9], value, refLowData;
|
||||||
float *src_ptr = src;
|
float *src_ptr = src;
|
||||||
float *dst_ptr = dst;
|
float *dst_ptr = dst;
|
||||||
@ -1629,7 +1626,7 @@ static int convertLogElementToRGBA(
|
|||||||
float *src, float *dst, LogImageFile *logImage, LogImageElement logElement, int dstIsLinearRGB)
|
float *src, float *dst, LogImageFile *logImage, LogImageElement logElement, int dstIsLinearRGB)
|
||||||
{
|
{
|
||||||
int rvalue;
|
int rvalue;
|
||||||
unsigned int i;
|
uint i;
|
||||||
float *src_ptr;
|
float *src_ptr;
|
||||||
float *dst_ptr;
|
float *dst_ptr;
|
||||||
|
|
||||||
@ -1698,7 +1695,7 @@ static int convertLogElementToRGBA(
|
|||||||
static int convertRGBAToLogElement(
|
static int convertRGBAToLogElement(
|
||||||
float *src, float *dst, LogImageFile *logImage, LogImageElement logElement, int srcIsLinearRGB)
|
float *src, float *dst, LogImageFile *logImage, LogImageElement logElement, int srcIsLinearRGB)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint i;
|
||||||
int rvalue;
|
int rvalue;
|
||||||
float *srgbSrc;
|
float *srgbSrc;
|
||||||
float *srgbSrc_ptr;
|
float *srgbSrc_ptr;
|
||||||
|
@ -44,7 +44,7 @@ int logimage_fseek(LogImageFile *logFile, intptr_t offset, int origin)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int logimage_fwrite(void *buffer, size_t size, unsigned int count, LogImageFile *logFile)
|
int logimage_fwrite(void *buffer, size_t size, uint count, LogImageFile *logFile)
|
||||||
{
|
{
|
||||||
if (logFile->file) {
|
if (logFile->file) {
|
||||||
return fwrite(buffer, size, count, logFile->file);
|
return fwrite(buffer, size, count, logFile->file);
|
||||||
@ -54,13 +54,13 @@ int logimage_fwrite(void *buffer, size_t size, unsigned int count, LogImageFile
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *logFile)
|
int logimage_fread(void *buffer, size_t size, uint count, LogImageFile *logFile)
|
||||||
{
|
{
|
||||||
if (logFile->file) {
|
if (logFile->file) {
|
||||||
return fread(buffer, size, count, logFile->file);
|
return fread(buffer, size, count, logFile->file);
|
||||||
}
|
}
|
||||||
/* we're reading from memory */
|
/* we're reading from memory */
|
||||||
unsigned char *buf = (unsigned char *)buffer;
|
uchar *buf = (uchar *)buffer;
|
||||||
uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
|
uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
|
||||||
size_t total_size = size * count;
|
size_t total_size = size * count;
|
||||||
if (pos + total_size > logFile->memBufferSize) {
|
if (pos + total_size > logFile->memBufferSize) {
|
||||||
@ -77,38 +77,38 @@ int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int logimage_read_uchar(unsigned char *x, LogImageFile *logFile)
|
int logimage_read_uchar(uchar *x, LogImageFile *logFile)
|
||||||
{
|
{
|
||||||
uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
|
uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
|
||||||
if (pos + sizeof(unsigned char) > logFile->memBufferSize) {
|
if (pos + sizeof(uchar) > logFile->memBufferSize) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*x = *(unsigned char *)logFile->memCursor;
|
*x = *(uchar *)logFile->memCursor;
|
||||||
logFile->memCursor += sizeof(unsigned char);
|
logFile->memCursor += sizeof(uchar);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int logimage_read_ushort(unsigned short *x, LogImageFile *logFile)
|
int logimage_read_ushort(ushort *x, LogImageFile *logFile)
|
||||||
{
|
{
|
||||||
uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
|
uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
|
||||||
if (pos + sizeof(unsigned short) > logFile->memBufferSize) {
|
if (pos + sizeof(ushort) > logFile->memBufferSize) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*x = *(unsigned short *)logFile->memCursor;
|
*x = *(ushort *)logFile->memCursor;
|
||||||
logFile->memCursor += sizeof(unsigned short);
|
logFile->memCursor += sizeof(ushort);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int logimage_read_uint(unsigned int *x, LogImageFile *logFile)
|
int logimage_read_uint(uint *x, LogImageFile *logFile)
|
||||||
{
|
{
|
||||||
uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
|
uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
|
||||||
if (pos + sizeof(unsigned int) > logFile->memBufferSize) {
|
if (pos + sizeof(uint) > logFile->memBufferSize) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*x = *(unsigned int *)logFile->memCursor;
|
*x = *(uint *)logFile->memCursor;
|
||||||
logFile->memCursor += sizeof(unsigned int);
|
logFile->memCursor += sizeof(uint);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -235,11 +235,11 @@ static ColormanageCacheData *colormanage_cachedata_get(const ImBuf *ibuf)
|
|||||||
return ibuf->colormanage_cache->data;
|
return ibuf->colormanage_cache->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int colormanage_hashhash(const void *key_v)
|
static uint colormanage_hashhash(const void *key_v)
|
||||||
{
|
{
|
||||||
const ColormanageCacheKey *key = key_v;
|
const ColormanageCacheKey *key = key_v;
|
||||||
|
|
||||||
unsigned int rval = (key->display << 16) | (key->view % 0xffff);
|
uint rval = (key->display << 16) | (key->view % 0xffff);
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
@ -336,8 +336,7 @@ static ImBuf *colormanage_cache_get_ibuf(ImBuf *ibuf,
|
|||||||
return cache_ibuf;
|
return cache_ibuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char *colormanage_cache_get(
|
static uchar *colormanage_cache_get(ImBuf *ibuf,
|
||||||
ImBuf *ibuf,
|
|
||||||
const ColormanageCacheViewSettings *view_settings,
|
const ColormanageCacheViewSettings *view_settings,
|
||||||
const ColormanageCacheDisplaySettings *display_settings,
|
const ColormanageCacheDisplaySettings *display_settings,
|
||||||
void **cache_handle)
|
void **cache_handle)
|
||||||
@ -383,7 +382,7 @@ static unsigned char *colormanage_cache_get(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (unsigned char *)cache_ibuf->rect;
|
return (uchar *)cache_ibuf->rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -392,7 +391,7 @@ static unsigned char *colormanage_cache_get(
|
|||||||
static void colormanage_cache_put(ImBuf *ibuf,
|
static void colormanage_cache_put(ImBuf *ibuf,
|
||||||
const ColormanageCacheViewSettings *view_settings,
|
const ColormanageCacheViewSettings *view_settings,
|
||||||
const ColormanageCacheDisplaySettings *display_settings,
|
const ColormanageCacheDisplaySettings *display_settings,
|
||||||
unsigned char *display_buffer,
|
uchar *display_buffer,
|
||||||
void **cache_handle)
|
void **cache_handle)
|
||||||
{
|
{
|
||||||
ColormanageCacheKey key;
|
ColormanageCacheKey key;
|
||||||
@ -410,7 +409,7 @@ static void colormanage_cache_put(ImBuf *ibuf,
|
|||||||
|
|
||||||
/* buffer itself */
|
/* buffer itself */
|
||||||
cache_ibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, 0);
|
cache_ibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, 0);
|
||||||
cache_ibuf->rect = (unsigned int *)display_buffer;
|
cache_ibuf->rect = (uint *)display_buffer;
|
||||||
|
|
||||||
cache_ibuf->mall |= IB_rect;
|
cache_ibuf->mall |= IB_rect;
|
||||||
cache_ibuf->flags |= IB_rect;
|
cache_ibuf->flags |= IB_rect;
|
||||||
@ -1441,10 +1440,10 @@ typedef struct DisplayBufferThread {
|
|||||||
ColormanageProcessor *cm_processor;
|
ColormanageProcessor *cm_processor;
|
||||||
|
|
||||||
const float *buffer;
|
const float *buffer;
|
||||||
unsigned char *byte_buffer;
|
uchar *byte_buffer;
|
||||||
|
|
||||||
float *display_buffer;
|
float *display_buffer;
|
||||||
unsigned char *display_buffer_byte;
|
uchar *display_buffer_byte;
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int start_line;
|
int start_line;
|
||||||
@ -1463,10 +1462,10 @@ typedef struct DisplayBufferInitData {
|
|||||||
ImBuf *ibuf;
|
ImBuf *ibuf;
|
||||||
ColormanageProcessor *cm_processor;
|
ColormanageProcessor *cm_processor;
|
||||||
const float *buffer;
|
const float *buffer;
|
||||||
unsigned char *byte_buffer;
|
uchar *byte_buffer;
|
||||||
|
|
||||||
float *display_buffer;
|
float *display_buffer;
|
||||||
unsigned char *display_buffer_byte;
|
uchar *display_buffer_byte;
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
|
|
||||||
@ -1539,13 +1538,13 @@ static void display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle,
|
|||||||
bool predivide = handle->predivide;
|
bool predivide = handle->predivide;
|
||||||
|
|
||||||
if (!handle->buffer) {
|
if (!handle->buffer) {
|
||||||
unsigned char *byte_buffer = handle->byte_buffer;
|
uchar *byte_buffer = handle->byte_buffer;
|
||||||
|
|
||||||
const char *from_colorspace = handle->byte_colorspace;
|
const char *from_colorspace = handle->byte_colorspace;
|
||||||
const char *to_colorspace = global_role_scene_linear;
|
const char *to_colorspace = global_role_scene_linear;
|
||||||
|
|
||||||
float *fp;
|
float *fp;
|
||||||
unsigned char *cp;
|
uchar *cp;
|
||||||
const size_t i_last = ((size_t)width) * height;
|
const size_t i_last = ((size_t)width) * height;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -1608,7 +1607,7 @@ static void *do_display_buffer_apply_thread(void *handle_v)
|
|||||||
DisplayBufferThread *handle = (DisplayBufferThread *)handle_v;
|
DisplayBufferThread *handle = (DisplayBufferThread *)handle_v;
|
||||||
ColormanageProcessor *cm_processor = handle->cm_processor;
|
ColormanageProcessor *cm_processor = handle->cm_processor;
|
||||||
float *display_buffer = handle->display_buffer;
|
float *display_buffer = handle->display_buffer;
|
||||||
unsigned char *display_buffer_byte = handle->display_buffer_byte;
|
uchar *display_buffer_byte = handle->display_buffer_byte;
|
||||||
int channels = handle->channels;
|
int channels = handle->channels;
|
||||||
int width = handle->width;
|
int width = handle->width;
|
||||||
int height = handle->tot_line;
|
int height = handle->tot_line;
|
||||||
@ -1698,9 +1697,9 @@ static void *do_display_buffer_apply_thread(void *handle_v)
|
|||||||
|
|
||||||
static void display_buffer_apply_threaded(ImBuf *ibuf,
|
static void display_buffer_apply_threaded(ImBuf *ibuf,
|
||||||
const float *buffer,
|
const float *buffer,
|
||||||
unsigned char *byte_buffer,
|
uchar *byte_buffer,
|
||||||
float *display_buffer,
|
float *display_buffer,
|
||||||
unsigned char *display_buffer_byte,
|
uchar *display_buffer_byte,
|
||||||
ColormanageProcessor *cm_processor)
|
ColormanageProcessor *cm_processor)
|
||||||
{
|
{
|
||||||
DisplayBufferInitData init_data;
|
DisplayBufferInitData init_data;
|
||||||
@ -1761,7 +1760,7 @@ static bool is_ibuf_rect_in_display_space(ImBuf *ibuf,
|
|||||||
static void colormanage_display_buffer_process_ex(
|
static void colormanage_display_buffer_process_ex(
|
||||||
ImBuf *ibuf,
|
ImBuf *ibuf,
|
||||||
float *display_buffer,
|
float *display_buffer,
|
||||||
unsigned char *display_buffer_byte,
|
uchar *display_buffer_byte,
|
||||||
const ColorManagedViewSettings *view_settings,
|
const ColorManagedViewSettings *view_settings,
|
||||||
const ColorManagedDisplaySettings *display_settings)
|
const ColorManagedDisplaySettings *display_settings)
|
||||||
{
|
{
|
||||||
@ -1783,7 +1782,7 @@ static void colormanage_display_buffer_process_ex(
|
|||||||
|
|
||||||
display_buffer_apply_threaded(ibuf,
|
display_buffer_apply_threaded(ibuf,
|
||||||
ibuf->rect_float,
|
ibuf->rect_float,
|
||||||
(unsigned char *)ibuf->rect,
|
(uchar *)ibuf->rect,
|
||||||
display_buffer,
|
display_buffer,
|
||||||
display_buffer_byte,
|
display_buffer_byte,
|
||||||
cm_processor);
|
cm_processor);
|
||||||
@ -1794,7 +1793,7 @@ static void colormanage_display_buffer_process_ex(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void colormanage_display_buffer_process(ImBuf *ibuf,
|
static void colormanage_display_buffer_process(ImBuf *ibuf,
|
||||||
unsigned char *display_buffer,
|
uchar *display_buffer,
|
||||||
const ColorManagedViewSettings *view_settings,
|
const ColorManagedViewSettings *view_settings,
|
||||||
const ColorManagedDisplaySettings *display_settings)
|
const ColorManagedDisplaySettings *display_settings)
|
||||||
{
|
{
|
||||||
@ -1810,7 +1809,7 @@ static void colormanage_display_buffer_process(ImBuf *ibuf,
|
|||||||
|
|
||||||
typedef struct ProcessorTransformThread {
|
typedef struct ProcessorTransformThread {
|
||||||
ColormanageProcessor *cm_processor;
|
ColormanageProcessor *cm_processor;
|
||||||
unsigned char *byte_buffer;
|
uchar *byte_buffer;
|
||||||
float *float_buffer;
|
float *float_buffer;
|
||||||
int width;
|
int width;
|
||||||
int start_line;
|
int start_line;
|
||||||
@ -1822,7 +1821,7 @@ typedef struct ProcessorTransformThread {
|
|||||||
|
|
||||||
typedef struct ProcessorTransformInit {
|
typedef struct ProcessorTransformInit {
|
||||||
ColormanageProcessor *cm_processor;
|
ColormanageProcessor *cm_processor;
|
||||||
unsigned char *byte_buffer;
|
uchar *byte_buffer;
|
||||||
float *float_buffer;
|
float *float_buffer;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
@ -1871,7 +1870,7 @@ static void processor_transform_init_handle(void *handle_v,
|
|||||||
static void *do_processor_transform_thread(void *handle_v)
|
static void *do_processor_transform_thread(void *handle_v)
|
||||||
{
|
{
|
||||||
ProcessorTransformThread *handle = (ProcessorTransformThread *)handle_v;
|
ProcessorTransformThread *handle = (ProcessorTransformThread *)handle_v;
|
||||||
unsigned char *byte_buffer = handle->byte_buffer;
|
uchar *byte_buffer = handle->byte_buffer;
|
||||||
float *float_buffer = handle->float_buffer;
|
float *float_buffer = handle->float_buffer;
|
||||||
const int channels = handle->channels;
|
const int channels = handle->channels;
|
||||||
const int width = handle->width;
|
const int width = handle->width;
|
||||||
@ -1907,7 +1906,7 @@ static void *do_processor_transform_thread(void *handle_v)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void processor_transform_apply_threaded(unsigned char *byte_buffer,
|
static void processor_transform_apply_threaded(uchar *byte_buffer,
|
||||||
float *float_buffer,
|
float *float_buffer,
|
||||||
const int width,
|
const int width,
|
||||||
const int height,
|
const int height,
|
||||||
@ -1942,7 +1941,7 @@ static void processor_transform_apply_threaded(unsigned char *byte_buffer,
|
|||||||
|
|
||||||
/* Convert the whole buffer from specified by name color space to another -
|
/* Convert the whole buffer from specified by name color space to another -
|
||||||
* internal implementation. */
|
* internal implementation. */
|
||||||
static void colormanagement_transform_ex(unsigned char *byte_buffer,
|
static void colormanagement_transform_ex(uchar *byte_buffer,
|
||||||
float *float_buffer,
|
float *float_buffer,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
@ -2008,7 +2007,7 @@ void IMB_colormanagement_transform_threaded(float *buffer,
|
|||||||
NULL, buffer, width, height, channels, from_colorspace, to_colorspace, predivide, true);
|
NULL, buffer, width, height, channels, from_colorspace, to_colorspace, predivide, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMB_colormanagement_transform_byte(unsigned char *buffer,
|
void IMB_colormanagement_transform_byte(uchar *buffer,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
int channels,
|
int channels,
|
||||||
@ -2018,7 +2017,7 @@ void IMB_colormanagement_transform_byte(unsigned char *buffer,
|
|||||||
colormanagement_transform_ex(
|
colormanagement_transform_ex(
|
||||||
buffer, NULL, width, height, channels, from_colorspace, to_colorspace, false, false);
|
buffer, NULL, width, height, channels, from_colorspace, to_colorspace, false, false);
|
||||||
}
|
}
|
||||||
void IMB_colormanagement_transform_byte_threaded(unsigned char *buffer,
|
void IMB_colormanagement_transform_byte_threaded(uchar *buffer,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
int channels,
|
int channels,
|
||||||
@ -2030,7 +2029,7 @@ void IMB_colormanagement_transform_byte_threaded(unsigned char *buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IMB_colormanagement_transform_from_byte(float *float_buffer,
|
void IMB_colormanagement_transform_from_byte(float *float_buffer,
|
||||||
unsigned char *byte_buffer,
|
uchar *byte_buffer,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
int channels,
|
int channels,
|
||||||
@ -2050,7 +2049,7 @@ void IMB_colormanagement_transform_from_byte(float *float_buffer,
|
|||||||
float_buffer, width, height, channels, from_colorspace, to_colorspace, true);
|
float_buffer, width, height, channels, from_colorspace, to_colorspace, true);
|
||||||
}
|
}
|
||||||
void IMB_colormanagement_transform_from_byte_threaded(float *float_buffer,
|
void IMB_colormanagement_transform_from_byte_threaded(float *float_buffer,
|
||||||
unsigned char *byte_buffer,
|
uchar *byte_buffer,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
int channels,
|
int channels,
|
||||||
@ -2205,7 +2204,7 @@ void IMB_colormanagement_colorspace_to_scene_linear(float *buffer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMB_colormanagement_imbuf_to_byte_texture(unsigned char *out_buffer,
|
void IMB_colormanagement_imbuf_to_byte_texture(uchar *out_buffer,
|
||||||
const int offset_x,
|
const int offset_x,
|
||||||
const int offset_y,
|
const int offset_y,
|
||||||
const int width,
|
const int width,
|
||||||
@ -2220,14 +2219,14 @@ void IMB_colormanagement_imbuf_to_byte_texture(unsigned char *out_buffer,
|
|||||||
IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace) ||
|
IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace) ||
|
||||||
IMB_colormanagement_space_is_data(ibuf->rect_colorspace));
|
IMB_colormanagement_space_is_data(ibuf->rect_colorspace));
|
||||||
|
|
||||||
const unsigned char *in_buffer = (unsigned char *)ibuf->rect;
|
const uchar *in_buffer = (uchar *)ibuf->rect;
|
||||||
const bool use_premultiply = IMB_alpha_affects_rgb(ibuf) && store_premultiplied;
|
const bool use_premultiply = IMB_alpha_affects_rgb(ibuf) && store_premultiplied;
|
||||||
|
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
const size_t in_offset = (offset_y + y) * ibuf->x + offset_x;
|
const size_t in_offset = (offset_y + y) * ibuf->x + offset_x;
|
||||||
const size_t out_offset = y * width;
|
const size_t out_offset = y * width;
|
||||||
const unsigned char *in = in_buffer + in_offset * 4;
|
const uchar *in = in_buffer + in_offset * 4;
|
||||||
unsigned char *out = out_buffer + out_offset * 4;
|
uchar *out = out_buffer + out_offset * 4;
|
||||||
|
|
||||||
if (use_premultiply) {
|
if (use_premultiply) {
|
||||||
/* Premultiply only. */
|
/* Premultiply only. */
|
||||||
@ -2305,7 +2304,7 @@ void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Byte source buffer. */
|
/* Byte source buffer. */
|
||||||
const unsigned char *in_buffer = (unsigned char *)ibuf->rect;
|
const uchar *in_buffer = (uchar *)ibuf->rect;
|
||||||
const bool use_premultiply = IMB_alpha_affects_rgb(ibuf) && store_premultiplied;
|
const bool use_premultiply = IMB_alpha_affects_rgb(ibuf) && store_premultiplied;
|
||||||
|
|
||||||
/* TODO(brecht): make this multi-threaded, or at least process in batches. */
|
/* TODO(brecht): make this multi-threaded, or at least process in batches. */
|
||||||
@ -2317,7 +2316,7 @@ void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer,
|
|||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
const size_t in_offset = (offset_y + y) * ibuf->x + offset_x;
|
const size_t in_offset = (offset_y + y) * ibuf->x + offset_x;
|
||||||
const size_t out_offset = y * width;
|
const size_t out_offset = y * width;
|
||||||
const unsigned char *in = in_buffer + in_offset * 4;
|
const uchar *in = in_buffer + in_offset * 4;
|
||||||
float *out = out_buffer + out_offset * 4;
|
float *out = out_buffer + out_offset * 4;
|
||||||
|
|
||||||
/* Convert to scene linear, to sRGB and premultiply. */
|
/* Convert to scene linear, to sRGB and premultiply. */
|
||||||
@ -2458,7 +2457,7 @@ static void colormanagement_imbuf_make_display_space(
|
|||||||
}
|
}
|
||||||
|
|
||||||
colormanage_display_buffer_process_ex(
|
colormanage_display_buffer_process_ex(
|
||||||
ibuf, ibuf->rect_float, (unsigned char *)ibuf->rect, view_settings, display_settings);
|
ibuf, ibuf->rect_float, (uchar *)ibuf->rect, view_settings, display_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMB_colormanagement_imbuf_make_display_space(
|
void IMB_colormanagement_imbuf_make_display_space(
|
||||||
@ -2545,10 +2544,8 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (colormanaged_ibuf->rect) {
|
if (colormanaged_ibuf->rect) {
|
||||||
IMB_alpha_under_color_byte((unsigned char *)colormanaged_ibuf->rect,
|
IMB_alpha_under_color_byte(
|
||||||
colormanaged_ibuf->x,
|
(uchar *)colormanaged_ibuf->rect, colormanaged_ibuf->x, colormanaged_ibuf->y, color);
|
||||||
colormanaged_ibuf->y,
|
|
||||||
color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2603,7 +2600,7 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
|
|||||||
|
|
||||||
if (colormanaged_ibuf->rect) {
|
if (colormanaged_ibuf->rect) {
|
||||||
/* Byte to byte. */
|
/* Byte to byte. */
|
||||||
IMB_colormanagement_transform_byte_threaded((unsigned char *)colormanaged_ibuf->rect,
|
IMB_colormanagement_transform_byte_threaded((uchar *)colormanaged_ibuf->rect,
|
||||||
colormanaged_ibuf->x,
|
colormanaged_ibuf->x,
|
||||||
colormanaged_ibuf->y,
|
colormanaged_ibuf->y,
|
||||||
colormanaged_ibuf->channels,
|
colormanaged_ibuf->channels,
|
||||||
@ -2650,12 +2647,12 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf,
|
|||||||
/** \name Public Display Buffers Interfaces
|
/** \name Public Display Buffers Interfaces
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf,
|
uchar *IMB_display_buffer_acquire(ImBuf *ibuf,
|
||||||
const ColorManagedViewSettings *view_settings,
|
const ColorManagedViewSettings *view_settings,
|
||||||
const ColorManagedDisplaySettings *display_settings,
|
const ColorManagedDisplaySettings *display_settings,
|
||||||
void **cache_handle)
|
void **cache_handle)
|
||||||
{
|
{
|
||||||
unsigned char *display_buffer;
|
uchar *display_buffer;
|
||||||
size_t buffer_size;
|
size_t buffer_size;
|
||||||
ColormanageCacheViewSettings cache_view_settings;
|
ColormanageCacheViewSettings cache_view_settings;
|
||||||
ColormanageCacheDisplaySettings cache_display_settings;
|
ColormanageCacheDisplaySettings cache_display_settings;
|
||||||
@ -2683,7 +2680,7 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf,
|
|||||||
*/
|
*/
|
||||||
if (ibuf->rect_float == NULL && ibuf->rect_colorspace && ibuf->channels == 4) {
|
if (ibuf->rect_float == NULL && ibuf->rect_colorspace && ibuf->channels == 4) {
|
||||||
if (is_ibuf_rect_in_display_space(ibuf, applied_view_settings, display_settings)) {
|
if (is_ibuf_rect_in_display_space(ibuf, applied_view_settings, display_settings)) {
|
||||||
return (unsigned char *)ibuf->rect;
|
return (uchar *)ibuf->rect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2694,7 +2691,7 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf,
|
|||||||
if ((ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) == 0) {
|
if ((ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) == 0) {
|
||||||
IMB_partial_display_buffer_update_threaded(ibuf,
|
IMB_partial_display_buffer_update_threaded(ibuf,
|
||||||
ibuf->rect_float,
|
ibuf->rect_float,
|
||||||
(unsigned char *)ibuf->rect,
|
(uchar *)ibuf->rect,
|
||||||
ibuf->x,
|
ibuf->x,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@ -2713,14 +2710,14 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf,
|
|||||||
|
|
||||||
/* ensure color management bit fields exists */
|
/* ensure color management bit fields exists */
|
||||||
if (!ibuf->display_buffer_flags) {
|
if (!ibuf->display_buffer_flags) {
|
||||||
ibuf->display_buffer_flags = MEM_callocN(sizeof(unsigned int) * global_tot_display,
|
ibuf->display_buffer_flags = MEM_callocN(sizeof(uint) * global_tot_display,
|
||||||
"imbuf display_buffer_flags");
|
"imbuf display_buffer_flags");
|
||||||
}
|
}
|
||||||
else if (ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) {
|
else if (ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) {
|
||||||
/* all display buffers were marked as invalid from other areas,
|
/* all display buffers were marked as invalid from other areas,
|
||||||
* now propagate this flag to internal color management routines
|
* now propagate this flag to internal color management routines
|
||||||
*/
|
*/
|
||||||
memset(ibuf->display_buffer_flags, 0, global_tot_display * sizeof(unsigned int));
|
memset(ibuf->display_buffer_flags, 0, global_tot_display * sizeof(uint));
|
||||||
|
|
||||||
ibuf->userflags &= ~IB_DISPLAY_BUFFER_INVALID;
|
ibuf->userflags &= ~IB_DISPLAY_BUFFER_INVALID;
|
||||||
}
|
}
|
||||||
@ -2747,7 +2744,7 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf,
|
|||||||
return display_buffer;
|
return display_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, void **cache_handle)
|
uchar *IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, void **cache_handle)
|
||||||
{
|
{
|
||||||
ColorManagedViewSettings *view_settings;
|
ColorManagedViewSettings *view_settings;
|
||||||
ColorManagedDisplaySettings *display_settings;
|
ColorManagedDisplaySettings *display_settings;
|
||||||
@ -2757,7 +2754,7 @@ unsigned char *IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, vo
|
|||||||
return IMB_display_buffer_acquire(ibuf, view_settings, display_settings, cache_handle);
|
return IMB_display_buffer_acquire(ibuf, view_settings, display_settings, cache_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMB_display_buffer_transform_apply(unsigned char *display_buffer,
|
void IMB_display_buffer_transform_apply(uchar *display_buffer,
|
||||||
float *linear_buffer,
|
float *linear_buffer,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
@ -3396,9 +3393,9 @@ void IMB_colormanagement_colorspace_items_add(EnumPropertyItem **items, int *tot
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static void partial_buffer_update_rect(ImBuf *ibuf,
|
static void partial_buffer_update_rect(ImBuf *ibuf,
|
||||||
unsigned char *display_buffer,
|
uchar *display_buffer,
|
||||||
const float *linear_buffer,
|
const float *linear_buffer,
|
||||||
const unsigned char *byte_buffer,
|
const uchar *byte_buffer,
|
||||||
int display_stride,
|
int display_stride,
|
||||||
int linear_stride,
|
int linear_stride,
|
||||||
int linear_offset_x,
|
int linear_offset_x,
|
||||||
@ -3547,9 +3544,9 @@ static void partial_buffer_update_rect(ImBuf *ibuf,
|
|||||||
|
|
||||||
typedef struct PartialThreadData {
|
typedef struct PartialThreadData {
|
||||||
ImBuf *ibuf;
|
ImBuf *ibuf;
|
||||||
unsigned char *display_buffer;
|
uchar *display_buffer;
|
||||||
const float *linear_buffer;
|
const float *linear_buffer;
|
||||||
const unsigned char *byte_buffer;
|
const uchar *byte_buffer;
|
||||||
int display_stride;
|
int display_stride;
|
||||||
int linear_stride;
|
int linear_stride;
|
||||||
int linear_offset_x, linear_offset_y;
|
int linear_offset_x, linear_offset_y;
|
||||||
@ -3580,7 +3577,7 @@ static void partial_buffer_update_rect_thread_do(void *data_v, int scanline)
|
|||||||
static void imb_partial_display_buffer_update_ex(
|
static void imb_partial_display_buffer_update_ex(
|
||||||
ImBuf *ibuf,
|
ImBuf *ibuf,
|
||||||
const float *linear_buffer,
|
const float *linear_buffer,
|
||||||
const unsigned char *byte_buffer,
|
const uchar *byte_buffer,
|
||||||
int stride,
|
int stride,
|
||||||
int offset_x,
|
int offset_x,
|
||||||
int offset_y,
|
int offset_y,
|
||||||
@ -3595,7 +3592,7 @@ static void imb_partial_display_buffer_update_ex(
|
|||||||
ColormanageCacheViewSettings cache_view_settings;
|
ColormanageCacheViewSettings cache_view_settings;
|
||||||
ColormanageCacheDisplaySettings cache_display_settings;
|
ColormanageCacheDisplaySettings cache_display_settings;
|
||||||
void *cache_handle = NULL;
|
void *cache_handle = NULL;
|
||||||
unsigned char *display_buffer = NULL;
|
uchar *display_buffer = NULL;
|
||||||
int buffer_width = ibuf->x;
|
int buffer_width = ibuf->x;
|
||||||
|
|
||||||
if (ibuf->display_buffer_flags) {
|
if (ibuf->display_buffer_flags) {
|
||||||
@ -3621,7 +3618,7 @@ static void imb_partial_display_buffer_update_ex(
|
|||||||
buffer_width = ibuf->x;
|
buffer_width = ibuf->x;
|
||||||
|
|
||||||
/* Mark all other buffers as invalid. */
|
/* Mark all other buffers as invalid. */
|
||||||
memset(ibuf->display_buffer_flags, 0, global_tot_display * sizeof(unsigned int));
|
memset(ibuf->display_buffer_flags, 0, global_tot_display * sizeof(uint));
|
||||||
ibuf->display_buffer_flags[display_index] |= view_flag;
|
ibuf->display_buffer_flags[display_index] |= view_flag;
|
||||||
|
|
||||||
BLI_thread_unlock(LOCK_COLORMANAGE);
|
BLI_thread_unlock(LOCK_COLORMANAGE);
|
||||||
@ -3689,7 +3686,7 @@ static void imb_partial_display_buffer_update_ex(
|
|||||||
|
|
||||||
void IMB_partial_display_buffer_update(ImBuf *ibuf,
|
void IMB_partial_display_buffer_update(ImBuf *ibuf,
|
||||||
const float *linear_buffer,
|
const float *linear_buffer,
|
||||||
const unsigned char *byte_buffer,
|
const uchar *byte_buffer,
|
||||||
int stride,
|
int stride,
|
||||||
int offset_x,
|
int offset_x,
|
||||||
int offset_y,
|
int offset_y,
|
||||||
@ -3718,7 +3715,7 @@ void IMB_partial_display_buffer_update(ImBuf *ibuf,
|
|||||||
void IMB_partial_display_buffer_update_threaded(
|
void IMB_partial_display_buffer_update_threaded(
|
||||||
struct ImBuf *ibuf,
|
struct ImBuf *ibuf,
|
||||||
const float *linear_buffer,
|
const float *linear_buffer,
|
||||||
const unsigned char *byte_buffer,
|
const uchar *byte_buffer,
|
||||||
int stride,
|
int stride,
|
||||||
int offset_x,
|
int offset_x,
|
||||||
int offset_y,
|
int offset_y,
|
||||||
@ -3925,7 +3922,7 @@ void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IMB_colormanagement_processor_apply_byte(
|
void IMB_colormanagement_processor_apply_byte(
|
||||||
ColormanageProcessor *cm_processor, unsigned char *buffer, int width, int height, int channels)
|
ColormanageProcessor *cm_processor, uchar *buffer, int width, int height, int channels)
|
||||||
{
|
{
|
||||||
/* TODO(sergey): Would be nice to support arbitrary channels configurations,
|
/* TODO(sergey): Would be nice to support arbitrary channels configurations,
|
||||||
* but for now it's not so important.
|
* but for now it's not so important.
|
||||||
|
@ -21,7 +21,7 @@ float IMB_colormanagement_get_luminance(const float rgb[3])
|
|||||||
return dot_v3v3(imbuf_luma_coefficients, rgb);
|
return dot_v3v3(imbuf_luma_coefficients, rgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char IMB_colormanagement_get_luminance_byte(const unsigned char rgb[3])
|
uchar IMB_colormanagement_get_luminance_byte(const uchar rgb[3])
|
||||||
{
|
{
|
||||||
float rgbf[3];
|
float rgbf[3];
|
||||||
float val;
|
float val;
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
* OTHER DEALINGS IN THE SOFTWARE. */
|
* OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
|
||||||
|
#include <BLI_sys_types.h> /* For `uint`. */
|
||||||
|
|
||||||
#include <BlockDXT.h>
|
#include <BlockDXT.h>
|
||||||
#include <ColorBlock.h>
|
#include <ColorBlock.h>
|
||||||
#include <Common.h>
|
#include <Common.h>
|
||||||
@ -576,7 +578,7 @@ void mem_read(Stream &mem, BlockDXT1 &block)
|
|||||||
|
|
||||||
void mem_read(Stream &mem, AlphaBlockDXT3 &block)
|
void mem_read(Stream &mem, AlphaBlockDXT3 &block)
|
||||||
{
|
{
|
||||||
for (unsigned short &alpha : block.row) {
|
for (ushort &alpha : block.row) {
|
||||||
mem_read(mem, alpha);
|
mem_read(mem, alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -867,7 +867,7 @@ uint DDSHeader::d3d9Format() const
|
|||||||
return findD3D9Format(pf.bitcount, pf.rmask, pf.gmask, pf.bmask, pf.amask);
|
return findD3D9Format(pf.bitcount, pf.rmask, pf.gmask, pf.bmask, pf.amask);
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectDrawSurface::DirectDrawSurface(unsigned char *mem, uint size) : stream(mem, size), header()
|
DirectDrawSurface::DirectDrawSurface(uchar *mem, uint size) : stream(mem, size), header()
|
||||||
{
|
{
|
||||||
mem_read(stream, header);
|
mem_read(stream, header);
|
||||||
|
|
||||||
@ -1112,7 +1112,7 @@ void *DirectDrawSurface::readData(uint &rsize)
|
|||||||
uint size = stream.size - header_size;
|
uint size = stream.size - header_size;
|
||||||
rsize = size;
|
rsize = size;
|
||||||
|
|
||||||
unsigned char *data = (unsigned char *)malloc(sizeof(*data) * size);
|
uchar *data = (uchar *)malloc(sizeof(*data) * size);
|
||||||
|
|
||||||
stream.seek(header_size);
|
stream.seek(header_size);
|
||||||
mem_read(stream, data, size);
|
mem_read(stream, data, size);
|
||||||
@ -1158,7 +1158,7 @@ void DirectDrawSurface::readLinearImage(Image *img)
|
|||||||
for (uint y = 0; y < h; y++) {
|
for (uint y = 0; y < h; y++) {
|
||||||
for (uint x = 0; x < w; x++) {
|
for (uint x = 0; x < w; x++) {
|
||||||
uint c = 0;
|
uint c = 0;
|
||||||
mem_read(stream, (unsigned char *)(&c), byteCount);
|
mem_read(stream, (uchar *)(&c), byteCount);
|
||||||
|
|
||||||
Color32 pixel(0, 0, 0, 0xFF);
|
Color32 pixel(0, 0, 0, 0xFF);
|
||||||
pixel.r = PixelFormat::convert((c & header.pf.rmask) >> rshift, rsize, 8);
|
pixel.r = PixelFormat::convert((c & header.pf.rmask) >> rshift, rsize, 8);
|
||||||
|
@ -104,19 +104,19 @@ static void FlipDXT5BlockFull(uint8_t *block)
|
|||||||
* bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * (bits_3 +
|
* bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * (bits_3 +
|
||||||
* 256 * (bits_4 + 256 * bits_5))))
|
* 256 * (bits_4 + 256 * bits_5))))
|
||||||
*
|
*
|
||||||
* bits is a 48-bit unsigned integer, from which a three-bit control code
|
* bits is a 48-bit uinteger, from which a three-bit control code
|
||||||
* is extracted for a texel at location (x,y) in the block using:
|
* is extracted for a texel at location (x,y) in the block using:
|
||||||
*
|
*
|
||||||
* code(x,y) = bits[3*(4*y+x)+1..3*(4*y+x)+0]
|
* code(x,y) = bits[3*(4*y+x)+1..3*(4*y+x)+0]
|
||||||
*
|
*
|
||||||
* where bit 47 is the most significant and bit 0 is the least
|
* where bit 47 is the most significant and bit 0 is the least
|
||||||
* significant bit. */
|
* significant bit. */
|
||||||
unsigned int line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
|
uint line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
|
||||||
unsigned int line_2_3 = block[5] + 256 * (block[6] + 256 * block[7]);
|
uint line_2_3 = block[5] + 256 * (block[6] + 256 * block[7]);
|
||||||
/* swap lines 0 and 1 in line_0_1. */
|
/* swap lines 0 and 1 in line_0_1. */
|
||||||
unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
|
uint line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
|
||||||
/* swap lines 2 and 3 in line_2_3. */
|
/* swap lines 2 and 3 in line_2_3. */
|
||||||
unsigned int line_3_2 = ((line_2_3 & 0x000fff) << 12) | ((line_2_3 & 0xfff000) >> 12);
|
uint line_3_2 = ((line_2_3 & 0x000fff) << 12) | ((line_2_3 & 0xfff000) >> 12);
|
||||||
|
|
||||||
block[2] = line_3_2 & 0xff;
|
block[2] = line_3_2 & 0xff;
|
||||||
block[3] = (line_3_2 & 0xff00) >> 8;
|
block[3] = (line_3_2 & 0xff00) >> 8;
|
||||||
@ -133,21 +133,21 @@ static void FlipDXT5BlockFull(uint8_t *block)
|
|||||||
static void FlipDXT5BlockHalf(uint8_t *block)
|
static void FlipDXT5BlockHalf(uint8_t *block)
|
||||||
{
|
{
|
||||||
/* See layout above. */
|
/* See layout above. */
|
||||||
unsigned int line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
|
uint line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]);
|
||||||
unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
|
uint line_1_0 = ((line_0_1 & 0x000fff) << 12) | ((line_0_1 & 0xfff000) >> 12);
|
||||||
block[2] = line_1_0 & 0xff;
|
block[2] = line_1_0 & 0xff;
|
||||||
block[3] = (line_1_0 & 0xff00) >> 8;
|
block[3] = (line_1_0 & 0xff00) >> 8;
|
||||||
block[4] = (line_1_0 & 0xff0000) >> 16;
|
block[4] = (line_1_0 & 0xff0000) >> 16;
|
||||||
FlipDXT1BlockHalf(block + 8);
|
FlipDXT1BlockHalf(block + 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FlipDXTCImage(unsigned int width,
|
int FlipDXTCImage(uint width,
|
||||||
unsigned int height,
|
uint height,
|
||||||
unsigned int levels,
|
uint levels,
|
||||||
int fourcc,
|
int fourcc,
|
||||||
uint8_t *data,
|
uint8_t *data,
|
||||||
int data_size,
|
int data_size,
|
||||||
unsigned int *r_num_valid_levels)
|
uint *r_num_valid_levels)
|
||||||
{
|
{
|
||||||
*r_num_valid_levels = 0;
|
*r_num_valid_levels = 0;
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ int FlipDXTCImage(unsigned int width,
|
|||||||
|
|
||||||
FlipBlockFunction full_block_function;
|
FlipBlockFunction full_block_function;
|
||||||
FlipBlockFunction half_block_function;
|
FlipBlockFunction half_block_function;
|
||||||
unsigned int block_bytes = 0;
|
uint block_bytes = 0;
|
||||||
|
|
||||||
switch (fourcc) {
|
switch (fourcc) {
|
||||||
case FOURCC_DXT1:
|
case FOURCC_DXT1:
|
||||||
@ -186,15 +186,15 @@ int FlipDXTCImage(unsigned int width,
|
|||||||
|
|
||||||
*r_num_valid_levels = levels;
|
*r_num_valid_levels = levels;
|
||||||
|
|
||||||
unsigned int mip_width = width;
|
uint mip_width = width;
|
||||||
unsigned int mip_height = height;
|
uint mip_height = height;
|
||||||
|
|
||||||
const uint8_t *data_end = data + data_size;
|
const uint8_t *data_end = data + data_size;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < levels; i++) {
|
for (uint i = 0; i < levels; i++) {
|
||||||
unsigned int blocks_per_row = (mip_width + 3) / 4;
|
uint blocks_per_row = (mip_width + 3) / 4;
|
||||||
unsigned int blocks_per_col = (mip_height + 3) / 4;
|
uint blocks_per_col = (mip_height + 3) / 4;
|
||||||
unsigned int blocks = blocks_per_row * blocks_per_col;
|
uint blocks = blocks_per_row * blocks_per_col;
|
||||||
|
|
||||||
if (data + block_bytes * blocks > data_end) {
|
if (data + block_bytes * blocks > data_end) {
|
||||||
/* Stop flipping when running out of data to be modified, avoiding possible buffer overrun
|
/* Stop flipping when running out of data to be modified, avoiding possible buffer overrun
|
||||||
@ -209,23 +209,23 @@ int FlipDXTCImage(unsigned int width,
|
|||||||
}
|
}
|
||||||
if (mip_height == 2) {
|
if (mip_height == 2) {
|
||||||
/* flip the first 2 lines in each block. */
|
/* flip the first 2 lines in each block. */
|
||||||
for (unsigned int i = 0; i < blocks_per_row; i++) {
|
for (uint i = 0; i < blocks_per_row; i++) {
|
||||||
half_block_function(data + i * block_bytes);
|
half_block_function(data + i * block_bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* flip each block. */
|
/* flip each block. */
|
||||||
for (unsigned int i = 0; i < blocks; i++) {
|
for (uint i = 0; i < blocks; i++) {
|
||||||
full_block_function(data + i * block_bytes);
|
full_block_function(data + i * block_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Swap each block line in the first half of the image with the
|
/* Swap each block line in the first half of the image with the
|
||||||
* corresponding one in the second half.
|
* corresponding one in the second half.
|
||||||
* note that this is a no-op if mip_height is 4. */
|
* note that this is a no-op if mip_height is 4. */
|
||||||
unsigned int row_bytes = block_bytes * blocks_per_row;
|
uint row_bytes = block_bytes * blocks_per_row;
|
||||||
uint8_t *temp_line = new uint8_t[row_bytes];
|
uint8_t *temp_line = new uint8_t[row_bytes];
|
||||||
|
|
||||||
for (unsigned int y = 0; y < blocks_per_col / 2; y++) {
|
for (uint y = 0; y < blocks_per_col / 2; y++) {
|
||||||
uint8_t *line1 = data + y * row_bytes;
|
uint8_t *line1 = data + y * row_bytes;
|
||||||
uint8_t *line2 = data + (blocks_per_col - y - 1) * row_bytes;
|
uint8_t *line2 = data + (blocks_per_col - y - 1) * row_bytes;
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
* \ingroup imbdds
|
* \ingroup imbdds
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "BLI_sys_types.h" /* For `uint`. */
|
||||||
|
|
||||||
#include <Stream.h>
|
#include <Stream.h>
|
||||||
|
|
||||||
#include <cstdio> /* printf */
|
#include <cstdio> /* printf */
|
||||||
@ -12,7 +14,7 @@
|
|||||||
static const char *msg_error_seek = "DDS: trying to seek beyond end of stream (corrupt file?)";
|
static const char *msg_error_seek = "DDS: trying to seek beyond end of stream (corrupt file?)";
|
||||||
static const char *msg_error_read = "DDS: trying to read beyond end of stream (corrupt file?)";
|
static const char *msg_error_read = "DDS: trying to read beyond end of stream (corrupt file?)";
|
||||||
|
|
||||||
inline bool is_read_within_bounds(const Stream &mem, unsigned int count)
|
inline bool is_read_within_bounds(const Stream &mem, uint count)
|
||||||
{
|
{
|
||||||
if (mem.pos >= mem.size) {
|
if (mem.pos >= mem.size) {
|
||||||
/* No more data remained in the memory buffer. */
|
/* No more data remained in the memory buffer. */
|
||||||
@ -27,7 +29,7 @@ inline bool is_read_within_bounds(const Stream &mem, unsigned int count)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Stream::seek(unsigned int p)
|
uint Stream::seek(uint p)
|
||||||
{
|
{
|
||||||
if (p > size) {
|
if (p > size) {
|
||||||
set_failed(msg_error_seek);
|
set_failed(msg_error_seek);
|
||||||
@ -39,7 +41,7 @@ unsigned int Stream::seek(unsigned int p)
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int mem_read(Stream &mem, unsigned long long &i)
|
uint mem_read(Stream &mem, unsigned long long &i)
|
||||||
{
|
{
|
||||||
if (!is_read_within_bounds(mem, 8)) {
|
if (!is_read_within_bounds(mem, 8)) {
|
||||||
mem.set_failed(msg_error_seek);
|
mem.set_failed(msg_error_seek);
|
||||||
@ -50,7 +52,7 @@ unsigned int mem_read(Stream &mem, unsigned long long &i)
|
|||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int mem_read(Stream &mem, unsigned int &i)
|
uint mem_read(Stream &mem, uint &i)
|
||||||
{
|
{
|
||||||
if (!is_read_within_bounds(mem, 4)) {
|
if (!is_read_within_bounds(mem, 4)) {
|
||||||
mem.set_failed(msg_error_read);
|
mem.set_failed(msg_error_read);
|
||||||
@ -61,7 +63,7 @@ unsigned int mem_read(Stream &mem, unsigned int &i)
|
|||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int mem_read(Stream &mem, unsigned short &i)
|
uint mem_read(Stream &mem, ushort &i)
|
||||||
{
|
{
|
||||||
if (!is_read_within_bounds(mem, 2)) {
|
if (!is_read_within_bounds(mem, 2)) {
|
||||||
mem.set_failed(msg_error_read);
|
mem.set_failed(msg_error_read);
|
||||||
@ -72,7 +74,7 @@ unsigned int mem_read(Stream &mem, unsigned short &i)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int mem_read(Stream &mem, unsigned char &i)
|
uint mem_read(Stream &mem, uchar &i)
|
||||||
{
|
{
|
||||||
if (!is_read_within_bounds(mem, 1)) {
|
if (!is_read_within_bounds(mem, 1)) {
|
||||||
mem.set_failed(msg_error_read);
|
mem.set_failed(msg_error_read);
|
||||||
@ -83,7 +85,7 @@ unsigned int mem_read(Stream &mem, unsigned char &i)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int mem_read(Stream &mem, unsigned char *i, unsigned int count)
|
uint mem_read(Stream &mem, uchar *i, uint count)
|
||||||
{
|
{
|
||||||
if (!is_read_within_bounds(mem, count)) {
|
if (!is_read_within_bounds(mem, count)) {
|
||||||
mem.set_failed(msg_error_read);
|
mem.set_failed(msg_error_read);
|
||||||
|
@ -58,7 +58,7 @@ bool imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool imb_is_a_dds(const unsigned char *mem, const size_t size)
|
bool imb_is_a_dds(const uchar *mem, const size_t size)
|
||||||
{
|
{
|
||||||
if (size < 8) {
|
if (size < 8) {
|
||||||
return false;
|
return false;
|
||||||
@ -75,19 +75,16 @@ bool imb_is_a_dds(const unsigned char *mem, const size_t size)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ImBuf *imb_load_dds(const unsigned char *mem,
|
struct ImBuf *imb_load_dds(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
|
||||||
size_t size,
|
|
||||||
int flags,
|
|
||||||
char colorspace[IM_MAX_SPACE])
|
|
||||||
{
|
{
|
||||||
struct ImBuf *ibuf = nullptr;
|
struct ImBuf *ibuf = nullptr;
|
||||||
DirectDrawSurface dds((unsigned char *)mem, size); /* reads header */
|
DirectDrawSurface dds((uchar *)mem, size); /* reads header */
|
||||||
unsigned char bits_per_pixel;
|
uchar bits_per_pixel;
|
||||||
unsigned int *rect;
|
uint *rect;
|
||||||
Image img;
|
Image img;
|
||||||
unsigned int numpixels = 0;
|
uint numpixels = 0;
|
||||||
int col;
|
int col;
|
||||||
unsigned char *cp = (unsigned char *)&col;
|
uchar *cp = (uchar *)&col;
|
||||||
Color32 pixel;
|
Color32 pixel;
|
||||||
Color32 *pixels = nullptr;
|
Color32 *pixels = nullptr;
|
||||||
|
|
||||||
@ -128,7 +125,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
|
|||||||
bits_per_pixel = 24;
|
bits_per_pixel = 24;
|
||||||
if (img.format() == Image::Format_ARGB) {
|
if (img.format() == Image::Format_ARGB) {
|
||||||
/* check that there is effectively an alpha channel */
|
/* check that there is effectively an alpha channel */
|
||||||
for (unsigned int i = 0; i < numpixels; i++) {
|
for (uint i = 0; i < numpixels; i++) {
|
||||||
pixel = pixels[i];
|
pixel = pixels[i];
|
||||||
if (pixel.a != 255) {
|
if (pixel.a != 255) {
|
||||||
bits_per_pixel = 32;
|
bits_per_pixel = 32;
|
||||||
@ -156,7 +153,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
|
|||||||
rect = ibuf->rect;
|
rect = ibuf->rect;
|
||||||
cp[3] = 0xff; /* default alpha if alpha channel is not present */
|
cp[3] = 0xff; /* default alpha if alpha channel is not present */
|
||||||
|
|
||||||
for (unsigned int i = 0; i < numpixels; i++) {
|
for (uint i = 0; i < numpixels; i++) {
|
||||||
pixel = pixels[i];
|
pixel = pixels[i];
|
||||||
cp[0] = pixel.r; /* set R component of col */
|
cp[0] = pixel.r; /* set R component of col */
|
||||||
cp[1] = pixel.g; /* set G component of col */
|
cp[1] = pixel.g; /* set G component of col */
|
||||||
@ -168,7 +165,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ibuf->dds_data.fourcc != FOURCC_DDS) {
|
if (ibuf->dds_data.fourcc != FOURCC_DDS) {
|
||||||
ibuf->dds_data.data = (unsigned char *)dds.readData(ibuf->dds_data.size);
|
ibuf->dds_data.data = (uchar *)dds.readData(ibuf->dds_data.size);
|
||||||
|
|
||||||
/* flip compressed texture */
|
/* flip compressed texture */
|
||||||
if (ibuf->dds_data.data) {
|
if (ibuf->dds_data.data) {
|
||||||
|
@ -48,7 +48,7 @@ static void clear_dither_context(DitherContext *di)
|
|||||||
/** \name Generic Buffer Conversion
|
/** \name Generic Buffer Conversion
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
MINLINE void ushort_to_byte_v4(uchar b[4], const unsigned short us[4])
|
MINLINE void ushort_to_byte_v4(uchar b[4], const ushort us[4])
|
||||||
{
|
{
|
||||||
b[0] = unit_ushort_to_uchar(us[0]);
|
b[0] = unit_ushort_to_uchar(us[0]);
|
||||||
b[1] = unit_ushort_to_uchar(us[1]);
|
b[1] = unit_ushort_to_uchar(us[1]);
|
||||||
@ -56,13 +56,13 @@ MINLINE void ushort_to_byte_v4(uchar b[4], const unsigned short us[4])
|
|||||||
b[3] = unit_ushort_to_uchar(us[3]);
|
b[3] = unit_ushort_to_uchar(us[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
MINLINE unsigned char ftochar(float value)
|
MINLINE uchar ftochar(float value)
|
||||||
{
|
{
|
||||||
return unit_float_to_uchar_clamp(value);
|
return unit_float_to_uchar_clamp(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
MINLINE void ushort_to_byte_dither_v4(
|
MINLINE void ushort_to_byte_dither_v4(
|
||||||
uchar b[4], const unsigned short us[4], DitherContext *di, float s, float t)
|
uchar b[4], const ushort us[4], DitherContext *di, float s, float t)
|
||||||
{
|
{
|
||||||
#define USHORTTOFLOAT(val) ((float)val / 65535.0f)
|
#define USHORTTOFLOAT(val) ((float)val / 65535.0f)
|
||||||
float dither_value = dither_random_value(s, t) * 0.0033f * di->dither;
|
float dither_value = dither_random_value(s, t) * 0.0033f * di->dither;
|
||||||
@ -192,7 +192,7 @@ void IMB_buffer_byte_from_float(uchar *rect_to,
|
|||||||
}
|
}
|
||||||
else if (profile_to == IB_PROFILE_SRGB) {
|
else if (profile_to == IB_PROFILE_SRGB) {
|
||||||
/* convert from linear to sRGB */
|
/* convert from linear to sRGB */
|
||||||
unsigned short us[4];
|
ushort us[4];
|
||||||
float straight[4];
|
float straight[4];
|
||||||
|
|
||||||
if (dither && predivide) {
|
if (dither && predivide) {
|
||||||
@ -729,7 +729,7 @@ void IMB_rect_from_float(ImBuf *ibuf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* convert float to byte */
|
/* convert float to byte */
|
||||||
IMB_buffer_byte_from_float((unsigned char *)ibuf->rect,
|
IMB_buffer_byte_from_float((uchar *)ibuf->rect,
|
||||||
buffer,
|
buffer,
|
||||||
ibuf->channels,
|
ibuf->channels,
|
||||||
ibuf->dither,
|
ibuf->dither,
|
||||||
@ -768,7 +768,7 @@ void IMB_float_from_rect_ex(struct ImBuf *dst,
|
|||||||
|
|
||||||
float *rect_float = dst->rect_float;
|
float *rect_float = dst->rect_float;
|
||||||
rect_float += (region_to_update->xmin + region_to_update->ymin * dst->x) * 4;
|
rect_float += (region_to_update->xmin + region_to_update->ymin * dst->x) * 4;
|
||||||
unsigned char *rect = (unsigned char *)src->rect;
|
uchar *rect = (uchar *)src->rect;
|
||||||
rect += (region_to_update->xmin + region_to_update->ymin * dst->x) * 4;
|
rect += (region_to_update->xmin + region_to_update->ymin * dst->x) * 4;
|
||||||
const int region_width = BLI_rcti_size_x(region_to_update);
|
const int region_width = BLI_rcti_size_x(region_to_update);
|
||||||
const int region_height = BLI_rcti_size_y(region_to_update);
|
const int region_height = BLI_rcti_size_y(region_to_update);
|
||||||
@ -889,7 +889,7 @@ void IMB_buffer_float_premultiply(float *buf, int width, int height)
|
|||||||
void IMB_saturation(ImBuf *ibuf, float sat)
|
void IMB_saturation(ImBuf *ibuf, float sat)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
unsigned char *rct = (unsigned char *)ibuf->rect;
|
uchar *rct = (uchar *)ibuf->rect;
|
||||||
float *rct_fl = ibuf->rect_float;
|
float *rct_fl = ibuf->rect_float;
|
||||||
float hsv[3];
|
float hsv[3];
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
#include "imbuf.h"
|
#include "imbuf.h"
|
||||||
|
|
||||||
static void filtrow(unsigned char *point, int x)
|
static void filtrow(uchar *point, int x)
|
||||||
{
|
{
|
||||||
unsigned int c1, c2, c3, error;
|
uint c1, c2, c3, error;
|
||||||
|
|
||||||
if (x > 1) {
|
if (x > 1) {
|
||||||
c1 = c2 = *point;
|
c1 = c2 = *point;
|
||||||
@ -56,10 +56,10 @@ static void filtrowf(float *point, int x)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void filtcolum(unsigned char *point, int y, int skip)
|
static void filtcolum(uchar *point, int y, int skip)
|
||||||
{
|
{
|
||||||
unsigned int c1, c2, c3, error;
|
uint c1, c2, c3, error;
|
||||||
unsigned char *point2;
|
uchar *point2;
|
||||||
|
|
||||||
if (y > 1) {
|
if (y > 1) {
|
||||||
c1 = c2 = *point;
|
c1 = c2 = *point;
|
||||||
@ -101,11 +101,11 @@ static void filtcolumf(float *point, int y, int skip)
|
|||||||
|
|
||||||
void IMB_filtery(struct ImBuf *ibuf)
|
void IMB_filtery(struct ImBuf *ibuf)
|
||||||
{
|
{
|
||||||
unsigned char *point;
|
uchar *point;
|
||||||
float *pointf;
|
float *pointf;
|
||||||
int x, y, skip;
|
int x, y, skip;
|
||||||
|
|
||||||
point = (unsigned char *)ibuf->rect;
|
point = (uchar *)ibuf->rect;
|
||||||
pointf = ibuf->rect_float;
|
pointf = ibuf->rect_float;
|
||||||
|
|
||||||
x = ibuf->x;
|
x = ibuf->x;
|
||||||
@ -142,11 +142,11 @@ void IMB_filtery(struct ImBuf *ibuf)
|
|||||||
|
|
||||||
void imb_filterx(struct ImBuf *ibuf)
|
void imb_filterx(struct ImBuf *ibuf)
|
||||||
{
|
{
|
||||||
unsigned char *point;
|
uchar *point;
|
||||||
float *pointf;
|
float *pointf;
|
||||||
int x, y, skip;
|
int x, y, skip;
|
||||||
|
|
||||||
point = (unsigned char *)ibuf->rect;
|
point = (uchar *)ibuf->rect;
|
||||||
pointf = ibuf->rect_float;
|
pointf = ibuf->rect_float;
|
||||||
|
|
||||||
x = ibuf->x;
|
x = ibuf->x;
|
||||||
@ -395,7 +395,7 @@ static int check_pixel_assigned(
|
|||||||
res = mask[index] != 0 ? 1 : 0;
|
res = mask[index] != 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
else if ((is_float && ((const float *)buffer)[alpha_index] != 0.0f) ||
|
else if ((is_float && ((const float *)buffer)[alpha_index] != 0.0f) ||
|
||||||
(!is_float && ((const unsigned char *)buffer)[alpha_index] != 0)) {
|
(!is_float && ((const uchar *)buffer)[alpha_index] != 0)) {
|
||||||
res = 1;
|
res = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -408,7 +408,7 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
|
|||||||
const int width = ibuf->x;
|
const int width = ibuf->x;
|
||||||
const int height = ibuf->y;
|
const int height = ibuf->y;
|
||||||
const int depth = 4; /* always 4 channels */
|
const int depth = 4; /* always 4 channels */
|
||||||
const int chsize = ibuf->rect_float ? sizeof(float) : sizeof(unsigned char);
|
const int chsize = ibuf->rect_float ? sizeof(float) : sizeof(uchar);
|
||||||
const size_t bsize = ((size_t)width) * height * depth * chsize;
|
const size_t bsize = ((size_t)width) * height * depth * chsize;
|
||||||
const bool is_float = (ibuf->rect_float != NULL);
|
const bool is_float = (ibuf->rect_float != NULL);
|
||||||
void *dstbuf = (void *)MEM_dupallocN(ibuf->rect_float ? (void *)ibuf->rect_float :
|
void *dstbuf = (void *)MEM_dupallocN(ibuf->rect_float ? (void *)ibuf->rect_float :
|
||||||
@ -478,7 +478,7 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (c = 0; c < depth; c++) {
|
for (c = 0; c < depth; c++) {
|
||||||
tmp[c] = (float)((const unsigned char *)srcbuf)[depth * tmpindex + c];
|
tmp[c] = (float)((const uchar *)srcbuf)[depth * tmpindex + c];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,8 +505,10 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (c = 0; c < depth; c++) {
|
for (c = 0; c < depth; c++) {
|
||||||
((unsigned char *)dstbuf)[depth * index + c] =
|
((uchar *)dstbuf)[depth * index + c] = acc[c] > 255 ?
|
||||||
acc[c] > 255 ? 255 : (acc[c] < 0 ? 0 : (unsigned char)roundf(acc[c]));
|
255 :
|
||||||
|
(acc[c] < 0 ? 0 :
|
||||||
|
(uchar)roundf(acc[c]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,7 +615,7 @@ ImBuf *IMB_getmipmap(ImBuf *ibuf, int level)
|
|||||||
return (level == 0) ? ibuf : ibuf->mipmap[level - 1];
|
return (level == 0) ? ibuf : ibuf->mipmap[level - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMB_premultiply_rect(unsigned int *rect, char planes, int w, int h)
|
void IMB_premultiply_rect(uint *rect, char planes, int w, int h)
|
||||||
{
|
{
|
||||||
char *cp;
|
char *cp;
|
||||||
int x, y, val;
|
int x, y, val;
|
||||||
@ -674,7 +676,7 @@ void IMB_premultiply_alpha(ImBuf *ibuf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMB_unpremultiply_rect(unsigned int *rect, char planes, int w, int h)
|
void IMB_unpremultiply_rect(uint *rect, char planes, int w, int h)
|
||||||
{
|
{
|
||||||
char *cp;
|
char *cp;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf)
|
void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf)
|
||||||
{
|
{
|
||||||
size_t size;
|
size_t size;
|
||||||
unsigned char rt, *cp = (unsigned char *)ibuf->rect;
|
uchar rt, *cp = (uchar *)ibuf->rect;
|
||||||
float rtf, *cpf = ibuf->rect_float;
|
float rtf, *cpf = ibuf->rect_float;
|
||||||
|
|
||||||
if (ibuf->rect) {
|
if (ibuf->rect) {
|
||||||
@ -58,14 +58,13 @@ void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pixel_from_buffer(
|
static void pixel_from_buffer(const struct ImBuf *ibuf, uchar **outI, float **outF, int x, int y)
|
||||||
const struct ImBuf *ibuf, unsigned char **outI, float **outF, int x, int y)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
size_t offset = ((size_t)ibuf->x) * y * 4 + 4 * x;
|
size_t offset = ((size_t)ibuf->x) * y * 4 + 4 * x;
|
||||||
|
|
||||||
if (ibuf->rect) {
|
if (ibuf->rect) {
|
||||||
*outI = (unsigned char *)ibuf->rect + offset;
|
*outI = (uchar *)ibuf->rect + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ibuf->rect_float) {
|
if (ibuf->rect_float) {
|
||||||
@ -78,19 +77,19 @@ static void pixel_from_buffer(
|
|||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
void bicubic_interpolation_color(
|
void bicubic_interpolation_color(
|
||||||
const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
|
const struct ImBuf *in, uchar outI[4], float outF[4], float u, float v)
|
||||||
{
|
{
|
||||||
if (outF) {
|
if (outF) {
|
||||||
BLI_bicubic_interpolation_fl(in->rect_float, outF, in->x, in->y, 4, u, v);
|
BLI_bicubic_interpolation_fl(in->rect_float, outF, in->x, in->y, 4, u, v);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BLI_bicubic_interpolation_char((unsigned char *)in->rect, outI, in->x, in->y, 4, u, v);
|
BLI_bicubic_interpolation_char((uchar *)in->rect, outI, in->x, in->y, 4, u, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bicubic_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int xout, int yout)
|
void bicubic_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int xout, int yout)
|
||||||
{
|
{
|
||||||
unsigned char *outI = NULL;
|
uchar *outI = NULL;
|
||||||
float *outF = NULL;
|
float *outF = NULL;
|
||||||
|
|
||||||
if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) {
|
if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) {
|
||||||
@ -110,7 +109,7 @@ void bicubic_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int xo
|
|||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
void bilinear_interpolation_color_fl(
|
void bilinear_interpolation_color_fl(
|
||||||
const struct ImBuf *in, unsigned char UNUSED(outI[4]), float outF[4], float u, float v)
|
const struct ImBuf *in, uchar UNUSED(outI[4]), float outF[4], float u, float v)
|
||||||
{
|
{
|
||||||
BLI_assert(outF);
|
BLI_assert(outF);
|
||||||
BLI_assert(in->rect_float);
|
BLI_assert(in->rect_float);
|
||||||
@ -118,21 +117,21 @@ void bilinear_interpolation_color_fl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void bilinear_interpolation_color_char(
|
void bilinear_interpolation_color_char(
|
||||||
const struct ImBuf *in, unsigned char outI[4], float UNUSED(outF[4]), float u, float v)
|
const struct ImBuf *in, uchar outI[4], float UNUSED(outF[4]), float u, float v)
|
||||||
{
|
{
|
||||||
BLI_assert(outI);
|
BLI_assert(outI);
|
||||||
BLI_assert(in->rect);
|
BLI_assert(in->rect);
|
||||||
BLI_bilinear_interpolation_char((unsigned char *)in->rect, outI, in->x, in->y, 4, u, v);
|
BLI_bilinear_interpolation_char((uchar *)in->rect, outI, in->x, in->y, 4, u, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bilinear_interpolation_color(
|
void bilinear_interpolation_color(
|
||||||
const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
|
const struct ImBuf *in, uchar outI[4], float outF[4], float u, float v)
|
||||||
{
|
{
|
||||||
if (outF) {
|
if (outF) {
|
||||||
BLI_bilinear_interpolation_fl(in->rect_float, outF, in->x, in->y, 4, u, v);
|
BLI_bilinear_interpolation_fl(in->rect_float, outF, in->x, in->y, 4, u, v);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BLI_bilinear_interpolation_char((unsigned char *)in->rect, outI, in->x, in->y, 4, u, v);
|
BLI_bilinear_interpolation_char((uchar *)in->rect, outI, in->x, in->y, 4, u, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,10 +139,10 @@ void bilinear_interpolation_color(
|
|||||||
/* BILINEAR INTERPOLATION */
|
/* BILINEAR INTERPOLATION */
|
||||||
|
|
||||||
void bilinear_interpolation_color_wrap(
|
void bilinear_interpolation_color_wrap(
|
||||||
const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
|
const struct ImBuf *in, uchar outI[4], float outF[4], float u, float v)
|
||||||
{
|
{
|
||||||
float *row1, *row2, *row3, *row4, a, b;
|
float *row1, *row2, *row3, *row4, a, b;
|
||||||
unsigned char *row1I, *row2I, *row3I, *row4I;
|
uchar *row1I, *row2I, *row3I, *row4I;
|
||||||
float a_b, ma_b, a_mb, ma_mb;
|
float a_b, ma_b, a_mb, ma_mb;
|
||||||
int y1, y2, x1, x2;
|
int y1, y2, x1, x2;
|
||||||
|
|
||||||
@ -198,10 +197,10 @@ void bilinear_interpolation_color_wrap(
|
|||||||
}
|
}
|
||||||
if (outI) {
|
if (outI) {
|
||||||
/* sample including outside of edges of image */
|
/* sample including outside of edges of image */
|
||||||
row1I = (unsigned char *)in->rect + ((size_t)in->x) * y1 * 4 + 4 * x1;
|
row1I = (uchar *)in->rect + ((size_t)in->x) * y1 * 4 + 4 * x1;
|
||||||
row2I = (unsigned char *)in->rect + ((size_t)in->x) * y2 * 4 + 4 * x1;
|
row2I = (uchar *)in->rect + ((size_t)in->x) * y2 * 4 + 4 * x1;
|
||||||
row3I = (unsigned char *)in->rect + ((size_t)in->x) * y1 * 4 + 4 * x2;
|
row3I = (uchar *)in->rect + ((size_t)in->x) * y1 * 4 + 4 * x2;
|
||||||
row4I = (unsigned char *)in->rect + ((size_t)in->x) * y2 * 4 + 4 * x2;
|
row4I = (uchar *)in->rect + ((size_t)in->x) * y2 * 4 + 4 * x2;
|
||||||
|
|
||||||
/* Tested with white images and this should not wrap back to zero. */
|
/* Tested with white images and this should not wrap back to zero. */
|
||||||
outI[0] = roundf(ma_mb * row1I[0] + a_mb * row3I[0] + ma_b * row2I[0] + a_b * row4I[0]);
|
outI[0] = roundf(ma_mb * row1I[0] + a_mb * row3I[0] + ma_b * row2I[0] + a_b * row4I[0]);
|
||||||
@ -213,7 +212,7 @@ void bilinear_interpolation_color_wrap(
|
|||||||
|
|
||||||
void bilinear_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int xout, int yout)
|
void bilinear_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int xout, int yout)
|
||||||
{
|
{
|
||||||
unsigned char *outI = NULL;
|
uchar *outI = NULL;
|
||||||
float *outF = NULL;
|
float *outF = NULL;
|
||||||
|
|
||||||
if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) {
|
if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) {
|
||||||
@ -233,7 +232,7 @@ void bilinear_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int x
|
|||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
void nearest_interpolation_color_char(
|
void nearest_interpolation_color_char(
|
||||||
const struct ImBuf *in, unsigned char outI[4], float UNUSED(outF[4]), float u, float v)
|
const struct ImBuf *in, uchar outI[4], float UNUSED(outF[4]), float u, float v)
|
||||||
{
|
{
|
||||||
BLI_assert(outI);
|
BLI_assert(outI);
|
||||||
BLI_assert(in->rect);
|
BLI_assert(in->rect);
|
||||||
@ -248,7 +247,7 @@ void nearest_interpolation_color_char(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const size_t offset = ((size_t)in->x * y1 + x1) * 4;
|
const size_t offset = ((size_t)in->x * y1 + x1) * 4;
|
||||||
const unsigned char *dataI = (unsigned char *)in->rect + offset;
|
const uchar *dataI = (uchar *)in->rect + offset;
|
||||||
outI[0] = dataI[0];
|
outI[0] = dataI[0];
|
||||||
outI[1] = dataI[1];
|
outI[1] = dataI[1];
|
||||||
outI[2] = dataI[2];
|
outI[2] = dataI[2];
|
||||||
@ -256,7 +255,7 @@ void nearest_interpolation_color_char(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void nearest_interpolation_color_fl(
|
void nearest_interpolation_color_fl(
|
||||||
const struct ImBuf *in, unsigned char UNUSED(outI[4]), float outF[4], float u, float v)
|
const struct ImBuf *in, uchar UNUSED(outI[4]), float outF[4], float u, float v)
|
||||||
{
|
{
|
||||||
BLI_assert(outF);
|
BLI_assert(outF);
|
||||||
BLI_assert(in->rect_float);
|
BLI_assert(in->rect_float);
|
||||||
@ -276,7 +275,7 @@ void nearest_interpolation_color_fl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void nearest_interpolation_color(
|
void nearest_interpolation_color(
|
||||||
const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
|
const struct ImBuf *in, uchar outI[4], float outF[4], float u, float v)
|
||||||
{
|
{
|
||||||
if (outF) {
|
if (outF) {
|
||||||
nearest_interpolation_color_fl(in, outI, outF, u, v);
|
nearest_interpolation_color_fl(in, outI, outF, u, v);
|
||||||
@ -287,10 +286,10 @@ void nearest_interpolation_color(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void nearest_interpolation_color_wrap(
|
void nearest_interpolation_color_wrap(
|
||||||
const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
|
const struct ImBuf *in, uchar outI[4], float outF[4], float u, float v)
|
||||||
{
|
{
|
||||||
const float *dataF;
|
const float *dataF;
|
||||||
unsigned char *dataI;
|
uchar *dataI;
|
||||||
int y, x;
|
int y, x;
|
||||||
|
|
||||||
/* ImBuf in must have a valid rect or rect_float, assume this is already checked */
|
/* ImBuf in must have a valid rect or rect_float, assume this is already checked */
|
||||||
@ -309,7 +308,7 @@ void nearest_interpolation_color_wrap(
|
|||||||
y += in->y;
|
y += in->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataI = (unsigned char *)in->rect + ((size_t)in->x) * y * 4 + 4 * x;
|
dataI = (uchar *)in->rect + ((size_t)in->x) * y * 4 + 4 * x;
|
||||||
if (outI) {
|
if (outI) {
|
||||||
outI[0] = dataI[0];
|
outI[0] = dataI[0];
|
||||||
outI[1] = dataI[1];
|
outI[1] = dataI[1];
|
||||||
@ -327,7 +326,7 @@ void nearest_interpolation_color_wrap(
|
|||||||
|
|
||||||
void nearest_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int xout, int yout)
|
void nearest_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int xout, int yout)
|
||||||
{
|
{
|
||||||
unsigned char *outI = NULL;
|
uchar *outI = NULL;
|
||||||
float *outF = NULL;
|
float *outF = NULL;
|
||||||
|
|
||||||
if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) {
|
if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) {
|
||||||
@ -446,10 +445,10 @@ void IMB_alpha_under_color_float(float *rect_float, int x, int y, float backcol[
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, const float backcol[3])
|
void IMB_alpha_under_color_byte(uchar *rect, int x, int y, const float backcol[3])
|
||||||
{
|
{
|
||||||
size_t a = ((size_t)x) * y;
|
size_t a = ((size_t)x) * y;
|
||||||
unsigned char *cp = rect;
|
uchar *cp = rect;
|
||||||
|
|
||||||
while (a--) {
|
while (a--) {
|
||||||
if (cp[3] == 255) {
|
if (cp[3] == 255) {
|
||||||
@ -487,7 +486,7 @@ void IMB_sampleImageAtLocation(ImBuf *ibuf, float x, float y, bool make_linear_r
|
|||||||
nearest_interpolation_color(ibuf, NULL, color, x, y);
|
nearest_interpolation_color(ibuf, NULL, color, x, y);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unsigned char byte_color[4];
|
uchar byte_color[4];
|
||||||
nearest_interpolation_color(ibuf, byte_color, NULL, x, y);
|
nearest_interpolation_color(ibuf, byte_color, NULL, x, y);
|
||||||
rgba_uchar_to_float(color, byte_color);
|
rgba_uchar_to_float(color, byte_color);
|
||||||
if (make_linear_rgb) {
|
if (make_linear_rgb) {
|
||||||
|
@ -39,7 +39,7 @@ typedef struct img_folder {
|
|||||||
float *rates;
|
float *rates;
|
||||||
} img_fol_t;
|
} img_fol_t;
|
||||||
|
|
||||||
static bool check_jp2(const unsigned char *mem, const size_t size) /* J2K_CFMT */
|
static bool check_jp2(const uchar *mem, const size_t size) /* J2K_CFMT */
|
||||||
{
|
{
|
||||||
if (size < sizeof(JP2_HEAD)) {
|
if (size < sizeof(JP2_HEAD)) {
|
||||||
return false;
|
return false;
|
||||||
@ -47,7 +47,7 @@ static bool check_jp2(const unsigned char *mem, const size_t size) /* J2K_CFMT *
|
|||||||
return memcmp(JP2_HEAD, mem, sizeof(JP2_HEAD)) ? 0 : 1;
|
return memcmp(JP2_HEAD, mem, sizeof(JP2_HEAD)) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool check_j2k(const unsigned char *mem, const size_t size) /* J2K_CFMT */
|
static bool check_j2k(const uchar *mem, const size_t size) /* J2K_CFMT */
|
||||||
{
|
{
|
||||||
if (size < sizeof(J2K_HEAD)) {
|
if (size < sizeof(J2K_HEAD)) {
|
||||||
return false;
|
return false;
|
||||||
@ -55,8 +55,7 @@ static bool check_j2k(const unsigned char *mem, const size_t size) /* J2K_CFMT *
|
|||||||
return memcmp(J2K_HEAD, mem, sizeof(J2K_HEAD)) ? 0 : 1;
|
return memcmp(J2K_HEAD, mem, sizeof(J2K_HEAD)) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static OPJ_CODEC_FORMAT format_from_header(const unsigned char mem[JP2_FILEHEADER_SIZE],
|
static OPJ_CODEC_FORMAT format_from_header(const uchar mem[JP2_FILEHEADER_SIZE], const size_t size)
|
||||||
const size_t size)
|
|
||||||
{
|
{
|
||||||
if (check_jp2(mem, size)) {
|
if (check_jp2(mem, size)) {
|
||||||
return OPJ_CODEC_JP2;
|
return OPJ_CODEC_JP2;
|
||||||
@ -68,7 +67,7 @@ static OPJ_CODEC_FORMAT format_from_header(const unsigned char mem[JP2_FILEHEADE
|
|||||||
return OPJ_CODEC_UNKNOWN;
|
return OPJ_CODEC_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool imb_is_a_jp2(const unsigned char *buf, size_t size)
|
bool imb_is_a_jp2(const uchar *buf, size_t size)
|
||||||
{
|
{
|
||||||
return (check_jp2(buf, size) || check_j2k(buf, size));
|
return (check_jp2(buf, size) || check_j2k(buf, size));
|
||||||
}
|
}
|
||||||
@ -102,11 +101,11 @@ static void info_callback(const char *msg, void *client_data)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PIXEL_LOOPER_BEGIN(_rect) \
|
#define PIXEL_LOOPER_BEGIN(_rect) \
|
||||||
for (y = h - 1; y != (unsigned int)(-1); y--) { \
|
for (y = h - 1; y != (uint)(-1); y--) { \
|
||||||
for (i = y * w, i_next = (y + 1) * w; i < i_next; i++, _rect += 4) {
|
for (i = y * w, i_next = (y + 1) * w; i < i_next; i++, _rect += 4) {
|
||||||
|
|
||||||
#define PIXEL_LOOPER_BEGIN_CHANNELS(_rect, _channels) \
|
#define PIXEL_LOOPER_BEGIN_CHANNELS(_rect, _channels) \
|
||||||
for (y = h - 1; y != (unsigned int)(-1); y--) { \
|
for (y = h - 1; y != (uint)(-1); y--) { \
|
||||||
for (i = y * w, i_next = (y + 1) * w; i < i_next; i++, _rect += _channels) {
|
for (i = y * w, i_next = (y + 1) * w; i < i_next; i++, _rect += _channels) {
|
||||||
|
|
||||||
#define PIXEL_LOOPER_END \
|
#define PIXEL_LOOPER_END \
|
||||||
@ -119,8 +118,8 @@ static void info_callback(const char *msg, void *client_data)
|
|||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
struct BufInfo {
|
struct BufInfo {
|
||||||
const unsigned char *buf;
|
const uchar *buf;
|
||||||
const unsigned char *cur;
|
const uchar *cur;
|
||||||
OPJ_OFF_T len;
|
OPJ_OFF_T len;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -300,10 +299,7 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream,
|
|||||||
int flags,
|
int flags,
|
||||||
char colorspace[IM_MAX_SPACE]);
|
char colorspace[IM_MAX_SPACE]);
|
||||||
|
|
||||||
ImBuf *imb_load_jp2(const unsigned char *mem,
|
ImBuf *imb_load_jp2(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
|
||||||
size_t size,
|
|
||||||
int flags,
|
|
||||||
char colorspace[IM_MAX_SPACE])
|
|
||||||
{
|
{
|
||||||
const OPJ_CODEC_FORMAT format = (size > JP2_FILEHEADER_SIZE) ? format_from_header(mem, size) :
|
const OPJ_CODEC_FORMAT format = (size > JP2_FILEHEADER_SIZE) ? format_from_header(mem, size) :
|
||||||
OPJ_CODEC_UNKNOWN;
|
OPJ_CODEC_UNKNOWN;
|
||||||
@ -322,7 +318,7 @@ ImBuf *imb_load_jp2(const unsigned char *mem,
|
|||||||
ImBuf *imb_load_jp2_filepath(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
|
ImBuf *imb_load_jp2_filepath(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
|
||||||
{
|
{
|
||||||
FILE *p_file = NULL;
|
FILE *p_file = NULL;
|
||||||
unsigned char mem[JP2_FILEHEADER_SIZE];
|
uchar mem[JP2_FILEHEADER_SIZE];
|
||||||
opj_stream_t *stream = opj_stream_create_from_file(
|
opj_stream_t *stream = opj_stream_create_from_file(
|
||||||
filepath, OPJ_J2K_STREAM_CHUNK_SIZE, true, &p_file);
|
filepath, OPJ_J2K_STREAM_CHUNK_SIZE, true, &p_file);
|
||||||
if (stream) {
|
if (stream) {
|
||||||
@ -358,8 +354,8 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream,
|
|||||||
long signed_offsets[4] = {0, 0, 0, 0};
|
long signed_offsets[4] = {0, 0, 0, 0};
|
||||||
int float_divs[4] = {1, 1, 1, 1};
|
int float_divs[4] = {1, 1, 1, 1};
|
||||||
|
|
||||||
unsigned int i, i_next, w, h, planes;
|
uint i, i_next, w, h, planes;
|
||||||
unsigned int y;
|
uint y;
|
||||||
int *r, *g, *b, *a; /* matching 'opj_image_comp.data' type */
|
int *r, *g, *b, *a; /* matching 'opj_image_comp.data' type */
|
||||||
|
|
||||||
opj_dparameters_t parameters; /* decompression parameters */
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
@ -509,7 +505,7 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unsigned char *rect_uchar = (unsigned char *)ibuf->rect;
|
uchar *rect_uchar = (uchar *)ibuf->rect;
|
||||||
|
|
||||||
if (image->numcomps < 3) {
|
if (image->numcomps < 3) {
|
||||||
r = image->comps[0].data;
|
r = image->comps[0].data;
|
||||||
@ -599,11 +595,11 @@ static opj_image_t *rawtoimage(const char *filename,
|
|||||||
(_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 65535 : (int)(65535.0f * (_val)))
|
(_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 65535 : (int)(65535.0f * (_val)))
|
||||||
#else
|
#else
|
||||||
|
|
||||||
BLI_INLINE int UPSAMPLE_8_TO_12(const unsigned char _val)
|
BLI_INLINE int UPSAMPLE_8_TO_12(const uchar _val)
|
||||||
{
|
{
|
||||||
return (_val << 4) | (_val & ((1 << 4) - 1));
|
return (_val << 4) | (_val & ((1 << 4) - 1));
|
||||||
}
|
}
|
||||||
BLI_INLINE int UPSAMPLE_8_TO_16(const unsigned char _val)
|
BLI_INLINE int UPSAMPLE_8_TO_16(const uchar _val)
|
||||||
{
|
{
|
||||||
return (_val << 8) + _val;
|
return (_val << 8) + _val;
|
||||||
}
|
}
|
||||||
@ -811,14 +807,14 @@ static float channel_colormanage_noop(float value)
|
|||||||
|
|
||||||
static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
|
static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
|
||||||
{
|
{
|
||||||
unsigned char *rect_uchar;
|
uchar *rect_uchar;
|
||||||
float *rect_float, from_straight[4];
|
float *rect_float, from_straight[4];
|
||||||
|
|
||||||
unsigned int subsampling_dx = parameters->subsampling_dx;
|
uint subsampling_dx = parameters->subsampling_dx;
|
||||||
unsigned int subsampling_dy = parameters->subsampling_dy;
|
uint subsampling_dy = parameters->subsampling_dy;
|
||||||
|
|
||||||
unsigned int i, i_next, numcomps, w, h, prec;
|
uint i, i_next, numcomps, w, h, prec;
|
||||||
unsigned int y;
|
uint y;
|
||||||
int *r, *g, *b, *a; /* matching 'opj_image_comp.data' type */
|
int *r, *g, *b, *a; /* matching 'opj_image_comp.data' type */
|
||||||
OPJ_COLOR_SPACE color_space;
|
OPJ_COLOR_SPACE color_space;
|
||||||
opj_image_cmptparm_t cmptparm[4]; /* maximum of 4 components */
|
opj_image_cmptparm_t cmptparm[4]; /* maximum of 4 components */
|
||||||
@ -910,7 +906,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters)
|
|||||||
image->y1 = image->y0 + (h - 1) * subsampling_dy + 1 + image->y0;
|
image->y1 = image->y0 + (h - 1) * subsampling_dy + 1 + image->y0;
|
||||||
|
|
||||||
/* set image data */
|
/* set image data */
|
||||||
rect_uchar = (unsigned char *)ibuf->rect;
|
rect_uchar = (uchar *)ibuf->rect;
|
||||||
rect_float = ibuf->rect_float;
|
rect_float = ibuf->rect_float;
|
||||||
|
|
||||||
/* set the destination channels */
|
/* set the destination channels */
|
||||||
|
@ -37,7 +37,7 @@ static void init_source(j_decompress_ptr cinfo);
|
|||||||
static boolean fill_input_buffer(j_decompress_ptr cinfo);
|
static boolean fill_input_buffer(j_decompress_ptr cinfo);
|
||||||
static void skip_input_data(j_decompress_ptr cinfo, long num_bytes);
|
static void skip_input_data(j_decompress_ptr cinfo, long num_bytes);
|
||||||
static void term_source(j_decompress_ptr cinfo);
|
static void term_source(j_decompress_ptr cinfo);
|
||||||
static void memory_source(j_decompress_ptr cinfo, const unsigned char *buffer, size_t size);
|
static void memory_source(j_decompress_ptr cinfo, const uchar *buffer, size_t size);
|
||||||
static boolean handle_app1(j_decompress_ptr cinfo);
|
static boolean handle_app1(j_decompress_ptr cinfo);
|
||||||
static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo,
|
static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo,
|
||||||
int flags,
|
int flags,
|
||||||
@ -48,7 +48,7 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo,
|
|||||||
static const uchar jpeg_default_quality = 75;
|
static const uchar jpeg_default_quality = 75;
|
||||||
static uchar ibuf_quality;
|
static uchar ibuf_quality;
|
||||||
|
|
||||||
bool imb_is_a_jpeg(const unsigned char *mem, const size_t size)
|
bool imb_is_a_jpeg(const uchar *mem, const size_t size)
|
||||||
{
|
{
|
||||||
const char magic[2] = {0xFF, 0xD8};
|
const char magic[2] = {0xFF, 0xD8};
|
||||||
if (size < sizeof(magic)) {
|
if (size < sizeof(magic)) {
|
||||||
@ -89,7 +89,7 @@ static void jpeg_error(j_common_ptr cinfo)
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned char *buffer;
|
uchar *buffer;
|
||||||
int filled;
|
int filled;
|
||||||
} buffer_struct;
|
} buffer_struct;
|
||||||
#endif
|
#endif
|
||||||
@ -97,7 +97,7 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
struct jpeg_source_mgr pub; /* public fields */
|
struct jpeg_source_mgr pub; /* public fields */
|
||||||
|
|
||||||
const unsigned char *buffer;
|
const uchar *buffer;
|
||||||
int size;
|
int size;
|
||||||
JOCTET terminal[2];
|
JOCTET terminal[2];
|
||||||
} my_source_mgr;
|
} my_source_mgr;
|
||||||
@ -144,7 +144,7 @@ static void term_source(j_decompress_ptr cinfo)
|
|||||||
(void)cinfo; /* unused */
|
(void)cinfo; /* unused */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void memory_source(j_decompress_ptr cinfo, const unsigned char *buffer, size_t size)
|
static void memory_source(j_decompress_ptr cinfo, const uchar *buffer, size_t size)
|
||||||
{
|
{
|
||||||
my_src_ptr src;
|
my_src_ptr src;
|
||||||
|
|
||||||
@ -205,11 +205,11 @@ static void memory_source(j_decompress_ptr cinfo, const unsigned char *buffer, s
|
|||||||
MAKESTMT(MAKE_BYTE_AVAIL(cinfo, action); bytes_in_buffer--; V = GETJOCTET(*next_input_byte++);)
|
MAKESTMT(MAKE_BYTE_AVAIL(cinfo, action); bytes_in_buffer--; V = GETJOCTET(*next_input_byte++);)
|
||||||
|
|
||||||
/* As above, but read two bytes interpreted as an unsigned 16-bit integer.
|
/* As above, but read two bytes interpreted as an unsigned 16-bit integer.
|
||||||
* V should be declared unsigned int or perhaps INT32.
|
* V should be declared `uint` or perhaps INT32.
|
||||||
*/
|
*/
|
||||||
#define INPUT_2BYTES(cinfo, V, action) \
|
#define INPUT_2BYTES(cinfo, V, action) \
|
||||||
MAKESTMT(MAKE_BYTE_AVAIL(cinfo, action); bytes_in_buffer--; \
|
MAKESTMT(MAKE_BYTE_AVAIL(cinfo, action); bytes_in_buffer--; \
|
||||||
V = ((unsigned int)GETJOCTET(*next_input_byte++)) << 8; \
|
V = ((uint)GETJOCTET(*next_input_byte++)) << 8; \
|
||||||
MAKE_BYTE_AVAIL(cinfo, action); \
|
MAKE_BYTE_AVAIL(cinfo, action); \
|
||||||
bytes_in_buffer--; \
|
bytes_in_buffer--; \
|
||||||
V += GETJOCTET(*next_input_byte++);)
|
V += GETJOCTET(*next_input_byte++);)
|
||||||
@ -445,10 +445,7 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo,
|
|||||||
return ibuf;
|
return ibuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImBuf *imb_load_jpeg(const unsigned char *buffer,
|
ImBuf *imb_load_jpeg(const uchar *buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE])
|
||||||
size_t size,
|
|
||||||
int flags,
|
|
||||||
char colorspace[IM_MAX_SPACE])
|
|
||||||
{
|
{
|
||||||
struct jpeg_decompress_struct _cinfo, *cinfo = &_cinfo;
|
struct jpeg_decompress_struct _cinfo, *cinfo = &_cinfo;
|
||||||
struct my_error_mgr jerr;
|
struct my_error_mgr jerr;
|
||||||
@ -521,7 +518,7 @@ struct ImBuf *imb_thumbnail_jpeg(const char *filepath,
|
|||||||
if ((fgetc(infile) == JPEG_MARKER_MSB) && (fgetc(infile) == JPEG_MARKER_SOI) &&
|
if ((fgetc(infile) == JPEG_MARKER_MSB) && (fgetc(infile) == JPEG_MARKER_SOI) &&
|
||||||
(fgetc(infile) == JPEG_MARKER_MSB) && (fgetc(infile) == JPEG_MARKER_APP1)) {
|
(fgetc(infile) == JPEG_MARKER_MSB) && (fgetc(infile) == JPEG_MARKER_APP1)) {
|
||||||
/* This is a JPEG in EXIF format (SOI + APP1), not JFIF (SOI + APP0). */
|
/* This is a JPEG in EXIF format (SOI + APP1), not JFIF (SOI + APP0). */
|
||||||
unsigned int i = JPEG_APP1_MAX;
|
uint i = JPEG_APP1_MAX;
|
||||||
/* All EXIF data is within this 64K header segment. Skip ahead until next SOI for thumbnail. */
|
/* All EXIF data is within this 64K header segment. Skip ahead until next SOI for thumbnail. */
|
||||||
while (!((fgetc(infile) == JPEG_MARKER_MSB) && (fgetc(infile) == JPEG_MARKER_SOI)) &&
|
while (!((fgetc(infile) == JPEG_MARKER_MSB) && (fgetc(infile) == JPEG_MARKER_SOI)) &&
|
||||||
!feof(infile) && i--) {
|
!feof(infile) && i--) {
|
||||||
|
@ -81,7 +81,7 @@ struct MovieCacheItem {
|
|||||||
bool added_empty;
|
bool added_empty;
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int moviecache_hashhash(const void *keyv)
|
static uint moviecache_hashhash(const void *keyv)
|
||||||
{
|
{
|
||||||
const MovieCacheKey *key = (const MovieCacheKey *)keyv;
|
const MovieCacheKey *key = (const MovieCacheKey *)keyv;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ OIIO_NAMESPACE_USING
|
|||||||
using std::string;
|
using std::string;
|
||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
|
|
||||||
using uchar = unsigned char;
|
using uchar = uchar;
|
||||||
|
|
||||||
template<class T, class Q>
|
template<class T, class Q>
|
||||||
static void fill_all_channels(T *pixels, int width, int height, int components, Q alpha)
|
static void fill_all_channels(T *pixels, int width, int height, int components, Q alpha)
|
||||||
@ -147,9 +147,9 @@ static ImBuf *imb_oiio_load_image_float(
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
bool imb_is_a_photoshop(const unsigned char *mem, size_t size)
|
bool imb_is_a_photoshop(const uchar *mem, size_t size)
|
||||||
{
|
{
|
||||||
const unsigned char magic[4] = {'8', 'B', 'P', 'S'};
|
const uchar magic[4] = {'8', 'B', 'P', 'S'};
|
||||||
if (size < sizeof(magic)) {
|
if (size < sizeof(magic)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,7 @@ static void imb_exr_type_by_channels(ChannelList &channels,
|
|||||||
|
|
||||||
class IMemStream : public Imf::IStream {
|
class IMemStream : public Imf::IStream {
|
||||||
public:
|
public:
|
||||||
IMemStream(unsigned char *exrbuf, size_t exrsize)
|
IMemStream(uchar *exrbuf, size_t exrsize) : IStream("<memory>"), _exrpos(0), _exrsize(exrsize)
|
||||||
: IStream("<memory>"), _exrpos(0), _exrsize(exrsize)
|
|
||||||
{
|
{
|
||||||
_exrbuf = exrbuf;
|
_exrbuf = exrbuf;
|
||||||
}
|
}
|
||||||
@ -156,7 +155,7 @@ class IMemStream : public Imf::IStream {
|
|||||||
private:
|
private:
|
||||||
exr_file_offset_t _exrpos;
|
exr_file_offset_t _exrpos;
|
||||||
exr_file_offset_t _exrsize;
|
exr_file_offset_t _exrsize;
|
||||||
unsigned char *_exrbuf;
|
uchar *_exrbuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Memory-Mapped Input Stream */
|
/* Memory-Mapped Input Stream */
|
||||||
@ -178,7 +177,7 @@ class IMMapStream : public Imf::IStream {
|
|||||||
throw IEX_NAMESPACE::InputExc("BLI_mmap_open failed");
|
throw IEX_NAMESPACE::InputExc("BLI_mmap_open failed");
|
||||||
}
|
}
|
||||||
close(file);
|
close(file);
|
||||||
_exrbuf = (unsigned char *)BLI_mmap_get_pointer(_mmap_file);
|
_exrbuf = (uchar *)BLI_mmap_get_pointer(_mmap_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
~IMMapStream() override
|
~IMMapStream() override
|
||||||
@ -216,7 +215,7 @@ class IMMapStream : public Imf::IStream {
|
|||||||
BLI_mmap_file *_mmap_file;
|
BLI_mmap_file *_mmap_file;
|
||||||
exr_file_offset_t _exrpos;
|
exr_file_offset_t _exrpos;
|
||||||
exr_file_offset_t _exrsize;
|
exr_file_offset_t _exrsize;
|
||||||
unsigned char *_exrbuf;
|
uchar *_exrbuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* File Input Stream */
|
/* File Input Stream */
|
||||||
@ -395,7 +394,7 @@ static half float_to_half_safe(const float value)
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
bool imb_is_a_openexr(const unsigned char *mem, const size_t size)
|
bool imb_is_a_openexr(const uchar *mem, const size_t size)
|
||||||
{
|
{
|
||||||
/* No define is exposed for this size. */
|
/* No define is exposed for this size. */
|
||||||
if (size < 4) {
|
if (size < 4) {
|
||||||
@ -547,10 +546,10 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *name, const int flags
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unsigned char *from;
|
uchar *from;
|
||||||
|
|
||||||
for (int i = ibuf->y - 1; i >= 0; i--) {
|
for (int i = ibuf->y - 1; i >= 0; i--) {
|
||||||
from = (unsigned char *)ibuf->rect + 4 * i * width;
|
from = (uchar *)ibuf->rect + 4 * i * width;
|
||||||
|
|
||||||
for (int j = ibuf->x; j > 0; j--) {
|
for (int j = ibuf->x; j > 0; j--) {
|
||||||
to->r = srgb_to_linearrgb((float)from[0] / 255.0f);
|
to->r = srgb_to_linearrgb((float)from[0] / 255.0f);
|
||||||
@ -1670,29 +1669,29 @@ static bool imb_exr_multilayer_parse_channels_from_file(ExrHandle *data)
|
|||||||
if (ELEM(pass->totchan, 3, 4)) {
|
if (ELEM(pass->totchan, 3, 4)) {
|
||||||
if (pass->chan[0]->chan_id == 'B' || pass->chan[1]->chan_id == 'B' ||
|
if (pass->chan[0]->chan_id == 'B' || pass->chan[1]->chan_id == 'B' ||
|
||||||
pass->chan[2]->chan_id == 'B') {
|
pass->chan[2]->chan_id == 'B') {
|
||||||
lookup[(unsigned int)'R'] = 0;
|
lookup[(uint)'R'] = 0;
|
||||||
lookup[(unsigned int)'G'] = 1;
|
lookup[(uint)'G'] = 1;
|
||||||
lookup[(unsigned int)'B'] = 2;
|
lookup[(uint)'B'] = 2;
|
||||||
lookup[(unsigned int)'A'] = 3;
|
lookup[(uint)'A'] = 3;
|
||||||
}
|
}
|
||||||
else if (pass->chan[0]->chan_id == 'Y' || pass->chan[1]->chan_id == 'Y' ||
|
else if (pass->chan[0]->chan_id == 'Y' || pass->chan[1]->chan_id == 'Y' ||
|
||||||
pass->chan[2]->chan_id == 'Y') {
|
pass->chan[2]->chan_id == 'Y') {
|
||||||
lookup[(unsigned int)'X'] = 0;
|
lookup[(uint)'X'] = 0;
|
||||||
lookup[(unsigned int)'Y'] = 1;
|
lookup[(uint)'Y'] = 1;
|
||||||
lookup[(unsigned int)'Z'] = 2;
|
lookup[(uint)'Z'] = 2;
|
||||||
lookup[(unsigned int)'W'] = 3;
|
lookup[(uint)'W'] = 3;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lookup[(unsigned int)'U'] = 0;
|
lookup[(uint)'U'] = 0;
|
||||||
lookup[(unsigned int)'V'] = 1;
|
lookup[(uint)'V'] = 1;
|
||||||
lookup[(unsigned int)'A'] = 2;
|
lookup[(uint)'A'] = 2;
|
||||||
}
|
}
|
||||||
for (int a = 0; a < pass->totchan; a++) {
|
for (int a = 0; a < pass->totchan; a++) {
|
||||||
echan = pass->chan[a];
|
echan = pass->chan[a];
|
||||||
echan->rect = pass->rect + lookup[(unsigned int)echan->chan_id];
|
echan->rect = pass->rect + lookup[(uint)echan->chan_id];
|
||||||
echan->xstride = pass->totchan;
|
echan->xstride = pass->totchan;
|
||||||
echan->ystride = data->width * pass->totchan;
|
echan->ystride = data->width * pass->totchan;
|
||||||
pass->chan_id[(unsigned int)lookup[(unsigned int)echan->chan_id]] = echan->chan_id;
|
pass->chan_id[(uint)lookup[(uint)echan->chan_id]] = echan->chan_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { /* unknown */
|
else { /* unknown */
|
||||||
@ -1969,7 +1968,7 @@ bool IMB_exr_has_multilayer(void *handle)
|
|||||||
return imb_exr_is_multi(*data->ifile);
|
return imb_exr_is_multi(*data->ifile);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ImBuf *imb_load_openexr(const unsigned char *mem,
|
struct ImBuf *imb_load_openexr(const uchar *mem,
|
||||||
size_t size,
|
size_t size,
|
||||||
int flags,
|
int flags,
|
||||||
char colorspace[IM_MAX_SPACE])
|
char colorspace[IM_MAX_SPACE])
|
||||||
@ -1987,7 +1986,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
|
|||||||
try {
|
try {
|
||||||
bool is_multi;
|
bool is_multi;
|
||||||
|
|
||||||
membuf = new IMemStream((unsigned char *)mem, size);
|
membuf = new IMemStream((uchar *)mem, size);
|
||||||
file = new MultiPartInputFile(*membuf);
|
file = new MultiPartInputFile(*membuf);
|
||||||
|
|
||||||
Box2i dw = file->header(0).dataWindow();
|
Box2i dw = file->header(0).dataWindow();
|
||||||
@ -2209,7 +2208,7 @@ struct ImBuf *imb_load_filepath_thumbnail_openexr(const char *filepath,
|
|||||||
if (file->header().hasPreviewImage()) {
|
if (file->header().hasPreviewImage()) {
|
||||||
const Imf::PreviewImage &preview = file->header().previewImage();
|
const Imf::PreviewImage &preview = file->header().previewImage();
|
||||||
ImBuf *ibuf = IMB_allocFromBuffer(
|
ImBuf *ibuf = IMB_allocFromBuffer(
|
||||||
(unsigned int *)preview.pixels(), nullptr, preview.width(), preview.height(), 4);
|
(uint *)preview.pixels(), nullptr, preview.width(), preview.height(), 4);
|
||||||
delete file;
|
delete file;
|
||||||
delete stream;
|
delete stream;
|
||||||
IMB_flipy(ibuf);
|
IMB_flipy(ibuf);
|
||||||
|
@ -31,21 +31,21 @@
|
|||||||
#include "IMB_colormanagement_intern.h"
|
#include "IMB_colormanagement_intern.h"
|
||||||
|
|
||||||
typedef struct PNGReadStruct {
|
typedef struct PNGReadStruct {
|
||||||
const unsigned char *data;
|
const uchar *data;
|
||||||
unsigned int size;
|
uint size;
|
||||||
unsigned int seek;
|
uint seek;
|
||||||
} PNGReadStruct;
|
} PNGReadStruct;
|
||||||
|
|
||||||
static void ReadData(png_structp png_ptr, png_bytep data, png_size_t length);
|
static void ReadData(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||||
static void WriteData(png_structp png_ptr, png_bytep data, png_size_t length);
|
static void WriteData(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||||
static void Flush(png_structp png_ptr);
|
static void Flush(png_structp png_ptr);
|
||||||
|
|
||||||
BLI_INLINE unsigned short UPSAMPLE_8_TO_16(const unsigned char _val)
|
BLI_INLINE ushort UPSAMPLE_8_TO_16(const uchar _val)
|
||||||
{
|
{
|
||||||
return (_val << 8) + _val;
|
return (_val << 8) + _val;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool imb_is_a_png(const unsigned char *mem, size_t size)
|
bool imb_is_a_png(const uchar *mem, size_t size)
|
||||||
{
|
{
|
||||||
const int num_to_check = 8;
|
const int num_to_check = 8;
|
||||||
if (size < num_to_check) {
|
if (size < num_to_check) {
|
||||||
@ -102,7 +102,7 @@ static float channel_colormanage_noop(float value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* wrap to avoid macro calling functions multiple times */
|
/* wrap to avoid macro calling functions multiple times */
|
||||||
BLI_INLINE unsigned short ftoshort(float val)
|
BLI_INLINE ushort ftoshort(float val)
|
||||||
{
|
{
|
||||||
return unit_float_to_ushort_clamp(val);
|
return unit_float_to_ushort_clamp(val);
|
||||||
}
|
}
|
||||||
@ -112,9 +112,9 @@ bool imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags)
|
|||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
png_infop info_ptr;
|
png_infop info_ptr;
|
||||||
|
|
||||||
unsigned char *pixels = NULL;
|
uchar *pixels = NULL;
|
||||||
unsigned char *from, *to;
|
uchar *from, *to;
|
||||||
unsigned short *pixels16 = NULL, *to16;
|
ushort *pixels16 = NULL, *to16;
|
||||||
float *from_float, from_straight[4];
|
float *from_float, from_straight[4];
|
||||||
png_bytepp row_pointers = NULL;
|
png_bytepp row_pointers = NULL;
|
||||||
int i, bytesperpixel, color_type = PNG_COLOR_TYPE_GRAY;
|
int i, bytesperpixel, color_type = PNG_COLOR_TYPE_GRAY;
|
||||||
@ -169,10 +169,10 @@ bool imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags)
|
|||||||
/* copy image data */
|
/* copy image data */
|
||||||
num_bytes = ((size_t)ibuf->x) * ibuf->y * bytesperpixel;
|
num_bytes = ((size_t)ibuf->x) * ibuf->y * bytesperpixel;
|
||||||
if (is_16bit) {
|
if (is_16bit) {
|
||||||
pixels16 = MEM_mallocN(num_bytes * sizeof(unsigned short), "png 16bit pixels");
|
pixels16 = MEM_mallocN(num_bytes * sizeof(ushort), "png 16bit pixels");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pixels = MEM_mallocN(num_bytes * sizeof(unsigned char), "png 8bit pixels");
|
pixels = MEM_mallocN(num_bytes * sizeof(uchar), "png 8bit pixels");
|
||||||
}
|
}
|
||||||
if (pixels == NULL && pixels16 == NULL) {
|
if (pixels == NULL && pixels16 == NULL) {
|
||||||
printf(
|
printf(
|
||||||
@ -210,7 +210,7 @@ bool imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
from = (unsigned char *)ibuf->rect;
|
from = (uchar *)ibuf->rect;
|
||||||
to = pixels;
|
to = pixels;
|
||||||
from_float = ibuf->rect_float;
|
from_float = ibuf->rect_float;
|
||||||
to16 = pixels16;
|
to16 = pixels16;
|
||||||
@ -453,8 +453,8 @@ bool imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags)
|
|||||||
if (ibuf->ppm[0] > 0.0 && ibuf->ppm[1] > 0.0) {
|
if (ibuf->ppm[0] > 0.0 && ibuf->ppm[1] > 0.0) {
|
||||||
png_set_pHYs(png_ptr,
|
png_set_pHYs(png_ptr,
|
||||||
info_ptr,
|
info_ptr,
|
||||||
(unsigned int)(ibuf->ppm[0] + 0.5),
|
(uint)(ibuf->ppm[0] + 0.5),
|
||||||
(unsigned int)(ibuf->ppm[1] + 0.5),
|
(uint)(ibuf->ppm[1] + 0.5),
|
||||||
PNG_RESOLUTION_METER);
|
PNG_RESOLUTION_METER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,15 +468,15 @@ bool imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags)
|
|||||||
/* set the individual row-pointers to point at the correct offsets */
|
/* set the individual row-pointers to point at the correct offsets */
|
||||||
if (is_16bit) {
|
if (is_16bit) {
|
||||||
for (i = 0; i < ibuf->y; i++) {
|
for (i = 0; i < ibuf->y; i++) {
|
||||||
row_pointers[ibuf->y - 1 - i] = (png_bytep)((unsigned short *)pixels16 +
|
row_pointers[ibuf->y - 1 - i] = (png_bytep)((ushort *)pixels16 +
|
||||||
(((size_t)i) * ibuf->x) * bytesperpixel);
|
(((size_t)i) * ibuf->x) * bytesperpixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (i = 0; i < ibuf->y; i++) {
|
for (i = 0; i < ibuf->y; i++) {
|
||||||
row_pointers[ibuf->y - 1 - i] = (png_bytep)((unsigned char *)pixels +
|
row_pointers[ibuf->y - 1 - i] = (png_bytep)((uchar *)pixels + (((size_t)i) * ibuf->x) *
|
||||||
(((size_t)i) * ibuf->x) * bytesperpixel *
|
bytesperpixel *
|
||||||
sizeof(unsigned char));
|
sizeof(uchar));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,22 +521,22 @@ static void imb_png_error(png_structp UNUSED(png_ptr), png_const_charp message)
|
|||||||
fprintf(stderr, "libpng error: %s\n", message);
|
fprintf(stderr, "libpng error: %s\n", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
|
ImBuf *imb_loadpng(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
|
||||||
{
|
{
|
||||||
struct ImBuf *ibuf = NULL;
|
struct ImBuf *ibuf = NULL;
|
||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
png_infop info_ptr;
|
png_infop info_ptr;
|
||||||
unsigned char *pixels = NULL;
|
uchar *pixels = NULL;
|
||||||
unsigned short *pixels16 = NULL;
|
ushort *pixels16 = NULL;
|
||||||
png_bytepp row_pointers = NULL;
|
png_bytepp row_pointers = NULL;
|
||||||
png_uint_32 width, height;
|
png_uint_32 width, height;
|
||||||
int bit_depth, color_type;
|
int bit_depth, color_type;
|
||||||
PNGReadStruct ps;
|
PNGReadStruct ps;
|
||||||
|
|
||||||
unsigned char *from, *to;
|
uchar *from, *to;
|
||||||
unsigned short *from16;
|
ushort *from16;
|
||||||
float *to_float;
|
float *to_float;
|
||||||
unsigned int channels;
|
uint channels;
|
||||||
|
|
||||||
if (imb_is_a_png(mem, size) == 0) {
|
if (imb_is_a_png(mem, size) == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -718,7 +718,7 @@ ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colors
|
|||||||
else {
|
else {
|
||||||
imb_addrectImBuf(ibuf);
|
imb_addrectImBuf(ibuf);
|
||||||
|
|
||||||
pixels = imb_alloc_pixels(ibuf->x, ibuf->y, channels, sizeof(unsigned char), "pixels");
|
pixels = imb_alloc_pixels(ibuf->x, ibuf->y, channels, sizeof(uchar), "pixels");
|
||||||
if (pixels == NULL || ibuf->rect == NULL) {
|
if (pixels == NULL || ibuf->rect == NULL) {
|
||||||
printf("Cannot allocate pixels array\n");
|
printf("Cannot allocate pixels array\n");
|
||||||
longjmp(png_jmpbuf(png_ptr), 1);
|
longjmp(png_jmpbuf(png_ptr), 1);
|
||||||
@ -733,16 +733,16 @@ ImBuf *imb_loadpng(const unsigned char *mem, size_t size, int flags, char colors
|
|||||||
|
|
||||||
/* set the individual row-pointers to point at the correct offsets */
|
/* set the individual row-pointers to point at the correct offsets */
|
||||||
for (int i = 0; i < ibuf->y; i++) {
|
for (int i = 0; i < ibuf->y; i++) {
|
||||||
row_pointers[ibuf->y - 1 - i] = (png_bytep)((unsigned char *)pixels +
|
row_pointers[ibuf->y - 1 - i] = (png_bytep)((uchar *)pixels + (((size_t)i) * ibuf->x) *
|
||||||
(((size_t)i) * ibuf->x) * channels *
|
channels *
|
||||||
sizeof(unsigned char));
|
sizeof(uchar));
|
||||||
}
|
}
|
||||||
|
|
||||||
png_read_image(png_ptr, row_pointers);
|
png_read_image(png_ptr, row_pointers);
|
||||||
|
|
||||||
/* copy image data */
|
/* copy image data */
|
||||||
|
|
||||||
to = (unsigned char *)ibuf->rect;
|
to = (uchar *)ibuf->rect;
|
||||||
from = pixels;
|
from = pixels;
|
||||||
|
|
||||||
switch (channels) {
|
switch (channels) {
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#define BLU 2
|
#define BLU 2
|
||||||
#define EXP 3
|
#define EXP 3
|
||||||
#define COLXS 128
|
#define COLXS 128
|
||||||
typedef unsigned char RGBE[4];
|
typedef uchar RGBE[4];
|
||||||
typedef float fCOLOR[3];
|
typedef float fCOLOR[3];
|
||||||
|
|
||||||
/* copy source -> dest */
|
/* copy source -> dest */
|
||||||
@ -41,10 +41,7 @@ typedef float fCOLOR[3];
|
|||||||
(c2[RED] = c1[RED], c2[GRN] = c1[GRN], c2[BLU] = c1[BLU], c2[EXP] = c1[EXP])
|
(c2[RED] = c1[RED], c2[GRN] = c1[GRN], c2[BLU] = c1[BLU], c2[EXP] = c1[EXP])
|
||||||
|
|
||||||
/* read routines */
|
/* read routines */
|
||||||
static const unsigned char *oldreadcolrs(RGBE *scan,
|
static const uchar *oldreadcolrs(RGBE *scan, const uchar *mem, int xmax, const uchar *mem_eof)
|
||||||
const unsigned char *mem,
|
|
||||||
int xmax,
|
|
||||||
const unsigned char *mem_eof)
|
|
||||||
{
|
{
|
||||||
size_t i, rshift = 0, len = xmax;
|
size_t i, rshift = 0, len = xmax;
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
@ -72,10 +69,7 @@ static const unsigned char *oldreadcolrs(RGBE *scan,
|
|||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const unsigned char *freadcolrs(RGBE *scan,
|
static const uchar *freadcolrs(RGBE *scan, const uchar *mem, int xmax, const uchar *mem_eof)
|
||||||
const unsigned char *mem,
|
|
||||||
int xmax,
|
|
||||||
const unsigned char *mem_eof)
|
|
||||||
{
|
{
|
||||||
if (UNLIKELY(mem_eof - mem < 4)) {
|
if (UNLIKELY(mem_eof - mem < 4)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -118,7 +112,7 @@ static const unsigned char *freadcolrs(RGBE *scan,
|
|||||||
}
|
}
|
||||||
val = *mem++;
|
val = *mem++;
|
||||||
while (code--) {
|
while (code--) {
|
||||||
scan[j++][i] = (unsigned char)val;
|
scan[j++][i] = (uchar)val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -167,16 +161,16 @@ static void FLOAT2RGBE(const fCOLOR fcol, RGBE rgbe)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
d = (float)frexp(d, &e) * 256.0f / d;
|
d = (float)frexp(d, &e) * 256.0f / d;
|
||||||
rgbe[RED] = (unsigned char)(fcol[RED] * d);
|
rgbe[RED] = (uchar)(fcol[RED] * d);
|
||||||
rgbe[GRN] = (unsigned char)(fcol[GRN] * d);
|
rgbe[GRN] = (uchar)(fcol[GRN] * d);
|
||||||
rgbe[BLU] = (unsigned char)(fcol[BLU] * d);
|
rgbe[BLU] = (uchar)(fcol[BLU] * d);
|
||||||
rgbe[EXP] = (unsigned char)(e + COLXS);
|
rgbe[EXP] = (uchar)(e + COLXS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ImBuf read */
|
/* ImBuf read */
|
||||||
|
|
||||||
bool imb_is_a_hdr(const unsigned char *buf, const size_t size)
|
bool imb_is_a_hdr(const uchar *buf, const size_t size)
|
||||||
{
|
{
|
||||||
/* NOTE: `#?RADIANCE` is used by other programs such as `ImageMagik`,
|
/* NOTE: `#?RADIANCE` is used by other programs such as `ImageMagik`,
|
||||||
* Although there are some files in the wild that only use `#?` (from looking online).
|
* Although there are some files in the wild that only use `#?` (from looking online).
|
||||||
@ -187,17 +181,14 @@ bool imb_is_a_hdr(const unsigned char *buf, const size_t size)
|
|||||||
*
|
*
|
||||||
* See: http://paulbourke.net/dataformats/pic/
|
* See: http://paulbourke.net/dataformats/pic/
|
||||||
*/
|
*/
|
||||||
const unsigned char magic[2] = {'#', '?'};
|
const uchar magic[2] = {'#', '?'};
|
||||||
if (size < sizeof(magic)) {
|
if (size < sizeof(magic)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return memcmp(buf, magic, sizeof(magic)) == 0;
|
return memcmp(buf, magic, sizeof(magic)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ImBuf *imb_loadhdr(const unsigned char *mem,
|
struct ImBuf *imb_loadhdr(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
|
||||||
size_t size,
|
|
||||||
int flags,
|
|
||||||
char colorspace[IM_MAX_SPACE])
|
|
||||||
{
|
{
|
||||||
struct ImBuf *ibuf;
|
struct ImBuf *ibuf;
|
||||||
RGBE *sline;
|
RGBE *sline;
|
||||||
@ -205,7 +196,7 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem,
|
|||||||
float *rect_float;
|
float *rect_float;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
int width = 0, height = 0;
|
int width = 0, height = 0;
|
||||||
const unsigned char *ptr, *mem_eof = mem + size;
|
const uchar *ptr, *mem_eof = mem + size;
|
||||||
char oriY[3], oriX[3];
|
char oriY[3], oriX[3];
|
||||||
|
|
||||||
if (!imb_is_a_hdr(mem, size)) {
|
if (!imb_is_a_hdr(mem, size)) {
|
||||||
@ -246,7 +237,7 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem,
|
|||||||
* since the format uses RLE compression. Can cause excessive memory allocation to occur. */
|
* since the format uses RLE compression. Can cause excessive memory allocation to occur. */
|
||||||
|
|
||||||
/* find end of this line, data right behind it */
|
/* find end of this line, data right behind it */
|
||||||
ptr = (const unsigned char *)strchr((const char *)&mem[x], '\n');
|
ptr = (const uchar *)strchr((const char *)&mem[x], '\n');
|
||||||
if (ptr == NULL || ptr >= mem_eof) {
|
if (ptr == NULL || ptr >= mem_eof) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -306,7 +297,7 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem,
|
|||||||
|
|
||||||
/* ImBuf write */
|
/* ImBuf write */
|
||||||
static int fwritecolrs(
|
static int fwritecolrs(
|
||||||
FILE *file, int width, int channels, const unsigned char *ibufscan, const float *fpscan)
|
FILE *file, int width, int channels, const uchar *ibufscan, const float *fpscan)
|
||||||
{
|
{
|
||||||
int beg, c2, count = 0;
|
int beg, c2, count = 0;
|
||||||
fCOLOR fcol;
|
fCOLOR fcol;
|
||||||
@ -343,8 +334,8 @@ static int fwritecolrs(
|
|||||||
/* put magic header */
|
/* put magic header */
|
||||||
putc(2, file);
|
putc(2, file);
|
||||||
putc(2, file);
|
putc(2, file);
|
||||||
putc((unsigned char)(width >> 8), file);
|
putc((uchar)(width >> 8), file);
|
||||||
putc((unsigned char)(width & 255), file);
|
putc((uchar)(width & 255), file);
|
||||||
/* put components separately */
|
/* put components separately */
|
||||||
for (size_t i = 0; i < 4; i++) {
|
for (size_t i = 0; i < 4; i++) {
|
||||||
for (size_t j = 0; j < width; j += count) { /* find next run */
|
for (size_t j = 0; j < width; j += count) { /* find next run */
|
||||||
@ -362,8 +353,8 @@ static int fwritecolrs(
|
|||||||
c2 = j + 1;
|
c2 = j + 1;
|
||||||
while (rgbe_scan[c2++][i] == rgbe_scan[j][i]) {
|
while (rgbe_scan[c2++][i] == rgbe_scan[j][i]) {
|
||||||
if (c2 == beg) { /* short run */
|
if (c2 == beg) { /* short run */
|
||||||
putc((unsigned char)(128 + beg - j), file);
|
putc((uchar)(128 + beg - j), file);
|
||||||
putc((unsigned char)(rgbe_scan[j][i]), file);
|
putc((uchar)(rgbe_scan[j][i]), file);
|
||||||
j = beg;
|
j = beg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -373,13 +364,13 @@ static int fwritecolrs(
|
|||||||
if ((c2 = beg - j) > 128) {
|
if ((c2 = beg - j) > 128) {
|
||||||
c2 = 128;
|
c2 = 128;
|
||||||
}
|
}
|
||||||
putc((unsigned char)(c2), file);
|
putc((uchar)(c2), file);
|
||||||
while (c2--) {
|
while (c2--) {
|
||||||
putc(rgbe_scan[j++][i], file);
|
putc(rgbe_scan[j++][i], file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count >= MINRUN) { /* write out run */
|
if (count >= MINRUN) { /* write out run */
|
||||||
putc((unsigned char)(128 + count), file);
|
putc((uchar)(128 + count), file);
|
||||||
putc(rgbe_scan[beg][i], file);
|
putc(rgbe_scan[beg][i], file);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -411,7 +402,7 @@ bool imb_savehdr(struct ImBuf *ibuf, const char *filepath, int flags)
|
|||||||
FILE *file = BLI_fopen(filepath, "wb");
|
FILE *file = BLI_fopen(filepath, "wb");
|
||||||
float *fp = NULL;
|
float *fp = NULL;
|
||||||
size_t width = ibuf->x, height = ibuf->y;
|
size_t width = ibuf->x, height = ibuf->y;
|
||||||
unsigned char *cp = NULL;
|
uchar *cp = NULL;
|
||||||
|
|
||||||
(void)flags; /* unused */
|
(void)flags; /* unused */
|
||||||
|
|
||||||
@ -422,7 +413,7 @@ bool imb_savehdr(struct ImBuf *ibuf, const char *filepath, int flags)
|
|||||||
writeHeader(file, width, height);
|
writeHeader(file, width, height);
|
||||||
|
|
||||||
if (ibuf->rect) {
|
if (ibuf->rect) {
|
||||||
cp = (unsigned char *)ibuf->rect + ibuf->channels * (height - 1) * width;
|
cp = (uchar *)ibuf->rect + ibuf->channels * (height - 1) * width;
|
||||||
}
|
}
|
||||||
if (ibuf->rect_float) {
|
if (ibuf->rect_float) {
|
||||||
fp = ibuf->rect_float + ibuf->channels * (height - 1) * width;
|
fp = ibuf->rect_float + ibuf->channels * (height - 1) * width;
|
||||||
|
@ -81,11 +81,8 @@ static void imb_handle_alpha(ImBuf *ibuf,
|
|||||||
colormanage_imbuf_make_linear(ibuf, effective_colorspace);
|
colormanage_imbuf_make_linear(ibuf, effective_colorspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImBuf *IMB_ibImageFromMemory(const unsigned char *mem,
|
ImBuf *IMB_ibImageFromMemory(
|
||||||
size_t size,
|
const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
|
||||||
int flags,
|
|
||||||
char colorspace[IM_MAX_SPACE],
|
|
||||||
const char *descr)
|
|
||||||
{
|
{
|
||||||
ImBuf *ibuf;
|
ImBuf *ibuf;
|
||||||
const ImFileType *type;
|
const ImFileType *type;
|
||||||
@ -157,7 +154,7 @@ ImBuf *IMB_loadifffile(
|
|||||||
int file, const char *filepath, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
|
int file, const char *filepath, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
|
||||||
{
|
{
|
||||||
ImBuf *ibuf;
|
ImBuf *ibuf;
|
||||||
unsigned char *mem;
|
uchar *mem;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
if (file == -1) {
|
if (file == -1) {
|
||||||
@ -319,9 +316,9 @@ ImBuf *IMB_testiffname(const char *filepath, int flags)
|
|||||||
return ibuf;
|
return ibuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int *rect)
|
static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, uint *rect)
|
||||||
{
|
{
|
||||||
unsigned char *mem;
|
uchar *mem;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
if (file == -1) {
|
if (file == -1) {
|
||||||
@ -352,7 +349,7 @@ static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int
|
|||||||
imb_mmap_unlock();
|
imb_mmap_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void imb_loadtile(ImBuf *ibuf, int tx, int ty, unsigned int *rect)
|
void imb_loadtile(ImBuf *ibuf, int tx, int ty, uint *rect)
|
||||||
{
|
{
|
||||||
int file;
|
int file;
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@
|
|||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
void IMB_blend_color_byte(unsigned char dst[4],
|
void IMB_blend_color_byte(uchar dst[4],
|
||||||
const unsigned char src1[4],
|
const uchar src1[4],
|
||||||
const unsigned char src2[4],
|
const uchar src2[4],
|
||||||
IMB_BlendMode mode)
|
IMB_BlendMode mode)
|
||||||
{
|
{
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
@ -487,17 +487,15 @@ void IMB_rectcpy(ImBuf *dbuf,
|
|||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (*IMB_blend_func)(unsigned char *dst,
|
typedef void (*IMB_blend_func)(uchar *dst, const uchar *src1, const uchar *src2);
|
||||||
const unsigned char *src1,
|
|
||||||
const unsigned char *src2);
|
|
||||||
typedef void (*IMB_blend_func_float)(float *dst, const float *src1, const float *src2);
|
typedef void (*IMB_blend_func_float)(float *dst, const float *src1, const float *src2);
|
||||||
|
|
||||||
void IMB_rectblend(ImBuf *dbuf,
|
void IMB_rectblend(ImBuf *dbuf,
|
||||||
const ImBuf *obuf,
|
const ImBuf *obuf,
|
||||||
const ImBuf *sbuf,
|
const ImBuf *sbuf,
|
||||||
unsigned short *dmask,
|
ushort *dmask,
|
||||||
const unsigned short *curvemask,
|
const ushort *curvemask,
|
||||||
const unsigned short *texmask,
|
const ushort *texmask,
|
||||||
float mask_max,
|
float mask_max,
|
||||||
int destx,
|
int destx,
|
||||||
int desty,
|
int desty,
|
||||||
@ -510,11 +508,11 @@ void IMB_rectblend(ImBuf *dbuf,
|
|||||||
IMB_BlendMode mode,
|
IMB_BlendMode mode,
|
||||||
bool accumulate)
|
bool accumulate)
|
||||||
{
|
{
|
||||||
unsigned int *drect = NULL, *orect = NULL, *srect = NULL, *dr, * or, *sr;
|
uint *drect = NULL, *orect = NULL, *srect = NULL, *dr, * or, *sr;
|
||||||
float *drectf = NULL, *orectf = NULL, *srectf = NULL, *drf, *orf, *srf;
|
float *drectf = NULL, *orectf = NULL, *srectf = NULL, *drf, *orf, *srf;
|
||||||
const unsigned short *cmaskrect = curvemask, *cmr;
|
const ushort *cmaskrect = curvemask, *cmr;
|
||||||
unsigned short *dmaskrect = dmask, *dmr;
|
ushort *dmaskrect = dmask, *dmr;
|
||||||
const unsigned short *texmaskrect = texmask, *tmr;
|
const ushort *texmaskrect = texmask, *tmr;
|
||||||
int srcskip, destskip, origskip, x;
|
int srcskip, destskip, origskip, x;
|
||||||
IMB_blend_func func = NULL;
|
IMB_blend_func func = NULL;
|
||||||
IMB_blend_func_float func_float = NULL;
|
IMB_blend_func_float func_float = NULL;
|
||||||
@ -766,7 +764,7 @@ void IMB_rectblend(ImBuf *dbuf,
|
|||||||
if (dmaskrect) {
|
if (dmaskrect) {
|
||||||
dmr = dmaskrect;
|
dmr = dmaskrect;
|
||||||
for (x = width; x > 0; x--, dr++, or ++, sr++, dmr++, cmr++) {
|
for (x = width; x > 0; x--, dr++, or ++, sr++, dmr++, cmr++) {
|
||||||
unsigned char *src = (unsigned char *)sr;
|
uchar *src = (uchar *)sr;
|
||||||
float mask_lim = mask_max * (*cmr);
|
float mask_lim = mask_max * (*cmr);
|
||||||
|
|
||||||
if (texmaskrect) {
|
if (texmaskrect) {
|
||||||
@ -786,7 +784,7 @@ void IMB_rectblend(ImBuf *dbuf,
|
|||||||
mask = min_ff(mask, 65535.0);
|
mask = min_ff(mask, 65535.0);
|
||||||
|
|
||||||
if (mask > *dmr) {
|
if (mask > *dmr) {
|
||||||
unsigned char mask_src[4];
|
uchar mask_src[4];
|
||||||
|
|
||||||
*dmr = mask;
|
*dmr = mask;
|
||||||
|
|
||||||
@ -797,11 +795,11 @@ void IMB_rectblend(ImBuf *dbuf,
|
|||||||
if (mode == IMB_BLEND_INTERPOLATE) {
|
if (mode == IMB_BLEND_INTERPOLATE) {
|
||||||
mask_src[3] = src[3];
|
mask_src[3] = src[3];
|
||||||
blend_color_interpolate_byte(
|
blend_color_interpolate_byte(
|
||||||
(unsigned char *)dr, (unsigned char *) or, mask_src, mask / 65535.0f);
|
(uchar *)dr, (uchar *) or, mask_src, mask / 65535.0f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mask_src[3] = divide_round_i(src[3] * mask, 65535);
|
mask_src[3] = divide_round_i(src[3] * mask, 65535);
|
||||||
func((unsigned char *)dr, (unsigned char *) or, mask_src);
|
func((uchar *)dr, (uchar *) or, mask_src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -811,7 +809,7 @@ void IMB_rectblend(ImBuf *dbuf,
|
|||||||
/* no destination mask buffer, do regular blend with masktexture if present */
|
/* no destination mask buffer, do regular blend with masktexture if present */
|
||||||
else {
|
else {
|
||||||
for (x = width; x > 0; x--, dr++, or ++, sr++, cmr++) {
|
for (x = width; x > 0; x--, dr++, or ++, sr++, cmr++) {
|
||||||
unsigned char *src = (unsigned char *)sr;
|
uchar *src = (uchar *)sr;
|
||||||
float mask = (float)mask_max * ((float)(*cmr));
|
float mask = (float)mask_max * ((float)(*cmr));
|
||||||
|
|
||||||
if (texmaskrect) {
|
if (texmaskrect) {
|
||||||
@ -821,7 +819,7 @@ void IMB_rectblend(ImBuf *dbuf,
|
|||||||
mask = min_ff(mask, 65535.0);
|
mask = min_ff(mask, 65535.0);
|
||||||
|
|
||||||
if (src[3] && (mask > 0.0f)) {
|
if (src[3] && (mask > 0.0f)) {
|
||||||
unsigned char mask_src[4];
|
uchar mask_src[4];
|
||||||
|
|
||||||
mask_src[0] = src[0];
|
mask_src[0] = src[0];
|
||||||
mask_src[1] = src[1];
|
mask_src[1] = src[1];
|
||||||
@ -830,11 +828,11 @@ void IMB_rectblend(ImBuf *dbuf,
|
|||||||
if (mode == IMB_BLEND_INTERPOLATE) {
|
if (mode == IMB_BLEND_INTERPOLATE) {
|
||||||
mask_src[3] = src[3];
|
mask_src[3] = src[3];
|
||||||
blend_color_interpolate_byte(
|
blend_color_interpolate_byte(
|
||||||
(unsigned char *)dr, (unsigned char *) or, mask_src, mask / 65535.0f);
|
(uchar *)dr, (uchar *) or, mask_src, mask / 65535.0f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mask_src[3] = divide_round_i(src[3] * mask, 65535);
|
mask_src[3] = divide_round_i(src[3] * mask, 65535);
|
||||||
func((unsigned char *)dr, (unsigned char *) or, mask_src);
|
func((uchar *)dr, (uchar *) or, mask_src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -848,8 +846,8 @@ void IMB_rectblend(ImBuf *dbuf,
|
|||||||
else {
|
else {
|
||||||
/* regular blending */
|
/* regular blending */
|
||||||
for (x = width; x > 0; x--, dr++, or ++, sr++) {
|
for (x = width; x > 0; x--, dr++, or ++, sr++) {
|
||||||
if (((unsigned char *)sr)[3]) {
|
if (((uchar *)sr)[3]) {
|
||||||
func((unsigned char *)dr, (unsigned char *) or, (unsigned char *)sr);
|
func((uchar *)dr, (uchar *) or, (uchar *)sr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -956,8 +954,8 @@ void IMB_rectblend(ImBuf *dbuf,
|
|||||||
typedef struct RectBlendThreadData {
|
typedef struct RectBlendThreadData {
|
||||||
ImBuf *dbuf;
|
ImBuf *dbuf;
|
||||||
const ImBuf *obuf, *sbuf;
|
const ImBuf *obuf, *sbuf;
|
||||||
unsigned short *dmask;
|
ushort *dmask;
|
||||||
const unsigned short *curvemask, *texmask;
|
const ushort *curvemask, *texmask;
|
||||||
float mask_max;
|
float mask_max;
|
||||||
int destx, desty, origx, origy;
|
int destx, desty, origx, origy;
|
||||||
int srcx, srcy, width;
|
int srcx, srcy, width;
|
||||||
@ -991,9 +989,9 @@ static void rectblend_thread_do(void *data_v, int scanline)
|
|||||||
void IMB_rectblend_threaded(ImBuf *dbuf,
|
void IMB_rectblend_threaded(ImBuf *dbuf,
|
||||||
const ImBuf *obuf,
|
const ImBuf *obuf,
|
||||||
const ImBuf *sbuf,
|
const ImBuf *sbuf,
|
||||||
unsigned short *dmask,
|
ushort *dmask,
|
||||||
const unsigned short *curvemask,
|
const ushort *curvemask,
|
||||||
const unsigned short *texmask,
|
const ushort *texmask,
|
||||||
float mask_max,
|
float mask_max,
|
||||||
int destx,
|
int destx,
|
||||||
int desty,
|
int desty,
|
||||||
@ -1052,7 +1050,7 @@ void IMB_rectfill(ImBuf *drect, const float col[4])
|
|||||||
int num;
|
int num;
|
||||||
|
|
||||||
if (drect->rect) {
|
if (drect->rect) {
|
||||||
unsigned int *rrect = drect->rect;
|
uint *rrect = drect->rect;
|
||||||
char ccol[4];
|
char ccol[4];
|
||||||
|
|
||||||
ccol[0] = (int)(col[0] * 255);
|
ccol[0] = (int)(col[0] * 255);
|
||||||
@ -1062,7 +1060,7 @@ void IMB_rectfill(ImBuf *drect, const float col[4])
|
|||||||
|
|
||||||
num = drect->x * drect->y;
|
num = drect->x * drect->y;
|
||||||
for (; num > 0; num--) {
|
for (; num > 0; num--) {
|
||||||
*rrect++ = *((unsigned int *)ccol);
|
*rrect++ = *((uint *)ccol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1106,15 +1104,15 @@ void IMB_rectfill_area_replace(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char col_char[4] = {col[0] * 255, col[1] * 255, col[2] * 255, col[3] * 255};
|
uchar col_char[4] = {col[0] * 255, col[1] * 255, col[2] * 255, col[3] * 255};
|
||||||
|
|
||||||
for (int y = y1; y < y2; y++) {
|
for (int y = y1; y < y2; y++) {
|
||||||
for (int x = x1; x < x2; x++) {
|
for (int x = x1; x < x2; x++) {
|
||||||
size_t offset = ((size_t)ibuf->x) * y * 4 + 4 * x;
|
size_t offset = ((size_t)ibuf->x) * y * 4 + 4 * x;
|
||||||
|
|
||||||
if (ibuf->rect) {
|
if (ibuf->rect) {
|
||||||
unsigned char *rrect = (unsigned char *)ibuf->rect + offset;
|
uchar *rrect = (uchar *)ibuf->rect + offset;
|
||||||
memcpy(rrect, &col_char, sizeof(unsigned char) * 4);
|
memcpy(rrect, &col_char, sizeof(uchar) * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ibuf->rect_float) {
|
if (ibuf->rect_float) {
|
||||||
@ -1125,7 +1123,7 @@ void IMB_rectfill_area_replace(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void buf_rectfill_area(unsigned char *rect,
|
void buf_rectfill_area(uchar *rect,
|
||||||
float *rectf,
|
float *rectf,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
@ -1165,8 +1163,8 @@ void buf_rectfill_area(unsigned char *rect,
|
|||||||
aich = ai / 255.0f;
|
aich = ai / 255.0f;
|
||||||
|
|
||||||
if (rect) {
|
if (rect) {
|
||||||
unsigned char *pixel;
|
uchar *pixel;
|
||||||
unsigned char chr = 0, chg = 0, chb = 0;
|
uchar chr = 0, chg = 0, chb = 0;
|
||||||
float fr = 0, fg = 0, fb = 0;
|
float fr = 0, fg = 0, fb = 0;
|
||||||
|
|
||||||
const int alphaint = unit_float_to_uchar_clamp(a);
|
const int alphaint = unit_float_to_uchar_clamp(a);
|
||||||
@ -1247,16 +1245,8 @@ void IMB_rectfill_area(ImBuf *ibuf,
|
|||||||
if (!ibuf) {
|
if (!ibuf) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf_rectfill_area((unsigned char *)ibuf->rect,
|
buf_rectfill_area(
|
||||||
ibuf->rect_float,
|
(uchar *)ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, display, x1, y1, x2, y2);
|
||||||
ibuf->x,
|
|
||||||
ibuf->y,
|
|
||||||
col,
|
|
||||||
display,
|
|
||||||
x1,
|
|
||||||
y1,
|
|
||||||
x2,
|
|
||||||
y2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMB_rectfill_alpha(ImBuf *ibuf, const float value)
|
void IMB_rectfill_alpha(ImBuf *ibuf, const float value)
|
||||||
@ -1271,8 +1261,8 @@ void IMB_rectfill_alpha(ImBuf *ibuf, const float value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ibuf->rect) {
|
if (ibuf->rect) {
|
||||||
const unsigned char cvalue = value * 255;
|
const uchar cvalue = value * 255;
|
||||||
unsigned char *cbuf = ((unsigned char *)ibuf->rect) + 3;
|
uchar *cbuf = ((uchar *)ibuf->rect) + 3;
|
||||||
for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf += 4) {
|
for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf += 4) {
|
||||||
*cbuf = cvalue;
|
*cbuf = cvalue;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ void IMB_flipy(struct ImBuf *ibuf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ibuf->rect) {
|
if (ibuf->rect) {
|
||||||
unsigned int *top, *bottom, *line;
|
uint *top, *bottom, *line;
|
||||||
|
|
||||||
x_size = ibuf->x;
|
x_size = ibuf->x;
|
||||||
y_size = ibuf->y;
|
y_size = ibuf->y;
|
||||||
@ -88,7 +88,7 @@ void IMB_flipx(struct ImBuf *ibuf)
|
|||||||
for (yi = y - 1; yi >= 0; yi--) {
|
for (yi = y - 1; yi >= 0; yi--) {
|
||||||
const size_t x_offset = (size_t)x * yi;
|
const size_t x_offset = (size_t)x * yi;
|
||||||
for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) {
|
for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) {
|
||||||
SWAP(unsigned int, ibuf->rect[x_offset + xr], ibuf->rect[x_offset + xl]);
|
SWAP(uint, ibuf->rect[x_offset + xr], ibuf->rect[x_offset + xl]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,10 +324,9 @@ struct ImBuf *IMB_double_y(struct ImBuf *ibuf1)
|
|||||||
/* pretty much specific functions which converts uchar <-> ushort but assumes
|
/* pretty much specific functions which converts uchar <-> ushort but assumes
|
||||||
* ushort range of 255*255 which is more convenient here
|
* ushort range of 255*255 which is more convenient here
|
||||||
*/
|
*/
|
||||||
MINLINE void straight_uchar_to_premul_ushort(unsigned short result[4],
|
MINLINE void straight_uchar_to_premul_ushort(ushort result[4], const uchar color[4])
|
||||||
const unsigned char color[4])
|
|
||||||
{
|
{
|
||||||
unsigned short alpha = color[3];
|
ushort alpha = color[3];
|
||||||
|
|
||||||
result[0] = color[0] * alpha;
|
result[0] = color[0] * alpha;
|
||||||
result[1] = color[1] * alpha;
|
result[1] = color[1] * alpha;
|
||||||
@ -335,7 +334,7 @@ MINLINE void straight_uchar_to_premul_ushort(unsigned short result[4],
|
|||||||
result[3] = alpha * 256;
|
result[3] = alpha * 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
MINLINE void premul_ushort_to_straight_uchar(unsigned char *result, const unsigned short color[4])
|
MINLINE void premul_ushort_to_straight_uchar(uchar *result, const ushort color[4])
|
||||||
{
|
{
|
||||||
if (color[3] <= 255) {
|
if (color[3] <= 255) {
|
||||||
result[0] = unit_ushort_to_uchar(color[0]);
|
result[0] = unit_ushort_to_uchar(color[0]);
|
||||||
@ -344,7 +343,7 @@ MINLINE void premul_ushort_to_straight_uchar(unsigned char *result, const unsign
|
|||||||
result[3] = unit_ushort_to_uchar(color[3]);
|
result[3] = unit_ushort_to_uchar(color[3]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unsigned short alpha = color[3] / 256;
|
ushort alpha = color[3] / 256;
|
||||||
|
|
||||||
result[0] = unit_ushort_to_uchar((ushort)(color[0] / alpha * 256));
|
result[0] = unit_ushort_to_uchar((ushort)(color[0] / alpha * 256));
|
||||||
result[1] = unit_ushort_to_uchar((ushort)(color[1] / alpha * 256));
|
result[1] = unit_ushort_to_uchar((ushort)(color[1] / alpha * 256));
|
||||||
@ -373,25 +372,25 @@ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (do_rect) {
|
if (do_rect) {
|
||||||
unsigned char *cp1, *cp2, *dest;
|
uchar *cp1, *cp2, *dest;
|
||||||
|
|
||||||
cp1 = (unsigned char *)ibuf1->rect;
|
cp1 = (uchar *)ibuf1->rect;
|
||||||
dest = (unsigned char *)ibuf2->rect;
|
dest = (uchar *)ibuf2->rect;
|
||||||
|
|
||||||
for (y = ibuf2->y; y > 0; y--) {
|
for (y = ibuf2->y; y > 0; y--) {
|
||||||
cp2 = cp1 + (ibuf1->x << 2);
|
cp2 = cp1 + (ibuf1->x << 2);
|
||||||
for (x = ibuf2->x; x > 0; x--) {
|
for (x = ibuf2->x; x > 0; x--) {
|
||||||
unsigned short p1i[8], p2i[8], desti[4];
|
ushort p1i[8], p2i[8], desti[4];
|
||||||
|
|
||||||
straight_uchar_to_premul_ushort(p1i, cp1);
|
straight_uchar_to_premul_ushort(p1i, cp1);
|
||||||
straight_uchar_to_premul_ushort(p2i, cp2);
|
straight_uchar_to_premul_ushort(p2i, cp2);
|
||||||
straight_uchar_to_premul_ushort(p1i + 4, cp1 + 4);
|
straight_uchar_to_premul_ushort(p1i + 4, cp1 + 4);
|
||||||
straight_uchar_to_premul_ushort(p2i + 4, cp2 + 4);
|
straight_uchar_to_premul_ushort(p2i + 4, cp2 + 4);
|
||||||
|
|
||||||
desti[0] = ((unsigned int)p1i[0] + p2i[0] + p1i[4] + p2i[4]) >> 2;
|
desti[0] = ((uint)p1i[0] + p2i[0] + p1i[4] + p2i[4]) >> 2;
|
||||||
desti[1] = ((unsigned int)p1i[1] + p2i[1] + p1i[5] + p2i[5]) >> 2;
|
desti[1] = ((uint)p1i[1] + p2i[1] + p1i[5] + p2i[5]) >> 2;
|
||||||
desti[2] = ((unsigned int)p1i[2] + p2i[2] + p1i[6] + p2i[6]) >> 2;
|
desti[2] = ((uint)p1i[2] + p2i[2] + p1i[6] + p2i[6]) >> 2;
|
||||||
desti[3] = ((unsigned int)p1i[3] + p2i[3] + p1i[7] + p2i[7]) >> 2;
|
desti[3] = ((uint)p1i[3] + p2i[3] + p1i[7] + p2i[7]) >> 2;
|
||||||
|
|
||||||
premul_ushort_to_straight_uchar(dest, desti);
|
premul_ushort_to_straight_uchar(dest, desti);
|
||||||
|
|
||||||
@ -460,12 +459,8 @@ ImBuf *IMB_onehalf(struct ImBuf *ibuf1)
|
|||||||
|
|
||||||
/* q_scale_linear_interpolation helper functions */
|
/* q_scale_linear_interpolation helper functions */
|
||||||
|
|
||||||
static void enlarge_picture_byte(unsigned char *src,
|
static void enlarge_picture_byte(
|
||||||
unsigned char *dst,
|
uchar *src, uchar *dst, int src_width, int src_height, int dst_width, int dst_height)
|
||||||
int src_width,
|
|
||||||
int src_height,
|
|
||||||
int dst_width,
|
|
||||||
int dst_height)
|
|
||||||
{
|
{
|
||||||
double ratiox = (double)(dst_width - 1.0) / (double)(src_width - 1.001);
|
double ratiox = (double)(dst_width - 1.0) / (double)(src_width - 1.001);
|
||||||
double ratioy = (double)(dst_height - 1.0) / (double)(src_height - 1.001);
|
double ratioy = (double)(dst_height - 1.0) / (double)(src_height - 1.001);
|
||||||
@ -477,8 +472,8 @@ static void enlarge_picture_byte(unsigned char *src,
|
|||||||
|
|
||||||
y_src = 0;
|
y_src = 0;
|
||||||
for (y_dst = 0; y_dst < dst_height; y_dst++) {
|
for (y_dst = 0; y_dst < dst_height; y_dst++) {
|
||||||
unsigned char *line1 = src + (y_src >> 16) * 4 * src_width;
|
uchar *line1 = src + (y_src >> 16) * 4 * src_width;
|
||||||
unsigned char *line2 = line1 + 4 * src_width;
|
uchar *line2 = line1 + 4 * src_width;
|
||||||
uintptr_t weight1y = 65536 - (y_src & 0xffff);
|
uintptr_t weight1y = 65536 - (y_src & 0xffff);
|
||||||
uintptr_t weight2y = 65536 - weight1y;
|
uintptr_t weight2y = 65536 - weight1y;
|
||||||
|
|
||||||
@ -491,7 +486,7 @@ static void enlarge_picture_byte(unsigned char *src,
|
|||||||
uintptr_t weight1x = 65536 - (x_src & 0xffff);
|
uintptr_t weight1x = 65536 - (x_src & 0xffff);
|
||||||
uintptr_t weight2x = 65536 - weight1x;
|
uintptr_t weight2x = 65536 - weight1x;
|
||||||
|
|
||||||
unsigned long x = (x_src >> 16) * 4;
|
ulong x = (x_src >> 16) * 4;
|
||||||
|
|
||||||
*dst++ = ((((line1[x] * weight1y) >> 16) * weight1x) >> 16) +
|
*dst++ = ((((line1[x] * weight1y) >> 16) * weight1x) >> 16) +
|
||||||
((((line2[x] * weight2y) >> 16) * weight1x) >> 16) +
|
((((line2[x] * weight2y) >> 16) * weight1x) >> 16) +
|
||||||
@ -528,19 +523,15 @@ struct scale_outpix_byte {
|
|||||||
uintptr_t weight;
|
uintptr_t weight;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void shrink_picture_byte(unsigned char *src,
|
static void shrink_picture_byte(
|
||||||
unsigned char *dst,
|
uchar *src, uchar *dst, int src_width, int src_height, int dst_width, int dst_height)
|
||||||
int src_width,
|
|
||||||
int src_height,
|
|
||||||
int dst_width,
|
|
||||||
int dst_height)
|
|
||||||
{
|
{
|
||||||
double ratiox = (double)(dst_width) / (double)(src_width);
|
double ratiox = (double)(dst_width) / (double)(src_width);
|
||||||
double ratioy = (double)(dst_height) / (double)(src_height);
|
double ratioy = (double)(dst_height) / (double)(src_height);
|
||||||
uintptr_t x_src, dx_dst, x_dst;
|
uintptr_t x_src, dx_dst, x_dst;
|
||||||
uintptr_t y_src, dy_dst, y_dst;
|
uintptr_t y_src, dy_dst, y_dst;
|
||||||
intptr_t y_counter;
|
intptr_t y_counter;
|
||||||
unsigned char *dst_begin = dst;
|
uchar *dst_begin = dst;
|
||||||
|
|
||||||
struct scale_outpix_byte *dst_line1 = NULL;
|
struct scale_outpix_byte *dst_line1 = NULL;
|
||||||
struct scale_outpix_byte *dst_line2 = NULL;
|
struct scale_outpix_byte *dst_line2 = NULL;
|
||||||
@ -556,7 +547,7 @@ static void shrink_picture_byte(unsigned char *src,
|
|||||||
y_dst = 0;
|
y_dst = 0;
|
||||||
y_counter = 65536;
|
y_counter = 65536;
|
||||||
for (y_src = 0; y_src < src_height; y_src++) {
|
for (y_src = 0; y_src < src_height; y_src++) {
|
||||||
unsigned char *line = src + y_src * 4 * src_width;
|
uchar *line = src + y_src * 4 * src_width;
|
||||||
uintptr_t weight1y = 65535 - (y_dst & 0xffff);
|
uintptr_t weight1y = 65535 - (y_dst & 0xffff);
|
||||||
uintptr_t weight2y = 65535 - weight1y;
|
uintptr_t weight2y = 65535 - weight1y;
|
||||||
x_dst = 0;
|
x_dst = 0;
|
||||||
@ -643,12 +634,8 @@ static void shrink_picture_byte(unsigned char *src,
|
|||||||
MEM_freeN(dst_line2);
|
MEM_freeN(dst_line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void q_scale_byte(unsigned char *in,
|
static void q_scale_byte(
|
||||||
unsigned char *out,
|
uchar *in, uchar *out, int in_width, int in_height, int dst_width, int dst_height)
|
||||||
int in_width,
|
|
||||||
int in_height,
|
|
||||||
int dst_width,
|
|
||||||
int dst_height)
|
|
||||||
{
|
{
|
||||||
if (dst_width > in_width && dst_height > in_height) {
|
if (dst_width > in_width && dst_height > in_height) {
|
||||||
enlarge_picture_byte(in, out, in_width, in_height, dst_width, dst_height);
|
enlarge_picture_byte(in, out, in_width, in_height, dst_width, dst_height);
|
||||||
@ -868,12 +855,12 @@ static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ibuf->rect) {
|
if (ibuf->rect) {
|
||||||
unsigned char *newrect = MEM_mallocN(sizeof(int) * newx * newy, "q_scale rect");
|
uchar *newrect = MEM_mallocN(sizeof(int) * newx * newy, "q_scale rect");
|
||||||
q_scale_byte((unsigned char *)ibuf->rect, newrect, ibuf->x, ibuf->y, newx, newy);
|
q_scale_byte((uchar *)ibuf->rect, newrect, ibuf->x, ibuf->y, newx, newy);
|
||||||
|
|
||||||
imb_freerectImBuf(ibuf);
|
imb_freerectImBuf(ibuf);
|
||||||
ibuf->mall |= IB_rect;
|
ibuf->mall |= IB_rect;
|
||||||
ibuf->rect = (unsigned int *)newrect;
|
ibuf->rect = (uint *)newrect;
|
||||||
}
|
}
|
||||||
if (ibuf->rect_float) {
|
if (ibuf->rect_float) {
|
||||||
float *newrect = MEM_mallocN(sizeof(float[4]) * newx * newy, "q_scale rectfloat");
|
float *newrect = MEM_mallocN(sizeof(float[4]) * newx * newy, "q_scale rectfloat");
|
||||||
@ -1014,7 +1001,7 @@ static ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
|
|||||||
BLI_assert((uchar *)rect - ((uchar *)ibuf->rect) == rect_size); /* see bug T26502. */
|
BLI_assert((uchar *)rect - ((uchar *)ibuf->rect) == rect_size); /* see bug T26502. */
|
||||||
imb_freerectImBuf(ibuf);
|
imb_freerectImBuf(ibuf);
|
||||||
ibuf->mall |= IB_rect;
|
ibuf->mall |= IB_rect;
|
||||||
ibuf->rect = (unsigned int *)_newrect;
|
ibuf->rect = (uint *)_newrect;
|
||||||
}
|
}
|
||||||
if (do_float) {
|
if (do_float) {
|
||||||
// printf("%ld %ld\n", rectf - ibuf->rect_float, rect_size);
|
// printf("%ld %ld\n", rectf - ibuf->rect_float, rect_size);
|
||||||
@ -1156,7 +1143,7 @@ static ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
|
|||||||
BLI_assert((uchar *)rect - ((uchar *)ibuf->rect) == rect_size); /* see bug T26502. */
|
BLI_assert((uchar *)rect - ((uchar *)ibuf->rect) == rect_size); /* see bug T26502. */
|
||||||
imb_freerectImBuf(ibuf);
|
imb_freerectImBuf(ibuf);
|
||||||
ibuf->mall |= IB_rect;
|
ibuf->mall |= IB_rect;
|
||||||
ibuf->rect = (unsigned int *)_newrect;
|
ibuf->rect = (uint *)_newrect;
|
||||||
}
|
}
|
||||||
if (do_float) {
|
if (do_float) {
|
||||||
// printf("%ld %ld\n", rectf - ibuf->rect_float, rect_size);
|
// printf("%ld %ld\n", rectf - ibuf->rect_float, rect_size);
|
||||||
@ -1361,7 +1348,7 @@ static ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
|
|||||||
if (do_rect) {
|
if (do_rect) {
|
||||||
imb_freerectImBuf(ibuf);
|
imb_freerectImBuf(ibuf);
|
||||||
ibuf->mall |= IB_rect;
|
ibuf->mall |= IB_rect;
|
||||||
ibuf->rect = (unsigned int *)_newrect;
|
ibuf->rect = (uint *)_newrect;
|
||||||
}
|
}
|
||||||
if (do_float) {
|
if (do_float) {
|
||||||
imb_freerectfloatImBuf(ibuf);
|
imb_freerectfloatImBuf(ibuf);
|
||||||
@ -1564,7 +1551,7 @@ static ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
|
|||||||
if (do_rect) {
|
if (do_rect) {
|
||||||
imb_freerectImBuf(ibuf);
|
imb_freerectImBuf(ibuf);
|
||||||
ibuf->mall |= IB_rect;
|
ibuf->mall |= IB_rect;
|
||||||
ibuf->rect = (unsigned int *)_newrect;
|
ibuf->rect = (uint *)_newrect;
|
||||||
}
|
}
|
||||||
if (do_float) {
|
if (do_float) {
|
||||||
imb_freerectfloatImBuf(ibuf);
|
imb_freerectfloatImBuf(ibuf);
|
||||||
@ -1641,7 +1628,7 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
|
bool IMB_scaleImBuf(struct ImBuf *ibuf, uint newx, uint newy)
|
||||||
{
|
{
|
||||||
BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!");
|
BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!");
|
||||||
|
|
||||||
@ -1686,11 +1673,11 @@ struct imbufRGBA {
|
|||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
|
bool IMB_scalefastImBuf(struct ImBuf *ibuf, uint newx, uint newy)
|
||||||
{
|
{
|
||||||
BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!");
|
BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!");
|
||||||
|
|
||||||
unsigned int *rect, *_newrect, *newrect;
|
uint *rect, *_newrect, *newrect;
|
||||||
struct imbufRGBA *rectf, *_newrectf, *newrectf;
|
struct imbufRGBA *rectf, *_newrectf, *newrectf;
|
||||||
int x, y;
|
int x, y;
|
||||||
bool do_float = false, do_rect = false;
|
bool do_float = false, do_rect = false;
|
||||||
@ -1789,23 +1776,23 @@ bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy
|
|||||||
typedef struct ScaleTreadInitData {
|
typedef struct ScaleTreadInitData {
|
||||||
ImBuf *ibuf;
|
ImBuf *ibuf;
|
||||||
|
|
||||||
unsigned int newx;
|
uint newx;
|
||||||
unsigned int newy;
|
uint newy;
|
||||||
|
|
||||||
unsigned char *byte_buffer;
|
uchar *byte_buffer;
|
||||||
float *float_buffer;
|
float *float_buffer;
|
||||||
} ScaleTreadInitData;
|
} ScaleTreadInitData;
|
||||||
|
|
||||||
typedef struct ScaleThreadData {
|
typedef struct ScaleThreadData {
|
||||||
ImBuf *ibuf;
|
ImBuf *ibuf;
|
||||||
|
|
||||||
unsigned int newx;
|
uint newx;
|
||||||
unsigned int newy;
|
uint newy;
|
||||||
|
|
||||||
int start_line;
|
int start_line;
|
||||||
int tot_line;
|
int tot_line;
|
||||||
|
|
||||||
unsigned char *byte_buffer;
|
uchar *byte_buffer;
|
||||||
float *float_buffer;
|
float *float_buffer;
|
||||||
} ScaleThreadData;
|
} ScaleThreadData;
|
||||||
|
|
||||||
@ -1844,9 +1831,8 @@ static void *do_scale_thread(void *data_v)
|
|||||||
int offset = y * data->newx + x;
|
int offset = y * data->newx + x;
|
||||||
|
|
||||||
if (data->byte_buffer) {
|
if (data->byte_buffer) {
|
||||||
unsigned char *pixel = data->byte_buffer + 4 * offset;
|
uchar *pixel = data->byte_buffer + 4 * offset;
|
||||||
BLI_bilinear_interpolation_char(
|
BLI_bilinear_interpolation_char((uchar *)ibuf->rect, pixel, ibuf->x, ibuf->y, 4, u, v);
|
||||||
(unsigned char *)ibuf->rect, pixel, ibuf->x, ibuf->y, 4, u, v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->float_buffer) {
|
if (data->float_buffer) {
|
||||||
@ -1860,7 +1846,7 @@ static void *do_scale_thread(void *data_v)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMB_scaleImBuf_threaded(ImBuf *ibuf, unsigned int newx, unsigned int newy)
|
void IMB_scaleImBuf_threaded(ImBuf *ibuf, uint newx, uint newy)
|
||||||
{
|
{
|
||||||
BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!");
|
BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!");
|
||||||
|
|
||||||
@ -1893,7 +1879,7 @@ void IMB_scaleImBuf_threaded(ImBuf *ibuf, unsigned int newx, unsigned int newy)
|
|||||||
if (ibuf->rect) {
|
if (ibuf->rect) {
|
||||||
imb_freerectImBuf(ibuf);
|
imb_freerectImBuf(ibuf);
|
||||||
ibuf->mall |= IB_rect;
|
ibuf->mall |= IB_rect;
|
||||||
ibuf->rect = (unsigned int *)init_data.byte_buffer;
|
ibuf->rect = (uint *)init_data.byte_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ibuf->rect_float) {
|
if (ibuf->rect_float) {
|
||||||
|
@ -650,8 +650,8 @@ static void imb_stereo3d_squeeze_rect(
|
|||||||
IMB_stereo3d_write_dimensions(s3d->display_mode, false, x, y, &width, &height);
|
IMB_stereo3d_write_dimensions(s3d->display_mode, false, x, y, &width, &height);
|
||||||
ibuf = IMB_allocImBuf(width, height, channels, IB_rect);
|
ibuf = IMB_allocImBuf(width, height, channels, IB_rect);
|
||||||
|
|
||||||
IMB_buffer_byte_from_byte((unsigned char *)ibuf->rect,
|
IMB_buffer_byte_from_byte((uchar *)ibuf->rect,
|
||||||
(unsigned char *)rect,
|
(uchar *)rect,
|
||||||
IB_PROFILE_SRGB,
|
IB_PROFILE_SRGB,
|
||||||
IB_PROFILE_SRGB,
|
IB_PROFILE_SRGB,
|
||||||
false,
|
false,
|
||||||
@ -661,7 +661,7 @@ static void imb_stereo3d_squeeze_rect(
|
|||||||
width);
|
width);
|
||||||
|
|
||||||
IMB_scaleImBuf_threaded(ibuf, x, y);
|
IMB_scaleImBuf_threaded(ibuf, x, y);
|
||||||
memcpy(rect, ibuf->rect, x * y * sizeof(unsigned int));
|
memcpy(rect, ibuf->rect, x * y * sizeof(uint));
|
||||||
IMB_freeImBuf(ibuf);
|
IMB_freeImBuf(ibuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,18 +30,18 @@
|
|||||||
/***/
|
/***/
|
||||||
|
|
||||||
typedef struct TARGA {
|
typedef struct TARGA {
|
||||||
unsigned char numid;
|
uchar numid;
|
||||||
unsigned char maptyp;
|
uchar maptyp;
|
||||||
unsigned char imgtyp;
|
uchar imgtyp;
|
||||||
short maporig;
|
short maporig;
|
||||||
short mapsize;
|
short mapsize;
|
||||||
unsigned char mapbits;
|
uchar mapbits;
|
||||||
short xorig;
|
short xorig;
|
||||||
short yorig;
|
short yorig;
|
||||||
short xsize;
|
short xsize;
|
||||||
short ysize;
|
short ysize;
|
||||||
unsigned char pixsize;
|
uchar pixsize;
|
||||||
unsigned char imgdes;
|
uchar imgdes;
|
||||||
} TARGA;
|
} TARGA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +54,7 @@ typedef struct TARGA {
|
|||||||
|
|
||||||
/***/
|
/***/
|
||||||
|
|
||||||
static int tga_out1(unsigned int data, FILE *file)
|
static int tga_out1(uint data, FILE *file)
|
||||||
{
|
{
|
||||||
uchar *p;
|
uchar *p;
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ static int tga_out1(unsigned int data, FILE *file)
|
|||||||
return ~EOF;
|
return ~EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tga_out2(unsigned int data, FILE *file)
|
static int tga_out2(uint data, FILE *file)
|
||||||
{
|
{
|
||||||
uchar *p;
|
uchar *p;
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ static int tga_out2(unsigned int data, FILE *file)
|
|||||||
return ~EOF;
|
return ~EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tga_out3(unsigned int data, FILE *file)
|
static int tga_out3(uint data, FILE *file)
|
||||||
{
|
{
|
||||||
uchar *p;
|
uchar *p;
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ static int tga_out3(unsigned int data, FILE *file)
|
|||||||
return ~EOF;
|
return ~EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tga_out4(unsigned int data, FILE *file)
|
static int tga_out4(uint data, FILE *file)
|
||||||
{
|
{
|
||||||
uchar *p;
|
uchar *p;
|
||||||
|
|
||||||
@ -117,11 +117,11 @@ static int tga_out4(unsigned int data, FILE *file)
|
|||||||
return ~EOF;
|
return ~EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool makebody_tga(ImBuf *ibuf, FILE *file, int (*out)(unsigned int, FILE *))
|
static bool makebody_tga(ImBuf *ibuf, FILE *file, int (*out)(uint, FILE *))
|
||||||
{
|
{
|
||||||
int last, this;
|
int last, this;
|
||||||
int copy, bytes;
|
int copy, bytes;
|
||||||
unsigned int *rect, *rectstart, *temp;
|
uint *rect, *rectstart, *temp;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
for (y = 0; y < ibuf->y; y++) {
|
for (y = 0; y < ibuf->y; y++) {
|
||||||
@ -345,7 +345,7 @@ bool imb_savetarga(struct ImBuf *ibuf, const char *filepath, int UNUSED(flags))
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checktarga(TARGA *tga, const unsigned char *mem, const size_t size)
|
static bool checktarga(TARGA *tga, const uchar *mem, const size_t size)
|
||||||
{
|
{
|
||||||
if (size < TARGA_HEADER_SIZE) {
|
if (size < TARGA_HEADER_SIZE) {
|
||||||
return false;
|
return false;
|
||||||
@ -397,14 +397,14 @@ static bool checktarga(TARGA *tga, const unsigned char *mem, const size_t size)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool imb_is_a_targa(const unsigned char *buf, size_t size)
|
bool imb_is_a_targa(const uchar *buf, size_t size)
|
||||||
{
|
{
|
||||||
TARGA tga;
|
TARGA tga;
|
||||||
|
|
||||||
return checktarga(&tga, buf, size);
|
return checktarga(&tga, buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect)
|
static void complete_partial_load(struct ImBuf *ibuf, uint *rect)
|
||||||
{
|
{
|
||||||
int size = (ibuf->x * ibuf->y) - (rect - ibuf->rect);
|
int size = (ibuf->x * ibuf->y) - (rect - ibuf->rect);
|
||||||
if (size) {
|
if (size) {
|
||||||
@ -420,11 +420,11 @@ static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void decodetarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize)
|
static void decodetarga(struct ImBuf *ibuf, const uchar *mem, size_t mem_size, int psize)
|
||||||
{
|
{
|
||||||
const unsigned char *mem_end = mem + mem_size;
|
const uchar *mem_end = mem + mem_size;
|
||||||
int count, col, size;
|
int count, col, size;
|
||||||
unsigned int *rect;
|
uint *rect;
|
||||||
uchar *cp = (uchar *)&col;
|
uchar *cp = (uchar *)&col;
|
||||||
|
|
||||||
if (ibuf == NULL) {
|
if (ibuf == NULL) {
|
||||||
@ -545,11 +545,11 @@ partial_load:
|
|||||||
complete_partial_load(ibuf, rect);
|
complete_partial_load(ibuf, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ldtarga(struct ImBuf *ibuf, const unsigned char *mem, size_t mem_size, int psize)
|
static void ldtarga(struct ImBuf *ibuf, const uchar *mem, size_t mem_size, int psize)
|
||||||
{
|
{
|
||||||
const unsigned char *mem_end = mem + mem_size;
|
const uchar *mem_end = mem + mem_size;
|
||||||
int col, size;
|
int col, size;
|
||||||
unsigned int *rect;
|
uint *rect;
|
||||||
uchar *cp = (uchar *)&col;
|
uchar *cp = (uchar *)&col;
|
||||||
|
|
||||||
if (ibuf == NULL) {
|
if (ibuf == NULL) {
|
||||||
@ -609,15 +609,12 @@ partial_load:
|
|||||||
complete_partial_load(ibuf, rect);
|
complete_partial_load(ibuf, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImBuf *imb_loadtarga(const unsigned char *mem,
|
ImBuf *imb_loadtarga(const uchar *mem, size_t mem_size, int flags, char colorspace[IM_MAX_SPACE])
|
||||||
size_t mem_size,
|
|
||||||
int flags,
|
|
||||||
char colorspace[IM_MAX_SPACE])
|
|
||||||
{
|
{
|
||||||
TARGA tga;
|
TARGA tga;
|
||||||
struct ImBuf *ibuf;
|
struct ImBuf *ibuf;
|
||||||
int count, size;
|
int count, size;
|
||||||
unsigned int *rect, *cmap = NULL /*, mincol = 0*/, cmap_max = 0;
|
uint *rect, *cmap = NULL /*, mincol = 0*/, cmap_max = 0;
|
||||||
int32_t cp_data;
|
int32_t cp_data;
|
||||||
uchar *cp = (uchar *)&cp_data;
|
uchar *cp = (uchar *)&cp_data;
|
||||||
|
|
||||||
@ -650,7 +647,7 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
|
|||||||
/* Load color map. */
|
/* Load color map. */
|
||||||
// mincol = tga.maporig; /* UNUSED */
|
// mincol = tga.maporig; /* UNUSED */
|
||||||
cmap_max = tga.mapsize;
|
cmap_max = tga.mapsize;
|
||||||
cmap = MEM_callocN(sizeof(unsigned int) * cmap_max, "targa cmap");
|
cmap = MEM_callocN(sizeof(uint) * cmap_max, "targa cmap");
|
||||||
|
|
||||||
for (count = 0; count < cmap_max; count++) {
|
for (count = 0; count < cmap_max; count++) {
|
||||||
switch (tga.mapbits >> 3) {
|
switch (tga.mapbits >> 3) {
|
||||||
@ -753,7 +750,7 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tga.pixsize == 16) {
|
if (tga.pixsize == 16) {
|
||||||
unsigned int col;
|
uint col;
|
||||||
rect = ibuf->rect;
|
rect = ibuf->rect;
|
||||||
for (size = ibuf->x * ibuf->y; size > 0; size--, rect++) {
|
for (size = ibuf->x * ibuf->y; size > 0; size--, rect++) {
|
||||||
col = *rect;
|
col = *rect;
|
||||||
@ -773,10 +770,10 @@ ImBuf *imb_loadtarga(const unsigned char *mem,
|
|||||||
|
|
||||||
if (ELEM(tga.imgtyp, 3, 11)) {
|
if (ELEM(tga.imgtyp, 3, 11)) {
|
||||||
uchar *crect;
|
uchar *crect;
|
||||||
unsigned int *lrect, col;
|
uint *lrect, col;
|
||||||
|
|
||||||
crect = (uchar *)ibuf->rect;
|
crect = (uchar *)ibuf->rect;
|
||||||
lrect = (unsigned int *)ibuf->rect;
|
lrect = (uint *)ibuf->rect;
|
||||||
|
|
||||||
for (size = ibuf->x * ibuf->y; size > 0; size--) {
|
for (size = ibuf->x * ibuf->y; size > 0; size--) {
|
||||||
col = *lrect++;
|
col = *lrect++;
|
||||||
|
@ -136,7 +136,7 @@ typedef enum {
|
|||||||
|
|
||||||
/* Don't lose comment alignment. */
|
/* Don't lose comment alignment. */
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
static const unsigned char acceptable[96] = {
|
static const uchar acceptable[96] = {
|
||||||
/* A table of the ASCII chars from space (32) to DEL (127) */
|
/* A table of the ASCII chars from space (32) to DEL (127) */
|
||||||
/* ! " # $ % & ' ( ) * + , - . / */
|
/* ! " # $ % & ' ( ) * + , - . / */
|
||||||
0x00,0x3F,0x20,0x20,0x28,0x00,0x2C,0x3F,0x3F,0x3F,0x3F,0x2A,0x28,0x3F,0x3F,0x1C,
|
0x00,0x3F,0x20,0x20,0x28,0x00,0x2C,0x3F,0x3F,0x3F,0x3F,0x2A,0x28,0x3F,0x3F,0x1C,
|
||||||
@ -176,7 +176,7 @@ static void escape_uri_string(const char *string,
|
|||||||
escaped_string_size -= 1;
|
escaped_string_size -= 1;
|
||||||
|
|
||||||
for (q = escaped_string, p = string; (*p != '\0') && escaped_string_size; p++) {
|
for (q = escaped_string, p = string; (*p != '\0') && escaped_string_size; p++) {
|
||||||
c = (unsigned char)*p;
|
c = (uchar)*p;
|
||||||
|
|
||||||
if (!ACCEPTABLE(c)) {
|
if (!ACCEPTABLE(c)) {
|
||||||
if (escaped_string_size < 3) {
|
if (escaped_string_size < 3) {
|
||||||
@ -227,7 +227,7 @@ static bool uri_from_filename(const char *path, char *uri)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* on windows, using always uppercase drive/volume letter in uri */
|
/* on windows, using always uppercase drive/volume letter in uri */
|
||||||
vol[0] = (unsigned char)toupper(path[0]);
|
vol[0] = (uchar)toupper(path[0]);
|
||||||
vol[1] = ':';
|
vol[1] = ':';
|
||||||
vol[2] = '\0';
|
vol[2] = '\0';
|
||||||
strcat(orig_uri, vol);
|
strcat(orig_uri, vol);
|
||||||
@ -256,7 +256,7 @@ static bool thumbpathname_from_uri(
|
|||||||
|
|
||||||
if (r_name) {
|
if (r_name) {
|
||||||
char hexdigest[33];
|
char hexdigest[33];
|
||||||
unsigned char digest[16];
|
uchar digest[16];
|
||||||
BLI_hash_md5_buffer(uri, strlen(uri), digest);
|
BLI_hash_md5_buffer(uri, strlen(uri), digest);
|
||||||
hexdigest[0] = '\0';
|
hexdigest[0] = '\0';
|
||||||
BLI_snprintf(r_name, name_len, "%s.png", BLI_hash_md5_to_hexdigest(digest, hexdigest));
|
BLI_snprintf(r_name, name_len, "%s.png", BLI_hash_md5_to_hexdigest(digest, hexdigest));
|
||||||
|
@ -41,7 +41,7 @@ void IMB_thumb_ensure_translations(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ImBuf *IMB_thumb_load_font(const char *filepath, unsigned int x, unsigned int y)
|
struct ImBuf *IMB_thumb_load_font(const char *filepath, uint x, uint y)
|
||||||
{
|
{
|
||||||
const int font_size = y / 4;
|
const int font_size = y / 4;
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ struct ImBuf *IMB_thumb_load_font(const char *filepath, unsigned int x, unsigned
|
|||||||
ARRAY_SIZE(thumb_str),
|
ARRAY_SIZE(thumb_str),
|
||||||
font_color,
|
font_color,
|
||||||
font_size,
|
font_size,
|
||||||
(unsigned char *)ibuf->rect,
|
(uchar *)ibuf->rect,
|
||||||
ibuf->x,
|
ibuf->x,
|
||||||
ibuf->y,
|
ibuf->y,
|
||||||
ibuf->channels);
|
ibuf->channels);
|
||||||
@ -83,7 +83,7 @@ bool IMB_thumb_load_font_get_hash(char *r_hash)
|
|||||||
int draw_str_lines = ARRAY_SIZE(thumb_str);
|
int draw_str_lines = ARRAY_SIZE(thumb_str);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
unsigned char digest[16];
|
uchar digest[16];
|
||||||
|
|
||||||
len += BLI_strncpy_rlen(str + len, THUMB_DEFAULT_HASH, sizeof(buf) - len);
|
len += BLI_strncpy_rlen(str + len, THUMB_DEFAULT_HASH, sizeof(buf) - len);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ static void imb_tiff_DummyUnmapProc(thandle_t fd, tdata_t base, toff_t size);
|
|||||||
/** Structure for in-memory TIFF file. */
|
/** Structure for in-memory TIFF file. */
|
||||||
typedef struct ImbTIFFMemFile {
|
typedef struct ImbTIFFMemFile {
|
||||||
/** Location of first byte of TIFF file. */
|
/** Location of first byte of TIFF file. */
|
||||||
const unsigned char *mem;
|
const uchar *mem;
|
||||||
/** Current offset within the file. */
|
/** Current offset within the file. */
|
||||||
toff_t offset;
|
toff_t offset;
|
||||||
/** Size of the TIFF file. */
|
/** Size of the TIFF file. */
|
||||||
@ -262,7 +262,7 @@ static toff_t imb_tiff_SizeProc(thandle_t handle)
|
|||||||
return (toff_t)(mfile->size);
|
return (toff_t)(mfile->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, const unsigned char *mem, size_t size)
|
static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, const uchar *mem, size_t size)
|
||||||
{
|
{
|
||||||
/* open the TIFF client layer interface to the in-memory file */
|
/* open the TIFF client layer interface to the in-memory file */
|
||||||
memFile->mem = mem;
|
memFile->mem = mem;
|
||||||
@ -303,7 +303,7 @@ static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, const unsigned char *
|
|||||||
* hence my manual comparison. - Jonathan Merritt (lancelet) 4th Sept 2005.
|
* hence my manual comparison. - Jonathan Merritt (lancelet) 4th Sept 2005.
|
||||||
*/
|
*/
|
||||||
#define IMB_TIFF_NCB 4 /* number of comparison bytes used */
|
#define IMB_TIFF_NCB 4 /* number of comparison bytes used */
|
||||||
bool imb_is_a_tiff(const unsigned char *buf, size_t size)
|
bool imb_is_a_tiff(const uchar *buf, size_t size)
|
||||||
{
|
{
|
||||||
const char big_endian[IMB_TIFF_NCB] = {0x4d, 0x4d, 0x00, 0x2a};
|
const char big_endian[IMB_TIFF_NCB] = {0x4d, 0x4d, 0x00, 0x2a};
|
||||||
const char lil_endian[IMB_TIFF_NCB] = {0x49, 0x49, 0x2a, 0x00};
|
const char lil_endian[IMB_TIFF_NCB] = {0x49, 0x49, 0x2a, 0x00};
|
||||||
@ -315,10 +315,7 @@ bool imb_is_a_tiff(const unsigned char *buf, size_t size)
|
|||||||
(memcmp(lil_endian, buf, IMB_TIFF_NCB) == 0));
|
(memcmp(lil_endian, buf, IMB_TIFF_NCB) == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scanline_contig_16bit(float *rectf,
|
static void scanline_contig_16bit(float *rectf, const ushort *sbuf, int scanline_w, int spp)
|
||||||
const unsigned short *sbuf,
|
|
||||||
int scanline_w,
|
|
||||||
int spp)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < scanline_w; i++) {
|
for (i = 0; i < scanline_w; i++) {
|
||||||
@ -340,10 +337,7 @@ static void scanline_contig_32bit(float *rectf, const float *fbuf, int scanline_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scanline_separate_16bit(float *rectf,
|
static void scanline_separate_16bit(float *rectf, const ushort *sbuf, int scanline_w, int chan)
|
||||||
const unsigned short *sbuf,
|
|
||||||
int scanline_w,
|
|
||||||
int chan)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < scanline_w; i++) {
|
for (i = 0; i < scanline_w; i++) {
|
||||||
@ -392,7 +386,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image)
|
|||||||
size_t scanline;
|
size_t scanline;
|
||||||
int ib_flag = 0, row, chan;
|
int ib_flag = 0, row, chan;
|
||||||
float *fbuf = NULL;
|
float *fbuf = NULL;
|
||||||
unsigned short *sbuf = NULL;
|
ushort *sbuf = NULL;
|
||||||
|
|
||||||
TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bitspersample);
|
TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bitspersample);
|
||||||
TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp); /* number of 'channels' */
|
TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp); /* number of 'channels' */
|
||||||
@ -410,7 +404,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image)
|
|||||||
* So let's keep this thing here for until proper solution is found (sergey)
|
* So let's keep this thing here for until proper solution is found (sergey)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned short extraSampleTypes[1];
|
ushort extraSampleTypes[1];
|
||||||
extraSampleTypes[0] = EXTRASAMPLE_ASSOCALPHA;
|
extraSampleTypes[0] = EXTRASAMPLE_ASSOCALPHA;
|
||||||
TIFFSetField(image, TIFFTAG_EXTRASAMPLES, 1, extraSampleTypes);
|
TIFFSetField(image, TIFFTAG_EXTRASAMPLES, 1, extraSampleTypes);
|
||||||
}
|
}
|
||||||
@ -428,7 +422,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image)
|
|||||||
}
|
}
|
||||||
else if (bitspersample == 16) {
|
else if (bitspersample == 16) {
|
||||||
ib_flag = IB_rectfloat;
|
ib_flag = IB_rectfloat;
|
||||||
sbuf = (unsigned short *)_TIFFmalloc(scanline);
|
sbuf = (ushort *)_TIFFmalloc(scanline);
|
||||||
if (!sbuf) {
|
if (!sbuf) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -539,10 +533,7 @@ void imb_inittiff(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImBuf *imb_loadtiff(const unsigned char *mem,
|
ImBuf *imb_loadtiff(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
|
||||||
size_t size,
|
|
||||||
int flags,
|
|
||||||
char colorspace[IM_MAX_SPACE])
|
|
||||||
{
|
{
|
||||||
TIFF *image = NULL;
|
TIFF *image = NULL;
|
||||||
ImBuf *ibuf = NULL, *hbuf;
|
ImBuf *ibuf = NULL, *hbuf;
|
||||||
@ -589,7 +580,7 @@ ImBuf *imb_loadtiff(const unsigned char *mem,
|
|||||||
/* get alpha mode from file header */
|
/* get alpha mode from file header */
|
||||||
if (flags & IB_alphamode_detect) {
|
if (flags & IB_alphamode_detect) {
|
||||||
if (spp == 4) {
|
if (spp == 4) {
|
||||||
unsigned short extra, *extraSampleTypes;
|
ushort extra, *extraSampleTypes;
|
||||||
const int found = TIFFGetField(image, TIFFTAG_EXTRASAMPLES, &extra, &extraSampleTypes);
|
const int found = TIFFGetField(image, TIFFTAG_EXTRASAMPLES, &extra, &extraSampleTypes);
|
||||||
|
|
||||||
if (found && (extraSampleTypes[0] == EXTRASAMPLE_ASSOCALPHA)) {
|
if (found && (extraSampleTypes[0] == EXTRASAMPLE_ASSOCALPHA)) {
|
||||||
@ -661,8 +652,7 @@ ImBuf *imb_loadtiff(const unsigned char *mem,
|
|||||||
return ibuf;
|
return ibuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void imb_loadtiletiff(
|
void imb_loadtiletiff(ImBuf *ibuf, const uchar *mem, size_t size, int tx, int ty, uint *rect)
|
||||||
ImBuf *ibuf, const unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect)
|
|
||||||
{
|
{
|
||||||
TIFF *image = NULL;
|
TIFF *image = NULL;
|
||||||
uint32_t width, height;
|
uint32_t width, height;
|
||||||
@ -723,9 +713,9 @@ bool imb_savetiff(ImBuf *ibuf, const char *filepath, int flags)
|
|||||||
TIFF *image = NULL;
|
TIFF *image = NULL;
|
||||||
uint16_t samplesperpixel, bitspersample;
|
uint16_t samplesperpixel, bitspersample;
|
||||||
size_t npixels;
|
size_t npixels;
|
||||||
unsigned char *pixels = NULL;
|
uchar *pixels = NULL;
|
||||||
unsigned char *from = NULL, *to = NULL;
|
uchar *from = NULL, *to = NULL;
|
||||||
unsigned short *pixels16 = NULL, *to16 = NULL;
|
ushort *pixels16 = NULL, *to16 = NULL;
|
||||||
float *fromf = NULL;
|
float *fromf = NULL;
|
||||||
float xres, yres;
|
float xres, yres;
|
||||||
int x, y, from_i, to_i, i;
|
int x, y, from_i, to_i, i;
|
||||||
@ -786,10 +776,10 @@ bool imb_savetiff(ImBuf *ibuf, const char *filepath, int flags)
|
|||||||
/* allocate array for pixel data */
|
/* allocate array for pixel data */
|
||||||
npixels = ibuf->x * ibuf->y;
|
npixels = ibuf->x * ibuf->y;
|
||||||
if (bitspersample == 16) {
|
if (bitspersample == 16) {
|
||||||
pixels16 = (unsigned short *)_TIFFmalloc(npixels * samplesperpixel * sizeof(unsigned short));
|
pixels16 = (ushort *)_TIFFmalloc(npixels * samplesperpixel * sizeof(ushort));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pixels = (unsigned char *)_TIFFmalloc(npixels * samplesperpixel * sizeof(unsigned char));
|
pixels = (uchar *)_TIFFmalloc(npixels * samplesperpixel * sizeof(uchar));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixels == NULL && pixels16 == NULL) {
|
if (pixels == NULL && pixels16 == NULL) {
|
||||||
@ -804,7 +794,7 @@ bool imb_savetiff(ImBuf *ibuf, const char *filepath, int flags)
|
|||||||
to16 = pixels16;
|
to16 = pixels16;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
from = (unsigned char *)ibuf->rect;
|
from = (uchar *)ibuf->rect;
|
||||||
to = pixels;
|
to = pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -813,7 +803,7 @@ bool imb_savetiff(ImBuf *ibuf, const char *filepath, int flags)
|
|||||||
TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
|
TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
|
||||||
|
|
||||||
if (samplesperpixel == 4) {
|
if (samplesperpixel == 4) {
|
||||||
unsigned short extraSampleTypes[1];
|
ushort extraSampleTypes[1];
|
||||||
|
|
||||||
if (bitspersample == 16) {
|
if (bitspersample == 16) {
|
||||||
extraSampleTypes[0] = EXTRASAMPLE_ASSOCALPHA;
|
extraSampleTypes[0] = EXTRASAMPLE_ASSOCALPHA;
|
||||||
@ -908,7 +898,7 @@ bool imb_savetiff(ImBuf *ibuf, const char *filepath, int flags)
|
|||||||
TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
|
TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
|
||||||
if (TIFFWriteEncodedStrip(image,
|
if (TIFFWriteEncodedStrip(image,
|
||||||
0,
|
0,
|
||||||
(bitspersample == 16) ? (unsigned char *)pixels16 : pixels,
|
(bitspersample == 16) ? (uchar *)pixels16 : pixels,
|
||||||
(size_t)ibuf->x * ibuf->y * samplesperpixel * bitspersample / 8) ==
|
(size_t)ibuf->x * ibuf->y * samplesperpixel * bitspersample / 8) ==
|
||||||
-1) {
|
-1) {
|
||||||
fprintf(stderr, "imb_savetiff: Could not write encoded TIFF.\n");
|
fprintf(stderr, "imb_savetiff: Could not write encoded TIFF.\n");
|
||||||
|
@ -147,7 +147,7 @@ class NoDiscard : public BaseDiscard {
|
|||||||
template<
|
template<
|
||||||
/**
|
/**
|
||||||
* \brief Kind of buffer.
|
* \brief Kind of buffer.
|
||||||
* Possible options: float, unsigned char.
|
* Possible options: float, uchar.
|
||||||
*/
|
*/
|
||||||
typename StorageType = float,
|
typename StorageType = float,
|
||||||
|
|
||||||
@ -170,10 +170,9 @@ class PixelPointer {
|
|||||||
if constexpr (std::is_same_v<StorageType, float>) {
|
if constexpr (std::is_same_v<StorageType, float>) {
|
||||||
pointer = image_buffer->rect_float + offset;
|
pointer = image_buffer->rect_float + offset;
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_same_v<StorageType, unsigned char>) {
|
else if constexpr (std::is_same_v<StorageType, uchar>) {
|
||||||
pointer = const_cast<unsigned char *>(
|
pointer = const_cast<uchar *>(
|
||||||
static_cast<const unsigned char *>(static_cast<const void *>(image_buffer->rect)) +
|
static_cast<const uchar *>(static_cast<const void *>(image_buffer->rect)) + offset);
|
||||||
offset);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pointer = nullptr;
|
pointer = nullptr;
|
||||||
@ -264,7 +263,7 @@ template<
|
|||||||
/** \brief Interpolation mode to use when sampling. */
|
/** \brief Interpolation mode to use when sampling. */
|
||||||
eIMBInterpolationFilterMode Filter,
|
eIMBInterpolationFilterMode Filter,
|
||||||
|
|
||||||
/** \brief storage type of a single pixel channel (unsigned char or float). */
|
/** \brief storage type of a single pixel channel (uchar or float). */
|
||||||
typename StorageType,
|
typename StorageType,
|
||||||
/**
|
/**
|
||||||
* \brief number of channels if the image to read.
|
* \brief number of channels if the image to read.
|
||||||
@ -294,14 +293,14 @@ class Sampler {
|
|||||||
const float wrapped_v = uv_wrapper.modify_v(source, v);
|
const float wrapped_v = uv_wrapper.modify_v(source, v);
|
||||||
bilinear_interpolation_color_fl(source, nullptr, r_sample.data(), wrapped_u, wrapped_v);
|
bilinear_interpolation_color_fl(source, nullptr, r_sample.data(), wrapped_u, wrapped_v);
|
||||||
}
|
}
|
||||||
else if constexpr (Filter == IMB_FILTER_NEAREST &&
|
else if constexpr (Filter == IMB_FILTER_NEAREST && std::is_same_v<StorageType, uchar> &&
|
||||||
std::is_same_v<StorageType, unsigned char> && NumChannels == 4) {
|
NumChannels == 4) {
|
||||||
const float wrapped_u = uv_wrapper.modify_u(source, u);
|
const float wrapped_u = uv_wrapper.modify_u(source, u);
|
||||||
const float wrapped_v = uv_wrapper.modify_v(source, v);
|
const float wrapped_v = uv_wrapper.modify_v(source, v);
|
||||||
nearest_interpolation_color_char(source, r_sample.data(), nullptr, wrapped_u, wrapped_v);
|
nearest_interpolation_color_char(source, r_sample.data(), nullptr, wrapped_u, wrapped_v);
|
||||||
}
|
}
|
||||||
else if constexpr (Filter == IMB_FILTER_BILINEAR &&
|
else if constexpr (Filter == IMB_FILTER_BILINEAR && std::is_same_v<StorageType, uchar> &&
|
||||||
std::is_same_v<StorageType, unsigned char> && NumChannels == 4) {
|
NumChannels == 4) {
|
||||||
const float wrapped_u = uv_wrapper.modify_u(source, u);
|
const float wrapped_u = uv_wrapper.modify_u(source, u);
|
||||||
const float wrapped_v = uv_wrapper.modify_v(source, v);
|
const float wrapped_v = uv_wrapper.modify_v(source, v);
|
||||||
bilinear_interpolation_color_char(source, r_sample.data(), nullptr, wrapped_u, wrapped_v);
|
bilinear_interpolation_color_char(source, r_sample.data(), nullptr, wrapped_u, wrapped_v);
|
||||||
@ -374,7 +373,7 @@ class Sampler {
|
|||||||
*
|
*
|
||||||
* Template class to convert and store a sample in a PixelPointer.
|
* Template class to convert and store a sample in a PixelPointer.
|
||||||
* It supports:
|
* It supports:
|
||||||
* - 4 channel unsigned char -> 4 channel unsigned char.
|
* - 4 channel uchar -> 4 channel uchar.
|
||||||
* - 4 channel float -> 4 channel float.
|
* - 4 channel float -> 4 channel float.
|
||||||
* - 3 channel float -> 4 channel float.
|
* - 3 channel float -> 4 channel float.
|
||||||
* - 2 channel float -> 4 channel float.
|
* - 2 channel float -> 4 channel float.
|
||||||
@ -392,7 +391,7 @@ class ChannelConverter {
|
|||||||
*/
|
*/
|
||||||
void convert_and_store(const SampleType &sample, PixelType &pixel_pointer)
|
void convert_and_store(const SampleType &sample, PixelType &pixel_pointer)
|
||||||
{
|
{
|
||||||
if constexpr (std::is_same_v<StorageType, unsigned char>) {
|
if constexpr (std::is_same_v<StorageType, uchar>) {
|
||||||
BLI_STATIC_ASSERT(SourceNumChannels == 4, "Unsigned chars always have 4 channels.");
|
BLI_STATIC_ASSERT(SourceNumChannels == 4, "Unsigned chars always have 4 channels.");
|
||||||
BLI_STATIC_ASSERT(DestinationNumChannels == 4, "Unsigned chars always have 4 channels.");
|
BLI_STATIC_ASSERT(DestinationNumChannels == 4, "Unsigned chars always have 4 channels.");
|
||||||
|
|
||||||
@ -550,8 +549,8 @@ static void transform_threaded(TransformUserData *user_data, const eIMBTransform
|
|||||||
scanline_func = get_scanline_function<Filter>(user_data, mode);
|
scanline_func = get_scanline_function<Filter>(user_data, mode);
|
||||||
}
|
}
|
||||||
else if (user_data->dst->rect && user_data->src->rect) {
|
else if (user_data->dst->rect && user_data->src->rect) {
|
||||||
/* Number of channels is always 4 when using unsigned char buffers (sRGB + straight alpha). */
|
/* Number of channels is always 4 when using uchar buffers (sRGB + straight alpha). */
|
||||||
scanline_func = get_scanline_function<Filter, unsigned char, 4, 4>(mode);
|
scanline_func = get_scanline_function<Filter, uchar, 4, 4>(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scanline_func != nullptr) {
|
if (scanline_func != nullptr) {
|
||||||
|
@ -106,8 +106,7 @@ const char *imb_ext_audio[] = {
|
|||||||
/* Increased from 32 to 64 because of the bitmaps header size. */
|
/* Increased from 32 to 64 because of the bitmaps header size. */
|
||||||
#define HEADER_SIZE 64
|
#define HEADER_SIZE 64
|
||||||
|
|
||||||
static ssize_t imb_ispic_read_header_from_filepath(const char *filepath,
|
static ssize_t imb_ispic_read_header_from_filepath(const char *filepath, uchar buf[HEADER_SIZE])
|
||||||
unsigned char buf[HEADER_SIZE])
|
|
||||||
{
|
{
|
||||||
BLI_stat_t st;
|
BLI_stat_t st;
|
||||||
int fp;
|
int fp;
|
||||||
@ -135,7 +134,7 @@ static ssize_t imb_ispic_read_header_from_filepath(const char *filepath,
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IMB_ispic_type_from_memory(const unsigned char *buf, const size_t buf_size)
|
int IMB_ispic_type_from_memory(const uchar *buf, const size_t buf_size)
|
||||||
{
|
{
|
||||||
for (const ImFileType *type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
|
for (const ImFileType *type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
|
||||||
if (type->is_a != NULL) {
|
if (type->is_a != NULL) {
|
||||||
@ -150,7 +149,7 @@ int IMB_ispic_type_from_memory(const unsigned char *buf, const size_t buf_size)
|
|||||||
|
|
||||||
int IMB_ispic_type(const char *filepath)
|
int IMB_ispic_type(const char *filepath)
|
||||||
{
|
{
|
||||||
unsigned char buf[HEADER_SIZE];
|
uchar buf[HEADER_SIZE];
|
||||||
const ssize_t buf_size = imb_ispic_read_header_from_filepath(filepath, buf);
|
const ssize_t buf_size = imb_ispic_read_header_from_filepath(filepath, buf);
|
||||||
if (buf_size <= 0) {
|
if (buf_size <= 0) {
|
||||||
return IMB_FTYPE_NONE;
|
return IMB_FTYPE_NONE;
|
||||||
@ -160,7 +159,7 @@ int IMB_ispic_type(const char *filepath)
|
|||||||
|
|
||||||
bool IMB_ispic_type_matches(const char *filepath, int filetype)
|
bool IMB_ispic_type_matches(const char *filepath, int filetype)
|
||||||
{
|
{
|
||||||
unsigned char buf[HEADER_SIZE];
|
uchar buf[HEADER_SIZE];
|
||||||
const ssize_t buf_size = imb_ispic_read_header_from_filepath(filepath, buf);
|
const ssize_t buf_size = imb_ispic_read_header_from_filepath(filepath, buf);
|
||||||
if (buf_size <= 0) {
|
if (buf_size <= 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -251,7 +250,7 @@ const char *IMB_ffmpeg_last_error(void)
|
|||||||
static int isffmpeg(const char *filepath)
|
static int isffmpeg(const char *filepath)
|
||||||
{
|
{
|
||||||
AVFormatContext *pFormatCtx = NULL;
|
AVFormatContext *pFormatCtx = NULL;
|
||||||
unsigned int i;
|
uint i;
|
||||||
int videoStream;
|
int videoStream;
|
||||||
const AVCodec *pCodec;
|
const AVCodec *pCodec;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
bool imb_is_a_webp(const unsigned char *buf, size_t size)
|
bool imb_is_a_webp(const uchar *buf, size_t size)
|
||||||
{
|
{
|
||||||
if (WebPGetInfo(buf, size, NULL, NULL)) {
|
if (WebPGetInfo(buf, size, NULL, NULL)) {
|
||||||
return true;
|
return true;
|
||||||
@ -37,10 +37,7 @@ bool imb_is_a_webp(const unsigned char *buf, size_t size)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImBuf *imb_loadwebp(const unsigned char *mem,
|
ImBuf *imb_loadwebp(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
|
||||||
size_t size,
|
|
||||||
int flags,
|
|
||||||
char colorspace[IM_MAX_SPACE])
|
|
||||||
{
|
{
|
||||||
if (!imb_is_a_webp(mem, size)) {
|
if (!imb_is_a_webp(mem, size)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -66,7 +63,7 @@ ImBuf *imb_loadwebp(const unsigned char *mem,
|
|||||||
ibuf->ftype = IMB_FTYPE_WEBP;
|
ibuf->ftype = IMB_FTYPE_WEBP;
|
||||||
imb_addrectImBuf(ibuf);
|
imb_addrectImBuf(ibuf);
|
||||||
/* Flip the image during decoding to match Blender. */
|
/* Flip the image during decoding to match Blender. */
|
||||||
unsigned char *last_row = (unsigned char *)(ibuf->rect + (ibuf->y - 1) * ibuf->x);
|
uchar *last_row = (uchar *)(ibuf->rect + (ibuf->y - 1) * ibuf->x);
|
||||||
if (WebPDecodeRGBAInto(mem, size, last_row, (size_t)(ibuf->x) * ibuf->y * 4, -4 * ibuf->x) ==
|
if (WebPDecodeRGBAInto(mem, size, last_row, (size_t)(ibuf->x) * ibuf->y * 4, -4 * ibuf->x) ==
|
||||||
NULL) {
|
NULL) {
|
||||||
fprintf(stderr, "WebP: Failed to decode image\n");
|
fprintf(stderr, "WebP: Failed to decode image\n");
|
||||||
@ -98,7 +95,7 @@ struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned char *data = BLI_mmap_get_pointer(mmap_file);
|
const uchar *data = BLI_mmap_get_pointer(mmap_file);
|
||||||
|
|
||||||
WebPDecoderConfig config;
|
WebPDecoderConfig config;
|
||||||
if (!data || !WebPInitDecoderConfig(&config) ||
|
if (!data || !WebPInitDecoderConfig(&config) ||
|
||||||
@ -162,7 +159,7 @@ struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath,
|
|||||||
bool imb_savewebp(struct ImBuf *ibuf, const char *name, int UNUSED(flags))
|
bool imb_savewebp(struct ImBuf *ibuf, const char *name, int UNUSED(flags))
|
||||||
{
|
{
|
||||||
const int bytesperpixel = (ibuf->planes + 7) >> 3;
|
const int bytesperpixel = (ibuf->planes + 7) >> 3;
|
||||||
unsigned char *encoded_data, *last_row;
|
uchar *encoded_data, *last_row;
|
||||||
size_t encoded_data_size;
|
size_t encoded_data_size;
|
||||||
|
|
||||||
if (bytesperpixel == 3) {
|
if (bytesperpixel == 3) {
|
||||||
@ -176,7 +173,7 @@ bool imb_savewebp(struct ImBuf *ibuf, const char *name, int UNUSED(flags))
|
|||||||
rgb_rect[i * 3 + 2] = rgba_rect[i * 4 + 2];
|
rgb_rect[i * 3 + 2] = rgba_rect[i * 4 + 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
last_row = (unsigned char *)(rgb_rect + (ibuf->y - 1) * ibuf->x * 3);
|
last_row = (uchar *)(rgb_rect + (ibuf->y - 1) * ibuf->x * 3);
|
||||||
|
|
||||||
if (ibuf->foptions.quality == 100.0f) {
|
if (ibuf->foptions.quality == 100.0f) {
|
||||||
encoded_data_size = WebPEncodeLosslessRGB(
|
encoded_data_size = WebPEncodeLosslessRGB(
|
||||||
@ -189,7 +186,7 @@ bool imb_savewebp(struct ImBuf *ibuf, const char *name, int UNUSED(flags))
|
|||||||
MEM_freeN(rgb_rect);
|
MEM_freeN(rgb_rect);
|
||||||
}
|
}
|
||||||
else if (bytesperpixel == 4) {
|
else if (bytesperpixel == 4) {
|
||||||
last_row = (unsigned char *)(ibuf->rect + (ibuf->y - 1) * ibuf->x);
|
last_row = (uchar *)(ibuf->rect + (ibuf->y - 1) * ibuf->x);
|
||||||
|
|
||||||
if (ibuf->foptions.quality == 100.0f) {
|
if (ibuf->foptions.quality == 100.0f) {
|
||||||
encoded_data_size = WebPEncodeLosslessRGBA(
|
encoded_data_size = WebPEncodeLosslessRGBA(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user