Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/CMakeLists.txt5
-rw-r--r--source/blender/imbuf/IMB_imbuf.h2
-rw-r--r--source/blender/imbuf/IMB_imbuf_types.h19
-rw-r--r--source/blender/imbuf/IMB_thumbs.h3
-rw-r--r--source/blender/imbuf/SConscript6
-rw-r--r--source/blender/imbuf/intern/IMB_targa.h2
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c5
-rw-r--r--source/blender/imbuf/intern/amiga.c2
-rw-r--r--source/blender/imbuf/intern/anim.c2
-rw-r--r--source/blender/imbuf/intern/cineon/SConscript4
-rw-r--r--source/blender/imbuf/intern/cineon/cineon_dpx.c20
-rw-r--r--source/blender/imbuf/intern/cineon/cineonlib.c6
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c8
-rw-r--r--source/blender/imbuf/intern/dds/SConscript2
-rw-r--r--source/blender/imbuf/intern/divers.c54
-rw-r--r--source/blender/imbuf/intern/filter.c88
-rw-r--r--source/blender/imbuf/intern/imbuf.h2
-rw-r--r--source/blender/imbuf/intern/openexr/SConscript4
-rw-r--r--source/blender/imbuf/intern/readimage.c25
-rw-r--r--source/blender/imbuf/intern/targa.c66
-rw-r--r--source/blender/imbuf/intern/thumbs.c15
-rw-r--r--source/blender/imbuf/intern/tiff.c2
-rw-r--r--source/blender/imbuf/intern/writeimage.c2
23 files changed, 257 insertions, 87 deletions
diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt
index 9894aa8136e..391f6e9e1a2 100644
--- a/source/blender/imbuf/CMakeLists.txt
+++ b/source/blender/imbuf/CMakeLists.txt
@@ -36,11 +36,6 @@ SET(INC
${OPENJPEG_INC}
)
-IF(WITH_VERSE)
- ADD_DEFINITIONS(-DWITH_VERSE)
- SET(INC ${INC} VERSE_INC)
-ENDIF(WITH_VERSE)
-
IF(WITH_OPENEXR)
ADD_DEFINITIONS(-DWITH_OPENEXR)
ENDIF(WITH_OPENEXR)
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 1d8035a2358..d2f561438b9 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -319,7 +319,7 @@ void IMB_antialias(struct ImBuf * ibuf);
void IMB_filter(struct ImBuf *ibuf);
void IMB_filterN(struct ImBuf *out, struct ImBuf *in);
void IMB_filter_extend(struct ImBuf *ibuf, char *mask);
-void IMB_makemipmap(struct ImBuf *ibuf, int use_filter);
+void IMB_makemipmap(struct ImBuf *ibuf, int use_filter, int SAT);
/**
*
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index eadd7affe6a..91a7b136fa5 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -83,6 +83,7 @@ typedef struct ImBuf {
int ftype; /**< File type we are going to save as */
unsigned int *cmap; /**< Color map data. */
unsigned int *rect; /**< pixel values stored here */
+ unsigned int *crect; /**< color corrected pixel values stored here */
unsigned int **planes; /**< bitplanes */
int flags; /**< Controls which components should exist. */
int mall; /**< what is malloced internal, and can be freed */
@@ -97,9 +98,13 @@ typedef struct ImBuf {
unsigned int encodedsize; /**< Size of data written to encodedbuffer */
unsigned int encodedbuffersize; /**< Size of encodedbuffer */
- float *rect_float; /**< floating point Rect equivilant */
+ float *rect_float; /**< floating point Rect equivalent
+ Linear RGB color space - may need gamma correction to
+ sRGB when generating 8bit representations */
int channels; /**< amount of channels in rect_float (0 = 4 channel default) */
float dither; /**< random dither value, for conversion from float -> byte rect */
+ short profile; /** color space/profile preset that the byte rect buffer represents */
+ char profile_filename[256]; /** to be implemented properly, specific filename for custom profiles */
struct MEM_CacheLimiterHandle_s * c_handle; /**< handle for cache limiter */
struct ImgInfo * img_info;
@@ -212,6 +217,18 @@ typedef enum {
#define AN_tanx (Anim | TANX)
/**@}*/
+/**
+ * \name Imbuf preset profile tags
+ * \brief Some predefined color space profiles that 8 bit imbufs can represent
+ */
+/**@{*/
+#define IB_PROFILE_NONE 0
+#define IB_PROFILE_LINEAR_RGB 1
+#define IB_PROFILE_SRGB 2
+#define IB_PROFILE_CUSTOM 3
+/**@}*/
+
+
/** \name Imbuf File Type Tests
* \brief These macros test if an ImBuf struct is the corresponding file type.
*/
diff --git a/source/blender/imbuf/IMB_thumbs.h b/source/blender/imbuf/IMB_thumbs.h
index 4f4b77ff000..53b63b4d304 100644
--- a/source/blender/imbuf/IMB_thumbs.h
+++ b/source/blender/imbuf/IMB_thumbs.h
@@ -67,7 +67,8 @@ void IMB_thumb_delete(const char* dir, const char* file, ThumbSize size);
/* return the state of the thumb, needed to determine how to manage the thumb */
ImBuf* IMB_thumb_manage(const char* dir, const char* file, ThumbSize size, ThumbSource source);
-
+/* create the necessary dirs to store the thumbnails */
+void IMB_thumb_makedirs();
#endif /* _IMB_THUMBS_H */
diff --git a/source/blender/imbuf/SConscript b/source/blender/imbuf/SConscript
index a8c49c0394e..9da0cf21596 100644
--- a/source/blender/imbuf/SConscript
+++ b/source/blender/imbuf/SConscript
@@ -13,10 +13,6 @@ incs += ' ' + env['BF_ZLIB_INC']
defs = []
-if env['WITH_BF_VERSE']:
- defs.append('WITH_VERSE')
- incs += ' ' + env['BF_VERSE_INCLUDE']
-
if env['WITH_BF_OPENEXR']:
defs.append('WITH_OPENEXR')
@@ -39,4 +35,4 @@ if env['WITH_BF_QUICKTIME']:
incs += ' ../quicktime ' + env['BF_QUICKTIME_INC']
defs.append('WITH_QUICKTIME')
-env.BlenderLib ( libname = 'bf_imbuf', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [80, 40] )
+env.BlenderLib ( libname = 'bf_imbuf', sources = sources, includes = Split(incs), defines = defs, libtype=['core'], priority = [190] )
diff --git a/source/blender/imbuf/intern/IMB_targa.h b/source/blender/imbuf/intern/IMB_targa.h
index 956bc512b97..7759e4bc772 100644
--- a/source/blender/imbuf/intern/IMB_targa.h
+++ b/source/blender/imbuf/intern/IMB_targa.h
@@ -41,7 +41,7 @@ struct ImBuf;
int imb_is_a_targa(void *buf);
-struct ImBuf *imb_loadtarga(unsigned char *mem, int flags);
+struct ImBuf *imb_loadtarga(unsigned char *mem, int size, int flags);
short imb_savetarga(struct ImBuf * ibuf, char *name, int flags);
#endif
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index ad7b1dce2e0..b561f0a583d 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -93,6 +93,10 @@ void imb_freerectImBuf(struct ImBuf * ibuf)
{
if (ibuf==NULL) return;
+ if (ibuf->crect && ibuf->crect != ibuf->rect) {
+ MEM_freeN(ibuf->crect);
+ }
+
if (ibuf->rect) {
if (ibuf->mall & IB_rect) {
MEM_freeN(ibuf->rect);
@@ -102,6 +106,7 @@ void imb_freerectImBuf(struct ImBuf * ibuf)
imb_freemipmapImBuf(ibuf);
ibuf->rect= NULL;
+ ibuf->crect= NULL;
ibuf->mall &= ~IB_rect;
}
diff --git a/source/blender/imbuf/intern/amiga.c b/source/blender/imbuf/intern/amiga.c
index 534e4945aa3..f84740826ae 100644
--- a/source/blender/imbuf/intern/amiga.c
+++ b/source/blender/imbuf/intern/amiga.c
@@ -532,7 +532,7 @@ struct ImBuf *imb_loadamiga(int *iffmem,int flags)
if (ibuf) {
if (ibuf->rect)
- if (G.order == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
+ if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
}
return (ibuf);
diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c
index 3e09eb5e306..a2dbdfbe483 100644
--- a/source/blender/imbuf/intern/anim.c
+++ b/source/blender/imbuf/intern/anim.c
@@ -778,7 +778,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
}
}
- if (G.order == B_ENDIAN) {
+ if (ENDIAN_ORDER == B_ENDIAN) {
int * dstStride
= anim->pFrameRGB->linesize;
uint8_t** dst = anim->pFrameRGB->data;
diff --git a/source/blender/imbuf/intern/cineon/SConscript b/source/blender/imbuf/intern/cineon/SConscript
index 7bfaa8dbdf2..ef9c44b85c8 100644
--- a/source/blender/imbuf/intern/cineon/SConscript
+++ b/source/blender/imbuf/intern/cineon/SConscript
@@ -13,5 +13,5 @@ incs = ['.',
'../../../makesdna']
defs = []
-
-env.BlenderLib ('bf_cineon', source_files, incs, defs, libtype=['core','player'], priority = [90, 200])
+
+env.BlenderLib ('bf_cineon', source_files, incs, defs, libtype=['core','player'], priority = [220, 75])
diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c
index 203eb8fe314..45f23d34405 100644
--- a/source/blender/imbuf/intern/cineon/cineon_dpx.c
+++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c
@@ -40,18 +40,22 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
-#include "MEM_guardedalloc.h"
-
-/* ugly bad level, should be fixed */
-#include "DNA_scene_types.h"
#include "BKE_global.h"
+#include "MEM_guardedalloc.h"
+
static void cineon_conversion_parameters(LogImageByteConversionParameters *params)
{
- params->blackPoint = G.scene?G.scene->r.cineonblack:95;
- params->whitePoint = G.scene?G.scene->r.cineonwhite:685;
- params->gamma = G.scene?G.scene->r.cineongamma:1.7f;
- params->doLogarithm = G.scene?G.scene->r.subimtype & R_CINEON_LOG:0;
+// params->blackPoint = scene?scene->r.cineonblack:95;
+// params->whitePoint = scene?scene->r.cineonwhite:685;
+// params->gamma = scene?scene->r.cineongamma:1.7f;
+// params->doLogarithm = scene?scene->r.subimtype & R_CINEON_LOG:0;
+
+ params->blackPoint = 95;
+ params->whitePoint = 685;
+ params->gamma = 1.7f;
+ params->doLogarithm = 0;
+
}
static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, int flags)
diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c
index 75516bbf3ae..85b7ef0d5e9 100644
--- a/source/blender/imbuf/intern/cineon/cineonlib.c
+++ b/source/blender/imbuf/intern/cineon/cineonlib.c
@@ -558,7 +558,7 @@ cineonOpen(const char* filename) {
cineon->pixelBuffer = malloc(cineon->lineBufferLength * 3 * sizeof(unsigned short));
if (cineon->pixelBuffer == 0) {
if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n",
- (cineon->width * cineon->depth) * sizeof(unsigned short));
+ (cineon->width * cineon->depth) * (int)sizeof(unsigned short));
cineonClose(cineon);
return 0;
}
@@ -658,7 +658,7 @@ cineonOpenFromMem(unsigned char *mem, unsigned int size) {
cineon->pixelBuffer = malloc(cineon->lineBufferLength * 3 * sizeof(unsigned short));
if (cineon->pixelBuffer == 0) {
if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n",
- (cineon->width * cineon->depth) * sizeof(unsigned short));
+ (cineon->width * cineon->depth) * (int)sizeof(unsigned short));
cineonClose(cineon);
return 0;
}
@@ -744,7 +744,7 @@ cineonCreate(const char* filename, int width, int height, int depth) {
cineon->pixelBuffer = malloc(cineon->lineBufferLength * 3 * sizeof(unsigned short));
if (cineon->pixelBuffer == 0) {
if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n",
- (cineon->width * cineon->depth) * sizeof(unsigned short));
+ (cineon->width * cineon->depth) * (int)sizeof(unsigned short));
cineonClose(cineon);
return 0;
}
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index 37e7ef3fc33..8459eb0f989 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -240,7 +240,7 @@ dpxGetRowBytes(DpxFile* dpx, unsigned short* row, int y) {
/* read enough longwords */
readLongs = pixelsToLongs(numPixels - dpx->pixelBufferUsed);
if (logimage_fread(dpx->lineBuffer, 4, readLongs, dpx) != readLongs) {
- if (verbose) d_printf("Couldn't read line %d length %d\n", y, readLongs * 4);
+ if (verbose) d_printf("Couldn't read line %d length %d\n", y, (int)readLongs * 4);
return 1;
}
++dpx->fileYPos;
@@ -352,7 +352,7 @@ dpxSetRowBytes(DpxFile* dpx, const unsigned short* row, int y) {
/* write them */
if (fwrite(dpx->lineBuffer, 4, writeLongs, dpx->file) != writeLongs) {
- if (verbose) d_printf("Couldn't write line %d length %d\n", y, writeLongs * 4);
+ if (verbose) d_printf("Couldn't write line %d length %d\n", y, (int)writeLongs * 4);
return 1;
}
++dpx->fileYPos;
@@ -462,7 +462,7 @@ intern_dpxOpen(int mode, const char* bytestuff, int bufsize) {
dpx->pixelBuffer = malloc((dpx->lineBufferLength * 3 + 2) * sizeof(unsigned short));
if (dpx->pixelBuffer == 0) {
if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n",
- (dpx->width * dpx->depth + 2 + 2) * sizeof(unsigned short));
+ (dpx->width * dpx->depth + 2 + 2) * (int)sizeof(unsigned short));
dpxClose(dpx);
return 0;
}
@@ -604,7 +604,7 @@ dpxCreate(const char* filename, int width, int height, int depth) {
dpx->pixelBuffer = malloc((dpx->lineBufferLength * 3 + 2) * sizeof(unsigned short));
if (dpx->pixelBuffer == 0) {
if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n",
- (dpx->width * dpx->depth + 2 + 2) * sizeof(unsigned short));
+ (dpx->width * dpx->depth + 2 + 2) * (int)sizeof(unsigned short));
dpxClose(dpx);
return 0;
}
diff --git a/source/blender/imbuf/intern/dds/SConscript b/source/blender/imbuf/intern/dds/SConscript
index d005bae02be..cec6023648b 100644
--- a/source/blender/imbuf/intern/dds/SConscript
+++ b/source/blender/imbuf/intern/dds/SConscript
@@ -16,4 +16,4 @@ incs = ['.',
defs = ['WITH_DDS']
-env.BlenderLib ('bf_dds', source_files, incs, defs, libtype=['core','player'], priority = [90, 200])
+env.BlenderLib ('bf_dds', source_files, incs, defs, libtype=['core','player'], priority = [230, 105])
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 8043e594454..6e1a176a5d2 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -39,6 +39,7 @@
#include "IMB_allocimbuf.h"
#include "IMB_divers.h"
#include "BKE_utildefines.h"
+#include "BKE_colortools.h"
void imb_checkncols(struct ImBuf *ibuf)
{
@@ -176,9 +177,11 @@ void IMB_gamwarp(struct ImBuf *ibuf, double gamma)
void IMB_rect_from_float(struct ImBuf *ibuf)
{
/* quick method to convert floatbuf to byte */
- float *tof = ibuf->rect_float;
+ float *tof = (float *)ibuf->rect_float;
float dither= ibuf->dither;
+ float srgb[3];
int i, channels= ibuf->channels;
+ short profile= ibuf->profile;
unsigned char *to = (unsigned char *) ibuf->rect;
if(tof==NULL) return;
@@ -187,7 +190,24 @@ void IMB_rect_from_float(struct ImBuf *ibuf)
to = (unsigned char *) ibuf->rect;
}
- if(dither==0.0f || channels!=4) {
+ if (profile == IB_PROFILE_SRGB && (channels == 3 || channels == 4)) {
+ if(channels == 3) {
+ for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof+=3) {
+ srgb[0]= linearrgb_to_srgb(tof[0]);
+ srgb[1]= linearrgb_to_srgb(tof[1]);
+ srgb[2]= linearrgb_to_srgb(tof[2]);
+
+ to[0] = FTOCHAR(srgb[0]);
+ to[1] = FTOCHAR(srgb[1]);
+ to[2] = FTOCHAR(srgb[2]);
+ to[3] = 255;
+ }
+ }
+ else if (channels == 4) {
+ floatbuf_to_srgb_byte(tof, to, 0, ibuf->x, 0, ibuf->y, ibuf->x);
+ }
+ }
+ else if(ELEM(profile, IB_PROFILE_NONE, IB_PROFILE_LINEAR_RGB) && (dither==0.0f || channels!=4)) {
if(channels==1) {
for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof++)
to[1]= to[2]= to[3]= to[0] = FTOCHAR(tof[0]);
@@ -242,14 +262,28 @@ void IMB_float_from_rect(struct ImBuf *ibuf)
tof = ibuf->rect_float;
}
- for (i = ibuf->x * ibuf->y; i > 0; i--)
- {
- tof[0] = ((float)to[0])*(1.0f/255.0f);
- tof[1] = ((float)to[1])*(1.0f/255.0f);
- tof[2] = ((float)to[2])*(1.0f/255.0f);
- tof[3] = ((float)to[3])*(1.0f/255.0f);
- to += 4;
- tof += 4;
+ if (ibuf->profile == IB_PROFILE_SRGB) {
+ /* convert from srgb to linear rgb */
+
+ for (i = ibuf->x * ibuf->y; i > 0; i--)
+ {
+ tof[0] = srgb_to_linearrgb(((float)to[0])*(1.0f/255.0f));
+ tof[1] = srgb_to_linearrgb(((float)to[1])*(1.0f/255.0f));
+ tof[2] = srgb_to_linearrgb(((float)to[2])*(1.0f/255.0f));
+ tof[3] = ((float)to[3])*(1.0f/255.0f);
+ to += 4;
+ tof += 4;
+ }
+ } else {
+ for (i = ibuf->x * ibuf->y; i > 0; i--)
+ {
+ tof[0] = ((float)to[0])*(1.0f/255.0f);
+ tof[1] = ((float)to[1])*(1.0f/255.0f);
+ tof[2] = ((float)to[2])*(1.0f/255.0f);
+ tof[3] = ((float)to[3])*(1.0f/255.0f);
+ to += 4;
+ tof += 4;
+ }
}
}
diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c
index 9802405fd8d..cc3315c7696 100644
--- a/source/blender/imbuf/intern/filter.c
+++ b/source/blender/imbuf/intern/filter.c
@@ -371,6 +371,7 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask)
}
}
+#if 0
void IMB_makemipmap(ImBuf *ibuf, int use_filter)
{
ImBuf *hbuf= ibuf;
@@ -394,5 +395,90 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter)
minsize= hbuf->x<hbuf->y?hbuf->x:hbuf->y;
}
}
+#endif
-
+void IMB_makemipmap(ImBuf *ibuf, int use_filter, int SAT)
+{
+ if (SAT) {
+ // to maximize precision subtract image average, use intermediate double SAT,
+ // only convert to float at the end
+ const double dv = 1.0/255.0;
+ double avg[4] = {0, 0, 0, 0};
+ const int x4 = ibuf->x << 2;
+ int x, y, i;
+ ImBuf* sbuf = IMB_allocImBuf(ibuf->x, ibuf->y, 32, IB_rectfloat, 0);
+ double *satp, *satbuf = MEM_callocN(sizeof(double)*ibuf->x*ibuf->y*4, "tmp SAT buf");
+ const double mf = ibuf->x*ibuf->y;
+ float* fp;
+ ibuf->mipmap[0] = sbuf;
+ if (ibuf->rect_float) {
+ fp = ibuf->rect_float;
+ for (y=0; y<ibuf->y; ++y)
+ for (x=0; x<ibuf->x; ++x) {
+ avg[0] += *fp++;
+ avg[1] += *fp++;
+ avg[2] += *fp++;
+ avg[3] += *fp++;
+ }
+ }
+ else {
+ char* cp = (char*)ibuf->rect;
+ for (y=0; y<ibuf->y; ++y)
+ for (x=0; x<ibuf->x; ++x) {
+ avg[0] += *cp++ * dv;
+ avg[1] += *cp++ * dv;
+ avg[2] += *cp++ * dv;
+ avg[3] += *cp++ * dv;
+ }
+ }
+ avg[0] /= mf;
+ avg[1] /= mf;
+ avg[2] /= mf;
+ avg[3] /= mf;
+ for (y=0; y<ibuf->y; ++y)
+ for (x=0; x<ibuf->x; ++x) {
+ const unsigned int p = (x + y*ibuf->x) << 2;
+ char* cp = (char*)ibuf->rect + p;
+ fp = ibuf->rect_float + p;
+ satp = satbuf + p;
+ for (i=0; i<4; ++i, ++cp, ++fp, ++satp) {
+ double sv = (ibuf->rect_float ? (double)*fp : (double)(*cp)*dv) - avg[i];
+ if (x > 0) sv += satp[-4];
+ if (y > 0) sv += satp[-x4];
+ if (x > 0 && y > 0) sv -= satp[-x4 - 4];
+ *satp = sv;
+ }
+ }
+ fp = sbuf->rect_float;
+ satp = satbuf;
+ for (y=0; y<ibuf->y; ++y)
+ for (x=0; x<ibuf->x; ++x) {
+ *fp++ = (float)*satp++;
+ *fp++ = (float)*satp++;
+ *fp++ = (float)*satp++;
+ *fp++ = (float)*satp++;
+ }
+ MEM_freeN(satbuf);
+ fp = &sbuf->rect_float[(sbuf->x - 1 + (sbuf->y - 1)*sbuf->x) << 2];
+ fp[0] = avg[0];
+ fp[1] = avg[1];
+ fp[2] = avg[2];
+ fp[3] = avg[3];
+ }
+ else {
+ ImBuf *hbuf = ibuf;
+ int curmap = 0;
+ while (curmap < IB_MIPMAP_LEVELS) {
+ if (use_filter) {
+ ImBuf *nbuf= IMB_allocImBuf(hbuf->x, hbuf->y, 32, IB_rect, 0);
+ IMB_filterN(nbuf, hbuf);
+ ibuf->mipmap[curmap] = IMB_onehalf(nbuf);
+ IMB_freeImBuf(nbuf);
+ }
+ else ibuf->mipmap[curmap] = IMB_onehalf(hbuf);
+ hbuf = ibuf->mipmap[curmap];
+ if (hbuf->x == 1 && hbuf->y == 1) break;
+ curmap++;
+ }
+ }
+}
diff --git a/source/blender/imbuf/intern/imbuf.h b/source/blender/imbuf/intern/imbuf.h
index bd2a0d3082f..7b5d668ce2b 100644
--- a/source/blender/imbuf/intern/imbuf.h
+++ b/source/blender/imbuf/intern/imbuf.h
@@ -51,7 +51,7 @@
#include <sys/mman.h>
#endif
-#if !defined(WIN32) && !defined(__BeOS)
+#if !defined(WIN32)
#define O_BINARY 0
#endif
diff --git a/source/blender/imbuf/intern/openexr/SConscript b/source/blender/imbuf/intern/openexr/SConscript
index 1b0a0ed6110..aa166a1983c 100644
--- a/source/blender/imbuf/intern/openexr/SConscript
+++ b/source/blender/imbuf/intern/openexr/SConscript
@@ -14,5 +14,5 @@ incs = ['.',
incs += Split(env['BF_OPENEXR_INC'])
defs = []
-
-env.BlenderLib ('bf_openexr', source_files, incs, defs, libtype=['core','player'], priority = [90, 200])
+
+env.BlenderLib ('bf_openexr', source_files, incs, defs, libtype=['core','player'], priority = [225, 85])
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index 6df92f69fff..4104a8db65c 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -143,7 +143,7 @@ ImBuf *IMB_ibImageFromMemory(int *mem, int size, int flags) {
ibuf = imb_bmp_decode((uchar *)mem, size, flags);
if (ibuf) return(ibuf);
- ibuf = imb_loadtarga((uchar *)mem, flags);
+ ibuf = imb_loadtarga((uchar *)mem, size, flags);
if (ibuf) return(ibuf);
ibuf = imb_loaddpx((uchar *)mem, size, flags);
@@ -229,7 +229,7 @@ struct ImBuf *IMB_loadiffmem(int *mem, int flags) {
}
}
- ibuf = imb_loadtarga((uchar *) mem,flags);
+ ibuf = imb_loadtarga((uchar *) mem,maxlen,flags);
if (ibuf) return(ibuf);
if (IB_verbose) fprintf(stderr,"Unknown fileformat\n");
@@ -244,26 +244,6 @@ struct ImBuf *IMB_loadifffile(int file, int flags) {
size = BLI_filesize(file);
-#if defined(AMIGA) || defined(__BeOS)
- mem= (int *)malloc(size);
- if (mem==0) {
- printf("Out of mem\n");
- return (0);
- }
-
- if (read(file, mem, size)!=size){
- printf("Read Error\n");
- free(mem);
- return (0);
- }
-
- ibuf = IMB_ibImageFromMemory(mem, size, flags);
- free(mem);
-
- /* for jpeg read */
- lseek(file, 0L, SEEK_SET);
-
-#else
mem= (int *)mmap(0,size,PROT_READ,MAP_SHARED,file,0);
if (mem==(int *)-1){
printf("Couldn't get mapping\n");
@@ -275,7 +255,6 @@ struct ImBuf *IMB_loadifffile(int file, int flags) {
if (munmap( (void *) mem, size)){
printf("Couldn't unmap file.\n");
}
-#endif
return(ibuf);
}
diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c
index 6a974464f56..c89bc6a632f 100644
--- a/source/blender/imbuf/intern/targa.c
+++ b/source/blender/imbuf/intern/targa.c
@@ -368,8 +368,24 @@ int imb_is_a_targa(void *buf) {
return checktarga(&tga, buf);
}
-static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, int psize)
+static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect)
{
+ int size = (ibuf->x * ibuf->y) - (rect - ibuf->rect);
+ if(size) {
+ printf("decodetarga: incomplete file, %.1f%% missing\n", 100*((float)size / (ibuf->x * ibuf->y)));
+
+ /* not essential but makes displaying partially rendered TGA's less ugly */
+ memset(rect, 0, size);
+ }
+ else {
+ /* shouldnt happen */
+ printf("decodetarga: incomplete file, all pixels written\n");
+ }
+}
+
+static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, int mem_size, int psize)
+{
+ unsigned char *mem_end = mem+mem_size;
int count, col, size;
unsigned int *rect;
uchar * cp = (uchar *) &col;
@@ -383,9 +399,13 @@ static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, int psize)
/* set alpha */
cp[0] = 0xff;
cp[1] = cp[2] = 0;
-
+
while(size > 0){
count = *mem++;
+
+ if(mem>mem_end)
+ goto partial_load;
+
if (count >= 128) {
/*if (count == 128) printf("TARGA: 128 in file !\n");*/
count -= 127;
@@ -455,15 +475,28 @@ static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, int psize)
}
*rect++ = col;
count --;
+
+ if(mem>mem_end)
+ goto partial_load;
}
+
+ if(mem>mem_end)
+ goto partial_load;
}
}
}
- if (size) printf("decodetarga: count would overwrite %d pixels\n", -size);
+ if (size) {
+ printf("decodetarga: count would overwrite %d pixels\n", -size);
+ }
+ return;
+
+partial_load:
+ complete_partial_load(ibuf, rect);
}
-static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, int psize)
+static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, int mem_size, int psize)
{
+ unsigned char *mem_end = mem+mem_size;
int col,size;
unsigned int *rect;
uchar * cp = (uchar *) &col;
@@ -479,6 +512,9 @@ static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, int psize)
cp[1] = cp[2] = 0;
while(size > 0){
+ if(mem>mem_end)
+ goto partial_load;
+
if (psize & 2){
if (psize & 1){
/* order = bgra */
@@ -508,10 +544,14 @@ static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, int psize)
*rect++ = col;
size--;
}
+ return;
+
+partial_load:
+ complete_partial_load(ibuf, rect);
}
-struct ImBuf *imb_loadtarga(unsigned char *mem, int flags)
+struct ImBuf *imb_loadtarga(unsigned char *mem, int mem_size, int flags)
{
TARGA tga;
struct ImBuf * ibuf;
@@ -582,18 +622,18 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, int flags)
case 1:
case 2:
case 3:
- if (tga.pixsize <= 8) ldtarga(ibuf,mem,0);
- else if (tga.pixsize <= 16) ldtarga(ibuf,mem,1);
- else if (tga.pixsize <= 24) ldtarga(ibuf,mem,2);
- else if (tga.pixsize <= 32) ldtarga(ibuf,mem,3);
+ if (tga.pixsize <= 8) ldtarga(ibuf,mem,mem_size,0);
+ else if (tga.pixsize <= 16) ldtarga(ibuf,mem,mem_size,1);
+ else if (tga.pixsize <= 24) ldtarga(ibuf,mem,mem_size,2);
+ else if (tga.pixsize <= 32) ldtarga(ibuf,mem,mem_size,3);
break;
case 9:
case 10:
case 11:
- if (tga.pixsize <= 8) decodetarga(ibuf,mem,0);
- else if (tga.pixsize <= 16) decodetarga(ibuf,mem,1);
- else if (tga.pixsize <= 24) decodetarga(ibuf,mem,2);
- else if (tga.pixsize <= 32) decodetarga(ibuf,mem,3);
+ if (tga.pixsize <= 8) decodetarga(ibuf,mem,mem_size,0);
+ else if (tga.pixsize <= 16) decodetarga(ibuf,mem,mem_size,1);
+ else if (tga.pixsize <= 24) decodetarga(ibuf,mem,mem_size,2);
+ else if (tga.pixsize <= 32) decodetarga(ibuf,mem,mem_size,3);
break;
}
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index 718b0537b48..86ca43824f3 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -27,9 +27,10 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/* also defined in BKE_utildefines, repeated here to avoid dependency */
-#define FILE_MAX 240
+#include <stdio.h>
+#include "BKE_global.h"
+#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
#include "MEM_guardedalloc.h"
@@ -231,6 +232,16 @@ static int thumbpath_from_uri(const char* uri, char* path, ThumbSize size)
return rv;
}
+void IMB_thumb_makedirs()
+{
+ char tpath[FILE_MAX];
+ if (get_thumb_dir(tpath, THB_NORMAL)) {
+ BLI_recurdir_fileops(tpath);
+ }
+ if (get_thumb_dir(tpath, THB_FAIL)) {
+ BLI_recurdir_fileops(tpath);
+ }
+}
/* create thumbnail for file and returns new imbuf for thumbnail */
ImBuf* IMB_thumb_create(const char* dir, const char* file, ThumbSize size, ThumbSource source)
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c
index 194082d3e19..b2465d6cc2f 100644
--- a/source/blender/imbuf/intern/tiff.c
+++ b/source/blender/imbuf/intern/tiff.c
@@ -410,7 +410,7 @@ struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags)
/* close the client layer interface to the in-memory file */
libtiff_TIFFClose(image);
- if (G.order == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
+ if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
/* return successfully */
return (ibuf);
diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c
index 5df0595d97f..7e1120bf3e4 100644
--- a/source/blender/imbuf/intern/writeimage.c
+++ b/source/blender/imbuf/intern/writeimage.c
@@ -33,6 +33,8 @@
#include <io.h>
#endif
+#include <stdio.h>
+
#include "BKE_global.h"
#include "BLI_blenlib.h"