1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-08 13:22:53 +02:00
FFmpeg/libavcodec/vvc/dsp.c

109 lines
3.1 KiB
C
Raw Normal View History

/*
* 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 "dsp.h"
#include "ctu.h"
#include "itx_1d.h"
#define VVC_SIGN(v) (v < 0 ? -1 : !!v)
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;
}
typedef struct IntraEdgeParams {
uint8_t* top;
uint8_t* left;
int filter_flag;
uint16_t left_array[6 * MAX_TB_SIZE + 5];
uint16_t filtered_left_array[6 * MAX_TB_SIZE + 5];
uint16_t top_array[6 * MAX_TB_SIZE + 5];
uint16_t filtered_top_array[6 * MAX_TB_SIZE + 5];
} IntraEdgeParams;
#define PROF_BORDER_EXT 1
#define PROF_BLOCK_SIZE (AFFINE_MIN_BLOCK_SIZE + PROF_BORDER_EXT * 2)
#define BDOF_BORDER_EXT 1
#define BDOF_BLOCK_SIZE 16
#define BDOF_MIN_BLOCK_SIZE 4
#define BIT_DEPTH 8
#include "dsp_template.c"
#undef BIT_DEPTH
#define BIT_DEPTH 10
#include "dsp_template.c"
#undef BIT_DEPTH
#define BIT_DEPTH 12
#include "dsp_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;
}
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-15 18:19:15 +02:00
#if ARCH_AARCH64
ff_vvc_dsp_init_aarch64(vvcdsp, bit_depth);
#elif ARCH_X86
ff_vvc_dsp_init_x86(vvcdsp, bit_depth);
#endif
}