FFmpeg
vf_idet.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Michael Niedermayer <michaelni@gmx.at>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <float.h> /* FLT_MAX */
22 
23 #include "libavutil/common.h"
24 #include "libavutil/opt.h"
25 #include "internal.h"
26 #include "vf_idet.h"
27 
28 #define OFFSET(x) offsetof(IDETContext, x)
29 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
30 
31 static const AVOption idet_options[] = {
32  { "intl_thres", "set interlacing threshold", OFFSET(interlace_threshold), AV_OPT_TYPE_FLOAT, {.dbl = 1.04}, -1, FLT_MAX, FLAGS },
33  { "prog_thres", "set progressive threshold", OFFSET(progressive_threshold), AV_OPT_TYPE_FLOAT, {.dbl = 1.5}, -1, FLT_MAX, FLAGS },
34  { "rep_thres", "set repeat threshold", OFFSET(repeat_threshold), AV_OPT_TYPE_FLOAT, {.dbl = 3.0}, -1, FLT_MAX, FLAGS },
35  { "half_life", "half life of cumulative statistics", OFFSET(half_life), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, -1, INT_MAX, FLAGS },
36  { "analyze_interlaced_flag", "set number of frames to use to determine if the interlace flag is accurate", OFFSET(analyze_interlaced_flag), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, FLAGS },
37  { NULL }
38 };
39 
41 
42 static const char *type2str(Type type)
43 {
44  switch(type) {
45  case TFF : return "tff";
46  case BFF : return "bff";
47  case PROGRESSIVE : return "progressive";
48  case UNDETERMINED : return "undetermined";
49  }
50  return NULL;
51 }
52 
53 #define PRECISION 1048576
54 
55 static uint64_t uintpow(uint64_t b,unsigned int e)
56 {
57  uint64_t r=1;
58  while(e--) r*=b;
59  return r;
60 }
61 
62 static int av_dict_set_fxp(AVDictionary **pm, const char *key, uint64_t value, unsigned int digits,
63  int flags)
64 {
65  char valuestr[44];
66  uint64_t print_precision = uintpow(10, digits);
67 
68  value = av_rescale(value, print_precision, PRECISION);
69 
70  snprintf(valuestr, sizeof(valuestr), "%"PRId64".%0*"PRId64,
71  value / print_precision, digits, value % print_precision);
72 
73  return av_dict_set(pm, key, valuestr, flags);
74 }
75 
76 static const char *rep2str(RepeatedField repeated_field)
77 {
78  switch(repeated_field) {
79  case REPEAT_NONE : return "neither";
80  case REPEAT_TOP : return "top";
81  case REPEAT_BOTTOM : return "bottom";
82  }
83  return NULL;
84 }
85 
86 int ff_idet_filter_line_c(const uint8_t *a, const uint8_t *b, const uint8_t *c, int w)
87 {
88  int x;
89  int ret=0;
90 
91  for(x=0; x<w; x++){
92  int v = (*a++ + *c++) - 2 * *b++;
93  ret += FFABS(v);
94  }
95 
96  return ret;
97 }
98 
99 int ff_idet_filter_line_c_16bit(const uint16_t *a, const uint16_t *b, const uint16_t *c, int w)
100 {
101  int x;
102  int ret=0;
103 
104  for(x=0; x<w; x++){
105  int v = (*a++ + *c++) - 2 * *b++;
106  ret += FFABS(v);
107  }
108 
109  return ret;
110 }
111 
113 {
114  IDETContext *idet = ctx->priv;
115  int y, i;
116  int64_t alpha[2]={0};
117  int64_t delta=0;
118  int64_t gamma[2]={0};
119  Type type, best_type;
120  RepeatedField repeat;
121  int match = 0;
122  AVDictionary **metadata = &idet->cur->metadata;
123 
124  for (i = 0; i < idet->csp->nb_components; i++) {
125  int w = idet->cur->width;
126  int h = idet->cur->height;
127  int refs = idet->cur->linesize[i];
128 
129  if (i && i<3) {
130  w = AV_CEIL_RSHIFT(w, idet->csp->log2_chroma_w);
131  h = AV_CEIL_RSHIFT(h, idet->csp->log2_chroma_h);
132  }
133 
134  for (y = 2; y < h - 2; y++) {
135  uint8_t *prev = &idet->prev->data[i][y*refs];
136  uint8_t *cur = &idet->cur ->data[i][y*refs];
137  uint8_t *next = &idet->next->data[i][y*refs];
138  alpha[ y &1] += idet->filter_line(cur-refs, prev, cur+refs, w);
139  alpha[(y^1)&1] += idet->filter_line(cur-refs, next, cur+refs, w);
140  delta += idet->filter_line(cur-refs, cur, cur+refs, w);
141  gamma[(y^1)&1] += idet->filter_line(cur , prev, cur , w);
142  }
143  }
144 
145  if (alpha[0] > idet->interlace_threshold * alpha[1]){
146  type = TFF;
147  }else if(alpha[1] > idet->interlace_threshold * alpha[0]){
148  type = BFF;
149  }else if(alpha[1] > idet->progressive_threshold * delta){
150  type = PROGRESSIVE;
151  }else{
152  type = UNDETERMINED;
153  }
154 
155  if ( gamma[0] > idet->repeat_threshold * gamma[1] ){
156  repeat = REPEAT_TOP;
157  } else if ( gamma[1] > idet->repeat_threshold * gamma[0] ){
158  repeat = REPEAT_BOTTOM;
159  } else {
160  repeat = REPEAT_NONE;
161  }
162 
163  memmove(idet->history+1, idet->history, HIST_SIZE-1);
164  idet->history[0] = type;
165  best_type = UNDETERMINED;
166  for(i=0; i<HIST_SIZE; i++){
167  if(idet->history[i] != UNDETERMINED){
168  if(best_type == UNDETERMINED)
169  best_type = idet->history[i];
170 
171  if(idet->history[i] == best_type) {
172  match++;
173  }else{
174  match=0;
175  break;
176  }
177  }
178  }
179  if(idet->last_type == UNDETERMINED){
180  if(match ) idet->last_type = best_type;
181  }else{
182  if(match>2) idet->last_type = best_type;
183  }
184 
185  if (idet->last_type == TFF){
186 #if FF_API_INTERLACED_FRAME
188  idet->cur->top_field_first = 1;
189  idet->cur->interlaced_frame = 1;
191 #endif
193  }else if(idet->last_type == BFF){
194 #if FF_API_INTERLACED_FRAME
196  idet->cur->top_field_first = 0;
197  idet->cur->interlaced_frame = 1;
199 #endif
202  }else if(idet->last_type == PROGRESSIVE){
203 #if FF_API_INTERLACED_FRAME
205  idet->cur->interlaced_frame = 0;
207 #endif
209  }
210 
211  for(i=0; i<3; i++)
212  idet->repeats[i] = av_rescale(idet->repeats [i], idet->decay_coefficient, PRECISION);
213 
214  for(i=0; i<4; i++){
215  idet->prestat [i] = av_rescale(idet->prestat [i], idet->decay_coefficient, PRECISION);
216  idet->poststat[i] = av_rescale(idet->poststat[i], idet->decay_coefficient, PRECISION);
217  }
218 
219  idet->total_repeats [ repeat] ++;
220  idet->repeats [ repeat] += PRECISION;
221 
222  idet->total_prestat [ type] ++;
223  idet->prestat [ type] += PRECISION;
224 
225  idet->total_poststat[idet->last_type] ++;
226  idet->poststat [idet->last_type] += PRECISION;
227 
228  av_log(ctx, AV_LOG_DEBUG, "Repeated Field:%12s, Single frame:%12s, Multi frame:%12s\n",
229  rep2str(repeat), type2str(type), type2str(idet->last_type));
230 
231  av_dict_set (metadata, "lavfi.idet.repeated.current_frame", rep2str(repeat), 0);
232  av_dict_set_fxp(metadata, "lavfi.idet.repeated.neither", idet->repeats[REPEAT_NONE], 2, 0);
233  av_dict_set_fxp(metadata, "lavfi.idet.repeated.top", idet->repeats[REPEAT_TOP], 2, 0);
234  av_dict_set_fxp(metadata, "lavfi.idet.repeated.bottom", idet->repeats[REPEAT_BOTTOM], 2, 0);
235 
236  av_dict_set (metadata, "lavfi.idet.single.current_frame", type2str(type), 0);
237  av_dict_set_fxp(metadata, "lavfi.idet.single.tff", idet->prestat[TFF], 2 , 0);
238  av_dict_set_fxp(metadata, "lavfi.idet.single.bff", idet->prestat[BFF], 2, 0);
239  av_dict_set_fxp(metadata, "lavfi.idet.single.progressive", idet->prestat[PROGRESSIVE], 2, 0);
240  av_dict_set_fxp(metadata, "lavfi.idet.single.undetermined", idet->prestat[UNDETERMINED], 2, 0);
241 
242  av_dict_set (metadata, "lavfi.idet.multiple.current_frame", type2str(idet->last_type), 0);
243  av_dict_set_fxp(metadata, "lavfi.idet.multiple.tff", idet->poststat[TFF], 2, 0);
244  av_dict_set_fxp(metadata, "lavfi.idet.multiple.bff", idet->poststat[BFF], 2, 0);
245  av_dict_set_fxp(metadata, "lavfi.idet.multiple.progressive", idet->poststat[PROGRESSIVE], 2, 0);
246  av_dict_set_fxp(metadata, "lavfi.idet.multiple.undetermined", idet->poststat[UNDETERMINED], 2, 0);
247 }
248 
249 static int filter_frame(AVFilterLink *link, AVFrame *picref)
250 {
251  AVFilterContext *ctx = link->dst;
252  IDETContext *idet = ctx->priv;
253 
254  // initial frame(s) and not interlaced, just pass through for
255  // the analyze_interlaced_flag mode
256  if (idet->analyze_interlaced_flag &&
257  !(picref->flags & AV_FRAME_FLAG_INTERLACED) &&
258  !idet->next) {
259  return ff_filter_frame(ctx->outputs[0], picref);
260  }
261  if (idet->analyze_interlaced_flag_done) {
262  if ((picref->flags & AV_FRAME_FLAG_INTERLACED) && idet->interlaced_flag_accuracy < 0) {
263 #if FF_API_INTERLACED_FRAME
265  picref->interlaced_frame = 0;
267 #endif
268  picref->flags &= ~AV_FRAME_FLAG_INTERLACED;
269  }
270  return ff_filter_frame(ctx->outputs[0], picref);
271  }
272 
273  av_frame_free(&idet->prev);
274 
275  if( picref->width != link->w
276  || picref->height != link->h
277  || picref->format != link->format) {
278  link->dst->inputs[0]->format = picref->format;
279  link->dst->inputs[0]->w = picref->width;
280  link->dst->inputs[0]->h = picref->height;
281 
282  av_frame_free(&idet->cur );
283  av_frame_free(&idet->next);
284  }
285 
286  idet->prev = idet->cur;
287  idet->cur = idet->next;
288  idet->next = picref;
289 
290  if (!idet->cur &&
291  !(idet->cur = av_frame_clone(idet->next)))
292  return AVERROR(ENOMEM);
293 
294  if (!idet->prev)
295  return 0;
296 
297  if (!idet->csp)
299  if (idet->csp->comp[0].depth > 8){
301 #if ARCH_X86
302  ff_idet_init_x86(idet, 1);
303 #endif
304  }
305 
306  if (idet->analyze_interlaced_flag) {
307  if (idet->cur->flags & AV_FRAME_FLAG_INTERLACED) {
308 #if FF_API_INTERLACED_FRAME
310  idet->cur->interlaced_frame = 0;
312 #endif
314  filter(ctx);
315  if (idet->last_type == PROGRESSIVE) {
316  idet->interlaced_flag_accuracy --;
317  idet->analyze_interlaced_flag --;
318  } else if (idet->last_type != UNDETERMINED) {
319  idet->interlaced_flag_accuracy ++;
320  idet->analyze_interlaced_flag --;
321  }
322  if (idet->analyze_interlaced_flag == 1) {
323  ff_filter_frame(ctx->outputs[0], av_frame_clone(idet->cur));
324 
325  if ((idet->next->flags & AV_FRAME_FLAG_INTERLACED) && idet->interlaced_flag_accuracy < 0) {
326 #if FF_API_INTERLACED_FRAME
328  idet->next->interlaced_frame = 0;
330 #endif
332  }
334  av_log(ctx, AV_LOG_INFO, "Final flag accuracy %d\n", idet->interlaced_flag_accuracy);
335  return ff_filter_frame(ctx->outputs[0], av_frame_clone(idet->next));
336  }
337  }
338  } else {
339  filter(ctx);
340  }
341 
342  return ff_filter_frame(ctx->outputs[0], av_frame_clone(idet->cur));
343 }
344 
346 {
347  AVFilterContext *ctx = link->src;
348  IDETContext *idet = ctx->priv;
349  int ret;
350 
351  if (idet->eof)
352  return AVERROR_EOF;
353 
354  ret = ff_request_frame(link->src->inputs[0]);
355 
356  if (ret == AVERROR_EOF && idet->cur && !idet->analyze_interlaced_flag_done) {
357  AVFrame *next = av_frame_clone(idet->next);
358 
359  if (!next)
360  return AVERROR(ENOMEM);
361 
362  ret = filter_frame(link->src->inputs[0], next);
363  idet->eof = 1;
364  }
365 
366  return ret;
367 }
368 
370 {
371  IDETContext *idet = ctx->priv;
372 
373  av_log(ctx, AV_LOG_INFO, "Repeated Fields: Neither:%6"PRId64" Top:%6"PRId64" Bottom:%6"PRId64"\n",
374  idet->total_repeats[REPEAT_NONE],
375  idet->total_repeats[REPEAT_TOP],
377  );
378  av_log(ctx, AV_LOG_INFO, "Single frame detection: TFF:%6"PRId64" BFF:%6"PRId64" Progressive:%6"PRId64" Undetermined:%6"PRId64"\n",
379  idet->total_prestat[TFF],
380  idet->total_prestat[BFF],
381  idet->total_prestat[PROGRESSIVE],
383  );
384  av_log(ctx, AV_LOG_INFO, "Multi frame detection: TFF:%6"PRId64" BFF:%6"PRId64" Progressive:%6"PRId64" Undetermined:%6"PRId64"\n",
385  idet->total_poststat[TFF],
386  idet->total_poststat[BFF],
389  );
390 
391  av_frame_free(&idet->prev);
392  av_frame_free(&idet->cur );
393  av_frame_free(&idet->next);
394 }
395 
396 static const enum AVPixelFormat pix_fmts[] = {
428 };
429 
431 {
432  IDETContext *idet = ctx->priv;
433 
434  idet->eof = 0;
435  idet->last_type = UNDETERMINED;
436  memset(idet->history, UNDETERMINED, HIST_SIZE);
437 
438  if( idet->half_life > 0 )
439  idet->decay_coefficient = lrint( PRECISION * exp2(-1.0 / idet->half_life) );
440  else
442 
444 
445 #if ARCH_X86
446  ff_idet_init_x86(idet, 0);
447 #endif
448 
449  return 0;
450 }
451 
452 static const AVFilterPad idet_inputs[] = {
453  {
454  .name = "default",
455  .type = AVMEDIA_TYPE_VIDEO,
456  .filter_frame = filter_frame,
457  },
458 };
459 
460 static const AVFilterPad idet_outputs[] = {
461  {
462  .name = "default",
463  .type = AVMEDIA_TYPE_VIDEO,
464  .request_frame = request_frame
465  },
466 };
467 
469  .name = "idet",
470  .description = NULL_IF_CONFIG_SMALL("Interlace detect Filter."),
471  .priv_size = sizeof(IDETContext),
472  .init = init,
473  .uninit = uninit,
478  .priv_class = &idet_class,
479 };
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:73
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
type2str
static const char * type2str(Type type)
Definition: vf_idet.c:42
r
const char * r
Definition: vf_curves.c:126
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
request_frame
static int request_frame(AVFilterLink *link)
Definition: vf_idet.c:345
opt.h
PROGRESSIVE
@ PROGRESSIVE
in the bitstream is reported as 00b
Definition: vc1.h:149
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:2962
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
IDETContext::filter_line
ff_idet_filter_func filter_line
Definition: vf_idet.h:64
IDETContext::half_life
float half_life
Definition: vf_idet.h:47
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:162
HIST_SIZE
#define HIST_SIZE
Definition: f_ebur128.c:51
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:88
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
AVFrame::width
int width
Definition: frame.h:412
w
uint8_t w
Definition: llviddspenc.c:38
AVComponentDescriptor::depth
int depth
Number of bits in the component.
Definition: pixdesc.h:57
AVOption
AVOption.
Definition: opt.h:346
b
#define b
Definition: input.c:41
REPEAT_NONE
@ REPEAT_NONE
Definition: vf_idet.h:37
REPEAT_BOTTOM
@ REPEAT_BOTTOM
Definition: vf_idet.h:39
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *picref)
Definition: vf_idet.c:249
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:478
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:462
float.h
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_idet.c:396
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
AVDictionary
Definition: dict.c:34
AVFrame::flags
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition: frame.h:612
IDETContext::analyze_interlaced_flag_done
int analyze_interlaced_flag_done
Definition: vf_idet.h:68
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:361
AV_FRAME_FLAG_TOP_FIELD_FIRST
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
Definition: frame.h:604
RepeatedField
RepeatedField
Definition: vf_idet.h:36
IDETContext
Definition: vf_idet.h:42
ff_idet_filter_line_c_16bit
int ff_idet_filter_line_c_16bit(const uint16_t *a, const uint16_t *b, const uint16_t *c, int w)
Definition: vf_idet.c:99
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(idet)
IDETContext::prestat
uint64_t prestat[4]
Definition: vf_idet.h:53
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:476
vf_idet.h
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:462
IDETContext::interlace_threshold
float interlace_threshold
Definition: vf_idet.h:44
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:481
IDETContext::prev
AVFrame * prev
Definition: vf_idet.h:63
AVFrame::interlaced_frame
attribute_deprecated int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:517
lrint
#define lrint
Definition: tablegen.h:53
BFF
@ BFF
Definition: vf_idet.h:31
av_cold
#define av_cold
Definition: attributes.h:90
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:490
IDETContext::next
AVFrame * next
Definition: vf_idet.h:62
REPEAT_TOP
@ REPEAT_TOP
Definition: vf_idet.h:38
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:86
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:108
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:491
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
av_dict_set_fxp
static int av_dict_set_fxp(AVDictionary **pm, const char *key, uint64_t value, unsigned int digits, int flags)
Definition: vf_idet.c:62
FLAGS
#define FLAGS
Definition: vf_idet.c:29
idet_outputs
static const AVFilterPad idet_outputs[]
Definition: vf_idet.c:460
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:475
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:489
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:521
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_idet.c:430
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
IDETContext::repeat_threshold
float repeat_threshold
Definition: vf_idet.h:46
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:73
IDETContext::eof
int eof
Definition: vf_idet.h:71
key
const char * key
Definition: hwcontext_opencl.c:189
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
IDETContext::csp
const AVPixFmtDescriptor * csp
Definition: vf_idet.h:70
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:87
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
idet_options
static const AVOption idet_options[]
Definition: vf_idet.c:31
ff_vf_idet
const AVFilter ff_vf_idet
Definition: vf_idet.c:468
NULL
#define NULL
Definition: coverity.c:32
AVPixFmtDescriptor::nb_components
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
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:85
idet_inputs
static const AVFilterPad idet_inputs[]
Definition: vf_idet.c:452
OFFSET
#define OFFSET(x)
Definition: vf_idet.c:28
uintpow
static uint64_t uintpow(uint64_t b, unsigned int e)
Definition: vf_idet.c:55
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:479
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
IDETContext::total_poststat
uint64_t total_poststat[4]
Definition: vf_idet.h:57
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
IDETContext::interlaced_flag_accuracy
int interlaced_flag_accuracy
Definition: vf_idet.h:66
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:106
filter
static void filter(AVFilterContext *ctx)
Definition: vf_idet.c:112
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_idet.c:369
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:483
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:485
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:427
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
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:174
ff_idet_filter_func
int(* ff_idet_filter_func)(const uint8_t *a, const uint8_t *b, const uint8_t *c, int w)
Definition: vf_idet.h:27
IDETContext::analyze_interlaced_flag
int analyze_interlaced_flag
Definition: vf_idet.h:67
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
internal.h
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:238
Type
Type
Definition: vf_idet.h:29
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVFrame::top_field_first
attribute_deprecated int top_field_first
If the content is interlaced, is top field displayed first.
Definition: frame.h:525
rep2str
static const char * rep2str(RepeatedField repeated_field)
Definition: vf_idet.c:76
common.h
delta
float delta
Definition: vorbis_enc_data.h:430
exp2
#define exp2(x)
Definition: libm.h:288
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
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:107
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
IDETContext::cur
AVFrame * cur
Definition: vf_idet.h:61
AV_FRAME_FLAG_INTERLACED
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
Definition: frame.h:599
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:477
IDETContext::poststat
uint64_t poststat[4]
Definition: vf_idet.h:54
IDETContext::total_prestat
uint64_t total_prestat[4]
Definition: vf_idet.h:56
UNDETERMINED
@ UNDETERMINED
Definition: vf_idet.h:33
AVFilter
Filter definition.
Definition: avfilter.h:166
ret
ret
Definition: filter_design.txt:187
IDETContext::total_repeats
uint64_t total_repeats[3]
Definition: vf_idet.h:55
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:482
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:487
PRECISION
#define PRECISION
Definition: vf_idet.c:53
IDETContext::history
uint8_t history[HIST_SIZE]
Definition: vf_idet.h:59
AVFrame::height
int height
Definition: frame.h:412
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
AVFrame::metadata
AVDictionary * metadata
metadata.
Definition: frame.h:658
IDETContext::repeats
uint64_t repeats[3]
Definition: vf_idet.h:52
AVFILTER_FLAG_METADATA_ONLY
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition: avfilter.h:133
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
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:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:72
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ff_idet_filter_line_c
int ff_idet_filter_line_c(const uint8_t *a, const uint8_t *b, const uint8_t *c, int w)
Definition: vf_idet.c:86
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:77
IDETContext::decay_coefficient
uint64_t decay_coefficient
Definition: vf_idet.h:48
IDETContext::progressive_threshold
float progressive_threshold
Definition: vf_idet.h:45
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
TFF
@ TFF
Definition: vf_idet.h:30
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:88
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:80
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
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:385
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:79
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
h
h
Definition: vp9dsp_template.c:2038
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:488
IDETContext::last_type
Type last_type
Definition: vf_idet.h:50
snprintf
#define snprintf
Definition: snprintf.h:34
ff_idet_init_x86
void ff_idet_init_x86(IDETContext *idet, int for_16b)
Definition: vf_idet_init.c:63
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
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:173
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:486