51 #define OFFSET(x) offsetof(W3FDIFContext, x) 52 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 53 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit } 60 CONST(
"all",
"deinterlace all frames", 0,
"deint"),
61 CONST(
"interlaced",
"only deinterlace frames marked as interlaced", 1,
"deint"),
104 *work_line = *in_lines_cur[0]++ * coef[0];
105 *work_line++ += *in_lines_cur[1]++ * coef[1];
116 *work_line = *in_lines_cur[0]++ * coef[0];
117 *work_line += *in_lines_cur[1]++ * coef[1];
118 *work_line += *in_lines_cur[2]++ * coef[2];
119 *work_line++ += *in_lines_cur[3]++ * coef[3];
131 *work_line += *in_lines_cur[0]++ * coef[0];
132 *work_line += *in_lines_adj[0]++ * coef[0];
133 *work_line += *in_lines_cur[1]++ * coef[1];
134 *work_line += *in_lines_adj[1]++ * coef[1];
135 *work_line += *in_lines_cur[2]++ * coef[2];
136 *work_line++ += *in_lines_adj[2]++ * coef[2];
148 *work_line += *in_lines_cur[0]++ * coef[0];
149 *work_line += *in_lines_adj[0]++ * coef[0];
150 *work_line += *in_lines_cur[1]++ * coef[1];
151 *work_line += *in_lines_adj[1]++ * coef[1];
152 *work_line += *in_lines_cur[2]++ * coef[2];
153 *work_line += *in_lines_adj[2]++ * coef[2];
154 *work_line += *in_lines_cur[3]++ * coef[3];
155 *work_line += *in_lines_adj[3]++ * coef[3];
156 *work_line += *in_lines_cur[4]++ * coef[4];
157 *work_line++ += *in_lines_adj[4]++ * coef[4];
165 for (j = 0; j <
linesize; j++, out_pixel++, work_pixel++)
166 *out_pixel = av_clip(*work_pixel, 0, 255 * 256 * 128) >> 15;
173 uint16_t *in_lines_cur[2] = { (uint16_t *)in_lines_cur8[0], (uint16_t *)in_lines_cur8[1] };
178 *work_line = *in_lines_cur[0]++ * coef[0];
179 *work_line++ += *in_lines_cur[1]++ * coef[1];
187 uint16_t *in_lines_cur[4] = { (uint16_t *)in_lines_cur8[0],
188 (uint16_t *)in_lines_cur8[1],
189 (uint16_t *)in_lines_cur8[2],
190 (uint16_t *)in_lines_cur8[3] };
195 *work_line = *in_lines_cur[0]++ * coef[0];
196 *work_line += *in_lines_cur[1]++ * coef[1];
197 *work_line += *in_lines_cur[2]++ * coef[2];
198 *work_line++ += *in_lines_cur[3]++ * coef[3];
207 uint16_t *in_lines_cur[3] = { (uint16_t *)in_lines_cur8[0],
208 (uint16_t *)in_lines_cur8[1],
209 (uint16_t *)in_lines_cur8[2] };
210 uint16_t *in_lines_adj[3] = { (uint16_t *)in_lines_adj8[0],
211 (uint16_t *)in_lines_adj8[1],
212 (uint16_t *)in_lines_adj8[2] };
217 *work_line += *in_lines_cur[0]++ * coef[0];
218 *work_line += *in_lines_adj[0]++ * coef[0];
219 *work_line += *in_lines_cur[1]++ * coef[1];
220 *work_line += *in_lines_adj[1]++ * coef[1];
221 *work_line += *in_lines_cur[2]++ * coef[2];
222 *work_line++ += *in_lines_adj[2]++ * coef[2];
231 uint16_t *in_lines_cur[5] = { (uint16_t *)in_lines_cur8[0],
232 (uint16_t *)in_lines_cur8[1],
233 (uint16_t *)in_lines_cur8[2],
234 (uint16_t *)in_lines_cur8[3],
235 (uint16_t *)in_lines_cur8[4] };
236 uint16_t *in_lines_adj[5] = { (uint16_t *)in_lines_adj8[0],
237 (uint16_t *)in_lines_adj8[1],
238 (uint16_t *)in_lines_adj8[2],
239 (uint16_t *)in_lines_adj8[3],
240 (uint16_t *)in_lines_adj8[4] };
245 *work_line += *in_lines_cur[0]++ * coef[0];
246 *work_line += *in_lines_adj[0]++ * coef[0];
247 *work_line += *in_lines_cur[1]++ * coef[1];
248 *work_line += *in_lines_adj[1]++ * coef[1];
249 *work_line += *in_lines_cur[2]++ * coef[2];
250 *work_line += *in_lines_adj[2]++ * coef[2];
251 *work_line += *in_lines_cur[3]++ * coef[3];
252 *work_line += *in_lines_adj[3]++ * coef[3];
253 *work_line += *in_lines_cur[4]++ * coef[4];
254 *work_line++ += *in_lines_adj[4]++ * coef[4];
260 uint16_t *out_pixel = (uint16_t *)out_pixel8;
264 for (j = 0; j <
linesize; j++, out_pixel++, work_pixel++)
265 *out_pixel = av_clip(*work_pixel, 0, max) >> 15;
299 s->
max = ((1 << depth) - 1) * 256 * 128;
341 static const int16_t
coef_lf[2][4] = {{ 16384, 16384, 0, 0},
342 { -852, 17236, 17236, -852}};
344 static const int16_t
coef_hf[2][5] = {{ -2048, 4096, -2048, 0, 0},
345 { 1016, -3801, 5570, -3801, 1016}};
359 const int plane = td->
plane;
361 uint8_t *in_line, *in_lines_cur[5], *in_lines_adj[5];
369 const int cur_line_stride = cur->
linesize[plane];
370 const int adj_line_stride = adj->
linesize[plane];
371 const int dst_line_stride = out->
linesize[plane];
372 const int start = (height * jobnr) / nb_jobs;
373 const int end = (height * (jobnr+1)) / nb_jobs;
380 in_line = cur_data + (y_out * cur_line_stride);
381 out_line = dst_data + (y_out * dst_line_stride);
383 while (y_out < end) {
384 memcpy(out_line, in_line, linesize);
386 in_line += cur_line_stride * 2;
387 out_line += dst_line_stride * 2;
393 out_line = dst_data + (y_out * dst_line_stride);
395 while (y_out < end) {
398 y_in = (y_out + 1) + (j * 2) - n_coef_lf[
filter];
402 while (y_in >= height)
405 in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
409 switch (n_coef_lf[filter]) {
421 y_in = (y_out + 1) + (j * 2) - n_coef_hf[
filter];
425 while (y_in >= height)
428 in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
429 in_lines_adj[j] = adj_data + (y_in * adj_line_stride);
433 switch (n_coef_hf[filter]) {
445 out_pixel = out_line;
451 out_line += dst_line_stride * 2;
475 int64_t cur_pts = s->
cur->
pts;
476 int64_t next_pts = s->
next->
pts;
479 out->
pts = cur_pts + next_pts;
487 for (plane = 0; plane < s->
nb_planes; plane++) {
553 }
else if (ret < 0) {
599 .priv_class = &w3fdif_class,
#define AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P9
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_YUVA422P10
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Main libavfilter public API header.
static void filter16_scale(uint8_t *out_pixel8, const int32_t *work_pixel, int linesize, int max)
int h
agreed upon image height
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUV420P12
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
int is_disabled
the enabled state from the last expression evaluation
static void filter_complex_low(int32_t *work_line, uint8_t *in_lines_cur[4], const int16_t *coef, int linesize)
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
const char * name
Pad name.
static const AVOption w3fdif_options[]
AVFilterLink ** inputs
array of pointers to input links
static int config_input(AVFilterLink *inlink)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
AVFILTER_DEFINE_CLASS(w3fdif)
static av_cold int end(AVCodecContext *avctx)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_PIX_FMT_YUVA420P9
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)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
void(* filter_complex_low)(int32_t *work_line, uint8_t *in_lines_cur[4], const int16_t *coef, int linesize)
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
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)
#define AVERROR_EOF
End of file.
int interlaced_frame
The content of the picture is interlaced.
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUVA420P16
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)
A filter pad used for either input or output.
int linesize[4]
bytes of pixel data per line for each plane
A link between two filters.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
AVFrame * next
previous, current, next frames
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int query_formats(AVFilterContext *ctx)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
static const int16_t coef_hf[2][5]
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. ...
void * priv
private data for use by the filter
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
#define AV_PIX_FMT_YUVA444P16
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
#define AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_YUV444P10
int planeheight[4]
height of each plane
#define AV_PIX_FMT_GBRAP16
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
#define AV_PIX_FMT_YUV422P9
static void filter16_complex_low(int32_t *work_line, uint8_t *in_lines_cur8[4], const int16_t *coef, int linesize)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
int field
which field are we on, 0 or 1
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define AV_PIX_FMT_YUVA444P12
static const int16_t coef_lf[2][4]
void(* filter_scale)(uint8_t *out_pixel, const int32_t *work_pixel, int linesize, int max)
AVFilterContext * src
source filter
#define AV_PIX_FMT_YUVA444P10
static const int8_t n_coef_hf[2]
static const AVFilterPad inputs[]
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_GBRP14
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
static const AVFilterPad outputs[]
int format
agreed upon media format
static int config_output(AVFilterLink *outlink)
#define AV_PIX_FMT_YUV420P14
Used for passing data between threads.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static const int8_t n_coef_lf[2]
#define AV_PIX_FMT_YUV420P10
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
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.
const char * name
Filter name.
#define AV_PIX_FMT_YUV420P9
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)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_GBRP12
#define flags(name, subs,...)
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define CONST(name, help, val, unit)
static const AVFilterPad w3fdif_inputs[]
void(* filter_simple_low)(int32_t *work_line, uint8_t *in_lines_cur[2], const int16_t *coef, int linesize)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal and external API header
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
planar GBRA 4:4:4:4 32bpp
int deint
which frames to deinterlace
#define AV_PIX_FMT_YUVA444P9
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
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)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
avfilter_execute_func * execute
int top_field_first
If the content is interlaced, is top field displayed first.
AVFilterContext * dst
dest filter
static const AVFilterPad w3fdif_outputs[]
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
static void filter16_simple_low(int32_t *work_line, uint8_t *in_lines_cur8[2], const int16_t *coef, int linesize)
static av_cold void uninit(AVFilterContext *ctx)
void ff_w3fdif_init_x86(W3FDIFDSPContext *dsp, int depth)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static void filter_scale(uint8_t *out_pixel, const int32_t *work_pixel, int linesize, int max)
static void filter_simple_low(int32_t *work_line, uint8_t *in_lines_cur[2], const int16_t *coef, int linesize)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
int32_t ** work_line
lines we are calculating
static int request_frame(AVFilterLink *outlink)
int depth
Number of bits in the component.
AVPixelFormat
Pixel format.
int filter
0 is simple, 1 is more complex
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)
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.
#define AV_PIX_FMT_YUVA422P12
#define AV_CEIL_RSHIFT(a, b)