FFmpeg
Macros | Functions | Variables
vf_tinterlace.c File Reference
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavutil/avassert.h"
#include "avfilter.h"
#include "filters.h"
#include "tinterlace.h"
#include "video.h"

Go to the source code of this file.

Macros

#define OFFSET(x)   offsetof(TInterlaceContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define FULL_SCALE_YUVJ_FORMATS   AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P
 
#define FIELD_UPPER   0
 
#define FIELD_LOWER   1
 
#define FIELD_UPPER_AND_LOWER   2
 

Functions

 AVFILTER_DEFINE_CLASS (tinterlace)
 
 AVFILTER_DEFINE_CLASS (interlace)
 
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_c_16 (uint8_t *dst8, ptrdiff_t width, const uint8_t *src8, 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 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 av_cold void uninit (AVFilterContext *ctx)
 
static int config_out_props (AVFilterLink *outlink)
 
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. More...
 
static int filter_frame (AVFilterLink *inlink, AVFrame *picref)
 
static int init_interlace (AVFilterContext *ctx)
 

Variables

static const AVOption tinterlace_options []
 
static const AVOption interlace_options []
 
static enum AVPixelFormat full_scale_yuvj_pix_fmts []
 
static const AVRational standard_tbs []
 
static enum AVPixelFormat pix_fmts []
 
static const AVFilterPad tinterlace_inputs []
 
static const AVFilterPad tinterlace_outputs []
 
const AVFilter ff_vf_tinterlace
 
const AVFilter ff_vf_interlace
 

Detailed Description

temporal field interlace filter, ported from MPlayer/libmpcodecs

Definition in file vf_tinterlace.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(TInterlaceContext, x)

Definition at line 38 of file vf_tinterlace.c.

◆ FLAGS

Definition at line 39 of file vf_tinterlace.c.

◆ FULL_SCALE_YUVJ_FORMATS

Definition at line 79 of file vf_tinterlace.c.

◆ FIELD_UPPER

#define FIELD_UPPER   0

Definition at line 312 of file vf_tinterlace.c.

◆ FIELD_LOWER

#define FIELD_LOWER   1

Definition at line 313 of file vf_tinterlace.c.

◆ FIELD_UPPER_AND_LOWER

#define FIELD_UPPER_AND_LOWER   2

Definition at line 314 of file vf_tinterlace.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS() [1/2]

AVFILTER_DEFINE_CLASS ( tinterlace  )

◆ AVFILTER_DEFINE_CLASS() [2/2]

AVFILTER_DEFINE_CLASS ( interlace  )

◆ lowpass_line_c()

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

Definition at line 106 of file vf_tinterlace.c.

Referenced by config_out_props().

◆ lowpass_line_c_16()

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

Definition at line 120 of file vf_tinterlace.c.

Referenced by config_out_props().

◆ lowpass_line_complex_c()

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

Definition at line 138 of file vf_tinterlace.c.

Referenced by config_out_props().

◆ lowpass_line_complex_c_16()

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

Definition at line 165 of file vf_tinterlace.c.

Referenced by config_out_props().

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 200 of file vf_tinterlace.c.

◆ config_out_props()

static int config_out_props ( AVFilterLink outlink)
static

Definition at line 211 of file vf_tinterlace.c.

◆ copy_picture_field()

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 
)
inlinestatic

Copy picture field from src to dst.

Parameters
src_fieldcopy from upper, lower field or both
interleaveleave a padding line between each copied line
dst_fieldcopy to upper or lower field, only meaningful when interleave is selected
flagscontext flags

Definition at line 326 of file vf_tinterlace.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame picref 
)
static

Definition at line 376 of file vf_tinterlace.c.

◆ init_interlace()

static int init_interlace ( AVFilterContext ctx)
static

Definition at line 574 of file vf_tinterlace.c.

Variable Documentation

◆ tinterlace_options

