[cvs] / xvidcore / src / divx4.c Repository:
ViewVC logotype

Annotation of /xvidcore/src/divx4.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21.2.3 - (view) (download)

1 : edgomez 1.21.2.2 /*****************************************************************************
2 : Isibaar 1.1 *
3 : edgomez 1.13 * XVID MPEG-4 VIDEO CODEC
4 : edgomez 1.21.2.2 * - DivX 4.x compatibility layer (Deprecated and not up2date code) -
5 : Isibaar 1.1 *
6 : edgomez 1.21.2.2 * Copyright(C) 2001-2003 Peter Ross <pross@xvid.org>
7 :     * 2002-2003 Edouard Gomez <ed.gomez@free.fr>
8 : edgomez 1.18 *
9 : edgomez 1.21.2.2 * This program is free software ; you can redistribute it and/or modify
10 : edgomez 1.21 * it under the terms of the GNU General Public License as published by
11 : edgomez 1.21.2.2 * the Free Software Foundation ; either version 2 of the License, or
12 : edgomez 1.13 * (at your option) any later version.
13 :     *
14 :     * This program is distributed in the hope that it will be useful,
15 : edgomez 1.21.2.2 * but WITHOUT ANY WARRANTY ; without even the implied warranty of
16 : edgomez 1.13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 :     * GNU General Public License for more details.
18 :     *
19 :     * You should have received a copy of the GNU General Public License
20 : edgomez 1.21.2.2 * along with this program ; if not, write to the Free Software
21 :     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 : edgomez 1.21 *
23 : edgomez 1.21.2.3 * $Id: divx4.c,v 1.21.2.2 2003/06/09 13:50:12 edgomez Exp $
24 : edgomez 1.10 *
25 : edgomez 1.21.2.2 ****************************************************************************/
26 : Isibaar 1.1
27 : knhor 1.7 #include <stdlib.h>
28 : edgomez 1.9 #include <string.h>
29 : edgomez 1.11 #include <stdio.h>
30 : Isibaar 1.1
31 :     #include "xvid.h"
32 :     #include "divx4.h"
33 :     #include "decoder.h"
34 :     #include "encoder.h"
35 :    
36 :     #define EMULATED_DIVX_VERSION 20011001
37 :    
38 : edgomez 1.21.2.2 /*****************************************************************************
39 : edgomez 1.9 * Divx Instance Structure
40 :     *
41 :     * This chain list datatype allows XviD do instanciate multiples divx4
42 :     * sessions.
43 :     *
44 :     * ToDo : The way this chain list is used does not guarantee reentrance
45 :     * because they are not protected by any kind of mutex to allow
46 :     * only one modifier. We should add a mutex for each element in
47 :     * the chainlist.
48 : edgomez 1.21.2.2 ****************************************************************************/
49 : Isibaar 1.1
50 :    
51 :     typedef struct DINST
52 :     {
53 :     unsigned long key;
54 : edgomez 1.14 struct DINST *next;
55 : Isibaar 1.1
56 : edgomez 1.14 void *handle;
57 : Isibaar 1.1 XVID_DEC_FRAME xframe;
58 :    
59 : edgomez 1.14 }
60 :     DINST;
61 : Isibaar 1.1
62 : edgomez 1.11 typedef struct EINST
63 :     {
64 : edgomez 1.14 struct EINST *next;
65 : edgomez 1.11
66 : edgomez 1.14 void *handle;
67 : edgomez 1.11 int quality;
68 :    
69 : edgomez 1.14 }
70 :     EINST;
71 : edgomez 1.11
72 : edgomez 1.21.2.2 /*****************************************************************************
73 : edgomez 1.9 * Global data (needed to emulate correctly exported symbols from divx4)
74 : edgomez 1.21.2.2 ****************************************************************************/
75 : edgomez 1.9
76 :     /* This is not used in this module but is required by some divx4 encoders*/
77 :     int quiet_encore = 1;
78 :    
79 : edgomez 1.21.2.2 /*****************************************************************************
80 : edgomez 1.9 * Local data
81 : edgomez 1.21.2.2 ****************************************************************************/
82 : edgomez 1.9
83 :     /* The Divx4 instance chainlist */
84 : edgomez 1.14 static DINST *dhead = NULL;
85 :     static EINST *ehead = NULL;
86 : edgomez 1.9
87 :     /* Divx4 quality to XviD encoder motion flag presets */
88 :     static int const divx4_motion_presets[7] = {
89 : edgomez 1.14 0,
90 : edgomez 1.9
91 : edgomez 1.21 0,
92 : edgomez 1.9
93 : edgomez 1.21.2.1 XVID_ME_ADVANCEDDIAMOND16,
94 : edgomez 1.9
95 : edgomez 1.21.2.1 XVID_ME_HALFPELREFINE16,
96 : edgomez 1.9
97 : edgomez 1.21.2.1 XVID_ME_HALFPELREFINE16 | XVID_ME_HALFPELREFINE8,
98 : edgomez 1.9
99 : edgomez 1.21.2.1 XVID_ME_HALFPELREFINE16 | XVID_ME_HALFPELREFINE8,
100 : edgomez 1.9
101 : edgomez 1.21.2.1 XVID_ME_HALFPELREFINE16 | XVID_ME_EXTSEARCH16 | XVID_ME_HALFPELREFINE8
102 : edgomez 1.9 };
103 :    
104 :    
105 :     /* Divx4 quality to general encoder flag presets */
106 :     static int const divx4_general_presets[7] = {
107 : edgomez 1.14 0,
108 :     XVID_H263QUANT,
109 : edgomez 1.9 XVID_H263QUANT,
110 : edgomez 1.21.2.1 XVID_H263QUANT | XVID_VOP_HALFPEL,
111 :     XVID_H263QUANT | XVID_VOP_INTER4V | XVID_VOP_HALFPEL,
112 :     XVID_H263QUANT | XVID_VOP_INTER4V | XVID_VOP_HALFPEL,
113 :     XVID_H263QUANT | XVID_VOP_INTER4V | XVID_VOP_HALFPEL
114 : edgomez 1.9 };
115 :    
116 : edgomez 1.21.2.2 /*****************************************************************************
117 : edgomez 1.9 * Local Prototypes
118 : edgomez 1.21.2.2 ****************************************************************************/
119 : edgomez 1.9
120 :     /* Chain list helper functions */
121 : edgomez 1.14 static DINST *dinst_find(unsigned long key);
122 :     static DINST *dinst_add(unsigned long key);
123 :     static void dinst_remove(unsigned long key);
124 :    
125 :     static EINST *einst_find(void *handle);
126 :     static EINST *einst_add(void *handle);
127 :     static void einst_remove(void *handle);
128 : edgomez 1.11
129 : edgomez 1.9 /* Converts divx4 colorspaces codes to xvid codes */
130 :     static int xvid_to_opendivx_dec_csp(int csp);
131 :     static int xvid_to_opendivx_enc_csp(int csp);
132 :    
133 : edgomez 1.21.2.2 /*****************************************************************************
134 : edgomez 1.9 * decore part
135 :     *
136 :     * decore is the divx4 entry point used to decompress the mpeg4 bitstream
137 :     * into a user defined image format.
138 : edgomez 1.21.2.2 ****************************************************************************/
139 : edgomez 1.9
140 :     int
141 : edgomez 1.14 decore(unsigned long key,
142 :     unsigned long opt,
143 :     void *param1,
144 :     void *param2)
145 : edgomez 1.9 {
146 :    
147 :     int xerr;
148 :    
149 :     switch (opt) {
150 :    
151 : edgomez 1.14 case DEC_OPT_MEMORY_REQS:
152 : edgomez 1.9 {
153 : edgomez 1.14 memset(param2, 0, sizeof(DEC_MEM_REQS));
154 :     return DEC_OK;
155 : edgomez 1.9 }
156 :    
157 : edgomez 1.14 case DEC_OPT_INIT:
158 :     {
159 :     XVID_INIT_PARAM xinit;
160 :     XVID_DEC_PARAM xparam;
161 :     DINST *dcur;
162 :     DEC_PARAM *dparam = (DEC_PARAM *) param1;
163 : edgomez 1.9
164 : edgomez 1.14 /* Find the divx4 instance */
165 :     if ((dcur = dinst_find(key)) == NULL) {
166 :     dcur = dinst_add(key);
167 :     }
168 : edgomez 1.9
169 : edgomez 1.14 /*
170 :     * XviD initialization
171 :     * XviD will detect the host cpu type and activate optimized
172 :     * functions according to the host cpu features.
173 :     */
174 :     xinit.cpu_flags = 0;
175 :     xvid_init(NULL, 0, &xinit, NULL);
176 : edgomez 1.9
177 : edgomez 1.14 /* XviD decoder initialization for this instance */
178 :     xparam.width = dparam->x_dim;
179 :     xparam.height = dparam->y_dim;
180 :     dcur->xframe.colorspace =
181 :     xvid_to_opendivx_dec_csp(dparam->output_format);
182 : edgomez 1.9
183 : edgomez 1.14 xerr = decoder_create(&xparam);
184 : edgomez 1.9
185 : edgomez 1.14 /* Store the xvid handle into the divx4 instance chainlist */
186 :     dcur->handle = xparam.handle;
187 : edgomez 1.9
188 : edgomez 1.14 break;
189 :     }
190 : edgomez 1.9
191 : edgomez 1.14 case DEC_OPT_RELEASE:
192 : edgomez 1.9 {
193 : edgomez 1.14 DINST *dcur;
194 :    
195 :     /* Find the divx4 instance into the chain list */
196 :     if ((dcur = dinst_find(key)) == NULL) {
197 :     return DEC_EXIT;
198 :     }
199 : edgomez 1.9
200 : edgomez 1.14 /* Destroy the XviD decoder attached to this divx4 instance */
201 :     xerr = decoder_destroy(dcur->handle);
202 : edgomez 1.9
203 : edgomez 1.14 /* Remove the divx4 instance from the chainlist */
204 :     dinst_remove(key);
205 : edgomez 1.9
206 : edgomez 1.14 break;
207 : edgomez 1.9 }
208 :    
209 : edgomez 1.14 case DEC_OPT_SETPP:
210 : edgomez 1.9 {
211 : edgomez 1.14 DINST *dcur;
212 :    
213 :     /* Find the divx4 instance into the chain list */
214 :     if ((dcur = dinst_find(key)) == NULL) {
215 :     return DEC_EXIT;
216 :     }
217 :    
218 : edgomez 1.9 /*
219 : edgomez 1.14 * We return DEC_OK but XviD has no postprocessing implemented
220 :     * in core.
221 : edgomez 1.9 */
222 : edgomez 1.14 return DEC_OK;
223 : edgomez 1.9 }
224 :    
225 : edgomez 1.14 case DEC_OPT_SETOUT:
226 : edgomez 1.9 {
227 : edgomez 1.14 DINST *dcur;
228 :     DEC_PARAM *dparam = (DEC_PARAM *) param1;
229 :    
230 :     if ((dcur = dinst_find(key)) == NULL) {
231 :     return DEC_EXIT;
232 :     }
233 :    
234 :     /* Change the output colorspace */
235 :     dcur->xframe.colorspace =
236 :     xvid_to_opendivx_dec_csp(dparam->output_format);
237 :    
238 :     return DEC_OK;
239 : edgomez 1.9 }
240 :    
241 : edgomez 1.14 case DEC_OPT_FRAME:
242 :     {
243 :     int csp_tmp = 0;
244 :     DINST *dcur;
245 :     DEC_FRAME *dframe = (DEC_FRAME *) param1;
246 :    
247 :     if ((dcur = dinst_find(key)) == NULL) {
248 :     return DEC_EXIT;
249 :     }
250 :    
251 :     /* Copy the divx4 fields to the XviD decoder structure */
252 :     dcur->xframe.bitstream = dframe->bitstream;
253 :     dcur->xframe.length = dframe->length;
254 :     dcur->xframe.image = dframe->bmp;
255 :     dcur->xframe.stride = dframe->stride;
256 :    
257 :     /* Does the frame need to be skipped ? */
258 :     if (!dframe->render_flag) {
259 :     /*
260 :     * Then we use the null colorspace to force XviD to
261 :     * skip the frame. The original colorspace will be
262 :     * restored after the decoder call
263 :     */
264 :     csp_tmp = dcur->xframe.colorspace;
265 :     dcur->xframe.colorspace = XVID_CSP_NULL;
266 :     }
267 :    
268 :     /* Decode the bitstream */
269 : edgomez 1.21 xerr = decoder_decode(dcur->handle, &dcur->xframe, NULL);
270 : edgomez 1.14
271 :     /* Restore the real colorspace for this instance */
272 :     if (!dframe->render_flag) {
273 :     dcur->xframe.colorspace = csp_tmp;
274 :     }
275 :    
276 :     break;
277 :     }
278 : edgomez 1.9
279 : edgomez 1.14 case DEC_OPT_FRAME_311:
280 : edgomez 1.9 /* XviD does not handle Divx ;-) 3.11 yet */
281 :     return DEC_EXIT;
282 :    
283 :     case DEC_OPT_VERSION:
284 :     return EMULATED_DIVX_VERSION;
285 :    
286 : edgomez 1.14 default:
287 : edgomez 1.9 return DEC_EXIT;
288 :     }
289 :    
290 :    
291 :     /* XviD error code -> Divx4 */
292 : edgomez 1.14 switch (xerr) {
293 :     case XVID_ERR_OK:
294 : edgomez 1.9 return DEC_OK;
295 : edgomez 1.14 case XVID_ERR_MEMORY:
296 : edgomez 1.9 return DEC_MEMORY;
297 : edgomez 1.14 case XVID_ERR_FORMAT:
298 : edgomez 1.9 return DEC_BAD_FORMAT;
299 : edgomez 1.14 default:
300 : edgomez 1.9 return DEC_EXIT;
301 :     }
302 :     }
303 :    
304 : edgomez 1.21.2.2 /*****************************************************************************
305 : edgomez 1.9 * Encore Part
306 :     *
307 :     * encore is the divx4 entry point used to compress a frame to a mpeg4
308 :     * bitstream.
309 : edgomez 1.21.2.2 ****************************************************************************/
310 : edgomez 1.9
311 :     #define FRAMERATE_INCR 1001
312 :    
313 :     int
314 : edgomez 1.14 encore(void *handle,
315 :     int opt,
316 :     void *param1,
317 :     void *param2)
318 : edgomez 1.9 {
319 :    
320 :     int xerr;
321 :    
322 : edgomez 1.14 switch (opt) {
323 :     case ENC_OPT_INIT:
324 : edgomez 1.9 {
325 : edgomez 1.14 EINST *ecur;
326 :     ENC_PARAM *eparam = (ENC_PARAM *) param1;
327 :     XVID_INIT_PARAM xinit;
328 :     XVID_ENC_PARAM xparam;
329 :    
330 :     /* Init XviD which will detect host cpu features */
331 :     xinit.cpu_flags = 0;
332 :     xvid_init(NULL, 0, &xinit, NULL);
333 :    
334 :     /* Settings are copied to the XviD encoder structure */
335 :     xparam.width = eparam->x_dim;
336 :     xparam.height = eparam->y_dim;
337 :     if ((eparam->framerate - (int) eparam->framerate) == 0) {
338 :     xparam.fincr = 1;
339 :     xparam.fbase = (int) eparam->framerate;
340 :     } else {
341 :     xparam.fincr = FRAMERATE_INCR;
342 :     xparam.fbase = (int) (FRAMERATE_INCR * eparam->framerate);
343 :     }
344 :     xparam.rc_bitrate = eparam->bitrate;
345 :     xparam.rc_reaction_delay_factor = 16;
346 :     xparam.rc_averaging_period = 100;
347 :     xparam.rc_buffer = 100;
348 :     xparam.min_quantizer = eparam->min_quantizer;
349 :     xparam.max_quantizer = eparam->max_quantizer;
350 :     xparam.max_key_interval = eparam->max_key_interval;
351 : edgomez 1.21
352 :     xparam.global = 0;
353 :     xparam.max_bframes = -1; /* use "original" IP-frame encoder */
354 :     xparam.bquant_ratio = 200;
355 :     xparam.frame_drop_ratio = 0; /* dont drop frames */
356 : edgomez 1.14
357 :     /* Create the encoder session */
358 :     xerr = encoder_create(&xparam);
359 :    
360 :     eparam->handle = xparam.handle;
361 :    
362 :     /* Create an encoder instance in the chainlist */
363 :     if ((ecur = einst_find(xparam.handle)) == NULL) {
364 :     ecur = einst_add(xparam.handle);
365 :    
366 :     if (ecur == NULL) {
367 :     encoder_destroy((Encoder *) xparam.handle);
368 :     return ENC_MEMORY;
369 :     }
370 :    
371 :     }
372 : edgomez 1.9
373 : edgomez 1.14 ecur->quality = eparam->quality;
374 :     if (ecur->quality < 0)
375 :     ecur->quality = 0;
376 :     if (ecur->quality > 6)
377 :     ecur->quality = 6;
378 : edgomez 1.9
379 : edgomez 1.14 break;
380 :     }
381 : edgomez 1.9
382 : edgomez 1.14 case ENC_OPT_RELEASE:
383 : edgomez 1.11 {
384 : edgomez 1.14 EINST *ecur;
385 : edgomez 1.11
386 : edgomez 1.14 if ((ecur = einst_find(handle)) == NULL) {
387 :     return ENC_FAIL;
388 : edgomez 1.11 }
389 :    
390 : edgomez 1.14 einst_remove(handle);
391 :     xerr = encoder_destroy((Encoder *) handle);
392 :    
393 :     break;
394 : edgomez 1.11 }
395 :    
396 : edgomez 1.14 case ENC_OPT_ENCODE:
397 :     case ENC_OPT_ENCODE_VBR:
398 : edgomez 1.11 {
399 : edgomez 1.14 EINST *ecur;
400 : edgomez 1.11
401 : edgomez 1.14 ENC_FRAME *eframe = (ENC_FRAME *) param1;
402 :     ENC_RESULT *eresult = (ENC_RESULT *) param2;
403 :     XVID_ENC_FRAME xframe;
404 :     XVID_ENC_STATS xstats;
405 : edgomez 1.9
406 : edgomez 1.14 if ((ecur = einst_find(handle)) == NULL) {
407 :     return ENC_FAIL;
408 :     }
409 : edgomez 1.11
410 : edgomez 1.14 /* Copy the divx4 info into the xvid structure */
411 :     xframe.bitstream = eframe->bitstream;
412 :     xframe.length = eframe->length;
413 :     xframe.motion = divx4_motion_presets[ecur->quality];
414 :     xframe.general = divx4_general_presets[ecur->quality];
415 :    
416 :     xframe.image = eframe->image;
417 :     xframe.colorspace = xvid_to_opendivx_enc_csp(eframe->colorspace);
418 :    
419 :     if (opt == ENC_OPT_ENCODE_VBR) {
420 :     xframe.intra = eframe->intra;
421 :     xframe.quant = eframe->quant;
422 :     } else {
423 :     xframe.intra = -1;
424 :     xframe.quant = 0;
425 :     }
426 : edgomez 1.9
427 : edgomez 1.14 /* Encode the frame */
428 :     xerr =
429 :     encoder_encode((Encoder *) handle, &xframe,
430 :     (eresult ? &xstats : NULL));
431 :    
432 :     /* Copy back the xvid structure to the divx4 one */
433 :     if (eresult) {
434 :     eresult->is_key_frame = xframe.intra;
435 :     eresult->quantizer = xstats.quant;
436 :     eresult->total_bits = xframe.length * 8;
437 :     eresult->motion_bits = xstats.hlength * 8;
438 :     eresult->texture_bits =
439 :     eresult->total_bits - eresult->motion_bits;
440 :     }
441 : edgomez 1.9
442 : edgomez 1.14 eframe->length = xframe.length;
443 : edgomez 1.9
444 : edgomez 1.14 break;
445 : edgomez 1.9 }
446 :    
447 :     default:
448 :     return ENC_FAIL;
449 :     }
450 :    
451 :     /* XviD Error code -> Divx4 error code */
452 : edgomez 1.14 switch (xerr) {
453 :     case XVID_ERR_OK:
454 : edgomez 1.9 return ENC_OK;
455 : edgomez 1.14 case XVID_ERR_MEMORY:
456 : edgomez 1.9 return ENC_MEMORY;
457 : edgomez 1.14 case XVID_ERR_FORMAT:
458 : edgomez 1.9 return ENC_BAD_FORMAT;
459 : edgomez 1.14 default:
460 : edgomez 1.9 return ENC_FAIL;
461 :     }
462 :     }
463 :    
464 : edgomez 1.21.2.2 /*****************************************************************************
465 : edgomez 1.9 * Local Functions
466 : edgomez 1.21.2.2 ****************************************************************************/
467 : Isibaar 1.1
468 : edgomez 1.9 /***************************************
469 :     * DINST chainlist helper functions *
470 :     ***************************************/
471 : Isibaar 1.1
472 : edgomez 1.9 /* Find an element in the chainlist according to its key value */
473 : edgomez 1.14 static DINST *
474 :     dinst_find(unsigned long key)
475 : Isibaar 1.1 {
476 : edgomez 1.14 DINST *dcur = dhead;
477 : Isibaar 1.1
478 : edgomez 1.14 while (dcur) {
479 :     if (dcur->key == key) {
480 : Isibaar 1.1 return dcur;
481 :     }
482 :     dcur = dcur->next;
483 :     }
484 :    
485 :     return NULL;
486 :     }
487 :    
488 :    
489 : edgomez 1.9 /* Add an element to the chainlist */
490 : edgomez 1.14 static DINST *
491 :     dinst_add(unsigned long key)
492 : Isibaar 1.1 {
493 : edgomez 1.14 DINST *dnext = dhead;
494 : Isibaar 1.1
495 :     dhead = malloc(sizeof(DINST));
496 : edgomez 1.14 if (dhead == NULL) {
497 : Isibaar 1.1 dhead = dnext;
498 :     return NULL;
499 :     }
500 :    
501 :     dhead->key = key;
502 :     dhead->next = dnext;
503 :    
504 :     return dhead;
505 :     }
506 :    
507 :    
508 : edgomez 1.9 /* Remove an elmement from the chainlist */
509 : edgomez 1.14 static void
510 :     dinst_remove(unsigned long key)
511 : Isibaar 1.1 {
512 : edgomez 1.14 DINST *dcur = dhead;
513 : Isibaar 1.1
514 : edgomez 1.14 if (dhead == NULL) {
515 : Isibaar 1.1 return;
516 :     }
517 :    
518 : edgomez 1.14 if (dcur->key == key) {
519 : Isibaar 1.1 dhead = dcur->next;
520 :     free(dcur);
521 :     return;
522 :     }
523 :    
524 : edgomez 1.14 while (dcur->next) {
525 :     if (dcur->next->key == key) {
526 :     DINST *tmp = dcur->next;
527 :    
528 : Isibaar 1.1 dcur->next = tmp->next;
529 :     free(tmp);
530 :     return;
531 :     }
532 :     dcur = dcur->next;
533 :     }
534 :     }
535 :    
536 : edgomez 1.11
537 :     /***************************************
538 :     * EINST chainlist helper functions *
539 :     ***************************************/
540 :    
541 :     /* Find an element in the chainlist according to its handle */
542 : edgomez 1.14 static EINST *
543 :     einst_find(void *handle)
544 : edgomez 1.11 {
545 : edgomez 1.14 EINST *ecur = ehead;
546 : edgomez 1.11
547 : edgomez 1.14 while (ecur) {
548 :     if (ecur->handle == handle) {
549 : edgomez 1.11 return ecur;
550 :     }
551 :     ecur = ecur->next;
552 :     }
553 :    
554 :     return NULL;
555 :     }
556 :    
557 :    
558 :     /* Add an element to the chainlist */
559 : edgomez 1.14 static EINST *
560 :     einst_add(void *handle)
561 : edgomez 1.11 {
562 : edgomez 1.14 EINST *enext = ehead;
563 : edgomez 1.11
564 :     ehead = malloc(sizeof(EINST));
565 : edgomez 1.14 if (ehead == NULL) {
566 : edgomez 1.11 ehead = enext;
567 :     return NULL;
568 :     }
569 :    
570 :     ehead->handle = handle;
571 :     ehead->next = enext;
572 :    
573 :     return ehead;
574 :     }
575 :    
576 :    
577 :     /* Remove an elmement from the chainlist */
578 : edgomez 1.14 static void
579 :     einst_remove(void *handle)
580 : edgomez 1.11 {
581 : edgomez 1.14 EINST *ecur = ehead;
582 : edgomez 1.11
583 : edgomez 1.14 if (ehead == NULL) {
584 : edgomez 1.11 return;
585 :     }
586 :    
587 : edgomez 1.14 if (ecur->handle == handle) {
588 : edgomez 1.11 ehead = ecur->next;
589 :     free(ecur);
590 :     return;
591 :     }
592 :    
593 : edgomez 1.14 while (ecur->next) {
594 :     if (ecur->next->handle == handle) {
595 :     EINST *tmp = ecur->next;
596 :    
597 : edgomez 1.11 ecur->next = tmp->next;
598 :     free(tmp);
599 :     return;
600 :     }
601 :     ecur = ecur->next;
602 :     }
603 :     }
604 : edgomez 1.14
605 : edgomez 1.9 /***************************************
606 :     * Colorspace code converter *
607 :     ***************************************/
608 : Isibaar 1.1
609 : edgomez 1.14 static int
610 :     xvid_to_opendivx_dec_csp(int csp)
611 : Isibaar 1.1 {
612 : edgomez 1.9
613 : edgomez 1.14 switch (csp) {
614 :     case DEC_YV12:
615 : Isibaar 1.1 return XVID_CSP_YV12;
616 : edgomez 1.14 case DEC_420:
617 : Isibaar 1.1 return XVID_CSP_I420;
618 : edgomez 1.14 case DEC_YUY2:
619 : Isibaar 1.1 return XVID_CSP_YUY2;
620 : edgomez 1.14 case DEC_UYVY:
621 : Isibaar 1.1 return XVID_CSP_UYVY;
622 : edgomez 1.14 case DEC_RGB32:
623 : Isibaar 1.1 return XVID_CSP_VFLIP | XVID_CSP_RGB32;
624 : edgomez 1.14 case DEC_RGB24:
625 : Isibaar 1.1 return XVID_CSP_VFLIP | XVID_CSP_RGB24;
626 : edgomez 1.14 case DEC_RGB565:
627 : Isibaar 1.1 return XVID_CSP_VFLIP | XVID_CSP_RGB565;
628 : edgomez 1.14 case DEC_RGB555:
629 : Isibaar 1.1 return XVID_CSP_VFLIP | XVID_CSP_RGB555;
630 : edgomez 1.14 case DEC_RGB32_INV:
631 : Isibaar 1.1 return XVID_CSP_RGB32;
632 : edgomez 1.14 case DEC_RGB24_INV:
633 : Isibaar 1.1 return XVID_CSP_RGB24;
634 : edgomez 1.14 case DEC_RGB565_INV:
635 : Isibaar 1.1 return XVID_CSP_RGB565;
636 : edgomez 1.14 case DEC_RGB555_INV:
637 : Isibaar 1.1 return XVID_CSP_RGB555;
638 : edgomez 1.14 case DEC_USER:
639 :     return XVID_CSP_USER;
640 :     default:
641 : Isibaar 1.1 return -1;
642 :     }
643 :     }
644 :    
645 : edgomez 1.14 static int
646 :     xvid_to_opendivx_enc_csp(int csp)
647 : Isibaar 1.1 {
648 :    
649 : edgomez 1.14 switch (csp) {
650 :     case ENC_CSP_RGB24:
651 : edgomez 1.9 return XVID_CSP_VFLIP | XVID_CSP_RGB24;
652 : edgomez 1.14 case ENC_CSP_YV12:
653 : edgomez 1.9 return XVID_CSP_YV12;
654 : edgomez 1.14 case ENC_CSP_YUY2:
655 : edgomez 1.9 return XVID_CSP_YUY2;
656 : edgomez 1.14 case ENC_CSP_UYVY:
657 : edgomez 1.9 return XVID_CSP_UYVY;
658 : edgomez 1.14 case ENC_CSP_I420:
659 : edgomez 1.9 return XVID_CSP_I420;
660 : edgomez 1.14 default:
661 : edgomez 1.9 return -1;
662 : Isibaar 1.1 }
663 :     }

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