Parent Directory
|
Revision Log
Revision 698 - (view) (download)
1 : | chl | 326 | /************************************************************************** |
2 : | * | ||
3 : | * XVID MPEG-4 VIDEO CODEC | ||
4 : | * - Motion sad header - | ||
5 : | * | ||
6 : | chl | 530 | * 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 : | * | ||
15 : | chl | 326 | * 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 : | * 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 : | suxen_drol | 698 | * $Id: motion.h,v 1.13.2.7 2002-12-08 06:43:34 suxen_drol 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 : | // fast ((A)/2)*2 | ||
40 : | #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 : | Isibaar | 616 | static const uint32_t roundtab[16] = |
46 : | { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 }; | ||
47 : | |||
48 : | chl | 326 | /* |
49 : | Isibaar | 616 | * modified rounding tables |
50 : | * original tables see ISO spec tables 7-6 -> 7-9 | ||
51 : | */ | ||
52 : | |||
53 : | /* 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 : | |||
60 : | |||
61 : | /* | ||
62 : | chl | 530 | * 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 : | const uint32_t stride) | ||
79 : | { | ||
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 : | const uint32_t stride) | ||
113 : | { | ||
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 : | 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 : | syskin | 644 | const FRAMEINFO * const b_reference, |
145 : | chl | 326 | const IMAGE * const b_ref, |
146 : | const IMAGE * const b_refH, | ||
147 : | const IMAGE * const b_refV, | ||
148 : | const IMAGE * const b_refHV); | ||
149 : | |||
150 : | 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 : | chl | 530 | void |
166 : | MotionEstimationHinted( MBParam * const pParam, | ||
167 : | FRAMEINFO * const current, | ||
168 : | FRAMEINFO * const reference, | ||
169 : | const IMAGE * const pRefH, | ||
170 : | const IMAGE * const pRefV, | ||
171 : | const IMAGE * const pRefHV); | ||
172 : | chl | 326 | |
173 : | Isibaar | 539 | int |
174 : | MEanalysis( const IMAGE * const pRef, | ||
175 : | syskin | 644 | FRAMEINFO * const Current, |
176 : | Isibaar | 539 | MBParam * const pParam, |
177 : | syskin | 644 | int maxIntra, |
178 : | int intraCount, | ||
179 : | int bCount); | ||
180 : | chl | 326 | |
181 : | syskin | 576 | int |
182 : | FindFcode( const MBParam * const pParam, | ||
183 : | const FRAMEINFO * const current); | ||
184 : | Isibaar | 539 | |
185 : | chl | 619 | |
186 : | |||
187 : | chl | 326 | #endif /* _MOTION_H_ */ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |