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 | 11733499 | static int vvc_sad(const int16_t *src0, const int16_t *src1, int dx, int dy, | |
30 | const int block_w, const int block_h) | ||
31 | { | ||
32 | 11733499 | int sad = 0; | |
33 | 11733499 | dx -= 2; | |
34 | 11733499 | dy -= 2; | |
35 | 11733499 | src0 += (2 + dy) * MAX_PB_SIZE + 2 + dx; | |
36 | 11733499 | src1 += (2 - dy) * MAX_PB_SIZE + 2 - dx; | |
37 |
2/2✓ Branch 0 taken 92435700 times.
✓ Branch 1 taken 11733499 times.
|
104169199 | for (int y = 0; y < block_h; y += 2) { |
38 |
2/2✓ Branch 0 taken 1452945344 times.
✓ Branch 1 taken 92435700 times.
|
1545381044 | for (int x = 0; x < block_w; x++) { |
39 | 1452945344 | sad += FFABS(src0[x] - src1[x]); | |
40 | } | ||
41 | 92435700 | src0 += 2 * MAX_PB_SIZE; | |
42 | 92435700 | src1 += 2 * MAX_PB_SIZE; | |
43 | } | ||
44 | 11733499 | return sad; | |
45 | } | ||
46 | |||
47 | 108949 | static av_always_inline void unpack_mip_info(int *intra_mip_transposed_flag, | |
48 | int *intra_mip_mode, const uint8_t mip_info) | ||
49 | { | ||
50 |
1/2✓ Branch 0 taken 108949 times.
✗ Branch 1 not taken.
|
108949 | if (intra_mip_transposed_flag) |
51 | 108949 | *intra_mip_transposed_flag = (mip_info >> 1) & 0x1; | |
52 |
1/2✓ Branch 0 taken 108949 times.
✗ Branch 1 not taken.
|
108949 | if (intra_mip_mode) |
53 | 108949 | *intra_mip_mode = (mip_info >> 2) & 0xf; | |
54 | 108949 | } | |
55 | |||
56 | typedef struct IntraEdgeParams { | ||
57 | uint8_t* top; | ||
58 | uint8_t* left; | ||
59 | int filter_flag; | ||
60 | |||
61 | uint16_t left_array[6 * MAX_TB_SIZE + 5]; | ||
62 | uint16_t filtered_left_array[6 * MAX_TB_SIZE + 5]; | ||
63 | uint16_t top_array[6 * MAX_TB_SIZE + 5]; | ||
64 | uint16_t filtered_top_array[6 * MAX_TB_SIZE + 5]; | ||
65 | } IntraEdgeParams; | ||
66 | |||
67 | #define PROF_BORDER_EXT 1 | ||
68 | #define PROF_BLOCK_SIZE (AFFINE_MIN_BLOCK_SIZE + PROF_BORDER_EXT * 2) | ||
69 | |||
70 | #define BDOF_BORDER_EXT 1 | ||
71 | #define BDOF_BLOCK_SIZE 16 | ||
72 | #define BDOF_MIN_BLOCK_SIZE 4 | ||
73 | |||
74 | #define BIT_DEPTH 8 | ||
75 | #include "dsp_template.c" | ||
76 | #undef BIT_DEPTH | ||
77 | |||
78 | #define BIT_DEPTH 10 | ||
79 | #include "dsp_template.c" | ||
80 | #undef BIT_DEPTH | ||
81 | |||
82 | #define BIT_DEPTH 12 | ||
83 | #include "dsp_template.c" | ||
84 | #undef BIT_DEPTH | ||
85 | |||
86 | 1323 | void ff_vvc_dsp_init(VVCDSPContext *vvcdsp, int bit_depth) | |
87 | { | ||
88 | #undef FUNC | ||
89 | #define FUNC(a, depth) a ## _ ## depth | ||
90 | |||
91 | #define VVC_DSP(depth) \ | ||
92 | FUNC(ff_vvc_inter_dsp_init, depth)(&vvcdsp->inter); \ | ||
93 | FUNC(ff_vvc_intra_dsp_init, depth)(&vvcdsp->intra); \ | ||
94 | FUNC(ff_vvc_itx_dsp_init, depth)(&vvcdsp->itx); \ | ||
95 | FUNC(ff_vvc_lmcs_dsp_init, depth)(&vvcdsp->lmcs); \ | ||
96 | FUNC(ff_vvc_lf_dsp_init, depth)(&vvcdsp->lf); \ | ||
97 | FUNC(ff_vvc_sao_dsp_init, depth)(&vvcdsp->sao); \ | ||
98 | FUNC(ff_vvc_alf_dsp_init, depth)(&vvcdsp->alf); \ | ||
99 | |||
100 |
3/3✓ Branch 0 taken 117 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 152 times.
|
1323 | switch (bit_depth) { |
101 | 117 | case 12: | |
102 | 117 | VVC_DSP(12); | |
103 | 117 | break; | |
104 | 1054 | case 10: | |
105 | 1054 | VVC_DSP(10); | |
106 | 1054 | break; | |
107 | 152 | default: | |
108 | 152 | VVC_DSP(8); | |
109 | 152 | break; | |
110 | } | ||
111 | |||
112 | #if ARCH_AARCH64 | ||
113 | ff_vvc_dsp_init_aarch64(vvcdsp, bit_depth); | ||
114 | #elif ARCH_RISCV | ||
115 | ff_vvc_dsp_init_riscv(vvcdsp, bit_depth); | ||
116 | #elif ARCH_X86 | ||
117 | 1323 | ff_vvc_dsp_init_x86(vvcdsp, bit_depth); | |
118 | #endif | ||
119 | 1323 | } | |
120 |