38#define OFFSET(x) offsetof(TInterlaceContext, x)
39#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
79#define FULL_SCALE_YUVJ_FORMATS \
80 AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P
107 ptrdiff_t mref, ptrdiff_t pref,
int clip_max)
109 const uint8_t *srcp_above = srcp + mref;
110 const uint8_t *srcp_below = srcp + pref;
116 dstp[
i] = (1 + srcp[
i] + srcp[
i] + srcp_above[
i] + srcp_below[
i]) >> 2;
121 ptrdiff_t mref, ptrdiff_t pref,
int clip_max)
123 uint16_t *dstp = (uint16_t *)dst8;
124 const uint16_t *srcp = (
const uint16_t *)src8;
125 const uint16_t *srcp_above = srcp + mref / 2;
126 const uint16_t *srcp_below = srcp + pref / 2;
139 ptrdiff_t mref, ptrdiff_t pref,
int clip_max)
141 const uint8_t *srcp_above = srcp + mref;
142 const uint8_t *srcp_below = srcp + pref;
143 const uint8_t *srcp_above2 = srcp + mref * 2;
144 const uint8_t *srcp_below2 = srcp + pref * 2;
145 int i, src_x, src_ab;
150 src_x = srcp[
i] << 1;
151 src_ab = srcp_above[
i] + srcp_below[
i];
153 - srcp_above2[
i] - srcp_below2[
i]) >> 3);
157 if (src_ab > src_x) {
158 if (dstp[
i] < srcp[
i])
160 }
else if (dstp[
i] > srcp[
i])
166 ptrdiff_t mref, ptrdiff_t pref,
int clip_max)
168 uint16_t *dstp = (uint16_t *)dst8;
169 const uint16_t *srcp = (
const uint16_t *)src8;
170 const uint16_t *srcp_above = srcp + mref / 2;
171 const uint16_t *srcp_below = srcp + pref / 2;
172 const uint16_t *srcp_above2 = srcp + mref;
173 const uint16_t *srcp_below2 = srcp + pref;
174 int i, dst_le, src_le, src_x, src_ab;
182 dst_le =
av_clip((4 + ((src_le + src_x + src_ab) << 1)
188 if (src_ab > src_x) {
193 }
else if (dst_le > src_le) {
221 tinterlace->
vsub =
desc->log2_chroma_h;
222 outlink->
w = inlink->
w;
224 inlink->
h*2 : inlink->
h;
230 uint8_t black[4] = { 0, 0, 0, 16 };
240 outlink->
w, outlink->
h, outlink->
format, 16);
249 outlink->
w, outlink->
h, outlink->
format, 16);
289#if ARCH_X86 && HAVE_X86ASM
297#if ARCH_X86 && HAVE_X86ASM
311 inlink->
h, outlink->
h);
318#define FIELD_UPPER_AND_LOWER 2
331 uint8_t *
dst[4],
int dst_linesize[4],
332 const uint8_t *
src[4],
int src_linesize[4],
339 int plane, vsub =
desc->log2_chroma_h;
343 for (plane = 0; plane <
desc->nb_components; plane++) {
344 int lines = plane == 1 || plane == 2 ?
AV_CEIL_RSHIFT(src_h, vsub) : src_h;
346 uint8_t *dstp =
dst[plane];
347 const uint8_t *srcp =
src[plane];
348 int srcp_linesize = src_linesize[plane] * k;
349 int dstp_linesize = dst_linesize[plane] * (
interleave ? 2 : 1);
350 int clip_max = (1 << tinterlace->
csp->
comp[plane].
depth) - 1;
354 srcp += src_linesize[plane];
356 dstp += dst_linesize[plane];
362 for (
h = lines;
h > 0;
h--) {
363 ptrdiff_t pref = src_linesize[plane];
364 ptrdiff_t mref = -pref;
365 if (
h >= (lines - x)) mref = 0;
366 else if (
h <= (1 + x)) pref = 0;
368 tinterlace->
lowpass_line(dstp, cols, srcp, mref, pref, clip_max);
369 dstp += dstp_linesize;
370 srcp += srcp_linesize;
388 int field, tff,
full, ret;
391 tinterlace->
cur = tinterlace->
next;
392 tinterlace->
next = picref;
396 cur = tinterlace->
cur;
397 next = tinterlace->
next;
399 if (!tinterlace->
cur)
402 switch (tinterlace->
mode) {
411 out->height = outlink->
h;
418 inlink->
format, inlink->
w, inlink->
h,
423 inlink->
format, inlink->
w, inlink->
h,
443 out->height = outlink->
h;
451 inlink->
format, inlink->
w, inlink->
h,
456 inlink->
format, inlink->
w, inlink->
h,
466 "video is already interlaced, adjusting framerate only\n");
489 inlink->
format, inlink->
w, inlink->
h,
494 (
const uint8_t **)next->data, next->linesize,
495 inlink->
format, inlink->
w, inlink->
h,
527 out->pts = cur->
pts + next->pts;
533 inlink->
format, inlink->
w, inlink->
h,
538 (
const uint8_t **)next->data, next->linesize,
539 inlink->
format, inlink->
w, inlink->
h,
588 .p.name =
"tinterlace",
590 .p.priv_class = &tinterlace_class,
600 .p.name =
"interlace",
602 .p.priv_class = &interlace_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static const char *const format[]
const FFFilter ff_vf_interlace
const FFFilter ff_vf_tinterlace
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_x, int dst_y, int w, int h)
Fill a rectangle with an uniform color.
int ff_draw_init_from_link(FFDrawContext *draw, const AVFilterLink *link, unsigned flags)
Init a draw context, taking the format, colorspace and range from the given filter link.
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
static AVRational av_make_q(int num, int den)
Create an AVRational.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum AVPixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
#define AV_NOPTS_VALUE
Undefined timestamp value.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
int ff_ccfifo_inject(CCFifo *ccf, AVFrame *frame)
Insert CC data from the FIFO into an AVFrame (as side data)
int ff_ccfifo_init(CCFifo *ccf, AVRational framerate, void *log_ctx)
Initialize a CCFifo.
void ff_ccfifo_uninit(CCFifo *ccf)
Free all memory allocated in a CCFifo and clear the context.
int ff_ccfifo_extract(CCFifo *ccf, AVFrame *frame)
Extract CC data from an AVFrame.
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
int ff_pixfmt_is_in(enum AVPixelFormat fmt, const enum AVPixelFormat *fmts)
Tell if a pixel format is contained in the provided AV_PIX_FMT_NONE-terminated list.
#define FILTER_PIXFMTS_ARRAY(array)
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
Memory handling functions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
@ AVCOL_RANGE_JPEG
Full range content.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_YUVA444P10LE
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUVA420P10LE
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_YUVA422P10LE
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV422P12LE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_YUV440P12LE
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_YUV420P12LE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
@ AV_PIX_FMT_YUV440P10LE
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
@ AV_PIX_FMT_YUV444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
#define FF_ARRAY_ELEMS(a)
int depth
Number of bits in the component.
AVFilterLink ** inputs
array of pointers to input links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
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).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Rational number (pair of numerator and denominator).
union FFDrawColor::@125210232202265035037051142373134026157344251103 comp[MAX_PLANES]
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
int64_t frame_count_in
Number of past frames sent through the link.
AVRational preout_time_base
const AVPixFmtDescriptor * csp
uint8_t * black_data[2][4]
buffer used to fill padded lines (limited/full)
void(* lowpass_line)(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, ptrdiff_t mref, ptrdiff_t pref, int clip_max)
int flags
flags affecting interlacing algorithm
int lowpass
legacy interlace filter lowpass mode
int vsub
chroma vertical subsampling
int mode
TInterlaceMode, interlace mode selected.
static AVFormatContext * ctx
temporal field interlace filter, ported from MPlayer/libmpcodecs
#define TINTERLACE_FLAG_BYPASS_IL
#define TINTERLACE_FLAG_EXACT_TB
void ff_tinterlace_init_x86(TInterlaceContext *interlace)
#define TINTERLACE_FLAG_VLPF
#define TINTERLACE_FLAG_CVLPF
static int config_out_props(AVFilterLink *outlink)
static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dst_linesize, int src_linesize, enum FilterMode mode, int swap)
static enum AVPixelFormat full_scale_yuvj_pix_fmts[]
static int init_interlace(AVFilterContext *ctx)
#define FULL_SCALE_YUVJ_FORMATS
static void copy_picture_field(TInterlaceContext *tinterlace, uint8_t *dst[4], int dst_linesize[4], const uint8_t *src[4], int src_linesize[4], enum AVPixelFormat format, int w, int src_h, int src_field, int interleave, int dst_field, int flags)
Copy picture field from src to dst.
#define FIELD_UPPER_AND_LOWER
static const AVOption tinterlace_options[]
static void lowpass_line_c(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, ptrdiff_t mref, ptrdiff_t pref, int clip_max)
static void lowpass_line_complex_c(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, ptrdiff_t mref, ptrdiff_t pref, int clip_max)
static const AVRational standard_tbs[]
static const AVOption interlace_options[]
static void lowpass_line_c_16(uint8_t *dst8, ptrdiff_t width, const uint8_t *src8, ptrdiff_t mref, ptrdiff_t pref, int clip_max)
static av_cold void uninit(AVFilterContext *ctx)
static void lowpass_line_complex_c_16(uint8_t *dst8, ptrdiff_t width, const uint8_t *src8, ptrdiff_t mref, ptrdiff_t pref, int clip_max)
static const AVFilterPad tinterlace_inputs[]
static const AVFilterPad tinterlace_outputs[]
static int config_out_props(AVFilterLink *outlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.