22 #include "libavutil/cpu.h"
23 #include "libavutil/common.h"
24 #include "libavutil/opt.h"
25 #include "libavutil/pixdesc.h"
44 { int score = FFABS(cur[mrefs - 1 + (j)] - cur[prefs - 1 - (j)])\
45 + FFABS(cur[mrefs +(j)] - cur[prefs -(j)])\
46 + FFABS(cur[mrefs + 1 + (j)] - cur[prefs + 1 - (j)]);\
47 if (score < spatial_score) {\
48 spatial_score= score;\
49 spatial_pred= (cur[mrefs +(j)] + cur[prefs -(j)])>>1;\
54 #define FILTER(start, end, is_not_edge) \
55 for (x = start; x < end; x++) { \
57 int d = (prev2[0] + next2[0])>>1; \
59 int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
60 int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
61 int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
62 int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
63 int spatial_pred = (c+e) >> 1; \
66 int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
67 + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
68 CHECK(-1) CHECK(-2) }} }} \
69 CHECK( 1) CHECK( 2) }} }} \
73 int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
74 int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
75 int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
76 int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
78 diff = FFMAX3(diff, min, -max); \
81 if (spatial_pred > d + diff) \
82 spatial_pred = d + diff; \
83 else if (spatial_pred < d - diff) \
84 spatial_pred = d - diff; \
86 dst[0] = spatial_pred; \
97 void *prev1,
void *cur1,
void *next1,
98 int w,
int prefs,
int mrefs,
int parity,
int mode)
105 uint8_t *prev2 = parity ? prev : cur ;
106 uint8_t *next2 = parity ? cur : next;
115 static void filter_edges(
void *dst1,
void *prev1,
void *cur1,
void *next1,
116 int w,
int prefs,
int mrefs,
int parity,
int mode)
123 uint8_t *prev2 = parity ? prev : cur ;
124 uint8_t *next2 = parity ? cur : next;
131 prev = (
uint8_t*)prev1 + w - 3;
133 next = (
uint8_t*)next1 + w - 3;
134 prev2 = (
uint8_t*)(parity ? prev : cur);
135 next2 = (
uint8_t*)(parity ? cur : next);
142 void *prev1,
void *cur1,
void *next1,
143 int w,
int prefs,
int mrefs,
int parity,
146 uint16_t *dst = dst1;
147 uint16_t *prev = prev1;
148 uint16_t *cur = cur1;
149 uint16_t *next = next1;
151 uint16_t *prev2 = parity ? prev : cur ;
152 uint16_t *next2 = parity ? cur : next;
160 int w,
int prefs,
int mrefs,
int parity,
int mode)
162 uint16_t *dst = dst1;
163 uint16_t *prev = prev1;
164 uint16_t *cur = cur1;
165 uint16_t *next = next1;
167 uint16_t *prev2 = parity ? prev : cur ;
168 uint16_t *next2 = parity ? cur : next;
174 dst = (uint16_t*)dst1 + w - 3;
175 prev = (uint16_t*)prev1 + w - 3;
176 cur = (uint16_t*)cur1 + w - 3;
177 next = (uint16_t*)next1 + w - 3;
178 prev2 = (uint16_t*)(parity ? prev : cur);
179 next2 = (uint16_t*)(parity ? cur : next);
191 int slice_h = td->
h / nb_jobs;
192 int slice_start = jobnr * slice_h;
193 int slice_end = (jobnr == nb_jobs - 1) ? td->
h : (jobnr + 1) * slice_h;
199 for (y = slice_start; y <
slice_end; y++) {
200 if ((y ^ td->
parity) & 1) {
205 int mode = y == 1 || y + 2 == td->
h ? 2 : s->
mode;
206 s->
filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
207 next + pix_3, td->
w - 6,
208 y + 1 < td->
h ? refs : -refs,
212 y + 1 < td->
h ? refs : -refs,
231 int w = dstpic->
width;
234 if (i == 1 || i == 2) {
262 for (i = 0; i < 3; i++)
274 if (yadif->
parity == -1) {
290 filter(ctx, yadif->
out, tff ^ !is_second, tff);
293 int64_t cur_pts = yadif->
cur->
pts;
294 int64_t next_pts = yadif->
next->
pts;
297 yadif->
out->
pts = cur_pts + next_pts;
381 }
else if (ret < 0) {
384 }
while (!yadif->
cur);
402 if (val == 1 && !yadif->
next) {
409 assert(yadif->
next || !val);
414 return val * ((yadif->
mode&1)+1);
480 #define OFFSET(x) offsetof(YADIFContext, x)
481 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
525 .priv_class = &yadif_class,
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static const AVFilterPad avfilter_vf_yadif_inputs[]
This structure describes decoded (raw) audio or video data.
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
const char * name
Filter name.
void * priv
private data for use by the filter
static const AVFilterPad outputs[]
int h
agreed upon image height
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
static const AVOption options[]
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
static void filter_line_c(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
static const AVClass yadif_class
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static int request_frame(AVFilterLink *link)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
int nb_threads
Maximum number of threads used by filters in this graph.
#define AVERROR_EOF
End of file.
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)
int interlaced_frame
The content of the picture is interlaced.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
A link between two filters.
uint16_t depth_minus1
Number of bits in the component minus 1.
int width
width and height of the video frame
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
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. ...
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
AVFilterContext * src
source filter
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int query_formats(AVFilterContext *ctx)
AVPixelFormat
Pixel format.
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_outputs[]
int w
agreed upon image width
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)
static int config_props(AVFilterLink *link)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
int format
agreed upon media format
Main libavfilter public API header.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
AVFilterLink ** outputs
array of pointers to output links
static int poll_frame(AVFilterLink *link)
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
Describe the class of an AVClass context structure.
static int filter_frame(AVFilterLink *link, AVFrame *frame)
static const AVFilterPad inputs[]
AVFilterLink ** inputs
array of pointers to input links
int parity
0: top field first 1: bottom field first -1: auto-detection
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
AVFilterContext * dst
dest filter
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
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.
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
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:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
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:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
struct AVFilterGraph * graph
filtergraph this filter belongs to
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
avfilter_execute_func * execute
struct AVFilterPad AVFilterPad
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Y , 16bpp, little-endian.
static AVFrame * get_video_buffer(AVFilterLink *link, int w, int h)
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)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
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.
av_default_item_name
Return the context name.
int ff_poll_frame(AVFilterLink *link)
Poll a frame from the filter chain.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int mode
0: send 1 frame for each frame 1: send 1 frame for each field 2: like 0 but skips spatial interlacing...
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)