FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
vf_bwdif.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
#include "bwdif.h"

Go to the source code of this file.

Data Structures

struct  ThreadData
 

Macros

#define FILTER_INTRA()
 
#define FILTER1()
 
#define SPAT_CHECK()
 
#define FILTER_LINE()
 
#define FILTER_EDGE()
 
#define FILTER2()
 
#define OFFSET(x)   offsetof(BWDIFContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define CONST(name, help, val, unit)   { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
 

Functions

static void filter_intra (void *dst1, void *cur1, int w, int prefs, int mrefs, int prefs3, int mrefs3, int parity, int clip_max)
 
static void filter_line_c (void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int prefs2, int mrefs2, int prefs3, int mrefs3, int prefs4, int mrefs4, int parity, int clip_max)
 
static void filter_edge (void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int prefs2, int mrefs2, int parity, int clip_max, int spat)
 
static void filter_intra_16bit (void *dst1, void *cur1, int w, int prefs, int mrefs, int prefs3, int mrefs3, int parity, int clip_max)
 
static void filter_line_c_16bit (void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int prefs2, int mrefs2, int prefs3, int mrefs3, int prefs4, int mrefs4, int parity, int clip_max)
 
static void filter_edge_16bit (void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int prefs2, int mrefs2, int parity, int clip_max, int spat)
 
static int filter_slice (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static void filter (AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff)
 
static int return_frame (AVFilterContext *ctx, int is_second)
 
static int checkstride (BWDIFContext *bwdif, const AVFrame *a, const AVFrame *b)
 
static void fixstride (AVFilterLink *link, AVFrame *f)
 
static int filter_frame (AVFilterLink *link, AVFrame *frame)
 
static int request_frame (AVFilterLink *link)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_props (AVFilterLink *link)
 
 AVFILTER_DEFINE_CLASS (bwdif)
 

Variables

static const uint16_t coef_lf [2] = { 4309, 213 }
 
static const uint16_t coef_hf [3] = { 5570, 3801, 1016 }
 
static const uint16_t coef_sp [2] = { 5077, 981 }
 
static const AVOption bwdif_options []
 
static const AVFilterPad avfilter_vf_bwdif_inputs []
 
static const AVFilterPad avfilter_vf_bwdif_outputs []
 
AVFilter ff_vf_bwdif
 

Macro Definition Documentation

#define FILTER_INTRA ( )
Value:
for (x = 0; x < w; x++) { \
interpol = (coef_sp[0] * (cur[mrefs] + cur[prefs]) - coef_sp[1] * (cur[mrefs3] + cur[prefs3])) >> 13; \
dst[0] = av_clip(interpol, 0, clip_max); \
\
dst++; \
cur++; \
}
static const uint16_t coef_sp[2]
Definition: vf_bwdif.c:50
static int interpol(MBContext *s, uint32_t *color, int x, int y, int linesize)

Definition at line 60 of file vf_bwdif.c.

Referenced by filter_intra(), and filter_intra_16bit().

#define FILTER1 ( )
Value:
for (x = 0; x < w; x++) { \
int c = cur[mrefs]; \
int d = (prev2[0] + next2[0]) >> 1; \
int e = cur[prefs]; \
int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e)) >> 1; \
int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e)) >> 1; \
int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
if (!diff) { \
dst[0] = d; \
} else {
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
if(ret< 0)
Definition: vf_mcdeint.c:282
static double c[64]
static av_always_inline int diff(const uint32_t a, const uint32_t b)
#define FFMAX3(a, b, c)
Definition: common.h:95

Definition at line 69 of file vf_bwdif.c.

Referenced by filter_edge(), filter_edge_16bit(), filter_line_c(), and filter_line_c_16bit().

#define SPAT_CHECK ( )
Value:
int b = ((prev2[mrefs2] + next2[mrefs2]) >> 1) - c; \
int f = ((prev2[prefs2] + next2[prefs2]) >> 1) - e; \
int dc = d - c; \
int de = d - e; \
int max = FFMAX3(de, dc, FFMIN(b, f)); \
int min = FFMIN3(de, dc, FFMAX(b, f)); \
diff = FFMAX3(diff, min, -max);
const char * b
Definition: vf_curves.c:113
#define FFMIN3(a, b, c)
Definition: common.h:97
#define FFMAX(a, b)
Definition: common.h:94
#define FFMIN(a, b)
Definition: common.h:96
static double c[64]
static av_always_inline int diff(const uint32_t a, const uint32_t b)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> dc
float min
#define FFMAX3(a, b, c)
Definition: common.h:95

Definition at line 83 of file vf_bwdif.c.

#define FILTER_LINE ( )
Value:
if (FFABS(c - e) > temporal_diff0) { \
interpol = (((coef_hf[0] * (prev2[0] + next2[0]) \
- coef_hf[1] * (prev2[mrefs2] + next2[mrefs2] + prev2[prefs2] + next2[prefs2]) \
+ coef_hf[2] * (prev2[mrefs4] + next2[mrefs4] + prev2[prefs4] + next2[prefs4])) >> 2) \
+ coef_lf[0] * (c + e) - coef_lf[1] * (cur[mrefs3] + cur[prefs3])) >> 13; \
} else { \
interpol = (coef_sp[0] * (c + e) - coef_sp[1] * (cur[mrefs3] + cur[prefs3])) >> 13; \
}
static const uint16_t coef_sp[2]
Definition: vf_bwdif.c:50
static const uint16_t coef_lf[2]
Definition: vf_bwdif.c:48
static int interpol(MBContext *s, uint32_t *color, int x, int y, int linesize)
#define SPAT_CHECK()
Definition: vf_bwdif.c:83
static const uint16_t coef_hf[3]
Definition: vf_bwdif.c:49
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
if(ret< 0)
Definition: vf_mcdeint.c:282
static double c[64]

Definition at line 92 of file vf_bwdif.c.

Referenced by filter_line_c(), and filter_line_c_16bit().

#define FILTER_EDGE ( )
Value:
if (spat) { \
} \
interpol = (c + e) >> 1;
static int interpol(MBContext *s, uint32_t *color, int x, int y, int linesize)
#define SPAT_CHECK()
Definition: vf_bwdif.c:83
static double c[64]

Definition at line 103 of file vf_bwdif.c.

Referenced by filter_edge(), and filter_edge_16bit().

#define FILTER2 ( )
Value:
if (interpol > d + diff) \
else if (interpol < d - diff) \
interpol = d - diff; \
\
dst[0] = av_clip(interpol, 0, clip_max); \
} \
\
dst++; \
cur++; \
prev++; \
next++; \
prev2++; \
next2++; \
}
static int interpol(MBContext *s, uint32_t *color, int x, int y, int linesize)
static av_always_inline int diff(const uint32_t a, const uint32_t b)

