36 #define OFFSET(x) offsetof(TInterlaceContext, x) 37 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM 62 #define FULL_SCALE_YUVJ_FORMATS \ 63 AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P 98 ptrdiff_t mref, ptrdiff_t pref,
int clip_max)
100 const uint8_t *srcp_above = srcp + mref;
101 const uint8_t *srcp_below = srcp + pref;
103 for (i = 0; i <
width; i++) {
107 dstp[i] = (1 + srcp[i] + srcp[i] + srcp_above[i] + srcp_below[i]) >> 2;
112 ptrdiff_t mref, ptrdiff_t pref,
int clip_max)
114 uint16_t *
dstp = (uint16_t *)dst8;
115 const uint16_t *
srcp = (
const uint16_t *)src8;
116 const uint16_t *srcp_above = srcp + mref / 2;
117 const uint16_t *srcp_below = srcp + pref / 2;
119 for (i = 0; i <
width; i++) {
130 ptrdiff_t mref, ptrdiff_t pref,
int clip_max)
132 const uint8_t *srcp_above = srcp + mref;
133 const uint8_t *srcp_below = srcp + pref;
134 const uint8_t *srcp_above2 = srcp + mref * 2;
135 const uint8_t *srcp_below2 = srcp + pref * 2;
136 int i, src_x, src_ab;
137 for (i = 0; i <
width; i++) {
141 src_x = srcp[i] << 1;
142 src_ab = srcp_above[i] + srcp_below[i];
143 dstp[i] = av_clip_uint8((4 + ((srcp[i] + src_x + src_ab) << 1)
144 - srcp_above2[i] - srcp_below2[i]) >> 3);
148 if (src_ab > src_x) {
149 if (dstp[i] < srcp[i])
151 }
else if (dstp[i] > srcp[i])
157 ptrdiff_t mref, ptrdiff_t pref,
int clip_max)
159 uint16_t *
dstp = (uint16_t *)dst8;
160 const uint16_t *
srcp = (
const uint16_t *)src8;
161 const uint16_t *srcp_above = srcp + mref / 2;
162 const uint16_t *srcp_below = srcp + pref / 2;
163 const uint16_t *srcp_above2 = srcp + mref;
164 const uint16_t *srcp_below2 = srcp + pref;
165 int i, dst_le, src_le, src_x, src_ab;
166 for (i = 0; i <
width; i++) {
173 dst_le = av_clip((4 + ((src_le + src_x + src_ab) << 1)
175 -
av_le2ne16(srcp_below2[i])) >> 3, 0, clip_max);
179 if (src_ab > src_x) {
184 }
else if (dst_le > src_le) {
209 outlink->
w = inlink->
w;
211 inlink->
h*2 : inlink->
h;
217 uint8_t black[4] = { 0, 0, 0, 16 };
224 outlink->
w, outlink->
h, outlink->
format, 16);
279 inlink->
h, outlink->
h);
284 #define FIELD_UPPER 0 285 #define FIELD_LOWER 1 286 #define FIELD_UPPER_AND_LOWER 2 299 uint8_t *dst[4],
int dst_linesize[4],
312 int lines = plane == 1 || plane == 2 ?
AV_CEIL_RSHIFT(src_h, vsub) : src_h;
316 int srcp_linesize = src_linesize[
plane] * k;
317 int dstp_linesize = dst_linesize[
plane] * (interleave ? 2 : 1);
322 srcp += src_linesize[
plane];
324 dstp += dst_linesize[
plane];
330 for (h = lines; h > 0; h--) {
331 ptrdiff_t pref = src_linesize[
plane];
332 ptrdiff_t mref = -pref;
333 if (h >= (lines - x)) mref = 0;
334 else if (h <= (1 + x)) pref = 0;
336 tinterlace->
lowpass_line(dstp, cols, srcp, mref, pref, clip_max);
337 dstp += dstp_linesize;
338 srcp += srcp_linesize;
357 tinterlace->
cur = tinterlace->
next;
358 tinterlace->
next = picref;
360 cur = tinterlace->
cur;
361 next = tinterlace->
next;
363 if (!tinterlace->
cur)
366 switch (tinterlace->
mode) {
383 inlink->
format, inlink->
w, inlink->
h,
388 inlink->
format, inlink->
w, inlink->
h,
411 field = (1 + tinterlace->
frame) & 1 ? FIELD_UPPER : FIELD_LOWER;
415 inlink->
format, inlink->
w, inlink->
h,
420 inlink->
format, inlink->
w, inlink->
h,
439 inlink->
format, inlink->
w, inlink->
h,
440 tff ? FIELD_UPPER : FIELD_LOWER, 1, tff ? FIELD_UPPER : FIELD_LOWER,
444 (
const uint8_t **)next->data, next->linesize,
445 inlink->
format, inlink->
w, inlink->
h,
446 tff ? FIELD_LOWER : FIELD_UPPER, 1, tff ? FIELD_LOWER : FIELD_UPPER,
464 tff = next->top_field_first;
473 out->
pts = cur->
pts + next->pts;
479 inlink->
format, inlink->
w, inlink->
h,
480 tff ? FIELD_LOWER : FIELD_UPPER, 1, tff ? FIELD_LOWER : FIELD_UPPER,
484 (
const uint8_t **)next->data, next->linesize,
485 inlink->
format, inlink->
w, inlink->
h,
486 tff ? FIELD_UPPER : FIELD_LOWER, 1, tff ? FIELD_UPPER : FIELD_LOWER,
519 .
name =
"tinterlace",
524 .
inputs = tinterlace_inputs,
526 .priv_class = &tinterlace_class,
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
void(* lowpass_line)(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, ptrdiff_t mref, ptrdiff_t pref, int clip_max)
static enum AVPixelFormat full_scale_yuvj_pix_fmts[]
static int query_formats(AVFilterContext *ctx)
static const char * format[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define TINTERLACE_FLAG_CVLPF
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)
Main libavfilter public API header.
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...
int h
agreed upon image height
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
int mode
TInterlaceMode, interlace mode selected.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
int flags
flags affecting interlacing algorithm
AVFilter ff_vf_tinterlace
#define FULL_SCALE_YUVJ_FORMATS
BYTE int const BYTE * srcp
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
#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.
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.
static const AVOption tinterlace_options[]
temporal field interlace filter, ported from MPlayer/libmpcodecs
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int frame
number of the output frame
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)
#define AV_LOG_VERBOSE
Detailed information.
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)
int interlaced_frame
The content of the picture is interlaced.
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
union FFDrawColor::@179 comp[MAX_PLANES]
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void ff_tinterlace_init_x86(TInterlaceContext *interlace)
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.
int vsub
chroma vertical subsampling
#define TINTERLACE_FLAG_VLPF
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
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
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.
simple assert() macros that are a bit more flexible than ISO C assert().
AVFILTER_DEFINE_CLASS(tinterlace)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
uint8_t nb_components
The number of components each pixel has, (1-4)
static av_cold void uninit(AVFilterContext *ctx)
AVFilterContext * src
source filter
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
static const AVFilterPad tinterlace_outputs[]
static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
static const AVFilterPad inputs[]
static const AVRational standard_tbs[]
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
#define FF_ARRAY_ELEMS(a)
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)
static AVRational av_make_q(int num, int den)
Create an AVRational.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
static av_always_inline void RENAME() interleave(TYPE *dst, TYPE *src0, TYPE *src1, int w2, int add, int shift)
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
uint8_t * black_data[4]
buffer used to fill padded lines
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Rational number (pair of numerator and denominator).
const char * name
Filter name.
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
Init a draw context.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
static const AVFilterPad tinterlace_inputs[]
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
const AVPixFmtDescriptor * csp
static int config_out_props(AVFilterLink *outlink)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
#define TINTERLACE_FLAG_EXACT_TB
int top_field_first
If the content is interlaced, is top field displayed first.
AVFilterContext * dst
dest filter
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.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
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.
#define FIELD_UPPER_AND_LOWER
int depth
Number of bits in the component.
AVRational preout_time_base
AVPixelFormat
Pixel format.
mode
Use these values in ebur128_init (or'ed).
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_CEIL_RSHIFT(a, b)