From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id E35264F187 for ; Fri, 20 Feb 2026 19:10:15 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'RqKgxqq4+nv9NB+y5RTlrPzDqR0X1i8O7YC6WoiPQW0=', expected b'/USKQErQDvIRk0FYZdkcn51TAbx4BVhhJHW0whl5uzE=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771614586; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=RqKgxqq4+nv9NB+y5RTlrPzDqR0X1i8O7YC6WoiPQW0=; b=VK9DnZiO0ABkv3Y3RCRPQvUtHsUVSkNBkbdsMJf4IvOwudHS8uCw8DScR1TAhFLI0gaZV mHhwtSdZEPSag9uZE4EtFABauYy7nbBx++z/c6KrKiEX75Wof3Ulxd3h24Hg1zyVA0Y1cmU gEo/Babw5QoPAcWRnd2VBLm8z8zZQbazPPXaELAr7WK66zs6LQPBuaUujY4yAKdYWHHd195 k8FmnUD+ddzUGBmyzVrtrXVDNzrfkM825/lhlJTXzxyKRPfi4If2MAYfnctMwjXXdC/IrtW QEwdUattz/R7BIavqzAVWvdqZSs+p53AF8tB5geqXNbEplm0rBqYub5ONMZw== Received: from [172.18.0.3] (unknown [172.18.0.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 740B96911DA; Fri, 20 Feb 2026 21:09:46 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1771614574; b=LqIfY0W7ml2INRitb3j0+f28gzzl2LeGoqocVtLKMJ/Og/aME8rHawNu6DfjJjcQWiOBm UC0GyykT6e81Olw7FCUEN22pxEDDEIvPvsh3hMuFBD91sMSC/WX7nZ8L4LszUIYhGDgii4V mi6nydaSmKqWbxa4rSQmZ6XTwyPmbIxqsIl9UsI7sPSDv2VJE6Q0S+y8HAyD83JRT0RktiK u/EQ+6w5/rqBvtuqt4uuizhn1ppa/brAAyjGfvzdmHX0lH5y95dTh1vXs8pbyEQpNZeYsVc 6DehPa5fHhz5BP2qbK0QwW+K86FxYNVR9bLEqW6kkTRjU69ipRp4F6IokOyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1771614574; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=sKz+rm8isN3QMaM2tQW+O7WjCjnHOdCkJyH+AgUZp4I=; b=tXOTs0eoeNsNNvMwMjClW54CbLRdOPM7jWCM/44pyn00tkOygM2WPto5k8x3GwNDxmium g43fN6/84P+wzrFOfrJYBdHH6kjngCUym9t3GbbjNsWqP6cSOwyOddCpSUlkkXBraY9i00J iCgZKotkhOLnyM7/p49OEFKHGqUKncTMcxqVnC2JsYVo2zZFnk9JWf08u61Kbf6QS4QtlVu VGcHKRYlGfOT9SLNzezrlNvv5IaRZtOUWcjUA06BelKhbhYhV9BkDH8nMMEC3er6dFIRd/C 2UCjb2WmABAtf71wpRFJTU0j5U1VF4u3TCvcUz53wD2CcVjdNUrQnW7seMMw== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771614563; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=/USKQErQDvIRk0FYZdkcn51TAbx4BVhhJHW0whl5uzE=; b=HH7GVKQ/u11XVl0qMx4lLP7UBkhS+wa9TlhiFUtMgsOij90kvKBidUXWXCUvLrKuAmqQU 4EVPJF/KXL/JVJ+Oujl+7/XtaXJ0z6Fq9bttQMYPYXaspl86MbKou5YcI1ngR3WDGFvOYpt VH6YWp14yxjtY3x+BwNQOt8ThuMRlf0iK1xxa44iFyGFXoXTLF6ZsgkSwb+8+CfKAj90v4z E2rExUo5fbr/q076eV69G8n9MP6kr/AO+sfTkYvpRT3AL3zx2A7VtnfifzIdSorO1Ocy1Dm HMJnSUIROu5E3FEuak3LF03gccrn2X6uiM/80T39uH1u6jb98XFCwbtt2MrA== MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Feb 2026 19:09:23 -0000 Message-ID: <177161456403.25.15604846861356495344@29965ddac10e> Message-ID-Hash: PTQ5J6VSWNOWWG5FYK75244IESS7FQFZ X-Message-ID-Hash: PTQ5J6VSWNOWWG5FYK75244IESS7FQFZ X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PR] avcodec/vvc/inter: Remove always-false/true checks, deduplicate applying averaging (PR #22232) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: mkver via ffmpeg-devel Cc: mkver Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #22232 opened by mkver URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22232 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22232.patch Further improvements will have to wait for #21790. >>From 97b68f56bcc5e07e4ba7e7815a5a74c93830b8aa Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 20 Feb 2026 19:49:38 +0100 Subject: [PATCH 1/3] avcodec/vvc/inter: Remove always-false/true checks derive_weight() is only called when pred_flag is PF_BI, which only happens in B slices. Signed-off-by: Andreas Rheinhardt --- libavcodec/vvc/inter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c index 64a9dd1e46..98997837ae 100644 --- a/libavcodec/vvc/inter.c +++ b/libavcodec/vvc/inter.c @@ -224,8 +224,8 @@ static int derive_weight(int *denom, int *w0, int *w1, int *o0, int *o1, const VVCPPS *pps = fc->ps.pps; const VVCSH *sh = &lc->sc->sh; const int bcw_idx = mvf->bcw_idx; - const int weight_flag = (IS_P(sh->r) && pps->r->pps_weighted_pred_flag) || - (IS_B(sh->r) && pps->r->pps_weighted_bipred_flag && !dmvr_flag); + av_assert2(IS_B(sh->r)); + const int weight_flag = pps->r->pps_weighted_bipred_flag && !dmvr_flag; if ((!weight_flag && !bcw_idx) || (bcw_idx && lc->cu->ciip_flag)) return 0; -- 2.52.0 >>From fa7d8b976ee44ebd347b39c3fbbb85cdbcd29bb1 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 20 Feb 2026 19:51:42 +0100 Subject: [PATCH 2/3] avcodec/vvc/inter: Remove redundant variable, fix shadowing Signed-off-by: Andreas Rheinhardt --- libavcodec/vvc/inter.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c index 98997837ae..c259414f56 100644 --- a/libavcodec/vvc/inter.c +++ b/libavcodec/vvc/inter.c @@ -235,7 +235,6 @@ static int derive_weight(int *denom, int *w0, int *w1, int *o0, int *o1, *w0 = 8 - *w1; *o0 = *o1 = 0; } else { - const VVCPPS *pps = fc->ps.pps; const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt; *denom = w->log2_denom[c_idx > 0]; -- 2.52.0 >>From 9ce7420a9fc1d93d64b66be48b9d74eecfa8d6d1 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 20 Feb 2026 20:02:01 +0100 Subject: [PATCH 3/3] avcodec/vvc/inter: Deduplicate applying averaging Signed-off-by: Andreas Rheinhardt --- libavcodec/vvc/inter.c | 56 +++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c index c259414f56..85e0665a75 100644 --- a/libavcodec/vvc/inter.c +++ b/libavcodec/vvc/inter.c @@ -217,8 +217,9 @@ static int derive_weight_uni(int *denom, int *wx, int *ox, } // part of 8.5.6.6 Weighted sample prediction process -static int derive_weight(int *denom, int *w0, int *w1, int *o0, int *o1, - const VVCLocalContext *lc, const MvField *mvf, const int c_idx, const int dmvr_flag) +static void apply_averaging(uint8_t *dst, const ptrdiff_t dst_stride, + const int16_t *src0, const int16_t *src1, int width, int height, + const VVCLocalContext *lc, const MvField *mvf, const int c_idx, const int dmvr_flag) { const VVCFrameContext *fc = lc->fc; const VVCPPS *pps = fc->ps.pps; @@ -226,24 +227,27 @@ static int derive_weight(int *denom, int *w0, int *w1, int *o0, int *o1, const int bcw_idx = mvf->bcw_idx; av_assert2(IS_B(sh->r)); const int weight_flag = pps->r->pps_weighted_bipred_flag && !dmvr_flag; - if ((!weight_flag && !bcw_idx) || (bcw_idx && lc->cu->ciip_flag)) - return 0; + if ((!weight_flag && !bcw_idx) || (bcw_idx && lc->cu->ciip_flag)) { + fc->vvcdsp.inter.avg(dst, dst_stride, src0, src1, width, height); + return; + } + int denom, w0, w1, o1, o2; if (bcw_idx) { - *denom = 2; - *w1 = bcw_w_lut[bcw_idx]; - *w0 = 8 - *w1; - *o0 = *o1 = 0; + denom = 2; + w1 = bcw_w_lut[bcw_idx]; + w0 = 8 - w1; + o1 = o2 = 0; } else { const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt; - *denom = w->log2_denom[c_idx > 0]; - *w0 = w->weight[L0][c_idx][mvf->ref_idx[L0]]; - *w1 = w->weight[L1][c_idx][mvf->ref_idx[L1]]; - *o0 = w->offset[L0][c_idx][mvf->ref_idx[L0]]; - *o1 = w->offset[L1][c_idx][mvf->ref_idx[L1]]; + denom = w->log2_denom[c_idx > 0]; + w0 = w->weight[L0][c_idx][mvf->ref_idx[L0]]; + w1 = w->weight[L1][c_idx][mvf->ref_idx[L1]]; + o1 = w->offset[L0][c_idx][mvf->ref_idx[L0]]; + o2 = w->offset[L1][c_idx][mvf->ref_idx[L1]]; } - return 1; + fc->vvcdsp.inter.w_avg(dst, dst_stride, src0, src1, width, height, denom, w0, w1, o1, o2); } #define INTER_FILTER(t, frac) (is_chroma ? ff_vvc_inter_chroma_filters[t][frac] : ff_vvc_inter_luma_filters[t][frac]) @@ -320,8 +324,6 @@ static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, const int idx = av_log2(block_w) - 1; const VVCFrame *refs[] = { ref0, ref1 }; int16_t *tmp[] = { lc->tmp + sb_bdof_flag * PROF_TEMP_OFFSET, lc->tmp1 + sb_bdof_flag * PROF_TEMP_OFFSET }; - int denom, w0, w1, o0, o1; - const int weight_flag = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, c_idx, pu->dmvr_flag); const int is_chroma = !!c_idx; const int hpel_if_idx = is_chroma ? 0 : pu->mi.hpel_if_idx; @@ -352,10 +354,9 @@ static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, } if (sb_bdof_flag) fc->vvcdsp.inter.apply_bdof(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h); - else if (weight_flag) - fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1); else - fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h); + apply_averaging(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, + lc, mvf, c_idx, pu->dmvr_flag); } static const int8_t* inter_filter_scaled(const int scale, const int is_chroma, const int is_affine) @@ -468,9 +469,6 @@ static void mc_bi_scaled(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_ const VVCRefPic *refp0, const VVCRefPic *refp1, const MvField *mvf, const int x_off, const int y_off, const int block_w, const int block_h, const int c_idx) { - int denom, w0, w1, o0, o1; - const VVCFrameContext *fc = lc->fc; - const int weight_flag = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, c_idx, lc->cu->pu.dmvr_flag); const VVCRefPic *refps[] = { refp0, refp1 }; int16_t *tmp[] = { lc->tmp, lc->tmp1 }; @@ -483,10 +481,8 @@ static void mc_bi_scaled(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_ else mc(lc, tmp[i], refp->ref, mv, x_off, y_off, block_w, block_h, c_idx); } - if (weight_flag) - fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1); - else - fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h); + apply_averaging(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, + lc, mvf, c_idx, lc->cu->pu.dmvr_flag); } static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, @@ -560,11 +556,8 @@ static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_ const VVCRefPic *ref0, const VVCRefPic *ref1, const MvField *mvf, const int x_off, const int y_off, const int block_w, const int block_h) { - const VVCFrameContext *fc = lc->fc; const VVCRefPic *refps[] = { ref0, ref1 }; int16_t *tmp[] = { lc->tmp, lc->tmp1 }; - int denom, w0, w1, o0, o1; - const int weight_flag = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, LUMA, 0); for (int i = L0; i <= L1; i++) { const VVCRefPic *refp = refps[i]; @@ -576,10 +569,7 @@ static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_ luma_prof(lc, tmp[i], refp->ref, mv, x_off, y_off, block_w, block_h, i); } - if (weight_flag) - fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1); - else - fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h); + apply_averaging(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, lc, mvf, LUMA, 0); } static int pred_get_refs(const VVCLocalContext *lc, VVCRefPic *refp[2], const MvField *mv) -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org