Skip to content

Commit 47963e5

Browse files
committed
clamp input pixel value
1 parent 310238b commit 47963e5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/waifu2x_preproc_fp16.comp

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ void main()
3535
x = clamp(x, 0, p.w - 1);
3636
y = clamp(y, 0, p.h - 1);
3737

38-
top_blob_data[gz * p.outcstep + gy * p.outw + gx] = float16_t(bottom_blob_data[gz * p.cstep + y * p.w + x]);
38+
float v = bottom_blob_data[gz * p.cstep + y * p.w + x];
39+
top_blob_data[gz * p.outcstep + gy * p.outw + gx] = float16_t(clamp(v, 0.0, 1.0));
3940
}

src/waifu2x_preproc_fp32.comp

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ void main()
3434
x = clamp(x, 0, p.w - 1);
3535
y = clamp(y, 0, p.h - 1);
3636

37-
top_blob_data[gz * p.outcstep + gy * p.outw + gx] = bottom_blob_data[gz * p.cstep + y * p.w + x];
37+
float v = bottom_blob_data[gz * p.cstep + y * p.w + x];
38+
top_blob_data[gz * p.outcstep + gy * p.outw + gx] = clamp(v, 0.0, 1.0);
3839
}

0 commit comments

Comments
 (0)