[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.6, Fri May 3 00:45:10 2002 UTC revision 1.10, Fri Jun 28 15:14:40 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 unsigned int bound_x,
84                                    const unsigned int bound_y);
85    
86    
87  /* get_pmvdata returns the median predictor and nothing else */  /* get_pmvdata returns the median predictor and nothing else */
88    
89  static __inline VECTOR get_pmv(const MACROBLOCK * const pMBs,  static __inline VECTOR
90    get_pmv(const MACROBLOCK * const pMBs,
91                                 const uint32_t x,                                 const uint32_t x,
92                                 const uint32_t y,                                 const uint32_t y,
93                                 const uint32_t x_dim,                                 const uint32_t x_dim,
# Line 88  Line 104 
104          uint32_t index = x + y * x_dim;          uint32_t index = x + y * x_dim;
105    
106          /* first row (special case) */          /* first row (special case) */
107          if (y == 0 && (block == 0 || block == 1))          if (y == 0 && (block == 0 || block == 1)) {
         {  
108                  if ((x == 0) && (block == 0))           // first column, first block                  if ((x == 0) && (block == 0))           // first column, first block
109                  {                  {
110                          return zeroMV;                          return zeroMV;
# Line 97  Line 112 
112                  if (block == 1)         // second block; has only a left neighbour                  if (block == 1)         // second block; has only a left neighbour
113                  {                  {
114                          return pMBs[index].mvs[0];                          return pMBs[index].mvs[0];
115                  }                  } else {                                /* block==0, but x!=0, so again, there is a left neighbour */
116                  else /* block==0, but x!=0, so again, there is a left neighbour*/  
                 {  
117                          return pMBs[index-1].mvs[1];                          return pMBs[index-1].mvs[1];
118                  }                  }
119          }          }
# Line 117  Line 131 
131           *   [   | 3 ]    [ 2 | 3 ]    [   |   ]           *   [   | 3 ]    [ 2 | 3 ]    [   |   ]
132           */           */
133    
134          switch (block)          switch (block) {
         {  
135          case 0:          case 0:
136                  xin1 = x - 1;   yin1 = y;       vec1 = 1;       /* left */                  xin1 = x - 1;
137                  xin2 = x;       yin2 = y - 1;   vec2 = 2;       /* top */                  yin1 = y;
138                  xin3 = x + 1;   yin3 = y - 1;   vec3 = 2;       /* top right */                  vec1 = 1;                               /* left */
139                    xin2 = x;
140                    yin2 = y - 1;
141                    vec2 = 2;                               /* top */
142                    xin3 = x + 1;
143                    yin3 = y - 1;
144                    vec3 = 2;                               /* top right */
145                  break;                  break;
146          case 1:          case 1:
147                  xin1 = x;               yin1 = y;               vec1 = 0;                  xin1 = x;
148                  xin2 = x;               yin2 = y - 1;   vec2 = 3;                  yin1 = y;
149                  xin3 = x + 1;   yin3 = y - 1;   vec3 = 2;                  vec1 = 0;
150                    xin2 = x;
151                    yin2 = y - 1;
152                    vec2 = 3;
153                    xin3 = x + 1;
154                    yin3 = y - 1;
155                    vec3 = 2;
156                  break;                  break;
157          case 2:          case 2:
158                  xin1 = x - 1;   yin1 = y;               vec1 = 3;                  xin1 = x - 1;
159                  xin2 = x;               yin2 = y;               vec2 = 0;                  yin1 = y;
160                  xin3 = x;               yin3 = y;               vec3 = 1;                  vec1 = 3;
161                    xin2 = x;
162                    yin2 = y;
163                    vec2 = 0;
164                    xin3 = x;
165                    yin3 = y;
166                    vec3 = 1;
167                  break;                  break;
168          default:          default:
169                  xin1 = x;               yin1 = y;               vec1 = 2;                  xin1 = x;
170                  xin2 = x;               yin2 = y;               vec2 = 0;                  yin1 = y;
171                  xin3 = x;               yin3 = y;               vec3 = 1;                  vec1 = 2;
172                    xin2 = x;
173                    yin2 = y;
174                    vec2 = 0;
175                    xin3 = x;
176                    yin3 = y;
177                    vec3 = 1;
178          }          }
179    
180    
181          if (xin1 < 0 || /* yin1 < 0  || */ xin1 >= (int32_t)x_dim)          if (xin1 < 0 || /* yin1 < 0  || */ xin1 >= (int32_t) x_dim) {
         {  
182                  lneigh = zeroMV;                  lneigh = zeroMV;
183          }          } else {
         else  
         {  
184                  lneigh = pMBs[xin1 + yin1 * x_dim].mvs[vec1];                  lneigh = pMBs[xin1 + yin1 * x_dim].mvs[vec1];
185          }          }
186    
187          if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t)x_dim)          if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t) x_dim) {
         {  
188                  tneigh = zeroMV;                  tneigh = zeroMV;
189          }          } else {
         else  
         {  
190                  tneigh = pMBs[xin2 + yin2 * x_dim].mvs[vec2];                  tneigh = pMBs[xin2 + yin2 * x_dim].mvs[vec2];
191          }          }
192    
193          if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t)x_dim)          if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t) x_dim) {
         {  
194                  trneigh = zeroMV;                  trneigh = zeroMV;
195          }          } else {
         else  
         {  
196                  trneigh = pMBs[xin3 + yin3 * x_dim].mvs[vec3];                  trneigh = pMBs[xin3 + yin3 * x_dim].mvs[vec3];
197          }          }
198    
199          /* median,minimum */          /* median,minimum */
200    
201          median.x = MIN(MAX(lneigh.x, tneigh.x), MIN(MAX(tneigh.x, trneigh.x), MAX(lneigh.x, trneigh.x)));          median.x =
202          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),
203                            MIN(MAX(tneigh.x, trneigh.x), MAX(lneigh.x, trneigh.x)));
204            median.y =
205                    MIN(MAX(lneigh.y, tneigh.y),
206                            MIN(MAX(tneigh.y, trneigh.y), MAX(lneigh.y, trneigh.y)));
207          return median;          return median;
208  }  }
209    
# Line 179  Line 211 
211  /* 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
212     instead of only Median MV */     instead of only Median MV */
213    
214  static __inline int get_pmvdata(const MACROBLOCK * const pMBs,  static __inline int
215                                  const uint32_t x, const uint32_t y,  get_pmvdata(const MACROBLOCK * const pMBs,
216                            const uint32_t x,
217                            const uint32_t y,
218                                  const uint32_t x_dim,                                  const uint32_t x_dim,
219                                  const uint32_t block,                                  const uint32_t block,
220                                  VECTOR * const pmv,                                  VECTOR * const pmv,
221                                  int32_t * const psad)                          int32_t * const psad,
222                            const unsigned int bound_x,
223                            const unsigned int bound_y)
224  {  {
225    
226          /*          /*
# Line 204  Line 240 
240          int yin1, yin2, yin3;          int yin1, yin2, yin3;
241          int vec1, vec2, vec3;          int vec1, vec2, vec3;
242    
         static VECTOR zeroMV;  
243          uint32_t index = x + y * x_dim;          uint32_t index = x + y * x_dim;
244          zeroMV.x = zeroMV.y = 0;          const VECTOR zeroMV = { 0, 0 };
245    
246          // first row (special case)          // first row of blocks (special case)
247          if (y == 0 && (block == 0 || block == 1))          /* if (y == 0 && (block == 0 || block == 1)) { */
248          {          if (((y == bound_y && x >= bound_x) || (y == bound_y + 1 && x < bound_x))
249                  if ((x == 0) && (block == 0))           // first column, first block                  && (block == 0 || block == 1)) {
250    
251                    /* if ((x == 0) && (block == 0)) */     // first column, first block
252                    if ((x == 0 || (y == bound_y && x == bound_x)) && (block == 0)) // first column, first block
253                  {                  {
254                          pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;                          pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;
255                          psad[0] = psad[1] = psad[2] = psad[3] = MV_MAX_ERROR;                          psad[0] = 0;
256                            psad[1] = psad[2] = psad[3] = MV_MAX_ERROR;
257                          return 0;                          return 0;
258                  }                  }
259                  if (block == 1)         // second block; has only a left neighbour                  if (block == 1)         // second block; has only a left neighbour
# Line 224  Line 263 
263                          psad[0] = psad[1] = pMBs[index].sad8[0];                          psad[0] = psad[1] = pMBs[index].sad8[0];
264                          psad[2] = psad[3] = MV_MAX_ERROR;                          psad[2] = psad[3] = MV_MAX_ERROR;
265                          return 0;                          return 0;
266                  }                  } else {                                /* block==0, but x!=0, so again, there is a left neighbour */
267                  else /* block==0, but x!=0, so again, there is a left neighbour*/  
                 {  
268                          pmv[0] = pmv[1] = pMBs[index-1].mvs[1];                          pmv[0] = pmv[1] = pMBs[index-1].mvs[1];
269                          pmv[2] = pmv[3] = zeroMV;                          pmv[2] = pmv[3] = zeroMV;
270                          psad[0] = psad[1] = pMBs[index-1].sad8[1];                          psad[0] = psad[1] = pMBs[index-1].sad8[1];
# Line 248  Line 286 
286           *  [   | 3 ]    [ 2 | 3 ]    [   |   ]           *  [   | 3 ]    [ 2 | 3 ]    [   |   ]
287           */           */
288    
289          switch (block)          switch (block) {
         {  
290          case 0:          case 0:
291                  xin1 = x - 1; yin1 = y;     vec1 = 1; /* left */                  xin1 = x - 1;
292                  xin2 = x;     yin2 = y - 1; vec2 = 2; /* top */                  yin1 = y;
293                  xin3 = x + 1; yin3 = y - 1; vec3 = 2; /* top right */                  vec1 = 1;                               /* left */
294                    xin2 = x;
295                    yin2 = y - 1;
296                    vec2 = 2;                               /* top */
297                    xin3 = x + 1;
298                    yin3 = y - 1;
299                    vec3 = 2;                               /* top right */
300                  break;                  break;
301          case 1:          case 1:
302                  xin1 = x;     yin1 = y;     vec1 = 0;                  xin1 = x;
303                  xin2 = x;     yin2 = y - 1; vec2 = 3;                  yin1 = y;
304                  xin3 = x + 1; yin3 = y - 1; vec3 = 2;                  vec1 = 0;
305                    xin2 = x;
306                    yin2 = y - 1;
307                    vec2 = 3;
308                    xin3 = x + 1;
309                    yin3 = y - 1;
310                    vec3 = 2;
311                  break;                  break;
312          case 2:          case 2:
313                  xin1 = x - 1; yin1 = y; vec1 = 3;                  xin1 = x - 1;
314                  xin2 = x;     yin2 = y; vec2 = 0;                  yin1 = y;
315                  xin3 = x;     yin3 = y; vec3 = 1;                  vec1 = 3;
316                    xin2 = x;
317                    yin2 = y;
318                    vec2 = 0;
319                    xin3 = x;
320                    yin3 = y;
321                    vec3 = 1;
322                  break;                  break;
323          default:          default:
324                  xin1 = x; yin1 = y; vec1 = 2;                  xin1 = x;
325                  xin2 = x; yin2 = y; vec2 = 0;                  yin1 = y;
326                  xin3 = x; yin3 = y; vec3 = 1;                  vec1 = 2;
327                    xin2 = x;
328                    yin2 = y;
329                    vec2 = 0;
330                    xin3 = x;
331                    yin3 = y;
332                    vec3 = 1;
333          }          }
334    
335    
336          if (xin1 < 0 || /* yin1 < 0  || */ xin1 >= (int32_t)x_dim)          if (xin1 < 0 || xin1 >= (int32_t) x_dim) {
         {  
337              pmv[1] = zeroMV;              pmv[1] = zeroMV;
338                  psad[1] = MV_MAX_ERROR;                  psad[1] = MV_MAX_ERROR;
339          }          } else {
         else  
         {  
340                  pmv[1] = pMBs[xin1 + yin1 * x_dim].mvs[vec1];                  pmv[1] = pMBs[xin1 + yin1 * x_dim].mvs[vec1];
341                  psad[1] = pMBs[xin1 + yin1 * x_dim].sad8[vec1];                  psad[1] = pMBs[xin1 + yin1 * x_dim].sad8[vec1];
342          }          }
343    
344          if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t)x_dim)          if (xin2 < 0 || xin2 >= (int32_t) x_dim) {
         {  
345                  pmv[2] = zeroMV;                  pmv[2] = zeroMV;
346                  psad[2] = MV_MAX_ERROR;                  psad[2] = MV_MAX_ERROR;
347          }          } else {
         else  
         {  
348                  pmv[2] = pMBs[xin2 + yin2 * x_dim].mvs[vec2];                  pmv[2] = pMBs[xin2 + yin2 * x_dim].mvs[vec2];
349                  psad[2] = pMBs[xin2 + yin2 * x_dim].sad8[vec2];                  psad[2] = pMBs[xin2 + yin2 * x_dim].sad8[vec2];
350          }          }
351    
352          if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t)x_dim)          if (xin3 < 0 || xin3 >= (int32_t) x_dim) {
         {  
353                  pmv[3] = zeroMV;                  pmv[3] = zeroMV;
354                  psad[3] = MV_MAX_ERROR;                  psad[3] = MV_MAX_ERROR;
355          }          } else {
         else  
         {  
356                  pmv[3] = pMBs[xin3 + yin3 * x_dim].mvs[vec3];                  pmv[3] = pMBs[xin3 + yin3 * x_dim].mvs[vec3];
357                  psad[3] = pMBs[xin2 + yin2 * x_dim].sad8[vec3];                  psad[3] = pMBs[xin2 + yin2 * x_dim].sad8[vec3];
358          }          }
359    
360          if ( (MVequal(pmv[1],pmv[2])) && (MVequal(pmv[1],pmv[3])) )          if ((MVequal(pmv[1], pmv[2])) && (MVequal(pmv[1], pmv[3]))) {
361          {       pmv[0]=pmv[1];                  pmv[0] = pmv[1];
362          psad[0]=psad[1];                  psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);
363          return 1;          return 1;
364          }          }
365    
366          /* median,minimum */          /* median,minimum */
367    
368          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 =
369          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),
370                            MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x)));
371            pmv[0].y =
372                    MIN(MAX(pmv[1].y, pmv[2].y),
373                            MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));
374          psad[0]=MIN(MIN(psad[1],psad[2]),psad[3]);          psad[0]=MIN(MIN(psad[1],psad[2]),psad[3]);
375    
376          return 0;          return 0;

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.10

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