Parent Directory | Revision Log
Revision 195 - (view) (download)
1 : | Isibaar | 3 | /************************************************************************** |
2 : | * | ||
3 : | * Modifications: | ||
4 : | * | ||
5 : | * 22.08.2001 added support for EXT_MODE encoding mode | ||
6 : | * support for EXTENDED API | ||
7 : | * 22.08.2001 fixed bug in iDQtab | ||
8 : | * | ||
9 : | * Michael Militzer <isibaar@videocoding.de> | ||
10 : | * | ||
11 : | **************************************************************************/ | ||
12 : | |||
13 : | #ifndef _ENCODER_H_ | ||
14 : | #define _ENCODER_H_ | ||
15 : | |||
16 : | |||
17 : | #include "xvid.h" | ||
18 : | |||
19 : | #include "portab.h" | ||
20 : | #include "global.h" | ||
21 : | #include "image/image.h" | ||
22 : | edgomez | 188 | #include "utils/ratecontrol.h" |
23 : | Isibaar | 3 | |
24 : | #define H263_QUANT 0 | ||
25 : | #define MPEG4_QUANT 1 | ||
26 : | |||
27 : | |||
28 : | typedef uint32_t bool; | ||
29 : | |||
30 : | |||
31 : | typedef enum | ||
32 : | { | ||
33 : | edgomez | 188 | I_VOP = 0, |
34 : | P_VOP = 1, | ||
35 : | suxen_drol | 136 | B_VOP = 2 |
36 : | Isibaar | 3 | } |
37 : | VOP_TYPE; | ||
38 : | |||
39 : | /*********************************** | ||
40 : | |||
41 : | Encoding Parameters | ||
42 : | |||
43 : | edgomez | 195 | ************************************/ |
44 : | Isibaar | 3 | |
45 : | typedef struct | ||
46 : | { | ||
47 : | edgomez | 188 | uint32_t width; |
48 : | uint32_t height; | ||
49 : | Isibaar | 3 | |
50 : | uint32_t edged_width; | ||
51 : | uint32_t edged_height; | ||
52 : | uint32_t mb_width; | ||
53 : | uint32_t mb_height; | ||
54 : | |||
55 : | suxen_drol | 152 | /* frame rate increment & base */ |
56 : | uint32_t fincr; | ||
57 : | uint32_t fbase; | ||
58 : | |||
59 : | suxen_drol | 164 | #ifdef BFRAMES |
60 : | int max_bframes; | ||
61 : | #endif | ||
62 : | |||
63 : | edgomez | 188 | /* rounding type; alternate 0-1 after each interframe */ |
64 : | Isibaar | 3 | /* 1 <= fixed_code <= 4 |
65 : | automatically adjusted using motion vector statistics inside | ||
66 : | edgomez | 195 | */ |
67 : | Isibaar | 3 | |
68 : | suxen_drol | 136 | /* 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 : | edgomez | 195 | HINTINFO *hint; |
74 : | suxen_drol | 136 | |
75 : | suxen_drol | 152 | #ifdef BFRAMES |
76 : | uint32_t m_seconds; | ||
77 : | uint32_t m_ticks; | ||
78 : | #endif | ||
79 : | |||
80 : | edgomez | 195 | } |
81 : | MBParam; | ||
82 : | suxen_drol | 136 | |
83 : | |||
84 : | typedef struct | ||
85 : | { | ||
86 : | edgomez | 188 | uint32_t quant; |
87 : | edgomez | 195 | uint32_t motion_flags; |
88 : | Isibaar | 3 | uint32_t global_flags; |
89 : | h | 101 | |
90 : | suxen_drol | 136 | VOP_TYPE coding_type; |
91 : | edgomez | 188 | uint32_t rounding_type; |
92 : | uint32_t fcode; | ||
93 : | suxen_drol | 136 | uint32_t bcode; |
94 : | Isibaar | 3 | |
95 : | suxen_drol | 152 | #ifdef BFRAMES |
96 : | uint32_t seconds; | ||
97 : | uint32_t ticks; | ||
98 : | #endif | ||
99 : | suxen_drol | 136 | |
100 : | IMAGE image; | ||
101 : | |||
102 : | edgomez | 195 | MACROBLOCK *mbs; |
103 : | suxen_drol | 136 | |
104 : | edgomez | 195 | } |
105 : | FRAMEINFO; | ||
106 : | suxen_drol | 136 | |
107 : | Isibaar | 3 | typedef struct |
108 : | { | ||
109 : | edgomez | 188 | int iTextBits; |
110 : | float fMvPrevSigma; | ||
111 : | int iMvSum; | ||
112 : | int iMvCount; | ||
113 : | Isibaar | 3 | int kblks; |
114 : | int mblks; | ||
115 : | int ublks; | ||
116 : | } | ||
117 : | Statistics; | ||
118 : | |||
119 : | |||
120 : | |||
121 : | typedef struct | ||
122 : | { | ||
123 : | edgomez | 188 | MBParam mbParam; |
124 : | Isibaar | 3 | |
125 : | edgomez | 188 | int iFrameNum; |
126 : | int iMaxKeyInterval; | ||
127 : | Isibaar | 3 | int bitrate; |
128 : | |||
129 : | // images | ||
130 : | |||
131 : | edgomez | 195 | FRAMEINFO *current; |
132 : | FRAMEINFO *reference; | ||
133 : | suxen_drol | 136 | |
134 : | Isibaar | 113 | #ifdef _DEBUG |
135 : | IMAGE sOriginal; | ||
136 : | #endif | ||
137 : | edgomez | 188 | IMAGE vInterH; |
138 : | IMAGE vInterV; | ||
139 : | h | 83 | IMAGE vInterVf; |
140 : | edgomez | 188 | IMAGE vInterHV; |
141 : | h | 83 | IMAGE vInterHVf; |
142 : | Isibaar | 3 | |
143 : | suxen_drol | 152 | #ifdef BFRAMES |
144 : | /* constants */ | ||
145 : | int bquant_ratio; | ||
146 : | /* vars */ | ||
147 : | int bframenum_head; | ||
148 : | int bframenum_tail; | ||
149 : | int flush_bframes; | ||
150 : | |||
151 : | edgomez | 195 | FRAMEINFO **bframes; |
152 : | edgomez | 188 | IMAGE f_refh; |
153 : | IMAGE f_refv; | ||
154 : | IMAGE f_refhv; | ||
155 : | suxen_drol | 152 | #endif |
156 : | edgomez | 188 | Statistics sStat; |
157 : | RateControl rate_control; | ||
158 : | Isibaar | 3 | } |
159 : | Encoder; | ||
160 : | |||
161 : | |||
162 : | // indicates no quantizer changes in INTRA_Q/INTER_Q modes | ||
163 : | #define NO_CHANGE 64 | ||
164 : | |||
165 : | void init_encoder(uint32_t cpu_flags); | ||
166 : | |||
167 : | int encoder_create(XVID_ENC_PARAM * pParam); | ||
168 : | int encoder_destroy(Encoder * pEnc); | ||
169 : | edgomez | 195 | int encoder_encode(Encoder * pEnc, |
170 : | XVID_ENC_FRAME * pFrame, | ||
171 : | XVID_ENC_STATS * pResult); | ||
172 : | |||
173 : | static __inline uint8_t | ||
174 : | get_fcode(uint16_t sr) | ||
175 : | Isibaar | 3 | { |
176 : | edgomez | 188 | if (sr <= 16) |
177 : | Isibaar | 3 | return 1; |
178 : | |||
179 : | edgomez | 195 | else if (sr <= 32) |
180 : | Isibaar | 3 | return 2; |
181 : | |||
182 : | edgomez | 188 | else if (sr <= 64) |
183 : | Isibaar | 3 | return 3; |
184 : | |||
185 : | edgomez | 188 | else if (sr <= 128) |
186 : | Isibaar | 3 | return 4; |
187 : | |||
188 : | edgomez | 188 | else if (sr <= 256) |
189 : | Isibaar | 3 | return 5; |
190 : | |||
191 : | edgomez | 188 | else if (sr <= 512) |
192 : | Isibaar | 3 | return 6; |
193 : | |||
194 : | edgomez | 188 | else if (sr <= 1024) |
195 : | Isibaar | 3 | return 7; |
196 : | |||
197 : | edgomez | 188 | else |
198 : | Isibaar | 3 | return 0; |
199 : | } | ||
200 : | |||
201 : | edgomez | 195 | #endif /* _ENCODER_H_ */ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |