41     {   int score = FFABS(cur[mrefs - 1 + (j)] - cur[prefs - 1 - (j)])\ 
   42                   + FFABS(cur[mrefs  +(j)] - cur[prefs  -(j)])\ 
   43                   + FFABS(cur[mrefs + 1 + (j)] - cur[prefs + 1 - (j)]);\ 
   44         if (score < spatial_score) {\ 
   45             spatial_score= score;\ 
   46             spatial_pred= (cur[mrefs  +(j)] + cur[prefs  -(j)])>>1;\ 
   51 #define FILTER(start, end, is_not_edge) \ 
   52     for (x = start;  x < end; x++) { \ 
   54         int d = (prev2[0] + next2[0])>>1; \ 
   56         int temporal_diff0 = FFABS(prev2[0] - next2[0]); \ 
   57         int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \ 
   58         int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \ 
   59         int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \ 
   60         int spatial_pred = (c+e) >> 1; \ 
   63             int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \ 
   64                               + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \ 
   65             CHECK(-1) CHECK(-2) }} }} \ 
   66             CHECK( 1) CHECK( 2) }} }} \ 
   70             int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \ 
   71             int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \ 
   72             int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \ 
   73             int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \ 
   75             diff = FFMAX3(diff, min, -max); \ 
   78         if (spatial_pred > d + diff) \ 
   79            spatial_pred = d + diff; \ 
   80         else if (spatial_pred < d - diff) \ 
   81            spatial_pred = d - diff; \ 
   83         dst[0] = spatial_pred; \ 
   94                           void *prev1, 
void *cur1, 
void *next1,
 
   95                           int w, 
int prefs, 
int mrefs, 
int parity, 
int mode)
 
  102     uint8_t *prev2 = parity ? prev : cur ;
 
  103     uint8_t *next2 = parity ? cur  : next;
 
  113 static void filter_edges(
void *dst1, 
void *prev1, 
void *cur1, 
void *next1,
 
  114                          int w, 
int prefs, 
int mrefs, 
int parity, 
int mode)
 
  121     uint8_t *prev2 = parity ? prev : cur ;
 
  122     uint8_t *next2 = parity ? cur  : next;
 
  132     prev2 = (
uint8_t*)(parity ? prev : cur);
 
  133     next2 = (
uint8_t*)(parity ? cur  : next);
 
  141                                 void *prev1, 
void *cur1, 
void *next1,
 
  142                                 int w, 
int prefs, 
int mrefs, 
int parity,
 
  145     uint16_t *dst  = dst1;
 
  146     uint16_t *prev = prev1;
 
  147     uint16_t *cur  = cur1;
 
  148     uint16_t *next = next1;
 
  150     uint16_t *prev2 = parity ? prev : cur ;
 
  151     uint16_t *next2 = parity ? cur  : next;
 
  159                                int w, 
