FFmpeg
Classes | Macros | Typedefs | Enumerations | Functions | Variables
vf_mcdeint.c File Reference

Motion Compensation Deinterlacer Ported from MPlayer libmpcodecs/vf_mcdeint.c. More...

#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavcodec/avcodec.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"

Classes

struct  MCDeintContext
 

Macros

#define OFFSET(x)   offsetof(MCDeintContext, 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 }
 
#define DELTA(j)   av_clip(j, -x, w-1-x)
 
#define GET_SCORE_EDGE(j)
 
#define GET_SCORE(j)
 
#define CHECK_EDGE(j)
 
#define CHECK(j)
 

Typedefs

typedef struct MCDeintContext MCDeintContext
 

Enumerations

enum  MCDeintMode {
  MODE_FAST = 0, MODE_MEDIUM, MODE_SLOW, MODE_EXTRA_SLOW,
  MODE_NB
}
 
enum  MCDeintParity { PARITY_TFF = 0, PARITY_BFF = 1 }
 

Functions

 AVFILTER_DEFINE_CLASS (mcdeint)
 
 CHECK (-1) CHECK(-2) }} }} CHECK(1) CHECK(2) }} }} } if(diff0+diff1 > 0) temp -
 
 for (y=0;y< h;y++)
 
 if (ret< 0)
 
return ff_filter_frame (outlink, outpic)
 

Variables

 else
 
else temp = (diff0 + diff1 + FFABS(FFABS(diff0) - FFABS(diff1)) / 2) / 2
 
filp = *dstp = temp > 255U ? ~(temp>>31) : temp
 
mcdeint parity = 1
 
end __pad0__
 
av_frame_freeinpic
 
AVFilter ff_vf_mcdeint
 

Detailed Description

Motion Compensation Deinterlacer Ported from MPlayer libmpcodecs/vf_mcdeint.c.

Known Issues:

The motion estimation is somewhat at the mercy of the input, if the input frames are created purely based on spatial interpolation then for example a thin black line or another random and not interpolateable pattern will cause problems. Note: completely ignoring the "unavailable" lines during motion estimation did not look any better, so the most obvious solution would be to improve tfields or penalize problematic motion vectors.

If non iterative ME is used then snow currently ignores the OBMC window and as a result sometimes creates artifacts.

Only past frames are used, we should ideally use future frames too, something like filtering the whole movie in forward and then backward direction seems like an interesting idea but the current filter framework is FAR from supporting such things.

Combining the motion compensated image with the input image also is not as trivial as it seems, simple blindly taking even lines from one and odd ones from the other does not work at all as ME/MC sometimes has nothing in the previous frames which matches the current. The current algorithm has been found by trial and error and almost certainly can be improved...

Macro Definition Documentation

§ CHECK

#define CHECK (   j)
Value:
{ int score = GET_SCORE(j);\
if (score < spatial_score){\
spatial_score= score;\
diff0 = filp[-fils+(j)] - srcp[-srcs+(j)];\
diff1 = filp[+fils-(j)] - srcp[+srcs-(j)];\

§ CHECK_EDGE

#define CHECK_EDGE (   j)
Value:
{ int score = GET_SCORE_EDGE(j);\
if (score < spatial_score){\
spatial_score = score;\
diff0 = filp[-fils+DELTA(j)] - srcp[-srcs+DELTA(j)];\
diff1 = filp[+fils+DELTA(-(j))] - srcp[+srcs+DELTA(-(j))];\

§ GET_SCORE

#define GET_SCORE (   j)
Value:
FFABS(srcp[-srcs-1+(j)] - srcp[+srcs-1-(j)])+\
FFABS(srcp[-srcs +(j)] - srcp[+srcs -(j)])+\
FFABS(srcp[-srcs+1+(j)] - srcp[+srcs+1-(j)])
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72

§ GET_SCORE_EDGE

#define GET_SCORE_EDGE (   j)
Value:
FFABS(srcp[-srcs+DELTA(-1+(j))] - srcp[+srcs+DELTA(-1-(j))])+\
FFABS(srcp[-srcs+DELTA(j) ] - srcp[+srcs+DELTA( -(j))])+\
FFABS(srcp[-srcs+DELTA(1+(j)) ] - srcp[+srcs+DELTA( 1-(j))])
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72

Enumeration Type Documentation

§ MCDeintParity

Enumerator
PARITY_TFF 

top field first

PARITY_BFF 

bottom field first

Variable Documentation

§ else

else
Initial value:
{
int spatial_score = GET_SCORE(0) - 1

§ ff_vf_mcdeint

AVFilter ff_vf_mcdeint
Initial value:
= {
.name = "mcdeint",
.description = NULL_IF_CONFIG_SMALL("Apply motion compensating deinterlacing."),
.priv_size = sizeof(MCDeintContext),
.uninit = uninit,
.query_formats = query_formats,
.inputs = mcdeint_inputs,
.outputs = mcdeint_outputs,
.priv_class = &mcdeint_class,
}
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
Definition: vf_mcdeint.c:72