const AVOption tinterlace_options[]
static
Initial value:
= {
{"mode", "select interlace mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_MERGE}, 0, MODE_NB-1, FLAGS, .unit = "mode"},
{"merge", "merge fields", 0, AV_OPT_TYPE_CONST, {.i64=MODE_MERGE}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
{"drop_even", "drop even fields", 0, AV_OPT_TYPE_CONST, {.i64=MODE_DROP_EVEN}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
{"drop_odd", "drop odd fields", 0, AV_OPT_TYPE_CONST, {.i64=MODE_DROP_ODD}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
{"pad", "pad alternate lines with black", 0, AV_OPT_TYPE_CONST, {.i64=MODE_PAD}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
{"interleave_top", "interleave top and bottom fields", 0, AV_OPT_TYPE_CONST, {.i64=MODE_INTERLEAVE_TOP}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
{"interleave_bottom", "interleave bottom and top fields", 0, AV_OPT_TYPE_CONST, {.i64=MODE_INTERLEAVE_BOTTOM}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
{"interlacex2", "interlace fields from two consecutive frames", 0, AV_OPT_TYPE_CONST, {.i64=MODE_INTERLACEX2}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
{"mergex2", "merge fields keeping same frame rate", 0, AV_OPT_TYPE_CONST, {.i64=MODE_MERGEX2}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
{"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, INT_MAX, 0, .unit = "flags" },
{"low_pass_filter", "enable vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_VLPF}, INT_MIN, INT_MAX, FLAGS, .unit = "flags" },
{"vlpf", "enable vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_VLPF}, INT_MIN, INT_MAX, FLAGS, .unit = "flags" },
{"complex_filter", "enable complex vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_CVLPF},INT_MIN, INT_MAX, FLAGS, .unit = "flags" },
{"cvlpf", "enable complex vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_CVLPF},INT_MIN, INT_MAX, FLAGS, .unit = "flags" },
{"exact_tb", "force a timebase which can represent timestamps exactly", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_EXACT_TB}, INT_MIN, INT_MAX, FLAGS, .unit = "flags" },
{"bypass_il", "bypass already interlaced frames", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_BYPASS_IL}, INT_MIN, INT_MAX, FLAGS, .unit = "flags" },
{NULL}
}

Definition at line 41 of file vf_tinterlace.c.

◆ interlace_options

const AVOption interlace_options[]
static
Initial value:
= {
{ "scan", "scanning mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = MODE_TFF}, 0, 1, FLAGS, .unit = "mode"},
{ "tff", "top field first", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_TFF}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
{ "bff", "bottom field first", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_BFF}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
{ "lowpass", "set vertical low-pass filter", OFFSET(lowpass), AV_OPT_TYPE_INT, {.i64 = VLPF_LIN}, 0, 2, FLAGS, .unit = "lowpass" },
{ "off", "disable vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = VLPF_OFF}, INT_MIN, INT_MAX, FLAGS, .unit = "lowpass" },
{ "linear", "linear vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = VLPF_LIN}, INT_MIN, INT_MAX, FLAGS, .unit = "lowpass" },
{ "complex", "complex vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = VLPF_CMP}, INT_MIN, INT_MAX, FLAGS, .unit = "lowpass" },
{ NULL }
}

Definition at line 65 of file vf_tinterlace.c.

◆ full_scale_yuvj_pix_fmts

enum AVPixelFormat full_scale_yuvj_pix_fmts[]
static
Initial value:

Definition at line 82 of file vf_tinterlace.c.

Referenced by config_out_props(), and filter_frame().

◆ standard_tbs

const AVRational standard_tbs[]
static
Initial value:
= {
{1, 25},
{1, 30},
{1001, 30000},
}

Definition at line 86 of file vf_tinterlace.c.

Referenced by config_out_props().

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ tinterlace_inputs

const AVFilterPad tinterlace_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
}

Definition at line 590 of file vf_tinterlace.c.

◆ tinterlace_outputs

const AVFilterPad tinterlace_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_out_props,
},
}

Definition at line 598 of file vf_tinterlace.c.

◆ ff_vf_tinterlace

const AVFilter ff_vf_tinterlace
Initial value:
= {
.name = "tinterlace",
.description = NULL_IF_CONFIG_SMALL("Perform temporal field interlacing."),
.priv_size = sizeof(TInterlaceContext),
.priv_class = &tinterlace_class,
}

Definition at line 606 of file vf_tinterlace.c.

◆ ff_vf_interlace

const AVFilter ff_vf_interlace
Initial value:
= {
.name = "interlace",
.description = NULL_IF_CONFIG_SMALL("Convert progressive video into interlaced."),
.priv_size = sizeof(TInterlaceContext),
.priv_class = &interlace_class,
}

Definition at line 618 of file vf_tinterlace.c.

filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
Definition: vf_tinterlace.c:376
MODE_MERGE
@ MODE_MERGE
Definition: tinterlace.h:49
init_interlace
static int init_interlace(AVFilterContext *ctx)
Definition: vf_tinterlace.c:574
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
TINTERLACE_FLAG_BYPASS_IL
#define TINTERLACE_FLAG_BYPASS_IL
Definition: tinterlace.h:40
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
mode
Definition: swscale.c:52
TInterlaceContext
Definition: tinterlace.h:65
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
VLPF_LIN
@ VLPF_LIN
Definition: tinterlace.h:44
MODE_INTERLEAVE_TOP
@ MODE_INTERLEAVE_TOP
Definition: tinterlace.h:53
AV_PIX_FMT_YUV420P12LE
@ AV_PIX_FMT_YUV420P12LE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:268
OFFSET
#define OFFSET(x)
Definition: vf_tinterlace.c:38
config_out_props
static int config_out_props(AVFilterLink *outlink)
Definition: vf_tinterlace.c:211
tinterlace_inputs
static const AVFilterPad tinterlace_inputs[]
Definition: vf_tinterlace.c:590
AV_PIX_FMT_YUV420P10LE
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:156
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_tinterlace.c:200
AV_PIX_FMT_YUV444P12LE
@ AV_PIX_FMT_YUV444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:276
MODE_MERGEX2
@ MODE_MERGEX2
Definition: tinterlace.h:56
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
VLPF_CMP
@ VLPF_CMP
Definition: tinterlace.h:45
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
AV_PIX_FMT_YUV444P10LE
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:162
AV_PIX_FMT_YUVA422P10LE
@ AV_PIX_FMT_YUVA422P10LE
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:184
TINTERLACE_FLAG_EXACT_TB
#define TINTERLACE_FLAG_EXACT_TB
Definition: tinterlace.h:39
NULL
#define NULL
Definition: coverity.c:32
MODE_DROP_EVEN
@ MODE_DROP_EVEN
Definition: tinterlace.h:50
AV_PIX_FMT_YUV440P10LE
@ AV_PIX_FMT_YUV440P10LE
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:298
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
lowpass
@ lowpass
Definition: af_biquads.c:86
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_PIX_FMT_YUV440P12LE
@ AV_PIX_FMT_YUV440P12LE
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:300
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_tinterlace.c:92
AV_PIX_FMT_YUV422P10LE
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:158
TINTERLACE_FLAG_CVLPF
#define TINTERLACE_FLAG_CVLPF
Definition: tinterlace.h:38
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
FULL_SCALE_YUVJ_FORMATS
#define FULL_SCALE_YUVJ_FORMATS
Definition: vf_tinterlace.c:79
AV_PIX_FMT_YUVA420P10LE
@ AV_PIX_FMT_YUVA420P10LE
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:182
MODE_NB
@ MODE_NB
Definition: avf_avectorscope.c:40
MODE_INTERLEAVE_BOTTOM
@ MODE_INTERLEAVE_BOTTOM
Definition: tinterlace.h:54
MODE_BFF
@ MODE_BFF
Definition: tinterlace.h:62
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
MODE_PAD
@ MODE_PAD
Definition: tinterlace.h:52
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
MODE_INTERLACEX2
@ MODE_INTERLACEX2
Definition: tinterlace.h:55
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
VLPF_OFF
@ VLPF_OFF
Definition: tinterlace.h:43
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
AV_PIX_FMT_YUVA444P10LE
@ AV_PIX_FMT_YUVA444P10LE
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:186
MODE_TFF
@ MODE_TFF
Definition: tinterlace.h:61
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
TINTERLACE_FLAG_VLPF
#define TINTERLACE_FLAG_VLPF
Definition: tinterlace.h:37
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
FLAGS
#define FLAGS
Definition: vf_tinterlace.c:39
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
AV_PIX_FMT_YUV422P12LE
@ AV_PIX_FMT_YUV422P12LE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:272
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:173
MODE_DROP_ODD
@ MODE_DROP_ODD
Definition: tinterlace.h:51
tinterlace_outputs
static const AVFilterPad tinterlace_outputs[]
Definition: vf_tinterlace.c:598