From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 34FE84BA54 for ; Thu, 1 May 2025 14:47:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 52C4468BC6F; Thu, 1 May 2025 17:44:19 +0300 (EEST) Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 14A7868BABF for ; Thu, 1 May 2025 17:44:11 +0300 (EEST) Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-af548cb1f83so1075887a12.3 for ; Thu, 01 May 2025 07:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746110650; x=1746715450; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eCNXVH4a+/Y6DMdfWrO8Elfp6RrT54kHYL3FYkVWsFk=; b=DQ1cr/9zRVLl2bwR9seVKrAjbW/KSWX/ORcHYY0+eOfVAuzjsXygZsJRelXzFRDokI ijnkV2y4jJqOFiE2VnSJRprPcVGHSzPpukSgq3PmNq4UgpYSK4fi/bFG5frErX4/llCr 80aY7q5kbMN256tprxoQ+DMt4nw4d8pQJoK9TYqh/sZ8ZBWsAotODILyy+1gAXNKTKr+ 6ADMQ/FkqfUwAdrGl2c7Em1v/QTP/yOV6oPBqM/scGcJf8tiEtKtv53wg04UlBj4Yma3 1bstekQlpP4obLFj0N4PCmvyLnyxIUxDJ6IckjlACIb42jCnLE2JOEtXTNd4gdsMk1LY 0jNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746110650; x=1746715450; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eCNXVH4a+/Y6DMdfWrO8Elfp6RrT54kHYL3FYkVWsFk=; b=Q8x2EfR+FlJx4MLzxX0/yp3Xwn+U2gOLdg/MYqhbENy7lKPiH2NZwX1DUsfQ2vlabJ nbJ1m1blnZNDbFAFDNCklwU+cUcRk0T43NJ679dTf5VHdZlnclDdjySkMyBFYBGT4vNy WUWrm45TyEmg0otLiswwpgNVbTXecn1kKeTEeEgW0hWU/iUP4cOT8DexM0qJnGizPqmE d7LdNZC2liZwj+zcxS1UPmepvtfUYF8Nfh05l7Gw4GGraHBvDbRrtrdUQvT9uJ8gG+td ap/4oUCuUJ5x3nQ9yv2rEuA1p6sE4B+P3k/kBQUniUP7UklDzQHpPC3U7bSPXPVN6zVv BIAw== X-Gm-Message-State: AOJu0YzMbe3t1EcyzChJlk3hfc8wrG1aQEsdJEMGQ6qm72Dx3JumrTw/ 9shrNfx+4/zuPoXQK2WrCks6swkjGS2Jxu+h+1jo8dKcbH3AxQ0ym4WAzA== X-Gm-Gg: ASbGncuj/HlK5JHjIa/7qoD1mtWqviMsNh16/IAKTOVmB2RbaO9HvPcN+EVoGXdfRUB 0SHL502rex7RLiCZOukom2PD2fROIo+vC4U6VcTMOcCve5MKefn5E9MT7YljhpjXS0c6zjwGtBJ EVkCBpDWCun6bGC++RngD74x5S1XIMekmprzUnms8iu7U8aK+T9yZPHXCYZ6pHE9nl1DWkXv10r DtpjBfuxRDMMFnZIqKeq6zy/iRTtsPlFkCWxX6a84ZQYO379+iUWd0apKjEAE8WXpm8xQ3W0BNY mwS0Jj5ZaHkZbxGmQbVOOX6Dld/2cVpwyQGpZDA5aE0MF02biZW8Ude9sDsTyg== X-Google-Smtp-Source: AGHT+IESWG67PLNQsxAl1EzCjMfbKL8ufsE64mEd4H3Ps/eN7ua4DU1z0xb/HEUt+QnlizImwMxFmQ== X-Received: by 2002:a05:6a20:d526:b0:1f5:8a1d:3904 with SMTP id adf61e73a8af0-20aa26d41b1mr10290662637.7.1746110650038; Thu, 01 May 2025 07:44:10 -0700 (PDT) Received: from localhost.localdomain ([124.79.129.75]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b1f9d4b68e8sm807271a12.27.2025.05.01.07.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 May 2025 07:44:09 -0700 (PDT) From: toqsxw@gmail.com X-Google-Original-From: toqsxw@outlook.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 1 May 2025 22:43:17 +0800 Message-ID: <20250501144324.958-19-toqsxw@outlook.com> X-Mailer: git-send-email 2.44.0.windows.1 In-Reply-To: <20250501144324.958-1-toqsxw@outlook.com> References: <20250501144324.958-1-toqsxw@outlook.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 19/23] avcodec/vvc/intra: refact, predict jcbcr to tb->coeffs 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 Cc: Wu Jianhua Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Wu Jianhua prepare for adaptive color transform Signed-off-by: Wu Jianhua --- libavcodec/vvc/dsp.h | 1 - libavcodec/vvc/dsp_template.c | 18 ------------- libavcodec/vvc/intra.c | 51 ++++++++++++++--------------------- 3 files changed, 20 insertions(+), 50 deletions(-) diff --git a/libavcodec/vvc/dsp.h b/libavcodec/vvc/dsp.h index e9ef9f5b25..fa1387aadd 100644 --- a/libavcodec/vvc/dsp.h +++ b/libavcodec/vvc/dsp.h @@ -122,7 +122,6 @@ typedef struct VVCIntraDSPContext { typedef struct VVCItxDSPContext { void (*add_residual)(uint8_t *dst, const int *res, int width, int height, ptrdiff_t stride); - void (*add_residual_joint)(uint8_t *dst, const int *res, int width, int height, ptrdiff_t stride, int c_sign, int shift); void (*pred_residual_joint)(int *dst, const int *src, int width, int height, int c_sign, int shift); void (*itx[VVC_N_TX_TYPE][VVC_N_TX_SIZE])(int *coeffs, ptrdiff_t step, size_t nz); diff --git a/libavcodec/vvc/dsp_template.c b/libavcodec/vvc/dsp_template.c index 218a600cce..13bd8cd4a1 100644 --- a/libavcodec/vvc/dsp_template.c +++ b/libavcodec/vvc/dsp_template.c @@ -45,23 +45,6 @@ static void FUNC(add_residual)(uint8_t *_dst, const int *res, } } -static void FUNC(add_residual_joint)(uint8_t *_dst, const int *res, - const int w, const int h, const ptrdiff_t _stride, const int c_sign, const int shift) -{ - pixel *dst = (pixel *)_dst; - - const int stride = _stride / sizeof(pixel); - - for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) { - const int r = ((*res) * c_sign) >> shift; - dst[x] = av_clip_pixel(dst[x] + r); - res++; - } - dst += stride; - } -} - static void FUNC(pred_residual_joint)(int *dst, const int *src, const int w, const int h, const int c_sign, const int shift) { @@ -121,7 +104,6 @@ static void FUNC(ff_vvc_itx_dsp_init)(VVCItxDSPContext *const itx) VVC_ITX(TYPE, type, 32); itx->add_residual = FUNC(add_residual); - itx->add_residual_joint = FUNC(add_residual_joint); itx->pred_residual_joint = FUNC(pred_residual_joint); itx->transform_bdpcm = FUNC(transform_bdpcm); VVC_ITX(DCT2, dct2, 2) diff --git a/libavcodec/vvc/intra.c b/libavcodec/vvc/intra.c index 5f9bbea3d1..3db3347d8c 100644 --- a/libavcodec/vvc/intra.c +++ b/libavcodec/vvc/intra.c @@ -164,28 +164,6 @@ static void derive_transform_type(const VVCFrameContext *fc, const VVCLocalConte *trv = mts_to_trv[cu->mts_idx]; } -static void add_residual_for_joint_coding_chroma(VVCLocalContext *lc, - const TransformUnit *tu, TransformBlock *tb, const int chroma_scale) -{ - const VVCFrameContext *fc = lc->fc; - const CodingUnit *cu = lc->cu; - const int c_sign = 1 - 2 * fc->ps.ph.r->ph_joint_cbcr_sign_flag; - const int shift = tu->coded_flag[1] ^ tu->coded_flag[2]; - const int c_idx = 1 + tu->coded_flag[1]; - const ptrdiff_t stride = fc->frame->linesize[c_idx]; - const int hs = fc->ps.sps->hshift[c_idx]; - const int vs = fc->ps.sps->vshift[c_idx]; - uint8_t *dst = &fc->frame->data[c_idx][(tb->y0 >> vs) * stride + - ((tb->x0 >> hs) << fc->ps.sps->pixel_shift)]; - if (chroma_scale) { - fc->vvcdsp.itx.pred_residual_joint(tb->coeffs, tb->coeffs, tb->tb_width, tb->tb_height, c_sign, shift); - fc->vvcdsp.intra.lmcs_scale_chroma(lc, tb->coeffs, tb->coeffs, tb->tb_width, tb->tb_height, cu->x0, cu->y0); - fc->vvcdsp.itx.add_residual(dst, tb->coeffs, tb->tb_width, tb->tb_height, stride); - } else { - fc->vvcdsp.itx.add_residual_joint(dst, tb->coeffs, tb->tb_width, tb->tb_height, stride, c_sign, shift); - } -} - static int add_reconstructed_area(VVCLocalContext *lc, const int ch_type, const int x0, const int y0, const int w, const int h) { const VVCSPS *sps = lc->fc->ps.sps; @@ -531,7 +509,7 @@ static void itransform(VVCLocalContext *lc, TransformUnit *tu, const int tu_idx, const ptrdiff_t stride = fc->frame->linesize[c_idx]; const int hs = sps->hshift[c_idx]; const int vs = sps->vshift[c_idx]; - uint8_t *dst = &fc->frame->data[c_idx][(tb->y0 >> vs) * stride + ((tb->x0 >> hs) << ps)]; + const int has_jcbcr = tu->joint_cbcr_residual_flag && c_idx; if (cu->bdpcm_flag[tb->c_idx]) transform_bdpcm(tb, lc, cu); @@ -548,14 +526,25 @@ static void itransform(VVCLocalContext *lc, TransformUnit *tu, const int tu_idx, itx_1d(fc, tb, trh, trv); } - if (chroma_scale) - fc->vvcdsp.intra.lmcs_scale_chroma(lc, temp, tb->coeffs, w, h, cu->x0, cu->y0); - // TODO: Address performance issue here by combining transform, lmcs_scale_chroma, and add_residual into one function. - // Complete this task before implementing ASM code. - fc->vvcdsp.itx.add_residual(dst, chroma_scale ? temp : tb->coeffs, w, h, stride); - - if (tu->joint_cbcr_residual_flag && tb->c_idx) - add_residual_for_joint_coding_chroma(lc, tu, tb, chroma_scale); + for (int j = 0; j < 1 + has_jcbcr; j++) { + const bool is_jcbcr = j > 0; + const int jcbcr_idx = CB + tu->coded_flag[CB]; + TransformBlock *jcbcr = &tu->tbs[jcbcr_idx - tu->tbs[0].c_idx]; + const int c = is_jcbcr ? jcbcr_idx : tb->c_idx; + int *coeffs = is_jcbcr ? jcbcr->coeffs : tb->coeffs; + uint8_t *dst = &fc->frame->data[c][(tb->y0 >> vs) * stride + ((tb->x0 >> hs) << ps)]; + + if (!j && has_jcbcr) { + const int c_sign = 1 - 2 * fc->ps.ph.r->ph_joint_cbcr_sign_flag; + const int shift = tu->coded_flag[CB] ^ tu->coded_flag[CR]; + fc->vvcdsp.itx.pred_residual_joint(jcbcr->coeffs, tb->coeffs, tb->tb_width, tb->tb_height, c_sign, shift); + } + if (chroma_scale) + fc->vvcdsp.intra.lmcs_scale_chroma(lc, temp, coeffs, w, h, cu->x0, cu->y0); + // TODO: Address performance issue here by combining transform, lmcs_scale_chroma, and add_residual into one function. + // Complete this task before implementing ASM code. + fc->vvcdsp.itx.add_residual(dst, chroma_scale ? temp : coeffs, w, h, stride); + } } } } -- 2.44.0.windows.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".