/src/avm/av2/common/gdf.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2025, Alliance for Open Media. All rights reserved |
3 | | * |
4 | | * This source code is subject to the terms of the BSD 3-Clause Clear License |
5 | | * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear |
6 | | * License was not distributed with this source code in the LICENSE file, you |
7 | | * can obtain it at aomedia.org/license/software-license/bsd-3-c-c/. If the |
8 | | * Alliance for Open Media Patent License 1.0 was not distributed with this |
9 | | * source code in the PATENTS file, you can obtain it at |
10 | | * aomedia.org/license/patent-license/. |
11 | | */ |
12 | | |
13 | | #ifndef AVM_AV2_COMMON_GDF_H |
14 | | #define AVM_AV2_COMMON_GDF_H |
15 | | #include "av2/common/av2_common_int.h" |
16 | | #include "av2/common/bru.h" |
17 | | #ifdef __cplusplus |
18 | | extern "C" { |
19 | | #endif |
20 | | |
21 | | enum Direction { GDF_VER, GDF_HOR, GDF_DIAG0, GDF_DIAG1, GDF_NUM_DIRS }; |
22 | | |
23 | | #define GDF_VERBOSE 0 |
24 | | |
25 | 5.63k | #define GDF_RDO_QP_NUM_LOG2 2 |
26 | 5.66k | #define GDF_RDO_SCALE_NUM_LOG2 2 |
27 | | #define GDF_RDO_QP_NUM (1 << GDF_RDO_QP_NUM_LOG2) |
28 | | #define GDF_RDO_SCALE_NUM (1 << GDF_RDO_SCALE_NUM_LOG2) |
29 | | |
30 | | /*!\brief Function to initialize information of GDF from cm |
31 | | */ |
32 | | void init_gdf(AV2_COMMON *cm); |
33 | | |
34 | | /*!\brief Function to initialize information of GDF for tests |
35 | | */ |
36 | | void init_gdf_test(GdfInfo *gi, int mib_size, int rec_height, int rec_width); |
37 | | |
38 | | /*!\brief Function to allocate memory storing block's expected coding error of |
39 | | * GDF |
40 | | */ |
41 | | void alloc_gdf_buffers(GdfInfo *gi); |
42 | | |
43 | | /*!\brief Function to free memory storing block's expected coding error of GDF |
44 | | */ |
45 | | void free_gdf_buffers(GdfInfo *gi); |
46 | | |
47 | | /*!\brief Function to print paramters of GDF |
48 | | */ |
49 | | void gdf_print_info(AV2_COMMON *cm, char *info, int poc); |
50 | | |
51 | | /*!\brief Function to extend - pad - the copy guided frame of GDF |
52 | | */ |
53 | | void gdf_extend_frame_highbd(uint16_t *data, int width, int height, int stride, |
54 | | int border_horz, int border_vert); |
55 | | |
56 | | /*!\brief Function to setup reference lines for filtering stripe |
57 | | */ |
58 | | void gdf_setup_reference_lines(AV2_COMMON *cm, int i_min, int i_max, |
59 | | int frame_stripe, int copy_above, |
60 | | int copy_below); |
61 | | |
62 | | /*!\brief Function to unset reference lines for filtering stripe |
63 | | */ |
64 | | void gdf_unset_reference_lines(AV2_COMMON *cm, int i_min, int i_max, |
65 | | int copy_above, int copy_below); |
66 | | |
67 | | /*!\brief Function to allocate memory and copy guided frame of GDF |
68 | | */ |
69 | | void gdf_copy_guided_frame(AV2_COMMON *cm); |
70 | | /*!\brief Function to free memory for guided frame of GDF |
71 | | */ |
72 | | void gdf_free_guided_frame(AV2_COMMON *cm); |
73 | | |
74 | | /*!\brief Function to calculate block index in list of block on/off flags |
75 | | */ |
76 | | int gdf_get_block_idx(const AV2_COMMON *cm, int y_h, int y_w); |
77 | | |
78 | | /*!\brief Function to calculate indices for lookup tables of GDF |
79 | | * in which index is calculated based on distances to references frames |
80 | | * and tables are weight, bias, clipping, and expected coding error |
81 | | */ |
82 | | int gdf_get_ref_dst_idx(const AV2_COMMON *cm); |
83 | | |
84 | | /*!\brief Function to calculate indices for lookup weight+bias+clipping tables |
85 | | * of GDF in which index is calculated based on QP and tables are weight, bias, |
86 | | * clipping, and expected coding error |
87 | | */ |
88 | | int gdf_get_qp_idx_base(const AV2_COMMON *cm); |
89 | | |
90 | | /*!\brief Function to apply GDF to whole frame |
91 | | */ |
92 | | void gdf_filter_frame(AV2_COMMON *cm); |
93 | | |
94 | | /*!\brief Function to check whether GDF allowed. |
95 | | */ |
96 | 381k | static inline int is_allow_gdf(const AV2_COMMON *cm) { |
97 | 381k | return !cm->features.coded_lossless; |
98 | 381k | } Unexecuted instantiation: av2_dx_iface.c:is_allow_gdf decodeframe.c:is_allow_gdf Line | Count | Source | 96 | 5.69k | static inline int is_allow_gdf(const AV2_COMMON *cm) { | 97 | 5.69k | return !cm->features.coded_lossless; | 98 | 5.69k | } |
Line | Count | Source | 96 | 375k | static inline int is_allow_gdf(const AV2_COMMON *cm) { | 97 | 375k | return !cm->features.coded_lossless; | 98 | 375k | } |
Unexecuted instantiation: gdf.c:is_allow_gdf Unexecuted instantiation: gdf_block.c:is_allow_gdf Unexecuted instantiation: level.c:is_allow_gdf Unexecuted instantiation: gdf_block_avx2.c:is_allow_gdf |
99 | | |
100 | | /*!\brief Function to check whether GDF enabled. |
101 | | */ |
102 | 40 | static inline int is_gdf_enabled(const AV2_COMMON *cm) { |
103 | 40 | return is_allow_gdf(cm) && cm->gdf_info.gdf_mode > 0; |
104 | 40 | } Unexecuted instantiation: av2_dx_iface.c:is_gdf_enabled decodeframe.c:is_gdf_enabled Line | Count | Source | 102 | 40 | static inline int is_gdf_enabled(const AV2_COMMON *cm) { | 103 | 40 | return is_allow_gdf(cm) && cm->gdf_info.gdf_mode > 0; | 104 | 40 | } |
Unexecuted instantiation: decodemv.c:is_gdf_enabled Unexecuted instantiation: gdf.c:is_gdf_enabled Unexecuted instantiation: gdf_block.c:is_gdf_enabled Unexecuted instantiation: level.c:is_gdf_enabled Unexecuted instantiation: gdf_block_avx2.c:is_gdf_enabled |
105 | | |
106 | | /*!\brief Function to adjust the GDF block boundary to ensure even alignment. |
107 | | * Because the minimum required pixel size in GDF block is 2x2. |
108 | | * \param[in] i_min The pos of the block's top boundary |
109 | | * \param[in] i_max The pos of the block's bottom boundary |
110 | | * \param[in] j_min The pos of the block's left boundary |
111 | | * \param[in] j_max The pos of the block's right boundary |
112 | | * * \return Returns a value indicating whether the block size is valid |
113 | | */ |
114 | | static inline int gdf_block_adjust_and_validate(int *i_min, int *i_max, |
115 | 328 | int *j_min, int *j_max) { |
116 | 328 | *i_min = (*i_min + 1) & ~0x1; |
117 | 328 | *i_max = *i_max & ~0x1; |
118 | 328 | *j_min = (*j_min + 1) & ~0x1; |
119 | 328 | *j_max = *j_max & ~0x1; |
120 | 328 | return (*i_max > *i_min) && (*j_max > *j_min); |
121 | 328 | } Unexecuted instantiation: av2_dx_iface.c:gdf_block_adjust_and_validate Unexecuted instantiation: decodeframe.c:gdf_block_adjust_and_validate Unexecuted instantiation: decodemv.c:gdf_block_adjust_and_validate gdf.c:gdf_block_adjust_and_validate Line | Count | Source | 115 | 328 | int *j_min, int *j_max) { | 116 | 328 | *i_min = (*i_min + 1) & ~0x1; | 117 | 328 | *i_max = *i_max & ~0x1; | 118 | 328 | *j_min = (*j_min + 1) & ~0x1; | 119 | 328 | *j_max = *j_max & ~0x1; | 120 | 328 | return (*i_max > *i_min) && (*j_max > *j_min); | 121 | 328 | } |
Unexecuted instantiation: gdf_block.c:gdf_block_adjust_and_validate Unexecuted instantiation: level.c:gdf_block_adjust_and_validate Unexecuted instantiation: gdf_block_avx2.c:gdf_block_adjust_and_validate |
122 | | |
123 | | /*!\brief Function to copy left/right buffers when disabling filtering |
124 | | * across tiles is desired. |
125 | | */ |
126 | | void gdf_setup_processing_stripe_leftright_boundary(GdfInfo *gdf, int i_min, |
127 | | int i_max, int j_min, |
128 | | int j_max, |
129 | | int tile_boundary_left, |
130 | | int tile_boundary_right); |
131 | | |
132 | | /*!\brief Function to restore left/right buffers when disabling filtering |
133 | | * across tiles is desired. |
134 | | */ |
135 | | void gdf_restore_processing_stripe_leftright_boundary(GdfInfo *gdf, int i_min, |
136 | | int i_max, int j_min, |
137 | | int j_max, |
138 | | int tile_boundary_left, |
139 | | int tile_boundary_right); |
140 | | #ifdef __cplusplus |
141 | | } // extern "C" |
142 | | #endif |
143 | | |
144 | | #endif // AVM_AV2_COMMON_GDF_H |