Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * VVC DSP | ||
3 | * | ||
4 | * Copyright (C) 2021 Nuo Mi | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | #include "dsp.h" | ||
24 | #include "ctu.h" | ||
25 | #include "itx_1d.h" | ||
26 | |||
27 | #define VVC_SIGN(v) (v < 0 ? -1 : !!v) | ||
28 | |||
29 | 2100882 | static void av_always_inline pad_int16(int16_t *_dst, const ptrdiff_t dst_stride, const int width, const int height) | |
30 | { | ||
31 | 2100882 | const int padded_width = width + 2; | |
32 | int16_t *dst; | ||
33 |
2/2✓ Branch 0 taken 32921856 times.
✓ Branch 1 taken 2100882 times.
|
35022738 | for (int y = 0; y < height; y++) { |
34 | 32921856 | dst = _dst + y * dst_stride; | |
35 |
2/2✓ Branch 0 taken 511865856 times.
✓ Branch 1 taken 32921856 times.
|
544787712 | for (int x = 0; x < width; x++) { |
36 | 511865856 | dst[-1] = dst[0]; | |
37 | 511865856 | dst[width] = dst[width - 1]; | |
38 | } | ||
39 | } | ||
40 | |||
41 | 2100882 | _dst--; | |
42 | //top | ||
43 | 2100882 | memcpy(_dst - dst_stride, _dst, padded_width * sizeof(int16_t)); | |
44 | //bottom | ||
45 | 2100882 | _dst += dst_stride * height; | |
46 | 2100882 | memcpy(_dst, _dst - dst_stride, padded_width * sizeof(int16_t)); | |
47 | 2100882 | } | |
48 | |||
49 | 11784614 | static int vvc_sad(const int16_t *src0, const int16_t *src1, int dx, int dy, | |
50 | const int block_w, const int block_h) | ||
51 | { | ||
52 | 11784614 | int sad = 0; | |
53 | 11784614 | dx -= 2; | |
54 | 11784614 | dy -= 2; | |
55 | 11784614 | src0 += (2 + dy) * MAX_PB_SIZE + 2 + dx; | |
56 | 11784614 | src1 += (2 - dy) * MAX_PB_SIZE + 2 - dx; | |
57 |
2/2✓ Branch 0 taken 92845032 times.
✓ Branch 1 taken 11784614 times.
|
104629646 | for (int y = 0; y < block_h; y += 2) { |
58 |
2/2✓ Branch 0 taken 1459494848 times.
✓ Branch 1 taken 92845032 times.
|
1552339880 | for (int x = 0; x < block_w; x++) { |
59 | 1459494848 | sad += FFABS(src0[x] - src1[x]); | |
60 | } | ||
61 | 92845032 | src0 += 2 * MAX_PB_SIZE; | |
62 | 92845032 | src1 += 2 * MAX_PB_SIZE; | |
63 | } | ||
64 | 11784614 | return sad; | |
65 | } | ||
66 | |||
67 | typedef struct IntraEdgeParams { | ||
68 | uint8_t* top; | ||
69 | uint8_t* left; | ||
70 | int filter_flag; | ||
71 | |||
72 | uint16_t left_array[6 * MAX_TB_SIZE + 5]; | ||
73 | uint16_t filtered_left_array[6 * MAX_TB_SIZE + 5]; | ||
74 | uint16_t top_array[6 * MAX_TB_SIZE + 5]; | ||
75 | uint16_t filtered_top_array[6 * MAX_TB_SIZE + 5]; | ||
76 | } IntraEdgeParams; | ||
77 | |||
78 | #define PROF_BORDER_EXT 1 | ||
79 | #define PROF_BLOCK_SIZE (AFFINE_MIN_BLOCK_SIZE + PROF_BORDER_EXT * 2) | ||
80 | #define BDOF_BORDER_EXT 1 | ||
81 | |||
82 | #define BDOF_PADDED_SIZE (16 + BDOF_BORDER_EXT * 2) | ||
83 | #define BDOF_BLOCK_SIZE 4 | ||
84 | #define BDOF_GRADIENT_SIZE (BDOF_BLOCK_SIZE + BDOF_BORDER_EXT * 2) | ||
85 | |||
86 | #define BIT_DEPTH 8 | ||
87 | #include "dsp_template.c" | ||
88 | #undef BIT_DEPTH | ||
89 | |||
90 | #define BIT_DEPTH 10 | ||
91 | #include "dsp_template.c" | ||
92 | #undef BIT_DEPTH | ||
93 | |||
94 | #define BIT_DEPTH 12 | ||
95 | #include "dsp_template.c" | ||
96 | #undef BIT_DEPTH | ||
97 | |||
98 | 1067 | void ff_vvc_dsp_init(VVCDSPContext *vvcdsp, int bit_depth) | |
99 | { | ||
100 | #undef FUNC | ||
101 | #define FUNC(a, depth) a ## _ ## depth | ||
102 | |||
103 | #define VVC_DSP(depth) \ | ||
104 | FUNC(ff_vvc_inter_dsp_init, depth)(&vvcdsp->inter); \ | ||
105 | FUNC(ff_vvc_intra_dsp_init, depth)(&vvcdsp->intra); \ | ||
106 | FUNC(ff_vvc_itx_dsp_init, depth)(&vvcdsp->itx); \ | ||
107 | FUNC(ff_vvc_lmcs_dsp_init, depth)(&vvcdsp->lmcs); \ | ||
108 | FUNC(ff_vvc_lf_dsp_init, depth)(&vvcdsp->lf); \ | ||
109 | FUNC(ff_vvc_sao_dsp_init, depth)(&vvcdsp->sao); \ | ||
110 | FUNC(ff_vvc_alf_dsp_init, depth)(&vvcdsp->alf); \ | ||
111 | |||
112 |
3/3✓ Branch 0 taken 65 times.
✓ Branch 1 taken 934 times.
✓ Branch 2 taken 68 times.
|
1067 | switch (bit_depth) { |
113 | 65 | case 12: | |
114 | 65 | VVC_DSP(12); | |
115 | 65 | break; | |
116 | 934 | case 10: | |
117 | 934 | VVC_DSP(10); | |
118 | 934 | break; | |
119 | 68 | default: | |
120 | 68 | VVC_DSP(8); | |
121 | 68 | break; | |
122 | } | ||
123 | |||
124 | #if ARCH_X86 | ||
125 | 1067 | ff_vvc_dsp_init_x86(vvcdsp, bit_depth); | |
126 | #endif | ||
127 | 1067 | } | |
128 |