Parent Directory | Revision Log
Revision 1053 - (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 | 1053 | * $Id: motion.h,v 1.20.2.2 2003-06-09 01:21:17 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 | 1053 | /* 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 | 872 | /***************************************************************************** |
46 : | * Modified rounding tables -- defined in motion_est.c | ||
47 : | * Original tables see ISO spec tables 7-6 -> 7-9 | ||
48 : | ****************************************************************************/ | ||
49 : | chl | 326 | |
50 : | edgomez | 872 | extern const uint32_t roundtab[16]; |
51 : | edgomez | 851 | /* K = 4 */ |
52 : | edgomez | 872 | extern const uint32_t roundtab_76[16]; |
53 : | edgomez | 851 | /* K = 2 */ |
54 : | edgomez | 872 | extern const uint32_t roundtab_78[8]; |
55 : | edgomez | 851 | /* K = 1 */ |
56 : | edgomez | 872 | extern const uint32_t roundtab_79[4]; |
57 : | chl | 326 | |
58 : | /* | ||
59 : | edgomez | 851 | * getref: calculate reference image pointer |
60 : | chl | 326 | * the decision to use interpolation h/v/hv or the normal image is |
61 : | * based on dx & dy. | ||
62 : | */ | ||
63 : | |||
64 : | static __inline const uint8_t * | ||
65 : | get_ref(const uint8_t * const refn, | ||
66 : | const uint8_t * const refh, | ||
67 : | const uint8_t * const refv, | ||
68 : | const uint8_t * const refhv, | ||
69 : | const uint32_t x, | ||
70 : | const uint32_t y, | ||
71 : | const uint32_t block, /* block dimension, 8 or 16 */ | ||
72 : | const int32_t dx, | ||
73 : | const int32_t dy, | ||
74 : | edgomez | 851 | const int32_t stride) |
75 : | chl | 326 | { |
76 : | switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ | ||
77 : | case 0: | ||
78 : | return refn + (int) ((x * block + dx / 2) + (y * block + dy / 2) * stride); | ||
79 : | case 1: | ||
80 : | edgomez | 953 | return refv + (int) ((x * block + dx / 2) + (y * block + (dy - 1) / 2) * stride); |
81 : | chl | 326 | case 2: |
82 : | edgomez | 953 | return refh + (int) ((x * block + (dx - 1) / 2) + (y * block + dy / 2) * stride); |
83 : | chl | 326 | default: |
84 : | edgomez | 953 | return refhv + (int) ((x * block + (dx - 1) / 2) + (y * block + (dy - 1) / 2) * stride); |
85 : | chl | 326 | } |
86 : | } | ||
87 : | |||
88 : | edgomez | 851 | void MotionEstimationBVOP(MBParam * const pParam, |
89 : | edgomez | 953 | FRAMEINFO * const frame, |
90 : | edgomez | 1053 | /* forward (past) reference */ |
91 : | edgomez | 953 | const int32_t time_bp, |
92 : | const int32_t time_pp, | ||
93 : | const MACROBLOCK * const f_mbs, | ||
94 : | const IMAGE * const f_ref, | ||
95 : | const IMAGE * const f_refH, | ||
96 : | const IMAGE * const f_refV, | ||
97 : | const IMAGE * const f_refHV, | ||
98 : | edgomez | 1053 | /* backward (future) reference */ |
99 : | edgomez | 953 | const FRAMEINFO * const b_reference, |
100 : | const IMAGE * const b_ref, | ||
101 : | const IMAGE * const b_refH, | ||
102 : | const IMAGE * const b_refV, | ||
103 : | const IMAGE * const b_refHV); | ||
104 : | chl | 326 | |
105 : | edgomez | 851 | void MBMotionCompensationBVOP(MBParam * pParam, |
106 : | edgomez | 953 | MACROBLOCK * const mb, |
107 : | const uint32_t i, | ||
108 : | const uint32_t j, | ||
109 : | IMAGE * const cur, | ||
110 : | const IMAGE * const f_ref, | ||
111 : | const IMAGE * const f_refh, | ||
112 : | const IMAGE * const f_refv, | ||
113 : | const IMAGE * const f_refhv, | ||
114 : | const IMAGE * const b_ref, | ||
115 : | const IMAGE * const b_refh, | ||
116 : | const IMAGE * const b_refv, | ||
117 : | const IMAGE * const b_refhv, | ||
118 : | int16_t * dct_codes); | ||
119 : | |||
120 : | |||
121 : | edgomez | 851 | /* GMC stuff. Maybe better put it into a separate file */ |
122 : | edgomez | 953 | |
123 : | void | ||
124 : | edgomez | 1053 | generate_GMCparameters( const int num_wp, /* [input]: number of warppoints */ |
125 : | const int res, /* [input]: resolution */ | ||
126 : | const WARPPOINTS *const warp, /* [input]: warp points */ | ||
127 : | const int width, const int height, /* [input]: without edges! */ | ||
128 : | GMC_DATA *const gmc); /* [output] precalculated parameters */ | ||
129 : | chl | 326 | |
130 : | edgomez | 953 | void |
131 : | edgomez | 1053 | generate_GMCimage( const GMC_DATA *const gmc_data, /* [input] precalculated data */ |
132 : | const IMAGE *const pRef, /* [input] */ | ||
133 : | edgomez | 953 | const int mb_width, |
134 : | edgomez | 851 | const int mb_height, |
135 : | const int stride, | ||
136 : | edgomez | 953 | const int stride2, |
137 : | edgomez | 1053 | const int fcode, /* [input] some parameters... */ |
138 : | const int32_t quarterpel, /* [input] for rounding avgMV */ | ||
139 : | const int reduced_resolution, /* [input] ignored */ | ||
140 : | const int32_t rounding, /* [input] for rounding image data */ | ||
141 : | MACROBLOCK *const pMBs, /* [output] average motion vectors */ | ||
142 : | IMAGE *const pGMC); /* [output] full warped image */ | ||
143 : | chl | 326 | |
144 : | edgomez | 851 | VECTOR generate_GMCimageMB( const GMC_DATA *const gmc_data, /* [input] all precalc data */ |
145 : | edgomez | 1053 | const IMAGE *const pRef, /* [input] */ |
146 : | edgomez | 953 | const int mi, const int mj, /* [input] MB position */ |
147 : | edgomez | 851 | const int stride, /* [input] Lumi stride */ |
148 : | const int stride2, /* [input] chroma stride */ | ||
149 : | const int quarterpel, /* [input] for rounding of AvgMV */ | ||
150 : | edgomez | 953 | const int rounding, |
151 : | edgomez | 851 | IMAGE *const pGMC); /* [outut] generate image */ |
152 : | chl | 326 | |
153 : | edgomez | 851 | int |
154 : | edgomez | 953 | MEanalysis( const IMAGE * const pRef, |
155 : | const FRAMEINFO * const Current, | ||
156 : | const MBParam * const pParam, | ||
157 : | const int maxIntra, | ||
158 : | const int intraCount, | ||
159 : | const int bCount, | ||
160 : | const int b_thresh); | ||
161 : | chl | 326 | |
162 : | #endif /* _MOTION_H_ */ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |