Skip to content

Commit

Permalink
Merge pull request #38 from nazonoSAUNA/directionalblur
Browse files Browse the repository at this point in the history
方向ブラー修正
  • Loading branch information
ePi5131 authored Jun 15, 2022
2 parents ae8c2dc + b578e42 commit aaa3c4a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
22 changes: 12 additions & 10 deletions patch/clprogram.cl
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ kernel void DirectionalBlur_Media(global short* dst, global short* src, int obj_

dst += (x + y * obj_line) * 4;

uint sum_y = 0;
int sum_y = 0;
int sum_cb = 0;
int sum_cr = 0;
int sum_a = 0;
Expand All @@ -598,10 +598,11 @@ kernel void DirectionalBlur_Media(global short* dst, global short* src, int obj_
x_itr += x_step;
y_itr += y_step;
}
if (sum_a) {
dst[0] = (short)(sum_y * 4096 / sum_a);
dst[1] = (short)(sum_cb * 4096 / sum_a);
dst[2] = (short)(sum_cr * 4096 / sum_a);
if (0 < sum_a) {
float a_float = 4096.0f / (float)sum_a;
dst[0] = (short)round((float)sum_y * a_float);
dst[1] = (short)round((float)sum_cb * a_float);
dst[2] = (short)round((float)sum_cr * a_float);
} else {
dst[0] = dst[1] = dst[2] = 0;
}
Expand All @@ -618,7 +619,7 @@ kernel void DirectionalBlur_original_size(global short* dst, global short* src,
int x_itr = (x << 16) + 0x8000 - range * x_step;
int y_itr = (y << 16) + 0x8000 - range * y_step;

uint sum_y = 0;
int sum_y = 0;
int sum_cb = 0;
int sum_cr = 0;
int sum_a = 0;
Expand All @@ -640,10 +641,11 @@ kernel void DirectionalBlur_original_size(global short* dst, global short* src,
y_itr += y_step;
}
if(cnt == 0) cnt = 0xffffff;
if (sum_a) {
dst[0] = (short)(sum_y * 4096 / sum_a);
dst[1] = (short)(sum_cb * 4096 / sum_a);
dst[2] = (short)(sum_cr * 4096 / sum_a);
if (0 < sum_a) {
float a_float = 4096.0f / (float)sum_a;
dst[0] = (short)round((float)sum_y * a_float);
dst[1] = (short)round((float)sum_cb * a_float);
dst[2] = (short)round((float)sum_cr * a_float);
} else {
dst[0] = dst[1] = dst[2] = 0;
}
Expand Down
22 changes: 12 additions & 10 deletions patch/patch_fast_cl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ kernel void DirectionalBlur_Media(global short* dst, global short* src, int obj_
dst += (x + y * obj_line) * 4;
uint sum_y = 0;
int sum_y = 0;
int sum_cb = 0;
int sum_cr = 0;
int sum_a = 0;
Expand All @@ -633,10 +633,11 @@ kernel void DirectionalBlur_Media(global short* dst, global short* src, int obj_
x_itr += x_step;
y_itr += y_step;
}
if (sum_a) {
dst[0] = (short)(sum_y * 4096 / sum_a);
dst[1] = (short)(sum_cb * 4096 / sum_a);
dst[2] = (short)(sum_cr * 4096 / sum_a);
if (0 < sum_a) {
float a_float = 4096.0f / (float)sum_a;
dst[0] = (short)round((float)sum_y * a_float);
dst[1] = (short)round((float)sum_cb * a_float);
dst[2] = (short)round((float)sum_cr * a_float);
} else {
dst[0] = dst[1] = dst[2] = 0;
}
Expand All @@ -654,7 +655,7 @@ kernel void DirectionalBlur_original_size(global short* dst, global short* src,
int x_itr = (x << 16) + 0x8000 - range * x_step;
int y_itr = (y << 16) + 0x8000 - range * y_step;
uint sum_y = 0;
int sum_y = 0;
int sum_cb = 0;
int sum_cr = 0;
int sum_a = 0;
Expand All @@ -676,10 +677,11 @@ kernel void DirectionalBlur_original_size(global short* dst, global short* src,
y_itr += y_step;
}
if(cnt == 0) cnt = 0xffffff;
if (sum_a) {
dst[0] = (short)(sum_y * 4096 / sum_a);
dst[1] = (short)(sum_cb * 4096 / sum_a);
dst[2] = (short)(sum_cr * 4096 / sum_a);
if (0 < sum_a) {
float a_float = 4096.0f / (float)sum_a;
dst[0] = (short)round((float)sum_y * a_float);
dst[1] = (short)round((float)sum_cb * a_float);
dst[2] = (short)round((float)sum_cr * a_float);
} else {
dst[0] = dst[1] = dst[2] = 0;
}
Expand Down

0 comments on commit aaa3c4a

Please sign in to comment.