1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef AVCODEC_VULKAN_DECODE_H
20 #define AVCODEC_VULKAN_DECODE_H
21
26
28
34
37
43
45
46 VkVideoCapabilitiesKHR
caps;
48
50
51 /* Software-defined decoder context */
55
59
61 int external_fg;
/* Oddity #2 - hardware can't apply film grain */
62
63 /* Workaround for NVIDIA drivers tested with CTS version 1.3.8 for AV1.
64 * The tests were incorrect as the OrderHints were offset by 1. */
66
67 /* Thread-local state below */
70
74
77
78 struct {
85
88
89 /* Current picture */
90 VkVideoPictureResourceInfoKHR
ref;
92
93 /* Picture refs. H264 has the maximum number of refs (36) of any supported codec. */
94 VkVideoPictureResourceInfoKHR
refs [36];
96
97 /* Main decoding struct */
99
100 /* Slice data */
103
104 /* Vulkan functions needed for destruction, as no other context is guaranteed to exist */
109
110 /**
111 * Initialize decoder.
112 */
114
115 /**
116 * Synchronize the contexts between 2 threads.
117 */
119
120 /**
121 * Initialize hw_frames_ctx with the parameters needed to decode the stream
122 * using the parameters from avctx.
123 *
124 * NOTE: if avctx->internal->hwaccel_priv_data exists, will partially initialize
125 * the context.
126 */
128
129 /**
130 * Removes current session parameters to recreate them
131 */
133
134 /**
135 * Prepare a frame, creates the image view, and sets up the dpb fields.
136 */
139 int alloc_dpb);
140
141 /**
142 * Software-defined decoder version of ff_vk_decode_prepare_frame.
143 */
147
148 /**
149 * Add slice data to frame.
150 */
152 const uint8_t *
data,
size_t size,
int add_startcode,
153 uint32_t *nb_slices,
const uint32_t **
offsets);
154
155 /**
156 * Decode a frame.
157 */
161
162 /**
163 * Free a frame and its state.
164 */
166
167 /**
168 * Get an FFVkBuffer suitable for decoding from.
169 */
171 void *create_pNext,
size_t size);
172
173 /**
174 * Create VkVideoSessionParametersKHR wrapped in an AVBufferRef.
175 */
177 const VkVideoSessionParametersCreateInfoKHR *session_params_create);
178
179 /**
180 * Flush decoder.
181 */
183
184 /**
185 * Free decoder.
186 */
188
189 #endif /* AVCODEC_VULKAN_DECODE_H */