|
| 1 | +/** |
| 2 | + ****************************************************************************** |
| 3 | + * @file mve_matop.h |
| 4 | + * @author AIS Team |
| 5 | + * @brief MVE Image processing library mathematic operation optimized functions |
| 6 | +
|
| 7 | + ****************************************************************************** |
| 8 | + * @attention |
| 9 | + * |
| 10 | + * Copyright (c) 2025 STMicroelectronics. |
| 11 | + * All rights reserved. |
| 12 | + * |
| 13 | + * This software is licensed under terms that can be found in the LICENSE file |
| 14 | + * in the root directory of this software component. |
| 15 | + * If no LICENSE file comes with this software, it is provided AS-IS. |
| 16 | + * |
| 17 | + ****************************************************************************** |
| 18 | + */ |
| 19 | + |
| 20 | +#ifndef __MVE_MATOP_H__ |
| 21 | +#define __MVE_MATOP_H__ |
| 22 | + |
| 23 | +#include "stm32ipl_imlib.h" |
| 24 | +#include "stm32ipl_imlib_int.h" |
| 25 | + |
| 26 | +#include "mve_imlib.h" |
| 27 | + |
| 28 | +static inline void mve_imlib_difference_line_op_grayscale(image_t *img, int line, void *other, image_t *mask) |
| 29 | +{ |
| 30 | + uint8_t *p_data_0 = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(img, line); |
| 31 | + uint8_t *p_data_1 = (uint8_t *)other; |
| 32 | + if (NULL == mask) { |
| 33 | + for (int i = 0; i < img->w; i+=16) { |
| 34 | + mve_pred16_t p = vctp8q(img->w-i); |
| 35 | + uint8x16_t u8x16_data_0 = vldrbq_z_u8(p_data_0, p); |
| 36 | + uint8x16_t u8x16_data_1 = vldrbq_z_u8(p_data_1, p); |
| 37 | + uint8x16_t u8x16_data_out = vabdq_u8(u8x16_data_0, u8x16_data_1); |
| 38 | + vstrbq_p_u8(p_data_0, u8x16_data_out, p); |
| 39 | + p_data_0 += 16; |
| 40 | + p_data_1 += 16; |
| 41 | + } |
| 42 | + } |
| 43 | + else |
| 44 | + { |
| 45 | + for (int i = 0; i < img->w; i+=16) { |
| 46 | + mve_pred16_t p_mask = mve_image_get_mask_pixel(mask, i, line); |
| 47 | + uint8x16_t u8x16_data_0 = vldrbq_z_u8(p_data_0, p_mask); |
| 48 | + uint8x16_t u8x16_data_1 = vldrbq_z_u8(p_data_1, p_mask); |
| 49 | + uint8x16_t u8x16_data_out = vabdq_u8(u8x16_data_0, u8x16_data_1); |
| 50 | + vstrbq_p_u8(p_data_0, u8x16_data_out, p_mask); |
| 51 | + p_data_0 += 16; |
| 52 | + p_data_1 += 16; |
| 53 | + } |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +static inline void mve_imlib_difference_line_op_rgb888(image_t *img, int line, void *other, image_t *mask) |
| 58 | +{ |
| 59 | + rgb888_t *ptr_rgb888_0 = IMAGE_COMPUTE_RGB888_PIXEL_ROW_PTR(img, line); |
| 60 | + rgb888_t *ptr_rgb888_1 = (rgb888_t *)other; |
| 61 | + uint8x16_t u8x16_incr = vidupq_n_u8(0, 1) * 3; |
| 62 | + if (NULL == mask) { |
| 63 | + for (int i = 0; i < img->w; i+=16) { |
| 64 | + mve_pred16_t pred = vctp8q(img->w-i); |
| 65 | + uint8x16_t u8x16_r_0 = vldrbq_gather_offset_z_u8(&(ptr_rgb888_0->r), u8x16_incr, pred); |
| 66 | + uint8x16_t u8x16_g_0 = vldrbq_gather_offset_z_u8(&(ptr_rgb888_0->g), u8x16_incr, pred); |
| 67 | + uint8x16_t u8x16_b_0 = vldrbq_gather_offset_z_u8(&(ptr_rgb888_0->b), u8x16_incr, pred); |
| 68 | + uint8x16_t u8x16_r_1 = vldrbq_gather_offset_z_u8(&(ptr_rgb888_1->r), u8x16_incr, pred); |
| 69 | + uint8x16_t u8x16_g_1 = vldrbq_gather_offset_z_u8(&(ptr_rgb888_1->g), u8x16_incr, pred); |
| 70 | + uint8x16_t u8x16_b_1 = vldrbq_gather_offset_z_u8(&(ptr_rgb888_1->b), u8x16_incr, pred); |
| 71 | + uint8x16_t u8x16_data_out; |
| 72 | + u8x16_data_out = vabdq_u8(u8x16_r_0, u8x16_r_1); |
| 73 | + vstrbq_scatter_offset_p_u8(&(ptr_rgb888_0->r), u8x16_incr, u8x16_data_out, pred); |
| 74 | + u8x16_data_out = vabdq_u8(u8x16_g_0, u8x16_g_1); |
| 75 | + vstrbq_scatter_offset_p_u8(&(ptr_rgb888_0->g), u8x16_incr, u8x16_data_out, pred); |
| 76 | + u8x16_data_out = vabdq_u8(u8x16_b_0, u8x16_b_1); |
| 77 | + vstrbq_scatter_offset_p_u8(&(ptr_rgb888_0->b), u8x16_incr, u8x16_data_out, pred); |
| 78 | + ptr_rgb888_0 += 16; |
| 79 | + ptr_rgb888_1 += 16; |
| 80 | + } |
| 81 | + } |
| 82 | + else |
| 83 | + { |
| 84 | + for (int i = 0; i < img->w; i+=16) { |
| 85 | + mve_pred16_t pred = mve_image_get_mask_pixel(mask, i, line); |
| 86 | + uint8x16_t u8x16_r_0 = vldrbq_gather_offset_z_u8(&(ptr_rgb888_0->r), u8x16_incr, pred); |
| 87 | + uint8x16_t u8x16_g_0 = vldrbq_gather_offset_z_u8(&(ptr_rgb888_0->g), u8x16_incr, pred); |
| 88 | + uint8x16_t u8x16_b_0 = vldrbq_gather_offset_z_u8(&(ptr_rgb888_0->b), u8x16_incr, pred); |
| 89 | + uint8x16_t u8x16_r_1 = vldrbq_gather_offset_z_u8(&(ptr_rgb888_1->r), u8x16_incr, pred); |
| 90 | + uint8x16_t u8x16_g_1 = vldrbq_gather_offset_z_u8(&(ptr_rgb888_1->g), u8x16_incr, pred); |
| 91 | + uint8x16_t u8x16_b_1 = vldrbq_gather_offset_z_u8(&(ptr_rgb888_1->b), u8x16_incr, pred); |
| 92 | + uint8x16_t u8x16_data_out; |
| 93 | + u8x16_data_out = vabdq_u8(u8x16_r_0, u8x16_r_1); |
| 94 | + vstrbq_scatter_offset_p_u8(&(ptr_rgb888_0->r), u8x16_incr, u8x16_data_out, pred); |
| 95 | + u8x16_data_out = vabdq_u8(u8x16_g_0, u8x16_g_1); |
| 96 | + vstrbq_scatter_offset_p_u8(&(ptr_rgb888_0->g), u8x16_incr, u8x16_data_out, pred); |
| 97 | + u8x16_data_out = vabdq_u8(u8x16_b_0, u8x16_b_1); |
| 98 | + vstrbq_scatter_offset_p_u8(&(ptr_rgb888_0->b), u8x16_incr, u8x16_data_out, pred); |
| 99 | + ptr_rgb888_0 += 16; |
| 100 | + ptr_rgb888_1 += 16; |
| 101 | + } |
| 102 | + } |
| 103 | +} |
| 104 | +#endif /* __MVE_MATOP_H__ */ |
0 commit comments