[svn] / trunk / xvidcore / src / motion / motion.h Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/motion/motion.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 851 - (view) (download)

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 851 * $Id: motion.h,v 1.19 2003-02-15 15:22:18 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 851 static const uint32_t roundtab[16] =
46 :     { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };
47 : chl 326
48 :     /*
49 : edgomez 851 * modified rounding tables
50 :     * original tables see ISO spec tables 7-6 -> 7-9
51 : chl 326 */
52 :    
53 : edgomez 851 /* K = 4 */
54 :     static const uint32_t roundtab_76[16] = { 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1 };
55 :     /* K = 2 */
56 :     static const uint32_t roundtab_78[8] = { 0, 0, 1, 1, 0, 0, 0, 1 };
57 :     /* K = 1 */
58 :     static const uint32_t roundtab_79[4] = { 0, 1, 0, 0 };
59 : chl 326
60 :    
61 :     /*
62 : edgomez 851 * getref: calculate reference image pointer
63 : chl 326 * the decision to use interpolation h/v/hv or the normal image is
64 :     * based on dx & dy.
65 :     */
66 :    
67 :     static __inline const uint8_t *
68 :     get_ref(const uint8_t * const refn,
69 :     const uint8_t * const refh,
70 :     const uint8_t * const refv,
71 :     const uint8_t * const refhv,
72 :     const uint32_t x,
73 :     const uint32_t y,
74 :     const uint32_t block, /* block dimension, 8 or 16 */
75 :    
76 :     const int32_t dx,
77 :     const int32_t dy,
78 : edgomez 851 const int32_t stride)
79 : chl 326 {
80 :    
81 :    
82 :     switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */
83 :     case 0:
84 :     return refn + (int) ((x * block + dx / 2) + (y * block + dy / 2) * stride);
85 :     case 1:
86 :     return refv + (int) ((x * block + dx / 2) + (y * block +
87 :     (dy - 1) / 2) * stride);
88 :     case 2:
89 :     return refh + (int) ((x * block + (dx - 1) / 2) + (y * block +
90 :     dy / 2) * stride);
91 :     default:
92 :     return refhv + (int) ((x * block + (dx - 1) / 2) + (y * block +
93 :     (dy - 1) / 2) * stride);
94 :     }
95 :    
96 :     }
97 :    
98 :    
99 :     /* This is somehow a copy of get_ref, but with MV instead of X,Y */
100 :    
101 :     static __inline const uint8_t *
102 :     get_ref_mv(const uint8_t * const refn,
103 :     const uint8_t * const refh,
104 :     const uint8_t * const refv,
105 :     const uint8_t * const refhv,
106 :     const uint32_t x,
107 :     const uint32_t y,
108 :     const uint32_t block, /* block dimension, 8 or 16 */
109 :    
110 :     const VECTOR * mv, /* measured in half-pel! */
111 :    
112 : edgomez 851 const int32_t stride)
113 : chl 326 {
114 :    
115 :     switch ((((mv->x) & 1) << 1) + ((mv->y) & 1)) {
116 :     case 0:
117 :     return refn + (int) ((x * block + (mv->x) / 2) + (y * block +
118 :     (mv->y) / 2) * stride);
119 :     case 1:
120 :     return refv + (int) ((x * block + (mv->x) / 2) + (y * block +
121 :     ((mv->y) - 1) / 2) * stride);
122 :     case 2:
123 :     return refh + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block +
124 :     (mv->y) / 2) * stride);
125 :     default:
126 :     return refhv + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block +
127 :     ((mv->y) -
128 :     1) / 2) * stride);
129 :     }
130 :    
131 :     }
132 :    
133 : edgomez 851 void MotionEstimationBVOP(MBParam * const pParam,
134 :     FRAMEINFO * const frame,
135 :     // forward (past) reference
136 :     const int32_t time_bp,
137 :     const int32_t time_pp,
138 :     const MACROBLOCK * const f_mbs,
139 :     const IMAGE * const f_ref,
140 :     const IMAGE * const f_refH,
141 :     const IMAGE * const f_refV,
142 :     const IMAGE * const f_refHV,
143 :     // backward (future) reference
144 :     const FRAMEINFO * const b_reference,
145 :     const IMAGE * const b_ref,
146 :     const IMAGE * const b_refH,
147 :     const IMAGE * const b_refV,
148 :     const IMAGE * const b_refHV);
149 : chl 326
150 : edgomez 851 void MBMotionCompensationBVOP(MBParam * pParam,
151 :     MACROBLOCK * const mb,
152 :     const uint32_t i,
153 :     const uint32_t j,
154 :     IMAGE * const cur,
155 :     const IMAGE * const f_ref,
156 :     const IMAGE * const f_refh,
157 :     const IMAGE * const f_refv,
158 :     const IMAGE * const f_refhv,
159 :     const IMAGE * const b_ref,
160 :     const IMAGE * const b_refh,
161 :     const IMAGE * const b_refv,
162 :     const IMAGE * const b_refhv,
163 :     int16_t * dct_codes);
164 :    
165 :    
166 :     /* GMC stuff. Maybe better put it into a separate file */
167 :    
168 :     void
169 :     generate_GMCparameters( const int num_wp, // [input]: number of warppoints
170 :     const int res, // [input]: resolution
171 :     const WARPPOINTS *const warp, // [input]: warp points
172 :     const int width, const int height, // [input]: without edges!
173 :     GMC_DATA *const gmc); // [output] precalculated parameters
174 : chl 326
175 : edgomez 851 void
176 :     generate_GMCimage( const GMC_DATA *const gmc_data, // [input] precalculated data
177 :     const IMAGE *const pRef, // [input]
178 :     const int mb_width,
179 :     const int mb_height,
180 :     const int stride,
181 :     const int stride2,
182 :     const int fcode, // [input] some parameters...
183 :     const int32_t quarterpel, // [input] for rounding avgMV
184 :     const int reduced_resolution, // [input] ignored
185 :     const int32_t rounding, // [input] for rounding image data
186 :     MACROBLOCK *const pMBs, // [output] average motion vectors
187 :     IMAGE *const pGMC); // [output] full warped image
188 :    
189 : chl 326
190 : edgomez 851 VECTOR generate_GMCimageMB( const GMC_DATA *const gmc_data, /* [input] all precalc data */
191 :     const IMAGE *const pRef, // [input]
192 :     const int mi, const int mj, /* [input] MB position */
193 :     const int stride, /* [input] Lumi stride */
194 :     const int stride2, /* [input] chroma stride */
195 :     const int quarterpel, /* [input] for rounding of AvgMV */
196 :     const int rounding,
197 :     IMAGE *const pGMC); /* [outut] generate image */
198 : chl 326
199 :    
200 :    
201 : edgomez 851 /* Hinted ME */
202 : chl 326
203 : edgomez 851 void
204 :     MotionEstimationHinted( MBParam * const pParam,
205 :     FRAMEINFO * const current,
206 :     FRAMEINFO * const reference,
207 :     const IMAGE * const pRefH,
208 :     const IMAGE * const pRefV,
209 :     const IMAGE * const pRefHV);
210 : chl 326
211 : edgomez 851 int
212 :     MEanalysis( const IMAGE * const pRef,
213 :     FRAMEINFO * const Current,
214 :     MBParam * const pParam,
215 :     int maxIntra,
216 :     int intraCount,
217 :     int bCount);
218 : chl 326
219 : edgomez 851 int
220 :     FindFcode( const MBParam * const pParam,
221 :     const FRAMEINFO * const current);
222 : chl 326
223 :    
224 : edgomez 851 int d_amv_penalty(int x, int y, const VECTOR pred, const uint32_t iFcode, const int quant);
225 :    
226 : chl 326
227 :     #endif /* _MOTION_H_ */

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4