FFmpeg
vf_nnedi.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2011 Kevin Stone
3  * Copyright (C) 2016 Paul B Mahol
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (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
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #include <float.h>
23 
24 #include "libavutil/common.h"
25 #include "libavutil/float_dsp.h"
26 #include "libavutil/imgutils.h"
27 #include "libavutil/mem_internal.h"
28 #include "libavutil/opt.h"
29 #include "libavutil/pixdesc.h"
30 #include "avfilter.h"
31 #include "formats.h"
32 #include "internal.h"
33 #include "video.h"
34 
35 static const size_t NNEDI_WEIGHTS_SIZE = 13574928;
36 static const uint8_t NNEDI_XDIM[] = { 8, 16, 32, 48, 8, 16, 32 };
37 static const uint8_t NNEDI_YDIM[] = { 6, 6, 6, 6, 4, 4, 4 };
38 static const uint16_t NNEDI_NNS[] = { 16, 32, 64, 128, 256 };
39 
40 typedef struct PrescreenerCoefficients {
41  DECLARE_ALIGNED(32, float, kernel_l0)[4][16 * 4];
42  DECLARE_ALIGNED(32, float, bias_l0)[4];
43 
44  DECLARE_ALIGNED(32, float, kernel_l1)[4][4];
45  DECLARE_ALIGNED(32, float, bias_l1)[4];
46 
47  DECLARE_ALIGNED(32, float, kernel_l2)[4][8];
48  DECLARE_ALIGNED(32, float, bias_l2)[4];
50 
51 typedef struct PredictorCoefficients {
52  int xdim, ydim, nns, nsize;
53  float *data;
54  float *softmax_q1;
55  float *elliott_q1;
58  float *softmax_q2;
59  float *elliott_q2;
63 
64 typedef struct NNEDIContext {
65  const AVClass *class;
66 
67  char *weights_file;
68 
70  int eof;
71  int64_t pts;
72 
74  int depth;
75  int nb_planes;
77  int linesize[4];
78  int planewidth[4];
79  int planeheight[4];
80  int field_n;
81 
84 
85  float half;
86  float in_scale;
87  float out_scale;
88 
89  // Parameters
90  int deint;
91  int field;
93  int nsize;
94  int nnsparam;
95  int qual;
96  int etype;
97  int pscrn;
98 
100  uint8_t **prescreen_buf;
101  float **input_buf;
102  float **output_buf;
103 
104  void (*read)(const uint8_t *src, float *dst,
105  int src_stride, int dst_stride,
106  int width, int height, float scale);
107  void (*write)(const float *src, uint8_t *dst,
108  int src_stride, int dst_stride,
109  int width, int height, int depth, float scale);
111  const void *src, ptrdiff_t src_stride,
112  uint8_t *prescreen, int N,
113  const PrescreenerCoefficients *const coeffs);
114 } NNEDIContext;
115 
116 #define OFFSET(x) offsetof(NNEDIContext, x)
117 #define RFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
118 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
119 
120 static const AVOption nnedi_options[] = {
121  {"weights", "set weights file", OFFSET(weights_file), AV_OPT_TYPE_STRING, {.str="nnedi3_weights.bin"}, 0, 0, FLAGS },
122  {"deint", "set which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, RFLAGS, "deint" },
123  {"all", "deinterlace all frames", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "deint" },
124  {"interlaced", "only deinterlace frames marked as interlaced", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "deint" },
125  {"field", "set mode of operation", OFFSET(field), AV_OPT_TYPE_INT, {.i64=-1}, -2, 3, RFLAGS, "field" },
126  {"af", "use frame flags, both fields", 0, AV_OPT_TYPE_CONST, {.i64=-2}, 0, 0, RFLAGS, "field" },
127  {"a", "use frame flags, single field", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, RFLAGS, "field" },
128  {"t", "use top field only", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "field" },
129  {"b", "use bottom field only", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "field" },
130  {"tf", "use both fields, top first", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, RFLAGS, "field" },
131  {"bf", "use both fields, bottom first", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, RFLAGS, "field" },
132  {"planes", "set which planes to process", OFFSET(process_plane), AV_OPT_TYPE_INT, {.i64=7}, 0, 15, RFLAGS },
133  {"nsize", "set size of local neighborhood around each pixel, used by the predictor neural network", OFFSET(nsize), AV_OPT_TYPE_INT, {.i64=6}, 0, 6, RFLAGS, "nsize" },
134  {"s8x6", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "nsize" },
135  {"s16x6", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "nsize" },
136  {"s32x6", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, RFLAGS, "nsize" },
137  {"s48x6", NULL, 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, RFLAGS, "nsize" },
138  {"s8x4", NULL, 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, RFLAGS, "nsize" },
139  {"s16x4", NULL, 0, AV_OPT_TYPE_CONST, {.i64=5}, 0, 0, RFLAGS, "nsize" },
140  {"s32x4", NULL, 0, AV_OPT_TYPE_CONST, {.i64=6}, 0, 0, RFLAGS, "nsize" },
141  {"nns", "set number of neurons in predictor neural network", OFFSET(nnsparam), AV_OPT_TYPE_INT, {.i64=1}, 0, 4, RFLAGS, "nns" },
142  {"n16", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "nns" },
143  {"n32", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "nns" },
144  {"n64", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, RFLAGS, "nns" },
145  {"n128", NULL, 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, RFLAGS, "nns" },
146  {"n256", NULL, 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, RFLAGS, "nns" },
147  {"qual", "set quality", OFFSET(qual), AV_OPT_TYPE_INT, {.i64=1}, 1, 2, RFLAGS, "qual" },
148  {"fast", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "qual" },
149  {"slow", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, RFLAGS, "qual" },
150  {"etype", "set which set of weights to use in the predictor", OFFSET(etype), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, RFLAGS, "etype" },
151  {"a", "weights trained to minimize absolute error", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "etype" },
152  {"abs","weights trained to minimize absolute error", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "etype" },
153  {"s", "weights trained to minimize squared error", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "etype" },
154  {"mse","weights trained to minimize squared error", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "etype" },
155  {"pscrn", "set prescreening", OFFSET(pscrn), AV_OPT_TYPE_INT, {.i64=2}, 0, 4, RFLAGS, "pscrn" },
156  {"none", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, RFLAGS, "pscrn" },
157  {"original", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, RFLAGS, "pscrn" },
158  {"new", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, RFLAGS, "pscrn" },
159  {"new2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, RFLAGS, "pscrn" },
160  {"new3", NULL, 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, RFLAGS, "pscrn" },
161  { NULL }
162 };
163 
164 AVFILTER_DEFINE_CLASS(nnedi);
165 
166 static int config_output(AVFilterLink *outlink)
167 {
168  AVFilterContext *ctx = outlink->src;
169 
170  outlink->time_base = av_mul_q(ctx->inputs[0]->time_base, (AVRational){1, 2});
171  outlink->w = ctx->inputs[0]->w;
172  outlink->h = ctx->inputs[0]->h;
173 
174  outlink->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate,
175  (AVRational){2, 1});
176 
177  return 0;
178 }
179 
180 static const enum AVPixelFormat pix_fmts[] = {
204 };
205 
206 static float dot_dsp(const NNEDIContext *const s, const float *kernel, const float *input,
207  int n, float scale, float bias)
208 {
209  float sum, y;
210 
211  sum = s->fdsp->scalarproduct_float(kernel, input, n);
212 
213  y = sum * scale + bias + 1e-20f;
214 
215  return y;
216 }
217 
218 static float elliott(float x)
219 {
220  return x / (1.0f + fabsf(x));
221 }
222 
223 static void transform_elliott(float *input, int size)
224 {
225  for (int i = 0; i < size; i++)
226  input[i] = elliott(input[i]);
227 }
228 
230  const void *src, ptrdiff_t src_stride,
231  uint8_t *prescreen, int N,
232  const PrescreenerCoefficients *const m_data)
233 {
234  NNEDIContext *s = ctx->priv;
235  const float *src_p = src;
236 
237  // Adjust source pointer to point to top-left of filter window.
238  const float *window = src_p - 2 * src_stride - 5;
239 
240  for (int j = 0; j < N; j++) {
241  LOCAL_ALIGNED_32(float, input, [48]);
242  float state[12];
243 
244  for (int i = 0; i < 4; i++)
245  memcpy(input + i * 12, window + i * src_stride + j, 12 * sizeof(float));
246 
247  // Layer 0.
248  for (int n = 0; n < 4; n++)
249  state[n] = dot_dsp(s, m_data->kernel_l0[n], input, 48, 1.0f, m_data->bias_l0[n]);
250  transform_elliott(state + 1, 3);
251 
252  // Layer 1.
253  for (int n = 0; n < 4; n++)
254  state[n + 4] = dot_dsp(s, m_data->kernel_l1[n], state, 4, 1.0f, m_data->bias_l1[n]);
255  transform_elliott(state + 4, 3);
256 
257  // Layer 2.
258  for (int n = 0; n < 4; n++)
259  state[n + 8] = dot_dsp(s, m_data->kernel_l2[n], state, 8, 1.0f, m_data->bias_l2[n]);
260 
261  prescreen[j] = FFMAX(state[10], state[11]) <= FFMAX(state[8], state[9]) ? 255 : 0;
262  }
263 }
264 
266  const void *src, ptrdiff_t src_stride,
267  uint8_t *prescreen, int N,
268  const PrescreenerCoefficients *const m_data)
269 {
270  NNEDIContext *s = ctx->priv;
271  const float *src_p = src;
272 
273  // Adjust source pointer to point to top-left of filter window.
274  const float *window = src_p - 2 * src_stride - 6;
275 
276  for (int j = 0; j < N; j += 4) {
277  LOCAL_ALIGNED_32(float, input, [64]);
278  float state[8];
279 
280  for (int i = 0; i < 4; i++)
281  memcpy(input + i * 16, window + i * src_stride + j, 16 * sizeof(float));
282 
283  for (int n = 0; n < 4; n++)
284  state[n] = dot_dsp(s, m_data->kernel_l0[n], input, 64, 1.0f, m_data->bias_l0[n]);
286 
287  for (int n = 0; n < 4; n++)
288  state[n + 4] = dot_dsp(s, m_data->kernel_l1[n], state, 4, 1.0f, m_data->bias_l1[n]);
289 
290  for (int n = 0; n < 4; n++)
291  prescreen[j + n] = state[n + 4] > 0.f;
292  }
293 }
294 
295 static int filter_offset(int nn, const PredictorCoefficients *const model)
296 {
297  return nn * model->nsize;
298 }
299 
300 static const float *softmax_q1_filter(int nn,
301  const PredictorCoefficients *const model)
302 {
303  return model->softmax_q1 + filter_offset(nn, model);
304 }
305 
306 static const float *elliott_q1_filter(int nn,
307  const PredictorCoefficients *const model)
308 {
309  return model->elliott_q1 + filter_offset(nn, model);
310 }
311 
312 static const float *softmax_q2_filter(int nn,
313  const PredictorCoefficients *const model)
314 {
315  return model->softmax_q2 + filter_offset(nn, model);
316 }
317 
318 static const float *elliott_q2_filter(int nn,
319  const PredictorCoefficients *const model)
320 {
321  return model->elliott_q2 + filter_offset(nn, model);
322 }
323 
324 static void gather_input(const float *src, ptrdiff_t src_stride,
325  float *buf, float mstd[4],
326  const PredictorCoefficients *const model)
327 {
328  const float scale = 1.f / model->nsize;
329  float sum = 0.f;
330  float sum_sq = 0.f;
331  float tmp;
332 
333  for (int i = 0; i < model->ydim; i++) {
334  memcpy(buf, src, model->xdim * sizeof(float));
335 
336  for (int j = 0; j < model->xdim; j++) {
337  const float val = src[j];
338 
339  sum += val;
340  sum_sq += val * val;
341  }
342 
343  src += src_stride;
344  buf += model->xdim;
345  }
346 
347  mstd[0] = sum * scale;
348  mstd[3] = 0.f;
349 
350  tmp = sum_sq * scale - mstd[0] * mstd[0];
351  if (tmp < FLT_EPSILON) {
352  mstd[1] = 0.0f;
353  mstd[2] = 0.0f;
354  } else {
355  mstd[1] = sqrtf(tmp);
356  mstd[2] = 1.0f / mstd[1];
357  }
358 }
359 
360 static float softmax_exp(float x)
361 {
362  return expf(av_clipf(x, -80.f, 80.f));
363 }
364 
365 static void transform_softmax_exp(float *input, int size)
366 {
367  for (int i = 0; i < size; i++)
368  input[i] = softmax_exp(input[i]);
369 }
370 
371 static void wae5(const float *softmax, const float *el,
372  int n, float mstd[4])
373 {
374  float vsum = 0.0f, wsum = 0.0f;
375 
376  for (int i = 0; i < n; i++) {
377  vsum += softmax[i] * elliott(el[i]);
378  wsum += softmax[i];
379  }
380 
381  if (wsum > 1e-10f)
382  mstd[3] += (5.0f * vsum) / wsum * mstd[1] + mstd[0];
383  else
384  mstd[3] += mstd[0];
385 }
386 
388  const void *src, ptrdiff_t src_stride, void *dst,
389  const uint8_t *prescreen, int N,
390  const PredictorCoefficients *const model, int use_q2)
391 {
392  const NNEDIContext *const s = ctx->priv;
393  const float *src_p = src;
394  float *dst_p = dst;
395 
396  // Adjust source pointer to point to top-left of filter window.
397  const float *window = src_p - (model->ydim / 2) * src_stride - (model->xdim / 2 - 1);
398  const int filter_size = model->nsize;
399  const int nns = model->nns;
400 
401  for (int i = 0; i < N; i++) {
402  LOCAL_ALIGNED_32(float, input, [48 * 6]);
403  float activation[256 * 2];
404  float mstd[4];
405  float scale;
406 
407  if (prescreen[i])
408  continue;
409 
410  gather_input(window + i, src_stride, input, mstd, model);
411  scale = mstd[2];
412 
413  for (int nn = 0; nn < nns; nn++)
414  activation[nn] = dot_dsp(s, softmax_q1_filter(nn, model), input, filter_size, scale, model->softmax_bias_q1[nn]);
415 
416  for (int nn = 0; nn < nns; nn++)
417  activation[nns + nn] = dot_dsp(s, elliott_q1_filter(nn, model), input, filter_size, scale, model->elliott_bias_q1[nn]);
418 
419  transform_softmax_exp(activation, nns);
420  wae5(activation, activation + nns, nns, mstd);
421 
422  if (use_q2) {
423  for (int nn = 0; nn < nns; nn++)
424  activation[nn] = dot_dsp(s, softmax_q2_filter(nn, model), input, filter_size, scale, model->softmax_bias_q2[nn]);
425 
426  for (int nn = 0; nn < nns; nn++)
427  activation[nns + nn] = dot_dsp(s, elliott_q2_filter(nn, model), input, filter_size, scale, model->elliott_bias_q2[nn]);
428 
429  transform_softmax_exp(activation, nns);
430  wae5(activation, activation + nns, nns, mstd);
431  }
432 
433  dst_p[i] = mstd[3] * (use_q2 ? 0.5f : 1.f);
434  }
435 }
436 
437 static void read_bytes(const uint8_t *src, float *dst,
438  int src_stride, int dst_stride,
439  int width, int height, float scale)
440 {
441  for (int y = 0; y < height; y++) {
442  for (int x = 0; x < 32; x++)
443  dst[-x - 1] = src[x];
444 
445  for (int x = 0; x < width; x++)
446  dst[x] = src[x];
447 
448  for (int x = 0; x < 32; x++)
449  dst[width + x] = src[width - x - 1];
450 
451  dst += dst_stride;
452  src += src_stride;
453  }
454 }
455 
456 static void read_words(const uint8_t *srcp, float *dst,
457  int src_stride, int dst_stride,
458  int width, int height, float scale)
459 {
460  const uint16_t *src = (const uint16_t *)srcp;
461 
462  src_stride /= 2;
463 
464  for (int y = 0; y < height; y++) {
465  for (int x = 0; x < 32; x++)
466  dst[-x - 1] = src[x] * scale;
467 
468  for (int x = 0; x < width; x++)
469  dst[x] = src[x] * scale;
470 
471  for (int x = 0; x < 32; x++)
472  dst[width + x] = src[width - x - 1] * scale;
473 
474  dst += dst_stride;
475  src += src_stride;
476  }
477 }
478 
479 static void write_bytes(const float *src, uint8_t *dst,
480  int src_stride, int dst_stride,
481  int width, int height, int depth,
482  float scale)
483 {
484  for (int y = 0; y < height; y++) {
485  for (int x = 0; x < width; x++)
486  dst[x] = av_clip_uint8(src[x]);
487 
488  dst += dst_stride;
489  src += src_stride;
490  }
491 }
492 
493 static void write_words(const float *src, uint8_t *dstp,
494  int src_stride, int dst_stride,
495  int width, int height, int depth,
496  float scale)
497 {
498  uint16_t *dst = (uint16_t *)dstp;
499 
500  dst_stride /= 2;
501 
502  for (int y = 0; y < height; y++) {
503  for (int x = 0; x < width; x++)
504  dst[x] = av_clip_uintp2_c(src[x] * scale, depth);
505 
506  dst += dst_stride;
507  src += src_stride;
508  }
509 }
510 
511 static void interpolation(const void *src, ptrdiff_t src_stride,
512  void *dst, const uint8_t *prescreen, int n)
513 {
514  const float *src_p = src;
515  float *dst_p = dst;
516  const float *window = src_p - 2 * src_stride;
517 
518  for (int i = 0; i < n; i++) {
519  float accum = 0.0f;
520 
521  if (!prescreen[i])
522  continue;
523 
524  accum += (-3.0f / 32.0f) * window[0 * src_stride + i];
525  accum += (19.0f / 32.0f) * window[1 * src_stride + i];
526  accum += (19.0f / 32.0f) * window[2 * src_stride + i];
527  accum += (-3.0f / 32.0f) * window[3 * src_stride + i];
528 
529  dst_p[i] = accum;
530  }
531 }
532 
533 static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
534 {
535  const NNEDIContext *const s = ctx->priv;
536  AVFrame *out = arg;
537  AVFrame *in = s->prev;
538  const float in_scale = s->in_scale;
539  const float out_scale = s->out_scale;
540  const int depth = s->depth;
541  const int interlaced = in->interlaced_frame;
542  const int tff = s->field_n == (s->field < 0 ? interlaced ? in->top_field_first : 1 :
543  (s->field & 1) ^ 1);
544 
545 
546  for (int p = 0; p < s->nb_planes; p++) {
547  const int height = s->planeheight[p];
548  const int width = s->planewidth[p];
549  const int slice_start = 2 * ((height / 2 * jobnr) / nb_jobs);
550  const int slice_end = 2 * ((height / 2 * (jobnr+1)) / nb_jobs);
551  const uint8_t *src_data = in->data[p];
552  uint8_t *dst_data = out->data[p];
553  uint8_t *dst = out->data[p] + slice_start * out->linesize[p];
554  const int src_linesize = in->linesize[p];
555  const int dst_linesize = out->linesize[p];
556  uint8_t *prescreen_buf = s->prescreen_buf[jobnr];
557  float *srcbuf = s->input_buf[jobnr];
558  const int srcbuf_stride = width + 64;
559  float *dstbuf = s->output_buf[jobnr];
560  const int dstbuf_stride = width;
561  const int slice_height = (slice_end - slice_start) / 2;
562  const int last_slice = slice_end == height;
563  const uint8_t *in_line;
564  uint8_t *out_line;
565  int y_out;
566 
567  if (!(s->process_plane & (1 << p))) {
568  av_image_copy_plane(dst, out->linesize[p],
569  in->data[p] + slice_start * in->linesize[p],
570  in->linesize[p],
571  s->linesize[p], slice_end - slice_start);
572  continue;
573  }
574 
575  y_out = slice_start + (tff ^ (slice_start & 1));
576  in_line = src_data + (y_out * src_linesize);
577  out_line = dst_data + (y_out * dst_linesize);
578 
579  while (y_out < slice_end) {
580  memcpy(out_line, in_line, s->linesize[p]);
581  y_out += 2;
582  in_line += src_linesize * 2;
583  out_line += dst_linesize * 2;
584  }
585 
586  y_out = slice_start + ((!tff) ^ (slice_start & 1));
587 
588  s->read(src_data + FFMAX(y_out - 5, tff) * src_linesize,
589  srcbuf + 32,
590  src_linesize * 2, srcbuf_stride,
591  width, 1, in_scale);
592  srcbuf += srcbuf_stride;
593 
594  s->read(src_data + FFMAX(y_out - 3, tff) * src_linesize,
595  srcbuf + 32,
596  src_linesize * 2, srcbuf_stride,
597  width, 1, in_scale);
598  srcbuf += srcbuf_stride;
599 
600  s->read(src_data + FFMAX(y_out - 1, tff) * src_linesize,
601  srcbuf + 32,
602  src_linesize * 2, srcbuf_stride,
603  width, 1, in_scale);
604  srcbuf += srcbuf_stride;
605 
606  in_line = src_data + FFMIN(y_out + 1, height - 1 - !tff) * src_linesize;
607  out_line = dst_data + (y_out * dst_linesize);
608 
609  s->read(in_line, srcbuf + 32, src_linesize * 2, srcbuf_stride,
610  width, slice_height - last_slice, in_scale);
611 
612  y_out += (slice_height - last_slice) * 2;
613 
614  s->read(src_data + FFMIN(y_out + 1, height - 1 - !tff) * src_linesize,
615  srcbuf + 32 + srcbuf_stride * (slice_height - last_slice),
616  src_linesize * 2, srcbuf_stride,
617  width, 1, in_scale);
618 
619  s->read(src_data + FFMIN(y_out + 3, height - 1 - !tff) * src_linesize,
620  srcbuf + 32 + srcbuf_stride * (slice_height + 1 - last_slice),
621  src_linesize * 2, srcbuf_stride,
622  width, 1, in_scale);
623 
624  s->read(src_data + FFMIN(y_out + 5, height - 1 - !tff) * src_linesize,
625  srcbuf + 32 + srcbuf_stride * (slice_height + 2 - last_slice),
626  src_linesize * 2, srcbuf_stride,
627  width, 1, in_scale);
628 
629  for (int y = 0; y < slice_end - slice_start; y += 2) {
630  if (s->pscrn > 0)
631  s->prescreen[s->pscrn > 1](ctx, srcbuf + (y / 2) * srcbuf_stride + 32,
632  srcbuf_stride, prescreen_buf, width,
633  &s->prescreener[s->pscrn - 1]);
634 
635  predictor(ctx,
636  srcbuf + (y / 2) * srcbuf_stride + 32,
637  srcbuf_stride,
638  dstbuf + (y / 2) * dstbuf_stride,
639  prescreen_buf, width,
640  &s->coeffs[s->etype][s->nnsparam][s->nsize], s->qual == 2);
641 
642  if (s->pscrn > 0)
643  interpolation(srcbuf + (y / 2) * srcbuf_stride + 32,
644  srcbuf_stride,
645  dstbuf + (y / 2) * dstbuf_stride,
646  prescreen_buf, width);
647  }
648 
649  s->write(dstbuf, out_line, dstbuf_stride, dst_linesize * 2,
650  width, slice_height, depth, out_scale);
651  }
652 
653  return 0;
654 }
655 
656 static int get_frame(AVFilterContext *ctx, int is_second)
657 {
658  NNEDIContext *s = ctx->priv;
659  AVFilterLink *outlink = ctx->outputs[0];
660  AVFrame *dst;
661 
662  dst = ff_get_video_buffer(outlink, outlink->w, outlink->h);
663  if (!dst)
664  return AVERROR(ENOMEM);
665  av_frame_copy_props(dst, s->prev);
666  dst->interlaced_frame = 0;
667  dst->pts = s->pts;
668 
670  FFMIN(s->planeheight[1] / 2, s->nb_threads));
671 
672  if (s->field == -2 || s->field > 1)
673  s->field_n = !s->field_n;
674 
675  return ff_filter_frame(outlink, dst);
676 }
677 
679 {
680  AVFilterContext *ctx = inlink->dst;
681  NNEDIContext *s = ctx->priv;
682  int ret;
683 
684  if (!s->prev) {
685  s->prev = in;
686  return 0;
687  }
688 
689  if ((s->deint && !s->prev->interlaced_frame) || ctx->is_disabled) {
690  s->prev->pts *= 2;
691  ret = ff_filter_frame(ctx->outputs[0], s->prev);
692  s->prev = in;
693  return ret;
694  }
695 
696  s->pts = s->prev->pts * 2;
697  ret = get_frame(ctx, 0);
698  if (ret < 0 || (s->field > -2 && s->field < 2)) {
699  av_frame_free(&s->prev);
700  s->prev = in;
701  return ret;
702  }
703 
704  s->pts = s->prev->pts + in->pts;
705  ret = get_frame(ctx, 1);
706  av_frame_free(&s->prev);
707  s->prev = in;
708  return ret;
709 }
710 
712 {
713  AVFilterContext *ctx = link->src;
714  NNEDIContext *s = ctx->priv;
715  int ret;
716 
717  if (s->eof)
718  return AVERROR_EOF;
719 
720  ret = ff_request_frame(ctx->inputs[0]);
721 
722  if (ret == AVERROR_EOF && s->prev) {
723  AVFrame *next = av_frame_clone(s->prev);
724 
725  if (!next)
726  return AVERROR(ENOMEM);
727 
728  next->pts = s->prev->pts + av_rescale_q(1, av_inv_q(ctx->outputs[0]->frame_rate),
729  ctx->outputs[0]->time_base);
730  s->eof = 1;
731 
732  ret = filter_frame(ctx->inputs[0], next);
733  } else if (ret < 0) {
734  return ret;
735  }
736 
737  return ret;
738 }
739 
740 static void copy_weights(float *dst, int n, const float **data)
741 {
742  memcpy(dst, *data, n * sizeof(float));
743  *data += n;
744 }
745 
746 static float *allocate(float **ptr, int size)
747 {
748  float *ret = *ptr;
749 
750  *ptr += size;
751 
752  return ret;
753 }
754 
755 static int allocate_model(PredictorCoefficients *coeffs, int xdim, int ydim, int nns)
756 {
757  int filter_size = nns * xdim * ydim;
758  int bias_size = nns;
759  float *data;
760 
761  data = av_calloc(filter_size + bias_size, 4 * sizeof(float));
762  if (!data)
763  return AVERROR(ENOMEM);
764 
765  coeffs->data = data;
766  coeffs->xdim = xdim;
767  coeffs->ydim = ydim;
768  coeffs->nsize = xdim * ydim;
769  coeffs->nns = nns;
770 
771  coeffs->softmax_q1 = allocate(&data, filter_size);
772  coeffs->elliott_q1 = allocate(&data, filter_size);
773  coeffs->softmax_bias_q1 = allocate(&data, bias_size);
774  coeffs->elliott_bias_q1 = allocate(&data, bias_size);
775 
776  coeffs->softmax_q2 = allocate(&data, filter_size);
777  coeffs->elliott_q2 = allocate(&data, filter_size);
778  coeffs->softmax_bias_q2 = allocate(&data, bias_size);
779  coeffs->elliott_bias_q2 = allocate(&data, bias_size);
780 
781  return 0;
782 }
783 
784 static int read_weights(AVFilterContext *ctx, const float *bdata)
785 {
786  NNEDIContext *s = ctx->priv;
787  int ret;
788 
789  copy_weights(&s->prescreener[0].kernel_l0[0][0], 4 * 48, &bdata);
790  copy_weights(s->prescreener[0].bias_l0, 4, &bdata);
791 
792  copy_weights(&s->prescreener[0].kernel_l1[0][0], 4 * 4, &bdata);
793  copy_weights(s->prescreener[0].bias_l1, 4, &bdata);
794 
795  copy_weights(&s->prescreener[0].kernel_l2[0][0], 4 * 8, &bdata);
796  copy_weights(s->prescreener[0].bias_l2, 4, &bdata);
797 
798  for (int i = 0; i < 3; i++) {
799  PrescreenerCoefficients *data = &s->prescreener[i + 1];
800  float kernel_l0_shuffled[4 * 64];
801  float kernel_l1_shuffled[4 * 4];
802 
803  copy_weights(kernel_l0_shuffled, 4 * 64, &bdata);
804  copy_weights(data->bias_l0, 4, &bdata);
805 
806  copy_weights(kernel_l1_shuffled, 4 * 4, &bdata);
807  copy_weights(data->bias_l1, 4, &bdata);
808 
809  for (int n = 0; n < 4; n++) {
810  for (int k = 0; k < 64; k++)
811  data->kernel_l0[n][k] = kernel_l0_shuffled[(k / 8) * 32 + n * 8 + k % 8];
812  for (int k = 0; k < 4; k++)
813  data->kernel_l1[n][k] = kernel_l1_shuffled[k * 4 + n];
814  }
815  }
816 
817  for (int m = 0; m < 2; m++) {
818  // Grouping by neuron count.
819  for (int i = 0; i < 5; i++) {
820  const int nns = NNEDI_NNS[i];
821 
822  // Grouping by window size.
823  for (int j = 0; j < 7; j++) {
824  PredictorCoefficients *model = &s->coeffs[m][i][j];
825  const int xdim = NNEDI_XDIM[j];
826  const int ydim = NNEDI_YDIM[j];
827  const int filter_size = xdim * ydim;
828 
829  ret = allocate_model(model, xdim, ydim, nns);
830  if (ret < 0)
831  return ret;
832 
833  // Quality 1 model. NNS[i] * (XDIM[j] * YDIM[j]) * 2 coefficients.
834  copy_weights(model->softmax_q1, nns * filter_size, &bdata);
835  copy_weights(model->elliott_q1, nns * filter_size, &bdata);
836 
837  // Quality 1 model bias. NNS[i] * 2 coefficients.
838  copy_weights(model->softmax_bias_q1, nns, &bdata);
839  copy_weights(model->elliott_bias_q1, nns, &bdata);
840 
841  // Quality 2 model. NNS[i] * (XDIM[j] * YDIM[j]) * 2 coefficients.
842  copy_weights(model->softmax_q2, nns * filter_size, &bdata);
843  copy_weights(model->elliott_q2, nns * filter_size, &bdata);
844 
845  // Quality 2 model bias. NNS[i] * 2 coefficients.
846  copy_weights(model->softmax_bias_q2, nns, &bdata);
847  copy_weights(model->elliott_bias_q2, nns, &bdata);
848  }
849  }
850  }
851 
852  return 0;
853 }
854 
855 static float mean(const float *input, int size)
856 {
857  float sum = 0.f;
858 
859  for (int i = 0; i < size; i++)
860  sum += input[i];
861 
862  return sum / size;
863 }
864 
865 static void transform(float *input, int size, float mean, float half)
866 {
867  for (int i = 0; i < size; i++)
868  input[i] = (input[i] - mean) / half;
869 }
870 
871 static void subtract_mean_old(PrescreenerCoefficients *coeffs, float half)
872 {
873  for (int n = 0; n < 4; n++) {
874  float m = mean(coeffs->kernel_l0[n], 48);
875 
876  transform(coeffs->kernel_l0[n], 48, m, half);
877  }
878 }
879 
880 static void subtract_mean_new(PrescreenerCoefficients *coeffs, float half)
881 {
882  for (int n = 0; n < 4; n++) {
883  float m = mean(coeffs->kernel_l0[n], 64);
884 
885  transform(coeffs->kernel_l0[n], 64, m, half);
886  }
887 }
888 
890 {
891  const int filter_size = model->nsize;
892  const int nns = model->nns;
893  const float scale = 1.f / nns;
894 
895  double softmax_means[256]; // Average of individual softmax filters.
896  double elliott_means[256]; // Average of individual elliott filters.
897  double mean_filter[48 * 6] = { 0 }; // Pointwise average of all softmax filters.
898  double mean_bias;
899 
900  // Quality 1.
901  for (int nn = 0; nn < nns; nn++) {
902  softmax_means[nn] = mean(model->softmax_q1 + nn * filter_size, filter_size);
903  elliott_means[nn] = mean(model->elliott_q1 + nn * filter_size, filter_size);
904 
905  for (int k = 0; k < filter_size; k++)
906  mean_filter[k] += model->softmax_q1[nn * filter_size + k] - softmax_means[nn];
907  }
908 
909  for (int k = 0; k < filter_size; k++)
910  mean_filter[k] *= scale;
911 
912  mean_bias = mean(model->softmax_bias_q1, nns);
913 
914  for (int nn = 0; nn < nns; nn++) {
915  for (int k = 0; k < filter_size; k++) {
916  model->softmax_q1[nn * filter_size + k] -= softmax_means[nn] + mean_filter[k];
917  model->elliott_q1[nn * filter_size + k] -= elliott_means[nn];
918  }
919  model->softmax_bias_q1[nn] -= mean_bias;
920  }
921 
922  // Quality 2.
923  memset(mean_filter, 0, sizeof(mean_filter));
924 
925  for (int nn = 0; nn < nns; nn++) {
926  softmax_means[nn] = mean(model->softmax_q2 + nn * filter_size, filter_size);
927  elliott_means[nn] = mean(model->elliott_q2 + nn * filter_size, filter_size);
928 
929  for (int k = 0; k < filter_size; k++) {
930  mean_filter[k] += model->softmax_q2[nn * filter_size + k] - softmax_means[nn];
931  }
932  }
933 
934  for (int k = 0; k < filter_size; k++)
935  mean_filter[k] *= scale;
936 
937  mean_bias = mean(model->softmax_bias_q2, nns);
938 
939  for (int nn = 0; nn < nns; nn++) {
940  for (int k = 0; k < filter_size; k++) {
941  model->softmax_q2[nn * filter_size + k] -= softmax_means[nn] + mean_filter[k];
942  model->elliott_q2[nn * filter_size + k] -= elliott_means[nn];
943  }
944 
945  model->softmax_bias_q2[nn] -= mean_bias;
946  }
947 }
948 
950 {
951  NNEDIContext *s = ctx->priv;
952  FILE *weights_file = NULL;
953  int64_t weights_size;
954  float *bdata;
955  size_t bytes_read;
956  int ret = 0;
957 
958  weights_file = av_fopen_utf8(s->weights_file, "rb");
959  if (!weights_file) {
960  av_log(ctx, AV_LOG_ERROR, "No weights file provided, aborting!\n");
961  return AVERROR(EINVAL);
962  }
963 
964  if (fseek(weights_file, 0, SEEK_END)) {
965  av_log(ctx, AV_LOG_ERROR, "Couldn't seek to the end of weights file.\n");
966  fclose(weights_file);
967  return AVERROR(EINVAL);
968  }
969 
970  weights_size = ftell(weights_file);
971 
972  if (weights_size == -1) {
973  fclose(weights_file);
974  av_log(ctx, AV_LOG_ERROR, "Couldn't get size of weights file.\n");
975  return AVERROR(EINVAL);
976  } else if (weights_size != NNEDI_WEIGHTS_SIZE) {
977  fclose(weights_file);
978  av_log(ctx, AV_LOG_ERROR, "Unexpected weights file size.\n");
979  return AVERROR(EINVAL);
980  }
981 
982  if (fseek(weights_file, 0, SEEK_SET)) {
983  fclose(weights_file);
984  av_log(ctx, AV_LOG_ERROR, "Couldn't seek to the start of weights file.\n");
985  return AVERROR(EINVAL);
986  }
987 
988  bdata = av_malloc(NNEDI_WEIGHTS_SIZE);
989  if (!bdata) {
990  fclose(weights_file);
991  return AVERROR(ENOMEM);
992  }
993 
994  bytes_read = fread(bdata, 1, NNEDI_WEIGHTS_SIZE, weights_file);
995  if (bytes_read != NNEDI_WEIGHTS_SIZE) {
996  fclose(weights_file);
998  av_log(ctx, AV_LOG_ERROR, "Couldn't read weights file.\n");
999  goto fail;
1000  }
1001 
1002  fclose(weights_file);
1003 
1004  s->fdsp = avpriv_float_dsp_alloc(0);
1005  if (!s->fdsp) {
1006  ret = AVERROR(ENOMEM);
1007  goto fail;
1008  }
1009 
1010  ret = read_weights(ctx, bdata);
1011  if (ret < 0)
1012  goto fail;
1013 
1014 fail:
1015  av_free(bdata);
1016  return ret;
1017 }
1018 
1020 {
1021  AVFilterContext *ctx = inlink->dst;
1022  NNEDIContext *s = ctx->priv;
1024  int ret;
1025 
1026  s->depth = desc->comp[0].depth;
1027  s->nb_threads = ff_filter_get_nb_threads(ctx);
1028  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
1029  if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
1030  return ret;
1031 
1032  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
1033  s->planewidth[0] = s->planewidth[3] = inlink->w;
1034  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
1035  s->planeheight[0] = s->planeheight[3] = inlink->h;
1036 
1037  s->half = ((1 << 8) - 1) / 2.f;
1038  s->out_scale = 1 << (s->depth - 8);
1039  s->in_scale = 1.f / s->out_scale;
1040 
1041  switch (s->depth) {
1042  case 8:
1043  s->read = read_bytes;
1044  s->write = write_bytes;
1045  break;
1046  default:
1047  s->read = read_words;
1048  s->write = write_words;
1049  break;
1050  }
1051 
1052  subtract_mean_old(&s->prescreener[0], s->half);
1053  subtract_mean_new(&s->prescreener[1], s->half);
1054  subtract_mean_new(&s->prescreener[2], s->half);
1055  subtract_mean_new(&s->prescreener[3], s->half);
1056 
1057  s->prescreen[0] = process_old;
1058  s->prescreen[1] = process_new;
1059 
1060  for (int i = 0; i < 2; i++) {
1061  for (int j = 0; j < 5; j++) {
1062  for (int k = 0; k < 7; k++)
1063  subtract_mean_predictor(&s->coeffs[i][j][k]);
1064  }
1065  }
1066 
1067  s->input_size = (s->planewidth[0] + 64) * (s->planeheight[0] + 6);
1068  s->input_buf = av_calloc(s->nb_threads, sizeof(*s->input_buf));
1069  if (!s->input_buf)
1070  return AVERROR(ENOMEM);
1071 
1072  for (int i = 0; i < s->nb_threads; i++) {
1073  s->input_buf[i] = av_calloc(s->input_size, sizeof(**s->input_buf));
1074  if (!s->input_buf[i])
1075  return AVERROR(ENOMEM);
1076  }
1077 
1078  s->output_buf = av_calloc(s->nb_threads, sizeof(*s->output_buf));
1079  if (!s->output_buf)
1080  return AVERROR(ENOMEM);
1081 
1082  for (int i = 0; i < s->nb_threads; i++) {
1083  s->output_buf[i] = av_calloc(s->input_size, sizeof(**s->output_buf));
1084  if (!s->output_buf[i])
1085  return AVERROR(ENOMEM);
1086  }
1087 
1088  s->prescreen_buf = av_calloc(s->nb_threads, sizeof(*s->prescreen_buf));
1089  if (!s->prescreen_buf)
1090  return AVERROR(ENOMEM);
1091 
1092  for (int i = 0; i < s->nb_threads; i++) {
1093  s->prescreen_buf[i] = av_calloc(s->planewidth[0], sizeof(**s->prescreen_buf));
1094  if (!s->prescreen_buf[i])
1095  return AVERROR(ENOMEM);
1096  }
1097 
1098  return 0;
1099 }
1100 
1102 {
1103  NNEDIContext *s = ctx->priv;
1104 
1105  for (int i = 0; i < s->nb_threads && s->prescreen_buf; i++)
1106  av_freep(&s->prescreen_buf[i]);
1107 
1108  av_freep(&s->prescreen_buf);
1109 
1110  for (int i = 0; i < s->nb_threads && s->input_buf; i++)
1111  av_freep(&s->input_buf[i]);
1112 
1113  av_freep(&s->input_buf);
1114 
1115  for (int i = 0; i < s->nb_threads && s->output_buf; i++)
1116  av_freep(&s->output_buf[i]);
1117 
1118  av_freep(&s->output_buf);
1119  av_freep(&s->fdsp);
1120 
1121  for (int i = 0; i < 2; i++) {
1122  for (int j = 0; j < 5; j++) {
1123  for (int k = 0; k < 7; k++) {
1124  av_freep(&s->coeffs[i][j][k].data);
1125  }
1126  }
1127  }
1128 
1129  av_frame_free(&s->prev);
1130 }
1131 
1132 static const AVFilterPad inputs[] = {
1133  {
1134  .name = "default",
1135  .type = AVMEDIA_TYPE_VIDEO,
1136  .filter_frame = filter_frame,
1137  .config_props = config_input,
1138  },
1139 };
1140 
1141 static const AVFilterPad outputs[] = {
1142  {
1143  .name = "default",
1144  .type = AVMEDIA_TYPE_VIDEO,
1145  .config_props = config_output,
1146  .request_frame = request_frame,
1147  },
1148 };
1149 
1151  .name = "nnedi",
1152  .description = NULL_IF_CONFIG_SMALL("Apply neural network edge directed interpolation intra-only deinterlacer."),
1153  .priv_size = sizeof(NNEDIContext),
1154  .priv_class = &nnedi_class,
1155  .init = init,
1156  .uninit = uninit,
1161  .process_command = ff_filter_process_command,
1162 };
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:98
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:447
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:426
dot_dsp
static float dot_dsp(const NNEDIContext *const s, const float *kernel, const float *input, int n, float scale, float bias)
Definition: vf_nnedi.c:206
NNEDIContext::prescreen_buf
uint8_t ** prescreen_buf
Definition: vf_nnedi.c:100
NNEDIContext::fdsp
AVFloatDSPContext * fdsp
Definition: vf_nnedi.c:73
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
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
get_frame
static int get_frame(AVFilterContext *ctx, int is_second)
Definition: vf_nnedi.c:656
mem_internal.h
NNEDIContext::pscrn
int pscrn
Definition: vf_nnedi.c:97
subtract_mean_predictor
static void subtract_mean_predictor(PredictorCoefficients *model)
Definition: vf_nnedi.c:889
out
FILE * out
Definition: movenc.c:54
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2660
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
PredictorCoefficients::softmax_bias_q2
float * softmax_bias_q2
Definition: vf_nnedi.c:60
NNEDIContext::field
int field
Definition: vf_nnedi.c:91
NNEDIContext::weights_file
char * weights_file
Definition: vf_nnedi.c:67
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
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
softmax_q2_filter
static const float * softmax_q2_filter(int nn, const PredictorCoefficients *const model)
Definition: vf_nnedi.c:312
PrescreenerCoefficients::kernel_l2
float kernel_l2[4][8]
Definition: vf_nnedi.c:47
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
NNEDIContext::qual
int qual
Definition: vf_nnedi.c:95
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:439
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:26
pixdesc.h
av_clip_uintp2_c
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
Clip a signed integer to an unsigned power of two range.
Definition: common.h:276
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:424
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:446
NNEDIContext
Definition: vf_nnedi.c:64
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:441
AVFrame::top_field_first
int top_field_first
If the content is interlaced, is top field displayed first.
Definition: frame.h:474
read_bytes
static void read_bytes(const uint8_t *src, float *dst, int src_stride, int dst_stride, int width, int height, float scale)
Definition: vf_nnedi.c:437
AVOption
AVOption.
Definition: opt.h:247
data
const char data[16]
Definition: mxf.c:143
expf
#define expf(x)
Definition: libm.h:283
half
static uint8_t half(int a, int b)
Definition: mobiclip.c:540
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:404
ff_request_frame
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:420
process_old
static void process_old(AVFilterContext *ctx, const void *src, ptrdiff_t src_stride, uint8_t *prescreen, int N, const PrescreenerCoefficients *const m_data)
Definition: vf_nnedi.c:229
NNEDIContext::prescreen
void(* prescreen[2])(AVFilterContext *ctx, const void *src, ptrdiff_t src_stride, uint8_t *prescreen, int N, const PrescreenerCoefficients *const coeffs)
Definition: vf_nnedi.c:110
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(nnedi)
OFFSET
#define OFFSET(x)
Definition: vf_nnedi.c:116
float.h
NNEDIContext::nsize
int nsize
Definition: vf_nnedi.c:93
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_nnedi.c:1101
NNEDIContext::depth
int depth
Definition: vf_nnedi.c:74
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
video.h
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:442
PrescreenerCoefficients::bias_l2
float bias_l2[4]
Definition: vf_nnedi.c:48
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:384
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:338
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
av_image_copy_plane
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:374
formats.h
elliott
static float elliott(float x)
Definition: vf_nnedi.c:218
NNEDIContext::pts
int64_t pts
Definition: vf_nnedi.c:71
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2700
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:438
window
static SDL_Window * window
Definition: ffplay.c:364
elliott_q2_filter
static const float * elliott_q2_filter(int nn, const PredictorCoefficients *const model)
Definition: vf_nnedi.c:318
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:422
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
fail
#define fail()
Definition: checkasm.h:127
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:420
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:448
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:402
PredictorCoefficients::softmax_q1
float * softmax_q1
Definition: vf_nnedi.c:54
ff_vf_nnedi
const AVFilter ff_vf_nnedi
Definition: vf_nnedi.c:1150
NNEDIContext::nnsparam
int nnsparam
Definition: vf_nnedi.c:94
val
static double val(void *priv, double ch)
Definition: aeval.c:76
PredictorCoefficients::data
float * data
Definition: vf_nnedi.c:53
NNEDI_XDIM
static const uint8_t NNEDI_XDIM[]
Definition: vf_nnedi.c:36
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1388
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:388
fabsf
static __device__ float fabsf(float a)
Definition: cuda_runtime.h:181
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
write_words
static void write_words(const float *src, uint8_t *dstp, int src_stride, int dst_stride, int width, int height, int depth, float scale)
Definition: vf_nnedi.c:493
softmax_exp
static float softmax_exp(float x)
Definition: vf_nnedi.c:360
NNEDIContext::eof
int eof
Definition: vf_nnedi.c:70
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:407
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:248
filter_slice
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_nnedi.c:533
inputs
static const AVFilterPad inputs[]
Definition: vf_nnedi.c:1132
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
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:416
av_fopen_utf8
FILE * av_fopen_utf8(const char *path, const char *mode)
Open a file using a UTF-8 filename.
Definition: file_open.c:158
RFLAGS
#define RFLAGS
Definition: vf_nnedi.c:117
allocate
static float * allocate(float **ptr, int size)
Definition: vf_nnedi.c:746
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:424
NNEDI_NNS
static const uint16_t NNEDI_NNS[]
Definition: vf_nnedi.c:38
width
#define width
av_image_fill_linesizes
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition: imgutils.c:89
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:425
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:417
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:51
NNEDIContext::planewidth
int planewidth[4]
Definition: vf_nnedi.c:78
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2042
PredictorCoefficients::softmax_bias_q1
float * softmax_bias_q1
Definition: vf_nnedi.c:56
PrescreenerCoefficients::kernel_l0
float kernel_l0[4][16 *4]
Definition: vf_nnedi.c:41
request_frame
static int request_frame(AVFilterLink *link)
Definition: vf_nnedi.c:711
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:445
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:401
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:415
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:387
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:422
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:141
FLAGS
#define FLAGS
Definition: vf_nnedi.c:118
PredictorCoefficients::nns
int nns
Definition: vf_nnedi.c:52
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
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
PredictorCoefficients::ydim
int ydim
Definition: vf_nnedi.c:52
f
#define f(width, name)
Definition: cbs_vp9.c:255
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
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
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
arg
const char * arg
Definition: jacosubdec.c:67
NNEDIContext::planeheight
int planeheight[4]
Definition: vf_nnedi.c:79
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:385
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:423
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
softmax_q1_filter
static const float * softmax_q1_filter(int nn, const PredictorCoefficients *const model)
Definition: vf_nnedi.c:300
interpolation
static void interpolation(const void *src, ptrdiff_t src_stride, void *dst, const uint8_t *prescreen, int n)
Definition: vf_nnedi.c:511
NULL
#define NULL
Definition: coverity.c:32
PrescreenerCoefficients::bias_l0
float bias_l0[4]
Definition: vf_nnedi.c:42
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition: mem_internal.h:136
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:537
NNEDIContext::coeffs
PredictorCoefficients coeffs[2][5][7]
Definition: vf_nnedi.c:83
PrescreenerCoefficients::bias_l1
float bias_l1[4]
Definition: vf_nnedi.c:45
subtract_mean_old
static void subtract_mean_old(PrescreenerCoefficients *coeffs, float half)
Definition: vf_nnedi.c:871
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
transform_elliott
static void transform_elliott(float *input, int size)
Definition: vf_nnedi.c:223
av_clipf
#define av_clipf
Definition: common.h:144
src
#define src
Definition: vp8dsp.c:255
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:406
NNEDIContext::write
void(* write)(const float *src, uint8_t *dst, int src_stride, int dst_stride, int width, int height, int depth, float scale)
Definition: vf_nnedi.c:107
NNEDI_YDIM
static const uint8_t NNEDI_YDIM[]
Definition: vf_nnedi.c:37
nnedi_options
static const AVOption nnedi_options[]
Definition: vf_nnedi.c:120
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:405
PrescreenerCoefficients::kernel_l1
float kernel_l1[4][4]
Definition: vf_nnedi.c:44
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:419
NNEDIContext::etype
int etype
Definition: vf_nnedi.c:96
float_dsp.h
NNEDIContext::half
float half
Definition: vf_nnedi.c:85
NNEDIContext::nb_threads
int nb_threads
Definition: vf_nnedi.c:76
state
static struct @320 state
NNEDIContext::process_plane
int process_plane
Definition: vf_nnedi.c:92
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:117
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:409
wae5
static void wae5(const float *softmax, const float *el, int n, float mstd[4])
Definition: vf_nnedi.c:371
size
int size
Definition: twinvq_data.h:10344
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:411
NNEDIContext::nb_planes
int nb_planes
Definition: vf_nnedi.c:75
elliott_q1_filter
static const float * elliott_q1_filter(int nn, const PredictorCoefficients *const model)
Definition: vf_nnedi.c:306
AVFloatDSPContext
Definition: float_dsp.h:24
PrescreenerCoefficients
Definition: vf_nnedi.c:40
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:882
PredictorCoefficients
Definition: vf_nnedi.c:51
predictor
static void predictor(AVFilterContext *ctx, const void *src, ptrdiff_t src_stride, void *dst, const uint8_t *prescreen, int N, const PredictorCoefficients *const model, int use_q2)
Definition: vf_nnedi.c:387
height
#define height
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:167
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:443
NNEDIContext::linesize
int linesize[4]
Definition: vf_nnedi.c:77
transform_softmax_exp
static void transform_softmax_exp(float *input, int size)
Definition: vf_nnedi.c:365
PredictorCoefficients::xdim
int xdim
Definition: vf_nnedi.c:52
N
#define N
Definition: af_mcompand.c:53
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
internal.h
outputs
static const AVFilterPad outputs[]
Definition: vf_nnedi.c:1141
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_nnedi.c:949
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem.h:116
AVFrame::interlaced_frame
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:469
interlaced
uint8_t interlaced
Definition: mxfenc.c:2040
filter_offset
static int filter_offset(int nn, const PredictorCoefficients *const model)
Definition: vf_nnedi.c:295
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:421
common.h
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:803
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:100
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_nnedi.c:180
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
PredictorCoefficients::softmax_q2
float * softmax_q2
Definition: vf_nnedi.c:58
write_bytes
static void write_bytes(const float *src, uint8_t *dst, int src_stride, int dst_stride, int width, int height, int depth, float scale)
Definition: vf_nnedi.c:479
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:271
NNEDIContext::read
void(* read)(const uint8_t *src, float *dst, int src_stride, int dst_stride, int width, int height, float scale)
Definition: vf_nnedi.c:104
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:403
NNEDIContext::input_size
int input_size
Definition: vf_nnedi.c:99
AVFilter
Filter definition.
Definition: avfilter.h:165
PredictorCoefficients::nsize
int nsize
Definition: vf_nnedi.c:52
ret
ret
Definition: filter_design.txt:187
PredictorCoefficients::elliott_bias_q2
float * elliott_bias_q2
Definition: vf_nnedi.c:61
subtract_mean_new
static void subtract_mean_new(PrescreenerCoefficients *coeffs, float half)
Definition: vf_nnedi.c:880
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:440
gather_input
static void gather_input(const float *src, ptrdiff_t src_stride, float *buf, float mstd[4], const PredictorCoefficients *const model)
Definition: vf_nnedi.c:324
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:408
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:413
PredictorCoefficients::elliott_q2
float * elliott_q2
Definition: vf_nnedi.c:59
allocate_model
static int allocate_model(PredictorCoefficients *coeffs, int xdim, int ydim, int nns)
Definition: vf_nnedi.c:755
NNEDIContext::deint
int deint
Definition: vf_nnedi.c:90
NNEDIContext::in_scale
float in_scale
Definition: vf_nnedi.c:86
NNEDI_WEIGHTS_SIZE
static const size_t NNEDI_WEIGHTS_SIZE
Definition: vf_nnedi.c:35
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:444
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
PredictorCoefficients::elliott_bias_q1
float * elliott_bias_q1
Definition: vf_nnedi.c:57
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_nnedi.c:678
process_new
static void process_new(AVFilterContext *ctx, const void *src, ptrdiff_t src_stride, uint8_t *prescreen, int N, const PrescreenerCoefficients *const m_data)
Definition: vf_nnedi.c:265
mean
static float mean(const float *input, int size)
Definition: vf_nnedi.c:855
NNEDIContext::input_buf
float ** input_buf
Definition: vf_nnedi.c:101
read_words
static void read_words(const uint8_t *srcp, float *dst, int src_stride, int dst_stride, int width, int height, float scale)
Definition: vf_nnedi.c:456
transform
static void transform(float *input, int size, float mean, float half)
Definition: vf_nnedi.c:865
av_mul_q
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
av_clip_uint8
#define av_clip_uint8
Definition: common.h:102
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:121
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
PredictorCoefficients::elliott_q1
float * elliott_q1
Definition: vf_nnedi.c:55
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
NNEDIContext::out_scale
float out_scale
Definition: vf_nnedi.c:87
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
read_weights
static int read_weights(AVFilterContext *ctx, const float *bdata)
Definition: vf_nnedi.c:784
avpriv_float_dsp_alloc
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
Definition: float_dsp.c:135
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_nnedi.c:1019
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:154
imgutils.h
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:362
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
copy_weights
static void copy_weights(float *dst, int n, const float **data)
Definition: vf_nnedi.c:740
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:410
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:414
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:386
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:143
NNEDIContext::field_n
int field_n
Definition: vf_nnedi.c:80
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
NNEDIContext::prev
AVFrame * prev
Definition: vf_nnedi.c:69
NNEDIContext::output_buf
float ** output_buf
Definition: vf_nnedi.c:102
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:166
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:412
NNEDIContext::prescreener
PrescreenerCoefficients prescreener[4]
Definition: vf_nnedi.c:82
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_nnedi.c:166