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

Diff of /xvidcore/src/motion/motion.h

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

revision 1.19, Sat Feb 15 15:22:18 2003 UTC revision 1.26, Sat Dec 18 16:02:00 2010 UTC
# Line 1  Line 1 
1  /**************************************************************************  /*****************************************************************************
2   *   *
3   *  XVID MPEG-4 VIDEO CODEC   *  XVID MPEG-4 VIDEO CODEC
4   *  -  Motion sad header  -   *  - Motion module header -
5     *
6     *  Copyright(C) 2002-2003 Radoslaw Czyz <xvid@syskin.cjb.net>
7     *               2002 Michael Militzer <michael@xvid.org>
8   *   *
  *  This program is an implementation of a part of one or more MPEG-4  
  *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  
  *  to use this software module in hardware or software products are  
  *  advised that its use may infringe existing patents or copyrights, and  
  *  any such use would be at such party's own risk.  The original  
  *  developer of this software module and his/her company, and subsequent  
  *  editors and their companies, will have no liability for use of this  
  *  software or modifications or derivatives thereof.  
9   *   *
10   *  This program is free software; you can redistribute it and/or modify   *  This program is free software; you can redistribute it and/or modify
11   *  it under the terms of the GNU General Public License as published by   *  it under the terms of the GNU General Public License as published by
# Line 36  Line 31 
31  #include "../portab.h"  #include "../portab.h"
32  #include "../global.h"  #include "../global.h"
33    
34  // fast ((A)/2)*2  /*****************************************************************************
35  #define EVEN(A)         (((A)<0?(A)+1:(A)) & ~1)   * Modified rounding tables -- defined in estimation_common.c
36     * Original tables see ISO spec tables 7-6 -> 7-9
37  #define MVzero(A) ( ((A).x)==(0) && ((A).y)==(0) )   ****************************************************************************/
 #define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) )  
   
 static const uint32_t roundtab[16] =  
                 { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };  
   
 /*  
  * modified rounding tables  
  * original tables see ISO spec tables 7-6 -> 7-9  
  */  
38    
39    extern const uint32_t roundtab[16];
40  /* K = 4 */  /* K = 4 */
41  static const uint32_t roundtab_76[16] = { 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1 };  extern const uint32_t roundtab_76[16];
42  /* K = 2 */  /* K = 2 */
43  static const uint32_t roundtab_78[8] = { 0, 0, 1, 1, 0, 0, 0, 1  };  extern const uint32_t roundtab_78[8];
44  /* K = 1 */  /* K = 1 */
45  static const uint32_t roundtab_79[4] = { 0, 1, 0, 0 };  extern const uint32_t roundtab_79[4];
46    
47    
48  /*  /** MotionEstimation **/
  * getref: calculate reference image pointer  
  * the decision to use interpolation h/v/hv or the normal image is  
  * based on dx & dy.  
  */  
   
 static __inline const uint8_t *  
 get_ref(const uint8_t * const refn,  
                 const uint8_t * const refh,  
                 const uint8_t * const refv,  
                 const uint8_t * const refhv,  
                 const uint32_t x,  
                 const uint32_t y,  
                 const uint32_t block,   /* block dimension, 8 or 16 */  
   
                 const int32_t dx,  
                 const int32_t dy,  
                 const int32_t stride)  
 {  
   
   
         switch (((dx & 1) << 1) + (dy & 1)) {   /* ((dx%2)?2:0)+((dy%2)?1:0) */  
         case 0:  
                 return refn + (int) ((x * block + dx / 2) + (y * block + dy / 2) * stride);  
         case 1:  
                 return refv + (int) ((x * block + dx / 2) + (y * block +  
                                                                                           (dy - 1) / 2) * stride);  
         case 2:  
                 return refh + (int) ((x * block + (dx - 1) / 2) + (y * block +  
                                                                                                         dy / 2) * stride);  
         default:  
                 return refhv + (int) ((x * block + (dx - 1) / 2) + (y * block +  
                                                                                                          (dy - 1) / 2) * stride);  
         }  
   
 }  
   
   
 /* This is somehow a copy of get_ref, but with MV instead of X,Y */  
   
 static __inline const uint8_t *  
 get_ref_mv(const uint8_t * const refn,  
                    const uint8_t * const refh,  
                    const uint8_t * const refv,  
                    const uint8_t * const refhv,  
                    const uint32_t x,  
                    const uint32_t y,  
                    const uint32_t block,        /* block dimension, 8 or 16 */  
   
                    const VECTOR * mv,   /* measured in half-pel! */  
   
                    const int32_t stride)  
 {  
   
         switch ((((mv->x) & 1) << 1) + ((mv->y) & 1)) {  
         case 0:  
                 return refn + (int) ((x * block + (mv->x) / 2) + (y * block +  
                                                                                                    (mv->y) / 2) * stride);  
         case 1:  
                 return refv + (int) ((x * block + (mv->x) / 2) + (y * block +  
                                                                                                    ((mv->y) - 1) / 2) * stride);  
         case 2:  
                 return refh + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block +  
                                                                                                                  (mv->y) / 2) * stride);  
         default:  
                 return refhv + (int) ((x * block + ((mv->x) - 1) / 2) + (y * block +  
                                                                                                                   ((mv->y) -  
                                                                                                                    1) / 2) * stride);  
         }  
