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:
authorCampbell Barton <ideasman42@gmail.com>2018-05-02 13:46:14 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-05-02 13:46:14 +0300
commitd09920687c4474f5f6ccf0f089d359f69932afac (patch)
tree3fa95c573d162f2b228d1165b66f9bb6d41cf538
parentadc17317c5af23c0986a449da6d0aef130d1f503 (diff)
parent128506eeb1a2d87393061b4c9783289a5e4b3275 (diff)
Merge branch 'master' into blender2.8
-rw-r--r--intern/cycles/device/device_cuda.cpp2
-rw-r--r--intern/cycles/kernel/kernel_types.h2
-rw-r--r--intern/cycles/kernel/svm/svm_bevel.h2
-rw-r--r--intern/cycles/kernel/svm/svm_displace.h2
-rw-r--r--intern/cycles/render/nodes.cpp2
-rw-r--r--intern/cycles/render/object.cpp2
-rw-r--r--intern/cycles/util/util_math_float3.h2
-rw-r--r--source/blender/blenkernel/intern/colortools.c2
-rw-r--r--source/blender/blenlib/BLI_math_color.h9
-rw-r--r--source/blender/blenlib/intern/math_color.c37
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.cpp4
-rw-r--r--source/blender/editors/interface/interface_draw.c2
-rw-r--r--source/blender/editors/space_image/image_draw.c6
-rw-r--r--tests/gtests/blenlib/BLI_math_color_test.cc4
16 files changed, 53 insertions, 29 deletions
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 66c3f526ae7..b1bc417ba4f 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -1684,7 +1684,7 @@ public:
min_blocks *= 8;
}
- uint step_samples = divide_up(min_blocks * num_threads_per_block, wtile->w * wtile->h);;
+ uint step_samples = divide_up(min_blocks * num_threads_per_block, wtile->w * wtile->h);
/* Render all samples. */
int start_sample = rtile.start_sample;
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index af1ecb05788..72fbf7be557 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -1452,7 +1452,7 @@ typedef struct KernelObject {
uint attribute_map_offset;
uint motion_offset;
uint pad;
-} KernelObject;;
+} KernelObject;
static_assert_align(KernelObject, 16);
typedef struct KernelSpotLight {
diff --git a/intern/cycles/kernel/svm/svm_bevel.h b/intern/cycles/kernel/svm/svm_bevel.h
index 6d5a10db98f..89f4a98e846 100644
--- a/intern/cycles/kernel/svm/svm_bevel.h
+++ b/intern/cycles/kernel/svm/svm_bevel.h
@@ -216,7 +216,7 @@ ccl_device void svm_node_bevel(
if(stack_valid(normal_offset)) {
/* Preserve input normal. */
float3 ref_N = stack_load_float3(stack, normal_offset);
- bevel_N = normalize(ref_N + (bevel_N - sd->N));;
+ bevel_N = normalize(ref_N + (bevel_N - sd->N));
}
stack_store_float3(stack, out_offset, bevel_N);
diff --git a/intern/cycles/kernel/svm/svm_displace.h b/intern/cycles/kernel/svm/svm_displace.h
index b9fd5bbf84d..533b7f065e6 100644
--- a/intern/cycles/kernel/svm/svm_displace.h
+++ b/intern/cycles/kernel/svm/svm_displace.h
@@ -141,7 +141,7 @@ ccl_device void svm_node_vector_displacement(KernelGlobals *kg, ShaderData *sd,
tangent = normalize(sd->dPdu);
}
- float3 bitangent = normalize(cross(normal, tangent));;
+ float3 bitangent = normalize(cross(normal, tangent));
const AttributeDescriptor attr_sign = find_attribute(kg, sd, node.w);
if(attr_sign.offset != ATTR_STD_NOT_FOUND) {
float sign = primitive_attribute_float(kg, sd, attr_sign, NULL, NULL);
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index d732189af66..01399c85bc0 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -4601,7 +4601,7 @@ void AttributeNode::compile(SVMCompiler& compiler)
ShaderOutput *vector_out = output("Vector");
ShaderOutput *fac_out = output("Fac");
ShaderNodeType attr_node = NODE_ATTR;
- int attr = compiler.attribute_standard(attribute);;
+ int attr = compiler.attribute_standard(attribute);
if(bump == SHADER_BUMP_DX)
attr_node = NODE_ATTR_BUMP_DX;
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index 138de250c5f..4d64d841206 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -480,7 +480,7 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
kobject.dupli_uv[1] = ob->dupli_uv[1];
int totalsteps = mesh->motion_steps;
kobject.numsteps = (totalsteps - 1)/2;
- kobject.numverts = mesh->verts.size();;
+ kobject.numverts = mesh->verts.size();
kobject.patch_map_offset = 0;
kobject.attribute_map_offset = 0;
diff --git a/intern/cycles/util/util_math_float3.h b/intern/cycles/util/util_math_float3.h
index a0a62ae95df..f5149fe13ed 100644
--- a/intern/cycles/util/util_math_float3.h
+++ b/intern/cycles/util/util_math_float3.h
@@ -67,7 +67,7 @@ ccl_device_inline float len_squared(const float3 a);
ccl_device_inline float3 saturate3(float3 a);
ccl_device_inline float3 safe_normalize(const float3 a);
-ccl_device_inline float3 normalize_len(const float3 a, float *t);;
+ccl_device_inline float3 normalize_len(const float3 a, float *t);
ccl_device_inline float3 safe_normalize_len(const float3 a, float *t);
ccl_device_inline float3 interp(float3 a, float3 b, float t);
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 0fe429312db..e7fa4cee587 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -1034,7 +1034,7 @@ static void save_sample_line(Scopes *scopes, const int idx, const float fx, cons
float yuv[3];
/* vectorscope*/
- rgb_to_yuv(rgb[0], rgb[1], rgb[2], &yuv[0], &yuv[1], &yuv[2]);
+ rgb_to_yuv(rgb[0], rgb[1], rgb[2], &yuv[0], &yuv[1], &yuv[2], BLI_YUV_ITU_BT709);
scopes->vecscope[idx + 0] = yuv[1];
scopes->vecscope[idx + 1] = yuv[2];
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index 34fc52c12c0..72d29164988 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -51,6 +51,10 @@ extern "C" {
#define BLI_YCC_ITU_BT709 1
#define BLI_YCC_JFIF_0_255 2
+/* YUV */
+#define BLI_YUV_ITU_BT601 0
+#define BLI_YUV_ITU_BT709 1
+
/******************* Conversion to RGB ********************/
void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b);
@@ -58,14 +62,14 @@ void hsv_to_rgb_v(const float hsv[3], float r_rgb[3]);
void hsl_to_rgb(float h, float c, float l, float *r, float *g, float *b);
void hsl_to_rgb_v(const float hcl[3], float r_rgb[3]);
void hex_to_rgb(char *hexcol, float *r, float *g, float *b);
-void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb);
+void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb, int colorspace);
void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb, int colorspace);
void xyz_to_rgb(float x, float y, float z, float *r, float *g, float *b, int colorspace);
void cpack_to_rgb(unsigned int col, float *r, float *g, float *b);
/***************** Conversion from RGB ********************/
-void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv);
+void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv, int colorspace);
void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr, int colorspace);
void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv);
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3]);
@@ -164,4 +168,3 @@ void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *o
#endif
#endif /* __BLI_MATH_COLOR_H__ */
-
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 3879a409675..2a6f28ef6ee 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -83,24 +83,45 @@ void hsl_to_rgb_v(const float hsl[3], float r_rgb[3])
hsl_to_rgb(hsl[0], hsl[1], hsl[2], &r_rgb[0], &r_rgb[1], &r_rgb[2]);
}
-void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv)
+void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv, int colorspace)
{
float y, u, v;
- y = 0.299f * r + 0.587f * g + 0.114f * b;
- u = -0.147f * r - 0.289f * g + 0.436f * b;
- v = 0.615f * r - 0.515f * g - 0.100f * b;
+
+ switch (colorspace) {
+ case BLI_YUV_ITU_BT601:
+ y = 0.299f * r + 0.587f * g + 0.114f * b;
+ u = -0.147f * r - 0.289f * g + 0.436f * b;
+ v = 0.615f * r - 0.515f * g - 0.100f * b;
+ break;
+ case BLI_YUV_ITU_BT709:
+ default:
+ y = 0.2126f * r + 0.7152f * g + 0.0722f * b;
+ u = -0.09991f * r - 0.33609f * g + 0.436f * b;
+ v = 0.615f * r - 0.55861f * g - 0.05639f * b;
+ break;
+ }
*ly = y;
*lu = u;
*lv = v;
}
-void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb)
+void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb, int colorspace)
{
float r, g, b;
- r = y + 1.140f * v;
- g = y - 0.394f * u - 0.581f * v;
- b = y + 2.032f * u;
+
+ switch (colorspace) {
+ case BLI_YUV_ITU_BT601:
+ r = y + 1.140f * v;
+ g = y - 0.394f * u - 0.581f * v;
+ b = y + 2.032f * u;
+ break;
+ case BLI_YUV_ITU_BT709:
+ r = y + 1.28033f * v;
+ g = y - 0.21482f * u - 0.38059f * v;
+ b = y + 2.12798f * u;
+ break;
+ }
*lr = r;
*lg = g;
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
index d26dcd17750..ecbc7a9a93d 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
@@ -121,7 +121,7 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile)
case 5:
{
float yuv[3];
- rgb_to_yuv(buffer[offset], buffer[offset + 1], buffer[offset + 2], &yuv[0], &yuv[1], &yuv[2]);
+ rgb_to_yuv(buffer[offset], buffer[offset + 1], buffer[offset + 2], &yuv[0], &yuv[1], &yuv[2], BLI_YUV_ITU_BT709);
sum += yuv[0];
break;
}
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
index 6b238e53d7b..56b402f2b3b 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
@@ -87,7 +87,7 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect)
case 5: /* luminance */
{
float yuv[3];
- rgb_to_yuv(buffer[offset], buffer[offset + 1], buffer[offset + 2], &yuv[0], &yuv[1], &yuv[2]);
+ rgb_to_yuv(buffer[offset], buffer[offset + 1], buffer[offset + 2], &yuv[0], &yuv[1], &yuv[2], BLI_YUV_ITU_BT709);
sum += (yuv[0] - mean) * (yuv[0] - mean);
break;
}
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.cpp b/source/blender/compositor/operations/COM_ConvertOperation.cpp
index 8b8e8408208..327015c1139 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertOperation.cpp
@@ -241,7 +241,7 @@ void ConvertRGBToYUVOperation::executePixelSampled(float output[4], float x, flo
{
float inputColor[4];
this->m_inputOperation->readSampled(inputColor, x, y, sampler);
- rgb_to_yuv(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2]);
+ rgb_to_yuv(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2], BLI_YUV_ITU_BT709);
output[3] = inputColor[3];
}
@@ -258,7 +258,7 @@ void ConvertYUVToRGBOperation::executePixelSampled(float output[4], float x, flo
{
float inputColor[4];
this->m_inputOperation->readSampled(inputColor, x, y, sampler);
- yuv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2]);
+ yuv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2], BLI_YUV_ITU_BT709);
output[3] = inputColor[3];
}
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 97491d365b7..11cbc448713 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1114,7 +1114,7 @@ static void vectorscope_draw_target(unsigned int pos, float centerx, float cente
float tangle = 0.0f, tampli;
float dangle, dampli, dangle2, dampli2;
- rgb_to_yuv(colf[0], colf[1], colf[2], &y, &u, &v);
+ rgb_to_yuv(colf[0], colf[1], colf[2], &y, &u, &v, BLI_YUV_ITU_BT709);
if (u > 0 && v >= 0) tangle = atanf(v / u);
else if (u > 0 && v < 0) tangle = atanf(v / u) + 2.0f * (float)M_PI;
else if (u < 0) tangle = atanf(v / u) + (float)M_PI;
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index e1ba83a0d78..fc4d8c39e26 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -378,11 +378,11 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
if (channels == 1) {
if (fp) {
rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val);
- rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v);
+ rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v, BLI_YUV_ITU_BT709);
}
else if (cp) {
rgb_to_hsv((float)cp[0] / 255.0f, (float)cp[0] / 255.0f, (float)cp[0] / 255.0f, &hue, &sat, &val);
- rgb_to_yuv((float)cp[0] / 255.0f, (float)cp[0] / 255.0f, (float)cp[0] / 255.0f, &lum, &u, &v);
+ rgb_to_yuv((float)cp[0] / 255.0f, (float)cp[0] / 255.0f, (float)cp[0] / 255.0f, &lum, &u, &v, BLI_YUV_ITU_BT709);
}
BLI_snprintf(str, sizeof(str), "V:%-.4f", val);
@@ -396,7 +396,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
}
else if (channels >= 3) {
rgb_to_hsv(finalcol[0], finalcol[1], finalcol[2], &hue, &sat, &val);
- rgb_to_yuv(finalcol[0], finalcol[1], finalcol[2], &lum, &u, &v);
+ rgb_to_yuv(finalcol[0], finalcol[1], finalcol[2], &lum, &u, &v, BLI_YUV_ITU_BT709);
BLI_snprintf(str, sizeof(str), "H:%-.4f", hue);
BLF_position(blf_mono_font, dx, dy, 0);
diff --git a/tests/gtests/blenlib/BLI_math_color_test.cc b/tests/gtests/blenlib/BLI_math_color_test.cc
index 2118822a9d8..8989e6740a5 100644
--- a/tests/gtests/blenlib/BLI_math_color_test.cc
+++ b/tests/gtests/blenlib/BLI_math_color_test.cc
@@ -27,9 +27,9 @@ TEST(math_color, RGBToYUVRoundtrip)
float orig_rgb[3] = {0.1f, 0.2f, 0.3f};
float yuv[3], rgb[3];
rgb_to_yuv(orig_rgb[0], orig_rgb[1], orig_rgb[2],
- &yuv[0], &yuv[1], &yuv[2]);
+ &yuv[0], &yuv[1], &yuv[2], BLI_YUV_ITU_BT709);
yuv_to_rgb(yuv[0], yuv[1], yuv[2],
- &rgb[0], &rgb[1], &rgb[2]);
+ &rgb[0], &rgb[1], &rgb[2], BLI_YUV_ITU_BT709);
EXPECT_V3_NEAR(orig_rgb, rgb, 1e-4);
}