From patchwork Mon Jan 22 15:25:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 45709 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:120f:b0:199:de12:6fa6 with SMTP id v15csp44279pzf; Mon, 22 Jan 2024 07:26:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgHPvLi0K4/awZzkKVbWqJq8p+hhwe+9SGFsK9lxzzR40BplmM6IVa2DwnfeCYRtmYdbhz X-Received: by 2002:a05:600c:2055:b0:40e:88be:4ef7 with SMTP id p21-20020a05600c205500b0040e88be4ef7mr2575984wmg.197.1705937161357; Mon, 22 Jan 2024 07:26:01 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ca21-20020a170906a3d500b00a2d226ef487si8616518ejb.463.2024.01.22.07.26.00; Mon, 22 Jan 2024 07:26:01 -0800 (PST) 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=oKHAPf87; 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D782068CFA3; Mon, 22 Jan 2024 17:25:56 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01olkn2050.outbound.protection.outlook.com [40.92.99.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4E5B868C6BB for ; Mon, 22 Jan 2024 17:25:49 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GtdIaSlzvtVtnrlUoOKvVSYP/iXTfCQ4XQRgNRDoMKuFZQN7DzNywl7cFpJhGRY7rThT/g+YFmImYkkynjXlQakpyu/RtVmuwHRlcsPAxivnvCrGB7Wi1FlrKk8m0dSQWloQTvo8ach2P+PHhRRvWa7r2XFvwSd2solm6kMz9Ekne6t3458+1oOdEAwkJlWlMdpDEMiPajXAaTlKULdUy2CUj8MFeBHcID4QCExU7zvvnZ/NjKzheCmKardCYFl+9acZ0gIKh8buh51AXNFxG0cVZMlmAkmZd+G5XCS3A8GCPzfQEfm//SJ/VLz0SKrKSuViyo0hlKGp9LSTcAmaIg== 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=+kDushbViWZ6mfCHewVHfueru+uP06YgpwwE43O4dCU=; b=XBtQZKmTprjxRTZ3gOuOUeXu38X7T1Wwu198769QMHjVyU8GpeODzpFuweiCOXgJMr5oZCWmr+PKSIbKSkQ6mFYNaAW+WKoj2pZXUkMSHsLONeYHR0Uc9eULUAbEI9oGQO591rpH9vUAdzk9Vh1r41ZGu+ppJZKa/KPmJdGXpuJ0Fyr5ucTToT1KwkWhZRqUhWk9hW0Xne6EnTBfj1NeRwl0kdhqgS73hzZB4hrkQBCXJmhuxNeUfdHVRS1IPe+stkOuy9KN0hIZl8DaxUZY3MYWTdzDROT1dSeJORY6VcrG533bjERQY3HETao1/40GwAuukcR+i+JWhxwklCboOA== 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=+kDushbViWZ6mfCHewVHfueru+uP06YgpwwE43O4dCU=; b=oKHAPf87iRKIj8Gbl3M2QFpYtn293W1VS5hs8ON38vHwkGgfccXBtUZXZ4QLEqaydMBP53HliIGV6QTqOIh73Iv8aB0COnAuIMs/xze+VdG1Hua7f5z/9OTdU17MyUWL66NxUci3F9hAhVnNFgpgaRWzEmXkr+YL8/5wVlDM+7/DwQXTD1muQPiVmLP/yRneO3Yy78dIWaOo+dR05TUWdndDw7tyoUBYPRfCVv2uveKAmrFhfFhsPZXmtxK+6oxGwtTDX5ZhpfCYHVynG5k36QiYz0KemvgMnI1mfkCAelO0nBMBF1LCkTvZvLyoWdbaqCZnjFkx8t1VmPY3q/zKmQ== Received: from OSZP286MB2173.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:186::5) by TYCP286MB1682.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:184::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.36; Mon, 22 Jan 2024 15:25:43 +0000 Received: from OSZP286MB2173.JPNP286.PROD.OUTLOOK.COM ([fe80::86fc:6255:f4c1:a076]) by OSZP286MB2173.JPNP286.PROD.OUTLOOK.COM ([fe80::86fc:6255:f4c1:a076%3]) with mapi id 15.20.7202.035; Mon, 22 Jan 2024 15:25:43 +0000 From: toqsxw@outlook.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Jan 2024 23:25:20 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [yfwNYhRUT7sSbiFiZlzPg4kF6KgHZAzM] X-ClientProxiedBy: SI1PR02CA0022.apcprd02.prod.outlook.com (2603:1096:4:1f4::16) To OSZP286MB2173.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:186::5) X-Microsoft-Original-Message-ID: <20240122152527.601122-1-toqsxw@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OSZP286MB2173:EE_|TYCP286MB1682:EE_ X-MS-Office365-Filtering-Correlation-Id: 66366b31-ca55-4969-ccea-08dc1b5e65f8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jlcxpI7X2u9N0hbbs4Vio9I3wuxNGeR5oKKwaIHU0zXM9Px68HfoeufyfQ1OFKs9UUc+ASwfyU7F41IART2BloS2z7jB8dt5lhtJVp9foG7OU8mSzlW1dVxVPdhXMQxcSvo+UvAHjq48UdFfy1zCPp1k1+vbr3I3quXWmp1aEV4Yr7kY+izQ7MuB9uemUp3dEFCqqJoAAOEBib6w/tY46UwGovNWnfLXvA8utfMbd5bqG1RsNLs+B4ninEMBL7FDV0byvJ6H4y/+15UZDd59/DbFwIDI/PoYH9Xqa3jExZY4L/dcqBoaR2h7jQUmr/v/uRobA+Tkaah/oi64ekFKLO5LYkZcfvKVh0IOzs4j4BJT6XRZmR/laTbJkUzPpoDZIC6UP/rAguZS/srkU7tB7M8SF8scKWGEy99eOMd5K8shIkW7BBz5sFSAlZMM2zz/ZZu76eDVyhSTK7oKHjmn2U7Mu781yS4Zy6gxMcqjnpi/3JGVHn0REvmD1U82293lM4tfaX2mDMTMohuPZWWNNdTW15lJ6GZjZVt8gD4eyPn01Ia1ONK2TK0zOio/At0yk3fJ1EniHXMwBYAT+Pur5R6KK11rKFWN98rIip6+n2wNraRl3qJI4m+D9OYNXQNR X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +E7EXwmpPt0Pidhk0XqVzaRKWpptb2ttuFDKLyWWj8sXD9K3jhTUedP8WDUcV2uQWhh6lG3f3kACoouGRVahnR1MTt4oOu4xIHFTL5k9+2gxv7Eu0MVKbJodf5X02YJXgi3YAERR4lXEtIIbMaxT3VFm3w6GRcU+vYHGQjX27ob8VAjTGy3+vkFi4r7wqZiwRXwFouIrBWRRTjXwt+5g6ZPZQuh/x92zF3klWrYvQpkKygJicAgGc2yc5bSa7aF2EvDq+rB6MYY13REHbhEYAQCSGpSChq6aqaIhsTaQayeTKeVd0q47wI/654nh7tinraH0/osAcKKK9nNUa2+rIXCMIBShwfNjg9dHzWDLQxYWQWaFzblCmoUjL779KnKb1fHV9iRSMk+rbUqkYcVMhzfQYTeyjIBthW/mfLmSTOLlQGNemI8woR2xKaEvKlxWzz2uzj3D8u5cZzmhDtDdLlstLPrGLSc7rh7ZJ+3yZq4Um4uYJC7sZmZjq21skHmd+eGNBE8R7O1snawCZiYNn1xXDsOJf+0mmDWhPxlycVM0HKZmCaeBfZeKd9JZ8FJHZgOyUZ1YrVMvMrMiDdDy9uN8jGvt95jcJzXbK40fDyhfalJImuNwYLXPW2tR6JoZFViVRrlNQafypHhvMFvFudeTJtmqX9OPonn2zMp6hcEUGnsGCN9WeO9opC2He9DqiksGDfGZunap3CgmCEk0RnOiwYUiycg5m4llYvWdIjBIoz5+bO3Lc8/4WeTvmFDMWt0LyzDSX4+xaR0yZCHiXdw4McvZmO3XRKSQjYgkWTA/CAIIquQMaui3o15kiQUUmsWHkFDWkiMdIWBoIlBrV9Qi9cGE41zjsU6hOJZ+hRaIO6uofb/UkXI+SqZM+BB8y54iGWsf+v8QmYmc5/vJvMGZdYS3s3OWMMvv7Ewcr0yXsfaN4PKmWq1dbYqhLJe2Eh0mHzmRBXPWiFOYgJFH1VcZLGPqTDv4bnZXhgWHCUCp12PNVmhh1YfYQkU2xf/xjPRXnX8a4TkC0/KwMDyiLeVzoRMfvELrl1wmnXqfwfSwSboljavf9GWQLcVnpfhqIwQpjZoMimfdz15yc3ZeJIZDeSdgGgLDOrxmExkV/Of8g28VRJ4VRR4NJO4i84AaCmzI5WTkm0nWsH2QHDzrQgq6CfADrIloTBdvh8x1BmZosNpX+Y6qWbDUZYof51nFiFCz2LkfpM+3mqIBPO2i44Cod+ZO+kbhfJapxTxFN2M= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66366b31-ca55-4969-ccea-08dc1b5e65f8 X-MS-Exchange-CrossTenant-AuthSource: OSZP286MB2173.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2024 15:25:43.4722 (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: TYCP286MB1682 Subject: [FFmpeg-devel] [PATCH v3 1/8] avcodec/vvc/vvc_inter_template: move put/put_luma/put_chroma template to h2656_inter_template.c 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: Wu Jianhua Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: gKA78iTwkGJ2 From: Wu Jianhua Signed-off-by: Wu Jianhua --- libavcodec/h26x/h2656_inter_template.c | 577 +++++++++++++++++++++++++ libavcodec/vvc/vvc_inter_template.c | 559 +----------------------- 2 files changed, 578 insertions(+), 558 deletions(-) create mode 100644 libavcodec/h26x/h2656_inter_template.c diff --git a/libavcodec/h26x/h2656_inter_template.c b/libavcodec/h26x/h2656_inter_template.c new file mode 100644 index 0000000000..864f6c7e7d --- /dev/null +++ b/libavcodec/h26x/h2656_inter_template.c @@ -0,0 +1,577 @@ +/* + * inter prediction template for HEVC/VVC + * + * Copyright (C) 2022 Nuo Mi + * Copyright (C) 2024 Wu Jianhua + * + * 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 + */ + +#define CHROMA_EXTRA_BEFORE 1 +#define CHROMA_EXTRA 3 +#define LUMA_EXTRA_BEFORE 3 +#define LUMA_EXTRA 7 + +static void FUNC(put_pixels)(int16_t *dst, + const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + const pixel *src = (const pixel *)_src; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = src[x] << (14 - BIT_DEPTH); + src += src_stride; + dst += MAX_PB_SIZE; + } +} + +static void FUNC(put_uni_pixels)(uint8_t *_dst, const ptrdiff_t _dst_stride, + const uint8_t *_src, const ptrdiff_t _src_stride, const int height, + const int8_t *hf, const int8_t *vf, const int width) +{ + const pixel *src = (const pixel *)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + + for (int y = 0; y < height; y++) { + memcpy(dst, src, width * sizeof(pixel)); + src += src_stride; + dst += dst_stride; + } +} + +static void FUNC(put_uni_w_pixels)(uint8_t *_dst, const ptrdiff_t _dst_stride, + const uint8_t *_src, const ptrdiff_t _src_stride, const int height, + const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, + const int width) +{ + const pixel *src = (const pixel *)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const int shift = denom + 14 - BIT_DEPTH; +#if BIT_DEPTH < 14 + const int offset = 1 << (shift - 1); +#else + const int offset = 0; +#endif + const int ox = _ox * (1 << (BIT_DEPTH - 8)); + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + const int v = (src[x] << (14 - BIT_DEPTH)); + dst[x] = av_clip_pixel(((v * wx + offset) >> shift) + ox); + } + src += src_stride; + dst += dst_stride; + } +} + +#define LUMA_FILTER(src, stride) \ + (filter[0] * src[x - 3 * stride] + \ + filter[1] * src[x - 2 * stride] + \ + filter[2] * src[x - stride] + \ + filter[3] * src[x ] + \ + filter[4] * src[x + stride] + \ + filter[5] * src[x + 2 * stride] + \ + filter[6] * src[x + 3 * stride] + \ + filter[7] * src[x + 4 * stride]) + +static void FUNC(put_luma_h)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + const pixel *src = (const pixel*)_src; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const int8_t *filter = hf; + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8); + src += src_stride; + dst += MAX_PB_SIZE; + } +} + +static void FUNC(put_luma_v)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + const pixel *src = (pixel*)_src; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const int8_t *filter = vf; + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8); + src += src_stride; + dst += MAX_PB_SIZE; + } +} + +static void FUNC(put_luma_hv)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE]; + int16_t *tmp = tmp_array; + const pixel *src = (const pixel*)_src; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const int8_t *filter = hf; + + src -= LUMA_EXTRA_BEFORE * src_stride; + for (int y = 0; y < height + LUMA_EXTRA; y++) { + for (int x = 0; x < width; x++) + tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8); + src += src_stride; + tmp += MAX_PB_SIZE; + } + + tmp = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE; + filter = vf; + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6; + tmp += MAX_PB_SIZE; + dst += MAX_PB_SIZE; + } +} + +static void FUNC(put_uni_luma_h)(uint8_t *_dst, const ptrdiff_t _dst_stride, + const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + const pixel *src = (const pixel*)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const int8_t *filter = hf; + const int shift = 14 - BIT_DEPTH; +#if BIT_DEPTH < 14 + const int offset = 1 << (shift - 1); +#else + const int offset = 0; +#endif + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + const int val = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8); + dst[x] = av_clip_pixel((val + offset) >> shift); + } + src += src_stride; + dst += dst_stride; + } +} + +static void FUNC(put_uni_luma_v)(uint8_t *_dst, const ptrdiff_t _dst_stride, + const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + + const pixel *src = (const pixel*)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const int8_t *filter = vf; + const int shift = 14 - BIT_DEPTH; +#if BIT_DEPTH < 14 + const int offset = 1 << (shift - 1); +#else + const int offset = 0; +#endif + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + const int val = LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8); + dst[x] = av_clip_pixel((val + offset) >> shift); + } + src += src_stride; + dst += dst_stride; + } +} + +static void FUNC(put_uni_luma_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride, + const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE]; + int16_t *tmp = tmp_array; + const pixel *src = (const pixel*)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const int8_t *filter = hf; + const int shift = 14 - BIT_DEPTH; +#if BIT_DEPTH < 14 + const int offset = 1 << (shift - 1); +#else + const int offset = 0; +#endif + + src -= LUMA_EXTRA_BEFORE * src_stride; + for (int y = 0; y < height + LUMA_EXTRA; y++) { + for (int x = 0; x < width; x++) + tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8); + src += src_stride; + tmp += MAX_PB_SIZE; + } + + tmp = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE; + filter = vf; + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + const int val = LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6; + dst[x] = av_clip_pixel((val + offset) >> shift); + } + tmp += MAX_PB_SIZE; + dst += dst_stride; + } + +} + +static void FUNC(put_uni_luma_w_h)(uint8_t *_dst, const ptrdiff_t _dst_stride, + const uint8_t *_src, const ptrdiff_t _src_stride, int height, + const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, + const int width) +{ + const pixel *src = (const pixel*)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const int8_t *filter = hf; + const int ox = _ox * (1 << (BIT_DEPTH - 8)); + const int shift = denom + 14 - BIT_DEPTH; +#if BIT_DEPTH < 14 + const int offset = 1 << (shift - 1); +#else + const int offset = 0; +#endif + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = av_clip_pixel((((LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox); + src += src_stride; + dst += dst_stride; + } +} + +static void FUNC(put_uni_luma_w_v)(uint8_t *_dst, const ptrdiff_t _dst_stride, + const uint8_t *_src, const ptrdiff_t _src_stride, const int height, + const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, + const int width) +{ + const pixel *src = (const pixel*)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const int8_t *filter = vf; + const int ox = _ox * (1 << (BIT_DEPTH - 8)); + const int shift = denom + 14 - BIT_DEPTH; +#if BIT_DEPTH < 14 + const int offset = 1 << (shift - 1); +#else + const int offset = 0; +#endif + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = av_clip_pixel((((LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox); + src += src_stride; + dst += dst_stride; + } +} + +static void FUNC(put_uni_luma_w_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride, + const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int denom, + const int wx, const int _ox, const int8_t *hf, const int8_t *vf, const int width) +{ + int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE]; + int16_t *tmp = tmp_array; + const pixel *src = (const pixel*)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const int8_t *filter = hf; + const int ox = _ox * (1 << (BIT_DEPTH - 8)); + const int shift = denom + 14 - BIT_DEPTH; +#if BIT_DEPTH < 14 + const int offset = 1 << (shift - 1); +#else + const int offset = 0; +#endif + + src -= LUMA_EXTRA_BEFORE * src_stride; + for (int y = 0; y < height + LUMA_EXTRA; y++) { + for (int x = 0; x < width; x++) + tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8); + src += src_stride; + tmp += MAX_PB_SIZE; + } + + tmp = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE; + filter = vf; + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = av_clip_pixel((((LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox); + tmp += MAX_PB_SIZE; + dst += dst_stride; + } +} + +#define CHROMA_FILTER(src, stride) \ + (filter[0] * src[x - stride] + \ + filter[1] * src[x] + \ + filter[2] * src[x + stride] + \ + filter[3] * src[x + 2 * stride]) + +static void FUNC(put_chroma_h)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + const pixel *src = (const pixel *)_src; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const int8_t *filter = hf; + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8); + src += src_stride; + dst += MAX_PB_SIZE; + } +} + +static void FUNC(put_chroma_v)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + const pixel *src = (const pixel *)_src; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const int8_t *filter = vf; + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8); + src += src_stride; + dst += MAX_PB_SIZE; + } +} + +static void FUNC(put_chroma_hv)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE]; + int16_t *tmp = tmp_array; + const pixel *src = (const pixel *)_src; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const int8_t *filter = hf; + + src -= CHROMA_EXTRA_BEFORE * src_stride; + + for (int y = 0; y < height + CHROMA_EXTRA; y++) { + for (int x = 0; x < width; x++) + tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8); + src += src_stride; + tmp += MAX_PB_SIZE; + } + + tmp = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE; + filter = vf; + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6; + tmp += MAX_PB_SIZE; + dst += MAX_PB_SIZE; + } +} + +static void FUNC(put_uni_chroma_h)(uint8_t *_dst, const ptrdiff_t _dst_stride, + const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + const pixel *src = (const pixel *)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const int8_t *filter = hf; + const int shift = 14 - BIT_DEPTH; +#if BIT_DEPTH < 14 + const int offset = 1 << (shift - 1); +#else + const int offset = 0; +#endif + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = av_clip_pixel(((CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) + offset) >> shift); + src += src_stride; + dst += dst_stride; + } +} + +static void FUNC(put_uni_chroma_v)(uint8_t *_dst, const ptrdiff_t _dst_stride, + const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + const pixel *src = (const pixel *)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const int8_t *filter = vf; + const int shift = 14 - BIT_DEPTH; +#if BIT_DEPTH < 14 + const int offset = 1 << (shift - 1); +#else + const int offset = 0; +#endif + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = av_clip_pixel(((CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) + offset) >> shift); + src += src_stride; + dst += dst_stride; + } +} + +static void FUNC(put_uni_chroma_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride, + const uint8_t *_src, const ptrdiff_t _src_stride, + const int height, const int8_t *hf, const int8_t *vf, const int width) +{ + int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE]; + int16_t *tmp = tmp_array; + const pixel *src = (const pixel *)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const int8_t *filter = hf; + const int shift = 14 - BIT_DEPTH; +#if BIT_DEPTH < 14 + const int offset = 1 << (shift - 1); +#else + const int offset = 0; +#endif + + src -= CHROMA_EXTRA_BEFORE * src_stride; + + for (int y = 0; y < height + CHROMA_EXTRA; y++) { + for (int x = 0; x < width; x++) + tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8); + src += src_stride; + tmp += MAX_PB_SIZE; + } + + tmp = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE; + filter = vf; + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = av_clip_pixel(((CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6) + offset) >> shift); + tmp += MAX_PB_SIZE; + dst += dst_stride; + } +} + +static void FUNC(put_uni_chroma_w_h)(uint8_t *_dst, ptrdiff_t _dst_stride, + const uint8_t *_src, ptrdiff_t _src_stride, int height, int denom, int wx, int ox, + const int8_t *hf, const int8_t *vf, int width) +{ + const pixel *src = (const pixel *)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const int8_t *filter = hf; + const int shift = denom + 14 - BIT_DEPTH; +#if BIT_DEPTH < 14 + const int offset = 1 << (shift - 1); +#else + const int offset = 0; +#endif + + ox = ox * (1 << (BIT_DEPTH - 8)); + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + dst[x] = av_clip_pixel((((CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox); + } + dst += dst_stride; + src += src_stride; + } +} + +static void FUNC(put_uni_chroma_w_v)(uint8_t *_dst, const ptrdiff_t _dst_stride, + const uint8_t *_src, const ptrdiff_t _src_stride, const int height, + const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, + const int width) +{ + const pixel *src = (const pixel *)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const int8_t *filter = vf; + const int shift = denom + 14 - BIT_DEPTH; + const int ox = _ox * (1 << (BIT_DEPTH - 8)); +#if BIT_DEPTH < 14 + int offset = 1 << (shift - 1); +#else + int offset = 0; +#endif + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + dst[x] = av_clip_pixel((((CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox); + } + dst += dst_stride; + src += src_stride; + } +} + +static void FUNC(put_uni_chroma_w_hv)(uint8_t *_dst, ptrdiff_t _dst_stride, + const uint8_t *_src, ptrdiff_t _src_stride, int height, int denom, int wx, int ox, + const int8_t *hf, const int8_t *vf, int width) +{ + int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE]; + int16_t *tmp = tmp_array; + const pixel *src = (const pixel *)_src; + pixel *dst = (pixel *)_dst; + const ptrdiff_t src_stride = _src_stride / sizeof(pixel); + const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); + const int8_t *filter = hf; + const int shift = denom + 14 - BIT_DEPTH; +#if BIT_DEPTH < 14 + const int offset = 1 << (shift - 1); +#else + const int offset = 0; +#endif + + src -= CHROMA_EXTRA_BEFORE * src_stride; + + for (int y = 0; y < height + CHROMA_EXTRA; y++) { + for (int x = 0; x < width; x++) + tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8); + src += src_stride; + tmp += MAX_PB_SIZE; + } + + tmp = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE; + filter = vf; + + ox = ox * (1 << (BIT_DEPTH - 8)); + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + dst[x] = av_clip_pixel((((CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox); + tmp += MAX_PB_SIZE; + dst += dst_stride; + } +} diff --git a/libavcodec/vvc/vvc_inter_template.c b/libavcodec/vvc/vvc_inter_template.c index b67b66a2dc..9a9284a9a5 100644 --- a/libavcodec/vvc/vvc_inter_template.c +++ b/libavcodec/vvc/vvc_inter_template.c @@ -20,564 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -static void FUNC(put_pixels)(int16_t *dst, - const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - const pixel *src = (const pixel *)_src; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = src[x] << (14 - BIT_DEPTH); - src += src_stride; - dst += MAX_PB_SIZE; - } -} - -static void FUNC(put_uni_pixels)(uint8_t *_dst, const ptrdiff_t _dst_stride, - const uint8_t *_src, const ptrdiff_t _src_stride, const int height, - const int8_t *hf, const int8_t *vf, const int width) -{ - const pixel *src = (const pixel *)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - - for (int y = 0; y < height; y++) { - memcpy(dst, src, width * sizeof(pixel)); - src += src_stride; - dst += dst_stride; - } -} - -static void FUNC(put_uni_w_pixels)(uint8_t *_dst, const ptrdiff_t _dst_stride, - const uint8_t *_src, const ptrdiff_t _src_stride, const int height, - const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, - const int width) -{ - const pixel *src = (const pixel *)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const int shift = denom + 14 - BIT_DEPTH; -#if BIT_DEPTH < 14 - const int offset = 1 << (shift - 1); -#else - const int offset = 0; -#endif - const int ox = _ox * (1 << (BIT_DEPTH - 8)); - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - const int v = (src[x] << (14 - BIT_DEPTH)); - dst[x] = av_clip_pixel(((v * wx + offset) >> shift) + ox); - } - src += src_stride; - dst += dst_stride; - } -} - -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -#define LUMA_FILTER(src, stride) \ - (filter[0] * src[x - 3 * stride] + \ - filter[1] * src[x - 2 * stride] + \ - filter[2] * src[x - stride] + \ - filter[3] * src[x ] + \ - filter[4] * src[x + stride] + \ - filter[5] * src[x + 2 * stride] + \ - filter[6] * src[x + 3 * stride] + \ - filter[7] * src[x + 4 * stride]) - -static void FUNC(put_luma_h)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - const pixel *src = (const pixel*)_src; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const int8_t *filter = hf; - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8); - src += src_stride; - dst += MAX_PB_SIZE; - } -} - -static void FUNC(put_luma_v)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - const pixel *src = (pixel*)_src; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const int8_t *filter = vf; - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8); - src += src_stride; - dst += MAX_PB_SIZE; - } -} - -static void FUNC(put_luma_hv)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE]; - int16_t *tmp = tmp_array; - const pixel *src = (const pixel*)_src; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const int8_t *filter = hf; - - src -= LUMA_EXTRA_BEFORE * src_stride; - for (int y = 0; y < height + LUMA_EXTRA; y++) { - for (int x = 0; x < width; x++) - tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8); - src += src_stride; - tmp += MAX_PB_SIZE; - } - - tmp = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE; - filter = vf; - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6; - tmp += MAX_PB_SIZE; - dst += MAX_PB_SIZE; - } -} - -static void FUNC(put_uni_luma_h)(uint8_t *_dst, const ptrdiff_t _dst_stride, - const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - const pixel *src = (const pixel*)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const int8_t *filter = hf; - const int shift = 14 - BIT_DEPTH; -#if BIT_DEPTH < 14 - const int offset = 1 << (shift - 1); -#else - const int offset = 0; -#endif - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - const int val = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8); - dst[x] = av_clip_pixel((val + offset) >> shift); - } - src += src_stride; - dst += dst_stride; - } -} - -static void FUNC(put_uni_luma_v)(uint8_t *_dst, const ptrdiff_t _dst_stride, - const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - - const pixel *src = (const pixel*)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const int8_t *filter = vf; - const int shift = 14 - BIT_DEPTH; -#if BIT_DEPTH < 14 - const int offset = 1 << (shift - 1); -#else - const int offset = 0; -#endif - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - const int val = LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8); - dst[x] = av_clip_pixel((val + offset) >> shift); - } - src += src_stride; - dst += dst_stride; - } -} - -static void FUNC(put_uni_luma_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride, - const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE]; - int16_t *tmp = tmp_array; - const pixel *src = (const pixel*)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const int8_t *filter = hf; - const int shift = 14 - BIT_DEPTH; -#if BIT_DEPTH < 14 - const int offset = 1 << (shift - 1); -#else - const int offset = 0; -#endif - - src -= LUMA_EXTRA_BEFORE * src_stride; - for (int y = 0; y < height + LUMA_EXTRA; y++) { - for (int x = 0; x < width; x++) - tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8); - src += src_stride; - tmp += MAX_PB_SIZE; - } - - tmp = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE; - filter = vf; - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - const int val = LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6; - dst[x] = av_clip_pixel((val + offset) >> shift); - } - tmp += MAX_PB_SIZE; - dst += dst_stride; - } - -} - -static void FUNC(put_uni_luma_w_h)(uint8_t *_dst, const ptrdiff_t _dst_stride, - const uint8_t *_src, const ptrdiff_t _src_stride, int height, - const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, - const int width) -{ - const pixel *src = (const pixel*)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const int8_t *filter = hf; - const int ox = _ox * (1 << (BIT_DEPTH - 8)); - const int shift = denom + 14 - BIT_DEPTH; -#if BIT_DEPTH < 14 - const int offset = 1 << (shift - 1); -#else - const int offset = 0; -#endif - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = av_clip_pixel((((LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox); - src += src_stride; - dst += dst_stride; - } -} - -static void FUNC(put_uni_luma_w_v)(uint8_t *_dst, const ptrdiff_t _dst_stride, - const uint8_t *_src, const ptrdiff_t _src_stride, const int height, - const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, - const int width) -{ - const pixel *src = (const pixel*)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const int8_t *filter = vf; - const int ox = _ox * (1 << (BIT_DEPTH - 8)); - const int shift = denom + 14 - BIT_DEPTH; -#if BIT_DEPTH < 14 - const int offset = 1 << (shift - 1); -#else - const int offset = 0; -#endif - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = av_clip_pixel((((LUMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox); - src += src_stride; - dst += dst_stride; - } -} - -static void FUNC(put_uni_luma_w_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride, - const uint8_t *_src, const ptrdiff_t _src_stride, const int height, const int denom, - const int wx, const int _ox, const int8_t *hf, const int8_t *vf, const int width) -{ - int16_t tmp_array[(MAX_PB_SIZE + LUMA_EXTRA) * MAX_PB_SIZE]; - int16_t *tmp = tmp_array; - const pixel *src = (const pixel*)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const int8_t *filter = hf; - const int ox = _ox * (1 << (BIT_DEPTH - 8)); - const int shift = denom + 14 - BIT_DEPTH; -#if BIT_DEPTH < 14 - const int offset = 1 << (shift - 1); -#else - const int offset = 0; -#endif - - src -= LUMA_EXTRA_BEFORE * src_stride; - for (int y = 0; y < height + LUMA_EXTRA; y++) { - for (int x = 0; x < width; x++) - tmp[x] = LUMA_FILTER(src, 1) >> (BIT_DEPTH - 8); - src += src_stride; - tmp += MAX_PB_SIZE; - } - - tmp = tmp_array + LUMA_EXTRA_BEFORE * MAX_PB_SIZE; - filter = vf; - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = av_clip_pixel((((LUMA_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox); - tmp += MAX_PB_SIZE; - dst += dst_stride; - } -} - -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -#define CHROMA_FILTER(src, stride) \ - (filter[0] * src[x - stride] + \ - filter[1] * src[x] + \ - filter[2] * src[x + stride] + \ - filter[3] * src[x + 2 * stride]) - -static void FUNC(put_chroma_h)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - const pixel *src = (const pixel *)_src; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const int8_t *filter = hf; - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8); - src += src_stride; - dst += MAX_PB_SIZE; - } -} - -static void FUNC(put_chroma_v)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - const pixel *src = (const pixel *)_src; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const int8_t *filter = vf; - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8); - src += src_stride; - dst += MAX_PB_SIZE; - } -} - -static void FUNC(put_chroma_hv)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE]; - int16_t *tmp = tmp_array; - const pixel *src = (const pixel *)_src; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const int8_t *filter = hf; - - src -= CHROMA_EXTRA_BEFORE * src_stride; - - for (int y = 0; y < height + CHROMA_EXTRA; y++) { - for (int x = 0; x < width; x++) - tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8); - src += src_stride; - tmp += MAX_PB_SIZE; - } - - tmp = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE; - filter = vf; - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6; - tmp += MAX_PB_SIZE; - dst += MAX_PB_SIZE; - } -} - -static void FUNC(put_uni_chroma_h)(uint8_t *_dst, const ptrdiff_t _dst_stride, - const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - const pixel *src = (const pixel *)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const int8_t *filter = hf; - const int shift = 14 - BIT_DEPTH; -#if BIT_DEPTH < 14 - const int offset = 1 << (shift - 1); -#else - const int offset = 0; -#endif - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = av_clip_pixel(((CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) + offset) >> shift); - src += src_stride; - dst += dst_stride; - } -} - -static void FUNC(put_uni_chroma_v)(uint8_t *_dst, const ptrdiff_t _dst_stride, - const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - const pixel *src = (const pixel *)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const int8_t *filter = vf; - const int shift = 14 - BIT_DEPTH; -#if BIT_DEPTH < 14 - const int offset = 1 << (shift - 1); -#else - const int offset = 0; -#endif - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = av_clip_pixel(((CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) + offset) >> shift); - src += src_stride; - dst += dst_stride; - } -} - -static void FUNC(put_uni_chroma_hv)(uint8_t *_dst, const ptrdiff_t _dst_stride, - const uint8_t *_src, const ptrdiff_t _src_stride, - const int height, const int8_t *hf, const int8_t *vf, const int width) -{ - int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE]; - int16_t *tmp = tmp_array; - const pixel *src = (const pixel *)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const int8_t *filter = hf; - const int shift = 14 - BIT_DEPTH; -#if BIT_DEPTH < 14 - const int offset = 1 << (shift - 1); -#else - const int offset = 0; -#endif - - src -= CHROMA_EXTRA_BEFORE * src_stride; - - for (int y = 0; y < height + CHROMA_EXTRA; y++) { - for (int x = 0; x < width; x++) - tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8); - src += src_stride; - tmp += MAX_PB_SIZE; - } - - tmp = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE; - filter = vf; - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = av_clip_pixel(((CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6) + offset) >> shift); - tmp += MAX_PB_SIZE; - dst += dst_stride; - } -} - -static void FUNC(put_uni_chroma_w_h)(uint8_t *_dst, ptrdiff_t _dst_stride, - const uint8_t *_src, ptrdiff_t _src_stride, int height, int denom, int wx, int ox, - const int8_t *hf, const int8_t *vf, int width) -{ - const pixel *src = (const pixel *)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const int8_t *filter = hf; - const int shift = denom + 14 - BIT_DEPTH; -#if BIT_DEPTH < 14 - const int offset = 1 << (shift - 1); -#else - const int offset = 0; -#endif - - ox = ox * (1 << (BIT_DEPTH - 8)); - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - dst[x] = av_clip_pixel((((CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox); - } - dst += dst_stride; - src += src_stride; - } -} - -static void FUNC(put_uni_chroma_w_v)(uint8_t *_dst, const ptrdiff_t _dst_stride, - const uint8_t *_src, const ptrdiff_t _src_stride, const int height, - const int denom, const int wx, const int _ox, const int8_t *hf, const int8_t *vf, - const int width) -{ - const pixel *src = (const pixel *)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const int8_t *filter = vf; - const int shift = denom + 14 - BIT_DEPTH; - const int ox = _ox * (1 << (BIT_DEPTH - 8)); -#if BIT_DEPTH < 14 - int offset = 1 << (shift - 1); -#else - int offset = 0; -#endif - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - dst[x] = av_clip_pixel((((CHROMA_FILTER(src, src_stride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox); - } - dst += dst_stride; - src += src_stride; - } -} - -static void FUNC(put_uni_chroma_w_hv)(uint8_t *_dst, ptrdiff_t _dst_stride, - const uint8_t *_src, ptrdiff_t _src_stride, int height, int denom, int wx, int ox, - const int8_t *hf, const int8_t *vf, int width) -{ - int16_t tmp_array[(MAX_PB_SIZE + CHROMA_EXTRA) * MAX_PB_SIZE]; - int16_t *tmp = tmp_array; - const pixel *src = (const pixel *)_src; - pixel *dst = (pixel *)_dst; - const ptrdiff_t src_stride = _src_stride / sizeof(pixel); - const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel); - const int8_t *filter = hf; - const int shift = denom + 14 - BIT_DEPTH; -#if BIT_DEPTH < 14 - const int offset = 1 << (shift - 1); -#else - const int offset = 0; -#endif - - src -= CHROMA_EXTRA_BEFORE * src_stride; - - for (int y = 0; y < height + CHROMA_EXTRA; y++) { - for (int x = 0; x < width; x++) - tmp[x] = CHROMA_FILTER(src, 1) >> (BIT_DEPTH - 8); - src += src_stride; - tmp += MAX_PB_SIZE; - } - - tmp = tmp_array + CHROMA_EXTRA_BEFORE * MAX_PB_SIZE; - filter = vf; - - ox = ox * (1 << (BIT_DEPTH - 8)); - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - dst[x] = av_clip_pixel((((CHROMA_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox); - tmp += MAX_PB_SIZE; - dst += dst_stride; - } -} +#include "libavcodec/h26x/h2656_inter_template.c" static void FUNC(avg)(uint8_t *_dst, const ptrdiff_t _dst_stride, const int16_t *src0, const int16_t *src1, const int width, const int height)