[svn] / trunk / xvidcore / src / xvid.c Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/xvid.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 154 - (view) (download)

1 : Isibaar 3 /**************************************************************************
2 :     *
3 :     * XVID MPEG-4 VIDEO CODEC
4 :     * native api
5 :     *
6 :     * This program is an implementation of a part of one or more MPEG-4
7 :     * Video tools as specified in ISO/IEC 14496-2 standard. Those intending
8 :     * to use this software module in hardware or software products are
9 :     * advised that its use may infringe existing patents or copyrights, and
10 :     * any such use would be at such party's own risk. The original
11 :     * developer of this software module and his/her company, and subsequent
12 :     * editors and their companies, will have no liability for use of this
13 :     * software or modifications or derivatives thereof.
14 :     *
15 :     * This program is free software; you can redistribute it and/or modify
16 :     * it under the terms of the GNU General Public License as published by
17 :     * the Free Software Foundation; either version 2 of the License, or
18 :     * (at your option) any later version.
19 :     *
20 :     * This program is distributed in the hope that it will be useful,
21 :     * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 :     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 :     * GNU General Public License for more details.
24 :     *
25 :     * You should have received a copy of the GNU General Public License
26 :     * along with this program; if not, write to the Free Software
27 :     * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 :     *
29 :     *************************************************************************/
30 :    
31 :     /**************************************************************************
32 :     *
33 :     * History:
34 :     *
35 : h 38 * 17.03.2002 Added interpolate8x8_halfpel_hv_xmm
36 : Isibaar 3 * 22.12.2001 API change: added xvid_init() - Isibaar
37 :     * 16.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>
38 :     *
39 :     *************************************************************************/
40 :    
41 :    
42 :     #include "xvid.h"
43 :     #include "decoder.h"
44 :     #include "encoder.h"
45 :     #include "bitstream/cbp.h"
46 :     #include "dct/idct.h"
47 :     #include "dct/fdct.h"
48 :     #include "image/colorspace.h"
49 :     #include "image/interpolate8x8.h"
50 :     #include "utils/mem_transfer.h"
51 :     #include "quant/quant_h263.h"
52 :     #include "quant/quant_mpeg4.h"
53 :     #include "motion/sad.h"
54 :     #include "utils/emms.h"
55 :     #include "utils/timer.h"
56 : Isibaar 100 #include "bitstream/mbcoding.h"
57 : Isibaar 3
58 :     int xvid_init(void *handle, int opt, void *param1, void *param2)
59 :     {
60 :     int cpu_flags;
61 :     XVID_INIT_PARAM *init_param;
62 :    
63 :     init_param = (XVID_INIT_PARAM *) param1;
64 :    
65 :     // force specific cpu settings?
66 :     if((init_param->cpu_flags & XVID_CPU_FORCE) > 0)
67 :     cpu_flags = init_param->cpu_flags;
68 :     else {
69 :    
70 :     #ifdef ARCH_X86
71 :     cpu_flags = check_cpu_features();
72 :     #else
73 :     cpu_flags = 0;
74 :     #endif
75 :     init_param->cpu_flags = cpu_flags;
76 :     }
77 :    
78 :     // initialize the function pointers
79 :     idct_int32_init();
80 : Isibaar 100 init_vlc_tables();
81 :    
82 : Isibaar 3 fdct = fdct_int32;
83 :     idct = idct_int32;
84 :    
85 : canard 115 sadInit = 0;
86 :    
87 : Isibaar 3 emms = emms_c;
88 :    
89 :     quant_intra = quant_intra_c;
90 :     dequant_intra = dequant_intra_c;
91 :     quant_inter = quant_inter_c;
92 :     dequant_inter = dequant_inter_c;
93 :    
94 :     quant4_intra = quant4_intra_c;
95 :     dequant4_intra = dequant4_intra_c;
96 :     quant4_inter = quant4_inter_c;
97 :     dequant4_inter = dequant4_inter_c;
98 :    
99 :     transfer_8to16copy = transfer_8to16copy_c;
100 :     transfer_16to8copy = transfer_16to8copy_c;
101 :     transfer_8to16sub = transfer_8to16sub_c;
102 : suxen_drol 118 transfer_8to16sub2 = transfer_8to16sub2_c;
103 : Isibaar 3 transfer_16to8add = transfer_16to8add_c;
104 :     transfer8x8_copy = transfer8x8_copy_c;
105 :    
106 :     interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_c;
107 :     interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_c;
108 :     interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c;
109 :    
110 :     colorspace_init();
111 :    
112 :     rgb555_to_yv12 = rgb555_to_yv12_c;
113 :     rgb565_to_yv12 = rgb565_to_yv12_c;
114 :     rgb24_to_yv12 = rgb24_to_yv12_c;
115 :     rgb32_to_yv12 = rgb32_to_yv12_c;
116 :     yuv_to_yv12 = yuv_to_yv12_c;
117 :     yuyv_to_yv12 = yuyv_to_yv12_c;
118 :     uyvy_to_yv12 = uyvy_to_yv12_c;
119 :    
120 :     yv12_to_rgb555 = yv12_to_rgb555_c;
121 :     yv12_to_rgb565 = yv12_to_rgb565_c;
122 :     yv12_to_rgb24 = yv12_to_rgb24_c;
123 :     yv12_to_rgb32 = yv12_to_rgb32_c;
124 :     yv12_to_yuv = yv12_to_yuv_c;
125 :     yv12_to_yuyv = yv12_to_yuyv_c;
126 :     yv12_to_uyvy = yv12_to_uyvy_c;
127 :    
128 :     calc_cbp = calc_cbp_c;
129 :     sad16 = sad16_c;
130 : suxen_drol 118 sad16bi = sad16bi_c;
131 : Isibaar 3 sad8 = sad8_c;
132 :     dev16 = dev16_c;
133 :    
134 :     #ifdef ARCH_X86
135 :     if((cpu_flags & XVID_CPU_MMX) > 0) {
136 :     fdct = fdct_mmx;
137 :     idct = idct_mmx;
138 :    
139 :     emms = emms_mmx;
140 :    
141 :     quant_intra = quant_intra_mmx;
142 :     dequant_intra = dequant_intra_mmx;
143 :     quant_inter = quant_inter_mmx;
144 :     dequant_inter = dequant_inter_mmx;
145 :    
146 :     quant4_intra = quant4_intra_mmx;
147 :     dequant4_intra = dequant4_intra_mmx;
148 :     quant4_inter = quant4_inter_mmx;
149 :     dequant4_inter = dequant4_inter_mmx;
150 :    
151 :     transfer_8to16copy = transfer_8to16copy_mmx;
152 :     transfer_16to8copy = transfer_16to8copy_mmx;
153 :     transfer_8to16sub = transfer_8to16sub_mmx;
154 :     transfer_16to8add = transfer_16to8add_mmx;
155 :     transfer8x8_copy = transfer8x8_copy_mmx;
156 :    
157 :     interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx;
158 :     interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx;
159 :     interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx;
160 :    
161 :     rgb24_to_yv12 = rgb24_to_yv12_mmx;
162 :     rgb32_to_yv12 = rgb32_to_yv12_mmx;
163 :     yuv_to_yv12 = yuv_to_yv12_mmx;
164 :     yuyv_to_yv12 = yuyv_to_yv12_mmx;
165 :     uyvy_to_yv12 = uyvy_to_yv12_mmx;
166 :    
167 :     yv12_to_rgb24 = yv12_to_rgb24_mmx;
168 :     yv12_to_rgb32 = yv12_to_rgb32_mmx;
169 :     yv12_to_yuyv = yv12_to_yuyv_mmx;
170 :     yv12_to_uyvy = yv12_to_uyvy_mmx;
171 :    
172 :     calc_cbp = calc_cbp_mmx;
173 :     sad16 = sad16_mmx;
174 :     sad8 = sad8_mmx;
175 :     dev16 = dev16_mmx;
176 :    
177 :     }
178 :    
179 :     if((cpu_flags & XVID_CPU_MMXEXT) > 0) {
180 :     idct = idct_xmm;
181 :     interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_xmm;
182 :     interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm;
183 : h 38 interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm;
184 : Isibaar 3 yuv_to_yv12 = yuv_to_yv12_xmm;
185 :    
186 :     sad16 = sad16_xmm;
187 :     sad8 = sad8_xmm;
188 :     dev16 = dev16_xmm;
189 :    
190 :     }
191 :    
192 :     if((cpu_flags & XVID_CPU_3DNOW) > 0) {
193 :     interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dn;
194 :     interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_3dn;
195 : h 40 interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn;
196 : Isibaar 3 }
197 :    
198 : h 126 if((cpu_flags & XVID_CPU_SSE2) > 0) {
199 : Isibaar 154 #ifdef EXPERIMENTAL_SSE2_CODE
200 :     quant_intra = quant_intra_sse2;
201 :     dequant_intra = dequant_intra_sse2;
202 :     quant_inter = quant_inter_sse2;
203 :     dequant_inter = dequant_inter_sse2;
204 : h 135
205 : Isibaar 154 calc_cbp = calc_cbp_sse2;
206 :     sad16 = sad16_sse2;
207 :     dev16 = dev16_sse2;
208 :     idct = idct_sse2;
209 :     fdct = fdct_sse2;
210 :     #endif
211 : h 126 }
212 :    
213 : Isibaar 3 #endif
214 : canard 52 #ifdef ARCH_PPC
215 : canard 71 #ifdef ARCH_PPC_ALTIVEC
216 :     calc_cbp = calc_cbp_altivec;
217 : canard 76 fdct = fdct_altivec;
218 :     idct = idct_altivec;
219 : canard 115 sadInit = sadInit_altivec;
220 : canard 89 sad16 = sad16_altivec;
221 :     sad8 = sad8_altivec;
222 :     dev16 = dev16_altivec;
223 : canard 71 #else
224 : canard 52 calc_cbp = calc_cbp_ppc;
225 :     #endif
226 : canard 71 #endif
227 : Isibaar 3
228 :     // API version
229 :     init_param->api_version = API_VERSION;
230 :    
231 :     // something clever has to be done for this
232 :     init_param->core_build = 1000;
233 :    
234 :     return XVID_ERR_OK;
235 :     }
236 :    
237 :     int xvid_decore(void * handle, int opt, void * param1, void * param2)
238 :     {
239 :     switch (opt)
240 :     {
241 :     case XVID_DEC_DECODE :
242 :     return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1);
243 :    
244 :     case XVID_DEC_CREATE :
245 :     return decoder_create((XVID_DEC_PARAM *) param1);
246 :    
247 :     case XVID_DEC_DESTROY :
248 :     return decoder_destroy((DECODER *) handle);
249 :    
250 :     default:
251 :     return XVID_ERR_FAIL;
252 :     }
253 :     }
254 :    
255 :    
256 :     int xvid_encore(void * handle, int opt, void * param1, void * param2)
257 :     {
258 :     switch (opt)
259 :     {
260 :     case XVID_ENC_ENCODE :
261 :     return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, (XVID_ENC_STATS *) param2);
262 :    
263 :     case XVID_ENC_CREATE :
264 :     return encoder_create((XVID_ENC_PARAM *) param1);
265 :    
266 :     case XVID_ENC_DESTROY :
267 :     return encoder_destroy((Encoder *) handle);
268 :    
269 :     default:
270 :     return XVID_ERR_FAIL;
271 :     }
272 :     }

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