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 ESMTP id BA0564726F for ; Sat, 2 Sep 2023 16:10:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EED1968C80B; Sat, 2 Sep 2023 19:08:38 +0300 (EEST) Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01olkn2052.outbound.protection.outlook.com [40.92.52.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1BC9E68C7E2 for ; Sat, 2 Sep 2023 19:08:33 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YdgoZho7MA55HqBdCZfqAmGk1j7KajzkHdrGYtg2aQ+iiAmM9GNc9wUMd1wIXd6DpmX73ydGguWVphgDtozeJ+7iSG8ZofvNO06HVPGF5L0FNqIHmCkLzAnJRYoVYw4LnUHwFI3Lu/hb1hxGULflXQDALjh1kXCQGPoQV4TgAlRP4NPtGuQrshapUaFgZ/Si25RXL1HjgsA41KfB3IwHyNXGwKCu0yx/0kKwueQYBlOyx48K2S1WPvSdAbbLHvBYeKfWhU6Y+3zqVmkXStrzUvLj1+zolSD45kQ9+usleVR91ScebpsHUgo2ANCxqEyQVK+MW7hBPif/Cey5SNJM+Q== 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=SbTYrAwbzU45g9NTNaaJd4+OHmVhJRYhCXFEZkV1baE=; b=mhruaVZh7VnTSU0NyLIqSML1IHrGCMzO/1h1oc6LvVAQHMo3XeUjHMuXGRN/3XC8gBufsjPFthcB+nWQ6m/8MmVCqLTazhzrwecc2VeOCWXarg7QEeJ3aXe5IzGk5IFkG0Y2wRqB446ojGun7TOviLNqLgsNRCIax07bI2Hn1JcC6y+xE7sQmEK1EdvdjOi862885EWMTI6cJWjAa2ruuKUb1dbozOw2mfYz4ST+brqc1Qe5GfWs+TOvWvqCLOiUHTABdf7Du5IgsoeFe6LhsM3b4adP8rPiPsHyUVA8YiG9X6pdSChnYIBWmSRhbW/0XxkleBlFx9DFgc9WTjaFhg== 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=SbTYrAwbzU45g9NTNaaJd4+OHmVhJRYhCXFEZkV1baE=; b=YVjiNGzEWyG2psxkHveA5WRspKVdlx5/iSBZxG7+1Tm7b8eS6JumfOZLAneNuklyOIcuBldnT7d1MhpHm9Y6djlWLRDlM6bW9glb6H5jRFsizm+XTDRb3r1RUJaxu7f5bzF9AyJQ2/j37JZcsfbxhx+3y+wCW459sK3WDYrhRYBWxWYaJlYvEzrtWerp6am1TtDPqjcZlh1KpTB7I0L0GJBM07vE6b2f36ghA0ercpRM+gsG+vGxpuD2cypqJV7Q0Hrkm8d09lzhdKybHBcEBCfeIXYQCf5+bvv1pX4zz2g/OzrGCmTxTuZJlNp42YCC9MTv4STHgt3Z19hCyuc9zw== Received: from TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) by TYZPR06MB4030.apcprd06.prod.outlook.com (2603:1096:400:24::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.27; Sat, 2 Sep 2023 16:08:17 +0000 Received: from TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::f1a4:bbff:7592:ee31]) by TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::f1a4:bbff:7592:ee31%5]) with mapi id 15.20.6745.030; Sat, 2 Sep 2023 16:08:17 +0000 From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Sep 2023 00:07:38 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230902160741.19197-1-nuomi2021@gmail.com> References: <20230902160741.19197-1-nuomi2021@gmail.com> X-TMN: [ZEkhpi0W+4b47On0zelcswenBRLe7y5I] X-ClientProxiedBy: TYCP286CA0242.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:456::9) To TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) X-Microsoft-Original-Message-ID: <20230902160741.19197-11-nuomi2021@gmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6433:EE_|TYZPR06MB4030:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d6bbb3c-8583-47ae-fe1b-08dbabced1d7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 54AIx/TyPUHfEVVGYsQkvNfgUllRCIVp8oredFU54+ZK5R2SrjFYuBDeeoQ1eNnmRH6RdpPpepgP4W/tyCIFNSdUTDjIS9bIoalE5Ex9Qj/SIrRplehM177NpM81ETNtgk7nOe8t0kB4247CdrDU94qD5oQ9VMkxKYRG7/gRF2hErxbxq7peaDiovhc+/f3d9WJV9mG6iTqCLuH1123ZvOp1RHWpH4NgAFcD2jfuv3RT0sJ9wp3HDM7AgOJw1IopmdPBnor0WdkkVQpgySgvApUuxsr/Is+eltWJlrFvhCQDJXQVtE/eT8XYoiyTHJxNTSTP0zw8KEqhZG/X0NyImJP61lPH7kWNksqGZjgKRb6LgYclHTIEjBMhCtndZKQBKNOjl8d5dFKrAFY+Rm8dia0fmH+aHAXitgNPjkndNF4fAXv18rflqrgARP+p8L/5YjtOS25uxutuuhupk3oqMy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2PscBNThYmi3EXA9Tg/H4aUk3CF1iChcxHhGarI0knCf?= =?us-ascii?Q?j1Pl5C+NW/ZqpJAvHvW6ZIYG3o3+rrRJw21hmX4X6fe5mpf0+bmr2ZvyR597?= =?us-ascii?Q?vzIZip+erNvBmAew7fnli8vf4FDUNQOmVegcFx44AlBk8wVIC5YpSeZCKBxg?= =?us-ascii?Q?68IvnkvLeEsYldfvw/wxzj46xngW7J7kqdgWiLf5eyXTBxXEB6dJ3/aKMsnv?= =?us-ascii?Q?3nRpmFk6tXfzUpAPK1ixBKgl1jN8tDH21ublS14tDPNrI0tCdUFt1VQRoLNq?= =?us-ascii?Q?4RZLrrRsOUx+IQkCooROkK7F4vy/I9zwlAbT73xuaWXmWumyhUNKrCkfgsQJ?= =?us-ascii?Q?8ohKdDgn3b58HDsdcmftoYM/9NB39ivYslFv9DeixGztDrESJNR/+HokRVJM?= =?us-ascii?Q?HPsmZj7GejMSwsYpI/yL0T9HpJqRglveqZ2CNBWNwBgPPX5XmhsuUm3+4tDM?= =?us-ascii?Q?S6iT0W5Nx8UCLsLmK91cMnjxnJm1g7BWcj8I7IE6ioX/NJjD+NbASoHVLh/P?= =?us-ascii?Q?xwZxNYO7vtuaaWidPVvl8YjHXi2SzcWAgHP41Cfga+HOU8obDxofvCnScVqo?= =?us-ascii?Q?atK0cVwijGu0oQqfbo8b?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d6bbb3c-8583-47ae-fe1b-08dbabced1d7 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6433.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2023 16:08:17.7532 (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: TYZPR06MB4030 Subject: [FFmpeg-devel] [PATCH v3 11/14] vvcdec: add dsp init and inv transform 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 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: --- libavcodec/vvc/Makefile | 1 + libavcodec/vvc/vvcdsp.c | 133 +++++++++++++++++++++++++++++++ libavcodec/vvc/vvcdsp_template.c | 120 ++++++++++++++++++++++++++++ 3 files changed, 254 insertions(+) create mode 100644 libavcodec/vvc/vvcdsp.c create mode 100644 libavcodec/vvc/vvcdsp_template.c diff --git a/libavcodec/vvc/Makefile b/libavcodec/vvc/Makefile index 2559de9429..c2b67ddfc8 100644 --- a/libavcodec/vvc/Makefile +++ b/libavcodec/vvc/Makefile @@ -2,6 +2,7 @@ clean:: $(RM) $(CLEANSUFFIXES:%=libavcodec/vvc/%) OBJS-$(CONFIG_VVC_DECODER) += vvc/vvcdec.o \ + vvc/vvcdsp.o \ vvc/vvc_cabac.o \ vvc/vvc_ctu.o \ vvc/vvc_data.o \ diff --git a/libavcodec/vvc/vvcdsp.c b/libavcodec/vvc/vvcdsp.c new file mode 100644 index 0000000000..e00f05c174 --- /dev/null +++ b/libavcodec/vvc/vvcdsp.c @@ -0,0 +1,133 @@ +/* + * VVC DSP + * + * Copyright (C) 2021 Nuo Mi + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "vvcdsp.h" +#include "vvc_ctu.h" +#include "vvc_itx_1d.h" + +#define VVC_SIGN(v) (v < 0 ? -1 : !!v) + +static void av_always_inline pad_int16(int16_t *_dst, const ptrdiff_t dst_stride, const int width, const int height) +{ + const int padded_width = width + 2; + int16_t *dst; + for (int y = 0; y < height; y++) { + dst = _dst + y * dst_stride; + for (int x = 0; x < width; x++) { + dst[-1] = dst[0]; + dst[width] = dst[width - 1]; + } + } + + _dst--; + //top + memcpy(_dst - dst_stride, _dst, padded_width * sizeof(int16_t)); + //bottom + _dst += dst_stride * height; + memcpy(_dst, _dst - dst_stride, padded_width * sizeof(int16_t)); +} + +static int vvc_sad(const int16_t *src0, const int16_t *src1, int dx, int dy, + const int block_w, const int block_h) +{ + int sad = 0; + dx -= 2; + dy -= 2; + src0 += (2 + dy) * MAX_PB_SIZE + 2 + dx; + src1 += (2 - dy) * MAX_PB_SIZE + 2 - dx; + for (int y = 0; y < block_h; y += 2) { + for (int x = 0; x < block_w; x++) { + sad += FFABS(src0[x] - src1[x]); + } + src0 += 2 * MAX_PB_SIZE; + src1 += 2 * MAX_PB_SIZE; + } + return sad; +} + +#define itx_fn(type, s) \ +static void itx_##type##_##s(int *out, ptrdiff_t out_step, const int *in, ptrdiff_t in_step) \ +{ \ + ff_vvc_inv_##type##_##s(out, out_step, in, in_step); \ +} + +#define itx_fn_common(type) \ + itx_fn(type, 4); \ + itx_fn(type, 8); \ + itx_fn(type, 16); \ + itx_fn(type, 32); \ + +itx_fn_common(dct2); +itx_fn_common(dst7); +itx_fn_common(dct8); +itx_fn(dct2, 2); +itx_fn(dct2, 64); + +typedef struct IntraEdgeParams { + uint8_t* top; + uint8_t* left; + int filter_flag; + + uint16_t left_array[3 * MAX_TB_SIZE + 3]; + uint16_t filtered_left_array[3 * MAX_TB_SIZE + 3]; + uint16_t top_array[3 * MAX_TB_SIZE + 3]; + uint16_t filtered_top_array[3 * MAX_TB_SIZE + 3]; +} IntraEdgeParams; + +#define BIT_DEPTH 8 +#include "vvcdsp_template.c" +#undef BIT_DEPTH + +#define BIT_DEPTH 10 +#include "vvcdsp_template.c" +#undef BIT_DEPTH + +#define BIT_DEPTH 12 +#include "vvcdsp_template.c" +#undef BIT_DEPTH + +void ff_vvc_dsp_init(VVCDSPContext *vvcdsp, int bit_depth) +{ +#undef FUNC +#define FUNC(a, depth) a ## _ ## depth + +#define VVC_DSP(depth) \ + FUNC(ff_vvc_inter_dsp_init, depth)(&vvcdsp->inter); \ + FUNC(ff_vvc_intra_dsp_init, depth)(&vvcdsp->intra); \ + FUNC(ff_vvc_itx_dsp_init, depth)(&vvcdsp->itx); \ + FUNC(ff_vvc_lmcs_dsp_init, depth)(&vvcdsp->lmcs); \ + FUNC(ff_vvc_lf_dsp_init, depth)(&vvcdsp->lf); \ + FUNC(ff_vvc_sao_dsp_init, depth)(&vvcdsp->sao); \ + FUNC(ff_vvc_alf_dsp_init, depth)(&vvcdsp->alf); \ + + switch (bit_depth) { + case 12: + VVC_DSP(12); + break; + case 10: + VVC_DSP(10); + break; + default: + VVC_DSP(8); + break; + } +} diff --git a/libavcodec/vvc/vvcdsp_template.c b/libavcodec/vvc/vvcdsp_template.c new file mode 100644 index 0000000000..a64cf7903f --- /dev/null +++ b/libavcodec/vvc/vvcdsp_template.c @@ -0,0 +1,120 @@ +/* + * VVC transform and residual DSP + * + * Copyright (C) 2021 Nuo Mi + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/bit_depth_template.c" + +#include "vvcdec.h" + +#include "vvc_data.h" +#include "vvc_inter_template.c" +#include "vvc_intra_template.c" +#include "vvc_filter_template.c" + +static void FUNC(add_residual)(uint8_t *_dst, const int *res, + const int w, const int h, const ptrdiff_t _stride) +{ + pixel *dst = (pixel *)_dst; + + const int stride = _stride / sizeof(pixel); + + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + dst[x] = av_clip_pixel(dst[x] + *res); + res++; + } + dst += stride; + } +} + +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 *buf, const int w, const int h, + const int c_sign, const int shift) +{ + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + *buf = ((*buf) * c_sign) >> shift; + buf++; + } + } +} + +static void FUNC(transform_bdpcm)(int *coeffs, const int width, const int height, + const int vertical, const int log2_transform_range) +{ + int x, y; + + if (vertical) { + coeffs += width; + for (y = 0; y < height - 1; y++) { + for (x = 0; x < width; x++) + coeffs[x] = av_clip_intp2(coeffs[x] + coeffs[x - width], log2_transform_range); + coeffs += width; + } + } else { + for (y = 0; y < height; y++) { + for (x = 1; x < width; x++) + coeffs[x] = av_clip_intp2(coeffs[x] + coeffs[x - 1], log2_transform_range); + coeffs += width; + } + } +} + +static void FUNC(ff_vvc_itx_dsp_init)(VVCItxDSPContext *const itx) +{ +#define VVC_ITX(TYPE, type, s) \ + itx->itx[TYPE][TX_SIZE_##s] = itx_##type##_##s; \ + +#define VVC_ITX_COMMON(TYPE, type) \ + VVC_ITX(TYPE, type, 4); \ + VVC_ITX(TYPE, type, 8); \ + VVC_ITX(TYPE, type, 16); \ + 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) + VVC_ITX(DCT2, dct2, 64) + VVC_ITX_COMMON(DCT2, dct2) + VVC_ITX_COMMON(DCT8, dct8) + VVC_ITX_COMMON(DST7, dst7) + +#undef VVC_ITX +#undef VVC_ITX_COMMON +} -- 2.25.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".