49 #define OFFSET(x) offsetof(MEContext, x)
50 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
51 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }
103 for (i = 0; i < 3; i++) {
115 int x,
int y,
int x_mv,
int y_mv,
int dir)
119 mv->
dst_x = x + (mb_size >> 1);
120 mv->
dst_y = y + (mb_size >> 1);
121 mv->
src_x = x_mv + (mb_size >> 1);
122 mv->
src_y = y_mv + (mb_size >> 1);
123 mv->
source = dir ? 1 : -1;
127 #define SEARCH_MV(method)\
129 for (mb_y = 0; mb_y < s->b_height; mb_y++)\
130 for (mb_x = 0; mb_x < s->b_width; mb_x++) {\
131 const int x_mb = mb_x << s->log2_mb_size;\
132 const int y_mb = mb_y << s->log2_mb_size;\
133 int mv[2] = {x_mb, y_mb};\
134 ff_me_search_##method(me_ctx, x_mb, y_mb, mv);\
135 add_mv_data(((AVMotionVector *) sd->data) + mv_count++, me_ctx->mb_size, x_mb, y_mb, mv[0], mv[1], dir);\
139 #define ADD_PRED(preds, px, py)\
141 preds.mvs[preds.nb][0] = px;\
142 preds.mvs[preds.nb][1] = py;\
192 for (dir = 0; dir < 2; dir++) {
210 for (mb_y = 0; mb_y < s->
b_height; mb_y++)
211 for (mb_x = 0; mb_x < s->
b_width; mb_x++) {
212 const int mb_i = mb_x + mb_y * s->
b_width;
215 int mv[2] = {x_mb, y_mb};
239 if (preds[0].nb == 4) {
240 me_ctx->
pred_x =
mid_pred(preds[0].mvs[1][0], preds[0].mvs[2][0], preds[0].mvs[3][0]);
241 me_ctx->
pred_y =
mid_pred(preds[0].mvs[1][1], preds[0].mvs[2][1], preds[0].mvs[3][1]);
242 }
else if (preds[0].nb == 3) {
243 me_ctx->
pred_x =
mid_pred(0, preds[0].mvs[1][0], preds[0].mvs[2][0]);
244 me_ctx->
pred_y =
mid_pred(0, preds[0].mvs[1][1], preds[0].mvs[2][1]);
245 }
else if (preds[0].nb == 2) {
255 s->
mv_table[0][mb_i][dir][0] = mv[0] - x_mb;
256 s->
mv_table[0][mb_i][dir][1] = mv[1] - y_mb;
262 for (mb_y = 0; mb_y < s->
b_height; mb_y++)
263 for (mb_x = 0; mb_x < s->
b_width; mb_x++) {
264 const int mb_i = mb_x + mb_y * s->
b_width;
267 int mv[2] = {x_mb, y_mb};
284 if (mb_y > 0 && mb_x + 1 < s->
b_width)
288 if (preds[0].nb == 4) {
289 me_ctx->
pred_x =
mid_pred(preds[0].mvs[1][0], preds[0].mvs[2][0], preds[0].mvs[3][0]);
290 me_ctx->
pred_y =
mid_pred(preds[0].mvs[1][1], preds[0].mvs[2][1], preds[0].mvs[3][1]);
291 }
else if (preds[0].nb == 3) {
292 me_ctx->
pred_x =
mid_pred(0, preds[0].mvs[1][0], preds[0].mvs[2][0]);
293 me_ctx->
pred_y =
mid_pred(0, preds[0].mvs[1][1], preds[0].mvs[2][1]);
294 }
else if (preds[0].nb == 2) {
327 s->
mv_table[0][mb_i][dir][0] = mv[0] - x_mb;
328 s->
mv_table[0][mb_i][dir][1] = mv[1] - y_mb;
346 for (i = 0; i < 3; i++)
372 .priv_class = &mestimate_class,
375 .
inputs = mestimate_inputs,
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int16_t src_x
Absolute source position.
Main libavfilter public API header.
int h
agreed upon image height
int pred_y
median predictor y
static int config_input(AVFilterLink *inlink)
#define AV_ME_METHOD_TDLS
Copyright (c) 2016 Davinder Singh (DSM_) <ds.mudhar<.com>
AVMotionEstPredictor preds[2]
const char * name
Pad name.
static void add_mv_data(AVMotionVector *mv, int mb_size, int x, int y, int x_mv, int y_mv, int dir)
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)
#define AV_ME_METHOD_NTSS
int pred_x
median predictor x
int16_t dst_x
Absolute destination position.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_ME_METHOD_EPZS
uint64_t ff_me_search_umh(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
Structure to hold side data for an AVFrame.
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
int32_t source
Where the current macroblock comes from; negative value when it comes from the past, positive value when it comes from the future.
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
AVFILTER_DEFINE_CLASS(mestimate)
#define CONST(name, help, val, unit)
#define AV_ME_METHOD_HEXBS
A filter pad used for either input or output.
A link between two filters.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
int mb_size
macroblock size
#define SEARCH_MV(method)
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. ...
uint8_t w
Width and height of the block.
void * priv
private data for use by the filter
uint64_t ff_me_search_epzs(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
simple assert() macros that are a bit more flexible than ISO C assert().
static void * av_mallocz_array(size_t nmemb, size_t size)
int search_param
search parameter
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
static const AVFilterPad mestimate_inputs[]
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec A...
int(*[3] mv_table)[2][2]
motion vectors of current & prev 2 frames
static const AVFilterPad outputs[]
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
static const int8_t mv[256][2]
#define ADD_PRED(preds, px, py)
void ff_me_init_context(AVMotionEstContext *me_ctx, int mb_size, int search_param, int width, int height, int x_min, int x_max, int y_min, int y_max)
static const AVFilterPad inputs[]
int method
motion estimation method
static const AVOption mestimate_options[]
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 av_cold void uninit(AVFilterContext *ctx)
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
uint64_t flags
Extra flag information.
common internal and external API header
AVMotionEstContext me_ctx
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define AV_ME_METHOD_ESA
Copyright (c) 2016 Davinder Singh (DSM_) <ds.mudhar<.com>
static int query_formats(AVFilterContext *ctx)
AVFilterContext * dst
dest filter
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static const AVFilterPad mestimate_outputs[]
static av_always_inline av_const int av_ceil_log2_c(int x)
Compute ceil(log2(x)).
AVPixelFormat
Pixel format.
#define AV_NOPTS_VALUE
Undefined timestamp value.