From patchwork Mon Jul 1 19:13:25 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: 50262 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp2008930vqv; Mon, 1 Jul 2024 12:13:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWkIsE+mBWwW0i+wYwXMEolMt22lIhQDybFsQzwFOjg656f86BvBBl3HnMLx2vMofA0VuCGqhEQ0PPGoe41LOzJgm05iP4TtQTalA== X-Google-Smtp-Source: AGHT+IFIjGzSqTzwlpE6hfqSrOW3Hx6FBNxCspqpLCETo0vCD2R7N5/8Y1YHAw8jGNfUieQPZDOu X-Received: by 2002:a05:6512:1592:b0:52c:f55d:44a3 with SMTP id 2adb3069b0e04-52e8266deffmr5251666e87.19.1719861220091; Mon, 01 Jul 2024 12:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719861220; cv=none; d=google.com; s=arc-20160816; b=gvIofe2n3jnLPtz9SzvjAKiebOM1T2VAaAuIvxOP7tCUqFY/oqJhRM4gjfV6R6lzL9 uUY4E9tOjFtJlYWOCidqv4N/qE3th3NOSZACn5wsUcgYkdWOCOSq7DVY39MXJwSyYn01 AGYzA3TU24aWH3dVJS6gxQ0d6WZgRBPA3lX3lc/sp6v0mONKl01+pJ1rgnPXUuYVPZDu fNfXaT3eOiusXTopwABN2J/uFvUiAC6mbqAKUhviWX4Mhj3dNh7z0pxl3R83SXRIuoUn PWZTBbfJT498ukJUrrKldyhEbbXv+p/LzU+awHBzqeCD8dwoG5cQcphEFEvBp4yGB9ff rOnA== 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:message-id:date:to:from :delivered-to; bh=jWl4aPFwfd3uP3J+zjC/6i2P/r17UI+LML+7sKid2x0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=ok2rSmcyyY9HqYSXQeUWRLK71ye5UbALlnzFwzuMEHPEa6DBZH+I77LF65PNc/UD8n RXOawWbb970pyJezZwFFcfkNYGrkLo4uAw//WX38XlHDKBOcR3yStsdCDrHQ0NhJ6kjE 0earZNIzlQRT908niKg7TEseHBtDz+qdEg0S/DFo9mlLjOVFMF9ewrQtnCTwQ9/cBMhO /DSCemZdRQIWvrfWnYgI6GnOVfrT8Iv4TVskwGy8oI/1YHiivfexZHYhp1o63iVOTkrT Otg+h+jqntQJe6NBDKATrNyJvrKoRLN7m6B9x4+3qKe5ldA0AGM8vepi5fSmNBdFjMC/ aA4w==; 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 2adb3069b0e04-52e7ab32161si2491615e87.553.2024.07.01.12.13.39; Mon, 01 Jul 2024 12:13:40 -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 7153068D5BD; Mon, 1 Jul 2024 22:13:36 +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 4315768D560 for ; Mon, 1 Jul 2024 22:13:29 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id D0E15C0140 for ; Mon, 1 Jul 2024 22:13:28 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 Jul 2024 22:13:25 +0300 Message-ID: <20240701191328.466433-1-remi@remlab.net> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] lavc/h263dsp: add DCT dequantisation functions 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: culcm7tymZFZ Note that optimised implementations of these functions will be taken into actual use only if MpegEncContext.dct_unquantize_h263_{inter,intra} are *not* overloaded by existing optimisations. --- libavcodec/h263dsp.c | 25 +++++++++++++++++++++++++ libavcodec/h263dsp.h | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/libavcodec/h263dsp.c b/libavcodec/h263dsp.c index 6a13353499..dc146bf821 100644 --- a/libavcodec/h263dsp.c +++ b/libavcodec/h263dsp.c @@ -19,10 +19,33 @@ #include #include "libavutil/attributes.h" +#include "libavutil/avassert.h" #include "libavutil/common.h" #include "config.h" #include "h263dsp.h" +static void h263_dct_unquantize_inter_c(int16_t *block, ptrdiff_t len, + int qmul, int qadd) +{ + for (ptrdiff_t i = 0; i <= len; i++) { + int level = block[i]; + + if (level) { + if (level < 0) + level = level * qmul - qadd; + else + level = level * qmul + qadd; + block[i] = level; + } + } +} + +static void h263_dct_unquantize_intra_c(int16_t *block, ptrdiff_t len, + int qmul, int qadd) +{ + h263_dct_unquantize_inter_c(block + 1, len - 1, qmul, qadd); +} + const uint8_t ff_h263_loop_filter_strength[32] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12 @@ -116,6 +139,8 @@ static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale) av_cold void ff_h263dsp_init(H263DSPContext *ctx) { + ctx->h263_dct_unquantize_intra = h263_dct_unquantize_intra_c; + ctx->h263_dct_unquantize_inter = h263_dct_unquantize_inter_c; ctx->h263_h_loop_filter = h263_h_loop_filter_c; ctx->h263_v_loop_filter = h263_v_loop_filter_c; diff --git a/libavcodec/h263dsp.h b/libavcodec/h263dsp.h index 2dccd23392..d26498f491 100644 --- a/libavcodec/h263dsp.h +++ b/libavcodec/h263dsp.h @@ -24,6 +24,10 @@ extern const uint8_t ff_h263_loop_filter_strength[32]; typedef struct H263DSPContext { + void (*h263_dct_unquantize_intra)(int16_t *block /* align 16 */, + ptrdiff_t len, int mul, int add); + void (*h263_dct_unquantize_inter)(int16_t *block /* align 16 */, + ptrdiff_t len, int mul, int add); void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale); void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale); } H263DSPContext; From patchwork Mon Jul 1 19:13:26 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: 50264 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp2009012vqv; Mon, 1 Jul 2024 12:13:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXymvsR/GWLEfVOe/f+63r5zhvATOVrn3Mp3jNo6MAKgN0kGjJqduj8b8qYoN1W4gyemhfAWRz9xXOQZJCPM+WfCe731Ro0RXrWtA== X-Google-Smtp-Source: AGHT+IEeCWekNKZkZTGGUaNNuqdjb5IxWhQvTBVX1QazoVV+Fke6CMjpp7yf8Im2DfKcmMqfUebO X-Received: by 2002:a17:907:86a0:b0:a5c:eafb:5288 with SMTP id a640c23a62f3a-a751448a596mr602879766b.31.1719861228308; Mon, 01 Jul 2024 12:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719861228; cv=none; d=google.com; s=arc-20160816; b=A07txkKSKFMKmv9G+MLSPehqRt5dJ02++CRURIb4SAsqTDOGcz06Wh4B+nbhZLjSQe Potfpc7fS6S1VS/ODyfQLVRkP6hp6ZMHWGVa/0D3W1cYsAJ52CQbsW0LC9G2uBtyoQoI TfsyRTryUjtR1Y0CI77vEVZfrlR5gLcaA1tGwRJsjL5VGCXkcqRFfdoAVvS3WQN5r45i 8lGOagppqswWWpGIS7ic2vw9H8i6pxPBQODsqomZ29671dGrUxqbpuDppLlBbmPZVk9E 3FC+36XMAnI+H/38RKV8k0hAObekQnIFiDvRnecNhaZPMrFne90xXEX+26tDoXuRnc+o 49Lg== 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=g1LNF2swuEK8sHNZUvS2rGhMIpxjGjQfxwLvbyvBc5E=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=KEF3OlA0O7NvWkpYXcm+CsjEuBqic6J+8pfjGnaMQi/aprrDEfy4mo50kBKI90tbX3 9lwYzJA+3HGRoQqTH1KfAe5SXmjWytIiq4d3j1XuHKnVl+MVWUVzi/CkA9ET5yx7iwQB 95auUGvC+gS/s7UM/nFAZ3fTXtRYOFtl+DzrnYj3gTI4i6EfoIs38RMhawOcTPid1GKx 5HrGcUo+PILTdxiTHWincAtl8EMhkxhl6CaWgf+DgvS8icLAsEvcTTwqzzNveAPkbJnN zcZB0JS79YtYWalTHZTLuFFj/klNCagHMVtGV2g7ewJXiiZCW7AbJqwjJfwzha0XHHtr ntkQ==; 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-a72aaef61d6si395304766b.43.2024.07.01.12.13.47; Mon, 01 Jul 2024 12:13:48 -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 8736168D845; Mon, 1 Jul 2024 22:13:37 +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 6D9A668D5BD for ; Mon, 1 Jul 2024 22:13:29 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 0D989C0170 for ; Mon, 1 Jul 2024 22:13:29 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 Jul 2024 22:13:26 +0300 Message-ID: <20240701191328.466433-2-remi@remlab.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240701191328.466433-1-remi@remlab.net> References: <20240701191328.466433-1-remi@remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] lavc/mpegvideo: use H263DSP dequant function 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: Y5rOCPW3jEPL --- configure | 4 ++-- libavcodec/mpegvideo.c | 40 +++++++++------------------------------- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/configure b/configure index fed4c44cd1..42b9a72d5a 100755 --- a/configure +++ b/configure @@ -2954,8 +2954,8 @@ ftr_decoder_select="adts_header" g2m_decoder_deps="zlib" g2m_decoder_select="blockdsp idctdsp jpegtables" g729_decoder_select="audiodsp" -h261_decoder_select="mpegvideodec" -h261_encoder_select="mpegvideoenc" +h261_decoder_select="h263dsp mpegvideodec" +h261_encoder_select="h263dsp mpegvideoenc" h263_decoder_select="h263_parser h263dsp mpegvideodec qpeldsp" h263_encoder_select="h263dsp mpegvideoenc" h263i_decoder_select="h263_decoder" diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index b9a0469335..c9094d1cce 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -202,13 +202,11 @@ static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s, static void dct_unquantize_h263_intra_c(MpegEncContext *s, int16_t *block, int n, int qscale) { - int i, level, qmul, qadd; - int nCoeffs; + int qmul = qscale << 1; + int qadd, nCoeffs; av_assert2(s->block_last_index[n]>=0 || s->h263_aic); - qmul = qscale << 1; - if (!s->h263_aic) { block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale; qadd = (qscale - 1) | 1; @@ -220,43 +218,20 @@ static void dct_unquantize_h263_intra_c(MpegEncContext *s, else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]; - for(i=1; i<=nCoeffs; i++) { - level = block[i]; - if (level) { - if (level < 0) { - level = level * qmul - qadd; - } else { - level = level * qmul + qadd; - } - block[i] = level; - } - } + s->h263dsp.h263_dct_unquantize_intra(block, nCoeffs, qmul, qadd); } static void dct_unquantize_h263_inter_c(MpegEncContext *s, int16_t *block, int n, int qscale) { - int i, level, qmul, qadd; + int qmul = qscale << 1; + int qadd = (qscale - 1) | 1; int nCoeffs; av_assert2(s->block_last_index[n]>=0); - qadd = (qscale - 1) | 1; - qmul = qscale << 1; - nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ]; - - for(i=0; i<=nCoeffs; i++) { - level = block[i]; - if (level) { - if (level < 0) { - level = level * qmul - qadd; - } else { - level = level * qmul + qadd; - } - block[i] = level; - } - } + s->h263dsp.h263_dct_unquantize_inter(block, nCoeffs, qmul, qadd); } @@ -276,6 +251,9 @@ static void gray8(uint8_t *dst, const uint8_t *src, ptrdiff_t linesize, int h) static av_cold void dsp_init(MpegEncContext *s) { ff_blockdsp_init(&s->bdsp); +#if CONFIG_H263DSP + ff_h263dsp_init(&s->h263dsp); +#endif ff_hpeldsp_init(&s->hdsp, s->avctx->flags); ff_videodsp_init(&s->vdsp, s->avctx->bits_per_raw_sample); From patchwork Mon Jul 1 19:13:27 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: 50265 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp2009086vqv; Mon, 1 Jul 2024 12:13:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUI1BYMn+Yx9FPkH/E1PXWH+iGCL7xkGfeC2oKjoYjvRdAWuCpg5finvbHZJeHWPxwSqYK1y6p7wIv9A2d/c/lpRbJvUufnHp4xvw== X-Google-Smtp-Source: AGHT+IHNUUGjE9jPdSYctsSYZuH8oO+0LimPusPF9MvYIyk9MjixVuFRP7i4xBDkFWYP5zbEMHAv X-Received: by 2002:a05:6512:12cc:b0:52c:9e51:c3f with SMTP id 2adb3069b0e04-52e8270fc8fmr4690399e87.42.1719861237810; Mon, 01 Jul 2024 12:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719861237; cv=none; d=google.com; s=arc-20160816; b=P7QpAcvKQGaFWvMOn5uyID2Z7AOQ4NLfOWXKh4+tWA9hYho+DRhvP5glQKii6IK/1U HbVQ8kT15yW6etFOPPGrrpnfEymdiLUaA/0MVLldMcN7HC1aLGNtdbzPkNRB0t9EIu6z tKPs3huV0S5oGuiD8Hh/wyWq/X3ScFKRU11qDJUpk1d0B4rqiIcuH1QwiEeosWgaCk9T nR1WqPKroghdf412w+LaUM2isdX9ZMiRQnExjS1dhgfIhtceuhJbkGKZyvpaDPZNJYmE v5JuUs16gRqny0IwYwzVEXWN33xFWB5IKVx6Jh37YJ/IdUQyuQus/eOzp937KddcTvXS cn9Q== 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=kUqyRWqYY//id+aMFhPa9BTaD2b+XiEIVlk3dvnvhsY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=pTRG5KhDeDF4CKhlzz7LJDeQz9DjERw+NwatYigUTnmavQNdA/wuBBx/EypOg0MJxG Rqyxp2hAudgk3YS/voLAXDTdQUAUnm1pruX4Kf/L/h1F0NZiB1v3ijAFKtDqjgEP3mnv A2f5TG45O69jPH/ICHx8eFa/Suc5+PmV7NuKJnOXVF4VL+caeR3/AeZsTwe0t7a5QE9Z SrV1hry+2mEMFu3sYaPYywpFzfS2niI7m8D1zd4IaX+UcYLUqxiYY2kDnxhv3ac+fNqu kBB3bqoYEBRez74GC4+9EiUU1QrPj4dJCg1wezfMXB9I3F8PIogE/CxnPMKy7BgMQx0z Lp2g==; 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 2adb3069b0e04-52e7ab31ca3si2421624e87.525.2024.07.01.12.13.57; Mon, 01 Jul 2024 12:13:57 -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 7D24A68D84B; Mon, 1 Jul 2024 22:13:38 +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 9AFA768D5BD for ; Mon, 1 Jul 2024 22:13:29 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 3DF1FC02F8 for ; Mon, 1 Jul 2024 22:13:29 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 Jul 2024 22:13:27 +0300 Message-ID: <20240701191328.466433-3-remi@remlab.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240701191328.466433-1-remi@remlab.net> References: <20240701191328.466433-1-remi@remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] checkasm/h263dsp: test dct_unquantize_{intra, inter} 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: EtOFLIR0nBB1 --- tests/checkasm/h263dsp.c | 57 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/tests/checkasm/h263dsp.c b/tests/checkasm/h263dsp.c index 2d0957a90b..26020211dc 100644 --- a/tests/checkasm/h263dsp.c +++ b/tests/checkasm/h263dsp.c @@ -18,13 +18,65 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #include #include "checkasm.h" -#include "libavcodec/h263dsp.h" +#include "libavutil/avassert.h" #include "libavutil/mem.h" #include "libavutil/mem_internal.h" +#include "libavcodec/h263dsp.h" +#include "libavcodec/mpegvideodata.h" + +static uint_fast8_t mpeg_qscale_rnd(void) +{ + int n = rnd(), q = (n >> 1) & 31; + + if (n & 1) + return ff_mpeg2_non_linear_qscale[q]; + else + return q << 1; +} + +typedef void (*unquantizer)(int16_t *, ptrdiff_t, int, int); + +static void check_dct_unquantize(unquantizer func, bool inter) +{ + const char *name = inter ? "inter" : "intra"; +#define LEN 64 + LOCAL_ALIGNED_16(int16_t, block0, [LEN]); + LOCAL_ALIGNED_16(int16_t, block1, [LEN]); + size_t len = rnd() % LEN; + const int qscale = mpeg_qscale_rnd(); + const int qmul = qscale << 1; + const int qadd = (rnd() & 1) ? (qscale - 1) | 1 : 0; + + declare_func(void, int16_t *, ptrdiff_t, int, int); + + for (size_t i = 0; i < LEN; i++) { + int r = rnd(); + + block1[i] = block0[i] = (r & 1) ? (r >> 1) : 0; + } + + if (check_func(func, "h263dsp.dct_unquantize_%s", name)) { + call_ref(block0, 0, qmul, qadd); + call_new(block1, 0, qmul, qadd); + + if (memcmp(block0, block1, LEN * sizeof (int16_t))) + fail(); + + av_assert0(len < LEN); + call_ref(block0, len, qmul, qadd); + call_new(block1, len, qmul, qadd); + + if (memcmp(block0, block1, LEN * sizeof (int16_t))) + fail(); + + bench_new(block1, LEN, qmul, qadd); + } +} typedef void (*filter)(uint8_t *src, int stride, int qscale); @@ -56,6 +108,9 @@ void checkasm_check_h263dsp(void) H263DSPContext ctx; ff_h263dsp_init(&ctx); + check_dct_unquantize(ctx.h263_dct_unquantize_intra, false); + check_dct_unquantize(ctx.h263_dct_unquantize_inter, true); + report("dct_unquantize"); check_loop_filter('h', ctx.h263_h_loop_filter); check_loop_filter('v', ctx.h263_v_loop_filter); report("loop_filter"); From patchwork Mon Jul 1 19:13:28 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: 50266 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp2009163vqv; Mon, 1 Jul 2024 12:14:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWujKfQhiHOv8EVIzC7sRDE/Hj/7+El0Bu0UjWDvR/kHfgQhGgkgiJXqxC17utowgyNkjTiDNUMGNTzpGzGki2ZsHSvR6eC4EgFJA== X-Google-Smtp-Source: AGHT+IGimIwZzbAuviJz97DQWj5qADS06A8gtQk6mx6Z1AkgMtVKz7B41EnSjfJXYCM2Cs7HYBTO X-Received: by 2002:a05:6512:3b11:b0:52c:dbc2:ea1 with SMTP id 2adb3069b0e04-52e82646845mr4367780e87.6.1719861246050; Mon, 01 Jul 2024 12:14:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719861246; cv=none; d=google.com; s=arc-20160816; b=yVJVfEQo8E07dB+USm7QjKnr/sRU4f399jOEnJQD3i9+Kk80/C4BCFncuqdAQOj0DC T2CgpWB0wFwnIemm6FXBAC0sfSmatBt2Nf2dYiSAS2KN+MlSjBioZCRKKBxDAFoz0nkU OgEnMw0z9MuO35wCNyMfSy1FiylIw6PzMwy92kiAjXOOvqIdWDIZns2V9rxKzAwPg3HS 37zhcRP+EFkgCMlJvXtC5JZ8qJgiVldPipX4pY3KESkWpw9G80bgBueNlfU9t3QDpMyd eRJNROIJpPPockJtDBwpRAxxDGzvbZZ3uwFznhvxGCYVpbWc/HVkxuIjDnNnCHP1otWa bqYg== 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=C7fAUt2mrZvWriL1XMuBV2K9//p+E/nHqjgzORfZa+w=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=SFGOs2hDO813DDUovmNxLxNsw/m6x3azvm4PK04PS8c58NbfMSu3GYjhV+uhzftHBz bfyRYUe6hp/r89bbAc69mWoiX/GowEc3XlWIkd4eincaGn1vEtRa1jy+/4HCSYdaHIcg v1uoDQ9mqOV1uJWkEVm0+hTaHZ1UKe0Aw5Ndz2OjYmeENQQ0GyFO5zSIopBS0oD0cMPV htMwn4e+j4JXf3gvS8BRDLGUNrEr4DasemngyD5A7pbeORAGqxDecHnn9KBMLnCsC0eG vTTS493h1+V7vxBRWp1ctlsnO40JHmKRIRqKabhrg/UY5qpNMDw1dvYSjJrhT1LGzrPa jFPg==; 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 2adb3069b0e04-52e7ab0e702si2501213e87.158.2024.07.01.12.14.05; Mon, 01 Jul 2024 12:14:06 -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 D0C0868D851; Mon, 1 Jul 2024 22:13:39 +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 15BB268D72B for ; Mon, 1 Jul 2024 22:13:30 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 6E7F5C02F9 for ; Mon, 1 Jul 2024 22:13:29 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 Jul 2024 22:13:28 +0300 Message-ID: <20240701191328.466433-4-remi@remlab.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240701191328.466433-1-remi@remlab.net> References: <20240701191328.466433-1-remi@remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] lavc/h263dsp: R-V V dct_unquantize_{intra, inter} 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: nAznwZuAxRrs T-Head C908: h263dsp.dct_unquantize_inter_c: 3.7 h263dsp.dct_unquantize_inter_rvv_i32: 1.7 h263dsp.dct_unquantize_intra_c: 4.0 h263dsp.dct_unquantize_intra_rvv_i32: 1.5 SpacemiT X60: h263dsp.dct_unquantize_inter_c: 3.5 h263dsp.dct_unquantize_inter_rvv_i32: 1.2 h263dsp.dct_unquantize_intra_c: 3.5 h263dsp.dct_unquantize_intra_rvv_i32: 1.2 --- libavcodec/riscv/h263dsp_init.c | 15 ++++++++++++--- libavcodec/riscv/h263dsp_rvv.S | 27 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/libavcodec/riscv/h263dsp_init.c b/libavcodec/riscv/h263dsp_init.c index 21b536366c..78d537d1e1 100644 --- a/libavcodec/riscv/h263dsp_init.c +++ b/libavcodec/riscv/h263dsp_init.c @@ -25,6 +25,8 @@ #include "libavutil/riscv/cpu.h" #include "libavcodec/h263dsp.h" +void ff_h263_dct_unquantize_intra_rvv(int16_t *, ptrdiff_t len, int, int); +void ff_h263_dct_unquantize_inter_rvv(int16_t *, ptrdiff_t len, int, int); void ff_h263_h_loop_filter_rvv(uint8_t *src, int stride, int q); void ff_h263_v_loop_filter_rvv(uint8_t *src, int stride, int q); @@ -33,9 +35,16 @@ av_cold void ff_h263dsp_init_riscv(H263DSPContext *c) #if HAVE_RVV int flags = av_get_cpu_flags(); - if ((flags & AV_CPU_FLAG_RVV_I32) && ff_rv_vlen_least(128)) { - c->h263_h_loop_filter = ff_h263_h_loop_filter_rvv; - c->h263_v_loop_filter = ff_h263_v_loop_filter_rvv; + if (flags & AV_CPU_FLAG_RVV_I32) { + if (ff_rv_vlen_least(128) || (flags & AV_CPU_FLAG_RVB_ADDR)) { + c->h263_dct_unquantize_intra = ff_h263_dct_unquantize_intra_rvv; + c->h263_dct_unquantize_inter = ff_h263_dct_unquantize_inter_rvv; + } + + if (ff_rv_vlen_least(128)) { + c->h263_h_loop_filter = ff_h263_h_loop_filter_rvv; + c->h263_v_loop_filter = ff_h263_v_loop_filter_rvv; + } } #endif } diff --git a/libavcodec/riscv/h263dsp_rvv.S b/libavcodec/riscv/h263dsp_rvv.S index 97503d527c..f2b7eb9a87 100644 --- a/libavcodec/riscv/h263dsp_rvv.S +++ b/libavcodec/riscv/h263dsp_rvv.S @@ -20,6 +20,33 @@ #include "libavutil/riscv/asm.S" +func ff_h263_dct_unquantize_intra_rvv, zve32x + addi a0, a0, 2 + j 1f +endfunc + +func ff_h263_dct_unquantize_inter_rvv, zve32x + addi a1, a1, 1 +1: + vsetvli t0, a1, e16, m8, ta, mu + vle16.v v8, (a0) +#if defined(__riscv_v_min_vlen) && __riscv_v_min_vlen < 128 + sub a1, a1, t0 +#endif + vmv.v.x v16, a3 + vmslt.vi v0, v8, 0 + vneg.v v16, v16, v0.t + vmsne.vi v0, v8, 0 + vmadd.vx v8, a2, v16, v0.t + vse16.v v8, (a0) +#if defined(__riscv_v_min_vlen) && __riscv_v_min_vlen < 128 + sh1add a0, t0, a0 + bnez a1, 1b +#endif + + ret +endfunc + .option push .option norelax func ff_h263_h_loop_filter_rvv, zve32x