ffmpeg/libavcodec/aarch64/vvc/alf_template.c
Zhao Zhili 2d4ef304c9 avcodec/vvc: Add aarch64 neon optimization for ALF
vvc_alf_filter_chroma_4x4_8_c: 3.0
vvc_alf_filter_chroma_4x4_8_neon: 1.0
vvc_alf_filter_chroma_4x4_10_c: 2.7
vvc_alf_filter_chroma_4x4_10_neon: 1.0
vvc_alf_filter_chroma_4x4_12_c: 2.7
vvc_alf_filter_chroma_4x4_12_neon: 1.0
vvc_alf_filter_chroma_8x8_8_c: 10.2
vvc_alf_filter_chroma_8x8_8_neon: 3.0
vvc_alf_filter_chroma_8x8_10_c: 10.0
vvc_alf_filter_chroma_8x8_10_neon: 2.5
vvc_alf_filter_chroma_8x8_12_c: 10.0
vvc_alf_filter_chroma_8x8_12_neon: 2.5
vvc_alf_filter_chroma_16x16_8_c: 41.7
vvc_alf_filter_chroma_16x16_8_neon: 11.2
vvc_alf_filter_chroma_16x16_10_c: 39.0
vvc_alf_filter_chroma_16x16_10_neon: 10.0
vvc_alf_filter_chroma_16x16_12_c: 40.2
vvc_alf_filter_chroma_16x16_12_neon: 10.2
vvc_alf_filter_chroma_32x32_8_c: 162.0
vvc_alf_filter_chroma_32x32_8_neon: 45.0
vvc_alf_filter_chroma_32x32_10_c: 155.5
vvc_alf_filter_chroma_32x32_10_neon: 39.5
vvc_alf_filter_chroma_32x32_12_c: 155.5
vvc_alf_filter_chroma_32x32_12_neon: 40.0
vvc_alf_filter_chroma_64x64_8_c: 646.0
vvc_alf_filter_chroma_64x64_8_neon: 175.5
vvc_alf_filter_chroma_64x64_10_c: 708.2
vvc_alf_filter_chroma_64x64_10_neon: 166.7
vvc_alf_filter_chroma_64x64_12_c: 619.2
vvc_alf_filter_chroma_64x64_12_neon: 157.2
vvc_alf_filter_chroma_128x128_8_c: 2611.5
vvc_alf_filter_chroma_128x128_8_neon: 698.2
vvc_alf_filter_chroma_128x128_10_c: 2470.0
vvc_alf_filter_chroma_128x128_10_neon: 616.0
vvc_alf_filter_chroma_128x128_12_c: 2531.5
vvc_alf_filter_chroma_128x128_12_neon: 620.2
vvc_alf_filter_luma_8x8_8_c: 25.2
vvc_alf_filter_luma_8x8_8_neon: 4.2
vvc_alf_filter_luma_8x8_10_c: 18.5
vvc_alf_filter_luma_8x8_10_neon: 4.0
vvc_alf_filter_luma_8x8_12_c: 19.0
vvc_alf_filter_luma_8x8_12_neon: 4.0
vvc_alf_filter_luma_16x16_8_c: 106.5
vvc_alf_filter_luma_16x16_8_neon: 16.2
vvc_alf_filter_luma_16x16_10_c: 75.2
vvc_alf_filter_luma_16x16_10_neon: 14.7
vvc_alf_filter_luma_16x16_12_c: 79.7
vvc_alf_filter_luma_16x16_12_neon: 14.7
vvc_alf_filter_luma_32x32_8_c: 400.5
vvc_alf_filter_luma_32x32_8_neon: 63.2
vvc_alf_filter_luma_32x32_10_c: 299.2
vvc_alf_filter_luma_32x32_10_neon: 57.7
vvc_alf_filter_luma_32x32_12_c: 299.2
vvc_alf_filter_luma_32x32_12_neon: 57.7
vvc_alf_filter_luma_64x64_8_c: 1602.5
vvc_alf_filter_luma_64x64_8_neon: 251.7
vvc_alf_filter_luma_64x64_10_c: 1197.0
vvc_alf_filter_luma_64x64_10_neon: 235.5
vvc_alf_filter_luma_64x64_12_c: 1220.2
vvc_alf_filter_luma_64x64_12_neon: 235.7
vvc_alf_filter_luma_128x128_8_c: 6570.2
vvc_alf_filter_luma_128x128_8_neon: 1007.7
vvc_alf_filter_luma_128x128_10_c: 4822.7
vvc_alf_filter_luma_128x128_10_neon: 936.2
vvc_alf_filter_luma_128x128_12_c: 4791.2
vvc_alf_filter_luma_128x128_12_neon: 938.5

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-07-22 21:09:56 +08:00

158 lines
6.3 KiB
C

