Skip to content

Commit f90aa09

Browse files
authored
Merge pull request #22 from ErickOF/feature-filter_module
Improving filter module code
2 parents 169886d + 3da0ea0 commit f90aa09

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

modules/filter/include/ips_filter_at_model.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ void Filter<IN, OUT, N>::exec_filter()
9393
wait(this->event);
9494

9595
// Default value for the result depending on the output datatype
96-
result_tmp = (OUT) 0;
96+
result_tmp = static_cast<OUT >(0);
9797

9898
// Getting the image window to filter
9999
IN* img_window_tmp = this->img_window.read();
100100

101101
// Perform the convolution
102102
for (i = 0; i < N; ++i)
103103
for (j = 0; j < N; ++j)
104-
result_tmp += this->kernel[i * N + j] * ((OUT) img_window_tmp[i * N + j]);
104+
result_tmp += this->kernel[i * N + j] * static_cast<OUT >(img_window_tmp[i * N + j]);
105105

106106
this->result.write(result_tmp);
107107
}
@@ -128,7 +128,7 @@ void Filter<IN, OUT, N>::init()
128128
{
129129
// Init a kernel of N x N with default value of 1 / (N * N)
130130
this->kernel = new OUT[N * N];
131-
std::fill_n(this->kernel, N * N, ((OUT) 1) / ((OUT) N * N));
131+
std::fill_n(this->kernel, N * N, static_cast<OUT >(1) / static_cast<OUT >(N * N));
132132

133133
#ifdef IPS_DEBUG_EN
134134
// Print the initialized kernel

modules/filter/include/ips_filter_lt_model.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void Filter<IN, OUT, N>::exec_filter()
9191
wait(this->event);
9292

9393
// Default value for the result depending on the output datatype
94-
*(this->result_ptr) = (OUT) 0;
94+
*(this->result_ptr) = static_cast<OUT >(0);
9595

9696
// Perform the convolution
9797
for (i = 0; i < N; ++i)
@@ -118,7 +118,7 @@ void Filter<IN, OUT, N>::filter(IN* img_window, OUT* result)
118118
// Perform the convolution
119119
for (i = 0; i < N; ++i)
120120
for (j = 0; j < N; ++j)
121-
this->img_window_tmp[i * N + j] = (OUT) img_window[i * N + j];
121+
this->img_window_tmp[i * N + j] = static_cast<OUT >(img_window[i * N + j]);
122122

123123
this->event.notify(DELAY_TIME, SC_NS);
124124
}
@@ -132,7 +132,7 @@ void Filter<IN, OUT, N>::init()
132132
{
133133
// Init a kernel of N x N with default value of 1 / (N * N)
134134
this->kernel = new OUT[N * N];
135-
std::fill_n(this->kernel, N * N, ((OUT) 1) / ((OUT) N * N));
135+
std::fill_n(this->kernel, N * N, static_cast<OUT >(1) / static_cast<OUT > (N * N));
136136
// Init image window of N x N with default value of 1 / (N * N)
137137
this->img_window_tmp = new OUT[N * N];
138138
#ifdef IPS_DEBUG_EN

modules/filter/include/ips_filter_pv_model.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ void Filter<IN, OUT, N>::filter(IN* img_window, OUT& result)
7373
size_t j;
7474

7575
// Default value for the result depending on the output datatype
76-
result = (OUT) 0;
76+
result = static_cast<OUT >(0);
7777

7878
// Perform the convolution
7979
for (i = 0; i < N; ++i)
8080
for (j = 0; j < N; ++j)
81-
result += this->kernel[i * N + j] * ((OUT) img_window[i * N + j]);
81+
result += this->kernel[i * N + j] * static_cast<OUT >(img_window[i * N + j]);
8282
}
8383

8484
/**
@@ -90,7 +90,7 @@ void Filter<IN, OUT, N>::init_kernel()
9090
{
9191
// Init a kernel of N x N with default value of 1 / (N * N)
9292
this->kernel = new OUT[N * N];
93-
std::fill_n(this->kernel, N * N, ((OUT) 1) / ((OUT) N * N));
93+
std::fill_n(this->kernel, N * N, static_cast<OUT >(1) / static_cast<OUT >(N * N));
9494
#ifdef IPS_DEBUG_EN
9595
// Print the initialized kernel
9696
SC_REPORT_INFO(this->name(), "init_kernel result");

0 commit comments

Comments
 (0)