Go to the documentation of this file.
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;\
47 #define FILTER(start, end, is_not_edge) \
48 for (x = start; x < end; x++) { \
50 int d = (prev2[0] + next2[0])>>1; \
52 int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
53 int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
54 int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
55 int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
56 int spatial_pred = (c+e) >> 1; \
59 int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
60 + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
61 CHECK(-1) CHECK(-2) }} }} \
62 CHECK( 1) CHECK( 2) }} }} \
66 int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
67 int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
68 int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
69 int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
71 diff = FFMAX3(diff, min, -max); \
74 if (spatial_pred > d + diff) \
75 spatial_pred = d + diff; \
76 else if (spatial_pred < d - diff) \
77 spatial_pred = d - diff; \
79 dst[0] = spatial_pred; \
90 void *prev1,
void *cur1,
void *next1,
94 uint8_t *prev = prev1;
96 uint8_t *next = next1;
98 uint8_t *prev2 =
parity ? prev : cur ;
99 uint8_t *next2 =
parity ? cur : next;
109 static void filter_edges(
void *dst1,
void *prev1,
void *cur1,
void *next1,
113 uint8_t *prev = prev1;
115 uint8_t *next = next1;
117 uint8_t *prev2 =
parity ? prev : cur ;
118 uint8_t *next2 =
parity ? cur : next;
128 prev = (uint8_t*)prev1 +
offset;
129 cur = (uint8_t*)cur1 +
offset;
130 next = (uint8_t*)next1 +
offset;
131 prev2 = (uint8_t*)(
parity ? prev : cur);
132 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;
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;
178 prev = (uint16_t*)prev1 +
offset;
179 cur = (uint16_t*)cur1 +
offset;
180 next = (uint16_t*)next1 +
offset;
181 prev2 = (uint16_t*)(
parity ? prev : cur);
182 next2 = (uint16_t*)(
parity ? cur : next);
193 int refs =
s->cur->linesize[td->
plane];
194 int df = (
s->csp->comp[td->
plane].depth + 7) / 8;
197 int slice_end = (td->
h * (jobnr+1)) / nb_jobs;
205 if ((y ^ td->
parity) & 1) {
206 uint8_t *prev = &
s->prev->data[td->
plane][y * refs];
207 uint8_t *cur = &
s->cur ->data[td->
plane][y * refs];
208 uint8_t *next = &
s->next->data[td->
plane][y * refs];
210 int mode = y == 1 || y + 2 == td->
h ? 2 :
s->mode;
211 s->filter_line(
dst + pix_3, prev + pix_3, cur + pix_3,
212 next + pix_3, td->
w - edge,
213 y + 1 < td->
h ? refs : -refs,
216 s->filter_edges(
dst, prev, cur, next, td->
w,
217 y + 1 < td->
h ? refs : -refs,
222 &
s->cur->data[td->
plane][y * refs], td->
w *
df);
239 if (
i == 1 ||
i == 2) {
284 if (
s->csp->comp[0].depth > 8) {
av_cold void ff_yadif_init_x86(YADIFContext *yadif)
AVPixelFormat
Pixel format.
#define FILTER_PIXFMTS_ARRAY(array)
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
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
#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.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int ff_yadif_config_output_common(AVFilterLink *outlink)
#define AV_PIX_FMT_GBRP14
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
@ 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
static enum AVPixelFormat pix_fmts[]
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
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)
#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_OUTPUTS(array)
@ 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)
@ 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
@ 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.
static int config_output(AVFilterLink *outlink)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
int format
agreed upon media format
#define AV_PIX_FMT_YUV422P12
static const AVFilterPad avfilter_vf_yadif_outputs[]
#define AV_PIX_FMT_YUV444P12
static void filter_edges(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int parity, int mode)
AVFilterContext * src
source filter
@ 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)
static void uninit(AVBSFContext *ctx)
#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.
const AVFilter ff_vf_yadif
#define AV_PIX_FMT_YUV444P9
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
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
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static void filter(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff)
int ff_yadif_request_frame(AVFilterLink *link)
@ 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...
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void ff_yadif_uninit(AVFilterContext *ctx)
@ 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...
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)
#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