/*
* VVC filters DSP
*
* Copyright (C) 2024 Zhao Zhili
*
* 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"
void FUNC2(ff_alf_filter_luma_kernel, BIT_DEPTH, _neon)(pixel *dst,
const pixel **p,
const int16_t *filter,
const int16_t *clip,
int is_near_vb);
void FUNC2(ff_alf_filter_chroma_kernel, BIT_DEPTH, _neon)(pixel *dst,
const pixel **p,
const int16_t *filter,
const int16_t *clip,
int is_near_vb);
static void FUNC2(alf_filter_luma, BIT_DEPTH, _neon)(uint8_t *_dst,
ptrdiff_t dst_stride,
const uint8_t *_src,
ptrdiff_t src_stride,
const int width, const int height,
const int16_t *filter,
const int16_t *clip,
const int vb_pos)
{
const pixel *src = (pixel *)_src;
dst_stride /= sizeof(pixel);
src_stride /= sizeof(pixel);
for (int y = 0; y < height; y += ALF_BLOCK_SIZE) {
int far = (y + 3 < vb_pos - 3) || (y > vb_pos + 2);
for (int x = 0; x < width; x += 2 * ALF_BLOCK_SIZE) {
const pixel *s0 = src + y * src_stride + x;
const pixel *s1 = s0 + src_stride;
const pixel *s2 = s0 - src_stride;
const pixel *s3 = s1 + src_stride;
const pixel *s4 = s2 - src_stride;
const pixel *s5 = s3 + src_stride;
const pixel *s6 = s4 - src_stride;
for (int i = 0; i < ALF_BLOCK_SIZE; i++) {
pixel *dst = (pixel *) _dst + (y + i) * dst_stride + x;
const pixel *p0 = s0 + i * src_stride;
const pixel *p1 = s1 + i * src_stride;
const pixel *p2 = s2 + i * src_stride;
const pixel *p3 = s3 + i * src_stride;
const pixel *p4 = s4 + i * src_stride;
const pixel *p5 = s5 + i * src_stride;
const pixel *p6 = s6 + i * src_stride;
int is_near_vb = 0;
if (!far) {
is_near_vb = (y + i == vb_pos - 1) || (y + i == vb_pos);
if (is_near_vb) {
p1 = p0;
p2 = p0;
}
if (y + i >= vb_pos - 2 && y + i <= vb_pos + 1) {
p3 = p1;
p4 = p2;
}
if (y + i >= vb_pos - 3 && y + i <= vb_pos + 2) {
p5 = p3;
p6 = p4;
}
}
FUNC2(ff_alf_filter_luma_kernel, BIT_DEPTH, _neon)(dst,
(const pixel *[]) { p0, p1, p2, p3, p4, p5, p6},
filter,
clip,
is_near_vb);
}
filter += 2 * ALF_NUM_COEFF_LUMA;
clip += 2 * ALF_NUM_COEFF_LUMA;
}
}
}
static void FUNC2(alf_filter_chroma, BIT_DEPTH, _neon)(uint8_t *_dst,
ptrdiff_t dst_stride,
const uint8_t *_src,
ptrdiff_t src_stride,
const int width,
const int height,
const int16_t *filter,
const int16_t *clip,
const int vb_pos)
{
const pixel *src = (pixel *)_src;
dst_stride /= sizeof(pixel);
src_stride /= sizeof(pixel);
for (int y = 0; y < height; y += ALF_BLOCK_SIZE) {
int far = (y + 3 < vb_pos - 2) || (y > vb_pos + 1);
for (int x = 0; x < width; x += ALF_BLOCK_SIZE) {
const pixel *s0 = src + y * src_stride + x;
const pixel *s1 = s0 + src_stride;
const pixel *s2 = s0 - src_stride;
const pixel *s3 = s1 + src_stride;
const pixel *s4 = s2 - src_stride;
for (int i = 0; i < ALF_BLOCK_SIZE; i++) {
pixel *dst = (pixel *)_dst + (y + i) * dst_stride + x;
const pixel *p0 = s0 + i * src_stride;
const pixel *p1 = s1 + i * src_stride;
const pixel *p2 = s2 + i * src_stride;
const pixel *p3 = s3 + i * src_stride;
const pixel *p4 = s4 + i * src_stride;
int is_near_vb = 0;
if (!far) {
is_near_vb = (y + i == vb_pos - 1) || (y + i == vb_pos);
if (is_near_vb) {
p1 = p0;
p2 = p0;
}
if (y + i >= vb_pos - 2 && y + i <= vb_pos + 1) {
p3 = p1;
p4 = p2;
}
}
FUNC2(ff_alf_filter_chroma_kernel, BIT_DEPTH, _neon)(dst,
(const pixel *[]){p0, p1, p2, p3, p4},
filter, clip,
is_near_vb);
}
}
}
}