Parent Directory
|
Revision Log
Revision 3 - (view) (download)
1 : | Isibaar | 3 | #ifndef _MBPREDICTION_H_ |
2 : | #define _MBPREDICTION_H_ | ||
3 : | |||
4 : | #include "../portab.h" | ||
5 : | #include "../decoder.h" | ||
6 : | #include "../global.h" | ||
7 : | |||
8 : | #define MIN(X, Y) ((X)<(Y)?(X):(Y)) | ||
9 : | #define MAX(X, Y) ((X)>(Y)?(X):(Y)) | ||
10 : | |||
11 : | // very large value | ||
12 : | #define MV_MAX_ERROR (4096 * 256) | ||
13 : | |||
14 : | #define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) ) | ||
15 : | |||
16 : | void MBPrediction(MBParam *pParam, /* <-- the parameter for ACDC and MV prediction */ | ||
17 : | uint32_t x_pos, /* <-- The x position of the MB to be searched */ | ||
18 : | uint32_t y_pos, /* <-- The y position of the MB to be searched */ | ||
19 : | uint32_t x_dim, /* <-- Number of macroblocks in a row */ | ||
20 : | int16_t qcoeff[][64], /* <-> The quantized DCT coefficients */ | ||
21 : | MACROBLOCK *MB_array /* <-> the array of all the MB Infomations */ | ||
22 : | ); | ||
23 : | |||
24 : | void add_acdc(MACROBLOCK *pMB, | ||
25 : | uint32_t block, | ||
26 : | int16_t dct_codes[64], | ||
27 : | uint32_t iDcScaler, | ||
28 : | int16_t predictors[8]); | ||
29 : | |||
30 : | |||
31 : | void predict_acdc(MACROBLOCK *pMBs, | ||
32 : | uint32_t x, uint32_t y, uint32_t mb_width, | ||
33 : | uint32_t block, | ||
34 : | int16_t qcoeff[64], | ||
35 : | uint32_t current_quant, | ||
36 : | int32_t iDcScaler, | ||
37 : | int16_t predictors[8]); | ||
38 : | |||
39 : | /* This is somehow a copy of get_pmv, but returning all MVs and Minimum SAD | ||
40 : | instead of only Median MV */ | ||
41 : | |||
42 : | static __inline int get_pmvdata(const MACROBLOCK * const pMBs, | ||
43 : | const uint32_t x, const uint32_t y, | ||
44 : | const uint32_t x_dim, | ||
45 : | const uint32_t block, | ||
46 : | VECTOR * const pmv, | ||
47 : | int32_t * const psad) | ||
48 : | { | ||
49 : | /* pmv are filled with: | ||
50 : | [0]: Median (or whatever is correct in a special case) | ||
51 : | [1]: left neighbour | ||
52 : | [2]: top neighbour, | ||
53 : | [3]: topright neighbour, | ||
54 : | psad are filled with: | ||
55 : | [0]: minimum of [1] to [3] | ||
56 : | [1]: left neighbour's SAD // [1] to [3] are actually not needed | ||
57 : | [2]: top neighbour's SAD, | ||
58 : | [3]: topright neighbour's SAD, | ||
59 : | */ | ||
60 : | |||
61 : | int xin1, xin2, xin3; | ||
62 : | int yin1, yin2, yin3; | ||
63 : | int vec1, vec2, vec3; | ||
64 : | |||
65 : | static VECTOR zeroMV; | ||
66 : | uint32_t index = x + y * x_dim; | ||
67 : | zeroMV.x = zeroMV.y = 0; | ||
68 : | |||
69 : | // first row (special case) | ||
70 : | if (y == 0 && (block == 0 || block == 1)) | ||
71 : | { | ||
72 : | if ((x == 0) && (block == 0)) // first column, first block | ||
73 : | { | ||
74 : | pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV; | ||
75 : | psad[0] = psad[1] = psad[2] = psad[3] = MV_MAX_ERROR; | ||
76 : | return 0; | ||
77 : | } | ||
78 : | if (block == 1) // second block; has only a left neighbour | ||
79 : | { | ||
80 : | pmv[0] = pmv[1] = pMBs[index].mvs[0]; | ||
81 : | pmv[2] = pmv[3] = zeroMV; | ||
82 : | psad[0] = psad[1] = pMBs[index].sad8[0]; | ||
83 : | psad[2] = psad[3] = MV_MAX_ERROR; | ||
84 : | return 0; | ||
85 : | } | ||
86 : | else /* block==0, but x!=0, so again, there is a left neighbour*/ | ||
87 : | { | ||
88 : | pmv[0] = pmv[1] = pMBs[index-1].mvs[1]; | ||
89 : | pmv[2] = pmv[3] = zeroMV; | ||
90 : | psad[0] = psad[1] = pMBs[index-1].sad8[1]; | ||
91 : | psad[2] = psad[3] = MV_MAX_ERROR; | ||
92 : | return 0; | ||
93 : | } | ||
94 : | } | ||
95 : | |||
96 : | /* | ||
97 : | MODE_INTER, vm18 page 48 | ||
98 : | MODE_INTER4V vm18 page 51 | ||
99 : | |||
100 : | (x,y-1) (x+1,y-1) | ||
101 : | [ | ] [ | ] | ||
102 : | [ 2 | 3 ] [ 2 | ] | ||
103 : | |||
104 : | (x-1,y) (x,y) (x+1,y) | ||
105 : | [ | 1 ] [ 0 | 1 ] [ 0 | ] | ||
106 : | [ | 3 ] [ 2 | 3 ] [ | ] | ||
107 : | */ | ||
108 : | |||
109 : | switch (block) | ||
110 : | { | ||
111 : | case 0: | ||
112 : | xin1 = x - 1; yin1 = y; vec1 = 1; /* left */ | ||
113 : | xin2 = x; yin2 = y - 1; vec2 = 2; /* top */ | ||
114 : | xin3 = x + 1; yin3 = y - 1; vec3 = 2; /* top right */ | ||
115 : | break; | ||
116 : | case 1: | ||
117 : | xin1 = x; yin1 = y; vec1 = 0; | ||
118 : | xin2 = x; yin2 = y - 1; vec2 = 3; | ||
119 : | xin3 = x + 1; yin3 = y - 1; vec3 = 2; | ||
120 : | break; | ||
121 : | case 2: | ||
122 : | xin1 = x - 1; yin1 = y; vec1 = 3; | ||
123 : | xin2 = x; yin2 = y; vec2 = 0; | ||
124 : | xin3 = x; yin3 = y; vec3 = 1; | ||
125 : | break; | ||
126 : | default: | ||
127 : | xin1 = x; yin1 = y; vec1 = 2; | ||
128 : | xin2 = x; yin2 = y; vec2 = 0; | ||
129 : | xin3 = x; yin3 = y; vec3 = 1; | ||
130 : | } | ||
131 : | |||
132 : | |||
133 : | if (xin1 < 0 || /* yin1 < 0 || */ xin1 >= (int32_t)x_dim) | ||
134 : | { | ||
135 : | pmv[1] = zeroMV; | ||
136 : | psad[1] = MV_MAX_ERROR; | ||
137 : | } | ||
138 : | else | ||
139 : | { | ||
140 : | pmv[1] = pMBs[xin1 + yin1 * x_dim].mvs[vec1]; | ||
141 : | psad[1] = pMBs[xin1 + yin1 * x_dim].sad8[vec1]; | ||
142 : | } | ||
143 : | |||
144 : | if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t)x_dim) | ||
145 : | { | ||
146 : | pmv[2] = zeroMV; | ||
147 : | psad[2] = MV_MAX_ERROR; | ||
148 : | } | ||
149 : | else | ||
150 : | { | ||
151 : | pmv[2] = pMBs[xin2 + yin2 * x_dim].mvs[vec2]; | ||
152 : | psad[2] = pMBs[xin2 + yin2 * x_dim].sad8[vec2]; | ||
153 : | } | ||
154 : | |||
155 : | if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t)x_dim) | ||
156 : | { | ||
157 : | pmv[3] = zeroMV; | ||
158 : | psad[3] = MV_MAX_ERROR; | ||
159 : | } | ||
160 : | else | ||
161 : | { | ||
162 : | pmv[3] = pMBs[xin3 + yin3 * x_dim].mvs[vec3]; | ||
163 : | psad[3] = pMBs[xin2 + yin2 * x_dim].sad8[vec3]; | ||
164 : | } | ||
165 : | |||
166 : | if ( (MVequal(pmv[1],pmv[2])) && (MVequal(pmv[1],pmv[3])) ) | ||
167 : | { pmv[0]=pmv[1]; | ||
168 : | psad[0]=psad[1]; | ||
169 : | return 1; | ||
170 : | } | ||
171 : | |||
172 : | // median,minimum | ||
173 : | |||
174 : | pmv[0].x = MIN(MAX(pmv[1].x, pmv[2].x), MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x))); | ||
175 : | pmv[0].y = MIN(MAX(pmv[1].y, pmv[2].y), MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y))); | ||
176 : | psad[0]=MIN(MIN(psad[1],psad[2]),psad[3]); | ||
177 : | return 0; | ||
178 : | } | ||
179 : | |||
180 : | |||
181 : | #endif /* _MBPREDICTION_H_ */ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |