From patchwork Tue Jun 4 12:04:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuo Mi X-Patchwork-Id: 49537 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9183:0:b0:460:55fa:d5ed with SMTP id s3csp2634774vqg; Tue, 4 Jun 2024 05:05:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWz0NK4W1i0MJ0kIMbMDxsEJy9gNU8QQWTZkleUwIX/S8E+yFTaof7sJO6FesUdd+GMN17zcJTL1jhx8I1RWVmVELDI0I2HUqknzg== X-Google-Smtp-Source: AGHT+IG6vdDw4/wZ5HzKra0gBWvA7B64H1xm61e30u+FQXOLKu+17ZA1S9n8iEHK/W33cNFrjFl7 X-Received: by 2002:a50:a6d6:0:b0:579:e283:d2a4 with SMTP id 4fb4d7f45d1cf-57a365641f4mr6851810a12.36.1717502704267; Tue, 04 Jun 2024 05:05:04 -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-57a31ca4e40si4884761a12.503.2024.06.04.05.05.03; Tue, 04 Jun 2024 05:05:04 -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=CNq36iAD; 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 862AD68D6FA; Tue, 4 Jun 2024 15:05:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01olkn2047.outbound.protection.outlook.com [40.92.52.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3C72B68D6E0 for ; Tue, 4 Jun 2024 15:04:53 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J8V/orBzdZDeKE+nKXF6BR7cwl2ruuqn9HYP6q/u3vMoGneknioTyt/ha781R1PzF8J2AOYiXwXecsdSOhXBgv/TdZqq4/pbopd1Tot4SG36GiZNP8NnlT7zixPgBqffYus7gBKFijHyEYbsEjNepXf6RQfqFwirkeBcPrW/KyKuotxxrCww+mEpJMni1sEr75tyHQM/REuuuKKJdkmxovvKj5+QhBxfElVjyIP/WBlHF0T1JGvl+dPQqm25w69dvmX0UUcEndBHkHZVmjFM/y15pf7a67v8JJ38n0b9RjiVV+skGLSujE7zX7Rz47GjQqRSjRhRVKvGE8QqQkbfIA== 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=po2wkLhe6FvF6Jh0fFg6xtHF4zSn1EgDF2PyfvJ5WRk=; b=R5jBmYjCVFhixJG4628vJfVnsv7FFyxGA2IA0tbdeG7sC0FEgsUwplpSoRTgnZoliBwTTBqIr3t2umdtfXds+GdgkDGRecHO73230q9V9BZRDePsegU1p3yCXUpO7zLV/EV0G60PjY2U5Gp6zSQM+BJ5IYOXjHXUKFCrq3xdxlkJP9urwnYv7rC5LsQNnb1r5fmJuhb9bq9gAwwfl5hZ3XqXI0CnR1LQlZgXu8V3o9JnLoxUv+4oqKQ64jD8yv2fass7T+9wFZp7cjoUCrCyZrVTaAwZ0S09fH+vhc7Xsc4/Pmzk01+RDJuC3BfoaYQOwsJIRdsrEl30yz6iXTLDpg== 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=po2wkLhe6FvF6Jh0fFg6xtHF4zSn1EgDF2PyfvJ5WRk=; b=CNq36iAD2vi3ecdSKfN3MZ/R6XHZ7K3riQVKfUpMrDfXW1H+UIj6WJbSOzCI4Z/kDhYxnQh0HcKMwI7tooXKUiT9BT+2jbZ3c6hL2JgEg6zYBsSh74gzWa2Pt31+V5rt6p+KBfc91u/+xNNOoHgv3nsdclFZszXqWd6v7BKnWyn64OfvbjsBF7CVnoMa/VTQWzEWNvCzWFUNRHFgXQjm8fqx61aNOZuwzmSo17SFkAM9EYae2Ha0TOQ1MuZ5F+xnpZRW9xH0uKDdR+V8brECobww5k6vQfXpTWmcCX1R0ycJ6d09mSahKW8rpP5fwVnlGmeU5+PKAtBKGIKTh9UkIQ== Received: from TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) by SEZPR06MB7187.apcprd06.prod.outlook.com (2603:1096:101:234::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Tue, 4 Jun 2024 12:04:46 +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.7633.021; Tue, 4 Jun 2024 12:04:46 +0000 From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Tue, 4 Jun 2024 20:04:07 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [2RovtOa6spuwEb1Hc1p3HyYdIcLqWR8u] X-ClientProxiedBy: TYCP286CA0038.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:29d::9) To TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) X-Microsoft-Original-Message-ID: <20240604120411.435626-1-nuomi2021@gmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6433:EE_|SEZPR06MB7187:EE_ X-MS-Office365-Filtering-Correlation-Id: f7753d5d-9621-4aa3-8bb7-08dc848e86ec X-Microsoft-Antispam: BCL:0; ARA:14566002|461199019|440099019|3412199016|1710799017; X-Microsoft-Antispam-Message-Info: 5Wn7Cd4MdY9JGzOxx+ekK30Fe1Kir5UjOqPeaV+LViR//LLxvHerTa3uXXnzbxckfH1+lVQ0Gw7Om/qNTvtBRITQkDaKpyIVt8iJTO2SMCA0TJTk2ibF6deZdaEIgqpbZk3jReeounilBVB92ljPbqEKy21d8un+8ZuKaSfYdP2v8/uvZ0fbRbFHOV4Fk68HfzBRF6tMpcZ90bIzIrPgiLGegQEO+v0VdFWFDRWvwp0WLM1+XGB4p18TFKQNrkf5WPjP68uQDdnxBSenXTBAFlzcHphGpAK+x+aCz48ieBWu3Njw1wmbHNlF+UiHG2KiZ8IQdMR9P/vgjAIMnlDSdFkqnfGFYEyrhaunEWLsuQtIXNxMKN5pZUkZuMT4GC12FWzsd05NYFif5F0Pgy9suRS3qgosVxrnK0k7oar9skH1KaofaRSPfC6Wp9xOxuesVprHRDief2BIBKZZ0otrvIi3bJo1IwQr7P/GYNp5rblFW3EyFhid9nn1v8NXBIA6CTfnzUNKa2CCkaKB/Mo/xjjXll6IyaUfSAbh4lR+BUZBjLi2DvHpqfLs+4fuipXvXVoWMYuo5M0uBJFrryaazzfQoujzwRwnPTRVdOnmAryrky7uMfZ7L7ryhrOvfK81 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bX13Ug4uWNextmgwIVXMAQwNjWk6i/8Rx+ttgzV3uxRDafGHEK+Q0WEdDkawKHFXxIBrn+F1Pja3x+HdtAierj8NTQnJE2aZozmXDIgqa3qLE3tKpSPnAkk+gafIHMhJPB3vqqoYwIpvWCpzzxsMpyOa8SK4fLXOKsmjVcw88tGCdaPRZSuILWjCMFBN72GkouzSCvXMifZPJx55imo2IA8SlFIc+7G624Lo1AYwZdJ35rvOi/wBuSrsZ4PVdOjRoAbotdrAZAeeIbT5K2axaKMXuDue0SJrNHQui06Plf511PiBZy+kXstLppMcilXI8p1inWgSdP9P0atAj+Gg+RVBVamXm5rp3l9lPNLC0DOfMkNdugVB2EZXz6fzCNjtoLv9osk21oh8INCT9BKgos9zfZhSgu49ecHXvoYq7jPj7Kq1Ev2yRtqkVgvtfFHmjNOnblLanfN7zT7wgGUucCx71Yt7duWPQfy16gZq9y47Av/DUxFZJrqyjSwO6BtlV66vTUmKvXQnFvhB6Ier4SrSk0abypQ0bsqHf/gv8VeBKfpo1Dy2weXkFXqZwWnTzBzmfv7nBbKs8350C4wk3nxFOqjdNh3G3vEGexsViBdWEj8m/a6kM77ei8l6quLHhCD4STTVG6wBV/VBPOiEkKm2Wg06jyWKahOrQ966srWPW4mKjSFZ/xajaSIKhL+HtmKjKaD8jGsrJfCdxi7SeELV4Px5w+JJSqHG90ZQgLxi00qBLGcoVE0BSQPP1sJW/6VW7YOk0KGy4M6agblQj4VgvcFbDcUUTvYbHmzCmd6KLoqGgaEIGLaZEhjTiQU1GjFniM4C1fd/wewdvb6iuJvwGvcqaBDf6/vC3ns1oadKsypqkxePIl2RmIKYDmIoLiq+1DDeRTMAKHI1HifqRLdoRQ5ibw3Uh5MM79bcjbaRCpAAu7Edhz6I0dLLu07MO8Oe6WoMxC0HeDKVKT0Ehbua4LyWPULfwDmPdT7hXMFy/FSWx+vNT0gEV5rofZfJa/T3PumuNZB16iw6YPXUEFCQcJgM5jyOtlCIB8T12nS/q0xp9D7V1Iz36UA2TSKMmb1YSaqXL6cyg7OjGcFxLcxcQeK8LlK6JOc5l/vmaykMHPF0fV0JhXH0gdkvHvURY2Mg5nrIi2OJuriNSxSdQbTL7GMN/AZWTG+S7nbJvsUZlvJPwgBBD9aqBg6XJbiIsaGKYnkD8JA/7VsnEIXzdVUUzVaQsL2kSqQK+R4kSpAvpda8KUjFkOy4hf/ZtjfchkqO+kn+L+g/UchQ+gJCFQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7753d5d-9621-4aa3-8bb7-08dc848e86ec X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6433.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2024 12:04:46.6622 (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: SEZPR06MB7187 Subject: [FFmpeg-devel] [PATCH v2 1/5] avcodec/vvcdec: refact, remove emulated_edge_dmvr and emulated_edge_bilinear to simplify code 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: benjamin.bross@hhi.fraunhofer.de, Nuo Mi Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: MyEMa8Wa7VPx --- libavcodec/vvc/inter.c | 146 +++++++++++++---------------------------- 1 file changed, 46 insertions(+), 100 deletions(-) diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c index e1011b4fa1..0843c99eb6 100644 --- a/libavcodec/vvc/inter.c +++ b/libavcodec/vvc/inter.c @@ -44,112 +44,59 @@ static void subpic_width_height(int *pic_width, int *pic_height, *pic_height = pps->subpic_height[subpic_idx] >> sps->vshift[is_chroma]; } -static int emulated_edge(const VVCLocalContext *lc, uint8_t *dst, const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame, - int x_off, int y_off, const int block_w, const int block_h, const int is_chroma) +static void emulated_edge(const VVCLocalContext *lc, uint8_t *dst, + const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame, + int x_sb, int y_sb, int x_off, int y_off, const int block_w, const int block_h, + const int is_chroma, const int extra_before, const int extra_after) { const VVCFrameContext *fc = lc->fc; const VVCSPS *sps = src_frame->sps; const VVCPPS *pps = src_frame->pps; const int subpic_idx = lc->sc->sh.r->curr_subpic_idx; - const int extra_before = is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE; - const int extra_after = is_chroma ? CHROMA_EXTRA_AFTER : LUMA_EXTRA_AFTER; - const int extra = is_chroma ? CHROMA_EXTRA : LUMA_EXTRA; - int pic_width, pic_height; - - subpic_offset(&x_off, &y_off, sps, pps, subpic_idx, is_chroma); - subpic_width_height(&pic_width, &pic_height, sps, pps, subpic_idx, is_chroma); - - if (x_off < extra_before || y_off < extra_before || - x_off >= pic_width - block_w - extra_after || - y_off >= pic_height - block_h - extra_after) { - const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << fc->ps.sps->pixel_shift; - int offset = extra_before * *src_stride + (extra_before << fc->ps.sps->pixel_shift); - int buf_offset = extra_before * edge_emu_stride + (extra_before << fc->ps.sps->pixel_shift); - - fc->vdsp.emulated_edge_mc(dst, *src - offset, edge_emu_stride, *src_stride, - block_w + extra, block_h + extra, x_off - extra_before, y_off - extra_before, - pic_width, pic_height); - - *src = dst + buf_offset; - *src_stride = edge_emu_stride; - return 1; - } - return 0; -} - -static void emulated_edge_dmvr(const VVCLocalContext *lc, uint8_t *dst, const uint8_t **src, ptrdiff_t *src_stride, - int x_sb, int y_sb, int x_off, int y_off, const int block_w, const int block_h, const int is_chroma) -{ - const VVCFrameContext *fc = lc->fc; - const VVCSPS *sps = fc->ps.sps; - const VVCPPS *pps = fc->ps.pps; - const int subpic_idx = lc->sc->sh.r->curr_subpic_idx; - const int extra_before = is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE; - const int extra_after = is_chroma ? CHROMA_EXTRA_AFTER : LUMA_EXTRA_AFTER; - const int extra = is_chroma ? CHROMA_EXTRA : LUMA_EXTRA; + const int extra = extra_before + extra_after; + const int dmvr_clip = x_sb != x_off || y_sb != y_off; int pic_width, pic_height; subpic_offset(&x_off, &y_off, sps, pps, subpic_idx, is_chroma); subpic_offset(&x_sb, &y_sb, sps, pps, subpic_idx, is_chroma); subpic_width_height(&pic_width, &pic_height, sps, pps, subpic_idx, is_chroma); + if (dmvr_clip) { + const int start_x = FFMIN(FFMAX(x_sb - extra_before, 0), pic_width - 1); + const int start_y = FFMIN(FFMAX(y_sb - extra_before, 0), pic_height - 1); + pic_width = FFMAX(FFMIN(pic_width, x_sb + block_w + extra_after) - start_x, 1); + pic_height = FFMAX(FFMIN(pic_height, y_sb + block_h + extra_after) - start_y, 1); + x_off -= start_x; + y_off -= start_y; + } - if (x_off < extra_before || y_off < extra_before || + if (dmvr_clip || x_off < extra_before || y_off < extra_before || x_off >= pic_width - block_w - extra_after || - y_off >= pic_height - block_h - extra_after|| - (x_off != x_sb || y_off != y_sb)) { + y_off >= pic_height - block_h - extra_after) { const int ps = fc->ps.sps->pixel_shift; const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << ps; - const int offset = extra_before * *src_stride + (extra_before << ps); + const int offset = extra_before * *src_stride + (extra_before << ps); const int buf_offset = extra_before * edge_emu_stride + (extra_before << ps); - const int start_x = FFMIN(FFMAX(x_sb - extra_before, 0), pic_width - 1); - const int start_y = FFMIN(FFMAX(y_sb - extra_before, 0), pic_height - 1); - const int width = FFMAX(FFMIN(pic_width, x_sb + block_w + extra_after) - start_x, 1); - const int height = FFMAX(FFMIN(pic_height, y_sb + block_h + extra_after) - start_y, 1); - - fc->vdsp.emulated_edge_mc(dst, *src - offset, edge_emu_stride, *src_stride, block_w + extra, block_h + extra, - x_off - start_x - extra_before, y_off - start_y - extra_before, width, height); - - *src = dst + buf_offset; - *src_stride = edge_emu_stride; - } -} - -static void emulated_edge_bilinear(const VVCLocalContext *lc, uint8_t *dst, const uint8_t **src, ptrdiff_t *src_stride, - int x_off, int y_off, const int block_w, const int block_h) -{ - const VVCFrameContext *fc = lc->fc; - const VVCSPS *sps = fc->ps.sps; - const VVCPPS *pps = fc->ps.pps; - const int subpic_idx = lc->sc->sh.r->curr_subpic_idx; - int pic_width, pic_height; - - subpic_offset(&x_off, &y_off, sps, pps, subpic_idx, 0); - subpic_width_height(&pic_width, &pic_height, sps, pps, subpic_idx, 0); - - if (x_off < BILINEAR_EXTRA_BEFORE || y_off < BILINEAR_EXTRA_BEFORE || - x_off >= pic_width - block_w - BILINEAR_EXTRA_AFTER || - y_off >= pic_height - block_h - BILINEAR_EXTRA_AFTER) { - const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << fc->ps.sps->pixel_shift; - const int offset = BILINEAR_EXTRA_BEFORE * *src_stride + (BILINEAR_EXTRA_BEFORE << fc->ps.sps->pixel_shift); - const int buf_offset = BILINEAR_EXTRA_BEFORE * edge_emu_stride + (BILINEAR_EXTRA_BEFORE << fc->ps.sps->pixel_shift); - - fc->vdsp.emulated_edge_mc(dst, *src - offset, edge_emu_stride, *src_stride, block_w + BILINEAR_EXTRA, block_h + BILINEAR_EXTRA, - x_off - BILINEAR_EXTRA_BEFORE, y_off - BILINEAR_EXTRA_BEFORE, pic_width, pic_height); + fc->vdsp.emulated_edge_mc(dst, *src - offset, edge_emu_stride, *src_stride, + block_w + extra, block_h + extra, x_off - extra_before, y_off - extra_before, + pic_width, pic_height); *src = dst + buf_offset; *src_stride = edge_emu_stride; } } -#define MC_EMULATED_EDGE(dst, src, src_stride, x_off, y_off) \ - emulated_edge(lc, dst, src, src_stride, ref, x_off, y_off, block_w, block_h, is_chroma) +#define MC_EMULATED_EDGE(dst, src, src_stride, x_off, y_off) \ + emulated_edge(lc, dst, src, src_stride, ref, x_off, y_off, x_off, y_off, block_w, block_h, is_chroma, \ + is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE, is_chroma ? CHROMA_EXTRA_AFTER : LUMA_EXTRA_AFTER) -#define MC_EMULATED_EDGE_DMVR(dst, src, src_stride, x_sb, y_sb, x_off, y_off) \ - emulated_edge_dmvr(lc, dst, src, src_stride, x_sb, y_sb, x_off, y_off, block_w, block_h, is_chroma) +#define MC_EMULATED_EDGE_DMVR(dst, src, src_stride, x_sb, y_sb, x_off, y_off) \ + emulated_edge(lc, dst, src, src_stride, ref, x_sb, y_sb, x_off, y_off, block_w, block_h, is_chroma, \ + is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE, is_chroma ? CHROMA_EXTRA_AFTER : LUMA_EXTRA_AFTER) -#define MC_EMULATED_EDGE_BILINEAR(dst, src, src_stride, x_off, y_off) \ - emulated_edge_bilinear(lc, dst, src, src_stride, x_off, y_off, pred_w, pred_h) +#define MC_EMULATED_EDGE_BILINEAR(dst, src, src_stride, x_off, y_off) \ + emulated_edge(lc, dst, src, src_stride, ref, x_off, y_off, x_off, y_off, pred_w, pred_h, 0, \ + BILINEAR_EXTRA_BEFORE, BILINEAR_EXTRA_AFTER) // part of 8.5.6.6 Weighted sample prediction process static int derive_weight_uni(int *denom, int *wx, int *ox, @@ -357,23 +304,21 @@ static void scaled_ref_pos_and_step(const VVCLocalContext *lc, const VVCRefPic * } 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 VVCFrame *ref, const int x, const int y, const int dx, const int dy, const int w, const int 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); + const int x_off = SCALED_INT(x); + const int y_off = SCALED_INT(y); + const int x_end = SCALED_INT(x + w * dx); + const int y_end = SCALED_INT(y + h * dy); + const int x_last = SCALED_INT(x + (w - 1) * dx); + const int y_last = SCALED_INT(y + (h - 1) * dy); + const int block_w = x_end - x_off + (x_end == x_last); + const int block_h = *src_height = y_end - y_off + (y_end == y_last); - *src_height = y_end - y0 + (y_end == y_last); + *src += y_off * *src_stride + (x_off * (1 << fc->ps.sps->pixel_shift)); - *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); + MC_EMULATED_EDGE(lc->edge_emu_buffer, src, src_stride, x_off, y_off); } static void mc_scaled(VVCLocalContext *lc, int16_t *dst, const VVCRefPic *refp, const Mv *mv, @@ -737,11 +682,11 @@ static int parametric_mv_refine(const int *sad, const int stride) #define SAD_ARRAY_SIZE 5 //8.5.3 Decoder-side motion vector refinement process static void dmvr_mv_refine(VVCLocalContext *lc, MvField *mvf, MvField *orig_mv, int *sb_bdof_flag, - const AVFrame *ref0, const AVFrame *ref1, const int x_off, const int y_off, const int block_w, const int block_h) + const VVCFrame *ref0, const VVCFrame *ref1, const int x_off, const int y_off, const int block_w, const int block_h) { const VVCFrameContext *fc = lc->fc; const int sr_range = 2; - const AVFrame *ref[] = { ref0, ref1 }; + const VVCFrame *refs[] = { ref0, ref1 }; int16_t *tmp[] = { lc->tmp, lc->tmp1 }; int sad[SAD_ARRAY_SIZE][SAD_ARRAY_SIZE]; int min_dx, min_dy, min_sad, dx, dy; @@ -757,8 +702,9 @@ static void dmvr_mv_refine(VVCLocalContext *lc, MvField *mvf, MvField *orig_mv, const int my = mv->y & 0xf; const int ox = x_off + (mv->x >> 4) - sr_range; const int oy = y_off + (mv->y >> 4) - sr_range; - ptrdiff_t src_stride = ref[i]->linesize[LUMA]; - const uint8_t *src = ref[i]->data[LUMA] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift)); + const VVCFrame *ref = refs[i]; + ptrdiff_t src_stride = ref->frame->linesize[LUMA]; + const uint8_t *src = ref->frame->data[LUMA] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift)); MC_EMULATED_EDGE_BILINEAR(lc->edge_emu_buffer, &src, &src_stride, ox, oy); fc->vvcdsp.inter.dmvr[!!my][!!mx](tmp[i], src, src_stride, pred_h, mx, my, pred_w); } @@ -828,7 +774,7 @@ static void derive_sb_mv(VVCLocalContext *lc, MvField *mv, MvField *orig_mv, int VVCRefPic *refp[2]; if (pred_get_refs(lc, refp, mv) < 0) return; - dmvr_mv_refine(lc, mv, orig_mv, sb_bdof_flag, refp[L0]->ref->frame, refp[L1]->ref->frame, x0, y0, sbw, sbh); + dmvr_mv_refine(lc, mv, orig_mv, sb_bdof_flag, refp[L0]->ref, refp[L1]->ref, x0, y0, sbw, sbh); set_dmvr_info(fc, x0, y0, sbw, sbh, mv); } }