[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.4 - (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 : edgomez 1.4 * $Id: motion.h,v 1.3 2002/05/01 13:00:02 suxen_drol 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 : edgomez 1.4 default:
102 :     case 3:
103 :     return refn + (x * block + dx / 2) + (y * block + dy / 2) * stride;
104 :     (dy - 1) / 2) * stride);
105 :     return refv + (x * block + dx / 2) + (y * block +
106 :     (dy - 1) / 2) * stride;
107 :     }
108 :     return refh + (x * block + (dx - 1) / 2) + (y * block +
109 :     dy / 2) * stride;
110 :     /* This is somehow a copy of get_ref, but with MV instead of X,Y */
111 :    
112 :     return refhv + (x * block + (dx - 1) / 2) + (y * block +
113 :     (dy - 1) / 2) * stride;
114 : suxen_drol 1.1 const uint8_t * const refh,
115 :     const uint8_t * const refv,
116 :     const uint8_t * const refhv,
117 :     const uint32_t x,
118 :     const uint32_t y,
119 :     const uint32_t block, /* block dimension, 8 or 16 */
120 :    
121 : edgomez 1.4 const VECTOR * mv, /* measured in half-pel! */
122 :    
123 :     const uint32_t stride)
124 :     {
125 :    
126 :     switch ((((mv->x) & 1) << 1) + ((mv->y) & 1)) {
127 :     case 0:
128 :     return refn + (int) ((x * block + (mv->x) / 2) + (y * block +
129 :     (mv->y) / 2) * stride);
130 :     case 1:
131 :     return refv + (int) ((x * block + (mv->x) / 2) + (y * block +
132 :     ((mv->y) - 1) / 2) * stride);
133 : suxen_drol 1.1 case 2:
134 :     return refh + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block +
135 : edgomez 1.4 (mv->y) / 2) * stride);
136 :     default:
137 :     return refn + (x * block + (mv->x) / 2) + (y * block +
138 :     (mv->y) / 2) * stride;
139 :     ((mv->y) -
140 :     return refv + (x * block + (mv->x) / 2) + (y * block +
141 :     ((mv->y) - 1) / 2) * stride;
142 :    
143 :     return refh + (x * block + ((mv->x) - 1) / 2) + (y * block +
144 :     (mv->y) / 2) * stride;
145 :    
146 :     static __inline const uint8_t *
147 :     return refhv + (x * block + ((mv->x) - 1) / 2) + (y * block +
148 :     const uint32_t x,
149 :     1) / 2) * stride;
150 : suxen_drol 1.3 const uint32_t block, /* block dimension, 8 or 16 */
151 :    
152 :     const int32_t dx,
153 :     const int32_t dy,
154 :     const IMAGE * const f_refV,
155 : edgomez 1.4 const IMAGE * const f_refHV,
156 :     // backward (future) reference
157 :     const MACROBLOCK * const b_mbs,
158 :     const IMAGE * const b_refV,
159 :     const IMAGE * const b_refHV);
160 :    
161 :     void MBMotionCompensationBVOP(MBParam * pParam,
162 :     MACROBLOCK * const mb,
163 :     const uint32_t i,
164 :     const uint32_t j,
165 :     IMAGE * const cur,
166 :     const IMAGE * const f_ref,
167 :     const IMAGE * const f_refh,
168 :     const IMAGE * const f_refv,
169 :     const IMAGE * const f_refhv,
170 :     const IMAGE * const b_ref,
171 :     const IMAGE * const b_refh,
172 :     const IMAGE * const b_refv,
173 :     const IMAGE * const b_refhv,
174 :     int16_t * dct_codes);
175 :    
176 :    
177 :    
178 :     typedef int32_t(Halfpel8_RefineFunc) (const uint8_t * const pRef,
179 :     const uint8_t * const pRefH,
180 :     const uint8_t * const pRefV,
181 :     const uint8_t * const pRefHV,
182 :     const uint8_t * const cur,
183 :     const int x,
184 :     #endif /* _MOTION_SAD_H_ */

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