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
33
36
41 VkVideoDecodeUsageInfoKHR
usage;
45
50
51 VkVideoCapabilitiesKHR
caps;
53
55
59
61
64
69
72 int external_fg;
/* Oddity #2 - hardware can't apply film grain */
74
75 /* Workaround for NVIDIA drivers tested with CTS version 1.3.8 for AV1.
76 * The tests were incorrect as the OrderHints were offset by 1. */
78
79 /* Thread-local state below */
82
86
89
90 VkImageView
img_view_ref;
/* Image representation view (reference) */
91 VkImageView
img_view_out;
/* Image representation view (output-only) */
92 VkImageView
img_view_dest;
/* Set to img_view_out if no layered refs are used */
93 VkImageAspectFlags
img_aspect;
/* Image plane mask bits */
95
98
99 /* Current picture */
100 VkVideoPictureResourceInfoKHR
ref;
102
103 /* Picture refs. H264 has the maximum number of refs (36) of any supported codec. */
104 VkVideoPictureResourceInfoKHR
refs [36];
106
107 /* Main decoding struct */
109
110 /* Slice data */
113
114 /* Vulkan functions needed for destruction, as no other context is guaranteed to exist */
118
119 /**
120 * Initialize decoder.
121 */
123
124 /**
125 * Synchronize the contexts between 2 threads.
126 */
128
129 /**
130 * Initialize hw_frames_ctx with the parameters needed to decode the stream
131 * using the parameters from avctx.
132 *
133 * NOTE: if avctx->internal->hwaccel_priv_data exists, will partially initialize
134 * the context.
135 */
137
138 /**
139 * Removes current session parameters to recreate them
140 */
142
143 /**
144 * Prepare a frame, creates the image view, and sets up the dpb fields.
145 */
148 int alloc_dpb);
149
150 /**
151 * Add slice data to frame.
152 */
154 const uint8_t *
data,
size_t size,
int add_startcode,
155 uint32_t *nb_slices,
const uint32_t **
offsets);
156
157 /**
158 * Decode a frame.
159 */
163
164 /**
165 * Free a frame and its state.
166 */
168
169 /**
170 * Get an FFVkBuffer suitable for decoding from.
171 */
173 void *create_pNext,
size_t size);
174
175 /**
176 * Create VkVideoSessionParametersKHR wrapped in an AVBufferRef.
177 */
179 const VkVideoSessionParametersCreateInfoKHR *session_params_create);
180
181 /**
182 * Flush decoder.
183 */
185
186 /**
187 * Free decoder.
188 */
190
191 #endif /* AVCODEC_VULKAN_DECODE_H */