/* * jidctred-neon.c - reduced-size IDCT (Arm Neon) * * Copyright (C) 2020, Arm Limited. All Rights Reserved. * Copyright (C) 2020, D. R. Commander. All Rights Reserved. * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution.
*/
/* jsimd_idct_2x2_neon() is an inverse DCT function that produces reduced-size * 2x2 output from an 8x8 DCT block. It uses the same calculations and * produces exactly the same output as IJG's original jpeg_idct_2x2() function * from jpeg-6b, which can be found in jidctred.c. * * Scaled integer constants are used to avoid floating-point arithmetic: * 0.720959822 = 5906 * 2^-13 * 0.850430095 = 6967 * 2^-13 * 1.272758580 = 10426 * 2^-13 * 3.624509785 = 29692 * 2^-13 * * See jidctred.c for further details of the 2x2 IDCT algorithm. Where * possible, the variable names and comments here in jsimd_idct_2x2_neon() * match up with those in jpeg_idct_2x2().
*/
/* Final output stage: descale and narrow to 16-bit. */
row0 = vcombine_s16(vrshrn_n_s32(vaddq_s32(tmp10_l, tmp0_l), CONST_BITS),
vrshrn_n_s32(vaddq_s32(tmp10_h, tmp0_h), CONST_BITS));
row1 = vcombine_s16(vrshrn_n_s32(vsubq_s32(tmp10_l, tmp0_l), CONST_BITS),
vrshrn_n_s32(vsubq_s32(tmp10_h, tmp0_h), CONST_BITS));
/* Transpose two rows, ready for second pass. */
int16x8x2_t cols_0246_1357 = vtrnq_s16(row0, row1);
int16x8_t cols_0246 = cols_0246_1357.val[0];
int16x8_t cols_1357 = cols_0246_1357.val[1]; /* Duplicate columns such that each is accessible in its own vector. */
int32x4x2_t cols_1155_3377 = vtrnq_s32(vreinterpretq_s32_s16(cols_1357),
vreinterpretq_s32_s16(cols_1357));
int16x8_t cols_1155 = vreinterpretq_s16_s32(cols_1155_3377.val[0]);
int16x8_t cols_3377 = vreinterpretq_s16_s32(cols_1155_3377.val[1]);
/* Pass 2: process two rows, store to output array. */
/* Even part: we're only interested in col0; the top half of tmp10 is "don't * care."
*/
int32x4_t tmp10 = vshll_n_s16(vget_low_s16(cols_0246), CONST_BITS + 2);
/* Odd part: we're only interested in the bottom half of tmp0. */
int32x4_t tmp0 = vmull_lane_s16(vget_low_s16(cols_1155), consts, 3);
tmp0 = vmlal_lane_s16(tmp0, vget_low_s16(cols_3377), consts, 2);
tmp0 = vmlal_lane_s16(tmp0, vget_high_s16(cols_1155), consts, 1);
tmp0 = vmlal_lane_s16(tmp0, vget_high_s16(cols_3377), consts, 0);
/* Final output stage: descale and clamp to range [0-255]. */
int16x8_t output_s16 = vcombine_s16(vaddhn_s32(tmp10, tmp0),
vsubhn_s32(tmp10, tmp0));
output_s16 = vrsraq_n_s16(vdupq_n_s16(CENTERJSAMPLE), output_s16,
CONST_BITS + PASS1_BITS + 3 + 2 - 16); /* Narrow to 8-bit and convert to unsigned. */
uint8x8_t output_u8 = vqmovun_s16(output_s16);
/* jsimd_idct_4x4_neon() is an inverse DCT function that produces reduced-size * 4x4 output from an 8x8 DCT block. It uses the same calculations and * produces exactly the same output as IJG's original jpeg_idct_4x4() function * from jpeg-6b, which can be found in jidctred.c. * * Scaled integer constants are used to avoid floating-point arithmetic: * 0.211164243 = 1730 * 2^-13 * 0.509795579 = 4176 * 2^-13 * 0.601344887 = 4926 * 2^-13 * 0.765366865 = 6270 * 2^-13 * 0.899976223 = 7373 * 2^-13 * 1.061594337 = 8697 * 2^-13 * 1.451774981 = 11893 * 2^-13 * 1.847759065 = 15137 * 2^-13 * 2.172734803 = 17799 * 2^-13 * 2.562915447 = 20995 * 2^-13 * * See jidctred.c for further details of the 4x4 IDCT algorithm. Where * possible, the variable names and comments here in jsimd_idct_4x4_neon() * match up with those in jpeg_idct_4x4().
*/
/* Load constants for IDCT computation. */ #ifdef HAVE_VLD1_S16_X3 const int16x4x3_t consts = vld1_s16_x3(jsimd_idct_4x4_neon_consts); #else /* GCC does not currently support the intrinsic vld1_<type>_x3(). */ const int16x4_t consts1 = vld1_s16(jsimd_idct_4x4_neon_consts); const int16x4_t consts2 = vld1_s16(jsimd_idct_4x4_neon_consts + 4); const int16x4_t consts3 = vld1_s16(jsimd_idct_4x4_neon_consts + 8); const int16x4x3_t consts = { { consts1, consts2, consts3 } }; #endif
if (left_ac_bitmap == 0 && right_ac_bitmap == 0) { /* All AC coefficients are zero. * Compute DC values and duplicate into row vectors 0, 1, 2, and 3.
*/
int16x8_t dcval = vshlq_n_s16(row0, PASS1_BITS);
row0 = dcval;
row1 = dcval;
row2 = dcval;
row3 = dcval;
} elseif (left_ac_bitmap == 0) { /* AC coefficients are zero for columns 0, 1, 2, and 3. * Compute DC values for these columns.
*/
int16x4_t dcval = vshl_n_s16(vget_low_s16(row0), PASS1_BITS);
/* Commence regular IDCT computation for columns 4, 5, 6, and 7. */
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.