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 "internal.h"
23 #include "metal/utils.h"
24 #include "yadif.h"
25 #include "libavutil/avassert.h"
26 #include "libavutil/hwcontext.h"
27 #include "libavutil/objc.h"
28 
29 #include <assert.h>
30 
32 extern unsigned int ff_vf_yadif_videotoolbox_metallib_len;
33 
34 typedef struct API_AVAILABLE(macos(10.11), ios(8.0)) YADIFVTContext {
35  YADIFContext yadif;
36 
37  AVBufferRef *device_ref;
38  AVBufferRef *input_frames_ref;
39  AVHWFramesContext *input_frames;
40 
41  id<MTLDevice> mtlDevice;
42  id<MTLLibrary> mtlLibrary;
43  id<MTLCommandQueue> mtlQueue;
44  id<MTLComputePipelineState> mtlPipeline;
45  id<MTLFunction> mtlFunction;
46  id<MTLBuffer> mtlParamsBuffer;
47 
48  CVMetalTextureCacheRef textureCache;
49 } YADIFVTContext API_AVAILABLE(macos(10.11), ios(8.0));
50 
51 // Using sizeof(YADIFVTContext) outside of an availability check will error
52 // if we're targeting an older OS version, so we need to calculate the size ourselves
53 // (we'll statically verify it's correct in yadif_videotoolbox_init behind a check)
54 #define YADIF_VT_CTX_SIZE (sizeof(YADIFContext) + sizeof(void*) * 10)
55 
56 struct mtlYadifParams {
57  uint channels;
58  uint parity;
59  uint tff;
60  bool is_second_field;
61  bool skip_spatial_check;
62  int field_mode;
63 };
64 
65 static void call_kernel(AVFilterContext *ctx,
66  id<MTLTexture> dst,
67  id<MTLTexture> prev,
68  id<MTLTexture> cur,
69  id<MTLTexture> next,
70  int channels,
71  int parity,
72  int tff) API_AVAILABLE(macos(10.11), ios(8.0))
73 {
74  YADIFVTContext *s = ctx->priv;
75  id<MTLCommandBuffer> buffer = s->mtlQueue.commandBuffer;
76  id<MTLComputeCommandEncoder> encoder = buffer.computeCommandEncoder;
77  struct mtlYadifParams *params = (struct mtlYadifParams *)s->mtlParamsBuffer.contents;
78  *params = (struct mtlYadifParams){
79  .channels = channels,
80  .parity = parity,
81  .tff = tff,
82  .is_second_field = !(parity ^ tff),
83  .skip_spatial_check = s->yadif.mode&2,
84  .field_mode = s->yadif.current_field
85  };
86 
87  [encoder setTexture:dst atIndex:0];
88  [encoder setTexture:prev atIndex:1];
89  [encoder setTexture:cur atIndex:2];
90  [encoder setTexture:next atIndex:3];
91  [encoder setBuffer:s->mtlParamsBuffer offset:0 atIndex:4];
92  ff_metal_compute_encoder_dispatch(s->mtlDevice, s->mtlPipeline, encoder, dst.width, dst.height);
93  [encoder endEncoding];
94 
95  [buffer commit];
96  [buffer waitUntilCompleted];
97 
98  ff_objc_release(&encoder);
100 }
101 
102 static void filter(AVFilterContext *ctx, AVFrame *dst,
103  int parity, int tff) API_AVAILABLE(macos(10.11), ios(8.0))
104 {
105  YADIFVTContext *s = ctx->priv;
106  YADIFContext *y = &s->yadif;
107  int i;
108 
109  for (i = 0; i < y->csp->nb_components; i++) {
110  int pixel_size, channels;
111  const AVComponentDescriptor *comp = &y->csp->comp[i];
112  CVMetalTextureRef prev, cur, next, dest;
113  id<MTLTexture> tex_prev, tex_cur, tex_next, tex_dest;
114  MTLPixelFormat format;
115 
116  if (comp->plane < i) {
117  // We process planes as a whole, so don't reprocess
118  // them for additional components
119  continue;
120  }
121 
122  pixel_size = (comp->depth + comp->shift) / 8;
123  channels = comp->step / pixel_size;
124  if (pixel_size > 2 || channels > 2) {
125  av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", y->csp->name);
126  goto exit;
127  }
128  switch (pixel_size) {
129  case 1:
130  format = channels == 1 ? MTLPixelFormatR8Unorm : MTLPixelFormatRG8Unorm;
131  break;
132  case 2:
133  format = channels == 1 ? MTLPixelFormatR16Unorm : MTLPixelFormatRG16Unorm;
134  break;
135  default:
136  av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", y->csp->name);
137  goto exit;
138  }
140  "Deinterlacing plane %d: pixel_size: %d channels: %d\n",
141  comp->plane, pixel_size, channels);
142 
143  prev = ff_metal_texture_from_pixbuf(ctx, s->textureCache, (CVPixelBufferRef)y->prev->data[3], i, format);
144  cur = ff_metal_texture_from_pixbuf(ctx, s->textureCache, (CVPixelBufferRef)y->cur->data[3], i, format);
145  next = ff_metal_texture_from_pixbuf(ctx, s->textureCache, (CVPixelBufferRef)y->next->data[3], i, format);
146  dest = ff_metal_texture_from_pixbuf(ctx, s->textureCache, (CVPixelBufferRef)dst->data[3], i, format);
147 
148  tex_prev = CVMetalTextureGetTexture(prev);
149  tex_cur = CVMetalTextureGetTexture(cur);
150  tex_next = CVMetalTextureGetTexture(next);
151  tex_dest = CVMetalTextureGetTexture(dest);
152 
153  call_kernel(ctx, tex_dest, tex_prev, tex_cur, tex_next,
154  channels, parity, tff);
155 
156  CFRelease(prev);
157  CFRelease(cur);
158  CFRelease(next);
159  CFRelease(dest);
160  }
161 
162  CVBufferPropagateAttachments((CVPixelBufferRef)y->cur->data[3], (CVPixelBufferRef)dst->data[3]);
163 
164  if (y->current_field == YADIF_FIELD_END) {
166  }
167 
168 exit:
169  return;
170 }
171 
172 static av_cold void do_uninit(AVFilterContext *ctx) API_AVAILABLE(macos(10.11), ios(8.0))
173 {
174  YADIFVTContext *s = ctx->priv;
175  YADIFContext *y = &s->yadif;
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 {
291  AVFilterContext *ctx = inlink->dst;
292  YADIFVTContext *s = ctx->priv;
293 
294  if (!inlink->hw_frames_ctx) {
295  av_log(ctx, AV_LOG_ERROR, "A hardware frames reference is "
296  "required to associate the processing device.\n");
297  return AVERROR(EINVAL);
298  }
299 
300  s->input_frames_ref = av_buffer_ref(inlink->hw_frames_ctx);
301  if (!s->input_frames_ref) {
302  av_log(ctx, AV_LOG_ERROR, "A input frames reference create "
303  "failed.\n");
304  return AVERROR(ENOMEM);
305  }
306  s->input_frames = (AVHWFramesContext*)s->input_frames_ref->data;
307 
308  return 0;
309 }
310 
311 static int config_input(AVFilterLink *inlink)
312 {
313  AVFilterContext *ctx = inlink->dst;
314  if (@available(macOS 10.11, iOS 8.0, *)) {
315  return do_config_input(inlink);
316  } else {
317  av_log(ctx, AV_LOG_ERROR, "Metal is not available on this OS version\n");
318  return AVERROR(ENOSYS);
319  }
320 }
321 
322 static int do_config_output(AVFilterLink *link) API_AVAILABLE(macos(10.11), ios(8.0))
323 {
324  AVHWFramesContext *output_frames;
325  AVFilterContext *ctx = link->src;
326  YADIFVTContext *s = ctx->priv;
327  YADIFContext *y = &s->yadif;
328  int ret = 0;
329 
330  av_assert0(s->input_frames);
331  s->device_ref = av_buffer_ref(s->input_frames->device_ref);
332  if (!s->device_ref) {
333  av_log(ctx, AV_LOG_ERROR, "A device reference create "
334  "failed.\n");
335  return AVERROR(ENOMEM);
336  }
337 
338  link->hw_frames_ctx = av_hwframe_ctx_alloc(s->device_ref);
339  if (!link->hw_frames_ctx) {
340  av_log(ctx, AV_LOG_ERROR, "Failed to create HW frame context "
341  "for output.\n");
342  ret = AVERROR(ENOMEM);
343  goto exit;
344  }
345 
346  output_frames = (AVHWFramesContext*)link->hw_frames_ctx->data;
347 
348  output_frames->format = AV_PIX_FMT_VIDEOTOOLBOX;
349  output_frames->sw_format = s->input_frames->sw_format;
350  output_frames->width = ctx->inputs[0]->w;
351  output_frames->height = ctx->inputs[0]->h;
352 
354  if (ret < 0)
355  goto exit;
356 
358  if (ret < 0) {
359  av_log(ctx, AV_LOG_ERROR, "Failed to initialise VideoToolbox frame "
360  "context for output: %d\n", ret);
361  goto exit;
362  }
363 
365  if (ret < 0)
366  goto exit;
367 
368  y->csp = av_pix_fmt_desc_get(output_frames->sw_format);
369  y->filter = filter;
370 
371 exit:
372  return ret;
373 }
374 
375 static int config_output(AVFilterLink *link)
376 {
377  AVFilterContext *ctx = link->src;
378  if (@available(macOS 10.11, iOS 8.0, *)) {
379  return do_config_output(link);
380  } else {
381  av_log(ctx, AV_LOG_ERROR, "Metal is not available on this OS version\n");
382  return AVERROR(ENOSYS);
383  }
384 }
385 
386 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
387 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
388 
389 static const AVOption yadif_videotoolbox_options[] = {
390  #define OFFSET(x) offsetof(YADIFContext, x)
391  { "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=YADIF_MODE_SEND_FRAME}, 0, 3, FLAGS, .unit = "mode"},
392  CONST("send_frame", "send one frame for each frame", YADIF_MODE_SEND_FRAME, "mode"),
393  CONST("send_field", "send one frame for each field", YADIF_MODE_SEND_FIELD, "mode"),
394  CONST("send_frame_nospatial", "send one frame for each frame, but skip spatial interlacing check", YADIF_MODE_SEND_FRAME_NOSPATIAL, "mode"),
395  CONST("send_field_nospatial", "send one frame for each field, but skip spatial interlacing check", YADIF_MODE_SEND_FIELD_NOSPATIAL, "mode"),
396 
397  { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=YADIF_PARITY_AUTO}, -1, 1, FLAGS, .unit = "parity" },
398  CONST("tff", "assume top field first", YADIF_PARITY_TFF, "parity"),
399  CONST("bff", "assume bottom field first", YADIF_PARITY_BFF, "parity"),
400  CONST("auto", "auto detect parity", YADIF_PARITY_AUTO, "parity"),
401 
402  { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=YADIF_DEINT_ALL}, 0, 1, FLAGS, .unit = "deint" },
403  CONST("all", "deinterlace all frames", YADIF_DEINT_ALL, "deint"),
404  CONST("interlaced", "only deinterlace frames marked as interlaced", YADIF_DEINT_INTERLACED, "deint"),
405  #undef OFFSET
406 
407  { NULL }
408 };
409 
410 AVFILTER_DEFINE_CLASS(yadif_videotoolbox);
411 
412 static const AVFilterPad yadif_videotoolbox_inputs[] = {
413  {
414  .name = "default",
415  .type = AVMEDIA_TYPE_VIDEO,
416  .filter_frame = ff_yadif_filter_frame,
417  .config_props = config_input,
418  },
419 };
420 
421 static const AVFilterPad yadif_videotoolbox_outputs[] = {
422  {
423  .name = "default",
424  .type = AVMEDIA_TYPE_VIDEO,
425  .request_frame = ff_yadif_request_frame,
426  .config_props = config_output,
427  },
428 };
429 
431  .name = "yadif_videotoolbox",
432  .description = NULL_IF_CONFIG_SMALL("YADIF for VideoToolbox frames using Metal compute"),
433  .priv_size = YADIF_VT_CTX_SIZE,
434  .priv_class = &yadif_videotoolbox_class,
435  .init = yadif_videotoolbox_init,
436  .uninit = yadif_videotoolbox_uninit,
438  FILTER_INPUTS(yadif_videotoolbox_inputs),
439  FILTER_OUTPUTS(yadif_videotoolbox_outputs),
441  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
442 };
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
ios
void ios(8.0))
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: internal.h:351
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:2965
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
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
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:357
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:170
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:395
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:186
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: internal.h:33
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:206
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:55
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
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
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
utils.h
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
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:120
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
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)
OFFSET
#define OFFSET(x)
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
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_aap.c:191
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:191
internal.h
AVFILTER_DEFINE_CLASS
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:323
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:172
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
available
if no frame is available
Definition: filter_design.txt:166
YADIFContext
Definition: yadif.h:51
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
AVFilter
Filter definition.
Definition: avfilter.h:166
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
AVFrame::hw_frames_ctx
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
Definition: frame.h:725
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
mode
mode
Definition: ebur128.h:83
ff_yadif_request_frame
int ff_yadif_request_frame(AVFilterLink *link)
Definition: yadif_common.c:184
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:245
CONST
#define CONST(name, help, val, unit)
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
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:256
YADIFContext::current_field
int current_field
YADIFCurrentField.
Definition: yadif.h:88
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
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:155
hwcontext.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
YADIFContext::cur
AVFrame * cur
Definition: yadif.h:60
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)
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:1613