34 #define PERM_RWP AV_PERM_WRITE | AV_PERM_PRESERVE | AV_PERM_REUSE
37 { int score = FFABS(cur[mrefs-1+(j)] - cur[prefs-1-(j)])\
38 + FFABS(cur[mrefs +(j)] - cur[prefs -(j)])\
39 + FFABS(cur[mrefs+1+(j)] - cur[prefs+1-(j)]);\
40 if (score < spatial_score) {\
41 spatial_score= score;\
42 spatial_pred= (cur[mrefs +(j)] + cur[prefs -(j)])>>1;\
45 for (x = 0; x < w; x++) { \
47 int d = (prev2[0] + next2[0])>>1; \
49 int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
50 int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
51 int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
52 int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
53 int spatial_pred = (c+e) >> 1; \
54 int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
55 + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
57 CHECK(-1) CHECK(-2) }} }} \
58 CHECK( 1) CHECK( 2) }} }} \
61 int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
62 int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
63 int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
64 int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
66 diff = FFMAX3(diff, min, -max); \
69 if (spatial_pred > d + diff) \
70 spatial_pred = d + diff; \
71 else if (spatial_pred < d - diff) \
72 spatial_pred = d - diff; \
74 dst[0] = spatial_pred; \
86 int w,
int prefs,
int mrefs,
int parity,
int mode)
96 uint16_t *prev, uint16_t *cur, uint16_t *next,
97 int w,
int prefs,
int mrefs,
int parity,
101 uint16_t *
prev2 = parity ? prev : cur ;
102 uint16_t *
next2 = parity ? cur : next;
121 if (i == 1 || i == 2) {
127 for (y = 0; y < h; y++) {
128 if ((y ^ parity) & 1) {
133 int mode = y == 1 || y + 2 == h ? 2 : yadif->
mode;
135 y + 1 < h ? refs : -refs,
140 &yadif->
cur->
data[i][y * refs], w * df);
161 for (i = 0; i < 3; i++)
173 if (yadif->
parity == -1) {
194 filter(ctx, yadif->
out, tff ^ !is_second, tff);
197 int64_t cur_pts = yadif->
cur->
pts;
198 int64_t next_pts = yadif->
next->
pts;
201 yadif->
out->
pts = cur_pts + next_pts;
224 yadif->
next = picref;
287 }
else if (ret < 0) {
290 }
while (!yadif->
cur);
308 if (val == 1 && !yadif->
next) {
315 assert(yadif->
next || !val);
320 return val * ((yadif->
mode&1)+1);
372 sscanf(args,
"%d:%d:%d",
426 .
inputs = avfilter_vf_yadif_inputs,
428 .
outputs = avfilter_vf_yadif_outputs,
static const AVFilterPad avfilter_vf_yadif_inputs[]
static void filter_line_c_16bit(uint16_t *dst, uint16_t *prev, uint16_t *cur, uint16_t *next, int w, int prefs, int mrefs, int parity, int mode)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static void filter(AVFilterContext *ctx, AVFilterBufferRef *dstpic, int parity, int tff)
AVFilterBufferRefVideoProps * video
video buffer specific properties
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
int linesize[8]
number of bytes per line
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static const AVFilterPad outputs[]
int h
agreed upon image height
int ff_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
Send a frame of data to the next filter.
av_cold void ff_yadif_init_x86(YADIFContext *yadif)
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
#define AV_PERM_READ
can read from the buffer
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
AVFilterBufferRef * ff_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
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.
int top_field_first
field order
static int filter_frame(AVFilterLink *link, AVFilterBufferRef *picref)
void avfilter_unref_bufferp(AVFilterBufferRef **ref)
Remove a reference to a buffer and set the pointer to NULL.
void(* filter_line)(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, int w, int prefs, int mrefs, int parity, int mode)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
int64_t pts
presentation timestamp.
A filter pad used for either input or output.
A link between two filters.
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
AVFilterBufferRef * ff_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
uint16_t depth_minus1
number of bits in the component minus 1
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
#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
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
void av_log(void *avcl, int level, const char *fmt,...)
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
static int query_formats(AVFilterContext *ctx)
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
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
Add a new reference to a buffer.
int auto_enable
0: deinterlace all frames 1: only deinterlace frames marked as interlaced
uint8_t nb_components
The number of components each pixel has, (1-4)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
static int config_props(AVFilterLink *link)
AVFilterContext * src
source filter
static void filter_line_c(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, int w, int prefs, int mrefs, int parity, int mode)
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
int format
agreed upon media format
static int poll_frame(AVFilterLink *link)
A reference to an AVFilterBuffer.
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static const AVFilterPad inputs[]
AVFilter avfilter_vf_yadif
int parity
0: top field first 1: bottom field first -1: auto-detection
const char * name
filter name
AVFilterLink ** outputs
array of pointers to output links
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
const AVPixFmtDescriptor * csp
static AVFilterBufferRef * get_video_buffer(AVFilterLink *link, int perms, int w, int h)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
int interlaced
is frame interlaced
common internal and external API header
void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
Copy properties of src to dst, without copying the actual data.
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static av_cold void uninit(AVFilterContext *ctx)
AVFilterContext * dst
dest filter
Y , 16bpp, little-endian.
uint8_t * data[8]
picture/audio data for each plane
static av_cold int init(AVFilterContext *ctx, const char *args)
struct YADIFContext YADIFContext
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.
int ff_poll_frame(AVFilterLink *link)
Poll a frame from the filter chain.
AVPixelFormat
Pixel format.
int mode
0: send 1 frame for each frame 1: send 1 frame for each field 2: like 0 but skips spatial interlacing...
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian