[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 398 - (view) (download)

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

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