int prefs, 
int mrefs, 
int parity, 
int mode)
 
  161     uint16_t *dst  = dst1;
 
  162     uint16_t *prev = prev1;
 
  163     uint16_t *cur  = cur1;
 
  164     uint16_t *next = next1;
 
  166     uint16_t *prev2 = parity ? prev : cur ;
 
  167     uint16_t *next2 = parity ? cur  : next;
 
  173     dst   = (uint16_t*)dst1  + w - (
MAX_ALIGN/2-1);
 
  174     prev  = (uint16_t*)prev1 + w - (
MAX_ALIGN/2-1);
 
  175     cur   = (uint16_t*)cur1  + w - (
MAX_ALIGN/2-1);
 
  176     next  = (uint16_t*)next1 + w - (
MAX_ALIGN/2-1);
 
  177     prev2 = (uint16_t*)(parity ? prev : cur);
 
  178     next2 = (uint16_t*)(parity ? cur  : next);
 
  191     int slice_start = (td->
h *  jobnr   ) / nb_jobs;
 
  192     int slice_end   = (td->
h * (jobnr+1)) / nb_jobs;
 
  198     for (y = slice_start; y < 
slice_end; y++) {
 
  199         if ((y ^ td->
parity) & 1) {
 
  204             int     mode  = y == 1 || y + 2 == td->
h ? 2 : s->
mode;
 
  205             s->
filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
 
  207                            y + 1 < td->
h ? refs : -refs,
 
  211                             y + 1 < td->
h ? refs : -refs,
 
  230         int w = dstpic->
width;
 
  233         if (i == 1 || i == 2) {
 
  255     if (yadif->
parity == -1) {
 
  271     filter(ctx, yadif->
out, tff ^ !is_second, tff);
 
  274         int64_t cur_pts  = yadif->
cur->
pts;
 
  275         int64_t next_pts = yadif->
next->
pts;
 
  278             yadif->
out->
pts = cur_pts + next_pts;
 
  404         } 
else if (ret < 0) {
 
  407     } 
while (!yadif->
prev);
 
  483     if (link->w < 3 || link->h < 3) {
 
  484         av_log(ctx, 
AV_LOG_ERROR, 
"Video of less than 3 columns or lines is not supported\n");
 
  489     if (
s->csp->comp[0].depth_minus1 / 8 == 1) {
 
  504 #define OFFSET(x) offsetof(YADIFContext, x) 
  505 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 
  507 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit } 
  553     .priv_class    = &yadif_class,
 
  556     .
inputs        = avfilter_vf_yadif_inputs,
 
  557     .
outputs       = avfilter_vf_yadif_outputs,
 
void(* filter_edges)(void *dst, void *prev, void *cur, void *next, int w, int prefs, int mrefs, int parity, int mode)
static const AVFilterPad avfilter_vf_yadif_inputs[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data. 
#define AV_PIX_FMT_YUV444P14
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) 
static const AVFilterPad outputs[]
Main libavfilter public API header. 
int h
agreed upon image height 
int repeat_pict
When decoding, this signals how much the picture must be delayed. 
send 1 frame for each frame but skips spatial interlacing check 
#define AV_PIX_FMT_GBRP10
static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)
static void fixstride(AVFilterLink *link, AVFrame *f)
static void filter_line_c(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
#define AV_PIX_FMT_YUV420P12
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src. 
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions. 
int is_disabled
the enabled state from the last expression evaluation 
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width. 
struct AVFilterGraph * graph
filtergraph this filter belongs to 
const char * name
Pad name. 
AVFilterLink ** inputs
array of pointers to input links 
#define av_assert0(cond)
assert() equivalent, that is always enabled. 
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter. 
static int request_frame(AVFilterLink *link)
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples) 
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed. 
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user). 
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals. 
int nb_threads
Maximum number of threads used by filters in this graph. 
void(* filter_line)(void *dst, void *prev, void *cur, void *next, int w, int prefs, int mrefs, int parity, int mode)
Required alignment for filter_line. 
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AVERROR_EOF
End of file. 
#define AV_LOG_VERBOSE
Detailed information. 
static void filter(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff)
static void filter_edges(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
#define AV_PIX_FMT_YUV444P16
int interlaced_frame
The content of the picture is interlaced. 
send 1 frame for each field 
#define AV_PIX_FMT_YUV422P12
A filter pad used for either input or output. 
A link between two filters. 
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples) 
uint16_t depth_minus1
Number of bits in the component minus 1. 
int width
width and height of the video frame 
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered. 
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height. 
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown; if left to 0/0, will be automatically be cop...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g. 
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter 
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert(). 
#define AV_PIX_FMT_YUV444P10
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int query_formats(AVFilterContext *ctx)
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data. 
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) 
static const AVFilterPad avfilter_vf_yadif_outputs[]
int w
agreed upon image width 
#define AV_PIX_FMT_YUV422P9
uint8_t nb_components
The number of components each pixel has, (1-4) 
#define AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GRAY16
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define FF_CEIL_RSHIFT(a, b)
static int config_props(AVFilterLink *link)
AVFilterContext * src
source filter 
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_GBRP14
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src. 
#define AV_PIX_FMT_YUV420P16
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
static const AVOption yadif_options[]
#define AV_PIX_FMT_YUV420P14
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line. 
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples) 
#define AV_PIX_FMT_YUV420P10
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) 
static int filter_frame(AVFilterLink *link, AVFrame *frame)
static const AVFilterPad inputs[]
rational number numerator/denominator 
send 1 frame for each field but skips spatial interlacing check 
const char * name
Filter name. 
AVFILTER_DEFINE_CLASS(yadif)
#define AV_PIX_FMT_YUV420P9
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
AVFilterLink ** outputs
array of pointers to output links 
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_GBRP12
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields. 
AVFilterInternal * internal
An opaque struct for libavfilter internal use. 
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes. 
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
const AVPixFmtDescriptor * csp
#define FILTER(start, end, is_not_edge)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) 
common internal and external API header 
planar GBRA 4:4:4:4 32bpp 
static void filter_edges_16bit(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) 
avfilter_execute_func * execute
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends. 
static av_cold void uninit(AVFilterContext *ctx)
int top_field_first
If the content is interlaced, is top field displayed first. 
av_cold void ff_yadif_init_x86(YADIFContext *yadif)
AVFilterContext * dst
dest filter 
send 1 frame for each frame 
#define CONST(name, help, val, unit)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) 
static int return_frame(AVFilterContext *ctx, int is_second)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link. 
only deinterlace frames marked as interlaced 
AVPixelFormat
Pixel format. 
#define AV_PIX_FMT_YUV422P16
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst. 
#define AV_NOPTS_VALUE
Undefined timestamp value. 
static void filter_line_c_16bit(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)