Go to the documentation of this file.
65 int err, device_is_derived;
74 device_is_derived = 0;
79 if (
ctx->derive_device_type) {
93 "device context: %d.\n", err);
96 device_is_derived = 1;
113 "required to map to a hardware format.\n");
125 "frames context: %d.\n", err);
140 if (!
ctx->hwframes_ref) {
157 "target frames context: %d.\n", err);
168 "derived source frames context: %d.\n", err);
188 if (!
ctx->hwframes_ref) {
197 "hwmap: from %s (%s) to %s.\n",
212 "required to create new frames with reverse "
221 if (!
ctx->hwframes_ref) {
238 "context for reverse mapping: %d.\n", err);
244 "context (a device, or frames on input).\n");
257 if (device_is_derived)
262 if (device_is_derived)
282 "frame for software mapping.\n");
295 "software: %d.\n", err);
328 if (!
map->hw_frames_ctx) {
333 if (
ctx->reverse && !
input->hw_frames_ctx) {
338 if (!
input->hw_frames_ctx) {
375 #define OFFSET(x) offsetof(HWMapContext, x)
376 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
378 {
"mode",
"Frame mapping mode",
381 0, INT_MAX,
FLAGS, .unit =
"mode" },
383 {
"read",
"Mapping should be readable",
385 INT_MIN, INT_MAX,
FLAGS, .unit =
"mode" },
386 {
"write",
"Mapping should be writeable",
388 INT_MIN, INT_MAX,
FLAGS, .unit =
"mode" },
389 {
"overwrite",
"Mapping will always overwrite the entire frame",
391 INT_MIN, INT_MAX,
FLAGS, .unit =
"mode" },
392 {
"direct",
"Mapping should not involve any copying",
394 INT_MIN, INT_MAX,
FLAGS, .unit =
"mode" },
396 {
"derive_device",
"Derive a new device of this type",
399 {
"reverse",
"Map in reverse (create and allocate in the sink)",
401 { .i64 = 0 }, 0, 1,
FLAGS },
430 .priv_class = &hwmap_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
char * derive_device_type
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 they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
@ AV_HWFRAME_MAP_OVERWRITE
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
static const AVOption hwmap_options[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
uint8_t * data
The data buffer.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags)
Map a hardware frame.
AVBufferRef * hwframes_ref
enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
Look up an AVHWDeviceType by name.
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in.
static const AVFilterPad hwmap_outputs[]
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
const char * name
Filter name.
int width
The allocated dimensions of the frames in this pool.
A link between two filters.
Link properties exposed to filter code, but not external callers.
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
void * priv
private data for use by the filter
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
if it could not because there are no more frames
int extra_hw_frames
Sets the number of extra hardware frames which the filter will allocate on its output links for use i...
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
A filter pad used for either input or output.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static av_cold void hwmap_uninit(AVFilterContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_HWFRAME_MAP_READ
The mapping must be readable.
const AVFilter ff_vf_hwmap
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define FILTER_OUTPUTS(array)
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 they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
Describe the class of an AVClass context structure.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
static int hwmap_query_formats(const AVFilterContext *avctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
AVFilterLink ** inputs
array of pointers to input links
@ AV_HWFRAME_MAP_WRITE
The mapping must be writeable.
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...
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
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 source
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
int format
agreed upon media format
AVFilterContext * src
source filter
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
AVFILTER_DEFINE_CLASS(hwmap)
int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr, enum AVHWDeviceType type, AVBufferRef *src_ref, int flags)
Create a new device of the specified type from an existing device.
int w
agreed upon image width
#define FILTER_QUERY_FUNC2(func)
const char * name
Pad name.
This struct describes a set or pool of "hardware" frames (i.e.
int h
agreed upon image height
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_HWFRAME_MAP_DIRECT
The mapping must be direct.
int initial_pool_size
Initial size of the frame pool.
static int hwmap_filter_frame(AVFilterLink *link, AVFrame *input)
A reference to a data buffer.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
const VDPAUPixFmtMap * map
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
static int hwmap_config_output(AVFilterLink *outlink)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
static const AVFilterPad hwmap_inputs[]
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
static AVFrame * hwmap_get_buffer(AVFilterLink *inlink, int w, int h)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
AVFilterLink ** outputs
array of pointers to output links