Parent Directory | Revision Log
Revision 872 -
(view)
(download)
Original Path: trunk/xvidcore/src/motion/motion.h
1 : | edgomez | 851 | /************************************************************************** |
2 : | chl | 326 | * |
3 : | * XVID MPEG-4 VIDEO CODEC | ||
4 : | edgomez | 851 | * - Motion sad header - |
5 : | chl | 326 | * |
6 : | edgomez | 851 | * This program is an implementation of a part of one or more MPEG-4 |
7 : | * Video tools as specified in ISO/IEC 14496-2 standard. Those intending | ||
8 : | * to use this software module in hardware or software products are | ||
9 : | * advised that its use may infringe existing patents or copyrights, and | ||
10 : | * any such use would be at such party's own risk. The original | ||
11 : | * developer of this software module and his/her company, and subsequent | ||
12 : | * editors and their companies, will have no liability for use of this | ||
13 : | * software or modifications or derivatives thereof. | ||
14 : | chl | 430 | * |
15 : | edgomez | 851 | * This program is free software; you can redistribute it and/or modify |
16 : | * it under the terms of the GNU General Public License as published by | ||
17 : | chl | 326 | * the Free Software Foundation; either version 2 of the License, or |
18 : | * (at your option) any later version. | ||
19 : | * | ||
20 : | * This program is distributed in the hope that it will be useful, | ||
21 : | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
22 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
23 : | * GNU General Public License for more details. | ||
24 : | * | ||
25 : | * You should have received a copy of the GNU General Public License | ||
26 : | * along with this program; if not, write to the Free Software | ||
27 : | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
28 : | * | ||
29 : | edgomez | 872 | * $Id: motion.h,v 1.20 2003-02-19 20:12:43 edgomez Exp $ |
30 : | chl | 326 | * |
31 : | ***************************************************************************/ | ||
32 : | |||
33 : | #ifndef _MOTION_H_ | ||
34 : | #define _MOTION_H_ | ||
35 : | |||
36 : | #include "../portab.h" | ||
37 : | #include "../global.h" | ||
38 : | |||
39 : | edgomez | 851 | // fast ((A)/2)*2 |
40 : | chl | 326 | #define EVEN(A) (((A)<0?(A)+1:(A)) & ~1) |
41 : | |||
42 : | #define MVzero(A) ( ((A).x)==(0) && ((A).y)==(0) ) | ||
43 : | #define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) ) | ||
44 : | |||
45 : | edgomez | 872 | /***************************************************************************** |
46 : | * Modified rounding tables -- defined in motion_est.c | ||
47 : | * Original tables see ISO spec tables 7-6 -> 7-9 | ||
48 : | ****************************************************************************/ | ||
49 : | chl | 326 | |
50 : | edgomez | 872 | extern const uint32_t roundtab[16]; |
51 : | chl | 326 | |
52 : | edgomez | 851 | /* K = 4 */ |
53 : | edgomez | 872 | extern const uint32_t roundtab_76[16]; |
54 : | edgomez | 851 | /* K = 2 */ |
55 : | edgomez | 872 | extern const uint32_t roundtab_78[8]; |
56 : | edgomez | 851 | /* K = 1 */ |
57 : | edgomez | 872 | extern const uint32_t roundtab_79[4]; |
58 : | chl | 326 | |
59 : | |||
60 : | /* | ||
61 : | edgomez | 851 | * getref: calculate reference image pointer |
62 : | chl | 326 | * the decision to use interpolation h/v/hv or the normal image is |
63 : | * based on dx & dy. | ||
64 : | */ | ||
65 : | |||
66 : | static __inline const uint8_t * | ||
67 : | get_ref(const uint8_t * const refn, | ||
68 : | const uint8_t * const refh, | ||
69 : | const uint8_t * const refv, | ||
70 : | const uint8_t * const refhv, | ||
71 : | const uint32_t x, | ||
72 : | const uint32_t y, | ||
73 : | const uint32_t block, /* block dimension, 8 or 16 */ | ||
74 : | |||
75 : | const int32_t dx, | ||
76 : | const int32_t dy, | ||
77 : | edgomez | 851 | const int32_t stride) |
78 : | chl | 326 | { |
79 : | |||
80 : | |||
81 : | switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ | ||
82 : | case 0: | ||
83 : | return refn + (int) ((x * block + dx / 2) + (y * block + dy / 2) * stride); | ||
84 : | case 1: | ||
85 : | return refv + (int) ((x * block + dx / 2) + (y * block + | ||
86 : | (dy - 1) / 2) * stride); | ||
87 : | case 2: | ||
88 : | return refh + (int) ((x * block + (dx - 1) / 2) + (y * block + | ||
89 : | dy / 2) * stride); | ||
90 : | default: | ||
91 : | return refhv + (int) ((x * block + (dx - 1) / 2) + (y * block + | ||
92 : | (dy - 1) / 2) * stride); | ||
93 : | } | ||
94 : | |||
95 : | } | ||
96 : | |||
97 : | |||
98 : | /* This is somehow a copy of get_ref, but with MV instead of X,Y */ | ||
99 : | |||
100 : | static __inline const uint8_t * | ||
101 : | get_ref_mv(const uint8_t * const refn, | ||
102 : | const uint8_t * const refh, | ||
103 : | const uint8_t * const refv, | ||
104 : | const uint8_t * const refhv, | ||
105 : | const uint32_t x, | ||
106 : | const uint32_t y, | ||
107 : | const uint32_t block, /* block dimension, 8 or 16 */ | ||
108 : | |||
109 : | const VECTOR * mv, /* measured in half-pel! */ | ||
110 : | |||
111 : | edgomez | 851 | const int32_t stride) |
112 : | chl | 326 | { |
113 : | |||
114 : | switch ((((mv->x) & 1) << 1) + ((mv->y) & 1)) { | ||
115 : | case 0: | ||
116 : | return refn + (int) ((x * block + (mv->x) / 2) + (y * block + | ||
117 : | (mv->y) / 2) * stride); | ||
118 : | case 1: | ||
119 : | return refv + (int) ((x * block + (mv->x) / 2) + (y * block + | ||
120 : | ((mv->y) - 1) / 2) * stride); | ||
121 : | case 2: | ||
122 : | return refh + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block + | ||
123 : | (mv->y) / 2) * stride); | ||
124 : | default: | ||
125 : | return refhv + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block + | ||
126 : | ((mv->y) - | ||
127 : | 1) / 2) * stride); | ||
128 : | } | ||
129 : | |||
130 : | } | ||
131 : | |||
132 : | edgomez | 851 | void MotionEstimationBVOP(MBParam * const pParam, |
133 : | FRAMEINFO * const frame, | ||
134 : | // forward (past) reference | ||
135 : | const int32_t time_bp, | ||
136 : | const int32_t time_pp, | ||
137 : | const MACROBLOCK * const f_mbs, | ||
138 : | const IMAGE * const f_ref, | ||
139 : | const IMAGE * const f_refH, | ||
140 : | const IMAGE * const f_refV, | ||
141 : | const IMAGE * const f_refHV, | ||
142 : | // backward (future) reference | ||
143 : | const FRAMEINFO * const b_reference, | ||
144 : | const IMAGE * const b_ref, | ||
145 : | const IMAGE * const b_refH, | ||
146 : | const IMAGE * const b_refV, | ||
147 : | const IMAGE * const b_refHV); | ||
148 : | chl | 326 | |
149 : | edgomez | 851 | void MBMotionCompensationBVOP(MBParam * pParam, |
150 : | MACROBLOCK * const mb, | ||
151 : | const uint32_t i, | ||
152 : | const uint32_t j, | ||
153 : | IMAGE * const cur, | ||
154 : | const IMAGE * const f_ref, | ||
155 : | const IMAGE * const f_refh, | ||
156 : | const IMAGE * const f_refv, | ||
157 : | const IMAGE * const f_refhv, | ||
158 : | const IMAGE * const b_ref, | ||
159 : | const IMAGE * const b_refh, | ||
160 : | const IMAGE * const b_refv, | ||
161 : | const IMAGE * const b_refhv, | ||
162 : | int16_t * dct_codes); | ||
163 : | |||
164 : | |||
165 : | /* GMC stuff. Maybe better put it into a separate file */ | ||
166 : | |||
167 : | void | ||
168 : | generate_GMCparameters( const int num_wp, // [input]: number of warppoints | ||
169 : | const int res, // [input]: resolution | ||
170 : | const WARPPOINTS *const warp, // [input]: warp points | ||
171 : | const int width, const int height, // [input]: without edges! | ||
172 : | GMC_DATA *const gmc); // [output] precalculated parameters | ||
173 : | chl | 326 | |
174 : | edgomez | 851 | void |
175 : | generate_GMCimage( const GMC_DATA *const gmc_data, // [input] precalculated data | ||
176 : | const IMAGE *const pRef, // [input] | ||
177 : | const int mb_width, | ||
178 : | const int mb_height, | ||
179 : | const int stride, | ||
180 : | const int stride2, | ||
181 : | const int fcode, // [input] some parameters... | ||
182 : | const int32_t quarterpel, // [input] for rounding avgMV | ||
183 : | const int reduced_resolution, // [input] ignored | ||
184 : | const int32_t rounding, // [input] for rounding image data | ||
185 : | MACROBLOCK *const pMBs, // [output] average motion vectors | ||
186 : | IMAGE *const pGMC); // [output] full warped image | ||
187 : | |||
188 : | chl | 326 | |
189 : | edgomez | 851 | VECTOR generate_GMCimageMB( const GMC_DATA *const gmc_data, /* [input] all precalc data */ |
190 : | const IMAGE *const pRef, // [input] | ||
191 : | const int mi, const int mj, /* [input] MB position */ | ||
192 : | const int stride, /* [input] Lumi stride */ | ||
193 : | const int stride2, /* [input] chroma stride */ | ||
194 : | const int quarterpel, /* [input] for rounding of AvgMV */ | ||
195 : | const int rounding, | ||
196 : | IMAGE *const pGMC); /* [outut] generate image */ | ||
197 : | chl | 326 | |
198 : | |||
199 : | |||
200 : | edgomez | 851 | /* Hinted ME */ |
201 : | chl | 326 | |
202 : | edgomez | 851 | void |
203 : | MotionEstimationHinted( MBParam * const pParam, | ||
204 : | FRAMEINFO * const current, | ||
205 : | FRAMEINFO * const reference, | ||
206 : | const IMAGE * const pRefH, | ||
207 : | const IMAGE * const pRefV, | ||
208 : | const IMAGE * const pRefHV); | ||
209 : | chl | 326 | |
210 : | edgomez | 851 | int |
211 : | MEanalysis( const IMAGE * const pRef, | ||
212 : | FRAMEINFO * const Current, | ||
213 : | MBParam * const pParam, | ||
214 : | int maxIntra, | ||
215 : | int intraCount, | ||
216 : | int bCount); | ||
217 : | chl | 326 | |
218 : | edgomez | 851 | int |
219 : | FindFcode( const MBParam * const pParam, | ||
220 : | const FRAMEINFO * const current); | ||
221 : | chl | 326 | |
222 : | |||
223 : | edgomez | 851 | int d_amv_penalty(int x, int y, const VECTOR pred, const uint32_t iFcode, const int quant); |
224 : | |||
225 : | chl | 326 | |
226 : | #endif /* _MOTION_H_ */ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |