Go to the documentation of this file.
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"),
95 const int16_t *coef,
int linesize)
99 for (
i = 0;
i < linesize;
i++) {
100 *work_line = *in_lines_cur[0]++ * coef[0];
101 *work_line++ += *in_lines_cur[1]++ * coef[1];
107 const int16_t *coef,
int linesize)
111 for (
i = 0;
i < linesize;
i++) {
112 *work_line = *in_lines_cur[0]++ * coef[0];
113 *work_line += *in_lines_cur[1]++ * coef[1];
114 *work_line += *in_lines_cur[2]++ * coef[2];
115 *work_line++ += *in_lines_cur[3]++ * coef[3];
122 const int16_t *coef,
int linesize)
126 for (
i = 0;
i < linesize;
i++) {
127 *work_line += *in_lines_cur[0]++ * coef[0];
128 *work_line += *in_lines_adj[0]++ * coef[0];
129 *work_line += *in_lines_cur[1]++ * coef[1];
130 *work_line += *in_lines_adj[1]++ * coef[1];
131 *work_line += *in_lines_cur[2]++ * coef[2];
132 *work_line++ += *in_lines_adj[2]++ * coef[2];
139 const int16_t *coef,
int linesize)
143 for (
i = 0;
i < linesize;
i++) {
144 *work_line += *in_lines_cur[0]++ * coef[0];
145 *work_line += *in_lines_adj[0]++ * coef[0];
146 *work_line += *in_lines_cur[1]++ * coef[1];
147 *work_line += *in_lines_adj[1]++ * coef[1];
148 *work_line += *in_lines_cur[2]++ * coef[2];
149 *work_line += *in_lines_adj[2]++ * coef[2];
150 *work_line += *in_lines_cur[3]++ * coef[3];
151 *work_line += *in_lines_adj[3]++ * coef[3];
152 *work_line += *in_lines_cur[4]++ * coef[4];
153 *work_line++ += *in_lines_adj[4]++ * coef[4];
161 for (j = 0; j < linesize; j++, out_pixel++, work_pixel++)
162 *out_pixel = av_clip(*work_pixel, 0, 255 * 256 * 128) >> 15;
167 const int16_t *coef,
int linesize)
169 uint16_t *in_lines_cur[2] = { (uint16_t *)in_lines_cur8[0], (uint16_t *)in_lines_cur8[1] };
173 for (
i = 0;
i < linesize;
i++) {
174 *work_line = *in_lines_cur[0]++ * coef[0];
175 *work_line++ += *in_lines_cur[1]++ * coef[1];
181 const int16_t *coef,
int linesize)
183 uint16_t *in_lines_cur[4] = { (uint16_t *)in_lines_cur8[0],
184 (uint16_t *)in_lines_cur8[1],
185 (uint16_t *)in_lines_cur8[2],
186 (uint16_t *)in_lines_cur8[3] };
190 for (
i = 0;
i < linesize;
i++) {
191 *work_line = *in_lines_cur[0]++ * coef[0];
192 *work_line += *in_lines_cur[1]++ * coef[1];
193 *work_line += *in_lines_cur[2]++ * coef[2];
194 *work_line++ += *in_lines_cur[3]++ * coef[3];
201 const int16_t *coef,
int linesize)
203 uint16_t *in_lines_cur[3] = { (uint16_t *)in_lines_cur8[0],
204 (uint16_t *)in_lines_cur8[1],
205 (uint16_t *)in_lines_cur8[2] };
206 uint16_t *in_lines_adj[3] = { (uint16_t *)in_lines_adj8[0],
207 (uint16_t *)in_lines_adj8[1],
208 (uint16_t *)in_lines_adj8[2] };
212 for (
i = 0;
i < linesize;
i++) {
213 *work_line += *in_lines_cur[0]++ * coef[0];
214 *work_line += *in_lines_adj[0]++ * coef[0];
215 *work_line += *in_lines_cur[1]++ * coef[1];
216 *work_line += *in_lines_adj[1]++ * coef[1];
217 *work_line += *in_lines_cur[2]++ * coef[2];
218 *work_line++ += *in_lines_adj[2]++ * coef[2];
225 const int16_t *coef,
int linesize)
227 uint16_t *in_lines_cur[5] = { (uint16_t *)in_lines_cur8[0],
228 (uint16_t *)in_lines_cur8[1],
229 (uint16_t *)in_lines_cur8[2],
230 (uint16_t *)in_lines_cur8[3],
231 (uint16_t *)in_lines_cur8[4] };
232 uint16_t *in_lines_adj[5] = { (uint16_t *)in_lines_adj8[0],
233 (uint16_t *)in_lines_adj8[1],
234 (uint16_t *)in_lines_adj8[2],
235 (uint16_t *)in_lines_adj8[3],
236 (uint16_t *)in_lines_adj8[4] };
240 for (
i = 0;
i < linesize;
i++) {
241 *work_line += *in_lines_cur[0]++ * coef[0];
242 *work_line += *in_lines_adj[0]++ * coef[0];
243 *work_line += *in_lines_cur[1]++ * coef[1];
244 *work_line += *in_lines_adj[1]++ * coef[1];
245 *work_line += *in_lines_cur[2]++ * coef[2];
246 *work_line += *in_lines_adj[2]++ * coef[2];
247 *work_line += *in_lines_cur[3]++ * coef[3];
248 *work_line += *in_lines_adj[3]++ * coef[3];
249 *work_line += *in_lines_cur[4]++ * coef[4];
250 *work_line++ += *in_lines_adj[4]++ * coef[4];
256 uint16_t *out_pixel = (uint16_t *)out_pixel8;
260 for (j = 0; j < linesize; j++, out_pixel++, work_pixel++)
261 *out_pixel = av_clip(*work_pixel, 0,
max) >> 15;
275 s->planeheight[0] =
s->planeheight[3] =
inlink->h;
284 s->work_line =
av_calloc(
s->nb_threads,
sizeof(*
s->work_line));
288 for (
i = 0;
i <
s->nb_threads;
i++) {
290 if (!
s->work_line[
i])
294 depth =
desc->comp[0].depth;
295 s->max = ((1 << depth) - 1) * 256 * 128;
337 static const int16_t
coef_lf[2][4] = {{ 16384, 16384, 0, 0},
338 { -852, 17236, 17236, -852}};
340 static const int16_t
coef_hf[2][5] = {{ -2048, 4096, -2048, 0, 0},
341 { 1016, -3801, 5570, -3801, 1016}};
357 uint8_t *in_line, *in_lines_cur[5], *in_lines_adj[5];
359 int32_t *work_line, *work_pixel;
363 const int linesize =
s->linesize[
plane];
367 const int dst_line_stride =
out->linesize[
plane];
369 const int end = (
height * (jobnr+1)) / nb_jobs;
370 const int max =
s->max;
376 in_line = cur_data + (y_out * cur_line_stride);
377 out_line = dst_data + (y_out * dst_line_stride);
379 while (y_out <
end) {
380 memcpy(out_line, in_line, linesize);
382 in_line += cur_line_stride * 2;
383 out_line += dst_line_stride * 2;
389 out_line = dst_data + (y_out * dst_line_stride);
391 while (y_out <
end) {
401 in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
404 work_line =
s->work_line[jobnr];
407 s->dsp.filter_simple_low(work_line, in_lines_cur,
411 s->dsp.filter_complex_low(work_line, in_lines_cur,
424 in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
425 in_lines_adj[j] = adj_data + (y_in * adj_line_stride);
428 work_line =
s->work_line[jobnr];
431 s->dsp.filter_simple_high(work_line, in_lines_cur, in_lines_adj,
435 s->dsp.filter_complex_high(work_line, in_lines_cur, in_lines_adj,
440 work_pixel =
s->work_line[jobnr];
441 out_pixel = out_line;
443 s->dsp.filter_scale(out_pixel, work_pixel, linesize,
max);
447 out_line += dst_line_stride * 2;
465 out->interlaced_frame = 0;
471 int64_t cur_pts =
s->cur->pts;
472 int64_t next_pts =
s->next->pts;
475 out->pts = cur_pts + next_pts;
481 adj =
s->field ?
s->next :
s->prev;
488 s->field = !
s->field;
510 if ((
s->deint && !
s->cur->interlaced_frame) ||
ctx->is_disabled) {
546 next->
pts =
s->next->pts * 2 -
s->cur->pts;
549 }
else if (
ret < 0) {
565 for (
i = 0;
i <
s->nb_threads;
i++)
595 .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.
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.
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.
static av_cold int end(AVCodecContext *avctx)
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).
int top_field_first
If the content is interlaced, is top field displayed first.
#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 query_formats(AVFilterContext *ctx)
static int request_frame(AVFilterLink *outlink)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
#define CONST(name, help, val, unit)
const char * name
Filter name.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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_GBRP14
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUV422P9
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)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
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.
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#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]
static const AVFilterPad outputs[]
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_YUV420P9
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)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
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.
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
AVFilterLink ** inputs
array of pointers to input links
int32_t ** work_line
lines we are calculating
#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.
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)
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)
static const AVOption w3fdif_options[]
#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_PIX_FMT_YUV444P9
int field
which field are we on, 0 or 1
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#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)
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
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
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)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
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)
@ 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...
@ 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...
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define AV_PIX_FMT_YUV444P14
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