Definition at line 109 of file vf_bwdif.c.

Referenced by filter_edge(), filter_edge_16bit(), filter_line_c(), and filter_line_c_16bit().

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

Definition at line 531 of file vf_bwdif.c.

Definition at line 532 of file vf_bwdif.c.

#define CONST (   name,
  help,
  val,
  unit 
)    { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }

Definition at line 534 of file vf_bwdif.c.

Referenced by bound().

Function Documentation

static void filter_intra ( void dst1,
void cur1,
int  w,
int  prefs,
int  mrefs,
int  prefs3,
int  mrefs3,
int  parity,
int  clip_max 
)
static

Definition at line 126 of file vf_bwdif.c.

static void filter_line_c ( void dst1,
void prev1,
void cur1,
void next1,
int  w,
int  prefs,
int  mrefs,
int  prefs2,
int  mrefs2,
int  prefs3,
int  mrefs3,
int  prefs4,
int  mrefs4,
int  parity,
int  clip_max 
)
static

Definition at line 136 of file vf_bwdif.c.

static void filter_edge ( void dst1,
void prev1,
void cur1,
void next1,
int  w,
int  prefs,
int  mrefs,
int  prefs2,
int  mrefs2,
int  parity,
int  clip_max,
int  spat 
)
static

Definition at line 154 of file vf_bwdif.c.

static void filter_intra_16bit ( void dst1,
void cur1,
int  w,
int  prefs,
int  mrefs,
int  prefs3,
int  mrefs3,
int  parity,
int  clip_max 
)
static

Definition at line 171 of file vf_bwdif.c.

static void filter_line_c_16bit ( void dst1,
void prev1,
void cur1,
void next1,
int  w,
int  prefs,
int  mrefs,
int  prefs2,
int  mrefs2,
int  prefs3,
int  mrefs3,
int  prefs4,
int  mrefs4,
int  parity,
int  clip_max 
)
static

Definition at line 181 of file vf_bwdif.c.

static void filter_edge_16bit ( void dst1,
void prev1,
void cur1,
void next1,
int  w,
int  prefs,
int  mrefs,
int  prefs2,
int  mrefs2,
int  parity,
int  clip_max,
int  spat 
)
static

Definition at line 199 of file vf_bwdif.c.

static int filter_slice ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 216 of file vf_bwdif.c.

Referenced by blend_frame(), and filter().

