mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-29 06:45:47 +00:00
swscale/aarch64: Add argb/abgr to yuv
Test on Apple M1 with kperf: : -O3 : -O3 -fno-vectorize abgr_to_uv_8_c : 19.4 : 26.1 abgr_to_uv_8_neon : 29.9 : 51.1 abgr_to_uv_128_c : 146.4 : 558.9 abgr_to_uv_128_neon : 85.1 : 83.4 abgr_to_uv_1080_c : 1162.6 : 4786.4 abgr_to_uv_1080_neon : 819.6 : 826.6 abgr_to_uv_1920_c : 2063.6 : 8492.1 abgr_to_uv_1920_neon : 1435.1 : 1447.1 abgr_to_uv_half_8_c : 16.4 : 11.4 abgr_to_uv_half_8_neon : 35.6 : 20.4 abgr_to_uv_half_128_c : 108.6 : 359.4 abgr_to_uv_half_128_neon : 75.4 : 42.6 abgr_to_uv_half_1080_c : 883.4 : 2885.6 abgr_to_uv_half_1080_neon : 460.6 : 481.1 abgr_to_uv_half_1920_c : 1553.6 : 5106.9 abgr_to_uv_half_1920_neon : 817.6 : 820.4 abgr_to_y_8_c : 6.1 : 26.4 abgr_to_y_8_neon : 40.6 : 6.4 abgr_to_y_128_c : 99.9 : 390.1 abgr_to_y_128_neon : 67.4 : 55.9 abgr_to_y_1080_c : 735.9 : 3170.4 abgr_to_y_1080_neon : 534.6 : 536.6 abgr_to_y_1920_c : 1279.4 : 6016.4 abgr_to_y_1920_neon : 932.6 : 927.6 Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
This commit is contained in:
parent
52422133ae
commit
4d90a76986
@ -34,6 +34,16 @@
|
||||
uxtl2 v24.8h, v18.16b // v24: b
|
||||
.endm
|
||||
|
||||
.macro argb_to_yuv_load_rgb src
|
||||
ld4 { v16.16b, v17.16b, v18.16b, v19.16b }, [\src]
|
||||
uxtl v21.8h, v19.8b // v21: b
|
||||
uxtl2 v24.8h, v19.16b // v24: b
|
||||
uxtl v19.8h, v17.8b // v19: r
|
||||
uxtl v20.8h, v18.8b // v20: g
|
||||
uxtl2 v22.8h, v17.16b // v22: r
|
||||
uxtl2 v23.8h, v18.16b // v23: g
|
||||
.endm
|
||||
|
||||
.macro rgb_to_yuv_product r, g, b, dst1, dst2, dst, coef0, coef1, coef2, right_shift
|
||||
mov \dst1\().16b, v6.16b // dst1 = const_offset
|
||||
mov \dst2\().16b, v6.16b // dst2 = const_offset
|
||||
@ -47,7 +57,7 @@
|
||||
sqshrn2 \dst\().8h, \dst2\().4s, \right_shift // dst_higher_half = dst2 >> right_shift
|
||||
.endm
|
||||
|
||||
.macro rgbToY_neon fmt_bgr, fmt_rgb, element
|
||||
.macro rgbToY_neon fmt_bgr, fmt_rgb, element, alpha_first=0
|
||||
function ff_\fmt_bgr\()ToY_neon, export=1
|
||||
cmp w4, #0 // check width > 0
|
||||
ldp w12, w11, [x5] // w12: ry, w11: gy
|
||||
@ -72,7 +82,11 @@ function ff_\fmt_rgb\()ToY_neon, export=1
|
||||
dup v2.8h, w12
|
||||
b.lt 2f
|
||||
1:
|
||||
.if \alpha_first
|
||||
argb_to_yuv_load_rgb x1
|
||||
.else
|
||||
rgb_to_yuv_load_rgb x1, \element
|
||||
.endif
|
||||
rgb_to_yuv_product v19, v20, v21, v25, v26, v16, v0, v1, v2, #9
|
||||
rgb_to_yuv_product v22, v23, v24, v27, v28, v17, v0, v1, v2, #9
|
||||
sub w4, w4, #16 // width -= 16
|
||||
@ -82,9 +96,15 @@ function ff_\fmt_rgb\()ToY_neon, export=1
|
||||
b.ge 1b
|
||||
cbz x4, 3f
|
||||
2:
|
||||
.if \alpha_first
|
||||
ldrb w13, [x1, #1] // w13: r
|
||||
ldrb w14, [x1, #2] // w14: g
|
||||
ldrb w15, [x1, #3] // w15: b
|
||||
.else
|
||||
ldrb w13, [x1] // w13: r
|
||||
ldrb w14, [x1, #1] // w14: g
|
||||
ldrb w15, [x1, #2] // w15: b
|
||||
.endif
|
||||
|
||||
smaddl x13, w13, w10, x9 // x13 = ry * r + const_offset
|
||||
smaddl x13, w14, w11, x13 // x13 += gy * g
|
||||
@ -103,6 +123,8 @@ rgbToY_neon bgr24, rgb24, element=3
|
||||
|
||||
rgbToY_neon bgra32, rgba32, element=4
|
||||
|
||||
rgbToY_neon abgr32, argb32, element=4, alpha_first=1
|
||||
|
||||
.macro rgb_set_uv_coeff half
|
||||
.if \half
|
||||
mov w9, #512
|
||||
@ -120,7 +142,21 @@ rgbToY_neon bgra32, rgba32, element=4
|
||||
dup v6.4s, w9
|
||||
.endm
|
||||
|
||||
.macro rgbToUV_half_neon fmt_bgr, fmt_rgb, element
|
||||
.macro rgb_load_add_half off_r1, off_r2, off_g1, off_g2, off_b1, off_b2
|
||||
ldrb w2, [x3, #\off_r1] // w2: r1
|
||||
ldrb w4, [x3, #\off_r2] // w4: r2
|
||||
add w2, w2, w4 // w2 = r1 + r2
|
||||
|
||||
ldrb w4, [x3, #\off_g1] // w4: g1
|
||||
ldrb w7, [x3, #\off_g2] // w7: g2
|
||||
add w4, w4, w7 // w4 = g1 + g2
|
||||
|
||||
ldrb w7, [x3, #\off_b1] // w7: b1
|
||||
ldrb w8, [x3, #\off_b2] // w8: b2
|
||||
add w7, w7, w8 // w7 = b1 + b2
|
||||
.endm
|
||||
|
||||
.macro rgbToUV_half_neon fmt_bgr, fmt_rgb, element, alpha_first=0
|
||||
function ff_\fmt_bgr\()ToUV_half_neon, export=1
|
||||
cmp w5, #0 // check width > 0
|
||||
b.le 3f
|
||||
@ -148,9 +184,15 @@ function ff_\fmt_rgb\()ToUV_half_neon, export=1
|
||||
.else
|
||||
ld4 { v16.16b, v17.16b, v18.16b, v19.16b }, [x3]
|
||||
.endif
|
||||
.if \alpha_first
|
||||
uaddlp v21.8h, v19.16b
|
||||
uaddlp v20.8h, v18.16b
|
||||
uaddlp v19.8h, v17.16b
|
||||
.else
|
||||
uaddlp v19.8h, v16.16b // v19: r
|
||||
uaddlp v20.8h, v17.16b // v20: g
|
||||
uaddlp v21.8h, v18.16b // v21: b
|
||||
.endif
|
||||
|
||||
rgb_to_yuv_product v19, v20, v21, v22, v23, v16, v0, v1, v2, #10
|
||||
rgb_to_yuv_product v19, v20, v21, v24, v25, v17, v3, v4, v5, #10
|
||||
@ -162,27 +204,15 @@ function ff_\fmt_rgb\()ToUV_half_neon, export=1
|
||||
b.ge 1b
|
||||
cbz w5, 3f
|
||||
2:
|
||||
ldrb w2, [x3] // w2: r1
|
||||
ldrb w4, [x3, #\element] // w4: r2
|
||||
add w2, w2, w4 // w2 = r1 + r2
|
||||
|
||||
.if \alpha_first
|
||||
rgb_load_add_half 1, 5, 2, 6, 3, 7
|
||||
.else
|
||||
.if \element == 3
|
||||
ldrb w4, [x3, #1] // w4: g1
|
||||
ldrb w7, [x3, #4] // w7: g2
|
||||
add w4, w4, w7 // w4 = g1 + g2
|
||||
|
||||
ldrb w7, [x3, #2] // w7: b1
|
||||
ldrb w8, [x3, #5] // w8: b2
|
||||
add w7, w7, w8 // w7 = b1 + b2
|
||||
rgb_load_add_half 0, 3, 1, 4, 2, 5
|
||||
.else
|
||||
ldrb w4, [x3, #1] // w4: g1
|
||||
ldrb w7, [x3, #5] // w7: g2
|
||||
add w4, w4, w7 // w4 = g1 + g2
|
||||
|
||||
ldrb w7, [x3, #2] // w7: b1
|
||||
ldrb w8, [x3, #6] // w8: b2
|
||||
add w7, w7, w8 // w7 = b1 + b2
|
||||
rgb_load_add_half 0, 4, 1, 5, 2, 6
|
||||
.endif
|
||||
.endif
|
||||
|
||||
smaddl x8, w2, w10, x9 // dst_u = ru * r + const_offset
|
||||
smaddl x8, w4, w11, x8 // dst_u += gu * g
|
||||
@ -207,7 +237,9 @@ rgbToUV_half_neon bgr24, rgb24, element=3
|
||||
|
||||
rgbToUV_half_neon bgra32, rgba32, element=4
|
||||
|
||||
.macro rgbToUV_neon fmt_bgr, fmt_rgb, element
|
||||
rgbToUV_half_neon abgr32, argb32, element=4, alpha_first=1
|
||||
|
||||
.macro rgbToUV_neon fmt_bgr, fmt_rgb, element, alpha_first=0
|
||||
function ff_\fmt_bgr\()ToUV_neon, export=1
|
||||
cmp w5, #0 // check width > 0
|
||||
b.le 3f
|
||||
@ -230,7 +262,11 @@ function ff_\fmt_rgb\()ToUV_neon, export=1
|
||||
rgb_set_uv_coeff half=0
|
||||
b.lt 2f
|
||||
1:
|
||||
.if \alpha_first
|
||||
argb_to_yuv_load_rgb x3
|
||||
.else
|
||||
rgb_to_yuv_load_rgb x3, \element
|
||||
.endif
|
||||
rgb_to_yuv_product v19, v20, v21, v25, v26, v16, v0, v1, v2, #9
|
||||
rgb_to_yuv_product v22, v23, v24, v27, v28, v17, v0, v1, v2, #9
|
||||
rgb_to_yuv_product v19, v20, v21, v25, v26, v18, v3, v4, v5, #9
|
||||
@ -243,9 +279,15 @@ function ff_\fmt_rgb\()ToUV_neon, export=1
|
||||
b.ge 1b
|
||||
cbz w5, 3f
|
||||
2:
|
||||
.if \alpha_first
|
||||
ldrb w16, [x3, #1] // w16: r
|
||||
ldrb w17, [x3, #2] // w17: g
|
||||
ldrb w4, [x3, #3] // w4: b
|
||||
.else
|
||||
ldrb w16, [x3] // w16: r
|
||||
ldrb w17, [x3, #1] // w17: g
|
||||
ldrb w4, [x3, #2] // w4: b
|
||||
.endif
|
||||
|
||||
smaddl x8, w16, w10, x9 // x8 = ru * r + const_offset
|
||||
smaddl x8, w17, w11, x8 // x8 += gu * g
|
||||
@ -269,3 +311,5 @@ endfunc
|
||||
rgbToUV_neon bgr24, rgb24, element=3
|
||||
|
||||
rgbToUV_neon bgra32, rgba32, element=4
|
||||
|
||||
rgbToUV_neon abgr32, argb32, element=4, alpha_first=1
|
||||
|
@ -211,6 +211,8 @@ void ff_##name##ToUV_half_neon(uint8_t *, uint8_t *, const uint8_t *, \
|
||||
const uint8_t *, const uint8_t *, int w, \
|
||||
uint32_t *coeffs, void *)
|
||||
|
||||
NEON_INPUT(abgr32);
|
||||
NEON_INPUT(argb32);
|
||||
NEON_INPUT(bgr24);
|
||||
NEON_INPUT(bgra32);
|
||||
NEON_INPUT(rgb24);
|
||||
@ -248,6 +250,21 @@ av_cold void ff_sws_init_swscale_aarch64(SwsContext *c)
|
||||
c->yuv2planeX = ff_yuv2planeX_8_neon;
|
||||
}
|
||||
switch (c->srcFormat) {
|
||||
case AV_PIX_FMT_ABGR:
|
||||
c->lumToYV12 = ff_abgr32ToY_neon;
|
||||
if (c->chrSrcHSubSample)
|
||||
c->chrToYV12 = ff_abgr32ToUV_half_neon;
|
||||
else
|
||||
c->chrToYV12 = ff_abgr32ToUV_neon;
|
||||
break;
|
||||
|
||||
case AV_PIX_FMT_ARGB:
|
||||
c->lumToYV12 = ff_argb32ToY_neon;
|
||||
if (c->chrSrcHSubSample)
|
||||
c->chrToYV12 = ff_argb32ToUV_half_neon;
|
||||
else
|
||||
c->chrToYV12 = ff_argb32ToUV_neon;
|
||||
break;
|
||||
case AV_PIX_FMT_BGR24:
|
||||
c->lumToYV12 = ff_bgr24ToY_neon;
|
||||
if (c->chrSrcHSubSample)
|
||||
|
Loading…
Reference in New Issue
Block a user