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

Diff of /xvidcore/src/global.h

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

revision 1.2, Tue Mar 26 11:16:08 2002 UTC revision 1.22, Fri Apr 4 22:16:15 2003 UTC
# Line 1  Line 1 
1  #ifndef _GLOBAL_H_  #ifndef _GLOBAL_H_
2  #define _GLOBAL_H_  #define _GLOBAL_H_
3    
4    #include "xvid.h"
5  #include "portab.h"  #include "portab.h"
6    
7  /* --- macroblock stuff --- */  /* --- macroblock modes --- */
8    
9  #define MODE_INTER              0  #define MODE_INTER              0
10  #define MODE_INTER_Q    1  #define MODE_INTER_Q    1
11  #define MODE_INTER4V    2  #define MODE_INTER4V    2
12  #define MODE_INTRA              3  #define MODE_INTRA              3
13  #define MODE_INTRA_Q    4  #define MODE_INTRA_Q    4
 #define MODE_STUFFING   7  
14  #define MODE_NOT_CODED  16  #define MODE_NOT_CODED  16
15    #define MODE_NOT_CODED_GMC      17
16    
17    /* --- bframe specific --- */
18    
19    #define MODE_DIRECT                     0
20    #define MODE_INTERPOLATE        1
21    #define MODE_BACKWARD           2
22    #define MODE_FORWARD            3
23    #define MODE_DIRECT_NONE_MV     4
24    #define MODE_DIRECT_NO4V        5
25    
26    typedef struct
27    {
28            VECTOR duv[3];
29    }
30    WARPPOINTS;
31    
32    /* save all warping parameters for GMC once and for all, instead of
33       recalculating for every block. This is needed for encoding&decoding
34       When switching to incremental calculations, this will get much shorter
35    */
36    
37    /*      we don't include WARPPOINTS wp  here, but in FRAMEINFO itself */
38    
39    typedef struct
40    {
41            int num_wp;             //      [input]: 0=none, 1=translation, 2,3 = warping
42                                                            //  a value of -1 means: "structure not initialized!"
43            int s;                                  //  [input]: calc is done with 1/s pel resolution
44    
45            int W;
46            int H;
47    
48            int ss;
49            int smask;
50            int sigma;
51    
52            int r;
53            int rho;
54    
55            int i0s;
56            int j0s;
57            int i1s;
58            int j1s;
59            int i2s;
60            int j2s;
61    
62            int i1ss;
63            int j1ss;
64            int i2ss;
65            int j2ss;
66    
67            int alpha;
68            int beta;
69            int Ws;
70            int Hs;
71    
72            int dxF, dyF, dxG, dyG;
73            int Fo, Go;
74            int cFo, cGo;
75    }
76    GMC_DATA;
77    
78    
79  typedef struct  typedef struct
80  {  {
81          int x;          uint8_t *y;
82          int y;          uint8_t *u;
83  } VECTOR;          uint8_t *v;
84    }
85    IMAGE;
86    
87    
88    typedef struct
89    {
90            uint32_t bufa;
91            uint32_t bufb;
92            uint32_t buf;
93            uint32_t pos;
94            uint32_t *tail;
95            uint32_t *start;
96            uint32_t length;
97            uint32_t initpos;
98    }
99    Bitstream;
100    
101    
102  #define MBPRED_SIZE  15  #define MBPRED_SIZE  15
# Line 27  Line 106 
106  {  {
107          // decoder/encoder          // decoder/encoder
108          VECTOR mvs[4];          VECTOR mvs[4];
         uint32_t sad8[4];               // SAD values for inter4v-VECTORs  
         uint32_t sad16;                 // SAD value for inter-VECTOR  
109    
110      short int pred_values[6][MBPRED_SIZE];      short int pred_values[6][MBPRED_SIZE];
111      int acpred_directions[6];      int acpred_directions[6];
# Line 43  Line 120 
120    
121          // encoder specific          // encoder specific
122    
123            VECTOR mv16;
124          VECTOR pmvs[4];          VECTOR pmvs[4];
125            VECTOR qmvs[4];                         // mvs in quarter pixel resolution
126    
127            int32_t sad8[4];                        // SAD values for inter4v-VECTORs
128            int32_t sad16;                          // SAD value for inter-VECTOR
129    
130          int dquant;          int dquant;
131          int cbp;          int cbp;
132    
133  } MACROBLOCK;          // bframe stuff
134    
135  static __inline int8_t get_dc_scaler(int32_t quant, uint32_t lum)          VECTOR b_mvs[4];
136  {          VECTOR b_qmvs[4];
     int8_t dc_scaler;  
137    
138          if(quant > 0 && quant < 5) {          int mb_type;
         dc_scaler = 8;  
                 return dc_scaler;  
         }  
139    
140          if(quant < 25 && !lum) {          // stuff for block based ME (needed for Qpel ME)
141          dc_scaler = (quant + 13) >> 1;          // backup of last integer ME vectors/sad
                 return dc_scaler;  
         }  
142    
143          if(quant < 9) {          VECTOR amv; // average motion vectors from GMC
144          dc_scaler = quant << 1;          int32_t mcsel;
145                  return dc_scaler;  
146          }  /* This structure has become way to big! What to do? Split it up?   */
147    
     if(quant < 25) {  
         dc_scaler = quant + 8;  
                 return dc_scaler;  
148          }          }
149    MACROBLOCK;
150    
151    static __inline uint32_t
152    get_dc_scaler(uint32_t quant,
153                              uint32_t lum)
154    {
155            if (quant < 5)
156                    return 8;
157    
158            if (quant < 25 && !lum)
159                    return (quant + 13) / 2;
160    
161            if (quant < 9)
162                    return 2 * quant;
163    
164            if (quant < 25)
165                    return quant + 8;
166    
167          if(lum)          if(lum)
168                  dc_scaler = (quant << 1) - 16;                  return 2 * quant - 16;
169          else          else
170          dc_scaler = quant - 6;                  return quant - 6;
   
     return dc_scaler;  
171  }  }
172    
173    // useful macros
174    
175    #define MIN(X, Y) ((X)<(Y)?(X):(Y))
176    #define MAX(X, Y) ((X)>(Y)?(X):(Y))
177    #define ABS(X)    (((X)>0)?(X):-(X))
178    #define SIGN(X)   (((X)>0)?1:-1)
179    #define CLIP(X,AMIN,AMAX)   (((X)<(AMIN)) ? (AMIN) : ((X)>(AMAX)) ? (AMAX) : (X))
180    #define DIV_DIV(a,b)    (((a)>0) ? ((a)+((b)>>1))/(b) : ((a)-((b)>>1))/(b))
181    
182    
183  #endif /* _GLOBAL_H_ */  #endif /* _GLOBAL_H_ */

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.22

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