1 |
#ifndef _GLOBAL_H_ |
2 |
#define _GLOBAL_H_ |
3 |
|
4 |
#include "portab.h" |
5 |
|
6 |
/* --- macroblock stuff --- */ |
7 |
|
8 |
#define MODE_INTER 0 |
9 |
#define MODE_INTER_Q 1 |
10 |
#define MODE_INTER4V 2 |
11 |
#define MODE_INTRA 3 |
12 |
#define MODE_INTRA_Q 4 |
13 |
#define MODE_STUFFING 7 |
14 |
#define MODE_NOT_CODED 16 |
15 |
|
16 |
typedef struct |
17 |
{ |
18 |
int x; |
19 |
int y; |
20 |
} VECTOR; |
21 |
|
22 |
|
23 |
#define MBPRED_SIZE 15 |
24 |
|
25 |
|
26 |
typedef struct |
27 |
{ |
28 |
// decoder/encoder |
29 |
VECTOR mvs[4]; |
30 |
uint32_t sad8[4]; // SAD values for inter4v-VECTORs |
31 |
uint32_t sad16; // SAD value for inter-VECTOR |
32 |
|
33 |
short int pred_values[6][MBPRED_SIZE]; |
34 |
int acpred_directions[6]; |
35 |
|
36 |
int mode; |
37 |
int quant; // absolute quant |
38 |
|
39 |
int field_dct; |
40 |
int field_pred; |
41 |
int field_for_top; |
42 |
int field_for_bot; |
43 |
|
44 |
// encoder specific |
45 |
|
46 |
VECTOR pmvs[4]; |
47 |
int dquant; |
48 |
int cbp; |
49 |
|
50 |
} MACROBLOCK; |
51 |
|
52 |
static __inline int8_t get_dc_scaler(int32_t quant, uint32_t lum) |
53 |
{ |
54 |
int8_t dc_scaler; |
55 |
|
56 |
if(quant > 0 && quant < 5) { |
57 |
dc_scaler = 8; |
58 |
return dc_scaler; |
59 |
} |
60 |
|
61 |
if(quant < 25 && !lum) { |
62 |
dc_scaler = (quant + 13) >> 1; |
63 |
return dc_scaler; |
64 |
} |
65 |
|
66 |
if(quant < 9) { |
67 |
dc_scaler = quant << 1; |
68 |
return dc_scaler; |
69 |
} |
70 |
|
71 |
if(quant < 25) { |
72 |
dc_scaler = quant + 8; |
73 |
return dc_scaler; |
74 |
} |
75 |
|
76 |
if(lum) |
77 |
dc_scaler = (quant << 1) - 16; |
78 |
else |
79 |
dc_scaler = quant - 6; |
80 |
|
81 |
return dc_scaler; |
82 |
} |
83 |
|
84 |
#endif /* _GLOBAL_H_ */ |