FFmpeg
vdpau.c
Go to the documentation of this file.
1 /*
2  * Video Decode and Presentation API for UNIX (VDPAU) is used for
3  * HW decode acceleration for MPEG-1/2, MPEG-4 ASP, H.264 and VC-1.
4  *
5  * Copyright (c) 2008 NVIDIA
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include <limits.h>
25 
26 #include "avcodec.h"
27 #include "decode.h"
28 #include "internal.h"
29 #include "h264dec.h"
30 #include "vc1.h"
31 #include "vdpau.h"
32 #include "vdpau_internal.h"
33 
34 // XXX: at the time of adding this ifdefery, av_assert* wasn't use outside.
35 // When dropping it, make sure other av_assert* were not added since then.
36 
37 /**
38  * @addtogroup VDPAU_Decoding
39  *
40  * @{
41  */
42 
43 static int vdpau_error(VdpStatus status)
44 {
45  switch (status) {
46  case VDP_STATUS_OK:
47  return 0;
48  case VDP_STATUS_NO_IMPLEMENTATION:
49  return AVERROR(ENOSYS);
50  case VDP_STATUS_DISPLAY_PREEMPTED:
51  return AVERROR(EIO);
52  case VDP_STATUS_INVALID_HANDLE:
53  return AVERROR(EBADF);
54  case VDP_STATUS_INVALID_POINTER:
55  return AVERROR(EFAULT);
56  case VDP_STATUS_RESOURCES:
57  return AVERROR(ENOBUFS);
58  case VDP_STATUS_HANDLE_DEVICE_MISMATCH:
59  return AVERROR(EXDEV);
60  case VDP_STATUS_ERROR:
61  return AVERROR(EIO);
62  default:
63  return AVERROR(EINVAL);
64  }
65 }
66 
68 {
69  return av_vdpau_alloc_context();
70 }
71 
72 MAKE_ACCESSORS(AVVDPAUContext, vdpau_hwaccel, AVVDPAU_Render2, render2)
73 
75  VdpChromaType *type,
76  uint32_t *width, uint32_t *height)
77 {
78  VdpChromaType t;
79  uint32_t w = avctx->coded_width;
80  uint32_t h = avctx->coded_height;
81 
82  /* See <vdpau/vdpau.h> for per-type alignment constraints. */
83  switch (avctx->sw_pix_fmt) {
84  case AV_PIX_FMT_YUV420P:
86  t = VDP_CHROMA_TYPE_420;
87  w = (w + 1) & ~1;
88  h = (h + 3) & ~3;
89  break;
90  case AV_PIX_FMT_YUV422P:
92  t = VDP_CHROMA_TYPE_422;
93  w = (w + 1) & ~1;
94  h = (h + 1) & ~1;
95  break;
96  case AV_PIX_FMT_YUV444P:
98  t = VDP_CHROMA_TYPE_444;
99  h = (h + 1) & ~1;
100  break;
101  default:
102  return AVERROR(ENOSYS);
103  }
104 
105  if (type)
106  *type = t;
107  if (width)
108  *width = w;
109  if (height)
110  *height = h;
111  return 0;
112 }
113 
115  AVBufferRef *hw_frames_ctx)
116 {
117  AVHWFramesContext *hw_frames = (AVHWFramesContext*)hw_frames_ctx->data;
118  VdpChromaType type;
119  uint32_t width;
120  uint32_t height;
121 
123  return AVERROR(EINVAL);
124 
125  hw_frames->format = AV_PIX_FMT_VDPAU;
126  hw_frames->sw_format = avctx->sw_pix_fmt;
127  hw_frames->width = width;
128  hw_frames->height = height;
129 
130  return 0;
131 }
132 
133 int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
134  int level)
135 {
136  VDPAUHWContext *hwctx = avctx->hwaccel_context;
137  VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
138  VdpVideoSurfaceQueryCapabilities *surface_query_caps;
139  VdpDecoderQueryCapabilities *decoder_query_caps;
140  VdpDecoderCreate *create;
141  VdpGetInformationString *info;
142  const char *info_string;
143  void *func;
144  VdpStatus status;
145  VdpBool supported;
146  uint32_t max_level, max_mb, max_width, max_height;
147  VdpChromaType type;
148  uint32_t width;
149  uint32_t height;
150  int ret;
151 
152  vdctx->width = UINT32_MAX;
153  vdctx->height = UINT32_MAX;
154 
156  return AVERROR(ENOSYS);
157 
158  if (hwctx) {
159  hwctx->reset = 0;
160 
161  if (hwctx->context.decoder != VDP_INVALID_HANDLE) {
162  vdctx->decoder = hwctx->context.decoder;
163  vdctx->render = hwctx->context.render;
164  vdctx->device = VDP_INVALID_HANDLE;
165  return 0; /* Decoder created by user */
166  }
167 
168  vdctx->device = hwctx->device;
169  vdctx->get_proc_address = hwctx->get_proc_address;
170 
171  if (hwctx->flags & AV_HWACCEL_FLAG_IGNORE_LEVEL)
172  level = 0;
173 
174  if (!(hwctx->flags & AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH) &&
175  type != VDP_CHROMA_TYPE_420)
176  return AVERROR(ENOSYS);
177  } else {
178  AVHWFramesContext *frames_ctx;
179  AVVDPAUDeviceContext *dev_ctx;
180 
182  if (ret < 0)
183  return ret;
184 
185  frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
186  dev_ctx = frames_ctx->device_ctx->hwctx;
187 
188  vdctx->device = dev_ctx->device;
189  vdctx->get_proc_address = dev_ctx->get_proc_address;
190 
192  level = 0;
193  }
194 
195  if (level < 0)
196  return AVERROR(ENOTSUP);
197 
198  status = vdctx->get_proc_address(vdctx->device,
199  VDP_FUNC_ID_GET_INFORMATION_STRING,
200  &func);
201  if (status != VDP_STATUS_OK)
202  return vdpau_error(status);
203  else
204  info = func;
205 
206  status = info(&info_string);
207  if (status != VDP_STATUS_OK)
208  return vdpau_error(status);
209  if (avctx->codec_id == AV_CODEC_ID_HEVC && strncmp(info_string, "NVIDIA ", 7) == 0 &&
211  int driver_version = 0;
212  sscanf(info_string, "NVIDIA VDPAU Driver Shared Library %d", &driver_version);
213  if (driver_version < 410) {
214  av_log(avctx, AV_LOG_VERBOSE, "HEVC with NVIDIA VDPAU drivers is buggy, skipping.\n");
215  return AVERROR(ENOTSUP);
216  }
217  }
218 
219  status = vdctx->get_proc_address(vdctx->device,
220  VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
221  &func);
222  if (status != VDP_STATUS_OK)
223  return vdpau_error(status);
224  else
225  surface_query_caps = func;
226 
227  status = surface_query_caps(vdctx->device, type, &supported,
228  &max_width, &max_height);
229  if (status != VDP_STATUS_OK)
230  return vdpau_error(status);
231  if (supported != VDP_TRUE ||
232  max_width < width || max_height < height)
233  return AVERROR(ENOTSUP);
234 
235  status = vdctx->get_proc_address(vdctx->device,
236  VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES,
237  &func);
238  if (status != VDP_STATUS_OK)
239  return vdpau_error(status);
240  else
241  decoder_query_caps = func;
242 
243  status = decoder_query_caps(vdctx->device, profile, &supported, &max_level,
244  &max_mb, &max_width, &max_height);
245 #ifdef VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE
246  if ((status != VDP_STATUS_OK || supported != VDP_TRUE) && profile == VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE) {
247  profile = VDP_DECODER_PROFILE_H264_MAIN;
248  status = decoder_query_caps(vdctx->device, profile, &supported,
249  &max_level, &max_mb,
250  &max_width, &max_height);
251  }
252 #endif
253  if (status != VDP_STATUS_OK)
254  return vdpau_error(status);
255 
256  if (supported != VDP_TRUE || max_level < level ||
257  max_width < width || max_height < height)
258  return AVERROR(ENOTSUP);
259 
260  status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_CREATE,
261  &func);
262  if (status != VDP_STATUS_OK)
263  return vdpau_error(status);
264  else
265  create = func;
266 
267  status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_DECODER_RENDER,
268  &func);
269  if (status != VDP_STATUS_OK)
270  return vdpau_error(status);
271  else
272  vdctx->render = func;
273 
274  status = create(vdctx->device, profile, width, height, avctx->refs,
275  &vdctx->decoder);
276  if (status == VDP_STATUS_OK) {
277  vdctx->width = avctx->coded_width;
278  vdctx->height = avctx->coded_height;
279  }
280 
281  return vdpau_error(status);
282 }
283 
285 {
286  VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
287  VdpDecoderDestroy *destroy;
288  void *func;
289  VdpStatus status;
290 
291  if (vdctx->device == VDP_INVALID_HANDLE)
292  return 0; /* Decoder created and destroyed by user */
293  if (vdctx->width == UINT32_MAX && vdctx->height == UINT32_MAX)
294  return 0;
295 
296  status = vdctx->get_proc_address(vdctx->device,
297  VDP_FUNC_ID_DECODER_DESTROY, &func);
298  if (status != VDP_STATUS_OK)
299  return vdpau_error(status);
300  else
301  destroy = func;
302 
303  status = destroy(vdctx->decoder);
304  return vdpau_error(status);
305 }
306 
308 {
309  VDPAUHWContext *hwctx = avctx->hwaccel_context;
310  VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
311 
312  if (vdctx->device == VDP_INVALID_HANDLE)
313  return 0; /* Decoder created by user */
314  if (avctx->coded_width == vdctx->width &&
315  avctx->coded_height == vdctx->height && (!hwctx || !hwctx->reset))
316  return 0;
317 
318  avctx->hwaccel->uninit(avctx);
319  return avctx->hwaccel->init(avctx);
320 }
321 
323  av_unused const uint8_t *buffer,
324  av_unused uint32_t size)
325 {
326  pic_ctx->bitstream_buffers_allocated = 0;
327  pic_ctx->bitstream_buffers_used = 0;
328  pic_ctx->bitstream_buffers = NULL;
329  return 0;
330 }
331 
333  struct vdpau_picture_context *pic_ctx)
334 {
335  VDPAUContext *vdctx = avctx->internal->hwaccel_priv_data;
336  AVVDPAUContext *hwctx = avctx->hwaccel_context;
337  VdpVideoSurface surf = ff_vdpau_get_surface_id(frame);
338  VdpStatus status;
339  int val;
340 
341  val = ff_vdpau_common_reinit(avctx);
342  if (val < 0)
343  return val;
344 
345  if (hwctx && !hwctx->render && hwctx->render2) {
346  status = hwctx->render2(avctx, frame, (void *)&pic_ctx->info,
347  pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
348  } else
349  status = vdctx->render(vdctx->decoder, surf, &pic_ctx->info,
350  pic_ctx->bitstream_buffers_used,
351  pic_ctx->bitstream_buffers);
352 
353  av_freep(&pic_ctx->bitstream_buffers);
354 
355  return vdpau_error(status);
356 }
357 
358 #if CONFIG_MPEG1_VDPAU_HWACCEL || \
359  CONFIG_MPEG2_VDPAU_HWACCEL || CONFIG_MPEG4_VDPAU_HWACCEL || \
360  CONFIG_VC1_VDPAU_HWACCEL || CONFIG_WMV3_VDPAU_HWACCEL
362 {
363  MpegEncContext *s = avctx->priv_data;
364  Picture *pic = s->current_picture_ptr;
365  struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
366  int val;
367 
368  val = ff_vdpau_common_end_frame(avctx, pic->f, pic_ctx);
369  if (val < 0)
370  return val;
371 
372  ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);
373  return 0;
374 }
375 #endif
376 
378  const uint8_t *buf, uint32_t size)
379 {
380  VdpBitstreamBuffer *buffers = pic_ctx->bitstream_buffers;
381 
382  buffers = av_fast_realloc(buffers, &pic_ctx->bitstream_buffers_allocated,
383  (pic_ctx->bitstream_buffers_used + 1) * sizeof(*buffers));
384  if (!buffers)
385  return AVERROR(ENOMEM);
386 
387  pic_ctx->bitstream_buffers = buffers;
388  buffers += pic_ctx->bitstream_buffers_used++;
389 
390  buffers->struct_version = VDP_BITSTREAM_BUFFER_VERSION;
391  buffers->bitstream = buf;
392  buffers->bitstream_bytes = size;
393  return 0;
394 }
395 
396 #if FF_API_VDPAU_PROFILE
397 int av_vdpau_get_profile(AVCodecContext *avctx, VdpDecoderProfile *profile)
398 {
399 #define PROFILE(prof) \
400 do { \
401  *profile = VDP_DECODER_PROFILE_##prof; \
402  return 0; \
403 } while (0)
404 
405  switch (avctx->codec_id) {
406  case AV_CODEC_ID_MPEG1VIDEO: PROFILE(MPEG1);
408  switch (avctx->profile) {
409  case FF_PROFILE_MPEG2_MAIN: PROFILE(MPEG2_MAIN);
410  case FF_PROFILE_MPEG2_SIMPLE: PROFILE(MPEG2_SIMPLE);
411  default: return AVERROR(EINVAL);
412  }
413  case AV_CODEC_ID_H263: PROFILE(MPEG4_PART2_ASP);
414  case AV_CODEC_ID_MPEG4:
415  switch (avctx->profile) {
416  case FF_PROFILE_MPEG4_SIMPLE: PROFILE(MPEG4_PART2_SP);
417  case FF_PROFILE_MPEG4_ADVANCED_SIMPLE: PROFILE(MPEG4_PART2_ASP);
418  default: return AVERROR(EINVAL);
419  }
420  case AV_CODEC_ID_H264:
421  switch (avctx->profile & ~FF_PROFILE_H264_INTRA) {
422  case FF_PROFILE_H264_BASELINE: PROFILE(H264_BASELINE);
424  case FF_PROFILE_H264_MAIN: PROFILE(H264_MAIN);
425  case FF_PROFILE_H264_HIGH: PROFILE(H264_HIGH);
426 #ifdef VDP_DECODER_PROFILE_H264_EXTENDED
427  case FF_PROFILE_H264_EXTENDED: PROFILE(H264_EXTENDED);
428 #endif
429  default: return AVERROR(EINVAL);
430  }
431  case AV_CODEC_ID_WMV3:
432  case AV_CODEC_ID_VC1:
433  switch (avctx->profile) {
434  case FF_PROFILE_VC1_SIMPLE: PROFILE(VC1_SIMPLE);
435  case FF_PROFILE_VC1_MAIN: PROFILE(VC1_MAIN);
436  case FF_PROFILE_VC1_ADVANCED: PROFILE(VC1_ADVANCED);
437  default: return AVERROR(EINVAL);
438  }
439  }
440  return AVERROR(EINVAL);
441 #undef PROFILE
442 }
443 #endif /* FF_API_VDPAU_PROFILE */
444 
446 {
447  return av_mallocz(sizeof(VDPAUHWContext));
448 }
449 
450 int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device,
451  VdpGetProcAddress *get_proc, unsigned flags)
452 {
453  VDPAUHWContext *hwctx;
454 
456  return AVERROR(EINVAL);
457 
458  if (av_reallocp(&avctx->hwaccel_context, sizeof(*hwctx)))
459  return AVERROR(ENOMEM);
460 
461  hwctx = avctx->hwaccel_context;
462 
463  memset(hwctx, 0, sizeof(*hwctx));
464  hwctx->context.decoder = VDP_INVALID_HANDLE;
465  hwctx->device = device;
466  hwctx->get_proc_address = get_proc;
467  hwctx->flags = flags;
468  hwctx->reset = 1;
469  return 0;
470 }
471 
472 /* @}*/
func
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:67
AVHWDeviceContext::hwctx
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:91
AVCodecContext::hwaccel
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
Definition: avcodec.h:2729
AVCodecContext::hwaccel_context
void * hwaccel_context
Hardware accelerator context.
Definition: avcodec.h:2741
status
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
level
uint8_t level
Definition: svq3.c:207
ff_vdpau_common_frame_params
int ff_vdpau_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Definition: vdpau.c:114
FF_PROFILE_MPEG2_SIMPLE
#define FF_PROFILE_MPEG2_SIMPLE
Definition: avcodec.h:2932
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
destroy
static void destroy(struct ResampleContext **c)
Definition: soxr_resample.c:64
FF_PROFILE_H264_INTRA
#define FF_PROFILE_H264_INTRA
Definition: avcodec.h:2935
FF_PROFILE_MPEG4_SIMPLE
#define FF_PROFILE_MPEG4_SIMPLE
Definition: avcodec.h:2958
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:89
vc1.h
FF_PROFILE_H264_BASELINE
#define FF_PROFILE_H264_BASELINE
Definition: avcodec.h:2937
ff_vdpau_common_reinit
static int ff_vdpau_common_reinit(AVCodecContext *avctx)
Definition: vdpau.c:307
AVHWFramesContext::format
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:208
FF_PROFILE_H264_CONSTRAINED_BASELINE
#define FF_PROFILE_H264_CONSTRAINED_BASELINE
Definition: avcodec.h:2938
av_unused
#define av_unused
Definition: attributes.h:125
AV_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: avcodec.h:230
profile
mfxU16 profile
Definition: qsvenc.c:44
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
VDPAUHWContext::get_proc_address
VdpGetProcAddress * get_proc_address
Definition: vdpau_internal.h:62
vdpau_picture_context::bitstream_buffers_used
int bitstream_buffers_used
Useful bitstream buffers in the bitstream buffers table.
Definition: vdpau_internal.h:106
w
uint8_t w
Definition: llviddspenc.c:38
internal.h
AVHWAccel::init
int(* init)(AVCodecContext *avctx)
Initialize the hwaccel private data.
Definition: avcodec.h:3779
AVVDPAUDeviceContext::get_proc_address
VdpGetProcAddress * get_proc_address
Definition: hwcontext_vdpau.h:37
AVVDPAUDeviceContext
This struct is allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_vdpau.h:35
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
Picture
Picture.
Definition: mpegpicture.h:45
AVHWFramesContext::width
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:228
VDPAUContext::width
uint32_t width
Definition: vdpau_internal.h:88
FF_PROFILE_MPEG2_MAIN
#define FF_PROFILE_MPEG2_MAIN
Definition: avcodec.h:2931
VDPAUContext::render
VdpDecoderRender * render
VDPAU decoder render callback.
Definition: vdpau_internal.h:86
vdpau_internal.h
AV_HWACCEL_FLAG_IGNORE_LEVEL
#define AV_HWACCEL_FLAG_IGNORE_LEVEL
Hardware acceleration should be used for decoding even if the codec level used is unknown or higher t...
Definition: avcodec.h:3825
VDPAUHWContext::device
VdpDevice device
Definition: vdpau_internal.h:61
vdpau_picture_context
Definition: vdpau_internal.h:92
AVVDPAUContext
This structure is used to share data between the libavcodec library and the client video application.
Definition: vdpau.h:81
MAKE_ACCESSORS
#define MAKE_ACCESSORS(str, name, type, field)
Definition: internal.h:91
AVCodecContext::refs
int refs
number of reference frames
Definition: avcodec.h:2153
ff_mpeg_draw_horiz_band
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
Definition: mpegvideo.c:2274
FF_PROFILE_H264_HIGH
#define FF_PROFILE_H264_HIGH
Definition: avcodec.h:2941
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
AVCodecContext::coded_height
int coded_height
Definition: avcodec.h:1753
AVVDPAUContext::render2
AVVDPAU_Render2 render2
Definition: vdpau.h:96
ff_vdpau_add_buffer
int ff_vdpau_add_buffer(struct vdpau_picture_context *pic_ctx, const uint8_t *buf, uint32_t size)
Definition: vdpau.c:377
buf
void * buf
Definition: avisynth_c.h:766
ff_vdpau_common_init
int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, int level)
Definition: vdpau.c:133
vdpau.h
AVHWFramesContext::height
int height
Definition: hwcontext.h:228
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
av_fast_realloc
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
Definition: mem.c:476
width
#define width
s
#define s(width, name)
Definition: cbs_vp9.c:257
AVHWAccel::uninit
int(* uninit)(AVCodecContext *avctx)
Uninitialize the hwaccel private data.
Definition: avcodec.h:3787
FF_PROFILE_H264_EXTENDED
#define FF_PROFILE_H264_EXTENDED
Definition: avcodec.h:2940
info
MIPS optimizations info
Definition: mips.txt:2
decode.h
limits.h
av_vdpau_bind_context
int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device, VdpGetProcAddress *get_proc, unsigned flags)
Associate a VDPAU device with a codec context for hardware acceleration.
Definition: vdpau.c:450
AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH
#define AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH
Hardware acceleration can output YUV pixel formats with a different chroma sampling than 4:2:0 and/or...
Definition: avcodec.h:3831
ff_vdpau_common_start_frame
int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic_ctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition: vdpau.c:322
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: avcodec.h:245
ff_vdpau_get_surface_id
static uintptr_t ff_vdpau_get_surface_id(AVFrame *pic)
Extract VdpVideoSurface from an AVFrame.
Definition: vdpau_internal.h:38
Picture::hwaccel_picture_private
void * hwaccel_picture_private
Hardware accelerator private data.
Definition: mpegpicture.h:77
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
ff_decode_get_hw_frames_ctx
int ff_decode_get_hw_frames_ctx(AVCodecContext *avctx, enum AVHWDeviceType dev_type)
Make sure avctx.hw_frames_ctx is set.
Definition: decode.c:1222
AVCodecContext::codec_id
enum AVCodecID codec_id
Definition: avcodec.h:1575
if
if(ret)
Definition: filter_design.txt:179
FF_PROFILE_VC1_SIMPLE
#define FF_PROFILE_VC1_SIMPLE
Definition: avcodec.h:2953
AV_CODEC_ID_WMV3
@ AV_CODEC_ID_WMV3
Definition: avcodec.h:289
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:221
PROFILE
#define PROFILE(prof)
create
static struct ResampleContext * create(struct ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, double precision, int cheby, int exact_rational)
Definition: soxr_resample.c:32
VDPAUContext::height
uint32_t height
Definition: vdpau_internal.h:89
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:1600
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
FF_PROFILE_VC1_MAIN
#define FF_PROFILE_VC1_MAIN
Definition: avcodec.h:2954
ff_vdpau_common_end_frame
int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame, struct vdpau_picture_context *pic_ctx)
Definition: vdpau.c:332
AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH
#define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH
Hardware acceleration should still be attempted for decoding when the codec profile does not match th...
Definition: avcodec.h:3845
AVVDPAUContext::render
VdpDecoderRender * render
VDPAU decoder render callback.
Definition: vdpau.h:94
VDPAUHWContext
Definition: vdpau_internal.h:59
AV_CODEC_ID_MPEG1VIDEO
@ AV_CODEC_ID_MPEG1VIDEO
Definition: avcodec.h:219
av_vdpau_get_surface_parameters
int av_vdpau_get_surface_parameters(AVCodecContext *avctx, VdpChromaType *type, uint32_t *width, uint32_t *height)
Gets the parameters to create an adequate VDPAU video surface for the codec context using VDPAU hardw...
Definition: vdpau.c:74
VDPAUContext::device
VdpDevice device
VDPAU device handle.
Definition: vdpau_internal.h:71
ff_vdpau_common_uninit
int ff_vdpau_common_uninit(AVCodecContext *avctx)
Definition: vdpau.c:284
VDPAUContext
Definition: vdpau_internal.h:67
AVVDPAUContext::decoder
VdpDecoder decoder
VDPAU decoder handle.
Definition: vdpau.h:87
AVCodecInternal::hwaccel_priv_data
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:190
AV_CODEC_ID_H263
@ AV_CODEC_ID_H263
Definition: avcodec.h:222
size
int size
Definition: twinvq_data.h:11134
av_reallocp
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
Definition: mem.c:163
VDPAUContext::decoder
VdpDecoder decoder
VDPAU decoder handle.
Definition: vdpau_internal.h:76
val
const char const char void * val
Definition: avisynth_c.h:863
ff_vdpau_mpeg_end_frame
int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
height
#define height
AV_PIX_FMT_VDPAU
@ AV_PIX_FMT_VDPAU
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
Definition: pixfmt.h:197
h264dec.h
VDPAUHWContext::reset
char reset
Definition: vdpau_internal.h:63
AVCodecContext::hwaccel_flags
int hwaccel_flags
Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated decoding (if active).
Definition: avcodec.h:3323
FF_PROFILE_MPEG4_ADVANCED_SIMPLE
#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE
Definition: avcodec.h:2973
vdpau_picture_context::bitstream_buffers
VdpBitstreamBuffer * bitstream_buffers
Table of bitstream buffers.
Definition: vdpau_internal.h:111
AV_CODEC_ID_HEVC
@ AV_CODEC_ID_HEVC
Definition: avcodec.h:392
av_vdpau_alloc_context
AVVDPAUContext * av_vdpau_alloc_context(void)
Allocate an AVVDPAUContext.
Definition: vdpau.c:445
uint8_t
uint8_t
Definition: audio_convert.c:194
AVVDPAU_Render2
int(* AVVDPAU_Render2)(struct AVCodecContext *, struct AVFrame *, const VdpPictureInfo *, uint32_t, const VdpBitstreamBuffer *)
Definition: vdpau.h:63
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:236
VDPAUHWContext::context
AVVDPAUContext context
Definition: vdpau_internal.h:60
AV_HWDEVICE_TYPE_VDPAU
@ AV_HWDEVICE_TYPE_VDPAU
Definition: hwcontext.h:29
AV_CODEC_ID_VC1
@ AV_CODEC_ID_VC1
Definition: avcodec.h:288
AVCodecContext::hw_frames_ctx
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
Definition: avcodec.h:3262
avcodec.h
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:123
ret
ret
Definition: filter_design.txt:187
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
AVHWFramesContext::device_ctx
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
Definition: hwcontext.h:148
VDPAUContext::get_proc_address
VdpGetProcAddress * get_proc_address
VDPAU device driver.
Definition: vdpau_internal.h:81
vdpau_picture_context::bitstream_buffers_allocated
int bitstream_buffers_allocated
Allocated size of the bitstream_buffers table.
Definition: vdpau_internal.h:101
AVCodecContext
main external API structure.
Definition: avcodec.h:1565
vdpau_picture_context::info
union VDPAUPictureInfo info
VDPAU picture information.
Definition: vdpau_internal.h:96
FF_PROFILE_VC1_ADVANCED
#define FF_PROFILE_VC1_ADVANCED
Definition: avcodec.h:2956
av_vdpau_get_profile
int av_vdpau_get_profile(AVCodecContext *avctx, VdpDecoderProfile *profile)
Get a decoder profile that should be used for initializing a VDPAU decoder.
Definition: vdpau.c:397
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
Picture::f
struct AVFrame * f
Definition: mpegpicture.h:46
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:2898
FF_PROFILE_H264_MAIN
#define FF_PROFILE_H264_MAIN
Definition: avcodec.h:2939
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AVCodecContext::coded_width
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:1753
vdpau_error
static int vdpau_error(VdpStatus status)
Definition: vdpau.c:43
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:81
av_alloc_vdpaucontext
AVVDPAUContext * av_alloc_vdpaucontext(void)
allocation function for AVVDPAUContext
Definition: vdpau.c:67
VDPAUHWContext::flags
unsigned char flags
Definition: vdpau_internal.h:64
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:1592
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
h
h
Definition: vp9dsp_template.c:2038
AVCodecContext::sw_pix_fmt
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:3112
AVVDPAUDeviceContext::device
VdpDevice device
Definition: hwcontext_vdpau.h:36
int
int
Definition: ffmpeg_filter.c:191
AV_CODEC_ID_MPEG2VIDEO
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:220
MpegEncContext
MpegEncContext.
Definition: mpegvideo.h:81