diff options
Diffstat (limited to 'source/blender/imbuf')
21 files changed, 67 insertions, 67 deletions
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 612517775f4..556c4beeae7 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -47,8 +47,8 @@ #include "MEM_guardedalloc.h" -#include "BLI_threads.h" #include "BLI_utildefines.h" +#include "BLI_threads.h" static SpinLock refcounter_spin; diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index eef7964ef3f..b8f6e66adfe 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -70,12 +70,8 @@ #include "MEM_guardedalloc.h" -#include "DNA_userdef_types.h" - #include "BKE_global.h" -#include "imbuf.h" - #ifdef WITH_AVI # include "AVI_avi.h" #endif @@ -89,7 +85,6 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "IMB_allocimbuf.h" #include "IMB_anim.h" #include "IMB_indexer.h" diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index dabeec74a62..8853fe449ba 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -36,7 +36,6 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "IMB_allocimbuf.h" #include "IMB_filetype.h" #include "IMB_colormanagement.h" diff --git a/source/blender/imbuf/intern/cache.c b/source/blender/imbuf/intern/cache.c index 677c3dbe700..759f8cc82c2 100644 --- a/source/blender/imbuf/intern/cache.c +++ b/source/blender/imbuf/intern/cache.c @@ -22,7 +22,6 @@ * \ingroup imbuf */ - #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" @@ -31,8 +30,6 @@ #include "BLI_memarena.h" #include "BLI_threads.h" - - #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "IMB_filetype.h" diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 5dd6b366a93..43b766f161b 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -44,7 +44,6 @@ #include "DNA_scene_types.h" #include "DNA_space_types.h" -#include "IMB_filter.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "IMB_filetype.h" @@ -53,14 +52,13 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_fileops.h" #include "BLI_math.h" #include "BLI_math_color.h" -#include "BLI_path_util.h" #include "BLI_string.h" #include "BLI_threads.h" #include "BLI_rect.h" +#include "BKE_appdir.h" #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_image.h" @@ -625,7 +623,7 @@ void colormanagement_init(void) } if (config == NULL) { - configdir = BLI_get_folder(BLENDER_DATAFILES, "colormanagement"); + configdir = BKE_appdir_folder_id(BLENDER_DATAFILES, "colormanagement"); if (configdir) { BLI_join_dirfile(configfile, sizeof(configfile), configdir, BCM_CONFIG_FILE); diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index 03cd5ecd646..81aef4ac6e4 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -37,7 +37,6 @@ #include "imbuf.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "IMB_allocimbuf.h" #include "IMB_filter.h" #include "IMB_colormanagement.h" diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index b6b46c72384..c6e358dd3d2 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -51,8 +51,6 @@ #include "quicktime_import.h" #endif -#include "imbuf.h" - static int imb_ftype_default(ImFileType *type, ImBuf *ibuf) { return (ibuf->ftype & type->filetype); diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index cf875bb247b..8234b01992b 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -166,6 +166,10 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char outI[4], if (x2 >= in->x) x2 = x2 - in->x; if (y2 >= in->y) y2 = y2 - in->y; + a = u - floorf(u); + b = v - floorf(v); + a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b); + if (outF) { /* sample including outside of edges of image */ row1 = in->rect_float + in->x * y1 * 4 + 4 * x1; @@ -173,14 +177,16 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char outI[4], row3 = in->rect_float + in->x * y1 * 4 + 4 * x2; row4 = in->rect_float + in->x * y2 * 4 + 4 * x2; - a = u - floorf(u); - b = v - floorf(v); - a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b); - outF[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0]; outF[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1]; outF[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2]; outF[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3]; + + /* clamp here or else we can easily get off-range */ + CLAMP(outF[0], 0.0f, 1.0f); + CLAMP(outF[1], 0.0f, 1.0f); + CLAMP(outF[2], 0.0f, 1.0f); + CLAMP(outF[3], 0.0f, 1.0f); } if (outI) { /* sample including outside of edges of image */ @@ -188,10 +194,6 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char outI[4], row2I = (unsigned char *)in->rect + in->x * y2 * 4 + 4 * x1; row3I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x2; row4I = (unsigned char *)in->rect + in->x * y2 * 4 + 4 * x2; - - a = u - floorf(u); - b = v - floorf(v); - a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b); /* need to add 0.5 to avoid rounding down (causes darken with the smear brush) * tested with white images and this should not wrap back to zero */ diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 547a8df4438..e66be77ecaf 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -1170,7 +1170,7 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, IMB_Timecod return context; - (void)tcs_in_use, (void)proxy_sizes_in_use, (void)quality; + UNUSED_VARS(tcs_in_use, proxy_sizes_in_use, quality); } void IMB_anim_index_rebuild(struct IndexBuildContext *context, @@ -1189,7 +1189,7 @@ void IMB_anim_index_rebuild(struct IndexBuildContext *context, #endif } - (void)stop, (void)do_update, (void)progress; + UNUSED_VARS(stop, do_update, progress); } void IMB_anim_index_rebuild_finish(IndexBuildContext *context, short stop) @@ -1207,8 +1207,8 @@ void IMB_anim_index_rebuild_finish(IndexBuildContext *context, short stop) #endif } - (void)stop; - (void)proxy_sizes; /* static defined at top of the file */ + /* static defined at top of the file */ + UNUSED_VARS(stop, proxy_sizes); } diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index 8f98f240053..ea5acf27e99 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -40,7 +40,6 @@ #include "imbuf.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "IMB_allocimbuf.h" #include "IMB_filetype.h" #include "IMB_colormanagement.h" diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 18c096450af..8750b825fb6 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -29,11 +29,8 @@ #include "BLI_math.h" #include "BLI_fileops.h" -#include "imbuf.h" - #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "IMB_allocimbuf.h" #include "IMB_filetype.h" #include "IMB_colormanagement.h" diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index d00a836667e..3266dc97c78 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -41,8 +41,6 @@ #include "MEM_guardedalloc.h" -#include "imbuf.h" - #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index db268546480..318bb7e96e3 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -38,7 +38,7 @@ */ #ifdef WIN32 -# include <io.h> +# include "BLI_utildefines.h" #endif #include "MEM_guardedalloc.h" @@ -72,10 +72,13 @@ typedef float fCOLOR[3]; #define COPY_RGBE(c1, c2) (c2[RED] = c1[RED], c2[GRN] = c1[GRN], c2[BLU] = c1[BLU], c2[EXP] = c1[EXP]) /* read routines */ -static unsigned char *oldreadcolrs(RGBE *scan, unsigned char *mem, int xmax) +static unsigned char *oldreadcolrs(RGBE *scan, unsigned char *mem, int xmax, unsigned char *mem_eof) { int i, rshift = 0, len = xmax; while (len > 0) { + if (mem_eof - mem < 4) { + return NULL; + } scan[0][RED] = *mem++; scan[0][GRN] = *mem++; scan[0][BLU] = *mem++; @@ -97,34 +100,62 @@ static unsigned char *oldreadcolrs(RGBE *scan, unsigned char *mem, int xmax) return mem; } -static unsigned char *freadcolrs(RGBE *scan, unsigned char *mem, int xmax) +static unsigned char *freadcolrs(RGBE *scan, unsigned char *mem, int xmax, unsigned char *mem_eof) { int i, j, code, val; - if ((xmax < MINELEN) | (xmax > MAXELEN)) return oldreadcolrs(scan, mem, xmax); + if (mem_eof - mem < 4) { + return NULL; + } + + if ((xmax < MINELEN) | (xmax > MAXELEN)) { + return oldreadcolrs(scan, mem, xmax, mem_eof); + } i = *mem++; - if (i != 2) return oldreadcolrs(scan, mem - 1, xmax); + if (i != 2) { + return oldreadcolrs(scan, mem - 1, xmax, mem_eof); + } scan[0][GRN] = *mem++; scan[0][BLU] = *mem++; i = *mem++; - if (((scan[0][BLU] << 8) | i) != xmax) return NULL; - for (i = 0; i < 4; i++) + if (scan[0][GRN] != 2 || scan[0][BLU] & 128) { + scan[0][RED] = 2; + scan[0][EXP] = i; + return oldreadcolrs(scan + 1, mem, xmax - 1, mem_eof); + } + + if (((scan[0][BLU] << 8) | i) != xmax) { + return NULL; + } + + for (i = 0; i < 4; i++) { + if (mem_eof - mem < 2) { + return NULL; + } for (j = 0; j < xmax; ) { code = *mem++; if (code > 128) { code &= 127; val = *mem++; - while (code--) + while (code--) { scan[j++][i] = (unsigned char)val; + } } - else - while (code--) + else { + if (mem_eof - mem < code) { + return NULL; + } + while (code--) { scan[j++][i] = *mem++; + } + } } + } + return mem; } @@ -182,7 +213,7 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags, char color int found = 0; int width = 0, height = 0; int x, y; - unsigned char *ptr; + unsigned char *ptr, *mem_eof = mem + size; char oriY[80], oriX[80]; if (imb_is_a_hdr((void *)mem)) { @@ -218,15 +249,14 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags, char color if (flags & IB_test) return ibuf; /* read in and decode the actual data */ - sline = (RGBE *)MEM_mallocN(sizeof(RGBE) * width, "radhdr_read_tmpscan"); + sline = (RGBE *)MEM_mallocN(sizeof(*sline) * width, __func__); rect_float = ibuf->rect_float; for (y = 0; y < height; y++) { - ptr = freadcolrs(sline, ptr, width); + ptr = freadcolrs(sline, ptr, width, mem_eof); if (ptr == NULL) { - printf("HDR decode error\n"); - MEM_freeN(sline); - return ibuf; + printf("WARNING! HDR decode error, image may be just truncated, or completely wrong...\n"); + break; } for (x = 0; x < width; x++) { /* convert to ldr */ diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index dd2406e234e..4001b681ad9 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -39,11 +39,9 @@ #include "BLI_math_color_blend.h" #include "BLI_math_vector.h" -#include "imbuf.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "IMB_allocimbuf.h" #include "IMB_colormanagement.h" void IMB_blend_color_byte(unsigned char dst[4], unsigned char src1[4], unsigned char src2[4], IMB_BlendMode mode) diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index e98757883be..886944f6190 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -39,8 +39,6 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "IMB_allocimbuf.h" - void IMB_flipy(struct ImBuf *ibuf) { int x, y; diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index e480f06da2b..2601fe62c2f 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -33,7 +33,6 @@ #include "BLI_utildefines.h" -#include "BLI_math_base.h" #include "BLI_math_color.h" #include "BLI_math_interp.h" #include "MEM_guardedalloc.h" @@ -42,7 +41,6 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "IMB_allocimbuf.h" #include "IMB_filter.h" #include "BLI_sys_types.h" // for intptr_t support diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index 2dcb27a05d4..70b71ec4182 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -44,7 +44,6 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "IMB_allocimbuf.h" #include "IMB_filetype.h" #include "IMB_colormanagement.h" diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index 9a97a142198..94e95c06fea 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -30,12 +30,13 @@ */ #include <stdio.h> +#include <stdlib.h> #include "BLI_utildefines.h" #include "BLI_string.h" #include "BLI_path_util.h" #include "BLI_fileops.h" -#include "BLI_md5.h" +#include "BLI_hash_md5.h" #include "BLI_system.h" #include BLI_SYSTEM_PID_H @@ -243,9 +244,9 @@ static void thumbname_from_uri(const char *uri, char *thumb, const int thumb_len char hexdigest[33]; unsigned char digest[16]; - md5_buffer(uri, strlen(uri), digest); + BLI_hash_md5_buffer(uri, strlen(uri), digest); hexdigest[0] = '\0'; - BLI_snprintf(thumb, thumb_len, "%s.png", md5_to_hexdigest(digest, hexdigest)); + BLI_snprintf(thumb, thumb_len, "%s.png", BLI_hash_md5_to_hexdigest(digest, hexdigest)); // printf("%s: '%s' --> '%s'\n", __func__, uri, thumb); } diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c index 73ced4095f9..af353461f1f 100644 --- a/source/blender/imbuf/intern/thumbs_blend.c +++ b/source/blender/imbuf/intern/thumbs_blend.c @@ -29,8 +29,6 @@ #include "zlib.h" -#include "MEM_guardedalloc.h" - #include "BLI_utildefines.h" #include "BLI_endian_switch.h" #include "BLI_fileops.h" diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index eb8f94cbc6e..e3b8e271387 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -53,9 +53,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "IMB_allocimbuf.h" #include "IMB_filetype.h" -#include "IMB_filter.h" #include "IMB_colormanagement.h" #include "IMB_colormanagement_intern.h" diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c index d4a9bf7dc09..087330d10d2 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.c @@ -41,8 +41,6 @@ #include "IMB_colormanagement.h" #include "IMB_colormanagement_intern.h" -#include "imbuf.h" - static ImBuf *prepare_write_imbuf(ImFileType *type, ImBuf *ibuf) { ImBuf *write_ibuf = ibuf; |