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 |
14 |
#define MODE_STUFFING 7 |
#define MODE_STUFFING 7 |
15 |
#define MODE_NOT_CODED 16 |
#define MODE_NOT_CODED 16 |
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 |
|
|
27 |
typedef struct |
typedef struct |
28 |
{ |
{ |
29 |
int x; |
uint32_t bufa; |
30 |
int y; |
uint32_t bufb; |
31 |
} VECTOR; |
uint32_t buf; |
32 |
|
uint32_t pos; |
33 |
|
uint32_t *tail; |
34 |
|
uint32_t *start; |
35 |
|
uint32_t length; |
36 |
|
} |
37 |
|
Bitstream; |
38 |
|
|
39 |
|
|
40 |
#define MBPRED_SIZE 15 |
#define MBPRED_SIZE 15 |
44 |
{ |
{ |
45 |
// decoder/encoder |
// decoder/encoder |
46 |
VECTOR mvs[4]; |
VECTOR mvs[4]; |
|
uint32_t sad8[4]; // SAD values for inter4v-VECTORs |
|
|
uint32_t sad16; // SAD value for inter-VECTOR |
|
47 |
|
|
48 |
short int pred_values[6][MBPRED_SIZE]; |
short int pred_values[6][MBPRED_SIZE]; |
49 |
int acpred_directions[6]; |
int acpred_directions[6]; |
51 |
int mode; |
int mode; |
52 |
int quant; // absolute quant |
int quant; // absolute quant |
53 |
|
|
54 |
|
int field_dct; |
55 |
|
int field_pred; |
56 |
|
int field_for_top; |
57 |
|
int field_for_bot; |
58 |
|
|
59 |
// encoder specific |
// encoder specific |
60 |
|
|
61 |
|
VECTOR mv16; |
62 |
VECTOR pmvs[4]; |
VECTOR pmvs[4]; |
63 |
|
VECTOR qmvs[4]; // mvs in quarter pixel resolution |
64 |
|
|
65 |
|
int32_t sad8[4]; // SAD values for inter4v-VECTORs |
66 |
|
int32_t sad16; // SAD value for inter-VECTOR |
67 |
|
|
68 |
int dquant; |
int dquant; |
69 |
int cbp; |
int cbp; |
70 |
|
|
71 |
} MACROBLOCK; |
// bframe stuff |
72 |
|
|
73 |
static __inline int8_t get_dc_scaler(int32_t quant, uint32_t lum) |
VECTOR b_mvs[4]; |
74 |
{ |
VECTOR b_qmvs[4]; |
75 |
int8_t dc_scaler; |
// VECTOR b_pmvs[1]; |
76 |
|
|
77 |
if(quant > 0 && quant < 5) { |
// bframe direct mode |
|
dc_scaler = 8; |
|
|
return dc_scaler; |
|
|
} |
|
78 |
|
|
79 |
if(quant < 25 && !lum) { |
// VECTOR directmv[4]; |
80 |
dc_scaler = (quant + 13) >> 1; |
// VECTOR deltamv; |
81 |
return dc_scaler; |
|
82 |
} |
int mb_type; |
83 |
|
int dbquant; |
84 |
|
|
85 |
|
// stuff for block based ME (needed for Qpel ME) |
86 |
|
// backup of last integer ME vectors/sad |
87 |
|
|
88 |
|
// VECTOR i_mv16; |
89 |
|
VECTOR i_mvs[4]; |
90 |
|
|
91 |
|
int32_t i_sad8[4]; // SAD values for inter4v-VECTORs |
92 |
|
// int32_t i_sad16; // SAD value for inter-VECTOR |
93 |
|
|
|
if(quant < 9) { |
|
|
dc_scaler = quant << 1; |
|
|
return dc_scaler; |
|
|
} |
|
94 |
|
|
|
if(quant < 25) { |
|
|
dc_scaler = quant + 8; |
|
|
return dc_scaler; |
|
95 |
} |
} |
96 |
|
MACROBLOCK; |
97 |
|
|
98 |
|
static __inline int8_t |
99 |
|
get_dc_scaler(uint32_t quant, |
100 |
|
uint32_t lum) |
101 |
|
{ |
102 |
|
if (quant < 5) |
103 |
|
return 8; |
104 |
|
|
105 |
|
if (quant < 25 && !lum) |
106 |
|
return (quant + 13) / 2; |
107 |
|
|
108 |
|
if (quant < 9) |
109 |
|
return 2 * quant; |
110 |
|
|
111 |
|
if (quant < 25) |
112 |
|
return quant + 8; |
113 |
|
|
114 |
if(lum) |
if(lum) |
115 |
dc_scaler = (quant << 1) - 16; |
return 2 * quant - 16; |
116 |
else |
else |
117 |
dc_scaler = quant - 6; |
return quant - 6; |
|
|
|
|
return dc_scaler; |
|
118 |
} |
} |
119 |
|
|
120 |
|
// useful macros |
121 |
|
|
122 |
|
#define MIN(X, Y) ((X)<(Y)?(X):(Y)) |
123 |
|
#define MAX(X, Y) ((X)>(Y)?(X):(Y)) |
124 |
|
#define ABS(X) (((X)>0)?(X):-(X)) |
125 |
|
#define SIGN(X) (((X)>0)?1:-1) |
126 |
|
|
127 |
|
|
128 |
#endif /* _GLOBAL_H_ */ |
#endif /* _GLOBAL_H_ */ |