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