From patchwork Thu Apr 8 19:00:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Nitenko X-Patchwork-Id: 26811 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 7314744A4CC for ; Thu, 8 Apr 2021 22:10:11 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 49DC368A682; Thu, 8 Apr 2021 22:10:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 14F9C68921B for ; Thu, 8 Apr 2021 22:10:05 +0300 (EEST) Received: by mail-lj1-f169.google.com with SMTP id s17so3585362ljc.5 for ; Thu, 08 Apr 2021 12:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xKmQ7fYn+7AWioEBnHrCpItJFHtF7FqBNnZnkAsfd9Y=; b=ZLwV21UeNp1s8hjlhMZ9XNQu4WeVSUPwaJraUA8LUj3lusFnKew/sEqHUzsVcrqN+y XVJmKjizQL/AXvX+jJRVmW39m7HOlSLono6Un98Ewd0Sq7NGKVR2/mrrPy6Qd4jriv+k QpPTwWTg6gxvxwQgkV1ohfg0R2KugYjxLRnl3BJSUfeW1ed/C6iwnhe3S/wCIxxHEuXv jHGd1kvv3PCGgn8StRjivqN1Dcvf9ShsrnOmtHBoERAkxU26M8gTmO0fth3BMOhcIUzd iPTAYx413/rzGnvKddW9ntoHDQ9QilZLBTpO7kFeE91ETiNca6wR7yaH3QUA+A1F2JnR f9rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xKmQ7fYn+7AWioEBnHrCpItJFHtF7FqBNnZnkAsfd9Y=; b=GbdWI0sRrqHxhkB472ImsBepg7DaVj++TjAN1KJmzXx2du1LDB+LuaRVntVCCOuYGW SDP+Z2gYeMoWbhmkAxQ2ogKpEgbRaIwjWNVjDE/HTsUHi1IGJ/5uE612YQMMDAVNtFBa K1GBtRajvSYfBBl/RhQu8MfWiJFzuRaRZYHnOhOxXmhKU4IMcdBcELv+ywsuhlJG7O59 Cfhg21n6HbShAQgJhCLCpRwcWRSIfbP2YogciWqjD8zHbof/87SZfiJPj1H37BTbaiji +uwvpw5zQ+9z0KXkC1HVIXt7fum8gSYHKvK3Zb+68cG4P85RmOkrGHcEEN2Q2lJa7goL 79Bw== X-Gm-Message-State: AOAM5308Yv/4iXxV57V3OBC//kj+CJBFPAsIRDsIzrVktsGc8PybNB1u 2YDFdEG7p54KhD03UsSQvYxoSh+m39vcNg== X-Google-Smtp-Source: ABdhPJyc2Uh+Of/DX3IASXRWCkO/FYFI2/5u1t6TjnJ+32Un2FEC7U/Iqpa0F04l+q/1gvjcmXcgqQ== X-Received: by 2002:a05:651c:1314:: with SMTP id u20mr7083106lja.36.1617908519155; Thu, 08 Apr 2021 12:01:59 -0700 (PDT) Received: from localhost.localdomain (broadband-109-173-73-178.ip.moscow.rt.ru. [109.173.73.178]) by smtp.gmail.com with ESMTPSA id i8sm29653lfe.153.2021.04.08.12.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 12:01:58 -0700 (PDT) From: Mikhail Nitenko To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Apr 2021 22:00:44 +0300 Message-Id: <20210408190044.70816-1-mnitenko@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/aarch64: add pred16x16 10-bit functions 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: Mikhail Nitenko Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" here are the benchmarks https://0x1.st/kX.txt --- libavcodec/aarch64/h264pred_init.c | 75 +++++++++++------- libavcodec/aarch64/h264pred_neon.S | 123 +++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+), 30 deletions(-) diff --git a/libavcodec/aarch64/h264pred_init.c b/libavcodec/aarch64/h264pred_init.c index b144376f90..d74205c2de 100644 --- a/libavcodec/aarch64/h264pred_init.c +++ b/libavcodec/aarch64/h264pred_init.c @@ -45,42 +45,57 @@ void ff_pred8x8_0lt_dc_neon(uint8_t *src, ptrdiff_t stride); void ff_pred8x8_l00_dc_neon(uint8_t *src, ptrdiff_t stride); void ff_pred8x8_0l0_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_128_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_top_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_left_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_hor_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_vert_neon_10(uint8_t *src, ptrdiff_t stride); + static av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc) { - const int high_depth = bit_depth > 8; - - if (high_depth) - return; - - if (chroma_format_idc <= 1) { - h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon; - h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_hor_neon; - if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) - h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon; - h->pred8x8[DC_128_PRED8x8 ] = ff_pred8x8_128_dc_neon; - if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 && - codec_id != AV_CODEC_ID_VP8) { - h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_neon; - h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon; - h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon; - h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = ff_pred8x8_l0t_dc_neon; - h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = ff_pred8x8_0lt_dc_neon; - h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = ff_pred8x8_l00_dc_neon; - h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = ff_pred8x8_0l0_dc_neon; + if (bit_depth == 8) { + if (chroma_format_idc <= 1) { + h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon; + h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_hor_neon; + if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) + h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon; + h->pred8x8[DC_128_PRED8x8 ] = ff_pred8x8_128_dc_neon; + if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 && + codec_id != AV_CODEC_ID_VP8) { + h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_neon; + h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon; + h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon; + h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = ff_pred8x8_l0t_dc_neon; + h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = ff_pred8x8_0lt_dc_neon; + h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = ff_pred8x8_l00_dc_neon; + h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = ff_pred8x8_0l0_dc_neon; + } } - } - h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon; - h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vert_neon; - h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_hor_neon; - h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_neon; - h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon; - h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_neon; - if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 && - codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) - h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon; + h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vert_neon; + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_hor_neon; + h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_neon; + h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon; + h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_neon; + if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 && + codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; + } + if (bit_depth == 10) { + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon_10; + h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vert_neon_10; + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_hor_neon_10; + h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon_10; + h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_neon_10; + h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_neon_10; + if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 && + codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) {} + //h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; + } } av_cold void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id, diff --git a/libavcodec/aarch64/h264pred_neon.S b/libavcodec/aarch64/h264pred_neon.S index 213b40b3e7..633b401d59 100644 --- a/libavcodec/aarch64/h264pred_neon.S +++ b/libavcodec/aarch64/h264pred_neon.S @@ -359,3 +359,126 @@ function ff_pred8x8_0l0_dc_neon, export=1 dup v1.8b, v1.b[0] b .L_pred8x8_dc_end endfunc + +.macro ldcol.16 rd, rs, rt, n=4, hi=0 +.if \n >= 4 || \hi == 0 + ld1 {\rd\().h}[0], [\rs], \rt + ld1 {\rd\().h}[1], [\rs], \rt +.endif +.if \n >= 4 || \hi == 1 + ld1 {\rd\().h}[2], [\rs], \rt + ld1 {\rd\().h}[3], [\rs], \rt +.endif +.if \n == 8 + ld1 {\rd\().h}[4], [\rs], \rt + ld1 {\rd\().h}[5], [\rs], \rt + ld1 {\rd\().h}[6], [\rs], \rt + ld1 {\rd\().h}[7], [\rs], \rt +.endif +.endm + +function ff_pred16x16_128_dc_neon_10, export=1 + movi v0.8h, #2, lsl #8 // 512, 1 << (bit_depth - 1) + + b .L_pred16x16_dc_10_end +endfunc + +function ff_pred16x16_top_dc_neon_10, export=1 + sub x2, x0, x1 + + ld1 {v0.8h}, [x2], #16 + ld1 {v1.8h}, [x2] + + uaddlv s0, v0.8h + uaddlv s1, v1.8h + + add v0.2s, v0.2s, v1.2s + + rshrn v0.4h, v0.4s, #4 + dup v0.8h, v0.h[0] + b .L_pred16x16_dc_10_end +endfunc + +function ff_pred16x16_left_dc_neon_10, export=1 + sub x2, x0, #2 // access to the "left" column + ldcol.16 v0, x2, x1, 8 + ldcol.16 v1, x2, x1, 8 // load "left" column + + uaddlv s0, v0.8h + uaddlv s1, v1.8h + + add v0.2s, v0.2s, v1.2s + + rshrn v0.4h, v0.4s, #4 + dup v0.8h, v0.h[0] + b .L_pred16x16_dc_10_end +endfunc + +function ff_pred16x16_dc_neon_10, export=1 + sub x2, x0, x1 // access to the "top" row + sub x3, x0, #2 // access to the "left" column + + ld1 {v0.8h}, [x2], #16 + ld1 {v1.8h}, [x2] + ldcol.16 v2, x3, x1, 8 + ldcol.16 v3, x3, x1, 8 // load pixels in "top" col and "left" row + + uaddlv s0, v0.8h + uaddlv s1, v1.8h + uaddlv s2, v2.8h // sum all pixels in the "top" row and "left" col + uaddlv s3, v3.8h // (sum stays in v0-v3 registers) + + add v0.2s, v0.2s, v1.2s + add v0.2s, v0.2s, v2.2s + add v0.2s, v0.2s, v3.2s // sum registers v0-v3 + + rshrn v0.4h, v0.4s, #5 // right shift vector + dup v0.8h, v0.h[0] // fill vector with 0th value (dcsplat) +.L_pred16x16_dc_10_end: + sub x1, x1, #16 + mov w3, #8 +6: st1 {v0.8h}, [x0], #16 + st1 {v0.8h}, [x0], x1 + + st1 {v0.8h}, [x0], #16 + st1 {v0.8h}, [x0], x1 + + subs w3, w3, #1 + b.ne 6b + ret +endfunc + +function ff_pred16x16_hor_neon_10, export=1 + sub x2, x0, #2 + sub x3, x1, #16 + + mov w4, #16 +1: ld1r {v0.8h}, [x2], x1 + st1 {v0.8h}, [x0], #16 + st1 {v0.8h}, [x0], x3 + + subs w4, w4, #1 + b.ne 1b + ret +endfunc + +function ff_pred16x16_vert_neon_10, export=1 + sub x2, x0, x1 + add x1, x1, x1 + sub x1, x1, #16 + + ld1 {v0.8h}, [x2], #16 + ld1 {v1.8h}, [x2], x1 + + mov w3, #8 +1: st1 {v0.8h}, [x0], #16 + st1 {v1.8h}, [x0], x1 + + st1 {v0.8h}, [x2], #16 + st1 {v1.8h}, [x2], x1 + + subs w3, w3, #1 + b.ne 1b + ret +endfunc +