From patchwork Sun Jan 10 23:24:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Reimar_D=C3=B6ffinger?= X-Patchwork-Id: 24890 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id F256E44AD29 for ; Mon, 11 Jan 2021 01:25:10 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BF33868A68F; Mon, 11 Jan 2021 01:25:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.73]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6F0C56880A8 for ; Mon, 11 Jan 2021 01:25:04 +0200 (EET) Received: from localhost.localdomain ([81.170.149.220]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mz9d7-1k2fiW1Mpf-00wDRy; Mon, 11 Jan 2021 00:25:03 +0100 From: Reimar.Doeffinger@gmx.de To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Jan 2021 00:24:53 +0100 Message-Id: <20210110232453.52663-1-Reimar.Doeffinger@gmx.de> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 X-Provags-ID: V03:K1:5LAFB+uZ4PGV+aQE4WOoxtBfiFJ8lFf8fC+IUNg4RXTJCY3rqZv h+5W430woWDL/PJxt9UvM2CydroYORr5YLvpe9bROREr0foMH0t5RJM3ooUCzoN0gmskGbS g3E4kG8arCV5DCqnMvu8rruw+prQz3p5sDsgeB4EEr1sivQeoeYvI0Fskj6ZKP2SNSbExhR lz1Av3xvE1VKAj4hADEUQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:PvfJ9MY9ZHk=:pikT/ykFGVYXmzyQxogU+h yda9x33+i33tHsB+51j34sFmw153x2VZLJtvyNhkJiH7FAgtYzZ1vZYJCicJF9HnUgrfvO9bv G99FBQUIuHtkdYjbVU13GgO5FgoEy7Uuc4qyvFC8KFLri4qBhmHGzxhQ/WTg6ZEwxDADKJ/0j p+kNzvE/qVRVCDc5iYXL8FTEdCFlOLGWjofZrh449lJPg4GOiuWT0e9n9Zyj19NnOpeWFjphc hNJjuxoM96UJQYGWlWAnx9autdkflN9Jpqs+WXOH2dXt7L6YpDXWJrGN3Omv8PtxasoDZ/OfK 4UF3NRjHVS2GKqhbOH6Sgy5fjFWFdRRJ0fYqkPK+0sNnY0tkKgXmZbEWJTnRq/xS2g7VkcmHb VKeFd8vxaQ2+9z9fjzhYXqSGV2Ao7txo8LXzPlce+6TkSkWfej24GUSphkENhZS09sL7C5v9q fS7JYjX4Ow== Subject: [FFmpeg-devel] [PATCH] libswscale/aarch64/hscale.S: Support more bit-depth variants. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: =?utf-8?q?Reimar_D=C3=B6ffinger?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Reimar Döffinger Trivially expand hscale assembler to support > 8 bit formats both for input and output. 16-bit input is not supported as I am not certain how to get sufficient test coverage. --- libswscale/aarch64/hscale.S | 53 ++++++++++++++++++++++++++---------- libswscale/aarch64/swscale.c | 49 +++++++++++++++++++++++++++++++-- 2 files changed, 85 insertions(+), 17 deletions(-) diff --git a/libswscale/aarch64/hscale.S b/libswscale/aarch64/hscale.S index af55ffe2b7..3b42d39dac 100644 --- a/libswscale/aarch64/hscale.S +++ b/libswscale/aarch64/hscale.S @@ -20,7 +20,11 @@ #include "libavutil/aarch64/asm.S" -function ff_hscale_8_to_15_neon, export=1 +.macro hscale srcbits, dstbits, ldt, lds, c +function ff_hscale_\srcbits\()_to_\dstbits\()_neon, export=1 +.if \dstbits >= 16 + movi v20.4S, #(0x1 << (\dstbits - 16)), msl #16 +.endif sbfiz x7, x6, #1, #32 // filterSize*2 (*2 because int16) 1: ldr w8, [x5], #4 // filterPos[idx] ldr w0, [x5], #4 // filterPos[idx + 1] @@ -34,30 +38,30 @@ function ff_hscale_8_to_15_neon, export=1 movi v1.2D, #0 // val sum part 2 (for dst[1]) movi v2.2D, #0 // val sum part 3 (for dst[2]) movi v3.2D, #0 // val sum part 4 (for dst[3]) - add x17, x3, w8, UXTW // srcp + filterPos[0] - add x8, x3, w0, UXTW // srcp + filterPos[1] - add x0, x3, w11, UXTW // srcp + filterPos[2] - add x11, x3, w9, UXTW // srcp + filterPos[3] + add x17, x3, w8, UXTW #!!(\srcbits > 8) // srcp + filterPos[0] + add x8, x3, w0, UXTW #!!(\srcbits > 8) // srcp + filterPos[1] + add x0, x3, w11, UXTW #!!(\srcbits > 8) // srcp + filterPos[2] + add x11, x3, w9, UXTW #!!(\srcbits > 8) // srcp + filterPos[3] mov w15, w6 // filterSize counter -2: ld1 {v4.8B}, [x17], #8 // srcp[filterPos[0] + {0..7}] +2: ld1 {v4.\ldt}, [x17], \lds // srcp[filterPos[0] + {0..7}] ld1 {v5.8H}, [x16], #16 // load 8x16-bit filter values, part 1 - ld1 {v6.8B}, [x8], #8 // srcp[filterPos[1] + {0..7}] + ld1 {v6.\ldt}, [x8], \lds // srcp[filterPos[1] + {0..7}] ld1 {v7.8H}, [x12], #16 // load 8x16-bit at filter+filterSize - uxtl v4.8H, v4.8B // unpack part 1 to 16-bit +\c\c uxtl v4.8H, v4.8B // unpack part 1 to 16-bit smlal v0.4S, v4.4H, v5.4H // v0 accumulates srcp[filterPos[0] + {0..3}] * filter[{0..3}] smlal2 v0.4S, v4.8H, v5.8H // v0 accumulates srcp[filterPos[0] + {4..7}] * filter[{4..7}] - ld1 {v16.8B}, [x0], #8 // srcp[filterPos[2] + {0..7}] + ld1 {v16.\ldt}, [x0], \lds // srcp[filterPos[2] + {0..7}] ld1 {v17.8H}, [x13], #16 // load 8x16-bit at filter+2*filterSize - uxtl v6.8H, v6.8B // unpack part 2 to 16-bit +\c\c uxtl v6.8H, v6.8B // unpack part 2 to 16-bit smlal v1.4S, v6.4H, v7.4H // v1 accumulates srcp[filterPos[1] + {0..3}] * filter[{0..3}] - uxtl v16.8H, v16.8B // unpack part 3 to 16-bit +\c\c uxtl v16.8H, v16.8B // unpack part 3 to 16-bit smlal v2.4S, v16.4H, v17.4H // v2 accumulates srcp[filterPos[2] + {0..3}] * filter[{0..3}] smlal2 v2.4S, v16.8H, v17.8H // v2 accumulates srcp[filterPos[2] + {4..7}] * filter[{4..7}] - ld1 {v18.8B}, [x11], #8 // srcp[filterPos[3] + {0..7}] + ld1 {v18.\ldt}, [x11], \lds // srcp[filterPos[3] + {0..7}] smlal2 v1.4S, v6.8H, v7.8H // v1 accumulates srcp[filterPos[1] + {4..7}] * filter[{4..7}] ld1 {v19.8H}, [x4], #16 // load 8x16-bit at filter+3*filterSize subs w15, w15, #8 // j -= 8: processed 8/filterSize - uxtl v18.8H, v18.8B // unpack part 4 to 16-bit +\c\c uxtl v18.8H, v18.8B // unpack part 4 to 16-bit smlal v3.4S, v18.4H, v19.4H // v3 accumulates srcp[filterPos[3] + {0..3}] * filter[{0..3}] smlal2 v3.4S, v18.8H, v19.8H // v3 accumulates srcp[filterPos[3] + {4..7}] * filter[{4..7}] b.gt 2b // inner loop if filterSize not consumed completely @@ -73,8 +77,29 @@ function ff_hscale_8_to_15_neon, export=1 zip1 v2.4S, v2.4S, v3.4S // part23 = zip values from part2 and part3 mov v0.d[1], v2.d[0] // part0123 = zip values from part01 and part23 subs w2, w2, #4 // dstW -= 4 - sqshrn v0.4H, v0.4S, #7 // shift and clip the 2x16-bit final values +.if \dstbits < 16 + sqshrn v0.4H, v0.4S, #(14 + \srcbits - \dstbits) // shift and clip the 2x16-bit final values st1 {v0.4H}, [x1], #8 // write to destination part0123 +.else + srshr v0.4S, v0.4S, #(14 + \srcbits - \dstbits) + smin v0.4S, V0.4S, V20.4S + st1 {v0.4S}, [x1], #16 +.endif b.gt 1b // loop until end of line ret endfunc +.endm + +hscale 8, 15, 8B, #8 +hscale 9, 15, 8H, #16, / +hscale 10, 15, 8H, #16, / +hscale 12, 15, 8H, #16, / +hscale 14, 15, 8H, #16, / +// hscale 16, 15, 8H, #16, / // needs testing and possibly some special-cases + +hscale 8 19, 8B, #8 +hscale 9, 19, 8H, #16, / +hscale 10, 19, 8H, #16, / +hscale 12, 19, 8H, #16, / +hscale 14, 19, 8H, #16, / +// hscale 16, 19, 8H, #16, / // needs testing and possibly some special-cases diff --git a/libswscale/aarch64/swscale.c b/libswscale/aarch64/swscale.c index eecbea88ca..4c88f929d7 100644 --- a/libswscale/aarch64/swscale.c +++ b/libswscale/aarch64/swscale.c @@ -24,6 +24,33 @@ void ff_hscale_8_to_15_neon(SwsContext *c, int16_t *dst, int dstW, const uint8_t *src, const int16_t *filter, const int32_t *filterPos, int filterSize); +void ff_hscale_9_to_15_neon(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize); +void ff_hscale_10_to_15_neon(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize); +void ff_hscale_12_to_15_neon(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize); +void ff_hscale_14_to_15_neon(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize); +void ff_hscale_8_to_19_neon(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize); +void ff_hscale_9_to_19_neon(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize); +void ff_hscale_10_to_19_neon(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize); +void ff_hscale_12_to_19_neon(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize); +void ff_hscale_14_to_19_neon(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize); void ff_yuv2planeX_8_neon(const int16_t *filter, int filterSize, const int16_t **src, uint8_t *dest, int dstW, @@ -34,11 +61,27 @@ av_cold void ff_sws_init_swscale_aarch64(SwsContext *c) int cpu_flags = av_get_cpu_flags(); if (have_neon(cpu_flags)) { - if (c->srcBpc == 8 && c->dstBpc <= 14 && - (c->hLumFilterSize % 8) == 0 && + if ((c->hLumFilterSize % 8) == 0 && (c->hChrFilterSize % 8) == 0) { - c->hyScale = c->hcScale = ff_hscale_8_to_15_neon; + int largedst = c->dstBpc > 14; + switch (c->srcBpc) { + case 8: + c->hyScale = c->hcScale = largedst ? ff_hscale_8_to_19_neon : ff_hscale_8_to_15_neon; + break; + case 9: + c->hyScale = c->hcScale = largedst ? ff_hscale_9_to_19_neon : ff_hscale_9_to_15_neon; + break; + case 10: + c->hyScale = c->hcScale = largedst ? ff_hscale_10_to_19_neon : ff_hscale_10_to_15_neon; + break; + case 12: + c->hyScale = c->hcScale = largedst ? ff_hscale_12_to_19_neon : ff_hscale_12_to_15_neon; + break; + case 14: + c->hyScale = c->hcScale = largedst ? ff_hscale_14_to_19_neon : ff_hscale_14_to_15_neon; + break; + } } if (c->dstBpc == 8) { c->yuv2planeX = ff_yuv2planeX_8_neon;