FFmpeg
vulkan_vp9.c
Go to the documentation of this file.
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 #include "vp9dec.h"
20 
21 #include "vulkan_decode.h"
22 
25  .decode_extension = FF_VK_EXT_VIDEO_DECODE_VP9,
26  .queue_flags = VK_QUEUE_VIDEO_DECODE_BIT_KHR,
27  .decode_op = VK_VIDEO_CODEC_OPERATION_DECODE_VP9_BIT_KHR,
28  .ext_props = {
29  .extensionName = VK_STD_VULKAN_VIDEO_CODEC_VP9_DECODE_EXTENSION_NAME,
30  .specVersion = VK_STD_VULKAN_VIDEO_CODEC_VP9_DECODE_SPEC_VERSION,
31  },
32 };
33 
34 typedef struct VP9VulkanDecodePicture {
36 
37  /* TODO: investigate if this can be removed to make decoding completely
38  * independent. */
40 
41  /* Current picture */
42  StdVideoVP9ColorConfig color_config;
43  StdVideoVP9Segmentation segmentation;
44  StdVideoVP9LoopFilter loop_filter;
45  StdVideoDecodeVP9PictureInfo std_pic_info;
46  VkVideoDecodeVP9PictureInfoKHR vp9_pic_info;
47 
48  const VP9Frame *ref_src[8];
49 
50  uint8_t frame_id_set;
51  uint8_t frame_id;
54 
55 static int vk_vp9_fill_pict(AVCodecContext *avctx, const VP9Frame **ref_src,
56  VkVideoReferenceSlotInfoKHR *ref_slot, /* Main structure */
57  VkVideoPictureResourceInfoKHR *ref, /* Goes in ^ */
58  const VP9Frame *pic, int is_current)
59 {
63  FFVulkanDecodePicture *vkpic = &hp->vp;
64 
65  int err = ff_vk_decode_prepare_frame(dec, pic->tf.f, vkpic, is_current,
66  dec->dedicated_dpb);
67  if (err < 0)
68  return err;
69 
70  *ref = (VkVideoPictureResourceInfoKHR) {
71  .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
72  .codedOffset = (VkOffset2D){ 0, 0 },
73  .codedExtent = (VkExtent2D){ pic->tf.f->width, pic->tf.f->height },
74  .baseArrayLayer = (dec->dedicated_dpb && ctx->common.layered_dpb) ?
75  hp->frame_id : 0,
76  .imageViewBinding = vkpic->view.ref[0],
77  };
78 
79  *ref_slot = (VkVideoReferenceSlotInfoKHR) {
80  .sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR,
81  .slotIndex = hp->frame_id,
82  .pPictureResource = ref,
83  };
84 
85  if (ref_src)
86  *ref_src = pic;
87 
88  return 0;
89 }
90 
91 static enum StdVideoVP9InterpolationFilter remap_interp(uint8_t is_filter_switchable,
92  uint8_t raw_interpolation_filter_type)
93 {
94  static const enum StdVideoVP9InterpolationFilter remap[] = {
95  STD_VIDEO_VP9_INTERPOLATION_FILTER_EIGHTTAP_SMOOTH,
96  STD_VIDEO_VP9_INTERPOLATION_FILTER_EIGHTTAP,
97  STD_VIDEO_VP9_INTERPOLATION_FILTER_EIGHTTAP_SHARP,
98  STD_VIDEO_VP9_INTERPOLATION_FILTER_BILINEAR,
99  };
100  if (is_filter_switchable)
101  return STD_VIDEO_VP9_INTERPOLATION_FILTER_SWITCHABLE;
102  return remap[raw_interpolation_filter_type];
103 }
104 
106  av_unused const AVBufferRef *buffer_ref,
107  av_unused const uint8_t *buffer,
108  av_unused uint32_t size)
109 {
110  int err;
111  int ref_count = 0;
112  const VP9Context *priv = avctx->priv_data;
113  const CodedBitstreamVP9Context *vp9 = priv->cbc->priv_data;
114  const VP9SharedContext *s = &priv->s;
115  uint32_t frame_id_alloc_mask = 0;
116 
117  const VP9Frame *pic = &s->frames[CUR_FRAME];
118  const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
120  uint8_t profile = (pic->frame_header->profile_high_bit << 1) | pic->frame_header->profile_low_bit;
121 
123  FFVulkanDecodePicture *vp = &ap->vp;
124 
125  /* Use the current frame_ids in ref_frames[] to decide occupied frame_ids */
126  for (int i = 0; i < STD_VIDEO_VP9_NUM_REF_FRAMES; i++) {
127  const VP9VulkanDecodePicture* rp = s->ref_frames[i].hwaccel_picture_private;
128  if (rp)
129  frame_id_alloc_mask |= 1 << rp->frame_id;
130  }
131 
132  if (!ap->frame_id_set) {
133  unsigned slot_idx = 0;
134  for (unsigned i = 0; i < 32; i++) {
135  if (!(frame_id_alloc_mask & (1 << i))) {
136  slot_idx = i;
137  break;
138  }
139  }
140  ap->frame_id = slot_idx;
141  ap->frame_id_set = 1;
142  frame_id_alloc_mask |= (1 << slot_idx);
143  }
144 
145  for (int i = 0; i < STD_VIDEO_VP9_REFS_PER_FRAME; i++) {
146  const int idx = pic->frame_header->ref_frame_idx[i];
147  const VP9Frame *ref_frame = &s->ref_frames[idx];
148  VP9VulkanDecodePicture *hp = ref_frame->hwaccel_picture_private;
149  int found = 0;
150 
151  if (!ref_frame->tf.f)
152  continue;
153 
154  for (int j = 0; j < ref_count; j++) {
155  if (vp->ref_slots[j].slotIndex == hp->frame_id) {
156  found = 1;
157  break;
158  }
159  }
160  if (found)
161  continue;
162 
163  err = vk_vp9_fill_pict(avctx, &ap->ref_src[ref_count],
164  &vp->ref_slots[ref_count], &vp->refs[ref_count],
165  ref_frame, 0);
166  if (err < 0)
167  return err;
168 
169  ref_count++;
170  }
171 
172  err = vk_vp9_fill_pict(avctx, NULL, &vp->ref_slot, &vp->ref,
173  pic, 1);
174  if (err < 0)
175  return err;
176 
177  ap->loop_filter = (StdVideoVP9LoopFilter) {
178  .flags = (StdVideoVP9LoopFilterFlags) {
179  .loop_filter_delta_enabled = pic->frame_header->loop_filter_delta_enabled,
180  .loop_filter_delta_update = pic->frame_header->loop_filter_delta_update,
181  },
182  .loop_filter_level = pic->frame_header->loop_filter_level,
183  .loop_filter_sharpness = pic->frame_header->loop_filter_sharpness,
184  .update_ref_delta = 0x0,
185  .update_mode_delta = 0x0,
186  };
187 
188  for (int i = 0; i < STD_VIDEO_VP9_MAX_REF_FRAMES; i++) {
189  ap->loop_filter.loop_filter_ref_deltas[i] = vp9->loop_filter_ref_deltas[i];
190  ap->loop_filter.update_ref_delta |= pic->frame_header->update_ref_delta[i];
191  }
192  for (int i = 0; i < STD_VIDEO_VP9_LOOP_FILTER_ADJUSTMENTS; i++) {
193  ap->loop_filter.loop_filter_mode_deltas[i] = vp9->loop_filter_mode_deltas[i];
194  ap->loop_filter.update_mode_delta |= pic->frame_header->update_mode_delta[i];
195  }
196 
197  ap->segmentation = (StdVideoVP9Segmentation) {
198  .flags = (StdVideoVP9SegmentationFlags) {
199  .segmentation_update_map = pic->frame_header->segmentation_update_map,
200  .segmentation_temporal_update = pic->frame_header->segmentation_temporal_update,
201  .segmentation_update_data = pic->frame_header->segmentation_update_data,
202  .segmentation_abs_or_delta_update = pic->frame_header->segmentation_abs_or_delta_update,
203  },
204  };
205 
206  for (int i = 0; i < STD_VIDEO_VP9_MAX_SEGMENTATION_TREE_PROBS; i++)
207  ap->segmentation.segmentation_tree_probs[i] = vp9->segmentation_tree_probs[i];
208  for (int i = 0; i < STD_VIDEO_VP9_MAX_SEGMENTATION_PRED_PROB; i++)
209  ap->segmentation.segmentation_pred_prob[i] = vp9->segmentation_pred_prob[i];
210  for (int i = 0; i < STD_VIDEO_VP9_MAX_SEGMENTS; i++) {
211  ap->segmentation.FeatureEnabled[i] = 0x0;
212  for (int j = 0; j < STD_VIDEO_VP9_SEG_LVL_MAX; j++) {
213  ap->segmentation.FeatureEnabled[i] |= vp9->feature_enabled[i][j] << j;
214  ap->segmentation.FeatureData[i][j] = vp9->feature_sign[i][j] ?
215  -vp9->feature_value[i][j] :
216  +vp9->feature_value[i][j];
217  }
218  }
219 
220  ap->color_config = (StdVideoVP9ColorConfig) {
221  .flags = (StdVideoVP9ColorConfigFlags) {
222  .color_range = pic->frame_header->color_range,
223  },
224  .BitDepth = profile < 2 ? 8 :
225  pic->frame_header->ten_or_twelve_bit ? 12 : 10,
226  .subsampling_x = pixdesc->log2_chroma_w,
227  .subsampling_y = pixdesc->log2_chroma_h,
228 
229  .color_space = pic->frame_header->color_space,
230  };
231 
232  ap->std_pic_info = (StdVideoDecodeVP9PictureInfo) {
233  .flags = (StdVideoDecodeVP9PictureInfoFlags) {
234  .error_resilient_mode = pic->frame_header->error_resilient_mode,
235  .intra_only = pic->frame_header->intra_only,
236  .allow_high_precision_mv = pic->frame_header->allow_high_precision_mv,
237  .refresh_frame_context = pic->frame_header->refresh_frame_context,
238  .frame_parallel_decoding_mode = pic->frame_header->frame_parallel_decoding_mode,
239  .segmentation_enabled = pic->frame_header->segmentation_enabled,
240  .show_frame = !s->h.invisible,
241  .UsePrevFrameMvs = s->h.use_last_frame_mvs,
242  },
243  .profile = profile,
244  .frame_type = pic->frame_header->frame_type,
245  .frame_context_idx = pic->frame_header->frame_context_idx,
246  .reset_frame_context = pic->frame_header->reset_frame_context,
247  .refresh_frame_flags = pic->frame_header->refresh_frame_flags,
248  .ref_frame_sign_bias_mask = 0x0,
249  .interpolation_filter = remap_interp(pic->frame_header->is_filter_switchable,
251  .base_q_idx = pic->frame_header->base_q_idx,
252  .delta_q_y_dc = pic->frame_header->delta_q_y_dc,
253  .delta_q_uv_dc = pic->frame_header->delta_q_uv_dc,
254  .delta_q_uv_ac = pic->frame_header->delta_q_uv_ac,
255  .tile_cols_log2 = pic->frame_header->tile_cols_log2,
256  .tile_rows_log2 = pic->frame_header->tile_rows_log2,
257  /* Reserved */
258  .pColorConfig = &ap->color_config,
259  .pLoopFilter = &ap->loop_filter,
260  .pSegmentation = &ap->segmentation,
261  };
262 
263  for (int i = VP9_LAST_FRAME; i <= VP9_ALTREF_FRAME; i++)
264  ap->std_pic_info.ref_frame_sign_bias_mask |= pic->frame_header->ref_frame_sign_bias[i] << i;
265 
266  ap->vp9_pic_info = (VkVideoDecodeVP9PictureInfoKHR) {
267  .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_VP9_PICTURE_INFO_KHR,
268  .pStdPictureInfo = &ap->std_pic_info,
269  .uncompressedHeaderOffset = 0,
270  .compressedHeaderOffset = s->h.uncompressed_header_size,
271  .tilesOffset = s->h.uncompressed_header_size +
272  s->h.compressed_header_size,
273  };
274 
275  for (int i = 0; i < STD_VIDEO_VP9_REFS_PER_FRAME; i++) {
276  const int idx = pic->frame_header->ref_frame_idx[i];
277  const VP9Frame *ref_frame = &s->ref_frames[idx];
278  VP9VulkanDecodePicture *hp = ref_frame->hwaccel_picture_private;
279 
280  if (!ref_frame->tf.f)
281  ap->vp9_pic_info.referenceNameSlotIndices[i] = -1;
282  else
283  ap->vp9_pic_info.referenceNameSlotIndices[i] = hp->frame_id;
284  }
285 
286  vp->decode_info = (VkVideoDecodeInfoKHR) {
287  .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR,
288  .pNext = &ap->vp9_pic_info,
289  .flags = 0x0,
290  .pSetupReferenceSlot = &vp->ref_slot,
291  .referenceSlotCount = ref_count,
292  .pReferenceSlots = vp->ref_slots,
293  .dstPictureResource = (VkVideoPictureResourceInfoKHR) {
294  .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
295  .codedOffset = (VkOffset2D){ 0, 0 },
296  .codedExtent = (VkExtent2D){ pic->tf.f->width, pic->tf.f->height },
297  .baseArrayLayer = 0,
298  .imageViewBinding = vp->view.out[0],
299  },
300  };
301 
302  ap->dec = dec;
303 
304  return 0;
305 }
306 
308  const uint8_t *data,
309  uint32_t size)
310 {
311  int err;
312  const VP9SharedContext *s = avctx->priv_data;
313  VP9VulkanDecodePicture *ap = s->frames[CUR_FRAME].hwaccel_picture_private;
314  FFVulkanDecodePicture *vp = &ap->vp;
315 
316  err = ff_vk_decode_add_slice(avctx, vp, data, size, 0, NULL, NULL);
317  if (err < 0)
318  return err;
319 
320  return 0;
321 }
322 
324 {
325  const VP9SharedContext *s = avctx->priv_data;
326 
327  const VP9Frame *pic = &s->frames[CUR_FRAME];
329  FFVulkanDecodePicture *vp = &ap->vp;
330  FFVulkanDecodePicture *rvp[STD_VIDEO_VP9_REFS_PER_FRAME] = { 0 };
331  AVFrame *rav[STD_VIDEO_VP9_REFS_PER_FRAME] = { 0 };
332 
333  for (int i = 0; i < vp->decode_info.referenceSlotCount; i++) {
334  const VP9Frame *rp = ap->ref_src[i];
336 
337  rvp[i] = &rhp->vp;
338  rav[i] = ap->ref_src[i]->tf.f;
339  }
340 
341  av_log(avctx, AV_LOG_VERBOSE, "Decoding frame, %zu bytes\n",
342  vp->slices_size);
343 
344  return ff_vk_decode_frame(avctx, pic->tf.f, vp, rav, rvp);
345 }
346 
348 {
349  AVHWDeviceContext *hwctx = _hwctx.nc;
351 
352  /* Free frame resources, this also destroys the session parameters. */
353  ff_vk_decode_free_frame(hwctx, &ap->vp);
354 }
355 
357  .p.name = "vp9_vulkan",
358  .p.type = AVMEDIA_TYPE_VIDEO,
359  .p.id = AV_CODEC_ID_VP9,
360  .p.pix_fmt = AV_PIX_FMT_VULKAN,
361  .start_frame = &vk_vp9_start_frame,
362  .decode_slice = &vk_vp9_decode_slice,
363  .end_frame = &vk_vp9_end_frame,
364  .free_frame_priv = &vk_vp9_free_frame_priv,
365  .frame_priv_data_size = sizeof(VP9VulkanDecodePicture),
370  .frame_params = &ff_vk_frame_params,
371  .priv_data_size = sizeof(FFVulkanDecodeContext),
372  .caps_internal = HWACCEL_CAP_ASYNC_SAFE,
373 };
VP9RawFrameHeader::intra_only
uint8_t intra_only
Definition: cbs_vp9.h:104
FFVulkanDecodePicture::slices_size
size_t slices_size
Definition: vulkan_decode.h:102
VP9VulkanDecodePicture::frame_id_set
uint8_t frame_id_set
Definition: vulkan_vp9.c:50
VP9RawFrameHeader::ref_frame_idx
uint8_t ref_frame_idx[VP9_REFS_PER_FRAME]
Definition: cbs_vp9.h:107
VP9RawFrameHeader::delta_q_uv_dc
int8_t delta_q_uv_dc
Definition: cbs_vp9.h:142
CodedBitstreamContext::priv_data
void * priv_data
Internal codec-specific data.
Definition: cbs.h:247
VP9Frame
Definition: vp9shared.h:66
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3456
FFVulkanDecodeContext::shared_ctx
FFVulkanDecodeShared * shared_ctx
Definition: vulkan_decode.h:57
AVRefStructOpaque
RefStruct is an API for creating reference-counted objects with minimal overhead.
Definition: refstruct.h:58
VP9VulkanDecodePicture::segmentation
StdVideoVP9Segmentation segmentation
Definition: vulkan_vp9.c:43
VP9RawFrameHeader::tile_rows_log2
uint8_t tile_rows_log2
Definition: cbs_vp9.h:159
AVRefStructOpaque::nc
void * nc
Definition: refstruct.h:59
av_unused
#define av_unused
Definition: attributes.h:151
FFHWAccel::p
AVHWAccel p
The public AVHWAccel.
Definition: hwaccel_internal.h:38
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:427
AVFrame::width
int width
Definition: frame.h:499
VP9VulkanDecodePicture::ref_src
const VP9Frame * ref_src[8]
Definition: vulkan_vp9.c:48
VP9RawFrameHeader::profile_high_bit
uint8_t profile_high_bit
Definition: cbs_vp9.h:86
VP9RawFrameHeader::error_resilient_mode
uint8_t error_resilient_mode
Definition: cbs_vp9.h:93
data
const char data[16]
Definition: mxf.c:149
FFVulkanDecodeDescriptor::codec_id
enum AVCodecID codec_id
Definition: vulkan_decode.h:30
VP9RawFrameHeader::frame_context_idx
uint8_t frame_context_idx
Definition: cbs_vp9.h:115
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:226
VP9Frame::tf
ProgressFrame tf
Definition: vp9shared.h:70
VP9RawFrameHeader::raw_interpolation_filter_type
uint8_t raw_interpolation_filter_type
Definition: cbs_vp9.h:127
CodedBitstreamVP9Context::feature_sign
uint8_t feature_sign[VP9_MAX_SEGMENTS][VP9_SEG_LVL_MAX]
Definition: cbs_vp9.h:215
FFVulkanDecodeContext
Definition: vulkan_decode.h:56
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
ff_vk_decode_prepare_frame
int ff_vk_decode_prepare_frame(FFVulkanDecodeContext *dec, AVFrame *pic, FFVulkanDecodePicture *vkpic, int is_current, int alloc_dpb)
Prepare a frame, creates the image view, and sets up the dpb fields.
Definition: vulkan_decode.c:190
vk_vp9_free_frame_priv
static void vk_vp9_free_frame_priv(AVRefStructOpaque _hwctx, void *data)
Definition: vulkan_vp9.c:347
VP9VulkanDecodePicture
Definition: vulkan_vp9.c:34
FFHWAccel
Definition: hwaccel_internal.h:34
AVCodecContext::refs
int refs
number of reference frames
Definition: avcodec.h:697
ff_vk_decode_frame
int ff_vk_decode_frame(AVCodecContext *avctx, AVFrame *pic, FFVulkanDecodePicture *vp, AVFrame *rpic[], FFVulkanDecodePicture *rvkp[])
Decode a frame.
Definition: vulkan_decode.c:411
FFVulkanDecodeShared
Definition: vulkan_decode.h:38
VP9Frame::hwaccel_picture_private
void * hwaccel_picture_private
RefStruct reference.
Definition: vp9shared.h:76
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:63
VP9VulkanDecodePicture::vp9_pic_info
VkVideoDecodeVP9PictureInfoKHR vp9_pic_info
Definition: vulkan_vp9.c:46
VP9_LAST_FRAME
@ VP9_LAST_FRAME
Definition: cbs_vp9.h:70
VP9_ALTREF_FRAME
@ VP9_ALTREF_FRAME
Definition: cbs_vp9.h:72
VP9VulkanDecodePicture::color_config
StdVideoVP9ColorConfig color_config
Definition: vulkan_vp9.c:42
VP9VulkanDecodePicture::dec
FFVulkanDecodeContext * dec
Definition: vulkan_vp9.c:39
s
#define s(width, name)
Definition: cbs_vp9.c:198
VP9SharedContext
Definition: vp9shared.h:168
FFVulkanDecodePicture
Definition: vulkan_decode.h:75
VP9Context::s
VP9SharedContext s
Definition: vp9dec.h:98
ff_vk_dec_vp9_desc
const FFVulkanDecodeDescriptor ff_vk_dec_vp9_desc
Definition: vulkan_vp9.c:23
AV_CODEC_ID_VP9
@ AV_CODEC_ID_VP9
Definition: codec_id.h:222
remap_interp
static enum StdVideoVP9InterpolationFilter remap_interp(uint8_t is_filter_switchable, uint8_t raw_interpolation_filter_type)
Definition: vulkan_vp9.c:91
vk_vp9_end_frame
static int vk_vp9_end_frame(AVCodecContext *avctx)
Definition: vulkan_vp9.c:323
VP9VulkanDecodePicture::vp
FFVulkanDecodePicture vp
Definition: vulkan_vp9.c:35
VP9VulkanDecodePicture::std_pic_info
StdVideoDecodeVP9PictureInfo std_pic_info
Definition: vulkan_vp9.c:45
ctx
AVFormatContext * ctx
Definition: movenc.c:49
VP9RawFrameHeader::ten_or_twelve_bit
uint8_t ten_or_twelve_bit
Definition: cbs_vp9.h:96
CodedBitstreamVP9Context::segmentation_pred_prob
uint8_t segmentation_pred_prob[3]
Definition: cbs_vp9.h:212
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
VP9VulkanDecodePicture::loop_filter
StdVideoVP9LoopFilter loop_filter
Definition: vulkan_vp9.c:44
HWACCEL_CAP_ASYNC_SAFE
#define HWACCEL_CAP_ASYNC_SAFE
Header providing the internals of AVHWAccel.
Definition: hwaccel_internal.h:31
VP9RawFrameHeader::refresh_frame_context
uint8_t refresh_frame_context
Definition: cbs_vp9.h:112
VP9VulkanDecodePicture::frame_id
uint8_t frame_id
Definition: vulkan_vp9.c:51
NULL
#define NULL
Definition: coverity.c:32
VP9Frame::frame_header
VP9RawFrameHeader * frame_header
Definition: vp9shared.h:68
ff_vk_decode_free_frame
void ff_vk_decode_free_frame(AVHWDeviceContext *dev_ctx, FFVulkanDecodePicture *vp)
Free a frame and its state.
Definition: vulkan_decode.c:617
VP9Context
Definition: vp9dec.h:97
FF_VK_EXT_VIDEO_DECODE_VP9
#define FF_VK_EXT_VIDEO_DECODE_VP9
Definition: vulkan_functions.h:63
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:474
ff_vk_decode_uninit
int ff_vk_decode_uninit(AVCodecContext *avctx)
Free decoder.
Definition: vulkan_decode.c:1229
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts.c:552
CodedBitstreamVP9Context::loop_filter_mode_deltas
int8_t loop_filter_mode_deltas[2]
Definition: cbs_vp9.h:210
VP9RawFrameHeader::profile_low_bit
uint8_t profile_low_bit
Definition: cbs_vp9.h:85
ff_vk_frame_params
int ff_vk_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Initialize hw_frames_ctx with the parameters needed to decode the stream using the parameters from av...
Definition: vulkan_decode.c:1089
VP9RawFrameHeader::ref_frame_sign_bias
uint8_t ref_frame_sign_bias[VP9_MAX_REF_FRAMES]
Definition: cbs_vp9.h:108
VP9RawFrameHeader::delta_q_y_dc
int8_t delta_q_y_dc
Definition: cbs_vp9.h:141
VP9RawFrameHeader::segmentation_temporal_update
uint8_t segmentation_temporal_update
Definition: cbs_vp9.h:149
VP9RawFrameHeader::segmentation_update_map
uint8_t segmentation_update_map
Definition: cbs_vp9.h:147
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:550
AVCodecInternal::hwaccel_priv_data
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:130
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:424
FFVulkanDecodePicture::ref
VkImageView ref[AV_NUM_DATA_POINTERS]
Definition: vulkan_decode.h:79
size
int size
Definition: twinvq_data.h:10344
ref_frame
static int ref_frame(VVCFrame *dst, const VVCFrame *src)
Definition: dec.c:616
VP9RawFrameHeader::frame_parallel_decoding_mode
uint8_t frame_parallel_decoding_mode
Definition: cbs_vp9.h:113
remap
static const int remap[16]
Definition: msvideo1enc.c:66
FFVulkanDecodePicture::view
struct FFVulkanDecodePicture::@327 view
CodedBitstreamVP9Context
Definition: cbs_vp9.h:192
VP9RawFrameHeader::is_filter_switchable
uint8_t is_filter_switchable
Definition: cbs_vp9.h:126
AVHWAccel::name
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:1957
VP9RawFrameHeader::segmentation_abs_or_delta_update
uint8_t segmentation_abs_or_delta_update
Definition: cbs_vp9.h:152
VP9RawFrameHeader::delta_q_uv_ac
int8_t delta_q_uv_ac
Definition: cbs_vp9.h:143
ff_vp9_vulkan_hwaccel
const FFHWAccel ff_vp9_vulkan_hwaccel
Definition: vulkan_vp9.c:356
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
VP9RawFrameHeader::color_range
uint8_t color_range
Definition: cbs_vp9.h:98
CodedBitstreamVP9Context::loop_filter_ref_deltas
int8_t loop_filter_ref_deltas[VP9_MAX_REF_FRAMES]
Definition: cbs_vp9.h:209
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
VP9RawFrameHeader::tile_cols_log2
uint8_t tile_cols_log2
Definition: cbs_vp9.h:158
vk_vp9_fill_pict
static int vk_vp9_fill_pict(AVCodecContext *avctx, const VP9Frame **ref_src, VkVideoReferenceSlotInfoKHR *ref_slot, VkVideoPictureResourceInfoKHR *ref, const VP9Frame *pic, int is_current)
Definition: vulkan_vp9.c:55
VP9RawFrameHeader::base_q_idx
uint8_t base_q_idx
Definition: cbs_vp9.h:140
vk_vp9_decode_slice
static int vk_vp9_decode_slice(AVCodecContext *avctx, const uint8_t *data, uint32_t size)
Definition: vulkan_vp9.c:307
VP9RawFrameHeader::reset_frame_context
uint8_t reset_frame_context
Definition: cbs_vp9.h:105
VP9RawFrameHeader::frame_type
uint8_t frame_type
Definition: cbs_vp9.h:91
profile
int profile
Definition: mxfenc.c:2297
ff_vk_decode_flush
void ff_vk_decode_flush(AVCodecContext *avctx)
Flush decoder.
Definition: vulkan_decode.c:375
VP9RawFrameHeader::loop_filter_sharpness
uint8_t loop_filter_sharpness
Definition: cbs_vp9.h:131
ProgressFrame::f
struct AVFrame * f
Definition: progressframe.h:74
ff_vk_decode_add_slice
int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp, const uint8_t *data, size_t size, int add_startcode, uint32_t *nb_slices, const uint32_t **offsets)
Add slice data to frame.
Definition: vulkan_decode.c:294
VP9RawFrameHeader::update_ref_delta
uint8_t update_ref_delta[VP9_MAX_REF_FRAMES]
Definition: cbs_vp9.h:134
AVCodecContext
main external API structure.
Definition: avcodec.h:439
AVFrame::height
int height
Definition: frame.h:499
FFVulkanDecodeContext::dedicated_dpb
int dedicated_dpb
Definition: vulkan_decode.h:60
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
CodedBitstreamVP9Context::feature_value
uint8_t feature_value[VP9_MAX_SEGMENTS][VP9_SEG_LVL_MAX]
Definition: cbs_vp9.h:214
VP9RawFrameHeader::color_space
uint8_t color_space
Definition: cbs_vp9.h:97
update_thread_context
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have update_thread_context() run it in the next thread. Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little speed gain at this point but it should work. Use ff_thread_get_buffer()(or ff_progress_frame_get_buffer() in case you have inter-frame dependencies and use the ProgressFrame API) to allocate frame buffers. Call ff_progress_frame_report() after some part of the current picture has decoded. A good place to put this is where draw_horiz_band() is called - add this if it isn 't called anywhere
FFVulkanDecodeDescriptor
Definition: vulkan_decode.h:29
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:117
VP9Context::cbc
CodedBitstreamContext * cbc
Definition: vp9dec.h:101
ff_vk_update_thread_context
int ff_vk_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
Synchronize the contexts between 2 threads.
Definition: vulkan_decode.c:134
vp9dec.h
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
VP9RawFrameHeader::segmentation_enabled
uint8_t segmentation_enabled
Definition: cbs_vp9.h:146
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
CUR_FRAME
#define CUR_FRAME
Definition: vp9shared.h:172
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
VP9RawFrameHeader::segmentation_update_data
uint8_t segmentation_update_data
Definition: cbs_vp9.h:151
VP9RawFrameHeader::loop_filter_delta_enabled
uint8_t loop_filter_delta_enabled
Definition: cbs_vp9.h:132
vulkan_decode.h
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:466
VP9RawFrameHeader::update_mode_delta
uint8_t update_mode_delta[2]
Definition: cbs_vp9.h:136
VP9RawFrameHeader::allow_high_precision_mv
uint8_t allow_high_precision_mv
Definition: cbs_vp9.h:110
VP9VulkanDecodePicture::ref_frame_sign_bias_mask
uint8_t ref_frame_sign_bias_mask
Definition: vulkan_vp9.c:52
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
CodedBitstreamVP9Context::segmentation_tree_probs
uint8_t segmentation_tree_probs[7]
Definition: cbs_vp9.h:211
VP9RawFrameHeader::loop_filter_delta_update
uint8_t loop_filter_delta_update
Definition: cbs_vp9.h:133
ff_vk_decode_init
int ff_vk_decode_init(AVCodecContext *avctx)
Initialize decoder.
Definition: vulkan_decode.c:1281
FFVulkanDecodePicture::decode_info
VkVideoDecodeInfoKHR decode_info
Definition: vulkan_decode.h:98
AVCodecContext::sw_pix_fmt
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:646
vk_vp9_start_frame
static int vk_vp9_start_frame(AVCodecContext *avctx, av_unused const AVBufferRef *buffer_ref, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition: vulkan_vp9.c:105
VP9RawFrameHeader::loop_filter_level
uint8_t loop_filter_level
Definition: cbs_vp9.h:130
CodedBitstreamVP9Context::feature_enabled
uint8_t feature_enabled[VP9_MAX_SEGMENTS][VP9_SEG_LVL_MAX]
Definition: cbs_vp9.h:213
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
VP9RawFrameHeader::refresh_frame_flags
uint8_t refresh_frame_flags
Definition: cbs_vp9.h:102