Libav
motion_est.h
Go to the documentation of this file.
1 /*
2  * Motion estimation
3  *
4  * This file is part of Libav.
5  *
6  * Libav is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * Libav is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with Libav; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVCODEC_MOTIONEST_H
22 #define AVCODEC_MOTIONEST_H
23 
24 #include <stdint.h>
25 
26 #include "avcodec.h"
27 #include "hpeldsp.h"
28 #include "qpeldsp.h"
29 
30 struct MpegEncContext;
31 
32 #define MAX_MV 2048
33 #define ME_MAP_SIZE 64
34 
35 #define FF_ME_ZERO 0
36 #define FF_ME_EPZS 1
37 #define FF_ME_XONE 2
38 
42 typedef struct MotionEstContext {
44  int skip;
45  int co_located_mv[4][2];
46  int direct_basis_mv[4][2];
52  int best_bits;
53  uint32_t *map;
54  uint32_t *score_map;
55  unsigned map_generation;
64  int flags;
65  int sub_flags;
66  int mb_flags;
67  int pre_pass;
68  int dia_size;
69  int xmin;
70  int xmax;
71  int ymin;
72  int ymax;
73  int pred_x;
74  int pred_y;
75  uint8_t *src[4][4];
76  uint8_t *ref[4][4];
77  int stride;
78  int uvstride;
79  /* temp variables for picture complexity calculation */
83 
88  uint8_t (*mv_penalty)[MAX_MV * 2 + 1];
91  int *mx_ptr, int *my_ptr, int dmin,
92  int src_index, int ref_index,
93  int size, int h);
95 
96 static inline int ff_h263_round_chroma(int x)
97 {
98  //FIXME static or not?
99  static const uint8_t h263_chroma_roundtab[16] = {
100  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
101  0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1,
102  };
103  return h263_chroma_roundtab[x & 0xf] + (x >> 3);
104 }
105 
106 int ff_init_me(struct MpegEncContext *s);
107 
108 void ff_estimate_p_frame_motion(struct MpegEncContext *s, int mb_x, int mb_y);
109 void ff_estimate_b_frame_motion(struct MpegEncContext *s, int mb_x, int mb_y);
110 
112  int mb_x, int mb_y);
113 
114 int ff_epzs_motion_search(struct MpegEncContext *s, int *mx_ptr, int *my_ptr,
115  int P[10][2], int src_index, int ref_index,
116  int16_t (*last_mv)[2], int ref_mv_scale, int size,
117  int h);
118 
119 int ff_get_mb_score(struct MpegEncContext *s, int mx, int my, int src_index,
120  int ref_index, int size, int h, int add_rate);
121 
122 int ff_get_best_fcode(struct MpegEncContext *s,
123  int16_t (*mv_table)[2], int type);
124 
125 void ff_fix_long_p_mvs(struct MpegEncContext *s);
126 void ff_fix_long_mvs(struct MpegEncContext *s, uint8_t *field_select_table,
127  int field_select, int16_t (*mv_table)[2], int f_code,
128  int type, int truncate);
129 
130 #endif /* AVCODEC_MOTIONEST_H */
uint8_t * scratchpad
data area for the ME algo, so that the ME does not need to malloc/free.
Definition: motion_est.h:47
int size
int skip
set if ME is skipped for the current MB
Definition: motion_est.h:44
int last_mv[2][2][2]
last MV, used for MV prediction in MPEG-1 & B-frame MPEG-4
Definition: mpegvideo.h:272
int pre_pass
= 1 for the pre pass
Definition: motion_est.h:67
int ff_epzs_motion_search(struct MpegEncContext *s, int *mx_ptr, int *my_ptr, int P[10][2], int src_index, int ref_index, int16_t(*last_mv)[2], int ref_mv_scale, int size, int h)
#define MAX_MV
Definition: motion_est.h:32
uint8_t * current_mv_penalty
Definition: motion_est.h:89
int(* sub_motion_search)(struct MpegEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h)
Definition: motion_est.h:90
int sub_penalty_factor
Definition: motion_est.h:62
uint32_t * score_map
map to store the scores
Definition: motion_est.h:54
int pre_penalty_factor
Definition: motion_est.h:56
int scene_change_score
Definition: motion_est.h:82
uint8_t * ref[4][4]
Definition: motion_est.h:76
int field_select[2][2]
Definition: mpegvideo.h:271
op_pixels_func(* hpel_put)[4]
Definition: motion_est.h:84
uint8_t
int ff_get_mb_score(struct MpegEncContext *s, int mx, int my, int src_index, int ref_index, int size, int h, int add_rate)
int ff_get_best_fcode(struct MpegEncContext *s, int16_t(*mv_table)[2], int type)
Definition: motion_est.c:1587
Motion estimation context.
Definition: motion_est.h:42
qpel_mc_func(* qpel_put)[16]
Definition: motion_est.h:86
quarterpel DSP functions
uint8_t(* mv_penalty)[MAX_MV *2+1]
bit amount needed to encode a MV
Definition: motion_est.h:88
op_pixels_func(* hpel_avg)[4]
Definition: motion_est.h:85
void ff_fix_long_p_mvs(struct MpegEncContext *s)
Definition: motion_est.c:1640
int ff_pre_estimate_p_frame_motion(struct MpegEncContext *s, int mb_x, int mb_y)
Definition: motion_est.c:1050
void ff_estimate_p_frame_motion(struct MpegEncContext *s, int mb_x, int mb_y)
Definition: motion_est.c:874
void(* qpel_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
Definition: qpeldsp.h:65
uint8_t * src[4][4]
Definition: motion_est.h:75
unsigned map_generation
Definition: motion_est.h:55
int penalty_factor
an estimate of the bits required to code a given mv value, e.g.
Definition: motion_est.h:57
Half-pel DSP functions.
Libavcodec external API header.
AVCodecContext * avctx
Definition: motion_est.h:43
main external API structure.
Definition: avcodec.h:1409
void(* op_pixels_func)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
Definition: hpeldsp.h:38
static int ff_h263_round_chroma(int x)
Definition: motion_est.h:96
int f_code
forward MV resolution
Definition: mpegvideo.h:229
void ff_fix_long_mvs(struct MpegEncContext *s, uint8_t *field_select_table, int field_select, int16_t(*mv_table)[2], int f_code, int type, int truncate)
Definition: motion_est.c:1689
qpel_mc_func(* qpel_avg)[16]
Definition: motion_est.h:87
int mc_mb_var_sum_temp
Definition: motion_est.h:80
uint8_t * best_mb
Definition: motion_est.h:49
MpegEncContext.
Definition: mpegvideo.h:76
int direct_basis_mv[4][2]
Definition: motion_est.h:46
int ff_init_me(struct MpegEncContext *s)
Definition: motion_est.c:303
int co_located_mv[4][2]
mv from last P-frame for direct mode ME
Definition: motion_est.h:45
uint32_t * map
map to avoid duplicate evaluations
Definition: motion_est.h:53
void ff_estimate_b_frame_motion(struct MpegEncContext *s, int mb_x, int mb_y)
Definition: motion_est.c:1479
uint8_t * temp_mb[2]
Definition: motion_est.h:50
uint8_t * temp
Definition: motion_est.h:51