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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (view) (download)

1 : edgomez 1.2 /**************************************************************************
2 :     *
3 :     * XVID MPEG-4 VIDEO CODEC
4 :     * - Motion sad header -
5 :     *
6 :     * This program is free software; you can redistribute it and/or modify
7 :     * it under the terms of the GNU General Public License as published by
8 :     * the Free Software Foundation; either version 2 of the License, or
9 :     * (at your option) any later version.
10 :     *
11 :     * This program 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
14 :     * GNU General Public License for more details.
15 :     *
16 :     * You should have received a copy of the GNU General Public License
17 :     * along with this program; if not, write to the Free Software
18 :     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 :     *
20 :     * $Id: motion.h,v 1.12 2002/07/19 14:56:00 chl Exp $
21 :     *
22 :     ***************************************************************************/
23 :    
24 :     #ifndef _MOTION_H_
25 :     #define _MOTION_H_
26 :    
27 :     #include "../portab.h"
28 :     #include "../global.h"
29 : Isibaar 1.5 * $Id: motion.h,v 1.4 2002/06/12 20:38:40 edgomez Exp $
30 : edgomez 1.2 /* hard coded motion search parameters for motion_est and smp_motion_est */
31 :    
32 :     // very large value
33 : suxen_drol 1.1 #ifndef _MOTION_SAD_H_
34 :     #define _MOTION_SAD_H_
35 :     // stop search if sdelta < THRESHOLD
36 :     #define MV16_THRESHOLD 192
37 :     #define MV8_THRESHOLD 56
38 :    
39 : edgomez 1.2 int32_t * const max_dy,
40 :     const uint32_t x,
41 :     const uint32_t y,
42 :     const uint32_t block_sz, /* block dimension, 8 or 16 */
43 : suxen_drol 1.1
44 : edgomez 1.4 const uint32_t width,
45 :     const uint32_t height,
46 :     const uint32_t fcode)
47 :     {
48 :    
49 :     const int search_range = 32 << (fcode - 1);
50 :     const int high = search_range - 1;
51 :     const int low = -search_range;
52 :    
53 :     /* convert full-pixel measurements to half pixel */
54 :     const int hp_width = 2 * width;
55 :     const int hp_height = 2 * height;
56 : suxen_drol 1.1 const int hp_edge = 2 * block_sz;
57 :    
58 :     /* we need _right end_ of block, not x-coordinate */
59 :     const int hp_x = 2 * (x) * block_sz;
60 :    
61 :     /* same for _bottom end_ */
62 : edgomez 1.2 const int hp_y = 2 * (y) * block_sz;
63 : suxen_drol 1.1
64 :     *max_dx = MIN(high, hp_width - hp_x);
65 :     *max_dy = MIN(high, hp_height - hp_y);
66 :     *min_dx = MAX(low, -(hp_edge + hp_x));
67 : edgomez 1.2 *min_dy = MAX(low, -(hp_edge + hp_y));
68 :    
69 : edgomez 1.4 }
70 : edgomez 1.2
71 :    
72 :     /*
73 : edgomez 1.4 * getref: calculate reference image pointer
74 :     * the decision to use interpolation h/v/hv or the normal image is
75 :     * based on dx & dy.
76 :     */
77 : suxen_drol 1.1
78 :     static __inline const uint8_t *
79 :     get_ref(const uint8_t * const refn,
80 :     const uint8_t * const refh,
81 :     const uint8_t * const refv,
82 :     const uint8_t * const refhv,
83 :     const uint32_t x,
84 :     const uint32_t y,
85 :     const uint32_t block, /* block dimension, 8 or 16 */
86 :    
87 : edgomez 1.4 const int32_t dx,
88 :     const int32_t dy,
89 :     const uint32_t stride)
90 :     {
91 :    
92 :    
93 :     switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */
94 :     case 0:
95 :     return refn + (int) ((x * block + dx / 2) + (y * block + dy / 2) * stride);
96 :     case 1:
97 :     return refv + (int) ((x * block + dx / 2) + (y * block +
98 :     (dy - 1) / 2) * stride);
99 : suxen_drol 1.1 case 2:
100 :     return refh + (int) ((x * block + (dx - 1) / 2) + (y * block +
101 : Isibaar 1.5 dy / 2) * stride);
102 : edgomez 1.4 default:
103 :     case 3:
104 : Isibaar 1.5 return refhv + (int) ((x * block + (dx - 1) / 2) + (y * block +
105 : edgomez 1.4 (dy - 1) / 2) * stride);
106 : Isibaar 1.5 }
107 :    
108 : edgomez 1.4 }
109 : Isibaar 1.5
110 :    
111 : edgomez 1.4 /* This is somehow a copy of get_ref, but with MV instead of X,Y */
112 :    
113 : Isibaar 1.5 static __inline const uint8_t *
114 :     get_ref_mv(const uint8_t * const refn,
115 : suxen_drol 1.1 const uint8_t * const refh,
116 :     const uint8_t * const refv,
117 :     const uint8_t * const refhv,
118 :     const uint32_t x,
119 :     const uint32_t y,
120 :     const uint32_t block, /* block dimension, 8 or 16 */
121 :    
122 : edgomez 1.4 const VECTOR * mv, /* measured in half-pel! */
123 :    
124 :     const uint32_t stride)
125 :     {
126 :    
127 :     switch ((((mv->x) & 1) << 1) + ((mv->y) & 1)) {
128 :     case 0:
129 :     return refn + (int) ((x * block + (mv->x) / 2) + (y * block +
130 :     (mv->y) / 2) * stride);
131 :     case 1:
132 :     return refv + (int) ((x * block + (mv->x) / 2) + (y * block +
133 :     ((mv->y) - 1) / 2) * stride);
134 : suxen_drol 1.1 case 2:
135 :     return refh + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block +
136 : edgomez 1.4 (mv->y) / 2) * stride);
137 :     default:
138 : Isibaar 1.5 case 3:
139 :     return refhv + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block +
140 : edgomez 1.4 ((mv->y) -
141 : Isibaar 1.5 1) / 2) * stride);
142 :     }
143 : edgomez 1.4
144 : Isibaar 1.5 }
145 :    
146 : edgomez 1.4
147 :     static __inline const uint8_t *
148 : Isibaar 1.5 get_iref(const uint8_t * const ref,
149 : edgomez 1.4 const uint32_t x,
150 : Isibaar 1.5 const uint32_t y,
151 : suxen_drol 1.3 const uint32_t block, /* block dimension, 8 or 16 */
152 :    
153 :     const int32_t dx,
154 :     const int32_t dy,
155 :     const IMAGE * const f_refV,
156 : edgomez 1.4 const IMAGE * const f_refHV,
157 :     // backward (future) reference
158 :     const MACROBLOCK * const b_mbs,
159 :     const IMAGE * const b_refV,
160 :     const IMAGE * const b_refHV);
161 :    
162 :     void MBMotionCompensationBVOP(MBParam * pParam,
163 :     MACROBLOCK * const mb,
164 :     const uint32_t i,
165 :     const uint32_t j,
166 :     IMAGE * const cur,
167 :     const IMAGE * const f_ref,
168 :     const IMAGE * const f_refh,
169 :     const IMAGE * const f_refv,
170 :     const IMAGE * const f_refhv,
171 :     const IMAGE * const b_ref,
172 :     const IMAGE * const b_refh,
173 :     const IMAGE * const b_refv,
174 :     const IMAGE * const b_refhv,
175 :     int16_t * dct_codes);
176 :    
177 :    
178 :    
179 :     typedef int32_t(Halfpel8_RefineFunc) (const uint8_t * const pRef,
180 :     const uint8_t * const pRefH,
181 :     const uint8_t * const pRefV,
182 :     const uint8_t * const pRefHV,
183 :     const uint8_t * const cur,
184 :     const int x,
185 :     #endif /* _MOTION_SAD_H_ */

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