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