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

Annotation of /xvidcore/src/divx4.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (view) (download)

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

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