50 #include "libavutil/opt.h"
51 #include "libavutil/pixdesc.h"
52 #include "libavcodec/avcodec.h"
78 #define OFFSET(x) offsetof(MCDeintContext, x)
79 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
80 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
117 enc_ctx->
width = inlink->
w;
130 switch (mcdeint->
mode) {
177 int x,
y, i,
ret, got_frame = 0;
197 for (i = 0; i < 3; i++) {
205 for (y = 0; y < h; y++) {
206 if ((y ^ mcdeint->
parity) & 1) {
207 for (x = 0; x < w; x++) {
212 if (y > 0 && y < h-1){
213 int is_edge = x < 3 || x > w-4;
214 int diff0 = filp[-fils] - srcp[-srcs];
215 int diff1 = filp[+fils] - srcp[+srcs];
218 #define DELTA(j) av_clip(j, -x, w-1-x)
220 #define GET_SCORE_EDGE(j)\
221 FFABS(srcp[-srcs+DELTA(-1+(j))] - srcp[+srcs+DELTA(-1-(j))])+\
222 FFABS(srcp[-srcs+DELTA(j) ] - srcp[+srcs+DELTA( -(j))])+\
223 FFABS(srcp[-srcs+DELTA(1+(j)) ] - srcp[+srcs+DELTA( 1-(j))])
225 #define GET_SCORE(j)\
226 FFABS(srcp[-srcs-1+(j)] - srcp[+srcs-1-(j)])+\
227 FFABS(srcp[-srcs +(j)] - srcp[+srcs -(j)])+\
228 FFABS(srcp[-srcs+1+(j)] - srcp[+srcs+1-(j)])
230 #define CHECK_EDGE(j)\
231 { int score = GET_SCORE_EDGE(j);\
232 if (score < spatial_score){\
233 spatial_score = score;\
234 diff0 = filp[-fils+DELTA(j)] - srcp[-srcs+DELTA(j)];\
235 diff1 = filp[+fils+DELTA(-(j))] - srcp[+srcs+DELTA(-(j))];\
238 { int score = GET_SCORE(j);\
239 if (score < spatial_score){\
240 spatial_score= score;\
241 diff0 = filp[-fils+(j)] - srcp[-srcs+(j)];\
242 diff1 = filp[+fils-(j)] - srcp[+srcs-(j)];\
255 if (diff0 + diff1 > 0)
268 if (!((
y ^ mcdeint->parity) & 1)) {
269 for (x = 0; x < w; x++) {
270 frame_dec->data[i][x +
y*fils] =
271 outpic ->data[i][x +
y*dsts] =
inpic->data[i][x +
y*srcs];
276 mcdeint->parity ^= 1;
314 .priv_class = &mcdeint_class,
static const AVFilterPad mcdeint_inputs[]
void av_free_packet(AVPacket *pkt)
Free a packet.
This structure describes decoded (raw) audio or video data.
const char * name
Filter name.
void * priv
private data for use by the filter
static const AVFilterPad outputs[]
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
int h
agreed upon image height
enum MCDeintParity parity
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define CODEC_FLAG_QPEL
Use qpel MC.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
BYTE int const BYTE * srcp
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define GET_SCORE_EDGE(j)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static av_cold int end(AVCodecContext *avctx)
int me_cmp
motion estimation comparison function
int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of video.
#define FF_CEIL_RSHIFT(a, b)
static const AVFilterPad mcdeint_outputs[]
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define CONST(name, help, val, unit)
A filter pad used for either input or output.
A link between two filters.
int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int config_props(AVFilterLink *inlink)
int me_sub_cmp
subpixel motion estimation comparison function
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_dict_free(AVDictionary **m)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
#define CODEC_FLAG_QSCALE
Use fixed qscale.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define CODEC_FLAG_LOW_DELAY
Force low delay.
int w
agreed upon image width
static av_cold void uninit(AVFilterContext *ctx)
int refs
number of reference frames
int width
picture width / height.
static const AVOption mcdeint_options[]
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Main libavfilter public API header.
AVFilterLink ** outputs
array of pointers to output links
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
AVFilter avfilter_vf_mcdeint
main external API structure.
static int query_formats(AVFilterContext *ctx)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
rational number numerator/denominator
AVFrame * coded_frame
the picture in the bitstream
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
AVFilterContext * dst
dest filter
int global_quality
Global quality for codecs which cannot change it per frame.
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
int mb_cmp
macroblock comparison function (not supported yet)
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
int dia_size
ME diamond size & shape.
#define AVFILTER_DEFINE_CLASS(fname)
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
int me_method
Motion estimation algorithm used for video coding.
#define CODEC_FLAG_4MV
4 MV per MB allowed / advanced prediction for H.263.
This structure stores compressed data.
int strict_std_compliance
strictly follow the standard (MPEG4, ...).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.