FFmpeg
vf_yadif_videotoolbox.m
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Philip Langdale <philipl@overt.org>
3  * 2020 Aman Karmani <aman@tmm1.net>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "filters.h"
23 #include "metal/utils.h"
24 #include "yadif.h"
25 #include "libavutil/avassert.h"
26 #include "libavutil/hwcontext.h"
28 #include "libavutil/objc.h"
29 
30 #include <assert.h>
31 
33 extern unsigned int ff_vf_yadif_videotoolbox_metallib_len;
34 
35 typedef struct API_AVAILABLE(macos(10.11), ios(8.0)) YADIFVTContext {
36  YADIFContext yadif;
37 
38  AVBufferRef *device_ref;
39  AVBufferRef *input_frames_ref;
40  AVHWFramesContext *input_frames;
41 
42  id<MTLDevice> mtlDevice;
43  id<MTLLibrary> mtlLibrary;
44  id<MTLCommandQueue> mtlQueue;
45  id<MTLComputePipelineState> mtlPipeline;
46  id<MTLFunction> mtlFunction;
47  id<MTLBuffer> mtlParamsBuffer;
48 
49  CVMetalTextureCacheRef textureCache;
50 } YADIFVTContext API_AVAILABLE(macos(10.11), ios(8.0));
51 
52 // Using sizeof(YADIFVTContext) outside of an availability check will error
53 // if we're targeting an older OS version, so we need to calculate the size ourselves
54 // (we'll statically verify it's correct in yadif_videotoolbox_init behind a check)
55 #define YADIF_VT_CTX_SIZE (sizeof(YADIFContext) + sizeof(void*) * 10)
56 
57 struct mtlYadifParams {
58  uint channels;
59  uint parity;
60  uint tff;
61  bool is_second_field;
62  bool skip_spatial_check;
63  int field_mode;
64 };
65 
66 static void call_kernel(AVFilterContext *ctx,
67  id<MTLTexture> dst,
68  id<MTLTexture> prev,
69  id<MTLTexture> cur,
70  id<MTLTexture> next,
71  int channels,
72  int parity,
73  int tff) API_AVAILABLE(macos(10.11), ios(8.0))
74 {
75  YADIFVTContext *s = ctx->priv;
76  id<MTLCommandBuffer> buffer = s->mtlQueue.commandBuffer;
77  id<MTLComputeCommandEncoder> encoder = buffer.computeCommandEncoder;
78  struct mtlYadifParams *params = (struct mtlYadifParams *)s->mtlParamsBuffer.contents;
79  *params = (struct mtlYadifParams){
80  .channels = channels,
81  .parity = parity,
82  .tff = tff,
83  .is_second_field = !(parity ^ tff),
84  .skip_spatial_check = s->yadif.mode&2,
85  .field_mode = s->yadif.current_field
86  };
87 
88  [encoder setTexture:dst atIndex:0];
89  [encoder setTexture:prev atIndex:1];
90  [encoder setTexture:cur atIndex:2];
91  [encoder setTexture:next atIndex:3];
92  [encoder setBuffer:s->mtlParamsBuffer offset:0 atIndex:4];
93  ff_metal_compute_encoder_dispatch(s->mtlDevice, s->mtlPipeline, encoder, dst.width, dst.height);
94  [encoder endEncoding];
95 
96  [buffer commit];
97  [buffer waitUntilCompleted];
98 
99  ff_objc_release(&encoder);
101 }
102 
103 static void filter(AVFilterContext *ctx, AVFrame *dst,
104  int parity, int tff) API_AVAILABLE(macos(10.11), ios(8.0))
105 {
106  YADIFVTContext *s = ctx->priv;
107  YADIFContext *y = &s->yadif;
108  int i;
109 
110  for (i = 0; i < y->csp->nb_components; i++) {
111  int pixel_size, channels;
112  const AVComponentDescriptor *comp = &y->csp->comp[i];
113  CVMetalTextureRef prev, cur, next, dest;
114  id<MTLTexture> tex_prev, tex_cur, tex_next, tex_dest;
115  MTLPixelFormat format;
116 
117  if (comp->plane < i) {
118  // We process planes as a whole, so don't reprocess
119  // them for additional components
120  continue;
121  }
122 
123  pixel_size = (comp->depth + comp->shift) / 8;
124  channels = comp->step / pixel_size;
125  if (pixel_size > 2 || channels > 2) {
126  av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", y->csp->name);
127  goto exit;
128  }
129  switch (pixel_size) {
130  case 1:
131  format = channels == 1 ? MTLPixelFormatR8Unorm : MTLPixelFormatRG8Unorm;
132  break;
133  case 2:
134  format = channels == 1 ? MTLPixelFormatR16Unorm : MTLPixelFormatRG16Unorm;
135  break;
136  default:
137  av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", y->csp->name);
138  goto exit;
139  }
141  "Deinterlacing plane %d: pixel_size: %d channels: %d\n",
142  comp->plane, pixel_size, channels);
143 
144  prev = ff_metal_texture_from_pixbuf(ctx, s->textureCache, (CVPixelBufferRef)y->prev->data[3], i, format);
145  cur = ff_metal_texture_from_pixbuf(ctx, s->textureCache, (CVPixelBufferRef)y->cur->data[3], i, format);
146  next = ff_metal_texture_from_pixbuf(ctx, s->textureCache, (CVPixelBufferRef)y->next->data[3], i, format);
147  dest = ff_metal_texture_from_pixbuf(ctx, s->textureCache, (CVPixelBufferRef)dst->data[3], i, format);
148 
149  tex_prev = CVMetalTextureGetTexture(prev);
150  tex_cur = CVMetalTextureGetTexture(cur);
151  tex_next = CVMetalTextureGetTexture(next);
152  tex_dest = CVMetalTextureGetTexture(dest);
153 
154  call_kernel(ctx, tex_dest, tex_prev, tex_cur, tex_next,
155  channels, parity, tff);
156 
157  CFRelease(prev);
158  CFRelease(cur);
159  CFRelease(next);
160  CFRelease(dest);
161  }
162 
163  CVBufferPropagateAttachments((CVPixelBufferRef)y->cur->data[3], (CVPixelBufferRef)dst->data[3]);
164 
165  if (y->current_field == YADIF_FIELD_END) {
167  }
168 
169 exit:
170  return;
171 }
172 
173 static av_cold void do_uninit(AVFilterContext *ctx) API_AVAILABLE(macos(10.11), ios(8.0))
174 {
175  YADIFVTContext *s = ctx->priv;
176 
178 
179  av_buffer_unref(&s->device_ref);
180  av_buffer_unref(&s->input_frames_ref);
181  s->input_frames = NULL;
182 
183  ff_objc_release(&s->mtlParamsBuffer);
184  ff_objc_release(&s->mtlFunction);
185  ff_objc_release(&s->mtlPipeline);
186  ff_objc_release(&s->mtlQueue);
187  ff_objc_release(&s->mtlLibrary);
188  ff_objc_release(&s->mtlDevice);
189 
190  if (s->textureCache) {
191  CFRelease(s->textureCache);
192  s->textureCache = NULL;
193  }
194 }
195 
196 
197 static av_cold void yadif_videotoolbox_uninit(AVFilterContext *ctx)
198 {
199  if (@available(macOS 10.11, iOS 8.0, *)) {
200  do_uninit(ctx);
201  }
202 }
203 
204 static av_cold int do_init(AVFilterContext *ctx) API_AVAILABLE(macos(10.11), ios(8.0))
205 {
206  YADIFVTContext *s = ctx->priv;
207  NSError *err = nil;
208  CVReturn ret;
209 
210  s->mtlDevice = MTLCreateSystemDefaultDevice();
211  if (!s->mtlDevice) {
212  av_log(ctx, AV_LOG_ERROR, "Unable to find Metal device\n");
213  goto fail;
214  }
215 
216  av_log(ctx, AV_LOG_INFO, "Using Metal device: %s\n", s->mtlDevice.name.UTF8String);
217 
218  dispatch_data_t libData = dispatch_data_create(
221  nil,
222  nil);
223  s->mtlLibrary = [s->mtlDevice newLibraryWithData:libData error:&err];
224  dispatch_release(libData);
225  libData = nil;
226  if (err) {
227  av_log(ctx, AV_LOG_ERROR, "Failed to load Metal library: %s\n", err.description.UTF8String);
228  goto fail;
229  }
230 
231  s->mtlFunction = [s->mtlLibrary newFunctionWithName:@"deint"];
232  if (!s->mtlFunction) {
233  av_log(ctx, AV_LOG_ERROR, "Failed to create Metal function!\n");
234  goto fail;
235  }
236 
237  s->mtlQueue = s->mtlDevice.newCommandQueue;
238  if (!s->mtlQueue) {
239  av_log(ctx, AV_LOG_ERROR, "Failed to create Metal command queue!\n");
240  goto fail;
241  }
242 
243  s->mtlPipeline = [s->mtlDevice
244  newComputePipelineStateWithFunction:s->mtlFunction
245  error:&err];
246  if (err) {
247  av_log(ctx, AV_LOG_ERROR, "Failed to create Metal compute pipeline: %s\n", err.description.UTF8String);
248  goto fail;
249  }
250 
251  s->mtlParamsBuffer = [s->mtlDevice
252  newBufferWithLength:sizeof(struct mtlYadifParams)
253  options:MTLResourceStorageModeShared];
254  if (!s->mtlParamsBuffer) {
255  av_log(ctx, AV_LOG_ERROR, "Failed to create Metal buffer for parameters\n");
256  goto fail;
257  }
258 
259  ret = CVMetalTextureCacheCreate(
260  NULL,
261  NULL,
262  s->mtlDevice,
263  NULL,
264  &s->textureCache
265  );
266  if (ret != kCVReturnSuccess) {
267  av_log(ctx, AV_LOG_ERROR, "Failed to create CVMetalTextureCache: %d\n", ret);
268  goto fail;
269  }
270 
271  return 0;
272 fail:
273  yadif_videotoolbox_uninit(ctx);
274  return AVERROR_EXTERNAL;
275 }
276 
277 static av_cold int yadif_videotoolbox_init(AVFilterContext *ctx)
278 {
279  if (@available(macOS 10.11, iOS 8.0, *)) {
280  // Ensure we calculated YADIF_VT_CTX_SIZE correctly
281  static_assert(YADIF_VT_CTX_SIZE == sizeof(YADIFVTContext), "Incorrect YADIF_VT_CTX_SIZE value!");
282  return do_init(ctx);
283  } else {
284  av_log(ctx, AV_LOG_ERROR, "Metal is not available on this OS version\n");
285  return AVERROR(ENOSYS);
286  }
287 }
288 
289 static int do_config_input(AVFilterLink *inlink) API_AVAILABLE(macos(10.11), ios(8.0))
290 {
292  AVFilterContext *ctx = inlink->dst;
293  YADIFVTContext *s = ctx->priv;
294 
295  if (!l->hw_frames_ctx) {
296  av_log(ctx, AV_LOG_ERROR, "A hardware frames reference is "
297  "required to associate the processing device.\n");
298  return AVERROR(EINVAL);
299  }
300 
301  s->input_frames_ref = av_buffer_ref(l->hw_frames_ctx);
302  if (!s->input_frames_ref) {
303  av_log(ctx, AV_LOG_ERROR, "A input frames reference create "
304  "failed.\n");
305  return AVERROR(ENOMEM);
306  }
307  s->input_frames = (AVHWFramesContext*)s->input_frames_ref->data;
308 
309  return 0;
310 }
311 
312 static int config_input(AVFilterLink *inlink)
313 {
314  AVFilterContext *ctx = inlink->dst;
315  if (@available(macOS 10.11, iOS 8.0, *)) {
316  return do_config_input(inlink);
317  } else {
318  av_log(ctx, AV_LOG_ERROR, "Metal is not available on this OS version\n");
319  return AVERROR(ENOSYS);
320  }
321 }
322 
323 static int do_config_output(AVFilterLink *link) API_AVAILABLE(macos(10.11), ios(8.0))
324 {
326  FilterLink *il = ff_filter_link(link->src->inputs[0]);
327  AVHWFramesContext *output_frames, *input_frames;
328  AVFilterContext *ctx = link->src;
329  YADIFVTContext *s = ctx->priv;
330  YADIFContext *y = &s->yadif;
331  int ret = 0;
332 
333  av_assert0(s->input_frames);
334  s->device_ref = av_buffer_ref(s->input_frames->device_ref);
335  if (!s->device_ref) {
336  av_log(ctx, AV_LOG_ERROR, "A device reference create "
337  "failed.\n");
338  return AVERROR(ENOMEM);
339  }
340 
341  l->hw_frames_ctx = av_hwframe_ctx_alloc(s->device_ref);
342  if (!l->hw_frames_ctx) {
343  av_log(ctx, AV_LOG_ERROR, "Failed to create HW frame context "
344  "for output.\n");
345  ret = AVERROR(ENOMEM);
346  goto exit;
347  }
348 
349  input_frames = (AVHWFramesContext*)il->hw_frames_ctx->data;
350  output_frames = (AVHWFramesContext*)l->hw_frames_ctx->data;
351 
352  output_frames->format = AV_PIX_FMT_VIDEOTOOLBOX;
353  output_frames->sw_format = s->input_frames->sw_format;
354  output_frames->width = ctx->inputs[0]->w;
355  output_frames->height = ctx->inputs[0]->h;
356  ((AVVTFramesContext *)output_frames->hwctx)->color_range = ((AVVTFramesContext *)input_frames->hwctx)->color_range;
357 
359  if (ret < 0)
360  goto exit;
361 
363  if (ret < 0) {
364  av_log(ctx, AV_LOG_ERROR, "Failed to initialise VideoToolbox frame "
365  "context for output: %d\n", ret);
366  goto exit;
367  }
368 
370  if (ret < 0)
371  goto exit;
372 
373  y->csp = av_pix_fmt_desc_get(output_frames->sw_format);
374  y->filter = filter;
375 
376 exit:
377  return ret;
378 }
379 
380 static int config_output(AVFilterLink *link)
381 {
382  AVFilterContext *ctx = link->src;
383  if (@available(macOS 10.11, iOS 8.0, *)) {
384  return do_config_output(link);
385  } else {
386  av_log(ctx, AV_LOG_ERROR, "Metal is not available on this OS version\n");
387  return AVERROR(ENOSYS);
388  }
389 }
390 
391 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
392 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
393 
394 static const AVOption yadif_videotoolbox_options[] = {
395  #define OFFSET(x) offsetof(YADIFContext, x)
396  { "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=YADIF_MODE_SEND_FRAME}, 0, 3, FLAGS, .unit = "mode"},
397  CONST("send_frame", "send one frame for each frame", YADIF_MODE_SEND_FRAME, "mode"),
398  CONST("send_field", "send one frame for each field", YADIF_MODE_SEND_FIELD, "mode"),
399  CONST("send_frame_nospatial", "send one frame for each frame, but skip spatial interlacing check", YADIF_MODE_SEND_FRAME_NOSPATIAL, "mode"),
400  CONST("send_field_nospatial", "send one frame for each field, but skip spatial interlacing check", YADIF_MODE_SEND_FIELD_NOSPATIAL, "mode"),
401 
402  { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=YADIF_PARITY_AUTO}, -1, 1, FLAGS, .unit = "parity" },
403  CONST("tff", "assume top field first", YADIF_PARITY_TFF, "parity"),
404  CONST("bff", "assume bottom field first", YADIF_PARITY_BFF, "parity"),
405  CONST("auto", "auto detect parity", YADIF_PARITY_AUTO, "parity"),
406 
407  { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=YADIF_DEINT_ALL}, 0, 1, FLAGS, .unit = "deint" },
408  CONST("all", "deinterlace all frames", YADIF_DEINT_ALL, "deint"),
409  CONST("interlaced", "only deinterlace frames marked as interlaced", YADIF_DEINT_INTERLACED, "deint"),
410  #undef OFFSET
411 
412  { NULL }
413 };
414 
415 AVFILTER_DEFINE_CLASS(yadif_videotoolbox);
416 
417 static const AVFilterPad yadif_videotoolbox_inputs[] = {
418  {
419  .name = "default",
420  .type = AVMEDIA_TYPE_VIDEO,
421  .filter_frame = ff_yadif_filter_frame,
422  .config_props = config_input,
423  },
424 };
425 
426 static const AVFilterPad yadif_videotoolbox_outputs[] = {
427  {
428  .name = "default",
429  .type = AVMEDIA_TYPE_VIDEO,
430  .request_frame = ff_yadif_request_frame,
431  .config_props = config_output,
432  },
433 };
434 
436  .name = "yadif_videotoolbox",
437  .description = NULL_IF_CONFIG_SMALL("YADIF for VideoToolbox frames using Metal compute"),
438  .priv_size = YADIF_VT_CTX_SIZE,
439  .priv_class = &yadif_videotoolbox_class,
440  .init = yadif_videotoolbox_init,
441  .uninit = yadif_videotoolbox_uninit,
443  FILTER_INPUTS(yadif_videotoolbox_inputs),
444  FILTER_OUTPUTS(yadif_videotoolbox_outputs),
446  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
447 };
YADIF_MODE_SEND_FIELD
@ YADIF_MODE_SEND_FIELD
send 1 frame for each field
Definition: yadif.h:29
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
comp
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:81
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3170
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
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
YADIFContext::csp
const AVPixFmtDescriptor * csp
Definition: yadif.h:76
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
mode
Definition: swscale.c:52
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:403
ff_objc_release
static void ff_objc_release(NSObject **obj)
Definition: objc.h:24
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
ff_vf_yadif_videotoolbox_metallib_len
unsigned int ff_vf_yadif_videotoolbox_metallib_len
AVPixFmtDescriptor::name
const char * name
Definition: pixdesc.h:70
AVOption
AVOption.
Definition: opt.h:429
filter
void(* filter)(uint8_t *src, int stride, int qscale)
Definition: h263dsp.c:29
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
objc.h
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:424
YADIF_MODE_SEND_FRAME
@ YADIF_MODE_SEND_FRAME
send 1 frame for each frame
Definition: yadif.h:28
YADIF_MODE_SEND_FIELD_NOSPATIAL
@ YADIF_MODE_SEND_FIELD_NOSPATIAL
send 1 frame for each field but skips spatial interlacing check
Definition: yadif.h:31
ff_yadif_config_output_common
int ff_yadif_config_output_common(AVFilterLink *outlink)
Definition: yadif_common.c:218
fail
#define fail()
Definition: checkasm.h:193
YADIF_PARITY_AUTO
@ YADIF_PARITY_AUTO
auto detection
Definition: yadif.h:37
YADIF_MODE_SEND_FRAME_NOSPATIAL
@ YADIF_MODE_SEND_FRAME_NOSPATIAL
send 1 frame for each frame but skips spatial interlacing check
Definition: yadif.h:30
ff_vf_yadif_videotoolbox
const AVFilter ff_vf_yadif_videotoolbox
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
first
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But first
Definition: rate_distortion.txt:12
avassert.h
AV_LOG_TRACE
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:235
call_kernel
static CUresult call_kernel(AVFilterContext *ctx, CUfunction func, CUdeviceptr prev, CUdeviceptr cur, CUdeviceptr next, CUarray_format format, int channels, int src_width, int src_height, int src_pitch, CUdeviceptr dst, int dst_width, int dst_height, int dst_pitch, int parity, int tff, int clip_max)
Definition: vf_bwdif_cuda.c:56
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
av_cold
#define av_cold
Definition: attributes.h:90
AVHWFramesContext::height
int height
Definition: hwcontext.h:217
s
#define s(width, name)
Definition: cbs_vp9.c:198
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
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
filters.h
ctx
AVFormatContext * ctx
Definition: movenc.c:49
channels
channels
Definition: aptx.h:31
field
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 field
Definition: writing_filters.txt:78
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
AVVTFramesContext
Definition: hwcontext_videotoolbox.h:45
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
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
YADIF_VT_CTX_SIZE
#define YADIF_VT_CTX_SIZE
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_acontrast.c:121
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
AVComponentDescriptor
Definition: pixdesc.h:30
AVPixFmtDescriptor::nb_components
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
OFFSET
#define OFFSET(x)
AVFILTER_DEFINE_CLASS
#define AVFILTER_DEFINE_CLASS(fname)
Definition: filters.h:273
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
hwcontext_videotoolbox.h
yadif.h
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
ios
void ios(8.0))
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_aap.c:190
YADIFContext::filter
void(* filter)(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff)
Definition: yadif.h:65
parity
mcdeint parity
Definition: vf_mcdeint.c:281
ff_vf_yadif_videotoolbox_metallib_data
char ff_vf_yadif_videotoolbox_metallib_data[]
YADIFContext::prev
AVFrame * prev
Definition: yadif.h:62
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:220
AV_PIX_FMT_VIDEOTOOLBOX
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
Definition: pixfmt.h:305
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
ff_metal_compute_encoder_dispatch
void ff_metal_compute_encoder_dispatch(id< MTLDevice > device, id< MTLComputePipelineState > pipeline, id< MTLComputeCommandEncoder > encoder, NSUInteger width, NSUInteger height) API_AVAILABLE(macos(10.11)
available
if no frame is available
Definition: filter_design.txt:166
YADIFContext
Definition: yadif.h:51
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
YADIF_DEINT_ALL
@ YADIF_DEINT_ALL
deinterlace all frames
Definition: yadif.h:41
AVHWFramesContext::hwctx
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition: hwcontext.h:150
YADIFContext::next
AVFrame * next
Definition: yadif.h:61
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
YADIF_FIELD_END
@ YADIF_FIELD_END
The first or last field in a sequence.
Definition: yadif.h:47
ff_yadif_request_frame
int ff_yadif_request_frame(AVFilterLink *link)
Definition: yadif_common.c:184
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
CONST
#define CONST(name, help, val, unit)
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
ff_metal_texture_from_pixbuf
CVMetalTextureRef ff_metal_texture_from_pixbuf(void *avclass, CVMetalTextureCacheRef textureCache, CVPixelBufferRef pixbuf, int plane, MTLPixelFormat format) API_AVAILABLE(macos(10.11)
utils.h
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
YADIF_DEINT_INTERLACED
@ YADIF_DEINT_INTERLACED
only deinterlace frames marked as interlaced
Definition: yadif.h:42
YADIF_FIELD_NORMAL
@ YADIF_FIELD_NORMAL
A normal field in the middle of a sequence.
Definition: yadif.h:48
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
YADIF_PARITY_TFF
@ YADIF_PARITY_TFF
top field first
Definition: yadif.h:35
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
ff_yadif_uninit
void ff_yadif_uninit(AVFilterContext *ctx)
Definition: yadif_common.c:258
YADIFContext::current_field
int current_field
YADIFCurrentField.
Definition: yadif.h:88
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:190
hwcontext.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
YADIFContext::cur
AVFrame * cur
Definition: yadif.h:60
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:252
ff_yadif_filter_frame
int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: yadif_common.c:104
FLAGS
#define FLAGS
YADIF_PARITY_BFF
@ YADIF_PARITY_BFF
bottom field first
Definition: yadif.h:36
ff_filter_init_hw_frames
int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link, int default_pool_size)
Perform any additional setup required for hardware frames.
Definition: avfilter.c:1638