26 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
* |
* |
29 |
* $Id: motion_est.h,v 1.1.2.2 2002-09-25 21:27:12 Isibaar Exp $ |
* $Id: motion_est.h,v 1.1.2.7 2002-11-04 10:58:24 syskin Exp $ |
30 |
* |
* |
31 |
***************************************************************************/ |
***************************************************************************/ |
32 |
|
|
44 |
/* INTER bias for INTER/INTRA decision; mpeg4 spec suggests 2*nb */ |
/* INTER bias for INTER/INTRA decision; mpeg4 spec suggests 2*nb */ |
45 |
#define MV16_INTER_BIAS 512 |
#define MV16_INTER_BIAS 512 |
46 |
|
|
47 |
|
/* vector map (vlc delta size) smoother parameters ! float !*/ |
48 |
|
#define NEIGH_TEND_16X16 10.5 |
49 |
|
#define NEIGH_TEND_8X8 4.0 |
50 |
|
#define NEIGH_8X8_BIAS 30 |
51 |
|
|
52 |
/* Parameters which control inter/inter4v decision */ |
/* Parameters which control inter/inter4v decision */ |
53 |
#define IMV16X16 2 |
#define IMV16X16 2 |
54 |
|
|
|
/* vector map (vlc delta size) smoother parameters ! float !*/ |
|
|
#define NEIGH_TEND_16X16 4.0 |
|
|
#define NEIGH_TEND_8X8 7.0 |
|
|
|
|
55 |
static const int lambda_vec16[32] = |
static const int lambda_vec16[32] = |
56 |
{ 0 ,(int)(1.00235 * NEIGH_TEND_16X16 + 0.5), |
{ 0 ,(int)(1.00235 * NEIGH_TEND_16X16 + 0.5), |
57 |
(int)(1.15582*NEIGH_TEND_16X16 + 0.5), (int)(1.31976*NEIGH_TEND_16X16 + 0.5), |
(int)(1.15582*NEIGH_TEND_16X16 + 0.5), (int)(1.31976*NEIGH_TEND_16X16 + 0.5), |
96 |
10, 11, 11, 11, 11, 11, 11, 12, 12 |
10, 11, 11, 11, 11, 11, 11, 12, 12 |
97 |
}; |
}; |
98 |
|
|
99 |
|
static const int DQtab[4] = { |
100 |
|
-1, -2, 1, 2 |
101 |
|
}; |
102 |
|
|
103 |
|
|
104 |
typedef struct |
typedef struct |
105 |
{ |
{ |
106 |
// general fields |
// general fields |
107 |
int max_dx, min_dx, max_dy, min_dy; |
int max_dx, min_dx, max_dy, min_dy; |
108 |
|
uint32_t rounding; |
109 |
VECTOR predMV; |
VECTOR predMV; |
110 |
|
VECTOR predQMV; |
111 |
VECTOR *currentMV; |
VECTOR *currentMV; |
112 |
|
VECTOR *currentQMV; |
113 |
int32_t *iMinSAD; |
int32_t *iMinSAD; |
114 |
const uint8_t * Ref; |
const uint8_t * Ref; |
115 |
const uint8_t * RefH; |
const uint8_t * RefH; |
116 |
const uint8_t * RefV; |
const uint8_t * RefV; |
117 |
const uint8_t * RefHV; |
const uint8_t * RefHV; |
118 |
|
const uint8_t * RefCU; |
119 |
|
const uint8_t * RefCV; |
120 |
|
const uint8_t * CurU; |
121 |
|
const uint8_t * CurV; |
122 |
|
uint8_t * RefQ; |
123 |
const uint8_t * Cur; |
const uint8_t * Cur; |
124 |
uint32_t iQuant; |
uint32_t lambda16; |
125 |
|
uint32_t lambda8; |
126 |
uint32_t iEdgedWidth; |
uint32_t iEdgedWidth; |
127 |
uint32_t iFcode; |
uint32_t iFcode; |
128 |
int * temp; |
int * temp; |
129 |
|
int qpel; |
130 |
|
int chroma; |
131 |
//fields for interpolate and direct mode |
//fields for interpolate and direct mode |
132 |
const uint8_t *bRef; |
const uint8_t *bRef; |
133 |
const uint8_t *bRefH; |
const uint8_t *bRefH; |
166 |
const uint32_t block_sz, /* block dimension, 8 or 16 */ |
const uint32_t block_sz, /* block dimension, 8 or 16 */ |
167 |
const uint32_t width, |
const uint32_t width, |
168 |
const uint32_t height, |
const uint32_t height, |
169 |
const uint32_t fcode) |
const uint32_t fcode, |
170 |
|
const uint32_t quarterpel) |
171 |
{ |
{ |
172 |
|
|
173 |
int k; |
int k; |
174 |
int high = (32 << (fcode - 1)) - 1; |
const int search_range = 32 << (fcode - 1 - quarterpel); |
175 |
|
const int high = search_range - 1; |
176 |
|
const int low = -search_range; |
177 |
|
|
178 |
k = 2 * (int)(width - x*block_sz); |
k = 2 * (int)(width - x*block_sz); |
179 |
*max_dx = MIN(high, k); |
*max_dx = MIN(high, k); |
180 |
k = 2 * (int)(height - y*block_sz); |
k = 2 * (int)(height - y*block_sz); |
181 |
*max_dy = MIN(high, k); |
*max_dy = MIN(high, k); |
182 |
|
|
|
high = -(32 << (fcode - 1)); |
|
183 |
k = -2 * (int)((x+1) * block_sz); |
k = -2 * (int)((x+1) * block_sz); |
184 |
*min_dx = MAX(high, k); |
*min_dx = MAX(low, k); |
185 |
k = -2 * (int)((y+1) * block_sz); |
k = -2 * (int)((y+1) * block_sz); |
186 |
*min_dy = MAX(high, k); |
*min_dy = MAX(low, k); |
187 |
|
|
188 |
} |
} |
189 |
|
|
211 |
const uint32_t iLimit); |
const uint32_t iLimit); |
212 |
|
|
213 |
static void |
static void |
214 |
SearchP(const uint8_t * const pRef, |
SearchP(const IMAGE * const pRef, |
215 |
const uint8_t * const pRefH, |
const uint8_t * const pRefH, |
216 |
const uint8_t * const pRefV, |
const uint8_t * const pRefV, |
217 |
const uint8_t * const pRefHV, |
const uint8_t * const pRefHV, |