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