49    
50  }  void MotionEstimation(MBParam * const pParam,
51                                            FRAMEINFO * const current,
52                                            FRAMEINFO * const reference,
53                                            const IMAGE * const pRefH,
54                                            const IMAGE * const pRefV,
55                                            const IMAGE * const pRefHV,
56                                            const IMAGE * const pGMC,
57                                            const uint32_t iLimit,
58                                            const int num_slices);
59    
60  void MotionEstimationBVOP(MBParam * const pParam,  void
61    MotionEstimationBVOP(MBParam * const pParam,
62                                                    FRAMEINFO * const frame,                                                    FRAMEINFO * const frame,
                                                   // forward (past) reference  
63                                                    const int32_t time_bp,                                                    const int32_t time_bp,
64                                                    const int32_t time_pp,                                                    const int32_t time_pp,
65                                                    const MACROBLOCK * const f_mbs,                                                    const MACROBLOCK * const f_mbs,
# Line 140  Line 67 
67                                                    const IMAGE * const f_refH,                                                    const IMAGE * const f_refH,
68                                                    const IMAGE * const f_refV,                                                    const IMAGE * const f_refV,
69                                                    const IMAGE * const f_refHV,                                                    const IMAGE * const f_refHV,
                                                   // backward (future) reference  
70                                                    const FRAMEINFO * const b_reference,                                                    const FRAMEINFO * const b_reference,
71                                                    const IMAGE * const b_ref,                                                    const IMAGE * const b_ref,
72                                                    const IMAGE * const b_refH,                                                    const IMAGE * const b_refH,
73                                                    const IMAGE * const b_refV,                                                    const IMAGE * const b_refV,
74                                                    const IMAGE * const b_refHV);                                                    const IMAGE * const b_refHV);
75    
 void MBMotionCompensationBVOP(MBParam * pParam,  
                                                           MACROBLOCK * const mb,  
                                                           const uint32_t i,  
                                                           const uint32_t j,  
                                                           IMAGE * const cur,  
                                                           const IMAGE * const f_ref,  
                                                           const IMAGE * const f_refh,  
                                                           const IMAGE * const f_refv,  
                                                           const IMAGE * const f_refhv,  
                                                           const IMAGE * const b_ref,  
                                                           const IMAGE * const b_refh,  
                                                           const IMAGE * const b_refv,  
                                                           const IMAGE * const b_refhv,  
                                                           int16_t * dct_codes);  
   
   
 /* GMC stuff. Maybe better put it into a separate file */  
   
76  void  void
77  generate_GMCparameters( const int num_wp,                               // [input]: number of warppoints  GMEanalysis(const MBParam * const pParam,
78                                                  const int res,                                  // [input]: resolution                          const FRAMEINFO * const current,
79                                                  const WARPPOINTS *const warp,   // [input]: warp points                          const FRAMEINFO * const reference,
80                                                  const int width, const int height,      // [input]: without edges!                          const IMAGE * const pRefH,
81                                                  GMC_DATA *const gmc);           // [output] precalculated parameters                          const IMAGE * const pRefV,
82                            const IMAGE * const pRefHV,
83  void                          const int num_slices);
 generate_GMCimage(      const GMC_DATA *const gmc_data,         // [input] precalculated data  
                                         const IMAGE *const pRef,                        // [input]  
                                         const int mb_width,  
                                         const int mb_height,  
                                         const int stride,  
                                         const int stride2,  
                                         const int fcode,                                        // [input] some parameters...  
                                         const int32_t quarterpel,                       // [input] for rounding avgMV  
                                         const int reduced_resolution,           // [input] ignored  
                                         const int32_t rounding,                 // [input] for rounding image data  
                                         MACROBLOCK *const pMBs,         // [output] average motion vectors  
                                         IMAGE *const pGMC);                     // [output] full warped image  
   
   
 VECTOR generate_GMCimageMB(     const GMC_DATA *const gmc_data,         /* [input] all precalc data */  
                                                         const IMAGE *const pRef,                        // [input]  
                                                         const int mi, const int mj,             /* [input] MB position  */  
                                                         const int stride,                                       /* [input] Lumi stride */  
                                                         const int stride2,                                      /* [input] chroma stride */  
                                                         const int quarterpel,                           /* [input] for rounding of AvgMV */  
                                                         const int rounding,  
                                                         IMAGE *const pGMC);                                     /* [outut] generate image */  
   
   
