for (c = 0; c < prop->input_meta.info[0].dimension[0]; c++) {
int sz;
/* Output[y'][x'] = Input[ y' * y / new-y ][ x' * x / new-x ]. Yeah This is Way too Simple. But this is just an example :D */
- unsigned ix, iy;
+ unsigned int ix, iy;
ix = x * prop->input_meta.info[0].dimension[1] / ox;
iy = y * prop->input_meta.info[0].dimension[2] / oy;
- assert (ix >= 0 && iy >= 0
- && ix < prop->input_meta.info[0].dimension[1]
- && iy < prop->input_meta.info[0].dimension[2]);
+ if (ix >= prop->input_meta.info[0].dimension[1] ||
+ iy >= prop->input_meta.info[0].dimension[2]) {
+ /* index error */
+ assert (0);
+ return -1;
+ }
/* output[z][y][x][c] = input[z][iy][ix][c]; */
for (sz = 0; sz < elementsize; sz++)
*
* LICENSE: LGPL-2.1
*
- * @file nnstreamer_customfilter_example_scaler.c
+ * @file nnstreamer_customfilter_example_scaler_allocator.c
* @date 22 Jun 2018
* @brief Custom NNStreamer Filter Example 3. "Scaler"
* @author MyungJoo Ham <myungjoo.ham@samsung.com>
unsigned int c;
for (c = 0; c < prop->input_meta.info[0].dimension[0]; c++) {
/* Output[y'][x'] = Input[ y' * y / new-y ][ x' * x / new-x ]. Yeah This is Way too Simple. But this is just an example :D */
- unsigned ix, iy, sz;
+ unsigned int ix, iy, sz;
ix = x * prop->input_meta.info[0].dimension[1] / ox;
iy = y * prop->input_meta.info[0].dimension[2] / oy;
- assert (ix >= 0 && iy >= 0
- && ix < prop->input_meta.info[0].dimension[1]
- && iy < prop->input_meta.info[0].dimension[2]);
+ if (ix >= prop->input_meta.info[0].dimension[1] ||
+ iy >= prop->input_meta.info[0].dimension[2]) {
+ /* index error */
+ assert (0);
+ return -1;
+ }
/* output[z][y][x][c] = input[z][iy][ix][c]; */
for (sz = 0; sz < elementsize; sz++)