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/blenlib')
-rw-r--r--source/blender/blenlib/BLI_arithb.h7
-rw-r--r--source/blender/blenlib/BLI_blenlib.h5
-rw-r--r--source/blender/blenlib/intern/arithb.c41
-rw-r--r--source/blender/blenlib/intern/dynlib.c6
-rw-r--r--source/blender/blenlib/intern/edgehash.c14
-rw-r--r--source/blender/blenlib/intern/freetypefont.c2
-rw-r--r--source/blender/blenlib/intern/util.c22
7 files changed, 79 insertions, 18 deletions
diff --git a/source/blender/blenlib/BLI_arithb.h b/source/blender/blenlib/BLI_arithb.h
index 6e54fae58d0..e2e71a2fb1a 100644
--- a/source/blender/blenlib/BLI_arithb.h
+++ b/source/blender/blenlib/BLI_arithb.h
@@ -91,6 +91,7 @@ float saasin(float fac);
float sasqrt(float fac);
int FloatCompare(float *v1, float *v2, float limit);
+int FloatCompare4(float *v1, float *v2, float limit);
float FloatLerpf(float target, float origin, float fac);
float CalcNormFloat(float *v1, float *v2, float *v3, float *n);
@@ -321,6 +322,10 @@ void i_window(
float mat[][4]
);
+#define BLI_CS_SMPTE 0
+#define BLI_CS_REC709 1
+#define BLI_CS_CIE 2
+
void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b);
void hex_to_rgb(char *hexcol, float *r, float *g, float *b);
void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv);
@@ -328,7 +333,7 @@ void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb);
void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb);
void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr);
void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv);
-void xyz_to_rgb(float x, float y, float z, float *r, float *g, float *b);
+void xyz_to_rgb(float x, float y, float z, float *r, float *g, float *b, int colorspace);
int constrain_rgb(float *r, float *g, float *b);
void gamma_correct_rgb(float *r, float *g, float *b);
unsigned int hsv_to_cpack(float h, float s, float v);
diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h
index a1db7adf33d..4bbda9709d7 100644
--- a/source/blender/blenlib/BLI_blenlib.h
+++ b/source/blender/blenlib/BLI_blenlib.h
@@ -137,6 +137,9 @@ void BLI_dlist_reinit(struct DynamicList *dlist);
void BLI_cleanup_file(const char *relabase, char *dir);
void BLI_cleanup_dir(const char *relabase, char *dir); /* same as above but adds a trailing slash */
+/* go back one directory */
+int BLI_parent_dir(char *path);
+
/**
* Blender's path code replacement function.
* Bases @a path strings leading with "//" by the
@@ -224,7 +227,7 @@ int BLI_strcaseeq(char *a, char *b);
/* in util.c */
#ifdef WITH_ICONV
-void BLI_string_to_utf8(char *original, char *utf_8, char *code);
+void BLI_string_to_utf8(char *original, char *utf_8, const char *code);
#endif
/**
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c
index 844c0cc909a..a9951406c46 100644
--- a/source/blender/blenlib/intern/arithb.c
+++ b/source/blender/blenlib/intern/arithb.c
@@ -1025,6 +1025,19 @@ int FloatCompare( float *v1, float *v2, float limit)
return 0;
}
+int FloatCompare4( float *v1, float *v2, float limit)
+{
+
+ if( fabs(v1[0]-v2[0])<limit ) {
+ if( fabs(v1[1]-v2[1])<limit ) {
+ if( fabs(v1[2]-v2[2])<limit ) {
+ if( fabs(v1[3]-v2[3])<limit ) return 1;
+ }
+ }
+ }
+ return 0;
+}
+
float FloatLerpf( float target, float origin, float fac)
{
return (fac*target) + (1.0f-fac)*origin;
@@ -3439,13 +3452,27 @@ void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv)
*lv = v;
}
-/*http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
- * SMPTE-C XYZ to RGB matrix*/
-void xyz_to_rgb(float xc, float yc, float zc, float *r, float *g, float *b)
-{
- *r = (3.50570 * xc) + (-1.73964 * yc) + (-0.544011 * zc);
- *g = (-1.06906 * xc) + (1.97781 * yc) + (0.0351720 * zc);
- *b = (0.0563117 * xc) + (-0.196994 * yc) + (1.05005 * zc);
+/*http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html */
+
+void xyz_to_rgb(float xc, float yc, float zc, float *r, float *g, float *b, int colorspace)
+{
+ switch (colorspace) {
+ case BLI_CS_SMPTE:
+ *r = (3.50570 * xc) + (-1.73964 * yc) + (-0.544011 * zc);
+ *g = (-1.06906 * xc) + (1.97781 * yc) + (0.0351720 * zc);
+ *b = (0.0563117 * xc) + (-0.196994 * yc) + (1.05005 * zc);
+ break;
+ case BLI_CS_REC709:
+ *r = (3.240476 * xc) + (-1.537150 * yc) + (-0.498535 * zc);
+ *g = (-0.969256 * xc) + (1.875992 * yc) + (0.041556 * zc);
+ *b = (0.055648 * xc) + (-0.204043 * yc) + (1.057311 * zc);
+ break;
+ case BLI_CS_CIE:
+ *r = (2.28783848734076f * xc) + (-0.833367677835217f * yc) + (-0.454470795871421f * zc);
+ *g = (-0.511651380743862f * xc) + (1.42275837632178f * yc) + (0.0888930017552939f * zc);
+ *b = (0.00572040983140966f * xc) + (-0.0159068485104036f * yc) + (1.0101864083734f * zc);
+ break;
+ }
}
/*If the requested RGB shade contains a negative weight for
diff --git a/source/blender/blenlib/intern/dynlib.c b/source/blender/blenlib/intern/dynlib.c
index c4692995f20..e7fa3332f43 100644
--- a/source/blender/blenlib/intern/dynlib.c
+++ b/source/blender/blenlib/intern/dynlib.c
@@ -77,12 +77,12 @@ char *PIL_dynlib_get_error_as_string(PILdynlib* lib) {
int err;
/* if lib is NULL reset the last error code */
+ err= GetLastError();
if (!lib) {
SetLastError(ERROR_SUCCESS);
- return NULL;
+ err = ERROR_SUCCESS;
}
- err= GetLastError();
if (err) {
static char buf[1024];
@@ -96,7 +96,7 @@ char *PIL_dynlib_get_error_as_string(PILdynlib* lib) {
return buf;
}
- return NULL;
+ return "unrecognized error";
}
void PIL_dynlib_close(PILdynlib *lib) {
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index 3e1c8afb7a8..603c85655d7 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -77,8 +77,12 @@ void BLI_edgehash_insert(EdgeHash *eh, int v0, int v1, void *val) {
unsigned int hash;
Entry *e= malloc(sizeof(*e));
- if (v1<v0) v0 ^= v1 ^= v0 ^= v1;
- hash = EDGEHASH(v0,v1)%eh->nbuckets;
+ if (v1<v0) {
+ v0 ^= v1;
+ v1 ^= v0;
+ v0 ^= v1;
+ }
+ hash = EDGEHASH(v0,v1)%eh->nbuckets;
e->v0 = v0;
e->v1 = v1;
@@ -114,7 +118,11 @@ void** BLI_edgehash_lookup_p(EdgeHash *eh, int v0, int v1) {
unsigned int hash;
Entry *e;
- if (v1<v0) v0 ^= v1 ^= v0 ^= v1;
+ if (v1<v0) {
+ v0 ^= v1;
+ v1 ^= v0;
+ v0 ^= v1;
+ }
hash = EDGEHASH(v0,v1)%eh->nbuckets;
for (e= eh->buckets[hash]; e; e= e->next)
if (v0==e->v0 && v1==e->v1)
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index 74f152ac635..48a40db6a72 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -404,8 +404,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile * pf)
break;
lcode = charcode;
}
-
- err = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
return vfd;
}
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c
index c27efcb7934..d65fe8a476a 100644
--- a/source/blender/blenlib/intern/util.c
+++ b/source/blender/blenlib/intern/util.c
@@ -1058,6 +1058,26 @@ void BLI_makestringcode(const char *relfile, char *file)
}
}
+int BLI_parent_dir(char *path)
+{
+#ifdef WIN32
+ static char *parent_dir="..\\";
+#else
+ static char *parent_dir="../";
+#endif
+ char tmp[FILE_MAXDIR+FILE_MAXFILE+4];
+ BLI_strncpy(tmp, path, sizeof(tmp));
+ BLI_add_slash(tmp);
+ strcat(tmp, parent_dir);
+ BLI_cleanup_dir(NULL, tmp);
+
+ if (!BLI_testextensie(tmp, parent_dir)) {
+ BLI_strncpy(path, tmp, sizeof(tmp));
+ return 1;
+ } else {
+ return 0;
+ }
+}
int BLI_convertstringframe(char *path, int frame)
{
@@ -1955,7 +1975,7 @@ int BLI_strncasecmp(const char *s1, const char *s2, int n) {
#include "iconv.h"
#include "localcharset.h"
-void BLI_string_to_utf8(char *original, char *utf_8, char *code)
+void BLI_string_to_utf8(char *original, char *utf_8, const char *code)
{
size_t inbytesleft=strlen(original);
size_t outbytesleft=512;