FFmpeg
4.3.1
|
Go to the source code of this file.
Data Structures | |
struct | AVHWDeviceContext |
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e. More... | |
struct | AVHWFramesContext |
This struct describes a set or pool of "hardware" frames (i.e. More... | |
struct | AVHWFramesConstraints |
This struct describes the constraints on hardware frames attached to a given device with a hardware-specific configuration. More... | |
Typedefs | |
typedef struct AVHWDeviceInternal | AVHWDeviceInternal |
typedef struct AVHWFramesInternal | AVHWFramesInternal |
Functions | |
enum AVHWDeviceType | av_hwdevice_find_type_by_name (const char *name) |
Look up an AVHWDeviceType by name. More... | |
const char * | av_hwdevice_get_type_name (enum AVHWDeviceType type) |
Get the string name of an AVHWDeviceType. More... | |
enum AVHWDeviceType | av_hwdevice_iterate_types (enum AVHWDeviceType prev) |
Iterate over supported device types. More... | |
AVBufferRef * | av_hwdevice_ctx_alloc (enum AVHWDeviceType type) |
Allocate an AVHWDeviceContext for a given hardware type. More... | |
int | av_hwdevice_ctx_init (AVBufferRef *ref) |
Finalize the device context before use. More... | |
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. More... | |
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. More... | |
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. More... | |
AVBufferRef * | av_hwframe_ctx_alloc (AVBufferRef *device_ctx) |
Allocate an AVHWFramesContext tied to a given device context. More... | |
int | av_hwframe_ctx_init (AVBufferRef *ref) |
Finalize the context before use. More... | |
int | av_hwframe_get_buffer (AVBufferRef *hwframe_ctx, AVFrame *frame, int flags) |
Allocate a new frame attached to the given AVHWFramesContext. More... | |
int | av_hwframe_transfer_data (AVFrame *dst, const AVFrame *src, int flags) |
Copy data to or from a hw surface. More... | |
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(). More... | |
void * | av_hwdevice_hwconfig_alloc (AVBufferRef *device_ctx) |
Allocate a HW-specific configuration structure for a given HW device. More... | |
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 that device. More... | |
void | av_hwframe_constraints_free (AVHWFramesConstraints **constraints) |
Free an AVHWFrameConstraints structure. More... | |
int | av_hwframe_map (AVFrame *dst, const AVFrame *src, int flags) |
Map a hardware frame. More... | |
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 different device. More... | |
typedef struct AVHWDeviceInternal AVHWDeviceInternal |
Definition at line 1 of file hwcontext.h.
typedef struct AVHWFramesInternal AVHWFramesInternal |
Definition at line 1 of file hwcontext.h.
enum AVHWDeviceType |
Definition at line 27 of file hwcontext.h.
Enumerator | |
---|---|
AV_HWFRAME_TRANSFER_DIRECTION_FROM | Transfer the data from the queried hw frame. |
AV_HWFRAME_TRANSFER_DIRECTION_TO | Transfer the data to the queried hw frame. |
Definition at line 415 of file hwcontext.h.
anonymous enum |
Flags to apply to frame mappings.
Enumerator | |
---|---|
AVFILTER_AUTO_CONVERT_ALL | all automatic conversions enabled |
AVFILTER_AUTO_CONVERT_NONE | all automatic conversions disabled |
AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT | Do not check for format changes. |
AV_BUFFERSRC_FLAG_PUSH | Immediately push the frame to the output. |
AV_BUFFERSRC_FLAG_KEEP_REF | Keep a reference to the frame. If the frame if reference-counted, create a new reference; otherwise copy the frame data. |
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX | The codec supports this format via the hw_device_ctx interface. When selecting this format, AVCodecContext.hw_device_ctx should have been set to a device of the specified type before calling avcodec_open2(). |
AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX | The codec supports this format via the hw_frames_ctx interface. When selecting this format for a decoder, AVCodecContext.hw_frames_ctx should be set to a suitable frames context inside the get_format() callback. The frames context must have been created on a device of the specified type. When selecting this format for an encoder, AVCodecContext.hw_frames_ctx should be set to the context which will be used for the input frames before calling avcodec_open2(). |
AV_CODEC_HW_CONFIG_METHOD_INTERNAL | The codec supports this format by some internal method. This format can be selected without any additional configuration - no device or frames context is required. |
AV_CODEC_HW_CONFIG_METHOD_AD_HOC | The codec supports this format by some ad-hoc method. Additional settings and/or function calls are required. See the codec-specific documentation for details. (Methods requiring this sort of configuration are deprecated and others should be used in preference.) |
AV_FRAME_CROP_UNALIGNED | Apply the maximum possible cropping, even if it requires setting the AVFrame.data[] entries to unaligned pointers. Passing unaligned data to FFmpeg API is generally not allowed, and causes undefined behavior (such as crashes). You can pass unaligned data only to FFmpeg APIs that are explicitly documented to accept it. Use this flag only if you absolutely know what you are doing. |
AV_HWFRAME_MAP_READ | The mapping must be readable. |
AV_HWFRAME_MAP_WRITE | The mapping must be writeable. |
AV_HWFRAME_MAP_OVERWRITE | The mapped frame will be overwritten completely in subsequent operations, so the current frame data need not be loaded. Any values which are not overwritten are unspecified. |
AV_HWFRAME_MAP_DIRECT | The mapping must be direct. That is, there must not be any copying in the map or unmap steps. Note that performance of direct mappings may be much lower than normal memory. |
AV_DRM_MAX_PLANES | The maximum number of layers/planes in a DRM frame. |
AV_VAAPI_DRIVER_QUIRK_USER_SET | The quirks field has been set by the user and should not be detected automatically by av_hwdevice_ctx_init(). |
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS | The driver does not destroy parameter buffers when they are used by vaRenderPicture(). Additional code will be required to destroy them separately afterwards. |
AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE | The driver does not support the VASurfaceAttribMemoryType attribute, so the surface allocation code will not try to use it. |
AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES | The driver does not support surface attributes at all. The surface allocation code will never pass them to surface allocation, and the results of the vaQuerySurfaceAttributes() call will be faked. |
AV_OPT_FLAG_IMPLICIT_KEY | Accept to parse a value without a key; the key will then be returned as NULL. |
Definition at line 520 of file hwcontext.h.
enum AVHWDeviceType av_hwdevice_find_type_by_name | ( | const char * | name | ) |
Look up an AVHWDeviceType by name.
name | String name of the device type (case-insensitive). |
Referenced by main().
const char* av_hwdevice_get_type_name | ( | enum AVHWDeviceType | type | ) |
Get the string name of an AVHWDeviceType.
type | Type from enum AVHWDeviceType. |
Referenced by main().
enum AVHWDeviceType av_hwdevice_iterate_types | ( | enum AVHWDeviceType | prev | ) |
Iterate over supported device types.
type | AV_HWDEVICE_TYPE_NONE initially, then the previous type returned by this function in subsequent iterations. |
Referenced by main().
AVBufferRef* av_hwdevice_ctx_alloc | ( | enum AVHWDeviceType | type | ) |
Allocate an AVHWDeviceContext for a given hardware type.
type | the type of the hardware device to allocate. |
int av_hwdevice_ctx_init | ( | AVBufferRef * | ref | ) |
Finalize the device context before use.
This function must be called after the context is filled with all the required information and before it is used in any way.
ref | a reference to the AVHWDeviceContext |
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.
This is a convenience function intended to cover the simple cases. Callers who need to fine-tune device creation/management should open the device manually and then wrap it in an AVHWDeviceContext using av_hwdevice_ctx_alloc()/av_hwdevice_ctx_init().
The returned context is already initialized and ready for use, the caller should not call av_hwdevice_ctx_init() on it. The user_opaque/free fields of the created AVHWDeviceContext are set by this function and should not be touched by the caller.
device_ctx | On success, a reference to the newly-created device context will be written here. The reference is owned by the caller and must be released with av_buffer_unref() when no longer needed. On failure, NULL will be written to this pointer. |
type | The type of the device to create. |
device | A type-specific string identifying the device to open. |
opts | A dictionary of additional (type-specific) options to use in opening the device. The dictionary remains owned by the caller. |
flags | currently unused |
Referenced by hw_decoder_init(), and main().
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.
If the source device is a device of the target type or was originally derived from such a device (possibly through one or more intermediate devices of other types), then this will return a reference to the existing device of the same type as is requested.
Otherwise, it will attempt to derive a new device from the given source device. If direct derivation to the new type is not implemented, it will attempt the same derivation from each ancestor of the source device in turn looking for an implemented derivation method.
dst_ctx | On success, a reference to the newly-created AVHWDeviceContext. |
type | The type of the new device to create. |
src_ctx | A reference to an existing AVHWDeviceContext which will be used to create the new device. |
flags | Currently unused; should be set to zero. |
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.
This function performs the same action as av_hwdevice_ctx_create_derived, however, it is able to set options for the new device to be derived.
dst_ctx | On success, a reference to the newly-created AVHWDeviceContext. |
type | The type of the new device to create. |
src_ctx | A reference to an existing AVHWDeviceContext which will be used to create the new device. |
options | Options for the new device to create, same format as in av_hwdevice_ctx_create. |
flags | Currently unused; should be set to zero. |
AVBufferRef* av_hwframe_ctx_alloc | ( | AVBufferRef * | device_ctx | ) |
Allocate an AVHWFramesContext tied to a given device context.
device_ctx | a reference to a AVHWDeviceContext. This function will make a new reference for internal use, the one passed to the function remains owned by the caller. |
Referenced by get_format(), and set_hwframe_ctx().
int av_hwframe_ctx_init | ( | AVBufferRef * | ref | ) |
Finalize the context before use.
This function must be called after the context is filled with all the required information and before it is attached to any frames.
ref | a reference to the AVHWFramesContext |
Referenced by get_format(), and set_hwframe_ctx().
int av_hwframe_get_buffer | ( | AVBufferRef * | hwframe_ctx, |
AVFrame * | frame, | ||
int | flags | ||
) |
Allocate a new frame attached to the given AVHWFramesContext.
hwframe_ctx | a reference to an AVHWFramesContext |
frame | an empty (freshly allocated or unreffed) frame to be filled with newly allocated buffers. |
flags | currently unused, should be set to zero |
Referenced by main().
Copy data to or from a hw surface.
At least one of dst/src must have an AVHWFramesContext attached.
If src has an AVHWFramesContext attached, then the format of dst (if set) must use one of the formats returned by av_hwframe_transfer_get_formats(src, AV_HWFRAME_TRANSFER_DIRECTION_FROM). If dst has an AVHWFramesContext attached, then the format of src must use one of the formats returned by av_hwframe_transfer_get_formats(dst, AV_HWFRAME_TRANSFER_DIRECTION_TO)
dst may be "clean" (i.e. with data/buf pointers unset), in which case the data buffers will be allocated by this function using av_frame_get_buffer(). If dst->format is set, then this format will be used, otherwise (when dst->format is AV_PIX_FMT_NONE) the first acceptable format will be chosen.
The two frames must have matching allocated dimensions (i.e. equal to AVHWFramesContext.width/height), since not all device types support transferring a sub-rectangle of the whole surface. The display dimensions (i.e. AVFrame.width/height) may be smaller than the allocated dimensions, but also have to be equal for both frames. When the display dimensions are smaller than the allocated dimensions, the content of the padding in the destination frame is unspecified.
dst | the destination frame. dst is not touched on failure. |
src | the source frame. |
flags | currently unused, should be set to zero |
Referenced by decode_packet(), decode_write(), and main().
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().
hwframe_ctx | the frame context to obtain the information for |
dir | the direction of the transfer |
formats | the pointer to the output format list will be written here. The list is terminated with AV_PIX_FMT_NONE and must be freed by the caller when no longer needed using av_free(). If this function returns successfully, the format list will have at least one item (not counting the terminator). On failure, the contents of this pointer are unspecified. |
flags | currently unused, should be set to zero |
void* av_hwdevice_hwconfig_alloc | ( | AVBufferRef * | device_ctx | ) |
Allocate a HW-specific configuration structure for a given HW device.
After use, the user must free all members as required by the specific hardware structure being used, then free the structure itself with av_free().
device_ctx | a reference to the associated AVHWDeviceContext. |
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 that device.
If no HW-specific configuration is provided, returns the maximum possible capabilities of the device.
ref | a reference to the associated AVHWDeviceContext. |
hwconfig | a filled HW-specific configuration structure, or NULL to return the maximum possible capabilities of the device. |
void av_hwframe_constraints_free | ( | AVHWFramesConstraints ** | constraints | ) |
Free an AVHWFrameConstraints structure.
constraints | The (filled or unfilled) AVHWFrameConstraints structure. |
Map a hardware frame.
This has a number of different possible effects, depending on the format and origin of the src and dst frames. On input, src should be a usable frame with valid buffers and dst should be blank (typically as just created by av_frame_alloc()). src should have an associated hwframe context, and dst may optionally have a format and associated hwframe context.
If src was created by mapping a frame from the hwframe context of dst, then this function undoes the mapping - dst is replaced by a reference to the frame that src was originally mapped from.
If both src and dst have an associated hwframe context, then this function attempts to map the src frame from its hardware context to that of dst and then fill dst with appropriate data to be usable there. This will only be possible if the hwframe contexts and associated devices are compatible - given compatible devices, av_hwframe_ctx_create_derived() can be used to create a hwframe context for dst in which mapping should be possible.
If src has a hwframe context but dst does not, then the src frame is mapped to normal memory and should thereafter be usable as a normal frame. If the format is set on dst, then the mapping will attempt to create dst with that format and fail if it is not possible. If format is unset (is AV_PIX_FMT_NONE) then dst will be mapped with whatever the most appropriate format to use is (probably the sw_format of the src hwframe context).
A return value of AVERROR(ENOSYS) indicates that the mapping is not possible with the given arguments and hwframe setup, while other return values indicate that it failed somehow.
dst | Destination frame, to contain the mapping. |
src | Source frame, to be mapped. |
flags | Some combination of AV_HWFRAME_MAP_* flags. |
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 different device.
av_hwframe_ctx_init() should not be called after this.
derived_frame_ctx | On success, a reference to the newly created AVHWFramesContext. |
derived_device_ctx | A reference to the device to create the new AVHWFramesContext on. |
source_frame_ctx | A reference to an existing AVHWFramesContext which will be mapped to the derived context. |
flags | Some combination of AV_HWFRAME_MAP_* flags, defining the mapping parameters to apply to frames which are allocated in the derived device. |