Parent Directory | Revision Log
Revision 1.8 - (view) (download)
1 : | edgomez | 1.2 | /***************************************************************************** |
2 : | * | ||
3 : | * XVID MPEG-4 VIDEO CODEC | ||
4 : | * - Motion Estimation related header - | ||
5 : | * | ||
6 : | * Copyright(C) 2002 Christoph Lampert <gruel@web.de> | ||
7 : | * 2002 Michael Militzer <michael@xvid.org> | ||
8 : | * 2002-2003 Radoslaw Czyz <xvid@syskin.cjb.net> | ||
9 : | * | ||
10 : | * This program is free software ; you can redistribute it and/or modify | ||
11 : | * it under the terms of the GNU General Public License as published by | ||
12 : | * the Free Software Foundation ; either version 2 of the License, or | ||
13 : | * (at your option) any later version. | ||
14 : | * | ||
15 : | * This program is distributed in the hope that it will be useful, | ||
16 : | * but WITHOUT ANY WARRANTY ; without even the implied warranty of | ||
17 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 : | * GNU General Public License for more details. | ||
19 : | * | ||
20 : | * You should have received a copy of the GNU General Public License | ||
21 : | * along with this program ; if not, write to the Free Software | ||
22 : | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 : | * | ||
24 : | syskin | 1.7 | * $Id: estimation.h,v 1.6 2004/07/18 11:48:08 syskin Exp $ |
25 : | edgomez | 1.2 | * |
26 : | ****************************************************************************/ | ||
27 : | |||
28 : | #ifndef _ESTIMATION_H_ | ||
29 : | #define _ESTIMATION_H_ | ||
30 : | |||
31 : | #include "../portab.h" | ||
32 : | #include "../global.h" | ||
33 : | |||
34 : | /* hard coded motion search parameters */ | ||
35 : | |||
36 : | /* very large value */ | ||
37 : | #define MV_MAX_ERROR (4096 * 256) | ||
38 : | |||
39 : | /* INTER bias for INTER/INTRA decision; mpeg4 spec suggests 2*nb */ | ||
40 : | #define MV16_INTER_BIAS 450 | ||
41 : | |||
42 : | /* vector map (vlc delta size) smoother parameters ! float !*/ | ||
43 : | #define NEIGH_TEND_16X16 10.5 | ||
44 : | #define NEIGH_TEND_8X8 40.0 | ||
45 : | #define NEIGH_8X8_BIAS 40 | ||
46 : | |||
47 : | #define BITS_MULT 16 | ||
48 : | |||
49 : | syskin | 1.4 | #define INITIAL_SKIP_THRESH 6 |
50 : | edgomez | 1.2 | #define FINAL_SKIP_THRESH 50 |
51 : | #define MAX_SAD00_FOR_SKIP 20 | ||
52 : | #define MAX_CHROMA_SAD_FOR_SKIP 22 | ||
53 : | |||
54 : | /* Parameters which control inter/inter4v decision */ | ||
55 : | #define IMV16X16 2 | ||
56 : | |||
57 : | extern const int xvid_me_lambda_vec16[32]; | ||
58 : | |||
59 : | #define CHECK_CANDIDATE(X,Y,D) { \ | ||
60 : | CheckCandidate((X),(Y), data, (D) ); } | ||
61 : | |||
62 : | /* fast ((A)/2)*2 */ | ||
63 : | #define EVEN(A) (((A)<0?(A)+1:(A)) & ~1) | ||
64 : | |||
65 : | #define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) ) | ||
66 : | |||
67 : | static const VECTOR zeroMV = { 0, 0 }; | ||
68 : | |||
69 : | typedef struct | ||
70 : | { | ||
71 : | /* data modified by CheckCandidates */ | ||
72 : | int32_t iMinSAD[5]; /* smallest SADs found so far */ | ||
73 : | VECTOR currentMV[5]; /* best vectors found so far */ | ||
74 : | VECTOR currentQMV[5]; /* as above, but used during qpel search */ | ||
75 : | int temp[4]; /* temporary space */ | ||
76 : | unsigned int dir; /* 'direction', set when better vector is found */ | ||
77 : | int chromaX, chromaY, chromaSAD; /* info to make ChromaSAD faster */ | ||
78 : | |||
79 : | /* general fields */ | ||
80 : | int max_dx, min_dx, max_dy, min_dy; /* maximum range */ | ||
81 : | uint32_t rounding; /* rounding type in use */ | ||
82 : | VECTOR predMV; /* vector which predicts current vector */ | ||
83 : | const uint8_t * RefP[6]; /* reference pictures - N, V, H, HV, cU, cV */ | ||
84 : | const uint8_t * Cur; /* current picture */ | ||
85 : | const uint8_t *CurU, *CurV; /* current picture - chroma planes */ | ||
86 : | |||
87 : | uint8_t * RefQ; /* temporary space for interpolations */ | ||
88 : | uint32_t lambda16; /* how much vector bits weight */ | ||
89 : | uint32_t lambda8; /* as above - for inter4v mode */ | ||
90 : | uint32_t iEdgedWidth; /* picture's stride */ | ||
91 : | uint32_t iFcode; /* current fcode */ | ||
92 : | syskin | 1.3 | |
93 : | edgomez | 1.2 | int qpel; /* if we're coding in qpel mode */ |
94 : | int qpel_precision; /* if X and Y are in qpel precision (refinement probably) */ | ||
95 : | int chroma; /* should we include chroma SAD? */ | ||
96 : | |||
97 : | /* fields for interpolate and direct modes */ | ||
98 : | const uint8_t * b_RefP[6]; /* backward reference pictures - N, V, H, HV, cU, cV */ | ||
99 : | syskin | 1.7 | VECTOR bpredMV; /* backward prediction - used in Interpolate-mode search only */ |
100 : | uint32_t bFcode; /* backward fcode - used in Interpolate-mode search only */ | ||
101 : | syskin | 1.4 | int b_chromaX, b_chromaY; |
102 : | edgomez | 1.2 | |
103 : | /* fields for direct mode */ | ||
104 : | VECTOR directmvF[4]; /* scaled reference vectors */ | ||
105 : | syskin | 1.7 | VECTOR directmvB[4]; |
106 : | edgomez | 1.2 | const VECTOR * referencemv; /* pointer to not-scaled reference vectors */ |
107 : | |||
108 : | /* BITS/R-D stuff */ | ||
109 : | int16_t * dctSpace; /* temporary space for dct */ | ||
110 : | uint32_t iQuant; /* current quant */ | ||
111 : | uint32_t quant_type; /* current quant type */ | ||
112 : | syskin | 1.6 | unsigned int cbp[2]; /* CBP of the best vector found so far + cbp for inter4v search */ |
113 : | edgomez | 1.2 | const uint16_t * scan_table; /* current scan table */ |
114 : | const uint16_t * mpeg_quant_matrices; /* current MPEG quantization matrices */ | ||
115 : | syskin | 1.6 | int lambda[6]; /* R-D lambdas for all 6 blocks */ |
116 : | edgomez | 1.2 | |
117 : | } SearchData; | ||
118 : | |||
119 : | typedef void(CheckFunc)(const int x, const int y, | ||
120 : | SearchData * const Data, | ||
121 : | const unsigned int Direction); | ||
122 : | |||
123 : | CheckFunc CheckCandidate16no4v; /* shared between p-vop and b-vop search */ | ||
124 : | |||
125 : | uint8_t * | ||
126 : | xvid_me_interpolate8x8qpel(const int x, const int y, const uint32_t block, | ||
127 : | const uint32_t dir, const SearchData * const data); | ||
128 : | |||
129 : | uint8_t * | ||
130 : | xvid_me_interpolate16x16qpel(const int x, const int y, const uint32_t dir, | ||
131 : | const SearchData * const data); | ||
132 : | |||
133 : | int32_t | ||
134 : | xvid_me_ChromaSAD(const int dx, const int dy, SearchData * const data); | ||
135 : | |||
136 : | int | ||
137 : | xvid_me_SkipDecisionP(const IMAGE * current, const IMAGE * reference, | ||
138 : | const int x, const int y, | ||
139 : | syskin | 1.7 | const uint32_t stride, const uint32_t iQuant); |
140 : | edgomez | 1.2 | |
141 : | #define iDiamondSize 2 | ||
142 : | typedef void | ||
143 : | MainSearchFunc(int x, int y, SearchData * const Data, | ||
144 : | int bDirection, CheckFunc * const CheckCandidate); | ||
145 : | |||
146 : | MainSearchFunc xvid_me_DiamondSearch, xvid_me_AdvDiamondSearch, xvid_me_SquareSearch; | ||
147 : | |||
148 : | void | ||
149 : | syskin | 1.5 | xvid_me_SubpelRefine(VECTOR centerMV, SearchData * const data, CheckFunc * const CheckCandidate, int dir); |
150 : | edgomez | 1.2 | |
151 : | syskin | 1.3 | void |
152 : | FullRefine_Fast(SearchData * data, CheckFunc * CheckCandidate, int direction); | ||
153 : | edgomez | 1.2 | |
154 : | void | ||
155 : | xvid_me_ModeDecision_RD(SearchData * const Data, | ||
156 : | MACROBLOCK * const pMB, | ||
157 : | const MACROBLOCK * const pMBs, | ||
158 : | const int x, const int y, | ||
159 : | const MBParam * const pParam, | ||
160 : | const uint32_t MotionFlags, | ||
161 : | const uint32_t VopFlags, | ||
162 : | const uint32_t VolFlags, | ||
163 : | const IMAGE * const pCurrent, | ||
164 : | const IMAGE * const pRef, | ||
165 : | const IMAGE * const vGMC, | ||
166 : | const int coding_type); | ||
167 : | |||
168 : | void | ||
169 : | xvid_me_ModeDecision_Fast(SearchData * const Data, | ||
170 : | MACROBLOCK * const pMB, | ||
171 : | const MACROBLOCK * const pMBs, | ||
172 : | const int x, const int y, | ||
173 : | const MBParam * const pParam, | ||
174 : | const uint32_t MotionFlags, | ||
175 : | const uint32_t VopFlags, | ||
176 : | const uint32_t VolFlags, | ||
177 : | const IMAGE * const pCurrent, | ||
178 : | const IMAGE * const pRef, | ||
179 : | const IMAGE * const vGMC, | ||
180 : | const int coding_type); | ||
181 : | |||
182 : | syskin | 1.6 | void |
183 : | ModeDecision_BVOP_RD(SearchData * const Data_d, | ||
184 : | SearchData * const Data_b, | ||
185 : | SearchData * const Data_f, | ||
186 : | SearchData * const Data_i, | ||
187 : | MACROBLOCK * const pMB, | ||
188 : | const MACROBLOCK * const b_mb, | ||
189 : | VECTOR * f_predMV, | ||
190 : | VECTOR * b_predMV, | ||
191 : | const uint32_t MotionFlags, | ||
192 : | const MBParam * const pParam, | ||
193 : | int x, int y); | ||
194 : | |||
195 : | edgomez | 1.2 | |
196 : | #endif /* _ESTIMATION_H_ */ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |