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