Parent Directory | Revision Log
Revision 530 - (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 : | chl | 530 | * $Id: motion.h,v 1.13.2.1 2002-09-23 20:36:01 chl 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 : | /* | ||
46 : | chl | 530 | * getref: calculate reference image pointer |
47 : | chl | 326 | * the decision to use interpolation h/v/hv or the normal image is |
48 : | * based on dx & dy. | ||
49 : | */ | ||
50 : | |||
51 : | static __inline const uint8_t * | ||
52 : | get_ref(const uint8_t * const refn, | ||
53 : | const uint8_t * const refh, | ||
54 : | const uint8_t * const refv, | ||
55 : | const uint8_t * const refhv, | ||
56 : | const uint32_t x, | ||
57 : | const uint32_t y, | ||
58 : | const uint32_t block, /* block dimension, 8 or 16 */ | ||
59 : | |||
60 : | const int32_t dx, | ||
61 : | const int32_t dy, | ||
62 : | const uint32_t stride) | ||
63 : | { | ||
64 : | |||
65 : | |||
66 : | switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ | ||
67 : | case 0: | ||
68 : | return refn + (int) ((x * block + dx / 2) + (y * block + dy / 2) * stride); | ||
69 : | case 1: | ||
70 : | return refv + (int) ((x * block + dx / 2) + (y * block + | ||
71 : | (dy - 1) / 2) * stride); | ||
72 : | case 2: | ||
73 : | return refh + (int) ((x * block + (dx - 1) / 2) + (y * block + | ||
74 : | dy / 2) * stride); | ||
75 : | default: | ||
76 : | return refhv + (int) ((x * block + (dx - 1) / 2) + (y * block + | ||
77 : | (dy - 1) / 2) * stride); | ||
78 : | } | ||
79 : | |||
80 : | } | ||
81 : | |||
82 : | |||
83 : | /* This is somehow a copy of get_ref, but with MV instead of X,Y */ | ||
84 : | |||
85 : | static __inline const uint8_t * | ||
86 : | get_ref_mv(const uint8_t * const refn, | ||
87 : | const uint8_t * const refh, | ||
88 : | const uint8_t * const refv, | ||
89 : | const uint8_t * const refhv, | ||
90 : | const uint32_t x, | ||
91 : | const uint32_t y, | ||
92 : | const uint32_t block, /* block dimension, 8 or 16 */ | ||
93 : | |||
94 : | const VECTOR * mv, /* measured in half-pel! */ | ||
95 : | |||
96 : | const uint32_t stride) | ||
97 : | { | ||
98 : | |||
99 : | switch ((((mv->x) & 1) << 1) + ((mv->y) & 1)) { | ||
100 : | case 0: | ||
101 : | return refn + (int) ((x * block + (mv->x) / 2) + (y * block + | ||
102 : | (mv->y) / 2) * stride); | ||
103 : | case 1: | ||
104 : | return refv + (int) ((x * block + (mv->x) / 2) + (y * block + | ||
105 : | ((mv->y) - 1) / 2) * stride); | ||
106 : | case 2: | ||
107 : | return refh + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block + | ||
108 : | (mv->y) / 2) * stride); | ||
109 : | default: | ||
110 : | return refhv + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block + | ||
111 : | ((mv->y) - | ||
112 : | 1) / 2) * stride); | ||
113 : | } | ||
114 : | |||
115 : | } | ||
116 : | |||
117 : | void MotionEstimationBVOP(MBParam * const pParam, | ||
118 : | FRAMEINFO * const frame, | ||
119 : | // forward (past) reference | ||
120 : | const int32_t time_bp, | ||
121 : | const int32_t time_pp, | ||
122 : | const MACROBLOCK * const f_mbs, | ||
123 : | const IMAGE * const f_ref, | ||
124 : | const IMAGE * const f_refH, | ||
125 : | const IMAGE * const f_refV, | ||
126 : | const IMAGE * const f_refHV, | ||
127 : | // backward (future) reference | ||
128 : | const MACROBLOCK * const b_mbs, | ||
129 : | const IMAGE * const b_ref, | ||
130 : | const IMAGE * const b_refH, | ||
131 : | const IMAGE * const b_refV, | ||
132 : | const IMAGE * const b_refHV); | ||
133 : | |||
134 : | void MBMotionCompensationBVOP(MBParam * pParam, | ||
135 : | MACROBLOCK * const mb, | ||
136 : | const uint32_t i, | ||
137 : | const uint32_t j, | ||
138 : | IMAGE * const cur, | ||
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 : | const IMAGE * const b_ref, | ||
144 : | const IMAGE * const b_refh, | ||
145 : | const IMAGE * const b_refv, | ||
146 : | const IMAGE * const b_refhv, | ||
147 : | int16_t * dct_codes); | ||
148 : | |||
149 : | chl | 530 | void |
150 : | MotionEstimationHinted( MBParam * const pParam, | ||
151 : | FRAMEINFO * const current, | ||
152 : | FRAMEINFO * const reference, | ||
153 : | const IMAGE * const pRefH, | ||
154 : | const IMAGE * const pRefV, | ||
155 : | const IMAGE * const pRefHV); | ||
156 : | chl | 326 | |
157 : | |||
158 : | #endif /* _MOTION_H_ */ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |