FFmpeg 8.0.1
Loading...
Searching...
No Matches
hwcontext.h
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#ifndef AVUTIL_HWCONTEXT_H
20#define AVUTIL_HWCONTEXT_H
21
22#include "buffer.h"
23#include "frame.h"
24#include "log.h"
25#include "pixfmt.h"
26
46
47/**
48 * This struct aggregates all the (hardware/vendor-specific) "high-level" state,
49 * i.e. state that is not tied to a concrete processing configuration.
50 * E.g., in an API that supports hardware-accelerated encoding and decoding,
51 * this struct will (if possible) wrap the state that is common to both encoding
52 * and decoding and from which specific instances of encoders or decoders can be
53 * derived.
54 *
55 * This struct is reference-counted with the AVBuffer mechanism. The
56 * av_hwdevice_ctx_alloc() constructor yields a reference, whose data field
57 * points to the actual AVHWDeviceContext. Further objects derived from
58 * AVHWDeviceContext (such as AVHWFramesContext, describing a frame pool with
59 * specific properties) will hold an internal reference to it. After all the
60 * references are released, the AVHWDeviceContext itself will be freed,
61 * optionally invoking a user-specified callback for uninitializing the hardware
62 * state.
63 */
64typedef struct AVHWDeviceContext {
65 /**
66 * A class for logging. Set by av_hwdevice_ctx_alloc().
67 */
69
70 /**
71 * This field identifies the underlying API used for hardware access.
72 *
73 * This field is set when this struct is allocated and never changed
74 * afterwards.
75 */
77
78 /**
79 * The format-specific data, allocated and freed by libavutil along with
80 * this context.
81 *
82 * Should be cast by the user to the format-specific context defined in the
83 * corresponding header (hwcontext_*.h) and filled as described in the
84 * documentation before calling av_hwdevice_ctx_init().
85 *
86 * After calling av_hwdevice_ctx_init() this struct should not be modified
87 * by the caller.
88 */
89 void *hwctx;
90
91 /**
92 * This field may be set by the caller before calling av_hwdevice_ctx_init().
93 *
94 * If non-NULL, this callback will be called when the last reference to
95 * this context is unreferenced, immediately before it is freed.
96 *
97 * @note when other objects (e.g an AVHWFramesContext) are derived from this
98 * struct, this callback will be invoked after all such child objects
99 * are fully uninitialized and their respective destructors invoked.
100 */
101 void (*free)(struct AVHWDeviceContext *ctx);
102
103 /**
104 * Arbitrary user data, to be used e.g. by the free() callback.
105 */
108
109/**
110 * This struct describes a set or pool of "hardware" frames (i.e. those with
111 * data not located in normal system memory). All the frames in the pool are
112 * assumed to be allocated in the same way and interchangeable.
113 *
114 * This struct is reference-counted with the AVBuffer mechanism and tied to a
115 * given AVHWDeviceContext instance. The av_hwframe_ctx_alloc() constructor
116 * yields a reference, whose data field points to the actual AVHWFramesContext
117 * struct.
118 */
119typedef struct AVHWFramesContext {
120 /**
121 * A class for logging.
122 */
124
125 /**
126 * A reference to the parent AVHWDeviceContext. This reference is owned and
127 * managed by the enclosing AVHWFramesContext, but the caller may derive
128 * additional references from it.
129 */
131
132 /**
133 * The parent AVHWDeviceContext. This is simply a pointer to
134 * device_ref->data provided for convenience.
135 *
136 * Set by libavutil in av_hwframe_ctx_init().
137 */
139
140 /**
141 * The format-specific data, allocated and freed automatically along with
142 * this context.
143 *
144 * The user shall ignore this field if the corresponding format-specific
145 * header (hwcontext_*.h) does not define a context to be used as
146 * AVHWFramesContext.hwctx.
147 *
148 * Otherwise, it should be cast by the user to said context and filled
149 * as described in the documentation before calling av_hwframe_ctx_init().
150 *
151 * After any frames using this context are created, the contents of this
152 * struct should not be modified by the caller.
153 */
154 void *hwctx;
155
156 /**
157 * This field may be set by the caller before calling av_hwframe_ctx_init().
158 *
159 * If non-NULL, this callback will be called when the last reference to
160 * this context is unreferenced, immediately before it is freed.
161 */
162 void (*free)(struct AVHWFramesContext *ctx);
163
164 /**
165 * Arbitrary user data, to be used e.g. by the free() callback.
166 */
168
169 /**
170 * A pool from which the frames are allocated by av_hwframe_get_buffer().
171 * This field may be set by the caller before calling av_hwframe_ctx_init().
172 * The buffers returned by calling av_buffer_pool_get() on this pool must
173 * have the properties described in the documentation in the corresponding hw
174 * type's header (hwcontext_*.h). The pool will be freed strictly before
175 * this struct's free() callback is invoked.
176 *
177 * This field may be NULL, then libavutil will attempt to allocate a pool
178 * internally. Note that certain device types enforce pools allocated at
179 * fixed size (frame count), which cannot be extended dynamically. In such a
180 * case, initial_pool_size must be set appropriately.
181 */
183
184 /**
185 * Initial size of the frame pool. If a device type does not support
186 * dynamically resizing the pool, then this is also the maximum pool size.
187 *
188 * May be set by the caller before calling av_hwframe_ctx_init(). Must be
189 * set if pool is NULL and the device type does not support dynamic pools.
190 */
192
193 /**
194 * The pixel format identifying the underlying HW surface type.
195 *
196 * Must be a hwaccel format, i.e. the corresponding descriptor must have the
197 * AV_PIX_FMT_FLAG_HWACCEL flag set.
198 *
199 * Must be set by the user before calling av_hwframe_ctx_init().
200 */
202
203 /**
204 * The pixel format identifying the actual data layout of the hardware
205 * frames.
206 *
207 * Must be set by the caller before calling av_hwframe_ctx_init().
208 *
209 * @note when the underlying API does not provide the exact data layout, but
210 * only the colorspace/bit depth, this field should be set to the fully
211 * planar version of that format (e.g. for 8-bit 420 YUV it should be
212 * AV_PIX_FMT_YUV420P, not AV_PIX_FMT_NV12 or anything else).
213 */
215
216 /**
217 * The allocated dimensions of the frames in this pool.
218 *
219 * Must be set by the user before calling av_hwframe_ctx_init().
220 */
223
224/**
225 * Look up an AVHWDeviceType by name.
226 *
227 * @param name String name of the device type (case-insensitive).
228 * @return The type from enum AVHWDeviceType, or AV_HWDEVICE_TYPE_NONE if
229 * not found.
230 */
232
233/** Get the string name of an AVHWDeviceType.
234 *
235 * @param type Type from enum AVHWDeviceType.
236 * @return Pointer to a static string containing the name, or NULL if the type
237 * is not valid.
238 */
240
241/**
242 * Iterate over supported device types.
243 *
244 * @param prev AV_HWDEVICE_TYPE_NONE initially, then the previous type
245 * returned by this function in subsequent iterations.
246 * @return The next usable device type from enum AVHWDeviceType, or
247 * AV_HWDEVICE_TYPE_NONE if there are no more.
248 */
250
251/**
252 * Allocate an AVHWDeviceContext for a given hardware type.
253 *
254 * @param type the type of the hardware device to allocate.
255 * @return a reference to the newly created AVHWDeviceContext on success or NULL
256 * on failure.
257 */
259
260/**
261 * Finalize the device context before use. This function must be called after
262 * the context is filled with all the required information and before it is
263 * used in any way.
264 *
265 * @param ref a reference to the AVHWDeviceContext
266 * @return 0 on success, a negative AVERROR code on failure
267 */
269
270/**
271 * Open a device of the specified type and create an AVHWDeviceContext for it.
272 *
273 * This is a convenience function intended to cover the simple cases. Callers
274 * who need to fine-tune device creation/management should open the device
275 * manually and then wrap it in an AVHWDeviceContext using
276 * av_hwdevice_ctx_alloc()/av_hwdevice_ctx_init().
277 *
278 * The returned context is already initialized and ready for use, the caller
279 * should not call av_hwdevice_ctx_init() on it. The user_opaque/free fields of
280 * the created AVHWDeviceContext are set by this function and should not be
281 * touched by the caller.
282 *
283 * @param device_ctx On success, a reference to the newly-created device context
284 * will be written here. The reference is owned by the caller
285 * and must be released with av_buffer_unref() when no longer
286 * needed. On failure, NULL will be written to this pointer.
287 * @param type The type of the device to create.
288 * @param device A type-specific string identifying the device to open.
289 * @param opts A dictionary of additional (type-specific) options to use in
290 * opening the device. The dictionary remains owned by the caller.
291 * @param flags currently unused
292 *
293 * @return 0 on success, a negative AVERROR code on failure.
294 */
296 const char *device, AVDictionary *opts, int flags);
297
298/**
299 * Create a new device of the specified type from an existing device.
300 *
301 * If the source device is a device of the target type or was originally
302 * derived from such a device (possibly through one or more intermediate
303 * devices of other types), then this will return a reference to the
304 * existing device of the same type as is requested.
305 *
306 * Otherwise, it will attempt to derive a new device from the given source
307 * device. If direct derivation to the new type is not implemented, it will
308 * attempt the same derivation from each ancestor of the source device in
309 * turn looking for an implemented derivation method.
310 *
311 * @param dst_ctx On success, a reference to the newly-created
312 * AVHWDeviceContext.
313 * @param type The type of the new device to create.
314 * @param src_ctx A reference to an existing AVHWDeviceContext which will be
315 * used to create the new device.
316 * @param flags Currently unused; should be set to zero.
317 * @return Zero on success, a negative AVERROR code on failure.
318 */
320 enum AVHWDeviceType type,
321 AVBufferRef *src_ctx, int flags);
322
323/**
324 * Create a new device of the specified type from an existing device.
325 *
326 * This function performs the same action as av_hwdevice_ctx_create_derived,
327 * however, it is able to set options for the new device to be derived.
328 *
329 * @param dst_ctx On success, a reference to the newly-created
330 * AVHWDeviceContext.
331 * @param type The type of the new device to create.
332 * @param src_ctx A reference to an existing AVHWDeviceContext which will be
333 * used to create the new device.
334 * @param options Options for the new device to create, same format as in
335 * av_hwdevice_ctx_create.
336 * @param flags Currently unused; should be set to zero.
337 * @return Zero on success, a negative AVERROR code on failure.
338 */
340 enum AVHWDeviceType type,
341 AVBufferRef *src_ctx,
342 AVDictionary *options, int flags);
343
344/**
345 * Allocate an AVHWFramesContext tied to a given device context.
346 *
347 * @param device_ctx a reference to a AVHWDeviceContext. This function will make
348 * a new reference for internal use, the one passed to the
349 * function remains owned by the caller.
350 * @return a reference to the newly created AVHWFramesContext on success or NULL
351 * on failure.
352 */
354
355/**
356 * Finalize the context before use. This function must be called after the
357 * context is filled with all the required information and before it is attached
358 * to any frames.
359 *
360 * @param ref a reference to the AVHWFramesContext
361 * @return 0 on success, a negative AVERROR code on failure
362 */
364
365/**
366 * Allocate a new frame attached to the given AVHWFramesContext.
367 *
368 * @param hwframe_ctx a reference to an AVHWFramesContext
369 * @param frame an empty (freshly allocated or unreffed) frame to be filled with
370 * newly allocated buffers.
371 * @param flags currently unused, should be set to zero
372 * @return 0 on success, a negative AVERROR code on failure
373 */
374int av_hwframe_get_buffer(AVBufferRef *hwframe_ctx, AVFrame *frame, int flags);
375
376/**
377 * Copy data to or from a hw surface. At least one of dst/src must have an
378 * AVHWFramesContext attached.
379 *
380 * If src has an AVHWFramesContext attached, then the format of dst (if set)
381 * must use one of the formats returned by av_hwframe_transfer_get_formats(src,
382 * AV_HWFRAME_TRANSFER_DIRECTION_FROM).
383 * If dst has an AVHWFramesContext attached, then the format of src must use one
384 * of the formats returned by av_hwframe_transfer_get_formats(dst,
385 * AV_HWFRAME_TRANSFER_DIRECTION_TO)
386 *
387 * dst may be "clean" (i.e. with data/buf pointers unset), in which case the
388 * data buffers will be allocated by this function using av_frame_get_buffer().
389 * If dst->format is set, then this format will be used, otherwise (when
390 * dst->format is AV_PIX_FMT_NONE) the first acceptable format will be chosen.
391 *
392 * The two frames must have matching allocated dimensions (i.e. equal to
393 * AVHWFramesContext.width/height), since not all device types support
394 * transferring a sub-rectangle of the whole surface. The display dimensions
395 * (i.e. AVFrame.width/height) may be smaller than the allocated dimensions, but
396 * also have to be equal for both frames. When the display dimensions are
397 * smaller than the allocated dimensions, the content of the padding in the
398 * destination frame is unspecified.
399 *
400 * @param dst the destination frame. dst is not touched on failure.
401 * @param src the source frame.
402 * @param flags currently unused, should be set to zero
403 * @return 0 on success, a negative AVERROR error code on failure.
404 */
405int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags);
406
408 /**
409 * Transfer the data from the queried hw frame.
410 */
412
413 /**
414 * Transfer the data to the queried hw frame.
415 */
417};
418
419/**
420 * Get a list of possible source or target formats usable in
421 * av_hwframe_transfer_data().
422 *
423 * @param hwframe_ctx the frame context to obtain the information for
424 * @param dir the direction of the transfer
425 * @param formats the pointer to the output format list will be written here.
426 * The list is terminated with AV_PIX_FMT_NONE and must be freed
427 * by the caller when no longer needed using av_free().
428 * If this function returns successfully, the format list will
429 * have at least one item (not counting the terminator).
430 * On failure, the contents of this pointer are unspecified.
431 * @param flags currently unused, should be set to zero
432 * @return 0 on success, a negative AVERROR code on failure.
433 */
436 enum AVPixelFormat **formats, int flags);
437
438
439/**
440 * This struct describes the constraints on hardware frames attached to
441 * a given device with a hardware-specific configuration. This is returned
442 * by av_hwdevice_get_hwframe_constraints() and must be freed by
443 * av_hwframe_constraints_free() after use.
444 */
445typedef struct AVHWFramesConstraints {
446 /**
447 * A list of possible values for format in the hw_frames_ctx,
448 * terminated by AV_PIX_FMT_NONE. This member will always be filled.
449 */
451
452 /**
453 * A list of possible values for sw_format in the hw_frames_ctx,
454 * terminated by AV_PIX_FMT_NONE. Can be NULL if this information is
455 * not known.
456 */
458
459 /**
460 * The minimum size of frames in this hw_frames_ctx.
461 * (Zero if not known.)
462 */
465
466 /**
467 * The maximum size of frames in this hw_frames_ctx.
468 * (INT_MAX if not known / no limit.)
469 */
473
474/**
475 * Allocate a HW-specific configuration structure for a given HW device.
476 * After use, the user must free all members as required by the specific
477 * hardware structure being used, then free the structure itself with
478 * av_free().
479 *
480 * @param device_ctx a reference to the associated AVHWDeviceContext.
481 * @return The newly created HW-specific configuration structure on
482 * success or NULL on failure.
483 */
485
486/**
487 * Get the constraints on HW frames given a device and the HW-specific
488 * configuration to be used with that device. If no HW-specific
489 * configuration is provided, returns the maximum possible capabilities
490 * of the device.
491 *
492 * @param ref a reference to the associated AVHWDeviceContext.
493 * @param hwconfig a filled HW-specific configuration structure, or NULL
494 * to return the maximum possible capabilities of the device.
495 * @return AVHWFramesConstraints structure describing the constraints
496 * on the device, or NULL if not available.
497 */
499 const void *hwconfig);
500
501/**
502 * Free an AVHWFrameConstraints structure.
503 *
504 * @param constraints The (filled or unfilled) AVHWFrameConstraints structure.
505 */
507
508
509/**
510 * Flags to apply to frame mappings.
511 */
512enum {
513 /**
514 * The mapping must be readable.
515 */
517 /**
518 * The mapping must be writeable.
519 */
521 /**
522 * The mapped frame will be overwritten completely in subsequent
523 * operations, so the current frame data need not be loaded. Any values
524 * which are not overwritten are unspecified.
525 */
527 /**
528 * The mapping must be direct. That is, there must not be any copying in
529 * the map or unmap steps. Note that performance of direct mappings may
530 * be much lower than normal memory.
531 */
533};
534
535/**
536 * Map a hardware frame.
537 *
538 * This has a number of different possible effects, depending on the format
539 * and origin of the src and dst frames. On input, src should be a usable
540 * frame with valid buffers and dst should be blank (typically as just created
541 * by av_frame_alloc()). src should have an associated hwframe context, and
542 * dst may optionally have a format and associated hwframe context.
543 *
544 * If src was created by mapping a frame from the hwframe context of dst,
545 * then this function undoes the mapping - dst is replaced by a reference to
546 * the frame that src was originally mapped from.
547 *
548 * If both src and dst have an associated hwframe context, then this function
549 * attempts to map the src frame from its hardware context to that of dst and
550 * then fill dst with appropriate data to be usable there. This will only be
551 * possible if the hwframe contexts and associated devices are compatible -
552 * given compatible devices, av_hwframe_ctx_create_derived() can be used to
553 * create a hwframe context for dst in which mapping should be possible.
554 *
555 * If src has a hwframe context but dst does not, then the src frame is
556 * mapped to normal memory and should thereafter be usable as a normal frame.
557 * If the format is set on dst, then the mapping will attempt to create dst
558 * with that format and fail if it is not possible. If format is unset (is
559 * AV_PIX_FMT_NONE) then dst will be mapped with whatever the most appropriate
560 * format to use is (probably the sw_format of the src hwframe context).
561 *
562 * A return value of AVERROR(ENOSYS) indicates that the mapping is not
563 * possible with the given arguments and hwframe setup, while other return
564 * values indicate that it failed somehow.
565 *
566 * On failure, the destination frame will be left blank, except for the
567 * hw_frames_ctx/format fields they may have been set by the caller - those will
568 * be preserved as they were.
569 *
570 * @param dst Destination frame, to contain the mapping.
571 * @param src Source frame, to be mapped.
572 * @param flags Some combination of AV_HWFRAME_MAP_* flags.
573 * @return Zero on success, negative AVERROR code on failure.
574 */
575int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags);
576
577
578/**
579 * Create and initialise an AVHWFramesContext as a mapping of another existing
580 * AVHWFramesContext on a different device.
581 *
582 * av_hwframe_ctx_init() should not be called after this.
583 *
584 * @param derived_frame_ctx On success, a reference to the newly created
585 * AVHWFramesContext.
586 * @param format The AVPixelFormat for the derived context.
587 * @param derived_device_ctx A reference to the device to create the new
588 * AVHWFramesContext on.
589 * @param source_frame_ctx A reference to an existing AVHWFramesContext
590 * which will be mapped to the derived context.
591 * @param flags Some combination of AV_HWFRAME_MAP_* flags, defining the
592 * mapping parameters to apply to frames which are allocated
593 * in the derived device.
594 * @return Zero on success, negative AVERROR code on failure.
595 */
597 enum AVPixelFormat format,
598 AVBufferRef *derived_device_ctx,
599 AVBufferRef *source_frame_ctx,
600 int flags);
601
602#endif /* AVUTIL_HWCONTEXT_H */
refcounted data buffer API
static AVFrame * frame
reference-counted frame API
struct AVBufferPool AVBufferPool
The buffer pool.
Definition buffer.h:255
struct AVDictionary AVDictionary
Definition dict.h:95
int av_hwframe_get_buffer(AVBufferRef *hwframe_ctx, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
enum AVHWDeviceType av_hwdevice_iterate_types(enum AVHWDeviceType prev)
Iterate over supported device types.
int av_hwdevice_ctx_init(AVBufferRef *ref)
Finalize the device context before use.
void av_hwframe_constraints_free(AVHWFramesConstraints **constraints)
Free an AVHWFrameConstraints structure.
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
@ AV_HWFRAME_MAP_READ
The mapping must be readable.
Definition hwcontext.h:516
@ AV_HWFRAME_MAP_DIRECT
The mapping must be direct.
Definition hwcontext.h:532
@ AV_HWFRAME_MAP_WRITE
The mapping must be writeable.
Definition hwcontext.h:520
@ AV_HWFRAME_MAP_OVERWRITE
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
Definition hwcontext.h:526
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ctx)
Allocate an AVHWFramesContext tied to a given device context.
int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx, enum AVPixelFormat format, AVBufferRef *derived_device_ctx, AVBufferRef *source_frame_ctx, int flags)
Create and initialise an AVHWFramesContext as a mapping of another existing AVHWFramesContext on a di...
enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
Look up an AVHWDeviceType by name.
AVBufferRef * av_hwdevice_ctx_alloc(enum AVHWDeviceType type)
Allocate an AVHWDeviceContext for a given hardware type.
int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ctx, enum AVHWDeviceType type, AVBufferRef *src_ctx, AVDictionary *options, int flags)
Create a new device of the specified type from an existing device.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ctx, enum AVHWDeviceType type, AVBufferRef *src_ctx, int flags)
Create a new device of the specified type from an existing device.
int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags)
Map a hardware frame.
AVHWFrameTransferDirection
Definition hwcontext.h:407
@ AV_HWFRAME_TRANSFER_DIRECTION_TO
Transfer the data to the queried hw frame.
Definition hwcontext.h:416
@ AV_HWFRAME_TRANSFER_DIRECTION_FROM
Transfer the data from the queried hw frame.
Definition hwcontext.h:411
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
Copy data to or from a hw surface.
int av_hwdevice_ctx_create(AVBufferRef **device_ctx, enum AVHWDeviceType type, const char *device, AVDictionary *opts, int flags)
Open a device of the specified type and create an AVHWDeviceContext for it.
AVHWDeviceType
Definition hwcontext.h:27
@ AV_HWDEVICE_TYPE_OHCODEC
Definition hwcontext.h:43
@ AV_HWDEVICE_TYPE_D3D11VA
Definition hwcontext.h:35
@ AV_HWDEVICE_TYPE_NONE
Definition hwcontext.h:28
@ AV_HWDEVICE_TYPE_AMF
Definition hwcontext.h:41
@ AV_HWDEVICE_TYPE_VDPAU
Definition hwcontext.h:29
@ AV_HWDEVICE_TYPE_OPENCL
Definition hwcontext.h:37
@ AV_HWDEVICE_TYPE_VULKAN
Definition hwcontext.h:39
@ AV_HWDEVICE_TYPE_MEDIACODEC
Definition hwcontext.h:38
@ AV_HWDEVICE_TYPE_QSV
Definition hwcontext.h:33
@ AV_HWDEVICE_TYPE_VIDEOTOOLBOX
Definition hwcontext.h:34
@ AV_HWDEVICE_TYPE_CUDA
Definition hwcontext.h:30
@ AV_HWDEVICE_TYPE_DRM
Definition hwcontext.h:36
@ AV_HWDEVICE_TYPE_D3D12VA
Definition hwcontext.h:40
@ AV_HWDEVICE_TYPE_DXVA2
Definition hwcontext.h:32
@ AV_HWDEVICE_TYPE_V4L2REQUEST
Definition hwcontext.h:44
@ AV_HWDEVICE_TYPE_VAAPI
Definition hwcontext.h:31
AVHWFramesConstraints * av_hwdevice_get_hwframe_constraints(AVBufferRef *ref, const void *hwconfig)
Get the constraints on HW frames given a device and the HW-specific configuration to be used with tha...
void * av_hwdevice_hwconfig_alloc(AVBufferRef *device_ctx)
Allocate a HW-specific configuration structure for a given HW device.
int av_hwframe_transfer_get_formats(AVBufferRef *hwframe_ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats, int flags)
Get a list of possible source or target formats usable in av_hwframe_transfer_data().
pixel format definitions
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
A reference to a data buffer.
Definition buffer.h:82
Describe the class of an AVClass context structure.
Definition log.h:76
This structure describes decoded (raw) audio or video data.
Definition frame.h:421
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition hwcontext.h:64
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition hwcontext.h:89
const AVClass * av_class
A class for logging.
Definition hwcontext.h:68
void(* free)(struct AVHWDeviceContext *ctx)
This field may be set by the caller before calling av_hwdevice_ctx_init().
Definition hwcontext.h:101
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
Definition hwcontext.h:76
void * user_opaque
Arbitrary user data, to be used e.g.
Definition hwcontext.h:106
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
Definition hwcontext.h:445
int max_width
The maximum size of frames in this hw_frames_ctx.
Definition hwcontext.h:470
enum AVPixelFormat * valid_hw_formats
A list of possible values for format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
Definition hwcontext.h:450
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
Definition hwcontext.h:457
int min_width
The minimum size of frames in this hw_frames_ctx.
Definition hwcontext.h:463
This struct describes a set or pool of "hardware" frames (i.e.
Definition hwcontext.h:119
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition hwcontext.h:201
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
Definition hwcontext.h:130
void * user_opaque
Arbitrary user data, to be used e.g.
Definition hwcontext.h:167
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition hwcontext.h:154
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition hwcontext.h:214
const AVClass * av_class
A class for logging.
Definition hwcontext.h:123
int initial_pool_size
Initial size of the frame pool.
Definition hwcontext.h:191
int width
The allocated dimensions of the frames in this pool.
Definition hwcontext.h:221
void(* free)(struct AVHWFramesContext *ctx)
This field may be set by the caller before calling av_hwframe_ctx_init().
Definition hwcontext.h:162
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
Definition hwcontext.h:138
AVBufferPool * pool
A pool from which the frames are allocated by av_hwframe_get_buffer().
Definition hwcontext.h:182