Go to the documentation of this file.
42 { int score = FFABS(cur[mrefs - 1 + (j)] - cur[prefs - 1 - (j)])\
43 + FFABS(cur[mrefs +(j)] - cur[prefs -(j)])\
44 + FFABS(cur[mrefs + 1 + (j)] - cur[prefs + 1 - (j)]);\
45 if (score < spatial_score) {\
46 spatial_score= score;\
47 spatial_pred= (cur[mrefs +(j)] + cur[prefs -(j)])>>1;\
52 #define FILTER(start, end, is_not_edge) \
53 for (x = start; x < end; x++) { \
55 int d = (prev2[0] + next2[0])>>1; \
57 int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
58 int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
59 int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
60 int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
61 int spatial_pred = (c+e) >> 1; \
64 int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
65 + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
66 CHECK(-1) CHECK(-2) }} }} \
67 CHECK( 1) CHECK( 2) }} }} \
71 int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
72 int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
73 int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
74 int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
76 diff = FFMAX3(diff, min, -max); \
79 if (spatial_pred > d + diff) \
80 spatial_pred = d + diff; \
81 else if (spatial_pred < d - diff) \
82 spatial_pred = d - diff; \
84 dst[0] = spatial_pred; \
95 void *prev1,
void *cur1,
void *next1,
114 static void filter_edges(
void *dst1,
void *prev1,
void *cur1,
void *next1,
146 void *prev1,
void *cur1,
void *next1,
147 int w,
int prefs,
int mrefs,
int parity,
150 uint16_t *dst = dst1;
151 uint16_t *prev = prev1;
152 uint16_t *cur = cur1;
153 uint16_t *next = next1;
155 uint16_t *prev2 =
parity ? prev : cur ;
156 uint16_t *next2 =
parity ? cur : next;
166 uint16_t *dst = dst1;
167 uint16_t *prev = prev1;
168 uint16_t *cur = cur1;
169 uint16_t *next = next1;
171 uint16_t *prev2 =
parity ? prev : cur ;
172 uint16_t *next2 =
parity ? cur : next;
182 dst = (uint16_t*)dst1 +
offset;
183 prev = (uint16_t*)prev1 +
offset;
184 cur = (uint16_t*)cur1 +
offset;
185 next = (uint16_t*)next1 +
offset;
186 prev2 = (uint16_t*)(
parity ? prev : cur);
187 next2 = (uint16_t*)(
parity ? cur : next);
198 int refs =
s->cur->linesize[
td->plane];
199 int df = (
s->csp->comp[
td->plane].depth + 7) / 8;
201 int slice_start = (
td->h * jobnr ) / nb_jobs;
209 for (y = slice_start; y <
slice_end; y++) {
210 if ((y ^
td->parity) & 1) {
211 uint8_t *prev = &
s->prev->data[
td->plane][y * refs];
212 uint8_t *cur = &
s->cur ->data[
td->plane][y * refs];
213 uint8_t *next = &
s->next->data[
td->plane][y * refs];
214 uint8_t *dst = &
td->frame->data[
td->plane][y *
td->frame->linesize[
td->plane]];
215 int mode = y == 1 || y + 2 ==
td->h ? 2 :
s->mode;
216 s->filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
217 next + pix_3,
td->w - edge,
218 y + 1 <
td->h ? refs : -refs,
221 s->filter_edges(dst, prev, cur, next,
td->w,
222 y + 1 <
td->h ? refs : -refs,
226 memcpy(&
td->frame->data[
td->plane][y *
td->frame->linesize[
td->plane]],
227 &
s->cur->data[
td->plane][y * refs],
td->w *
df);
244 if (
i == 1 ||
i == 2) {
323 link->time_base.num =
ctx->inputs[0]->time_base.num;
324 link->time_base.den =
ctx->inputs[0]->time_base.den * 2;
339 if (
s->csp->comp[0].depth > 8) {
av_cold void ff_yadif_init_x86(YADIFContext *yadif)
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
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static void filter_line_c_16bit(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
const AVPixFmtDescriptor * csp
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
static int query_formats(AVFilterContext *ctx)
#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.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
A link between two filters.
#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_YUV422P9
#define AV_PIX_FMT_GRAY16
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const AVFilterPad avfilter_vf_yadif_inputs[]
#define AV_PIX_FMT_YUV422P16
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
@ 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 av_cold void uninit(AVFilterContext *ctx)
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
static const AVFilterPad outputs[]
static enum AVPixelFormat pix_fmts[]
#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)
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
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static void filter_line_c(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
uint8_t nb_components
The number of components each pixel has, (1-4)
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 char * av_default_item_name(void *ptr)
Return the context name.
#define AV_PIX_FMT_YUV422P10
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_CLASS_CATEGORY_FILTER
const AVOption ff_yadif_options[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_YUV422P12
static const AVFilterPad avfilter_vf_yadif_outputs[]
#define AV_PIX_FMT_YUV444P12
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
static void filter_edges(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
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 offset
#define FILTER(start, end, is_not_edge)
#define i(width, name, range_min, range_max)
#define AV_PIX_FMT_GBRP12
static void filter_edges_16bit(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Used for passing data between threads.
@ 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
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
static void filter(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff)
int ff_yadif_request_frame(AVFilterLink *link)
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ 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...
static int config_props(AVFilterLink *link)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static const AVClass yadif_class
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define flags(name, subs,...)
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define AV_PIX_FMT_YUV444P14
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