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