📄 pixel.c
字号:
perm3vA = vec_lvsl(0, pix3); perm0vB = vec_lvsl(0, pix0 + i_stride); perm1vB = vec_lvsl(0, pix1 + i_stride); perm2vB = vec_lvsl(0, pix2 + i_stride); perm3vB = vec_lvsl(0, pix3 + i_stride); for (y = 0; y < 8; y++) { temp_lv = vec_ld(0, pix0); temp_hv = vec_ld(16, pix0); pix0v = vec_perm(temp_lv, temp_hv, perm0vA); pix0 += i_stride; temp_lv = vec_ld(0, pix1); temp_hv = vec_ld(16, pix1); pix1v = vec_perm(temp_lv, temp_hv, perm1vA); pix1 += i_stride; temp_lv = vec_ld(0, fenc); fencv = vec_perm(temp_lv, temp_hv, permEncv); fenc += FENC_STRIDE; temp_lv = vec_ld(0, pix2); temp_hv = vec_ld(16, pix2); pix2v = vec_perm(temp_lv, temp_hv, perm2vA); pix2 += i_stride; temp_lv = vec_ld(0, pix3); temp_hv = vec_ld(16, pix3); pix3v = vec_perm(temp_lv, temp_hv, perm3vA); pix3 += i_stride; sum0v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix0v ), vec_min( fencv, pix0v ) ), (vec_u32_t) sum0v ); sum1v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix1v ), vec_min( fencv, pix1v ) ), (vec_u32_t) sum1v ); sum2v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix2v ), vec_min( fencv, pix2v ) ), (vec_u32_t) sum2v ); sum3v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix3v ), vec_min( fencv, pix3v ) ), (vec_u32_t) sum3v ); temp_lv = vec_ld(0, pix0); temp_hv = vec_ld(16, pix0); pix0v = vec_perm(temp_lv, temp_hv, perm0vB); pix0 += i_stride; temp_lv = vec_ld(0, pix1); temp_hv = vec_ld(16, pix1); pix1v = vec_perm(temp_lv, temp_hv, perm1vB); pix1 += i_stride; temp_lv = vec_ld(0, fenc); fencv = vec_perm(temp_lv, temp_hv, permEncv); fenc += FENC_STRIDE; temp_lv = vec_ld(0, pix2); temp_hv = vec_ld(16, pix2); pix2v = vec_perm(temp_lv, temp_hv, perm2vB); pix2 += i_stride; temp_lv = vec_ld(0, pix3); temp_hv = vec_ld(16, pix3); pix3v = vec_perm(temp_lv, temp_hv, perm3vB); pix3 += i_stride; sum0v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix0v ), vec_min( fencv, pix0v ) ), (vec_u32_t) sum0v ); sum1v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix1v ), vec_min( fencv, pix1v ) ), (vec_u32_t) sum1v ); sum2v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix2v ), vec_min( fencv, pix2v ) ), (vec_u32_t) sum2v ); sum3v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix3v ), vec_min( fencv, pix3v ) ), (vec_u32_t) sum3v ); } sum0v = vec_sum2s( sum0v, zero_s32v ); sum1v = vec_sum2s( sum1v, zero_s32v ); sum2v = vec_sum2s( sum2v, zero_s32v ); sum3v = vec_sum2s( sum3v, zero_s32v ); sum0v = vec_splat( sum0v, 1 ); sum1v = vec_splat( sum1v, 1 ); sum2v = vec_splat( sum2v, 1 ); sum3v = vec_splat( sum3v, 1 ); vec_ste( sum0v, 0, &sum0); vec_ste( sum1v, 0, &sum1); vec_ste( sum2v, 0, &sum2); vec_ste( sum3v, 0, &sum3); scores[0] = sum0; scores[1] = sum1; scores[2] = sum2; scores[3] = sum3;}static void pixel_sad_x3_8x16_altivec( uint8_t *fenc, uint8_t *pix0, uint8_t *pix1, uint8_t *pix2, int i_stride, int scores[3] ){ DECLARE_ALIGNED_16( int sum0 ); DECLARE_ALIGNED_16( int sum1 ); DECLARE_ALIGNED_16( int sum2 ); int y; LOAD_ZERO; vec_u8_t temp_lv, temp_hv; vec_u8_t fencv, pix0v, pix1v, pix2v; vec_u8_t perm0vA, perm1vA, perm2vA, perm0vB, perm1vB, perm2vB,permEncv; vec_s32_t sum0v, sum1v, sum2v; sum0v = vec_splat_s32(0); sum1v = vec_splat_s32(0); sum2v = vec_splat_s32(0); permEncv = vec_lvsl(0, fenc); perm0vA = vec_lvsl(0, pix0); perm1vA = vec_lvsl(0, pix1); perm2vA = vec_lvsl(0, pix2); perm0vB = vec_lvsl(0, pix0 + i_stride); perm1vB = vec_lvsl(0, pix1 + i_stride); perm2vB = vec_lvsl(0, pix2 + i_stride); for (y = 0; y < 8; y++) { temp_lv = vec_ld(0, pix0); temp_hv = vec_ld(16, pix0); pix0v = vec_perm(temp_lv, temp_hv, perm0vA); pix0 += i_stride; temp_lv = vec_ld(0, pix1); temp_hv = vec_ld(16, pix1); pix1v = vec_perm(temp_lv, temp_hv, perm1vA); pix1 += i_stride; temp_lv = vec_ld(0, fenc); fencv = vec_perm(temp_lv, temp_hv, permEncv); fenc += FENC_STRIDE; temp_lv = vec_ld(0, pix2); temp_hv = vec_ld(16, pix2); pix2v = vec_perm(temp_lv, temp_hv, perm2vA); pix2 += i_stride; sum0v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix0v ), vec_min( fencv, pix0v ) ), (vec_u32_t) sum0v ); sum1v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix1v ), vec_min( fencv, pix1v ) ), (vec_u32_t) sum1v ); sum2v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix2v ), vec_min( fencv, pix2v ) ), (vec_u32_t) sum2v ); temp_lv = vec_ld(0, pix0); temp_hv = vec_ld(16, pix0); pix0v = vec_perm(temp_lv, temp_hv, perm0vB); pix0 += i_stride; temp_lv = vec_ld(0, pix1); temp_hv = vec_ld(16, pix1); pix1v = vec_perm(temp_lv, temp_hv, perm1vB); pix1 += i_stride; temp_lv = vec_ld(0, fenc); fencv = vec_perm(temp_lv, temp_hv, permEncv); fenc += FENC_STRIDE; temp_lv = vec_ld(0, pix2); temp_hv = vec_ld(16, pix2); pix2v = vec_perm(temp_lv, temp_hv, perm2vB); pix2 += i_stride; sum0v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix0v ), vec_min( fencv, pix0v ) ), (vec_u32_t) sum0v ); sum1v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix1v ), vec_min( fencv, pix1v ) ), (vec_u32_t) sum1v ); sum2v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix2v ), vec_min( fencv, pix2v ) ), (vec_u32_t) sum2v ); } sum0v = vec_sum2s( sum0v, zero_s32v ); sum1v = vec_sum2s( sum1v, zero_s32v ); sum2v = vec_sum2s( sum2v, zero_s32v ); sum0v = vec_splat( sum0v, 1 ); sum1v = vec_splat( sum1v, 1 ); sum2v = vec_splat( sum2v, 1 ); vec_ste( sum0v, 0, &sum0); vec_ste( sum1v, 0, &sum1); vec_ste( sum2v, 0, &sum2); scores[0] = sum0; scores[1] = sum1; scores[2] = sum2;}static void pixel_sad_x4_8x8_altivec( uint8_t *fenc, uint8_t *pix0, uint8_t *pix1, uint8_t *pix2, uint8_t *pix3, int i_stride, int scores[4] ){ DECLARE_ALIGNED_16( int sum0 ); DECLARE_ALIGNED_16( int sum1 ); DECLARE_ALIGNED_16( int sum2 ); DECLARE_ALIGNED_16( int sum3 ); int y; LOAD_ZERO; vec_u8_t temp_lv, temp_hv; vec_u8_t fencv, pix0v, pix1v, pix2v, pix3v; vec_u8_t perm0vA, perm1vA, perm2vA, perm3vA, perm0vB, perm1vB, perm2vB, perm3vB, permEncv; vec_s32_t sum0v, sum1v, sum2v, sum3v; sum0v = vec_splat_s32(0); sum1v = vec_splat_s32(0); sum2v = vec_splat_s32(0); sum3v = vec_splat_s32(0); permEncv = vec_lvsl(0, fenc); perm0vA = vec_lvsl(0, pix0); perm1vA = vec_lvsl(0, pix1); perm2vA = vec_lvsl(0, pix2); perm3vA = vec_lvsl(0, pix3); perm0vB = vec_lvsl(0, pix0 + i_stride); perm1vB = vec_lvsl(0, pix1 + i_stride); perm2vB = vec_lvsl(0, pix2 + i_stride); perm3vB = vec_lvsl(0, pix3 + i_stride); for (y = 0; y < 4; y++) { temp_lv = vec_ld(0, pix0); temp_hv = vec_ld(16, pix0); pix0v = vec_perm(temp_lv, temp_hv, perm0vA); pix0 += i_stride; temp_lv = vec_ld(0, pix1); temp_hv = vec_ld(16, pix1); pix1v = vec_perm(temp_lv, temp_hv, perm1vA); pix1 += i_stride; temp_lv = vec_ld(0, fenc); fencv = vec_perm(temp_lv, temp_hv, permEncv); fenc += FENC_STRIDE; temp_lv = vec_ld(0, pix2); temp_hv = vec_ld(16, pix2); pix2v = vec_perm(temp_lv, temp_hv, perm2vA); pix2 += i_stride; temp_lv = vec_ld(0, pix3); temp_hv = vec_ld(16, pix3); pix3v = vec_perm(temp_lv, temp_hv, perm3vA); pix3 += i_stride; sum0v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix0v ), vec_min( fencv, pix0v ) ), (vec_u32_t) sum0v ); sum1v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix1v ), vec_min( fencv, pix1v ) ), (vec_u32_t) sum1v ); sum2v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix2v ), vec_min( fencv, pix2v ) ), (vec_u32_t) sum2v ); sum3v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix3v ), vec_min( fencv, pix3v ) ), (vec_u32_t) sum3v ); temp_lv = vec_ld(0, pix0); temp_hv = vec_ld(16, pix0); pix0v = vec_perm(temp_lv, temp_hv, perm0vB); pix0 += i_stride; temp_lv = vec_ld(0, pix1); temp_hv = vec_ld(16, pix1); pix1v = vec_perm(temp_lv, temp_hv, perm1vB); pix1 += i_stride; temp_lv = vec_ld(0, fenc); fencv = vec_perm(temp_lv, temp_hv, permEncv); fenc += FENC_STRIDE; temp_lv = vec_ld(0, pix2); temp_hv = vec_ld(16, pix2); pix2v = vec_perm(temp_lv, temp_hv, perm2vB); pix2 += i_stride; temp_lv = vec_ld(0, pix3); temp_hv = vec_ld(16, pix3); pix3v = vec_perm(temp_lv, temp_hv, perm3vB); pix3 += i_stride; sum0v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix0v ), vec_min( fencv, pix0v ) ), (vec_u32_t) sum0v ); sum1v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix1v ), vec_min( fencv, pix1v ) ), (vec_u32_t) sum1v ); sum2v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix2v ), vec_min( fencv, pix2v ) ), (vec_u32_t) sum2v ); sum3v = (vec_s32_t) vec_sum4s( vec_sub( vec_max( fencv, pix3v ), vec_min( fencv, pix3v ) ), (vec_u32_t) sum3v ); } sum0v = vec_sum2s( sum0v, zero_s32v ); sum1v = vec_sum2s( sum1v, zero_s32v ); sum2v = vec_sum2s( sum2v, zero_s32v ); sum3v = vec_sum2s( sum3v, zero_s32v ); sum0v = vec_splat( sum0v, 1 ); sum1v = vec_splat( sum1v, 1 ); sum2v = vec_splat( sum2v, 1 ); sum3v = vec_splat( sum3v, 1 ); vec_ste( sum0v, 0, &sum0); vec_ste( sum1v, 0, &sum1); vec_ste( sum2v, 0, &sum2); vec_ste( sum3v, 0, &sum3); scores[0] = sum0; scores[1] = sum1; scores[2] = sum2; scores[3] = sum3;}static void pixel_sad_x3_8x8_altivec( uint8_t *fenc, uint8_t *pix0, uint8_t *pix1, uint8_t *pix2, int i_stride, int scores[3] ){ DECLARE_ALIGNED_16( int sum0 ); DECLARE_ALIGNED_16( int sum1 ); DECLARE_ALIGNED_16( int sum2 ); int y; LOAD_ZERO; vec_u8_t temp_lv, temp_hv; vec_u8_t fencv, pix0v, pix1v, pix2v; vec_u8_t perm0vA, perm1vA, perm2vA, perm0vB, perm1vB, perm2vB, permEncv; vec_s32_t sum0v, sum1v, sum2v; sum0v = vec_splat_s32(0); sum1v = vec_splat_s32(0); sum2v = vec_splat_s32(0); permEncv = vec_lvsl(0, fenc); perm0vA = vec_lvsl(0, pix0); perm1vA = vec_lvsl(0, pix1); perm2vA = vec_lvsl(0, pix2); perm0vB = vec_lvsl(0, pix0 + i_stride); perm1vB = vec_lvsl(0, pix1 + i_stride); perm2vB = vec_lvsl(0, pix2 + i_stride); for (y = 0; y < 4; y++) { temp_lv = vec_ld(0, pix0); temp_hv = vec_ld(16, pix0); pix0v = vec_perm(temp_lv, temp_hv, perm0vA); pix0 += i_stride; temp_lv = vec_ld(0, pix1); temp_hv = vec_ld(16, pix1); pix1v = vec_perm(temp_lv, temp_hv, perm1vA); pix1 += i_stride; temp_lv = vec_ld(0, fenc); fencv = vec_perm(temp_lv, temp_hv, permEncv); fenc += FENC_STRIDE; temp_lv = vec_ld(0, pix2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -