[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.12, Wed Jul 3 12:32:50 2002 UTC revision 1.18, Tue Nov 26 23:44:11 2002 UTC
# Line 3  Line 3 
3   *  XVID MPEG-4 VIDEO CODEC   *  XVID MPEG-4 VIDEO CODEC
4   *  -  MB prediction header file  -   *  -  MB prediction header file  -
5   *   *
6   *  This program is an implementation of a part of one or more MPEG-4   *  Copyright(C) 2002 Christoph Lampert <gruel@web.de>
7   *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending   *               2002 Peter Ross <pross@xvid.org>
8   *  to use this software module in hardware or software products are   *
9   *  advised that its use may infringe existing patents or copyrights, and   *  This file is part of XviD, a free MPEG-4 video encoder/decoder
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   *  XviD is free software; you can redistribute it and/or modify it
12   *  editors and their companies, will have no liability for use of this   *  under the terms of the GNU General Public License as published by
13   *  software or modifications or derivatives thereof.   *  the Free Software Foundation; either version 2 of the License, or
  *  
  *  This program is free software; you can redistribute it and/or modify  
  *  it under the terms of the GNU General Public License as published by  
  *  the xvid_free Software Foundation; either version 2 of the License, or  
14   *  (at your option) any later version.   *  (at your option) any later version.
15   *   *
16   *  This program is distributed in the hope that it will be useful,   *  This program is distributed in the hope that it will be useful,
# Line 23  Line 19 
19   *  GNU General Public License for more details.   *  GNU General Public License for more details.
20   *   *
21   *  You should have received a copy of the GNU General Public License   *  You should have received a copy of the GNU General Public License
22   *  along with this program; if not, write to the xvid_free Software   *  along with this program; if not, write to the Free Software
23   *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
24     *
25     *  Under section 8 of the GNU General Public License, the copyright
26     *  holders of XVID explicitly forbid distribution in the following
27     *  countries:
28     *
29     *    - Japan
30     *    - United States of America
31     *
32     *  Linking XviD statically or dynamically with other modules is making a
33     *  combined work based on XviD.  Thus, the terms and conditions of the
34     *  GNU General Public License cover the whole combination.
35     *
36     *  As a special exception, the copyright holders of XviD give you
37     *  permission to link XviD with independent modules that communicate with
38     *  XviD solely through the VFW1.1 and DShow interfaces, regardless of the
39     *  license terms of these independent modules, and to copy and distribute
40     *  the resulting combined work under terms of your choice, provided that
41     *  every copy of the combined work is accompanied by a complete copy of
42     *  the source code of XviD (the version of XviD used to produce the
43     *  combined work), being distributed under the terms of the GNU General
44     *  Public License plus this exception.  An independent module is a module
45     *  which is not derived from or based on XviD.
46     *
47     *  Note that people who make modified versions of XviD are not obligated
48     *  to grant this special exception for their modified versions; it is
49     *  their choice whether to do so.  The GNU General Public License gives
50     *  permission to release a modified version without this exception; this
51     *  exception also makes it possible to release a modified version which
52     *  carries forward this exception.
53   *   *
54   *  $Id$   *  $Id$
55   *   *
56   *************************************************************************/   *************************************************************************/
57    
  /******************************************************************************  
   *                                                                            *  
   *  Revision history:                                                         *  
   *                                                                            *  
   *  29.06.2002 get_pmvdata() bounding                                         *  
   *                                                                            *  
   ******************************************************************************/  
   
   
58  #ifndef _MBPREDICTION_H_  #ifndef _MBPREDICTION_H_
59  #define _MBPREDICTION_H_  #define _MBPREDICTION_H_
60    
# Line 54  Line 70 
70    
71  #define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) )  #define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) )
72    
73    /*****************************************************************************
74     * Prototypes
75     ****************************************************************************/
76    
77  void MBPrediction(FRAMEINFO * frame,    /* <-- The parameter for ACDC and MV prediction */  void MBPrediction(FRAMEINFO * frame,    /* <-- The parameter for ACDC and MV prediction */
78    
79                                    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  */
# Line 83  Line 103 
103                                  const int bound);                                  const int bound);
104    
105    
106  /* get_pmvdata returns the median predictor and nothing else */  /*****************************************************************************
107     * Inlined functions
108  static __inline VECTOR   ****************************************************************************/
 get_pmv(const MACROBLOCK * const pMBs,  
                 const uint32_t x,  
                 const uint32_t y,  
                 const uint32_t x_dim,  
                 const uint32_t block)  
 {  
   
         int xin1, xin2, xin3;  
         int yin1, yin2, yin3;  
         int vec1, vec2, vec3;  
         VECTOR lneigh, tneigh, trneigh; /* left neighbour, top neighbour, topright neighbour */  
         VECTOR median;  
   
         static VECTOR zeroMV = { 0, 0 };  
         uint32_t index = x + y * x_dim;  
   
         /* first row (special case) */  
         if (y == 0 && (block == 0 || block == 1)) {  
                 if ((x == 0) && (block == 0))   // first column, first block  
                 {  
                         return zeroMV;  
                 }  
                 if (block == 1)                 // second block; has only a left neighbour  
                 {  
                         return pMBs[index].mvs[0];  
                 } else {                                /* block==0, but x!=0, so again, there is a left neighbour */  
   
                         return pMBs[index - 1].mvs[1];  
                 }  
         }  
109    
110          /*          /*
111           * MODE_INTER, vm18 page 48           * MODE_INTER, vm18 page 48
# Line 130  Line 120 
120           *   [   | 3 ]    [ 2 | 3 ]    [   |   ]           *   [   | 3 ]    [ 2 | 3 ]    [   |   ]
121           */           */
122    
123    static __inline VECTOR
124    get_pmv2(const MACROBLOCK * const mbs,
125             const int mb_width,
126             const int bound,
127             const int x,
128             const int y,
129             const int block)
130    {
131            static const VECTOR zeroMV = { 0, 0 };
132    
133        int lx, ly, lz;         /* left */
134        int tx, ty, tz;         /* top */
135        int rx, ry, rz;         /* top-right */
136        int lpos, tpos, rpos;
137        int num_cand, last_cand;
138    
139            VECTOR pmv[4];  /* left neighbour, top neighbour, top-right neighbour */
140    
141          switch (block) {          switch (block) {
142          case 0:          case 0:
143                  xin1 = x - 1;                  lx = x - 1;     ly = y;         lz = 1;
144                  yin1 = y;                  tx = x;         ty = y - 1;     tz = 2;
145                  vec1 = 1;                               /* left */                  rx = x + 1;     ry = y - 1;     rz = 2;
                 xin2 = x;  
                 yin2 = y - 1;  
                 vec2 = 2;                               /* top */  
                 xin3 = x + 1;  
                 yin3 = y - 1;  
                 vec3 = 2;                               /* top right */  
146                  break;                  break;
147          case 1:          case 1:
148                  xin1 = x;                  lx = x;         ly = y;         lz = 0;
149                  yin1 = y;                  tx = x;         ty = y - 1;     tz = 3;
150                  vec1 = 0;                  rx = x + 1;     ry = y - 1;     rz = 2;
                 xin2 = x;  
                 yin2 = y - 1;  
                 vec2 = 3;  
                 xin3 = x + 1;  
                 yin3 = y - 1;  
                 vec3 = 2;  
151                  break;                  break;
152          case 2:          case 2:
153                  xin1 = x - 1;                  lx = x - 1;     ly = y;         lz = 3;
154                  yin1 = y;                  tx = x;         ty = y;         tz = 0;
155                  vec1 = 3;                  rx = x;         ry = y;         rz = 1;
                 xin2 = x;  
                 yin2 = y;  
                 vec2 = 0;  
                 xin3 = x;  
                 yin3 = y;  
                 vec3 = 1;  
156                  break;                  break;
157          default:          default:
158                  xin1 = x;                  lx = x;         ly = y;         lz = 2;
159                  yin1 = y;                  tx = x;         ty = y;         tz = 0;
160                  vec1 = 2;                  rx = x;         ry = y;         rz = 1;
                 xin2 = x;  
                 yin2 = y;  
                 vec2 = 0;  
                 xin3 = x;  
                 yin3 = y;  
                 vec3 = 1;  
161          }          }
162    
163        lpos = lx + ly * mb_width;
164        rpos = rx + ry * mb_width;
165        tpos = tx + ty * mb_width;
166        last_cand = num_cand = 0;
167    
168          if (xin1 < 0 || /* yin1 < 0  || */ xin1 >= (int32_t) x_dim) {      if (lpos >= bound && lx >= 0) {
169                  lneigh = zeroMV;          num_cand++;
170            last_cand = 1;
171            pmv[1] = mbs[lpos].mvs[lz];
172          } else {          } else {
173                  lneigh = pMBs[xin1 + yin1 * x_dim].mvs[vec1];          pmv[1] = zeroMV;
174          }          }
175    
176          if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t) x_dim) {      if (tpos >= bound) {
177                  tneigh = zeroMV;          num_cand++;
178            last_cand = 2;
179            pmv[2] = mbs[tpos].mvs[tz];
180          } else {          } else {
181                  tneigh = pMBs[xin2 + yin2 * x_dim].mvs[vec2];          pmv[2] = zeroMV;
182          }          }
183    
184          if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t) x_dim) {      if (rpos >= bound && rx < mb_width) {
185                  trneigh = zeroMV;          num_cand++;
186            last_cand = 3;
187            pmv[3] = mbs[rpos].mvs[rz];
188          } else {          } else {
189                  trneigh = pMBs[xin3 + yin3 * x_dim].mvs[vec3];          pmv[3] = zeroMV;
190          }          }
191    
192          /* median,minimum */      /*
193             * If there're more than one candidate, we return the median vector
194             * edgomez : the special case "no candidates" is handled the same way
195             *           because all vectors are set to zero. So the median vector
196             *           is {0,0}, and this is exactly the vector we must return
197             *           according to the mpeg4 specs.
198             */
199    
200          median.x =          if (num_cand != 1) {
201                  MIN(MAX(lneigh.x, tneigh.x),                  /* set median */
202                          MIN(MAX(tneigh.x, trneigh.x), MAX(lneigh.x, trneigh.x)));  
203          median.y =                  pmv[0].x =
204                  MIN(MAX(lneigh.y, tneigh.y),                          MIN(MAX(pmv[1].x, pmv[2].x),
205                          MIN(MAX(tneigh.y, trneigh.y), MAX(lneigh.y, trneigh.y)));                                  MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x)));
206          return median;                  pmv[0].y =
207                            MIN(MAX(pmv[1].y, pmv[2].y),
208                                    MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));
209                    return pmv[0];
210  }  }
211    
212             return pmv[last_cand];  /* no point calculating median mv */
213    }
214    
 /* This is somehow a copy of get_pmv, but returning all MVs and Minimum SAD  
    instead of only Median MV */  
215    
 static __inline int  
 get_pmvdata(const MACROBLOCK * const pMBs,  
                         const uint32_t x,  
                         const uint32_t y,  
                         const uint32_t x_dim,  
                         const uint32_t block,  
                         VECTOR * const pmv,  
                         int32_t * const psad)  
 {  
216    
217          /*          /*
218           * pmv are filled with:           * pmv are filled with:
# Line 233  Line 227 
227           *  [3]: topright neighbour's SAD           *  [3]: topright neighbour's SAD
228           */           */
229    
230          int xin1, xin2, xin3;  static __inline int
231          int yin1, yin2, yin3;  get_pmvdata2(const MACROBLOCK * const mbs,
232          int vec1, vec2, vec3;           const int mb_width,
233             const int bound,
234          uint32_t index = x + y * x_dim;           const int x,
235          const VECTOR zeroMV = { 0, 0 };           const int y,
236             const int block,
237          // first row of blocks (special case)                   VECTOR * const pmv,
238          if (y == 0 && (block == 0 || block == 1)) {                   int32_t * const psad)
                 if ((x == 0) && (block == 0))   // first column, first block  
                 {  
                         pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;  
                         psad[0] = 0;  
                         psad[1] = psad[2] = psad[3] = MV_MAX_ERROR;  
                         return 0;  
                 }  
                 if (block == 1)                 // second block; has only a left neighbour  
239                  {                  {
240                          pmv[0] = pmv[1] = pMBs[index].mvs[0];          static const VECTOR zeroMV = { 0, 0 };
                         pmv[2] = pmv[3] = zeroMV;  
                         psad[0] = psad[1] = pMBs[index].sad8[0];  
                         psad[2] = psad[3] = MV_MAX_ERROR;  
                         return 0;  
                 } else {                                /* block==0, but x!=0, so again, there is a left neighbour */  
   
                         pmv[0] = pmv[1] = pMBs[index - 1].mvs[1];  
                         pmv[2] = pmv[3] = zeroMV;  
                         psad[0] = psad[1] = pMBs[index - 1].sad8[1];  
                         psad[2] = psad[3] = MV_MAX_ERROR;  
                         return 0;  
                 }  
         }  
241    
242          /*      int lx, ly, lz;         /* left */
243           * MODE_INTER, vm18 page 48      int tx, ty, tz;         /* top */
244           * MODE_INTER4V vm18 page 51      int rx, ry, rz;         /* top-right */
245           *      int lpos, tpos, rpos;
246           *  (x,y-1)      (x+1,y-1)      int num_cand, last_cand;
          *  [   |   ]    [   |   ]  
          *  [ 2 | 3 ]    [ 2 |   ]  
          *  
          *  (x-1,y)      (x,y)        (x+1,y)  
          *  [   | 1 ]    [ 0 | 1 ]    [ 0 |   ]  
          *  [   | 3 ]    [ 2 | 3 ]    [   |   ]  
          */  
247    
248          switch (block) {          switch (block) {
249          case 0:          case 0:
250                  xin1 = x - 1;                  lx = x - 1;     ly = y;         lz = 1;
251                  yin1 = y;                  tx = x;         ty = y - 1;     tz = 2;
252                  vec1 = 1;                               /* left */                  rx = x + 1;     ry = y - 1;     rz = 2;
                 xin2 = x;  
                 yin2 = y - 1;  
                 vec2 = 2;                               /* top */  
                 xin3 = x + 1;  
                 yin3 = y - 1;  
                 vec3 = 2;                               /* top right */  
253                  break;                  break;
254          case 1:          case 1:
255                  xin1 = x;                  lx = x;         ly = y;         lz = 0;
256                  yin1 = y;                  tx = x;         ty = y - 1;     tz = 3;
257                  vec1 = 0;                  rx = x + 1;     ry = y - 1;     rz = 2;
                 xin2 = x;  
                 yin2 = y - 1;  
                 vec2 = 3;  
                 xin3 = x + 1;  
                 yin3 = y - 1;  
                 vec3 = 2;  
258                  break;                  break;
259          case 2:          case 2:
260                  xin1 = x - 1;                  lx = x - 1;     ly = y;         lz = 3;
261                  yin1 = y;                  tx = x;         ty = y;         tz = 0;
262                  vec1 = 3;                  rx = x;         ry = y;         rz = 1;
                 xin2 = x;  
                 yin2 = y;  
                 vec2 = 0;  
                 xin3 = x;  
                 yin3 = y;  
                 vec3 = 1;  
263                  break;                  break;
264          default:          default:
265                  xin1 = x;                  lx = x;         ly = y;         lz = 2;
266                  yin1 = y;                  tx = x;         ty = y;         tz = 0;
267                  vec1 = 2;                  rx = x;         ry = y;         rz = 1;
                 xin2 = x;  
                 yin2 = y;  
                 vec2 = 0;  
                 xin3 = x;  
                 yin3 = y;  
                 vec3 = 1;  
268          }          }
269    
270        lpos = lx + ly * mb_width;
271        rpos = rx + ry * mb_width;
272        tpos = tx + ty * mb_width;
273        last_cand = num_cand = 0;
274    
275          if (xin1 < 0 || xin1 >= (int32_t) x_dim) {      if (lpos >= bound && lx >= 0) {
276            num_cand++;
277            last_cand = 1;
278            pmv[1] = mbs[lpos].mvs[lz];
279                    psad[1] = mbs[lpos].sad8[lz];
280        } else {
281                  pmv[1] = zeroMV;                  pmv[1] = zeroMV;
282                  psad[1] = MV_MAX_ERROR;                  psad[1] = MV_MAX_ERROR;
         } else {  
                 pmv[1] = pMBs[xin1 + yin1 * x_dim].mvs[vec1];  
                 psad[1] = pMBs[xin1 + yin1 * x_dim].sad8[vec1];  
283          }          }
284    
285          if (xin2 < 0 || xin2 >= (int32_t) x_dim) {      if (tpos >= bound) {
286            num_cand++;
287            last_cand = 2;
288            pmv[2]= mbs[tpos].mvs[tz];
289            psad[2] = mbs[tpos].sad8[tz];
290        } else {
291                  pmv[2] = zeroMV;                  pmv[2] = zeroMV;
292                  psad[2] = MV_MAX_ERROR;                  psad[2] = MV_MAX_ERROR;
         } else {  
                 pmv[2] = pMBs[xin2 + yin2 * x_dim].mvs[vec2];  
                 psad[2] = pMBs[xin2 + yin2 * x_dim].sad8[vec2];  
293          }          }
294    
295          if (xin3 < 0 || xin3 >= (int32_t) x_dim) {      if (rpos >= bound && rx < mb_width) {
296            num_cand++;
297            last_cand = 3;
298            pmv[3] = mbs[rpos].mvs[rz];
299            psad[3] = mbs[rpos].sad8[rz];
300        } else {
301                  pmv[3] = zeroMV;                  pmv[3] = zeroMV;
302                  psad[3] = MV_MAX_ERROR;                  psad[3] = MV_MAX_ERROR;
303          } else {      }
304                  pmv[3] = pMBs[xin3 + yin3 * x_dim].mvs[vec3];  
305                  psad[3] = pMBs[xin3 + yin3 * x_dim].sad8[vec3];          /* original pmvdata() compatibility hack */
306            if (x == 0 && y == 0 && block == 0)
307            {
308                    pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV;
309                    psad[0] = 0;
310                    psad[1] = psad[2] = psad[3] = MV_MAX_ERROR;
311                    return 0;
312            }
313    
314        /* if only one valid candidate preictor, the invalid candiates are set to the canidate */
315            if (num_cand == 1) {
316                    pmv[0] = pmv[last_cand];
317                    psad[0] = psad[last_cand];
318            /* return MVequal(pmv[0], zeroMV);  no point calculating median mv and minimum sad  */
319    
320                    /* original pmvdata() compatibility hack */
321                    return y==0 && block <= 1 ? 0 : MVequal(pmv[0], zeroMV);
322          }          }
323    
324          if ((MVequal(pmv[1], pmv[2])) && (MVequal(pmv[1], pmv[3]))) {          if ((MVequal(pmv[1], pmv[2])) && (MVequal(pmv[1], pmv[3]))) {
325                  pmv[0] = pmv[1];                  pmv[0] = pmv[1];
326                  psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);                  psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);
327                  return 1;                  return 1;
328                    /* compatibility patch */
329                    /*return y==0 && block <= 1 ? 0 : 1; */
330          }          }
331    
332          /* median,minimum */          /* set median, minimum */
333    
334          pmv[0].x =          pmv[0].x =
335                  MIN(MAX(pmv[1].x, pmv[2].x),                  MIN(MAX(pmv[1].x, pmv[2].x),
# Line 364  Line 337 
337          pmv[0].y =          pmv[0].y =
338                  MIN(MAX(pmv[1].y, pmv[2].y),                  MIN(MAX(pmv[1].y, pmv[2].y),
339                          MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));                          MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y)));
340    
341          psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);          psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);
342    
343          return 0;          return 0;
344  }  }
345    
346    /* copies of get_pmv and get_pmvdata for prediction from integer search */
         /*  
          * MODE_INTER, vm18 page 48  
          * MODE_INTER4V vm18 page 51  
          *  
          *   (x,y-1)      (x+1,y-1)  
          *   [   |   ]    [   |   ]  
          *   [ 2 | 3 ]    [ 2 |   ]  
          *  
          *   (x-1,y)       (x,y)        (x+1,y)  
          *   [   | 1 ]    [ 0 | 1 ]    [ 0 |   ]  
          *   [   | 3 ]    [ 2 | 3 ]    [   |   ]  
          */  
