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 |
|
|
25 |
|
|
26 |
typedef struct |
typedef struct |
27 |
{ |
{ |
28 |
int x; |
uint32_t bufa; |
29 |
int y; |
uint32_t bufb; |
30 |
} VECTOR; |
uint32_t buf; |
31 |
|
uint32_t pos; |
32 |
|
uint32_t *tail; |
33 |
|
uint32_t *start; |
34 |
|
uint32_t length; |
35 |
|
} |
36 |
|
Bitstream; |
37 |
|
|
38 |
|
|
39 |
#define MBPRED_SIZE 15 |
#define MBPRED_SIZE 15 |
43 |
{ |
{ |
44 |
// decoder/encoder |
// decoder/encoder |
45 |
VECTOR mvs[4]; |
VECTOR mvs[4]; |
46 |
uint32_t sad8[4]; // SAD values for inter4v-VECTORs |
int32_t sad8[4]; // (signed!) SAD values for inter4v-VECTORs |
47 |
uint32_t sad16; // SAD value for inter-VECTOR |
int32_t sad16; // (signed!) SAD value for inter-VECTOR |
48 |
|
|
49 |
short int pred_values[6][MBPRED_SIZE]; |
short int pred_values[6][MBPRED_SIZE]; |
50 |
int acpred_directions[6]; |
int acpred_directions[6]; |
63 |
int dquant; |
int dquant; |
64 |
int cbp; |
int cbp; |
65 |
|
|
66 |
|
// bframe stuff |
67 |
|
|
68 |
|
VECTOR b_mvs[4]; |
69 |
|
VECTOR b_pmvs[4]; |
70 |
|
|
71 |
|
int mb_type; |
72 |
|
int dbquant; |
73 |
|
|
74 |
} MACROBLOCK; |
} MACROBLOCK; |
75 |
|
|
76 |
static __inline int8_t get_dc_scaler(int32_t quant, uint32_t lum) |
static __inline int8_t get_dc_scaler(uint32_t quant, uint32_t lum) |
77 |
{ |
{ |
78 |
int8_t dc_scaler; |
if(quant < 5) |
79 |
|
return 8; |
|
if(quant > 0 && quant < 5) { |
|
|
dc_scaler = 8; |
|
|
return dc_scaler; |
|
|
} |
|
80 |
|
|
81 |
if(quant < 25 && !lum) { |
if(quant < 25 && !lum) |
82 |
dc_scaler = (quant + 13) >> 1; |
return (quant + 13) / 2; |
|
return dc_scaler; |
|
|
} |
|
83 |
|
|
84 |
if(quant < 9) { |
if(quant < 9) |
85 |
dc_scaler = quant << 1; |
return 2 * quant; |
|
return dc_scaler; |
|
|
} |
|
86 |
|
|
87 |
if(quant < 25) { |
if(quant < 25) |
88 |
dc_scaler = quant + 8; |
return quant + 8; |
|
return dc_scaler; |
|
|
} |
|
89 |
|
|
90 |
if(lum) |
if(lum) |
91 |
dc_scaler = (quant << 1) - 16; |
return 2 * quant - 16; |
92 |
else |
else |
93 |
dc_scaler = quant - 6; |
return quant - 6; |
|
|
|
|
return dc_scaler; |
|
94 |
} |
} |
95 |
|
|
96 |
|
// useful macros |
97 |
|
|
98 |
|
#define MIN(X, Y) ((X)<(Y)?(X):(Y)) |
99 |
|
#define MAX(X, Y) ((X)>(Y)?(X):(Y)) |
100 |
|
#define ABS(X) (((X)>0)?(X):-(X)) |
101 |
|
#define SIGN(X) (((X)>0)?1:-1) |
102 |
|
|
103 |
|
|
104 |
#endif /* _GLOBAL_H_ */ |
#endif /* _GLOBAL_H_ */ |