19 |
#include "portab.h" |
#include "portab.h" |
20 |
#include "global.h" |
#include "global.h" |
21 |
#include "image/image.h" |
#include "image/image.h" |
22 |
|
#include "utils/ratecontrol.h" |
23 |
|
|
24 |
#define H263_QUANT 0 |
#define H263_QUANT 0 |
25 |
#define MPEG4_QUANT 1 |
#define MPEG4_QUANT 1 |
31 |
typedef enum |
typedef enum |
32 |
{ |
{ |
33 |
I_VOP = 0, |
I_VOP = 0, |
34 |
P_VOP = 1 |
P_VOP = 1, |
35 |
|
B_VOP = 2 |
36 |
} |
} |
37 |
VOP_TYPE; |
VOP_TYPE; |
38 |
|
|
52 |
uint32_t mb_width; |
uint32_t mb_width; |
53 |
uint32_t mb_height; |
uint32_t mb_height; |
54 |
|
|
55 |
VOP_TYPE coding_type; |
/* frame rate increment & base */ |
56 |
|
uint32_t fincr; |
57 |
|
uint32_t fbase; |
58 |
|
|
59 |
|
#ifdef BFRAMES |
60 |
|
int max_bframes; |
61 |
|
#endif |
62 |
|
|
63 |
/* rounding type; alternate 0-1 after each interframe */ |
/* rounding type; alternate 0-1 after each interframe */ |
|
|
|
|
uint32_t rounding_type; |
|
|
|
|
64 |
/* 1 <= fixed_code <= 4 |
/* 1 <= fixed_code <= 4 |
65 |
automatically adjusted using motion vector statistics inside |
automatically adjusted using motion vector statistics inside |
66 |
*/ |
*/ |
67 |
|
|
68 |
uint32_t fixed_code; |
/* vars that not "quite" frame independant */ |
69 |
|
uint32_t m_quant_type; |
70 |
|
uint32_t m_rounding_type; |
71 |
|
uint32_t m_fcode; |
72 |
|
|
73 |
|
HINTINFO *hint; |
74 |
|
|
75 |
|
#ifdef BFRAMES |
76 |
|
uint32_t m_seconds; |
77 |
|
uint32_t m_ticks; |
78 |
|
#endif |
79 |
|
|
80 |
|
} |
81 |
|
MBParam; |
82 |
|
|
83 |
|
|
84 |
|
typedef struct |
85 |
|
{ |
86 |
uint32_t quant; |
uint32_t quant; |
|
uint32_t quant_type; |
|
87 |
uint32_t motion_flags; |
uint32_t motion_flags; |
88 |
uint32_t global_flags; |
uint32_t global_flags; |
89 |
} MBParam; |
|
90 |
|
VOP_TYPE coding_type; |
91 |
|
uint32_t rounding_type; |
92 |
|
uint32_t fcode; |
93 |
|
uint32_t bcode; |
94 |
|
|
95 |
|
#ifdef BFRAMES |
96 |
|
uint32_t seconds; |
97 |
|
uint32_t ticks; |
98 |
|
#endif |
99 |
|
|
100 |
|
IMAGE image; |
101 |
|
|
102 |
|
MACROBLOCK *mbs; |
103 |
|
|
104 |
|
} |
105 |
|
FRAMEINFO; |
106 |
|
|
107 |
typedef struct |
typedef struct |
108 |
{ |
{ |
124 |
|
|
125 |
int iFrameNum; |
int iFrameNum; |
126 |
int iMaxKeyInterval; |
int iMaxKeyInterval; |
|
int lum_masking; |
|
127 |
int bitrate; |
int bitrate; |
128 |
|
|
129 |
// images |
// images |
130 |
|
|
131 |
IMAGE sCurrent; |
FRAMEINFO *current; |
132 |
IMAGE sReference; |
FRAMEINFO *reference; |
133 |
|
|
134 |
|
#ifdef _DEBUG |
135 |
|
IMAGE sOriginal; |
136 |
|
#endif |
137 |
IMAGE vInterH; |
IMAGE vInterH; |
138 |
IMAGE vInterV; |
IMAGE vInterV; |
139 |
|
IMAGE vInterVf; |
140 |
IMAGE vInterHV; |
IMAGE vInterHV; |
141 |
|
IMAGE vInterHVf; |
142 |
|
|
143 |
// macroblock |
#ifdef BFRAMES |
144 |
|
/* constants */ |
145 |
MACROBLOCK * pMBs; |
int bquant_ratio; |
146 |
|
/* vars */ |
147 |
|
int bframenum_head; |
148 |
|
int bframenum_tail; |
149 |
|
int flush_bframes; |
150 |
|
|
151 |
|
FRAMEINFO **bframes; |
152 |
|
IMAGE f_refh; |
153 |
|
IMAGE f_refv; |
154 |
|
IMAGE f_refhv; |
155 |
|
#endif |
156 |
Statistics sStat; |
Statistics sStat; |
157 |
|
RateControl rate_control; |
158 |
} |
} |
159 |
Encoder; |
Encoder; |
160 |
|
|
166 |
|
|
167 |
int encoder_create(XVID_ENC_PARAM * pParam); |
int encoder_create(XVID_ENC_PARAM * pParam); |
168 |
int encoder_destroy(Encoder * pEnc); |
int encoder_destroy(Encoder * pEnc); |
169 |
int encoder_encode(Encoder * pEnc, XVID_ENC_FRAME * pFrame, XVID_ENC_STATS * pResult); |
int encoder_encode(Encoder * pEnc, |
170 |
|
XVID_ENC_FRAME * pFrame, |
171 |
|
XVID_ENC_STATS * pResult); |
172 |
|
|
173 |
static __inline uint8_t get_fcode(uint16_t sr) |
static __inline uint8_t |
174 |
|
get_fcode(uint16_t sr) |
175 |
{ |
{ |
176 |
if (sr <= 16) |
if (sr <= 16) |
177 |
return 1; |
return 1; |