347    
348  static __inline VECTOR  static __inline VECTOR
349  get_pmv2(const MACROBLOCK * const mbs,  get_ipmv(const MACROBLOCK * const mbs,
350           const int mb_width,           const int mb_width,
351           const int bound,           const int bound,
352           const int x,           const int x,
# Line 426  Line 388 
388      lpos = lx + ly * mb_width;      lpos = lx + ly * mb_width;
389      rpos = rx + ry * mb_width;      rpos = rx + ry * mb_width;
390      tpos = tx + ty * mb_width;      tpos = tx + ty * mb_width;
391      num_cand = 0;      last_cand = num_cand = 0;
392    
393      if (lpos >= bound && lx >= 0) {      if (lpos >= bound && lx >= 0) {
394          num_cand++;          num_cand++;
395          last_cand = 1;          last_cand = 1;
396          pmv[1] = mbs[lpos].mvs[lz];          pmv[1] = mbs[lpos].i_mvs[lz];
397      } else {      } else {
398          pmv[1] = zeroMV;          pmv[1] = zeroMV;
399      }      }
# Line 439  Line 401 
401      if (tpos >= bound) {      if (tpos >= bound) {
402          num_cand++;          num_cand++;
403          last_cand = 2;          last_cand = 2;
404          pmv[2] = mbs[tpos].mvs[tz];          pmv[2] = mbs[tpos].i_mvs[tz];
405      } else {      } else {
406          pmv[2] = zeroMV;          pmv[2] = zeroMV;
407      }      }
# Line 447  Line 409 
409      if (rpos >= bound && rx < mb_width) {      if (rpos >= bound && rx < mb_width) {
410          num_cand++;          num_cand++;
411          last_cand = 3;          last_cand = 3;
412          pmv[3] = mbs[rpos].mvs[rz];          pmv[3] = mbs[rpos].i_mvs[rz];
413      } else {      } else {
414          pmv[3] = zeroMV;          pmv[3] = zeroMV;
415      }      }
416    
417      /* if only one valid candidate preictor, the invalid candiates are set to the canidate */      /* if only one valid candidate predictor, the invalid candiates are set to the canidate */
418          if (num_cand != 1) {          if (num_cand != 1) {
419                  /* set median */                  /* set median */
420    
# Line 468  Line 430 
430           return pmv[last_cand];  /* no point calculating median mv */           return pmv[last_cand];  /* no point calculating median mv */
431  }  }
432    
   
   
         /*  
          * pmv are filled with:  
          *  [0]: Median (or whatever is correct in a special case)  
          *  [1]: left neighbour  
          *  [2]: top neighbour  
          *  [3]: topright neighbour  
          * psad are filled with:  
          *  [0]: minimum of [1] to [3]  
          *  [1]: left neighbour's SAD (NB:[1] to [3] are actually not needed)  
          *  [2]: top neighbour's SAD  
          *  [3]: topright neighbour's SAD  
          */  
433  static __inline int  static __inline int
434  get_pmvdata2(const MACROBLOCK * const mbs,  get_ipmvdata(const MACROBLOCK * const mbs,
435           const int mb_width,           const int mb_width,
436           const int bound,           const int bound,
437           const int x,           const int x,
# Line 525  Line 473 
473      lpos = lx + ly * mb_width;      lpos = lx + ly * mb_width;
474      rpos = rx + ry * mb_width;      rpos = rx + ry * mb_width;
475      tpos = tx + ty * mb_width;      tpos = tx + ty * mb_width;
476      num_cand = 0;      last_cand = num_cand = 0;
477    
478      if (lpos >= bound && lx >= 0) {      if (lpos >= bound && lx >= 0) {
479          num_cand++;          num_cand++;
480          last_cand = 1;          last_cand = 1;
481          pmv[1] = mbs[lpos].mvs[lz];          pmv[1] = mbs[lpos].i_mvs[lz];
482                  psad[1] = mbs[lpos].sad8[lz];                  psad[1] = mbs[lpos].i_sad8[lz];
483      } else {      } else {
484          pmv[1] = zeroMV;          pmv[1] = zeroMV;
485                  psad[1] = MV_MAX_ERROR;                  psad[1] = MV_MAX_ERROR;
# Line 540  Line 488 
488      if (tpos >= bound) {      if (tpos >= bound) {
489          num_cand++;          num_cand++;
490          last_cand = 2;          last_cand = 2;
491          pmv[2]= mbs[tpos].mvs[tz];          pmv[2]= mbs[tpos].i_mvs[tz];
492          psad[2] = mbs[tpos].sad8[tz];          psad[2] = mbs[tpos].i_sad8[tz];
493      } else {      } else {
494          pmv[2] = zeroMV;          pmv[2] = zeroMV;
495                  psad[2] = MV_MAX_ERROR;                  psad[2] = MV_MAX_ERROR;
# Line 550  Line 498 
498      if (rpos >= bound && rx < mb_width) {      if (rpos >= bound && rx < mb_width) {
499          num_cand++;          num_cand++;
500          last_cand = 3;          last_cand = 3;
501          pmv[3] = mbs[rpos].mvs[rz];          pmv[3] = mbs[rpos].i_mvs[rz];
502          psad[3] = mbs[rpos].sad8[rz];          psad[3] = mbs[rpos].i_sad8[rz];
503      } else {      } else {
504          pmv[3] = zeroMV;          pmv[3] = zeroMV;
505                  psad[3] = MV_MAX_ERROR;                  psad[3] = MV_MAX_ERROR;
# Line 570  Line 518 
518          if (num_cand == 1) {          if (num_cand == 1) {
519                  pmv[0] = pmv[last_cand];                  pmv[0] = pmv[last_cand];
520                  psad[0] = psad[last_cand];                  psad[0] = psad[last_cand];
521          // return MVequal(pmv[0], zeroMV); /* no point calculating median mv and minimum sad */          /* return MVequal(pmv[0], zeroMV); no point calculating median mv and minimum sad */
522    
523                  /* original pmvdata() compatibility hack */                  /* original pmvdata() compatibility hack */
524                  return y==0 && block <= 1 ? 0 : MVequal(pmv[0], zeroMV);                  return y==0 && block <= 1 ? 0 : MVequal(pmv[0], zeroMV);
# Line 581  Line 529 
529                  psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);                  psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]);
530                  return 1;                  return 1;
531                  /* compatibility patch */                  /* compatibility patch */
532                  //return y==0 && block <= 1 ? 0 : 1;                  /*return y==0 && block <= 1 ? 0 : 1; */
533          }          }
534    
535          /* set median, minimum */          /* set median, minimum */

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.18

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