FFmpeg
Classes | Macros | Typedefs | Functions
motion_est.c File Reference

Motion estimation. More...

#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include "avcodec.h"
#include "internal.h"
#include "mathops.h"
#include "motion_est.h"
#include "mpegutils.h"
#include "mpegvideo.h"
#include "motion_est_template.c"

Classes

struct  Minima
 

Macros

#define P_LEFT   P[1]
 
#define P_TOP   P[2]
 
#define P_TOPRIGHT   P[3]
 
#define P_MEDIAN   P[4]
 
#define P_MV1   P[9]
 
#define ME_MAP_SHIFT   3
 
#define ME_MAP_MV_BITS   11
 
#define FLAG_QPEL   1
 
#define FLAG_CHROMA   2
 
#define FLAG_DIRECT   4
 
#define CHECK_SAD_HALF_MV(suffix, x, y)
 
#define HASH(fx, fy, bx, by)   ((fx)+17*(fy)+63*(bx)+117*(by))
 
#define HASH8(fx, fy, bx, by)   ((uint8_t)HASH(fx,fy,bx,by))
 
#define CHECK_BIDIR(fx, fy, bx, by)
 
#define CHECK_BIDIR2(a, b, c, d)
 

Typedefs

typedef struct Minima Minima
 

Functions

int ff_init_me (MpegEncContext *s)
 
void ff_estimate_p_frame_motion (MpegEncContext *s, int mb_x, int mb_y)
 
int ff_pre_estimate_p_frame_motion (MpegEncContext *s, int mb_x, int mb_y)
 
void ff_estimate_b_frame_motion (MpegEncContext *s, int mb_x, int mb_y)
 
int ff_get_best_fcode (MpegEncContext *s, int16_t(*mv_table)[2], int type)
 
void ff_fix_long_p_mvs (MpegEncContext *s)
 
void ff_fix_long_mvs (MpegEncContext *s, uint8_t *field_select_table, int field_select, int16_t(*mv_table)[2], int f_code, int type, int truncate)
 

Detailed Description

Motion estimation.

Macro Definition Documentation

§ CHECK_BIDIR

#define CHECK_BIDIR (   fx,
  fy,
  bx,
  by 
)
Value:
if( !map[(hashidx+HASH(fx,fy,bx,by))&255]\
&&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\
&&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\
int score;\
map[(hashidx+HASH(fx,fy,bx,by))&255] = 1;\
score= check_bidir_mv(s, motion_fx+fx, motion_fy+fy, motion_bx+bx, motion_by+by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16);\
if(score < fbmin){\
hashidx += HASH(fx,fy,bx,by);\
fbmin= score;\
motion_fx+=fx;\
motion_fy+=fy;\
motion_bx+=bx;\
motion_by+=by;\
end=0;\
}\
}

§ CHECK_BIDIR2

#define CHECK_BIDIR2 (   a,
  b,
  c,
 
)
Value:
CHECK_BIDIR(a,b,c,d)\
CHECK_BIDIR(-(a),-(b),-(c),-(d))

§ CHECK_SAD_HALF_MV

#define CHECK_SAD_HALF_MV (   suffix,
  x,
 
)
Value:
{\
d = s->mecc.pix_abs[size][(x ? 1 : 0) + (y ? 2 : 0)](NULL, pix, ptr + ((x) >> 1), stride, h); \
d += (mv_penalty[pen_x + x] + mv_penalty[pen_y + y])*penalty_factor;\
COPY3_IF_LT(dminh, d, dx, x, dy, y)\
}

Function Documentation

§ ff_estimate_p_frame_motion()

void ff_estimate_p_frame_motion ( MpegEncContext s,
int  mb_x,
int  mb_y 
)

< the variance of the block (sum of squared (p[y][x]-average))

< sum of squared differences with the estimated motion vector

§ ff_fix_long_mvs()

void ff_fix_long_mvs ( MpegEncContext s,
uint8_t *  field_select_table,
int  field_select,
int16_t(*)  mv_table[2],
int  f_code,
int  type,
int  truncate 
)
Parameters
truncate1 for truncation, 0 for using intra