69 int err, device_is_derived;
78 device_is_derived = 0;
83 if (
ctx->derive_device_type) {
97 "device context: %d.\n", err);
100 device_is_derived = 1;
117 "required to map to a hardware format.\n");
129 "frames context: %d.\n", err);
144 if (!
ctx->hwframes_ref) {
161 frames_d3d11->
BindFlags = D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE;
167 "target frames context: %d.\n", err);
178 "derived source frames context: %d.\n", err);
198 if (!
ctx->hwframes_ref) {
207 "hwmap: from %s (%s) to %s.\n",
222 "required to create new frames with reverse "
231 if (!
ctx->hwframes_ref) {
248 "context for reverse mapping: %d.\n", err);
254 "context (a device, or frames on input).\n");
264 outlink->
w = inlink->
w;
265 outlink->
h = inlink->
h;
267 if (device_is_derived)
272 if (device_is_derived)
292 "frame for software mapping.\n");
305 "software: %d.\n", err);
338 if (!
map->hw_frames_ctx) {
385#define OFFSET(x) offsetof(HWMapContext, x)
386#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
388 {
"mode",
"Frame mapping mode",
391 0, INT_MAX,
FLAGS, .unit =
"mode" },
393 {
"read",
"Mapping should be readable",
395 INT_MIN, INT_MAX,
FLAGS, .unit =
"mode" },
396 {
"write",
"Mapping should be writeable",
398 INT_MIN, INT_MAX,
FLAGS, .unit =
"mode" },
399 {
"overwrite",
"Mapping will always overwrite the entire frame",
401 INT_MIN, INT_MAX,
FLAGS, .unit =
"mode" },
402 {
"direct",
"Mapping should not involve any copying",
404 INT_MIN, INT_MAX,
FLAGS, .unit =
"mode" },
406 {
"derive_device",
"Derive a new device of this type",
409 {
"reverse",
"Map in reverse (create and allocate in the sink)",
411 { .i64 = 0 }, 0, 1,
FLAGS },
438 .p.priv_class = &hwmap_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFFilter ff_vf_hwmap
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
refcounted data buffer API
static uint64_t reverse(uint64_t p, unsigned int deg)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ 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...
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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 av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx, enum AVPixelFormat format, AVBufferRef *derived_device_ctx, AVBufferRef *source_frame_ctx, int flags)
Create and initialise an AVHWFramesContext as a mapping of another existing AVHWFramesContext on a di...
enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
Look up an AVHWDeviceType by name.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
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.
@ AV_HWFRAME_MAP_READ
The mapping must be readable.
@ AV_HWFRAME_MAP_DIRECT
The mapping must be direct.
@ 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 n...
An API-specific header for AV_HWDEVICE_TYPE_D3D11VA.
const VDPAUPixFmtMap * map
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
A reference to a data buffer.
uint8_t * data
The data buffer.
Describe the class of an AVClass context structure.
This struct is allocated as AVHWFramesContext.hwctx.
UINT BindFlags
D3D11_TEXTURE2D_DESC.BindFlags used for texture creation.
int extra_hw_frames
Sets the number of extra hardware frames which the filter will allocate on its output links for use i...
AVFilterLink ** inputs
array of pointers to input links
void * priv
private data for use by the filter
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in.
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
This struct describes a set or pool of "hardware" frames (i.e.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int initial_pool_size
Initial size of the frame pool.
int width
The allocated dimensions of the frames in this pool.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Link properties exposed to filter code, but not external callers.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
AVBufferRef * hwframes_ref
char * derive_device_type
static int hwmap_config_output(AVFilterLink *outlink)
static const AVFilterPad hwmap_inputs[]
static av_cold void hwmap_uninit(AVFilterContext *avctx)
static const AVFilterPad hwmap_outputs[]
static const AVOption hwmap_options[]
static int hwmap_filter_frame(AVFilterLink *link, AVFrame *input)
static int hwmap_query_formats(const AVFilterContext *avctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static AVFrame * hwmap_get_buffer(AVFilterLink *inlink, int w, int h)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)