84    
85  /* Hinted ME */  WARPPOINTS
86    GlobalMotionEst(MACROBLOCK * const pMBs,
87                                    const MBParam * const pParam,
88                                    const FRAMEINFO * const current,
89                                    const FRAMEINFO * const reference,
90                                    const IMAGE * const pRefH,
91                                    const IMAGE * const pRefV,
92                                    const IMAGE * const pRefHV,
93                                    const int num_slices);
94    
95  void  int
96  MotionEstimationHinted( MBParam * const pParam,  GlobalMotionEstRefine(
97                                                  FRAMEINFO * const current,                                  WARPPOINTS *const startwp,
98                                                  FRAMEINFO * const reference,                                  MACROBLOCK * const pMBs,
99                                    const MBParam * const pParam,
100                                    const FRAMEINFO * const current,
101                                    const FRAMEINFO * const reference,
102                                    const IMAGE * const pCurr,
103                                    const IMAGE * const pRef,
104                                                  const IMAGE * const pRefH,                                                  const IMAGE * const pRefH,
105                                                  const IMAGE * const pRefV,                                                  const IMAGE * const pRefV,
106                                                  const IMAGE * const pRefHV);                                                  const IMAGE * const pRefHV);
107    
108  int  int
109  MEanalysis(     const IMAGE * const pRef,  globalSAD(const WARPPOINTS *const wp,
110                          FRAMEINFO * const Current,                    const MBParam * const pParam,
111                          MBParam * const pParam,                    const MACROBLOCK * const pMBs,
112                          int maxIntra,                    const FRAMEINFO * const current,
113                          int intraCount,                    const IMAGE * const pRef,
114                          int bCount);                    const IMAGE * const pCurr,
115                      uint8_t *const GMCblock);
116    
117    
118  int  int
119  FindFcode(      const MBParam * const pParam,  MEanalysis(     const IMAGE * const pRef,
120                          const FRAMEINFO * const current);                          const FRAMEINFO * const Current,
121                            const MBParam * const pParam,
122                            const int maxIntra,
123                            const int intraCount,
124                            const int bCount,
125                            const int b_thresh,
126                            const MACROBLOCK * const prev_mbs);
127    
128    /** MotionCompensation **/
129    
130  int d_amv_penalty(int x, int y, const VECTOR pred, const uint32_t iFcode, const int quant);  void
131    MBMotionCompensation(MACROBLOCK * const mb,
132                                            const uint32_t i,
133                                            const uint32_t j,
134                                            const IMAGE * const ref,
135                                            const IMAGE * const refh,
136                                            const IMAGE * const refv,
137                                            const IMAGE * const refhv,
138                                            const IMAGE * const refGMC,
139                                            IMAGE * const cur,
140                                            int16_t * dct_codes,
141                                            const uint32_t width,
142                                            const uint32_t height,
143                                            const uint32_t edged_width,
144                                            const int32_t quarterpel,
145                                            const int32_t rounding,
146                                            const uint8_t * const tmp);
147    
148    void
149    MBMotionCompensationBVOP(MBParam * pParam,
150                                                            MACROBLOCK * const mb,
151                                                            const uint32_t i,
152                                                            const uint32_t j,
153                                                            IMAGE * const cur,
154                                                            const IMAGE * const f_ref,
155                                                            const IMAGE * const f_refh,
156                                                            const IMAGE * const f_refv,
157                                                            const IMAGE * const f_refhv,
158                                                            const IMAGE * const b_ref,
159                                                            const IMAGE * const b_refh,
160                                                            const IMAGE * const b_refv,
161                                                            const IMAGE * const b_refhv,
162                                                            int16_t * dct_codes,
163                                                            const uint8_t * const tmp);
164    
165  #endif                                                  /* _MOTION_H_ */  #endif                                                  /* _MOTION_H_ */

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.26

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