FFmpeg
vf_hwmap.c
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 #include "libavutil/buffer.h"
20 #include "libavutil/hwcontext.h"
21 #include "libavutil/log.h"
22 #include "libavutil/opt.h"
23 #include "libavutil/pixdesc.h"
24 
25 #include "avfilter.h"
26 #include "filters.h"
27 #include "formats.h"
28 #include "video.h"
29 
30 typedef struct HWMapContext {
31  const AVClass *class;
32 
34 
35  int mode;
37  int reverse;
38 } HWMapContext;
39 
41 {
42  int ret;
43 
45  &avctx->inputs[0]->outcfg.formats)) < 0 ||
47  &avctx->outputs[0]->incfg.formats)) < 0)
48  return ret;
49 
50  return 0;
51 }
52 
53 static int hwmap_config_output(AVFilterLink *outlink)
54 {
55  FilterLink *outl = ff_filter_link(outlink);
56  AVFilterContext *avctx = outlink->src;
57  HWMapContext *ctx = avctx->priv;
58  AVFilterLink *inlink = avctx->inputs[0];
60  AVHWFramesContext *hwfc;
61  AVBufferRef *device;
62  const AVPixFmtDescriptor *desc;
63  int err, device_is_derived;
64 
65  av_log(avctx, AV_LOG_DEBUG, "Configure hwmap %s -> %s.\n",
66  av_get_pix_fmt_name(inlink->format),
67  av_get_pix_fmt_name(outlink->format));
68 
69  av_buffer_unref(&ctx->hwframes_ref);
70 
71  device = avctx->hw_device_ctx;
72  device_is_derived = 0;
73 
74  if (inl->hw_frames_ctx) {
75  hwfc = (AVHWFramesContext*)inl->hw_frames_ctx->data;
76 
77  if (ctx->derive_device_type) {
78  enum AVHWDeviceType type;
79 
80  type = av_hwdevice_find_type_by_name(ctx->derive_device_type);
81  if (type == AV_HWDEVICE_TYPE_NONE) {
82  av_log(avctx, AV_LOG_ERROR, "Invalid device type.\n");
83  err = AVERROR(EINVAL);
84  goto fail;
85  }
86 
87  err = av_hwdevice_ctx_create_derived(&device, type,
88  hwfc->device_ref, 0);
89  if (err < 0) {
90  av_log(avctx, AV_LOG_ERROR, "Failed to created derived "
91  "device context: %d.\n", err);
92  goto fail;
93  }
94  device_is_derived = 1;
95  }
96 
97  desc = av_pix_fmt_desc_get(outlink->format);
98  if (!desc) {
99  err = AVERROR(EINVAL);
100  goto fail;
101  }
102 
103  if (inlink->format == hwfc->format &&
104  (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) &&
105  !ctx->reverse) {
106  // Map between two hardware formats (including the case of
107  // undoing an existing mapping).
108 
109  if (!device) {
110  av_log(avctx, AV_LOG_ERROR, "A device reference is "
111  "required to map to a hardware format.\n");
112  err = AVERROR(EINVAL);
113  goto fail;
114  }
115 
116  err = av_hwframe_ctx_create_derived(&ctx->hwframes_ref,
117  outlink->format,
118  device,
119  inl->hw_frames_ctx,
120  ctx->mode);
121  if (err < 0) {
122  av_log(avctx, AV_LOG_ERROR, "Failed to create derived "
123  "frames context: %d.\n", err);
124  goto fail;
125  }
126 
127  } else if (inlink->format == hwfc->format &&
128  (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) &&
129  ctx->reverse) {
130  // Map between two hardware formats, but do it in reverse.
131  // Make a new hwframe context for the target type, and then
132  // overwrite the input hwframe context with a derived context
133  // mapped from that back to the source type.
136 
137  ctx->hwframes_ref = av_hwframe_ctx_alloc(device);
138  if (!ctx->hwframes_ref) {
139  err = AVERROR(ENOMEM);
140  goto fail;
141  }
142  frames = (AVHWFramesContext*)ctx->hwframes_ref->data;
143 
144  frames->format = outlink->format;
145  frames->sw_format = hwfc->sw_format;
146  frames->width = hwfc->width;
147  frames->height = hwfc->height;
148 
149  if (avctx->extra_hw_frames >= 0)
150  frames->initial_pool_size = 2 + avctx->extra_hw_frames;
151 
152  err = av_hwframe_ctx_init(ctx->hwframes_ref);
153  if (err < 0) {
154  av_log(avctx, AV_LOG_ERROR, "Failed to initialise "
155  "target frames context: %d.\n", err);
156  goto fail;
157  }
158 
160  inlink->format,
161  hwfc->device_ref,
162  ctx->hwframes_ref,
163  ctx->mode);
164  if (err < 0) {
165  av_log(avctx, AV_LOG_ERROR, "Failed to create "
166  "derived source frames context: %d.\n", err);
167  goto fail;
168  }
169 
170  // Here is the naughty bit. This overwriting changes what
171  // ff_get_video_buffer() in the previous filter returns -
172  // it will now give a frame allocated here mapped back to
173  // the format it expects. If there were any additional
174  // constraints on the output frames there then this may
175  // break nastily.
177  inl->hw_frames_ctx = source;
178 
179  } else if ((outlink->format == hwfc->format &&
180  inlink->format == hwfc->sw_format) ||
181  inlink->format == hwfc->format) {
182  // Map from a hardware format to a software format, or
183  // undo an existing such mapping.
184 
185  ctx->hwframes_ref = av_buffer_ref(inl->hw_frames_ctx);
186  if (!ctx->hwframes_ref) {
187  err = AVERROR(ENOMEM);
188  goto fail;
189  }
190 
191  } else {
192  // Non-matching formats - not supported.
193 
194  av_log(avctx, AV_LOG_ERROR, "Unsupported formats for "
195  "hwmap: from %s (%s) to %s.\n",
196  av_get_pix_fmt_name(inlink->format),
198  av_get_pix_fmt_name(outlink->format));
199  err = AVERROR(EINVAL);
200  goto fail;
201  }
202  } else if (avctx->hw_device_ctx) {
203  // Map from a software format to a hardware format. This
204  // creates a new hwframe context like hwupload, but then
205  // returns frames mapped from that to the previous link in
206  // order to fill them without an additional copy.
207 
208  if (!device) {
209  av_log(avctx, AV_LOG_ERROR, "A device reference is "
210  "required to create new frames with reverse "
211  "mapping.\n");
212  err = AVERROR(EINVAL);
213  goto fail;
214  }
215 
216  ctx->reverse = 1;
217 
218  ctx->hwframes_ref = av_hwframe_ctx_alloc(device);
219  if (!ctx->hwframes_ref) {
220  err = AVERROR(ENOMEM);
221  goto fail;
222  }
223  hwfc = (AVHWFramesContext*)ctx->hwframes_ref->data;
224 
225  hwfc->format = outlink->format;
226  hwfc->sw_format = inlink->format;
227  hwfc->width = inlink->w;
228  hwfc->height = inlink->h;
229 
230  if (avctx->extra_hw_frames >= 0)
231  hwfc->initial_pool_size = 2 + avctx->extra_hw_frames;
232 
233  err = av_hwframe_ctx_init(ctx->hwframes_ref);
234  if (err < 0) {
235  av_log(avctx, AV_LOG_ERROR, "Failed to create frame "
236  "context for reverse mapping: %d.\n", err);
237  goto fail;
238  }
239 
240  } else {
241  av_log(avctx, AV_LOG_ERROR, "Mapping requires a hardware "
242  "context (a device, or frames on input).\n");
243  return AVERROR(EINVAL);
244  }
245 
246  outl->hw_frames_ctx = av_buffer_ref(ctx->hwframes_ref);
247  if (!outl->hw_frames_ctx) {
248  err = AVERROR(ENOMEM);
249  goto fail;
250  }
251 
252  outlink->w = inlink->w;
253  outlink->h = inlink->h;
254 
255  if (device_is_derived)
256  av_buffer_unref(&device);
257  return 0;
258 
259 fail:
260  if (device_is_derived)
261  av_buffer_unref(&device);
262  av_buffer_unref(&ctx->hwframes_ref);
263  return err;
264 }
265 
267 {
269  AVFilterContext *avctx = inlink->dst;
270  AVFilterLink *outlink = avctx->outputs[0];
271  HWMapContext *ctx = avctx->priv;
272 
273  if (ctx->reverse && !l->hw_frames_ctx) {
274  AVFrame *src, *dst;
275  int err;
276 
277  src = ff_get_video_buffer(outlink, w, h);
278  if (!src) {
279  av_log(avctx, AV_LOG_ERROR, "Failed to allocate source "
280  "frame for software mapping.\n");
281  return NULL;
282  }
283 
284  dst = av_frame_alloc();
285  if (!dst) {
286  av_frame_free(&src);
287  return NULL;
288  }
289 
290  err = av_hwframe_map(dst, src, ctx->mode);
291  if (err) {
292  av_log(avctx, AV_LOG_ERROR, "Failed to map frame to "
293  "software: %d.\n", err);
294  av_frame_free(&src);
295  av_frame_free(&dst);
296  return NULL;
297  }
298 
299  av_frame_free(&src);
300  return dst;
301  } else {
303  }
304 }
305 
307 {
308  AVFilterContext *avctx = link->dst;
309  AVFilterLink *outlink = avctx->outputs[0];
310  HWMapContext *ctx = avctx->priv;
311  AVFrame *map = NULL;
312  int err;
313 
314  av_log(ctx, AV_LOG_DEBUG, "Filter input: %s, %ux%u (%"PRId64").\n",
315  av_get_pix_fmt_name(input->format),
316  input->width, input->height, input->pts);
317 
318  map = av_frame_alloc();
319  if (!map) {
320  err = AVERROR(ENOMEM);
321  goto fail;
322  }
323 
324  map->format = outlink->format;
325  map->hw_frames_ctx = av_buffer_ref(ctx->hwframes_ref);
326  if (!map->hw_frames_ctx) {
327  err = AVERROR(ENOMEM);
328  goto fail;
329  }
330 
331  if (ctx->reverse && !input->hw_frames_ctx) {
332  // If we mapped backwards from hardware to software, we need
333  // to attach the hardware frame context to the input frame to
334  // make the mapping visible to av_hwframe_map().
335  input->hw_frames_ctx = av_buffer_ref(ctx->hwframes_ref);
336  if (!input->hw_frames_ctx) {
337  err = AVERROR(ENOMEM);
338  goto fail;
339  }
340  }
341 
342  err = av_hwframe_map(map, input, ctx->mode);
343  if (err < 0) {
344  av_log(avctx, AV_LOG_ERROR, "Failed to map frame: %d.\n", err);
345  goto fail;
346  }
347 
348  err = av_frame_copy_props(map, input);
349  if (err < 0)
350  goto fail;
351 
353 
354  av_log(ctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64").\n",
355  av_get_pix_fmt_name(map->format),
356  map->width, map->height, map->pts);
357 
358  return ff_filter_frame(outlink, map);
359 
360 fail:
362  av_frame_free(&map);
363  return err;
364 }
365 
367 {
368  HWMapContext *ctx = avctx->priv;
369 
370  av_buffer_unref(&ctx->hwframes_ref);
371 }
372 
373 #define OFFSET(x) offsetof(HWMapContext, x)
374 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
375 static const AVOption hwmap_options[] = {
376  { "mode", "Frame mapping mode",
379  0, INT_MAX, FLAGS, .unit = "mode" },
380 
381  { "read", "Mapping should be readable",
382  0, AV_OPT_TYPE_CONST, { .i64 = AV_HWFRAME_MAP_READ },
383  INT_MIN, INT_MAX, FLAGS, .unit = "mode" },
384  { "write", "Mapping should be writeable",
386  INT_MIN, INT_MAX, FLAGS, .unit = "mode" },
387  { "overwrite", "Mapping will always overwrite the entire frame",
389  INT_MIN, INT_MAX, FLAGS, .unit = "mode" },
390  { "direct", "Mapping should not involve any copying",
392  INT_MIN, INT_MAX, FLAGS, .unit = "mode" },
393 
394  { "derive_device", "Derive a new device of this type",
395  OFFSET(derive_device_type), AV_OPT_TYPE_STRING,
396  { .str = NULL }, 0, 0, FLAGS },
397  { "reverse", "Map in reverse (create and allocate in the sink)",
398  OFFSET(reverse), AV_OPT_TYPE_INT,
399  { .i64 = 0 }, 0, 1, FLAGS },
400 
401  { NULL }
402 };
403 
404 AVFILTER_DEFINE_CLASS(hwmap);
405 
406 static const AVFilterPad hwmap_inputs[] = {
407  {
408  .name = "default",
409  .type = AVMEDIA_TYPE_VIDEO,
410  .get_buffer.video = hwmap_get_buffer,
411  .filter_frame = hwmap_filter_frame,
412  },
413 };
414 
415 static const AVFilterPad hwmap_outputs[] = {
416  {
417  .name = "default",
418  .type = AVMEDIA_TYPE_VIDEO,
419  .config_props = hwmap_config_output,
420  },
421 };
422 
424  .name = "hwmap",
425  .description = NULL_IF_CONFIG_SMALL("Map hardware frames"),
426  .uninit = hwmap_uninit,
427  .priv_size = sizeof(HWMapContext),
428  .priv_class = &hwmap_class,
432  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
433  .flags = AVFILTER_FLAG_HWDEVICE,
434 };
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:116
HWMapContext::derive_device_type
char * derive_device_type
Definition: vf_hwmap.c:36
AVERROR
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
opt.h
hwmap_options
static const AVOption hwmap_options[]
Definition: vf_hwmap.c:375
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1023
HWMapContext
Definition: vf_hwmap.c:30
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2965
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AV_HWFRAME_MAP_DIRECT
@ AV_HWFRAME_MAP_DIRECT
The mapping must be direct.
Definition: hwcontext.h:528
AVHWFramesContext::format
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:197
inlink
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
Definition: filter_design.txt:212
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:162
av_hwframe_ctx_init
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition: hwcontext.c:322
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
test::height
int height
Definition: vc1dsp.c:40
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
pixdesc.h
w
uint8_t w
Definition: llviddspenc.c:38
av_hwframe_ctx_alloc
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
Definition: hwcontext.c:248
AV_HWDEVICE_TYPE_NONE
@ AV_HWDEVICE_TYPE_NONE
Definition: hwcontext.h:28
AVOption
AVOption.
Definition: opt.h:429
av_hwframe_map
int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags)
Map a hardware frame.
Definition: hwcontext.c:778
HWMapContext::hwframes_ref
AVBufferRef * hwframes_ref
Definition: vf_hwmap.c:33
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
AVFilterContext::hw_device_ctx
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in.
Definition: avfilter.h:519
hwmap_outputs
static const AVFilterPad hwmap_outputs[]
Definition: vf_hwmap.c:415
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
AVHWFramesContext::width
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:217
video.h
AV_HWFRAME_MAP_READ
@ AV_HWFRAME_MAP_READ
The mapping must be readable.
Definition: hwcontext.h:512
HWMapContext::reverse
int reverse
Definition: vf_hwmap.c:37
formats.h
ff_default_get_video_buffer
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:111
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:472
fail
#define fail()
Definition: checkasm.h:188
AV_PIX_FMT_FLAG_HWACCEL
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:128
frames
if it could not because there are no more frames
Definition: filter_design.txt:266
AVFilterContext::extra_hw_frames
int extra_hw_frames
Sets the number of extra hardware frames which the filter will allocate on its output links for use i...
Definition: avfilter.h:542
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
ff_all_formats
AVFilterFormats * ff_all_formats(enum AVMediaType type)
Return a list of all formats supported by FFmpeg for the given media type.
Definition: formats.c:535
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:150
hwmap_uninit
static av_cold void hwmap_uninit(AVFilterContext *avctx)
Definition: vf_hwmap.c:366
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
AVHWFramesContext::height
int height
Definition: hwcontext.h:217
ff_vf_hwmap
const AVFilter ff_vf_hwmap
Definition: vf_hwmap.c:423
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:678
AVHWDeviceType
AVHWDeviceType
Definition: hwcontext.h:27
filters.h
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:49
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
link
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
Definition: filter_design.txt:23
if
if(ret)
Definition: filter_design.txt:179
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:210
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:713
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
AVHWFramesContext::device_ref
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
Definition: hwcontext.h:126
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:465
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
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:197
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: filters.h:206
source
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
Definition: filter_design.txt:255
test::width
int width
Definition: vc1dsp.c:39
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
HWMapContext::mode
int mode
Definition: vf_hwmap.c:35
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:173
buffer.h
input
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
Definition: filter_design.txt:172
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(hwmap)
hwmap_query_formats
static int hwmap_query_formats(AVFilterContext *avctx)
Definition: vf_hwmap.c:40
OFFSET
#define OFFSET(x)
Definition: vf_hwmap.c:373
av_hwdevice_ctx_create_derived
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.
Definition: hwcontext.c:703
log.h
AV_HWFRAME_MAP_WRITE
@ AV_HWFRAME_MAP_WRITE
The mapping must be writeable.
Definition: hwcontext.h:516
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
AVFilter
Filter definition.
Definition: avfilter.h:201
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:115
ret
ret
Definition: filter_design.txt:187
FLAGS
#define FLAGS
Definition: vf_hwmap.c:374
mode
mode
Definition: ebur128.h:83
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
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
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
AVHWFramesContext::initial_pool_size
int initial_pool_size
Initial size of the frame pool.
Definition: hwcontext.h:187
desc
const char * desc
Definition: libsvtav1.c:79
hwmap_filter_frame
static int hwmap_filter_frame(AVFilterLink *link, AVFrame *input)
Definition: vf_hwmap.c:306
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
AVFilterFormatsConfig::formats
AVFilterFormats * formats
List of supported formats (pixel or sample).
Definition: avfilter.h:116
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
hwcontext.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
h
h
Definition: vp9dsp_template.c:2070
hwmap_config_output
static int hwmap_config_output(AVFilterLink *outlink)
Definition: vf_hwmap.c:53
AV_OPT_TYPE_STRING
@ 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...
Definition: opt.h:276
hwmap_inputs
static const AVFilterPad hwmap_inputs[]
Definition: vf_hwmap.c:406
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
hwmap_get_buffer
static AVFrame * hwmap_get_buffer(AVFilterLink *inlink, int w, int h)
Definition: vf_hwmap.c:266
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: filters.h:236
src
#define src
Definition: vp8dsp.c:248
av_get_pix_fmt_name
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.
Definition: pixdesc.c:2885
AVFilterContext::outputs
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:469