Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Use English for 'iwa_motionblurfx' comments

Campbell Bartond3ecc4ec7bbc
diff --git a/toonz/sources/stdfx/iwa_motionblurfx.cpp b/toonz/sources/stdfx/iwa_motionblurfx.cpp
index 564ee77f9..2ea9dd7ac 100644
--- a/toonz/sources/stdfx/iwa_motionblurfx.cpp
+++ b/toonz/sources/stdfx/iwa_motionblurfx.cpp
@@ -1,7 +1,7 @@
/*------------------------------------
Iwa_MotionBlurCompFx
-露光量/オブジェクトの軌跡を考慮したモーションブラー
-背景との露光値合成を可能にする
+Amount of light/Motion blur considering the trajectory of the object
+Enable synthesis of exposure value with background.
//------------------------------------*/
#include "iwa_motionblurfx.h"
@@ -11,9 +11,8 @@ Iwa_MotionBlurCompFx
#include "trop.h"
-/*- ソース画像を0〜1に正規化してホストメモリに読み込む
- ソース画像がPremultipyされているか、コンボボックスで指定されていない場合は
- ここで判定する -*/
+/* Normalize the source image to 0 to 1 and read it into the host memory
+ * If the source image is premultiped or not specified in the combo box. */
template <typename RASTER, typename PIXEL>
bool Iwa_MotionBlurCompFx::setSourceRaster(const RASTER srcRas, float4 *dstMem,
TDimensionI dim,
@@ -33,8 +32,9 @@ bool Iwa_MotionBlurCompFx::setSourceRaster(const RASTER srcRas, float4 *dstMem,
(*chann_p).z = (float)pix->b / (float)PIXEL::maxChannelValue;
(*chann_p).w = (float)pix->m / (float)PIXEL::maxChannelValue;
- /*- RGB値がアルファチャンネルより大きいピクセルがあれば、
- Premutiplyされていないと判断する -*/
+ /* If there are pixels whose RGB values ​​are larger than the alpha
+ * channel,
+ * Don't Premutiply */
if (type == AUTO && isPremultiplied &&
(((*chann_p).x > (*chann_p).w && (*chann_p).x > threshold) ||
((*chann_p).y > (*chann_p).w && (*chann_p).y > threshold) ||
@@ -59,7 +59,7 @@ bool Iwa_MotionBlurCompFx::setSourceRaster(const RASTER srcRas, float4 *dstMem,
}
/*------------------------------------------------------------
- 出力結果をChannel値に変換してタイルに格納
+ Convert output result to Channel value and store it in the tile
------------------------------------------------------------*/
template <typename RASTER, typename PIXEL>
void Iwa_MotionBlurCompFx::setOutputRaster(float4 *srcMem, const RASTER dstRas,
@@ -94,70 +94,72 @@ void Iwa_MotionBlurCompFx::setOutputRaster(float4 *srcMem, const RASTER dstRas,
}
/*------------------------------------------------------------
- フィルタをつくり、正規化する
+ Create and normalize filters
------------------------------------------------------------*/
void Iwa_MotionBlurCompFx::makeMotionBlurFilter_CPU(
float *filter_p, TDimensionI &filterDim, int marginLeft, int marginBottom,
float4 *pointsTable, int pointAmount, float startValue, float startCurve,
float endValue, float endCurve) {
- /*- フィルタ値を足しこむための変数 -*/
+ /* Variable to add filter value */
float fil_val_sum = 0.0f;
- /*- for文の中で回す、現在のフィルタ座標 -*/
+ /* For current filter coordinates to rotate in the 'for' statement */
float *current_fil_p = filter_p;
- /*- 各フィルタの座標について -*/
+ /* Coordinates of each filter information */
for (int fily = 0; fily < filterDim.ly; fily++) {
for (int filx = 0; filx < filterDim.lx; filx++, current_fil_p++) {
- /*- フィルタ座標を得る -*/
+ /* Get filter coordinates */
float2 pos = {static_cast<float>(filx - marginLeft),
static_cast<float>(fily - marginBottom)};
- /*- 更新してゆく値 -*/
+ /* Value to update */
float nearestDist2 = 100.0f;
int nearestIndex = -1;
float nearestFramePosRatio = 0.0f;
- /*- 各サンプル点のペアについて、一番近い点を探す -*/
+ /* Find the nearest point for each pair of sample points */
for (int v = 0; v < pointAmount - 1; v++) {
float4 p0 = pointsTable[v];
float4 p1 = pointsTable[v + 1];
- /*- 範囲内に無ければcontinue -*/
+ /* If it is not within the range, continue */
if (pos.x < std::min(p0.x, p1.x) - 1.0f ||
pos.x > std::max(p0.x, p1.x) + 1.0f ||
pos.y < std::min(p0.y, p1.y) - 1.0f ||
pos.y > std::max(p0.y, p1.y) + 1.0f)
continue;
- /*- 範囲内にあるので、線分と点の距離を得る -*/
- /*- P0->サンプル点とP0->P1の内積を求める -*/
+ /* Since it is within the range, obtain the distance between the line
+ * segment and the point. */
+ /* Find the inner product of 'p0' -> sampling point and 'p0' -> 'p1' */
float2 vec_p0_sample = {static_cast<float>(pos.x - p0.x),
static_cast<float>(pos.y - p0.y)};
float2 vec_p0_p1 = {static_cast<float>(p1.x - p0.x),
static_cast<float>(p1.y - p0.y)};
float dot =
vec_p0_sample.x * vec_p0_p1.x + vec_p0_sample.y * vec_p0_p1.y;
- /*- 距離の2乗を求める -*/
+ /* Find the square of distance */
float dist2;
float framePosRatio;
- /*- P0より手前にある場合 -*/
+ /* When it is before 'p0' */
if (dot <= 0.0f) {
dist2 = vec_p0_sample.x * vec_p0_sample.x +
vec_p0_sample.y * vec_p0_sample.y;
framePosRatio = 0.0f;
} else {
- /*- 軌跡ベクトルの長さの2乗を計算する -*/
+ /* Calculate the square of the length of the trajectory vector */
float length2 = p0.z * p0.z;
- /*- P0〜P1間にある場合
- pでの軌跡が点のとき、length2は0になるので、この条件の中に入ることはない。
- ので、ZeroDivideになる心配はないはず。 -*/
+ /* When it is between 'p0' and 'p1'
+ * When the trajectory at p is a point,
+ * length 2 becomes 0, so it will never fall into this condition.
+ * So, there should not be worry of becoming ZeroDivide. */
if (dot < length2) {
float p0_sample_dist2 = vec_p0_sample.x * vec_p0_sample.x +
vec_p0_sample.y * vec_p0_sample.y;
dist2 = p0_sample_dist2 - dot * dot / length2;
framePosRatio = dot / length2;
}
- /*- P1より先にある場合 -*/
+ /* if it is before 'p1' */
else {
float2 vec_p1_sample = {pos.x - p1.x, pos.y - p1.y};
dist2 = vec_p1_sample.x * vec_p1_sample.x +
@@ -165,11 +167,11 @@ void Iwa_MotionBlurCompFx::makeMotionBlurFilter_CPU(
framePosRatio = 1.0f;
}
}
- /*- 距離が(√2 + 1)/2より遠かったらcontinue
- * dist2との比較だから2乗している -*/
+ /* If the distance is farther than (√ 2 + 1) / 2, continue
+ * Because it is a comparison with dist2 I'm squaring */
if (dist2 > 1.4571f) continue;
- /*- 距離がより近かったら更新する -*/
+ /* Update if distance is closer */
if (dist2 < nearestDist2) {
nearestDist2 = dist2;
nearestIndex = v;
@@ -177,88 +179,95 @@ void Iwa_MotionBlurCompFx::makeMotionBlurFilter_CPU(
}
}
- /*-
- * 現在のピクセルの、近傍ベクトルが見つからなかった場合、フィルタ値は0でreturn
- * -*/
+ /* If neighbors of the current pixel can not be found,
+ * the filter value is 0 and return */
if (nearestIndex == -1) {
*current_fil_p = 0.0f;
continue;
}
- /*-
- 現在のピクセルのサブピクセル(16*16)が、近傍ベクトルからの距離0.5の範囲にどれだけ
- 含まれているかをカウントする。 -*/
+ /* How much is the subpixel (16 * 16) of the current pixel
+ * in the range 0.5 from the neighborhood vector.
+ *
+ * It counts whether it is included.
+ */
int count = 0;
float4 np0 = pointsTable[nearestIndex];
float4 np1 = pointsTable[nearestIndex + 1];
for (int yy = 0; yy < 16; yy++) {
- /*- サブピクセルのY座標 -*/
+ /* the Y coordinate of the sub pixel */
float subPosY = pos.y + ((float)yy - 7.5f) / 16.0f;
for (int xx = 0; xx < 16; xx++) {
- /*- サブピクセルのX座標 -*/
+ /* X coordinate of subpixel */
float subPosX = pos.x + ((float)xx - 7.5f) / 16.0f;
float2 vec_np0_sub = {subPosX - np0.x, subPosY - np0.y};
float2 vec_np0_np1 = {np1.x - np0.x, np1.y - np0.y};
float dot =
vec_np0_sub.x * vec_np0_np1.x + vec_np0_sub.y * vec_np0_np1.y;
- /*- 距離の2乗を求める -*/
+ /* Find the square of the distance */
float dist2;
- /*- P0より手前にある場合 -*/
+ /* When it is before 'p0' */
if (dot <= 0.0f)
dist2 =
vec_np0_sub.x * vec_np0_sub.x + vec_np0_sub.y * vec_np0_sub.y;
else {
- /*- 軌跡ベクトルの長さの2乗を計算する -*/
+ /* Compute the square of the length of the trajectory vector */
float length2 = np0.z * np0.z;
- /*- P0〜P1間にある場合 -*/
+ /* When it is between 'p0' and 'p1' */
if (dot < length2) {
float np0_sub_dist2 =
vec_np0_sub.x * vec_np0_sub.x + vec_np0_sub.y * vec_np0_sub.y;
dist2 = np0_sub_dist2 - dot * dot / length2;
}
- /*- P1より先にある場合 -*/
+ /* if it is before 'p1' */
else {
float2 vec_np1_sub = {subPosX - np1.x, subPosY - np1.y};
dist2 =
vec_np1_sub.x * vec_np1_sub.x + vec_np1_sub.y * vec_np1_sub.y;
}
}
- /*- 距離の2乗が0.25より近ければカウントをインクリメント -*/
+ /* Increment count if distance squared is less than 0.25 */
if (dist2 <= 0.25f) count++;
}
}
- /*- 保険 カウントが0の場合はフィールド値0でreturn -*/
+ /* If the insurance count is 0, the field value is 0 and return. */
if (count == 0) {
*current_fil_p = 0.0f;
continue;
}
- /*- countは Max256 -*/
+ /* Count is Max 256 */
float countRatio = (float)count / 256.0f;
- /*- フィルタ値の明るさは、ベクトルが作る幅1の線の面積に反比例する。
- ベクトルの前後には半径0.5の半円のキャップがあるので、長さ0のベクトルでも
- 0-divideになることはない。-*/
+ /* The brightness of the filter value is inversely proportional
+ * to the area of ​​the line of width 1 made by the vector.
+ *
+ * Since there are semicircular caps with radius 0.5
+ * before and after the vector, even vectors of length 0.
+ *
+ * It will never be 0-divide.
+ */
- /*- 近傍ベクトル、幅1のときの面積 -*/
+ /* Neighborhood vector, area when width 1 */
float vecMenseki = 0.25f * 3.14159265f + np0.z;
//-----------------
- /*- 続いて、ガンマ強弱の値を得る -*/
- /*- 近傍点のフレームのオフセット値 -*/
+ /* Next, get the value of the gamma strength */
+ /* Offset value of the frame of the neighbor point */
float curveValue;
float frameOffset =
np0.w * (1.0f - nearestFramePosRatio) + np1.w * nearestFramePosRatio;
- /*- フレームがちょうどフレーム原点、又は減衰値が無い場合はcurveValue = 1
- * -*/
+ /* If the frame is exactly at the frame origin,
+ * or 'curveValue = 1' if there is no attenuation value.
+ */
if (frameOffset == 0.0f || (frameOffset < 0.0f && startValue == 1.0f) ||
(frameOffset > 0.0f && endValue == 1.0f))
curveValue = 1.0f;
else {
- /*- オフセットの正負によって変える -*/
+ /* Change according to positive / negative of offset */
float value, curve, ratio;
- if (frameOffset < 0.0f) /*- start側 -*/
+ if (frameOffset < 0.0f) /* Start side */
{
value = startValue;
curve = startCurve;
@@ -273,13 +282,13 @@ void Iwa_MotionBlurCompFx::makeMotionBlurFilter_CPU(
}
//-----------------
- /*- フィールド値の格納 -*/
+ /* Store field value */
*current_fil_p = curveValue * countRatio / vecMenseki;
fil_val_sum += *current_fil_p;
}
}
- /*- 正規化 -*/
+ /* Normalization */
current_fil_p = filter_p;
for (int f = 0; f < filterDim.lx * filterDim.ly; f++, current_fil_p++) {
*current_fil_p /= fil_val_sum;
@@ -287,49 +296,51 @@ void Iwa_MotionBlurCompFx::makeMotionBlurFilter_CPU(
}
/*------------------------------------------------------------
- 残像フィルタをつくり、正規化する
+ Create afterimage filter and normalize
------------------------------------------------------------*/
void Iwa_MotionBlurCompFx::makeZanzoFilter_CPU(
float *filter_p, TDimensionI &filterDim, int marginLeft, int marginBottom,
float4 *pointsTable, int pointAmount, float startValue, float startCurve,
float endValue, float endCurve) {
- /*-フィルタ値足しこむための変数-*/
+ /* Variable for adding filter value */
float fil_val_sum = 0.0f;
- /*- for文の中で回す、現在のフィルタ座標 -*/
+ /* For current filter coordinates to rotate in the for statement */
float *current_fil_p = filter_p;
- /*- 各フィルタの座標について -*/
+ /* About the coordinates of each filter */
for (int fily = 0; fily < filterDim.ly; fily++) {
for (int filx = 0; filx < filterDim.lx; filx++, current_fil_p++) {
- /*- フィルタ座標を得る -*/
+ /* Get filter coordinates */
float2 pos = {(float)(filx - marginLeft), (float)(fily - marginBottom)};
- /*- これから積算する変数 -*/
+ /* Variable to be accumulated from now */
float filter_sum = 0.0f;
- /*- 各サンプル点について距離を測り、濃度を積算していく -*/
+ /* Measure the distance for each sample point and accumulate the
+ * concentration */
for (int v = 0; v < pointAmount; v++) {
float4 p0 = pointsTable[v];
- /*- p0の座標を中心として、距離 1 以内に無ければcontinue -*/
+ /* If it is not within the distance 1 around the coordinates of 'p0',
+ * continue */
if (pos.x < p0.x - 1.0f || pos.x > p0.x + 1.0f || pos.y < p0.y - 1.0f ||
pos.y > p0.y + 1.0f)
continue;
- /*- 近傍4ピクセルで線形補間する -*/
+ /* Linear interpolation with 4 neighboring pixels */
float xRatio = 1.0f - abs(pos.x - p0.x);
float yRatio = 1.0f - abs(pos.y - p0.y);
- /*- 続いて、ガンマ強弱の値を得る -*/
- /*- 近傍点のフレームのオフセット値 -*/
+ /* Next, get the value of the gamma strength */
+ /* Offset value of the frame of the neighbor point */
float curveValue;
float frameOffset = p0.w;
- /*- フレームがちょうどフレーム原点、又は減衰値が無い場合はcurveValue = 1
- * -*/
+ /* If the frame is exactly at the frame origin,
+ * or curveValue = 1 if there is no attenuation value */
if (frameOffset == 0.0f || (frameOffset < 0.0f && startValue == 1.0f) ||
(frameOffset > 0.0f && endValue == 1.0f))
curveValue = 1.0f;
else {
- /*- オフセットの正負によって変える -*/
+ /* Change according to positive / negative of offset */
float value, curve, ratio;
- if (frameOffset < 0.0f) /*- start側 -*/
+ if (frameOffset < 0.0f) /* Start side */
{
value = startValue;
curve = startCurve;
@@ -344,17 +355,17 @@ void Iwa_MotionBlurCompFx::makeZanzoFilter_CPU(
}
//-----------------
- /*- フィルタ値積算 -*/
+ /* Filter value integration */
filter_sum += xRatio * yRatio * curveValue;
}
- /*- 値を格納 -*/
+ /* Store value */
*current_fil_p = filter_sum;
fil_val_sum += *current_fil_p;
}
}
- /*- 正規化 -*/
+ /* Normalization */
current_fil_p = filter_p;
for (int f = 0; f < filterDim.lx * filterDim.ly; f++, current_fil_p++) {
*current_fil_p /= fil_val_sum;
@@ -362,7 +373,7 @@ void Iwa_MotionBlurCompFx::makeZanzoFilter_CPU(
}
/*------------------------------------------------------------
- 露光値をdepremultipy→RGB値(0〜1)に戻す→premultiply
+ Return exposure value from depremultipy to RGB value (0 to 1) -> premultiply
------------------------------------------------------------*/
void Iwa_MotionBlurCompFx::convertRGBtoExposure_CPU(
@@ -370,7 +381,7 @@ void Iwa_MotionBlurCompFx::convertRGBtoExposure_CPU(
bool sourceIsPremultiplied) {
float4 *cur_tile_p = in_tile_p;
for (int i = 0; i < dim.lx * dim.ly; i++, cur_tile_p++) {
- /*- アルファが0ならreturn -*/
+ /* if alpha is 0 return */
if (cur_tile_p->w == 0.0f) {
cur_tile_p->x = 0.0f;
cur_tile_p->y = 0.0f;
@@ -378,21 +389,21 @@ void Iwa_MotionBlurCompFx::convertRGBtoExposure_CPU(
continue;
}
- /*- 通常のLevelなど、Premultiplyされている素材に対し、depremultiplyを行う
- DigiBookなどには行わない -*/
+ /* Do depremultiply on materials that are premultiply, such as regular Level
+ * It is not done for DigiBook etc. */
if (sourceIsPremultiplied) {
- /*- depremultiply -*/
+ /* depremultiply */
cur_tile_p->x /= cur_tile_p->w;
cur_tile_p->y /= cur_tile_p->w;
cur_tile_p->z /= cur_tile_p->w;
}
- /*- RGBはExposureにする -*/
+ /* Set RGB to Exposure */
cur_tile_p->x = powf(10, (cur_tile_p->x - 0.5f) * hardness);
cur_tile_p->y = powf(10, (cur_tile_p->y - 0.5f) * hardness);
cur_tile_p->z = powf(10, (cur_tile_p->z - 0.5f) * hardness);
- /*- その後、アルファチャンネルでmultiply -*/
+ /* Then multiply on the alpha channel */
cur_tile_p->x *= cur_tile_p->w;
cur_tile_p->y *= cur_tile_p->w;
cur_tile_p->z *= cur_tile_p->w;
@@ -400,8 +411,8 @@ void Iwa_MotionBlurCompFx::convertRGBtoExposure_CPU(
}
/*------------------------------------------------------------
- 露光値をフィルタリングしてぼかす
- outDim の範囲だけループで回す
+ Filter and blur exposure values
+ Rotate by the loop only the range of 'outDim'.
------------------------------------------------------------*/
void Iwa_MotionBlurCompFx::applyBlurFilter_CPU(
@@ -409,30 +420,31 @@ void Iwa_MotionBlurCompFx::applyBlurFilter_CPU(
float *filter_p, TDimensionI &filterDim, int marginLeft, int marginBottom,
int marginRight, int marginTop, TDimensionI &outDim) {
for (int i = 0; i < outDim.lx * outDim.ly; i++) {
- /*- in_tile_devとout_tile_devはlx * ly の寸法でデータが入っている。
- ので、i を出力用の座標に変換する -*/
+ /* in_tile_dev and out_tile_dev contain data with dimensions lx * ly.
+ * Convert i to coordinates for output. */
int2 outPos = {i % outDim.lx + marginRight, i / outDim.lx + marginTop};
int outIndex = outPos.y * enlargedDim.lx + outPos.x;
- /*- out_tile_dev[outIndex]に結果をおさめていく -*/
+ /* put the result in out_tile_dev [outIndex] */
- /*- 値を積算する入れ物を用意 -*/
+ /* Prepare a container to accumulate values ​​- */
float4 value = {0.0f, 0.0f, 0.0f, 0.0f};
- /*- フィルタのサイズでループ
- ただし、フィルタはサンプル点の画像を収集するように
- 用いるため、上下左右反転してサンプルする -*/
+ /* Loop by filter size.
+ * However, the filter is designed to collect images of sample points
+ * To use it, invert the sample vertically and horizontally and sample it */
int filterIndex = 0;
for (int fily = -marginBottom; fily < filterDim.ly - marginBottom; fily++) {
- /*- サンプル座標 と インデックス の このスキャンラインのうしろ -*/
+ /* Sample coordinates and index back of this scan line */
int2 samplePos = {outPos.x + marginLeft, outPos.y - fily};
int sampleIndex = samplePos.y * enlargedDim.lx + samplePos.x;
for (int filx = -marginLeft; filx < filterDim.lx - marginLeft;
filx++, filterIndex++, sampleIndex--) {
- /*- フィルター値が0またはサンプルピクセルが透明ならcontinue -*/
+ /* If the filter value is 0 or the sample pixel is transparent continue
+ */
if (filter_p[filterIndex] == 0.0f || in_tile_p[sampleIndex].w == 0.0f)
continue;
- /*- サンプル点の値にフィルタ値を掛けて積算する -*/
+ /* multiply the sample point value by the filter value and integrate */
value.x += in_tile_p[sampleIndex].x * filter_p[filterIndex];
value.y += in_tile_p[sampleIndex].y * filter_p[filterIndex];
value.z += in_tile_p[sampleIndex].z * filter_p[filterIndex];
@@ -448,7 +460,8 @@ void Iwa_MotionBlurCompFx::applyBlurFilter_CPU(
}
/*------------------------------------------------------------
- 露光値をdepremultipy→RGB値(0〜1)に戻す→premultiply
+ Return exposure value from depremultipy to RGB value
+ (0 to 1) -> premultiply
------------------------------------------------------------*/
void Iwa_MotionBlurCompFx::convertExposureToRGB_CPU(float4 *out_tile_p,
@@ -456,7 +469,7 @@ void Iwa_MotionBlurCompFx::convertExposureToRGB_CPU(float4 *out_tile_p,
float hardness) {
float4 *cur_tile_p = out_tile_p;
for (int i = 0; i < dim.lx * dim.ly; i++, cur_tile_p++) {
- /*- アルファが0ならreturn -*/
+ /* if alpha is 0 return */
if (cur_tile_p->w == 0.0f) {
cur_tile_p->x = 0.0f;
cur_tile_p->y = 0.0f;
@@ -469,7 +482,7 @@ void Iwa_MotionBlurCompFx::convertExposureToRGB_CPU(float4 *out_tile_p,
cur_tile_p->y /= cur_tile_p->w;
cur_tile_p->z /= cur_tile_p->w;
- /*- ExposureをRGB値にする -*/
+ /* Set Exposure to RGB value */
cur_tile_p->x = log10f(cur_tile_p->x) / hardness + 0.5f;
cur_tile_p->y = log10f(cur_tile_p->y) / hardness + 0.5f;
cur_tile_p->z = log10f(cur_tile_p->z) / hardness + 0.5f;
@@ -479,7 +492,7 @@ void Iwa_MotionBlurCompFx::convertExposureToRGB_CPU(float4 *out_tile_p,
cur_tile_p->y *= cur_tile_p->w;
cur_tile_p->z *= cur_tile_p->w;
- /*- クランプ -*/
+ /* Clamp */
cur_tile_p->x = (cur_tile_p->x > 1.0f)
? 1.0f
: ((cur_tile_p->x < 0.0f) ? 0.0f : cur_tile_p->x);
@@ -493,7 +506,7 @@ void Iwa_MotionBlurCompFx::convertExposureToRGB_CPU(float4 *out_tile_p,
}
/*------------------------------------------------------------
- 背景があり、前景が動かない場合、単純にOverする
+ If there is a background and the foreground does not move, simply over
------------------------------------------------------------*/
void Iwa_MotionBlurCompFx::composeWithNoMotion(
TTile &tile, double frame, const TRenderSettings &settings) {
@@ -511,19 +524,20 @@ void Iwa_MotionBlurCompFx::composeWithNoMotion(
}
/*------------------------------------------------------------
- 背景を露光値にして通常合成
+ Normally synthesized with background as exposure value
------------------------------------------------------------*/
void Iwa_MotionBlurCompFx::composeBackgroundExposure_CPU(
float4 *out_tile_p, TDimensionI &enlargedDimIn, int marginRight,
int marginTop, TTile &back_tile, TDimensionI &dimOut, float hardness) {
- /*- ホストのメモリ確保 -*/
+ /* Memory allocation of host */
TRasterGR8P background_host_ras(sizeof(float4) * dimOut.lx, dimOut.ly);
background_host_ras->lock();
float4 *background_host = (float4 *)background_host_ras->getRawData();
bool bgIsPremultiplied;
- /*- 背景画像を0〜1に正規化してホストメモリに読み込む -*/
+ /* normalize the background image to 0 to 1 and read it into the host memory
+ */
TRaster32P backRas32 = (TRaster32P)back_tile.getRaster();
TRaster64P backRas64 = (TRaster64P)back_tile.getRaster();
if (backRas32)
@@ -539,16 +553,17 @@ void Iwa_MotionBlurCompFx::composeBackgroundExposure_CPU(
for (int j = 0; j < dimOut.ly; j++) {
out_p = out_tile_p + ((marginTop + j) * enlargedDimIn.lx + marginRight);
for (int i = 0; i < dimOut.lx; i++, bg_p++, out_p++) {
- /*- 上レイヤが完全に不透明ならcontinue -*/
+ /* if upper layer is completely opaque continue */
if ((*out_p).w >= 1.0f) continue;
- /*- 下レイヤが完全に透明でもcontinue -*/
+ /* even if the lower layer is completely transparent continue */
if ((*bg_p).w < 0.0001f) continue;
float3 bgExposure = {(*bg_p).x, (*bg_p).y, (*bg_p).z};
- /*- 通常のLevelなど、Premultiplyされている素材に対し、depremultiplyを行う
- DigiBookなどには行わない -*/
+ /* Do depremultiply on materials that are premultiply, such as regular
+ * Level.
+ * It is not done for DigiBook etc. */
if (bgIsPremultiplied) {
// demultiply
bgExposure.x /= (*bg_p).w;
@@ -556,7 +571,7 @@ void Iwa_MotionBlurCompFx::composeBackgroundExposure_CPU(
bgExposure.z /= (*bg_p).w;
}
- /*- ExposureをRGB値にする -*/
+ /* Set Exposure to RGB value */
bgExposure.x = powf(10, (bgExposure.x - 0.5f) * hardness);
bgExposure.y = powf(10, (bgExposure.y - 0.5f) * hardness);
bgExposure.z = powf(10, (bgExposure.z - 0.5f) * hardness);
@@ -566,11 +581,11 @@ void Iwa_MotionBlurCompFx::composeBackgroundExposure_CPU(
bgExposure.y *= (*bg_p).w;
bgExposure.z *= (*bg_p).w;
- /*- 手前とOver合成 -*/
+ /* Front and Over Synthesis */
(*out_p).x = (*out_p).x + bgExposure.x * (1.0f - (*out_p).w);
(*out_p).y = (*out_p).y + bgExposure.y * (1.0f - (*out_p).w);
(*out_p).z = (*out_p).z + bgExposure.z * (1.0f - (*out_p).w);
- /*- アルファ値もOver合成 -*/
+ /* Alpha value also over synthesized */
(*out_p).w = (*out_p).w + (*bg_p).w * (1.0f - (*out_p).w);
}
}
@@ -581,14 +596,14 @@ void Iwa_MotionBlurCompFx::composeBackgroundExposure_CPU(
Iwa_MotionBlurCompFx::Iwa_MotionBlurCompFx()
: m_hardness(0.3)
- /*- 左右をぼかすためのパラメータ -*/
+ /* Parameters for blurring left and right */
, m_startValue(1.0)
, m_startCurve(1.0)
, m_endValue(1.0)
, m_endCurve(1.0)
, m_zanzoMode(false)
, m_premultiType(new TIntEnumParam(AUTO, "Auto")) {
- /*- 共通パラメータのバインド -*/
+ /* Bind common parameters */
addInputPort("Source", m_input);
addInputPort("Back", m_background);
@@ -608,7 +623,7 @@ Iwa_MotionBlurCompFx::Iwa_MotionBlurCompFx()
bindParam(this, "premultiType", m_premultiType);
- /*- 共通パラメータの範囲設定 -*/
+ /* Common parameter range setting */
m_hardness->setValueRange(0.05, 10.0);
m_startValue->setValueRange(0.0, 1.0);
m_startCurve->setValueRange(0.1, 10.0);
@@ -626,18 +641,18 @@ Iwa_MotionBlurCompFx::Iwa_MotionBlurCompFx()
void Iwa_MotionBlurCompFx::doCompute(TTile &tile, double frame,
const TRenderSettings &settings) {
- /*- 接続していない場合は処理しない -*/
+ /* Do not process if not connected */
if (!m_input.isConnected() && !m_background.isConnected()) {
tile.getRaster()->clear();
return;
}
- /*- BGのみ接続の場合 -*/
+ /* For BG only connection */
if (!m_input.isConnected()) {
m_background->compute(tile, frame, settings);
return;
}
- /*- 動作パラメータを得る -*/
+ /* Get operating parameters */
QList<TPointD> points = getAttributes()->getMotionPoints();
double hardness = m_hardness->getValue(frame);
double shutterStart = m_shutterStart->getValue(frame);
@@ -648,22 +663,22 @@ void Iwa_MotionBlurCompFx::doCompute(TTile &tile, double frame,
float endValue = (float)m_endValue->getValue(frame);
float endCurve = (float)m_endCurve->getValue(frame);
- /*- 軌跡データが2つ以上無い場合は、処理しない -*/
+ /* Do not process if there are no more than two trajectory data */
if (points.size() < 2) {
if (!m_background.isConnected()) m_input->compute(tile, frame, settings);
- /*- 背景があり、前景が動かない場合、単純にOverする -*/
+ /* If there is a background and the foreground does not move, simply over */
else
composeWithNoMotion(tile, frame, settings);
return;
}
- /*- 表示の範囲を得る -*/
+ /* Get display range */
TRectD bBox =
- TRectD(tile.m_pos /*- Render画像上(Pixel単位)の位置 -*/
+ TRectD(tile.m_pos /* Render position on Pixel unit */
,
- TDimensionD(/*- Render画像上(Pixel単位)のサイズ -*/
+ TDimensionD(/* Size of Render image (Pixel unit) */
tile.getRaster()->getLx(), tile.getRaster()->getLy()));
- /*- 上下左右のマージンを得る -*/
+ /* Get upper, lower, left and right margin */
double minX = 0.0;
double maxX = 0.0;
double minY = 0.0;
@@ -679,17 +694,18 @@ void Iwa_MotionBlurCompFx::doCompute(TTile &tile, double frame,
int marginTop = (int)ceil(abs(maxY));
int marginBottom = (int)ceil(abs(minY));
- /*- 動かない(=フィルタマージンが全て0)場合、入力タイルをそのまま返す -*/
+ /* Returns the exact type tiles (= filter margin all 0's) doesn't work. */
if (marginLeft == 0 && marginRight == 0 && marginTop == 0 &&
marginBottom == 0) {
if (!m_background.isConnected()) m_input->compute(tile, frame, settings);
- /*- 背景があり、前景が動かない場合、単純にOverする -*/
+ /* If there is a background and the foreground does not move, simply over */
else
composeWithNoMotion(tile, frame, settings);
return;
}
- /*- マージンは、フィルタの上下左右を反転した寸法になる -*/
+ /* The margin is the size of the upper/lower/left/right of the filter reversed
+ */
TRectD enlargedBBox(bBox.x0 - (double)marginRight,
bBox.y0 - (double)marginTop, bBox.x1 + (double)marginLeft,
bBox.y1 + (double)marginBottom);
@@ -697,7 +713,7 @@ void Iwa_MotionBlurCompFx::doCompute(TTile &tile, double frame,
// std::cout<<"Margin Left:"<<marginLeft<<" Right:"<<marginRight<<
// " Bottom:"<<marginBottom<<" Top:"<<marginTop<<std::endl;
- TDimensionI enlargedDimIn(/*- Pixel単位に四捨五入 -*/
+ TDimensionI enlargedDimIn(/* Rounded to the nearest Pixel */
(int)(enlargedBBox.getLx() + 0.5),
(int)(enlargedBBox.getLy() + 0.5));
@@ -705,7 +721,7 @@ void Iwa_MotionBlurCompFx::doCompute(TTile &tile, double frame,
m_input->allocateAndCompute(enlarge_tile, enlargedBBox.getP00(),
enlargedDimIn, tile.getRaster(), frame, settings);
- /*- 背景が必要な場合 -*/
+ /* When background is required */
TTile back_Tile;
if (m_background.isConnected()) {
m_background->allocateAndCompute(back_Tile, tile.m_pos,
@@ -714,25 +730,25 @@ void Iwa_MotionBlurCompFx::doCompute(TTile &tile, double frame,
}
//-------------------------------------------------------
- /*- 計算範囲 -*/
+ /* Compute range */
TDimensionI dimOut(tile.getRaster()->getLx(), tile.getRaster()->getLy());
TDimensionI filterDim(marginLeft + marginRight + 1,
marginTop + marginBottom + 1);
- /*- pointsTableの解放は各doCompute内でやっている -*/
+ /* Release of pointsTable is done within each doCompute */
int pointAmount = points.size();
float4 *pointsTable = new float4[pointAmount];
float dt = (float)(shutterStart + shutterEnd) / (float)traceResolution;
for (int p = 0; p < pointAmount; p++) {
pointsTable[p].x = (float)points.at(p).x;
pointsTable[p].y = (float)points.at(p).y;
- /*- zにはp→p+1のベクトルの距離を格納 -*/
+ /* z contains the distance of p -> p + 1 vector */
if (p < pointAmount - 1) {
float2 vec = {(float)(points.at(p + 1).x - points.at(p).x),
(float)(points.at(p + 1).y - points.at(p).y)};
pointsTable[p].z = sqrtf(vec.x * vec.x + vec.y * vec.y);
}
- /*- wにはシャッター時間のオフセットを格納 -*/
+ /* 'w' stores shutter time offset */
pointsTable[p].w = -(float)shutterStart + (float)p * dt;
}
@@ -753,13 +769,13 @@ void Iwa_MotionBlurCompFx::doCompute_CPU(
int marginTop, int marginBottom, TDimensionI &enlargedDimIn,
TTile &enlarge_tile, TDimensionI &dimOut, TDimensionI &filterDim,
TTile &back_tile) {
- /*- 処理を行うメモリ -*/
- float4 *in_tile_p; /*- マージンあり -*/
- float4 *out_tile_p; /*- マージンあり -*/
- /*- フィルタ -*/
+ /* Processing memory */
+ float4 *in_tile_p; /* With margin */
+ float4 *out_tile_p; /* With margin */
+ /* Filter */
float *filter_p;
- /*- メモリ確保 -*/
+ /* Memory allocation */
TRasterGR8P in_tile_ras(sizeof(float4) * enlargedDimIn.lx, enlargedDimIn.ly);
in_tile_ras->lock();
in_tile_p = (float4 *)in_tile_ras->getRawData();
@@ -771,7 +787,7 @@ void Iwa_MotionBlurCompFx::doCompute_CPU(
filter_p = (float *)filter_ras->getRawData();
bool sourceIsPremultiplied;
- /*- ソース画像を0〜1に正規化してメモリに読み込む -*/
+ /* normalize the source image to 0 to 1 and read it into memory */
TRaster32P ras32 = (TRaster32P)enlarge_tile.getRaster();
TRaster64P ras64 = (TRaster64P)enlarge_tile.getRaster();
if (ras32)
@@ -783,16 +799,16 @@ void Iwa_MotionBlurCompFx::doCompute_CPU(
ras64, in_tile_p, enlargedDimIn,
(PremultiTypes)m_premultiType->getValue());
- /*- 残像モードがオフのとき -*/
+ /* When after image mode is off */
if (!m_zanzoMode->getValue()) {
- /*- フィルタをつくり、正規化する -*/
+ /* Create and normalize filters */
makeMotionBlurFilter_CPU(filter_p, filterDim, marginLeft, marginBottom,
pointsTable, pointAmount, startValue, startCurve,
endValue, endCurve);
}
- /*- 残像モードがオンのとき -*/
+ /* When ghosting mode */
else {
- /*- 残像フィルタをつくる/正規化する -*/
+ /* Create / normalize residual image filter */
makeZanzoFilter_CPU(filter_p, filterDim, marginLeft, marginBottom,
pointsTable, pointAmount, startValue, startCurve,
endValue, endCurve);
@@ -800,27 +816,31 @@ void Iwa_MotionBlurCompFx::doCompute_CPU(
delete[] pointsTable;
- /*- RGB値(0〜1)をdepremultiply→露光値に変換→再びpremultiply -*/
+ /* depremultiply RGB value (0 to 1)
+ * -> convert it to exposure value
+ * -> premultiply again
+ */
convertRGBtoExposure_CPU(in_tile_p, enlargedDimIn, hardness,
sourceIsPremultiplied);
- /*- 露光値をフィルタリングしてぼかす -*/
+ /* Filter and blur exposure value */
applyBlurFilter_CPU(in_tile_p, out_tile_p, enlargedDimIn, filter_p, filterDim,
marginLeft, marginBottom, marginRight, marginTop, dimOut);
- /*- メモリ解放 -*/
+ /* Memory release */
in_tile_ras->unlock();
filter_ras->unlock();
- /*- 背景がある場合、Exposureの乗算を行う -*/
+ /* If there is a background, do Exposure multiplication */
if (m_background.isConnected()) {
composeBackgroundExposure_CPU(out_tile_p, enlargedDimIn, marginRight,
marginTop, back_tile, dimOut,
(float)hardness);
}
- /*- 露光値をdepremultipy→RGB値(0〜1)に戻す→premultiply -*/
+ /* Return exposure value from depremultipy to RGB value
+ * (0 to 1) -> premultiply */
convertExposureToRGB_CPU(out_tile_p, enlargedDimIn, hardness);
- /*- ラスタのクリア -*/
+ /* Clear raster */
tile.getRaster()->clear();
TRaster32P outRas32 = (TRaster32P)tile.getRaster();
TRaster64P outRas64 = (TRaster64P)tile.getRaster();
@@ -832,7 +852,7 @@ void Iwa_MotionBlurCompFx::doCompute_CPU(
setOutputRaster<TRaster64P, TPixel64>(out_tile_p, outRas64, enlargedDimIn,
margin);
- /*- メモリ解放 -*/
+ /* Memory release */
out_tile_ras->unlock();
}
@@ -845,7 +865,7 @@ bool Iwa_MotionBlurCompFx::doGetBBox(double frame, TRectD &bBox,
return false;
}
- /*- 取り急ぎ、背景が繋がっていたら無限サイズにする -*/
+ /* Just a quick note, the background had led to infinite size */
if (m_background.isConnected()) {
bool _ret = m_background->doGetBBox(frame, bBox, info);
bBox = TConsts::infiniteRectD;
@@ -857,9 +877,9 @@ bool Iwa_MotionBlurCompFx::doGetBBox(double frame, TRectD &bBox,
if (bBox == TConsts::infiniteRectD) return true;
QList<TPointD> points = getAttributes()->getMotionPoints();
- /*- 移動した軌跡のバウンディングボックスからマージンを求める -*/
- /*- 各軌跡点の座標の絶対値の最大値を得る -*/
- /*- 上下左右のマージンを得る -*/
+ /* Find the margin from the bounding box of the moved trajectory */
+ /* Obtain the maximum absolute value of the coordinates of each locus point */
+ /* Get upper, lower, left and right margin */
double minX = 0.0;
double maxX = 0.0;
double minY = 0.0;
@@ -892,8 +912,8 @@ bool Iwa_MotionBlurCompFx::canHandle(const TRenderSettings &info,
}
/*------------------------------------------------------------
- 参考にしているオブジェクトが動いている可能性があるので、
- エイリアスは毎フレーム変える
+ Since there is a possibility that the reference object is moving,
+ Alias ​​is changed every frame
------------------------------------------------------------*/
std::string Iwa_MotionBlurCompFx::getAlias(double frame,
@@ -901,8 +921,8 @@ std::string Iwa_MotionBlurCompFx::getAlias(double frame,
std::string alias = getFxType();
alias += "[";
- // alias degli effetti connessi alle porte di input separati da virgole
- // una porta non connessa da luogo a un alias vuoto (stringa vuota)
+ // alias of the effects related to the input ports separated by commas
+ // a port that is not connected to an alias blank (empty string)
int i;
for (i = 0; i < getInputPortCount(); i++) {
TFxPort *port = getInputPort(i);