[cvs] / xvidcore / src / prediction / mbprediction.h Repository:
ViewVC logotype

Diff of /xvidcore/src/prediction/mbprediction.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7, Tue May 7 19:40:36 2002 UTC revision 1.11, Sun Jun 30 10:46:29 2002 UTC
# Line 30  Line 30 
30   *   *
31   *************************************************************************/   *************************************************************************/
32    
33     /******************************************************************************
34      *                                                                            *
35      *  Revision history:                                                         *
36      *                                                                            *
37      *  29.06.2002 get_pmvdata() bounding                                         *
38      *                                                                            *
39      ******************************************************************************/
40    
41    
42  #ifndef _MBPREDICTION_H_  #ifndef _MBPREDICTION_H_
43  #define _MBPREDICTION_H_  #define _MBPREDICTION_H_
44    
# Line 45  Line 54 
54    
55  #define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) )  #define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) )
56    
57  void MBPrediction(  void MBPrediction(FRAMEINFO * frame,    /* <-- The parameter for ACDC and MV prediction */
58          FRAMEINFO *frame, /* <-- The parameter for ACDC and MV prediction */  
59          uint32_t x_pos,   /* <-- The x position of the MB to be searched  */          uint32_t x_pos,   /* <-- The x position of the MB to be searched  */
60    
61          uint32_t y_pos,   /* <-- The y position of the MB to be searched  */          uint32_t y_pos,   /* <-- The y position of the MB to be searched  */
62    
63          uint32_t x_dim,   /* <-- Number of macroblocks in a row           */          uint32_t x_dim,   /* <-- Number of macroblocks in a row           */
64    
65          int16_t *qcoeff); /* <-> The quantized DCT coefficients           */          int16_t *qcoeff); /* <-> The quantized DCT coefficients           */
66    
67  void add_acdc(MACROBLOCK *pMB,  void add_acdc(MACROBLOCK *pMB,
# Line 67  Line 79 
79                    int16_t qcoeff[64],                    int16_t qcoeff[64],
80                    uint32_t current_quant,                    uint32_t current_quant,
81                    int32_t iDcScaler,                    int32_t iDcScaler,
82                    int16_t predictors[8]);                                    int16_t predictors[8],
83                                    const int bound);
84    
85    
86  /* get_pmvdata returns the median predictor and nothing else */  /* get_pmvdata returns the median predictor and nothing else */
87    
88  static __inline VECTOR get_pmv(const MACROBLOCK * const pMBs,  static __inline VECTOR
89    get_pmv(const MACROBLOCK * const pMBs,
90                                 const uint32_t x,                                 const uint32_t x,
91                                 const uint32_t y,                                 const uint32_t y,
92                                 const uint32_t x_dim,                                 const uint32_t x_dim,
# Line 88  Line 103 
103          uint32_t index = x + y * x_dim;          uint32_t index = x + y * x_dim;
104    
105          /* first row (special case) */          /* first row (special case) */
106          if (y == 0 && (block == 0 || block == 1))          if (y == 0 && (block == 0 || block == 1)) {
         {  
107                  if ((x == 0) && (block == 0))           // first column, first block                  if ((x == 0) && (block == 0))           // first column, first block
108                  {                  {
109                          return zeroMV;                          return zeroMV;
# Line 97  Line 111 
111                  if (block == 1)         // second block; has only a left neighbour                  if (block == 1)         // second block; has only a left neighbour
112                  {                  {
113                          return pMBs[index].mvs[0];                          return pMBs[index].mvs[0];
114                  }                  } else {                                /* block==0, but x!=0, so again, there is a left neighbour */
115                  else /* block==0, but x!=0, so again, there is a left neighbour*/  
                 {  
116                          return pMBs[index-1].mvs[1];                          return pMBs[index-1].mvs[1];
117                  }                  }
118          }          }
# Line 117  Line 130 
130           *   [   | 3 ]    [ 2 | 3 ]    [   |   ]           *   [   | 3 ]    [ 2 | 3 ]    [   |   ]
131           */           */
132    
133          switch (block)          switch (block) {
         {  
134          case 0:          case 0:
135                  xin1 = x - 1;   yin1 = y;       vec1 = 1;       /* left */                  xin1 = x - 1;
136                  xin2 = x;       yin2 = y - 1;   vec2 = 2;       /* top */                  yin1 = y;
137                  xin3 = x + 1;   yin3 = y - 1;   vec3 = 2;       /* top right */                  vec1 = 1;                               /* left */
138                    xin2 = x;
139                    yin2 = y - 1;
140                    vec2 = 2;                               /* top */
141                    xin3 = x + 1;
142                    yin3 = y - 1;
143                    vec3 = 2;                               /* top right */
144                  break;                  break;
145          case 1:          case 1:
146                  xin1 = x;               yin1 = y;               vec1 = 0;                  xin1 = x;
147                  xin2 = x;               yin2 = y - 1;   vec2 = 3;                  yin1 = y;
148                  xin3 = x + 1;   yin3 = y - 1;   vec3 = 2;                  vec1 = 0;
149                    xin2 = x;
150                    yin2 = y - 1;
151                    vec2 = 3;
152                    xin3 = x + 1;
153                    yin3 = y - 1;
154                    vec3 = 2;
155                  break;                  break;
156          case 2:          case 2:
157                  xin1 = x - 1;   yin1 = y;               vec1 = 3;                  xin1 = x - 1;
158                  xin2 = x;               yin2 = y;               vec2 = 0;                  yin1 = y;
159                  xin3 = x;               yin3 = y;               vec3 = 1;                  vec1 = 3;
160                    xin2 = x;
161                    yin2 = y;
162                    vec2 = 0;
163                    xin3 = x;
164                    yin3 = y;
165                    vec3 = 1;
166                  break;                  break;
167          default:          default:
168                  xin1 = x;               yin1 = y;               vec1 = 2;                  xin1 = x;
169                  xin2 = x;               yin2 = y;               vec2 = 0;                  yin1 = y;
170                  xin3 = x;               yin3 = y;               vec3 = 1;                  vec1 = 2;
171                    xin2 = x;
172                    yin2 = y;
173                    vec2 = 0;
174                    xin3 = x;
175                    yin3 = y;
176                    vec3 = 1;
177          }          }
178    
179    
180          if (xin1 < 0 || /* yin1 < 0  || */ xin1 >= (int32_t)x_dim)          if (xin1 < 0 || /* yin1 < 0  || */ xin1 >= (int32_t) x_dim) {
         {  
181                  lneigh = zeroMV;                  lneigh = zeroMV;
182          }          } else {
         else  
         {  
183                  lneigh = pMBs[xin1 + yin1 * x_dim].mvs[vec1];                  lneigh = pMBs[xin1 + yin1 * x_dim].mvs[vec1];
184          }          }
185    
186          if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t)x_dim)          if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t) x_dim) {
         {  
187                  tneigh = zeroMV;                  tneigh = zeroMV;
188          }          } else {
         else  
         {  
189                  tneigh = pMBs[xin2 + yin2 * x_dim].mvs[vec2];                  tneigh = pMBs[xin2 + yin2 * x_dim].mvs[vec2];
190          }          }
191    
192          if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t)x_dim)          if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t) x_dim) {
         {  
193                  trneigh = zeroMV;                  trneigh = zeroMV;
194          }          } else {
         else  
         {  
195                  trneigh = pMBs[xin3 + yin3 * x_dim].mvs[vec3];                  trneigh = pMBs[xin3 + yin3 * x_dim].mvs[vec3];
196          }          }
197    
198          /* median,minimum */          /* median,minimum */
199    
200          median.x = MIN(MAX(lneigh.x, tneigh.x), MIN(MAX(tneigh.x, trneigh.x), MAX(lneigh.x, trneigh.x)));          median.x =
201          median.y = MIN(MAX(lneigh.y, tneigh.y), MIN(MAX(tneigh.y, trneigh.y), MAX(lneigh.y, trneigh.y)));                  MIN(MAX(lneigh.x, tneigh.x),
202                            MIN(MAX(tneigh.x, trneigh.x), MAX(lneigh.x, trneigh.x)));
203            median.y =
204                    MIN(MAX(lneigh.y, tneigh.y),
205                            MIN(MAX(tneigh.y, trneigh.y), MAX(lneigh.y, trneigh.y)));
206          return median;          return median;
207  }  }
208    
209    
210    
211    int
212    get_pmvdata2(const MACROBLOCK * const pMBs,
213                            const uint32_t x,
214                            const uint32_t y,
215                            const uint32_t x_dim,
216                            const uint32_t block,
217                            VECTOR * const pmv,
218                            int32_t * const psad,
219                            const int bound);
220    
221    
222  /* This is somehow a copy of get_pmv, but returning all MVs and Minimum SAD  /* This is somehow a copy of get_pmv, but returning all MVs and Minimum SAD
223     instead of only Median MV */     instead of only Median MV */
224    
225  static __inline int get_pmvdata(const MACROBLOCK * const pMBs,  static __inline int
226                                  const uint32_t x, const uint32_t y,  get_pmvdata(const MACROBLOCK * const pMBs,
227                            const uint32_t x,
228                            const uint32_t y,
229                                  const uint32_t x_dim,                                  const uint32_t x_dim,
230                                  const uint32_t block,                                  const uint32_t block,
231                                  VECTOR * const pmv,                                  VECTOR * const pmv,
# Line 204  Line 249 
249          int yin1, yin2, yin3;          int yin1, yin2, yin3;
250          int vec1, vec2, vec3;          int vec1, vec2, vec3;
251    
         static VECTOR zeroMV;  
252          uint32_t index = x + y * x_dim;          uint32_t index = x + y * x_dim;
253          zeroMV.x = zeroMV.y = 0;          const VECTOR zeroMV = { 0, 0 };
254    
255          // first row (special case)          // first row of blocks (special case)
256          if (y == 0 && (block == 0 || block == 1))          if (y == 0 && (block == 0 || block == 1)) {
         {  
257                  if ((x == 0) && (block == 0))           // first column, first block                  if ((x == 0) && (block == 0))           // first column, first block
258                  {                  {
259                          pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;                          pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;
260                          psad[0] = psad[1] = psad[2] = psad[3] = 0;                          psad[0] = 0;
261                            psad[1] = psad[2] = psad[3] = MV_MAX_ERROR;
262                          return 0;                          return 0;
263                  }                  }
264                  if (block == 1)         // second block; has only a left neighbour                  if (block == 1)         // second block; has only a left neighbour
# Line 222  Line 266 
266                          pmv[0] = pmv[1] = pMBs[index].mvs[0];                          pmv[0] = pmv[1] = pMBs[index].mvs[0];
267                          pmv[2] = pmv[3] = zeroMV;                          pmv[2] = pmv[3] = zeroMV;
268                          psad[0] = psad[1] = pMBs[index].sad8[0];                          psad[0] = psad[1] = pMBs[index].sad8[0];
269                          psad[2] = psad[3] = 0;                          psad[2] = psad[3] = MV_MAX_ERROR;
270                          return 0;                          return 0;
271                  }                  } else {                                /* block==0, but x!=0, so again, there is a left neighbour */
272                  else /* block==0, but x!=0, so again, there is a left neighbour*/  
                 {  
273                          pmv[0] = pmv[1] = pMBs[index-1].mvs[1];                          pmv[0] = pmv[1] = pMBs[index-1].mvs[1];
274                          pmv[2] = pmv[3] = zeroMV;                          pmv[2] = pmv[3] = zeroMV;
275                          psad[0] = psad[1] = pMBs[index-1].sad8[1];                          psad[0] = psad[1] = pMBs[index-1].sad8[1];
276                          psad[2] = psad[3] = 0;                          psad[2] = psad[3] = MV_MAX_ERROR;
277                          return 0;                          return 0;
278                  }                  }
279          }          }
# Line 248  Line 291 
291           *  [   | 3 ]    [ 2 | 3 ]    [   |   ]           *  [   | 3 ]    [ 2 | 3 ]    [   |   ]
292           */           */
293    
294          switch (block)          switch (block) {
         {  
295          case 0:          case 0:
296                  xin1 = x - 1; yin1 = y;     vec1 = 1; /* left */                  xin1 = x - 1;
297                  xin2 = x;     yin2 = y - 1; vec2 = 2; /* top */                  yin1 = y;
298                  xin3 = x + 1; yin3 = y - 1; vec3 = 2; /* top right */                  vec1 = 1;                               /* left */
299                    xin2 = x;
300                    yin2 = y - 1;
301                    vec2 = 2;                               /* top */
302                    xin3 = x + 1;
303                    yin3 = y - 1;
304                    vec3 = 2;                               /* top right */
305                  break;                  break;
306          case 1:          case 1:
307                  xin1 = x;     yin1 = y;     vec1 = 0;                  xin1 = x;
308                  xin2 = x;     yin2 = y - 1; vec2 = 3;                  yin1 = y;
309                  xin3 = x + 1; yin3 = y - 1; vec3 = 2;                  vec1 = 0;
310                    xin2 = x;
311                    yin2 = y - 1;
312                    vec2 = 3;
313                    xin3 = x + 1;
314                    yin3 = y - 1;
315                    vec3 = 2;
316                  break;                  break;
317          case 2:          case 2:
318                  xin1 = x - 1; yin1 = y; vec1 = 3;                  xin1 = x - 1;
319                  xin2 = x;     yin2 = y; vec2 = 0;                  yin1 = y;
320                  xin3 = x;     yin3 = y; vec3 = 1;                  vec1 = 3;
321                    xin2 = x;
322                    yin2 = y;
323                    vec2 = 0;
324                    xin3 = x;
325                    yin3 = y;
326                    vec3 = 1;
327                  break;                  break;
328          default:          default:
329                  xin1 = x; yin1 = y; vec1 = 2;                  xin1 = x;
330                  xin2 = x; yin2 = y; vec2 = 0;                  yin1 = y;
331                  xin3 = x; yin3 = y; vec3 = 1;                  vec1 = 2;
332                    xin2 = x;
333                    yin2 = y;
334                    vec2 = 0;
335                    xin3 = x;
336                    yin3 = y;
337                    vec3 = 1;
338          }          }
339    
340    
341          if (xin1 < 0 || /* yin1 < 0  || */ xin1 >= (int32_t)x_dim)          if (xin1 < 0 || xin1 >= (int32_t) x_dim) {
         {  
342                  pmv[1] = zeroMV;                  pmv[1] = zeroMV;
343                  psad[1] = MV_MAX_ERROR;                  psad[1] = MV_MAX_ERROR;
344          }          } else {
         else  
         {  
345                  pmv[1] = pMBs[xin1 + yin1 * x_dim].mvs[vec1];                  pmv[1] = pMBs[xin1 + yin1 * x_dim].mvs[vec1];
346                  psad[1] = pMBs[xin1 + yin1 * x_dim].sad8[vec1];                  psad[1] = pMBs[xin1 + yin1 * x_dim].sad8[vec1];
347          }          }
348    
349          if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t)x_dim)          if (xin2 < 0 || xin2 >= (int32_t) x_dim) {
         {  
350                  pmv[2] = zeroMV;                  pmv[2] = zeroMV;
351                  psad[2] = MV_MAX_ERROR;                  psad[2] = MV_MAX_ERROR;
352          }          } else {
         else  
         {  
353                  pmv[2] = pMBs[xin2 + yin2 * x_dim].mvs[vec2];                  pmv[2] = pMBs[xin2 + yin2 * x_dim].mvs[vec2];
354                  psad[2] = pMBs[xin2 + yin2 * x_dim].sad8[vec2];                  psad[2] = pMBs[xin2 + yin2 * x_dim].sad8[vec2];
355          }          }
356    
357          if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t)x_dim)          if (xin3 < 0 || xin3 >= (int32_t) x_dim) {
         {  
358                  pmv[3] = zeroMV;                  pmv[3] = zeroMV;
359                  psad[3] = MV_MAX_ERROR;                  psad[3] = MV_MAX_ERROR;
360          }          } else {
         else  
         {  
361                  pmv[3] = pMBs[xin3 + yin3 * x_dim].mvs[vec3];                  pmv[3] = pMBs[xin3 + yin3 * x_dim].mvs[vec3];
362                  psad[3] = pMBs[xin2 + yin2 * x_dim].sad8[vec3];                  psad[3] = pMBs[xin2 + yin2 * x_dim].sad8[vec3];
363          }          }
364    
365          if ( (MVequal(pmv[1],pmv[2])) && (MVequal(pmv[1],pmv[3])) )          if ((MVequal(pmv[1], pmv[2])) && (MVequal(pmv[1], pmv[3]))) {
         {  
366                  pmv[0]=pmv[1];                  pmv[0]=pmv[1];
367                  psad[0]=MIN(MIN(psad[1],psad[2]),psad[3]);                  psad[0]=MIN(MIN(psad[1],psad[2]),psad[3]);
368                  return 1;                  return 1;
# Line 314  Line 370 
370    
371          /* median,minimum */          /* median,minimum */
372    
373          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)));          pmv[0].x =
374          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)));                  MIN(MAX(pmv[1].x, pmv[2].x),
375                            MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x)));
376            pmv[0].y =
377                    MIN(MAX(pmv[1].y, pmv[2].y),
378                            MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));
379          psad[0]=MIN(MIN(psad[1],psad[2]),psad[3]);          psad[0]=MIN(MIN(psad[1],psad[2]),psad[3]);
380    
381          return 0;          return 0;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.11

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