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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 238 - (view) (download)

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

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