static void filter ( AVFilterContext ctx,
AVFrame dstpic,
int  parity,
int  tff 
)
static

Definition at line 261 of file vf_bwdif.c.

Referenced by return_frame().

static int return_frame ( AVFilterContext ctx,
int  is_second 
)
static

Definition at line 290 of file vf_bwdif.c.

Referenced by filter_frame(), and request_frame().

static int checkstride ( BWDIFContext bwdif,
const AVFrame a,
const AVFrame b 
)
static

Definition at line 332 of file vf_bwdif.c.

Referenced by filter_frame().

static void fixstride ( AVFilterLink link,
AVFrame f 
)
static

Definition at line 341 of file vf_bwdif.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink link,
AVFrame frame 
)
static

Definition at line 355 of file vf_bwdif.c.

Referenced by request_frame().

static int request_frame ( AVFilterLink link)
static

Definition at line 422 of file vf_bwdif.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 456 of file vf_bwdif.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 465 of file vf_bwdif.c.

static int config_props ( AVFilterLink link)
static

Definition at line 495 of file vf_bwdif.c.

AVFILTER_DEFINE_CLASS ( bwdif  )

Variable Documentation

const uint16_t coef_lf[2] = { 4309, 213 }
static

Definition at line 48 of file vf_bwdif.c.

const uint16_t coef_hf[3] = { 5570, 3801, 1016 }
static

Definition at line 49 of file vf_bwdif.c.

const uint16_t coef_sp[2] = { 5077, 981 }
static

Definition at line 50 of file vf_bwdif.c.

const AVOption bwdif_options[]
static
Initial value:
= {
{ "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=BWDIF_MODE_SEND_FIELD}, 0, 1, FLAGS, "mode"},
CONST("send_frame", "send one frame for each frame", BWDIF_MODE_SEND_FRAME, "mode"),
CONST("send_field", "send one frame for each field", BWDIF_MODE_SEND_FIELD, "mode"),
{ "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=BWDIF_PARITY_AUTO}, -1, 1, FLAGS, "parity" },
CONST("tff", "assume top field first", BWDIF_PARITY_TFF, "parity"),
CONST("bff", "assume bottom field first", BWDIF_PARITY_BFF, "parity"),
CONST("auto", "auto detect parity", BWDIF_PARITY_AUTO, "parity"),
{ "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=BWDIF_DEINT_ALL}, 0, 1, FLAGS, "deint" },
CONST("all", "deinterlace all frames", BWDIF_DEINT_ALL, "deint"),
CONST("interlaced", "only deinterlace frames marked as interlaced", BWDIF_DEINT_INTERLACED, "deint"),
{ NULL }
}
send 1 frame for each frame
Definition: bwdif.h:26
#define NULL
Definition: coverity.c:32
#define CONST(name, help, val, unit)
Definition: vf_bwdif.c:534
top field first
Definition: bwdif.h:31
mode
Definition: f_perms.c:27
deinterlace all frames
Definition: bwdif.h:37
bottom field first
Definition: bwdif.h:32
mcdeint parity
Definition: vf_mcdeint.c:277
#define OFFSET(x)
Definition: vf_bwdif.c:531
only deinterlace frames marked as interlaced
Definition: bwdif.h:38
#define FLAGS
Definition: vf_bwdif.c:532
auto detection
Definition: bwdif.h:33
send 1 frame for each field
Definition: bwdif.h:27

Definition at line 536 of file vf_bwdif.c.

const AVFilterPad avfilter_vf_bwdif_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: vf_bwdif.c:355

Definition at line 555 of file vf_bwdif.c.

const AVFilterPad avfilter_vf_bwdif_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
.config_props = config_props,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int request_frame(AVFilterLink *link)
Definition: vf_bwdif.c:422
static int config_props(AVFilterLink *link)
Definition: vf_bwdif.c:495

Definition at line 564 of file vf_bwdif.c.

AVFilter ff_vf_bwdif
Initial value:
= {
.name = "bwdif",
.description = NULL_IF_CONFIG_SMALL("Deinterlace the input image."),
.priv_size = sizeof(BWDIFContext),
.priv_class = &bwdif_class,
}
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_bwdif.c:456
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:386
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:376
static const AVFilterPad avfilter_vf_bwdif_inputs[]
Definition: vf_bwdif.c:555
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:133
static int flags
Definition: cpu.c:47
static int query_formats(AVFilterContext *ctx)
Definition: vf_bwdif.c:465
static const AVFilterPad avfilter_vf_bwdif_outputs[]
Definition: vf_bwdif.c:564

Definition at line 574 of file vf_bwdif.c.