/* RGB -> Grayscale conversion is defined by the following equation: *Y=0.29900*R+0.58700*G+0.11400*B * *Avoidfloatingpointarithmeticbyusingshiftedintegerconstants: *0.29899597=19595*2^-16 *0.58700561=38470*2^-16 *0.11399841=7471*2^-16 *Theseconstantsaredefinedinjcgray-neon.c * *ThisisthesamecomputationastheRGB->YportionofRGB->YCbCr.
*/
void jsimd_rgb_gray_convert_neon(JDIMENSION image_width, JSAMPARRAY input_buf,
JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
{
JSAMPROW inptr;
JSAMPROW outptr; /* Allocate temporary buffer for final (image_width % 16) pixels in row. */
ALIGN(16) uint8_t tmp_buf[16 * RGB_PIXELSIZE];
int cols_remaining = image_width; for (; cols_remaining > 0; cols_remaining -= 16) {
/* To prevent buffer overread by the vector load instructions, the last *(image_width%16)columnsofdataarefirstmemcopiedtoatemporary *bufferlargeenoughtoaccommodatethevectorload.
*/ if (cols_remaining < 16) {
memcpy(tmp_buf, inptr, cols_remaining * RGB_PIXELSIZE);
inptr = tmp_buf;
}
/* Descale Y values (rounding right shift) and narrow to 16-bit. */
uint16x8_t y_l = vcombine_u16(vrshrn_n_u32(y_ll, 16),
vrshrn_n_u32(y_lh, 16));
uint16x8_t y_h = vcombine_u16(vrshrn_n_u32(y_hl, 16),
vrshrn_n_u32(y_hh, 16));
/* Narrow Y values to 8-bit and store to memory. Buffer overwrite is *permitteduptothenextmultipleofALIGN_SIZEbytes.
*/
vst1q_u8(outptr, vcombine_u8(vmovn_u16(y_l), vmovn_u16(y_h)));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.