From patchwork Mon Jul 1 17:08:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 50260 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp1948065vqv; Mon, 1 Jul 2024 10:08:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVd8wV7u92OEodtJeAKLZ5Ut8Zfleo+fhClVWF2uOsz/s7uVGXTFRWNfMC124V8EygEv++vmd/sFlSoatI9xZ7ooBlzzsKRHbWvyw== X-Google-Smtp-Source: AGHT+IFdvOSd1HAyAVx/A0OYj4KAesqHxiBFH8mOhyoQf2rjx5Gccoy/51sgG+jOUGlhAPKwTfQ6 X-Received: by 2002:a17:907:9854:b0:a6f:d867:4259 with SMTP id a640c23a62f3a-a7514489abbmr471147666b.26.1719853717668; Mon, 01 Jul 2024 10:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719853717; cv=none; d=google.com; s=arc-20160816; b=0/575imrEEt72SB+xQPQ0PGuHxhA4FB3qYx62oD3pQL7OVS46OjZAEdUHgjZjZrXbU hfFDcwMbP82m1Bxdy/yoG1cIQWkMPJy4FhHbYHI99PrnR+eUtMmIs3w6CEwUJcu5+THQ 5svM2R6tC/WaAKd17EdTUNV1S62tfGibWjOa1+r+TvhBGGhSMNXzIXDwZNHMrH2R+YC+ iOZ9NvFLRhNPUEOO/BYuo7OagQj55J//naCFrI4wvy5RQXfPC1RdSWK/5ALFVgj8gepw 22qqVWah9h+cc5n9NBvh1139UphuQAuwrqY/aHxS4xGNFn1QmEdbrWXCL/rfHrV1zXZf Bvfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=3YVAa7rJsiEu0TnbAKtOdmxEO2h50vcyig59s5N9+mY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=rRIcSco7UEQocO/Bz5el9yYYtdzcN7Ojk3LOrc9vM/Etx8+8A1mS+5zmph4tBNvcQM ps2BLjYvcDUKfu0QqTNomJn0nMryd12AYrAwSpNbKKNstbpaZG0y0q+CRiW9Bud0A6Rm iVsgbBI7RSqXXfEFeP1odvl78D0BE6+F63MrtXtPz+qhLRUJNoSBsW6DP7hFNFW5zTLn qYBJ4liSZp6bgKsxCpQNoe3DPreOnBY6fqX3fgtqzvIJXRSHK6MhyqHPXIvOOBY+t+uX JNK1jsQedjv3R4tPtIuAg2EofEhX3yWAh3jNrWBefmgyeFDFOH+bP4rEQDxNzbPvgBWP kFiQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a72ab075322si368403766b.544.2024.07.01.10.08.37; Mon, 01 Jul 2024 10:08:37 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CEBB068D816; Mon, 1 Jul 2024 20:08:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 479C868D787 for ; Mon, 1 Jul 2024 20:08:08 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id F41E5C02F8 for ; Mon, 1 Jul 2024 20:08:07 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 Jul 2024 20:08:06 +0300 Message-ID: <20240701170807.107018-3-remi@remlab.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240701170807.107018-1-remi@remlab.net> References: <20240701170807.107018-1-remi@remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] WIP: lavc/h264dsp: take over looking up TC values X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: GK/BpLhKmrOP This moves the look-up of TC values from bS from the generic C loop filter code to the DSP functions. This (potentially) eliminates a round-trip to the stack for the looked-up values. This is work-in-progress. 8 functions need to be updated and this only updates one of them. Also updating the platform-specific optimisations is left as an exercise for a future version, as is updating checkasm. --- libavcodec/h264_loopfilter.c | 8 ++------ libavcodec/h264dsp.h | 4 +++- libavcodec/h264dsp_template.c | 9 +++++++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c index 96f572c1d2..8fca08811c 100644 --- a/libavcodec/h264_loopfilter.c +++ b/libavcodec/h264_loopfilter.c @@ -108,12 +108,8 @@ static av_always_inline void filter_mb_edgev(uint8_t *pix, int stride, if (alpha ==0 || beta == 0) return; if( bS[0] < 4 || !intra ) { - int8_t tc[4]; - tc[0] = ff_h264_tc0_table[index_a][bS[0]]; - tc[1] = ff_h264_tc0_table[index_a][bS[1]]; - tc[2] = ff_h264_tc0_table[index_a][bS[2]]; - tc[3] = ff_h264_tc0_table[index_a][bS[3]]; - h->h264dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc); + const int8_t *tc = ff_h264_tc0_table[index_a]; + h->h264dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc, bS); } else { h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta); } diff --git a/libavcodec/h264dsp.h b/libavcodec/h264dsp.h index 13371c59ea..f37ff5414c 100644 --- a/libavcodec/h264dsp.h +++ b/libavcodec/h264dsp.h @@ -48,7 +48,9 @@ typedef struct H264DSPContext { void (*h264_v_loop_filter_luma)(uint8_t *pix /*align 16*/, ptrdiff_t stride, int alpha, int beta, int8_t *tc0); void (*h264_h_loop_filter_luma)(uint8_t *pix /*align 4 */, ptrdiff_t stride, - int alpha, int beta, int8_t *tc0); + int alpha, int beta, + const int8_t tc0[4] /*align 4*/, + const int16_t bs[4] /*align 8*/); void (*h264_h_loop_filter_luma_mbaff)(uint8_t *pix /*align 16*/, ptrdiff_t stride, int alpha, int beta, int8_t *tc0); /* v/h_loop_filter_luma_intra: align 16 */ diff --git a/libavcodec/h264dsp_template.c b/libavcodec/h264dsp_template.c index fe23a2cff1..4d4e34cf81 100644 --- a/libavcodec/h264dsp_template.c +++ b/libavcodec/h264dsp_template.c @@ -153,9 +153,14 @@ static void FUNCC(h264_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride, int a { FUNCC(h264_loop_filter_luma)(pix, stride, sizeof(pixel), 4, alpha, beta, tc0); } -static void FUNCC(h264_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0) +static void FUNCC(h264_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, const int8_t tc0[4], const int16_t bS[4]) { - FUNCC(h264_loop_filter_luma)(pix, sizeof(pixel), stride, 4, alpha, beta, tc0); + int8_t tc[4]; + + for (size_t i = 0; i < 4; i++) + tc[i] = tc0[bS[i]]; + + FUNCC(h264_loop_filter_luma)(pix, sizeof(pixel), stride, 4, alpha, beta, tc); } static void FUNCC(h264_h_loop_filter_luma_mbaff)(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0) {