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;