Go to the documentation of this file.
47 static const uint16_t
coef_lf[2] = { 4309, 213 };
48 static const uint16_t
coef_hf[3] = { 5570, 3801, 1016 };
49 static const uint16_t
coef_sp[2] = { 5077, 981 };
59 #define FILTER_INTRA() \
60 for (x = 0; x < w; x++) { \
61 interpol = (coef_sp[0] * (cur[mrefs] + cur[prefs]) - coef_sp[1] * (cur[mrefs3] + cur[prefs3])) >> 13; \
62 dst[0] = av_clip(interpol, 0, clip_max); \
69 for (x = 0; x < w; x++) { \
71 int d = (prev2[0] + next2[0]) >> 1; \
73 int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
74 int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e)) >> 1; \
75 int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e)) >> 1; \
76 int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
82 #define SPAT_CHECK() \
83 int b = ((prev2[mrefs2] + next2[mrefs2]) >> 1) - c; \
84 int f = ((prev2[prefs2] + next2[prefs2]) >> 1) - e; \
87 int max = FFMAX3(de, dc, FFMIN(b, f)); \
88 int min = FFMIN3(de, dc, FFMAX(b, f)); \
89 diff = FFMAX3(diff, min, -max);
91 #define FILTER_LINE() \
93 if (FFABS(c - e) > temporal_diff0) { \
94 interpol = (((coef_hf[0] * (prev2[0] + next2[0]) \
95 - coef_hf[1] * (prev2[mrefs2] + next2[mrefs2] + prev2[prefs2] + next2[prefs2]) \
96 + coef_hf[2] * (prev2[mrefs4] + next2[mrefs4] + prev2[prefs4] + next2[prefs4])) >> 2) \
97 + coef_lf[0] * (c + e) - coef_lf[1] * (cur[mrefs3] + cur[prefs3])) >> 13; \
99 interpol = (coef_sp[0] * (c + e) - coef_sp[1] * (cur[mrefs3] + cur[prefs3])) >> 13; \
102 #define FILTER_EDGE() \
106 interpol = (c + e) >> 1;
109 if (interpol > d + diff) \
110 interpol = d + diff; \
111 else if (interpol < d - diff) \
112 interpol = d - diff; \
114 dst[0] = av_clip(interpol, 0, clip_max); \
125 static void filter_intra(
void *dst1,
void *cur1,
int w,
int prefs,
int mrefs,
126 int prefs3,
int mrefs3,
int parity,
int clip_max)
136 int w,
int prefs,
int mrefs,
int prefs2,
int mrefs2,
137 int prefs3,
int mrefs3,
int prefs4,
int mrefs4,
141 uint8_t *prev = prev1;
143 uint8_t *next = next1;
144 uint8_t *prev2 =
parity ? prev : cur ;
145 uint8_t *next2 =
parity ? cur : next;
153 static void filter_edge(
void *dst1,
void *prev1,
void *cur1,
void *next1,
154 int w,
int prefs,
int mrefs,
int prefs2,
int mrefs2,
155 int parity,
int clip_max,
int spat)
158 uint8_t *prev = prev1;
160 uint8_t *next = next1;
161 uint8_t *prev2 =
parity ? prev : cur ;
162 uint8_t *next2 =
parity ? cur : next;
171 int prefs3,
int mrefs3,
int parity,
int clip_max)
173 uint16_t *dst = dst1;
174 uint16_t *cur = cur1;
181 int w,
int prefs,
int mrefs,
int prefs2,
int mrefs2,
182 int prefs3,
int mrefs3,
int prefs4,
int mrefs4,
185 uint16_t *dst = dst1;
186 uint16_t *prev = prev1;
187 uint16_t *cur = cur1;
188 uint16_t *next = next1;
189 uint16_t *prev2 =
parity ? prev : cur ;
190 uint16_t *next2 =
parity ? cur : next;
199 int w,
int prefs,
int mrefs,
int prefs2,
int mrefs2,
200 int parity,
int clip_max,
int spat)
202 uint16_t *dst = dst1;
203 uint16_t *prev = prev1;
204 uint16_t *cur = cur1;
205 uint16_t *next = next1;
206 uint16_t *prev2 =
parity ? prev : cur ;
207 uint16_t *next2 =
parity ? cur : next;
223 int refs = linesize /
df;
224 int slice_start = (
td->h * jobnr ) / nb_jobs;
228 for (y = slice_start; y <
slice_end; y++) {
229 if ((y ^
td->parity) & 1) {
230 uint8_t *prev = &yadif->
prev->
data[
td->plane][y * linesize];
231 uint8_t *cur = &yadif->
cur ->
data[
td->plane][y * linesize];
232 uint8_t *next = &yadif->
next->
data[
td->plane][y * linesize];
233 uint8_t *dst = &
td->frame->data[
td->plane][y *
td->frame->linesize[
td->plane]];
235 s->filter_intra(dst, cur,
td->w, (y +
df) <
td->h ? refs : -refs,
236 y > (
df - 1) ? -refs : refs,
237 (y + 3*
df) <
td->h ? 3 * refs : -refs,
238 y > (3*
df - 1) ? -3 * refs : refs,
239 td->parity ^
td->tff, clip_max);
240 }
else if ((y < 4) || ((y + 5) >
td->h)) {
241 s->filter_edge(dst, prev, cur, next,
td->w,
242 (y +
df) <
td->h ? refs : -refs,
243 y > (
df - 1) ? -refs : refs,
244 refs << 1, -(refs << 1),
245 td->parity ^
td->tff, clip_max,
246 (y < 2) || ((y + 3) >
td->h) ? 0 : 1);
248 s->filter_line(dst, prev, cur, next,
td->w,
249 refs, -refs, refs << 1, -(refs << 1),
250 3 * refs, -3 * refs, refs << 2, -(refs << 2),
251 td->parity ^
td->tff, clip_max);
254 memcpy(&
td->frame->data[
td->plane][y *
td->frame->linesize[
td->plane]],
273 if (
i == 1 ||
i == 2) {
360 #define OFFSET(x) offsetof(YADIFContext, x)
361 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
363 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
405 .priv_class = &bwdif_class,
#define AV_PIX_FMT_YUVA422P16
@ YADIF_MODE_SEND_FIELD
send 1 frame for each field
#define AV_PIX_FMT_GBRAP16
static int interpol(MBContext *s, uint32_t *color, int x, int y, int linesize)
AVPixelFormat
Pixel format.
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
static int config_props(AVFilterLink *link)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define FILTER_PIXFMTS_ARRAY(array)
const AVPixFmtDescriptor * csp
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_PIX_FMT_YUVA422P9
This structure describes decoded (raw) audio or video data.
#define AV_PIX_FMT_YUVA420P16
int depth
Number of bits in the component.
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV420P10
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * name
Filter name.
A link between two filters.
#define AV_PIX_FMT_YUVA422P10
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
@ YADIF_MODE_SEND_FRAME
send 1 frame for each frame
#define AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_GBRP14
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUV422P9
@ YADIF_PARITY_AUTO
auto detection
#define AV_PIX_FMT_GRAY16
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
static void filter_edge(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int prefs2, int mrefs2, int parity, int clip_max, int spat)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_PIX_FMT_YUV422P16
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_PIX_FMT_YUV444P16
#define AV_CEIL_RSHIFT(a, b)
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_INPUTS(array)
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
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
#define AV_PIX_FMT_GBRP16
uint8_t nb_components
The number of components each pixel has, (1-4)
static void filter_line_c(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int prefs2, int mrefs2, int prefs3, int mrefs3, int prefs4, int mrefs4, int parity, int clip_max)
Rational number (pair of numerator and denominator).
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
const AVFilter ff_vf_bwdif
AVFILTER_DEFINE_CLASS(bwdif)
#define AV_PIX_FMT_YUV422P10
void ff_bwdif_init_x86(BWDIFContext *bwdif)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
static void filter_line_c_16bit(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int prefs2, int mrefs2, int prefs3, int mrefs3, int prefs4, int mrefs4, int parity, int clip_max)
static void filter(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff)
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const uint16_t coef_sp[2]
#define AV_PIX_FMT_YUV422P12
void(* filter)(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff)
#define AV_PIX_FMT_YUV444P12
AVRational time_base
Time base for the timestamps in this frame.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
#define AV_PIX_FMT_YUVA444P10
static av_cold void uninit(AVFilterContext *ctx)
#define i(width, name, range_min, range_max)
#define AV_PIX_FMT_GBRP12
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Used for passing data between threads.
static const AVFilterPad avfilter_vf_bwdif_outputs[]
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
const char * name
Pad name.
#define AV_PIX_FMT_YUV444P9
static const AVOption bwdif_options[]
static enum AVPixelFormat pix_fmts[]
@ YADIF_DEINT_ALL
deinterlace all frames
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
@ YADIF_FIELD_END
The first or last field in a sequence.
int ff_yadif_request_frame(AVFilterLink *link)
static void filter_intra(void *dst1, void *cur1, int w, int prefs, int mrefs, int prefs3, int mrefs3, int parity, int clip_max)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
static void filter_edge_16bit(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int prefs2, int mrefs2, int parity, int clip_max, int spat)
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
#define CONST(name, help, val, unit)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ YADIF_DEINT_INTERLACED
only deinterlace frames marked as interlaced
@ YADIF_FIELD_NORMAL
A normal field in the middle of a sequence.
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ YADIF_PARITY_TFF
top field first
int current_field
YADIFCurrentField.
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static void filter_intra_16bit(void *dst1, void *cur1, int w, int prefs, int mrefs, int prefs3, int mrefs3, int parity, int clip_max)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static const uint16_t coef_hf[3]
#define AV_PIX_FMT_YUV444P14
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static const AVFilterPad avfilter_vf_bwdif_inputs[]
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
#define AV_PIX_FMT_YUV420P14
@ YADIF_PARITY_BFF
bottom field first
static const uint16_t coef_lf[2]