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 1E1C847F9F for ; Sat, 6 Jan 2024 10:52:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1B92568CA1F; Sat, 6 Jan 2024 12:52:26 +0200 (EET) Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01olkn2107.outbound.protection.outlook.com [40.92.52.107]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C641F68CA1F for ; Sat, 6 Jan 2024 12:52:18 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F2w60VrgnCH6o55akqz8mLHMMuzhIbP+kjEySPdVTuPvFN6EkzIdkwqpRoZJMDmEaz9bfsNfrQdt0YghhgLW3mlR9KBSNAENq2G7tkDWEUatSAHkU7P1PebzHjKZI5m5RZw3l5FnSf38st0MBZ5aSOb4SgyDK8oWvZZcDY9COHsKtOgopje8+pcuzuHiYdL3Mm/bwW5/ApY+Br8viGlCDQKU0FZVzP+R4gOrG5R+2Ne00vAViuRnh0WcmDGy8eM6N18tZPPNUP5iLaf5+bZYkT5Zk+vOfZhJGut7HiWJXlHuxmTD703WALEAIBh6dCN68kRuVDkiT8r5Mg77DvyhJQ== 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=vp5zkm41L4dGugHsp1jS19SCSjTarSqPO+oG/UxRDbM=; b=kgE9/od9PEXxlGSICudhoriidhvC/2bSnx9DcWPnJ9Dukvu7nwmoUaQ55ZRSRl6160oBIqyIhUi+uBHbTKJeJquyNsKK3GEfGYlJH6ilab7ogYOoFDp5+FGsaIfltVM7xMkCyqPgQ+PP6uR0pwVrHkck+wH34RiWff8IKSMUfG7OR8HH67ulyxN9zMPcH/UoyyiAdeRW2Wy76NS+dWEw+tMSWOX9c7YkLQB781dsD7BzHs1Amy1Bd6Lx3Ek3xErZ5EqrNdVYG9b9+N7Lvhh33KZAtyic7JAf8z/3YDPtsuZeksKdvotyu51OFOFDHQApJ75zvyeRydCEwNoIGN7f0A== 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=vp5zkm41L4dGugHsp1jS19SCSjTarSqPO+oG/UxRDbM=; b=r1oNLfWQQwleVGTPij3iJp23iBwrc4sCbssju9eRUFUw2sKvotTAYxDJYMMbDHQguKc0Wxv0r6jFgs8jtuMGpNa0NsDsI52yVnXhFG8ByJhYG4+J+x4FzzUHMN/qkWE6kGcp8DIfz2XI11QBg2onQKuO8NRfI7/B1xVZTCKyUVmIIkeJSPTGzY9DkOiWc6OG715y0V3ePCTtaDspHsihOeLdRPQGoXVOpMbXHF0CQIW5qYqkBuTn0emkoNDI5whu4JwOaaU0lNowUeiy1KyPLdo/XAUsgwk318/JDfCg0l+7+JGZWQgKUbvx2pGHREANd9Hqs9gzhMXt9CNVH84ZCQ== Received: from TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) by SI2PR06MB3946.apcprd06.prod.outlook.com (2603:1096:4:ea::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.17; Sat, 6 Jan 2024 10:52:14 +0000 Received: from TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::e139:fd7a:1b66:a3f7]) by TYSPR06MB6433.apcprd06.prod.outlook.com ([fe80::e139:fd7a:1b66:a3f7%7]) with mapi id 15.20.7159.018; Sat, 6 Jan 2024 10:52:14 +0000 From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Sat, 6 Jan 2024 18:51:29 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [r7/AWgyuUz+bT9wpiKOi0SAdW3sbwN0W] X-ClientProxiedBy: TYAPR04CA0003.apcprd04.prod.outlook.com (2603:1096:404:15::15) To TYSPR06MB6433.apcprd06.prod.outlook.com (2603:1096:400:47a::6) X-Microsoft-Original-Message-ID: <20240106105132.31509-1-nuomi2021@gmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6433:EE_|SI2PR06MB3946:EE_ X-MS-Office365-Filtering-Correlation-Id: 94c46b81-a46d-4dfc-5680-08dc0ea58a3d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PMSJ6iLTD3T+1hTjInsqJLAAtxTvBJ5uLKk1gOeNS2cyLYyrbwxAYwugvN9iUhZN0QvATKkfsttUa0ZaGkp3w1Z2Kpjts6xutZ5NLnQY8A0jIYjCwfSERuiRjB9tTb44KQVYfGsyBTu3LxIVeWJc2V5mQirieufjJPwjvPODlXe7vmXurTpNbljsJJyGZr4PIHg6ZYeG/gY0xDyRRD2dBCGK3zXPnhjTdtTFm0a4Adwsrtmfl864N4ydzDclA/S1cg0HaEUh182sHCQOXcRbT4syIo1Kp2AhmeIrydS4jhPUmsfBaNp7/3tvdSVQGhzA96sjlOAQ8X+c6/DwqLLwHOPGk+ntdmWHRfEjJAVLAdqEYc3WmE7vxvzzgdrWg1TVdLqHfq0ZAr6Ao4bFAxTjAPsWn/gCfBRPIjl/dvfuJrirlTo6cHZEG10CiVEC20uBp5hZH+biV8S+V2C87Y3+aAiewwoox4t/yGjbYhgBiEqzjrXJOu9R6iopy/qgimoODcSe/ElJ/x+b0oQDslx49q13e5JwNZxUIQhMnjYqaUFsFmY0Rp6dl57yF8Gdi5tXkDPB4+rnEh1M9Bhb7qRiMGGimXFpIn0y21aufTif8bT19UkKNGzAeJQcrjlRg4U4 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?iq8aiEvg+mLogHMkEcowPYxr65uGCWJNJ4gG0D5amvE1swC9pWBVQXT2iP4g?= =?us-ascii?Q?zIc9vka2jqKcingOTmGcsgENlD1ZG7rRu/HDupA4ktF+nA6+iyIiSRFiUMWj?= =?us-ascii?Q?tYmutF4FPvIsfSTU2VehyKofz0UQ0ZWHwVqGFpwDKJEctN+FOcddKfH1V8W0?= =?us-ascii?Q?oYLBPEc9vJOb4O3nZ+pgCV3TXhAX3/MReeDDKFbLJZBKBfeE5vEn8NWNLR5p?= =?us-ascii?Q?mtXvqPfHezD4kwPbKLt4SN9+cBEWfv7S3OZif8KrXUtH7wYh3WQuOK+A5Z4o?= =?us-ascii?Q?JSOtnZLZTzIHNtOuYIOTNMGTpyv0H9RDZRKBvaR4AXEaMzSuvaFrDv+Bh4WK?= =?us-ascii?Q?Ss/wa1E19IRnJdYcxo1TXQhiXLCgTFZnUk/cByJ6c0jDx/y53yJySNGGQLFf?= =?us-ascii?Q?mzUQeQookIs1GZY/YY615WoW4HDh1d6FQAJE8yFBUeWyrOYK/c2eilw29ZOZ?= =?us-ascii?Q?BwVw0r6ZN7RJucqLdciP4N337CD9Lz6ScoHlwF4/DBctXwZwFXAclhQkACKW?= =?us-ascii?Q?l+cSgoEc0HkX/u5ucO6CvTMjkw3puVq3LhW6pri3/rAAwwyAPTI9lPnk2Mhx?= =?us-ascii?Q?k9UmMkX7Ur1gfuby3nF8jLkPgtAweGeL9KpzfrlTaOgc3qS4iWGz4vYQwW68?= =?us-ascii?Q?eyzL8A6aPaBeIpj34mSQIEtll9Miwu/I15lCBw2xvAGl0ZrEbaCSCp+GTAau?= =?us-ascii?Q?CGZSKae95qQCxcrjq860Jhc0GqveK7iGZTifL1VhEWdRmci0Um5GMvDq3v8u?= =?us-ascii?Q?Z/Tp46kItBPUSNZlReZzhqLk+6CvcAv5mMvKx5XLNXNIVgXMw1agtX/UgUss?= =?us-ascii?Q?0w6c1sotv/JuYwvnPImqLbA+JogyzHSNJ9weocluUw0q/iBspMJGSdHap5kV?= =?us-ascii?Q?VebbQMbDe+5ZWFDa+/GMSOaSGVbeFKAbkI5S6vYDFj3znjHlw6tCZkjGuRYc?= =?us-ascii?Q?glG2NR/OhXSHyqSIgz+l9hYGHBlhmXcVV1Jc29VKKnZH4LvDn0RawTQsgbnI?= =?us-ascii?Q?t9QLLxfXEZlNBKNgkjio8mciBO3feH/hALNQY4joqnfDPp7KUXf09/XB+UhA?= =?us-ascii?Q?6KJe1sweFvv6PpodQVMRAPOjd/lIVM4/f4xGA4dqaic1x7rFmhkGW6d+ZcWO?= =?us-ascii?Q?7cRIGiU409JQyeZ42PyvqTLu/qfbXUsuwR5HkQOp3jobBPIb5kStQKWVuzAC?= =?us-ascii?Q?pfrmYNCtp8DFvLE9mZBEqsHBBABqdsFMyj3pq5+oyfNh54ZpIoQnHTDMNz+n?= =?us-ascii?Q?ytBYR7eeESi1qnheg+u0?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94c46b81-a46d-4dfc-5680-08dc0ea58a3d X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6433.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2024 10:52:13.5690 (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: SI2PR06MB3946 Subject: [FFmpeg-devel] [PATCH v2 1/4] hevcdec: move sao template to h26x/h2656_sao_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: 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/h26x/h2656_sao_template.c | 217 +++++++++++++++++++++++++++ libavcodec/hevcdsp_template.c | 196 +----------------------- 2 files changed, 218 insertions(+), 195 deletions(-) create mode 100644 libavcodec/h26x/h2656_sao_template.c diff --git a/libavcodec/h26x/h2656_sao_template.c b/libavcodec/h26x/h2656_sao_template.c new file mode 100644 index 0000000000..b3eb8a3deb --- /dev/null +++ b/libavcodec/h26x/h2656_sao_template.c @@ -0,0 +1,217 @@ +/* + * HEVC/VVC SAO template + * + * Copyright (C) 2024 Nuo Mi + * Copyright (C) 2012 - 2013 Guillaume Martres + * + * 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 + */ + +static void FUNC(sao_band_filter)(uint8_t *_dst, const uint8_t *_src, + ptrdiff_t stride_dst, ptrdiff_t stride_src, + const int16_t *sao_offset_val, int sao_left_class, + int width, int height) +{ + pixel *dst = (pixel *)_dst; + const pixel *src = (const pixel *)_src; + int offset_table[32] = { 0 }; + int k, y, x; + int shift = BIT_DEPTH - 5; + + stride_dst /= sizeof(pixel); + stride_src /= sizeof(pixel); + + for (k = 0; k < 4; k++) + offset_table[(k + sao_left_class) & 31] = sao_offset_val[k + 1]; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) + dst[x] = av_clip_pixel(src[x] + offset_table[(src[x] >> shift) & 31]); + dst += stride_dst; + src += stride_src; + } +} + +#define CMP(a, b) (((a) > (b)) - ((a) < (b))) + +static void FUNC(sao_edge_filter)(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst, const int16_t *sao_offset_val, + int eo, int width, int height) { + + static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 }; + static const int8_t pos[4][2][2] = { + { { -1, 0 }, { 1, 0 } }, // horizontal + { { 0, -1 }, { 0, 1 } }, // vertical + { { -1, -1 }, { 1, 1 } }, // 45 degree + { { 1, -1 }, { -1, 1 } }, // 135 degree + }; + pixel *dst = (pixel *)_dst; + const pixel *src = (const pixel *)_src; + int a_stride, b_stride; + int x, y; + ptrdiff_t stride_src = (2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) / sizeof(pixel); + stride_dst /= sizeof(pixel); + + a_stride = pos[eo][0][0] + pos[eo][0][1] * stride_src; + b_stride = pos[eo][1][0] + pos[eo][1][1] * stride_src; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + int diff0 = CMP(src[x], src[x + a_stride]); + int diff1 = CMP(src[x], src[x + b_stride]); + int offset_val = edge_idx[2 + diff0 + diff1]; + dst[x] = av_clip_pixel(src[x] + sao_offset_val[offset_val]); + } + src += stride_src; + dst += stride_dst; + } +} + +static void FUNC(sao_edge_restore_0)(uint8_t *_dst, const uint8_t *_src, + ptrdiff_t stride_dst, ptrdiff_t stride_src, const SAOParams *sao, + const int *borders, int _width, int _height, + int c_idx, const uint8_t *vert_edge, + const uint8_t *horiz_edge, const uint8_t *diag_edge) +{ + int x, y; + pixel *dst = (pixel *)_dst; + const pixel *src = (const pixel *)_src; + const int16_t *sao_offset_val = sao->offset_val[c_idx]; + int sao_eo_class = sao->eo_class[c_idx]; + int init_x = 0, width = _width, height = _height; + + stride_dst /= sizeof(pixel); + stride_src /= sizeof(pixel); + + if (sao_eo_class != SAO_EO_VERT) { + if (borders[0]) { + int offset_val = sao_offset_val[0]; + for (y = 0; y < height; y++) { + dst[y * stride_dst] = av_clip_pixel(src[y * stride_src] + offset_val); + } + init_x = 1; + } + if (borders[2]) { + int offset_val = sao_offset_val[0]; + int offset = width - 1; + for (x = 0; x < height; x++) { + dst[x * stride_dst + offset] = av_clip_pixel(src[x * stride_src + offset] + offset_val); + } + width--; + } + } + if (sao_eo_class != SAO_EO_HORIZ) { + if (borders[1]) { + int offset_val = sao_offset_val[0]; + for (x = init_x; x < width; x++) + dst[x] = av_clip_pixel(src[x] + offset_val); + } + if (borders[3]) { + int offset_val = sao_offset_val[0]; + ptrdiff_t y_stride_dst = stride_dst * (height - 1); + ptrdiff_t y_stride_src = stride_src * (height - 1); + for (x = init_x; x < width; x++) + dst[x + y_stride_dst] = av_clip_pixel(src[x + y_stride_src] + offset_val); + height--; + } + } +} + +static void FUNC(sao_edge_restore_1)(uint8_t *_dst, const uint8_t *_src, + ptrdiff_t stride_dst, ptrdiff_t stride_src, const SAOParams *sao, + const int *borders, int _width, int _height, + int c_idx, const uint8_t *vert_edge, + const uint8_t *horiz_edge, const uint8_t *diag_edge) +{ + int x, y; + pixel *dst = (pixel *)_dst; + const pixel *src = (const pixel *)_src; + const int16_t *sao_offset_val = sao->offset_val[c_idx]; + int sao_eo_class = sao->eo_class[c_idx]; + int init_x = 0, init_y = 0, width = _width, height = _height; + + stride_dst /= sizeof(pixel); + stride_src /= sizeof(pixel); + + if (sao_eo_class != SAO_EO_VERT) { + if (borders[0]) { + int offset_val = sao_offset_val[0]; + for (y = 0; y < height; y++) { + dst[y * stride_dst] = av_clip_pixel(src[y * stride_src] + offset_val); + } + init_x = 1; + } + if (borders[2]) { + int offset_val = sao_offset_val[0]; + int offset = width - 1; + for (x = 0; x < height; x++) { + dst[x * stride_dst + offset] = av_clip_pixel(src[x * stride_src + offset] + offset_val); + } + width--; + } + } + if (sao_eo_class != SAO_EO_HORIZ) { + if (borders[1]) { + int offset_val = sao_offset_val[0]; + for (x = init_x; x < width; x++) + dst[x] = av_clip_pixel(src[x] + offset_val); + init_y = 1; + } + if (borders[3]) { + int offset_val = sao_offset_val[0]; + ptrdiff_t y_stride_dst = stride_dst * (height - 1); + ptrdiff_t y_stride_src = stride_src * (height - 1); + for (x = init_x; x < width; x++) + dst[x + y_stride_dst] = av_clip_pixel(src[x + y_stride_src] + offset_val); + height--; + } + } + + { + int save_upper_left = !diag_edge[0] && sao_eo_class == SAO_EO_135D && !borders[0] && !borders[1]; + int save_upper_right = !diag_edge[1] && sao_eo_class == SAO_EO_45D && !borders[1] && !borders[2]; + int save_lower_right = !diag_edge[2] && sao_eo_class == SAO_EO_135D && !borders[2] && !borders[3]; + int save_lower_left = !diag_edge[3] && sao_eo_class == SAO_EO_45D && !borders[0] && !borders[3]; + + // Restore pixels that can't be modified + if(vert_edge[0] && sao_eo_class != SAO_EO_VERT) { + for(y = init_y+save_upper_left; y< height-save_lower_left; y++) + dst[y*stride_dst] = src[y*stride_src]; + } + if(vert_edge[1] && sao_eo_class != SAO_EO_VERT) { + for(y = init_y+save_upper_right; y< height-save_lower_right; y++) + dst[y*stride_dst+width-1] = src[y*stride_src+width-1]; + } + + if(horiz_edge[0] && sao_eo_class != SAO_EO_HORIZ) { + for(x = init_x+save_upper_left; x < width-save_upper_right; x++) + dst[x] = src[x]; + } + if(horiz_edge[1] && sao_eo_class != SAO_EO_HORIZ) { + for(x = init_x+save_lower_left; x < width-save_lower_right; x++) + dst[(height-1)*stride_dst+x] = src[(height-1)*stride_src+x]; + } + if(diag_edge[0] && sao_eo_class == SAO_EO_135D) + dst[0] = src[0]; + if(diag_edge[1] && sao_eo_class == SAO_EO_45D) + dst[width-1] = src[width-1]; + if(diag_edge[2] && sao_eo_class == SAO_EO_135D) + dst[stride_dst*(height-1)+width-1] = src[stride_src*(height-1)+width-1]; + if(diag_edge[3] && sao_eo_class == SAO_EO_45D) + dst[stride_dst*(height-1)] = src[stride_src*(height-1)]; + + } +} + +#undef CMP diff --git a/libavcodec/hevcdsp_template.c b/libavcodec/hevcdsp_template.c index 725fab99ed..2ff1776b92 100644 --- a/libavcodec/hevcdsp_template.c +++ b/libavcodec/hevcdsp_template.c @@ -25,6 +25,7 @@ #include "bit_depth_template.c" #include "hevcdsp.h" +#include "h26x/h2656_sao_template.c" static void FUNC(put_pcm)(uint8_t *_dst, ptrdiff_t stride, int width, int height, GetBitContext *gb, int pcm_bit_depth) @@ -295,201 +296,6 @@ IDCT_DC(32) #undef SET #undef SCALE -static void FUNC(sao_band_filter)(uint8_t *_dst, const uint8_t *_src, - ptrdiff_t stride_dst, ptrdiff_t stride_src, - const int16_t *sao_offset_val, int sao_left_class, - int width, int height) -{ - pixel *dst = (pixel *)_dst; - const pixel *src = (const pixel *)_src; - int offset_table[32] = { 0 }; - int k, y, x; - int shift = BIT_DEPTH - 5; - - stride_dst /= sizeof(pixel); - stride_src /= sizeof(pixel); - - for (k = 0; k < 4; k++) - offset_table[(k + sao_left_class) & 31] = sao_offset_val[k + 1]; - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) - dst[x] = av_clip_pixel(src[x] + offset_table[(src[x] >> shift) & 31]); - dst += stride_dst; - src += stride_src; - } -} - -#define CMP(a, b) (((a) > (b)) - ((a) < (b))) - -static void FUNC(sao_edge_filter)(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst, const int16_t *sao_offset_val, - int eo, int width, int height) { - - static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 }; - static const int8_t pos[4][2][2] = { - { { -1, 0 }, { 1, 0 } }, // horizontal - { { 0, -1 }, { 0, 1 } }, // vertical - { { -1, -1 }, { 1, 1 } }, // 45 degree - { { 1, -1 }, { -1, 1 } }, // 135 degree - }; - pixel *dst = (pixel *)_dst; - const pixel *src = (const pixel *)_src; - int a_stride, b_stride; - int x, y; - ptrdiff_t stride_src = (2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) / sizeof(pixel); - stride_dst /= sizeof(pixel); - - a_stride = pos[eo][0][0] + pos[eo][0][1] * stride_src; - b_stride = pos[eo][1][0] + pos[eo][1][1] * stride_src; - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { - int diff0 = CMP(src[x], src[x + a_stride]); - int diff1 = CMP(src[x], src[x + b_stride]); - int offset_val = edge_idx[2 + diff0 + diff1]; - dst[x] = av_clip_pixel(src[x] + sao_offset_val[offset_val]); - } - src += stride_src; - dst += stride_dst; - } -} - -static void FUNC(sao_edge_restore_0)(uint8_t *_dst, const uint8_t *_src, - ptrdiff_t stride_dst, ptrdiff_t stride_src, const SAOParams *sao, - const int *borders, int _width, int _height, - int c_idx, const uint8_t *vert_edge, - const uint8_t *horiz_edge, const uint8_t *diag_edge) -{ - int x, y; - pixel *dst = (pixel *)_dst; - const pixel *src = (const pixel *)_src; - const int16_t *sao_offset_val = sao->offset_val[c_idx]; - int sao_eo_class = sao->eo_class[c_idx]; - int init_x = 0, width = _width, height = _height; - - stride_dst /= sizeof(pixel); - stride_src /= sizeof(pixel); - - if (sao_eo_class != SAO_EO_VERT) { - if (borders[0]) { - int offset_val = sao_offset_val[0]; - for (y = 0; y < height; y++) { - dst[y * stride_dst] = av_clip_pixel(src[y * stride_src] + offset_val); - } - init_x = 1; - } - if (borders[2]) { - int offset_val = sao_offset_val[0]; - int offset = width - 1; - for (x = 0; x < height; x++) { - dst[x * stride_dst + offset] = av_clip_pixel(src[x * stride_src + offset] + offset_val); - } - width--; - } - } - if (sao_eo_class != SAO_EO_HORIZ) { - if (borders[1]) { - int offset_val = sao_offset_val[0]; - for (x = init_x; x < width; x++) - dst[x] = av_clip_pixel(src[x] + offset_val); - } - if (borders[3]) { - int offset_val = sao_offset_val[0]; - ptrdiff_t y_stride_dst = stride_dst * (height - 1); - ptrdiff_t y_stride_src = stride_src * (height - 1); - for (x = init_x; x < width; x++) - dst[x + y_stride_dst] = av_clip_pixel(src[x + y_stride_src] + offset_val); - height--; - } - } -} - -static void FUNC(sao_edge_restore_1)(uint8_t *_dst, const uint8_t *_src, - ptrdiff_t stride_dst, ptrdiff_t stride_src, const SAOParams *sao, - const int *borders, int _width, int _height, - int c_idx, const uint8_t *vert_edge, - const uint8_t *horiz_edge, const uint8_t *diag_edge) -{ - int x, y; - pixel *dst = (pixel *)_dst; - const pixel *src = (const pixel *)_src; - const int16_t *sao_offset_val = sao->offset_val[c_idx]; - int sao_eo_class = sao->eo_class[c_idx]; - int init_x = 0, init_y = 0, width = _width, height = _height; - - stride_dst /= sizeof(pixel); - stride_src /= sizeof(pixel); - - if (sao_eo_class != SAO_EO_VERT) { - if (borders[0]) { - int offset_val = sao_offset_val[0]; - for (y = 0; y < height; y++) { - dst[y * stride_dst] = av_clip_pixel(src[y * stride_src] + offset_val); - } - init_x = 1; - } - if (borders[2]) { - int offset_val = sao_offset_val[0]; - int offset = width - 1; - for (x = 0; x < height; x++) { - dst[x * stride_dst + offset] = av_clip_pixel(src[x * stride_src + offset] + offset_val); - } - width--; - } - } - if (sao_eo_class != SAO_EO_HORIZ) { - if (borders[1]) { - int offset_val = sao_offset_val[0]; - for (x = init_x; x < width; x++) - dst[x] = av_clip_pixel(src[x] + offset_val); - init_y = 1; - } - if (borders[3]) { - int offset_val = sao_offset_val[0]; - ptrdiff_t y_stride_dst = stride_dst * (height - 1); - ptrdiff_t y_stride_src = stride_src * (height - 1); - for (x = init_x; x < width; x++) - dst[x + y_stride_dst] = av_clip_pixel(src[x + y_stride_src] + offset_val); - height--; - } - } - - { - int save_upper_left = !diag_edge[0] && sao_eo_class == SAO_EO_135D && !borders[0] && !borders[1]; - int save_upper_right = !diag_edge[1] && sao_eo_class == SAO_EO_45D && !borders[1] && !borders[2]; - int save_lower_right = !diag_edge[2] && sao_eo_class == SAO_EO_135D && !borders[2] && !borders[3]; - int save_lower_left = !diag_edge[3] && sao_eo_class == SAO_EO_45D && !borders[0] && !borders[3]; - - // Restore pixels that can't be modified - if(vert_edge[0] && sao_eo_class != SAO_EO_VERT) { - for(y = init_y+save_upper_left; y< height-save_lower_left; y++) - dst[y*stride_dst] = src[y*stride_src]; - } - if(vert_edge[1] && sao_eo_class != SAO_EO_VERT) { - for(y = init_y+save_upper_right; y< height-save_lower_right; y++) - dst[y*stride_dst+width-1] = src[y*stride_src+width-1]; - } - - if(horiz_edge[0] && sao_eo_class != SAO_EO_HORIZ) { - for(x = init_x+save_upper_left; x < width-save_upper_right; x++) - dst[x] = src[x]; - } - if(horiz_edge[1] && sao_eo_class != SAO_EO_HORIZ) { - for(x = init_x+save_lower_left; x < width-save_lower_right; x++) - dst[(height-1)*stride_dst+x] = src[(height-1)*stride_src+x]; - } - if(diag_edge[0] && sao_eo_class == SAO_EO_135D) - dst[0] = src[0]; - if(diag_edge[1] && sao_eo_class == SAO_EO_45D) - dst[width-1] = src[width-1]; - if(diag_edge[2] && sao_eo_class == SAO_EO_135D) - dst[stride_dst*(height-1)+width-1] = src[stride_src*(height-1)+width-1]; - if(diag_edge[3] && sao_eo_class == SAO_EO_45D) - dst[stride_dst*(height-1)] = src[stride_src*(height-1)]; - - } -} - -#undef CMP - //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// -- 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".