Go to the documentation of this file.
52 #define OFFSET(x) offsetof(W3FDIFContext, x)
53 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
54 #define CONST(name, help, val, u) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, .unit = u }
61 CONST(
"frame",
"send one frame for each frame", 0,
"mode"),
62 CONST(
"field",
"send one frame for each field", 1,
"mode"),
64 CONST(
"tff",
"assume top field first", 0,
"parity"),
65 CONST(
"bff",
"assume bottom field first", 1,
"parity"),
66 CONST(
"auto",
"auto detect parity", -1,
"parity"),
68 CONST(
"all",
"deinterlace all frames", 0,
"deint"),
69 CONST(
"interlaced",
"only deinterlace frames marked as interlaced", 1,
"deint"),
102 uint8_t *in_lines_cur[2],
103 const int16_t *coef,
int linesize)
107 for (
i = 0;
i < linesize;
i++) {
108 *work_line = *in_lines_cur[0]++ * coef[0];
109 *work_line++ += *in_lines_cur[1]++ * coef[1];
114 uint8_t *in_lines_cur[4],
115 const int16_t *coef,
int linesize)
119 for (
i = 0;
i < linesize;
i++) {
120 *work_line = *in_lines_cur[0]++ * coef[0];
121 *work_line += *in_lines_cur[1]++ * coef[1];
122 *work_line += *in_lines_cur[2]++ * coef[2];
123 *work_line++ += *in_lines_cur[3]++ * coef[3];
128 uint8_t *in_lines_cur[3],
129 uint8_t *in_lines_adj[3],
130 const int16_t *coef,
int linesize)
134 for (
i = 0;
i < linesize;
i++) {
135 *work_line += *in_lines_cur[0]++ * coef[0];
136 *work_line += *in_lines_adj[0]++ * coef[0];
137 *work_line += *in_lines_cur[1]++ * coef[1];
138 *work_line += *in_lines_adj[1]++ * coef[1];
139 *work_line += *in_lines_cur[2]++ * coef[2];
140 *work_line++ += *in_lines_adj[2]++ * coef[2];
145 uint8_t *in_lines_cur[5],
146 uint8_t *in_lines_adj[5],
147 const int16_t *coef,
int linesize)
151 for (
i = 0;
i < linesize;
i++) {
152 *work_line += *in_lines_cur[0]++ * coef[0];
153 *work_line += *in_lines_adj[0]++ * coef[0];
154 *work_line += *in_lines_cur[1]++ * coef[1];
155 *work_line += *in_lines_adj[1]++ * coef[1];
156 *work_line += *in_lines_cur[2]++ * coef[2];
157 *work_line += *in_lines_adj[2]++ * coef[2];
158 *work_line += *in_lines_cur[3]++ * coef[3];
159 *work_line += *in_lines_adj[3]++ * coef[3];
160 *work_line += *in_lines_cur[4]++ * coef[4];
161 *work_line++ += *in_lines_adj[4]++ * coef[4];
169 for (j = 0; j < linesize; j++, out_pixel++, work_pixel++)
170 *out_pixel =
av_clip(*work_pixel, 0, 255 * 256 * 128) >> 15;
174 uint8_t *in_lines_cur8[2],
175 const int16_t *coef,
int linesize)
177 uint16_t *in_lines_cur[2] = { (uint16_t *)in_lines_cur8[0], (uint16_t *)in_lines_cur8[1] };
181 for (
i = 0;
i < linesize;
i++) {
182 *work_line = *in_lines_cur[0]++ * coef[0];
183 *work_line++ += *in_lines_cur[1]++ * coef[1];
188 uint8_t *in_lines_cur8[4],
189 const int16_t *coef,
int linesize)
191 uint16_t *in_lines_cur[4] = { (uint16_t *)in_lines_cur8[0],
192 (uint16_t *)in_lines_cur8[1],
193 (uint16_t *)in_lines_cur8[2],
194 (uint16_t *)in_lines_cur8[3] };
198 for (
i = 0;
i < linesize;
i++) {
199 *work_line = *in_lines_cur[0]++ * coef[0];
200 *work_line += *in_lines_cur[1]++ * coef[1];
201 *work_line += *in_lines_cur[2]++ * coef[2];
202 *work_line++ += *in_lines_cur[3]++ * coef[3];
207 uint8_t *in_lines_cur8[3],
208 uint8_t *in_lines_adj8[3],
209 const int16_t *coef,
int linesize)
211 uint16_t *in_lines_cur[3] = { (uint16_t *)in_lines_cur8[0],
212 (uint16_t *)in_lines_cur8[1],
213 (uint16_t *)in_lines_cur8[2] };
214 uint16_t *in_lines_adj[3] = { (uint16_t *)in_lines_adj8[0],
215 (uint16_t *)in_lines_adj8[1],
216 (uint16_t *)in_lines_adj8[2] };
220 for (
i = 0;
i < linesize;
i++) {
221 *work_line += *in_lines_cur[0]++ * coef[0];
222 *work_line += *in_lines_adj[0]++ * coef[0];
223 *work_line += *in_lines_cur[1]++ * coef[1];
224 *work_line += *in_lines_adj[1]++ * coef[1];
225 *work_line += *in_lines_cur[2]++ * coef[2];
226 *work_line++ += *in_lines_adj[2]++ * coef[2];
231 uint8_t *in_lines_cur8[5],
232 uint8_t *in_lines_adj8[5],
233 const int16_t *coef,
int linesize)
235 uint16_t *in_lines_cur[5] = { (uint16_t *)in_lines_cur8[0],
236 (uint16_t *)in_lines_cur8[1],
237 (uint16_t *)in_lines_cur8[2],
238 (uint16_t *)in_lines_cur8[3],
239 (uint16_t *)in_lines_cur8[4] };
240 uint16_t *in_lines_adj[5] = { (uint16_t *)in_lines_adj8[0],
241 (uint16_t *)in_lines_adj8[1],
242 (uint16_t *)in_lines_adj8[2],
243 (uint16_t *)in_lines_adj8[3],
244 (uint16_t *)in_lines_adj8[4] };
248 for (
i = 0;
i < linesize;
i++) {
249 *work_line += *in_lines_cur[0]++ * coef[0];
250 *work_line += *in_lines_adj[0]++ * coef[0];
251 *work_line += *in_lines_cur[1]++ * coef[1];
252 *work_line += *in_lines_adj[1]++ * coef[1];
253 *work_line += *in_lines_cur[2]++ * coef[2];
254 *work_line += *in_lines_adj[2]++ * coef[2];
255 *work_line += *in_lines_cur[3]++ * coef[3];
256 *work_line += *in_lines_adj[3]++ * coef[3];
257 *work_line += *in_lines_cur[4]++ * coef[4];
258 *work_line++ += *in_lines_adj[4]++ * coef[4];
264 uint16_t *out_pixel = (uint16_t *)out_pixel8;
268 for (j = 0; j < linesize; j++, out_pixel++, work_pixel++)
269 *out_pixel =
av_clip(*work_pixel, 0,
max) >> 15;
277 int ret,
i, depth, nb_threads;
283 s->planeheight[0] =
s->planeheight[3] =
inlink->h;
292 s->work_line =
av_calloc(nb_threads,
sizeof(*
s->work_line));
295 s->nb_threads = nb_threads;
297 for (
i = 0;
i <
s->nb_threads;
i++) {
299 if (!
s->work_line[
i])
303 depth =
desc->comp[0].depth;
304 s->max = ((1 << depth) - 1) * 256 * 128;
348 static const int16_t
coef_lf[2][4] = {{ 16384, 16384, 0, 0},
349 { -852, 17236, 17236, -852}};
351 static const int16_t
coef_hf[2][5] = {{ -2048, 4096, -2048, 0, 0},
352 { 1016, -3801, 5570, -3801, 1016}};
359 int jobnr,
int nb_jobs,
int plane)
367 uint8_t *in_line, *in_lines_cur[5], *in_lines_adj[5];
368 uint8_t *out_line, *out_pixel;
369 int32_t *work_line, *work_pixel;
370 uint8_t *cur_data = cur->
data[plane];
371 uint8_t *adj_data = adj->
data[plane];
372 uint8_t *dst_data =
out->data[plane];
373 const int linesize =
s->linesize[plane];
374 const int height =
s->planeheight[plane];
375 const int cur_line_stride = cur->
linesize[plane];
376 const int adj_line_stride = adj->
linesize[plane];
377 const int dst_line_stride =
out->linesize[plane];
378 const int start = (
height * jobnr) / nb_jobs;
379 const int end = (
height * (jobnr+1)) / nb_jobs;
380 const int max =
s->max;
387 y_out = start + (tff ^ (start & 1));
389 in_line = cur_data + (y_out * cur_line_stride);
390 out_line = dst_data + (y_out * dst_line_stride);
392 while (y_out < end) {
393 memcpy(out_line, in_line, linesize);
395 in_line += cur_line_stride * 2;
396 out_line += dst_line_stride * 2;
400 y_out = start + ((!tff) ^ (start & 1));
402 out_line = dst_data + (y_out * dst_line_stride);
404 while (y_out < end) {
414 in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
417 work_line =
s->work_line[jobnr];
420 s->dsp.filter_simple_low(work_line, in_lines_cur,
424 s->dsp.filter_complex_low(work_line, in_lines_cur,
437 in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
438 in_lines_adj[j] = adj_data + (y_in * adj_line_stride);
441 work_line =
s->work_line[jobnr];
444 s->dsp.filter_simple_high(work_line, in_lines_cur, in_lines_adj,
448 s->dsp.filter_complex_high(work_line, in_lines_cur, in_lines_adj,
453 work_pixel =
s->work_line[jobnr];
454 out_pixel = out_line;
456 s->dsp.filter_scale(out_pixel, work_pixel, linesize,
max);
460 out_line += dst_line_stride * 2;
467 int jobnr,
int nb_jobs)
471 for (
int p = 0; p <
s->nb_planes; p++)
488 #if FF_API_INTERLACED_FRAME
490 out->interlaced_frame = 0;
503 out->pts = cur_pts + next_pts;
509 adj =
s->field ?
s->next :
s->prev;
512 FFMIN(
s->planeheight[1],
s->nb_threads));
515 s->field = !
s->field;
552 if (ret < 0 || s->
mode == 0)
573 next->
pts =
s->next->pts * 2 -
s->cur->pts;
576 }
else if (
ret < 0) {
592 for (
i = 0;
i <
s->nb_threads;
i++)
620 .priv_class = &w3fdif_class,
int linesize[4]
bytes of pixel data per line for each plane
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_GBRAP16
#define FF_ENABLE_DEPRECATION_WARNINGS
int parity
frame field parity
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
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AVERROR_EOF
End of file.
#define FILTER_PIXFMTS_ARRAY(array)
void ff_w3fdif_init_x86(W3FDIFDSPContext *dsp, int depth)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
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.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV420P10
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
static int request_frame(AVFilterLink *outlink)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
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.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
int filter
0 is simple, 1 is more complex
static const int16_t coef_hf[2][5]
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
#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
#define AV_PIX_FMT_GRAY16
static const AVFilterPad w3fdif_outputs[]
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
static int config_input(AVFilterLink *inlink)
@ 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 av_cold void uninit(AVFilterContext *ctx)
static void filter16_scale(uint8_t *out_pixel8, const int32_t *work_pixel, int linesize, int max)
static enum AVPixelFormat pix_fmts[]
#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...
#define AV_PIX_FMT_GBRAP10
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
#define AV_PIX_FMT_GBRAP12
@ 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 deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static void filter_simple_high(int32_t *work_line, uint8_t *in_lines_cur[3], uint8_t *in_lines_adj[3], const int16_t *coef, int linesize)
static const int16_t coef_lf[2][4]
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
#define AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_GRAY14
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
static void filter_complex_low(int32_t *work_line, uint8_t *in_lines_cur[4], const int16_t *coef, int linesize)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_INPUTS(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_GRAY10
#define AV_PIX_FMT_GBRP16
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
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...
#define AV_PIX_FMT_YUV440P10
int32_t ** work_line
lines we are calculating
#define AV_PIX_FMT_YUV422P10
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
int deint
which frames to deinterlace
static int config_output(AVFilterLink *outlink)
static const AVFilterPad w3fdif_inputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVFILTER_DEFINE_CLASS(w3fdif)
#define AV_PIX_FMT_YUV422P12
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_PIX_FMT_YUV444P12
static void filter16_complex_high(int32_t *work_line, uint8_t *in_lines_cur8[5], uint8_t *in_lines_adj8[5], const int16_t *coef, int linesize)
AVFilterContext * src
source filter
static void filter_scale(uint8_t *out_pixel, const int32_t *work_pixel, int linesize, int max)
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
static void filter_simple_low(int32_t *work_line, uint8_t *in_lines_cur[2], const int16_t *coef, int linesize)
@ 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 const AVOption w3fdif_options[]
const AVFilter ff_vf_w3fdif
#define i(width, name, range_min, range_max)
int w
agreed upon image width
#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.
@ 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_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
void * av_calloc(size_t nmemb, size_t size)
#define AV_PIX_FMT_YUV444P9
int field
which field are we on, 0 or 1
#define AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUV420P12
int planeheight[4]
height of each plane
#define AV_PIX_FMT_YUV422P14
static void filter16_complex_low(int32_t *work_line, uint8_t *in_lines_cur8[4], const int16_t *coef, int linesize)
int h
agreed upon image height
static void filter16_simple_high(int32_t *work_line, uint8_t *in_lines_cur8[3], uint8_t *in_lines_adj8[3], const int16_t *coef, int linesize)
AVFrame * next
previous, current, next frames
#define AV_PIX_FMT_YUVA422P12
static void filter16_simple_low(int32_t *work_line, uint8_t *in_lines_cur8[2], const int16_t *coef, int linesize)
static void filter_complex_high(int32_t *work_line, uint8_t *in_lines_cur[5], uint8_t *in_lines_adj[5], const int16_t *coef, int linesize)
int mode
0 is frame, 1 is field
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
static const int8_t n_coef_lf[2]
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static int filter(AVFilterContext *ctx, int is_second)
#define FF_DISABLE_DEPRECATION_WARNINGS
@ 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)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
static int deinterlace_plane_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs, int plane)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#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_YUV440P12
#define AV_PIX_FMT_YUV444P14
#define CONST(name, help, val, u)
#define AV_PIX_FMT_GRAY12
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static const int8_t n_coef_hf[2]
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14