[svn] / trunk / xvidcore / src / encoder.h Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/encoder.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 188 - (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 :     ************************************/
44 :    
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 188 */
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 :     HINTINFO * hint;
74 :    
75 : suxen_drol 152 #ifdef BFRAMES
76 :     uint32_t m_seconds;
77 :     uint32_t m_ticks;
78 :     #endif
79 :    
80 : suxen_drol 136 } MBParam;
81 :    
82 :    
83 :     typedef struct
84 :     {
85 : edgomez 188 uint32_t quant;
86 : Isibaar 3 uint32_t motion_flags;
87 :     uint32_t global_flags;
88 : h 101
89 : suxen_drol 136 VOP_TYPE coding_type;
90 : edgomez 188 uint32_t rounding_type;
91 :     uint32_t fcode;
92 : suxen_drol 136 uint32_t bcode;
93 : Isibaar 3
94 : suxen_drol 152 #ifdef BFRAMES
95 :     uint32_t seconds;
96 :     uint32_t ticks;
97 :     #endif
98 : suxen_drol 136
99 :     IMAGE image;
100 :    
101 :     MACROBLOCK * mbs;
102 :    
103 :     } FRAMEINFO;
104 :    
105 : Isibaar 3 typedef struct
106 :     {
107 : edgomez 188 int iTextBits;
108 :     float fMvPrevSigma;
109 :     int iMvSum;
110 :     int iMvCount;
111 : Isibaar 3 int kblks;
112 :     int mblks;
113 :     int ublks;
114 :     }
115 :     Statistics;
116 :    
117 :    
118 :    
119 :     typedef struct
120 :     {
121 : edgomez 188 MBParam mbParam;
122 : Isibaar 3
123 : edgomez 188 int iFrameNum;
124 :     int iMaxKeyInterval;
125 : Isibaar 3 int bitrate;
126 :    
127 :     // images
128 :    
129 : suxen_drol 136 FRAMEINFO * current;
130 :     FRAMEINFO * reference;
131 :    
132 : Isibaar 113 #ifdef _DEBUG
133 :     IMAGE sOriginal;
134 :     #endif
135 : edgomez 188 IMAGE vInterH;
136 :     IMAGE vInterV;
137 : h 83 IMAGE vInterVf;
138 : edgomez 188 IMAGE vInterHV;
139 : h 83 IMAGE vInterHVf;
140 : Isibaar 3
141 : suxen_drol 152 #ifdef BFRAMES
142 :     /* constants */
143 :     int bquant_ratio;
144 :     /* vars */
145 :     int bframenum_head;
146 :     int bframenum_tail;
147 :     int flush_bframes;
148 :    
149 :     FRAMEINFO ** bframes;
150 : edgomez 188 IMAGE f_refh;
151 :     IMAGE f_refv;
152 :     IMAGE f_refhv;
153 : suxen_drol 152 #endif
154 : edgomez 188 Statistics sStat;
155 :     RateControl rate_control;
156 : Isibaar 3 }
157 :     Encoder;
158 :    
159 :    
160 :     // indicates no quantizer changes in INTRA_Q/INTER_Q modes
161 :     #define NO_CHANGE 64
162 :    
163 :     void init_encoder(uint32_t cpu_flags);
164 :    
165 :     int encoder_create(XVID_ENC_PARAM * pParam);
166 :     int encoder_destroy(Encoder * pEnc);
167 :     int encoder_encode(Encoder * pEnc, XVID_ENC_FRAME * pFrame, XVID_ENC_STATS * pResult);
168 :    
169 :     static __inline uint8_t get_fcode(uint16_t sr)
170 :     {
171 : edgomez 188 if (sr <= 16)
172 : Isibaar 3 return 1;
173 :    
174 : edgomez 188 else if (sr <= 32)
175 : Isibaar 3 return 2;
176 :    
177 : edgomez 188 else if (sr <= 64)
178 : Isibaar 3 return 3;
179 :    
180 : edgomez 188 else if (sr <= 128)
181 : Isibaar 3 return 4;
182 :    
183 : edgomez 188 else if (sr <= 256)
184 : Isibaar 3 return 5;
185 :    
186 : edgomez 188 else if (sr <= 512)
187 : Isibaar 3 return 6;
188 :    
189 : edgomez 188 else if (sr <= 1024)
190 : Isibaar 3 return 7;
191 :    
192 : edgomez 188 else
193 : Isibaar 3 return 0;
194 :     }
195 :    
196 :     #endif /* _ENCODER_H_ */

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4