From patchwork Sun May 19 13:27:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuo Mi X-Patchwork-Id: 49011 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp3924653pzb; Sun, 19 May 2024 06:42:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW/cQJOm2rie5kahdkajBLRmfCX868FOuVuLqhdv2N7vgYfjVeZjFGPU8anismgBKbvt6kQDhkPnNGX5tkEcVfG7Kz+i1O4i/N/hA== X-Google-Smtp-Source: AGHT+IFa+K1FEjOgMrghBdYiAtynHx6kKBqs40SY1PSq9xMwbrA+w5t00A62TtPWmOoPorsyeSto X-Received: by 2002:a50:c30e:0:b0:575:a7e:4f82 with SMTP id 4fb4d7f45d1cf-5752b3f8acbmr3640525a12.4.1716126135110; Sun, 19 May 2024 06:42:15 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5769313c713si998493a12.368.2024.05.19.06.42.13; Sun, 19 May 2024 06:42:15 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=EjlkHFR1; arc=fail (body hash mismatch); 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6802468D2FE; Sun, 19 May 2024 16:40:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from SINPR02CU002.outbound.protection.outlook.com (mail-southeastasiaazolkn19011003.outbound.protection.outlook.com [52.103.65.3]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9150E68CF47 for ; Sun, 19 May 2024 16:39:59 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ng1Ya2vbT8xkRmNq9Ds70t9uXoKTAIj7TROfllQSXKm6RUU9kZBPGC0ST4uygghCzbPlyC+2jmLILkciHMAaMZUekVxJr2EHOCjXG01EJ9IRzh0HjYjdcQBrzQ6WyQ7a3ac6M//Sf7uNy37/pCMQlKcIAbJmnKCFLIfgKhLRRq2V73N7NTQ6J1fuez54pEy04p75EB+y99j2rQSOptjwLhBVqJpcfAiTfuXA957bsG3E1lSLLrmYfvqpa2+RjW5hDVGOoDWnS8+nZ5+vzIDYBIxLWUZU2/2feZUwZRMvPyZjfdi+caK78e13Gn0J/BiivSUu9aaX9v+j3VxG19/k0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aYKToz1Canh2CkfUNSHTfgzyrO4r/4ePZdr2i5IEqgw=; b=Awj/zMFdVrQ6wevWB89DYBHX+RWew4CKMBQqjIMlYQQ70NhNn8Tp+I2UFYUwjhrn28kgTg+lZ+rQZvwUb560N9G2rrqPdbMglF0bEMyhGPhicVgduUzhj0uCo56/W8wz8cEY2bMuViSMuKSV9J2QBxL78iXie1CpT8Kn1hrXu7sF1zqQoS8uU14rqzQ+pIjKZcwA/IJIGVL3B+gPIB5pMblrsNE+O5w0Abk3IFRfuMy6CFTMLzFkiwybxVX+iLYfHr/Fw4pHb4KzzCD7HZXt+U8IXRnsiT6+FfqGAkIbX9FSo4Kp62qCrTqGxwcyfKbyqjS3+VTuOWeiLG8rZSW4cA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aYKToz1Canh2CkfUNSHTfgzyrO4r/4ePZdr2i5IEqgw=; b=EjlkHFR1TryBGsKvJZ+OmqS+OKiWYhPUFyRvSPQbZrplTZBZjgn5qBUDUS00QOaISJAPEdoiM/43DhdCBNqWR8fy6is+cQixdkk0s+f2/sRzGD+6pnA0lnNmYlv6drI13Z4jg5MGyr5b1uDhytV/x0eQ4jqZT67Im8iMpbE3IduDY8aHpnLg7sJSXiE9neQ2yUlLuSRw7oqfHiZlQDVD6nBn6wTiOlQPl7Lp6vsO8I74e7sn7AGZyuA/jWjSrUQ8/XRslLQ06pmgWKSRbyq+XAufSYeBN+aLRplP8XXOfd8pSQWAhh/nq346rtrPXFul7VdGbkPlIbbQdT8W2gczTQ== Received: from TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) by TYUPR06MB6098.apcprd06.prod.outlook.com (2603:1096:400:358::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.34; Sun, 19 May 2024 13:39:45 +0000 Received: from TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::81f7:9125:583a:1cca]) by TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::81f7:9125:583a:1cca%4]) with mapi id 15.20.7587.030; Sun, 19 May 2024 13:39:45 +0000 From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 May 2024 21:27:48 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240519132749.790832-1-nuomi2021@gmail.com> References: <20240519132749.790832-1-nuomi2021@gmail.com> X-TMN: [Zb50zfONj3TRmC4gDKUW6agF6vipAp0D] X-ClientProxiedBy: TYCP301CA0017.JPNP301.PROD.OUTLOOK.COM (2603:1096:400:381::8) To TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) X-Microsoft-Original-Message-ID: <20240519132749.790832-17-nuomi2021@gmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6433:EE_|TYUPR06MB6098:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e48cc52-4984-4ec8-94ee-08dc78092547 X-Microsoft-Antispam: BCL:0; ARA:14566002|461199019|440099019|3412199016|1710799017; X-Microsoft-Antispam-Message-Info: XSNf+1SULDh85vrCMysB6fQUd6YsLIvEkf3vA3vUMe992qIEmfr6qsETcNXvYhLvTomZkOZRHTUaF7aI5ds44SDfGUBiKtxLWhrgJ3G1bbDlS5aX60SQa6CX1lyGqclT9aKDSAIJewdHuCfI+FGAAkUR+pRPSioaGyT+OHi7G2eKCy9QpH5q7VrPQFU6e+NCDX3q/DtJ42IzfRXpdBfxA+ajFEwzn9G7By/ekX16oMYSD3p7MYAx429ACWVU4JUuQyDiUvgTE2+j0L2nz0Fr2YeJdSCUnknclJWKGy5mbHLEhgSlZYt5E+BYHoiUe9UADUZ3iSlbDwfXAwmScJh+QSKUGK/SWvGj7LCYWUAOsHzPVyf1FS6SZzIR4DCqRD0vc3W6bvGRqxy7e7tDjrvGDqU7cCSvJlaJveIswoZ3PD8ZG3FMCOjVZjWyBG32SPAqiUsTeRnh/oLfAn1eAztlAgeCrrgW+jih4uFqf2v8gTKLUKRcAjbsfUG8bSh6Qk0paNc24vPUar3PTgcVt6KiUrl85yPCwGMByevzoePbL/+p3wrmLPA9wICVWUwMiqWDLp/sFlebbNPryG8MH7S2uPcteUGxxG0FVDJS5lo8UoeB6pVRPatXKxN/zo+dm2jV X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kLxNV2CkW8hqr/BSYDnyEr0VMO43/HYYa1U2v4gxS9ly12LIdKnwOYzww7zt7Kk46KtNLtetHVfXmxbuczzpHqZoClgF4OUz3tUO63c62juIJnUIFQ3C7lJjhxwKJt3QSbl6qSpUfvddTc/MQCIbTPutP4/X8cjnxnIUSdCXqee5UlmiDQlNX8PGEgMYa5r/JZatF64RjewJuZV8j1L7D4BwvFbLM7Hb+AC+dWCfgbBaQX6kBO/yeejAneOH5zdIRmKcWCG1BwkXF1pJxKZHHKOl7SxNpGNz0IiVX9RlNtDsbBPtmlZahad9wRtXSmSEAZTKTUIfDDv9kQBEzpZJp7GeaH1B+Z//QBxerF2XpeWOmi2v6eUvoaxtvj8iU/lojykM/HmaZck0+UK5SYFQJT9+yJr7MTs9IFWKUboopeANI1TJOQ5srR19D8atPXnGYAWrKgt/ntecnkrGO0XTJAJf+XwPmms7aXGg9mWhWJDU/69SZ2ZVbH8h1ORXij2a3RtuzbXblfUwoF2jTHW4/UcR9q/zXruZ6+UiQ8ewEoW+oSodlswMEquX/I3JZ8Br7O0LGt2xYU62ksetiMPa5XTZxZkT8bxN8sG40zvEq0Qu3UyexaPn1oAXzsSBPy96AvZlzBHUjJ3CBAGye4l3PL5tn8upiNIq2ZEalDBtOWsViUD4K/jubF2bHCC2TutBe212AWNlf/DRA4VCMRukpIwWvoP/uJ2a1lbckNuQB1kxLCUa82sRbH8MbUHR2MPWlTFQu46/3W/eEKcs6SuuJZDRnl1BJY7O55p6COkmCo5MyqRgCfBclzNaPUWUkMxN5q1UYbNDaRu12O+0dtM26jm9ydpKP5w2iXSdvAAxsghyBC1YeLAMCQD9tJpxWJ7dZYncYywv8sxv4zFFK6kedweTmCmEeUzPEv/HI3rCn7RXPnCgWgBfb3p33eaGhV54wfa/DWj3gOt3Qq2+/iZKpvT2unvPTn943fV7blb3mlEYEgutP5KF4N0R3xA7t5vmB5GrbGJmE9FAAGY5HbXHIbHloQo+dBrLIr7gGYwEVmuPXhXuOSbkTh/7ebfcsrRqD6l58hSfjA04zN5dYI5TxTwmnlzys7hzcjw2rZkdUr85o3dHhC0pYxR4OkKSR+kwBcVj0LH7f/gz98tbgAi6Us4OX2Nj6HvLA1wr+GT6LtdRpxD8Szfc/Wp6ChlRyds1dh77IA/GWB/tc+fB9OfemaQo4QQLJFPhKBbj0xXlmaedMZ6vs/wXegTLLqkB6XhwnM92nI6RtT0Z5hM1a5BQAQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e48cc52-4984-4ec8-94ee-08dc78092547 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6433.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2024 13:39:45.7135 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYUPR06MB6098 Subject: [FFmpeg-devel] [PATCH 17/18] avcodec/vvcdec: support Reference Picture Resampling 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: Nuo Mi Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Wk/ucphZHJwd passed clips: RPR_A_Alibaba_4.bit RPR_B_Alibaba_3.bit RPR_C_Alibaba_3.bit RPR_D_Qualcomm_1.bit VVC_HDR_UHDTV1_OpenGOP_Max3840x2160_50fps_HLG10_res_change_with_RPR.ts --- libavcodec/vvc/inter.c | 190 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 173 insertions(+), 17 deletions(-) diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c index 5d553708d9..e1011b4fa1 100644 --- a/libavcodec/vvc/inter.c +++ b/libavcodec/vvc/inter.c @@ -313,6 +313,141 @@ static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h); } +static const int8_t* inter_filter_scaled(const int scale, const int is_chroma, const int is_affine) +{ +#define SCALE_THRESHOLD_1 20480 +#define SCALE_THRESHOLD_2 28672 + + const int i = (scale > SCALE_THRESHOLD_2) + (scale > SCALE_THRESHOLD_1); + + if (!is_chroma) { + if (!is_affine) + return &ff_vvc_inter_luma_filters[i + !!i][0][0]; //hpel 1 is not needed for scaled + return &ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE + i][0][0]; + } + + return &ff_vvc_inter_chroma_filters[i][0][0]; +} +#define INTER_FILTER_SCALED(scale) inter_filter_scaled(scale, is_chroma, is_affine) + +#define SCALED_CHROMA_ADDIN(scale, collocated_flag) (is_chroma ? (collocated_flag ? 0 : 8 * (scale - (1 << 14))) : 0) +#define SCALED_REF_SB(off, scaling_off, ref_mv, scale, add, shift) ((((off - (scaling_off << shift)) << (4 + shift)) + ref_mv) * scale + add) +#define SCALED_REF(ref_sb, offset, shift) (FFSIGN(ref_sb) * ((FFABS(ref_sb) + (128 << is_chroma)) >> (8 + is_chroma)) + (offset << (10 - shift)) + (32 >> is_chroma)) +#define SCALED_STEP(scale) ((scale + 8) >> 4) + +static void scaled_ref_pos_and_step(const VVCLocalContext *lc, const VVCRefPic *refp, const Mv *mv, const int x_off, const int y_off, const int c_idx, + int *x, int *y, int *dx, int *dy) +{ + const VVCFrameContext *fc = lc->fc; + const VVCSPS *sps = fc->ps.sps; + const int is_chroma = !!c_idx; + const int hs = sps->hshift[c_idx]; + const int vs = sps->vshift[c_idx]; + const int left_offset = fc->ref->scaling_win.left_offset; + const int top_offset = fc->ref->scaling_win.top_offset; + const int addx = SCALED_CHROMA_ADDIN(refp->scale[0], sps->r->sps_chroma_horizontal_collocated_flag); + const int addy = SCALED_CHROMA_ADDIN(refp->scale[1], sps->r->sps_chroma_vertical_collocated_flag); + const int refx_sb = SCALED_REF_SB(x_off, left_offset, mv->x, refp->scale[0], addx, hs); + const int refy_sb = SCALED_REF_SB(y_off, top_offset, mv->y, refp->scale[1], addy, vs); + + *x = SCALED_REF(refx_sb, left_offset, hs); + *y = SCALED_REF(refy_sb, top_offset, vs); + *dx = SCALED_STEP(refp->scale[0]); + *dy = SCALED_STEP(refp->scale[1]); +} + +static void emulated_edge_scaled(VVCLocalContext *lc, const uint8_t **src, ptrdiff_t *src_stride, int *src_height, + const VVCFrame *ref, const int x, const int y, const int dx, const int dy, + const int block_w, const int block_h, const int is_chroma) +{ + const VVCFrameContext *fc = lc->fc; + const int x0 = SCALED_INT(x); + const int y0 = SCALED_INT(y); + const int x_end = SCALED_INT(x + block_w * dx); + const int y_end = SCALED_INT(y + block_h * dy); + const int x_last = SCALED_INT(x + (block_w - 1) * dx); + const int y_last = SCALED_INT(y + (block_h - 1) * dy); + const int src_width = x_end - x0 + (x_end == x_last); + + *src_height = y_end - y0 + (y_end == y_last); + + *src += y0 * *src_stride + (x0 * (1 << fc->ps.sps->pixel_shift)); + + emulated_edge(lc, lc->edge_emu_buffer, src, src_stride, ref, x0, y0, src_width, *src_height, is_chroma); +} + +static void mc_scaled(VVCLocalContext *lc, int16_t *dst, const VVCRefPic *refp, const Mv *mv, + int x_off, int y_off, const int block_w, const int block_h, const int c_idx) +{ + const VVCFrameContext *fc = lc->fc; + const PredictionUnit *pu = &lc->cu->pu; + const uint8_t *src = refp->ref->frame->data[c_idx]; + ptrdiff_t src_stride = refp->ref->frame->linesize[c_idx]; + const int is_affine = pu->inter_affine_flag; + const int is_chroma = !!c_idx; + const int idx = av_log2(block_w) - 1; + const int8_t *hf = INTER_FILTER_SCALED(refp->scale[0]); + const int8_t *vf = INTER_FILTER_SCALED(refp->scale[1]); + int x, y, dx, dy, src_height; + + scaled_ref_pos_and_step(lc, refp, mv, x_off, y_off, c_idx, &x, &y, &dx, &dy); + emulated_edge_scaled(lc, &src, &src_stride, &src_height, refp->ref, x, y, dx, dy, block_w, block_h, is_chroma); + fc->vvcdsp.inter.put_scaled[is_chroma][idx](dst, src, src_stride, src_height, x, y, dx, dy, block_h, hf, vf, block_w); +} + +static void mc_uni_scaled(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, const VVCRefPic *refp, + const MvField *mvf, const int x_off, const int y_off, const int block_w, const int block_h, const int c_idx) +{ + const VVCFrameContext *fc = lc->fc; + const PredictionUnit *pu = &lc->cu->pu; + const uint8_t *src = refp->ref->frame->data[c_idx]; + ptrdiff_t src_stride = refp->ref->frame->linesize[c_idx]; + const int lx = mvf->pred_flag - PF_L0; + const Mv *mv = &mvf->mv[lx]; + const int is_affine = pu->inter_affine_flag; + const int is_chroma = !!c_idx; + const int idx = av_log2(block_w) - 1; + const int8_t *hf = INTER_FILTER_SCALED(refp->scale[0]); + const int8_t *vf = INTER_FILTER_SCALED(refp->scale[1]); + int denom, wx, ox, x, y, dx, dy, src_height; + + scaled_ref_pos_and_step(lc, refp, mv, x_off, y_off, c_idx, &x, &y, &dx, &dy); + emulated_edge_scaled(lc, &src, &src_stride, &src_height, refp->ref, x, y, dx, dy, block_w, block_h, is_chroma); + + if (derive_weight_uni(&denom, &wx, &ox, lc, mvf, c_idx)) { + fc->vvcdsp.inter.put_uni_w_scaled[is_chroma][idx](dst, dst_stride, src, src_stride, src_height, + x, y, dx, dy, block_h, denom, wx, ox, hf, vf, block_w); + } else { + fc->vvcdsp.inter.put_uni_scaled[is_chroma][idx](dst, dst_stride, src, src_stride, src_height, + x, y, dx, dy, block_h, hf, vf, block_w); + } +} + +static void mc_bi_scaled(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, + 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 }; + + for (int i = L0; i <= L1; i++) { + const Mv *mv = mvf->mv + i; + const VVCRefPic *refp = refps[i]; + + if (refp->is_scaled) + mc_scaled(lc, tmp[i], refp, mv, x_off, y_off, block_w, block_h, c_idx); + 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); +} + static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, const VVCFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h, const int cb_prof_flag, const int16_t *diff_mv_x, const int16_t *diff_mv_y) @@ -380,20 +515,23 @@ static void luma_prof(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref, } static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, - const VVCFrame *ref0, const VVCFrame *ref1, const MvField *mvf, const int x_off, const int y_off, + 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 VVCFrame *refs[] = { ref0, ref1 }; + 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 VVCFrame *ref = refs[i]; - const Mv *mv = mvf->mv + i; + const VVCRefPic *refp = refps[i]; + const Mv *mv = mvf->mv + i; - luma_prof(lc, tmp[i], ref, mv, x_off, y_off, block_w, block_h, i); + if (refp->is_scaled) + mc_scaled(lc, tmp[i], refp, mv, x_off, y_off, block_w, block_h, LUMA); + else + luma_prof(lc, tmp[i], refp->ref, mv, x_off, y_off, block_w, block_h, i); } if (weight_flag) @@ -465,10 +603,13 @@ static void pred_gpm_blk(VVCLocalContext *lc) for (int i = 0; i < 2; i++) { const MvField *mv = pu->gpm_mv + i; const int lx = mv->pred_flag - PF_L0; - VVCFrame *ref = lc->sc->rpl[lx].refs[mv->ref_idx[lx]].ref; - if (!ref) + VVCRefPic *refp = lc->sc->rpl[lx].refs + mv->ref_idx[lx]; + if (!refp->ref) return; - mc(lc, tmp[i], ref, mv->mv + lx, x, y, width, height, c_idx); + if (refp->is_scaled) + mc_scaled(lc, tmp[i], refp, mv->mv + lx, x, y, width, height, c_idx); + else + mc(lc, tmp[i], refp->ref, mv->mv + lx, x, y, width, height, c_idx); } fc->vvcdsp.inter.put_gpm(dst, dst_stride, width, height, tmp[0], tmp[1], weights, step_x, step_y); } @@ -524,11 +665,22 @@ static void pred_regular(VVCLocalContext *lc, const MvField *mvf, const MvField if (mvf->pred_flag != PF_BI) { const int lx = mvf->pred_flag - PF_L0; - mc_uni(lc, inter, inter_stride, refp[lx]->ref, mvf, - x, y, w, h, c_idx); + + if (refp[lx]->is_scaled) { + mc_uni_scaled(lc, inter, inter_stride, refp[lx], mvf, + x, y, w, h, c_idx); + } else { + mc_uni(lc, inter, inter_stride, refp[lx]->ref, mvf, + x, y, w, h, c_idx); + } } else { - mc_bi(lc, inter, inter_stride, refp[L0]->ref, refp[L1]->ref, mvf, orig_mvf, - x, y, w, h, c_idx, do_bdof); + if (refp[L0]->is_scaled || refp[L1]->is_scaled) { + mc_bi_scaled(lc, inter, inter_stride, refp[L0], refp[L1], mvf, + x, y, w, h, c_idx); + } else { + mc_bi(lc, inter, inter_stride, refp[L0]->ref, refp[L1]->ref, mvf, orig_mvf, + x, y, w, h, c_idx, do_bdof); + } } if (do_ciip) { const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh); @@ -739,6 +891,7 @@ static void pred_affine_blk(VVCLocalContext *lc) const int sbh = cu->cb_height / mi->num_sb_y; const int hs = fc->ps.sps->hshift[1]; const int vs = fc->ps.sps->vshift[1]; + const int dst_stride = fc->frame->linesize[LUMA]; for (int sby = 0; sby < mi->num_sb_y; sby++) { for (int sbx = 0; sbx < mi->num_sb_x; sbx++) { @@ -754,12 +907,15 @@ static void pred_affine_blk(VVCLocalContext *lc) if (mi->pred_flag != PF_BI) { const int lx = mi->pred_flag - PF_L0; - luma_prof_uni(lc, dst0, fc->frame->linesize[LUMA], refp[lx]->ref, - mv, x, y, sbw, sbh, pu->cb_prof_flag[lx], - pu->diff_mv_x[lx], pu->diff_mv_y[lx]); + if (refp[lx]->is_scaled) { + mc_uni_scaled(lc, dst0, dst_stride, refp[lx], mv, x, y, sbw, sbh, LUMA); + } else { + luma_prof_uni(lc, dst0, dst_stride, refp[lx]->ref, + mv, x, y, sbw, sbh, pu->cb_prof_flag[lx], + pu->diff_mv_x[lx], pu->diff_mv_y[lx]); + } } else { - luma_prof_bi(lc, dst0, fc->frame->linesize[LUMA], refp[L0]->ref, refp[L1]->ref, - mv, x, y, sbw, sbh); + luma_prof_bi(lc, dst0, dst_stride, refp[L0], refp[L1], mv, x, y, sbw, sbh); } if (fc->ps.sps->r->sps_chroma_format_idc) { if (!av_mod_uintp2(sby, vs) && !av_mod_uintp2(sbx, hs)) {