FFmpeg
dsp.c
Go to the documentation of this file.
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 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  int sad = 0;
33  dx -= 2;
34  dy -= 2;
35  src0 += (2 + dy) * MAX_PB_SIZE + 2 + dx;
36  src1 += (2 - dy) * MAX_PB_SIZE + 2 - dx;
37  for (int y = 0; y < block_h; y += 2) {
38  for (int x = 0; x < block_w; x++) {
39  sad += FFABS(src0[x] - src1[x]);
40  }
41  src0 += 2 * MAX_PB_SIZE;
42  src1 += 2 * MAX_PB_SIZE;
43  }
44  return sad;
45 }
46 
47 typedef struct IntraEdgeParams {
48  uint8_t* top;
49  uint8_t* left;
51 
52  uint16_t left_array[6 * MAX_TB_SIZE + 5];
53  uint16_t filtered_left_array[6 * MAX_TB_SIZE + 5];
54  uint16_t top_array[6 * MAX_TB_SIZE + 5];
55  uint16_t filtered_top_array[6 * MAX_TB_SIZE + 5];
57 
58 #define PROF_BORDER_EXT 1
59 #define PROF_BLOCK_SIZE (AFFINE_MIN_BLOCK_SIZE + PROF_BORDER_EXT * 2)
60 
61 #define BDOF_BORDER_EXT 1
62 #define BDOF_BLOCK_SIZE 16
63 #define BDOF_MIN_BLOCK_SIZE 4
64 
65 #define BIT_DEPTH 8
66 #include "dsp_template.c"
67 #undef BIT_DEPTH
68 
69 #define BIT_DEPTH 10
70 #include "dsp_template.c"
71 #undef BIT_DEPTH
72 
73 #define BIT_DEPTH 12
74 #include "dsp_template.c"
75 #undef BIT_DEPTH
76 
78 {
79 #undef FUNC
80 #define FUNC(a, depth) a ## _ ## depth
81 
82 #define VVC_DSP(depth) \
83  FUNC(ff_vvc_inter_dsp_init, depth)(&vvcdsp->inter); \
84  FUNC(ff_vvc_intra_dsp_init, depth)(&vvcdsp->intra); \
85  FUNC(ff_vvc_itx_dsp_init, depth)(&vvcdsp->itx); \
86  FUNC(ff_vvc_lmcs_dsp_init, depth)(&vvcdsp->lmcs); \
87  FUNC(ff_vvc_lf_dsp_init, depth)(&vvcdsp->lf); \
88  FUNC(ff_vvc_sao_dsp_init, depth)(&vvcdsp->sao); \
89  FUNC(ff_vvc_alf_dsp_init, depth)(&vvcdsp->alf); \
90 
91  switch (bit_depth) {
92  case 12:
93  VVC_DSP(12);
94  break;
95  case 10:
96  VVC_DSP(10);
97  break;
98  default:
99  VVC_DSP(8);
100  break;
101  }
102 
103 #if ARCH_AARCH64
105 #elif ARCH_RISCV
107 #elif ARCH_X86
109 #endif
110 }
IntraEdgeParams::top_array
uint16_t top_array[6 *MAX_TB_SIZE+5]
Definition: dsp.c:54
src1
const pixel * src1
Definition: h264pred_template.c:421
VVC_DSP
#define VVC_DSP(depth)
vvc_sad
static int vvc_sad(const int16_t *src0, const int16_t *src1, int dx, int dy, const int block_w, const int block_h)
Definition: dsp.c:29
bit_depth
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition: af_astats.c:246
IntraEdgeParams::left
uint8_t * left
Definition: dsp.c:49
dsp_template.c
dsp.h
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
ff_vvc_dsp_init_x86
void ff_vvc_dsp_init_x86(VVCDSPContext *hpc, const int bit_depth)
Definition: vvcdsp_init.c:374
IntraEdgeParams::filtered_top_array
uint16_t filtered_top_array[6 *MAX_TB_SIZE+5]
Definition: dsp.c:55
IntraEdgeParams::top
uint8_t * top
Definition: dsp.c:48
IntraEdgeParams::filtered_left_array
uint16_t filtered_left_array[6 *MAX_TB_SIZE+5]
Definition: dsp.c:53
IntraEdgeParams::left_array
uint16_t left_array[6 *MAX_TB_SIZE+5]
Definition: dsp.c:52
ff_vvc_dsp_init
void ff_vvc_dsp_init(VVCDSPContext *vvcdsp, int bit_depth)
Definition: dsp.c:77
IntraEdgeParams
Definition: dsp.c:47
itx_1d.h
MAX_PB_SIZE
#define MAX_PB_SIZE
Definition: dsp.h:32
ff_vvc_dsp_init_riscv
void ff_vvc_dsp_init_riscv(VVCDSPContext *const c, const int bd)
Definition: vvcdsp_init.c:40
ff_vvc_dsp_init_aarch64
void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd)
Definition: dsp_init.c:99
IntraEdgeParams::filter_flag
int filter_flag
Definition: dsp.c:50
src0
const pixel *const src0
Definition: h264pred_template.c:420
MAX_TB_SIZE
#define MAX_TB_SIZE
Definition: hevcdec.h:49
ctu.h
VVCDSPContext
Definition: dsp.h:169