| 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 | 12169095 | 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 | 12169095 | int sad = 0; | |
| 33 | 12169095 | dx -= 2; | |
| 34 | 12169095 | dy -= 2; | |
| 35 | 12169095 | src0 += (2 + dy) * MAX_PB_SIZE + 2 + dx; | |
| 36 | 12169095 | src1 += (2 - dy) * MAX_PB_SIZE + 2 - dx; | |
| 37 |
2/2✓ Branch 0 taken 95852428 times.
✓ Branch 1 taken 12169095 times.
|
108021523 | for (int y = 0; y < block_h; y += 2) { |
| 38 |
2/2✓ Branch 0 taken 1507105984 times.
✓ Branch 1 taken 95852428 times.
|
1602958412 | for (int x = 0; x < block_w; x++) { |
| 39 | 1507105984 | sad += FFABS(src0[x] - src1[x]); | |
| 40 | } | ||
| 41 | 95852428 | src0 += 2 * MAX_PB_SIZE; | |
| 42 | 95852428 | src1 += 2 * MAX_PB_SIZE; | |
| 43 | } | ||
| 44 | 12169095 | return sad; | |
| 45 | } | ||
| 46 | |||
| 47 | 113399 | 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 113399 times.
✗ Branch 1 not taken.
|
113399 | if (intra_mip_transposed_flag) |
| 51 | 113399 | *intra_mip_transposed_flag = (mip_info >> 1) & 0x1; | |
| 52 |
1/2✓ Branch 0 taken 113399 times.
✗ Branch 1 not taken.
|
113399 | if (intra_mip_mode) |
| 53 | 113399 | *intra_mip_mode = (mip_info >> 2) & 0xf; | |
| 54 | 113399 | } | |
| 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 | 1542 | 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 154 times.
✓ Branch 1 taken 1199 times.
✓ Branch 2 taken 189 times.
|
1542 | switch (bit_depth) { |
| 101 | 154 | case 12: | |
| 102 | 154 | VVC_DSP(12); | |
| 103 | 154 | break; | |
| 104 | 1199 | case 10: | |
| 105 | 1199 | VVC_DSP(10); | |
| 106 | 1199 | break; | |
| 107 | 189 | default: | |
| 108 | 189 | VVC_DSP(8); | |
| 109 | 189 | 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 && HAVE_X86ASM | ||
| 117 | 1542 | ff_vvc_dsp_init_x86(vvcdsp, bit_depth); | |
| 118 | #endif | ||
| 119 | 1542 | } | |
| 120 |