From patchwork Mon Mar 18 14:16:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuo Mi X-Patchwork-Id: 47173 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp1042644pzb; Mon, 18 Mar 2024 07:18:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUDgdIsSanAw+2vNuT+LXgqcWmSMrOd2TupA5hnahXa7E4+xDW3aNl89NLo1ocrwRcAliOkTaS16ICJrLT5UJfeNDcgX2+zzXsKDA== X-Google-Smtp-Source: AGHT+IEjoXXtxERCsikEqegyLczZ6LIAqtDMsTrIeVxAFpJ9sa3ama+zpWfAm0JwYKqQxWRejr5j X-Received: by 2002:a17:906:f295:b0:a46:bb6c:9ed3 with SMTP id gu21-20020a170906f29500b00a46bb6c9ed3mr2175363ejb.68.1710771532866; Mon, 18 Mar 2024 07:18:52 -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 ck22-20020a170906c45600b00a4654dfeacasi4386170ejb.258.2024.03.18.07.18.52; Mon, 18 Mar 2024 07:18:52 -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=byRo5Q5Z; 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 7957B68D1D0; Mon, 18 Mar 2024 16:17:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01olkn2032.outbound.protection.outlook.com [40.92.107.32]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 78D7468D2A8 for ; Mon, 18 Mar 2024 16:17:15 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PtdQSD8wD9EqnQrDfYR8wH597rQx9cwO3S4hsaJM29di85tbx+ORq9mCfMQ7eugiyGsYa8oASSgmg0t3Cpco50VEyeCisazvRyf8J0KYEpQdywDyIzHohE/vrpeXqzpjguXRWvjuFZ7dre6XxUHex88XdTuep7/eXBAkzkuv2BHyqgQEmDjpP6SyJURlCsWbNhBKksfskGhWXCSnWsw7gHDkibbLgVvTRwGkfEcYjysvy+2fvUjSThkNxcyaTZo6LYWQE2PjQUAYqq6SMoZyQMoecY5sJxPhIL8J/rteQvl84597zf1HK3Us29hFWvuZHmE491nAQ7IP3Tf7tnn8Ag== 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=uFuWrKM/37tokplLu/lbf/pBcWIFR9Q4xQMNjQCtwoQ=; b=AJ1xAf9LD+aAo55ck7KDZ/pO+82i7o3ZGdaqe8uxG2r3Z9YaevxHZZxrMkROtN4jOjlPZjrFKVmTAxELT4G81XbEiMdrYfnH6+4CjENjHVgf0vUsVWquVurLEvFTLhutk5+p+QN2Lpi2rkOw0SfAuph4w/sODcMSXOYAIAMa673ckMo6lekHk+PfwUf4KKFMBIh6o3+3H0DUvRSrzXfObPO2CqWgG4ayXUUAIUZDlLObSH+MRLIMKUn6p8yP7zfb7FZbJaTGwSgSxxF+TA15AUmt8eb/yeH5AyXfk3yTIEbMCCoAEOxngm3WniCnHCdRi4FSsOuyo5boIAvbOCDgeg== 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=uFuWrKM/37tokplLu/lbf/pBcWIFR9Q4xQMNjQCtwoQ=; b=byRo5Q5ZPfq29KFgpxPckVh+2C2q8W+Zg417cZcSFDDY8lcdynYHU2VywW4nNxLDBEM0kT/+M9FTogiRhVgugub0PJHUkUFPUsBV2+OqAmo+bE6HFm7EtEJXhbRK+t90r67UL8xdvgpTFzBv27YTccimrJ1eJouPcUMJjMQ6JAHhTHlrzCqaaEgxFymFZprQDRqb5nfjizabukqksZnGrUbyT1lujH8gKWDOu0+GHX+PNnseNZe7e5goztyY6Fp1b5TV5/DnJ0KBzieOEaCwlfUJquDbyHAyQ1i6Nod4w4NefMeTv4IX9aoPhEUU0wYYllikZ9TXSoj/r0p3loOnPg== Received: from TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) by JH0PR06MB6604.apcprd06.prod.outlook.com (2603:1096:990:3f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 14:17:02 +0000 Received: from TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::d001:da90:518b:ec1c]) by TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::d001:da90:518b:ec1c%3]) with mapi id 15.20.7386.025; Mon, 18 Mar 2024 14:17:02 +0000 From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Mon, 18 Mar 2024 22:16:18 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240318141626.3375-1-nuomi2021@gmail.com> References: <20240318141626.3375-1-nuomi2021@gmail.com> X-TMN: [bzXgbe/kPzlhAuF4Fj9UBSLM/wmUFc8e] X-ClientProxiedBy: TYAPR01CA0085.jpnprd01.prod.outlook.com (2603:1096:404:2c::25) To TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) X-Microsoft-Original-Message-ID: <20240318141626.3375-7-nuomi2021@gmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6433:EE_|JH0PR06MB6604:EE_ X-MS-Office365-Filtering-Correlation-Id: 36d893e2-912f-4254-8244-08dc475614e5 X-MS-Exchange-SLBlob-MailProps: qdrM8TqeFBtQM6LyuMuRQGpfKJqciaiF6xLc8j7kZKBDM+hSs9cdVr8Zng1U6+nqG1FH8xLQzYF8iHlR5HJXA8O1m/esO/Ba9Ck3JNHJ3XnHJ76pHjKwfJp3U/DPXdk9qzovoqZ3/2OUA5UNDt7piqGKKbyOFksRqk/Pn/tTZE+TTPczLqeJBkS9CEBmw9mrzHL9A8ZZ0CagkoHCbxEq2q2aeN5szI0a8bNCUeUU+3cRojfyFbYVfsKePy19NVl98gKrld0cW7zY7EDeE3kpZrkII5+YTXbmV0vPvNtwaWKrNuEvjyhDifyZowfWmHYXi1jDlfAPj+3KWngKzrHLBbiZZaYeRrWAvn0byV1zZUM6gJMz1V4TinVvTwmV8pclxJVkmXNbzZzqt3qPSyP6G99Woj0Fr3T88p6cIOamia2ESJF98BjmLbH+W5agUVWa82PMfCXi/vMECICddIPo+4m9eS8ddk4V4l2ij0614KsyMBbcH793dwZbGvA0rKWUinkVnrWC4wzlUEiev3VzU+EBqdmlkZCCohio4G++i/c06viuEghfx0Yx+PiZg8fL/cSFu0mLC6eE/DaUBEsxJumSPsSDtsaB5CFf7c1D8d6lkIBZcW0+3A7qQZa83Regkf7M/oVx7Mt3m0d5Vl5uwah9ZsUtC9bVZ6ILUTpuEijen0m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outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36d893e2-912f-4254-8244-08dc475614e5 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6433.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2024 14:17:02.5439 (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: JH0PR06MB6604 Subject: [FFmpeg-devel] [PATCH 06/14] avcodec/vvcdec: misc, rename x_ctb, y_ctb, ctu_x, ctu_y to rx, ry to avoid misleading 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: pZ+sJAO+kp3D --- libavcodec/vvc/vvc_ctu.c | 8 ++-- libavcodec/vvc/vvc_filter.c | 96 ++++++++++++++++++------------------- libavcodec/vvc/vvc_ps.c | 38 +++++++-------- 3 files changed, 71 insertions(+), 71 deletions(-) diff --git a/libavcodec/vvc/vvc_ctu.c b/libavcodec/vvc/vvc_ctu.c index 75d9f07143..519bd1ba76 100644 --- a/libavcodec/vvc/vvc_ctu.c +++ b/libavcodec/vvc/vvc_ctu.c @@ -87,10 +87,10 @@ static int get_qp_y_pred(const VVCLocalContext *lc) const int min_cb_width = fc->ps.pps->min_cb_width; const int x_cb = cu->x0 >> sps->min_cb_log2_size_y; const int y_cb = cu->y0 >> sps->min_cb_log2_size_y; - const int x_ctb = cu->x0 >> ctb_log2_size; - const int y_ctb = cu->y0 >> ctb_log2_size; - const int in_same_ctb_a = ((xQg - 1) >> ctb_log2_size) == x_ctb && (yQg >> ctb_log2_size) == y_ctb; - const int in_same_ctb_b = (xQg >> ctb_log2_size) == x_ctb && ((yQg - 1) >> ctb_log2_size) == y_ctb; + const int rx = cu->x0 >> ctb_log2_size; + const int ry = cu->y0 >> ctb_log2_size; + const int in_same_ctb_a = ((xQg - 1) >> ctb_log2_size) == rx && (yQg >> ctb_log2_size) == ry; + const int in_same_ctb_b = (xQg >> ctb_log2_size) == rx && ((yQg - 1) >> ctb_log2_size) == ry; int qPy_pred, qPy_a, qPy_b; if (lc->na.cand_up) { diff --git a/libavcodec/vvc/vvc_filter.c b/libavcodec/vvc/vvc_filter.c index dded447bfa..10bd57e078 100644 --- a/libavcodec/vvc/vvc_filter.c +++ b/libavcodec/vvc/vvc_filter.c @@ -99,7 +99,7 @@ static void copy_vert(uint8_t *dst, const uint8_t *src, const int pixel_shift, c static void copy_ctb_to_hv(VVCFrameContext *fc, const uint8_t *src, const ptrdiff_t src_stride, const int x, const int y, const int width, const int height, - const int c_idx, const int x_ctb, const int y_ctb, const int top) + const int c_idx, const int rx, const int ry, const int top) { const int ps = fc->ps.sps->pixel_shift; const int w = fc->ps.pps->width >> fc->ps.sps->hshift[c_idx]; @@ -107,16 +107,16 @@ static void copy_ctb_to_hv(VVCFrameContext *fc, const uint8_t *src, if (top) { /* top */ - memcpy(fc->tab.sao_pixel_buffer_h[c_idx] + (((2 * y_ctb) * w + x) << ps), + memcpy(fc->tab.sao_pixel_buffer_h[c_idx] + (((2 * ry) * w + x) << ps), src, width << ps); } else { /* bottom */ - memcpy(fc->tab.sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 1) * w + x) << ps), + memcpy(fc->tab.sao_pixel_buffer_h[c_idx] + (((2 * ry + 1) * w + x) << ps), src + src_stride * (height - 1), width << ps); /* copy vertical edges */ - copy_vert(fc->tab.sao_pixel_buffer_v[c_idx] + (((2 * x_ctb) * h + y) << ps), src, ps, height, 1 << ps, src_stride); - copy_vert(fc->tab.sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 1) * h + y) << ps), src + ((width - 1) << ps), ps, height, 1 << ps, src_stride); + copy_vert(fc->tab.sao_pixel_buffer_v[c_idx] + (((2 * rx) * h + y) << ps), src, ps, height, 1 << ps, src_stride); + copy_vert(fc->tab.sao_pixel_buffer_v[c_idx] + (((2 * rx + 1) * h + y) << ps), src + ((width - 1) << ps), ps, height, 1 << ps, src_stride); } } @@ -158,9 +158,9 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x, int y) static const uint8_t sao_tab[16] = { 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8 }; int c_idx; int edges[4]; // 0 left 1 top 2 right 3 bottom - const int x_ctb = x >> fc->ps.sps->ctb_log2_size_y; - const int y_ctb = y >> fc->ps.sps->ctb_log2_size_y; - const SAOParams *sao = &CTB(fc->tab.sao, x_ctb, y_ctb); + const int rx = x >> fc->ps.sps->ctb_log2_size_y; + const int ry = y >> fc->ps.sps->ctb_log2_size_y; + const SAOParams *sao = &CTB(fc->tab.sao, rx, ry); // flags indicating unfilterable edges uint8_t vert_edge[] = { 0, 0 }; uint8_t horiz_edge[] = { 0, 0 }; @@ -174,39 +174,39 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x, int y) uint8_t up_tile_edge = 0; uint8_t bottom_tile_edge = 0; - edges[LEFT] = x_ctb == 0; - edges[TOP] = y_ctb == 0; - edges[RIGHT] = x_ctb == fc->ps.pps->ctb_width - 1; - edges[BOTTOM] = y_ctb == fc->ps.pps->ctb_height - 1; + edges[LEFT] = rx == 0; + edges[TOP] = ry == 0; + edges[RIGHT] = rx == fc->ps.pps->ctb_width - 1; + edges[BOTTOM] = ry == fc->ps.pps->ctb_height - 1; if (restore) { if (!edges[LEFT]) { - left_tile_edge = no_tile_filter && fc->ps.pps->ctb_to_col_bd[x_ctb] == x_ctb; - vert_edge[0] = (!lfase && CTB(fc->tab.slice_idx, x_ctb, y_ctb) != CTB(fc->tab.slice_idx, x_ctb - 1, y_ctb)) || left_tile_edge; + left_tile_edge = no_tile_filter && fc->ps.pps->ctb_to_col_bd[rx] == rx; + vert_edge[0] = (!lfase && CTB(fc->tab.slice_idx, rx, ry) != CTB(fc->tab.slice_idx, rx - 1, ry)) || left_tile_edge; } if (!edges[RIGHT]) { - right_tile_edge = no_tile_filter && fc->ps.pps->ctb_to_col_bd[x_ctb] != fc->ps.pps->ctb_to_col_bd[x_ctb + 1]; - vert_edge[1] = (!lfase && CTB(fc->tab.slice_idx, x_ctb, y_ctb) != CTB(fc->tab.slice_idx, x_ctb + 1, y_ctb)) || right_tile_edge; + right_tile_edge = no_tile_filter && fc->ps.pps->ctb_to_col_bd[rx] != fc->ps.pps->ctb_to_col_bd[rx + 1]; + vert_edge[1] = (!lfase && CTB(fc->tab.slice_idx, rx, ry) != CTB(fc->tab.slice_idx, rx + 1, ry)) || right_tile_edge; } if (!edges[TOP]) { - up_tile_edge = no_tile_filter && fc->ps.pps->ctb_to_row_bd[y_ctb] == y_ctb; - horiz_edge[0] = (!lfase && CTB(fc->tab.slice_idx, x_ctb, y_ctb) != CTB(fc->tab.slice_idx, x_ctb, y_ctb - 1)) || up_tile_edge; + up_tile_edge = no_tile_filter && fc->ps.pps->ctb_to_row_bd[ry] == ry; + horiz_edge[0] = (!lfase && CTB(fc->tab.slice_idx, rx, ry) != CTB(fc->tab.slice_idx, rx, ry - 1)) || up_tile_edge; } if (!edges[BOTTOM]) { - bottom_tile_edge = no_tile_filter && fc->ps.pps->ctb_to_row_bd[y_ctb] != fc->ps.pps->ctb_to_row_bd[y_ctb + 1]; - horiz_edge[1] = (!lfase && CTB(fc->tab.slice_idx, x_ctb, y_ctb) != CTB(fc->tab.slice_idx, x_ctb, y_ctb + 1)) || bottom_tile_edge; + bottom_tile_edge = no_tile_filter && fc->ps.pps->ctb_to_row_bd[ry] != fc->ps.pps->ctb_to_row_bd[ry + 1]; + horiz_edge[1] = (!lfase && CTB(fc->tab.slice_idx, rx, ry) != CTB(fc->tab.slice_idx, rx, ry + 1)) || bottom_tile_edge; } if (!edges[LEFT] && !edges[TOP]) { - diag_edge[0] = (!lfase && CTB(fc->tab.slice_idx, x_ctb, y_ctb) != CTB(fc->tab.slice_idx, x_ctb - 1, y_ctb - 1)) || left_tile_edge || up_tile_edge; + diag_edge[0] = (!lfase && CTB(fc->tab.slice_idx, rx, ry) != CTB(fc->tab.slice_idx, rx - 1, ry - 1)) || left_tile_edge || up_tile_edge; } if (!edges[TOP] && !edges[RIGHT]) { - diag_edge[1] = (!lfase && CTB(fc->tab.slice_idx, x_ctb, y_ctb) != CTB(fc->tab.slice_idx, x_ctb + 1, y_ctb - 1)) || right_tile_edge || up_tile_edge; + diag_edge[1] = (!lfase && CTB(fc->tab.slice_idx, rx, ry) != CTB(fc->tab.slice_idx, rx + 1, ry - 1)) || right_tile_edge || up_tile_edge; } if (!edges[RIGHT] && !edges[BOTTOM]) { - diag_edge[2] = (!lfase && CTB(fc->tab.slice_idx, x_ctb, y_ctb) != CTB(fc->tab.slice_idx, x_ctb + 1, y_ctb + 1)) || right_tile_edge || bottom_tile_edge; + diag_edge[2] = (!lfase && CTB(fc->tab.slice_idx, rx, ry) != CTB(fc->tab.slice_idx, rx + 1, ry + 1)) || right_tile_edge || bottom_tile_edge; } if (!edges[LEFT] && !edges[BOTTOM]) { - diag_edge[3] = (!lfase && CTB(fc->tab.slice_idx, x_ctb, y_ctb) != CTB(fc->tab.slice_idx, x_ctb - 1, y_ctb + 1)) || left_tile_edge || bottom_tile_edge; + diag_edge[3] = (!lfase && CTB(fc->tab.slice_idx, rx, ry) != CTB(fc->tab.slice_idx, rx - 1, ry + 1)) || left_tile_edge || bottom_tile_edge; } } @@ -245,7 +245,7 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x, int y) int pos = 0; dst1 = dst - dst_stride - (left << sh); - src1 = fc->tab.sao_pixel_buffer_h[c_idx] + (((2 * y_ctb - 1) * w + x0 - left) << sh); + src1 = fc->tab.sao_pixel_buffer_h[c_idx] + (((2 * ry - 1) * w + x0 - left) << sh); if (left) { copy_pixel(dst1, src1, sh); pos += (1 << sh); @@ -264,7 +264,7 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x, int y) int pos = 0; dst1 = dst + height * dst_stride - (left << sh); - src1 = fc->tab.sao_pixel_buffer_h[c_idx] + (((2 * y_ctb + 2) * w + x0 - left) << sh); + src1 = fc->tab.sao_pixel_buffer_h[c_idx] + (((2 * ry + 2) * w + x0 - left) << sh); if (left) { copy_pixel(dst1, src1, sh); pos += (1 << sh); @@ -277,12 +277,12 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x, int y) } if (!edges[LEFT]) { copy_vert(dst - (1 << sh), - fc->tab.sao_pixel_buffer_v[c_idx] + (((2 * x_ctb - 1) * h + y0) << sh), + fc->tab.sao_pixel_buffer_v[c_idx] + (((2 * rx - 1) * h + y0) << sh), sh, height, dst_stride, 1 << sh); } if (!edges[RIGHT]) { copy_vert(dst + (width << sh), - fc->tab.sao_pixel_buffer_v[c_idx] + (((2 * x_ctb + 2) * h + y0) << sh), + fc->tab.sao_pixel_buffer_v[c_idx] + (((2 * rx + 2) * h + y0) << sh), sh, height, dst_stride, 1 << sh); } @@ -994,7 +994,7 @@ static void alf_extend_horz(uint8_t *dst, const uint8_t *src, } static void alf_copy_ctb_to_hv(VVCFrameContext *fc, const uint8_t *src, const ptrdiff_t src_stride, - const int x, const int y, const int width, const int height, const int x_ctb, const int y_ctb, const int c_idx) + const int x, const int y, const int width, const int height, const int rx, const int ry, const int c_idx) { const int ps = fc->ps.sps->pixel_shift; const int w = fc->ps.pps->width >> fc->ps.sps->hshift[c_idx]; @@ -1005,12 +1005,12 @@ static void alf_copy_ctb_to_hv(VVCFrameContext *fc, const uint8_t *src, const pt /* copy horizontal edges */ for (int i = 0; i < FF_ARRAY_ELEMS(offset_h); i++) { - alf_copy_border(fc->tab.alf_pixel_buffer_h[c_idx][i] + ((border_pixels * y_ctb * w + x)<< ps), + alf_copy_border(fc->tab.alf_pixel_buffer_h[c_idx][i] + ((border_pixels * ry * w + x)<< ps), src + offset_h[i] * src_stride, ps, width, border_pixels, w << ps, src_stride); } /* copy vertical edges */ for (int i = 0; i < FF_ARRAY_ELEMS(offset_v); i++) { - alf_copy_border(fc->tab.alf_pixel_buffer_v[c_idx][i] + ((h * x_ctb + y) * (border_pixels << ps)), + alf_copy_border(fc->tab.alf_pixel_buffer_v[c_idx][i] + ((h * rx + y) * (border_pixels << ps)), src + (offset_v[i] << ps), ps, border_pixels, height, border_pixels << ps, src_stride); } } @@ -1050,7 +1050,7 @@ static void alf_fill_border_v(uint8_t *dst, const ptrdiff_t dst_stride, const ui } static void alf_prepare_buffer(VVCFrameContext *fc, uint8_t *_dst, const uint8_t *_src, const int x, const int y, - const int x_ctb, const int y_ctb, const int width, const int height, const ptrdiff_t dst_stride, const ptrdiff_t src_stride, + const int rx, const int ry, const int width, const int height, const ptrdiff_t dst_stride, const ptrdiff_t src_stride, const int c_idx, const int *edges) { const int ps = fc->ps.sps->pixel_shift; @@ -1062,23 +1062,23 @@ static void alf_prepare_buffer(VVCFrameContext *fc, uint8_t *_dst, const uint8_t copy_ctb(_dst, _src, width << ps, height, dst_stride, src_stride); //top - src = fc->tab.alf_pixel_buffer_h[c_idx][1] + (((border_pixels * w) << ps) * (y_ctb - 1) + (x << ps)); + src = fc->tab.alf_pixel_buffer_h[c_idx][1] + (((border_pixels * w) << ps) * (ry - 1) + (x << ps)); dst = _dst - border_pixels * dst_stride; alf_fill_border_h(dst, dst_stride, src, w << ps, _dst, width, border_pixels, ps, edges[TOP]); //bottom - src = fc->tab.alf_pixel_buffer_h[c_idx][0] + (((border_pixels * w) << ps) * (y_ctb + 1) + (x << ps)); + src = fc->tab.alf_pixel_buffer_h[c_idx][0] + (((border_pixels * w) << ps) * (ry + 1) + (x << ps)); dst = _dst + height * dst_stride; alf_fill_border_h(dst, dst_stride, src, w << ps, _dst + (height - 1) * dst_stride, width, border_pixels, ps, edges[BOTTOM]); //left - src = fc->tab.alf_pixel_buffer_v[c_idx][1] + (h * (x_ctb - 1) + y - border_pixels) * (border_pixels << ps); + src = fc->tab.alf_pixel_buffer_v[c_idx][1] + (h * (rx - 1) + y - border_pixels) * (border_pixels << ps); dst = _dst - (border_pixels << ps) - border_pixels * dst_stride; alf_fill_border_v(dst, dst_stride, src, dst + (border_pixels << ps), border_pixels, height, ps, edges, edges[LEFT]); //right - src = fc->tab.alf_pixel_buffer_v[c_idx][0] + (h * (x_ctb + 1) + y - border_pixels) * (border_pixels << ps); + src = fc->tab.alf_pixel_buffer_v[c_idx][0] + (h * (rx + 1) + y - border_pixels) * (border_pixels << ps); dst = _dst + (width << ps) - border_pixels * dst_stride; alf_fill_border_v(dst, dst_stride, src, dst - (1 << ps), border_pixels, height, ps, edges, edges[RIGHT]); } @@ -1177,8 +1177,8 @@ static void alf_filter_cc(VVCLocalContext *lc, uint8_t *dst, const uint8_t *luma void ff_vvc_alf_copy_ctu_to_hv(VVCLocalContext* lc, const int x0, const int y0) { VVCFrameContext *fc = lc->fc; - const int x_ctb = x0 >> fc->ps.sps->ctb_log2_size_y; - const int y_ctb = y0 >> fc->ps.sps->ctb_log2_size_y; + const int rx = x0 >> fc->ps.sps->ctb_log2_size_y; + const int ry = y0 >> fc->ps.sps->ctb_log2_size_y; const int ctb_size_y = fc->ps.sps->ctb_size_y; const int ps = fc->ps.sps->pixel_shift; const int c_end = fc->ps.sps->r->sps_chroma_format_idc ? VVC_MAX_SAMPLE_ARRAYS : 1; @@ -1194,7 +1194,7 @@ void ff_vvc_alf_copy_ctu_to_hv(VVCLocalContext* lc, const int x0, const int y0) const int src_stride = fc->frame->linesize[c_idx]; uint8_t* src = &fc->frame->data[c_idx][y * src_stride + (x << ps)]; - alf_copy_ctb_to_hv(fc, src, src_stride, x, y, width, height, x_ctb, y_ctb, c_idx); + alf_copy_ctb_to_hv(fc, src, src_stride, x, y, width, height, rx, ry, c_idx); } } @@ -1202,28 +1202,28 @@ void ff_vvc_alf_filter(VVCLocalContext *lc, const int x0, const int y0) { VVCFrameContext *fc = lc->fc; const VVCPPS *pps = fc->ps.pps; - const int x_ctb = x0 >> fc->ps.sps->ctb_log2_size_y; - const int y_ctb = y0 >> fc->ps.sps->ctb_log2_size_y; + const int rx = x0 >> fc->ps.sps->ctb_log2_size_y; + const int ry = y0 >> fc->ps.sps->ctb_log2_size_y; const int ctb_size_y = fc->ps.sps->ctb_size_y; const int ps = fc->ps.sps->pixel_shift; const int padded_stride = EDGE_EMU_BUFFER_STRIDE << ps; const int padded_offset = padded_stride * ALF_PADDING_SIZE + (ALF_PADDING_SIZE << ps); const int c_end = fc->ps.sps->r->sps_chroma_format_idc ? VVC_MAX_SAMPLE_ARRAYS : 1; - ALFParams *alf = &CTB(fc->tab.alf, x_ctb, y_ctb); - int edges[MAX_EDGES] = { x_ctb == 0, y_ctb == 0, x_ctb == pps->ctb_width - 1, y_ctb == pps->ctb_height - 1 }; + ALFParams *alf = &CTB(fc->tab.alf, rx, ry); + int edges[MAX_EDGES] = { rx == 0, ry == 0, rx == pps->ctb_width - 1, ry == pps->ctb_height - 1 }; if (!pps->r->pps_loop_filter_across_tiles_enabled_flag) { edges[LEFT] = edges[LEFT] || (lc->boundary_flags & BOUNDARY_LEFT_TILE); edges[TOP] = edges[TOP] || (lc->boundary_flags & BOUNDARY_UPPER_TILE); - edges[RIGHT] = edges[RIGHT] || pps->ctb_to_col_bd[x_ctb] != pps->ctb_to_col_bd[x_ctb + 1]; - edges[BOTTOM] = edges[BOTTOM] || pps->ctb_to_row_bd[y_ctb] != pps->ctb_to_row_bd[y_ctb + 1]; + edges[RIGHT] = edges[RIGHT] || pps->ctb_to_col_bd[rx] != pps->ctb_to_col_bd[rx + 1]; + edges[BOTTOM] = edges[BOTTOM] || pps->ctb_to_row_bd[ry] != pps->ctb_to_row_bd[ry + 1]; } if (!pps->r->pps_loop_filter_across_slices_enabled_flag) { edges[LEFT] = edges[LEFT] || (lc->boundary_flags & BOUNDARY_LEFT_SLICE); edges[TOP] = edges[TOP] || (lc->boundary_flags & BOUNDARY_UPPER_SLICE); - edges[RIGHT] = edges[RIGHT] || CTB(fc->tab.slice_idx, x_ctb, y_ctb) != CTB(fc->tab.slice_idx, x_ctb + 1, y_ctb); - edges[BOTTOM] = edges[BOTTOM] || CTB(fc->tab.slice_idx, x_ctb, y_ctb) != CTB(fc->tab.slice_idx, x_ctb, y_ctb + 1); + edges[RIGHT] = edges[RIGHT] || CTB(fc->tab.slice_idx, rx, ry) != CTB(fc->tab.slice_idx, rx + 1, ry); + edges[BOTTOM] = edges[BOTTOM] || CTB(fc->tab.slice_idx, rx, ry) != CTB(fc->tab.slice_idx, rx, ry + 1); } for (int c_idx = 0; c_idx < c_end; c_idx++) { @@ -1243,7 +1243,7 @@ void ff_vvc_alf_filter(VVCLocalContext *lc, const int x0, const int y0) if (alf->ctb_flag[c_idx] || (!c_idx && (alf->ctb_cc_idc[0] || alf->ctb_cc_idc[1]))) { padded = (c_idx ? lc->alf_buffer_chroma : lc->alf_buffer_luma) + padded_offset; - alf_prepare_buffer(fc, padded, src, x, y, x_ctb, y_ctb, width, height, + alf_prepare_buffer(fc, padded, src, x, y, rx, ry, width, height, padded_stride, src_stride, c_idx, edges); } if (alf->ctb_flag[c_idx]) { diff --git a/libavcodec/vvc/vvc_ps.c b/libavcodec/vvc/vvc_ps.c index bbd666307f..d1d6be390a 100644 --- a/libavcodec/vvc/vvc_ps.c +++ b/libavcodec/vvc/vvc_ps.c @@ -319,24 +319,24 @@ static void tile_xy(int *tile_x, int *tile_y, const int tile_idx, const VVCPPS * *tile_y = tile_idx / pps->r->num_tile_columns; } -static void ctu_xy(int *ctu_x, int *ctu_y, const int tile_x, const int tile_y, const VVCPPS *pps) +static void ctu_xy(int *rx, int *ry, const int tile_x, const int tile_y, const VVCPPS *pps) { - *ctu_x = pps->col_bd[tile_x]; - *ctu_y = pps->row_bd[tile_y]; + *rx = pps->col_bd[tile_x]; + *ry = pps->row_bd[tile_y]; } -static int ctu_rs(const int ctu_x, const int ctu_y, const VVCPPS *pps) +static int ctu_rs(const int rx, const int ry, const VVCPPS *pps) { - return pps->ctb_width * ctu_y + ctu_x; + return pps->ctb_width * ry + rx; } -static int pps_add_ctus(VVCPPS *pps, int *off, const int ctu_x, const int ctu_y, +static int pps_add_ctus(VVCPPS *pps, int *off, const int rx, const int ry, const int w, const int h) { int start = *off; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { - pps->ctb_addr_in_slice[*off] = ctu_rs(ctu_x + x, ctu_y + y, pps); + pps->ctb_addr_in_slice[*off] = ctu_rs(rx + x, ry + y, pps); (*off)++; } } @@ -423,16 +423,16 @@ static void pps_single_slice_per_subpic(VVCPPS *pps, const VVCSPS *sps, int *off static int pps_one_tile_slices(VVCPPS *pps, const int tile_idx, int i, int *off) { const H266RawPPS *r = pps->r; - int ctu_x, ctu_y, ctu_y_end, tile_x, tile_y; + int rx, ry, ctu_y_end, tile_x, tile_y; tile_xy(&tile_x, &tile_y, tile_idx, pps); - ctu_xy(&ctu_x, &ctu_y, tile_x, tile_y, pps); - ctu_y_end = ctu_y + r->row_height_val[tile_y]; - while (ctu_y < ctu_y_end) { + ctu_xy(&rx, &ry, tile_x, tile_y, pps); + ctu_y_end = ry + r->row_height_val[tile_y]; + while (ry < ctu_y_end) { pps->slice_start_offset[i] = *off; - pps->num_ctus_in_slice[i] = pps_add_ctus(pps, off, ctu_x, ctu_y, + pps->num_ctus_in_slice[i] = pps_add_ctus(pps, off, rx, ry, r->col_width_val[tile_x], r->slice_height_in_ctus[i]); - ctu_y += r->slice_height_in_ctus[i++]; + ry += r->slice_height_in_ctus[i++]; } i--; return i; @@ -441,15 +441,15 @@ static int pps_one_tile_slices(VVCPPS *pps, const int tile_idx, int i, int *off) static void pps_multi_tiles_slice(VVCPPS *pps, const int tile_idx, const int i, int *off) { const H266RawPPS *r = pps->r; - int ctu_x, ctu_y,tile_x, tile_y; + int rx, ry, tile_x, tile_y; tile_xy(&tile_x, &tile_y, tile_idx, pps); pps->slice_start_offset[i] = *off; pps->num_ctus_in_slice[i] = 0; for (int ty = tile_y; ty <= tile_y + r->pps_slice_height_in_tiles_minus1[i]; ty++) { for (int tx = tile_x; tx <= tile_x + r->pps_slice_width_in_tiles_minus1[i]; tx++) { - ctu_xy(&ctu_x, &ctu_y, tx, ty, pps); - pps->num_ctus_in_slice[i] += pps_add_ctus(pps, off, ctu_x, ctu_y, + ctu_xy(&rx, &ry, tx, ty, pps); + pps->num_ctus_in_slice[i] += pps_add_ctus(pps, off, rx, ry, r->col_width_val[tx], r->row_height_val[ty]); } } @@ -479,12 +479,12 @@ static void pps_rect_slice(VVCPPS *pps, const VVCSPS *sps) static void pps_no_rect_slice(VVCPPS* pps) { const H266RawPPS* r = pps->r; - int ctu_x, ctu_y, off = 0; + int rx, ry, off = 0; for (int tile_y = 0; tile_y < r->num_tile_rows; tile_y++) { for (int tile_x = 0; tile_x < r->num_tile_columns; tile_x++) { - ctu_xy(&ctu_x, &ctu_y, tile_x, tile_y, pps); - pps_add_ctus(pps, &off, ctu_x, ctu_y, r->col_width_val[tile_x], r->row_height_val[tile_y]); + ctu_xy(&rx, &ry, tile_x, tile_y, pps); + pps_add_ctus(pps, &off, rx, ry, r->col_width_val[tile_x], r->row_height_val[tile_y]); } } }